efficient-shell 4.148.0 → 4.149.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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import{subscribePomo as e,getPomoSnapshot as t}from"./chunk-MU5H2CDL.js";export{setShellTodoProvider}from"./chunk-MU5H2CDL.js";export{ImageAnnotator_default as ImageAnnotator}from"./chunk-L7TEFXIS.js";import{PREVIEW_OPENED_EVENT as r,openPreviewFile as n}from"./chunk-4FS742BM.js";import{formatDate as o,Markdown as a,useTheme as l,GlobalSearch as i,resolveTheme as s,useClickOutside as c,ListLoadError as d,Checkbox_default as u,ListFooter as m,copyToClipboard as h,firstEnabledIndex as p,FormField as g,Input_default as f,applyThemePrefs as y,selectionAt as b,lastEnabledIndex as x,nextEnabledIndex as w,matchTypeahead as v}from"./chunk-ADTQ55CV.js";export{APP_UPDATE_POLL_MS,Accordion,AppUpdateBanner,AttachButton,AttachmentDropZone,AttachmentList,AuthScreen,Avatar,AvatarGroup,Banner,BarChart,BoxPlotChart,BrandAssetEditor,BudgetBar,CHART_INK,Calendar,CandlestickChart,Card,CartesianPlot,ChartBrush,ChartDefs,ChartDot,ChartFrame,ChartHighlightProvider,ChartSkeleton,ChartTooltip,ChatTemplate,Checkbox_default as Checkbox,CheckoutTemplate,ChordChart,ColoredBadge,ColumnChart,ComposerAttachments,ContainerFillChart,CountBadge,DAY_MS,DashboardTemplate,DataTable,DataTablePage,DatePicker_default as DatePicker,DateRangePicker,DateTimePicker_default as DateTimePicker,DescriptionList,Divider,DonutChart,Drawer,DropdownMenu,EmailTemplate,EmptyState,ErrorBoundary,ErrorPage,FilePicker_default as FilePicker,FormErrorSummary,FormField,FormLayoutPage,FunnelChart,GROUP_COLORS,GROUP_COLORS_SOLID,GalleryTemplate,GlobalSearch,Grid,HeatmapChart,HelpCenter,HistogramChart,INPUT_BASE,INPUT_SIZES,IconButton_default as IconButton,Inline,Input_default as Input,InputNumber_default as InputNumber,Kanban,Label,LineChart,ListFooter,ListLoadError,MAX_FRACTION_DIGITS,MENU_MAX_HEIGHT,MOTION,Markdown,Markdown as MarkdownLite,MediaUploadField,MediaUploadGrid,Meter,MetricBar,MilestoneTimeline,NativeSelect,NumericKeypad,POPUP_MAX_WIDTH,POST_PRODUCTION_STATUSES,PageHeader,Pagination,PaperclipGlyph,Paragraph,PieChart,Popover,PortalBrandingProvider,ProductionTimeline,RADAR_SERIES_CAP,RadarChart,RadialBarChart,Radio_default as Radio,RadioGroup,RangeChart,RankedBars,SCATTER_SERIES_CAP,SERIES_SLOT_COUNT,SERIES_VARS,STAGES,STATUS_VARS,SankeyChart,ScatterChart,SearchableSelect,Segmented,Select_default as Select,SettingRow,SidebarActionButton,SidebarGroupLabel,SidebarNavItem,Skeleton,Snippet,Sparkline,Stack,StatCard,StatTile,Statistic,StatusBadge,StatusBadgeProvider,Stepper,SunburstChart,Switch_default as Switch,Tabs,TagInput,Text,Textarea_default as Textarea,TileButton_default as TileButton,TimePicker_default as TimePicker,TimeSeriesChart,TimelineTrack,Title,Tooltip,TopNav,TreemapChart,WaterfallChart,angleScale,appendKey,applyThemePrefs,arcPath,areaBetween,areaFrom,autoHighlightIndex,backspace,bandScale,binValues,budgetState,bumpPath,calcOverall,calcReportOverall,copyToClipboard,curvePath,dashFor,fillFor,fillId,firstDayOfWeek,fmtSliderDate,formatDate,fromKey as fromDateKey,glowId,groundId,groupColors,highlightOpacity,inputClasses,isSeverityTone,ladderScale,linearPath,linearScale,logScale,maskId,mediaFileName,monotonePath,niceMax,polygonPoints,popupBounds,radiusScale,resolvePortalBrandAsset,resolveSeriesColor,resolveTheme,seriesColor,severityOf,splinePath,squarify,stagger,stepPath,tabButtonId,tabPanelId,toKey as toDateKey,toDayMs,toISODate,useAppUpdate,useClickOutside,useDropdownPosition,useHighlight,usePlotWidth,usePortalBranding,useProductionTimeline,useTheme}from"./chunk-ADTQ55CV.js";export{Breadcrumbs}from"./chunk-I55UMU3R.js";import{SidebarLayout as k}from"./chunk-SLCR26NK.js";export{SidebarLayout}from"./chunk-SLCR26NK.js";import{playNotification as N,playStartup as C,soundsEnabled as M,getSoundConfig as S,SOUND_PACK_KEYS as _,SOUND_PACKS as L,SOUND_TYPES as E,SOUND_TYPE_LABELS as P,setSoundForType as T,previewSound as $,setAllSounds as I,playLogout as D}from"./chunk-BUTSU7FO.js";import{useAuth as A}from"./chunk-LVDRBRYU.js";export{setShellAuthBridge}from"./chunk-LVDRBRYU.js";import{BrandMark as j}from"./chunk-OCSOMMY2.js";export{BrandMark,resolveBrandMarkTreatment}from"./chunk-OCSOMMY2.js";import{withSpareRow as B,EditableGrid as R}from"./chunk-TFKB2WEB.js";export{EditableGrid}from"./chunk-TFKB2WEB.js";import{escapeHtml as W}from"./chunk-BR22X7E5.js";import{publishDesktopFolders as F,requestFilesTrashView as z,FolderGlyph as O,requestFilesDesktopFolderView as H,FileIconTile as V}from"./chunk-NPJH5MD7.js";import{setPdfPreview as K}from"./chunk-ESL5TDNA.js";import{toast_default as U}from"./chunk-KKOHUQPF.js";export{toast_default as toast}from"./chunk-KKOHUQPF.js";import"./chunk-VTVSMRFX.js";import{APP_VERSION as X,VERSION as Y}from"./chunk-VUXPSUWI.js";export{VERSION}from"./chunk-VUXPSUWI.js";import{cancelWindowFront as q,requestWindowFront as G,useWindowManager as J,WINDOW_REGISTRY as Q,isPageEntry as Z,Modal as ee,setPerfCollecting as te,drainPerfEvents as re,markMenuOpen as ne,SIDEBAR_STRIP_W as oe,forgetMaximizedWindowBoxes as ae,ModalActions as le,useModalActive as ie,LoadingSpinner as se,useEnclosingModalId as ce,client_default as de,isDraftEntityId as ue,isShellApiClientConfigured as me,CancelButton as he,setWindowPosition as pe,isDraftEntityWindow as ge}from"./chunk-ET5HXDOR.js";export{CancelButton,CopyButton,DocFavStar,EntityWindowFallback,EntityWindowLoading,EntityWindowState,MODAL_SUBMIT_SELECTOR,Modal,ModalActions,UndoControls,UndoProvider,WindowCrashedFallback,WindowErrorBoundary,WindowManagerProvider,WindowTitle,beginWindowGesture,commitExposeHighlight,exitExposeMode,getActiveWindowRoute,getExposeHighlight,getWindowPosition,isEntityEntry,isPageEntry,markMenuOpen,requestWindowFront,setExposeHighlight,setShellApiClient,setShellWindowRegistry,setWindowDefaultPosition,setWindowPosition,subscribeExposeHighlight,toggleExposeMode,useEnclosingModalId,useIsActiveWindow,useModalActive,useUndo,useUndoCanEdit,useUndoable,useUndoableState,useWidgetSettings,useWindowDirty,useWindowManager,useWindowMenuItem,useWindowTitle}from"./chunk-ET5HXDOR.js";import{CMD_K as fe,CMD_DOT as ye,SHIFT as be,MOD as xe,ENTER as we,CMD_A as ve,ALT_SHIFT_N as ke,ALT_SHIFT_E as Ne,CMD_ENTER as Ce,CMD_S as Me,ALT_SHIFT_D as Se,CMD_Z as _e,CMD_SHIFT_Z as Le,useShellPrefs as Ee,useIsMobile as Pe,useShellPrefsAdapter as Te}from"./chunk-V453E4KU.js";export{ALT,ALT_SHIFT_D,ALT_SHIFT_E,ALT_SHIFT_N,CMD_A,CMD_DOT,CMD_ENTER,CMD_K,CMD_S,ENTER,Kbd,LoadingSpinner,MOD,NEXT_CHUNK_PATH_PREFIX,Result,SHIFT,STALE_CHUNK_RELOAD_COOLDOWN_MS,STALE_CHUNK_RELOAD_KEY,ShellPrefsProvider,VITE_PRELOAD_ERROR_EVENT,installStaleChunkReload,isMac,isStaleChunkError,useIsMobile,useLocalStoragePrefs,useShellPrefs}from"./chunk-V453E4KU.js";import{startMenuCategories as $e,navVisible as Ie,navSections as De,isSection as Ae,navIcons as je,isReachable as Be,sectionIcons as Re,useShellAuth as We,visibleChildren as Fe}from"./chunk-UB4JIOLD.js";export{ShellAuthProvider,setShellNavIcons,useShellAuth}from"./chunk-UB4JIOLD.js";import{useFileIntake as ze,FileIntakeAlert as Oe}from"./chunk-UB22J6EF.js";export{FileIntakeAlert,acceptsFile,useFileIntake}from"./chunk-UB22J6EF.js";import{Button_default as He}from"./chunk-PH3PRIFP.js";export{Button_default as Button,buttonClasses,iconButtonClasses}from"./chunk-PH3PRIFP.js";import{PopupMenu as Ve,PopupMenuDivider as Ke,PopupMenuLabel as Ue,PopupMenuItem as Xe,resolveMenuLevels as Ye,keepsNativeMenu as qe,describeContextTarget as Ge,MenuIcon as Je,openMenuLevel as Qe,closeMenuBelow as Ze,clampMenuTop as et,menuPanelLeft as tt}from"./chunk-ZBIWNVJS.js";export{NATIVE_MENU_ATTR,PopupMenu,PopupMenuDivider,PopupMenuItem,PopupMenuLabel,PopupSubmenu,describeContextTarget,keepsNativeMenu}from"./chunk-ZBIWNVJS.js";import{useDismissPopupsOnOpen as rt,Z_LAYERS as nt,registerModalEscapeInterceptor as ot,onOverlayOpen as at}from"./chunk-QOXIUJTN.js";export{ConfirmProvider,Dialog,OVERLAY_OPEN_EVENT,Z_LAYERS,confirm,confirmDestructive,dismissPopups,prompt,registerModalEscapeInterceptor,useConfirm,useFocusTrap,useScrollLock}from"./chunk-QOXIUJTN.js";import{GLASS_INPUT_BG as lt,glassStyle as it}from"./chunk-57MIENLJ.js";export{GLASS_DIVIDER,GLASS_INPUT_BG,glassStyle}from"./chunk-57MIENLJ.js";import"./chunk-MAIHBBWT.js";import{useShellStrings as st}from"./chunk-TR6PLN7W.js";export{DEFAULT_SHELL_STRINGS,ShellStringsProvider,useShellLocale,useShellStrings}from"./chunk-TR6PLN7W.js";import"./chunk-D65T4H6J.js";import{createContext as ct,lazy as dt,useSyncExternalStore as ut,useState as mt,useEffect as ht,useRef as pt,useCallback as gt,useLayoutEffect as ft,useMemo as yt,useContext as bt,isValidElement as xt,cloneElement as wt,Suspense as vt,useId as kt}from"react";import{Dialog as Nt,DialogBackdrop as Ct,DialogPanel as Mt}from"@headlessui/react";import{jsxs as St,jsx as _t,Fragment as Lt}from"react/jsx-runtime";import{createPortal as Et}from"react-dom";import{useQueryClient as Pt,useQuery as Tt,useInfiniteQuery as $t,QueryClientContext as It,QueryClient as Dt}from"@tanstack/react-query";import"react-router-dom";import{XMarkIcon as At}from"@heroicons/react/20/solid";function jt(...e){return Object.assign({},...e)}function Bt(e){let t=null,r=0;const n=/* @__PURE__ */new Set,o=()=>{n.forEach(e=>e())};return{windowKey:e,set(n,a){if(null===n)return t=null,q(e),void o();t={...n,nav:++r},o(),!1!==a?.raise&&G(e)},get:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function Rt(e){return ut(e.subscribe,e.get,e.get)}var Wt=[{title:"Global",shortcuts:[{keys:fe,description:"Search"},{keys:ye,description:"Toggle sidebar"},{keys:"Ctrl F11",description:"Toggle fullscreen"},{keys:"ESC",description:"Exit fullscreen (when no windows open)"},{keys:"?",description:"Show keyboard shortcuts"}]},{title:"Windows (title bar focused)",shortcuts:[{keys:"←↑→↓",description:"Move window"},{keys:`${be} Arrows`,description:"Resize window"},{keys:`${xe} ←/→`,description:"Snap to left / right half"},{keys:`${xe} ↑`,description:"Maximize"},{keys:`${xe} ↓`,description:"Restore / minimize"},{keys:we,description:"Toggle maximize"}]},{title:"Lists",shortcuts:[{keys:"J / ↓",description:"Next row"},{keys:"K / ↑",description:"Previous row"},{keys:"⏎",description:"Open selected row"},{keys:"⇧J / ⇧K",description:"Move and select"},{keys:"⇧ Click",description:"Range select"},{keys:"Space",description:"Toggle row checkbox"},{keys:ve,description:"Select / deselect all"},{keys:ke,description:"Create new item"},{keys:Ne,description:"Edit selected item"}]},{title:"Modals / Forms",shortcuts:[{keys:Ce,description:"Submit"},{keys:Me,description:"Save"},{keys:Se,description:"Save as new (duplicate)"},{keys:_e,description:"Undo the last change to the form"},{keys:Le,description:"Redo it"},{keys:"ESC",description:"Close modal"}]}];function Ft(){const[e,t]=mt(!1);return ht(()=>{const e=()=>t(e=>!e);return document.addEventListener("toggle-shortcut-help",e),()=>document.removeEventListener("toggle-shortcut-help",e)},[]),ht(()=>{const e=e=>{if("?"===e.key&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const r=e.target?.tagName;if("INPUT"===r||"TEXTAREA"===r||"SELECT"===r)return;if(e.target?.isContentEditable)return;e.preventDefault(),t(e=>!e)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),rt(e),/* @__PURE__ */St(Nt,{open:e,onClose:()=>t(!1),className:"relative",style:{zIndex:nt.overlay},children:[
2
+ import{subscribePomo as e,getPomoSnapshot as t}from"./chunk-MU5H2CDL.js";export{setShellTodoProvider}from"./chunk-MU5H2CDL.js";export{ImageAnnotator_default as ImageAnnotator}from"./chunk-L7TEFXIS.js";import{PREVIEW_OPENED_EVENT as r,openPreviewFile as n}from"./chunk-4FS742BM.js";import{formatDate as o,Markdown as a,useTheme as l,GlobalSearch as i,resolveTheme as s,useClickOutside as c,ListLoadError as d,Checkbox_default as u,ListFooter as m,copyToClipboard as h,firstEnabledIndex as p,FormField as g,Input_default as f,applyThemePrefs as y,selectionAt as b,lastEnabledIndex as x,nextEnabledIndex as w,matchTypeahead as v}from"./chunk-IH3W7GR5.js";export{APP_UPDATE_POLL_MS,Accordion,AppUpdateBanner,AttachButton,AttachmentDropZone,AttachmentList,AuthScreen,Avatar,AvatarGroup,Banner,BarChart,BoxPlotChart,BrandAssetEditor,BudgetBar,CHART_INK,Calendar,CandlestickChart,Card,CartesianPlot,ChartBrush,ChartDefs,ChartDot,ChartFrame,ChartHighlightProvider,ChartSkeleton,ChartTooltip,ChatTemplate,Checkbox_default as Checkbox,CheckoutTemplate,ChordChart,ColoredBadge,ColumnChart,ComposerAttachments,ContainerFillChart,CountBadge,DAY_MS,DashboardTemplate,DataTable,DataTablePage,DatePicker_default as DatePicker,DateRangePicker,DateTimePicker_default as DateTimePicker,DescriptionList,Divider,DonutChart,Drawer,DropdownMenu,EmailTemplate,EmptyState,ErrorBoundary,ErrorPage,FilePicker_default as FilePicker,FormErrorSummary,FormField,FormLayoutPage,FunnelChart,GROUP_COLORS,GROUP_COLORS_SOLID,GalleryTemplate,GlobalSearch,Grid,HeatmapChart,HelpCenter,HistogramChart,INPUT_BASE,INPUT_SIZES,IconButton_default as IconButton,Inline,Input_default as Input,InputNumber_default as InputNumber,Kanban,Label,LineChart,ListFooter,ListLoadError,MAX_FRACTION_DIGITS,MENU_MAX_HEIGHT,MOTION,Markdown,Markdown as MarkdownLite,MediaUploadField,MediaUploadGrid,Meter,MetricBar,MilestoneTimeline,NativeSelect,NumericKeypad,POPUP_MAX_WIDTH,POST_PRODUCTION_STATUSES,PageHeader,Pagination,PaperclipGlyph,Paragraph,PieChart,Popover,PortalBrandingProvider,ProductionTimeline,RADAR_SERIES_CAP,RadarChart,RadialBarChart,Radio_default as Radio,RadioGroup,RangeChart,RankedBars,SCATTER_SERIES_CAP,SERIES_SLOT_COUNT,SERIES_VARS,STAGES,STATUS_VARS,SankeyChart,ScatterChart,SearchableSelect,Segmented,Select_default as Select,SettingRow,SidebarActionButton,SidebarGroupLabel,SidebarNavItem,Skeleton,Snippet,Sparkline,Stack,StatCard,StatTile,Statistic,StatusBadge,StatusBadgeProvider,Stepper,SunburstChart,Switch_default as Switch,Tabs,TagInput,Text,Textarea_default as Textarea,TileButton_default as TileButton,TimePicker_default as TimePicker,TimeSeriesChart,TimelineTrack,Title,Tooltip,TopNav,TreemapChart,WaterfallChart,angleScale,appendKey,applyThemePrefs,arcPath,areaBetween,areaFrom,autoHighlightIndex,backspace,bandScale,binValues,budgetState,bumpPath,calcOverall,calcReportOverall,copyToClipboard,curvePath,dashFor,fillFor,fillId,firstDayOfWeek,fmtSliderDate,formatDate,fromKey as fromDateKey,glowId,groundId,groupColors,highlightOpacity,inputClasses,isSeverityTone,ladderScale,linearPath,linearScale,logScale,maskId,mediaFileName,monotonePath,niceMax,polygonPoints,popupBounds,radiusScale,resolvePortalBrandAsset,resolveSeriesColor,resolveTheme,seriesColor,severityOf,splinePath,squarify,stagger,stepPath,tabButtonId,tabPanelId,toKey as toDateKey,toDayMs,toISODate,useAppUpdate,useClickOutside,useDropdownPosition,useHighlight,usePlotWidth,usePortalBranding,useProductionTimeline,useTheme}from"./chunk-IH3W7GR5.js";export{Breadcrumbs}from"./chunk-I55UMU3R.js";import{SidebarLayout as k}from"./chunk-SLCR26NK.js";export{SidebarLayout}from"./chunk-SLCR26NK.js";import{playNotification as N,playStartup as C,soundsEnabled as M,getSoundConfig as S,SOUND_PACK_KEYS as _,SOUND_PACKS as L,SOUND_TYPES as E,SOUND_TYPE_LABELS as P,setSoundForType as T,previewSound as $,setAllSounds as I,playLogout as D}from"./chunk-BUTSU7FO.js";import{useAuth as A}from"./chunk-LVDRBRYU.js";export{setShellAuthBridge}from"./chunk-LVDRBRYU.js";import{BrandMark as j}from"./chunk-OCSOMMY2.js";export{BrandMark,resolveBrandMarkTreatment}from"./chunk-OCSOMMY2.js";import{withSpareRow as R,EditableGrid as B}from"./chunk-TFKB2WEB.js";export{EditableGrid}from"./chunk-TFKB2WEB.js";import{escapeHtml as W}from"./chunk-BR22X7E5.js";import{publishDesktopFolders as F,requestFilesTrashView as z,FolderGlyph as O,requestFilesDesktopFolderView as H,FileIconTile as V}from"./chunk-NPJH5MD7.js";import{setPdfPreview as K}from"./chunk-ESL5TDNA.js";import{toast_default as U}from"./chunk-KKOHUQPF.js";export{toast_default as toast}from"./chunk-KKOHUQPF.js";import"./chunk-VTVSMRFX.js";import{APP_VERSION as X,VERSION as Y}from"./chunk-2Q3T5CT3.js";export{VERSION}from"./chunk-2Q3T5CT3.js";import{cancelWindowFront as q,requestWindowFront as G,useWindowManager as J,WINDOW_REGISTRY as Q,isPageEntry as Z,Modal as ee,setPerfCollecting as te,drainPerfEvents as re,markMenuOpen as ne,SIDEBAR_STRIP_W as oe,forgetMaximizedWindowBoxes as ae,ModalActions as le,useModalActive as ie,LoadingSpinner as se,useEnclosingModalId as ce,client_default as de,isDraftEntityId as ue,isShellApiClientConfigured as me,CancelButton as he,setWindowPosition as pe,isDraftEntityWindow as ge}from"./chunk-ET5HXDOR.js";export{CancelButton,CopyButton,DocFavStar,EntityWindowFallback,EntityWindowLoading,EntityWindowState,MODAL_SUBMIT_SELECTOR,Modal,ModalActions,UndoControls,UndoProvider,WindowCrashedFallback,WindowErrorBoundary,WindowManagerProvider,WindowTitle,beginWindowGesture,commitExposeHighlight,exitExposeMode,getActiveWindowRoute,getExposeHighlight,getWindowPosition,isEntityEntry,isPageEntry,markMenuOpen,requestWindowFront,setExposeHighlight,setShellApiClient,setShellWindowRegistry,setWindowDefaultPosition,setWindowPosition,subscribeExposeHighlight,toggleExposeMode,useEnclosingModalId,useIsActiveWindow,useModalActive,useUndo,useUndoCanEdit,useUndoable,useUndoableState,useWidgetSettings,useWindowDirty,useWindowManager,useWindowMenuItem,useWindowTitle}from"./chunk-ET5HXDOR.js";import{CMD_K as fe,CMD_DOT as ye,SHIFT as be,MOD as xe,ENTER as we,CMD_A as ve,ALT_SHIFT_N as ke,ALT_SHIFT_E as Ne,CMD_ENTER as Ce,CMD_S as Me,ALT_SHIFT_D as Se,CMD_Z as _e,CMD_SHIFT_Z as Le,useShellPrefs as Ee,useIsMobile as Pe,useShellPrefsAdapter as Te}from"./chunk-V453E4KU.js";export{ALT,ALT_SHIFT_D,ALT_SHIFT_E,ALT_SHIFT_N,CMD_A,CMD_DOT,CMD_ENTER,CMD_K,CMD_S,ENTER,Kbd,LoadingSpinner,MOD,NEXT_CHUNK_PATH_PREFIX,Result,SHIFT,STALE_CHUNK_RELOAD_COOLDOWN_MS,STALE_CHUNK_RELOAD_KEY,ShellPrefsProvider,VITE_PRELOAD_ERROR_EVENT,installStaleChunkReload,isMac,isStaleChunkError,useIsMobile,useLocalStoragePrefs,useShellPrefs}from"./chunk-V453E4KU.js";import{startMenuCategories as $e,navVisible as Ie,navSections as De,isSection as Ae,navIcons as je,isReachable as Re,sectionIcons as Be,useShellAuth as We,visibleChildren as Fe}from"./chunk-UB4JIOLD.js";export{ShellAuthProvider,setShellNavIcons,useShellAuth}from"./chunk-UB4JIOLD.js";import{useFileIntake as ze,FileIntakeAlert as Oe}from"./chunk-UB22J6EF.js";export{FileIntakeAlert,acceptsFile,useFileIntake}from"./chunk-UB22J6EF.js";import{Button_default as He}from"./chunk-PH3PRIFP.js";export{Button_default as Button,buttonClasses,iconButtonClasses}from"./chunk-PH3PRIFP.js";import{PopupMenu as Ve,PopupMenuDivider as Ke,PopupMenuLabel as Ue,PopupMenuItem as Xe,resolveMenuLevels as Ye,keepsNativeMenu as qe,describeContextTarget as Ge,MenuIcon as Je,openMenuLevel as Qe,closeMenuBelow as Ze,clampMenuTop as et,menuPanelLeft as tt}from"./chunk-ZBIWNVJS.js";export{NATIVE_MENU_ATTR,PopupMenu,PopupMenuDivider,PopupMenuItem,PopupMenuLabel,PopupSubmenu,describeContextTarget,keepsNativeMenu}from"./chunk-ZBIWNVJS.js";import{useDismissPopupsOnOpen as rt,Z_LAYERS as nt,registerModalEscapeInterceptor as ot,onOverlayOpen as at}from"./chunk-QOXIUJTN.js";export{ConfirmProvider,Dialog,OVERLAY_OPEN_EVENT,Z_LAYERS,confirm,confirmDestructive,dismissPopups,prompt,registerModalEscapeInterceptor,useConfirm,useFocusTrap,useScrollLock}from"./chunk-QOXIUJTN.js";import{GLASS_INPUT_BG as lt,glassStyle as it}from"./chunk-57MIENLJ.js";export{GLASS_DIVIDER,GLASS_INPUT_BG,glassStyle}from"./chunk-57MIENLJ.js";import"./chunk-MAIHBBWT.js";import{useShellStrings as st}from"./chunk-TR6PLN7W.js";export{DEFAULT_SHELL_STRINGS,ShellStringsProvider,useShellLocale,useShellStrings}from"./chunk-TR6PLN7W.js";import"./chunk-D65T4H6J.js";import{createContext as ct,lazy as dt,useSyncExternalStore as ut,useState as mt,useEffect as ht,useRef as pt,useCallback as gt,useLayoutEffect as ft,useMemo as yt,useContext as bt,isValidElement as xt,cloneElement as wt,Suspense as vt,useId as kt}from"react";import{Dialog as Nt,DialogBackdrop as Ct,DialogPanel as Mt}from"@headlessui/react";import{jsxs as St,jsx as _t,Fragment as Lt}from"react/jsx-runtime";import{createPortal as Et}from"react-dom";import{useQueryClient as Pt,useQuery as Tt,useInfiniteQuery as $t,QueryClientContext as It,QueryClient as Dt}from"@tanstack/react-query";import"react-router-dom";import{XMarkIcon as At}from"@heroicons/react/20/solid";function jt(...e){return Object.assign({},...e)}function Rt(e){let t=null,r=0;const n=/* @__PURE__ */new Set,o=()=>{n.forEach(e=>e())};return{windowKey:e,set(n,a){if(null===n)return t=null,q(e),void o();t={...n,nav:++r},o(),!1!==a?.raise&&G(e)},get:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function Bt(e){return ut(e.subscribe,e.get,e.get)}var Wt=[{title:"Global",shortcuts:[{keys:fe,description:"Search"},{keys:ye,description:"Toggle sidebar"},{keys:"Ctrl F11",description:"Toggle fullscreen"},{keys:"ESC",description:"Exit fullscreen (when no windows open)"},{keys:"?",description:"Show keyboard shortcuts"}]},{title:"Windows (title bar focused)",shortcuts:[{keys:"←↑→↓",description:"Move window"},{keys:`${be} Arrows`,description:"Resize window"},{keys:`${xe} ←/→`,description:"Snap to left / right half"},{keys:`${xe} ↑`,description:"Maximize"},{keys:`${xe} ↓`,description:"Restore / minimize"},{keys:we,description:"Toggle maximize"}]},{title:"Lists",shortcuts:[{keys:"J / ↓",description:"Next row"},{keys:"K / ↑",description:"Previous row"},{keys:"⏎",description:"Open selected row"},{keys:"⇧J / ⇧K",description:"Move and select"},{keys:"⇧ Click",description:"Range select"},{keys:"Space",description:"Toggle row checkbox"},{keys:ve,description:"Select / deselect all"},{keys:ke,description:"Create new item"},{keys:Ne,description:"Edit selected item"}]},{title:"Modals / Forms",shortcuts:[{keys:Ce,description:"Submit"},{keys:Me,description:"Save"},{keys:Se,description:"Save as new (duplicate)"},{keys:_e,description:"Undo the last change to the form"},{keys:Le,description:"Redo it"},{keys:"ESC",description:"Close modal"}]}];function Ft(){const[e,t]=mt(!1);return ht(()=>{const e=()=>t(e=>!e);return document.addEventListener("toggle-shortcut-help",e),()=>document.removeEventListener("toggle-shortcut-help",e)},[]),ht(()=>{const e=e=>{if("?"===e.key&&!e.metaKey&&!e.ctrlKey&&!e.altKey){const r=e.target?.tagName;if("INPUT"===r||"TEXTAREA"===r||"SELECT"===r)return;if(e.target?.isContentEditable)return;e.preventDefault(),t(e=>!e)}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),rt(e),/* @__PURE__ */St(Nt,{open:e,onClose:()=>t(!1),className:"relative",style:{zIndex:nt.overlay},children:[
3
3
  /* @__PURE__ */_t(Ct,{className:"fixed inset-0 bg-black/30 transition-opacity"}),
4
4
  /* @__PURE__ */_t("div",{className:"fixed inset-0 flex items-center justify-center p-6",children:/* @__PURE__ */St(Mt,{className:"w-full max-w-md rounded-lg bg-white shadow-xl",children:[
5
5
  /* @__PURE__ */St("div",{className:"flex items-center justify-between px-5 pt-5 pb-3 border-b border-gray-200",children:[
@@ -81,7 +81,7 @@ return St("button",{onClick:()=>m(e),title:n?`Remove ${t} from desktop`:`Add ${t
81
81
  /* @__PURE__ */_t("span",{className:"shrink-0 inline-flex items-center justify-center h-6 w-6 rounded-full border transition-colors "+(n?"border-blue-500 bg-blue-500 text-white group-hover:border-red-400 group-hover:bg-red-400":"border-gray-300 text-gray-400 group-hover:border-blue-400 group-hover:text-blue-500"),children:n?/* @__PURE__ */St(Lt,{children:[
82
82
  /* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5 group-hover:hidden",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),
83
83
  /* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5 hidden group-hover:block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})]}):/* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})})})]},e)})})}),
84
- /* @__PURE__ */_t("p",{className:"shrink-0 pt-3 mt-1 border-t border-gray-100 text-[11px] text-gray-400 leading-relaxed",children:"Drag a widget anywhere on the desktop to reposition it. Right-click a widget for its appearance settings."})]})})}var nr=50,or=20,ar={kind:"cpu",label:"CPU-bound (JavaScript)",detail:"The main thread is blocked. Rendering settings will not help — this is script or data work."};function lr(e){if(e.length<2)return{fps:0,frameMs:0,worstMs:0};let t=0;for(let r=1;r<e.length;r++){const n=e[r]-e[r-1];n>t&&(t=n)}const r=e[e.length-1]-e[0];if(r<=0)return{fps:0,frameMs:0,worstMs:0};const n=e.length-1;return{fps:n/r*1e3,frameMs:r/n,worstMs:t}}function ir(e){const{fps:t,blockedPct:r}=e,n=null!==r&&r>=20;return!Number.isFinite(t)||t<=0?n?ar:{kind:"unknown",label:"Measuring…",detail:"Collecting frame timings."}:t>=50?{kind:"smooth",label:"Smooth",detail:"Frames are landing on time. No rendering bottleneck here."}:null===r?{kind:"unknown",label:"Janky — cause unknown",detail:"This browser reports no long-task timing, so GPU and JS cannot be told apart. Try Chrome or Edge."}:n?ar:{kind:"gpu",label:"GPU-bound (compositing)",detail:"Frames are late while the main thread sits idle. Try Preferences → Customization → Reduce transparency."}}var sr=[{kind:"submenu",test:e=>e.submenus>0},{kind:"menu",test:e=>e.menus>0},{kind:"resize",test:e=>e.resizeMs>0},{kind:"move",test:e=>e.moveMs>0},{kind:"scroll",test:e=>e.scrolls>0},{kind:"type",test:e=>e.keys>0},{kind:"click",test:e=>e.clicks>0||e.dragMs>0}];function cr(e){return sr.find(t=>t.test(e))?.kind??"idle"}var dr=2400,ur=4,mr=2;function hr(e,t,r=2400){const n=e.length>=r?e.slice(e.length-r+1):e.slice();return n.push(t),n}function pr(e){return"idle"!==cr(e)}function gr(e){if(!e.length)return 0;const t=e.slice().sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function fr(e){const t=e.filter(e=>e.fps>0);return{samples:e.length,medianFps:gr(t.map(e=>e.fps)),worstMs:e.reduce((e,t)=>t.worstMs>e?t.worstMs:e,0),stalls:e.length-t.length}}function yr(e,t){const r=/* @__PURE__ */new Map;for(const n of e){const e=t(n);if(null===e)continue;const o=r.get(e);o?o.push(n):r.set(e,[n])}return r}function br(e){return e.sort((e,t)=>e.medianFps-t.medianFps)}function xr(e){const t={samples:0,durationMs:0,medianFps:0,worstFrameMs:0,verdictShare:{smooth:0,gpu:0,cpu:0,unknown:0},interacting:null,idle:null,byActivity:[],byWindowCount:[],worstWindows:[],worstMenus:[]};if(!e.length)return t;const r={...t.verdictShare};for(const t of e)r[t.verdict]+=1/e.length;const n=e.filter(pr),o=e.filter(e=>!pr(e));return{samples:e.length,durationMs:e[e.length-1].t-e[0].t,medianFps:gr(e.filter(e=>e.fps>0).map(e=>e.fps)),worstFrameMs:e.reduce((e,t)=>t.worstMs>e?t.worstMs:e,0),verdictShare:r,interacting:n.length>=4?fr(n):null,idle:o.length>=4?fr(o):null,byActivity:br([...yr(e,cr).entries()].filter(([,e])=>e.length>=2).map(([e,t])=>({kind:e,...fr(t)}))),byWindowCount:[...yr(e,e=>e.windows).entries()].filter(([,e])=>e.length>=4).map(([e,t])=>({windows:e,...fr(t)})).sort((e,t)=>e.windows-t.windows),worstWindows:br([...yr(e,e=>e.active).entries()].filter(([,e])=>e.length>=4).map(([e,t])=>({key:e,...fr(t)}))),worstMenus:br([...yr(e,e=>e.menuKey).entries()].filter(([,e])=>e.length>=2).map(([e,t])=>({key:e,...fr(t)})))}}var wr=["t","fps","frameMs","worstMs","blockedPct","heapMB","verdict","windows","active","clicks","keys","scrolls","dragMs","menus","submenus","menuKey","moveMs","resizeMs"];function vr(e){return[wr.join(","),...e.map(e=>wr.map(t=>(e=>{if(null==e)return"";const t=String("number"==typeof e?Math.round(10*e)/10:e);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t})(e[t])).join(","))].join("\n")}function kr(e){if(!e?.length)return null;const t=e.filter(e=>!/not[^a-z]*a[^a-z]*brand/i.test(e.brand)),r=t.find(e=>"Chromium"!==e.brand)??t[0];return r?`${r.brand} ${r.version}`:null}function Nr(e){return"string"==typeof e&&e?e:null}async function Cr(){return{hints:await Mr(),battery:await Sr()}}async function Mr(){const e=navigator.userAgentData;if(!e)return null;const t={platform:e.platform??null,platformVersion:null,architecture:null,model:null,browser:kr(e.brands)};if(!e.getHighEntropyValues)return t;try{const r=await e.getHighEntropyValues(["platform","platformVersion","architecture","model","fullVersionList"]),n=r.fullVersionList;return{platform:Nr(r.platform)??t.platform,platformVersion:Nr(r.platformVersion),architecture:Nr(r.architecture),model:Nr(r.model),browser:kr(n)??t.browser}}catch{return t}}async function Sr(){const e=navigator.getBattery;if(!e)return null;try{const t=await e.call(navigator);return{charging:t.charging,level:t.level}}catch{return null}}function _r(e){try{return window.matchMedia(e).matches}catch{return!1}}function Lr(e){const t=navigator,r=performance.memory,n=e?.hints??null,o=function(){if("undefined"==typeof document)return{renderer:null,vendor:null,available:!1};try{const e=document.createElement("canvas").getContext("webgl");if(!e)return{renderer:null,vendor:null,available:!1};const t=e.getExtension("WEBGL_debug_renderer_info"),r=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),n=t?e.getParameter(t.UNMASKED_VENDOR_WEBGL):e.getParameter(e.VENDOR);return e.getExtension("WEBGL_lose_context")?.loseContext(),{renderer:Nr(r),vendor:Nr(n),available:!0}}catch{return{renderer:null,vendor:null,available:!1}}}(),a=t.connection;return{userAgent:t.userAgent,browser:n?.browser??null,platform:n?.platform??null,platformVersion:n?.platformVersion??null,architecture:n?.architecture??null,model:n?.model??null,cpuCores:"number"==typeof t.hardwareConcurrency?t.hardwareConcurrency:null,deviceMemoryGB:"number"==typeof t.deviceMemory?t.deviceMemory:null,gpu:o.renderer,gpuVendor:o.vendor,webglAvailable:o.available,screen:{width:screen.width,height:screen.height,dpr:window.devicePixelRatio,colorDepth:"number"==typeof screen.colorDepth?screen.colorDepth:null},viewport:{width:window.innerWidth,height:window.innerHeight},heapLimitMB:r?Math.round(r.jsHeapSizeLimit/1048576):null,network:a?{effectiveType:Nr(a.effectiveType),downlinkMbps:"number"==typeof a.downlink?a.downlink:null,rttMs:"number"==typeof a.rtt?a.rtt:null,saveData:!0===a.saveData}:null,battery:e?.battery??null,prefersReducedMotion:_r("(prefers-reduced-motion: reduce)"),forcedColors:_r("(forced-colors: active)"),reducedTransparency:document.documentElement.classList.contains("rosh-reduce-transparency"),touchPoints:"number"==typeof t.maxTouchPoints?t.maxTouchPoints:null}}function Er(e){const t=[];e.browser&&t.push(e.browser);const r=[e.platform,e.platformVersion].filter(Boolean).join(" ");return r&&t.push(e.architecture?`${r} (${e.architecture})`:r),e.gpu?t.push(e.gpu):e.webglAvailable||t.push("no WebGL (software rendering)"),e.cpuCores&&t.push(`${e.cpuCores} cores`),e.deviceMemoryGB&&t.push(`${e.deviceMemoryGB}GB+ RAM`),t.push(`${e.screen.width}×${e.screen.height} @${e.screen.dpr}x`),e.battery&&!e.battery.charging&&t.push(`on battery ${Math.round(100*e.battery.level)}%`),e.reducedTransparency&&t.push("reduce transparency on"),e.prefersReducedMotion&&t.push("reduced motion"),t.join(" · ")}var Pr={smooth:{dot:"bg-emerald-400",text:"text-emerald-300"},gpu:{dot:"bg-amber-400",text:"text-amber-300"},cpu:{dot:"bg-sky-400",text:"text-sky-300"},unknown:{dot:"bg-gray-400",text:"text-gray-300"}};function Tr({onClose:e,onSubmit:t,className:r=""}){const n=pt([]),o=pt(0),a=pt({clicks:0,keys:0,scrolls:0,dragMs:0}),l=pt({down:!1,since:0}),i=pt([]),s=pt(0),c=pt(0),d=pt(null),u=pt(null),[m,h]=mt(!1),[p,g]=mt({fps:0,frameMs:0,worstMs:0,blockedPct:null}),[f,y]=mt([]),[b,x]=mt(null),[w,v]=mt(0),[k,N]=mt(!1),[C,M]=mt(""),[S,_]=mt(!1),[L,E]=mt(null);ht(()=>(te(!0),()=>te(!1)),[]),ht(()=>{let e=!0;return Cr().then(t=>{e&&(u.current=t)}),()=>{e=!1}},[]),ht(()=>{let e=0;const t=r=>{const o=n.current;o.push(r);const a=r-1e3;for(;o.length&&o[0]<a;)o.shift();e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[]),ht(()=>{if("undefined"==typeof PerformanceObserver)return;let e;try{e=new PerformanceObserver(e=>{for(const t of e.getEntries())o.current+=t.duration}),e.observe({entryTypes:["longtask"]}),h(!0)}catch{return}return()=>e?.disconnect()},[]),ht(()=>{const e=()=>{a.current.clicks++,l.current={down:!0,since:performance.now()}},t=()=>{if(!l.current.down)return;const e=performance.now(),t=e-l.current.since;l.current.since=e,t<=100&&(a.current.dragMs+=t)},r=()=>{l.current.down=!1},n=()=>{a.current.keys++},o=()=>{a.current.scrolls++},i={capture:!0,passive:!0};return window.addEventListener("pointerdown",e,i),window.addEventListener("pointermove",t,i),window.addEventListener("pointerup",r,i),window.addEventListener("pointercancel",r,i),window.addEventListener("keydown",n,i),window.addEventListener("wheel",o,i),()=>{window.removeEventListener("pointerdown",e,i),window.removeEventListener("pointermove",t,i),window.removeEventListener("pointerup",r,i),window.removeEventListener("pointercancel",r,i),window.removeEventListener("keydown",n,i),window.removeEventListener("wheel",o,i)}},[]);const P=gt(()=>{try{localStorage.setItem("react-os-shell:perf-log",JSON.stringify(i.current))}catch{}},[]);ht(()=>{const e=()=>P();return window.addEventListener("pagehide",e),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("pagehide",e),document.removeEventListener("visibilitychange",e),P()}},[P]),ht(()=>{const e=setInterval(()=>{const e=performance.now();s.current||(s.current=e);const t=lr(n.current),r=m?Math.min(100,o.current/500*100):null;o.current=0;const l=performance.memory,d=l?l.usedJSHeapSize/1048576:null,u={...t,blockedPct:r},h=a.current,p=re(),{windows:f,active:b}=function(){if("undefined"==typeof document)return{windows:0,active:null};const e=document.querySelectorAll("[data-modal-panel]");let t=null,r=-1/0;return e.forEach(e=>{const n=parseInt(window.getComputedStyle(e).zIndex,10),o=Number.isFinite(n)?n:0;o>=r&&(r=o,t=e.dataset.windowKey??e.dataset.modalId??null)}),{windows:e.length,active:t}}();i.current=hr(i.current,{t:Math.round(e-s.current),...t,blockedPct:r,heapMB:d,verdict:ir(u).kind,windows:f,active:b,clicks:h.clicks,keys:h.keys,scrolls:h.scrolls,dragMs:Math.round(h.dragMs),menus:p.menus,submenus:p.submenus,menuKey:p.menuKey,moveMs:Math.round(p.moveMs),resizeMs:Math.round(p.resizeMs)}),h.clicks=0,h.keys=0,h.scrolls=0,h.dragMs=0,(!c.current||e-c.current>=1e4)&&(c.current=e,P()),g(u),y(e=>[...e,t.fps].slice(-40)),x(l?{usedMB:l.usedJSHeapSize/1048576,limitMB:l.jsHeapSizeLimit/1048576}:null),v(i.current.length)},500);return()=>clearInterval(e)},[m,P]);const T=gt(()=>{d.current=i.current.slice(),E(null),N(!0)},[]),$=ir(p),I=gt(()=>{const e=d.current??i.current,t=/* @__PURE__ */(new Date).toISOString().replace(/[:.]/g,"-").slice(0,19),r=xr(e),n=Lr(u.current);return{message:C,filename:`perf-log-${t}.json`,summary:r,environment:n,verdict:$.label,json:JSON.stringify({generatedAt:/* @__PURE__ */(new Date).toISOString(),message:C,verdict:$.label,environment:n,summary:r,records:e},null,2)}},[C,$.label]),D=gt(e=>{const t=URL.createObjectURL(new Blob([e.json],{type:"application/json"})),r=document.createElement("a");r.href=t,r.download=e.filename,r.click(),URL.revokeObjectURL(t)},[]),A=gt(async()=>{const e=I();_(!0),E(null);try{t?await t(e):D(e),d.current=null,M(""),N(!1)}catch(e){E(e instanceof Error&&e.message?e.message:"Could not send. Try again.")}finally{_(!1)}},[I,D,t]),j=Pr[$.kind],B=Math.max(60,...f),R=Math.round(500*w/1e3),W=t?"Send":"Download",F=d.current?.length??w;/* @__PURE__ */
84
+ /* @__PURE__ */_t("p",{className:"shrink-0 pt-3 mt-1 border-t border-gray-100 text-[11px] text-gray-400 leading-relaxed",children:"Drag a widget anywhere on the desktop to reposition it. Right-click a widget for its appearance settings."})]})})}var nr=50,or=20,ar={kind:"cpu",label:"CPU-bound (JavaScript)",detail:"The main thread is blocked. Rendering settings will not help — this is script or data work."};function lr(e){if(e.length<2)return{fps:0,frameMs:0,worstMs:0};let t=0;for(let r=1;r<e.length;r++){const n=e[r]-e[r-1];n>t&&(t=n)}const r=e[e.length-1]-e[0];if(r<=0)return{fps:0,frameMs:0,worstMs:0};const n=e.length-1;return{fps:n/r*1e3,frameMs:r/n,worstMs:t}}function ir(e){const{fps:t,blockedPct:r}=e,n=null!==r&&r>=20;return!Number.isFinite(t)||t<=0?n?ar:{kind:"unknown",label:"Measuring…",detail:"Collecting frame timings."}:t>=50?{kind:"smooth",label:"Smooth",detail:"Frames are landing on time. No rendering bottleneck here."}:null===r?{kind:"unknown",label:"Janky — cause unknown",detail:"This browser reports no long-task timing, so GPU and JS cannot be told apart. Try Chrome or Edge."}:n?ar:{kind:"gpu",label:"GPU-bound (compositing)",detail:"Frames are late while the main thread sits idle. Try Preferences → Customization → Reduce transparency."}}var sr=[{kind:"submenu",test:e=>e.submenus>0},{kind:"menu",test:e=>e.menus>0},{kind:"resize",test:e=>e.resizeMs>0},{kind:"move",test:e=>e.moveMs>0},{kind:"scroll",test:e=>e.scrolls>0},{kind:"type",test:e=>e.keys>0},{kind:"click",test:e=>e.clicks>0||e.dragMs>0}];function cr(e){return sr.find(t=>t.test(e))?.kind??"idle"}var dr=2400,ur=4,mr=2;function hr(e,t,r=2400){const n=e.length>=r?e.slice(e.length-r+1):e.slice();return n.push(t),n}function pr(e){return"idle"!==cr(e)}function gr(e){if(!e.length)return 0;const t=e.slice().sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function fr(e){const t=e.filter(e=>e.fps>0);return{samples:e.length,medianFps:gr(t.map(e=>e.fps)),worstMs:e.reduce((e,t)=>t.worstMs>e?t.worstMs:e,0),stalls:e.length-t.length}}function yr(e,t){const r=/* @__PURE__ */new Map;for(const n of e){const e=t(n);if(null===e)continue;const o=r.get(e);o?o.push(n):r.set(e,[n])}return r}function br(e){return e.sort((e,t)=>e.medianFps-t.medianFps)}function xr(e){const t={samples:0,durationMs:0,medianFps:0,worstFrameMs:0,verdictShare:{smooth:0,gpu:0,cpu:0,unknown:0},interacting:null,idle:null,byActivity:[],byWindowCount:[],worstWindows:[],worstMenus:[]};if(!e.length)return t;const r={...t.verdictShare};for(const t of e)r[t.verdict]+=1/e.length;const n=e.filter(pr),o=e.filter(e=>!pr(e));return{samples:e.length,durationMs:e[e.length-1].t-e[0].t,medianFps:gr(e.filter(e=>e.fps>0).map(e=>e.fps)),worstFrameMs:e.reduce((e,t)=>t.worstMs>e?t.worstMs:e,0),verdictShare:r,interacting:n.length>=4?fr(n):null,idle:o.length>=4?fr(o):null,byActivity:br([...yr(e,cr).entries()].filter(([,e])=>e.length>=2).map(([e,t])=>({kind:e,...fr(t)}))),byWindowCount:[...yr(e,e=>e.windows).entries()].filter(([,e])=>e.length>=4).map(([e,t])=>({windows:e,...fr(t)})).sort((e,t)=>e.windows-t.windows),worstWindows:br([...yr(e,e=>e.active).entries()].filter(([,e])=>e.length>=4).map(([e,t])=>({key:e,...fr(t)}))),worstMenus:br([...yr(e,e=>e.menuKey).entries()].filter(([,e])=>e.length>=2).map(([e,t])=>({key:e,...fr(t)})))}}var wr=["t","fps","frameMs","worstMs","blockedPct","heapMB","verdict","windows","active","clicks","keys","scrolls","dragMs","menus","submenus","menuKey","moveMs","resizeMs"];function vr(e){return[wr.join(","),...e.map(e=>wr.map(t=>(e=>{if(null==e)return"";const t=String("number"==typeof e?Math.round(10*e)/10:e);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t})(e[t])).join(","))].join("\n")}function kr(e){if(!e?.length)return null;const t=e.filter(e=>!/not[^a-z]*a[^a-z]*brand/i.test(e.brand)),r=t.find(e=>"Chromium"!==e.brand)??t[0];return r?`${r.brand} ${r.version}`:null}function Nr(e){return"string"==typeof e&&e?e:null}async function Cr(){return{hints:await Mr(),battery:await Sr()}}async function Mr(){const e=navigator.userAgentData;if(!e)return null;const t={platform:e.platform??null,platformVersion:null,architecture:null,model:null,browser:kr(e.brands)};if(!e.getHighEntropyValues)return t;try{const r=await e.getHighEntropyValues(["platform","platformVersion","architecture","model","fullVersionList"]),n=r.fullVersionList;return{platform:Nr(r.platform)??t.platform,platformVersion:Nr(r.platformVersion),architecture:Nr(r.architecture),model:Nr(r.model),browser:kr(n)??t.browser}}catch{return t}}async function Sr(){const e=navigator.getBattery;if(!e)return null;try{const t=await e.call(navigator);return{charging:t.charging,level:t.level}}catch{return null}}function _r(e){try{return window.matchMedia(e).matches}catch{return!1}}function Lr(e){const t=navigator,r=performance.memory,n=e?.hints??null,o=function(){if("undefined"==typeof document)return{renderer:null,vendor:null,available:!1};try{const e=document.createElement("canvas").getContext("webgl");if(!e)return{renderer:null,vendor:null,available:!1};const t=e.getExtension("WEBGL_debug_renderer_info"),r=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),n=t?e.getParameter(t.UNMASKED_VENDOR_WEBGL):e.getParameter(e.VENDOR);return e.getExtension("WEBGL_lose_context")?.loseContext(),{renderer:Nr(r),vendor:Nr(n),available:!0}}catch{return{renderer:null,vendor:null,available:!1}}}(),a=t.connection;return{userAgent:t.userAgent,browser:n?.browser??null,platform:n?.platform??null,platformVersion:n?.platformVersion??null,architecture:n?.architecture??null,model:n?.model??null,cpuCores:"number"==typeof t.hardwareConcurrency?t.hardwareConcurrency:null,deviceMemoryGB:"number"==typeof t.deviceMemory?t.deviceMemory:null,gpu:o.renderer,gpuVendor:o.vendor,webglAvailable:o.available,screen:{width:screen.width,height:screen.height,dpr:window.devicePixelRatio,colorDepth:"number"==typeof screen.colorDepth?screen.colorDepth:null},viewport:{width:window.innerWidth,height:window.innerHeight},heapLimitMB:r?Math.round(r.jsHeapSizeLimit/1048576):null,network:a?{effectiveType:Nr(a.effectiveType),downlinkMbps:"number"==typeof a.downlink?a.downlink:null,rttMs:"number"==typeof a.rtt?a.rtt:null,saveData:!0===a.saveData}:null,battery:e?.battery??null,prefersReducedMotion:_r("(prefers-reduced-motion: reduce)"),forcedColors:_r("(forced-colors: active)"),reducedTransparency:document.documentElement.classList.contains("rosh-reduce-transparency"),touchPoints:"number"==typeof t.maxTouchPoints?t.maxTouchPoints:null}}function Er(e){const t=[];e.browser&&t.push(e.browser);const r=[e.platform,e.platformVersion].filter(Boolean).join(" ");return r&&t.push(e.architecture?`${r} (${e.architecture})`:r),e.gpu?t.push(e.gpu):e.webglAvailable||t.push("no WebGL (software rendering)"),e.cpuCores&&t.push(`${e.cpuCores} cores`),e.deviceMemoryGB&&t.push(`${e.deviceMemoryGB}GB+ RAM`),t.push(`${e.screen.width}×${e.screen.height} @${e.screen.dpr}x`),e.battery&&!e.battery.charging&&t.push(`on battery ${Math.round(100*e.battery.level)}%`),e.reducedTransparency&&t.push("reduce transparency on"),e.prefersReducedMotion&&t.push("reduced motion"),t.join(" · ")}var Pr={smooth:{dot:"bg-emerald-400",text:"text-emerald-300"},gpu:{dot:"bg-amber-400",text:"text-amber-300"},cpu:{dot:"bg-sky-400",text:"text-sky-300"},unknown:{dot:"bg-gray-400",text:"text-gray-300"}};function Tr({onClose:e,onSubmit:t,className:r=""}){const n=pt([]),o=pt(0),a=pt({clicks:0,keys:0,scrolls:0,dragMs:0}),l=pt({down:!1,since:0}),i=pt([]),s=pt(0),c=pt(0),d=pt(null),u=pt(null),[m,h]=mt(!1),[p,g]=mt({fps:0,frameMs:0,worstMs:0,blockedPct:null}),[f,y]=mt([]),[b,x]=mt(null),[w,v]=mt(0),[k,N]=mt(!1),[C,M]=mt(""),[S,_]=mt(!1),[L,E]=mt(null);ht(()=>(te(!0),()=>te(!1)),[]),ht(()=>{let e=!0;return Cr().then(t=>{e&&(u.current=t)}),()=>{e=!1}},[]),ht(()=>{let e=0;const t=r=>{const o=n.current;o.push(r);const a=r-1e3;for(;o.length&&o[0]<a;)o.shift();e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>cancelAnimationFrame(e)},[]),ht(()=>{if("undefined"==typeof PerformanceObserver)return;let e;try{e=new PerformanceObserver(e=>{for(const t of e.getEntries())o.current+=t.duration}),e.observe({entryTypes:["longtask"]}),h(!0)}catch{return}return()=>e?.disconnect()},[]),ht(()=>{const e=()=>{a.current.clicks++,l.current={down:!0,since:performance.now()}},t=()=>{if(!l.current.down)return;const e=performance.now(),t=e-l.current.since;l.current.since=e,t<=100&&(a.current.dragMs+=t)},r=()=>{l.current.down=!1},n=()=>{a.current.keys++},o=()=>{a.current.scrolls++},i={capture:!0,passive:!0};return window.addEventListener("pointerdown",e,i),window.addEventListener("pointermove",t,i),window.addEventListener("pointerup",r,i),window.addEventListener("pointercancel",r,i),window.addEventListener("keydown",n,i),window.addEventListener("wheel",o,i),()=>{window.removeEventListener("pointerdown",e,i),window.removeEventListener("pointermove",t,i),window.removeEventListener("pointerup",r,i),window.removeEventListener("pointercancel",r,i),window.removeEventListener("keydown",n,i),window.removeEventListener("wheel",o,i)}},[]);const P=gt(()=>{try{localStorage.setItem("react-os-shell:perf-log",JSON.stringify(i.current))}catch{}},[]);ht(()=>{const e=()=>P();return window.addEventListener("pagehide",e),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("pagehide",e),document.removeEventListener("visibilitychange",e),P()}},[P]),ht(()=>{const e=setInterval(()=>{const e=performance.now();s.current||(s.current=e);const t=lr(n.current),r=m?Math.min(100,o.current/500*100):null;o.current=0;const l=performance.memory,d=l?l.usedJSHeapSize/1048576:null,u={...t,blockedPct:r},h=a.current,p=re(),{windows:f,active:b}=function(){if("undefined"==typeof document)return{windows:0,active:null};const e=document.querySelectorAll("[data-modal-panel]");let t=null,r=-1/0;return e.forEach(e=>{const n=parseInt(window.getComputedStyle(e).zIndex,10),o=Number.isFinite(n)?n:0;o>=r&&(r=o,t=e.dataset.windowKey??e.dataset.modalId??null)}),{windows:e.length,active:t}}();i.current=hr(i.current,{t:Math.round(e-s.current),...t,blockedPct:r,heapMB:d,verdict:ir(u).kind,windows:f,active:b,clicks:h.clicks,keys:h.keys,scrolls:h.scrolls,dragMs:Math.round(h.dragMs),menus:p.menus,submenus:p.submenus,menuKey:p.menuKey,moveMs:Math.round(p.moveMs),resizeMs:Math.round(p.resizeMs)}),h.clicks=0,h.keys=0,h.scrolls=0,h.dragMs=0,(!c.current||e-c.current>=1e4)&&(c.current=e,P()),g(u),y(e=>[...e,t.fps].slice(-40)),x(l?{usedMB:l.usedJSHeapSize/1048576,limitMB:l.jsHeapSizeLimit/1048576}:null),v(i.current.length)},500);return()=>clearInterval(e)},[m,P]);const T=gt(()=>{d.current=i.current.slice(),E(null),N(!0)},[]),$=ir(p),I=gt(()=>{const e=d.current??i.current,t=/* @__PURE__ */(new Date).toISOString().replace(/[:.]/g,"-").slice(0,19),r=xr(e),n=Lr(u.current);return{message:C,filename:`perf-log-${t}.json`,summary:r,environment:n,verdict:$.label,json:JSON.stringify({generatedAt:/* @__PURE__ */(new Date).toISOString(),message:C,verdict:$.label,environment:n,summary:r,records:e},null,2)}},[C,$.label]),D=gt(e=>{const t=URL.createObjectURL(new Blob([e.json],{type:"application/json"})),r=document.createElement("a");r.href=t,r.download=e.filename,r.click(),URL.revokeObjectURL(t)},[]),A=gt(async()=>{const e=I();_(!0),E(null);try{t?await t(e):D(e),d.current=null,M(""),N(!1)}catch(e){E(e instanceof Error&&e.message?e.message:"Could not send. Try again.")}finally{_(!1)}},[I,D,t]),j=Pr[$.kind],R=Math.max(60,...f),B=Math.round(500*w/1e3),W=t?"Send":"Download",F=d.current?.length??w;/* @__PURE__ */
85
85
  return St("div",{className:`w-56 rounded-lg border border-white/15 bg-[#11111b]/95 px-3 py-2 font-mono text-[10px] text-white/80 shadow-lg select-none ${r}`,role:"status","aria-live":"off","aria-label":"Performance statistics",children:[
86
86
  /* @__PURE__ */St("div",{className:"mb-1.5 flex items-center justify-between",children:[
87
87
  /* @__PURE__ */_t("span",{className:"text-[9px] uppercase tracking-wider text-white/40",children:"Performance"}),e&&/* @__PURE__ */_t("button",{onClick:e,className:"-mr-1 px-1 leading-none text-white/40 transition-colors hover:text-white/90","aria-label":"Hide performance statistics",children:"×"})]}),
@@ -90,7 +90,7 @@ return St("div",{className:`w-56 rounded-lg border border-white/15 bg-[#11111b]/
90
90
  /* @__PURE__ */_t("span",{className:"ml-1 text-[10px] font-normal text-white/40",children:"fps"})]}),
91
91
  /* @__PURE__ */_t("span",{className:"tabular-nums text-white/50",children:p.frameMs?`${p.frameMs.toFixed(1)} ms`:"—"})]}),
92
92
  /* @__PURE__ */_t("div",{className:"mt-1.5 flex h-5 items-end gap-px","aria-hidden":"true",children:Array.from({length:40},(e,t)=>{const r=f[f.length-40+t];/* @__PURE__ */
93
- return _t("div",{className:`flex-1 rounded-sm ${void 0===r?"bg-white/5":j.dot}`,style:{height:void 0===r?"2px":`${Math.max(6,r/B*100)}%`}},t)})}),
93
+ return _t("div",{className:`flex-1 rounded-sm ${void 0===r?"bg-white/5":j.dot}`,style:{height:void 0===r?"2px":`${Math.max(6,r/R*100)}%`}},t)})}),
94
94
  /* @__PURE__ */St("dl",{className:"mt-2 space-y-0.5",children:[
95
95
  /* @__PURE__ */_t($r,{label:"worst frame",value:p.worstMs?`${p.worstMs.toFixed(0)} ms`:"—"}),
96
96
  /* @__PURE__ */_t($r,{label:"main thread",value:null===p.blockedPct?"n/a":`${p.blockedPct.toFixed(0)}% blocked`}),
@@ -109,13 +109,13 @@ return _t("div",{className:`flex-1 rounded-sm ${void 0===r?"bg-white/5":j.dot}`,
109
109
  /* @__PURE__ */St("span",{className:"flex gap-1",children:[
110
110
  /* @__PURE__ */_t("button",{onClick:()=>{N(!1),d.current=null,E(null)},disabled:S,className:"rounded border border-white/15 px-1.5 py-0.5 text-white/50 transition-colors hover:border-white/30 hover:text-white disabled:opacity-40",children:"Cancel"}),
111
111
  /* @__PURE__ */_t("button",{onClick:A,disabled:S,className:"rounded border border-white/30 bg-white/10 px-1.5 py-0.5 text-white/90 transition-colors hover:bg-white/20 disabled:cursor-not-allowed disabled:opacity-40",children:S?"Sending…":W})]})]})]}:{className:"flex items-center justify-between",children:[
112
- /* @__PURE__ */St("span",{className:"text-white/35",children:["log ",w," · ",R<60?`${R}s`:`${Math.round(R/60)}m`]}),
112
+ /* @__PURE__ */St("span",{className:"text-white/35",children:["log ",w," · ",B<60?`${B}s`:`${Math.round(B/60)}m`]}),
113
113
  /* @__PURE__ */_t("button",{onClick:T,disabled:!w,className:"rounded border border-white/15 px-1.5 py-0.5 text-white/60 transition-colors hover:border-white/30 hover:text-white disabled:cursor-not-allowed disabled:opacity-40",children:t?"Report this":"Save report"})]})})]})}function $r({label:e,value:t}){/* @__PURE__ */
114
114
  return St("div",{className:"flex items-baseline justify-between gap-2",children:[
115
115
  /* @__PURE__ */_t("dt",{className:"text-white/40",children:e}),
116
- /* @__PURE__ */_t("dd",{className:"tabular-nums text-white/70",children:t})]})}var Ir=[],Dr="documents",Ar="Recent Documents",jr=90;var Br=ct({});function Rr({value:e,children:t}){/* @__PURE__ */
117
- return _t(Br.Provider,{value:e,children:t})}function Wr(){return bt(Br)}function Fr(){const e="undefined"!=typeof document?getComputedStyle(document.documentElement):null,t=(e?.getPropertyValue("--taskbar-position")||"bottom").trim();return{position:t,vertical:"left"===t||"right"===t,height:parseInt(e?.getPropertyValue("--taskbar-height")||"0")||0,width:parseInt(e?.getPropertyValue("--taskbar-width")||"0")||0}}function zr({profile:e}){const t=st();Pt();const{openEntity:l,openPage:i}=J(),s=pt(null),{prefs:c,save:d}=Ee(),u={...e?.preferences||{},...c},m=u.favorite_documents||[],h=u.desktop_folders||[],p=h.some(e=>e.id===Dr)?h.map(e=>e.id===Dr?{...e,name:Ar}:e):[...h,{id:Dr,name:Ar}],g=u.desktop_snap??!1,f=u.notepad_notes||[],y=f.filter(e=>e.sticky),b=Wr(),x=b.hiddenContextMenuItems??[],w=async(e,t)=>{const r=`${e}#${t}`;if(b.stickyResolver)try{const n=await b.stickyResolver(e,t);n?l(n.entityType,n.entityId,n.snapshot,n.label??r):U.error(`${r} not found`)}catch{U.error(`Failed to open ${r}`)}else U.error(`Unknown reference: ${r}`)},v=(e,t)=>{const r=f.find(t=>t.id===e);if(!r)return;const n=r.content,o=n.slice(t).match(/^\[([ xX]?)\]/);if(!o)return;const a="x"===o[1]||"X"===o[1]?"[ ]":"[x]",l=n.slice(0,t)+a+n.slice(t+o[0].length);Ce(f.map(t=>t.id===e?{...t,content:l,updated_at:/* @__PURE__ */(new Date).toISOString()}:t))},k=(e,t)=>{if(!t)return[];const r=t.split("\n");let n=0;return r.map((t,r)=>{const o=n;n+=t.length+1;const a=[],l=/([A-Z]{2,4})#(\d{4,6})/g;let i;for(;null!==(i=l.exec(t));)if(b.stickyResolver){const e=i[1],t=i[2],n=i.index,o=i[0];a.push({idx:n,len:o.length,render:()=>/* @__PURE__ */_t("button",{onClick:r=>{r.stopPropagation(),w(e,t)},className:"text-blue-700 hover:underline font-medium cursor-pointer",children:o},`r-${r}-${n}`)})}const s=/\[([ xX]?)\]/g;for(;null!==(i=s.exec(t));){const t="x"===i[1]||"X"===i[1],n=i.index,l=o+n;a.push({idx:n,len:i[0].length,render:()=>/* @__PURE__ */_t("button",{onClick:t=>{t.stopPropagation(),v(e,l)},className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded border ${t?"bg-blue-500 border-blue-500 text-white":"border-gray-500 bg-white/50 hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:t&&/* @__PURE__ */_t("svg",{className:"w-2.5 h-2.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})},`c-${r}-${n}`)})}a.sort((e,t)=>e.idx-t.idx);const c=[];let d=0;for(const e of a)e.idx>d&&c.push(/* @__PURE__ */_t("span",{children:t.slice(d,e.idx)},`t-${r}-${d}`)),c.push(e.render()),d=e.idx+e.len;d<t.length&&c.push(/* @__PURE__ */_t("span",{children:t.slice(d)},`t-${r}-${d}`)),0===c.length&&c.push(/* @__PURE__ */_t("span",{children:"​"},`e-${r}`));const u=/^\[x\]/i.test(t.trimStart());/* @__PURE__ */
118
- return _t("div",{className:u?"line-through opacity-50":"",children:c},r)})},[N,C]=mt(null),[M,S]=mt(null),[_,L]=mt(/* @__PURE__ */new Set),[E,P]=mt(null),[T,$]=mt(!1),[I,D]=mt(!1),[A,j]=mt(!1),[B,R]=mt(null),[W,K]=mt(""),[Y,q]=mt(null),[G,Q]=mt(null),[Z,te]=mt(null),[re,ne]=mt(null),oe=pt(null),ae=gt(e=>{b.saveShortcuts?b.saveShortcuts(e):d({favorite_documents:e})},[b,d]),le=gt(e=>{b.saveFolders?b.saveFolders(e):d({desktop_folders:e})},[b,d]);gt(e=>{b.saveSnap?b.saveSnap(e):d({desktop_snap:e})},[b,d]);const ie=pt({folders:p,favDocs:m,saveFolders:le,saveDocs:ae});ie.current={folders:p,favDocs:m,saveFolders:le,saveDocs:ae},ht(()=>{const e=e=>{const t=e.detail;if(!t?.filePath)return;const{favDocs:r,saveDocs:n}=ie.current,o=r.filter(e=>!("preview-file"===e.entityType&&e.filePath===t.filePath));n([{entityType:"preview-file",entityId:t.filePath,label:t.filename,filePath:t.filePath,fileKind:t.kind,folderId:Dr},...o])};return window.addEventListener(r,e),()=>window.removeEventListener(r,e)},[]);const se=e=>({right:20+Math.floor(e/8)*jr,top:20+e%8*jr}),ce=(e,t)=>null!=e.x&&null!=e.y?{right:e.x,top:e.y}:se(t),de=(e,t)=>null!=e.x&&null!=e.y?{right:e.x,top:e.y}:se(m.filter(e=>!e.folderId).length+t),ue=m.filter(e=>!e.folderId),me=e=>{"preview-file"===e.entityType&&e.filePath&&e.fileKind?n({filePath:e.filePath,filename:e.label,kind:e.fileKind,onStaged:e=>i(e)}):"page"===e.entityType?i(e.entityId):l(e.entityType,e.entityId,null,e.label)},he=e=>{H(e),i("/files")},pe=gt(e=>{const{favDocs:t,saveDocs:r}=ie.current,n=new Set(e.map(e=>`${e.entityType}|${e.entityId}`));r(t.map(e=>e.folderId&&n.has(`${e.entityType}|${e.entityId}`)?{...e,folderId:void 0,folderX:void 0,folderY:void 0}:e))},[]),ge=gt(e=>{const{favDocs:t,saveDocs:r}=ie.current,n=new Set(e.map(e=>`${e.entityType}|${e.entityId}`));r(t.filter(e=>!(e.folderId&&n.has(`${e.entityType}|${e.entityId}`))))},[]),[fe,ye]=mt({}),be=pt([]),xe=(e,t,r)=>{if(0!==r.button)return;const n="trash"===e?"trash":`${e}-${t}`,o=_.has(n)&&_.size>1?Array.from(_):[n],a=[];for(const e of o)if(e.startsWith("item-")){const t=parseInt(e.slice(5),10),r=ue[t];if(!r)continue;const n=ce(r,t),o=document.querySelector(`[data-desktop-icon="${e}"]`);a.push({key:e,type:"item",idx:t,origX:n.right,origY:n.top,el:o})}else if(e.startsWith("folder-")){const t=parseInt(e.slice(7),10),r=p[t];if(!r)continue;const n=de(r,t),o=document.querySelector(`[data-desktop-icon="${e}"]`);a.push({key:e,type:"folder",idx:t,origX:n.right,origY:n.top,el:o})}else if("trash"===e){const t=document.querySelector('[data-desktop-icon="trash"]');if(!t)continue;const r=parseFloat(t.style.right||"0")||0,n=parseFloat(t.style.bottom||"0")||0;a.push({key:e,type:"trash",idx:0,origX:r,origY:n,el:t})}be.current=a;const l=a.find(e=>e.key===n)??a[0];l&&(C({type:e,idx:t,startX:r.clientX,startY:r.clientY,origX:l.origX,origY:l.origY}),r.preventDefault())};ht(()=>{if(!N)return;const e=be.current,t=1===e.length&&"item"===e[0].type,r=()=>{if(!t)return null;const r=ue[e[0].idx];return"page"===r?.entityType?r.entityId:null},n=()=>document.querySelector("[data-taskbar-dropzone]"),o=(e,t)=>{const r=n();if(!r)return!1;const o=r.getBoundingClientRect();return e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom},a=e=>{const t=n();t&&(t.style.outline=e?"2px solid var(--accent-600, #7c3aed)":"",t.style.outlineOffset=e?"-2px":"")},l=n=>{const l=n.clientX-N.startX,i=n.clientY-N.startY;for(const t of e)t.el&&(t.el.style.right=t.origX-l+"px","trash"===t.type?t.el.style.bottom=t.origY-i+"px":(t.el.style.top=`${t.origY+i}px`,t.el.style.left="auto"),t.el.style.zIndex="100",t.el.style.opacity="0.7");if(t){const e=document.elementsFromPoint(n.clientX,n.clientY);let t=null;for(const r of e){const e=r.closest?.('[data-desktop-icon^="folder-"]');if(e){const r=e.getAttribute("data-desktop-icon");r&&(t=parseInt(r.slice(7),10));break}}oe.current=t,ne(e=>e===t?e:t),a(null!=r()&&o(n.clientX,n.clientY))}},i=t=>{const n=t.clientX-N.startX,l=t.clientY-N.startY;for(const t of e)t.el&&(t.el.style.zIndex="",t.el.style.opacity="");const i=r();if(i&&o(t.clientX,t.clientY)){a(!1);for(const t of e)t.el&&(t.el.style.left="auto",t.el.style.right=`${t.origX}px`,t.el.style.top=`${t.origY}px`);const t=Array.isArray(c.favorite_pages)?c.favorite_pages:[];return t.includes(i)||d({favorite_pages:[...t,i]}),oe.current=null,ne(null),C(null),void(be.current=[])}a(!1);const s=oe.current,u=null!=s?p[s]:null;oe.current=null,ne(null);const h=e.filter(e=>"trash"!==e.type).map(e=>{let t=e.origX-n,r=Math.max(0,e.origY+l);if(g){const e=(o=t,a=r,{x:Math.round(o/jr)*jr,y:Math.round(a/jr)*jr});t=e.x,r=e.y}var o,a;return t=Math.max(0,t),{entry:e,finalRight:t,finalTop:r}}),f=e.find(e=>"trash"===e.type);f&&d({desktop_trash_position:{right:Math.max(0,f.origX-n),bottom:Math.max(0,f.origY-l)}});const y=h.filter(e=>"item"===e.entry.type);if(y.length>0){const t=[...m],r={},n=1===y.length&&1===e.length?y[0]:null,o=n?u??p.find((e,t)=>{const r=de(e,t);return Math.abs(n.finalRight-r.right)<40&&Math.abs(n.finalTop-r.top)<40}):void 0;if(o&&n?.entry.el){const e=n.entry.el,t=p.indexOf(o),r=document.querySelector(`[data-desktop-icon="folder-${t}"]`);if(r){const t=e.getBoundingClientRect(),n=r.getBoundingClientRect(),o=n.left+n.width/2-(t.left+t.width/2),a=n.top+n.height/2-(t.top+t.height/2);e.style.transition="transform 220ms ease-out, opacity 220ms ease-out",e.style.transform=`translate(${o}px, ${a}px) scale(0.2)`,e.style.opacity="0"}r?.animate([{transform:"scale(1)"},{transform:"scale(1.15)"},{transform:"scale(1)"}],{duration:280,easing:"ease-out"})}for(const e of y){const n=m.indexOf(ue[e.entry.idx]);-1!==n&&(o?t[n]={...t[n],folderId:o.id,x:void 0,y:void 0,folderX:void 0,folderY:void 0}:(t[n]={...t[n],x:e.finalRight,y:e.finalTop,folderId:void 0},r[`item-${n}`]={right:e.finalRight,top:e.finalTop}))}const a=()=>{ae(t),Object.keys(r).length>0&&ye(e=>({...e,...r}))};o?setTimeout(a,220):a()}const b=h.filter(e=>"folder"===e.entry.type);if(b.length>0){const e=[...p],t={};for(const r of b)e[r.entry.idx]={...e[r.entry.idx],x:r.finalRight,y:r.finalTop},t[`folder-${r.entry.idx}`]={right:r.finalRight,top:r.finalTop};le(e),ye(e=>({...e,...t}))}C(null),be.current=[]};return window.addEventListener("pointermove",l),window.addEventListener("pointerup",i),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",i)}},[N,g,m,p,ue,c]);const we=JSON.stringify(m.map(e=>`${e.entityId}:${e.x??""}:${e.y??""}:${e.folderId??""}`)),ve=JSON.stringify(p.map(e=>`${e.id}:${e.x??""}:${e.y??""}`));ht(()=>{ye({})},[we,ve]),ht(()=>{const{folders:e,favDocs:t}=ie.current,r={};for(const t of e)r[t.id]=[];for(const e of t)e.folderId&&r[e.folderId]&&r[e.folderId].push(e);F({folders:e.map(e=>({id:e.id,name:e.name,itemCount:r[e.id]?.length??0})),itemsByFolder:r,moveToDesktop:pe,removeShortcuts:ge})},[we,ve,pe,ge]),ht(()=>()=>F(null),[]);const ke=pt(!1);ht(()=>{if(!E)return;const e=e=>{const t=s.current?.getBoundingClientRect();if(!t)return;const r=e.clientX-t.left,n=e.clientY-t.top,o=r-E.startX,a=n-E.startY;if(o*o+a*a>16&&(ke.current=!0),P(e=>e?{...e,endX:r,endY:n}:null),ke.current){const e=Math.min(E.startX,r),t=Math.max(E.startX,r),o=Math.min(E.startY,n),a=Math.max(E.startY,n);L(((e,t,r,n)=>{const o=/* @__PURE__ */new Set,a=s.current?.clientWidth||800;ue.forEach((l,i)=>{const s=ce(l,i),c=a-s.right-80;c+40>e&&c<t&&s.top+40>r&&s.top<n&&o.add(`item-${i}`)}),p.forEach((l,i)=>{const s=de(l,i),c=a-s.right-80;c+40>e&&c<t&&s.top+40>r&&s.top<n&&o.add(`folder-${i}`)});const l=s.current?.querySelector('[data-desktop-icon="trash"]'),i=s.current?.getBoundingClientRect();if(l&&i){const a=l.getBoundingClientRect(),s=a.left-i.left,c=a.top-i.top;s+a.width>e&&s<t&&c+a.height>r&&c<n&&o.add("trash")}return o})(e,t,o,a))}},t=()=>{P(null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[E]);ht(()=>{if(!M)return;const e=()=>S(null);return window.addEventListener("click",e),()=>window.removeEventListener("click",e)},[M]);const Ne=(e,t)=>{le(p.map(r=>r.id===e?{...r,name:t}:r)),R(null)},Ce=gt(e=>{b.saveNotes?b.saveNotes(e):d({notepad_notes:e})},[b,d]),Me=(e,t)=>{Ce(f.map(r=>r.id===e?{...r,content:t,updated_at:/* @__PURE__ */(new Date).toISOString()}:r))};ht(()=>{if(!G)return;const e=e=>{const t=document.querySelector(`[data-sticky-id="${G.id}"]`);t&&(t.style.left=G.origX+e.clientX-G.startX+"px",t.style.right="auto",t.style.top=G.origY+e.clientY-G.startY+"px")},t=e=>{const t=G.origX+e.clientX-G.startX,r=Math.max(0,G.origY+e.clientY-G.startY),n=document.querySelector(`[data-sticky-id="${G.id}"]`),o=n?.offsetWidth??192,a=t+o/2>window.innerWidth/2?"right":"left",l="right"===a?window.innerWidth-t-o:t;Ce(f.map(e=>e.id===G.id?{...e,sticky_x:l,sticky_y:r,sticky_anchor:a}:e)),n&&(n.style.left="",n.style.right=""),Q(null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[G,f]),ht(()=>{if(!Z)return;const e=e=>{const t=document.querySelector(`[data-sticky-id="${Z.id}"]`);t&&(t.style.width=`${Math.max(140,Z.origW+e.clientX-Z.startX)}px`,t.style.height=`${Math.max(100,Z.origH+e.clientY-Z.startY)}px`)},t=e=>{const t=Math.max(140,Z.origW+e.clientX-Z.startX),r=Math.max(100,Z.origH+e.clientY-Z.startY);Ce(f.map(e=>e.id===Z.id?{...e,sticky_w:t,sticky_h:r}:e)),te(null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[Z,f]);const Se={yellow:"bg-yellow-100 border-yellow-300",blue:"bg-blue-100 border-blue-300",green:"bg-green-100 border-green-300",pink:"bg-pink-100 border-pink-300",purple:"bg-purple-100 border-purple-300",orange:"bg-orange-100 border-orange-300"},_e=(e,t,r,n,o)=>/* @__PURE__ */St("div",{className:"flex flex-col items-center gap-1 w-20 p-2",children:[
116
+ /* @__PURE__ */_t("dd",{className:"tabular-nums text-white/70",children:t})]})}var Ir=[],Dr="documents",Ar="Recent Documents",jr=90;var Rr=ct({});function Br({value:e,children:t}){/* @__PURE__ */
117
+ return _t(Rr.Provider,{value:e,children:t})}function Wr(){return bt(Rr)}function Fr(){const e="undefined"!=typeof document?getComputedStyle(document.documentElement):null,t=(e?.getPropertyValue("--taskbar-position")||"bottom").trim();return{position:t,vertical:"left"===t||"right"===t,height:parseInt(e?.getPropertyValue("--taskbar-height")||"0")||0,width:parseInt(e?.getPropertyValue("--taskbar-width")||"0")||0}}function zr({profile:e}){const t=st();Pt();const{openEntity:l,openPage:i}=J(),s=pt(null),{prefs:c,save:d}=Ee(),u={...e?.preferences||{},...c},m=u.favorite_documents||[],h=u.desktop_folders||[],p=h.some(e=>e.id===Dr)?h.map(e=>e.id===Dr?{...e,name:Ar}:e):[...h,{id:Dr,name:Ar}],g=u.desktop_snap??!1,f=u.notepad_notes||[],y=f.filter(e=>e.sticky),b=Wr(),x=b.hiddenContextMenuItems??[],w=async(e,t)=>{const r=`${e}#${t}`;if(b.stickyResolver)try{const n=await b.stickyResolver(e,t);n?l(n.entityType,n.entityId,n.snapshot,n.label??r):U.error(`${r} not found`)}catch{U.error(`Failed to open ${r}`)}else U.error(`Unknown reference: ${r}`)},v=(e,t)=>{const r=f.find(t=>t.id===e);if(!r)return;const n=r.content,o=n.slice(t).match(/^\[([ xX]?)\]/);if(!o)return;const a="x"===o[1]||"X"===o[1]?"[ ]":"[x]",l=n.slice(0,t)+a+n.slice(t+o[0].length);Ce(f.map(t=>t.id===e?{...t,content:l,updated_at:/* @__PURE__ */(new Date).toISOString()}:t))},k=(e,t)=>{if(!t)return[];const r=t.split("\n");let n=0;return r.map((t,r)=>{const o=n;n+=t.length+1;const a=[],l=/([A-Z]{2,4})#(\d{4,6})/g;let i;for(;null!==(i=l.exec(t));)if(b.stickyResolver){const e=i[1],t=i[2],n=i.index,o=i[0];a.push({idx:n,len:o.length,render:()=>/* @__PURE__ */_t("button",{onClick:r=>{r.stopPropagation(),w(e,t)},className:"text-blue-700 hover:underline font-medium cursor-pointer",children:o},`r-${r}-${n}`)})}const s=/\[([ xX]?)\]/g;for(;null!==(i=s.exec(t));){const t="x"===i[1]||"X"===i[1],n=i.index,l=o+n;a.push({idx:n,len:i[0].length,render:()=>/* @__PURE__ */_t("button",{onClick:t=>{t.stopPropagation(),v(e,l)},className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded border ${t?"bg-blue-500 border-blue-500 text-white":"border-gray-500 bg-white/50 hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:t&&/* @__PURE__ */_t("svg",{className:"w-2.5 h-2.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})},`c-${r}-${n}`)})}a.sort((e,t)=>e.idx-t.idx);const c=[];let d=0;for(const e of a)e.idx>d&&c.push(/* @__PURE__ */_t("span",{children:t.slice(d,e.idx)},`t-${r}-${d}`)),c.push(e.render()),d=e.idx+e.len;d<t.length&&c.push(/* @__PURE__ */_t("span",{children:t.slice(d)},`t-${r}-${d}`)),0===c.length&&c.push(/* @__PURE__ */_t("span",{children:"​"},`e-${r}`));const u=/^\[x\]/i.test(t.trimStart());/* @__PURE__ */
118
+ return _t("div",{className:u?"line-through opacity-50":"",children:c},r)})},[N,C]=mt(null),[M,S]=mt(null),[_,L]=mt(/* @__PURE__ */new Set),[E,P]=mt(null),[T,$]=mt(!1),[I,D]=mt(!1),[A,j]=mt(!1),[R,B]=mt(null),[W,K]=mt(""),[Y,q]=mt(null),[G,Q]=mt(null),[Z,te]=mt(null),[re,ne]=mt(null),oe=pt(null),ae=gt(e=>{b.saveShortcuts?b.saveShortcuts(e):d({favorite_documents:e})},[b,d]),le=gt(e=>{b.saveFolders?b.saveFolders(e):d({desktop_folders:e})},[b,d]);gt(e=>{b.saveSnap?b.saveSnap(e):d({desktop_snap:e})},[b,d]);const ie=pt({folders:p,favDocs:m,saveFolders:le,saveDocs:ae});ie.current={folders:p,favDocs:m,saveFolders:le,saveDocs:ae},ht(()=>{const e=e=>{const t=e.detail;if(!t?.filePath)return;const{favDocs:r,saveDocs:n}=ie.current,o=r.filter(e=>!("preview-file"===e.entityType&&e.filePath===t.filePath));n([{entityType:"preview-file",entityId:t.filePath,label:t.filename,filePath:t.filePath,fileKind:t.kind,folderId:Dr},...o])};return window.addEventListener(r,e),()=>window.removeEventListener(r,e)},[]);const se=e=>({right:20+Math.floor(e/8)*jr,top:20+e%8*jr}),ce=(e,t)=>null!=e.x&&null!=e.y?{right:e.x,top:e.y}:se(t),de=(e,t)=>null!=e.x&&null!=e.y?{right:e.x,top:e.y}:se(m.filter(e=>!e.folderId).length+t),ue=m.filter(e=>!e.folderId),me=e=>{"preview-file"===e.entityType&&e.filePath&&e.fileKind?n({filePath:e.filePath,filename:e.label,kind:e.fileKind,onStaged:e=>i(e)}):"page"===e.entityType?i(e.entityId):l(e.entityType,e.entityId,null,e.label)},he=e=>{H(e),i("/files")},pe=gt(e=>{const{favDocs:t,saveDocs:r}=ie.current,n=new Set(e.map(e=>`${e.entityType}|${e.entityId}`));r(t.map(e=>e.folderId&&n.has(`${e.entityType}|${e.entityId}`)?{...e,folderId:void 0,folderX:void 0,folderY:void 0}:e))},[]),ge=gt(e=>{const{favDocs:t,saveDocs:r}=ie.current,n=new Set(e.map(e=>`${e.entityType}|${e.entityId}`));r(t.filter(e=>!(e.folderId&&n.has(`${e.entityType}|${e.entityId}`))))},[]),[fe,ye]=mt({}),be=pt([]),xe=(e,t,r)=>{if(0!==r.button)return;const n="trash"===e?"trash":`${e}-${t}`,o=_.has(n)&&_.size>1?Array.from(_):[n],a=[];for(const e of o)if(e.startsWith("item-")){const t=parseInt(e.slice(5),10),r=ue[t];if(!r)continue;const n=ce(r,t),o=document.querySelector(`[data-desktop-icon="${e}"]`);a.push({key:e,type:"item",idx:t,origX:n.right,origY:n.top,el:o})}else if(e.startsWith("folder-")){const t=parseInt(e.slice(7),10),r=p[t];if(!r)continue;const n=de(r,t),o=document.querySelector(`[data-desktop-icon="${e}"]`);a.push({key:e,type:"folder",idx:t,origX:n.right,origY:n.top,el:o})}else if("trash"===e){const t=document.querySelector('[data-desktop-icon="trash"]');if(!t)continue;const r=parseFloat(t.style.right||"0")||0,n=parseFloat(t.style.bottom||"0")||0;a.push({key:e,type:"trash",idx:0,origX:r,origY:n,el:t})}be.current=a;const l=a.find(e=>e.key===n)??a[0];l&&(C({type:e,idx:t,startX:r.clientX,startY:r.clientY,origX:l.origX,origY:l.origY}),r.preventDefault())};ht(()=>{if(!N)return;const e=be.current,t=1===e.length&&"item"===e[0].type,r=()=>{if(!t)return null;const r=ue[e[0].idx];return"page"===r?.entityType?r.entityId:null},n=()=>document.querySelector("[data-taskbar-dropzone]"),o=(e,t)=>{const r=n();if(!r)return!1;const o=r.getBoundingClientRect();return e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom},a=e=>{const t=n();t&&(t.style.outline=e?"2px solid var(--accent-600, #7c3aed)":"",t.style.outlineOffset=e?"-2px":"")},l=n=>{const l=n.clientX-N.startX,i=n.clientY-N.startY;for(const t of e)t.el&&(t.el.style.right=t.origX-l+"px","trash"===t.type?t.el.style.bottom=t.origY-i+"px":(t.el.style.top=`${t.origY+i}px`,t.el.style.left="auto"),t.el.style.zIndex="100",t.el.style.opacity="0.7");if(t){const e=document.elementsFromPoint(n.clientX,n.clientY);let t=null;for(const r of e){const e=r.closest?.('[data-desktop-icon^="folder-"]');if(e){const r=e.getAttribute("data-desktop-icon");r&&(t=parseInt(r.slice(7),10));break}}oe.current=t,ne(e=>e===t?e:t),a(null!=r()&&o(n.clientX,n.clientY))}},i=t=>{const n=t.clientX-N.startX,l=t.clientY-N.startY;for(const t of e)t.el&&(t.el.style.zIndex="",t.el.style.opacity="");const i=r();if(i&&o(t.clientX,t.clientY)){a(!1);for(const t of e)t.el&&(t.el.style.left="auto",t.el.style.right=`${t.origX}px`,t.el.style.top=`${t.origY}px`);const t=Array.isArray(c.favorite_pages)?c.favorite_pages:[];return t.includes(i)||d({favorite_pages:[...t,i]}),oe.current=null,ne(null),C(null),void(be.current=[])}a(!1);const s=oe.current,u=null!=s?p[s]:null;oe.current=null,ne(null);const h=e.filter(e=>"trash"!==e.type).map(e=>{let t=e.origX-n,r=Math.max(0,e.origY+l);if(g){const e=(o=t,a=r,{x:Math.round(o/jr)*jr,y:Math.round(a/jr)*jr});t=e.x,r=e.y}var o,a;return t=Math.max(0,t),{entry:e,finalRight:t,finalTop:r}}),f=e.find(e=>"trash"===e.type);f&&d({desktop_trash_position:{right:Math.max(0,f.origX-n),bottom:Math.max(0,f.origY-l)}});const y=h.filter(e=>"item"===e.entry.type);if(y.length>0){const t=[...m],r={},n=1===y.length&&1===e.length?y[0]:null,o=n?u??p.find((e,t)=>{const r=de(e,t);return Math.abs(n.finalRight-r.right)<40&&Math.abs(n.finalTop-r.top)<40}):void 0;if(o&&n?.entry.el){const e=n.entry.el,t=p.indexOf(o),r=document.querySelector(`[data-desktop-icon="folder-${t}"]`);if(r){const t=e.getBoundingClientRect(),n=r.getBoundingClientRect(),o=n.left+n.width/2-(t.left+t.width/2),a=n.top+n.height/2-(t.top+t.height/2);e.style.transition="transform 220ms ease-out, opacity 220ms ease-out",e.style.transform=`translate(${o}px, ${a}px) scale(0.2)`,e.style.opacity="0"}r?.animate([{transform:"scale(1)"},{transform:"scale(1.15)"},{transform:"scale(1)"}],{duration:280,easing:"ease-out"})}for(const e of y){const n=m.indexOf(ue[e.entry.idx]);-1!==n&&(o?t[n]={...t[n],folderId:o.id,x:void 0,y:void 0,folderX:void 0,folderY:void 0}:(t[n]={...t[n],x:e.finalRight,y:e.finalTop,folderId:void 0},r[`item-${n}`]={right:e.finalRight,top:e.finalTop}))}const a=()=>{ae(t),Object.keys(r).length>0&&ye(e=>({...e,...r}))};o?setTimeout(a,220):a()}const b=h.filter(e=>"folder"===e.entry.type);if(b.length>0){const e=[...p],t={};for(const r of b)e[r.entry.idx]={...e[r.entry.idx],x:r.finalRight,y:r.finalTop},t[`folder-${r.entry.idx}`]={right:r.finalRight,top:r.finalTop};le(e),ye(e=>({...e,...t}))}C(null),be.current=[]};return window.addEventListener("pointermove",l),window.addEventListener("pointerup",i),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",i)}},[N,g,m,p,ue,c]);const we=JSON.stringify(m.map(e=>`${e.entityId}:${e.x??""}:${e.y??""}:${e.folderId??""}`)),ve=JSON.stringify(p.map(e=>`${e.id}:${e.x??""}:${e.y??""}`));ht(()=>{ye({})},[we,ve]),ht(()=>{const{folders:e,favDocs:t}=ie.current,r={};for(const t of e)r[t.id]=[];for(const e of t)e.folderId&&r[e.folderId]&&r[e.folderId].push(e);F({folders:e.map(e=>({id:e.id,name:e.name,itemCount:r[e.id]?.length??0})),itemsByFolder:r,moveToDesktop:pe,removeShortcuts:ge})},[we,ve,pe,ge]),ht(()=>()=>F(null),[]);const ke=pt(!1);ht(()=>{if(!E)return;const e=e=>{const t=s.current?.getBoundingClientRect();if(!t)return;const r=e.clientX-t.left,n=e.clientY-t.top,o=r-E.startX,a=n-E.startY;if(o*o+a*a>16&&(ke.current=!0),P(e=>e?{...e,endX:r,endY:n}:null),ke.current){const e=Math.min(E.startX,r),t=Math.max(E.startX,r),o=Math.min(E.startY,n),a=Math.max(E.startY,n);L(((e,t,r,n)=>{const o=/* @__PURE__ */new Set,a=s.current?.clientWidth||800;ue.forEach((l,i)=>{const s=ce(l,i),c=a-s.right-80;c+40>e&&c<t&&s.top+40>r&&s.top<n&&o.add(`item-${i}`)}),p.forEach((l,i)=>{const s=de(l,i),c=a-s.right-80;c+40>e&&c<t&&s.top+40>r&&s.top<n&&o.add(`folder-${i}`)});const l=s.current?.querySelector('[data-desktop-icon="trash"]'),i=s.current?.getBoundingClientRect();if(l&&i){const a=l.getBoundingClientRect(),s=a.left-i.left,c=a.top-i.top;s+a.width>e&&s<t&&c+a.height>r&&c<n&&o.add("trash")}return o})(e,t,o,a))}},t=()=>{P(null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[E]);ht(()=>{if(!M)return;const e=()=>S(null);return window.addEventListener("click",e),()=>window.removeEventListener("click",e)},[M]);const Ne=(e,t)=>{le(p.map(r=>r.id===e?{...r,name:t}:r)),B(null)},Ce=gt(e=>{b.saveNotes?b.saveNotes(e):d({notepad_notes:e})},[b,d]),Me=(e,t)=>{Ce(f.map(r=>r.id===e?{...r,content:t,updated_at:/* @__PURE__ */(new Date).toISOString()}:r))};ht(()=>{if(!G)return;const e=e=>{const t=document.querySelector(`[data-sticky-id="${G.id}"]`);t&&(t.style.left=G.origX+e.clientX-G.startX+"px",t.style.right="auto",t.style.top=G.origY+e.clientY-G.startY+"px")},t=e=>{const t=G.origX+e.clientX-G.startX,r=Math.max(0,G.origY+e.clientY-G.startY),n=document.querySelector(`[data-sticky-id="${G.id}"]`),o=n?.offsetWidth??192,a=t+o/2>window.innerWidth/2?"right":"left",l="right"===a?window.innerWidth-t-o:t;Ce(f.map(e=>e.id===G.id?{...e,sticky_x:l,sticky_y:r,sticky_anchor:a}:e)),n&&(n.style.left="",n.style.right=""),Q(null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[G,f]),ht(()=>{if(!Z)return;const e=e=>{const t=document.querySelector(`[data-sticky-id="${Z.id}"]`);t&&(t.style.width=`${Math.max(140,Z.origW+e.clientX-Z.startX)}px`,t.style.height=`${Math.max(100,Z.origH+e.clientY-Z.startY)}px`)},t=e=>{const t=Math.max(140,Z.origW+e.clientX-Z.startX),r=Math.max(100,Z.origH+e.clientY-Z.startY);Ce(f.map(e=>e.id===Z.id?{...e,sticky_w:t,sticky_h:r}:e)),te(null)};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[Z,f]);const Se={yellow:"bg-yellow-100 border-yellow-300",blue:"bg-blue-100 border-blue-300",green:"bg-green-100 border-green-300",pink:"bg-pink-100 border-pink-300",purple:"bg-purple-100 border-purple-300",orange:"bg-orange-100 border-orange-300"},_e=(e,t,r,n,o)=>/* @__PURE__ */St("div",{className:"flex flex-col items-center gap-1 w-20 p-2",children:[
119
119
  /* @__PURE__ */_t(V,{entityType:e,isSelected:r,entityId:n,label:t,fileKind:o}),
120
120
  /* @__PURE__ */_t("span",{className:"text-[10px] font-medium text-center leading-tight w-full drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)] "+(r?"text-blue-200 bg-blue-600/60 rounded px-1":"text-white"),children:t})]}),Le=(e,t)=>({...e+180>window.innerWidth?{right:window.innerWidth-e}:{left:e},...t+250>window.innerHeight?{bottom:window.innerHeight-t}:{top:t}});/* @__PURE__ */
121
121
  return St("div",{ref:s,className:"flex-1 relative overflow-hidden",onPointerDown:e=>{if(0!==e.button||e.target!==s.current)return;const t=s.current.getBoundingClientRect(),r=e.clientX-t.left,n=e.clientY-t.top;P({startX:r,startY:n,endX:r,endY:n}),ke.current=!1,L(/* @__PURE__ */new Set)},onContextMenu:e=>{e.preventDefault(),S({x:e.clientX,y:e.clientY})},onClick:()=>{ke.current?ke.current=!1:(L(/* @__PURE__ */new Set),S(null))},children:[(()=>{const e=Fr(),t=20+("right"===e.position?e.width:0),r=20+("bottom"===e.position?e.height:0),n=u.desktop_trash_position,o=n?.right??t,a=n?.bottom??r,l=_.has("trash");/* @__PURE__ */
@@ -124,7 +124,7 @@ return _t("div",{"data-desktop-icon":"trash",style:{position:"absolute",right:o,
124
124
  /* @__PURE__ */_t("span",{className:"text-[10px] font-medium text-center leading-tight drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)] "+(l?"text-blue-200 bg-blue-600/60 rounded px-1":"text-white"),children:"Trash"})]})})})(),ue.map((e,t)=>{const r=m.indexOf(e),n=fe[`item-${r}`]||ce(e,t),o=_.has(`item-${t}`);/* @__PURE__ */
125
125
  return _t("div",{"data-desktop-icon":`item-${t}`,style:{position:"absolute",right:n.right,top:n.top,zIndex:1},onPointerDown:e=>{e.stopPropagation(),xe("item",t,e)},onClick:e=>{e.stopPropagation(),e.shiftKey||e.metaKey||e.ctrlKey?L(e=>{const r=new Set(e);return r.has(`item-${t}`)?r.delete(`item-${t}`):r.add(`item-${t}`),r}):_.has(`item-${t}`)||L(/* @__PURE__ */new Set([`item-${t}`]))},onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),S({x:e.clientX,y:e.clientY,itemIdx:t})})(e,t),onDoubleClick:t=>{t.stopPropagation(),me(e)},className:"cursor-default select-none",children:_e(e.entityType,e.label,o,e.entityId,e.fileKind)},`item-${e.entityType}-${e.entityId}-${t}`)}),p.map((e,t)=>{const r=fe[`folder-${t}`]||de(e,t),n=_.has(`folder-${t}`),o=re===t,a=(l=e.id,m.filter(e=>e.folderId===l)).length;var l;/* @__PURE__ */
126
126
  return _t("div",{"data-desktop-icon":`folder-${t}`,style:{position:"absolute",right:r.right,top:r.top,zIndex:1,transform:o?"scale(1.15)":"scale(1)",transition:"transform 180ms ease-out"},onPointerDown:e=>{e.stopPropagation(),xe("folder",t,e)},onClick:e=>{e.stopPropagation(),e.shiftKey||e.metaKey||e.ctrlKey?L(e=>{const r=new Set(e);return r.has(`folder-${t}`)?r.delete(`folder-${t}`):r.add(`folder-${t}`),r}):_.has(`folder-${t}`)||L(/* @__PURE__ */new Set([`folder-${t}`]))},onContextMenu:e=>((e,t)=>{e.preventDefault(),e.stopPropagation(),S({x:e.clientX,y:e.clientY,folderIdx:t})})(e,t),onDoubleClick:t=>{t.stopPropagation(),he(e.id)},className:"cursor-default select-none",children:/* @__PURE__ */St("div",{className:"flex flex-col items-center gap-1 w-20 p-2",children:[
127
- /* @__PURE__ */_t("div",{className:`w-12 h-12 flex items-center justify-center ${n?"rounded-lg bg-blue-400/30 ring-2 ring-blue-500":""} ${o?"rounded-lg ring-4 ring-amber-400 shadow-[0_0_20px_rgba(245,158,11,0.6)]":""}`,children:/* @__PURE__ */_t(O,{className:"h-12 w-12 text-amber-500 drop-shadow-[0_2px_3px_rgba(0,0,0,0.3)]"})}),B===e.id?/* @__PURE__ */_t("input",{autoFocus:!0,value:W,onChange:e=>K(e.target.value),onBlur:()=>Ne(e.id,W),onKeyDown:t=>{"Enter"===t.key&&Ne(e.id,W),"Escape"===t.key&&R(null)},className:"text-[10px] w-full text-center bg-white/80 rounded px-1 outline-none",onClick:e=>e.stopPropagation()}):/* @__PURE__ */St("span",{className:"text-[10px] font-medium text-center leading-tight w-full drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)] "+(n?"text-blue-200 bg-blue-600/60 rounded px-1":"text-white"),children:[e.name,a>0?` (${a})`:""]})]})},`folder-${e.id}`)}),y.map(e=>{const t=e.sticky_x??100,r=e.sticky_y??100,n=e.sticky_w??192,o=e.sticky_h??148,a=e.sticky_anchor||"left",l=Se[e.color]||Se.yellow,i=Y===e.id;/* @__PURE__ */
127
+ /* @__PURE__ */_t("div",{className:`w-12 h-12 flex items-center justify-center ${n?"rounded-lg bg-blue-400/30 ring-2 ring-blue-500":""} ${o?"rounded-lg ring-4 ring-amber-400 shadow-[0_0_20px_rgba(245,158,11,0.6)]":""}`,children:/* @__PURE__ */_t(O,{className:"h-12 w-12 text-amber-500 drop-shadow-[0_2px_3px_rgba(0,0,0,0.3)]"})}),R===e.id?/* @__PURE__ */_t("input",{autoFocus:!0,value:W,onChange:e=>K(e.target.value),onBlur:()=>Ne(e.id,W),onKeyDown:t=>{"Enter"===t.key&&Ne(e.id,W),"Escape"===t.key&&B(null)},className:"text-[10px] w-full text-center bg-white/80 rounded px-1 outline-none",onClick:e=>e.stopPropagation()}):/* @__PURE__ */St("span",{className:"text-[10px] font-medium text-center leading-tight w-full drop-shadow-[0_1px_2px_rgba(0,0,0,0.8)] "+(n?"text-blue-200 bg-blue-600/60 rounded px-1":"text-white"),children:[e.name,a>0?` (${a})`:""]})]})},`folder-${e.id}`)}),y.map(e=>{const t=e.sticky_x??100,r=e.sticky_y??100,n=e.sticky_w??192,o=e.sticky_h??148,a=e.sticky_anchor||"left",l=Se[e.color]||Se.yellow,i=Y===e.id;/* @__PURE__ */
128
128
  return St("div",{"data-sticky-id":e.id,style:{position:"absolute",..."right"===a?{right:t}:{left:t},top:r,width:n,height:o,zIndex:e.sticky_on_top?200:i?50:10},onClick:e=>e.stopPropagation(),className:`rounded-lg shadow-lg border ${l} select-none flex flex-col`,children:[
129
129
  /* @__PURE__ */St("div",{className:"flex items-center justify-between px-2 py-1 cursor-move border-b border-black/5",onPointerDown:o=>{if(0!==o.button)return;o.preventDefault(),o.stopPropagation();const l=o.target.closest("[data-sticky-id]"),i=l?l.getBoundingClientRect().left-(s.current?.getBoundingClientRect().left??0):"right"===a?window.innerWidth-t-n:t;Q({id:e.id,startX:o.clientX,startY:o.clientY,origX:i,origY:r})},children:[
130
130
  /* @__PURE__ */_t("div",{className:"flex items-center gap-1",children:/* @__PURE__ */_t("button",{onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),(e=>{const t=["yellow","blue","green","pink","purple","orange"],r=f.find(t=>t.id===e);if(!r)return;const n=t.indexOf(r.color),o=t[(n+1)%t.length];Ce(f.map(t=>t.id===e?{...t,color:o}:t))})(e.id)},title:"Change color",className:"w-3 h-3 rounded-full bg-black/10 hover:bg-black/20 transition-colors"})}),
@@ -142,7 +142,7 @@ return St("div",{"data-sticky-id":e.id,style:{position:"absolute",..."right"===a
142
142
  /* @__PURE__ */St("svg",{className:"h-4 w-4 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24",children:[
143
143
  /* @__PURE__ */_t("path",{d:"M4 4a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",opacity:"0.8"}),
144
144
  /* @__PURE__ */_t("path",{d:"M14 14v4a2 2 0 01-2 2H6a2 2 0 01-2-2v-6",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),"New Sticky Note"]}),
145
- /* @__PURE__ */St(Xe,{onClick:()=>{const e=s.current?.getBoundingClientRect(),t=e?.width??0,r=M?M.x-(e?.left??0):t-100,n=M?M.y-(e?.top??0):100,o=Math.max(0,t-r-40),a=Math.max(0,n-20),l=`folder-${Date.now()}`;le([...p,{id:l,name:"New Folder",x:o,y:a}]),S(null),R(l),K("New Folder")},children:[
145
+ /* @__PURE__ */St(Xe,{onClick:()=>{const e=s.current?.getBoundingClientRect(),t=e?.width??0,r=M?M.x-(e?.left??0):t-100,n=M?M.y-(e?.top??0):100,o=Math.max(0,t-r-40),a=Math.max(0,n-20),l=`folder-${Date.now()}`;le([...p,{id:l,name:"New Folder",x:o,y:a}]),S(null),B(l),K("New Folder")},children:[
146
146
  /* @__PURE__ */_t("svg",{className:"h-4 w-4 text-yellow-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"})}),"Create Folder"]}),
147
147
  /* @__PURE__ */St(Xe,{onClick:()=>{const e=s.current?.getBoundingClientRect(),t=e?.height||600,r=Math.max(1,Math.floor(t/jr));let n=0;const o=()=>{const e=Math.floor(n/r),t=n%r;return n++,{right:20+e*jr,top:10+t*jr}},a=p.map(e=>{const t=o();return{...e,x:t.right,y:t.top}});le(a);const l=m.map(e=>{if(e.folderId)return e;const t=o();return{...e,x:t.right,y:t.top}});ae(l),S(null)},children:[
148
148
  /* @__PURE__ */_t("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z"})}),"Snap to Grid"]}),
@@ -163,7 +163,7 @@ return St("div",{"data-sticky-id":e.id,style:{position:"absolute",..."right"===a
163
163
  /* @__PURE__ */_t(Ke,{}),
164
164
  /* @__PURE__ */_t(Xe,{danger:!0,onClick:()=>(e=>{const t=m.indexOf(ue[e]);ae(m.filter((e,r)=>r!==t)),S(null)})(M.itemIdx),children:"Remove Shortcut"})]}),M&&null!=M.folderIdx&&/* @__PURE__ */St(Ve,{style:Le(M.x,M.y),minWidth:160,children:[
165
165
  /* @__PURE__ */_t(Xe,{onClick:()=>{he(p[M.folderIdx].id),S(null)},children:"Open"}),p[M.folderIdx].id!==Dr&&/* @__PURE__ */St(Lt,{children:[
166
- /* @__PURE__ */_t(Xe,{onClick:()=>{R(p[M.folderIdx].id),K(p[M.folderIdx].name),S(null)},children:"Rename"}),
166
+ /* @__PURE__ */_t(Xe,{onClick:()=>{B(p[M.folderIdx].id),K(p[M.folderIdx].name),S(null)},children:"Rename"}),
167
167
  /* @__PURE__ */_t(Ke,{}),
168
168
  /* @__PURE__ */_t(Xe,{danger:!0,onClick:()=>(e=>{const t=p[e];if(t.id===Dr)return;const r=m.map(e=>e.folderId===t.id?{...e,folderId:void 0}:e);ae(r),le(p.filter((t,r)=>r!==e)),S(null)})(M.folderIdx),children:"Delete Folder"})]})]}),
169
169
  /* @__PURE__ */_t(rr,{open:A,onClose:()=>j(!1)}),T&&(()=>{const e=b.productVersion??X;/* @__PURE__ */
@@ -203,7 +203,7 @@ return _t(ee,{open:!0,onClose:()=>D(!1),title:t.about.whatsNew,size:"md",childre
203
203
  /* @__PURE__ */_t("h1",{className:"text-2xl font-bold tracking-[0.3em] text-white/90 uppercase",children:s.logout.goodbye}),
204
204
  /* @__PURE__ */_t("p",{className:"mt-2 text-xs text-white/40",children:s.logout.seeYou})]}),t&&/* @__PURE__ */_t("div",{className:"absolute bottom-8 transition-all duration-500 "+("show"===l?"opacity-40":"opacity-0"),children:/* @__PURE__ */_t("p",{className:"text-[10px] text-white/40 font-mono tracking-wider",children:t})}),
205
205
  /* @__PURE__ */_t("style",{children:"\n @keyframes logout-glow {\n 0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.15; }\n 50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.25; }\n }\n /* Reduced motion: same contract as StartupAnimation — fades stay,\n * movement goes, the 2300ms cover-and-swap timing is untouched. */\n @media (prefers-reduced-motion: reduce) {\n [data-logout-animation], [data-logout-animation] * {\n animation: none !important;\n transition-property: opacity !important;\n }\n }\n "})]})}function Vr(e,t){return e.length===t.length&&e.every((e,r)=>e.type===t[r].type&&e.route===t[r].route&&e.entityType===t[r].entityType&&e.entityId===t[r].entityId&&e.label===t[r].label)}function Kr(){const{openWindows:e,openEntity:t,openPage:r}=J(),{prefs:n,save:o}=Te(),a=pt(!1),l=pt([]),i=pt(null),s=pt(0),c=pt(void 0);return ht(()=>{if(a.current)return;a.current=!0;const o=Array.isArray(n.session_windows)?n.session_windows:[];if(l.current=o,!1!==n.restore_windows&&!(e.length>0))for(const e of o)"page"===e.type&&e.route?r(e.route):"entity"===e.type&&e.entityType&&e.entityId&&!ue(e.entityId)&&t(e.entityType,e.entityId,void 0,e.label,e.route)},[]),ht(()=>{if(!a.current)return;clearTimeout(c.current);const t=function(e){const t=[];for(const r of e)"page"===r.type&&r.route?t.push({type:"page",route:r.route}):r.entityType&&r.entityId&&"part_number"!==r.type&&!ge(r)&&t.push({type:"entity",entityType:r.entityType,entityId:r.entityId,label:r.label,route:r.route});return t}(e);return Vr(t,l.current)||i.current&&Vr(t,i.current)?void 0:(c.current=setTimeout(()=>{const e=++s.current;i.current=t,Promise.resolve(o({session_windows:t})).then(()=>{e===s.current&&(l.current=t,i.current=null)}).catch(()=>{e===s.current&&(i.current=null)})},800),()=>clearTimeout(c.current))},[e,o]),null}var Ur=e=>e.menuLabel??e.label,Xr=e=>Boolean(e.menuLabel&&e.menuLabel!==e.label),Yr=e=>Xr(e)?`${e.menuLabel}, ${e.label}`:void 0;function qr({entry:e,className:t}){const r=Xr(e),[n,o]=mt(r);/* @__PURE__ */
206
- return _t("span",{className:t,title:n?e.label:void 0,"data-menu-label":!0,onMouseEnter:e=>o(r||e.currentTarget.scrollWidth>e.currentTarget.clientWidth),children:Ur(e)})}function Gr({left:e,anchorY:t,estHeight:r,minTop:n,maxBottom:o,flipped:a,className:l,style:i,onMouseEnter:s,onMouseLeave:c,children:d}){const u=pt(null);return ft(()=>{const e=u.current;e&&(e.style.top=`${et(t,e.offsetHeight,n,o)}px`)}),/* @__PURE__ */_t("div",{ref:u,"data-menu-panel":!0,className:`fixed rounded-2xl overflow-hidden ${l??""}`,style:{left:e,top:et(t,r,n,o),animation:(a?"submenu-in-left":"submenu-in")+" 0.1s ease-out",...i},onMouseEnter:s,onMouseLeave:c,children:d})}function Jr({open:e,onClose:t,openPage:r,profile:n,user:o,onLogout:a,taskbarPosition:l,taskbarH:i,taskbarW:s=0,taskbarGap:c=4,size:d="medium",navSections:u=De,navIcons:m=je,sectionIcons:h=Re,categories:p=$e}){const g=new Set(p.erp),f=new Set(p.system),y=new Set(p.footer??[]),b=p.virtual??[],x=Object.fromEntries(b.map(e=>[e.label,e])),{hasAnyPerm:w}=A(),v=(p.footerItems??[]).filter(e=>Ie(e,w)),k=Pe(),[N,C]=mt([]),[M,S]=mt(""),[_,L]=mt(0),E=pt(null),P=pt();ht(()=>{e||(S(""),C([]),L(0))},[e]),ht(()=>()=>clearTimeout(P.current),[]);const T=N.length>0?N[N.length-1].key:null;if(ht(()=>{e&&ne("menu","start")},[e]),ht(()=>{T&&ne("submenu",T)},[T]),ht(()=>{if(!e)return;const r=e=>{"Escape"===e.key&&t()},n=e=>{e.target.closest("[data-menu-toggle]")||E.current&&!E.current.contains(e.target)&&t()};return window.addEventListener("keydown",r),window.addEventListener("pointerdown",n),()=>{window.removeEventListener("keydown",r),window.removeEventListener("pointerdown",n)}},[e,t]),!e)return null;const $=e=>{r(e),t()},I=e=>{if(e.onSelect)return e.onSelect(),void t();$(e.to)};if(k){const e=[],r=(t,n)=>{if(Ie(t,w)&&Be(t,w)){e.push({item:t,sectionLabel:n});for(const e of Fe(t,w))r(e,t.label)}};for(const e of u)if(Ae(e)){const t=e;if(!Ie(t,w))continue;for(const e of t.items)r(e,t.label)}else r(e);for(const e of v)r(e);const n=M.length>=1?e.filter(({item:e})=>e.label.toLowerCase().includes(M.toLowerCase())):e;/* @__PURE__ */
206
+ return _t("span",{className:t,title:n?e.label:void 0,"data-menu-label":!0,onMouseEnter:e=>o(r||e.currentTarget.scrollWidth>e.currentTarget.clientWidth),children:Ur(e)})}function Gr({left:e,anchorY:t,estHeight:r,minTop:n,maxBottom:o,flipped:a,className:l,style:i,onMouseEnter:s,onMouseLeave:c,children:d}){const u=pt(null);return ft(()=>{const e=u.current;e&&(e.style.top=`${et(t,e.offsetHeight,n,o)}px`)}),/* @__PURE__ */_t("div",{ref:u,"data-menu-panel":!0,className:`fixed rounded-2xl overflow-hidden ${l??""}`,style:{left:e,top:et(t,r,n,o),animation:(a?"submenu-in-left":"submenu-in")+" 0.1s ease-out",...i},onMouseEnter:s,onMouseLeave:c,children:d})}function Jr({open:e,onClose:t,openPage:r,profile:n,user:o,onLogout:a,taskbarPosition:l,taskbarH:i,taskbarW:s=0,taskbarGap:c=4,size:d="medium",navSections:u=De,navIcons:m=je,sectionIcons:h=Be,categories:p=$e}){const g=new Set(p.erp),f=new Set(p.system),y=new Set(p.footer??[]),b=p.virtual??[],x=Object.fromEntries(b.map(e=>[e.label,e])),{hasAnyPerm:w}=A(),v=(p.footerItems??[]).filter(e=>Ie(e,w)),k=Pe(),[N,C]=mt([]),[M,S]=mt(""),[_,L]=mt(0),E=pt(null),P=pt();ht(()=>{e||(S(""),C([]),L(0))},[e]),ht(()=>()=>clearTimeout(P.current),[]);const T=N.length>0?N[N.length-1].key:null;if(ht(()=>{e&&ne("menu","start")},[e]),ht(()=>{T&&ne("submenu",T)},[T]),ht(()=>{if(!e)return;const r=e=>{"Escape"===e.key&&t()},n=e=>{e.target.closest("[data-menu-toggle]")||E.current&&!E.current.contains(e.target)&&t()};return window.addEventListener("keydown",r),window.addEventListener("pointerdown",n),()=>{window.removeEventListener("keydown",r),window.removeEventListener("pointerdown",n)}},[e,t]),!e)return null;const $=e=>{r(e),t()},I=e=>{if(e.onSelect)return e.onSelect(),void t();$(e.to)};if(k){const e=[],r=(t,n)=>{if(Ie(t,w)&&Re(t,w)){e.push({item:t,sectionLabel:n});for(const e of Fe(t,w))r(e,t.label)}};for(const e of u)if(Ae(e)){const t=e;if(!Ie(t,w))continue;for(const e of t.items)r(e,t.label)}else r(e);for(const e of v)r(e);const n=M.length>=1?e.filter(({item:e})=>e.label.toLowerCase().includes(M.toLowerCase())):e;/* @__PURE__ */
207
207
  return St("div",{ref:E,className:"fixed inset-0 z-[260] flex flex-col bg-white",style:{paddingBottom:"var(--mobile-bottom-nav, 56px)"},children:[
208
208
  /* @__PURE__ */St("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200",children:[
209
209
  /* @__PURE__ */_t("button",{onClick:t,className:"p-2 -ml-1 rounded-full active:bg-gray-200 text-gray-700","aria-label":"Close menu",children:/* @__PURE__ */_t("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),
@@ -214,7 +214,7 @@ return St("div",{ref:E,className:"fixed inset-0 z-[260] flex flex-col bg-white",
214
214
  return St("button",{onClick:()=>I(e),"aria-label":Yr(e),className:"w-full flex items-center gap-3 px-4 py-3 active:bg-gray-100 border-b border-gray-100 text-left",children:[
215
215
  /* @__PURE__ */_t("span",{className:"h-8 w-8 rounded-lg bg-gray-100 flex items-center justify-center text-gray-600 shrink-0",children:n&&xt(n)?wt(n,{className:"h-5 w-5"}):null}),
216
216
  /* @__PURE__ */St("div",{className:"min-w-0 flex-1",children:[
217
- /* @__PURE__ */_t(qr,{entry:e,className:"block truncate text-sm font-medium text-gray-900"}),t&&/* @__PURE__ */_t("div",{className:"text-[11px] text-gray-500 truncate",children:t})]})]},`${e.to}-${r}`)})})]})}const D="bottom"!==l,j=u.filter(e=>!Ae(e)).filter(e=>Ie(e,w)&&Be(e,w)),B=u.filter(e=>Ae(e)&&g.has(e.label)),R=u.filter(e=>Ae(e)&&f.has(e.label)),W=u.filter(e=>Ae(e)&&y.has(e.label)),F=j.length>0||R.length>0||b.length>0,z=e=>e.items.filter(e=>Ie(e,w)),O=e=>Fe(e,w),H=e=>O(e).filter(e=>Be(e,w)),V=(e,t)=>{if(!Ie(e,w))return[];if(!Be(e,w))return[];const r=O(e),n=[];e.label.toLowerCase().includes(M.toLowerCase())&&n.push({...e,section:t});for(const t of r)n.push(...V(t,e.label));return n},K=M.length>=2?[...u.flatMap(e=>{if(Ae(e)){const t=e;return t.items.flatMap(e=>V(e,t.label))}return V(e,"")}),...v.flatMap(e=>V(e,""))]:[],U="top"===l?{top:i+c,left:8}:"left"===l?{top:8,left:s+c}:"right"===l?{top:8,right:s+c}:{bottom:i+c,left:8},X=e=>{const t=m[e];return t&&xt(t)?wt(t,{className:"h-4 w-4 shrink-0"}):null},Y=e=>{const t=h[e];return t&&xt(t)?wt(t,{className:"h-4 w-4 shrink-0"}):null},q=N.length>0?N[0].key:null,G=q?x[q]:void 0,J=G?null:q?[...B,...R,...W].find(e=>e.label===q):null,Q=(G?G.items:J?z(J):[]).filter(e=>Be(e,w)),Z="undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--menu-density")?.trim()||"normal",ee={tight:{small:{w:"w-52",fw:"w-44",fwPx:176,text:"text-xs",py:"py-1",px:"px-3",mw:208,itemH:24},medium:{w:"w-56",fw:"w-48",fwPx:192,text:"text-xs",py:"py-1",px:"px-3",mw:224,itemH:26},large:{w:"w-64",fw:"w-52",fwPx:208,text:"text-sm",py:"py-1.5",px:"px-3",mw:256,itemH:30}},normal:{small:{w:"w-56",fw:"w-48",fwPx:192,text:"text-xs",py:"py-1.5",px:"px-3",mw:224,itemH:30},medium:{w:"w-64",fw:"w-56",fwPx:224,text:"text-sm",py:"py-1.5",px:"px-4",mw:256,itemH:32},large:{w:"w-72",fw:"w-60",fwPx:240,text:"text-sm",py:"py-2",px:"px-4",mw:288,itemH:36}},large:{small:{w:"w-56",fw:"w-48",fwPx:192,text:"text-xs",py:"py-2",px:"px-3",mw:224,itemH:32},medium:{w:"w-64",fw:"w-56",fwPx:224,text:"text-sm",py:"py-2",px:"px-4",mw:256,itemH:36},large:{w:"w-72",fw:"w-60",fwPx:240,text:"text-sm",py:"py-2",px:"px-4",mw:288,itemH:36}}}["tight"===Z||"large"===Z?Z:"normal"][d],te=it(),re=`w-full min-w-0 overflow-hidden whitespace-nowrap flex items-center gap-2 rounded-lg ${ee.px} ${ee.py} ${ee.text}`,oe="min-w-0 flex-1 truncate text-left",ae="undefined"!=typeof window?window.innerHeight:800,le="undefined"!=typeof window?window.innerWidth:1280,ie=("top"===l?i:0)+8,se=ae-("bottom"===l?i:0)-8,ce=Math.max(0,se-ie),de=Ye(Q,N,H),ue=()=>clearTimeout(P.current),me=(e,t)=>{const r=t.closest("[data-menu-panel]");if(!r)return{left:0,flipped:!1};const n=0===e?r.getBoundingClientRect().left:N[e-1]?.left??0,o=0===e?r.getBoundingClientRect().right:n+r.offsetWidth,a=e>0&&(N[e-1]?.flipped??!1);return tt(n,o,ee.fwPx,le,4,a)},he=(e,t,r)=>{ue();const n=r.currentTarget,o=n.getBoundingClientRect(),a={key:t,y:o.top+o.height/2,...me(e,n)};C(t=>Qe(t,e,a))},pe=e=>{ue(),P.current=setTimeout(()=>C(t=>Ze(t,e)),200)},ge=/* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5 shrink-0 ml-auto text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),fe=(e,t)=>{if(!Ie(e,w))return null;if(0===z(e).length)return null;const r=q===e.label;/* @__PURE__ */
217
+ /* @__PURE__ */_t(qr,{entry:e,className:"block truncate text-sm font-medium text-gray-900"}),t&&/* @__PURE__ */_t("div",{className:"text-[11px] text-gray-500 truncate",children:t})]})]},`${e.to}-${r}`)})})]})}const D="bottom"!==l,j=u.filter(e=>!Ae(e)).filter(e=>Ie(e,w)&&Re(e,w)),R=u.filter(e=>Ae(e)&&g.has(e.label)),B=u.filter(e=>Ae(e)&&f.has(e.label)),W=u.filter(e=>Ae(e)&&y.has(e.label)),F=j.length>0||B.length>0||b.length>0,z=e=>e.items.filter(e=>Ie(e,w)),O=e=>Fe(e,w),H=e=>O(e).filter(e=>Re(e,w)),V=(e,t)=>{if(!Ie(e,w))return[];if(!Re(e,w))return[];const r=O(e),n=[];e.label.toLowerCase().includes(M.toLowerCase())&&n.push({...e,section:t});for(const t of r)n.push(...V(t,e.label));return n},K=M.length>=2?[...u.flatMap(e=>{if(Ae(e)){const t=e;return t.items.flatMap(e=>V(e,t.label))}return V(e,"")}),...v.flatMap(e=>V(e,""))]:[],U="top"===l?{top:i+c,left:8}:"left"===l?{top:8,left:s+c}:"right"===l?{top:8,right:s+c}:{bottom:i+c,left:8},X=e=>{const t=m[e];return t&&xt(t)?wt(t,{className:"h-4 w-4 shrink-0"}):null},Y=e=>{const t=h[e];return t&&xt(t)?wt(t,{className:"h-4 w-4 shrink-0"}):null},q=N.length>0?N[0].key:null,G=q?x[q]:void 0,J=G?null:q?[...R,...B,...W].find(e=>e.label===q):null,Q=(G?G.items:J?z(J):[]).filter(e=>Re(e,w)),Z="undefined"!=typeof document&&getComputedStyle(document.documentElement).getPropertyValue("--menu-density")?.trim()||"normal",ee={tight:{small:{w:"w-52",fw:"w-44",fwPx:176,text:"text-xs",py:"py-1",px:"px-3",mw:208,itemH:24},medium:{w:"w-56",fw:"w-48",fwPx:192,text:"text-xs",py:"py-1",px:"px-3",mw:224,itemH:26},large:{w:"w-64",fw:"w-52",fwPx:208,text:"text-sm",py:"py-1.5",px:"px-3",mw:256,itemH:30}},normal:{small:{w:"w-56",fw:"w-48",fwPx:192,text:"text-xs",py:"py-1.5",px:"px-3",mw:224,itemH:30},medium:{w:"w-64",fw:"w-56",fwPx:224,text:"text-sm",py:"py-1.5",px:"px-4",mw:256,itemH:32},large:{w:"w-72",fw:"w-60",fwPx:240,text:"text-sm",py:"py-2",px:"px-4",mw:288,itemH:36}},large:{small:{w:"w-56",fw:"w-48",fwPx:192,text:"text-xs",py:"py-2",px:"px-3",mw:224,itemH:32},medium:{w:"w-64",fw:"w-56",fwPx:224,text:"text-sm",py:"py-2",px:"px-4",mw:256,itemH:36},large:{w:"w-72",fw:"w-60",fwPx:240,text:"text-sm",py:"py-2",px:"px-4",mw:288,itemH:36}}}["tight"===Z||"large"===Z?Z:"normal"][d],te=it(),re=`w-full min-w-0 overflow-hidden whitespace-nowrap flex items-center gap-2 rounded-lg ${ee.px} ${ee.py} ${ee.text}`,oe="min-w-0 flex-1 truncate text-left",ae="undefined"!=typeof window?window.innerHeight:800,le="undefined"!=typeof window?window.innerWidth:1280,ie=("top"===l?i:0)+8,se=ae-("bottom"===l?i:0)-8,ce=Math.max(0,se-ie),de=Ye(Q,N,H),ue=()=>clearTimeout(P.current),me=(e,t)=>{const r=t.closest("[data-menu-panel]");if(!r)return{left:0,flipped:!1};const n=0===e?r.getBoundingClientRect().left:N[e-1]?.left??0,o=0===e?r.getBoundingClientRect().right:n+r.offsetWidth,a=e>0&&(N[e-1]?.flipped??!1);return tt(n,o,ee.fwPx,le,4,a)},he=(e,t,r)=>{ue();const n=r.currentTarget,o=n.getBoundingClientRect(),a={key:t,y:o.top+o.height/2,...me(e,n)};C(t=>Qe(t,e,a))},pe=e=>{ue(),P.current=setTimeout(()=>C(t=>Ze(t,e)),200)},ge=/* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5 shrink-0 ml-auto text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})}),fe=(e,t)=>{if(!Ie(e,w))return null;if(0===z(e).length)return null;const r=q===e.label;/* @__PURE__ */
218
218
  return St("div",{onMouseEnter:t=>he(0,e.label,t),children:[
219
219
  /* @__PURE__ */St("button",{"aria-label":Yr(e),className:`${re} transition-colors ${r?"bg-blue-50 text-blue-700":"text-gray-700 hover:bg-blue-50 hover:text-blue-700"}`,children:[Y(e.label),
220
220
  /* @__PURE__ */_t(qr,{entry:e,className:`${oe} ${t?"font-medium":""}`}),ge]}),e.dividerAfter&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"})]},e.label)},ye=e=>{if(0===e.items.length)return null;const t=q===e.label;/* @__PURE__ */
@@ -229,11 +229,11 @@ return St("div",{ref:E,className:"fixed z-[1100]",style:U,children:[
229
229
  /* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5 text-gray-400 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"})}),
230
230
  /* @__PURE__ */_t("input",{value:M,onChange:e=>{S(e.target.value),C([]),L(0)},onKeyDown:e=>{M.length>=2&&K.length>0&&("ArrowDown"===e.key?(e.preventDefault(),L(e=>Math.min(e+1,K.length-1))):"ArrowUp"===e.key?(e.preventDefault(),L(e=>Math.max(e-1,0))):"Enter"===e.key&&(e.preventDefault(),I(K[_])))},placeholder:"Search...",className:"flex-1 bg-transparent text-xs outline-none placeholder-gray-400",autoFocus:!0})]})}),M.length>=2?/* @__PURE__ */_t("div",{className:"flex-1 overflow-y-auto overflow-x-hidden px-1 pb-2 max-h-[400px]",children:0===K.length?/* @__PURE__ */_t("p",{className:"text-xs text-gray-400 text-center py-4",children:"No results"}):K.map((e,t)=>/* @__PURE__ */St("button",{onClick:()=>I(e),onMouseEnter:()=>L(t),"aria-label":Yr(e),className:`${re} transition-colors ${t===_?"bg-blue-50 text-blue-700":"text-gray-700 hover:bg-blue-50 hover:text-blue-700"}`,children:[X(e.to),
231
231
  /* @__PURE__ */_t(qr,{entry:e,className:oe}),e.section&&/* @__PURE__ */_t("span",{className:"max-w-[40%] shrink-0 truncate text-[10px] text-gray-400 ml-auto",children:e.section})]},t))}):/* @__PURE__ */St("div",{className:"flex-1 overflow-y-auto overflow-x-hidden px-1 pb-1 flex flex-col",children:[D&&/* @__PURE__ */St(Lt,{children:[v.map(e=>/* @__PURE__ */St("button",{onClick:()=>I(e),onMouseEnter:()=>pe(0),"aria-label":Yr(e),className:`${re} text-gray-700 hover:bg-blue-50 hover:text-blue-700 transition-colors`,children:[X(e.to),
232
- /* @__PURE__ */_t(qr,{entry:e,className:oe})]},e.to)),W.map(e=>fe(e,!1)),(W.length>0||v.length>0)&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),B.map(e=>fe(e,!0)),B.length>0&&F&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),j.map(e=>/* @__PURE__ */St("div",{onMouseEnter:()=>pe(0),children:[
232
+ /* @__PURE__ */_t(qr,{entry:e,className:oe})]},e.to)),W.map(e=>fe(e,!1)),(W.length>0||v.length>0)&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),R.map(e=>fe(e,!0)),R.length>0&&F&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),j.map(e=>/* @__PURE__ */St("div",{onMouseEnter:()=>pe(0),children:[
233
233
  /* @__PURE__ */St("button",{onClick:()=>I(e),"aria-label":Yr(e),className:`${re} text-gray-700 hover:bg-blue-50 hover:text-blue-700 transition-colors`,children:[X(e.to),
234
- /* @__PURE__ */_t(qr,{entry:e,className:oe})]}),e.dividerAfter&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"})]},e.to)),R.map(e=>fe(e,!1)),b.map(e=>ye(e))]}),!D&&/* @__PURE__ */St(Lt,{children:[j.map(e=>/* @__PURE__ */St("div",{onMouseEnter:()=>pe(0),children:[
234
+ /* @__PURE__ */_t(qr,{entry:e,className:oe})]}),e.dividerAfter&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"})]},e.to)),B.map(e=>fe(e,!1)),b.map(e=>ye(e))]}),!D&&/* @__PURE__ */St(Lt,{children:[j.map(e=>/* @__PURE__ */St("div",{onMouseEnter:()=>pe(0),children:[
235
235
  /* @__PURE__ */St("button",{onClick:()=>I(e),"aria-label":Yr(e),className:`${re} text-gray-700 hover:bg-blue-50 hover:text-blue-700 transition-colors`,children:[X(e.to),
236
- /* @__PURE__ */_t(qr,{entry:e,className:oe})]}),e.dividerAfter&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"})]},e.to)),R.map(e=>fe(e,!1)),b.map(e=>ye(e)),F&&B.length>0&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),B.map(e=>fe(e,!0)),(W.length>0||v.length>0)&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),W.map(e=>fe(e,!1)),v.map(e=>/* @__PURE__ */St("button",{onClick:()=>I(e),onMouseEnter:()=>pe(0),"aria-label":Yr(e),className:`${re} text-gray-700 hover:bg-blue-50 hover:text-blue-700 transition-colors`,children:[X(e.to),
236
+ /* @__PURE__ */_t(qr,{entry:e,className:oe})]}),e.dividerAfter&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"})]},e.to)),B.map(e=>fe(e,!1)),b.map(e=>ye(e)),F&&R.length>0&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),R.map(e=>fe(e,!0)),(W.length>0||v.length>0)&&/* @__PURE__ */_t("div",{className:"border-t border-white/20 my-1.5 mx-2"}),W.map(e=>fe(e,!1)),v.map(e=>/* @__PURE__ */St("button",{onClick:()=>I(e),onMouseEnter:()=>pe(0),"aria-label":Yr(e),className:`${re} text-gray-700 hover:bg-blue-50 hover:text-blue-700 transition-colors`,children:[X(e.to),
237
237
  /* @__PURE__ */_t(qr,{entry:e,className:oe})]},e.to))]})]}),
238
238
  /* @__PURE__ */_t("div",{className:(D?"border-b":"border-t")+" border-white/20 p-1",onMouseEnter:()=>pe(0),children:/* @__PURE__ */St("div",{onClick:()=>$("/profile"),className:"rounded-lg px-2 py-1.5 flex items-center gap-2.5 hover:bg-blue-50 hover:text-blue-700 transition-colors cursor-pointer",children:[n?.avatar_url?/* @__PURE__ */_t("img",{src:n.avatar_url,alt:"",className:"h-8 w-8 rounded-full object-cover border border-white/20 shrink-0"}):/* @__PURE__ */_t("div",{className:"h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-sm font-bold text-blue-700 shrink-0",children:(n?.first_name?.charAt(0)||o?.email?.charAt(0)||"?").toUpperCase()}),
239
239
  /* @__PURE__ */_t("p",{className:"flex-1 min-w-0 text-sm font-medium text-gray-900 truncate",children:n?.first_name?`${n.first_name} ${n.last_name||""}`.trim():o?.email}),
@@ -276,15 +276,15 @@ return _t("button",{onClick:()=>a(e),title:t,onContextMenu:r=>{r.preventDefault(
276
276
  /* @__PURE__ */St(Xe,{onClick:()=>{s(null),a(i.path)},children:[(()=>{const e=o[i.path];return e&&xt(e)?wt(e,{className:"h-4 w-4 text-gray-400"}):/* @__PURE__ */_t("span",{className:"w-4"})})(),"Open ",i.label]}),
277
277
  /* @__PURE__ */_t(Ke,{}),
278
278
  /* @__PURE__ */St(Xe,{danger:!0,onClick:()=>{s(null),l(i.path)},children:[
279
- /* @__PURE__ */_t("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})}),"Remove from Favorites"]})]})]});var d,u}function ln({branding:e,productName:t="efficient-shell",productIcon:r="/favicon.svg",wallpapers:n,navSections:o=De,navIcons:a=je,sectionIcons:s=Re,categories:c=$e,notifications:d,search:u,taskbarTrayLeft:m,clockCalendar:h,mobileApp:p,contextMenu:g=!0}={}){const f=e?.productName??t,y=e?.logo??r,b=e?.tagline,x=e?.adaptiveLogo??!1,w=e?.logoHasAlpha??null,v=e?.logoIsLight??null,k=Wr(),{user:N,logout:M,hasAnyPerm:S}=A(),{openPage:_,openEntity:L,openWindows:E}=J(),[P,T]=mt(!1),$=Pe(),I=N||{};l();const{favorites:D,toggle:B,desktopBg:R}=function(e){const{prefs:t,save:r}=Ee(),n=t.favorite_pages||[],o=gt(e=>{const t=n.includes(e)?n.filter(t=>t!==e):[...n,e];r({favorite_pages:t})},[n,r]),a=e&&e.length>0?e:[],l=pt(a.length>0?a[Math.floor(Math.random()*a.length)]:"none"),i=t.desktop_bg||(a.length>0?"random":"none"),s="random"===i?l.current:i,c=gt(e=>{r({desktop_bg:e})},[r]);return{favorites:n,toggle:o,isFavorite:e=>n.includes(e),desktopBg:s,setDesktopBg:c}}(n??k.wallpapers?.map(e=>e.src)),{prefs:W,save:F}=Ee(),z="sidebar"===W.layout_mode?"sidebar":"classic",O="sidebar"===z,H=O?oe:0,V=W.taskbar_position||"bottom",K=O?"bottom":V,U=W.taskbar_size||"medium",X=W.desktop_dblclick||"deactivate",Y="left"===K||"right"===K,q=Y?0:"small"===U?42:"large"===U?72:56,G=Y?"small"===U?180:"large"===U?260:220:0,Q="small"===U?2:"large"===U?6:4,Z="small"===U?"h-[42px]":"large"===U?"h-[72px]":"h-14",ee="small"===U?"w-[180px]":"large"===U?"w-[260px]":"w-[220px]",te=!!W.reduce_transparency,re=te?1:(W.transparency_taskbar??70)/100,ne=(W.transparency_start_menu??95)/100,ae=(W.transparency_inactive_header??70)/100,le=(W.transparency_inactive_content??80)/100,ie=(W.transparency_active_header??80)/100,se=(W.transparency_active_content??90)/100;ht(()=>{const e=document.documentElement;e.classList.toggle("rosh-reduce-transparency",te),e.style.setProperty("--inactive-header-opacity",String(ae)),e.style.setProperty("--inactive-content-opacity",String(le)),e.style.setProperty("--active-header-opacity",String(ie)),e.style.setProperty("--active-content-opacity",String(se)),e.style.setProperty("--menu-opacity",String(ne)),e.style.setProperty("--taskbar-height",`${q}px`),e.style.setProperty("--taskbar-width",`${G}px`),e.style.setProperty("--taskbar-position",K),e.style.setProperty("--sidebar-width",`${H}px`),e.style.setProperty("--layout-mode",z),window.dispatchEvent(new CustomEvent("react-os-shell:layout-mode-changed")),e.style.setProperty("--default-window-size",W.default_window_size||"large"),e.style.setProperty("--window-position",W.window_position||"cascade"),e.style.setProperty("--menu-density",W.menu_density||"normal");const t={small:{font:"12px",px:"0.75rem",py:"0.25rem",tabW:"150px",tabFont:"11px"},medium:{font:"14px",px:"1rem",py:"0.5rem",tabW:"200px",tabFont:"12px"},large:{font:"15px",px:"1.125rem",py:"0.625rem",tabW:"240px",tabFont:"13px"}},r=t[W.start_menu_size||"medium"]||t.medium;e.style.setProperty("--menu-font-size",r.font),e.style.setProperty("--menu-padding-x",r.px),e.style.setProperty("--menu-padding-y",r.py),e.style.setProperty("--window-tab-width",r.tabW),e.style.setProperty("--window-tab-font-size",r.tabFont)},[te,ae,le,ie,se,q,K,W.default_window_size,W.window_position,W.menu_density,W.start_menu_size,H,z]),ht(()=>{document.documentElement.style.setProperty("--mobile-bottom-nav","0px")},[]);const[ce,de]=mt(!1),[ue,me]=mt(!!document.fullscreenElement),[he,pe]=mt(null),[ge,fe]=mt(!1),ye=gt((e,t)=>{F({[e]:t})},[F]),be=gt(async()=>{if(document.fullscreenElement)navigator.keyboard?.unlock&&navigator.keyboard.unlock(),document.exitFullscreen();else if(await document.documentElement.requestFullscreen(),navigator.keyboard?.lock)try{await navigator.keyboard.lock(["Escape"])}catch{}},[]);ht(()=>{const e=()=>{me(!!document.fullscreenElement),!document.fullscreenElement&&navigator.keyboard?.unlock&&navigator.keyboard.unlock()};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);const xe=pt(!1);ht(()=>{if(!xe.current&&W.auto_fullscreen&&!document.fullscreenElement){xe.current=!0;const e=async()=>{if(!document.fullscreenElement)try{await document.documentElement.requestFullscreen(),navigator.keyboard?.lock&&navigator.keyboard.lock(["Escape"]).catch(()=>{})}catch{}document.removeEventListener("click",e)};document.addEventListener("click",e,{once:!0})}},[W.auto_fullscreen]);const[we,ve]=mt(!1),ke=pt(!1);ht(()=>{if(ke.current)return;ke.current=!0;const e="erp_startup_shown";sessionStorage.getItem(e)||(sessionStorage.setItem(e,"1"),ve(!0))},[]);const Ne=pt(!1);return ht(()=>{!Ne.current&&we&&(Ne.current=!0,setTimeout(()=>C(),500))},[we]),ht(()=>{const e=e=>{if((e.ctrlKey||e.metaKey)&&"."===e.key&&(e.preventDefault(),T(e=>!e)),e.ctrlKey&&"F11"===e.key&&(e.preventDefault(),be()),"Escape"===e.key&&document.fullscreenElement){document.querySelectorAll("[data-modal-panel]").length>0||(e.preventDefault(),be())}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[be]),/* @__PURE__ */St("div",{className:"flex flex-col h-screen",children:[
280
- /* @__PURE__ */_t(Kr,{}),we&&/* @__PURE__ */_t(Or,{onComplete:()=>ve(!1),ready:!!I,productName:f,logo:y,subtitle:b,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v}),ge&&/* @__PURE__ */_t(Hr,{onComplete:()=>{sessionStorage.removeItem("erp_startup_shown"),M()},logo:y,subtitle:b,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v}),!O&&/* @__PURE__ */_t(Jr,{open:P,onClose:()=>T(!1),openPage:e=>{_(e),T(!1)},openWindows:E,profile:I,user:N,onLogout:()=>fe(!0),onNavigate:e=>{_(e),T(!1)},taskbarPosition:K,taskbarH:q,taskbarW:G,taskbarGap:Q,size:W.start_menu_size||"medium",navSections:o,navIcons:a,sectionIcons:s,categories:c}),O&&/* @__PURE__ */_t(vt,{fallback:null,children:/* @__PURE__ */_t(Zr,{width:H,openPage:e=>_(e),profile:I,user:N,onLogout:()=>fe(!0),onNavigate:e=>_(e),navSections:o,navIcons:a,sectionIcons:s,categories:c,productName:f,productIcon:y,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v})}),(()=>{const e={backgroundColor:R?.startsWith("#")?R:"none"===R?(()=>{const e=getComputedStyle(document.documentElement).getPropertyValue("--custom-bg-color")?.trim();if(e)return e;return{light:"#f3f4f6",dark:"#1e1e2e",pink:"#fdf2f8",green:"#f0fdf4",grey:"#d1d5db",blue:"#eff6ff"}[document.documentElement.getAttribute("data-theme")||"light"]||"#f3f4f6"})():"#1a1a2e",backgroundImage:R&&"none"!==R&&!R.startsWith("#")?`url(${R})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"};return $?/* @__PURE__ */_t(Qr,{productName:f,productIcon:y,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v,config:p,wallpaperStyle:e}):/* @__PURE__ */St(Lt,{children:[
279
+ /* @__PURE__ */_t("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})}),"Remove from Favorites"]})]})]});var d,u}function ln({branding:e,productName:t="efficient-shell",productIcon:r="/favicon.svg",wallpapers:n,navSections:o=De,navIcons:a=je,sectionIcons:s=Be,categories:c=$e,notifications:d,search:u,taskbarTrayLeft:m,clockCalendar:h,mobileApp:p,contextMenu:g=!0}={}){const f=e?.productName??t,y=e?.logo??r,b=e?.tagline,x=e?.adaptiveLogo??!1,w=e?.logoHasAlpha??null,v=e?.logoIsLight??null,k=Wr(),{user:N,logout:M,hasAnyPerm:S}=A(),{openPage:_,openEntity:L,openWindows:E}=J(),[P,T]=mt(!1),$=Pe(),I=N||{};l();const{favorites:D,toggle:R,desktopBg:B}=function(e){const{prefs:t,save:r}=Ee(),n=t.favorite_pages||[],o=gt(e=>{const t=n.includes(e)?n.filter(t=>t!==e):[...n,e];r({favorite_pages:t})},[n,r]),a=e&&e.length>0?e:[],l=pt(a.length>0?a[Math.floor(Math.random()*a.length)]:"none"),i=t.desktop_bg||(a.length>0?"random":"none"),s="random"===i?l.current:i,c=gt(e=>{r({desktop_bg:e})},[r]);return{favorites:n,toggle:o,isFavorite:e=>n.includes(e),desktopBg:s,setDesktopBg:c}}(n??k.wallpapers?.map(e=>e.src)),{prefs:W,save:F}=Ee(),z="sidebar"===W.layout_mode?"sidebar":"classic",O="sidebar"===z,H=O?oe:0,V=W.taskbar_position||"bottom",K=O?"bottom":V,U=W.taskbar_size||"medium",X=W.desktop_dblclick||"deactivate",Y="left"===K||"right"===K,q=Y?0:"small"===U?42:"large"===U?72:56,G=Y?"small"===U?180:"large"===U?260:220:0,Q="small"===U?2:"large"===U?6:4,Z="small"===U?"h-[42px]":"large"===U?"h-[72px]":"h-14",ee="small"===U?"w-[180px]":"large"===U?"w-[260px]":"w-[220px]",te=!!W.reduce_transparency,re=te?1:(W.transparency_taskbar??70)/100,ne=(W.transparency_start_menu??95)/100,ae=(W.transparency_inactive_header??70)/100,le=(W.transparency_inactive_content??80)/100,ie=(W.transparency_active_header??80)/100,se=(W.transparency_active_content??90)/100;ht(()=>{const e=document.documentElement;e.classList.toggle("rosh-reduce-transparency",te),e.style.setProperty("--inactive-header-opacity",String(ae)),e.style.setProperty("--inactive-content-opacity",String(le)),e.style.setProperty("--active-header-opacity",String(ie)),e.style.setProperty("--active-content-opacity",String(se)),e.style.setProperty("--menu-opacity",String(ne)),e.style.setProperty("--taskbar-height",`${q}px`),e.style.setProperty("--taskbar-width",`${G}px`),e.style.setProperty("--taskbar-position",K),e.style.setProperty("--sidebar-width",`${H}px`),e.style.setProperty("--layout-mode",z),window.dispatchEvent(new CustomEvent("react-os-shell:layout-mode-changed")),e.style.setProperty("--default-window-size",W.default_window_size||"large"),e.style.setProperty("--window-position",W.window_position||"cascade"),e.style.setProperty("--menu-density",W.menu_density||"normal");const t={small:{font:"12px",px:"0.75rem",py:"0.25rem",tabW:"150px",tabFont:"11px"},medium:{font:"14px",px:"1rem",py:"0.5rem",tabW:"200px",tabFont:"12px"},large:{font:"15px",px:"1.125rem",py:"0.625rem",tabW:"240px",tabFont:"13px"}},r=t[W.start_menu_size||"medium"]||t.medium;e.style.setProperty("--menu-font-size",r.font),e.style.setProperty("--menu-padding-x",r.px),e.style.setProperty("--menu-padding-y",r.py),e.style.setProperty("--window-tab-width",r.tabW),e.style.setProperty("--window-tab-font-size",r.tabFont)},[te,ae,le,ie,se,q,K,W.default_window_size,W.window_position,W.menu_density,W.start_menu_size,H,z]),ht(()=>{document.documentElement.style.setProperty("--mobile-bottom-nav","0px")},[]);const[ce,de]=mt(!1),[ue,me]=mt(!!document.fullscreenElement),[he,pe]=mt(null),[ge,fe]=mt(!1),ye=gt((e,t)=>{F({[e]:t})},[F]),be=gt(async()=>{if(document.fullscreenElement)navigator.keyboard?.unlock&&navigator.keyboard.unlock(),document.exitFullscreen();else if(await document.documentElement.requestFullscreen(),navigator.keyboard?.lock)try{await navigator.keyboard.lock(["Escape"])}catch{}},[]);ht(()=>{const e=()=>{me(!!document.fullscreenElement),!document.fullscreenElement&&navigator.keyboard?.unlock&&navigator.keyboard.unlock()};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);const xe=pt(!1);ht(()=>{if(!xe.current&&W.auto_fullscreen&&!document.fullscreenElement){xe.current=!0;const e=async()=>{if(!document.fullscreenElement)try{await document.documentElement.requestFullscreen(),navigator.keyboard?.lock&&navigator.keyboard.lock(["Escape"]).catch(()=>{})}catch{}document.removeEventListener("click",e)};document.addEventListener("click",e,{once:!0})}},[W.auto_fullscreen]);const[we,ve]=mt(!1),ke=pt(!1);ht(()=>{if(ke.current)return;ke.current=!0;const e="erp_startup_shown";sessionStorage.getItem(e)||(sessionStorage.setItem(e,"1"),ve(!0))},[]);const Ne=pt(!1);return ht(()=>{!Ne.current&&we&&(Ne.current=!0,setTimeout(()=>C(),500))},[we]),ht(()=>{const e=e=>{if((e.ctrlKey||e.metaKey)&&"."===e.key&&(e.preventDefault(),T(e=>!e)),e.ctrlKey&&"F11"===e.key&&(e.preventDefault(),be()),"Escape"===e.key&&document.fullscreenElement){document.querySelectorAll("[data-modal-panel]").length>0||(e.preventDefault(),be())}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[be]),/* @__PURE__ */St("div",{className:"flex flex-col h-screen",children:[
280
+ /* @__PURE__ */_t(Kr,{}),we&&/* @__PURE__ */_t(Or,{onComplete:()=>ve(!1),ready:!!I,productName:f,logo:y,subtitle:b,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v}),ge&&/* @__PURE__ */_t(Hr,{onComplete:()=>{sessionStorage.removeItem("erp_startup_shown"),M()},logo:y,subtitle:b,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v}),!O&&/* @__PURE__ */_t(Jr,{open:P,onClose:()=>T(!1),openPage:e=>{_(e),T(!1)},openWindows:E,profile:I,user:N,onLogout:()=>fe(!0),onNavigate:e=>{_(e),T(!1)},taskbarPosition:K,taskbarH:q,taskbarW:G,taskbarGap:Q,size:W.start_menu_size||"medium",navSections:o,navIcons:a,sectionIcons:s,categories:c}),O&&/* @__PURE__ */_t(vt,{fallback:null,children:/* @__PURE__ */_t(Zr,{width:H,openPage:e=>_(e),profile:I,user:N,onLogout:()=>fe(!0),onNavigate:e=>_(e),navSections:o,navIcons:a,sectionIcons:s,categories:c,productName:f,productIcon:y,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v})}),(()=>{const e={backgroundColor:B?.startsWith("#")?B:"none"===B?(()=>{const e=getComputedStyle(document.documentElement).getPropertyValue("--custom-bg-color")?.trim();if(e)return e;return{light:"#f3f4f6",dark:"#1e1e2e",pink:"#fdf2f8",green:"#f0fdf4",grey:"#d1d5db",blue:"#eff6ff"}[document.documentElement.getAttribute("data-theme")||"light"]||"#f3f4f6"})():"#1a1a2e",backgroundImage:B&&"none"!==B&&!B.startsWith("#")?`url(${B})`:"none",backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"};return $?/* @__PURE__ */_t(Qr,{productName:f,productIcon:y,adaptiveLogo:x,logoHasAlpha:w,logoIsLight:v,config:p,wallpaperStyle:e}):/* @__PURE__ */St(Lt,{children:[
281
281
  /* @__PURE__ */_t("div",{className:"flex flex-1 min-h-0",children:/* @__PURE__ */_t("main",{className:"flex-1 flex flex-col overflow-hidden cursor-default",onDoubleClick:()=>{"deactivate"===X&&(T(!1),window.dispatchEvent(new CustomEvent("deactivate-all-modals")))},style:e,children:/* @__PURE__ */_t(zr,{profile:I})})}),
282
282
  /* @__PURE__ */St("div",{className:"flex backdrop-blur-sm border-gray-200 z-[250] fixed "+(Y?`flex-col items-center ${ee} py-3 gap-2 top-0 bottom-0 ${"left"===K?"left-0 border-r":"right-0 border-l"}`:`items-center ${Z} px-3 gap-2 right-0 ${"top"===K?"top-0 border-b":"bottom-0 border-t"}`),style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${re})`,...Y?{}:{left:H}},"data-taskbar-dropzone":!0,onContextMenu:e=>{e.preventDefault(),pe({x:e.clientX,y:e.clientY})},children:[!O&&/* @__PURE__ */St("div",{className:"relative shrink-0",children:[0===E.length&&!P&&!ce&&/* @__PURE__ */St("div",{className:"absolute left-1/2 -translate-x-1/2 whitespace-nowrap text-white text-[10px] font-medium pl-3 pr-2 py-1 rounded-full shadow-lg animate-bounce flex items-center gap-1 "+("top"===K?"top-full mt-2":"-top-8"),style:{backgroundColor:"var(--accent-600, #7c3aed)"},children:["Click here to start",
283
283
  /* @__PURE__ */_t("button",{onClick:e=>{e.stopPropagation(),de(!0)},className:"text-white/60 hover:text-white ml-1.5",children:/* @__PURE__ */_t("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),
284
284
  /* @__PURE__ */_t("div",{className:"absolute left-1/2 -translate-x-1/2 border-[6px] border-transparent "+("top"===K?"bottom-full border-b-[var(--accent-color,#7c3aed)]":"top-full border-t-[var(--accent-color,#7c3aed)]"),style:"top"===K?{borderBottomColor:"var(--accent-600, #7c3aed)"}:{borderTopColor:"var(--accent-600, #7c3aed)"}})]}),
285
285
  /* @__PURE__ */St("button",{"data-menu-toggle":!0,onClick:()=>T(e=>!e),title:P?"Close menu":"Open menu",className:`group/erp relative flex items-center justify-center gap-1.5 rounded-lg px-4 py-2 text-xs font-medium border overflow-hidden transition-all ${Y?"w-full":"min-w-[140px]"} ${P?"bg-gray-200/40 border-gray-300/40 text-gray-800":"bg-gray-50/40 border-gray-200/40 text-gray-600 hover:text-gray-800"}`,style:{transition:"box-shadow 0.3s, border-color 0.3s"},onMouseMove:e=>{const t=e.currentTarget.getBoundingClientRect();e.currentTarget.style.setProperty("--mx",e.clientX-t.left+"px"),e.currentTarget.style.setProperty("--my",e.clientY-t.top+"px")},onMouseEnter:e=>{e.currentTarget.style.boxShadow="0 0 15px rgba(255,255,255,0.2), 0 0 30px rgba(255,255,255,0.1)",e.currentTarget.style.borderColor="rgba(255,255,255,0.4)"},onMouseLeave:e=>{e.currentTarget.style.boxShadow="",e.currentTarget.style.borderColor=""},children:[
286
286
  /* @__PURE__ */_t("span",{className:"absolute inset-0 opacity-0 group-hover/erp:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle 60px at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.25) 0%, transparent 100%)"}}),y&&/* @__PURE__ */_t(j,{src:y,alt:"",slot:"compact",surface:"light",adaptive:x,hasAlpha:w,isLight:v,size:14,decorative:!0,className:"relative z-10 opacity-60"}),
287
- /* @__PURE__ */_t("span",{className:"relative z-10 truncate",children:f})]})]}),!O&&/* @__PURE__ */_t(an,{favorites:D,vertical:Y,taskbarPosition:K,navSections:o,navIcons:a,onOpen:e=>_(e),onToggleFavorite:B}),!O&&/* @__PURE__ */_t("div",{className:Y?"h-px w-6 bg-gray-300 my-1":"w-px h-6 bg-gray-300 mx-1"}),
287
+ /* @__PURE__ */_t("span",{className:"relative z-10 truncate",children:f})]})]}),!O&&/* @__PURE__ */_t(an,{favorites:D,vertical:Y,taskbarPosition:K,navSections:o,navIcons:a,onOpen:e=>_(e),onToggleFavorite:R}),!O&&/* @__PURE__ */_t("div",{className:Y?"h-px w-6 bg-gray-300 my-1":"w-px h-6 bg-gray-300 mx-1"}),
288
288
  /* @__PURE__ */_t("div",{id:"taskbar-windows",className:"flex-1 flex "+(Y?"flex-col items-center gap-1 min-h-0 overflow-y-auto w-full":"items-center gap-1.5 min-w-0 overflow-x-auto")}),
289
289
  /* @__PURE__ */_t("div",{className:Y?"h-px w-6 bg-gray-300 my-1":"w-px h-6 bg-gray-300 mx-1"}),Y?
290
290
  /* @__PURE__ */_t("div",{className:"w-full px-2",children:/* @__PURE__ */St("div",{className:"flex items-center justify-center gap-2 "+("right"===K?"flex-row-reverse":""),children:[
@@ -295,11 +295,11 @@ return _t("button",{onClick:()=>a(e),title:t,onContextMenu:r=>{r.preventDefault(
295
295
  /* @__PURE__ */_t(tn,{clockCalendar:h})]})]})]})})(),he&&/* @__PURE__ */_t(on,{x:he.x,y:he.y,position:K,size:U,onChangePosition:e=>{ye("taskbar_position",e),pe(null)},onChangeSize:e=>{ye("taskbar_size",e),pe(null)},onClose:()=>pe(null),onReportBug:k.onReportBug}),
296
296
  /* @__PURE__ */_t(i,{...u,onSelect:e=>L(e.entity_type,e.entity_id,void 0,e.label)}),
297
297
  /* @__PURE__ */_t(Ft,{}),
298
- /* @__PURE__ */_t(Xt,{disabled:!g})]})}var sn=[{key:"system",label:"System",bar1:"bg-[#e5e7eb]",bar2:"bg-[#e5e7eb]"},{key:"light",label:"Light",bar1:"bg-[#e5e7eb]",bar2:"bg-[#e5e7eb]"},{key:"dark",label:"Dark",bar1:"bg-[#45475a]",bar2:"bg-[#45475a]"},{key:"pink",label:"Blossom",bar1:"bg-[#fbcfe8]",bar2:"bg-[#fbcfe8]"},{key:"green",label:"Nature",bar1:"bg-[#bbf7d0]",bar2:"bg-[#bbf7d0]"},{key:"grey",label:"Quicksilver",bar1:"bg-[#d1d5db]",bar2:"bg-[#d1d5db]"},{key:"blue",label:"Ocean",bar1:"bg-[#bfdbfe]",bar2:"bg-[#bfdbfe]"}],cn=[];function dn(){const e=/* @__PURE__ */new Date;return`v${String(e.getDate()).padStart(2,"0")}${String(e.getMonth()+1).padStart(2,"0")}.${String(e.getHours()).padStart(2,"0")}.${String(e.getMinutes()).padStart(2,"0")}.${e.getFullYear()}`}function un(e,t,r,n,o,a,l){return"dark"===e?r:"pink"===e?n:"green"===e?o:"grey"===e?a??t:"blue"===e?l??t:t}function mn({omit:e,section:t}={}){const r=new Set(e??[]),n=e=>void 0===t||t===e,o=Wr(),a=o.wallpapers&&o.wallpapers.length>0?o.wallpapers:cn,{prefs:l,save:i}=Ee(),[c,d]=mt({}),u=e=>e in c?c[e]:l[e];ht(()=>{d(e=>{const t={};let r=!1;for(const n of Object.keys(e))l[n]===e[n]?r=!0:t[n]=e[n];return r?t:e})},[l]);const m=["theme","accent_color","custom_bg_color","custom_title_color","custom_window_color","custom_button_color"],h=e=>{const t={...e};for(const e of m)e in t||(t[e]=u(e));y(t),d(t=>({...t,...e})),i(e)},p=u("theme")||"system",g=s(p),f=l.desktop_bg||(a.length>0?"random":"none"),b=pt(a.length>0?a[Math.floor(Math.random()*a.length)].src:"none"),x="random"===f?b.current:f,w=l.desktop_bg_custom||"",v=x?.startsWith("#"),k=/* @__PURE__ */new Set([...a.map(e=>e.src),"random"]),N=!v&&"none"!==x&&"random"!==f&&x&&!k.has(x),C=(e,t)=>{i({[e]:t})},M=!!u("reduce_transparency"),[S,_]=mt({}),L=pt({}),E=gt((e,t)=>{_(r=>({...r,[e]:t}));const r={transparency_taskbar:"--taskbar-opacity",transparency_inactive_header:"--inactive-header-opacity",transparency_inactive_content:"--inactive-content-opacity",transparency_active_header:"--active-header-opacity",transparency_active_content:"--active-content-opacity"};r[e]&&document.documentElement.style.setProperty(r[e],String(t/100)),L.current[e]&&clearTimeout(L.current[e]),L.current[e]=setTimeout(()=>{C(e,t),_(t=>{const r={...t};return delete r[e],r})},300)},[C]);ht(()=>()=>{Object.values(L.current).forEach(clearTimeout)},[]);const P=(l.transparency_taskbar??70)/100,T=(l.transparency_active_header??80)/100,$=(l.transparency_active_content??90)/100,I=un(g,"bg-white/90","bg-[#1e1e2e]/90","bg-pink-50/90","bg-green-50/90","bg-gray-200/90","bg-blue-50/90"),D=un(g,"bg-gray-200","bg-[#313244]","bg-pink-200","bg-green-200","bg-gray-400","bg-blue-200"),A=un(g,"bg-white border border-gray-200","bg-[#1e1e2e] border border-[#45475a]","bg-white border border-pink-200","bg-white border border-green-200","bg-gray-100 border border-gray-300","bg-blue-50 border border-blue-200"),j=un(g,"bg-gray-100","bg-[#313244]","bg-pink-50","bg-green-50","bg-gray-300","bg-blue-100"),B=un(g,"bg-blue-600","bg-blue-500","bg-pink-600","bg-green-600","bg-gray-700","bg-blue-700");/* @__PURE__ */
298
+ /* @__PURE__ */_t(Xt,{disabled:!g})]})}var sn=[{key:"system",label:"System",bar1:"bg-[#e5e7eb]",bar2:"bg-[#e5e7eb]"},{key:"light",label:"Light",bar1:"bg-[#e5e7eb]",bar2:"bg-[#e5e7eb]"},{key:"dark",label:"Dark",bar1:"bg-[#45475a]",bar2:"bg-[#45475a]"},{key:"pink",label:"Blossom",bar1:"bg-[#fbcfe8]",bar2:"bg-[#fbcfe8]"},{key:"green",label:"Nature",bar1:"bg-[#bbf7d0]",bar2:"bg-[#bbf7d0]"},{key:"grey",label:"Quicksilver",bar1:"bg-[#d1d5db]",bar2:"bg-[#d1d5db]"},{key:"blue",label:"Ocean",bar1:"bg-[#bfdbfe]",bar2:"bg-[#bfdbfe]"}],cn=[];function dn(){const e=/* @__PURE__ */new Date;return`v${String(e.getDate()).padStart(2,"0")}${String(e.getMonth()+1).padStart(2,"0")}.${String(e.getHours()).padStart(2,"0")}.${String(e.getMinutes()).padStart(2,"0")}.${e.getFullYear()}`}function un(e,t,r,n,o,a,l){return"dark"===e?r:"pink"===e?n:"green"===e?o:"grey"===e?a??t:"blue"===e?l??t:t}function mn({omit:e,section:t}={}){const r=new Set(e??[]),n=e=>void 0===t||t===e,o=Wr(),a=o.wallpapers&&o.wallpapers.length>0?o.wallpapers:cn,{prefs:l,save:i}=Ee(),[c,d]=mt({}),u=e=>e in c?c[e]:l[e];ht(()=>{d(e=>{const t={};let r=!1;for(const n of Object.keys(e))l[n]===e[n]?r=!0:t[n]=e[n];return r?t:e})},[l]);const m=["theme","accent_color","custom_bg_color","custom_title_color","custom_window_color","custom_button_color"],h=e=>{const t={...e};for(const e of m)e in t||(t[e]=u(e));y(t),d(t=>({...t,...e})),i(e)},p=u("theme")||"system",g=s(p),f=l.desktop_bg||(a.length>0?"random":"none"),b=pt(a.length>0?a[Math.floor(Math.random()*a.length)].src:"none"),x="random"===f?b.current:f,w=l.desktop_bg_custom||"",v=x?.startsWith("#"),k=/* @__PURE__ */new Set([...a.map(e=>e.src),"random"]),N=!v&&"none"!==x&&"random"!==f&&x&&!k.has(x),C=(e,t)=>{i({[e]:t})},M=!!u("reduce_transparency"),[S,_]=mt({}),L=pt({}),E=gt((e,t)=>{_(r=>({...r,[e]:t}));const r={transparency_taskbar:"--taskbar-opacity",transparency_inactive_header:"--inactive-header-opacity",transparency_inactive_content:"--inactive-content-opacity",transparency_active_header:"--active-header-opacity",transparency_active_content:"--active-content-opacity"};r[e]&&document.documentElement.style.setProperty(r[e],String(t/100)),L.current[e]&&clearTimeout(L.current[e]),L.current[e]=setTimeout(()=>{C(e,t),_(t=>{const r={...t};return delete r[e],r})},300)},[C]);ht(()=>()=>{Object.values(L.current).forEach(clearTimeout)},[]);const P=(l.transparency_taskbar??70)/100,T=(l.transparency_active_header??80)/100,$=(l.transparency_active_content??90)/100,I=un(g,"bg-white/90","bg-[#1e1e2e]/90","bg-pink-50/90","bg-green-50/90","bg-gray-200/90","bg-blue-50/90"),D=un(g,"bg-gray-200","bg-[#313244]","bg-pink-200","bg-green-200","bg-gray-400","bg-blue-200"),A=un(g,"bg-white border border-gray-200","bg-[#1e1e2e] border border-[#45475a]","bg-white border border-pink-200","bg-white border border-green-200","bg-gray-100 border border-gray-300","bg-blue-50 border border-blue-200"),j=un(g,"bg-gray-100","bg-[#313244]","bg-pink-50","bg-green-50","bg-gray-300","bg-blue-100"),R=un(g,"bg-blue-600","bg-blue-500","bg-pink-600","bg-green-600","bg-gray-700","bg-blue-700");/* @__PURE__ */
299
299
  return St("div",{className:"space-y-6",children:[n("appearance")&&/* @__PURE__ */St(Lt,{children:[
300
300
  /* @__PURE__ */_t("div",{className:"flex justify-center",children:/* @__PURE__ */_t("div",{className:"rounded-lg border border-gray-200 overflow-hidden",style:{width:480},children:/* @__PURE__ */St("div",{className:"relative",style:{height:300},children:[v?/* @__PURE__ */_t("div",{className:"absolute inset-0",style:{backgroundColor:x}}):/* @__PURE__ */_t("img",{src:x,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),
301
301
  /* @__PURE__ */St("div",{className:`absolute left-0 right-0 bottom-0 h-4 ${I} border-t border-gray-200/50 flex items-center px-2 gap-1`,style:{opacity:P},children:[
302
- /* @__PURE__ */_t("div",{className:`h-2 w-8 rounded-sm ${B}`}),
302
+ /* @__PURE__ */_t("div",{className:`h-2 w-8 rounded-sm ${R}`}),
303
303
  /* @__PURE__ */_t("div",{className:`h-2 w-6 rounded-sm ${D}`})]}),
304
304
  /* @__PURE__ */_t("div",{className:"absolute left-4 top-4 flex gap-4",children:[{icon:"📋",label:"Orders"},{icon:"📦",label:"Products"},{icon:"📊",label:"Reports"}].map(e=>/* @__PURE__ */St("div",{className:"flex flex-col items-center gap-0.5 w-8",children:[
305
305
  /* @__PURE__ */_t("div",{className:"text-sm drop-shadow",children:e.icon}),
@@ -469,23 +469,23 @@ return St("div",{className:"space-y-4",children:[
469
469
  return _t(k,{storageKey:"shell.systemPreferences.sidebarWidth",defaultWidth:240,minWidth:200,maxWidth:360,className:r,sidebarClassName:"border-r border-gray-200 bg-gray-50",sidebar:/* @__PURE__ */_t("nav",{className:"px-1 py-1.5 space-y-0.5",children:e.map(e=>{const t=e.key===o;/* @__PURE__ */
470
470
  return St("button",{type:"button",onClick:()=>a(e.key),className:"w-full text-left rounded-lg px-3 py-2.5 text-sm transition-colors flex items-start gap-2.5 "+(t?"bg-blue-50 text-blue-700":"hover:bg-gray-100 text-gray-700"),children:[e.icon&&/* @__PURE__ */_t("span",{className:"mt-0.5 "+(t?"text-blue-600":"text-gray-400"),children:e.icon}),
471
471
  /* @__PURE__ */St("span",{className:"min-w-0",children:[
472
- /* @__PURE__ */_t("span",{className:"block "+(t?"font-semibold text-blue-700":"font-medium text-gray-800"),children:e.label}),e.description&&/* @__PURE__ */_t("span",{className:"block text-[11px] text-gray-500 mt-0.5",children:e.description})]})]},e.key)})}),children:/* @__PURE__ */_t("main",{className:"flex-1 min-w-0 overflow-auto p-4",children:l?.render()})})}function kn(e,t,r,n,o){const[a,l]=mt(-1),i=pt(e),s=pt(t),c=pt(r),d=pt(n),u=pt(o),m=pt(a),h=pt(-1),p=ie(),g=pt(p);i.current=e,s.current=t,c.current=r,d.current=n,u.current=o,m.current=a,g.current=p;const f=pt(void 0),y=e=>{clearTimeout(f.current),f.current=setTimeout(()=>l(e),0)};ht(()=>()=>clearTimeout(f.current),[]);const b=pt(e.length);return ht(()=>{e.length!==b.current&&(clearTimeout(f.current),l(-1),h.current=-1,b.current=e.length)},[e.length]),ht(()=>{const e=e=>{if(!g.current)return;if(e.shiftKey)return;const t=e.target,r=t?.closest?.("[data-row-idx]");if(!r)return;if("INPUT"!==t.tagName||"checkbox"!==t.type)return;const n=parseInt(r.getAttribute("data-row-idx"),10);isNaN(n)||(h.current=n,y(n))};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[]),ht(()=>{const e=e=>{if(!g.current)return;const t=e.target?.tagName;if("INPUT"===t||"TEXTAREA"===t||"SELECT"===t)return;if(e.target?.isContentEditable)return;if((e.metaKey||e.ctrlKey)&&"a"===e.key)return e.preventDefault(),void d.current?.();if(e.metaKey||e.ctrlKey||e.altKey)return;const r=i.current.length;if(0===r)return;const n="KeyJ"===e.code||"j"===e.key||"J"===e.key||"ArrowDown"===e.key,o="KeyK"===e.code||"k"===e.key||"K"===e.key||"ArrowUp"===e.key;if(n||o){e.preventDefault();const t=m.current,o=n?Math.min(t+1,r-1):Math.max(t-1,0);o!==t&&(l(o),a=o,requestAnimationFrame(()=>{const e=document.querySelector(`[data-row-idx="${a}"]`);e?.scrollIntoView({block:"nearest"})}),e.shiftKey&&c.current&&(c.current(i.current[o]),h.current=o))}else if("Enter"===e.key&&m.current>=0&&m.current<r)e.preventDefault(),s.current(i.current[m.current]);else if(" "===e.key&&m.current>=0&&m.current<r){if(e.preventDefault(),e.shiftKey&&h.current>=0&&u.current){const e=Math.min(h.current,m.current),t=Math.max(h.current,m.current);u.current(e,t)}else c.current?.(i.current[m.current]);h.current=m.current}var a};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),ht(()=>{const e=e=>{if(!g.current)return;if(!e.shiftKey)return;const t=e.target,r=t?.closest?.("[data-row-idx]");if(!r)return;const n=parseInt(r.getAttribute("data-row-idx"),10);if(isNaN(n))return;const o="INPUT"===t.tagName&&"checkbox"===t.type?t:null,a=h.current;if(a<0){if(o)return h.current=n,void y(n);c.current?.(i.current[n])}else{const e=Math.min(a,n),t=Math.max(a,n);if(u.current)u.current(e,t),o&&(o.checked=!0);else if(c.current)for(let r=e;r<=t;r++)c.current(i.current[r])}o||e.preventDefault(),e.stopPropagation(),h.current=n,l(n)};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[]),a}function Nn(){return"undefined"!=typeof window&&window.matchMedia("(max-width: 767px), (pointer: coarse)").matches?"mobile":"desktop"}function Cn(e,t){return["react-os-shell","default-columns",e,t]}function Mn(e){const t=yt(Nn,[]),r=bt(It)||(pn||(pn=new Dt),pn),{data:n}=Tt({queryKey:Cn(e??"",t),queryFn:()=>de.get(`/auth/default-columns/${e}/`,{params:{viewport:t}}).then(e=>e?.data??null),enabled:!!e&&me(),retry:!1,staleTime:3e5,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1},r);return{defaultConfig:n??void 0,viewport:t}}function Sn(e,t){return e.length===t.length&&e.every((e,r)=>e.key===t[r].key&&e.width===t[r].width&&!!e.hidden==!!t[r].hidden)}function _n(e){const t=e.findIndex(e=>"_select"===e.key);if(t>=0){const[r]=e.splice(t,1);r.hidden=!1,e.unshift(r)}return e}function Ln(e,t){const{prefs:r,save:n}=Ee(),o=`columns_${e}`,a=r[o],{defaultConfig:l}=Mn(e),[i,s]=mt(()=>{const r=localStorage.getItem(`col-config-${e}`);if(r)try{const e=JSON.parse(r),n=new Set(e.map(e=>e.key));return _n([...e.filter(e=>t.some(t=>t.key===e.key)),...t.filter(e=>!n.has(e.key)).map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden}))])}catch{}return _n(t.map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden})))}),[c,d]=mt(null),[u,m]=mt(null),h=pt(null),p=pt(!1),g=pt(a);g.current=a;const f=pt(null),y=pt(n);y.current=n;const b=gt(t=>{p.current=!0,localStorage.setItem(`col-config-${e}`,JSON.stringify(t)),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{y.current({[o]:t})},1e3)},[e,o]);ht(()=>{if(p.current||!Array.isArray(a))return;const r=new Set(a.map(e=>e.key)),n=_n([...a.filter(e=>t.some(t=>t.key===e.key)).map(e=>({...e})),...t.filter(e=>!r.has(e.key)).map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden}))]);s(e=>Sn(e,n)?e:n),localStorage.setItem(`col-config-${e}`,JSON.stringify(n))},[e,a]),ht(()=>{if(p.current||Array.isArray(g.current))return;const r=l?.visible_columns;if(!Array.isArray(r)||0===r.length)return;const n=new Set(r),o=_n(t.map(e=>({key:e.key,width:e.defaultWidth||150,hidden:!n.has(e.key)})));s(e=>Sn(e,o)?e:o),localStorage.setItem(`col-config-${e}`,JSON.stringify(o))},[e,l]);const x=pt(/* @__PURE__ */new Map);ht(()=>{s(e=>function(e,t,r){const n=new Set(t.map(e=>e.key)),o=new Set(e.map(e=>e.key)),a=t.filter(e=>!o.has(e.key)),l=e.filter(e=>"_select"===e.key||n.has(e.key));if(!a.length&&l.length===e.length)return e;for(const t of e)"_select"===t.key||n.has(t.key)||r.set(t.key,t);const i=[...l];for(const e of a){let n=-1;for(let r=t.indexOf(e)-1;r>=0;r-=1){const e=i.findIndex(e=>e.key===t[r].key);if(e>=0){n=e;break}}i.splice(n+1,0,r.get(e.key)??{key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden}),r.delete(e.key)}return _n(i)}(e,t,x.current))},[t]);const w=i.filter(e=>!e.hidden),v=gt((e,r)=>{r.preventDefault(),r.stopPropagation();const n=w[e],o=i.findIndex(e=>e.key===n.key);h.current={idx:o,startX:r.clientX,startWidth:i[o].width};const a=e=>{if(!h.current)return;const{idx:r,startX:n,startWidth:o}=h.current,a=t.find(e=>e.key===i[r].key)?.minWidth||30,l=Math.max(a,o+e.clientX-n);s(e=>{const t=[...e];return t[r]={...t[r],width:l},t})},l=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l),h.current=null,s(e=>(b(e),e))};document.addEventListener("mousemove",a),document.addEventListener("mouseup",l)},[i,w,t,b]),k=gt(e=>{d(e)},[]),N=gt((e,t)=>{if(t.preventDefault(),null===c)return;const r=t.currentTarget.getBoundingClientRect();let n=t.clientX<r.left+r.width/2?e:e+1;const o=i.filter(e=>!e.hidden);"_select"===o[0]?.key&&0===n&&(n=1),m(n)},[c,i]),C=gt((e,t)=>(t.preventDefault(),null===c||null===u||u===c||u===c+1?(d(null),void m(null)):(s(e=>{const t=e.filter(e=>!e.hidden),r=t[c];if(!r)return e;const n=e.findIndex(e=>e.key===r.key);let o;o=u<t.length?e.findIndex(e=>e.key===t[u].key):e.findIndex(e=>e.key===t[t.length-1].key)+1;const a=[...e],[l]=a.splice(n,1);return a.splice(o>n?o-1:o,0,l),b(a),a}),d(null),void m(null))),[c,u,b]),M=gt(()=>{d(null),m(null)},[]),S=gt(e=>{s(t=>{const r=t.map(t=>t.key===e?{...t,hidden:!t.hidden}:t);return 0===r.filter(e=>!e.hidden).length?t:(b(r),r)})},[b]),_=gt(()=>{const e=_n(t.map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden})));s(e),b(e)},[t,b]);return{orderedColumns:w.map(e=>({...t.find(t=>t.key===e.key),width:e.width})).filter(Boolean),allColumns:i.map(e=>{const r=t.find(t=>t.key===e.key);return{key:e.key,label:r?.label||e.key,hidden:!!e.hidden}}),onResizeStart:v,onDragStart:k,onDragOver:N,onDrop:C,onDragEnd:M,toggleColumn:S,resetColumns:_,draggedIdx:c,dropGap:u}}function En({tableId:e,columns:t,sort:r,onSort:n,footer:o,afterBody:a,saveDefaultPerms:l=["change_numberingconfig"],children:i}){const s=Pe(),[d,u]=mt(!1),m=yt(()=>s&&!d?t.filter(e=>"_select"!==e.key):t,[t,s,d]),{orderedColumns:h,allColumns:p,onResizeStart:g,onDragStart:f,onDragOver:y,onDrop:b,onDragEnd:x,toggleColumn:w,resetColumns:v,draggedIdx:k,dropGap:N}=Ln(e,m),{hasAnyPerm:C}=We(),[M,S]=mt(!1),[_,L]=mt(!1),[E,P]=mt(!1),T=pt(null),$=l.length>0&&C(l);c(T,gt(()=>{M&&S(!1)},[M]));const I=h.reduce((e,t)=>e+t.width,0),D=h.map(e=>`${e.width}px`),A={tableLayout:"fixed",width:I,minWidth:"100%"},j=pt(null),B=gt(e=>{const t=j.current;t&&(t.scrollLeft=e.currentTarget.scrollLeft)},[]),R=yt(()=>t.some(e=>"_select"===e.key),[t]);/* @__PURE__ */
472
+ /* @__PURE__ */_t("span",{className:"block "+(t?"font-semibold text-blue-700":"font-medium text-gray-800"),children:e.label}),e.description&&/* @__PURE__ */_t("span",{className:"block text-[11px] text-gray-500 mt-0.5",children:e.description})]})]},e.key)})}),children:/* @__PURE__ */_t("main",{className:"flex-1 min-w-0 overflow-auto p-4",children:l?.render()})})}function kn(e,t,r,n,o){const[a,l]=mt(-1),i=pt(e),s=pt(t),c=pt(r),d=pt(n),u=pt(o),m=pt(a),h=pt(-1),p=ie(),g=pt(p);i.current=e,s.current=t,c.current=r,d.current=n,u.current=o,m.current=a,g.current=p;const f=pt(void 0),y=e=>{clearTimeout(f.current),f.current=setTimeout(()=>l(e),0)};ht(()=>()=>clearTimeout(f.current),[]);const b=pt(e.length);return ht(()=>{e.length!==b.current&&(clearTimeout(f.current),l(-1),h.current=-1,b.current=e.length)},[e.length]),ht(()=>{const e=e=>{if(!g.current)return;if(e.shiftKey)return;const t=e.target,r=t?.closest?.("[data-row-idx]");if(!r)return;if("INPUT"!==t.tagName||"checkbox"!==t.type)return;const n=parseInt(r.getAttribute("data-row-idx"),10);isNaN(n)||(h.current=n,y(n))};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[]),ht(()=>{const e=e=>{if(!g.current)return;const t=e.target?.tagName;if("INPUT"===t||"TEXTAREA"===t||"SELECT"===t)return;if(e.target?.isContentEditable)return;if((e.metaKey||e.ctrlKey)&&"a"===e.key)return e.preventDefault(),void d.current?.();if(e.metaKey||e.ctrlKey||e.altKey)return;const r=i.current.length;if(0===r)return;const n="KeyJ"===e.code||"j"===e.key||"J"===e.key||"ArrowDown"===e.key,o="KeyK"===e.code||"k"===e.key||"K"===e.key||"ArrowUp"===e.key;if(n||o){e.preventDefault();const t=m.current,o=n?Math.min(t+1,r-1):Math.max(t-1,0);o!==t&&(l(o),a=o,requestAnimationFrame(()=>{const e=document.querySelector(`[data-row-idx="${a}"]`);e?.scrollIntoView({block:"nearest"})}),e.shiftKey&&c.current&&(c.current(i.current[o]),h.current=o))}else if("Enter"===e.key&&m.current>=0&&m.current<r)e.preventDefault(),s.current(i.current[m.current]);else if(" "===e.key&&m.current>=0&&m.current<r){if(e.preventDefault(),e.shiftKey&&h.current>=0&&u.current){const e=Math.min(h.current,m.current),t=Math.max(h.current,m.current);u.current(e,t)}else c.current?.(i.current[m.current]);h.current=m.current}var a};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),ht(()=>{const e=e=>{if(!g.current)return;if(!e.shiftKey)return;const t=e.target,r=t?.closest?.("[data-row-idx]");if(!r)return;const n=parseInt(r.getAttribute("data-row-idx"),10);if(isNaN(n))return;const o="INPUT"===t.tagName&&"checkbox"===t.type?t:null,a=h.current;if(a<0){if(o)return h.current=n,void y(n);c.current?.(i.current[n])}else{const e=Math.min(a,n),t=Math.max(a,n);if(u.current)u.current(e,t),o&&(o.checked=!0);else if(c.current)for(let r=e;r<=t;r++)c.current(i.current[r])}o||e.preventDefault(),e.stopPropagation(),h.current=n,l(n)};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[]),a}function Nn(){return"undefined"!=typeof window&&window.matchMedia("(max-width: 767px), (pointer: coarse)").matches?"mobile":"desktop"}function Cn(e,t){return["react-os-shell","default-columns",e,t]}function Mn(e){const t=yt(Nn,[]),r=bt(It)||(pn||(pn=new Dt),pn),{data:n}=Tt({queryKey:Cn(e??"",t),queryFn:()=>de.get(`/auth/default-columns/${e}/`,{params:{viewport:t}}).then(e=>e?.data??null),enabled:!!e&&me(),retry:!1,staleTime:3e5,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1},r);return{defaultConfig:n??void 0,viewport:t}}function Sn(e,t){return e.length===t.length&&e.every((e,r)=>e.key===t[r].key&&e.width===t[r].width&&!!e.hidden==!!t[r].hidden)}function _n(e){const t=e.findIndex(e=>"_select"===e.key);if(t>=0){const[r]=e.splice(t,1);r.hidden=!1,e.unshift(r)}return e}function Ln(e,t){const{prefs:r,save:n}=Ee(),o=`columns_${e}`,a=r[o],{defaultConfig:l}=Mn(e),[i,s]=mt(()=>{const r=localStorage.getItem(`col-config-${e}`);if(r)try{const e=JSON.parse(r),n=new Set(e.map(e=>e.key));return _n([...e.filter(e=>t.some(t=>t.key===e.key)),...t.filter(e=>!n.has(e.key)).map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden}))])}catch{}return _n(t.map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden})))}),[c,d]=mt(null),[u,m]=mt(null),h=pt(null),p=pt(!1),g=pt(a);g.current=a;const f=pt(null),y=pt(n);y.current=n;const b=gt(t=>{p.current=!0,localStorage.setItem(`col-config-${e}`,JSON.stringify(t)),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{y.current({[o]:t})},1e3)},[e,o]);ht(()=>{if(p.current||!Array.isArray(a))return;const r=new Set(a.map(e=>e.key)),n=_n([...a.filter(e=>t.some(t=>t.key===e.key)).map(e=>({...e})),...t.filter(e=>!r.has(e.key)).map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden}))]);s(e=>Sn(e,n)?e:n),localStorage.setItem(`col-config-${e}`,JSON.stringify(n))},[e,a]),ht(()=>{if(p.current||Array.isArray(g.current))return;const r=l?.visible_columns;if(!Array.isArray(r)||0===r.length)return;const n=new Set(r),o=_n(t.map(e=>({key:e.key,width:e.defaultWidth||150,hidden:!n.has(e.key)})));s(e=>Sn(e,o)?e:o),localStorage.setItem(`col-config-${e}`,JSON.stringify(o))},[e,l]);const x=pt(/* @__PURE__ */new Map);ht(()=>{s(e=>function(e,t,r){const n=new Set(t.map(e=>e.key)),o=new Set(e.map(e=>e.key)),a=t.filter(e=>!o.has(e.key)),l=e.filter(e=>"_select"===e.key||n.has(e.key));if(!a.length&&l.length===e.length)return e;for(const t of e)"_select"===t.key||n.has(t.key)||r.set(t.key,t);const i=[...l];for(const e of a){let n=-1;for(let r=t.indexOf(e)-1;r>=0;r-=1){const e=i.findIndex(e=>e.key===t[r].key);if(e>=0){n=e;break}}i.splice(n+1,0,r.get(e.key)??{key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden}),r.delete(e.key)}return _n(i)}(e,t,x.current))},[t]);const w=i.filter(e=>!e.hidden),v=gt((e,r)=>{r.preventDefault(),r.stopPropagation();const n=w[e],o=i.findIndex(e=>e.key===n.key);h.current={idx:o,startX:r.clientX,startWidth:i[o].width};const a=e=>{if(!h.current)return;const{idx:r,startX:n,startWidth:o}=h.current,a=t.find(e=>e.key===i[r].key)?.minWidth||30,l=Math.max(a,o+e.clientX-n);s(e=>{const t=[...e];return t[r]={...t[r],width:l},t})},l=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l),h.current=null,s(e=>(b(e),e))};document.addEventListener("mousemove",a),document.addEventListener("mouseup",l)},[i,w,t,b]),k=gt(e=>{d(e)},[]),N=gt((e,t)=>{if(t.preventDefault(),null===c)return;const r=t.currentTarget.getBoundingClientRect();let n=t.clientX<r.left+r.width/2?e:e+1;const o=i.filter(e=>!e.hidden);"_select"===o[0]?.key&&0===n&&(n=1),m(n)},[c,i]),C=gt((e,t)=>(t.preventDefault(),null===c||null===u||u===c||u===c+1?(d(null),void m(null)):(s(e=>{const t=e.filter(e=>!e.hidden),r=t[c];if(!r)return e;const n=e.findIndex(e=>e.key===r.key);let o;o=u<t.length?e.findIndex(e=>e.key===t[u].key):e.findIndex(e=>e.key===t[t.length-1].key)+1;const a=[...e],[l]=a.splice(n,1);return a.splice(o>n?o-1:o,0,l),b(a),a}),d(null),void m(null))),[c,u,b]),M=gt(()=>{d(null),m(null)},[]),S=gt(e=>{s(t=>{const r=t.map(t=>t.key===e?{...t,hidden:!t.hidden}:t);return 0===r.filter(e=>!e.hidden).length?t:(b(r),r)})},[b]),_=gt(()=>{const e=_n(t.map(e=>({key:e.key,width:e.defaultWidth||150,hidden:e.defaultHidden})));s(e),b(e)},[t,b]);return{orderedColumns:w.map(e=>({...t.find(t=>t.key===e.key),width:e.width})).filter(Boolean),allColumns:i.map(e=>{const r=t.find(t=>t.key===e.key);return{key:e.key,label:r?.label||e.key,hidden:!!e.hidden}}),onResizeStart:v,onDragStart:k,onDragOver:N,onDrop:C,onDragEnd:M,toggleColumn:S,resetColumns:_,draggedIdx:c,dropGap:u}}function En({tableId:e,columns:t,sort:r,onSort:n,footer:o,afterBody:a,saveDefaultPerms:l=["change_numberingconfig"],children:i}){const s=Pe(),[d,u]=mt(!1),m=yt(()=>s&&!d?t.filter(e=>"_select"!==e.key):t,[t,s,d]),{orderedColumns:h,allColumns:p,onResizeStart:g,onDragStart:f,onDragOver:y,onDrop:b,onDragEnd:x,toggleColumn:w,resetColumns:v,draggedIdx:k,dropGap:N}=Ln(e,m),{hasAnyPerm:C}=We(),[M,S]=mt(!1),[_,L]=mt(!1),[E,P]=mt(!1),T=pt(null),$=l.length>0&&C(l);c(T,gt(()=>{M&&S(!1)},[M]));const I=h.reduce((e,t)=>e+t.width,0),D=h.map(e=>`${e.width}px`),A={tableLayout:"fixed",width:I,minWidth:"100%"},j=pt(null),R=gt(e=>{const t=j.current;t&&(t.scrollLeft=e.currentTarget.scrollLeft)},[]),B=yt(()=>t.some(e=>"_select"===e.key),[t]);/* @__PURE__ */
473
473
  return St("div",{className:"flex flex-col flex-1 min-h-0 "+(s?"-mx-4":""),children:[
474
474
  /* @__PURE__ */_t("div",{ref:j,className:"shrink-0 overflow-x-hidden",children:/* @__PURE__ */St("table",{className:"divide-y divide-gray-200",style:A,children:[
475
475
  /* @__PURE__ */_t("colgroup",{children:h.map((e,t)=>/* @__PURE__ */_t("col",{style:{width:D[t]}},e.key))}),
476
476
  /* @__PURE__ */_t("thead",{className:"bg-gray-50",children:/* @__PURE__ */_t("tr",{children:h.map((e,o)=>{const a=t.find(t=>t.key===e.key),l=a?.sortField??("_select"!==e.key?e.key:void 0),i=r&&l&&r.field===l,s="_select"===e.key;/* @__PURE__ */
477
477
  return St("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase select-none relative "+(k===o?"bg-blue-50":""),draggable:!s,onDragStart:s?void 0:()=>f(o),onDragOver:s?void 0:e=>y(o,e),onDrop:s?void 0:e=>b(o,e),onDragEnd:s?void 0:x,style:s?void 0:{cursor:"grab"},children:[
478
478
  /* @__PURE__ */St("span",{className:`${s?"":"truncate pr-3"} block ${l&&n?"cursor-pointer hover:text-gray-700":""}`,onClick:l&&n?e=>{e.stopPropagation(),n(l)}:void 0,children:[e.headerNode??e.label,i&&/* @__PURE__ */_t("span",{className:"ml-1",children:"asc"===r.direction?"▲":"▼"})]}),!s&&/* @__PURE__ */_t("div",{className:"absolute right-0 top-0 bottom-0 w-4 cursor-col-resize flex items-center justify-center z-10",onMouseDown:e=>g(o,e),style:{marginRight:-8},children:/* @__PURE__ */_t("div",{className:"w-0.5 h-full bg-gray-200 hover:bg-blue-500 transition-colors"})}),N===o&&/* @__PURE__ */_t("div",{className:"absolute left-0 top-0 bottom-0 w-0.5 bg-blue-500 z-20 pointer-events-none"}),o===h.length-1&&N===h.length&&/* @__PURE__ */_t("div",{className:"absolute right-0 top-0 bottom-0 w-0.5 bg-blue-500 z-20 pointer-events-none"})]},e.key)})})})]})}),
479
- /* @__PURE__ */St("div",{className:"flex-1 overflow-y-auto overflow-x-auto min-h-0",onScroll:B,children:[
479
+ /* @__PURE__ */St("div",{className:"flex-1 overflow-y-auto overflow-x-auto min-h-0",onScroll:R,children:[
480
480
  /* @__PURE__ */St("table",{className:"divide-y divide-gray-200",style:A,children:[
481
481
  /* @__PURE__ */_t("colgroup",{children:h.map((e,t)=>/* @__PURE__ */_t("col",{style:{width:D[t]}},e.key))}),i(h)]}),a]}),void 0!==o&&/* @__PURE__ */St("div",{className:"border-t border-gray-200 px-4 py-2 text-sm text-gray-500 shrink-0 flex items-center justify-between",children:[
482
482
  /* @__PURE__ */_t("span",{children:o}),
483
- /* @__PURE__ */St("div",{className:"flex items-center gap-3 relative",ref:T,children:[s&&R&&/* @__PURE__ */_t("button",{onClick:()=>u(e=>!e),className:"text-[11px] px-2 py-0.5 rounded "+(d?"bg-blue-600 text-white":"text-gray-500 hover:text-gray-700 border border-gray-300"),title:d?"Hide selection column":"Show selection column",children:d?"Done":"Select"}),
483
+ /* @__PURE__ */St("div",{className:"flex items-center gap-3 relative",ref:T,children:[s&&B&&/* @__PURE__ */_t("button",{onClick:()=>u(e=>!e),className:"text-[11px] px-2 py-0.5 rounded "+(d?"bg-blue-600 text-white":"text-gray-500 hover:text-gray-700 border border-gray-300"),title:d?"Hide selection column":"Show selection column",children:d?"Done":"Select"}),
484
484
  /* @__PURE__ */_t("button",{onClick:v,className:"text-[10px] text-gray-400 hover:text-gray-600",children:"Reset"}),
485
485
  /* @__PURE__ */_t("button",{onClick:()=>S(!M),className:"text-gray-400 hover:text-gray-600",title:"Choose columns",children:/* @__PURE__ */_t("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",viewBox:"0 0 24 24",children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75"})})}),M&&/* @__PURE__ */St("div",{className:"absolute bottom-full right-0 mb-1 w-52 rounded-2xl z-50 py-1 max-h-80 overflow-y-auto",style:it(),children:[
486
486
  /* @__PURE__ */_t("p",{className:"px-3 py-1.5 text-[10px] font-semibold text-gray-400 uppercase",children:"Columns"}),p.filter(e=>"_select"!==e.key).map(e=>/* @__PURE__ */St("label",{className:"flex items-center gap-2 px-3 py-1 text-sm text-gray-700 hover:bg-gray-50 cursor-pointer",children:[
487
- /* @__PURE__ */_t("input",{type:"checkbox",checked:!e.hidden,onChange:()=>w(e.key),className:"h-3.5 w-3.5 rounded border-gray-300 text-blue-600"}),e.label]},e.key)),$&&/* @__PURE__ */_t("div",{className:"border-t border-gray-100 mt-1 pt-1 px-3 pb-1",children:/* @__PURE__ */_t("button",{onClick:async()=>{L(!0);const t=p.filter(e=>!e.hidden).map(e=>e.key),n=s?"mobile":"desktop",o={visible_columns:t};r&&(o.sort=r);try{await de.patch(`/auth/default-columns/${e}/`,o,{params:{viewport:n}}).catch(()=>de.post("/auth/default-columns/",{table_id:e,viewport:n,...o})),P(!0),setTimeout(()=>P(!1),2e3)}catch{}L(!1)},disabled:_,className:"text-[10px] w-full text-center py-1 rounded "+(E?"text-green-600":"text-gray-500 hover:text-blue-600"),children:_?"...":E?"Saved as default":"Save as default for all users"})})]})]})]})]})}function Pn(e){return Array.from(e.children).filter(e=>void 0!==e.dataset?.colKey&&"_select"!==e.dataset.colKey)}function Tn(e){return("string"==typeof e.innerText?e.innerText:e.textContent??"").replace(/\s+/g," ").trim()}function $n(e){const{items:t,isLoading:r,emptyState:n,totalCount:o,isError:a,onRetry:l,errorTitle:i,errorMessage:s,tableId:c,columns:p,renderCell:g,getRowId:f=e=>e.id,sort:y,onSort:x,selected:w,setSelected:v,onRowClick:k,onRowHover:N,getRowClassName:C,footerLabel:M,footerExtra:S,sentinelRef:_,isFetchingNextPage:L,saveDefaultPerms:E,exportEndpoint:P,exportFilename:T="export.csv",contextActions:$}=e,[I,D]=mt(null),A=pt(null),j=st(),B=e=>{v(t=>{const r=new Set(t),n=f(e);return r.has(n)?r.delete(n):r.add(n),r})},R=()=>{v(e=>e.size===t.length?/* @__PURE__ */new Set:new Set(t.map(f)))},F=kn(t,k,B,R,(e,r)=>{v(n=>{const o=new Set(n);for(let n=e;n<=r;n++)o.add(f(t[n]));return o})}),z=t.filter(e=>w.has(f(e))),O=()=>{const e=[...A.current?.querySelectorAll("tr[data-row-idx]")??[]].filter(e=>{const r=t[Number(e.dataset.rowIdx)];return void 0!==r&&w.has(f(r))}),r=e.length?Pn(e[0]).map(e=>e.dataset.colKey??""):[],n=new Map(p.map(e=>[e.key,e.label]));return{keys:r,header:r.map(e=>n.get(e)??e),body:e.map(e=>Pn(e).map(Tn))}},H=()=>{D(null);const{header:e,body:t}=O();if(!t.length)return;const r=[e,...t].map(e=>e.join("\t")).join("\n"),n="<table><thead><tr>"+e.map(e=>`<th>${W(e)}</th>`).join("")+"</tr></thead><tbody>"+t.map(e=>`<tr>${e.map(e=>`<td>${W(e)}</td>`).join("")}</tr>`).join("")+"</tbody></table>";h(1===t.length?"Row":`${t.length} rows`,r,n)},V=async()=>{D(null);const e=[...w];if(!e.length||!P)return;const t=new URLSearchParams({ids:e.join(",")}),r=(()=>{const e=new Map(p.map(e=>[e.key,e.label]));try{const t=localStorage.getItem(`col-config-${c}`);if(t){const r=JSON.parse(t).filter(t=>!t.hidden&&"_select"!==t.key&&e.has(t.key)).map(t=>`${t.key}|${e.get(t.key)}`);if(r.length)return r.join(",")}}catch{}return p.filter(e=>!e.defaultHidden).map(e=>`${e.key}|${e.label}`).join(",")})();r&&t.set("cols",r);const n=P.includes("?")?"&":"?";try{const r=await de.get(`${P}${n}${t}`,{responseType:"blob"}),o=window.URL.createObjectURL(new Blob([r.data],{type:"text/csv"})),a=document.createElement("a");a.href=o,a.download=T,a.click(),window.URL.revokeObjectURL(o);const l=r.headers??{},i=Number(l["x-row-count"]);if("true"===String(l["x-truncated"])){const t=Number.isFinite(i)?`${i} of ${e.length}`:`only some of the ${e.length}`;return void U.notify(`Exported ${t} rows. The server capped this export, so the file is incomplete.`)}U.success(`Exported ${e.length} ${1===e.length?"row":"rows"}.`)}catch{U.error("CSV export failed.")}};if(r)/* @__PURE__ */return _t(se,{});if(a&&0===t.length)/* @__PURE__ */
488
- return _t(d,{title:i,message:s,onRetry:l});if(0===t.length)/* @__PURE__ */return _t(Lt,{children:n});const K=t.length>0&&w.size===t.length,X=w.size>0&&!K,Y=[{key:"_select",label:"",defaultWidth:52,minWidth:52,headerNode:/* @__PURE__ */_t(u,{"aria-label":j.table.selectAll,checked:K,indeterminate:X,onChange:R,style:{height:14,width:14}})},...p],q=/* @__PURE__ */_t(m,{selectedCount:w.size,loadedCount:t.length,totalCount:o,label:M,isFetchingMore:L,extra:S}),G=_?/* @__PURE__ */St(Lt,{children:[
487
+ /* @__PURE__ */_t("input",{type:"checkbox",checked:!e.hidden,onChange:()=>w(e.key),className:"h-3.5 w-3.5 rounded border-gray-300 text-blue-600"}),e.label]},e.key)),$&&/* @__PURE__ */_t("div",{className:"border-t border-gray-100 mt-1 pt-1 px-3 pb-1",children:/* @__PURE__ */_t("button",{onClick:async()=>{L(!0);const t=p.filter(e=>!e.hidden).map(e=>e.key),n=s?"mobile":"desktop",o={visible_columns:t};r&&(o.sort=r);try{await de.patch(`/auth/default-columns/${e}/`,o,{params:{viewport:n}}).catch(()=>de.post("/auth/default-columns/",{table_id:e,viewport:n,...o})),P(!0),setTimeout(()=>P(!1),2e3)}catch{}L(!1)},disabled:_,className:"text-[10px] w-full text-center py-1 rounded "+(E?"text-green-600":"text-gray-500 hover:text-blue-600"),children:_?"...":E?"Saved as default":"Save as default for all users"})})]})]})]})]})}function Pn(e){return Array.from(e.children).filter(e=>void 0!==e.dataset?.colKey&&"_select"!==e.dataset.colKey)}function Tn(e){return("string"==typeof e.innerText?e.innerText:e.textContent??"").replace(/\s+/g," ").trim()}function $n(e){const{items:t,isLoading:r,emptyState:n,totalCount:o,isError:a,onRetry:l,errorTitle:i,errorMessage:s,tableId:c,columns:p,renderCell:g,getRowId:f=e=>e.id,sort:y,onSort:x,selected:w,setSelected:v,onRowClick:k,onRowHover:N,getRowClassName:C,footerLabel:M,footerExtra:S,sentinelRef:_,isFetchingNextPage:L,saveDefaultPerms:E,exportEndpoint:P,exportFilename:T="export.csv",contextActions:$}=e,[I,D]=mt(null),A=pt(null),j=st(),R=e=>{v(t=>{const r=new Set(t),n=f(e);return r.has(n)?r.delete(n):r.add(n),r})},B=()=>{v(e=>e.size===t.length?/* @__PURE__ */new Set:new Set(t.map(f)))},F=kn(t,k,R,B,(e,r)=>{v(n=>{const o=new Set(n);for(let n=e;n<=r;n++)o.add(f(t[n]));return o})}),z=t.filter(e=>w.has(f(e))),O=()=>{const e=[...A.current?.querySelectorAll("tr[data-row-idx]")??[]].filter(e=>{const r=t[Number(e.dataset.rowIdx)];return void 0!==r&&w.has(f(r))}),r=e.length?Pn(e[0]).map(e=>e.dataset.colKey??""):[],n=new Map(p.map(e=>[e.key,e.label]));return{keys:r,header:r.map(e=>n.get(e)??e),body:e.map(e=>Pn(e).map(Tn))}},H=()=>{D(null);const{header:e,body:t}=O();if(!t.length)return;const r=[e,...t].map(e=>e.join("\t")).join("\n"),n="<table><thead><tr>"+e.map(e=>`<th>${W(e)}</th>`).join("")+"</tr></thead><tbody>"+t.map(e=>`<tr>${e.map(e=>`<td>${W(e)}</td>`).join("")}</tr>`).join("")+"</tbody></table>";h(1===t.length?"Row":`${t.length} rows`,r,n)},V=async()=>{D(null);const e=[...w];if(!e.length||!P)return;const t=new URLSearchParams({ids:e.join(",")}),r=(()=>{const e=new Map(p.map(e=>[e.key,e.label]));try{const t=localStorage.getItem(`col-config-${c}`);if(t){const r=JSON.parse(t).filter(t=>!t.hidden&&"_select"!==t.key&&e.has(t.key)).map(t=>`${t.key}|${e.get(t.key)}`);if(r.length)return r.join(",")}}catch{}return p.filter(e=>!e.defaultHidden).map(e=>`${e.key}|${e.label}`).join(",")})();r&&t.set("cols",r);const n=P.includes("?")?"&":"?";try{const r=await de.get(`${P}${n}${t}`,{responseType:"blob"}),o=window.URL.createObjectURL(new Blob([r.data],{type:"text/csv"})),a=document.createElement("a");a.href=o,a.download=T,a.click(),window.URL.revokeObjectURL(o);const l=r.headers??{},i=Number(l["x-row-count"]);if("true"===String(l["x-truncated"])){const t=Number.isFinite(i)?`${i} of ${e.length}`:`only some of the ${e.length}`;return void U.notify(`Exported ${t} rows. The server capped this export, so the file is incomplete.`)}U.success(`Exported ${e.length} ${1===e.length?"row":"rows"}.`)}catch{U.error("CSV export failed.")}};if(r)/* @__PURE__ */return _t(se,{});if(a&&0===t.length)/* @__PURE__ */
488
+ return _t(d,{title:i,message:s,onRetry:l});if(0===t.length)/* @__PURE__ */return _t(Lt,{children:n});const K=t.length>0&&w.size===t.length,X=w.size>0&&!K,Y=[{key:"_select",label:"",defaultWidth:52,minWidth:52,headerNode:/* @__PURE__ */_t(u,{"aria-label":j.table.selectAll,checked:K,indeterminate:X,onChange:B,style:{height:14,width:14}})},...p],q=/* @__PURE__ */_t(m,{selectedCount:w.size,loadedCount:t.length,totalCount:o,label:M,isFetchingMore:L,extra:S}),G=_?/* @__PURE__ */St(Lt,{children:[
489
489
  /* @__PURE__ */_t("div",{ref:_}),L&&/* @__PURE__ */_t("div",{className:"text-center py-3",children:/* @__PURE__ */_t("span",{className:"text-sm text-gray-500",children:"Loading more..."})})]}):void 0;let J=null;if(I){const{x:e,y:r,item:n,text:a,firstColumn:i}=I,s=$?$(z):[],c=z.length,d=()=>D(null),u=void 0!==o&&o>t.length;J=/* @__PURE__ */St(Ve,{portal:!0,style:{left:e,top:r},onClose:d,minWidth:210,children:[
490
490
  /* @__PURE__ */St(Ue,{children:[w.size," selected"]}),
491
491
  /* @__PURE__ */_t(Xe,{className:"font-medium",onClick:()=>{d(),k(n)},children:"Open"}),
@@ -496,14 +496,14 @@ return _t(d,{title:i,message:s,onRetry:l});if(0===t.length)/* @__PURE__ */return
496
496
  /* @__PURE__ */_t(Xe,{onClick:()=>{d(),v(/* @__PURE__ */new Set)},children:"Clear selection"}),l&&/* @__PURE__ */_t(Xe,{onClick:()=>{d(),l()},children:"Refresh"})]})}/* @__PURE__ */
497
497
  return St("div",{className:"flex-1 flex flex-col mb-1 bg-white rounded-lg shadow overflow-hidden",children:[
498
498
  /* @__PURE__ */_t("div",{className:"flex-1 min-h-0 flex flex-col",children:/* @__PURE__ */_t(En,{tableId:c,columns:Y,sort:y,onSort:x,footer:q,afterBody:G,saveDefaultPerms:E,children:e=>/* @__PURE__ */_t("tbody",{ref:A,className:"divide-y divide-gray-100",children:t.map((t,r)=>{const n=f(t);/* @__PURE__ */
499
- return _t("tr",{"data-row-idx":r,className:`cursor-pointer ${F===r?"bg-blue-50 ring-1 ring-inset ring-blue-300":w.has(n)?"bg-blue-50 hover:bg-blue-100":"hover:bg-gray-50"} ${C?.(t)??""}`,onClick:()=>k(t),onContextMenu:e=>((e,t)=>{if(e.shiftKey||qe(e.target))return;e.preventDefault();const r=f(t);w.has(r)||v(/* @__PURE__ */new Set([r]));const n=Pn(e.currentTarget)[0]?.dataset.colKey,o=n?p.find(e=>e.key===n)?.label:void 0;D({x:e.clientX,y:e.clientY,item:t,text:b(e.target),firstColumn:n&&o?{key:n,label:o}:null})})(e,t),onMouseEnter:N?()=>N(t):void 0,children:e.map(e=>/* @__PURE__ */_t("td",{"data-col-key":e.key,className:"px-4 py-3 whitespace-nowrap text-sm overflow-hidden",children:"_select"===e.key?/* @__PURE__ */_t(u,{"aria-label":j.table.selectRow,checked:w.has(n),onChange:()=>B(t),onClick:e=>e.stopPropagation(),style:{height:14,width:14}}):g(t,e.key)},e.key))},n)})})})}),J]})}function In({queryKey:e,fetchFn:t,extraParams:r={},pageSize:n=25}){const o=pt(null),a=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),l=$t({queryKey:e,queryFn:({pageParam:e=1})=>t({page:String(e),...a}),getNextPageParam:(e,t)=>{if(e.next)return t.length+1},initialPageParam:1}),{fetchNextPage:i,hasNextPage:s,isFetchingNextPage:c}=l,d=gt(e=>{const[t]=e;t.isIntersecting&&s&&!c&&i()},[i,s,c]);ht(()=>{const e=o.current;if(!e)return;let t=e.parentElement;for(;t;){const e=getComputedStyle(t).overflowY;if("auto"===e||"scroll"===e)break;t=t.parentElement}const r=new IntersectionObserver(d,{root:t,rootMargin:"200px",threshold:0});return r.observe(e),()=>r.disconnect()},[d]);const u=/* @__PURE__ */new Set;return{items:(l.data?.pages.flatMap(e=>e?.results??[])??[]).filter(e=>null!=e).filter(e=>{const t=e.id;return null==t||!u.has(t)&&(u.add(t),!0)}),totalCount:l.data?.pages[0]?.count??0,isLoading:l.isLoading,isError:l.isError,error:l.error,isFetchingNextPage:c,hasNextPage:!!s,sentinelRef:o,refetch:l.refetch}}function Dn(e){const t=e;return!!t&&"string"==typeof t.field&&t.field.length>0&&("asc"===t.direction||"desc"===t.direction)}function An(e,t="asc",r,n){const{prefs:o,save:a}=Ee(),l=r?`sort_${r}`:null,[i,s]=mt(()=>{if(l){if(Dn(o[l]))return o[l];try{const e=JSON.parse(localStorage.getItem(`sort-config-${r}`)||"null");if(Dn(e))return e}catch{}}return{field:e,direction:t}}),c=pt(!1),d=l?o[l]:void 0,u=pt(d);u.current=d,ht(()=>{if(!c.current&&Dn(d)){s(e=>e.field===d.field&&e.direction===d.direction?e:d);try{localStorage.setItem(`sort-config-${r}`,JSON.stringify(d))}catch{}}},[r,d?.field,d?.direction]);const{defaultConfig:m}=Mn(r);ht(()=>{const e=m?.sort;if(!c.current&&!Dn(u.current)&&Dn(e)){s(t=>t.field===e.field&&t.direction===e.direction?t:e);try{localStorage.setItem(`sort-config-${r}`,JSON.stringify(e))}catch{}}},[r,m]);const h=n?.columns?.length?n.columns:void 0,p=!h||function(e,t){return e.some(e=>(e.sortField??("_select"!==e.key?e.key:""))===t&&""!==t)}(h,i.field)?i:{field:e,direction:t},g="desc"===p.direction?`-${p.field}`:p.field;return{sort:p,onSort:e=>{c.current=!0;const t=p.field===e?{field:e,direction:"asc"===p.direction?"desc":"asc"}:{field:e,direction:"asc"};if(s(t),l){try{localStorage.setItem(`sort-config-${r}`,JSON.stringify(t))}catch{}a({[l]:t})}},ordering:g}}function jn({filters:e,values:t,onChange:r,onClear:n,children:o}){const a=Object.values(t).filter(Boolean).length;/* @__PURE__ */
499
+ return _t("tr",{"data-row-idx":r,className:`cursor-pointer ${F===r?"bg-blue-50 ring-1 ring-inset ring-blue-300":w.has(n)?"bg-blue-50 hover:bg-blue-100":"hover:bg-gray-50"} ${C?.(t)??""}`,onClick:()=>k(t),onContextMenu:e=>((e,t)=>{if(e.shiftKey||qe(e.target))return;e.preventDefault();const r=f(t);w.has(r)||v(/* @__PURE__ */new Set([r]));const n=Pn(e.currentTarget)[0]?.dataset.colKey,o=n?p.find(e=>e.key===n)?.label:void 0;D({x:e.clientX,y:e.clientY,item:t,text:b(e.target),firstColumn:n&&o?{key:n,label:o}:null})})(e,t),onMouseEnter:N?()=>N(t):void 0,children:e.map(e=>/* @__PURE__ */_t("td",{"data-col-key":e.key,className:"px-4 py-3 whitespace-nowrap text-sm overflow-hidden",children:"_select"===e.key?/* @__PURE__ */_t(u,{"aria-label":j.table.selectRow,checked:w.has(n),onChange:()=>R(t),onClick:e=>e.stopPropagation(),style:{height:14,width:14}}):g(t,e.key)},e.key))},n)})})})}),J]})}function In({queryKey:e,fetchFn:t,extraParams:r={},pageSize:n=25}){const o=pt(null),a=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),l=$t({queryKey:e,queryFn:({pageParam:e=1})=>t({page:String(e),...a}),getNextPageParam:(e,t)=>{if(e.next)return t.length+1},initialPageParam:1}),{fetchNextPage:i,hasNextPage:s,isFetchingNextPage:c}=l,d=gt(e=>{const[t]=e;t.isIntersecting&&s&&!c&&i()},[i,s,c]);ht(()=>{const e=o.current;if(!e)return;let t=e.parentElement;for(;t;){const e=getComputedStyle(t).overflowY;if("auto"===e||"scroll"===e)break;t=t.parentElement}const r=new IntersectionObserver(d,{root:t,rootMargin:"200px",threshold:0});return r.observe(e),()=>r.disconnect()},[d]);const u=/* @__PURE__ */new Set;return{items:(l.data?.pages.flatMap(e=>e?.results??[])??[]).filter(e=>null!=e).filter(e=>{const t=e.id;return null==t||!u.has(t)&&(u.add(t),!0)}),totalCount:l.data?.pages[0]?.count??0,isLoading:l.isLoading,isError:l.isError,error:l.error,isFetchingNextPage:c,hasNextPage:!!s,sentinelRef:o,refetch:l.refetch}}function Dn(e){const t=e;return!!t&&"string"==typeof t.field&&t.field.length>0&&("asc"===t.direction||"desc"===t.direction)}function An(e,t="asc",r,n){const{prefs:o,save:a}=Ee(),l=r?`sort_${r}`:null,[i,s]=mt(()=>{if(l){if(Dn(o[l]))return o[l];try{const e=JSON.parse(localStorage.getItem(`sort-config-${r}`)||"null");if(Dn(e))return e}catch{}}return{field:e,direction:t}}),c=pt(!1),d=l?o[l]:void 0,u=pt(d);u.current=d,ht(()=>{if(!c.current&&Dn(d)){s(e=>e.field===d.field&&e.direction===d.direction?e:d);try{localStorage.setItem(`sort-config-${r}`,JSON.stringify(d))}catch{}}},[r,d?.field,d?.direction]);const{defaultConfig:m}=Mn(r);ht(()=>{const e=m?.sort;if(!c.current&&!Dn(u.current)&&Dn(e)){s(t=>t.field===e.field&&t.direction===e.direction?t:e);try{localStorage.setItem(`sort-config-${r}`,JSON.stringify(e))}catch{}}},[r,m]);const h=n?.columns?.length?n.columns:void 0,p=!h||function(e,t){return e.some(e=>(e.sortField??("_select"!==e.key?e.key:""))===t&&""!==t)}(h,i.field)?i:{field:e,direction:t},g="desc"===p.direction?`-${p.field}`:p.field;return{sort:p,onSort:e=>{c.current=!0;const t=p.field===e?{field:e,direction:"asc"===p.direction?"desc":"asc"}:{field:e,direction:"asc"};if(s(t),l){try{localStorage.setItem(`sort-config-${r}`,JSON.stringify(t))}catch{}a({[l]:t})}},ordering:g}}function jn({filters:e,values:t,onChange:r,onClear:n,children:o}){const a=Object.values(t).filter(Boolean).length;/* @__PURE__ */
500
500
  return St("div",{className:"flex items-center gap-3 flex-wrap",children:[e.map(e=>{const n=e.searchable??e.options.length>8;/* @__PURE__ */
501
- return _t(n?Rn:Bn,{filter:e,value:t[e.field]||"",onChange:t=>r(e.field,t)},e.field)}),o,a>0&&/* @__PURE__ */St("button",{onClick:n,className:"flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700",children:[
502
- /* @__PURE__ */_t(At,{className:"h-4 w-4"}),"Clear filters"]})]})}function Bn({filter:e,value:t,onChange:r}){const[n,o]=mt(!1),[a,l]=mt(-1),i=pt(null),s=pt(null),d=pt(null),u=pt(n);u.current=n;const m=pt({buffer:"",timer:null}),h=kt(),g=`${h}-listbox`,f=e=>`${h}-opt-${e}`,y=[{value:"",label:e.label},...e.options],b=t?y.findIndex(e=>e.value===t):0,k=t?e.options.find(e=>e.value===t)?.label:null,N=gt((e=!0)=>{o(!1),l(-1),e&&s.current?.focus()},[]),C=gt(()=>{l(b>=0?b:p(y)),o(!0)},[b,y]),M=gt(e=>{const t=y[e];t&&(r(t.value),N())},[y,r,N]);c(i,gt(()=>{n&&N(!1)},[n,N])),ht(()=>{if(n)return ot(e=>!("Escape"!==e.key||!u.current)&&(N(),!0))},[n,N]),ht(()=>{!n||a<0||d.current?.querySelector(`#${CSS.escape(f(a))}`)?.scrollIntoView({block:"nearest"})});/* @__PURE__ */
501
+ return _t(n?Bn:Rn,{filter:e,value:t[e.field]||"",onChange:t=>r(e.field,t)},e.field)}),o,a>0&&/* @__PURE__ */St("button",{onClick:n,className:"flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700",children:[
502
+ /* @__PURE__ */_t(At,{className:"h-4 w-4"}),"Clear filters"]})]})}function Rn({filter:e,value:t,onChange:r}){const[n,o]=mt(!1),[a,l]=mt(-1),i=pt(null),s=pt(null),d=pt(null),u=pt(n);u.current=n;const m=pt({buffer:"",timer:null}),h=kt(),g=`${h}-listbox`,f=e=>`${h}-opt-${e}`,y=[{value:"",label:e.label},...e.options],b=t?y.findIndex(e=>e.value===t):0,k=t?e.options.find(e=>e.value===t)?.label:null,N=gt((e=!0)=>{o(!1),l(-1),e&&s.current?.focus()},[]),C=gt(()=>{l(b>=0?b:p(y)),o(!0)},[b,y]),M=gt(e=>{const t=y[e];t&&(r(t.value),N())},[y,r,N]);c(i,gt(()=>{n&&N(!1)},[n,N])),ht(()=>{if(n)return ot(e=>!("Escape"!==e.key||!u.current)&&(N(),!0))},[n,N]),ht(()=>{!n||a<0||d.current?.querySelector(`#${CSS.escape(f(a))}`)?.scrollIntoView({block:"nearest"})});/* @__PURE__ */
503
503
  return St("div",{ref:i,className:"relative",children:[
504
504
  /* @__PURE__ */St("button",{ref:s,type:"button",role:"combobox","aria-haspopup":"listbox","aria-expanded":n,"aria-controls":n?g:void 0,"aria-activedescendant":n&&a>=0?f(a):void 0,onClick:()=>n?N():C(),onKeyDown:e=>{switch(e.key){case"ArrowDown":return e.preventDefault(),void(n?l(e=>w(y,e,1)):C());case"ArrowUp":return e.preventDefault(),void(n?l(e=>w(y,e,-1)):C());case"Home":return void(n&&(e.preventDefault(),l(p(y))));case"End":return void(n&&(e.preventDefault(),l(x(y))));case"Enter":return void(n&&(e.preventDefault(),M(a)));case" ":return e.preventDefault(),void(n?M(a):C());case"Escape":return void(n&&(e.preventDefault(),e.stopPropagation(),N()));case"Tab":return void(n&&N(!1));default:1!==e.key.length||e.metaKey||e.ctrlKey||e.altKey||(e.preventDefault(),(e=>{const t=m.current;t.timer&&clearTimeout(t.timer),t.buffer+=e,t.timer=setTimeout(()=>{t.buffer="",t.timer=null},500);const r=v(y,t.buffer,n?a:b);r<0||(n?l(r):M(r))})(e.key))}},className:"flex items-center gap-1.5 border rounded-lg px-2.5 py-1.5 text-sm transition-colors "+(t?"border-blue-400 bg-blue-50 text-blue-700":"border-gray-300 text-gray-600 hover:border-gray-400"),children:[
505
505
  /* @__PURE__ */_t("span",{className:"truncate max-w-[140px]",children:k||e.label}),t?
506
- /* @__PURE__ */_t("span",{"aria-hidden":"true",onClick:e=>{e.stopPropagation(),r("")},className:"cursor-pointer text-blue-400 hover:text-blue-600",children:/* @__PURE__ */_t(At,{className:"h-3.5 w-3.5"})}):/* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5 text-gray-400 transition-transform "+(n?"rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),n&&/* @__PURE__ */_t("div",{ref:d,id:g,role:"listbox",className:"absolute top-full left-0 mt-1 w-56 rounded-2xl z-[400] max-h-52 overflow-y-auto py-1",style:it(),children:y.map((e,t)=>/* @__PURE__ */_t("div",{id:f(t),role:"option","aria-selected":t===b,onPointerEnter:()=>l(t),onClick:()=>M(t),className:"mx-1 cursor-pointer truncate rounded-lg px-3 py-1.5 text-sm\n "+(t===a?"bg-blue-50 text-blue-700":t===b?"font-medium text-blue-600":"text-gray-700"),children:e.label},e.value||"__all__"))})]})}function Rn({filter:e,value:t,onChange:r}){const[n,o]=mt(!1),[a,l]=mt(""),i=pt(null),s=pt(null),d=t?e.options.find(e=>e.value===t)?.label:null;c(i,gt(()=>{n&&(o(!1),l(""))},[n])),ht(()=>{n&&setTimeout(()=>s.current?.focus(),50)},[n]);const u=a?e.options.filter(e=>e.label.toLowerCase().includes(a.toLowerCase())):e.options;/* @__PURE__ */
506
+ /* @__PURE__ */_t("span",{"aria-hidden":"true",onClick:e=>{e.stopPropagation(),r("")},className:"cursor-pointer text-blue-400 hover:text-blue-600",children:/* @__PURE__ */_t(At,{className:"h-3.5 w-3.5"})}):/* @__PURE__ */_t("svg",{className:"h-3.5 w-3.5 text-gray-400 transition-transform "+(n?"rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})]}),n&&/* @__PURE__ */_t("div",{ref:d,id:g,role:"listbox",className:"absolute top-full left-0 mt-1 w-56 rounded-2xl z-[400] max-h-52 overflow-y-auto py-1",style:it(),children:y.map((e,t)=>/* @__PURE__ */_t("div",{id:f(t),role:"option","aria-selected":t===b,onPointerEnter:()=>l(t),onClick:()=>M(t),className:"mx-1 cursor-pointer truncate rounded-lg px-3 py-1.5 text-sm\n "+(t===a?"bg-blue-50 text-blue-700":t===b?"font-medium text-blue-600":"text-gray-700"),children:e.label},e.value||"__all__"))})]})}function Bn({filter:e,value:t,onChange:r}){const[n,o]=mt(!1),[a,l]=mt(""),i=pt(null),s=pt(null),d=t?e.options.find(e=>e.value===t)?.label:null;c(i,gt(()=>{n&&(o(!1),l(""))},[n])),ht(()=>{n&&setTimeout(()=>s.current?.focus(),50)},[n]);const u=a?e.options.filter(e=>e.label.toLowerCase().includes(a.toLowerCase())):e.options;/* @__PURE__ */
507
507
  return St("div",{ref:i,className:"relative",children:[
508
508
  /* @__PURE__ */St("button",{onClick:()=>o(!n),className:"flex items-center gap-1.5 border rounded-lg px-2.5 py-1.5 text-sm transition-colors "+(t?"border-blue-400 bg-blue-50 text-blue-700":"border-gray-300 text-gray-600 hover:border-gray-400"),children:[
509
509
  /* @__PURE__ */_t("span",{className:"truncate max-w-[140px]",children:d||e.label}),t?
@@ -560,7 +560,7 @@ return St("td",{className:"px-2 py-1 font-mono text-gray-700",children:[n.length
560
560
  /* @__PURE__ */St("span",{className:"text-xs text-gray-600",children:[l," duplicate rows → ",t.length," merged line",1===t.length?"":"s"]}),
561
561
  /* @__PURE__ */St("div",{className:"flex gap-2",children:[
562
562
  /* @__PURE__ */_t(he,{onClick:o,className:"text-sm text-gray-500 hover:text-gray-700",children:"Cancel"}),
563
- /* @__PURE__ */_t("button",{type:"button",onClick:n,className:"bg-blue-600 text-white px-3 py-1.5 text-sm font-medium rounded-lg hover:bg-blue-700",children:"Proceed"})]})]})]})}function eo({columns:e,onImport:t,description:r,mergeDuplicates:n=!1}){const[o,a]=mt(()=>Array.from({length:15},()=>Array(e.length).fill(""))),[l,i]=mt(!1),[s,c]=mt(""),[d,u]=mt(null),[m,h]=mt(null),[p,g]=mt(null),f=e.length,y=e[0]?.title?.replace(" *","")||"value",b=o.filter(e=>e[0]?.trim()),x=b.length,w={};for(let t=1;t<e.length;t++){if("text"===Yn(e[t],t))continue;let r=0;for(const e of b){const n=parseFloat(Un(e[t]||""));isNaN(n)||(r+=n)}r>0&&(w[e[t].key]=r)}const v=e.map(e=>({key:e.key,title:e.title,width:e.width})),k=gt(t=>{const r=t.map(t=>{const r=[...t];for(;r.length<f;)r.push("");return r.slice(0,f).map((t,r)=>{const n=Yn(e[r],r);return"price"===n||"qty"===n?Un(t):t})});for(;r.length<15;)r.push(Array(f).fill(""));a(B(r,f))},[f,e]),N=ze({accept:".csv,.tsv,.txt",acceptHint:"CSV · TSV · TXT",multiple:!1,onAccept:([t])=>(t=>{const r=new FileReader;r.onload=t=>{const r=(t.target?.result||"").split("\n").map(e=>e.trim()).filter(Boolean).map(Xn);if(0===r.length)return;const n=Gn(r,e);if(n){const t=r.map(t=>e.map((e,r)=>n[r]>=0&&t[n[r]]||""));k(t)}else u(r)},r.readAsText(t)})(t)}),C=async e=>{i(!0);try{await t(e)}catch{c("Import failed.")}i(!1)},M=r||"Paste from spreadsheets, type directly, or upload a CSV. Rows don't need to be in order — they'll be matched. Values not in the list will be added to the end. Fields left blank will not be affected.";/* @__PURE__ */
563
+ /* @__PURE__ */_t("button",{type:"button",onClick:n,className:"bg-blue-600 text-white px-3 py-1.5 text-sm font-medium rounded-lg hover:bg-blue-700",children:"Proceed"})]})]})]})}function eo({columns:e,onImport:t,description:r,mergeDuplicates:n=!1}){const[o,a]=mt(()=>Array.from({length:15},()=>Array(e.length).fill(""))),[l,i]=mt(!1),[s,c]=mt(""),[d,u]=mt(null),[m,h]=mt(null),[p,g]=mt(null),f=e.length,y=e[0]?.title?.replace(" *","")||"value",b=o.filter(e=>e[0]?.trim()),x=b.length,w={};for(let t=1;t<e.length;t++){if("text"===Yn(e[t],t))continue;let r=0;for(const e of b){const n=parseFloat(Un(e[t]||""));isNaN(n)||(r+=n)}r>0&&(w[e[t].key]=r)}const v=e.map(e=>({key:e.key,title:e.title,width:e.width})),k=gt(t=>{const r=t.map(t=>{const r=[...t];for(;r.length<f;)r.push("");return r.slice(0,f).map((t,r)=>{const n=Yn(e[r],r);return"price"===n||"qty"===n?Un(t):t})});for(;r.length<15;)r.push(Array(f).fill(""));a(R(r,f))},[f,e]),N=ze({accept:".csv,.tsv,.txt",acceptHint:"CSV · TSV · TXT",multiple:!1,onAccept:([t])=>(t=>{const r=new FileReader;r.onload=t=>{const r=(t.target?.result||"").split("\n").map(e=>e.trim()).filter(Boolean).map(Xn);if(0===r.length)return;const n=Gn(r,e);if(n){const t=r.map(t=>e.map((e,r)=>n[r]>=0&&t[n[r]]||""));k(t)}else u(r)},r.readAsText(t)})(t)}),C=async e=>{i(!0);try{await t(e)}catch{c("Import failed.")}i(!1)},M=r||"Paste from spreadsheets, type directly, or upload a CSV. Rows don't need to be in order — they'll be matched. Values not in the list will be added to the end. Fields left blank will not be affected.";/* @__PURE__ */
564
564
  return St("div",{...N.zoneProps,className:["border rounded-lg bg-gray-50 mb-3 overflow-hidden transition-colors",N.dragOver?"border-dashed border-blue-500 bg-blue-50":"border-gray-200"].join(" "),children:[
565
565
  /* @__PURE__ */St("div",{className:"px-4 pt-3 pb-2 flex items-center justify-between",children:[
566
566
  /* @__PURE__ */St("p",{className:"text-xs text-gray-500",children:[M,
@@ -569,7 +569,7 @@ return St("div",{...N.zoneProps,className:["border rounded-lg bg-gray-50 mb-3 ov
569
569
  /* @__PURE__ */_t("input",{...N.inputProps}),
570
570
  /* @__PURE__ */_t("button",{type:"button",onClick:N.open,className:"text-blue-600 border border-blue-200 bg-white px-3 py-1.5 text-sm font-medium rounded-lg hover:bg-blue-50 hover:border-blue-300",children:"Upload CSV"}),
571
571
  /* @__PURE__ */_t("button",{type:"button",onClick:async()=>{const t=o.filter(e=>e[0]?.trim()).map(t=>{const r={};return e.forEach((e,n)=>{const o=t[n]?.trim()||"",a=Yn(e,n);r[e.key]="price"===a||"qty"===a?Un(o):o}),r});if(0===t.length)return void c(`Enter at least one ${y.toLowerCase()}.`);c("");const r=Hn(t,e[0].key);if(r.length>0)if(n)g({rows:t,groups:r});else{const e={};for(const t of r)e[t.key.toUpperCase()]="first";h({rows:t,groups:r,resolutions:e})}else await C(t)},disabled:l||0===x,className:"text-green-600 border border-green-200 bg-white px-3 py-1.5 text-sm font-medium rounded-lg hover:bg-green-50 hover:border-green-300 disabled:opacity-50",children:l?"Importing...":`Import ${x} Lines`})]})]}),d&&/* @__PURE__ */_t("div",{className:"px-4 pb-2",children:/* @__PURE__ */_t(Jn,{csvPreview:d,targetColumns:e,onConfirm:t=>{if(!d)return;const r=d.map(r=>e.map((e,n)=>t[n]>=0&&r[t[n]]||""));k(r),u(null)},onCancel:()=>u(null)})}),m&&/* @__PURE__ */_t("div",{className:"px-4 pb-2",children:/* @__PURE__ */_t(Qn,{rows:m.rows,groups:m.groups,columns:e,resolutions:m.resolutions,onResolutionChange:(e,t)=>h(r=>r?{...r,resolutions:{...r.resolutions,[e]:t}}:r),onConfirm:async()=>{if(!m)return;const{rows:e,groups:t,resolutions:r}=m,n=/* @__PURE__ */new Set;for(const e of t){const t=r[e.key.toUpperCase()]||"first",o=e.rowIndices;if("first"===t)for(let e=1;e<o.length;e++)n.add(o[e]);else if("last"===t)for(let e=0;e<o.length-1;e++)n.add(o[e]);else if("skip"===t)for(const e of o)n.add(e)}const o=e.filter((e,t)=>!n.has(t));h(null),0!==o.length?await C(o):c("All rows skipped.")},onCancel:()=>h(null)})}),p&&/* @__PURE__ */_t("div",{className:"px-4 pb-2",children:/* @__PURE__ */_t(Zn,{rows:p.rows,groups:p.groups,columns:e,onConfirm:async()=>{if(!p)return;const t=function(e,t,r){const n=r[0].key,o=/* @__PURE__ */new Map,a=/* @__PURE__ */new Set;for(const e of t)o.set(e.rowIndices[0],e),e.rowIndices.slice(1).forEach(e=>a.add(e));const l=[];return e.forEach((t,i)=>{const s=o.get(i);if(s){const t={};for(const o of r){if(o.key===n){t[o.key]=s.key;continue}const r=s.rowIndices.map(t=>(e[t]?.[o.key]??"").trim()).filter(e=>""!==e&&Number.isFinite(Number(e))).map(Number);t[o.key]=r.length>0?String(r.reduce((e,t)=>e+t,0)):""}l.push(t)}else a.has(i)||l.push(t)}),l}(p.rows,p.groups,e);g(null),await C(t)},onCancel:()=>g(null)})}),
572
- /* @__PURE__ */_t(R,{columns:v,data:o,onChange:a}),
572
+ /* @__PURE__ */_t(B,{columns:v,data:o,onChange:a}),
573
573
  /* @__PURE__ */_t(Oe,{rejections:N.rejections,className:"px-4 py-1"}),s&&/* @__PURE__ */_t("p",{className:"text-xs text-red-600 px-4 py-1",children:s})]})}function to(e){if(!e)return"—";const t=Math.max(0,Date.now()-e.getTime());return t<1500?"just now":t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:`${Math.round(t/36e5)}h ago`}function ro({healthCheck:e,healthUrl:t="/api/health/",pollMs:r=15e3,requestTimeoutMs:n=5e3,user:o,version:a=Y}){const[l,i]=mt("checking"),[s,c]=mt(null),[d,u]=mt(null),[m,h]=mt(null),[p,g]=mt(navigator.onLine),[f,y]=mt(!1),[b,x]=mt({left:0,top:0}),[,w]=mt(0),v=pt(!1),k=pt(null),N=pt(null),C=pt(e),M=pt(t),S=pt(n);C.current=e,M.current=t,S.current=n;const _=gt(async()=>{const e=performance.now();try{let t;if(C.current)t=await C.current();else{const r=new AbortController,n=setTimeout(()=>r.abort(),S.current);try{t={ok:(await fetch(M.current,{method:"GET",cache:"no-store",signal:r.signal})).ok,latencyMs:Math.round(performance.now()-e)}}finally{clearTimeout(n)}}if(v.current)return;t.ok?(i("connected"),c(/* @__PURE__ */new Date),h(t.latencyMs??Math.round(performance.now()-e))):(i("disconnected"),u(/* @__PURE__ */new Date))}catch{v.current||(i("disconnected"),u(/* @__PURE__ */new Date))}},[]);ht(()=>{v.current=!1,_();const e=setInterval(_,r);return()=>{v.current=!0,clearInterval(e)}},[_,r]),ht(()=>{const e=()=>g(!0),t=()=>g(!1);return window.addEventListener("online",e),window.addEventListener("offline",t),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",t)}},[]),ht(()=>{if(!f)return;const e=setInterval(()=>w(e=>e+1),1e3);return()=>clearInterval(e)},[f]);const L=gt(()=>{if(!k.current)return;const e=k.current.getBoundingClientRect(),t=N.current?.offsetHeight||320,r=e.left+e.width/2,n=Math.max(8,Math.min(window.innerWidth-320-8,r-160)),o=e.top+e.height/2>window.innerHeight/2?Math.max(8,e.top-t-6):e.bottom+6;x({left:n,top:o})},[]);ht(()=>{if(f)return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[f,L]),ft(()=>{f&&N.current&&L()},[f,L]),ht(()=>{if(!f)return;const e=e=>{const t=e.target;N.current?.contains(t)||k.current?.contains(t)||y(!1)},t=e=>{"Escape"===e.key&&y(!1)};window.addEventListener("mousedown",e),window.addEventListener("keydown",t);const r=at(()=>y(!1));return()=>{window.removeEventListener("mousedown",e),window.removeEventListener("keydown",t),r()}},[f]);const E="connected"===l?"#16a34a":"disconnected"===l?"#dc2626":"#9ca3af",P="connected"===l?"Connected":"disconnected"===l?"Disconnected":"Checking…",T="connected"===l?"bg-green-500":"disconnected"===l?"bg-red-500":"bg-gray-400",$=o?o.name?.trim()||o.email||"—":"Not signed in",I=o?.role||"";/* @__PURE__ */
574
574
  return St(Lt,{children:[
575
575
  /* @__PURE__ */_t("button",{ref:k,type:"button",onClick:()=>y(e=>!e),className:"shrink-0 inline-flex items-center justify-center rounded-md p-2 transition-colors hover:bg-white/20 "+("disconnected"!==l||f?"":"animate-pulse"),title:`${P}${s?` · last ok ${s.toLocaleTimeString()}`:""}`,"aria-label":P,"aria-expanded":f,children:/* @__PURE__ */St("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:E,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[
@@ -637,4 +637,4 @@ return St(Lt,{children:[
637
637
  /* @__PURE__ */_t(Ke,{}),
638
638
  /* @__PURE__ */St(Xe,{onClick:async()=>{u(!1);const e=await b();e!==oo?e&&a&&a(e):U.error(`${t} took too long to load. Please try again.`)},children:[
639
639
  /* @__PURE__ */_t("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */_t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),"Send by Email"]})]})]}),document.body)]})}var io=ct(null);function so({value:e,children:t}){/* @__PURE__ */
640
- return _t(io.Provider,{value:e,children:t})}function co(){return bt(io)??(e=>{throw new Error(`efficient-shell: cannot fetch ${e} — no <ShellEntityFetcherProvider> mounted. If your app registers entity windows, supply an entityFetcher.`)})}function uo(e){const t=ie();ht(()=>{if(!t)return;const r=t=>{const r="KeyN"===t.code||"N"===t.key||"n"===t.key;t.altKey&&t.shiftKey&&r&&!t.metaKey&&!t.ctrlKey&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t])}function mo(e){const t=ie();ht(()=>{if(!e||!t)return;const r=t=>{const r="KeyE"===t.code||"E"===t.key||"e"===t.key;t.altKey&&t.shiftKey&&r&&!t.metaKey&&!t.ctrlKey&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t])}function ho(e,t){const r=e?.modalId;return"string"!=typeof r||""===r||(!t||r===t)}function po(e){const t=ce();ht(()=>{if(!e)return;const r=r=>{ho(r.detail,t)&&e()};return document.addEventListener("modal-save",r),()=>document.removeEventListener("modal-save",r)},[e,t])}function go(e){const t=ce();ht(()=>{if(!e)return;const r=r=>{ho(r.detail,t)&&e()};return document.addEventListener("modal-duplicate",r),()=>document.removeEventListener("modal-duplicate",r)},[e,t])}export{or as BLOCKED_PCT_CPU,bn as BehaviorPanel,eo as BulkImportGrid,no as ChangePasswordForm,mn as Customization,Gt as DEV_BANNER_TEXT,zr as Desktop,Rr as DesktopHostProvider,Zt as DevIndicator,$n as EntityList,jn as FilterBar,dr as LOG_CAP,ln as Layout,mr as MIN_EVENT_SAMPLES,ur as MIN_GROUP_SAMPLES,qt as NotificationBell,lo as PdfActionButton,Tr as PerfStats,En as ResizableTable,nr as SMOOTH_FPS,ro as ServerStatusIndicator,Xt as ShellContextMenu,so as ShellEntityFetcherProvider,Ft as ShortcutHelp,wn as SoundsPanel,Jr as StartMenu,vn as SystemPreferences,rr as WidgetManager,hr as appendPerfRecord,Qt as applyDevTitle,cr as classifyActivity,ir as classifyPerf,jt as createWindowRegistry,Bt as createWindowTarget,Er as describeMachine,zn as describePerfReport,Hn as findDuplicateKeys,Jt as isDevEnv,pr as isInteracting,Kn as mergeBulkItems,vr as perfLogToCsv,On as perfReportFile,Lr as readPerfEnvironment,Cr as requestAsyncEnvironment,lr as summariseFrames,xr as summarisePerfLog,Ln as useColumnConfig,Wr as useDesktopHost,mo as useEditHotkey,Wn as useFilters,In as useInfiniteScroll,go as useModalDuplicate,po as useModalSave,uo as useNewHotkey,co as useShellEntityFetcher,An as useSort,kn as useTableNav,Rt as useWindowTarget};
640
+ return _t(io.Provider,{value:e,children:t})}function co(){return bt(io)??(e=>{throw new Error(`efficient-shell: cannot fetch ${e} — no <ShellEntityFetcherProvider> mounted. If your app registers entity windows, supply an entityFetcher.`)})}function uo(e){const t=ie();ht(()=>{if(!t)return;const r=t=>{const r="KeyN"===t.code||"N"===t.key||"n"===t.key;t.altKey&&t.shiftKey&&r&&!t.metaKey&&!t.ctrlKey&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t])}function mo(e){const t=ie();ht(()=>{if(!e||!t)return;const r=t=>{const r="KeyE"===t.code||"E"===t.key||"e"===t.key;t.altKey&&t.shiftKey&&r&&!t.metaKey&&!t.ctrlKey&&(t.preventDefault(),t.stopPropagation(),e())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[e,t])}function ho(e,t){const r=e?.modalId;return"string"!=typeof r||""===r||(!t||r===t)}function po(e){const t=ce();ht(()=>{if(!e)return;const r=r=>{ho(r.detail,t)&&e()};return document.addEventListener("modal-save",r),()=>document.removeEventListener("modal-save",r)},[e,t])}function go(e){const t=ce();ht(()=>{if(!e)return;const r=r=>{ho(r.detail,t)&&e()};return document.addEventListener("modal-duplicate",r),()=>document.removeEventListener("modal-duplicate",r)},[e,t])}export{or as BLOCKED_PCT_CPU,bn as BehaviorPanel,eo as BulkImportGrid,no as ChangePasswordForm,mn as Customization,Gt as DEV_BANNER_TEXT,zr as Desktop,Br as DesktopHostProvider,Zt as DevIndicator,$n as EntityList,jn as FilterBar,dr as LOG_CAP,ln as Layout,mr as MIN_EVENT_SAMPLES,ur as MIN_GROUP_SAMPLES,qt as NotificationBell,lo as PdfActionButton,Tr as PerfStats,En as ResizableTable,nr as SMOOTH_FPS,ro as ServerStatusIndicator,Xt as ShellContextMenu,so as ShellEntityFetcherProvider,Ft as ShortcutHelp,wn as SoundsPanel,Jr as StartMenu,vn as SystemPreferences,rr as WidgetManager,hr as appendPerfRecord,Qt as applyDevTitle,cr as classifyActivity,ir as classifyPerf,jt as createWindowRegistry,Rt as createWindowTarget,Er as describeMachine,zn as describePerfReport,Hn as findDuplicateKeys,Jt as isDevEnv,pr as isInteracting,Kn as mergeBulkItems,vr as perfLogToCsv,On as perfReportFile,Lr as readPerfEnvironment,Cr as requestAsyncEnvironment,lr as summariseFrames,xr as summarisePerfLog,Ln as useColumnConfig,Wr as useDesktopHost,mo as useEditHotkey,Wn as useFilters,In as useInfiniteScroll,go as useModalDuplicate,po as useModalSave,uo as useNewHotkey,co as useShellEntityFetcher,An as useSort,kn as useTableNav,Bt as useWindowTarget};