efficient-easel 0.99.2 → 0.101.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 (108) hide show
  1. package/README.md +233 -17
  2. package/dist/autosave/index.d.ts +11 -5
  3. package/dist/blocks/index.d.ts +1 -1
  4. package/dist/canvas/index.d.ts +2 -2
  5. package/dist/canvas/index.js +1 -1
  6. package/dist/chrome/chrome.css +96 -29
  7. package/dist/chrome/index.d.ts +67 -18
  8. package/dist/chrome/index.js +25 -21
  9. package/dist/{chunk-JYPOOHII.js → chunk-2FZJWH24.js} +3 -3
  10. package/dist/chunk-3EDSDPIP.js +1 -0
  11. package/dist/chunk-546BBOPE.js +1 -0
  12. package/dist/chunk-67GNT6PF.js +1 -0
  13. package/dist/chunk-EOJNJCMJ.js +16 -0
  14. package/dist/chunk-EWVJSRRY.js +6 -0
  15. package/dist/chunk-FPOKPNO4.js +1 -0
  16. package/dist/chunk-H24N5TMZ.js +11 -0
  17. package/dist/chunk-IG3U5NWJ.js +1 -0
  18. package/dist/chunk-JUQ6YJCG.js +1 -0
  19. package/dist/chunk-KTVH2ZRL.js +15 -0
  20. package/dist/{chunk-PI26YXYD.js → chunk-L5KW4HG5.js} +16 -8
  21. package/dist/chunk-M6F6LS3H.js +1 -0
  22. package/dist/chunk-P6O363EE.js +6 -0
  23. package/dist/chunk-PAELDYYS.js +1 -0
  24. package/dist/chunk-QTLAVDJE.js +1 -0
  25. package/dist/chunk-UH7IGZKF.js +1 -0
  26. package/dist/chunk-WZ7TGAAT.js +3 -0
  27. package/dist/chunk-ZFDCDJNZ.js +16 -0
  28. package/dist/chunk-ZJEBF4NB.js +1 -0
  29. package/dist/chunk-ZNS7727Y.js +12 -0
  30. package/dist/copy/copy.css +442 -5
  31. package/dist/copy/index.d.ts +302 -5
  32. package/dist/copy/index.js +32 -10
  33. package/dist/drag/drag.css +10 -1
  34. package/dist/drag/index.d.ts +99 -8
  35. package/dist/drag/index.js +18 -17
  36. package/dist/easel/easel.css +15 -0
  37. package/dist/easel/index.d.ts +104 -33
  38. package/dist/easel/index.js +9 -1
  39. package/dist/edit-lock/index.d.ts +1 -3
  40. package/dist/edit-lock/index.js +1 -1
  41. package/dist/fields/fields.css +270 -38
  42. package/dist/fields/index.d.ts +209 -26
  43. package/dist/fields/index.js +22 -53
  44. package/dist/gold/index.js +1 -1
  45. package/dist/icons/index.d.ts +13 -1
  46. package/dist/icons/index.js +1 -1
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.js +1 -1
  49. package/dist/markup/index.d.ts +111 -10
  50. package/dist/markup/index.js +1 -1
  51. package/dist/menu/index.d.ts +58 -5
  52. package/dist/menu/index.js +1 -15
  53. package/dist/menu/menu.css +17 -6
  54. package/dist/node-ops/index.d.ts +1 -1
  55. package/dist/node-ops/index.js +1 -1
  56. package/dist/panel/index.d.ts +83 -4
  57. package/dist/panel/index.js +18 -16
  58. package/dist/panel/panel.css +135 -62
  59. package/dist/pick/index.d.ts +78 -2
  60. package/dist/pick/index.js +7 -14
  61. package/dist/pick/pick.css +197 -10
  62. package/dist/rail/index.d.ts +3 -7
  63. package/dist/rail/index.js +1 -1
  64. package/dist/strings/catalogue.d.ts +13 -35
  65. package/dist/strings/catalogue.js +1 -1
  66. package/dist/strings/index.d.ts +12 -18
  67. package/dist/strings/index.js +2 -2
  68. package/dist/style-clipboard/index.d.ts +1 -1
  69. package/dist/style-clipboard/index.js +1 -1
  70. package/dist/text-styles/index.d.ts +328 -0
  71. package/dist/text-styles/index.js +38 -0
  72. package/dist/text-styles/text-styles.css +309 -0
  73. package/dist/tree/index.d.ts +43 -2
  74. package/dist/tree/index.js +1 -1
  75. package/dist/tree/tree.css +71 -0
  76. package/dist/{types-p9j2Fac7.d.ts → types-DGcCsxs8.d.ts} +72 -7
  77. package/dist/{types-Bs_gVkVI.d.ts → types-DWS-s9z-.d.ts} +1 -9
  78. package/dist/{types-DO-b0LNj.d.ts → types-Djdq6Xkd.d.ts} +9 -8
  79. package/dist/{types-BOSGNvil.d.ts → types-E3HrTPg2.d.ts} +7 -13
  80. package/dist/{types-C7HFvdtk.d.ts → types-VqL6t5HH.d.ts} +82 -5
  81. package/dist/{watch-B5RTR-WX.d.ts → watch-BTYOJpQU.d.ts} +18 -1
  82. package/dist/{words-DagJdwIA.d.ts → words-AHHfiaRY.d.ts} +31 -2
  83. package/dist/words-BGrHZAJJ.d.ts +46 -0
  84. package/dist/{words-c-3h9xQQ.d.ts → words-BMzV04b1.d.ts} +1 -1
  85. package/dist/words-CRYvAiHX.d.ts +105 -0
  86. package/dist/words-D8kf071T.d.ts +93 -0
  87. package/dist/{words-N4ebT88_.d.ts → words-DgHcY5qB.d.ts} +9 -3
  88. package/dist/{words-C74EUpFr.d.ts → words-XH0TvZPg.d.ts} +60 -4
  89. package/package.json +8 -8
  90. package/dist/chunk-66CKSTXP.js +0 -14
  91. package/dist/chunk-672FAEKU.js +0 -1
  92. package/dist/chunk-67VZRQLG.js +0 -13
  93. package/dist/chunk-6PS6STGA.js +0 -1
  94. package/dist/chunk-7A7O2JWQ.js +0 -1
  95. package/dist/chunk-7JTL3P6P.js +0 -1
  96. package/dist/chunk-F2PIG3AA.js +0 -10
  97. package/dist/chunk-H4B72XCJ.js +0 -1
  98. package/dist/chunk-KDIVA6WD.js +0 -1
  99. package/dist/chunk-MCLBHENY.js +0 -1
  100. package/dist/chunk-QB3BZIRA.js +0 -5
  101. package/dist/chunk-SJQG5ENJ.js +0 -1
  102. package/dist/chunk-SUO5627P.js +0 -1
  103. package/dist/chunk-XUE5O62R.js +0 -3
  104. package/dist/chunk-ZT7M24XD.js +0 -1
  105. package/dist/editor/index.d.ts +0 -10
  106. package/dist/editor/index.js +0 -1
  107. package/dist/words-CD3WADyb.d.ts +0 -51
  108. /package/dist/{chunk-2PHD4L6A.js → chunk-OWBO4WKA.js} +0 -0
@@ -1,8 +1,111 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { MarkStyle, MarkupTool, WrapResult, InlineRule } from '../markup/index.js';
4
- import { a as CopyAlign } from '../words-C74EUpFr.js';
5
- export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, C as CopyWords, f as copyAlignOptions } from '../words-C74EUpFr.js';
3
+ import { MarkStyle, MarkupTool, WrapResult, InlineRule, MarkedLine } from '../markup/index.js';
4
+ import { C as CopyWords, a as CopyAlign } from '../words-XH0TvZPg.js';
5
+ export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, f as copyAlignOptions } from '../words-XH0TvZPg.js';
6
+
7
+ type CellWords = NonNullable<CopyWords['cells']>;
8
+ interface CopyCell {
9
+ /** Which cell this is — a stable key for the grid. */
10
+ key: string;
11
+ /** The cell's name, from the copy words (the four the design draws)… */
12
+ nameKey?: Exclude<keyof CellWords, 'tip'>;
13
+ /** …or the host's own (a cell the package does not know). */
14
+ name?: string;
15
+ icon?: ReactNode;
16
+ unit?: string;
17
+ /** What an arrow or ↑↓ moves by, in SHOWN units. */
18
+ step?: number;
19
+ /** What Shift moves by. Default ten steps. */
20
+ shiftStep?: number;
21
+ /** Bounds, in SHOWN units. */
22
+ min?: number;
23
+ max?: number;
24
+ /** Shown = stored × scale (100 for a multiple shown in %). Default 1. */
25
+ scale?: number;
26
+ /** The STORED value, or `undefined` while the cell follows the style. */
27
+ value: number | undefined;
28
+ /** The style's STORED value, shown grey while the cell is empty. */
29
+ styleValue?: number;
30
+ /** A STORED value, or `undefined` when the cell is emptied. */
31
+ onChange: (value: number | undefined) => void;
32
+ }
33
+ /** A cell's preset: everything but its value and its write. */
34
+ type CopyCellPreset = Omit<CopyCell, 'value' | 'styleValue' | 'onChange'>;
35
+ /** The four cells the final design draws, with its steps and ranges
36
+ * (the campaign page's "三个框的规则" table, read 2026-10-06). */
37
+ declare const COPY_CELLS: {
38
+ fontSize: CopyCellPreset;
39
+ lineHeight: CopyCellPreset;
40
+ letterSpacing: CopyCellPreset;
41
+ paragraphSpacing: CopyCellPreset;
42
+ };
43
+ declare function CopyCells({ cells, words, readOnly }: {
44
+ cells: readonly CopyCell[];
45
+ words?: CellWords;
46
+ readOnly?: boolean;
47
+ }): react.JSX.Element;
48
+
49
+ /** A theme colour the host offers: the NAME saved, what it is called, and the
50
+ * value the box paints it in. */
51
+ interface CopyThemeColor {
52
+ name: string;
53
+ label: string;
54
+ value: string;
55
+ }
56
+ declare function ColorWindow({ colors, current, words, onPick, }: {
57
+ colors: readonly CopyThemeColor[];
58
+ /** The colour the selection wears — a theme name or a hex — or null. */
59
+ current: string | null;
60
+ words: NonNullable<CopyWords['colors']>;
61
+ /** A theme name, a lowercase `#rrggbb`, or null to take the colour off. */
62
+ onPick: (color: string | null) => void;
63
+ }): react.JSX.Element;
64
+
65
+ /** The marks row 1 can carry, in the order drawn. */
66
+ type ToolbarMark = 'bold' | 'italic' | 'underline' | 'strike' | 'link' | 'sup' | 'sub';
67
+ /** A letter case the toolbar sets on the host's field. */
68
+ type CopyCase = 'none' | 'upper' | 'lower';
69
+ interface TextToolbarProps {
70
+ words: NonNullable<CopyWords['toolbar']>;
71
+ align: Record<CopyAlign, string>;
72
+ /** The alignment group's accessible name (`copy.alignment`). */
73
+ alignmentLabel: string;
74
+ /** The marks the host offers. */
75
+ offered: ReadonlySet<string>;
76
+ /** The marks the selection wears (or a pending press set). */
77
+ pressed: Partial<Record<string, boolean>>;
78
+ onMark: (style: ToolbarMark) => void;
79
+ /** The colour button, when the host hands colours. `run` paints the bar under the A. */
80
+ color?: {
81
+ run?: string;
82
+ open: boolean;
83
+ onToggle: () => void;
84
+ };
85
+ linkOpen: boolean;
86
+ /** The host's own control for row 1's 9th cell. Left out: row 1 is eight
87
+ * buttons, spread over the row. */
88
+ last?: ReactNode;
89
+ alignment?: {
90
+ value: CopyAlign | '';
91
+ allow: readonly CopyAlign[];
92
+ onChange: (next: CopyAlign) => void;
93
+ disabled?: boolean;
94
+ };
95
+ /** The list the selection's lines are in, and the presses. */
96
+ list?: {
97
+ pressed: 'bullet' | 'number' | null;
98
+ onList: (kind: 'bullet' | 'number') => void;
99
+ };
100
+ letterCase?: {
101
+ value: CopyCase | '';
102
+ onChange: (next: CopyCase | '') => void;
103
+ disabled?: boolean;
104
+ };
105
+ disabled?: boolean;
106
+ ariaLabel?: string;
107
+ }
108
+ declare function TextToolbar({ words, align: alignWords, alignmentLabel, offered, pressed, onMark, color, linkOpen, last, alignment, list, letterCase, disabled, ariaLabel, }: TextToolbarProps): react.JSX.Element;
6
109
 
7
110
  /** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
8
111
  * shortcut. Meta is what the tooltips promise (⌘); Ctrl works too. */
@@ -160,6 +263,27 @@ interface CopyBoxFooter {
160
263
  /** Put a literal string where the caret is, replacing any selection. */
161
264
  insert: (text: string) => void;
162
265
  }
266
+ /**
267
+ * What a host needs to draw its OWN control in row 1's 9th cell of the final
268
+ * toolbar ({@link CopyBoxProps.lastTool}) — the campaign designer's Insert
269
+ * (merge tags), owner ruling 2026-10-07. The website editor passes nothing.
270
+ *
271
+ * `className` makes it a cell that looks like its neighbours; `keepCaret` on
272
+ * its mousedown keeps the caret and the selection in the box; `insert` writes
273
+ * at the caret, as {@link CopyBoxFooter.insert} does.
274
+ */
275
+ interface CopyBoxLastTool {
276
+ className: string;
277
+ /** The box is read-only. */
278
+ disabled: boolean;
279
+ /** Words are selected (not just a caret). */
280
+ selected: boolean;
281
+ keepCaret: (e: {
282
+ preventDefault(): void;
283
+ }) => void;
284
+ /** Put a literal string where the caret is, replacing any selection. */
285
+ insert: (text: string) => void;
286
+ }
163
287
  /**
164
288
  * The alignment strip, when the host has an alignment to offer.
165
289
  *
@@ -254,13 +378,186 @@ interface CopyBoxProps {
254
378
  * words, not a column of toolbars.
255
379
  */
256
380
  barShows?: 'always' | 'focus';
381
+ /**
382
+ * Show the EFFECT, not the marks (0.95.0, rulings B + C — the default). A
383
+ * many-line box gets a "Show marks" switch under it that flips to the raw
384
+ * text with its marks and back; a one-line box is always the effect.
385
+ * `false` keeps the 0.94 box (the raw text, painted) with no switch.
386
+ *
387
+ * ⚠️ In the rich view there is no textarea, so {@link inputRef} holds null.
388
+ * Insert at the caret through `renderFooter`'s `insert`, which works in both.
389
+ */
390
+ richText?: boolean;
391
+ /** A many-line box opens with its marks shown. Default false. */
392
+ defaultShowMarks?: boolean;
393
+ /**
394
+ * Which toolbar (E5b). `'final'` — the default — is the design made final
395
+ * on 2026-10-06: two rows on one 9-column grid, B · I · U · S · Color ·
396
+ * Link · Superscript · Subscript · the host's {@link lastTool} (Undo until
397
+ * 2026-10-07) over Left · Center · Right · Justify
398
+ * · Bulleted · Numbered · Aa · AA · aa, with the number {@link cells}
399
+ * between it and the box. `'classic'` is the bar before it (`MarkBar` and
400
+ * the alignment strip), for a host not moved over yet.
401
+ */
402
+ toolbar?: 'final' | 'classic';
403
+ /**
404
+ * The theme colours the colour window offers (final toolbar): the NAME
405
+ * saved in `[words]{color=name}`, what it is called, and its value. The box
406
+ * paints a coloured word with the value (`--es-color-<name>`). The window
407
+ * also offers Any color, saved as a hex (`[words]{color=#rrggbb}`). No colours:
408
+ * no colour button — its cell stays, empty.
409
+ */
410
+ colors?: readonly CopyThemeColor[];
411
+ /** The number cells between the toolbar and the box (final toolbar), each
412
+ * the host's value — see `COPY_CELLS`. None: no cells. */
413
+ cells?: readonly CopyCell[];
414
+ /**
415
+ * The host's letter-case field, set by Aa · AA · aa (final toolbar). The
416
+ * lit one pressed again writes `''`: no case of its own, the style decides.
417
+ * Left out: the three cells stay, empty.
418
+ */
419
+ letterCase?: {
420
+ value: CopyCase | '';
421
+ onChange: (next: CopyCase | '') => void;
422
+ disabled?: boolean;
423
+ };
424
+ /**
425
+ * Row 1's 9th cell of the final toolbar, drawn by the host (owner ruling
426
+ * 2026-10-07: Undo left that cell). Return one control; it is placed in the
427
+ * cell as given. Left out, row 1 is eight buttons spread over the row. See
428
+ * {@link CopyBoxLastTool}.
429
+ */
430
+ lastTool?: (slot: CopyBoxLastTool) => ReactNode;
257
431
  /** A handle on the textarea, for a host that needs one — and the SAME object
258
432
  * the control uses, so there is never a second ref to reconcile. A plain prop
259
433
  * rather than `ref`, for the reason `GoldLayer.layerRef` gives. */
260
434
  inputRef?: TextAreaHandle;
261
435
  }
262
436
 
263
- declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, actions, align, glyphs, barLabel, renderFooter, inputRef, barShows, }: CopyBoxProps): react.JSX.Element;
437
+ declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, actions, align, glyphs, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, toolbar, colors, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
438
+
439
+ /** The clipboard type a copy from this box carries, so a paste back in keeps
440
+ * every mark (the HTML filter keeps only bold, italic and links). */
441
+ declare const MARKUP_CLIPBOARD_TYPE = "application/x-efficient-markup";
442
+ /** What the host can ask of the box, in SAVED offsets. */
443
+ interface RichHandle {
444
+ /** The selection, or null when it is not in the box. */
445
+ getSource(): {
446
+ start: number;
447
+ end: number;
448
+ } | null;
449
+ /** Put the selection here once the box shows `text` (a host may write a
450
+ * commit or more late — the same wait as `useCaretEdit`). */
451
+ setSource(start: number, end: number, text: string): void;
452
+ focus(): void;
453
+ /** The drawn words between two saved offsets, as a DOM range — what the
454
+ * colour and link windows open under. Null before the box is drawn. */
455
+ rangeOf(start: number, end: number): Range | null;
456
+ }
457
+ interface RichBoxProps {
458
+ value: string;
459
+ rules: readonly InlineRule[];
460
+ multiline: boolean;
461
+ readOnly?: boolean;
462
+ placeholder?: string;
463
+ ariaLabel?: string;
464
+ /** Filled with the box's handle. */
465
+ handle: {
466
+ current: RichHandle | null;
467
+ };
468
+ /** The box made an edit. `before` is the saved selection it replaced, for
469
+ * undo; `kind` says whether it may join the previous typing. */
470
+ onEdit(text: string, before: {
471
+ start: number;
472
+ end: number;
473
+ }, kind: 'type' | 'edit'): void;
474
+ /** The selection moved (saved offsets). */
475
+ onSelect(sel: {
476
+ start: number;
477
+ end: number;
478
+ }): void;
479
+ /** The browser's own Undo / Redo (the Edit menu), and its format commands. */
480
+ onHistory(dir: 'undo' | 'redo'): void;
481
+ onFormat(style: MarkStyle): void;
482
+ /** Marks the next typed words gain or lose — a press with nothing selected. */
483
+ pending?: {
484
+ add: readonly MarkStyle[];
485
+ drop: readonly string[];
486
+ color?: string | null;
487
+ };
488
+ onCommit?: (value: string) => void;
489
+ onCancel?: (restored: string) => void;
490
+ }
491
+ declare function RichBox({ value, rules, multiline, readOnly, placeholder, ariaLabel, handle, onEdit, onSelect, onHistory, onFormat, pending, onCommit, onCancel, }: RichBoxProps): react.JSX.Element;
492
+
493
+ /** One line of the rich view. `src` is where its words start in the saved
494
+ * string (after a `- `), `start` where the line itself starts, `vis` where
495
+ * its words start in the visible text. */
496
+ interface RichLine extends MarkedLine {
497
+ start: number;
498
+ src: number;
499
+ vis: number;
500
+ text: string;
501
+ }
502
+ interface RichLayout {
503
+ lines: RichLine[];
504
+ /** The visible words, lines joined by `\n`. */
505
+ text: string;
506
+ }
507
+ declare function richLayout(value: string, rules: readonly InlineRule[]): RichLayout;
508
+ /**
509
+ * A visible offset in the saved string, read as a CARET: after the word before
510
+ * it, so inside any run that word is in (typing there continues the run). At
511
+ * the start of a line it is where the line's words start.
512
+ */
513
+ declare function toSource(layout: RichLayout, v: number): number;
514
+ /** A visible offset read as the START of a selection: at the word it starts
515
+ * on, so a selection's saved range holds its first word's delimiters out. */
516
+ declare function toSourceStart(layout: RichLayout, v: number): number;
517
+ /** A saved-string offset as a visible one. Inside a delimiter it is the word
518
+ * boundary that delimiter sits on. */
519
+ declare function toVisible(layout: RichLayout, s: number): number;
520
+ /** A saved selection as a visible one, and back. */
521
+ declare function selectionToVisible(layout: RichLayout, start: number, end: number): [number, number];
522
+ declare function selectionToSource(layout: RichLayout, a: number, b: number): [number, number];
523
+ /** What to put in. */
524
+ interface RichInsert {
525
+ /** Typed words: they take the marks of the caret (see the header). */
526
+ text?: string;
527
+ /** Pasted markup: its characters keep their own marks and take none. */
528
+ markup?: string;
529
+ /** A press with nothing selected: marks the next typed words gain… */
530
+ add?: readonly MarkStyle[];
531
+ /** …or lose (`highlight` takes the legacy `accent` off too). */
532
+ drop?: readonly string[];
533
+ /** A pending colour (E5b): the next typed words take this theme colour by
534
+ * name, or — `null` — no colour. Left out, they keep the caret's. */
535
+ color?: string | null;
536
+ }
537
+ interface RichEdit {
538
+ text: string;
539
+ /** The visible caret after the edit. */
540
+ caret: number;
541
+ }
542
+ /**
543
+ * Replace the visible words `vs..ve` with `insert`, and say where the caret
544
+ * goes. A `\n` in typed words splits the line; the new line keeps the bullet.
545
+ *
546
+ * A mark the grammar cannot hold is not written — `_it_s` would print its
547
+ * underscores — so typed words fall back to the caret's own marks, and then
548
+ * the words are written however they read.
549
+ */
550
+ declare function editVisible(value: string, rules: readonly InlineRule[], vs: number, ve: number, insert: RichInsert): RichEdit;
551
+ /**
552
+ * Enter. On an empty bullet it ends the list (the bullet comes off, the line
553
+ * stays); anywhere else it splits the line, and a bullet carries on.
554
+ */
555
+ declare function newLine(value: string, rules: readonly InlineRule[], vs: number, ve: number): RichEdit;
556
+ /** Put a line's bullet on or take its list prefix (a bullet or a number)
557
+ * off, keeping its words and the caret. */
558
+ declare function setBullet(value: string, rules: readonly InlineRule[], index: number, on: boolean, caret: number): RichEdit;
559
+ /** The words `vs..ve` as markup, marks and bullets included — for a copy. */
560
+ declare function markupOfRange(value: string, rules: readonly InlineRule[], vs: number, ve: number): string;
264
561
 
265
562
  interface PasteData {
266
563
  /** The clipboard's `text/html`, when there is one. */
@@ -333,4 +630,4 @@ interface CaretEdit {
333
630
  */
334
631
  declare function useCaretEdit({ target, onChange }: CaretEdit): (edit: (el: HTMLInputElement | HTMLTextAreaElement | null) => WrapResult) => void;
335
632
 
336
- export { type CaretEdit, CopyAlign, CopyBox, type CopyBoxAlign, type CopyBoxFooter, type CopyBoxProps, type History, MarkBar, type MarkBarProps, type MarkWriter, type PasteData, type PasteOptions, type SelectionSource, type Snapshot, TYPING_BURST_MS, type TextAreaHandle, type TextBoxHandle, ariaShortcut, createHistory, insertSelection, markSelection, pasteToMarkup, useCaretEdit };
633
+ export { COPY_CELLS, type CaretEdit, ColorWindow, CopyAlign, CopyBox, type CopyBoxAlign, type CopyBoxFooter, type CopyBoxLastTool, type CopyBoxProps, type CopyCase, type CopyCell, type CopyCellPreset, CopyCells, type CopyThemeColor, CopyWords, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type MarkWriter, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInsert, type RichLayout, type RichLine, type SelectionSource, type Snapshot, TYPING_BURST_MS, type TextAreaHandle, type TextBoxHandle, TextToolbar, type TextToolbarProps, type ToolbarMark, ariaShortcut, createHistory, editVisible, insertSelection, markSelection, markupOfRange, newLine, pasteToMarkup, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
@@ -1,10 +1,32 @@
1
- import{DEFAULT_COPY_WORDS as e}from"../chunk-ZT7M24XD.js";import{SettingsSegmented as t}from"../chunk-QB3BZIRA.js";import{GoldTextInput as n}from"../chunk-JYPOOHII.js";import{applyMark as l,STANDARD_MARKUP as r,writeMarkedLines as o,sameMarks as i,markedLines as a,spanFor as s,markupTools as c,findLink as u,markedAt as d,removeLink as p,writeLink as h,isSafeLinkHref as f}from"../chunk-SJQG5ENJ.js";import{useWords as m}from"../chunk-MFIRYGHW.js";import"../chunk-BZ5ASXOL.js";import{AlignSeparateIcon as y,AlignRightIcon as b,AlignCenterIcon as g,AlignLeftIcon as k,ClearMarksIcon as v,LinkIcon as x,QuietIcon as w,EmphasisIcon as C,StrikeIcon as D,ItalicIcon as N,BoldIcon as S}from"../chunk-PI26YXYD.js";import{useRef as j,useLayoutEffect as E,useState as L,useEffect as P,useId as K}from"react";import{jsx as T,jsxs as z,Fragment as $}from"react/jsx-runtime";var A=["left","center","right","justify"],B=e.align,M={left:/* @__PURE__ */T(k,{}),center:/* @__PURE__ */T(g,{}),right:/* @__PURE__ */T(b,{}),justify:/* @__PURE__ */T(y,{})},R={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function I(e,t=B){return A.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:M[e],title:t[e]}))}var Y=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function F(e){if(e.every(e=>e.label===B[e.id]))return e.length>3?R.four:R.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(Y.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function O(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function Z(e,t,n,r=l){const{start:o,end:i}=O(e,n);return r(e,o,i,t)}function q(e,t,n){const{start:l,end:r}=O(e,n),o=l+t.length;return{text:e.slice(0,l)+t+e.slice(r),selectionStart:o,selectionEnd:o}}var H=1e3;function J(e=200){let t=[],n=[],l=null,r=0;return{record(o,i,a){const s="type"===i&&"type"===l&&a-r<1e3;l=i,r=a,n=[],s||(t.push(o),t.length>e&&t.shift())},undo(e){const r=t.pop();return r?(n.push(e),l=null,r):null},redo(e){const r=n.pop();return r?(t.push(e),l=null,r):null},reset(){t=[],n=[],l=null}}}function X({href:t,editing:n,onApply:l,onRemove:r,onClose:o}){const i=m("copy",e).link,a=K(),[s,c]=L(t),[u,d]=L(!1),p=j(null);P(()=>{p.current?.focus(),p.current?.select()},[]);const h=()=>{const e=s.trim();f(e)?l(e):d(!0)};/* @__PURE__ */
2
- return z("div",{role:"dialog","aria-label":i.title,className:"es-copy-link",onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),h()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),o())},children:[
3
- /* @__PURE__ */T("label",{htmlFor:a,className:"es-copy-link-label",children:i.label}),
4
- /* @__PURE__ */T("input",{ref:p,id:a,type:"text",className:"es-copy-link-input",value:s,placeholder:i.placeholder,spellCheck:!1,autoComplete:"off","aria-invalid":u||void 0,"aria-describedby":u?`${a}-why`:void 0,onChange:e=>{c(e.target.value),d(!1)}}),u?/* @__PURE__ */T("p",{id:`${a}-why`,role:"alert",className:"es-copy-link-why",children:i.refused}):null,
5
- /* @__PURE__ */z("div",{className:"es-copy-link-actions",children:[n?/* @__PURE__ */T("button",{type:"button",className:"es-copy-link-btn",onClick:r,children:i.remove}):null,
6
- /* @__PURE__ */T("button",{type:"button",className:"es-copy-link-btn is-primary",onClick:h,disabled:""===s.trim(),children:i.apply})]})]})}var G=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),Q=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function U(e,t){const n=t.rules??r,l=e.html&&""!==e.html.trim()?function(e,t,n){const l=t.createElement("template");l.innerHTML=e;const r=[[]],s=()=>r[r.length-1],c=()=>{const e=s();for(;e.length>0&&" "===e[e.length-1].ch;)e.pop();e.length>0&&r.push([])},u=(e,t,n,l)=>{if(3===e.nodeType){for(const r of e.textContent??""){const e=/\s/.test(r)?" ":r,o=s();(" "!==e||0!==o.length&&" "!==o[o.length-1].ch)&&o.push({ch:e,bold:t,italic:n,href:l})}return}if(1!==e.nodeType&&11!==e.nodeType)return;const o=e,i=1===e.nodeType?o.localName:"";if(G.has(i))return;if("br"===i)return void r.push([]);let a=t,d=n,p=l;if("b"!==i&&"strong"!==i||(a=!0),"i"!==i&&"em"!==i||(d=!0),"a"===i){const e=(o.getAttribute("href")??"").trim();p=f(e)?e:null}const h=1===e.nodeType?o.style:null;if(h){const e=h.fontWeight;"bold"===e||"bolder"===e||Number(e)>=600?a=!0:("normal"===e||"lighter"===e||""!==e&&Number(e)<600)&&(a=!1),"italic"===h.fontStyle||"oblique"===h.fontStyle?d=!0:"normal"===h.fontStyle&&(d=!1)}const m=Q.has(i);m&&c();for(const t of[...e.childNodes])u(t,a,d,p);m&&c()};u(l.content,!1,!1,null);for(;r.length>1&&0===r[r.length-1].length;)r.pop();return r.map(e=>function(e,t){const n=t=>e.map((n,l)=>n[t]&&(" "!==n.ch||Boolean(e[l-1]?.[t])&&Boolean(e[l+1]?.[t]))),l=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const r of l){const l=W(e,r.bold?n("bold"):null,r.italic?n("italic"):null,r.links),s=o([l]).text;if(i([l],a(s,t)))return s}return e.map(e=>e.ch).join("")}(e,n))}(e.html,t.doc,n):(e.text??"").replace(/\r\n?/g,"\n").split("\n");return t.multiline?l.join("\n"):l.map(e=>e.trim()).filter(e=>""!==e).join(" ")}function W(e,t,n,l){let r=0,o=null,i=null,a=null;return{bullet:!1,chars:e.map((e,c)=>{const u=l?e.href:null;return o=null===u?null:o&&o.href===u?o:s(++r,"link",u),i=t?.[c]?i??s(++r,"bold"):null,a=n?.[c]?a??s(++r,"italic"):null,{ch:e.ch,at:-1,marks:[o,i,a].filter(e=>null!==e)}})}}var V={bold:/* @__PURE__ */T(S,{size:16}),italic:/* @__PURE__ */T(N,{size:16}),strike:/* @__PURE__ */T(D,{size:16}),highlight:/* @__PURE__ */T(C,{size:16}),quiet:/* @__PURE__ */T(w,{size:16}),link:/* @__PURE__ */T(x,{size:16}),clear:/* @__PURE__ */T(v,{size:16})};function _(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}var ee={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function te({tools:t,onApply:n,disabled:l=!1,actions:r,align:o,glyphs:i,ariaLabel:a,pressed:s,open:u=null}){const d=m("copy",e),p="string"==typeof t[0]?c(t).map(e=>({...e,...d.marks[e.style]})):t;return 0!==p.length||r||o?/* @__PURE__ */z("div",{className:"es-copy-bar",role:"group","aria-label":a??d.formatting,children:[p.map(e=>{const t=i?.[e.style]??V[e.style],r=u===e.style||Boolean(s?.[e.style]);/* @__PURE__ */
7
- return T("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:l,title:e.title,"aria-label":e.name??e.title,"aria-keyshortcuts":_(e.shortcut),"aria-pressed":s||u?r:void 0,"aria-haspopup":"link"===e.style&&s?"dialog":void 0,"aria-expanded":"link"===e.style&&s?"link"===u:void 0,className:`es-copy-mark${t?" has-glyph":ee[e.style]?` ${ee[e.style]}`:""}${r?" is-active":""}`,children:t??e.label},e.style)}),r?/* @__PURE__ */z($,{children:[
8
- /* @__PURE__ */T("span",{className:"es-copy-bar-split","aria-hidden":"true"}),r]}):null,o?/* @__PURE__ */T("span",{className:"es-copy-bar-end",children:o}):null]}):null}function ne({target:e,onChange:t}){const n=j(null);return E(()=>{const t=n.current,l=e.current;t&&l&&l.value===t.text&&(n.current=null,l.focus(),l.setSelectionRange(t.start,t.end))}),l=>{const r=l(e.current);t(r.text),n.current={start:r.selectionStart,end:r.selectionEnd,text:r.text}}}function le({value:o,onChange:i,onCommit:a,onCancel:s,multiline:f=!1,placeholder:y,ariaLabel:b,className:g,readOnly:k=!1,rules:v,tools:x=[],writeMark:w,actions:C,align:D,glyphs:N,barLabel:S,renderFooter:E,inputRef:K,barShows:$="always"}){const A=m("copy",e),B=j(null),M=K??B,[R,Y]=L(!1),[O,H]=L(null),G=j(J()).current,Q=j(null);P(()=>{const e=Q.current;e&&o===e.to?Q.current=null:e&&o===e.from||(Q.current=null,G.reset())},[o,G]);const W=e=>{Q.current={from:Q.current?.from??o,to:e},i(e)},V=e=>({text:o,start:e?.selectionStart??O?.start??o.length,end:e?.selectionEnd??O?.end??o.length}),_=ne({target:M,onChange:W}),ee=e=>(H({start:e.selectionStart,end:e.selectionEnd}),e),le=e=>_(t=>(G.record(V(t),"edit",Date.now()),ee(e(t)))),[re,oe]=L(null),ie=v??r,ae="string"==typeof x[0]?c(x):x,se=ae.map(e=>e.style),ce={};if(O)for(const e of se)ce[e]="link"===e?null!==u(o,O.start,O.end):d(o,O.start,O.end,e);const ue=e=>{if("clear"===e)return void le(t=>Z(o,e,t,(e,t,n)=>l(e,t,n,"clear",ie)));if("link"!==e){const t=w??((e,t,n,o)=>l(e,t,n,o,r,A.placeholders));return void le(n=>Z(o,e,n,t))}const t=M.current,n=t?.selectionStart??o.length,i=t?.selectionEnd??n;oe({start:n,end:i,link:u(o,n,i)})},de=D?I(D.allow,A.align):[];/* @__PURE__ */
9
- return z("div",{className:"es-copy"+(g?` ${g}`:""),onFocus:()=>Y(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||Y(!1)},onKeyDown:e=>{if(k||e.target!==M.current)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const t=e.key.toLowerCase(),n="KeyZ"===e.code||"z"===t,l=("KeyY"===e.code||"y"===t)&&!e.shiftKey;if(n||l)return e.preventDefault(),e.stopPropagation(),r=l||e.shiftKey?"redo":"undo",void _(e=>{const t=V(e),n=G[r](t);return ee(n?{text:n.text,selectionStart:n.start,selectionEnd:n.end}:{text:t.text,selectionStart:t.start,selectionEnd:t.end})});var r;const o=`${e.shiftKey?"shift+":""}${t}`,i=ae.find(e=>e.shortcut===o);i&&(e.preventDefault(),e.stopPropagation(),ue(i.style))},onPaste:e=>{const t=M.current;if(k||!t||e.target!==t)return;e.preventDefault();const n=U({html:e.clipboardData.getData("text/html"),text:e.clipboardData.getData("text/plain")},{doc:t.ownerDocument,multiline:f,rules:ie});le(e=>q(o,n,e))},onSelect:()=>{const e=M.current;e&&e.ownerDocument.activeElement===e&&H({start:e.selectionStart??o.length,end:e.selectionEnd??o.length})},children:["always"===$||R||null!==re?/* @__PURE__ */T(te,{tools:x,disabled:k,actions:C,glyphs:N,ariaLabel:S,pressed:ce,open:re?"link":null,onApply:ue,align:D?/* @__PURE__ */T(t,{options:de,value:D.value,onChange:D.onChange,ariaLabel:A.alignment,disabled:k||D.disabled,fit:F(de)}):null}):null,
10
- /* @__PURE__ */T(n,{value:o,onInput:e=>{G.record(V(null),"type",Date.now()),W(e)},onCommit:a,onCancel:s,multiline:f,placeholder:y,ariaLabel:b,rules:v,disabled:k,inputRef:M,className:"es-copy-box"}),re?/* @__PURE__ */T(X,{href:re.link?.href??"",editing:null!==re.link,onApply:e=>{const t=re;oe(null),le(()=>h(o,t.start,t.end,e))},onRemove:()=>{const e=re.link;oe(null),e&&le(()=>p(o,e))},onClose:()=>{oe(null),M.current?.focus()}}):null,E?E({focused:R,insert:e=>le(t=>q(o,e,t))}):null]})}export{A as COPY_ALIGNS,R as COPY_ALIGN_FIT,M as COPY_ALIGN_GLYPHS,B as COPY_ALIGN_LABELS,le as CopyBox,te as MarkBar,H as TYPING_BURST_MS,_ as ariaShortcut,I as copyAlignOptions,J as createHistory,q as insertSelection,Z as markSelection,U as pasteToMarkup,ne as useCaretEdit};
1
+ import{ColourWindow as e}from"../chunk-H24N5TMZ.js";import{DEFAULT_COPY_WORDS as t}from"../chunk-UH7IGZKF.js";import{DEFAULT_PICK_WORDS as n}from"../chunk-ZAOM6PFH.js";import{FieldNumber as l}from"../chunk-EWVJSRRY.js";import{SettingsSegmented as r,SettingsSwitch as o}from"../chunk-P6O363EE.js";import"../chunk-FPOKPNO4.js";import{GoldTextInput as a}from"../chunk-2FZJWH24.js";import{RETIRED_MARKS as s,applyMark as i,STANDARD_MARKUP as c,writeMarkedLines as u,sameMarks as d,markedLines as h,spanFor as p,markupTools as f,marksIn as m,findLink as b,markedAt as g,listIn as y,colorIn as v,clearStyle as k,isSafeLinkHref as x,toggleMark as w,colorOver as C,setList as E,unlinkAt as S,removeLink as D,linkOver as N,writeLink as M}from"../chunk-546BBOPE.js";import{useWords as L}from"../chunk-MFIRYGHW.js";import"../chunk-BZ5ASXOL.js";import{AlignJustifyIcon as T,AlignRightIcon as j,AlignCenterIcon as B,AlignLeftIcon as O,ParagraphSpacingIcon as R,LetterSpacingIcon as P,TextLinesIcon as K,TextSizeIcon as F,CaseNormalIcon as H,CaseUpperIcon as W,CaseLowerIcon as $,TextColorIcon as z,ListIcon as I,NumberedListIcon as A,ClearMarksIcon as q,BoldIcon as U,ItalicIcon as V,UnderlineIcon as Z,StrikeIcon as Y,LinkIcon as G,SuperscriptIcon as J,SubscriptIcon as X,QuietIcon as Q,EmphasisIcon as _}from"../chunk-L5KW4HG5.js";import{useRef as ee,useState as te,useLayoutEffect as ne,useEffect as le,useId as re}from"react";import{jsx as oe,jsxs as ae,Fragment as se}from"react/jsx-runtime";var ie=["left","center","right","justify"],ce=t.align,ue={left:/* @__PURE__ */oe(O,{}),center:/* @__PURE__ */oe(B,{}),right:/* @__PURE__ */oe(j,{}),justify:/* @__PURE__ */oe(T,{})},de={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function he(e,t=ce){return ie.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:ue[e],title:t[e]}))}var pe=/[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;function fe(e){if(e.every(e=>e.label===ce[e.id]))return e.length>3?de.four:de.three;const t=e.map(e=>[...e.label].reduce((e,t)=>e+(pe.test(t)?13:8),0));return{labelsPx:t.reduce((e,t)=>e+t,0),widestLabelPx:Math.max(0,...t)}}function me(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function be(e,t,n,l=i){const{start:r,end:o}=me(e,n);return l(e,r,o,t)}function ge(e,t,n){const{start:l,end:r}=me(e,n),o=l+t.length;return{text:e.slice(0,l)+t+e.slice(r),selectionStart:o,selectionEnd:o}}var ye=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),ve=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function ke(e,t){const n=t.rules??c,l=e.html&&""!==e.html.trim()?function(e,t,n){const l=t.createElement("template");l.innerHTML=e;const r=[[]],o=()=>r[r.length-1],a=()=>{const e=o();for(;e.length>0&&" "===e[e.length-1].ch;)e.pop();e.length>0&&r.push([])},s=(e,t,n,l)=>{if(3===e.nodeType){for(const a of e.textContent??""){const e=/\s/.test(a)?" ":a,s=o();" "===e&&(0===s.length&&r.length>1||" "===s[s.length-1]?.ch)||s.push({ch:e,bold:t,italic:n,href:l})}return}if(1!==e.nodeType&&11!==e.nodeType)return;const i=e,c=1===e.nodeType?i.localName:"";if(ye.has(c))return;if("br"===c)return void r.push([]);let u=t,d=n,h=l;if("b"!==c&&"strong"!==c||(u=!0),"i"!==c&&"em"!==c||(d=!0),"a"===c){const e=(i.getAttribute("href")??"").trim();h=x(e)?e:null}const p=1===e.nodeType?i.style:null;if(p){const e=p.fontWeight;"bold"===e||"bolder"===e||Number(e)>=600?u=!0:("normal"===e||"lighter"===e||""!==e&&Number(e)<600)&&(u=!1),"italic"===p.fontStyle||"oblique"===p.fontStyle?d=!0:"normal"===p.fontStyle&&(d=!1)}const f=ve.has(c);f&&a();for(const t of[...e.childNodes])s(t,u,d,h);f&&a()};s(l.content,!1,!1,null);for(;r.length>1&&0===r[r.length-1].length;)r.pop();return r.map(e=>function(e,t){const n=t=>e.map((n,l)=>n[t]&&(" "!==n.ch||Boolean(e[l-1]?.[t])&&Boolean(e[l+1]?.[t]))),l=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const r of l){const l=xe(e,r.bold?n("bold"):null,r.italic?n("italic"):null,r.links),o=u([l]).text;if(d([l],h(o,t)))return o}return e.map(e=>e.ch).join("")}(e,n))}(e.html,t.doc,n):(e.text??"").replace(/\r\n?/g,"\n").split("\n");return t.multiline?l.join("\n"):1===l.length?l[0]:l.map(e=>e.trim()).filter(e=>""!==e).join(" ")}function xe(e,t,n,l){let r=0,o=null,a=null,s=null;return{bullet:!1,chars:e.map((e,i)=>{const c=l?e.href:null;return o=null===c?null:o&&o.href===c?o:p(++r,"link",c),a=t?.[i]?a??p(++r,"bold"):null,s=n?.[i]?s??p(++r,"italic"):null,{ch:e.ch,at:-1,marks:[o,a,s].filter(e=>null!==e)}})}}var we=/^([0-9]{1,3})\. $/;function Ce(e,t){const n=e.split("\n"),l=h(e,t);let r=0,o=0;const a=l.map((e,t)=>{const l=!e.bullet&&null==e.number&&"- "===n[t],a=null!=e.number||e.bullet?null:we.exec(n[t]),s=e.bullet||l,i=a?a[1]:e.number??null,c=l||a?[]:e.chars,u=c.map(e=>e.ch).join(""),d=null!=i?i.length+2:s?2:0,h={bullet:s,number:i,chars:c,start:r,src:r+d,vis:o,text:u};return r+=n[t].length+1,o+=u.length+1,h});return{lines:a,text:a.map(e=>e.text).join("\n")}}function Ee(e,t){const{lines:n}=e;for(let e=0;e<n.length;e+=1){const l=n[e];if(t<=l.vis+l.text.length||e===n.length-1)return[l,Math.max(0,Math.min(t-l.vis,l.text.length)),e]}return[n[0],0,0]}function Se(e,t){const[n,l]=Ee(e,t);if(0===l)return n.src;let r=0;for(const e of n.chars){if(l<=r+e.ch.length)return e.at+(l-r);r+=e.ch.length}return n.src}function De(e,t){const[n,l]=Ee(e,t);let r=0;for(const e of n.chars){if(l===r)return e.at;r+=e.ch.length}return Se(e,t)}function Ne(e,t){const{lines:n}=e;let l=n[0];for(const e of n)t>=e.start&&(l=e);let r=0;for(const e of l.chars){if(!(t>=e.at+e.ch.length)){t>e.at&&(r+=t-e.at);break}r+=e.ch.length}return l.vis+r}function Me(e,t,n){return[Ne(e,t),Ne(e,n)]}function Le(e,t,n){return t===n?[Se(e,t),Se(e,t)]:[De(e,t),Se(e,n)]}function Te(e,t){let n=0;for(let l=0;l<e.chars.length;l+=1){if(n>=t)return l;n+=e.chars[l].ch.length}return e.chars.length}function je(e,t,n,l,r){const o=Ce(e,t),[a,s,i]=Ee(o,Math.min(n,l)),[c,f,m]=Ee(o,Math.max(n,l)),b=Te(a,s),g=Te(c,f),y=a.chars.slice(0,b),v=c.chars.slice(g),k=n!==l&&a.chars[b]&&(i!==m||b<g)?a.chars[b].marks:function(e,t){const n=e.chars[t-1],l=e.chars[t],r=(e,t)=>{const n=e.findIndex(e=>"link"===e.kind);return-1===n||t?e:e.slice(0,n)};if(n){const e=n.marks.find(e=>"link"===e.kind),t=Boolean(e&&l?.marks.some(t=>t.id===e.id));return r(n.marks,t)}return l?r(l.marks,!1):[]}(a,b);let x=(w=o.lines,Math.max(0,...w.flatMap(e=>e.chars.flatMap(e=>e.marks.map(e=>e.id))))+1);var w;const C=e=>{let n;if(void 0!==r.markup){const e=x;n=h(r.markup,t).map(t=>({bullet:t.bullet,number:t.number??null,chars:t.chars.map(t=>({...t,at:-1,marks:t.marks.map(t=>({...t,id:t.id+e}))}))}))}else{let t=a.number??null;n=(r.text??"").split("\n").map((n,l)=>(l>0&&null!=t&&(t=function(e){return String(Number(e)+1).padStart(e.length,"0")}(t)),{bullet:a.bullet,number:t,chars:[...n].map(t=>({ch:t,at:-1,marks:e??[]}))}))}const l=n.map(e=>e.chars.map(e=>e.ch).join("")).join("\n"),s={bullet:a.bullet,number:a.number??null,chars:[...y,...n[0].chars]},c=n.slice(1);if(c.length>0){const e=c[c.length-1];c[c.length-1]={...e,chars:[...e.chars,...v]}}else s.chars.push(...v);return{lines:[...o.lines.slice(0,i).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n})),s,...c,...o.lines.slice(m+1).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n}))],shown:l}},E=void 0!==r.markup?[null]:[(e=>{let t=e.filter(e=>!r.drop?.some(t=>e.kind===t||"highlight"===t&&"accent"===e.kind));for(const e of r.add??[]){if(t.some(t=>t.kind===e))continue;const n=p(x++,e);n&&(t=[...t,n])}if(void 0!==r.color){t=t.filter(e=>"color"!==e.kind);const e=null===r.color?null:p(x++,"color",r.color);e&&(t=[...t,e])}return t})(k),k,[]];let S="",D="";for(const e of E){const n=C(e),l=u(n.lines).text;if(S=l,D=n.shown,d(n.lines,Ce(l,t).lines))break}return{text:S,caret:Math.min(n,l)+D.length}}function Be(e,t,n,l){const r=Ce(e,t),[o,,a]=Ee(r,n);return n!==l||!o.bullet&&null==o.number||""!==o.text?je(e,t,n,l,{text:"\n"}):Oe(e,t,a,!1,n)}function Oe(e,t,n,l,r){const o=Ce(e,t).lines.map(({bullet:e,number:t,chars:r},o)=>o===n?{bullet:l,number:null,chars:r}:{bullet:e,number:t,chars:r});return{text:u(o).text,caret:r}}function Re(e,t,n,l){const r=Ce(e,t),[o,a,s]=Ee(r,Math.min(n,l)),[i,c,d]=Ee(r,Math.max(n,l)),h=r.lines.slice(s,d+1).map(({bullet:e,number:t,chars:n},l)=>{const r=0===l?Te(o,a):0,u=l===d-s?Te(i,c):n.length;return{bullet:e,number:t,chars:n.slice(r,u)}});return u(h).text}var Pe="application/x-efficient-markup";function Ke(e,t,n,l){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",l&&(t.dataset.color=l,t.title=l.startsWith("#")?l.toUpperCase():l,t.style.color=l.startsWith("#")?l:`var(--es-color-${l}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Fe(e,t,n,l){const r=e.layout.lines;if(n===t)return l>=e.lines.length?e.layout.text.length:r[l].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,l)}catch{return r[o].vis}return r[o].vis+Math.min(a.toString().length,r[o].text.length)}function He(e,t){const n=e.layout.lines;let l=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){l=e;break}let r=Math.max(0,t-n[l].vis);const o=e.lines[l].ownerDocument.createTreeWalker(e.lines[l],4);let a=o.nextNode(),s=null;for(;a;){if(r<=a.data.length)return[a,r];r-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[l],0]}function We(e,t,n){if(n<0){const n=e.charCodeAt(t-1);return t-(n>=56320&&n<=57343&&t>=2?2:1)}const l=e.charCodeAt(t);return t+(l>=55296&&l<=56319?2:1)}function $e({value:e,rules:t,multiline:n,readOnly:l=!1,placeholder:r,ariaLabel:o,handle:a,onEdit:s,onSelect:i,onHistory:c,onFormat:u,pending:d,onCommit:h,onCancel:p}){const f=ee(null),m=ee(null),b=ee(null),g=ee(null),y=ee(null),v=ee(e),[k,x]=te(0),w=ee({value:e,rules:t,multiline:n,readOnly:l,pending:d,onEdit:s,onHistory:c,onFormat:u});w.current={value:e,rules:t,multiline:n,readOnly:l,pending:d,onEdit:s,onHistory:c,onFormat:u};const C=()=>{const e=f.current,t=m.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const l=Fe(t,e,n.anchorNode,n.anchorOffset),r=n.focusNode&&e.contains(n.focusNode)?Fe(t,e,n.focusNode,n.focusOffset):l;return l<=r?[l,r]:[r,l]},E=(e,t)=>{const n=f.current,l=m.current;if(!n||!l)return;const[r,o]=He(l,e),[a,s]=He(l,t);n.ownerDocument.getSelection()?.setBaseAndExtent(r,o,a,s)};a.current={getSource(){const e=C(),t=m.current;if(!e||!t)return null;const[n,l]=Le(t.layout,e[0],e[1]);return{start:n,end:l}},setSource(e,t,n){g.current={text:n,src:[e,t]},x(e=>e+1)},focus(){f.current?.focus()},rangeOf(e,t){const n=f.current,l=m.current;if(!n||!l)return null;const[r,o]=Me(l.layout,e,t),[a,s]=He(l,r),[i,c]=He(l,o),u=n.ownerDocument.createRange();return u.setStart(a,s),u.setEnd(i,c),u}},ne(()=>{const n=f.current;if(!n||y.current)return;const l=g.current?null:C();m.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const l=t.lines.map(t=>{const l=n.createElement("div");l.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(l.dataset.number=t.number);const r=[],o=()=>r.length?r[r.length-1].el:l;let a=null;for(const e of t.chars){let t=0;for(;t<r.length&&t<e.marks.length&&r[t].id===e.marks[t].id;)t+=1;(r.length>t||e.marks.length>t)&&(a=null),r.length=t;for(let l=t;l<e.marks.length;l+=1){const t=Ke(n,e.marks[l].kind,e.marks[l].href,e.marks[l].color);o().appendChild(t),r.push({id:e.marks[l].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&l.appendChild(n.createElement("br")),e.appendChild(l),l});return{layout:t,lines:l}}(n,Ce(e,t)),b.current=e;const r=g.current;if(!r||r.text!==e)return void(l&&n.ownerDocument.activeElement===n&&E(l[0],Math.min(l[1],m.current.layout.text.length)));g.current=null;const o=m.current.layout,[a,s]=r.vis??Me(o,r.src[0],r.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),E(a,s)},[e,t,k]);const S=(e,t,n)=>{const l=m.current,[r,o]=Le(l.layout,t[0],t[1]);g.current={text:e.text,vis:[e.caret,e.caret]},e.text!==w.current.value?w.current.onEdit(e.text,{start:r,end:o},n):x(e=>e+1)};le(()=>{const e=f.current;if(!e)return;const t=t=>{const{value:n,rules:l,multiline:r,readOnly:o,pending:a}=w.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=m.current,i=C();if(!s||!i)return;let[c,u]=i;const d="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0;d&&!d.collapsed&&t.inputType.startsWith("delete")&&(c=Fe(s,e,d.startContainer,d.startOffset),u=Fe(s,e,d.endContainer,d.endOffset));const h=s.layout.text,p=t.inputType;if("historyUndo"!==p&&"historyRedo"!==p)if("formatBold"!==p&&"formatItalic"!==p&&"formatStrikeThrough"!==p)if("insertParagraph"!==p&&"insertLineBreak"!==p){if(p.startsWith("insert")){let o=t.data??t.dataTransfer?.getData("text/plain")??"";if("insertFromDrop"===p||"insertFromPaste"===p){const a=ke({html:t.dataTransfer?.getData("text/html"),text:o},{doc:e.ownerDocument,multiline:r,rules:l});return void S(je(n,l,c,u,{markup:a}),[c,u],"edit")}return r||(o=o.replace(/\s*\r?\n\s*/g," ")),void S(je(n,l,c,u,{text:o,add:a?.add,drop:a?.drop,color:a?.color}),[c,u],"type")}if(p.startsWith("delete")){if(c===u){const e=p.includes("Backward"),t=s.layout.lines.findIndex(e=>c>=e.vis&&c<=e.vis+e.text.length),r=s.layout.lines[t];if(e&&r&&c===r.vis&&(r.bullet||null!=r.number))return void S(Oe(n,l,t,!1,c),[c,u],"edit");if(e?0===c:c===h.length)return;e?c=We(h,c,-1):u=We(h,u,1)}S(je(n,l,c,u,{text:""}),[c,u],"type")}}else r&&S(Be(n,l,c,u),[c,u],"edit");else w.current.onFormat("formatBold"===p?"bold":"formatItalic"===p?"italic":"strike");else w.current.onHistory("historyUndo"===p?"undo":"redo")},n=()=>{y.current||x(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),le(()=>{const e=f.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=a.current?.getSource();e&&i(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const D=(n,r=!1)=>{const o=C();if(!o||o[0]===o[1])return;n.preventDefault();const a=m.current;n.clipboardData.setData("text/plain",a.layout.text.slice(o[0],o[1])),n.clipboardData.setData(Pe,Re(e,t,o[0],o[1])),r&&!l&&S(je(e,t,o[0],o[1],{text:""}),o,"edit")};/* @__PURE__ */
2
+ return ae("div",{className:"es-rich-wrap",children:[r&&""===e?/* @__PURE__ */oe("div",{className:"es-rich-placeholder","aria-hidden":"true",children:r}):null,
3
+ /* @__PURE__ */oe("div",{ref:f,className:`es-rich${n?" is-multiline":" is-single"}${l?" is-off":""}`,contentEditable:!l,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":n,"aria-label":o,"aria-readonly":l||void 0,"aria-placeholder":r,tabIndex:l?-1:0,spellCheck:!0,onFocus:()=>{v.current=e},onBlur:()=>{e!==v.current&&h?.(e),v.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),p?.(v.current),void(v.current=e);"Enter"!==t.key||n||(t.preventDefault(),e!==v.current&&h?.(e),v.current=e)},onCompositionStart:()=>{const e=C()??[0,0];y.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=y.current;if(y.current=null,!t)return;const{value:n,rules:l,pending:r}=w.current;e.data?S(je(n,l,t.from,t.to,{text:e.data,add:r?.add,drop:r?.drop,color:r?.color}),[t.from,t.to],"type"):x(e=>e+1)},onCopy:e=>D(e),onCut:e=>D(e,!0),onPaste:r=>{if(r.preventDefault(),l)return;const o=C();if(!o)return;const a=r.clipboardData.getData(Pe),s=a?n?a:a.replace(/\s*\r?\n\s*/g," "):ke({html:r.clipboardData.getData("text/html"),text:r.clipboardData.getData("text/plain")},{doc:r.currentTarget.ownerDocument,multiline:n,rules:t});S(je(e,t,o[0],o[1],{markup:s}),o,"edit")}})]})}var ze=1e3;function Ie(e=200){let t=[],n=[],l=null,r=0;return{record(o,a,s){const i="type"===a&&"type"===l&&s-r<1e3;l=a,r=s,n=[],i||(t.push(o),t.length>e&&t.shift())},undo(e){const r=t.pop();return r?(n.push(e),l=null,r):null},redo(e){const r=n.pop();return r?(t.push(e),l=null,r):null},reset(){t=[],n=[],l=null}}}var Ae={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */oe(F,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */oe(K,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */oe(P,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */oe(R,{}),unit:"px",step:1,shiftStep:10,min:0}};function qe(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Ue({cells:e,words:n,readOnly:r=!1}){const o=n??t.cells;/* @__PURE__ */
4
+ return oe("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,n=e.name??(e.nameKey?o[e.nameKey]:e.key),a=e.unit??"",s=e.step??1;/* @__PURE__ */
5
+ return oe(l,{value:qe(e.value,t),styleValue:qe(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:a||void 0,steppers:!0,readOnly:r,ariaLabel:n,title:o.tip({name:n,step:s,unit:a})},e.key)})})}var Ve=e=>e.preventDefault();function Ze({colors:t,current:l,words:r,onPick:o}){const a=null===l?null:l.startsWith("#")?l.toLowerCase():t.find(e=>e.name===l)?.value.toLowerCase()??null;/* @__PURE__ */
6
+ return ae("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":r.title,onMouseDown:e=>{e.target instanceof HTMLInputElement||e.preventDefault()},children:[
7
+ /* @__PURE__ */oe("span",{className:"es-copy-pop-label",children:r.theme}),
8
+ /* @__PURE__ */oe("div",{className:"es-pick-theme",role:"group","aria-label":r.theme,children:t.map(e=>/* @__PURE__ */oe("button",{type:"button",className:"es-pick-theme-swatch","data-color":e.name,"aria-label":e.label,title:`${e.label} · ${e.value.toUpperCase()}`,"aria-pressed":l===e.name,style:{background:e.value},onMouseDown:Ve,onClick:()=>o(e.name)},e.name))}),
9
+ /* @__PURE__ */oe("span",{className:"es-copy-pop-label",children:r.any}),
10
+ /* @__PURE__ */oe(e,{value:a??"",onChange:e=>{e!==l&&o(e)},label:r.title,swatch:!0,dragWrites:"end",words:{...n.colour,dialog:()=>r.any,square:r.square,hue:r.hue,hex:()=>r.hex}}),
11
+ /* @__PURE__ */oe("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn is-danger",onMouseDown:Ve,onClick:()=>o(null),children:r.remove})})]})}function Ye({href:e,editing:n,onApply:l,onRemove:r,onClose:o,floating:a=!1}){const s=L("copy",t).link,i=re(),[c,u]=te(e),[d,h]=te(!1),p=ee(null);le(()=>{p.current?.focus(),p.current?.select()},[]);const f=()=>{const e=c.trim();x(e)?l(e):h(!0)};/* @__PURE__ */
12
+ return ae("div",{role:"dialog","aria-label":s.title,className:"es-copy-link"+(a?" es-copy-pop":""),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),f()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),o())},children:[
13
+ /* @__PURE__ */oe("label",{htmlFor:i,className:"es-copy-link-label",children:s.label}),
14
+ /* @__PURE__ */oe("input",{ref:p,id:i,type:"text",className:"es-copy-link-input",value:c,placeholder:s.placeholder,spellCheck:!1,autoComplete:"off","aria-invalid":d||void 0,"aria-describedby":d?`${i}-why`:void 0,onChange:e=>{u(e.target.value),h(!1)}}),d?/* @__PURE__ */oe("p",{id:`${i}-why`,role:"alert",className:"es-copy-link-why",children:s.refused}):null,
15
+ /* @__PURE__ */ae("div",{className:"es-copy-link-actions",children:[n?/* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn is-danger",onClick:r,children:s.remove}):null,
16
+ /* @__PURE__ */ae("span",{className:"es-copy-link-end",children:[
17
+ /* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn",onClick:o,children:s.cancel??t.link.cancel}),
18
+ /* @__PURE__ */oe("button",{type:"button",className:"es-copy-link-btn is-primary",onClick:f,disabled:""===c.trim(),children:s.apply})]})]})]})}var Ge=e=>e.preventDefault();function Je(){/* @__PURE__ */
19
+ return oe("span",{className:"es-tb-cell is-empty","aria-hidden":"true"})}function Xe({words:e,align:t,alignmentLabel:n,offered:l,pressed:r,onMark:o,color:a,linkOpen:s,last:i,alignment:c,list:u,letterCase:d,disabled:h=!1,ariaLabel:p="Formatting"}){const f=(e,t,n,a)=>l.has(e)?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn"+(r[e]||"link"===e&&s?" is-on":""),"aria-label":t,title:t,"aria-pressed":"link"===e?void 0:Boolean(r[e]),"aria-haspopup":"link"===e?"dialog":void 0,"aria-expanded":"link"===e?s:void 0,"aria-keyshortcuts":a,disabled:h,onMouseDown:Ge,onClick:()=>o(e),children:n},e):/* @__PURE__ */oe(Je,{},e),m=[["left",/* @__PURE__ */oe(O,{},"l")],["center",/* @__PURE__ */oe(B,{},"c")],["right",/* @__PURE__ */oe(j,{},"r")],["justify",/* @__PURE__ */oe(T,{},"j")]],b=[["none",e.caseNone,/* @__PURE__ */oe(H,{},"n")],["upper",e.caseUpper,/* @__PURE__ */oe(W,{},"u")],["lower",e.caseLower,/* @__PURE__ */oe($,{},"w")]];/* @__PURE__ */
20
+ return ae("div",{className:"es-tb",role:"toolbar","aria-label":p,children:[
21
+ /* @__PURE__ */ae("div",{className:"es-tb-row"+(void 0===i?" is-eight":""),children:[f("bold",e.bold,/* @__PURE__ */oe(U,{}),"Meta+B"),f("italic",e.italic,/* @__PURE__ */oe(V,{}),"Meta+I"),f("underline",e.underline,/* @__PURE__ */oe(Z,{}),"Meta+U"),f("strike",e.strike,/* @__PURE__ */oe(Y,{})),a?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn es-tb-color"+(a.open?" is-on":""),"aria-label":e.color,title:e.color,"aria-haspopup":"dialog","aria-expanded":a.open,disabled:h,style:a.run?{"--es-tb-run":a.run}:void 0,onMouseDown:Ge,onClick:a.onToggle,children:/* @__PURE__ */oe(z,{})}):/* @__PURE__ */oe(Je,{}),f("link",e.link,/* @__PURE__ */oe(G,{}),"Meta+K"),f("sup",e.sup,/* @__PURE__ */oe(J,{})),f("sub",e.sub,/* @__PURE__ */oe(X,{})),void 0!==i?i??/* @__PURE__ */oe(Je,{}):null]}),
22
+ /* @__PURE__ */ae("div",{className:"es-tb-row",children:[
23
+ /* @__PURE__ */oe("div",{className:"es-tb-group",role:"radiogroup","aria-label":n,children:m.map(([e,n])=>c&&c.allow.includes(e)?/* @__PURE__ */oe("button",{type:"button",role:"radio",className:"es-tb-cell es-tb-btn"+(c.value===e?" is-on":""),"aria-checked":c.value===e,"aria-label":t[e],title:t[e],disabled:h||c.disabled,onMouseDown:Ge,onClick:()=>c.onChange(e),children:n},e):/* @__PURE__ */oe(Je,{},e))}),u&&l.has("bullet")?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn"+("bullet"===u.pressed?" is-on":""),"aria-label":e.bullet,title:e.bullet,"aria-pressed":"bullet"===u.pressed,disabled:h,onMouseDown:Ge,onClick:()=>u.onList("bullet"),children:/* @__PURE__ */oe(I,{})}):/* @__PURE__ */oe(Je,{}),u&&l.has("number")?/* @__PURE__ */oe("button",{type:"button",className:"es-tb-cell es-tb-btn"+("number"===u.pressed?" is-on":""),"aria-label":e.number,title:e.number,"aria-pressed":"number"===u.pressed,disabled:h,onMouseDown:Ge,onClick:()=>u.onList("number"),children:/* @__PURE__ */oe(A,{})}):/* @__PURE__ */oe(Je,{}),
24
+ /* @__PURE__ */oe("div",{className:"es-tb-group",role:"radiogroup","aria-label":e.letterCase,children:b.map(([e,t,n])=>d?/* @__PURE__ */oe("button",{type:"button",role:"radio",className:"es-tb-cell es-tb-btn"+(d.value===e?" is-on":""),"aria-checked":d.value===e,"aria-label":t,title:t,disabled:h||d.disabled,onMouseDown:Ge,onClick:()=>d.onChange(d.value===e?"":e),children:n},e):/* @__PURE__ */oe(Je,{},e))})]})]})}var Qe=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var _e=e=>({left:e.left,top:e.top,right:e.right,bottom:e.bottom});function et(e){const t=e.ownerDocument,n=t.documentElement,l={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},r=t.defaultView?.getComputedStyle.bind(t.defaultView);for(let o=e.parentElement;o&&o!==n&&o!==t.body;o=o.parentElement){const e=r?.(o);if(!e||"visible"===e.overflowX&&"visible"===e.overflowY)continue;const t=o.getBoundingClientRect();if(0===t.width&&0===t.height)continue;const n=t.left+o.clientLeft,a=t.top+o.clientTop;l.left=Math.max(l.left,n),l.top=Math.max(l.top,a),l.right=Math.min(l.right,n+(o.clientWidth||t.width)),l.bottom=Math.min(l.bottom,a+(o.clientHeight||t.height))}return l}function tt(e){const t=e.offsetParent??e.parentElement;if(!t)return{left:0,top:0};const n=t.getBoundingClientRect();return{left:n.left+t.clientLeft-t.scrollLeft,top:n.top+t.clientTop-t.scrollTop}}var nt=/* @__PURE__ */new Set([...s,"clear"]),lt={bold:/* @__PURE__ */oe(U,{size:16}),italic:/* @__PURE__ */oe(V,{size:16}),strike:/* @__PURE__ */oe(Y,{size:16}),highlight:/* @__PURE__ */oe(_,{size:16}),quiet:/* @__PURE__ */oe(Q,{size:16}),link:/* @__PURE__ */oe(G,{size:16}),clear:/* @__PURE__ */oe(q,{size:16})};function rt(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}var ot={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function at({tools:e,onApply:n,disabled:l=!1,actions:r,align:o,glyphs:a,ariaLabel:s,pressed:i,open:c=null}){const u=L("copy",t),d=("string"==typeof e[0]?f(e).map(e=>({...e,...u.marks[e.style]})):e).filter(e=>!nt.has(e.style));return 0!==d.length||r||o?/* @__PURE__ */ae("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=a?.[e.style]??lt[e.style],r=c===e.style||Boolean(i?.[e.style]);/* @__PURE__ */
25
+ return oe("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:l,title:e.title,"aria-label":e.name??e.title,"aria-keyshortcuts":rt(e.shortcut),"aria-pressed":i||c?r:void 0,"aria-haspopup":"link"===e.style&&i?"dialog":void 0,"aria-expanded":"link"===e.style&&i?"link"===c:void 0,className:`es-copy-mark${t?" has-glyph":ot[e.style]?` ${ot[e.style]}`:""}${r?" is-active":""}`,children:t??e.label},e.style)}),r?/* @__PURE__ */ae(se,{children:[
26
+ /* @__PURE__ */oe("span",{className:"es-copy-bar-split","aria-hidden":"true"}),r]}):null,o?/* @__PURE__ */oe("span",{className:"es-copy-bar-end",children:o}):null]}):null}function st({target:e,onChange:t}){const n=ee(null);return ne(()=>{const t=n.current,l=e.current;t&&l&&l.value===t.text&&(n.current=null,l.focus(),l.setSelectionRange(t.start,t.end))}),l=>{const r=l(e.current);t(r.text),n.current={start:r.selectionStart,end:r.selectionEnd,text:r.text}}}function it({value:e,onChange:n,onCommit:l,onCancel:s,multiline:u=!1,placeholder:d,ariaLabel:h,className:x,readOnly:T=!1,rules:j,tools:B=[],writeMark:O,actions:R,align:P,glyphs:K,barLabel:F,renderFooter:H,inputRef:W,barShows:$="always",richText:z=!0,defaultShowMarks:I=!1,toolbar:A="final",colors:U,cells:V,letterCase:Z,lastTool:Y}){const G="final"===A,J=L("copy",t),X=ee(null),Q=W??X,[_,ie]=te(!1),[ce,ue]=te(null),de=ee(Ie()).current,pe=ee(null);le(()=>{const t=pe.current;t&&e===t.to?pe.current=null:t&&e===t.from||(pe.current=null,de.reset())},[e,de]);const me=t=>{pe.current={from:pe.current?.from??e,to:t},n(t)},ye=t=>({text:e,start:t?.selectionStart??ce?.start??e.length,end:t?.selectionEnd??ce?.end??e.length}),[ve,xe]=te(I),we=z&&!(u&&ve),Ce=ee(null),Ee=re(),[Se,De]=te(null),[Ne,Me]=te(!1),Le=()=>{if(!we)return Q.current;const e=Ce.current?.getSource()??ce;return e?{selectionStart:e.start,selectionEnd:e.end}:null},Te=st({target:Q,onChange:me}),je=e=>(ue({start:e.selectionStart,end:e.selectionEnd}),e),Be=(t,n)=>{if(!we)return void Te(e=>(n&&de.record(ye(e),"edit",Date.now()),je(t(e))));const l=Le(),r=je(t(l));n&&de.record(ye(l),"edit",Date.now()),De(null),r.text!==e&&me(r.text),Ce.current?.setSource(r.selectionStart,r.selectionEnd,r.text)},Oe=e=>Be(e,!0),Re=e=>Be(t=>{const n=ye(t),l=de[e](n);return l?{text:l.text,selectionStart:l.start,selectionEnd:l.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),Pe=ee(null);ne(()=>{const t=Pe.current;t&&(Pe.current=null,we?Ce.current?.setSource(t.start,t.end,e):(Q.current?.focus(),Q.current?.setSelectionRange(t.start,t.end),ue(t)))},[we]);const[Ke,Fe]=te(null),He=j??c,We=("string"==typeof B[0]?f(B):B).filter(e=>!nt.has(e.style)),ze=G?("string"==typeof B[0]?B:B.map(e=>e.style)).filter(e=>!nt.has(e)):We.map(e=>e.style),Ae={};if(ce&&(we||G)){const t=m(e,ce.start,ce.end,He);for(const e of ze){const n=t.has(e)||"highlight"===e&&t.has("accent");Ae[e]=!!Se?.add.includes(e)||!Se?.drop.includes(e)&&n}G&&(Ae.link=t.has("link"))}else if(ce)for(const t of ze)Ae[t]="link"===t?null!==b(e,ce.start,ce.end):g(e,ce.start,ce.end,t);const qe=()=>{const t=Le(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},Ve={sup:"sub",sub:"sup"},Ge=t=>{if(G&&"link"!==t&&p(0,t)){const{start:n,end:l}=qe(),r=Ve[t];if(n===l){if(!we)return void Oe(n=>be(e,t,n,(e,t,n,l)=>i(e,t,n,l,He,J.placeholders)));const o=m(e,n,l,He),a=Se&&Se.at===n?Se:null,s=o.has(t),c=!!a?.add.includes(t)||!a?.drop.includes(t)&&s;let u=(a?.add??[]).filter(e=>e!==t),d=(a?.drop??[]).filter(e=>e!==t);return c&&s?d.push(t):c||s||u.push(t),!c&&r&&(u=u.filter(e=>e!==r),o.has(r)&&(d=[...d.filter(e=>e!==r),r])),void De(u.length||d.length||void 0!==a?.color?{add:u,drop:d,color:a?.color,at:n}:null)}return void Oe(()=>{let o=e,a=n,s=l;if(r&&!m(o,a,s,He).has(t)&&m(o,a,s,He).has(r)){const e=w(o,a,s,r,He);({text:o,selectionStart:a,selectionEnd:s}=e)}return w(o,a,s,t,He)})}if("clear"===t)return void Oe(n=>be(e,t,n,(e,t,n)=>i(e,t,n,"clear",He)));if("link"!==t&&we&&p(0,t)){const n=Le(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;if(l===r){const n=m(e,l,r,He),o=n.has(t)||"highlight"===t&&n.has("accent"),a=Se&&Se.at===l?Se:null,s=!!a?.add.includes(t)||!a?.drop.includes(t)&&o,i=(a?.add??[]).filter(e=>e!==t),c=(a?.drop??[]).filter(e=>e!==t);return s&&o?c.push(t):s||o||i.push(t),void De(i.length||c.length?{add:i,drop:c,at:l}:null)}return void Oe(n=>w(e,n?.selectionStart??l,n?.selectionEnd??r,t,He))}if("link"!==t){const n=O??((e,t,n,l)=>i(e,t,n,l,c,J.placeholders));return void Oe(l=>be(e,t,l,n))}const n=Le(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;Me(!1),Fe({start:l,end:r,link:b(e,l,r)})},Je=Boolean(ce&&ce.start!==ce.end),lt=ce?y(e,ce.start,ce.end,He):null,rt=ce?Se&&void 0!==Se.color&&Se.at===ce.start?Se.color:v(e,ce.start,ce.end,He):null,ot=rt?rt.startsWith("#")?rt:U?.find(e=>e.name===rt)?.value:void 0,it=t=>{we?t?Ce.current?.setSource(t.start,t.end,e):Ce.current?.focus():(Q.current?.focus(),t&&Q.current?.setSelectionRange(t.start,t.end))},ct=()=>{const e=Ke;Fe(null),it(e?{start:e.start,end:e.end}:ce)},ut=()=>{const e=dt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Me(!1),t&&it(ce)},dt=ee(null),ht=Ne||null!==Ke;le(()=>{const e=dt.current;if(!ht||!e)return;const t=e.ownerDocument,n=()=>{Me(!1),Fe(null)},l=t=>{e.contains(t.target)||n()};let r;const o=l=>{const o=l.relatedTarget;o?e.contains(o)||n():(clearTimeout(r),r=setTimeout(()=>{const l=t.activeElement;t.hasFocus()&&l&&l!==t.body&&!e.contains(l)&&n()},0))};return t.addEventListener("pointerdown",l,!0),e.addEventListener("focusout",o),()=>{clearTimeout(r),t.removeEventListener("pointerdown",l,!0),e.removeEventListener("focusout",o)}},[ht]);const pt=Ke??(Ne?ce??{start:e.length,end:e.length}:null),ft=ee(()=>{});ft.current=()=>{const e=dt.current,t=e?.querySelector(".es-tb-wrap > .es-copy-pop");if(!e||!t||!pt)return;const n=we?null:e.querySelector(".es-gold-layer"),l=we?Ce.current?.rangeOf(pt.start,pt.end)??null:n?function(e,t,n){const l=e.ownerDocument,r=l.createTreeWalker(e,4),o=e=>{let t=e,n=null;for(let e=r.nextNode();e;e=r.nextNode()){if(t<=e.data.length)return[e,t];t-=e.data.length,n=e}return n?[n,n.data.length]:null},a=o(t);r.currentNode=e;const s=o(n);if(!a||!s)return null;const i=l.createRange();return i.setStart(a[0],a[1]),i.setEnd(s[0],s[1]),i}(n,pt.start,pt.end):null,r=l?.endContainer,o=r?1===r.nodeType?r:r.parentElement:null,a=l?function(e,t){const n=("function"==typeof e.getClientRects?[...e.getClientRects()]:[]).filter(e=>e.height>0);if(n.length>0){const t="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():n[0];return t.height>0?_e(t):_e(n[0])}if(!t)return null;const l=t.getBoundingClientRect();return{left:l.left,top:l.top,right:l.left,bottom:l.bottom}}(l,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!a)return;const s=function({anchor:e,size:t,within:n,clip:l,parent:r,gap:o=8}){const a=Math.max(n.left,l.left),s=Math.min(n.right,l.right)-t.width,i=Qe(e.left,a,s),c=l.bottom-(e.bottom+o),u=e.top-o-l.top,d=t.height>c&&(t.height<=u||u>c),h=d?e.top-o-t.height:e.bottom+o,p=e.left+Math.min((e.right-e.left)/2,10),f=Qe(p-5-i,10,t.width-10-10);return{top:h-r.top,left:i-r.left,above:d,point:f}}({anchor:a,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:et(e),parent:tt(t)});t.style.top=`${s.top}px`,t.style.left=`${s.left}px`,t.style.setProperty("--es-pop-point",`${s.point}px`),t.dataset.side=s.above?"above":"below"},ne(()=>{const e=dt.current;if(!ht||!e)return;const t=()=>ft.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const l=e.querySelector(".es-tb-wrap > .es-copy-pop"),r=n?.ResizeObserver,o=r&&l?new r(t):null;return o&&l&&o.observe(l),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[ht,Ne,Ke,pt?.start,pt?.end,we]);const mt=t=>Ke&&/* @__PURE__ */oe(Ye,{floating:t,href:Ke.link?.href??"",editing:null!==Ke.link,onApply:t=>{const n=Ke;Fe(null),Oe(()=>we?N(e,n.start,n.end,t,He):M(e,n.start,n.end,t))},onRemove:()=>{const t=Ke.link,n=Ke;Fe(null),t&&Oe(()=>we?S(e,n.start,n.end,He):D(e,t))},onClose:ct}),bt=P?he(P.allow,J.align):[],gt="always"===$||_||null!==Ke||Ne;/* @__PURE__ */
27
+ return ae("div",{ref:dt,className:"es-copy"+(x?` ${x}`:""),onFocus:()=>ie(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||ie(!1)},onKeyDownCapture:e=>{Ne&&"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),ut())},onKeyDown:e=>{const t=e.target===Q.current||Boolean(e.target.closest?.(".es-rich"));if(T||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),l="KeyZ"===e.code||"z"===n,r=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(l||r)return e.preventDefault(),e.stopPropagation(),void Re(r||e.shiftKey?"redo":"undo");const o=`${e.shiftKey?"shift+":""}${n}`;if(G){const t={b:"bold",i:"italic",u:"underline",k:"link"}[o];if(!t||!ze.includes(t))return;return e.preventDefault(),e.stopPropagation(),void Ge(t)}const a=We.find(e=>e.shortcut===o);a&&(e.preventDefault(),e.stopPropagation(),Ge(a.style))},onPaste:t=>{const n=Q.current;if(T||!n||t.target!==n)return;t.preventDefault();const l=ke({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:u,rules:He});Oe(t=>ge(e,l,t))},style:U&&U.length>0?Object.fromEntries(U.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=Q.current;t&&t.ownerDocument.activeElement===t&&ue({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[gt&&G?/* @__PURE__ */ae("div",{className:"es-tb-wrap"+(Y?"":" is-eight"),children:[
28
+ /* @__PURE__ */oe(Xe,{words:J.toolbar??t.toolbar,align:J.align,alignmentLabel:J.alignment,ariaLabel:F??J.formatting,offered:new Set(ze),pressed:Ae,onMark:e=>Ge(e),color:U&&U.length>0?{run:ot,open:Ne,onToggle:()=>{Fe(null),Ne?ut():Me(!0)}}:void 0,linkOpen:null!==Ke,last:Y?Y({className:"es-tb-cell es-tb-btn",disabled:T,selected:Je,keepCaret:e=>e.preventDefault(),insert:t=>Oe(n=>ge(e,t,n))}):void 0,alignment:P?{value:P.value,allow:P.allow,onChange:P.onChange,disabled:P.disabled}:void 0,list:{pressed:lt,onList:t=>{const{start:n,end:l}=qe(),r=y(e,n,l,He);Oe(()=>E(e,n,l,r===t?null:t,He))}},letterCase:Z,disabled:T}),Ne&&U&&U.length>0?/* @__PURE__ */oe(Ze,{colors:U,current:rt,words:J.colors??t.colors,onPick:t=>{const{start:n,end:l}=qe();if(n!==l)Oe(()=>C(e,n,l,t,He));else{if(!we)return;De({add:Se?.add??[],drop:Se?.drop??[],color:t,at:n})}}}):null,Ke?mt(!0):null]}):null,G&&V&&V.length>0?/* @__PURE__ */oe(Ue,{cells:V,words:J.cells??t.cells,readOnly:T}):null,gt&&!G?/* @__PURE__ */oe(at,{tools:B,disabled:T,actions:R,glyphs:K,ariaLabel:F,pressed:Ae,open:Ke?"link":null,onApply:Ge,align:P?/* @__PURE__ */oe(r,{options:bt,value:P.value,onChange:P.onChange,ariaLabel:J.alignment,disabled:T||P.disabled,fit:fe(bt)}):null}):null,we?/* @__PURE__ */oe($e,{value:e,rules:He,multiline:u,readOnly:T,placeholder:d,ariaLabel:h,handle:Ce,pending:Se??void 0,onEdit:(t,n,l)=>{de.record({text:e,start:n.start,end:n.end},l,Date.now()),De(null),me(t)},onSelect:e=>{ue(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Se||e.start===Se.at&&e.end===Se.at||De(null)},onHistory:Re,onFormat:e=>{ze.includes(e)&&Ge(e)},onCommit:l,onCancel:s}):/* @__PURE__ */oe(a,{value:e,onInput:e=>{de.record(ye(null),"type",Date.now()),me(e)},onCommit:l,onCancel:s,multiline:u,placeholder:d,ariaLabel:h,rules:j,disabled:T,inputRef:Q,className:"es-copy-box"}),Ke&&!G?mt(!1):null,H?H({focused:_,insert:t=>Oe(n=>ge(e,t,n))}):null,z&&u||G&&gt?
29
+ /* @__PURE__ */ae("div",{className:"es-copy-marks",children:[z&&u?/* @__PURE__ */ae(se,{children:[
30
+ /* @__PURE__ */oe(o,{checked:ve,onChange:()=>{const e=Le();Pe.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:ce,De(null),xe(e=>!e)},ariaLabelledBy:Ee,disabled:T}),
31
+ /* @__PURE__ */oe("span",{id:Ee,className:"es-copy-marks-label",children:J.showMarks??"Show marks"})]}):null,G&&gt?/* @__PURE__ */ae("button",{type:"button",className:"es-copy-clear",disabled:T||!Je,title:Je?void 0:J.clearStyleEmpty??"Select words first",onMouseDown:e=>e.preventDefault(),onClick:()=>{const{start:t,end:n}=qe();if(t===n)return;const l=k(e,t,n,He);l.text!==e&&Oe(()=>l)},children:[
32
+ /* @__PURE__ */oe(q,{size:16}),J.clearStyle??"Clear style"]}):null]}):null]})}export{ie as COPY_ALIGNS,de as COPY_ALIGN_FIT,ue as COPY_ALIGN_GLYPHS,ce as COPY_ALIGN_LABELS,Ae as COPY_CELLS,Ze as ColorWindow,it as CopyBox,Ue as CopyCells,Pe as MARKUP_CLIPBOARD_TYPE,at as MarkBar,$e as RichBox,ze as TYPING_BURST_MS,Xe as TextToolbar,rt as ariaShortcut,he as copyAlignOptions,Ie as createHistory,je as editVisible,ge as insertSelection,be as markSelection,Re as markupOfRange,Be as newLine,ke as pasteToMarkup,Ce as richLayout,Le as selectionToSource,Me as selectionToVisible,Oe as setBullet,Se as toSource,De as toSourceStart,Ne as toVisible,st as useCaretEdit};
@@ -272,9 +272,13 @@
272
272
  text-transform: uppercase;
273
273
  color: var(--es-muted);
274
274
  }
275
+ /* The title's own grey, at a lighter weight. It was `--es-field-placeholder`
276
+ (#9ca3af): 2.5:1 on the panel at 11px, under the 4.5:1 WCAG AA asks of text
277
+ this size (second host, axe-core, 2026-10-07). A count is read, so it is not
278
+ a placeholder. Held by ratio in tests/contrast-small-text.test.ts. */
275
279
  .es-add-group-count {
276
280
  font-size: 11px;
277
- color: var(--es-field-placeholder);
281
+ color: var(--es-muted);
278
282
  }
279
283
  .es-add-grid {
280
284
  display: grid;
@@ -328,6 +332,11 @@
328
332
  .es-add-tile:hover .es-add-tile-glyph {
329
333
  color: var(--es-accent);
330
334
  }
335
+ /* A tile that is off — the whole panel's `readOnly`, or its own `disabled` —
336
+ answers the pointer with nothing: its glyph stays grey too. */
337
+ .es-add-tile[aria-disabled='true']:hover .es-add-tile-glyph {
338
+ color: var(--es-icon);
339
+ }
331
340
  /* Cards (0.80.0): a group whose tiles all carry a cover — two across, the
332
341
  picture above the name, so a section is chosen by how it looks. */
333
342
  .es-add-grid.is-cards {