efficient-shell 7.25.0 → 7.26.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 (62) hide show
  1. package/dist/{Browser-BYTQJJAO.js → Browser-3FDTXKE5.js} +14 -14
  2. package/dist/{Calculator-S4SULQZG.js → Calculator-HARXMYLM.js} +11 -11
  3. package/dist/ConfirmDialog-VL3YU35U.js +1 -0
  4. package/dist/{CurrencyConverter-6A5U4LH3.js → CurrencyConverter-KQ5UR4AU.js} +9 -9
  5. package/dist/{Documents-TTGR4W4W.js → Documents-WUZBS5SD.js} +27 -27
  6. package/dist/{Files-JOBA7MKL.js → Files-363VK5RY.js} +20 -20
  7. package/dist/{Notepad-LV3UNTYY.js → Notepad-PJUJ5VF2.js} +10 -10
  8. package/dist/PdfViewer-4KFBJ4ZV.js +1 -0
  9. package/dist/{PomodoroTimer-66WV5HAK.js → PomodoroTimer-BMBZ2TTC.js} +32 -32
  10. package/dist/{Preview-V562VG6J.js → Preview-KXLUDKH2.js} +8 -8
  11. package/dist/Sidebar-GO32NHGH.js +44 -0
  12. package/dist/{Spreadsheet-WY252FYX.js → Spreadsheet-XPLYPDLZ.js} +13 -13
  13. package/dist/{Stock-EC62JSPA.js → Stock-4LFU53UL.js} +3 -3
  14. package/dist/{Weather-VHHULAGC.js → Weather-BIOZMSPH.js} +18 -18
  15. package/dist/{WorldClock-AM54TQZB.js → WorldClock-BO6TIFOK.js} +4 -4
  16. package/dist/apps/index.js +1 -1
  17. package/dist/bin/ui-check.js +1 -1
  18. package/dist/brand.css +1 -1
  19. package/dist/{chunk-WGUFMSMA.js → chunk-2I3Z4UFG.js} +28 -28
  20. package/dist/{chunk-2CD2LZHH.js → chunk-42B7TUEB.js} +1 -1
  21. package/dist/{chunk-6A2D6H7Z.js → chunk-56UKP6J6.js} +1 -1
  22. package/dist/{chunk-5SKXAWAU.js → chunk-5MBF4FPG.js} +1 -1
  23. package/dist/{chunk-H3S7GHXR.js → chunk-6AXCLPSI.js} +1 -1
  24. package/dist/{chunk-C3CWQVGM.js → chunk-6JVUT3D4.js} +2 -2
  25. package/dist/{chunk-75BDNIYU.js → chunk-6RFXIPCN.js} +1 -1
  26. package/dist/chunk-C2PGWIIO.js +1 -0
  27. package/dist/{chunk-D5CGXUQK.js → chunk-CV3XVHWR.js} +45 -45
  28. package/dist/chunk-DBWGMZCY.js +1 -0
  29. package/dist/{chunk-JI2JL7ZQ.js → chunk-DY43MKMT.js} +1 -1
  30. package/dist/{chunk-U5H3Q5JM.js → chunk-F2GDJO2Y.js} +17 -17
  31. package/dist/{chunk-MUDY7BV4.js → chunk-H3U47ZEL.js} +8 -8
  32. package/dist/{chunk-AW7GP54G.js → chunk-LG3UEPOI.js} +3 -3
  33. package/dist/{chunk-ISN4DJJ7.js → chunk-MEIVZG77.js} +9 -9
  34. package/dist/{chunk-ISEM2MNY.js → chunk-OICSZKUO.js} +1 -1
  35. package/dist/{chunk-YJRAJD27.js → chunk-QD22TNW3.js} +8 -8
  36. package/dist/{chunk-ODGCVNYP.js → chunk-QKNGN4H4.js} +3 -3
  37. package/dist/{chunk-R3IJQGAB.js → chunk-RMXUKHVK.js} +1 -1
  38. package/dist/chunk-SKDIIPFY.js +1 -0
  39. package/dist/{chunk-5WYTOXIO.js → chunk-VROJD5KW.js} +486 -485
  40. package/dist/{chunk-SRQXRDTA.js → chunk-YJZ4VVDT.js} +11 -11
  41. package/dist/{chunk-UQOFRZMX.js → chunk-ZXHA3XDM.js} +1 -1
  42. package/dist/file-intake/index.js +1 -1
  43. package/dist/i18n/index.d.ts +1 -1
  44. package/dist/{index-Bz_SKBsS.d.ts → index-cfVn8e67.d.ts} +57 -6
  45. package/dist/index.d.ts +3 -3
  46. package/dist/index.js +631 -631
  47. package/dist/locales/zh-Hans.d.ts +1 -1
  48. package/dist/locales/zh-Hans.js +1 -1
  49. package/dist/map/index.js +7 -7
  50. package/dist/page-tabs/index.js +5 -5
  51. package/dist/pdf/index.js +1 -1
  52. package/dist/{strings-D9AIYTbE.d.ts → strings-DkffgGGm.d.ts} +12 -0
  53. package/dist/telemetry/index.js +1 -1
  54. package/dist/ui/index.d.ts +2 -2
  55. package/dist/ui/index.js +1 -1
  56. package/package.json +1 -1
  57. package/dist/ConfirmDialog-TGAPFTMU.js +0 -1
  58. package/dist/PdfViewer-BPQHIBZ7.js +0 -1
  59. package/dist/Sidebar-PU6MUQEQ.js +0 -44
  60. package/dist/chunk-6CC3IJ7Y.js +0 -1
  61. package/dist/chunk-BSCGC2HA.js +0 -1
  62. package/dist/chunk-DCXQZ4BR.js +0 -1
@@ -1,4 +1,4 @@
1
- import{computeMaximizedBox as e,isSidebarStripReserved as t,boxFillsWorkArea as n,readAlwaysMaximizedFlag as r,WORK_AREA_CHANGED_EVENT as o,useShellAuth as i,scrollerIsFluid as a,growBoxToWidth as s,widthToFit as l,navIcons as c}from"./chunk-DSSLOQDW.js";import{CopyButton as d}from"./chunk-JI2JL7ZQ.js";import{isStaleChunkError as u,CMD_Z as h,CMD_SHIFT_Z as m,Result as p,useIsMobile as f,useShellPrefs as w}from"./chunk-ODGCVNYP.js";import{LoadingSpinner as y}from"./chunk-NVFKXL52.js";import{Button_default as g}from"./chunk-SZTKBF3D.js";import{confirm as b,dialogA11y as v}from"./chunk-U5H3Q5JM.js";import{PopupMenu as x,PopupMenuItem as k,PopupMenuDivider as E,PopupMenuLabel as C}from"./chunk-GNW45MGV.js";import{Z_LAYERS as M,runEscapeInterceptors as N}from"./chunk-FIEA5CGB.js";import{reportBoundaryError as S}from"./chunk-KNUR2UEG.js";import{useShellStrings as L}from"./chunk-BSCGC2HA.js";import{Icon as T}from"./chunk-B427NVDP.js";import{createContext as z,useContext as A,Component as D,useLayoutEffect as P,useRef as I,useEffect as $,useState as K,useSyncExternalStore as W,useCallback as O,isValidElement as R,Fragment as F,Children as q,cloneElement as j,useMemo as B,useId as H,useReducer as U,Suspense as Y}from"react";import{jsxs as X,jsx as V,Fragment as _}from"react/jsx-runtime";import{createPortal as J}from"react-dom";import{useLocation as G}from"react-router-dom";import{useQueryClient as Q,useQuery as Z}from"@tanstack/react-query";function ee(e){return"component"in e}function te(e){return"endpoint"in e}var ne={};function re(e){ne=e}var oe=new Proxy({},{get:(e,t)=>ne[t],has:(e,t)=>t in ne,ownKeys:()=>Object.keys(ne),getOwnPropertyDescriptor(e,t){if(t in ne)return{configurable:!0,enumerable:!0,value:ne[t]}}}),ie=null;function ae(e){ie=e}function se(){return null!==ie}var le=/* @__PURE__ */new Set(["get","post","put","patch","delete","head","options","request"]),ce=new Proxy({},{get:(e,t)=>ie?ie[t]:"string"==typeof t&&le.has(t)?()=>Promise.resolve({data:null,status:0,statusText:"",headers:{},config:{}}):void 0}),de=z(null);function ue(){return A(de)?.pageSearch??""}var he=null,me=/* @__PURE__ */new Set;function pe(e){he!==e&&(he=e,me.forEach(e=>e()))}function fe(){return he}function we(e){return me.add(e),()=>{me.delete(e)}}function ye({error:e,onReload:t}){const n=u(e);/* @__PURE__ */
1
+ import{computeMaximizedBox as e,isSidebarStripReserved as t,boxFillsWorkArea as n,readAlwaysMaximizedFlag as r,WORK_AREA_CHANGED_EVENT as o,useShellAuth as i,scrollerIsFluid as a,growBoxToWidth as s,widthToFit as l,navIcons as c}from"./chunk-DSSLOQDW.js";import{CopyButton as d}from"./chunk-DY43MKMT.js";import{isStaleChunkError as u,CMD_Z as h,CMD_SHIFT_Z as m,Result as p,useIsMobile as f,useShellPrefs as w}from"./chunk-QKNGN4H4.js";import{LoadingSpinner as y}from"./chunk-NVFKXL52.js";import{Button_default as g}from"./chunk-SZTKBF3D.js";import{confirm as b,dialogA11y as v}from"./chunk-F2GDJO2Y.js";import{PopupMenu as x,PopupMenuItem as k,PopupMenuDivider as E,PopupMenuLabel as C}from"./chunk-GNW45MGV.js";import{Z_LAYERS as M,runEscapeInterceptors as N}from"./chunk-FIEA5CGB.js";import{reportBoundaryError as S}from"./chunk-KNUR2UEG.js";import{useShellStrings as L}from"./chunk-DBWGMZCY.js";import{Icon as T}from"./chunk-B427NVDP.js";import{createContext as z,useContext as A,Component as D,useLayoutEffect as P,useRef as I,useEffect as K,useState as $,useSyncExternalStore as W,useCallback as O,isValidElement as R,Fragment as F,Children as q,cloneElement as j,useMemo as B,useId as H,useReducer as Y,Suspense as U}from"react";import{jsxs as X,jsx as V,Fragment as _}from"react/jsx-runtime";import{createPortal as G}from"react-dom";import{useLocation as J}from"react-router-dom";import{useQueryClient as Q,useQuery as Z}from"@tanstack/react-query";function ee(e){return"component"in e}function te(e){return"endpoint"in e}var ne={};function re(e){ne=e}var oe=new Proxy({},{get:(e,t)=>ne[t],has:(e,t)=>t in ne,ownKeys:()=>Object.keys(ne),getOwnPropertyDescriptor(e,t){if(t in ne)return{configurable:!0,enumerable:!0,value:ne[t]}}}),ie=null;function ae(e){ie=e}function se(){return null!==ie}var le=/* @__PURE__ */new Set(["get","post","put","patch","delete","head","options","request"]),ce=new Proxy({},{get:(e,t)=>ie?ie[t]:"string"==typeof t&&le.has(t)?()=>Promise.resolve({data:null,status:0,statusText:"",headers:{},config:{}}):void 0}),de=z(null);function ue(){return A(de)?.pageSearch??""}var he=null,me=/* @__PURE__ */new Set;function pe(e){he!==e&&(he=e,me.forEach(e=>e()))}function fe(){return he}function we(e){return me.add(e),()=>{me.delete(e)}}function ye({error:e,onReload:t}){const n=u(e);/* @__PURE__ */
2
2
  return X("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 py-12 text-center",children:[
3
3
  /* @__PURE__ */V(T,{name:"warning",className:"h-8 w-8 text-amber-500",strokeWidth:1.5}),
4
4
  /* @__PURE__ */X("div",{className:"min-w-0",children:[
@@ -14,40 +14,40 @@ return V(p,{status:"warning",title:i.signInRequired,subTitle:i.signInBody,classN
14
14
  return V(p,{status:"403",className:Se});if(404===e||410===e)/* @__PURE__ */
15
15
  return V(p,{status:"404",title:i.notFound,className:Se});const t=null==e||408===e||429===e||e>=500;/* @__PURE__ */
16
16
  return V(p,{status:"500",title:i.loadFailed,subTitle:t?i.checkConnection:i.rejected,extra:t?/* @__PURE__ */V(g,{variant:"secondary",size:"sm",onClick:o,children:i.retry}):void 0,className:Se})}/* @__PURE__ */
17
- return V(p,{status:"404",title:i.notFound,className:Se})}function Ae({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */V(_,{children:t(e)}):/* @__PURE__ */V(ze,{...n})}var De=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function Pe(e){return"string"==typeof e&&(e.startsWith("new-")||De.test(e))}function Ie(e){if(Pe(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var $e=z({openWindows:[],openEntity:()=>{},openPage:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),Ke=z(null);function We(e){const t=A(Ke),n=I(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),P(()=>{if(t)return t(n.current,e)},[t,e]),$(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function Oe(){const e=I(/* @__PURE__ */new Map),[t,n]=K(!1);return{dirty:t,registerDirty:O((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 Re(){return A($e)}function Fe(e){if("page"!==e.type&&Ie(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 qe({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=Oe(),i=oe[e.route];if(!i||!ee(i))return null;const a=i,s=a.component;/* @__PURE__ */
18
- return V(zr,{open:!0,onClose:t,icon:c[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__ */V(Ke.Provider,{value:o,children:/* @__PURE__ */V(Y,{fallback:/* @__PURE__ */V("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */V(Ne,{})}),children:/* @__PURE__ */V(s,{})})})})}function je({entityType:e,entityId:t,label:n}){const r=L(),o=Q(),{data:i}=Z({queryKey:["my-profile-sidebar"],enabled:se(),queryFn:()=>ce.get("/auth/me/").then(e=>e.data)}),a=(i?.preferences||{}).favorite_documents||[],s=a.some(n=>n.entityType===e&&n.entityId===t);/* @__PURE__ */
19
- return V("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];ce.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__ */V(T,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var Be=/* @__PURE__ */new Set;function He({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=oe[e.entityType];if(!o||!te(o))return null;const i=o,[a,s]=K(!1),{dirty:l,registerDirty:d}=Oe(),u=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,h=e.entitySnapshot?._duplicate,m=Pe(e.entityId),p=!i.selfFetching&&!h&&!m&&se(),f=Z({queryKey:[u,e.entityId],queryFn:()=>{return ce.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:Te(e.entitySnapshot),initialDataUpdatedAt:0,enabled:p,staleTime:0,refetchOnWindowFocus:!0,refetchOnMount:"always",refetchInterval:e=>!Ce(e.state.error)&&6e4,refetchIntervalInBackground:!1,retry:Me}),w=f.data,y=f.refetch;$(()=>{var t;if(p)return t=t=>{t!==e.id||Be.has(t)||y({cancelRefetch:!1})},In.add(t),()=>{In.delete(t)}},[y,e.id,p]);const g=O(()=>{a&&!l?s(!1):t()},[a,l,t]),b=i.selfFetching?e.label:w?i.title(w,a,s):e.label,v=i.icon,x=v?c[v]:null,k=b,E=!i.selfFetching&&w&&i.footer&&!h?i.footer(w):void 0;return i.rendersOwnModal?i.selfFetching?/* @__PURE__ */V(Y,{fallback:/* @__PURE__ */V(Ne,{}),children:i.render(w??e.entitySnapshot,t,e.entityId,a,s)}):null!=w?/* @__PURE__ */V(Y,{fallback:/* @__PURE__ */V(zr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */V(Le,{})}),children:i.render(w,t,e.entityId,a,s)}):/* @__PURE__ */V(zr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */V(ze,{isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y})}):/* @__PURE__ */V(zr,{open:!0,onClose:g,onMinimize:n,initialBox:e.savedBox,icon:x,title:k,footer:E,copyText:e.label,windowKey:e.id,openedFromKey:e.openedFrom,size:i.size||"2xl",dirty:l,editing:a||m||h,dimensions:i.dimensions,autoHeight:i.autoHeight,autoMinHeight:i.autoMinHeight,autoWidth:i.autoWidth,appStyle:i.appStyle,flushBody:i.flushBody,accentRgb:r,children:/* @__PURE__ */V(Ke.Provider,{value:d,children:/* @__PURE__ */V(Y,{fallback:/* @__PURE__ */V(Le,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */V(Ae,{entity:w,isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y,children:n=>i.render(n,t,e.entityId,a,s)})})})})}function Ue(e){return document.querySelector(`[data-modal-panel][data-window-key="${e}"]`)}function Ye(e){return document.querySelector(`[data-modal-panel][data-window-root][data-window-owner="${e}"]`)}function Xe(e){const t=Ue(e),n=t??Ye(e);if(!n)return;if(t&&!Yn(t))return r=e,void window.dispatchEvent(new CustomEvent("modal-reveal",{detail:{windowKey:r}}));var r;const o=n.getAttribute("data-modal-id");o&&$n(o)}function Ve(e){if("page"!==e.type)return!0;const t=e.route?oe[e.route]:void 0;if(!t||!ee(t))return!0;const n=t;return!n.widget&&!n.utility}function _e(){const e=ar();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var Je=/* @__PURE__ */new Map;function Ge(){const e=_e();if(e)return Je.get(e)}function Qe(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 Ze="rosh-peek-style",et=M.peek,tt=M.taskbarPreview;function nt(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(Ze))return;const e=document.createElement("style");e.id=Ze,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:${et}!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 rt(){"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 ot({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=L(),l=I(null),[c,d]=K({w:n,h:Math.round(.75*r)}),[u,h]=K(!1);return P(()=>{const o=l.current;if(!o)return;const i=Ue(e)??Qe(t);if(!i)return void h(!1);const a=i.getBoundingClientRect();if(0===a.width||0===a.height)return void h(!1);const s=Math.min(n/a.width,r/a.height),c=Math.max(80,Math.round(a.width*s)),u=Math.max(60,Math.round(a.height*s));d({w:c,h:u}),h(!0);const m=i.cloneNode(!0);return m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.right="auto",m.style.bottom="auto",m.style.width=a.width+"px",m.style.height=a.height+"px",m.style.transform=`scale(${s})`,m.style.transformOrigin="top left",m.style.pointerEvents="none",m.style.animation="none",m.style.zIndex="auto",m.removeAttribute("data-modal-panel"),m.removeAttribute("data-modal-id"),m.removeAttribute("data-window-key"),m.querySelectorAll('[role="dialog"], [data-portal]').forEach(e=>{e.style.display="none"}),o.innerHTML="",o.appendChild(m),()=>{o.innerHTML=""}},[e,t,n,r]),/* @__PURE__ */X("div",{style:{width:c.w,height:c.h},className:"relative rounded-md overflow-hidden bg-white/95 border border-gray-300 shadow-(--elevation-panel) cursor-pointer ring-2 ring-transparent group-hover:ring-blue-400 transition shrink-0",onClick:i,children:[
17
+ return V(p,{status:"404",title:i.notFound,className:Se})}function Ae({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */V(_,{children:t(e)}):/* @__PURE__ */V(ze,{...n})}var De=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function Pe(e){return"string"==typeof e&&(e.startsWith("new-")||De.test(e))}function Ie(e){if(Pe(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var Ke=z({openWindows:[],openEntity:()=>{},openPage:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),$e=z(null);function We(e){const t=A($e),n=I(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),P(()=>{if(t)return t(n.current,e)},[t,e]),K(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function Oe(){const e=I(/* @__PURE__ */new Map),[t,n]=$(!1);return{dirty:t,registerDirty:O((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 Re(){return A(Ke)}function Fe(e){if("page"!==e.type&&Ie(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 qe({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=Oe(),i=oe[e.route];if(!i||!ee(i))return null;const a=i,s=a.component;/* @__PURE__ */
18
+ return V(zr,{open:!0,onClose:t,icon:c[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__ */V($e.Provider,{value:o,children:/* @__PURE__ */V(U,{fallback:/* @__PURE__ */V("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */V(Ne,{})}),children:/* @__PURE__ */V(s,{})})})})}function je({entityType:e,entityId:t,label:n}){const r=L(),o=Q(),{data:i}=Z({queryKey:["my-profile-sidebar"],enabled:se(),queryFn:()=>ce.get("/auth/me/").then(e=>e.data)}),a=(i?.preferences||{}).favorite_documents||[],s=a.some(n=>n.entityType===e&&n.entityId===t);/* @__PURE__ */
19
+ return V("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];ce.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__ */V(T,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var Be=/* @__PURE__ */new Set;function He({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=oe[e.entityType];if(!o||!te(o))return null;const i=o,[a,s]=$(!1),{dirty:l,registerDirty:d}=Oe(),u=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,h=e.entitySnapshot?._duplicate,m=Pe(e.entityId),p=!i.selfFetching&&!h&&!m&&se(),f=Z({queryKey:[u,e.entityId],queryFn:()=>{return ce.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:Te(e.entitySnapshot),initialDataUpdatedAt:0,enabled:p,staleTime:0,refetchOnWindowFocus:!0,refetchOnMount:"always",refetchInterval:e=>!Ce(e.state.error)&&6e4,refetchIntervalInBackground:!1,retry:Me}),w=f.data,y=f.refetch;K(()=>{var t;if(p)return t=t=>{t!==e.id||Be.has(t)||y({cancelRefetch:!1})},In.add(t),()=>{In.delete(t)}},[y,e.id,p]);const g=O(()=>{a&&!l?s(!1):t()},[a,l,t]),b=i.selfFetching?e.label:w?i.title(w,a,s):e.label,v=i.icon,x=v?c[v]:null,k=b,E=!i.selfFetching&&w&&i.footer&&!h?i.footer(w):void 0;return i.rendersOwnModal?i.selfFetching?/* @__PURE__ */V(U,{fallback:/* @__PURE__ */V(Ne,{}),children:i.render(w??e.entitySnapshot,t,e.entityId,a,s)}):null!=w?/* @__PURE__ */V(U,{fallback:/* @__PURE__ */V(zr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */V(Le,{})}),children:i.render(w,t,e.entityId,a,s)}):/* @__PURE__ */V(zr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */V(ze,{isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y})}):/* @__PURE__ */V(zr,{open:!0,onClose:g,onMinimize:n,initialBox:e.savedBox,icon:x,title:k,footer:E,copyText:e.label,windowKey:e.id,openedFromKey:e.openedFrom,size:i.size||"2xl",dirty:l,editing:a||m||h,dimensions:i.dimensions,autoHeight:i.autoHeight,autoMinHeight:i.autoMinHeight,autoWidth:i.autoWidth,appStyle:i.appStyle,flushBody:i.flushBody,accentRgb:r,children:/* @__PURE__ */V($e.Provider,{value:d,children:/* @__PURE__ */V(U,{fallback:/* @__PURE__ */V(Le,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */V(Ae,{entity:w,isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y,children:n=>i.render(n,t,e.entityId,a,s)})})})})}function Ye(e){return document.querySelector(`[data-modal-panel][data-window-key="${e}"]`)}function Ue(e){return document.querySelector(`[data-modal-panel][data-window-root][data-window-owner="${e}"]`)}function Xe(e){const t=Ye(e),n=t??Ue(e);if(!n)return;if(t&&!Un(t))return r=e,void window.dispatchEvent(new CustomEvent("modal-reveal",{detail:{windowKey:r}}));var r;const o=n.getAttribute("data-modal-id");o&&Kn(o)}function Ve(e){if("page"!==e.type)return!0;const t=e.route?oe[e.route]:void 0;if(!t||!ee(t))return!0;const n=t;return!n.widget&&!n.utility}function _e(){const e=ar();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var Ge=/* @__PURE__ */new Map;function Je(){const e=_e();if(e)return Ge.get(e)}function Qe(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 Ze="rosh-peek-style",et=M.peek,tt=M.taskbarPreview;function nt(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(Ze))return;const e=document.createElement("style");e.id=Ze,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:${et}!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 rt(){"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 ot({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=L(),l=I(null),[c,d]=$({w:n,h:Math.round(.75*r)}),[u,h]=$(!1);return P(()=>{const o=l.current;if(!o)return;const i=Ye(e)??Qe(t);if(!i)return void h(!1);const a=i.getBoundingClientRect();if(0===a.width||0===a.height)return void h(!1);const s=Math.min(n/a.width,r/a.height),c=Math.max(80,Math.round(a.width*s)),u=Math.max(60,Math.round(a.height*s));d({w:c,h:u}),h(!0);const m=i.cloneNode(!0);return m.style.position="absolute",m.style.top="0",m.style.left="0",m.style.right="auto",m.style.bottom="auto",m.style.width=a.width+"px",m.style.height=a.height+"px",m.style.transform=`scale(${s})`,m.style.transformOrigin="top left",m.style.pointerEvents="none",m.style.animation="none",m.style.zIndex="auto",m.removeAttribute("data-modal-panel"),m.removeAttribute("data-modal-id"),m.removeAttribute("data-window-key"),m.querySelectorAll('[role="dialog"], [data-portal]').forEach(e=>{e.style.display="none"}),o.innerHTML="",o.appendChild(m),()=>{o.innerHTML=""}},[e,t,n,r]),/* @__PURE__ */X("div",{style:{width:c.w,height:c.h},className:"relative rounded-md overflow-hidden bg-white/95 border border-gray-300 shadow-(--elevation-panel) cursor-pointer ring-2 ring-transparent group-hover:ring-blue-400 transition shrink-0",onClick:i,children:[
20
20
  /* @__PURE__ */V("div",{ref:l,className:"absolute inset-0 z-0 overflow-hidden"}),!u&&/* @__PURE__ */X("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-gray-400 bg-gray-50",children:[
21
21
  /* @__PURE__ */V(T,{name:"window",className:"h-6 w-6",strokeWidth:1.5}),
22
- /* @__PURE__ */V("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */V("div",{className:"absolute bottom-0 left-0 right-0 z-10 px-2 py-1 text-2xs font-medium text-white bg-gradient-to-t from-black/80 to-transparent truncate pointer-events-none",children:t}),a&&/* @__PURE__ */V("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-white flex items-center justify-center",title:s.taskbar.closeWindow,children:/* @__PURE__ */V(T,{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=L(),s=e.length>1,l=I(null),[c,d]=K({left:-9999,top:-9999,ready:!1}),[u,h]=K(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");P(()=>{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";h(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)),d({left:a,top:i,ready:!0})};n();const r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,e.length]),$(()=>rt,[]);const m="top"===u,p=(m?"mt-1":"mb-1")+" max-w-[240px] truncate text-2xs font-medium text-gray-900 bg-white/80 px-2 py-0.5 rounded shadow-sm ring-2 ring-transparent transition group-hover:ring-blue-400";return J(
23
- /* @__PURE__ */V("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:()=>{rt(),i()},children:e.map(e=>{const t=Ue(e.id)??Qe(e.label),o=t?function(e){if(Yn(e))return null;const t=e.getBoundingClientRect(),n=Fn(),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__ */
22
+ /* @__PURE__ */V("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */V("div",{className:"absolute bottom-0 left-0 right-0 z-10 px-2 py-1 text-2xs font-medium text-white bg-gradient-to-t from-black/80 to-transparent truncate pointer-events-none",children:t}),a&&/* @__PURE__ */V("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-white flex items-center justify-center",title:s.taskbar.closeWindow,children:/* @__PURE__ */V(T,{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=L(),s=e.length>1,l=I(null),[c,d]=$({left:-9999,top:-9999,ready:!1}),[u,h]=$(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");P(()=>{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";h(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)),d({left:a,top:i,ready:!0})};n();const r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,e.length]),K(()=>rt,[]);const m="top"===u,p=(m?"mt-1":"mb-1")+" max-w-[240px] truncate text-2xs font-medium text-gray-900 bg-white/80 px-2 py-0.5 rounded shadow-sm ring-2 ring-transparent transition group-hover:ring-blue-400";return G(
23
+ /* @__PURE__ */V("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:()=>{rt(),i()},children:e.map(e=>{const t=Ye(e.id)??Qe(e.label),o=t?function(e){if(Un(e))return null;const t=e.getBoundingClientRect(),n=Fn(),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__ */
24
24
  return X("div",{className:"group flex flex-col items-center",onMouseEnter:()=>nt(t),children:[!m&&/* @__PURE__ */V("span",{className:p,children:e.label}),
25
25
  /* @__PURE__ */V(ot,{id:e.id,label:e.label,maxW:240,maxH:160,titleAbove:!0,onClick:()=>n(e.id),onClose:()=>r(e.id)}),m&&/* @__PURE__ */V("span",{className:p,children:e.label}),null!==o&&/* @__PURE__ */X("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-white shadow-sm",children:[
26
- /* @__PURE__ */V(T,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function at(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 st({openWindows:e,onRemove:t,onSplitView:n,onActivate:r,onActivateById:o}){const i=L(),[a,s]=K(null);$(()=>{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 l=W(sr,ar),[,d]=K(0);$(()=>{const e=()=>d(e=>e+1);return window.addEventListener("modal-geometry",e),window.addEventListener("resize",e),()=>{window.removeEventListener("modal-geometry",e),window.removeEventListener("resize",e)}},[]);const[,u]=K(0);$(()=>{const e=()=>u(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const h=e=>{const t=Qe(e),n=t?.querySelector("[data-window-title]");return n?.textContent?.trim()||e},[m,p]=K(null),[f,w]=K(null),[y,g]=K(null),b=I(null),v=()=>{b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{p(null),w(null)},150)},M=e.filter(e=>!e.route||!oe[e.route]?.utility);if(!a||!a.isConnected||0===M.length)return null;const N=[],S=/* @__PURE__ */new Map;for(const e of M){const t=e.route?oe[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=S.get(r);if(void 0!==o)N[o].items.push(e);else{S.set(r,N.length);const o=n?.label??t?.label??e.label;N.push({key:r,route:n?.icon??e.route,label:o,items:[e]})}}return J(
27
- /* @__PURE__ */X(_,{children:[N.map(e=>{const n=e.route?c[e.route]:null,r=e.items[e.items.length-1];let a=!1;if(l){const t=document.querySelector(`[data-modal-id="${l}"]`);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,d=e.items.some(e=>{const t=Ue(e.id)??Qe(e.label);return!!t&&!Yn(t)});/* @__PURE__ */
26
+ /* @__PURE__ */V(T,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function at(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 st({openWindows:e,onRemove:t,onSplitView:n,onActivate:r,onActivateById:o}){const i=L(),[a,s]=$(null);K(()=>{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 l=W(sr,ar),[,d]=$(0);K(()=>{const e=()=>d(e=>e+1);return window.addEventListener("modal-geometry",e),window.addEventListener("resize",e),()=>{window.removeEventListener("modal-geometry",e),window.removeEventListener("resize",e)}},[]);const[,u]=$(0);K(()=>{const e=()=>u(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const h=e=>{const t=Qe(e),n=t?.querySelector("[data-window-title]");return n?.textContent?.trim()||e},[m,p]=$(null),[f,w]=$(null),[y,g]=$(null),b=I(null),v=()=>{b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{p(null),w(null)},150)},M=e.filter(e=>!e.route||!oe[e.route]?.utility);if(!a||!a.isConnected||0===M.length)return null;const N=[],S=/* @__PURE__ */new Map;for(const e of M){const t=e.route?oe[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=S.get(r);if(void 0!==o)N[o].items.push(e);else{S.set(r,N.length);const o=n?.label??t?.label??e.label;N.push({key:r,route:n?.icon??e.route,label:o,items:[e]})}}return G(
27
+ /* @__PURE__ */X(_,{children:[N.map(e=>{const n=e.route?c[e.route]:null,r=e.items[e.items.length-1];let a=!1;if(l){const t=document.querySelector(`[data-modal-id="${l}"]`);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,d=e.items.some(e=>{const t=Ye(e.id)??Qe(e.label);return!!t&&!Un(t)});/* @__PURE__ */
28
28
  return X("button",{onClick:()=>o(r.id),onMouseEnter:t=>{return n=e.items,r=t.currentTarget,void(y||(b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{p(n),w(r)},350)));var n,r},onMouseLeave:v,onDoubleClick:e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent("modal-center",{detail:{windowKey:r.id,label:r.label}}))},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),b.current&&(clearTimeout(b.current),b.current=null),p(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&&R(n)?j(n,{className:"h-3.5 w-3.5 shrink-0"}):/* @__PURE__ */V(T,{name:"expand",className:"h-3.5 w-3.5 shrink-0",strokeWidth:2}),
29
29
  /* @__PURE__ */V("span",{className:"truncate flex-1",children:s?e.label:h(r.label)}),d&&/* @__PURE__ */V("span",{title:i.taskbar.offscreenDot,className:"shrink-0 h-1.5 w-1.5 rounded-full bg-amber-500"}),s&&/* @__PURE__ */V("span",{className:"shrink-0 px-2 py-0.5 rounded-full bg-blue-500/80 text-white text-2xs font-bold leading-none",children:e.items.length}),!s&&/* @__PURE__ */V("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__ */V(T,{name:"close",className:"h-3 w-3",strokeWidth:2})})]},e.key)}),
30
30
  /* @__PURE__ */V("div",{className:"flex-1"}),M.length>=2&&/* @__PURE__ */X("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-blue-50 transition-colors shrink-0",children:[
31
31
  /* @__PURE__ */V(T,{name:"grid",className:"h-3 w-3",strokeWidth:2}),"Exposé"]}),y&&/* @__PURE__ */X(x,{portal:!0,minWidth:200,style:at(y.x,y.y),onClose:()=>g(null),children:[
32
32
  /* @__PURE__ */V(C,{children:y.label}),
33
- /* @__PURE__ */X(k,{onClick:()=>{g(null),y.items.forEach(e=>function(e){const t=kn.get(e);t&&Kn(t)}(e.id))},children:[
33
+ /* @__PURE__ */X(k,{onClick:()=>{g(null),y.items.forEach(e=>function(e){const t=kn.get(e);t&&$n(t)}(e.id))},children:[
34
34
  /* @__PURE__ */V(T,{name:"remove",className:"h-4 w-4",strokeWidth:1.5}),i.taskbar.minimizeAllWindows]}),
35
35
  /* @__PURE__ */X(k,{onClick:()=>{g(null),y.items.forEach(e=>o(e.id))},children:[
36
36
  /* @__PURE__ */V("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */V("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75h6.5v6.5h-6.5zM13.75 8.75h6.5v6.5h-6.5z"})}),i.taskbar.restoreAllWindows]}),
37
37
  /* @__PURE__ */V(E,{}),
38
38
  /* @__PURE__ */X(k,{danger:!0,onClick:()=>{g(null),y.items.forEach(e=>t(e.id))},children:[
39
- /* @__PURE__ */V(T,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${y.items.length})`]})]}),m&&f&&/* @__PURE__ */V(it,{items:m,anchorEl:f,onActivate:e=>{o(e),p(null),w(null)},onClose:e=>{t(e),p(null),w(null)},onMouseEnter:()=>{b.current&&(clearTimeout(b.current),b.current=null)},onMouseLeave:v})]}),a)}var lt=["/login","/forgot-password","/reset-password","/force-change-password"];function ct({children:e,windowAccentForRoute:t}){const n=G(),r=lt.some(e=>n.pathname.startsWith(e)),[o,i]=K([]),a=I(o);P(()=>{a.current=o},[o]);const s=W(we,fe,fe),l=I(/* @__PURE__ */new Map),c=e=>{const t=Ve(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};$(()=>{Je.clear();for(const e of o)e.route&&Je.set(e.id,e.route)},[o]);const d=O(e=>{i(t=>t.filter(t=>t.id!==e))},[]),u=O(e=>{var t;Ue(e)||Ye(e)?(t=e,window.dispatchEvent(new CustomEvent(lr,{detail:{windowKey:t}}))):d(e)},[d]),h=(e,t=!1)=>{const n=yn;t&&Be.add(e),setTimeout(()=>{const r=document.querySelector(`[data-modal-panel][data-window-key="${e}"]`),o=r?.getAttribute("data-modal-id");var i,a;!o||(i=o,a=n,(gn.get(i)??-1)>a)||$n(o),t&&Be.delete(e)},50)},m=O((e,t,n,r,o)=>{if(!oe[e]||!te(oe[e]))return;const a=`${e}:${t}`,s=_e();i(i=>{const l=i.find(n=>n.entityType===e&&String(n.entityId)===String(t));return l?(h(l.id),i):(h(a,!0),[...i,{id:a,type:"modal",label:r||t,route:o||window.location.pathname,entityType:e,entityId:t,entitySnapshot:Te(n),openedFrom:s}])})},[]),p=O((e,t={})=>{if(!oe[e]||!ee(oe[e]))return;const n=oe[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l}=t,c=e=>{var t;o?(t=e,Sn.add(t)):h(e)};if(n.widget){const t=a.current.find(t=>"page"===t.type&&t.route===e);if(t)return void u(t.id)}const d=_e();i(t=>{if(n.multiInstance){const i=t.filter(t=>"page"===t.type&&t.route===e);if(r&&!l&&i.length>0)return o||h(i[i.length-1].id),t;const a=`page:${e}:${Math.random().toString(36).slice(2,8)}`;return c(a),[...t,{id:a,type:"page",label:n.label,route:e,openedFrom:d,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}}]}const i=t.find(t=>"page"===t.type&&t.route===e);if(i)return n.widget?t:(o||h(i.id),l&&i.pageSearch!==l?t.map(e=>e===i?{...e,pageSearch:l}:e):t);const a=`page:${e}`;return c(a),[...t,{id:a,type:"page",label:n.label,route:e,openedFrom:d,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}}]})},[u]),f=O(()=>{},[]),w=O(()=>{},[]),y=u,g=u;/* @__PURE__ */
40
- return X($e.Provider,{value:{openWindows:o,openEntity:m,openPage:p,closeEntity:y,minimize:f,items:[],openItems:o,restore:w,remove:g,restoreIfMinimized:()=>!1},children:[e,
41
- /* @__PURE__ */V(st,{openWindows:o,onRemove:u,onSplitView:Lr,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&&$n(e)}})},onActivateById:Xe}),
39
+ /* @__PURE__ */V(T,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${y.items.length})`]})]}),m&&f&&/* @__PURE__ */V(it,{items:m,anchorEl:f,onActivate:e=>{o(e),p(null),w(null)},onClose:e=>{t(e),p(null),w(null)},onMouseEnter:()=>{b.current&&(clearTimeout(b.current),b.current=null)},onMouseLeave:v})]}),a)}var lt=["/login","/forgot-password","/reset-password","/force-change-password"];function ct({children:e,windowAccentForRoute:t}){const n=J(),r=lt.some(e=>n.pathname.startsWith(e)),[o,i]=$([]),a=I(o);P(()=>{a.current=o},[o]);const s=W(we,fe,fe),l=I(/* @__PURE__ */new Map),c=e=>{const t=Ve(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};K(()=>{Ge.clear();for(const e of o)e.route&&Ge.set(e.id,e.route)},[o]);const d=O(e=>{i(t=>t.filter(t=>t.id!==e))},[]),u=O(e=>{var t;Ye(e)||Ue(e)?(t=e,window.dispatchEvent(new CustomEvent(lr,{detail:{windowKey:t}}))):d(e)},[d]),h=(e,t=!1)=>{const n=yn;t&&Be.add(e),setTimeout(()=>{const r=document.querySelector(`[data-modal-panel][data-window-key="${e}"]`),o=r?.getAttribute("data-modal-id");var i,a;!o||(i=o,a=n,(gn.get(i)??-1)>a)||Kn(o),t&&Be.delete(e)},50)},m=O((e,t,n,r,o)=>{if(!oe[e]||!te(oe[e]))return;const a=`${e}:${t}`,s=_e();i(i=>{const l=i.find(n=>n.entityType===e&&String(n.entityId)===String(t));return l?(h(l.id),i):(h(a,!0),[...i,{id:a,type:"modal",label:r||t,route:o||window.location.pathname,entityType:e,entityId:t,entitySnapshot:Te(n),openedFrom:s}])})},[]),p=O((e,t={})=>{if(!oe[e]||!ee(oe[e]))return;const n=oe[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l}=t,c=e=>{var t;o?(t=e,Sn.add(t)):h(e)};if(n.widget){const t=a.current.find(t=>"page"===t.type&&t.route===e);if(t)return void u(t.id)}const d=_e();i(t=>{if(n.multiInstance){const i=t.filter(t=>"page"===t.type&&t.route===e);if(r&&!l&&i.length>0)return o||h(i[i.length-1].id),t;const a=`page:${e}:${Math.random().toString(36).slice(2,8)}`;return c(a),[...t,{id:a,type:"page",label:n.label,route:e,openedFrom:d,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}}]}const i=t.find(t=>"page"===t.type&&t.route===e);if(i)return n.widget?t:(o||h(i.id),l&&i.pageSearch!==l?t.map(e=>e===i?{...e,pageSearch:l}:e):t);const a=`page:${e}`;return c(a),[...t,{id:a,type:"page",label:n.label,route:e,openedFrom:d,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}}]})},[u]),f=O(()=>{},[]),w=O(()=>{},[]),y=u,g=u;/* @__PURE__ */
40
+ return X(Ke.Provider,{value:{openWindows:o,openEntity:m,openPage:p,closeEntity:y,minimize:f,items:[],openItems:o,restore:w,remove:g,restoreIfMinimized:()=>!1},children:[e,
41
+ /* @__PURE__ */V(st,{openWindows:o,onRemove:u,onSplitView:Lr,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&&Kn(e)}})},onActivateById:Xe}),
42
42
  /* @__PURE__ */V(Tr,{}),!r&&o.map(e=>{const n=e.route?t?.(e.route):void 0;
43
43
  /* @__PURE__ */
44
- return V(de.Provider,{value:c(e),children:/* @__PURE__ */V(ge,{fallback:(t,n)=>/* @__PURE__ */V(zr,{open:!0,onClose:()=>d(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */V(ye,{error:t,onReload:n})}),children:/* @__PURE__ */V($t,{spec:Fe(e),children:/* @__PURE__ */V(Wr,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */V(qe,{item:e,onClose:()=>d(e.id),accentRgb:n}):/* @__PURE__ */V(He,{item:e,onClose:()=>d(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var dt=null,ut=/* @__PURE__ */new Set;function ht(){return dt}function mt(e){if(dt!==e){dt=e;for(const e of ut)e()}}function pt(e){return ut.add(e),()=>{ut.delete(e)}}var ft=!1,wt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},yt=()=>{};function gt(e){ft=e,wt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function bt(e,t){ft&&("submenu"===e?wt.submenus++:wt.menus++,wt.menuKey=t)}function vt(e){if(!ft)return yt;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!ft)return;const r=performance.now()-t;"move"===e?wt.moveMs+=r:wt.resizeMs+=r}}function xt(){const e=wt;return wt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var kt=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),Et=/* @__PURE__ */new Set(["svg"]);function Ct(e){const t=[],n={text:"",accessories:[]};return Mt(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function Mt(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=>Mt(e,t,n));if(!R(e))return;const r=e;if(r.type!==d)if(r.type!==F){if("string"==typeof r.type){if(Et.has(r.type))return;if(!kt.has(r.type))return n.push(" "),q.toArray(r.props.children).forEach(e=>Mt(e,t,n)),void n.push(" ")}t.accessories.push(j(r,{key:`title-part-${t.accessories.length}`}))}else q.toArray(r.props.children).forEach(e=>Mt(e,t,n));else void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text)}var Nt=/* @__PURE__ */new Map,St=/* @__PURE__ */new Set,Lt=0;function Tt(){Lt++,St.forEach(e=>e())}function zt(e){return Nt.get(e)}function At(e){return St.add(e),()=>{St.delete(e)}}function Dt(){return Lt}var Pt=z(""),It=z(null);function $t({spec:e,children:t}){/* @__PURE__ */
45
- return V(It.Provider,{value:e,children:t})}var Kt=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),Wt='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600',Ot='button, a[href], summary, [role="button"], [role="link"], [role="menuitem"], select';function Rt(e){return Ft(e).replace(/\s+/g," ").trim()}function Ft(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(Ft).join("");if(R(e)){const t=e,n="string"==typeof t.type?t.type:"";return Kt.has(n)?"":` ${Ft(t.props?.children)} `}return""}function qt(e){const t=A(Pt);$(()=>{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 jt={};function Bt(e,t,n){const r=A(Pt);$(()=>{if(!r)return;jt[r]||(jt[r]=[]);const o={label:e,icon:n,onClick:t};return jt[r].push(o),()=>{jt[r]=(jt[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function Ht({title:e}){const t=I(null);return $(()=>{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__ */V("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function Ut(e){}var Yt=z(null);function Xt(){return A(Pt)}function Vt(){const e=W(sr,ar),t=A(Yt);return t?.active??(pn.length<=1||null!=e)}function _t({children:e,position:t="right",quiet:n=!1}){const r=A(Yt),[o,i]=K(null);return $(()=>{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?J(e,o):null}function Jt({onClick:e,children:t,className:n}){const r=A(Yt);/* @__PURE__ */
46
- return V("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./ConfirmDialog-TGAPFTMU.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 Gt="erp_window_positions",Qt={};try{const e=localStorage.getItem(Gt);e&&(Qt=JSON.parse(e))}catch{}var Zt=null;function en(){Zt&&clearTimeout(Zt),Zt=setTimeout(()=>{try{localStorage.setItem(Gt,JSON.stringify(Qt))}catch{}},500)}var tn="erp_activation_order",nn=[];try{const e=localStorage.getItem(tn),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(nn=t)}catch{}var rn=null;function on(){rn&&clearTimeout(rn),rn=setTimeout(()=>{try{localStorage.setItem(tn,JSON.stringify(nn))}catch{}},500)}function an(e,t){Qt[e]||(Qt[e]=t,en())}function sn(e){return Qt[e]?{...Qt[e]}:null}function ln(e,t){Qt[e]=t,en()}function cn(){const r=e(),o=t();let i=!1;for(const e of Object.keys(Qt))n(Qt[e],r,o)&&(delete Qt[e],i=!0);i&&en()}var dn={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},un=4e3,hn=()=>{if("undefined"==typeof document)return"large";const e=getComputedStyle(document.documentElement).getPropertyValue("--default-window-size")?.trim();return"small"===e||"medium"===e||"maximized"===e?e:"large"},mn={small:.8,medium:1,large:1.25,maximized:1.25},pn=[],fn=/* @__PURE__ */new Set,wn=/* @__PURE__ */new Set,yn=0,gn=/* @__PURE__ */new Map;var bn=0;function vn(){return bn}function xn(){bn++,fn.forEach(e=>e())}var kn=/* @__PURE__ */new Map,En=/* @__PURE__ */new Map,Cn=/* @__PURE__ */new Map;function Mn(){for(let e=pn.length-1;e>=0;e--){const t=Cn.get(pn[e]);if(t?.tab)return t.owner}return null}function Nn(){return W(sr,Mn,()=>null)}var Sn=/* @__PURE__ */new Set;var Ln=null;function Tn(e){Ln=null,$n(e)}function zn(e){Ln=e;const t=kn.get(e);t&&Tn(t)}function An(e){Ln===e&&(Ln=null)}function Dn(e,t,n){if(n&&Cn.set(e,n),t)if(kn.set(t,e),En.set(e,t),Sn.delete(t)){pn.unshift(e);const n=nn.indexOf(t);-1!==n&&nn.splice(n,1),nn.unshift(t),on()}else!function(e,t){const n=nn.indexOf(t);if(-1===n)return void pn.push(e);let r=pn.length;for(let e=0;e<pn.length;e++){const t=En.get(pn[e]);if(t&&nn.indexOf(t)>n){r=e;break}}pn.splice(r,0,e)}(e,t),-1===nn.indexOf(t)&&(nn.push(t),on());else pn.push(e);xn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&Ln===t&&Tn(e)}function Pn(e){return e?Cn.get(e)?.owner??En.get(e)??null:null}var In=/* @__PURE__ */new Set;function $n(e){const t=Pn(ar()),n=pn.indexOf(e);-1!==n&&pn.splice(n,1),pn.push(e);const o=Cn.get(e);if(o?.root&&o.tab&&r()){const e=pn.filter(e=>{const t=Cn.get(e);return!!t&&!t.root&&t.owner===o.owner});for(const t of e)pn.splice(pn.indexOf(t),1),pn.push(t)}wn.delete(e);const i=En.get(e);if(i){const e=nn.indexOf(i);-1!==e&&nn.splice(e,1),nn.push(i),on(),Ln&&Ln!==i&&(Ln=null)}xn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const a=Pn(ar());a&&a!==t&&In.forEach(e=>e(a))}function Kn(e){const t=pn.indexOf(e);-1!==t&&pn.splice(t,1),wn.add(e),gn.set(e,++yn);const n=En.get(e);if(n){const e=nn.indexOf(n);-1!==e&&(nn.splice(e,1),on())}xn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var Wn=/* @__PURE__ */new Set;var On=8,Rn=32;function Fn(){return e()}var qn=40,jn=80,Bn=384,Hn=400;function Un(e,t=Fn()){const n=Math.min(Math.max(e.x,t.x+jn-e.w),t.x+t.w-jn),r=Math.min(Math.max(e.y,t.y),t.y+t.h-qn);return n===e.x&&r===e.y?e:{...e,x:n,y:r}}function Yn(e){const t=e.getBoundingClientRect();if(0===t.width||0===t.height)return!0;const n=Fn();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 Xn(e){const t=Fn(),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 Vn=null;function _n(e){const t=(Vn||((Vn=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${M.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(Vn)),Vn);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 Jn(){Vn&&(Vn.style.opacity="0",Vn.style.display="none")}var Gn=[{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"}],Qn=350,Zn=200;function er({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o}){const[i,a]=K(!1),s=I(void 0),l=I(void 0);$(()=>()=>{clearTimeout(s.current),clearTimeout(l.current)},[]);const c=()=>{clearTimeout(l.current),s.current=setTimeout(()=>a(!0),Qn)},d=()=>{clearTimeout(s.current),l.current=setTimeout(()=>a(!1),Zn)};/* @__PURE__ */
44
+ return V(de.Provider,{value:c(e),children:/* @__PURE__ */V(ge,{fallback:(t,n)=>/* @__PURE__ */V(zr,{open:!0,onClose:()=>d(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */V(ye,{error:t,onReload:n})}),children:/* @__PURE__ */V(Kt,{spec:Fe(e),children:/* @__PURE__ */V(Wr,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */V(qe,{item:e,onClose:()=>d(e.id),accentRgb:n}):/* @__PURE__ */V(He,{item:e,onClose:()=>d(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var dt=null,ut=/* @__PURE__ */new Set;function ht(){return dt}function mt(e){if(dt!==e){dt=e;for(const e of ut)e()}}function pt(e){return ut.add(e),()=>{ut.delete(e)}}var ft=!1,wt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},yt=()=>{};function gt(e){ft=e,wt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function bt(e,t){ft&&("submenu"===e?wt.submenus++:wt.menus++,wt.menuKey=t)}function vt(e){if(!ft)return yt;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!ft)return;const r=performance.now()-t;"move"===e?wt.moveMs+=r:wt.resizeMs+=r}}function xt(){const e=wt;return wt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var kt=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),Et=/* @__PURE__ */new Set(["svg"]);function Ct(e){const t=[],n={text:"",accessories:[]};return Mt(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function Mt(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=>Mt(e,t,n));if(!R(e))return;const r=e;if(r.type!==d)if(r.type!==F){if("string"==typeof r.type){if(Et.has(r.type))return;if(!kt.has(r.type))return n.push(" "),q.toArray(r.props.children).forEach(e=>Mt(e,t,n)),void n.push(" ")}t.accessories.push(j(r,{key:`title-part-${t.accessories.length}`}))}else q.toArray(r.props.children).forEach(e=>Mt(e,t,n));else void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text)}var Nt=/* @__PURE__ */new Map,St=/* @__PURE__ */new Set,Lt=0;function Tt(){Lt++,St.forEach(e=>e())}function zt(e){return Nt.get(e)}function At(e){return St.add(e),()=>{St.delete(e)}}function Dt(){return Lt}var Pt=z(""),It=z(null);function Kt({spec:e,children:t}){/* @__PURE__ */
45
+ return V(It.Provider,{value:e,children:t})}var $t=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),Wt='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600',Ot='button, a[href], summary, [role="button"], [role="link"], [role="menuitem"], select';function Rt(e){return Ft(e).replace(/\s+/g," ").trim()}function Ft(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(Ft).join("");if(R(e)){const t=e,n="string"==typeof t.type?t.type:"";return $t.has(n)?"":` ${Ft(t.props?.children)} `}return""}function qt(e){const t=A(Pt);K(()=>{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 jt={};function Bt(e,t,n){const r=A(Pt);K(()=>{if(!r)return;jt[r]||(jt[r]=[]);const o={label:e,icon:n,onClick:t};return jt[r].push(o),()=>{jt[r]=(jt[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function Ht({title:e}){const t=I(null);return K(()=>{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__ */V("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function Yt(e){}var Ut=z(null);function Xt(){return A(Pt)}function Vt(){const e=W(sr,ar),t=A(Ut);return t?.active??(pn.length<=1||null!=e)}function _t({children:e,position:t="right",quiet:n=!1}){const r=A(Ut),[o,i]=$(null);return K(()=>{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?G(e,o):null}function Gt({onClick:e,children:t,className:n}){const r=A(Ut);/* @__PURE__ */
46
+ return V("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./ConfirmDialog-VL3YU35U.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 Jt="erp_window_positions",Qt={};try{const e=localStorage.getItem(Jt);e&&(Qt=JSON.parse(e))}catch{}var Zt=null;function en(){Zt&&clearTimeout(Zt),Zt=setTimeout(()=>{try{localStorage.setItem(Jt,JSON.stringify(Qt))}catch{}},500)}var tn="erp_activation_order",nn=[];try{const e=localStorage.getItem(tn),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(nn=t)}catch{}var rn=null;function on(){rn&&clearTimeout(rn),rn=setTimeout(()=>{try{localStorage.setItem(tn,JSON.stringify(nn))}catch{}},500)}function an(e,t){Qt[e]||(Qt[e]=t,en())}function sn(e){return Qt[e]?{...Qt[e]}:null}function ln(e,t){Qt[e]=t,en()}function cn(){const r=e(),o=t();let i=!1;for(const e of Object.keys(Qt))n(Qt[e],r,o)&&(delete Qt[e],i=!0);i&&en()}var dn={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},un=4e3,hn=()=>{if("undefined"==typeof document)return"large";const e=getComputedStyle(document.documentElement).getPropertyValue("--default-window-size")?.trim();return"small"===e||"medium"===e||"maximized"===e?e:"large"},mn={small:.8,medium:1,large:1.25,maximized:1.25},pn=[],fn=/* @__PURE__ */new Set,wn=/* @__PURE__ */new Set,yn=0,gn=/* @__PURE__ */new Map;var bn=0;function vn(){return bn}function xn(){bn++,fn.forEach(e=>e())}var kn=/* @__PURE__ */new Map,En=/* @__PURE__ */new Map,Cn=/* @__PURE__ */new Map;function Mn(){for(let e=pn.length-1;e>=0;e--){const t=Cn.get(pn[e]);if(t?.tab)return t.owner}return null}function Nn(){return W(sr,Mn,()=>null)}var Sn=/* @__PURE__ */new Set;var Ln=null;function Tn(e){Ln=null,Kn(e)}function zn(e){Ln=e;const t=kn.get(e);t&&Tn(t)}function An(e){Ln===e&&(Ln=null)}function Dn(e,t,n){if(n&&Cn.set(e,n),t)if(kn.set(t,e),En.set(e,t),Sn.delete(t)){pn.unshift(e);const n=nn.indexOf(t);-1!==n&&nn.splice(n,1),nn.unshift(t),on()}else!function(e,t){const n=nn.indexOf(t);if(-1===n)return void pn.push(e);let r=pn.length;for(let e=0;e<pn.length;e++){const t=En.get(pn[e]);if(t&&nn.indexOf(t)>n){r=e;break}}pn.splice(r,0,e)}(e,t),-1===nn.indexOf(t)&&(nn.push(t),on());else pn.push(e);xn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&Ln===t&&Tn(e)}function Pn(e){return e?Cn.get(e)?.owner??En.get(e)??null:null}var In=/* @__PURE__ */new Set;function Kn(e){const t=Pn(ar()),n=pn.indexOf(e);-1!==n&&pn.splice(n,1),pn.push(e);const o=Cn.get(e);if(o?.root&&o.tab&&r()){const e=pn.filter(e=>{const t=Cn.get(e);return!!t&&!t.root&&t.owner===o.owner});for(const t of e)pn.splice(pn.indexOf(t),1),pn.push(t)}wn.delete(e);const i=En.get(e);if(i){const e=nn.indexOf(i);-1!==e&&nn.splice(e,1),nn.push(i),on(),Ln&&Ln!==i&&(Ln=null)}xn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const a=Pn(ar());a&&a!==t&&In.forEach(e=>e(a))}function $n(e){const t=pn.indexOf(e);-1!==t&&pn.splice(t,1),wn.add(e),gn.set(e,++yn);const n=En.get(e);if(n){const e=nn.indexOf(n);-1!==e&&(nn.splice(e,1),on())}xn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var Wn=/* @__PURE__ */new Set;var On=8,Rn=32;function Fn(){return e()}var qn=40,jn=80,Bn=384,Hn=400;function Yn(e,t=Fn()){const n=Math.min(Math.max(e.x,t.x+jn-e.w),t.x+t.w-jn),r=Math.min(Math.max(e.y,t.y),t.y+t.h-qn);return n===e.x&&r===e.y?e:{...e,x:n,y:r}}function Un(e){const t=e.getBoundingClientRect();if(0===t.width||0===t.height)return!0;const n=Fn();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 Xn(e){const t=Fn(),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 Vn=null;function _n(e){const t=(Vn||((Vn=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${M.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(Vn)),Vn);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 Gn(){Vn&&(Vn.style.opacity="0",Vn.style.display="none")}var Jn=[{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"}],Qn=350,Zn=200;function er({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o}){const[i,a]=$(!1),s=I(void 0),l=I(void 0);K(()=>()=>{clearTimeout(s.current),clearTimeout(l.current)},[]);const c=()=>{clearTimeout(l.current),s.current=setTimeout(()=>a(!0),Qn)},d=()=>{clearTimeout(s.current),l.current=setTimeout(()=>a(!1),Zn)};/* @__PURE__ */
47
47
  return X("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:d,children:[
48
- /* @__PURE__ */V("button",{onClick:t,onFocus:c,onBlur:d,title:e?o.windowed:o.maximize,className:r,children:e?"❐":"⤢"}),i&&/* @__PURE__ */V("div",{role:"group","aria-label":o.snapLayouts,onMouseEnter:()=>clearTimeout(l.current),onMouseLeave:d,className:"absolute right-0 top-full z-30 mt-1 grid w-max grid-cols-2 gap-1 rounded-lg border border-gray-200 bg-white p-2 shadow-lg",children:Gn.map(({zone:e,labelKey:t,region:r})=>/* @__PURE__ */V("button",{type:"button","aria-label":o[t],title:o[t],onClick:()=>{a(!1),n(e)},onFocus:()=>clearTimeout(l.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__ */V("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var tr="rosh-gesture-style";var nr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},rr=4;function or(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(tr))return;const e=document.createElement("style");e.id=tr,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=vt(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function ir(e){const t=pn.indexOf(e);if(-1===t)return-1;const n=M.window+t*M.windowStep,o=Cn.get(e);if(!o||o.root||!o.tab||!r())return n;let i=-1;for(const[e,t]of Cn){if(!t.root||t.owner!==o.owner)continue;const n=pn.indexOf(e);-1!==n&&(i=Math.max(i,M.window+n*M.windowStep))}return i>=n?i+2+Math.min(t,7):n}function ar(){return pn[pn.length-1]||null}function sr(e){return fn.add(e),()=>{fn.delete(e)}}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=pn.length-1;e>=0;e--)Wn.has(pn[e])||pn.splice(e,1);nn=nn.filter(e=>{const t=kn.get(e);return null!=t&&Wn.has(t)}),on(),xn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var lr="modal-close-request";function cr(e){W(sr,vn);const t=A(Yt);if(pn.length<=1)return!0;if(e){const t=kn.get(e);if(null!=t)return ar()===t}return t?.active??null!=ar()}var dr=!1,ur=/* @__PURE__ */new Set;function hr(e){return ur.add(e),()=>ur.delete(e)}function mr(){return dr}function pr(e){dr!==e&&(dr=e,ur.forEach(e=>e()))}function fr(){pr(!dr)}function wr(){pr(!1)}var yr=null,gr=/* @__PURE__ */new Set;function br(e){return gr.add(e),()=>gr.delete(e)}function vr(){return yr}function xr(e){yr!==e&&(yr=e,gr.forEach(e=>e()))}var kr=null,Er=/* @__PURE__ */new Set;function Cr(e){return Er.add(e),()=>Er.delete(e)}function Mr(){return kr}function Nr(e){kr!==e&&(kr=e,Er.forEach(e=>e()))}function Sr(){if(!kr)return void pr(!1);xr(kr),Nr(null),pr(!1)}function Lr(){pr(!dr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function Tr(){const e=W(hr,mr),[t,n]=K(e),[r,o]=K(e);return $(()=>{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?J(
49
- /* @__PURE__ */V("div",{onMouseDown:e=>{e.stopPropagation(),pr(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:M.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 zr({open:t,onClose:i,title:c,icon:d,copyText:u,size:h="lg",dirty:m=!1,onNext:p,onPrev:y,footer:g,bodyScroll:C,onMinimize:S,initialBox:z,actions:D,actionsLeft:F,editing:q=!1,allowPinOnTop:U,initialPosition:Y,widget:G,compact:Q,appStyle:Z,flushBody:ee,autoHeight:te,autoMinHeight:ne,autoWidth:re,widgetMenu:oe,dimensions:ie,windowKey:ae,openedFromKey:se,accentRgb:le,children:ce}){const ue=f(),[he,me]=K(0),[pe,fe]=K(!1),we=I(null),ye=I(0);$(()=>{ye.current=he},[he]);const ve=O(e=>{ue&&(we.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},fe(!0),mt(se??null))},[ue,se]),ke=W(pt,ht);$(()=>{if(!pe)return;const e=e=>{if(!we.current)return;const t=e.clientX-we.current.startX;if(Math.abs(e.clientY-we.current.startY)>Math.abs(t)+12)return we.current=null,fe(!1),me(0),void mt(null);me(Math.max(0,t))},t=()=>{if(!we.current)return;const e=.3*window.innerWidth,t=ye.current>e;we.current=null,fe(!1),t?(me(window.innerWidth),setTimeout(()=>{i(),me(0),mt(null)},180)):(me(0),mt(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)}},[pe]);const[Ee,Ce]=K(c),Me=L(),Ne=Me.window;$(()=>{Ce(c)},[c]);const Se=B(()=>Rt(Ee).trim()||void 0,[Ee]),Le=H(),[Te,ze]=K(!1),Ae=I(!1),[De,Pe]=K(!1),[Ie,$e]=K(null),Ke=A(It),Oe=A(de),{prefs:Fe,save:qe}=w(),je=!!Fe.window_accent_stripe,Be=Fe.favorite_documents||[],He=!!Ke&&Be.some(e=>e.entityType===Ke.entityType&&e.entityId===Ke.entityId),Ue=O(()=>{if(!Ke)return;const e=He?Be.filter(e=>!(e.entityType===Ke.entityType&&e.entityId===Ke.entityId)):[...Be,{entityType:Ke.entityType,entityId:Ke.entityId,label:Ke.label}];qe({favorite_documents:e})},[Ke,He,Be,qe]),[Ye,Xe]=K(null),[Ve,_e]=K("top-right"===Y?"right":"left"),Je=I(!1),Ge=I(null);P(()=>{const e=Ge.current;e&&(le?e.style.setProperty("--window-accent-rgb",le):e.style.removeProperty("--window-accent-rgb"))},[le]);const Qe=I(!1),Ze=I(null),et=I(null),tt=I(null),[nt,rt]=K(!1),ot=I(null),it=!!(g||D||F)||nt,at=A(be),st=""!==A(Pt),lt=I(null);lt.current=Oe?{owner:Oe.key,tab:Oe.tab,root:!st}:null;const ct=ae||(Oe&&!st?Oe.key:null),dt=!!at&&!st&&at.enabled&&at.hasState&&(q||at.declaredEditable)&&!at.handMounted&&it&&!G&&!Q&&!Z&&!ue,ut=/* @__PURE__ */V(T,{name:"window",className:"h-4 w-4",strokeWidth:1.5}),ft=d&&R(d)?j(d,{className:`h-4 w-4 ${d.props?.className??""}`.trim()}):d??ut,wt=()=>/* @__PURE__ */V("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation();const t=e.currentTarget.getBoundingClientRect();$e(e=>e?null:{x:t.left,y:t.bottom+4})},className:"shrink-0 p-0.5 rounded hover:bg-gray-200/50 transition-colors",title:"Window menu",children:ft}),yt=40,{minimize:gt,items:bt,restoreIfMinimized:vt,openWindows:xt}=Re(),kt=I(`modal-${Math.random().toString(36).slice(2,8)}`).current;$(()=>{if(G)return Wn.add(kt),()=>{Wn.delete(kt)}},[G,kt]),$(()=>{const e=e=>{const t=e.detail;t?.id===kt&&Ce(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[kt]);const[Et,Mt]=K(M.window),St=function(e){const t=W(sr,ar);return pn.length<=1||t===e}(kt),Lt=function(e){return W(sr,()=>wn.has(e))}(kt),zt=W(hr,mr),At=W(br,vr),Dt=W(Cr,Mr),$t=!U&&!G,Kt=zt&&$t,[Ft,qt]=K(!1),Bt=Kt&&Dt===kt,[Ht,Ut]=K(!1),Xt=Ht&&$t&&At===kt?"picked":null,Vt=I(Kt);$(()=>{if(Vt.current&&!Kt){Ut(!0);const e=setTimeout(()=>{Ut(!1),yr===kt&&xr(null)},700);return Vt.current=Kt,()=>clearTimeout(e)}Vt.current=Kt},[Kt,kt]),$(()=>{Kt||qt(!1)},[Kt]),$(()=>{const e=et.current,t=tt.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>rt(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]),$(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&Ge.current){const t=Ge.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=et.current,n=tt.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const _t=I(!1),Jt=O(e,[]),Gt=O(()=>{const t=e(),n=ie?ie[0]:dn[h]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=mn[hn()],l=ie?Math.min(ie[1],i):(()=>{const e=("sm"===h?500:"md"===h?600:"lg"===h?700:"xl"===h?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*(pn.length-1),d=Math.max(yt,(i-l)/2),u=(o-a)/2,m=t.h-yt-l-d;return"top-right"===Y?{x:t.x+t.w-a-yt,y:t.y+yt,w:a,h:l}:"top-left"===Y?{x:t.x+yt,y:t.y+yt,w:a,h:l}:{x:t.x+Math.max(yt,(o-a)/2+yt)+Math.min(c,Math.max(0,u)),y:t.y+d+Math.min(c,Math.max(0,m)),w:a,h:l}},[h]),Zt=I(!1);t||(Zt.current=!1);const tn=ae||u||null;$(()=>{if(!t)return;Dn(kt,tn,lt.current??void 0),ae||$n(kt),_t.current=!1,Mt(ir(kt));const e=()=>{Mt(ir(kt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===ae;if(!e.label)return!1;const t=Ge.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if($n(kt),Mn.current)return;const t=Fn(),n=Math.min(An.current.w,t.w-40),o=Math.min(An.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;on({x:i,y:a,w:n,h:o}),zn(!1)},i=e=>{const t=e.detail;r(t)&&($n(kt),$e({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==ae)return;$n(kt);const t=An.current,n=function(e,t=Fn()){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=Ge.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)}on(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=pn.indexOf(e);-1!==t&&(pn.splice(t,1),xn()),wn.delete(e),gn.delete(e),Cn.delete(e);const n=En.get(e);n&&(En.delete(e),kn.delete(n))}(kt),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,kt,tn,Jt]);const nn=!G&&"maximized"===hn(),[rn,on]=K(()=>{if(tn&&Qt[tn]){const e={...Qt[tn]};return ie&&(e.w=ie[0],te||(e.h=ie[1])),Un(e)}return z?{x:z.x,y:z.y,w:z.w,h:z.h}:nn?Jt():Gt()}),[an,sn]=K(()=>!te),[ln,cn]=K(()=>r()),fn=I(ln),yn=I(null);$(()=>{const e=()=>{const e=r();e!==fn.current&&yn.current?.(e),fn.current=e,cn(e),Mt(ir(kt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[kt]);const bn=ln&&!!Oe?.tab&&!st&&!G&&!ue,vn=bn,Mn=I(vn);Mn.current=vn;const Sn=Nn(),Ln=ln&&!!Oe?.tab&&!G&&!ue&&!zt&&Sn!==Oe.key,[Tn,zn]=K(()=>tn&&Qt[tn]||z?vn:vn||nn),An=I(rn);An.current=rn;const Pn=I(Tn);P(()=>{Pn.current=Tn},[Tn]),P(()=>{if(an||bn)return;const e=Ge.current,t=Ze.current;if(!e||!t)return;const n=ne??(G?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 d=e.offsetHeight-t.offsetHeight,u=t.style.flex,h=t.style.overflowY,m=t.style.height;t.style.flex="0 0 auto",t.style.height="auto",t.style.overflowY="visible";const p=t.offsetHeight,f=c.offsetHeight;t.style.flex=u,t.style.height=m,t.style.overflowY=h;const w=c.offsetHeight>f+4,y=Math.max(n,window.innerHeight-r-Math.max(0,An.current.y)-24),g=w?Math.min(An.current.h,y):Math.min(Math.max(n,d+p),y),b=Math.abs(g-o)>1;b&&(o=g,on(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),G||(g<=n?i&&(clearTimeout(i),i=null):(b||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&sn(!0)},160)))},l=new ResizeObserver(s);s(),ot.current&&l.observe(ot.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[an,G,ne,it,bn]),P(()=>{if(!te||!an||G||!t)return;const e=ot.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||Tn)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=ne??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,An.current.y)-24);on(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[te,an,G,t,Tn,ne]);const In=!1!==re&&!G&&!Z&&!ue,[qn,jn]=K(()=>!In);P(()=>{if(qn||!t)return;if(!In||Tn)return void jn(!0);const n=Ge.current,r=Ze.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let i=An.current.w,c=0;const d=()=>jn(!0),u=()=>{c=0;const t=An.current;if(Math.abs(t.w-i)>1||document.body.classList.contains("rosh-gesturing"))return void d();const u=e(),h=u.w-80;if(t.w>=h)return void d();const m=[],p=[];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||(m.push(e),p.push(t))}if(!m.length)return;const f=Math.min(h,t.w+Math.max(...p)),w=f-t.w,y=n.style.width;n.style.width=`${f}px`;const g=m.map((e,t)=>({over:p[t],residual:e.scrollWidth-e.clientWidth}));n.style.width=y,g.forEach((e,t)=>{a(e,w)||o.add(m[t])});const b=s(t,l(t.w,w,g),u,yt);b!==t&&(i=b.w,on(b))};u();const h=new MutationObserver(()=>{c||(c=requestAnimationFrame(u))});h.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["style","class","hidden"]});const m=setTimeout(d,un);return()=>{h.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(m)}},[qn,t,In,Tn]);const Yn=I(null),Vn=!(!Oe?.tab||st||G||ue);yn.current=t=>{if(!Vn)return;if(t)return Yn.current||(Yn.current={box:{...An.current},maximized:Pn.current}),void(Pn.current=!0);const r=Yn.current;Yn.current=null;const o=e();if(r?.maximized)return Pn.current=!0,zn(!0),void on(o);const i=r?.box??(tn?Qt[tn]:void 0);if(Pn.current=!1,zn(!1),i&&!n(i,o,!1)){const e={...i};ie&&(e.w=ie[0],te||(e.h=ie[1])),on(Un(e))}else on(Gt())},$(()=>{vn&&(Pn.current=!0,zn(!0),on(Jt()))},[vn,Jt]),$(()=>{if(G)return;const e=()=>{const e=tn?Qt[tn]:void 0;if(Pn.current=!1,zn(!1),e){const t={...e};ie&&(t.w=ie[0],te||(t.h=ie[1])),on(Un(t))}else on(Gt())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[G,Gt,tn]),$(()=>{t&&tn&&!bn&&(Qt[tn]=rn,en()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[rn,t,tn,bn]),$(()=>{if(!t)return;const e=()=>{Pn.current?on(Jt()):document.body.classList.contains("rosh-gesturing")||on(Un)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return Tn&&(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,Tn,Jt]),$(()=>{if(t&&(ze(!1),Ae.current=!1,Je.current=!1,jn(!In),!Mn.current)){if(tn&&Qt[tn]){const e=Qt[tn];return void on(t=>Un({...e,...te?{h:t.h}:{},...In?{x:t.x,w:t.w}:{}}))}z&&(on({x:z.x,y:z.y,w:z.w,h:z.h}),zn(z.maximized))}},[t]),$(()=>{if(!t||"auto"!==m)return;let e;const n=t=>{Ge.current?.contains(t.target)&&!Ae.current&&(Ae.current=!0,e=setTimeout(()=>ze(!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,m]);const Gn="auto"===m?Te:!0===m,Qn=Oe&&!st?Oe.key:null,Zn=B(()=>Ct(Ee),[Ee]),tr=I({shortcutSpec:Ke,isOnDesktop:He,toggleDesktopShortcut:Ue,taskbarStrings:Me.taskbar});P(()=>{tr.current={shortcutSpec:Ke,isOnDesktop:He,toggleDesktopShortcut:Ue,taskbarStrings:Me.taskbar}});const cr=I(null);cr.current||(cr.current={open:(e,t)=>$e({x:e,y:t}),items:()=>{const e=tr.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of jt[kt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),$(()=>{t&&Qn&&function(e,t){const n=Nt.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.menu===t.menu||(Nt.set(e,t),Tt())}(Qn,{title:Zn.text||Se,dirty:Gn,copy:Zn.copy,menu:cr.current??void 0})},[t,Qn,Se,Gn,Zn.text,Zn.copy]),$(()=>{if(t&&Qn)return()=>{return e=Qn,void(Nt.delete(e)&&Tt());var e}},[t,Qn]),We(!(ae||!t)&&Gn);const dr=O(async()=>{if(!Je.current){if(Gn||"auto"===m&&Ae.current){Je.current=!0;const e=Se,t=await b({title:"Discard changes?",message:e?`“${e}” has unsaved changes. Are you sure you want to close? All changes will be lost.`:"You have unsaved changes. Are you sure you want to close? All changes will be lost.",confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"});if(Je.current=!1,!t)return}i()}},[Gn,m,i,Se]);P(()=>{if(!t||!ct)return;const e=e=>{e.detail?.windowKey===ct&&dr()};return window.addEventListener(lr,e),()=>window.removeEventListener(lr,e)},[t,ct,dr]);const ur=I(null),fr=O(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if($e(null),$n(kt),Mn.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=Ge.current,s=a?.getBoundingClientRect();let l,c,d,u;if(ur.current){const t=ur.current;ur.current=null,u=t.w,d=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=`${u}px`,a.style.height=`${d}px`,a.style.left=`${l}px`,a.style.top=`${c}px`)}else l=s?s.left:An.current.x,c=s?s.top:An.current.y,d=s?s.height:An.current.h,u=s?s.width:An.current.w;zn(!1),on(e=>({...e,x:l,y:c,w:u,h:d}));let h=null;const m=e=>{if(!r){if(Math.abs(e.clientX-o)<rr&&Math.abs(e.clientY-i)<rr)return;r=or(t,n,"move","move"),a&&(a.style.transition="none")}const s=l+e.clientX-o,d=Math.max(0,c+e.clientY-i);if(a&&(a.style.transform=`translate(${s-l}px, ${d-c}px)`),An.current={...An.current,x:s,y:d},!G){const t=function(e,t){const n=Fn(),r=e<=n.x+On,o=e>=n.x+n.w-On,i=t<=n.y+On,a=t>=n.y+n.h-On,s=e<=n.x+Rn,l=e>=n.x+n.w-Rn,c=t<=n.y+Rn,d=t>=n.y+n.h-Rn;return i&&s?"tl":i&&l?"tr":a&&s?"bl":a&&l?"br":c&&r?"tl":c&&o?"tr":d&&r?"bl":d&&o?"br":i?"top":r?"left":o?"right":null}(e.clientX,e.clientY);t!==h&&(h=t,t?_n(Xn(t)):Jn())}},p=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),r?.(),Jn();const e=Un({...An.current});if(An.current=e,!G&&h){ur.current={x:l,y:c,w:u,h:d};const e=Xn(h);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 on(e)}if(G){const t=e.x+e.w/2,n=window.innerWidth/2;_e(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),on(e)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",p)},[]),wr=O((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=Ge.current,l=s?.getBoundingClientRect(),c=l?l.left:An.current.x,d=l?l.top:An.current.y,u=l?l.width:An.current.w,h=l?l.height:An.current.h,m="sw"===t||"nw"===t||"w"===t,p="ne"===t||"nw"===t||"n"===t,f="se"===t||"ne"===t||"e"===t,w="se"===t||"sw"===t||"s"===t;zn(!1),on({x:c,y:d,w:u,h:h}),An.current={x:c,y:d,w:u,h:h};let y=0,g=null;const b=()=>{if(y=0,!g)return;const e=g;g=null,An.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`)},v=e=>{if(!o){if(Math.abs(e.clientX-i)<rr&&Math.abs(e.clientY-a)<rr)return;o=or(n,r,nr[t],"resize")}g=((e,t)=>{let n=c,r=d,o=u,i=h;if(f&&(o=Math.max(Bn,u+e)),w&&(i=Math.max(Hn,h+t)),m){const t=Math.max(Bn,u-e);n=c+u-t,o=t}if(p){const e=Math.max(Hn,h-t);r=d+h-e,i=e}return{x:n,y:r,w:o,h:i}})(e.clientX-i,e.clientY-a),y||(y=requestAnimationFrame(b))},x=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),y&&cancelAnimationFrame(y),b(),o?.(),on({...An.current})};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x)},[]),gr=O(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(),$n(kt),"Enter"===e.key)return void(Tn?(zn(!1),on(Gt())):(zn(!0),on(Jt())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{ur.current||(ur.current={...An.current})};if(r<0)return e(),zn(!0),void on(Jt());if(r>0){if(Tn)return zn(!1),void on(Gt());if(ur.current){const e=Un(ur.current);return ur.current=null,An.current=e,void on(e)}return void Kn(kt)}e(),zn(!1);const t=Xn(n<0?"left":"right");return An.current=t,void on(t)}if(Tn)return;const o=An.current,i=e.shiftKey?{...o,w:Math.max(Bn,o.w+24*n),h:Math.max(Hn,o.h+24*r)}:Un({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});An.current=i,on(i)},[kt,Tn,Gt,Jt]),kr=O(e=>{ur.current||(ur.current={...An.current}),zn(!1);const t=Xn(e);An.current=t,on(t),$n(kt)},[kt]),Er=vn||Kt?{}:{tabIndex:0,role:"group","aria-label":Se?`${Se} — ${Ne.windowSuffix}`:Ne.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:gr},Nr=()=>{zn(!0),on(Jt())},Sr=O(()=>{const e=Ge.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector(Wt);t&&!t.disabled&&t.click()}},[]);$(()=>{if(!t)return;if(G)return;const e=e=>{if(pn[pn.length-1]===kt&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),Sr();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&Ge.current?.contains(t)))return;if(t.closest(Ot))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Sr,kt,G]),$(()=>{if(!t)return;const e=e=>{pn[pn.length-1]===kt&&((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:kt}})),Ae.current=!1,ze(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:kt}}))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),$(()=>{if(!t)return;if(G)return;const e=e=>{if("Escape"===e.key&&pn[pn.length-1]===kt){if(N(e))return e.preventDefault(),void e.stopPropagation();if(bn&&!q)return;e.preventDefault(),e.stopPropagation(),dr()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,dr,kt,G,bn,q]);const Lr=t&&(void 0!==p||void 0!==y),Tr=O(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-white 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($(()=>{if(!t)return;const e=e=>{if(pn[pn.length-1]!==kt)return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&Lr&&(e.preventDefault(),p?p():Tr("bottom")),"k"===e.key&&Lr&&(e.preventDefault(),y?y():Tr("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,y,Lr,Tr,kt]),!t||Zt.current)return null;const zr=Kt?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,d=Fn(),u=(d.w-20*(o+1))/o,h=(d.h-14*(i+1)-22*i)/i,m=c?(o-l)*(u+20)/2:0;return{x:d.x+20+s*(u+20)+m,y:d.y+14+a*(h+14+22),w:u,h:h}}(kt):null,Ar=Kt&&zr?Math.min(zr.w/rn.w,zr.h/rn.h):1,Dr=(()=>{if(Kt&&zr){const e=Ar,t=rn.w*e,n=rn.h*e,r=zr.x+(zr.w-t)/2-rn.x,o=zr.y+(zr.h-n)/2-rn.y,i=Ft||Bt;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:M.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(Ht&&$t){const e="picked"===Xt;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:M.expose+30}:{}}}return null})(),Pr=v({modal:!1,titleId:!G&&(bn?!Oe?.home:!ue)?Le:void 0,label:Zn.text||Se}),Ir=/* @__PURE__ */X("div",{children:[
50
- /* @__PURE__ */X("div",{ref:Ge,"data-modal-panel":!0,"data-modal-id":kt,"data-window-key":ae||void 0,...U?{"data-utility":""}:{},...De?{"data-pinned-top":""}:{},...G?{"data-widget":""}:{},...Oe?{"data-window-owner":Oe.key}:{},...Oe&&!st?{"data-window-root":""}:{},...bn?{"data-window-tab":""}:{},...Pr,className:bn?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(G?St?"shadow-xl":"shadow-lg":"border "+(St?"shadow-xl border-gray-200":"shadow-lg border-gray-300")),onMouseDownCapture:e=>{if(Qe.current=!1,Kt){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),xr(kt),pr(!1),void $n(kt)}if(!St&&!G&&!De&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===Ge.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),Qe.current=!0,$e(null),$n(kt),window.addEventListener("mouseup",()=>{setTimeout(()=>{Qe.current=!1},0)},{once:!0}))}},onClickCapture:e=>{Qe.current&&(Qe.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if(Kt)return;$e(null);e.target.closest("[data-modal-panel]")===Ge.current&&(e.target.closest("button, input, a, select, textarea")||$n(kt))},style:ue?{zIndex:Et+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${he}px)`,transition:pe?"none":"transform 180ms ease-out",...G?{display:"none"}:{},...Et<0?{display:"none"}:{},...St||De||ke&&ae===ke?{}:{display:"none"}}:{zIndex:De?M.pinnedWindow:Et+1,width:rn.w,height:rn.h,top:rn.y,...G&&"right"===Ve?{right:window.innerWidth-rn.x-rn.w}:{left:rn.x},...Et<0&&!De?{display:"none"}:{},...Ln?{visibility:"hidden",pointerEvents:"none"}:{},...Dr??{}},children:[ue&&!G&&/* @__PURE__ */V("div",{onPointerDown:ve,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),G?null:bn?Oe?.home?null:/* @__PURE__ */X(_,{children:[
48
+ /* @__PURE__ */V("button",{onClick:t,onFocus:c,onBlur:d,title:e?o.windowed:o.maximize,className:r,children:e?"❐":"⤢"}),i&&/* @__PURE__ */V("div",{role:"group","aria-label":o.snapLayouts,onMouseEnter:()=>clearTimeout(l.current),onMouseLeave:d,className:"absolute right-0 top-full z-30 mt-1 grid w-max grid-cols-2 gap-1 rounded-lg border border-gray-200 bg-white p-2 shadow-lg",children:Jn.map(({zone:e,labelKey:t,region:r})=>/* @__PURE__ */V("button",{type:"button","aria-label":o[t],title:o[t],onClick:()=>{a(!1),n(e)},onFocus:()=>clearTimeout(l.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__ */V("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var tr="rosh-gesture-style";var nr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},rr=4;function or(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(tr))return;const e=document.createElement("style");e.id=tr,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=vt(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function ir(e){const t=pn.indexOf(e);if(-1===t)return-1;const n=M.window+t*M.windowStep,o=Cn.get(e);if(!o||o.root||!o.tab||!r())return n;let i=-1;for(const[e,t]of Cn){if(!t.root||t.owner!==o.owner)continue;const n=pn.indexOf(e);-1!==n&&(i=Math.max(i,M.window+n*M.windowStep))}return i>=n?i+2+Math.min(t,7):n}function ar(){return pn[pn.length-1]||null}function sr(e){return fn.add(e),()=>{fn.delete(e)}}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=pn.length-1;e>=0;e--)Wn.has(pn[e])||pn.splice(e,1);nn=nn.filter(e=>{const t=kn.get(e);return null!=t&&Wn.has(t)}),on(),xn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var lr="modal-close-request";function cr(e){W(sr,vn);const t=A(Ut);if(pn.length<=1)return!0;if(e){const t=kn.get(e);if(null!=t)return ar()===t}return t?.active??null!=ar()}var dr=!1,ur=/* @__PURE__ */new Set;function hr(e){return ur.add(e),()=>ur.delete(e)}function mr(){return dr}function pr(e){dr!==e&&(dr=e,ur.forEach(e=>e()))}function fr(){pr(!dr)}function wr(){pr(!1)}var yr=null,gr=/* @__PURE__ */new Set;function br(e){return gr.add(e),()=>gr.delete(e)}function vr(){return yr}function xr(e){yr!==e&&(yr=e,gr.forEach(e=>e()))}var kr=null,Er=/* @__PURE__ */new Set;function Cr(e){return Er.add(e),()=>Er.delete(e)}function Mr(){return kr}function Nr(e){kr!==e&&(kr=e,Er.forEach(e=>e()))}function Sr(){if(!kr)return void pr(!1);xr(kr),Nr(null),pr(!1)}function Lr(){pr(!dr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function Tr(){const e=W(hr,mr),[t,n]=$(e),[r,o]=$(e);return K(()=>{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?G(
49
+ /* @__PURE__ */V("div",{onMouseDown:e=>{e.stopPropagation(),pr(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:M.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 zr({open:t,onClose:i,title:c,icon:d,copyText:u,size:h="lg",dirty:m=!1,onNext:p,onPrev:y,footer:g,bodyScroll:C,onMinimize:S,initialBox:z,actions:D,actionsLeft:F,editing:q=!1,allowPinOnTop:Y,initialPosition:U,widget:J,compact:Q,appStyle:Z,flushBody:ee,autoHeight:te,autoMinHeight:ne,autoWidth:re,widgetMenu:oe,dimensions:ie,windowKey:ae,openedFromKey:se,accentRgb:le,children:ce}){const ue=f(),[he,me]=$(0),[pe,fe]=$(!1),we=I(null),ye=I(0);K(()=>{ye.current=he},[he]);const ve=O(e=>{ue&&(we.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},fe(!0),mt(se??null))},[ue,se]),ke=W(pt,ht);K(()=>{if(!pe)return;const e=e=>{if(!we.current)return;const t=e.clientX-we.current.startX;if(Math.abs(e.clientY-we.current.startY)>Math.abs(t)+12)return we.current=null,fe(!1),me(0),void mt(null);me(Math.max(0,t))},t=()=>{if(!we.current)return;const e=.3*window.innerWidth,t=ye.current>e;we.current=null,fe(!1),t?(me(window.innerWidth),setTimeout(()=>{i(),me(0),mt(null)},180)):(me(0),mt(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)}},[pe]);const[Ee,Ce]=$(c),Me=L(),Ne=Me.window;K(()=>{Ce(c)},[c]);const Se=B(()=>Rt(Ee).trim()||void 0,[Ee]),Le=H(),[Te,ze]=$(!1),Ae=I(!1),[De,Pe]=$(!1),[Ie,Ke]=$(null),$e=A(It),Oe=A(de),{prefs:Fe,save:qe}=w(),je=!!Fe.window_accent_stripe,Be=Fe.favorite_documents||[],He=!!$e&&Be.some(e=>e.entityType===$e.entityType&&e.entityId===$e.entityId),Ye=O(()=>{if(!$e)return;const e=He?Be.filter(e=>!(e.entityType===$e.entityType&&e.entityId===$e.entityId)):[...Be,{entityType:$e.entityType,entityId:$e.entityId,label:$e.label}];qe({favorite_documents:e})},[$e,He,Be,qe]),[Ue,Xe]=$(null),[Ve,_e]=$("top-right"===U?"right":"left"),Ge=I(!1),Je=I(null);P(()=>{const e=Je.current;e&&(le?e.style.setProperty("--window-accent-rgb",le):e.style.removeProperty("--window-accent-rgb"))},[le]);const Qe=I(!1),Ze=I(null),et=I(null),tt=I(null),[nt,rt]=$(!1),ot=I(null),it=!!(g||D||F)||nt,at=A(be),st=""!==A(Pt),lt=I(null);lt.current=Oe?{owner:Oe.key,tab:Oe.tab,root:!st}:null;const ct=ae||(Oe&&!st?Oe.key:null),dt=!!at&&!st&&at.enabled&&at.hasState&&(q||at.declaredEditable)&&!at.handMounted&&it&&!J&&!Q&&!Z&&!ue,ut=/* @__PURE__ */V(T,{name:"window",className:"h-4 w-4",strokeWidth:1.5}),ft=d&&R(d)?j(d,{className:`h-4 w-4 ${d.props?.className??""}`.trim()}):d??ut,wt=()=>/* @__PURE__ */V("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation();const t=e.currentTarget.getBoundingClientRect();Ke(e=>e?null:{x:t.left,y:t.bottom+4})},className:"shrink-0 p-0.5 rounded hover:bg-gray-200/50 transition-colors",title:"Window menu",children:ft}),yt=40,{minimize:gt,items:bt,restoreIfMinimized:vt,openWindows:xt}=Re(),kt=I(`modal-${Math.random().toString(36).slice(2,8)}`).current;K(()=>{if(J)return Wn.add(kt),()=>{Wn.delete(kt)}},[J,kt]),K(()=>{const e=e=>{const t=e.detail;t?.id===kt&&Ce(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[kt]);const[Et,Mt]=$(M.window),St=function(e){const t=W(sr,ar);return pn.length<=1||t===e}(kt),Lt=function(e){return W(sr,()=>wn.has(e))}(kt),zt=W(hr,mr),At=W(br,vr),Dt=W(Cr,Mr),Kt=!Y&&!J,$t=zt&&Kt,[Ft,qt]=$(!1),Bt=$t&&Dt===kt,[Ht,Yt]=$(!1),Xt=Ht&&Kt&&At===kt?"picked":null,Vt=I($t);K(()=>{if(Vt.current&&!$t){Yt(!0);const e=setTimeout(()=>{Yt(!1),yr===kt&&xr(null)},700);return Vt.current=$t,()=>clearTimeout(e)}Vt.current=$t},[$t,kt]),K(()=>{$t||qt(!1)},[$t]),K(()=>{const e=et.current,t=tt.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>rt(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]),K(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&Je.current){const t=Je.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=et.current,n=tt.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const _t=I(!1),Gt=O(e,[]),Jt=O(()=>{const t=e(),n=ie?ie[0]:dn[h]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=mn[hn()],l=ie?Math.min(ie[1],i):(()=>{const e=("sm"===h?500:"md"===h?600:"lg"===h?700:"xl"===h?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*(pn.length-1),d=Math.max(yt,(i-l)/2),u=(o-a)/2,m=t.h-yt-l-d;return"top-right"===U?{x:t.x+t.w-a-yt,y:t.y+yt,w:a,h:l}:"top-left"===U?{x:t.x+yt,y:t.y+yt,w:a,h:l}:{x:t.x+Math.max(yt,(o-a)/2+yt)+Math.min(c,Math.max(0,u)),y:t.y+d+Math.min(c,Math.max(0,m)),w:a,h:l}},[h]),Zt=I(!1);t||(Zt.current=!1);const tn=ae||u||null;K(()=>{if(!t)return;Dn(kt,tn,lt.current??void 0),ae||Kn(kt),_t.current=!1,Mt(ir(kt));const e=()=>{Mt(ir(kt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===ae;if(!e.label)return!1;const t=Je.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if(Kn(kt),Mn.current)return;const t=Fn(),n=Math.min(An.current.w,t.w-40),o=Math.min(An.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;on({x:i,y:a,w:n,h:o}),zn(!1)},i=e=>{const t=e.detail;r(t)&&(Kn(kt),Ke({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==ae)return;Kn(kt);const t=An.current,n=function(e,t=Fn()){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=Je.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)}on(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=pn.indexOf(e);-1!==t&&(pn.splice(t,1),xn()),wn.delete(e),gn.delete(e),Cn.delete(e);const n=En.get(e);n&&(En.delete(e),kn.delete(n))}(kt),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,kt,tn,Gt]);const nn=!J&&"maximized"===hn(),[rn,on]=$(()=>{if(tn&&Qt[tn]){const e={...Qt[tn]};return ie&&(e.w=ie[0],te||(e.h=ie[1])),Yn(e)}return z?{x:z.x,y:z.y,w:z.w,h:z.h}:nn?Gt():Jt()}),[an,sn]=$(()=>!te),[ln,cn]=$(()=>r()),fn=I(ln),yn=I(null);K(()=>{const e=()=>{const e=r();e!==fn.current&&yn.current?.(e),fn.current=e,cn(e),Mt(ir(kt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[kt]);const bn=ln&&!!Oe?.tab&&!st&&!J&&!ue,vn=bn,Mn=I(vn);Mn.current=vn;const Sn=Nn(),Ln=ln&&!!Oe?.tab&&!J&&!ue&&!zt&&Sn!==Oe.key,[Tn,zn]=$(()=>tn&&Qt[tn]||z?vn:vn||nn),An=I(rn);An.current=rn;const Pn=I(Tn);P(()=>{Pn.current=Tn},[Tn]),P(()=>{if(an||bn)return;const e=Je.current,t=Ze.current;if(!e||!t)return;const n=ne??(J?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 d=e.offsetHeight-t.offsetHeight,u=t.style.flex,h=t.style.overflowY,m=t.style.height;t.style.flex="0 0 auto",t.style.height="auto",t.style.overflowY="visible";const p=t.offsetHeight,f=c.offsetHeight;t.style.flex=u,t.style.height=m,t.style.overflowY=h;const w=c.offsetHeight>f+4,y=Math.max(n,window.innerHeight-r-Math.max(0,An.current.y)-24),g=w?Math.min(An.current.h,y):Math.min(Math.max(n,d+p),y),b=Math.abs(g-o)>1;b&&(o=g,on(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),J||(g<=n?i&&(clearTimeout(i),i=null):(b||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&sn(!0)},160)))},l=new ResizeObserver(s);s(),ot.current&&l.observe(ot.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[an,J,ne,it,bn]),P(()=>{if(!te||!an||J||!t)return;const e=ot.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||Tn)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=ne??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,An.current.y)-24);on(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[te,an,J,t,Tn,ne]);const In=!1!==re&&!J&&!Z&&!ue,[qn,jn]=$(()=>!In);P(()=>{if(qn||!t)return;if(!In||Tn)return void jn(!0);const n=Je.current,r=Ze.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let i=An.current.w,c=0;const d=()=>jn(!0),u=()=>{c=0;const t=An.current;if(Math.abs(t.w-i)>1||document.body.classList.contains("rosh-gesturing"))return void d();const u=e(),h=u.w-80;if(t.w>=h)return void d();const m=[],p=[];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||(m.push(e),p.push(t))}if(!m.length)return;const f=Math.min(h,t.w+Math.max(...p)),w=f-t.w,y=n.style.width;n.style.width=`${f}px`;const g=m.map((e,t)=>({over:p[t],residual:e.scrollWidth-e.clientWidth}));n.style.width=y,g.forEach((e,t)=>{a(e,w)||o.add(m[t])});const b=s(t,l(t.w,w,g),u,yt);b!==t&&(i=b.w,on(b))};u();const h=new MutationObserver(()=>{c||(c=requestAnimationFrame(u))});h.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["style","class","hidden"]});const m=setTimeout(d,un);return()=>{h.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(m)}},[qn,t,In,Tn]);const Un=I(null),Vn=!(!Oe?.tab||st||J||ue);yn.current=t=>{if(!Vn)return;if(t)return Un.current||(Un.current={box:{...An.current},maximized:Pn.current}),void(Pn.current=!0);const r=Un.current;Un.current=null;const o=e();if(r?.maximized)return Pn.current=!0,zn(!0),void on(o);const i=r?.box??(tn?Qt[tn]:void 0);if(Pn.current=!1,zn(!1),i&&!n(i,o,!1)){const e={...i};ie&&(e.w=ie[0],te||(e.h=ie[1])),on(Yn(e))}else on(Jt())},K(()=>{vn&&(Pn.current=!0,zn(!0),on(Gt()))},[vn,Gt]),K(()=>{if(J)return;const e=()=>{const e=tn?Qt[tn]:void 0;if(Pn.current=!1,zn(!1),e){const t={...e};ie&&(t.w=ie[0],te||(t.h=ie[1])),on(Yn(t))}else on(Jt())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[J,Jt,tn]),K(()=>{t&&tn&&!bn&&(Qt[tn]=rn,en()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[rn,t,tn,bn]),K(()=>{if(!t)return;const e=()=>{Pn.current?on(Gt()):document.body.classList.contains("rosh-gesturing")||on(Yn)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return Tn&&(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,Tn,Gt]),K(()=>{if(t&&(ze(!1),Ae.current=!1,Ge.current=!1,jn(!In),!Mn.current)){if(tn&&Qt[tn]){const e=Qt[tn];return void on(t=>Yn({...e,...te?{h:t.h}:{},...In?{x:t.x,w:t.w}:{}}))}z&&(on({x:z.x,y:z.y,w:z.w,h:z.h}),zn(z.maximized))}},[t]),K(()=>{if(!t||"auto"!==m)return;let e;const n=t=>{Je.current?.contains(t.target)&&!Ae.current&&(Ae.current=!0,e=setTimeout(()=>ze(!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,m]);const Jn="auto"===m?Te:!0===m,Qn=Oe&&!st?Oe.key:null,Zn=B(()=>Ct(Ee),[Ee]),tr=I({shortcutSpec:$e,isOnDesktop:He,toggleDesktopShortcut:Ye,taskbarStrings:Me.taskbar});P(()=>{tr.current={shortcutSpec:$e,isOnDesktop:He,toggleDesktopShortcut:Ye,taskbarStrings:Me.taskbar}});const cr=I(null);cr.current||(cr.current={open:(e,t)=>Ke({x:e,y:t}),items:()=>{const e=tr.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of jt[kt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),K(()=>{t&&Qn&&function(e,t){const n=Nt.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.menu===t.menu||(Nt.set(e,t),Tt())}(Qn,{title:Zn.text||Se,dirty:Jn,copy:Zn.copy,menu:cr.current??void 0})},[t,Qn,Se,Jn,Zn.text,Zn.copy]),K(()=>{if(t&&Qn)return()=>{return e=Qn,void(Nt.delete(e)&&Tt());var e}},[t,Qn]),We(!(ae||!t)&&Jn);const dr=O(async()=>{if(!Ge.current){if(Jn||"auto"===m&&Ae.current){Ge.current=!0;const e=Se,t=await b({title:"Discard changes?",message:e?`“${e}” has unsaved changes. Are you sure you want to close? All changes will be lost.`:"You have unsaved changes. Are you sure you want to close? All changes will be lost.",confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"});if(Ge.current=!1,!t)return}i()}},[Jn,m,i,Se]);P(()=>{if(!t||!ct)return;const e=e=>{e.detail?.windowKey===ct&&dr()};return window.addEventListener(lr,e),()=>window.removeEventListener(lr,e)},[t,ct,dr]);const ur=I(null),fr=O(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if(Ke(null),Kn(kt),Mn.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=Je.current,s=a?.getBoundingClientRect();let l,c,d,u;if(ur.current){const t=ur.current;ur.current=null,u=t.w,d=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=`${u}px`,a.style.height=`${d}px`,a.style.left=`${l}px`,a.style.top=`${c}px`)}else l=s?s.left:An.current.x,c=s?s.top:An.current.y,d=s?s.height:An.current.h,u=s?s.width:An.current.w;zn(!1),on(e=>({...e,x:l,y:c,w:u,h:d}));let h=null;const m=e=>{if(!r){if(Math.abs(e.clientX-o)<rr&&Math.abs(e.clientY-i)<rr)return;r=or(t,n,"move","move"),a&&(a.style.transition="none")}const s=l+e.clientX-o,d=Math.max(0,c+e.clientY-i);if(a&&(a.style.transform=`translate(${s-l}px, ${d-c}px)`),An.current={...An.current,x:s,y:d},!J){const t=function(e,t){const n=Fn(),r=e<=n.x+On,o=e>=n.x+n.w-On,i=t<=n.y+On,a=t>=n.y+n.h-On,s=e<=n.x+Rn,l=e>=n.x+n.w-Rn,c=t<=n.y+Rn,d=t>=n.y+n.h-Rn;return i&&s?"tl":i&&l?"tr":a&&s?"bl":a&&l?"br":c&&r?"tl":c&&o?"tr":d&&r?"bl":d&&o?"br":i?"top":r?"left":o?"right":null}(e.clientX,e.clientY);t!==h&&(h=t,t?_n(Xn(t)):Gn())}},p=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),r?.(),Gn();const e=Yn({...An.current});if(An.current=e,!J&&h){ur.current={x:l,y:c,w:u,h:d};const e=Xn(h);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 on(e)}if(J){const t=e.x+e.w/2,n=window.innerWidth/2;_e(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),on(e)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",p)},[]),wr=O((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=Je.current,l=s?.getBoundingClientRect(),c=l?l.left:An.current.x,d=l?l.top:An.current.y,u=l?l.width:An.current.w,h=l?l.height:An.current.h,m="sw"===t||"nw"===t||"w"===t,p="ne"===t||"nw"===t||"n"===t,f="se"===t||"ne"===t||"e"===t,w="se"===t||"sw"===t||"s"===t;zn(!1),on({x:c,y:d,w:u,h:h}),An.current={x:c,y:d,w:u,h:h};let y=0,g=null;const b=()=>{if(y=0,!g)return;const e=g;g=null,An.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`)},v=e=>{if(!o){if(Math.abs(e.clientX-i)<rr&&Math.abs(e.clientY-a)<rr)return;o=or(n,r,nr[t],"resize")}g=((e,t)=>{let n=c,r=d,o=u,i=h;if(f&&(o=Math.max(Bn,u+e)),w&&(i=Math.max(Hn,h+t)),m){const t=Math.max(Bn,u-e);n=c+u-t,o=t}if(p){const e=Math.max(Hn,h-t);r=d+h-e,i=e}return{x:n,y:r,w:o,h:i}})(e.clientX-i,e.clientY-a),y||(y=requestAnimationFrame(b))},x=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),y&&cancelAnimationFrame(y),b(),o?.(),on({...An.current})};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x)},[]),gr=O(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(),Kn(kt),"Enter"===e.key)return void(Tn?(zn(!1),on(Jt())):(zn(!0),on(Gt())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{ur.current||(ur.current={...An.current})};if(r<0)return e(),zn(!0),void on(Gt());if(r>0){if(Tn)return zn(!1),void on(Jt());if(ur.current){const e=Yn(ur.current);return ur.current=null,An.current=e,void on(e)}return void $n(kt)}e(),zn(!1);const t=Xn(n<0?"left":"right");return An.current=t,void on(t)}if(Tn)return;const o=An.current,i=e.shiftKey?{...o,w:Math.max(Bn,o.w+24*n),h:Math.max(Hn,o.h+24*r)}:Yn({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});An.current=i,on(i)},[kt,Tn,Jt,Gt]),kr=O(e=>{ur.current||(ur.current={...An.current}),zn(!1);const t=Xn(e);An.current=t,on(t),Kn(kt)},[kt]),Er=vn||$t?{}:{tabIndex:0,role:"group","aria-label":Se?`${Se} — ${Ne.windowSuffix}`:Ne.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:gr},Nr=()=>{zn(!0),on(Gt())},Sr=O(()=>{const e=Je.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector(Wt);t&&!t.disabled&&t.click()}},[]);K(()=>{if(!t)return;if(J)return;const e=e=>{if(pn[pn.length-1]===kt&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),Sr();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&Je.current?.contains(t)))return;if(t.closest(Ot))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Sr,kt,J]),K(()=>{if(!t)return;const e=e=>{pn[pn.length-1]===kt&&((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:kt}})),Ae.current=!1,ze(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:kt}}))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),K(()=>{if(!t)return;if(J)return;const e=e=>{if("Escape"===e.key&&pn[pn.length-1]===kt){if(N(e))return e.preventDefault(),void e.stopPropagation();if(bn&&!q)return;e.preventDefault(),e.stopPropagation(),dr()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,dr,kt,J,bn,q]);const Lr=t&&(void 0!==p||void 0!==y),Tr=O(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-white 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(K(()=>{if(!t)return;const e=e=>{if(pn[pn.length-1]!==kt)return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&Lr&&(e.preventDefault(),p?p():Tr("bottom")),"k"===e.key&&Lr&&(e.preventDefault(),y?y():Tr("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,y,Lr,Tr,kt]),!t||Zt.current)return null;const zr=$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,d=Fn(),u=(d.w-20*(o+1))/o,h=(d.h-14*(i+1)-22*i)/i,m=c?(o-l)*(u+20)/2:0;return{x:d.x+20+s*(u+20)+m,y:d.y+14+a*(h+14+22),w:u,h:h}}(kt):null,Ar=$t&&zr?Math.min(zr.w/rn.w,zr.h/rn.h):1,Dr=(()=>{if($t&&zr){const e=Ar,t=rn.w*e,n=rn.h*e,r=zr.x+(zr.w-t)/2-rn.x,o=zr.y+(zr.h-n)/2-rn.y,i=Ft||Bt;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:M.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(Ht&&Kt){const e="picked"===Xt;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:M.expose+30}:{}}}return null})(),Pr=v({modal:!1,titleId:!J&&(bn?!Oe?.home:!ue)?Le:void 0,label:Zn.text||Se}),Ir=/* @__PURE__ */X("div",{children:[
50
+ /* @__PURE__ */X("div",{ref:Je,"data-modal-panel":!0,"data-modal-id":kt,"data-window-key":ae||void 0,...Y?{"data-utility":""}:{},...De?{"data-pinned-top":""}:{},...J?{"data-widget":""}:{},...Oe?{"data-window-owner":Oe.key}:{},...Oe&&!st?{"data-window-root":""}:{},...bn?{"data-window-tab":""}:{},...Pr,className:bn?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(J?St?"shadow-xl":"shadow-lg":"border "+(St?"shadow-xl border-gray-200":"shadow-lg border-gray-300")),onMouseDownCapture:e=>{if(Qe.current=!1,$t){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),xr(kt),pr(!1),void Kn(kt)}if(!St&&!J&&!De&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===Je.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),Qe.current=!0,Ke(null),Kn(kt),window.addEventListener("mouseup",()=>{setTimeout(()=>{Qe.current=!1},0)},{once:!0}))}},onClickCapture:e=>{Qe.current&&(Qe.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if($t)return;Ke(null);e.target.closest("[data-modal-panel]")===Je.current&&(e.target.closest("button, input, a, select, textarea")||Kn(kt))},style:ue?{zIndex:Et+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${he}px)`,transition:pe?"none":"transform 180ms ease-out",...J?{display:"none"}:{},...Et<0?{display:"none"}:{},...St||De||ke&&ae===ke?{}:{display:"none"}}:{zIndex:De?M.pinnedWindow:Et+1,width:rn.w,height:rn.h,top:rn.y,...J&&"right"===Ve?{right:window.innerWidth-rn.x-rn.w}:{left:rn.x},...Et<0&&!De?{display:"none"}:{},...Ln?{visibility:"hidden",pointerEvents:"none"}:{},...Dr??{}},children:[ue&&!J&&/* @__PURE__ */V("div",{onPointerDown:ve,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),J?null:bn?Oe?.home?null:/* @__PURE__ */X(_,{children:[
51
51
  /* @__PURE__ */V("h2",{id:Le,"data-window-title":!0,className:"sr-only",children:Zn.text||Se}),(Zn.accessories.length>0||Lr)&&/* @__PURE__ */X("div",{"data-window-chrome":"","data-record-bar":"",className:"flex h-9 shrink-0 select-none items-center gap-3 border-b border-gray-200 px-4",style:{backgroundColor:"rgb(var(--window-content-rgb))"},children:[
52
52
  /* @__PURE__ */V("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:Zn.accessories}),Lr&&/* @__PURE__ */X("span",{className:"flex items-center gap-1 shrink-0 text-2xs text-gray-400",children:[
53
53
  /* @__PURE__ */V("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-2 py-0.5 font-medium text-gray-500",children:"K"}),
@@ -55,23 +55,23 @@ return X("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:d,
55
55
  /* @__PURE__ */V("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-2 py-0.5 font-medium ml-1 text-gray-500",children:"J"}),
56
56
  /* @__PURE__ */V("span",{children:Ne.next})]})]})]}):ue?null:
57
57
  /* @__PURE__ */X("div",Q?{onPointerDown:fr,"data-window-chrome":"",...Er,className:"flex items-center justify-between h-(--row-height-compact-bar) px-3 border-b border-gray-200 shrink-0 cursor-move select-none rounded-t-(--radius-window) focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400 "+(St?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:St?"rgb(var(--window-header-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-header-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
58
- /* @__PURE__ */X("div",{"data-window-title":!0,title:Se,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:St?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!Kt&&wt(),
59
- /* @__PURE__ */V("span",{id:Le,className:"truncate",children:Kt?Rt(Ee):Ee})]}),!Kt&&/* @__PURE__ */X("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[U&&/* @__PURE__ */V("button",{onClick:()=>Pe(e=>!e),title:De?Ne.unpin:Ne.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(De?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */V(T,{name:"bookmark-square",className:"h-3 w-3",fill:De?"currentColor":"none",strokeWidth:1.5})}),
58
+ /* @__PURE__ */X("div",{"data-window-title":!0,title:Se,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:St?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!$t&&wt(),
59
+ /* @__PURE__ */V("span",{id:Le,className:"truncate",children:$t?Rt(Ee):Ee})]}),!$t&&/* @__PURE__ */X("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[Y&&/* @__PURE__ */V("button",{onClick:()=>Pe(e=>!e),title:De?Ne.unpin:Ne.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(De?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */V(T,{name:"bookmark-square",className:"h-3 w-3",fill:De?"currentColor":"none",strokeWidth:1.5})}),
60
60
  /* @__PURE__ */V("button",{type:"button",onClick:dr,className:"rounded p-0.5 text-gray-400 hover:text-gray-600 hover:bg-gray-200",children:/* @__PURE__ */V(T,{name:"close",className:"h-4 w-4"})})]})]}:Z?{onPointerDown:fr,"data-window-chrome":"",...Er,className:"flex items-center justify-between h-(--row-height-compact-bar) px-3 border-b border-gray-200 shrink-0 cursor-move select-none rounded-t-(--radius-window) focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400 "+(St?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:St?"rgb(var(--window-header-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-header-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
61
- /* @__PURE__ */X("div",{"data-window-title":!0,title:Se,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:St?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!Kt&&wt(),
62
- /* @__PURE__ */V("span",{id:Le,className:"truncate",children:Kt?Rt(Ee):Ee})]}),!Kt&&/* @__PURE__ */X("div",{className:"flex items-center gap-0.5 shrink-0 ml-2",children:[U&&/* @__PURE__ */V("button",{onClick:()=>Pe(e=>!e),title:De?Ne.unpin:Ne.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(De?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */V(T,{name:"bookmark-square",className:"h-3 w-3",fill:De?"currentColor":"none",strokeWidth:1.5})}),
63
- /* @__PURE__ */V("button",{onClick:()=>Kn(kt),title:Ne.minimize,className:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",children:"─"}),!vn&&/* @__PURE__ */V(er,{maximized:Tn,onToggleMax:()=>{Tn?(zn(!1),on(Gt())):Nr()},onSnap:kr,buttonClassName:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",strings:Ne}),
61
+ /* @__PURE__ */X("div",{"data-window-title":!0,title:Se,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:St?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!$t&&wt(),
62
+ /* @__PURE__ */V("span",{id:Le,className:"truncate",children:$t?Rt(Ee):Ee})]}),!$t&&/* @__PURE__ */X("div",{className:"flex items-center gap-0.5 shrink-0 ml-2",children:[Y&&/* @__PURE__ */V("button",{onClick:()=>Pe(e=>!e),title:De?Ne.unpin:Ne.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(De?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */V(T,{name:"bookmark-square",className:"h-3 w-3",fill:De?"currentColor":"none",strokeWidth:1.5})}),
63
+ /* @__PURE__ */V("button",{onClick:()=>$n(kt),title:Ne.minimize,className:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",children:"─"}),!vn&&/* @__PURE__ */V(er,{maximized:Tn,onToggleMax:()=>{Tn?(zn(!1),on(Jt())):Nr()},onSnap:kr,buttonClassName:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",strings:Ne}),
64
64
  /* @__PURE__ */V("button",{type:"button",onClick:dr,className:"rounded p-0.5 text-gray-400 hover:text-gray-600 hover:bg-gray-200",children:/* @__PURE__ */V(T,{name:"close",className:"h-4 w-4"})})]})]}:{onPointerDown:fr,"data-window-chrome":"",...Er,className:"flex items-center justify-between h-(--row-height-window-bar) px-4 border-b border-gray-200 shrink-0 cursor-move select-none rounded-t-(--radius-window) focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400 "+(St?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:St?"rgb(var(--window-header-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-header-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
65
- /* @__PURE__ */X("div",{"data-window-title":!0,title:Se,className:"text-base font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:St?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!Kt&&wt(),
66
- /* @__PURE__ */V("span",{id:Le,className:"truncate",children:Kt?Rt(Ee):Ee})]}),!Kt&&/* @__PURE__ */X("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:[Lr&&/* @__PURE__ */X("span",{className:"flex items-center gap-1 mr-1 text-2xs text-gray-400",children:[
65
+ /* @__PURE__ */X("div",{"data-window-title":!0,title:Se,className:"text-base font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:St?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!$t&&wt(),
66
+ /* @__PURE__ */V("span",{id:Le,className:"truncate",children:$t?Rt(Ee):Ee})]}),!$t&&/* @__PURE__ */X("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:[Lr&&/* @__PURE__ */X("span",{className:"flex items-center gap-1 mr-1 text-2xs text-gray-400",children:[
67
67
  /* @__PURE__ */V("kbd",{className:"rounded border border-gray-300 bg-gray-200 px-2 py-0.5 font-medium text-gray-500",children:"K"}),
68
68
  /* @__PURE__ */V("span",{children:Ne.prev}),
69
69
  /* @__PURE__ */V("kbd",{className:"rounded border border-gray-300 bg-gray-200 px-2 py-0.5 font-medium ml-1 text-gray-500",children:"J"}),
70
- /* @__PURE__ */V("span",{children:Ne.next})]}),U&&/* @__PURE__ */V("button",{onClick:()=>Pe(e=>!e),title:De?Ne.unpin:Ne.pinOnTop,className:"text-xs px-2 py-1 rounded hover:bg-gray-200 "+(De?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */V(T,{name:"bookmark-square",className:"h-3.5 w-3.5",fill:De?"currentColor":"none",strokeWidth:1.5})}),
71
- /* @__PURE__ */V("button",{onClick:()=>Kn(kt),title:Ne.minimize,className:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",children:"─"}),!vn&&/* @__PURE__ */V(er,{maximized:Tn,onToggleMax:()=>{Tn?(zn(!1),on(Gt())):Nr()},onSnap:kr,buttonClassName:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",strings:Ne}),
70
+ /* @__PURE__ */V("span",{children:Ne.next})]}),Y&&/* @__PURE__ */V("button",{onClick:()=>Pe(e=>!e),title:De?Ne.unpin:Ne.pinOnTop,className:"text-xs px-2 py-1 rounded hover:bg-gray-200 "+(De?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */V(T,{name:"bookmark-square",className:"h-3.5 w-3.5",fill:De?"currentColor":"none",strokeWidth:1.5})}),
71
+ /* @__PURE__ */V("button",{onClick:()=>$n(kt),title:Ne.minimize,className:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",children:"─"}),!vn&&/* @__PURE__ */V(er,{maximized:Tn,onToggleMax:()=>{Tn?(zn(!1),on(Jt())):Nr()},onSnap:kr,buttonClassName:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",strings:Ne}),
72
72
  /* @__PURE__ */V("kbd",{className:"rounded border border-gray-300 bg-gray-200 px-2 py-0.5 text-2xs font-medium text-gray-400",children:"ESC"}),
73
- /* @__PURE__ */V("button",{type:"button",onClick:dr,className:"rounded-(--radius-control) text-gray-400 hover:text-gray-600",children:/* @__PURE__ */V(T,{name:"close",className:"h-5 w-5"})})]})]}),le&&je&&!G&&!ue&&/* @__PURE__ */V("div",{"aria-hidden":"true",className:"h-[3px] shrink-0 pointer-events-none",style:{backgroundColor:`rgb(var(--window-accent-rgb) / ${St?.9:.55})`}}),
74
- /* @__PURE__ */V(Pt.Provider,{value:kt,children:/* @__PURE__ */V(Yt.Provider,{value:{rightRef:et,leftRef:tt,notify:()=>rt(!0),active:St,isDirty:Gn,footerOpen:it&&!G&&!Q&&!Z&&!ue},children:/* @__PURE__ */V("div",{ref:Ze,...G?{onPointerDown:fr,onContextMenu:e=>{e.preventDefault(),Xe({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${G?"p-0 cursor-move":Z||ee?"p-0":Q?"p-2":"p-4"} ${G||bn?"":"backdrop-blur-sm"} ${!1===C||Z||ee?"overflow-hidden":"overflow-y-auto overscroll-contain"} ${G?"rounded-2xl select-none":""}`,style:{...G?{touchAction:"none"}:{},backgroundColor:G?"transparent":bn?"rgb(var(--window-content-rgb))":St?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */V(ge,{children:ce})})})}),G&&Ye&&/* @__PURE__ */X(x,{minWidth:160,style:{left:Ye.x,top:Ye.y},onClose:()=>Xe(null),children:[
73
+ /* @__PURE__ */V("button",{type:"button",onClick:dr,className:"rounded-(--radius-control) text-gray-400 hover:text-gray-600",children:/* @__PURE__ */V(T,{name:"close",className:"h-5 w-5"})})]})]}),le&&je&&!J&&!ue&&/* @__PURE__ */V("div",{"aria-hidden":"true",className:"h-[3px] shrink-0 pointer-events-none",style:{backgroundColor:`rgb(var(--window-accent-rgb) / ${St?.9:.55})`}}),
74
+ /* @__PURE__ */V(Pt.Provider,{value:kt,children:/* @__PURE__ */V(Ut.Provider,{value:{rightRef:et,leftRef:tt,notify:()=>rt(!0),active:St,isDirty:Jn,footerOpen:it&&!J&&!Q&&!Z&&!ue},children:/* @__PURE__ */V("div",{ref:Ze,...J?{onPointerDown:fr,onContextMenu:e=>{e.preventDefault(),Xe({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${J?"p-0 cursor-move":Z||ee?"p-0":Q?"p-2":"p-4"} ${J||bn?"":"backdrop-blur-sm"} ${!1===C||Z||ee?"overflow-hidden":"overflow-y-auto overscroll-contain"} ${J?"rounded-2xl select-none":""}`,style:{...J?{touchAction:"none"}:{},backgroundColor:J?"transparent":bn?"rgb(var(--window-content-rgb))":St?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */V(ge,{children:ce})})})}),J&&Ue&&/* @__PURE__ */X(x,{minWidth:160,style:{left:Ue.x,top:Ue.y},onClose:()=>Xe(null),children:[
75
75
  /* @__PURE__ */V(k,{onClick:()=>{Xe(null),window.dispatchEvent(new CustomEvent("widget-open-settings",{detail:kt}))},children:"Settings"}),
76
76
  /* @__PURE__ */V(E,{}),oe&&/* @__PURE__ */X(_,{children:[oe,
77
77
  /* @__PURE__ */V(E,{})]}),
@@ -79,11 +79,11 @@ return X("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:d,
79
79
  /* @__PURE__ */V("span",{className:"flex-1",children:"Always on Top"}),De&&/* @__PURE__ */V(T,{name:"check",className:"h-4 w-4 text-blue-600 shrink-0",strokeWidth:2})]}),
80
80
  /* @__PURE__ */V(E,{}),
81
81
  /* @__PURE__ */V(k,{onClick:()=>{Xe(null),dr()},children:"Close"})]}),
82
- /* @__PURE__ */X("div",{onPointerDown:fr,ref:ot,className:`px-4 py-2 border-t border-gray-200 shrink-0 flex items-center justify-between text-xs select-none${bn?"":" cursor-move"}${St&&!bn?" backdrop-blur-sm":""}${G||Q||Z||ue||!it?" hidden":""}`,style:{touchAction:"none",backgroundColor:bn?"rgb(var(--window-footer-rgb))":St?"rgb(var(--window-footer-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-footer-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
82
+ /* @__PURE__ */X("div",{onPointerDown:fr,ref:ot,className:`px-4 py-2 border-t border-gray-200 shrink-0 flex items-center justify-between text-xs select-none${bn?"":" cursor-move"}${St&&!bn?" backdrop-blur-sm":""}${J||Q||Z||ue||!it?" hidden":""}`,style:{touchAction:"none",backgroundColor:bn?"rgb(var(--window-footer-rgb))":St?"rgb(var(--window-footer-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-footer-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
83
83
  /* @__PURE__ */X("div",{className:"flex items-center gap-2 min-w-0",children:[dt&&/* @__PURE__ */V(xe,{auto:!0}),F,
84
84
  /* @__PURE__ */V("div",{ref:tt,"data-modal-actions-left":!0,className:"flex items-center gap-2"}),g]}),
85
85
  /* @__PURE__ */X("div",{className:"flex items-center gap-2 ml-auto",children:[
86
- /* @__PURE__ */V("div",{ref:et,"data-modal-actions":!0,className:"flex items-center gap-2"}),D]})]}),!G&&!ue&&!Kt&&St&&!vn&&/* @__PURE__ */X(_,{children:[
86
+ /* @__PURE__ */V("div",{ref:et,"data-modal-actions":!0,className:"flex items-center gap-2"}),D]})]}),!J&&!ue&&!$t&&St&&!vn&&/* @__PURE__ */X(_,{children:[
87
87
  /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"se"),className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize z-10"}),
88
88
  /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"sw"),className:"absolute bottom-0 left-0 w-3 h-3 cursor-nesw-resize z-10"}),
89
89
  /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"ne"),className:"absolute top-0 right-0 w-3 h-3 cursor-nesw-resize z-10"}),
@@ -91,18 +91,18 @@ return X("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:d,
91
91
  /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"n"),className:"absolute top-0 left-3 right-3 h-1 cursor-ns-resize"}),
92
92
  /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"s"),className:"absolute bottom-0 left-3 right-3 h-1 cursor-ns-resize"}),
93
93
  /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"e"),className:"absolute top-3 bottom-3 right-0 w-1 cursor-ew-resize"}),
94
- /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"w"),className:"absolute top-3 bottom-3 left-0 w-1 cursor-ew-resize"})]}),Kt&&/* @__PURE__ */V("div",{className:"absolute inset-0",style:{zIndex:M.hint,cursor:"pointer",background:"transparent"},onMouseEnter:()=>qt(!0),onMouseLeave:()=>qt(!1),onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),$n(kt),pr(!1)},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:Ft&&/* @__PURE__ */V("button",{type:"button","data-expose-close":!0,"aria-label":Me.taskbar.closeWindow,title:"Close",className:"absolute flex items-center justify-center rounded-full bg-black/55 text-white 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/Ar})`,transformOrigin:"top right",zIndex:M.raised},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:e=>{e.stopPropagation(),e.preventDefault(),dr()},children:/* @__PURE__ */V(T,{name:"close",className:"h-4 w-4",strokeWidth:2.2})})})]}),Kt&&zr&&/* @__PURE__ */V("div",{className:"fixed pointer-events-none select-none truncate text-center",style:{left:zr.x,top:zr.y+zr.h+4,width:zr.w,zIndex:M.expose+(Ft?21:11),color:"white",fontSize:"var(--text-xs)",fontWeight:500,textShadow:"0 1px 2px rgba(0,0,0,0.6)"},children:Rt(Ee)})]}),$r=Ie&&/* @__PURE__ */X(x,{style:{left:Ie.x,top:Ie.y},onClose:()=>$e(null),minWidth:160,children:[!G&&!Q&&!bn&&/* @__PURE__ */X(_,{children:[
95
- /* @__PURE__ */X(k,{onClick:()=>{Kn(kt),$e(null)},children:[
96
- /* @__PURE__ */V(T,{name:"remove",className:"h-4 w-4",strokeWidth:1.5}),Ne.minimize]}),!vn&&/* @__PURE__ */X(k,Tn?{onClick:()=>{zn(!1),on(Gt()),$e(null)},children:[
97
- /* @__PURE__ */V("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */V("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 4.5v15m6-15v15M4.5 9h15M4.5 15h15"})}),Ne.windowed]}:{onClick:()=>{Nr(),$e(null)},children:[
98
- /* @__PURE__ */V(T,{name:"expand",className:"h-4 w-4",strokeWidth:1.5}),Ne.maximize]})]}),U&&!bn&&/* @__PURE__ */X(k,{onClick:()=>{Pe(e=>!e),$e(null)},children:[
99
- /* @__PURE__ */V(T,{name:"bookmark-square",className:"h-4 w-4 "+(De?"text-blue-600":""),fill:De?"currentColor":"none",strokeWidth:1.5}),De?Ne.unpin:Ne.pinOnTop]}),Ke&&/* @__PURE__ */X(k,{onClick:()=>{$e(null),Ue()},children:[
100
- /* @__PURE__ */V(T,{name:"star",className:"h-4 w-4",fill:He?"currentColor":"none",strokeWidth:1.5}),He?Me.taskbar.removeFromDesktop:Me.taskbar.addToDesktop]}),(jt[kt]||[]).length>0&&/* @__PURE__ */V(_,{children:(jt[kt]||[]).map((e,t)=>/* @__PURE__ */X(k,{onClick:()=>{$e(null),e.onClick()},children:[e.icon,e.label]},t))}),!(bn&&Oe?.home)&&/* @__PURE__ */X(_,{children:[
94
+ /* @__PURE__ */V("div",{onPointerDown:e=>wr(e,"w"),className:"absolute top-3 bottom-3 left-0 w-1 cursor-ew-resize"})]}),$t&&/* @__PURE__ */V("div",{className:"absolute inset-0",style:{zIndex:M.hint,cursor:"pointer",background:"transparent"},onMouseEnter:()=>qt(!0),onMouseLeave:()=>qt(!1),onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),Kn(kt),pr(!1)},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:Ft&&/* @__PURE__ */V("button",{type:"button","data-expose-close":!0,"aria-label":Me.taskbar.closeWindow,title:"Close",className:"absolute flex items-center justify-center rounded-full bg-black/55 text-white 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/Ar})`,transformOrigin:"top right",zIndex:M.raised},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:e=>{e.stopPropagation(),e.preventDefault(),dr()},children:/* @__PURE__ */V(T,{name:"close",className:"h-4 w-4",strokeWidth:2.2})})})]}),$t&&zr&&/* @__PURE__ */V("div",{className:"fixed pointer-events-none select-none truncate text-center",style:{left:zr.x,top:zr.y+zr.h+4,width:zr.w,zIndex:M.expose+(Ft?21:11),color:"white",fontSize:"var(--text-xs)",fontWeight:500,textShadow:"0 1px 2px rgba(0,0,0,0.6)"},children:Rt(Ee)})]}),Kr=Ie&&/* @__PURE__ */X(x,{style:{left:Ie.x,top:Ie.y},onClose:()=>Ke(null),minWidth:160,children:[!J&&!Q&&!bn&&/* @__PURE__ */X(_,{children:[
95
+ /* @__PURE__ */X(k,{onClick:()=>{$n(kt),Ke(null)},children:[
96
+ /* @__PURE__ */V(T,{name:"remove",className:"h-4 w-4",strokeWidth:1.5}),Ne.minimize]}),!vn&&/* @__PURE__ */X(k,Tn?{onClick:()=>{zn(!1),on(Jt()),Ke(null)},children:[
97
+ /* @__PURE__ */V("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */V("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 4.5v15m6-15v15M4.5 9h15M4.5 15h15"})}),Ne.windowed]}:{onClick:()=>{Nr(),Ke(null)},children:[
98
+ /* @__PURE__ */V(T,{name:"expand",className:"h-4 w-4",strokeWidth:1.5}),Ne.maximize]})]}),Y&&!bn&&/* @__PURE__ */X(k,{onClick:()=>{Pe(e=>!e),Ke(null)},children:[
99
+ /* @__PURE__ */V(T,{name:"bookmark-square",className:"h-4 w-4 "+(De?"text-blue-600":""),fill:De?"currentColor":"none",strokeWidth:1.5}),De?Ne.unpin:Ne.pinOnTop]}),$e&&/* @__PURE__ */X(k,{onClick:()=>{Ke(null),Ye()},children:[
100
+ /* @__PURE__ */V(T,{name:"star",className:"h-4 w-4",fill:He?"currentColor":"none",strokeWidth:1.5}),He?Me.taskbar.removeFromDesktop:Me.taskbar.addToDesktop]}),(jt[kt]||[]).length>0&&/* @__PURE__ */V(_,{children:(jt[kt]||[]).map((e,t)=>/* @__PURE__ */X(k,{onClick:()=>{Ke(null),e.onClick()},children:[e.icon,e.label]},t))}),!(bn&&Oe?.home)&&/* @__PURE__ */X(_,{children:[
101
101
  /* @__PURE__ */V(E,{}),
102
- /* @__PURE__ */X(k,{danger:!0,onClick:()=>{$e(null),dr()},children:[
103
- /* @__PURE__ */V(T,{name:"close",className:"h-4 w-4"}),Ne.close]})]})]}),Kr=!!ae&&xt.some(e=>e.id===ae),Wr=!Lt||Kr||G?null:/* @__PURE__ */X("div",{"data-modal-restore-tab":!0,"data-modal-id":kt,className:"fixed left-1/2 z-(--z-restore-tab) flex -translate-x-1/2 items-center gap-1 rounded-lg border border-gray-300 bg-white px-2 py-1 shadow-lg",style:{bottom:"calc(var(--taskbar-height, 0px) + 12px)"},children:[
104
- /* @__PURE__ */V("button",{type:"button",onClick:()=>$n(kt),title:Ne.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:Se||Ne.windowSuffix}),
105
- /* @__PURE__ */V("button",{type:"button",onClick:()=>$n(kt),title:Ne.restore,"aria-label":Ne.restore,className:"rounded px-2 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:"▴"}),
106
- /* @__PURE__ */V("button",{type:"button",onClick:()=>{dr()},title:Ne.close,"aria-label":Ne.close,className:"rounded px-2 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:"✕"})]});return J(
107
- /* @__PURE__ */X(It.Provider,{value:null,children:[Ir,$r,Wr]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{dr&&"Escape"===e.key&&(Nr(null),pr(!1))});var Ar=100,Dr={past:[],future:[]};function Pr(e,t){switch(t.type){case"record":{const n=e.past[e.past.length-1];if(null!==t.step.coalesceKey&&n?.coalesceKey===t.step.coalesceKey)return 0===e.future.length?e:{...e,future:[]};const r=[...e.past,t.step];return{past:r.length>Ar?r.slice(r.length-Ar):r,future:[]}}case"undo":return 0===e.past.length?e:{past:e.past.slice(0,-1),future:[t.redoStep,...e.future]};case"redo":return 0===e.future.length?e:{past:[...e.past,t.undoStep],future:e.future.slice(1)};case"clear":return 0===e.past.length&&0===e.future.length?e:Dr}}var Ir=/* @__PURE__ */new Set(["INPUT","TEXTAREA","SELECT"]);var $r=500,Kr=250;function Wr({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,a]=U(Pr,Dr),s=I(/* @__PURE__ */new Map),[l,c]=K(0),d=l>0,[u,h]=K(0),[m,p]=K(0),f=m>0,{hasAnyPerm:w}=i(),y=t&&0===u&&(!(n&&n.length>0)||w(n)),g=I(null),b=I(!1),v=O(()=>{const e={};for(const[t,n]of s.current)e[t]=n.getLast();return e},[]),x=O((e,t)=>{s.current.has(e)||c(e=>e+1),s.current.set(e,t)},[]),k=O(e=>{s.current.delete(e)&&c(e=>e-1)},[]),E=O(e=>{h(t=>t+(e?1:-1))},[]),C=O(e=>{p(t=>t+(e?1:-1))},[]),[M,N]=K(0),S=M>0,L=O(e=>{N(t=>t+(e?1:-1))},[]),T=A(be),z=T?.claimReadOnly;$(()=>{if(z&&!y)return z(!0),()=>z(!1)},[z,y]);const D=T?.claimOwnMount;$(()=>{if(D&&S)return D(!0),()=>D(!1)},[D,S]);const P=I({last:0,count:0,tripped:!1}),W=I(!1),R=O((e,t,n)=>{if(b.current)return void(n&&function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;if(Array.isArray(e)!==Array.isArray(t))return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}(n.prev,n.next)||(W.current=!0));if(!y||g.current)return;const r=P.current;if(r.tripped)return;const o=Date.now();if(o-r.last>Kr&&(r.count=0),r.last=o,++r.count>$r)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${$r} 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.`);g.current={values:v(),label:e,coalesceKey:t},queueMicrotask(()=>{const e=g.current;g.current=null,e&&a({type:"record",step:e})})},[y,v]),F=O(e=>{for(const[t,n]of Object.entries(e)){const e=s.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),q=O(()=>{const e=o.past[o.past.length-1];if(!e)return;const t={values:v(),label:e.label,coalesceKey:null};F(e.values),a({type:"undo",redoStep:t})},[o.past,v,F]),j=O(()=>{const e=o.future[0];if(!e)return;const t={values:v(),label:e.label,coalesceKey:null};F(e.values),a({type:"redo",undoStep:t})},[o.future,v,F]),[H,Y]=K(0),_=I(0),J=I(0),G=I(!1),Q=O(()=>{b.current=!0,W.current=!1,g.current=null,_.current+=1,J.current=_.current,Y(_.current)},[]),Z=I(void 0),ee=O(e=>{void 0!==e&&(void 0!==Z.current&&e!==Z.current&&(G.current=!0),Z.current=e),Q()},[Q]);$(()=>{b.current&&H===J.current&&(b.current=!1,g.current=null,(W.current||G.current)&&a({type:"clear"}),W.current=!1,G.current=!1)},[H]);const te=O(()=>{G.current=!0,a({type:"clear"}),Q()},[Q]),ne=y&&o.past.length>0,re=y&&o.future.length>0,oe=cr(r),ie=I({undo:q,redo:j,canUndo:ne,canRedo:re});ie.current={undo:q,redo:j,canUndo:ne,canRedo:re},$(()=>{if(!oe||!y)return;const e=e=>{const t=function(e){if(!e.metaKey&&!e.ctrlKey||e.altKey)return null;const t=e.key.toLowerCase(),n="z"===t?e.shiftKey?"redo":"undo":"y"!==t||!e.ctrlKey||e.metaKey||e.shiftKey?null:"redo";if(!n)return null;const r=e.target;return r?.isContentEditable||r?.tagName&&Ir.has(r.tagName.toUpperCase())?null:n}(e);if(!t)return;const n=ie.current;("undo"===t?n.canUndo:n.canRedo)&&(e.preventDefault(),"undo"===t?n.undo():n.redo())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe,y]);const ae=B(()=>({register:x,unregister:k,record:R,undo:q,redo:j,clear:te,baseline:ee,canUndo:ne,canRedo:re,enabled:y,hasState:d,handMounted:S,claimOwnMount:L,claimReadOnly:E,declaredEditable:f,claimEditable:C,undoLabel:ne?o.past[o.past.length-1].label:null,redoLabel:re?o.future[0].label:null}),[x,k,R,q,j,te,ee,ne,re,y,d,S,L,E,f,C,o.past,o.future]),se=""!==Xt(),le=A(Yt)?.footerOpen??!1,ce=se&&y&&d&&!S&&le;/* @__PURE__ */
108
- return X(be.Provider,{value:ae,children:[ce&&/* @__PURE__ */V(_t,{position:"left",quiet:!0,children:/* @__PURE__ */V(xe,{auto:!0})}),e]})}function Or(){const e=A(be),t=O(()=>{},[]);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 Rr(e){const t=A(be),n=t?.claimReadOnly,r=t?.claimEditable;$(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}function Fr(e,t,n){const r=A(be),o=H(),i=I(e),a=I(t);a.current=t,$(()=>{if(r)return r.register(o,{getLast:()=>i.current,setLast:e=>{i.current=e},apply:e=>a.current(e)}),()=>r.unregister(o)},[r,o]);const{label:s,coalesceKey:l=null}=n,c=I(r);c.current=r;const d=I({label:s,coalesceKey:l});d.current={label:s,coalesceKey:l},$(()=>{const t=c.current;t&&(Object.is(e,i.current)||(t.record(d.current.label,d.current.coalesceKey,{prev:i.current,next:e}),i.current=e))},[e])}function qr(e,t){const[n,r]=K(e);return Fr(n,e=>r(()=>e),t),[n,r]}export{Jt as CancelButton,je as DocFavStar,ze as EntityWindowFallback,Le as EntityWindowLoading,Ae as EntityWindowState,Ot as KEY_ACTIVATED_SELECTOR,Ne as LoadingSpinner,Wt as MODAL_SUBMIT_SELECTOR,zr as Modal,_t as ModalActions,xe as UndoControls,Wr as UndoProvider,oe as WINDOW_REGISTRY,ye as WindowCrashedFallback,ge as WindowErrorBoundary,ct as WindowManagerProvider,Ht as WindowTitle,Xe as activateWindowById,vt as beginWindowGesture,An as cancelWindowFront,ce as client_default,Sr as commitExposeHighlight,xt as drainPerfEvents,wr as exitExposeMode,cn as forgetMaximizedWindowBoxes,ar as getActiveModalId,Ge as getActiveWindowRoute,Mr as getExposeHighlight,Dt as getWindowChromeVersion,sn as getWindowPosition,Pe as isDraftEntityId,Ie as isDraftEntityWindow,te as isEntityEntry,ee as isPageEntry,se as isShellApiClientConfigured,Ve as isTabWindow,bt as markMenuOpen,zt as readWindowChrome,zn as requestWindowFront,Nr as setExposeHighlight,gt as setPerfCollecting,ae as setShellApiClient,pe as setShellHomeRoute,re as setShellWindowRegistry,an as setWindowDefaultPosition,ln as setWindowPosition,Ct as splitTitle,Cr as subscribeExposeHighlight,At as subscribeWindowChrome,fr as toggleExposeMode,Nn as useCurrentTabKey,Xt as useEnclosingModalId,cr as useIsActiveWindow,Vt as useModalActive,ue as usePageSearch,Or as useUndo,Rr as useUndoCanEdit,Fr as useUndoable,qr as useUndoableState,qt as useWidgetSettings,We as useWindowDirty,Re as useWindowManager,Bt as useWindowMenuItem,Ut as useWindowTitle};
102
+ /* @__PURE__ */X(k,{danger:!0,onClick:()=>{Ke(null),dr()},children:[
103
+ /* @__PURE__ */V(T,{name:"close",className:"h-4 w-4"}),Ne.close]})]})]}),$r=!!ae&&xt.some(e=>e.id===ae),Wr=!Lt||$r||J?null:/* @__PURE__ */X("div",{"data-modal-restore-tab":!0,"data-modal-id":kt,className:"fixed left-1/2 z-(--z-restore-tab) flex -translate-x-1/2 items-center gap-1 rounded-lg border border-gray-300 bg-white px-2 py-1 shadow-lg",style:{bottom:"calc(var(--taskbar-height, 0px) + 12px)"},children:[
104
+ /* @__PURE__ */V("button",{type:"button",onClick:()=>Kn(kt),title:Ne.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:Se||Ne.windowSuffix}),
105
+ /* @__PURE__ */V("button",{type:"button",onClick:()=>Kn(kt),title:Ne.restore,"aria-label":Ne.restore,className:"rounded px-2 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:"▴"}),
106
+ /* @__PURE__ */V("button",{type:"button",onClick:()=>{dr()},title:Ne.close,"aria-label":Ne.close,className:"rounded px-2 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:"✕"})]});return G(
107
+ /* @__PURE__ */X(It.Provider,{value:null,children:[Ir,Kr,Wr]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{dr&&"Escape"===e.key&&(Nr(null),pr(!1))});var Ar=100,Dr={past:[],future:[]};function Pr(e,t){switch(t.type){case"record":{const n=e.past[e.past.length-1];if(null!==t.step.coalesceKey&&n?.coalesceKey===t.step.coalesceKey)return 0===e.future.length?e:{...e,future:[]};const r=[...e.past,t.step];return{past:r.length>Ar?r.slice(r.length-Ar):r,future:[]}}case"undo":return 0===e.past.length?e:{past:e.past.slice(0,-1),future:[t.redoStep,...e.future]};case"redo":return 0===e.future.length?e:{past:[...e.past,t.undoStep],future:e.future.slice(1)};case"clear":return 0===e.past.length&&0===e.future.length?e:Dr}}var Ir=/* @__PURE__ */new Set(["INPUT","TEXTAREA","SELECT"]);var Kr=500,$r=250;function Wr({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,a]=Y(Pr,Dr),s=I(/* @__PURE__ */new Map),[l,c]=$(0),d=l>0,[u,h]=$(0),[m,p]=$(0),f=m>0,{hasAnyPerm:w}=i(),y=t&&0===u&&(!(n&&n.length>0)||w(n)),g=I(null),b=I(!1),v=O(()=>{const e={};for(const[t,n]of s.current)e[t]=n.getLast();return e},[]),x=O((e,t)=>{s.current.has(e)||c(e=>e+1),s.current.set(e,t)},[]),k=O(e=>{s.current.delete(e)&&c(e=>e-1)},[]),E=O(e=>{h(t=>t+(e?1:-1))},[]),C=O(e=>{p(t=>t+(e?1:-1))},[]),[M,N]=$(0),S=M>0,L=O(e=>{N(t=>t+(e?1:-1))},[]),T=A(be),z=T?.claimReadOnly;K(()=>{if(z&&!y)return z(!0),()=>z(!1)},[z,y]);const D=T?.claimOwnMount;K(()=>{if(D&&S)return D(!0),()=>D(!1)},[D,S]);const P=I({last:0,count:0,tripped:!1}),W=I(!1),R=O((e,t,n)=>{if(b.current)return void(n&&function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;if(Array.isArray(e)!==Array.isArray(t))return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}(n.prev,n.next)||(W.current=!0));if(!y||g.current)return;const r=P.current;if(r.tripped)return;const o=Date.now();if(o-r.last>$r&&(r.count=0),r.last=o,++r.count>Kr)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${Kr} 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.`);g.current={values:v(),label:e,coalesceKey:t},queueMicrotask(()=>{const e=g.current;g.current=null,e&&a({type:"record",step:e})})},[y,v]),F=O(e=>{for(const[t,n]of Object.entries(e)){const e=s.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),q=O(()=>{const e=o.past[o.past.length-1];if(!e)return;const t={values:v(),label:e.label,coalesceKey:null};F(e.values),a({type:"undo",redoStep:t})},[o.past,v,F]),j=O(()=>{const e=o.future[0];if(!e)return;const t={values:v(),label:e.label,coalesceKey:null};F(e.values),a({type:"redo",undoStep:t})},[o.future,v,F]),[H,U]=$(0),_=I(0),G=I(0),J=I(!1),Q=O(()=>{b.current=!0,W.current=!1,g.current=null,_.current+=1,G.current=_.current,U(_.current)},[]),Z=I(void 0),ee=O(e=>{void 0!==e&&(void 0!==Z.current&&e!==Z.current&&(J.current=!0),Z.current=e),Q()},[Q]);K(()=>{b.current&&H===G.current&&(b.current=!1,g.current=null,(W.current||J.current)&&a({type:"clear"}),W.current=!1,J.current=!1)},[H]);const te=O(()=>{J.current=!0,a({type:"clear"}),Q()},[Q]),ne=y&&o.past.length>0,re=y&&o.future.length>0,oe=cr(r),ie=I({undo:q,redo:j,canUndo:ne,canRedo:re});ie.current={undo:q,redo:j,canUndo:ne,canRedo:re},K(()=>{if(!oe||!y)return;const e=e=>{const t=function(e){if(!e.metaKey&&!e.ctrlKey||e.altKey)return null;const t=e.key.toLowerCase(),n="z"===t?e.shiftKey?"redo":"undo":"y"!==t||!e.ctrlKey||e.metaKey||e.shiftKey?null:"redo";if(!n)return null;const r=e.target;return r?.isContentEditable||r?.tagName&&Ir.has(r.tagName.toUpperCase())?null:n}(e);if(!t)return;const n=ie.current;("undo"===t?n.canUndo:n.canRedo)&&(e.preventDefault(),"undo"===t?n.undo():n.redo())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe,y]);const ae=B(()=>({register:x,unregister:k,record:R,undo:q,redo:j,clear:te,baseline:ee,canUndo:ne,canRedo:re,enabled:y,hasState:d,handMounted:S,claimOwnMount:L,claimReadOnly:E,declaredEditable:f,claimEditable:C,undoLabel:ne?o.past[o.past.length-1].label:null,redoLabel:re?o.future[0].label:null}),[x,k,R,q,j,te,ee,ne,re,y,d,S,L,E,f,C,o.past,o.future]),se=""!==Xt(),le=A(Ut)?.footerOpen??!1,ce=se&&y&&d&&!S&&le;/* @__PURE__ */
108
+ return X(be.Provider,{value:ae,children:[ce&&/* @__PURE__ */V(_t,{position:"left",quiet:!0,children:/* @__PURE__ */V(xe,{auto:!0})}),e]})}function Or(){const e=A(be),t=O(()=>{},[]);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 Rr(e){const t=A(be),n=t?.claimReadOnly,r=t?.claimEditable;K(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}function Fr(e,t,n){const r=A(be),o=H(),i=I(e),a=I(t);a.current=t,K(()=>{if(r)return r.register(o,{getLast:()=>i.current,setLast:e=>{i.current=e},apply:e=>a.current(e)}),()=>r.unregister(o)},[r,o]);const{label:s,coalesceKey:l=null}=n,c=I(r);c.current=r;const d=I({label:s,coalesceKey:l});d.current={label:s,coalesceKey:l},K(()=>{const t=c.current;t&&(Object.is(e,i.current)||(t.record(d.current.label,d.current.coalesceKey,{prev:i.current,next:e}),i.current=e))},[e])}function qr(e,t){const[n,r]=$(e);return Fr(n,e=>r(()=>e),t),[n,r]}export{Gt as CancelButton,je as DocFavStar,ze as EntityWindowFallback,Le as EntityWindowLoading,Ae as EntityWindowState,Ot as KEY_ACTIVATED_SELECTOR,Ne as LoadingSpinner,Wt as MODAL_SUBMIT_SELECTOR,zr as Modal,_t as ModalActions,xe as UndoControls,Wr as UndoProvider,oe as WINDOW_REGISTRY,ye as WindowCrashedFallback,ge as WindowErrorBoundary,ct as WindowManagerProvider,Ht as WindowTitle,Xe as activateWindowById,vt as beginWindowGesture,An as cancelWindowFront,ce as client_default,Sr as commitExposeHighlight,xt as drainPerfEvents,wr as exitExposeMode,cn as forgetMaximizedWindowBoxes,ar as getActiveModalId,Je as getActiveWindowRoute,Mr as getExposeHighlight,Dt as getWindowChromeVersion,sn as getWindowPosition,Pe as isDraftEntityId,Ie as isDraftEntityWindow,te as isEntityEntry,ee as isPageEntry,se as isShellApiClientConfigured,Ve as isTabWindow,bt as markMenuOpen,zt as readWindowChrome,zn as requestWindowFront,Nr as setExposeHighlight,gt as setPerfCollecting,ae as setShellApiClient,pe as setShellHomeRoute,re as setShellWindowRegistry,an as setWindowDefaultPosition,ln as setWindowPosition,Ct as splitTitle,Cr as subscribeExposeHighlight,At as subscribeWindowChrome,fr as toggleExposeMode,Nn as useCurrentTabKey,Xt as useEnclosingModalId,cr as useIsActiveWindow,Vt as useModalActive,ue as usePageSearch,Or as useUndo,Rr as useUndoCanEdit,Fr as useUndoable,qr as useUndoableState,qt as useWidgetSettings,We as useWindowDirty,Re as useWindowManager,Bt as useWindowMenuItem,Yt as useWindowTitle};