efficient-shell 13.19.0 → 13.21.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 (60) hide show
  1. package/README.md +40 -1
  2. package/dist/{Browser-ZTKWHNYX.js → Browser-AE7OYSTS.js} +12 -12
  3. package/dist/Calculator-QEQU3W2L.js +29 -0
  4. package/dist/CurrencyConverter-L22FF4ST.js +21 -0
  5. package/dist/{Files-R2IVXZJJ.js → Files-Y5UGT3RX.js} +80 -80
  6. package/dist/Notepad-YZOEXYE3.js +24 -0
  7. package/dist/{PomodoroTimer-JVCYYGRD.js → PomodoroTimer-6XHLOAJD.js} +21 -21
  8. package/dist/{Preview-STATKTFB.js → Preview-XQXSRAGY.js} +16 -16
  9. package/dist/{Stock-S266KGAF.js → Stock-36O4LW46.js} +4 -4
  10. package/dist/{Weather-TE4TTTQA.js → Weather-BN6AJJ4S.js} +21 -21
  11. package/dist/{WorldClock-5TPBHBYA.js → WorldClock-TUVIRPTM.js} +6 -6
  12. package/dist/ai/index.js +8 -8
  13. package/dist/apps/index.d.ts +1 -1
  14. package/dist/apps/index.js +1 -1
  15. package/dist/bin/browser-check.js +1 -1
  16. package/dist/bin/media-host-check.js +1 -1
  17. package/dist/bin/ui-check.js +1 -1
  18. package/dist/brand.css +1 -1
  19. package/dist/chunk-2TXQCA4C.js +15 -0
  20. package/dist/{chunk-34HRPEQD.js → chunk-ABTVRB23.js} +1 -1
  21. package/dist/{chunk-GEQZUCEO.js → chunk-BVX7LUAW.js} +6 -6
  22. package/dist/chunk-D4WO73XD.js +91 -0
  23. package/dist/{chunk-LUCO5PS6.js → chunk-F3E3CEZM.js} +1 -1
  24. package/dist/{chunk-46A3BMJB.js → chunk-H75CQD46.js} +1 -1
  25. package/dist/{chunk-QTDR2CTB.js → chunk-IUQJGFEO.js} +3 -3
  26. package/dist/{chunk-4SYPNE3P.js → chunk-J4CVYOY3.js} +1 -1
  27. package/dist/chunk-LZOKBMAF.js +1 -0
  28. package/dist/{chunk-QSJMLHBD.js → chunk-MUNP5Z24.js} +1 -1
  29. package/dist/{chunk-ENVANMHI.js → chunk-SHHRC5XK.js} +7 -7
  30. package/dist/{chunk-IQPYTW2O.js → chunk-SOXZRLSD.js} +2 -2
  31. package/dist/{chunk-EHM3ZVVT.js → chunk-UC5IC3AM.js} +4 -4
  32. package/dist/{chunk-TKCCJRPE.js → chunk-VRJKV44O.js} +1 -1
  33. package/dist/{chunk-S7YUQLBN.js → chunk-XXTAMF3O.js} +6 -6
  34. package/dist/chunk-YI4T5I5D.js +1 -0
  35. package/dist/data/EntityList.js +1 -1
  36. package/dist/data/ResizableTable.js +1 -1
  37. package/dist/forms/BrandAssetEditor.js +1 -1
  38. package/dist/forms/MediaLibrary.js +1 -1
  39. package/dist/forms/MediaUploadField.js +1 -1
  40. package/dist/icons/index.js +1 -1
  41. package/dist/index.d.ts +4 -3
  42. package/dist/index.js +662 -665
  43. package/dist/shell/LanguageSelect.js +1 -1
  44. package/dist/shell/SettingRow.js +1 -1
  45. package/dist/shell/SidebarLayout.d.ts +5 -2
  46. package/dist/shell/SidebarLayout.js +1 -1
  47. package/dist/telemetry/index.js +1 -1
  48. package/dist/templates/ChatTemplate.js +1 -1
  49. package/dist/templates/EmailTemplate.js +1 -1
  50. package/dist/{types-ClT92-8Z.d.ts → types-DWIjEVSy.d.ts} +5 -5
  51. package/dist/ui/index.js +1 -1
  52. package/dist/ui.css +11 -0
  53. package/dist/version.js +1 -1
  54. package/package.json +1 -1
  55. package/dist/Calculator-4UBMDAJO.js +0 -29
  56. package/dist/CurrencyConverter-H3HHXXKT.js +0 -21
  57. package/dist/Notepad-Z2XMVRSD.js +0 -24
  58. package/dist/chunk-HNMWF6OG.js +0 -1
  59. package/dist/chunk-U5RG34NE.js +0 -14
  60. package/dist/chunk-ZI2FDUYJ.js +0 -99
@@ -1,99 +0,0 @@
1
- import{computeMaximizedBox as e,isSidebarStripReserved as t,boxFillsWorkArea as n,readAlwaysMaximizedFlag as r,WORK_AREA_CHANGED_EVENT as o,scrollerIsFluid as i,growBoxToWidth as a,widthToFit as s,navIcons as l}from"./chunk-4LXCCZDM.js";import{reportBoundaryError as c}from"./chunk-KNUR2UEG.js";import{isStaleChunkError as u}from"./chunk-JDCM2VHG.js";import{Result as d}from"./chunk-M2TQOJ3G.js";import{CMD_Z as h,CMD_SHIFT_Z as m}from"./chunk-FBZUEZK7.js";import{CopyButton as p}from"./chunk-BG3C4ALM.js";import{confirm as f}from"./chunk-GMLOMLCS.js";import{useModalDragAside as w}from"./chunk-EIFNESXS.js";import{ItemCount as y}from"./chunk-SXHV5OLA.js";import{isInOverlayOver as g}from"./chunk-SF4IIV5Z.js";import{dialogA11y as v}from"./chunk-VWGWZY7A.js";import{ColoredBadge as b}from"./chunk-WRV6QKJN.js";import{ROW_HEIGHTS as x}from"./chunk-AW7TOB6N.js";import{LoadingSpinner as k}from"./chunk-4U5M37SF.js";import{activationOrder as E,activeListeners as C,ModalActionsContext as M,subscribeActive as N,getActiveModalId as S,KEY_ACTIVATED_SELECTOR as L}from"./chunk-F3ZOO23R.js";import{useShellAuth as T}from"./chunk-2QY5BJLA.js";import{useIsMobile as z,useIsPhone as A}from"./chunk-UGTRSRIW.js";import{useShellPrefs as D}from"./chunk-DPFEQQQU.js";import{focusableIn as I}from"./chunk-DWGYC7OD.js";import{StatusBadge as P}from"./chunk-YDJ5IZOU.js";import{PopupMenu as R,PopupMenuItem as O,PopupMenuDivider as W,PopupMenuLabel as K}from"./chunk-THAPVKEJ.js";import{Button_default as $}from"./chunk-UTISUEO4.js";import{Icon as j}from"./chunk-ISVODSRP.js";import{LoadingSpinner as F}from"./chunk-R2VKEMZH.js";import{Z_LAYERS as q}from"./chunk-62LW225J.js";import{shellHttp as H,isShellHttpConfigured as B}from"./chunk-STKJA4PV.js";import{fitBoxScale as U,fitFrameStyle as Y}from"./chunk-M6UKCZHT.js";import{runEscapeInterceptors as X}from"./chunk-TWVUQUUD.js";import{useShellStrings as V}from"./chunk-IUVGHHR3.js";import{createContext as G,createElement as J,useContext as _,Component as Z,useLayoutEffect as Q,useRef as ee,useEffect as te,useState as ne,useSyncExternalStore as re,useCallback as oe,isValidElement as ie,Fragment as ae,Children as se,cloneElement as le,useMemo as ce,useId as ue,useReducer as de,Suspense as he}from"react";import{jsxs as me,jsx as pe,Fragment as fe}from"react/jsx-runtime";import{createPortal as we}from"react-dom";import{useLocation as ye}from"react-router-dom";import{useQueryClient as ge,useQuery as ve}from"@tanstack/react-query";function be(e){return"component"in e}function xe(e){return"endpoint"in e}var ke={};function Ee(e){ke=e}var Ce=new Proxy({},{get:(e,t)=>ke[t],has:(e,t)=>t in ke,ownKeys:()=>Object.keys(ke),getOwnPropertyDescriptor(e,t){if(t in ke)return{configurable:!0,enumerable:!0,value:ke[t]}}});function Me(){return B()}var Ne=H,Se=G({});function Le({value:e,children:t}){return J(Se.Provider,{value:e},t)}function Te(){return _(Se)}var ze=G(null);function Ae(){return _(ze)?.pageSearch??""}var De=null,Ie=/* @__PURE__ */new Set;function Pe(e){De!==e&&(De=e,Ie.forEach(e=>e()))}function Re(){return De}function Oe(e){return Ie.add(e),()=>{Ie.delete(e)}}var We=null;function Ke(e){We=e}function $e({error:e,onReload:t}){const n=u(e);/* @__PURE__ */
2
- return me("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 py-12 text-center",children:[
3
- /* @__PURE__ */pe(j,{name:"warning",className:"h-8 w-8 text-amber-500",strokeWidth:1.5}),
4
- /* @__PURE__ */me("div",{className:"min-w-0",children:[
5
- /* @__PURE__ */pe("p",{className:"text-sm font-medium text-gray-700",children:n?"This window needs the latest version of the app":"This window crashed"}),
6
- /* @__PURE__ */pe("p",{className:"mt-1 text-xs text-gray-400 max-w-sm break-words",children:n?"A new version was deployed while this tab was open. Reload the page to pick it up.":e.message||String(e)})]}),
7
- /* @__PURE__ */pe("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 je=class extends Z{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){console.error("[efficient-shell] window content crashed:",e,t.componentStack),c(e)}reset=()=>this.setState({error:null});render(){const{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):/* @__PURE__ */pe($e,{error:e,onReload:this.reset}):this.props.children}},Fe=G(null),qe="text-xs text-gray-500 hover:text-gray-700 disabled:opacity-40 disabled:hover:text-gray-500 disabled:cursor-default";function He({className:e="",auto:t=!1}){const n=_(Fe),r=V().undo,o=n?.claimOwnMount;if(Q(()=>{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:u}=n;/* @__PURE__ */
8
- return me("div",{className:`flex items-center gap-2 ${e}`,"data-undo-controls":t?"shell":"form",children:[
9
- /* @__PURE__ */pe("button",{type:"button",onClick:i,disabled:!s,title:s?r.undoStep(c??"",h):r.nothingToUndo,className:qe,children:r.undo}),
10
- /* @__PURE__ */pe("button",{type:"button",onClick:a,disabled:!l,title:l?r.redoStep(u??"",m):r.nothingToRedo,className:qe,children:r.redo})]})}var Be=/* @__PURE__ */new Set([408,429]);function Ue(e){const t=e?.response?.status;return"number"==typeof t?t:void 0}function Ye(e){const t=Ue(e);return null!=t&&(t>=400&&t<500&&!Be.has(t))}function Xe(e,t){return!Ye(t)&&e<3}function Ve(e){if("page"!==e.type)return!0;const t=e.route?Ce[e.route]:void 0;if(!t||!be(t))return!0;const n=t;return!n.widget&&!n.utility}function Ge(e){const t=e.route?Ce[e.route]:void 0;if(!t||!be(t))return;const n=t;return n.taskbarGroup?n.taskbarGroup:{key:e.route,label:n.label,icon:e.route}}var Je=(e,t)=>!!t&&"page"===e.type&&e.route===t;var _e="flex-1 min-h-0";function Ze(){const e=V().record;/* @__PURE__ */
11
- return pe(F,{label:e.loading,padding:"",className:_e})}function Qe(e){return e??void 0}function et({isPending:e,isFetching:t,enabled:n=!0,error:r,onRetry:o}){const i=V().record;if(t||e&&n)/* @__PURE__ */return pe(Ze,{});if(r){const e=Ue(r);if(401===e)/* @__PURE__ */
12
- return pe(d,{status:"warning",title:i.signInRequired,subTitle:i.signInBody,className:_e});if(403===e)/* @__PURE__ */
13
- return pe(d,{status:"403",className:_e});if(404===e||410===e)/* @__PURE__ */
14
- return pe(d,{status:"404",title:i.notFound,className:_e});const t=null==e||408===e||429===e||e>=500;/* @__PURE__ */
15
- return pe(d,{status:"500",title:i.loadFailed,subTitle:t?i.checkConnection:i.rejected,extra:t?/* @__PURE__ */pe($,{variant:"secondary",size:"sm",onClick:o,children:i.retry}):void 0,className:_e})}/* @__PURE__ */
16
- return pe(d,{status:"404",title:i.notFound,className:_e})}function tt({entity:e,children:t,...n}){return null!=e?/* @__PURE__ */pe(fe,{children:t(e)}):/* @__PURE__ */pe(et,{...n})}var nt=/^[a-z]+(?:-[a-z]+)*-\d{13}$/;function rt(e){return"string"==typeof e&&(e.startsWith("new-")||nt.test(e))}function ot(e){if(rt(e.entityId))return!0;const t=e.entitySnapshot;return!(!t||"object"!=typeof t||!t._new&&!t._duplicate)}var it=G({openWindows:[],openEntity:()=>{},openPage:()=>{},reorderWindows:()=>{},closeEntity:()=>{},minimize:()=>{},items:[],restore:()=>{},remove:()=>{},restoreIfMinimized:()=>!1,openItems:[]}),at=G(null);function st(e){const t=_(at),n=ee(null);null===n.current&&(n.current=/* @__PURE__ */Symbol("window-dirty")),Q(()=>{if(t)return t(n.current,e)},[t,e]),te(()=>{if(!t||!e)return;const n=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])}function lt(){const e=ee(/* @__PURE__ */new Map),[t,n]=ne(!1);return{dirty:t,registerDirty:oe((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 ct(){return _(it)}function ut(e){if("page"!==e.type&&ot(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 dt({item:e,onClose:t,accentRgb:n}){const{dirty:r,registerDirty:o}=lt(),i=Ce[e.route];if(!i||!be(i))return null;const a=i,s=a.component;/* @__PURE__ */
17
- return pe(eo,{open:!0,onClose:t,icon:l[e.route],title:a.label,size:a.size||"2xl",dirty:r,allowPinOnTop:a.allowPinOnTop,initialPosition:a.initialPosition,widget:a.widget,compact:a.compact,appStyle:a.appStyle,flushBody:a.flushBody,autoHeight:a.autoHeight,autoMinHeight:a.autoMinHeight,autoWidth:a.autoWidth,dimensions:a.dimensions,windowKey:e.id,openedFromKey:e.openedFrom,accentRgb:n,children:/* @__PURE__ */pe(at.Provider,{value:o,children:/* @__PURE__ */pe(he,{fallback:/* @__PURE__ */pe("div",{className:"flex items-center justify-center py-12",children:/* @__PURE__ */pe(k,{})}),children:/* @__PURE__ */pe(s,{})})})})}function ht({entityType:e,entityId:t,label:n}){const r=V(),o=ge(),{data:i}=ve({queryKey:["my-profile-sidebar"],enabled:Me(),queryFn:()=>Ne.get("/auth/me/").then(e=>e.data)}),a=(i?.preferences||{}).favorite_documents||[],s=a.some(n=>n.entityType===e&&n.entityId===t);/* @__PURE__ */
18
- return pe("button",{onClick:()=>{const r=s?a.filter(n=>!(n.entityType===e&&n.entityId===t)):[...a,{entityType:e,entityId:t,label:n}];Ne.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__ */pe(j,{name:"star",className:"h-4 w-4",fill:s?"currentColor":"none",strokeWidth:1.5})})}var mt=/* @__PURE__ */new Set,pt=()=>"hidden";function ft({item:e,onClose:t,onMinimize:n,accentRgb:r}){const o=Ce[e.entityType];if(!o||!xe(o))return null;const i=o,[a,s]=ne(!1),{dirty:c,registerDirty:u}=lt(),d=i.queryKey||i.endpoint.replace(/^\/|\/$/g,"").split("/").pop()||e.entityType,h=e.entitySnapshot?._duplicate,m=rt(e.entityId),p=Te(),f=(w=e.id,re(N,()=>{const e=Un.get(w);return null!=e&&$n.has(e)}));var w;const y=!i.selfFetching&&!h&&!m&&Me(),g=ve({queryKey:[d,e.entityId],queryFn:()=>{return Ne.get((t=i.endpoint,n=String(e.entityId),`${t}${encodeURIComponent(n)}/`)).then(e=>e.data);var t,n},initialData:Qe(e.entitySnapshot),initialDataUpdatedAt:0,enabled:y,staleTime:0,refetchOnWindowFocus:()=>{return void 0===(e=p.entityRefetchOnWindowFocus)||("function"==typeof e?e():e);var e},refetchOnMount:"always",refetchInterval:e=>function(e,t={}){if(Ye(e))return!1;if(t.minimized)return!1;const n=t.hostInterval;if(void 0===n)return 6e4;const r="function"==typeof n?n():n;return"number"==typeof r&&r>0&&r}(e.state.error,{minimized:f,hostInterval:p.entityRefetchInterval}),refetchIntervalInBackground:!1,retry:Xe}),v=g.data,b=g.refetch;te(()=>{var t;if(y)return t=t=>{t!==e.id||mt.has(t)||b({cancelRefetch:!1})},ar.add(t),()=>{ar.delete(t)}},[b,e.id,y]);const x=oe(()=>{a&&!c?s(!1):t()},[a,c,t]),E=(i.useEdit??pt)(v??null),C=!i.useEdit||m||h?void 0:{state:E,editing:a,onEdit:()=>s(!0),onDiscard:()=>s(!1)},M=i.selfFetching?e.label:v?i.title(v,a,s):e.label,S=i.icon,L=S?l[S]:null,T=M,z=!i.selfFetching&&v&&i.footer&&!h?i.footer(v):void 0;return i.rendersOwnModal?i.selfFetching?/* @__PURE__ */pe(he,{fallback:/* @__PURE__ */pe(k,{}),children:i.render(v??e.entitySnapshot,t,e.entityId,a,s)}):null!=v?/* @__PURE__ */pe(he,{fallback:/* @__PURE__ */pe(eo,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */pe(Ze,{})}),children:i.render(v,t,e.entityId,a,s)}):/* @__PURE__ */pe(eo,{open:!0,onClose:t,title:e.label,size:i.size||"2xl",children:/* @__PURE__ */pe(et,{isPending:g.isPending,isFetching:g.isFetching,enabled:y,error:g.error,onRetry:b})}):/* @__PURE__ */pe(eo,{open:!0,onClose:x,onMinimize:n,initialBox:e.savedBox,icon:L,title:T,footer:z,copyText:e.label,windowKey:e.id,openedFromKey:e.openedFrom,size:i.size||"2xl",dirty:c,editing:a||m||h,edit:C,dimensions:i.dimensions,autoHeight:i.autoHeight,autoMinHeight:i.autoMinHeight,autoWidth:i.autoWidth,appStyle:i.appStyle,flushBody:i.flushBody,accentRgb:r,children:/* @__PURE__ */pe(at.Provider,{value:u,children:/* @__PURE__ */pe(he,{fallback:/* @__PURE__ */pe(Ze,{}),children:i.selfFetching?i.render(null,t,e.entityId,a,s):/* @__PURE__ */pe(tt,{entity:v,isPending:g.isPending,isFetching:g.isFetching,enabled:y,error:g.error,onRetry:b,children:n=>i.render(n,t,e.entityId,a,s)})})})})}function wt(e){return document.querySelector(`[data-modal-panel][data-window-key="${e}"]`)}function yt(e){return document.querySelector(`[data-modal-panel][data-window-root][data-window-owner="${e}"]`)}function gt(e){const t=wt(e),n=t??yt(e);if(!n)return;if(t&&!gr(t))return r=e,void window.dispatchEvent(new CustomEvent("modal-reveal",{detail:{windowKey:r}}));var r;const o=n.getAttribute("data-modal-id");o&&sr(o)}function vt(){const e=S();if(!e)return;const t=document.querySelector(`[data-modal-panel][data-modal-id="${e}"]`);return t?.getAttribute("data-window-key")??void 0}var bt=/* @__PURE__ */new Map;function xt(){const e=vt();if(e)return bt.get(e)}function kt(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 Et="rosh-peek-style",Ct=q.peek,Mt=q.taskbarPreview;function Nt(e){"undefined"!=typeof document&&(!function(){if("undefined"==typeof document||document.getElementById(Et))return;const e=document.createElement("style");e.id=Et,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:${Ct}!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 St(){"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 Lt({id:e,label:t,maxW:n,maxH:r,titleAbove:o=!1,onClick:i,onClose:a}){const s=V(),l=ee(null),[c,u]=ne({w:n,h:Math.round(.75*r)}),[d,h]=ne(!1);return Q(()=>{const o=l.current;if(!o)return;const i=wt(e)??kt(t);if(!i)return void h(!1);const a=i.getBoundingClientRect();if(0===a.width||0===a.height)return void h(!1);const s=U({width:n,height:r},a),c=Math.max(80,Math.round(a.width*s)),d=Math.max(60,Math.round(a.height*s));u({w:c,h:d}),h(!0);const m=i.cloneNode(!0);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";const p=Y(a.width,s);return Object.assign(m.style,{transform:p.transform??"",transformOrigin:p.transformOrigin}),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.removeAttribute("role"),m.removeAttribute("aria-labelledby"),m.removeAttribute("aria-label"),m.querySelectorAll('[role="dialog"], [data-portal]').forEach(e=>{e.style.display="none"}),o.innerHTML="",o.appendChild(m),()=>{o.innerHTML=""}},[e,t,n,r]),/* @__PURE__ */me("div",{style:{width:c.w,height:c.h},className:"relative rounded-md overflow-hidden bg-white/95 border border-line-strong shadow-(--elevation-panel) cursor-pointer ring-2 ring-transparent group-hover:ring-blue-400 transition shrink-0",onClick:i,children:[
19
- /* @__PURE__ */pe("div",{ref:l,className:"absolute inset-0 z-0 overflow-hidden"}),!d&&/* @__PURE__ */me("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-gray-400 bg-gray-50",children:[
20
- /* @__PURE__ */pe(j,{name:"window",className:"h-6 w-6",strokeWidth:1.5}),
21
- /* @__PURE__ */pe("span",{className:"mt-1 text-3xs uppercase tracking-wide",children:"Hidden"})]}),!o&&/* @__PURE__ */pe("div",{className:"absolute bottom-0 left-0 right-0 z-10 px-2 py-1 text-2xs font-medium text-on-accent bg-gradient-to-t from-black/80 to-transparent truncate pointer-events-none",children:t}),a&&/* @__PURE__ */pe("button",{onClick:e=>{e.stopPropagation(),a()},className:"absolute top-1 right-1 z-20 h-5 w-5 rounded-full bg-gray-900/90 ring-1 ring-white/80 shadow-sm hover:bg-red-500 text-on-accent flex items-center justify-center",title:s.taskbar.closeWindow,children:/* @__PURE__ */pe(j,{name:"close",className:"h-3 w-3",strokeWidth:3})})]})}function Tt({items:e,anchorEl:t,onActivate:n,onClose:r,onMouseEnter:o,onMouseLeave:i}){const a=V(),s=e.length>1,l=ee(null),[c,u]=ne({left:-9999,top:-9999,ready:!1}),[d,h]=ne(()=>"undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--taskbar-position")?.trim()||"bottom");Q(()=>{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)),u({left:a,top:i,ready:!0})};n();const r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t,e.length]),te(()=>St,[]);const m="top"===d,p=(m?"mt-1":"mb-1")+" max-w-[240px] truncate text-2xs font-medium text-ink-strongest bg-white/80 px-2 py-0.5 rounded shadow-sm ring-2 ring-transparent transition group-hover:ring-blue-400";return we(
22
- /* @__PURE__ */pe("div",{ref:l,"data-taskbar-preview":"",style:{position:"fixed",left:c.left,top:c.top,zIndex:Mt,maxWidth:"calc(100vw - 16px)",opacity:c.ready?1:0},className:s?"flex gap-2 flex-wrap":"",onMouseEnter:o,onMouseLeave:()=>{St(),i()},children:e.map(e=>{const t=wt(e.id)??kt(e.label),o=t?function(e){if(gr(e))return null;const t=e.getBoundingClientRect(),n=hr(),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__ */
23
- return me("div",{className:"group flex flex-col items-center",onMouseEnter:()=>Nt(t),children:[!m&&/* @__PURE__ */pe("span",{className:p,children:e.label}),
24
- /* @__PURE__ */pe(Lt,{id:e.id,label:e.label,maxW:240,maxH:160,titleAbove:!0,onClick:()=>n(e.id),onClose:()=>r(e.id)}),m&&/* @__PURE__ */pe("span",{className:p,children:e.label}),null!==o&&/* @__PURE__ */me("span",{title:a.taskbar.offscreenHint,className:"mt-1 inline-flex items-center gap-1 rounded bg-amber-500 px-2 py-0.5 text-2xs font-semibold text-on-accent shadow-sm",children:[
25
- /* @__PURE__ */pe(j,{name:"arrow-right",className:"h-3 w-3",style:{transform:`rotate(${o}deg)`},strokeWidth:3}),"Off screen"]})]},e.id)})}),document.body)}function zt(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=V(),[a,s]=ne(null);te(()=>{let e,t;const n=()=>{clearInterval(e),clearTimeout(t),e=void 0},r=()=>{const e=document.getElementById("taskbar-windows");return s(t=>t===e?t:e),!!e},o=()=>{n(),r()||(e=setInterval(()=>{r()&&n()},100),t=setTimeout(n,5e3))};return o(),window.addEventListener("react-os-shell:layout-mode-changed",o),()=>{n(),window.removeEventListener("react-os-shell:layout-mode-changed",o)}},[]);const c=re(N,S),[,u]=ne(0);te(()=>{const e=()=>u(e=>e+1);return window.addEventListener("modal-geometry",e),window.addEventListener("resize",e),()=>{window.removeEventListener("modal-geometry",e),window.removeEventListener("resize",e)}},[]);const[,d]=ne(0);te(()=>{const e=()=>d(e=>e+1);return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[]);const h=e=>{const t=kt(e),n=t?.querySelector("[data-window-title]");return n?.textContent?.trim()||e},[m,p]=ne(null),[f,w]=ne(null),[g,v]=ne(null),b=ee(null),x=()=>{b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{p(null),w(null)},150)},k=e.filter(e=>!e.route||!Ce[e.route]?.utility);if(!a||!a.isConnected||0===k.length)return null;const E=[],C=/* @__PURE__ */new Map;for(const e of k){const t=e.route?Ce[e.route]:void 0,n=t?.taskbarGroup,r=n?.key??e.route??`entity:${e.id}`,o=C.get(r);if(void 0!==o)E[o].items.push(e);else{C.set(r,E.length);const o=n?.label??t?.label??e.label;E.push({key:r,route:n?.icon??e.route,label:o,items:[e]})}}return we(
26
- /* @__PURE__ */me(fe,{children:[E.map(e=>{const n=e.route?l[e.route]:null,r=e.items[e.items.length-1];let a=!1;if(c){const t=document.querySelector(`[data-modal-id="${c}"]`);if(t){const n=t.querySelector("[data-window-title]"),r=n?.textContent??"";a=e.items.some(e=>r.includes(e.label))}}const s=e.items.length>1,u=e.items.some(e=>{const t=wt(e.id)??kt(e.label);return!!t&&!gr(t)});/* @__PURE__ */
27
- return me("button",{onClick:()=>o(r.id),onMouseEnter:t=>{return n=e.items,r=t.currentTarget,void(g||(b.current&&(clearTimeout(b.current),b.current=null),b.current=setTimeout(()=>{p(n),w(r)},350)));var n,r},onMouseLeave:x,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?v({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&&ie(n)?le(n,{className:"h-3.5 w-3.5 shrink-0"}):/* @__PURE__ */pe(j,{name:"expand",className:"h-3.5 w-3.5 shrink-0",strokeWidth:2}),
28
- /* @__PURE__ */pe("span",{className:"truncate flex-1",children:s?e.label:h(r.label)}),u&&/* @__PURE__ */pe("span",{title:i.taskbar.offscreenDot,className:"shrink-0 h-1.5 w-1.5 rounded-full bg-amber-500"}),s&&/* @__PURE__ */pe(y,{count:e.items.length,label:i.count.windows(e.items.length)}),!s&&/* @__PURE__ */pe("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__ */pe(j,{name:"close",className:"h-3 w-3",strokeWidth:2})})]},e.key)}),
29
- /* @__PURE__ */pe("div",{className:"flex-1"}),k.length>=2&&/* @__PURE__ */me("button",{onClick:n,title:i.taskbar.expose,className:"flex items-center gap-1 rounded px-2 py-1 text-2xs font-medium text-blue-600 border border-blue-300 hover:bg-accent-tint transition-colors shrink-0",children:[
30
- /* @__PURE__ */pe(j,{name:"grid",className:"h-3 w-3",strokeWidth:2}),"Exposé"]}),g&&/* @__PURE__ */me(R,{portal:!0,minWidth:200,style:zt(g.x,g.y),onClose:()=>v(null),children:[
31
- /* @__PURE__ */pe(K,{children:g.label}),
32
- /* @__PURE__ */me(O,{onClick:()=>{v(null),g.items.forEach(e=>function(e){const t=Un.get(e);t&&lr(t)}(e.id))},children:[
33
- /* @__PURE__ */pe(j,{name:"remove",className:"h-4 w-4",strokeWidth:1.5}),i.taskbar.minimizeAllWindows]}),
34
- /* @__PURE__ */me(O,{onClick:()=>{v(null),g.items.forEach(e=>o(e.id))},children:[
35
- /* @__PURE__ */pe("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */pe("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75h6.5v6.5h-6.5zM13.75 8.75h6.5v6.5h-6.5z"})}),i.taskbar.restoreAllWindows]}),
36
- /* @__PURE__ */pe(W,{}),
37
- /* @__PURE__ */me(O,{danger:!0,onClick:()=>{v(null),g.items.forEach(e=>t(e.id))},children:[
38
- /* @__PURE__ */pe(j,{name:"close",className:"h-4 w-4",strokeWidth:2}),`${i.taskbar.closeAllWindows} (${g.items.length})`]})]}),m&&f&&/* @__PURE__ */pe(Tt,{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:x})]}),a)}var Dt=["/login","/forgot-password","/reset-password","/force-change-password"];function It({children:e,windowAccentForRoute:t}){const n=ye(),r=Dt.some(e=>n.pathname.startsWith(e)),[o,i]=ne([]),a=ee(o);Q(()=>{a.current=o},[o]);const s=re(Oe,Re,Re),l=ee(/* @__PURE__ */new Map),c=e=>{const t=Ve(e),n=!!s&&"page"===e.type&&e.route===s,r=e.pageSearch||void 0,o=l.current.get(e.id);if(o&&o.tab===t&&o.home===n&&o.pageSearch===r)return o;const i={key:e.id,tab:t,home:n,...r?{pageSearch:r}:{}};return l.current.set(e.id,i),i};te(()=>{bt.clear();for(const e of o)e.route&&bt.set(e.id,e.route)},[o]);const u=oe(e=>{i(t=>t.filter(t=>t.id!==e))},[]),d=oe(e=>{var t;wt(e)||yt(e)?(t=e,window.dispatchEvent(new CustomEvent(Dr,{detail:{windowKey:t}}))):u(e)},[u]),h=(e,t=!1)=>{const n=jn;t&&mt.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,(Fn.get(i)??-1)>a)||sr(o),t&&mt.delete(e)},50)},m=(e,t,n)=>{const r=We;if(n||!r)return[...e,t];const o=function(e,t,n){if(!Ve(t))return e.length;if(t.shellOwned&&Je(t,n.home))return 0;const r=Je(t,n.home)?void 0:Ge(t)?.key;if(r){let t=-1;if(e.forEach((e,o)=>{Ve(e)&&!Je(e,n.home)&&Ge(e)?.key===r&&(t=o)}),t>=0)return t+1}if("page"===t.type&&t.route&&!Je(t,n.home)&&n.favorites.includes(t.route))return e.length>0&&Je(e[0],n.home)?1:0;const o=t.openedFrom?e.findIndex(e=>e.id===t.openedFrom):-1;if(o>=0){const t=/* @__PURE__ */new Set([e[o].id]);let r=o+1;for(;r<e.length&&e[r].openedFrom&&t.has(e[r].openedFrom);)t.add(e[r].id),r++;const i=t=>Ve(e[t])&&!Je(e[t],n.home)?Ge(e[t])?.key:void 0;for(;r>0&&r<e.length&&void 0!==i(r)&&i(r)===i(r-1);)r++;return r}return e.length}(e,t,{home:Re(),favorites:r.favorites});return[...e.slice(0,o),t,...e.slice(o)]},p=oe(e=>{i(t=>function(e,t){const n=new Set(t),r=new Map(e.map(e=>[e.id,e])),o=t.map(e=>r.get(e)).filter(e=>!!e);if(o.length!==n.size)return e;let i=0;const a=e.map(e=>n.has(e.id)?o[i++]:e);return a.every((t,n)=>t===e[n])?e:a}(t,e))},[]),f=oe((e,t,n,r,o,a={})=>{if(!Ce[e]||!xe(Ce[e]))return;const s=`${e}:${t}`,l=vt();i(i=>{const c=i.find(n=>n.entityType===e&&String(n.entityId)===String(t));return c?(h(c.id),i):(h(s,!0),m(i,{id:s,type:"modal",label:r||t,route:o||window.location.pathname,entityType:e,entityId:t,entitySnapshot:Qe(n),openedFrom:l},!!a.append))})},[]),w=oe((e,t={})=>{if(!Ce[e]||!be(Ce[e]))return;const n=Ce[e],{reuse:r=!1,background:o=!1,shellOwned:s,search:l,append:c=!1}=t,u=e=>{var t;o?(t=e,Jn.add(t)):h(e)};if(n.widget){const t=a.current.find(t=>"page"===t.type&&t.route===e);if(t)return void d(t.id)}const p=vt();i(t=>{if(n.multiInstance){const i=t.filter(t=>"page"===t.type&&t.route===e);if(s&&i.length>0)return t;if(r&&!l&&i.length>0)return o||h(i[i.length-1].id),t;const a=`page:${e}:${Math.random().toString(36).slice(2,8)}`;return u(a),m(t,{id:a,type:"page",label:n.label,route:e,openedFrom:p,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)}const i=t.find(t=>"page"===t.type&&t.route===e);if(i)return n.widget?t:(o||h(i.id),l&&i.pageSearch!==l?t.map(e=>e===i?{...e,pageSearch:l}:e):t);const a=`page:${e}`;return u(a),m(t,{id:a,type:"page",label:n.label,route:e,openedFrom:p,...s?{shellOwned:s}:{},...l?{pageSearch:l}:{}},c)})},[d]),y=oe(()=>{},[]),g=oe(()=>{},[]),v=d,b=d;/* @__PURE__ */
39
- return me(it.Provider,{value:{openWindows:o,openEntity:f,openPage:w,reorderWindows:p,closeEntity:v,minimize:y,items:[],openItems:o,restore:g,remove:b,restoreIfMinimized:()=>!1},children:[e,
40
- /* @__PURE__ */pe(At,{openWindows:o,onRemove:d,onSplitView:Zr,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&&sr(e)}})},onActivateById:gt}),
41
- /* @__PURE__ */pe(Qr,{}),!r&&o.map(e=>{const n=e.route?t?.(e.route):void 0;
42
- /* @__PURE__ */
43
- return pe(ze.Provider,{value:c(e),children:/* @__PURE__ */pe(je,{fallback:(t,n)=>/* @__PURE__ */pe(eo,{open:!0,onClose:()=>u(e.id),title:e.label,size:"md",autoHeight:!0,windowKey:e.id,children:/* @__PURE__ */pe($e,{error:t,onReload:n})}),children:/* @__PURE__ */pe(un,{spec:ut(e),children:/* @__PURE__ */pe(so,{windowId:e.id,children:"page"===e.type?/* @__PURE__ */pe(dt,{item:e,onClose:()=>u(e.id),accentRgb:n}):/* @__PURE__ */pe(ft,{item:e,onClose:()=>u(e.id),onMinimize:()=>{},accentRgb:n})})})})},e.id)})]})}var Pt=400;function Rt({panelRef:e,bodyRef:t,open:n,widget:r,active:o,minimized:i}){const a=ee(null),s=ee(!1);n&&!s.current&&(a.current="undefined"==typeof document?null:document.activeElement),s.current=n;const l=ee(!1),c=ee(void 0),u=ee(i),d=u.current&&!i;u.current=i;const h=()=>{l.current=!0,clearTimeout(c.current),c.current=setTimeout(()=>{l.current=!1},Pt)};te(()=>{n&&!r&&h()},[n,r]),te(()=>{d&&n&&!r&&h()},[d]),te(()=>()=>clearTimeout(c.current),[]),te(()=>{if(!n||r||!o||i||!l.current)return;l.current=!1;const a=e.current;if(!a||a.contains(document.activeElement))return;if(document.activeElement?.closest('[aria-modal="true"]'))return;const s=t.current?I(t.current)[0]:void 0;s?s.focus():(a.hasAttribute("tabindex")||a.setAttribute("tabindex","-1"),a.focus())},[n,r,o,i,e,t]),Q(()=>{if(!n||r)return;const t=e.current;return()=>{const e=a.current,n=document.activeElement;(!n||n===document.body||!!t?.contains(n))&&e&&e.isConnected&&!t?.contains(e)&&e.focus?.()}},[n,r,e])}var Ot=null,Wt=/* @__PURE__ */new Set;function Kt(){return Ot}function $t(e){if(Ot!==e){Ot=e;for(const e of Wt)e()}}function jt(e){return Wt.add(e),()=>{Wt.delete(e)}}var Ft=!1,qt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},Ht=()=>{};function Bt(e){Ft=e,qt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0}}function Ut(e,t){Ft&&("submenu"===e?qt.submenus++:qt.menus++,qt.menuKey=t)}function Yt(e){if(!Ft)return Ht;const t=performance.now();let n=!1;return()=>{if(n)return;if(n=!0,!Ft)return;const r=performance.now()-t;"move"===e?qt.moveMs+=r:qt.resizeMs+=r}}function Xt(){const e=qt;return qt={menus:0,submenus:0,menuKey:null,moveMs:0,resizeMs:0},e}var Vt=/* @__PURE__ */new Set([P,b]),Gt=e=>Vt.has(e)||"function"==typeof e&&"badge"===e.titleRole,Jt=/* @__PURE__ */new Set(["button","a","input","select","textarea","kbd"]),_t=/* @__PURE__ */new Set(["svg"]);function Zt(e){const t=[],n={text:"",accessories:[],badges:[],actions:[]};return Qt(e,n,t),n.text=t.join("").replace(/\s+/g," ").trim(),n}function Qt(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=>Qt(e,t,n));if(!ie(e))return;const r=e;if(r.type===p)return void(void 0===t.copy&&"string"==typeof r.props.text&&r.props.text&&(t.copy=r.props.text));if(r.type===ae)return void se.toArray(r.props.children).forEach(e=>Qt(e,t,n));if("string"==typeof r.type){if(_t.has(r.type))return;if(!Jt.has(r.type))return n.push(" "),se.toArray(r.props.children).forEach(e=>Qt(e,t,n)),void n.push(" ")}const o=le(r,{key:`title-part-${t.accessories.length}`});t.accessories.push(o),(Gt(r.type)?t.badges:t.actions).push(o)}var en=/* @__PURE__ */new Map,tn=/* @__PURE__ */new Set,nn=0;function rn(){nn++,tn.forEach(e=>e())}function on(e){return en.get(e)}function an(e){return tn.add(e),()=>{tn.delete(e)}}function sn(){return nn}var ln=G(""),cn=G(null);function un({spec:e,children:t}){/* @__PURE__ */
44
- return pe(cn.Provider,{value:e,children:t})}var dn=/* @__PURE__ */new Set(["button","input","textarea","select","kbd","svg"]),hn='button[type="submit"], button[data-submit], button.btn-submit, button.bg-green-600, button.bg-blue-600';function mn(e){return pn(e).replace(/\s+/g," ").trim()}function pn(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(pn).join("");if(ie(e)){const t=e,n="string"==typeof t.type?t.type:"";return dn.has(n)?"":` ${pn(t.props?.children)} `}return""}function fn(e){const t=_(ln);te(()=>{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 wn={};function yn(e,t,n){const r=_(ln);te(()=>{if(!r)return;wn[r]||(wn[r]=[]);const o={label:e,icon:n,onClick:t};return wn[r].push(o),()=>{wn[r]=(wn[r]||[]).filter(e=>e!==o)}},[r,e,t,n])}function gn({title:e}){const t=ee(null);return te(()=>{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__ */pe("span",{ref:t,style:{display:"none"},"aria-hidden":"true"})}function vn(e){}function bn(){return _(ln)}function xn({children:e,position:t="right",quiet:n=!1}){const r=_(M),[o,i]=ne(null);return te(()=>{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?we(e,o):null}function kn({onClick:e,children:t,className:n}){const r=_(M);/* @__PURE__ */
45
- return pe("button",{type:"button",onClick:async()=>{if(r?.isDirty){const{confirm:e}=await(import("./shell/ConfirmDialog.js"));if(!await e({title:"Discard changes?",message:"You have unsaved changes. Are you sure you want to cancel? All changes will be lost.",confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"}))return}e()},className:n||"bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50",children:t||"Cancel"})}var En="erp_window_positions",Cn={};try{const e=localStorage.getItem(En);e&&(Cn=JSON.parse(e))}catch{}var Mn=null;function Nn(){Mn&&clearTimeout(Mn),Mn=setTimeout(()=>{try{localStorage.setItem(En,JSON.stringify(Cn))}catch{}},500)}var Sn="erp_activation_order",Ln=[];try{const e=localStorage.getItem(Sn),t=e?JSON.parse(e):null;Array.isArray(t)&&t.every(e=>"string"==typeof e)&&(Ln=t)}catch{}var Tn=null;function zn(){Tn&&clearTimeout(Tn),Tn=setTimeout(()=>{try{localStorage.setItem(Sn,JSON.stringify(Ln))}catch{}},500)}function An(e,t){Cn[e]||(Cn[e]=t,Nn())}function Dn(e){return Cn[e]?{...Cn[e]}:null}function In(e,t){Cn[e]=t,Nn()}function Pn(){const r=e(),o=t();let i=!1;for(const e of Object.keys(Cn))n(Cn[e],r,o)&&(delete Cn[e],i=!0);i&&Nn()}var Rn={sm:384,md:512,lg:672,xl:896,"2xl":1152,"3xl":1408},On=4e3,Wn=()=>{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"},Kn={small:.8,medium:1,large:1.25,maximized:1.25},$n=/* @__PURE__ */new Set,jn=0,Fn=/* @__PURE__ */new Map;var qn=0;function Hn(){return qn}function Bn(){qn++,C.forEach(e=>e())}var Un=/* @__PURE__ */new Map,Yn=/* @__PURE__ */new Map,Xn=/* @__PURE__ */new Map;function Vn(){for(let e=E.length-1;e>=0;e--){const t=Xn.get(E[e]);if(t?.tab)return t.owner}return null}function Gn(){return re(N,Vn,()=>null)}var Jn=/* @__PURE__ */new Set;var _n=null;function Zn(e){_n=null,sr(e)}function Qn(e){_n=e;const t=Un.get(e);t&&Zn(t)}var er=/* @__PURE__ */new Map;function tr(e){return er.get(e)?.holdsChanges()??!1}function nr(e){const t=er.get(e);return t?t.ask():Promise.resolve(!0)}function rr(e){_n===e&&(_n=null)}function or(e,t,n){if(n&&Xn.set(e,n),t)if(Un.set(t,e),Yn.set(e,t),Jn.delete(t)){E.unshift(e);const n=Ln.indexOf(t);-1!==n&&Ln.splice(n,1),Ln.unshift(t),zn()}else!function(e,t){const n=Ln.indexOf(t);if(-1===n)return void E.push(e);let r=E.length;for(let e=0;e<E.length;e++){const t=Yn.get(E[e]);if(t&&Ln.indexOf(t)>n){r=e;break}}E.splice(r,0,e)}(e,t),-1===Ln.indexOf(t)&&(Ln.push(t),zn());else E.push(e);Bn(),window.dispatchEvent(new CustomEvent("modal-reorder")),t&&_n===t&&Zn(e)}function ir(e){return e?Xn.get(e)?.owner??Yn.get(e)??null:null}var ar=/* @__PURE__ */new Set;function sr(e){const t=ir(S()),n=E.indexOf(e);-1!==n&&E.splice(n,1),E.push(e);const r=Xn.get(e);if(r?.root)for(const[e,t]of Xn){if(t.root||t.owner!==r.owner||$n.has(e))continue;const n=E.indexOf(e);-1!==n&&E.splice(n,1),E.push(e)}$n.delete(e);const o=Yn.get(e);if(o){const e=Ln.indexOf(o);-1!==e&&Ln.splice(e,1),Ln.push(o),zn(),_n&&_n!==o&&(_n=null)}Bn(),window.dispatchEvent(new CustomEvent("modal-reorder"));const i=ir(S());i&&i!==t&&ar.forEach(e=>e(i))}function lr(e){const t=E.indexOf(e);-1!==t&&E.splice(t,1),$n.add(e),Fn.set(e,++jn);const n=Yn.get(e);if(n){const e=Ln.indexOf(n);-1!==e&&(Ln.splice(e,1),zn())}Bn(),window.dispatchEvent(new CustomEvent("modal-reorder"))}var cr=/* @__PURE__ */new Set;var ur=8,dr=32;function hr(){return e()}var mr=x.windowBar,pr=80,fr=384,wr=400;function yr(e,t=hr()){const n=Math.min(Math.max(e.x,t.x+pr-e.w),t.x+t.w-pr),r=Math.min(Math.max(e.y,t.y),t.y+t.h-mr);return n===e.x&&r===e.y?e:{...e,x:n,y:r}}function gr(e){const t=e.getBoundingClientRect();if(0===t.width||0===t.height)return!0;const n=hr();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 vr(e){const t=hr(),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 br=null;function xr(e){const t=(br||((br=document.createElement("div")).style.cssText=["position: fixed","pointer-events: none",`z-index: ${q.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(br)),br);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 kr(){br&&(br.style.opacity="0",br.style.display="none")}var Er=[{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"}],Cr=350,Mr=200;function Nr({maximized:e,onToggleMax:t,onSnap:n,buttonClassName:r,strings:o}){const[i,a]=ne(!1),s=ee(void 0),l=ee(void 0);te(()=>()=>{clearTimeout(s.current),clearTimeout(l.current)},[]);const c=()=>{clearTimeout(l.current),s.current=setTimeout(()=>a(!0),Cr)},u=()=>{clearTimeout(s.current),l.current=setTimeout(()=>a(!1),Mr)};/* @__PURE__ */
46
- return me("span",{className:"relative inline-flex",onMouseEnter:c,onMouseLeave:u,children:[
47
- /* @__PURE__ */pe("button",{onClick:t,onFocus:c,onBlur:u,"aria-label":e?o.windowed:o.maximize,title:e?o.windowed:o.maximize,className:r,children:e?"❐":"⤢"}),i&&/* @__PURE__ */pe("div",{role:"group","aria-label":o.snapLayouts,onMouseEnter:()=>clearTimeout(l.current),onMouseLeave:u,className:"absolute right-0 top-full z-30 mt-1 grid w-max grid-cols-2 gap-1 rounded-lg border border-line bg-surface p-2 shadow-lg",children:Er.map(({zone:e,labelKey:t,region:r})=>/* @__PURE__ */pe("button",{type:"button","aria-label":o[t],title:o[t],onClick:()=>{a(!1),n(e)},onFocus:()=>clearTimeout(l.current),onBlur:u,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__ */pe("span",{"aria-hidden":"true",className:`absolute rounded-sm bg-blue-500/70 ${r}`,style:{margin:2}})},e))})]})}var Sr="rosh-gesture-style";var Lr={se:"nwse-resize",nw:"nwse-resize",sw:"nesw-resize",ne:"nesw-resize",n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize"},Tr=4;function zr(e,t,n,r){!function(){if("undefined"==typeof document||document.getElementById(Sr))return;const e=document.createElement("style");e.id=Sr,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=Yt(r);let a=!1;return()=>{if(!a){a=!0,i();try{e.releasePointerCapture(t)}catch{}o.remove(),document.body.classList.remove("rosh-gesturing")}}}function Ar(e){const t=E.indexOf(e);if(-1===t)return-1;const n=q.window+t*q.windowStep,r=Xn.get(e);if(!r||r.root)return n;let o=-1;for(const[e,t]of Xn){if(!t.root||t.owner!==r.owner)continue;const n=E.indexOf(e);-1!==n&&(o=Math.max(o,q.window+n*q.windowStep))}return o>=n?o+2+Math.min(t,7):n}"undefined"!=typeof window&&window.addEventListener("deactivate-all-modals",function(){for(let e=E.length-1;e>=0;e--)cr.has(E[e])||E.splice(e,1);Ln=Ln.filter(e=>{const t=Un.get(e);return null!=t&&cr.has(t)}),zn(),Bn(),window.dispatchEvent(new CustomEvent("modal-reorder"))});var Dr="modal-close-request";function Ir(e){re(N,Hn);const t=_(M);if(E.length<=1)return!0;if(e){const t=Un.get(e);if(null!=t)return S()===t}return t?.active??null!=S()}var Pr=!1,Rr=/* @__PURE__ */new Set;function Or(e){return Rr.add(e),()=>Rr.delete(e)}function Wr(){return Pr}function Kr(e){Pr!==e&&(Pr=e,Rr.forEach(e=>e()))}function $r(){Kr(!Pr)}function jr(){Kr(!1)}var Fr=null,qr=/* @__PURE__ */new Set;function Hr(e){return qr.add(e),()=>qr.delete(e)}function Br(){return Fr}function Ur(e){Fr!==e&&(Fr=e,qr.forEach(e=>e()))}var Yr=null,Xr=/* @__PURE__ */new Set;function Vr(e){return Xr.add(e),()=>Xr.delete(e)}function Gr(){return Yr}function Jr(e){Yr!==e&&(Yr=e,Xr.forEach(e=>e()))}function _r(){if(!Yr)return void Kr(!1);Ur(Yr),Jr(null),Kr(!1)}function Zr(){Kr(!Pr),window.dispatchEvent(new CustomEvent("modal-split-view"))}function Qr(){const e=re(Or,Wr),[t,n]=ne(e),[r,o]=ne(e);return te(()=>{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?we(
48
- /* @__PURE__ */pe("div",{onMouseDown:e=>{e.stopPropagation(),Kr(!1)},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",zIndex:q.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 eo({open:t,onClose:l,title:c,icon:u,copyText:d,size:h="lg",dirty:m=!1,onNext:p,onPrev:y,footer:b,bodyScroll:x,onMinimize:k,initialBox:C,actions:T,actionsLeft:I,editing:P=!1,edit:K,allowPinOnTop:F,initialPosition:H,widget:B,compact:Y,appStyle:G,flushBody:J,autoHeight:Z,autoMinHeight:ae,autoWidth:se,widgetMenu:de,dimensions:he,windowKey:ye,openedFromKey:ge,accentRgb:ve,children:be}){const[xe,ke]=ne(()=>r()),Ee=z()&&!xe,Ce=A()&&!!B,[Me,Ne]=ne(0),[Se,Le]=ne(!1),Te=ee(null),Ae=ee(0);te(()=>{Ae.current=Me},[Me]);const De=oe(e=>{Ee&&(Te.current={startX:e.clientX,startY:e.clientY,pointerId:e.pointerId},Le(!0),$t(ge??null))},[Ee,ge]),Ie=re(jt,Kt);te(()=>{if(!Se)return;const e=e=>{if(!Te.current)return;const t=e.clientX-Te.current.startX;if(Math.abs(e.clientY-Te.current.startY)>Math.abs(t)+12)return Te.current=null,Le(!1),Ne(0),void $t(null);Ne(Math.max(0,t))},t=()=>{if(!Te.current)return;const e=.3*window.innerWidth,t=Ae.current>e;Te.current=null,Le(!1),t?(Ne(window.innerWidth),setTimeout(()=>{l(),Ne(0),$t(null)},180)):(Ne(0),$t(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)}},[Se]);const[Pe,Re]=ne(c),Oe=V(),We=Oe.window;te(()=>{Re(c)},[c]);const Ke=ce(()=>mn(Pe).trim()||void 0,[Pe]),$e=ue(),[qe,Be]=ne(!1),Ue=ee(!1),[Ye,Xe]=ne(!1),[Ve,Ge]=ne(null),Je=_(cn),_e=_(ze),{prefs:Ze,save:Qe}=D(),et=!!Ze.window_accent_stripe,tt=Ze.favorite_documents||[],nt=!!Je&&tt.some(e=>e.entityType===Je.entityType&&e.entityId===Je.entityId),rt=oe(()=>{if(!Je)return;const e=nt?tt.filter(e=>!(e.entityType===Je.entityType&&e.entityId===Je.entityId)):[...tt,{entityType:Je.entityType,entityId:Je.entityId,label:Je.label}];Qe({favorite_documents:e})},[Je,nt,tt,Qe]),[ot,it]=ne(null),[at,lt]=ne("top-right"===H?"right":"left"),ut=ee(!1),dt=ee(null);Q(()=>{const e=dt.current;e&&(ve?e.style.setProperty("--window-accent-rgb",ve):e.style.removeProperty("--window-accent-rgb"))},[ve]);const ht=ee(!1),mt=ee(null),pt=ee(null),ft=ee(null),[wt,yt]=ne(!1),gt=ee(null),vt=ee(null),bt=ee(null),[xt,kt]=ne(!1);Q(()=>{const e=vt.current,t=bt.current;if(!e||!t)return;const n=()=>kt(function(e,t){return e.scrollWidth>t.clientWidth}(t,e));if(n(),"undefined"==typeof ResizeObserver)return;const r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[null!=b&&!1!==b]);const Et=!!K&&!B&&!Y&&!G&&(K.editing||"hidden"!==K.state),Ct=!!(b||T||I)||wt||Et,Mt=_(Fe),Nt=""!==_(ln),St=ee(null);St.current=_e?{owner:_e.key,tab:_e.tab,root:!Nt}:null;const Lt=ye||(_e&&!Nt?_e.key:null),Tt=!!Mt&&!Nt&&Mt.enabled&&Mt.hasState&&(P||Mt.declaredEditable)&&!Mt.handMounted&&Ct&&!B&&!Y&&!G&&!Ee,zt=/* @__PURE__ */pe(j,{name:"window",className:"h-4 w-4",strokeWidth:1.5}),At=u&&ie(u)?le(u,{className:`h-4 w-4 ${u.props?.className??""}`.trim()}):u??zt,Dt=()=>/* @__PURE__ */pe("button",{onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation();const t=e.currentTarget.getBoundingClientRect();Ge(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:At}),It=40,{minimize:Pt,items:Ot,restoreIfMinimized:Wt,openWindows:Ft}=ct(),qt=ee(`modal-${Math.random().toString(36).slice(2,8)}`).current,Ht=w(qt);te(()=>{if(B)return cr.add(qt),()=>{cr.delete(qt)}},[B,qt]),te(()=>{const e=e=>{const t=e.detail;t?.id===qt&&Re(t.title)};return window.addEventListener("window-title-update",e),()=>window.removeEventListener("window-title-update",e)},[qt]);const[Bt,Ut]=ne(q.window),Yt=function(e){const t=re(N,S);return E.length<=1||t===e}(qt),Xt=ee(K);Xt.current=K;const Vt=!!K&&!K.editing&&"enabled"===K.state;te(()=>{if(!t||!Yt||!Vt)return;const e=e=>{("KeyE"===e.code||"E"===e.key||"e"===e.key)&&e.altKey&&e.shiftKey&&!e.metaKey&&!e.ctrlKey&&(g(e.target,dt.current)||(e.preventDefault(),e.stopPropagation(),Xt.current?.onEdit()))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Yt,Vt]);const Gt=function(e){return re(N,()=>$n.has(e))}(qt);Rt({panelRef:dt,bodyRef:mt,open:t,widget:!!B,active:Yt,minimized:Gt});const Jt=re(Or,Wr),_t=re(Hr,Br),Qt=re(Vr,Gr),tn=!F&&!B,nn=Jt&&tn,[on,an]=ne(!1),sn=nn&&Qt===qt,[un,dn]=ne(!1),pn=un&&tn&&_t===qt?"picked":null,fn=ee(nn);te(()=>{if(fn.current&&!nn){dn(!0);const e=setTimeout(()=>{dn(!1),Fr===qt&&Ur(null)},700);return fn.current=nn,()=>clearTimeout(e)}fn.current=nn},[nn,qt]),te(()=>{nn||an(!1)},[nn]),te(()=>{const e=pt.current,t=ft.current;if(!e&&!t)return;const n=e=>e?Array.from(e.children).filter(e=>"shell"!==e.dataset.undoControls).length:0,r=()=>yt(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]),te(()=>{const e=e=>{if(e.target.closest('button[type="submit"]')&&dt.current){const t=dt.current.querySelector("form");t&&(e.preventDefault(),t.requestSubmit())}},t=pt.current,n=ft.current;return t&&t.addEventListener("click",e),n&&n.addEventListener("click",e),()=>{t&&t.removeEventListener("click",e),n&&n.removeEventListener("click",e)}},[t]);const yn=ee(!1),gn=oe(e,[]),vn=oe(()=>{const t=e(),n=he?he[0]:Rn[h]||672,o=t.w-80,i=t.h-80,a=Math.min(n,o),s=Kn[Wn()],l=he?Math.min(he[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*(E.length-1),u=Math.max(It,(i-l)/2),d=(o-a)/2,m=t.h-It-l-u;return"top-right"===H?{x:t.x+t.w-a-It,y:t.y+It,w:a,h:l}:"top-left"===H?{x:t.x+It,y:t.y+It,w:a,h:l}:{x:t.x+Math.max(It,(o-a)/2+It)+Math.min(c,Math.max(0,d)),y:t.y+u+Math.min(c,Math.max(0,m)),w:a,h:l}},[h]),bn=ee(!1);t||(bn.current=!1);const xn=ye||d||null;te(()=>{if(!t)return;or(qt,xn,St.current??void 0),ye||sr(qt),yn.current=!1,Ut(Ar(qt));const e=()=>{Ut(Ar(qt))},n=()=>{},r=e=>{if(!e)return!1;if(e.windowKey)return e.windowKey===ye;if(!e.label)return!1;const t=dt.current?.querySelector("[data-window-title]");return!!t?.textContent?.includes(e.label)},o=e=>{if(!r(e.detail))return;if(sr(qt),In.current)return;const t=hr(),n=Math.min(Jn.current.w,t.w-40),o=Math.min(Jn.current.h,t.h-40),i=t.x+(t.w-n)/2,a=t.y+(t.h-o)/2;Mn({x:i,y:a,w:n,h:o}),Vn(!1)},i=e=>{const t=e.detail;r(t)&&(sr(qt),Ge({x:t.x,y:t.y}))},a=e=>{if(e.detail?.windowKey!==ye)return;sr(qt);const t=Jn.current,n=function(e,t=hr()){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=dt.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)}Mn(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=E.indexOf(e);-1!==t&&(E.splice(t,1),Bn()),$n.delete(e),Fn.delete(e),Xn.delete(e);const n=Yn.get(e);n&&(Yn.delete(e),Un.delete(n))}(qt),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,qt,xn,gn]);const kn=!B&&"maximized"===Wn(),[En,Mn]=ne(()=>{if(xn&&Cn[xn]){const e={...Cn[xn]};return he&&(e.w=he[0],Z||(e.h=he[1])),yr(e)}return C?{x:C.x,y:C.y,w:C.w,h:C.h}:kn?gn():vn()}),[Sn,Ln]=ne(()=>!Z),Tn=ee(xe),zn=ee(null);te(()=>{const e=()=>{const e=r();e!==Tn.current&&zn.current?.(e),Tn.current=e,ke(e),Ut(Ar(qt))};return window.addEventListener("react-os-shell:layout-mode-changed",e),()=>window.removeEventListener("react-os-shell:layout-mode-changed",e)},[qt]);const An=xe&&!!_e?.tab&&!Nt&&!B&&!Ee,Dn=An,In=ee(Dn);In.current=Dn;const Pn=Gn(),jn=xe&&!!_e?.tab&&!B&&!Ee&&!Jt&&Pn!==_e.key,qn=!!B&&xe&&!Jt&&null!==Pn,[Hn,Vn]=ne(()=>xn&&Cn[xn]||C?Dn:Dn||kn),Jn=ee(En);Jn.current=En;const _n=ee(Hn);Q(()=>{_n.current=Hn},[Hn]),Q(()=>{if(Sn||An)return;const e=dt.current,t=mt.current;if(!e||!t)return;const n=ae??(B?0:240),r=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0;let o=0,i=null,a=null;const s=()=>{const c=t.firstElementChild;if(!c||e.offsetHeight<=0)return;c!==a&&(a&&l.unobserve(a),l.observe(c),a=c);const u=e.offsetHeight-t.offsetHeight,d=t.style.flex,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=d,t.style.height=m,t.style.overflowY=h;const w=c.offsetHeight>f+4,y=Math.max(n,window.innerHeight-r-Math.max(0,Jn.current.y)-24),g=w?Math.min(Jn.current.h,y):Math.min(Math.max(n,u+p),y),v=Math.abs(g-o)>1;v&&(o=g,Mn(e=>Math.abs(e.h-g)>1?{...e,h:g}:e)),B||(g<=n?i&&(clearTimeout(i),i=null):(v||null===i)&&(i&&clearTimeout(i),i=setTimeout(()=>{const e=o;s(),o===e&&Ln(!0)},160)))},l=new ResizeObserver(s);s(),gt.current&&l.observe(gt.current);const c=new MutationObserver(s);return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),c.disconnect(),i&&clearTimeout(i)}},[Sn,B,ae,Ct,An]),Q(()=>{if(!Z||!Sn||B||!t)return;const e=gt.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||Hn)return;if(document.body.classList.contains("rosh-gesturing"))return;const i=ae??240,a=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--taskbar-height"))||0,s=Math.max(i,window.innerHeight-a-Math.max(0,Jn.current.y)-24);Mn(e=>({...e,h:Math.min(Math.max(i,e.h+r),s)}))});return r.observe(e),()=>r.disconnect()},[Z,Sn,B,t,Hn,ae]);const Zn=!1!==se&&!B&&!G&&!Ee,[Qn,tr]=ne(()=>!Zn);Q(()=>{if(Qn||!t)return;if(!Zn||Hn)return void tr(!0);const n=dt.current,r=mt.current;if(!n||!r)return;const o=/* @__PURE__ */new WeakSet;let l=Jn.current.w,c=0;const u=()=>tr(!0),d=()=>{c=0;const t=Jn.current;if(Math.abs(t.w-l)>1||document.body.classList.contains("rosh-gesturing"))return void u();const d=e(),h=d.w-80;if(t.w>=h)return void u();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)=>{i(e,w)||o.add(m[t])});const v=a(t,s(t.w,w,g),d,It);v!==t&&(l=v.w,Mn(v))};d();const h=new MutationObserver(()=>{c||(c=requestAnimationFrame(d))});h.observe(r,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["style","class","hidden"]});const m=setTimeout(u,On);return()=>{h.disconnect(),c&&cancelAnimationFrame(c),clearTimeout(m)}},[Qn,t,Zn,Hn]);const nr=ee(null),rr=!(!_e?.tab||Nt||B||Ee);zn.current=t=>{if(!rr)return;if(t)return nr.current||(nr.current={box:{...Jn.current},maximized:_n.current}),void(_n.current=!0);const r=nr.current;nr.current=null;const o=e();if(r?.maximized)return _n.current=!0,Vn(!0),void Mn(o);const i=r?.box??(xn?Cn[xn]:void 0);if(_n.current=!1,Vn(!1),i&&!n(i,o,!1)){const e={...i};he&&(e.w=he[0],Z||(e.h=he[1])),Mn(yr(e))}else Mn(vn())},te(()=>{Dn&&(_n.current=!0,Vn(!0),Mn(gn()))},[Dn,gn]),te(()=>{if(B)return;const e=()=>{const e=xn?Cn[xn]:void 0;if(_n.current=!1,Vn(!1),e){const t={...e};he&&(t.w=he[0],Z||(t.h=he[1])),Mn(yr(t))}else Mn(vn())};return window.addEventListener("react-os-shell:restore-windowed",e),()=>window.removeEventListener("react-os-shell:restore-windowed",e)},[B,vn,xn]),te(()=>{t&&xn&&!An&&(Cn[xn]=En,Nn()),t&&window.dispatchEvent(new CustomEvent("modal-geometry"))},[En,t,xn,An]),te(()=>{if(!t)return;const e=()=>{_n.current?Mn(gn()):document.body.classList.contains("rosh-gesturing")||Mn(yr)};window.addEventListener("resize",e),window.addEventListener(o,e);let n=null;return Hn&&(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,Hn,gn]),te(()=>{if(t&&(Be(!1),Ue.current=!1,ut.current=!1,tr(!Zn),!In.current)){if(xn&&Cn[xn]){const e=Cn[xn];return void Mn(t=>yr({...e,...Z?{h:t.h}:{},...Zn?{x:t.x,w:t.w}:{}}))}C&&(Mn({x:C.x,y:C.y,w:C.w,h:C.h}),Vn(C.maximized))}},[t]),te(()=>{if(!t||"auto"!==m)return;let e;const n=t=>{dt.current?.contains(t.target)&&!Ue.current&&(Ue.current=!0,e=setTimeout(()=>Be(!0),0))};return document.addEventListener("input",n,!0),document.addEventListener("change",n,!0),()=>{clearTimeout(e),document.removeEventListener("input",n,!0),document.removeEventListener("change",n,!0)}},[t,m]);const ir="auto"===m?qe:!0===m,ar=_e&&!Nt?_e.key:null,mr=ce(()=>Zt(Pe),[Pe]),pr=ee({shortcutSpec:Je,isOnDesktop:nt,toggleDesktopShortcut:rt,taskbarStrings:Oe.taskbar});Q(()=>{pr.current={shortcutSpec:Je,isOnDesktop:nt,toggleDesktopShortcut:rt,taskbarStrings:Oe.taskbar}});const gr=ee(null);gr.current||(gr.current={open:(e,t)=>Ge({x:e,y:t}),items:()=>{const e=pr.current,t=[];e.shortcutSpec&&t.push({label:e.isOnDesktop?e.taskbarStrings.removeFromDesktop:e.taskbarStrings.addToDesktop,onSelect:e.toggleDesktopShortcut});for(const e of wn[qt]||[])t.push({label:e.label,icon:e.icon,onSelect:e.onClick});return t}}),te(()=>{if(t&&ar)return()=>{return e=ar,void(en.delete(e)&&rn());var e}},[t,ar]),st(!(ye||!t)&&ir);const br=oe(()=>ir||"auto"===m&&Ue.current,[ir,m]),Er=oe(async e=>{if(ut.current)return!1;if(!br())return!0;ut.current=!0;const t=Ke,n="close"===e?"Are you sure you want to close?":"discard"===e?"Are you sure you want to stop editing?":"Are you sure you want to continue?",r=await f({title:"Discard changes?",message:t?`“${t}” has unsaved changes. ${n} All changes will be lost.`:`You have unsaved changes. ${n} All changes will be lost.`,confirmLabel:"Discard",cancelLabel:"Keep Editing",variant:"warning"});return ut.current=!1,r},[br,Ke]),Cr=oe(()=>ut.current?Promise.resolve():br()?Er("close").then(e=>{e&&l()}):(l(),Promise.resolve()),[br,Er,l]),Mr=oe(async()=>{await Er("discard")&&(Ue.current=!1,Be(!1),Xt.current?.onDiscard())},[Er]),Sr=oe(async()=>{const e=await Er("switch");return e&&(Ue.current=!1,Be(!1)),e},[Er]),Ir=ee(()=>!1);Q(()=>{Ir.current=br}),Q(()=>{if(!t||!ye)return;const e={holdsChanges:()=>Ir.current(),ask:Sr};return er.set(ye,e),()=>{er.get(ye)===e&&er.delete(ye)}},[t,ye,Sr]),Q(()=>{if(!t||!Lt)return;const e=e=>{e.detail?.windowKey===Lt&&Cr()};return window.addEventListener(Dr,e),()=>window.removeEventListener(Dr,e)},[t,Lt,Cr]);const Pr=ee(null),Rr=oe(e=>{if(0!==e.button)return;if(e.target.closest("button, input, a, kbd, select, textarea"))return;if(Ge(null),sr(qt),In.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=dt.current,s=a?.getBoundingClientRect();let l,c,u,d;if(Pr.current){const t=Pr.current;Pr.current=null,d=t.w,u=t.h;const n=s?Math.min(Math.max(20,e.clientX-s.left),t.w-20):t.w/2;l=e.clientX-n,c=e.clientY-12,a&&(a.style.width=`${d}px`,a.style.height=`${u}px`,a.style.left=`${l}px`,a.style.top=`${c}px`)}else l=s?s.left:Jn.current.x,c=s?s.top:Jn.current.y,u=s?s.height:Jn.current.h,d=s?s.width:Jn.current.w;Vn(!1),Mn(e=>({...e,x:l,y:c,w:d,h:u}));let h=null;const m=e=>{if(!r){if(Math.abs(e.clientX-o)<Tr&&Math.abs(e.clientY-i)<Tr)return;r=zr(t,n,"move","move"),a&&(a.style.transition="none")}const s=l+e.clientX-o,u=Math.max(0,c+e.clientY-i);if(a&&(a.style.transform=`translate(${s-l}px, ${u-c}px)`),Jn.current={...Jn.current,x:s,y:u},!B){const t=function(e,t){const n=hr(),r=e<=n.x+ur,o=e>=n.x+n.w-ur,i=t<=n.y+ur,a=t>=n.y+n.h-ur,s=e<=n.x+dr,l=e>=n.x+n.w-dr,c=t<=n.y+dr,u=t>=n.y+n.h-dr;return i&&s?"tl":i&&l?"tr":a&&s?"bl":a&&l?"br":c&&r?"tl":c&&o?"tr":u&&r?"bl":u&&o?"br":i?"top":r?"left":o?"right":null}(e.clientX,e.clientY);t!==h&&(h=t,t?xr(vr(t)):kr())}},p=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),r?.(),kr();const e=yr({...Jn.current});if(Jn.current=e,!B&&h){Pr.current={x:l,y:c,w:d,h:u};const e=vr(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 Mn(e)}if(B){const t=e.x+e.w/2,n=window.innerWidth/2;lt(t>n?"right":"left")}a&&(a.style.left=`${e.x}px`,a.style.top=`${e.y}px`,a.style.transform="",a.style.transition=""),Mn(e)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",p)},[]),$r=oe((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=dt.current,l=s?.getBoundingClientRect(),c=l?l.left:Jn.current.x,u=l?l.top:Jn.current.y,d=l?l.width:Jn.current.w,h=l?l.height:Jn.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;Vn(!1),Mn({x:c,y:u,w:d,h:h}),Jn.current={x:c,y:u,w:d,h:h};let y=0,g=null;const v=()=>{if(y=0,!g)return;const e=g;g=null,Jn.current=e,s&&(s.style.left=`${e.x}px`,s.style.top=`${e.y}px`,s.style.width=`${e.w}px`,s.style.height=`${e.h}px`)},b=e=>{if(!o){if(Math.abs(e.clientX-i)<Tr&&Math.abs(e.clientY-a)<Tr)return;o=zr(n,r,Lr[t],"resize")}g=((e,t)=>{let n=c,r=u,o=d,i=h;if(f&&(o=Math.max(fr,d+e)),w&&(i=Math.max(wr,h+t)),m){const t=Math.max(fr,d-e);n=c+d-t,o=t}if(p){const e=Math.max(wr,h-t);r=u+h-e,i=e}return{x:n,y:r,w:o,h:i}})(e.clientX-i,e.clientY-a),y||(y=requestAnimationFrame(v))},x=()=>{window.removeEventListener("pointermove",b),window.removeEventListener("pointerup",x),y&&cancelAnimationFrame(y),v(),o?.(),Mn({...Jn.current})};window.addEventListener("pointermove",b),window.addEventListener("pointerup",x)},[]),jr=oe(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(),sr(qt),"Enter"===e.key)return void(Hn?(Vn(!1),Mn(vn())):(Vn(!0),Mn(gn())));const[n,r]=t;if(e.ctrlKey||e.metaKey){const e=()=>{Pr.current||(Pr.current={...Jn.current})};if(r<0)return e(),Vn(!0),void Mn(gn());if(r>0){if(Hn)return Vn(!1),void Mn(vn());if(Pr.current){const e=yr(Pr.current);return Pr.current=null,Jn.current=e,void Mn(e)}return void lr(qt)}e(),Vn(!1);const t=vr(n<0?"left":"right");return Jn.current=t,void Mn(t)}if(Hn)return;const o=Jn.current,i=e.shiftKey?{...o,w:Math.max(fr,o.w+24*n),h:Math.max(wr,o.h+24*r)}:yr({...o,x:o.x+24*n,y:Math.max(0,o.y+24*r)});Jn.current=i,Mn(i)},[qt,Hn,vn,gn]),qr=oe(e=>{Pr.current||(Pr.current={...Jn.current}),Vn(!1);const t=vr(e);Jn.current=t,Mn(t),sr(qt)},[qt]),Yr=Dn||nn?{}:{tabIndex:0,role:"group","aria-label":Ke?`${Ke} — ${We.windowSuffix}`:We.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:jr},Xr=()=>{Vn(!0),Mn(gn())},Jr=oe(()=>{const e=dt.current;if(!e)return;const t=e.querySelector("form");if(t)t.requestSubmit();else{const t=e.querySelector(hn);t&&!t.disabled&&t.click()}},[]);te(()=>{if(!t)return;if(B)return;const e=e=>{if(E[E.length-1]===qt&&!g(e.target,dt.current)&&"Enter"===e.key){const t=e.target;if("TEXTAREA"===t.tagName||t.isContentEditable)return;if(e.metaKey||e.ctrlKey)e.preventDefault(),Jr();else{if("INPUT"===t.tagName&&t.closest("form"))return;if(!(t instanceof Element&&dt.current?.contains(t)))return;if(t.closest(L))return;e.preventDefault()}}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Jr,qt,B]),te(()=>{if(!t)return;const e=e=>{E[E.length-1]===qt&&(g(e.target,dt.current)||((e.metaKey||e.ctrlKey)&&"s"===e.key?(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-save",{detail:{modalId:qt}})),Ue.current=!1,Be(!1)):e.altKey&&e.shiftKey&&("KeyD"===e.code||"D"===e.key||"d"===e.key)&&(e.preventDefault(),document.dispatchEvent(new CustomEvent("modal-duplicate",{detail:{modalId:qt}})))))};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t]),te(()=>{if(!t)return;if(B)return;const e=e=>{if("Escape"===e.key&&E[E.length-1]===qt){if(X(e))return e.preventDefault(),void e.stopPropagation();if(An&&!P)return;e.preventDefault(),e.stopPropagation(),Cr()}};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[t,Cr,qt,B,An,P]);const _r=t&&(void 0!==p||void 0!==y),[Zr]=ne(()=>{if("undefined"==typeof document)return null;const e=document.createElement("span");return e.className="flex shrink-0 items-center gap-2",e.setAttribute("data-tab-actions",""),e}),Qr=An&&!_e?.home&&mr.actions.length>0;te(()=>{t&&ar&&function(e,t){const n=en.get(e);n&&n.title===t.title&&n.dirty===t.dirty&&n.copy===t.copy&&n.actions===t.actions&&n.menu===t.menu||(en.set(e,t),rn())}(ar,{title:mr.text||Ke,dirty:ir,copy:mr.copy,actions:Qr&&Zr?Zr:void 0,menu:gr.current??void 0})},[t,ar,Ke,ir,mr.text,mr.copy,Qr,Zr]);const eo=oe(e=>{const t=document.getElementById("nav-boundary-toast");t&&t.remove();const n="bottom"===e?["That's the last one, chief.","You've hit rock bottom... of the list.","End of the line, buddy.","Nothing left. Go outside.","Congratulations, you scrolled to the void.","There's no more. I checked.","You've reached the edge of the known universe.","Plot twist: there is no next one.","Even scrolling has limits. Unlike your ambition.","Last one. Time to touch grass."]:["Already at the top. Overachiever.","There is no item above this. Trust me.","You're #1. Literally.","Can't go higher. You've peaked.","This is it. The summit. The top.","First item. No VIP lounge above this.","Going up? Nope. Elevator's broken.","You want negative indexes? Bold.","Top of the list. Top of the world.","The only way is down from here."],r=n[Math.floor(Math.random()*n.length)],o=document.createElement("div");o.id="nav-boundary-toast",o.className="fixed bottom-6 left-1/2 -translate-x-1/2 z-(--z-toast) bg-gray-900 text-on-accent flex min-h-10 items-center px-5 py-3 rounded-lg shadow-lg text-sm font-medium transition-opacity duration-300",o.textContent=r,document.body.appendChild(o),setTimeout(()=>{o.style.opacity="0",setTimeout(()=>o.remove(),300)},2e3)},[]);if(te(()=>{if(!t)return;const e=e=>{if(E[E.length-1]!==qt)return;if(g(e.target,dt.current))return;const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.target.isContentEditable||("j"===e.key&&_r&&(e.preventDefault(),p?p():eo("bottom")),"k"===e.key&&_r&&(e.preventDefault(),y?y():eo("top"))))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,y,_r,eo,qt]),!t||bn.current)return null;const to=nn?function(e){if("undefined"==typeof document)return null;const t=Array.from(document.querySelectorAll("[data-modal-panel]")).filter(e=>{const t=e;return!t.hasAttribute("data-utility")&&!t.hasAttribute("data-widget")&&"none"!==t.style.display});t.sort((e,t)=>(e.getAttribute("data-modal-id")||"").localeCompare(t.getAttribute("data-modal-id")||""));const n=t.findIndex(t=>t.getAttribute("data-modal-id")===e),r=t.length;if(n<0||r<1)return null;const o=Math.ceil(Math.sqrt(r)),i=Math.ceil(r/o),a=Math.floor(n/o),s=n%o,l=r-o*(i-1),c=a===i-1&&l<o,u=hr(),d=(u.w-20*(o+1))/o,h=(u.h-14*(i+1)-22*i)/i,m=c?(o-l)*(d+20)/2:0;return{x:u.x+20+s*(d+20)+m,y:u.y+14+a*(h+14+22),w:d,h:h}}(qt):null,no=nn&&to?U({width:to.w,height:to.h},{width:En.w,height:En.h}):1,ro=(()=>{if(nn&&to){const e=no,t=En.w*e,n=En.h*e,r=to.x+(to.w-t)/2-En.x,o=to.y+(to.h-n)/2-En.y,i=on||sn;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:q.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(un&&tn){const e="picked"===pn;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:q.expose+30}:{}}}return null})(),oo=v({modal:!1,titleId:!B&&(An?!_e?.home:!Ee)?$e:void 0,label:mr.text||Ke}),io=/* @__PURE__ */me("div",{children:[
49
- /* @__PURE__ */me("div",{ref:dt,"data-modal-panel":!0,"data-modal-id":qt,"data-window-key":ye||void 0,...F?{"data-utility":""}:{},...Ye?{"data-pinned-top":""}:{},...B?{"data-widget":""}:{},..._e?{"data-window-owner":_e.key}:{},..._e&&!Nt?{"data-window-root":""}:{},...An?{"data-window-tab":""}:{},...oo,className:An?"fixed flex flex-col overflow-hidden":"fixed rounded-(--radius-window) flex flex-col overflow-hidden "+(B?Yt?"shadow-xl":"shadow-lg":"border "+(Yt?"shadow-xl border-line":"shadow-lg border-line-strong")),onMouseDownCapture:e=>{if(ht.current=!1,nn){if(e.target.closest("[data-expose-close]"))return;return e.preventDefault(),e.stopPropagation(),Ur(qt),Kr(!1),void sr(qt)}if(!Yt&&!B&&!Ye&&0===e.button){const t=e.target;t.closest("[data-modal-panel]")===dt.current&&t.closest("button, input, a, select, textarea")&&!t.closest("[data-window-chrome]")&&(e.preventDefault(),e.stopPropagation(),ht.current=!0,Ge(null),sr(qt),window.addEventListener("mouseup",()=>{setTimeout(()=>{ht.current=!1},0)},{once:!0}))}},onClickCapture:e=>{ht.current&&(ht.current=!1,e.preventDefault(),e.stopPropagation())},onMouseDown:e=>{if(nn)return;Ge(null);e.target.closest("[data-modal-panel]")===dt.current&&(e.target.closest("button, input, a, select, textarea")||sr(qt))},style:Ee?{zIndex:Bt+1,top:0,left:0,right:0,bottom:"var(--mobile-bottom-nav, 56px)",width:"auto",height:"auto",transform:`translateX(${Me}px)`,transition:Se?"none":"transform 180ms ease-out",...B?{display:"none"}:{},...Bt<0?{display:"none"}:{},...Yt||Ye||Ie&&ye===Ie?{}:{display:"none"},...Ht?{visibility:"hidden",pointerEvents:"none"}:{}}:{zIndex:Ye?q.pinnedWindow:Bt+1,width:En.w,height:En.h,top:En.y,...B&&"right"===at?{right:window.innerWidth-En.x-En.w}:{left:En.x},...Bt<0&&!Ye?{display:"none"}:{},...Ce?{display:"none"}:{},...jn||qn||Ht?{visibility:"hidden",pointerEvents:"none"}:{},...ro??{}},children:[Ee&&!B&&/* @__PURE__ */pe("div",{onPointerDown:De,className:"absolute top-0 bottom-0 left-0 w-[22px] z-[5]",style:{touchAction:"pan-y"},"aria-hidden":"true"}),B?null:An?_e?.home?null:/* @__PURE__ */me(fe,{children:[
50
- /* @__PURE__ */pe("h2",{id:$e,"data-window-title":!0,className:"sr-only",children:mr.text||Ke}),Qr&&Zr&&we(
51
- /* @__PURE__ */pe(fe,{children:mr.actions}),Zr),mr.badges.length>0&&/* @__PURE__ */pe("div",{"data-window-chrome":"","data-record-bar":"",className:"flex h-9 shrink-0 select-none items-center gap-2 overflow-hidden border-b border-gray-200 px-4",style:{backgroundColor:"rgb(var(--window-content-rgb))"},children:mr.badges})]}):Ee?null:
52
- /* @__PURE__ */me("div",Y?{onPointerDown:Rr,"data-window-chrome":"",...Yr,className:"flex items-center justify-between h-(--row-height-compact-bar) px-3 border-b border-line 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 "+(Yt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:Yt?"rgb(var(--window-header-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-header-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
53
- /* @__PURE__ */me("div",{"data-window-title":!0,title:Ke,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:Yt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!nn&&Dt(),
54
- /* @__PURE__ */pe("span",{id:$e,className:"truncate",children:nn?mn(Pe):Pe})]}),!nn&&/* @__PURE__ */me("div",{className:"flex items-center gap-2 shrink-0 ml-2",children:[F&&/* @__PURE__ */pe("button",{onClick:()=>Xe(e=>!e),title:Ye?We.unpin:We.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(Ye?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */pe(j,{name:"bookmark-square",className:"h-3 w-3",fill:Ye?"currentColor":"none",strokeWidth:1.5})}),
55
- /* @__PURE__ */pe("button",{type:"button",onClick:Cr,"aria-label":We.close,className:"rounded p-0.5 text-ink-faintest hover:text-gray-600 hover:bg-gray-200",children:/* @__PURE__ */pe(j,{name:"close",className:"h-4 w-4"})})]})]}:G?{onPointerDown:Rr,"data-window-chrome":"",...Yr,className:"flex items-center justify-between h-(--row-height-compact-bar) px-3 border-b border-line 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 "+(Yt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:Yt?"rgb(var(--window-header-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-header-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
56
- /* @__PURE__ */me("div",{"data-window-title":!0,title:Ke,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:Yt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!nn&&Dt(),
57
- /* @__PURE__ */pe("span",{id:$e,className:"truncate",children:nn?mn(Pe):Pe})]}),!nn&&/* @__PURE__ */me("div",{className:"flex items-center gap-2 shrink-0 ml-2",children:[F&&/* @__PURE__ */pe("button",{onClick:()=>Xe(e=>!e),title:Ye?We.unpin:We.pinOnTop,className:"p-0.5 rounded hover:bg-gray-200 "+(Ye?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */pe(j,{name:"bookmark-square",className:"h-3 w-3",fill:Ye?"currentColor":"none",strokeWidth:1.5})}),
58
- /* @__PURE__ */pe("button",{onClick:()=>lr(qt),"aria-label":We.minimize,title:We.minimize,className:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",children:"─"}),!Dn&&/* @__PURE__ */pe(Nr,{maximized:Hn,onToggleMax:()=>{Hn?(Vn(!1),Mn(vn())):Xr()},onSnap:qr,buttonClassName:"text-gray-400 hover:text-gray-600 px-1 py-0.5 rounded hover:bg-gray-200 text-xs leading-none",strings:We}),
59
- /* @__PURE__ */pe("button",{type:"button",onClick:Cr,"aria-label":We.close,className:"rounded p-0.5 text-ink-faintest hover:text-gray-600 hover:bg-gray-200",children:/* @__PURE__ */pe(j,{name:"close",className:"h-4 w-4"})})]})]}:{onPointerDown:Rr,"data-window-chrome":"",...Yr,className:"flex items-center justify-between h-(--row-height-window-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 "+(Yt?"backdrop-blur-sm":""),style:{touchAction:"none",backgroundColor:Yt?"rgb(var(--window-header-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-header-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
60
- /* @__PURE__ */me("div",{"data-window-title":!0,title:Ke,className:"text-sm font-medium min-w-0 flex-1 truncate flex items-center gap-2",style:{color:Yt?"var(--window-title-active, rgb(17 24 39))":"var(--window-title-inactive, rgb(156 163 175))"},children:[!nn&&Dt(),
61
- /* @__PURE__ */pe("span",{id:$e,className:"truncate",children:nn?mn(Pe):Pe})]}),!nn&&/* @__PURE__ */me("div",{className:"flex items-center gap-3 shrink-0 ml-4",children:[F&&/* @__PURE__ */pe("button",{onClick:()=>Xe(e=>!e),title:Ye?We.unpin:We.pinOnTop,className:"text-xs px-2 py-1 rounded hover:bg-gray-200 "+(Ye?"text-blue-600":"text-gray-400 hover:text-gray-600"),children:/* @__PURE__ */pe(j,{name:"bookmark-square",className:"h-3.5 w-3.5",fill:Ye?"currentColor":"none",strokeWidth:1.5})}),
62
- /* @__PURE__ */pe("button",{onClick:()=>lr(qt),"aria-label":We.minimize,title:We.minimize,className:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",children:"─"}),!Dn&&/* @__PURE__ */pe(Nr,{maximized:Hn,onToggleMax:()=>{Hn?(Vn(!1),Mn(vn())):Xr()},onSnap:qr,buttonClassName:"text-gray-400 hover:text-gray-600 text-xs px-2 py-1 rounded hover:bg-gray-200",strings:We}),
63
- /* @__PURE__ */pe("button",{type:"button",onClick:Cr,"aria-label":We.close,className:"rounded-(--radius-control) text-ink-faintest hover:text-gray-600",children:/* @__PURE__ */pe(j,{name:"close",className:"h-5 w-5"})})]})]}),ve&&et&&!B&&!Ee&&/* @__PURE__ */pe("div",{"aria-hidden":"true",className:"h-[3px] shrink-0 pointer-events-none",style:{backgroundColor:`rgb(var(--window-accent-rgb) / ${Yt?.9:.55})`}}),
64
- /* @__PURE__ */pe(ln.Provider,{value:qt,children:/* @__PURE__ */pe(M.Provider,{value:{rightRef:pt,leftRef:ft,notify:()=>yt(!0),active:Yt,isDirty:ir,footerOpen:Ct&&!B&&!Y&&!G&&!Ee},children:/* @__PURE__ */pe("div",{ref:mt,...B?{onPointerDown:Rr,onContextMenu:e=>{e.preventDefault(),it({x:e.clientX,y:e.clientY})}}:{},className:`flex-1 min-h-0 flex flex-col ${B?"p-0 cursor-move":G||J?"p-0":Y?"p-2":"p-4"} ${B||An?"":"backdrop-blur-sm"} ${!1===x||G||J?"overflow-hidden":"overflow-y-auto overscroll-contain"} ${B?"rounded-2xl select-none":""}`,style:{...B?{touchAction:"none"}:{},backgroundColor:B?"transparent":An?"rgb(var(--window-content-rgb))":Yt?"rgb(var(--window-content-rgb) / var(--active-content-opacity, 0.9))":"rgb(var(--window-content-rgb) / var(--inactive-content-opacity, 0.8))"},children:/* @__PURE__ */pe(je,{children:be})})})}),B&&ot&&/* @__PURE__ */me(R,{minWidth:160,style:{left:ot.x,top:ot.y},onClose:()=>it(null),children:[
65
- /* @__PURE__ */pe(O,{onClick:()=>{it(null),window.dispatchEvent(new CustomEvent("widget-open-settings",{detail:qt}))},children:"Settings"}),
66
- /* @__PURE__ */pe(W,{}),de&&/* @__PURE__ */me(fe,{children:[de,
67
- /* @__PURE__ */pe(W,{})]}),
68
- /* @__PURE__ */me(O,{onClick:()=>{it(null),Xe(e=>!e)},children:[
69
- /* @__PURE__ */pe("span",{className:"flex-1",children:"Always on Top"}),Ye&&/* @__PURE__ */pe(j,{name:"check",className:"h-4 w-4 text-blue-600 shrink-0",strokeWidth:2})]}),
70
- /* @__PURE__ */pe(W,{}),
71
- /* @__PURE__ */pe(O,{onClick:()=>{it(null),Cr()},children:"Close"})]}),
72
- /* @__PURE__ */me("div",{onPointerDown:Rr,ref:gt,"data-modal-footer":"",className:`px-4 py-2 border-t border-gray-200 shrink-0 flex items-center justify-between text-xs select-none${An?"":" cursor-move"}${Yt&&!An?" backdrop-blur-sm":""}${B||Y||G||Ee||!Ct?" hidden":""}`,style:{touchAction:"none",backgroundColor:An?"rgb(var(--window-footer-rgb))":Yt?"rgb(var(--window-footer-rgb) / var(--active-header-opacity, 0.8))":"rgb(var(--window-footer-rgb) / var(--inactive-header-opacity, 0.7))"},children:[
73
- /* @__PURE__ */me("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[Tt&&/* @__PURE__ */pe(He,{auto:!0}),I,
74
- /* @__PURE__ */pe("div",{ref:ft,"data-modal-actions-left":!0,className:"flex items-center gap-2 shrink-0"}),null!=b&&!1!==b&&
75
- /* @__PURE__ */pe("div",{ref:vt,"data-modal-footer-facts":"",className:"min-w-0 flex-1 overflow-hidden",children:/* @__PURE__ */pe("div",{ref:bt,className:"inline-flex items-center gap-2 whitespace-nowrap"+(xt?" invisible":""),children:b})})]}),
76
- /* @__PURE__ */me("div",{"data-modal-footer-right":"",className:"flex items-center gap-2 ml-auto shrink-0",children:[Et&&K&&(K.editing?/* @__PURE__ */pe($,{variant:"secondary",size:"sm","data-modal-discard":"",onClick:()=>{Mr()},children:We.discard}):"object"==typeof K.state?/* @__PURE__ */pe($,{variant:"secondary",size:"sm","data-modal-edit":"","aria-disabled":!0,disabledReason:K.state.disabledReason,children:We.edit}):/* @__PURE__ */pe($,{variant:"secondary",size:"sm","data-modal-edit":"",onClick:()=>K.onEdit(),children:We.edit})),
77
- /* @__PURE__ */pe("div",{ref:pt,"data-modal-actions":!0,className:"flex items-center gap-2"}),T]})]}),!B&&!Ee&&!nn&&Yt&&!Dn&&/* @__PURE__ */me(fe,{children:[
78
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"se"),className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize z-10"}),
79
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"sw"),className:"absolute bottom-0 left-0 w-3 h-3 cursor-nesw-resize z-10"}),
80
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"ne"),className:"absolute top-0 right-0 w-3 h-3 cursor-nesw-resize z-10"}),
81
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"nw"),className:"absolute top-0 left-0 w-3 h-3 cursor-nwse-resize z-10"}),
82
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"n"),className:"absolute top-0 left-3 right-3 h-1 cursor-ns-resize"}),
83
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"s"),className:"absolute bottom-0 left-3 right-3 h-1 cursor-ns-resize"}),
84
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"e"),className:"absolute top-3 bottom-3 right-0 w-1 cursor-ew-resize"}),
85
- /* @__PURE__ */pe("div",{onPointerDown:e=>$r(e,"w"),className:"absolute top-3 bottom-3 left-0 w-1 cursor-ew-resize"})]}),nn&&/* @__PURE__ */pe("div",{className:"absolute inset-0",style:{zIndex:q.hint,cursor:"pointer",background:"transparent"},onMouseEnter:()=>an(!0),onMouseLeave:()=>an(!1),onMouseDown:e=>{e.stopPropagation(),e.preventDefault(),sr(qt),Kr(!1)},onClick:e=>{e.stopPropagation(),e.preventDefault()},children:on&&/* @__PURE__ */pe("button",{type:"button","data-expose-close":!0,"aria-label":Oe.taskbar.closeWindow,title:"Close",className:"absolute flex items-center justify-center rounded-full bg-black/55 text-on-accent shadow-lg ring-1 ring-white/40 transition-colors hover:bg-red-500",style:{top:8,right:8,width:30,height:30,transform:`scale(${1/no})`,transformOrigin:"top right",zIndex:q.raised},onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},onClick:e=>{e.stopPropagation(),e.preventDefault(),Cr()},children:/* @__PURE__ */pe(j,{name:"close",className:"h-4 w-4",strokeWidth:2.2})})})]}),nn&&to&&/* @__PURE__ */pe("div",{className:"fixed pointer-events-none select-none truncate text-center",style:{left:to.x,top:to.y+to.h+4,width:to.w,zIndex:q.expose+(on?21:11),color:"white",fontSize:"var(--text-xs)",fontWeight:500,textShadow:"0 1px 2px rgba(0,0,0,0.6)"},children:mn(Pe)})]}),ao=Ve&&/* @__PURE__ */me(R,{style:{left:Ve.x,top:Ve.y},onClose:()=>Ge(null),minWidth:160,children:[!B&&!Y&&!An&&/* @__PURE__ */me(fe,{children:[
86
- /* @__PURE__ */me(O,{onClick:()=>{lr(qt),Ge(null)},children:[
87
- /* @__PURE__ */pe(j,{name:"remove",className:"h-4 w-4",strokeWidth:1.5}),We.minimize]}),!Dn&&/* @__PURE__ */me(O,Hn?{onClick:()=>{Vn(!1),Mn(vn()),Ge(null)},children:[
88
- /* @__PURE__ */pe(j,{name:"collapse",className:"h-4 w-4",strokeWidth:1.5}),We.windowed]}:{onClick:()=>{Xr(),Ge(null)},children:[
89
- /* @__PURE__ */pe(j,{name:"expand",className:"h-4 w-4",strokeWidth:1.5}),We.maximize]})]}),F&&!An&&/* @__PURE__ */me(O,{onClick:()=>{Xe(e=>!e),Ge(null)},children:[
90
- /* @__PURE__ */pe(j,{name:"bookmark-square",className:"h-4 w-4 "+(Ye?"text-blue-600":""),fill:Ye?"currentColor":"none",strokeWidth:1.5}),Ye?We.unpin:We.pinOnTop]}),Je&&/* @__PURE__ */me(O,{onClick:()=>{Ge(null),rt()},children:[
91
- /* @__PURE__ */pe(j,{name:"star",className:"h-4 w-4",fill:nt?"currentColor":"none",strokeWidth:1.5}),nt?Oe.taskbar.removeFromDesktop:Oe.taskbar.addToDesktop]}),(wn[qt]||[]).length>0&&/* @__PURE__ */pe(fe,{children:(wn[qt]||[]).map((e,t)=>/* @__PURE__ */me(O,{onClick:()=>{Ge(null),e.onClick()},children:[e.icon,e.label]},t))}),!(An&&_e?.home)&&/* @__PURE__ */me(fe,{children:[
92
- /* @__PURE__ */pe(W,{}),
93
- /* @__PURE__ */me(O,{danger:!0,onClick:()=>{Ge(null),Cr()},children:[
94
- /* @__PURE__ */pe(j,{name:"close",className:"h-4 w-4"}),We.close]})]})]}),so=!!ye&&Ft.some(e=>e.id===ye),lo=!Gt||so||B?null:/* @__PURE__ */me("div",{"data-modal-restore-tab":!0,"data-modal-id":qt,className:"fixed left-1/2 z-(--z-restore-tab) flex -translate-x-1/2 items-center gap-1 rounded-lg border border-line-strong bg-surface px-2 py-1 shadow-lg",style:{bottom:"calc(var(--taskbar-height, 0px) + 12px)"},children:[
95
- /* @__PURE__ */pe("button",{type:"button",onClick:()=>sr(qt),title:We.restore,className:"max-w-[16rem] truncate rounded px-2 py-0.5 text-sm font-medium text-gray-700 hover:bg-gray-100 hover:text-gray-900",children:Ke||We.windowSuffix}),
96
- /* @__PURE__ */pe("button",{type:"button",onClick:()=>sr(qt),title:We.restore,"aria-label":We.restore,className:"rounded px-2 py-0.5 text-xs leading-none text-ink-faintest hover:bg-gray-100 hover:text-gray-600",children:"▴"}),
97
- /* @__PURE__ */pe("button",{type:"button",onClick:()=>{Cr()},title:We.close,"aria-label":We.close,className:"rounded px-2 py-0.5 text-xs leading-none text-ink-faintest hover:bg-gray-100 hover:text-gray-600",children:"✕"})]});return we(
98
- /* @__PURE__ */me(cn.Provider,{value:null,children:[io,ao,lo]}),document.body)}"undefined"!=typeof window&&window.addEventListener("keydown",e=>{Pr&&"Escape"===e.key&&(Jr(null),Kr(!1))});var to=100,no={past:[],future:[]};function ro(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>to?r.slice(r.length-to):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:no}}var oo=/* @__PURE__ */new Set(["INPUT","TEXTAREA","SELECT"]);var io=500,ao=250;function so({children:e,canEdit:t=!0,perms:n,windowId:r}){const[o,i]=de(ro,no),a=ee(/* @__PURE__ */new Map),[s,l]=ne(0),c=s>0,[u,d]=ne(0),[h,m]=ne(0),p=h>0,{hasAnyPerm:f}=T(),w=t&&0===u&&(!(n&&n.length>0)||f(n)),y=ee(null),g=ee(!1),v=oe(()=>{const e={};for(const[t,n]of a.current)e[t]=n.getLast();return e},[]),b=oe((e,t)=>{a.current.has(e)||l(e=>e+1),a.current.set(e,t)},[]),x=oe(e=>{a.current.delete(e)&&l(e=>e-1)},[]),k=oe(e=>{d(t=>t+(e?1:-1))},[]),E=oe(e=>{m(t=>t+(e?1:-1))},[]),[C,N]=ne(0),S=C>0,L=oe(e=>{N(t=>t+(e?1:-1))},[]),z=_(Fe),A=z?.claimReadOnly;te(()=>{if(A&&!w)return A(!0),()=>A(!1)},[A,w]);const D=z?.claimOwnMount;te(()=>{if(D&&S)return D(!0),()=>D(!1)},[D,S]);const I=ee({last:0,count:0,tripped:!1}),P=ee(!1),R=oe((e,t,n)=>{if(g.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)||(P.current=!0));if(!w||y.current)return;const r=I.current;if(r.tripped)return;const o=Date.now();if(o-r.last>ao&&(r.count=0),r.last=o,++r.count>io)return r.tripped=!0,void console.error(`[efficient-shell] UndoProvider: "${e}" recorded ${io} 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.`);y.current={values:v(),label:e,coalesceKey:t},queueMicrotask(()=>{const e=y.current;y.current=null,e&&i({type:"record",step:e})})},[w,v]),O=oe(e=>{for(const[t,n]of Object.entries(e)){const e=a.current.get(t);e&&(e.setLast(n),e.apply(n))}},[]),W=oe(()=>{const e=o.past[o.past.length-1];if(!e)return;const t={values:v(),label:e.label,coalesceKey:null};O(e.values),i({type:"undo",redoStep:t})},[o.past,v,O]),K=oe(()=>{const e=o.future[0];if(!e)return;const t={values:v(),label:e.label,coalesceKey:null};O(e.values),i({type:"redo",undoStep:t})},[o.future,v,O]),[$,j]=ne(0),F=ee(0),q=ee(0),H=ee(!1),B=oe(()=>{g.current=!0,P.current=!1,y.current=null,F.current+=1,q.current=F.current,j(F.current)},[]),U=ee(void 0),Y=oe(e=>{void 0!==e&&(void 0!==U.current&&e!==U.current&&(H.current=!0),U.current=e),B()},[B]);te(()=>{g.current&&$===q.current&&(g.current=!1,y.current=null,(P.current||H.current)&&i({type:"clear"}),P.current=!1,H.current=!1)},[$]);const X=oe(()=>{H.current=!0,i({type:"clear"}),B()},[B]),V=w&&o.past.length>0,G=w&&o.future.length>0,J=Ir(r),Z=ee({undo:W,redo:K,canUndo:V,canRedo:G});Z.current={undo:W,redo:K,canUndo:V,canRedo:G},te(()=>{if(!J||!w)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&&oo.has(r.tagName.toUpperCase())?null:n}(e);if(!t)return;const n=Z.current;("undo"===t?n.canUndo:n.canRedo)&&(e.preventDefault(),"undo"===t?n.undo():n.redo())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[J,w]);const Q=ce(()=>({register:b,unregister:x,record:R,undo:W,redo:K,clear:X,baseline:Y,canUndo:V,canRedo:G,enabled:w,hasState:c,handMounted:S,claimOwnMount:L,claimReadOnly:k,declaredEditable:p,claimEditable:E,undoLabel:V?o.past[o.past.length-1].label:null,redoLabel:G?o.future[0].label:null}),[b,x,R,W,K,X,Y,V,G,w,c,S,L,k,p,E,o.past,o.future]),re=""!==bn(),ie=_(M)?.footerOpen??!1,ae=re&&w&&c&&!S&&ie;/* @__PURE__ */
99
- return me(Fe.Provider,{value:Q,children:[ae&&/* @__PURE__ */pe(xn,{position:"left",quiet:!0,children:/* @__PURE__ */pe(He,{auto:!0})}),e]})}function lo(){const e=_(Fe),t=oe(()=>{},[]);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 co(e){const t=_(Fe),n=t?.claimReadOnly,r=t?.claimEditable;te(()=>{const t=e?r:n;if(t)return t(!0),()=>t(!1)},[n,r,e])}function uo(e,t,n){const r=_(Fe),o=ue(),i=ee(e),a=ee(t);a.current=t,te(()=>{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=ee(r);c.current=r;const u=ee({label:s,coalesceKey:l});u.current={label:s,coalesceKey:l},te(()=>{const t=c.current;t&&(Object.is(e,i.current)||(t.record(u.current.label,u.current.coalesceKey,{prev:i.current,next:e}),i.current=e))},[e])}function ho(e,t){const[n,r]=ne(e);return uo(n,e=>r(()=>e),t),[n,r]}export{kn as CancelButton,Le as DesktopHostProvider,ht as DocFavStar,et as EntityWindowFallback,Ze as EntityWindowLoading,tt as EntityWindowState,hn as MODAL_SUBMIT_SELECTOR,eo as Modal,xn as ModalActions,He as UndoControls,so as UndoProvider,Ce as WINDOW_REGISTRY,$e as WindowCrashedFallback,je as WindowErrorBoundary,It as WindowManagerProvider,gn as WindowTitle,gt as activateWindowById,Yt as beginWindowGesture,rr as cancelWindowFront,Ne as client_default,_r as commitExposeHighlight,nr as confirmWindowDiscard,Xt as drainPerfEvents,jr as exitExposeMode,Pn as forgetMaximizedWindowBoxes,xt as getActiveWindowRoute,Gr as getExposeHighlight,sn as getWindowChromeVersion,Dn as getWindowPosition,rt as isDraftEntityId,ot as isDraftEntityWindow,xe as isEntityEntry,be as isPageEntry,Me as isShellApiClientConfigured,Ve as isTabWindow,Ut as markMenuOpen,on as readWindowChrome,Qn as requestWindowFront,Jr as setExposeHighlight,Bt as setPerfCollecting,Pe as setShellHomeRoute,Ke as setShellTabStrip,Ee as setShellWindowRegistry,An as setWindowDefaultPosition,In as setWindowPosition,Zt as splitTitle,Vr as subscribeExposeHighlight,an as subscribeWindowChrome,Ge as tabGroupOf,$r as toggleExposeMode,Gn as useCurrentTabKey,Te as useDesktopHost,bn as useEnclosingModalId,Ir as useIsActiveWindow,Ae as usePageSearch,lo as useUndo,co as useUndoCanEdit,uo as useUndoable,ho as useUndoableState,fn as useWidgetSettings,st as useWindowDirty,ct as useWindowManager,yn as useWindowMenuItem,vn as useWindowTitle,tr as windowHoldsChanges};