efficient-shell 6.4.0 → 7.7.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 (88) hide show
  1. package/README.md +88 -22
  2. package/dist/Browser-56LX7FTE.js +43 -0
  3. package/dist/Calculator-GBKLJHM6.js +29 -0
  4. package/dist/ConfirmDialog-PS5BXNAT.js +1 -0
  5. package/dist/CurrencyConverter-ZXY7XNG6.js +21 -0
  6. package/dist/{Documents-ADFEHEUW.js → Documents-SVKR757H.js} +27 -27
  7. package/dist/Files-KSHU7ROB.js +87 -0
  8. package/dist/Notepad-5GT2GUCJ.js +25 -0
  9. package/dist/PdfViewer-YVAWFZVH.js +1 -0
  10. package/dist/PomodoroTimer-GAGDQ4NF.js +91 -0
  11. package/dist/Preview-YDCDW5NE.js +182 -0
  12. package/dist/Sidebar-IH6WUPKT.js +44 -0
  13. package/dist/Spreadsheet-SYR23K4I.js +37 -0
  14. package/dist/Stock-LH5CR667.js +16 -0
  15. package/dist/{Weather-BLO354GM.js → Weather-MZGIPR2R.js} +35 -35
  16. package/dist/WorldClock-DLB2RRLI.js +32 -0
  17. package/dist/apps/index.js +1 -1
  18. package/dist/bin/ui-check.js +1 -1
  19. package/dist/brand.css +1 -1
  20. package/dist/chunk-2ALIPI3D.js +1 -0
  21. package/dist/{chunk-MORDXCV6.js → chunk-2R5RTN5T.js} +1 -1
  22. package/dist/{chunk-5LUN632W.js → chunk-43XFZY4K.js} +2 -2
  23. package/dist/{chunk-ZEIKSMFR.js → chunk-4JGNJYVL.js} +8 -8
  24. package/dist/{chunk-XO2AMGVU.js → chunk-5TOLXFQ6.js} +1 -1
  25. package/dist/{chunk-QJHWLDEN.js → chunk-6SCHK75C.js} +50 -50
  26. package/dist/{chunk-4JZZLUGG.js → chunk-B4PGVDB6.js} +1 -1
  27. package/dist/chunk-BUGGBB5J.js +1 -0
  28. package/dist/{chunk-2SSRFEOZ.js → chunk-CJHT4VTF.js} +1 -1
  29. package/dist/chunk-CLFUF3BH.js +9 -0
  30. package/dist/{chunk-I2H2CKID.js → chunk-CQ2DLPPS.js} +1 -1
  31. package/dist/{chunk-HQLAISFX.js → chunk-G4CTTSAR.js} +4 -4
  32. package/dist/{chunk-I534M65N.js → chunk-HIRMYFOF.js} +2 -2
  33. package/dist/{chunk-SK5DL6JX.js → chunk-JKHXDQEI.js} +14 -14
  34. package/dist/{chunk-GWDVD3VQ.js → chunk-JQRIAZDP.js} +23 -23
  35. package/dist/{chunk-IHZL3GJU.js → chunk-KONXUO5I.js} +1 -1
  36. package/dist/{chunk-Q5O5UMJY.js → chunk-M4MCXII7.js} +1 -1
  37. package/dist/{chunk-UUYPUKP7.js → chunk-M4TRVJTO.js} +1 -1
  38. package/dist/chunk-MSGBGLGI.js +29 -0
  39. package/dist/{chunk-CXJQ42XT.js → chunk-N7JTY3LU.js} +15 -15
  40. package/dist/{chunk-VR6TR575.js → chunk-NODT4F2C.js} +3 -3
  41. package/dist/{chunk-R5VRLW5Z.js → chunk-OXTM3XZI.js} +1 -1
  42. package/dist/chunk-PT4Z3KIA.js +12 -0
  43. package/dist/chunk-QRCDQPJA.js +1 -0
  44. package/dist/{chunk-7PGHRG6J.js → chunk-QUVE5JZZ.js} +11 -11
  45. package/dist/{chunk-YX2IMURA.js → chunk-R2TPTM4O.js} +8 -8
  46. package/dist/{chunk-5K76RQML.js → chunk-RBKIYZ7H.js} +1 -1
  47. package/dist/{chunk-GJ37JCC2.js → chunk-RUHUTZN4.js} +1 -1
  48. package/dist/chunk-TCYS67ND.js +1016 -0
  49. package/dist/file-intake/index.js +1 -1
  50. package/dist/i18n/index.d.ts +1 -1
  51. package/dist/icons/efficient-looks.js +4 -4
  52. package/dist/icons/efficient.d.ts +2 -2
  53. package/dist/icons/efficient.js +3 -3
  54. package/dist/icons/index.js +1 -1
  55. package/dist/{index-D5bms_uA.d.ts → index-BkBsXpfV.d.ts} +285 -88
  56. package/dist/index.d.ts +3 -3
  57. package/dist/index.js +635 -639
  58. package/dist/locales/zh-Hans.d.ts +1 -1
  59. package/dist/locales/zh-Hans.js +1 -1
  60. package/dist/map/index.js +8 -8
  61. package/dist/markdown/index.js +1 -1
  62. package/dist/page-tabs/index.js +5 -5
  63. package/dist/pdf/index.js +1 -1
  64. package/dist/{strings-fYzxZPn4.d.ts → strings-BQtq9300.d.ts} +17 -2
  65. package/dist/telemetry/index.js +1 -1
  66. package/dist/ui/index.d.ts +2 -2
  67. package/dist/ui/index.js +1 -1
  68. package/dist/ui.css +48 -54
  69. package/package.json +1 -1
  70. package/dist/Browser-USPZWDYH.js +0 -43
  71. package/dist/Calculator-FP5HUWCW.js +0 -29
  72. package/dist/ConfirmDialog-3TIHKJRT.js +0 -1
  73. package/dist/CurrencyConverter-XD5LYOCD.js +0 -21
  74. package/dist/Files-BVUVRNC5.js +0 -87
  75. package/dist/Notepad-WJI5ODGS.js +0 -25
  76. package/dist/PdfViewer-226I3LSD.js +0 -1
  77. package/dist/PomodoroTimer-GEMQHIPJ.js +0 -91
  78. package/dist/Preview-HNSEYNZL.js +0 -182
  79. package/dist/Sidebar-PVHZPNIY.js +0 -44
  80. package/dist/Spreadsheet-6Z5ACGTT.js +0 -37
  81. package/dist/Stock-X3LIU4ZX.js +0 -16
  82. package/dist/WorldClock-BAH7QFRG.js +0 -32
  83. package/dist/chunk-5MDQNFOG.js +0 -9
  84. package/dist/chunk-DBXZS7OA.js +0 -29
  85. package/dist/chunk-K6DKX55N.js +0 -1
  86. package/dist/chunk-PFKMIPZH.js +0 -1028
  87. package/dist/chunk-S3LGKIZ3.js +0 -12
  88. package/dist/chunk-SBF5A6XV.js +0 -1
@@ -14,7 +14,7 @@ return i("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"current
14
14
  /* @__PURE__ */r("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.827 6.175A2.31 2.31 0 0 1 5.186 7.23c-.38.054-.757.112-1.134.175C2.999 7.58 2.25 8.507 2.25 9.574V18a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9.574c0-1.067-.75-1.994-1.802-2.169a47.865 47.865 0 0 0-1.134-.175 2.31 2.31 0 0 1-1.64-1.055l-.822-1.316a2.192 2.192 0 0 0-1.736-1.039 48.774 48.774 0 0 0-5.232 0 2.192 2.192 0 0 0-1.736 1.039l-.821 1.316Z"}),
15
15
  /* @__PURE__ */r("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 12.75a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM18.75 10.5h.008v.008h-.008V10.5Z"})]})},"camera:mini":function({size:e=18,...i}){/* @__PURE__ */
16
16
  return r("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",...i,children:/* @__PURE__ */r("path",{fillRule:"evenodd",d:"M1 8a2 2 0 0 1 2-2h.93a2 2 0 0 0 1.664-.89l.812-1.22A2 2 0 0 1 8.07 3h3.86a2 2 0 0 1 1.664.89l.812 1.22A2 2 0 0 0 16.07 6H17a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8Zm13.5 3a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM10 14a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",clipRule:"evenodd"})})},"chart-bar":function({size:e=18,...i}){/* @__PURE__ */
17
- return r("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...i,children:/* @__PURE__ */r("path",{d:"M3 20.25L21 20.25M6 12h1.5a0.75 0.75 0 0 1 0.75 0.75v6.75a0.75 0.75 0 0 1 -0.75 0.75h-1.5a0.75 0.75 0 0 1 -0.75 -0.75v-6.75a0.75 0.75 0 0 1 0.75 -0.75ZM11.25 6h1.5a0.75 0.75 0 0 1 0.75 0.75v12.75a0.75 0.75 0 0 1 -0.75 0.75h-1.5a0.75 0.75 0 0 1 -0.75 -0.75v-12.75a0.75 0.75 0 0 1 0.75 -0.75ZM16.5 9.75h1.5a0.75 0.75 0 0 1 0.75 0.75v9a0.75 0.75 0 0 1 -0.75 0.75h-1.5a0.75 0.75 0 0 1 -0.75 -0.75v-9a0.75 0.75 0 0 1 0.75 -0.75Z"})})},check:function({size:e=18,...i}){/* @__PURE__ */
17
+ return r("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",...i,children:/* @__PURE__ */r("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 0 1 3 19.875v-6.75ZM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125V8.625ZM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 0 1-1.125-1.125V4.125Z"})})},check:function({size:e=18,...i}){/* @__PURE__ */
18
18
  return r("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",...i,children:/* @__PURE__ */r("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 12.75 6 6 9-13.5"})})},"check-circle":function({size:e=18,...i}){/* @__PURE__ */
19
19
  return r("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",...i,children:/* @__PURE__ */r("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})})},"check-circle:mini":function({size:e=18,...i}){/* @__PURE__ */
20
20
  return r("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",...i,children:/* @__PURE__ */r("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z",clipRule:"evenodd"})})},"chevron-double-left":function({size:e=18,...i}){/* @__PURE__ */
@@ -0,0 +1,9 @@
1
+ import{useWindowMenuItem as e,Modal as t}from"./chunk-6SCHK75C.js";import{navIcons as r}from"./chunk-DSSLOQDW.js";import{VERSION as s}from"./chunk-BUGGBB5J.js";import{DEFAULT_SHELL_STRINGS as o,useShellStrings as n,splitAround as i}from"./chunk-QRCDQPJA.js";import{Icon as a}from"./chunk-CJHT4VTF.js";import{useState as m,useCallback as c,isValidElement as l,cloneElement as d}from"react";import{jsx as p,jsxs as h}from"react/jsx-runtime";var u=o.aboutApp,x={spreadsheet:{name:"Spreadsheets",version:"1.1.3",route:"/spreadsheet",description:u.spreadsheet},notepad:{name:"Notepad",version:"1.0.2",route:"/notepad",description:u.notepad},documents:{name:"Documents",version:"1.1.1",route:"/documents",description:u.documents},preview:{name:"Preview",version:"1.4.3",route:"/preview",description:u.preview},files:{name:"Files",version:"1.1.2",route:"/files",description:u.files},browser:{name:"Browser",version:"1.0.2",route:"/browser",description:u.browser}},f=/* @__PURE__ */p(a,{name:"info",className:"h-4 w-4 text-gray-400",strokeWidth:1.5}),v=/* @__PURE__ */p(a,{name:"window",className:"h-9 w-9",strokeWidth:1.5});function w({app:o}){const a=x[o],[u,w]=m(!1),g=c(()=>w(!0),[]),N=n().aboutApp,y=N.title(a.name);if(e(y,g,f),!u)return null;const b=r[a.route],k=l(b)?d(b,{className:"h-9 w-9"}):v,[j,C]=i(N.partOf);/* @__PURE__ */
2
+ return p(t,{open:!0,onClose:()=>w(!1),title:y,size:"sm",compact:!0,bodyScroll:!1,autoHeight:!0,dimensions:[320,320],children:/* @__PURE__ */h("div",{className:"flex flex-col items-center text-center px-5 pt-5 pb-4",children:[
3
+ /* @__PURE__ */p("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl bg-gray-100 text-gray-600 shrink-0",children:k}),
4
+ /* @__PURE__ */p("h2",{className:"mt-3 text-lg font-bold text-gray-900",children:a.name}),
5
+ /* @__PURE__ */p("p",{className:"text-2xs font-mono text-gray-400",children:N.version(a.version)}),
6
+ /* @__PURE__ */p("p",{className:"mt-2 text-xs text-gray-500 leading-relaxed",children:N[o]}),
7
+ /* @__PURE__ */h("div",{className:"mt-4 pt-3 border-t border-gray-200 w-full",children:[
8
+ /* @__PURE__ */h("p",{className:"text-2xs text-gray-500",children:[j,
9
+ /* @__PURE__ */p("span",{className:"font-medium text-gray-700",children:"efficient-shell"}),C]}),s&&/* @__PURE__ */p("p",{className:"mt-0.5 text-2xs font-mono text-gray-400",children:N.shellVersion(s)})]})]})})}export{w as AboutApp,x as BUILTIN_APP_INFO};
@@ -1,3 +1,3 @@
1
- import{useShellStrings as e}from"./chunk-K6DKX55N.js";import{Icon as t}from"./chunk-2SSRFEOZ.js";import{useState as r,useRef as o,useEffect as c,useCallback as i}from"react";import{jsx as n}from"react/jsx-runtime";function a(e){const[t,n]=r(!1),a=o(void 0);c(()=>()=>clearTimeout(a.current),[]);return{copied:t,copy:i(t=>{t?.stopPropagation(),navigator.clipboard?.writeText(e).then(()=>{n(!0),clearTimeout(a.current),a.current=setTimeout(()=>n(!1),1500)},()=>{})},[e])}}function u({copied:e,className:r="w-4 h-4"}){/* @__PURE__ */
1
+ import{useShellStrings as e}from"./chunk-QRCDQPJA.js";import{Icon as t}from"./chunk-CJHT4VTF.js";import{useState as r,useRef as o,useEffect as c,useCallback as i}from"react";import{jsx as n}from"react/jsx-runtime";function a(e){const[t,n]=r(!1),a=o(void 0);c(()=>()=>clearTimeout(a.current),[]);return{copied:t,copy:i(t=>{t?.stopPropagation(),navigator.clipboard?.writeText(e).then(()=>{n(!0),clearTimeout(a.current),a.current=setTimeout(()=>n(!1),1500)},()=>{})},[e])}}function u({copied:e,className:r="w-4 h-4"}){/* @__PURE__ */
2
2
  return n(t,e?{name:"check",className:`${r} text-green-600`,"aria-hidden":"true"}:{name:"copy",className:r,"aria-hidden":"true"})}function m({text:t}){const{copied:r,copy:o}=a(t),c=e().copy;/* @__PURE__ */
3
3
  return n("button",{onClick:o,title:r?c.copiedValue:c.copyValue(t),className:"shrink-0 text-gray-400 hover:text-gray-600 transition-colors",children:/* @__PURE__ */n(u,{copied:r})})}export{m as CopyButton,u as CopyGlyph,a as useCopyText};
@@ -1,4 +1,4 @@
1
- import{useHydrated as e,useBrowserState as t}from"./chunk-D65T4H6J.js";import{useShellStrings as r}from"./chunk-K6DKX55N.js";import{Icon as n}from"./chunk-2SSRFEOZ.js";import{createContext as o,useSyncExternalStore as i,useCallback as a,useContext as s,useMemo as c}from"react";import{jsxs as l,jsx as u}from"react/jsx-runtime";var d="(max-width: 767px), (pointer: coarse)";function f(){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(d).matches}function m(){return!1}function h(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=window.matchMedia(d);return t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function w(){return i(h,f,m)}var g={success:"success",error:"error",warning:"warning",info:"info",404:"info",403:"warning",500:"error"},p={success:"text-green-600 bg-green-100",error:"text-red-600 bg-red-100",warning:"text-amber-600 bg-amber-100",info:"text-blue-600 bg-blue-100"},y={404:e=>e.notFound,403:e=>e.noAccess,500:e=>e.serverError};function v({tone:e}){const t={className:"h-6 w-6",strokeWidth:1.5,"aria-hidden":!0};switch(e){case"success":/* @__PURE__ */
1
+ import{useHydrated as e,useBrowserState as t}from"./chunk-D65T4H6J.js";import{useShellStrings as r}from"./chunk-QRCDQPJA.js";import{Icon as n}from"./chunk-CJHT4VTF.js";import{createContext as o,useSyncExternalStore as i,useCallback as a,useContext as s,useMemo as c}from"react";import{jsxs as l,jsx as u}from"react/jsx-runtime";var d="(max-width: 767px), (pointer: coarse)";function f(){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(d).matches}function m(){return!1}function h(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=window.matchMedia(d);return t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}function w(){return i(h,f,m)}var g={success:"success",error:"error",warning:"warning",info:"info",404:"info",403:"warning",500:"error"},p={success:"text-green-600 bg-green-100",error:"text-red-600 bg-red-100",warning:"text-amber-600 bg-amber-100",info:"text-blue-600 bg-blue-100"},y={404:e=>e.notFound,403:e=>e.noAccess,500:e=>e.serverError};function v({tone:e}){const t={className:"h-6 w-6",strokeWidth:1.5,"aria-hidden":!0};switch(e){case"success":/* @__PURE__ */
2
2
  return u(n,{name:"check",...t});case"error":/* @__PURE__ */
3
3
  return u(n,{name:"close",...t});case"warning":/* @__PURE__ */
4
4
  return u(n,{name:"error",...t});default:/* @__PURE__ */
@@ -6,6 +6,6 @@ return u(n,{name:"info",...t})}}function x({status:e="info",title:t,subTitle:n,e
6
6
  return l("div",{role:"error"===c?"alert":void 0,className:`flex flex-col items-center justify-center px-6 py-12 text-center ${s}`.trim(),children:[
7
7
  /* @__PURE__ */u("div",{className:`flex h-14 w-14 items-center justify-center rounded-full ${p[c]}`,children:i??/* @__PURE__ */u(v,{tone:c})}),
8
8
  /* @__PURE__ */u("h2",{className:"mt-4 text-lg font-semibold text-gray-900",children:t??y[e]?.(d)??""}),n&&/* @__PURE__ */u("p",{className:"mt-1 max-w-md text-sm text-gray-500",children:n}),a&&/* @__PURE__ */u("div",{className:"mt-4 w-full max-w-md text-left",children:a}),o&&/* @__PURE__ */u("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-3",children:o})]})}function b({size:e="md",padding:t="py-12",label:r,className:n=""}){const o=/* @__PURE__ */u("div",{className:`${"sm"===e?"h-5 w-5":"lg"===e?"h-12 w-12":"h-8 w-8"} animate-spin rounded-full border-2 border-gray-200 border-t-blue-600`});return null==r?/* @__PURE__ */u("div",{className:`flex items-center justify-center ${t} ${n}`,children:o}):/* @__PURE__ */l("div",{role:"status",className:`flex flex-col items-center justify-center gap-3 ${t} ${n}`,children:[o,
9
- /* @__PURE__ */u("p",{className:"text-sm text-gray-500",children:r})]})}var S="undefined"!=typeof window&&"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),_={MOD:["⌘","Ctrl"],ALT:["⌥","Alt"],CMD_ENTER:["⌘⏎","Ctrl⏎"],CMD_S:["⌘S","Ctrl+S"],CMD_K:["⌘K","Ctrl+K"],CMD_DOT:["⌘.","Ctrl+."],CMD_A:["⌘A","Ctrl+A"],CMD_Z:["⌘Z","Ctrl+Z"],CMD_SHIFT_Z:["⌘⇧Z","Ctrl+Shift+Z"],ALT_SHIFT_D:["⌥⇧D","Alt+Shift+D"],ALT_SHIFT_E:["⌥⇧E","Alt+Shift+E"],ALT_SHIFT_N:["⌥⇧N","Alt+Shift+N"]},N=S?0:1,D=_.MOD[N],E=_.ALT[N],C="⇧",L="⏎",M=_.CMD_ENTER[N],T=_.CMD_S[N],A=_.CMD_K[N],k=_.CMD_DOT[N],j=_.CMD_A[N],I=_.CMD_Z[N],F=_.CMD_SHIFT_Z[N],H=_.ALT_SHIFT_D[N],Z=_.ALT_SHIFT_E[N],O=_.ALT_SHIFT_N[N],P=new Map(S?Object.values(_).map(([e,t])=>[e,t]):[]);function $(t){return e()?t:P.get(t)??t}var K={neutral:"inline-flex items-center justify-center rounded border border-gray-200 bg-gray-50 font-medium text-gray-500",accent:"inline-flex items-center justify-center rounded border kbd-submit font-medium",warning:"inline-flex items-center justify-center rounded border border-amber-300 bg-amber-100 font-medium"},R={sm:"px-1 py-0.5 text-[10px]",md:"px-1.5 py-0.5 text-[11px]"};function z({keys:e,size:t="md",tone:r="neutral",className:n=""}){const o=$(e);/* @__PURE__ */
10
- return u("kbd",{className:[K[r],R[t],n].filter(Boolean).join(" "),children:o})}var J=o(null);function U({value:e,children:t}){/* @__PURE__ */
11
- return u(J.Provider,{value:e,children:t})}function W(e="react-os-shell:prefs",r){const[n,o]=t(()=>{try{const t=JSON.parse(localStorage.getItem(e)||"{}");return{...r??{},...t}}catch{return{...r??{}}}},{...r??{}});return{prefs:n,save:a(t=>{o(r=>{const n={...r,...t};try{localStorage.setItem(e,JSON.stringify(n))}catch{}return n})},[e])}}var B={prefs:{},save:()=>{}};function X(){return s(J)??B}function q(){const{prefs:e,save:t}=X(),r=a(e=>{const r=t(e);return r&&"function"==typeof r.then?r.catch(()=>{}):r},[t]);return c(()=>({prefs:e,save:r}),[e,r])}var G="react-os-shell:stale-chunk-reload-at",Q=3e4,V="vite:preloadError",Y="/_next/static/",ee=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed|Unable to preload CSS/i;function te(e){if(e instanceof Error&&"ChunkLoadError"===e.name)return!0;const t=e instanceof Error?e.message:"string"==typeof e?e:"";return ee.test(t)}function re(e={}){if("undefined"==typeof window)return()=>{};const t=e.cooldownMs??3e4,r=e.reload??(()=>window.location.reload()),n=e.now??Date.now,o=void 0===e.storage?function(){try{const e=window.sessionStorage;return e.getItem(G),e}catch{return null}}():e.storage,i=void 0===e.chunkPathPrefix?Y:e.chunkPathPrefix,a=e=>{const r=n(),i=function(e){if(!e)return null;try{const t=e.getItem(G),r=null===t?NaN:Number(t);return Number.isFinite(r)?r:null}catch{return null}}(o);return null!==i&&r-i<t?(console.error("[efficient-shell] a lazy chunk is still missing after a reload; letting the failure through:",e),!1):(function(e,t){if(e)try{e.setItem(G,String(t))}catch{}}(o,r),console.warn("[efficient-shell] a lazy chunk is no longer on the server (new deploy?); reloading onto the current build:",e),!0)},s=e=>{const t=e.payload;te(t)&&a(t)&&(e.preventDefault(),r())};let c=!0,l=!1;const u=/* @__PURE__ */new Set,d=null===i?null:e=>{const t=function(e,t){const r=e.target;let n="";if(r instanceof window.HTMLScriptElement?n=r.src:r instanceof window.HTMLLinkElement&&function(e){const t=e.rel.toLowerCase().split(/\s+/);if(t.includes("stylesheet")||t.includes("modulepreload"))return!0;const r=(e.getAttribute("as")??"").toLowerCase();return t.includes("preload")&&("script"===r||"style"===r)}(r)?n=r.href:e instanceof window.ErrorEvent&&"SyntaxError"===e.error?.name&&(n=e.filename),!n)return null;try{const e=new URL(t,window.location.origin).href,r=new URL(n,window.location.href).href;return r.startsWith(e)?r:null}catch{return null}}(e,i);!t||l||u.has(t)||(u.add(t),async function(e){try{const t=await fetch(e,{method:"HEAD",cache:"no-store"});return 404===t.status||410===t.status||t.ok&&/\btext\/html\b/i.test(t.headers.get("content-type")??"")}catch{return!1}}(t).then(e=>{u.delete(t),e&&c&&!l&&a(t)&&(l=!0,r())}))};return window.addEventListener(V,s),d&&window.addEventListener("error",d,!0),()=>{c=!1,window.removeEventListener(V,s),d&&window.removeEventListener("error",d,!0)}}export{E as ALT,H as ALT_SHIFT_D,Z as ALT_SHIFT_E,O as ALT_SHIFT_N,j as CMD_A,k as CMD_DOT,M as CMD_ENTER,A as CMD_K,T as CMD_S,F as CMD_SHIFT_Z,I as CMD_Z,L as ENTER,z as Kbd,b as LoadingSpinner,D as MOD,Y as NEXT_CHUNK_PATH_PREFIX,x as Result,C as SHIFT,Q as STALE_CHUNK_RELOAD_COOLDOWN_MS,G as STALE_CHUNK_RELOAD_KEY,U as ShellPrefsProvider,V as VITE_PRELOAD_ERROR_EVENT,re as installStaleChunkReload,S as isMac,te as isStaleChunkError,w as useIsMobile,W as useLocalStoragePrefs,q as useShellPrefs,X as useShellPrefsAdapter,$ as useShortcutLabel};
9
+ /* @__PURE__ */u("p",{className:"text-sm text-gray-500",children:r})]})}var _="undefined"!=typeof window&&"undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),C={MOD:["⌘","Ctrl"],ALT:["⌥","Alt"],CMD_ENTER:["⌘⏎","Ctrl⏎"],CMD_S:["⌘S","Ctrl+S"],CMD_K:["⌘K","Ctrl+K"],CMD_DOT:["⌘.","Ctrl+."],CMD_A:["⌘A","Ctrl+A"],CMD_Z:["⌘Z","Ctrl+Z"],CMD_SHIFT_Z:["⌘⇧Z","Ctrl+Shift+Z"],ALT_SHIFT_D:["⌥⇧D","Alt+Shift+D"],ALT_SHIFT_E:["⌥⇧E","Alt+Shift+E"],ALT_SHIFT_N:["⌥⇧N","Alt+Shift+N"]},D=_?0:1,N=C.MOD[D],S=C.ALT[D],E="⇧",T="⏎",L=C.CMD_ENTER[D],M=C.CMD_S[D],A=C.CMD_K[D],k=C.CMD_DOT[D],j=C.CMD_A[D],I=C.CMD_Z[D],H=C.CMD_SHIFT_Z[D],F=C.ALT_SHIFT_D[D],P=C.ALT_SHIFT_E[D],Z=C.ALT_SHIFT_N[D],O=new Map(_?Object.values(C).map(([e,t])=>[e,t]):[]);function $(t){return e()?t:O.get(t)??t}var J={neutral:"inline-flex items-center justify-center rounded border border-gray-200 bg-gray-50 font-medium text-gray-500",accent:"inline-flex items-center justify-center rounded border kbd-submit font-medium",warning:"inline-flex items-center justify-center rounded border border-amber-300 bg-amber-100 font-medium"},R={sm:"px-1 py-0.5 text-2xs",md:"px-1.5 py-0.5 text-2xs"};function z({keys:e,size:t="md",tone:r="neutral",className:n=""}){const o=$(e);/* @__PURE__ */
10
+ return u("kbd",{className:[J[r],R[t],n].filter(Boolean).join(" "),children:o})}var K=o(null);function U({value:e,children:t}){/* @__PURE__ */
11
+ return u(K.Provider,{value:e,children:t})}function Q(e="react-os-shell:prefs",r){const[n,o]=t(()=>{try{const t=JSON.parse(localStorage.getItem(e)||"{}");return{...r??{},...t}}catch{return{...r??{}}}},{...r??{}});return{prefs:n,save:a(t=>{o(r=>{const n={...r,...t};try{localStorage.setItem(e,JSON.stringify(n))}catch{}return n})},[e])}}var W={prefs:{},save:()=>{}};function B(){return s(K)??W}function V(){const{prefs:e,save:t}=B(),r=a(e=>{const r=t(e);return r&&"function"==typeof r.then?r.catch(()=>{}):r},[t]);return c(()=>({prefs:e,save:r}),[e,r])}var q="react-os-shell:stale-chunk-reload-at",G=3e4,X="vite:preloadError",Y="/_next/static/",ee=/Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed|Unable to preload CSS/i;function te(e){if(e instanceof Error&&"ChunkLoadError"===e.name)return!0;const t=e instanceof Error?e.message:"string"==typeof e?e:"";return ee.test(t)}function re(e={}){if("undefined"==typeof window)return()=>{};const t=e.cooldownMs??3e4,r=e.reload??(()=>window.location.reload()),n=e.now??Date.now,o=void 0===e.storage?function(){try{const e=window.sessionStorage;return e.getItem(q),e}catch{return null}}():e.storage,i=void 0===e.chunkPathPrefix?Y:e.chunkPathPrefix,a=e=>{const r=n(),i=function(e){if(!e)return null;try{const t=e.getItem(q),r=null===t?NaN:Number(t);return Number.isFinite(r)?r:null}catch{return null}}(o);return null!==i&&r-i<t?(console.error("[efficient-shell] a lazy chunk is still missing after a reload; letting the failure through:",e),!1):(function(e,t){if(e)try{e.setItem(q,String(t))}catch{}}(o,r),console.warn("[efficient-shell] a lazy chunk is no longer on the server (new deploy?); reloading onto the current build:",e),!0)},s=e=>{const t=e.payload;te(t)&&a(t)&&(e.preventDefault(),r())};let c=!0,l=!1;const u=/* @__PURE__ */new Set,d=null===i?null:e=>{const t=function(e,t){const r=e.target;let n="";if(r instanceof window.HTMLScriptElement?n=r.src:r instanceof window.HTMLLinkElement&&function(e){const t=e.rel.toLowerCase().split(/\s+/);if(t.includes("stylesheet")||t.includes("modulepreload"))return!0;const r=(e.getAttribute("as")??"").toLowerCase();return t.includes("preload")&&("script"===r||"style"===r)}(r)?n=r.href:e instanceof window.ErrorEvent&&"SyntaxError"===e.error?.name&&(n=e.filename),!n)return null;try{const e=new URL(t,window.location.origin).href,r=new URL(n,window.location.href).href;return r.startsWith(e)?r:null}catch{return null}}(e,i);!t||l||u.has(t)||(u.add(t),async function(e){try{const t=await fetch(e,{method:"HEAD",cache:"no-store"});return 404===t.status||410===t.status||t.ok&&/\btext\/html\b/i.test(t.headers.get("content-type")??"")}catch{return!1}}(t).then(e=>{u.delete(t),e&&c&&!l&&a(t)&&(l=!0,r())}))};return window.addEventListener(X,s),d&&window.addEventListener("error",d,!0),()=>{c=!1,window.removeEventListener(X,s),d&&window.removeEventListener("error",d,!0)}}export{S as ALT,F as ALT_SHIFT_D,P as ALT_SHIFT_E,Z as ALT_SHIFT_N,j as CMD_A,k as CMD_DOT,L as CMD_ENTER,A as CMD_K,M as CMD_S,H as CMD_SHIFT_Z,I as CMD_Z,T as ENTER,z as Kbd,b as LoadingSpinner,N as MOD,Y as NEXT_CHUNK_PATH_PREFIX,x as Result,E as SHIFT,G as STALE_CHUNK_RELOAD_COOLDOWN_MS,q as STALE_CHUNK_RELOAD_KEY,U as ShellPrefsProvider,X as VITE_PRELOAD_ERROR_EVENT,re as installStaleChunkReload,_ as isMac,te as isStaleChunkError,w as useIsMobile,Q as useLocalStoragePrefs,V as useShellPrefs,B as useShellPrefsAdapter,$ as useShortcutLabel};
@@ -1,2 +1,2 @@
1
- import{toast_default as t}from"./chunk-GJ37JCC2.js";import{useShellPrefs as e}from"./chunk-HQLAISFX.js";import{useSyncExternalStore as n,useCallback as o,useMemo as a}from"react";var r=[{id:"bell",label:"Bell",description:"Soft bell with one harmonic"},{id:"chime",label:"Chime",description:"Two-note ascending chime"},{id:"bowl",label:"Singing Bowl",description:"Long-decay meditation tone"},{id:"wind-chimes",label:"Wind Chimes",description:"Four soft tones in succession"},{id:"off",label:"Off (silent)",description:"No sound — only desktop notification"}],i=[{id:"none",label:"None"},{id:"tick-fast",label:"Ticking Fast"},{id:"tick-slow",label:"Ticking Slow"},{id:"rain",label:"Rain"},{id:"fireplace",label:"Fireplace"},{id:"white",label:"White Noise"},{id:"pink",label:"Pink Noise"},{id:"brown",label:"Brown Noise"}],c=()=>`pomodoro-${/* @__PURE__ */(new Date).toISOString().slice(0,10)}`,l={focus:1500,short:300,long:900},s="bell",u=100,d=1,f="none",m=50,h={autoStartBreaks:!1,autoStartPomodoros:!1,longBreakInterval:4},g={running:!1,remaining:l.focus,mode:"focus",total:l.focus,streak:0,count:"undefined"!=typeof localStorage?(()=>{try{return parseInt(localStorage.getItem(c())||"0",10)||0}catch{return 0}})():0},p=null,k=/* @__PURE__ */new Set,w=t=>{g={...g,...t},k.forEach(t=>t())};function M(){return g}function S(t){return k.add(t),()=>{k.delete(t)}}function b(t){l=t,g.running||g.remaining!==g.total||w({remaining:t[g.mode],total:t[g.mode]})}function y(t){s=t}function v(t,e){u=Math.max(0,Math.min(100,Math.round(t))),d=Math.max(1,Math.min(5,Math.round(e)))}function T(t){h={autoStartBreaks:!!t.autoStartBreaks,autoStartPomodoros:!!t.autoStartPomodoros,longBreakInterval:Math.max(1,Math.min(20,Math.round(t.longBreakInterval||4)))}}function A(t,e){f=t,m=Math.max(0,Math.min(100,Math.round(e))),g.running&&"focus"===g.mode?(G(),F()):"none"!==t&&0!==m||G()}function I(){g.running||(w({running:!0}),p=setInterval(C,1e3),"focus"===g.mode&&F())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),G())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function C(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);G(),N(s,{volume:u,repeat:d});const e="focus"===g.mode?"Pomodoro complete — time for a break! 🍅":"Break's over — back to work!";if("undefined"!=typeof Notification&&"granted"===Notification.permission)try{new Notification(e)}catch{}try{t.info(e)}catch{}if("focus"===g.mode){const t=g.streak+1,e=g.count+1;(t=>{try{localStorage.setItem(c(),String(t))}catch{}})(e);const n=t%h.longBreakInterval===0?"long":"short";w({running:!1,streak:t,count:e,mode:n,remaining:l[n],total:l[n]}),h.autoStartBreaks&&setTimeout(()=>I(),50)}else w({running:!1,mode:"focus",remaining:l.focus,total:l.focus}),h.autoStartPomodoros&&setTimeout(()=>I(),50)}():w({remaining:g.remaining-1})}function N(t=s,e={}){if("off"===t)return;const n=Math.max(0,Math.min(100,e.volume??100))/100;if(0===n)return;const o=Math.max(1,Math.min(5,e.repeat??1));for(let e=0;e<o;e++)setTimeout(()=>P(t,n),2500*e)}function P(t,e){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=(t,n,a,r=.22,i="sine")=>{const c=o.createOscillator(),l=o.createGain();c.connect(l),l.connect(o.destination),c.type=i,c.frequency.value=t;const s=o.currentTime+n;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(r*e,s+.03),l.gain.exponentialRampToValueAtTime(1e-4,s+a),c.start(s),c.stop(s+a)};let r=2;"bell"===t?(a(880,0,1.8),a(1320,0,1.4,.1),r=2):"chime"===t?(a(659.25,0,.7),a(880,.2,1.3),r=2):"bowl"===t?(a(440,0,3.4,.22),a(660,0,3,.08),a(880,.05,2.8,.05),r=4):"wind-chimes"===t&&(a(1175,0,1.1,.16),a(880,.15,1.3,.16),a(1318,.3,1.5,.16),a(1047,.5,1.7,.13),r=3),setTimeout(()=>{try{o.close()}catch{}},1e3*r+500)}catch{}}var D=null,_={none:0,white:.3,pink:.3,brown:.3,"tick-fast":.6,"tick-slow":.6,rain:.4,fireplace:.5};function O(t,e){if("none"===e)return null;const n=t.sampleRate,o="white"===e||"pink"===e||"brown"===e?2:4,a=n*o,r=t.createBuffer(1,a,n),i=r.getChannelData(0);if("white"===e)for(let t=0;t<a;t++)i[t]=.5*(2*Math.random()-1);else if("pink"===e){let t=0,e=0,n=0,o=0,r=0,c=0,l=0;for(let s=0;s<a;s++){const a=2*Math.random()-1;t=.99886*t+.0555179*a,e=.99332*e+.0750759*a,n=.969*n+.153852*a,o=.8665*o+.3104856*a,r=.55*r+.5329522*a,c=-.7616*c-.016898*a,i[s]=.11*(t+e+n+o+r+c+l+.5362*a)*.55,l=.115926*a}}else if("brown"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=3.5*t*.5}}else if("tick-fast"===e||"tick-slow"===e){const t="tick-fast"===e?.5:1,r=Math.floor(.045*n);for(let e=0;e<o;e+=t){const t=Math.floor(e*n);for(let e=0;e<r&&t+e<a;e++){const o=Math.exp(-e/n*180),a=2*Math.random()-1,r=Math.sin(2*Math.PI*1100*(e/n));i[t+e]+=(.7*a+.25*r)*o*.55}}}else if("rain"===e){let t=0;for(let e=0;e<a;e++){const o=2*Math.random()-1,a=o-.93*t;t=o;const r=.7+.3*Math.sin(e/n*2*Math.PI*.25);i[e]=a*r*.4}}else if("fireplace"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=1.6*t}let e=.4*Math.random()*n;for(;e<a;){const t=Math.floor((.012+.05*Math.random())*n),o=.35+.45*Math.random(),r=Math.floor(e);for(let e=0;e<t&&r+e<a;e++){const t=Math.exp(-e/n*90);i[r+e]+=(2*Math.random()-1)*t*o}e+=(.08+.62*Math.random())*n}}return r}function F(){if(!D&&"none"!==f&&0!==m)try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const e=new t,n=O(e,f);if(!n){try{e.close()}catch{}return}const o=e.createBufferSource();o.buffer=n,o.loop=!0;const a=e.createGain();a.gain.value=m/100*_[f],o.connect(a).connect(e.destination),o.start(),D={ctx:e,src:o,gain:a}}catch{}}function G(){if(D){try{D.src.stop()}catch{}try{D.ctx.close()}catch{}D=null}}function R(t,e){if("none"!==t&&0!==e)try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=O(o,t);if(!a){try{o.close()}catch{}return}const r=o.createBufferSource();r.buffer=a,r.loop=!0;const i=o.createGain();i.gain.value=e/100*_[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var J="pomodoro_tasks",V="pomodoro_tasks_migrated";function j(){return Math.random().toString(36).slice(2,11)}function L(){/* @__PURE__ */
2
- return(new Date).toISOString()}var W=null,q=[],E=!1,H=null,Q=/* @__PURE__ */new Set;function X(){for(const t of Q)t()}function $(t){q=t,X()}function z(){const t=W;return t?H=t.list().then(e=>{W===t&&(q=e,E=!0,X())}).catch(()=>{W===t&&(E=!0,X())}).finally(()=>{H=null}):(q=[],E=!0,X(),Promise.resolve())}function K(t){W=t,q=[],E=!1,t?z():X()}function U(t){return Q.add(t),!W||E||H||z(),()=>{Q.delete(t)}}function Y(){return q}function Z(){const t=function(){const{prefs:t,save:n}=e(),r=a(()=>{const e=t.todo_tasks;return Array.isArray(e)?e:[]},[t.todo_tasks]),i=o(t=>{n({todo_tasks:t})},[n]),c=o(t=>{const e=j(),n=L(),o={done:!1,...t,name:t.name.trim(),id:e,createdAt:n,updatedAt:n};return i([...r,o]),e},[r,i]),l=o((t,e)=>{i(r.map(n=>n.id===t?{...n,...e,id:n.id,updatedAt:L()}:n))},[r,i]),s=o(t=>{i(r.filter(e=>e.id!==t))},[r,i]),u=o(t=>{const e=r.find(e=>e.id===t);e&&l(t,{done:!e.done})},[r,l]);return{tasks:r,addTask:c,updateTask:l,removeTask:s,toggleDone:u,setAllTasks:i}}(),r=n(U,Y,Y),i=o(e=>{const n=W;if(!n)return t.addTask(e);const o="tmp-"+j(),a=L(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return $([...q,r]),n.create({...e,name:e.name.trim()}).then(t=>$(q.map(e=>e.id===o?{...r,...t}:e))).catch(()=>$(q.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=W;if(!o)return t.updateTask(e,n);$(q.map(t=>t.id===e?{...t,...n,id:e,updatedAt:L()}:t)),o.update(e,n).catch(()=>{z()})},[t]),l=o(e=>{const n=W;if(!n)return t.removeTask(e);const o=q;$(q.filter(t=>t.id!==e)),n.remove(e).catch(()=>$(o))},[t]),s=o(e=>{if(!W)return t.toggleDone(e);const n=q.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{W||t.setAllTasks(e)},[t]);return null===W?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(V))return;const n=localStorage.getItem(J);if(!n)return void localStorage.setItem(V,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(J),void localStorage.setItem(V,"1");const a=L(),r=o.filter(t=>"string"==typeof t?.name).map(t=>({id:t.id||j(),name:String(t.name),done:!!t.done,estimated:"number"==typeof t.estimated?t.estimated:void 0,completed:"number"==typeof t.completed?t.completed:void 0,createdAt:a,updatedAt:a})),i=new Set(t.map(t=>t.id));e([...r.filter(t=>!i.has(t.id)),...t]),localStorage.removeItem(J),localStorage.setItem(V,"1")}catch{try{localStorage.setItem(V,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,N as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,R as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,T as setPomoBehaviour,b as setPomoDurations,A as setPomoFocusSound,K as setShellTodoProvider,S as subscribePomo,Z as useTodoTasks};
1
+ import{toast_default as t}from"./chunk-RUHUTZN4.js";import{useShellPrefs as e}from"./chunk-G4CTTSAR.js";import{useSyncExternalStore as n,useCallback as o,useMemo as a}from"react";var r=[{id:"bell",label:"Bell",description:"Soft bell with one harmonic"},{id:"chime",label:"Chime",description:"Two-note ascending chime"},{id:"bowl",label:"Singing Bowl",description:"Long-decay meditation tone"},{id:"wind-chimes",label:"Wind Chimes",description:"Four soft tones in succession"},{id:"off",label:"Off (silent)",description:"No sound — only desktop notification"}],i=[{id:"none",label:"None"},{id:"tick-fast",label:"Ticking Fast"},{id:"tick-slow",label:"Ticking Slow"},{id:"rain",label:"Rain"},{id:"fireplace",label:"Fireplace"},{id:"white",label:"White Noise"},{id:"pink",label:"Pink Noise"},{id:"brown",label:"Brown Noise"}],c=()=>`pomodoro-${/* @__PURE__ */(new Date).toISOString().slice(0,10)}`,l={focus:1500,short:300,long:900},s="bell",u=100,d=1,f="none",m=50,h={autoStartBreaks:!1,autoStartPomodoros:!1,longBreakInterval:4},g={running:!1,remaining:l.focus,mode:"focus",total:l.focus,streak:0,count:"undefined"!=typeof localStorage?(()=>{try{return parseInt(localStorage.getItem(c())||"0",10)||0}catch{return 0}})():0},p=null,k=/* @__PURE__ */new Set,w=t=>{g={...g,...t},k.forEach(t=>t())};function M(){return g}function S(t){return k.add(t),()=>{k.delete(t)}}function b(t){l=t,g.running||g.remaining!==g.total||w({remaining:t[g.mode],total:t[g.mode]})}function y(t){s=t}function v(t,e){u=Math.max(0,Math.min(100,Math.round(t))),d=Math.max(1,Math.min(5,Math.round(e)))}function T(t){h={autoStartBreaks:!!t.autoStartBreaks,autoStartPomodoros:!!t.autoStartPomodoros,longBreakInterval:Math.max(1,Math.min(20,Math.round(t.longBreakInterval||4)))}}function A(t,e){f=t,m=Math.max(0,Math.min(100,Math.round(e))),g.running&&"focus"===g.mode?(G(),O()):"none"!==t&&0!==m||G()}function I(){g.running||(w({running:!0}),p=setInterval(C,1e3),"focus"===g.mode&&O())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),G())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function C(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);G(),N(s,{volume:u,repeat:d});const e="focus"===g.mode?"Pomodoro complete — time for a break! 🍅":"Break's over — back to work!";if("undefined"!=typeof Notification&&"granted"===Notification.permission)try{new Notification(e)}catch{}try{t.info(e)}catch{}if("focus"===g.mode){const t=g.streak+1,e=g.count+1;(t=>{try{localStorage.setItem(c(),String(t))}catch{}})(e);const n=t%h.longBreakInterval===0?"long":"short";w({running:!1,streak:t,count:e,mode:n,remaining:l[n],total:l[n]}),h.autoStartBreaks&&setTimeout(()=>I(),50)}else w({running:!1,mode:"focus",remaining:l.focus,total:l.focus}),h.autoStartPomodoros&&setTimeout(()=>I(),50)}():w({remaining:g.remaining-1})}function N(t=s,e={}){if("off"===t)return;const n=Math.max(0,Math.min(100,e.volume??100))/100;if(0===n)return;const o=Math.max(1,Math.min(5,e.repeat??1));for(let e=0;e<o;e++)setTimeout(()=>P(t,n),2500*e)}function P(t,e){try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=(t,n,a,r=.22,i="sine")=>{const c=o.createOscillator(),l=o.createGain();c.connect(l),l.connect(o.destination),c.type=i,c.frequency.value=t;const s=o.currentTime+n;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(r*e,s+.03),l.gain.exponentialRampToValueAtTime(1e-4,s+a),c.start(s),c.stop(s+a)};let r=2;"bell"===t?(a(880,0,1.8),a(1320,0,1.4,.1),r=2):"chime"===t?(a(659.25,0,.7),a(880,.2,1.3),r=2):"bowl"===t?(a(440,0,3.4,.22),a(660,0,3,.08),a(880,.05,2.8,.05),r=4):"wind-chimes"===t&&(a(1175,0,1.1,.16),a(880,.15,1.3,.16),a(1318,.3,1.5,.16),a(1047,.5,1.7,.13),r=3),setTimeout(()=>{try{o.close()}catch{}},1e3*r+500)}catch{}}var D=null,R={none:0,white:.3,pink:.3,brown:.3,"tick-fast":.6,"tick-slow":.6,rain:.4,fireplace:.5};function _(t,e){if("none"===e)return null;const n=t.sampleRate,o="white"===e||"pink"===e||"brown"===e?2:4,a=n*o,r=t.createBuffer(1,a,n),i=r.getChannelData(0);if("white"===e)for(let t=0;t<a;t++)i[t]=.5*(2*Math.random()-1);else if("pink"===e){let t=0,e=0,n=0,o=0,r=0,c=0,l=0;for(let s=0;s<a;s++){const a=2*Math.random()-1;t=.99886*t+.0555179*a,e=.99332*e+.0750759*a,n=.969*n+.153852*a,o=.8665*o+.3104856*a,r=.55*r+.5329522*a,c=-.7616*c-.016898*a,i[s]=.11*(t+e+n+o+r+c+l+.5362*a)*.55,l=.115926*a}}else if("brown"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=3.5*t*.5}}else if("tick-fast"===e||"tick-slow"===e){const t="tick-fast"===e?.5:1,r=Math.floor(.045*n);for(let e=0;e<o;e+=t){const t=Math.floor(e*n);for(let e=0;e<r&&t+e<a;e++){const o=Math.exp(-e/n*180),a=2*Math.random()-1,r=Math.sin(2*Math.PI*1100*(e/n));i[t+e]+=(.7*a+.25*r)*o*.55}}}else if("rain"===e){let t=0;for(let e=0;e<a;e++){const o=2*Math.random()-1,a=o-.93*t;t=o;const r=.7+.3*Math.sin(e/n*2*Math.PI*.25);i[e]=a*r*.4}}else if("fireplace"===e){let t=0;for(let e=0;e<a;e++){t=(t+.02*(2*Math.random()-1))/1.02,i[e]=1.6*t}let e=.4*Math.random()*n;for(;e<a;){const t=Math.floor((.012+.05*Math.random())*n),o=.35+.45*Math.random(),r=Math.floor(e);for(let e=0;e<t&&r+e<a;e++){const t=Math.exp(-e/n*90);i[r+e]+=(2*Math.random()-1)*t*o}e+=(.08+.62*Math.random())*n}}return r}function O(){if(!D&&"none"!==f&&0!==m)try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const e=new t,n=_(e,f);if(!n){try{e.close()}catch{}return}const o=e.createBufferSource();o.buffer=n,o.loop=!0;const a=e.createGain();a.gain.value=m/100*R[f],o.connect(a).connect(e.destination),o.start(),D={ctx:e,src:o,gain:a}}catch{}}function G(){if(D){try{D.src.stop()}catch{}try{D.ctx.close()}catch{}D=null}}function F(t,e){if("none"!==t&&0!==e)try{const n=window.AudioContext||window.webkitAudioContext;if(!n)return;const o=new n,a=_(o,t);if(!a){try{o.close()}catch{}return}const r=o.createBufferSource();r.buffer=a,r.loop=!0;const i=o.createGain();i.gain.value=e/100*R[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var V="pomodoro_tasks",j="pomodoro_tasks_migrated";function U(){return Math.random().toString(36).slice(2,11)}function W(){/* @__PURE__ */
2
+ return(new Date).toISOString()}var q=null,E=[],H=!1,J=null,L=/* @__PURE__ */new Set;function Z(){for(const t of L)t()}function $(t){E=t,Z()}function z(){const t=q;return t?J=t.list().then(e=>{q===t&&(E=e,H=!0,Z())}).catch(()=>{q===t&&(H=!0,Z())}).finally(()=>{J=null}):(E=[],H=!0,Z(),Promise.resolve())}function K(t){q=t,E=[],H=!1,t?z():Z()}function Q(t){return L.add(t),!q||H||J||z(),()=>{L.delete(t)}}function X(){return E}function Y(){const t=function(){const{prefs:t,save:n}=e(),r=a(()=>{const e=t.todo_tasks;return Array.isArray(e)?e:[]},[t.todo_tasks]),i=o(t=>{n({todo_tasks:t})},[n]),c=o(t=>{const e=U(),n=W(),o={done:!1,...t,name:t.name.trim(),id:e,createdAt:n,updatedAt:n};return i([...r,o]),e},[r,i]),l=o((t,e)=>{i(r.map(n=>n.id===t?{...n,...e,id:n.id,updatedAt:W()}:n))},[r,i]),s=o(t=>{i(r.filter(e=>e.id!==t))},[r,i]),u=o(t=>{const e=r.find(e=>e.id===t);e&&l(t,{done:!e.done})},[r,l]);return{tasks:r,addTask:c,updateTask:l,removeTask:s,toggleDone:u,setAllTasks:i}}(),r=n(Q,X,X),i=o(e=>{const n=q;if(!n)return t.addTask(e);const o="tmp-"+U(),a=W(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return $([...E,r]),n.create({...e,name:e.name.trim()}).then(t=>$(E.map(e=>e.id===o?{...r,...t}:e))).catch(()=>$(E.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=q;if(!o)return t.updateTask(e,n);$(E.map(t=>t.id===e?{...t,...n,id:e,updatedAt:W()}:t)),o.update(e,n).catch(()=>{z()})},[t]),l=o(e=>{const n=q;if(!n)return t.removeTask(e);const o=E;$(E.filter(t=>t.id!==e)),n.remove(e).catch(()=>$(o))},[t]),s=o(e=>{if(!q)return t.toggleDone(e);const n=E.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{q||t.setAllTasks(e)},[t]);return null===q?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(j))return;const n=localStorage.getItem(V);if(!n)return void localStorage.setItem(j,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(V),void localStorage.setItem(j,"1");const a=W(),r=o.filter(t=>"string"==typeof t?.name).map(t=>({id:t.id||U(),name:String(t.name),done:!!t.done,estimated:"number"==typeof t.estimated?t.estimated:void 0,completed:"number"==typeof t.completed?t.completed:void 0,createdAt:a,updatedAt:a})),i=new Set(t.map(t=>t.id));e([...r.filter(t=>!i.has(t.id)),...t]),localStorage.removeItem(V),localStorage.setItem(j,"1")}catch{try{localStorage.setItem(j,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,N as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,F as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,T as setPomoBehaviour,b as setPomoDurations,A as setPomoFocusSound,K as setShellTodoProvider,S as subscribePomo,Y as useTodoTasks};
@@ -1,23 +1,23 @@
1
- import{toast_default as e}from"./chunk-GJ37JCC2.js";import{useShellStrings as t}from"./chunk-K6DKX55N.js";import{Icon as n}from"./chunk-2SSRFEOZ.js";import{createContext as r,useContext as a,useRef as o,useState as i,useEffect as s}from"react";import*as l from"pdfjs-dist";import{createPortal as c}from"react-dom";import{jsx as d,jsxs as u}from"react/jsx-runtime";function m(e,t,n){return new Error(`The response for ${e} is not a WebAssembly module (got ${function(e){if(0===e.length)return"an empty response";const t=Array.from(e.subarray(0,24)).map(e=>e>=32&&e<127?String.fromCharCode(e):".").join("");return`${e.length} bytes starting "${t}"`}(n)}). The bundler did not emit "${t}" as an asset, and the host answered with a fallback page instead of a 404. Serve pdfjs-dist/wasm/ yourself and point window.__REACT_OS_SHELL_PDF_WASM__ at it.`)}var h=r(null);function p({children:e}){const t=a(h);return t?c(e,t):
2
- /* @__PURE__ */d("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||l.GlobalWorkerOptions.workerSrc||(l.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${l.version}/build/pdf.worker.min.mjs`);var f={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},g=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=f[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw m(n,t,a);return a}};function w(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:g}}var y=[50,75,100,125,150,200,300,400];function v(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function b({url:r,filename:a,fit:c="width",onDownload:m,onEmail:h,workerSrc:f,wasmUrl:g}){const b=t().pdf,x=o(null),k=o(null),C=o(null),[N,j]=i(null),[E,M]=i(1),[_,z]=i(0),[D,P]=i(1),[S,W]=i(!0),[L,$]=i(!0),O=o(b.loadFailed);O.current=b.loadFailed,s(()=>{let t=!1;return $(!0),M(1),f&&(l.GlobalWorkerOptions.workerSrc=f),l.getDocument({url:r,...w(g)}).promise.then(e=>{t||(j(e),z(e.numPages),$(!1))}).catch(()=>{t||(e.error(O.current),$(!1))}),()=>{t=!0}},[r,f,g]),s(()=>{if(!N||!S||!C.current)return;const e=()=>{const e=C.current;e&&N.getPage(E).then(t=>{if(!C.current)return;const n=t.getViewport({scale:1}),r=v(c,{width:e.clientWidth,height:e.clientHeight},{width:n.width,height:n.height});P(e=>Math.abs(e-r)<.005?e:r)})};e();const t=new ResizeObserver(e);return t.observe(C.current),()=>t.disconnect()},[N,E,S,c]),s(()=>{if(!N||!x.current)return;let e=!1,t=null,n=null;return N.getPage(E).then(r=>{if(e||!x.current)return;const a=r.getViewport({scale:D}),o=x.current;o.width=a.width,o.height=a.height,o.style.width=`${a.width}px`,o.style.height=`${a.height}px`;const i=o.getContext("2d");t=r.render({canvas:o,canvasContext:i,viewport:a}),t.promise.catch(()=>{});const s=k.current;s&&(s.replaceChildren(),s.style.setProperty("--total-scale-factor",String(a.scale)),n=new l.TextLayer({textContentSource:r.streamTextContent(),container:s,viewport:a}),n.render().then(()=>{if(e)return;const t=document.createElement("div");t.className="endOfContent",s.append(t)}).catch(()=>{}))}),()=>{e=!0,t?.cancel(),n?.cancel()}},[N,E,D]),s(()=>{const e=()=>k.current?.classList.remove("selecting");return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]);const T="page"===c?b.fitPage:b.fitWidth,A="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
1
+ import{toast_default as e}from"./chunk-RUHUTZN4.js";import{useShellStrings as t}from"./chunk-QRCDQPJA.js";import{Icon as n}from"./chunk-CJHT4VTF.js";import{createContext as r,useContext as a,useRef as o,useState as i,useEffect as s}from"react";import*as l from"pdfjs-dist";import{createPortal as c}from"react-dom";import{jsx as d,jsxs as u}from"react/jsx-runtime";function m(e,t,n){return new Error(`The response for ${e} is not a WebAssembly module (got ${function(e){if(0===e.length)return"an empty response";const t=Array.from(e.subarray(0,24)).map(e=>e>=32&&e<127?String.fromCharCode(e):".").join("");return`${e.length} bytes starting "${t}"`}(n)}). The bundler did not emit "${t}" as an asset, and the host answered with a fallback page instead of a 404. Serve pdfjs-dist/wasm/ yourself and point window.__REACT_OS_SHELL_PDF_WASM__ at it.`)}var h=r(null);function p({children:e}){const t=a(h);return t?c(e,t):
2
+ /* @__PURE__ */d("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs",children:e})}"undefined"==typeof window||l.GlobalWorkerOptions.workerSrc||(l.GlobalWorkerOptions.workerSrc=`https://unpkg.com/pdfjs-dist@${l.version}/build/pdf.worker.min.mjs`);var f={"jbig2.wasm":new URL("pdfjs-dist/wasm/jbig2.wasm",import.meta.url).href,"openjpeg.wasm":new URL("pdfjs-dist/wasm/openjpeg.wasm",import.meta.url).href},g=class{async fetch({kind:e,filename:t}){if("wasmUrl"!==e)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const n=f[t];if(!n)throw new Error(`No bundled pdf.js wasm module for "${t}".`);const r=await fetch(n);if(!r.ok)throw new Error(`Unable to load wasm data at: ${n}`);const a=new Uint8Array(await r.arrayBuffer());if(!function(e){return e.length>=4&&0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]}(a))throw m(n,t,a);return a}};function w(e){const t=e||("undefined"!=typeof window?window.__REACT_OS_SHELL_PDF_WASM__:void 0);return"string"==typeof t&&t?{wasmUrl:t.endsWith("/")?t:`${t}/`}:{BinaryDataFactory:g}}var y=[50,75,100,125,150,200,300,400];function v(e,t,n){const r=(t.width-40)/n.width,a="page"===e?Math.min(r,(t.height-40)/n.height):r;return Math.min(Math.max(a,.3),4)}function b({url:r,filename:a,fit:c="width",onDownload:m,onEmail:h,workerSrc:f,wasmUrl:g}){const b=t().pdf,x=o(null),k=o(null),C=o(null),[N,j]=i(null),[M,E]=i(1),[P,_]=i(0),[z,D]=i(1),[T,W]=i(!0),[L,S]=i(!0),$=o(b.loadFailed);$.current=b.loadFailed,s(()=>{let t=!1;return S(!0),E(1),f&&(l.GlobalWorkerOptions.workerSrc=f),l.getDocument({url:r,...w(g)}).promise.then(e=>{t||(j(e),_(e.numPages),S(!1))}).catch(()=>{t||(e.error($.current),S(!1))}),()=>{t=!0}},[r,f,g]),s(()=>{if(!N||!T||!C.current)return;const e=()=>{const e=C.current;e&&N.getPage(M).then(t=>{if(!C.current)return;const n=t.getViewport({scale:1}),r=v(c,{width:e.clientWidth,height:e.clientHeight},{width:n.width,height:n.height});D(e=>Math.abs(e-r)<.005?e:r)})};e();const t=new ResizeObserver(e);return t.observe(C.current),()=>t.disconnect()},[N,M,T,c]),s(()=>{if(!N||!x.current)return;let e=!1,t=null,n=null;return N.getPage(M).then(r=>{if(e||!x.current)return;const a=r.getViewport({scale:z}),o=x.current;o.width=a.width,o.height=a.height,o.style.width=`${a.width}px`,o.style.height=`${a.height}px`;const i=o.getContext("2d");t=r.render({canvas:o,canvasContext:i,viewport:a}),t.promise.catch(()=>{});const s=k.current;s&&(s.replaceChildren(),s.style.setProperty("--total-scale-factor",String(a.scale)),n=new l.TextLayer({textContentSource:r.streamTextContent(),container:s,viewport:a}),n.render().then(()=>{if(e)return;const t=document.createElement("div");t.className="endOfContent",s.append(t)}).catch(()=>{}))}),()=>{e=!0,t?.cancel(),n?.cancel()}},[N,M,z]),s(()=>{const e=()=>k.current?.classList.remove("selecting");return window.addEventListener("pointerup",e),()=>window.removeEventListener("pointerup",e)},[]);const A="page"===c?b.fitPage:b.fitWidth,O="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
3
3
  return u("div",{className:"flex flex-col h-full",children:[
4
4
  /* @__PURE__ */u(p,{children:[
5
- /* @__PURE__ */d("button",{type:"button","aria-label":b.previousPage,onClick:()=>M(e=>Math.max(1,e-1)),disabled:E<=1,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */d(n,{name:"chevron-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
6
- /* @__PURE__ */d("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:b.pageOf(E,_)}),
7
- /* @__PURE__ */d("button",{type:"button","aria-label":b.nextPage,onClick:()=>M(e=>Math.min(_,e+1)),disabled:E>=_,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */d(n,{name:"chevron-right",className:"h-3.5 w-3.5",strokeWidth:2})}),
5
+ /* @__PURE__ */d("button",{type:"button","aria-label":b.previousPage,onClick:()=>E(e=>Math.max(1,e-1)),disabled:M<=1,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */d(n,{name:"chevron-left",className:"h-3.5 w-3.5",strokeWidth:2})}),
6
+ /* @__PURE__ */d("span",{className:"text-gray-600 font-medium tabular-nums whitespace-nowrap",children:b.pageOf(M,P)}),
7
+ /* @__PURE__ */d("button",{type:"button","aria-label":b.nextPage,onClick:()=>E(e=>Math.min(P,e+1)),disabled:M>=P,className:"px-1 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-600",children:/* @__PURE__ */d(n,{name:"chevron-right",className:"h-3.5 w-3.5",strokeWidth:2})}),
8
8
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
9
- /* @__PURE__ */d("button",{type:"button","aria-label":b.zoomOut,title:b.zoomOut,onClick:()=>{W(!1),P(e=>Math.max(.3,Math.round(100*(e-.25))/100))},className:A,children:/* @__PURE__ */d("span",{"aria-hidden":"true",children:"−"})}),
10
- /* @__PURE__ */u("select",{value:S?"fit":y.includes(Math.round(100*D))?Math.round(100*D):"custom",onChange:e=>{const t=e.target.value;"fit"!==t?"custom"!==t&&(W(!1),P(Number(t)/100)):W(!0)},className:"bg-transparent hover:bg-gray-200 rounded px-1 py-1 text-gray-600 tabular-nums cursor-pointer focus:outline-none focus:ring-1 focus:ring-blue-400","aria-label":b.zoom,title:b.zoom,children:[
11
- /* @__PURE__ */d("option",{value:"fit",children:T}),!S&&!y.includes(Math.round(100*D))&&/* @__PURE__ */u("option",{value:"custom",children:[Math.round(100*D),"%"]}),y.map(e=>/* @__PURE__ */u("option",{value:e,children:[e,"%"]},e))]}),
12
- /* @__PURE__ */d("button",{type:"button","aria-label":b.zoomIn,title:b.zoomIn,onClick:()=>{W(!1),P(e=>Math.min(4,Math.round(100*(e+.25))/100))},className:A,children:/* @__PURE__ */d("span",{"aria-hidden":"true",children:"+"})}),
13
- /* @__PURE__ */d("button",{type:"button",onClick:()=>W(!0),"aria-pressed":S,className:A+(S?" bg-gray-200 text-gray-900":""),title:b.fitHint,children:b.fit}),
9
+ /* @__PURE__ */d("button",{type:"button","aria-label":b.zoomOut,title:b.zoomOut,onClick:()=>{W(!1),D(e=>Math.max(.3,Math.round(100*(e-.25))/100))},className:O,children:/* @__PURE__ */d("span",{"aria-hidden":"true",children:"−"})}),
10
+ /* @__PURE__ */u("select",{value:T?"fit":y.includes(Math.round(100*z))?Math.round(100*z):"custom",onChange:e=>{const t=e.target.value;"fit"!==t?"custom"!==t&&(W(!1),D(Number(t)/100)):W(!0)},className:"bg-transparent hover:bg-gray-200 rounded px-1 py-1 text-gray-600 tabular-nums cursor-pointer focus:outline-none focus:ring-1 focus:ring-blue-400","aria-label":b.zoom,title:b.zoom,children:[
11
+ /* @__PURE__ */d("option",{value:"fit",children:A}),!T&&!y.includes(Math.round(100*z))&&/* @__PURE__ */u("option",{value:"custom",children:[Math.round(100*z),"%"]}),y.map(e=>/* @__PURE__ */u("option",{value:e,children:[e,"%"]},e))]}),
12
+ /* @__PURE__ */d("button",{type:"button","aria-label":b.zoomIn,title:b.zoomIn,onClick:()=>{W(!1),D(e=>Math.min(4,Math.round(100*(e+.25))/100))},className:O,children:/* @__PURE__ */d("span",{"aria-hidden":"true",children:"+"})}),
13
+ /* @__PURE__ */d("button",{type:"button",onClick:()=>W(!0),"aria-pressed":T,className:O+(T?" bg-gray-200 text-gray-900":""),title:b.fitHint,children:b.fit}),
14
14
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
15
- /* @__PURE__ */u("button",{type:"button",onClick:()=>{if(!N)return;const t=window.open("","_blank");if(!t)return void e.error(b.allowPopups);const n=[];for(let e=1;e<=_;e++)n.push(N.getPage(e).then(e=>{const t=e.getViewport({scale:2}),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,e.render({canvas:n,canvasContext:n.getContext("2d"),viewport:t}).promise.then(()=>n.toDataURL())}));Promise.all(n).then(e=>{var n;t.document.write(`<html><head><title>${n=a,n.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e]))}</title><style>@media print{body{margin:0}img{width:100%;page-break-after:always}}</style></head><body>`),t.document.write(e.map(e=>`<img src="${e}"/>`).join("")),t.document.write("</body></html>"),t.document.close(),setTimeout(()=>{t.print(),t.close()},300)})},className:A,children:[
15
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>{if(!N)return;const t=window.open("","_blank");if(!t)return void e.error(b.allowPopups);const n=[];for(let e=1;e<=P;e++)n.push(N.getPage(e).then(e=>{const t=e.getViewport({scale:2}),n=document.createElement("canvas");return n.width=t.width,n.height=t.height,e.render({canvas:n,canvasContext:n.getContext("2d"),viewport:t}).promise.then(()=>n.toDataURL())}));Promise.all(n).then(e=>{var n;t.document.write(`<html><head><title>${n=a,n.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e]))}</title><style>@media print{body{margin:0}img{width:100%;page-break-after:always}}</style></head><body>`),t.document.write(e.map(e=>`<img src="${e}"/>`).join("")),t.document.write("</body></html>"),t.document.close(),setTimeout(()=>{t.print(),t.close()},300)})},className:O,children:[
16
16
  /* @__PURE__ */d(n,{name:"print",className:"h-3.5 w-3.5",strokeWidth:1.5}),b.print]}),
17
- /* @__PURE__ */u("button",{type:"button",onClick:m??(()=>{const e=document.createElement("a");e.href=r,e.download=a,e.click()}),className:A,children:[
18
- /* @__PURE__ */d(n,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),b.download]}),h&&/* @__PURE__ */u("button",{type:"button",onClick:h,className:A,children:[
17
+ /* @__PURE__ */u("button",{type:"button",onClick:m??(()=>{const e=document.createElement("a");e.href=r,e.download=a,e.click()}),className:O,children:[
18
+ /* @__PURE__ */d(n,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),b.download]}),h&&/* @__PURE__ */u("button",{type:"button",onClick:h,className:O,children:[
19
19
  /* @__PURE__ */d(n,{name:"email",className:"h-3.5 w-3.5",strokeWidth:1.5}),b.email]})]}),
20
- /* @__PURE__ */d("div",{ref:C,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!N)return;if(e.ctrlKey||e.metaKey)return;const t=C.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&E<_?(e.preventDefault(),M(e=>Math.min(_,e+1)),requestAnimationFrame(()=>{C.current&&(C.current.scrollTop=0)})):e.deltaY<0&&n&&E>1&&(e.preventDefault(),M(e=>Math.max(1,e-1)),requestAnimationFrame(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)}))},onKeyDown:e=>{if(!N)return;const t=(document.activeElement?.tagName||"").toLowerCase();"input"===t||"textarea"===t||document.activeElement?.isContentEditable||("PageDown"===e.key||"ArrowRight"===e.key?E<_&&(e.preventDefault(),M(e=>Math.min(_,e+1))):"PageUp"===e.key||"ArrowLeft"===e.key?E>1&&(e.preventDefault(),M(e=>Math.max(1,e-1))):"Home"===e.key?(e.preventDefault(),M(1)):"End"===e.key&&(e.preventDefault(),M(_)))},children:L?/* @__PURE__ */d("div",{className:"flex items-center justify-center h-full text-gray-500 text-sm",role:"status",children:b.loading}):/* @__PURE__ */u("div",{className:"min-h-full flex items-center justify-center p-4",children:[
20
+ /* @__PURE__ */d("div",{ref:C,className:"flex-1 overflow-auto bg-gray-100 outline-none",tabIndex:0,onWheel:e=>{if(!N)return;if(e.ctrlKey||e.metaKey)return;const t=C.current;if(!t)return;const n=t.scrollTop<=0,r=t.scrollTop+t.clientHeight>=t.scrollHeight-1;e.deltaY>0&&r&&M<P?(e.preventDefault(),E(e=>Math.min(P,e+1)),requestAnimationFrame(()=>{C.current&&(C.current.scrollTop=0)})):e.deltaY<0&&n&&M>1&&(e.preventDefault(),E(e=>Math.max(1,e-1)),requestAnimationFrame(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)}))},onKeyDown:e=>{if(!N)return;const t=(document.activeElement?.tagName||"").toLowerCase();"input"===t||"textarea"===t||document.activeElement?.isContentEditable||("PageDown"===e.key||"ArrowRight"===e.key?M<P&&(e.preventDefault(),E(e=>Math.min(P,e+1))):"PageUp"===e.key||"ArrowLeft"===e.key?M>1&&(e.preventDefault(),E(e=>Math.max(1,e-1))):"Home"===e.key?(e.preventDefault(),E(1)):"End"===e.key&&(e.preventDefault(),E(P)))},children:L?/* @__PURE__ */d("div",{className:"flex items-center justify-center h-full text-gray-500 text-sm",role:"status",children:b.loading}):/* @__PURE__ */u("div",{className:"min-h-full flex items-center justify-center p-4",children:[
21
21
  /* @__PURE__ */d("style",{children:'\n.preview-pdf-textlayer {\n position: absolute;\n inset: 0;\n overflow: clip;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n --min-font-size: 1;\n --text-scale-factor: calc(var(--total-scale-factor, 1) * var(--min-font-size));\n --min-font-size-inv: calc(1 / var(--min-font-size));\n}\n.preview-pdf-textlayer :is(span, br) {\n color: transparent;\n position: absolute;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n}\n.preview-pdf-textlayer > :not(.markedContent),\n.preview-pdf-textlayer .markedContent span:not(.markedContent) {\n z-index: 1;\n --font-height: 0;\n font-size: calc(var(--text-scale-factor) * var(--font-height));\n --scale-x: 1;\n --rotate: 0deg;\n transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));\n}\n.preview-pdf-textlayer .markedContent {\n display: contents;\n}\n.preview-pdf-textlayer span[role="img"] {\n user-select: none;\n cursor: default;\n}\n.preview-pdf-textlayer ::selection {\n background: rgba(0, 80, 255, 0.25);\n}\n.preview-pdf-textlayer br::selection {\n background: transparent;\n}\n.preview-pdf-textlayer .endOfContent {\n display: block;\n position: absolute;\n inset: 100% 0 0;\n z-index: 0;\n cursor: default;\n user-select: none;\n}\n.preview-pdf-textlayer.selecting .endOfContent {\n top: 0;\n}\n'}),
22
22
  /* @__PURE__ */u("div",{className:"relative shadow-lg rounded",children:[
23
23
  /* @__PURE__ */d("canvas",{ref:x,className:"block rounded"}),
@@ -1,38 +1,38 @@
1
- import{toast_default as e}from"./chunk-GJ37JCC2.js";import{useShellStrings as t}from"./chunk-K6DKX55N.js";import{forwardRef as r,useRef as n,useState as o,useMemo as i,useEffect as a,useImperativeHandle as l}from"react";import{jsx as c,jsxs as s,Fragment as d}from"react/jsx-runtime";var h=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],u=[{id:"system",name:"fontSystem",css:"-apple-system, system-ui, sans-serif"},{id:"serif",name:"fontSerif",css:'Georgia, "Times New Roman", serif'},{id:"mono",name:"fontMono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",name:"fontCursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],p=()=>Math.random().toString(36).slice(2,9),y=r(function({src:r,filename:y,onApply:m,onCancel:g},N){const L=n(null),z=n(null),D=n(null),P=n(null),$=t().annotator,E=n($);E.current=$;const[I,S]=o("select"),[W,B]=o(h[0]),[R,j]=o(4),[H,F]=o(24),[T,U]=o(u[0].id),[A,K]=o(!0),[O,V]=o(!1),[X,Z]=o(!1),[G,q]=o(null),[J,Y]=o(null),[_,Q]=o(6),[ee,te]=o(12),[re,ne]=o([]),[oe,ie]=o(null),[ae,le]=o(null),[ce,se]=o(null),[de,he]=o(1),[ue,pe]=o(null),[ye,xe]=o(null),[me,ge]=o(null),we=n(null),[fe,be]=o(!1),ve=i(()=>ce?{w:ce.w*de,h:ce.h*de}:null,[ce,de]),ke=ve&&ae?ve.w/ae.w:1,Me=i(()=>re.find(e=>e.id===oe)??null,[re,oe]);a(()=>{"select"===I&&Me&&("color"in Me&&B(Me.color),"stroke"in Me&&j(Me.stroke),"rect"===Me.type&&te(Me.radius),"text"===Me.type&&(F(Me.size),U(Me.font),K(Me.bold),V(Me.italic),Z(Me.underline),q(Me.borderColor),Y(Me.background),Q(Me.padding)))},[oe]),a(()=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>{P.current=t,le({w:t.naturalWidth,h:t.naturalHeight}),ne([]),ie(null)},t.onerror=()=>e.error(E.current.loadFailed),t.src=r},[r]),a(()=>{if(!ae)return;const e=()=>{const e=L.current;if(!e)return;const t=e.getBoundingClientRect(),r=Math.max(0,t.width-32),n=Math.max(0,t.height-32);if(0===r||0===n)return;const o=ae.w/ae.h;let i=ae.w,a=ae.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),se({w:i,h:a})};e();const t=new ResizeObserver(e);return L.current&&t.observe(L.current),()=>t.disconnect()},[ae]);const Ne=i(()=>re.filter(e=>"mosaic"===e.type),[re]);a(()=>{const e=P.current,t=z.current;if(!e||!t||!ae)return;t.width=ae.w,t.height=ae.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of Ne)C(r,e)},[ae,Ne,ce]);const Ce=e=>{const t=D.current;if(!t)return{x:0,y:0};const r=t.createSVGPoint();r.x=e.clientX,r.y=e.clientY;const n=t.getScreenCTM();if(!n)return{x:0,y:0};const o=r.matrixTransform(n.inverse());return{x:o.x,y:o.y}},Le=e=>{we.current=e,be(!0)};a(()=>{if(!fe)return;const e=e=>{const t=we.current;if(!t)return;const r=Ce(e);if("draw"===t.kind)pe(b(I,t.start,r,W,R,ee));else if("pen"===t.kind){const e=t.points[t.points.length-1];(Math.abs(r.x-e.x)>1||Math.abs(r.y-e.y)>1)&&(t.points.push(r),pe({id:"",type:"draw",points:t.points.slice(),color:W,stroke:R}))}else if("crop"===t.kind)ge(M(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ne(r=>r.map(r=>r.id===t.id?v(t.original,e,n):r))}else"resize"===t.kind&&ne(e=>e.map(e=>e.id===t.id?function(e,t,r){if("arrow"===e.type)return"start"===t?{...e,x1:r.x,y1:r.y}:"end"===t?{...e,x2:r.x,y2:r.y}:e;if("text"===e.type||"draw"===e.type)return e;const n=e.x,o=e.x+e.w,i=e.y,a=e.y+e.h;let l=n,c=i,s=o,d=a;"nw"===t&&(l=r.x,c=r.y);"ne"===t&&(s=r.x,c=r.y);"se"===t&&(s=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=M({x:l,y:c},{x:s,y:d});return{...e,x:h.x,y:h.y,w:h.w,h:h.h}}(t.original,t.corner,r):e))},t=()=>{const e=we.current;if(we.current=null,be(!1),"draw"===e?.kind)pe(e=>{if(!e||("arrow"===(t=e).type?Math.abs(t.x2-t.x1)<4&&Math.abs(t.y2-t.y1)<4:"draw"===t.type?t.points.length<2:"w"in t&&"h"in t&&(t.w<4||t.h<4)))return null;var t;const r={...e,id:p()};return ne(e=>[...e,r]),ie(r.id),S("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void pe(null);const t={id:p(),type:"draw",points:e.points,color:W,stroke:R};ne(e=>[...e,t]),ie(t.id),S("select"),pe(null)}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[fe,I,W,R,ee]);a(()=>{const e=e=>{if(!document.activeElement||!/^(INPUT|TEXTAREA)$/.test(document.activeElement.tagName))return!e.metaKey&&!e.ctrlKey||"z"!==e.key&&"Z"!==e.key||e.shiftKey?void(oe&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ne(e=>e.filter(e=>e.id!==oe)),ie(null)):"Escape"===e.key&&ie(null))):(e.preventDefault(),ne(e=>e.slice(0,-1)),void ie(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe]);const ze=e=>{const t=!{bold:A,italic:O,underline:X}[e];"bold"===e&&K(t),"italic"===e&&V(t),"underline"===e&&Z(t),oe&&ne(r=>r.map(r=>r.id===oe&&"text"===r.type?{...r,[e]:t}:r))},De=e=>{q(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,borderColor:e}:t))},Pe=e=>{Y(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,background:e}:t))},$e=e=>{if(!ye)return;const t=e??ye.value;if(!t.trim())return ye.editingId&&ne(e=>e.filter(e=>e.id!==ye.editingId)),void xe(null);if(ye.editingId)ne(e=>e.map(e=>e.id===ye.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:p(),type:"text",x:ye.x,y:ye.y,text:t,color:W,size:H,font:T,bold:A,italic:O,underline:X,borderColor:G,background:J,padding:_};ne(t=>[...t,e]),ie(e.id),S("select")}xe(null)},Ee=async()=>{const e=z.current,t=D.current;if(!e||!t||!ae)return null;const r=document.createElement("canvas");r.width=ae.w,r.height=ae.h;const n=r.getContext("2d");n.drawImage(e,0,0);const o=t.cloneNode(!0);o.querySelectorAll("[data-chrome]").forEach(e=>e.remove());const i=(new XMLSerializer).serializeToString(o),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a),c=new Image;return await new Promise(e=>{c.onload=()=>e(),c.onerror=()=>e(),c.src=l}),n.drawImage(c,0,0,ae.w,ae.h),URL.revokeObjectURL(l),r};l(N,()=>({save:async()=>{const t=await Ee();t&&t.toBlob(t=>{if(!t)return void e.error(E.current.exportFailed);const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=y.replace(/\.[^.]+$/,"");n.download=`${o}-annotated.png`,n.click(),URL.revokeObjectURL(r)},"image/png")},copy:async()=>{if(!("clipboard"in navigator)||"undefined"==typeof ClipboardItem)return void e.error(E.current.clipboardUnsupported);const t=await Ee();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success(E.current.copied)}catch{e.error(E.current.copyRefused)}else e.error(E.current.copyFailed)},"image/png")}}),[ae,y]);const Ie=i(()=>[{id:"select",label:$.toolSelect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:$.toolDraw,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487z"})})},{id:"rect",label:$.toolRect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:$.toolEllipse,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:$.toolArrow,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:$.toolMosaic,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:$.toolText,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:$.toolCrop,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[$]),Se=e=>"p-1.5 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),We=Me?.type??("select"===I?null:I),Be="rect"===We||"circle"===We||"arrow"===We||"draw"===We,Re="rect"===We,je="text"===We;/* @__PURE__ */
1
+ import{toast_default as e}from"./chunk-RUHUTZN4.js";import{useShellStrings as t}from"./chunk-QRCDQPJA.js";import{forwardRef as r,useRef as n,useState as o,useMemo as i,useEffect as a,useImperativeHandle as l}from"react";import{jsx as c,jsxs as s,Fragment as d}from"react/jsx-runtime";var h=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],u=[{id:"system",name:"fontSystem",css:"-apple-system, system-ui, sans-serif"},{id:"serif",name:"fontSerif",css:'Georgia, "Times New Roman", serif'},{id:"mono",name:"fontMono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",name:"fontCursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],p=()=>Math.random().toString(36).slice(2,9),y=r(function({src:r,filename:y,onApply:m,onCancel:g},N){const L=n(null),z=n(null),D=n(null),P=n(null),$=t().annotator,E=n($);E.current=$;const[I,S]=o("select"),[W,R]=o(h[0]),[B,j]=o(4),[H,T]=o(24),[U,F]=o(u[0].id),[A,O]=o(!0),[K,Z]=o(!1),[V,X]=o(!1),[q,G]=o(null),[Q,Y]=o(null),[_,J]=o(6),[ee,te]=o(12),[re,ne]=o([]),[oe,ie]=o(null),[ae,le]=o(null),[ce,se]=o(null),[de,he]=o(1),[ue,pe]=o(null),[ye,xe]=o(null),[me,ge]=o(null),we=n(null),[fe,be]=o(!1),ve=i(()=>ce?{w:ce.w*de,h:ce.h*de}:null,[ce,de]),ke=ve&&ae?ve.w/ae.w:1,Me=i(()=>re.find(e=>e.id===oe)??null,[re,oe]);a(()=>{"select"===I&&Me&&("color"in Me&&R(Me.color),"stroke"in Me&&j(Me.stroke),"rect"===Me.type&&te(Me.radius),"text"===Me.type&&(T(Me.size),F(Me.font),O(Me.bold),Z(Me.italic),X(Me.underline),G(Me.borderColor),Y(Me.background),J(Me.padding)))},[oe]),a(()=>{const t=new Image;t.crossOrigin="anonymous",t.onload=()=>{P.current=t,le({w:t.naturalWidth,h:t.naturalHeight}),ne([]),ie(null)},t.onerror=()=>e.error(E.current.loadFailed),t.src=r},[r]),a(()=>{if(!ae)return;const e=()=>{const e=L.current;if(!e)return;const t=e.getBoundingClientRect(),r=Math.max(0,t.width-32),n=Math.max(0,t.height-32);if(0===r||0===n)return;const o=ae.w/ae.h;let i=ae.w,a=ae.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),se({w:i,h:a})};e();const t=new ResizeObserver(e);return L.current&&t.observe(L.current),()=>t.disconnect()},[ae]);const Ne=i(()=>re.filter(e=>"mosaic"===e.type),[re]);a(()=>{const e=P.current,t=z.current;if(!e||!t||!ae)return;t.width=ae.w,t.height=ae.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of Ne)C(r,e)},[ae,Ne,ce]);const Ce=e=>{const t=D.current;if(!t)return{x:0,y:0};const r=t.createSVGPoint();r.x=e.clientX,r.y=e.clientY;const n=t.getScreenCTM();if(!n)return{x:0,y:0};const o=r.matrixTransform(n.inverse());return{x:o.x,y:o.y}},Le=e=>{we.current=e,be(!0)};a(()=>{if(!fe)return;const e=e=>{const t=we.current;if(!t)return;const r=Ce(e);if("draw"===t.kind)pe(b(I,t.start,r,W,B,ee));else if("pen"===t.kind){const e=t.points[t.points.length-1];(Math.abs(r.x-e.x)>1||Math.abs(r.y-e.y)>1)&&(t.points.push(r),pe({id:"",type:"draw",points:t.points.slice(),color:W,stroke:B}))}else if("crop"===t.kind)ge(M(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ne(r=>r.map(r=>r.id===t.id?v(t.original,e,n):r))}else"resize"===t.kind&&ne(e=>e.map(e=>e.id===t.id?function(e,t,r){if("arrow"===e.type)return"start"===t?{...e,x1:r.x,y1:r.y}:"end"===t?{...e,x2:r.x,y2:r.y}:e;if("text"===e.type||"draw"===e.type)return e;const n=e.x,o=e.x+e.w,i=e.y,a=e.y+e.h;let l=n,c=i,s=o,d=a;"nw"===t&&(l=r.x,c=r.y);"ne"===t&&(s=r.x,c=r.y);"se"===t&&(s=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=M({x:l,y:c},{x:s,y:d});return{...e,x:h.x,y:h.y,w:h.w,h:h.h}}(t.original,t.corner,r):e))},t=()=>{const e=we.current;if(we.current=null,be(!1),"draw"===e?.kind)pe(e=>{if(!e||("arrow"===(t=e).type?Math.abs(t.x2-t.x1)<4&&Math.abs(t.y2-t.y1)<4:"draw"===t.type?t.points.length<2:"w"in t&&"h"in t&&(t.w<4||t.h<4)))return null;var t;const r={...e,id:p()};return ne(e=>[...e,r]),ie(r.id),S("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void pe(null);const t={id:p(),type:"draw",points:e.points,color:W,stroke:B};ne(e=>[...e,t]),ie(t.id),S("select"),pe(null)}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[fe,I,W,B,ee]);a(()=>{const e=e=>{if(!document.activeElement||!/^(INPUT|TEXTAREA)$/.test(document.activeElement.tagName))return!e.metaKey&&!e.ctrlKey||"z"!==e.key&&"Z"!==e.key||e.shiftKey?void(oe&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ne(e=>e.filter(e=>e.id!==oe)),ie(null)):"Escape"===e.key&&ie(null))):(e.preventDefault(),ne(e=>e.slice(0,-1)),void ie(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[oe]);const ze=e=>{const t=!{bold:A,italic:K,underline:V}[e];"bold"===e&&O(t),"italic"===e&&Z(t),"underline"===e&&X(t),oe&&ne(r=>r.map(r=>r.id===oe&&"text"===r.type?{...r,[e]:t}:r))},De=e=>{G(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,borderColor:e}:t))},Pe=e=>{Y(e),oe&&ne(t=>t.map(t=>t.id===oe&&"text"===t.type?{...t,background:e}:t))},$e=e=>{if(!ye)return;const t=e??ye.value;if(!t.trim())return ye.editingId&&ne(e=>e.filter(e=>e.id!==ye.editingId)),void xe(null);if(ye.editingId)ne(e=>e.map(e=>e.id===ye.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:p(),type:"text",x:ye.x,y:ye.y,text:t,color:W,size:H,font:U,bold:A,italic:K,underline:V,borderColor:q,background:Q,padding:_};ne(t=>[...t,e]),ie(e.id),S("select")}xe(null)},Ee=async()=>{const e=z.current,t=D.current;if(!e||!t||!ae)return null;const r=document.createElement("canvas");r.width=ae.w,r.height=ae.h;const n=r.getContext("2d");n.drawImage(e,0,0);const o=t.cloneNode(!0);o.querySelectorAll("[data-chrome]").forEach(e=>e.remove());const i=(new XMLSerializer).serializeToString(o),a=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a),c=new Image;return await new Promise(e=>{c.onload=()=>e(),c.onerror=()=>e(),c.src=l}),n.drawImage(c,0,0,ae.w,ae.h),URL.revokeObjectURL(l),r};l(N,()=>({save:async()=>{const t=await Ee();t&&t.toBlob(t=>{if(!t)return void e.error(E.current.exportFailed);const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=y.replace(/\.[^.]+$/,"");n.download=`${o}-annotated.png`,n.click(),URL.revokeObjectURL(r)},"image/png")},copy:async()=>{if(!("clipboard"in navigator)||"undefined"==typeof ClipboardItem)return void e.error(E.current.clipboardUnsupported);const t=await Ee();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success(E.current.copied)}catch{e.error(E.current.copyRefused)}else e.error(E.current.copyFailed)},"image/png")}}),[ae,y]);const Ie=i(()=>[{id:"select",label:$.toolSelect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:$.toolDraw,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487z"})})},{id:"rect",label:$.toolRect,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:$.toolEllipse,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:$.toolArrow,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:$.toolMosaic,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:$.toolText,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:$.toolCrop,icon:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[$]),Se=e=>"p-2 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),We=Me?.type??("select"===I?null:I),Re="rect"===We||"circle"===We||"arrow"===We||"draw"===We,Be="rect"===We,je="text"===We;/* @__PURE__ */
2
2
  return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
3
- /* @__PURE__ */s("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-[12px]",children:[Ie.map(e=>/* @__PURE__ */c("button",{onClick:()=>{S(e.id),ie(null)},title:e.label,className:Se(I===e.id),children:e.icon},e.id)),
3
+ /* @__PURE__ */s("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-white shrink-0 flex-wrap text-xs",children:[Ie.map(e=>/* @__PURE__ */c("button",{onClick:()=>{S(e.id),ie(null)},title:e.label,className:Se(I===e.id),children:e.icon},e.id)),
4
4
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
5
- /* @__PURE__ */c("div",{className:"flex items-center gap-1",children:h.map(e=>/* @__PURE__ */c("button",{onClick:()=>(e=>{B(e),oe&&ne(t=>t.map(t=>t.id!==oe||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+(W===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Be&&/* @__PURE__ */s(d,{children:[
5
+ /* @__PURE__ */c("div",{className:"flex items-center gap-1",children:h.map(e=>/* @__PURE__ */c("button",{onClick:()=>(e=>{R(e),oe&&ne(t=>t.map(t=>t.id!==oe||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+(W===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Re&&/* @__PURE__ */s(d,{children:[
6
6
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
7
- /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
7
+ /* @__PURE__ */s("label",{className:"flex items-center gap-2 text-gray-600",children:[
8
8
  /* @__PURE__ */c("span",{children:$.weight}),
9
- /* @__PURE__ */c("input",{type:"range",min:1,max:20,step:1,value:R,onChange:e=>{return t=Number(e.target.value),j(t),void(oe&&ne(e=>e.map(e=>e.id!==oe?e:"rect"===e.type||"circle"===e.type||"arrow"===e.type||"draw"===e.type?{...e,stroke:t}:e)));var t},className:"w-16 accent-blue-500"}),
10
- /* @__PURE__ */c("span",{className:"tabular-nums w-5 text-right",children:R})]})]}),Re&&/* @__PURE__ */s(d,{children:[
9
+ /* @__PURE__ */c("input",{type:"range",min:1,max:20,step:1,value:B,onChange:e=>{return t=Number(e.target.value),j(t),void(oe&&ne(e=>e.map(e=>e.id!==oe?e:"rect"===e.type||"circle"===e.type||"arrow"===e.type||"draw"===e.type?{...e,stroke:t}:e)));var t},className:"w-16 accent-blue-500"}),
10
+ /* @__PURE__ */c("span",{className:"tabular-nums w-5 text-right",children:B})]})]}),Be&&/* @__PURE__ */s(d,{children:[
11
11
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
12
- /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
12
+ /* @__PURE__ */s("label",{className:"flex items-center gap-2 text-gray-600",children:[
13
13
  /* @__PURE__ */c("span",{children:$.radius}),
14
14
  /* @__PURE__ */c("input",{type:"range",min:0,max:48,step:1,value:ee,onChange:e=>{return t=Number(e.target.value),te(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
15
15
  /* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:ee})]})]}),je&&/* @__PURE__ */s(d,{children:[
16
16
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
17
- /* @__PURE__ */c("select",{value:T,onChange:e=>{return t=e.target.value,U(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,font:t}:e)));var t},className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:u.map(e=>/* @__PURE__ */c("option",{value:e.id,children:$[e.name]},e.id))}),
17
+ /* @__PURE__ */c("select",{value:U,onChange:e=>{return t=e.target.value,F(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,font:t}:e)));var t},className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:u.map(e=>/* @__PURE__ */c("option",{value:e.id,children:$[e.name]},e.id))}),
18
18
  /* @__PURE__ */c("button",{onClick:()=>ze("bold"),className:Se(A),title:$.bold,children:/* @__PURE__ */c("span",{className:"font-bold",children:$.boldLetter})}),
19
- /* @__PURE__ */c("button",{onClick:()=>ze("italic"),className:Se(O),title:$.italic,children:/* @__PURE__ */c("span",{className:"italic",children:$.italicLetter})}),
20
- /* @__PURE__ */c("button",{onClick:()=>ze("underline"),className:Se(X),title:$.underline,children:/* @__PURE__ */c("span",{className:"underline",children:$.underlineLetter})}),
21
- /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
19
+ /* @__PURE__ */c("button",{onClick:()=>ze("italic"),className:Se(K),title:$.italic,children:/* @__PURE__ */c("span",{className:"italic",children:$.italicLetter})}),
20
+ /* @__PURE__ */c("button",{onClick:()=>ze("underline"),className:Se(V),title:$.underline,children:/* @__PURE__ */c("span",{className:"underline",children:$.underlineLetter})}),
21
+ /* @__PURE__ */s("label",{className:"flex items-center gap-2 text-gray-600",children:[
22
22
  /* @__PURE__ */c("span",{children:$.size}),
23
- /* @__PURE__ */c("input",{type:"range",min:10,max:96,step:1,value:H,onChange:e=>{return t=Number(e.target.value),F(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
23
+ /* @__PURE__ */c("input",{type:"range",min:10,max:96,step:1,value:H,onChange:e=>{return t=Number(e.target.value),T(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
24
24
  /* @__PURE__ */c("span",{className:"tabular-nums w-7 text-right",children:H})]}),
25
25
  /* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
26
- /* @__PURE__ */c("span",{children:$.border}),G?/* @__PURE__ */s(d,{children:[
27
- /* @__PURE__ */c("input",{type:"color",value:G,onChange:e=>De(e.target.value),title:$.borderColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
28
- /* @__PURE__ */c("button",{onClick:()=>De(null),title:$.removeBorder,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>De(W),title:$.addBorder,className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:$.add})]}),
26
+ /* @__PURE__ */c("span",{children:$.border}),q?/* @__PURE__ */s(d,{children:[
27
+ /* @__PURE__ */c("input",{type:"color",value:q,onChange:e=>De(e.target.value),title:$.borderColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
28
+ /* @__PURE__ */c("button",{onClick:()=>De(null),title:$.removeBorder,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>De(W),title:$.addBorder,className:"px-2 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:$.add})]}),
29
29
  /* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
30
- /* @__PURE__ */c("span",{children:$.fill}),J?/* @__PURE__ */s(d,{children:[
31
- /* @__PURE__ */c("input",{type:"color",value:J,onChange:e=>Pe(e.target.value),title:$.fillColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
32
- /* @__PURE__ */c("button",{onClick:()=>Pe(null),title:$.removeFill,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>Pe("#ffffff"),title:$.addFill,className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:$.add})]}),
33
- /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
30
+ /* @__PURE__ */c("span",{children:$.fill}),Q?/* @__PURE__ */s(d,{children:[
31
+ /* @__PURE__ */c("input",{type:"color",value:Q,onChange:e=>Pe(e.target.value),title:$.fillColor,className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
32
+ /* @__PURE__ */c("button",{onClick:()=>Pe(null),title:$.removeFill,className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */c("button",{onClick:()=>Pe("#ffffff"),title:$.addFill,className:"px-2 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:$.add})]}),
33
+ /* @__PURE__ */s("label",{className:"flex items-center gap-2 text-gray-600",children:[
34
34
  /* @__PURE__ */c("span",{children:$.padding}),
35
- /* @__PURE__ */c("input",{type:"range",min:0,max:40,step:1,value:_,onChange:e=>{return t=Number(e.target.value),Q(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
35
+ /* @__PURE__ */c("input",{type:"range",min:0,max:40,step:1,value:_,onChange:e=>{return t=Number(e.target.value),J(t),void(oe&&ne(e=>e.map(e=>e.id===oe&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
36
36
  /* @__PURE__ */c("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),
37
37
  /* @__PURE__ */c("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
38
38
  /* @__PURE__ */c("button",{onClick:()=>he(e=>Math.max(.25,Math.round(100*(e-.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:$.zoomOut,children:"−"}),
@@ -47,8 +47,8 @@ return s("div",{className:"flex flex-col h-full bg-gray-100",children:[
47
47
  /* @__PURE__ */c("button",{onClick:async()=>{const t=await Ee();t?t.toBlob(t=>{t?m(t):e.error(E.current.exportFailed)},"image/png"):e.error(E.current.exportFailed)},className:"px-3 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 text-xs font-medium",children:$.apply})]})]})]}),
48
48
  /* @__PURE__ */c("div",{ref:L,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:ve&&ae&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:ve.w,height:ve.h},children:[
49
49
  /* @__PURE__ */c("canvas",{ref:z,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),
50
- /* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ae.w} ${ae.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===I?"default":"text"===I?"text":"crosshair"},onPointerDown:e=>{if("select"===I)return void ie(null);if("text"===I){if(ye)return void $e();const t=Ce(e);return void xe({x:t.x,y:t.y,value:""})}const t=Ce(e);if("crop"!==I){if("draw"===I)return Le({kind:"pen",points:[t]}),void pe({id:"",type:"draw",points:[t],color:W,stroke:R});pe(b(I,t,t,W,R,ee)),Le({kind:"draw",start:t})}else Le({kind:"crop",start:t})},children:[re.map(e=>/* @__PURE__ */c(x,{anno:e,selected:oe===e.id,zoom:de,onPointerDown:t=>((e,t)=>{"select"===I&&(e.stopPropagation(),ie(t.id),Le({kind:"move",id:t.id,start:Ce(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&xe({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Le({kind:"resize",id:t.id,corner:r,start:Ce(e),original:t})})(t,e,r)},e.id)),ue&&/* @__PURE__ */c(x,{anno:{...ue,id:"__preview"},preview:!0}),me&&/* @__PURE__ */c(w,{rect:me,imageSize:ae})]}),ye&&/* @__PURE__ */c(f,{pendingText:ye,color:W,size:H,font:u.find(e=>e.id===T)?.css??u[0].css,bold:A,italic:O,underline:X,borderColor:G,background:J,padding:_,scale:ke,onChange:e=>xe({...ye,value:e}),onCommit:$e,onCancel:()=>xe(null)})]})}),
51
- /* @__PURE__ */c("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===I?oe?$.hintSelected:$.hintSelect:"text"===I?$.hintText:"crop"===I?$.hintCrop:"draw"===I?$.hintDraw:$.hintShape})]})});function x({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const l=k(e),h=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,rx:e.radius,ry:e.radius,fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("circle"===e.type)y=/* @__PURE__ */c("ellipse",{cx:e.x+e.w/2,cy:e.y+e.h/2,rx:e.w/2,ry:e.h/2,fill:"none",stroke:e.color,strokeWidth:e.stroke,...h});else if("arrow"===e.type)y=/* @__PURE__ */c(g,{anno:e,interactive:h});else if("draw"===e.type)y=/* @__PURE__ */c("path",{d:N(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("mosaic"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"rgba(0,0,0,0.001)",stroke:t?"#3b82f6":"none",strokeWidth:t?2:0,strokeDasharray:t?"6,4":void 0,...h});else{const t=u.find(t=>t.id===e.font)?.css??u[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=k(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...h,...p,children:[n&&/* @__PURE__ */c("rect",{x:o.x-r,y:o.y-r,width:Math.max(0,o.w)+2*r,height:Math.max(0,o.h)+2*r,rx:Math.min(8,r),ry:Math.min(8,r),fill:e.background??"none",stroke:e.borderColor??"none",strokeWidth:i}),
50
+ /* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ae.w} ${ae.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===I?"default":"text"===I?"text":"crosshair"},onPointerDown:e=>{if("select"===I)return void ie(null);if("text"===I){if(ye)return void $e();const t=Ce(e);return void xe({x:t.x,y:t.y,value:""})}const t=Ce(e);if("crop"!==I){if("draw"===I)return Le({kind:"pen",points:[t]}),void pe({id:"",type:"draw",points:[t],color:W,stroke:B});pe(b(I,t,t,W,B,ee)),Le({kind:"draw",start:t})}else Le({kind:"crop",start:t})},children:[re.map(e=>/* @__PURE__ */c(x,{anno:e,selected:oe===e.id,zoom:de,onPointerDown:t=>((e,t)=>{"select"===I&&(e.stopPropagation(),ie(t.id),Le({kind:"move",id:t.id,start:Ce(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&xe({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Le({kind:"resize",id:t.id,corner:r,start:Ce(e),original:t})})(t,e,r)},e.id)),ue&&/* @__PURE__ */c(x,{anno:{...ue,id:"__preview"},preview:!0}),me&&/* @__PURE__ */c(w,{rect:me,imageSize:ae})]}),ye&&/* @__PURE__ */c(f,{pendingText:ye,color:W,size:H,font:u.find(e=>e.id===U)?.css??u[0].css,bold:A,italic:K,underline:V,borderColor:q,background:Q,padding:_,scale:ke,onChange:e=>xe({...ye,value:e}),onCommit:$e,onCancel:()=>xe(null)})]})}),
51
+ /* @__PURE__ */c("div",{className:"px-3 py-2 border-t border-gray-200 bg-white text-2xs text-gray-500 shrink-0",children:"select"===I?oe?$.hintSelected:$.hintSelect:"text"===I?$.hintText:"crop"===I?$.hintCrop:"draw"===I?$.hintDraw:$.hintShape})]})});function x({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const l=k(e),h=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,rx:e.radius,ry:e.radius,fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("circle"===e.type)y=/* @__PURE__ */c("ellipse",{cx:e.x+e.w/2,cy:e.y+e.h/2,rx:e.w/2,ry:e.h/2,fill:"none",stroke:e.color,strokeWidth:e.stroke,...h});else if("arrow"===e.type)y=/* @__PURE__ */c(g,{anno:e,interactive:h});else if("draw"===e.type)y=/* @__PURE__ */c("path",{d:N(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...h});else if("mosaic"===e.type)y=/* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"rgba(0,0,0,0.001)",stroke:t?"#3b82f6":"none",strokeWidth:t?2:0,strokeDasharray:t?"6,4":void 0,...h});else{const t=u.find(t=>t.id===e.font)?.css??u[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=k(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...h,...p,children:[n&&/* @__PURE__ */c("rect",{x:o.x-r,y:o.y-r,width:Math.max(0,o.w)+2*r,height:Math.max(0,o.h)+2*r,rx:Math.min(8,r),ry:Math.min(8,r),fill:e.background??"none",stroke:e.borderColor??"none",strokeWidth:i}),
52
52
  /* @__PURE__ */c("text",{x:e.x,y:e.y+e.size,fill:e.color,fontSize:e.size,fontWeight:e.bold?700:400,fontStyle:e.italic?"italic":"normal",textDecoration:e.underline?"underline":void 0,fontFamily:t,style:{userSelect:"none"},children:e.text.split("\n").map((t,r)=>/* @__PURE__ */c("tspan",{x:e.x,dy:0===r?0:1.2*e.size,children:t},r))})]})}/* @__PURE__ */
53
53
  return s("g",{children:[y,t&&!r&&/* @__PURE__ */s(d,{children:[
54
54
  /* @__PURE__ */c("rect",{"data-chrome":"selection",x:l.x-4,y:l.y-4,width:l.w+8,height:l.h+8,fill:"none",stroke:"#3b82f6",strokeWidth:2/n,strokeDasharray:`${6/n},${4/n}`,pointerEvents:"none"}),a&&/* @__PURE__ */c(m,{anno:e,zoom:n,onHandlePointerDown:a})]})]})}function m({anno:e,zoom:t,onHandlePointerDown:r}){const n=6/t,o=1.5/t,i=e=>({fill:"#fff",stroke:"#3b82f6",strokeWidth:o,pointerEvents:"all",style:{cursor:e},"data-chrome":"handle"});if("arrow"===e.type)/* @__PURE__ */
@@ -66,4 +66,4 @@ return s("g",{...t,children:[
66
66
  return s("g",{pointerEvents:"none",children:[
67
67
  /* @__PURE__ */c("path",{d:`M0,0 H${t.w} V${t.h} H0 Z M${e.x},${e.y} V${e.y+e.h} H${e.x+e.w} V${e.y} Z`,fill:"rgba(0,0,0,0.45)",fillRule:"evenodd"}),
68
68
  /* @__PURE__ */c("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"8,6"})]})}function f({pendingText:e,color:r,size:o,font:i,bold:l,italic:s,underline:d,borderColor:h,background:u,padding:p,scale:y,onChange:x,onCommit:m,onCancel:g}){const w=n(null),f=t().annotator;a(()=>{const e=requestAnimationFrame(()=>{w.current?.focus(),w.current?.select?.()});return()=>cancelAnimationFrame(e)},[]);const b=()=>m(w.current?.value),v=h?Math.max(1,Math.round(o/12)):0;/* @__PURE__ */
69
- return c("div",{style:{position:"absolute",left:e.x*y+"px",top:e.y*y+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */c("textarea",{ref:w,value:e.value,onChange:e=>x(e.target.value),onBlur:b,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),g()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),b())},placeholder:f.textPlaceholder,rows:1,className:"outline-none resize-none shadow-md",style:{color:r,fontSize:o*y+"px",fontFamily:i,fontWeight:l?700:400,fontStyle:s?"italic":"normal",textDecoration:d?"underline":void 0,minWidth:80,padding:p*y+"px",borderRadius:Math.min(8,p)*y+"px",border:h?`${v*y}px solid ${h}`:"1px dashed #60a5fa",background:u??"rgba(255,255,255,0.95)"}})})}function b(e,t,r,n,o,i){if("rect"===e){const e=M(t,r);return{id:"",type:"rect",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o,radius:i}}if("circle"===e){const e=M(t,r);return{id:"",type:"circle",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o}}if("arrow"===e)return{id:"",type:"arrow",x1:t.x,y1:t.y,x2:r.x,y2:r.y,color:n,stroke:o};if("mosaic"===e){const e=M(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function v(e,t,r){return"arrow"===e.type?{...e,x1:e.x1+t,y1:e.y1+r,x2:e.x2+t,y2:e.y2+r}:"draw"===e.type?{...e,points:e.points.map(e=>({x:e.x+t,y:e.y+r}))}:(e.type,{...e,x:e.x+t,y:e.y+r})}function k(e){if("arrow"===e.type){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}if("draw"===e.type){if(0===e.points.length)return{x:0,y:0,w:0,h:0};let t=e.points[0].x,r=e.points[0].x,n=e.points[0].y,o=e.points[0].y;for(const i of e.points)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return{x:t,y:n,w:r-t,h:o-n}}if("text"===e.type){const t=e.text.split("\n"),r=t.reduce((e,t)=>Math.max(e,t.length),0);return{x:e.x,y:e.y,w:r*e.size*.55,h:t.length*e.size*1.2}}return{x:e.x,y:e.y,w:e.w,h:e.h}}function M(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function N(e){if(0===e.length)return"";let t=`M ${e[0].x} ${e[0].y}`;for(let r=1;r<e.length;r++)t+=` L ${e[r].x} ${e[r].y}`;return t}function C(e,t){const r=Math.round(Math.max(0,t.x)),n=Math.round(Math.max(0,t.y)),o=Math.round(Math.min(e.canvas.width-r,t.w)),i=Math.round(Math.min(e.canvas.height-n,t.h));if(o<2||i<2)return;const a=e.getImageData(r,n,o,i);for(let e=0;e<i;e+=12)for(let t=0;t<o;t+=12){let r=0,n=0,l=0,c=0,s=0;const d=Math.min(12,o-t),h=Math.min(12,i-e);for(let i=0;i<h;i++)for(let h=0;h<d;h++){const d=4*((e+i)*o+(t+h));r+=a.data[d],n+=a.data[d+1],l+=a.data[d+2],c+=a.data[d+3],s++}r=Math.round(r/s),n=Math.round(n/s),l=Math.round(l/s),c=Math.round(c/s);for(let i=0;i<h;i++)for(let s=0;s<d;s++){const d=4*((e+i)*o+(t+s));a.data[d]=r,a.data[d+1]=n,a.data[d+2]=l,a.data[d+3]=c}}e.putImageData(a,r,n)}export{y as ImageAnnotator_default};
69
+ return c("div",{style:{position:"absolute",left:e.x*y+"px",top:e.y*y+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */c("textarea",{ref:w,value:e.value,onChange:e=>x(e.target.value),onBlur:b,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),g()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),b())},placeholder:f.textPlaceholder,rows:1,className:"outline-none resize-none shadow-(--elevation-panel)",style:{color:r,fontSize:o*y+"px",fontFamily:i,fontWeight:l?700:400,fontStyle:s?"italic":"normal",textDecoration:d?"underline":void 0,minWidth:80,padding:p*y+"px",borderRadius:Math.min(8,p)*y+"px",border:h?`${v*y}px solid ${h}`:"1px dashed #60a5fa",background:u??"rgba(255,255,255,0.95)"}})})}function b(e,t,r,n,o,i){if("rect"===e){const e=M(t,r);return{id:"",type:"rect",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o,radius:i}}if("circle"===e){const e=M(t,r);return{id:"",type:"circle",x:e.x,y:e.y,w:e.w,h:e.h,color:n,stroke:o}}if("arrow"===e)return{id:"",type:"arrow",x1:t.x,y1:t.y,x2:r.x,y2:r.y,color:n,stroke:o};if("mosaic"===e){const e=M(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function v(e,t,r){return"arrow"===e.type?{...e,x1:e.x1+t,y1:e.y1+r,x2:e.x2+t,y2:e.y2+r}:"draw"===e.type?{...e,points:e.points.map(e=>({x:e.x+t,y:e.y+r}))}:(e.type,{...e,x:e.x+t,y:e.y+r})}function k(e){if("arrow"===e.type){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),w:Math.abs(e.x2-e.x1),h:Math.abs(e.y2-e.y1)}}if("draw"===e.type){if(0===e.points.length)return{x:0,y:0,w:0,h:0};let t=e.points[0].x,r=e.points[0].x,n=e.points[0].y,o=e.points[0].y;for(const i of e.points)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return{x:t,y:n,w:r-t,h:o-n}}if("text"===e.type){const t=e.text.split("\n"),r=t.reduce((e,t)=>Math.max(e,t.length),0);return{x:e.x,y:e.y,w:r*e.size*.55,h:t.length*e.size*1.2}}return{x:e.x,y:e.y,w:e.w,h:e.h}}function M(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function N(e){if(0===e.length)return"";let t=`M ${e[0].x} ${e[0].y}`;for(let r=1;r<e.length;r++)t+=` L ${e[r].x} ${e[r].y}`;return t}function C(e,t){const r=Math.round(Math.max(0,t.x)),n=Math.round(Math.max(0,t.y)),o=Math.round(Math.min(e.canvas.width-r,t.w)),i=Math.round(Math.min(e.canvas.height-n,t.h));if(o<2||i<2)return;const a=e.getImageData(r,n,o,i);for(let e=0;e<i;e+=12)for(let t=0;t<o;t+=12){let r=0,n=0,l=0,c=0,s=0;const d=Math.min(12,o-t),h=Math.min(12,i-e);for(let i=0;i<h;i++)for(let h=0;h<d;h++){const d=4*((e+i)*o+(t+h));r+=a.data[d],n+=a.data[d+1],l+=a.data[d+2],c+=a.data[d+3],s++}r=Math.round(r/s),n=Math.round(n/s),l=Math.round(l/s),c=Math.round(c/s);for(let i=0;i<h;i++)for(let s=0;s<d;s++){const d=4*((e+i)*o+(t+s));a.data[d]=r,a.data[d+1]=n,a.data[d+2]=l,a.data[d+3]=c}}e.putImageData(a,r,n)}export{y as ImageAnnotator_default};
@@ -1 +1 @@
1
- import{client_default as a}from"./chunk-QJHWLDEN.js";var e=()=>a.get("/auth/numbering-configs/").then(a=>a.data?.results??a.data??[]),t="uploaded:wallpaper";function r(a,e){return"string"!=typeof a||!a||"none"===a||a.startsWith("#")?"":a===t?e||"":a}var p=()=>a.get("/auth/me/wallpaper/").then(a=>a.data),n=e=>{const t=new FormData;return t.append("wallpaper",e),a.post("/auth/me/wallpaper/",t).then(a=>a.data)},l=()=>a.delete("/auth/me/wallpaper/").then(a=>a.data);function s(a){const e=a?.response?.status,t=a?.response?.data,r=Array.isArray(t?.wallpaper)?t.wallpaper[0]:void 0;return r||(413===e?"That picture is too large to use as a wallpaper.":415===e?"That file is not a picture this can use as a wallpaper.":"The wallpaper could not be saved. Please try again.")}export{t as WALLPAPER_PREF_TOKEN,l as deleteWallpaper,e as getNumberingConfigs,p as getWallpaper,n as uploadWallpaper,r as wallpaperSrc,s as wallpaperUploadError};
1
+ import{client_default as a}from"./chunk-6SCHK75C.js";var e=()=>a.get("/auth/numbering-configs/").then(a=>a.data?.results??a.data??[]),t="uploaded:wallpaper";function r(a,e){return"string"!=typeof a||!a||"none"===a||a.startsWith("#")?"":a===t?e||"":a}var p=()=>a.get("/auth/me/wallpaper/").then(a=>a.data),n=e=>{const t=new FormData;return t.append("wallpaper",e),a.post("/auth/me/wallpaper/",t).then(a=>a.data)},l=()=>a.delete("/auth/me/wallpaper/").then(a=>a.data);function s(a){const e=a?.response?.status,t=a?.response?.data,r=Array.isArray(t?.wallpaper)?t.wallpaper[0]:void 0;return r||(413===e?"That picture is too large to use as a wallpaper.":415===e?"That file is not a picture this can use as a wallpaper.":"The wallpaper could not be saved. Please try again.")}export{t as WALLPAPER_PREF_TOKEN,l as deleteWallpaper,e as getNumberingConfigs,p as getWallpaper,n as uploadWallpaper,r as wallpaperSrc,s as wallpaperUploadError};
@@ -1,4 +1,4 @@
1
- import{useShellStrings as e}from"./chunk-K6DKX55N.js";import{Icon as i}from"./chunk-2SSRFEOZ.js";import{Fragment as t}from"react";import{jsx as n,jsxs as a}from"react/jsx-runtime";var s=/* @__PURE__ */n(i,{name:"chevron-right",look:"mini",className:"h-3.5 w-3.5 shrink-0 text-gray-300","aria-hidden":!0}),r="inline-flex min-w-0 items-center gap-1 truncate rounded px-1 -mx-1 text-gray-500 transition-colors hover:text-gray-900 hover:underline rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]";function l({items:i,separator:l,maxItems:c=0,className:m}){const o=e().breadcrumbs;if(0===i.length)return null;const h=l??s,d=[],u=i.length-1;if(c>0&&i.length>c&&c>=2){const e=Math.max(1,c-1);d.push({kind:"item",item:i[0],isLast:!1}),d.push({kind:"ellipsis"});for(let t=i.length-e;t<=u;t++)d.push({kind:"item",item:i[t],isLast:t===u})}else i.forEach((e,i)=>d.push({kind:"item",item:e,isLast:i===u}));/* @__PURE__ */
1
+ import{useShellStrings as e}from"./chunk-QRCDQPJA.js";import{Icon as i}from"./chunk-CJHT4VTF.js";import{Fragment as t}from"react";import{jsx as n,jsxs as a}from"react/jsx-runtime";var s=/* @__PURE__ */n(i,{name:"chevron-right",look:"mini",className:"h-3.5 w-3.5 shrink-0 text-gray-300","aria-hidden":!0}),r="inline-flex min-w-0 items-center gap-1 truncate rounded px-1 -mx-1 text-gray-500 transition-colors hover:text-gray-900 hover:underline rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]";function l({items:i,separator:l,maxItems:c=0,className:m}){const o=e().breadcrumbs;if(0===i.length)return null;const h=l??s,d=[],u=i.length-1;if(c>0&&i.length>c&&c>=2){const e=Math.max(1,c-1);d.push({kind:"item",item:i[0],isLast:!1}),d.push({kind:"ellipsis"});for(let t=i.length-e;t<=u;t++)d.push({kind:"item",item:i[t],isLast:t===u})}else i.forEach((e,i)=>d.push({kind:"item",item:e,isLast:i===u}));/* @__PURE__ */
2
2
  return n("nav",{"aria-label":o.label,className:`min-w-0 ${m??""}`,children:/* @__PURE__ */n("ol",{className:"flex items-center gap-1.5 text-sm",children:d.map((e,i)=>/* @__PURE__ */a(t,{children:[i>0&&/* @__PURE__ */n("li",{"aria-hidden":!0,className:"flex items-center",children:h}),
3
3
  /* @__PURE__ */n("li",{className:"flex min-w-0 items-center",children:"ellipsis"===e.kind?/* @__PURE__ */n("span",{className:"px-0.5 text-gray-400 select-none","aria-label":o.hidden,children:"…"}):e.isLast||!e.item.href&&!e.item.onClick?/* @__PURE__ */a("span",{"aria-current":e.isLast?"page":void 0,className:"inline-flex min-w-0 items-center gap-1 truncate "+(e.isLast?"font-medium text-gray-900":"text-gray-500"),children:[e.item.icon,
4
4
  /* @__PURE__ */n("span",{className:"truncate",children:e.item.label})]}):e.item.href?/* @__PURE__ */a("a",{href:e.item.href,onClick:e.item.onClick,className:r,children:[e.item.icon,
@@ -1 +1 @@
1
- import{DEFAULT_SHELL_STRINGS as e,useShellStrings as t}from"./chunk-K6DKX55N.js";import{useRef as r,useState as n,useCallback as s}from"react";import{jsx as a}from"react/jsx-runtime";function o(e,t){const r=(t??"").split(",").map(e=>e.trim().toLocaleLowerCase()).filter(Boolean);if(0===r.length||r.includes("*")||r.includes("*/*"))return!0;const n=e.name.toLocaleLowerCase(),s=e.type.toLocaleLowerCase();return r.some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?s.startsWith(e.slice(0,-1)):s===e)}var l=(t,r=e.files)=>t<1024?r.bytes(t):t<1048576?r.kilobytes(Math.round(t/1024)):r.megabytes(t/1048576),i=e=>Array.from(e.dataTransfer?.types??[]).includes("Files");function c({onAccept:e,accept:a,maxSizeBytes:c,maxFiles:u,multiple:f=!0,currentCount:p=0,acceptHint:m,disabled:d=!1}){const h=t().files,g=r(null),[y,x]=n(!1),[v,D]=n([]),L=r(0),b="string"==typeof m?m:"",A=s(t=>{if(d||!t)return;const r=Array.from(t);if(0===r.length)return;const n=[],s=[];for(const e of f?r:r.slice(0,1))o(e,a)?null!=c&&e.size>c?s.push({file:e,reason:"size",message:h.tooLarge(e.name,l(e.size,h),l(c,h))}):f&&null!=u&&p+n.length>=u?s.push({file:e,reason:"count",message:h.tooMany(e.name,u)}):n.push(e):s.push({file:e,reason:"type",message:h.notAccepted(e.name,b)});D(s),n.length&&e(n),g.current&&(g.current.value="")},[d,f,a,b,c,u,p,e,h]),j=s(()=>{d||g.current?.click()},[d]),k=s(()=>D([]),[]);return{inputRef:g,inputProps:{ref:g,type:"file",accept:a||void 0,multiple:f,disabled:d,tabIndex:-1,"aria-hidden":!0,className:"hidden",onChange:e=>A(e.target.files)},zoneProps:d?{}:{onDragEnter:e=>{i(e)&&(e.preventDefault(),L.current+=1,x(!0))},onDragOver:e=>{i(e)&&(e.preventDefault(),y||x(!0))},onDragLeave:e=>{i(e)&&(L.current=Math.max(0,L.current-1),0===L.current&&x(!1))},onDrop:e=>{i(e)&&(e.preventDefault(),L.current=0,x(!1),A(e.dataTransfer.files))}},pasteProps:d?{}:{onPaste:e=>{const t=function(e){const t=e.clipboardData;if(!t)return[];if(t.files&&t.files.length>0)return Array.from(t.files);const r=[];for(const e of Array.from(t.items??[]))if("file"===e.kind){const t=e.getAsFile();t&&r.push(t)}return r}(e);0!==t.length&&(e.preventDefault(),A(t))}},open:j,take:A,dragOver:y,rejections:v,clearRejections:k}}function u({rejections:e,className:t="mt-2"}){return 0===e.length?null:/* @__PURE__ */a("ul",{role:"alert",className:`${t} flex flex-col gap-0.5`,children:e.map(({file:e,message:t},r)=>/* @__PURE__ */a("li",{className:"text-xs text-red-600",children:t},`${e.name}-${r}`))})}export{u as FileIntakeAlert,o as acceptsFile,l as humanSize,c as useFileIntake};
1
+ import{DEFAULT_SHELL_STRINGS as e,useShellStrings as t}from"./chunk-QRCDQPJA.js";import{useRef as r,useState as n,useCallback as s}from"react";import{jsx as a}from"react/jsx-runtime";function o(e,t){const r=(t??"").split(",").map(e=>e.trim().toLocaleLowerCase()).filter(Boolean);if(0===r.length||r.includes("*")||r.includes("*/*"))return!0;const n=e.name.toLocaleLowerCase(),s=e.type.toLocaleLowerCase();return r.some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?s.startsWith(e.slice(0,-1)):s===e)}var l=(t,r=e.files)=>t<1024?r.bytes(t):t<1048576?r.kilobytes(Math.round(t/1024)):r.megabytes(t/1048576),i=e=>Array.from(e.dataTransfer?.types??[]).includes("Files");function c({onAccept:e,accept:a,maxSizeBytes:c,maxFiles:u,multiple:f=!0,currentCount:p=0,acceptHint:m,disabled:d=!1}){const h=t().files,g=r(null),[y,x]=n(!1),[v,D]=n([]),A=r(0),L="string"==typeof m?m:"",b=s(t=>{if(d||!t)return;const r=Array.from(t);if(0===r.length)return;const n=[],s=[];for(const e of f?r:r.slice(0,1))o(e,a)?null!=c&&e.size>c?s.push({file:e,reason:"size",message:h.tooLarge(e.name,l(e.size,h),l(c,h))}):f&&null!=u&&p+n.length>=u?s.push({file:e,reason:"count",message:h.tooMany(e.name,u)}):n.push(e):s.push({file:e,reason:"type",message:h.notAccepted(e.name,L)});D(s),n.length&&e(n),g.current&&(g.current.value="")},[d,f,a,L,c,u,p,e,h]),C=s(()=>{d||g.current?.click()},[d]),j=s(()=>D([]),[]);return{inputRef:g,inputProps:{ref:g,type:"file",accept:a||void 0,multiple:f,disabled:d,tabIndex:-1,"aria-hidden":!0,className:"hidden",onChange:e=>b(e.target.files)},zoneProps:d?{}:{onDragEnter:e=>{i(e)&&(e.preventDefault(),A.current+=1,x(!0))},onDragOver:e=>{i(e)&&(e.preventDefault(),y||x(!0))},onDragLeave:e=>{i(e)&&(A.current=Math.max(0,A.current-1),0===A.current&&x(!1))},onDrop:e=>{i(e)&&(e.preventDefault(),A.current=0,x(!1),b(e.dataTransfer.files))}},pasteProps:d?{}:{onPaste:e=>{const t=function(e){const t=e.clipboardData;if(!t)return[];if(t.files&&t.files.length>0)return Array.from(t.files);const r=[];for(const e of Array.from(t.items??[]))if("file"===e.kind){const t=e.getAsFile();t&&r.push(t)}return r}(e);0!==t.length&&(e.preventDefault(),b(t))}},open:C,take:b,dragOver:y,rejections:v,clearRejections:j}}function u({rejections:e,className:t="mt-2"}){return 0===e.length?null:/* @__PURE__ */a("ul",{role:"alert",className:`${t} flex flex-col gap-0.5`,children:e.map(({file:e,message:t},r)=>/* @__PURE__ */a("li",{className:"text-xs text-red-600",children:t},`${e.name}-${r}`))})}export{u as FileIntakeAlert,o as acceptsFile,l as humanSize,c as useFileIntake};
@@ -0,0 +1,29 @@
1
+ import{useDismissPopupsOnOpen as e}from"./chunk-UVBK6YSR.js";import{buttonClasses as t}from"./chunk-2ALIPI3D.js";import{registerModalEscapeInterceptor as n,Z_LAYERS as r}from"./chunk-FIEA5CGB.js";import{useShellStrings as o,splitAround as i}from"./chunk-QRCDQPJA.js";import{Icon as l}from"./chunk-CJHT4VTF.js";import{createContext as a,useEffect as s,useRef as c,useId as d,useContext as u,useState as m,useCallback as f}from"react";import{jsxs as h,jsx as b,Fragment as g}from"react/jsx-runtime";var p=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function v(e){return Array.from(e.querySelectorAll(p)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var y=[];function x(e){const t=y.findIndex(t=>t!==e&&e.contains(t));-1===t?y.push(e):y.splice(t,0,e)}function w(e){const t=y.lastIndexOf(e);-1!==t&&y.splice(t,1)}var N=/* @__PURE__ */new WeakSet;function k(e){return v(e)}function C(e,t){s(()=>{if(!t)return;const n=e.current;return n?(N.add(n),x(n),()=>{w(n),N.delete(n)}):void 0},[e,t])}function E(e,t){const n=y.lastIndexOf(t),r=n>0?y[n-1]:-1===n?y[y.length-1]??null:null,o=v(r??e.ownerDocument.body).filter(n=>!t.contains(n)&&!e.contains(n)),i=o.find(t=>0!==(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));return i||(r&&!N.has(r)?o[0]??null:null)}function L(e,t,n){s(()=>{if(!t)return;const r=e.current;if(!r)return;const o=document.activeElement,i=n?.current??v(r)[0]??r;i!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),i.focus();const l=e=>{if("Tab"!==e.key)return;if(y[y.length-1]!==r)return;const t=v(r);if(0===t.length)return void e.preventDefault();const n=t[0],o=t[t.length-1],i=document.activeElement;!e.shiftKey||i!==n&&r.contains(i)?e.shiftKey||i!==o&&r.contains(i)||(e.preventDefault(),n.focus()):(e.preventDefault(),o.focus())};return x(r),document.addEventListener("keydown",l,!0),()=>{w(r),document.removeEventListener("keydown",l,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&o?.focus?.()}},[e,t,n])}var P=0,j=null;function D(e){s(()=>{if(!e)return;const t=document.body;if(0===P){j={overflow:t.style.overflow,paddingRight:t.style.paddingRight};const e=window.innerWidth-document.documentElement.clientWidth;t.style.overflow="hidden",e>0&&(t.style.paddingRight=`${e}px`)}return P+=1,()=>{0===(P-=1)&&j&&(t.style.overflow=j.overflow,t.style.paddingRight=j.paddingRight,j=null)}},[e])}var I={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function T({open:t,onClose:i,title:a,description:u,role:m="dialog",children:f,footer:g,blocking:p=!1,size:v="md",initialFocus:y,"aria-label":x,"aria-labelledby":w,"aria-describedby":N,className:k=""}){const C=c(null),E=d(),P=d(),j=!p&&!g,T=d(),F=o().dialog;return e(t),L(C,t,y),D(t),s(()=>{if(t)return n(()=>(p||i(),!0),()=>C.current)},[t,p,i]),t?/* @__PURE__ */h("div",{className:"fixed inset-0",style:{zIndex:r.overlay},role:"presentation",children:[
2
+ /* @__PURE__ */b("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"}),
3
+ /* @__PURE__ */b("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:p?void 0:e=>{e.target===e.currentTarget&&i()},children:/* @__PURE__ */h("div",{ref:C,role:m,"aria-modal":"true","aria-labelledby":a?T:w,"aria-label":a||w?void 0:x,"aria-describedby":N??(u?P:f?E:void 0),className:`relative max-h-full w-full ${I[v]} overflow-y-auto overscroll-contain rounded-(--radius-card) bg-white p-6 shadow-xl ${k}`.trim(),children:[a&&/* @__PURE__ */b("h2",{id:T,className:(j?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:a}),u&&/* @__PURE__ */b("p",{id:P,className:((a?"mt-1":j?"pr-8":"")+" text-sm text-gray-500").trim(),children:u}),f&&/* @__PURE__ */b("div",{id:E,className:"mt-2 text-sm text-gray-600",children:f}),g&&/* @__PURE__ */b("div",{className:"mt-6 flex flex-wrap justify-end gap-3",children:g}),j&&/* @__PURE__ */b("button",{type:"button",onClick:i,"aria-label":F.close,className:"absolute right-3 top-3 rounded-(--radius-control) p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 rosh-focus-ring focus-visible:ring-2 focus-visible:ring-[color:var(--rosh-focus-ring-solid)]",children:/* @__PURE__ */b(l,{name:"close",className:"h-5 w-5",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true"})})]})})]}):null}var F=a(()=>Promise.resolve(!1)),W=()=>u(F),A=()=>Promise.resolve(!1),O=e=>A(e),R=()=>Promise.resolve(!1),$=e=>R(e),K=()=>Promise.resolve(null),S=e=>K(e),V={danger:{icon:"text-red-600 bg-red-100",button:t({variant:"danger"})},warning:{icon:"text-yellow-600 bg-yellow-100",button:t({variant:"warning"})},info:{icon:"text-blue-600 bg-blue-100",button:t({variant:"primary"})}},z=t({variant:"secondary"}),B=t({variant:"primary"}),G="w-full rounded-md border border-gray-300 h-8 px-3 text-sm";function J(){/* @__PURE__ */
4
+ return b(l,{name:"warning",className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function Q(){/* @__PURE__ */
5
+ return b(l,{name:"close",className:"h-5 w-5",strokeWidth:1.5,"aria-hidden":"true"})}function U({children:e}){const[t,n]=m(!1),[r,l]=m({message:""}),[a,d]=m(0),u=c(),p=c(null),v=c(0),y=c([]),x=c(null),w=c(null),N=f(e=>{p.current=e.id,u.current=e.resolve,d(e.id),l(e.options),n(!0)},[]),k=f(e=>{const t="string"==typeof e?{message:e}:e;return new Promise(e=>{const n={id:++v.current,options:t,resolve:e};null===p.current?N(n):y.current.push(n)})},[N]),[C,E]=m(!1),[L,P]=m({message:""}),[j,D]=m(""),I=c(),W=f(e=>(P(e),D(""),E(!0),new Promise(e=>{I.current=e})),[]),[O,$]=m(!1),[S,U]=m({}),[_,q]=m(""),H=c(),M=f(e=>{const t="string"==typeof e?{message:e}:e;return U(t),q(t.defaultValue??""),$(!0),new Promise(e=>{H.current=e})},[]);s(()=>{A=k,R=W,K=M},[k,W,M]);const Y=(e,t)=>{if(p.current!==e)return;const r=u.current,o=y.current.shift();o?N(o):(p.current=null,u.current=void 0,n(!1)),r?.(t)},X=e=>{E(!1),D(""),I.current?.(e)},Z=e=>{if(e){const e=_.trim();if(!e&&!S.allowEmpty)return $(!1),void H.current?.(null);$(!1),H.current?.(e)}else $(!1),H.current?.(null)},ee=r.variant||(r.confirmLabel?.toLowerCase().includes("delete")||r.message.toLowerCase().includes("delete")?"danger":"info"),te=V[ee],ne=V["warning"===L.variant?"warning":"danger"],re=L.confirmWord,oe=null==re||j===re,ie=o().dialog,[le,ae]=i(ie.typeToConfirm);/* @__PURE__ */
6
+ return h(F.Provider,{value:k,children:[e,
7
+ /* @__PURE__ */b(T,{open:t,onClose:()=>Y(a,!1),initialFocus:x,footer:/* @__PURE__ */h(g,{children:[
8
+ /* @__PURE__ */b("button",{ref:x,type:"button",onClick:()=>Y(a,!1),className:z,children:r.cancelLabel||ie.cancel}),
9
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>Y(a,!0),className:te.button,children:r.confirmLabel||ie.ok})]}),children:/* @__PURE__ */h("div",{className:"flex gap-4",children:[
10
+ /* @__PURE__ */b("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${te.icon}`,children:/* @__PURE__ */b(J,{})}),
11
+ /* @__PURE__ */h("div",{className:"flex-1",children:[
12
+ /* @__PURE__ */b("h2",{className:"text-base font-semibold text-gray-900",children:r.title||ie.confirmTitle}),
13
+ /* @__PURE__ */b("p",{className:"mt-2 text-sm text-gray-600",children:r.message})]})]})}),
14
+ /* @__PURE__ */h(T,{open:C,onClose:()=>X(!1),initialFocus:null!=re?void 0:w,footer:/* @__PURE__ */h(g,{children:[
15
+ /* @__PURE__ */b("button",{ref:w,type:"button",onClick:()=>X(!1),className:z,children:L.cancelLabel||ie.destructiveCancel}),
16
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>X(!0),disabled:!oe,className:ne.button,children:re??L.confirmLabel??ie.destructiveConfirm})]}),children:[
17
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>X(!1),"aria-label":ie.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */b(Q,{})}),
18
+ /* @__PURE__ */h("div",{className:"flex gap-4",children:[
19
+ /* @__PURE__ */b("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ne.icon}`,children:/* @__PURE__ */b(J,{})}),
20
+ /* @__PURE__ */h("div",{className:"flex-1",children:[
21
+ /* @__PURE__ */b("h2",{className:"text-base font-semibold text-gray-900 pr-6",children:L.title||ie.destructiveTitle}),
22
+ /* @__PURE__ */b("p",{className:"mt-2 text-sm text-gray-600",children:L.message}),null!=re&&/* @__PURE__ */h(g,{children:[
23
+ /* @__PURE__ */h("p",{className:"mt-3 text-sm text-gray-700",children:[le,
24
+ /* @__PURE__ */b("kbd",{className:"rounded border border-gray-300 bg-gray-50 px-1.5 py-0.5 text-xs font-bold text-red-600 font-mono",children:re}),ae]}),
25
+ /* @__PURE__ */b("input",{autoFocus:!0,type:"text",value:j,onChange:e=>D(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j===re&&X(!0)},placeholder:re,className:`mt-2 ${G} focus:border-red-500`})]})]})]})]}),
26
+ /* @__PURE__ */h(T,{open:O,onClose:()=>Z(!1),title:S.title||ie.promptTitle,footer:/* @__PURE__ */h(g,{children:[
27
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>Z(!1),className:z,children:S.cancelLabel||ie.cancel}),
28
+ /* @__PURE__ */b("button",{type:"button",onClick:()=>Z(!0),disabled:!S.allowEmpty&&!_.trim(),className:B,children:S.confirmLabel||ie.ok})]}),children:[S.message&&/* @__PURE__ */b("p",{className:"text-sm text-gray-600",children:S.message}),
29
+ /* @__PURE__ */b("input",{autoFocus:!0,type:"text",value:_,onChange:e=>q(e.target.value),onKeyDown:e=>{"Enter"===e.key?Z(!0):"Escape"===e.key&&Z(!1)},onFocus:e=>e.target.select(),placeholder:S.placeholder,className:`mt-3 ${G} focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]`})]})]})}export{U as ConfirmProvider,T as Dialog,O as confirm,$ as confirmDestructive,k as focusableIn,S as prompt,E as stopAfter,W as useConfirm,L as useFocusTrap,D as useScrollLock,C as useTabLayer};