efficient-shell 5.6.1 → 6.4.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 (112) hide show
  1. package/README.md +184 -44
  2. package/THIRD_PARTY_NOTICES.md +212 -0
  3. package/dist/Browser-USPZWDYH.js +43 -0
  4. package/dist/Calculator-FP5HUWCW.js +29 -0
  5. package/dist/ConfirmDialog-3TIHKJRT.js +1 -0
  6. package/dist/{CurrencyConverter-2IGOOR3I.js → CurrencyConverter-XD5LYOCD.js} +8 -8
  7. package/dist/Documents-ADFEHEUW.js +52 -0
  8. package/dist/Files-BVUVRNC5.js +87 -0
  9. package/dist/Notepad-WJI5ODGS.js +25 -0
  10. package/dist/PdfViewer-226I3LSD.js +1 -0
  11. package/dist/PomodoroTimer-GEMQHIPJ.js +91 -0
  12. package/dist/Preview-HNSEYNZL.js +182 -0
  13. package/dist/Sidebar-PVHZPNIY.js +44 -0
  14. package/dist/{Spreadsheet-SRAUU3OA.js → Spreadsheet-6Z5ACGTT.js} +14 -14
  15. package/dist/{Stock-7EKOAQ7C.js → Stock-X3LIU4ZX.js} +4 -4
  16. package/dist/{Weather-RWI6NKB2.js → Weather-BLO354GM.js} +14 -14
  17. package/dist/{WorldClock-CEHWDFEO.js → WorldClock-BAH7QFRG.js} +7 -7
  18. package/dist/apps/index.js +1 -1
  19. package/dist/bin/ui-check.js +1 -1
  20. package/dist/brand.css +1 -1
  21. package/dist/chunk-2SSRFEOZ.js +91 -0
  22. package/dist/{chunk-TFETN2GI.js → chunk-4JZZLUGG.js} +1 -1
  23. package/dist/{chunk-GG7AE6OC.js → chunk-5K76RQML.js} +1 -1
  24. package/dist/chunk-5LUN632W.js +5 -0
  25. package/dist/chunk-5MDQNFOG.js +9 -0
  26. package/dist/chunk-7IQ3B77H.js +1 -0
  27. package/dist/{chunk-SKB6L53D.js → chunk-7PGHRG6J.js} +9 -9
  28. package/dist/chunk-CXJQ42XT.js +21 -0
  29. package/dist/chunk-DBXZS7OA.js +29 -0
  30. package/dist/{chunk-X4FJ54PP.js → chunk-FIEA5CGB.js} +1 -1
  31. package/dist/chunk-GJ37JCC2.js +1 -0
  32. package/dist/{chunk-KXAUDC3A.js → chunk-GWDVD3VQ.js} +27 -27
  33. package/dist/chunk-HQLAISFX.js +11 -0
  34. package/dist/chunk-I2H2CKID.js +3 -0
  35. package/dist/{chunk-YIH6JLMV.js → chunk-I534M65N.js} +2 -2
  36. package/dist/{chunk-WWF2EQXF.js → chunk-IHZL3GJU.js} +1 -1
  37. package/dist/chunk-K6DKX55N.js +1 -0
  38. package/dist/chunk-KNUR2UEG.js +1 -0
  39. package/dist/{chunk-JXAAZGLJ.js → chunk-MORDXCV6.js} +1 -1
  40. package/dist/chunk-PFKMIPZH.js +1028 -0
  41. package/dist/chunk-PJPK2ADX.js +1 -0
  42. package/dist/chunk-Q5O5UMJY.js +6 -0
  43. package/dist/chunk-QJHWLDEN.js +108 -0
  44. package/dist/chunk-R5VRLW5Z.js +1 -0
  45. package/dist/chunk-S3LGKIZ3.js +12 -0
  46. package/dist/chunk-SBF5A6XV.js +1 -0
  47. package/dist/chunk-SK5DL6JX.js +24 -0
  48. package/dist/{chunk-CLPJDJH4.js → chunk-UUYPUKP7.js} +1 -1
  49. package/dist/{chunk-AFYQTVZO.js → chunk-UVBK6YSR.js} +1 -1
  50. package/dist/chunk-VR6TR575.js +13 -0
  51. package/dist/{chunk-7WC3EOFS.js → chunk-XO2AMGVU.js} +1 -1
  52. package/dist/{chunk-N3A3GWJI.js → chunk-YX2IMURA.js} +12 -12
  53. package/dist/chunk-ZEIKSMFR.js +10 -0
  54. package/dist/client-DLm3Fvbc.d.ts +65 -0
  55. package/dist/file-intake/index.js +1 -1
  56. package/dist/i18n/index.d.ts +1 -1
  57. package/dist/icons/efficient-looks.d.ts +1 -1
  58. package/dist/icons/efficient.d.ts +1 -1
  59. package/dist/icons/index.d.ts +12 -12
  60. package/dist/icons/index.js +1 -1
  61. package/dist/{index-ZI6vl2Wq.d.ts → index-D5bms_uA.d.ts} +186 -76
  62. package/dist/index.d.ts +6 -4
  63. package/dist/index.js +639 -639
  64. package/dist/locales/zh-Hans.d.ts +1 -1
  65. package/dist/locales/zh-Hans.js +1 -1
  66. package/dist/map/index.js +22 -22
  67. package/dist/markdown/index.js +6 -6
  68. package/dist/markup/index.d.ts +460 -36
  69. package/dist/markup/index.js +1 -1
  70. package/dist/page-tabs/index.js +5 -5
  71. package/dist/pdf/index.js +1 -1
  72. package/dist/{registry-J-TU7zKx.d.ts → registry-Dw6QO2Ch.d.ts} +12 -9
  73. package/dist/{strings-BVB64Nck.d.ts → strings-fYzxZPn4.d.ts} +5 -0
  74. package/dist/telemetry/index.d.ts +39 -0
  75. package/dist/telemetry/index.js +1 -0
  76. package/dist/ui/index.d.ts +4 -3
  77. package/dist/ui/index.js +1 -1
  78. package/dist/ui.css +62 -21
  79. package/package.json +7 -21
  80. package/dist/Browser-RXGEZ77D.js +0 -43
  81. package/dist/Calculator-MVPKTZZF.js +0 -29
  82. package/dist/ConfirmDialog-XOYCYFA7.js +0 -1
  83. package/dist/Documents-YBLR7WVX.js +0 -52
  84. package/dist/Files-7XNR5IL2.js +0 -87
  85. package/dist/Notepad-ZQYQXV75.js +0 -25
  86. package/dist/PdfViewer-SQVMMA7B.js +0 -1
  87. package/dist/PomodoroTimer-XIUN4M73.js +0 -91
  88. package/dist/Preview-YCOA5JPP.js +0 -182
  89. package/dist/Sidebar-VI7E3EKI.js +0 -44
  90. package/dist/chunk-3HJTOINK.js +0 -1
  91. package/dist/chunk-4SWPNARR.js +0 -5
  92. package/dist/chunk-5ABLFFC5.js +0 -24
  93. package/dist/chunk-6LTDJKIL.js +0 -138
  94. package/dist/chunk-F6B3J3GW.js +0 -6
  95. package/dist/chunk-HZZNJHRH.js +0 -1
  96. package/dist/chunk-IMMHJIV5.js +0 -29
  97. package/dist/chunk-OGXU7QFW.js +0 -12
  98. package/dist/chunk-P4CIOJHP.js +0 -3
  99. package/dist/chunk-RBDGN4YU.js +0 -9
  100. package/dist/chunk-RC2EG6P4.js +0 -1026
  101. package/dist/chunk-RL626E7Q.js +0 -13
  102. package/dist/chunk-RMJZOKHY.js +0 -10
  103. package/dist/chunk-SFCDHHQP.js +0 -1
  104. package/dist/chunk-TNBCUZVE.js +0 -1
  105. package/dist/chunk-VWBQ2P5G.js +0 -108
  106. package/dist/chunk-XWSWYMGM.js +0 -2
  107. package/dist/chunk-YGC7AX3X.js +0 -11
  108. package/dist/chunk-Z7D6Y5WA.js +0 -21
  109. package/dist/icons/heroicons.d.ts +0 -6
  110. package/dist/icons/heroicons.js +0 -1
  111. package/dist/icons/lucide.d.ts +0 -6
  112. package/dist/icons/lucide.js +0 -1
@@ -0,0 +1,25 @@
1
+ import{getNumberingConfigs as e}from"./chunk-IHZL3GJU.js";import{SidebarLayout as t}from"./chunk-5LUN632W.js";import{AboutApp as r}from"./chunk-5MDQNFOG.js";import{useWindowManager as n,client_default as o}from"./chunk-QJHWLDEN.js";import"./chunk-DSSLOQDW.js";import"./chunk-I2H2CKID.js";import{toast_default as i}from"./chunk-GJ37JCC2.js";import{useShellPrefs as s}from"./chunk-HQLAISFX.js";import"./chunk-5A7MWTXX.js";import"./chunk-S3LGKIZ3.js";import"./chunk-DBXZS7OA.js";import"./chunk-ZEIKSMFR.js";import"./chunk-UVBK6YSR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-SBF5A6XV.js";import"./chunk-KNUR2UEG.js";import{timeAgo as a}from"./chunk-W32SKK3D.js";import"./chunk-K6DKX55N.js";import"./chunk-C3QOHMR6.js";import{Icon as l}from"./chunk-2SSRFEOZ.js";import{useRef as c,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}=n(),{prefs:v,save:N}=s(),{data:w}=u({queryKey:["numbering-configs"],queryFn:()=>e(),retry:!1}),_=c({});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,S]=p(null),[C,$]=p(""),[W,D]=p(""),[I,X]=p("yellow"),[K,O]=p(!1),[E,F]=p(!1),U=c(null),H=c(),L=j.find(e=>e.id===T);d(()=>{if(!T&&j.length>0){const e=j[0];S(e.id),$(e.title),D(e.content),X(e.color)}},[j.length]);const R=m(e=>{N({notepad_notes:e})},[N]),q=m(()=>{if(!T||!K)return;const e=j.map(e=>e.id===T?{...e,title:C,content:W,color:I,updated_at:/* @__PURE__ */(new Date).toISOString()}:e);R(e),O(!1)},[T,K,C,W,I,j,R]);d(()=>{if(K)return H.current&&clearTimeout(H.current),H.current=setTimeout(q,800),()=>{H.current&&clearTimeout(H.current)}},[K,q]),d(()=>()=>{K&&q()},[]);const A=e=>{K&&q(),S(e.id),$(e.title),D(e.content),X(e.color),O(!1),F(!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);D(t+n+o),O(!0)},G=async(e,t)=>{const r=_.current[e];if(!r)return;const n=`${e}#${t}`;try{const{data:e}=await o.get(r.endpoint,{params:{search:n,page_size:1}}),t=(e?.results??e??[])[0];t?k(r.entityType,t.id,t,n):i.error(`${n} not found`)}catch{i.error(`Failed to look up ${n}`)}},Q="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.)",Z=/* @__PURE__ */h(y,{children:[
2
+ /* @__PURE__ */g("div",{className:"p-2 border-b border-gray-200",children:/* @__PURE__ */h("button",{onClick:()=>{K&&q();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];R(t),S(e.id),$(""),D(""),X("yellow"),O(!1),F(!0),setTimeout(()=>U.current?.focus(),50)},className:"w-full flex items-center justify-center gap-1.5 rounded-lg bg-blue-600 text-white px-3 py-1.5 text-sm font-medium hover:bg-blue-700 transition-colors",children:[
3
+ /* @__PURE__ */g(l,{name:"add",className:"h-4 w-4",strokeWidth:2}),"New Note"]})}),
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
+ return h("button",{onClick:()=>A(e),className:"w-full text-left px-3 py-2.5 border-b border-gray-100 transition-colors "+(T===e.id?"bg-blue-50":"hover:bg-gray-50"),children:[
6
+ /* @__PURE__ */h("div",{className:"flex items-center gap-2",children:[
7
+ /* @__PURE__ */g("div",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${t.dot}`}),
8
+ /* @__PURE__ */g("span",{className:"text-sm font-medium text-gray-900 truncate flex-1",children:e.title||"Untitled"}),e.sticky&&/* @__PURE__ */g(l,{name:"bookmark",look:"solid",className:"h-3 w-3 text-amber-500 shrink-0"})]}),
9
+ /* @__PURE__ */g("p",{className:"text-xs text-gray-400 mt-0.5 truncate ml-4.5",children:e.content.replace(/\[[ xX]?\]/g,"").slice(0,60)||"Empty note"}),
10
+ /* @__PURE__ */g("p",{className:"text-[10px] text-gray-300 mt-0.5 ml-4.5",children:a(e.updated_at)})]},e.id)})})]});/* @__PURE__ */
11
+ return h("div",{className:"h-full",children:[
12
+ /* @__PURE__ */g(r,{app:"notepad"}),
13
+ /* @__PURE__ */g(t,{sidebar:Z,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
+ /* @__PURE__ */h("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200",children:[
15
+ /* @__PURE__ */g("input",{value:C,onChange:e=>{$(e.target.value),O(!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:()=>{X(e.key),O(!0)},className:`w-5 h-5 rounded-full border-2 transition-all ${e.dot} ${I===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);R(t);const r=t.find(t=>t.id===e);i.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(l,{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(R(t),T===e){const e=t[0];e?A(e):(S(null),$(""),D(""))}})(T),title:"Delete note",className:"p-1 rounded text-gray-300 hover:text-red-500 transition-colors",children:/* @__PURE__ */g(l,{name:"trash",className:"h-4 w-4",strokeWidth:1.5})})]}),E?/* @__PURE__ */g("textarea",{ref:U,value:W,onChange:e=>{D(e.target.value),O(!0)},onBlur:()=>{F(!1),K&&q()},placeholder:Q,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(()=>U.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:()=>G(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 c=0;for(let e=0;e<r;e++)c+=t[e].length+1;for(;null!==(a=f.exec(e));){const e="x"===a[1]||"X"===a[1],t=a.index,n=c+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(l,{name:"check",className:"w-3 h-3",strokeWidth:3})},`cb-${r}-${t}`)})}i.sort((e,t)=>e.idx-t.idx);for(const t of i)t.idx>o&&n.push(/* @__PURE__ */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:Q})}),
20
+ /* @__PURE__ */h("div",{className:"px-4 py-1.5 border-t border-gray-100 flex items-center gap-4 text-[10px] text-gray-400",children:[
21
+ /* @__PURE__ */g("span",{children:"[] checkbox"}),
22
+ /* @__PURE__ */g("span",{children:"SO#35001 entity link"}),
23
+ /* @__PURE__ */g("span",{className:"ml-auto",children:E?"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
+ /* @__PURE__ */g(l,{name:"page",className:"h-12 w-12 mx-auto mb-3 text-gray-300",strokeWidth:1}),
25
+ /* @__PURE__ */g("p",{className:"text-sm",children:"Select a note or create a new one"})]})})})]})}export{k as default};
@@ -0,0 +1 @@
1
+ export{PdfViewer as default,fitScale,pdfWasmParams}from"./chunk-SK5DL6JX.js";import"./chunk-GJ37JCC2.js";import"./chunk-K6DKX55N.js";import"./chunk-C3QOHMR6.js";import"./chunk-2SSRFEOZ.js";
@@ -0,0 +1,91 @@
1
+ import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-XO2AMGVU.js";import{subscribePomo as a,getPomoSnapshot as o,setPomoDurations as n,setPomoAlarm as r,setPomoAlarmConfig as s,setPomoBehaviour as l,setPomoFocusSound as i,useTodoTasks as c,migratePomodoroTasksOnce as d,pomoSwitchMode as u,pomoPause as m,pomoStart as h,ALARM_OPTIONS as p,playAlarm as g,FOCUS_SOUND_OPTIONS as f,previewFocusSound as b}from"./chunk-I534M65N.js";import{useWidgetSettings as k}from"./chunk-QJHWLDEN.js";import"./chunk-DSSLOQDW.js";import"./chunk-I2H2CKID.js";import"./chunk-GJ37JCC2.js";import{useShellPrefs as x}from"./chunk-HQLAISFX.js";import"./chunk-5A7MWTXX.js";import"./chunk-S3LGKIZ3.js";import"./chunk-DBXZS7OA.js";import"./chunk-ZEIKSMFR.js";import"./chunk-UVBK6YSR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-KNUR2UEG.js";import"./chunk-K6DKX55N.js";import"./chunk-C3QOHMR6.js";import{Icon as v}from"./chunk-2SSRFEOZ.js";import{useSyncExternalStore as y,useEffect as N,useMemo as w,useState as S,useRef as C,useCallback as B}from"react";import{jsxs as M,Fragment as j,jsx as T}from"react/jsx-runtime";var I="pomodoro_appearance",P="pomodoro_active_task_id",A={focus:"Pomodoro",short:"Short Break",long:"Long Break"},D={focus:"#0f172a",short:"#508a52",long:"#5b7898"};var $=25,L=5,V=15,R=!1,E=!1,_=4,F=!0,O=!0,W="bell",K=100,H=1,U="none",X=50,z=(e,t,a,o)=>"number"==typeof e&&isFinite(e)?Math.max(t,Math.min(a,Math.round(e))):o;function G(){const t=y(a,o,o),{prefs:g,save:b}=x(),G=function(e){const t=e&&"object"==typeof e?e:{};return{focusMinutes:z(t.focusMinutes,1,120,$),shortBreakMinutes:z(t.shortBreakMinutes,1,120,L),longBreakMinutes:z(t.longBreakMinutes,1,120,V),autoStartBreaks:"boolean"==typeof t.autoStartBreaks?t.autoStartBreaks:R,autoStartPomodoros:"boolean"==typeof t.autoStartPomodoros?t.autoStartPomodoros:E,longBreakInterval:z(t.longBreakInterval,1,20,_),autoCheckTasks:"boolean"==typeof t.autoCheckTasks?t.autoCheckTasks:F,checkToBottom:"boolean"==typeof t.checkToBottom?t.checkToBottom:O,alarmSound:p.some(e=>e.id===t.alarmSound)?t.alarmSound:W,alarmVolume:z(t.alarmVolume,0,100,K),alarmRepeat:z(t.alarmRepeat,1,5,H),focusSound:f.some(e=>e.id===t.focusSound)?t.focusSound:U,focusVolume:z(t.focusVolume,0,100,X)}}(g.pomodoro_settings);N(()=>{n({focus:60*G.focusMinutes,short:60*G.shortBreakMinutes,long:60*G.longBreakMinutes})},[G.focusMinutes,G.shortBreakMinutes,G.longBreakMinutes]),N(()=>{r(G.alarmSound),s(G.alarmVolume,G.alarmRepeat)},[G.alarmSound,G.alarmVolume,G.alarmRepeat]),N(()=>{l({autoStartBreaks:G.autoStartBreaks,autoStartPomodoros:G.autoStartPomodoros,longBreakInterval:G.longBreakInterval})},[G.autoStartBreaks,G.autoStartPomodoros,G.longBreakInterval]),N(()=>{i(G.focusSound,G.focusVolume)},[G.focusSound,G.focusVolume]),N(()=>{if("undefined"!=typeof Notification&&"default"===Notification.permission)try{Notification.requestPermission()}catch{}},[]);const Q=c(),Z=Q.tasks,q=w(()=>/* @__PURE__ */(new Date).toISOString().slice(0,10),[]),Y=function(e,t){return w(()=>t?(e=>{const t=[],a=[];for(const o of e)(o.done?a:t).push(o);return[...t,...a]})(e):e,[e,t])}(w(()=>Z.filter(e=>!!e.dueDate&&(e.dueDate===q||e.dueDate<q&&!e.done)),[Z,q]),G.checkToBottom),[ee,te]=S(()=>localStorage.getItem(P)),[ae,oe]=S(!1),[ne,re]=S(null),se=C(!1);N(()=>{se.current||(se.current=!0,d(Z,Q.setAllTasks))},[]),N(()=>{try{ee?localStorage.setItem(P,ee):localStorage.removeItem(P)}catch{}},[ee]),N(()=>{if(!ne)return;const e=()=>re(null),t=setTimeout(()=>document.addEventListener("click",e),0);return()=>{clearTimeout(t),document.removeEventListener("click",e)}},[ne]);const ie=C(t.streak);N(()=>{if(t.streak>ie.current&&ee){const e=Z.find(e=>e.id===ee);if(e){const t=(e.completed??0)+1,a=e.estimated??0,o=G.autoCheckTasks&&a>0&&t>=a;Q.updateTask(ee,{completed:t,done:e.done||o})}}ie.current=t.streak},[t.streak,ee,G.autoCheckTasks,Z,Q]);const ce=Y.reduce((e,t)=>e+(t.completed??0),0),de=Y.reduce((e,t)=>e+Math.max(t.estimated??0,t.completed??0),0),ue=Y.reduce((e,t)=>t.done?e:e+Math.max(0,(t.estimated??0)-(t.completed??0)),0),me=t.running&&"focus"===t.mode?t.remaining:0,he=ue*G.focusMinutes*60+me,pe=new Date(Date.now()+1e3*he).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1}),ge=(he/3600).toFixed(1),fe=ee?Z.find(e=>e.id===ee)??null:null,be=String(Math.floor(t.remaining/60)).padStart(2,"0"),ke=String(t.remaining%60).padStart(2,"0"),[xe,ve]=S(()=>e(I)),[ye,Ne]=S(!1),[we,Se]=S(xe),[Ce,Be]=S(G);k(B(()=>{Se({...xe}),Be({...G}),Ne(!0)},[xe,G]));const Me="focus"!==t.mode,je=D[t.mode],Te=Me?(Ie=je,Pe=xe.activeOpacity/100,`rgba(${parseInt(Ie.slice(1,3),16)}, ${parseInt(Ie.slice(3,5),16)}, ${parseInt(Ie.slice(5,7),16)}, ${Pe})`):`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${xe.activeOpacity/100})`;var Ie,Pe;const Ae={primary:Me?"text-white":"text-gray-900",secondary:Me?"text-white/85":"text-gray-700",muted:Me?"text-white/65":"text-gray-500",tabActive:Me?"bg-white/15 text-white":"bg-gray-200 text-gray-900",tabInactive:Me?"text-white/75 hover:bg-white/10":"text-gray-500 hover:bg-gray-200",divider:Me?"border-white/30":"border-gray-200",softDivider:Me?"border-white/20":"border-gray-200",iconBtn:Me?"bg-black/15 hover:bg-black/25 text-white/85":"bg-gray-200 hover:bg-gray-300 text-gray-600",addTaskBtn:Me?"border-white/45 text-white/90 hover:bg-white/[0.06]":"border-gray-300 text-gray-500 hover:bg-gray-200/50"},De=Me?je:"#0f172a";/* @__PURE__ */
2
+ return M(j,{children:[
3
+ /* @__PURE__ */M("div",{className:`flex flex-col h-full select-none transition-colors duration-300 ${Ae.primary}`,style:{backgroundColor:Te,backdropFilter:xe.activeBlur>0?`blur(${xe.activeBlur}px)`:void 0},children:[
4
+ /* @__PURE__ */T("div",{className:"px-3 pt-3 flex justify-center gap-1.5",children:["focus","short","long"].map(e=>/* @__PURE__ */T("button",{onClick:()=>u(e),className:`px-2.5 py-1 text-[13px] font-bold rounded transition-colors ${t.mode===e?Ae.tabActive:Ae.tabInactive}`,children:A[e]},e))}),
5
+ /* @__PURE__ */M("div",{className:"text-center font-bold tabular-nums leading-none tracking-tight mt-3",style:{fontSize:"4.5rem"},children:[be,":",ke]}),
6
+ /* @__PURE__ */T("div",{className:"flex justify-center mt-3 mb-2",children:/* @__PURE__ */T("button",{onClick:()=>t.running?m():h(),className:"bg-white px-12 py-2.5 rounded-md font-bold text-base shadow-[0_4px_0_rgba(0,0,0,0.12)] hover:shadow-[0_3px_0_rgba(0,0,0,0.12)] active:translate-y-1 active:shadow-none transition-all",style:{color:De,letterSpacing:"0.08em"},children:t.running?"PAUSE":"START"})}),
7
+ /* @__PURE__ */T("div",{className:"px-3 py-3 text-center",children:fe?/* @__PURE__ */M(j,{children:[
8
+ /* @__PURE__ */M("div",{className:`text-xs leading-tight ${Ae.muted}`,children:["#",(fe.completed??0)+1]}),
9
+ /* @__PURE__ */T("div",{className:`text-[15px] font-medium leading-tight truncate mt-0.5 ${Ae.primary}`,children:fe.name})]}):/* @__PURE__ */T("div",{className:`text-xs italic ${Ae.muted}`,children:"No task selected"})}),
10
+ /* @__PURE__ */M("div",{className:"px-3 mt-1 flex items-center justify-between",children:[
11
+ /* @__PURE__ */T("h3",{className:`text-base font-bold tracking-tight ${Ae.primary}`,children:"Tasks"}),
12
+ /* @__PURE__ */T("button",{className:`rounded p-1 transition-colors ${Ae.iconBtn}`,"aria-label":"Tasks menu",tabIndex:-1,children:/* @__PURE__ */T(v,{name:"more-vertical",look:"solid",className:"h-4 w-4"})})]}),
13
+ /* @__PURE__ */T("div",{className:`border-t mx-3 mt-2 ${Ae.divider}`}),
14
+ /* @__PURE__ */M("div",{className:"flex-1 px-3 py-3 space-y-2 overflow-y-auto",children:[Y.map(e=>{const t=e.id===ee;/* @__PURE__ */
15
+ return M("div",{onClick:()=>te(e.id),className:"bg-white text-gray-800 rounded-md flex items-center pr-2 py-2.5 shadow-sm cursor-pointer transition-shadow hover:shadow-md "+(t?"border-l-4 border-gray-700 pl-2":"pl-3 border-l-4 border-transparent"),children:[
16
+ /* @__PURE__ */T("button",{onClick:t=>{var a;t.stopPropagation(),a=e.id,Q.toggleDone(a)},className:"shrink-0",children:e.done?/* @__PURE__ */T("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",style:{color:De},children:/* @__PURE__ */T("path",{d:"M10 0a10 10 0 100 20 10 10 0 000-20zm-1 14.5l-4.5-4.5 1.4-1.4 3.1 3.1 6.1-6.1 1.4 1.4z"})}):/* @__PURE__ */T("svg",{className:"h-5 w-5 text-gray-300",fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:/* @__PURE__ */T("circle",{cx:"12",cy:"12",r:"10"})})}),
17
+ /* @__PURE__ */T("span",{className:"ml-3 flex-1 font-semibold truncate "+(e.done?"line-through text-gray-400":"text-gray-800"),children:e.name}),
18
+ /* @__PURE__ */M("span",{className:"text-sm tabular-nums mr-1.5 shrink-0",children:[
19
+ /* @__PURE__ */T("span",{className:"font-bold text-gray-500",children:e.completed??0}),
20
+ /* @__PURE__ */T("span",{className:"text-gray-400",children:" / "}),
21
+ /* @__PURE__ */T("span",{className:"text-gray-400",children:e.estimated??"–"})]}),
22
+ /* @__PURE__ */M("div",{className:"relative",children:[
23
+ /* @__PURE__ */T("button",{onClick:t=>{t.stopPropagation(),re(ne===e.id?null:e.id)},className:"rounded p-1 bg-gray-100 hover:bg-gray-200",children:/* @__PURE__ */T(v,{name:"more-vertical",look:"solid",className:"h-4 w-4 text-gray-500"})}),ne===e.id&&/* @__PURE__ */T("div",{className:"absolute right-0 top-full mt-1 bg-white text-gray-800 rounded shadow-lg border border-gray-200 z-10 min-w-[110px] overflow-hidden",onClick:e=>e.stopPropagation(),children:/* @__PURE__ */T("button",{onClick:t=>{var a;t.stopPropagation(),a=e.id,Q.removeTask(a),ee===a&&te(null),re(null)},className:"block w-full px-3 py-1.5 text-sm text-left hover:bg-red-50 text-red-600",children:"Delete"})})]})]},e.id)}),ae?/* @__PURE__ */T(le,{onSubmit:(e,t)=>{const a=e.trim();if(!a)return;const o=Q.addTask({name:a,estimated:t,completed:0,dueDate:q});ee||te(o),oe(!1)},onCancel:()=>oe(!1),accentColor:De}):/* @__PURE__ */M("button",{onClick:()=>oe(!0),className:`w-full border-2 border-dashed rounded-md py-3 font-semibold flex items-center justify-center gap-2 transition-colors ${Ae.addTaskBtn}`,children:[
24
+ /* @__PURE__ */T(v,{name:"add-circle",className:"h-5 w-5",strokeWidth:2}),"Add Task"]})]}),
25
+ /* @__PURE__ */M("div",{className:`border-t px-3 py-2.5 flex items-center justify-center gap-5 text-sm ${Ae.softDivider}`,children:[
26
+ /* @__PURE__ */M("span",{className:Ae.secondary,children:["Pomos: ",
27
+ /* @__PURE__ */T("span",{className:`font-bold ${Ae.primary}`,children:ce}),
28
+ /* @__PURE__ */T("span",{className:Ae.muted,children:" / "}),
29
+ /* @__PURE__ */T("span",{className:`font-bold ${Ae.primary}`,children:de})]}),he>0&&/* @__PURE__ */M("span",{className:Ae.secondary,children:["Finish At: ",
30
+ /* @__PURE__ */T("span",{className:`font-bold ${Ae.primary}`,children:pe}),
31
+ /* @__PURE__ */M("span",{className:Ae.muted,children:[" (",ge,"h)"]})]})]})]}),
32
+ /* @__PURE__ */T(J,{open:ye,onClose:()=>Ne(!1),onSave:()=>{ve(we),localStorage.setItem(I,JSON.stringify(we)),b({pomodoro_settings:Ce}),Ne(!1)},configAppearance:we,setConfigAppearance:Se,configPrefs:Ce,setConfigPrefs:Be})]})}function J({open:e,onClose:a,onSave:o,configAppearance:n,setConfigAppearance:r,configPrefs:s,setConfigPrefs:l}){const i=(e,t)=>l(a=>({...a,[e]:t}));/* @__PURE__ */
33
+ return M(t,{open:e,onClose:a,title:"Pomodoro Settings",appearance:n,onAppearanceChange:r,onSave:o,children:[
34
+ /* @__PURE__ */M(Q,{icon:/* @__PURE__ */T(ne,{}),label:"TIMER",children:[
35
+ /* @__PURE__ */M("div",{children:[
36
+ /* @__PURE__ */T("p",{className:"text-sm font-bold text-gray-800 mb-2",children:"Time (minutes)"}),
37
+ /* @__PURE__ */M("div",{className:"grid grid-cols-3 gap-3",children:[
38
+ /* @__PURE__ */T(Y,{label:"Pomodoro",value:s.focusMinutes,onChange:e=>i("focusMinutes",e),max:120}),
39
+ /* @__PURE__ */T(Y,{label:"Short Break",value:s.shortBreakMinutes,onChange:e=>i("shortBreakMinutes",e),max:120}),
40
+ /* @__PURE__ */T(Y,{label:"Long Break",value:s.longBreakMinutes,onChange:e=>i("longBreakMinutes",e),max:120})]})]}),
41
+ /* @__PURE__ */T(Z,{label:"Auto Start Breaks",children:/* @__PURE__ */T(ae,{checked:s.autoStartBreaks,onChange:e=>i("autoStartBreaks",e)})}),
42
+ /* @__PURE__ */T(Z,{label:"Auto Start Pomodoros",children:/* @__PURE__ */T(ae,{checked:s.autoStartPomodoros,onChange:e=>i("autoStartPomodoros",e)})}),
43
+ /* @__PURE__ */T(Z,{label:"Long Break interval",children:/* @__PURE__ */T(ee,{value:s.longBreakInterval,onChange:e=>i("longBreakInterval",e),min:1,max:20,className:"w-14 text-center"})})]}),
44
+ /* @__PURE__ */M(Q,{icon:/* @__PURE__ */T(re,{}),label:"TASK",children:[
45
+ /* @__PURE__ */T(Z,{label:"Auto Check Tasks",info:'If you enable "Auto Check Tasks", the active task will be automatically checked when the actual pomodoro count reaches the estimated count.',children:/* @__PURE__ */T(ae,{checked:s.autoCheckTasks,onChange:e=>i("autoCheckTasks",e)})}),
46
+ /* @__PURE__ */T(Z,{label:"Check to Bottom",info:'If you enable "Check to Bottom", the checked task will be automatically moved to the bottom of the task list.',children:/* @__PURE__ */T(ae,{checked:s.checkToBottom,onChange:e=>i("checkToBottom",e)})})]}),
47
+ /* @__PURE__ */M(Q,{icon:/* @__PURE__ */T(se,{}),label:"SOUND",children:[
48
+ /* @__PURE__ */T(Z,{label:"Alarm Sound",children:/* @__PURE__ */M("div",{className:"flex items-center gap-2",children:[
49
+ /* @__PURE__ */T(te,{value:s.alarmSound,onChange:e=>i("alarmSound",e),options:p.map(e=>({id:e.id,label:e.label}))}),"off"!==s.alarmSound&&/* @__PURE__ */T("button",{type:"button",onClick:()=>g(s.alarmSound,{volume:s.alarmVolume,repeat:1}),className:"px-2 py-1 text-[11px] rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:"Play"})]})}),
50
+ /* @__PURE__ */T(q,{value:s.alarmVolume,onChange:e=>i("alarmVolume",e)}),
51
+ /* @__PURE__ */T(Z,{label:"repeat",children:/* @__PURE__ */T(ee,{value:s.alarmRepeat,onChange:e=>i("alarmRepeat",e),min:1,max:5,className:"w-14 text-center"})}),
52
+ /* @__PURE__ */T(Z,{label:"Focus Sound",children:/* @__PURE__ */M("div",{className:"flex items-center gap-2",children:[
53
+ /* @__PURE__ */T(te,{value:s.focusSound,onChange:e=>i("focusSound",e),options:f}),"none"!==s.focusSound&&/* @__PURE__ */T("button",{type:"button",onClick:()=>b(s.focusSound,s.focusVolume),className:"px-2 py-1 text-[11px] rounded border border-gray-300 text-gray-600 hover:bg-gray-100",children:"Play"})]})}),
54
+ /* @__PURE__ */T(q,{value:s.focusVolume,onChange:e=>i("focusVolume",e)})]})]})}function Q({icon:e,label:t,children:a}){/* @__PURE__ */
55
+ return M("div",{className:"border-t border-gray-200 pt-3 first:border-0 first:pt-0",children:[
56
+ /* @__PURE__ */M("div",{className:"flex items-center gap-1.5 mb-3 text-gray-400",children:[e,
57
+ /* @__PURE__ */T("span",{className:"text-xs font-bold tracking-[0.15em]",children:t})]}),
58
+ /* @__PURE__ */T("div",{className:"space-y-3",children:a})]})}function Z({label:e,info:t,children:a}){/* @__PURE__ */
59
+ return M("div",{className:"flex items-center justify-between gap-3",children:[
60
+ /* @__PURE__ */M("div",{className:"flex items-center gap-1.5 min-w-0",children:[
61
+ /* @__PURE__ */T("span",{className:"text-sm font-semibold text-gray-800",children:e}),t&&/* @__PURE__ */T(oe,{title:t})]}),
62
+ /* @__PURE__ */T("div",{className:"shrink-0",children:a})]})}function q({value:e,onChange:t}){/* @__PURE__ */
63
+ return M("div",{className:"flex items-center justify-end gap-3",children:[
64
+ /* @__PURE__ */T("span",{className:"text-xs text-gray-400 w-7 text-right tabular-nums",children:e}),
65
+ /* @__PURE__ */T("input",{type:"range",min:0,max:100,value:e,onChange:e=>t(parseInt(e.target.value,10)),className:"w-40 accent-blue-500"})]})}function Y({label:e,value:t,onChange:a,min:o=1,max:n=99}){/* @__PURE__ */
66
+ return M("label",{className:"flex flex-col",children:[
67
+ /* @__PURE__ */T("span",{className:"text-xs font-semibold text-gray-500 mb-1",children:e}),
68
+ /* @__PURE__ */T(ee,{value:t,onChange:a,min:o,max:n})]})}function ee({value:e,onChange:t,min:a=1,max:o=99,className:n=""}){/* @__PURE__ */
69
+ return T("input",{type:"number",min:a,max:o,value:e,onChange:e=>t(Math.max(a,Math.min(o,parseInt(e.target.value,10)||a))),className:`bg-gray-100 border-0 rounded-md px-2 py-1.5 text-sm font-medium text-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500 w-full ${n}`})}function te({value:e,onChange:t,options:a}){/* @__PURE__ */
70
+ return M("div",{className:"relative",children:[
71
+ /* @__PURE__ */T("select",{value:e,onChange:e=>t(e.target.value),className:"appearance-none bg-gray-100 border-0 rounded-md pl-3 pr-8 py-1.5 text-sm font-medium text-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer",children:a.map(e=>/* @__PURE__ */T("option",{value:e.id,children:e.label},e.id))}),
72
+ /* @__PURE__ */T(v,{name:"chevron-down",className:"absolute right-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-gray-400 pointer-events-none",strokeWidth:2.5})]})}function ae({checked:e,onChange:t}){/* @__PURE__ */
73
+ return T("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(!e),className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors "+(e?"bg-emerald-500":"bg-gray-300"),children:/* @__PURE__ */T("span",{className:"absolute h-5 w-5 rounded-full bg-white shadow transition-transform "+(e?"translate-x-[22px]":"translate-x-0.5")})})}function oe({title:e}){/* @__PURE__ */
74
+ return T("span",{title:e,className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-gray-300 text-white text-[10px] font-bold cursor-help",children:"i"})}function ne(){/* @__PURE__ */
75
+ return M("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
76
+ /* @__PURE__ */T("circle",{cx:"12",cy:"12",r:"9"}),
77
+ /* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7v5l3 2"})]})}function re(){/* @__PURE__ */
78
+ return M("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
79
+ /* @__PURE__ */T("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),
80
+ /* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12l2 2 4-4"})]})}function se(){/* @__PURE__ */
81
+ return M("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
82
+ /* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5L6 9H2v6h4l5 4V5z"}),
83
+ /* @__PURE__ */T("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.5 8.5a5 5 0 010 7M19 5a9 9 0 010 14"})]})}function le({onSubmit:e,onCancel:t,accentColor:a}){const[o,n]=S(""),[r,s]=S(1),l=()=>e(o,r);/* @__PURE__ */
84
+ return M("div",{className:"bg-white text-gray-800 rounded-md p-3 shadow-md",children:[
85
+ /* @__PURE__ */T("input",{autoFocus:!0,value:o,onChange:e=>n(e.target.value),placeholder:"What are you working on?",onKeyDown:e=>{"Enter"===e.key&&l(),"Escape"===e.key&&t()},className:"w-full text-base font-medium bg-transparent border-0 outline-none placeholder-gray-400"}),
86
+ /* @__PURE__ */M("div",{className:"flex items-center justify-between mt-2",children:[
87
+ /* @__PURE__ */T("span",{className:"text-xs font-semibold text-gray-500",children:"Est Pomodoros"}),
88
+ /* @__PURE__ */T("input",{type:"number",min:1,max:20,value:r,onChange:e=>s(Math.max(1,Math.min(20,parseInt(e.target.value,10)||1))),className:"w-16 bg-gray-100 rounded px-2 py-1 text-sm text-right border-0 focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),
89
+ /* @__PURE__ */M("div",{className:"flex gap-2 mt-3 justify-end",children:[
90
+ /* @__PURE__ */T("button",{onClick:t,className:"px-3 py-1 text-sm text-gray-500 hover:bg-gray-100 rounded",children:"Cancel"}),
91
+ /* @__PURE__ */T("button",{onClick:l,className:"px-4 py-1 text-sm font-semibold text-white rounded shadow-sm",style:{backgroundColor:a},children:"Save"})]})]})}export{G as default};
@@ -0,0 +1,182 @@
1
+ import{PdfViewer as e,ToolbarSlotContext as t,PanelActions as n}from"./chunk-SK5DL6JX.js";import{ImageAnnotator_default as r}from"./chunk-GWDVD3VQ.js";import{AboutApp as i}from"./chunk-5MDQNFOG.js";import{peekPdfPreviewStage as s,claimPdfPreviewStage as a,PDF_PREVIEW_UPDATE_EVENT as o}from"./chunk-ESL5TDNA.js";import{WindowTitle as l,getActiveModalId as c}from"./chunk-QJHWLDEN.js";import"./chunk-DSSLOQDW.js";import"./chunk-I2H2CKID.js";import{toast_default as d}from"./chunk-GJ37JCC2.js";import"./chunk-HQLAISFX.js";import"./chunk-5A7MWTXX.js";import"./chunk-S3LGKIZ3.js";import"./chunk-DBXZS7OA.js";import"./chunk-ZEIKSMFR.js";import"./chunk-UVBK6YSR.js";import"./chunk-7IQ3B77H.js";import{registerModalEscapeInterceptor as u}from"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import"./chunk-SBF5A6XV.js";import"./chunk-KNUR2UEG.js";import{useShellStrings as p,splitAround as m}from"./chunk-K6DKX55N.js";import"./chunk-C3QOHMR6.js";import{Icon as h}from"./chunk-2SSRFEOZ.js";import{useRef as y,useState as x,useEffect as f}from"react";import{jsxs as g,jsx as b,Fragment as w}from"react/jsx-runtime";var v=!1;function k(e,t){return e?.url&&e.url!==t.url&&e.url.startsWith("blob:")&&URL.revokeObjectURL(e.url),t}function N(){const n=y(void 0);void 0===n.current&&(n.current=s());const[r,u]=x(n.current?.data??null);f(()=>{const e=n.current;null!=e&&(a(e),u(t=>t===e.data?t:k(t,e.data)))},[]),f(()=>{const e=n.current?.token;if(null==e)return;const t=t=>{const n=t.detail;n&&n.token===e&&u(e=>k(e,n.data))};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)},[]);const v=y(void 0);f(()=>{v.current=r?.url},[r?.url]);const N=y(null);f(()=>(null!==N.current&&(clearTimeout(N.current),N.current=null),()=>{const e=v.current;e?.startsWith("blob:")&&(N.current=setTimeout(()=>URL.revokeObjectURL(e),0))}),[]);const A=p().preview,E=r?.filename?(S=r.filename).length>24?`${S.slice(0,23)}…`:S:A.untitled;var S;const M=y(null),z=y(null),[T,R]=x(null),[F,H]=x(!1),I=y(0),O=()=>M.current?.click(),P=()=>{I.current=0,H(!1)},W=e=>{const t=e.closest("[data-modal-id]");return!t||c()===t.dataset.modalId};f(()=>{const e=()=>P(),t=()=>P(),n=e=>{"Escape"===e.key&&P()};return window.addEventListener("dragend",e),window.addEventListener("drop",t),window.addEventListener("keydown",n),()=>{window.removeEventListener("dragend",e),window.removeEventListener("drop",t),window.removeEventListener("keydown",n)}},[]);const B=e=>{const t=(e.name.split(".").pop()||"").toLowerCase(),n="pdf"===t?"pdf":"dxf"===t?"dxf":["jpg","jpeg","png","gif","webp","svg","avif","bmp"].includes(t)?"image":["stp","step","stl","obj","gltf","glb","3mf","iges","igs","ply","fbx"].includes(t)?"3d":void 0;if(!n)return void("dwg"===t?d.error(A.dwgUnsupported):d.error(A.unsupportedType(t)));const r=URL.createObjectURL(e);u(t=>(t?.url?.startsWith("blob:")&&t.url!==r&&URL.revokeObjectURL(t.url),{url:r,filename:e.name,kind:n}))},X=/* @__PURE__ */g("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
2
+ /* @__PURE__ */b("input",{ref:M,type:"file",accept:".pdf,.dxf,.jpg,.jpeg,.png,.gif,.webp,.svg,.avif,.bmp,.stp,.step,.stl,.obj,.gltf,.glb,.3mf,.iges,.igs,.ply,.fbx",onChange:e=>{const t=e.target.files?.[0];t&&B(t),M.current&&(M.current.value="")},className:"hidden"}),
3
+ /* @__PURE__ */g("button",{onClick:O,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:[
4
+ /* @__PURE__ */b(h,{name:"folder-open",className:"h-3.5 w-3.5",strokeWidth:1.5}),A.open]}),
5
+ /* @__PURE__ */b("span",{className:"text-[10px] text-gray-400 ml-1",children:A.formats}),r?.filename&&/* @__PURE__ */g(w,{children:[
6
+ /* @__PURE__ */b("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
7
+ /* @__PURE__ */b("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:r.filename,children:r.filename})]}),
8
+ /* @__PURE__ */b("div",{ref:R,className:"ml-auto flex items-center gap-1 text-xs"})]});let G;if(r)G=r.converting||!r.url?/* @__PURE__ */b(C,{filename:r.filename,message:r.convertingMessage}):"dxf"===r.kind?/* @__PURE__ */b(L,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):"3d"===r.kind?/* @__PURE__ */b(j,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):"image"===r.kind?/* @__PURE__ */b(D,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url):/* @__PURE__ */b(e,{url:r.url,filename:r.filename,onDownload:r.onDownload,onEmail:r.onEmail},r.url);else{const[e,t]=m(A.dropHere),[n,r]=m(A.formatDxf),[i,s]=m(A.format3d);G=/* @__PURE__ */g("div",{className:"flex flex-1 flex-col items-center justify-center text-gray-500 text-sm gap-3 p-8 text-center",children:[
9
+ /* @__PURE__ */b(h,{name:"page",className:"h-12 w-12 text-gray-300",strokeWidth:1.5}),
10
+ /* @__PURE__ */g("p",{className:"font-medium text-gray-700",children:[e,
11
+ /* @__PURE__ */b("button",{onClick:O,className:"text-blue-600 hover:underline",children:A.open}),t]}),
12
+ /* @__PURE__ */g("div",{className:"text-xs text-gray-500 max-w-sm",children:[
13
+ /* @__PURE__ */b("p",{className:"font-semibold uppercase tracking-wide text-[10px] text-gray-400 mb-1",children:A.supportedFormats}),
14
+ /* @__PURE__ */g("ul",{className:"space-y-0.5",children:[
15
+ /* @__PURE__ */g("li",{children:[
16
+ /* @__PURE__ */b("span",{className:"font-mono text-gray-700",children:".pdf"})," — ",A.formatPdf]}),
17
+ /* @__PURE__ */g("li",{children:[
18
+ /* @__PURE__ */b("span",{className:"font-mono text-gray-700",children:".dxf"})," — ",n,
19
+ /* @__PURE__ */b("span",{className:"font-mono",children:"dxf-viewer"}),r]}),
20
+ /* @__PURE__ */g("li",{children:[
21
+ /* @__PURE__ */b("span",{className:"font-mono text-gray-700",children:".stp .step .stl .obj .gltf .glb .3mf .iges"})," — ",i,
22
+ /* @__PURE__ */b("span",{className:"font-mono",children:"online-3d-viewer"}),s]}),
23
+ /* @__PURE__ */g("li",{children:[
24
+ /* @__PURE__ */b("span",{className:"font-mono text-gray-700",children:".jpg .jpeg .png .gif .webp .svg .avif .bmp"})," — ",A.formatImage]})]}),
25
+ /* @__PURE__ */b("p",{className:"mt-2 text-[11px] text-gray-400 italic",children:A.dwgNote})]})]})}/* @__PURE__ */
26
+ return g("div",{className:"relative flex flex-col h-full",ref:z,onDragEnter:e=>{e.dataTransfer?.types?.includes?.("Files")&&W(e.currentTarget)&&(e.preventDefault(),I.current++,F||H(!0))},onDragOver:e=>{e.dataTransfer?.types?.includes?.("Files")&&W(e.currentTarget)&&e.preventDefault()},onDragLeave:()=>{I.current>0&&I.current--,0===I.current&&H(!1)},onDrop:e=>{W(e.currentTarget)?(e=>{e.preventDefault(),P();const t=e.dataTransfer.files?.[0];t&&B(t)})(e):P()},children:[
27
+ /* @__PURE__ */b(l,{title:A.windowTitle(E)}),
28
+ /* @__PURE__ */b(i,{app:"preview"}),X,
29
+ /* @__PURE__ */b(t.Provider,{value:T,children:/* @__PURE__ */b("div",{className:"flex-1 min-h-0",children:G})}),F&&/* @__PURE__ */b("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__ */b("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:A.dropToOpen})})]})}function C({filename:e,message:t}){const n=p().preview;/* @__PURE__ */
30
+ return g("div",{className:"flex flex-col items-center justify-center h-full bg-gray-100 gap-4 px-8",children:[
31
+ /* @__PURE__ */g("div",{className:"flex flex-col items-center gap-3",children:[
32
+ /* @__PURE__ */g("svg",{className:"h-12 w-12 text-blue-500 animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
33
+ /* @__PURE__ */b("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.2"}),
34
+ /* @__PURE__ */b("path",{d:"M22 12a10 10 0 0 1-10 10",strokeLinecap:"round"})]}),
35
+ /* @__PURE__ */b("div",{className:"text-base font-semibold tracking-wide text-gray-700 uppercase",children:t||n.converting}),
36
+ /* @__PURE__ */b("div",{className:"text-xs text-gray-400 truncate max-w-md",children:e})]}),
37
+ /* @__PURE__ */b("div",{className:"w-72 h-1.5 rounded-full bg-gray-200 overflow-hidden",children:/* @__PURE__ */b("div",{className:"h-full w-1/3 bg-blue-500 rounded-full animate-pulse",style:{animation:"preview-bar 1.4s ease-in-out infinite"}})}),
38
+ /* @__PURE__ */b("style",{children:"@keyframes preview-bar { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }"})]})}var A=["https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/Roboto-LightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NotoSansDisplay-SemiCondensedLightItalic.ttf","https://cdn.jsdelivr.net/gh/vagran/dxf-viewer-example-src@master/src/assets/fonts/NanumGothic-Regular.ttf"],E={l:"LINE",line:"LINE",pl:"PLINE",pline:"PLINE",ex:"EXTEND",extend:"EXTEND",tr:"TRIM",trim:"TRIM",e:"ERASE",erase:"ERASE",m:"MOVE",move:"MOVE",co:"COPY",cp:"COPY",copy:"COPY",o:"OFFSET",offset:"OFFSET",f:"FILLET",fillet:"FILLET",cha:"CHAMFER",chamfer:"CHAMFER",x:"EXPLODE",explode:"EXPLODE",mi:"MIRROR",mirror:"MIRROR",ro:"ROTATE",rotate:"ROTATE",sc:"SCALE",scale:"SCALE",s:"STRETCH",stretch:"STRETCH",ar:"ARRAY",array:"ARRAY",rec:"RECTANG",rectang:"RECTANG",rectangle:"RECTANG",c:"CIRCLE",circle:"CIRCLE",a:"ARC",arc:"ARC",el:"ELLIPSE",ellipse:"ELLIPSE",t:"MTEXT",mt:"MTEXT",mtext:"MTEXT",text:"TEXT",b:"BLOCK",block:"BLOCK",i:"INSERT",insert:"INSERT",ha:"HATCH",hatch:"HATCH"};function L({url:e,filename:t,onDownload:r,onEmail:i}){const s=y(null),a=y(null),[o,l]=x(!0),[d,v]=x(null),[k,N]=x([]),[C,L]=x(!1),[S,M]=x(!0),z=p(),T=z.drawing,j=z.preview,D=y(T);D.current=T;const[F,H]=x(!1),[I,O]=x("auto"),[P,W]=x(null),[B,X]=x(null),[G,_]=x(null),[U,V]=x(""),Y=y(I),$=y(G);f(()=>{Y.current=I},[I]),f(()=>{$.current=G},[G]);const K=y(null),q=y(null),Z=y(null),[Q,J]=x(""),[ee,te]=x(null),ne=y(""),re=y(null),ie=y(null),se=y(null);f(()=>{let t=!1,n=null;return l(!0),v(null),N([]),(async()=>{let r;try{r=(await(import("dxf-viewer"))).DxfViewer}catch(e){return void(t||(v(D.current.notInstalled),l(!1)))}if(!t&&s.current)try{if(await new Promise(e=>{const t=()=>{const n=s.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),t||!s.current)return;const i={autoResize:!0},o=r.DefaultOptions?.clearColor;"function"==typeof o?.clone&&(i.clearColor=o.clone().setHex(16777215)),n=new r(s.current,i),a.current=n;const c="undefined"!=typeof window&&window.__REACT_OS_SHELL_DXF_FONTS__||A;if(await n.Load({url:e,fonts:c,workerFactory:null}),t)return;try{const e=n.GetLayers?.()??[];Array.isArray(e)&&N(e.map(e=>({name:e.name,displayName:e.displayName??e.name,color:"number"==typeof e.color?e.color:void 0,visible:!0})))}catch{}const d=()=>{try{const e=s.current?.getBoundingClientRect();e&&e.width>0&&e.height>0&&n.SetSize?.(Math.round(e.width),Math.round(e.height));const t=n.GetBounds?.(),r=n.GetOrigin?.();t&&r&&n.FitView(t.minX-r.x,t.maxX-r.x,t.minY-r.y,t.maxY-r.y),n.Render?.()}catch(e){console.warn("[Preview] DXF refit failed",e)}};d(),requestAnimationFrame(d),l(!1)}catch(e){t||(v(e?.message||D.current.renderFailed),l(!1))}})(),()=>{t=!0;try{n?.Destroy?.()}catch{}a.current=null}},[e]),f(()=>{if(!S||o)return;const e=setTimeout(()=>M(!1),5e3);return()=>clearTimeout(e)},[S,o]);const ae=k.map(e=>e.visible?"1":"0").join("");f(()=>{const e=a.current;if(o||d||!e)return;const t=e.GetScene?.(),n=e.GetCamera?.(),r=e.GetCanvas?.();if(!(t&&n&&r&&s.current))return;const i=()=>{const e=se.current;e&&(e.overlay&&e.overlay.parentElement&&e.overlay.parentElement.removeChild(e.overlay),se.current=null)};if(!F)return i(),W(null),void X(null);const l=document.createElement("div");l.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:5;",s.current.appendChild(l);const c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.setAttribute("style","position:absolute;inset:0;width:100%;height:100%;pointer-events:none;");const u=document.createElementNS("http://www.w3.org/2000/svg","defs"),p=document.createElementNS("http://www.w3.org/2000/svg","marker");p.setAttribute("id","dxf-measure-arrow"),p.setAttribute("viewBox","0 0 10 10"),p.setAttribute("refX","9"),p.setAttribute("refY","5"),p.setAttribute("markerWidth","6"),p.setAttribute("markerHeight","6"),p.setAttribute("orient","auto-start-reverse");const m=document.createElementNS("http://www.w3.org/2000/svg","path");m.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),m.setAttribute("fill","#ff8800"),p.appendChild(m),u.appendChild(p),c.appendChild(u),l.appendChild(c);const h=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","line");return e.setAttribute("stroke","#ff8800"),e.setAttribute("stroke-width","1"),e.setAttribute("stroke-dasharray","6,4"),e.setAttribute("opacity","0.55"),e.style.display="none",c.appendChild(e),e},y=h(),x=h(),f=document.createElementNS("http://www.w3.org/2000/svg","line");f.setAttribute("stroke","#ff8800"),f.setAttribute("stroke-width","1"),f.setAttribute("opacity","0.85"),f.style.display="none",c.appendChild(f);const g=document.createElementNS("http://www.w3.org/2000/svg","line");g.setAttribute("stroke","#ff8800"),g.setAttribute("stroke-width","1"),g.setAttribute("opacity","0.85"),g.style.display="none",c.appendChild(g);const b=document.createElementNS("http://www.w3.org/2000/svg","line");b.setAttribute("stroke","#ff8800"),b.setAttribute("stroke-width","1.5"),b.setAttribute("stroke-linecap","round"),b.style.display="none",c.appendChild(b);const w=document.createElementNS("http://www.w3.org/2000/svg","line");w.setAttribute("stroke","#ff8800"),w.setAttribute("stroke-width","1.5"),w.setAttribute("stroke-linecap","round"),w.style.display="none",c.appendChild(w);const v=document.createElement("div");v.style.cssText="position:absolute;transform:translate(-50%,-50%);pointer-events:none;display:none;";const k="http://www.w3.org/2000/svg",N=document.createElementNS(k,"svg");N.setAttribute("width","22"),N.setAttribute("height","22"),N.setAttribute("viewBox","0 0 22 22"),N.setAttribute("style","overflow:visible;display:block"),v.appendChild(N);const C=e=>{const t=document.createElementNS(k,"g");return e(t),t.style.display="none",N.appendChild(t),t},A=C(e=>{const t=document.createElementNS(k,"rect");t.setAttribute("x","4"),t.setAttribute("y","4"),t.setAttribute("width","14"),t.setAttribute("height","14"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t)}),E=C(e=>{const t=(e,t,n,r)=>{const i=document.createElementNS(k,"line");return i.setAttribute("x1",String(e)),i.setAttribute("y1",String(t)),i.setAttribute("x2",String(n)),i.setAttribute("y2",String(r)),i.setAttribute("stroke","#ff8800"),i.setAttribute("stroke-width","2.2"),i.setAttribute("stroke-linecap","round"),i};e.appendChild(t(4,4,18,18)),e.appendChild(t(18,4,4,18))}),L=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","4,4 18,4 4,18 18,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),S=C(e=>{const t=document.createElementNS(k,"polygon");t.setAttribute("points","11,3 19,18 3,18"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),e.appendChild(t)}),M=C(e=>{const t=document.createElementNS(k,"circle");t.setAttribute("cx","11"),t.setAttribute("cy","11"),t.setAttribute("r","7"),t.setAttribute("fill","rgba(255,255,255,0.9)"),t.setAttribute("stroke","#ff8800"),t.setAttribute("stroke-width","1.8"),e.appendChild(t);const n=(e,t,n,r)=>{const i=document.createElementNS(k,"line");return i.setAttribute("x1",String(e)),i.setAttribute("y1",String(t)),i.setAttribute("x2",String(n)),i.setAttribute("y2",String(r)),i.setAttribute("stroke","#ff8800"),i.setAttribute("stroke-width","1.6"),i.setAttribute("stroke-linecap","round"),i};e.appendChild(n(6.5,6.5,15.5,15.5)),e.appendChild(n(15.5,6.5,6.5,15.5))});l.appendChild(v),se.current={picks:[],rawSecondClick:null,overlay:l,svg:c,line:b,fixedLine:w,fixedLabel:null,refLine:y,refLineV:x,extLineA:f,extLineB:g,markers:[],label:null,snap:v,segs:null,nodes:null};const z=n?.position?.constructor??t?.position?.constructor??null;let T=!1;const j=(e,t)=>{if(!z)return{x:0,y:0};const i=new z(e,t,0).project(n),s=r.clientWidth,a=r.clientHeight;return{x:(i.x+1)/2*s,y:(1-i.y)/2*a}};(()=>{try{const e=se.current;if(!e)return;const n=[],r=[];let i=!1;const s=e=>{const t=e?.attributes?.instanceTransform0,n=e?.attributes?.instanceTransform1;if(t&&n){const e=[],r=Math.min(t.count,n.count);for(let i=0;i<r;i++)e.push([t.getX(i),t.getY(i),t.getZ(i),n.getX(i),n.getY(i),n.getZ(i)]);return e}const r=e?.attributes?.instanceTransform;if(r){const e=[];for(let t=0;t<r.count;t++)e.push([1,0,r.getX(t),0,1,r.getY(t)]);return e}return[[1,0,0,0,1,0]]},a=e=>{const t=!!e?.isLineSegments;if(!t&&!!!e?.isPoints)return;const a=e.geometry,o=a?.attributes?.position;if(!o)return;const l=s(a);if(t){const e=a.index,t=Math.floor((e?e.count:o.count)/2);for(let r=0;r<t;r++){const t=e?e.getX(2*r):2*r,s=e?e.getX(2*r+1):2*r+1,a=o.getX(t),c=o.getY(t),d=o.getX(s),u=o.getY(s);if(Number.isFinite(a+c+d+u))for(const e of l){if(n.length>=16e5)return void(i=!0);const t=e[0]*a+e[1]*c+e[2],r=e[3]*a+e[4]*c+e[5],s=e[0]*d+e[1]*u+e[2],o=e[3]*d+e[4]*u+e[5];t===s&&r===o||n.push(t,r,s,o)}}}else for(let e=0;e<o.count;e++){const t=o.getX(e),n=o.getY(e);if(Number.isFinite(t+n))for(const e of l)r.push(e[0]*t+e[1]*n+e[2],e[3]*t+e[4]*n+e[5])}};"function"==typeof t.traverseVisible?t.traverseVisible(a):t.traverse(a),e.segs=new Float64Array(n),e.nodes=new Float64Array(r),i&&console.warn("[Preview] DXF snap cache truncated at 400000 segments — snapping may miss some geometry."),T=!0}catch{}})();const I=(e,t,n,r,i,s,a,o)=>{const l=(n-e)*(o-s)-(r-t)*(a-i);if(Math.abs(l)<1e-9)return null;const c=((i-e)*(o-s)-(s-t)*(a-i))/l,d=((i-e)*(r-t)-(s-t)*(n-e))/l,u=1e-4;return c<-u||c>1+u||d<-u||d>1+u?null:{px:e+c*(n-e),py:t+c*(r-t),t:c}},O=()=>{const e=document.createElement("div");return e.style.cssText="position:absolute;width:10px;height:10px;border-radius:50%;background:#ff8800;border:2px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,0.25);transform:translate(-50%,-50%);pointer-events:none;",l.appendChild(e),e},P=(e,t,n)=>{const r=j(t,n);e.style.left=`${r.x}px`,e.style.top=`${r.y}px`},B=()=>{const e=se.current;if(!e||!e.rawSecondClick||e.picks.length<2)return;const t=e.picks[0],n=e.rawSecondClick,r=$.current,i=Y.current;if(null===r||!Number.isFinite(r)||"horizontal"!==i&&"vertical"!==i)e.picks[1]={x:n.x,y:n.y};else if("horizontal"===i){const i=n.x>=t.x?1:-1;e.picks[1]={x:t.x+i*Math.abs(r),y:n.y}}else{const i=n.y>=t.y?1:-1;e.picks[1]={x:n.x,y:t.y+i*Math.abs(r)}}},G=(e,t)=>{const n=Y.current;return"auto"!==n?n:e&&t?Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?"horizontal":"vertical":"horizontal"},_=()=>{const e=se.current;if(!e)return;B();const t=Y.current,n=$.current,i=null!==n&&Number.isFinite(n)&&("horizontal"===t||"vertical"===t);e.markers[0]&&P(e.markers[0],e.picks[0].x,e.picks[0].y),e.markers[1]&&P(e.markers[1],e.picks[1].x,e.picks[1].y);const s=(t,n,i)=>{if(!t)return;if(!i||e.picks.length<1)return void(t.style.display="none");const s=e.picks[0],a=r.clientWidth,o=r.clientHeight,l=4*Math.hypot(a,o),c=j(s.x,s.y),d=j(s.x+n.dx,s.y+n.dy),u=l/(Math.hypot(d.x-c.x,d.y-c.y)||1),p=j(s.x-n.dx*u,s.y-n.dy*u),m=j(s.x+n.dx*u,s.y+n.dy*u);t.setAttribute("x1",String(p.x)),t.setAttribute("y1",String(p.y)),t.setAttribute("x2",String(m.x)),t.setAttribute("y2",String(m.y)),t.style.display=""};let a="horizontal"===t,o="vertical"===t;if("auto"===t)if(e.picks.length>=2){const t=G(e.picks[0],e.picks[1]);a="horizontal"===t,o="vertical"===t}else a=!0,o=!0;if(s(e.refLine,{dx:1,dy:0},a),s(e.refLineV,{dx:0,dy:1},o),2===e.picks.length){const t=e.picks[0],s=e.picks[1],a=G(t,s),o=(()=>{const e=se.current,t=e.picks[0],n=e.picks[1],r=G(t,n),i=Y.current,s=$.current;return null!==s&&Number.isFinite(s)&&"horizontal"===i?{from:{x:n.x,y:t.y},to:{x:n.x,y:n.y}}:null!==s&&Number.isFinite(s)&&"vertical"===i?{from:{x:t.x,y:n.y},to:{x:n.x,y:n.y}}:"horizontal"===r?{from:t,to:{x:n.x,y:t.y}}:"vertical"===r?{from:t,to:{x:t.x,y:n.y}}:{from:t,to:n}})(),l=j(o.from.x,o.from.y),c=j(o.to.x,o.to.y);e.line.setAttribute("x1",String(l.x)),e.line.setAttribute("y1",String(l.y)),e.line.setAttribute("x2",String(c.x)),e.line.setAttribute("y2",String(c.y)),e.line.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.line.setAttribute("marker-end","url(#dxf-measure-arrow)");const d=Math.hypot(c.x-l.x,c.y-l.y);if(e.line.style.display=d>.5?"":"none",i&&e.fixedLine){const i="horizontal"===a?{x:s.x,y:t.y}:{x:t.x,y:s.y},o=j(t.x,t.y),l=j(i.x,i.y);e.fixedLine.setAttribute("x1",String(o.x)),e.fixedLine.setAttribute("y1",String(o.y)),e.fixedLine.setAttribute("x2",String(l.x)),e.fixedLine.setAttribute("y2",String(l.y)),e.fixedLine.setAttribute("marker-start","url(#dxf-measure-arrow)"),e.fixedLine.setAttribute("marker-end","url(#dxf-measure-arrow)"),e.fixedLine.style.display="";const c=U();c.textContent=R(Math.abs(n));const d=(o.x+l.x)/2,u=(o.y+l.y)/2;c.style.left=`${d}px`,c.style.top=`${u}px`;const p=r.clientWidth,m=r.clientHeight;c.style.display=d<0||u<0||d>p||u>m?"none":""}else e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none");const u=e.extLineA,p=e.extLineB;if(!i&&"horizontal"===a&&Math.abs(s.y-t.y)>1e-9){const e=j(s.x,t.y),n=j(s.x,s.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else if(!i&&"vertical"===a&&Math.abs(s.x-t.x)>1e-9){const e=j(t.x,s.y),n=j(s.x,s.y);p.setAttribute("x1",String(e.x)),p.setAttribute("y1",String(e.y)),p.setAttribute("x2",String(n.x)),p.setAttribute("y2",String(n.y)),p.style.display="",u.style.display="none"}else u.style.display="none",p.style.display="none";if(e.label){const t=(l.x+c.x)/2,n=(l.y+c.y)/2;e.label.style.left=`${t}px`,e.label.style.top=`${n}px`;const i=r.clientWidth,s=r.clientHeight;e.label.style.display=t<0||n<0||t>i||n>s?"none":"",d<=.5&&(e.label.style.display="none")}}else e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none")},U=()=>{const e=se.current;if(e.fixedLabel)return e.fixedLabel;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:11px;font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.75);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.fixedLabel=t,t};let V=0,Q=0,J=0,ee=!1,ne=!1,re=null;const ie=e=>{const t=e?.detail;t&&0===t.domEvent?.button&&(V=t.canvasCoord.x,Q=t.canvasCoord.y,J=performance.now(),ne=!1,ee=!0)},ae=e=>{const t=r.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;ee&&(n-V)**2+(i-Q)**2>16&&(ne=!0);const s=se.current;var a;if(s&&s.snap)if(ee&&ne)s.snap.style.display="none";else if(re=((e,t)=>{const n=se.current;if(!n||!T||!n.segs)return null;const r=j(0,0),i=j(1,0),s=j(0,1),a=i.x-r.x,o=i.y-r.y,l=s.x-r.x,c=s.y-r.y,d=a*c-l*o;if(!d)return null;const u=((e-r.x)*c-(t-r.y)*l)/d,p=((t-r.y)*a-(e-r.x)*o)/d,m=18/(Math.hypot(a,o)||1),h=18/(Math.hypot(l,c)||1),y=u-m,x=u+m,f=p-h,g=p+h,b=324;let w=null,v=b,k=null,N=b,C=null,A=b,E=null,L=b;const S=[],M=n.segs;for(let n=0;n<M.length;n+=4){const i=M[n],s=M[n+1],d=M[n+2],u=M[n+3];if(i<y&&d<y||i>x&&d>x||s<f&&u<f||s>g&&u>g)continue;const p=r.x+a*i+l*s,m=r.y+o*i+c*s,h=r.x+a*d+l*u,E=r.y+o*d+c*u;let L=!1,z=e-p,T=t-m,R=z*z+T*T;R<b&&(L=!0,R<v&&(v=R,w={sx:i,sy:s,type:"endpoint"})),z=e-h,T=t-E,R=z*z+T*T,R<b&&(L=!0,R<v&&(v=R,w={sx:d,sy:u,type:"endpoint"})),z=e-(p+h)/2,T=t-(m+E)/2,R=z*z+T*T,R<b&&(L=!0,R<N&&(N=R,k={sx:(i+d)/2,sy:(s+u)/2,type:"midpoint"}));const j=h-p,D=E-m,F=j*j+D*D;if(F>0){const n=((e-p)*j+(t-m)*D)/F;n>0&&n<1&&(z=e-(p+n*j),T=t-(m+n*D),R=z*z+T*T,R<b&&(L=!0,R<A&&(A=R,C={sx:i+n*(d-i),sy:s+n*(u-s),type:"line"})))}L&&S.push({ax:i,ay:s,bx:d,by:u,apx:p,apy:m,bpx:h,bpy:E})}const z=n.nodes;if(z)for(let n=0;n<z.length;n+=2){const i=z[n],s=z[n+1];if(i<y||i>x||s<f||s>g)continue;const d=e-(r.x+a*i+l*s),u=t-(r.y+o*i+c*s),p=d*d+u*u;p<v&&(v=p,w={sx:i,sy:s,type:"node"})}for(let n=0;n<S.length;n++){const r=S[n];for(let i=n+1;i<S.length;i++){const n=S[i],s=I(r.apx,r.apy,r.bpx,r.bpy,n.apx,n.apy,n.bpx,n.bpy);if(!s)continue;const a=e-s.px,o=t-s.py,l=a*a+o*o;l>=b||l>=L||(L=l,E={sx:r.ax+s.t*(r.bx-r.ax),sy:r.ay+s.t*(r.by-r.ay),type:"intersection"})}}return(E&&w?L<v-1?E:w:E??w)??k??C})(n,i),re){const e=j(re.sx,re.sy);s.snap.style.left=`${e.x}px`,s.snap.style.top=`${e.y}px`,s.snap.style.display="",a=re.type,A.style.display="endpoint"===a?"":"none",E.style.display="intersection"===a?"":"none",L.style.display="line"===a?"":"none",S.style.display="midpoint"===a?"":"none",M.style.display="node"===a?"":"none"}else s.snap.style.display="none"},oe=e=>{if(!ee)return;ee=!1;const t=performance.now()-J;if(ne||t>350)return;const n=e?.detail?.position;if(!n)return;const r=re?{x:re.sx,y:re.sy}:{x:n.x,y:n.y};ue(r)},le=()=>{const e=se.current;if(!e||2!==e.picks.length)return;B();const t=e.picks[0],n=e.picks[1],r=Y.current,i=G(t,n),s=$.current,a=null!==s&&Number.isFinite(s)&&("horizontal"===r||"vertical"===r);let o,c,d="",u=i;const p=Math.abs(n.x-t.x),m=Math.abs(n.y-t.y);if(a&&"horizontal"===r?(o=m,d=" ↕",u="vertical",c=D.current.echoLocked("ΔY",R(m),"ΔX",R(Math.abs(s)))):a&&"vertical"===r?(o=p,d=" ↔",u="horizontal",c=D.current.echoLocked("ΔX",R(p),"ΔY",R(Math.abs(s)))):"horizontal"===i?(o=p,d=" ↔",c=D.current.echoLinear(R(p),"ΔX")):"vertical"===i?(o=m,d=" ↕",c=D.current.echoLinear(R(m),"ΔY")):(o=Math.hypot(n.x-t.x,n.y-t.y),c=D.current.echoDistance(R(o),R(p),R(m))),!Number.isFinite(o))return W(null),X(null),void(e.label&&(e.label.style.opacity="0"));W(o),X(u),te(c);const h=(()=>{const e=se.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.cssText="position:absolute;left:-9999px;top:-9999px;transform:translate(-50%,-50%);padding:2px 6px;font-size:11px;font-weight:600;font-family:system-ui,-apple-system,sans-serif;background:rgba(255,136,0,0.95);color:#fff;border-radius:4px;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,0.25);pointer-events:none;",l.appendChild(t),e.label=t,t})();h.style.opacity="1",h.textContent=`${R(o)}${d}`};K.current=()=>{le(),_()};const ce=e=>{e.line.style.display="none",e.fixedLine&&(e.fixedLine.style.display="none"),e.fixedLabel&&(e.fixedLabel.style.display="none"),e.extLineA&&(e.extLineA.style.display="none"),e.extLineB&&(e.extLineB.style.display="none"),e.label&&(e.label.style.opacity="0"),W(null),X(null)},de=()=>{const e=se.current;if(e){for(const t of e.markers)t.parentElement?.removeChild(t);e.markers=[],e.picks=[],e.rawSecondClick=null,e.refLine&&(e.refLine.style.display="none"),e.refLineV&&(e.refLineV.style.display="none"),ce(e)}};q.current=de,Z.current=()=>{const e=se.current;if(!e||0===e.picks.length)return;e.picks.pop();const t=e.markers.pop();t?.parentElement?.removeChild(t),e.rawSecondClick=null,ce(e),_()};const ue=e=>{const t=se.current;t&&(2===t.picks.length&&de(),0===t.picks.length?(t.picks.push({x:e.x,y:e.y}),t.markers.push(O())):(t.rawSecondClick={x:e.x,y:e.y},t.picks.push({x:e.x,y:e.y}),t.markers.push(O()),le()),_())},pe=e=>{"Escape"===e.key&&H(!1)};r.style.cursor="crosshair";try{e.Subscribe?.("pointerdown",ie)}catch{}try{e.Subscribe?.("pointerup",oe)}catch{}try{e.Subscribe?.("viewChanged",_)}catch{}return r.addEventListener("pointermove",ae),window.addEventListener("keydown",pe),()=>{r.style.cursor="";try{e.Unsubscribe?.("pointerdown",ie)}catch{}try{e.Unsubscribe?.("pointerup",oe)}catch{}try{e.Unsubscribe?.("viewChanged",_)}catch{}r.removeEventListener("pointermove",ae),window.removeEventListener("keydown",pe),K.current=null,q.current=null,Z.current=null,i(),W(null),X(null)}},[F,o,d,ae]),f(()=>{K.current?.()},[I,G]);const oe=e=>{N(t=>t.map(t=>{if(t.visible===e)return t;try{a.current?.ShowLayer?.(t.name,e)}catch{}return{...t,visible:e}}))},le=()=>{try{const e=a.current,t=e?.GetBounds?.(),n=e?.GetOrigin?.();t&&n?e.FitView(t.minX-n.x,t.maxX-n.x,t.minY-n.y,t.maxY-n.y):e?.FitView?.(),e?.Render?.()}catch{}};f(()=>{const e=e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;if(1!==e.key.length||" "===e.key)return;const t=e.target;if(t&&("INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable))return;const n=ie.current;if(!n)return;const r=n.closest("[data-modal-id]");r&&c()!==r.dataset.modalId||re.current?.focus()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);const ce=y(Q),de=y(F);f(()=>{ce.current=Q},[Q]),f(()=>{de.current=F},[F]),f(()=>u(()=>{const e=ie.current;if(!e)return!1;const t=e.closest("[data-modal-id]");return!(!t||c()!==t.dataset.modalId)&&(ce.current?(J(""),te(D.current.cancelled),!0):!!de.current&&(H(!1),te(D.current.measureOff),!0))}),[]);const ue="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1",[pe,me]=m(T.typeToMeasure);/* @__PURE__ */
39
+ return g("div",{ref:ie,className:"flex flex-col h-full",children:[
40
+ /* @__PURE__ */g(n,{children:[
41
+ /* @__PURE__ */g("button",{onClick:()=>L(e=>!e),className:ue+(C?" bg-gray-200":""),title:T.layersHint,disabled:0===k.length,children:[
42
+ /* @__PURE__ */b(h,{name:"layers",className:"h-3.5 w-3.5",strokeWidth:1.5}),T.layers," ",k.length>0&&/* @__PURE__ */g("span",{className:"text-gray-400",children:["(",k.filter(e=>e.visible).length,"/",k.length,")"]})]}),
43
+ /* @__PURE__ */b("button",{onClick:()=>M(e=>!e),className:ue,title:j.howToNavigate,children:/* @__PURE__ */b(h,{name:"help",className:"h-3.5 w-3.5",strokeWidth:1.5})}),
44
+ /* @__PURE__ */g("button",{onClick:()=>H(e=>!e),className:ue+(F?" bg-gray-200":""),title:F?j.stopMeasuring:T.measureHint,children:[
45
+ /* @__PURE__ */g("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[
46
+ /* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 14.25l6-6 6 6 4.5-4.5M9.75 8.25v3M12.75 11.25v3M15.75 14.25v3"}),
47
+ /* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 18.75h19.5"})]}),T.measure]}),F&&/* @__PURE__ */g(w,{children:[
48
+ /* @__PURE__ */g("div",{className:"flex items-stretch h-7 rounded border border-gray-200 overflow-hidden text-[11px] font-semibold",children:[
49
+ /* @__PURE__ */b("button",{onClick:()=>O("auto"),className:"px-2 transition-colors "+("auto"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:T.autoHint,children:T.auto}),
50
+ /* @__PURE__ */b("button",{onClick:()=>O("horizontal"),className:"px-2 transition-colors "+("horizontal"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:T.horizontalHint,children:"H"}),
51
+ /* @__PURE__ */b("button",{onClick:()=>O("vertical"),className:"px-2 transition-colors "+("vertical"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:T.verticalHint,children:"V"}),
52
+ /* @__PURE__ */b("button",{onClick:()=>O("point"),className:"px-2 transition-colors "+("point"===I?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:T.pointHint,children:T.point})]}),("horizontal"===I||"vertical"===I)&&/* @__PURE__ */g("div",{className:"flex items-center gap-1",children:[
53
+ /* @__PURE__ */b("input",{type:"number",inputMode:"decimal",step:"any",value:U,placeholder:"horizontal"===I?T.fixX:T.fixY,onChange:e=>{const t=e.target.value;if(V(t),""===t.trim())_(null);else{const e=parseFloat(t);_(Number.isFinite(e)&&0!==e?e:null)}},className:"h-7 w-20 px-1.5 text-[11px] font-mono rounded border border-gray-200 bg-white text-gray-700 focus:outline-none focus:border-orange-400",title:T.fixHint}),null!==G&&/* @__PURE__ */b("button",{onClick:()=>{_(null),V("")},className:"text-gray-400 hover:text-gray-600 text-[11px] px-1",title:T.clearFixed,children:"×"})]})]}),F&&null!==P&&/* @__PURE__ */g("div",{className:"px-2 py-1 text-[11px] font-mono font-semibold text-orange-600 bg-orange-50 border border-orange-200 rounded whitespace-nowrap",title:"horizontal"===B?T.horizontalDistance("auto"===I):"vertical"===B?T.verticalDistance("auto"===I):T.straightDistance,children:[R(P),"horizontal"===B?" ↔":"vertical"===B?" ↕":""]}),
54
+ /* @__PURE__ */b("button",{onClick:le,className:ue,title:T.fitHint,children:T.fit}),
55
+ /* @__PURE__ */g("button",{onClick:r??(()=>{const n=document.createElement("a");n.href=e,n.download=t,n.click()}),className:ue,children:[
56
+ /* @__PURE__ */b(h,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),j.download]}),i&&/* @__PURE__ */g("button",{onClick:i,className:ue,children:[
57
+ /* @__PURE__ */b(h,{name:"email",className:"h-3.5 w-3.5",strokeWidth:1.5}),j.email]})]}),
58
+ /* @__PURE__ */g("div",{className:"relative flex-1 bg-white min-h-0",children:[
59
+ /* @__PURE__ */b("div",{ref:s,style:{width:"100%",height:"100%"}}),C&&k.length>0&&/* @__PURE__ */g("div",{className:"absolute top-2 right-2 w-64 max-h-[70%] flex flex-col bg-white/95 backdrop-blur border border-gray-200 rounded-md shadow-xl z-10 text-xs",children:[
60
+ /* @__PURE__ */g("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-gray-200 bg-gray-50",children:[
61
+ /* @__PURE__ */b("span",{className:"font-medium text-gray-700",children:T.layers}),
62
+ /* @__PURE__ */g("div",{className:"flex items-center gap-1",children:[
63
+ /* @__PURE__ */b("button",{onClick:()=>oe(!0),className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-600",children:T.allLayers}),
64
+ /* @__PURE__ */b("button",{onClick:()=>oe(!1),className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-600",children:T.noLayers}),
65
+ /* @__PURE__ */b("button",{onClick:()=>L(!1),className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-600",title:j.closePanel,children:"×"})]})]}),
66
+ /* @__PURE__ */b("div",{className:"overflow-y-auto py-1",children:k.map(e=>{/* @__PURE__ */return g("label",{className:"flex items-center gap-2 px-2 py-1 hover:bg-gray-100 cursor-pointer",children:[
67
+ /* @__PURE__ */b("input",{type:"checkbox",checked:e.visible,onChange:()=>{return t=e.name,void N(e=>e.map(e=>{if(e.name!==t)return e;const n=!e.visible;try{a.current?.ShowLayer?.(t,n)}catch{}return{...e,visible:n}}));var t},className:"h-3.5 w-3.5"}),
68
+ /* @__PURE__ */b("span",{className:"inline-block h-3 w-3 rounded-sm border border-gray-300 shrink-0",style:{background:(t=e.color,"number"!=typeof t?"#999":"#"+t.toString(16).padStart(6,"0"))}}),
69
+ /* @__PURE__ */b("span",{className:"truncate text-gray-700",title:e.displayName,children:e.displayName||e.name})]},e.name);var t})})]}),S&&!o&&!d&&/* @__PURE__ */g("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 bg-gray-900/85 text-white text-[11px] px-3 py-1.5 rounded-full shadow-lg flex items-center gap-3 z-10 pointer-events-none",children:[
70
+ /* @__PURE__ */g("span",{className:"flex items-center gap-1",children:[
71
+ /* @__PURE__ */b("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"})}),T.dragToPan]}),
72
+ /* @__PURE__ */b("span",{className:"text-white/40",children:"•"}),
73
+ /* @__PURE__ */g("span",{className:"flex items-center gap-1",children:[
74
+ /* @__PURE__ */b(h,{name:"zoom-in",className:"h-3.5 w-3.5",strokeWidth:1.8}),j.scrollToZoom]}),
75
+ /* @__PURE__ */b("span",{className:"text-white/40",children:"•"}),
76
+ /* @__PURE__ */b("span",{children:T.fitToReset}),
77
+ /* @__PURE__ */b("span",{className:"text-white/40",children:"•"}),
78
+ /* @__PURE__ */g("span",{children:[pe,
79
+ /* @__PURE__ */b("span",{className:"font-mono font-semibold",children:"DI"})," / ",
80
+ /* @__PURE__ */b("span",{className:"font-mono font-semibold",children:"DIM"}),me]})]}),o&&/* @__PURE__ */b("div",{className:"absolute inset-0 flex items-center justify-center bg-white/80 text-sm text-gray-500",children:T.loading}),d&&/* @__PURE__ */b("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-600 px-6 text-center",children:d})]}),
81
+ /* @__PURE__ */g("div",{className:"shrink-0 border-t border-gray-200 bg-gray-50",children:[ee&&/* @__PURE__ */b("div",{className:"px-2.5 pt-1 text-[11px] font-mono text-gray-500 truncate",title:ee,children:ee}),
82
+ /* @__PURE__ */g("div",{className:"flex items-center gap-1.5 px-2.5 h-7",children:[
83
+ /* @__PURE__ */b("span",{className:"text-[11px] font-mono font-semibold text-gray-400 select-none",children:">"}),
84
+ /* @__PURE__ */b("input",{ref:re,value:Q,onChange:e=>J(e.target.value),onKeyDown:e=>{"Enter"===e.key||" "===e.key?(e.preventDefault(),(e=>{const t=e.trim()||ne.current;if(J(""),!t)return;const n=t.toLowerCase().split(/\s+/)[0],r=()=>{ne.current=t},i=(e,t)=>{H(!0),O(e),q.current?.(),te(t),r()};if(/^-?(\d+\.?\d*|\.\d+)$/.test(n))if(!F||"horizontal"!==I&&"vertical"!==I)te(T.fixedNeedsAxis);else{const e=parseFloat(n);e?(V(n),_(e),te(T.axisLocked("horizontal"===I?"ΔX":"ΔY",R(Math.abs(e))))):(V(""),_(null),te(T.fixedCleared))}else switch(n){case"di":case"dist":case"mea":case"measuregeom":i("point",T.echoDist);break;case"dim":case"dli":case"dimlin":case"dimlinear":i("auto",T.echoDimLinear);break;case"h":case"hor":case"horizontal":H(!0),O("horizontal"),te(T.echoHorizontal),r();break;case"v":case"ver":case"vertical":H(!0),O("vertical"),te(T.echoVertical),r();break;case"au":case"auto":H(!0),O("auto"),te(T.echoAuto),r();break;case"measure":H(!F),te(F?T.measureOff:T.measureOn),r();break;case"u":case"undo":Z.current?.(),te(T.pickRemoved),r();break;case"z":case"ze":case"zoom":case"fit":case"zoomextents":le(),te(T.zoomExtents),r();break;case"la":case"layer":case"layers":L(e=>!e),te(T.layersToggled),r();break;case"off":case"clear":_(null),V(""),q.current?.(),te(T.measurementCleared),r();break;case"?":case"help":te(T.commandHelp);break;default:{const e=E[n];te(e?T.readOnly(e):T.unknownCommand(n.toUpperCase()))}}})(Q)):"Escape"===e.key&&(Q?(e.stopPropagation(),J(""),te(T.cancelled)):e.target.blur())},placeholder:T.commandPlaceholder,spellCheck:!1,autoComplete:"off",className:"flex-1 min-w-0 bg-transparent text-[11px] font-mono text-gray-700 focus:outline-none placeholder:text-gray-300"})]})]})]})}var S="https://cdn.jsdelivr.net/npm/online-3d-viewer@0.18.0/libs/";function M(e,t,n=0){return{id:e.GetId?.()??0,name:e.GetName?.()||(0===n?t.root:t.node),isMeshNode:!!e.IsMeshNode?.(),meshIndices:e.GetMeshIndices?.()??[],children:(e.GetChildNodes?.()??[]).map(e=>M(e,t,n+1))}}function z(e,t){t.add(e.id);for(const n of e.children)z(n,t)}function T(e,t){const n=/^#?([0-9a-f]{6})$/i.exec(t),r=n?parseInt(n[1],16):0;return new e.RGBColor(r>>16&255,r>>8&255,255&r)}function R(e){return e>=1e3?`${(e/1e3).toFixed(3)} m`:`${e.toFixed(2)} mm`}function j({url:e,filename:t,onDownload:r,onEmail:i}){const s=y(null),a=y(null),o=y(null),[l,c]=x(!0),[d,u]=x(null),[m,w]=x(!0),k=p(),N=k.model,C=k.preview,A=y(N);A.current=N;const[E,L]=x(null),[j,D]=x({}),[F,H]=x(/* @__PURE__ */new Set),[I,O]=x("#f5f6f8"),[P,W]=x(!0),[B,X]=x("#000000"),[G,_]=x(1),[U,V]=x(!1),[Y,$]=x(!1),[K,q]=x(!1),[Z,Q]=x(!1),[J,ee]=x("x"),[te,ne]=x(!1),[re,ie]=x(.5),[se,ae]=x(0),[oe,le]=x(!1),[ce,de]=x("point"),[ue,pe]=x(null),me=y(null),he=y(null);f(()=>{let n=!1,r=null,i=null;return c(!0),u(null),L(null),D({}),H(/* @__PURE__ */new Set),(async()=>{let l;try{l=await(import("online-3d-viewer"))}catch{return void(n||(u(A.current.notInstalled),c(!1)))}if(o.current=l,!n&&s.current&&(await new Promise(e=>{const t=()=>{const n=s.current?.getBoundingClientRect();n&&n.width>4&&n.height>4?e():requestAnimationFrame(t)};t()}),!n&&s.current))try{const o="undefined"!=typeof window&&window.__REACT_OS_SHELL_O3DV_LIBS__||S;l.SetExternalLibLocation?.(o),function(){if(v)return;if("undefined"==typeof HTMLCanvasElement)return;v=!0;const e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,n){return"webgl"!==t&&"webgl2"!==t&&"experimental-webgl"!==t||(n={...n||{},stencil:!0}),e.call(this,t,n)},console.info("[Preview] section: canvas getContext patched (force stencil=true)")}(),r=new l.EmbeddedViewer(s.current,{backgroundColor:new l.RGBAColor(245,246,248,255),defaultColor:new l.RGBColor(180,188,200),edgeSettings:new l.EdgeSettings(!0,new l.RGBColor(0,0,0),1),onModelLoaded:()=>{if(!n){try{const e=r.GetModel?.(),t=e?.GetRootNode?.();if(t){const e=M(t,{root:A.current.rootNode,node:A.current.node});L(e);const n={[e.id]:!0};for(const t of e.children)n[t.id]=!0;D(n)}}catch(e){console.warn("[Preview] mesh tree extraction failed",e)}c(!1)}},onModelLoadFailed:()=>{n||(u(A.current.loadFailed),c(!1))}}),a.current=r;const d=new l.InputFile(t,l.FileSource.Url,e);r.LoadModelFromInputFiles([d]),s.current&&"undefined"!=typeof ResizeObserver&&(i=new ResizeObserver(()=>{try{const e=a.current;e?.Resize?e.Resize():e?.viewer?.Resize&&e.viewer.Resize(),e?.viewer?.Render?.()}catch{}}),i.observe(s.current))}catch(e){n||(u(e?.message||A.current.loadFailed),c(!1))}})(),()=>{n=!0;try{i?.disconnect()}catch{}try{r?.Destroy?.()}catch{}a.current=null}},[e,t]),f(()=>{const e=a.current;if(e?.viewer)try{const t=e=>{if(e.userData?.__sectionHelper)return;const t=e.userData?.originalMeshInstance??e.userData,n=t?.id?.nodeId??t?.nodeId;"number"==typeof n&&(e.visible=!F.has(n))};e.viewer.mainModel?.EnumerateMeshesAndLines?.(t),e.viewer.mainModel?.EnumerateEdges?.(t),e.viewer.Render?.()}catch(e){console.warn("[Preview] visibility update failed",e)}},[F,E]),f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer)try{t.viewer.SetEdgeSettings(new e.EdgeSettings(P,T(e,B),G));const n=he.current;if(n){const e=[];t.viewer.mainModel?.EnumerateEdges?.(t=>{t.userData?.__sectionHelper&&e.push(t)});for(const t of e)t.parent?.remove(t),t.geometry?.dispose?.(),t.material?.dispose?.();const r=n.plane,i=e=>{e&&!n.materialState.has(e)&&(n.materialState.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[r],e.clipShadows=!0,e.needsUpdate=!0)};t.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)i(e);else i(t)})}t.viewer.Render?.()}catch{}},[P,B,G]),f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer)try{const n=T(e,I);t.viewer.SetBackgroundColor(new e.RGBAColor(n.r,n.g,n.b,255)),t.viewer.Render?.()}catch{}},[I]),f(()=>{const e=a.current;if(!e?.viewer||l)return;const t=e.viewer.renderer,n=e.viewer.scene;if(!t||!n)return;if(he.current){const e=he.current;for(const[t,n]of e.materialState.entries())t.clippingPlanes=n.clippingPlanes,t.clipShadows=n.clipShadows,t.needsUpdate=!0;for(const t of e.helpers)t.parent?.remove(t),t.material?.dispose?.();e.capMesh&&(n.remove(e.capMesh),e.capMesh.geometry?.dispose?.(),e.capMesh.material?.dispose?.()),he.current=null}if(!Z)return t.localClippingEnabled=!1,void e.viewer.Render?.();const r=e.viewer.GetBoundingBox?.(()=>!0);if(!r)return;const i=[];if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{e.userData?.__sectionHelper||i.push(e)}),!i.length)return t.localClippingEnabled=!1,void e.viewer.Render?.();const s=i[0],o=s.constructor,c=s.material?.constructor,d=s.geometry?.constructor,u=s.geometry?.attributes?.position?.constructor;o&&c&&d&&u||console.warn("[Preview] section: missing THREE constructors, falling back to no cap");const p=7681;let m=!0;try{const e=t.getContext?.(),n=e?.getContextAttributes?.();m=!1!==n?.stencil,t.autoClearStencil=!0,console.info("[Preview] section: stencil buffer =",m,"targets =",i.length)}catch{}t.localClippingEnabled=!0;const h={normal:{x:0,y:0,z:-1},constant:0,clone:function e(){const t={normal:{x:this.normal.x,y:this.normal.y,z:this.normal.z},constant:this.constant};return t.clone=e,t}},y=[],x=/* @__PURE__ */new Map,f=e=>{e&&!x.has(e)&&(x.set(e,{clippingPlanes:e.clippingPlanes,clipShadows:e.clipShadows}),e.clippingPlanes=[h],e.clipShadows=!0,e.needsUpdate=!0)};for(const e of i){const t=e.material;if(Array.isArray(t))for(const e of t)f(e);else f(t);const n=Array.isArray(t)?t[0]:t;if(o&&m&&n?.clone){const t=(t,r)=>{const i=n.clone();i.depthWrite=!1,i.depthTest=!1,i.colorWrite=!1,i.stencilWrite=!0,i.stencilFunc=519,i.stencilFail=r,i.stencilZFail=r,i.stencilZPass=r,i.side=t,i.transparent=!1,i.clippingPlanes=[h],i.clipShadows=!0,i.needsUpdate=!0;const s=new o(e.geometry,i);s.matrixAutoUpdate=!1,s.renderOrder=1,s.userData.__sectionHelper=!0,e.add(s),y.push(s)};t(1,7682),t(0,7683)}}e.viewer.mainModel?.EnumerateEdges?.(e=>{const t=e.material;if(Array.isArray(t))for(const e of t)f(e);else f(t)});let g=null;const b=i[0]?.material&&(Array.isArray(i[0].material)?i[0].material[0]:i[0].material);if(m&&o&&d&&u&&b?.clone){const e=r.max.x-r.min.x,t=r.max.y-r.min.y,i=r.max.z-r.min.z,s=2*Math.max(e,t,i,1)/2,a=new d,l=new Float32Array([-s,-s,0,s,-s,0,s,s,0,-s,s,0]),c=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]);a.setAttribute("position",new u(l,3)),a.setAttribute("normal",new u(c,3)),a.setIndex([0,1,2,0,2,3]);const m=b.clone(),h=b.color?.getHex?.()??11844808;m.emissive?.setHex?.(h),"emissiveIntensity"in m&&(m.emissiveIntensity=.25),m.side=2,m.transparent=!1,m.opacity=1,m.stencilWrite=!0,m.stencilRef=0,m.stencilFunc=517,m.stencilFail=p,m.stencilZFail=p,m.stencilZPass=p,m.clippingPlanes=[],m.polygonOffset=!0,m.polygonOffsetFactor=-1,m.polygonOffsetUnits=-1,m.needsUpdate=!0,g=new o(a,m),g.renderOrder=2,g.userData.__sectionHelper=!0,n.add(g)}he.current={plane:h,capMesh:g,helpers:y,materialState:x,bbox:r},console.info("[Preview] section: helpers =",y.length,"cap =",!!g),e.viewer.Render?.()},[Z,l,E]),f(()=>{const e=a.current,t=he.current;if(e?.viewer&&t&&Z)try{const n=t.bbox,r="x"===J?0:"y"===J?1:2,i=[n.min.x,n.min.y,n.min.z][r],s=i+([n.max.x,n.max.y,n.max.z][r]-i)*re,a=se*Math.PI/180,o=Math.cos(a),l=Math.sin(a),c=te?-1:1;let d=0,u=0,p=0;"x"===J?(d=c*o,p=c*l):"y"===J?(u=c*o,d=c*l):(p=c*o,u=c*l);const m={x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2,z:(n.min.z+n.max.z)/2},h="x"===J?s:m.x,y="y"===J?s:m.y,x="z"===J?s:m.z;if(t.plane.normal.x=d,t.plane.normal.y=u,t.plane.normal.z=p,t.plane.constant=-(d*h+u*y+p*x),t.capMesh){const e=m.x,n=m.y,r=m.z,i=d*e+u*n+p*r+t.plane.constant,s=e-d*i,a=n-u*i,o=r-p*i;t.capMesh.position.set(s,a,o),t.capMesh.lookAt?.(s+d,a+u,o+p)}e.viewer.Render?.()}catch(e){console.warn("[Preview] section update failed",e)}},[Z,J,te,re,se]),f(()=>{const e=a.current;if(!e?.viewer||l||!s.current)return;const t=e.viewer.renderer,n=e.viewer.scene,r=t?.domElement;if(!t||!n||!r)return;let i=null;if(e.viewer.mainModel?.EnumerateMeshes?.(e=>{i||e.userData?.__sectionHelper||e.userData?.__measureHelper||(i=e)}),!i)return;const c=i.position.constructor,d=i.constructor,u=(Array.isArray(i.material)?i.material[0]:i.material)?.constructor,p=i.geometry.constructor,m=i.geometry.attributes?.position?.constructor;if(!(c&&d&&u&&p&&m))return;let h=null,y=null;n.traverse(e=>{if(h&&y)return;if(!e?.isLineSegments)return;h=e.constructor;const t=Array.isArray(e.material)?e.material[0]:e.material;t?.constructor&&(y=t.constructor)});const x=()=>{const t=me.current;if(t){null!==t.rafId&&cancelAnimationFrame(t.rafId);for(const e of t.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();t.line&&(n.remove(t.line),t.line.geometry?.dispose?.(),t.line.material?.dispose?.()),t.label&&t.label.parentElement&&t.label.parentElement.removeChild(t.label),me.current=null,e.viewer.Render?.()}};if(!oe)return x(),void pe(null);me.current={points:[],normals:[],markers:[],line:null,label:null,rafId:null};const f=o.current,g=f?.IntersectionMode?.MeshOnly??1,b=e.viewer.GetBoundingBox?.(()=>!0),w=b?Math.sqrt((b.max.x-b.min.x)**2+(b.max.y-b.min.y)**2+(b.max.z-b.min.z)**2):100,v=Math.max(.005*w,.2),k=e=>{const t=[],r=[];for(let e=0;e<=12;e++){const n=e/12*Math.PI;for(let e=0;e<=16;e++){const r=e/16*Math.PI*2;t.push(v*Math.sin(n)*Math.cos(r),v*Math.cos(n),v*Math.sin(n)*Math.sin(r))}}for(let e=0;e<12;e++)for(let t=0;t<16;t++){const n=17*e+t,i=n+16+1;r.push(n,i,n+1,i,i+1,n+1)}const i=new p;i.setAttribute("position",new m(new Float32Array(t),3)),i.setIndex(r),i.computeVertexNormals?.();const s=new u;s.color?.setHex?.(16746496),s.depthTest=!1,s.depthWrite=!1,s.transparent=!0,s.opacity=.95;const a=new d(i,s);return a.position.copy(e),a.renderOrder=9999,a.userData.__measureHelper=!0,n.add(a),a},N=()=>{const t=me.current;t&&((()=>{const t=me.current;if(!t||t.points.length<2||!t.label)return;const n=e.viewer.camera;if(!n)return;const i=t.points[0],s=t.points[1],a=new c((i.x+s.x)/2,(i.y+s.y)/2,(i.z+s.z)/2).clone();a.project?.(n);const o=r.getBoundingClientRect(),l=(a.x+1)/2*o.width,d=(1-a.y)/2*o.height;t.label.style.left=`${l}px`,t.label.style.top=`${d}px`;const u=l<0||d<0||l>o.width||d>o.height;t.label.style.opacity=a.z>1||u?"0":"1"})(),t.rafId=requestAnimationFrame(N))};me.current.rafId=requestAnimationFrame(N);let C=0,A=0,E=0,L=!1,S=!1;const M=t=>{if(!e.viewer.camera)return;const i=r.getBoundingClientRect(),a={x:t.clientX-i.left,y:t.clientY-i.top},o=e.viewer.GetMeshIntersectionUnderMouse?.(g,a);if(!o)return;const l=me.current,x=new c(o.point.x,o.point.y,o.point.z),f=(e=>{const t=e?.face?.normal,n=e?.object;if(!t||!n)return null;try{const e=new c(t.x,t.y,t.z);return e.transformDirection?.(n.matrixWorld),{x:e.x,y:e.y,z:e.z}}catch{return{x:t.x,y:t.y,z:t.z}}})(o);if(2===l.points.length){for(const e of l.markers)n.remove(e),e.geometry?.dispose?.(),e.material?.dispose?.();l.line&&(n.remove(l.line),l.line.geometry?.dispose?.(),l.line.material?.dispose?.()),l.label&&(l.label.style.opacity="0"),l.points=[],l.markers=[],l.line=null,l.normals=[],pe(null)}if(l.points.push(x),l.normals.push(f),"perp"===ce){const e=((e,t)=>{const r=e?.geometry,i=r?.attributes?.position;if(!r||!i||!t?.face?.normal)return null;const s=i.array,a=r.index?r.index.array:null,o=new c(t.point.x,t.point.y,t.point.z);e.worldToLocal?.(o);const l=t.face.normal,h=-(l.x*o.x+l.y*o.y+l.z*o.z);r.computeBoundingBox?.();const y=r.boundingBox,x=y?Math.sqrt((y.max.x-y.min.x)**2+(y.max.y-y.min.y)**2+(y.max.z-y.min.z)**2):100,f=Math.max(.001*x,.005),g=a?a.length/3:i.count/3,b=[],w=new c;for(let t=0;t<g;t++){const n=a?a[3*t]:3*t,r=a?a[3*t+1]:3*t+1,i=a?a[3*t+2]:3*t+2,o=s[3*n],c=s[3*n+1],d=s[3*n+2],u=s[3*r],p=s[3*r+1],m=s[3*r+2],y=s[3*i],x=s[3*i+1],g=s[3*i+2],v=u-o,k=p-c,N=m-d,C=y-o,A=x-c,E=g-d;let L=k*E-N*A,S=N*C-v*E,M=v*A-k*C;const z=Math.sqrt(L*L+S*S+M*M);if(0===z)continue;if(L/=z,S/=z,M/=z,L*l.x+S*l.y+M*l.z<.9995)continue;const T=(o+u+y)/3,R=(c+p+x)/3,j=(d+m+g)/3;if(!(Math.abs(l.x*T+l.y*R+l.z*j+h)>f))for(const[t,n,r]of[[o,c,d],[u,p,m],[y,x,g]])w.set?.(t,n,r),e.localToWorld?.(w),b.push(w.x,w.y,w.z)}if(0===b.length)return null;const v=new p;v.setAttribute("position",new m(new Float32Array(b),3)),v.computeVertexNormals?.();const k=new u;k.color?.setHex?.(16746496),k.transparent=!0,k.opacity=.45,k.depthWrite=!1,k.polygonOffset=!0,k.polygonOffsetFactor=-2,k.polygonOffsetUnits=-2;const N=new d(v,k);return N.renderOrder=9998,N.userData.__measureHelper=!0,n.add(N),N})(o.object,o);l.markers.push(e??k(x))}else l.markers.push(k(x));if(2===l.points.length){const e=l.points[0];let t,r=l.points[1],i="";if("perp"===ce){const n=l.normals[0]??l.normals[1];if(n){const s=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z)||1,a=n.x/s,o=n.y/s,d=n.z/s,u=(r.x-e.x)*a+(r.y-e.y)*o+(r.z-e.z)*d,p=new c(e.x+a*u,e.y+o*u,e.z+d*u);l.points[1]=p,r=p,t=Math.abs(u),i=" ⊥"}else{const n=r.x-e.x,i=r.y-e.y,s=r.z-e.z;t=Math.sqrt(n*n+i*i+s*s)}}else{const n=r.x-e.x,i=r.y-e.y,s=r.z-e.z;t=Math.sqrt(n*n+i*i+s*s)}l.line=((e,t)=>{const r=new p;r.setAttribute("position",new m(new Float32Array([e.x,e.y,e.z,t.x,t.y,t.z]),3));const i=new(h??d)(r,new(y??u)({color:16746496,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.95}));return i.renderOrder=9998,i.userData.__measureHelper=!0,n.add(i),i})(e,r),pe(t);const a=(()=>{const e=me.current;if(e.label)return e.label;const t=document.createElement("div");return t.style.position="absolute",t.style.left="-9999px",t.style.top="-9999px",t.style.transform="translate(-50%, -50%)",t.style.padding="2px 6px",t.style.fontSize="11px",t.style.fontWeight="600",t.style.fontFamily="system-ui, -apple-system, sans-serif",t.style.background="rgba(255, 136, 0, 0.95)",t.style.color="#fff",t.style.borderRadius="4px",t.style.pointerEvents="none",t.style.whiteSpace="nowrap",t.style.boxShadow="0 1px 4px rgba(0,0,0,0.25)",t.style.zIndex="5",s.current.appendChild(t),e.label=t,t})();a.textContent=`${R(t)}${i}`}e.viewer.Render?.()},z=e=>{0===e.button&&(C=e.clientX,A=e.clientY,E=performance.now(),L=!1,S=!0)},T=e=>{if(!S)return;const t=e.clientX-C,n=e.clientY-A;t*t+n*n>16&&(L=!0)},j=e=>{if(0!==e.button||!S)return;const t=performance.now()-E;S=!1,!L&&t<350&&M(e)},D=e=>{"Escape"===e.key&&le(!1)};return r.style.cursor="crosshair",r.addEventListener("pointerdown",z),r.addEventListener("pointermove",T),r.addEventListener("pointerup",j),r.addEventListener("pointercancel",j),window.addEventListener("keydown",D),()=>{r.style.cursor="",r.removeEventListener("pointerdown",z),r.removeEventListener("pointermove",T),r.removeEventListener("pointerup",j),r.removeEventListener("pointercancel",j),window.removeEventListener("keydown",D),x(),pe(null)}},[oe,ce,l,E]),f(()=>{if(!m||l)return;const e=setTimeout(()=>w(!1),5e3);return()=>clearTimeout(e)},[m,l]);const ye=e=>{const t=/* @__PURE__ */new Set;z(e,t),H(e=>{const n=new Set(e),r=[...t].some(e=>!n.has(e));for(const e of t)r?n.add(e):n.delete(e);return n})},xe=()=>{try{const e=a.current,t=e?.viewer?.GetBoundingSphere?.(()=>!0);t&&e.viewer.FitSphereToWindow(t,!0),e?.viewer?.Render?.()}catch{}};f(()=>{const e=o.current,t=a.current;if(e&&t?.viewer&&!l)try{t.viewer.SetProjectionMode(K?e.ProjectionMode.Perspective:e.ProjectionMode.Orthographic)}catch{}},[K,l]);const fe=e=>{const t=o.current,n=a.current;if(t&&n?.viewer)try{const r=n.viewer.GetBoundingSphere?.(()=>!0);if(!r)return;const i=r.center,s=3*(r.radius||1),a=i.x??0,o=i.y??0,l=i.z??0;let c,d;switch(e){case"top":c=new t.Coord3D(a,o,l+s),d=new t.Coord3D(0,1,0);break;case"front":c=new t.Coord3D(a,o-s,l),d=new t.Coord3D(0,0,1);break;case"side":c=new t.Coord3D(a+s,o,l),d=new t.Coord3D(0,0,1);break;default:{const e=s/Math.sqrt(3);c=new t.Coord3D(a+e,o-e,l+e),d=new t.Coord3D(0,0,1);break}}const u=new t.Coord3D(a,o,l),p=new t.Camera(c,u,d,45);n.viewer.SetCamera(p),n.viewer.AdjustClippingPlanesToSphere?.(r),n.viewer.Render?.()}catch{}},ge=(t.split(".").pop()||"").toUpperCase(),be=(e,t=0)=>{const n=e.children.length>0,r=!1!==j[e.id],i=!F.has(e.id);/* @__PURE__ */
85
+ return g("div",{children:[
86
+ /* @__PURE__ */g("div",{className:"group flex items-center gap-1 px-1.5 py-1 hover:bg-gray-100 cursor-default text-[12px] text-gray-700",style:{paddingLeft:12*t+6+"px"},children:[n?/* @__PURE__ */b("button",{onClick:()=>{return t=e.id,void D(e=>({...e,[t]:!e[t]}));var t},className:"h-4 w-4 shrink-0 flex items-center justify-center text-gray-500 hover:text-gray-900",title:r?N.collapse:N.expand,children:/* @__PURE__ */b(h,r?{name:"chevron-down",className:"h-3 w-3",strokeWidth:2}:{name:"chevron-right",className:"h-3 w-3",strokeWidth:2})}):/* @__PURE__ */b("span",{className:"h-4 w-4 shrink-0 flex items-center justify-center",children:/* @__PURE__ */b("span",{className:"h-1 w-1 rounded-full bg-gray-400"})}),
87
+ /* @__PURE__ */b("span",{className:"flex-1 truncate "+(i?"":"opacity-40"),title:e.name,children:e.name}),
88
+ /* @__PURE__ */b("button",{onClick:()=>{xe()},className:"h-4 w-4 shrink-0 text-gray-400 hover:text-gray-900 opacity-0 group-hover:opacity-100 transition-opacity",title:N.fitToView,children:/* @__PURE__ */b(h,{name:"expand",className:"h-3.5 w-3.5",strokeWidth:1.5})}),
89
+ /* @__PURE__ */b("button",{onClick:()=>ye(e),className:"h-4 w-4 shrink-0 text-gray-500 hover:text-gray-900",title:i?N.hide:N.show,children:/* @__PURE__ */b(h,i?{name:"eye",className:"h-3.5 w-3.5",strokeWidth:1.5}:{name:"eye-off",className:"h-3.5 w-3.5",strokeWidth:1.5})})]}),r&&n&&/* @__PURE__ */b("div",{children:e.children.map(e=>be(e,t+1))})]},e.id)},we="h-8 w-8 shrink-0 flex items-center justify-center rounded text-gray-600 hover:bg-gray-200 hover:text-gray-900 transition-colors",ve="h-8 w-8 shrink-0 flex items-center justify-center rounded bg-gray-200 text-gray-900",ke="h-5 w-px bg-gray-300 mx-1";/* @__PURE__ */
90
+ return g("div",{className:"flex flex-col h-full bg-white",children:[
91
+ /* @__PURE__ */g(n,{children:[
92
+ /* @__PURE__ */b("button",{onClick:xe,className:we,title:N.fitToView,children:/* @__PURE__ */b(h,{name:"expand",className:"h-4 w-4",strokeWidth:1.5})}),
93
+ /* @__PURE__ */b("div",{className:ke}),
94
+ /* @__PURE__ */b("button",{onClick:()=>fe("iso"),className:we,title:N.isometricView,children:/* @__PURE__ */b("span",{className:"text-[10px] font-semibold",children:N.isometric})}),
95
+ /* @__PURE__ */b("button",{onClick:()=>fe("top"),className:we,title:N.topView,children:/* @__PURE__ */b("span",{className:"text-[10px] font-semibold",children:N.top})}),
96
+ /* @__PURE__ */b("button",{onClick:()=>fe("front"),className:we,title:N.frontView,children:/* @__PURE__ */b("span",{className:"text-[10px] font-semibold",children:N.front})}),
97
+ /* @__PURE__ */b("button",{onClick:()=>fe("side"),className:we,title:N.sideView,children:/* @__PURE__ */b("span",{className:"text-[10px] font-semibold",children:N.side})}),
98
+ /* @__PURE__ */b("button",{onClick:()=>q(e=>!e),className:K?"h-8 shrink-0 flex items-center justify-center px-2 rounded bg-gray-200 text-gray-900":"h-8 shrink-0 flex items-center justify-center px-2 rounded text-gray-600 hover:bg-gray-200 hover:text-gray-900 transition-colors",title:K?N.toOrthographic:N.toPerspective,children:/* @__PURE__ */b("span",{className:"text-[11px] font-semibold whitespace-nowrap",children:K?N.perspective:N.orthographic})}),
99
+ /* @__PURE__ */b("div",{className:ke}),
100
+ /* @__PURE__ */b("button",{onClick:()=>{try{const e=a.current,n=e?.viewer?.GetCanvasSize?.()??{width:1280,height:720},r=e?.viewer?.GetImageAsDataUrl?.(n.width,n.height,!1);if(!r)return;const i=document.createElement("a");i.href=r,i.download=`${t.replace(/\.[^.]+$/,"")}-snapshot.png`,i.click()}catch{}},className:we,title:N.snapshot,children:/* @__PURE__ */b(h,{name:"camera",className:"h-4 w-4",strokeWidth:1.5})}),
101
+ /* @__PURE__ */b("button",{onClick:()=>w(e=>!e),className:we,title:C.howToNavigate,children:/* @__PURE__ */b(h,{name:"help",className:"h-4 w-4",strokeWidth:1.5})}),
102
+ /* @__PURE__ */b("button",{onClick:()=>le(e=>!e),className:oe?ve:we,title:oe?C.stopMeasuring:N.measureHint,children:/* @__PURE__ */g("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[
103
+ /* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 14.25l6-6 6 6 4.5-4.5M9.75 8.25v3M12.75 11.25v3M15.75 14.25v3"}),
104
+ /* @__PURE__ */b("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 18.75h19.5"})]})}),oe&&/* @__PURE__ */g("div",{className:"flex items-stretch h-8 rounded border border-gray-200 overflow-hidden",children:[
105
+ /* @__PURE__ */b("button",{onClick:()=>de("point"),className:"px-2 text-[11px] font-semibold transition-colors "+("point"===ce?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:N.pointHint,children:N.point}),
106
+ /* @__PURE__ */b("button",{onClick:()=>de("perp"),className:"px-2 text-[12px] font-semibold transition-colors "+("perp"===ce?"bg-orange-500 text-white":"bg-white text-gray-600 hover:bg-gray-50"),title:N.perpendicularHint,children:"⊥"})]}),oe&&null!==ue&&/* @__PURE__ */g("div",{className:"px-2 py-1 text-[11px] font-mono font-semibold text-orange-600 bg-orange-50 border border-orange-200 rounded whitespace-nowrap",title:"perp"===ce?N.perpendicularDistance:N.straightDistance,children:[R(ue),"perp"===ce?" ⊥":""]}),
107
+ /* @__PURE__ */b("div",{className:ke}),
108
+ /* @__PURE__ */b("button",{onClick:()=>V(e=>!e),className:U?ve:we,title:N.meshesHint,children:/* @__PURE__ */b(h,{name:"menu",className:"h-4 w-4",strokeWidth:1.5})}),
109
+ /* @__PURE__ */b("button",{onClick:()=>$(e=>!e),className:Y?ve:we,title:N.displayHint,children:/* @__PURE__ */b(h,{name:"settings",className:"h-4 w-4",strokeWidth:1.5})}),
110
+ /* @__PURE__ */b("button",{onClick:r??(()=>{const n=document.createElement("a");n.href=e,n.download=t,n.click()}),className:we,title:N.downloadOriginal,children:/* @__PURE__ */b(h,{name:"download",className:"h-4 w-4",strokeWidth:1.5})}),i&&/* @__PURE__ */b("button",{onClick:i,className:we,title:C.email,children:/* @__PURE__ */b(h,{name:"email",className:"h-4 w-4",strokeWidth:1.5})})]}),
111
+ /* @__PURE__ */b("div",{className:"flex-1 flex min-h-0",children:/* @__PURE__ */g("div",{className:"relative flex-1 min-w-0",style:{background:I},children:[
112
+ /* @__PURE__ */b("div",{ref:s,style:{width:"100%",height:"100%"}}),U&&/* @__PURE__ */g("div",{className:"absolute top-2 left-2 w-64 max-h-[80%] flex flex-col bg-white/95 backdrop-blur border border-gray-200 rounded-md shadow-xl z-10 text-xs",children:[
113
+ /* @__PURE__ */g("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-gray-200 bg-gray-50",children:[
114
+ /* @__PURE__ */b("span",{className:"font-medium text-gray-700",children:N.meshes}),
115
+ /* @__PURE__ */b("button",{onClick:()=>V(!1),className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-600",title:C.closePanel,children:"×"})]}),
116
+ /* @__PURE__ */b("div",{className:"flex-1 overflow-y-auto py-1",children:E?be(E):/* @__PURE__ */b("div",{className:"px-3 py-3 text-[11px] text-gray-500 italic",children:l?N.readingModel:N.noStructure})}),E&&/* @__PURE__ */b("div",{className:"px-3 py-1.5 text-[10px] text-gray-500 border-t border-gray-200",children:0===F.size?N.allVisible:N.hiddenCount(F.size)})]}),m&&!l&&!d&&/* @__PURE__ */g("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 bg-gray-900/85 text-white text-[11px] px-3 py-1.5 rounded-full shadow-lg flex items-center gap-3 z-10 pointer-events-none",children:[
117
+ /* @__PURE__ */b("span",{children:N.dragToRotate}),
118
+ /* @__PURE__ */b("span",{className:"text-white/40",children:"•"}),
119
+ /* @__PURE__ */b("span",{children:N.rightDragToPan}),
120
+ /* @__PURE__ */b("span",{className:"text-white/40",children:"•"}),
121
+ /* @__PURE__ */b("span",{children:C.scrollToZoom})]}),l&&/* @__PURE__ */g("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-white/85 text-sm text-gray-600 gap-2",children:[
122
+ /* @__PURE__ */g("svg",{className:"h-6 w-6 text-blue-500 animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[
123
+ /* @__PURE__ */b("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.2"}),
124
+ /* @__PURE__ */b("path",{d:"M22 12a10 10 0 0 1-10 10",strokeLinecap:"round"})]}),
125
+ /* @__PURE__ */b("span",{children:N.loading}),"STP"===ge||"STEP"===ge?/* @__PURE__ */b("span",{className:"text-[10px] text-gray-400",children:N.stepNote}):null]}),d&&/* @__PURE__ */b("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-600 px-6 text-center bg-white/85",children:d}),Y&&/* @__PURE__ */g("div",{className:"absolute top-2 right-2 w-64 max-h-[80%] flex flex-col bg-white/95 backdrop-blur border border-gray-200 rounded-md shadow-xl z-10 text-xs",children:[
126
+ /* @__PURE__ */g("div",{className:"flex items-center justify-between px-2 py-1.5 border-b border-gray-200 bg-gray-50",children:[
127
+ /* @__PURE__ */b("span",{className:"font-medium text-gray-700",children:N.display}),
128
+ /* @__PURE__ */b("button",{onClick:()=>$(!1),className:"px-1.5 py-0.5 rounded hover:bg-gray-200 text-gray-600",title:C.closePanel,children:"×"})]}),
129
+ /* @__PURE__ */g("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-3 text-[12px] text-gray-700",children:[
130
+ /* @__PURE__ */g("label",{className:"flex items-center justify-between gap-2",children:[
131
+ /* @__PURE__ */b("span",{children:N.backgroundColor}),
132
+ /* @__PURE__ */b("input",{type:"color",value:I,onChange:e=>O(e.target.value),className:"h-6 w-10 rounded border border-gray-300 bg-white"})]}),
133
+ /* @__PURE__ */g("label",{className:"flex items-center justify-between gap-2",children:[
134
+ /* @__PURE__ */b("span",{children:N.showEdges}),
135
+ /* @__PURE__ */b("button",{onClick:()=>W(e=>!e),role:"switch","aria-checked":P,className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors "+(P?"bg-blue-500":"bg-gray-300"),children:/* @__PURE__ */b("span",{className:"inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform "+(P?"translate-x-[18px]":"translate-x-0.5")})})]}),
136
+ /* @__PURE__ */g("label",{className:"flex items-center justify-between gap-2",children:[
137
+ /* @__PURE__ */b("span",{className:P?"":"opacity-40",children:N.edgeColor}),
138
+ /* @__PURE__ */b("input",{type:"color",value:B,onChange:e=>X(e.target.value),disabled:!P,className:"h-6 w-10 rounded border border-gray-300 bg-white disabled:opacity-40"})]}),
139
+ /* @__PURE__ */g("div",{className:P?"":"opacity-40 pointer-events-none",children:[
140
+ /* @__PURE__ */g("div",{className:"flex items-center justify-between gap-2 mb-1",children:[
141
+ /* @__PURE__ */b("span",{children:N.edgeThreshold}),
142
+ /* @__PURE__ */g("span",{className:"text-gray-500 tabular-nums",children:[G,"°"]})]}),
143
+ /* @__PURE__ */b("input",{type:"range",min:0,max:45,step:1,value:G,onChange:e=>_(Number(e.target.value)),className:"w-full accent-blue-500"})]}),
144
+ /* @__PURE__ */g("div",{className:"border-t border-gray-200 -mx-3 px-3 pt-3 mt-1",children:[
145
+ /* @__PURE__ */g("label",{className:"flex items-center justify-between gap-2",children:[
146
+ /* @__PURE__ */b("span",{className:"font-medium",children:N.sectionView}),
147
+ /* @__PURE__ */b("button",{onClick:()=>Q(e=>!e),role:"switch","aria-checked":Z,className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors "+(Z?"bg-blue-500":"bg-gray-300"),children:/* @__PURE__ */b("span",{className:"inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform "+(Z?"translate-x-[18px]":"translate-x-0.5")})})]}),
148
+ /* @__PURE__ */g("div",{className:Z?"mt-2 space-y-2":"mt-2 space-y-2 opacity-40 pointer-events-none",children:[
149
+ /* @__PURE__ */g("div",{children:[
150
+ /* @__PURE__ */g("div",{className:"flex items-center justify-between gap-2 mb-1",children:[
151
+ /* @__PURE__ */b("span",{children:N.angle}),
152
+ /* @__PURE__ */g("span",{className:"text-gray-500 tabular-nums",children:[se,"°"]})]}),
153
+ /* @__PURE__ */b("input",{type:"range",min:0,max:180,step:1,value:se,onChange:e=>ae(Number(e.target.value)),className:"w-full accent-blue-500"})]}),
154
+ /* @__PURE__ */g("div",{children:[
155
+ /* @__PURE__ */g("div",{className:"flex items-center justify-between gap-2 mb-1",children:[
156
+ /* @__PURE__ */b("span",{children:N.axis}),
157
+ /* @__PURE__ */b("button",{onClick:()=>ne(e=>!e),className:"text-[10px] text-gray-600 hover:text-gray-900 px-1.5 py-0.5 rounded bg-gray-100 hover:bg-gray-200",title:N.flipHint,children:te?N.flipped:N.flip})]}),
158
+ /* @__PURE__ */b("div",{className:"grid grid-cols-3 gap-1",children:["x","y","z"].map(e=>/* @__PURE__ */b("button",{onClick:()=>ee(e),className:"py-1 rounded text-[11px] font-semibold "+(J===e?"bg-blue-500 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:e.toUpperCase()},e))})]}),
159
+ /* @__PURE__ */g("div",{children:[
160
+ /* @__PURE__ */g("div",{className:"flex items-center justify-between gap-2 mb-1",children:[
161
+ /* @__PURE__ */b("span",{children:N.position}),
162
+ /* @__PURE__ */g("span",{className:"text-gray-500 tabular-nums",children:[Math.round(100*re),"%"]})]}),
163
+ /* @__PURE__ */b("input",{type:"range",min:0,max:1,step:.01,value:re,onChange:e=>ie(Number(e.target.value)),className:"w-full accent-blue-500"})]})]})]})]}),
164
+ /* @__PURE__ */b("div",{className:"px-3 py-2 border-t border-gray-200",children:/* @__PURE__ */b("button",{onClick:()=>{O("#f5f6f8"),W(!0),X("#000000"),_(1),Q(!1),ee("x"),ne(!1),ie(.5),ae(0)},className:"w-full text-[11px] text-gray-700 bg-gray-100 hover:bg-gray-200 rounded py-1.5 transition-colors",children:N.resetDisplay})})]})]})})]})}function D({url:e,filename:t,onDownload:i,onEmail:s}){const[a,o]=x(1),[l,c]=x(!1),[u,m]=x(!1),f=y(null),v=p().preview,k="px-2 py-1 rounded hover:bg-gray-200 transition-colors text-gray-600 flex items-center gap-1";/* @__PURE__ */
165
+ return g("div",{className:"flex flex-col h-full",children:[
166
+ /* @__PURE__ */g(n,{children:[!u&&/* @__PURE__ */g(w,{children:[
167
+ /* @__PURE__ */b("button",{onClick:()=>o(e=>Math.max(.1,Math.round(100*(e-.25))/100)),className:k,children:"−"}),
168
+ /* @__PURE__ */g("span",{className:"text-gray-500 w-12 text-center tabular-nums",children:[Math.round(100*a),"%"]}),
169
+ /* @__PURE__ */b("button",{onClick:()=>o(e=>Math.min(8,Math.round(100*(e+.25))/100)),className:k,children:"+"}),
170
+ /* @__PURE__ */b("button",{onClick:()=>o(1),className:k,children:"1:1"}),
171
+ /* @__PURE__ */b("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
172
+ /* @__PURE__ */g("button",{onClick:()=>m(!0),className:k,title:v.annotateHint,children:[
173
+ /* @__PURE__ */b(h,{name:"edit",className:"h-3.5 w-3.5",strokeWidth:1.5}),v.annotate]})]}),u&&/* @__PURE__ */g(w,{children:[
174
+ /* @__PURE__ */g("button",{onClick:()=>m(!1),className:k,title:v.viewHint,children:[
175
+ /* @__PURE__ */b(h,{name:"chevron-left",className:"h-3.5 w-3.5",strokeWidth:1.5}),v.view]}),
176
+ /* @__PURE__ */g("button",{onClick:()=>f.current?.copy(),className:k,children:[
177
+ /* @__PURE__ */b(h,{name:"duplicate",className:"h-3.5 w-3.5",strokeWidth:1.5}),v.copy]}),
178
+ /* @__PURE__ */g("button",{onClick:()=>f.current?.save(),className:k,children:[
179
+ /* @__PURE__ */b(h,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),v.save]})]}),
180
+ /* @__PURE__ */g("button",{onClick:i??(async()=>{if(e.startsWith("blob:")||e.startsWith("data:")){const n=document.createElement("a");return n.href=e,n.download=t,void n.click()}const n=async t=>{const n=await fetch(e,t);if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.blob()};try{let e;try{e=await n({credentials:"include"})}catch{e=await n({credentials:"omit"})}const r=URL.createObjectURL(e),i=document.createElement("a");i.href=r,i.download=t,i.click(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}catch{d.error(v.downloadFailed)}}),className:k,children:[
181
+ /* @__PURE__ */b(h,{name:"download",className:"h-3.5 w-3.5",strokeWidth:1.5}),v.download]}),s&&/* @__PURE__ */g("button",{onClick:s,className:k,children:[
182
+ /* @__PURE__ */b(h,{name:"email",className:"h-3.5 w-3.5",strokeWidth:1.5}),v.email]})]}),u?/* @__PURE__ */b(r,{ref:f,src:e,filename:t}):/* @__PURE__ */b("div",{className:"flex-1 overflow-auto bg-gray-100 flex items-center justify-center p-4",children:l?/* @__PURE__ */b("div",{className:"text-sm text-red-600",children:v.imageFailed}):/* @__PURE__ */b("img",{src:e,alt:t,onError:()=>c(!0),style:{transform:`scale(${a})`,transformOrigin:"center center",transition:"transform 120ms ease"},className:"max-w-full max-h-full shadow-lg rounded bg-white"})})]})}export{N as default};
@@ -0,0 +1,44 @@
1
+ import{useAuth as e,parseOpenSections as t,readStored as a,RAIL_OPEN_SECTIONS_KEY as r,toggleOpenSection as n,writeStored as i}from"./chunk-S2PS4IOT.js";import{partitionNav as l,BrandMark as o,openGlobalSearch as s,visibleNavChildren as c,visibleSectionItems as d,rowsContainRoute as m}from"./chunk-7PGHRG6J.js";import{navSections as h,startMenuCategories as p,TAB_STRIP_H as u,navIcons as b,sectionIcons as g}from"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import{PopupMenu as f,PopupMenuItem as x,PopupMenuDivider as y}from"./chunk-ZEIKSMFR.js";import"./chunk-UVBK6YSR.js";import"./chunk-7IQ3B77H.js";import"./chunk-FIEA5CGB.js";import"./chunk-D65T4H6J.js";import{useShellStrings as N}from"./chunk-K6DKX55N.js";import"./chunk-C3QOHMR6.js";import{Icon as v}from"./chunk-2SSRFEOZ.js";import{useMemo as k,useState as w,useRef as C,useEffect as S,isValidElement as j,cloneElement as z}from"react";import{jsx as L,jsxs as $}from"react/jsx-runtime";var A="undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),I=(e,t)=>["flex h-9 w-full items-center gap-2.5 rounded-md px-3 text-left text-[13.5px] font-medium transition-colors",t?"justify-center px-0":"",e?"bg-gray-100 text-gray-900":"text-gray-600 hover:bg-gray-100 hover:text-gray-900"].join(" "),W="flex size-[18px] shrink-0 items-center justify-center [&>svg]:size-[18px]";function K({open:e}){/* @__PURE__ */
2
+ return L(v,{name:"chevron-down",className:"size-4 shrink-0 text-gray-400 transition-transform "+(e?"rotate-180":""),strokeWidth:2,"aria-hidden":"true"})}function R({dir:e}){/* @__PURE__ */
3
+ return L(v,"left"===e?{name:"chevron-double-left",className:"size-[18px]",strokeWidth:1.5,"aria-hidden":"true"}:{name:"chevron-double-right",className:"size-[18px]",strokeWidth:1.5,"aria-hidden":"true"})}function M({className:e}){/* @__PURE__ */
4
+ return L(v,{name:"search",className:e,strokeWidth:2,"aria-hidden":"true"})}function T({width:T,collapsed:B,onToggleCollapsed:H,onOpen:O,activeRoute:D,profile:_,user:P,onLogout:E,onSwitchToDesktop:F,onReportBug:G,navSections:J=h,navIcons:Q=b,sectionIcons:X=g,categories:U=p,productName:Z,productIcon:V,tagline:Y,adaptiveLogo:q=!1,logoHasAlpha:ee=null,logoIsLight:te=null}){const ae=N().layout,{hasAnyPerm:re}=e(),ne=k(()=>l(J,U,re),[J,U,re]),[ie,le]=w(()=>t(a(r))),oe=e=>le(t=>{const a=n(t,e);return i(r,JSON.stringify([...a])),a}),[se,ce]=w(null),[de,me]=w(!1),he=C(null);S(()=>{B||ce(null)},[B]);const pe=(e,t)=>{ce(null),e.onSelect?e.onSelect():O(e.to,!!t&&(e=>e.metaKey||e.ctrlKey||1===e.button)(t))},ue=(e,t)=>{const a=t[e];/* @__PURE__ */
5
+ return L("span",{className:W,"aria-hidden":"true",children:a&&j(a)?z(a,{className:"size-[18px]"}):a})},be=(e,t)=>{const a=c(e,re),r=e.menuLabel??e.label;if(a.length>0){const n=`child:${e.to}`,i=ie.has(n),l=!i&&m(a,D,re);/* @__PURE__ */
6
+ return $("div",{children:[
7
+ /* @__PURE__ */$("button",{type:"button",onClick:()=>oe(n),"aria-expanded":i,className:I(l,!1),style:t>0?{paddingLeft:.75+1.75*t+"rem"}:void 0,children:[0===t&&ue(e.to,Q),
8
+ /* @__PURE__ */L("span",{className:"min-w-0 flex-1 truncate",children:r}),
9
+ /* @__PURE__ */L(K,{open:i})]}),i&&/* @__PURE__ */L("div",{className:"space-y-0.5 pt-0.5",children:a.map(e=>be(e,t+1))}),e.dividerAfter&&/* @__PURE__ */L("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.to)}const n=e.to===D;/* @__PURE__ */
10
+ return $("div",{children:[
11
+ /* @__PURE__ */$("button",{type:"button",onClick:t=>pe(e,t),onAuxClick:t=>{1===t.button&&pe(e,t)},"aria-current":n?"page":void 0,className:I(n,!1),style:t>0?{paddingLeft:.75+1.75*t+"rem"}:void 0,children:[0===t&&ue(e.to,Q),
12
+ /* @__PURE__ */L("span",{className:"min-w-0 flex-1 truncate",children:r})]}),e.dividerAfter&&/* @__PURE__ */L("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.to)},ge=(e,t)=>{const a=t?e.items:d(e,re);if(0===a.length)return null;const r="icon"in e&&e.icon?/* @__PURE__ */L("span",{className:W,"aria-hidden":"true",children:e.icon}):ue(e.label,X),n=e.menuLabel??e.label,i=m(a,D,re),l="dividerAfter"in e&&e.dividerAfter;if(B)/* @__PURE__ */
13
+ return $("div",{children:[
14
+ /* @__PURE__ */L("button",{type:"button",title:n,"aria-label":n,"aria-haspopup":"menu","aria-expanded":se?.label===e.label,onClick:t=>{const r=t.currentTarget.getBoundingClientRect();ce(t=>t?.label===e.label?null:{label:e.label,items:a,top:r.top})},className:I(i||se?.label===e.label,!0),children:r}),l&&/* @__PURE__ */L("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.label);const o=ie.has(e.label),s=`rosh-rail-${e.label.replace(/[^a-z0-9]+/gi,"-").toLowerCase()}`;/* @__PURE__ */
15
+ return $("div",{children:[
16
+ /* @__PURE__ */$("button",{type:"button",onClick:()=>oe(e.label),"aria-expanded":o,"aria-controls":s,className:I(!o&&i,!1),children:[r,
17
+ /* @__PURE__ */L("span",{className:"min-w-0 flex-1 truncate",children:n}),
18
+ /* @__PURE__ */L(K,{open:o})]}),
19
+ /* @__PURE__ */L("div",{id:s,role:"group","aria-label":n,hidden:!o,className:"space-y-0.5 pt-0.5",children:o&&a.map(e=>be(e,1))}),l&&/* @__PURE__ */L("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.label)},fe=_?.first_name?`${_.first_name} ${_.last_name||""}`.trim():P?.email||"",xe=(_?.first_name?.charAt(0)||P?.email?.charAt(0)||"?").toUpperCase(),ye=_?.avatar_url?/* @__PURE__ */L("img",{src:_.avatar_url,alt:"",className:"size-8 shrink-0 rounded-full object-cover"}):/* @__PURE__ */L("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-full bg-blue-600 text-xs font-semibold text-white",children:xe}),Ne=de?he.current?.getBoundingClientRect():void 0,ve=B?"px-2.5":"px-3",ke=ne.erpSections.length>0||ne.systemSections.length>0||ne.virtualSections.length>0;/* @__PURE__ */
20
+ return $("aside",{"aria-label":ae.navLabel,className:"fixed left-0 top-0 z-(--z-sidebar) flex h-dvh flex-col border-r border-gray-200 bg-white text-gray-800",style:{width:T},children:[
21
+ /* @__PURE__ */$("div",{className:"flex shrink-0 items-center border-b border-gray-200 "+(B?"justify-center":"justify-between gap-2 pl-4 pr-2"),style:{height:u},children:[
22
+ /* @__PURE__ */$("span",{className:"flex min-w-0 items-center gap-2",children:[V&&/* @__PURE__ */L(o,{src:V,alt:"",slot:"compact",surface:"light",adaptive:q,hasAlpha:ee,isLight:te,size:28,decorative:!0}),!B&&/* @__PURE__ */$("span",{className:"min-w-0 leading-tight",children:[
23
+ /* @__PURE__ */L("span",{className:"block truncate text-[15px] font-bold tracking-wide text-gray-900",children:Z??"Apps"}),Y&&/* @__PURE__ */L("span",{className:"block truncate text-[11px] font-medium text-gray-500",children:Y})]})]}),!B&&/* @__PURE__ */L("button",{type:"button",onClick:H,"aria-label":ae.collapseSidebar,title:`${ae.collapseSidebar} (${A?"⌘":"Ctrl"} .)`,className:"flex size-8 shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900",children:/* @__PURE__ */L(R,{dir:"left"})})]}),
24
+ /* @__PURE__ */L("div",{className:`shrink-0 pt-3 ${ve}`,children:B?/* @__PURE__ */L("button",{type:"button",onClick:s,"aria-label":ae.search,title:`${ae.search} (${A?"⌘K":"Ctrl K"})`,className:I(!1,!0),children:/* @__PURE__ */L(M,{className:"size-[18px]"})}):/* @__PURE__ */$("button",{type:"button",onClick:s,className:"flex h-[34px] w-full items-center gap-2 rounded-md border border-gray-200 bg-white px-2.5 text-left transition-colors hover:bg-gray-100",children:[
25
+ /* @__PURE__ */L(M,{className:"size-3.5 text-gray-500"}),
26
+ /* @__PURE__ */L("span",{className:"min-w-0 flex-1 truncate text-[13px] text-gray-500",children:ae.search}),
27
+ /* @__PURE__ */L("kbd",{className:"rounded border border-gray-200 bg-gray-100 px-1.5 py-0.5 font-mono text-[11px] font-semibold text-gray-500",children:A?"⌘K":"Ctrl K"})]})}),
28
+ /* @__PURE__ */$("nav",{"aria-label":ae.navLabel,className:`min-h-0 flex-1 overflow-y-auto pb-4 pt-3 ${ve} ${B?"space-y-1":"space-y-0.5"}`,children:[B&&/* @__PURE__ */L("button",{type:"button",onClick:H,"aria-label":ae.expandSidebar,title:`${ae.expandSidebar} (${A?"⌘":"Ctrl"} .)`,className:`${I(!1,!0)} mb-3`,children:/* @__PURE__ */L(R,{dir:"right"})}),ne.topItems.map(e=>{if(!B)return be(e,0);const t=c(e,re),a=e.to===D||m(t,D,re),r=e.menuLabel??e.label;/* @__PURE__ */
29
+ return $("div",{children:[
30
+ /* @__PURE__ */L("button",{type:"button",title:r,"aria-label":r,onClick:a=>{if(0===t.length)return void pe(e,a);const r=a.currentTarget.getBoundingClientRect();ce(a=>a?.label===e.to?null:{label:e.to,items:t,top:r.top})},className:I(a,!0),children:ue(e.to,Q)}),e.dividerAfter&&/* @__PURE__ */L("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.to)}),ne.topItems.length>0&&ke&&/* @__PURE__ */L("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"}),ne.erpSections.map(e=>ge(e,!1)),ne.systemSections.map(e=>ge(e,!1)),ne.virtualSections.map(e=>ge(e,!0)),ne.footerSections.length>0&&/* @__PURE__ */L("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"}),ne.footerSections.map(e=>ge(e,!1))]}),
31
+ /* @__PURE__ */L("div",{className:`shrink-0 border-t border-gray-200 py-2 ${ve}`,children:/* @__PURE__ */$("button",{ref:he,type:"button",onClick:()=>me(e=>!e),"aria-haspopup":"menu","aria-expanded":de,"aria-label":B?ae.accountMenu(fe):void 0,className:"flex w-full items-center gap-2.5 rounded-md hover:bg-gray-100 "+(B?"justify-center py-2":"px-2 py-2"),children:[ye,!B&&/* @__PURE__ */$("span",{className:"min-w-0 flex-1 text-left",children:[
32
+ /* @__PURE__ */L("span",{className:"block truncate text-[13px] font-semibold text-gray-800",children:fe}),P?.email&&fe!==P.email&&/* @__PURE__ */L("span",{className:"block truncate text-[11px] text-gray-500",children:P.email})]})]})}),de&&Ne&&/* @__PURE__ */$(f,{portal:!0,minWidth:224,onClose:()=>me(!1),style:{left:Ne.left,bottom:window.innerHeight-Ne.top+8},children:[B&&/* @__PURE__ */$("div",{className:"border-b border-gray-200 px-3 py-2.5",children:[
33
+ /* @__PURE__ */L("p",{className:"truncate text-sm font-semibold text-gray-800",children:fe}),P?.email&&/* @__PURE__ */L("p",{className:"truncate text-xs text-gray-500",children:P.email})]}),
34
+ /* @__PURE__ */$(x,{onClick:()=>{me(!1),O("/profile",!1)},children:[
35
+ /* @__PURE__ */L(v,{name:"account",className:"h-4 w-4 text-gray-400",strokeWidth:1.5,"aria-hidden":"true"}),ae.profile]}),ne.footerItems.map(e=>/* @__PURE__ */$(x,{onClick:()=>{me(!1),pe(e)},children:[
36
+ /* @__PURE__ */L("span",{className:"h-4 w-4 text-gray-400 [&>svg]:size-4","aria-hidden":"true",children:Q[e.to]}),e.menuLabel??e.label]},e.to)),G&&/* @__PURE__ */$(x,{onClick:()=>{me(!1),G()},children:[
37
+ /* @__PURE__ */L(v,{name:"error",className:"h-4 w-4 text-gray-400",strokeWidth:1.5,"aria-hidden":"true"}),ae.reportIssue]}),
38
+ /* @__PURE__ */L(y,{}),
39
+ /* @__PURE__ */$(x,{onClick:()=>{me(!1),F()},children:[
40
+ /* @__PURE__ */L(v,{name:"desktop",className:"h-4 w-4 text-gray-400",strokeWidth:1.5,"aria-hidden":"true"}),ae.switchToDesktop]}),
41
+ /* @__PURE__ */L(y,{}),
42
+ /* @__PURE__ */$(x,{danger:!0,onClick:()=>{me(!1),E()},children:[
43
+ /* @__PURE__ */L(v,{name:"logout",className:"h-4 w-4",strokeWidth:1.5,"aria-hidden":"true"}),ae.signOut]})]}),se&&B&&/* @__PURE__ */L(f,{portal:!0,minWidth:220,onClose:()=>ce(null),style:{left:T+6,top:Math.min(se.top,window.innerHeight-48*Math.min(se.items.length,10)-16)},children:se.items.flatMap(e=>{const t=c(e,re);return(t.length>0?t:[e]).map(e=>/* @__PURE__ */$(x,{onClick:()=>pe(e),children:[ue(e.to,Q),
44
+ /* @__PURE__ */L("span",{className:e.to===D?"font-semibold":"",children:e.menuLabel??e.label})]},e.to))})})]})}export{T as default};