/*! For license information please see files_sharing-files_sharing.js.LICENSE.txt */ (()=>{"use strict";var e,t={64123:(e,t,i)=>{var r,n,s,o=i(31352),a=i(77958),l=i(17499),d=i(62520);null===(r=(0,a.ts)())?(0,l.IY)().setApp("files").build():(0,l.IY)().setApp("files").setUid(r.uid).build(),function(e){e.Folder="folder",e.File="file"}(n||(n={})),function(e){e[e.NONE=0]="NONE",e[e.CREATE=4]="CREATE",e[e.READ=1]="READ",e[e.UPDATE=2]="UPDATE",e[e.DELETE=8]="DELETE",e[e.SHARE=16]="SHARE",e[e.ALL=31]="ALL"}(s||(s={}));const h=function(e,t){return null!==e.match(t)},u=(e,t)=>{if("id"in e&&("number"!=typeof e.id||e.id<0))throw new Error("Invalid id type of value");if(!e.source)throw new Error("Missing mandatory source");try{new URL(e.source)}catch(e){throw new Error("Invalid source format, source must be a valid URL")}if(!e.source.startsWith("http"))throw new Error("Invalid source format, only http(s) is supported");if("mtime"in e&&!(e.mtime instanceof Date))throw new Error("Invalid mtime type");if("crtime"in e&&!(e.crtime instanceof Date))throw new Error("Invalid crtime type");if(!e.mime||"string"!=typeof e.mime||!e.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))throw new Error("Missing or invalid mandatory mime");if("size"in e&&"number"!=typeof e.size)throw new Error("Invalid size type");if("permissions"in e&&!("number"==typeof e.permissions&&e.permissions>=s.NONE&&e.permissions<=s.ALL))throw new Error("Invalid permissions");if("owner"in e&&null!==e.owner&&"string"!=typeof e.owner)throw new Error("Invalid owner type");if("attributes"in e&&"object"!=typeof e.attributes)throw new Error("Invalid attributes format");if("root"in e&&"string"!=typeof e.root)throw new Error("Invalid root format");if(e.root&&!e.root.startsWith("/"))throw new Error("Root must start with a leading slash");if(e.root&&!e.source.includes(e.root))throw new Error("Root must be part of the source");if(e.root&&h(e.source,t)){const i=e.source.match(t)[0];if(!e.source.includes((0,d.join)(i,e.root)))throw new Error("The root must be relative to the service. e.g /files/emma")}};class c{_data;_attributes;_knownDavService=/(remote|public)\.php\/(web)?dav/i;constructor(e,t){u(e,t||this._knownDavService),this._data=e;const i={set:(e,t,i)=>(this._data.mtime=new Date,Reflect.set(e,t,i)),deleteProperty:(e,t)=>(this._data.mtime=new Date,Reflect.deleteProperty(e,t))};this._attributes=new Proxy(e.attributes||{},i),delete this._data.attributes,t&&(this._knownDavService=t)}get source(){return this._data.source.replace(/\/$/i,"")}get basename(){return(0,d.basename)(this.source)}get extension(){return(0,d.extname)(this.source)}get dirname(){if(this.root){const e=this.source.indexOf(this.root);return(0,d.dirname)(this.source.slice(e+this.root.length)||"/")}const e=new URL(this.source);return(0,d.dirname)(e.pathname)}get mime(){return this._data.mime}get mtime(){return this._data.mtime}get crtime(){return this._data.crtime}get size(){return this._data.size}get attributes(){return this._attributes}get permissions(){return null!==this.owner||this.isDavRessource?void 0!==this._data.permissions?this._data.permissions:s.NONE:s.READ}get owner(){return this.isDavRessource?this._data.owner:null}get isDavRessource(){return h(this.source,this._knownDavService)}get root(){return this._data.root?this._data.root.replace(/^(.+)\/$/,"$1"):this.isDavRessource&&(0,d.dirname)(this.source).split(this._knownDavService).pop()||null}get path(){if(this.root){const e=this.source.indexOf(this.root);return this.source.slice(e+this.root.length)||"/"}return(this.dirname+"/"+this.basename).replace(/\/\//g,"/")}get fileid(){return this._data?.id||this.attributes?.fileid}move(e){u({...this._data,source:e},this._knownDavService),this._data.source=e,this._data.mtime=new Date}rename(e){if(e.includes("/"))throw new Error("Invalid basename");this.move((0,d.dirname)(this.source)+"/"+e)}}class p extends c{get type(){return n.File}}class f extends c{constructor(e){super({...e,mime:"httpd/unix-directory"})}get type(){return n.Folder}get extension(){return null}get mime(){return"httpd/unix-directory"}}var g=i(79753),m=i(26937);const w=(0,l.IY)().setApp("files_sharing").detectUser().build();var v;const _="/files/".concat(null===(v=(0,a.ts)())||void 0===v?void 0:v.uid),y={"Content-Type":"application/json"},b=function(e){try{var t;const i="folder"===(null==e?void 0:e.item_type),r=!0===(null==e?void 0:e.has_preview),n=i?f:p,s=e.file_source,o=r?(0,g.generateUrl)("/core/preview?fileId={fileid}&x=32&y=32&forceIcon=0",{fileid:s}):void 0,a=(null==e?void 0:e.path)||e.file_target,l=(0,g.generateRemoteUrl)("dav/".concat(_,"/").concat(a).replaceAll(/\/\//gm,"/"));let d=null!=e&&e.item_mtime?new Date(1e3*e.item_mtime):void 0;return(null==e?void 0:e.stime)>((null==e?void 0:e.item_mtime)||0)&&(d=new Date(1e3*e.stime)),new n({id:s,source:l,owner:null==e?void 0:e.uid_owner,mime:null==e?void 0:e.mimetype,mtime:d,size:null==e?void 0:e.item_size,permissions:(null==e?void 0:e.item_permissions)||(null==e?void 0:e.permissions),root:_,attributes:{...e,previewUrl:o,"has-preview":r,favorite:null!=e&&null!==(t=e.tags)&&void 0!==t&&t.includes(window.OC.TAG_FAVORITE)?1:0}})}catch(e){return w.error("Error while parsing OCS entry",{error:e}),null}},I=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/shares");return m.Z.get(t,{headers:y,params:{shared_with_me:e,include_tags:!0}})},C=async function(){var e;let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];const s=[];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&s.push(I(!0),function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/remote_shares");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}()),t&&s.push(I()),i&&s.push(function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/shares/pending");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}(),function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/remote_shares/pending");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}()),r&&s.push(function(){const e=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/deletedshares");return m.Z.get(e,{headers:y,params:{include_tags:!0}})}());let o=(await Promise.all(s)).map((e=>e.data.ocs.data)).flat().map(b).filter((e=>null!==e));return n.length>0&&(o=o.filter((e=>{var t;return n.includes(null===(t=e.attributes)||void 0===t?void 0:t.share_type)}))),{folder:new f({id:0,source:(0,g.generateRemoteUrl)("dav"+_),owner:(null===(e=(0,a.ts)())||void 0===e?void 0:e.uid)||null}),contents:o}},E="shareoverview",x="sharingin",A="sharingout",L="sharinglinks",O="deletedshares",S="pendingshares";var H=i(69183);const R=(0,l.IY)().setApp("files").detectUser().build();var D;!function(e){e.DEFAULT="default",e.HIDDEN="hidden"}(D||(D={}));class N{constructor(e){var t,i,r;t=this,r=void 0,(i=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(i="_action"))in t?Object.defineProperty(t,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[i]=r,this.validateAction(e),this._action=e}get id(){return this._action.id}get displayName(){return this._action.displayName}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get default(){return this._action.default}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(e){if(!e.id||"string"!=typeof e.id)throw new Error("Invalid id");if(!e.displayName||"function"!=typeof e.displayName)throw new Error("Invalid displayName function");if(!e.iconSvgInline||"function"!=typeof e.iconSvgInline)throw new Error("Invalid iconSvgInline function");if(!e.exec||"function"!=typeof e.exec)throw new Error("Invalid exec function");if("enabled"in e&&"function"!=typeof e.enabled)throw new Error("Invalid enabled function");if("execBatch"in e&&"function"!=typeof e.execBatch)throw new Error("Invalid execBatch function");if("order"in e&&"number"!=typeof e.order)throw new Error("Invalid order");if(e.default&&!Object.values(D).includes(e.default))throw new Error("Invalid default");if("inline"in e&&"function"!=typeof e.inline)throw new Error("Invalid inline function");if("renderInline"in e&&"function"!=typeof e.renderInline)throw new Error("Invalid renderInline function")}}const M=function(e){void 0===window._nc_fileactions&&(window._nc_fileactions=[],R.debug("FileActions initialized")),window._nc_fileactions.find((t=>t.id===e.id))?R.error("FileAction ".concat(e.id," already registered"),{action:e}):window._nc_fileactions.push(e)};M(new N({id:"accept-share",displayName:e=>(0,o.uN)("files_sharing","Accept share","Accept shares",e.length),iconSvgInline:()=>'',enabled:(e,t)=>e.length>0&&t.id===S,async exec(e){try{const t=!!e.attributes.remote,i=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/{shareBase}/pending/{id}",{shareBase:t?"remote_shares":"shares",id:e.attributes.id});return await m.Z.post(i),(0,H.j8)("files:node:deleted",e),!0}catch(e){return!1}},async execBatch(e,t,i){return Promise.all(e.map((e=>this.exec(e,t,i))))},order:1,inline:()=>!0})),M(new N({id:"open-in-files",displayName:()=>(0,o.Iu)("files","Open in files"),iconSvgInline:()=>"",enabled:(e,t)=>[E,x,A,L].includes(t.id),exec:async e=>(window.OCP.Files.Router.goToRoute(null,{view:"files",fileid:e.fileid},{dir:e.dirname,fileid:e.fileid}),null),default:D.HIDDEN,order:-1e3})),M(new N({id:"reject-share",displayName:e=>(0,o.uN)("files_sharing","Reject share","Reject shares",e.length),iconSvgInline:()=>'',enabled:(e,t)=>t.id===S&&0!==e.length&&!e.some((e=>e.attributes.remote_id&&e.attributes.share_type===window.OC.Share.SHARE_TYPE_REMOTE_GROUP)),async exec(e){try{const t=!!e.attributes.remote,i=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/{shareBase}/{id}",{shareBase:t?"remote_shares":"shares",id:e.attributes.id});return await m.Z.delete(i),(0,H.j8)("files:node:deleted",e),!0}catch(e){return!1}},async execBatch(e,t,i){return Promise.all(e.map((e=>this.exec(e,t,i))))},order:2,inline:()=>!0})),M(new N({id:"restore-share",displayName:e=>(0,o.uN)("files_sharing","Restore share","Restore shares",e.length),iconSvgInline:()=>'',enabled:(e,t)=>e.length>0&&t.id===O,async exec(e){try{const t=(0,g.generateOcsUrl)("apps/files_sharing/api/v1/deletedshares/{id}",{id:e.attributes.id});return await m.Z.post(t),(0,H.j8)("files:node:deleted",e),!0}catch(e){return!1}},async execBatch(e,t,i){return Promise.all(e.map((e=>this.exec(e,t,i))))},order:1,inline:()=>!0})),(()=>{const e=window.OCP.Files.Navigation;e.register({id:E,name:(0,o.Iu)("files_sharing","Shares"),caption:(0,o.Iu)("files_sharing","Overview of shared files."),emptyTitle:(0,o.Iu)("files_sharing","No shares"),emptyCaption:(0,o.Iu)("files_sharing","Files and folders you shared or have been shared with you will show up here"),icon:'',order:20,columns:[],getContents:()=>C()}),e.register({id:x,name:(0,o.Iu)("files_sharing","Shared with you"),caption:(0,o.Iu)("files_sharing","List of files that are shared with you."),emptyTitle:(0,o.Iu)("files_sharing","Nothing shared with you yet"),emptyCaption:(0,o.Iu)("files_sharing","Files and folders others shared with you will show up here"),icon:'',order:1,parent:E,columns:[],getContents:()=>C(!0,!1,!1,!1)}),e.register({id:A,name:(0,o.Iu)("files_sharing","Shared with others"),caption:(0,o.Iu)("files_sharing","List of files that you shared with others."),emptyTitle:(0,o.Iu)("files_sharing","Nothing shared yet"),emptyCaption:(0,o.Iu)("files_sharing","Files and folders you shared will show up here"),icon:'',order:2,parent:E,columns:[],getContents:()=>C(!1,!0,!1,!1)}),e.register({id:L,name:(0,o.Iu)("files_sharing","Shared by link"),caption:(0,o.Iu)("files_sharing","List of files that are shared by link."),emptyTitle:(0,o.Iu)("files_sharing","No shared links"),emptyCaption:(0,o.Iu)("files_sharing","Files and folders you shared by link will show up here"),icon:'',order:3,parent:E,columns:[],getContents:()=>C(!1,!0,!1,!1,[window.OC.Share.SHARE_TYPE_LINK])}),e.register({id:O,name:(0,o.Iu)("files_sharing","Deleted shares"),caption:(0,o.Iu)("files_sharing","List of shares you left."),emptyTitle:(0,o.Iu)("files_sharing","No deleted shares"),emptyCaption:(0,o.Iu)("files_sharing","Shares you have left will show up here"),icon:'',order:4,parent:E,columns:[],getContents:()=>C(!1,!1,!1,!0)}),e.register({id:S,name:(0,o.Iu)("files_sharing","Pending shares"),caption:(0,o.Iu)("files_sharing","List of unapproved shares."),emptyTitle:(0,o.Iu)("files_sharing","No pending shares"),emptyCaption:(0,o.Iu)("files_sharing","Shares you have received but not approved will show up here"),icon:'',order:5,parent:E,columns:[],getContents:()=>C(!1,!1,!0,!1)})})()}},i={};function r(e){var n=i[e];if(void 0!==n)return n.exports;var s=i[e]={id:e,loaded:!1,exports:{}};return t[e].call(s.exports,s,s.exports,r),s.loaded=!0,s.exports}r.m=t,e=[],r.O=(t,i,n,s)=>{if(!i){var o=1/0;for(h=0;h=s)&&Object.keys(r.O).every((e=>r.O[e](i[l])))?i.splice(l--,1):(a=!1,s0&&e[h-1][2]>s;h--)e[h]=e[h-1];e[h]=[i,n,s]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),r.j=6691,(()=>{r.b=document.baseURI||self.location.href;var e={6691:0};r.O.j=t=>0===e[t];var t=(t,i)=>{var n,s,o=i[0],a=i[1],l=i[2],d=0;if(o.some((t=>0!==e[t]))){for(n in a)r.o(a,n)&&(r.m[n]=a[n]);if(l)var h=l(r)}for(t&&t(i);dr(64123)));n=r.O(n)})(); //# sourceMappingURL=files_sharing-files_sharing.js.map?v=ee51fe58f7ba7de90a86