efficient-shell 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +29 -2
  2. package/dist/{Browser-5F5LWXYQ.js → Browser-WUVL7ZSM.js} +18 -18
  3. package/dist/Calculator-E2CBADVF.js +29 -0
  4. package/dist/ConfirmDialog-ZM364NPI.js +1 -0
  5. package/dist/{CurrencyConverter-QEG6RFAS.js → CurrencyConverter-LF2WHJW4.js} +7 -7
  6. package/dist/{Documents-6DEUZVVA.js → Documents-MB4TJGNY.js} +26 -26
  7. package/dist/Files-JQYIBZEP.js +87 -0
  8. package/dist/{Notepad-KNJRTYXR.js → Notepad-UQSG5BE3.js} +11 -11
  9. package/dist/PdfViewer-4VGNBBED.js +1 -0
  10. package/dist/{PomodoroTimer-T6YAQFIE.js → PomodoroTimer-XARF7DO3.js} +50 -50
  11. package/dist/{Preview-KEIDYSHF.js → Preview-LETK6AJS.js} +126 -126
  12. package/dist/Sidebar-VR4QYFQU.js +44 -0
  13. package/dist/{Spreadsheet-HKXSYD5B.js → Spreadsheet-RCHOM2RE.js} +13 -13
  14. package/dist/{Stock-BZFC2ROU.js → Stock-25FQMI2G.js} +3 -3
  15. package/dist/{Weather-S3N5OWYF.js → Weather-KLQ55R64.js} +17 -17
  16. package/dist/{WorldClock-ACC3S6OA.js → WorldClock-RMPU7D2M.js} +6 -6
  17. package/dist/apps/index.js +1 -1
  18. package/dist/bin/ui-check.js +1 -1
  19. package/dist/brand.css +1 -1
  20. package/dist/{chunk-2DX65GOO.js → chunk-2KTBZE5F.js} +1 -1
  21. package/dist/{chunk-PQLVWCUI.js → chunk-2TP4GK53.js} +5 -5
  22. package/dist/chunk-3JK2LSFU.js +1 -0
  23. package/dist/{chunk-R7EBJKN2.js → chunk-4KLBITSY.js} +28 -28
  24. package/dist/{chunk-5IWSOLLY.js → chunk-5LCZFVE4.js} +2 -2
  25. package/dist/{chunk-GMMTTWHB.js → chunk-6TCHOT4R.js} +1 -1
  26. package/dist/{chunk-3DGTIWZP.js → chunk-DBB4DB7J.js} +1 -1
  27. package/dist/{chunk-KDRAU4XQ.js → chunk-DXNCJBGY.js} +7 -7
  28. package/dist/{chunk-WNEO7TSP.js → chunk-FA6E75W5.js} +1 -1
  29. package/dist/{chunk-TKUNR5KP.js → chunk-GPNNQIRY.js} +2 -2
  30. package/dist/{chunk-LK7V32MR.js → chunk-H5NEXQTX.js} +1 -1
  31. package/dist/{chunk-T4CFSGSL.js → chunk-HKLW5KTW.js} +6 -6
  32. package/dist/{chunk-NHIGOEZF.js → chunk-JK2KQ4PF.js} +1 -1
  33. package/dist/chunk-LOXV3J6X.js +1005 -0
  34. package/dist/{chunk-QRV7RNQX.js → chunk-LTGIQ7HO.js} +14 -14
  35. package/dist/{chunk-MIAJQGWE.js → chunk-LY2G6LHW.js} +1 -1
  36. package/dist/{chunk-PE4F4MJE.js → chunk-MDI265RK.js} +4 -4
  37. package/dist/{chunk-FOEVG7RT.js → chunk-N3W6PH55.js} +11 -11
  38. package/dist/chunk-OBMR6BEP.js +1 -0
  39. package/dist/{chunk-SBDIHKLU.js → chunk-TMZVVRTA.js} +20 -20
  40. package/dist/{chunk-ZZKIKW62.js → chunk-VOY6TCS2.js} +19 -19
  41. package/dist/{chunk-VJP3R52B.js → chunk-XNHYCOPO.js} +1 -1
  42. package/dist/file-intake/index.js +1 -1
  43. package/dist/i18n/index.d.ts +1 -1
  44. package/dist/{index-HMDUOPnX.d.ts → index-CzMz_Y9A.d.ts} +139 -3
  45. package/dist/index.d.ts +3 -3
  46. package/dist/index.js +479 -479
  47. package/dist/locales/zh-Hans.d.ts +1 -1
  48. package/dist/locales/zh-Hans.js +1 -1
  49. package/dist/map/index.js +5 -5
  50. package/dist/page-tabs/index.js +5 -5
  51. package/dist/pdf/index.js +1 -1
  52. package/dist/{strings-ZbotP_I6.d.ts → strings-BEuOOURI.d.ts} +21 -0
  53. package/dist/ui/index.d.ts +2 -2
  54. package/dist/ui/index.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/Calculator-4K53PFBL.js +0 -29
  57. package/dist/ConfirmDialog-X2DPOYWO.js +0 -1
  58. package/dist/Files-2VSFXA45.js +0 -87
  59. package/dist/PdfViewer-UZGDE4HD.js +0 -1
  60. package/dist/Sidebar-3NZRIL7F.js +0 -44
  61. package/dist/chunk-67PNFBCW.js +0 -993
  62. package/dist/chunk-J3LIIIHJ.js +0 -1
  63. package/dist/chunk-YKHMAGEM.js +0 -1
@@ -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 l}from"./chunk-S2PS4IOT.js";import{partitionNav as i,BrandMark as o,openGlobalSearch as s,visibleNavChildren as c,visibleSectionItems as d,rowsContainRoute as m}from"./chunk-DXNCJBGY.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-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import{AccountFallback as k,ErrorFallback as N,DesktopFallback as v,LogoutFallback as w,ChevronDoubleLeftFallback as C,ChevronDoubleRightFallback as j,SearchFallback as S,ChevronDownFallback as L}from"./chunk-XUF7VW4U.js";import{useShellStrings as z}from"./chunk-3JK2LSFU.js";import"./chunk-C3QOHMR6.js";import{Icon as A}from"./chunk-YKZHOXI4.js";import{useMemo as $,useState as W,useRef as I,useEffect as H,isValidElement as T,cloneElement as K}from"react";import{jsx as O,jsxs as R}from"react/jsx-runtime";var D="undefined"!=typeof navigator&&/Mac|iPhone|iPad/.test(navigator.platform),M=(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(" "),J="flex size-[18px] shrink-0 items-center justify-center [&>svg]:size-[18px]";function P({open:e}){/* @__PURE__ */
2
+ return O(A,{name:"chevron-down",fallback:L,className:"size-4 shrink-0 text-gray-400 transition-transform "+(e?"rotate-180":""),strokeWidth:2,"aria-hidden":"true"})}function X({dir:e}){/* @__PURE__ */
3
+ return O(A,"left"===e?{name:"chevron-double-left",fallback:C,className:"size-[18px]",strokeWidth:1.5,"aria-hidden":"true"}:{name:"chevron-double-right",fallback:j,className:"size-[18px]",strokeWidth:1.5,"aria-hidden":"true"})}function _({className:e}){/* @__PURE__ */
4
+ return O(A,{name:"search",fallback:S,className:e,strokeWidth:2,"aria-hidden":"true"})}function B({width:C,collapsed:j,onToggleCollapsed:S,onOpen:L,activeRoute:B,profile:F,user:Z,onLogout:U,onSwitchToDesktop:Q,onReportBug:Y,navSections:V=h,navIcons:G=b,sectionIcons:q=g,categories:E=p,productName:ee,productIcon:te,tagline:ae,adaptiveLogo:re=!1,logoHasAlpha:ne=null,logoIsLight:le=null}){const ie=z().layout,{hasAnyPerm:oe}=e(),se=$(()=>i(V,E,oe),[V,E,oe]),[ce,de]=W(()=>t(a(r))),me=e=>de(t=>{const a=n(t,e);return l(r,JSON.stringify([...a])),a}),[he,pe]=W(null),[ue,be]=W(!1),ge=I(null);H(()=>{j||pe(null)},[j]);const fe=(e,t)=>{pe(null),e.onSelect?e.onSelect():L(e.to,!!t&&(e=>e.metaKey||e.ctrlKey||1===e.button)(t))},xe=(e,t)=>{const a=t[e];/* @__PURE__ */
5
+ return O("span",{className:J,"aria-hidden":"true",children:a&&T(a)?K(a,{className:"size-[18px]"}):a})},ye=(e,t)=>{const a=c(e,oe),r=e.menuLabel??e.label;if(a.length>0){const n=`child:${e.to}`,l=ce.has(n),i=!l&&m(a,B,oe);/* @__PURE__ */
6
+ return R("div",{children:[
7
+ /* @__PURE__ */R("button",{type:"button",onClick:()=>me(n),"aria-expanded":l,className:M(i,!1),style:t>0?{paddingLeft:.75+1.75*t+"rem"}:void 0,children:[0===t&&xe(e.to,G),
8
+ /* @__PURE__ */O("span",{className:"min-w-0 flex-1 truncate",children:r}),
9
+ /* @__PURE__ */O(P,{open:l})]}),l&&/* @__PURE__ */O("div",{className:"space-y-0.5 pt-0.5",children:a.map(e=>ye(e,t+1))}),e.dividerAfter&&/* @__PURE__ */O("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.to)}const n=e.to===B;/* @__PURE__ */
10
+ return R("div",{children:[
11
+ /* @__PURE__ */R("button",{type:"button",onClick:t=>fe(e,t),onAuxClick:t=>{1===t.button&&fe(e,t)},"aria-current":n?"page":void 0,className:M(n,!1),style:t>0?{paddingLeft:.75+1.75*t+"rem"}:void 0,children:[0===t&&xe(e.to,G),
12
+ /* @__PURE__ */O("span",{className:"min-w-0 flex-1 truncate",children:r})]}),e.dividerAfter&&/* @__PURE__ */O("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.to)},ke=(e,t)=>{const a=t?e.items:d(e,oe);if(0===a.length)return null;const r="icon"in e&&e.icon?/* @__PURE__ */O("span",{className:J,"aria-hidden":"true",children:e.icon}):xe(e.label,q),n=e.menuLabel??e.label,l=m(a,B,oe),i="dividerAfter"in e&&e.dividerAfter;if(j)/* @__PURE__ */
13
+ return R("div",{children:[
14
+ /* @__PURE__ */O("button",{type:"button",title:n,"aria-label":n,"aria-haspopup":"menu","aria-expanded":he?.label===e.label,onClick:t=>{const r=t.currentTarget.getBoundingClientRect();pe(t=>t?.label===e.label?null:{label:e.label,items:a,top:r.top})},className:M(l||he?.label===e.label,!0),children:r}),i&&/* @__PURE__ */O("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.label);const o=ce.has(e.label),s=`rosh-rail-${e.label.replace(/[^a-z0-9]+/gi,"-").toLowerCase()}`;/* @__PURE__ */
15
+ return R("div",{children:[
16
+ /* @__PURE__ */R("button",{type:"button",onClick:()=>me(e.label),"aria-expanded":o,"aria-controls":s,className:M(!o&&l,!1),children:[r,
17
+ /* @__PURE__ */O("span",{className:"min-w-0 flex-1 truncate",children:n}),
18
+ /* @__PURE__ */O(P,{open:o})]}),
19
+ /* @__PURE__ */O("div",{id:s,role:"group","aria-label":n,hidden:!o,className:"space-y-0.5 pt-0.5",children:o&&a.map(e=>ye(e,1))}),i&&/* @__PURE__ */O("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.label)},Ne=F?.first_name?`${F.first_name} ${F.last_name||""}`.trim():Z?.email||"",ve=(F?.first_name?.charAt(0)||Z?.email?.charAt(0)||"?").toUpperCase(),we=F?.avatar_url?/* @__PURE__ */O("img",{src:F.avatar_url,alt:"",className:"size-8 shrink-0 rounded-full object-cover"}):/* @__PURE__ */O("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-full bg-blue-600 text-xs font-semibold text-white",children:ve}),Ce=ue?ge.current?.getBoundingClientRect():void 0,je=j?"px-2.5":"px-3",Se=se.erpSections.length>0||se.systemSections.length>0||se.virtualSections.length>0;/* @__PURE__ */
20
+ return R("aside",{"aria-label":ie.navLabel,className:"fixed left-0 top-0 z-[260] flex h-dvh flex-col border-r border-gray-200 bg-white text-gray-800",style:{width:C},children:[
21
+ /* @__PURE__ */R("div",{className:"flex shrink-0 items-center border-b border-gray-200 "+(j?"justify-center":"justify-between gap-2 pl-4 pr-2"),style:{height:u},children:[
22
+ /* @__PURE__ */R("span",{className:"flex min-w-0 items-center gap-2",children:[te&&/* @__PURE__ */O(o,{src:te,alt:"",slot:"compact",surface:"light",adaptive:re,hasAlpha:ne,isLight:le,size:28,decorative:!0}),!j&&/* @__PURE__ */R("span",{className:"min-w-0 leading-tight",children:[
23
+ /* @__PURE__ */O("span",{className:"block truncate text-[15px] font-bold tracking-wide text-gray-900",children:ee??"Apps"}),ae&&/* @__PURE__ */O("span",{className:"block truncate text-[11px] font-medium text-gray-500",children:ae})]})]}),!j&&/* @__PURE__ */O("button",{type:"button",onClick:S,"aria-label":ie.collapseSidebar,title:`${ie.collapseSidebar} (${D?"⌘":"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__ */O(X,{dir:"left"})})]}),
24
+ /* @__PURE__ */O("div",{className:`shrink-0 pt-3 ${je}`,children:j?/* @__PURE__ */O("button",{type:"button",onClick:s,"aria-label":ie.search,title:`${ie.search} (${D?"⌘K":"Ctrl K"})`,className:M(!1,!0),children:/* @__PURE__ */O(_,{className:"size-[18px]"})}):/* @__PURE__ */R("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__ */O(_,{className:"size-3.5 text-gray-500"}),
26
+ /* @__PURE__ */O("span",{className:"min-w-0 flex-1 truncate text-[13px] text-gray-500",children:ie.search}),
27
+ /* @__PURE__ */O("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:D?"⌘K":"Ctrl K"})]})}),
28
+ /* @__PURE__ */R("nav",{"aria-label":ie.navLabel,className:`min-h-0 flex-1 overflow-y-auto pb-4 pt-3 ${je} ${j?"space-y-1":"space-y-0.5"}`,children:[j&&/* @__PURE__ */O("button",{type:"button",onClick:S,"aria-label":ie.expandSidebar,title:`${ie.expandSidebar} (${D?"⌘":"Ctrl"} .)`,className:`${M(!1,!0)} mb-3`,children:/* @__PURE__ */O(X,{dir:"right"})}),se.topItems.map(e=>{if(!j)return ye(e,0);const t=c(e,oe),a=e.to===B||m(t,B,oe),r=e.menuLabel??e.label;/* @__PURE__ */
29
+ return R("div",{children:[
30
+ /* @__PURE__ */O("button",{type:"button",title:r,"aria-label":r,onClick:a=>{if(0===t.length)return void fe(e,a);const r=a.currentTarget.getBoundingClientRect();pe(a=>a?.label===e.to?null:{label:e.to,items:t,top:r.top})},className:M(a,!0),children:xe(e.to,G)}),e.dividerAfter&&/* @__PURE__ */O("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"})]},e.to)}),se.topItems.length>0&&Se&&/* @__PURE__ */O("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"}),se.erpSections.map(e=>ke(e,!1)),se.systemSections.map(e=>ke(e,!1)),se.virtualSections.map(e=>ke(e,!0)),se.footerSections.length>0&&/* @__PURE__ */O("div",{className:"mx-2 my-1.5 border-t border-gray-200","aria-hidden":"true"}),se.footerSections.map(e=>ke(e,!1))]}),
31
+ /* @__PURE__ */O("div",{className:`shrink-0 border-t border-gray-200 py-2 ${je}`,children:/* @__PURE__ */R("button",{ref:ge,type:"button",onClick:()=>be(e=>!e),"aria-haspopup":"menu","aria-expanded":ue,"aria-label":j?ie.accountMenu(Ne):void 0,className:"flex w-full items-center gap-2.5 rounded-md hover:bg-gray-100 "+(j?"justify-center py-2":"px-2 py-2"),children:[we,!j&&/* @__PURE__ */R("span",{className:"min-w-0 flex-1 text-left",children:[
32
+ /* @__PURE__ */O("span",{className:"block truncate text-[13px] font-semibold text-gray-800",children:Ne}),Z?.email&&Ne!==Z.email&&/* @__PURE__ */O("span",{className:"block truncate text-[11px] text-gray-500",children:Z.email})]})]})}),ue&&Ce&&/* @__PURE__ */R(f,{portal:!0,minWidth:224,onClose:()=>be(!1),style:{left:Ce.left,bottom:window.innerHeight-Ce.top+8},children:[j&&/* @__PURE__ */R("div",{className:"border-b border-gray-200 px-3 py-2.5",children:[
33
+ /* @__PURE__ */O("p",{className:"truncate text-sm font-semibold text-gray-800",children:Ne}),Z?.email&&/* @__PURE__ */O("p",{className:"truncate text-xs text-gray-500",children:Z.email})]}),
34
+ /* @__PURE__ */R(x,{onClick:()=>{be(!1),L("/profile",!1)},children:[
35
+ /* @__PURE__ */O(A,{name:"account",fallback:k,className:"h-4 w-4 text-gray-400",strokeWidth:1.5,"aria-hidden":"true"}),ie.profile]}),se.footerItems.map(e=>/* @__PURE__ */R(x,{onClick:()=>{be(!1),fe(e)},children:[
36
+ /* @__PURE__ */O("span",{className:"h-4 w-4 text-gray-400 [&>svg]:size-4","aria-hidden":"true",children:G[e.to]}),e.menuLabel??e.label]},e.to)),Y&&/* @__PURE__ */R(x,{onClick:()=>{be(!1),Y()},children:[
37
+ /* @__PURE__ */O(A,{name:"error",fallback:N,className:"h-4 w-4 text-gray-400",strokeWidth:1.5,"aria-hidden":"true"}),ie.reportIssue]}),
38
+ /* @__PURE__ */O(y,{}),
39
+ /* @__PURE__ */R(x,{onClick:()=>{be(!1),Q()},children:[
40
+ /* @__PURE__ */O(A,{name:"desktop",fallback:v,className:"h-4 w-4 text-gray-400",strokeWidth:1.5,"aria-hidden":"true"}),ie.switchToDesktop]}),
41
+ /* @__PURE__ */O(y,{}),
42
+ /* @__PURE__ */R(x,{danger:!0,onClick:()=>{be(!1),U()},children:[
43
+ /* @__PURE__ */O(A,{name:"logout",fallback:w,className:"h-4 w-4",strokeWidth:1.5,"aria-hidden":"true"}),ie.signOut]})]}),he&&j&&/* @__PURE__ */O(f,{portal:!0,minWidth:220,onClose:()=>pe(null),style:{left:C+6,top:Math.min(he.top,window.innerHeight-48*Math.min(he.items.length,10)-16)},children:he.items.flatMap(e=>{const t=c(e,oe);return(t.length>0?t:[e]).map(e=>/* @__PURE__ */R(x,{onClick:()=>fe(e),children:[xe(e.to,G),
44
+ /* @__PURE__ */O("span",{className:e.to===B?"font-semibold":"",children:e.menuLabel??e.label})]},e.to))})})]})}export{B as default};
@@ -1,19 +1,19 @@
1
- import{EditableGrid as e}from"./chunk-T4CFSGSL.js";import"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-TKUNR5KP.js";import{peekSpreadsheetPreviewStage as r,claimSpreadsheetPreviewStage as n,SPREADSHEET_PREVIEW_UPDATE_EVENT as o}from"./chunk-VTVSMRFX.js";import{WindowTitle as a}from"./chunk-SBDIHKLU.js";import"./chunk-DSSLOQDW.js";import"./chunk-GMMTTWHB.js";import"./chunk-YKHMAGEM.js";import"./chunk-PQLVWCUI.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-ZZKIKW62.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-J3LIIIHJ.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useRef as l,useState as s,useEffect as c,useCallback as i}from"react";import{jsxs as u,jsx as d,Fragment as h}from"react/jsx-runtime";var m="ABCDEFGHIJKLMNOPQRSTUVWXYZ",p=10,x=30;function g(e){return e<26?m[e]:m[Math.floor(e/26)-1]+m[e%26]}function y(e){return Array.from({length:e},(e,t)=>({key:`col_${t}`,title:g(t),width:100}))}function b(e,t){return Array.from({length:e},()=>Array(t).fill(""))}function f(e){return{id:crypto.randomUUID(),name:e,columns:y(p),data:b(x,p),cellStyles:{}}}function v(e){return e.split("\n").map(e=>{if(e.includes("\t"))return e.split("\t").map(e=>e.trim());const t=[];let r="",n=!1;for(const o of e)'"'!==o?","!==o||n?r+=o:(t.push(r.trim()),r=""):n=!n;return t.push(r.trim()),t}).filter(e=>e.some(e=>e.trim()))}function k(e,t){const r=v(e);if(0===r.length)return null;const n=Math.max(p,r.reduce((e,t)=>Math.max(e,t.length),0)),o=r.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));return{id:crypto.randomUUID(),name:t,columns:y(n),data:o,cellStyles:{}}}function w(){const m=l(null),g=l(void 0);void 0===g.current&&(g.current=r());const w=l(g.current?.data??null),N=(()=>{const e=g.current;if(!e)return null;const t=k(e.data.csv,"Sheet 1");if(!t)return null;return{sheet:t,title:e.data.filename.replace(/\.(csv|tsv|txt)$/i,"")}})(),[C,S]=s(N?[N.sheet]:[f("Sheet 1")]),[j,M]=s(0),U=l([]),$=l(C),A=l(!1);c(()=>{A.current?A.current=!1:$.current!==C&&(U.current.push($.current),U.current.length>50&&U.current.shift()),$.current=C},[C]);const E=i(()=>{const e=U.current.pop();e&&(A.current=!0,S(e))},[]);c(()=>{const e=e=>{if(!m.current?.contains(document.activeElement)&&!m.current?.matches(":focus-within"))return;(e.ctrlKey||e.metaKey)&&!e.shiftKey&&("z"===e.key||"Z"===e.key)&&(e.preventDefault(),E())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E]);const[L,D]=s(N?.title??"Untitled"),[F,I]=s(()=>g.current?.data.onEmail),K=i(e=>{const t=k(e.csv,"Sheet 1");t&&(S([t]),M(0),D(e.filename.replace(/\.(csv|tsv|txt)$/i,"")),I(()=>e.onEmail))},[]);c(()=>{const e=g.current;null!=e&&(n(e),e.data!==w.current&&K(e.data))},[]),c(()=>{const e=g.current?.token;if(null==e)return;const t=t=>{const r=t.detail;r&&r.token===e&&K(r.data)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)},[]);const[R,H]=s(!1),[X,B]=s(null),[O,T]=s(""),W=l(null),[Z,V]=s("1"),[J,P]=s("10"),Q=C[j]||C[0],G=Q.data,z=Q.columns,Y=Q.cellStyles??{},[_,q]=s(null),[ee,te]=s(null),re=i(()=>{if(ee){const e=Math.min(ee.anchor.row,ee.end.row),t=Math.max(ee.anchor.row,ee.end.row),r=Math.min(ee.anchor.col,ee.end.col),n=Math.max(ee.anchor.col,ee.end.col),o=[];for(let a=e;a<=t;a++)for(let e=r;e<=n;e++)o.push({row:a,col:e});return o}return _?[_]:[]},[ee,_]),ne=i((e,t)=>{const r=re();0!==r.length&&S(n=>n.map((n,o)=>{if(o!==j)return n;const a={...n.cellStyles??{}},l=`${r[0].row}:${r[0].col}`,s=void 0!==t?t:!(a[l]??{})[e];for(const{row:t,col:n}of r){const r=`${t}:${n}`;a[r]={...a[r]??{},[e]:s}}return{...n,cellStyles:a}}))},[re,j]),oe=ee?{row:ee.anchor.row,col:ee.anchor.col}:_,ae=oe?Y[`${oe.row}:${oe.col}`]??{}:{},le=!!oe,se=i(e=>{S(t=>t.map((t,r)=>r===j?{...t,...e}:t))},[j]),ce=i(e=>{const t=e.reduce((e,t)=>Math.max(e,t.length),0);t!==z.length?se({data:e,columns:y(t)}):se({data:e})},[se,z.length]),ie=(e,t)=>{S(r=>r.map((r,n)=>n===e?{...r,name:t}:r)),B(null)},ue=()=>G.filter(e=>e.some(e=>e.trim())).map(e=>e.map(e=>e.includes(",")||e.includes('"')||e.includes("\n")?`"${e.replace(/"/g,'""')}"`:e).join(",")).join("\n"),de=[];G.forEach(e=>e.forEach(e=>{const t=parseFloat(e);!isNaN(t)&&e.trim()&&de.push(t)}));const he=G.reduce((e,t)=>e+t.filter(e=>e.trim()).length,0);/* @__PURE__ */
1
+ import{EditableGrid as e}from"./chunk-HKLW5KTW.js";import"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-GPNNQIRY.js";import{peekSpreadsheetPreviewStage as r,claimSpreadsheetPreviewStage as n,SPREADSHEET_PREVIEW_UPDATE_EVENT as o}from"./chunk-VTVSMRFX.js";import{WindowTitle as a}from"./chunk-TMZVVRTA.js";import"./chunk-DSSLOQDW.js";import"./chunk-6TCHOT4R.js";import"./chunk-OBMR6BEP.js";import"./chunk-2TP4GK53.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-VOY6TCS2.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-3JK2LSFU.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useRef as l,useState as s,useEffect as c,useCallback as i}from"react";import{jsxs as u,jsx as d,Fragment as h}from"react/jsx-runtime";var m="ABCDEFGHIJKLMNOPQRSTUVWXYZ",p=10,x=30;function g(e){return e<26?m[e]:m[Math.floor(e/26)-1]+m[e%26]}function y(e){return Array.from({length:e},(e,t)=>({key:`col_${t}`,title:g(t),width:100}))}function b(e,t){return Array.from({length:e},()=>Array(t).fill(""))}function f(e){return{id:crypto.randomUUID(),name:e,columns:y(p),data:b(x,p),cellStyles:{}}}function v(e){return e.split("\n").map(e=>{if(e.includes("\t"))return e.split("\t").map(e=>e.trim());const t=[];let r="",n=!1;for(const o of e)'"'!==o?","!==o||n?r+=o:(t.push(r.trim()),r=""):n=!n;return t.push(r.trim()),t}).filter(e=>e.some(e=>e.trim()))}function k(e,t){const r=v(e);if(0===r.length)return null;const n=Math.max(p,r.reduce((e,t)=>Math.max(e,t.length),0)),o=r.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));return{id:crypto.randomUUID(),name:t,columns:y(n),data:o,cellStyles:{}}}function w(){const m=l(null),g=l(void 0);void 0===g.current&&(g.current=r());const w=l(g.current?.data??null),N=(()=>{const e=g.current;if(!e)return null;const t=k(e.data.csv,"Sheet 1");if(!t)return null;return{sheet:t,title:e.data.filename.replace(/\.(csv|tsv|txt)$/i,"")}})(),[C,S]=s(N?[N.sheet]:[f("Sheet 1")]),[j,M]=s(0),U=l([]),$=l(C),A=l(!1);c(()=>{A.current?A.current=!1:$.current!==C&&(U.current.push($.current),U.current.length>50&&U.current.shift()),$.current=C},[C]);const E=i(()=>{const e=U.current.pop();e&&(A.current=!0,S(e))},[]);c(()=>{const e=e=>{if(!m.current?.contains(document.activeElement)&&!m.current?.matches(":focus-within"))return;(e.ctrlKey||e.metaKey)&&!e.shiftKey&&("z"===e.key||"Z"===e.key)&&(e.preventDefault(),E())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[E]);const[R,D]=s(N?.title??"Untitled"),[L,F]=s(()=>g.current?.data.onEmail),O=i(e=>{const t=k(e.csv,"Sheet 1");t&&(S([t]),M(0),D(e.filename.replace(/\.(csv|tsv|txt)$/i,"")),F(()=>e.onEmail))},[]);c(()=>{const e=g.current;null!=e&&(n(e),e.data!==w.current&&O(e.data))},[]),c(()=>{const e=g.current?.token;if(null==e)return;const t=t=>{const r=t.detail;r&&r.token===e&&O(r.data)};return window.addEventListener(o,t),()=>window.removeEventListener(o,t)},[]);const[T,K]=s(!1),[H,X]=s(null),[B,I]=s(""),V=l(null),[W,Z]=s("1"),[P,Q]=s("10"),J=C[j]||C[0],Y=J.data,z=J.columns,G=J.cellStyles??{},[_,q]=s(null),[ee,te]=s(null),re=i(()=>{if(ee){const e=Math.min(ee.anchor.row,ee.end.row),t=Math.max(ee.anchor.row,ee.end.row),r=Math.min(ee.anchor.col,ee.end.col),n=Math.max(ee.anchor.col,ee.end.col),o=[];for(let a=e;a<=t;a++)for(let e=r;e<=n;e++)o.push({row:a,col:e});return o}return _?[_]:[]},[ee,_]),ne=i((e,t)=>{const r=re();0!==r.length&&S(n=>n.map((n,o)=>{if(o!==j)return n;const a={...n.cellStyles??{}},l=`${r[0].row}:${r[0].col}`,s=void 0!==t?t:!(a[l]??{})[e];for(const{row:t,col:n}of r){const r=`${t}:${n}`;a[r]={...a[r]??{},[e]:s}}return{...n,cellStyles:a}}))},[re,j]),oe=ee?{row:ee.anchor.row,col:ee.anchor.col}:_,ae=oe?G[`${oe.row}:${oe.col}`]??{}:{},le=!!oe,se=i(e=>{S(t=>t.map((t,r)=>r===j?{...t,...e}:t))},[j]),ce=i(e=>{const t=e.reduce((e,t)=>Math.max(e,t.length),0);t!==z.length?se({data:e,columns:y(t)}):se({data:e})},[se,z.length]),ie=(e,t)=>{S(r=>r.map((r,n)=>n===e?{...r,name:t}:r)),X(null)},ue=()=>Y.filter(e=>e.some(e=>e.trim())).map(e=>e.map(e=>e.includes(",")||e.includes('"')||e.includes("\n")?`"${e.replace(/"/g,'""')}"`:e).join(",")).join("\n"),de=[];Y.forEach(e=>e.forEach(e=>{const t=parseFloat(e);!isNaN(t)&&e.trim()&&de.push(t)}));const he=Y.reduce((e,t)=>e+t.filter(e=>e.trim()).length,0);/* @__PURE__ */
2
2
  return u("div",{ref:m,className:"flex flex-col h-full",children:[
3
- /* @__PURE__ */d(a,{title:`${me=L||"Untitled",me.length>24?`${me.slice(0,23)}…`:me} - Spreadsheets`}),
3
+ /* @__PURE__ */d(a,{title:`${me=R||"Untitled",me.length>24?`${me.slice(0,23)}…`:me} - Spreadsheets`}),
4
4
  /* @__PURE__ */d(t,{app:"spreadsheet"}),
5
- /* @__PURE__ */u("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[R?/* @__PURE__ */d("input",{type:"text",value:L,onChange:e=>D(e.target.value),onBlur:()=>H(!1),onKeyDown:e=>{"Enter"===e.key&&H(!1)},autoFocus:!0,className:"text-sm font-medium text-gray-900 border border-gray-300 rounded px-2 py-0.5 w-40 focus:border-blue-500 focus:ring-blue-500"}):/* @__PURE__ */d("button",{onClick:()=>H(!0),className:"text-sm font-medium text-gray-900 hover:text-blue-600 truncate max-w-[200px]",title:"Click to rename",children:L||"Untitled"}),
5
+ /* @__PURE__ */u("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[T?/* @__PURE__ */d("input",{type:"text",value:R,onChange:e=>D(e.target.value),onBlur:()=>K(!1),onKeyDown:e=>{"Enter"===e.key&&K(!1)},autoFocus:!0,className:"text-sm font-medium text-gray-900 border border-gray-300 rounded px-2 py-0.5 w-40 focus:border-blue-500 focus:ring-blue-500"}):/* @__PURE__ */d("button",{onClick:()=>K(!0),className:"text-sm font-medium text-gray-900 hover:text-blue-600 truncate max-w-[200px]",title:"Click to rename",children:R||"Untitled"}),
6
6
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
7
- /* @__PURE__ */d("input",{ref:W,type:"file",accept:".csv,.tsv,.txt,.xlsx,.xls,.ods",onChange:async e=>{const t=e.target.files?.[0];if(!t)return;const r=t.name.replace(/\.(csv|tsv|txt|xlsx|xls|ods)$/i,"");if(/\.(xlsx|xls|ods)$/i.test(t.name)){const e=new Uint8Array(await t.arrayBuffer()),n=await(import("xlsx")),o=n.read(e,{type:"array"}),a=o.SheetNames.map(e=>{const t=n.utils.sheet_to_json(o.Sheets[e],{header:1,defval:""}),r=Math.max(p,t.reduce((e,t)=>Math.max(e,t.length),0)),a=t.map(e=>{const t=e.map(e=>String(e??""));for(;t.length<r;)t.push("");return t});for(;a.length<x;)a.push(Array(r).fill(""));return{id:crypto.randomUUID(),name:e,columns:y(r),data:a}});S(a),M(0),D(r)}else{const e=v(await t.text());if(0===e.length)return;const n=Math.max(p,e.reduce((e,t)=>Math.max(e,t.length),0)),o=e.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));se({columns:y(n),data:o}),D(r)}W.current&&(W.current.value="")},className:"hidden"}),
8
- /* @__PURE__ */d("button",{onClick:()=>W.current?.click(),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Open"}),
9
- /* @__PURE__ */d("button",{onClick:()=>{const e=new Blob([ue()],{type:"text/csv"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=`${L||"spreadsheet"}.csv`,r.click(),URL.revokeObjectURL(t)},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save CSV"}),F&&/* @__PURE__ */d("button",{onClick:()=>F(ue(),`${L||"spreadsheet"}.csv`),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Email"}),
7
+ /* @__PURE__ */d("input",{ref:V,type:"file",accept:".csv,.tsv,.txt,.xlsx,.xls,.ods",onChange:async e=>{const t=e.target.files?.[0];if(!t)return;const r=t.name.replace(/\.(csv|tsv|txt|xlsx|xls|ods)$/i,"");if(/\.(xlsx|xls|ods)$/i.test(t.name)){const e=new Uint8Array(await t.arrayBuffer()),n=await(import("xlsx")),o=n.read(e,{type:"array"}),a=o.SheetNames.map(e=>{const t=n.utils.sheet_to_json(o.Sheets[e],{header:1,defval:""}),r=Math.max(p,t.reduce((e,t)=>Math.max(e,t.length),0)),a=t.map(e=>{const t=e.map(e=>String(e??""));for(;t.length<r;)t.push("");return t});for(;a.length<x;)a.push(Array(r).fill(""));return{id:crypto.randomUUID(),name:e,columns:y(r),data:a}});S(a),M(0),D(r)}else{const e=v(await t.text());if(0===e.length)return;const n=Math.max(p,e.reduce((e,t)=>Math.max(e,t.length),0)),o=e.map(e=>{for(;e.length<n;)e.push("");return e});for(;o.length<x;)o.push(Array(n).fill(""));se({columns:y(n),data:o}),D(r)}V.current&&(V.current.value="")},className:"hidden"}),
8
+ /* @__PURE__ */d("button",{onClick:()=>V.current?.click(),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Open"}),
9
+ /* @__PURE__ */d("button",{onClick:()=>{const e=new Blob([ue()],{type:"text/csv"}),t=URL.createObjectURL(e),r=document.createElement("a");r.href=t,r.download=`${R||"spreadsheet"}.csv`,r.click(),URL.revokeObjectURL(t)},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save CSV"}),L&&/* @__PURE__ */d("button",{onClick:()=>L(ue(),`${R||"spreadsheet"}.csv`),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Email"}),
10
10
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
11
11
  /* @__PURE__ */u("div",{className:"flex items-center gap-1",children:[
12
- /* @__PURE__ */d("input",{type:"number",min:"1",max:"50",value:Z,onChange:e=>V(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
13
- /* @__PURE__ */d("button",{onClick:()=>(e=>{const t=z.length+e;se({columns:y(t),data:G.map(t=>[...t,...Array(e).fill("")])})})(parseInt(Z)||1),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Col"})]}),
12
+ /* @__PURE__ */d("input",{type:"number",min:"1",max:"50",value:W,onChange:e=>Z(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
13
+ /* @__PURE__ */d("button",{onClick:()=>(e=>{const t=z.length+e;se({columns:y(t),data:Y.map(t=>[...t,...Array(e).fill("")])})})(parseInt(W)||1),className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Col"})]}),
14
14
  /* @__PURE__ */u("div",{className:"flex items-center gap-1",children:[
15
- /* @__PURE__ */d("input",{type:"number",min:"1",max:"500",value:J,onChange:e=>P(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
16
- /* @__PURE__ */d("button",{onClick:()=>{return e=parseInt(J)||10,void se({data:[...G,...Array.from({length:e},()=>Array(z.length).fill(""))]});var e},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Row"})]}),
15
+ /* @__PURE__ */d("input",{type:"number",min:"1",max:"500",value:P,onChange:e=>Q(e.target.value),className:"w-10 text-xs text-center border border-gray-300 rounded px-1 py-0.5 focus:border-blue-500 focus:ring-blue-500"}),
16
+ /* @__PURE__ */d("button",{onClick:()=>{return e=parseInt(P)||10,void se({data:[...Y,...Array.from({length:e},()=>Array(z.length).fill(""))]});var e},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"+ Row"})]}),
17
17
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
18
18
  /* @__PURE__ */d("button",{onClick:()=>{se({columns:y(p),data:b(x,p)})},className:"text-xs text-gray-600 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Clear"}),
19
19
  /* @__PURE__ */d("div",{className:"h-4 w-px bg-gray-300"}),
@@ -26,12 +26,12 @@ return u("div",{ref:m,className:"flex flex-col h-full",children:[
26
26
  /* @__PURE__ */d("option",{value:"base",children:"S"}),
27
27
  /* @__PURE__ */d("option",{value:"lg",children:"M"}),
28
28
  /* @__PURE__ */d("option",{value:"xl",children:"L"})]})]})]}),
29
- /* @__PURE__ */d("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */d(e,{columns:z,data:G,onChange:ce,onColumnsChange:e=>se({columns:e}),cellStyles:Y,onFocusChange:q,onSelectionChange:te,minRows:x,maxHeight:"100%"})}),
29
+ /* @__PURE__ */d("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */d(e,{columns:z,data:Y,onChange:ce,onColumnsChange:e=>se({columns:e}),cellStyles:G,onFocusChange:q,onSelectionChange:te,minRows:x,maxHeight:"100%"})}),
30
30
  /* @__PURE__ */u("div",{className:"flex items-center border-t border-gray-200 bg-gray-50 shrink-0",children:[
31
- /* @__PURE__ */u("div",{className:"flex items-center gap-0.5 px-1 py-1 overflow-x-auto flex-1 min-w-0",children:[C.map((e,t)=>/* @__PURE__ */d("button",{onClick:()=>M(t),onDoubleClick:()=>{B(t),T(e.name)},onContextMenu:e=>{e.preventDefault(),C.length>1&&(e=>{C.length<=1||(S(t=>t.filter((t,r)=>r!==e)),j>=e&&j>0&&M(j-1))})(t)},className:"px-3 py-1 text-xs font-medium rounded-b whitespace-nowrap transition-colors "+(t===j?"bg-white text-blue-700 border border-t-0 border-gray-300 -mt-px relative z-10":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"),children:X===t?/* @__PURE__ */d("input",{type:"text",value:O,onChange:e=>T(e.target.value),onBlur:()=>ie(t,O||e.name),onKeyDown:r=>{"Enter"===r.key&&ie(t,O||e.name),"Escape"===r.key&&B(null)},onClick:e=>e.stopPropagation(),autoFocus:!0,className:"w-20 text-xs border border-blue-400 rounded px-1 py-0 focus:ring-0 focus:outline-none"}):e.name},e.id)),
31
+ /* @__PURE__ */u("div",{className:"flex items-center gap-0.5 px-1 py-1 overflow-x-auto flex-1 min-w-0",children:[C.map((e,t)=>/* @__PURE__ */d("button",{onClick:()=>M(t),onDoubleClick:()=>{X(t),I(e.name)},onContextMenu:e=>{e.preventDefault(),C.length>1&&(e=>{C.length<=1||(S(t=>t.filter((t,r)=>r!==e)),j>=e&&j>0&&M(j-1))})(t)},className:"px-3 py-1 text-xs font-medium rounded-b whitespace-nowrap transition-colors "+(t===j?"bg-white text-blue-700 border border-t-0 border-gray-300 -mt-px relative z-10":"text-gray-500 hover:text-gray-700 hover:bg-gray-100"),children:H===t?/* @__PURE__ */d("input",{type:"text",value:B,onChange:e=>I(e.target.value),onBlur:()=>ie(t,B||e.name),onKeyDown:r=>{"Enter"===r.key&&ie(t,B||e.name),"Escape"===r.key&&X(null)},onClick:e=>e.stopPropagation(),autoFocus:!0,className:"w-20 text-xs border border-blue-400 rounded px-1 py-0 focus:ring-0 focus:outline-none"}):e.name},e.id)),
32
32
  /* @__PURE__ */d("button",{onClick:()=>{const e=`Sheet ${C.length+1}`;S(t=>[...t,f(e)]),M(C.length)},className:"px-2 py-1 text-xs text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded",title:"Add sheet",children:"+"})]}),
33
33
  /* @__PURE__ */u("div",{className:"flex items-center gap-4 px-3 py-1 text-xs text-gray-500 shrink-0 border-l border-gray-200",children:[
34
34
  /* @__PURE__ */u("span",{children:[he," cells"]}),de.length>0&&/* @__PURE__ */u(h,{children:[
35
35
  /* @__PURE__ */u("span",{children:["Sum: ",de.reduce((e,t)=>e+t,0).toLocaleString(void 0,{maximumFractionDigits:2})]}),
36
36
  /* @__PURE__ */u("span",{children:["Avg: ",(de.reduce((e,t)=>e+t,0)/de.length).toLocaleString(void 0,{maximumFractionDigits:2})]})]}),
37
- /* @__PURE__ */u("span",{children:[G.length," × ",z.length]})]})]})]});var me}export{w as default};
37
+ /* @__PURE__ */u("span",{children:[Y.length," × ",z.length]})]})]})]});var me}export{w as default};
@@ -1,4 +1,4 @@
1
- import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-MIAJQGWE.js";import{useWidgetSettings as a}from"./chunk-SBDIHKLU.js";import"./chunk-DSSLOQDW.js";import"./chunk-GMMTTWHB.js";import"./chunk-PQLVWCUI.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-ZZKIKW62.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-J3LIIIHJ.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useState as r,useCallback as n}from"react";import{jsxs as c,Fragment as s,jsx as i}from"react/jsx-runtime";var o=["AAPL","MSFT","GOOGL","TSLA","NVDA"],l="stock_symbols",m="stock_appearance",p={AAPL:{price:229.87,change:1.42,changePct:.62},MSFT:{price:451.16,change:-2.31,changePct:-.51},GOOGL:{price:178.34,change:.89,changePct:.5},AMZN:{price:201.45,change:-1.08,changePct:-.53},TSLA:{price:248.92,change:6.74,changePct:2.78},NVDA:{price:134.81,change:-3.12,changePct:-2.26},META:{price:563.27,change:4.55,changePct:.81}},h=Object.keys(p);function d(){try{const e=JSON.parse(localStorage.getItem(l)||"");if(Array.isArray(e)&&e.length)return e.slice(0,8)}catch{}return o}var g=e=>`${e>=0?"+":""}${e.toFixed(2)}`;function u(){const[o,u]=r(d),[x,y]=r(()=>e(m)),[b,f]=r(!1),[N,k]=r([]),[v,j]=r(x),[A,S]=r(""),O=n(()=>{k([...o]),j({...x}),S(""),f(!0)},[o,x]);a(O);const P=()=>{const e=A.trim().toUpperCase();!e||N.includes(e)||N.length>=8||(k(t=>[...t,e]),S(""))},D=h.filter(e=>!N.includes(e));/* @__PURE__ */
1
+ import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-LY2G6LHW.js";import{useWidgetSettings as a}from"./chunk-TMZVVRTA.js";import"./chunk-DSSLOQDW.js";import"./chunk-6TCHOT4R.js";import"./chunk-2TP4GK53.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-VOY6TCS2.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-3JK2LSFU.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useState as r,useCallback as n}from"react";import{jsxs as c,Fragment as s,jsx as i}from"react/jsx-runtime";var o=["AAPL","MSFT","GOOGL","TSLA","NVDA"],l="stock_symbols",m="stock_appearance",p={AAPL:{price:229.87,change:1.42,changePct:.62},MSFT:{price:451.16,change:-2.31,changePct:-.51},GOOGL:{price:178.34,change:.89,changePct:.5},AMZN:{price:201.45,change:-1.08,changePct:-.53},TSLA:{price:248.92,change:6.74,changePct:2.78},NVDA:{price:134.81,change:-3.12,changePct:-2.26},META:{price:563.27,change:4.55,changePct:.81}},h=Object.keys(p);function d(){try{const e=JSON.parse(localStorage.getItem(l)||"");if(Array.isArray(e)&&e.length)return e.slice(0,8)}catch{}return o}var g=e=>`${e>=0?"+":""}${e.toFixed(2)}`;function u(){const[o,u]=r(d),[x,y]=r(()=>e(m)),[b,f]=r(!1),[N,k]=r([]),[v,j]=r(x),[A,S]=r(""),O=n(()=>{k([...o]),j({...x}),S(""),f(!0)},[o,x]);a(O);const T=()=>{const e=A.trim().toUpperCase();!e||N.includes(e)||N.length>=8||(k(t=>[...t,e]),S(""))},P=h.filter(e=>!N.includes(e));/* @__PURE__ */
2
2
  return c(s,{children:[
3
3
  /* @__PURE__ */i("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${x.activeOpacity/100})`,backdropFilter:x.activeBlur>0?`blur(${x.activeBlur}px)`:void 0},children:/* @__PURE__ */i("div",{className:"px-4 py-3",children:0===o.length?/* @__PURE__ */i("div",{className:"text-xs text-gray-500 text-center py-6",children:"No symbols yet — add some in settings."}):/* @__PURE__ */i("div",{className:"space-y-0.5",children:o.map(e=>{const t=p[e],a=(t?.change??0)>=0,r=t?t.change>0?"text-green-600":t.change<0?"text-red-600":"text-gray-500":"text-gray-400";/* @__PURE__ */
4
4
  return c("div",{className:"flex items-center justify-between px-2 py-2 border-b border-gray-200 last:border-0",children:[
@@ -11,6 +11,6 @@ return c("div",{className:"flex items-center justify-between px-2 py-2 border-b
11
11
  /* @__PURE__ */c("div",{className:"space-y-1 mb-2",children:[N.map((e,t)=>/* @__PURE__ */c("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
12
12
  /* @__PURE__ */i("span",{className:"text-sm font-semibold text-gray-700",children:e}),
13
13
  /* @__PURE__ */i("button",{onClick:()=>k(e=>e.filter((e,a)=>a!==t)),className:"text-red-400 hover:text-red-600",children:"×"})]},t)),0===N.length&&/* @__PURE__ */i("p",{className:"text-[11px] text-gray-400 italic",children:"No symbols — add a ticker below."})]}),N.length<8?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
14
- /* @__PURE__ */i("input",{value:A,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&P()},placeholder:"e.g. NVDA",className:"flex-1 bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm uppercase focus:outline-none focus:ring-1 focus:ring-blue-500"}),
15
- /* @__PURE__ */i("button",{onClick:P,className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */c("p",{className:"text-[11px] text-gray-400 italic",children:["Max ",8," symbols — remove one to add another."]}),D.length>0&&N.length<8&&/* @__PURE__ */i("div",{className:"flex flex-wrap gap-1.5 mt-2",children:D.map(e=>/* @__PURE__ */i("button",{onClick:()=>k(t=>t.length<8?[...t,e]:t),className:"text-[11px] font-medium text-gray-600 bg-gray-100 hover:bg-gray-200 rounded px-2 py-0.5 transition-colors",children:e},e))}),
14
+ /* @__PURE__ */i("input",{value:A,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&T()},placeholder:"e.g. NVDA",className:"flex-1 bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm uppercase focus:outline-none focus:ring-1 focus:ring-blue-500"}),
15
+ /* @__PURE__ */i("button",{onClick:T,className:"text-sm font-medium text-blue-600 hover:text-blue-800 px-2",children:"+ Add"})]}):/* @__PURE__ */c("p",{className:"text-[11px] text-gray-400 italic",children:["Max ",8," symbols — remove one to add another."]}),P.length>0&&N.length<8&&/* @__PURE__ */i("div",{className:"flex flex-wrap gap-1.5 mt-2",children:P.map(e=>/* @__PURE__ */i("button",{onClick:()=>k(t=>t.length<8?[...t,e]:t),className:"text-[11px] font-medium text-gray-600 bg-gray-100 hover:bg-gray-200 rounded px-2 py-0.5 transition-colors",children:e},e))}),
16
16
  /* @__PURE__ */i("p",{className:"text-[11px] text-gray-400 mt-2",children:"Demo prices — static sample data, no live feed."})]})})]})}export{u as default};
@@ -1,4 +1,4 @@
1
- import{fetchCityWeather as e,getCondition as t,AVAILABLE_CITIES as a,toFahrenheit as r}from"./chunk-FBDZGO3V.js";import{loadAppearance as n,WidgetSettingsModal as i}from"./chunk-MIAJQGWE.js";import{useWidgetSettings as s}from"./chunk-SBDIHKLU.js";import"./chunk-DSSLOQDW.js";import"./chunk-GMMTTWHB.js";import{useShellPrefs as o}from"./chunk-PQLVWCUI.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-ZZKIKW62.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-J3LIIIHJ.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useState as l,useEffect as c,useCallback as d}from"react";import{jsx as m,jsxs as p,Fragment as h}from"react/jsx-runtime";var u="weather_city",f="weather_appearance",y={useFahrenheit:!1,showLocalTime:!0,use24Hour:!1};function g(){const e="undefined"!=typeof localStorage?localStorage.getItem(u):null;if(e&&a[e])return e;try{const e=JSON.parse(localStorage.getItem("weather_cities")||"");if(Array.isArray(e)&&e[0]&&a[e[0]])return localStorage.setItem(u,e[0]),e[0]}catch{}return function(){try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;for(const[t,r]of Object.entries(a))if(r.tz===e)return t}catch{}return"London"}()}var x=r;function b(e,t=!1){try{if(t){const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!1}).formatToParts(/* @__PURE__ */new Date),a=parseInt(t.find(e=>"hour"===e.type)?.value||"0"),r=parseInt(t.find(e=>"minute"===e.type)?.value||"0");return`${String(a).padStart(2,"0")}:${String(r).padStart(2,"0")}`}const a=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(/* @__PURE__ */new Date),r=parseInt(a.find(e=>"hour"===e.type)?.value||"12"),n=parseInt(a.find(e=>"minute"===e.type)?.value||"0"),i=a.find(e=>"dayPeriod"===e.type)?.value||"";return`${r}:${String(n).padStart(2,"0")} ${i}`}catch{return""}}function w(){/* @__PURE__ */
1
+ import{fetchCityWeather as e,getCondition as t,AVAILABLE_CITIES as a,toFahrenheit as r}from"./chunk-FBDZGO3V.js";import{loadAppearance as n,WidgetSettingsModal as i}from"./chunk-LY2G6LHW.js";import{useWidgetSettings as s}from"./chunk-TMZVVRTA.js";import"./chunk-DSSLOQDW.js";import"./chunk-6TCHOT4R.js";import{useShellPrefs as o}from"./chunk-2TP4GK53.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-VOY6TCS2.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-3JK2LSFU.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useState as l,useEffect as c,useCallback as d}from"react";import{jsx as m,jsxs as p,Fragment as h}from"react/jsx-runtime";var u="weather_city",f="weather_appearance",y={useFahrenheit:!1,showLocalTime:!0,use24Hour:!1};function g(){const e="undefined"!=typeof localStorage?localStorage.getItem(u):null;if(e&&a[e])return e;try{const e=JSON.parse(localStorage.getItem("weather_cities")||"");if(Array.isArray(e)&&e[0]&&a[e[0]])return localStorage.setItem(u,e[0]),e[0]}catch{}return function(){try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;for(const[t,r]of Object.entries(a))if(r.tz===e)return t}catch{}return"London"}()}var x=r;function b(e,t=!1){try{if(t){const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!1}).formatToParts(/* @__PURE__ */new Date),a=parseInt(t.find(e=>"hour"===e.type)?.value||"0"),r=parseInt(t.find(e=>"minute"===e.type)?.value||"0");return`${String(a).padStart(2,"0")}:${String(r).padStart(2,"0")}`}const a=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(/* @__PURE__ */new Date),r=parseInt(a.find(e=>"hour"===e.type)?.value||"12"),n=parseInt(a.find(e=>"minute"===e.type)?.value||"0"),i=a.find(e=>"dayPeriod"===e.type)?.value||"";return`${r}:${String(n).padStart(2,"0")} ${i}`}catch{return""}}function w(){/* @__PURE__ */
2
2
  return p("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[
3
3
  /* @__PURE__ */m("div",{className:"absolute -top-5 -right-5 w-24 h-24",style:{animation:"wx-sun-rays 70s linear infinite"},children:/* @__PURE__ */m("svg",{viewBox:"0 0 100 100",className:"w-full h-full",children:Array.from({length:12}).map((e,t)=>/* @__PURE__ */m("rect",{x:49,y:3,width:2,height:14,rx:1,fill:"rgba(255, 232, 130, 0.55)",transform:`rotate(${30*t} 50 50)`},t))})}),
4
4
  /* @__PURE__ */m("div",{className:"absolute top-1 right-1 w-10 h-10 rounded-full",style:{background:"radial-gradient(circle at 35% 35%, #fff8cc 0%, #ffd84a 55%, #ff9e2a 100%)",boxShadow:"0 0 18px 5px rgba(255, 200, 80, 0.55)",animation:"wx-sun-pulse 4.5s ease-in-out infinite"}})]})}function v(){const e=Array.from({length:16}).map((e,t)=>({left:(53*t+11)%95+"%",top:(37*t+9)%78+"%",size:1+13*t%3,delay:.41*t%4+"s",duration:2.5+7*t%5*.6+"s"}));/* @__PURE__ */
@@ -18,43 +18,43 @@ return p("div",{className:"absolute inset-0 overflow-hidden pointer-events-none"
18
18
  /* @__PURE__ */m("div",{className:"absolute",style:{top:"8%",animation:"wx-drift-cloud 42s linear infinite"},children:/* @__PURE__ */m(a,{scale:.9})}),
19
19
  /* @__PURE__ */m("div",{className:"absolute",style:{top:"40%",animation:"wx-drift-cloud 60s linear -22s infinite",opacity:.85},children:/* @__PURE__ */m(a,{scale:1.25})}),
20
20
  /* @__PURE__ */m("div",{className:"absolute",style:{top:"68%",animation:"wx-drift-cloud 78s linear -45s infinite",opacity:.7},children:/* @__PURE__ */m(a,{scale:.75})})]})}function N({heavy:e=!1}){const t=e?26:16,a=["wx-rain-a","wx-rain-b","wx-rain-c"],r=Array.from({length:t}).map((e,r)=>({left:(100*r/t+11*r%7)%100+"%",delay:.087*r%1.3+"s",height:12+r%4*5+"px",duration:.7+r%3*.18+"s",variant:a[r%a.length]}));/* @__PURE__ */
21
- return m("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:r.map((e,t)=>/* @__PURE__ */m("div",{className:"absolute",style:{left:e.left,top:"-20px",width:"1px",height:e.height,background:"linear-gradient(180deg, rgba(180,210,255,0) 0%, rgba(220,235,255,0.85) 90%, rgba(255,255,255,0.95) 100%)",transform:"rotate(8deg)",animation:`${e.variant} ${e.duration} linear ${e.delay} infinite`,transformOrigin:"top"}},t))})}function j(){const e=["wx-snow-a","wx-snow-b","wx-snow-c"],t=Array.from({length:16}).map((t,a)=>({left:(100*a/16+13*a%5)%100+"%",delay:.43*a%5+"s",duration:4.5+a%5+"s",size:3+a%4*1.4,opacity:.65+7*a%4*.08,variant:e[a%e.length]}));/* @__PURE__ */
22
- return m("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:t.map((e,t)=>/* @__PURE__ */m("div",{className:"absolute rounded-full bg-white",style:{left:e.left,top:"-12px",width:e.size,height:e.size,opacity:e.opacity,boxShadow:"0 0 4px rgba(255,255,255,0.65)",animation:`${e.variant} ${e.duration} linear ${e.delay} infinite`}},t))})}function S(){/* @__PURE__ */
21
+ return m("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:r.map((e,t)=>/* @__PURE__ */m("div",{className:"absolute",style:{left:e.left,top:"-20px",width:"1px",height:e.height,background:"linear-gradient(180deg, rgba(180,210,255,0) 0%, rgba(220,235,255,0.85) 90%, rgba(255,255,255,0.95) 100%)",transform:"rotate(8deg)",animation:`${e.variant} ${e.duration} linear ${e.delay} infinite`,transformOrigin:"top"}},t))})}function S(){const e=["wx-snow-a","wx-snow-b","wx-snow-c"],t=Array.from({length:16}).map((t,a)=>({left:(100*a/16+13*a%5)%100+"%",delay:.43*a%5+"s",duration:4.5+a%5+"s",size:3+a%4*1.4,opacity:.65+7*a%4*.08,variant:e[a%e.length]}));/* @__PURE__ */
22
+ return m("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:t.map((e,t)=>/* @__PURE__ */m("div",{className:"absolute rounded-full bg-white",style:{left:e.left,top:"-12px",width:e.size,height:e.size,opacity:e.opacity,boxShadow:"0 0 4px rgba(255,255,255,0.65)",animation:`${e.variant} ${e.duration} linear ${e.delay} infinite`}},t))})}function j(){/* @__PURE__ */
23
23
  return p("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[
24
24
  /* @__PURE__ */m(N,{heavy:!0}),
25
25
  /* @__PURE__ */m("div",{className:"absolute inset-0 bg-white",style:{animation:"wx-flash 6s ease-out infinite"}}),
26
- /* @__PURE__ */m("div",{className:"absolute inset-y-0 right-1/3 flex items-center justify-center pointer-events-none",style:{animation:"wx-bolt 6s ease-out infinite"},children:/* @__PURE__ */m("svg",{viewBox:"0 0 18 60",className:"h-4/5",style:{filter:"drop-shadow(0 0 6px rgba(255, 240, 150, 0.95)) drop-shadow(0 0 14px rgba(255, 220, 90, 0.7))"},children:/* @__PURE__ */m("path",{d:"M11 0 L2 28 L8 30 L4 60 L16 24 L9 22 Z",fill:"rgba(255, 250, 200, 0.98)",stroke:"rgba(255, 255, 255, 0.9)",strokeWidth:.3})})})]})}function I(){/* @__PURE__ */
27
- return m("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:Array.from({length:4}).map((e,t)=>/* @__PURE__ */m("div",{className:"absolute left-0 right-0",style:{top:10+22*t+"%",height:"14px",background:"linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 100%)",filter:"blur(2px)",animation:`wx-fog-drift ${10+3*t}s ease-in-out ${.7*t}s infinite alternate`}},t))})}function $({code:e,isDay:t}){return 0===e||1===e?/* @__PURE__ */m(t?w:v,{}):2===e?/* @__PURE__ */p(h,{children:[/* @__PURE__ */m(t?w:v,{}),
28
- /* @__PURE__ */m(k,{tone:t?"light":"dark"})]}):3===e?/* @__PURE__ */m(k,{tone:t?"light":"dark"}):45===e||48===e?/* @__PURE__ */m(I,{}):[51,53,61,80,81].includes(e)?/* @__PURE__ */m(N,{}):[55,63,65,82].includes(e)?/* @__PURE__ */m(N,{heavy:!0}):[71,73,75].includes(e)?/* @__PURE__ */m(j,{}):[95,96,99].includes(e)?/* @__PURE__ */m(S,{}):null}function F(){const[r,w]=l(g),[v,k]=l(()=>n(f)),[N,j]=l(null),[S,I]=l(!0),[,F]=l(0);c(()=>{const e=setInterval(()=>F(e=>e+1),6e4);return()=>clearInterval(e)},[]);const[H,D]=l(!1),[L,T]=l(r),[A,C]=l(v),{prefs:O,save:Z}=o(),W={...y,...O.weather_prefs??{}},[z,X]=l(W);s(d(()=>{T(r),C({...v}),X({...W}),D(!0)},[r,v,W])),c(()=>{let t=!1;return I(!0),e(r).then(e=>{t||(j(e),I(!1))}),()=>{t=!0}},[r]);const B=e=>W.useFahrenheit?`${x(e)}°F`:`${e}°`;if(S&&!N)/* @__PURE__ */
26
+ /* @__PURE__ */m("div",{className:"absolute inset-y-0 right-1/3 flex items-center justify-center pointer-events-none",style:{animation:"wx-bolt 6s ease-out infinite"},children:/* @__PURE__ */m("svg",{viewBox:"0 0 18 60",className:"h-4/5",style:{filter:"drop-shadow(0 0 6px rgba(255, 240, 150, 0.95)) drop-shadow(0 0 14px rgba(255, 220, 90, 0.7))"},children:/* @__PURE__ */m("path",{d:"M11 0 L2 28 L8 30 L4 60 L16 24 L9 22 Z",fill:"rgba(255, 250, 200, 0.98)",stroke:"rgba(255, 255, 255, 0.9)",strokeWidth:.3})})})]})}function $(){/* @__PURE__ */
27
+ return m("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:Array.from({length:4}).map((e,t)=>/* @__PURE__ */m("div",{className:"absolute left-0 right-0",style:{top:10+22*t+"%",height:"14px",background:"linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 100%)",filter:"blur(2px)",animation:`wx-fog-drift ${10+3*t}s ease-in-out ${.7*t}s infinite alternate`}},t))})}function T({code:e,isDay:t}){return 0===e||1===e?/* @__PURE__ */m(t?w:v,{}):2===e?/* @__PURE__ */p(h,{children:[/* @__PURE__ */m(t?w:v,{}),
28
+ /* @__PURE__ */m(k,{tone:t?"light":"dark"})]}):3===e?/* @__PURE__ */m(k,{tone:t?"light":"dark"}):45===e||48===e?/* @__PURE__ */m($,{}):[51,53,61,80,81].includes(e)?/* @__PURE__ */m(N,{}):[55,63,65,82].includes(e)?/* @__PURE__ */m(N,{heavy:!0}):[71,73,75].includes(e)?/* @__PURE__ */m(S,{}):[95,96,99].includes(e)?/* @__PURE__ */m(j,{}):null}function F(){const[r,w]=l(g),[v,k]=l(()=>n(f)),[N,S]=l(null),[j,$]=l(!0),[,F]=l(0);c(()=>{const e=setInterval(()=>F(e=>e+1),6e4);return()=>clearInterval(e)},[]);const[H,L]=l(!1),[C,D]=l(r),[I,O]=l(v),{prefs:A,save:Z}=o(),z={...y,...A.weather_prefs??{}},[X,W]=l(z);s(d(()=>{D(r),O({...v}),W({...z}),L(!0)},[r,v,z])),c(()=>{let t=!1;return $(!0),e(r).then(e=>{t||(S(e),$(!1))}),()=>{t=!0}},[r]);const B=e=>z.useFahrenheit?`${x(e)}°F`:`${e}°`;if(j&&!N)/* @__PURE__ */
29
29
  return m("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-sky-400 to-blue-500 rounded-lg text-white/80 text-xs",style:{minHeight:110},children:"Loading…"});if(!N)/* @__PURE__ */
30
- return m("div",{className:"flex items-center justify-center h-full bg-slate-700 rounded-lg text-white/80 text-xs",style:{minHeight:110},children:"Couldn't load weather"});const[J,M,P]=t(N.code,N.isDay);/* @__PURE__ */
30
+ return m("div",{className:"flex items-center justify-center h-full bg-slate-700 rounded-lg text-white/80 text-xs",style:{minHeight:110},children:"Couldn't load weather"});const[P,J,M]=t(N.code,N.isDay);/* @__PURE__ */
31
31
  return p(h,{children:[
32
32
  /* @__PURE__ */m("style",{children:"\n@keyframes wx-rain-a { 0% { transform: translate(0,-20px); opacity: 0; } 10% { opacity: 0.95; } 100% { transform: translate(8px,140px); opacity: 0; } }\n@keyframes wx-rain-b { 0% { transform: translate(0,-20px); opacity: 0; } 12% { opacity: 0.85; } 100% { transform: translate(12px,140px); opacity: 0; } }\n@keyframes wx-rain-c { 0% { transform: translate(0,-20px); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(5px,140px); opacity: 0; } }\n@keyframes wx-snow-a { 0% { transform: translate(0,-12px) rotate(0deg); opacity: 0; } 10% { opacity: 0.9; } 50% { transform: translate(10px,55px) rotate(180deg); } 100% { transform: translate(-4px,140px) rotate(360deg); opacity: 0; } }\n@keyframes wx-snow-b { 0% { transform: translate(0,-12px) rotate(0deg); opacity: 0; } 10% { opacity: 0.85; } 50% { transform: translate(-12px,55px) rotate(-180deg); } 100% { transform: translate(6px,140px) rotate(-360deg); opacity: 0; } }\n@keyframes wx-snow-c { 0% { transform: translate(0,-12px); opacity: 0; } 10% { opacity: 0.7; } 100% { transform: translate(2px,140px); opacity: 0; } }\n@keyframes wx-drift-cloud { 0% { transform: translateX(-40%); } 100% { transform: translateX(140%); } }\n@keyframes wx-twinkle { 0%, 100% { opacity: 0.25; transform: scale(1); } 50% { opacity: 1; transform: scale(1.6); } }\n@keyframes wx-flash { 0%, 86%, 100% { opacity: 0; } 87% { opacity: 0.95; } 88% { opacity: 0.15; } 89% { opacity: 0.85; } 90% { opacity: 0; } }\n@keyframes wx-bolt { 0%, 86%, 90%, 100% { opacity: 0; } 87% { opacity: 1; } 89% { opacity: 0.85; } }\n@keyframes wx-sun-pulse { 0%, 100% { transform: scale(1); opacity: 0.65; } 50% { transform: scale(1.12); opacity: 0.95; } }\n@keyframes wx-sun-rays { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }\n@keyframes wx-fog-drift { 0% { transform: translateX(-25%); opacity: 0.3; } 50% { opacity: 0.65; } 100% { transform: translateX(25%); opacity: 0.3; } }\n@keyframes wx-shooting-star { 0%, 95% { opacity: 0; transform: translate(0,0) scale(0); } 96% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(40px,30px) scale(1); } }\n"}),
33
- /* @__PURE__ */m("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:`rgba(15, 23, 42, ${v.activeOpacity/100})`,backdropFilter:v.activeBlur>0?`blur(${v.activeBlur}px)`:void 0},children:/* @__PURE__ */p("div",{className:`relative rounded-lg overflow-hidden text-white bg-gradient-to-br ${P}`,style:{height:110},children:[
34
- /* @__PURE__ */m($,{code:N.code,isDay:N.isDay}),
33
+ /* @__PURE__ */m("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:`rgba(15, 23, 42, ${v.activeOpacity/100})`,backdropFilter:v.activeBlur>0?`blur(${v.activeBlur}px)`:void 0},children:/* @__PURE__ */p("div",{className:`relative rounded-lg overflow-hidden text-white bg-gradient-to-br ${M}`,style:{height:110},children:[
34
+ /* @__PURE__ */m(T,{code:N.code,isDay:N.isDay}),
35
35
  /* @__PURE__ */p("div",{className:"relative z-10 px-3 py-2.5 flex flex-col h-full justify-between",children:[
36
36
  /* @__PURE__ */p("div",{className:"flex items-start justify-between gap-2",children:[
37
37
  /* @__PURE__ */p("div",{className:"min-w-0 flex-1",children:[
38
- /* @__PURE__ */m("div",{className:"text-base font-semibold leading-tight truncate drop-shadow-sm",children:N.city}),W.showLocalTime&&/* @__PURE__ */m("div",{className:"text-[10px] opacity-90 leading-tight tabular-nums drop-shadow-sm",children:b(N.timezone,W.use24Hour)})]}),
38
+ /* @__PURE__ */m("div",{className:"text-base font-semibold leading-tight truncate drop-shadow-sm",children:N.city}),z.showLocalTime&&/* @__PURE__ */m("div",{className:"text-[10px] opacity-90 leading-tight tabular-nums drop-shadow-sm",children:b(N.timezone,z.use24Hour)})]}),
39
39
  /* @__PURE__ */m("div",{className:"text-3xl font-extralight leading-none tracking-tight tabular-nums shrink-0 drop-shadow-sm",children:B(N.temp)})]}),
40
40
  /* @__PURE__ */p("div",{className:"flex items-end justify-between gap-2",children:[
41
41
  /* @__PURE__ */p("div",{className:"flex items-center gap-1.5 min-w-0",children:[
42
- /* @__PURE__ */m("span",{className:"text-lg leading-none drop-shadow-sm",children:M}),
43
- /* @__PURE__ */m("span",{className:"text-[11px] font-medium drop-shadow-sm truncate",children:J})]}),
42
+ /* @__PURE__ */m("span",{className:"text-lg leading-none drop-shadow-sm",children:J}),
43
+ /* @__PURE__ */m("span",{className:"text-[11px] font-medium drop-shadow-sm truncate",children:P})]}),
44
44
  /* @__PURE__ */p("span",{className:"text-[10px] opacity-90 tabular-nums drop-shadow-sm shrink-0",children:["H:",B(N.high)," L:",B(N.low)]})]})]})]})}),
45
- /* @__PURE__ */p(i,{open:H,onClose:()=>D(!1),title:"Weather Settings",appearance:A,onAppearanceChange:C,onSave:()=>{w(L),k(A),Z({weather_prefs:z}),localStorage.setItem(u,L),localStorage.setItem(f,JSON.stringify(A)),D(!1)},children:[
45
+ /* @__PURE__ */p(i,{open:H,onClose:()=>L(!1),title:"Weather Settings",appearance:I,onAppearanceChange:O,onSave:()=>{w(C),k(I),Z({weather_prefs:X}),localStorage.setItem(u,C),localStorage.setItem(f,JSON.stringify(I)),L(!1)},children:[
46
46
  /* @__PURE__ */m("div",{className:"space-y-3",children:/* @__PURE__ */p("div",{children:[
47
47
  /* @__PURE__ */m("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Display"}),
48
48
  /* @__PURE__ */p("div",{className:"flex items-center gap-3 mb-2",children:[
49
49
  /* @__PURE__ */m("span",{className:"text-sm text-gray-600 w-24",children:"Temperature"}),
50
- /* @__PURE__ */m("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */m("button",{onClick:()=>X(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(z.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
50
+ /* @__PURE__ */m("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */m("button",{onClick:()=>W(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(X.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
51
51
  /* @__PURE__ */p("div",{className:"flex items-center gap-3 mb-2",children:[
52
52
  /* @__PURE__ */m("span",{className:"text-sm text-gray-600 w-24",children:"Time Format"}),
53
- /* @__PURE__ */m("div",{className:"flex gap-1",children:[{key:!1,label:"AM/PM"},{key:!0,label:"24H"}].map(e=>/* @__PURE__ */m("button",{onClick:()=>X(t=>({...t,use24Hour:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(z.use24Hour===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
53
+ /* @__PURE__ */m("div",{className:"flex gap-1",children:[{key:!1,label:"AM/PM"},{key:!0,label:"24H"}].map(e=>/* @__PURE__ */m("button",{onClick:()=>W(t=>({...t,use24Hour:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(X.use24Hour===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
54
54
  /* @__PURE__ */p("label",{className:"flex items-center gap-2 cursor-pointer",children:[
55
- /* @__PURE__ */m("input",{type:"checkbox",checked:z.showLocalTime,onChange:e=>X(t=>({...t,showLocalTime:e.target.checked})),className:"rounded border-gray-300 text-blue-600 h-3.5 w-3.5"}),
55
+ /* @__PURE__ */m("input",{type:"checkbox",checked:X.showLocalTime,onChange:e=>W(t=>({...t,showLocalTime:e.target.checked})),className:"rounded border-gray-300 text-blue-600 h-3.5 w-3.5"}),
56
56
  /* @__PURE__ */m("span",{className:"text-sm text-gray-600",children:"Show local time"})]})]})}),
57
57
  /* @__PURE__ */p("div",{children:[
58
58
  /* @__PURE__ */m("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"City"}),
59
- /* @__PURE__ */m("select",{value:L,onChange:e=>T(e.target.value),className:"w-full bg-gray-50 border border-gray-200 rounded px-2 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:Object.keys(a).map(e=>/* @__PURE__ */m("option",{value:e,children:e},e))}),
59
+ /* @__PURE__ */m("select",{value:C,onChange:e=>D(e.target.value),className:"w-full bg-gray-50 border border-gray-200 rounded px-2 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:Object.keys(a).map(e=>/* @__PURE__ */m("option",{value:e,children:e},e))}),
60
60
  /* @__PURE__ */m("p",{className:"mt-1 text-[10px] text-gray-400",children:"Auto-detected from your timezone; change if needed."})]})]})]})}export{F as default};
@@ -1,6 +1,6 @@
1
- import{AVAILABLE_CITIES as e,fetchCityWeather as t,getCondition as r,toFahrenheit as a}from"./chunk-FBDZGO3V.js";import{loadAppearance as n,WidgetSettingsModal as i}from"./chunk-MIAJQGWE.js";import{useWidgetSettings as s}from"./chunk-SBDIHKLU.js";import"./chunk-DSSLOQDW.js";import"./chunk-GMMTTWHB.js";import{useShellPrefs as c}from"./chunk-PQLVWCUI.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-ZZKIKW62.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-J3LIIIHJ.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useState as l,useEffect as o,useCallback as m}from"react";import{jsxs as h,Fragment as d,jsx as p}from"react/jsx-runtime";var u="world_clock_appearance",g=["London","Shanghai","New York"];function x(){const{prefs:x,save:y}=c(),[b,f]=l(()=>n(u)),[k,v]=l(!1),[N,j]=l([]),[w,F]=l(b),C={useFahrenheit:!!x.weather_prefs?.useFahrenheit},[I,D]=l(C),[O,S]=l(()=>/* @__PURE__ */new Date);o(()=>{const e=setInterval(()=>S(/* @__PURE__ */new Date),3e4);return()=>clearInterval(e)},[]);const W=Object.fromEntries(Object.entries(e).map(([e,t])=>[t.tz,e])),H=x.world_clocks,T=(()=>{if(!Array.isArray(H)||0===H.length)return g;const t=[];for(const r of H){const a=e[r]?r:W[r];a&&!t.includes(a)&&t.push(a)}return t.length?t:g})(),[Z,L]=l({}),[U,A]=l(!0);o(()=>{let e=!1;return A(!0),(async()=>{const r={};await Promise.all(T.map(async e=>{const a=await t(e);a&&(r[e]=a)})),e||(L(r),A(!1))})(),()=>{e=!0}},[T.join(",")]),s(m(()=>{j([...T]),F({...b}),D({...C}),v(!0)},[T.join(","),b,C.useFahrenheit]));const J=e=>C.useFahrenheit?`${a(e)}°`:`${e}°`;/* @__PURE__ */
1
+ import{AVAILABLE_CITIES as e,fetchCityWeather as t,getCondition as r,toFahrenheit as a}from"./chunk-FBDZGO3V.js";import{loadAppearance as n,WidgetSettingsModal as i}from"./chunk-LY2G6LHW.js";import{useWidgetSettings as s}from"./chunk-TMZVVRTA.js";import"./chunk-DSSLOQDW.js";import"./chunk-6TCHOT4R.js";import{useShellPrefs as c}from"./chunk-2TP4GK53.js";import"./chunk-5A7MWTXX.js";import"./chunk-OGXU7QFW.js";import"./chunk-VOY6TCS2.js";import"./chunk-ZDF5AR5W.js";import"./chunk-AFYQTVZO.js";import"./chunk-HZZNJHRH.js";import"./chunk-X4FJ54PP.js";import"./chunk-D65T4H6J.js";import"./chunk-XUF7VW4U.js";import"./chunk-3JK2LSFU.js";import"./chunk-C3QOHMR6.js";import"./chunk-YKZHOXI4.js";import{useState as l,useEffect as o,useCallback as m}from"react";import{jsxs as h,Fragment as d,jsx as p}from"react/jsx-runtime";var u="world_clock_appearance",g=["London","Shanghai","New York"];function x(){const{prefs:x,save:y}=c(),[b,f]=l(()=>n(u)),[k,v]=l(!1),[N,j]=l([]),[w,F]=l(b),C={useFahrenheit:!!x.weather_prefs?.useFahrenheit},[O,T]=l(C),[S,D]=l(()=>/* @__PURE__ */new Date);o(()=>{const e=setInterval(()=>D(/* @__PURE__ */new Date),3e4);return()=>clearInterval(e)},[]);const H=Object.fromEntries(Object.entries(e).map(([e,t])=>[t.tz,e])),L=x.world_clocks,W=(()=>{if(!Array.isArray(L)||0===L.length)return g;const t=[];for(const r of L){const a=e[r]?r:H[r];a&&!t.includes(a)&&t.push(a)}return t.length?t:g})(),[Z,A]=l({}),[U,_]=l(!0);o(()=>{let e=!1;return _(!0),(async()=>{const r={};await Promise.all(W.map(async e=>{const a=await t(e);a&&(r[e]=a)})),e||(A(r),_(!1))})(),()=>{e=!0}},[W.join(",")]),s(m(()=>{j([...W]),F({...b}),T({...C}),v(!0)},[W.join(","),b,C.useFahrenheit]));const P=e=>C.useFahrenheit?`${a(e)}°`:`${e}°`;/* @__PURE__ */
2
2
  return h(d,{children:[
3
- /* @__PURE__ */p("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${b.activeOpacity/100})`,backdropFilter:b.activeBlur>0?`blur(${b.activeBlur}px)`:void 0},children:/* @__PURE__ */h("div",{className:"divide-y divide-gray-200",children:[U&&T.every(e=>!Z[e])&&/* @__PURE__ */p("div",{className:"px-3 py-6 text-center text-xs text-gray-500",children:"Loading…"}),T.map(t=>{const a=Z[t],n=e[t]?.tz??"UTC",{time:i,ampm:s}=function(e,t){try{const r=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(t),a=r.find(e=>"hour"===e.type)?.value||"12";return{time:`${a}:${r.find(e=>"minute"===e.type)?.value||"00"}`,ampm:(r.find(e=>"dayPeriod"===e.type)?.value||"").toUpperCase()}}catch{return{time:"",ampm:""}}}(n,O);if(!a)/* @__PURE__ */
3
+ /* @__PURE__ */p("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${b.activeOpacity/100})`,backdropFilter:b.activeBlur>0?`blur(${b.activeBlur}px)`:void 0},children:/* @__PURE__ */h("div",{className:"divide-y divide-gray-200",children:[U&&W.every(e=>!Z[e])&&/* @__PURE__ */p("div",{className:"px-3 py-6 text-center text-xs text-gray-500",children:"Loading…"}),W.map(t=>{const a=Z[t],n=e[t]?.tz??"UTC",{time:i,ampm:s}=function(e,t){try{const r=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(t),a=r.find(e=>"hour"===e.type)?.value||"12";return{time:`${a}:${r.find(e=>"minute"===e.type)?.value||"00"}`,ampm:(r.find(e=>"dayPeriod"===e.type)?.value||"").toUpperCase()}}catch{return{time:"",ampm:""}}}(n,S);if(!a)/* @__PURE__ */
4
4
  return h("div",{className:"px-4 py-3",children:[
5
5
  /* @__PURE__ */h("div",{className:"flex items-baseline justify-between gap-2",children:[
6
6
  /* @__PURE__ */p("span",{className:"text-[15px] font-semibold tracking-tight text-gray-900 truncate",children:t}),
@@ -10,7 +10,7 @@ return h("div",{className:"px-4 py-3",children:[
10
10
  return h("div",{className:"px-4 py-3",children:[
11
11
  /* @__PURE__ */h("div",{className:"flex items-baseline justify-between gap-2",children:[
12
12
  /* @__PURE__ */p("span",{className:"text-[15px] font-semibold tracking-tight text-gray-900 truncate",children:t}),
13
- /* @__PURE__ */p("span",{className:"text-[26px] font-extralight leading-none tabular-nums tracking-tight text-gray-900 shrink-0",children:J(a.temp)})]}),
13
+ /* @__PURE__ */p("span",{className:"text-[26px] font-extralight leading-none tabular-nums tracking-tight text-gray-900 shrink-0",children:P(a.temp)})]}),
14
14
  /* @__PURE__ */h("div",{className:"flex items-center justify-between gap-2 mt-1.5 text-[11px]",children:[
15
15
  /* @__PURE__ */h("div",{className:"flex items-center gap-1.5 min-w-0 text-gray-500",children:[
16
16
  /* @__PURE__ */p("span",{className:"text-base leading-none shrink-0",children:l}),
@@ -18,13 +18,13 @@ return h("div",{className:"px-4 py-3",children:[
18
18
  /* @__PURE__ */p("span",{className:"text-[9px] font-medium ml-0.5 opacity-70",children:s})]}),
19
19
  /* @__PURE__ */p("span",{className:"text-gray-300 shrink-0",children:"·"}),
20
20
  /* @__PURE__ */p("span",{className:"truncate",children:c})]}),
21
- /* @__PURE__ */h("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",J(a.high)," L:",J(a.low)]})]})]},t)})]})}),
22
- /* @__PURE__ */h(i,{open:k,onClose:()=>v(!1),title:"World Clock Settings",appearance:w,onAppearanceChange:F,onSave:()=>{0!==N.length&&(y({world_clocks:N,weather_prefs:{...x.weather_prefs??{},useFahrenheit:I.useFahrenheit}}),f(w),localStorage.setItem(u,JSON.stringify(w)),v(!1))},children:[
21
+ /* @__PURE__ */h("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",P(a.high)," L:",P(a.low)]})]})]},t)})]})}),
22
+ /* @__PURE__ */h(i,{open:k,onClose:()=>v(!1),title:"World Clock Settings",appearance:w,onAppearanceChange:F,onSave:()=>{0!==N.length&&(y({world_clocks:N,weather_prefs:{...x.weather_prefs??{},useFahrenheit:O.useFahrenheit}}),f(w),localStorage.setItem(u,JSON.stringify(w)),v(!1))},children:[
23
23
  /* @__PURE__ */h("div",{children:[
24
24
  /* @__PURE__ */p("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Display"}),
25
25
  /* @__PURE__ */h("div",{className:"flex items-center gap-3 mb-2",children:[
26
26
  /* @__PURE__ */p("span",{className:"text-sm text-gray-600 w-24",children:"Temperature"}),
27
- /* @__PURE__ */p("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */p("button",{onClick:()=>D(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(I.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
27
+ /* @__PURE__ */p("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */p("button",{onClick:()=>T(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(O.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
28
28
  /* @__PURE__ */p("p",{className:"text-[10px] text-gray-400 mt-1",children:"Shared with the Weather widget."})]}),
29
29
  /* @__PURE__ */h("div",{children:[
30
30
  /* @__PURE__ */p("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Cities"}),
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{openFilesInTrashMode,setFilesDemoTree}from"../chunk-P4SGJTK3.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-TKUNR5KP.js";import"../chunk-LMIQV3NB.js";import{setPdfPreview as e}from"../chunk-ESL5TDNA.js";export{setPdfPreview}from"../chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"../chunk-VTVSMRFX.js";export{setSpreadsheetPreview}from"../chunk-VTVSMRFX.js";import"../chunk-SBDIHKLU.js";import"../chunk-DSSLOQDW.js";import"../chunk-GMMTTWHB.js";import"../chunk-YKHMAGEM.js";import{toast_default as o}from"../chunk-3DGTIWZP.js";import"../chunk-PQLVWCUI.js";import"../chunk-5A7MWTXX.js";import"../chunk-OGXU7QFW.js";import"../chunk-ZZKIKW62.js";import"../chunk-ZDF5AR5W.js";import"../chunk-AFYQTVZO.js";import"../chunk-HZZNJHRH.js";import"../chunk-X4FJ54PP.js";import"../chunk-D65T4H6J.js";import"../chunk-XUF7VW4U.js";import{currentShellStrings as r}from"../chunk-J3LIIIHJ.js";import"../chunk-C3QOHMR6.js";import"../chunk-YKZHOXI4.js";import{lazy as n}from"react";function i(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),l=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),a=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function m(e){const t=i(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":l.has(t)?"image":a.has(t)?"3d":null}function p(e){window.open(e,"_blank","noopener,noreferrer")}async function u(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const r=await fetch(e);if(!r.ok)throw new Error(`fetch failed: ${r.status}`);return r.text()}function d(e,t){return(e instanceof Error?e.message:"")||t}async function h(n,s,l={}){const a=r().attachment,h=n?.url||"",f=n?.filename||a.fallbackName;if(!h&&!l.fetchBlob)return void o.error(a.noLink);const j=m(f)??m(h);if("csv"===j){try{t({csv:await u(h,l,n),filename:f}),s("/spreadsheet")}catch{o.error(a.spreadsheetFailed),h&&p(h)}return}if(c.has(i(f)||i(h)))return o.error(a.workbookUnavailable),void(h&&p(h));if(!j)return h?(o.info(a.noViewer),void p(h)):void o.error(a.noLink);if(!l.fetchBlob)return e({url:h,filename:f,kind:j}),void s("/preview");const k=e({filename:f,kind:j,converting:!0,convertingMessage:l.loadingMessage||a.loading});s("/preview");try{const e=await l.fetchBlob(n);k.update({url:URL.createObjectURL(e),filename:f,kind:j})}catch(e){k.update({filename:f,kind:j,converting:!1,convertingMessage:d(e,a.loadFailed)})}}var f=n(()=>import("../Calculator-4K53PFBL.js")),j=n(()=>import("../Spreadsheet-HKXSYD5B.js")),k=n(()=>import("../Weather-S3N5OWYF.js")),w=n(()=>import("../CurrencyConverter-QEG6RFAS.js")),g=n(()=>import("../PomodoroTimer-T6YAQFIE.js")),S=n(()=>import("../Notepad-KNJRTYXR.js")),v=n(()=>import("../WorldClock-ACC3S6OA.js")),b=n(()=>import("../Stock-BZFC2ROU.js")),F=n(()=>import("../Preview-KEIDYSHF.js")),T=n(()=>import("../PdfViewer-UZGDE4HD.js")),x=n(()=>import("../Documents-6DEUZVVA.js")),y=n(()=>import("../Files-2VSFXA45.js")),I=n(()=>import("../Browser-5F5LWXYQ.js")),P={"/calculator":{component:f,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/spreadsheet":{component:j,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0},"/notepad":{component:S,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:k,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:w,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:g,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:v,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:b,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},H={"/preview":{component:F,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/documents":{component:x,label:"Documents",size:"xl",appStyle:!0,multiInstance:!0},"/files":{component:y,label:"Files",size:"xl",appStyle:!0}},L={"/browser":{component:I,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},B={...P,...H,...L};export{I as Browser,f as Calculator,w as CurrencyConverter,x as Documents,y as Files,S as Notepad,T as PdfViewer,g as PomodoroTimer,F as Preview,j as Spreadsheet,b as Stock,k as Weather,v as WorldClock,m as attachmentKind,B as bundledApps,H as documentApps,h as openAttachment,P as utilityApps,L as webApps};
2
+ export{openFilesInTrashMode,setFilesDemoTree}from"../chunk-P4SGJTK3.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-GPNNQIRY.js";import"../chunk-LMIQV3NB.js";import{setPdfPreview as e}from"../chunk-ESL5TDNA.js";export{setPdfPreview}from"../chunk-ESL5TDNA.js";import{setSpreadsheetPreview as t}from"../chunk-VTVSMRFX.js";export{setSpreadsheetPreview}from"../chunk-VTVSMRFX.js";import"../chunk-TMZVVRTA.js";import"../chunk-DSSLOQDW.js";import"../chunk-6TCHOT4R.js";import"../chunk-OBMR6BEP.js";import{toast_default as o}from"../chunk-DBB4DB7J.js";import"../chunk-2TP4GK53.js";import"../chunk-5A7MWTXX.js";import"../chunk-OGXU7QFW.js";import"../chunk-VOY6TCS2.js";import"../chunk-ZDF5AR5W.js";import"../chunk-AFYQTVZO.js";import"../chunk-HZZNJHRH.js";import"../chunk-X4FJ54PP.js";import"../chunk-D65T4H6J.js";import"../chunk-XUF7VW4U.js";import{currentShellStrings as r}from"../chunk-3JK2LSFU.js";import"../chunk-C3QOHMR6.js";import"../chunk-YKZHOXI4.js";import{lazy as n}from"react";function i(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),l=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),a=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function m(e){const t=i(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":l.has(t)?"image":a.has(t)?"3d":null}function p(e){window.open(e,"_blank","noopener,noreferrer")}async function u(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const r=await fetch(e);if(!r.ok)throw new Error(`fetch failed: ${r.status}`);return r.text()}function d(e,t){return(e instanceof Error?e.message:"")||t}async function h(n,s,l={}){const a=r().attachment,h=n?.url||"",f=n?.filename||a.fallbackName;if(!h&&!l.fetchBlob)return void o.error(a.noLink);const j=m(f)??m(h);if("csv"===j){try{t({csv:await u(h,l,n),filename:f}),s("/spreadsheet")}catch{o.error(a.spreadsheetFailed),h&&p(h)}return}if(c.has(i(f)||i(h)))return o.error(a.workbookUnavailable),void(h&&p(h));if(!j)return h?(o.info(a.noViewer),void p(h)):void o.error(a.noLink);if(!l.fetchBlob)return e({url:h,filename:f,kind:j}),void s("/preview");const k=e({filename:f,kind:j,converting:!0,convertingMessage:l.loadingMessage||a.loading});s("/preview");try{const e=await l.fetchBlob(n);k.update({url:URL.createObjectURL(e),filename:f,kind:j})}catch(e){k.update({filename:f,kind:j,converting:!1,convertingMessage:d(e,a.loadFailed)})}}var f=n(()=>import("../Calculator-E2CBADVF.js")),j=n(()=>import("../Spreadsheet-RCHOM2RE.js")),k=n(()=>import("../Weather-KLQ55R64.js")),w=n(()=>import("../CurrencyConverter-LF2WHJW4.js")),g=n(()=>import("../PomodoroTimer-XARF7DO3.js")),v=n(()=>import("../Notepad-UQSG5BE3.js")),b=n(()=>import("../WorldClock-RMPU7D2M.js")),S=n(()=>import("../Stock-25FQMI2G.js")),T=n(()=>import("../Preview-LETK6AJS.js")),B=n(()=>import("../PdfViewer-4VGNBBED.js")),x=n(()=>import("../Documents-MB4TJGNY.js")),P=n(()=>import("../Files-JQYIBZEP.js")),y=n(()=>import("../Browser-WUVL7ZSM.js")),F={"/calculator":{component:f,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/spreadsheet":{component:j,label:"Spreadsheets",size:"2xl",appStyle:!0,multiInstance:!0},"/notepad":{component:v,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:k,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:w,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:g,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:b,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:S,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},L={"/preview":{component:T,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/documents":{component:x,label:"Documents",size:"xl",appStyle:!0,multiInstance:!0},"/files":{component:P,label:"Files",size:"xl",appStyle:!0}},M={"/browser":{component:y,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},R={...F,...L,...M};export{y as Browser,f as Calculator,w as CurrencyConverter,x as Documents,P as Files,v as Notepad,B as PdfViewer,g as PomodoroTimer,T as Preview,j as Spreadsheet,S as Stock,k as Weather,b as WorldClock,m as attachmentKind,R as bundledApps,L as documentApps,h as openAttachment,F as utilityApps,M as webApps};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{execFileSync as e}from"child_process";import{createRequire as t}from"module";import{join as n}from"path";import{existsSync as i,readFileSync as o,writeFileSync as s,readdirSync as r}from"fs";var a=["button","input","range","textarea","select","dialog","title","portal","native","dark","hex","radius","kit","icon","kit-dep"],l=e=>"string"==typeof e&&a.includes(e),c={button:{counts:"a raw <button>",instead:"Button or IconButton from efficient-shell/ui"},input:{counts:"a raw <input> (not hidden, not a range)",instead:"Input, InputNumber, Checkbox, Radio or Switch from efficient-shell/ui"},range:{counts:'a raw <input type="range">',instead:"Slider from efficient-shell/ui"},textarea:{counts:"a raw <textarea>",instead:"Textarea from efficient-shell/ui"},select:{counts:"a raw <select>",instead:"Select or SearchableSelect from efficient-shell/ui"},dialog:{counts:'a raw <dialog>, or role="dialog" / role="alertdialog" on a raw element',instead:"Dialog or Modal from efficient-shell"},title:{counts:"a title= on a raw element (the browser's own tooltip)",instead:"Tooltip from efficient-shell/ui (harness UI-17)"},portal:{counts:"a createPortal(…) call (a layer the file floats itself)",instead:"Popover, PopupMenu, DropdownMenu, Tooltip or Dialog from efficient-shell/ui"},native:{counts:"window.confirm / alert / prompt, or a bare call that resolves to one",instead:"confirm, confirmDestructive, prompt or toast from efficient-shell (harness UI-20)"},dark:{counts:"a dark: variant in a class string",instead:"the light Tailwind class alone; the shell remaps it in dark mode (harness UI-7)"},hex:{counts:"a hex colour literal in a .tsx string",instead:"a shell token or a Tailwind palette class (harness FT-1)"},radius:{counts:"a literal corner radius (an arbitrary-value radius class, or an inline borderRadius)",instead:"a radius utility from the scale or a role token such as rounded-(--radius-control); the theme sets how round they are (harness UI-7)"},kit:{counts:"an import of a second UI kit",instead:"the component from efficient-shell/ui, or fold it into the shell (harness FT-3)"},icon:{counts:"an import of an icon package",instead:"<Icon name> from efficient-shell/icons, drawn by the set the theme chose (harness UI-24)"},"kit-dep":{counts:"a UI kit or icon package declared in package.json (not one the shell entries imported here need)",instead:"remove the dependency once nothing imports it (harness FT-3)"}},d=["@headlessui/","@radix-ui/","@mui/","@chakra-ui/","@mantine/","@floating-ui/","antd","react-aria","react-aria-","react-bootstrap","react-select","react-colorful","react-tooltip","react-hot-toast","react-toastify","sonner"],u=["@heroicons/","@tabler/icons","@tabler/icons-","@phosphor-icons/","@fortawesome/","@iconify/","@radix-ui/react-icons","@mui/icons-material","lucide","lucide-react","simple-icons","react-icons","react-feather"],f={"efficient-shell":["@headlessui/react","@heroicons/react"],"efficient-shell/apps":["@heroicons/react"],"efficient-shell/icons/heroicons":["@heroicons/react"],"efficient-shell/icons/lucide":["lucide-react"]};function h(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function p(e){return h(e,u)?"icon":h(e,d)?"kit":null}var m=/[.+^$()|[\]\\]/g;function g(e){let t="",n=0;for(let i=0;i<e.length;i++){const o=e[i];"*"===o?"*"===e[i+1]?"/"===e[i+2]?(t+="(?:[^/]+/)*",i+=2):(t+=".*",i+=1):t+="[^/]*":"?"===o?t+="[^/]":"{"===o?(t+="(?:",n+=1):"}"===o&&n>0?(t+=")",n-=1):t+=","===o&&n>0?"|":o.replace(m,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function k(e){const t=e.map(g);return e=>t.some(t=>t.test(e))}var $=new Set(["node_modules",".git"]),w=new Set(["dist","coverage",".next",".turbo"]);function b(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function y(e,t){const i=k(t),o=[...new Set(t.map(b))].sort(),s=o.filter(e=>!o.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),a=new Set,l=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?$.has(e.name)||""===t&&w.has(e.name)||l(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)l(e);return[...a].sort(x)}var x=(e,t)=>e<t?-1:e>t?1:0,v=class extends Error{},S=(e,t)=>`${e}:${t}`;function j(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var I=e=>a.indexOf(e);function T(e,t){const n=j(e),i=j(t);return x(n.file,i.file)||I(n.kind)-I(i.kind)}function A(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new v(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new v(`${t}: ${e}. The tool writes this file; do not edit it by hand.`)};if("object"!=typeof n||null===n||Array.isArray(n))return i("must be a JSON object");const o=n;if(1!==o.schema)return i("number"==typeof o.schema&&o.schema>1?`"schema": ${o.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');if(!Array.isArray(o.kinds)||o.kinds.some(e=>"string"!=typeof e))return i('"kinds" must be a list');const s=o.kinds.filter(l);if("object"!=typeof o.counts||null===o.counts||Array.isArray(o.counts))return i('"counts" must be an object');const r=new Map;for(const[e,t]of Object.entries(o.counts)){const{file:n,kind:o}=j(e);if(!n||!o)return i(`"${e}" is not "<file>:<kind>"`);if("number"!=typeof t||!Number.isInteger(t)||t<1)return i(`"${e}" must be a whole number, 1 or more (a line that reaches 0 is deleted)`);l(o)&&r.set(e,t)}return{kinds:s,counts:r}}function E(e){const t=a.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(T).map(t=>` ${JSON.stringify(t)}: ${e.counts.get(t)}`);return["{",' "schema": 1,',` "kinds": [${t.map(e=>JSON.stringify(e)).join(", ")}],`,n.length?` "counts": {\n${n.join(",\n")}\n }`:' "counts": {}',"}",""].join("\n")}function M(e){const t={};for(const[n,i]of e){const{kind:e}=j(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var O=class extends Error{},D=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),N=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var R="package.json",L=new Set(["iframe","frame","object","embed"]),F=new Set(["href","xlinkHref","to","id","key","htmlFor"]),J=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,P=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,U=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,B=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,W=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,C=new Set(["confirm","alert","prompt"]),q=new Set(["window","globalThis","self"]);function z(e,t,n,i,o){const s=new Set(i),r=e.createSourceFile(t,n,e.ScriptTarget.Latest,!0,function(e,t){return t.endsWith(".tsx")?e.ScriptKind.TSX:t.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(t)?e.ScriptKind.JS:e.ScriptKind.TS}(e,t)),a={},l=/\.[jt]sx$/.test(t),c=(e,t)=>{var n;s.has(e)&&(a[e]??=[]).push((n=t.getStart(r),r.getLineAndCharacterOfPosition(n).line+1))},d=(t,n)=>t.attributes.properties.find(t=>e.isJsxAttribute(t)&&t.name.getText(r)===n),u=t=>{const n=t?.initializer;if(n)return e.isStringLiteral(n)?n.text:e.isJsxExpression(n)&&n.expression&&e.isStringLiteralLike(n.expression)?n.expression.text:void 0},f=new Set;if(s.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))C.has(n.text)&&f.add(n.text);else if(e.isObjectBindingPattern(n)||e.isArrayBindingPattern(n))for(const i of n.elements)e.isBindingElement(i)&&t(i.name)},n=i=>{(e.isImportClause(i)||e.isImportSpecifier(i)||e.isNamespaceImport(i)||e.isVariableDeclaration(i)||e.isParameter(i)||e.isFunctionDeclaration(i))&&t(i.name),e.forEachChild(i,n)};n(r)}const h=t=>t&&e.isStringLiteralLike(t)?t.text:void 0,m=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&o?.add(e);const n=e?p(e):null;n&&c(n,t)},g=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(W))c("dark",t);if(s.has("radius"))for(const n of e.matchAll(P))B.test(n[1].trim())||c("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(J))c("hex",t)},k=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);if(/^[a-z]/.test(e)){const n=u(d(t,"type"));"button"===e?c("button",t):"select"===e?c("select",t):"textarea"===e?c("textarea",t):"input"===e&&("range"===n?c("range",t):"hidden"!==n&&c("input",t));const i=u(d(t,"role"));"dialog"!==e&&"dialog"!==i&&"alertdialog"!==i||c("dialog",t),!L.has(e)&&d(t,"title")&&c("title",t)}}else if(e.isCallExpression(t)){const n=t.expression;e.isIdentifier(n)?"createPortal"===n.text?c("portal",t):C.has(n.text)&&!f.has(n.text)?c("native",t):"require"===n.text&&m(h(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?c("portal",t):C.has(n.name.text)&&e.isIdentifier(n.expression)&&q.has(n.expression.text)&&c("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(h(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(h(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)&&s.has("radius")){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;U.test(n)&&(e.isNumericLiteral(i)?B.test(i.text)||c("radius",t):e.isStringLiteralLike(i)&&!B.test(i.text.trim())&&c("radius",t))}else if(e.isStringLiteralLike(t))g(t.text,t,n);else if(e.isTemplateExpression(t)){g(t.head.text,t.head,n);for(const e of t.templateSpans)g(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&F.has(t.name.getText(r))?e.forEachChild(t,e=>k(e,!1)):e.forEachChild(t,e=>k(e,n))};return k(r,!0),a}function K(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function G(e,t,n){const i=e.createSourceFile(t,n,e.ScriptTarget.Latest,!1),o=[];for(const t of i.statements)(e.isImportDeclaration(t)||e.isExportDeclaration(t))&&t.moduleSpecifier&&e.isStringLiteralLike(t.moduleSpecifier)&&o.push(t.moduleSpecifier.text);return o}var _=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var H=e=>new Map(e.allow.map(e=>[S(e.file,e.kind),e.count]));function X(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var V=(e,t,n)=>{if("kit-dep"===n)return` (${e.kitDeps.join(", ")})`;const i=e.hits.get(t)?.[n]??[];if(0===i.length)return"";const o=i.slice(0,12).join(", ");return` (line${1===i.length?"":"s"} ${o}${i.length>12?", …":""})`};function Q(e,t,n){const i=H(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=j(e);if(!l(t)||!n.includes(t))continue;const r=s-(i.get(e)??0);r>0&&o.set(e,r)}return{kinds:a.filter(e=>n.includes(e)),counts:o}}function Y(e,t){let n=0;for(const i of new Set([...e.keys(),...t.keys()]))(e.get(i)??0)!==(t.get(i)??0)&&(n+=1);return n}var Z="\n// <button> in a comment is not a button\n/* nor is <input title=\"x\"> in this one, or dark:bg-black, or #fff */\nimport { createPortal } from 'react-dom';\nimport { Dialog } from '@headlessui/react';\nimport { TrashIcon } from '@heroicons/react/24/outline';\nimport type { Icon } from 'lucide-react';\nimport { Button, confirm } from 'efficient-shell';\nexport { Slot } from '@radix-ui/react-slot';\nexport { CheckIcon } from '@radix-ui/react-icons';\n\nconst a = <button title=\"Says what it does\">x</button>;\nconst b = <input type=\"range\" />;\nconst c = <input type=\"text\" />;\nconst c2 = <input type={\"hidden\"} name=\"csrf\" />;\nconst c3 = <input type=\"hidden\" />;\nconst c4 = <input type={kind} />;\nconst d = <select />;\nconst d2 = <textarea />;\nconst e = <div role=\"dialog\" />;\nconst e2 = <dialog open />;\nconst e3 = <section role={'alertdialog'} />;\nconst f = <iframe title=\"Preview\" />;\nconst f2 = <object title=\"Chart\" />;\nconst g = <Button title=\"a prop, not a tooltip\" role=\"dialog\" />;\nconst g2 = (\n <button\n type=\"button\"\n title={hint}\n >\n y\n </button>\n);\nconst h = ReactDOM.createPortal(a, document.body);\nconst i = createPortal(a, document.body);\n\nasync function leave() {\n if (window.confirm('Sure?')) return;\n globalThis.alert('No');\n alert('native: nothing binds the name');\n prompt('native too');\n await confirm('the shell: the import binds it');\n record.confirm('a method, not the popup');\n}\n\nconst j = <div className=\"bg-white dark:bg-black dark:hover:text-white is-dark:no\" />;\nconst k = clsx('text-gray-900', on && 'dark:text-gray-100');\nconst l = <span style={{ color: '#fff', background: \"#12ab34\" }} className={`border-[#0a0b0c80] ${x}`} />;\nconst m = <a href=\"#faded\" id=\"#bad\" key=\"#abc\" to=\"#face\">skip</a>;\nconst n = <label htmlFor={'#dead'}>skip</label>;\nconst o = <span>&#1234; and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity &#x1f; ref BG#00340';\nconst q = <use xlinkHref=\"#abc\" fill=\"url(#fed)\" />;\nconst t = <div className=\"rounded-[4px] rounded-t-[0.5rem] hover:rounded-[2px] rounded-lg rounded-(--radius-card) rounded-[inherit] rounded-[var(--r)]\" />;\nconst u = <div style={{ borderRadius: 6, borderTopLeftRadius: '3px', borderBottomRightRadius: '50%', borderEndEndRadius: 'var(--radius-card)' }} />;\nconst v = <i style={{ borderRadius: 9999 }} />;\nconst r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\n",ee={button:2,input:2,range:1,textarea:1,select:1,dialog:3,title:2,portal:2,native:4,dark:3,hex:3,radius:5,kit:4,icon:3},te={kit:1,dark:1,portal:1,radius:2},ne=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var ie="ui-kit.config.json",oe="ui-kit.baseline.json",se="efficient-shell-ui-check",re=`${se}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${se} check this repository against ${oe}\n ${se} --print print today's counts as a baseline, and change nothing\n ${se} --summary print totals per kind and per folder, as Markdown\n ${se} --json print the result as JSON\n ${se} --update lower the lines whose counts fell, and delete the ones at zero\n ${se} --update --allow-move also follow a renamed or split file (no total may rise)\n ${se} --init write the first ${oe}\n ${se} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${se} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${ie} in the current directory.`;var ae=(e,t)=>`${e} ${t}${1===e?"":"s"}`,le=(e,t)=>{const n=M(e);return t.map(e=>`${e} ${n[e]??0}`).join(" · ")};process.exitCode=function(e,t){const r=function(e){const t={print:!1,summary:!1,json:!1,update:!1,allowMove:!1,init:!1,noBase:!1,help:!1,version:!1,kinds:[]};for(let n=0;n<e.length;n++){const i=e[n];if("--print"===i)t.print=!0;else if("--summary"===i)t.summary=!0;else if("--json"===i)t.json=!0;else if("--update"===i)t.update=!0;else if("--allow-move"===i)t.allowMove=!0;else if("--init"===i)t.init=!0;else if("--no-base"===i)t.noBase=!0;else if("--help"===i||"-h"===i)t.help=!0;else if("--version"===i||"-v"===i)t.version=!0;else if("--kind"===i){const i=e[++n];if(!i)return"--kind needs a kind after it";t.kinds.push(...i.split(","))}else{if(!i.startsWith("--kind="))return`unknown argument "${i}"`;t.kinds.push(...i.slice(7).split(","))}}return t.allowMove&&!t.update?"--allow-move goes with --update":t.kinds.length&&!t.init?"--kind goes with --init":[t.print,t.summary,t.update,t.init].filter(Boolean).length>1?"choose one of --print, --summary, --update and --init":t}(e);if("string"==typeof r)return t.err(`${se}: ${r}\n\n${re}`),2;if(r.help)return t.out(re),0;if(r.version)return t.out(t.version),0;const d=e=>(r.json?t.out(JSON.stringify({tool:se,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${se}: ${e}`),1),u=n(t.cwd,ie);if(!i(u))return d(`no ${ie} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let h,m;try{h=function(e,t="ui-kit.config.json"){const n=[],i=e=>{n.push(e)},o=(e,t,{required:n=!1}={})=>{if(void 0===e&&!n)return[];if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||""===e))return i(`${t} must be a list of non-empty strings`),[];n&&0===e.length&&i(`${t} must name at least one entry`);for(const n of e)(n.startsWith("/")||n.startsWith("./")||n.includes("\\")||n.split("/").includes(".."))&&i(`${t}: "${n}" must be a path from the repository root, written with / (no ./, .. or \\)`);return e},s=(e,t)=>"string"!=typeof e||e.trim().length<10?(i(`${t} needs a "reason" a reviewer can read (a sentence, not a word)`),""):e,r=(e,t)=>void 0===e?[]:!Array.isArray(e)||e.some(e=>!D(e))?(i(`${t} must be a list of objects`),[]):e;if(!D(e))throw new O(`${t}: must be a JSON object`);for(const t of Object.keys(e))N.has(t)||i(`unknown key "${t}"`);1!==e.schema&&i("number"==typeof e.schema&&e.schema>1?`"schema": ${e.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');const c=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)l(t)?c.includes(t)?i(`"kinds": "${t}" is listed twice`):c.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${a.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${a.join(", ")}`);const d=o(e.include,'"include"'),u=o(e.exclude,'"exclude"'),f=r(e.includeImporting,'"includeImporting"').map((e,t)=>({files:o(e.files,`"includeImporting"[${t}].files`,{required:!0}),modules:o(e.modules,`"includeImporting"[${t}].modules`,{required:!0}),reason:s(e.reason,`"includeImporting"[${t}]`)}));0===d.length&&0===f.length&&i('"include" must name the files that are operator UI (for example ["src/**/*.tsx"])');const h=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),p=[],m=new Set;if(r(e.allow,'"allow"').forEach((e,t)=>{const n=`"allow"[${t}]`,[r]=o([e.file],`${n}.file`),d=s(e.reason,n);if(!l(e.kind))return void i(`${n}.kind must be one of: ${a.join(", ")}`);if(c.includes(e.kind)||i(`${n}: kind "${e.kind}" is not in "kinds"`),"number"!=typeof e.count||!Number.isInteger(e.count)||e.count<1)return void i(`${n}.count must be a whole number, 1 or more`);if(!r)return;const u=`${r}:${e.kind}`;m.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),m.add(u),p.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new O(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:f,output:h,allow:p}}(JSON.parse(o(u,"utf8")),ie)}catch(e){return d(e instanceof O?e.message:`${ie} is not valid JSON: ${e.message}`)}try{m=t.loadTypeScript()}catch{return d('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const g=function(e){const t=[],n=a.filter(e=>"kit-dep"!==e),i=[["fixture.tsx",Z,ee],["fixture.ts","\nimport { toast } from 'sonner';\nexport const tone = { warn: '#f59e0b' };\nexport const cls = 'ring-1 dark:ring-white rounded-[3px]';\nexport const box = { borderRadius: '0.25rem', radius: 4 };\nexport function ask(confirm: (message: string) => boolean) {\n return confirm('a parameter binds the name');\n}\nexport const mount = (node: unknown) => ReactDOM.createPortal(node, document.body);\n",te]];for(const[o,s,r]of i){const i=K(z(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${ne(i)}; it holds ${ne(r)}`)}const o=K(z(e,"fixture.tsx",Z,["button"]));return"button"!==Object.keys(o).join()&&t.push(`asked for button alone, the reader reported ${ne(o)}`),t}(m);if(g.length)return d(`the reader misread its own fixtures with typescript ${m.version}, so nothing it says about this repository can be trusted:\n - `+g.join("\n - "));const $=function(e,t,s){const r=[],a=k(s.exclude),l=k(s.output.flatMap(e=>e.files)),c=new Map,d=e=>{let i=c.get(e);return void 0===i&&c.set(e,i=o(n(t,e),"utf8")),i},u=(e,n)=>{for(const i of e)0===y(t,[i]).length&&r.push(`${n}: "${i}" matches no file. Delete the line, or fix the path.`)};u(s.include,'"include"'),s.output.forEach((e,t)=>u(e.files,`"output"[${t}]`)),s.includeImporting.forEach((e,t)=>u(e.files,`"includeImporting"[${t}]`));const h=new Set,m=e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!a(e)&&!l(e);for(const e of y(t,s.include))m(e)&&h.add(e);for(const n of s.includeImporting)for(const i of y(t,n.files))m(i)&&!h.has(i)&&_(G(e,i,d(i)),n.modules)&&h.add(i);const g=[...h].sort(),$=s.kinds.filter(e=>"kit-dep"!==e),w=new Map,b=new Map,x=new Set;for(const t of g){const n=z(e,t,d(t),$,x);let i=!1;for(const e of $){const o=n[e]?.length??0;o&&(b.set(S(t,e),o),i=!0)}i&&w.set(t,n)}let v=[],j=[];if(s.kinds.includes("kit-dep")){const e=n(t,R);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...x].flatMap(e=>f[e]??[])),s=[...new Set(n)].filter(e=>null!==p(e)).sort();v=s.filter(e=>!i.has(e)),j=s.filter(e=>i.has(e)),v.length&&b.set(S(R,"kit-dep"),v.length)}else r.push(`"kinds" includes "kit-dep", and there is no ${R} here to read.`)}for(const e of s.allow)("kit-dep"===e.kind?e.file===R:h.has(e.file))||r.push(`"allow": ${e.file} (${e.kind}) is not a file this check reads. Delete the entry, or fix the path.`);return{files:g,hits:w,counts:b,kitDeps:v,shellPeers:j,problems:r}}(m,t.cwd,h);if(0===$.files.length)return d(`read no files. "include" in ${ie} matches nothing, so a pass would mean nothing.`);const w=n(t.cwd,oe),b=r.json,x=e=>{b||t.out(e)};if(r.print)return t.out(E(Q(h,$,h.kinds)).trimEnd()),0;if(r.summary){for(const e of function(e,t){const n=new Map,i=new Map;for(const[e,o]of t.counts){const{file:t,kind:s}=j(e);if(!l(s))continue;const r=n.get(s)??{count:0,files:new Set};r.count+=o,r.files.add(t),n.set(s,r);const a=t.split("/"),c=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(c)??{};d[s]=(d[s]??0)+o,i.set(c,d)}const o=e.kinds.filter(e=>n.has(e)),s=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>j(e).file)).size} of ${ae(t.files.length,"file")} still draw UI of their own.`,"","| Kind | Count | Files | The shell has |","|---|---:|---:|---|",...e.kinds.map(e=>{const t=n.get(e);return`| \`${e}\` | ${t?.count??0} | ${t?.files.size??0} | ${c[e].instead} |`})];if(o.length&&i.size){const e=e=>o.reduce((t,n)=>t+(e[n]??0),0),t=[...i].sort((t,n)=>e(n[1])-e(t[1])||(t[0]<n[0]?-1:1));s.push("",`| Folder | ${o.map(e=>`\`${e}\``).join(" | ")} | Total |`,`|---|${o.map(()=>"---:").join("|")}|---:|`,...t.map(([t,n])=>`| \`${t}\` | ${o.map(e=>n[e]??0).join(" | ")} | ${e(n)} |`))}return s}(h,$))t.out(e);return 0}let I=null;if(i(w))try{I=A(o(w,"utf8"),oe)}catch(e){return d(e instanceof v?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!l(e)||!h.kinds.includes(e));if(e.length)return d(`--kind ${e.join(", ")}: not in "kinds" in ${ie}. Add it there first.`);const t=r.kinds;if(I){if(0===t.length)return d(`${oe} already exists, and --init would overwrite what it holds. It is for the adoption pull request only. To start checking a kind, add it to "kinds" and run --init --kind <kind>.`);const e=t.filter(e=>I.kinds.includes(e));if(e.length)return d(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Q(h,$,t);I={kinds:[...I.kinds,...t],counts:new Map([...I.counts,...n.counts])}}else{if(t.length)return d(`there is no ${oe} yet. Run --init on its own first.`);I=Q(h,$,h.kinds)}s(w,E(I)),x(`${se}: wrote ${oe} (${ae(I.counts.size,"line")}: ${le(I.counts,I.kinds)})`)}if(!I)return d(`no ${oe}. This repository has not adopted the check yet: run ${se} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=X(e,t),s=Q(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(j(e).kind)));if(i){const e=M(r),n=M(s.counts),i=o.filter(t=>(n[t]??0)>(e[t]??0)).map(t=>`${t}: ${n[t]??0} across the repository, and the baseline holds ${e[t]??0}`);return i.length?{baseline:t,lowered:0,refused:i}:{baseline:s,lowered:Y(r,s.counts),refused:[]}}const a=new Map;for(const[e,t]of r){const n=Math.min(t,s.counts.get(e)??0);n>0&&a.set(e,n)}return{baseline:{kinds:o,counts:a},lowered:Y(r,a),refused:[]}}(h,I,$,{allowMove:r.allowMove});if(e.refused.length)return d(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);I=e.baseline,s(w,E(I)),x(`${se}: ${e.lowered?`changed ${ae(e.lowered,"line")} in`:"nothing to change in"} ${oe}`)}const L=function(e,t,n){const i=[],o=[],s=[...n.problems],r=H(e),a=new Set(X(e,t)),d=e.kinds.filter(e=>!t.kinds.includes(e));d.length&&s.push(`"kinds" names ${d.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===d.length?"it":"them"}. Run: efficient-shell-ui-check --init ${d.map(e=>`--kind ${e}`).join(" ")}`);const u=t.kinds.filter(t=>!e.kinds.includes(t));u.length&&o.push(`the baseline still carries ${u.map(e=>`"${e}"`).join(", ")}, which "kinds" no longer names`);const f=new Set([...n.counts.keys(),...t.counts.keys(),...r.keys()]);for(const e of[...f].sort(T)){const{file:d,kind:u}=j(e);if(!l(u)||!a.has(u))continue;const f=n.counts.get(e)??0,h=r.get(e)??0,p=t.counts.get(e)??0;f>h+p?i.push(`${d}: ${u} ${f}, and its line allows ${h+p}${V(n,d,u)}. ${c[u].counts} is counted; use ${c[u].instead}.`):f<h?s.push(`${d}: ${u} ${f}, and "allow" in ui-kit.config.json says ${h}. ${0===f?"Delete the entry":`Lower its count to ${f}`}: an exception does not outlive what it excused.`):f<h+p&&o.push(`${d}: ${u} ${f}, and its line says ${h+p}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(h,I,$),F=r.noBase?{problems:[],note:""}:function(e,t,n){const i=e.env.GITHUB_BASE_REF;if(!i)return{problems:[],note:""};const o=e.git(["rev-parse","--show-prefix"]);if(null===o)return{problems:[],note:"not a git checkout; the base branch was not compared"};const s=`origin/${i}`;if(null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])&&(e.git(["fetch","--no-tags","--depth=1","origin",`+refs/heads/${i}:refs/remotes/origin/${i}`]),null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])))return{problems:[],note:`${s} could not be fetched; the base branch was not compared`};const r=e.git(["show",`${s}:${o.trim()}${oe}`]);if(null===r)return{problems:[],note:`${s} has no ${oe} yet (adoption)`};let a;try{a=A(r,`${s}:${oe}`)}catch{return{problems:[],note:`${s}'s ${oe} could not be read; the base branch was not compared`}}const l=M(a.counts),d=M(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(d[e]??0)>(l[e]??0)).map(e=>`${oe} holds ${d[e]??0} of "${e}", and ${s} holds ${l[e]??0}. The baseline only goes down: use ${c[e].instead}. A count that is meant to stay goes in "allow" in ${ie}, with its reason.`),note:`compared with ${s}`}}(t,I,h.kinds),J=h.kinds.filter(e=>I.kinds.includes(e)),P=`${se} --update`,U=[...L.other,...L.grown,...L.shrunk.map(e=>`${e}. Run: ${P}`),...F.problems],B=0===U.length;if(r.json){const e=new Map(h.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));return t.out(JSON.stringify({tool:se,version:t.version,ok:B,schema:h.schema,kinds:h.kinds,files:$.files.length,counts:M($.counts),baseline:M(I.counts),allowed:M(e),kitDeps:$.kitDeps,shellPeers:$.shellPeers,failures:U},null,2)),B?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const W=(e,n,i="")=>{if(0===n.length)return t.out(` ok ${e}`);t.err(` FAIL ${e}`);for(const e of n)t.err(` ${e}`);i&&t.err(` ${i}`)};t.out(` ok the reader reads its own fixtures (typescript ${m.version})`),t.out(` ok read ${ae($.files.length,"file")}`),W(`${ie} and ${oe} describe this repository`,L.other),W("no file draws more of its own UI than its line allows",L.grown),W("every line is exact: a count that fell is a line to lower",L.shrunk,`Run: ${P}${L.updateFixes?"":" (after the failures above are fixed)"}`),F.note&&W(`the baseline is no higher than the base branch (${F.note})`,F.problems);const C=new Set([...$.counts.keys()].map(e=>j(e).file));return t.out(` ok PROGRESS: ${C.size} of ${ae($.files.length,"file")} still draw UI of their own: `+le($.counts,J)),t.out(""),B?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${ae(U.length,"problem")})`),B?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:function(){for(const e of[n(process.cwd(),"package.json"),import.meta.url])try{return t(e)("typescript")}catch{}throw new Error("typescript is not installed")},git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"5.0.0"});
2
+ import{execFileSync as e}from"child_process";import{createRequire as t}from"module";import{join as n}from"path";import{existsSync as i,readFileSync as o,writeFileSync as s,readdirSync as r}from"fs";var a=["button","input","range","textarea","select","dialog","title","portal","native","dark","hex","radius","kit","icon","kit-dep"],l=e=>"string"==typeof e&&a.includes(e),c={button:{counts:"a raw <button>",instead:"Button or IconButton from efficient-shell/ui"},input:{counts:"a raw <input> (not hidden, not a range)",instead:"Input, InputNumber, Checkbox, Radio or Switch from efficient-shell/ui"},range:{counts:'a raw <input type="range">',instead:"Slider from efficient-shell/ui"},textarea:{counts:"a raw <textarea>",instead:"Textarea from efficient-shell/ui"},select:{counts:"a raw <select>",instead:"Select or SearchableSelect from efficient-shell/ui"},dialog:{counts:'a raw <dialog>, or role="dialog" / role="alertdialog" on a raw element',instead:"Dialog or Modal from efficient-shell"},title:{counts:"a title= on a raw element (the browser's own tooltip)",instead:"Tooltip from efficient-shell/ui (harness UI-17)"},portal:{counts:"a createPortal(…) call (a layer the file floats itself)",instead:"Popover, PopupMenu, DropdownMenu, Tooltip or Dialog from efficient-shell/ui"},native:{counts:"window.confirm / alert / prompt, or a bare call that resolves to one",instead:"confirm, confirmDestructive, prompt or toast from efficient-shell (harness UI-20)"},dark:{counts:"a dark: variant in a class string",instead:"the light Tailwind class alone; the shell remaps it in dark mode (harness UI-7)"},hex:{counts:"a hex colour literal in a .tsx string",instead:"a shell token or a Tailwind palette class (harness FT-1)"},radius:{counts:"a literal corner radius (an arbitrary-value radius class, or an inline borderRadius)",instead:"a radius utility from the scale or a role token such as rounded-(--radius-control); the theme sets how round they are (harness UI-7)"},kit:{counts:"an import of a second UI kit",instead:"the component from efficient-shell/ui, or fold it into the shell (harness FT-3)"},icon:{counts:"an import of an icon package",instead:"<Icon name> from efficient-shell/icons, drawn by the set the theme chose (harness UI-24)"},"kit-dep":{counts:"a UI kit or icon package declared in package.json (not one the shell entries imported here need)",instead:"remove the dependency once nothing imports it (harness FT-3)"}},d=["@headlessui/","@radix-ui/","@mui/","@chakra-ui/","@mantine/","@floating-ui/","antd","react-aria","react-aria-","react-bootstrap","react-select","react-colorful","react-tooltip","react-hot-toast","react-toastify","sonner"],u=["@heroicons/","@tabler/icons","@tabler/icons-","@phosphor-icons/","@fortawesome/","@iconify/","@radix-ui/react-icons","@mui/icons-material","lucide","lucide-react","simple-icons","react-icons","react-feather"],f={"efficient-shell":["@headlessui/react","@heroicons/react"],"efficient-shell/apps":["@heroicons/react"],"efficient-shell/icons/heroicons":["@heroicons/react"],"efficient-shell/icons/lucide":["lucide-react"]};function h(e,t){return t.some(t=>t.endsWith("/")||t.endsWith("-")?e.startsWith(t):e===t||e.startsWith(`${t}/`))}function p(e){return h(e,u)?"icon":h(e,d)?"kit":null}var m=/[.+^$()|[\]\\]/g;function g(e){let t="",n=0;for(let i=0;i<e.length;i++){const o=e[i];"*"===o?"*"===e[i+1]?"/"===e[i+2]?(t+="(?:[^/]+/)*",i+=2):(t+=".*",i+=1):t+="[^/]*":"?"===o?t+="[^/]":"{"===o?(t+="(?:",n+=1):"}"===o&&n>0?(t+=")",n-=1):t+=","===o&&n>0?"|":o.replace(m,"\\$&")}if(0!==n)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${t}$`)}function k(e){const t=e.map(g);return e=>t.some(t=>t.test(e))}var $=new Set(["node_modules",".git"]),w=new Set(["dist","coverage",".next",".turbo"]);function b(e){const t=e.search(/[*?{]/),n=-1===t?e:e.slice(0,t),i=n.lastIndexOf("/");return-1===i?"":n.slice(0,i)}function y(e,t){const i=k(t),o=[...new Set(t.map(b))].sort(),s=o.filter(e=>!o.some(t=>t!==e&&(""===t||e.startsWith(`${t}/`)))),a=new Set,l=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?$.has(e.name)||""===t&&w.has(e.name)||l(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)l(e);return[...a].sort(x)}var x=(e,t)=>e<t?-1:e>t?1:0,v=class extends Error{},S=(e,t)=>`${e}:${t}`;function j(e){const t=e.lastIndexOf(":");return{file:e.slice(0,t),kind:e.slice(t+1)}}var I=e=>a.indexOf(e);function T(e,t){const n=j(e),i=j(t);return x(n.file,i.file)||I(n.kind)-I(i.kind)}function A(e,t="ui-kit.baseline.json"){let n;try{n=JSON.parse(e)}catch(e){throw new v(`${t} is not valid JSON: ${e.message}`)}const i=e=>{throw new v(`${t}: ${e}. The tool writes this file; do not edit it by hand.`)};if("object"!=typeof n||null===n||Array.isArray(n))return i("must be a JSON object");const o=n;if(1!==o.schema)return i("number"==typeof o.schema&&o.schema>1?`"schema": ${o.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');if(!Array.isArray(o.kinds)||o.kinds.some(e=>"string"!=typeof e))return i('"kinds" must be a list');const s=o.kinds.filter(l);if("object"!=typeof o.counts||null===o.counts||Array.isArray(o.counts))return i('"counts" must be an object');const r=new Map;for(const[e,t]of Object.entries(o.counts)){const{file:n,kind:o}=j(e);if(!n||!o)return i(`"${e}" is not "<file>:<kind>"`);if("number"!=typeof t||!Number.isInteger(t)||t<1)return i(`"${e}" must be a whole number, 1 or more (a line that reaches 0 is deleted)`);l(o)&&r.set(e,t)}return{kinds:s,counts:r}}function E(e){const t=a.filter(t=>e.kinds.includes(t)),n=[...e.counts.keys()].filter(t=>(e.counts.get(t)??0)>0).sort(T).map(t=>` ${JSON.stringify(t)}: ${e.counts.get(t)}`);return["{",' "schema": 1,',` "kinds": [${t.map(e=>JSON.stringify(e)).join(", ")}],`,n.length?` "counts": {\n${n.join(",\n")}\n }`:' "counts": {}',"}",""].join("\n")}function M(e){const t={};for(const[n,i]of e){const{kind:e}=j(n);l(e)&&(t[e]=(t[e]??0)+i)}return t}var O=class extends Error{},D=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),N=new Set(["$schema","schema","kinds","include","exclude","includeImporting","output","allow"]);var R="package.json",L=new Set(["iframe","frame","object","embed"]),F=new Set(["href","xlinkHref","to","id","key","htmlFor"]),J=/(?<![&\w])(?<!url\()#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})(?![\w-])/g,P=/(?<![\w-])rounded(?:-(?:[trblse]|tl|tr|br|bl|ss|se|ee|es))?-\[([^\]]*)\]/g,U=/^border(?:(?:Top|Bottom)(?:Left|Right)|(?:Start|End)(?:Start|End))?Radius$/,B=/^(?:inherit|initial|unset|revert)$|var\(|^(?:50|100)%$|^(?:999|9999)(?:px)?$/,W=/(?<![\w-])dark:(?=[\w[\-!@*(])/g,C=new Set(["confirm","alert","prompt"]),q=new Set(["window","globalThis","self"]);function z(e,t,n,i,o){const s=new Set(i),r=e.createSourceFile(t,n,e.ScriptTarget.Latest,!0,function(e,t){return t.endsWith(".tsx")?e.ScriptKind.TSX:t.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(t)?e.ScriptKind.JS:e.ScriptKind.TS}(e,t)),a={},l=/\.[jt]sx$/.test(t),c=(e,t)=>{var n;s.has(e)&&(a[e]??=[]).push((n=t.getStart(r),r.getLineAndCharacterOfPosition(n).line+1))},d=(t,n)=>t.attributes.properties.find(t=>e.isJsxAttribute(t)&&t.name.getText(r)===n),u=t=>{const n=t?.initializer;if(n)return e.isStringLiteral(n)?n.text:e.isJsxExpression(n)&&n.expression&&e.isStringLiteralLike(n.expression)?n.expression.text:void 0},f=new Set;if(s.has("native")){const t=n=>{if(n)if(e.isIdentifier(n))C.has(n.text)&&f.add(n.text);else if(e.isObjectBindingPattern(n)||e.isArrayBindingPattern(n))for(const i of n.elements)e.isBindingElement(i)&&t(i.name)},n=i=>{(e.isImportClause(i)||e.isImportSpecifier(i)||e.isNamespaceImport(i)||e.isVariableDeclaration(i)||e.isParameter(i)||e.isFunctionDeclaration(i))&&t(i.name),e.forEachChild(i,n)};n(r)}const h=t=>t&&e.isStringLiteralLike(t)?t.text:void 0,m=(e,t)=>{e&&("efficient-shell"===e||e.startsWith("efficient-shell/"))&&o?.add(e);const n=e?p(e):null;n&&c(n,t)},g=(e,t,n)=>{if(s.has("dark"))for(const n of e.matchAll(W))c("dark",t);if(s.has("radius"))for(const n of e.matchAll(P))B.test(n[1].trim())||c("radius",t);if(n&&l&&s.has("hex"))for(const n of e.matchAll(J))c("hex",t)},k=(t,n)=>{if(e.isJsxOpeningElement(t)||e.isJsxSelfClosingElement(t)){const e=t.tagName.getText(r);if(/^[a-z]/.test(e)){const n=u(d(t,"type"));"button"===e?c("button",t):"select"===e?c("select",t):"textarea"===e?c("textarea",t):"input"===e&&("range"===n?c("range",t):"hidden"!==n&&c("input",t));const i=u(d(t,"role"));"dialog"!==e&&"dialog"!==i&&"alertdialog"!==i||c("dialog",t),!L.has(e)&&d(t,"title")&&c("title",t)}}else if(e.isCallExpression(t)){const n=t.expression;e.isIdentifier(n)?"createPortal"===n.text?c("portal",t):C.has(n.text)&&!f.has(n.text)?c("native",t):"require"===n.text&&m(h(t.arguments[0]),t):e.isPropertyAccessExpression(n)?"createPortal"===n.name.text?c("portal",t):C.has(n.name.text)&&e.isIdentifier(n.expression)&&q.has(n.expression.text)&&c("native",t):n.kind===e.SyntaxKind.ImportKeyword&&m(h(t.arguments[0]),t)}else{if(e.isImportDeclaration(t)||e.isExportDeclaration(t))return void m(h(t.moduleSpecifier),t);if(e.isPropertyAssignment(t)&&s.has("radius")){const n=e.isIdentifier(t.name)||e.isStringLiteralLike(t.name)?t.name.text:"",i=t.initializer;U.test(n)&&(e.isNumericLiteral(i)?B.test(i.text)||c("radius",t):e.isStringLiteralLike(i)&&!B.test(i.text.trim())&&c("radius",t))}else if(e.isStringLiteralLike(t))g(t.text,t,n);else if(e.isTemplateExpression(t)){g(t.head.text,t.head,n);for(const e of t.templateSpans)g(e.literal.text,e.literal,n)}}e.isJsxAttribute(t)&&F.has(t.name.getText(r))?e.forEachChild(t,e=>k(e,!1)):e.forEachChild(t,e=>k(e,n))};return k(r,!0),a}function K(e){const t={};for(const[n,i]of Object.entries(e))i.length&&(t[n]=i.length);return t}function G(e,t,n){const i=e.createSourceFile(t,n,e.ScriptTarget.Latest,!1),o=[];for(const t of i.statements)(e.isImportDeclaration(t)||e.isExportDeclaration(t))&&t.moduleSpecifier&&e.isStringLiteralLike(t.moduleSpecifier)&&o.push(t.moduleSpecifier.text);return o}var _=(e,t)=>e.some(e=>t.some(t=>t.endsWith("/*")?e.startsWith(t.slice(0,-1)):e===t));var H=e=>new Map(e.allow.map(e=>[S(e.file,e.kind),e.count]));function X(e,t){return e.kinds.filter(e=>t.kinds.includes(e))}var V=(e,t,n)=>{if("kit-dep"===n)return` (${e.kitDeps.join(", ")})`;const i=e.hits.get(t)?.[n]??[];if(0===i.length)return"";const o=i.slice(0,12).join(", ");return` (line${1===i.length?"":"s"} ${o}${i.length>12?", …":""})`};function Q(e,t,n){const i=H(e),o=new Map;for(const[e,s]of t.counts){const{kind:t}=j(e);if(!l(t)||!n.includes(t))continue;const r=s-(i.get(e)??0);r>0&&o.set(e,r)}return{kinds:a.filter(e=>n.includes(e)),counts:o}}function Y(e,t){let n=0;for(const i of new Set([...e.keys(),...t.keys()]))(e.get(i)??0)!==(t.get(i)??0)&&(n+=1);return n}var Z="\n// <button> in a comment is not a button\n/* nor is <input title=\"x\"> in this one, or dark:bg-black, or #fff */\nimport { createPortal } from 'react-dom';\nimport { Dialog } from '@headlessui/react';\nimport { TrashIcon } from '@heroicons/react/24/outline';\nimport type { Icon } from 'lucide-react';\nimport { Button, confirm } from 'efficient-shell';\nexport { Slot } from '@radix-ui/react-slot';\nexport { CheckIcon } from '@radix-ui/react-icons';\n\nconst a = <button title=\"Says what it does\">x</button>;\nconst b = <input type=\"range\" />;\nconst c = <input type=\"text\" />;\nconst c2 = <input type={\"hidden\"} name=\"csrf\" />;\nconst c3 = <input type=\"hidden\" />;\nconst c4 = <input type={kind} />;\nconst d = <select />;\nconst d2 = <textarea />;\nconst e = <div role=\"dialog\" />;\nconst e2 = <dialog open />;\nconst e3 = <section role={'alertdialog'} />;\nconst f = <iframe title=\"Preview\" />;\nconst f2 = <object title=\"Chart\" />;\nconst g = <Button title=\"a prop, not a tooltip\" role=\"dialog\" />;\nconst g2 = (\n <button\n type=\"button\"\n title={hint}\n >\n y\n </button>\n);\nconst h = ReactDOM.createPortal(a, document.body);\nconst i = createPortal(a, document.body);\n\nasync function leave() {\n if (window.confirm('Sure?')) return;\n globalThis.alert('No');\n alert('native: nothing binds the name');\n prompt('native too');\n await confirm('the shell: the import binds it');\n record.confirm('a method, not the popup');\n}\n\nconst j = <div className=\"bg-white dark:bg-black dark:hover:text-white is-dark:no\" />;\nconst k = clsx('text-gray-900', on && 'dark:text-gray-100');\nconst l = <span style={{ color: '#fff', background: \"#12ab34\" }} className={`border-[#0a0b0c80] ${x}`} />;\nconst m = <a href=\"#faded\" id=\"#bad\" key=\"#abc\" to=\"#face\">skip</a>;\nconst n = <label htmlFor={'#dead'}>skip</label>;\nconst o = <span>&#1234; and BG#00340 and #12345 and #added are not colours</span>;\nconst p = 'entity &#x1f; ref BG#00340';\nconst q = <use xlinkHref=\"#abc\" fill=\"url(#fed)\" />;\nconst t = <div className=\"rounded-[4px] rounded-t-[0.5rem] hover:rounded-[2px] rounded-lg rounded-(--radius-card) rounded-[inherit] rounded-[var(--r)]\" />;\nconst u = <div style={{ borderRadius: 6, borderTopLeftRadius: '3px', borderBottomRightRadius: '50%', borderEndEndRadius: 'var(--radius-card)' }} />;\nconst v = <i style={{ borderRadius: 9999 }} />;\nconst r = lazy(() => import('@mui/material'));\nconst s = require('react-select');\n",ee={button:2,input:2,range:1,textarea:1,select:1,dialog:3,title:2,portal:2,native:4,dark:3,hex:3,radius:5,kit:4,icon:3},te={kit:1,dark:1,portal:1,radius:2},ne=e=>a.filter(t=>e[t]).map(t=>`${t} ${e[t]}`).join(", ")||"nothing";var ie="ui-kit.config.json",oe="ui-kit.baseline.json",se="efficient-shell-ui-check",re=`${se}: every surface a person operates takes its UI from efficient-shell (harness UI-24).\n\n ${se} check this repository against ${oe}\n ${se} --print print today's counts as a baseline, and change nothing\n ${se} --summary print totals per kind and per folder, as Markdown\n ${se} --json print the result as JSON\n ${se} --update lower the lines whose counts fell, and delete the ones at zero\n ${se} --update --allow-move also follow a renamed or split file (no total may rise)\n ${se} --init write the first ${oe}\n ${se} --init --kind <kind> take the baseline for a kind just added to "kinds"\n ${se} --no-base do not compare with the pull request's base branch\n\nKinds: ${a.join(", ")}\nReads ${ie} in the current directory.`;var ae=(e,t)=>`${e} ${t}${1===e?"":"s"}`,le=(e,t)=>{const n=M(e);return t.map(e=>`${e} ${n[e]??0}`).join(" · ")};process.exitCode=function(e,t){const r=function(e){const t={print:!1,summary:!1,json:!1,update:!1,allowMove:!1,init:!1,noBase:!1,help:!1,version:!1,kinds:[]};for(let n=0;n<e.length;n++){const i=e[n];if("--print"===i)t.print=!0;else if("--summary"===i)t.summary=!0;else if("--json"===i)t.json=!0;else if("--update"===i)t.update=!0;else if("--allow-move"===i)t.allowMove=!0;else if("--init"===i)t.init=!0;else if("--no-base"===i)t.noBase=!0;else if("--help"===i||"-h"===i)t.help=!0;else if("--version"===i||"-v"===i)t.version=!0;else if("--kind"===i){const i=e[++n];if(!i)return"--kind needs a kind after it";t.kinds.push(...i.split(","))}else{if(!i.startsWith("--kind="))return`unknown argument "${i}"`;t.kinds.push(...i.slice(7).split(","))}}return t.allowMove&&!t.update?"--allow-move goes with --update":t.kinds.length&&!t.init?"--kind goes with --init":[t.print,t.summary,t.update,t.init].filter(Boolean).length>1?"choose one of --print, --summary, --update and --init":t}(e);if("string"==typeof r)return t.err(`${se}: ${r}\n\n${re}`),2;if(r.help)return t.out(re),0;if(r.version)return t.out(t.version),0;const d=e=>(r.json?t.out(JSON.stringify({tool:se,version:t.version,ok:!1,failures:[e]},null,2)):t.err(`${se}: ${e}`),1),u=n(t.cwd,ie);if(!i(u))return d(`no ${ie} in ${t.cwd}. Run it from the repository root; the harness has the template.`);let h,m;try{h=function(e,t="ui-kit.config.json"){const n=[],i=e=>{n.push(e)},o=(e,t,{required:n=!1}={})=>{if(void 0===e&&!n)return[];if(!Array.isArray(e)||e.some(e=>"string"!=typeof e||""===e))return i(`${t} must be a list of non-empty strings`),[];n&&0===e.length&&i(`${t} must name at least one entry`);for(const n of e)(n.startsWith("/")||n.startsWith("./")||n.includes("\\")||n.split("/").includes(".."))&&i(`${t}: "${n}" must be a path from the repository root, written with / (no ./, .. or \\)`);return e},s=(e,t)=>"string"!=typeof e||e.trim().length<10?(i(`${t} needs a "reason" a reviewer can read (a sentence, not a word)`),""):e,r=(e,t)=>void 0===e?[]:!Array.isArray(e)||e.some(e=>!D(e))?(i(`${t} must be a list of objects`),[]):e;if(!D(e))throw new O(`${t}: must be a JSON object`);for(const t of Object.keys(e))N.has(t)||i(`unknown key "${t}"`);1!==e.schema&&i("number"==typeof e.schema&&e.schema>1?`"schema": ${e.schema} is newer than this efficient-shell reads (1); upgrade efficient-shell`:'"schema" must be 1');const c=[];if(Array.isArray(e.kinds)&&0!==e.kinds.length)for(const t of e.kinds)l(t)?c.includes(t)?i(`"kinds": "${t}" is listed twice`):c.push(t):i(`"kinds": unknown kind ${JSON.stringify(t)} (this efficient-shell knows: ${a.join(", ")})`);else i(`"kinds" must list the kinds this repository checks, from: ${a.join(", ")}`);const d=o(e.include,'"include"'),u=o(e.exclude,'"exclude"'),f=r(e.includeImporting,'"includeImporting"').map((e,t)=>({files:o(e.files,`"includeImporting"[${t}].files`,{required:!0}),modules:o(e.modules,`"includeImporting"[${t}].modules`,{required:!0}),reason:s(e.reason,`"includeImporting"[${t}]`)}));0===d.length&&0===f.length&&i('"include" must name the files that are operator UI (for example ["src/**/*.tsx"])');const h=r(e.output,'"output"').map((e,t)=>({files:o(e.files,`"output"[${t}].files`,{required:!0}),reason:s(e.reason,`"output"[${t}]`)})),p=[],m=new Set;if(r(e.allow,'"allow"').forEach((e,t)=>{const n=`"allow"[${t}]`,[r]=o([e.file],`${n}.file`),d=s(e.reason,n);if(!l(e.kind))return void i(`${n}.kind must be one of: ${a.join(", ")}`);if(c.includes(e.kind)||i(`${n}: kind "${e.kind}" is not in "kinds"`),"number"!=typeof e.count||!Number.isInteger(e.count)||e.count<1)return void i(`${n}.count must be a whole number, 1 or more`);if(!r)return;const u=`${r}:${e.kind}`;m.has(u)&&i(`${n}: ${r} already has an allow entry for "${e.kind}"`),m.add(u),p.push({file:r,kind:e.kind,count:e.count,reason:d})}),n.length)throw new O(`${t}:\n - ${n.join("\n - ")}`);return{schema:1,kinds:a.filter(e=>c.includes(e)),include:d,exclude:u,includeImporting:f,output:h,allow:p}}(JSON.parse(o(u,"utf8")),ie)}catch(e){return d(e instanceof O?e.message:`${ie} is not valid JSON: ${e.message}`)}try{m=t.loadTypeScript()}catch{return d('this check reads the TypeScript AST and found no "typescript" package here. Install it as a devDependency.')}const g=function(e){const t=[],n=a.filter(e=>"kit-dep"!==e),i=[["fixture.tsx",Z,ee],["fixture.ts","\nimport { toast } from 'sonner';\nexport const tone = { warn: '#f59e0b' };\nexport const cls = 'ring-1 dark:ring-white rounded-[3px]';\nexport const box = { borderRadius: '0.25rem', radius: 4 };\nexport function ask(confirm: (message: string) => boolean) {\n return confirm('a parameter binds the name');\n}\nexport const mount = (node: unknown) => ReactDOM.createPortal(node, document.body);\n",te]];for(const[o,s,r]of i){const i=K(z(e,o,s,n));n.some(e=>(i[e]??0)!==(r[e]??0))&&t.push(`${o}: read ${ne(i)}; it holds ${ne(r)}`)}const o=K(z(e,"fixture.tsx",Z,["button"]));return"button"!==Object.keys(o).join()&&t.push(`asked for button alone, the reader reported ${ne(o)}`),t}(m);if(g.length)return d(`the reader misread its own fixtures with typescript ${m.version}, so nothing it says about this repository can be trusted:\n - `+g.join("\n - "));const $=function(e,t,s){const r=[],a=k(s.exclude),l=k(s.output.flatMap(e=>e.files)),c=new Map,d=e=>{let i=c.get(e);return void 0===i&&c.set(e,i=o(n(t,e),"utf8")),i},u=(e,n)=>{for(const i of e)0===y(t,[i]).length&&r.push(`${n}: "${i}" matches no file. Delete the line, or fix the path.`)};u(s.include,'"include"'),s.output.forEach((e,t)=>u(e.files,`"output"[${t}]`)),s.includeImporting.forEach((e,t)=>u(e.files,`"includeImporting"[${t}]`));const h=new Set,m=e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!a(e)&&!l(e);for(const e of y(t,s.include))m(e)&&h.add(e);for(const n of s.includeImporting)for(const i of y(t,n.files))m(i)&&!h.has(i)&&_(G(e,i,d(i)),n.modules)&&h.add(i);const g=[...h].sort(),$=s.kinds.filter(e=>"kit-dep"!==e),w=new Map,b=new Map,x=new Set;for(const t of g){const n=z(e,t,d(t),$,x);let i=!1;for(const e of $){const o=n[e]?.length??0;o&&(b.set(S(t,e),o),i=!0)}i&&w.set(t,n)}let v=[],j=[];if(s.kinds.includes("kit-dep")){const e=n(t,R);if(i(e)){const t=JSON.parse(o(e,"utf8")),n=["dependencies","peerDependencies","optionalDependencies"].flatMap(e=>Object.keys(t[e]??{})),i=new Set([...x].flatMap(e=>f[e]??[])),s=[...new Set(n)].filter(e=>null!==p(e)).sort();v=s.filter(e=>!i.has(e)),j=s.filter(e=>i.has(e)),v.length&&b.set(S(R,"kit-dep"),v.length)}else r.push(`"kinds" includes "kit-dep", and there is no ${R} here to read.`)}for(const e of s.allow)("kit-dep"===e.kind?e.file===R:h.has(e.file))||r.push(`"allow": ${e.file} (${e.kind}) is not a file this check reads. Delete the entry, or fix the path.`);return{files:g,hits:w,counts:b,kitDeps:v,shellPeers:j,problems:r}}(m,t.cwd,h);if(0===$.files.length)return d(`read no files. "include" in ${ie} matches nothing, so a pass would mean nothing.`);const w=n(t.cwd,oe),b=r.json,x=e=>{b||t.out(e)};if(r.print)return t.out(E(Q(h,$,h.kinds)).trimEnd()),0;if(r.summary){for(const e of function(e,t){const n=new Map,i=new Map;for(const[e,o]of t.counts){const{file:t,kind:s}=j(e);if(!l(s))continue;const r=n.get(s)??{count:0,files:new Set};r.count+=o,r.files.add(t),n.set(s,r);const a=t.split("/"),c=a.length>2?a.slice(0,2).join("/"):2===a.length?a[0]:".",d=i.get(c)??{};d[s]=(d[s]??0)+o,i.set(c,d)}const o=e.kinds.filter(e=>n.has(e)),s=[`**UI kit check (harness UI-24):** ${new Set([...t.counts.keys()].map(e=>j(e).file)).size} of ${ae(t.files.length,"file")} still draw UI of their own.`,"","| Kind | Count | Files | The shell has |","|---|---:|---:|---|",...e.kinds.map(e=>{const t=n.get(e);return`| \`${e}\` | ${t?.count??0} | ${t?.files.size??0} | ${c[e].instead} |`})];if(o.length&&i.size){const e=e=>o.reduce((t,n)=>t+(e[n]??0),0),t=[...i].sort((t,n)=>e(n[1])-e(t[1])||(t[0]<n[0]?-1:1));s.push("",`| Folder | ${o.map(e=>`\`${e}\``).join(" | ")} | Total |`,`|---|${o.map(()=>"---:").join("|")}|---:|`,...t.map(([t,n])=>`| \`${t}\` | ${o.map(e=>n[e]??0).join(" | ")} | ${e(n)} |`))}return s}(h,$))t.out(e);return 0}let I=null;if(i(w))try{I=A(o(w,"utf8"),oe)}catch(e){return d(e instanceof v?e.message:String(e))}if(r.init){const e=r.kinds.filter(e=>!l(e)||!h.kinds.includes(e));if(e.length)return d(`--kind ${e.join(", ")}: not in "kinds" in ${ie}. Add it there first.`);const t=r.kinds;if(I){if(0===t.length)return d(`${oe} already exists, and --init would overwrite what it holds. It is for the adoption pull request only. To start checking a kind, add it to "kinds" and run --init --kind <kind>.`);const e=t.filter(e=>I.kinds.includes(e));if(e.length)return d(`the baseline was already taken for ${e.join(", ")}. Its lines only go down; use --update.`);const n=Q(h,$,t);I={kinds:[...I.kinds,...t],counts:new Map([...I.counts,...n.counts])}}else{if(t.length)return d(`there is no ${oe} yet. Run --init on its own first.`);I=Q(h,$,h.kinds)}s(w,E(I)),x(`${se}: wrote ${oe} (${ae(I.counts.size,"line")}: ${le(I.counts,I.kinds)})`)}if(!I)return d(`no ${oe}. This repository has not adopted the check yet: run ${se} --init, and commit the file.`);if(r.update){const e=function(e,t,n,{allowMove:i=!1}={}){const o=X(e,t),s=Q(e,n,o),r=new Map([...t.counts].filter(([e])=>o.includes(j(e).kind)));if(i){const e=M(r),n=M(s.counts),i=o.filter(t=>(n[t]??0)>(e[t]??0)).map(t=>`${t}: ${n[t]??0} across the repository, and the baseline holds ${e[t]??0}`);return i.length?{baseline:t,lowered:0,refused:i}:{baseline:s,lowered:Y(r,s.counts),refused:[]}}const a=new Map;for(const[e,t]of r){const n=Math.min(t,s.counts.get(e)??0);n>0&&a.set(e,n)}return{baseline:{kinds:o,counts:a},lowered:Y(r,a),refused:[]}}(h,I,$,{allowMove:r.allowMove});if(e.refused.length)return d(`--allow-move follows code that moved, and this is more of it than before:\n - ${e.refused.join("\n - ")}\nNothing was written.`);I=e.baseline,s(w,E(I)),x(`${se}: ${e.lowered?`changed ${ae(e.lowered,"line")} in`:"nothing to change in"} ${oe}`)}const L=function(e,t,n){const i=[],o=[],s=[...n.problems],r=H(e),a=new Set(X(e,t)),d=e.kinds.filter(e=>!t.kinds.includes(e));d.length&&s.push(`"kinds" names ${d.map(e=>`"${e}"`).join(", ")}, and the baseline was never taken for ${1===d.length?"it":"them"}. Run: efficient-shell-ui-check --init ${d.map(e=>`--kind ${e}`).join(" ")}`);const u=t.kinds.filter(t=>!e.kinds.includes(t));u.length&&o.push(`the baseline still carries ${u.map(e=>`"${e}"`).join(", ")}, which "kinds" no longer names`);const f=new Set([...n.counts.keys(),...t.counts.keys(),...r.keys()]);for(const e of[...f].sort(T)){const{file:d,kind:u}=j(e);if(!l(u)||!a.has(u))continue;const f=n.counts.get(e)??0,h=r.get(e)??0,p=t.counts.get(e)??0;f>h+p?i.push(`${d}: ${u} ${f}, and its line allows ${h+p}${V(n,d,u)}. ${c[u].counts} is counted; use ${c[u].instead}.`):f<h?s.push(`${d}: ${u} ${f}, and "allow" in ui-kit.config.json says ${h}. ${0===f?"Delete the entry":`Lower its count to ${f}`}: an exception does not outlive what it excused.`):f<h+p&&o.push(`${d}: ${u} ${f}, and its line says ${h+p}`)}return{grown:i,shrunk:o,other:s,updateFixes:0===i.length&&0===s.length&&o.length>0}}(h,I,$),F=r.noBase?{problems:[],note:""}:function(e,t,n){const i=e.env.GITHUB_BASE_REF;if(!i)return{problems:[],note:""};const o=e.git(["rev-parse","--show-prefix"]);if(null===o)return{problems:[],note:"not a git checkout; the base branch was not compared"};const s=`origin/${i}`;if(null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])&&(e.git(["fetch","--no-tags","--depth=1","origin",`+refs/heads/${i}:refs/remotes/origin/${i}`]),null===e.git(["rev-parse","--verify","--quiet",`${s}^{commit}`])))return{problems:[],note:`${s} could not be fetched; the base branch was not compared`};const r=e.git(["show",`${s}:${o.trim()}${oe}`]);if(null===r)return{problems:[],note:`${s} has no ${oe} yet (adoption)`};let a;try{a=A(r,`${s}:${oe}`)}catch{return{problems:[],note:`${s}'s ${oe} could not be read; the base branch was not compared`}}const l=M(a.counts),d=M(t.counts);return{problems:n.filter(e=>a.kinds.includes(e)&&(d[e]??0)>(l[e]??0)).map(e=>`${oe} holds ${d[e]??0} of "${e}", and ${s} holds ${l[e]??0}. The baseline only goes down: use ${c[e].instead}. A count that is meant to stay goes in "allow" in ${ie}, with its reason.`),note:`compared with ${s}`}}(t,I,h.kinds),J=h.kinds.filter(e=>I.kinds.includes(e)),P=`${se} --update`,U=[...L.other,...L.grown,...L.shrunk.map(e=>`${e}. Run: ${P}`),...F.problems],B=0===U.length;if(r.json){const e=new Map(h.allow.map(e=>[`${e.file}:${e.kind}`,e.count]));return t.out(JSON.stringify({tool:se,version:t.version,ok:B,schema:h.schema,kinds:h.kinds,files:$.files.length,counts:M($.counts),baseline:M(I.counts),allowed:M(e),kitDeps:$.kitDeps,shellPeers:$.shellPeers,failures:U},null,2)),B?0:1}t.out(`UI kit check (harness UI-24), efficient-shell ${t.version}\n`);const W=(e,n,i="")=>{if(0===n.length)return t.out(` ok ${e}`);t.err(` FAIL ${e}`);for(const e of n)t.err(` ${e}`);i&&t.err(` ${i}`)};t.out(` ok the reader reads its own fixtures (typescript ${m.version})`),t.out(` ok read ${ae($.files.length,"file")}`),W(`${ie} and ${oe} describe this repository`,L.other),W("no file draws more of its own UI than its line allows",L.grown),W("every line is exact: a count that fell is a line to lower",L.shrunk,`Run: ${P}${L.updateFixes?"":" (after the failures above are fixed)"}`),F.note&&W(`the baseline is no higher than the base branch (${F.note})`,F.problems);const C=new Set([...$.counts.keys()].map(e=>j(e).file));return t.out(` ok PROGRESS: ${C.size} of ${ae($.files.length,"file")} still draw UI of their own: `+le($.counts,J)),t.out(""),B?t.out("UI kit check: ok"):t.err(`UI kit check: FAILED (${ae(U.length,"problem")})`),B?0:1}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:function(){for(const e of[n(process.cwd(),"package.json"),import.meta.url])try{return t(e)("typescript")}catch{}throw new Error("typescript is not installed")},git:function(t){try{return e("git",t,{cwd:process.cwd(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:6e4,maxBuffer:67108864})}catch{return null}},version:"5.1.0"});