efficient-shell 15.6.0 → 15.8.0

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 (52) hide show
  1. package/README.md +11 -5
  2. package/dist/{Browser-MBT76EKF.js → Browser-5QLDJ74Z.js} +13 -13
  3. package/dist/Calculator-6WNTZLWL.js +29 -0
  4. package/dist/{CurrencyConverter-UAZYLLHT.js → CurrencyConverter-C4KCZWUM.js} +10 -10
  5. package/dist/{Files-G5VBN3GD.js → Files-VFRXPQLV.js} +46 -46
  6. package/dist/{Notepad-23YBRLDH.js → Notepad-S5JMXH2O.js} +9 -9
  7. package/dist/PomodoroTimer-BGTCWT53.js +91 -0
  8. package/dist/{Preview-4VKAQ4TY.js → Preview-HTFTEL7K.js} +19 -19
  9. package/dist/{Stock-6YYK6VWP.js → Stock-LIOPTQG5.js} +6 -6
  10. package/dist/{Weather-2OU3LEWQ.js → Weather-K3BVAFRV.js} +18 -18
  11. package/dist/{WorldClock-PYJ4762U.js → WorldClock-RHAHXLW4.js} +6 -6
  12. package/dist/ai/index.js +8 -8
  13. package/dist/apps/ImageAnnotator.js +1 -1
  14. package/dist/apps/index.js +1 -1
  15. package/dist/bin/browser-check.js +1 -1
  16. package/dist/bin/media-host-check.js +1 -1
  17. package/dist/bin/ui-check.js +1 -1
  18. package/dist/brand.css +1 -1
  19. package/dist/chunk-3AUPCKBR.js +1 -0
  20. package/dist/chunk-6FOLK4HD.js +1 -0
  21. package/dist/{chunk-6ZNJ6JU5.js → chunk-E4WVF6AS.js} +6 -6
  22. package/dist/{chunk-OQAGCYR7.js → chunk-EA423N2F.js} +3 -3
  23. package/dist/chunk-GD5NGS6D.js +89 -0
  24. package/dist/chunk-GZ4AMXEU.js +1 -0
  25. package/dist/{chunk-N3T5BE2T.js → chunk-OHPDB4UN.js} +4 -4
  26. package/dist/{chunk-3C2VY2VF.js → chunk-RRWQBWLW.js} +1 -1
  27. package/dist/chunk-WGDVYCQX.js +69 -0
  28. package/dist/{chunk-OZNCUWYB.js → chunk-XZKVGJIB.js} +1 -1
  29. package/dist/{chunk-NICH2O4C.js → chunk-YFVQKS5U.js} +1 -1
  30. package/dist/chunk-ZLB5GRL6.js +1 -0
  31. package/dist/format/index.d.ts +15 -1
  32. package/dist/format/index.js +1 -1
  33. package/dist/forms/LinkPicker.js +1 -1
  34. package/dist/forms/MediaLibrary.js +1 -1
  35. package/dist/hooks/index.d.ts +42 -1
  36. package/dist/hooks/index.js +1 -1
  37. package/dist/icons/index.js +1 -1
  38. package/dist/index.d.ts +117 -75
  39. package/dist/index.js +662 -662
  40. package/dist/motion.css +9 -4
  41. package/dist/routine-index.json +1 -1
  42. package/dist/shell/LanguageSelect.js +1 -1
  43. package/dist/telemetry/index.js +1 -1
  44. package/dist/ui/index.js +1 -1
  45. package/dist/value-index.json +1 -1
  46. package/dist/version.js +1 -1
  47. package/package.json +1 -1
  48. package/dist/Calculator-PAMITD4N.js +0 -29
  49. package/dist/PomodoroTimer-QFF2FTAG.js +0 -91
  50. package/dist/chunk-IN36HWJK.js +0 -1
  51. package/dist/chunk-TDUOBP55.js +0 -69
  52. package/dist/chunk-XRWUNOI3.js +0 -92
@@ -0,0 +1 @@
1
+ import{createContext as r}from"react";var o=r(null);export{o as UndoContext};
@@ -0,0 +1 @@
1
+ var r="15.8.0",a=r;export{a as APP_VERSION,r as VERSION};
@@ -1,20 +1,20 @@
1
- import{Tree as e,TreeRow as n,TreeGroup as l}from"./chunk-BTMZ5MUY.js";import{ImageLightbox as r}from"./chunk-MQNSKFZY.js";import{MarqueeBox as a}from"./chunk-IC72MGON.js";import{Drawer as i}from"./chunk-DEV3ZHPP.js";import{EmptyState as t}from"./chunk-W3454ZES.js";import{DescriptionList as o}from"./chunk-SACUSHVN.js";import{Breadcrumbs as d}from"./chunk-WREUA43Q.js";import{ROOT_KEY as s,mediaLibraryMenu as c}from"./chunk-UFJR63AO.js";import{useMediaMoveItems as u}from"./chunk-GRAFJD3L.js";import{RenameField as m}from"./chunk-OK2J6WSC.js";import{MediaUploadGrid as p}from"./chunk-B4Y5NGHR.js";import{MediaUsedInList as h}from"./chunk-EULBBS5L.js";import{NativeSelect as f}from"./chunk-W7HTHKN2.js";import{useGridSelection as g}from"./chunk-VLKDWKVR.js";import{useMarquee as v}from"./chunk-OLFYNMTD.js";import{copyToClipboard as k}from"./chunk-XYVFJLAU.js";import{Checkbox_default as y}from"./chunk-CGZBDI6C.js";import{Segmented as b}from"./chunk-TALQMTCE.js";import{useContextMenu as w,ContextMenu as N}from"./chunk-MF7OELXP.js";import{Banner as x}from"./chunk-OSMRYND3.js";import{Input_default as C}from"./chunk-D7MRZZVV.js";import{useFileIntake as I,FileIntakeAlert as D}from"./chunk-TNGIXSTM.js";import{setModalDragAside as S,modalIdHolding as j}from"./chunk-EIFNESXS.js";import{ColoredBadge as L}from"./chunk-L2WQOJ3T.js";import{DropdownMenu as T}from"./chunk-NJY4HPNB.js";import{IconButton_default as z}from"./chunk-APFDZ2HG.js";import{Button_default as F}from"./chunk-A4ROXNUF.js";import{Icon as O}from"./chunk-ISVODSRP.js";import{Tooltip as E}from"./chunk-CIZAUBWA.js";import{buttonClasses as A}from"./chunk-UQYNPYF4.js";import{usePlotWidth as P}from"./chunk-MAFUXCPZ.js";import{useShellStrings as M}from"./chunk-NRHG4R2Q.js";import{useRef as R,useMemo as U,useCallback as B,useState as K,useEffect as H}from"react";import{jsxs as J,Fragment as V,jsx as W}from"react/jsx-runtime";var Z="application/x-efficient-media-files",G="application/x-efficient-media-folder",Y="application/x-efficient-media-file";function Q(e){if(!e||!Array.from(e.types).includes(Y))return null;try{const n=JSON.parse(e.getData(Y));if(n&&"string"==typeof n.id&&"string"==typeof n.url&&"string"==typeof n.name&&("image"===n.kind||"video"===n.kind))return{id:n.id,url:n.url,kind:n.kind,name:n.name}}catch{}return null}var $={type:"all",use:"any",sort:"newest"},X={lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-4 w-4"}),folder:/* @__PURE__ */W(O,{name:"folder","aria-hidden":"true",className:"h-4 w-4"}),folderOpen:/* @__PURE__ */W(O,{name:"folder-open","aria-hidden":"true",className:"h-4 w-4"}),folderPlus:/* @__PURE__ */W(O,{name:"folder-plus","aria-hidden":"true",className:"h-4 w-4"}),trash:/* @__PURE__ */W(O,{name:"trash","aria-hidden":"true",className:"h-4 w-4"}),upload:/* @__PURE__ */W(O,{name:"upload","aria-hidden":"true",className:"h-4 w-4"}),search:/* @__PURE__ */W(O,{name:"search","aria-hidden":"true",className:"h-4 w-4"}),grid:/* @__PURE__ */W(O,{name:"grid","aria-hidden":"true",className:"h-4 w-4"}),list:/* @__PURE__ */W(O,{name:"list","aria-hidden":"true",className:"h-4 w-4"}),more:/* @__PURE__ */W(O,{name:"more","aria-hidden":"true",className:"h-4 w-4"}),copy:/* @__PURE__ */W(O,{name:"copy","aria-hidden":"true",className:"h-4 w-4"}),edit:/* @__PURE__ */W(O,{name:"edit","aria-hidden":"true",className:"h-4 w-4"}),swap:/* @__PURE__ */W(O,{name:"swap","aria-hidden":"true",className:"h-4 w-4"}),crop:/* @__PURE__ */W(O,{name:"crop","aria-hidden":"true",className:"h-4 w-4"}),external:/* @__PURE__ */W(O,{name:"external","aria-hidden":"true",className:"h-4 w-4"}),undo:/* @__PURE__ */W(O,{name:"undo","aria-hidden":"true",className:"h-4 w-4"})},q={link:/* @__PURE__ */W(O,{name:"link","aria-hidden":"true",className:"h-3 w-3"}),email:/* @__PURE__ */W(O,{name:"email","aria-hidden":"true",className:"h-3 w-3"}),lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-3 w-3"}),clock:/* @__PURE__ */W(O,{name:"clock","aria-hidden":"true",className:"h-3 w-3"})};function _(O){const{mode:Q="manage",layout:_="auto",location:ee,onLocationChange:ne,folders:le,products:re,allFilesCount:ae,trashCount:ie,files:te,query:oe,onQueryChange:de,filters:se=$,onFiltersChange:ce,extraFilters:ue,view:me="grid",onViewChange:pe,selectedIds:he,onSelectionChange:fe,usedIn:ge,denied:ve={},accept:ke="image/*,video/*",maxSizeBytes:ye,busy:be,progress:we,onUpload:Ne,onNewFolder:xe,onRename:Ce,onMove:Ie,onTrash:De,onDeleteFolder:Se,onRestore:je,onDeleteForever:Le,onEmptyTrash:Te,onReplace:ze,onCropEdit:Fe,onOpenInDesign:Oe,onChoose:Ee,onCancel:Ae,pickNote:Pe,onDragOut:Me,className:Re=""}=O,Ue=M().mediaLibrary,Be=M().media,Ke="pick"===Q,He=!Ke,Je=R(null),Ve=P(Je,"phone"===_?343:1200),We="phone"===_||"auto"===_&&Ve<640,Ze=U(()=>function(e=[]){const n=/* @__PURE__ */new Map,l=(e,r)=>{for(const a of e){const e=[...r,a];n.set(a.id,{node:a,path:e}),a.children&&l(a.children,e)}};return l(e,[]),n}(re),[re]),Ge=U(()=>new Map(le.map(e=>[e.id,e])),[le]),Ye=U(()=>{const e=/* @__PURE__ */new Map;for(const n of le){const l=n.parentId&&Ge.has(n.parentId)?n.parentId:null;e.set(l,[...e.get(l)??[],n])}return e},[le,Ge]),Qe=B(e=>{const n=[];for(let l=e?Ge.get(e):void 0;l&&(n.unshift(l),!(n.length>le.length));l=l.parentId?Ge.get(l.parentId):void 0);return n},[Ge,le.length]),$e=B((e,n)=>Qe(e).some(e=>e.id===n),[Qe]),[Xe,qe]=K(()=>/* @__PURE__ */new Set(["@files"])),_e=e=>qe(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l}),en=B(e=>{qe(n=>e.every(e=>n.has(e))?n:/* @__PURE__ */new Set([...n,...e]))},[]),nn="files"===(ln=ee).place?`files:${ln.folderId??""}`:"products"===ln.place?`products:${ln.nodeId??""}`:"trash";var ln;H(()=>{if("files"===ee.place)en(["@files",...Qe(ee.folderId).slice(0,-1).map(e=>e.id)]);else if("products"===ee.place){const e=ee.nodeId?Ze.get(ee.nodeId)?.path??[]:[];en(["@products",...e.slice(0,-1).map(e=>`p:${e.id}`)])}},[nn]);const rn="products"===ee.place,an="trash"===ee.place,tn="files"===ee.place,on=tn?ee.folderId:null,dn=rn&&ee.nodeId?Ze.get(ee.nodeId)?.path[0]:void 0,sn=e=>e?.sharedFrom?`${Ue.readOnly} ${Ue.editedAtHq(e.sharedFrom)}`:Ue.readOnly,cn=U(()=>te.map(e=>e.id),[te]),un=U(()=>new Map(te.map(e=>[e.id,e])),[te]),mn=g(cn),pn=U(()=>cn.filter(e=>mn.selected.has(e)),[cn,mn.selected]),hn=1===pn.length?un.get(pn[0]):void 0,fn=R(!0);H(()=>{fn.current?fn.current=!1:mn.clear()},[nn]);const gn=he?.join("\0");H(()=>{he&&mn.setSelection(he)},[gn]);const vn=R(gn??""),kn=pn.join("\0");H(()=>{vn.current!==kn&&(vn.current=kn,fe?.(pn))},[kn]);const yn=(e,n={})=>{Ke?mn.select(e):mn.select(e,{ctrl:!(!n.ctrlKey&&!n.metaKey),shift:!!n.shiftKey})},[bn,wn]=K(null),Nn=e=>{const n=bn;if(wn(null),!n||null==e)return;e!==("folder"===n.kind?Ge.get(n.id)?.name:un.get(n.id)?.name)&&Ce?.(n,e)},xn=async e=>{if(!xe)return;const n=await xe(e);en(["@files",...e?[e]:[]]),"string"==typeof n&&wn({kind:"folder",id:n})},Cn=B(e=>{const n=[],l=n=>{if("files"===e.kind)return n===on&&tn?Ue.alreadyHere:void 0;const l=Ge.get(e.id);return n===e.id||n&&$e(n,e.id)?Ue.notIntoItself:(l?.parentId??null)===n?Ue.folderAlreadyHere:void 0};n.push({key:s,label:Ue.allFiles,disabledReason:l(null)});const r=(e,a)=>{for(const i of Ye.get(e)??[])n.push({key:i.id,label:i.name,depth:a,disabledReason:l(i.id)}),r(i.id,a+1)};return r(null,1),n},[Ye,Ge,tn,$e,on,Ue]),In=B(e=>{const n=new Set(e.map(e=>un.get(e)?.kind??"image"));return 1===n.size?[...n][0]:"file"},[un]),[Dn,Sn]=K(null),jn={words:Ue,media:Be,denied:ve,moveTargets:Cn,kindOf:In,urlOf:e=>un.get(e)?.url,newSubfolder:xe&&He?e=>{xn(e)}:void 0,rename:Ce&&He?e=>{"file"!==e.kind||mn.isSelected(e.id)||mn.select(e.id),wn(e)}:void 0,move:Ie&&He?Ie:void 0,trash:De&&He?De:void 0,deleteFolder:Se&&He?Se:void 0,folderNotEmpty:e=>!!Ge.get(e)?.notEmpty,replace:ze&&He?ze:void 0,copyUrl:e=>{const n=un.get(e)?.url;n&&k(Ue.urlLabel,n)},openInDesign:Oe,restore:je,deleteForever:Le},Ln=e=>c(e,jn),Tn=w(),zn=(e,n)=>{Ke||(mn.isSelected(e)||mn.select(e),Tn.open(n,(e=>{const n=mn.isSelected(e)?pn:[e];return rn?{kind:"render",id:e}:an?{kind:"trashed",ids:n}:{kind:"files",ids:n}})(e)))},[Fn,On]=K(null),[En,An]=K(null),[Pn,Mn]=K(null);H(()=>{if(!En&&!Fn)return;const e=()=>{An(null),On(null)};return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[En,Fn]);const Rn=(e,n)=>Array.from(e.dataTransfer?.types??[]).includes(n),Un=(e,n)=>!(!Ie||ve.move||Ke)&&(!!Rn(e,Z)||!(!Rn(e,G)||!Pn)&&(n!==Pn&&!(n&&$e(n,Pn)))),Bn=(e,n)=>({onDragEnter:l=>{Un(l,n)&&(l.preventDefault(),On(e))},onDragOver:l=>{Un(l,n)&&(l.preventDefault(),l.dataTransfer.dropEffect="move",Fn!==e&&On(e))},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||On(n=>n===e?null:n)},onDrop:e=>{if(Un(e,n))if(e.preventDefault(),On(null),Rn(e,Z)){let l;try{l=JSON.parse(e.dataTransfer.getData(Z))}catch{l=null}Array.isArray(l)&&l.length&&Ie({kind:"files",ids:l.map(String)},n)}else Pn&&(Ie({kind:"folder",id:Pn},n),Mn(null))}}),Kn=e=>{const n=e=>Rn(e,Z)||Rn(e,G)||Rn(e,"Files");return{onDragEnter:l=>{n(l)&&An(e)},onDragOver:l=>{n(l)&&En!==e&&An(e)},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||An(n=>n===e?null:n)}}},Hn=(e,n,l)=>/* @__PURE__ */W(E,{side:"right",content:En===e?Ue.noDropProducts:sn(l),open:En===e||!En&&void 0,children:/* @__PURE__ */W("span",{children:n})}),Jn=e=>({onContextMenu:n=>{Tn.open(n,e)}}),Vn=(e,r,a)=>e.map(e=>{const i=`p:${e.id}`,t=a??e,o=Xe.has(i),d=e.children?.length?e.children:null;/* @__PURE__ */
1
+ import{Tree as e,TreeRow as n,TreeGroup as l}from"./chunk-BTMZ5MUY.js";import{ImageLightbox as r}from"./chunk-MQNSKFZY.js";import{MarqueeBox as a}from"./chunk-IC72MGON.js";import{Drawer as i}from"./chunk-DEV3ZHPP.js";import{EmptyState as t}from"./chunk-W3454ZES.js";import{DescriptionList as o}from"./chunk-SACUSHVN.js";import{Breadcrumbs as d}from"./chunk-WREUA43Q.js";import{useGridSelection as s}from"./chunk-VLKDWKVR.js";import{useMarquee as c}from"./chunk-OLFYNMTD.js";import{ROOT_KEY as u,mediaLibraryMenu as m}from"./chunk-UFJR63AO.js";import{useMediaMoveItems as p}from"./chunk-GRAFJD3L.js";import{RenameField as h}from"./chunk-OK2J6WSC.js";import{MediaUploadGrid as f}from"./chunk-B4Y5NGHR.js";import{MediaUsedInList as g}from"./chunk-EULBBS5L.js";import{NativeSelect as v}from"./chunk-W7HTHKN2.js";import{copyToClipboard as k}from"./chunk-XYVFJLAU.js";import{Checkbox_default as y}from"./chunk-CGZBDI6C.js";import{Segmented as b}from"./chunk-TALQMTCE.js";import{useContextMenu as w,ContextMenu as N}from"./chunk-MF7OELXP.js";import{Banner as x}from"./chunk-OSMRYND3.js";import{Input_default as C}from"./chunk-D7MRZZVV.js";import{useFileIntake as I,FileIntakeAlert as D}from"./chunk-TNGIXSTM.js";import{setModalDragAside as S,modalIdHolding as j}from"./chunk-EIFNESXS.js";import{ColoredBadge as L}from"./chunk-L2WQOJ3T.js";import{DropdownMenu as T}from"./chunk-NJY4HPNB.js";import{IconButton_default as z}from"./chunk-APFDZ2HG.js";import{Button_default as F}from"./chunk-A4ROXNUF.js";import{Icon as O}from"./chunk-ISVODSRP.js";import{Tooltip as E}from"./chunk-CIZAUBWA.js";import{buttonClasses as A}from"./chunk-UQYNPYF4.js";import{usePlotWidth as P}from"./chunk-MAFUXCPZ.js";import{useShellStrings as M}from"./chunk-NRHG4R2Q.js";import{useRef as R,useMemo as U,useCallback as B,useState as K,useEffect as H}from"react";import{jsxs as J,Fragment as V,jsx as W}from"react/jsx-runtime";var Z="application/x-efficient-media-files",G="application/x-efficient-media-folder",Y="application/x-efficient-media-file";function Q(e){if(!e||!Array.from(e.types).includes(Y))return null;try{const n=JSON.parse(e.getData(Y));if(n&&"string"==typeof n.id&&"string"==typeof n.url&&"string"==typeof n.name&&("image"===n.kind||"video"===n.kind))return{id:n.id,url:n.url,kind:n.kind,name:n.name}}catch{}return null}var $={type:"all",use:"any",sort:"newest"},X={lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-4 w-4"}),folder:/* @__PURE__ */W(O,{name:"folder","aria-hidden":"true",className:"h-4 w-4"}),folderOpen:/* @__PURE__ */W(O,{name:"folder-open","aria-hidden":"true",className:"h-4 w-4"}),folderPlus:/* @__PURE__ */W(O,{name:"folder-plus","aria-hidden":"true",className:"h-4 w-4"}),trash:/* @__PURE__ */W(O,{name:"trash","aria-hidden":"true",className:"h-4 w-4"}),upload:/* @__PURE__ */W(O,{name:"upload","aria-hidden":"true",className:"h-4 w-4"}),search:/* @__PURE__ */W(O,{name:"search","aria-hidden":"true",className:"h-4 w-4"}),grid:/* @__PURE__ */W(O,{name:"grid","aria-hidden":"true",className:"h-4 w-4"}),list:/* @__PURE__ */W(O,{name:"list","aria-hidden":"true",className:"h-4 w-4"}),more:/* @__PURE__ */W(O,{name:"more","aria-hidden":"true",className:"h-4 w-4"}),copy:/* @__PURE__ */W(O,{name:"copy","aria-hidden":"true",className:"h-4 w-4"}),edit:/* @__PURE__ */W(O,{name:"edit","aria-hidden":"true",className:"h-4 w-4"}),swap:/* @__PURE__ */W(O,{name:"swap","aria-hidden":"true",className:"h-4 w-4"}),crop:/* @__PURE__ */W(O,{name:"crop","aria-hidden":"true",className:"h-4 w-4"}),external:/* @__PURE__ */W(O,{name:"external","aria-hidden":"true",className:"h-4 w-4"}),undo:/* @__PURE__ */W(O,{name:"undo","aria-hidden":"true",className:"h-4 w-4"})},q={link:/* @__PURE__ */W(O,{name:"link","aria-hidden":"true",className:"h-3 w-3"}),email:/* @__PURE__ */W(O,{name:"email","aria-hidden":"true",className:"h-3 w-3"}),lock:/* @__PURE__ */W(O,{name:"lock","aria-hidden":"true",className:"h-3 w-3"}),clock:/* @__PURE__ */W(O,{name:"clock","aria-hidden":"true",className:"h-3 w-3"})};function _(O){const{mode:Q="manage",layout:_="auto",location:ee,onLocationChange:ne,folders:le,products:re,allFilesCount:ae,trashCount:ie,files:te,query:oe,onQueryChange:de,filters:se=$,onFiltersChange:ce,extraFilters:ue,view:me="grid",onViewChange:pe,selectedIds:he,onSelectionChange:fe,usedIn:ge,denied:ve={},accept:ke="image/*,video/*",maxSizeBytes:ye,busy:be,progress:we,onUpload:Ne,onNewFolder:xe,onRename:Ce,onMove:Ie,onTrash:De,onDeleteFolder:Se,onRestore:je,onDeleteForever:Le,onEmptyTrash:Te,onReplace:ze,onCropEdit:Fe,onOpenInDesign:Oe,onChoose:Ee,onCancel:Ae,pickNote:Pe,onDragOut:Me,className:Re=""}=O,Ue=M().mediaLibrary,Be=M().media,Ke="pick"===Q,He=!Ke,Je=R(null),Ve=P(Je,"phone"===_?343:1200),We="phone"===_||"auto"===_&&Ve<640,Ze=U(()=>function(e=[]){const n=/* @__PURE__ */new Map,l=(e,r)=>{for(const a of e){const e=[...r,a];n.set(a.id,{node:a,path:e}),a.children&&l(a.children,e)}};return l(e,[]),n}(re),[re]),Ge=U(()=>new Map(le.map(e=>[e.id,e])),[le]),Ye=U(()=>{const e=/* @__PURE__ */new Map;for(const n of le){const l=n.parentId&&Ge.has(n.parentId)?n.parentId:null;e.set(l,[...e.get(l)??[],n])}return e},[le,Ge]),Qe=B(e=>{const n=[];for(let l=e?Ge.get(e):void 0;l&&(n.unshift(l),!(n.length>le.length));l=l.parentId?Ge.get(l.parentId):void 0);return n},[Ge,le.length]),$e=B((e,n)=>Qe(e).some(e=>e.id===n),[Qe]),[Xe,qe]=K(()=>/* @__PURE__ */new Set(["@files"])),_e=e=>qe(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l}),en=B(e=>{qe(n=>e.every(e=>n.has(e))?n:/* @__PURE__ */new Set([...n,...e]))},[]),nn="files"===(ln=ee).place?`files:${ln.folderId??""}`:"products"===ln.place?`products:${ln.nodeId??""}`:"trash";var ln;H(()=>{if("files"===ee.place)en(["@files",...Qe(ee.folderId).slice(0,-1).map(e=>e.id)]);else if("products"===ee.place){const e=ee.nodeId?Ze.get(ee.nodeId)?.path??[]:[];en(["@products",...e.slice(0,-1).map(e=>`p:${e.id}`)])}},[nn]);const rn="products"===ee.place,an="trash"===ee.place,tn="files"===ee.place,on=tn?ee.folderId:null,dn=rn&&ee.nodeId?Ze.get(ee.nodeId)?.path[0]:void 0,sn=e=>e?.sharedFrom?`${Ue.readOnly} ${Ue.editedAtHq(e.sharedFrom)}`:Ue.readOnly,cn=U(()=>te.map(e=>e.id),[te]),un=U(()=>new Map(te.map(e=>[e.id,e])),[te]),mn=s(cn),pn=U(()=>cn.filter(e=>mn.selected.has(e)),[cn,mn.selected]),hn=1===pn.length?un.get(pn[0]):void 0,fn=R(!0);H(()=>{fn.current?fn.current=!1:mn.clear()},[nn]);const gn=he?.join("\0");H(()=>{he&&mn.setSelection(he)},[gn]);const vn=R(gn??""),kn=pn.join("\0");H(()=>{vn.current!==kn&&(vn.current=kn,fe?.(pn))},[kn]);const yn=(e,n={})=>{Ke?mn.select(e):mn.select(e,{ctrl:!(!n.ctrlKey&&!n.metaKey),shift:!!n.shiftKey})},[bn,wn]=K(null),Nn=e=>{const n=bn;if(wn(null),!n||null==e)return;e!==("folder"===n.kind?Ge.get(n.id)?.name:un.get(n.id)?.name)&&Ce?.(n,e)},xn=async e=>{if(!xe)return;const n=await xe(e);en(["@files",...e?[e]:[]]),"string"==typeof n&&wn({kind:"folder",id:n})},Cn=B(e=>{const n=[],l=n=>{if("files"===e.kind)return n===on&&tn?Ue.alreadyHere:void 0;const l=Ge.get(e.id);return n===e.id||n&&$e(n,e.id)?Ue.notIntoItself:(l?.parentId??null)===n?Ue.folderAlreadyHere:void 0};n.push({key:u,label:Ue.allFiles,disabledReason:l(null)});const r=(e,a)=>{for(const i of Ye.get(e)??[])n.push({key:i.id,label:i.name,depth:a,disabledReason:l(i.id)}),r(i.id,a+1)};return r(null,1),n},[Ye,Ge,tn,$e,on,Ue]),In=B(e=>{const n=new Set(e.map(e=>un.get(e)?.kind??"image"));return 1===n.size?[...n][0]:"file"},[un]),[Dn,Sn]=K(null),jn={words:Ue,media:Be,denied:ve,moveTargets:Cn,kindOf:In,urlOf:e=>un.get(e)?.url,newSubfolder:xe&&He?e=>{xn(e)}:void 0,rename:Ce&&He?e=>{"file"!==e.kind||mn.isSelected(e.id)||mn.select(e.id),wn(e)}:void 0,move:Ie&&He?Ie:void 0,trash:De&&He?De:void 0,deleteFolder:Se&&He?Se:void 0,folderNotEmpty:e=>!!Ge.get(e)?.notEmpty,replace:ze&&He?ze:void 0,copyUrl:e=>{const n=un.get(e)?.url;n&&k(Ue.urlLabel,n)},openInDesign:Oe,restore:je,deleteForever:Le},Ln=e=>m(e,jn),Tn=w(),zn=(e,n)=>{Ke||(mn.isSelected(e)||mn.select(e),Tn.open(n,(e=>{const n=mn.isSelected(e)?pn:[e];return rn?{kind:"render",id:e}:an?{kind:"trashed",ids:n}:{kind:"files",ids:n}})(e)))},[Fn,On]=K(null),[En,An]=K(null),[Pn,Mn]=K(null);H(()=>{if(!En&&!Fn)return;const e=()=>{An(null),On(null)};return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[En,Fn]);const Rn=(e,n)=>Array.from(e.dataTransfer?.types??[]).includes(n),Un=(e,n)=>!(!Ie||ve.move||Ke)&&(!!Rn(e,Z)||!(!Rn(e,G)||!Pn)&&(n!==Pn&&!(n&&$e(n,Pn)))),Bn=(e,n)=>({onDragEnter:l=>{Un(l,n)&&(l.preventDefault(),On(e))},onDragOver:l=>{Un(l,n)&&(l.preventDefault(),l.dataTransfer.dropEffect="move",Fn!==e&&On(e))},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||On(n=>n===e?null:n)},onDrop:e=>{if(Un(e,n))if(e.preventDefault(),On(null),Rn(e,Z)){let l;try{l=JSON.parse(e.dataTransfer.getData(Z))}catch{l=null}Array.isArray(l)&&l.length&&Ie({kind:"files",ids:l.map(String)},n)}else Pn&&(Ie({kind:"folder",id:Pn},n),Mn(null))}}),Kn=e=>{const n=e=>Rn(e,Z)||Rn(e,G)||Rn(e,"Files");return{onDragEnter:l=>{n(l)&&An(e)},onDragOver:l=>{n(l)&&En!==e&&An(e)},onDragLeave:n=>{const l=n.relatedTarget;l&&n.currentTarget.contains(l)||An(n=>n===e?null:n)}}},Hn=(e,n,l)=>/* @__PURE__ */W(E,{side:"right",content:En===e?Ue.noDropProducts:sn(l),open:En===e||!En&&void 0,children:/* @__PURE__ */W("span",{children:n})}),Jn=e=>({onContextMenu:n=>{Tn.open(n,e)}}),Vn=(e,r,a)=>e.map(e=>{const i=`p:${e.id}`,t=a??e,o=Xe.has(i),d=e.children?.length?e.children:null;/* @__PURE__ */
2
2
  return J("div",{role:"none",className:"contents",children:[
3
3
  /* @__PURE__ */W(n,{label:Hn(i,e.name,t),level:r,icon:d&&o?X.folderOpen:X.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Ue.fileCount(e.count):void 0,selected:rn&&ee.nodeId===e.id,expanded:d?o:void 0,onToggle:d?()=>_e(i):void 0,onSelect:()=>ne({place:"products",nodeId:e.id}),rowProps:{"data-media-row":i,...Kn(i),...He?Jn({kind:"product-node",id:e.id}):{}}}),d&&o&&/* @__PURE__ */W(l,{children:Vn(d,r+1,t)})]},e.id)}),Wn=(e,r)=>(Ye.get(e)??[]).map(e=>{const a=Ye.get(e.id),i=Xe.has(e.id),t="folder"===bn?.kind&&bn.id===e.id,o=Ln({kind:"folder",id:e.id});/* @__PURE__ */
4
4
  return J("div",{role:"none",className:"contents",children:[
5
- /* @__PURE__ */W(n,{label:e.name,level:r,icon:a&&i?X.folderOpen:X.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Ue.fileCount(e.count):void 0,selected:t||tn&&ee.folderId===e.id,expanded:a?i:void 0,onToggle:a?()=>_e(e.id):void 0,onSelect:()=>ne({place:"files",folderId:e.id}),drop:Fn===e.id?"into":void 0,dragging:Pn===e.id,draggable:He&&!!Ie&&!ve.move,rename:t?/* @__PURE__ */W(m,{value:e.name,label:Ue.folderName,onDone:Nn}):void 0,actions:He&&o.length?/* @__PURE__ */W(T,{align:"end","aria-label":Ue.folderActions,trigger:X.more,items:o}):void 0,rowProps:{"data-media-row":e.id,...Bn(e.id,e.id),...He?Jn({kind:"folder",id:e.id}):{},...He&&Ie&&!ve.move?{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed="move",n.dataTransfer.setData(G,e.id),Mn(e.id)},onDragEnd:()=>{Mn(null),On(null)}}:{}}}),a&&i&&/* @__PURE__ */W(l,{children:Wn(e.id,r+1)})]},e.id)}),Zn=Xe.has("@files"),Gn=Xe.has("@products"),Yn=/* @__PURE__ */J(e,{"aria-label":Ue.folders,children:[re&&/* @__PURE__ */J(V,{children:[
5
+ /* @__PURE__ */W(n,{label:e.name,level:r,icon:a&&i?X.folderOpen:X.folder,count:e.count,countLabel:null!=e.count?e.countLabel??Ue.fileCount(e.count):void 0,selected:t||tn&&ee.folderId===e.id,expanded:a?i:void 0,onToggle:a?()=>_e(e.id):void 0,onSelect:()=>ne({place:"files",folderId:e.id}),drop:Fn===e.id?"into":void 0,dragging:Pn===e.id,draggable:He&&!!Ie&&!ve.move,rename:t?/* @__PURE__ */W(h,{value:e.name,label:Ue.folderName,onDone:Nn}):void 0,actions:He&&o.length?/* @__PURE__ */W(T,{align:"end","aria-label":Ue.folderActions,trigger:X.more,items:o}):void 0,rowProps:{"data-media-row":e.id,...Bn(e.id,e.id),...He?Jn({kind:"folder",id:e.id}):{},...He&&Ie&&!ve.move?{draggable:!0,onDragStart:n=>{n.dataTransfer.effectAllowed="move",n.dataTransfer.setData(G,e.id),Mn(e.id)},onDragEnd:()=>{Mn(null),On(null)}}:{}}}),a&&i&&/* @__PURE__ */W(l,{children:Wn(e.id,r+1)})]},e.id)}),Zn=Xe.has("@files"),Gn=Xe.has("@products"),Yn=/* @__PURE__ */J(e,{"aria-label":Ue.folders,children:[re&&/* @__PURE__ */J(V,{children:[
6
6
  /* @__PURE__ */W(n,{label:Hn("@products",Ue.products),level:1,icon:X.lock,badge:{label:Ue.readOnlyBadge,tone:"neutral"},expanded:re.length?Gn:void 0,onToggle:()=>_e("@products"),selected:rn&&null==ee.nodeId,onSelect:()=>ne({place:"products",nodeId:null}),rowProps:{"data-media-row":"@products",...Kn("@products")}}),Gn&&re.length>0&&/* @__PURE__ */W(l,{children:Vn(re,2)})]}),
7
- /* @__PURE__ */W(n,{label:Ue.allFiles,level:1,icon:Zn?X.folderOpen:X.folder,count:ae,countLabel:null!=ae?Ue.fileCount(ae):void 0,expanded:Ye.get(null)?.length?Zn:void 0,onToggle:()=>_e("@files"),selected:tn&&null==ee.folderId,onSelect:()=>ne({place:"files",folderId:null}),drop:"@files"===Fn?"into":void 0,rowProps:{"data-media-row":"@files",...Bn("@files",null)}}),Zn&&(Ye.get(null)?.length??0)>0&&/* @__PURE__ */W(l,{children:Wn(null,2)}),He&&/* @__PURE__ */W(n,{label:Ue.trash,level:1,icon:X.trash,count:ie,countLabel:null!=ie?Ue.fileCount(ie):void 0,selected:an,onSelect:()=>ne({place:"trash"}),rowProps:{"data-media-row":"@trash"}})]}),Qn=(()=>{if(an)return[{label:Ue.trash}];if(rn){const e=ee.nodeId?Ze.get(ee.nodeId)?.path??[]:[];return[{label:Ue.products,onClick:e.length?()=>ne({place:"products",nodeId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"products",nodeId:n.id}):void 0}))]}const e=Qe(on);return[{label:Ue.allFiles,onClick:e.length?()=>ne({place:"files",folderId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"files",folderId:n.id}):void 0}))]})(),$n=rn?Ue.readOnly:ve.upload,Xn=!!Ne&&!an&&!$n,qn=I({accept:ke,maxSizeBytes:ye,multiple:!0,disabled:!Xn,onAccept:e=>Ne?.(e,on)}),_n=rn?Ue.noProductFolder:ve.newFolder,el=e=>e?{"aria-disabled":!0,disabledReason:e}:{},nl=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[He&&xe&&!an&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.folderPlus,onClick:()=>{xn(on)},...el(_n),children:Ue.newFolder}),Ne&&!an&&/* @__PURE__ */W(F,{variant:"primary",size:"sm",leftIcon:X.upload,onClick:()=>qn.open(),...el($n),children:Ue.upload}),He&&an&&Te&&te.length>0&&/* @__PURE__ */W(F,{variant:"danger",size:"sm",onClick:Te,...el(ve.deleteForever),children:Ue.emptyTrash})]}),ll=(e,n,l,r,a)=>/* @__PURE__ */W("div",{style:{width:We?void 0:a,flex:We?"1 1 120px":"0 0 auto",minWidth:0},children:/* @__PURE__ */W(f,{size:"sm","aria-label":e,value:n,onChange:r,options:l})},e),rl=e=>n=>ce?.({...se,[e]:n}),al=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[de&&/* @__PURE__ */W("div",{style:{flex:"1 1 200px",minWidth:0},children:/* @__PURE__ */W(C,{size:"sm",type:"search",leftIcon:X.search,placeholder:rn?Ue.searchProducts:Ue.search,"aria-label":rn?Ue.searchProducts:Ue.search,value:oe??"",onChange:e=>de(e.target.value)})}),ce&&ll(Ue.mediaType,se.type,[{value:"all",label:Ue.allTypes},{value:"image",label:Ue.images},{value:"video",label:Ue.videos},{value:"svg",label:"SVG"},{value:"gif",label:"GIF"}],rl("type"),130),ce&&!rn&&!an&&ll(Ue.use,se.use,[{value:"any",label:Ue.anyUse},{value:"email",label:Ue.emailOnly},{value:"website",label:Ue.websiteOnly},{value:"unused",label:Ue.notUsed}],rl("use"),130),ce&&He&&ll(Ue.sort,se.sort,[{value:"newest",label:Ue.newest},{value:"name",label:Ue.byName},{value:"size",label:Ue.bySize}],rl("sort"),110),ue?.map(e=>ll(e.label,e.value,e.options,e.onChange,120)),pe&&/* @__PURE__ */W(b,{size:"sm",label:Ue.view,value:me,onChange:pe,options:[{value:"grid",label:Ue.grid,icon:X.grid},{value:"list",label:Ue.list,icon:X.list}]})]}),il=e=>{const n=[];return null!=e.trashedDaysAgo&&n.push({key:"t",label:Ue.daysAgo(e.trashedDaysAgo),count:e.trashedDaysAgo,icon:q.clock,tone:"neutral"}),e.usedCount&&n.push({key:"u",label:Ue.used(e.usedCount),count:e.usedCount,icon:q.link,tone:"active"}),e.email&&n.push({key:"e",label:Ue.email,icon:q.email,tone:"queued"}),e.private&&n.push({key:"p",label:Ue.private,icon:q.lock,tone:"neutral"}),n},tl=e=>il(e).map(e=>/* @__PURE__ */W(L,{tone:e.tone,size:"xs",children:e.label},e.key)),ol=He&&tn&&!!Ie&&!ve.move,dl=!!Me&&!an,sl=R(""),cl=R(null),ul=()=>cl.current?.dropped?"dropped":"cancelled",ml=R(Me);ml.current=Me;const pl=B(e=>{const n=cl.current;n&&(cl.current=null,n.stop(),S(sl.current,!1),e&&ml.current?.(e))},[]),hl=B(e=>{pl(ul());const n=Je.current?.ownerDocument;if(!n)return;sl.current=j(Je.current);const l=Je.current?.closest("[data-modal-panel]"),r=e=>{sl.current&&!l?.contains(e.target)&&S(sl.current,!0)},a=()=>!!e&&!e.isConnected,i=()=>{const e=cl.current;if(e){if(a())return pl("dropped");e.dropped=!0,S(sl.current,!1)}},t=e=>{const n=e.dataTransfer?.dropEffect;pl(n&&"none"!==n?"dropped":a()?ul():"cancelled")},o=()=>{a()&&pl(ul())},d=["pointermove","pointerdown","mousemove","mousedown"];n.addEventListener("dragover",r,!0),n.addEventListener("drop",i,!0),n.addEventListener("dragend",t,!0);for(const e of d)n.addEventListener(e,o,!0);cl.current={dropped:!1,stop:()=>{n.removeEventListener("dragover",r,!0),n.removeEventListener("drop",i,!0),n.removeEventListener("dragend",t,!0);for(const e of d)n.removeEventListener(e,o,!0)}}},[pl]);H(()=>()=>pl(ul()),[pl]);const fl=(e,n,l)=>{if("start"!==e)return;const r=un.get(n);r&&gl(r)&&(hl(l??null),Me(e))},gl=e=>!dl||e.private||e.pickDisabledReason?void 0:JSON.stringify({id:e.id,url:e.url,kind:"video"===e.kind?"video":"image",name:e.name}),vl=te.map(e=>({id:e.id,url:e.thumbUrl??e.url,name:e.name,kind:e.kind,caption:e.name,badges:il(e),dragData:ol?JSON.stringify(mn.isSelected(e.id)?pn:[e.id]):gl(e),...ol&&gl(e)?{dragAlso:{[Y]:gl(e)}}:{}})),kl=We?Math.max(72,Math.floor((Ve-24-16-1)/3)):112,yl=R(null),bl=v({containerRef:yl,enabled:He&&!We&&te.length>0,selected:mn.selected,setSelection:e=>mn.setSelection(e),clearSelection:mn.clear}),wl=e=>{if(Ke){const n=un.get(e);return void(!n||n.private||n.pickDisabledReason||Ee?.(n))}const n=cn.indexOf(e);n>=0&&Sn(n)},Nl=te.length?null:oe?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.noMatches}):rn?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.emptyProducts,description:sn(dn)}):an?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.trashEmpty}):!Xn||Ke?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.emptyFolder}):null,xl="list"===me&&te.length>0,Cl=Nl??(xl?/* @__PURE__ */W("ul",{role:"listbox","aria-multiselectable":He||void 0,"aria-label":Ue.folders,className:"flex flex-col gap-1",children:te.map(e=>/* @__PURE__ */J("li",{role:"option","aria-selected":mn.isSelected(e.id),tabIndex:0,"data-grid-item":"","data-grid-id":e.id,onClick:n=>yn(e.id,n),onDoubleClick:()=>wl(e.id),onContextMenu:n=>zn(e.id,n),draggable:!!gl(e)||void 0,onDragStart:gl(e)?n=>{n.dataTransfer.effectAllowed="link",n.dataTransfer.setData(Y,gl(e)),fl("start",e.id,n.currentTarget)}:void 0,onKeyDown:n=>{"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),yn(e.id,n))},className:"flex h-12 cursor-pointer items-center gap-3 rounded-md px-2 text-sm rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)] "+(mn.isSelected(e.id)?"bg-accent-tint text-blue-700":"text-ink hover:bg-gray-100"),children:[
7
+ /* @__PURE__ */W(n,{label:Ue.allFiles,level:1,icon:Zn?X.folderOpen:X.folder,count:ae,countLabel:null!=ae?Ue.fileCount(ae):void 0,expanded:Ye.get(null)?.length?Zn:void 0,onToggle:()=>_e("@files"),selected:tn&&null==ee.folderId,onSelect:()=>ne({place:"files",folderId:null}),drop:"@files"===Fn?"into":void 0,rowProps:{"data-media-row":"@files",...Bn("@files",null)}}),Zn&&(Ye.get(null)?.length??0)>0&&/* @__PURE__ */W(l,{children:Wn(null,2)}),He&&/* @__PURE__ */W(n,{label:Ue.trash,level:1,icon:X.trash,count:ie,countLabel:null!=ie?Ue.fileCount(ie):void 0,selected:an,onSelect:()=>ne({place:"trash"}),rowProps:{"data-media-row":"@trash"}})]}),Qn=(()=>{if(an)return[{label:Ue.trash}];if(rn){const e=ee.nodeId?Ze.get(ee.nodeId)?.path??[]:[];return[{label:Ue.products,onClick:e.length?()=>ne({place:"products",nodeId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"products",nodeId:n.id}):void 0}))]}const e=Qe(on);return[{label:Ue.allFiles,onClick:e.length?()=>ne({place:"files",folderId:null}):void 0},...e.map((n,l)=>({label:n.name,onClick:l<e.length-1?()=>ne({place:"files",folderId:n.id}):void 0}))]})(),$n=rn?Ue.readOnly:ve.upload,Xn=!!Ne&&!an&&!$n,qn=I({accept:ke,maxSizeBytes:ye,multiple:!0,disabled:!Xn,onAccept:e=>Ne?.(e,on)}),_n=rn?Ue.noProductFolder:ve.newFolder,el=e=>e?{"aria-disabled":!0,disabledReason:e}:{},nl=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[He&&xe&&!an&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.folderPlus,onClick:()=>{xn(on)},...el(_n),children:Ue.newFolder}),Ne&&!an&&/* @__PURE__ */W(F,{variant:"primary",size:"sm",leftIcon:X.upload,onClick:()=>qn.open(),...el($n),children:Ue.upload}),He&&an&&Te&&te.length>0&&/* @__PURE__ */W(F,{variant:"danger",size:"sm",onClick:Te,...el(ve.deleteForever),children:Ue.emptyTrash})]}),ll=(e,n,l,r,a)=>/* @__PURE__ */W("div",{style:{width:We?void 0:a,flex:We?"1 1 120px":"0 0 auto",minWidth:0},children:/* @__PURE__ */W(v,{size:"sm","aria-label":e,value:n,onChange:r,options:l})},e),rl=e=>n=>ce?.({...se,[e]:n}),al=/* @__PURE__ */J("div",{className:"flex flex-wrap items-center gap-2",children:[de&&/* @__PURE__ */W("div",{style:{flex:"1 1 200px",minWidth:0},children:/* @__PURE__ */W(C,{size:"sm",type:"search",leftIcon:X.search,placeholder:rn?Ue.searchProducts:Ue.search,"aria-label":rn?Ue.searchProducts:Ue.search,value:oe??"",onChange:e=>de(e.target.value)})}),ce&&ll(Ue.mediaType,se.type,[{value:"all",label:Ue.allTypes},{value:"image",label:Ue.images},{value:"video",label:Ue.videos},{value:"svg",label:"SVG"},{value:"gif",label:"GIF"}],rl("type"),130),ce&&!rn&&!an&&ll(Ue.use,se.use,[{value:"any",label:Ue.anyUse},{value:"email",label:Ue.emailOnly},{value:"website",label:Ue.websiteOnly},{value:"unused",label:Ue.notUsed}],rl("use"),130),ce&&He&&ll(Ue.sort,se.sort,[{value:"newest",label:Ue.newest},{value:"name",label:Ue.byName},{value:"size",label:Ue.bySize}],rl("sort"),110),ue?.map(e=>ll(e.label,e.value,e.options,e.onChange,120)),pe&&/* @__PURE__ */W(b,{size:"sm",label:Ue.view,value:me,onChange:pe,options:[{value:"grid",label:Ue.grid,icon:X.grid},{value:"list",label:Ue.list,icon:X.list}]})]}),il=e=>{const n=[];return null!=e.trashedDaysAgo&&n.push({key:"t",label:Ue.daysAgo(e.trashedDaysAgo),count:e.trashedDaysAgo,icon:q.clock,tone:"neutral"}),e.usedCount&&n.push({key:"u",label:Ue.used(e.usedCount),count:e.usedCount,icon:q.link,tone:"active"}),e.email&&n.push({key:"e",label:Ue.email,icon:q.email,tone:"queued"}),e.private&&n.push({key:"p",label:Ue.private,icon:q.lock,tone:"neutral"}),n},tl=e=>il(e).map(e=>/* @__PURE__ */W(L,{tone:e.tone,size:"xs",children:e.label},e.key)),ol=He&&tn&&!!Ie&&!ve.move,dl=!!Me&&!an,sl=R(""),cl=R(null),ul=()=>cl.current?.dropped?"dropped":"cancelled",ml=R(Me);ml.current=Me;const pl=B(e=>{const n=cl.current;n&&(cl.current=null,n.stop(),S(sl.current,!1),e&&ml.current?.(e))},[]),hl=B(e=>{pl(ul());const n=Je.current?.ownerDocument;if(!n)return;sl.current=j(Je.current);const l=Je.current?.closest("[data-modal-panel]"),r=e=>{sl.current&&!l?.contains(e.target)&&S(sl.current,!0)},a=()=>!!e&&!e.isConnected,i=()=>{const e=cl.current;if(e){if(a())return pl("dropped");e.dropped=!0,S(sl.current,!1)}},t=e=>{const n=e.dataTransfer?.dropEffect;pl(n&&"none"!==n?"dropped":a()?ul():"cancelled")},o=()=>{a()&&pl(ul())},d=["pointermove","pointerdown","mousemove","mousedown"];n.addEventListener("dragover",r,!0),n.addEventListener("drop",i,!0),n.addEventListener("dragend",t,!0);for(const e of d)n.addEventListener(e,o,!0);cl.current={dropped:!1,stop:()=>{n.removeEventListener("dragover",r,!0),n.removeEventListener("drop",i,!0),n.removeEventListener("dragend",t,!0);for(const e of d)n.removeEventListener(e,o,!0)}}},[pl]);H(()=>()=>pl(ul()),[pl]);const fl=(e,n,l)=>{if("start"!==e)return;const r=un.get(n);r&&gl(r)&&(hl(l??null),Me(e))},gl=e=>!dl||e.private||e.pickDisabledReason?void 0:JSON.stringify({id:e.id,url:e.url,kind:"video"===e.kind?"video":"image",name:e.name}),vl=te.map(e=>({id:e.id,url:e.thumbUrl??e.url,name:e.name,kind:e.kind,caption:e.name,badges:il(e),dragData:ol?JSON.stringify(mn.isSelected(e.id)?pn:[e.id]):gl(e),...ol&&gl(e)?{dragAlso:{[Y]:gl(e)}}:{}})),kl=We?Math.max(72,Math.floor((Ve-24-16-1)/3)):112,yl=R(null),bl=c({containerRef:yl,enabled:He&&!We&&te.length>0,selected:mn.selected,setSelection:e=>mn.setSelection(e),clearSelection:mn.clear}),wl=e=>{if(Ke){const n=un.get(e);return void(!n||n.private||n.pickDisabledReason||Ee?.(n))}const n=cn.indexOf(e);n>=0&&Sn(n)},Nl=te.length?null:oe?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.noMatches}):rn?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.emptyProducts,description:sn(dn)}):an?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.trashEmpty}):!Xn||Ke?/* @__PURE__ */W(t,{variant:"dashed",title:Ue.emptyFolder}):null,xl="list"===me&&te.length>0,Cl=Nl??(xl?/* @__PURE__ */W("ul",{role:"listbox","aria-multiselectable":He||void 0,"aria-label":Ue.folders,className:"flex flex-col gap-1",children:te.map(e=>/* @__PURE__ */J("li",{role:"option","aria-selected":mn.isSelected(e.id),tabIndex:0,"data-grid-item":"","data-grid-id":e.id,onClick:n=>yn(e.id,n),onDoubleClick:()=>wl(e.id),onContextMenu:n=>zn(e.id,n),draggable:!!gl(e)||void 0,onDragStart:gl(e)?n=>{n.dataTransfer.effectAllowed="link",n.dataTransfer.setData(Y,gl(e)),fl("start",e.id,n.currentTarget)}:void 0,onKeyDown:n=>{"Enter"!==n.key&&" "!==n.key||(n.preventDefault(),yn(e.id,n))},className:"flex h-12 cursor-pointer items-center gap-3 rounded-md px-2 text-sm rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)] "+(mn.isSelected(e.id)?"bg-accent-tint text-blue-700":"text-ink hover:bg-gray-100"),children:[
8
8
  /* @__PURE__ */W("img",{src:e.thumbUrl??e.url,alt:"",className:"h-10 w-10 shrink-0 rounded bg-gray-100 object-contain"}),
9
9
  /* @__PURE__ */W("span",{className:"min-w-0 flex-1 truncate",children:e.name}),
10
- /* @__PURE__ */W("span",{className:"flex shrink-0 items-center gap-1",children:tl(e)}),e.sizeLabel&&/* @__PURE__ */W("span",{className:"w-16 shrink-0 text-right text-xs text-ink-faint",children:e.sizeLabel})]},e.id))}):/* @__PURE__ */W(p,{items:vl,readOnly:!Xn||Ke,onFiles:Xn&&!Ke?e=>Ne(e,on):void 0,accept:ke,maxSizeBytes:ye,busy:be,progress:we,fit:"contain",thumbSize:kl,dragType:ol?Z:dl?Y:void 0,onDragOutChange:dl?(e,n,l)=>fl(e,n,l):void 0,selected:mn.selected,onItemClick:yn,onItemDoubleClick:wl,onItemContextMenu:He?zn:void 0,menuOnMedia:He})),Il=u({count:pn.length,kind:In(pn),targets:Cn({kind:"files",ids:pn}),onPick:e=>Ie?.({kind:"files",ids:pn},e.key===s?null:e.key)}),Dl=A({variant:"secondary",size:"sm"}),Sl=/* @__PURE__ */W(T,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(V,{children:[X.folder,Ue.moveTo]}),items:Il,disabled:!!ve.move}),jl=He&&pn.length>1&&!rn?/* @__PURE__ */J("div",{"data-media-bulk":"",className:"flex flex-wrap items-center gap-2 rounded-lg border border-line px-3 py-2",children:[
10
+ /* @__PURE__ */W("span",{className:"flex shrink-0 items-center gap-1",children:tl(e)}),e.sizeLabel&&/* @__PURE__ */W("span",{className:"w-16 shrink-0 text-right text-xs text-ink-faint",children:e.sizeLabel})]},e.id))}):/* @__PURE__ */W(f,{items:vl,readOnly:!Xn||Ke,onFiles:Xn&&!Ke?e=>Ne(e,on):void 0,accept:ke,maxSizeBytes:ye,busy:be,progress:we,fit:"contain",thumbSize:kl,dragType:ol?Z:dl?Y:void 0,onDragOutChange:dl?(e,n,l)=>fl(e,n,l):void 0,selected:mn.selected,onItemClick:yn,onItemDoubleClick:wl,onItemContextMenu:He?zn:void 0,menuOnMedia:He})),Il=p({count:pn.length,kind:In(pn),targets:Cn({kind:"files",ids:pn}),onPick:e=>Ie?.({kind:"files",ids:pn},e.key===u?null:e.key)}),Dl=A({variant:"secondary",size:"sm"}),Sl=/* @__PURE__ */W(T,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(V,{children:[X.folder,Ue.moveTo]}),items:Il,disabled:!!ve.move}),jl=He&&pn.length>1&&!rn?/* @__PURE__ */J("div",{"data-media-bulk":"",className:"flex flex-wrap items-center gap-2 rounded-lg border border-line px-3 py-2",children:[
11
11
  /* @__PURE__ */W(y,{checked:pn.length===te.length,indeterminate:pn.length<te.length,onChange:e=>e?mn.selectAll():mn.clear(),label:Ue.selected(pn.length)}),/* @__PURE__ */J(V,an?{children:[je&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.undo,onClick:()=>je(pn),...el(ve.restore),children:Ue.restore}),Le&&/* @__PURE__ */W(F,{variant:"secondary-danger",size:"sm",onClick:()=>Le(pn),...el(ve.deleteForever),children:Ue.deleteForever})]}:{children:[Ie&&Sl,Ce&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.edit,disabled:!0,children:Ue.rename}),De&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.trash,onClick:()=>De({kind:"files",ids:pn}),...el(ve.trash),children:Ue.moveFilesToTrash(pn.length)})]}),
12
- /* @__PURE__ */W(F,{variant:"ghost",size:"sm",onClick:mn.clear,children:Ue.clearSelection})]}):null,Ll=e=>{const n=[],l=(e,l,r)=>{null!=r&&""!==r&&n.push({key:e,label:l,value:r})},r="file"===bn?.kind&&bn.id===e.id;l("name",Ue.name,r?/* @__PURE__ */W(m,{value:e.name,label:Ue.fileName,onDone:Nn}):e.name),l("type",Ue.type,e.typeLabel),l("size",Ue.size,e.sizeLabel),l("resolution",Ue.resolution,e.resolution),rn?(l("design",Ue.design,e.design),l("finish",Ue.finish,e.finish),l("angle",Ue.angleLug,e.angleLug),l("owner",Ue.owner,e.owner)):(l("added",Ue.addedBy,e.addedBy),l("folder",Ue.folder,e.folderPath)),l("used",Ue.usedIn,null!=e.usedCount?Ue.places(e.usedCount):void 0);const a=c({kind:"files",ids:[e.id]},jn).find(e=>"submenu"===e.type);/* @__PURE__ */
12
+ /* @__PURE__ */W(F,{variant:"ghost",size:"sm",onClick:mn.clear,children:Ue.clearSelection})]}):null,Ll=e=>{const n=[],l=(e,l,r)=>{null!=r&&""!==r&&n.push({key:e,label:l,value:r})},r="file"===bn?.kind&&bn.id===e.id;l("name",Ue.name,r?/* @__PURE__ */W(h,{value:e.name,label:Ue.fileName,onDone:Nn}):e.name),l("type",Ue.type,e.typeLabel),l("size",Ue.size,e.sizeLabel),l("resolution",Ue.resolution,e.resolution),rn?(l("design",Ue.design,e.design),l("finish",Ue.finish,e.finish),l("angle",Ue.angleLug,e.angleLug),l("owner",Ue.owner,e.owner)):(l("added",Ue.addedBy,e.addedBy),l("folder",Ue.folder,e.folderPath)),l("used",Ue.usedIn,null!=e.usedCount?Ue.places(e.usedCount):void 0);const a=m({kind:"files",ids:[e.id]},jn).find(e=>"submenu"===e.type);/* @__PURE__ */
13
13
  return J("div",{"data-media-details":"",className:"flex flex-col gap-3",children:[
14
14
  /* @__PURE__ */W("img",{src:e.url,alt:e.name,className:"aspect-square w-full rounded-lg bg-gray-100 object-contain"}),rn&&/* @__PURE__ */W(x,{tone:"neutral",title:Ue.readOnlyBadge,children:sn(dn)}),
15
15
  /* @__PURE__ */W(o,{size:"sm",columns:1,items:n}),!an&&/* @__PURE__ */J("div",{className:"flex gap-2",children:[
16
16
  /* @__PURE__ */W("div",{style:{flex:"1 1 0",minWidth:0},children:/* @__PURE__ */W(C,{size:"sm",readOnly:!0,value:e.url,"aria-label":Ue.fileUrl,onFocus:e=>e.currentTarget.select()})}),
17
- /* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.copy,onClick:()=>jn.copyUrl(e.id),children:Ue.copyUrl})]}),tn&&He&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[ze&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.swap,onClick:()=>ze(e.id),...el(ve.replace),children:Ue.replace}),Fe&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.crop,onClick:()=>Fe(e.id),children:Ue.cropEdit}),Ie&&"submenu"===a?.type&&/* @__PURE__ */W(T,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(V,{children:[X.folder,Ue.moveTo]}),items:a.items,disabled:!!ve.move}),Ce&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.edit,onClick:()=>wn({kind:"file",id:e.id}),...el(ve.rename),children:Ue.rename}),De&&/* @__PURE__ */W(z,{"aria-label":Ue.moveToTrash,size:"sm",onClick:()=>De({kind:"files",ids:[e.id]}),disabledReason:ve.trash,"aria-disabled":!!ve.trash||void 0,children:X.trash})]}),an&&He&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[je&&/* @__PURE__ */W(F,{variant:"primary",size:"sm",leftIcon:X.undo,onClick:()=>je([e.id]),...el(ve.restore),children:Ue.restore}),Le&&/* @__PURE__ */W(F,{variant:"danger",size:"sm",onClick:()=>Le([e.id]),...el(ve.deleteForever),children:Ue.deleteForever})]}),rn&&Oe&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.external,onClick:()=>Oe({kind:"render",id:e.id}),children:Ue.openInDesign}),ge&&/* @__PURE__ */W(h,{items:ge})]})},Tl=hn?hn.private?Ue.privateNoPick:hn.pickDisabledReason:void 0,zl=Ke?/* @__PURE__ */J("div",{"data-media-picker-footer":"",className:"flex flex-wrap items-center justify-between gap-2 border-t border-line px-3 py-2",children:[
17
+ /* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.copy,onClick:()=>jn.copyUrl(e.id),children:Ue.copyUrl})]}),tn&&He&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[ze&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.swap,onClick:()=>ze(e.id),...el(ve.replace),children:Ue.replace}),Fe&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.crop,onClick:()=>Fe(e.id),children:Ue.cropEdit}),Ie&&"submenu"===a?.type&&/* @__PURE__ */W(T,{align:"start",triggerClassName:Dl,trigger:/* @__PURE__ */J(V,{children:[X.folder,Ue.moveTo]}),items:a.items,disabled:!!ve.move}),Ce&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.edit,onClick:()=>wn({kind:"file",id:e.id}),...el(ve.rename),children:Ue.rename}),De&&/* @__PURE__ */W(z,{"aria-label":Ue.moveToTrash,size:"sm",onClick:()=>De({kind:"files",ids:[e.id]}),disabledReason:ve.trash,"aria-disabled":!!ve.trash||void 0,children:X.trash})]}),an&&He&&/* @__PURE__ */J("div",{className:"flex flex-wrap gap-2",children:[je&&/* @__PURE__ */W(F,{variant:"primary",size:"sm",leftIcon:X.undo,onClick:()=>je([e.id]),...el(ve.restore),children:Ue.restore}),Le&&/* @__PURE__ */W(F,{variant:"danger",size:"sm",onClick:()=>Le([e.id]),...el(ve.deleteForever),children:Ue.deleteForever})]}),rn&&Oe&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",leftIcon:X.external,onClick:()=>Oe({kind:"render",id:e.id}),children:Ue.openInDesign}),ge&&/* @__PURE__ */W(g,{items:ge})]})},Tl=hn?hn.private?Ue.privateNoPick:hn.pickDisabledReason:void 0,zl=Ke?/* @__PURE__ */J("div",{"data-media-picker-footer":"",className:"flex flex-wrap items-center justify-between gap-2 border-t border-line px-3 py-2",children:[
18
18
  /* @__PURE__ */W("span",{className:"min-w-0 truncate text-sm text-ink-faint",children:hn?Ue.oneChosen(hn.name):Ue.noneChosen}),
19
19
  /* @__PURE__ */J("div",{className:"flex gap-2",children:[Ae&&/* @__PURE__ */W(F,{variant:"secondary",size:"sm",onClick:Ae,children:Ue.cancel}),
20
20
  /* @__PURE__ */W(F,{variant:"primary",size:"sm",disabled:!hn,...el(Tl),onClick:()=>{hn&&!Tl&&Ee?.(hn)},children:Ue.chooseImage})]})]}):null,Fl=He&&!!hn,Ol=/* @__PURE__ */J("div",{className:"flex min-w-0 flex-col gap-3",children:[Pe&&/* @__PURE__ */W(x,{tone:"neutral",children:Pe}),
@@ -1,9 +1,9 @@
1
- import{useWindowMenuItem as e,Modal as t}from"./chunk-XRWUNOI3.js";import{navIcons as r}from"./chunk-4LXCCZDM.js";import{VERSION as n}from"./chunk-IN36HWJK.js";import{Icon as s}from"./chunk-ISVODSRP.js";import{DEFAULT_SHELL_STRINGS as i,useShellStrings as o,splitAround as a}from"./chunk-NRHG4R2Q.js";import{useState as l,useCallback as m,isValidElement as c,cloneElement as p}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";var h=i.aboutApp,x={notepad:{name:"Notepad",version:"1.1.0",route:"/notepad",description:h.notepad},preview:{name:"Preview",version:"1.5.1",route:"/preview",description:h.preview},files:{name:"Files",version:"2.0.1",route:"/files",description:h.files},browser:{name:"Browser",version:"1.0.3",route:"/browser",description:h.browser}},u=/* @__PURE__ */d(s,{name:"info",className:"h-4 w-4",strokeWidth:1.5}),N=/* @__PURE__ */d(s,{name:"window",className:"h-9 w-9",strokeWidth:1.5});function w({app:s}){const i=x[s],[h,w]=l(!1),v=m(()=>w(!0),[]),b=o().aboutApp,k=b.title(i.name);if(e(k,v,u),!h)return null;const g=r[i.route],y=c(g)?p(g,{className:"h-9 w-9"}):N,[j,R]=a(b.partOf);/* @__PURE__ */
2
- return d(t,{open:!0,onClose:()=>w(!1),title:k,size:"sm",compact:!0,bodyScroll:!1,autoHeight:!0,dimensions:[320,320],children:/* @__PURE__ */f("div",{className:"flex flex-col items-center text-center px-5 pt-5 pb-4",children:[
1
+ import{useWindowMenuItem as e,Modal as t}from"./chunk-GD5NGS6D.js";import{navIcons as r}from"./chunk-4LXCCZDM.js";import{VERSION as n}from"./chunk-6FOLK4HD.js";import{Icon as s}from"./chunk-ISVODSRP.js";import{DEFAULT_SHELL_STRINGS as i,useShellStrings as o,splitAround as a}from"./chunk-NRHG4R2Q.js";import{useState as l,useCallback as m,isValidElement as c,cloneElement as p}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";var h=i.aboutApp,x={notepad:{name:"Notepad",version:"1.1.0",route:"/notepad",description:h.notepad},preview:{name:"Preview",version:"1.5.1",route:"/preview",description:h.preview},files:{name:"Files",version:"2.0.1",route:"/files",description:h.files},browser:{name:"Browser",version:"1.0.3",route:"/browser",description:h.browser}},u=/* @__PURE__ */d(s,{name:"info",className:"h-4 w-4",strokeWidth:1.5}),w=/* @__PURE__ */d(s,{name:"window",className:"h-9 w-9",strokeWidth:1.5});function N({app:s}){const i=x[s],[h,N]=l(!1),v=m(()=>N(!0),[]),b=o().aboutApp,k=b.title(i.name);if(e(k,v,u),!h)return null;const g=r[i.route],y=c(g)?p(g,{className:"h-9 w-9"}):w,[j,D]=a(b.partOf);/* @__PURE__ */
2
+ return d(t,{open:!0,onClose:()=>N(!1),title:k,size:"sm",compact:!0,bodyScroll:!1,autoHeight:!0,dimensions:[320,320],children:/* @__PURE__ */f("div",{className:"flex flex-col items-center text-center px-5 pt-5 pb-4",children:[
3
3
  /* @__PURE__ */d("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gray-100 text-gray-600 shrink-0",children:y}),
4
4
  /* @__PURE__ */d("h2",{className:"mt-3 text-lg font-bold text-gray-900",children:i.name}),
5
5
  /* @__PURE__ */d("p",{className:"text-2xs font-mono text-ink-faintest",children:b.version(i.version)}),
6
6
  /* @__PURE__ */d("p",{className:"mt-2 text-xs text-gray-500 leading-relaxed",children:b[s]}),
7
7
  /* @__PURE__ */f("div",{className:"mt-4 pt-3 border-t border-gray-200 w-full",children:[
8
8
  /* @__PURE__ */f("p",{className:"text-2xs text-ink-faint",children:[j,
9
- /* @__PURE__ */d("span",{className:"font-medium text-gray-700",children:"efficient-shell"}),R]}),n&&/* @__PURE__ */d("p",{className:"mt-0.5 text-2xs font-mono text-ink-faintest",children:b.shellVersion(n)})]})]})})}export{w as AboutApp,x as BUILTIN_APP_INFO};
9
+ /* @__PURE__ */d("span",{className:"font-medium text-gray-700",children:"efficient-shell"}),D]}),n&&/* @__PURE__ */d("p",{className:"mt-0.5 text-2xs font-mono text-ink-faintest",children:b.shellVersion(n)})]})]})})}export{N as AboutApp,x as BUILTIN_APP_INFO};
@@ -0,0 +1,89 @@
1
+ import{computeMaximizedBox as e,isSidebarStripReserved as t,boxFillsWorkArea as n,readAlwaysMaximizedFlag as r,WORK_AREA_CHANGED_EVENT as o,scrollerIsFluid as i,growBoxToWidth as a,widthToFit as s,navIcons as l}from"./chunk-4LXCCZDM.js";import{reportBoundaryError as c}from"./chunk-KNUR2UEG.js";import{isStaleChunkError as u}from"./chunk-JDCM2VHG.js";import{Result as d}from"./chunk-PSVGB7KT.js";import{WindowInsetContext as m,NO_WINDOW_DRAG as h}from"./chunk-YI4T5I5D.js";import{CopyButton as f}from"./chunk-TJ5YMXVB.js";import{confirm as p}from"./chunk-JRKD7SD3.js";import{undoReducer as w,emptyUndoState as y,sameValue as g,matchUndoHotkey as v}from"./chunk-ZLB5GRL6.js";import{useModalDragAside as b}from"./chunk-EIFNESXS.js";import{ItemCount as x}from"./chunk-PO2KNVCC.js";import{isInOverlayOver as k}from"./chunk-CJ4OEY3T.js";import{dialogA11y as E}from"./chunk-VWGWZY7A.js";import{ColoredBadge as C}from"./chunk-L2WQOJ3T.js";import{ROW_HEIGHTS as M}from"./chunk-5VJVEKVM.js";import{parseOption as S}from"./chunk-YPXONNBV.js";import{LoadingSpinner as N}from"./chunk-4PJFL26P.js";import{useShellAuth as L}from"./chunk-2QY5BJLA.js";import{useIsMobile as z,useIsPhone as T}from"./chunk-UGTRSRIW.js";import{useShellPrefs as A}from"./chunk-POBVGDZP.js";import{activationOrder as D,activeListeners as P,ModalActionsContext as I,subscribeActive as R,getActiveModalId as W,KEY_ACTIVATED_SELECTOR as $}from"./chunk-F3ZOO23R.js";import{DropdownMenu as O}from"./chunk-NJY4HPNB.js";import{focusableIn as K}from"./chunk-DWGYC7OD.js";import{StatusBadge as j}from"./chunk-ABIWAS5K.js";import{PopupMenu as F,PopupMenuItem as B,PopupMenuDivider as Y,PopupMenuLabel as q}from"./chunk-P56YLT73.js";import{Button_default as H}from"./chunk-A4ROXNUF.js";import{Icon as U}from"./chunk-ISVODSRP.js";import{LoadingSpinner as X}from"./chunk-R2VKEMZH.js";import{createShellPortal as V}from"./chunk-5QRHQCRG.js";import{Z_LAYERS as G}from"./chunk-62LW225J.js";import{shellHttp as J,isShellHttpConfigured as _}from"./chunk-STKJA4PV.js";import{fitBoxScale as Q,fitFrameStyle as Z}from"./chunk-M6UKCZHT.js";import{UndoContext as ee}from"./chunk-3AUPCKBR.js";import{buttonClasses as te}from"./chunk-UQYNPYF4.js";import{runEscapeInterceptors as ne}from"./chunk-TWVUQUUD.js";import{useShellStrings as re}from"./chunk-NRHG4R2Q.js";import{createContext as oe,createElement as ie,useContext as ae,Component as se,useRef as le,useLayoutEffect as ce,useEffect as ue,useState as de,useSyncExternalStore as me,useCallback as he,isValidElement as fe,Fragment as pe,Children as we,cloneElement as ye,useMemo as ge,useId as ve,useReducer as be,Suspense as xe}from"react";import{jsxs as ke,jsx as Ee,Fragment as Ce}from"react/jsx-runtime";import{useLocation as Me}from"react-router-dom";import{useQueryClient as Se,useQuery as Ne}from"@tanstack/react-query";function Le(e){return"component"in e}function ze(e){return"endpoint"in e}var Te={};function Ae(e){Te=e}var De=new Proxy({},{get:(e,t)=>Te[t],has:(e,t)=>t in Te,ownKeys:()=>Object.keys(Te),getOwnPropertyDescriptor(e,t){if(t in Te)return{configurable:!0,enumerable:!0,value:Te[t]}}});function Pe(){return _()}var Ie=J,Re=oe({});function We({value:e,children:t}){return ie(Re.Provider,{value:e},t)}function $e(){return ae(Re)}var Oe=oe(null);function Ke(){return ae(Oe)?.pageSearch??""}var je=null,Fe=/* @__PURE__ */new Set;function Be(e){je!==e&&(je=e,Fe.forEach(e=>e()))}function Ye(){return je}function qe(e){return Fe.add(e),()=>{Fe.delete(e)}}var He=null;function Ue(e){He=e}function Xe({error:e,onReload:t}){const n=u(e);/* @__PURE__ */
2
+ return ke("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 py-12 text-center",children:[
3
+ /* @__PURE__ */Ee(U,{name:"warning",className:"h-8 w-8 text-amber-500",strokeWidth:1.5}),
4
+ /* @__PURE__ */ke("div",{className:"min-w-0",children:[
5
+ /* @__PURE__ */Ee("p",{className:"text-sm font-medium text-gray-700",children:n?"This window needs the latest version of the app":"This window crashed"}),
6
+ /* @__PURE__ */Ee("p",{className:"mt-1 text-xs text-gray-400 max-w-sm break-words",children:n?"A new version was deployed while this tab was open. Reload the page to pick it up.":e.message||String(e)})]}),
7
+ /* @__PURE__ */Ee("button",{type:"button",onClick:n?()=>window.location.reload():t,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg",children:n?"Reload page":"Reload window"})]})}var Ve=class extends se{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){console.error("[efficient-shell] window content crashed:",e,t.componentStack),c(e)}reset=()=>this.setState({error:null});render(){const{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):/* @__PURE__ */Ee(Xe,{error:e,onReload:this.reset}):this.props.children}},Ge=/* @__PURE__ */new Set([408,429]);function Je(e){const t=e?.response?.status;return"number"==typeof t?t:void 0}function _e(e){const t=Je(e);return null!=t&&(t>=400&&t<500&&!Ge.has(t))}function Qe(e,t){return!_e(t)&&e<3}function Ze(e){if("page"!==e.type)return!0;const t=e.route?De[e.route]:void 0;if(!t||!Le(t))return!0;const n=t;return!n.widget&&!n.utility}function et(e){const t=e.route?De[e.route]:void 0;if(!t||!Le(t))return;const n=t;return n.taskbarGroup?n.taskbarGroup:{key:e.route,label:n.label,icon:e.route}}var tt=(e,t)=>!!t&&"page"===e.type&&e.route===t;var nt="flex-1 min-h-0";function rt(){const e=re().record;/* @__PURE__ */
8
+ return Ee(X,{label:e.loading,padding:"",className:nt})}function ot(e){return e??void 0}function it({isPending:e,isFetching:t,enabled:n=!0,error:r,onRetry:o}){const i=re().record;if(t||e&&n)/* @__PURE__ */return Ee(rt,{});if(r){const e=Je(r);if(401===e)/* @__PURE__ */
9
+ return Ee(d,{status:"warning",title:i.signInRequired,subTitle:i.signInBody,className:nt});if(403===e)/* @__PURE__ */
10
+ return Ee(d,{status:"403",className:nt});if(404===e||410===e)/* @__PURE__ */
11
+ return Ee(d,{status:"404",title:i.notFound,className:nt});const t=null==e||408===e||429===e||e>=500;/* @__PURE__ */
12
+ return Ee(d,{status:"500",title:i.loadFailed,subTitle:t?i.checkConnection:i.rejected,extra:t?/* @__PURE__ */Ee(H,{variant:"secondary",size:"sm",onClick:o,children:i.retry}):void 0,className:nt})}/* @__PURE__ */
13
+ return Ee(d,{status:"404",title:i.notFound,className:nt})}function at({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */Ee(Ce,{children:t(e)}):/* @__PURE__ */Ee(it,{...n})}var st=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function lt(e){return"string"==typeof e&&(e.startsWith("new-")||st.test(e))}function ct(e){if(lt(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var ut=oe({openWindows:[],openEntity:()=>{},openPage:()=>{},reorderWindows:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),dt=oe(null);function mt(e){const t=ae(dt),n=le(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),ce(()=>{if(t)return t(n.current,e)},[t,e]),ue(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function ht(){const e=le(/* @__PURE__ */new Map),[t,n]=de(!1);return{dirty:t,registerDirty:he((t,r)=>{const o=()=>{const t=Array.from(e.current.values()).some(Boolean);n(e=>e===t?e:t)};return e.current.set(t,r),o(),()=>{e.current.delete(t),o()}},[])}}function ft(){return ae(ut)}function pt(e){if("page"!==e.type&&ct(e))return null;const t="page"===e.type?"page":e.entityType||"",n="page"===e.type?e.route||"":e.entityId||"";return t&&n?{entityType:t,entityId:n,label:e.label}:null}function wt({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=ht(),i=De[e.route];if(!i||!Le(i))return null;const a=i,s=a.component;/* @__PURE__ */
14
+ return Ee(mo,{open:!0,onClose:t,icon:l[e.route],title:a.label,size:a.size||"2xl",dirty:r,allowPinOnTop:a.allowPinOnTop,initialPosition:a.initialPosition,widget:a.widget,compact:a.compact,appStyle:a.appStyle,flushBody:a.flushBody,autoHeight:a.autoHeight,autoMinHeight:a.autoMinHeight,autoWidth:a.autoWidth,dimensions:a.dimensions,windowKey:e.id,openedFromKey:e.openedFrom,accentRgb:n,children:/* @__PURE__ */Ee(dt.Provider,{value:o,children:/* @__PURE__ */Ee(xe,{fallback:/* @__PURE__ */Ee("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */Ee(N,{})}),children:/* @__PURE__ */Ee(s,{})})})})}function yt({entityType:e,entityId:t,label:n}){const r=re(),o=Se(),{data:i}=Ne({queryKey:["my-profile-sidebar"],enabled:Pe(),queryFn:()=>Ie.get("/auth/me/").then(e=>e.data)}),a=(i?.preferences||{}).favorite_documents||[],s=a.some(n=>n.entityType===e&&n.entityId===t);/* @__PURE__ */
15
+ return Ee("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];Ie.patch("/auth/me/",{preferences:{favorite_documents:r}}).then(()=>{o.invalidateQueries({queryKey:["my-profile-sidebar"]})})},title:s?r.taskbar.removeFromDesktop:r.taskbar.addToDesktop,className:"shrink-0 transition-colors "+(s?"text-yellow-500 hover:text-yellow-600":"text-gray-300 hover:text-yellow-400"),children:/* @__PURE__ */Ee(U,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var gt=/* @__PURE__ */new Set,vt=()=>"hidden";function bt({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=De[e.entityType];if(!o||!ze(o))return null;const i=o,[a,s]=de(!1),{dirty:c,registerDirty:u}=ht(),d=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,m=e.entitySnapshot?._duplicate,h=lt(e.entityId),f=$e(),p=(w=e.id,me(R,()=>{const e=Zn.get(w);return null!=e&&Xn.has(e)}));var w;const y=!i.selfFetching&&!m&&!h&&Pe(),g=Ne({queryKey:[d,e.entityId],queryFn:()=>{return Ie.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:ot(e.entitySnapshot),initialDataUpdatedAt:0,enabled:y,staleTime:0,refetchOnWindowFocus:()=>{return void 0===(e=f.entityRefetchOnWindowFocus)||("function"==typeof e?e():e);var e},refetchOnMount:"always",refetchInterval:e=>function(e,t={}){if(_e(e))return!1;if(t.minimized)return!1;const n=t.hostInterval;if(void 0===n)return 6e4;const r="function"==typeof n?n():n;return"number"==typeof r&&r>0&&r}(e.state.error,{minimized:p,hostInterval:f.entityRefetchInterval}),refetchIntervalInBackground:!1,retry:Qe}),v=g.data,b=g.refetch;ue(()=>{var t;if(y)return t=t=>{t!==e.id||gt.has(t)||b({cancelRefetch:!1})},fr.add(t),()=>{fr.delete(t)}},[b,e.id,y]);const x=he(()=>{a&&!c?s(!1):t()},[a,c,t]),k=(i.useEdit??vt)(v??null),E=!i.useEdit||h||m?void 0:{state:k,editing:a,onEdit:()=>s(!0),onDiscard:()=>s(!1)},C=i.selfFetching?e.label:v?i.title(v,a,s):e.label,M=i.icon,S=M?l[M]:null,L=C,z=!i.selfFetching&&v&&i.footer&&!m?i.footer(v):void 0;return i.rendersOwnModal?i.selfFetching?/* @__PURE__ */Ee(xe,{fallback:/* @__PURE__ */Ee(N,{}),children:i.render(v??e.entitySnapshot,t,e.entityId,a,s)}):null!=v?/* @__PURE__ */Ee(xe,{fallback:/* @__PURE__ */Ee(mo,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */Ee(rt,{})}),children:i.render(v,t,e.entityId,a,s)}):/* @__PURE__ */Ee(mo,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */Ee(it,{isPending:g.isPending,isFetching:g.isFetching,enabled:y,error:g.error,onRetry:b})}):/* @__PURE__ */Ee(mo,{open:!0,onClose:x,onMinimize:n,initialBox:e.savedBox,icon:S,title:L,footer:z,copyText:e.label,windowKey:e.id,openedFromKey:e.openedFrom,size:i.size||"2xl",dirty:c,editing:a||h||m,edit:E,dimensions:i.dimensions,autoHeight:i.autoHeight,autoMinHeight:i.autoMinHeight,autoWidth:i.autoWidth,appStyle:i.appStyle,flushBody:i.flushBody,accentRgb:r,children:/* @__PURE__ */Ee(dt.Provider,{value:u,children:/* @__PURE__ */Ee(xe,{fallback:/* @__PURE__ */Ee(rt,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */Ee(at,{entity:v,isPending:g.isPending,isFetching:g.isFetching,enabled:y,error:g.error,onRetry:b,children:n=>i.render(n,t,e.entityId,a,s)})})})})}function xt(e){return document.querySelector(`[data-modal-panel][data-window-key="${e}"]`)}function kt(e){return document.querySelector(`[data-modal-panel][data-window-root][data-window-owner="${e}"]`)}function Et(e){const t=xt(e),n=t??kt(e);if(!n)return;if(t&&!zr(t))return r=e,void window.dispatchEvent(new CustomEvent("modal-reveal",{detail:{windowKey:r}}));var r;const o=n.getAttribute("data-modal-id");o&&pr(o)}function Ct(){const e=W();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var Mt=/* @__PURE__ */new Map;function St(){const e=Ct();if(e)return Mt.get(e)}function Nt(e){const t=document.querySelectorAll("[data-modal-panel]");for(const n of Array.from(t)){const t=n.querySelector("[data-window-title]");if(t?.textContent?.includes(e))return n}return null}var Lt="rosh-peek-style",zt=G.peek,Tt=G.taskbarPreview;function At(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(Lt))return;const e=document.createElement("style");e.id=Lt,e.textContent=`body.rosh-peeking [data-modal-panel]{transition:opacity .18s ease}body.rosh-peeking [data-modal-panel]:not([data-peek-focus]){opacity:.4}body.rosh-peeking [data-modal-panel][data-peek-focus]{opacity:1}body.rosh-peeking [data-modal-panel][data-peek-focus]:not([data-pinned-top]){z-index:${zt}!important}html.rosh-reduce-transparency body.rosh-peeking [data-modal-panel]:not([data-peek-focus]){opacity:.92}@media (prefers-reduced-motion:reduce){body.rosh-peeking [data-modal-panel]{transition:none}}`,document.head.appendChild(e)}(),document.querySelectorAll("[data-modal-panel][data-peek-focus]").forEach(e=>e.removeAttribute("data-peek-focus")),e&&e.setAttribute("data-peek-focus",""),document.body.classList.toggle("rosh-peeking",!!e))}function Dt(){"undefined"!=typeof document&&(document.body.classList.remove("rosh-peeking"),document.querySelectorAll("[data-modal-panel][data-peek-focus]").forEach(e=>e.removeAttribute("data-peek-focus")))}function Pt({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=re(),l=le(null),[c,u]=de({w:n,h:Math.round(.75*r)}),[d,m]=de(!1);return ce(()=>{const o=l.current;if(!o)return;const i=xt(e)??Nt(t);if(!i)return void m(!1);const a=i.getBoundingClientRect();if(0===a.width||0===a.height)return void m(!1);const s=Q({width:n,height:r},a),c=Math.max(80,Math.round(a.width*s)),d=Math.max(60,Math.round(a.height*s));u({w:c,h:d}),m(!0);const h=i.cloneNode(!0);h.style.position="absolute",h.style.top="0",h.style.left="0",h.style.right="auto",h.style.bottom="auto",h.style.width=a.width+"px",h.style.height=a.height+"px";const f=Z(a.width,s);return Object.assign(h.style,{transform:f.transform??"",transformOrigin:f.transformOrigin}),h.style.pointerEvents="none",h.style.animation="none",h.style.zIndex="auto",h.removeAttribute("data-modal-panel"),h.removeAttribute("data-modal-id"),h.removeAttribute("data-window-key"),h.removeAttribute("role"),h.removeAttribute("aria-labelledby"),h.removeAttribute("aria-label"),h.querySelectorAll('[role="dialog"], [data-portal]').forEach(e=>{e.style.display="none"}),o.innerHTML="",o.appendChild(h),()=>{o.innerHTML=""}},[e,t,n,r]),/* @__PURE__ */ke("div",{style:{width:c.w,height:c.h},className:"relative rounded-md overflow-hidden bg-white/95 border border-line-strong shadow-(--elevation-panel) cursor-pointer ring-2 ring-transparent group-hover:ring-blue-400 transition shrink-0",onClick:i,children:[
16
+ /* @__PURE__ */Ee("div",{ref:l,className:"absolute inset-0 z-0 overflow-hidden"}),!d&&/* @__PURE__ */ke("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-gray-400 bg-gray-50",children:[
17
+ /* @__PURE__ */Ee(U,{name:"window",className:"h-6 w-6",strokeWidth:1.5}),
18
+ /* @__PURE__ */Ee("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */Ee("div",{className:"absolute bottom-0 left-0 right-0 z-10 px-2 py-1 text-2xs font-medium text-on-accent bg-gradient-to-t from-black/80 to-transparent truncate pointer-events-none",children:t}),a&&/* @__PURE__ */Ee("button",{onClick:e=>{e.stopPropagation(),a()},className:"absolute top-1 right-1 z-20 h-5 w-5 rounded-full bg-gray-900/90 ring-1 ring-white/80 shadow-sm hover:bg-red-500 text-on-accent flex items-center justify-center",title:s.taskbar.closeWindow,children:/* @__PURE__ */Ee(U,{name:"close",className:"h-3 w-3",strokeWidth:3})})]})}function It({items:e,anchorEl:t,onActivate:n,onClose:r,onMouseEnter:o,onMouseLeave:i}){const a=re(),s=e.length>1,l=le(null),[c,u]=de({left:-9999,top:-9999,ready:!1}),[d,m]=de(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");ce(()=>{const e=l.current;if(!e)return;const n=()=>{const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom";m(o);let i,a=n.left+n.width/2-r.width/2;"top"===o?i=n.bottom+8:"left"===o?(a=n.right+8,i=n.top+n.height/2-r.height/2):"right"===o?(a=n.left-r.width-8,i=n.top+n.height/2-r.height/2):i=n.top-r.height-8,a=Math.max(8,Math.min(a,window.innerWidth-r.width-8)),i=Math.max(8,Math.min(i,window.innerHeight-r.height-8)),u({left:a,top:i,ready:!0})};n();const r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,e.length]),ue(()=>Dt,[]);const h="top"===d,f=(h?"mt-1":"mb-1")+" max-w-[240px] truncate text-2xs font-medium text-ink-strongest bg-white/80 px-2 py-0.5 rounded shadow-sm ring-2 ring-transparent transition group-hover:ring-blue-400";return V(
19
+ /* @__PURE__ */Ee("div",{ref:l,"data-taskbar-preview":"",style:{position:"fixed",left:c.left,top:c.top,zIndex:Tt,maxWidth:"calc(100vw - 16px)",opacity:c.ready?1:0},className:s?"flex gap-2 flex-wrap":"",onMouseEnter:o,onMouseLeave:()=>{Dt(),i()},children:e.map(e=>{const t=xt(e.id)??Nt(e.label),o=t?function(e){if(zr(e))return null;const t=e.getBoundingClientRect(),n=br(),r=t.left+t.width/2-(n.x+n.w/2),o=t.top+t.height/2-(n.y+n.h/2);return 180*Math.atan2(o,r)/Math.PI}(t):null;/* @__PURE__ */
20
+ return ke("div",{className:"group flex flex-col items-center",onMouseEnter:()=>At(t),children:[!h&&/* @__PURE__ */Ee("span",{className:f,children:e.label}),
21
+ /* @__PURE__ */Ee(Pt,{id:e.id,label:e.label,maxW:240,maxH:160,titleAbove:!0,onClick:()=>n(e.id),onClose:()=>r(e.id)}),h&&/* @__PURE__ */Ee("span",{className:f,children:e.label}),null!==o&&/* @__PURE__ */ke("span",{title:a.taskbar.offscreenHint,className:"mt-1 inline-flex items-center gap-1 rounded bg-amber-500 px-2 py-0.5 text-2xs font-semibold text-on-accent shadow-sm",children:[
22
+ /* @__PURE__ */Ee(U,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function Rt(e,t){const n=getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom";return"top"===n?{left:Math.min(e,window.innerWidth-220),top:t+4}:"left"===n?{left:e+4,top:Math.min(t,window.innerHeight-160)}:"right"===n?{right:window.innerWidth-e+4,top:Math.min(t,window.innerHeight-160)}:{left:Math.min(e,window.innerWidth-220),bottom:window.innerHeight-t+4}}function Wt({openWindows:e,onRemove:t,onSplitView:n,onActivate:r,onActivateById:o}){const i=re(),[a,s]=de(null);ue(()=>{let e,t;const n=()=>{clearInterval(e),clearTimeout(t),e=void 0},r=()=>{const e=document.getElementById("taskbar-windows");return s(t=>t===e?t:e),!!e},o=()=>{n(),r()||(e=setInterval(()=>{r()&&n()},100),t=setTimeout(n,5e3))};return o(),window.addEventListener("react-os-shell:layout-mode-changed",o),()=>{n(),window.removeEventListener("react-os-shell:layout-mode-changed",o)}},[]);const c=me(R,W),[,u]=de(0);ue(()=>{const e=()=>u(e=>e+1);return window.addEventListener("modal-geometry",e),window.addEventListener("resize",e),()=>{window.removeEventListener("modal-geometry",e),window.removeEventListener("resize",e)}},[]);const[,d]=de(0);ue(()=>{const e=()=>d(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const m=e=>{const t=Nt(e),n=t?.querySelector("[data-window-title]");return n?.textContent?.trim()||e},[h,f]=de(null),[p,w]=de(null),[y,g]=de(null),v=le(null),b=()=>{v.current&&(clearTimeout(v.current),v.current=null),v.current=setTimeout(()=>{f(null),w(null)},150)},k=e.filter(e=>!e.route||!De[e.route]?.utility);if(!a||!a.isConnected||0===k.length)return null;const E=[],C=/* @__PURE__ */new Map;for(const e of k){const t=e.route?De[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=C.get(r);if(void 0!==o)E[o].items.push(e);else{C.set(r,E.length);const o=n?.label??t?.label??e.label;E.push({key:r,route:n?.icon??e.route,label:o,items:[e]})}}return V(
23
+ /* @__PURE__ */ke(Ce,{children:[E.map(e=>{const n=e.route?l[e.route]:null,r=e.items[e.items.length-1];let a=!1;if(c){const t=document.querySelector(`[data-modal-id="${c}"]`);if(t){const n=t.querySelector("[data-window-title]"),r=n?.textContent??"";a=e.items.some(e=>r.includes(e.label))}}const s=e.items.length>1,u=e.items.some(e=>{const t=xt(e.id)??Nt(e.label);return!!t&&!zr(t)});/* @__PURE__ */
24
+ return ke("button",{onClick:()=>o(r.id),onMouseEnter:t=>{return n=e.items,r=t.currentTarget,void(y||(v.current&&(clearTimeout(v.current),v.current=null),v.current=setTimeout(()=>{f(n),w(r)},350)));var n,r},onMouseLeave:b,onDoubleClick:e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent("modal-center",{detail:{windowKey:r.id,label:r.label}}))},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),v.current&&(clearTimeout(v.current),v.current=null),f(null),w(null),s?g({x:t.clientX,y:t.clientY,items:e.items,label:e.label}):window.dispatchEvent(new CustomEvent("modal-context-menu",{detail:{windowKey:r.id,label:r.label,x:t.clientX,y:t.clientY}}))},style:{width:"var(--window-tab-width, 200px)",fontSize:"var(--window-tab-font-size, 12px)"},"data-tab-group":e.key,className:"group relative flex items-center gap-2 rounded-lg px-3 py-2 font-medium transition-all min-w-0 shrink "+(a?"bg-blue-100/60 border border-blue-400/60 text-blue-700":"bg-gray-50/40 border border-gray-200/40 text-gray-700 hover:bg-gray-200/40"),children:[n&&fe(n)?ye(n,{className:"h-3.5 w-3.5 shrink-0"}):/* @__PURE__ */Ee(U,{name:"expand",className:"h-3.5 w-3.5 shrink-0",strokeWidth:2}),
25
+ /* @__PURE__ */Ee("span",{className:"truncate flex-1",children:s?e.label:m(r.label)}),u&&/* @__PURE__ */Ee("span",{title:i.taskbar.offscreenDot,className:"shrink-0 h-1.5 w-1.5 rounded-full bg-amber-500"}),s&&/* @__PURE__ */Ee(x,{count:e.items.length,label:i.count.windows(e.items.length)}),!s&&/* @__PURE__ */Ee("span",{role:"button",onClick:e=>{e.stopPropagation(),t(r.id)},className:"ml-auto text-gray-400 hover:text-red-500 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:/* @__PURE__ */Ee(U,{name:"close",className:"h-3 w-3",strokeWidth:2})})]},e.key)}),
26
+ /* @__PURE__ */Ee("div",{className:"flex-1"}),k.length>=2&&/* @__PURE__ */ke("button",{onClick:n,title:i.taskbar.expose,className:"flex items-center gap-1 rounded px-2 py-1 text-2xs font-medium text-blue-600 border border-blue-300 hover:bg-accent-tint transition-colors shrink-0",children:[
27
+ /* @__PURE__ */Ee(U,{name:"grid",className:"h-3 w-3",strokeWidth:2}),"Exposé"]}),y&&/* @__PURE__ */ke(F,{portal:!0,minWidth:200,style:Rt(y.x,y.y),onClose:()=>g(null),children:[
28
+ /* @__PURE__ */Ee(q,{children:y.label}),
29
+ /* @__PURE__ */ke(B,{onClick:()=>{g(null),y.items.forEach(e=>function(e){const t=Zn.get(e);t&&wr(t)}(e.id))},children:[
30
+ /* @__PURE__ */Ee(U,{name:"remove",className:"h-4 w-4",strokeWidth:1.5}),i.taskbar.minimizeAllWindows]}),
31
+ /* @__PURE__ */ke(B,{onClick:()=>{g(null),y.items.forEach(e=>o(e.id))},children:[
32
+ /* @__PURE__ */Ee("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */Ee("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75h6.5v6.5h-6.5zM13.75 8.75h6.5v6.5h-6.5z"})}),i.taskbar.restoreAllWindows]}),
33
+ /* @__PURE__ */Ee(Y,{}),
34
+ /* @__PURE__ */ke(B,{danger:!0,onClick:()=>{g(null),y.items.forEach(e=>t(e.id))},children:[
35
+ /* @__PURE__ */Ee(U,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${y.items.length})`]})]}),h&&p&&/* @__PURE__ */Ee(It,{items:h,anchorEl:p,onActivate:e=>{o(e),f(null),w(null)},onClose:e=>{t(e),f(null),w(null)},onMouseEnter:()=>{v.current&&(clearTimeout(v.current),v.current=null)},onMouseLeave:b})]}),a)}var $t=["/login","/forgot-password","/reset-password","/force-change-password"];function Ot({children:e,windowAccentForRoute:t}){const n=Me(),r=$t.some(e=>n.pathname.startsWith(e)),[o,i]=de([]),a=le(o);ce(()=>{a.current=o},[o]);const s=me(qe,Ye,Ye),l=le(/* @__PURE__ */new Map),c=e=>{const t=Ze(e),n=!!s&&"page"===e.type&&e.route===s,r=e.pageSearch||void 0,o=l.current.get(e.id);if(o&&o.tab===t&&o.home===n&&o.pageSearch===r)return o;const i={key:e.id,tab:t,home:n,...r?{pageSearch:r}:{}};return l.current.set(e.id,i),i};ue(()=>{Mt.clear();for(const e of o)e.route&&Mt.set(e.id,e.route)},[o]);const u=he(e=>{i(t=>t.filter(t=>t.id!==e))},[]),d=he(e=>{var t;xt(e)||kt(e)?(t=e,window.dispatchEvent(new CustomEvent(Yr,{detail:{windowKey:t}}))):u(e)},[u]),m=(e,t=!1)=>{const n=Vn;t&&gt.add(e),setTimeout(()=>{const r=xt(e)??kt(e),o=r?.getAttribute("data-modal-id");var i,a;!o||(i=o,a=n,(Gn.get(i)??-1)>a)||pr(o),t&&gt.delete(e)},50)},h=(e,t,n)=>{const r=He;if(n||!r)return[...e,t];const o=function(e,t,n){if(!Ze(t))return e.length;if(t.shellOwned&&tt(t,n.home))return 0;const r=tt(t,n.home)?void 0:et(t)?.key;if(r){let t=-1;if(e.forEach((e,o)=>{Ze(e)&&!tt(e,n.home)&&et(e)?.key===r&&(t=o)}),t>=0)return t+1}if("page"===t.type&&t.route&&!tt(t,n.home)&&n.favorites.includes(t.route))return e.length>0&&tt(e[0],n.home)?1:0;const o=t.openedFrom?e.findIndex(e=>e.id===t.openedFrom):-1;if(o>=0){const t=/* @__PURE__ */new Set([e[o].id]);let r=o+1;for(;r<e.length&&e[r].openedFrom&&t.has(e[r].openedFrom);)t.add(e[r].id),r++;const i=t=>Ze(e[t])&&!tt(e[t],n.home)?et(e[t])?.key:void 0;for(;r>0&&r<e.length&&void 0!==i(r)&&i(r)===i(r-1);)r++;return r}return e.length}(e,t,{home:Ye(),favorites:r.favorites});return[...e.slice(0,o),t,...e.slice(o)]},f=he(e=>{i(t=>function(e,t){const n=new Set(t),r=new Map(e.map(e=>[e.id,e])),o=t.map(e=>r.get(e)).filter(e=>!!e);if(o.length!==n.size)return e;let i=0;const a=e.map(e=>n.has(e.id)?o[i++]:e);return a.every((t,n)=>t===e[n])?e:a}(t,e))},[]),p=he((e,t,n,r,o,a={})=>{if(!De[e]||!ze(De[e]))return;const s=`${e}:${t}`,l=Ct();i(i=>{const c=i.find(n=>n.entityType===e&&String(n.entityId)===String(t));return c?(m(c.id),i):(m(s,!0),h(i,{id:s,type:"modal",label:r||t,route:o||window.location.pathname,entityType:e,entityId:t,entitySnapshot:ot(n),openedFrom:l},!!a.append))})},[]),w=he((e,t={})=>{if(!De[e]||!Le(De[e]))return;const n=De[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l,append:c=!1}=t,u=e=>{var t;o?(t=e,or.add(t)):m(e)};if(n.widget){const t=a.current.find(t=>"page"===t.type&&t.route===e);if(t)return void d(t.id)}const f=Ct();i(t=>{if(n.multiInstance){const i=t.filter(t=>"page"===t.type&&t.route===e);if(s&&i.length>0)return t;if(r&&!l&&i.length>0)return o||m(i[i.length-1].id),t;const a=`page:${e}:${Math.random().toString(36).slice(2,8)}`;return u(a),h(t,{id:a,type:"page",label:n.label,route:e,openedFrom:f,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)}const i=t.find(t=>"page"===t.type&&t.route===e);if(i)return n.widget?t:(o||m(i.id),l&&i.pageSearch!==l?t.map(e=>e===i?{...e,pageSearch:l}:e):t);const a=`page:${e}`;return u(a),h(t,{id:a,type:"page",label:n.label,route:e,openedFrom:f,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)})},[d]),y=he(()=>{},[]),g=he(()=>{},[]),v=d,b=d;/* @__PURE__ */
36
+ return ke(ut.Provider,{value:{openWindows:o,openEntity:p,openPage:w,reorderWindows:f,closeEntity:v,minimize:y,items:[],openItems:o,restore:g,remove:b,restoreIfMinimized:()=>!1},children:[e,
37
+ /* @__PURE__ */Ee(Wt,{openWindows:o,onRemove:d,onSplitView:co,onActivate:e=>{document.querySelectorAll("[data-modal-panel]").forEach(t=>{const n=t.querySelector("[data-window-title]");if(n?.textContent?.includes(e)){const e=t.getAttribute("data-modal-id");e&&pr(e)}})},onActivateById:Et}),
38
+ /* @__PURE__ */Ee(uo,{}),!r&&o.map(e=>{const n=e.route?t?.(e.route):void 0;
39
+ /* @__PURE__ */
40
+ return Ee(Oe.Provider,{value:c(e),children:/* @__PURE__ */Ee(Ve,{fallback:(t,n)=>/* @__PURE__ */Ee(mo,{open:!0,onClose:()=>u(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */Ee(Xe,{error:t,onReload:n})}),children:/* @__PURE__ */Ee(pn,{spec:pt(e),children:/* @__PURE__ */Ee(po,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */Ee(wt,{item:e,onClose:()=>u(e.id),accentRgb:n}):/* @__PURE__ */Ee(bt,{item:e,onClose:()=>u(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var Kt=400;function jt({panelRef:e,bodyRef:t,open:n,widget:r,active:o,minimized:i}){const a=le(null),s=le(!1);n&&!s.current&&(a.current="undefined"==typeof document?null:document.activeElement),s.current=n;const l=le(!1),c=le(void 0),u=le(i),d=u.current&&!i;u.current=i;const m=()=>{l.current=!0,clearTimeout(c.current),c.current=setTimeout(()=>{l.current=!1},Kt)};ue(()=>{n&&!r&&m()},[n,r]),ue(()=>{d&&n&&!r&&m()},[d]),ue(()=>()=>clearTimeout(c.current),[]),ue(()=>{if(!n||r||!o||i||!l.current)return;l.current=!1;const a=e.current;if(!a||a.contains(document.activeElement))return;if(document.activeElement?.closest('[aria-modal="true"]'))return;const s=t.current?K(t.current)[0]:void 0;s?s.focus():(a.hasAttribute("tabindex")||a.setAttribute("tabindex","-1"),a.focus())},[n,r,o,i,e,t]),ce(()=>{if(!n||r)return;const t=e.current;return()=>{const e=a.current,n=document.activeElement;(!n||n===document.body||!!t?.contains(n))&&e&&e.isConnected&&!t?.contains(e)&&e.focus?.()}},[n,r,e])}var Ft=null,Bt=/* @__PURE__ */new Set;function Yt(){return Ft}function qt(e){if(Ft!==e){Ft=e;for(const e of Bt)e()}}function Ht(e){return Bt.add(e),()=>{Bt.delete(e)}}var Ut=!1,Xt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},Vt=()=>{};function Gt(e){Ut=e,Xt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function Jt(e,t){Ut&&("submenu"===e?Xt.submenus++:Xt.menus++,Xt.menuKey=t)}function _t(e){if(!Ut)return Vt;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!Ut)return;const r=performance.now()-t;"move"===e?Xt.moveMs+=r:Xt.resizeMs+=r}}function Qt(){const e=Xt;return Xt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var Zt=/* @__PURE__ */new Set([j,C]),en=e=>Zt.has(e)||"function"==typeof e&&"badge"===e.titleRole,tn=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),nn=/* @__PURE__ */new Set(["svg"]);function rn(e){const t=[],n={text:"",accessories:[],badges:[],actions:[]};return on(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function on(e,t,n){if(null==e||"boolean"==typeof e)return;if("string"==typeof e||"number"==typeof e)return void n.push(String(e));if(Array.isArray(e))return void e.forEach(e=>on(e,t,n));if(!fe(e))return;const r=e;if(r.type===f)return void(void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text));if(r.type===pe)return void we.toArray(r.props.children).forEach(e=>on(e,t,n));if("string"==typeof r.type){if(nn.has(r.type))return;if(!tn.has(r.type))return n.push(" "),we.toArray(r.props.children).forEach(e=>on(e,t,n)),void n.push(" ")}const o=ye(r,{key:`title-part-${t.accessories.length}`});t.accessories.push(o),(en(r.type)?t.badges:t.actions).push(o)}var an=/* @__PURE__ */new Map,sn=/* @__PURE__ */new Set,ln=0;function cn(){ln++,sn.forEach(e=>e())}function un(e){return an.get(e)}function dn(e){return sn.add(e),()=>{sn.delete(e)}}function mn(){return ln}var hn=oe(""),fn=oe(null);function pn({spec:e,children:t}){/* @__PURE__ */
41
+ return Ee(fn.Provider,{value:e,children:t})}var wn=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),yn='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600';function gn(e){return vn(e).replace(/\s+/g," ").trim()}function vn(e){if(null==e||"boolean"==typeof e)return"";if("string"==typeof e)return e;if("number"==typeof e)return String(e);if(Array.isArray(e))return e.map(vn).join("");if(fe(e)){const t=e,n="string"==typeof t.type?t.type:"";return wn.has(n)?"":` ${vn(t.props?.children)} `}return""}function bn(e){const t=ae(hn);ue(()=>{if(!t)return;const n=n=>{n.detail===t&&e()};return window.addEventListener("widget-open-settings",n),()=>window.removeEventListener("widget-open-settings",n)},[e,t])}var xn={};function kn(e,t,n){const r=ae(hn);ue(()=>{if(!r)return;xn[r]||(xn[r]=[]);const o={label:e,icon:n,onClick:t};return xn[r].push(o),()=>{xn[r]=(xn[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function En({title:e}){const t=le(null);return ue(()=>{const n=setTimeout(()=>{const n=t.current?.closest("[data-modal-id]"),r=n?.getAttribute("data-modal-id");r&&window.dispatchEvent(new CustomEvent("window-title-update",{detail:{id:r,title:e}}))},0);return()=>clearTimeout(n)},[e]),/* @__PURE__ */Ee("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function Cn(e){}function Mn(){return ae(hn)}function Sn({className:e=""}){const t=ae(I)?.setEditSlot,n=he(e=>{t?.(e)},[t]);return t?/* @__PURE__ */Ee("span",{ref:n,"data-window-edit-slot":"",className:`inline-flex items-center empty:hidden ${e}`.trim()}):null}function Nn({items:e,label:t}){const n=re().window.more;return 0===e.length?null:/* @__PURE__ */Ee(O,{side:"top",items:e,triggerClassName:te({variant:"secondary",size:"sm"}),trigger:/* @__PURE__ */ke(Ce,{children:[t??n,
42
+ /* @__PURE__ */Ee(U,{name:"chevron-down",className:"size-3.5",strokeWidth:2,"aria-hidden":"true"})]})})}function Ln({children:e,position:t="right",quiet:n=!1}){const r=ae(I),[o,i]=de(null);return ue(()=>{if(!r)return;const e="left"===t?r.leftRef:r.rightRef,o=()=>!!e.current&&(i(e.current),n||r.notify(),!0);if(o())return;const a=setInterval(()=>{o()&&clearInterval(a)},50),s=setTimeout(()=>clearInterval(a),2e3);return()=>{clearInterval(a),clearTimeout(s)}},[r,t,n]),o?V(e,o):null}function zn({onClick:e,children:t,className:n}){const r=ae(I);/* @__PURE__ */
43
+ return Ee("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./shell/ConfirmDialog.js"));if(!await e({title:"Discard changes?",message:"You have unsaved changes. Are you sure you want to cancel? All changes will be lost.",confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"}))return}e()},className:n||"bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50",children:t||"Cancel"})}var Tn="erp_window_positions",An={};try{const e=localStorage.getItem(Tn);e&&(An=JSON.parse(e))}catch{}var Dn=null;function Pn(){Dn&&clearTimeout(Dn),Dn=setTimeout(()=>{try{localStorage.setItem(Tn,JSON.stringify(An))}catch{}},500)}var In="erp_activation_order",Rn=[];try{const e=localStorage.getItem(In),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(Rn=t)}catch{}var Wn=null;function $n(){Wn&&clearTimeout(Wn),Wn=setTimeout(()=>{try{localStorage.setItem(In,JSON.stringify(Rn))}catch{}},500)}function On(e,t){An[e]||(An[e]=t,Pn())}function Kn(e){return An[e]?{...An[e]}:null}function jn(e,t){An[e]=t,Pn()}function Fn(){const r=e(),o=t();let i=!1;for(const e of Object.keys(An))n(An[e],r,o)&&(delete An[e],i=!0);i&&Pn()}var Bn={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},Yn=4e3,qn=["small","medium","large","maximized"],Hn=()=>{if("undefined"==typeof document)return"large";const e=getComputedStyle(document.documentElement).getPropertyValue("--default-window-size")?.trim();return S(qn,"large",e)},Un={small:.8,medium:1,large:1.25,maximized:1.25},Xn=/* @__PURE__ */new Set,Vn=0,Gn=/* @__PURE__ */new Map;var Jn=0;function _n(){return Jn}function Qn(){Jn++,P.forEach(e=>e())}var Zn=/* @__PURE__ */new Map,er=/* @__PURE__ */new Map,tr=/* @__PURE__ */new Map;function nr(){for(let e=D.length-1;e>=0;e--){const t=tr.get(D[e]);if(t?.tab)return t.owner}return null}function rr(){return me(R,nr,()=>null)}var or=/* @__PURE__ */new Set;var ir=null;function ar(e){ir=null,pr(e)}function sr(e){ir=e;const t=Zn.get(e);t&&ar(t)}var lr=/* @__PURE__ */new Map;function cr(e){return lr.get(e)?.holdsChanges()??!1}function ur(e){const t=lr.get(e);return t?t.ask():Promise.resolve(!0)}function dr(e){ir===e&&(ir=null)}function mr(e,t,n){if(n&&tr.set(e,n),t)if(Zn.set(t,e),er.set(e,t),or.delete(t)){D.unshift(e);const n=Rn.indexOf(t);-1!==n&&Rn.splice(n,1),Rn.unshift(t),$n()}else!function(e,t){const n=Rn.indexOf(t);if(-1===n)return void D.push(e);let r=D.length;for(let e=0;e<D.length;e++){const t=er.get(D[e]);if(t&&Rn.indexOf(t)>n){r=e;break}}D.splice(r,0,e)}(e,t),-1===Rn.indexOf(t)&&(Rn.push(t),$n());else D.push(e);Qn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&ir===t&&ar(e)}function hr(e){return e?tr.get(e)?.owner??er.get(e)??null:null}var fr=/* @__PURE__ */new Set;function pr(e){const t=hr(W()),n=D.indexOf(e);-1!==n&&D.splice(n,1),D.push(e);const r=tr.get(e);if(r?.root)for(const[e,t]of tr){if(t.root||t.owner!==r.owner||Xn.has(e))continue;const n=D.indexOf(e);-1!==n&&D.splice(n,1),D.push(e)}Xn.delete(e);const o=er.get(e);if(o){const e=Rn.indexOf(o);-1!==e&&Rn.splice(e,1),Rn.push(o),$n(),ir&&ir!==o&&(ir=null)}Qn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const i=hr(W());i&&i!==t&&fr.forEach(e=>e(i))}function wr(e){const t=D.indexOf(e);-1!==t&&D.splice(t,1),Xn.add(e),Gn.set(e,++Vn);const n=er.get(e);if(n){const e=Rn.indexOf(n);-1!==e&&(Rn.splice(e,1),$n())}Qn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var yr=/* @__PURE__ */new Set;var gr=8,vr=32;function br(){return e()}var xr="flex size-6 shrink-0 items-center justify-center rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-400",kr="flex size-3 items-center justify-center rounded-full text-gray-900/70",Er="size-2 opacity-0 group-hover/controls:opacity-100 group-focus-within/controls:opacity-100",Cr=M.windowBar,Mr=80,Sr=384,Nr=400;function Lr(e,t=br()){const n=Math.min(Math.max(e.x,t.x+Mr-e.w),t.x+t.w-Mr),r=Math.min(Math.max(e.y,t.y),t.y+t.h-Cr);return n===e.x&&r===e.y?e:{...e,x:n,y:r}}function zr(e){const t=e.getBoundingClientRect();if(0===t.width||0===t.height)return!0;const n=br();return t.left>=n.x-1&&t.top>=n.y-1&&t.right<=n.x+n.w+1&&t.bottom<=n.y+n.h+1}function Tr(e){const t=br(),n=Math.floor(t.w/2),r=Math.floor(t.h/2);switch(e){case"top":return{x:t.x,y:t.y,w:t.w,h:t.h};case"left":return{x:t.x,y:t.y,w:n,h:t.h};case"right":return{x:t.x+n,y:t.y,w:t.w-n,h:t.h};case"tl":return{x:t.x,y:t.y,w:n,h:r};case"tr":return{x:t.x+n,y:t.y,w:t.w-n,h:r};case"bl":return{x:t.x,y:t.y+r,w:n,h:t.h-r};case"br":return{x:t.x+n,y:t.y+r,w:t.w-n,h:t.h-r}}}var Ar=null;function Dr(e){const t=(Ar||((Ar=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${G.snapPreview}`,"border-radius: 8px","background: rgba(59, 130, 246, 0.18)","border: 2px solid rgb(59, 130, 246)","transition: left 120ms ease, top 120ms ease, width 120ms ease, height 120ms ease, opacity 120ms ease","opacity: 0","display: none"].join(";"),document.body.appendChild(Ar)),Ar);t.style.display="block",t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.w}px`,t.style.height=`${e.h}px`,t.style.opacity="1"}function Pr(){Ar&&(Ar.style.opacity="0",Ar.style.display="none")}var Ir=[{zone:"left",labelKey:"snapLeft",region:"inset-y-0 left-0 w-1/2"},{zone:"right",labelKey:"snapRight",region:"inset-y-0 right-0 w-1/2"},{zone:"tl",labelKey:"snapTopLeft",region:"top-0 left-0 h-1/2 w-1/2"},{zone:"tr",labelKey:"snapTopRight",region:"top-0 right-0 h-1/2 w-1/2"},{zone:"bl",labelKey:"snapBottomLeft",region:"bottom-0 left-0 h-1/2 w-1/2"},{zone:"br",labelKey:"snapBottomRight",region:"bottom-0 right-0 h-1/2 w-1/2"}],Rr=350,Wr=200;function $r({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o,children:i}){const[a,s]=de(!1),l=le(void 0),c=le(void 0);ue(()=>()=>{clearTimeout(l.current),clearTimeout(c.current)},[]);const u=()=>{clearTimeout(c.current),l.current=setTimeout(()=>s(!0),Rr)},d=()=>{clearTimeout(l.current),c.current=setTimeout(()=>s(!1),Wr)};/* @__PURE__ */
44
+ return ke("span",{className:"relative inline-flex",onMouseEnter:u,onMouseLeave:d,children:[
45
+ /* @__PURE__ */Ee("button",{onClick:t,onFocus:u,onBlur:d,"aria-label":e?o.windowed:o.maximize,title:e?o.windowed:o.maximize,className:r,children:i}),a&&/* @__PURE__ */Ee("div",{role:"group","aria-label":o.snapLayouts,onMouseEnter:()=>clearTimeout(c.current),onMouseLeave:d,className:"absolute left-0 top-full z-30 mt-1 grid w-max grid-cols-2 gap-1 rounded-lg border border-line bg-surface p-2 shadow-lg",children:Ir.map(({zone:e,labelKey:t,region:r})=>/* @__PURE__ */Ee("button",{type:"button","aria-label":o[t],title:o[t],onClick:()=>{s(!1),n(e)},onFocus:()=>clearTimeout(c.current),onBlur:d,className:"relative h-7 w-11 rounded border border-gray-300 bg-gray-50 hover:border-blue-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-400",children:/* @__PURE__ */Ee("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var Or="rosh-gesture-style";var Kr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},jr=4;function Fr(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(Or))return;const e=document.createElement("style");e.id=Or,e.textContent="body.rosh-gesturing [data-modal-panel]{will-change:transform}",document.head.appendChild(e)}();try{e.setPointerCapture(t)}catch{}document.body.classList.add("rosh-gesturing");const o=document.createElement("div");o.setAttribute("data-drag-shield",""),o.style.cssText=`position:fixed;inset:0;z-index:2147483647;cursor:${n};background:transparent;touch-action:none`,document.body.appendChild(o);const i=_t(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function Br(e){const t=D.indexOf(e);if(-1===t)return-1;const n=G.window+t*G.windowStep,r=tr.get(e);if(!r||r.root)return n;let o=-1;for(const[e,t]of tr){if(!t.root||t.owner!==r.owner)continue;const n=D.indexOf(e);-1!==n&&(o=Math.max(o,G.window+n*G.windowStep))}return o>=n?o+2+Math.min(t,7):n}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=D.length-1;e>=0;e--)yr.has(D[e])||D.splice(e,1);Rn=Rn.filter(e=>{const t=Zn.get(e);return null!=t&&yr.has(t)}),$n(),Qn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var Yr="modal-close-request";function qr(e){me(R,_n);const t=ae(I);if(D.length<=1)return!0;if(e){const t=Zn.get(e);if(null!=t)return W()===t}return t?.active??null!=W()}var Hr=!1,Ur=/* @__PURE__ */new Set;function Xr(e){return Ur.add(e),()=>Ur.delete(e)}function Vr(){return Hr}function Gr(e){Hr!==e&&(Hr=e,Ur.forEach(e=>e()))}function Jr(){Gr(!Hr)}function _r(){Gr(!1)}var Qr=null,Zr=/* @__PURE__ */new Set;function eo(e){return Zr.add(e),()=>Zr.delete(e)}function to(){return Qr}function no(e){Qr!==e&&(Qr=e,Zr.forEach(e=>e()))}var ro=null,oo=/* @__PURE__ */new Set;function io(e){return oo.add(e),()=>oo.delete(e)}function ao(){return ro}function so(e){ro!==e&&(ro=e,oo.forEach(e=>e()))}function lo(){if(!ro)return void Gr(!1);no(ro),so(null),Gr(!1)}function co(){Gr(!Hr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function uo(){const e=me(Xr,Vr),[t,n]=de(e),[r,o]=de(e);return ue(()=>{if(e){n(!0);const e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)}o(!1);const t=setTimeout(()=>n(!1),280);return()=>clearTimeout(t)},[e]),t&&"undefined"!=typeof document?V(
46
+ /* @__PURE__ */Ee("div",{onMouseDown:e=>{e.stopPropagation(),Gr(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:G.expose,cursor:"pointer",opacity:r?1:0,transition:"opacity 260ms cubic-bezier(0.2, 0.8, 0.2, 1)",pointerEvents:r?"auto":"none"}}),document.body):null}function mo({open:t,onClose:l,title:c,icon:u,copyText:d,size:f="lg",dirty:w=!1,onNext:y,onPrev:g,footer:v,bodyScroll:x,onMinimize:C,initialBox:S,actions:N,actionsLeft:L,editing:P=!1,edit:O,allowPinOnTop:K,initialPosition:j,widget:q,compact:X,appStyle:J,flushBody:_,autoHeight:Z,autoMinHeight:ee,autoWidth:te,widgetMenu:oe,dimensions:ie,windowKey:se,openedFromKey:fe,accentRgb:pe,children:we}){const[ye,be]=de(()=>r()),xe=z()&&!ye,Me=T()&&!!q,[Se,Ne]=de(0),[Le,ze]=de(!1),Te=le(null),Ae=le(0);ue(()=>{Ae.current=Se},[Se]);const De=he(e=>{xe&&(Te.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},ze(!0),qt(fe??null))},[xe,fe]),Pe=me(Ht,Yt);ue(()=>{if(!Le)return;const e=e=>{if(!Te.current)return;const t=e.clientX-Te.current.startX;if(Math.abs(e.clientY-Te.current.startY)>Math.abs(t)+12)return Te.current=null,ze(!1),Ne(0),void qt(null);Ne(Math.max(0,t))},t=()=>{if(!Te.current)return;const e=.3*window.innerWidth,t=Ae.current>e;Te.current=null,ze(!1),t?(Ne(window.innerWidth),setTimeout(()=>{l(),Ne(0),qt(null)},180)):(Ne(0),qt(null))};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[Le]);const[Ie,Re]=de(c),We=re(),$e=We.window;ue(()=>{Re(c)},[c]);const Ke=ge(()=>gn(Ie).trim()||void 0,[Ie]),je=ve(),[Fe,Be]=de(!1),Ye=le(!1),[qe,He]=de(!1),[Ue,Xe]=de(null),Ge=ae(fn),Je=ae(Oe),{prefs:_e,save:Qe}=A(),Ze=!!_e.window_accent_stripe,et=_e.favorite_documents||[],tt=!!Ge&&et.some(e=>e.entityType===Ge.entityType&&e.entityId===Ge.entityId),nt=he(()=>{if(!Ge)return;const e=tt?et.filter(e=>!(e.entityType===Ge.entityType&&e.entityId===Ge.entityId)):[...et,{entityType:Ge.entityType,entityId:Ge.entityId,label:Ge.label}];Qe({favorite_documents:e})},[Ge,tt,et,Qe]),[rt,ot]=de(null),[it,at]=de("top-right"===j?"right":"left"),st=le(!1),lt=le(null);ce(()=>{const e=lt.current;e&&(pe?e.style.setProperty("--window-accent-rgb",pe):e.style.removeProperty("--window-accent-rgb"))},[pe]);const ct=le(!1),ut=le(null),dt=le(null),ht=le(null),[pt,wt]=de(!1),yt=le(null),gt=le(null),vt=le(null),[bt,xt]=de(!1);ce(()=>{const e=gt.current,t=vt.current;if(!e||!t)return;const n=()=>xt(function(e,t){return e.scrollWidth>t.clientWidth}(t,e));if(n(),"undefined"==typeof ResizeObserver)return;const r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[null!=v&&!1!==v]);const kt=!!O&&!q&&!X&&!J&&(O.editing||"hidden"!==O.state),[Et,Ct]=de(null),Mt=kt&&(!!O?.editing||!Et),St=!!(v||N||L)||pt||Mt,Nt=""!==ae(hn),Lt=le(null);Lt.current=Je?{owner:Je.key,tab:Je.tab,root:!Nt}:null;const zt=se||(Je&&!Nt?Je.key:null),Tt=40,{minimize:At,items:Dt,restoreIfMinimized:Pt,openWindows:It}=ft(),Rt=le(`modal-${Math.random().toString(36).slice(2,8)}`).current,Wt=b(Rt);ue(()=>{if(q)return yr.add(Rt),()=>{yr.delete(Rt)}},[q,Rt]),ue(()=>{const e=e=>{const t=e.detail;t?.id===Rt&&Re(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[Rt]);const[$t,Ot]=de(G.window),Kt=function(e){const t=me(R,W);return D.length<=1||t===e}(Rt),Ft=le(O);Ft.current=O;const Bt=!!O&&!O.editing&&"enabled"===O.state;ue(()=>{if(!t||!Kt||!Bt)return;const e=e=>{("KeyE"===e.code||"E"===e.key||"e"===e.key)&&e.altKey&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(k(e.target,lt.current)||(e.preventDefault(),e.stopPropagation(),Ft.current?.onEdit()))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Kt,Bt]);const Ut=function(e){return me(R,()=>Xn.has(e))}(Rt);jt({panelRef:lt,bodyRef:ut,open:t,widget:!!q,active:Kt,minimized:Ut});const Xt=me(Xr,Vr),Vt=me(eo,to),Gt=me(io,ao),Jt=!K&&!q,_t=Xt&&Jt,[Qt,Zt]=de(!1),en=_t&&Gt===Rt,[tn,nn]=de(!1),on=tn&&Jt&&Vt===Rt?"picked":null,sn=le(_t);ue(()=>{if(sn.current&&!_t){nn(!0);const e=setTimeout(()=>{nn(!1),Qr===Rt&&no(null)},700);return sn.current=_t,()=>clearTimeout(e)}sn.current=_t},[_t,Rt]),ue(()=>{_t||Zt(!1)},[_t]),ue(()=>{const e=dt.current,t=ht.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>wt(n(e)+n(t)>0);r();const o=new MutationObserver(r);return e&&o.observe(e,{childList:!0}),t&&o.observe(t,{childList:!0}),()=>o.disconnect()},[t]),ue(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&lt.current){const t=lt.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=dt.current,n=ht.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const ln=le(!1),un=he(e,[]),dn=he(()=>{const t=e(),n=ie?ie[0]:Bn[f]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=Un[Hn()],l=ie?Math.min(ie[1],i):(()=>{const e=("sm"===f?500:"md"===f?600:"lg"===f?700:"xl"===f?800:920)*s;return Math.max(320,Math.min(e,t.h-80))})(),c="cascade"!==(getComputedStyle(document.documentElement).getPropertyValue("--window-position")?.trim()||"cascade")||r()?0:30*(D.length-1),u=Math.max(Tt,(i-l)/2),d=(o-a)/2,m=t.h-Tt-l-u;return"top-right"===j?{x:t.x+t.w-a-Tt,y:t.y+Tt,w:a,h:l}:"top-left"===j?{x:t.x+Tt,y:t.y+Tt,w:a,h:l}:{x:t.x+Math.max(Tt,(o-a)/2+Tt)+Math.min(c,Math.max(0,d)),y:t.y+u+Math.min(c,Math.max(0,m)),w:a,h:l}},[f]),mn=le(!1);t||(mn.current=!1);const pn=se||d||null;ue(()=>{if(!t)return;mr(Rt,pn,Lt.current??void 0),se||pr(Rt),ln.current=!1,Ot(Br(Rt));const e=()=>{Ot(Br(Rt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===se;if(!e.label)return!1;const t=lt.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if(pr(Rt),Ln.current)return;const t=br(),n=Math.min(Wn.current.w,t.w-40),o=Math.min(Wn.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;bn({x:i,y:a,w:n,h:o}),Rn(!1)},i=e=>{const t=e.detail;r(t)&&(pr(Rt),Xe({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==se)return;pr(Rt);const t=Wn.current,n=function(e,t=br()){const n=Math.min(e.w,t.w),r=Math.min(e.h,t.h);return{w:n,h:r,x:Math.min(Math.max(e.x,t.x),t.x+t.w-n),y:Math.min(Math.max(e.y,t.y),t.y+t.h-r)}}(t);if(n.x===t.x&&n.y===t.y&&n.w===t.w&&n.h===t.h)return;const r=lt.current,o="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(r&&!o){let e=!1;const t=()=>{e||(e=!0,r.style.transition="",window.dispatchEvent(new CustomEvent("modal-geometry")))};r.style.transition="left .28s ease, top .28s ease, width .28s ease, height .28s ease",r.addEventListener("transitionend",t,{once:!0}),window.setTimeout(t,400)}bn(n)};return window.addEventListener("modal-reorder",e),window.addEventListener("modal-split-view",n),window.addEventListener("modal-center",o),window.addEventListener("modal-reveal",a),window.addEventListener("modal-context-menu",i),()=>{!function(e){const t=D.indexOf(e);-1!==t&&(D.splice(t,1),Qn()),Xn.delete(e),Gn.delete(e),tr.delete(e);const n=er.get(e);n&&(er.delete(e),Zn.delete(n))}(Rt),window.removeEventListener("modal-reorder",e),window.removeEventListener("modal-split-view",n),window.removeEventListener("modal-center",o),window.removeEventListener("modal-reveal",a),window.removeEventListener("modal-context-menu",i),window.dispatchEvent(new CustomEvent("modal-reorder"))}},[t,Rt,pn,un]);const wn=!q&&"maximized"===Hn(),[vn,bn]=de(()=>{if(pn&&An[pn]){const e={...An[pn]};return ie&&(e.w=ie[0],Z||(e.h=ie[1])),Lr(e)}return S?{x:S.x,y:S.y,w:S.w,h:S.h}:wn?un():dn()}),[kn,En]=de(()=>!Z),Cn=le(ye),Mn=le(null);ue(()=>{const e=()=>{const e=r();e!==Cn.current&&Mn.current?.(e),Cn.current=e,be(e),Ot(Br(Rt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[Rt]);const Sn=ye&&!!Je?.tab&&!Nt&&!q&&!xe,Nn=Sn,Ln=le(Nn);Ln.current=Nn;const zn=rr(),Tn=ye&&!!Je?.tab&&!q&&!xe&&!Xt&&zn!==Je.key,Dn=!!q&&ye&&!Xt&&null!==zn,[In,Rn]=de(()=>pn&&An[pn]||S?Nn:Nn||wn),Wn=le(vn);Wn.current=vn;const $n=le(In);ce(()=>{$n.current=In},[In]),ce(()=>{if(kn||Sn)return;const e=lt.current,t=ut.current;if(!e||!t)return;const n=ee??(q?0:240),r=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0;let o=0,i=null,a=null;const s=()=>{const c=t.firstElementChild;if(!c||e.offsetHeight<=0)return;c!==a&&(a&&l.unobserve(a),l.observe(c),a=c);const u=e.offsetHeight-t.offsetHeight,d=t.style.flex,m=t.style.overflowY,h=t.style.height;t.style.flex="0 0 auto",t.style.height="auto",t.style.overflowY="visible";const f=t.offsetHeight,p=c.offsetHeight;t.style.flex=d,t.style.height=h,t.style.overflowY=m;const w=c.offsetHeight>p+4,y=Math.max(n,window.innerHeight-r-Math.max(0,Wn.current.y)-24),g=w?Math.min(Wn.current.h,y):Math.min(Math.max(n,u+f),y),v=Math.abs(g-o)>1;v&&(o=g,bn(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),q||(g<=n?i&&(clearTimeout(i),i=null):(v||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&En(!0)},160)))},l=new ResizeObserver(s);s(),yt.current&&l.observe(yt.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[kn,q,ee,St,Sn]),ce(()=>{if(!Z||!kn||q||!t)return;const e=yt.current;if(!e)return;let n=e.offsetHeight;const r=new ResizeObserver(()=>{if(!e.isConnected)return;const t=e.offsetHeight,r=t-n,o=t>0!=n>0;if(n=t,!o||0===r||In)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=ee??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,Wn.current.y)-24);bn(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[Z,kn,q,t,In,ee]);const On=!1!==te&&!q&&!J&&!xe,[Kn,jn]=de(()=>!On);ce(()=>{if(Kn||!t)return;if(!On||In)return void jn(!0);const n=lt.current,r=ut.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let l=Wn.current.w,c=0;const u=()=>jn(!0),d=()=>{c=0;const t=Wn.current;if(Math.abs(t.w-l)>1||document.body.classList.contains("rosh-gesturing"))return void u();const d=e(),m=d.w-80;if(t.w>=m)return void u();const h=[],f=[];for(const e of[r,...Array.from(r.querySelectorAll("*"))]){const t=e.scrollWidth-e.clientWidth;if(t<=4||o.has(e))continue;const n=getComputedStyle(e).overflowX;"auto"!==n&&"scroll"!==n||(h.push(e),f.push(t))}if(!h.length)return;const p=Math.min(m,t.w+Math.max(...f)),w=p-t.w,y=n.style.width;n.style.width=`${p}px`;const g=h.map((e,t)=>({over:f[t],residual:e.scrollWidth-e.clientWidth}));n.style.width=y,g.forEach((e,t)=>{i(e,w)||o.add(h[t])});const v=a(t,s(t.w,w,g),d,Tt);v!==t&&(l=v.w,bn(v))};d();const m=new MutationObserver(()=>{c||(c=requestAnimationFrame(d))});m.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["style","class","hidden"]});const h=setTimeout(u,Yn);return()=>{m.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(h)}},[Kn,t,On,In]);const Fn=le(null),qn=!(!Je?.tab||Nt||q||xe);Mn.current=t=>{if(!qn)return;if(t)return Fn.current||(Fn.current={box:{...Wn.current},maximized:$n.current}),void($n.current=!0);const r=Fn.current;Fn.current=null;const o=e();if(r?.maximized)return $n.current=!0,Rn(!0),void bn(o);const i=r?.box??(pn?An[pn]:void 0);if($n.current=!1,Rn(!1),i&&!n(i,o,!1)){const e={...i};ie&&(e.w=ie[0],Z||(e.h=ie[1])),bn(Lr(e))}else bn(dn())},ue(()=>{Nn&&($n.current=!0,Rn(!0),bn(un()))},[Nn,un]),ue(()=>{if(q)return;const e=()=>{const e=pn?An[pn]:void 0;if($n.current=!1,Rn(!1),e){const t={...e};ie&&(t.w=ie[0],Z||(t.h=ie[1])),bn(Lr(t))}else bn(dn())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[q,dn,pn]),ue(()=>{t&&pn&&!Sn&&(An[pn]=vn,Pn()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[vn,t,pn,Sn]),ue(()=>{if(!t)return;const e=()=>{$n.current?bn(un()):document.body.classList.contains("rosh-gesturing")||bn(Lr)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return In&&(n=new MutationObserver(e),n.observe(document.body,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["class"]})),()=>{window.removeEventListener("resize",e),window.removeEventListener(o,e),n?.disconnect()}},[t,In,un]),ue(()=>{if(t&&(Be(!1),Ye.current=!1,st.current=!1,jn(!On),!Ln.current)){if(pn&&An[pn]){const e=An[pn];return void bn(t=>Lr({...e,...Z?{h:t.h}:{},...On?{x:t.x,w:t.w}:{}}))}S&&(bn({x:S.x,y:S.y,w:S.w,h:S.h}),Rn(S.maximized))}},[t]),ue(()=>{if(!t||"auto"!==w)return;let e;const n=t=>{lt.current?.contains(t.target)&&!Ye.current&&(Ye.current=!0,e=setTimeout(()=>Be(!0),0))};return document.addEventListener("input",n,!0),document.addEventListener("change",n,!0),()=>{clearTimeout(e),document.removeEventListener("input",n,!0),document.removeEventListener("change",n,!0)}},[t,w]);const Vn="auto"===w?Fe:!0===w,Jn=Je&&!Nt?Je.key:null,_n=ge(()=>rn(Ie),[Ie]),nr=le({shortcutSpec:Ge,isOnDesktop:tt,toggleDesktopShortcut:nt,taskbarStrings:We.taskbar});ce(()=>{nr.current={shortcutSpec:Ge,isOnDesktop:tt,toggleDesktopShortcut:nt,taskbarStrings:We.taskbar}});const or=le(null);or.current||(or.current={open:(e,t)=>Xe({x:e,y:t}),items:()=>{const e=nr.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of xn[Rt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),ue(()=>{if(t&&Jn)return()=>{return e=Jn,void(an.delete(e)&&cn());var e}},[t,Jn]),mt(!(se||!t)&&Vn);const ir=he(()=>Vn||"auto"===w&&Ye.current,[Vn,w]),ar=he(async e=>{if(st.current)return!1;if(!ir())return!0;st.current=!0;const t=Ke,n="close"===e?"Are you sure you want to close?":"discard"===e?"Are you sure you want to stop editing?":"Are you sure you want to continue?",r=await p({title:"Discard changes?",message:t?`“${t}” has unsaved changes. ${n} All changes will be lost.`:`You have unsaved changes. ${n} All changes will be lost.`,confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"});return st.current=!1,r},[ir,Ke]),sr=he(()=>st.current?Promise.resolve():ir()?ar("close").then(e=>{e&&l()}):(l(),Promise.resolve()),[ir,ar,l]),cr=he(async()=>{await ar("discard")&&(Ye.current=!1,Be(!1),Ft.current?.onDiscard())},[ar]),ur=he(async()=>{const e=await ar("switch");return e&&(Ye.current=!1,Be(!1)),e},[ar]),dr=le(()=>!1);ce(()=>{dr.current=ir}),ce(()=>{if(!t||!se)return;const e={holdsChanges:()=>dr.current(),ask:ur};return lr.set(se,e),()=>{lr.get(se)===e&&lr.delete(se)}},[t,se,ur]),ce(()=>{if(!t||!zt)return;const e=e=>{e.detail?.windowKey===zt&&sr()};return window.addEventListener(Yr,e),()=>window.removeEventListener(Yr,e)},[t,zt,sr]);const hr=le(null),fr=he(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if(Xe(null),pr(Rt),Ln.current)return void e.preventDefault();e.preventDefault();const t=e.currentTarget,n=e.pointerId;let r=null;const o=e.clientX,i=e.clientY,a=lt.current,s=a?.getBoundingClientRect();let l,c,u,d;if(hr.current){const t=hr.current;hr.current=null,d=t.w,u=t.h;const n=s?Math.min(Math.max(20,e.clientX-s.left),t.w-20):t.w/2;l=e.clientX-n,c=e.clientY-12,a&&(a.style.width=`${d}px`,a.style.height=`${u}px`,a.style.left=`${l}px`,a.style.top=`${c}px`)}else l=s?s.left:Wn.current.x,c=s?s.top:Wn.current.y,u=s?s.height:Wn.current.h,d=s?s.width:Wn.current.w;Rn(!1),bn(e=>({...e,x:l,y:c,w:d,h:u}));let m=null;const h=e=>{if(!r){if(Math.abs(e.clientX-o)<jr&&Math.abs(e.clientY-i)<jr)return;r=Fr(t,n,"move","move"),a&&(a.style.transition="none")}const s=l+e.clientX-o,u=Math.max(0,c+e.clientY-i);if(a&&(a.style.transform=`translate(${s-l}px, ${u-c}px)`),Wn.current={...Wn.current,x:s,y:u},!q){const t=function(e,t){const n=br(),r=e<=n.x+gr,o=e>=n.x+n.w-gr,i=t<=n.y+gr,a=t>=n.y+n.h-gr,s=e<=n.x+vr,l=e>=n.x+n.w-vr,c=t<=n.y+vr,u=t>=n.y+n.h-vr;return i&&s?"tl":i&&l?"tr":a&&s?"bl":a&&l?"br":c&&r?"tl":c&&o?"tr":u&&r?"bl":u&&o?"br":i?"top":r?"left":o?"right":null}(e.clientX,e.clientY);t!==m&&(m=t,t?Dr(Tr(t)):Pr())}},f=()=>{window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",f),r?.(),Pr();const e=Lr({...Wn.current});if(Wn.current=e,!q&&m){hr.current={x:l,y:c,w:d,h:u};const e=Tr(m);return a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.width=`${e.w}px`,a.style.height=`${e.h}px`,a.style.transform="",a.style.transition=""),void bn(e)}if(q){const t=e.x+e.w/2,n=window.innerWidth/2;at(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),bn(e)};window.addEventListener("pointermove",h),window.addEventListener("pointerup",f)},[]),Cr=he((e,t)=>{if(0!==e.button)return;e.preventDefault(),e.stopPropagation();const n=e.currentTarget,r=e.pointerId;let o=null;const i=e.clientX,a=e.clientY,s=lt.current,l=s?.getBoundingClientRect(),c=l?l.left:Wn.current.x,u=l?l.top:Wn.current.y,d=l?l.width:Wn.current.w,m=l?l.height:Wn.current.h,h="sw"===t||"nw"===t||"w"===t,f="ne"===t||"nw"===t||"n"===t,p="se"===t||"ne"===t||"e"===t,w="se"===t||"sw"===t||"s"===t;Rn(!1),bn({x:c,y:u,w:d,h:m}),Wn.current={x:c,y:u,w:d,h:m};let y=0,g=null;const v=()=>{if(y=0,!g)return;const e=g;g=null,Wn.current=e,s&&(s.style.left=`${e.x}px`,s.style.top=`${e.y}px`,s.style.width=`${e.w}px`,s.style.height=`${e.h}px`)},b=e=>{if(!o){if(Math.abs(e.clientX-i)<jr&&Math.abs(e.clientY-a)<jr)return;o=Fr(n,r,Kr[t],"resize")}g=((e,t)=>{let n=c,r=u,o=d,i=m;if(p&&(o=Math.max(Sr,d+e)),w&&(i=Math.max(Nr,m+t)),h){const t=Math.max(Sr,d-e);n=c+d-t,o=t}if(f){const e=Math.max(Nr,m-t);r=u+m-e,i=e}return{x:n,y:r,w:o,h:i}})(e.clientX-i,e.clientY-a),y||(y=requestAnimationFrame(v))},x=()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",x),y&&cancelAnimationFrame(y),v(),o?.(),bn({...Wn.current})};window.addEventListener("pointermove",b),window.addEventListener("pointerup",x)},[]),Mr=he(e=>{if(e.target.closest("button, input, a, kbd, select, textarea"))return;const t={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!t&&"Enter"!==e.key)return;if(e.preventDefault(),e.stopPropagation(),pr(Rt),"Enter"===e.key)return void(In?(Rn(!1),bn(dn())):(Rn(!0),bn(un())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{hr.current||(hr.current={...Wn.current})};if(r<0)return e(),Rn(!0),void bn(un());if(r>0){if(In)return Rn(!1),void bn(dn());if(hr.current){const e=Lr(hr.current);return hr.current=null,Wn.current=e,void bn(e)}return void wr(Rt)}e(),Rn(!1);const t=Tr(n<0?"left":"right");return Wn.current=t,void bn(t)}if(In)return;const o=Wn.current,i=e.shiftKey?{...o,w:Math.max(Sr,o.w+24*n),h:Math.max(Nr,o.h+24*r)}:Lr({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});Wn.current=i,bn(i)},[Rt,In,dn,un]),zr=he(e=>{hr.current||(hr.current={...Wn.current}),Rn(!1);const t=Tr(e);Wn.current=t,bn(t),pr(Rt)},[Rt]),Ar=!q&&!Sn&&!xe,[Ir,Rr]=de(0),Wr=Ar&&!X&&!J&&(!!N||!!L||pt||Mt),Or=Ar&&Ir>0,qr=le(Or);qr.current=Or;const Hr=!!X||!!J,Ur=Hr?"h-(--row-height-compact-bar)":"h-(--row-height-window-bar)",Jr=Ar&&!Hr&&!Or&&!_?"h-(--row-height-window-row)":Ur,_r=he(e=>{const t=e.closest("[data-window-body]");if(!t)return null;const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return Math.abs(n.left-r.left)>2||Math.abs(n.top-r.top)>2?null:(Rr(e=>e+1),()=>Rr(e=>Math.max(0,e-1)))},[]),Zr=ge(()=>Ar?{compact:Hr,over:Or,claim:_r,title:Ke,active:Kt}:null,[Ar,Hr,Or,_r,Ke,Kt]),ro=he(e=>{if(_t)return;e.preventDefault(),e.stopPropagation();const t=0===e.clientX&&0===e.clientY,n=e.currentTarget.getBoundingClientRect();Xe(t?{x:n.left,y:n.bottom+4}:{x:e.clientX,y:e.clientY})},[_t]),oo=!!pe&&Ze&&!q&&!xe,so=Nn||_t?{}:{tabIndex:0,role:"group","aria-label":Ke?`${Ke} — ${$e.windowSuffix}`:$e.windowSuffix,"aria-keyshortcuts":"ArrowUp ArrowDown ArrowLeft ArrowRight Shift+ArrowUp Shift+ArrowDown Shift+ArrowLeft Shift+ArrowRight Control+ArrowUp Control+ArrowDown Control+ArrowLeft Control+ArrowRight Enter",onKeyDown:Mr},lo=()=>{Rn(!0),bn(un())},co=he(()=>{const e=lt.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector(yn);t&&!t.disabled&&t.click()}},[]);ue(()=>{if(!t)return;if(q)return;const e=e=>{if(D[D.length-1]===Rt&&!k(e.target,lt.current)&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),co();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&lt.current?.contains(t)))return;if(t.closest($))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,co,Rt,q]),ue(()=>{if(!t)return;const e=e=>{D[D.length-1]===Rt&&(k(e.target,lt.current)||((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:Rt}})),Ye.current=!1,Be(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:Rt}})))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),ue(()=>{if(!t)return;if(q)return;const e=e=>{if("Escape"===e.key&&D[D.length-1]===Rt){if(ne(e))return e.preventDefault(),void e.stopPropagation();if(Sn&&!P)return;e.preventDefault(),e.stopPropagation(),sr()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,sr,Rt,q,Sn,P]);const uo=t&&(void 0!==y||void 0!==g),[mo]=de(()=>{if("undefined"==typeof document)return null;const e=document.createElement("span");return e.className="flex shrink-0 items-center gap-2",e.setAttribute("data-tab-actions",""),e}),ho=Sn&&!Je?.home&&_n.actions.length>0;ue(()=>{t&&Jn&&function(e,t){const n=an.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.actions===t.actions&&n.menu===t.menu||(an.set(e,t),cn())}(Jn,{title:_n.text||Ke,dirty:Vn,copy:_n.copy,actions:ho&&mo?mo:void 0,menu:or.current??void 0})},[t,Jn,Ke,Vn,_n.text,_n.copy,ho,mo]);const fo=he(e=>{const t=document.getElementById("nav-boundary-toast");t&&t.remove();const n="bottom"===e?["That's the last one, chief.","You've hit rock bottom... of the list.","End of the line, buddy.","Nothing left. Go outside.","Congratulations, you scrolled to the void.","There's no more. I checked.","You've reached the edge of the known universe.","Plot twist: there is no next one.","Even scrolling has limits. Unlike your ambition.","Last one. Time to touch grass."]:["Already at the top. Overachiever.","There is no item above this. Trust me.","You're #1. Literally.","Can't go higher. You've peaked.","This is it. The summit. The top.","First item. No VIP lounge above this.","Going up? Nope. Elevator's broken.","You want negative indexes? Bold.","Top of the list. Top of the world.","The only way is down from here."],r=n[Math.floor(Math.random()*n.length)],o=document.createElement("div");o.id="nav-boundary-toast",o.className="fixed bottom-6 left-1/2 -translate-x-1/2 z-(--z-toast) bg-gray-900 text-on-accent flex min-h-10 items-center px-5 py-3 rounded-lg shadow-lg text-sm font-medium transition-opacity duration-300",o.textContent=r,document.body.appendChild(o),setTimeout(()=>{o.style.opacity="0",setTimeout(()=>o.remove(),300)},2e3)},[]);if(ue(()=>{if(!t)return;const e=e=>{if(D[D.length-1]!==Rt)return;if(k(e.target,lt.current))return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&uo&&(e.preventDefault(),y?y():fo("bottom")),"k"===e.key&&uo&&(e.preventDefault(),g?g():fo("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,y,g,uo,fo,Rt]),!t||mn.current)return null;const po=_t?function(e){if("undefined"==typeof document)return null;const t=Array.from(document.querySelectorAll("[data-modal-panel]")).filter(e=>{const t=e;return!t.hasAttribute("data-utility")&&!t.hasAttribute("data-widget")&&"none"!==t.style.display});t.sort((e,t)=>(e.getAttribute("data-modal-id")||"").localeCompare(t.getAttribute("data-modal-id")||""));const n=t.findIndex(t=>t.getAttribute("data-modal-id")===e),r=t.length;if(n<0||r<1)return null;const o=Math.ceil(Math.sqrt(r)),i=Math.ceil(r/o),a=Math.floor(n/o),s=n%o,l=r-o*(i-1),c=a===i-1&&l<o,u=br(),d=(u.w-20*(o+1))/o,m=(u.h-14*(i+1)-22*i)/i,h=c?(o-l)*(d+20)/2:0;return{x:u.x+20+s*(d+20)+h,y:u.y+14+a*(m+14+22),w:d,h:m}}(Rt):null,wo=_t&&po?Q({width:po.w,height:po.h},{width:vn.w,height:vn.h}):1,yo=(()=>{if(_t&&po){const e=wo,t=vn.w*e,n=vn.h*e,r=po.x+(po.w-t)/2-vn.x,o=po.y+(po.h-n)/2-vn.y,i=Qt||en;return{transform:`translate(${r}px, ${o}px) scale(${e})`,transformOrigin:"top left",transition:"transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 280ms",cursor:"pointer",zIndex:G.expose+(i?20:10),boxShadow:i?"0 24px 72px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.55), 0 0 36px 12px rgba(96,165,250,0.85), 0 0 96px 28px rgba(96,165,250,0.55)":"0 16px 48px rgba(0,0,0,0.55)",pointerEvents:"auto"}}if(tn&&Jt){const e="picked"===on;return{transition:e?"transform 640ms cubic-bezier(0.34, 1.42, 0.64, 1), box-shadow 600ms":"transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 600ms",...e?{zIndex:G.expose+30}:{}}}return null})(),go=E({modal:!1,titleId:!q&&(Sn?!Je?.home:!xe)?je:void 0,label:_n.text||Ke}),vo=kt&&O&&!O.editing?"object"==typeof O.state?/* @__PURE__ */Ee(H,{variant:"secondary",size:"sm","data-modal-edit":"","aria-disabled":!0,disabledReason:O.state.disabledReason,children:$e.edit}):/* @__PURE__ */Ee(H,{variant:"secondary",size:"sm","data-modal-edit":"",onClick:()=>O.onEdit(),children:$e.edit}):null,bo=/* @__PURE__ */ke("div",{children:[
47
+ /* @__PURE__ */ke("div",{ref:lt,"data-modal-panel":!0,"data-modal-id":Rt,"data-window-key":se||void 0,...K?{"data-utility":""}:{},...qe?{"data-pinned-top":""}:{},...q?{"data-widget":""}:{},...Je?{"data-window-owner":Je.key}:{},...Je&&!Nt?{"data-window-root":""}:{},...Sn?{"data-window-tab":""}:{},...go,className:Sn?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(q?Kt?"shadow-xl":"shadow-lg":"border "+(Kt?"shadow-xl border-line":"shadow-lg border-line-strong")),onPointerDown:e=>{if(!qr.current||_t||0!==e.button)return;const t=e.target;if(t.closest("[data-modal-panel]")!==lt.current)return;if(t.closest("[data-window-chrome]"))return;if(t.closest("[data-sidebar-rail]"))return void(t.closest(h)||fr(e));const n=e.currentTarget.getBoundingClientRect(),r=n.height/(e.currentTarget.offsetHeight||n.height),o=(Hr?M.compactBar:M.windowBar)*r;e.clientY-n.top>o||t.closest(h)||fr(e)},onContextMenu:e=>{const t=e.target;t.closest("[data-window-strip]")&&t.closest("[data-modal-panel]")===lt.current&&ro(e)},onMouseDownCapture:e=>{if(ct.current=!1,_t){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),no(Rt),Gr(!1),void pr(Rt)}if(!Kt&&!q&&!qe&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===lt.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),ct.current=!0,Xe(null),pr(Rt),window.addEventListener("mouseup",()=>{setTimeout(()=>{ct.current=!1},0)},{once:!0}))}},onClickCapture:e=>{ct.current&&(ct.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if(_t)return;Xe(null);e.target.closest("[data-modal-panel]")===lt.current&&(e.target.closest("button, input, a, select, textarea")||pr(Rt))},style:xe?{zIndex:$t+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${Se}px)`,transition:Le?"none":"transform 180ms ease-out",...q?{display:"none"}:{},...$t<0?{display:"none"}:{},...Kt||qe||Pe&&se===Pe?{}:{display:"none"},...Wt?{visibility:"hidden",pointerEvents:"none"}:{}}:{zIndex:qe?G.pinnedWindow:$t+1,width:vn.w,height:vn.h,top:vn.y,...q&&"right"===it?{right:window.innerWidth-vn.x-vn.w}:{left:vn.x},...$t<0&&!qe?{display:"none"}:{},...Me?{display:"none"}:{},...Tn||Dn||Wt?{visibility:"hidden",pointerEvents:"none"}:{},...yo??{}},children:[xe&&!q&&/* @__PURE__ */Ee("div",{onPointerDown:De,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),
48
+ /* @__PURE__ */ke("div",{"data-window-surface":"",className:"flex min-h-0 flex-1 flex-col "+(Ar?"backdrop-blur-sm":""),style:Ar?{backgroundColor:Kt?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"}:void 0,children:[q?null:Sn?Je?.home?null:/* @__PURE__ */ke(Ce,{children:[
49
+ /* @__PURE__ */Ee("h2",{id:je,"data-window-title":!0,className:"sr-only",children:_n.text||Ke}),ho&&mo&&V(
50
+ /* @__PURE__ */Ee(Ce,{children:_n.actions}),mo),_n.badges.length>0&&/* @__PURE__ */Ee("div",{"data-window-chrome":"","data-record-bar":"",className:"flex h-9 shrink-0 select-none items-center gap-2 overflow-hidden border-b border-gray-200 px-4",style:{backgroundColor:"rgb(var(--window-content-rgb))"},children:_n.badges})]}):xe?null:
51
+ /* @__PURE__ */ke("div",{onPointerDown:fr,onContextMenu:ro,"data-window-chrome":"",...Or?{"data-window-controls-over":""}:{},...so,className:Or?`absolute left-0 z-10 flex ${Ur} items-center px-3 select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400`:`flex items-center gap-3 ${Jr} px-3 shrink-0 cursor-move select-none focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400`,style:{touchAction:"none",...Or?{top:oo?3:0}:{}},children:[!_t&&/* @__PURE__ */ke("div",{"data-window-controls":"",className:"group/controls flex shrink-0 items-center",children:[
52
+ /* @__PURE__ */Ee("button",{type:"button",onClick:sr,"aria-label":$e.close,title:$e.close,className:xr,children:/* @__PURE__ */Ee("span",{"aria-hidden":"true",className:`${kr} ${Kt?"bg-red-500":"bg-gray-300 group-hover/controls:bg-red-500"}`,children:/* @__PURE__ */Ee(U,{name:"close",className:Er,strokeWidth:3})})}),!X&&/* @__PURE__ */Ee("button",{type:"button",onClick:()=>wr(Rt),"aria-label":$e.minimize,title:$e.minimize,className:xr,children:/* @__PURE__ */Ee("span",{"aria-hidden":"true",className:`${kr} ${Kt?"bg-amber-400":"bg-gray-300 group-hover/controls:bg-amber-400"}`,children:/* @__PURE__ */Ee("span",{className:"h-0.5 w-2 rounded-full bg-current opacity-0 group-hover/controls:opacity-100 group-focus-within/controls:opacity-100"})})}),!X&&/* @__PURE__ */Ee($r,{maximized:In,onToggleMax:()=>{In?(Rn(!1),bn(dn())):lo()},onSnap:zr,buttonClassName:xr,strings:$e,children:/* @__PURE__ */Ee("span",{"aria-hidden":"true",className:`${kr} ${Kt?"bg-green-500":"bg-gray-300 group-hover/controls:bg-green-500"}`,children:/* @__PURE__ */Ee(U,{name:In?"collapse":"expand",className:Er,strokeWidth:3})})}),K&&/* @__PURE__ */Ee("button",{type:"button",onClick:()=>He(e=>!e),"aria-label":qe?$e.unpin:$e.pinOnTop,title:qe?$e.unpin:$e.pinOnTop,className:"ml-1 p-0.5 rounded hover:bg-gray-200 "+(qe?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */Ee(U,{name:"bookmark-square",className:"h-3.5 w-3.5",fill:qe?"currentColor":"none",strokeWidth:1.5})})]}),Or?
53
+ /* @__PURE__ */Ee("h2",{id:je,"data-window-title":!0,className:"sr-only",children:_n.text||Ke}):/* @__PURE__ */Ee("div",{"data-window-title":!0,title:Ke,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:Kt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:/* @__PURE__ */Ee("span",{id:je,className:"truncate",children:_t?gn(Ie):Ie})})]}),oo&&/* @__PURE__ */Ee("div",{"aria-hidden":"true",className:"h-[3px] shrink-0 pointer-events-none",style:{backgroundColor:`rgb(var(--window-accent-rgb) / ${Kt?.9:.55})`}}),
54
+ /* @__PURE__ */Ee(hn.Provider,{value:Rt,children:/* @__PURE__ */Ee(m.Provider,{value:Zr,children:/* @__PURE__ */Ee(I.Provider,{value:{rightRef:dt,leftRef:ht,notify:()=>wt(!0),setEditSlot:Ct,active:Kt,isDirty:Vn,footerOpen:St&&!q&&!X&&!J&&!xe},children:/* @__PURE__ */Ee("div",{ref:ut,"data-window-body":"",...q?{onPointerDown:fr,onContextMenu:e=>{e.preventDefault(),ot({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${q?"p-0 cursor-move":J||_?"p-0":X?"p-2":Ar?"px-4 pb-4":"p-4"} ${q||Sn||Ar?"":"backdrop-blur-sm"} ${!1===x||J||_?"overflow-hidden":"overflow-y-auto overscroll-contain"+(Ar?Wr?" mr-1":" mb-2 mr-1":"")} ${q?"rounded-2xl select-none":""}`,style:{...q?{touchAction:"none"}:{},backgroundColor:q||Ar?"transparent":Sn?"rgb(var(--window-content-rgb))":Kt?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */Ee(Ve,{children:we})})})})}),q&&rt&&/* @__PURE__ */ke(F,{minWidth:160,style:{left:rt.x,top:rt.y},onClose:()=>ot(null),children:[
55
+ /* @__PURE__ */Ee(B,{onClick:()=>{ot(null),window.dispatchEvent(new CustomEvent("widget-open-settings",{detail:Rt}))},children:"Settings"}),
56
+ /* @__PURE__ */Ee(Y,{}),oe&&/* @__PURE__ */ke(Ce,{children:[oe,
57
+ /* @__PURE__ */Ee(Y,{})]}),
58
+ /* @__PURE__ */ke(B,{onClick:()=>{ot(null),He(e=>!e)},children:[
59
+ /* @__PURE__ */Ee("span",{className:"flex-1",children:"Always on Top"}),qe&&/* @__PURE__ */Ee(U,{name:"check",className:"h-4 w-4 text-blue-600 shrink-0",strokeWidth:2})]}),
60
+ /* @__PURE__ */Ee(Y,{}),
61
+ /* @__PURE__ */Ee(B,{onClick:()=>{ot(null),sr()},children:"Close"})]}),
62
+ /* @__PURE__ */ke("div",{onPointerDown:fr,ref:yt,"data-modal-footer":"",...Ar?{"data-modal-footer-bare":""}:{},className:Ar?"h-(--row-height-window-row) px-4 py-1 shrink-0 flex items-center justify-between text-xs select-none cursor-move"+(Wr?"":" hidden"):`px-4 py-2 border-t border-gray-200 shrink-0 flex items-center justify-between text-xs select-none${Sn?"":" cursor-move"}${Kt&&!Sn?" backdrop-blur-sm":""}${q||X||J||xe||!St?" hidden":""}`,style:Ar?{touchAction:"none"}:{touchAction:"none",backgroundColor:Sn?"rgb(var(--window-footer-rgb))":Kt?"rgb(var(--window-footer-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-footer-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
63
+ /* @__PURE__ */ke("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[L,
64
+ /* @__PURE__ */Ee("div",{ref:ht,"data-modal-actions-left":!0,className:"flex items-center gap-2 shrink-0"}),null!=v&&!1!==v&&!Ar&&
65
+ /* @__PURE__ */Ee("div",{ref:gt,"data-modal-footer-facts":"",className:"min-w-0 flex-1 overflow-hidden",children:/* @__PURE__ */Ee("div",{ref:vt,className:"inline-flex items-center gap-2 whitespace-nowrap"+(bt?" invisible":""),children:v})})]}),
66
+ /* @__PURE__ */ke("div",{"data-modal-footer-right":"",className:"flex items-center gap-2 ml-auto shrink-0",children:[kt&&O&&(O.editing?/* @__PURE__ */Ee(H,{variant:"secondary",size:"sm","data-modal-discard":"",onClick:()=>{cr()},children:$e.discard}):Et?V(vo,Et):vo),
67
+ /* @__PURE__ */Ee("div",{ref:dt,"data-modal-actions":!0,className:"flex items-center gap-2"}),N]})]})]}),!q&&!xe&&!_t&&Kt&&!Nn&&/* @__PURE__ */ke(Ce,{children:[
68
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"se"),className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize z-10"}),
69
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"sw"),className:"absolute bottom-0 left-0 w-3 h-3 cursor-nesw-resize z-10"}),
70
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"ne"),className:"absolute top-0 right-0 w-3 h-3 cursor-nesw-resize z-10"}),
71
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"nw"),className:"absolute top-0 left-0 w-3 h-3 cursor-nwse-resize z-10"}),
72
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"n"),className:"absolute top-0 left-3 right-3 h-1 cursor-ns-resize"}),
73
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"s"),className:"absolute bottom-0 left-3 right-3 h-1 cursor-ns-resize"}),
74
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"e"),className:"absolute top-3 bottom-3 right-0 w-1 cursor-ew-resize"}),
75
+ /* @__PURE__ */Ee("div",{onPointerDown:e=>Cr(e,"w"),className:"absolute top-3 bottom-3 left-0 w-1 cursor-ew-resize"})]}),_t&&/* @__PURE__ */Ee("div",{className:"absolute inset-0",style:{zIndex:G.hint,cursor:"pointer",background:"transparent"},onMouseEnter:()=>Zt(!0),onMouseLeave:()=>Zt(!1),onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),pr(Rt),Gr(!1)},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:Qt&&/* @__PURE__ */Ee("button",{type:"button","data-expose-close":!0,"aria-label":We.taskbar.closeWindow,title:"Close",className:"absolute flex items-center justify-center rounded-full bg-black/55 text-on-accent shadow-lg ring-1 ring-white/40 transition-colors hover:bg-red-500",style:{top:8,right:8,width:30,height:30,transform:`scale(${1/wo})`,transformOrigin:"top right",zIndex:G.raised},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:e=>{e.stopPropagation(),e.preventDefault(),sr()},children:/* @__PURE__ */Ee(U,{name:"close",className:"h-4 w-4",strokeWidth:2.2})})})]}),_t&&po&&/* @__PURE__ */Ee("div",{className:"fixed pointer-events-none select-none truncate text-center",style:{left:po.x,top:po.y+po.h+4,width:po.w,zIndex:G.expose+(Qt?21:11),color:"white",fontSize:"var(--text-xs)",fontWeight:500,textShadow:"0 1px 2px rgba(0,0,0,0.6)"},children:gn(Ie)})]}),xo=Ue&&/* @__PURE__ */ke(F,{style:{left:Ue.x,top:Ue.y},onClose:()=>Xe(null),minWidth:160,children:[!q&&!X&&!Sn&&/* @__PURE__ */ke(Ce,{children:[
76
+ /* @__PURE__ */ke(B,{onClick:()=>{wr(Rt),Xe(null)},children:[
77
+ /* @__PURE__ */Ee(U,{name:"remove",className:"h-4 w-4",strokeWidth:1.5}),$e.minimize]}),!Nn&&/* @__PURE__ */ke(B,In?{onClick:()=>{Rn(!1),bn(dn()),Xe(null)},children:[
78
+ /* @__PURE__ */Ee(U,{name:"collapse",className:"h-4 w-4",strokeWidth:1.5}),$e.windowed]}:{onClick:()=>{lo(),Xe(null)},children:[
79
+ /* @__PURE__ */Ee(U,{name:"expand",className:"h-4 w-4",strokeWidth:1.5}),$e.maximize]})]}),K&&!Sn&&/* @__PURE__ */ke(B,{onClick:()=>{He(e=>!e),Xe(null)},children:[
80
+ /* @__PURE__ */Ee(U,{name:"bookmark-square",className:"h-4 w-4 "+(qe?"text-blue-600":""),fill:qe?"currentColor":"none",strokeWidth:1.5}),qe?$e.unpin:$e.pinOnTop]}),Ge&&/* @__PURE__ */ke(B,{onClick:()=>{Xe(null),nt()},children:[
81
+ /* @__PURE__ */Ee(U,{name:"star",className:"h-4 w-4",fill:tt?"currentColor":"none",strokeWidth:1.5}),tt?We.taskbar.removeFromDesktop:We.taskbar.addToDesktop]}),(xn[Rt]||[]).length>0&&/* @__PURE__ */Ee(Ce,{children:(xn[Rt]||[]).map((e,t)=>/* @__PURE__ */ke(B,{onClick:()=>{Xe(null),e.onClick()},children:[e.icon,e.label]},t))}),!(Sn&&Je?.home)&&/* @__PURE__ */ke(Ce,{children:[
82
+ /* @__PURE__ */Ee(Y,{}),
83
+ /* @__PURE__ */ke(B,{danger:!0,onClick:()=>{Xe(null),sr()},children:[
84
+ /* @__PURE__ */Ee(U,{name:"close",className:"h-4 w-4"}),$e.close]})]})]}),ko=!!se&&It.some(e=>e.id===se),Eo=!Ut||ko||q?null:/* @__PURE__ */ke("div",{"data-modal-restore-tab":!0,"data-modal-id":Rt,className:"fixed left-1/2 z-(--z-restore-tab) flex -translate-x-1/2 items-center gap-1 rounded-lg border border-line-strong bg-surface px-2 py-1 shadow-lg",style:{bottom:"calc(var(--taskbar-height, 0px) + 12px)"},children:[
85
+ /* @__PURE__ */Ee("button",{type:"button",onClick:()=>pr(Rt),title:$e.restore,className:"max-w-[16rem] truncate rounded px-2 py-0.5 text-sm font-medium text-gray-700 hover:bg-gray-100 hover:text-gray-900",children:Ke||$e.windowSuffix}),
86
+ /* @__PURE__ */Ee("button",{type:"button",onClick:()=>pr(Rt),title:$e.restore,"aria-label":$e.restore,className:"rounded px-2 py-0.5 text-xs leading-none text-ink-faintest hover:bg-gray-100 hover:text-gray-600",children:"▴"}),
87
+ /* @__PURE__ */Ee("button",{type:"button",onClick:()=>{sr()},title:$e.close,"aria-label":$e.close,className:"rounded px-2 py-0.5 text-xs leading-none text-ink-faintest hover:bg-gray-100 hover:text-gray-600",children:"✕"})]});return V(
88
+ /* @__PURE__ */ke(fn.Provider,{value:null,children:[bo,xo,Eo]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{Hr&&"Escape"===e.key&&(so(null),Gr(!1))});var ho=500,fo=250;function po({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,i]=be(w,y),a=le(/* @__PURE__ */new Map),[s,l]=de(0),c=s>0,[u,d]=de(0),[m,h]=de(0),f=m>0,{hasAnyPerm:p}=L(),b=t&&0===u&&(!(n&&n.length>0)||p(n)),x=le(null),k=le(!1),E=he(()=>{const e={};for(const[t,n]of a.current)e[t]=n.getLast();return e},[]),C=he((e,t)=>{a.current.has(e)||l(e=>e+1),a.current.set(e,t)},[]),M=he(e=>{a.current.delete(e)&&l(e=>e-1)},[]),S=he(e=>{d(t=>t+(e?1:-1))},[]),N=he(e=>{h(t=>t+(e?1:-1))},[]),z=ae(ee),T=z?.claimReadOnly;ue(()=>{if(T&&!b)return T(!0),()=>T(!1)},[T,b]);const A=le({last:0,count:0,tripped:!1}),D=le(!1),P=he((e,t,n)=>{if(k.current)return void(n&&g(n.prev,n.next)||(D.current=!0));if(!b||x.current)return;const r=A.current;if(r.tripped)return;const o=Date.now();if(o-r.last>fo&&(r.count=0),r.last=o,++r.count>ho)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${ho} undo steps with no pause between them, which no user action can do. The value passed to useUndoable for this slice is almost certainly rebuilt on every render (a .map/.filter/object literal in the call) rather than held in state, so it reads as changed every time — and since recording a step re-renders the form, that is a loop. Undo recording is now off for this form to keep the tab responsive.`);x.current={values:E(),label:e,coalesceKey:t},queueMicrotask(()=>{const e=x.current;x.current=null,e&&i({type:"record",step:e})})},[b,E]),I=he(e=>{for(const[t,n]of Object.entries(e)){const e=a.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),R=he(()=>{const e=o.past[o.past.length-1];if(!e)return;const t={values:E(),label:e.label,coalesceKey:null};I(e.values),i({type:"undo",redoStep:t})},[o.past,E,I]),W=he(()=>{const e=o.future[0];if(!e)return;const t={values:E(),label:e.label,coalesceKey:null};I(e.values),i({type:"redo",undoStep:t})},[o.future,E,I]),[$,O]=de(0),K=le(0),j=le(0),F=le(!1),B=he(()=>{k.current=!0,D.current=!1,x.current=null,K.current+=1,j.current=K.current,O(K.current)},[]),Y=le(void 0),q=he(e=>{void 0!==e&&(void 0!==Y.current&&e!==Y.current&&(F.current=!0),Y.current=e),B()},[B]);ue(()=>{k.current&&$===j.current&&(k.current=!1,x.current=null,(D.current||F.current)&&i({type:"clear"}),D.current=!1,F.current=!1)},[$]);const H=he(()=>{F.current=!0,i({type:"clear"}),B()},[B]),U=b&&o.past.length>0,X=b&&o.future.length>0,V=qr(r),G=le([]),J=le({undo:R,redo:W,canUndo:U,canRedo:X});J.current={undo:R,redo:W,canUndo:U,canRedo:X};const _=le(b);_.current=b;const Q=he(e=>{if(!_.current)return;const t=v(e);if(!t)return;const n=G.current[G.current.length-1],r=n?{undo:n.undo,redo:n.redo,canUndo:n.canUndo(),canRedo:n.canRedo()}:J.current;("undo"===t?r.canUndo:r.canRedo)&&(e.preventDefault(),"undo"===t?r.undo():r.redo())},[]);ue(()=>{if(V&&b)return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[V,b,Q]);const Z=he(e=>(G.current=[...G.current,e],()=>{G.current=G.current.filter(t=>t!==e)}),[]),te=he(e=>{const t=e=>Q(e);return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)},[Q]),ne=ge(()=>({register:C,unregister:M,record:P,undo:R,redo:W,clear:H,baseline:q,canUndo:U,canRedo:X,enabled:b,hasState:c,claimReadOnly:S,declaredEditable:f,claimEditable:N,addSource:Z,bindKeys:te,undoLabel:U?o.past[o.past.length-1].label:null,redoLabel:X?o.future[0].label:null}),[C,M,P,R,W,H,q,U,X,b,c,S,f,N,Z,te,o.past,o.future]);/* @__PURE__ */
89
+ return Ee(ee.Provider,{value:ne,children:e})}function wo(){const e=ae(ee),t=he(()=>{},[]);return{undo:e?.undo??t,redo:e?.redo??t,clear:e?.clear??t,baseline:e?.baseline??t,canUndo:e?.canUndo??!1,canRedo:e?.canRedo??!1,undoLabel:e?.undoLabel??null,redoLabel:e?.redoLabel??null,enabled:e?.enabled??!1,hasState:e?.hasState??!1}}function yo(e){const t=ae(ee),n=t?.claimReadOnly,r=t?.claimEditable;ue(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}export{zn as CancelButton,We as DesktopHostProvider,yt as DocFavStar,it as EntityWindowFallback,rt as EntityWindowLoading,at as EntityWindowState,yn as MODAL_SUBMIT_SELECTOR,mo as Modal,Ln as ModalActions,Nn as ModalMoreActions,po as UndoProvider,De as WINDOW_REGISTRY,Xe as WindowCrashedFallback,Sn as WindowEditSlot,Ve as WindowErrorBoundary,Ot as WindowManagerProvider,En as WindowTitle,Et as activateWindowById,_t as beginWindowGesture,dr as cancelWindowFront,Ie as client_default,lo as commitExposeHighlight,ur as confirmWindowDiscard,Qt as drainPerfEvents,_r as exitExposeMode,Fn as forgetMaximizedWindowBoxes,St as getActiveWindowRoute,ao as getExposeHighlight,mn as getWindowChromeVersion,Kn as getWindowPosition,lt as isDraftEntityId,ct as isDraftEntityWindow,ze as isEntityEntry,Le as isPageEntry,Pe as isShellApiClientConfigured,Ze as isTabWindow,Jt as markMenuOpen,un as readWindowChrome,sr as requestWindowFront,so as setExposeHighlight,Gt as setPerfCollecting,Be as setShellHomeRoute,Ue as setShellTabStrip,Ae as setShellWindowRegistry,On as setWindowDefaultPosition,jn as setWindowPosition,rn as splitTitle,io as subscribeExposeHighlight,dn as subscribeWindowChrome,et as tabGroupOf,Jr as toggleExposeMode,rr as useCurrentTabKey,$e as useDesktopHost,Mn as useEnclosingModalId,qr as useIsActiveWindow,Ke as usePageSearch,wo as useUndo,yo as useUndoCanEdit,bn as useWidgetSettings,mt as useWindowDirty,ft as useWindowManager,kn as useWindowMenuItem,Cn as useWindowTitle,cr as windowHoldsChanges};
@@ -0,0 +1 @@
1
+ import{UndoContext as e}from"./chunk-3AUPCKBR.js";import{useContext as r,useId as t,useRef as c,useEffect as n,useState as u}from"react";function o(u,o,s){const l=r(e),a=t(),i=c(u),p=c(o);p.current=o,n(()=>{if(l)return l.register(a,{getLast:()=>i.current,setLast:e=>{i.current=e},apply:e=>p.current(e)}),()=>l.unregister(a)},[l,a]);const{label:b,coalesceKey:f=null}=s,y=c(l);y.current=l;const K=c({label:b,coalesceKey:f});K.current={label:b,coalesceKey:f},n(()=>{const e=y.current;e&&(Object.is(u,i.current)||(e.record(K.current.label,K.current.coalesceKey,{prev:i.current,next:u}),i.current=u))},[u])}function s(e,r){const[t,c]=u(e);return o(t,e=>c(()=>e),r),[t,c]}export{o as useUndoable,s as useUndoableState};
@@ -1,8 +1,8 @@
1
- import{SearchableSelect as e}from"./chunk-DVKOVZJ2.js";import{labelClasses as a}from"./chunk-EQKUFYX6.js";import{Select_default as l}from"./chunk-W7HTHKN2.js";import{isSafeLinkHref as t}from"./chunk-Z5TE3MEG.js";import{Input_default as r}from"./chunk-D7MRZZVV.js";import{INPUT_SIZES as n}from"./chunk-AYZY3YNC.js";import{Button_default as i}from"./chunk-A4ROXNUF.js";import{Icon as o}from"./chunk-ISVODSRP.js";import{registerModalEscapeInterceptor as s}from"./chunk-TWVUQUUD.js";import{useShellStrings as u}from"./chunk-NRHG4R2Q.js";import{useId as d,useRef as c,useState as p,useEffect as m}from"react";import{jsx as f,jsxs as v,Fragment as g}from"react/jsx-runtime";function h(e){return"select"===e.type?e.options:"groups"===e.type?e.groups.flatMap(e=>e.options):[]}var b="address",x={kindOf:()=>b,targetOf:e=>e,readFilter:()=>null,withFilter:e=>e},k=e=>t(e.trim());function y(t){const{value:n,kinds:o,rules:y=x,filtersFor:w,label:N,readOnly:C,placeholder:O,className:F="",tidyAddress:j,addressAddon:E}=t,$=void 0!==t.onApply,A=u().link,D=y.isSafe??k,R=d(),T=c(null),z=c(null),[V,K]=p({url:n}),U=$?V.url:n,[Z,H]=p(!1),[M,P]=p(null),[S,W]=p(null),[Y,Q]=p(!1),B=c(null),G=c(()=>{});G.current=$?t.onCancel:()=>{},m(()=>{if($)return s(e=>{const a=T.current;return!!("Escape"===e.key&&a&&e.target instanceof Node&&a.contains(e.target))&&(G.current(),!0)},()=>T.current)},[$]),m(()=>{if(!$)return;const e=z.current;e?(e.focus(),e.select()):T.current?.querySelector("button, input")?.focus()},[]);const L=o??[{value:b,label:A.address,target:{type:"text"}}],X=M&&M.against===U?M.kind:y.kindOf(U),q=L.filter(e=>!e.hideWhenEmpty||h(e.target).length>0||e.value===X),I=q.find(e=>"text"===e.target.type),J=q.find(e=>e.value===X)??I??q[0];if(!J)return null;const _="text"!==J.target.type,ee=_?y.targetOf(U):U,ae=h(J.target),le=ae.find(e=>e.value===ee),te=e=>({value:e,label:A.unavailable(e)}),re="select"===J.target.type&&ee&&w?w(ee):null,ne=re?y.readFilter(U):null,ie=ne?re?.find(e=>e.param===ne.param):void 0,oe=S&&S.against===U?S.text:U,se=_?U:j?j(oe.trim()).trim():oe.trim(),ue=$&&j?se:oe,de=!_&&""!==ue.trim()&&!D(ue),ce=de&&(!$||Z);_&&Y&&Q(!1);const pe=(e,a)=>{$?K({url:e,name:a}):void 0===a?t.onChange(e):t.onChange(e,a)},me=(e,a)=>{P(a=>a?{...a,against:e}:a),pe(e,a)},fe=e=>{if(!e)return me("");const a=ae.find(a=>a.value===e);me(e,a?.label)},ve=e=>{H(!1);const a=e.trim();a?D(e)?(W({text:e,against:a}),me(a)):W({text:e,against:U}):(W({text:e,against:""}),me(""))},ge=e=>{const a=e.relatedTarget;if(a&&(a===z.current||B.current?.contains(a)))return;if(Q(!1),$||!j||C)return;const l=j(oe.trim());l.trim()!==oe.trim()&&ve(l)},he=()=>{if(!$||!se)return;if(!_&&de)return void H(!0);const e=_&&V.url===se?V.name:void 0,a=t.onApply;void 0===e?a(se):a(se,e)},be=(e,a)=>a&&!e.some(e=>e.value===a)?[te(a),...e]:[...e],xe=(a,t,r,n,i)=>{const o=[];for(const e of r){const a=o[o.length-1],l={value:e.value,label:e.label};e.group?a&&"options"in a&&a.label===e.group?a.options.push(l):o.push({label:e.group,options:[l]}):o.push(l)}if(i){const l=r.some(e=>""===e.value);/* @__PURE__ */
2
- return f(e,{"aria-label":a,value:t,options:o,disabled:C,clearable:l,placeholder:r.find(e=>""===e.value)?.label,onChange:n})}/* @__PURE__ */
3
- return f(l,{size:"sm","aria-label":a,value:t,options:o,readOnly:C,onChange:n})};let ke;if("text"===J.target.type)ke=/* @__PURE__ */f(r,{ref:z,id:`${R}-address`,size:"sm",type:"text",invalid:ce,"aria-label":A.address,"aria-describedby":ce?`${R}-why`:void 0,placeholder:O??A.addressPlaceholder,spellCheck:!1,autoComplete:"off",value:oe,readOnly:C,onChange:e=>ve(e.target.value),onFocus:()=>Q(!0),onBlur:ge,onKeyDown:j&&!$?e=>{"Enter"===e.key&&e.currentTarget.blur()}:void 0});else{const e="groups"===J.target.type?J.target.groups.flatMap(e=>e.options.map(a=>({value:a.value,label:a.label,group:e.label}))):J.target.options.map(e=>({value:e.value,label:e.label})),a=[{value:"",label:J.target.placeholder},...be(e,ee)];ke=xe(J.label,ee,a,fe,e.length>10)}const ye=/* @__PURE__ */v(g,{children:[o&&xe(A.linkType,J.value,q.map(e=>({value:e.value,label:e.label})),e=>{W(null),H(!1);const a=q.find(a=>a.value===e);if(!a||"text"===a.target.type)return void P({kind:e,against:U});const l=h(a.target)[0];P({kind:e,against:l?l.value:""}),l?pe(l.value,l.label):pe("")},!1),ke,E&&Y&&!C&&"text"===J.target.type&&/* @__PURE__ */f("div",{ref:B,onBlur:ge,children:E({url:oe,onChange:ve})}),re&&xe(A.filter,ne?.param??"",[{value:"",label:A.noFilter},...ne&&!ie?[te(ne.param)]:[],...re.map(e=>({value:e.param,label:e.label}))],e=>{if(!e)return me(ee,le?.label);const a=re?.find(a=>a.param===e),l=a?.values[0];l&&me(y.withFilter(ee,{param:e,value:l.value}),l.label)},!1),re&&ne&&xe(A.value,ne.value,be((ie?.values??[]).map(e=>({value:e.value,label:e.label})),ne.value),e=>{if(!ne)return;const a=ie?.values.find(a=>a.value===e);me(y.withFilter(ee,{param:ne.param,value:e}),a?.label)},(ie?.values.length??0)>10),ce&&/* @__PURE__ */f("p",{id:`${R}-why`,role:"alert",className:"text-2xs leading-4 text-red-600",children:A.unsafe}),J.hint&&/* @__PURE__ */f("p",{className:"text-2xs leading-4 text-ink-faintest",children:J.hint}),re&&/* @__PURE__ */f("p",{className:"text-2xs leading-4 text-ink-faintest",children:A.filterHint})]});if(!$)/* @__PURE__ */
1
+ import{SearchableSelect as e}from"./chunk-DVKOVZJ2.js";import{Select_default as a}from"./chunk-W7HTHKN2.js";import{labelClasses as l}from"./chunk-EQKUFYX6.js";import{isSafeLinkHref as t}from"./chunk-Z5TE3MEG.js";import{Input_default as r}from"./chunk-D7MRZZVV.js";import{INPUT_SIZES as n}from"./chunk-AYZY3YNC.js";import{Button_default as i}from"./chunk-A4ROXNUF.js";import{Icon as o}from"./chunk-ISVODSRP.js";import{registerModalEscapeInterceptor as s}from"./chunk-TWVUQUUD.js";import{useShellStrings as u}from"./chunk-NRHG4R2Q.js";import{useId as d,useRef as c,useState as p,useEffect as m}from"react";import{jsx as f,jsxs as v,Fragment as g}from"react/jsx-runtime";function h(e){return"select"===e.type?e.options:"groups"===e.type?e.groups.flatMap(e=>e.options):[]}var b="address",x={kindOf:()=>b,targetOf:e=>e,readFilter:()=>null,withFilter:e=>e},k=e=>t(e.trim());function y(t){const{value:n,kinds:o,rules:y=x,filtersFor:w,label:N,readOnly:C,placeholder:O,className:F="",tidyAddress:j,addressAddon:E}=t,$=void 0!==t.onApply,A=u().link,D=y.isSafe??k,R=d(),T=c(null),z=c(null),[V,K]=p({url:n}),U=$?V.url:n,[Z,H]=p(!1),[M,P]=p(null),[S,W]=p(null),[Y,Q]=p(!1),B=c(null),G=c(()=>{});G.current=$?t.onCancel:()=>{},m(()=>{if($)return s(e=>{const a=T.current;return!!("Escape"===e.key&&a&&e.target instanceof Node&&a.contains(e.target))&&(G.current(),!0)},()=>T.current)},[$]),m(()=>{if(!$)return;const e=z.current;e?(e.focus(),e.select()):T.current?.querySelector("button, input")?.focus()},[]);const L=o??[{value:b,label:A.address,target:{type:"text"}}],X=M&&M.against===U?M.kind:y.kindOf(U),q=L.filter(e=>!e.hideWhenEmpty||h(e.target).length>0||e.value===X),I=q.find(e=>"text"===e.target.type),J=q.find(e=>e.value===X)??I??q[0];if(!J)return null;const _="text"!==J.target.type,ee=_?y.targetOf(U):U,ae=h(J.target),le=ae.find(e=>e.value===ee),te=e=>({value:e,label:A.unavailable(e)}),re="select"===J.target.type&&ee&&w?w(ee):null,ne=re?y.readFilter(U):null,ie=ne?re?.find(e=>e.param===ne.param):void 0,oe=S&&S.against===U?S.text:U,se=_?U:j?j(oe.trim()).trim():oe.trim(),ue=$&&j?se:oe,de=!_&&""!==ue.trim()&&!D(ue),ce=de&&(!$||Z);_&&Y&&Q(!1);const pe=(e,a)=>{$?K({url:e,name:a}):void 0===a?t.onChange(e):t.onChange(e,a)},me=(e,a)=>{P(a=>a?{...a,against:e}:a),pe(e,a)},fe=e=>{if(!e)return me("");const a=ae.find(a=>a.value===e);me(e,a?.label)},ve=e=>{H(!1);const a=e.trim();a?D(e)?(W({text:e,against:a}),me(a)):W({text:e,against:U}):(W({text:e,against:""}),me(""))},ge=e=>{const a=e.relatedTarget;if(a&&(a===z.current||B.current?.contains(a)))return;if(Q(!1),$||!j||C)return;const l=j(oe.trim());l.trim()!==oe.trim()&&ve(l)},he=()=>{if(!$||!se)return;if(!_&&de)return void H(!0);const e=_&&V.url===se?V.name:void 0,a=t.onApply;void 0===e?a(se):a(se,e)},be=(e,a)=>a&&!e.some(e=>e.value===a)?[te(a),...e]:[...e],xe=(l,t,r,n,i)=>{const o=[];for(const e of r){const a=o[o.length-1],l={value:e.value,label:e.label};e.group?a&&"options"in a&&a.label===e.group?a.options.push(l):o.push({label:e.group,options:[l]}):o.push(l)}if(i){const a=r.some(e=>""===e.value);/* @__PURE__ */
2
+ return f(e,{"aria-label":l,value:t,options:o,disabled:C,clearable:a,placeholder:r.find(e=>""===e.value)?.label,onChange:n})}/* @__PURE__ */
3
+ return f(a,{size:"sm","aria-label":l,value:t,options:o,readOnly:C,onChange:n})};let ke;if("text"===J.target.type)ke=/* @__PURE__ */f(r,{ref:z,id:`${R}-address`,size:"sm",type:"text",invalid:ce,"aria-label":A.address,"aria-describedby":ce?`${R}-why`:void 0,placeholder:O??A.addressPlaceholder,spellCheck:!1,autoComplete:"off",value:oe,readOnly:C,onChange:e=>ve(e.target.value),onFocus:()=>Q(!0),onBlur:ge,onKeyDown:j&&!$?e=>{"Enter"===e.key&&e.currentTarget.blur()}:void 0});else{const e="groups"===J.target.type?J.target.groups.flatMap(e=>e.options.map(a=>({value:a.value,label:a.label,group:e.label}))):J.target.options.map(e=>({value:e.value,label:e.label})),a=[{value:"",label:J.target.placeholder},...be(e,ee)];ke=xe(J.label,ee,a,fe,e.length>10)}const ye=/* @__PURE__ */v(g,{children:[o&&xe(A.linkType,J.value,q.map(e=>({value:e.value,label:e.label})),e=>{W(null),H(!1);const a=q.find(a=>a.value===e);if(!a||"text"===a.target.type)return void P({kind:e,against:U});const l=h(a.target)[0];P({kind:e,against:l?l.value:""}),l?pe(l.value,l.label):pe("")},!1),ke,E&&Y&&!C&&"text"===J.target.type&&/* @__PURE__ */f("div",{ref:B,onBlur:ge,children:E({url:oe,onChange:ve})}),re&&xe(A.filter,ne?.param??"",[{value:"",label:A.noFilter},...ne&&!ie?[te(ne.param)]:[],...re.map(e=>({value:e.param,label:e.label}))],e=>{if(!e)return me(ee,le?.label);const a=re?.find(a=>a.param===e),l=a?.values[0];l&&me(y.withFilter(ee,{param:e,value:l.value}),l.label)},!1),re&&ne&&xe(A.value,ne.value,be((ie?.values??[]).map(e=>({value:e.value,label:e.label})),ne.value),e=>{if(!ne)return;const a=ie?.values.find(a=>a.value===e);me(y.withFilter(ee,{param:ne.param,value:e}),a?.label)},(ie?.values.length??0)>10),ce&&/* @__PURE__ */f("p",{id:`${R}-why`,role:"alert",className:"text-2xs leading-4 text-red-600",children:A.unsafe}),J.hint&&/* @__PURE__ */f("p",{className:"text-2xs leading-4 text-ink-faintest",children:J.hint}),re&&/* @__PURE__ */f("p",{className:"text-2xs leading-4 text-ink-faintest",children:A.filterHint})]});if(!$)/* @__PURE__ */
4
4
  return f("div",{ref:T,className:`flex min-w-0 flex-auto flex-col gap-2 ${F}`.trim(),role:N?"group":void 0,"aria-label":N,children:ye});const we=t.onRemove;/* @__PURE__ */
5
- return v("div",{ref:T,role:"dialog","aria-label":N??A.title,className:`flex min-w-0 flex-col gap-2 rounded-xl border border-line bg-surface p-3 shadow-lg ${F}`.trim(),onKeyDown:e=>{"Enter"!==e.key||e.defaultPrevented||e.target instanceof Element&&e.target.closest("button")||(e.preventDefault(),he())},children:[_?/* @__PURE__ */f("span",{className:a({inline:!0}),children:A.title}):/* @__PURE__ */f("label",{htmlFor:`${R}-address`,className:a({inline:!0}),children:A.title}),ye,
5
+ return v("div",{ref:T,role:"dialog","aria-label":N??A.title,className:`flex min-w-0 flex-col gap-2 rounded-xl border border-line bg-surface p-3 shadow-lg ${F}`.trim(),onKeyDown:e=>{"Enter"!==e.key||e.defaultPrevented||e.target instanceof Element&&e.target.closest("button")||(e.preventDefault(),he())},children:[_?/* @__PURE__ */f("span",{className:l({inline:!0}),children:A.title}):/* @__PURE__ */f("label",{htmlFor:`${R}-address`,className:l({inline:!0}),children:A.title}),ye,
6
6
  /* @__PURE__ */v("div",{className:"flex items-center justify-between gap-2",children:[we?/* @__PURE__ */f(i,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onClick:we,children:A.remove}):null,
7
7
  /* @__PURE__ */v("span",{className:"ml-auto flex gap-1",children:[
8
8
  /* @__PURE__ */f(i,{variant:"secondary",size:"sm","data-window-action":"cancel",onClick:()=>G.current(),children:A.cancel}),
@@ -1,4 +1,4 @@
1
- import{Modal as e}from"./chunk-XRWUNOI3.js";import{keepsNativeMenu as a}from"./chunk-5QFPTDQF.js";import{jsx as i,jsxs as n}from"react/jsx-runtime";var t={activeOpacity:70,inactiveOpacity:50,activeBlur:0,inactiveBlur:0};function r(e){try{const a=JSON.parse(localStorage.getItem(e)||"");return null!=a.blur&&null==a.activeBlur&&(a.activeBlur=a.blur,a.inactiveBlur=a.blur,delete a.blur),{...t,...a}}catch{return t}}function l({open:t,onClose:r,title:l,appearance:c,onAppearanceChange:s,onSave:d,children:o}){if(!t)return null;const u="w-full h-1.5 rounded-full appearance-none bg-gray-200 cursor-pointer accent-blue-500",p="flex items-center justify-between text-xs text-gray-500";/* @__PURE__ */
1
+ import{Modal as e}from"./chunk-GD5NGS6D.js";import{keepsNativeMenu as a}from"./chunk-5QFPTDQF.js";import{jsx as i,jsxs as n}from"react/jsx-runtime";var t={activeOpacity:70,inactiveOpacity:50,activeBlur:0,inactiveBlur:0};function r(e){try{const a=JSON.parse(localStorage.getItem(e)||"");return null!=a.blur&&null==a.activeBlur&&(a.activeBlur=a.blur,a.inactiveBlur=a.blur,delete a.blur),{...t,...a}}catch{return t}}function l({open:t,onClose:r,title:l,appearance:c,onAppearanceChange:s,onSave:d,children:o}){if(!t)return null;const u="w-full h-1.5 rounded-full appearance-none bg-gray-200 cursor-pointer accent-blue-500",p="flex items-center justify-between text-xs text-gray-500";/* @__PURE__ */
2
2
  return i("div",{onPointerDown:e=>e.stopPropagation(),onContextMenu:e=>{e.stopPropagation(),a(e.target)||e.preventDefault()},children:/* @__PURE__ */i(e,{open:t,onClose:r,title:l,size:"sm",children:/* @__PURE__ */n("div",{className:"space-y-4",children:[o,
3
3
  /* @__PURE__ */n("div",{children:[
4
4
  /* @__PURE__ */i("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"Appearance"}),