efficient-shell 4.163.0 → 4.165.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 (59) hide show
  1. package/README.md +115 -6
  2. package/dist/{Browser-2I27OQFE.js → Browser-ZX5GWPSM.js} +12 -12
  3. package/dist/{Calculator-2EB2RAT7.js → Calculator-NZH4FVRW.js} +23 -23
  4. package/dist/ConfirmDialog-WEVZTFLU.js +1 -0
  5. package/dist/{CurrencyConverter-4EEIPAVX.js → CurrencyConverter-7OPRFA5D.js} +7 -7
  6. package/dist/{Documents-24YAA5UU.js → Documents-QV63346J.js} +15 -15
  7. package/dist/{Files-BU7FY2VD.js → Files-BU5V56YF.js} +24 -24
  8. package/dist/{Notepad-3D4L3K5W.js → Notepad-KZIJ5ZTF.js} +10 -10
  9. package/dist/PdfViewer-S2B2DZYB.js +1 -0
  10. package/dist/{PomodoroTimer-B4OPUTJL.js → PomodoroTimer-FJV6MGE3.js} +25 -25
  11. package/dist/{Preview-VZSNH76G.js → Preview-PMQKG6FH.js} +13 -13
  12. package/dist/{Sidebar-7AY5WJZC.js → Sidebar-E6GLVCJL.js} +26 -26
  13. package/dist/{Spreadsheet-TAJ24BQS.js → Spreadsheet-DE5HPVE2.js} +14 -14
  14. package/dist/{Stock-VEPDDIMJ.js → Stock-SSNUY34E.js} +4 -4
  15. package/dist/{Weather-KGZF4DDW.js → Weather-T5WM66B2.js} +21 -21
  16. package/dist/{WorldClock-UGADOCFW.js → WorldClock-C3GT27AV.js} +7 -7
  17. package/dist/apps/index.js +1 -1
  18. package/dist/brand.css +1 -1
  19. package/dist/{chunk-J5HNLMGZ.js → chunk-3U47BTEV.js} +9 -9
  20. package/dist/{chunk-GSBX7KIS.js → chunk-4P3IWZUC.js} +13 -13
  21. package/dist/{chunk-PH3PRIFP.js → chunk-4UCRT4ST.js} +5 -5
  22. package/dist/{chunk-WURTAA2S.js → chunk-5J2TKKGH.js} +1 -1
  23. package/dist/{chunk-6A7BN7EN.js → chunk-A7Q4BCPI.js} +4 -4
  24. package/dist/{chunk-4GOHPACN.js → chunk-D7EJSASN.js} +1 -1
  25. package/dist/{chunk-2FZGALCU.js → chunk-DJ6UVHAZ.js} +8 -8
  26. package/dist/chunk-ELSUXC3N.js +1 -0
  27. package/dist/{chunk-TZ2EFTST.js → chunk-FGPWGHNT.js} +9 -9
  28. package/dist/{chunk-UMOVLVTC.js → chunk-FZRQBHTK.js} +1 -1
  29. package/dist/{chunk-E4JWTNG5.js → chunk-KRTZFHYW.js} +15 -15
  30. package/dist/{chunk-NLASNJNY.js → chunk-KSSAVLO7.js} +1 -1
  31. package/dist/chunk-NCQLGQYR.js +1 -0
  32. package/dist/{chunk-IJ3V2YOS.js → chunk-PLX2N4N6.js} +9 -9
  33. package/dist/{chunk-MAMJHPFN.js → chunk-QTPVA26D.js} +1 -1
  34. package/dist/{chunk-ZAJPQAGP.js → chunk-QZG72OVX.js} +1 -1
  35. package/dist/{chunk-PX435JG4.js → chunk-RKEHUV7U.js} +1 -1
  36. package/dist/chunk-SHVGZW2J.js +1 -0
  37. package/dist/chunk-SQ7BPUZG.js +9 -0
  38. package/dist/chunk-VDL2RLZG.js +10 -0
  39. package/dist/chunk-XYITV4EC.js +983 -0
  40. package/dist/{chunk-FWY5IRGL.js → chunk-YWXYBJ5Y.js} +2 -2
  41. package/dist/{chunk-TBM3ZIAN.js → chunk-ZLJCWBDF.js} +61 -61
  42. package/dist/file-intake/index.js +1 -1
  43. package/dist/{index-JQXMH_km.d.ts → index-DRkpyISn.d.ts} +239 -16
  44. package/dist/index.d.ts +11 -4
  45. package/dist/index.js +92 -92
  46. package/dist/map/index.js +4 -4
  47. package/dist/page-tabs/index.js +4 -4
  48. package/dist/pdf/index.js +1 -1
  49. package/dist/ui/index.d.ts +1 -1
  50. package/dist/ui/index.js +1 -1
  51. package/package.json +1 -1
  52. package/dist/ConfirmDialog-4LZXI6FM.js +0 -1
  53. package/dist/PdfViewer-5VBKCPCM.js +0 -1
  54. package/dist/chunk-A6O4Y63A.js +0 -1
  55. package/dist/chunk-L7ZMDZAB.js +0 -9
  56. package/dist/chunk-OSJ3ADF2.js +0 -1
  57. package/dist/chunk-QRJ2ERKR.js +0 -9
  58. package/dist/chunk-VWTYRICQ.js +0 -963
  59. package/dist/chunk-YJX2IWHB.js +0 -1
package/README.md CHANGED
@@ -563,6 +563,25 @@ losing focus closes it too. `autoFocus={false}` leaves focus where it was, and
563
563
  the first arrow key moves in. The shell-wide menu opens this way, so a text
564
564
  selection that Copy acts on is not disturbed.
565
565
 
566
+ **Checked items.** A `PopupMenuItem` with `checked` (true or false) is a state
567
+ the item turns on or off. It is a `menuitemcheckbox` by default and a
568
+ `menuitemradio` with `role="menuitemradio"`, and it says `aria-checked`, in any
569
+ menu: `ContextMenu`, a plain `PopupMenu` or a `PopupSubmenu`. A check box draws
570
+ a box with the kit's tick in it. A radio draws the tick alone, in a column the
571
+ unchecked rows keep empty, so the labels of a set line up. These are
572
+ `DropdownMenu`'s marks. Inside a submenu a check box toggles and leaves the
573
+ menu open; a radio closes it, as a plain item does.
574
+
575
+ ```tsx
576
+ <PopupSubmenu label="Select layer">
577
+ {layers.map(l => (
578
+ <PopupMenuItem key={l.id} role="menuitemradio" checked={l.id === current} onClick={() => select(l.id)}>
579
+ {l.name}
580
+ </PopupMenuItem>
581
+ ))}
582
+ </PopupSubmenu>
583
+ ```
584
+
566
585
  ### Editor controls — `Slider`, `ColorPicker`, `Tree`, `IconRail`, `ResizeHandle`
567
586
 
568
587
  These were folded in from `efficient-easel` under harness UI-24, because the
@@ -582,10 +601,14 @@ The range is held to `min`/`max`. A typed number is held to `inputMin`/`inputMax
582
601
  end. `step` (default 1) is the range's step and the box's ArrowUp/ArrowDown.
583
602
  `precision` (default: the decimals in `step`) rounds a value. A number typed on
584
603
  its way somewhere else ("2" of "25" in a 10–100 box) is not written until it is
585
- in bounds, and blur clamps it. `emptyLabel` lets the value be `null`: the box
586
- shows the word, and emptying it writes `null`. Without `emptyLabel`, an emptied
587
- box goes back to the value. `valueText` sets what the range announces, and
588
- `showInput={false}` draws the range alone.
604
+ in bounds. Enter or blur commits it: snapped to `step` counted from the box's
605
+ lower bound (`inputMin`, default `min`), then clamped. Escape puts back the
606
+ value from before the box was entered, including numbers written live while
607
+ typing. These are `InputNumber`'s keys (`snap`, `allowEmpty`), not a copy.
608
+ `emptyLabel` lets the value be `null`: the box shows the word, and emptying it
609
+ writes `null`. Without `emptyLabel`, an emptied box goes back to the value.
610
+ `valueText` sets what the range announces, and `showInput={false}` draws the
611
+ range alone.
589
612
 
590
613
  **`ColorPicker`** is a swatch that opens a saturation/brightness square, a hue
591
614
  strip, a hex box and optional presets, in the kit's `Popover`. That means the
@@ -613,8 +636,8 @@ Escape). `ColorSwatch` is a button painted with a colour (`selected` sets
613
636
  `aria-pressed`). Beside them are `colorSwatchClasses`, `colorFill`, `HexInput`,
614
637
  and the maths: `parseHexColor`, `hexToHsv`, `hsvToHex`.
615
638
 
616
- **`Tree`**, **`TreeRow`**, **`TreeGroup`**, **`TreeGroupLabel`** and
617
- **`TreeEmptySlot`** draw a layers panel or an outline. They follow the WAI-ARIA
639
+ **`Tree`**, **`TreeRow`**, **`TreeGroup`**, **`TreeGroupLabel`**,
640
+ **`TreeEmptySlot`** and **`TreeSeam`** draw a layers panel or an outline. They follow the WAI-ARIA
618
641
  tree pattern.
619
642
 
620
643
  ```tsx
@@ -642,6 +665,35 @@ and `actionsPinned` keeps the actions showing at rest. `preview` adds quieter
642
665
  text after the name, and `rowProps` takes the host's drag handlers. The tree
643
666
  holds no state: everything goes through `onSelect`/`onToggle`.
644
667
 
668
+ Moving rows is drawn here and decided by the host:
669
+
670
+ ```tsx
671
+ <Tree aria-label="Layers">
672
+ {rows.map((row, i) => (
673
+ <Fragment key={row.id}>
674
+ <TreeRow label={row.name} draggable onMove={to => move(row.id, to)}
675
+ rowProps={{ draggable: true, onDragStart: …, onDragOver: … }} drop={dropAt(row.id)} />
676
+ <TreeSeam onInsert={() => insertAt(i + 1)} drop={seamDrop === i + 1} seamProps={{ onDrop: … }} />
677
+ </Fragment>
678
+ ))}
679
+ </Tree>
680
+ ```
681
+
682
+ `draggable` shows a grip (six dots) in the row's left padding while the row is
683
+ hovered or focused, with "Drag to move" in a `Tooltip` (`dragHint` to change
684
+ it), and the grab cursor. It draws only: the DOM `draggable` attribute and the
685
+ drag handlers go on `rowProps`. `onMove(to)` is called with `'up'` on
686
+ Alt+ArrowUp and `'down'` on Alt+ArrowDown. The row then carries
687
+ `aria-keyshortcuts="Alt+ArrowUp Alt+ArrowDown"` and a description that says
688
+ so. A modified arrow never walks the tree. `TreeSeam` is the gap between two
689
+ rows, as a place. A drop over it lands there (`drop` shows the line,
690
+ `seamProps` takes the handlers), and with `onInsert` a "+" shows on hover or
691
+ focus, named "Insert here" (`label`) and inserting at that place. It hands back
692
+ the height of the gap it sits in, so a list reads the same with seams or
693
+ without. Put one in every gap or in none, and use `TreeEmptySlot` for an empty
694
+ list. The words come from the catalog: `tree.dragHint`, `tree.moveHint` and
695
+ `tree.insertHere`.
696
+
645
697
  **`IconRail`** and **`IconRailButton`** make a slim strip of icon toggles
646
698
  (`role="toolbar"`, `orientation="vertical" | "horizontal"`). A button with a
647
699
  boolean `active` is a toggle (`aria-pressed`). Leave `active` out for an action
@@ -650,6 +702,27 @@ disabled buttons), and Home/End jump to the ends. Each button's `label` is its
650
702
  accessible name and its `Tooltip`, never `title`. `badge` takes a count or
651
703
  `true` for a dot.
652
704
 
705
+ `labels="beside"` or `labels="below"` draws each button's word with its glyph.
706
+ The word is display text: `label` stays the name. With `labelsFit` the words
707
+ stay only while they fit the rail's parent, and the rail measures to decide.
708
+ It shows every word while they all fit, then only the word of the toggle that
709
+ is on, then none. It measures again as the parent resizes, the labels or the
710
+ chosen toggle change, and web fonts load. The room is the parent's content
711
+ width, so put the rail in a box whose width the rail does not set (a column, a
712
+ slot of the top bar). On a server, and until it is measured, a fitted rail
713
+ draws no words: icons alone always fit. `onLabelsShown(shown)` reports `all`,
714
+ `chosen` or `none` when that changes. Without `labels` the rail is the
715
+ icon-only markup it always was.
716
+
717
+ ```tsx
718
+ <div style={{ width: panelWidth }}>
719
+ <IconRail aria-label="Editor panels" orientation="horizontal" labels="beside" labelsFit>
720
+ <IconRailButton label="Layers" icon={<LayersIcon />} active={panel === 'layers'} onClick={…} />
721
+ …
722
+ </IconRail>
723
+ </div>
724
+ ```
725
+
653
726
  **`ResizeHandle`** is the grip a side panel resizes by, and `SidebarLayout`
654
727
  draws its edge with it.
655
728
 
@@ -672,6 +745,42 @@ width after mount and keeps it once a drag settles. Its hint is a `Tooltip`.
672
745
  `renderOption(option, { selected })` to draw each option, for example each face
673
746
  in itself. The `label` still names, filters and fills the field.
674
747
 
748
+ **Gaps the editors found in the form kit** (efficient-easel#199, harness UI-24),
749
+ now in the kit itself:
750
+
751
+ - **`Segmented`**: the chosen chip has a 1px `--ink-faint` ring, 3:1 or more
752
+ against its track in light and dark, so a strip of icons shows which option
753
+ is chosen (WCAG 1.4.11). An option's `title` is shown in the kit's `Tooltip`,
754
+ not the native attribute. A radio option also gets it as its description.
755
+ - **`Input`, `Textarea`**: `readOnly` draws the read-only ground (`bg-gray-50`,
756
+ `--surface-sunken` in dark). The border and focus ring do not change.
757
+ `inputClasses({ readOnly: true })` gives the same look to anything else.
758
+ - **`Select`**: the open listbox is named by `aria-labelledby`, `aria-label` or
759
+ the trigger. `options` may hold groups, `{ label, options }`. They are drawn
760
+ under a heading as `role="group"`, and the keys skip the headings; on touch
761
+ they are `<optgroup>`s. `multiple` takes `value: string[]` and
762
+ `onChange(string[])`. It checks each chosen option and stays open while
763
+ options are toggled. `renderOption(option, { selected, active })` draws a
764
+ row, with the same signature as `SearchableSelect`'s.
765
+ - **`SearchableSelect`**: `aria-label`, `aria-labelledby` and
766
+ `aria-describedby` go on the field. The open list is a named `listbox` of
767
+ `option`s, and ArrowUp/ArrowDown and Enter work it.
768
+ - **`InputNumber`**: `readOnly`. `placeholder` with `value={null}` is the empty
769
+ state ("Auto", or the inherited "16"). It is announced as the value, and the
770
+ first step starts from it when it is a number. Escape puts back the value
771
+ from before focus. Enter commits like blur, Shift+Arrow steps
772
+ `shiftStep` (default ten steps), and a comma is accepted as the decimal
773
+ separator. `steppers` adds two `IconButton` arrows with hold-to-repeat,
774
+ `snap` puts a committed number on the `step` grid from `min`, and
775
+ `allowEmpty={false}` puts an emptied field back to its value.
776
+ - **`IconButton`**: `aria-pressed` true draws the pressed look, the accent wash
777
+ and ink of an active `IconRailButton`. `iconButtonClasses({ pressed })` gives
778
+ the same look to a link.
779
+ - **`Tooltip`**: a press on the trigger closes it until the pointer leaves or
780
+ focus goes. It takes Escape only when no open popup, menu or dialog is drawn
781
+ above its trigger. An overlay opening closes it.
782
+ - **`CountBadge`**: `className` lands on the badge when it has no children.
783
+
675
784
  ## API reference
676
785
 
677
786
  All exports are named — `import { Modal, ... } from 'efficient-shell'`.
@@ -1,29 +1,29 @@
1
- import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-4GOHPACN.js";import"./chunk-A6O4Y63A.js";import{WindowTitle as r}from"./chunk-TBM3ZIAN.js";import"./chunk-6A7BN7EN.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-PH3PRIFP.js";import"./chunk-6KO2U66R.js";import{confirm as n}from"./chunk-E4JWTNG5.js";import"./chunk-L7ZMDZAB.js";import"./chunk-OSJ3ADF2.js";import"./chunk-MAIHBBWT.js";import"./chunk-YJX2IWHB.js";import"./chunk-D65T4H6J.js";import{useRef as a,useEffect as i,useState as s}from"react";import{jsxs as l,jsx as c,Fragment as m}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",u="react-os-shell:browser-homepage",h="https://en.wikipedia.org/wiki/Main_Page",p=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],g=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function b(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var k=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function f(){if("undefined"==typeof window)return p;try{const e=localStorage.getItem(d);if(!e)return p;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return p}function x(){return"undefined"==typeof window?h:localStorage.getItem(u)||h}function w(){const m=a(void 0);void 0===m.current&&(m.current=e()),i(()=>{null!=m.current&&t(m.current)},[]);const h=m.current?b(m.current.url):"",[p,g]=s(x),[k,w]=s(h||p),[N,L]=s(k),[j,C]=s([k]),[z,M]=s(0),[W,A]=s(0),[B,S]=s(f),[H,R]=s(!1),[D,E]=s(null),O=a(null),T=a(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(B))}catch{}},[B]);const I=e=>{const t=b(e);t&&(w(t),L(t),C(e=>{const o=e.slice(0,z+1);return o.push(t),o}),M(e=>e+1),R(!1))},P=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},U=()=>{const e=D?.trim();e?(S(t=>[...t,{label:e,url:k}]),E(null)):E(null)};i(()=>{if(null===D)return;O.current?.focus(),O.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||E(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==D]);const q=e=>{S(t=>t.filter((t,o)=>o!==e))},F=z>0,J=z<j.length-1,G=B.some(e=>e.url===k),V="p-1.5 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
1
+ import{peekBrowserStartUrl as e,claimBrowserStartUrl as t}from"./chunk-LWLCNQY7.js";import{AboutApp as o}from"./chunk-D7EJSASN.js";import"./chunk-SHVGZW2J.js";import{WindowTitle as r}from"./chunk-ZLJCWBDF.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-4UCRT4ST.js";import"./chunk-6KO2U66R.js";import{confirm as n}from"./chunk-KRTZFHYW.js";import"./chunk-VDL2RLZG.js";import"./chunk-ELSUXC3N.js";import"./chunk-MAIHBBWT.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useRef as a,useEffect as i,useState as s}from"react";import{jsxs as l,jsx as c,Fragment as m}from"react/jsx-runtime";var d="react-os-shell:browser-bookmarks",u="react-os-shell:browser-homepage",h="https://en.wikipedia.org/wiki/Main_Page",p=[{label:"Wikipedia",url:"https://en.wikipedia.org/wiki/Main_Page"},{label:"DevDocs",url:"https://devdocs.io"},{label:"Example",url:"https://example.com"}],g=new Set(["ac ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi","bj bm bn bo br bs bt bw by bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv","cw cx cy cz de dj dk dm do dz ec ee eg er es et eu fi fj fk fm fo fr ga gd","ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il","im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc","li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mm mn mo mp mq mr ms mt mu","mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl","pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sk sl sm sn","so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tr tt tv tw tz","ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw","com net org edu gov mil int info biz name pro app dev xyz online site tech","store shop cloud design digital agency studio media news blog live life","world today email systems solutions services software page link space host","press wiki team group works careers finance capital energy academy"].join(" ").split(" "));function b(e){let t=e.trim();return t?/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:function(e){const t=/^([\w-]+\.)+([a-z]{2,})(\/.*)?$/i.exec(e);return null!==t&&g.has(t[2].toLowerCase())}(t)?"https://"+t:"https://duckduckgo.com/?q="+encodeURIComponent(t):""}var k=["duckduckgo.com","developer.mozilla.org","google.com","gmail.com","youtube.com","facebook.com","instagram.com","whatsapp.com","twitter.com","x.com","github.com","gitlab.com","linkedin.com","reddit.com","pinterest.com","amazon.com","amazon.ca","amazon.co.uk","apple.com","icloud.com","microsoft.com","outlook.com","live.com","office.com","netflix.com","spotify.com","paypal.com","stripe.com","chat.openai.com","chatgpt.com","claude.ai"];function f(){if("undefined"==typeof window)return p;try{const e=localStorage.getItem(d);if(!e)return p;const t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>"string"==typeof e?.url))return t}catch{}return p}function x(){return"undefined"==typeof window?h:localStorage.getItem(u)||h}function w(){const m=a(void 0);void 0===m.current&&(m.current=e()),i(()=>{null!=m.current&&t(m.current)},[]);const h=m.current?b(m.current.url):"",[p,g]=s(x),[k,w]=s(h||p),[N,L]=s(k),[C,j]=s([k]),[z,M]=s(0),[S,W]=s(0),[R,B]=s(f),[H,A]=s(!1),[D,E]=s(null),T=a(null),U=a(null);i(()=>{try{localStorage.setItem(d,JSON.stringify(R))}catch{}},[R]);const I=e=>{const t=b(e);t&&(w(t),L(t),j(e=>{const o=e.slice(0,z+1);return o.push(t),o}),M(e=>e+1),A(!1))},O=()=>{"undefined"!=typeof window&&window.open(k,"_blank","noopener,noreferrer")},V=()=>{const e=D?.trim();e?(B(t=>[...t,{label:e,url:k}]),E(null)):E(null)};i(()=>{if(null===D)return;T.current?.focus(),T.current?.select();const e=e=>{const t=e.target;t?.closest("[data-bookmark-popover]")||E(null)},t=setTimeout(()=>document.addEventListener("mousedown",e),0);return()=>{clearTimeout(t),document.removeEventListener("mousedown",e)}},[null!==D]);const q=e=>{B(t=>t.filter((t,o)=>o!==e))},F=z>0,G=z<C.length-1,J=R.some(e=>e.url===k),P="p-1.5 rounded hover:bg-gray-200 transition-colors text-gray-600 disabled:opacity-30";/* @__PURE__ */
2
2
  return l("div",{className:"relative flex flex-col h-full bg-white",children:[
3
3
  /* @__PURE__ */c(r,{title:`Browser - ${v(k)}`}),
4
4
  /* @__PURE__ */c(o,{app:"browser"}),
5
5
  /* @__PURE__ */l("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-gray-200 bg-gray-50 shrink-0",children:[
6
- /* @__PURE__ */c("button",{onClick:()=>{if(z>0){const e=z-1;M(e),w(j[e]),L(j[e]),R(!1)}},disabled:!F,className:V,title:"Back",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}),
7
- /* @__PURE__ */c("button",{onClick:()=>{if(z<j.length-1){const e=z+1;M(e),w(j[e]),L(j[e]),R(!1)}},disabled:!J,className:V,title:"Forward",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}),
8
- /* @__PURE__ */c("button",{onClick:()=>A(e=>e+1),className:V,title:"Refresh",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992V4.356M2.985 19.644v-4.992h4.992M3.05 9.348a9 9 0 0114.85-3.36L21.015 9.348m0 5.304a9 9 0 01-14.85 3.36l-3.115-3.36"})})}),
9
- /* @__PURE__ */c("button",{onClick:()=>I(p),className:V,title:"Home",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0l8.954 8.955M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"})})}),
6
+ /* @__PURE__ */c("button",{onClick:()=>{if(z>0){const e=z-1;M(e),w(C[e]),L(C[e]),A(!1)}},disabled:!F,className:P,title:"Back",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}),
7
+ /* @__PURE__ */c("button",{onClick:()=>{if(z<C.length-1){const e=z+1;M(e),w(C[e]),L(C[e]),A(!1)}},disabled:!G,className:P,title:"Forward",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}),
8
+ /* @__PURE__ */c("button",{onClick:()=>W(e=>e+1),className:P,title:"Refresh",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992V4.356M2.985 19.644v-4.992h4.992M3.05 9.348a9 9 0 0114.85-3.36L21.015 9.348m0 5.304a9 9 0 01-14.85 3.36l-3.115-3.36"})})}),
9
+ /* @__PURE__ */c("button",{onClick:()=>I(p),className:P,title:"Home",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12l8.954-8.955a1.5 1.5 0 012.122 0l8.954 8.955M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"})})}),
10
10
  /* @__PURE__ */c("form",{onSubmit:e=>{e.preventDefault(),I(N)},className:"flex-1 flex items-center mx-1",children:/* @__PURE__ */l("div",{className:"flex items-center w-full bg-white border border-gray-300 rounded focus-within:border-blue-400 focus-within:ring-1 focus-within:ring-blue-200",children:[
11
11
  /* @__PURE__ */c("span",{className:"px-2 text-gray-400 text-xs",children:k.startsWith("https://")?"🔒":"⚠️"}),
12
12
  /* @__PURE__ */c("input",{type:"text",value:N,onChange:e=>L(e.target.value),onFocus:e=>e.target.select(),className:"flex-1 px-1 py-1 text-sm bg-transparent outline-none font-mono",spellCheck:!1,placeholder:"Enter URL or search…"}),k!==N&&/* @__PURE__ */c("button",{type:"button",onClick:()=>L(k),className:"px-1.5 text-[10px] text-gray-400 hover:text-gray-700",title:"Reset to current URL",children:"×"})]})}),
13
- /* @__PURE__ */c("button",{"data-bookmark-popover":!0,onClick:()=>G?q(B.findIndex(e=>e.url===k)):void E(v(k)),className:V+" "+(G?"text-yellow-500":""),title:G?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:G?"currentColor":"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})}),
14
- /* @__PURE__ */c("button",{onClick:P,className:V,title:"Open in new tab",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-7.5-9L21 3m0 0v6m0-6L9.75 14.25"})})}),
15
- /* @__PURE__ */c("button",{onClick:()=>R(e=>!e),className:V,title:"Embedding help",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})})]}),null!==D&&/* @__PURE__ */l("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
13
+ /* @__PURE__ */c("button",{"data-bookmark-popover":!0,onClick:()=>J?q(R.findIndex(e=>e.url===k)):void E(v(k)),className:P+" "+(J?"text-yellow-500":""),title:J?"Remove bookmark":"Add bookmark",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:J?"currentColor":"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z"})})}),
14
+ /* @__PURE__ */c("button",{onClick:O,className:P,title:"Open in new tab",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-7.5-9L21 3m0 0v6m0-6L9.75 14.25"})})}),
15
+ /* @__PURE__ */c("button",{onClick:()=>A(e=>!e),className:P,title:"Embedding help",children:/* @__PURE__ */c("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"})})})]}),null!==D&&/* @__PURE__ */l("div",{"data-bookmark-popover":!0,className:"absolute right-3 top-12 z-30 w-72 bg-white border border-gray-200 rounded-md shadow-lg p-3",children:[
16
16
  /* @__PURE__ */c("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 mb-1",children:"Bookmark this page"}),
17
17
  /* @__PURE__ */c("div",{className:"text-[11px] text-gray-400 truncate mb-2 font-mono",title:k,children:k}),
18
- /* @__PURE__ */c("input",{ref:O,type:"text",value:D,onChange:e=>E(e.target.value),onKeyDown:e=>{"Enter"===e.key?U():"Escape"===e.key&&E(null)},placeholder:"Name",className:"w-full text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
18
+ /* @__PURE__ */c("input",{ref:T,type:"text",value:D,onChange:e=>E(e.target.value),onKeyDown:e=>{"Enter"===e.key?V():"Escape"===e.key&&E(null)},placeholder:"Name",className:"w-full text-sm px-2 py-1.5 border border-gray-300 rounded focus:outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-200"}),
19
19
  /* @__PURE__ */l("div",{className:"flex justify-end gap-1 mt-2",children:[
20
20
  /* @__PURE__ */c("button",{onClick:()=>E(null),className:"px-2 py-1 text-xs text-gray-600 hover:bg-gray-100 rounded",children:"Cancel"}),
21
- /* @__PURE__ */c("button",{onClick:U,disabled:!D.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
22
- /* @__PURE__ */l("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===B.length&&/* @__PURE__ */c("span",{className:"text-[11px] text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),B.map((e,t)=>/* @__PURE__ */l("button",{onClick:()=>I(e.url),onContextMenu:async o=>{o.preventDefault();await n({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&q(t)},className:"flex items-center gap-1.5 px-2 py-0.5 rounded text-[12px] text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
21
+ /* @__PURE__ */c("button",{onClick:V,disabled:!D.trim(),className:"px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-40",children:"Save"})]})]}),
22
+ /* @__PURE__ */l("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-gray-200 bg-white shrink-0 overflow-x-auto",children:[0===R.length&&/* @__PURE__ */c("span",{className:"text-[11px] text-gray-400 italic px-2",children:"No bookmarks yet — star the address bar to add one."}),R.map((e,t)=>/* @__PURE__ */l("button",{onClick:()=>I(e.url),onContextMenu:async o=>{o.preventDefault();await n({title:"Remove bookmark",message:`"${e.label}" will be removed from your bookmarks.`,confirmLabel:"Remove",variant:"danger"})&&q(t)},className:"flex items-center gap-1.5 px-2 py-0.5 rounded text-[12px] text-gray-700 hover:bg-gray-100 whitespace-nowrap",title:`${e.url}\n(right-click to remove)`,children:[
23
23
  /* @__PURE__ */c("img",{src:`https://icons.duckduckgo.com/ip3/${new URL(e.url).hostname}.ico`,alt:"",className:"h-3.5 w-3.5",onError:e=>{e.target.style.visibility="hidden"}}),e.label]},t)),
24
24
  /* @__PURE__ */c("div",{className:"flex-1"}),
25
25
  /* @__PURE__ */c("button",{onClick:()=>{g(k);try{localStorage.setItem(u,k)}catch{}},className:"px-2 py-0.5 text-[11px] text-gray-500 hover:text-gray-800",title:"Set current page as homepage",children:"Set as home"})]}),
26
- /* @__PURE__ */c("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */c(y,{url:k,iframeKey:W,iframeRef:T,openExternal:P,showHelp:H,dismissHelp:()=>R(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function y({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:a}){const[d,u]=s(!1);i(()=>{u(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return k.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */c("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */l("div",{className:"max-w-md text-center",children:[
26
+ /* @__PURE__ */c("div",{className:"flex-1 relative min-h-0 bg-gray-50",children:/* @__PURE__ */c(y,{url:k,iframeKey:S,iframeRef:U,openExternal:O,showHelp:H,dismissHelp:()=>A(!1)})})]})}function v(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function y({url:e,iframeKey:t,iframeRef:o,openExternal:r,showHelp:n,dismissHelp:a}){const[d,u]=s(!1);i(()=>{u(!1)},[e]);return function(e){try{const t=new URL(e).hostname.toLowerCase();return k.some(e=>t===e||t.endsWith("."+e))}catch{return!1}}(e)&&!d?/* @__PURE__ */c("div",{className:"absolute inset-0 flex items-center justify-center bg-white p-8",children:/* @__PURE__ */l("div",{className:"max-w-md text-center",children:[
27
27
  /* @__PURE__ */c("svg",{className:"h-14 w-14 mx-auto text-gray-300 mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.2,children:/* @__PURE__ */c("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728L5.636 5.636m12.728 12.728L21 21M5.636 5.636L3 3m9 9a9 9 0 110-18 9 9 0 010 18z"})}),
28
28
  /* @__PURE__ */l("h3",{className:"text-base font-semibold text-gray-800 mb-1",children:[v(e)," can't be embedded"]}),
29
29
  /* @__PURE__ */l("p",{className:"text-sm text-gray-500 mb-4",children:["This site sends an ",
@@ -1,29 +1,29 @@
1
- import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-PX435JG4.js";import{useWidgetSettings as n}from"./chunk-TBM3ZIAN.js";import"./chunk-6A7BN7EN.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-PH3PRIFP.js";import"./chunk-6KO2U66R.js";import"./chunk-E4JWTNG5.js";import"./chunk-L7ZMDZAB.js";import"./chunk-OSJ3ADF2.js";import"./chunk-MAIHBBWT.js";import"./chunk-YJX2IWHB.js";import"./chunk-D65T4H6J.js";import{useState as r,useRef as l,useCallback as o,useEffect as i}from"react";import{jsxs as a,Fragment as c,jsx as s}from"react/jsx-runtime";var u="calc_appearance";function d(){const[d,h]=r("0"),[m,b]=r(null),[k,g]=r(null),[p,N]=r(!1),[v,x]=r(""),[y,f]=r([]),[C,$]=r(!1),[j,w]=r(()=>e(u)),[E,B]=r(!1),[S,T]=r(j),A=l(null);n(o(()=>{T({...j}),B(!0)},[j]));const L=o(e=>{x(""),h(t=>p||"0"===t?(N(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[p]),W=o(()=>{h("0"),b(null),g(null),N(!1)},[]),D=o((e,t,n)=>{switch(n){case"+":return e+t;case"-":return e-t;case"×":return e*t;case"÷":return 0===t?0:e/t;default:return t}},[]),F=o(e=>{const t=parseFloat(d);if(null!==m&&k&&!p){const e=D(m,t,k);h(String(e)),b(e),f(n=>[`${m} ${k} ${t} = ${e}`,...n].slice(0,20))}else b(t);g(e),N(!0)},[d,m,k,p,D]),M=o(()=>{if(null===m||!k)return;const e=parseFloat(d),t=D(m,e,k),n=`${m} ${k} ${e} =`;f(e=>[`${n} ${t}`,...e].slice(0,20)),x(n),h(String(t)),b(null),g(null),N(!0)},[d,m,k,D]),I=o(()=>{h(e=>String(parseFloat(e)/100))},[]),J=o(()=>{h(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);i(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?L(e.key):"."===e.key?L("."):"+"===e.key?F("+"):"-"===e.key?F("-"):"*"===e.key?F("×"):"/"===e.key?(e.preventDefault(),F("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&A.current?.contains(e.target)&&e.preventDefault(),M()):"Escape"===e.key?W():"Backspace"===e.key?h(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&I())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[L,F,M,W,I]);const H="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",O=`${H} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,P=`${H} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,X=`${H} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,R=`${H} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
1
+ import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-RKEHUV7U.js";import{useWidgetSettings as n}from"./chunk-ZLJCWBDF.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-4UCRT4ST.js";import"./chunk-6KO2U66R.js";import"./chunk-KRTZFHYW.js";import"./chunk-VDL2RLZG.js";import"./chunk-ELSUXC3N.js";import"./chunk-MAIHBBWT.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useState as r,useRef as l,useCallback as o,useEffect as i}from"react";import{jsxs as a,Fragment as c,jsx as s}from"react/jsx-runtime";var u="calc_appearance";function d(){const[d,h]=r("0"),[m,b]=r(null),[k,g]=r(null),[p,v]=r(!1),[x,y]=r(""),[N,f]=r([]),[C,$]=r(!1),[j,w]=r(()=>e(u)),[L,E]=r(!1),[S,T]=r(j),W=l(null);n(o(()=>{T({...j}),E(!0)},[j]));const B=o(e=>{y(""),h(t=>p||"0"===t?(v(!1),"."===e?"0.":e):"."===e&&t.includes(".")?t:t+e)},[p]),A=o(()=>{h("0"),b(null),g(null),v(!1)},[]),D=o((e,t,n)=>{switch(n){case"+":return e+t;case"-":return e-t;case"×":return e*t;case"÷":return 0===t?0:e/t;default:return t}},[]),F=o(e=>{const t=parseFloat(d);if(null!==m&&k&&!p){const e=D(m,t,k);h(String(e)),b(e),f(n=>[`${m} ${k} ${t} = ${e}`,...n].slice(0,20))}else b(t);g(e),v(!0)},[d,m,k,p,D]),R=o(()=>{if(null===m||!k)return;const e=parseFloat(d),t=D(m,e,k),n=`${m} ${k} ${e} =`;f(e=>[`${n} ${t}`,...e].slice(0,20)),y(n),h(String(t)),b(null),g(null),v(!0)},[d,m,k,D]),U=o(()=>{h(e=>String(parseFloat(e)/100))},[]),H=o(()=>{h(e=>e.startsWith("-")?e.slice(1):"0"===e?e:"-"+e)},[]);i(()=>{const e=e=>{const t=e.target.tagName;"INPUT"!==t&&"TEXTAREA"!==t&&"SELECT"!==t&&(e.key>="0"&&e.key<="9"?B(e.key):"."===e.key?B("."):"+"===e.key?F("+"):"-"===e.key?F("-"):"*"===e.key?F("×"):"/"===e.key?(e.preventDefault(),F("÷")):"Enter"===e.key||"="===e.key?("Enter"===e.key&&e.target instanceof Node&&W.current?.contains(e.target)&&e.preventDefault(),R()):"Escape"===e.key?A():"Backspace"===e.key?h(e=>e.length>1?e.slice(0,-1):"0"):"%"===e.key&&U())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B,F,R,A,U]);const M="flex items-center justify-center rounded-lg text-sm font-medium transition-colors",I=`${M} bg-white border border-gray-200 text-gray-900 hover:bg-gray-50 active:bg-gray-100`,O=`${M} bg-blue-50 border border-blue-200 text-blue-700 hover:bg-blue-100 active:bg-blue-200`,Q=`${M} bg-gray-100 border border-gray-200 text-gray-600 hover:bg-gray-200 active:bg-gray-300`,X=`${M} bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800`;/* @__PURE__ */
2
2
  return a(c,{children:[
3
- /* @__PURE__ */a("div",{ref:A,className:"flex flex-col h-full",style:{opacity:j.activeOpacity/100,backdropFilter:j.activeBlur>0?`blur(${j.activeBlur}px)`:void 0},children:[
3
+ /* @__PURE__ */a("div",{ref:W,className:"flex flex-col h-full",style:{opacity:j.activeOpacity/100,backdropFilter:j.activeBlur>0?`blur(${j.activeBlur}px)`:void 0},children:[
4
4
  /* @__PURE__ */a("div",{className:"bg-slate-200 rounded-t-lg px-4 py-2 group/display relative flex flex-col justify-end min-h-[120px] border-b border-slate-300",children:[
5
- /* @__PURE__ */s("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:y.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */s("div",{className:"text-[11px] text-slate-400 text-right font-mono truncate",children:e},t))}),(v||k&&null!==m)&&/* @__PURE__ */s("div",{className:"text-base text-slate-600 text-right font-mono",children:v||`${m} ${k} ${p?"":d}`}),
5
+ /* @__PURE__ */s("div",{className:"flex flex-col justify-end flex-1 overflow-hidden",children:N.slice(0,3).reverse().map((e,t)=>/* @__PURE__ */s("div",{className:"text-[11px] text-slate-400 text-right font-mono truncate",children:e},t))}),(x||k&&null!==m)&&/* @__PURE__ */s("div",{className:"text-base text-slate-600 text-right font-mono",children:x||`${m} ${k} ${p?"":d}`}),
6
6
  /* @__PURE__ */a("div",{className:"flex items-center gap-2",children:[
7
7
  /* @__PURE__ */s("button",{onClick:()=>{navigator.clipboard.writeText(d),$(!0),setTimeout(()=>$(!1),1200)},title:"Copy result",className:"shrink-0 text-slate-300 hover:text-slate-500 transition-colors opacity-0 group-hover/display:opacity-100",children:/* @__PURE__ */s("svg",C?{className:"h-5 w-5 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}:{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),
8
8
  /* @__PURE__ */s("div",{className:"text-right text-4xl font-mono font-bold text-slate-800 truncate flex-1",children:(e=>{const t=parseFloat(e);return isNaN(t)||e.endsWith(".")||e.endsWith(".0")||Math.abs(t)<1e15&&e.length<16?e:t.toExponential(6)})(d)})]})]}),
9
9
  /* @__PURE__ */a("div",{className:"grid grid-cols-4 grid-rows-5 gap-1.5 flex-1 min-h-0 p-2",children:[
10
- /* @__PURE__ */s("button",{onClick:W,className:X,children:"AC"}),
11
- /* @__PURE__ */s("button",{onClick:J,className:X,children:"+/−"}),
12
- /* @__PURE__ */s("button",{onClick:I,className:X,children:"%"}),
13
- /* @__PURE__ */s("button",{onClick:()=>F("÷"),className:`${P} ${"÷"===k?"ring-2 ring-blue-400":""}`,children:"÷"}),
14
- /* @__PURE__ */s("button",{onClick:()=>L("7"),className:O,children:"7"}),
15
- /* @__PURE__ */s("button",{onClick:()=>L("8"),className:O,children:"8"}),
16
- /* @__PURE__ */s("button",{onClick:()=>L("9"),className:O,children:"9"}),
17
- /* @__PURE__ */s("button",{onClick:()=>F("×"),className:`${P} ${"×"===k?"ring-2 ring-blue-400":""}`,children:"×"}),
18
- /* @__PURE__ */s("button",{onClick:()=>L("4"),className:O,children:"4"}),
19
- /* @__PURE__ */s("button",{onClick:()=>L("5"),className:O,children:"5"}),
20
- /* @__PURE__ */s("button",{onClick:()=>L("6"),className:O,children:"6"}),
21
- /* @__PURE__ */s("button",{onClick:()=>F("-"),className:`${P} ${"-"===k?"ring-2 ring-blue-400":""}`,children:"−"}),
22
- /* @__PURE__ */s("button",{onClick:()=>L("1"),className:O,children:"1"}),
23
- /* @__PURE__ */s("button",{onClick:()=>L("2"),className:O,children:"2"}),
24
- /* @__PURE__ */s("button",{onClick:()=>L("3"),className:O,children:"3"}),
25
- /* @__PURE__ */s("button",{onClick:()=>F("+"),className:`${P} ${"+"===k?"ring-2 ring-blue-400":""}`,children:"+"}),
26
- /* @__PURE__ */s("button",{onClick:()=>L("0"),className:`${O} col-span-2`,children:"0"}),
27
- /* @__PURE__ */s("button",{onClick:()=>L("."),className:O,children:"."}),
28
- /* @__PURE__ */s("button",{onClick:M,className:R,children:"="})]})]}),
29
- /* @__PURE__ */s(t,{open:E,onClose:()=>B(!1),title:"Calculator Settings",appearance:S,onAppearanceChange:T,onSave:()=>{w(S),localStorage.setItem(u,JSON.stringify(S)),B(!1)}})]})}export{d as default};
10
+ /* @__PURE__ */s("button",{onClick:A,className:Q,children:"AC"}),
11
+ /* @__PURE__ */s("button",{onClick:H,className:Q,children:"+/−"}),
12
+ /* @__PURE__ */s("button",{onClick:U,className:Q,children:"%"}),
13
+ /* @__PURE__ */s("button",{onClick:()=>F("÷"),className:`${O} ${"÷"===k?"ring-2 ring-blue-400":""}`,children:"÷"}),
14
+ /* @__PURE__ */s("button",{onClick:()=>B("7"),className:I,children:"7"}),
15
+ /* @__PURE__ */s("button",{onClick:()=>B("8"),className:I,children:"8"}),
16
+ /* @__PURE__ */s("button",{onClick:()=>B("9"),className:I,children:"9"}),
17
+ /* @__PURE__ */s("button",{onClick:()=>F("×"),className:`${O} ${"×"===k?"ring-2 ring-blue-400":""}`,children:"×"}),
18
+ /* @__PURE__ */s("button",{onClick:()=>B("4"),className:I,children:"4"}),
19
+ /* @__PURE__ */s("button",{onClick:()=>B("5"),className:I,children:"5"}),
20
+ /* @__PURE__ */s("button",{onClick:()=>B("6"),className:I,children:"6"}),
21
+ /* @__PURE__ */s("button",{onClick:()=>F("-"),className:`${O} ${"-"===k?"ring-2 ring-blue-400":""}`,children:"−"}),
22
+ /* @__PURE__ */s("button",{onClick:()=>B("1"),className:I,children:"1"}),
23
+ /* @__PURE__ */s("button",{onClick:()=>B("2"),className:I,children:"2"}),
24
+ /* @__PURE__ */s("button",{onClick:()=>B("3"),className:I,children:"3"}),
25
+ /* @__PURE__ */s("button",{onClick:()=>F("+"),className:`${O} ${"+"===k?"ring-2 ring-blue-400":""}`,children:"+"}),
26
+ /* @__PURE__ */s("button",{onClick:()=>B("0"),className:`${I} col-span-2`,children:"0"}),
27
+ /* @__PURE__ */s("button",{onClick:()=>B("."),className:I,children:"."}),
28
+ /* @__PURE__ */s("button",{onClick:R,className:X,children:"="})]})]}),
29
+ /* @__PURE__ */s(t,{open:L,onClose:()=>E(!1),title:"Calculator Settings",appearance:S,onAppearanceChange:T,onSave:()=>{w(S),localStorage.setItem(u,JSON.stringify(S)),E(!1)}})]})}export{d as default};
@@ -0,0 +1 @@
1
+ export{ConfirmProvider,confirm,confirmDestructive,prompt,useConfirm}from"./chunk-KRTZFHYW.js";import"./chunk-ELSUXC3N.js";import"./chunk-NCQLGQYR.js";
@@ -1,6 +1,6 @@
1
- import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-PX435JG4.js";import{useWidgetSettings as r}from"./chunk-TBM3ZIAN.js";import"./chunk-6A7BN7EN.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-PH3PRIFP.js";import"./chunk-6KO2U66R.js";import"./chunk-E4JWTNG5.js";import"./chunk-L7ZMDZAB.js";import"./chunk-OSJ3ADF2.js";import"./chunk-MAIHBBWT.js";import"./chunk-YJX2IWHB.js";import"./chunk-D65T4H6J.js";import{useState as a,useCallback as n,useEffect as s}from"react";import{jsxs as c,Fragment as o,jsx as i}from"react/jsx-runtime";var l=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],m=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],u="currency_pairs",d="currency_appearance",p="currency_rates_cache";function h(e){try{const t=JSON.parse(localStorage.getItem(p)||"{}")[e];if(t&&Date.now()-t.timestamp<36e5)return t.rates}catch{}return null}function g(e,t){try{const r=JSON.parse(localStorage.getItem(p)||"{}");r[e]={rates:t,timestamp:Date.now()},localStorage.setItem(p,JSON.stringify(r))}catch{}}function x(){try{const e=JSON.parse(localStorage.getItem(u)||"");if(Array.isArray(e)&&e.length)return e.slice(0,4)}catch{}return m}var y={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[m,p]=a(x),[f,N]=a(()=>e(d)),[b,v]=a({}),[S,D]=a(!1),[k,C]=a(!1),[j,B]=a([]),[A,J]=a(f),[I,U]=a("USD"),[O,P]=a("CNY");r(n(()=>{B([...m]),J({...f}),C(!0)},[m,f])),s(()=>{const e=[...new Set(m.map(([e])=>e))];let t=!0;return async function(){D(!0);const r={};for(const t of e){const e=h(t);if(e)r[t]=e;else try{const e=await fetch(`https://open.er-api.com/v6/latest/${t}`),a=await e.json();a.rates&&(r[t]=a.rates,g(t,a.rates))}catch{}}t&&(v(r),D(!1))}(),()=>{t=!1}},[m]);/* @__PURE__ */
1
+ import{loadAppearance as e,WidgetSettingsModal as t}from"./chunk-RKEHUV7U.js";import{useWidgetSettings as r}from"./chunk-ZLJCWBDF.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-4UCRT4ST.js";import"./chunk-6KO2U66R.js";import"./chunk-KRTZFHYW.js";import"./chunk-VDL2RLZG.js";import"./chunk-ELSUXC3N.js";import"./chunk-MAIHBBWT.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useState as a,useCallback as n,useEffect as s}from"react";import{jsxs as c,Fragment as o,jsx as i}from"react/jsx-runtime";var l=["USD","CNY","AUD","GBP","EUR","JPY","CAD","THB","NZD","SGD","HKD","CHF","KRW","INR","MXN","BRL"],m=[["USD","CNY"],["USD","AUD"],["GBP","USD"],["USD","JPY"]],u="currency_pairs",d="currency_appearance",p="currency_rates_cache";function h(e){try{const t=JSON.parse(localStorage.getItem(p)||"{}")[e];if(t&&Date.now()-t.timestamp<36e5)return t.rates}catch{}return null}function g(e,t){try{const r=JSON.parse(localStorage.getItem(p)||"{}");r[e]={rates:t,timestamp:Date.now()},localStorage.setItem(p,JSON.stringify(r))}catch{}}function x(){try{const e=JSON.parse(localStorage.getItem(u)||"");if(Array.isArray(e)&&e.length)return e.slice(0,4)}catch{}return m}var y={USD:"🇺🇸",CNY:"🇨🇳",AUD:"🇦🇺",GBP:"🇬🇧",JPY:"🇯🇵",CAD:"🇨🇦",EUR:"🇪🇺",THB:"🇹🇭",NZD:"🇳🇿",SGD:"🇸🇬",HKD:"🇭🇰",CHF:"🇨🇭",KRW:"🇰🇷",INR:"🇮🇳",MXN:"🇲🇽",BRL:"🇧🇷"};function f(){const[m,p]=a(x),[f,N]=a(()=>e(d)),[b,S]=a({}),[v,D]=a(!1),[C,k]=a(!1),[j,U]=a([]),[B,R]=a(f),[L,A]=a("USD"),[J,I]=a("CNY");r(n(()=>{U([...m]),R({...f}),k(!0)},[m,f])),s(()=>{const e=[...new Set(m.map(([e])=>e))];let t=!0;return async function(){D(!0);const r={};for(const t of e){const e=h(t);if(e)r[t]=e;else try{const e=await fetch(`https://open.er-api.com/v6/latest/${t}`),a=await e.json();a.rates&&(r[t]=a.rates,g(t,a.rates))}catch{}}t&&(S(r),D(!1))}(),()=>{t=!1}},[m]);/* @__PURE__ */
2
2
  return c(o,{children:[
3
- /* @__PURE__ */i("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */c("div",{className:"px-4 py-3 space-y-1",children:[S&&/* @__PURE__ */i("div",{className:"text-xs text-gray-400 text-center py-4",children:"Loading rates..."}),m.map(([e,t],r)=>{const a=b[e]?.[t];/* @__PURE__ */
3
+ /* @__PURE__ */i("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */c("div",{className:"px-4 py-3 space-y-1",children:[v&&/* @__PURE__ */i("div",{className:"text-xs text-gray-400 text-center py-4",children:"Loading rates..."}),m.map(([e,t],r)=>{const a=b[e]?.[t];/* @__PURE__ */
4
4
  return c("button",{onClick:()=>{const e=m.map((e,t)=>t===r?[e[1],e[0]]:e);p(e),localStorage.setItem(u,JSON.stringify(e))},className:"flex items-center justify-between px-2 py-2 border-b border-gray-200 last:border-0 w-full hover:bg-gray-100 rounded transition-colors cursor-pointer",children:[
5
5
  /* @__PURE__ */c("div",{className:"flex items-center gap-1.5",children:[
6
6
  /* @__PURE__ */i("span",{className:"text-base",children:y[e]||""}),
@@ -9,13 +9,13 @@ return c("button",{onClick:()=>{const e=m.map((e,t)=>t===r?[e[1],e[0]]:e);p(e),l
9
9
  /* @__PURE__ */i("span",{className:"text-base",children:y[t]||""}),
10
10
  /* @__PURE__ */i("span",{className:"text-sm font-semibold text-gray-700",children:t})]}),
11
11
  /* @__PURE__ */i("div",{className:"text-base font-mono font-semibold text-gray-900 tabular-nums",children:null!=a?a.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"—"})]},`${e}-${t}-${r}`)})]})}),
12
- /* @__PURE__ */i(t,{open:k,onClose:()=>C(!1),title:"Currency Settings",appearance:A,onAppearanceChange:J,onSave:()=>{if(0===j.length)return;const e=j.slice(0,4);p(e),N(A),localStorage.setItem(u,JSON.stringify(e)),localStorage.setItem(d,JSON.stringify(A)),C(!1)},children:/* @__PURE__ */c("div",{children:[
12
+ /* @__PURE__ */i(t,{open:C,onClose:()=>k(!1),title:"Currency Settings",appearance:B,onAppearanceChange:R,onSave:()=>{if(0===j.length)return;const e=j.slice(0,4);p(e),N(B),localStorage.setItem(u,JSON.stringify(e)),localStorage.setItem(d,JSON.stringify(B)),k(!1)},children:/* @__PURE__ */c("div",{children:[
13
13
  /* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:["Currency Pairs ",
14
14
  /* @__PURE__ */c("span",{className:"text-[11px] font-normal text-gray-400",children:["(",j.length,"/",4,")"]})]}),
15
15
  /* @__PURE__ */i("div",{className:"space-y-1 mb-2",children:j.map(([e,t],r)=>/* @__PURE__ */c("div",{className:"flex items-center justify-between py-1 px-2 bg-gray-50 rounded",children:[
16
16
  /* @__PURE__ */c("span",{className:"text-sm",children:[y[e]||""," ",e," → ",y[t]||""," ",t]}),
17
- /* @__PURE__ */i("button",{onClick:()=>B(e=>e.filter((e,t)=>t!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),j.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
18
- /* @__PURE__ */i("select",{value:I,onChange:e=>U(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
17
+ /* @__PURE__ */i("button",{onClick:()=>U(e=>e.filter((e,t)=>t!==r)),className:"text-red-400 hover:text-red-600",children:"×"})]},r))}),j.length<4?/* @__PURE__ */c("div",{className:"flex items-center gap-2",children:[
18
+ /* @__PURE__ */i("select",{value:L,onChange:e=>A(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
19
19
  /* @__PURE__ */i("span",{className:"text-gray-400",children:"→"}),
20
- /* @__PURE__ */i("select",{value:O,onChange:e=>P(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
21
- /* @__PURE__ */i("button",{onClick:()=>{I!==O&&j.length<4&&B(e=>[...e,[I,O]])},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 ",4," pairs — remove one to add another."]})]})})]})}export{f as default};
20
+ /* @__PURE__ */i("select",{value:J,onChange:e=>I(e.target.value),className:"bg-gray-50 border border-gray-200 rounded px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:l.map(e=>/* @__PURE__ */i("option",{children:e},e))}),
21
+ /* @__PURE__ */i("button",{onClick:()=>{L!==J&&j.length<4&&U(e=>[...e,[L,J]])},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 ",4," pairs — remove one to add another."]})]})})]})}export{f as default};
@@ -1,14 +1,14 @@
1
- import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-4GOHPACN.js";import{toast_default as n}from"./chunk-NLASNJNY.js";import"./chunk-A6O4Y63A.js";import{WindowTitle as r}from"./chunk-TBM3ZIAN.js";import"./chunk-6A7BN7EN.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-PH3PRIFP.js";import"./chunk-6KO2U66R.js";import"./chunk-E4JWTNG5.js";import{PopupMenu as o,PopupMenuLabel as l,PopupMenuItem as a,PopupMenuDivider as i}from"./chunk-L7ZMDZAB.js";import"./chunk-OSJ3ADF2.js";import"./chunk-MAIHBBWT.js";import"./chunk-YJX2IWHB.js";import"./chunk-D65T4H6J.js";import{useState as s,useRef as c}from"react";import{jsxs as d,jsx as h}from"react/jsx-runtime";var m=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),u=/* @__PURE__ */new Set(["docx"]),p={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function g(){const[g,x]=s(p),[f,y]=s(!1),[v,b]=s(!1),[k,w]=s(!1),[N,C]=s(null),j=c(null),D=c(null),L=c(null),M=(e,t)=>{L.current?.focus(),document.execCommand(e,!1,t),w(!0)},A=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{L.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),w(!0)},e.readAsDataURL(t)}},B=e=>{N&&(N.el.removeAttribute("width"),N.el.removeAttribute("height"),N.el.style.width=e??"",N.el.style.height=e?"auto":"",w(!0),C(null))},U=async t=>{const r=(t.name.split(".").pop()||"").toLowerCase();y(!0);try{if(m.has(r)||!u.has(r)&&t.type.startsWith("text/")){const n=await t.text(),o=e(n).replace(/\n/g,"<br>");x({filename:t.name,kind:"text",content:o,ext:r}),w(!1)}else if(u.has(r))try{const e=await(import(
1
+ import{escapeHtml as e}from"./chunk-BR22X7E5.js";import{AboutApp as t}from"./chunk-D7EJSASN.js";import{toast_default as n}from"./chunk-KSSAVLO7.js";import"./chunk-SHVGZW2J.js";import{WindowTitle as r}from"./chunk-ZLJCWBDF.js";import"./chunk-A7Q4BCPI.js";import"./chunk-DSSLOQDW.js";import"./chunk-5A7MWTXX.js";import"./chunk-4UCRT4ST.js";import"./chunk-6KO2U66R.js";import"./chunk-KRTZFHYW.js";import{PopupMenu as o,PopupMenuLabel as l,PopupMenuItem as a,PopupMenuDivider as i}from"./chunk-VDL2RLZG.js";import"./chunk-ELSUXC3N.js";import"./chunk-MAIHBBWT.js";import"./chunk-NCQLGQYR.js";import"./chunk-D65T4H6J.js";import{useState as s,useRef as c}from"react";import{jsxs as d,jsx as h}from"react/jsx-runtime";var m=/* @__PURE__ */new Set(["txt","md","markdown","csv","tsv","log","json","xml","html","htm","css","js","jsx","ts","tsx","py","rb","go","rs","java","c","h","cpp","hpp","sh","bash","yml","yaml","toml","ini","conf","env","sql"]),u=/* @__PURE__ */new Set(["docx"]),p={filename:"Untitled",kind:"docx",content:"",ext:"docx"};function g(){const[g,x]=s(p),[f,y]=s(!1),[v,b]=s(!1),[k,w]=s(!1),[N,C]=s(null),D=c(null),L=c(null),j=c(null),M=(e,t)=>{j.current?.focus(),document.execCommand(e,!1,t),w(!0)},R=e=>{for(const t of e){if(!t.type.startsWith("image/"))continue;const e=new FileReader;e.onload=()=>{j.current?.focus(),document.execCommand("insertImage",!1,String(e.result)),w(!0)},e.readAsDataURL(t)}},U=e=>{N&&(N.el.removeAttribute("width"),N.el.removeAttribute("height"),N.el.style.width=e??"",N.el.style.height=e?"auto":"",w(!0),C(null))},S=async t=>{const r=(t.name.split(".").pop()||"").toLowerCase();y(!0);try{if(m.has(r)||!u.has(r)&&t.type.startsWith("text/")){const n=await t.text(),o=e(n).replace(/\n/g,"<br>");x({filename:t.name,kind:"text",content:o,ext:r}),w(!1)}else if(u.has(r))try{const e=await(import(
2
2
  /* @vite-ignore */
3
- "mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});x({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),w(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{y(!1)}},R=g?.filename?(W=g.filename).length>24?`${W.slice(0,23)}…`:W:"Untitled";var W;/* @__PURE__ */
4
- return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),v||b(!0)},onDragLeave:e=>{e.currentTarget===e.target&&b(!1)},onDrop:e=>{e.preventDefault(),b(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?A(t):U(t[0]))},children:[
5
- /* @__PURE__ */h(r,{title:`${R}${k?" •":""} - Documents`}),
3
+ "mammoth")),n=await t.arrayBuffer(),o=await e.convertToHtml({arrayBuffer:n});x({filename:t.name,kind:"docx",content:o.value||"<p><em>(empty document)</em></p>",ext:r}),w(!1)}catch(e){n.error('Install the optional "mammoth" peer dep to read .docx files.')}else"doc"===r?n.error(".doc is the legacy Word binary format — convert to .docx first."):n.error(`Unsupported file type: .${r||"unknown"}`)}finally{y(!1)}},B=g?.filename?(W=g.filename).length>24?`${W.slice(0,23)}…`:W:"Untitled";var W;/* @__PURE__ */
4
+ return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preventDefault(),v||b(!0)},onDragLeave:e=>{e.currentTarget===e.target&&b(!1)},onDrop:e=>{e.preventDefault(),b(!1);const t=Array.from(e.dataTransfer.files??[]);0!==t.length&&(t.every(e=>e.type.startsWith("image/"))?R(t):S(t[0]))},children:[
5
+ /* @__PURE__ */h(r,{title:`${B}${k?" •":""} - Documents`}),
6
6
  /* @__PURE__ */h(t,{app:"documents"}),
7
7
  /* @__PURE__ */d("div",{className:"flex items-center flex-wrap gap-x-2 gap-y-1 px-3 py-2 border-b border-gray-200 bg-gray-50 shrink-0",children:[
8
- /* @__PURE__ */h("input",{ref:j,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&U(t),j.current&&(j.current.value="")},className:"hidden"}),
9
- /* @__PURE__ */d("button",{onClick:()=>j.current?.click(),className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
8
+ /* @__PURE__ */h("input",{ref:D,type:"file",accept:".txt,.md,.csv,.tsv,.log,.json,.xml,.html,.htm,.css,.js,.jsx,.ts,.tsx,.py,.rb,.go,.rs,.java,.c,.h,.cpp,.hpp,.sh,.bash,.yml,.yaml,.toml,.ini,.conf,.env,.sql,.docx,text/*",onChange:e=>{const t=e.target.files?.[0];t&&S(t),D.current&&(D.current.value="")},className:"hidden"}),
9
+ /* @__PURE__ */d("button",{onClick:()=>D.current?.click(),className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors flex items-center gap-1",children:[
10
10
  /* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),"Open"]}),
11
- /* @__PURE__ */h("button",{onClick:()=>{if(!g)return;const t=L.current?.innerHTML??"";if("text"===g.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(g.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${g.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=L.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=g.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(g.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${g.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
11
+ /* @__PURE__ */h("button",{onClick:()=>{if(!g)return;const t=j.current?.innerHTML??"";if("text"===g.kind){if(/<(b|strong|i|em|u|font|span style|ul|ol|img)|style="[^"]*text-align/i.test(t)){const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(g.filename)}</title><body style="font-family:ui-monospace,monospace;white-space:pre-wrap">${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${g.filename.replace(/\.[^.]+$/,"")}.html`,o.click(),URL.revokeObjectURL(r)}else{const e=j.current?.innerText??"",t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n,r.download=g.filename,r.click(),URL.revokeObjectURL(n)}}else{const n=new Blob([`<!doctype html><meta charset="utf-8"><title>${e(g.filename)}</title>${t}`],{type:"text/html"}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=`${g.filename.replace(/\.docx$/i,"")}.html`,o.click(),URL.revokeObjectURL(r)}},className:"text-xs text-gray-700 hover:text-gray-900 px-2 py-1 rounded hover:bg-gray-200 transition-colors",children:"Save"}),
12
12
  /* @__PURE__ */h("span",{className:"text-[10px] text-gray-400 ml-1",children:"TXT · DOCX · Code"}),
13
13
  /* @__PURE__ */h("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
14
14
  /* @__PURE__ */d("span",{className:"text-xs font-medium text-gray-700 truncate max-w-[200px]",title:g.filename,children:[g.filename,k?" •":""]}),
@@ -38,15 +38,15 @@ return d("div",{className:"relative flex flex-col h-full",onDragOver:e=>{e.preve
38
38
  /* @__PURE__ */h("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>M("justifyRight"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Align right",children:/* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */h("path",{strokeLinecap:"round",d:"M3.75 6h16.5M10.5 12h9.75M6 18h14.25"})})}),
39
39
  /* @__PURE__ */h("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>M("justifyFull"),className:"px-2 py-1 rounded text-gray-700 hover:bg-gray-200 transition-colors",title:"Justify",children:/* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.8,children:/* @__PURE__ */h("path",{strokeLinecap:"round",d:"M3.75 6h16.5M3.75 12h16.5M3.75 18h16.5"})})})]}),
40
40
  /* @__PURE__ */h("div",{className:"h-4 w-px bg-gray-300 mx-1"}),
41
- /* @__PURE__ */h("input",{ref:D,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&A(Array.from(e.target.files)),D.current&&(D.current.value="")}}),
42
- /* @__PURE__ */d("button",{onClick:()=>D.current?.click(),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors flex items-center gap-1",title:"Insert image (or paste / drop one)",children:[
41
+ /* @__PURE__ */h("input",{ref:L,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files?.length&&R(Array.from(e.target.files)),L.current&&(L.current.value="")}}),
42
+ /* @__PURE__ */d("button",{onClick:()=>L.current?.click(),className:"px-2 py-1 text-xs rounded text-gray-700 hover:bg-gray-200 transition-colors flex items-center gap-1",title:"Insert image (or paste / drop one)",children:[
43
43
  /* @__PURE__ */h("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:/* @__PURE__ */h("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})}),"Image"]})]}),
44
- /* @__PURE__ */h("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */h("div",f?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===g.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */h("div",{ref:L,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>w(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),A(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:g.content},className:"docx"===g.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-[14px] leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-[13px] leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),v&&/* @__PURE__ */h("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */h("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),N&&/* @__PURE__ */d(o,{minWidth:150,style:{left:N.x,top:N.y},onClose:()=>C(null),children:[
44
+ /* @__PURE__ */h("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */h("div",f?{className:"flex items-center justify-center h-full text-sm text-gray-400",children:"Loading…"}:{className:"h-full overflow-auto "+("docx"===g.kind?"bg-gray-100 px-6 py-8":"bg-white"),children:/* @__PURE__ */h("div",{ref:j,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:()=>w(!0),onPaste:e=>{const t=Array.from(e.clipboardData?.items??[]).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(e=>!!e);t.length&&(e.preventDefault(),R(t))},onClick:e=>{const t=e.target;"IMG"===t.tagName&&(e.preventDefault(),C({x:e.clientX,y:e.clientY,el:t}))},dangerouslySetInnerHTML:{__html:g.content},className:"docx"===g.kind?"docs-editor mx-auto w-[8.5in] min-h-[11in] bg-white p-[1in] shadow text-[14px] leading-relaxed text-gray-800 outline-none focus:ring-2 focus:ring-blue-400/40":"docs-editor block w-full min-h-full p-4 font-mono text-[13px] leading-relaxed text-gray-800 bg-white outline-none whitespace-pre-wrap"})})}),v&&/* @__PURE__ */h("div",{className:"absolute inset-0 bg-blue-500/15 border-4 border-dashed border-blue-500 pointer-events-none flex items-center justify-center z-20",children:/* @__PURE__ */h("div",{className:"px-4 py-2 rounded-md bg-blue-600 text-white text-sm font-medium shadow-lg",children:"Drop a document to open · images insert into the page"})}),N&&/* @__PURE__ */d(o,{minWidth:150,style:{left:N.x,top:N.y},onClose:()=>C(null),children:[
45
45
  /* @__PURE__ */h(l,{children:"Image width"}),
46
- /* @__PURE__ */h(a,{onClick:()=>B("25%"),children:"25%"}),
47
- /* @__PURE__ */h(a,{onClick:()=>B("50%"),children:"50%"}),
48
- /* @__PURE__ */h(a,{onClick:()=>B("75%"),children:"75%"}),
49
- /* @__PURE__ */h(a,{onClick:()=>B("100%"),children:"100%"}),
50
- /* @__PURE__ */h(a,{onClick:()=>B(null),children:"Original size"}),
46
+ /* @__PURE__ */h(a,{onClick:()=>U("25%"),children:"25%"}),
47
+ /* @__PURE__ */h(a,{onClick:()=>U("50%"),children:"50%"}),
48
+ /* @__PURE__ */h(a,{onClick:()=>U("75%"),children:"75%"}),
49
+ /* @__PURE__ */h(a,{onClick:()=>U("100%"),children:"100%"}),
50
+ /* @__PURE__ */h(a,{onClick:()=>U(null),children:"Original size"}),
51
51
  /* @__PURE__ */h(i,{}),
52
52
  /* @__PURE__ */h(a,{danger:!0,onClick:()=>{N?.el.remove(),w(!0),C(null)},children:"Remove image"})]})]})}export{g as default};