efficient-shell 7.7.0 → 7.10.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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/{Browser-56LX7FTE.js → Browser-VCRHLL3W.js} +15 -15
  3. package/dist/Calculator-HFF54RNH.js +29 -0
  4. package/dist/ConfirmDialog-6LAVAGDE.js +1 -0
  5. package/dist/{CurrencyConverter-ZXY7XNG6.js → CurrencyConverter-SAIDT4WN.js} +10 -10
  6. package/dist/{Documents-SVKR757H.js → Documents-OWPQE6D6.js} +11 -11
  7. package/dist/{Files-KSHU7ROB.js → Files-UCNAQWGM.js} +81 -81
  8. package/dist/{Notepad-5GT2GUCJ.js → Notepad-NNYMEU7M.js} +9 -9
  9. package/dist/PdfViewer-PHABUM7K.js +1 -0
  10. package/dist/{PomodoroTimer-GAGDQ4NF.js → PomodoroTimer-AV3YE2WJ.js} +50 -50
  11. package/dist/{Preview-YDCDW5NE.js → Preview-PWFREL75.js} +15 -15
  12. package/dist/Sidebar-3IB3YIWC.js +44 -0
  13. package/dist/{Spreadsheet-SYR23K4I.js → Spreadsheet-F5BXANOO.js} +11 -11
  14. package/dist/{Stock-LH5CR667.js → Stock-EP2SB76N.js} +7 -7
  15. package/dist/{Weather-MZGIPR2R.js → Weather-62FA6T6O.js} +13 -13
  16. package/dist/{WorldClock-DLB2RRLI.js → WorldClock-C3A6PZYM.js} +5 -5
  17. package/dist/apps/index.js +1 -1
  18. package/dist/bin/ui-check.js +1 -1
  19. package/dist/brand.css +1 -1
  20. package/dist/{chunk-R2TPTM4O.js → chunk-7BX3JQBP.js} +6 -6
  21. package/dist/{chunk-2R5RTN5T.js → chunk-7HLTPMQV.js} +1 -1
  22. package/dist/chunk-B4XGJA3N.js +1 -0
  23. package/dist/{chunk-QUVE5JZZ.js → chunk-BQ7GR7H6.js} +1 -1
  24. package/dist/{chunk-OXTM3XZI.js → chunk-BXW5WAEX.js} +1 -1
  25. package/dist/{chunk-JKHXDQEI.js → chunk-FTJ2G343.js} +6 -6
  26. package/dist/{chunk-5TOLXFQ6.js → chunk-GGSG7HSD.js} +1 -1
  27. package/dist/{chunk-4JGNJYVL.js → chunk-ICN533ML.js} +8 -8
  28. package/dist/{chunk-HIRMYFOF.js → chunk-ITCBLL72.js} +2 -2
  29. package/dist/{chunk-WOEFPBQF.js → chunk-KBOYLXAT.js} +1 -1
  30. package/dist/{chunk-MSGBGLGI.js → chunk-KSLOSQKN.js} +20 -20
  31. package/dist/{chunk-N7JTY3LU.js → chunk-MFDZYZZX.js} +8 -8
  32. package/dist/{chunk-2ALIPI3D.js → chunk-NGUH7T5V.js} +1 -1
  33. package/dist/{chunk-CQ2DLPPS.js → chunk-SCJT2XXU.js} +1 -1
  34. package/dist/{chunk-6SCHK75C.js → chunk-THM35LAN.js} +60 -60
  35. package/dist/{chunk-43XFZY4K.js → chunk-UJL5J7GX.js} +4 -4
  36. package/dist/{chunk-CLFUF3BH.js → chunk-UZJ6RYMF.js} +4 -4
  37. package/dist/{chunk-TCYS67ND.js → chunk-W6BQVATM.js} +173 -173
  38. package/dist/{chunk-NODT4F2C.js → chunk-XN7CAWSZ.js} +2 -2
  39. package/dist/{chunk-KONXUO5I.js → chunk-Y56GRZ2Q.js} +1 -1
  40. package/dist/{chunk-PT4Z3KIA.js → chunk-YMWCZKUN.js} +8 -8
  41. package/dist/{chunk-M4MCXII7.js → chunk-Z2TTHY7G.js} +2 -2
  42. package/dist/{chunk-CJHT4VTF.js → chunk-ZGUQLVY4.js} +4 -2
  43. package/dist/{chunk-G4CTTSAR.js → chunk-ZRU5F2XT.js} +4 -4
  44. package/dist/icons/efficient-looks.js +16 -6
  45. package/dist/icons/efficient.d.ts +5 -3
  46. package/dist/icons/efficient.js +49 -46
  47. package/dist/icons/index.d.ts +1 -1
  48. package/dist/icons/index.js +1 -1
  49. package/dist/{index-BkBsXpfV.d.ts → index-Cevszdp8.d.ts} +14 -5
  50. package/dist/index.d.ts +2 -2
  51. package/dist/index.js +103 -106
  52. package/dist/map/index.js +9 -9
  53. package/dist/markdown/index.js +4 -4
  54. package/dist/page-tabs/index.js +5 -5
  55. package/dist/pdf/index.js +1 -1
  56. package/dist/telemetry/index.js +1 -1
  57. package/dist/ui/index.d.ts +1 -1
  58. package/dist/ui/index.js +1 -1
  59. package/dist/ui.css +3 -1
  60. package/package.json +1 -1
  61. package/dist/Calculator-GBKLJHM6.js +0 -29
  62. package/dist/ConfirmDialog-PS5BXNAT.js +0 -1
  63. package/dist/PdfViewer-YVAWFZVH.js +0 -1
  64. package/dist/Sidebar-IH6WUPKT.js +0 -44
  65. package/dist/chunk-BUGGBB5J.js +0 -1
@@ -1,11 +1,11 @@
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-CQ2DLPPS.js";import{isStaleChunkError as u,CMD_Z as h,CMD_SHIFT_Z as m,LoadingSpinner as p,Result as f,useIsMobile as w,useShellPrefs as y}from"./chunk-G4CTTSAR.js";import{Button_default as g}from"./chunk-PT4Z3KIA.js";import{confirm as b}from"./chunk-MSGBGLGI.js";import{PopupMenu as v,PopupMenuItem as x,PopupMenuDivider as k,PopupMenuLabel as E}from"./chunk-4JGNJYVL.js";import{Z_LAYERS as C,runEscapeInterceptors as M}from"./chunk-FIEA5CGB.js";import{reportBoundaryError as N}from"./chunk-KNUR2UEG.js";import{useShellStrings as S}from"./chunk-QRCDQPJA.js";import{Icon as L}from"./chunk-CJHT4VTF.js";import{createContext as T,useContext as z,Component as A,useLayoutEffect as D,useRef as P,useEffect as I,useState as $,useSyncExternalStore as K,useCallback as W,isValidElement as O,Fragment as R,Children as F,cloneElement as q,useMemo as j,useReducer as B,useId as H,Suspense as Y}from"react";import{jsxs as U,jsx as X,Fragment as V}from"react/jsx-runtime";import{createPortal as _}from"react-dom";import{useLocation as J}from"react-router-dom";import{useQueryClient as G,useQuery as Q}from"@tanstack/react-query";function Z(e){return"component"in e}function ee(e){return"endpoint"in e}var te={};function ne(e){te=e}var re=new Proxy({},{get:(e,t)=>te[t],has:(e,t)=>t in te,ownKeys:()=>Object.keys(te),getOwnPropertyDescriptor(e,t){if(t in te)return{configurable:!0,enumerable:!0,value:te[t]}}}),oe=null;function ie(e){oe=e}function ae(){return null!==oe}var se=/* @__PURE__ */new Set(["get","post","put","patch","delete","head","options","request"]),le=new Proxy({},{get:(e,t)=>oe?oe[t]:"string"==typeof t&&se.has(t)?()=>Promise.resolve({data:null,status:0,statusText:"",headers:{},config:{}}):void 0}),ce=T(null);function de(){return z(ce)?.pageSearch??""}var ue=null,he=/* @__PURE__ */new Set;function me(e){ue!==e&&(ue=e,he.forEach(e=>e()))}function pe(){return ue}function fe(e){return he.add(e),()=>{he.delete(e)}}function we({error:e,onReload:t}){const n=u(e);/* @__PURE__ */
2
- return U("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 py-12 text-center",children:[
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-SCJT2XXU.js";import{isStaleChunkError as u,CMD_Z as h,CMD_SHIFT_Z as m,LoadingSpinner as p,Result as f,useIsMobile as w,useShellPrefs as y}from"./chunk-ZRU5F2XT.js";import{Button_default as g}from"./chunk-YMWCZKUN.js";import{confirm as b}from"./chunk-KSLOSQKN.js";import{PopupMenu as v,PopupMenuItem as x,PopupMenuDivider as k,PopupMenuLabel as E}from"./chunk-ICN533ML.js";import{Z_LAYERS as C,runEscapeInterceptors as M}from"./chunk-FIEA5CGB.js";import{reportBoundaryError as N}from"./chunk-KNUR2UEG.js";import{useShellStrings as S}from"./chunk-QRCDQPJA.js";import{Icon as L}from"./chunk-ZGUQLVY4.js";import{createContext as T,useContext as z,Component as A,useLayoutEffect as D,useRef as P,useEffect as I,useState as K,useSyncExternalStore as $,useCallback as W,isValidElement as O,Fragment as R,Children as F,cloneElement as q,useMemo as j,useReducer as B,useId as H,Suspense as U}from"react";import{jsxs as Y,jsx as X,Fragment as V}from"react/jsx-runtime";import{createPortal as _}from"react-dom";import{useLocation as J}from"react-router-dom";import{useQueryClient as G,useQuery as Q}from"@tanstack/react-query";function Z(e){return"component"in e}function ee(e){return"endpoint"in e}var te={};function ne(e){te=e}var re=new Proxy({},{get:(e,t)=>te[t],has:(e,t)=>t in te,ownKeys:()=>Object.keys(te),getOwnPropertyDescriptor(e,t){if(t in te)return{configurable:!0,enumerable:!0,value:te[t]}}}),oe=null;function ie(e){oe=e}function ae(){return null!==oe}var se=/* @__PURE__ */new Set(["get","post","put","patch","delete","head","options","request"]),le=new Proxy({},{get:(e,t)=>oe?oe[t]:"string"==typeof t&&se.has(t)?()=>Promise.resolve({data:null,status:0,statusText:"",headers:{},config:{}}):void 0}),ce=T(null);function de(){return z(ce)?.pageSearch??""}var ue=null,he=/* @__PURE__ */new Set;function me(e){ue!==e&&(ue=e,he.forEach(e=>e()))}function pe(){return ue}function fe(e){return he.add(e),()=>{he.delete(e)}}function we({error:e,onReload:t}){const n=u(e);/* @__PURE__ */
2
+ return Y("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 py-12 text-center",children:[
3
3
  /* @__PURE__ */X(L,{name:"warning",className:"h-8 w-8 text-amber-500",strokeWidth:1.5}),
4
- /* @__PURE__ */U("div",{className:"min-w-0",children:[
4
+ /* @__PURE__ */Y("div",{className:"min-w-0",children:[
5
5
  /* @__PURE__ */X("p",{className:"text-sm font-medium text-gray-700",children:n?"This window needs the latest version of the app":"This window crashed"}),
6
6
  /* @__PURE__ */X("p",{className:"mt-1 text-xs text-gray-400 max-w-sm break-words",children:n?"A new version was deployed while this tab was open. Reload the page to pick it up.":e.message||String(e)})]}),
7
7
  /* @__PURE__ */X("button",{type:"button",onClick:n?()=>window.location.reload():t,className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg",children:n?"Reload page":"Reload window"})]})}var ye=class extends A{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){console.error("[efficient-shell] window content crashed:",e,t.componentStack),N(e)}reset=()=>this.setState({error:null});render(){const{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):/* @__PURE__ */X(we,{error:e,onReload:this.reset}):this.props.children}},ge=T(null),be="text-xs text-gray-500 hover:text-gray-700 disabled:opacity-40 disabled:hover:text-gray-500 disabled:cursor-default";function ve({className:e="",auto:t=!1}){const n=z(ge),r=S().undo,o=n?.claimOwnMount;if(D(()=>{if(!t&&o)return o(!0),()=>o(!1)},[t,o]),!n||!n.enabled)return null;const{undo:i,redo:a,canUndo:s,canRedo:l,undoLabel:c,redoLabel:d}=n;/* @__PURE__ */
8
- return U("div",{className:`flex items-center gap-2 ${e}`,"data-undo-controls":t?"shell":"form",children:[
8
+ return Y("div",{className:`flex items-center gap-2 ${e}`,"data-undo-controls":t?"shell":"form",children:[
9
9
  /* @__PURE__ */X("button",{type:"button",onClick:i,disabled:!s,title:s?r.undoStep(c??"",h):r.nothingToUndo,className:be,children:r.undo}),
10
10
  /* @__PURE__ */X("button",{type:"button",onClick:a,disabled:!l,title:l?r.redoStep(d??"",m):r.nothingToRedo,className:be,children:r.redo})]})}var xe=/* @__PURE__ */new Set([408,429]);function ke(e){const t=e?.response?.status;return"number"==typeof t?t:void 0}function Ee(e){const t=ke(e);return null!=t&&(t>=400&&t<500&&!xe.has(t))}function Ce(e,t){return!Ee(t)&&e<3}function Me(){const e=S().loading;/* @__PURE__ */
11
11
  return X("div",{className:"flex items-center justify-center p-8 text-sm text-gray-400",children:e.label})}var Ne="flex-1 min-h-0";function Se(){const e=S().record;/* @__PURE__ */
@@ -14,76 +14,76 @@ return X(f,{status:"warning",title:i.signInRequired,subTitle:i.signInBody,classN
14
14
  return X(f,{status:"403",className:Ne});if(404===e||410===e)/* @__PURE__ */
15
15
  return X(f,{status:"404",title:i.notFound,className:Ne});const t=null==e||408===e||429===e||e>=500;/* @__PURE__ */
16
16
  return X(f,{status:"500",title:i.loadFailed,subTitle:t?i.checkConnection:i.rejected,extra:t?/* @__PURE__ */X(g,{variant:"secondary",size:"sm",onClick:o,children:i.retry}):void 0,className:Ne})}/* @__PURE__ */
17
- return X(f,{status:"404",title:i.notFound,className:Ne})}function ze({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */X(V,{children:t(e)}):/* @__PURE__ */X(Te,{...n})}var Ae=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function De(e){return"string"==typeof e&&(e.startsWith("new-")||Ae.test(e))}function Pe(e){if(De(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var Ie=T({openWindows:[],openEntity:()=>{},openPage:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),$e=T(null);function Ke(e){const t=z($e),n=P(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),D(()=>{if(t)return t(n.current,e)},[t,e]),I(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function We(){const e=P(/* @__PURE__ */new Map),[t,n]=$(!1);return{dirty:t,registerDirty:W((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 Oe(){return z(Ie)}function Re(e){if("page"!==e.type&&Pe(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 Fe({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=We(),i=re[e.route];if(!i||!Z(i))return null;const a=i,s=a.component;/* @__PURE__ */
18
- return X(Tr,{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__ */X($e.Provider,{value:o,children:/* @__PURE__ */X(Y,{fallback:/* @__PURE__ */X("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */X(Me,{})}),children:/* @__PURE__ */X(s,{})})})})}function qe({entityType:e,entityId:t,label:n}){const r=S(),o=G(),{data:i}=Q({queryKey:["my-profile-sidebar"],enabled:ae(),queryFn:()=>le.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 X("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];le.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__ */X(L,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var je=/* @__PURE__ */new Set;function Be({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=re[e.entityType];if(!o||!ee(o))return null;const i=o,[a,s]=$(!1),{dirty:l,registerDirty:d}=We(),u=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,h=e.entitySnapshot?._duplicate,m=De(e.entityId),p=!i.selfFetching&&!h&&!m&&ae(),f=Q({queryKey:[u,e.entityId],queryFn:()=>{return le.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:Le(e.entitySnapshot),initialDataUpdatedAt:0,enabled:p,staleTime:0,refetchOnWindowFocus:!0,refetchOnMount:"always",refetchInterval:e=>!Ee(e.state.error)&&6e4,refetchIntervalInBackground:!1,retry:Ce}),w=f.data,y=f.refetch;I(()=>{var t;if(p)return t=t=>{t!==e.id||je.has(t)||y({cancelRefetch:!1})},Pn.add(t),()=>{Pn.delete(t)}},[y,e.id,p]);const g=W(()=>{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__ */X(Y,{fallback:/* @__PURE__ */X(Me,{}),children:i.render(w??e.entitySnapshot,t,e.entityId,a,s)}):null!=w?/* @__PURE__ */X(Y,{fallback:/* @__PURE__ */X(Tr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */X(Se,{})}),children:i.render(w,t,e.entityId,a,s)}):/* @__PURE__ */X(Tr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */X(Te,{isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y})}):/* @__PURE__ */X(Tr,{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__ */X($e.Provider,{value:d,children:/* @__PURE__ */X(Y,{fallback:/* @__PURE__ */X(Se,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */X(ze,{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 He(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 Ue(e){const t=He(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&&In(o)}function Xe(e){if("page"!==e.type)return!0;const t=e.route?re[e.route]:void 0;if(!t||!Z(t))return!0;const n=t;return!n.widget&&!n.utility}function Ve(){const e=ir();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var _e=/* @__PURE__ */new Map;function Je(){const e=Ve();if(e)return _e.get(e)}function Ge(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 Qe="rosh-peek-style",Ze=C.peek,et=C.taskbarPreview;function tt(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(Qe))return;const e=document.createElement("style");e.id=Qe,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:${Ze}!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 nt(){"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 rt({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=S(),l=P(null),[c,d]=$({w:n,h:Math.round(.75*r)}),[u,h]=$(!1);return D(()=>{const o=l.current;if(!o)return;const i=He(e)??Ge(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__ */U("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
- /* @__PURE__ */X("div",{ref:l,className:"absolute inset-0 z-0 overflow-hidden"}),!u&&/* @__PURE__ */U("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-gray-400 bg-gray-50",children:[
17
+ return X(f,{status:"404",title:i.notFound,className:Ne})}function ze({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */X(V,{children:t(e)}):/* @__PURE__ */X(Te,{...n})}var Ae=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function De(e){return"string"==typeof e&&(e.startsWith("new-")||Ae.test(e))}function Pe(e){if(De(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var Ie=T({openWindows:[],openEntity:()=>{},openPage:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),Ke=T(null);function $e(e){const t=z(Ke),n=P(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),D(()=>{if(t)return t(n.current,e)},[t,e]),I(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function We(){const e=P(/* @__PURE__ */new Map),[t,n]=K(!1);return{dirty:t,registerDirty:W((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 Oe(){return z(Ie)}function Re(e){if("page"!==e.type&&Pe(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 Fe({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=We(),i=re[e.route];if(!i||!Z(i))return null;const a=i,s=a.component;/* @__PURE__ */
18
+ return X(Tr,{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__ */X(Ke.Provider,{value:o,children:/* @__PURE__ */X(U,{fallback:/* @__PURE__ */X("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */X(Me,{})}),children:/* @__PURE__ */X(s,{})})})})}function qe({entityType:e,entityId:t,label:n}){const r=S(),o=G(),{data:i}=Q({queryKey:["my-profile-sidebar"],enabled:ae(),queryFn:()=>le.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 X("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];le.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__ */X(L,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var je=/* @__PURE__ */new Set;function Be({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=re[e.entityType];if(!o||!ee(o))return null;const i=o,[a,s]=K(!1),{dirty:l,registerDirty:d}=We(),u=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,h=e.entitySnapshot?._duplicate,m=De(e.entityId),p=!i.selfFetching&&!h&&!m&&ae(),f=Q({queryKey:[u,e.entityId],queryFn:()=>{return le.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:Le(e.entitySnapshot),initialDataUpdatedAt:0,enabled:p,staleTime:0,refetchOnWindowFocus:!0,refetchOnMount:"always",refetchInterval:e=>!Ee(e.state.error)&&6e4,refetchIntervalInBackground:!1,retry:Ce}),w=f.data,y=f.refetch;I(()=>{var t;if(p)return t=t=>{t!==e.id||je.has(t)||y({cancelRefetch:!1})},Pn.add(t),()=>{Pn.delete(t)}},[y,e.id,p]);const g=W(()=>{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__ */X(U,{fallback:/* @__PURE__ */X(Me,{}),children:i.render(w??e.entitySnapshot,t,e.entityId,a,s)}):null!=w?/* @__PURE__ */X(U,{fallback:/* @__PURE__ */X(Tr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */X(Se,{})}),children:i.render(w,t,e.entityId,a,s)}):/* @__PURE__ */X(Tr,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */X(Te,{isPending:f.isPending,isFetching:f.isFetching,enabled:p,error:f.error,onRetry:y})}):/* @__PURE__ */X(Tr,{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__ */X(Ke.Provider,{value:d,children:/* @__PURE__ */X(U,{fallback:/* @__PURE__ */X(Se,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */X(ze,{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 He(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 Ye(e){const t=He(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&&In(o)}function Xe(e){if("page"!==e.type)return!0;const t=e.route?re[e.route]:void 0;if(!t||!Z(t))return!0;const n=t;return!n.widget&&!n.utility}function Ve(){const e=ir();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var _e=/* @__PURE__ */new Map;function Je(){const e=Ve();if(e)return _e.get(e)}function Ge(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 Qe="rosh-peek-style",Ze=C.peek,et=C.taskbarPreview;function tt(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(Qe))return;const e=document.createElement("style");e.id=Qe,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:${Ze}!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 nt(){"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 rt({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=S(),l=P(null),[c,d]=K({w:n,h:Math.round(.75*r)}),[u,h]=K(!1);return D(()=>{const o=l.current;if(!o)return;const i=He(e)??Ge(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__ */Y("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
+ /* @__PURE__ */X("div",{ref:l,className:"absolute inset-0 z-0 overflow-hidden"}),!u&&/* @__PURE__ */Y("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-gray-400 bg-gray-50",children:[
21
21
  /* @__PURE__ */X(L,{name:"window",className:"h-6 w-6",strokeWidth:1.5}),
22
- /* @__PURE__ */X("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */X("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__ */X("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__ */X(L,{name:"close",className:"h-3 w-3",strokeWidth:3})})]})}function ot({items:e,anchorEl:t,onActivate:n,onClose:r,onMouseEnter:o,onMouseLeave:i}){const a=S(),s=e.length>1,l=P(null),[c,d]=$({left:-9999,top:-9999,ready:!1}),[u,h]=$(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");D(()=>{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]),I(()=>nt,[]);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 _(
23
- /* @__PURE__ */X("div",{ref:l,"data-taskbar-preview":"",style:{position:"fixed",left:c.left,top:c.top,zIndex:et,maxWidth:"calc(100vw - 16px)",opacity:c.ready?1:0},className:s?"flex gap-2 flex-wrap":"",onMouseEnter:o,onMouseLeave:()=>{nt(),i()},children:e.map(e=>{const t=He(e.id)??Ge(e.label),o=t?function(e){if(Yn(e))return null;const t=e.getBoundingClientRect(),n=Rn(),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
- return U("div",{className:"group flex flex-col items-center",onMouseEnter:()=>tt(t),children:[!m&&/* @__PURE__ */X("span",{className:p,children:e.label}),
25
- /* @__PURE__ */X(rt,{id:e.id,label:e.label,maxW:240,maxH:160,titleAbove:!0,onClick:()=>n(e.id),onClose:()=>r(e.id)}),m&&/* @__PURE__ */X("span",{className:p,children:e.label}),null!==o&&/* @__PURE__ */U("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__ */X(L,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function it(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 at({openWindows:e,onRemove:t,onSplitView:n,onActivate:r,onActivateById:o}){const i=S(),[a,s]=$(null);I(()=>{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=K(ar,ir),[,d]=$(0);I(()=>{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);I(()=>{const e=()=>u(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const h=e=>{const t=Ge(e),n=t?.querySelector("[data-window-title]");return n?.textContent?.trim()||e},[m,p]=$(null),[f,w]=$(null),[y,g]=$(null),b=P(null),C=()=>{b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{p(null),w(null)},150)},M=e.filter(e=>!e.route||!re[e.route]?.utility);if(!a||!a.isConnected||0===M.length)return null;const N=[],T=/* @__PURE__ */new Map;for(const e of M){const t=e.route?re[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=T.get(r);if(void 0!==o)N[o].items.push(e);else{T.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 _(
27
- /* @__PURE__ */U(V,{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=He(e.id)??Ge(e.label);return!!t&&!Yn(t)});/* @__PURE__ */
28
- return U("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:C,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&&O(n)?q(n,{className:"h-3.5 w-3.5 shrink-0 "+(a?"text-blue-600":"text-gray-400")}):/* @__PURE__ */X(L,{name:"expand",className:"h-3.5 w-3.5 shrink-0 "+(a?"text-blue-600":"text-gray-400"),strokeWidth:2}),
22
+ /* @__PURE__ */X("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */X("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__ */X("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__ */X(L,{name:"close",className:"h-3 w-3",strokeWidth:3})})]})}function ot({items:e,anchorEl:t,onActivate:n,onClose:r,onMouseEnter:o,onMouseLeave:i}){const a=S(),s=e.length>1,l=P(null),[c,d]=K({left:-9999,top:-9999,ready:!1}),[u,h]=K(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");D(()=>{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]),I(()=>nt,[]);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 _(
23
+ /* @__PURE__ */X("div",{ref:l,"data-taskbar-preview":"",style:{position:"fixed",left:c.left,top:c.top,zIndex:et,maxWidth:"calc(100vw - 16px)",opacity:c.ready?1:0},className:s?"flex gap-2 flex-wrap":"",onMouseEnter:o,onMouseLeave:()=>{nt(),i()},children:e.map(e=>{const t=He(e.id)??Ge(e.label),o=t?function(e){if(Un(e))return null;const t=e.getBoundingClientRect(),n=Rn(),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
+ return Y("div",{className:"group flex flex-col items-center",onMouseEnter:()=>tt(t),children:[!m&&/* @__PURE__ */X("span",{className:p,children:e.label}),
25
+ /* @__PURE__ */X(rt,{id:e.id,label:e.label,maxW:240,maxH:160,titleAbove:!0,onClick:()=>n(e.id),onClose:()=>r(e.id)}),m&&/* @__PURE__ */X("span",{className:p,children:e.label}),null!==o&&/* @__PURE__ */Y("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__ */X(L,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function it(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 at({openWindows:e,onRemove:t,onSplitView:n,onActivate:r,onActivateById:o}){const i=S(),[a,s]=K(null);I(()=>{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=$(ar,ir),[,d]=K(0);I(()=>{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);I(()=>{const e=()=>u(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const h=e=>{const t=Ge(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=P(null),C=()=>{b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{p(null),w(null)},150)},M=e.filter(e=>!e.route||!re[e.route]?.utility);if(!a||!a.isConnected||0===M.length)return null;const N=[],T=/* @__PURE__ */new Map;for(const e of M){const t=e.route?re[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=T.get(r);if(void 0!==o)N[o].items.push(e);else{T.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 _(
27
+ /* @__PURE__ */Y(V,{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=He(e.id)??Ge(e.label);return!!t&&!Un(t)});/* @__PURE__ */
28
+ return Y("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:C,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&&O(n)?q(n,{className:"h-3.5 w-3.5 shrink-0 "+(a?"text-blue-600":"text-gray-400")}):/* @__PURE__ */X(L,{name:"expand",className:"h-3.5 w-3.5 shrink-0 "+(a?"text-blue-600":"text-gray-400"),strokeWidth:2}),
29
29
  /* @__PURE__ */X("span",{className:"truncate flex-1",children:s?e.label:h(r.label)}),d&&/* @__PURE__ */X("span",{title:i.taskbar.offscreenDot,className:"shrink-0 h-1.5 w-1.5 rounded-full bg-amber-500"}),s&&/* @__PURE__ */X("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__ */X("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__ */X(L,{name:"close",className:"h-3 w-3",strokeWidth:2})})]},e.key)}),
30
- /* @__PURE__ */X("div",{className:"flex-1"}),M.length>=2&&/* @__PURE__ */U("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
- /* @__PURE__ */X(L,{name:"grid",className:"h-3 w-3",strokeWidth:2}),"Exposé"]}),y&&/* @__PURE__ */U(v,{portal:!0,minWidth:200,style:it(y.x,y.y),onClose:()=>g(null),children:[
30
+ /* @__PURE__ */X("div",{className:"flex-1"}),M.length>=2&&/* @__PURE__ */Y("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
+ /* @__PURE__ */X(L,{name:"grid",className:"h-3 w-3",strokeWidth:2}),"Exposé"]}),y&&/* @__PURE__ */Y(v,{portal:!0,minWidth:200,style:it(y.x,y.y),onClose:()=>g(null),children:[
32
32
  /* @__PURE__ */X(E,{children:y.label}),
33
- /* @__PURE__ */U(x,{onClick:()=>{g(null),y.items.forEach(e=>function(e){const t=xn.get(e);t&&$n(t)}(e.id))},children:[
33
+ /* @__PURE__ */Y(x,{onClick:()=>{g(null),y.items.forEach(e=>function(e){const t=xn.get(e);t&&Kn(t)}(e.id))},children:[
34
34
  /* @__PURE__ */X(L,{name:"remove",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),i.taskbar.minimizeAllWindows]}),
35
- /* @__PURE__ */U(x,{onClick:()=>{g(null),y.items.forEach(e=>o(e.id))},children:[
35
+ /* @__PURE__ */Y(x,{onClick:()=>{g(null),y.items.forEach(e=>o(e.id))},children:[
36
36
  /* @__PURE__ */X("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */X("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__ */X(k,{}),
38
- /* @__PURE__ */U(x,{danger:!0,onClick:()=>{g(null),y.items.forEach(e=>t(e.id))},children:[
39
- /* @__PURE__ */X(L,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${y.items.length})`]})]}),m&&f&&/* @__PURE__ */X(ot,{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:C})]}),a)}var st=["/login","/forgot-password","/reset-password","/force-change-password"];function lt({children:e,windowAccentForRoute:t}){const n=J(),r=st.some(e=>n.pathname.startsWith(e)),[o,i]=$([]),a=P(o);D(()=>{a.current=o},[o]);const s=K(fe,pe,pe),l=P(/* @__PURE__ */new Map),c=e=>{const t=Xe(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};I(()=>{_e.clear();for(const e of o)e.route&&_e.set(e.id,e.route)},[o]);const d=W(e=>{i(t=>t.filter(t=>t.id!==e))},[]),u=W(e=>{var t;He(e)||Ye(e)?(t=e,window.dispatchEvent(new CustomEvent(sr,{detail:{windowKey:t}}))):d(e)},[d]),h=(e,t=!1)=>{const n=wn;t&&je.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,(yn.get(i)??-1)>a)||In(o),t&&je.delete(e)},50)},m=W((e,t,n,r,o)=>{if(!re[e]||!ee(re[e]))return;const a=`${e}:${t}`,s=Ve();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:Le(n),openedFrom:s}])})},[]),p=W((e,t={})=>{if(!re[e]||!Z(re[e]))return;const n=re[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l}=t,c=e=>{var t;o?(t=e,Nn.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=Ve();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=W(()=>{},[]),w=W(()=>{},[]),y=u,g=u;/* @__PURE__ */
40
- return U(Ie.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__ */X(at,{openWindows:o,onRemove:u,onSplitView:Sr,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&&In(e)}})},onActivateById:Ue}),
38
+ /* @__PURE__ */Y(x,{danger:!0,onClick:()=>{g(null),y.items.forEach(e=>t(e.id))},children:[
39
+ /* @__PURE__ */X(L,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${y.items.length})`]})]}),m&&f&&/* @__PURE__ */X(ot,{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:C})]}),a)}var st=["/login","/forgot-password","/reset-password","/force-change-password"];function lt({children:e,windowAccentForRoute:t}){const n=J(),r=st.some(e=>n.pathname.startsWith(e)),[o,i]=K([]),a=P(o);D(()=>{a.current=o},[o]);const s=$(fe,pe,pe),l=P(/* @__PURE__ */new Map),c=e=>{const t=Xe(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};I(()=>{_e.clear();for(const e of o)e.route&&_e.set(e.id,e.route)},[o]);const d=W(e=>{i(t=>t.filter(t=>t.id!==e))},[]),u=W(e=>{var t;He(e)||Ue(e)?(t=e,window.dispatchEvent(new CustomEvent(sr,{detail:{windowKey:t}}))):d(e)},[d]),h=(e,t=!1)=>{const n=wn;t&&je.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,(yn.get(i)??-1)>a)||In(o),t&&je.delete(e)},50)},m=W((e,t,n,r,o)=>{if(!re[e]||!ee(re[e]))return;const a=`${e}:${t}`,s=Ve();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:Le(n),openedFrom:s}])})},[]),p=W((e,t={})=>{if(!re[e]||!Z(re[e]))return;const n=re[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l}=t,c=e=>{var t;o?(t=e,Nn.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=Ve();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=W(()=>{},[]),w=W(()=>{},[]),y=u,g=u;/* @__PURE__ */
40
+ return Y(Ie.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__ */X(at,{openWindows:o,onRemove:u,onSplitView:Sr,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&&In(e)}})},onActivateById:Ye}),
42
42
  /* @__PURE__ */X(Lr,{}),!r&&o.map(e=>{const n=e.route?t?.(e.route):void 0;
43
43
  /* @__PURE__ */
44
- return X(ce.Provider,{value:c(e),children:/* @__PURE__ */X(ye,{fallback:(t,n)=>/* @__PURE__ */X(Tr,{open:!0,onClose:()=>d(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */X(we,{error:t,onReload:n})}),children:/* @__PURE__ */X(It,{spec:Re(e),children:/* @__PURE__ */X(Kr,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */X(Fe,{item:e,onClose:()=>d(e.id),accentRgb:n}):/* @__PURE__ */X(Be,{item:e,onClose:()=>d(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var ct=null,dt=/* @__PURE__ */new Set;function ut(){return ct}function ht(e){if(ct!==e){ct=e;for(const e of dt)e()}}function mt(e){return dt.add(e),()=>{dt.delete(e)}}var pt=!1,ft={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},wt=()=>{};function yt(e){pt=e,ft={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function gt(e,t){pt&&("submenu"===e?ft.submenus++:ft.menus++,ft.menuKey=t)}function bt(e){if(!pt)return wt;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!pt)return;const r=performance.now()-t;"move"===e?ft.moveMs+=r:ft.resizeMs+=r}}function vt(){const e=ft;return ft={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var xt=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),kt=/* @__PURE__ */new Set(["svg"]);function Et(e){const t=[],n={text:"",accessories:[]};return Ct(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function Ct(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=>Ct(e,t,n));if(!O(e))return;const r=e;if(r.type!==d)if(r.type!==R){if("string"==typeof r.type){if(kt.has(r.type))return;if(!xt.has(r.type))return n.push(" "),F.toArray(r.props.children).forEach(e=>Ct(e,t,n)),void n.push(" ")}t.accessories.push(q(r,{key:`title-part-${t.accessories.length}`}))}else F.toArray(r.props.children).forEach(e=>Ct(e,t,n));else void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text)}var Mt=/* @__PURE__ */new Map,Nt=/* @__PURE__ */new Set,St=0;function Lt(){St++,Nt.forEach(e=>e())}function Tt(e){return Mt.get(e)}function zt(e){return Nt.add(e),()=>{Nt.delete(e)}}function At(){return St}var Dt=T(""),Pt=T(null);function It({spec:e,children:t}){/* @__PURE__ */
45
- return X(Pt.Provider,{value:e,children:t})}var $t=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),Kt='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600',Wt='button, a[href], summary, [role="button"], [role="link"], [role="menuitem"], select';function Ot(e){return Rt(e).replace(/\s+/g," ").trim()}function Rt(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(Rt).join("");if(O(e)){const t=e,n="string"==typeof t.type?t.type:"";return $t.has(n)?"":` ${Rt(t.props?.children)} `}return""}function Ft(e){const t=z(Dt);I(()=>{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 qt={};function jt(e,t,n){const r=z(Dt);I(()=>{if(!r)return;qt[r]||(qt[r]=[]);const o={label:e,icon:n,onClick:t};return qt[r].push(o),()=>{qt[r]=(qt[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function Bt({title:e}){const t=P(null);return I(()=>{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__ */X("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function Ht(e){}var Yt=T(null);function Ut(){return z(Dt)}function Xt(){const e=K(ar,ir),t=z(Yt);return t?.active??(mn.length<=1||null!=e)}function Vt({children:e,position:t="right",quiet:n=!1}){const r=z(Yt),[o,i]=$(null);return I(()=>{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?_(e,o):null}function _t({onClick:e,children:t,className:n}){const r=z(Yt);/* @__PURE__ */
46
- return X("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./ConfirmDialog-PS5BXNAT.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",Gt={};try{const e=localStorage.getItem(Jt);e&&(Gt=JSON.parse(e))}catch{}var Qt=null;function Zt(){Qt&&clearTimeout(Qt),Qt=setTimeout(()=>{try{localStorage.setItem(Jt,JSON.stringify(Gt))}catch{}},500)}var en="erp_activation_order",tn=[];try{const e=localStorage.getItem(en),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(tn=t)}catch{}var nn=null;function rn(){nn&&clearTimeout(nn),nn=setTimeout(()=>{try{localStorage.setItem(en,JSON.stringify(tn))}catch{}},500)}function on(e,t){Gt[e]||(Gt[e]=t,Zt())}function an(e){return Gt[e]?{...Gt[e]}:null}function sn(e,t){Gt[e]=t,Zt()}function ln(){const r=e(),o=t();let i=!1;for(const e of Object.keys(Gt))n(Gt[e],r,o)&&(delete Gt[e],i=!0);i&&Zt()}var cn={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},dn=4e3,un=()=>{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"},hn={small:.8,medium:1,large:1.25,maximized:1.25},mn=[],pn=/* @__PURE__ */new Set,fn=/* @__PURE__ */new Set,wn=0,yn=/* @__PURE__ */new Map;var gn=0;function bn(){return gn}function vn(){gn++,pn.forEach(e=>e())}var xn=/* @__PURE__ */new Map,kn=/* @__PURE__ */new Map,En=/* @__PURE__ */new Map;function Cn(){for(let e=mn.length-1;e>=0;e--){const t=En.get(mn[e]);if(t?.tab)return t.owner}return null}function Mn(){return K(ar,Cn,()=>null)}var Nn=/* @__PURE__ */new Set;var Sn=null;function Ln(e){Sn=null,In(e)}function Tn(e){Sn=e;const t=xn.get(e);t&&Ln(t)}function zn(e){Sn===e&&(Sn=null)}function An(e,t,n){if(n&&En.set(e,n),t)if(xn.set(t,e),kn.set(e,t),Nn.delete(t)){mn.unshift(e);const n=tn.indexOf(t);-1!==n&&tn.splice(n,1),tn.unshift(t),rn()}else!function(e,t){const n=tn.indexOf(t);if(-1===n)return void mn.push(e);let r=mn.length;for(let e=0;e<mn.length;e++){const t=kn.get(mn[e]);if(t&&tn.indexOf(t)>n){r=e;break}}mn.splice(r,0,e)}(e,t),-1===tn.indexOf(t)&&(tn.push(t),rn());else mn.push(e);vn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&Sn===t&&Ln(e)}function Dn(e){return e?En.get(e)?.owner??kn.get(e)??null:null}var Pn=/* @__PURE__ */new Set;function In(e){const t=Dn(ir()),n=mn.indexOf(e);-1!==n&&mn.splice(n,1),mn.push(e);const o=En.get(e);if(o?.root&&o.tab&&r()){const e=mn.filter(e=>{const t=En.get(e);return!!t&&!t.root&&t.owner===o.owner});for(const t of e)mn.splice(mn.indexOf(t),1),mn.push(t)}fn.delete(e);const i=kn.get(e);if(i){const e=tn.indexOf(i);-1!==e&&tn.splice(e,1),tn.push(i),rn(),Sn&&Sn!==i&&(Sn=null)}vn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const a=Dn(ir());a&&a!==t&&Pn.forEach(e=>e(a))}function $n(e){const t=mn.indexOf(e);-1!==t&&mn.splice(t,1),fn.add(e),yn.set(e,++wn);const n=kn.get(e);if(n){const e=tn.indexOf(n);-1!==e&&(tn.splice(e,1),rn())}vn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var Kn=/* @__PURE__ */new Set;var Wn=8,On=32;function Rn(){return e()}var Fn=40,qn=80,jn=384,Bn=400;function Hn(e,t=Rn()){const n=Math.min(Math.max(e.x,t.x+qn-e.w),t.x+t.w-qn),r=Math.min(Math.max(e.y,t.y),t.y+t.h-Fn);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=Rn();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 Un(e){const t=Rn(),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 Xn=null;function Vn(e){const t=(Xn||((Xn=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${C.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(Xn)),Xn);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 _n(){Xn&&(Xn.style.opacity="0",Xn.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"}],Gn=350,Qn=200;function Zn({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o}){const[i,a]=$(!1),s=P(void 0),l=P(void 0);I(()=>()=>{clearTimeout(s.current),clearTimeout(l.current)},[]);const c=()=>{clearTimeout(l.current),s.current=setTimeout(()=>a(!0),Gn)},d=()=>{clearTimeout(s.current),l.current=setTimeout(()=>a(!1),Qn)};/* @__PURE__ */
47
- return U("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:d,children:[
48
- /* @__PURE__ */X("button",{onClick:t,onFocus:c,onBlur:d,title:e?o.windowed:o.maximize,className:r,children:e?"❐":"⤢"}),i&&/* @__PURE__ */X("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__ */X("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__ */X("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var er="rosh-gesture-style";var tr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},nr=4;function rr(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(er))return;const e=document.createElement("style");e.id=er,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=bt(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function or(e){const t=mn.indexOf(e);if(-1===t)return-1;const n=C.window+t*C.windowStep,o=En.get(e);if(!o||o.root||!o.tab||!r())return n;let i=-1;for(const[e,t]of En){if(!t.root||t.owner!==o.owner)continue;const n=mn.indexOf(e);-1!==n&&(i=Math.max(i,C.window+n*C.windowStep))}return i>=n?i+2+Math.min(t,7):n}function ir(){return mn[mn.length-1]||null}function ar(e){return pn.add(e),()=>{pn.delete(e)}}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=mn.length-1;e>=0;e--)Kn.has(mn[e])||mn.splice(e,1);tn=tn.filter(e=>{const t=xn.get(e);return null!=t&&Kn.has(t)}),rn(),vn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var sr="modal-close-request";function lr(e){K(ar,bn);const t=z(Yt);if(mn.length<=1)return!0;if(e){const t=xn.get(e);if(null!=t)return ir()===t}return t?.active??null!=ir()}var cr=!1,dr=/* @__PURE__ */new Set;function ur(e){return dr.add(e),()=>dr.delete(e)}function hr(){return cr}function mr(e){cr!==e&&(cr=e,dr.forEach(e=>e()))}function pr(){mr(!cr)}function fr(){mr(!1)}var wr=null,yr=/* @__PURE__ */new Set;function gr(e){return yr.add(e),()=>yr.delete(e)}function br(){return wr}function vr(e){wr!==e&&(wr=e,yr.forEach(e=>e()))}var xr=null,kr=/* @__PURE__ */new Set;function Er(e){return kr.add(e),()=>kr.delete(e)}function Cr(){return xr}function Mr(e){xr!==e&&(xr=e,kr.forEach(e=>e()))}function Nr(){if(!xr)return void mr(!1);vr(xr),Mr(null),mr(!1)}function Sr(){mr(!cr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function Lr(){const e=K(ur,hr),[t,n]=$(e),[r,o]=$(e);return I(()=>{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?_(
49
- /* @__PURE__ */X("div",{onMouseDown:e=>{e.stopPropagation(),mr(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:C.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 Tr({open:t,onClose:i,title:c,icon:d,copyText:u,size:h="lg",dirty:m=!1,onNext:p,onPrev:f,footer:g,bodyScroll:E,onMinimize:N,initialBox:T,actions:A,actionsLeft:R,editing:F=!1,allowPinOnTop:B,initialPosition:H,widget:Y,compact:J,appStyle:G,flushBody:Q,autoHeight:Z,autoMinHeight:ee,autoWidth:te,widgetMenu:ne,dimensions:re,windowKey:oe,openedFromKey:ie,accentRgb:ae,children:se}){const le=w(),[de,ue]=$(0),[he,me]=$(!1),pe=P(null),fe=P(0);I(()=>{fe.current=de},[de]);const we=W(e=>{le&&(pe.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},me(!0),ht(ie??null))},[le,ie]),be=K(mt,ut);I(()=>{if(!he)return;const e=e=>{if(!pe.current)return;const t=e.clientX-pe.current.startX;if(Math.abs(e.clientY-pe.current.startY)>Math.abs(t)+12)return pe.current=null,me(!1),ue(0),void ht(null);ue(Math.max(0,t))},t=()=>{if(!pe.current)return;const e=.3*window.innerWidth,t=fe.current>e;pe.current=null,me(!1),t?(ue(window.innerWidth),setTimeout(()=>{i(),ue(0),ht(null)},180)):(ue(0),ht(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)}},[he]);const[xe,ke]=$(c),Ee=S(),Ce=Ee.window;I(()=>{ke(c)},[c]);const Me=j(()=>Ot(xe).trim()||void 0,[xe]),[Ne,Se]=$(!1),Le=P(!1),[Te,ze]=$(!1),[Ae,De]=$(null),Pe=z(Pt),Ie=z(ce),{prefs:$e,save:We}=y(),Re=!!$e.window_accent_stripe,Fe=$e.favorite_documents||[],qe=!!Pe&&Fe.some(e=>e.entityType===Pe.entityType&&e.entityId===Pe.entityId),je=W(()=>{if(!Pe)return;const e=qe?Fe.filter(e=>!(e.entityType===Pe.entityType&&e.entityId===Pe.entityId)):[...Fe,{entityType:Pe.entityType,entityId:Pe.entityId,label:Pe.label}];We({favorite_documents:e})},[Pe,qe,Fe,We]),[Be,He]=$(null),[Ye,Ue]=$("top-right"===H?"right":"left"),Xe=P(!1),Ve=P(null);D(()=>{const e=Ve.current;e&&(ae?e.style.setProperty("--window-accent-rgb",ae):e.style.removeProperty("--window-accent-rgb"))},[ae]);const _e=P(!1),Je=P(null),Ge=P(null),Qe=P(null),[Ze,et]=$(!1),tt=P(null),nt=!!(g||A||R)||Ze,rt=z(ge),ot=""!==z(Dt),it=P(null);it.current=Ie?{owner:Ie.key,tab:Ie.tab,root:!ot}:null;const at=oe||(Ie&&!ot?Ie.key:null),st=!!rt&&!ot&&rt.enabled&&rt.hasState&&(F||rt.declaredEditable)&&!rt.handMounted&&nt&&!Y&&!J&&!G&&!le,lt=/* @__PURE__ */X(L,{name:"window",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),ct=d&&O(d)?q(d,{className:`h-4 w-4 ${d.props?.className??""}`.trim()}):d??lt,dt=()=>/* @__PURE__ */X("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation();const t=e.currentTarget.getBoundingClientRect();De(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:ct}),pt=40,{minimize:ft,items:wt,restoreIfMinimized:yt,openWindows:gt}=Oe(),bt=P(`modal-${Math.random().toString(36).slice(2,8)}`).current;I(()=>{if(Y)return Kn.add(bt),()=>{Kn.delete(bt)}},[Y,bt]),I(()=>{const e=e=>{const t=e.detail;t?.id===bt&&ke(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[bt]);const[vt,xt]=$(C.window),kt=function(e){const t=K(ar,ir);return mn.length<=1||t===e}(bt),Ct=function(e){return K(ar,()=>fn.has(e))}(bt),Nt=K(ur,hr),St=K(gr,br),Tt=K(Er,Cr),zt=!B&&!Y,At=Nt&&zt,[It,$t]=$(!1),Rt=At&&Tt===bt,[Ft,jt]=$(!1),Bt=Ft&&zt&&St===bt?"picked":null,Ht=P(At);I(()=>{if(Ht.current&&!At){jt(!0);const e=setTimeout(()=>{jt(!1),wr===bt&&vr(null)},700);return Ht.current=At,()=>clearTimeout(e)}Ht.current=At},[At,bt]),I(()=>{At||$t(!1)},[At]),I(()=>{const e=Ge.current,t=Qe.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>et(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]),I(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&Ve.current){const t=Ve.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=Ge.current,n=Qe.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const Ut=P(!1),Xt=W(e,[]),Vt=W(()=>{const t=e(),n=re?re[0]:cn[h]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=hn[un()],l=re?Math.min(re[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*(mn.length-1),d=Math.max(pt,(i-l)/2),u=(o-a)/2,m=t.h-pt-l-d;return"top-right"===H?{x:t.x+t.w-a-pt,y:t.y+pt,w:a,h:l}:"top-left"===H?{x:t.x+pt,y:t.y+pt,w:a,h:l}:{x:t.x+Math.max(pt,(o-a)/2+pt)+Math.min(c,Math.max(0,u)),y:t.y+d+Math.min(c,Math.max(0,m)),w:a,h:l}},[h]),_t=P(!1);t||(_t.current=!1);const Jt=oe||u||null;I(()=>{if(!t)return;An(bt,Jt,it.current??void 0),oe||In(bt),Ut.current=!1,xt(or(bt));const e=()=>{xt(or(bt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===oe;if(!e.label)return!1;const t=Ve.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if(In(bt),gn.current)return;const t=Rn(),n=Math.min(Ln.current.w,t.w-40),o=Math.min(Ln.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;tn({x:i,y:a,w:n,h:o}),Sn(!1)},i=e=>{const t=e.detail;r(t)&&(In(bt),De({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==oe)return;In(bt);const t=Ln.current,n=function(e,t=Rn()){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=Ve.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)}tn(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=mn.indexOf(e);-1!==t&&(mn.splice(t,1),vn()),fn.delete(e),yn.delete(e),En.delete(e);const n=kn.get(e);n&&(kn.delete(e),xn.delete(n))}(bt),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,bt,Jt,Xt]);const Qt=!Y&&"maximized"===un(),[en,tn]=$(()=>{if(Jt&&Gt[Jt]){const e={...Gt[Jt]};return re&&(e.w=re[0],Z||(e.h=re[1])),Hn(e)}return T?{x:T.x,y:T.y,w:T.w,h:T.h}:Qt?Xt():Vt()}),[nn,rn]=$(()=>!Z),[on,an]=$(()=>r()),sn=P(on),ln=P(null);I(()=>{const e=()=>{const e=r();e!==sn.current&&ln.current?.(e),sn.current=e,an(e),xt(or(bt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[bt]);const pn=on&&!!Ie?.tab&&!ot&&!Y&&!le,wn=pn,gn=P(wn);gn.current=wn;const bn=Mn(),Cn=on&&!!Ie?.tab&&!Y&&!le&&!Nt&&bn!==Ie.key,[Nn,Sn]=$(()=>Jt&&Gt[Jt]||T?wn:wn||Qt),Ln=P(en);Ln.current=en;const Tn=P(Nn);D(()=>{Tn.current=Nn},[Nn]),D(()=>{if(nn||pn)return;const e=Ve.current,t=Je.current;if(!e||!t)return;const n=ee??(Y?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,Ln.current.y)-24),g=w?Math.min(Ln.current.h,y):Math.min(Math.max(n,d+p),y),b=Math.abs(g-o)>1;b&&(o=g,tn(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),Y||(g<=n?i&&(clearTimeout(i),i=null):(b||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&rn(!0)},160)))},l=new ResizeObserver(s);s(),tt.current&&l.observe(tt.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[nn,Y,ee,nt,pn]),D(()=>{if(!Z||!nn||Y||!t)return;const e=tt.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||Nn)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=ee??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,Ln.current.y)-24);tn(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[Z,nn,Y,t,Nn,ee]);const zn=!1!==te&&!Y&&!G&&!le,[Dn,Pn]=$(()=>!zn);D(()=>{if(Dn||!t)return;if(!zn||Nn)return void Pn(!0);const n=Ve.current,r=Je.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let i=Ln.current.w,c=0;const d=()=>Pn(!0),u=()=>{c=0;const t=Ln.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,pt);b!==t&&(i=b.w,tn(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,dn);return()=>{h.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(m)}},[Dn,t,zn,Nn]);const Fn=P(null),qn=!(!Ie?.tab||ot||Y||le);ln.current=t=>{if(!qn)return;if(t)return Fn.current||(Fn.current={box:{...Ln.current},maximized:Tn.current}),void(Tn.current=!0);const r=Fn.current;Fn.current=null;const o=e();if(r?.maximized)return Tn.current=!0,Sn(!0),void tn(o);const i=r?.box??(Jt?Gt[Jt]:void 0);if(Tn.current=!1,Sn(!1),i&&!n(i,o,!1)){const e={...i};re&&(e.w=re[0],Z||(e.h=re[1])),tn(Hn(e))}else tn(Vt())},I(()=>{wn&&(Tn.current=!0,Sn(!0),tn(Xt()))},[wn,Xt]),I(()=>{if(Y)return;const e=()=>{const e=Jt?Gt[Jt]:void 0;if(Tn.current=!1,Sn(!1),e){const t={...e};re&&(t.w=re[0],Z||(t.h=re[1])),tn(Hn(t))}else tn(Vt())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[Y,Vt,Jt]),I(()=>{t&&Jt&&!pn&&(Gt[Jt]=en,Zt()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[en,t,Jt,pn]),I(()=>{if(!t)return;const e=()=>{Tn.current?tn(Xt()):document.body.classList.contains("rosh-gesturing")||tn(Hn)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return Nn&&(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,Nn,Xt]),I(()=>{if(t&&(Se(!1),Le.current=!1,Xe.current=!1,Pn(!zn),!gn.current)){if(Jt&&Gt[Jt]){const e=Gt[Jt];return void tn(t=>Hn({...e,...Z?{h:t.h}:{},...zn?{x:t.x,w:t.w}:{}}))}T&&(tn({x:T.x,y:T.y,w:T.w,h:T.h}),Sn(T.maximized))}},[t]),I(()=>{if(!t||"auto"!==m)return;let e;const n=t=>{Ve.current?.contains(t.target)&&!Le.current&&(Le.current=!0,e=setTimeout(()=>Se(!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 Yn="auto"===m?Ne:!0===m,Xn=Ie&&!ot?Ie.key:null,Jn=j(()=>Et(xe),[xe]),Gn=P({shortcutSpec:Pe,isOnDesktop:qe,toggleDesktopShortcut:je,taskbarStrings:Ee.taskbar});D(()=>{Gn.current={shortcutSpec:Pe,isOnDesktop:qe,toggleDesktopShortcut:je,taskbarStrings:Ee.taskbar}});const Qn=P(null);Qn.current||(Qn.current={open:(e,t)=>De({x:e,y:t}),items:()=>{const e=Gn.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of qt[bt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),I(()=>{t&&Xn&&function(e,t){const n=Mt.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.menu===t.menu||(Mt.set(e,t),Lt())}(Xn,{title:Jn.text||Me,dirty:Yn,copy:Jn.copy,menu:Qn.current??void 0})},[t,Xn,Me,Yn,Jn.text,Jn.copy]),I(()=>{if(t&&Xn)return()=>{return e=Xn,void(Mt.delete(e)&&Lt());var e}},[t,Xn]),Ke(!(oe||!t)&&Yn);const er=W(async()=>{if(!Xe.current){if(Yn||"auto"===m&&Le.current){Xe.current=!0;const e=Me,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(Xe.current=!1,!t)return}i()}},[Yn,m,i,Me]);D(()=>{if(!t||!at)return;const e=e=>{e.detail?.windowKey===at&&er()};return window.addEventListener(sr,e),()=>window.removeEventListener(sr,e)},[t,at,er]);const lr=P(null),cr=W(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if(De(null),In(bt),gn.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=Ve.current,s=a?.getBoundingClientRect();let l,c,d,u;if(lr.current){const t=lr.current;lr.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:Ln.current.x,c=s?s.top:Ln.current.y,d=s?s.height:Ln.current.h,u=s?s.width:Ln.current.w;Sn(!1),tn(e=>({...e,x:l,y:c,w:u,h:d}));let h=null;const m=e=>{if(!r){if(Math.abs(e.clientX-o)<nr&&Math.abs(e.clientY-i)<nr)return;r=rr(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)`),Ln.current={...Ln.current,x:s,y:d},!Y){const t=function(e,t){const n=Rn(),r=e<=n.x+Wn,o=e>=n.x+n.w-Wn,i=t<=n.y+Wn,a=t>=n.y+n.h-Wn,s=e<=n.x+On,l=e>=n.x+n.w-On,c=t<=n.y+On,d=t>=n.y+n.h-On;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?Vn(Un(t)):_n())}},p=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),r?.(),_n();const e=Hn({...Ln.current});if(Ln.current=e,!Y&&h){lr.current={x:l,y:c,w:u,h:d};const e=Un(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 tn(e)}if(Y){const t=e.x+e.w/2,n=window.innerWidth/2;Ue(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),tn(e)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",p)},[]),dr=W((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=Ve.current,l=s?.getBoundingClientRect(),c=l?l.left:Ln.current.x,d=l?l.top:Ln.current.y,u=l?l.width:Ln.current.w,h=l?l.height:Ln.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;Sn(!1),tn({x:c,y:d,w:u,h:h}),Ln.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,Ln.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)<nr&&Math.abs(e.clientY-a)<nr)return;o=rr(n,r,tr[t],"resize")}g=((e,t)=>{let n=c,r=d,o=u,i=h;if(f&&(o=Math.max(jn,u+e)),w&&(i=Math.max(Bn,h+t)),m){const t=Math.max(jn,u-e);n=c+u-t,o=t}if(p){const e=Math.max(Bn,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?.(),tn({...Ln.current})};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x)},[]),pr=W(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(),In(bt),"Enter"===e.key)return void(Nn?(Sn(!1),tn(Vt())):(Sn(!0),tn(Xt())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{lr.current||(lr.current={...Ln.current})};if(r<0)return e(),Sn(!0),void tn(Xt());if(r>0){if(Nn)return Sn(!1),void tn(Vt());if(lr.current){const e=Hn(lr.current);return lr.current=null,Ln.current=e,void tn(e)}return void $n(bt)}e(),Sn(!1);const t=Un(n<0?"left":"right");return Ln.current=t,void tn(t)}if(Nn)return;const o=Ln.current,i=e.shiftKey?{...o,w:Math.max(jn,o.w+24*n),h:Math.max(Bn,o.h+24*r)}:Hn({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});Ln.current=i,tn(i)},[bt,Nn,Vt,Xt]),fr=W(e=>{lr.current||(lr.current={...Ln.current}),Sn(!1);const t=Un(e);Ln.current=t,tn(t),In(bt)},[bt]),yr=wn||At?{}:{tabIndex:0,role:"group","aria-label":Me?`${Me} — ${Ce.windowSuffix}`:Ce.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:pr},xr=()=>{Sn(!0),tn(Xt())},kr=W(()=>{const e=Ve.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector(Kt);t&&!t.disabled&&t.click()}},[]);I(()=>{if(!t)return;if(Y)return;const e=e=>{if(mn[mn.length-1]===bt&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),kr();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&Ve.current?.contains(t)))return;if(t.closest(Wt))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,kr,bt,Y]),I(()=>{if(!t)return;const e=e=>{mn[mn.length-1]===bt&&((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:bt}})),Le.current=!1,Se(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:bt}}))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),I(()=>{if(!t)return;if(Y)return;const e=e=>{if("Escape"===e.key&&mn[mn.length-1]===bt){if(M(e))return e.preventDefault(),void e.stopPropagation();if(pn&&!F)return;e.preventDefault(),e.stopPropagation(),er()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,er,bt,Y,pn,F]);const Mr=t&&(void 0!==p||void 0!==f),Nr=W(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(I(()=>{if(!t)return;const e=e=>{if(mn[mn.length-1]!==bt)return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&Mr&&(e.preventDefault(),p?p():Nr("bottom")),"k"===e.key&&Mr&&(e.preventDefault(),f?f():Nr("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,f,Mr,Nr,bt]),!t||_t.current)return null;const Sr=At?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=Rn(),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}}(bt):null,Lr=At&&Sr?Math.min(Sr.w/en.w,Sr.h/en.h):1,Tr=(()=>{if(At&&Sr){const e=Lr,t=en.w*e,n=en.h*e,r=Sr.x+(Sr.w-t)/2-en.x,o=Sr.y+(Sr.h-n)/2-en.y,i=It||Rt;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:C.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(Ft&&zt){const e="picked"===Bt;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:C.expose+30}:{}}}return null})(),zr=/* @__PURE__ */U("div",{children:[
50
- /* @__PURE__ */U("div",{ref:Ve,"data-modal-panel":!0,"data-modal-id":bt,"data-window-key":oe||void 0,...B?{"data-utility":""}:{},...Te?{"data-pinned-top":""}:{},...Y?{"data-widget":""}:{},...Ie?{"data-window-owner":Ie.key}:{},...Ie&&!ot?{"data-window-root":""}:{},...pn?{"data-window-tab":""}:{},className:pn?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(Y?kt?"shadow-xl":"shadow-lg":"border "+(kt?"shadow-xl border-gray-200":"shadow-lg border-gray-300")),onMouseDownCapture:e=>{if(_e.current=!1,At){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),vr(bt),mr(!1),void In(bt)}if(!kt&&!Y&&!Te&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===Ve.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),_e.current=!0,De(null),In(bt),window.addEventListener("mouseup",()=>{setTimeout(()=>{_e.current=!1},0)},{once:!0}))}},onClickCapture:e=>{_e.current&&(_e.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if(At)return;De(null);e.target.closest("[data-modal-panel]")===Ve.current&&(e.target.closest("button, input, a, select, textarea")||In(bt))},style:le?{zIndex:vt+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${de}px)`,transition:he?"none":"transform 180ms ease-out",...Y?{display:"none"}:{},...vt<0?{display:"none"}:{},...kt||Te||be&&oe===be?{}:{display:"none"}}:{zIndex:Te?C.pinnedWindow:vt+1,width:en.w,height:en.h,top:en.y,...Y&&"right"===Ye?{right:window.innerWidth-en.x-en.w}:{left:en.x},...vt<0&&!Te?{display:"none"}:{},...Cn?{visibility:"hidden",pointerEvents:"none"}:{},...Tr??{}},children:[le&&!Y&&/* @__PURE__ */X("div",{onPointerDown:we,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),Y?null:pn?Ie?.home?null:/* @__PURE__ */U(V,{children:[
51
- /* @__PURE__ */X("h2",{"data-window-title":!0,className:"sr-only",children:Jn.text||Me}),(Jn.accessories.length>0||Mr)&&/* @__PURE__ */U("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
- /* @__PURE__ */X("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:Jn.accessories}),Mr&&/* @__PURE__ */U("span",{className:"flex items-center gap-1 shrink-0 text-2xs text-gray-400",children:[
44
+ return X(ce.Provider,{value:c(e),children:/* @__PURE__ */X(ye,{fallback:(t,n)=>/* @__PURE__ */X(Tr,{open:!0,onClose:()=>d(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */X(we,{error:t,onReload:n})}),children:/* @__PURE__ */X(It,{spec:Re(e),children:/* @__PURE__ */X($r,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */X(Fe,{item:e,onClose:()=>d(e.id),accentRgb:n}):/* @__PURE__ */X(Be,{item:e,onClose:()=>d(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var ct=null,dt=/* @__PURE__ */new Set;function ut(){return ct}function ht(e){if(ct!==e){ct=e;for(const e of dt)e()}}function mt(e){return dt.add(e),()=>{dt.delete(e)}}var pt=!1,ft={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},wt=()=>{};function yt(e){pt=e,ft={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function gt(e,t){pt&&("submenu"===e?ft.submenus++:ft.menus++,ft.menuKey=t)}function bt(e){if(!pt)return wt;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!pt)return;const r=performance.now()-t;"move"===e?ft.moveMs+=r:ft.resizeMs+=r}}function vt(){const e=ft;return ft={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var xt=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),kt=/* @__PURE__ */new Set(["svg"]);function Et(e){const t=[],n={text:"",accessories:[]};return Ct(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function Ct(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=>Ct(e,t,n));if(!O(e))return;const r=e;if(r.type!==d)if(r.type!==R){if("string"==typeof r.type){if(kt.has(r.type))return;if(!xt.has(r.type))return n.push(" "),F.toArray(r.props.children).forEach(e=>Ct(e,t,n)),void n.push(" ")}t.accessories.push(q(r,{key:`title-part-${t.accessories.length}`}))}else F.toArray(r.props.children).forEach(e=>Ct(e,t,n));else void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text)}var Mt=/* @__PURE__ */new Map,Nt=/* @__PURE__ */new Set,St=0;function Lt(){St++,Nt.forEach(e=>e())}function Tt(e){return Mt.get(e)}function zt(e){return Nt.add(e),()=>{Nt.delete(e)}}function At(){return St}var Dt=T(""),Pt=T(null);function It({spec:e,children:t}){/* @__PURE__ */
45
+ return X(Pt.Provider,{value:e,children:t})}var Kt=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),$t='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600',Wt='button, a[href], summary, [role="button"], [role="link"], [role="menuitem"], select';function Ot(e){return Rt(e).replace(/\s+/g," ").trim()}function Rt(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(Rt).join("");if(O(e)){const t=e,n="string"==typeof t.type?t.type:"";return Kt.has(n)?"":` ${Rt(t.props?.children)} `}return""}function Ft(e){const t=z(Dt);I(()=>{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 qt={};function jt(e,t,n){const r=z(Dt);I(()=>{if(!r)return;qt[r]||(qt[r]=[]);const o={label:e,icon:n,onClick:t};return qt[r].push(o),()=>{qt[r]=(qt[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function Bt({title:e}){const t=P(null);return I(()=>{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__ */X("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function Ht(e){}var Ut=T(null);function Yt(){return z(Dt)}function Xt(){const e=$(ar,ir),t=z(Ut);return t?.active??(mn.length<=1||null!=e)}function Vt({children:e,position:t="right",quiet:n=!1}){const r=z(Ut),[o,i]=K(null);return I(()=>{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?_(e,o):null}function _t({onClick:e,children:t,className:n}){const r=z(Ut);/* @__PURE__ */
46
+ return X("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./ConfirmDialog-6LAVAGDE.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",Gt={};try{const e=localStorage.getItem(Jt);e&&(Gt=JSON.parse(e))}catch{}var Qt=null;function Zt(){Qt&&clearTimeout(Qt),Qt=setTimeout(()=>{try{localStorage.setItem(Jt,JSON.stringify(Gt))}catch{}},500)}var en="erp_activation_order",tn=[];try{const e=localStorage.getItem(en),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(tn=t)}catch{}var nn=null;function rn(){nn&&clearTimeout(nn),nn=setTimeout(()=>{try{localStorage.setItem(en,JSON.stringify(tn))}catch{}},500)}function on(e,t){Gt[e]||(Gt[e]=t,Zt())}function an(e){return Gt[e]?{...Gt[e]}:null}function sn(e,t){Gt[e]=t,Zt()}function ln(){const r=e(),o=t();let i=!1;for(const e of Object.keys(Gt))n(Gt[e],r,o)&&(delete Gt[e],i=!0);i&&Zt()}var cn={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},dn=4e3,un=()=>{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"},hn={small:.8,medium:1,large:1.25,maximized:1.25},mn=[],pn=/* @__PURE__ */new Set,fn=/* @__PURE__ */new Set,wn=0,yn=/* @__PURE__ */new Map;var gn=0;function bn(){return gn}function vn(){gn++,pn.forEach(e=>e())}var xn=/* @__PURE__ */new Map,kn=/* @__PURE__ */new Map,En=/* @__PURE__ */new Map;function Cn(){for(let e=mn.length-1;e>=0;e--){const t=En.get(mn[e]);if(t?.tab)return t.owner}return null}function Mn(){return $(ar,Cn,()=>null)}var Nn=/* @__PURE__ */new Set;var Sn=null;function Ln(e){Sn=null,In(e)}function Tn(e){Sn=e;const t=xn.get(e);t&&Ln(t)}function zn(e){Sn===e&&(Sn=null)}function An(e,t,n){if(n&&En.set(e,n),t)if(xn.set(t,e),kn.set(e,t),Nn.delete(t)){mn.unshift(e);const n=tn.indexOf(t);-1!==n&&tn.splice(n,1),tn.unshift(t),rn()}else!function(e,t){const n=tn.indexOf(t);if(-1===n)return void mn.push(e);let r=mn.length;for(let e=0;e<mn.length;e++){const t=kn.get(mn[e]);if(t&&tn.indexOf(t)>n){r=e;break}}mn.splice(r,0,e)}(e,t),-1===tn.indexOf(t)&&(tn.push(t),rn());else mn.push(e);vn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&Sn===t&&Ln(e)}function Dn(e){return e?En.get(e)?.owner??kn.get(e)??null:null}var Pn=/* @__PURE__ */new Set;function In(e){const t=Dn(ir()),n=mn.indexOf(e);-1!==n&&mn.splice(n,1),mn.push(e);const o=En.get(e);if(o?.root&&o.tab&&r()){const e=mn.filter(e=>{const t=En.get(e);return!!t&&!t.root&&t.owner===o.owner});for(const t of e)mn.splice(mn.indexOf(t),1),mn.push(t)}fn.delete(e);const i=kn.get(e);if(i){const e=tn.indexOf(i);-1!==e&&tn.splice(e,1),tn.push(i),rn(),Sn&&Sn!==i&&(Sn=null)}vn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const a=Dn(ir());a&&a!==t&&Pn.forEach(e=>e(a))}function Kn(e){const t=mn.indexOf(e);-1!==t&&mn.splice(t,1),fn.add(e),yn.set(e,++wn);const n=kn.get(e);if(n){const e=tn.indexOf(n);-1!==e&&(tn.splice(e,1),rn())}vn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var $n=/* @__PURE__ */new Set;var Wn=8,On=32;function Rn(){return e()}var Fn=40,qn=80,jn=384,Bn=400;function Hn(e,t=Rn()){const n=Math.min(Math.max(e.x,t.x+qn-e.w),t.x+t.w-qn),r=Math.min(Math.max(e.y,t.y),t.y+t.h-Fn);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=Rn();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 Yn(e){const t=Rn(),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 Xn=null;function Vn(e){const t=(Xn||((Xn=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${C.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(Xn)),Xn);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 _n(){Xn&&(Xn.style.opacity="0",Xn.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"}],Gn=350,Qn=200;function Zn({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o}){const[i,a]=K(!1),s=P(void 0),l=P(void 0);I(()=>()=>{clearTimeout(s.current),clearTimeout(l.current)},[]);const c=()=>{clearTimeout(l.current),s.current=setTimeout(()=>a(!0),Gn)},d=()=>{clearTimeout(s.current),l.current=setTimeout(()=>a(!1),Qn)};/* @__PURE__ */
47
+ return Y("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:d,children:[
48
+ /* @__PURE__ */X("button",{onClick:t,onFocus:c,onBlur:d,title:e?o.windowed:o.maximize,className:r,children:e?"❐":"⤢"}),i&&/* @__PURE__ */X("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__ */X("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__ */X("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var er="rosh-gesture-style";var tr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},nr=4;function rr(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(er))return;const e=document.createElement("style");e.id=er,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=bt(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function or(e){const t=mn.indexOf(e);if(-1===t)return-1;const n=C.window+t*C.windowStep,o=En.get(e);if(!o||o.root||!o.tab||!r())return n;let i=-1;for(const[e,t]of En){if(!t.root||t.owner!==o.owner)continue;const n=mn.indexOf(e);-1!==n&&(i=Math.max(i,C.window+n*C.windowStep))}return i>=n?i+2+Math.min(t,7):n}function ir(){return mn[mn.length-1]||null}function ar(e){return pn.add(e),()=>{pn.delete(e)}}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=mn.length-1;e>=0;e--)$n.has(mn[e])||mn.splice(e,1);tn=tn.filter(e=>{const t=xn.get(e);return null!=t&&$n.has(t)}),rn(),vn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var sr="modal-close-request";function lr(e){$(ar,bn);const t=z(Ut);if(mn.length<=1)return!0;if(e){const t=xn.get(e);if(null!=t)return ir()===t}return t?.active??null!=ir()}var cr=!1,dr=/* @__PURE__ */new Set;function ur(e){return dr.add(e),()=>dr.delete(e)}function hr(){return cr}function mr(e){cr!==e&&(cr=e,dr.forEach(e=>e()))}function pr(){mr(!cr)}function fr(){mr(!1)}var wr=null,yr=/* @__PURE__ */new Set;function gr(e){return yr.add(e),()=>yr.delete(e)}function br(){return wr}function vr(e){wr!==e&&(wr=e,yr.forEach(e=>e()))}var xr=null,kr=/* @__PURE__ */new Set;function Er(e){return kr.add(e),()=>kr.delete(e)}function Cr(){return xr}function Mr(e){xr!==e&&(xr=e,kr.forEach(e=>e()))}function Nr(){if(!xr)return void mr(!1);vr(xr),Mr(null),mr(!1)}function Sr(){mr(!cr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function Lr(){const e=$(ur,hr),[t,n]=K(e),[r,o]=K(e);return I(()=>{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?_(
49
+ /* @__PURE__ */X("div",{onMouseDown:e=>{e.stopPropagation(),mr(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:C.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 Tr({open:t,onClose:i,title:c,icon:d,copyText:u,size:h="lg",dirty:m=!1,onNext:p,onPrev:f,footer:g,bodyScroll:E,onMinimize:N,initialBox:T,actions:A,actionsLeft:R,editing:F=!1,allowPinOnTop:B,initialPosition:H,widget:U,compact:J,appStyle:G,flushBody:Q,autoHeight:Z,autoMinHeight:ee,autoWidth:te,widgetMenu:ne,dimensions:re,windowKey:oe,openedFromKey:ie,accentRgb:ae,children:se}){const le=w(),[de,ue]=K(0),[he,me]=K(!1),pe=P(null),fe=P(0);I(()=>{fe.current=de},[de]);const we=W(e=>{le&&(pe.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},me(!0),ht(ie??null))},[le,ie]),be=$(mt,ut);I(()=>{if(!he)return;const e=e=>{if(!pe.current)return;const t=e.clientX-pe.current.startX;if(Math.abs(e.clientY-pe.current.startY)>Math.abs(t)+12)return pe.current=null,me(!1),ue(0),void ht(null);ue(Math.max(0,t))},t=()=>{if(!pe.current)return;const e=.3*window.innerWidth,t=fe.current>e;pe.current=null,me(!1),t?(ue(window.innerWidth),setTimeout(()=>{i(),ue(0),ht(null)},180)):(ue(0),ht(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)}},[he]);const[xe,ke]=K(c),Ee=S(),Ce=Ee.window;I(()=>{ke(c)},[c]);const Me=j(()=>Ot(xe).trim()||void 0,[xe]),[Ne,Se]=K(!1),Le=P(!1),[Te,ze]=K(!1),[Ae,De]=K(null),Pe=z(Pt),Ie=z(ce),{prefs:Ke,save:We}=y(),Re=!!Ke.window_accent_stripe,Fe=Ke.favorite_documents||[],qe=!!Pe&&Fe.some(e=>e.entityType===Pe.entityType&&e.entityId===Pe.entityId),je=W(()=>{if(!Pe)return;const e=qe?Fe.filter(e=>!(e.entityType===Pe.entityType&&e.entityId===Pe.entityId)):[...Fe,{entityType:Pe.entityType,entityId:Pe.entityId,label:Pe.label}];We({favorite_documents:e})},[Pe,qe,Fe,We]),[Be,He]=K(null),[Ue,Ye]=K("top-right"===H?"right":"left"),Xe=P(!1),Ve=P(null);D(()=>{const e=Ve.current;e&&(ae?e.style.setProperty("--window-accent-rgb",ae):e.style.removeProperty("--window-accent-rgb"))},[ae]);const _e=P(!1),Je=P(null),Ge=P(null),Qe=P(null),[Ze,et]=K(!1),tt=P(null),nt=!!(g||A||R)||Ze,rt=z(ge),ot=""!==z(Dt),it=P(null);it.current=Ie?{owner:Ie.key,tab:Ie.tab,root:!ot}:null;const at=oe||(Ie&&!ot?Ie.key:null),st=!!rt&&!ot&&rt.enabled&&rt.hasState&&(F||rt.declaredEditable)&&!rt.handMounted&&nt&&!U&&!J&&!G&&!le,lt=/* @__PURE__ */X(L,{name:"window",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),ct=d&&O(d)?q(d,{className:`h-4 w-4 ${d.props?.className??""}`.trim()}):d??lt,dt=()=>/* @__PURE__ */X("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation();const t=e.currentTarget.getBoundingClientRect();De(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:ct}),pt=40,{minimize:ft,items:wt,restoreIfMinimized:yt,openWindows:gt}=Oe(),bt=P(`modal-${Math.random().toString(36).slice(2,8)}`).current;I(()=>{if(U)return $n.add(bt),()=>{$n.delete(bt)}},[U,bt]),I(()=>{const e=e=>{const t=e.detail;t?.id===bt&&ke(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[bt]);const[vt,xt]=K(C.window),kt=function(e){const t=$(ar,ir);return mn.length<=1||t===e}(bt),Ct=function(e){return $(ar,()=>fn.has(e))}(bt),Nt=$(ur,hr),St=$(gr,br),Tt=$(Er,Cr),zt=!B&&!U,At=Nt&&zt,[It,Kt]=K(!1),Rt=At&&Tt===bt,[Ft,jt]=K(!1),Bt=Ft&&zt&&St===bt?"picked":null,Ht=P(At);I(()=>{if(Ht.current&&!At){jt(!0);const e=setTimeout(()=>{jt(!1),wr===bt&&vr(null)},700);return Ht.current=At,()=>clearTimeout(e)}Ht.current=At},[At,bt]),I(()=>{At||Kt(!1)},[At]),I(()=>{const e=Ge.current,t=Qe.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>et(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]),I(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&Ve.current){const t=Ve.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=Ge.current,n=Qe.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const Yt=P(!1),Xt=W(e,[]),Vt=W(()=>{const t=e(),n=re?re[0]:cn[h]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=hn[un()],l=re?Math.min(re[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*(mn.length-1),d=Math.max(pt,(i-l)/2),u=(o-a)/2,m=t.h-pt-l-d;return"top-right"===H?{x:t.x+t.w-a-pt,y:t.y+pt,w:a,h:l}:"top-left"===H?{x:t.x+pt,y:t.y+pt,w:a,h:l}:{x:t.x+Math.max(pt,(o-a)/2+pt)+Math.min(c,Math.max(0,u)),y:t.y+d+Math.min(c,Math.max(0,m)),w:a,h:l}},[h]),_t=P(!1);t||(_t.current=!1);const Jt=oe||u||null;I(()=>{if(!t)return;An(bt,Jt,it.current??void 0),oe||In(bt),Yt.current=!1,xt(or(bt));const e=()=>{xt(or(bt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===oe;if(!e.label)return!1;const t=Ve.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if(In(bt),gn.current)return;const t=Rn(),n=Math.min(Ln.current.w,t.w-40),o=Math.min(Ln.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;tn({x:i,y:a,w:n,h:o}),Sn(!1)},i=e=>{const t=e.detail;r(t)&&(In(bt),De({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==oe)return;In(bt);const t=Ln.current,n=function(e,t=Rn()){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=Ve.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)}tn(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=mn.indexOf(e);-1!==t&&(mn.splice(t,1),vn()),fn.delete(e),yn.delete(e),En.delete(e);const n=kn.get(e);n&&(kn.delete(e),xn.delete(n))}(bt),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,bt,Jt,Xt]);const Qt=!U&&"maximized"===un(),[en,tn]=K(()=>{if(Jt&&Gt[Jt]){const e={...Gt[Jt]};return re&&(e.w=re[0],Z||(e.h=re[1])),Hn(e)}return T?{x:T.x,y:T.y,w:T.w,h:T.h}:Qt?Xt():Vt()}),[nn,rn]=K(()=>!Z),[on,an]=K(()=>r()),sn=P(on),ln=P(null);I(()=>{const e=()=>{const e=r();e!==sn.current&&ln.current?.(e),sn.current=e,an(e),xt(or(bt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[bt]);const pn=on&&!!Ie?.tab&&!ot&&!U&&!le,wn=pn,gn=P(wn);gn.current=wn;const bn=Mn(),Cn=on&&!!Ie?.tab&&!U&&!le&&!Nt&&bn!==Ie.key,[Nn,Sn]=K(()=>Jt&&Gt[Jt]||T?wn:wn||Qt),Ln=P(en);Ln.current=en;const Tn=P(Nn);D(()=>{Tn.current=Nn},[Nn]),D(()=>{if(nn||pn)return;const e=Ve.current,t=Je.current;if(!e||!t)return;const n=ee??(U?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,Ln.current.y)-24),g=w?Math.min(Ln.current.h,y):Math.min(Math.max(n,d+p),y),b=Math.abs(g-o)>1;b&&(o=g,tn(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),U||(g<=n?i&&(clearTimeout(i),i=null):(b||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&rn(!0)},160)))},l=new ResizeObserver(s);s(),tt.current&&l.observe(tt.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[nn,U,ee,nt,pn]),D(()=>{if(!Z||!nn||U||!t)return;const e=tt.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||Nn)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=ee??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,Ln.current.y)-24);tn(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[Z,nn,U,t,Nn,ee]);const zn=!1!==te&&!U&&!G&&!le,[Dn,Pn]=K(()=>!zn);D(()=>{if(Dn||!t)return;if(!zn||Nn)return void Pn(!0);const n=Ve.current,r=Je.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let i=Ln.current.w,c=0;const d=()=>Pn(!0),u=()=>{c=0;const t=Ln.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,pt);b!==t&&(i=b.w,tn(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,dn);return()=>{h.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(m)}},[Dn,t,zn,Nn]);const Fn=P(null),qn=!(!Ie?.tab||ot||U||le);ln.current=t=>{if(!qn)return;if(t)return Fn.current||(Fn.current={box:{...Ln.current},maximized:Tn.current}),void(Tn.current=!0);const r=Fn.current;Fn.current=null;const o=e();if(r?.maximized)return Tn.current=!0,Sn(!0),void tn(o);const i=r?.box??(Jt?Gt[Jt]:void 0);if(Tn.current=!1,Sn(!1),i&&!n(i,o,!1)){const e={...i};re&&(e.w=re[0],Z||(e.h=re[1])),tn(Hn(e))}else tn(Vt())},I(()=>{wn&&(Tn.current=!0,Sn(!0),tn(Xt()))},[wn,Xt]),I(()=>{if(U)return;const e=()=>{const e=Jt?Gt[Jt]:void 0;if(Tn.current=!1,Sn(!1),e){const t={...e};re&&(t.w=re[0],Z||(t.h=re[1])),tn(Hn(t))}else tn(Vt())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[U,Vt,Jt]),I(()=>{t&&Jt&&!pn&&(Gt[Jt]=en,Zt()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[en,t,Jt,pn]),I(()=>{if(!t)return;const e=()=>{Tn.current?tn(Xt()):document.body.classList.contains("rosh-gesturing")||tn(Hn)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return Nn&&(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,Nn,Xt]),I(()=>{if(t&&(Se(!1),Le.current=!1,Xe.current=!1,Pn(!zn),!gn.current)){if(Jt&&Gt[Jt]){const e=Gt[Jt];return void tn(t=>Hn({...e,...Z?{h:t.h}:{},...zn?{x:t.x,w:t.w}:{}}))}T&&(tn({x:T.x,y:T.y,w:T.w,h:T.h}),Sn(T.maximized))}},[t]),I(()=>{if(!t||"auto"!==m)return;let e;const n=t=>{Ve.current?.contains(t.target)&&!Le.current&&(Le.current=!0,e=setTimeout(()=>Se(!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 Un="auto"===m?Ne:!0===m,Xn=Ie&&!ot?Ie.key:null,Jn=j(()=>Et(xe),[xe]),Gn=P({shortcutSpec:Pe,isOnDesktop:qe,toggleDesktopShortcut:je,taskbarStrings:Ee.taskbar});D(()=>{Gn.current={shortcutSpec:Pe,isOnDesktop:qe,toggleDesktopShortcut:je,taskbarStrings:Ee.taskbar}});const Qn=P(null);Qn.current||(Qn.current={open:(e,t)=>De({x:e,y:t}),items:()=>{const e=Gn.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of qt[bt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),I(()=>{t&&Xn&&function(e,t){const n=Mt.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.menu===t.menu||(Mt.set(e,t),Lt())}(Xn,{title:Jn.text||Me,dirty:Un,copy:Jn.copy,menu:Qn.current??void 0})},[t,Xn,Me,Un,Jn.text,Jn.copy]),I(()=>{if(t&&Xn)return()=>{return e=Xn,void(Mt.delete(e)&&Lt());var e}},[t,Xn]),$e(!(oe||!t)&&Un);const er=W(async()=>{if(!Xe.current){if(Un||"auto"===m&&Le.current){Xe.current=!0;const e=Me,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(Xe.current=!1,!t)return}i()}},[Un,m,i,Me]);D(()=>{if(!t||!at)return;const e=e=>{e.detail?.windowKey===at&&er()};return window.addEventListener(sr,e),()=>window.removeEventListener(sr,e)},[t,at,er]);const lr=P(null),cr=W(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if(De(null),In(bt),gn.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=Ve.current,s=a?.getBoundingClientRect();let l,c,d,u;if(lr.current){const t=lr.current;lr.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:Ln.current.x,c=s?s.top:Ln.current.y,d=s?s.height:Ln.current.h,u=s?s.width:Ln.current.w;Sn(!1),tn(e=>({...e,x:l,y:c,w:u,h:d}));let h=null;const m=e=>{if(!r){if(Math.abs(e.clientX-o)<nr&&Math.abs(e.clientY-i)<nr)return;r=rr(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)`),Ln.current={...Ln.current,x:s,y:d},!U){const t=function(e,t){const n=Rn(),r=e<=n.x+Wn,o=e>=n.x+n.w-Wn,i=t<=n.y+Wn,a=t>=n.y+n.h-Wn,s=e<=n.x+On,l=e>=n.x+n.w-On,c=t<=n.y+On,d=t>=n.y+n.h-On;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?Vn(Yn(t)):_n())}},p=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),r?.(),_n();const e=Hn({...Ln.current});if(Ln.current=e,!U&&h){lr.current={x:l,y:c,w:u,h:d};const e=Yn(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 tn(e)}if(U){const t=e.x+e.w/2,n=window.innerWidth/2;Ye(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),tn(e)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",p)},[]),dr=W((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=Ve.current,l=s?.getBoundingClientRect(),c=l?l.left:Ln.current.x,d=l?l.top:Ln.current.y,u=l?l.width:Ln.current.w,h=l?l.height:Ln.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;Sn(!1),tn({x:c,y:d,w:u,h:h}),Ln.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,Ln.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)<nr&&Math.abs(e.clientY-a)<nr)return;o=rr(n,r,tr[t],"resize")}g=((e,t)=>{let n=c,r=d,o=u,i=h;if(f&&(o=Math.max(jn,u+e)),w&&(i=Math.max(Bn,h+t)),m){const t=Math.max(jn,u-e);n=c+u-t,o=t}if(p){const e=Math.max(Bn,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?.(),tn({...Ln.current})};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x)},[]),pr=W(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(),In(bt),"Enter"===e.key)return void(Nn?(Sn(!1),tn(Vt())):(Sn(!0),tn(Xt())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{lr.current||(lr.current={...Ln.current})};if(r<0)return e(),Sn(!0),void tn(Xt());if(r>0){if(Nn)return Sn(!1),void tn(Vt());if(lr.current){const e=Hn(lr.current);return lr.current=null,Ln.current=e,void tn(e)}return void Kn(bt)}e(),Sn(!1);const t=Yn(n<0?"left":"right");return Ln.current=t,void tn(t)}if(Nn)return;const o=Ln.current,i=e.shiftKey?{...o,w:Math.max(jn,o.w+24*n),h:Math.max(Bn,o.h+24*r)}:Hn({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});Ln.current=i,tn(i)},[bt,Nn,Vt,Xt]),fr=W(e=>{lr.current||(lr.current={...Ln.current}),Sn(!1);const t=Yn(e);Ln.current=t,tn(t),In(bt)},[bt]),yr=wn||At?{}:{tabIndex:0,role:"group","aria-label":Me?`${Me} — ${Ce.windowSuffix}`:Ce.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:pr},xr=()=>{Sn(!0),tn(Xt())},kr=W(()=>{const e=Ve.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector($t);t&&!t.disabled&&t.click()}},[]);I(()=>{if(!t)return;if(U)return;const e=e=>{if(mn[mn.length-1]===bt&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),kr();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&Ve.current?.contains(t)))return;if(t.closest(Wt))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,kr,bt,U]),I(()=>{if(!t)return;const e=e=>{mn[mn.length-1]===bt&&((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:bt}})),Le.current=!1,Se(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:bt}}))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),I(()=>{if(!t)return;if(U)return;const e=e=>{if("Escape"===e.key&&mn[mn.length-1]===bt){if(M(e))return e.preventDefault(),void e.stopPropagation();if(pn&&!F)return;e.preventDefault(),e.stopPropagation(),er()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,er,bt,U,pn,F]);const Mr=t&&(void 0!==p||void 0!==f),Nr=W(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(I(()=>{if(!t)return;const e=e=>{if(mn[mn.length-1]!==bt)return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&Mr&&(e.preventDefault(),p?p():Nr("bottom")),"k"===e.key&&Mr&&(e.preventDefault(),f?f():Nr("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,f,Mr,Nr,bt]),!t||_t.current)return null;const Sr=At?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=Rn(),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}}(bt):null,Lr=At&&Sr?Math.min(Sr.w/en.w,Sr.h/en.h):1,Tr=(()=>{if(At&&Sr){const e=Lr,t=en.w*e,n=en.h*e,r=Sr.x+(Sr.w-t)/2-en.x,o=Sr.y+(Sr.h-n)/2-en.y,i=It||Rt;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:C.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(Ft&&zt){const e="picked"===Bt;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:C.expose+30}:{}}}return null})(),zr=/* @__PURE__ */Y("div",{children:[
50
+ /* @__PURE__ */Y("div",{ref:Ve,"data-modal-panel":!0,"data-modal-id":bt,"data-window-key":oe||void 0,...B?{"data-utility":""}:{},...Te?{"data-pinned-top":""}:{},...U?{"data-widget":""}:{},...Ie?{"data-window-owner":Ie.key}:{},...Ie&&!ot?{"data-window-root":""}:{},...pn?{"data-window-tab":""}:{},className:pn?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(U?kt?"shadow-xl":"shadow-lg":"border "+(kt?"shadow-xl border-gray-200":"shadow-lg border-gray-300")),onMouseDownCapture:e=>{if(_e.current=!1,At){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),vr(bt),mr(!1),void In(bt)}if(!kt&&!U&&!Te&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===Ve.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),_e.current=!0,De(null),In(bt),window.addEventListener("mouseup",()=>{setTimeout(()=>{_e.current=!1},0)},{once:!0}))}},onClickCapture:e=>{_e.current&&(_e.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if(At)return;De(null);e.target.closest("[data-modal-panel]")===Ve.current&&(e.target.closest("button, input, a, select, textarea")||In(bt))},style:le?{zIndex:vt+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${de}px)`,transition:he?"none":"transform 180ms ease-out",...U?{display:"none"}:{},...vt<0?{display:"none"}:{},...kt||Te||be&&oe===be?{}:{display:"none"}}:{zIndex:Te?C.pinnedWindow:vt+1,width:en.w,height:en.h,top:en.y,...U&&"right"===Ue?{right:window.innerWidth-en.x-en.w}:{left:en.x},...vt<0&&!Te?{display:"none"}:{},...Cn?{visibility:"hidden",pointerEvents:"none"}:{},...Tr??{}},children:[le&&!U&&/* @__PURE__ */X("div",{onPointerDown:we,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),U?null:pn?Ie?.home?null:/* @__PURE__ */Y(V,{children:[
51
+ /* @__PURE__ */X("h2",{"data-window-title":!0,className:"sr-only",children:Jn.text||Me}),(Jn.accessories.length>0||Mr)&&/* @__PURE__ */Y("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
+ /* @__PURE__ */X("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:Jn.accessories}),Mr&&/* @__PURE__ */Y("span",{className:"flex items-center gap-1 shrink-0 text-2xs text-gray-400",children:[
53
53
  /* @__PURE__ */X("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-2 py-0.5 font-medium text-gray-500",children:"K"}),
54
54
  /* @__PURE__ */X("span",{children:Ce.prev}),
55
55
  /* @__PURE__ */X("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__ */X("span",{children:Ce.next})]})]})]}):le?null:
57
- /* @__PURE__ */U("div",J?{onPointerDown:cr,"data-window-chrome":"",...yr,className:"flex items-center justify-between h-8 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 "+(kt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:kt?"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__ */U("div",{"data-window-title":!0,title:Me,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:kt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!At&&dt(),
59
- /* @__PURE__ */X("span",{className:"truncate",children:At?Ot(xe):xe})]}),!At&&/* @__PURE__ */U("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[B&&/* @__PURE__ */X("button",{onClick:()=>ze(e=>!e),title:Te?Ce.unpin:Ce.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(Te?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */X(L,{name:"bookmark-square",className:"h-3 w-3",fill:Te?"currentColor":"none",strokeWidth:1.5})}),
60
- /* @__PURE__ */X("button",{type:"button",onClick:er,className:"rounded p-0.5 text-gray-400 hover:text-gray-600 hover:bg-gray-200",children:/* @__PURE__ */X(L,{name:"close",className:"h-4 w-4"})})]})]}:G?{onPointerDown:cr,"data-window-chrome":"",...yr,className:"flex items-center justify-between h-8 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 "+(kt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:kt?"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__ */U("div",{"data-window-title":!0,title:Me,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:kt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!At&&dt(),
62
- /* @__PURE__ */X("span",{className:"truncate",children:At?Ot(xe):xe})]}),!At&&/* @__PURE__ */U("div",{className:"flex items-center gap-0.5 shrink-0 ml-2",children:[B&&/* @__PURE__ */X("button",{onClick:()=>ze(e=>!e),title:Te?Ce.unpin:Ce.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(Te?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */X(L,{name:"bookmark-square",className:"h-3 w-3",fill:Te?"currentColor":"none",strokeWidth:1.5})}),
63
- /* @__PURE__ */X("button",{onClick:()=>$n(bt),title:Ce.minimize,className:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",children:"─"}),!wn&&/* @__PURE__ */X(Zn,{maximized:Nn,onToggleMax:()=>{Nn?(Sn(!1),tn(Vt())):xr()},onSnap:fr,buttonClassName:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",strings:Ce}),
57
+ /* @__PURE__ */Y("div",J?{onPointerDown:cr,"data-window-chrome":"",...yr,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 "+(kt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:kt?"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__ */Y("div",{"data-window-title":!0,title:Me,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:kt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!At&&dt(),
59
+ /* @__PURE__ */X("span",{className:"truncate",children:At?Ot(xe):xe})]}),!At&&/* @__PURE__ */Y("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[B&&/* @__PURE__ */X("button",{onClick:()=>ze(e=>!e),title:Te?Ce.unpin:Ce.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(Te?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */X(L,{name:"bookmark-square",className:"h-3 w-3",fill:Te?"currentColor":"none",strokeWidth:1.5})}),
60
+ /* @__PURE__ */X("button",{type:"button",onClick:er,className:"rounded p-0.5 text-gray-400 hover:text-gray-600 hover:bg-gray-200",children:/* @__PURE__ */X(L,{name:"close",className:"h-4 w-4"})})]})]}:G?{onPointerDown:cr,"data-window-chrome":"",...yr,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 "+(kt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:kt?"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__ */Y("div",{"data-window-title":!0,title:Me,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:kt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!At&&dt(),
62
+ /* @__PURE__ */X("span",{className:"truncate",children:At?Ot(xe):xe})]}),!At&&/* @__PURE__ */Y("div",{className:"flex items-center gap-0.5 shrink-0 ml-2",children:[B&&/* @__PURE__ */X("button",{onClick:()=>ze(e=>!e),title:Te?Ce.unpin:Ce.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(Te?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */X(L,{name:"bookmark-square",className:"h-3 w-3",fill:Te?"currentColor":"none",strokeWidth:1.5})}),
63
+ /* @__PURE__ */X("button",{onClick:()=>Kn(bt),title:Ce.minimize,className:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",children:"─"}),!wn&&/* @__PURE__ */X(Zn,{maximized:Nn,onToggleMax:()=>{Nn?(Sn(!1),tn(Vt())):xr()},onSnap:fr,buttonClassName:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",strings:Ce}),
64
64
  /* @__PURE__ */X("button",{type:"button",onClick:er,className:"rounded p-0.5 text-gray-400 hover:text-gray-600 hover:bg-gray-200",children:/* @__PURE__ */X(L,{name:"close",className:"h-4 w-4"})})]})]}:{onPointerDown:cr,"data-window-chrome":"",...yr,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 "+(kt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:kt?"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__ */U("div",{"data-window-title":!0,title:Me,className:"text-base font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:kt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!At&&dt(),
66
- /* @__PURE__ */X("span",{className:"truncate",children:At?Ot(xe):xe})]}),!At&&/* @__PURE__ */U("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:[Mr&&/* @__PURE__ */U("span",{className:"flex items-center gap-1 mr-1 text-2xs text-gray-400",children:[
65
+ /* @__PURE__ */Y("div",{"data-window-title":!0,title:Me,className:"text-base font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:kt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!At&&dt(),
66
+ /* @__PURE__ */X("span",{className:"truncate",children:At?Ot(xe):xe})]}),!At&&/* @__PURE__ */Y("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:[Mr&&/* @__PURE__ */Y("span",{className:"flex items-center gap-1 mr-1 text-2xs text-gray-400",children:[
67
67
  /* @__PURE__ */X("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__ */X("span",{children:Ce.prev}),
69
69
  /* @__PURE__ */X("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
70
  /* @__PURE__ */X("span",{children:Ce.next})]}),B&&/* @__PURE__ */X("button",{onClick:()=>ze(e=>!e),title:Te?Ce.unpin:Ce.pinOnTop,className:"text-xs px-2 py-1 rounded hover:bg-gray-200 "+(Te?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */X(L,{name:"bookmark-square",className:"h-3.5 w-3.5",fill:Te?"currentColor":"none",strokeWidth:1.5})}),
71
- /* @__PURE__ */X("button",{onClick:()=>$n(bt),title:Ce.minimize,className:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",children:"─"}),!wn&&/* @__PURE__ */X(Zn,{maximized:Nn,onToggleMax:()=>{Nn?(Sn(!1),tn(Vt())):xr()},onSnap:fr,buttonClassName:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",strings:Ce}),
71
+ /* @__PURE__ */X("button",{onClick:()=>Kn(bt),title:Ce.minimize,className:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",children:"─"}),!wn&&/* @__PURE__ */X(Zn,{maximized:Nn,onToggleMax:()=>{Nn?(Sn(!1),tn(Vt())):xr()},onSnap:fr,buttonClassName:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",strings:Ce}),
72
72
  /* @__PURE__ */X("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__ */X("button",{type:"button",onClick:er,className:"rounded-(--radius-control) text-gray-400 hover:text-gray-600",children:/* @__PURE__ */X(L,{name:"close",className:"h-5 w-5"})})]})]}),ae&&Re&&!Y&&!le&&/* @__PURE__ */X("div",{"aria-hidden":"true",className:"h-[3px] shrink-0 pointer-events-none",style:{backgroundColor:`rgb(var(--window-accent-rgb) / ${kt?.9:.55})`}}),
74
- /* @__PURE__ */X(Dt.Provider,{value:bt,children:/* @__PURE__ */X(Yt.Provider,{value:{rightRef:Ge,leftRef:Qe,notify:()=>et(!0),active:kt,isDirty:Yn,footerOpen:nt&&!Y&&!J&&!G&&!le},children:/* @__PURE__ */X("div",{ref:Je,...Y?{onPointerDown:cr,onContextMenu:e=>{e.preventDefault(),He({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${Y?"p-0 cursor-move":G||Q?"p-0":J?"p-2":"p-4"} ${Y||pn?"":"backdrop-blur-sm"} ${!1===E||G||Q?"overflow-hidden":"overflow-y-auto overscroll-contain"} ${Y?"rounded-2xl select-none":""}`,style:{...Y?{touchAction:"none"}:{},backgroundColor:Y?"transparent":pn?"rgb(var(--window-content-rgb))":kt?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */X(ye,{children:se})})})}),Y&&Be&&/* @__PURE__ */U(v,{minWidth:160,style:{left:Be.x,top:Be.y},onClose:()=>He(null),children:[
73
+ /* @__PURE__ */X("button",{type:"button",onClick:er,className:"rounded-(--radius-control) text-gray-400 hover:text-gray-600",children:/* @__PURE__ */X(L,{name:"close",className:"h-5 w-5"})})]})]}),ae&&Re&&!U&&!le&&/* @__PURE__ */X("div",{"aria-hidden":"true",className:"h-[3px] shrink-0 pointer-events-none",style:{backgroundColor:`rgb(var(--window-accent-rgb) / ${kt?.9:.55})`}}),
74
+ /* @__PURE__ */X(Dt.Provider,{value:bt,children:/* @__PURE__ */X(Ut.Provider,{value:{rightRef:Ge,leftRef:Qe,notify:()=>et(!0),active:kt,isDirty:Un,footerOpen:nt&&!U&&!J&&!G&&!le},children:/* @__PURE__ */X("div",{ref:Je,...U?{onPointerDown:cr,onContextMenu:e=>{e.preventDefault(),He({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${U?"p-0 cursor-move":G||Q?"p-0":J?"p-2":"p-4"} ${U||pn?"":"backdrop-blur-sm"} ${!1===E||G||Q?"overflow-hidden":"overflow-y-auto overscroll-contain"} ${U?"rounded-2xl select-none":""}`,style:{...U?{touchAction:"none"}:{},backgroundColor:U?"transparent":pn?"rgb(var(--window-content-rgb))":kt?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */X(ye,{children:se})})})}),U&&Be&&/* @__PURE__ */Y(v,{minWidth:160,style:{left:Be.x,top:Be.y},onClose:()=>He(null),children:[
75
75
  /* @__PURE__ */X(x,{onClick:()=>{He(null),window.dispatchEvent(new CustomEvent("widget-open-settings",{detail:bt}))},children:"Settings"}),
76
- /* @__PURE__ */X(k,{}),ne&&/* @__PURE__ */U(V,{children:[ne,
76
+ /* @__PURE__ */X(k,{}),ne&&/* @__PURE__ */Y(V,{children:[ne,
77
77
  /* @__PURE__ */X(k,{})]}),
78
- /* @__PURE__ */U(x,{onClick:()=>{He(null),ze(e=>!e)},children:[
78
+ /* @__PURE__ */Y(x,{onClick:()=>{He(null),ze(e=>!e)},children:[
79
79
  /* @__PURE__ */X("span",{className:"flex-1",children:"Always on Top"}),Te&&/* @__PURE__ */X(L,{name:"check",className:"h-4 w-4 text-blue-600 shrink-0",strokeWidth:2})]}),
80
80
  /* @__PURE__ */X(k,{}),
81
81
  /* @__PURE__ */X(x,{onClick:()=>{He(null),er()},children:"Close"})]}),
82
- /* @__PURE__ */U("div",{onPointerDown:cr,ref:tt,className:`px-4 py-2 border-t border-gray-200 shrink-0 flex items-center justify-between text-xs select-none${pn?"":" cursor-move"}${kt&&!pn?" backdrop-blur-sm":""}${Y||J||G||le||!nt?" hidden":""}`,style:{touchAction:"none",backgroundColor:pn?"rgb(var(--window-footer-rgb))":kt?"rgb(var(--window-footer-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-footer-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
83
- /* @__PURE__ */U("div",{className:"flex items-center gap-2 min-w-0",children:[st&&/* @__PURE__ */X(ve,{auto:!0}),R,
82
+ /* @__PURE__ */Y("div",{onPointerDown:cr,ref:tt,className:`px-4 py-2 border-t border-gray-200 shrink-0 flex items-center justify-between text-xs select-none${pn?"":" cursor-move"}${kt&&!pn?" backdrop-blur-sm":""}${U||J||G||le||!nt?" hidden":""}`,style:{touchAction:"none",backgroundColor:pn?"rgb(var(--window-footer-rgb))":kt?"rgb(var(--window-footer-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-footer-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
83
+ /* @__PURE__ */Y("div",{className:"flex items-center gap-2 min-w-0",children:[st&&/* @__PURE__ */X(ve,{auto:!0}),R,
84
84
  /* @__PURE__ */X("div",{ref:Qe,"data-modal-actions-left":!0,className:"flex items-center gap-2"}),g]}),
85
- /* @__PURE__ */U("div",{className:"flex items-center gap-2 ml-auto",children:[
86
- /* @__PURE__ */X("div",{ref:Ge,"data-modal-actions":!0,className:"flex items-center gap-2"}),A]})]}),!Y&&!le&&!At&&kt&&!wn&&/* @__PURE__ */U(V,{children:[
85
+ /* @__PURE__ */Y("div",{className:"flex items-center gap-2 ml-auto",children:[
86
+ /* @__PURE__ */X("div",{ref:Ge,"data-modal-actions":!0,className:"flex items-center gap-2"}),A]})]}),!U&&!le&&!At&&kt&&!wn&&/* @__PURE__ */Y(V,{children:[
87
87
  /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"se"),className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize z-10"}),
88
88
  /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"sw"),className:"absolute bottom-0 left-0 w-3 h-3 cursor-nesw-resize z-10"}),
89
89
  /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"ne"),className:"absolute top-0 right-0 w-3 h-3 cursor-nesw-resize z-10"}),
@@ -91,18 +91,18 @@ return U("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:d,
91
91
  /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"n"),className:"absolute top-0 left-3 right-3 h-1 cursor-ns-resize"}),
92
92
  /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"s"),className:"absolute bottom-0 left-3 right-3 h-1 cursor-ns-resize"}),
93
93
  /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"e"),className:"absolute top-3 bottom-3 right-0 w-1 cursor-ew-resize"}),
94
- /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"w"),className:"absolute top-3 bottom-3 left-0 w-1 cursor-ew-resize"})]}),At&&/* @__PURE__ */X("div",{className:"absolute inset-0",style:{zIndex:9999,cursor:"pointer",background:"transparent"},onMouseEnter:()=>$t(!0),onMouseLeave:()=>$t(!1),onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),In(bt),mr(!1)},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:It&&/* @__PURE__ */X("button",{type:"button","data-expose-close":!0,"aria-label":Ee.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/Lr})`,transformOrigin:"top right",zIndex:1e4},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:e=>{e.stopPropagation(),e.preventDefault(),er()},children:/* @__PURE__ */X(L,{name:"close",className:"h-4 w-4",strokeWidth:2.2})})})]}),At&&Sr&&/* @__PURE__ */X("div",{className:"fixed pointer-events-none select-none truncate text-center",style:{left:Sr.x,top:Sr.y+Sr.h+4,width:Sr.w,zIndex:C.expose+(It?21:11),color:"white",fontSize:"var(--text-xs)",fontWeight:500,textShadow:"0 1px 2px rgba(0,0,0,0.6)"},children:Ot(xe)})]}),Ar=Ae&&/* @__PURE__ */U(v,{style:{left:Ae.x,top:Ae.y},onClose:()=>De(null),minWidth:160,children:[!Y&&!J&&!pn&&/* @__PURE__ */U(V,{children:[
95
- /* @__PURE__ */U(x,{onClick:()=>{$n(bt),De(null)},children:[
96
- /* @__PURE__ */X(L,{name:"remove",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),Ce.minimize]}),!wn&&/* @__PURE__ */U(x,Nn?{onClick:()=>{Sn(!1),tn(Vt()),De(null)},children:[
94
+ /* @__PURE__ */X("div",{onPointerDown:e=>dr(e,"w"),className:"absolute top-3 bottom-3 left-0 w-1 cursor-ew-resize"})]}),At&&/* @__PURE__ */X("div",{className:"absolute inset-0",style:{zIndex:C.hint,cursor:"pointer",background:"transparent"},onMouseEnter:()=>Kt(!0),onMouseLeave:()=>Kt(!1),onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),In(bt),mr(!1)},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:It&&/* @__PURE__ */X("button",{type:"button","data-expose-close":!0,"aria-label":Ee.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/Lr})`,transformOrigin:"top right",zIndex:C.raised},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:e=>{e.stopPropagation(),e.preventDefault(),er()},children:/* @__PURE__ */X(L,{name:"close",className:"h-4 w-4",strokeWidth:2.2})})})]}),At&&Sr&&/* @__PURE__ */X("div",{className:"fixed pointer-events-none select-none truncate text-center",style:{left:Sr.x,top:Sr.y+Sr.h+4,width:Sr.w,zIndex:C.expose+(It?21:11),color:"white",fontSize:"var(--text-xs)",fontWeight:500,textShadow:"0 1px 2px rgba(0,0,0,0.6)"},children:Ot(xe)})]}),Ar=Ae&&/* @__PURE__ */Y(v,{style:{left:Ae.x,top:Ae.y},onClose:()=>De(null),minWidth:160,children:[!U&&!J&&!pn&&/* @__PURE__ */Y(V,{children:[
95
+ /* @__PURE__ */Y(x,{onClick:()=>{Kn(bt),De(null)},children:[
96
+ /* @__PURE__ */X(L,{name:"remove",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),Ce.minimize]}),!wn&&/* @__PURE__ */Y(x,Nn?{onClick:()=>{Sn(!1),tn(Vt()),De(null)},children:[
97
97
  /* @__PURE__ */X("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */X("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 4.5v15m6-15v15M4.5 9h15M4.5 15h15"})}),Ce.windowed]}:{onClick:()=>{xr(),De(null)},children:[
98
- /* @__PURE__ */X(L,{name:"expand",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),Ce.maximize]})]}),B&&!pn&&/* @__PURE__ */U(x,{onClick:()=>{ze(e=>!e),De(null)},children:[
99
- /* @__PURE__ */X(L,{name:"bookmark-square",className:"h-4 w-4 "+(Te?"text-blue-600":"text-gray-400"),fill:Te?"currentColor":"none",strokeWidth:1.5}),Te?Ce.unpin:Ce.pinOnTop]}),Pe&&/* @__PURE__ */U(x,{onClick:()=>{De(null),je()},children:[
100
- /* @__PURE__ */X(L,{name:"star",className:"h-4 w-4 "+(qe?"text-yellow-500":"text-gray-400"),fill:qe?"currentColor":"none",strokeWidth:1.5}),qe?Ee.taskbar.removeFromDesktop:Ee.taskbar.addToDesktop]}),(qt[bt]||[]).length>0&&/* @__PURE__ */X(V,{children:(qt[bt]||[]).map((e,t)=>/* @__PURE__ */U(x,{onClick:()=>{De(null),e.onClick()},children:[e.icon,e.label]},t))}),!(pn&&Ie?.home)&&/* @__PURE__ */U(V,{children:[
98
+ /* @__PURE__ */X(L,{name:"expand",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),Ce.maximize]})]}),B&&!pn&&/* @__PURE__ */Y(x,{onClick:()=>{ze(e=>!e),De(null)},children:[
99
+ /* @__PURE__ */X(L,{name:"bookmark-square",className:"h-4 w-4 "+(Te?"text-blue-600":"text-gray-400"),fill:Te?"currentColor":"none",strokeWidth:1.5}),Te?Ce.unpin:Ce.pinOnTop]}),Pe&&/* @__PURE__ */Y(x,{onClick:()=>{De(null),je()},children:[
100
+ /* @__PURE__ */X(L,{name:"star",className:"h-4 w-4 "+(qe?"text-yellow-500":"text-gray-400"),fill:qe?"currentColor":"none",strokeWidth:1.5}),qe?Ee.taskbar.removeFromDesktop:Ee.taskbar.addToDesktop]}),(qt[bt]||[]).length>0&&/* @__PURE__ */X(V,{children:(qt[bt]||[]).map((e,t)=>/* @__PURE__ */Y(x,{onClick:()=>{De(null),e.onClick()},children:[e.icon,e.label]},t))}),!(pn&&Ie?.home)&&/* @__PURE__ */Y(V,{children:[
101
101
  /* @__PURE__ */X(k,{}),
102
- /* @__PURE__ */U(x,{danger:!0,onClick:()=>{De(null),er()},children:[
103
- /* @__PURE__ */X(L,{name:"close",className:"h-4 w-4"}),Ce.close]})]})]}),Dr=!!oe&&gt.some(e=>e.id===oe),Pr=!Ct||Dr||Y?null:/* @__PURE__ */U("div",{"data-modal-restore-tab":!0,"data-modal-id":bt,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:[
102
+ /* @__PURE__ */Y(x,{danger:!0,onClick:()=>{De(null),er()},children:[
103
+ /* @__PURE__ */X(L,{name:"close",className:"h-4 w-4"}),Ce.close]})]})]}),Dr=!!oe&&gt.some(e=>e.id===oe),Pr=!Ct||Dr||U?null:/* @__PURE__ */Y("div",{"data-modal-restore-tab":!0,"data-modal-id":bt,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
104
  /* @__PURE__ */X("button",{type:"button",onClick:()=>In(bt),title:Ce.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:Me||Ce.windowSuffix}),
105
105
  /* @__PURE__ */X("button",{type:"button",onClick:()=>In(bt),title:Ce.restore,"aria-label":Ce.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
106
  /* @__PURE__ */X("button",{type:"button",onClick:()=>{er()},title:Ce.close,"aria-label":Ce.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 _(
107
- /* @__PURE__ */U(Pt.Provider,{value:null,children:[zr,Ar,Pr]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{cr&&"Escape"===e.key&&(Mr(null),mr(!1))});var zr=100,Ar={past:[],future:[]};function Dr(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>zr?r.slice(r.length-zr):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:Ar}}var Pr=/* @__PURE__ */new Set(["INPUT","TEXTAREA","SELECT"]);var Ir=500,$r=250;function Kr({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,a]=B(Dr,Ar),s=P(/* @__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=P(null),b=P(!1),v=W(()=>{const e={};for(const[t,n]of s.current)e[t]=n.getLast();return e},[]),x=W((e,t)=>{s.current.has(e)||c(e=>e+1),s.current.set(e,t)},[]),k=W(e=>{s.current.delete(e)&&c(e=>e-1)},[]),E=W(e=>{h(t=>t+(e?1:-1))},[]),C=W(e=>{p(t=>t+(e?1:-1))},[]),[M,N]=$(0),S=M>0,L=W(e=>{N(t=>t+(e?1:-1))},[]),T=z(ge),A=T?.claimReadOnly;I(()=>{if(A&&!y)return A(!0),()=>A(!1)},[A,y]);const D=T?.claimOwnMount;I(()=>{if(D&&S)return D(!0),()=>D(!1)},[D,S]);const K=P({last:0,count:0,tripped:!1}),O=P(!1),R=W((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)||(O.current=!0));if(!y||g.current)return;const r=K.current;if(r.tripped)return;const o=Date.now();if(o-r.last>$r&&(r.count=0),r.last=o,++r.count>Ir)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${Ir} 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=W(e=>{for(const[t,n]of Object.entries(e)){const e=s.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),q=W(()=>{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]),H=W(()=>{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]),[Y,V]=$(0),_=P(0),J=P(0),G=P(!1),Q=W(()=>{b.current=!0,O.current=!1,g.current=null,_.current+=1,J.current=_.current,V(_.current)},[]),Z=P(void 0),ee=W(e=>{void 0!==e&&(void 0!==Z.current&&e!==Z.current&&(G.current=!0),Z.current=e),Q()},[Q]);I(()=>{b.current&&Y===J.current&&(b.current=!1,g.current=null,(O.current||G.current)&&a({type:"clear"}),O.current=!1,G.current=!1)},[Y]);const te=W(()=>{G.current=!0,a({type:"clear"}),Q()},[Q]),ne=y&&o.past.length>0,re=y&&o.future.length>0,oe=lr(r),ie=P({undo:q,redo:H,canUndo:ne,canRedo:re});ie.current={undo:q,redo:H,canUndo:ne,canRedo:re},I(()=>{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&&Pr.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=j(()=>({register:x,unregister:k,record:R,undo:q,redo:H,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,H,te,ee,ne,re,y,d,S,L,E,f,C,o.past,o.future]),se=""!==Ut(),le=z(Yt)?.footerOpen??!1,ce=se&&y&&d&&!S&&le;/* @__PURE__ */
108
- return U(ge.Provider,{value:ae,children:[ce&&/* @__PURE__ */X(Vt,{position:"left",quiet:!0,children:/* @__PURE__ */X(ve,{auto:!0})}),e]})}function Wr(){const e=z(ge),t=W(()=>{},[]);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 Or(e){const t=z(ge),n=t?.claimReadOnly,r=t?.claimEditable;I(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}function Rr(e,t,n){const r=z(ge),o=H(),i=P(e),a=P(t);a.current=t,I(()=>{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=P(r);c.current=r;const d=P({label:s,coalesceKey:l});d.current={label:s,coalesceKey:l},I(()=>{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 Fr(e,t){const[n,r]=$(e);return Rr(n,e=>r(()=>e),t),[n,r]}export{_t as CancelButton,qe as DocFavStar,Te as EntityWindowFallback,Se as EntityWindowLoading,ze as EntityWindowState,Wt as KEY_ACTIVATED_SELECTOR,Me as LoadingSpinner,Kt as MODAL_SUBMIT_SELECTOR,Tr as Modal,Vt as ModalActions,ve as UndoControls,Kr as UndoProvider,re as WINDOW_REGISTRY,we as WindowCrashedFallback,ye as WindowErrorBoundary,lt as WindowManagerProvider,Bt as WindowTitle,Ue as activateWindowById,bt as beginWindowGesture,zn as cancelWindowFront,le as client_default,Nr as commitExposeHighlight,vt as drainPerfEvents,fr as exitExposeMode,ln as forgetMaximizedWindowBoxes,ir as getActiveModalId,Je as getActiveWindowRoute,Cr as getExposeHighlight,At as getWindowChromeVersion,an as getWindowPosition,De as isDraftEntityId,Pe as isDraftEntityWindow,ee as isEntityEntry,Z as isPageEntry,ae as isShellApiClientConfigured,Xe as isTabWindow,gt as markMenuOpen,Tt as readWindowChrome,Tn as requestWindowFront,Mr as setExposeHighlight,yt as setPerfCollecting,ie as setShellApiClient,me as setShellHomeRoute,ne as setShellWindowRegistry,on as setWindowDefaultPosition,sn as setWindowPosition,Et as splitTitle,Er as subscribeExposeHighlight,zt as subscribeWindowChrome,pr as toggleExposeMode,Mn as useCurrentTabKey,Ut as useEnclosingModalId,lr as useIsActiveWindow,Xt as useModalActive,de as usePageSearch,Wr as useUndo,Or as useUndoCanEdit,Rr as useUndoable,Fr as useUndoableState,Ft as useWidgetSettings,Ke as useWindowDirty,Oe as useWindowManager,jt as useWindowMenuItem,Ht as useWindowTitle};
107
+ /* @__PURE__ */Y(Pt.Provider,{value:null,children:[zr,Ar,Pr]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{cr&&"Escape"===e.key&&(Mr(null),mr(!1))});var zr=100,Ar={past:[],future:[]};function Dr(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>zr?r.slice(r.length-zr):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:Ar}}var Pr=/* @__PURE__ */new Set(["INPUT","TEXTAREA","SELECT"]);var Ir=500,Kr=250;function $r({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,a]=B(Dr,Ar),s=P(/* @__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=P(null),b=P(!1),v=W(()=>{const e={};for(const[t,n]of s.current)e[t]=n.getLast();return e},[]),x=W((e,t)=>{s.current.has(e)||c(e=>e+1),s.current.set(e,t)},[]),k=W(e=>{s.current.delete(e)&&c(e=>e-1)},[]),E=W(e=>{h(t=>t+(e?1:-1))},[]),C=W(e=>{p(t=>t+(e?1:-1))},[]),[M,N]=K(0),S=M>0,L=W(e=>{N(t=>t+(e?1:-1))},[]),T=z(ge),A=T?.claimReadOnly;I(()=>{if(A&&!y)return A(!0),()=>A(!1)},[A,y]);const D=T?.claimOwnMount;I(()=>{if(D&&S)return D(!0),()=>D(!1)},[D,S]);const $=P({last:0,count:0,tripped:!1}),O=P(!1),R=W((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)||(O.current=!0));if(!y||g.current)return;const r=$.current;if(r.tripped)return;const o=Date.now();if(o-r.last>Kr&&(r.count=0),r.last=o,++r.count>Ir)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${Ir} 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=W(e=>{for(const[t,n]of Object.entries(e)){const e=s.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),q=W(()=>{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]),H=W(()=>{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]),[U,V]=K(0),_=P(0),J=P(0),G=P(!1),Q=W(()=>{b.current=!0,O.current=!1,g.current=null,_.current+=1,J.current=_.current,V(_.current)},[]),Z=P(void 0),ee=W(e=>{void 0!==e&&(void 0!==Z.current&&e!==Z.current&&(G.current=!0),Z.current=e),Q()},[Q]);I(()=>{b.current&&U===J.current&&(b.current=!1,g.current=null,(O.current||G.current)&&a({type:"clear"}),O.current=!1,G.current=!1)},[U]);const te=W(()=>{G.current=!0,a({type:"clear"}),Q()},[Q]),ne=y&&o.past.length>0,re=y&&o.future.length>0,oe=lr(r),ie=P({undo:q,redo:H,canUndo:ne,canRedo:re});ie.current={undo:q,redo:H,canUndo:ne,canRedo:re},I(()=>{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&&Pr.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=j(()=>({register:x,unregister:k,record:R,undo:q,redo:H,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,H,te,ee,ne,re,y,d,S,L,E,f,C,o.past,o.future]),se=""!==Yt(),le=z(Ut)?.footerOpen??!1,ce=se&&y&&d&&!S&&le;/* @__PURE__ */
108
+ return Y(ge.Provider,{value:ae,children:[ce&&/* @__PURE__ */X(Vt,{position:"left",quiet:!0,children:/* @__PURE__ */X(ve,{auto:!0})}),e]})}function Wr(){const e=z(ge),t=W(()=>{},[]);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 Or(e){const t=z(ge),n=t?.claimReadOnly,r=t?.claimEditable;I(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}function Rr(e,t,n){const r=z(ge),o=H(),i=P(e),a=P(t);a.current=t,I(()=>{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=P(r);c.current=r;const d=P({label:s,coalesceKey:l});d.current={label:s,coalesceKey:l},I(()=>{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 Fr(e,t){const[n,r]=K(e);return Rr(n,e=>r(()=>e),t),[n,r]}export{_t as CancelButton,qe as DocFavStar,Te as EntityWindowFallback,Se as EntityWindowLoading,ze as EntityWindowState,Wt as KEY_ACTIVATED_SELECTOR,Me as LoadingSpinner,$t as MODAL_SUBMIT_SELECTOR,Tr as Modal,Vt as ModalActions,ve as UndoControls,$r as UndoProvider,re as WINDOW_REGISTRY,we as WindowCrashedFallback,ye as WindowErrorBoundary,lt as WindowManagerProvider,Bt as WindowTitle,Ye as activateWindowById,bt as beginWindowGesture,zn as cancelWindowFront,le as client_default,Nr as commitExposeHighlight,vt as drainPerfEvents,fr as exitExposeMode,ln as forgetMaximizedWindowBoxes,ir as getActiveModalId,Je as getActiveWindowRoute,Cr as getExposeHighlight,At as getWindowChromeVersion,an as getWindowPosition,De as isDraftEntityId,Pe as isDraftEntityWindow,ee as isEntityEntry,Z as isPageEntry,ae as isShellApiClientConfigured,Xe as isTabWindow,gt as markMenuOpen,Tt as readWindowChrome,Tn as requestWindowFront,Mr as setExposeHighlight,yt as setPerfCollecting,ie as setShellApiClient,me as setShellHomeRoute,ne as setShellWindowRegistry,on as setWindowDefaultPosition,sn as setWindowPosition,Et as splitTitle,Er as subscribeExposeHighlight,zt as subscribeWindowChrome,pr as toggleExposeMode,Mn as useCurrentTabKey,Yt as useEnclosingModalId,lr as useIsActiveWindow,Xt as useModalActive,de as usePageSearch,Wr as useUndo,Or as useUndoCanEdit,Rr as useUndoable,Fr as useUndoableState,Ft as useWidgetSettings,$e as useWindowDirty,Oe as useWindowManager,jt as useWindowMenuItem,Ht as useWindowTitle};