efficient-shell 10.23.0 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +32 -5
  2. package/dist/Browser-PTDZDMCG.js +44 -0
  3. package/dist/Calculator-KP57FK7Y.js +29 -0
  4. package/dist/CurrencyConverter-W66ZDA6I.js +21 -0
  5. package/dist/{Documents-MTCJXTXY.js → Documents-EASK3J36.js} +3 -3
  6. package/dist/{Files-XMZ3XBP4.js → Files-YT4Z4J36.js} +28 -28
  7. package/dist/Notepad-T6NV4BSM.js +24 -0
  8. package/dist/{PomodoroTimer-5ELVNJEU.js → PomodoroTimer-6B2MNLWD.js} +31 -31
  9. package/dist/{Preview-QCA6XUDU.js → Preview-KHCQHAWG.js} +17 -17
  10. package/dist/Sidebar-BCTWRG7P.js +44 -0
  11. package/dist/{Spreadsheet-EKYP6XIX.js → Spreadsheet-IQZECLJW.js} +11 -11
  12. package/dist/{Stock-TRG6CAZJ.js → Stock-GCCTYXAG.js} +3 -3
  13. package/dist/{Weather-YGTT7UWR.js → Weather-DL4IZELD.js} +17 -17
  14. package/dist/{WorldClock-UCX5LCJB.js → WorldClock-ZVN5O77W.js} +6 -6
  15. package/dist/ai/index.js +91 -91
  16. package/dist/api/shellHttp.d.ts +52 -0
  17. package/dist/api/shellHttp.js +1 -0
  18. package/dist/apps/index.js +1 -1
  19. package/dist/bin/media-host-check.js +1 -1
  20. package/dist/bin/ui-check.js +1 -1
  21. package/dist/brand.css +1 -1
  22. package/dist/chunk-2QY5BJLA.js +2 -0
  23. package/dist/chunk-3XZFWR6T.js +13 -0
  24. package/dist/{chunk-CIHR5ZKF.js → chunk-4DDL6NXB.js} +1 -1
  25. package/dist/chunk-4LXCCZDM.js +1 -0
  26. package/dist/{chunk-U2RFKQVA.js → chunk-5H4SWQGM.js} +1 -1
  27. package/dist/{chunk-USWA6YNZ.js → chunk-5PDHKH2A.js} +3 -3
  28. package/dist/{chunk-GCZU4XFA.js → chunk-5WY5DQI7.js} +1 -1
  29. package/dist/{chunk-75UD5ZMP.js → chunk-6IOFNPR6.js} +3 -3
  30. package/dist/{chunk-OTITQ3IH.js → chunk-6KGIHI6X.js} +7 -7
  31. package/dist/{chunk-5RQJRD2E.js → chunk-7DQ3PM5Z.js} +1 -1
  32. package/dist/{chunk-YOZGW2RB.js → chunk-7FW2BQTV.js} +1 -1
  33. package/dist/chunk-AIJ3G6BD.js +1 -0
  34. package/dist/{chunk-DRUQH4ZE.js → chunk-AIJ6OR6X.js} +2 -2
  35. package/dist/{chunk-RV2FGSGH.js → chunk-ALTBTO3Z.js} +2 -2
  36. package/dist/{chunk-VCCGS6Q2.js → chunk-AM6HSHT5.js} +19 -19
  37. package/dist/chunk-ATMJ5ZPK.js +1 -0
  38. package/dist/{chunk-CQEVJG43.js → chunk-AWGJIDBR.js} +1 -1
  39. package/dist/{chunk-XJPKDTQN.js → chunk-BUO7XCYR.js} +12 -12
  40. package/dist/{chunk-USVL5SLG.js → chunk-D5HGRACW.js} +1 -1
  41. package/dist/{chunk-JET2TKEQ.js → chunk-DOF56HTO.js} +5 -5
  42. package/dist/chunk-E6FDUFPH.js +1 -0
  43. package/dist/chunk-ETJRGQNG.js +1 -0
  44. package/dist/chunk-F3ZOO23R.js +1 -0
  45. package/dist/chunk-HNUKXGYP.js +5 -0
  46. package/dist/chunk-HNVSVTNC.js +16 -0
  47. package/dist/{chunk-GOXQJCXG.js → chunk-HUU4XMWE.js} +17 -17
  48. package/dist/{chunk-Z3SLQKE6.js → chunk-ILY4DU3D.js} +1 -1
  49. package/dist/chunk-IQZD6QQF.js +99 -0
  50. package/dist/{chunk-E5QPXEKN.js → chunk-JFBL4PR3.js} +1 -1
  51. package/dist/{chunk-E6LQY6TB.js → chunk-KIXTJNHQ.js} +2 -2
  52. package/dist/{chunk-DGWS4GTI.js → chunk-KXU4ORKE.js} +1 -1
  53. package/dist/chunk-KYBXJL6A.js +23 -0
  54. package/dist/chunk-LH7IKIGE.js +1 -0
  55. package/dist/{chunk-JPOYR5AO.js → chunk-NZISMTQE.js} +5 -5
  56. package/dist/chunk-O3MBPAWZ.js +2 -0
  57. package/dist/{chunk-QWCEKHAP.js → chunk-OEPYQUXZ.js} +9 -9
  58. package/dist/{chunk-HUA3TGMM.js → chunk-P2C33RHT.js} +1 -1
  59. package/dist/{chunk-CX4XR4HO.js → chunk-PLC656AN.js} +1 -1
  60. package/dist/chunk-Q5Z3KHT2.js +1 -0
  61. package/dist/{chunk-RZQGPWSN.js → chunk-QOI4GQVH.js} +1 -1
  62. package/dist/{chunk-G7BBSHDF.js → chunk-QRU55BUS.js} +1 -1
  63. package/dist/{chunk-O52BQ5DP.js → chunk-QYXZC37J.js} +1 -1
  64. package/dist/{chunk-DBL7MFCB.js → chunk-RBZKV3ED.js} +5 -5
  65. package/dist/chunk-STKJA4PV.js +1 -0
  66. package/dist/chunk-SX3SG522.js +13 -0
  67. package/dist/{chunk-GC3DA6D6.js → chunk-T6BGS26U.js} +1 -1
  68. package/dist/{chunk-ZTV2BA3P.js → chunk-U6LKNGC6.js} +1 -1
  69. package/dist/chunk-UKBXQXDZ.js +1 -0
  70. package/dist/chunk-ULJQYXHB.js +1 -0
  71. package/dist/{chunk-I4DLYOPO.js → chunk-V2J2AHDW.js} +4 -4
  72. package/dist/chunk-WBJ6KNUF.js +1 -0
  73. package/dist/{chunk-Z46MSUTP.js → chunk-WLYYC3AP.js} +1 -1
  74. package/dist/{chunk-OGU5JE52.js → chunk-WOAMPTZI.js} +6 -6
  75. package/dist/data/DataTable.js +1 -1
  76. package/dist/data/EntityList.d.ts +125 -0
  77. package/dist/data/EntityList.js +2 -0
  78. package/dist/data/ResizableTable.d.ts +31 -0
  79. package/dist/data/ResizableTable.js +2 -0
  80. package/dist/data/useColumnConfig.d.ts +68 -0
  81. package/dist/data/useColumnConfig.js +2 -0
  82. package/dist/data/useSort.d.ts +55 -0
  83. package/dist/data/useSort.js +2 -0
  84. package/dist/data/useTableNav.d.ts +28 -0
  85. package/dist/data/useTableNav.js +2 -0
  86. package/dist/format/index.d.ts +1 -1
  87. package/dist/format/index.js +1 -1
  88. package/dist/forms/BorderInput.js +1 -1
  89. package/dist/forms/BrandAssetEditor.js +1 -1
  90. package/dist/forms/ColorPicker.js +1 -1
  91. package/dist/forms/CornersInput.js +1 -1
  92. package/dist/forms/DateRangePicker.js +1 -1
  93. package/dist/forms/Input.d.ts +50 -2
  94. package/dist/forms/Input.js +1 -1
  95. package/dist/forms/InputNumber.js +1 -1
  96. package/dist/forms/LinkPicker.js +1 -1
  97. package/dist/forms/MediaLibrary.js +1 -1
  98. package/dist/forms/MediaUploadGrid.js +1 -1
  99. package/dist/forms/PositionInput.js +1 -1
  100. package/dist/forms/SidesInput.js +1 -1
  101. package/dist/forms/Slider.js +1 -1
  102. package/dist/forms/SplitButton.js +1 -1
  103. package/dist/forms/WidthsBar.js +1 -1
  104. package/dist/forms/linkHref.js +1 -1
  105. package/dist/icons/efficient-glyphs.js +1 -1
  106. package/dist/icons/efficient-looks.js +1 -1
  107. package/dist/icons/efficient-meanings.d.ts +2 -2
  108. package/dist/icons/efficient-meanings.js +1 -1
  109. package/dist/icons/efficient.js +1 -1
  110. package/dist/icons/looks/map.js +1 -1
  111. package/dist/icons/payment.js +1 -1
  112. package/dist/icons/sets.js +1 -1
  113. package/dist/index.d.ts +15 -318
  114. package/dist/index.js +666 -694
  115. package/dist/markup/index.d.ts +55 -11
  116. package/dist/markup/index.js +1 -1
  117. package/dist/motion/values.d.ts +75 -0
  118. package/dist/motion/values.js +1 -0
  119. package/dist/motion.css +26 -0
  120. package/dist/page-tabs/index.js +4 -4
  121. package/dist/shell/ContextMenu.js +1 -1
  122. package/dist/shell/DropdownMenu.js +1 -1
  123. package/dist/shell/HelpCenter.js +1 -1
  124. package/dist/shell/ImageLightbox.js +1 -1
  125. package/dist/shell/LanguageSelect.js +1 -1
  126. package/dist/shell/Markdown.js +1 -1
  127. package/dist/shell/PopupMenu.js +1 -1
  128. package/dist/shell/SearchableSelect.d.ts +11 -1
  129. package/dist/shell/SearchableSelect.js +1 -1
  130. package/dist/shell/TopNav.js +1 -1
  131. package/dist/telemetry/index.js +1 -1
  132. package/dist/templates/AuthScreen.js +1 -1
  133. package/dist/templates/ChatTemplate.js +1 -1
  134. package/dist/templates/CheckoutTemplate.js +1 -1
  135. package/dist/templates/DataTablePage.js +1 -1
  136. package/dist/templates/FormLayoutPage.js +1 -1
  137. package/dist/tokens/type.d.ts +3 -31
  138. package/dist/tokens/type.js +1 -1
  139. package/dist/ui/index.d.ts +8 -1
  140. package/dist/ui/index.js +1 -1
  141. package/dist/version.js +1 -1
  142. package/package.json +3 -2
  143. package/dist/Browser-GTQKXJQ6.js +0 -43
  144. package/dist/Calculator-PM4TYWTE.js +0 -29
  145. package/dist/CurrencyConverter-4I2ENTSX.js +0 -21
  146. package/dist/Notepad-QIJN7VDZ.js +0 -24
  147. package/dist/Sidebar-7LN3ZEF4.js +0 -44
  148. package/dist/chunk-7IY47EKR.js +0 -1
  149. package/dist/chunk-7RP7QTRF.js +0 -12
  150. package/dist/chunk-CY5N5OA3.js +0 -2
  151. package/dist/chunk-DHKRXHJN.js +0 -1
  152. package/dist/chunk-H475WZPF.js +0 -23
  153. package/dist/chunk-I3XM2PSQ.js +0 -100
  154. package/dist/chunk-MAMWQCJ6.js +0 -2
  155. package/dist/chunk-OFCHJWM2.js +0 -1
  156. package/dist/chunk-PJPK2ADX.js +0 -1
  157. /package/dist/{chunk-CSA6CGXS.js → chunk-2F5SLLBJ.js} +0 -0
package/README.md CHANGED
@@ -1889,11 +1889,22 @@ draws its own controls it restyles them. `<html class="rosh-host-elements">`
1889
1889
  turns those three off. The kit's own controls stay dark through their
1890
1890
  remapped utility classes.
1891
1891
 
1892
+ **The list comes too.** `EntityList` over `ResizableTable` is the admin
1893
+ portals' list: drag a heading to reorder, drag its edge to resize, Reset and
1894
+ the column picker in the footer, the row menu, keyboard navigation. It and its
1895
+ hooks (`useSort`, `useColumnConfig`, `useTableNav`) are in the kit. Column
1896
+ layouts and sort persist through `<ShellPrefsProvider>` when you mount one, and
1897
+ in this browser's `localStorage` otherwise. The admin-saved defaults
1898
+ (`GET /auth/default-columns/{tableId}/`) are read once per table through the
1899
+ client you pass `setShellApiClient`, and not at all without one. Paging is
1900
+ yours: `useInfiniteScroll` is react-query and stays on the root, so a kit host
1901
+ feeds `items`, `totalCount` and `sentinelRef` from its own query.
1902
+
1892
1903
  What you do not get: `Modal` and the window manager, `Layout`, `Desktop`,
1893
1904
  `StartMenu`, `GlobalSearch`, the settings panels, the bundled apps, and the
1894
- components that reach an optional peer for their own reasons (`EntityList`,
1895
- `ResizableTable` and the react-query data hooks, `FilterBar`, `UndoControls`,
1896
- `BulkImportGrid`, `ConfirmProvider`/`confirm`).
1905
+ components that reach an optional peer for their own reasons
1906
+ (`useInfiniteScroll` and the other react-query data hooks, `FilterBar`,
1907
+ `UndoControls`, `BulkImportGrid`, `ConfirmProvider`/`confirm`).
1897
1908
 
1898
1909
  **Stylesheets: import exactly one.** `ui.css` is the kit; `styles.css` is the
1899
1910
  umbrella over the kit *plus* the window/taskbar/desktop rules. Taking both
@@ -2231,6 +2242,20 @@ Border width: `--border-hairline` 1px, `--border-strong` 2px, `--border-accent`
2231
2242
  4px. Code takes the same numbers from `efficient-shell/ui`: `TYPE_SCALE`,
2232
2243
  `FONT_WEIGHTS`, `MOTION_DURATIONS`, `BORDER_WIDTHS`.
2233
2244
 
2245
+ **Page motion.** The animations a website page plays — a block arriving, a card
2246
+ on hover, a row that loops, a number counting up — are not the chrome's
2247
+ motion. Each timed one has a Duration and a Delay in seconds, like Wix:
2248
+ `MOTION_TIMING` gives every group its default, its ends and its step (Entrance
2249
+ 0.6 s in 0–4 s, Hover 0.7 s, Loop 50 s in 1–120 s, Click 0.3 s, Count up 1.4 s;
2250
+ every Delay starts at 0). `motionSeconds(group, 'duration' | 'delay', stored)`
2251
+ reads a stored value into its range and onto its step. `MOTION_EASING` has
2252
+ `arrive`, `loop` and `media` (a card picture on hover), `HOVER_MOTION` the
2253
+ hover distances, and `rotateDegrees(spokes)` turns a wheel by one spoke (72°
2254
+ when the count is unknown). `efficient-shell/motion.css` declares the same
2255
+ defaults as `--page-motion-*`, `--page-ease-*` and `--page-hover-*`. A
2256
+ published page takes them from `efficient-shell/format`, the kit from
2257
+ `efficient-shell/ui`.
2258
+
2234
2259
  **Corners.** A component does not pick a step of the scale for itself; it asks
2235
2260
  for the radius of what it is. Five role tokens, each defaulting to the step that
2236
2261
  role has always drawn, so they change nothing until you set one:
@@ -3954,13 +3979,14 @@ keeps its own renderer and walks the same tree or token list.
3954
3979
  | `1. ` at the start of a line | a numbered line, one level: 1-3 digits, `. `, words; the number is kept as typed | yes |
3955
3980
  | `[x]{underline}`, `[x]{sup}`, `[x]{sub}` | underline, superscript, subscript (tree only) | `applyMark` / `toggleMark` |
3956
3981
  | `[x]{color=name}` / `[x]{color=#rrggbb}` | a theme colour by name (`isColorName`), or any colour as exactly six hex digits (`isColorValue`; saved lowercase) (tree only) | `applyColor` / `colorOver` |
3982
+ | `[x]{style=id}` | one of the site's text styles, `heading-1` … `body-7` (`isStyleId`) (tree only) | `styleOver` |
3957
3983
  | `@@x@@`, `++x++` | Emphasis, Strong (the storefront's old word styles). `++` opens only at a word start, so `A++ rated tyres, A++ service` is plain text | no — read only |
3958
3984
  | `*x*`, `#x#`, `[x]` | legacy accent, bold, italic (per product set) | no — read only |
3959
3985
 
3960
3986
  The three names a merchant sees are in `MARK_NAMES`. A run never crosses a line
3961
3987
  break, and runs, spans and links nest up to four levels
3962
3988
  (`[**_[x]{sup}_**]{color=accent}`); a fifth stays as typed. Any block after `]`
3963
- that is not exactly one of the four (`[x]{foo}`, `[x]{color=#f00}`,
3989
+ that is not exactly one of the five (`[x]{foo}`, `[x]{color=#f00}`, `[x]{style=Body 6}`,
3964
3990
  `[x]{{first_name}}`) is plain text. The spans and the numbered line are read by
3965
3991
  `parseMarkup` only: `tokenizeInline` keeps them as text, so a renderer that has
3966
3992
  not learned them prints the delimiters.
@@ -3973,9 +3999,10 @@ not learned them prints the delimiters.
3973
3999
  | `tokenizeInline(value, rules)`, `stripInline(value, rules)` | The flat reading older renderers use: runs only, no links, no nesting. Tokens ALTERNATE, starting and ending with a `text` token that may be empty. `stripInline` is the only correct source for an `alt`, an `aria-label` or a structured-data field. |
3974
4000
  | `applyMark(text, start, end, style, rules?, placeholders?)`, `markedAt`, `MARKUP_TOOLS`, `markupTools`, `COPY_FIELD_TOOLS`, `MARK_PLACEHOLDERS` | The writer behind a toolbar button (pressing the same button again unwraps), whether a button is pressed, and the button descriptors. A copy field offers bold, italic and strike. |
3975
4001
  | `applyColor(text, start, end, name)`, `isColorName`, `isColorValue`, `spanFor` | A colour carries a value, so it has its own writer: it writes, changes and (`null`) takes off `[x]{color=name}`, and changes nothing for a value `isColorValue` refuses (`#f00`, `rgb()`, a typo). |
4002
+ | `colorRole(value)`, `COLOR_SLOTS` | The ONE reading of a saved colour: `{ kind: 'slot', slot }` for `main`, `text`, `background` or `muted` — a colour of the theme of the section the words sit in — or `{ kind: 'hex', hex }` for a 6-digit hex. Null for anything else (an old name such as `accent`), which a renderer draws as plain words. Every renderer and panel reads a colour through it and maps the role to its own paint. |
3976
4003
  | `findLink`, `writeLink`, `removeLink` | The link window's reading and writing, with the parser's own link rule. |
3977
4004
  | `markedLines`, `writeMarkedLines`, `sameMarks` | The saved string as characters, each carrying its runs, and back byte for byte — what an editor that hides the delimiters edits. |
3978
- | `toggleMark`, `marksIn`, `linkOver`, `unlinkAt`, `colorOver`, `colorIn`, `setList`, `listIn`, `clearMarks`, `clearStyle` | Writers that act on the WORDS whichever runs they sit in, splitting a run rather than crossing a delimiter, and the readers a toolbar draws its pressed state from. |
4005
+ | `toggleMark`, `marksIn`, `linkOver`, `unlinkAt`, `colorOver`, `colorIn`, `styleOver`, `styleIn`, `setList`, `listIn`, `clearMarks`, `clearStyle` | Writers that act on the WORDS whichever runs they sit in, splitting a run rather than crossing a delimiter, and the readers a toolbar draws its pressed state from. |
3979
4006
  | `STANDARD_MARKUP`, `STOREFRONT_MARKUP`, `CAMPAIGN_MARKUP`, `RETIRED_MARKS` | The rule sets. The last two add each product's LEGACY runs, designed to be deleted once stored content has been converted. |
3980
4007
 
3981
4008
  Two delimiter choices worth knowing. Italic is `_phrase_`, not `*phrase*`,
@@ -0,0 +1,44 @@
1
+ import{InputEndActionButton as e}from"./chunk-HNUKXGYP.js";import"./chunk-NZISMTQE.js";import"./chunk-4DDL6NXB.js";import"./chunk-AYZY3YNC.js";import"./chunk-LE5LWALR.js";import{peekBrowserStartUrl as t,claimBrowserStartUrl as o}from"./chunk-LWLCNQY7.js";import{AboutApp as r}from"./chunk-KIXTJNHQ.js";import{WindowTitle as n}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import{confirm as s}from"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-ETJRGQNG.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as a}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useRef as i,useEffect as l,useState as c}from"react";import{jsxs as m,jsx as u,Fragment as h}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",p="react-os-shell:browser-homepage",k="https://en.wikipedia.org/wiki/Main_Page",b=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],g=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function f(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var w=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return b;try{const e=localStorage.getItem(d);if(!e)return b;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return b}function y(){return"undefined"==typeof window?k:localStorage.getItem(p)||k}function v(){const h=i(void 0);void 0===h.current&&(h.current=t()),l(()=>{null!=h.current&&o(h.current)},[]);const k=h.current?f(h.current.url):"",[b,g]=c(y),[w,v]=c(k||b),[C,W]=c(w),[E,L]=c([w]),[z,D]=c(0),[R,H]=c(0),[S,K]=c(x),[T,Q]=c(!1),[U,Z]=c(null),G=i(null),X=i(null);l(()=>{try{localStorage.setItem(d,JSON.stringify(S))}catch{}},[S]);const J=e=>{const t=f(e);t&&(v(t),W(t),L(e=>{const o=e.slice(0,z+1);return o.push(t),o}),D(e=>e+1),Q(!1))},M=()=>{"undefined"!=typeof window&&window.open(w,"_blank","noopener,noreferrer")},O=()=>{const e=U?.trim();e?(K(t=>[...t,{label:e,url:w}]),Z(null)):Z(null)};l(()=>{if(null===U)return;G.current?.focus(),G.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||Z(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==U]);const P=e=>{K(t=>t.filter((t,o)=>o!==e))},A=z>0,B=z<E.length-1,I=S.some(e=>e.url===w),Y="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
2
+ return m("div",{className:"relative flex flex-col h-full bg-white",children:[
3
+ /* @__PURE__ */u(n,{title:`Browser - ${N(w)}`}),
4
+ /* @__PURE__ */u(r,{app:"browser"}),
5
+ /* @__PURE__ */m("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-line bg-surface-sunken shrink-0",children:[
6
+ /* @__PURE__ */u("button",{onClick:()=>{if(z>0){const e=z-1;D(e),v(E[e]),W(E[e]),Q(!1)}},disabled:!A,className:Y,title:"Back",children:/* @__PURE__ */u(a,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
7
+ /* @__PURE__ */u("button",{onClick:()=>{if(z<E.length-1){const e=z+1;D(e),v(E[e]),W(E[e]),Q(!1)}},disabled:!B,className:Y,title:"Forward",children:/* @__PURE__ */u(a,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
8
+ /* @__PURE__ */u("button",{onClick:()=>H(e=>e+1),className:Y,title:"Refresh",children:/* @__PURE__ */u(a,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
9
+ /* @__PURE__ */u("button",{onClick:()=>J(b),className:Y,title:"Home",children:/* @__PURE__ */u(a,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
10
+ /* @__PURE__ */u("form",{onSubmit:e=>{e.preventDefault(),J(C)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */m("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
11
+ /* @__PURE__ */u("span",{className:"px-2 text-gray-400 text-xs",children:w.startsWith("https://")?"🔒":"⚠️"}),
12
+ /* @__PURE__ */u("input",{type:"text",value:C,onChange:e=>W(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),w!==C&&
13
+ /* @__PURE__ */u("span",{className:"flex pr-1",children:/* @__PURE__ */u(e,{action:{label:"Reset to current URL",icon:/* @__PURE__ */u(a,{name:"close"}),onClick:()=>W(w)}})})]})}),
14
+ /* @__PURE__ */u("button",{"data-bookmark-popover":!0,onClick:()=>I?P(S.findIndex(e=>e.url===w)):void Z(N(w)),className:Y+" "+(I?"text-yellow-500":""),title:I?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */u(a,{name:"star",className:"h-4 w-4",fill:I?"currentColor":"none",strokeWidth:1.5})}),
15
+ /* @__PURE__ */u("button",{onClick:M,className:Y,title:"Open in new tab",children:/* @__PURE__ */u(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
16
+ /* @__PURE__ */u("button",{onClick:()=>Q(e=>!e),className:Y,title:"Embedding help",children:/* @__PURE__ */u(a,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==U&&/* @__PURE__ */m("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
17
+ /* @__PURE__ */u("div",{className:"text-2xs font-semibold uppercase tracking-wide text-ink-faint mb-1",children:"Bookmark this page"}),
18
+ /* @__PURE__ */u("div",{className:"text-2xs text-ink-faintest truncate mb-2 font-mono",title:w,children:w}),
19
+ /* @__PURE__ */u("input",{ref:G,type:"text",value:U,onChange:e=>Z(e.target.value),onKeyDown:e=>{"Enter"===e.key?O():"Escape"===e.key&&Z(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-line-strong rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
20
+ /* @__PURE__ */m("div",{className:"flex justify-end gap-1 mt-2",children:[
21
+ /* @__PURE__ */u("button",{onClick:()=>Z(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
22
+ /* @__PURE__ */u("button",{onClick:O,disabled:!U.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
23
+ /* @__PURE__ */m("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===S.length&&/* @__PURE__ */u("span",{className:"text-2xs text-ink-faintest italic px-2",children:"No bookmarks yet — star the address bar to add one."}),S.map((e,t)=>/* @__PURE__ */m("button",{onClick:()=>J(e.url),onContextMenu:async o=>{o.preventDefault();await s({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&P(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-ink hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
24
+ /* @__PURE__ */u("img",{src:`https://icons.duckduckgo.com/ip3/${new URL(e.url).hostname}.ico`,alt:"",className:"h-3.5 w-3.5",onError:e=>{e.target.style.visibility="hidden"}}),e.label]},t)),
25
+ /* @__PURE__ */u("div",{className:"flex-1"}),
26
+ /* @__PURE__ */u("button",{onClick:()=>{g(w);try{localStorage.setItem(p,w)}catch{}},className:"px-2 py-0.5 text-2xs text-ink-faint hover:text-ink-strong",title:"Set current page as homepage",children:"Set as home"})]}),
27
+ /* @__PURE__ */u("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */u(j,{url:w,iframeKey:R,iframeRef:X,openExternal:M,showHelp:T,dismissHelp:()=>Q(!1)})})]})}function N(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function j({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:s}){const[i,d]=c(!1);l(()=>{d(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return w.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!i?/* @__PURE__ */u("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */m("div",{className:"max-w-md text-center",children:[
28
+ /* @__PURE__ */u(a,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
29
+ /* @__PURE__ */m("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[N(e)," can't be embedded"]}),
30
+ /* @__PURE__ */m("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
31
+ /* @__PURE__ */u("span",{className:"font-mono text-xs",children:"X-Frame-Options"})," ","or ",
32
+ /* @__PURE__ */u("span",{className:"font-mono text-xs",children:"Content-Security-Policy"})," header that refuses iframe embedding. The browser blocks the load before our app can do anything about it."]}),
33
+ /* @__PURE__ */m("div",{className:"flex flex-col items-center gap-2",children:[
34
+ /* @__PURE__ */m("button",{onClick:r,className:"px-4 py-2 bg-blue-500 text-white text-sm rounded hover:bg-blue-600 inline-flex items-center gap-2",children:[
35
+ /* @__PURE__ */u(a,{name:"external",className:"h-4 w-4",strokeWidth:1.5}),"Open in a new tab"]}),
36
+ /* @__PURE__ */u("button",{onClick:()=>d(!0),className:"text-xs text-gray-500 hover:text-gray-800 underline",children:"Try loading it here anyway"})]})]})}):/* @__PURE__ */m(h,{children:[
37
+ /* @__PURE__ */u("iframe",{ref:o,src:e,className:"absolute inset-0 w-full h-full bg-white",sandbox:"allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-modals",referrerPolicy:"no-referrer-when-downgrade"},t+e),n&&/* @__PURE__ */m("div",{className:"absolute top-2 right-2 max-w-sm bg-white border border-gray-200 rounded-md shadow-lg p-3 text-xs text-gray-700 z-10",children:[
38
+ /* @__PURE__ */u("div",{className:"font-medium text-gray-900 mb-1",children:"Why is this page blank?"}),
39
+ /* @__PURE__ */m("p",{className:"mb-2",children:["Most major sites (Google, GitHub, banks, news) refuse to be embedded in an iframe via ",
40
+ /* @__PURE__ */u("span",{className:"font-mono",children:"X-Frame-Options"})," or Content Security Policy. There's no workaround — the browser blocks the load before our app can do anything."]}),
41
+ /* @__PURE__ */m("p",{children:["Hit the ",
42
+ /* @__PURE__ */u("span",{className:"font-medium",children:"↗"})," button to open the page in a real new tab. Sites that ",
43
+ /* @__PURE__ */u("em",{children:"do"})," allow embedding (Wikipedia, DevDocs, your own apps) work fine in here."]}),
44
+ /* @__PURE__ */u("button",{onClick:s,className:"mt-2 text-2xs text-blue-600 hover:underline",children:"Got it"})]})]})}export{v as default};
@@ -0,0 +1,29 @@
1
+ import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-7DQ3PM5Z.js";import{useWidgetSettings as n}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as r}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as c,useRef as i,useCallback as o,useEffect as s}from"react";import{jsxs as l,Fragment as a,jsx as u}from"react/jsx-runtime";var h="calc_appearance";function m(){const[m,k]=c("0"),[p,d]=c(null),[b,g]=c(null),[j,N]=c(!1),[y,x]=c(""),[f,v]=c([]),[C,$]=c(!1),[E,W]=c(()=>e(h)),[D,Z]=c(!1),[T,Q]=c(E),K=i(null);n(o(()=>{Q({...E}),Z(!0)},[E]));const w=o(e=>{x(""),k(t=>j||"0"===t?(N(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[j]),A=o(()=>{k("0"),d(null),g(null),N(!1)},[]),B=o((e,t,n)=>{switch(n){case"+":return e+t;case"-":return e-t;case"×":return e*t;case"÷":return 0===t?0:e/t;default:return t}},[]),F=o(e=>{const t=parseFloat(m);if(null!==p&&b&&!j){const e=B(p,t,b);k(String(e)),d(e),v(n=>[`${p} ${b} ${t} = ${e}`,...n].slice(0,20))}else d(t);g(e),N(!0)},[m,p,b,j,B]),J=o(()=>{if(null===p||!b)return;const e=parseFloat(m),t=B(p,e,b),n=`${p} ${b} ${e} =`;v(e=>[`${n} ${t}`,...e].slice(0,20)),x(n),k(String(t)),d(null),g(null),N(!0)},[m,p,b,B]),S=o(()=>{k(e=>String(parseFloat(e)/100))},[]),X=o(()=>{k(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);s(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?w(e.key):"."===e.key?w("."):"+"===e.key?F("+"):"-"===e.key?F("-"):"*"===e.key?F("×"):"/"===e.key?(e.preventDefault(),F("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&K.current?.contains(e.target)&&e.preventDefault(),J()):"Escape"===e.key?A():"Backspace"===e.key?k(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&S())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,F,J,A,S]);const L="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",M=`${L} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,U=`${L} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,G=`${L} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,H=`${L} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
2
+ return l(a,{children:[
3
+ /* @__PURE__ */l("div",{ref:K,className:"flex flex-col h-full",style:{opacity:E.activeOpacity/100,backdropFilter:E.activeBlur>0?`blur(${E.activeBlur}px)`:void 0},children:[
4
+ /* @__PURE__ */l("div",{className:"bg-slate-200 rounded-t-lg px-4 py-2 group/display relative flex flex-col justify-end min-h-[120px] border-b border-slate-300",children:[
5
+ /* @__PURE__ */u("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:f.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */u("div",{className:"text-2xs text-slate-400 text-right font-mono truncate",children:e},t))}),(y||b&&null!==p)&&/* @__PURE__ */u("div",{className:"text-base text-slate-600 text-right font-mono",children:y||`${p} ${b} ${j?"":m}`}),
6
+ /* @__PURE__ */l("div",{className:"flex items-center gap-2",children:[
7
+ /* @__PURE__ */u("button",{onClick:()=>{navigator.clipboard.writeText(m),$(!0),setTimeout(()=>$(!1),1200)},title:"Copy result",className:"shrink-0 text-slate-300 hover:text-slate-500 transition-colors opacity-0 group-hover/display:opacity-100",children:/* @__PURE__ */u(r,C?{name:"check",className:"h-5 w-5 text-green-500",strokeWidth:2}:{name:"copy",className:"h-5 w-5",strokeWidth:2})}),
8
+ /* @__PURE__ */u("div",{className:"text-right text-4xl font-mono font-bold text-slate-800 truncate flex-1",children:(e=>{const t=parseFloat(e);return isNaN(t)||e.endsWith(".")||e.endsWith(".0")||Math.abs(t)<1e15&&e.length<16?e:t.toExponential(6)})(m)})]})]}),
9
+ /* @__PURE__ */l("div",{className:"grid grid-cols-4 grid-rows-5 gap-2 flex-1 min-h-0 p-2",children:[
10
+ /* @__PURE__ */u("button",{onClick:A,className:G,children:"AC"}),
11
+ /* @__PURE__ */u("button",{onClick:X,className:G,children:"+/−"}),
12
+ /* @__PURE__ */u("button",{onClick:S,className:G,children:"%"}),
13
+ /* @__PURE__ */u("button",{onClick:()=>F("÷"),className:`${U} ${"÷"===b?"ring-2 ring-blue-400":""}`,children:"÷"}),
14
+ /* @__PURE__ */u("button",{onClick:()=>w("7"),className:M,children:"7"}),
15
+ /* @__PURE__ */u("button",{onClick:()=>w("8"),className:M,children:"8"}),
16
+ /* @__PURE__ */u("button",{onClick:()=>w("9"),className:M,children:"9"}),
17
+ /* @__PURE__ */u("button",{onClick:()=>F("×"),className:`${U} ${"×"===b?"ring-2 ring-blue-400":""}`,children:"×"}),
18
+ /* @__PURE__ */u("button",{onClick:()=>w("4"),className:M,children:"4"}),
19
+ /* @__PURE__ */u("button",{onClick:()=>w("5"),className:M,children:"5"}),
20
+ /* @__PURE__ */u("button",{onClick:()=>w("6"),className:M,children:"6"}),
21
+ /* @__PURE__ */u("button",{onClick:()=>F("-"),className:`${U} ${"-"===b?"ring-2 ring-blue-400":""}`,children:"−"}),
22
+ /* @__PURE__ */u("button",{onClick:()=>w("1"),className:M,children:"1"}),
23
+ /* @__PURE__ */u("button",{onClick:()=>w("2"),className:M,children:"2"}),
24
+ /* @__PURE__ */u("button",{onClick:()=>w("3"),className:M,children:"3"}),
25
+ /* @__PURE__ */u("button",{onClick:()=>F("+"),className:`${U} ${"+"===b?"ring-2 ring-blue-400":""}`,children:"+"}),
26
+ /* @__PURE__ */u("button",{onClick:()=>w("0"),className:`${M} col-span-2`,children:"0"}),
27
+ /* @__PURE__ */u("button",{onClick:()=>w("."),className:M,children:"."}),
28
+ /* @__PURE__ */u("button",{onClick:J,className:H,children:"="})]})]}),
29
+ /* @__PURE__ */u(t,{open:D,onClose:()=>Z(!1),title:"Calculator Settings",appearance:T,onAppearanceChange:Q,onSave:()=>{W(T),localStorage.setItem(h,JSON.stringify(T)),Z(!1)}})]})}export{m as default};
@@ -0,0 +1,21 @@
1
+ import{loadAppearance as t,WidgetSettingsModal as e}from"./chunk-7DQ3PM5Z.js";import{useWidgetSettings as r}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as n}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as s,useCallback as o,useEffect as c}from"react";import{jsxs as i,Fragment as a,jsx as m}from"react/jsx-runtime";var l=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],u=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],p="currency_pairs",h="currency_appearance",d="currency_rates_cache";function k(t){try{const e=JSON.parse(localStorage.getItem(d)||"{}")[t];if(e&&Date.now()-e.timestamp<36e5)return e.rates}catch{}return null}function g(t,e){try{const r=JSON.parse(localStorage.getItem(d)||"{}");r[t]={rates:e,timestamp:Date.now()},localStorage.setItem(d,JSON.stringify(r))}catch{}}function j(){try{const t=JSON.parse(localStorage.getItem(p)||"");if(Array.isArray(t)&&t.length)return t.slice(0,4)}catch{}return u}var N={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[u,d]=s(j),[f,x]=s(()=>t(h)),[y,b]=s({}),[D,S]=s(!1),[v,C]=s(!1),[U,J]=s([]),[B,Z]=s(f),[A,K]=s("USD"),[W,H]=s("CNY");r(o(()=>{J([...u]),Z({...f}),C(!0)},[u,f])),c(()=>{const t=[...new Set(u.map(([t])=>t))];let e=!0;return async function(){S(!0);const r={};for(const e of t){const t=k(e);if(t)r[e]=t;else try{const t=await fetch(`https://open.er-api.com/v6/latest/${e}`),n=await t.json();n.rates&&(r[e]=n.rates,g(e,n.rates))}catch{}}e&&(b(r),S(!1))}(),()=>{e=!1}},[u]);/* @__PURE__ */
2
+ return i(a,{children:[
3
+ /* @__PURE__ */m("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */i("div",{className:"px-4 py-3 space-y-1",children:[D&&/* @__PURE__ */m(n,{size:"sm",padding:"py-4",label:"Loading rates"}),u.map(([t,e],r)=>{const n=y[t]?.[e];/* @__PURE__ */
4
+ return i("button",{onClick:()=>{const t=u.map((t,e)=>e===r?[t[1],t[0]]:t);d(t),localStorage.setItem(p,JSON.stringify(t))},className:"flex items-center justify-between px-2 py-2 border-b border-gray-200 last:border-0 w-full hover:bg-gray-100 rounded transition-colors cursor-pointer",children:[
5
+ /* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[
6
+ /* @__PURE__ */m("span",{className:"text-base",children:N[t]||""}),
7
+ /* @__PURE__ */m("span",{className:"text-sm font-semibold text-gray-700",children:t}),
8
+ /* @__PURE__ */m("svg",{className:"h-3 w-3 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */m("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})}),
9
+ /* @__PURE__ */m("span",{className:"text-base",children:N[e]||""}),
10
+ /* @__PURE__ */m("span",{className:"text-sm font-semibold text-gray-700",children:e})]}),
11
+ /* @__PURE__ */m("div",{className:"text-base font-mono font-semibold text-gray-900 tabular-nums",children:null!=n?n.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${t}-${e}-${r}`)})]})}),
12
+ /* @__PURE__ */m(e,{open:v,onClose:()=>C(!1),title:"Currency Settings",appearance:B,onAppearanceChange:Z,onSave:()=>{if(0===U.length)return;const t=U.slice(0,4);d(t),x(B),localStorage.setItem(p,JSON.stringify(t)),localStorage.setItem(h,JSON.stringify(B)),C(!1)},children:/* @__PURE__ */i("div",{children:[
13
+ /* @__PURE__ */i("h3",{className:"text-sm font-semibold text-ink mb-2",children:["Currency Pairs ",
14
+ /* @__PURE__ */i("span",{className:"text-2xs font-normal text-ink-faintest",children:["(",U.length,"/",4,")"]})]}),
15
+ /* @__PURE__ */m("div",{className:"space-y-1 mb-2",children:U.map(([t,e],r)=>/* @__PURE__ */i("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
16
+ /* @__PURE__ */i("span",{className:"text-sm",children:[N[t]||""," ",t," → ",N[e]||""," ",e]}),
17
+ /* @__PURE__ */m("button",{onClick:()=>J(t=>t.filter((t,e)=>e!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),U.length<4?/* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[
18
+ /* @__PURE__ */m("select",{value:A,onChange:t=>K(t.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
19
+ /* @__PURE__ */m("span",{className:"text-gray-400",children:"→"}),
20
+ /* @__PURE__ */m("select",{value:W,onChange:t=>H(t.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(t=>/* @__PURE__ */m("option",{children:t},t))}),
21
+ /* @__PURE__ */m("button",{onClick:()=>{A!==W&&U.length<4&&J(t=>[...t,[A,W]])},className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */i("p",{className:"text-2xs text-ink-faintest italic",children:["Max ",4," pairs — remove one to add another."]})]})})]})}export{f as default};
@@ -1,6 +1,6 @@
1
- import{escapeHtml as e}from"./chunk-G6DKCCWH.js";import{AboutApp as t}from"./chunk-E6LQY6TB.js";import{WindowTitle as n}from"./chunk-I3XM2PSQ.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import{toast_default as r}from"./chunk-7ELJQL7J.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-KC3EX26K.js";import"./chunk-OFCHJWM2.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-OTITQ3IH.js";import"./chunk-5QFPTDQF.js";import"./chunk-URHGHXDN.js";import"./chunk-FZM3ZPW3.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as s}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as c}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as m,useRef as h}from"react";import{jsxs as u,jsx as d}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,y]=m(x),[k,v]=m(!1),[b,j]=m(!1),[w,N]=m(!1),[D,C]=m(null),L=h(null),M=h(null),U=h(null),W=(e,t)=>{U.current?.focus(),document.execCommand(e,!1,t),N(!0)},R=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{U.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),N(!0)},e.readAsDataURL(t)}},T=e=>{D&&(D.el.removeAttribute("width"),D.el.removeAttribute("height"),D.el.style.width=e??"",D.el.style.height=e?"auto":"",N(!0),C(null))},B=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(p.has(n)||!g.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");y({filename:t.name,kind:"text",content:o,ext:n}),N(!1)}else if(g.has(n))try{const e=await(import(
1
+ import{escapeHtml as e}from"./chunk-G6DKCCWH.js";import{AboutApp as t}from"./chunk-KIXTJNHQ.js";import{WindowTitle as n}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import{toast_default as r}from"./chunk-7ELJQL7J.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-ETJRGQNG.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import{PopupMenu as o,PopupMenuLabel as i,PopupMenuItem as l,PopupMenuDivider as a}from"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as s}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as c}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as m,useRef as h}from"react";import{jsxs as u,jsx as d}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,k]=m(x),[y,v]=m(!1),[b,j]=m(!1),[w,N]=m(!1),[D,C]=m(null),L=h(null),M=h(null),U=h(null),W=(e,t)=>{U.current?.focus(),document.execCommand(e,!1,t),N(!0)},R=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{U.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),N(!0)},e.readAsDataURL(t)}},T=e=>{D&&(D.el.removeAttribute("width"),D.el.removeAttribute("height"),D.el.style.width=e??"",D.el.style.height=e?"auto":"",N(!0),C(null))},B=async t=>{const n=(t.name.split(".").pop()||"").toLowerCase();v(!0);try{if(p.has(n)||!g.has(n)&&t.type.startsWith("text/")){const r=await t.text(),o=e(r).replace(/\n/g,"<br>");k({filename:t.name,kind:"text",content:o,ext:n}),N(!1)}else if(g.has(n))try{const e=await(import(
2
2
  /* @vite-ignore */
3
- "mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},O=f?.filename?(E=f.filename).length>24?`${E.slice(0,23)}…`:E:"Untitled";var E;/* @__PURE__ */
3
+ "mammoth")),r=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:r});k({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:n}),N(!1)}catch(e){r.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===n?r.error(".doc is the legacy Word binary format — convert to .docx first."):r.error(`Unsupported file type: .${n||"unknown"}`)}finally{v(!1)}},O=f?.filename?(A=f.filename).length>24?`${A.slice(0,23)}…`:A:"Untitled";var A;/* @__PURE__ */
4
4
  return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),b||j(!0)},onDragLeave:e=>{e.currentTarget===e.target&&j(!1)},onDrop:e=>{e.preventDefault(),j(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?R(t):B(t[0]))},children:[
5
5
  /* @__PURE__ */d(n,{title:`${O}${w?" •":""} - Documents`}),
6
6
  /* @__PURE__ */d(t,{app:"documents"}),
@@ -41,7 +41,7 @@ return u("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
41
41
  /* @__PURE__ */d("input",{ref:M,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&R(Array.from(e.target.files)),M.current&&(M.current.value="")}}),
42
42
  /* @__PURE__ */u("button",{onClick:()=>M.current?.click(),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors flex items-center gap-1",title:"Insert image (or paste / drop one)",children:[
43
43
  /* @__PURE__ */d(s,{name:"image",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Image"]})]}),
44
- /* @__PURE__ */d("div",{className:"flex-1 min-h-0 overflow-hidden",children:k?/* @__PURE__ */d(c,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */d("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */d("div",{ref:U,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>N(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),R(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:f.content},className:"docx"===f.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-surface p-[1in] shadow text-sm leading-relaxed text-ink-strong outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-sm leading-relaxed text-ink-strong bg-surface outline-none whitespace-pre-wrap"})})}),b&&/* @__PURE__ */d("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */d("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),D&&/* @__PURE__ */u(o,{minWidth:150,style:{left:D.x,top:D.y},onClose:()=>C(null),children:[
44
+ /* @__PURE__ */d("div",{className:"flex-1 min-h-0 overflow-hidden",children:y?/* @__PURE__ */d(c,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */d("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */d("div",{ref:U,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>N(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),R(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:f.content},className:"docx"===f.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-surface p-[1in] shadow text-sm leading-relaxed text-ink-strong outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-sm leading-relaxed text-ink-strong bg-surface outline-none whitespace-pre-wrap"})})}),b&&/* @__PURE__ */d("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */d("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),D&&/* @__PURE__ */u(o,{minWidth:150,style:{left:D.x,top:D.y},onClose:()=>C(null),children:[
45
45
  /* @__PURE__ */d(i,{children:"Image width"}),
46
46
  /* @__PURE__ */d(l,{onClick:()=>T("25%"),children:"25%"}),
47
47
  /* @__PURE__ */d(l,{onClick:()=>T("50%"),children:"50%"}),
@@ -1,54 +1,54 @@
1
- import{openPreviewFile as e}from"./chunk-EOWUUOVE.js";import{SidebarLayout as t}from"./chunk-AFG34RBV.js";import"./chunk-QWK6DRSN.js";import"./chunk-Z44JWU75.js";import{Breadcrumbs as a}from"./chunk-XYECIBVX.js";import{formatBytes as n}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{getFilesDemoTree as r}from"./chunk-U2RFKQVA.js";import{AboutApp as i}from"./chunk-E6LQY6TB.js";import{peekFilesViewRequest as s,consumeFilesViewRequest as o,FILES_SHOW_TRASH_EVENT as l,FILES_OPEN_DESKTOP_FOLDER_EVENT as c,subscribeDesktopFolders as d,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-E5QPXEKN.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-I3XM2PSQ.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import{confirm as k,prompt as g}from"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import{ItemCount as b}from"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import{toast_default as y}from"./chunk-7ELJQL7J.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-KC3EX26K.js";import"./chunk-OFCHJWM2.js";import"./chunk-OTITQ3IH.js";import"./chunk-5QFPTDQF.js";import"./chunk-URHGHXDN.js";import"./chunk-FZM3ZPW3.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as N}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as w}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import{TH_ONE_LINE as v}from"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as j,useEffect as $,useSyncExternalStore as E,useRef as C,useCallback as D}from"react";import{jsxs as L,jsx as T,Fragment as W}from"react/jsx-runtime";var R="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",F={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function P(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function U(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function O(){const O=R.replace(/\/$/,""),S=null!==r(),[I,M]=j("/"),[A,V]=j([]),[J,B]=j([]),[K,Q]=j(null),[H,X]=j(!0),[G,Z]=j(!1),[Y,z]=j(null),[_,q]=j(!1),[ee,te]=j(()=>{const e=s();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});$(()=>{o()},[]);const[ae,ne]=j([]);$(()=>{const e=()=>{o(),te("trash")},t=e=>{o();const t=e.detail?.folderId;t&&te({desktopFolderId:t})};return window.addEventListener(l,e),window.addEventListener(c,t),()=>{window.removeEventListener(l,e),window.removeEventListener(c,t)}},[]);const re=E(d,m,m),ie="object"==typeof ee?ee.desktopFolderId:null,se=ie?re?.folders.find(e=>e.id===ie)??null:null,oe=ie&&re?.itemsByFolder[ie]||[];$(()=>{ie&&re&&!re.folders.some(e=>e.id===ie)&&te("files")},[ie,re]);const le=C(0),ce=C(null),{openPage:de,openEntity:me}=f(),he=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>de(e)}):"page"===t.entityType?de(t.entityId):me(t.entityType,t.entityId,null,t.label)},pe=D((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),ue=D(async()=>{try{const e=await pe(`${O}/api/quota`);if(e.ok){const t=await e.json();z({used:t.used,limit:t.limit})}}catch{}},[pe,O]),fe=D(async e=>{if(Q(null),S){const t=function(e){const t=r();if(!t)return[];let a=t;for(const t of e.split("/").filter(Boolean)){const e=a.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];a=e.children}return a.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return V(t),M(e),Z(!1),X(!1),void("/"===e&&B(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}X(!0);try{const t=await pe(`${O}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Failed to list (${t.status})`)}const a=await t.json(),n=a.entries||[];V(n),M(a.path||e),Z(!1),"/"===(a.path||e)&&B(n.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){Z(!0)}finally{X(!1)}ue()},[pe,O,ue,S]),xe=D(async()=>{if(S)return ne([]),void X(!1);X(!0),Q(null);try{const e=await pe(`${O}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void y.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();ne(t.entries||[]),Z(!1)}catch{Z(!0)}finally{X(!1)}ue()},[pe,O,ue,S]);$(()=>{"files"===ee?fe(I):"trash"===ee&&xe()},[I,ee]);const ke=async e=>{const t=P(I,e.name);try{const a=await pe(`${O}/api/file?path=${encodeURIComponent(t)}`);if(!a.ok)return void y.error(`Download failed (${a.status})`);const n=await a.blob(),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=e.name,i.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}catch(e){y.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const a=await pe(`${O}/api/upload?path=${encodeURIComponent(I)}`,{method:"POST",body:t});if(!a.ok){const t=await a.json().catch(()=>({}));if(413===a.status){const a=Math.max(0,(t.limit||0)-(t.used||0));y.error(`Quota exceeded — ${n(a)} free, ${e.name} is ${n(t.attempted||e.size)}`)}else y.error(`Upload ${e.name}: ${t.error||a.status}`)}}catch(t){y.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}fe(I)},be=()=>{le.current=0,q(!1)};if($(()=>{const e=()=>be();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),G)/* @__PURE__ */
1
+ import{openPreviewFile as e}from"./chunk-EOWUUOVE.js";import{SidebarLayout as t}from"./chunk-AFG34RBV.js";import"./chunk-QWK6DRSN.js";import"./chunk-Z44JWU75.js";import{Breadcrumbs as n}from"./chunk-XYECIBVX.js";import{formatBytes as a}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{getFilesDemoTree as r}from"./chunk-5H4SWQGM.js";import{AboutApp as i}from"./chunk-KIXTJNHQ.js";import{peekFilesViewRequest as s,consumeFilesViewRequest as o,FILES_SHOW_TRASH_EVENT as l,FILES_OPEN_DESKTOP_FOLDER_EVENT as c,subscribeDesktopFolders as d,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-JFBL4PR3.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{useWindowManager as f,WindowTitle as x}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import{confirm as k,prompt as g}from"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import{ItemCount as b}from"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import{toast_default as y}from"./chunk-7ELJQL7J.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-ETJRGQNG.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as N}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as w}from"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import{TH_ONE_LINE as v}from"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useState as j,useEffect as $,useSyncExternalStore as C,useRef as E,useCallback as D}from"react";import{jsxs as L,jsx as T,Fragment as W}from"react/jsx-runtime";var R="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",F={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function P(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function S(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function U(){const U=R.replace(/\/$/,""),I=null!==r(),[M,O]=j("/"),[A,J]=j([]),[B,Q]=j([]),[V,K]=j(null),[G,H]=j(!0),[Z,X]=j(!1),[Y,z]=j(null),[_,q]=j(!1),[ee,te]=j(()=>{const e=s();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});$(()=>{o()},[]);const[ne,ae]=j([]);$(()=>{const e=()=>{o(),te("trash")},t=e=>{o();const t=e.detail?.folderId;t&&te({desktopFolderId:t})};return window.addEventListener(l,e),window.addEventListener(c,t),()=>{window.removeEventListener(l,e),window.removeEventListener(c,t)}},[]);const re=C(d,m,m),ie="object"==typeof ee?ee.desktopFolderId:null,se=ie?re?.folders.find(e=>e.id===ie)??null:null,oe=ie&&re?.itemsByFolder[ie]||[];$(()=>{ie&&re&&!re.folders.some(e=>e.id===ie)&&te("files")},[ie,re]);const le=E(0),ce=E(null),{openPage:de,openEntity:me}=f(),he=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>de(e)}):"page"===t.entityType?de(t.entityId):me(t.entityType,t.entityId,null,t.label)},pe=D((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),ue=D(async()=>{try{const e=await pe(`${U}/api/quota`);if(e.ok){const t=await e.json();z({used:t.used,limit:t.limit})}}catch{}},[pe,U]),fe=D(async e=>{if(K(null),I){const t=function(e){const t=r();if(!t)return[];let n=t;for(const t of e.split("/").filter(Boolean)){const e=n.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];n=e.children}return n.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return J(t),O(e),X(!1),H(!1),void("/"===e&&Q(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}H(!0);try{const t=await pe(`${U}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Failed to list (${t.status})`)}const n=await t.json(),a=n.entries||[];J(a),O(n.path||e),X(!1),"/"===(n.path||e)&&Q(a.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){X(!0)}finally{H(!1)}ue()},[pe,U,ue,I]),xe=D(async()=>{if(I)return ae([]),void H(!1);H(!0),K(null);try{const e=await pe(`${U}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void y.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();ae(t.entries||[]),X(!1)}catch{X(!0)}finally{H(!1)}ue()},[pe,U,ue,I]);$(()=>{"files"===ee?fe(M):"trash"===ee&&xe()},[M,ee]);const ke=async e=>{const t=P(M,e.name);try{const n=await pe(`${U}/api/file?path=${encodeURIComponent(t)}`);if(!n.ok)return void y.error(`Download failed (${n.status})`);const a=await n.blob(),r=URL.createObjectURL(a),i=document.createElement("a");i.href=r,i.download=e.name,i.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}catch(e){y.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const n=await pe(`${U}/api/upload?path=${encodeURIComponent(M)}`,{method:"POST",body:t});if(!n.ok){const t=await n.json().catch(()=>({}));if(413===n.status){const n=Math.max(0,(t.limit||0)-(t.used||0));y.error(`Quota exceeded — ${a(n)} free, ${e.name} is ${a(t.attempted||e.size)}`)}else y.error(`Upload ${e.name}: ${t.error||n.status}`)}}catch(t){y.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}fe(M)},be=()=>{le.current=0,q(!1)};if($(()=>{const e=()=>be();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),Z)/* @__PURE__ */
2
2
  return L("div",{className:"flex flex-col h-full bg-white",children:[
3
3
  /* @__PURE__ */T(x,{title:"Files - offline"}),
4
4
  /* @__PURE__ */T("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */L("div",{className:"max-w-md",children:[
5
5
  /* @__PURE__ */T(N,{name:"close-circle",className:"h-12 w-12 mx-auto text-gray-300 mb-3",strokeWidth:1.4}),
6
6
  /* @__PURE__ */T("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:"Can't reach the file server"}),
7
7
  /* @__PURE__ */L("p",{className:"text-sm text-gray-500 mb-3",children:["No response from ",
8
- /* @__PURE__ */T("span",{className:"font-mono",children:O}),". Make sure the server is running — see ",
8
+ /* @__PURE__ */T("span",{className:"font-mono",children:U}),". Make sure the server is running — see ",
9
9
  /* @__PURE__ */T("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
10
- /* @__PURE__ */T("button",{onClick:()=>fe(I),className:"px-3 h-8 text-sm bg-blue-500 text-on-accent rounded hover:bg-blue-600",children:"Retry"})]})})]});const ye="/"===I?[]:I.split("/").filter(Boolean),Ne=Y&&Y.limit>0?Math.min(100,Math.round(Y.used/Y.limit*100)):0,we=Ne>90?"bg-red-500":Ne>75?"bg-amber-500":"bg-blue-500",ve=[{label:"My files",onClick:()=>M("/")},...ye.map((e,t)=>({label:e,onClick:()=>M("/"+ye.slice(0,t+1).join("/"))}))],je=e=>"flex w-full items-center gap-2 rounded-md px-3 min-h-(--row-height-menu) py-2 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),$e=e=>/* @__PURE__ */T("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),Ee=/* @__PURE__ */L("nav",{className:"p-2",children:[
10
+ /* @__PURE__ */T("button",{onClick:()=>fe(M),className:"px-3 h-8 text-sm bg-blue-500 text-on-accent rounded hover:bg-blue-600",children:"Retry"})]})})]});const ye="/"===M?[]:M.split("/").filter(Boolean),Ne=Y&&Y.limit>0?Math.min(100,Math.round(Y.used/Y.limit*100)):0,we=Ne>90?"bg-red-500":Ne>75?"bg-amber-500":"bg-blue-500",ve=[{label:"My files",onClick:()=>O("/")},...ye.map((e,t)=>({label:e,onClick:()=>O("/"+ye.slice(0,t+1).join("/"))}))],je=e=>"flex w-full items-center gap-2 rounded-md px-3 min-h-(--row-height-menu) py-2 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),$e=e=>/* @__PURE__ */T("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),Ce=/* @__PURE__ */L("nav",{className:"p-2",children:[
11
11
  /* @__PURE__ */T("div",{className:"px-2 py-2 text-2xs font-semibold uppercase tracking-wide text-ink-faintest",children:"Locations"}),
12
- /* @__PURE__ */L("button",{onClick:()=>{te("files"),M("/")},className:je("files"===ee&&"/"===I),children:[$e("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),J.map(e=>/* @__PURE__ */L("button",{onClick:()=>{te("files"),M("/"+e)},className:je("files"===ee&&I==="/"+e),children:[$e("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"),
13
- /* @__PURE__ */T("span",{className:"truncate",children:e})]},e)),!S&&/* @__PURE__ */L("button",{onClick:()=>te("trash"),className:je("trash"===ee),children:[$e("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),re&&re.folders.length>0&&/* @__PURE__ */L(W,{children:[
12
+ /* @__PURE__ */L("button",{onClick:()=>{te("files"),O("/")},className:je("files"===ee&&"/"===M),children:[$e("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),B.map(e=>/* @__PURE__ */L("button",{onClick:()=>{te("files"),O("/"+e)},className:je("files"===ee&&M==="/"+e),children:[$e("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"),
13
+ /* @__PURE__ */T("span",{className:"truncate",children:e})]},e)),!I&&/* @__PURE__ */L("button",{onClick:()=>te("trash"),className:je("trash"===ee),children:[$e("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),re&&re.folders.length>0&&/* @__PURE__ */L(W,{children:[
14
14
  /* @__PURE__ */T("div",{className:"px-2 pt-3 pb-2 text-2xs font-semibold uppercase tracking-wide text-ink-faintest",children:"Desktop"}),re.folders.map(e=>/* @__PURE__ */L("button",{onClick:()=>te({desktopFolderId:e.id}),className:je(ie===e.id),children:[
15
15
  /* @__PURE__ */T(h,{className:"h-4 w-4 shrink-0 text-amber-500"}),
16
16
  /* @__PURE__ */T("span",{className:"truncate",children:e.name}),
17
17
  /* @__PURE__ */T(b,{count:e.itemCount,active:ie===e.id,className:"ml-auto"})]},e.id))]})]});/* @__PURE__ */
18
- return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{S||"object"==typeof ee||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),le.current++,_||q(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{le.current>0&&le.current--,0===le.current&&q(!1)},onDrop:e=>{e.preventDefault(),be(),S||"object"==typeof ee||e.dataTransfer.files?.length&&ge(e.dataTransfer.files)},children:[
19
- /* @__PURE__ */T(x,{title:se?`Files - ${se.name}`:"Files"+("/"===I?"":" - "+I)}),
18
+ return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e=>{I||"object"==typeof ee||e.dataTransfer?.types?.includes?.("Files")&&(e.preventDefault(),le.current++,_||q(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&e.preventDefault()},onDragLeave:()=>{le.current>0&&le.current--,0===le.current&&q(!1)},onDrop:e=>{e.preventDefault(),be(),I||"object"==typeof ee||e.dataTransfer.files?.length&&ge(e.dataTransfer.files)},children:[
19
+ /* @__PURE__ */T(x,{title:se?`Files - ${se.name}`:"Files"+("/"===M?"":" - "+M)}),
20
20
  /* @__PURE__ */T(i,{app:"files"}),
21
21
  /* @__PURE__ */T("input",{ref:ce,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&ge(e.target.files),ce.current&&(ce.current.value="")}}),
22
- /* @__PURE__ */T("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */T(t,{sidebar:Ee,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */L("div",{className:"flex h-full min-w-0 flex-col",children:[
22
+ /* @__PURE__ */T("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */T(t,{sidebar:Ce,storageKey:"files.sidebarWidth",defaultWidth:200,minWidth:150,maxWidth:320,children:/* @__PURE__ */L("div",{className:"flex h-full min-w-0 flex-col",children:[
23
23
  /* @__PURE__ */L("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-line bg-surface-sunken shrink-0 text-xs",children:[/* @__PURE__ */L(W,"files"===ee?{children:[
24
- /* @__PURE__ */T("button",{onClick:()=>M(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),a=t.lastIndexOf("/");return a<=0?"/":t.slice(0,a)}(I)),disabled:"/"===I,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
25
- /* @__PURE__ */T("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */T(a,{items:ve,maxItems:5})}),
26
- /* @__PURE__ */T("button",{onClick:()=>fe(I),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */T(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),!S&&/* @__PURE__ */L(W,{children:[
24
+ /* @__PURE__ */T("button",{onClick:()=>O(function(e){if("/"===e||""===e)return"/";const t=e.replace(/\/$/,""),n=t.lastIndexOf("/");return n<=0?"/":t.slice(0,n)}(M)),disabled:"/"===M,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",title:"Parent folder",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
25
+ /* @__PURE__ */T("div",{className:"flex-1 min-w-0",children:/* @__PURE__ */T(n,{items:ve,maxItems:5})}),
26
+ /* @__PURE__ */T("button",{onClick:()=>fe(M),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */T(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),!I&&/* @__PURE__ */L(W,{children:[
27
27
  /* @__PURE__ */L("button",{onClick:()=>te("trash"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",title:"Open trash",children:[
28
28
  /* @__PURE__ */T(N,{name:"trash",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Trash"]}),
29
- /* @__PURE__ */L("button",{onClick:async()=>{const e=await g({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void y.error("Folder names cannot contain slashes");const t=P(I,e),a=await pe(`${O}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!a.ok){const e=await a.json().catch(()=>({}));return void y.error(e.error||`Create folder failed (${a.status})`)}fe(I)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
29
+ /* @__PURE__ */L("button",{onClick:async()=>{const e=await g({title:"New folder",placeholder:"Folder name",confirmLabel:"Create"});if(!e)return;if(/[\\/]/.test(e))return void y.error("Folder names cannot contain slashes");const t=P(M,e),n=await pe(`${U}/api/folder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!n.ok){const e=await n.json().catch(()=>({}));return void y.error(e.error||`Create folder failed (${n.status})`)}fe(M)},className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600 flex items-center gap-1",children:[
30
30
  /* @__PURE__ */T(N,{name:"folder-plus",className:"h-3.5 w-3.5",strokeWidth:1.5}),"New Folder"]}),
31
31
  /* @__PURE__ */L("button",{onClick:()=>ce.current?.click(),className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 flex items-center gap-1",children:[
32
32
  /* @__PURE__ */T(N,{name:"upload",className:"h-3.5 w-3.5",strokeWidth:1.8}),"Upload"]})]})]}:"trash"===ee?{children:[
33
33
  /* @__PURE__ */T("button",{onClick:()=>te("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
34
34
  /* @__PURE__ */T("span",{className:"flex-1 text-gray-700 font-medium px-2",children:"Trash"}),
35
35
  /* @__PURE__ */T("button",{onClick:xe,className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Refresh",children:/* @__PURE__ */T(N,{name:"refresh",className:"h-3.5 w-3.5",strokeWidth:1.8})}),
36
- /* @__PURE__ */T("button",{onClick:async()=>{if(0===ae.length)return;if(!await k({title:"Empty trash",message:`${ae.length} item${1===ae.length?"":"s"} will be permanently removed. This can't be undone.`,confirmLabel:"Empty trash",variant:"danger"}))return;const e=await pe(`${O}/api/trash`,{method:"DELETE"});if(!e.ok){const t=await e.json().catch(()=>({}));return void y.error(t.error||`Empty trash failed (${e.status})`)}xe()},disabled:0===ae.length,className:"px-2 py-1 rounded text-red-600 hover:bg-red-50 disabled:opacity-30 flex items-center gap-1",children:"Empty trash"})]}:{children:[
36
+ /* @__PURE__ */T("button",{onClick:async()=>{if(0===ne.length)return;if(!await k({title:"Empty trash",message:`${ne.length} item${1===ne.length?"":"s"} will be permanently removed. This can't be undone.`,confirmLabel:"Empty trash",variant:"danger"}))return;const e=await pe(`${U}/api/trash`,{method:"DELETE"});if(!e.ok){const t=await e.json().catch(()=>({}));return void y.error(t.error||`Empty trash failed (${e.status})`)}xe()},disabled:0===ne.length,className:"px-2 py-1 rounded text-red-600 hover:bg-red-50 disabled:opacity-30 flex items-center gap-1",children:"Empty trash"})]}:{children:[
37
37
  /* @__PURE__ */T("button",{onClick:()=>te("files"),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-600",title:"Back to files",children:/* @__PURE__ */T(N,{name:"arrow-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
38
38
  /* @__PURE__ */T(h,{className:"h-4 w-4 text-amber-500 ml-1"}),
39
39
  /* @__PURE__ */T("span",{className:"flex-1 text-gray-700 font-medium px-1 truncate",children:se?.name??"Desktop folder"}),
40
40
  /* @__PURE__ */T("span",{className:"text-2xs text-ink-faintest px-2",children:"Desktop shortcuts"})]}),Y&&/* @__PURE__ */L(W,{children:[
41
41
  /* @__PURE__ */T("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
42
- /* @__PURE__ */L("div",{className:"flex items-center gap-2",title:`${n(Y.used)} of ${n(Y.limit)} used`,children:[
42
+ /* @__PURE__ */L("div",{className:"flex items-center gap-2",title:`${a(Y.used)} of ${a(Y.limit)} used`,children:[
43
43
  /* @__PURE__ */T("div",{className:"w-20 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */T("div",{className:`h-full ${we} transition-all`,style:{width:`${Ne}%`}})}),
44
- /* @__PURE__ */L("span",{className:"text-2xs text-ink-faint tabular-nums whitespace-nowrap",children:[n(Y.used)," / ",n(Y.limit)]})]})]})]}),
44
+ /* @__PURE__ */L("span",{className:"text-2xs text-ink-faint tabular-nums whitespace-nowrap",children:[a(Y.used)," / ",a(Y.limit)]})]})]})]}),
45
45
  /* @__PURE__ */T("div",{className:"flex-1 overflow-auto",children:"object"==typeof ee?0===oe.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:"This desktop folder is empty. Drag shortcuts onto it on the desktop."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
46
46
  /* @__PURE__ */T("thead",{className:"bg-surface-sunken text-2xs uppercase tracking-wide text-ink-faint",children:/* @__PURE__ */L("tr",{children:[
47
47
  /* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Name"}),
48
48
  /* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8 w-28`,children:"Type"}),
49
49
  /* @__PURE__ */T("th",{className:`${v} w-56`})]})}),
50
50
  /* @__PURE__ */T("tbody",{children:oe.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
51
- return L("tr",{onClick:()=>Q(t),onDoubleClick:()=>he(e),className:"cursor-default border-b border-gray-100 "+(K===t?"bg-blue-50":"hover:bg-gray-50"),children:[
51
+ return L("tr",{onClick:()=>K(t),onDoubleClick:()=>he(e),className:"cursor-default border-b border-gray-100 "+(V===t?"bg-blue-50":"hover:bg-gray-50"),children:[
52
52
  /* @__PURE__ */L("td",{className:"px-3 h-8 flex items-center gap-2",children:[
53
53
  /* @__PURE__ */T(p,{item:e}),
54
54
  /* @__PURE__ */T("span",{className:"truncate",title:e.label,children:e.label})]}),
@@ -56,33 +56,33 @@ return L("tr",{onClick:()=>Q(t),onDoubleClick:()=>he(e),className:"cursor-defaul
56
56
  /* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
57
57
  /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),he(e)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Open"}),
58
58
  /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re?.moveToDesktop([e])},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs ml-1",children:"Move to desktop"}),
59
- /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re?.removeShortcuts([e])},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Remove"})]})]},t)})})]}):"trash"===ee?H&&0===ae.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===ae.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
59
+ /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re?.removeShortcuts([e])},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Remove"})]})]},t)})})]}):"trash"===ee?G&&0===ne.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===ne.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
60
60
  /* @__PURE__ */T("thead",{className:"bg-surface-sunken text-2xs uppercase tracking-wide text-ink-faint",children:/* @__PURE__ */L("tr",{children:[
61
61
  /* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Name"}),
62
62
  /* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Original location"}),
63
63
  /* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
64
64
  /* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-40`,children:"Deleted"}),
65
65
  /* @__PURE__ */T("th",{className:`${v} w-44`})]})}),
66
- /* @__PURE__ */T("tbody",{children:ae.map(e=>/* @__PURE__ */L("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[
66
+ /* @__PURE__ */T("tbody",{children:ne.map(e=>/* @__PURE__ */L("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[
67
67
  /* @__PURE__ */L("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===e.kind?/* @__PURE__ */T(N,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */T(N,{name:"page",className:"h-4 w-4 text-ink-faintest shrink-0",strokeWidth:1.5}),
68
68
  /* @__PURE__ */T("span",{className:"truncate",title:e.name,children:e.name})]}),
69
69
  /* @__PURE__ */T("td",{className:"px-3 h-8 text-ink-faint text-xs font-mono truncate",title:e.originalPath,children:e.originalPath||"—"}),
70
- /* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-ink-faint",children:n(e.size)}),
71
- /* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:e.deletedAt?U(e.deletedAt):"—"}),
70
+ /* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-ink-faint",children:a(e.size)}),
71
+ /* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:e.deletedAt?S(e.deletedAt):"—"}),
72
72
  /* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
73
- /* @__PURE__ */T("button",{onClick:()=>(async e=>{const t=await pe(`${O}/api/trash/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Restore failed (${t.status})`)}y.success(`Restored "${e.name}"`),xe()})(e),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Restore"}),
74
- /* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await k({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await pe(`${O}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${t.status})`)}xe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):H&&0===A.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===A.length?/* @__PURE__ */L("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!S&&/* @__PURE__ */L(W,{children:[" Drop files here or click ",
73
+ /* @__PURE__ */T("button",{onClick:()=>(async e=>{const t=await pe(`${U}/api/trash/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Restore failed (${t.status})`)}y.success(`Restored "${e.name}"`),xe()})(e),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Restore"}),
74
+ /* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await k({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await pe(`${U}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${t.status})`)}xe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):G&&0===A.length?/* @__PURE__ */T(w,{size:"sm",padding:"p-6",label:"Loading"}):0===A.length?/* @__PURE__ */L("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!I&&/* @__PURE__ */L(W,{children:[" Drop files here or click ",
75
75
  /* @__PURE__ */T("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
76
76
  /* @__PURE__ */T("thead",{className:"bg-surface-sunken text-2xs uppercase tracking-wide text-ink-faint",children:/* @__PURE__ */L("tr",{children:[
77
77
  /* @__PURE__ */T("th",{className:`${v} text-left font-medium px-3 h-8`,children:"Name"}),
78
78
  /* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
79
79
  /* @__PURE__ */T("th",{className:`${v} text-right font-medium px-3 h-8 w-40`,children:"Modified"}),
80
80
  /* @__PURE__ */T("th",{className:`${v} w-32`})]})}),
81
- /* @__PURE__ */T("tbody",{children:A.map(t=>/* @__PURE__ */L("tr",{onClick:()=>Q(t.name),onDoubleClick:()=>{"folder"===t.kind?M(P(I,t.name)):(async t=>{if(S)return;const a=P(I,t.name),n=(t.name.split(".").pop()||"").toLowerCase(),r=F[n];r?await e({filePath:a,filename:t.name,kind:r,onStaged:e=>de(e)}):ke(t)})(t)},className:"cursor-default border-b border-gray-100 "+(K===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
81
+ /* @__PURE__ */T("tbody",{children:A.map(t=>/* @__PURE__ */L("tr",{onClick:()=>K(t.name),onDoubleClick:()=>{"folder"===t.kind?O(P(M,t.name)):(async t=>{if(I)return;const n=P(M,t.name),a=(t.name.split(".").pop()||"").toLowerCase(),r=F[a];r?await e({filePath:n,filename:t.name,kind:r,onStaged:e=>de(e)}):ke(t)})(t)},className:"cursor-default border-b border-gray-100 "+(V===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
82
82
  /* @__PURE__ */L("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */T(N,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */T(N,{name:"page",className:"h-4 w-4 text-ink-faintest shrink-0",strokeWidth:1.5}),
83
83
  /* @__PURE__ */T("span",{className:"truncate",title:t.name,children:t.name})]}),
84
- /* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-ink-faint",children:"folder"===t.kind?"—":n(t.size)}),
85
- /* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:U(t.modifiedAt)}),
86
- /* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!S&&/* @__PURE__ */L(W,{children:["file"===t.kind&&/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),ke(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs",children:"Download"}),
87
- /* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await g({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void y.error("Names cannot contain slashes");const a=P(I,e.name),n=P(I,t),r=await pe(`${O}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a,to:n})});if(!r.ok){const e=await r.json().catch(()=>({}));return void y.error(e.error||`Rename failed (${r.status})`)}fe(I)})(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs ml-1",children:"Rename"}),
88
- /* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await k({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=P(I,e.name),a=await pe(`${O}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const e=await a.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${a.status})`)}fe(I)})(t)},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),_&&/* @__PURE__ */T("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */T("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{O as default};
84
+ /* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-ink-faint",children:"folder"===t.kind?"—":a(t.size)}),
85
+ /* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-ink-faint tabular-nums",children:S(t.modifiedAt)}),
86
+ /* @__PURE__ */T("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:!I&&/* @__PURE__ */L(W,{children:["file"===t.kind&&/* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),ke(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs",children:"Download"}),
87
+ /* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{const t=await g({title:`Rename ${e.kind}`,defaultValue:e.name,confirmLabel:"Rename"});if(!t||t===e.name)return;if(/[\\/]/.test(t))return void y.error("Names cannot contain slashes");const n=P(M,e.name),a=P(M,t),r=await pe(`${U}/api/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:n,to:a})});if(!r.ok){const e=await r.json().catch(()=>({}));return void y.error(e.error||`Rename failed (${r.status})`)}fe(M)})(t)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-ink-faint text-2xs ml-1",children:"Rename"}),
88
+ /* @__PURE__ */T("button",{onClick:e=>{e.stopPropagation(),(async e=>{if(!await k({title:`Delete ${e.kind}`,message:`"${e.name}"${"folder"===e.kind?" and everything inside":""} will be permanently removed.`,confirmLabel:"Delete",variant:"danger"}))return;const t=P(M,e.name),n=await pe(`${U}/api/files?path=${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok){const e=await n.json().catch(()=>({}));return void y.error(e.error||`Delete failed (${n.status})`)}fe(M)})(t)},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete"})]})})]},t.name))})]})})]})})}),_&&/* @__PURE__ */T("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */T("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop to upload"})})]})}export{U as default};
@@ -0,0 +1,24 @@
1
+ import{getNumberingConfigs as e}from"./chunk-5WY5DQI7.js";import{SidebarLayout as t}from"./chunk-AFG34RBV.js";import"./chunk-QWK6DRSN.js";import"./chunk-Z44JWU75.js";import{timeAgo as r}from"./chunk-GEYM4WN3.js";import"./chunk-Y3JW2GW5.js";import"./chunk-36BRD5J3.js";import"./chunk-LF27WIN2.js";import{AboutApp as n}from"./chunk-KIXTJNHQ.js";import{useWindowManager as o,client_default as i}from"./chunk-IQZD6QQF.js";import"./chunk-4LXCCZDM.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-QYL26AB4.js";import"./chunk-ZDMZM7HD.js";import"./chunk-5A7MWTXX.js";import"./chunk-2E2SUEEE.js";import"./chunk-PLK2WHZG.js";import"./chunk-7INZ7O3A.js";import"./chunk-55AEZX6K.js";import"./chunk-3DVNXNTF.js";import"./chunk-ECJKIPWU.js";import"./chunk-VWGWZY7A.js";import"./chunk-7QSDPSXP.js";import"./chunk-OKHKY3ZZ.js";import"./chunk-O3MBPAWZ.js";import{toast_default as c}from"./chunk-7ELJQL7J.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import{useShellPrefs as s}from"./chunk-KC3EX26K.js";import"./chunk-F3ZOO23R.js";import"./chunk-ETJRGQNG.js";import"./chunk-FZM3ZPW3.js";import"./chunk-CDAJKLGL.js";import"./chunk-6KGIHI6X.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-EOVXFXVV.js";import"./chunk-UQYNPYF4.js";import"./chunk-TE6R53YD.js";import{Icon as l}from"./chunk-2UO47XB4.js";import"./chunk-J75ZT2JQ.js";import"./chunk-R2VKEMZH.js";import"./chunk-MRJKZWWV.js";import"./chunk-WGLHB6WE.js";import"./chunk-NJN5IKWO.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-STKJA4PV.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-TWVUQUUD.js";import"./chunk-GDQJBQ5B.js";import"./chunk-C3QOHMR6.js";import{useRef as a,useEffect as p,useState as d,useCallback as m}from"react";import{useQuery as u}from"@tanstack/react-query";import{jsxs as h,Fragment as g,jsx as x}from"react/jsx-runtime";var y=[{key:"yellow",bg:"bg-yellow-100",border:"border-yellow-300",text:"text-yellow-900",dot:"bg-yellow-400"},{key:"blue",bg:"bg-blue-100",border:"border-blue-300",text:"text-blue-900",dot:"bg-blue-400"},{key:"green",bg:"bg-green-100",border:"border-green-300",text:"text-green-900",dot:"bg-green-400"},{key:"pink",bg:"bg-pink-100",border:"border-pink-300",text:"text-pink-900",dot:"bg-pink-400"},{key:"purple",bg:"bg-purple-100",border:"border-purple-300",text:"text-purple-900",dot:"bg-purple-400"},{key:"orange",bg:"bg-orange-100",border:"border-orange-300",text:"text-orange-900",dot:"bg-orange-400"},{key:"white",bg:"bg-white",border:"border-gray-300",text:"text-gray-900",dot:"bg-gray-300"}];var k={sales_order:{entityType:"order",endpoint:"/orders/sales-orders/"},purchase_order:{entityType:"purchase_order",endpoint:"/purchase-orders/"},invoice:{entityType:"invoice",endpoint:"/invoicing/invoices/"},vendor_invoice:{entityType:"vendor_invoice",endpoint:"/invoicing/vendor-invoices/"},shipment:{entityType:"shipment",endpoint:"/shipments/delivery-notes/"},receipt:{entityType:"payment",endpoint:"/invoicing/payments/"},vendor_payment:{entityType:"vendor_payment",endpoint:"/invoicing/vendor-payments/"},vendor_price_sheet:{entityType:"vendor_price_sheet",endpoint:"/pricing/manufacturer-price-sheets/"},client_price_sheet:{entityType:"price_sheet",endpoint:"/pricing/price-sheets/"},qc_report:{entityType:"qc_report",endpoint:"/qc-reports/"},warranty_claim:{entityType:"warranty_claim",endpoint:"/warranty-claims/claims/"},vendor_shipment:{entityType:"vendor_shipment",endpoint:"/shipments/goods-receipts/"}},b=/\[([ xX]?)\]/g;function f(){const{openEntity:f}=o(),{prefs:j,save:N}=s(),{data:v}=u({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),w=a({});p(()=>{if(!v)return;const e={};for(const t of v){const r=k[t.entity_type];if(!r)continue;const n=(t.prefix||"").replace("#","").toUpperCase();if(n&&(e[n]={...r,prefix:t.prefix}),t.alt_prefix){const n=t.alt_prefix.replace("#","").toUpperCase();n&&(e[n]={...r,prefix:t.alt_prefix})}}w.current=e},[v]);const T=j.notepad_notes||[],[W,_]=d(null),[D,C]=d(""),[X,J]=d(""),[Q,E]=d("yellow"),[K,Z]=d(!1),[$,S]=d(!1),G=a(null),O=a();p(()=>{if(!W&&T.length>0){const e=T[0];_(e.id),C(e.title),J(e.content),E(e.color)}},[T.length]);const U=m(e=>{N({notepad_notes:e})},[N]),I=m(()=>{if(!W||!K)return;const e=T.map(e=>e.id===W?{...e,title:D,content:X,color:Q,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);U(e),Z(!1)},[W,K,D,X,Q,T,U]);p(()=>{if(K)return O.current&&clearTimeout(O.current),O.current=setTimeout(I,800),()=>{O.current&&clearTimeout(O.current)}},[K,I]),p(()=>()=>{K&&I()},[]);const B=e=>{K&&I(),_(e.id),C(e.title),J(e.content),E(e.color),Z(!1),S(!1)},L=e=>{const t=X.slice(0,e),r=X.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=X.slice(e+r[0].length);J(t+n+o),Z(!0)},F=async(e,t)=>{const r=w.current[e];if(!r)return;const n=`${e}#${t}`;try{const{data:e}=await i.get(r.endpoint,{params:{search:n,page_size:1}}),t=(e?.results??e??[])[0];t?f(r.entityType,t.id,t,n):c.error(`${n} not found`)}catch{c.error(`Failed to look up ${n}`)}},H="Start writing...\n\nTips:\n [] Type [] for a checkbox, click to toggle\n SO#35001 Type XX#NNNNN to link entities (SO, PO, CI, VI, PL, etc.)",M=/* @__PURE__ */h(g,{children:[
2
+ /* @__PURE__ */x("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{K&&I();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...T];U(t),_(e.id),C(""),J(""),E("yellow"),Z(!1),S(!0),setTimeout(()=>G.current?.focus(),50)},className:"w-full flex items-center justify-center gap-2 rounded-lg bg-accent-fill text-on-accent px-3 min-h-8 py-1 text-sm font-medium hover:bg-accent-fill-hover transition-colors",children:[
3
+ /* @__PURE__ */x(l,{name:"add",className:"h-4 w-4",strokeWidth:2}),"New Note"]})}),
4
+ /* @__PURE__ */x("div",{className:"flex-1 overflow-y-auto",children:0===T.length?/* @__PURE__ */x("p",{className:"text-sm text-gray-400 text-center py-8 px-4",children:"No notes yet. Create one to get started."}):T.map(e=>{const t=(n=e.color,y.find(e=>e.key===n)||y[0]);var n;/* @__PURE__ */
5
+ return h("button",{onClick:()=>B(e),className:"w-full text-left px-3 py-3 border-b border-line-subtle transition-colors "+(W===e.id?"bg-accent-tint":"hover:bg-row-hover"),children:[
6
+ /* @__PURE__ */h("div",{className:"flex items-center gap-2",children:[
7
+ /* @__PURE__ */x("div",{className:`w-3 h-3 rounded-full shrink-0 ${t.dot}`}),
8
+ /* @__PURE__ */x("span",{className:"text-sm font-medium text-gray-900 truncate flex-1",children:e.title||"Untitled"})]}),
9
+ /* @__PURE__ */x("p",{className:"text-xs text-ink-faintest mt-0.5 truncate ml-5",children:e.content.replace(/\[[ xX]?\]/g,"").slice(0,60)||"Empty note"}),
10
+ /* @__PURE__ */x("p",{className:"text-2xs text-gray-300 mt-0.5 ml-5",children:r(e.updated_at)})]},e.id)})})]});/* @__PURE__ */
11
+ return h("div",{className:"h-full",children:[
12
+ /* @__PURE__ */x(n,{app:"notepad"}),
13
+ /* @__PURE__ */x(t,{sidebar:M,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:W?/* @__PURE__ */h("div",{className:"flex-1 flex flex-col min-w-0",children:[
14
+ /* @__PURE__ */h("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200",children:[
15
+ /* @__PURE__ */x("input",{value:D,onChange:e=>{C(e.target.value),Z(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
16
+ /* @__PURE__ */x("div",{className:"flex gap-1",children:y.map(e=>/* @__PURE__ */x("button",{onClick:()=>{E(e.key),Z(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${Q===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
17
+ /* @__PURE__ */x("button",{onClick:()=>(e=>{const t=T.filter(t=>t.id!==e);if(U(t),W===e){const e=t[0];e?B(e):(_(null),C(""),J(""))}})(W),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */x(l,{name:"trash",className:"h-4 w-4",strokeWidth:1.5})})]}),$?/* @__PURE__ */x("textarea",{ref:G,value:X,onChange:e=>{J(e.target.value),Z(!0)},onBlur:()=>{S(!1),K&&I()},placeholder:H,className:"flex-1 p-4 text-sm text-gray-700 outline-none resize-none bg-transparent leading-relaxed placeholder:text-gray-300 font-mono"}):/* @__PURE__ */x("div",{onClick:()=>{S(!0),setTimeout(()=>G.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:X?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],c=/([A-Z]{2,4})#(\d{4,6})/g;let s;for(;null!==(s=c.exec(e));){const e=s[1],t=s[2];if(w.current[e]){const n=s.index,o=s[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */x("button",{onClick:()=>F(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}b.lastIndex=0;let a=0;for(let e=0;e<r;e++)a+=t[e].length+1;for(;null!==(s=b.exec(e));){const e="x"===s[1]||"X"===s[1],t=s.index,n=a+t;i.push({idx:t,len:s[0].length,render:()=>/* @__PURE__ */x("button",{onClick:()=>L(n),className:`inline-flex items-center justify-center w-4 h-4 rounded border ${e?"bg-blue-500 border-blue-500 text-white":"border-gray-400 bg-white hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:e&&/* @__PURE__ */x(l,{name:"check",className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */x("span",{children:e.slice(o,t.idx)},`t-${r}-${o}`)),n.push(t.render()),o=t.idx+t.len;o<e.length&&n.push(/* @__PURE__ */x("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */x("span",{children:"​"},`empty-${r}`));const p=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
18
+ return x("div",{className:p?"line-through text-gray-400":"",children:n},r)})})(X):/* @__PURE__ */x("p",{className:"text-gray-300 whitespace-pre-line",children:H})}),
19
+ /* @__PURE__ */h("div",{className:"px-4 min-h-8 py-1 border-t border-line-subtle flex items-center gap-4 text-2xs text-ink-faintest",children:[
20
+ /* @__PURE__ */x("span",{children:"[] checkbox"}),
21
+ /* @__PURE__ */x("span",{children:"SO#35001 entity link"}),
22
+ /* @__PURE__ */x("span",{className:"ml-auto",children:$?"Editing":"Click to edit"})]})]}):/* @__PURE__ */x("div",{className:"flex-1 flex items-center justify-center",children:/* @__PURE__ */h("div",{className:"text-center text-gray-400",children:[
23
+ /* @__PURE__ */x(l,{name:"page",className:"h-12 w-12 mx-auto mb-3 text-gray-300",strokeWidth:1}),
24
+ /* @__PURE__ */x("p",{className:"text-sm",children:"Select a note or create a new one"})]})})})]})}export{f as default};