@sync-in/server 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/package.json +1 -1
  3. package/server/app.constants.js +3 -3
  4. package/server/app.constants.js.map +1 -1
  5. package/server/app.functions.js +42 -0
  6. package/server/app.functions.js.map +1 -0
  7. package/static/{chunk-CCGGCHGN.js → chunk-2TB2INBF.js} +1 -1
  8. package/static/{chunk-KNZ3AQPR.js → chunk-3WLBVJ2S.js} +1 -1
  9. package/static/{chunk-24Q7OUU2.js → chunk-3YDYZLF7.js} +1 -1
  10. package/static/{chunk-XOTKK2NJ.js → chunk-4PZPHJ7L.js} +1 -1
  11. package/static/{chunk-7CFSJ4BO.js → chunk-5E3TYOL3.js} +1 -1
  12. package/static/{chunk-T74SMT7I.js → chunk-5S6KPQRA.js} +1 -1
  13. package/static/{chunk-PG54TWBO.js → chunk-6B3GGAV3.js} +1 -1
  14. package/static/{chunk-KHRF67SG.js → chunk-6NEBGCAZ.js} +1 -1
  15. package/static/{chunk-N3P6P6GW.js → chunk-BODMMLVB.js} +1 -1
  16. package/static/{chunk-Y2I36A4K.js → chunk-BU4ZICZR.js} +1 -1
  17. package/static/{chunk-RX3YQ67K.js → chunk-DQ3GEMPM.js} +1 -1
  18. package/static/{chunk-BYWSTP3P.js → chunk-FNOTGWRW.js} +1 -1
  19. package/static/{chunk-F7TXTNZC.js → chunk-GNZPP2VO.js} +1 -1
  20. package/static/{chunk-LJSVNPPQ.js → chunk-GRLHFXGB.js} +1 -1
  21. package/static/{chunk-EKEGRXCV.js → chunk-HCSWO7BO.js} +1 -1
  22. package/static/{chunk-FTSIPHMG.js → chunk-HMOB6XC5.js} +1 -1
  23. package/static/{chunk-5HNQLBSW.js → chunk-I2S3XPC5.js} +1 -1
  24. package/static/{chunk-S6EVLDHA.js → chunk-JWPXQOS3.js} +1 -1
  25. package/static/{chunk-MRF3CNLZ.js → chunk-JY2I3HGL.js} +1 -1
  26. package/static/{chunk-2FOWUJQF.js → chunk-K657XPXA.js} +1 -1
  27. package/static/{chunk-MRMSMTWD.js → chunk-MIA5YBOI.js} +1 -1
  28. package/static/{chunk-BQZWSZNN.js → chunk-NKGKBQBX.js} +1 -1
  29. package/static/{chunk-OJCAIKUK.js → chunk-PXRT4L57.js} +1 -1
  30. package/static/{chunk-3IISSX63.js → chunk-RDNTK4YH.js} +1 -1
  31. package/static/{chunk-MNNCSSHN.js → chunk-RK2ONYTL.js} +1 -1
  32. package/static/{chunk-QNFNXDSX.js → chunk-S2VBGI6Q.js} +1 -1
  33. package/static/{chunk-Y44XDRM5.js → chunk-TGLJFALR.js} +1 -1
  34. package/static/{chunk-LXQGVNU2.js → chunk-U4RW6XG5.js} +1 -1
  35. package/static/{chunk-4FJUCMEG.js → chunk-V6FA5QY4.js} +1 -1
  36. package/static/{chunk-XX7JXKA6.js → chunk-VK7XMFVE.js} +1 -1
  37. package/static/{chunk-RT3K6DZR.js → chunk-VQJYCYWI.js} +1 -1
  38. package/static/{chunk-MVZJSG5R.js → chunk-XQGPSNQB.js} +1 -1
  39. package/static/{chunk-2XPHUNYN.js → chunk-ZXXHFBGL.js} +1 -1
  40. package/static/index.html +1 -1
  41. package/static/{main-3PLRDZTO.js → main-56PZQ6TJ.js} +3 -3
@@ -1 +1 @@
1
- import{c as Y,d as Te,h as ee,m as ue}from"./chunk-MYM43ENO.js";import{a as Ht}from"./chunk-LYZGJZNP.js";import{b as Ut}from"./chunk-BQZWSZNN.js";import{l as Pt,n as Rt,o as Nt,p as $t,q as U,r as Ot,s as H,w as Mt}from"./chunk-BYWSTP3P.js";import{a as Ft,b as Bt}from"./chunk-ZCOWBVOT.js";import{b as Q}from"./chunk-OJCAIKUK.js";import{$a as de,Ba as he,Ca as Et,Cb as Z,Db as u,Gb as wt,Hb as xt,Ib as Tt,Ja as Ie,K as Ct,Mb as xe,N as At,Na as N,Nb as B,Ob as I,Pb as Dt,W as ce,Wa as bt,gb as yt,ib as vt,s as lt,t as pt,tb as It,w as ct,x as mt,y as ht,ya as k}from"./chunk-5HNQLBSW.js";import{d as se}from"./chunk-Y5RLD72B.js";import{Bb as oe,Cd as ot,Dd as st,De as St,Eb as D,Ed as le,Ef as _t,G as _e,Gb as d,Jd as pe,Kd as at,L as Oe,Oa as l,Od as dt,Pc as qe,Qa as ke,Qb as je,Ra as Ue,Rb as J,Sb as P,Tb as c,Ub as q,Vb as O,Wb as Ke,Wf as kt,Xb as Ee,Yb as be,Yc as W,Zb as ye,ab as re,cc as G,ea as R,ed as Ge,f as Ne,fd as We,gc as Ve,ha as Me,hd as ae,ia as ne,ie as ut,ja as S,jd as Ze,kc as b,kd as Ye,lb as A,ld as ve,le as ft,mb as E,mc as y,nb as He,nd as _,oa as K,od as Xe,og as me,p as z,pa as V,pb as Ce,pd as ze,pg as we,qb as Ae,qd as Je,qg as Lt,ra as Fe,rb as m,rg as F,sb as s,sd as Qe,t as $e,tb as a,td as et,ub as g,ud as tt,v as f,vd as it,wd as nt,wf as gt,xa as Be,xd as rt}from"./chunk-IOIBQGHN.js";import{n as M}from"./chunk-DM4NXKEP.js";import{a as v,b as L,d as Re}from"./chunk-KAVP6UXH.js";var X={BASE:`${ce}/link`,LINK:"link",VALIDATION:"validation",ACCESS:"access",AUTH:"auth"},jt=`${X.BASE}/${X.VALIDATION}`,Le=`${X.BASE}/${X.ACCESS}`,Kt=`${X.BASE}/${X.AUTH}`;var h={BASE:`${ce}/shares`,LIST:"list",CHILDREN:"children",LINKS:"links",LINKS_LIST:"links/list",LINKS_UUID:"links/uuid"},Vt=`${h.BASE}/${h.LIST}`,te=`${h.BASE}/${h.LINKS}`,qt=`${h.BASE}/${h.LINKS_LIST}`,Gt=`${h.BASE}/${h.LINKS_UUID}`;var Wt=new Me("WindowToken",typeof window<"u"&&window.document?{providedIn:"root",factory:()=>window}:{providedIn:"root",factory:()=>{}});var Zt=(()=>{class o{constructor(i,e,t){this.ngZone=i,this.document=e,this.window=t,this.copySubject=new Ne,this.copyResponse$=this.copySubject.asObservable(),this.config={}}configure(i){this.config=i}copy(i){if(!this.isSupported||!i)return this.pushCopyResponse({isSuccess:!1,content:i});let e=this.copyFromContent(i);return e?this.pushCopyResponse({content:i,isSuccess:e}):this.pushCopyResponse({isSuccess:!1,content:i})}get isSupported(){return!!this.document.queryCommandSupported&&!!this.document.queryCommandSupported("copy")&&!!this.window}isTargetValid(i){if(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement){if(i.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');return!0}throw new Error("Target should be input or textarea")}copyFromInputElement(i,e=!0){try{this.selectTarget(i);let t=this.copyText();return this.clearSelection(e?i:void 0,this.window),t&&this.isCopySuccessInIE11()}catch{return!1}}isCopySuccessInIE11(){let i=this.window.clipboardData;return!(i&&i.getData&&!i.getData("Text"))}copyFromContent(i,e=this.document.body){if(this.tempTextArea&&!e.contains(this.tempTextArea)&&this.destroy(this.tempTextArea.parentElement||void 0),!this.tempTextArea){this.tempTextArea=this.createTempTextArea(this.document,this.window);try{e.appendChild(this.tempTextArea)}catch{throw new Error("Container should be a Dom element")}}this.tempTextArea.value=i;let t=this.copyFromInputElement(this.tempTextArea,!1);return this.config.cleanUpAfterCopy&&this.destroy(this.tempTextArea.parentElement||void 0),t}destroy(i=this.document.body){this.tempTextArea&&(i.removeChild(this.tempTextArea),this.tempTextArea=void 0)}selectTarget(i){return i.select(),i.setSelectionRange(0,i.value.length),i.value.length}copyText(){return this.document.execCommand("copy")}clearSelection(i,e){i&&i.focus(),e.getSelection()?.removeAllRanges()}createTempTextArea(i,e){let t=i.documentElement.getAttribute("dir")==="rtl",n;n=i.createElement("textarea"),n.style.fontSize="12pt",n.style.border="0",n.style.padding="0",n.style.margin="0",n.style.position="absolute",n.style[t?"right":"left"]="-9999px";let p=e.pageYOffset||i.documentElement.scrollTop;return n.style.top=p+"px",n.setAttribute("readonly",""),n}pushCopyResponse(i){this.copySubject.observers.length>0&&this.ngZone.run(()=>{this.copySubject.next(i)})}pushCopyReponse(i){this.pushCopyResponse(i)}}return o.\u0275fac=function(i){return new(i||o)(ne(Ue),ne(Fe),ne(Wt,8))},o.\u0275prov=R({token:o,factory:o.\u0275fac,providedIn:"root"}),o})();var De=(function(o){return o[o.COMMON=0]="COMMON",o[o.LINK=1]="LINK",o})(De||{}),Yt=Object.values(k).filter(o=>o!==k.SHARE_INSIDE).sort().join(":");function ti(o,r){if(o&1&&g(0,"fa-icon",2),o&2){let i=d();P(i.repository.class),je("min-width",i.galleryMode.dimensions/3,"px")("min-height",i.galleryMode.dimensions/3,"px")("font-size",i.galleryMode.faSize/1.8,"px"),m("icon",i.repository.icon)}}function ii(o,r){if(o&1&&g(0,"fa-icon",5),o&2){let i=d(2);P(i.repository.class),m("icon",i.repository.icon)}}function ni(o,r){if(o&1&&(c(0),b(1,"translate")),o&2){let i=d(2);O(" ",y(1,1,i.repository.label,i.locale.language)," ")}}function ri(o,r){if(o&1&&c(0),o&2){let i=d(2);O(" ",i.repository.label," ")}}function oi(o,r){if(o&1&&(s(0,"div",1),A(1,ii,1,3,"fa-icon",3),s(2,"span",4),A(3,ni,2,4)(4,ri,1,1),a()()),o&2){let i=d();l(),E(i.showIcon?1:-1),l(2),E(i.repository.translate?3:4)}}var Xt=(()=>{let r=class r{constructor(){this.showIcon=!0,this.showFullPath=!1,this.locale=S(le),this.layout=S(Z),this.unknownRepository={icon:dt,label:"",class:"circle-primary-icon",translate:!1}}ngOnInit(){this.setRepository()}ngOnChanges(){this.setRepository()}setRepository(){this.share.parent?.id||this.share.parent?.id===0?this.repository={icon:B.SHARES,label:this.share.parent.name,class:"circle-purple-icon",translate:!1}:this.share.file?.ownerId?this.repository={icon:B.PERSONAL,label:xe.PERSONAL_FILES,class:"circle-primary-icon",translate:!0}:this.share.file?.space?.alias?this.repository={icon:B.SPACES,label:`${this.share.file.space.name}`,class:"circle-primary-icon",translate:!1}:this.share.externalPath?this.repository={icon:B.EXTERNAL,label:"External",class:"circle-primary-icon",translate:!0}:this.repository=v({},this.unknownRepository),this.showFullPath&&this.setFullPath()}setFullPath(){if(!this.repository.label)return;let e=this.share.file?.path?this.share.file.path.split("/").filter(t=>t&&t!=="."):[];this.share.parent?.id&&!this.share.file?.id&&this.share.file?.path.indexOf("/")===-1?e.shift():this.share.file?.space?.alias&&this.share.file.space?.root?.alias&&(e.length?e.unshift(this.share.file.space.root.name):e.push(this.share.file.space.root.name)),this.repository.label===xe.PERSONAL_FILES&&(this.repository.label=this.layout.translateString(this.repository.label)),e.length&&(this.repository.label=`${this.repository.label}/${e.join("/")}`)}};r.\u0275fac=function(t){return new(t||r)},r.\u0275cmp=re({type:r,selectors:[["app-share-repository"]],inputs:{share:"share",galleryMode:"galleryMode",showIcon:"showIcon",showFullPath:"showFullPath"},features:[Be],decls:2,vars:1,consts:[[3,"icon","class","min-width","min-height","font-size"],[1,"d-flex","align-items-center","overflow-wrap-and-whitespace"],[3,"icon"],[1,"me-2",3,"icon","class"],["draggable","false",1,"no-pointer-events"],[1,"me-2",3,"icon"]],template:function(t,n){t&1&&A(0,ti,1,9,"fa-icon",0)(1,oi,5,2,"div",1),t&2&&E(n.galleryMode?0:1)},dependencies:[me,pe],encapsulation:2});let o=r;return o})();function Se(o){o.file?.id?(o.file.isDir&&(o.file.mime=o.parent?.alias?Te:Y),o.mimeUrl=ee(o.file.mime)):o.mimeUrl=ee(o.parent?.alias?Te:Y)}function zt(o){let r,i=o.file.path?o.file.path.split("/").filter(t=>t&&t!=="."):[];if(o.parent?.id){if(!i.length)return[I.SPACES_SHARES,o.parent.alias];r=`${I.SPACES_SHARES}/${o.parent.alias}`}else o.file.space?.alias?o.file.inTrash?r=`${I.SPACES_TRASH}/${o.file.space.alias}`:(r=`${I.SPACES_FILES}/${o.file.space.alias}`,o.file.space?.root?.alias&&(i.length?r=`${r}/${o.file.space.root.alias}`:i.push(o.file.space.root.name))):o.file?.ownerId?r=`${o.file.inTrash?I.PERSONAL_TRASH:I.PERSONAL_FILES}`:console.warn("unable to find the right file path",o);let e=i.pop();return r&&i.length&&(r=`${r}/${i.join("/")}`),[r,e]}var w=class{constructor(r){this.members=[],this.links=[],this.hPerms={},this.setMembers(N("members",r),r.externalPath||r.file?.isDir?[k.SHARE_INSIDE]:[]),Object.assign(this,r),Se(this),this.checkFile(),this.setPermissions()}fallBackMimeUrl(){this.mimeUrl=ue}setMembers(r,i){if(r)for(let e of r)e.linkId?this.links.push(new H(e,[...i,k.SHARE_OUTSIDE])):this.members.push(new H(e,i))}checkFile(){this.file&&(!this.file.path&&this.file.space.root?.name&&(this.file.path=this.file.space.root.name,this.file.name=this.file.space.root.name),this.file.permissions&&(this.file.permissions=this.file.permissions.split(":").filter(r=>r===k.SHARE_INSIDE||r===k.ADD&&this.file.id&&!this.file.isDir?!1:!(r===k.DELETE&&this.file.id&&!this.file.isDir)).join(":")))}setPermissions(){typeof this.file?.permissions=="string"?this.hPerms=U(this.file.permissions):this.externalPath&&(this.hPerms=U(Yt))}};var Jt=(()=>{let r=class r{constructor(){this.http=S(W),this.router=S(se)}getShare(e){return this.http.get(`${h.BASE}/${e}`).pipe(f(t=>new w(t)))}createShare(e){return this.http.post(h.BASE,e).pipe(f(t=>new w(t)))}updateShare(e){return this.http.put(`${h.BASE}/${e.id}`,e).pipe(f(t=>new w(t)))}deleteShare(e){return this.http.delete(`${h.BASE}/${e}`)}listShares(){return this.http.get(Vt)}getShareChild(e,t){return this.http.get(`${h.BASE}/${e}/${h.CHILDREN}/${t}`).pipe(f(n=>new w(n)))}updateShareChild(e,t,n){return this.http.put(`${h.BASE}/${e}/${h.CHILDREN}/${t}`,n).pipe(f(p=>new w(p)))}deleteShareChild(e,t){return this.http.delete(`${h.BASE}/${e}/${h.CHILDREN}/${t}`)}listChildShares(e){return this.http.get(`${h.BASE}/${e}/${h.CHILDREN}`)}initShareFromFile(e,t,n=!1,p=!1){let C,x=null,T=v({id:0,name:"",createdAt:new Date,modifiedAt:new Date,storageIndexing:!0,enabled:!0},n?{parent:{id:0,ownerId:0,alias:t.space.alias,name:t.space.name}}:{});if(t){p&&(x=t.root.id);let Pe=null;(t?.root?.owner.login===e.login||!t?.space?.alias)&&(t.space=null,Pe=e.id),C=new w(L(v({},T),{name:t.name,file:L(v({},t),{path:p?".":bt(t.path,2),ownerId:Pe})}))}else C=new w(T);return[C,x]}goTo(e){if(!e.id)return $e(z(!1));if(e.externalPath&&!e.parent?.id)return this.router.navigate([I.SPACES_SHARES],{queryParams:{select:e.name}});if(e.parent?.id&&!e.file?.id&&e.file?.path.indexOf("/")===-1)return this.router.navigate([I.SPACES_SHARES],{queryParams:{select:e.parent.name}});{let[t,n]=zt(e);return this.router.navigate([t],{queryParams:{select:n}})}}};r.\u0275fac=function(t){return new(t||r)},r.\u0275prov=R({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();var $=class{constructor(r){this.hTimeExpirationAgo=0,this.hPerms={},this.newly=0,Object.assign(this,r),Se(this),this.updatePermission(),this.updateTimes()}fallBackMimeUrl(){this.mimeUrl=ue}updatePermission(){this.hPerms=U(this.link.permissions)}updateTimes(){if(this.hTimeAccessAgo=M(this.link.currentAccess).fromNow(!0),this.newly=de(this.link.currentAccess),this.link.expiresAt){this.link.expiresAt=new Date(M(this.link.expiresAt).local().format("YYYY-MM-DD"));let r=Math.max(0,M(this.link.expiresAt).diff(M(),"hours"));r===0?this.hTimeExpirationAgo=0:r<=24?this.hTimeExpirationAgo=1:this.hTimeExpirationAgo=Math.round(r/24)+1}else this.hTimeExpirationAgo=0}};var j=class{constructor(r){this.roots=[],this.managers=[],this.members=[],this.links=[],this.hPerms={},this.newly=0,this.hPerms=U(r.permissions),this.setMembers(N("members",r)),this.setRoots(N("roots",r)),Object.assign(this,r),this.hTimeAgo=M(this.modifiedAt).fromNow(!0),this.newly=de(this.modifiedAt),this.sort()}addRoot(r,i=!1){r.hPerms=Nt(r.permissions,[k.SHARE_INSIDE]),r.owner?.login&&(r.owner.avatarUrl=It(r.owner.login)),r.file.mimeUrl=ee(r.file?.mime?r.file.mime:Y),i?this.roots.unshift(r):this.roots.push(r),r.isDir=r.file.mime===Y||!!r.externalPath}havePermission(r){return this.permissions.indexOf(r)>-1}setMembers(r){if(r)for(let i of r){let e=new H(i);e.isLink?this.links.push(e):e.spaceRole===he.IS_MANAGER?this.managers.push(e):this.members.push(e)}}setRoots(r){if(r)for(let i of r)this.addRoot(i)}sort(){Q(this.roots,"createdAt",!1),Q(this.managers,"createdAt",!1),Q(this.members,"createdAt",!1),Q(this.links,"createdAt",!1)}};var Qt=(()=>{let r=class r{constructor(){this.http=S(W)}listSpaces(){return this.http.get(wt).pipe(f(e=>e.map(t=>new j(t))))}getSpace(e){return this.http.get(`${u.BASE}/${e}`).pipe(f(t=>new j(t)))}getUserSpaceRoots(e){return this.http.get(`${u.BASE}/${e}/${u.ROOTS}`)}createUserSpaceRoots(e,t){return this.http.post(`${u.BASE}/${e}/${u.ROOTS}`,t)}updateUserSpaceRoots(e,t){return this.http.put(`${u.BASE}/${e}/${u.ROOTS}`,t)}updateSpace(e){return this.http.put(`${u.BASE}/${e.id}`,e).pipe(f(t=>t?new j(t):null))}createSpace(e){return this.http.post(u.BASE,e).pipe(f(t=>(t.permissions=Et,new j(t))))}deleteSpace(e,t){return this.http.request("delete",`${u.BASE}/${e}`,{body:t})}searchSpaces(e){return this.http.request("search",u.BASE,{body:e})}listSpaceShares(e){return this.http.get(`${u.BASE}/${e}/${u.SHARES}`)}getSpaceShare(e,t){return this.http.get(`${u.BASE}/${e}/${u.SHARES}/${t}`).pipe(f(n=>new w(n)))}updateSpaceShare(e,t){return this.http.put(`${u.BASE}/${e}/${u.SHARES}/${t.id}`,t).pipe(f(n=>new w(n)))}deleteSpaceShare(e,t){return this.http.delete(`${u.BASE}/${e}/${u.SHARES}/${t}`)}getSpaceShareLink(e,t){return this.http.get(`${u.BASE}/${e}/${u.LINKS}/${t}`).pipe(f(n=>new $(n)))}listTrashBins(){return this.http.get(xt)}checkSpaceRootPath(e){return this.http.post(Tt,{path:e})}};r.\u0275fac=function(t){return new(t||r)},r.\u0275prov=R({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();var ai=o=>({dateInputFormat:"YYYY-MM-DD",containerClass:"theme-dark-blue",returnFocusToInput:!0,minDate:o,showWeekNumbers:!1}),li=(o,r)=>r.key;function pi(o,r){o&1&&(s(0,"span",4),c(1,"Edit link"),a())}function ci(o,r){o&1&&(s(0,"span",4),c(1,"New link"),a())}function mi(o,r){o&1&&g(0,"div",54)}function hi(o,r){if(o&1){let i=oe();s(0,"button",53),b(1,"translate"),ye("ngModelChange",function(t){let n=K(i).$implicit,p=d(3);return be(p.permissions[n.key],t)||(p.permissions[n.key]=t),V(t)}),D("ngModelChange",function(){K(i);let t=d(3);return V(t.onPermissionChange())}),g(2,"fa-icon",50),a(),A(3,mi,1,0,"div",54)}if(o&2){let i=r.$implicit,e=r.$index,t=r.$count,n=d(3);Ee("ngModel",n.permissions[i.key]),m("tooltip",y(1,4,n.SPACES_PERMISSIONS_TEXT[i.key].text,n.locale.language)),l(2),m("icon",n.SPACES_PERMISSIONS_TEXT[i.key].icon),l(),E(e===t-1?3:-1)}}function di(o,r){if(o&1&&(Ce(0,hi,4,7,null,null,li),b(2,"keyvalue")),o&2){let i=d(2);Ae(y(2,0,i.permissions,i.originalOrderKeyValue))}}function ui(o,r){if(o&1&&(s(0,"div",51),g(1,"app-share-repository",55),a()),o&2){let i=d(2);l(),m("share",i.share)("showIcon",!0)("showFullPath",!0)}}function fi(o,r){if(o&1){let i=oe();s(0,"div",44),g(1,"fa-icon",45),s(2,"div",46)(3,"span"),c(4),a(),s(5,"span",47),c(6),a()(),s(7,"div",48),A(8,di,3,3),s(9,"button",49),b(10,"translate"),D("click",function(){K(i);let t=d();return V(t.toggleRequireAuth())}),g(11,"fa-icon",50),a(),s(12,"button",49),b(13,"translate"),D("click",function(){K(i);let t=d();return V(t.copyToClipboard())}),g(14,"fa-icon",50),a()()(),A(15,ui,2,3,"div",51),g(16,"hr",52)}if(o&2){let i=d();l(),m("icon",i.icons.links),l(3),q(i.linkForm.value.name||i.linkForm.value.shareName),l(2),q(i.linkForm.value.email),l(2),E(i.share&&i.permissions?8:-1),l(),P(G("btn btn-sm ",i.linkForm.value.requireAuth?"btn-success":"btn-warning")),m("tooltip",y(10,15,"Password",i.locale.language)),l(2),m("icon",i.linkForm.value.requireAuth?i.icons.faLock:i.icons.faLockOpen),l(),P(G("btn btn-sm ms-2 ",i.linkWasCopied?"btn-info":"btn-secondary")),m("tooltip",y(13,18,"Copy link",i.locale.language)),l(2),m("icon",i.linkWasCopied?i.icons.faClipboardCheck:i.icons.faClipboard),l(),E(i.share?15:-1)}}function Si(o,r){if(o&1&&(s(0,"span"),c(1),a()),o&2){let i=d();P(G("badge rounded-pill ",(i.share?i.share.link.nbAccess:i.link.nbAccess)>=i.linkForm.value.limitAccess?"bg-danger":"bg-success")),l(),Ke(" ",i.share?i.share.link.nbAccess:i.link.nbAccess,"/",i.linkForm.value.limitAccess," ")}}function gi(o,r){if(o&1&&(s(0,"span",20),c(1),a()),o&2){let i=d();l(),q(i.share?i.share.link.nbAccess:i.link.nbAccess)}}function _i(o,r){if(o&1&&(s(0,"div",27)(1,"label",56),c(2,"Share name"),a(),g(3,"input",57),b(4,"translate"),a(),s(5,"div",27)(6,"label",58),c(7,"Share description"),a(),g(8,"input",59),b(9,"translate"),a()),o&2){let i=d();l(3),J("is-invalid",i.linkForm.controls.shareName.invalid),m("placeholder",y(4,4,"Share name",i.locale.language)),l(5),m("placeholder",y(9,7,"Share description",i.locale.language))}}function ki(o,r){if(o&1&&(s(0,"option",30),c(1),a()),o&2){let i=r.$implicit,e=d();m("ngValue",i),l(),q(e.i18nLanguageText[i])}}function Ci(o,r){if(o&1&&(s(0,"div",37),g(1,"app-password-strength-bar",60),a()),o&2){let i=d();l(),m("passwordToCheck",i.password)}}function Ai(o,r){if(o&1){let i=oe();s(0,"button",61),D("click",function(){K(i);let t=d();return V(t.confirmDeletion=!0)}),c(1," Remove "),a()}if(o&2){let i=d();m("disabled",i.confirmDeletion)}}var ge=(()=>{let r=class r{constructor(){this.layout=S(Z),this.parentSpaceId=null,this.isSharesRepo=!1,this.inSharesList=!1,this.submitEvent=new ke,this.shareChange=new ke,this.locale=S(le),this.confirmDeletion=!1,this.submitted=!1,this.SPACES_PERMISSIONS_TEXT=Dt,this.originalOrderKeyValue=yt,this.icons={faEye:ut,faEyeSlash:kt,links:B.LINKS,faClipboard:St,faClipboardCheck:ft,faLock:_t,faLockOpen:gt},this.languages=this.layout.getLanguages(),this.minDate=Ie(),this.defaultPassword=this.layout.translateString(Ct),this.passwordMinLength=8,this.password="",this.linkIsExpired=!1,this.linkIsHovered=!1,this.linkWasCopied=!1,this.i18nLanguageText=At,this.userService=S(Mt),this.sharesService=S(Jt),this.linksService=S(ei),this.spacesService=S(Qt),this.minDate.setDate(this.minDate.getDate()+1)}ngOnInit(){this.link?this.initLink():this.file?this.initFile():this.initShareLink(),this.linkForm.value.requireAuth&&(this.password=this.defaultPassword),this.linkForm.value.expiresAt&&this.isLinkIsExpired(this.share?this.share.link.expiresAt:this.link.expiresAt),this.linkForm.controls.expiresAt.valueChanges.subscribe(e=>this.isLinkIsExpired(e))}onPermissionChange(){let e=Ot(this.permissions);this.linkForm.controls.permissions.setValue(e),e!==this.share.link.permissions?this.linkForm.controls.permissions.markAsDirty():this.linkForm.controls.permissions.markAsPristine()}toggleRequireAuth(){this.linkForm.controls.requireAuth.setValue(!this.linkForm.value.requireAuth),this.linkForm.controls.requireAuth.markAsDirty()}copyToClipboard(){this.linksService.copyLinkToClipboard(this.share?this.share.link.uuid:this.link.uuid),this.linkWasCopied=!0,this.layout.sendNotification("info","Link copied",this.linkForm.value.name||this.linkForm.value.shareName),setTimeout(()=>this.linkWasCopied=!1,3e3)}onCancel(){this.confirmDeletion?this.confirmDeletion=!1:this.layout.closeDialog()}onSubmit(){if(this.submitted=!0,this.confirmDeletion){(this.parentSpaceId?this.spacesService.deleteSpaceShare(this.parentSpaceId,this.share.id):this.sharesService.deleteShare(this.share.id)).subscribe({next:()=>{this.layout.sendNotification("success","Link deleted",this.share.link.name||this.share.name),this.shareChange.emit(["delete",this.share]),this.layout.closeDialog()},error:p=>{this.layout.sendNotification("error","Delete share",this.share.name,p),this.layout.closeDialog()}});return}if(this.file?.id){let t=this.share,{link:n}=t,p=Re(t,["link"]),C=L(v(v({},n),this.linkForm.value),{password:this.mustIncludePassword()?this.password:void 0});p.name=N("shareName",C),p.description=N("shareDescription",C);let x=this.linksService.shareLinkGuestToMember(-1,-1,C);this.sharesService.createShare(L(v({},p),{type:De.LINK,links:[x]})).subscribe({next:T=>{this.shareChange.emit(["add",T]),this.layout.sendNotification("success","Link created",n.name||T.name),this.layout.closeDialog()},error:T=>{this.layout.sendNotification("error","Link error",this.share.name,T),this.layout.closeDialog()}});return}let e={};for(let n in this.linkForm.controls)this.linkForm.controls[n].dirty&&(e[n]=this.linkForm.controls[n].value);if(this.mustIncludePassword()&&(e.password=this.password),this.share?.id){Object.keys(e).length&&this.linksService.updateLinkFromSpaceOrShare(this.share.link.id,this.share.id,Lt.SHARE,e).subscribe({next:n=>{this.share.name=this.linkForm.value.shareName,this.share.description=this.linkForm.value.shareDescription,this.share.link=Object.assign(this.share.link,n),this.share.updateTimes(),this.share.updatePermission(),this.shareChange.emit(["update",this.share]),this.layout.closeDialog()},error:n=>{this.layout.sendNotification("error","Link error",this.share.link.name||this.share.name,n),this.layout.closeDialog()}}),this.layout.closeDialog();return}this.submitEvent.emit(e)}initFile(){let e=this.sharesService.initShareFromFile(this.userService.user,this.file,this.isSharesRepo,this.inSharesList)[0];this.share=L(v({},e),{link:{id:-1,userId:-1,uuid:"",isActive:!0,requireAuth:!1,permissions:"",nbAccess:0,limitAccess:0}}),this.linksService.genUUID().subscribe(t=>this.share.link.uuid=t),this.initShareLink(),this.onPermissionChange()}initShareLink(){this.linkForm=new ve({shareName:new _(this.share.name,ae.required),shareDescription:new _(this.share.description||""),name:new _(this.share.link?.name||""),email:new _(this.share.link?.email||"",ae.email),language:new _(this.share.link.language||null),limitAccess:new _(this.share.link.limitAccess||null),expiresAt:new _(this.share.link.expiresAt||null),requireAuth:new _(this.share.link.requireAuth||!1),permissions:new _(this.share.link.permissions),isActive:new _(this.share.link.isActive)}),this.permissions=$t(this.share.file.permissions,this.share.link.permissions,[k.SHARE_INSIDE,k.SHARE_OUTSIDE,...this.share.file.isDir?[]:[k.DELETE,k.ADD]])}initLink(){this.linkForm=new ve({shareName:new _(""),shareDescription:new _(""),name:new _(this.link.name||""),email:new _(this.link.email||"",ae.email),language:new _(this.link.language||null),limitAccess:new _(this.link.limitAccess||null),expiresAt:new _(this.link.expiresAt||null),requireAuth:new _(this.link.requireAuth||!1),permissions:new _(this.link.permissions),isActive:new _(this.link.isActive)}),this.link.id||(this.linkForm.controls.name.markAsDirty(),this.linkForm.controls.isActive.markAsDirty())}isLinkIsExpired(e){if(e==null){if(this.linkIsExpired=!1,e===null)return;this.linkForm.controls.expiresAt.setValue(null)}this.linkIsExpired=Ie()>=e}mustIncludePassword(){return!!this.password.length&&this.password!==this.defaultPassword}};r.\u0275fac=function(t){return new(t||r)},r.\u0275cmp=re({type:r,selectors:[["app-link-dialog"]],inputs:{share:"share",parentSpaceId:"parentSpaceId",link:"link",file:"file",isSharesRepo:"isSharesRepo",inSharesList:"inSharesList"},outputs:{submitEvent:"submitEvent",shareChange:"shareChange"},decls:73,vars:52,consts:[[1,"modal-header","align-items-center"],[1,"modal-title"],[1,"me-2",3,"icon"],[1,"modal-title","ms-auto"],["l10nTranslate",""],["aria-label","Close","type","button",1,"btn-close","btn-close-white","ms-2",3,"click"],[1,"modal-body"],["autocomplete","off",3,"formGroup"],[1,"d-flex"],[1,"d-flex","flex-column","flex-grow-1"],[1,"d-flex","align-items-center","cursor-pointer","py-2",3,"mouseover","mouseleave","focus","click"],["for","link","l10nTranslate",""],["id","link",1,"ms-auto"],[1,"d-flex","align-items-center","py-2"],["for","state","l10nTranslate","",1,"cursor-pointer","me-auto"],[1,"d-flex","align-items-center","form-check","form-switch","cursor-pointer"],["id","state","formControlName","isActive","type","checkbox","role","button",1,"form-check-input"],["for","access","l10nTranslate",""],["id","access",1,"ms-auto"],[3,"class"],[1,"badge","rounded-pill","bg-success"],[1,"d-flex","align-items-center"],["for","guestName","l10nTranslate",""],["id","guestName","formControlName","name","type","text",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],[1,"d-flex","align-items-center","justify-content-between","px-0"],["for","guestEmail","l10nTranslate",""],["id","guestEmail","autocomplete","off","formControlName","email","type","email",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],[1,"d-flex","align-items-center","justify-content-between"],["for","guestLanguage","l10nTranslate",""],["id","guestLanguage","formControlName","language",1,"form-control","form-select","form-select-sm","ms-auto","w-50"],[3,"ngValue"],["for","limitAccess","l10nTranslate",""],["id","limitAccess","formControlName","limitAccess","min","1","type","number",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],["for","expiration","l10nTranslate",""],["bsDatepicker","","id","expiration","formControlName","expiresAt","placement","left","type","text",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder","bsConfig"],[1,"d-flex","align-items-center","px-0"],["for","requireAuth","translate","",1,"cursor-pointer","me-auto"],[1,"d-flex","align-items-center","d-none","d-sm-flex","mx-auto"],["id","requireAuth","formControlName","requireAuth","type","checkbox","role","button",1,"form-check-input"],["placeholder","Set a password",2,"width","45%",3,"passwordChange","isRequired","disabled","passwordMinLength","password","showGenerator"],[1,"modal-footer"],["type","button","l10nTranslate","",1,"btn","btn-sm","btn-danger",3,"disabled"],["data-dismiss","modal","type","button","l10nTranslate","",1,"btn","btn-sm","btn-secondary","ms-auto",3,"click"],["type","button","l10nTranslate","",3,"click","disabled"],[1,"d-flex","flex-fill","align-items-center"],[1,"circle-primary-icon","me-2",3,"icon"],[1,"d-flex","flex-column","overflow-wrap-and-whitespace","me-2"],[1,"fs-xxxs"],[1,"d-flex","ms-auto"],["container","body","type","button",3,"click","tooltip"],["size","lg",3,"icon"],[1,"d-flex","align-items-center","d-none","d-sm-flex","py-2"],[1,"my-2"],["btnCheckbox","","type","button",1,"btn","btn-sm","btn-custom","me-0","ms-2",3,"ngModelChange","ngModel","tooltip"],[1,"vr","mx-2"],["id","file",3,"share","showIcon","showFullPath"],["for","shareName","l10nTranslate",""],["id","shareName","formControlName","shareName","type","email",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],["for","shareDescription","l10nTranslate",""],["id","shareDescription","formControlName","shareDescription","type","email",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],[3,"passwordToCheck"],["type","button","l10nTranslate","",1,"btn","btn-sm","btn-danger",3,"click","disabled"]],template:function(t,n){t&1&&(s(0,"div",0)(1,"h4",1),g(2,"fa-icon",2),s(3,"span"),c(4),a()(),s(5,"h4",3),A(6,pi,2,0,"span",4)(7,ci,2,0,"span",4),a(),s(8,"button",5),D("click",function(){return n.layout.closeDialog()}),a()(),s(9,"div",6),A(10,fi,17,21),s(11,"form",7)(12,"div",8)(13,"div",9)(14,"div",10),D("mouseover",function(){return n.linkIsHovered=!0})("mouseleave",function(){return n.linkIsHovered=!1})("focus",function(){return n.linkIsHovered=!0})("click",function(){return n.copyToClipboard()}),s(15,"label",11),c(16,"Link"),a(),s(17,"span",12),c(18),a()(),s(19,"div",13)(20,"label",14),c(21,"Active"),a(),s(22,"div",15),g(23,"input",16),s(24,"span"),c(25),b(26,"translate"),a()()(),s(27,"div",13)(28,"label",17),c(29,"Current access count"),a(),s(30,"span",18),A(31,Si,2,5,"span",19)(32,gi,2,1,"span",20),a()(),A(33,_i,10,10),s(34,"div",21)(35,"label",22),c(36,"Guest name"),a(),g(37,"input",23),b(38,"translate"),a(),s(39,"div",24)(40,"label",25),c(41,"Guest email"),a(),g(42,"input",26),b(43,"translate"),a(),s(44,"div",27)(45,"label",28),c(46,"Guest language"),a(),s(47,"select",29),Ce(48,ki,2,2,"option",30,He),a()(),s(50,"div",27)(51,"label",31),c(52,"Limit access"),a(),g(53,"input",32),b(54,"translate"),a(),s(55,"div",27)(56,"label",33),c(57,"Expiration"),a(),g(58,"input",34),b(59,"translate"),a(),s(60,"div",35)(61,"label",36),c(62,"Password"),a(),A(63,Ci,2,1,"div",37),s(64,"div",15),g(65,"input",38),a(),s(66,"app-input-password",39),ye("passwordChange",function(C){return be(n.password,C)||(n.password=C),C}),a()()()()()(),s(67,"div",40),A(68,Ai,2,1,"button",41),s(69,"button",42),D("click",function(){return n.onCancel()}),c(70,"Cancel"),a(),s(71,"button",43),D("click",function(){return n.onSubmit()}),c(72),a()()),t&2&&(l(2),m("icon",n.icons.links),l(2),q(n.linkForm.value.name||n.linkForm.value.shareName),l(2),E(n.share!=null&&n.share.id||n.link!=null&&n.link.id?6:7),l(4),E(n.share||n.link?10:-1),l(),m("formGroup",n.linkForm),l(6),J("text-primary",n.linkIsHovered),l(),O(" ",n.share?n.share.link.uuid:n.link.uuid," "),l(6),P(G("badge rounded-pill ms-3 ",n.linkForm.value.isActive?"bg-primary":"bg-danger")),l(),O(" ",y(26,35,n.linkForm.value.isActive?"yes":"no",n.locale.language)," "),l(6),E(n.linkForm.value.limitAccess?31:32),l(2),E(n.share?33:-1),l(4),m("placeholder",y(38,38,"Guest name",n.locale.language)),l(5),J("is-invalid",n.linkForm.controls.email.invalid),m("placeholder",y(43,41,"Guest email",n.locale.language)),l(6),Ae(n.languages),l(5),m("placeholder",y(54,44,"Unlimited",n.locale.language)),l(5),J("text-danger",n.linkIsExpired),m("placeholder",y(59,47,"Never expires",n.locale.language))("bsConfig",Ve(50,ai,n.minDate)),l(5),E(n.linkForm.value.requireAuth&&n.password!==n.defaultPassword?63:-1),l(3),m("isRequired",n.linkForm.value.requireAuth)("disabled",!n.linkForm.value.requireAuth)("passwordMinLength",n.passwordMinLength),Ee("password",n.password),m("showGenerator",!0),l(2),E(n.share!=null&&n.share.id?68:-1),l(3),P(G("btn btn-sm ",n.confirmDeletion?"btn-danger":"btn-primary")),m("disabled",n.linkForm.invalid||n.linkForm.controls.requireAuth.value&&n.password.length<n.passwordMinLength||n.submitted),l(),O(" ",n.confirmDeletion?"Confirm deletion":"Confirm"," "))},dependencies:[me,at,ht,ct,mt,Bt,Ft,ot,ze,it,nt,We,Je,Ge,tt,Ze,Ye,rt,Xe,Pt,pt,lt,st,Qe,et,Xt,Ht,qe,pe],encapsulation:2});let o=r;return o})();var ei=(()=>{let r=class r{constructor(){this.router=S(se),this.http=S(W),this.layout=S(Z),this.authService=S(Ut),this.clipboard=S(Zt)}shareLinksList(){return this.http.get(qt).pipe(f(e=>e.map(t=>new $(t))))}shareLink(e){return this.http.get(`${te}/${e}`).pipe(f(t=>new $(t)))}shareLinkChild(e,t){return this.http.get(`${te}/${e}/${h.CHILDREN}/${t}`).pipe(f(n=>new $(n)))}linkFromSpaceOrShare(e,t,n){return this.http.get(`${te}/${e}/${n}/${t}`)}linkValidation(e){return this.http.get(`${jt}/${e}`).pipe(f(t=>t.ok?t.link:(t.error&&(t.error===we.UNAUTHORIZED?this.router.navigate([`${F.LINK}/${e}/${F.AUTH}`]).catch(console.error):this.router.navigate([`${F.LINK}/${e}/${t.error}`]).catch(console.error)),!1)),_e(()=>(this.authService.logout(),z(!1))))}linkAccess(e,t){t.share?.isDir||t.space?.alias?this.http.get(`${Le}/${e}`).subscribe(n=>{this.authService.initUserFromResponse(n),t.space?this.router.navigate([I.SPACES,t.space.alias]).catch(console.error):this.router.navigate([I.SPACES_SHARES,t.share.alias]).catch(console.error)}):vt(`${Le}/${e}`)}linkAuthentication(e,t){return this.http.post(`${Kt}/${e}`,{password:t}).pipe(f(n=>(this.authService.initUserFromResponse(n),this.router.navigate([`${F.LINK}/${e}`]).catch(console.error),!0)),_e(n=>(n.error.message===we.UNAUTHORIZED?this.layout.sendNotification("warning","Link","Bad password"):this.router.navigate([`${F.LINK}/${e}/${n.error.message}`]).catch(console.error),z(!1))))}copyLinkToClipboard(e){this.clipboard.copyFromContent(this.genLink(e))}genUUID(){return this.http.get(Gt).pipe(f(e=>e.uuid))}createLinkDialog(e){this.genUUID().subscribe(t=>{let n=this.layout.openDialog(ge,"md",{initialState:{link:{name:e.name,uuid:t,isActive:!0,nbAccess:0}}});this.subscribeToSubmitLinkModal(n,e)})}updateLinkFromSpaceOrShare(e,t,n,p){return this.http.put(`${te}/${e}/${n}/${t}`,p)}editLinkDialog(e,t,n){if(t.id===0||e?.linkSettings?.uuid){let p=this.layout.openDialog(ge,"md",{initialState:{link:e.linkSettings}});this.subscribeToSubmitLinkModal(p,t,e)}else this.linkFromSpaceOrShare(e.linkId,t.id,n).subscribe({next:p=>{let C=this.layout.openDialog(ge,"md",{initialState:{link:L(v({},p),{permissions:e.permissions})}});this.subscribeToSubmitLinkModal(C,t,e)},error:p=>this.layout.sendNotification("error","Link error",e.name||t.name,p)})}shareLinkGuestToMember(e,t,n){return new H({id:e,linkId:t,name:n.name,description:n.email,createdAt:n.createdAt,permissions:n.permissions,type:Rt.LINK,spaceRole:he.IS_MEMBER,linkSettings:n},[k.SHARE_INSIDE,k.SHARE_OUTSIDE])}subscribeToSubmitLinkModal(e,t,n){e.content.submitEvent.pipe(Oe(1)).subscribe(p=>{if(Object.keys(p).length){let C=Object.assign(e.content.link,p),x=this.shareLinkGuestToMember(C.userId||-(t.links.length+1),n?.linkId||-(t.links.length+1),C);x.linkId?t.links=[x,...t.links.filter(T=>T.linkId!==x.linkId)]:t.links=[x,...t.links]}e.content.layout.closeDialog()})}genLink(e){return`${document.location.origin}/#/${F.LINK}/${e}`}};r.\u0275fac=function(t){return new(t||r)},r.\u0275prov=R({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();export{Zt as a,De as b,Xt as c,Se as d,w as e,Jt as f,j as g,Qt as h,ge as i,ei as j};
1
+ import{c as Y,d as Te,h as ee,m as ue}from"./chunk-MYM43ENO.js";import{a as Ht}from"./chunk-LYZGJZNP.js";import{b as Ut}from"./chunk-NKGKBQBX.js";import{l as Pt,n as Rt,o as Nt,p as $t,q as U,r as Ot,s as H,w as Mt}from"./chunk-FNOTGWRW.js";import{a as Ft,b as Bt}from"./chunk-ZCOWBVOT.js";import{b as Q}from"./chunk-PXRT4L57.js";import{$a as de,Ba as he,Ca as Et,Cb as Z,Db as u,Gb as wt,Hb as xt,Ib as Tt,Ja as Ie,K as Ct,Mb as xe,N as At,Na as N,Nb as B,Ob as I,Pb as Dt,W as ce,Wa as bt,gb as yt,ib as vt,s as lt,t as pt,tb as It,w as ct,x as mt,y as ht,ya as k}from"./chunk-I2S3XPC5.js";import{d as se}from"./chunk-Y5RLD72B.js";import{Bb as oe,Cd as ot,Dd as st,De as St,Eb as D,Ed as le,Ef as _t,G as _e,Gb as d,Jd as pe,Kd as at,L as Oe,Oa as l,Od as dt,Pc as qe,Qa as ke,Qb as je,Ra as Ue,Rb as J,Sb as P,Tb as c,Ub as q,Vb as O,Wb as Ke,Wf as kt,Xb as Ee,Yb as be,Yc as W,Zb as ye,ab as re,cc as G,ea as R,ed as Ge,f as Ne,fd as We,gc as Ve,ha as Me,hd as ae,ia as ne,ie as ut,ja as S,jd as Ze,kc as b,kd as Ye,lb as A,ld as ve,le as ft,mb as E,mc as y,nb as He,nd as _,oa as K,od as Xe,og as me,p as z,pa as V,pb as Ce,pd as ze,pg as we,qb as Ae,qd as Je,qg as Lt,ra as Fe,rb as m,rg as F,sb as s,sd as Qe,t as $e,tb as a,td as et,ub as g,ud as tt,v as f,vd as it,wd as nt,wf as gt,xa as Be,xd as rt}from"./chunk-IOIBQGHN.js";import{n as M}from"./chunk-DM4NXKEP.js";import{a as v,b as L,d as Re}from"./chunk-KAVP6UXH.js";var X={BASE:`${ce}/link`,LINK:"link",VALIDATION:"validation",ACCESS:"access",AUTH:"auth"},jt=`${X.BASE}/${X.VALIDATION}`,Le=`${X.BASE}/${X.ACCESS}`,Kt=`${X.BASE}/${X.AUTH}`;var h={BASE:`${ce}/shares`,LIST:"list",CHILDREN:"children",LINKS:"links",LINKS_LIST:"links/list",LINKS_UUID:"links/uuid"},Vt=`${h.BASE}/${h.LIST}`,te=`${h.BASE}/${h.LINKS}`,qt=`${h.BASE}/${h.LINKS_LIST}`,Gt=`${h.BASE}/${h.LINKS_UUID}`;var Wt=new Me("WindowToken",typeof window<"u"&&window.document?{providedIn:"root",factory:()=>window}:{providedIn:"root",factory:()=>{}});var Zt=(()=>{class o{constructor(i,e,t){this.ngZone=i,this.document=e,this.window=t,this.copySubject=new Ne,this.copyResponse$=this.copySubject.asObservable(),this.config={}}configure(i){this.config=i}copy(i){if(!this.isSupported||!i)return this.pushCopyResponse({isSuccess:!1,content:i});let e=this.copyFromContent(i);return e?this.pushCopyResponse({content:i,isSuccess:e}):this.pushCopyResponse({isSuccess:!1,content:i})}get isSupported(){return!!this.document.queryCommandSupported&&!!this.document.queryCommandSupported("copy")&&!!this.window}isTargetValid(i){if(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement){if(i.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');return!0}throw new Error("Target should be input or textarea")}copyFromInputElement(i,e=!0){try{this.selectTarget(i);let t=this.copyText();return this.clearSelection(e?i:void 0,this.window),t&&this.isCopySuccessInIE11()}catch{return!1}}isCopySuccessInIE11(){let i=this.window.clipboardData;return!(i&&i.getData&&!i.getData("Text"))}copyFromContent(i,e=this.document.body){if(this.tempTextArea&&!e.contains(this.tempTextArea)&&this.destroy(this.tempTextArea.parentElement||void 0),!this.tempTextArea){this.tempTextArea=this.createTempTextArea(this.document,this.window);try{e.appendChild(this.tempTextArea)}catch{throw new Error("Container should be a Dom element")}}this.tempTextArea.value=i;let t=this.copyFromInputElement(this.tempTextArea,!1);return this.config.cleanUpAfterCopy&&this.destroy(this.tempTextArea.parentElement||void 0),t}destroy(i=this.document.body){this.tempTextArea&&(i.removeChild(this.tempTextArea),this.tempTextArea=void 0)}selectTarget(i){return i.select(),i.setSelectionRange(0,i.value.length),i.value.length}copyText(){return this.document.execCommand("copy")}clearSelection(i,e){i&&i.focus(),e.getSelection()?.removeAllRanges()}createTempTextArea(i,e){let t=i.documentElement.getAttribute("dir")==="rtl",n;n=i.createElement("textarea"),n.style.fontSize="12pt",n.style.border="0",n.style.padding="0",n.style.margin="0",n.style.position="absolute",n.style[t?"right":"left"]="-9999px";let p=e.pageYOffset||i.documentElement.scrollTop;return n.style.top=p+"px",n.setAttribute("readonly",""),n}pushCopyResponse(i){this.copySubject.observers.length>0&&this.ngZone.run(()=>{this.copySubject.next(i)})}pushCopyReponse(i){this.pushCopyResponse(i)}}return o.\u0275fac=function(i){return new(i||o)(ne(Ue),ne(Fe),ne(Wt,8))},o.\u0275prov=R({token:o,factory:o.\u0275fac,providedIn:"root"}),o})();var De=(function(o){return o[o.COMMON=0]="COMMON",o[o.LINK=1]="LINK",o})(De||{}),Yt=Object.values(k).filter(o=>o!==k.SHARE_INSIDE).sort().join(":");function ti(o,r){if(o&1&&g(0,"fa-icon",2),o&2){let i=d();P(i.repository.class),je("min-width",i.galleryMode.dimensions/3,"px")("min-height",i.galleryMode.dimensions/3,"px")("font-size",i.galleryMode.faSize/1.8,"px"),m("icon",i.repository.icon)}}function ii(o,r){if(o&1&&g(0,"fa-icon",5),o&2){let i=d(2);P(i.repository.class),m("icon",i.repository.icon)}}function ni(o,r){if(o&1&&(c(0),b(1,"translate")),o&2){let i=d(2);O(" ",y(1,1,i.repository.label,i.locale.language)," ")}}function ri(o,r){if(o&1&&c(0),o&2){let i=d(2);O(" ",i.repository.label," ")}}function oi(o,r){if(o&1&&(s(0,"div",1),A(1,ii,1,3,"fa-icon",3),s(2,"span",4),A(3,ni,2,4)(4,ri,1,1),a()()),o&2){let i=d();l(),E(i.showIcon?1:-1),l(2),E(i.repository.translate?3:4)}}var Xt=(()=>{let r=class r{constructor(){this.showIcon=!0,this.showFullPath=!1,this.locale=S(le),this.layout=S(Z),this.unknownRepository={icon:dt,label:"",class:"circle-primary-icon",translate:!1}}ngOnInit(){this.setRepository()}ngOnChanges(){this.setRepository()}setRepository(){this.share.parent?.id||this.share.parent?.id===0?this.repository={icon:B.SHARES,label:this.share.parent.name,class:"circle-purple-icon",translate:!1}:this.share.file?.ownerId?this.repository={icon:B.PERSONAL,label:xe.PERSONAL_FILES,class:"circle-primary-icon",translate:!0}:this.share.file?.space?.alias?this.repository={icon:B.SPACES,label:`${this.share.file.space.name}`,class:"circle-primary-icon",translate:!1}:this.share.externalPath?this.repository={icon:B.EXTERNAL,label:"External",class:"circle-primary-icon",translate:!0}:this.repository=v({},this.unknownRepository),this.showFullPath&&this.setFullPath()}setFullPath(){if(!this.repository.label)return;let e=this.share.file?.path?this.share.file.path.split("/").filter(t=>t&&t!=="."):[];this.share.parent?.id&&!this.share.file?.id&&this.share.file?.path.indexOf("/")===-1?e.shift():this.share.file?.space?.alias&&this.share.file.space?.root?.alias&&(e.length?e.unshift(this.share.file.space.root.name):e.push(this.share.file.space.root.name)),this.repository.label===xe.PERSONAL_FILES&&(this.repository.label=this.layout.translateString(this.repository.label)),e.length&&(this.repository.label=`${this.repository.label}/${e.join("/")}`)}};r.\u0275fac=function(t){return new(t||r)},r.\u0275cmp=re({type:r,selectors:[["app-share-repository"]],inputs:{share:"share",galleryMode:"galleryMode",showIcon:"showIcon",showFullPath:"showFullPath"},features:[Be],decls:2,vars:1,consts:[[3,"icon","class","min-width","min-height","font-size"],[1,"d-flex","align-items-center","overflow-wrap-and-whitespace"],[3,"icon"],[1,"me-2",3,"icon","class"],["draggable","false",1,"no-pointer-events"],[1,"me-2",3,"icon"]],template:function(t,n){t&1&&A(0,ti,1,9,"fa-icon",0)(1,oi,5,2,"div",1),t&2&&E(n.galleryMode?0:1)},dependencies:[me,pe],encapsulation:2});let o=r;return o})();function Se(o){o.file?.id?(o.file.isDir&&(o.file.mime=o.parent?.alias?Te:Y),o.mimeUrl=ee(o.file.mime)):o.mimeUrl=ee(o.parent?.alias?Te:Y)}function zt(o){let r,i=o.file.path?o.file.path.split("/").filter(t=>t&&t!=="."):[];if(o.parent?.id){if(!i.length)return[I.SPACES_SHARES,o.parent.alias];r=`${I.SPACES_SHARES}/${o.parent.alias}`}else o.file.space?.alias?o.file.inTrash?r=`${I.SPACES_TRASH}/${o.file.space.alias}`:(r=`${I.SPACES_FILES}/${o.file.space.alias}`,o.file.space?.root?.alias&&(i.length?r=`${r}/${o.file.space.root.alias}`:i.push(o.file.space.root.name))):o.file?.ownerId?r=`${o.file.inTrash?I.PERSONAL_TRASH:I.PERSONAL_FILES}`:console.warn("unable to find the right file path",o);let e=i.pop();return r&&i.length&&(r=`${r}/${i.join("/")}`),[r,e]}var w=class{constructor(r){this.members=[],this.links=[],this.hPerms={},this.setMembers(N("members",r),r.externalPath||r.file?.isDir?[k.SHARE_INSIDE]:[]),Object.assign(this,r),Se(this),this.checkFile(),this.setPermissions()}fallBackMimeUrl(){this.mimeUrl=ue}setMembers(r,i){if(r)for(let e of r)e.linkId?this.links.push(new H(e,[...i,k.SHARE_OUTSIDE])):this.members.push(new H(e,i))}checkFile(){this.file&&(!this.file.path&&this.file.space.root?.name&&(this.file.path=this.file.space.root.name,this.file.name=this.file.space.root.name),this.file.permissions&&(this.file.permissions=this.file.permissions.split(":").filter(r=>r===k.SHARE_INSIDE||r===k.ADD&&this.file.id&&!this.file.isDir?!1:!(r===k.DELETE&&this.file.id&&!this.file.isDir)).join(":")))}setPermissions(){typeof this.file?.permissions=="string"?this.hPerms=U(this.file.permissions):this.externalPath&&(this.hPerms=U(Yt))}};var Jt=(()=>{let r=class r{constructor(){this.http=S(W),this.router=S(se)}getShare(e){return this.http.get(`${h.BASE}/${e}`).pipe(f(t=>new w(t)))}createShare(e){return this.http.post(h.BASE,e).pipe(f(t=>new w(t)))}updateShare(e){return this.http.put(`${h.BASE}/${e.id}`,e).pipe(f(t=>new w(t)))}deleteShare(e){return this.http.delete(`${h.BASE}/${e}`)}listShares(){return this.http.get(Vt)}getShareChild(e,t){return this.http.get(`${h.BASE}/${e}/${h.CHILDREN}/${t}`).pipe(f(n=>new w(n)))}updateShareChild(e,t,n){return this.http.put(`${h.BASE}/${e}/${h.CHILDREN}/${t}`,n).pipe(f(p=>new w(p)))}deleteShareChild(e,t){return this.http.delete(`${h.BASE}/${e}/${h.CHILDREN}/${t}`)}listChildShares(e){return this.http.get(`${h.BASE}/${e}/${h.CHILDREN}`)}initShareFromFile(e,t,n=!1,p=!1){let C,x=null,T=v({id:0,name:"",createdAt:new Date,modifiedAt:new Date,storageIndexing:!0,enabled:!0},n?{parent:{id:0,ownerId:0,alias:t.space.alias,name:t.space.name}}:{});if(t){p&&(x=t.root.id);let Pe=null;(t?.root?.owner.login===e.login||!t?.space?.alias)&&(t.space=null,Pe=e.id),C=new w(L(v({},T),{name:t.name,file:L(v({},t),{path:p?".":bt(t.path,2),ownerId:Pe})}))}else C=new w(T);return[C,x]}goTo(e){if(!e.id)return $e(z(!1));if(e.externalPath&&!e.parent?.id)return this.router.navigate([I.SPACES_SHARES],{queryParams:{select:e.name}});if(e.parent?.id&&!e.file?.id&&e.file?.path.indexOf("/")===-1)return this.router.navigate([I.SPACES_SHARES],{queryParams:{select:e.parent.name}});{let[t,n]=zt(e);return this.router.navigate([t],{queryParams:{select:n}})}}};r.\u0275fac=function(t){return new(t||r)},r.\u0275prov=R({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();var $=class{constructor(r){this.hTimeExpirationAgo=0,this.hPerms={},this.newly=0,Object.assign(this,r),Se(this),this.updatePermission(),this.updateTimes()}fallBackMimeUrl(){this.mimeUrl=ue}updatePermission(){this.hPerms=U(this.link.permissions)}updateTimes(){if(this.hTimeAccessAgo=M(this.link.currentAccess).fromNow(!0),this.newly=de(this.link.currentAccess),this.link.expiresAt){this.link.expiresAt=new Date(M(this.link.expiresAt).local().format("YYYY-MM-DD"));let r=Math.max(0,M(this.link.expiresAt).diff(M(),"hours"));r===0?this.hTimeExpirationAgo=0:r<=24?this.hTimeExpirationAgo=1:this.hTimeExpirationAgo=Math.round(r/24)+1}else this.hTimeExpirationAgo=0}};var j=class{constructor(r){this.roots=[],this.managers=[],this.members=[],this.links=[],this.hPerms={},this.newly=0,this.hPerms=U(r.permissions),this.setMembers(N("members",r)),this.setRoots(N("roots",r)),Object.assign(this,r),this.hTimeAgo=M(this.modifiedAt).fromNow(!0),this.newly=de(this.modifiedAt),this.sort()}addRoot(r,i=!1){r.hPerms=Nt(r.permissions,[k.SHARE_INSIDE]),r.owner?.login&&(r.owner.avatarUrl=It(r.owner.login)),r.file.mimeUrl=ee(r.file?.mime?r.file.mime:Y),i?this.roots.unshift(r):this.roots.push(r),r.isDir=r.file.mime===Y||!!r.externalPath}havePermission(r){return this.permissions.indexOf(r)>-1}setMembers(r){if(r)for(let i of r){let e=new H(i);e.isLink?this.links.push(e):e.spaceRole===he.IS_MANAGER?this.managers.push(e):this.members.push(e)}}setRoots(r){if(r)for(let i of r)this.addRoot(i)}sort(){Q(this.roots,"createdAt",!1),Q(this.managers,"createdAt",!1),Q(this.members,"createdAt",!1),Q(this.links,"createdAt",!1)}};var Qt=(()=>{let r=class r{constructor(){this.http=S(W)}listSpaces(){return this.http.get(wt).pipe(f(e=>e.map(t=>new j(t))))}getSpace(e){return this.http.get(`${u.BASE}/${e}`).pipe(f(t=>new j(t)))}getUserSpaceRoots(e){return this.http.get(`${u.BASE}/${e}/${u.ROOTS}`)}createUserSpaceRoots(e,t){return this.http.post(`${u.BASE}/${e}/${u.ROOTS}`,t)}updateUserSpaceRoots(e,t){return this.http.put(`${u.BASE}/${e}/${u.ROOTS}`,t)}updateSpace(e){return this.http.put(`${u.BASE}/${e.id}`,e).pipe(f(t=>t?new j(t):null))}createSpace(e){return this.http.post(u.BASE,e).pipe(f(t=>(t.permissions=Et,new j(t))))}deleteSpace(e,t){return this.http.request("delete",`${u.BASE}/${e}`,{body:t})}searchSpaces(e){return this.http.request("search",u.BASE,{body:e})}listSpaceShares(e){return this.http.get(`${u.BASE}/${e}/${u.SHARES}`)}getSpaceShare(e,t){return this.http.get(`${u.BASE}/${e}/${u.SHARES}/${t}`).pipe(f(n=>new w(n)))}updateSpaceShare(e,t){return this.http.put(`${u.BASE}/${e}/${u.SHARES}/${t.id}`,t).pipe(f(n=>new w(n)))}deleteSpaceShare(e,t){return this.http.delete(`${u.BASE}/${e}/${u.SHARES}/${t}`)}getSpaceShareLink(e,t){return this.http.get(`${u.BASE}/${e}/${u.LINKS}/${t}`).pipe(f(n=>new $(n)))}listTrashBins(){return this.http.get(xt)}checkSpaceRootPath(e){return this.http.post(Tt,{path:e})}};r.\u0275fac=function(t){return new(t||r)},r.\u0275prov=R({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();var ai=o=>({dateInputFormat:"YYYY-MM-DD",containerClass:"theme-dark-blue",returnFocusToInput:!0,minDate:o,showWeekNumbers:!1}),li=(o,r)=>r.key;function pi(o,r){o&1&&(s(0,"span",4),c(1,"Edit link"),a())}function ci(o,r){o&1&&(s(0,"span",4),c(1,"New link"),a())}function mi(o,r){o&1&&g(0,"div",54)}function hi(o,r){if(o&1){let i=oe();s(0,"button",53),b(1,"translate"),ye("ngModelChange",function(t){let n=K(i).$implicit,p=d(3);return be(p.permissions[n.key],t)||(p.permissions[n.key]=t),V(t)}),D("ngModelChange",function(){K(i);let t=d(3);return V(t.onPermissionChange())}),g(2,"fa-icon",50),a(),A(3,mi,1,0,"div",54)}if(o&2){let i=r.$implicit,e=r.$index,t=r.$count,n=d(3);Ee("ngModel",n.permissions[i.key]),m("tooltip",y(1,4,n.SPACES_PERMISSIONS_TEXT[i.key].text,n.locale.language)),l(2),m("icon",n.SPACES_PERMISSIONS_TEXT[i.key].icon),l(),E(e===t-1?3:-1)}}function di(o,r){if(o&1&&(Ce(0,hi,4,7,null,null,li),b(2,"keyvalue")),o&2){let i=d(2);Ae(y(2,0,i.permissions,i.originalOrderKeyValue))}}function ui(o,r){if(o&1&&(s(0,"div",51),g(1,"app-share-repository",55),a()),o&2){let i=d(2);l(),m("share",i.share)("showIcon",!0)("showFullPath",!0)}}function fi(o,r){if(o&1){let i=oe();s(0,"div",44),g(1,"fa-icon",45),s(2,"div",46)(3,"span"),c(4),a(),s(5,"span",47),c(6),a()(),s(7,"div",48),A(8,di,3,3),s(9,"button",49),b(10,"translate"),D("click",function(){K(i);let t=d();return V(t.toggleRequireAuth())}),g(11,"fa-icon",50),a(),s(12,"button",49),b(13,"translate"),D("click",function(){K(i);let t=d();return V(t.copyToClipboard())}),g(14,"fa-icon",50),a()()(),A(15,ui,2,3,"div",51),g(16,"hr",52)}if(o&2){let i=d();l(),m("icon",i.icons.links),l(3),q(i.linkForm.value.name||i.linkForm.value.shareName),l(2),q(i.linkForm.value.email),l(2),E(i.share&&i.permissions?8:-1),l(),P(G("btn btn-sm ",i.linkForm.value.requireAuth?"btn-success":"btn-warning")),m("tooltip",y(10,15,"Password",i.locale.language)),l(2),m("icon",i.linkForm.value.requireAuth?i.icons.faLock:i.icons.faLockOpen),l(),P(G("btn btn-sm ms-2 ",i.linkWasCopied?"btn-info":"btn-secondary")),m("tooltip",y(13,18,"Copy link",i.locale.language)),l(2),m("icon",i.linkWasCopied?i.icons.faClipboardCheck:i.icons.faClipboard),l(),E(i.share?15:-1)}}function Si(o,r){if(o&1&&(s(0,"span"),c(1),a()),o&2){let i=d();P(G("badge rounded-pill ",(i.share?i.share.link.nbAccess:i.link.nbAccess)>=i.linkForm.value.limitAccess?"bg-danger":"bg-success")),l(),Ke(" ",i.share?i.share.link.nbAccess:i.link.nbAccess,"/",i.linkForm.value.limitAccess," ")}}function gi(o,r){if(o&1&&(s(0,"span",20),c(1),a()),o&2){let i=d();l(),q(i.share?i.share.link.nbAccess:i.link.nbAccess)}}function _i(o,r){if(o&1&&(s(0,"div",27)(1,"label",56),c(2,"Share name"),a(),g(3,"input",57),b(4,"translate"),a(),s(5,"div",27)(6,"label",58),c(7,"Share description"),a(),g(8,"input",59),b(9,"translate"),a()),o&2){let i=d();l(3),J("is-invalid",i.linkForm.controls.shareName.invalid),m("placeholder",y(4,4,"Share name",i.locale.language)),l(5),m("placeholder",y(9,7,"Share description",i.locale.language))}}function ki(o,r){if(o&1&&(s(0,"option",30),c(1),a()),o&2){let i=r.$implicit,e=d();m("ngValue",i),l(),q(e.i18nLanguageText[i])}}function Ci(o,r){if(o&1&&(s(0,"div",37),g(1,"app-password-strength-bar",60),a()),o&2){let i=d();l(),m("passwordToCheck",i.password)}}function Ai(o,r){if(o&1){let i=oe();s(0,"button",61),D("click",function(){K(i);let t=d();return V(t.confirmDeletion=!0)}),c(1," Remove "),a()}if(o&2){let i=d();m("disabled",i.confirmDeletion)}}var ge=(()=>{let r=class r{constructor(){this.layout=S(Z),this.parentSpaceId=null,this.isSharesRepo=!1,this.inSharesList=!1,this.submitEvent=new ke,this.shareChange=new ke,this.locale=S(le),this.confirmDeletion=!1,this.submitted=!1,this.SPACES_PERMISSIONS_TEXT=Dt,this.originalOrderKeyValue=yt,this.icons={faEye:ut,faEyeSlash:kt,links:B.LINKS,faClipboard:St,faClipboardCheck:ft,faLock:_t,faLockOpen:gt},this.languages=this.layout.getLanguages(),this.minDate=Ie(),this.defaultPassword=this.layout.translateString(Ct),this.passwordMinLength=8,this.password="",this.linkIsExpired=!1,this.linkIsHovered=!1,this.linkWasCopied=!1,this.i18nLanguageText=At,this.userService=S(Mt),this.sharesService=S(Jt),this.linksService=S(ei),this.spacesService=S(Qt),this.minDate.setDate(this.minDate.getDate()+1)}ngOnInit(){this.link?this.initLink():this.file?this.initFile():this.initShareLink(),this.linkForm.value.requireAuth&&(this.password=this.defaultPassword),this.linkForm.value.expiresAt&&this.isLinkIsExpired(this.share?this.share.link.expiresAt:this.link.expiresAt),this.linkForm.controls.expiresAt.valueChanges.subscribe(e=>this.isLinkIsExpired(e))}onPermissionChange(){let e=Ot(this.permissions);this.linkForm.controls.permissions.setValue(e),e!==this.share.link.permissions?this.linkForm.controls.permissions.markAsDirty():this.linkForm.controls.permissions.markAsPristine()}toggleRequireAuth(){this.linkForm.controls.requireAuth.setValue(!this.linkForm.value.requireAuth),this.linkForm.controls.requireAuth.markAsDirty()}copyToClipboard(){this.linksService.copyLinkToClipboard(this.share?this.share.link.uuid:this.link.uuid),this.linkWasCopied=!0,this.layout.sendNotification("info","Link copied",this.linkForm.value.name||this.linkForm.value.shareName),setTimeout(()=>this.linkWasCopied=!1,3e3)}onCancel(){this.confirmDeletion?this.confirmDeletion=!1:this.layout.closeDialog()}onSubmit(){if(this.submitted=!0,this.confirmDeletion){(this.parentSpaceId?this.spacesService.deleteSpaceShare(this.parentSpaceId,this.share.id):this.sharesService.deleteShare(this.share.id)).subscribe({next:()=>{this.layout.sendNotification("success","Link deleted",this.share.link.name||this.share.name),this.shareChange.emit(["delete",this.share]),this.layout.closeDialog()},error:p=>{this.layout.sendNotification("error","Delete share",this.share.name,p),this.layout.closeDialog()}});return}if(this.file?.id){let t=this.share,{link:n}=t,p=Re(t,["link"]),C=L(v(v({},n),this.linkForm.value),{password:this.mustIncludePassword()?this.password:void 0});p.name=N("shareName",C),p.description=N("shareDescription",C);let x=this.linksService.shareLinkGuestToMember(-1,-1,C);this.sharesService.createShare(L(v({},p),{type:De.LINK,links:[x]})).subscribe({next:T=>{this.shareChange.emit(["add",T]),this.layout.sendNotification("success","Link created",n.name||T.name),this.layout.closeDialog()},error:T=>{this.layout.sendNotification("error","Link error",this.share.name,T),this.layout.closeDialog()}});return}let e={};for(let n in this.linkForm.controls)this.linkForm.controls[n].dirty&&(e[n]=this.linkForm.controls[n].value);if(this.mustIncludePassword()&&(e.password=this.password),this.share?.id){Object.keys(e).length&&this.linksService.updateLinkFromSpaceOrShare(this.share.link.id,this.share.id,Lt.SHARE,e).subscribe({next:n=>{this.share.name=this.linkForm.value.shareName,this.share.description=this.linkForm.value.shareDescription,this.share.link=Object.assign(this.share.link,n),this.share.updateTimes(),this.share.updatePermission(),this.shareChange.emit(["update",this.share]),this.layout.closeDialog()},error:n=>{this.layout.sendNotification("error","Link error",this.share.link.name||this.share.name,n),this.layout.closeDialog()}}),this.layout.closeDialog();return}this.submitEvent.emit(e)}initFile(){let e=this.sharesService.initShareFromFile(this.userService.user,this.file,this.isSharesRepo,this.inSharesList)[0];this.share=L(v({},e),{link:{id:-1,userId:-1,uuid:"",isActive:!0,requireAuth:!1,permissions:"",nbAccess:0,limitAccess:0}}),this.linksService.genUUID().subscribe(t=>this.share.link.uuid=t),this.initShareLink(),this.onPermissionChange()}initShareLink(){this.linkForm=new ve({shareName:new _(this.share.name,ae.required),shareDescription:new _(this.share.description||""),name:new _(this.share.link?.name||""),email:new _(this.share.link?.email||"",ae.email),language:new _(this.share.link.language||null),limitAccess:new _(this.share.link.limitAccess||null),expiresAt:new _(this.share.link.expiresAt||null),requireAuth:new _(this.share.link.requireAuth||!1),permissions:new _(this.share.link.permissions),isActive:new _(this.share.link.isActive)}),this.permissions=$t(this.share.file.permissions,this.share.link.permissions,[k.SHARE_INSIDE,k.SHARE_OUTSIDE,...this.share.file.isDir?[]:[k.DELETE,k.ADD]])}initLink(){this.linkForm=new ve({shareName:new _(""),shareDescription:new _(""),name:new _(this.link.name||""),email:new _(this.link.email||"",ae.email),language:new _(this.link.language||null),limitAccess:new _(this.link.limitAccess||null),expiresAt:new _(this.link.expiresAt||null),requireAuth:new _(this.link.requireAuth||!1),permissions:new _(this.link.permissions),isActive:new _(this.link.isActive)}),this.link.id||(this.linkForm.controls.name.markAsDirty(),this.linkForm.controls.isActive.markAsDirty())}isLinkIsExpired(e){if(e==null){if(this.linkIsExpired=!1,e===null)return;this.linkForm.controls.expiresAt.setValue(null)}this.linkIsExpired=Ie()>=e}mustIncludePassword(){return!!this.password.length&&this.password!==this.defaultPassword}};r.\u0275fac=function(t){return new(t||r)},r.\u0275cmp=re({type:r,selectors:[["app-link-dialog"]],inputs:{share:"share",parentSpaceId:"parentSpaceId",link:"link",file:"file",isSharesRepo:"isSharesRepo",inSharesList:"inSharesList"},outputs:{submitEvent:"submitEvent",shareChange:"shareChange"},decls:73,vars:52,consts:[[1,"modal-header","align-items-center"],[1,"modal-title"],[1,"me-2",3,"icon"],[1,"modal-title","ms-auto"],["l10nTranslate",""],["aria-label","Close","type","button",1,"btn-close","btn-close-white","ms-2",3,"click"],[1,"modal-body"],["autocomplete","off",3,"formGroup"],[1,"d-flex"],[1,"d-flex","flex-column","flex-grow-1"],[1,"d-flex","align-items-center","cursor-pointer","py-2",3,"mouseover","mouseleave","focus","click"],["for","link","l10nTranslate",""],["id","link",1,"ms-auto"],[1,"d-flex","align-items-center","py-2"],["for","state","l10nTranslate","",1,"cursor-pointer","me-auto"],[1,"d-flex","align-items-center","form-check","form-switch","cursor-pointer"],["id","state","formControlName","isActive","type","checkbox","role","button",1,"form-check-input"],["for","access","l10nTranslate",""],["id","access",1,"ms-auto"],[3,"class"],[1,"badge","rounded-pill","bg-success"],[1,"d-flex","align-items-center"],["for","guestName","l10nTranslate",""],["id","guestName","formControlName","name","type","text",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],[1,"d-flex","align-items-center","justify-content-between","px-0"],["for","guestEmail","l10nTranslate",""],["id","guestEmail","autocomplete","off","formControlName","email","type","email",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],[1,"d-flex","align-items-center","justify-content-between"],["for","guestLanguage","l10nTranslate",""],["id","guestLanguage","formControlName","language",1,"form-control","form-select","form-select-sm","ms-auto","w-50"],[3,"ngValue"],["for","limitAccess","l10nTranslate",""],["id","limitAccess","formControlName","limitAccess","min","1","type","number",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],["for","expiration","l10nTranslate",""],["bsDatepicker","","id","expiration","formControlName","expiresAt","placement","left","type","text",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder","bsConfig"],[1,"d-flex","align-items-center","px-0"],["for","requireAuth","translate","",1,"cursor-pointer","me-auto"],[1,"d-flex","align-items-center","d-none","d-sm-flex","mx-auto"],["id","requireAuth","formControlName","requireAuth","type","checkbox","role","button",1,"form-check-input"],["placeholder","Set a password",2,"width","45%",3,"passwordChange","isRequired","disabled","passwordMinLength","password","showGenerator"],[1,"modal-footer"],["type","button","l10nTranslate","",1,"btn","btn-sm","btn-danger",3,"disabled"],["data-dismiss","modal","type","button","l10nTranslate","",1,"btn","btn-sm","btn-secondary","ms-auto",3,"click"],["type","button","l10nTranslate","",3,"click","disabled"],[1,"d-flex","flex-fill","align-items-center"],[1,"circle-primary-icon","me-2",3,"icon"],[1,"d-flex","flex-column","overflow-wrap-and-whitespace","me-2"],[1,"fs-xxxs"],[1,"d-flex","ms-auto"],["container","body","type","button",3,"click","tooltip"],["size","lg",3,"icon"],[1,"d-flex","align-items-center","d-none","d-sm-flex","py-2"],[1,"my-2"],["btnCheckbox","","type","button",1,"btn","btn-sm","btn-custom","me-0","ms-2",3,"ngModelChange","ngModel","tooltip"],[1,"vr","mx-2"],["id","file",3,"share","showIcon","showFullPath"],["for","shareName","l10nTranslate",""],["id","shareName","formControlName","shareName","type","email",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],["for","shareDescription","l10nTranslate",""],["id","shareDescription","formControlName","shareDescription","type","email",1,"form-control","form-control-sm","ms-auto","w-50",3,"placeholder"],[3,"passwordToCheck"],["type","button","l10nTranslate","",1,"btn","btn-sm","btn-danger",3,"click","disabled"]],template:function(t,n){t&1&&(s(0,"div",0)(1,"h4",1),g(2,"fa-icon",2),s(3,"span"),c(4),a()(),s(5,"h4",3),A(6,pi,2,0,"span",4)(7,ci,2,0,"span",4),a(),s(8,"button",5),D("click",function(){return n.layout.closeDialog()}),a()(),s(9,"div",6),A(10,fi,17,21),s(11,"form",7)(12,"div",8)(13,"div",9)(14,"div",10),D("mouseover",function(){return n.linkIsHovered=!0})("mouseleave",function(){return n.linkIsHovered=!1})("focus",function(){return n.linkIsHovered=!0})("click",function(){return n.copyToClipboard()}),s(15,"label",11),c(16,"Link"),a(),s(17,"span",12),c(18),a()(),s(19,"div",13)(20,"label",14),c(21,"Active"),a(),s(22,"div",15),g(23,"input",16),s(24,"span"),c(25),b(26,"translate"),a()()(),s(27,"div",13)(28,"label",17),c(29,"Current access count"),a(),s(30,"span",18),A(31,Si,2,5,"span",19)(32,gi,2,1,"span",20),a()(),A(33,_i,10,10),s(34,"div",21)(35,"label",22),c(36,"Guest name"),a(),g(37,"input",23),b(38,"translate"),a(),s(39,"div",24)(40,"label",25),c(41,"Guest email"),a(),g(42,"input",26),b(43,"translate"),a(),s(44,"div",27)(45,"label",28),c(46,"Guest language"),a(),s(47,"select",29),Ce(48,ki,2,2,"option",30,He),a()(),s(50,"div",27)(51,"label",31),c(52,"Limit access"),a(),g(53,"input",32),b(54,"translate"),a(),s(55,"div",27)(56,"label",33),c(57,"Expiration"),a(),g(58,"input",34),b(59,"translate"),a(),s(60,"div",35)(61,"label",36),c(62,"Password"),a(),A(63,Ci,2,1,"div",37),s(64,"div",15),g(65,"input",38),a(),s(66,"app-input-password",39),ye("passwordChange",function(C){return be(n.password,C)||(n.password=C),C}),a()()()()()(),s(67,"div",40),A(68,Ai,2,1,"button",41),s(69,"button",42),D("click",function(){return n.onCancel()}),c(70,"Cancel"),a(),s(71,"button",43),D("click",function(){return n.onSubmit()}),c(72),a()()),t&2&&(l(2),m("icon",n.icons.links),l(2),q(n.linkForm.value.name||n.linkForm.value.shareName),l(2),E(n.share!=null&&n.share.id||n.link!=null&&n.link.id?6:7),l(4),E(n.share||n.link?10:-1),l(),m("formGroup",n.linkForm),l(6),J("text-primary",n.linkIsHovered),l(),O(" ",n.share?n.share.link.uuid:n.link.uuid," "),l(6),P(G("badge rounded-pill ms-3 ",n.linkForm.value.isActive?"bg-primary":"bg-danger")),l(),O(" ",y(26,35,n.linkForm.value.isActive?"yes":"no",n.locale.language)," "),l(6),E(n.linkForm.value.limitAccess?31:32),l(2),E(n.share?33:-1),l(4),m("placeholder",y(38,38,"Guest name",n.locale.language)),l(5),J("is-invalid",n.linkForm.controls.email.invalid),m("placeholder",y(43,41,"Guest email",n.locale.language)),l(6),Ae(n.languages),l(5),m("placeholder",y(54,44,"Unlimited",n.locale.language)),l(5),J("text-danger",n.linkIsExpired),m("placeholder",y(59,47,"Never expires",n.locale.language))("bsConfig",Ve(50,ai,n.minDate)),l(5),E(n.linkForm.value.requireAuth&&n.password!==n.defaultPassword?63:-1),l(3),m("isRequired",n.linkForm.value.requireAuth)("disabled",!n.linkForm.value.requireAuth)("passwordMinLength",n.passwordMinLength),Ee("password",n.password),m("showGenerator",!0),l(2),E(n.share!=null&&n.share.id?68:-1),l(3),P(G("btn btn-sm ",n.confirmDeletion?"btn-danger":"btn-primary")),m("disabled",n.linkForm.invalid||n.linkForm.controls.requireAuth.value&&n.password.length<n.passwordMinLength||n.submitted),l(),O(" ",n.confirmDeletion?"Confirm deletion":"Confirm"," "))},dependencies:[me,at,ht,ct,mt,Bt,Ft,ot,ze,it,nt,We,Je,Ge,tt,Ze,Ye,rt,Xe,Pt,pt,lt,st,Qe,et,Xt,Ht,qe,pe],encapsulation:2});let o=r;return o})();var ei=(()=>{let r=class r{constructor(){this.router=S(se),this.http=S(W),this.layout=S(Z),this.authService=S(Ut),this.clipboard=S(Zt)}shareLinksList(){return this.http.get(qt).pipe(f(e=>e.map(t=>new $(t))))}shareLink(e){return this.http.get(`${te}/${e}`).pipe(f(t=>new $(t)))}shareLinkChild(e,t){return this.http.get(`${te}/${e}/${h.CHILDREN}/${t}`).pipe(f(n=>new $(n)))}linkFromSpaceOrShare(e,t,n){return this.http.get(`${te}/${e}/${n}/${t}`)}linkValidation(e){return this.http.get(`${jt}/${e}`).pipe(f(t=>t.ok?t.link:(t.error&&(t.error===we.UNAUTHORIZED?this.router.navigate([`${F.LINK}/${e}/${F.AUTH}`]).catch(console.error):this.router.navigate([`${F.LINK}/${e}/${t.error}`]).catch(console.error)),!1)),_e(()=>(this.authService.logout(),z(!1))))}linkAccess(e,t){t.share?.isDir||t.space?.alias?this.http.get(`${Le}/${e}`).subscribe(n=>{this.authService.initUserFromResponse(n),t.space?this.router.navigate([I.SPACES,t.space.alias]).catch(console.error):this.router.navigate([I.SPACES_SHARES,t.share.alias]).catch(console.error)}):vt(`${Le}/${e}`)}linkAuthentication(e,t){return this.http.post(`${Kt}/${e}`,{password:t}).pipe(f(n=>(this.authService.initUserFromResponse(n),this.router.navigate([`${F.LINK}/${e}`]).catch(console.error),!0)),_e(n=>(n.error.message===we.UNAUTHORIZED?this.layout.sendNotification("warning","Link","Bad password"):this.router.navigate([`${F.LINK}/${e}/${n.error.message}`]).catch(console.error),z(!1))))}copyLinkToClipboard(e){this.clipboard.copyFromContent(this.genLink(e))}genUUID(){return this.http.get(Gt).pipe(f(e=>e.uuid))}createLinkDialog(e){this.genUUID().subscribe(t=>{let n=this.layout.openDialog(ge,"md",{initialState:{link:{name:e.name,uuid:t,isActive:!0,nbAccess:0}}});this.subscribeToSubmitLinkModal(n,e)})}updateLinkFromSpaceOrShare(e,t,n,p){return this.http.put(`${te}/${e}/${n}/${t}`,p)}editLinkDialog(e,t,n){if(t.id===0||e?.linkSettings?.uuid){let p=this.layout.openDialog(ge,"md",{initialState:{link:e.linkSettings}});this.subscribeToSubmitLinkModal(p,t,e)}else this.linkFromSpaceOrShare(e.linkId,t.id,n).subscribe({next:p=>{let C=this.layout.openDialog(ge,"md",{initialState:{link:L(v({},p),{permissions:e.permissions})}});this.subscribeToSubmitLinkModal(C,t,e)},error:p=>this.layout.sendNotification("error","Link error",e.name||t.name,p)})}shareLinkGuestToMember(e,t,n){return new H({id:e,linkId:t,name:n.name,description:n.email,createdAt:n.createdAt,permissions:n.permissions,type:Rt.LINK,spaceRole:he.IS_MEMBER,linkSettings:n},[k.SHARE_INSIDE,k.SHARE_OUTSIDE])}subscribeToSubmitLinkModal(e,t,n){e.content.submitEvent.pipe(Oe(1)).subscribe(p=>{if(Object.keys(p).length){let C=Object.assign(e.content.link,p),x=this.shareLinkGuestToMember(C.userId||-(t.links.length+1),n?.linkId||-(t.links.length+1),C);x.linkId?t.links=[x,...t.links.filter(T=>T.linkId!==x.linkId)]:t.links=[x,...t.links]}e.content.layout.closeDialog()})}genLink(e){return`${document.location.origin}/#/${F.LINK}/${e}`}};r.\u0275fac=function(t){return new(t||r)},r.\u0275prov=R({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();export{Zt as a,De as b,Xt as c,Se as d,w as e,Jt as f,j as g,Qt as h,ge as i,ei as j};