(()=>{vare,i,s,n={958:(e,i,s)=>{"use strict";varn=s(53334),a=s(85471),r=s(9165),o=s(21777),l=s(19051),d=s(87485),c=s(85168),u=s(61338),p=s(35810),f=s(71225),h=s(63814),g=s(40715),m=s(74692),y=s.n(m),b=s(57505),A=s(29333),v=s(4604),w=s(11275),_=s(6695),C=s(77764),T=s(81222),S=s(88289),I=s(5212),L=s(1822);constx=(0,L.c)();asyncfunctionF(e){constt=(0,L.l)(),i=awaitx.stat(`${(0,L.g)()}${e}`,{details:!0,data:t});return(0,L.r)(i.data)}varO=s(35947);constH=(0,O.YK)().setApp("systemtags").detectUser().build();s(12555);varE=s(71654);constV={userVisible:!0,userAssignable:!0,canAssign:!0};functionM(e){returne.map(({props:e})=>Object.fromEntries(Object.entries(e).map(([e,t])=>[(0,E.A)(e),"displayName"===(0,E.A)(e)?String(t):t])))}functionN(e){if("name"ine&&!("displayName"ine))return{...e};constt={...e};returnt.name=t.displayName,deletet.displayName,t}vark=s(60669);constD=(0,h.dC)("dav"),P=(0,k.UU)(D);functionB(e){P.setHeaders({"X-Requested-With":"XMLHttpRequest",requesttoken:e??""})}(0,o.zo)(B),B((0,o.do)());const$='<?xml version="1.0"?>\n<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">\n\t<d:prop>\n\t\t<oc:id />\n\t\t<oc:display-name />\n\t\t<oc:user-visible />\n\t\t<oc:user-assignable />\n\t\t<oc:can-assign />\n\t\t<d:getetag />\n\t\t<nc:color />\n\t</d:prop>\n</d:propfind>';asyncfunctionU(e){constt="/systemtags-relations/files/"+e;try{const{data:e}=awaitP.getDirectoryContents(t,{data:$,details:!0,glob:"/systemtags-relations/files/*/*"});returnM(e)}catch(e){throwH.error((0,n.t)("systemtags","Failed to load tags for file"),{error:e}),newError((0,n.t)("systemtags","Failed to load tags for file"))}}asyncfunctionj(e,t){consti="/systemtags-relations/files/"+t+"/"+e.id,s=N(e);try{awaitP.customRequest(i,{method:"PUT",data:s})}catch(e){throwH.error((0,n.t)("systemtags","Failed to set tag for file"),{error:e}),newError((0,n.t)("systemtags","Failed to set tag for file"))}}constR=a.Ay.extend({name:"SystemTags",components:{NcLoadingIcon:S.A,NcSelectTags:I.A},props:{fileId:{type:Number,required:!0},disabled:{type:Boolean,default:!1}},data:()=>({sortedTags:[],selectedTags:[],loadingTags:!1,loading:!1}),watch:{fileId:{immediate:!0,asynchandler(){this.loadingTags=!0;try{this.selectedTags=awaitU(this.fileId)}catch(e){(0,c.Qg)((0,n.t)("systemtags","Failed to load selected tags")),H.error("Failed to load selected tags",{error:e})}this.loadingTags=!1}}},asynccreated(){try{conste=awaitasyncfunction(){try{const{data:e}=awaitP.getDirectoryContents("/systemtags",{data:$,details:!0,glob:"/systemtags/*"});returnM(e)}catch(e){throwH.error((0,n.t)("systemtags","Failed to load tags"),{error:e}),newError((0,n.t)("systemtags","Failed to load tags"))}}(),t=awaitasyncfunction(){conste=(0,h.Jv)("/apps/systemtags/lastused");try{const{data:t}=awaitl.Ay.get(e);returnt.map(Number)}catch(e){throwH.error((0,n.t)("systemtags","Failed to load last used tags"),{error:e}),newError((0,n.t)("systemtags","Failed to load last used tags"))}}(),i=[],s=[];for(constnofe)t.includes(n.id)?i.push(n):s.push(n);consta=(e,i)=>t.indexOf(e.id)-t.indexOf(i.id);i.sort(a),this.sortedTags=[...i,...s]}catch(e){(0,c.Qg)((0,n.t)("systemtags","Failed to load tags")),H.error("Failed to load tags",{error:e})}},mounted(){(0,u.B1)("systemtags:node:updated",this.onTagUpdated)},methods:{t:n.t,createOption(e){for(consttofthis.sortedTags){const{displayName:i,...s}=t;if(i===e&&Object.entries(s).every(([e,t])=>V[e]===t))returnt}return{...V,displayName:e}},handleInput(e){this.selectedTags=e.filter(e=>Boolean(e.id))},asynchandleSelect(e){constt=e[e.length-1];if(!t.id)return;consti=t;this.loading=!0;try{awaitj(i,this.fileId);conste=(e,t)=>e.id===i.id?-1:t.id===i.id?1:0;this.sortedTags.sort(e)}catch(e){(0,c.Qg)((0,n.t)("systemtags","Failed to select tag")),H.error("Failed to select tag",{error:e})}this.loading=!1,this.updateAndDispatchNodeTagsEvent(this.fileId)},asynchandleCreate(e){this.loading=!0;try{constt=awaitasyncfunction(e,t){consti=N(e),s=awaitasyncfunction(e){constt=N(e);try{const