/*! For license information please see files_sharing-init.js.LICENSE.txt */
(()=>{"use strict";var e,t,i,n={70370:(e,t,i)=>{var n=i(31346),r=i(53334);const s='',a='',o='';var l=i(63814),d=i(21777),h=i(65043),u=i(35947);const c=(0,u.YK)().setApp("files_sharing").detectUser().build();var p;const g="/files/".concat(null===(p=(0,d.HW)())||void 0===p?void 0:p.uid),v={"Content-Type":"application/json"},m=async function(e){try{var t;if(void 0!==(null==e?void 0:e.remote_id)){if(!e.mimetype){const t=(await i.e(857).then(i.bind(i,10857))).default;e.mimetype=t.getType(e.name)}e.item_type=e.type||(e.mimetype?"file":"folder"),e.item_mtime=e.mtime,e.file_target=e.file_target||e.mountpoint,e.item_permissions=n.aX.NONE,e.permissions=n.aX.NONE,e.uid_owner=e.owner,e.displayname_owner=e.owner}const r="folder"===(null==e?void 0:e.item_type),s=!0===(null==e?void 0:e.has_preview),a=r?n.vd:n.ZH,o=e.file_source||e.file_id||e.id,d=e.path||e.file_target||e.name,h=(0,l.dC)("dav/".concat(g,"/").concat(d).replaceAll(/\/\//gm,"/"));let u=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)&&(u=new Date(1e3*e.stime)),new a({id:o,source:h,owner:null==e?void 0:e.uid_owner,mime:(null==e?void 0:e.mimetype)||"application/octet-stream",mtime:u,size:null==e?void 0:e.item_size,permissions:(null==e?void 0:e.item_permissions)||(null==e?void 0:e.permissions),root:g,attributes:{...e,"has-preview":s,"owner-id":null==e?void 0:e.uid_owner,"owner-display-name":null==e?void 0:e.displayname_owner,"share-types":null==e?void 0:e.share_type,"share-attributes":(null==e?void 0:e.attributes)||"[]",favorite:null!=e&&null!==(t=e.tags)&&void 0!==t&&t.includes(window.OC.TAG_FAVORITE)?1:0}})}catch(e){return c.error("Error while parsing OCS entry",{error:e}),null}},w=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=(0,l.KT)("apps/files_sharing/api/v1/shares");return h.Ay.get(t,{headers:v,params:{shared_with_me:e,include_tags:!0}})},f=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],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];const a=[];(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&a.push(w(!0),function(){const e=(0,l.KT)("apps/files_sharing/api/v1/remote_shares");return h.Ay.get(e,{headers:v,params:{include_tags:!0}})}()),t&&a.push(w()),i&&a.push(function(){const e=(0,l.KT)("apps/files_sharing/api/v1/shares/pending");return h.Ay.get(e,{headers:v,params:{include_tags:!0}})}(),function(){const e=(0,l.KT)("apps/files_sharing/api/v1/remote_shares/pending");return h.Ay.get(e,{headers:v,params:{include_tags:!0}})}()),r&&a.push(function(){const e=(0,l.KT)("apps/files_sharing/api/v1/deletedshares");return h.Ay.get(e,{headers:v,params:{include_tags:!0}})}());const o=(await Promise.all(a)).map((e=>e.data.ocs.data)).flat();let u=(await Promise.all(o.map(m))).filter((e=>null!==e));var c,p;return s.length>0&&(u=u.filter((e=>{var t;return s.includes(null===(t=e.attributes)||void 0===t?void 0:t.share_type)}))),u=(c=u,p="source",Object.values(c.reduce((function(e,t){return(e[t[p]]=e[t[p]]||[]).push(t),e}),{}))).map((e=>{const t=e[0];return t.attributes["share-types"]=e.map((e=>e.attributes["share-types"])),t})),{folder:new n.vd({id:0,source:(0,l.dC)("dav"+g),owner:(null===(e=(0,d.HW)())||void 0===e?void 0:e.uid)||null}),contents:u}},A="shareoverview",y="sharingin",_="sharingout",C="sharinglinks",b="deletedshares",T="pendingshares";var x=i(61338);const S=new n.hY({id:"accept-share",displayName:e=>(0,r.zw)("files_sharing","Accept share","Accept shares",e.length),iconSvgInline:()=>'',enabled:(e,t)=>e.length>0&&t.id===T,async exec(e){try{const t=!!e.attributes.remote,i=(0,l.KT)("apps/files_sharing/api/v1/{shareBase}/pending/{id}",{shareBase:t?"remote_shares":"shares",id:e.attributes.id});return await h.Ay.post(i),(0,x.Ic)("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});(0,n.Gg)(S);const H=new n.hY({id:"open-in-files",displayName:()=>(0,r.Tl)("files","Open in Files"),iconSvgInline:()=>"",enabled:(e,t)=>[A,y,_,C].includes(t.id),async exec(e){const t=e.type===n.pt.Folder;return window.OCP.Files.Router.goToRoute(null,{view:"files",fileid:String(e.fileid)},{dir:t?e.path:e.dirname,openfile:t?void 0:"true"}),null},order:-1e3,default:n.m9.HIDDEN});(0,n.Gg)(H);const L=new n.hY({id:"reject-share",displayName:e=>(0,r.zw)("files_sharing","Reject share","Reject shares",e.length),iconSvgInline:()=>'',enabled:(e,t)=>t.id===T&&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,l.KT)("apps/files_sharing/api/v1/{shareBase}/{id}",{shareBase:t?"remote_shares":"shares",id:e.attributes.id});return await h.Ay.delete(i),(0,x.Ic)("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});(0,n.Gg)(L);const E=new n.hY({id:"restore-share",displayName:e=>(0,r.zw)("files_sharing","Restore share","Restore shares",e.length),iconSvgInline:()=>'',enabled:(e,t)=>e.length>0&&t.id===b,async exec(e){try{const t=(0,l.KT)("apps/files_sharing/api/v1/deletedshares/{id}",{id:e.attributes.id});return await h.Ay.post(t),(0,x.Ic)("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});(0,n.Gg)(E);var O=i(77905),M=i(49981);const V=(0,u.YK)().setApp("files").detectUser().build(),N=new n.hY({id:"details",displayName:()=>(0,r.Tl)("files","Open details"),iconSvgInline:()=>M,enabled:e=>{var t,i,r;return 1===e.length&&!!e[0]&&!(null===(t=window)||void 0===t||null===(t=t.OCA)||void 0===t||null===(t=t.Files)||void 0===t||!t.Sidebar)&&null!==(i=(null===(r=e[0].root)||void 0===r?void 0:r.startsWith("/files/"))&&e[0].permissions!==n.aX.NONE)&&void 0!==i&&i},async exec(e,t,i){try{return await window.OCA.Files.Sidebar.open(e.path),window.OCP.Files.Router.goToRoute(null,{view:t.id,fileid:e.fileid},{...window.OCP.Files.Router.query,dir:i},!0),null}catch(e){return V.error("Error while opening sidebar",{error:e}),!1}},order:-50});var P=i(85072),R=i.n(P),k=i(97825),B=i.n(k),I=i(77659),Y=i.n(I),j=i(55056),F=i.n(j),G=i(10540),Z=i.n(G),U=i(41113),K=i.n(U),D=i(8132),W={};W.styleTagTransform=K(),W.setAttributes=F(),W.insert=Y().bind(null,"head"),W.domAPI=B(),W.insertStyleElement=Z(),R()(D.A,W),D.A&&D.A.locals&&D.A.locals;const z=e=>void 0!==e.attributes.remote_id,q=new n.hY({id:"sharing-status",displayName(e){var t,i;const n=e[0];return Object.values((null==n||null===(t=n.attributes)||void 0===t?void 0:t["share-types"])||{}).flat().length>0||n.owner!==(null===(i=(0,d.HW)())||void 0===i?void 0:i.uid)||z(n)?(0,r.Tl)("files_sharing","Shared"):""},title(e){var t,i,n;const s=e[0];if(Array.isArray(null===(t=s.attributes)||void 0===t?void 0:t["share-types"])&&(null===(i=s.attributes)||void 0===i?void 0:i["share-types"].length)>1)return(0,r.Tl)("files_sharing","Shared multiple times with different people");if(s.owner&&(s.owner!==(null===(n=(0,d.HW)())||void 0===n?void 0:n.uid)||z(s))){var a;const e=null==s||null===(a=s.attributes)||void 0===a?void 0:a["owner-display-name"];return(0,r.Tl)("files_sharing","Shared by {ownerDisplayName}",{ownerDisplayName:e})}return(0,r.Tl)("files_sharing","Show sharing options")},iconSvgInline(e){var t,i,n,r;const h=e[0],u=Object.values((null==h||null===(t=h.attributes)||void 0===t?void 0:t["share-types"])||{}).flat();return Array.isArray(null===(i=h.attributes)||void 0===i?void 0:i["share-types"])&&(null===(n=h.attributes)||void 0===n?void 0:n["share-types"].length)>1?a:u.includes(O.Z.SHARE_TYPE_LINK)||u.includes(O.Z.SHARE_TYPE_EMAIL)?o:u.includes(O.Z.SHARE_TYPE_GROUP)||u.includes(O.Z.SHARE_TYPE_REMOTE_GROUP)?s:u.includes(O.Z.SHARE_TYPE_CIRCLE)?'':h.owner&&(h.owner!==(null===(r=(0,d.HW)())||void 0===r?void 0:r.uid)||z(h))?function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=t?"/avatar/guest/".concat(e):"/avatar/".concat(e),n=!0===(null===(r=window)||void 0===r||null===(s=r.matchMedia)||void 0===s||null===(s=s.call(r,"(prefers-color-scheme: dark)"))||void 0===s?void 0:s.matches)||null!==document.querySelector("[data-themes*=dark]")?"/dark":"";var r,s;const a=t?"":"?guestFallback=true",o="".concat(i,"/32").concat(n).concat(a),d=(0,l.Jv)(o,{userId:e});return'')}(h.owner.replace(/[^a-zA-Z0-9._%+@-]+/g,"").replace(/\//g,""),z(h)):a},enabled(e){var t,i;if(1!==e.length)return!1;const r=e[0],s=null===(t=r.attributes)||void 0===t?void 0:t["share-types"];return!!(Array.isArray(s)&&s.length>0)||!(!r.owner||r.owner===(null===(i=(0,d.HW)())||void 0===i?void 0:i.uid)&&!z(r))||0!=(r.permissions&n.aX.SHARE)},async exec(e,t,i){var r,s;return 0!=(e.permissions&n.aX.READ)?(null===(r=window.OCA)||void 0===r||null===(r=r.Files)||void 0===r||null===(r=r.Sidebar)||void 0===r||null===(s=r.setActiveTab)||void 0===s||s.call(r,"sharing"),N.exec(e,t,i)):null},inline:()=>!0});(0,n.Gg)(q),(()=>{const e=(0,n.bh)();e.register(new n.Ss({id:A,name:(0,r.Tl)("files_sharing","Shares"),caption:(0,r.Tl)("files_sharing","Overview of shared files."),emptyTitle:(0,r.Tl)("files_sharing","No shares"),emptyCaption:(0,r.Tl)("files_sharing","Files and folders you shared or have been shared with you will show up here"),icon:a,order:20,columns:[],getContents:()=>f()})),e.register(new n.Ss({id:y,name:(0,r.Tl)("files_sharing","Shared with you"),caption:(0,r.Tl)("files_sharing","List of files that are shared with you."),emptyTitle:(0,r.Tl)("files_sharing","Nothing shared with you yet"),emptyCaption:(0,r.Tl)("files_sharing","Files and folders others shared with you will show up here"),icon:'',order:1,parent:A,columns:[],getContents:()=>f(!0,!1,!1,!1)})),e.register(new n.Ss({id:_,name:(0,r.Tl)("files_sharing","Shared with others"),caption:(0,r.Tl)("files_sharing","List of files that you shared with others."),emptyTitle:(0,r.Tl)("files_sharing","Nothing shared yet"),emptyCaption:(0,r.Tl)("files_sharing","Files and folders you shared will show up here"),icon:s,order:2,parent:A,columns:[],getContents:()=>f(!1,!0,!1,!1)})),e.register(new n.Ss({id:C,name:(0,r.Tl)("files_sharing","Shared by link"),caption:(0,r.Tl)("files_sharing","List of files that are shared by link."),emptyTitle:(0,r.Tl)("files_sharing","No shared links"),emptyCaption:(0,r.Tl)("files_sharing","Files and folders you shared by link will show up here"),icon:o,order:3,parent:A,columns:[],getContents:()=>f(!1,!0,!1,!1,[window.OC.Share.SHARE_TYPE_LINK])})),e.register(new n.Ss({id:b,name:(0,r.Tl)("files_sharing","Deleted shares"),caption:(0,r.Tl)("files_sharing","List of shares you left."),emptyTitle:(0,r.Tl)("files_sharing","No deleted shares"),emptyCaption:(0,r.Tl)("files_sharing","Shares you have left will show up here"),icon:'',order:4,parent:A,columns:[],getContents:()=>f(!1,!1,!1,!0)})),e.register(new n.Ss({id:T,name:(0,r.Tl)("files_sharing","Pending shares"),caption:(0,r.Tl)("files_sharing","List of unapproved shares."),emptyTitle:(0,r.Tl)("files_sharing","No pending shares"),emptyCaption:(0,r.Tl)("files_sharing","Shares you have received but not approved will show up here"),icon:'',order:5,parent:A,columns:[],getContents:()=>f(!1,!1,!0,!1)}))})(),(0,n.Yc)("nc:share-attributes",{nc:"http://nextcloud.org/ns"}),(0,n.Yc)("oc:share-types",{oc:"http://owncloud.org/ns"}),(0,n.Yc)("ocs:share-permissions",{ocs:"http://open-collaboration-services.org/ns"})},8132:(e,t,i)=>{i.d(t,{A:()=>o});var n=i(71354),r=i.n(n),s=i(76314),a=i.n(s)()(r());a.push([e.id,".action-items>.files-list__row-action-sharing-status{direction:rtl;padding-right:0 !important}svg.sharing-status__avatar{height:32px !important;width:32px !important;max-height:32px !important;max-width:32px !important;border-radius:32px;overflow:hidden}","",{version:3,sources:["webpack://./apps/files_sharing/src/actions/sharingStatusAction.scss"],names:[],mappings:"AAsBA,qDAEC,aAAA,CAEG,0BAAA,CAGJ,2BACC,sBAAA,CACA,qBAAA,CACA,0BAAA,CACA,yBAAA,CACA,kBAAA,CACA,eAAA",sourcesContent:["/**\n * @copyright Copyright (c) 2023 John Molakvoæ \n *\n * @author John Molakvoæ \n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see .\n *\n */\n // Only when rendered inline, when not enough space, this is put in the menu\n.action-items > .files-list__row-action-sharing-status {\n\t// put icon at the end of the button\n\tdirection: rtl;\n\t// align icons with textless inline actions\n padding-right: 0 !important;\n}\n\nsvg.sharing-status__avatar {\n\theight: 32px !important;\n\twidth: 32px !important;\n\tmax-height: 32px !important;\n\tmax-width: 32px !important;\n\tborder-radius: 32px;\n\toverflow: hidden;\n}\n"],sourceRoot:""}]);const o=a}},r={};function s(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={id:e,loaded:!1,exports:{}};return n[e].call(i.exports,i,i.exports,s),i.loaded=!0,i.exports}s.m=n,e=[],s.O=(t,i,n,r)=>{if(!i){var a=1/0;for(h=0;h=r)&&Object.keys(s.O).every((e=>s.O[e](i[l])))?i.splice(l--,1):(o=!1,r0&&e[h-1][2]>r;h--)e[h]=e[h-1];e[h]=[i,n,r]},s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var i in t)s.o(t,i)&&!s.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,i)=>(s.f[i](e,t),t)),[])),s.u=e=>e+"-"+e+".js?v=6797210df0f1d53f94c4",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},i="nextcloud:",s.l=(e,n,r,a)=>{if(t[e])t[e].push(n);else{var o,l;if(void 0!==r)for(var d=document.getElementsByTagName("script"),h=0;h{o.onerror=o.onload=null,clearTimeout(p);var r=t[e];if(delete t[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach((e=>e(n))),i)return i(n)},p=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),l&&document.head.appendChild(o)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),s.j=5928,(()=>{var e;s.g.importScripts&&(e=s.g.location+"");var t=s.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var i=t.getElementsByTagName("script");if(i.length)for(var n=i.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=i[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=e})(),(()=>{s.b=document.baseURI||self.location.href;var e={5928:0};s.f.j=(t,i)=>{var n=s.o(e,t)?e[t]:void 0;if(0!==n)if(n)i.push(n[2]);else{var r=new Promise(((i,r)=>n=e[t]=[i,r]));i.push(n[2]=r);var a=s.p+s.u(t),o=new Error;s.l(a,(i=>{if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var r=i&&("load"===i.type?"missing":i.type),a=i&&i.target&&i.target.src;o.message="Loading chunk "+t+" failed.\n("+r+": "+a+")",o.name="ChunkLoadError",o.type=r,o.request=a,n[1](o)}}),"chunk-"+t,t)}},s.O.j=t=>0===e[t];var t=(t,i)=>{var n,r,a=i[0],o=i[1],l=i[2],d=0;if(a.some((t=>0!==e[t]))){for(n in o)s.o(o,n)&&(s.m[n]=o[n]);if(l)var h=l(s)}for(t&&t(i);ds(70370)));a=s.O(a)})();
//# sourceMappingURL=files_sharing-init.js.map?v=1ac2f2aa1193620a2fe0