efficient-shell 7.31.0 → 7.31.1

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.
@@ -1,29 +1,29 @@
1
- import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-N6RZ56QX.js";import"./chunk-KOKCGKQX.js";import{WindowTitle as r}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import{confirm as a}from"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-NVFKXL52.js";import"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as n}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{useRef as s,useEffect as l,useState as i}from"react";import{jsxs as c,jsx as m,Fragment as d}from"react/jsx-runtime";var u="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",g=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],b=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function f(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&b.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var k=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return g;try{const e=localStorage.getItem(u);if(!e)return g;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return g}function w(){return"undefined"==typeof window?p:localStorage.getItem(h)||p}function y(){const d=s(void 0);void 0===d.current&&(d.current=e()),l(()=>{null!=d.current&&t(d.current)},[]);const p=d.current?f(d.current.url):"",[g,b]=i(w),[k,y]=i(p||g),[j,C]=i(k),[z,W]=i([k]),[L,S]=i(0),[R,H]=i(0),[E,D]=i(x),[K,M]=i(!1),[O,T]=i(null),A=s(null),F=s(null);l(()=>{try{localStorage.setItem(u,JSON.stringify(E))}catch{}},[E]);const I=e=>{const t=f(e);t&&(y(t),C(t),W(e=>{const o=e.slice(0,L+1);return o.push(t),o}),S(e=>e+1),M(!1))},X=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},P=()=>{const e=O?.trim();e?(D(t=>[...t,{label:e,url:k}]),T(null)):T(null)};l(()=>{if(null===O)return;A.current?.focus(),A.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||T(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==O]);const U=e=>{D(t=>t.filter((t,o)=>o!==e))},G=L>0,Q=L<z.length-1,q=E.some(e=>e.url===k),B="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
1
+ import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-FJBTASQI.js";import"./chunk-QK67IFHD.js";import{WindowTitle as r}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import{confirm as a}from"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-NVFKXL52.js";import"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as n}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{useRef as s,useEffect as l,useState as i}from"react";import{jsxs as c,jsx as m,Fragment as d}from"react/jsx-runtime";var u="react-os-shell:browser-bookmarks",h="react-os-shell:browser-homepage",p="https://en.wikipedia.org/wiki/Main_Page",g=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],b=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function f(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&b.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var k=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function x(){if("undefined"==typeof window)return g;try{const e=localStorage.getItem(u);if(!e)return g;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return g}function w(){return"undefined"==typeof window?p:localStorage.getItem(h)||p}function y(){const d=s(void 0);void 0===d.current&&(d.current=e()),l(()=>{null!=d.current&&t(d.current)},[]);const p=d.current?f(d.current.url):"",[g,b]=i(w),[k,y]=i(p||g),[j,C]=i(k),[z,S]=i([k]),[W,L]=i(0),[R,H]=i(0),[E,D]=i(x),[F,I]=i(!1),[T,A]=i(null),M=s(null),K=s(null);l(()=>{try{localStorage.setItem(u,JSON.stringify(E))}catch{}},[E]);const O=e=>{const t=f(e);t&&(y(t),C(t),S(e=>{const o=e.slice(0,W+1);return o.push(t),o}),L(e=>e+1),I(!1))},P=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},U=()=>{const e=T?.trim();e?(D(t=>[...t,{label:e,url:k}]),A(null)):A(null)};l(()=>{if(null===T)return;M.current?.focus(),M.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||A(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==T]);const Q=e=>{D(t=>t.filter((t,o)=>o!==e))},X=W>0,B=W<z.length-1,G=E.some(e=>e.url===k),J="p-2 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
2
2
  return c("div",{className:"relative flex flex-col h-full bg-white",children:[
3
3
  /* @__PURE__ */m(r,{title:`Browser - ${v(k)}`}),
4
4
  /* @__PURE__ */m(o,{app:"browser"}),
5
5
  /* @__PURE__ */c("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
6
- /* @__PURE__ */m("button",{onClick:()=>{if(L>0){const e=L-1;S(e),y(z[e]),C(z[e]),M(!1)}},disabled:!G,className:B,title:"Back",children:/* @__PURE__ */m(n,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
7
- /* @__PURE__ */m("button",{onClick:()=>{if(L<z.length-1){const e=L+1;S(e),y(z[e]),C(z[e]),M(!1)}},disabled:!Q,className:B,title:"Forward",children:/* @__PURE__ */m(n,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
8
- /* @__PURE__ */m("button",{onClick:()=>H(e=>e+1),className:B,title:"Refresh",children:/* @__PURE__ */m(n,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
9
- /* @__PURE__ */m("button",{onClick:()=>I(g),className:B,title:"Home",children:/* @__PURE__ */m(n,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
10
- /* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),I(j)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */c("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
6
+ /* @__PURE__ */m("button",{onClick:()=>{if(W>0){const e=W-1;L(e),y(z[e]),C(z[e]),I(!1)}},disabled:!X,className:J,title:"Back",children:/* @__PURE__ */m(n,{name:"chevron-left",className:"h-4 w-4",strokeWidth:2})}),
7
+ /* @__PURE__ */m("button",{onClick:()=>{if(W<z.length-1){const e=W+1;L(e),y(z[e]),C(z[e]),I(!1)}},disabled:!B,className:J,title:"Forward",children:/* @__PURE__ */m(n,{name:"chevron-right",className:"h-4 w-4",strokeWidth:2})}),
8
+ /* @__PURE__ */m("button",{onClick:()=>H(e=>e+1),className:J,title:"Refresh",children:/* @__PURE__ */m(n,{name:"refresh",className:"h-4 w-4",strokeWidth:1.8})}),
9
+ /* @__PURE__ */m("button",{onClick:()=>O(g),className:J,title:"Home",children:/* @__PURE__ */m(n,{name:"home",className:"h-4 w-4",strokeWidth:1.8})}),
10
+ /* @__PURE__ */m("form",{onSubmit:e=>{e.preventDefault(),O(j)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */c("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
11
11
  /* @__PURE__ */m("span",{className:"px-2 text-gray-400 text-xs",children:k.startsWith("https://")?"🔒":"⚠️"}),
12
12
  /* @__PURE__ */m("input",{type:"text",value:j,onChange:e=>C(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),k!==j&&/* @__PURE__ */m("button",{type:"button",onClick:()=>C(k),className:"px-2 text-2xs text-gray-400 hover:text-gray-700",title:"Reset to current URL",children:"×"})]})}),
13
- /* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>q?U(E.findIndex(e=>e.url===k)):void T(v(k)),className:B+" "+(q?"text-yellow-500":""),title:q?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(n,{name:"star",className:"h-4 w-4",fill:q?"currentColor":"none",strokeWidth:1.5})}),
14
- /* @__PURE__ */m("button",{onClick:X,className:B,title:"Open in new tab",children:/* @__PURE__ */m(n,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
15
- /* @__PURE__ */m("button",{onClick:()=>M(e=>!e),className:B,title:"Embedding help",children:/* @__PURE__ */m(n,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==O&&/* @__PURE__ */c("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
13
+ /* @__PURE__ */m("button",{"data-bookmark-popover":!0,onClick:()=>G?Q(E.findIndex(e=>e.url===k)):void A(v(k)),className:J+" "+(G?"text-yellow-500":""),title:G?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */m(n,{name:"star",className:"h-4 w-4",fill:G?"currentColor":"none",strokeWidth:1.5})}),
14
+ /* @__PURE__ */m("button",{onClick:P,className:J,title:"Open in new tab",children:/* @__PURE__ */m(n,{name:"external",className:"h-4 w-4",strokeWidth:1.5})}),
15
+ /* @__PURE__ */m("button",{onClick:()=>I(e=>!e),className:J,title:"Embedding help",children:/* @__PURE__ */m(n,{name:"help",className:"h-4 w-4",strokeWidth:1.5})})]}),null!==T&&/* @__PURE__ */c("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
16
16
  /* @__PURE__ */m("div",{className:"text-2xs font-semibold uppercase tracking-wide text-gray-500 mb-1",children:"Bookmark this page"}),
17
17
  /* @__PURE__ */m("div",{className:"text-2xs text-gray-400 truncate mb-2 font-mono",title:k,children:k}),
18
- /* @__PURE__ */m("input",{ref:A,type:"text",value:O,onChange:e=>T(e.target.value),onKeyDown:e=>{"Enter"===e.key?P():"Escape"===e.key&&T(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
18
+ /* @__PURE__ */m("input",{ref:M,type:"text",value:T,onChange:e=>A(e.target.value),onKeyDown:e=>{"Enter"===e.key?U():"Escape"===e.key&&A(null)},placeholder:"Name",className:"w-full text-sm px-2 h-8 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
19
19
  /* @__PURE__ */c("div",{className:"flex justify-end gap-1 mt-2",children:[
20
- /* @__PURE__ */m("button",{onClick:()=>T(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
21
- /* @__PURE__ */m("button",{onClick:P,disabled:!O.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
22
- /* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===E.length&&/* @__PURE__ */m("span",{className:"text-2xs text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),E.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>I(e.url),onContextMenu:async o=>{o.preventDefault();await a({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&U(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
20
+ /* @__PURE__ */m("button",{onClick:()=>A(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
21
+ /* @__PURE__ */m("button",{onClick:U,disabled:!T.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
22
+ /* @__PURE__ */c("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===E.length&&/* @__PURE__ */m("span",{className:"text-2xs text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),E.map((e,t)=>/* @__PURE__ */c("button",{onClick:()=>O(e.url),onContextMenu:async o=>{o.preventDefault();await a({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&Q(t)},className:"flex items-center gap-2 px-2 py-0.5 rounded text-xs text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
23
23
  /* @__PURE__ */m("img",{src:`https://icons.duckduckgo.com/ip3/${new URL(e.url).hostname}.ico`,alt:"",className:"h-3.5 w-3.5",onError:e=>{e.target.style.visibility="hidden"}}),e.label]},t)),
24
24
  /* @__PURE__ */m("div",{className:"flex-1"}),
25
25
  /* @__PURE__ */m("button",{onClick:()=>{b(k);try{localStorage.setItem(h,k)}catch{}},className:"px-2 py-0.5 text-2xs text-gray-500 hover:text-gray-800",title:"Set current page as homepage",children:"Set as home"})]}),
26
- /* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:k,iframeKey:R,iframeRef:F,openExternal:X,showHelp:K,dismissHelp:()=>M(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function N({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:a,dismissHelp:s}){const[u,h]=i(!1);l(()=>{h(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return k.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!u?/* @__PURE__ */m("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */c("div",{className:"max-w-md text-center",children:[
26
+ /* @__PURE__ */m("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */m(N,{url:k,iframeKey:R,iframeRef:K,openExternal:P,showHelp:F,dismissHelp:()=>I(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function N({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:a,dismissHelp:s}){const[u,h]=i(!1);l(()=>{h(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return k.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!u?/* @__PURE__ */m("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */c("div",{className:"max-w-md text-center",children:[
27
27
  /* @__PURE__ */m(n,{name:"no-symbol",className:"h-14 w-14 mx-auto text-gray-300 mb-3",strokeWidth:1.2}),
28
28
  /* @__PURE__ */c("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
29
29
  /* @__PURE__ */c("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
@@ -1,6 +1,6 @@
1
- import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-N6RZ56QX.js";import{toast_default as n}from"./chunk-BTLM7W6P.js";import"./chunk-KOKCGKQX.js";import{WindowTitle as r}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import{LoadingSpinner as o}from"./chunk-NVFKXL52.js";import{PopupMenu as l,PopupMenuLabel as a,PopupMenuItem as i,PopupMenuDivider as s}from"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as c}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{useState as d,useRef as m}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,y]=d(x),[v,b]=d(!1),[k,w]=d(!1),[N,C]=d(!1),[j,D]=d(null),L=m(null),M=m(null),R=m(null),U=(e,t)=>{R.current?.focus(),document.execCommand(e,!1,t),C(!0)},W=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{R.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),C(!0)},e.readAsDataURL(t)}},A=e=>{j&&(j.el.removeAttribute("width"),j.el.removeAttribute("height"),j.el.style.width=e??"",j.el.style.height=e?"auto":"",C(!0),D(null))},B=async t=>{const r=(t.name.split(".").pop()||"").toLowerCase();b(!0);try{if(p.has(r)||!g.has(r)&&t.type.startsWith("text/")){const n=await t.text(),o=e(n).replace(/\n/g,"<br>");y({filename:t.name,kind:"text",content:o,ext:r}),C(!1)}else if(g.has(r))try{const e=await(import(
1
+ import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-FJBTASQI.js";import{toast_default as n}from"./chunk-BTLM7W6P.js";import"./chunk-QK67IFHD.js";import{WindowTitle as r}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import{LoadingSpinner as o}from"./chunk-NVFKXL52.js";import{PopupMenu as l,PopupMenuLabel as a,PopupMenuItem as i,PopupMenuDivider as s}from"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as c}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{useState as d,useRef as m}from"react";import{jsxs as h,jsx as u}from"react/jsx-runtime";var p=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),g=/* @__PURE__ */new Set(["docx"]),x={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function f(){const[f,y]=d(x),[v,b]=d(!1),[k,w]=d(!1),[N,C]=d(!1),[j,D]=d(null),L=m(null),M=m(null),U=m(null),R=(e,t)=>{U.current?.focus(),document.execCommand(e,!1,t),C(!0)},W=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{U.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),C(!0)},e.readAsDataURL(t)}},A=e=>{j&&(j.el.removeAttribute("width"),j.el.removeAttribute("height"),j.el.style.width=e??"",j.el.style.height=e?"auto":"",C(!0),D(null))},B=async t=>{const r=(t.name.split(".").pop()||"").toLowerCase();b(!0);try{if(p.has(r)||!g.has(r)&&t.type.startsWith("text/")){const n=await t.text(),o=e(n).replace(/\n/g,"<br>");y({filename:t.name,kind:"text",content:o,ext:r}),C(!1)}else if(g.has(r))try{const e=await(import(
2
2
  /* @vite-ignore */
3
- "mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),C(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{b(!1)}},T=f?.filename?(O=f.filename).length>24?`${O.slice(0,23)}…`:O:"Untitled";var O;/* @__PURE__ */
3
+ "mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});y({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),C(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{b(!1)}},T=f?.filename?(S=f.filename).length>24?`${S.slice(0,23)}…`:S:"Untitled";var S;/* @__PURE__ */
4
4
  return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),k||w(!0)},onDragLeave:e=>{e.currentTarget===e.target&&w(!1)},onDrop:e=>{e.preventDefault(),w(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?W(t):B(t[0]))},children:[
5
5
  /* @__PURE__ */u(r,{title:`${T}${N?" •":""} - Documents`}),
6
6
  /* @__PURE__ */u(t,{app:"documents"}),
@@ -8,18 +8,18 @@ return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
8
8
  /* @__PURE__ */u("input",{ref:L,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&B(t),L.current&&(L.current.value="")},className:"hidden"}),
9
9
  /* @__PURE__ */h("button",{onClick:()=>L.current?.click(),className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
10
10
  /* @__PURE__ */u(c,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Open"]}),
11
- /* @__PURE__ */u("button",{onClick:()=>{if(!f)return;const t=R.current?.innerHTML??"";if("text"===f.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=R.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=f.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
11
+ /* @__PURE__ */u("button",{onClick:()=>{if(!f)return;const t=U.current?.innerHTML??"";if("text"===f.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=U.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=f.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(f.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${f.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
12
12
  /* @__PURE__ */u("span",{className:"text-2xs text-gray-400 ml-1",children:"TXT · DOCX · Code"}),
13
13
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
14
14
  /* @__PURE__ */h("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:f.filename,children:[f.filename,N?" •":""]}),
15
15
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
16
16
  /* @__PURE__ */h("div",{className:"flex items-center gap-0.5",children:[
17
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("bold"),className:"px-2 py-1 text-xs rounded font-bold text-gray-700 hover:bg-gray-200 transition-colors",title:"Bold",children:"B"}),
18
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("italic"),className:"px-2 py-1 text-xs rounded italic text-gray-700 hover:bg-gray-200 transition-colors",title:"Italic",children:"I"}),
19
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("underline"),className:"px-2 py-1 text-xs rounded underline text-gray-700 hover:bg-gray-200 transition-colors",title:"Underline",children:"U"}),
20
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("strikeThrough"),className:"px-2 py-1 text-xs rounded line-through text-gray-700 hover:bg-gray-200 transition-colors",title:"Strikethrough",children:"S"})]}),
17
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("bold"),className:"px-2 py-1 text-xs rounded font-bold text-gray-700 hover:bg-gray-200 transition-colors",title:"Bold",children:"B"}),
18
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("italic"),className:"px-2 py-1 text-xs rounded italic text-gray-700 hover:bg-gray-200 transition-colors",title:"Italic",children:"I"}),
19
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("underline"),className:"px-2 py-1 text-xs rounded underline text-gray-700 hover:bg-gray-200 transition-colors",title:"Underline",children:"U"}),
20
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("strikeThrough"),className:"px-2 py-1 text-xs rounded line-through text-gray-700 hover:bg-gray-200 transition-colors",title:"Strikethrough",children:"S"})]}),
21
21
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
22
- /* @__PURE__ */h("select",{onMouseDown:e=>e.preventDefault(),onChange:e=>{U("fontSize",e.target.value),e.currentTarget.value=""},defaultValue:"",className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:[
22
+ /* @__PURE__ */h("select",{onMouseDown:e=>e.preventDefault(),onChange:e=>{R("fontSize",e.target.value),e.currentTarget.value=""},defaultValue:"",className:"text-xs border border-gray-300 rounded px-1 py-0.5 bg-white",children:[
23
23
  /* @__PURE__ */u("option",{value:"",disabled:!0,children:"Size"}),
24
24
  /* @__PURE__ */u("option",{value:"1",children:"XS"}),
25
25
  /* @__PURE__ */u("option",{value:"2",children:"S"}),
@@ -27,21 +27,21 @@ return h("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
27
27
  /* @__PURE__ */u("option",{value:"4",children:"L"}),
28
28
  /* @__PURE__ */u("option",{value:"5",children:"XL"}),
29
29
  /* @__PURE__ */u("option",{value:"6",children:"2XL"})]}),
30
- /* @__PURE__ */u("input",{type:"color",defaultValue:"#000000",onChange:e=>U("foreColor",e.target.value),className:"w-7 h-6 border border-gray-300 rounded cursor-pointer",title:"Text color"}),
30
+ /* @__PURE__ */u("input",{type:"color",defaultValue:"#000000",onChange:e=>R("foreColor",e.target.value),className:"w-7 h-6 border border-gray-300 rounded cursor-pointer",title:"Text color"}),
31
31
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
32
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("insertUnorderedList"),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Bulleted list",children:"• List"}),
33
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("insertOrderedList"),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Numbered list",children:"1."}),
32
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("insertUnorderedList"),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Bulleted list",children:"• List"}),
33
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("insertOrderedList"),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Numbered list",children:"1."}),
34
34
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
35
35
  /* @__PURE__ */h("div",{className:"flex items-center gap-0.5",children:[
36
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyLeft"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align left",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h9.75M3.75 18h14.25"})})}),
37
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyCenter"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align center",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M7.125 12h9.75M4.875 18h14.25"})})}),
38
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyRight"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align right",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M10.5 12h9.75M6 18h14.25"})})}),
39
- /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>U("justifyFull"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Justify",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5"})})})]}),
36
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("justifyLeft"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align left",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h9.75M3.75 18h14.25"})})}),
37
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("justifyCenter"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align center",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M7.125 12h9.75M4.875 18h14.25"})})}),
38
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("justifyRight"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align right",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M10.5 12h9.75M6 18h14.25"})})}),
39
+ /* @__PURE__ */u("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>R("justifyFull"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Justify",children:/* @__PURE__ */u("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */u("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5"})})})]}),
40
40
  /* @__PURE__ */u("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
41
41
  /* @__PURE__ */u("input",{ref:M,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&W(Array.from(e.target.files)),M.current&&(M.current.value="")}}),
42
42
  /* @__PURE__ */h("button",{onClick:()=>M.current?.click(),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors flex items-center gap-1",title:"Insert image (or paste / drop one)",children:[
43
43
  /* @__PURE__ */u(c,{name:"image",className:"h-3.5 w-3.5",strokeWidth:1.5}),"Image"]})]}),
44
- /* @__PURE__ */u("div",{className:"flex-1 min-h-0 overflow-hidden",children:v?/* @__PURE__ */u(o,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */u("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */u("div",{ref:R,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>C(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),W(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),D({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:f.content},className:"docx"===f.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-sm leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-sm leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),k&&/* @__PURE__ */u("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */u("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),j&&/* @__PURE__ */h(l,{minWidth:150,style:{left:j.x,top:j.y},onClose:()=>D(null),children:[
44
+ /* @__PURE__ */u("div",{className:"flex-1 min-h-0 overflow-hidden",children:v?/* @__PURE__ */u(o,{size:"sm",padding:"",className:"h-full",label:"Loading"}):/* @__PURE__ */u("div",{className:"h-full overflow-auto "+("docx"===f.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */u("div",{ref:U,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>C(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),W(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),D({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:f.content},className:"docx"===f.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-sm leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-sm leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),k&&/* @__PURE__ */u("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */u("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),j&&/* @__PURE__ */h(l,{minWidth:150,style:{left:j.x,top:j.y},onClose:()=>D(null),children:[
45
45
  /* @__PURE__ */u(a,{children:"Image width"}),
46
46
  /* @__PURE__ */u(i,{onClick:()=>A("25%"),children:"25%"}),
47
47
  /* @__PURE__ */u(i,{onClick:()=>A("50%"),children:"50%"}),
@@ -1,4 +1,4 @@
1
- import{openPreviewFile as e}from"./chunk-RAFTWZF5.js";import{Breadcrumbs as t}from"./chunk-XDM6YBBX.js";import{TH_ONE_LINE as a}from"./chunk-RYBDLJJV.js";import{SidebarLayout as r}from"./chunk-BDXFODVC.js";import{getFilesDemoTree as n}from"./chunk-T4HEQXBK.js";import{AboutApp as s}from"./chunk-N6RZ56QX.js";import{peekFilesViewRequest as i,consumeFilesViewRequest as l,FILES_SHOW_TRASH_EVENT as o,FILES_OPEN_DESKTOP_FOLDER_EVENT as d,subscribeDesktopFolders as c,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-MDD5DHF2.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{toast_default as f}from"./chunk-BTLM7W6P.js";import"./chunk-KOKCGKQX.js";import{useWindowManager as x,WindowTitle as g}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import{confirm as y,prompt as b}from"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import{LoadingSpinner as k}from"./chunk-NVFKXL52.js";import"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as N}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{formatBytes as w}from"./chunk-W32SKK3D.js";import{useState as v,useEffect as $,useSyncExternalStore as j,useRef as C,useCallback as D}from"react";import{jsxs as L,jsx as T,Fragment as E}from"react/jsx-runtime";var R="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",F={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function S(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function M(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function P(){const P=R.replace(/\/$/,""),W=null!==n(),[A,I]=v("/"),[O,U]=v([]),[B,K]=v([]),[H,V]=v(null),[X,z]=v(!0),[J,Q]=v(!1),[_,G]=v(null),[Y,Z]=v(!1),[q,ee]=v(()=>{const e=i();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});$(()=>{l()},[]);const[te,ae]=v([]);$(()=>{const e=()=>{l(),ee("trash")},t=e=>{l();const t=e.detail?.folderId;t&&ee({desktopFolderId:t})};return window.addEventListener(o,e),window.addEventListener(d,t),()=>{window.removeEventListener(o,e),window.removeEventListener(d,t)}},[]);const re=j(c,m,m),ne="object"==typeof q?q.desktopFolderId:null,se=ne?re?.folders.find(e=>e.id===ne)??null:null,ie=ne&&re?.itemsByFolder[ne]||[];$(()=>{ne&&re&&!re.folders.some(e=>e.id===ne)&&ee("files")},[ne,re]);const le=C(0),oe=C(null),{openPage:de,openEntity:ce}=x(),me=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>de(e)}):"page"===t.entityType?de(t.entityId):ce(t.entityType,t.entityId,null,t.label)},he=D((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),pe=D(async()=>{try{const e=await he(`${P}/api/quota`);if(e.ok){const t=await e.json();G({used:t.used,limit:t.limit})}}catch{}},[he,P]),ue=D(async e=>{if(V(null),W){const t=function(e){const t=n();if(!t)return[];let a=t;for(const t of e.split("/").filter(Boolean)){const e=a.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];a=e.children}return a.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return U(t),I(e),Q(!1),z(!1),void("/"===e&&K(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}z(!0);try{const t=await he(`${P}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void f.error(e.error||`Failed to list (${t.status})`)}const a=await t.json(),r=a.entries||[];U(r),I(a.path||e),Q(!1),"/"===(a.path||e)&&K(r.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){Q(!0)}finally{z(!1)}pe()},[he,P,pe,W]),fe=D(async()=>{if(W)return ae([]),void z(!1);z(!0),V(null);try{const e=await he(`${P}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void f.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();ae(t.entries||[]),Q(!1)}catch{Q(!0)}finally{z(!1)}pe()},[he,P,pe,W]);$(()=>{"files"===q?ue(A):"trash"===q&&fe()},[A,q]);const xe=async e=>{const t=S(A,e.name);try{const a=await he(`${P}/api/file?path=${encodeURIComponent(t)}`);if(!a.ok)return void f.error(`Download failed (${a.status})`);const r=await a.blob(),n=URL.createObjectURL(r),s=document.createElement("a");s.href=n,s.download=e.name,s.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){f.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const a=await he(`${P}/api/upload?path=${encodeURIComponent(A)}`,{method:"POST",body:t});if(!a.ok){const t=await a.json().catch(()=>({}));if(413===a.status){const a=Math.max(0,(t.limit||0)-(t.used||0));f.error(`Quota exceeded — ${w(a)} free, ${e.name} is ${w(t.attempted||e.size)}`)}else f.error(`Upload ${e.name}: ${t.error||a.status}`)}}catch(t){f.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}ue(A)},ye=()=>{le.current=0,Z(!1)};if($(()=>{const e=()=>ye();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),J)/* @__PURE__ */
1
+ import{openPreviewFile as e}from"./chunk-RAFTWZF5.js";import{Breadcrumbs as t}from"./chunk-XDM6YBBX.js";import{TH_ONE_LINE as a}from"./chunk-RYBDLJJV.js";import{SidebarLayout as r}from"./chunk-BDXFODVC.js";import{getFilesDemoTree as n}from"./chunk-T4HEQXBK.js";import{AboutApp as s}from"./chunk-FJBTASQI.js";import{peekFilesViewRequest as i,consumeFilesViewRequest as l,FILES_SHOW_TRASH_EVENT as o,FILES_OPEN_DESKTOP_FOLDER_EVENT as d,subscribeDesktopFolders as c,getDesktopFoldersSnapshot as m,FolderGlyph as h,DesktopItemMiniIcon as p,desktopItemTypeLabel as u}from"./chunk-MDD5DHF2.js";import"./chunk-ESL5TDNA.js";import"./chunk-VTVSMRFX.js";import{toast_default as f}from"./chunk-BTLM7W6P.js";import"./chunk-QK67IFHD.js";import{useWindowManager as x,WindowTitle as g}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import{confirm as y,prompt as b}from"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import{LoadingSpinner as k}from"./chunk-NVFKXL52.js";import"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as N}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{formatBytes as w}from"./chunk-W32SKK3D.js";import{useState as v,useEffect as $,useSyncExternalStore as j,useRef as C,useCallback as D}from"react";import{jsxs as L,jsx as T,Fragment as E}from"react/jsx-runtime";var R="undefined"!=typeof window&&window.__REACT_OS_SHELL_FILE_SERVER__||"http://localhost:4000",F={pdf:"pdf",dxf:"dxf",csv:"csv",jpg:"image",jpeg:"image",png:"image",gif:"image",webp:"image",svg:"image",avif:"image",bmp:"image",stp:"3d",step:"3d",stl:"3d",obj:"3d",gltf:"3d",glb:"3d","3mf":"3d",iges:"3d",igs:"3d",ply:"3d",fbx:"3d"};function S(e,t){return"/"===e||""===e?"/"+t:e.replace(/\/$/,"")+"/"+t}function M(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?"—":t.toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return e}}function P(){const P=R.replace(/\/$/,""),W=null!==n(),[A,I]=v("/"),[O,B]=v([]),[U,H]=v([]),[K,V]=v(null),[z,X]=v(!0),[J,Q]=v(!1),[_,G]=v(null),[Y,Z]=v(!1),[q,ee]=v(()=>{const e=i();return"trash"===e?"trash":e?{desktopFolderId:e.folderId}:"files"});$(()=>{l()},[]);const[te,ae]=v([]);$(()=>{const e=()=>{l(),ee("trash")},t=e=>{l();const t=e.detail?.folderId;t&&ee({desktopFolderId:t})};return window.addEventListener(o,e),window.addEventListener(d,t),()=>{window.removeEventListener(o,e),window.removeEventListener(d,t)}},[]);const re=j(c,m,m),ne="object"==typeof q?q.desktopFolderId:null,se=ne?re?.folders.find(e=>e.id===ne)??null:null,ie=ne&&re?.itemsByFolder[ne]||[];$(()=>{ne&&re&&!re.folders.some(e=>e.id===ne)&&ee("files")},[ne,re]);const le=C(0),oe=C(null),{openPage:de,openEntity:ce}=x(),me=t=>{"preview-file"===t.entityType&&t.filePath&&t.fileKind?e({filePath:t.filePath,filename:t.label,kind:t.fileKind,onStaged:e=>de(e)}):"page"===t.entityType?de(t.entityId):ce(t.entityType,t.entityId,null,t.label)},he=D((e,t={})=>fetch(e,{...t,credentials:"include"}),[]),pe=D(async()=>{try{const e=await he(`${P}/api/quota`);if(e.ok){const t=await e.json();G({used:t.used,limit:t.limit})}}catch{}},[he,P]),ue=D(async e=>{if(V(null),W){const t=function(e){const t=n();if(!t)return[];let a=t;for(const t of e.split("/").filter(Boolean)){const e=a.find(e=>"folder"===e.kind&&e.name===t);if(!e||!e.children)return[];a=e.children}return a.map(e=>({name:e.name,kind:e.kind,size:e.size??0,modifiedAt:e.modifiedAt??""}))}(e);return B(t),I(e),Q(!1),X(!1),void("/"===e&&H(t.filter(e=>"folder"===e.kind).map(e=>e.name)))}X(!0);try{const t=await he(`${P}/api/files?path=${encodeURIComponent(e)}`);if(!t.ok){const e=await t.json().catch(()=>({}));return void f.error(e.error||`Failed to list (${t.status})`)}const a=await t.json(),r=a.entries||[];B(r),I(a.path||e),Q(!1),"/"===(a.path||e)&&H(r.filter(e=>"folder"===e.kind).map(e=>e.name))}catch(e){Q(!0)}finally{X(!1)}pe()},[he,P,pe,W]),fe=D(async()=>{if(W)return ae([]),void X(!1);X(!0),V(null);try{const e=await he(`${P}/api/trash`);if(!e.ok){const t=await e.json().catch(()=>({}));return void f.error(t.error||`Failed to list trash (${e.status})`)}const t=await e.json();ae(t.entries||[]),Q(!1)}catch{Q(!0)}finally{X(!1)}pe()},[he,P,pe,W]);$(()=>{"files"===q?ue(A):"trash"===q&&fe()},[A,q]);const xe=async e=>{const t=S(A,e.name);try{const a=await he(`${P}/api/file?path=${encodeURIComponent(t)}`);if(!a.ok)return void f.error(`Download failed (${a.status})`);const r=await a.blob(),n=URL.createObjectURL(r),s=document.createElement("a");s.href=n,s.download=e.name,s.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){f.error(e?.message||"Download failed")}},ge=async e=>{const t=Array.from(e);for(const e of t){const t=new FormData;t.append("file",e);try{const a=await he(`${P}/api/upload?path=${encodeURIComponent(A)}`,{method:"POST",body:t});if(!a.ok){const t=await a.json().catch(()=>({}));if(413===a.status){const a=Math.max(0,(t.limit||0)-(t.used||0));f.error(`Quota exceeded — ${w(a)} free, ${e.name} is ${w(t.attempted||e.size)}`)}else f.error(`Upload ${e.name}: ${t.error||a.status}`)}}catch(t){f.error(`Upload ${e.name}: ${t?.message||"failed"}`)}}ue(A)},ye=()=>{le.current=0,Z(!1)};if($(()=>{const e=()=>ye();return window.addEventListener("dragend",e),window.addEventListener("drop",e),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",e)}},[]),J)/* @__PURE__ */
2
2
  return L("div",{className:"flex flex-col h-full bg-white",children:[
3
3
  /* @__PURE__ */T(g,{title:"Files - offline"}),
4
4
  /* @__PURE__ */T("div",{className:"flex-1 flex items-center justify-center p-8 text-center",children:/* @__PURE__ */L("div",{className:"max-w-md",children:[
@@ -9,7 +9,7 @@ return L("div",{className:"flex flex-col h-full bg-white",children:[
9
9
  /* @__PURE__ */T("span",{className:"font-mono",children:"examples/file-server/README.md"}),"."]}),
10
10
  /* @__PURE__ */T("button",{onClick:()=>ue(A),className:"px-3 h-8 text-sm bg-blue-500 text-white rounded hover:bg-blue-600",children:"Retry"})]})})]});const be="/"===A?[]:A.split("/").filter(Boolean),ke=_&&_.limit>0?Math.min(100,Math.round(_.used/_.limit*100)):0,Ne=ke>90?"bg-red-500":ke>75?"bg-amber-500":"bg-blue-500",we=[{label:"My files",onClick:()=>I("/")},...be.map((e,t)=>({label:e,onClick:()=>I("/"+be.slice(0,t+1).join("/"))}))],ve=e=>"flex w-full items-center gap-2 rounded-md px-3 min-h-(--row-height-menu) py-2 text-left text-sm transition-colors "+(e?"bg-blue-50 font-medium text-blue-700":"text-gray-700 hover:bg-gray-100"),$e=e=>/* @__PURE__ */T("svg",{className:"h-4 w-4 shrink-0 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.6,children:/* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e})}),je=/* @__PURE__ */L("nav",{className:"p-2",children:[
11
11
  /* @__PURE__ */T("div",{className:"px-2 py-2 text-2xs font-semibold uppercase tracking-wide text-gray-400",children:"Locations"}),
12
- /* @__PURE__ */L("button",{onClick:()=>{ee("files"),I("/")},className:ve("files"===q&&"/"===A),children:[$e("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),B.map(e=>/* @__PURE__ */L("button",{onClick:()=>{ee("files"),I("/"+e)},className:ve("files"===q&&A==="/"+e),children:[$e("M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"),
12
+ /* @__PURE__ */L("button",{onClick:()=>{ee("files"),I("/")},className:ve("files"===q&&"/"===A),children:[$e("M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0L21.75 12M4.5 9.75v9.75a.75.75 0 00.75.75H9V15a.75.75 0 01.75-.75h4.5A.75.75 0 0115 15v5.25h3.75a.75.75 0 00.75-.75V9.75"),"My files"]}),U.map(e=>/* @__PURE__ */L("button",{onClick:()=>{ee("files"),I("/"+e)},className:ve("files"===q&&A==="/"+e),children:[$e("M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"),
13
13
  /* @__PURE__ */T("span",{className:"truncate",children:e})]},e)),!W&&/* @__PURE__ */L("button",{onClick:()=>ee("trash"),className:ve("trash"===q),children:[$e("M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79"),"Trash"]}),re&&re.folders.length>0&&/* @__PURE__ */L(E,{children:[
14
14
  /* @__PURE__ */T("div",{className:"px-2 pt-3 pb-2 text-2xs font-semibold uppercase tracking-wide text-gray-400",children:"Desktop"}),re.folders.map(e=>/* @__PURE__ */L("button",{onClick:()=>ee({desktopFolderId:e.id}),className:ve(ne===e.id),children:[
15
15
  /* @__PURE__ */T(h,{className:"h-4 w-4 shrink-0 text-amber-500"}),
@@ -47,7 +47,7 @@ return L("div",{className:"relative flex flex-col h-full bg-white",onDragEnter:e
47
47
  /* @__PURE__ */T("th",{className:`${a} text-left font-medium px-3 h-8 w-28`,children:"Type"}),
48
48
  /* @__PURE__ */T("th",{className:`${a} w-56`})]})}),
49
49
  /* @__PURE__ */T("tbody",{children:ie.map(e=>{const t=`${e.entityType}|${e.entityId}`;/* @__PURE__ */
50
- return L("tr",{onClick:()=>V(t),onDoubleClick:()=>me(e),className:"cursor-default border-b border-gray-100 "+(H===t?"bg-blue-50":"hover:bg-gray-50"),children:[
50
+ return L("tr",{onClick:()=>V(t),onDoubleClick:()=>me(e),className:"cursor-default border-b border-gray-100 "+(K===t?"bg-blue-50":"hover:bg-gray-50"),children:[
51
51
  /* @__PURE__ */L("td",{className:"px-3 h-8 flex items-center gap-2",children:[
52
52
  /* @__PURE__ */T(p,{item:e}),
53
53
  /* @__PURE__ */T("span",{className:"truncate",title:e.label,children:e.label})]}),
@@ -55,7 +55,7 @@ return L("tr",{onClick:()=>V(t),onDoubleClick:()=>me(e),className:"cursor-defaul
55
55
  /* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
56
56
  /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),me(e)},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Open"}),
57
57
  /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re?.moveToDesktop([e])},className:"px-2 py-0.5 rounded hover:bg-gray-200 text-gray-500 text-2xs ml-1",children:"Move to desktop"}),
58
- /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re?.removeShortcuts([e])},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Remove"})]})]},t)})})]}):"trash"===q?X&&0===te.length?/* @__PURE__ */T(k,{size:"sm",padding:"p-6",label:"Loading"}):0===te.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
58
+ /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re?.removeShortcuts([e])},className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Remove"})]})]},t)})})]}):"trash"===q?z&&0===te.length?/* @__PURE__ */T(k,{size:"sm",padding:"p-6",label:"Loading"}):0===te.length?/* @__PURE__ */T("div",{className:"p-10 text-center text-sm text-gray-400",children:"Trash is empty."}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
59
59
  /* @__PURE__ */T("thead",{className:"bg-gray-50 text-2xs uppercase tracking-wide text-gray-500",children:/* @__PURE__ */L("tr",{children:[
60
60
  /* @__PURE__ */T("th",{className:`${a} text-left font-medium px-3 h-8`,children:"Name"}),
61
61
  /* @__PURE__ */T("th",{className:`${a} text-left font-medium px-3 h-8`,children:"Original location"}),
@@ -70,14 +70,14 @@ return L("tr",{onClick:()=>V(t),onDoubleClick:()=>me(e),className:"cursor-defaul
70
70
  /* @__PURE__ */T("td",{className:"px-3 h-8 text-right text-gray-500 tabular-nums",children:e.deletedAt?M(e.deletedAt):"—"}),
71
71
  /* @__PURE__ */L("td",{className:"px-3 h-8 text-right whitespace-nowrap",children:[
72
72
  /* @__PURE__ */T("button",{onClick:()=>(async e=>{const t=await he(`${P}/api/trash/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.id})});if(!t.ok){const e=await t.json().catch(()=>({}));return void f.error(e.error||`Restore failed (${t.status})`)}f.success(`Restored "${e.name}"`),fe()})(e),className:"px-2 py-0.5 rounded hover:bg-gray-200 text-blue-600 text-2xs",children:"Restore"}),
73
- /* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await y({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await he(`${P}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void f.error(e.error||`Delete failed (${t.status})`)}fe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):X&&0===O.length?/* @__PURE__ */T(k,{size:"sm",padding:"p-6",label:"Loading"}):0===O.length?/* @__PURE__ */L("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!W&&/* @__PURE__ */L(E,{children:[" Drop files here or click ",
73
+ /* @__PURE__ */T("button",{onClick:()=>(async e=>{if(!await y({title:"Permanently delete",message:`"${e.name}" will be permanently removed. This can't be undone.`,confirmLabel:"Delete forever",variant:"danger"}))return;const t=await he(`${P}/api/trash/${encodeURIComponent(e.id)}`,{method:"DELETE"});if(!t.ok){const e=await t.json().catch(()=>({}));return void f.error(e.error||`Delete failed (${t.status})`)}fe()})(e),className:"px-2 py-0.5 rounded hover:bg-red-100 text-red-600 text-2xs ml-1",children:"Delete forever"})]})]},e.id))})]}):z&&0===O.length?/* @__PURE__ */T(k,{size:"sm",padding:"p-6",label:"Loading"}):0===O.length?/* @__PURE__ */L("div",{className:"p-10 text-center text-sm text-gray-400",children:["Empty folder.",!W&&/* @__PURE__ */L(E,{children:[" Drop files here or click ",
74
74
  /* @__PURE__ */T("span",{className:"font-medium",children:"Upload"}),"."]})]}):/* @__PURE__ */L("table",{className:"w-full text-sm",children:[
75
75
  /* @__PURE__ */T("thead",{className:"bg-gray-50 text-2xs uppercase tracking-wide text-gray-500",children:/* @__PURE__ */L("tr",{children:[
76
76
  /* @__PURE__ */T("th",{className:`${a} text-left font-medium px-3 h-8`,children:"Name"}),
77
77
  /* @__PURE__ */T("th",{className:`${a} text-right font-medium px-3 h-8 w-24`,children:"Size"}),
78
78
  /* @__PURE__ */T("th",{className:`${a} text-right font-medium px-3 h-8 w-40`,children:"Modified"}),
79
79
  /* @__PURE__ */T("th",{className:`${a} w-32`})]})}),
80
- /* @__PURE__ */T("tbody",{children:O.map(t=>/* @__PURE__ */L("tr",{onClick:()=>V(t.name),onDoubleClick:()=>{"folder"===t.kind?I(S(A,t.name)):(async t=>{if(W)return;const a=S(A,t.name),r=(t.name.split(".").pop()||"").toLowerCase(),n=F[r];n?await e({filePath:a,filename:t.name,kind:n,onStaged:e=>de(e)}):xe(t)})(t)},className:"cursor-default border-b border-gray-100 "+(H===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
80
+ /* @__PURE__ */T("tbody",{children:O.map(t=>/* @__PURE__ */L("tr",{onClick:()=>V(t.name),onDoubleClick:()=>{"folder"===t.kind?I(S(A,t.name)):(async t=>{if(W)return;const a=S(A,t.name),r=(t.name.split(".").pop()||"").toLowerCase(),n=F[r];n?await e({filePath:a,filename:t.name,kind:n,onStaged:e=>de(e)}):xe(t)})(t)},className:"cursor-default border-b border-gray-100 "+(K===t.name?"bg-blue-50":"hover:bg-gray-50"),children:[
81
81
  /* @__PURE__ */L("td",{className:"px-3 h-8 flex items-center gap-2",children:["folder"===t.kind?/* @__PURE__ */T(N,{name:"folder",look:"solid",className:"h-4 w-4 text-amber-500 shrink-0"}):/* @__PURE__ */T(N,{name:"page",className:"h-4 w-4 text-gray-400 shrink-0",strokeWidth:1.5}),
82
82
  /* @__PURE__ */T("span",{className:"truncate",title:t.name,children:t.name})]}),
83
83
  /* @__PURE__ */T("td",{className:"px-3 h-8 text-right tabular-nums text-gray-500",children:"folder"===t.kind?"—":w(t.size)}),
@@ -1,5 +1,5 @@
1
- import{getNumberingConfigs as e}from"./chunk-EQI47WNM.js";import{SidebarLayout as t}from"./chunk-BDXFODVC.js";import{AboutApp as r}from"./chunk-N6RZ56QX.js";import{toast_default as n}from"./chunk-BTLM7W6P.js";import"./chunk-KOKCGKQX.js";import{useWindowManager as o,client_default as i}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import{useShellPrefs as s}from"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-NVFKXL52.js";import"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as c}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{timeAgo as a}from"./chunk-W32SKK3D.js";import{useRef as l,useEffect as d,useState as p,useCallback as m}from"react";import{useQuery as u}from"@tanstack/react-query";import{jsxs as h,Fragment as y,jsx as g}from"react/jsx-runtime";var x=[{key:"yellow",bg:"bg-yellow-100",border:"border-yellow-300",text:"text-yellow-900",dot:"bg-yellow-400"},{key:"blue",bg:"bg-blue-100",border:"border-blue-300",text:"text-blue-900",dot:"bg-blue-400"},{key:"green",bg:"bg-green-100",border:"border-green-300",text:"text-green-900",dot:"bg-green-400"},{key:"pink",bg:"bg-pink-100",border:"border-pink-300",text:"text-pink-900",dot:"bg-pink-400"},{key:"purple",bg:"bg-purple-100",border:"border-purple-300",text:"text-purple-900",dot:"bg-purple-400"},{key:"orange",bg:"bg-orange-100",border:"border-orange-300",text:"text-orange-900",dot:"bg-orange-400"},{key:"white",bg:"bg-white",border:"border-gray-300",text:"text-gray-900",dot:"bg-gray-300"}];var b={sales_order:{entityType:"order",endpoint:"/orders/sales-orders/"},purchase_order:{entityType:"purchase_order",endpoint:"/purchase-orders/"},invoice:{entityType:"invoice",endpoint:"/invoicing/invoices/"},vendor_invoice:{entityType:"vendor_invoice",endpoint:"/invoicing/vendor-invoices/"},shipment:{entityType:"shipment",endpoint:"/shipments/delivery-notes/"},receipt:{entityType:"payment",endpoint:"/invoicing/payments/"},vendor_payment:{entityType:"vendor_payment",endpoint:"/invoicing/vendor-payments/"},vendor_price_sheet:{entityType:"vendor_price_sheet",endpoint:"/pricing/manufacturer-price-sheets/"},client_price_sheet:{entityType:"price_sheet",endpoint:"/pricing/price-sheets/"},qc_report:{entityType:"qc_report",endpoint:"/qc-reports/"},warranty_claim:{entityType:"warranty_claim",endpoint:"/warranty-claims/claims/"},vendor_shipment:{entityType:"vendor_shipment",endpoint:"/shipments/goods-receipts/"}},f=/\[([ xX]?)\]/g;function k(){const{openEntity:k}=o(),{prefs:v,save:N}=s(),{data:w}=u({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),_=l({});d(()=>{if(!w)return;const e={};for(const t of w){const r=b[t.entity_type];if(!r)continue;const n=(t.prefix||"").replace("#","").toUpperCase();if(n&&(e[n]={...r,prefix:t.prefix}),t.alt_prefix){const n=t.alt_prefix.replace("#","").toUpperCase();n&&(e[n]={...r,prefix:t.alt_prefix})}}_.current=e},[w]);const j=v.notepad_notes||[],[T,C]=p(null),[$,S]=p(""),[W,X]=p(""),[K,D]=p("yellow"),[O,I]=p(!1),[M,F]=p(!1),L=l(null),P=l(),A=j.find(e=>e.id===T);d(()=>{if(!T&&j.length>0){const e=j[0];C(e.id),S(e.title),X(e.content),D(e.color)}},[j.length]);const E=m(e=>{N({notepad_notes:e})},[N]),H=m(()=>{if(!T||!O)return;const e=j.map(e=>e.id===T?{...e,title:$,content:W,color:K,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);E(e),I(!1)},[T,O,$,W,K,j,E]);d(()=>{if(O)return P.current&&clearTimeout(P.current),P.current=setTimeout(H,800),()=>{P.current&&clearTimeout(P.current)}},[O,H]),d(()=>()=>{O&&H()},[]);const Q=e=>{O&&H(),C(e.id),S(e.title),X(e.content),D(e.color),I(!1),F(!1)},R=e=>{const t=W.slice(0,e),r=W.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=W.slice(e+r[0].length);X(t+n+o),I(!0)},q=async(e,t)=>{const r=_.current[e];if(!r)return;const o=`${e}#${t}`;try{const{data:e}=await i.get(r.endpoint,{params:{search:o,page_size:1}}),t=(e?.results??e??[])[0];t?k(r.entityType,t.id,t,o):n.error(`${o} not found`)}catch{n.error(`Failed to look up ${o}`)}},B="Start writing...\n\nTips:\n [] Type [] for a checkbox, click to toggle\n SO#35001 Type XX#NNNNN to link entities (SO, PO, CI, VI, PL, etc.)",U=/* @__PURE__ */h(y,{children:[
2
- /* @__PURE__ */g("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{O&&H();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",sticky:!1,updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...j];E(t),C(e.id),S(""),X(""),D("yellow"),I(!1),F(!0),setTimeout(()=>L.current?.focus(),50)},className:"w-full flex items-center justify-center gap-2 rounded-lg bg-blue-600 text-white px-3 min-h-8 py-1 text-sm font-medium hover:bg-blue-700 transition-colors",children:[
1
+ import{getNumberingConfigs as e}from"./chunk-EQI47WNM.js";import{SidebarLayout as t}from"./chunk-BDXFODVC.js";import{AboutApp as r}from"./chunk-FJBTASQI.js";import{toast_default as n}from"./chunk-BTLM7W6P.js";import"./chunk-QK67IFHD.js";import{useWindowManager as o,client_default as i}from"./chunk-HTHLFM24.js";import"./chunk-E5DFGCAL.js";import{useShellPrefs as s}from"./chunk-5MKWCHMD.js";import"./chunk-KNUR2UEG.js";import"./chunk-LTH3NJTS.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-NVFKXL52.js";import"./chunk-AEJQC7GF.js";import"./chunk-UVBK6YSR.js";import"./chunk-XZXMVACA.js";import"./chunk-WOZ36LPR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-K7PQXJO7.js";import"./chunk-D65T4H6J.js";import{Icon as c}from"./chunk-KMSAHFLP.js";import"./chunk-2PNYIWIN.js";import"./chunk-C3QOHMR6.js";import{timeAgo as a}from"./chunk-W32SKK3D.js";import{useRef as l,useEffect as d,useState as p,useCallback as m}from"react";import{useQuery as u}from"@tanstack/react-query";import{jsxs as h,Fragment as y,jsx as g}from"react/jsx-runtime";var x=[{key:"yellow",bg:"bg-yellow-100",border:"border-yellow-300",text:"text-yellow-900",dot:"bg-yellow-400"},{key:"blue",bg:"bg-blue-100",border:"border-blue-300",text:"text-blue-900",dot:"bg-blue-400"},{key:"green",bg:"bg-green-100",border:"border-green-300",text:"text-green-900",dot:"bg-green-400"},{key:"pink",bg:"bg-pink-100",border:"border-pink-300",text:"text-pink-900",dot:"bg-pink-400"},{key:"purple",bg:"bg-purple-100",border:"border-purple-300",text:"text-purple-900",dot:"bg-purple-400"},{key:"orange",bg:"bg-orange-100",border:"border-orange-300",text:"text-orange-900",dot:"bg-orange-400"},{key:"white",bg:"bg-white",border:"border-gray-300",text:"text-gray-900",dot:"bg-gray-300"}];var b={sales_order:{entityType:"order",endpoint:"/orders/sales-orders/"},purchase_order:{entityType:"purchase_order",endpoint:"/purchase-orders/"},invoice:{entityType:"invoice",endpoint:"/invoicing/invoices/"},vendor_invoice:{entityType:"vendor_invoice",endpoint:"/invoicing/vendor-invoices/"},shipment:{entityType:"shipment",endpoint:"/shipments/delivery-notes/"},receipt:{entityType:"payment",endpoint:"/invoicing/payments/"},vendor_payment:{entityType:"vendor_payment",endpoint:"/invoicing/vendor-payments/"},vendor_price_sheet:{entityType:"vendor_price_sheet",endpoint:"/pricing/manufacturer-price-sheets/"},client_price_sheet:{entityType:"price_sheet",endpoint:"/pricing/price-sheets/"},qc_report:{entityType:"qc_report",endpoint:"/qc-reports/"},warranty_claim:{entityType:"warranty_claim",endpoint:"/warranty-claims/claims/"},vendor_shipment:{entityType:"vendor_shipment",endpoint:"/shipments/goods-receipts/"}},f=/\[([ xX]?)\]/g;function k(){const{openEntity:k}=o(),{prefs:v,save:N}=s(),{data:w}=u({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),_=l({});d(()=>{if(!w)return;const e={};for(const t of w){const r=b[t.entity_type];if(!r)continue;const n=(t.prefix||"").replace("#","").toUpperCase();if(n&&(e[n]={...r,prefix:t.prefix}),t.alt_prefix){const n=t.alt_prefix.replace("#","").toUpperCase();n&&(e[n]={...r,prefix:t.alt_prefix})}}_.current=e},[w]);const j=v.notepad_notes||[],[T,C]=p(null),[$,S]=p(""),[W,X]=p(""),[D,I]=p("yellow"),[F,K]=p(!1),[O,M]=p(!1),A=l(null),H=l(),L=j.find(e=>e.id===T);d(()=>{if(!T&&j.length>0){const e=j[0];C(e.id),S(e.title),X(e.content),I(e.color)}},[j.length]);const P=m(e=>{N({notepad_notes:e})},[N]),E=m(()=>{if(!T||!F)return;const e=j.map(e=>e.id===T?{...e,title:$,content:W,color:D,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);P(e),K(!1)},[T,F,$,W,D,j,P]);d(()=>{if(F)return H.current&&clearTimeout(H.current),H.current=setTimeout(E,800),()=>{H.current&&clearTimeout(H.current)}},[F,E]),d(()=>()=>{F&&E()},[]);const Q=e=>{F&&E(),C(e.id),S(e.title),X(e.content),I(e.color),K(!1),M(!1)},B=e=>{const t=W.slice(0,e),r=W.slice(e).match(/^\[([ xX]?)\]/);if(!r)return;const n="x"===r[1]||"X"===r[1]?"[ ]":"[x]",o=W.slice(e+r[0].length);X(t+n+o),K(!0)},q=async(e,t)=>{const r=_.current[e];if(!r)return;const o=`${e}#${t}`;try{const{data:e}=await i.get(r.endpoint,{params:{search:o,page_size:1}}),t=(e?.results??e??[])[0];t?k(r.entityType,t.id,t,o):n.error(`${o} not found`)}catch{n.error(`Failed to look up ${o}`)}},R="Start writing...\n\nTips:\n [] Type [] for a checkbox, click to toggle\n SO#35001 Type XX#NNNNN to link entities (SO, PO, CI, VI, PL, etc.)",U=/* @__PURE__ */h(y,{children:[
2
+ /* @__PURE__ */g("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{F&&E();const e={id:`note-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,title:"",content:"",color:"yellow",sticky:!1,updated_at:/* @__PURE__ */(new Date).toISOString()},t=[e,...j];P(t),C(e.id),S(""),X(""),I("yellow"),K(!1),M(!0),setTimeout(()=>A.current?.focus(),50)},className:"w-full flex items-center justify-center gap-2 rounded-lg bg-blue-600 text-white px-3 min-h-8 py-1 text-sm font-medium hover:bg-blue-700 transition-colors",children:[
3
3
  /* @__PURE__ */g(c,{name:"add",className:"h-4 w-4",strokeWidth:2}),"New Note"]})}),
4
4
  /* @__PURE__ */g("div",{className:"flex-1 overflow-y-auto",children:0===j.length?/* @__PURE__ */g("p",{className:"text-sm text-gray-400 text-center py-8 px-4",children:"No notes yet. Create one to get started."}):j.map(e=>{const t=(r=e.color,x.find(e=>e.key===r)||x[0]);var r;/* @__PURE__ */
5
5
  return h("button",{onClick:()=>Q(e),className:"w-full text-left px-3 py-3 border-b border-gray-100 transition-colors "+(T===e.id?"bg-blue-50":"hover:bg-gray-50"),children:[
@@ -12,14 +12,14 @@ return h("div",{className:"h-full",children:[
12
12
  /* @__PURE__ */g(r,{app:"notepad"}),
13
13
  /* @__PURE__ */g(t,{sidebar:U,storageKey:"notepad.sidebarWidth",defaultWidth:224,minWidth:180,maxWidth:360,children:T?/* @__PURE__ */h("div",{className:"flex-1 flex flex-col min-w-0",children:[
14
14
  /* @__PURE__ */h("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200",children:[
15
- /* @__PURE__ */g("input",{value:$,onChange:e=>{S(e.target.value),I(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
16
- /* @__PURE__ */g("div",{className:"flex gap-1",children:x.map(e=>/* @__PURE__ */g("button",{onClick:()=>{D(e.key),I(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${K===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
17
- /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=j.map(t=>t.id===e?{...t,sticky:!t.sticky}:t);E(t);const r=t.find(t=>t.id===e);n.success(r?.sticky?"Pinned to desktop":"Removed from desktop")})(T),title:A?.sticky?"Remove from desktop":"Pin to desktop",className:"p-1 rounded transition-colors "+(A?.sticky?"text-amber-500 hover:text-amber-600":"text-gray-300 hover:text-amber-400"),children:/* @__PURE__ */g(c,{name:"bookmark",className:"h-4 w-4",fill:A?.sticky?"currentColor":"none",strokeWidth:1.5})}),
18
- /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=j.filter(t=>t.id!==e);if(E(t),T===e){const e=t[0];e?Q(e):(C(null),S(""),X(""))}})(T),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */g(c,{name:"trash",className:"h-4 w-4",strokeWidth:1.5})})]}),M?/* @__PURE__ */g("textarea",{ref:L,value:W,onChange:e=>{X(e.target.value),I(!0)},onBlur:()=>{F(!1),O&&H()},placeholder:B,className:"flex-1 p-4 text-sm text-gray-700 outline-none resize-none bg-transparent leading-relaxed placeholder:text-gray-300 font-mono"}):/* @__PURE__ */g("div",{onClick:()=>{F(!0),setTimeout(()=>L.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:W?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],s=/([A-Z]{2,4})#(\d{4,6})/g;let a;for(;null!==(a=s.exec(e));){const e=a[1],t=a[2];if(_.current[e]){const n=a.index,o=a[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */g("button",{onClick:()=>q(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}f.lastIndex=0;let l=0;for(let e=0;e<r;e++)l+=t[e].length+1;for(;null!==(a=f.exec(e));){const e="x"===a[1]||"X"===a[1],t=a.index,n=l+t;i.push({idx:t,len:a[0].length,render:()=>/* @__PURE__ */g("button",{onClick:()=>R(n),className:`inline-flex items-center justify-center w-4 h-4 rounded border ${e?"bg-blue-500 border-blue-500 text-white":"border-gray-400 bg-white hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:e&&/* @__PURE__ */g(c,{name:"check",className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */g("span",{children:e.slice(o,t.idx)},`t-${r}-${o}`)),n.push(t.render()),o=t.idx+t.len;o<e.length&&n.push(/* @__PURE__ */g("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */g("span",{children:"​"},`empty-${r}`));const d=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
19
- return g("div",{className:d?"line-through text-gray-400":"",children:n},r)})})(W):/* @__PURE__ */g("p",{className:"text-gray-300 whitespace-pre-line",children:B})}),
15
+ /* @__PURE__ */g("input",{value:$,onChange:e=>{S(e.target.value),K(!0)},placeholder:"Note title...",className:"flex-1 text-lg font-semibold text-gray-900 outline-none bg-transparent placeholder:text-gray-300"}),
16
+ /* @__PURE__ */g("div",{className:"flex gap-1",children:x.map(e=>/* @__PURE__ */g("button",{onClick:()=>{I(e.key),K(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${D===e.key?"border-gray-600 scale-110":"border-transparent hover:border-gray-400"}`,title:e.key},e.key))}),
17
+ /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=j.map(t=>t.id===e?{...t,sticky:!t.sticky}:t);P(t);const r=t.find(t=>t.id===e);n.success(r?.sticky?"Pinned to desktop":"Removed from desktop")})(T),title:L?.sticky?"Remove from desktop":"Pin to desktop",className:"p-1 rounded transition-colors "+(L?.sticky?"text-amber-500 hover:text-amber-600":"text-gray-300 hover:text-amber-400"),children:/* @__PURE__ */g(c,{name:"bookmark",className:"h-4 w-4",fill:L?.sticky?"currentColor":"none",strokeWidth:1.5})}),
18
+ /* @__PURE__ */g("button",{onClick:()=>(e=>{const t=j.filter(t=>t.id!==e);if(P(t),T===e){const e=t[0];e?Q(e):(C(null),S(""),X(""))}})(T),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */g(c,{name:"trash",className:"h-4 w-4",strokeWidth:1.5})})]}),O?/* @__PURE__ */g("textarea",{ref:A,value:W,onChange:e=>{X(e.target.value),K(!0)},onBlur:()=>{M(!1),F&&E()},placeholder:R,className:"flex-1 p-4 text-sm text-gray-700 outline-none resize-none bg-transparent leading-relaxed placeholder:text-gray-300 font-mono"}):/* @__PURE__ */g("div",{onClick:()=>{M(!0),setTimeout(()=>A.current?.focus(),50)},className:"flex-1 p-4 text-sm text-gray-700 overflow-y-auto leading-relaxed cursor-text",children:W?(e=>{if(!e)return[];const t=e.split("\n");return t.map((e,r)=>{const n=[];let o=0;const i=[],s=/([A-Z]{2,4})#(\d{4,6})/g;let a;for(;null!==(a=s.exec(e));){const e=a[1],t=a[2];if(_.current[e]){const n=a.index,o=a[0];i.push({idx:n,len:o.length,render:()=>/* @__PURE__ */g("button",{onClick:()=>q(e,t),className:"text-blue-600 hover:text-blue-800 hover:underline font-medium cursor-pointer",children:o},`ref-${r}-${n}`)})}}f.lastIndex=0;let l=0;for(let e=0;e<r;e++)l+=t[e].length+1;for(;null!==(a=f.exec(e));){const e="x"===a[1]||"X"===a[1],t=a.index,n=l+t;i.push({idx:t,len:a[0].length,render:()=>/* @__PURE__ */g("button",{onClick:()=>B(n),className:`inline-flex items-center justify-center w-4 h-4 rounded border ${e?"bg-blue-500 border-blue-500 text-white":"border-gray-400 bg-white hover:border-blue-400"} cursor-pointer align-text-bottom mr-0.5`,children:e&&/* @__PURE__ */g(c,{name:"check",className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */g("span",{children:e.slice(o,t.idx)},`t-${r}-${o}`)),n.push(t.render()),o=t.idx+t.len;o<e.length&&n.push(/* @__PURE__ */g("span",{children:e.slice(o)},`t-${r}-${o}`)),0===n.length&&n.push(/* @__PURE__ */g("span",{children:"​"},`empty-${r}`));const d=/^\[x\]/i.test(e.trimStart());/* @__PURE__ */
19
+ return g("div",{className:d?"line-through text-gray-400":"",children:n},r)})})(W):/* @__PURE__ */g("p",{className:"text-gray-300 whitespace-pre-line",children:R})}),
20
20
  /* @__PURE__ */h("div",{className:"px-4 min-h-8 py-1 border-t border-gray-100 flex items-center gap-4 text-2xs text-gray-400",children:[
21
21
  /* @__PURE__ */g("span",{children:"[] checkbox"}),
22
22
  /* @__PURE__ */g("span",{children:"SO#35001 entity link"}),
23
- /* @__PURE__ */g("span",{className:"ml-auto",children:M?"Editing":"Click to edit"})]})]}):/* @__PURE__ */g("div",{className:"flex-1 flex items-center justify-center",children:/* @__PURE__ */h("div",{className:"text-center text-gray-400",children:[
23
+ /* @__PURE__ */g("span",{className:"ml-auto",children:O?"Editing":"Click to edit"})]})]}):/* @__PURE__ */g("div",{className:"flex-1 flex items-center justify-center",children:/* @__PURE__ */h("div",{className:"text-center text-gray-400",children:[
24
24
  /* @__PURE__ */g(c,{name:"page",className:"h-12 w-12 mx-auto mb-3 text-gray-300",strokeWidth:1}),
25
25
  /* @__PURE__ */g("p",{className:"text-sm",children:"Select a note or create a new one"})]})})})]})}export{k as default};