efficient-shell 4.137.0 → 4.145.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 (176) hide show
  1. package/LICENSE +6 -17
  2. package/README.md +80 -12
  3. package/dist/Browser-24YNRTKT.js +43 -0
  4. package/dist/Calculator-LER6KUQC.js +29 -0
  5. package/dist/ConfirmDialog-GAYETRMG.js +1 -0
  6. package/dist/CurrencyConverter-Y35GFDFF.js +21 -0
  7. package/dist/Documents-7FYX2CGT.js +52 -0
  8. package/dist/Files-RZOML2N6.js +89 -0
  9. package/dist/Notepad-VVDCBDUA.js +25 -0
  10. package/dist/PdfViewer-CvLb2j_l.d.ts +40 -0
  11. package/dist/PdfViewer-ZCT3PYXU.js +1 -0
  12. package/dist/PomodoroTimer-VAM3AJOX.js +99 -0
  13. package/dist/Preview-HZ37D7QJ.js +187 -0
  14. package/dist/Sidebar-CVF7C6BO.js +23 -0
  15. package/dist/Spreadsheet-6WX3P6AB.js +37 -0
  16. package/dist/Stock-AUWI3TUX.js +16 -0
  17. package/dist/Weather-HU75TH7T.js +60 -0
  18. package/dist/WorldClock-T64MDRMJ.js +32 -0
  19. package/dist/apps/index.d.ts +3 -23
  20. package/dist/apps/index.js +1 -151
  21. package/dist/brand.css +1 -1
  22. package/dist/chunk-2RHMSFZV.js +9 -0
  23. package/dist/chunk-4FS742BM.js +1 -0
  24. package/dist/chunk-57MIENLJ.js +1 -0
  25. package/dist/chunk-7DAQ3WVP.js +106 -0
  26. package/dist/chunk-BR22X7E5.js +1 -0
  27. package/dist/chunk-BUTSU7FO.js +1 -0
  28. package/dist/chunk-CVTOZCM3.js +24 -0
  29. package/dist/chunk-D65T4H6J.js +1 -0
  30. package/dist/chunk-ESL5TDNA.js +1 -0
  31. package/dist/chunk-FBDZGO3V.js +1 -0
  32. package/dist/chunk-FHTLC7HH.js +1 -0
  33. package/dist/chunk-GDSGXDET.js +34 -0
  34. package/dist/chunk-I55UMU3R.js +6 -0
  35. package/dist/chunk-KKOHUQPF.js +1 -0
  36. package/dist/chunk-L7TEFXIS.js +69 -0
  37. package/dist/chunk-LVDRBRYU.js +1 -0
  38. package/dist/chunk-LVFMK5OQ.js +29 -0
  39. package/dist/chunk-LWLCNQY7.js +1 -0
  40. package/dist/chunk-MAIHBBWT.js +1 -0
  41. package/dist/chunk-MU5H2CDL.js +2 -0
  42. package/dist/chunk-NBBOFQPL.js +947 -0
  43. package/dist/chunk-NPJH5MD7.js +13 -0
  44. package/dist/chunk-OCSOMMY2.js +1 -0
  45. package/dist/chunk-PH3PRIFP.js +5 -0
  46. package/dist/chunk-RJ4LACFH.js +9 -0
  47. package/dist/chunk-SLCR26NK.js +4 -0
  48. package/dist/chunk-TFKB2WEB.js +19 -0
  49. package/dist/chunk-TR6PLN7W.js +1 -0
  50. package/dist/chunk-TWV42Q3K.js +1 -0
  51. package/dist/chunk-UB22J6EF.js +1 -0
  52. package/dist/chunk-UB4JIOLD.js +2 -0
  53. package/dist/chunk-V453E4KU.js +11 -0
  54. package/dist/chunk-VTVSMRFX.js +1 -0
  55. package/dist/file-intake/index.js +1 -4
  56. package/dist/{index-DVI9DMSu.d.ts → index-NhR7frRu.d.ts} +189 -17
  57. package/dist/index.d.ts +2 -2
  58. package/dist/index.js +639 -7473
  59. package/dist/map/index.d.ts +266 -13
  60. package/dist/map/index.js +22 -540
  61. package/dist/markdown/index.js +6 -184
  62. package/dist/markup/index.js +1 -135
  63. package/dist/page-tabs/index.js +21 -709
  64. package/dist/pdf/index.d.ts +9 -0
  65. package/dist/pdf/index.js +2 -0
  66. package/dist/sounds-OMHXVVQ4.js +1 -0
  67. package/dist/ui/index.d.ts +1 -1
  68. package/dist/ui/index.js +1 -19
  69. package/dist/ui.css +7 -0
  70. package/package.json +9 -3
  71. package/dist/Browser-ZNX4WFUH.js +0 -482
  72. package/dist/Browser-ZNX4WFUH.js.map +0 -1
  73. package/dist/Calculator-6FGNKOXU.js +0 -192
  74. package/dist/Calculator-6FGNKOXU.js.map +0 -1
  75. package/dist/ConfirmDialog-NPQMIGUR.js +0 -4
  76. package/dist/ConfirmDialog-NPQMIGUR.js.map +0 -1
  77. package/dist/CurrencyConverter-FF7EXRYL.js +0 -236
  78. package/dist/CurrencyConverter-FF7EXRYL.js.map +0 -1
  79. package/dist/Documents-H3R7XSBH.js +0 -441
  80. package/dist/Documents-H3R7XSBH.js.map +0 -1
  81. package/dist/Files-ZHJIAUC2.js +0 -805
  82. package/dist/Files-ZHJIAUC2.js.map +0 -1
  83. package/dist/Notepad-VE7ISWRQ.js +0 -410
  84. package/dist/Notepad-VE7ISWRQ.js.map +0 -1
  85. package/dist/PdfViewer-SQBFYAGW.js +0 -5
  86. package/dist/PdfViewer-SQBFYAGW.js.map +0 -1
  87. package/dist/PomodoroTimer-IR3WREED.js +0 -633
  88. package/dist/PomodoroTimer-IR3WREED.js.map +0 -1
  89. package/dist/Preview-DAQGRNRM.js +0 -2959
  90. package/dist/Preview-DAQGRNRM.js.map +0 -1
  91. package/dist/Sidebar-YW6H4NDJ.js +0 -291
  92. package/dist/Sidebar-YW6H4NDJ.js.map +0 -1
  93. package/dist/Spreadsheet-HOCPHJOC.js +0 -519
  94. package/dist/Spreadsheet-HOCPHJOC.js.map +0 -1
  95. package/dist/Stock-LVRQPURG.js +0 -158
  96. package/dist/Stock-LVRQPURG.js.map +0 -1
  97. package/dist/Weather-LZQGVDJL.js +0 -431
  98. package/dist/Weather-LZQGVDJL.js.map +0 -1
  99. package/dist/WorldClock-XPD7WOZT.js +0 -202
  100. package/dist/WorldClock-XPD7WOZT.js.map +0 -1
  101. package/dist/apps/index.js.map +0 -1
  102. package/dist/chunk-5O42JXQE.js +0 -26
  103. package/dist/chunk-5O42JXQE.js.map +0 -1
  104. package/dist/chunk-5RPTS3BT.js +0 -70
  105. package/dist/chunk-5RPTS3BT.js.map +0 -1
  106. package/dist/chunk-6XJEJWNJ.js +0 -61
  107. package/dist/chunk-6XJEJWNJ.js.map +0 -1
  108. package/dist/chunk-7CCHEEYC.js +0 -94
  109. package/dist/chunk-7CCHEEYC.js.map +0 -1
  110. package/dist/chunk-BE7FZOFU.js +0 -17
  111. package/dist/chunk-BE7FZOFU.js.map +0 -1
  112. package/dist/chunk-COWYSHG2.js +0 -79
  113. package/dist/chunk-COWYSHG2.js.map +0 -1
  114. package/dist/chunk-D7PYW2QS.js +0 -265
  115. package/dist/chunk-D7PYW2QS.js.map +0 -1
  116. package/dist/chunk-DVZWYWSD.js +0 -26
  117. package/dist/chunk-DVZWYWSD.js.map +0 -1
  118. package/dist/chunk-E7TB6WD2.js +0 -153
  119. package/dist/chunk-E7TB6WD2.js.map +0 -1
  120. package/dist/chunk-FIHOGVUP.js +0 -416
  121. package/dist/chunk-FIHOGVUP.js.map +0 -1
  122. package/dist/chunk-GA35NEND.js +0 -56
  123. package/dist/chunk-GA35NEND.js.map +0 -1
  124. package/dist/chunk-HUBJAUGG.js +0 -316
  125. package/dist/chunk-HUBJAUGG.js.map +0 -1
  126. package/dist/chunk-I2TAAJHS.js +0 -465
  127. package/dist/chunk-I2TAAJHS.js.map +0 -1
  128. package/dist/chunk-ICTRCKUE.js +0 -3710
  129. package/dist/chunk-ICTRCKUE.js.map +0 -1
  130. package/dist/chunk-IPXN646P.js +0 -14
  131. package/dist/chunk-IPXN646P.js.map +0 -1
  132. package/dist/chunk-IRWSRJ4K.js +0 -48
  133. package/dist/chunk-IRWSRJ4K.js.map +0 -1
  134. package/dist/chunk-JOPU6WPY.js +0 -504
  135. package/dist/chunk-JOPU6WPY.js.map +0 -1
  136. package/dist/chunk-MGGY74RY.js +0 -14
  137. package/dist/chunk-MGGY74RY.js.map +0 -1
  138. package/dist/chunk-PVPPAWVM.js +0 -46
  139. package/dist/chunk-PVPPAWVM.js.map +0 -1
  140. package/dist/chunk-R7QGMK6N.js +0 -102
  141. package/dist/chunk-R7QGMK6N.js.map +0 -1
  142. package/dist/chunk-RT6DSB5Y.js +0 -143
  143. package/dist/chunk-RT6DSB5Y.js.map +0 -1
  144. package/dist/chunk-TRCWINHF.js +0 -105
  145. package/dist/chunk-TRCWINHF.js.map +0 -1
  146. package/dist/chunk-TW7LPMVR.js +0 -16
  147. package/dist/chunk-TW7LPMVR.js.map +0 -1
  148. package/dist/chunk-UTYKLGGT.js +0 -195
  149. package/dist/chunk-UTYKLGGT.js.map +0 -1
  150. package/dist/chunk-VNJJCH5A.js +0 -822
  151. package/dist/chunk-VNJJCH5A.js.map +0 -1
  152. package/dist/chunk-XJHZWSKV.js +0 -1103
  153. package/dist/chunk-XJHZWSKV.js.map +0 -1
  154. package/dist/chunk-Y3GYJ7YR.js +0 -549
  155. package/dist/chunk-Y3GYJ7YR.js.map +0 -1
  156. package/dist/chunk-YA4EE7ST.js +0 -14107
  157. package/dist/chunk-YA4EE7ST.js.map +0 -1
  158. package/dist/chunk-YDHXWCCJ.js +0 -145
  159. package/dist/chunk-YDHXWCCJ.js.map +0 -1
  160. package/dist/chunk-YE6GUDGP.js +0 -548
  161. package/dist/chunk-YE6GUDGP.js.map +0 -1
  162. package/dist/chunk-YNKK7NE3.js +0 -171
  163. package/dist/chunk-YNKK7NE3.js.map +0 -1
  164. package/dist/chunk-YPO6RDMX.js +0 -20
  165. package/dist/chunk-YPO6RDMX.js.map +0 -1
  166. package/dist/chunk-ZS7PMGUW.js +0 -7
  167. package/dist/chunk-ZS7PMGUW.js.map +0 -1
  168. package/dist/file-intake/index.js.map +0 -1
  169. package/dist/index.js.map +0 -1
  170. package/dist/map/index.js.map +0 -1
  171. package/dist/markdown/index.js.map +0 -1
  172. package/dist/markup/index.js.map +0 -1
  173. package/dist/page-tabs/index.js.map +0 -1
  174. package/dist/sounds-NT4DEZGD.js +0 -3
  175. package/dist/sounds-NT4DEZGD.js.map +0 -1
  176. package/dist/ui/index.js.map +0 -1
@@ -0,0 +1,69 @@
1
+ import{toast_default as e}from"./chunk-KKOHUQPF.js";import{forwardRef as t,useRef as r,useState as n,useMemo as o,useEffect as i,useImperativeHandle as a}from"react";import{jsx as l,jsxs as s,Fragment as c}from"react/jsx-runtime";var d=["#ef4444","#f97316","#eab308","#22c55e","#3b82f6","#8b5cf6","#000000","#ffffff"],h=[{id:"system",label:"System",css:"-apple-system, system-ui, sans-serif"},{id:"serif",label:"Serif",css:'Georgia, "Times New Roman", serif'},{id:"mono",label:"Mono",css:'ui-monospace, "SF Mono", Menlo, monospace'},{id:"cursive",label:"Cursive",css:'"Brush Script MT", "Comic Sans MS", cursive'}],u=()=>Math.random().toString(36).slice(2,9),p=t(function({src:t,filename:p,onApply:x,onCancel:m},M){const N=r(null),L=r(null),D=r(null),z=r(null),[P,E]=n("select"),[$,I]=n(d[0]),[W,B]=n(4),[S,R]=n(24),[j,A]=n(h[0].id),[T,F]=n(!0),[U,H]=n(!1),[K,O]=n(!1),[Z,V]=n(null),[X,q]=n(null),[G,Y]=n(6),[_,Q]=n(12),[J,ee]=n([]),[te,re]=n(null),[ne,oe]=n(null),[ie,ae]=n(null),[le,se]=n(1),[ce,de]=n(null),[he,ue]=n(null),[pe,ye]=n(null),xe=r(null),[me,ge]=n(!1),we=o(()=>ie?{w:ie.w*le,h:ie.h*le}:null,[ie,le]),fe=we&&ne?we.w/ne.w:1,be=o(()=>J.find(e=>e.id===te)??null,[J,te]);i(()=>{"select"===P&&be&&("color"in be&&I(be.color),"stroke"in be&&B(be.stroke),"rect"===be.type&&Q(be.radius),"text"===be.type&&(R(be.size),A(be.font),F(be.bold),H(be.italic),O(be.underline),V(be.borderColor),q(be.background),Y(be.padding)))},[te]),i(()=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{z.current=r,oe({w:r.naturalWidth,h:r.naturalHeight}),ee([]),re(null)},r.onerror=()=>e.error("Failed to load image"),r.src=t},[t]),i(()=>{if(!ne)return;const e=()=>{const e=N.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=ne.w/ne.h;let i=ne.w,a=ne.h;i>r&&(i=r,a=i/o),a>n&&(a=n,i=a*o),ae({w:i,h:a})};e();const t=new ResizeObserver(e);return N.current&&t.observe(N.current),()=>t.disconnect()},[ne]);const ve=o(()=>J.filter(e=>"mosaic"===e.type),[J]);i(()=>{const e=z.current,t=L.current;if(!e||!t||!ne)return;t.width=ne.w,t.height=ne.h;const r=t.getContext("2d");r.drawImage(e,0,0);for(const e of ve)C(r,e)},[ne,ve,ie]);const ke=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}},Me=e=>{xe.current=e,ge(!0)};i(()=>{if(!me)return;const e=e=>{const t=xe.current;if(!t)return;const r=ke(e);if("draw"===t.kind)de(f(P,t.start,r,$,W,_));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),de({id:"",type:"draw",points:t.points.slice(),color:$,stroke:W}))}else if("crop"===t.kind)ye(k(t.start,r));else if("move"===t.kind){const e=r.x-t.start.x,n=r.y-t.start.y;ee(r=>r.map(r=>r.id===t.id?b(t.original,e,n):r))}else"resize"===t.kind&&ee(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,s=i,c=o,d=a;"nw"===t&&(l=r.x,s=r.y);"ne"===t&&(c=r.x,s=r.y);"se"===t&&(c=r.x,d=r.y);"sw"===t&&(l=r.x,d=r.y);const h=k({x:l,y:s},{x:c,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=xe.current;if(xe.current=null,ge(!1),"draw"===e?.kind)de(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:u()};return ee(e=>[...e,r]),re(r.id),E("select"),null});else if("pen"===e?.kind){if(e.points.length<2)return void de(null);const t={id:u(),type:"draw",points:e.points,color:$,stroke:W};ee(e=>[...e,t]),re(t.id),E("select"),de(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)}},[me,P,$,W,_]);i(()=>{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(te&&("Delete"===e.key||"Backspace"===e.key?(e.preventDefault(),ee(e=>e.filter(e=>e.id!==te)),re(null)):"Escape"===e.key&&re(null))):(e.preventDefault(),ee(e=>e.slice(0,-1)),void re(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[te]);const Ce=e=>{const t=!{bold:T,italic:U,underline:K}[e];"bold"===e&&F(t),"italic"===e&&H(t),"underline"===e&&O(t),te&&ee(r=>r.map(r=>r.id===te&&"text"===r.type?{...r,[e]:t}:r))},Ne=e=>{V(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,borderColor:e}:t))},Le=e=>{q(e),te&&ee(t=>t.map(t=>t.id===te&&"text"===t.type?{...t,background:e}:t))},De=e=>{if(!he)return;const t=e??he.value;if(!t.trim())return he.editingId&&ee(e=>e.filter(e=>e.id!==he.editingId)),void ue(null);if(he.editingId)ee(e=>e.map(e=>e.id===he.editingId&&"text"===e.type?{...e,text:t}:e));else{const e={id:u(),type:"text",x:he.x,y:he.y,text:t,color:$,size:S,font:j,bold:T,italic:U,underline:K,borderColor:Z,background:X,padding:G};ee(t=>[...t,e]),re(e.id),E("select")}ue(null)},ze=async()=>{const e=L.current,t=D.current;if(!e||!t||!ne)return null;const r=document.createElement("canvas");r.width=ne.w,r.height=ne.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),s=new Image;return await new Promise(e=>{s.onload=()=>e(),s.onerror=()=>e(),s.src=l}),n.drawImage(s,0,0,ne.w,ne.h),URL.revokeObjectURL(l),r};a(M,()=>({save:async()=>{const t=await ze();t&&t.toBlob(t=>{if(!t)return void e.error("Failed to export");const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r;const o=p.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("Clipboard images not supported in this browser");const t=await ze();t&&t.toBlob(async t=>{if(t)try{await navigator.clipboard.write([new ClipboardItem({"image/png":t})]),e.success("Copied to clipboard")}catch{e.error("Copy failed (clipboard permission?)")}else e.error("Failed to copy")},"image/png")}}),[ne,p]);const Pe=o(()=>[{id:"select",label:"Select / Move",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 3l7 17 2-7 7-2L5 3z"})})},{id:"draw",label:"Pen / Draw",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("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:"Rectangle",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("rect",{x:"4",y:"6",width:"16",height:"12",rx:"3"})})},{id:"circle",label:"Ellipse",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6"})})},{id:"arrow",label:"Arrow",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 19L19 5m0 0h-7m7 0v7"})})},{id:"mosaic",label:"Mosaic",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"})})},{id:"text",label:"Text",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M12 6v14M9 20h6"})})},{id:"crop",label:"Crop",icon:/* @__PURE__ */l("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */l("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 2v15a1 1 0 001 1h15M2 6h15a1 1 0 011 1v15"})})}],[]),Ee=e=>"p-1.5 rounded transition-colors "+(e?"bg-blue-500 text-white":"text-gray-700 hover:bg-gray-200"),$e=be?.type??("select"===P?null:P),Ie="rect"===$e||"circle"===$e||"arrow"===$e||"draw"===$e,We="rect"===$e,Be="text"===$e;/* @__PURE__ */
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:[Pe.map(e=>/* @__PURE__ */l("button",{onClick:()=>{E(e.id),re(null)},title:e.label,className:Ee(P===e.id),children:e.icon},e.id)),
4
+ /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
5
+ /* @__PURE__ */l("div",{className:"flex items-center gap-1",children:d.map(e=>/* @__PURE__ */l("button",{onClick:()=>(e=>{I(e),te&&ee(t=>t.map(t=>t.id!==te||"mosaic"===t.type?t:{...t,color:e}))})(e),title:e,className:"h-5 w-5 rounded-full border "+($===e?"ring-2 ring-blue-500 ring-offset-1":"border-gray-300"),style:{background:e}},e))}),Ie&&/* @__PURE__ */s(c,{children:[
6
+ /* @__PURE__ */l("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:[
8
+ /* @__PURE__ */l("span",{children:"Weight"}),
9
+ /* @__PURE__ */l("input",{type:"range",min:1,max:20,step:1,value:W,onChange:e=>{return t=Number(e.target.value),B(t),void(te&&ee(e=>e.map(e=>e.id!==te?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__ */l("span",{className:"tabular-nums w-5 text-right",children:W})]})]}),We&&/* @__PURE__ */s(c,{children:[
11
+ /* @__PURE__ */l("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:[
13
+ /* @__PURE__ */l("span",{children:"Radius"}),
14
+ /* @__PURE__ */l("input",{type:"range",min:0,max:48,step:1,value:_,onChange:e=>{return t=Number(e.target.value),Q(t),void(te&&ee(e=>e.map(e=>e.id===te&&"rect"===e.type?{...e,radius:t}:e)));var t},className:"w-16 accent-blue-500"}),
15
+ /* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:_})]})]}),Be&&/* @__PURE__ */s(c,{children:[
16
+ /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
17
+ /* @__PURE__ */l("select",{value:j,onChange:e=>{return t=e.target.value,A(t),void(te&&ee(e=>e.map(e=>e.id===te&&"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:h.map(e=>/* @__PURE__ */l("option",{value:e.id,children:e.label},e.id))}),
18
+ /* @__PURE__ */l("button",{onClick:()=>Ce("bold"),className:Ee(T),title:"Bold",children:/* @__PURE__ */l("span",{className:"font-bold",children:"B"})}),
19
+ /* @__PURE__ */l("button",{onClick:()=>Ce("italic"),className:Ee(U),title:"Italic",children:/* @__PURE__ */l("span",{className:"italic",children:"I"})}),
20
+ /* @__PURE__ */l("button",{onClick:()=>Ce("underline"),className:Ee(K),title:"Underline",children:/* @__PURE__ */l("span",{className:"underline",children:"U"})}),
21
+ /* @__PURE__ */s("label",{className:"flex items-center gap-1.5 text-gray-600",children:[
22
+ /* @__PURE__ */l("span",{children:"Size"}),
23
+ /* @__PURE__ */l("input",{type:"range",min:10,max:96,step:1,value:S,onChange:e=>{return t=Number(e.target.value),R(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,size:t}:e)));var t},className:"w-16 accent-blue-500"}),
24
+ /* @__PURE__ */l("span",{className:"tabular-nums w-7 text-right",children:S})]}),
25
+ /* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
26
+ /* @__PURE__ */l("span",{children:"Border"}),Z?/* @__PURE__ */s(c,{children:[
27
+ /* @__PURE__ */l("input",{type:"color",value:Z,onChange:e=>Ne(e.target.value),title:"Text-box border color",className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
28
+ /* @__PURE__ */l("button",{onClick:()=>Ne(null),title:"Remove border",className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */l("button",{onClick:()=>Ne($),title:"Add a border",className:"px-1.5 py-0.5 rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:"Add"})]}),
29
+ /* @__PURE__ */s("label",{className:"flex items-center gap-1 text-gray-600",children:[
30
+ /* @__PURE__ */l("span",{children:"Fill"}),X?/* @__PURE__ */s(c,{children:[
31
+ /* @__PURE__ */l("input",{type:"color",value:X,onChange:e=>Le(e.target.value),title:"Text-box background color",className:"h-5 w-6 rounded border border-gray-300 bg-white p-0 cursor-pointer"}),
32
+ /* @__PURE__ */l("button",{onClick:()=>Le(null),title:"Remove fill",className:"px-0.5 text-gray-400 hover:text-gray-700",children:"✕"})]}):/* @__PURE__ */l("button",{onClick:()=>Le("#ffffff"),title:"Add a background fill",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:[
34
+ /* @__PURE__ */l("span",{children:"Pad"}),
35
+ /* @__PURE__ */l("input",{type:"range",min:0,max:40,step:1,value:G,onChange:e=>{return t=Number(e.target.value),Y(t),void(te&&ee(e=>e.map(e=>e.id===te&&"text"===e.type?{...e,padding:t}:e)));var t},className:"w-14 accent-blue-500"}),
36
+ /* @__PURE__ */l("span",{className:"tabular-nums w-6 text-right",children:G})]})]}),
37
+ /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
38
+ /* @__PURE__ */l("button",{onClick:()=>se(e=>Math.max(.25,Math.round(100*(e-.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:"Zoom out",children:"−"}),
39
+ /* @__PURE__ */s("span",{className:"text-gray-600 tabular-nums w-10 text-center",children:[Math.round(100*le),"%"]}),
40
+ /* @__PURE__ */l("button",{onClick:()=>se(e=>Math.min(4,Math.round(100*(e+.25))/100)),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:"Zoom in",children:"+"}),
41
+ /* @__PURE__ */l("button",{onClick:()=>se(1),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",title:"Fit to area",children:"Fit"}),
42
+ /* @__PURE__ */l("div",{className:"h-5 w-px bg-gray-300 mx-1"}),
43
+ /* @__PURE__ */l("button",{onClick:()=>{ee(e=>e.slice(0,-1)),re(null)},disabled:0===J.length,className:"px-2 py-1 rounded hover:bg-gray-200 disabled:opacity-30 text-gray-700",children:"Undo"}),
44
+ /* @__PURE__ */s("div",{className:"ml-auto flex items-center gap-2",children:[pe&&/* @__PURE__ */s(c,{children:[
45
+ /* @__PURE__ */l("button",{onClick:()=>{if(!pe||!z.current||!ne)return;const e=pe,t=document.createElement("canvas");t.width=Math.round(e.w),t.height=Math.round(e.h);const r=t.getContext("2d"),n=document.createElement("canvas");n.width=ne.w,n.height=ne.h;const o=n.getContext("2d");o.drawImage(z.current,0,0);for(const e of ve)C(o,e);r.drawImage(n,e.x,e.y,e.w,e.h,0,0,e.w,e.h);const i=new Image;i.onload=()=>{z.current=i,oe({w:i.naturalWidth,h:i.naturalHeight}),ee(t=>t.filter(e=>"mosaic"!==e.type).map(t=>b(t,-e.x,-e.y)).filter(e=>function(e,t,r){const n=v(e);return n.x+n.w>0&&n.y+n.h>0&&n.x<t&&n.y<r}(e,i.naturalWidth,i.naturalHeight))),ye(null)},i.src=t.toDataURL("image/png")},className:"px-2 py-1 rounded bg-blue-500 text-white hover:bg-blue-600",children:"Apply Crop"}),
46
+ /* @__PURE__ */l("button",{onClick:()=>ye(null),className:"px-2 py-1 rounded hover:bg-gray-200 text-gray-700",children:"Cancel"})]}),x&&!pe&&/* @__PURE__ */s(c,{children:[m&&/* @__PURE__ */l("button",{onClick:m,className:"px-3 py-1 rounded hover:bg-gray-200 text-gray-700 text-xs font-medium",children:"Cancel"}),
47
+ /* @__PURE__ */l("button",{onClick:async()=>{const t=await ze();t?t.toBlob(t=>{t?x(t):e.error("Failed to export")},"image/png"):e.error("Failed to export")},className:"px-3 py-1 rounded bg-blue-500 text-white hover:bg-blue-600 text-xs font-medium",children:"Apply"})]})]})]}),
48
+ /* @__PURE__ */l("div",{ref:N,className:"flex-1 overflow-auto bg-gray-200 flex items-center justify-center p-4 relative",children:we&&ne&&/* @__PURE__ */s("div",{className:"relative shadow-lg rounded overflow-hidden bg-white shrink-0",style:{width:we.w,height:we.h},children:[
49
+ /* @__PURE__ */l("canvas",{ref:L,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block"}}),
50
+ /* @__PURE__ */s("svg",{ref:D,viewBox:`0 0 ${ne.w} ${ne.h}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",touchAction:"none",cursor:"select"===P?"default":"text"===P?"text":"crosshair"},onPointerDown:e=>{if("select"===P)return void re(null);if("text"===P){if(he)return void De();const t=ke(e);return void ue({x:t.x,y:t.y,value:""})}const t=ke(e);if("crop"!==P){if("draw"===P)return Me({kind:"pen",points:[t]}),void de({id:"",type:"draw",points:[t],color:$,stroke:W});de(f(P,t,t,$,W,_)),Me({kind:"draw",start:t})}else Me({kind:"crop",start:t})},children:[J.map(e=>/* @__PURE__ */l(y,{anno:e,selected:te===e.id,zoom:le,onPointerDown:t=>((e,t)=>{"select"===P&&(e.stopPropagation(),re(t.id),Me({kind:"move",id:t.id,start:ke(e),original:t}))})(t,e),onDoubleClick:()=>{var t;"text"===(t=e).type&&ue({x:t.x,y:t.y,value:t.text,editingId:t.id})},onHandlePointerDown:(t,r)=>((e,t,r)=>{e.stopPropagation(),Me({kind:"resize",id:t.id,corner:r,start:ke(e),original:t})})(t,e,r)},e.id)),ce&&/* @__PURE__ */l(y,{anno:{...ce,id:"__preview"},preview:!0}),pe&&/* @__PURE__ */l(g,{rect:pe,imageSize:ne})]}),he&&/* @__PURE__ */l(w,{pendingText:he,color:$,size:S,font:h.find(e=>e.id===j)?.css??h[0].css,bold:T,italic:U,underline:K,borderColor:Z,background:X,padding:G,scale:fe,onChange:e=>ue({...he,value:e}),onCommit:De,onCancel:()=>ue(null)})]})}),
51
+ /* @__PURE__ */l("div",{className:"px-3 py-1.5 border-t border-gray-200 bg-white text-[11px] text-gray-500 shrink-0",children:"select"===P?te?"Drag to move. Drag a corner to resize. Delete / Backspace removes. Click outside to deselect.":"Tap a shape to select. Double-click text to edit.":"text"===P?"Click to drop a text label.":"crop"===P?"Drag a rectangle to set the crop region.":"draw"===P?"Drag to draw freehand.":"Drag on the image to draw."})]})});function y({anno:e,selected:t,preview:r,zoom:n=1,onPointerDown:o,onDoubleClick:i,onHandlePointerDown:a}){const d=v(e),u=o?{onPointerDown:o,pointerEvents:"all",style:{cursor:"move"}}:{},p=i?{onDoubleClick:i}:{};let y;if("rect"===e.type)y=/* @__PURE__ */l("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",...u});else if("circle"===e.type)y=/* @__PURE__ */l("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,...u});else if("arrow"===e.type)y=/* @__PURE__ */l(m,{anno:e,interactive:u});else if("draw"===e.type)y=/* @__PURE__ */l("path",{d:M(e.points),fill:"none",stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round",strokeLinejoin:"round",...u});else if("mosaic"===e.type)y=/* @__PURE__ */l("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,...u});else{const t=h.find(t=>t.id===e.font)?.css??h[0].css,r=e.padding??0,n=!!e.borderColor||!!e.background,o=v(e),i=e.borderColor?Math.max(1,Math.round(e.size/12)):0;y=/* @__PURE__ */s("g",{...u,...p,children:[n&&/* @__PURE__ */l("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
+ /* @__PURE__ */l("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__ */l("tspan",{x:e.x,dy:0===r?0:1.2*e.size,children:t},r))})]})}/* @__PURE__ */
53
+ return s("g",{children:[y,t&&!r&&/* @__PURE__ */s(c,{children:[
54
+ /* @__PURE__ */l("rect",{"data-chrome":"selection",x:d.x-4,y:d.y-4,width:d.w+8,height:d.h+8,fill:"none",stroke:"#3b82f6",strokeWidth:2/n,strokeDasharray:`${6/n},${4/n}`,pointerEvents:"none"}),a&&/* @__PURE__ */l(x,{anno:e,zoom:n,onHandlePointerDown:a})]})]})}function x({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__ */
55
+ return s(c,{children:[
56
+ /* @__PURE__ */l("circle",{cx:e.x1,cy:e.y1,r:n,...i("grab"),onPointerDown:e=>r(e,"start")}),
57
+ /* @__PURE__ */l("circle",{cx:e.x2,cy:e.y2,r:n,...i("grab"),onPointerDown:e=>r(e,"end")})]});if("text"===e.type||"draw"===e.type)return null;const a=e.x,d=e.y,h=e.w,u=e.h;/* @__PURE__ */
58
+ return s(c,{children:[
59
+ /* @__PURE__ */l("circle",{cx:a,cy:d,r:n,...i("nwse-resize"),onPointerDown:e=>r(e,"nw")}),
60
+ /* @__PURE__ */l("circle",{cx:a+h,cy:d,r:n,...i("nesw-resize"),onPointerDown:e=>r(e,"ne")}),
61
+ /* @__PURE__ */l("circle",{cx:a+h,cy:d+u,r:n,...i("nwse-resize"),onPointerDown:e=>r(e,"se")}),
62
+ /* @__PURE__ */l("circle",{cx:a,cy:d+u,r:n,...i("nesw-resize"),onPointerDown:e=>r(e,"sw")})]})}function m({anno:e,interactive:t}){const r=Math.max(12,4*e.stroke),n=Math.atan2(e.y2-e.y1,e.x2-e.x1),o=n+Math.PI-Math.PI/7,i=n+Math.PI+Math.PI/7,a=`M${e.x2},${e.y2} L${e.x2+r*Math.cos(o)},${e.y2+r*Math.sin(o)} L${e.x2+r*Math.cos(i)},${e.y2+r*Math.sin(i)} Z`;/* @__PURE__ */
63
+ return s("g",{...t,children:[
64
+ /* @__PURE__ */l("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.color,strokeWidth:e.stroke,strokeLinecap:"round"}),
65
+ /* @__PURE__ */l("path",{d:a,fill:e.color})]})}function g({rect:e,imageSize:t}){/* @__PURE__ */
66
+ return s("g",{pointerEvents:"none",children:[
67
+ /* @__PURE__ */l("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
+ /* @__PURE__ */l("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"8,6"})]})}function w({pendingText:e,color:t,size:n,font:o,bold:a,italic:s,underline:c,borderColor:d,background:h,padding:u,scale:p,onChange:y,onCommit:x,onCancel:m}){const g=r(null);i(()=>{const e=requestAnimationFrame(()=>{g.current?.focus(),g.current?.select?.()});return()=>cancelAnimationFrame(e)},[]);const w=()=>x(g.current?.value),f=d?Math.max(1,Math.round(n/12)):0;/* @__PURE__ */
69
+ return l("div",{style:{position:"absolute",left:e.x*p+"px",top:e.y*p+"px",transform:"translateY(-2px)",zIndex:5},onPointerDown:e=>e.stopPropagation(),children:/* @__PURE__ */l("textarea",{ref:g,value:e.value,onChange:e=>y(e.target.value),onBlur:w,onKeyDown:e=>{"Escape"===e.key?(e.preventDefault(),m()):"Enter"!==e.key||e.shiftKey||(e.preventDefault(),w())},placeholder:"Type then Enter…",rows:1,className:"outline-none resize-none shadow-md",style:{color:t,fontSize:n*p+"px",fontFamily:o,fontWeight:a?700:400,fontStyle:s?"italic":"normal",textDecoration:c?"underline":void 0,minWidth:80,padding:u*p+"px",borderRadius:Math.min(8,u)*p+"px",border:d?`${f*p}px solid ${d}`:"1px dashed #60a5fa",background:h??"rgba(255,255,255,0.95)"}})})}function f(e,t,r,n,o,i){if("rect"===e){const e=k(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=k(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=k(t,r);return{id:"",type:"mosaic",x:e.x,y:e.y,w:e.w,h:e.h}}return null}function b(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 v(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 k(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 M(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,s=0,c=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],s+=a.data[d+3],c++}r=Math.round(r/c),n=Math.round(n/c),l=Math.round(l/c),s=Math.round(s/c);for(let i=0;i<h;i++)for(let c=0;c<d;c++){const d=4*((e+i)*o+(t+c));a.data[d]=r,a.data[d+1]=n,a.data[d+2]=l,a.data[d+3]=s}}e.putImageData(a,r,n)}export{p as ImageAnnotator_default};
@@ -0,0 +1 @@
1
+ import{useShellAuth as o}from"./chunk-UB4JIOLD.js";var r={};function n(o){r=o}function t(){const{hasAnyPerm:n}=o();return{user:r.user,logout:r.logout??(()=>{}),hasAnyPerm:n}}export{n as setShellAuthBridge,t as useAuth};
@@ -0,0 +1,29 @@
1
+ import{useShellStrings as e,splitAround as t}from"./chunk-TR6PLN7W.js";import{createContext as n,useEffect as r,useRef as o,useId as i,useContext as l,useState as a,useCallback as s,useLayoutEffect as d}from"react";import{jsxs as c,jsx as u,Fragment as m}from"react/jsx-runtime";var f=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function h(e){return Array.from(e.querySelectorAll(f)).filter(e=>null!==e.offsetParent||e===document.activeElement)}var b=[];function g(e,t,n){r(()=>{if(!t)return;const r=e.current;if(!r)return;const o=document.activeElement,i=n?.current??h(r)[0]??r;i!==r||r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),i.focus();const l=e=>{if("Tab"!==e.key)return;if(b[b.length-1]!==r)return;const t=h(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 function(e){const t=b.findIndex(t=>t!==e&&e.contains(t));-1===t?b.push(e):b.splice(t,0,e)}(r),document.addEventListener("keydown",l,!0),()=>{!function(e){const t=b.lastIndexOf(e);-1!==t&&b.splice(t,1)}(r),document.removeEventListener("keydown",l,!0),(r.contains(document.activeElement)||document.activeElement===document.body)&&o?.focus?.()}},[e,t,n])}var p=0,v=null;function y(e){r(()=>{if(!e)return;const t=document.body;if(0===p){v={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)&&v&&(t.style.overflow=v.overflow,t.style.paddingRight=v.paddingRight,v=null)}},[e])}var x=/* @__PURE__ */new Set,w=null;function k(e){return x.add(e),function(){if(w||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&N(e)&&(e.preventDefault(),e.stopPropagation())};document.addEventListener("keydown",e,!0),w=()=>document.removeEventListener("keydown",e,!0)}(),()=>{x.delete(e),0===x.size&&w&&(w(),w=null)}}function N(e){const t=Array.from(x);for(let n=t.length-1;n>=0;n--)try{if(t[n](e))return!0}catch{}return!1}var L="react-os-shell:overlay-open";function C(){"undefined"!=typeof window&&window.dispatchEvent(new Event(L))}function E(e){return"undefined"==typeof window?()=>{}:(window.addEventListener(L,e),()=>window.removeEventListener(L,e))}var P="undefined"==typeof document?r:d;function j(e){P(()=>{e&&C()},[e])}var W={window:50,windowStep:10,menu:400,pinnedWindow:999,overlay:9999,popup:1e4},T={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-4xl"};function $({open:t,onClose:n,title:l,description:a,role:s="dialog",children:d,footer:m,blocking:f=!1,size:h="md",initialFocus:b,"aria-label":p,"aria-labelledby":v,"aria-describedby":x,className:w=""}){const N=o(null),L=i(),C=i(),E=!f&&!m,P=i(),$=e().dialog;return j(t),g(N,t,b),y(t),r(()=>{if(t)return k(()=>(f||n(),!0))},[t,f,n]),t?/* @__PURE__ */c("div",{className:"fixed inset-0",style:{zIndex:W.overlay},role:"presentation",children:[
2
+ /* @__PURE__ */u("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"}),
3
+ /* @__PURE__ */u("div",{className:"fixed inset-0 flex items-center justify-center p-4",onClick:f?void 0:e=>{e.target===e.currentTarget&&n()},children:/* @__PURE__ */c("div",{ref:N,role:s,"aria-modal":"true","aria-labelledby":l?P:v,"aria-label":l||v?void 0:p,"aria-describedby":x??(a?C:d?L:void 0),className:`relative w-full ${T[h]} rounded-lg bg-white p-6 shadow-xl ${w}`.trim(),children:[l&&/* @__PURE__ */u("h2",{id:P,className:(E?"pr-8 ":"")+"text-base font-semibold text-gray-900",children:l}),a&&/* @__PURE__ */u("p",{id:C,className:((l?"mt-1":E?"pr-8":"")+" text-sm text-gray-500").trim(),children:a}),d&&/* @__PURE__ */u("div",{id:L,className:"mt-2 text-sm text-gray-600",children:d}),m&&/* @__PURE__ */u("div",{className:"mt-6 flex justify-end gap-3",children:m}),E&&/* @__PURE__ */u("button",{type:"button",onClick:n,"aria-label":$.close,className:"absolute right-3 top-3 rounded-md 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__ */u("svg",{className:"h-5 w-5",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:/* @__PURE__ */u("path",{d:"M6 6l8 8M14 6l-8 8"})})})]})})]}):null}var D=n(()=>Promise.resolve(!1)),F=()=>l(D),M=()=>Promise.resolve(!1),R=e=>M(e),z=()=>Promise.resolve(!1),A=e=>z(e),K=()=>Promise.resolve(null),B=e=>K(e),I={danger:{icon:"text-red-600 bg-red-100",button:"bg-red-600 hover:bg-red-700 text-white"},warning:{icon:"text-yellow-600 bg-yellow-100",button:"bg-yellow-600 hover:bg-yellow-700 text-white"},info:{icon:"text-blue-600 bg-blue-100",button:"bg-blue-600 hover:bg-blue-700 text-white"}},S="bg-white text-gray-700 border border-gray-300 px-4 py-2 text-sm font-medium rounded-lg hover:bg-gray-50";function q(){/* @__PURE__ */
4
+ return u("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */u("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})})}function H(){/* @__PURE__ */
5
+ return u("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,"aria-hidden":"true",children:/* @__PURE__ */u("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function O({children:n}){const[i,l]=a(!1),[d,f]=a({message:""}),[h,b]=a(0),g=o(),p=o(null),v=o(0),y=o([]),x=o(null),w=o(null),k=s(e=>{p.current=e.id,g.current=e.resolve,b(e.id),f(e.options),l(!0)},[]),N=s(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?k(n):y.current.push(n)})},[k]),[L,C]=a(!1),[E,P]=a({message:""}),[j,W]=a(""),T=o(),F=s(e=>(P(e),W(""),C(!0),new Promise(e=>{T.current=e})),[]),[R,A]=a(!1),[B,O]=a({}),[V,G]=a(""),J=o(),Q=s(e=>{const t="string"==typeof e?{message:e}:e;return O(t),G(t.defaultValue??""),A(!0),new Promise(e=>{J.current=e})},[]);r(()=>{M=N,z=F,K=Q},[N,F,Q]);const U=(e,t)=>{if(p.current!==e)return;const n=g.current,r=y.current.shift();r?k(r):(p.current=null,g.current=void 0,l(!1)),n?.(t)},X=e=>{C(!1),W(""),T.current?.(e)},Y=e=>{if(e){const e=V.trim();if(!e&&!B.allowEmpty)return A(!1),void J.current?.(null);A(!1),J.current?.(e)}else A(!1),J.current?.(null)},Z=d.variant||(d.confirmLabel?.toLowerCase().includes("delete")||d.message.toLowerCase().includes("delete")?"danger":"info"),_=I[Z],ee=I["warning"===E.variant?"warning":"danger"],te=E.confirmWord,ne=null==te||j===te,re=e().dialog,[oe,ie]=t(re.typeToConfirm);/* @__PURE__ */
6
+ return c(D.Provider,{value:N,children:[n,
7
+ /* @__PURE__ */u($,{open:i,onClose:()=>U(h,!1),initialFocus:x,footer:/* @__PURE__ */c(m,{children:[
8
+ /* @__PURE__ */u("button",{ref:x,type:"button",onClick:()=>U(h,!1),className:S,children:d.cancelLabel||re.cancel}),
9
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>U(h,!0),className:`px-4 py-2 text-sm font-medium rounded-lg ${_.button}`,children:d.confirmLabel||re.ok})]}),children:/* @__PURE__ */c("div",{className:"flex gap-4",children:[
10
+ /* @__PURE__ */u("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${_.icon}`,children:/* @__PURE__ */u(q,{})}),
11
+ /* @__PURE__ */c("div",{className:"flex-1",children:[
12
+ /* @__PURE__ */u("h2",{className:"text-base font-semibold text-gray-900",children:d.title||re.confirmTitle}),
13
+ /* @__PURE__ */u("p",{className:"mt-2 text-sm text-gray-600",children:d.message})]})]})}),
14
+ /* @__PURE__ */c($,{open:L,onClose:()=>X(!1),initialFocus:null!=te?void 0:w,footer:/* @__PURE__ */c(m,{children:[
15
+ /* @__PURE__ */u("button",{ref:w,type:"button",onClick:()=>X(!1),className:S,children:E.cancelLabel||re.destructiveCancel}),
16
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>X(!0),disabled:!ne,className:`px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40 ${ee.button}`,children:te??E.confirmLabel??re.destructiveConfirm})]}),children:[
17
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>X(!1),"aria-label":re.close,className:"absolute right-4 top-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:/* @__PURE__ */u(H,{})}),
18
+ /* @__PURE__ */c("div",{className:"flex gap-4",children:[
19
+ /* @__PURE__ */u("div",{className:`shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${ee.icon}`,children:/* @__PURE__ */u(q,{})}),
20
+ /* @__PURE__ */c("div",{className:"flex-1",children:[
21
+ /* @__PURE__ */u("h2",{className:"text-base font-semibold text-gray-900 pr-6",children:E.title||re.destructiveTitle}),
22
+ /* @__PURE__ */u("p",{className:"mt-2 text-sm text-gray-600",children:E.message}),null!=te&&/* @__PURE__ */c(m,{children:[
23
+ /* @__PURE__ */c("p",{className:"mt-3 text-sm text-gray-700",children:[oe,
24
+ /* @__PURE__ */u("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:te}),ie]}),
25
+ /* @__PURE__ */u("input",{autoFocus:!0,type:"text",value:j,onChange:e=>W(e.target.value),onKeyDown:e=>{"Enter"===e.key&&j===te&&X(!0)},placeholder:te,className:"mt-2 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-red-500"})]})]})]})]}),
26
+ /* @__PURE__ */c($,{open:R,onClose:()=>Y(!1),title:B.title||re.promptTitle,footer:/* @__PURE__ */c(m,{children:[
27
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>Y(!1),className:S,children:B.cancelLabel||re.cancel}),
28
+ /* @__PURE__ */u("button",{type:"button",onClick:()=>Y(!0),disabled:!B.allowEmpty&&!V.trim(),className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 text-sm font-medium rounded-lg disabled:opacity-40",children:B.confirmLabel||re.ok})]}),children:[B.message&&/* @__PURE__ */u("p",{className:"text-sm text-gray-600",children:B.message}),
29
+ /* @__PURE__ */u("input",{autoFocus:!0,type:"text",value:V,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key?Y(!0):"Escape"===e.key&&Y(!1)},onFocus:e=>e.target.select(),placeholder:B.placeholder,className:"mt-3 w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 rosh-focus-ring focus-visible:ring-1 focus-visible:ring-[color:var(--rosh-focus-ring-accent)]"})]})]})}export{O as ConfirmProvider,$ as Dialog,L as OVERLAY_OPEN_EVENT,W as Z_LAYERS,R as confirm,A as confirmDestructive,C as dismissPopups,E as onOverlayOpen,B as prompt,k as registerModalEscapeInterceptor,N as runEscapeInterceptors,F as useConfirm,j as useDismissPopupsOnOpen,g as useFocusTrap,y as useScrollLock};
@@ -0,0 +1 @@
1
+ var n=null,u=0;function t(t){n={token:++u,url:t}}function l(){return n}function o(u){n===u&&(n=null)}export{o as claimBrowserStartUrl,l as peekBrowserStartUrl,t as setBrowserStartUrl};
@@ -0,0 +1 @@
1
+ function t(){try{const t=document.documentElement;return"dark"===t.getAttribute("data-theme")||t.classList.contains("dark")}catch{return!1}}var e=["data-theme","class"];export{e as ROOT_THEME_ATTRIBUTES,t as rootIsDark};
@@ -0,0 +1,2 @@
1
+ import{toast_default as t}from"./chunk-KKOHUQPF.js";import{useShellPrefs as e}from"./chunk-V453E4KU.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?(R(),F()):"none"!==t&&0!==m||R()}function I(){g.running||(w({running:!0}),p=setInterval(P,1e3),"focus"===g.mode&&F())}function x(){(g.running||null!==p)&&(null!==p&&(clearInterval(p),p=null),w({running:!1}),R())}function B(t){x(),w({mode:t,remaining:l[t],total:l[t]})}function P(){g.remaining<=1?function(){null!==p&&(clearInterval(p),p=null);R(),C(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 C(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(()=>N(t,n),2500*e)}function N(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,O={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 F(){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*O[f],o.connect(a).connect(e.destination),o.start(),D={ctx:e,src:o,gain:a}}catch{}}function R(){if(D){try{D.src.stop()}catch{}try{D.ctx.close()}catch{}D=null}}function V(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*O[t],r.connect(i).connect(o.destination),r.start(),setTimeout(()=>{try{r.stop()}catch{}try{o.close()}catch{}},3e3)}catch{}}var G="pomodoro_tasks",K="pomodoro_tasks_migrated";function j(){return Math.random().toString(36).slice(2,11)}function E(){/* @__PURE__ */
2
+ return(new Date).toISOString()}var U=null,W=[],q=!1,H=null,J=/* @__PURE__ */new Set;function L(){for(const t of J)t()}function Q(t){W=t,L()}function $(){const t=U;return t?H=t.list().then(e=>{U===t&&(W=e,q=!0,L())}).catch(()=>{U===t&&(q=!0,L())}).finally(()=>{H=null}):(W=[],q=!0,L(),Promise.resolve())}function z(t){U=t,W=[],q=!1,t?$():L()}function X(t){return J.add(t),!U||q||H||$(),()=>{J.delete(t)}}function Y(){return W}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=E(),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:E()}: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(X,Y,Y),i=o(e=>{const n=U;if(!n)return t.addTask(e);const o="tmp-"+j(),a=E(),r={done:!1,...e,name:e.name.trim(),id:o,createdAt:a,updatedAt:a};return Q([...W,r]),n.create({...e,name:e.name.trim()}).then(t=>Q(W.map(e=>e.id===o?{...r,...t}:e))).catch(()=>Q(W.filter(t=>t.id!==o))),o},[t]),c=o((e,n)=>{const o=U;if(!o)return t.updateTask(e,n);Q(W.map(t=>t.id===e?{...t,...n,id:e,updatedAt:E()}:t)),o.update(e,n).catch(()=>{$()})},[t]),l=o(e=>{const n=U;if(!n)return t.removeTask(e);const o=W;Q(W.filter(t=>t.id!==e)),n.remove(e).catch(()=>Q(o))},[t]),s=o(e=>{if(!U)return t.toggleDone(e);const n=W.find(t=>t.id===e);n&&c(e,{done:!n.done})},[t,c]),u=o(e=>{U||t.setAllTasks(e)},[t]);return null===U?t:{tasks:r,addTask:i,updateTask:c,removeTask:l,toggleDone:s,setAllTasks:u}}function tt(t,e){try{if(localStorage.getItem(K))return;const n=localStorage.getItem(G);if(!n)return void localStorage.setItem(K,"1");const o=JSON.parse(n);if(!Array.isArray(o)||0===o.length)return localStorage.removeItem(G),void localStorage.setItem(K,"1");const a=E(),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(G),localStorage.setItem(K,"1")}catch{try{localStorage.setItem(K,"1")}catch{}}}export{r as ALARM_OPTIONS,i as FOCUS_SOUND_OPTIONS,M as getPomoSnapshot,tt as migratePomodoroTasksOnce,C as playAlarm,x as pomoPause,I as pomoStart,B as pomoSwitchMode,V as previewFocusSound,y as setPomoAlarm,v as setPomoAlarmConfig,T as setPomoBehaviour,b as setPomoDurations,A as setPomoFocusSound,z as setShellTodoProvider,S as subscribePomo,Z as useTodoTasks};