efficient-easel 0.99.1 → 0.100.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 (110) hide show
  1. package/README.md +281 -36
  2. package/dist/autosave/index.d.ts +12 -6
  3. package/dist/blocks/index.d.ts +2 -2
  4. package/dist/canvas/index.d.ts +3 -3
  5. package/dist/canvas/index.js +1 -1
  6. package/dist/chrome/chrome.css +96 -29
  7. package/dist/chrome/index.d.ts +72 -19
  8. package/dist/chrome/index.js +17 -21
  9. package/dist/chunk-3EDSDPIP.js +1 -0
  10. package/dist/chunk-67GNT6PF.js +1 -0
  11. package/dist/{chunk-PI26YXYD.js → chunk-6EIVTKZZ.js} +21 -14
  12. package/dist/chunk-A5UK76FC.js +6 -0
  13. package/dist/chunk-AZT7V4UM.js +10 -0
  14. package/dist/chunk-DICUMYMG.js +12 -0
  15. package/dist/chunk-HDVD27VB.js +1 -0
  16. package/dist/chunk-JQM3V7XQ.js +1 -0
  17. package/dist/{chunk-TDA4HH54.js → chunk-JUQ6YJCG.js} +1 -1
  18. package/dist/chunk-LA54QLP5.js +1 -0
  19. package/dist/chunk-LGKQXSKO.js +16 -0
  20. package/dist/chunk-M6F6LS3H.js +1 -0
  21. package/dist/chunk-MH5GUZFQ.js +9 -0
  22. package/dist/chunk-P6O363EE.js +6 -0
  23. package/dist/chunk-PAELDYYS.js +1 -0
  24. package/dist/{chunk-JYPOOHII.js → chunk-QKVR3K73.js} +3 -3
  25. package/dist/chunk-SAJUCHOX.js +1 -0
  26. package/dist/chunk-TRVZ7C23.js +1 -0
  27. package/dist/chunk-V7GIIXFB.js +16 -0
  28. package/dist/{chunk-IBOFSS56.js → chunk-WZ7TGAAT.js} +1 -1
  29. package/dist/chunk-ZJEBF4NB.js +1 -0
  30. package/dist/copy/copy.css +388 -5
  31. package/dist/copy/index.d.ts +271 -8
  32. package/dist/copy/index.js +31 -10
  33. package/dist/data/index.d.ts +4 -4
  34. package/dist/drag/drag.css +10 -1
  35. package/dist/drag/index.d.ts +102 -11
  36. package/dist/drag/index.js +18 -17
  37. package/dist/{editor/editor.css → easel/easel.css} +16 -1
  38. package/dist/{editor → easel}/index.d.ts +146 -51
  39. package/dist/easel/index.js +9 -0
  40. package/dist/edit-lock/index.d.ts +3 -3
  41. package/dist/edit-lock/index.js +1 -1
  42. package/dist/fields/fields.css +103 -26
  43. package/dist/fields/index.d.ts +51 -13
  44. package/dist/fields/index.js +30 -46
  45. package/dist/gold/index.js +1 -1
  46. package/dist/icons/index.d.ts +10 -1
  47. package/dist/icons/index.js +1 -1
  48. package/dist/index.d.ts +3 -3
  49. package/dist/index.js +1 -1
  50. package/dist/markup/index.d.ts +94 -10
  51. package/dist/markup/index.js +1 -1
  52. package/dist/menu/index.d.ts +61 -6
  53. package/dist/menu/index.js +15 -15
  54. package/dist/menu/menu.css +17 -6
  55. package/dist/node-ops/index.d.ts +9 -9
  56. package/dist/node-ops/index.js +1 -1
  57. package/dist/panel/index.d.ts +73 -5
  58. package/dist/panel/index.js +18 -16
  59. package/dist/panel/panel.css +56 -1
  60. package/dist/pick/index.d.ts +42 -4
  61. package/dist/pick/index.js +7 -14
  62. package/dist/pick/pick.css +14 -0
  63. package/dist/rail/index.d.ts +6 -6
  64. package/dist/rail/index.js +1 -1
  65. package/dist/rail/rail.css +1 -1
  66. package/dist/strings/catalogue.d.ts +24 -40
  67. package/dist/strings/catalogue.js +1 -1
  68. package/dist/strings/index.d.ts +25 -23
  69. package/dist/strings/index.js +2 -2
  70. package/dist/style-clipboard/index.d.ts +5 -5
  71. package/dist/style-clipboard/index.js +1 -1
  72. package/dist/text-styles/index.d.ts +328 -0
  73. package/dist/text-styles/index.js +38 -0
  74. package/dist/text-styles/text-styles.css +309 -0
  75. package/dist/tree/index.d.ts +44 -3
  76. package/dist/tree/index.js +1 -1
  77. package/dist/tree/tree.css +71 -0
  78. package/dist/{types-CnRzp9oc.d.ts → types-DGcCsxs8.d.ts} +79 -12
  79. package/dist/{types-DNrn_w4V.d.ts → types-DWS-s9z-.d.ts} +10 -10
  80. package/dist/{types-pGBXevBU.d.ts → types-Djdq6Xkd.d.ts} +15 -8
  81. package/dist/{types-Dy6oR6Z2.d.ts → types-E3HrTPg2.d.ts} +20 -14
  82. package/dist/{types-C7HFvdtk.d.ts → types-VqL6t5HH.d.ts} +82 -5
  83. package/dist/{watch-DmasQA61.d.ts → watch-BTYOJpQU.d.ts} +19 -2
  84. package/dist/{wordFit-9B9nqyf3.d.ts → wordFit-D4S36PvB.d.ts} +1 -1
  85. package/dist/{words-DagJdwIA.d.ts → words-AHHfiaRY.d.ts} +31 -2
  86. package/dist/{words-D9ChvbNC.d.ts → words-BDignMl_.d.ts} +1 -1
  87. package/dist/{words-Cqmyey0s.d.ts → words-BMzV04b1.d.ts} +2 -2
  88. package/dist/words-CJjUKcV5.d.ts +37 -0
  89. package/dist/words-CRYvAiHX.d.ts +105 -0
  90. package/dist/{words-B2YLaKEr.d.ts → words-CnnHb9jo.d.ts} +1 -1
  91. package/dist/{words-CD3WADyb.d.ts → words-CzoyDNHm.d.ts} +4 -0
  92. package/dist/{words-bOMsUJk9.d.ts → words-DBq7vfHy.d.ts} +59 -6
  93. package/dist/{words-DOhF-4D4.d.ts → words-DMG4dYq2.d.ts} +1 -1
  94. package/dist/{words-BK-npta-.d.ts → words-DgHcY5qB.d.ts} +10 -4
  95. package/dist/{words-B87GIFWH.d.ts → words-is_Vy6hn.d.ts} +1 -1
  96. package/package.json +14 -8
  97. package/dist/chunk-66CKSTXP.js +0 -14
  98. package/dist/chunk-67VZRQLG.js +0 -13
  99. package/dist/chunk-6PS6STGA.js +0 -1
  100. package/dist/chunk-7A7O2JWQ.js +0 -1
  101. package/dist/chunk-H4B72XCJ.js +0 -1
  102. package/dist/chunk-JE63JHKO.js +0 -1
  103. package/dist/chunk-KDIVA6WD.js +0 -1
  104. package/dist/chunk-MCLBHENY.js +0 -1
  105. package/dist/chunk-QB3BZIRA.js +0 -5
  106. package/dist/chunk-SJQG5ENJ.js +0 -1
  107. package/dist/chunk-SUO5627P.js +0 -1
  108. package/dist/chunk-ZT7M24XD.js +0 -1
  109. package/dist/editor/index.js +0 -9
  110. /package/dist/{chunk-GGTPNGFJ.js → chunk-AELNNAFM.js} +0 -0
@@ -1,8 +1,109 @@
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-bOMsUJk9.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-bOMsUJk9.js';
3
+ import { MarkStyle, MarkupTool, WrapResult, InlineRule, MarkedLine } from '../markup/index.js';
4
+ import { C as CopyWords, a as CopyAlign } from '../words-DBq7vfHy.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-DBq7vfHy.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
+ onUndo: () => void;
87
+ alignment?: {
88
+ value: CopyAlign | '';
89
+ allow: readonly CopyAlign[];
90
+ onChange: (next: CopyAlign) => void;
91
+ disabled?: boolean;
92
+ };
93
+ /** The list the selection's lines are in, and the presses. */
94
+ list?: {
95
+ pressed: 'bullet' | 'number' | null;
96
+ onList: (kind: 'bullet' | 'number') => void;
97
+ };
98
+ letterCase?: {
99
+ value: CopyCase | '';
100
+ onChange: (next: CopyCase | '') => void;
101
+ disabled?: boolean;
102
+ };
103
+ disabled?: boolean;
104
+ ariaLabel?: string;
105
+ }
106
+ declare function TextToolbar({ words, align: alignWords, alignmentLabel, offered, pressed, onMark, color, linkOpen, onUndo, alignment, list, letterCase, disabled, ariaLabel, }: TextToolbarProps): react.JSX.Element;
6
107
 
7
108
  /** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
8
109
  * shortcut. Meta is what the tooltips promise (⌘); Ctrl works too. */
@@ -65,7 +166,7 @@ interface MarkBarProps {
65
166
  */
66
167
  glyphs?: Partial<Record<MarkStyle, ReactNode>>;
67
168
  /**
68
- * What the group is CALLED. Defaults to "Formatting" (`EditorStrings.copy.formatting`).
169
+ * What the group is CALLED. Defaults to "Formatting" (`EaselStrings.copy.formatting`).
69
170
  *
70
171
  * A bar bound to one box needs nothing more. A bar SHARED by several rows has
71
172
  * to say which row it is aimed at, because the visible cue — the marked row —
@@ -254,13 +355,175 @@ interface CopyBoxProps {
254
355
  * words, not a column of toolbars.
255
356
  */
256
357
  barShows?: 'always' | 'focus';
358
+ /**
359
+ * Show the EFFECT, not the marks (0.95.0, rulings B + C — the default). A
360
+ * many-line box gets a "Show marks" switch under it that flips to the raw
361
+ * text with its marks and back; a one-line box is always the effect.
362
+ * `false` keeps the 0.94 box (the raw text, painted) with no switch.
363
+ *
364
+ * ⚠️ In the rich view there is no textarea, so {@link inputRef} holds null.
365
+ * Insert at the caret through `renderFooter`'s `insert`, which works in both.
366
+ */
367
+ richText?: boolean;
368
+ /** A many-line box opens with its marks shown. Default false. */
369
+ defaultShowMarks?: boolean;
370
+ /**
371
+ * Which toolbar (E5b). `'final'` — the default — is the design made final
372
+ * on 2026-10-06: two rows on one 9-column grid, B · I · U · S · Color ·
373
+ * Link · Superscript · Subscript · Undo over Left · Center · Right · Justify
374
+ * · Bulleted · Numbered · Aa · AA · aa, with the number {@link cells}
375
+ * between it and the box. `'classic'` is the bar before it (`MarkBar` and
376
+ * the alignment strip), for a host not moved over yet.
377
+ */
378
+ toolbar?: 'final' | 'classic';
379
+ /**
380
+ * The theme colours the colour window offers (final toolbar): the NAME
381
+ * saved in `[words]{color=name}`, what it is called, and its value. The box
382
+ * paints a coloured word with the value (`--es-color-<name>`). The window
383
+ * also offers Any color, saved as a hex (`[words]{color=#rrggbb}`). No colours:
384
+ * no colour button — its cell stays, empty.
385
+ */
386
+ colors?: readonly CopyThemeColor[];
387
+ /** The number cells between the toolbar and the box (final toolbar), each
388
+ * the host's value — see `COPY_CELLS`. None: no cells. */
389
+ cells?: readonly CopyCell[];
390
+ /**
391
+ * The host's letter-case field, set by Aa · AA · aa (final toolbar). The
392
+ * lit one pressed again writes `''`: no case of its own, the style decides.
393
+ * Left out: the three cells stay, empty.
394
+ */
395
+ letterCase?: {
396
+ value: CopyCase | '';
397
+ onChange: (next: CopyCase | '') => void;
398
+ disabled?: boolean;
399
+ };
257
400
  /** A handle on the textarea, for a host that needs one — and the SAME object
258
401
  * the control uses, so there is never a second ref to reconcile. A plain prop
259
402
  * rather than `ref`, for the reason `GoldLayer.layerRef` gives. */
260
403
  inputRef?: TextAreaHandle;
261
404
  }
262
405
 
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;
406
+ 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, }: CopyBoxProps): react.JSX.Element;
407
+
408
+ /** The clipboard type a copy from this box carries, so a paste back in keeps
409
+ * every mark (the HTML filter keeps only bold, italic and links). */
410
+ declare const MARKUP_CLIPBOARD_TYPE = "application/x-efficient-markup";
411
+ /** What the host can ask of the box, in SAVED offsets. */
412
+ interface RichHandle {
413
+ /** The selection, or null when it is not in the box. */
414
+ getSource(): {
415
+ start: number;
416
+ end: number;
417
+ } | null;
418
+ /** Put the selection here once the box shows `text` (a host may write a
419
+ * commit or more late — the same wait as `useCaretEdit`). */
420
+ setSource(start: number, end: number, text: string): void;
421
+ focus(): void;
422
+ }
423
+ interface RichBoxProps {
424
+ value: string;
425
+ rules: readonly InlineRule[];
426
+ multiline: boolean;
427
+ readOnly?: boolean;
428
+ placeholder?: string;
429
+ ariaLabel?: string;
430
+ /** Filled with the box's handle. */
431
+ handle: {
432
+ current: RichHandle | null;
433
+ };
434
+ /** The box made an edit. `before` is the saved selection it replaced, for
435
+ * undo; `kind` says whether it may join the previous typing. */
436
+ onEdit(text: string, before: {
437
+ start: number;
438
+ end: number;
439
+ }, kind: 'type' | 'edit'): void;
440
+ /** The selection moved (saved offsets). */
441
+ onSelect(sel: {
442
+ start: number;
443
+ end: number;
444
+ }): void;
445
+ /** The browser's own Undo / Redo (the Edit menu), and its format commands. */
446
+ onHistory(dir: 'undo' | 'redo'): void;
447
+ onFormat(style: MarkStyle): void;
448
+ /** Marks the next typed words gain or lose — a press with nothing selected. */
449
+ pending?: {
450
+ add: readonly MarkStyle[];
451
+ drop: readonly string[];
452
+ color?: string | null;
453
+ };
454
+ onCommit?: (value: string) => void;
455
+ onCancel?: (restored: string) => void;
456
+ }
457
+ declare function RichBox({ value, rules, multiline, readOnly, placeholder, ariaLabel, handle, onEdit, onSelect, onHistory, onFormat, pending, onCommit, onCancel, }: RichBoxProps): react.JSX.Element;
458
+
459
+ /** One line of the rich view. `src` is where its words start in the saved
460
+ * string (after a `- `), `start` where the line itself starts, `vis` where
461
+ * its words start in the visible text. */
462
+ interface RichLine extends MarkedLine {
463
+ start: number;
464
+ src: number;
465
+ vis: number;
466
+ text: string;
467
+ }
468
+ interface RichLayout {
469
+ lines: RichLine[];
470
+ /** The visible words, lines joined by `\n`. */
471
+ text: string;
472
+ }
473
+ declare function richLayout(value: string, rules: readonly InlineRule[]): RichLayout;
474
+ /**
475
+ * A visible offset in the saved string, read as a CARET: after the word before
476
+ * it, so inside any run that word is in (typing there continues the run). At
477
+ * the start of a line it is where the line's words start.
478
+ */
479
+ declare function toSource(layout: RichLayout, v: number): number;
480
+ /** A visible offset read as the START of a selection: at the word it starts
481
+ * on, so a selection's saved range holds its first word's delimiters out. */
482
+ declare function toSourceStart(layout: RichLayout, v: number): number;
483
+ /** A saved-string offset as a visible one. Inside a delimiter it is the word
484
+ * boundary that delimiter sits on. */
485
+ declare function toVisible(layout: RichLayout, s: number): number;
486
+ /** A saved selection as a visible one, and back. */
487
+ declare function selectionToVisible(layout: RichLayout, start: number, end: number): [number, number];
488
+ declare function selectionToSource(layout: RichLayout, a: number, b: number): [number, number];
489
+ /** What to put in. */
490
+ interface RichInsert {
491
+ /** Typed words: they take the marks of the caret (see the header). */
492
+ text?: string;
493
+ /** Pasted markup: its characters keep their own marks and take none. */
494
+ markup?: string;
495
+ /** A press with nothing selected: marks the next typed words gain… */
496
+ add?: readonly MarkStyle[];
497
+ /** …or lose (`highlight` takes the legacy `accent` off too). */
498
+ drop?: readonly string[];
499
+ /** A pending colour (E5b): the next typed words take this theme colour by
500
+ * name, or — `null` — no colour. Left out, they keep the caret's. */
501
+ color?: string | null;
502
+ }
503
+ interface RichEdit {
504
+ text: string;
505
+ /** The visible caret after the edit. */
506
+ caret: number;
507
+ }
508
+ /**
509
+ * Replace the visible words `vs..ve` with `insert`, and say where the caret
510
+ * goes. A `\n` in typed words splits the line; the new line keeps the bullet.
511
+ *
512
+ * A mark the grammar cannot hold is not written — `_it_s` would print its
513
+ * underscores — so typed words fall back to the caret's own marks, and then
514
+ * the words are written however they read.
515
+ */
516
+ declare function editVisible(value: string, rules: readonly InlineRule[], vs: number, ve: number, insert: RichInsert): RichEdit;
517
+ /**
518
+ * Enter. On an empty bullet it ends the list (the bullet comes off, the line
519
+ * stays); anywhere else it splits the line, and a bullet carries on.
520
+ */
521
+ declare function newLine(value: string, rules: readonly InlineRule[], vs: number, ve: number): RichEdit;
522
+ /** Put a line's bullet on or take its list prefix (a bullet or a number)
523
+ * off, keeping its words and the caret. */
524
+ declare function setBullet(value: string, rules: readonly InlineRule[], index: number, on: boolean, caret: number): RichEdit;
525
+ /** The words `vs..ve` as markup, marks and bullets included — for a copy. */
526
+ declare function markupOfRange(value: string, rules: readonly InlineRule[], vs: number, ve: number): string;
264
527
 
265
528
  interface PasteData {
266
529
  /** The clipboard's `text/html`, when there is one. */
@@ -286,10 +549,10 @@ declare function pasteToMarkup(data: PasteData, opts: PasteOptions): string;
286
549
  *
287
550
  * A browser's own text undo cannot do it: it forgets everything the moment a
288
551
  * value is set from script, and every mark, link, clear and paste is set from
289
- * script. And the editor's undo (`efficient-easel/editor` `bindUndoKeys`)
552
+ * script. And the easel's undo (`efficient-easel/easel` `bindUndoKeys`)
290
553
  * steps the whole document, a keystroke at a time. So the box keeps the steps
291
554
  * IT made, with the selection each one started from, and answers ⌘Z itself —
292
- * the key never reaches the editor while the caret is in the box, so one key
555
+ * the key never reaches the easel while the caret is in the box, so one key
293
556
  * is never answered twice.
294
557
  *
295
558
  * Typing is one step per burst: keystrokes less than a second apart are one
@@ -333,4 +596,4 @@ interface CaretEdit {
333
596
  */
334
597
  declare function useCaretEdit({ target, onChange }: CaretEdit): (edit: (el: HTMLInputElement | HTMLTextAreaElement | null) => WrapResult) => void;
335
598
 
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 };
599
+ export { COPY_CELLS, type CaretEdit, ColorWindow, CopyAlign, CopyBox, type CopyBoxAlign, type CopyBoxFooter, 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,31 @@
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-AZT7V4UM.js";import{DEFAULT_COPY_WORDS as t}from"../chunk-JQM3V7XQ.js";import{DEFAULT_PICK_WORDS as n}from"../chunk-ZAOM6PFH.js";import{FieldNumber as l}from"../chunk-A5UK76FC.js";import{SettingsSegmented as r,SettingsSwitch as a}from"../chunk-P6O363EE.js";import"../chunk-LA54QLP5.js";import{GoldTextInput as o}from"../chunk-QKVR3K73.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 m,marksIn as f,findLink as b,markedAt as g,listIn as y,colorIn as v,isSafeLinkHref as k,toggleMark as x,colorOver as w,setList as C,unlinkAt as D,removeLink as N,linkOver as S,writeLink as E}from"../chunk-HDVD27VB.js";import{useWords as M}from"../chunk-MFIRYGHW.js";import"../chunk-BZ5ASXOL.js";import{AlignJustifyIcon as L,AlignRightIcon as T,AlignCenterIcon as j,AlignLeftIcon as K,ParagraphSpacingIcon as P,LetterSpacingIcon as O,TextLinesIcon as B,TextSizeIcon as F,CaseNormalIcon as $,CaseUpperIcon as A,CaseLowerIcon as H,TextColorIcon as R,UndoIcon as U,ListIcon as W,NumberedListIcon as z,BoldIcon as I,ItalicIcon as V,UnderlineIcon as Z,StrikeIcon as q,LinkIcon as Q,SuperscriptIcon as X,SubscriptIcon as Y,ClearMarksIcon as G,QuietIcon as J,EmphasisIcon as _}from"../chunk-6EIVTKZZ.js";import{useRef as ee,useState as te,useLayoutEffect as ne,useEffect as le,useId as re}from"react";import{jsx as ae,jsxs as oe,Fragment as se}from"react/jsx-runtime";var ie=["left","center","right","justify"],ce=t.align,ue={left:/* @__PURE__ */ae(K,{}),center:/* @__PURE__ */ae(j,{}),right:/* @__PURE__ */ae(T,{}),justify:/* @__PURE__ */ae(L,{})},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 me(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 fe(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:a}=fe(e,n);return l(e,r,a,t)}function ge(e,t,n){const{start:l,end:r}=fe(e,n),a=l+t.length;return{text:e.slice(0,l)+t+e.slice(r),selectionStart:a,selectionEnd:a}}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=[[]],a=()=>r[r.length-1],o=()=>{const e=a();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 o of e.textContent??""){const e=/\s/.test(o)?" ":o,s=a();" "===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=k(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 m=ve.has(c);m&&o();for(const t of[...e.childNodes])s(t,u,d,h);m&&o()};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),a=u([l]).text;if(d([l],h(a,t)))return a}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,a=null,o=null,s=null;return{bullet:!1,chars:e.map((e,i)=>{const c=l?e.href:null;return a=null===c?null:a&&a.href===c?a:p(++r,"link",c),o=t?.[i]?o??p(++r,"bold"):null,s=n?.[i]?s??p(++r,"italic"):null,{ch:e.ch,at:-1,marks:[a,o,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,a=0;const o=l.map((e,t)=>{const l=!e.bullet&&null==e.number&&"- "===n[t],o=null!=e.number||e.bullet?null:we.exec(n[t]),s=e.bullet||l,i=o?o[1]:e.number??null,c=l||o?[]: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:a,text:u};return r+=n[t].length+1,a+=u.length+1,h});return{lines:o,text:o.map(e=>e.text).join("\n")}}function De(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 Ne(e,t){const[n,l]=De(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 Se(e,t){const[n,l]=De(e,t);let r=0;for(const e of n.chars){if(l===r)return e.at;r+=e.ch.length}return Ne(e,t)}function Ee(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[Ee(e,t),Ee(e,n)]}function Le(e,t,n){return t===n?[Ne(e,t),Ne(e,t)]:[Se(e,t),Ne(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 a=Ce(e,t),[o,s,i]=De(a,Math.min(n,l)),[c,m,f]=De(a,Math.max(n,l)),b=Te(o,s),g=Te(c,m),y=o.chars.slice(0,b),v=c.chars.slice(g),k=n!==l&&o.chars[b]&&(i!==f||b<g)?o.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):[]}(o,b);let x=(w=a.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=o.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:o.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:o.bullet,number:o.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:[...a.lines.slice(0,i).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n})),s,...c,...a.lines.slice(f+1).map(({bullet:e,number:t,chars:n})=>({bullet:e,number:t,chars:n}))],shown:l}},D=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 N="",S="";for(const e of D){const n=C(e),l=u(n.lines).text;if(N=l,S=n.shown,d(n.lines,Ce(l,t).lines))break}return{text:N,caret:Math.min(n,l)+S.length}}function Ke(e,t,n,l){const r=Ce(e,t),[a,,o]=De(r,n);return n!==l||!a.bullet&&null==a.number||""!==a.text?je(e,t,n,l,{text:"\n"}):Pe(e,t,o,!1,n)}function Pe(e,t,n,l,r){const a=Ce(e,t).lines.map(({bullet:e,number:t,chars:r},a)=>a===n?{bullet:l,number:null,chars:r}:{bullet:e,number:t,chars:r});return{text:u(a).text,caret:r}}function Oe(e,t,n,l){const r=Ce(e,t),[a,o,s]=De(r,Math.min(n,l)),[i,c,d]=De(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(a,o):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 Be="application/x-efficient-markup";function Fe(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 $e(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 a=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===a)return 0;const o=t.ownerDocument.createRange();o.setStart(e.lines[a],0);try{o.setEnd(n,l)}catch{return r[a].vis}return r[a].vis+Math.min(o.toString().length,r[a].text.length)}function Ae(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 a=e.lines[l].ownerDocument.createTreeWalker(e.lines[l],4);let o=a.nextNode(),s=null;for(;o;){if(r<=o.data.length)return[o,r];r-=o.data.length,s=o,o=a.nextNode()}return s?[s,s.data.length]:[e.lines[l],0]}function He(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 Re({value:e,rules:t,multiline:n,readOnly:l=!1,placeholder:r,ariaLabel:a,handle:o,onEdit:s,onSelect:i,onHistory:c,onFormat:u,pending:d,onCommit:h,onCancel:p}){const m=ee(null),f=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=m.current,t=f.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const l=$e(t,e,n.anchorNode,n.anchorOffset),r=n.focusNode&&e.contains(n.focusNode)?$e(t,e,n.focusNode,n.focusOffset):l;return l<=r?[l,r]:[r,l]},D=(e,t)=>{const n=m.current,l=f.current;if(!n||!l)return;const[r,a]=Ae(l,e),[o,s]=Ae(l,t);n.ownerDocument.getSelection()?.setBaseAndExtent(r,a,o,s)};o.current={getSource(){const e=C(),t=f.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(){m.current?.focus()}},ne(()=>{const n=m.current;if(!n||y.current)return;const l=g.current?null:C();f.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=[],a=()=>r.length?r[r.length-1].el:l;let o=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)&&(o=null),r.length=t;for(let l=t;l<e.marks.length;l+=1){const t=Fe(n,e.marks[l].kind,e.marks[l].href,e.marks[l].color);a().appendChild(t),r.push({id:e.marks[l].id,el:t})}o||(o=n.createTextNode(""),a().appendChild(o)),o.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&&D(l[0],Math.min(l[1],f.current.layout.text.length)));g.current=null;const a=f.current.layout,[o,s]=r.vis??Me(a,r.src[0],r.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),D(o,s)},[e,t,k]);const N=(e,t,n)=>{const l=f.current,[r,a]=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:a},n):x(e=>e+1)};le(()=>{const e=m.current;if(!e)return;const t=t=>{const{value:n,rules:l,multiline:r,readOnly:a,pending:o}=w.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),a)return;const s=f.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=$e(s,e,d.startContainer,d.startOffset),u=$e(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 a=t.data??t.dataTransfer?.getData("text/plain")??"";if("insertFromDrop"===p||"insertFromPaste"===p){const o=ke({html:t.dataTransfer?.getData("text/html"),text:a},{doc:e.ownerDocument,multiline:r,rules:l});return void N(je(n,l,c,u,{markup:o}),[c,u],"edit")}return r||(a=a.replace(/\s*\r?\n\s*/g," ")),void N(je(n,l,c,u,{text:a,add:o?.add,drop:o?.drop,color:o?.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 N(Pe(n,l,t,!1,c),[c,u],"edit");if(e?0===c:c===h.length)return;e?c=He(h,c,-1):u=He(h,u,1)}N(je(n,l,c,u,{text:""}),[c,u],"type")}}else r&&N(Ke(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=m.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=o.current?.getSource();e&&i(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const S=(n,r=!1)=>{const a=C();if(!a||a[0]===a[1])return;n.preventDefault();const o=f.current;n.clipboardData.setData("text/plain",o.layout.text.slice(a[0],a[1])),n.clipboardData.setData(Be,Oe(e,t,a[0],a[1])),r&&!l&&N(je(e,t,a[0],a[1],{text:""}),a,"edit")};/* @__PURE__ */
2
+ return oe("div",{className:"es-rich-wrap",children:[r&&""===e?/* @__PURE__ */ae("div",{className:"es-rich-placeholder","aria-hidden":"true",children:r}):null,
3
+ /* @__PURE__ */ae("div",{ref:m,className:`es-rich${n?" is-multiline":" is-single"}${l?" is-off":""}`,contentEditable:!l,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":n,"aria-label":a,"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?N(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=>S(e),onCut:e=>S(e,!0),onPaste:r=>{if(r.preventDefault(),l)return;const a=C();if(!a)return;const o=r.clipboardData.getData(Be),s=o?n?o:o.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});N(je(e,t,a[0],a[1],{markup:s}),a,"edit")}})]})}var Ue=1e3;function We(e=200){let t=[],n=[],l=null,r=0;return{record(a,o,s){const i="type"===o&&"type"===l&&s-r<1e3;l=o,r=s,n=[],i||(t.push(a),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 ze={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */ae(F,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */ae(B,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */ae(O,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */ae(P,{}),unit:"px",step:1,shiftStep:10,min:0}};function Ie(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Ve({cells:e,words:n,readOnly:r=!1}){const a=n??t.cells;/* @__PURE__ */
4
+ return ae("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,n=e.name??(e.nameKey?a[e.nameKey]:e.key),o=e.unit??"",s=e.step??1;/* @__PURE__ */
5
+ return ae(l,{value:Ie(e.value,t),styleValue:Ie(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:o||void 0,steppers:!0,readOnly:r,ariaLabel:n,title:a.tip({name:n,step:s,unit:o})},e.key)})})}var Ze=e=>e.preventDefault();function qe({colors:t,current:l,words:r,onPick:a}){const o=null===l?null:l.startsWith("#")?l.toLowerCase():t.find(e=>e.name===l)?.value.toLowerCase()??null;/* @__PURE__ */
6
+ return oe("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__ */ae("span",{className:"es-copy-pop-label",children:r.theme}),
8
+ /* @__PURE__ */ae("div",{className:"es-copy-swatches",children:t.map(e=>/* @__PURE__ */ae("button",{type:"button",className:"es-copy-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:Ze,onClick:()=>a(e.name)},e.name))}),
9
+ /* @__PURE__ */ae("span",{className:"es-copy-pop-label",children:r.any}),
10
+ /* @__PURE__ */ae(e,{value:o??"",onChange:e=>{e!==l&&a(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__ */ae("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn is-danger",onMouseDown:Ze,onClick:()=>a(null),children:r.remove})})]})}function Qe({href:e,editing:n,onApply:l,onRemove:r,onClose:a,floating:o=!1}){const s=M("copy",t).link,i=re(),[c,u]=te(e),[d,h]=te(!1),p=ee(null);le(()=>{p.current?.focus(),p.current?.select()},[]);const m=()=>{const e=c.trim();k(e)?l(e):h(!0)};/* @__PURE__ */
12
+ return oe("div",{role:"dialog","aria-label":s.title,className:"es-copy-link"+(o?" es-copy-pop":""),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),m()):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),a())},children:[
13
+ /* @__PURE__ */ae("label",{htmlFor:i,className:"es-copy-link-label",children:s.label}),
14
+ /* @__PURE__ */ae("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__ */ae("p",{id:`${i}-why`,role:"alert",className:"es-copy-link-why",children:s.refused}):null,
15
+ /* @__PURE__ */oe("div",{className:"es-copy-link-actions",children:[n?/* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn is-danger",onClick:r,children:s.remove}):null,
16
+ /* @__PURE__ */oe("span",{className:"es-copy-link-end",children:[
17
+ /* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn",onClick:a,children:s.cancel??t.link.cancel}),
18
+ /* @__PURE__ */ae("button",{type:"button",className:"es-copy-link-btn is-primary",onClick:m,disabled:""===c.trim(),children:s.apply})]})]})]})}var Xe=e=>e.preventDefault();function Ye(){/* @__PURE__ */
19
+ return ae("span",{className:"es-tb-cell is-empty","aria-hidden":"true"})}function Ge({words:e,align:t,alignmentLabel:n,offered:l,pressed:r,onMark:a,color:o,linkOpen:s,onUndo:i,alignment:c,list:u,letterCase:d,disabled:h=!1,ariaLabel:p="Formatting"}){const m=(e,t,n,o)=>l.has(e)?/* @__PURE__ */ae("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":o,disabled:h,onMouseDown:Xe,onClick:()=>a(e),children:n},e):/* @__PURE__ */ae(Ye,{},e),f=[["left",/* @__PURE__ */ae(K,{},"l")],["center",/* @__PURE__ */ae(j,{},"c")],["right",/* @__PURE__ */ae(T,{},"r")],["justify",/* @__PURE__ */ae(L,{},"j")]],b=[["none",e.caseNone,/* @__PURE__ */ae($,{},"n")],["upper",e.caseUpper,/* @__PURE__ */ae(A,{},"u")],["lower",e.caseLower,/* @__PURE__ */ae(H,{},"w")]];/* @__PURE__ */
20
+ return oe("div",{className:"es-tb",role:"toolbar","aria-label":p,children:[
21
+ /* @__PURE__ */oe("div",{className:"es-tb-row",children:[m("bold",e.bold,/* @__PURE__ */ae(I,{}),"Meta+B"),m("italic",e.italic,/* @__PURE__ */ae(V,{}),"Meta+I"),m("underline",e.underline,/* @__PURE__ */ae(Z,{}),"Meta+U"),m("strike",e.strike,/* @__PURE__ */ae(q,{})),o?/* @__PURE__ */ae("button",{type:"button",className:"es-tb-cell es-tb-btn es-tb-color"+(o.open?" is-on":""),"aria-label":e.color,title:e.color,"aria-haspopup":"dialog","aria-expanded":o.open,disabled:h,style:o.run?{"--es-tb-run":o.run}:void 0,onMouseDown:Xe,onClick:o.onToggle,children:/* @__PURE__ */ae(R,{})}):/* @__PURE__ */ae(Ye,{}),m("link",e.link,/* @__PURE__ */ae(Q,{}),"Meta+K"),m("sup",e.sup,/* @__PURE__ */ae(X,{})),m("sub",e.sub,/* @__PURE__ */ae(Y,{})),
22
+ /* @__PURE__ */ae("button",{type:"button",className:"es-tb-cell es-tb-btn","aria-label":e.undo,title:e.undoTitle,"aria-keyshortcuts":"Meta+Z",disabled:h,onMouseDown:Xe,onClick:i,children:/* @__PURE__ */ae(U,{})})]}),
23
+ /* @__PURE__ */oe("div",{className:"es-tb-row",children:[
24
+ /* @__PURE__ */ae("div",{className:"es-tb-group",role:"radiogroup","aria-label":n,children:f.map(([e,n])=>c&&c.allow.includes(e)?/* @__PURE__ */ae("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:Xe,onClick:()=>c.onChange(e),children:n},e):/* @__PURE__ */ae(Ye,{},e))}),u&&l.has("bullet")?/* @__PURE__ */ae("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:Xe,onClick:()=>u.onList("bullet"),children:/* @__PURE__ */ae(W,{})}):/* @__PURE__ */ae(Ye,{}),u&&l.has("number")?/* @__PURE__ */ae("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:Xe,onClick:()=>u.onList("number"),children:/* @__PURE__ */ae(z,{})}):/* @__PURE__ */ae(Ye,{}),
25
+ /* @__PURE__ */ae("div",{className:"es-tb-group",role:"radiogroup","aria-label":e.letterCase,children:b.map(([e,t,n])=>d?/* @__PURE__ */ae("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:Xe,onClick:()=>d.onChange(d.value===e?"":e),children:n},e):/* @__PURE__ */ae(Ye,{},e))})]})]})}var Je=/* @__PURE__ */new Set([...s,"clear"]),_e={bold:/* @__PURE__ */ae(I,{size:16}),italic:/* @__PURE__ */ae(V,{size:16}),strike:/* @__PURE__ */ae(q,{size:16}),highlight:/* @__PURE__ */ae(_,{size:16}),quiet:/* @__PURE__ */ae(J,{size:16}),link:/* @__PURE__ */ae(Q,{size:16}),clear:/* @__PURE__ */ae(G,{size:16})};function et(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 tt={bold:"is-bold",italic:"is-italic",strike:"is-strike"};function nt({tools:e,onApply:n,disabled:l=!1,actions:r,align:a,glyphs:o,ariaLabel:s,pressed:i,open:c=null}){const u=M("copy",t),d=("string"==typeof e[0]?m(e).map(e=>({...e,...u.marks[e.style]})):e).filter(e=>!Je.has(e.style));return 0!==d.length||r||a?/* @__PURE__ */oe("div",{className:"es-copy-bar",role:"group","aria-label":s??u.formatting,children:[d.map(e=>{const t=o?.[e.style]??_e[e.style],r=c===e.style||Boolean(i?.[e.style]);/* @__PURE__ */
26
+ return ae("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>n(e.style),disabled:l,title:e.title,"aria-label":e.name??e.title,"aria-keyshortcuts":et(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":tt[e.style]?` ${tt[e.style]}`:""}${r?" is-active":""}`,children:t??e.label},e.style)}),r?/* @__PURE__ */oe(se,{children:[
27
+ /* @__PURE__ */ae("span",{className:"es-copy-bar-split","aria-hidden":"true"}),r]}):null,a?/* @__PURE__ */ae("span",{className:"es-copy-bar-end",children:a}):null]}):null}function lt({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 rt({value:e,onChange:n,onCommit:l,onCancel:s,multiline:u=!1,placeholder:d,ariaLabel:h,className:k,readOnly:L=!1,rules:T,tools:j=[],writeMark:K,actions:P,align:O,glyphs:B,barLabel:F,renderFooter:$,inputRef:A,barShows:H="always",richText:R=!0,defaultShowMarks:U=!1,toolbar:W="final",colors:z,cells:I,letterCase:V}){const Z="final"===W,q=M("copy",t),Q=ee(null),X=A??Q,[Y,G]=te(!1),[J,_]=te(null),se=ee(We()).current,ie=ee(null);le(()=>{const t=ie.current;t&&e===t.to?ie.current=null:t&&e===t.from||(ie.current=null,se.reset())},[e,se]);const ce=t=>{ie.current={from:ie.current?.from??e,to:t},n(t)},ue=t=>({text:e,start:t?.selectionStart??J?.start??e.length,end:t?.selectionEnd??J?.end??e.length}),[de,pe]=te(U),fe=R&&!(u&&de),ye=ee(null),ve=re(),[xe,we]=te(null),[Ce,De]=te(!1),Ne=()=>{if(!fe)return X.current;const e=ye.current?.getSource()??J;return e?{selectionStart:e.start,selectionEnd:e.end}:null},Se=lt({target:X,onChange:ce}),Ee=e=>(_({start:e.selectionStart,end:e.selectionEnd}),e),Me=(t,n)=>{if(!fe)return void Se(e=>(n&&se.record(ue(e),"edit",Date.now()),Ee(t(e))));const l=Ne(),r=Ee(t(l));n&&se.record(ue(l),"edit",Date.now()),we(null),r.text!==e&&ce(r.text),ye.current?.setSource(r.selectionStart,r.selectionEnd,r.text)},Le=e=>Me(e,!0),Te=e=>Me(t=>{const n=ue(t),l=se[e](n);return l?{text:l.text,selectionStart:l.start,selectionEnd:l.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),je=ee(null);ne(()=>{const t=je.current;t&&(je.current=null,fe?ye.current?.setSource(t.start,t.end,e):(X.current?.focus(),X.current?.setSelectionRange(t.start,t.end),_(t)))},[fe]);const[Ke,Pe]=te(null),Oe=T??c,Be=("string"==typeof j[0]?m(j):j).filter(e=>!Je.has(e.style)),Fe=Z?("string"==typeof j[0]?j:j.map(e=>e.style)).filter(e=>!Je.has(e)):Be.map(e=>e.style),$e={};if(J&&(fe||Z)){const t=f(e,J.start,J.end,Oe);for(const e of Fe){const n=t.has(e)||"highlight"===e&&t.has("accent");$e[e]=!!xe?.add.includes(e)||!xe?.drop.includes(e)&&n}Z&&($e.link=t.has("link"))}else if(J)for(const t of Fe)$e[t]="link"===t?null!==b(e,J.start,J.end):g(e,J.start,J.end,t);const Ae=()=>{const t=Ne(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},He={sup:"sub",sub:"sup"},Ue=t=>{if(Z&&"link"!==t&&p(0,t)){const{start:n,end:l}=Ae(),r=He[t];if(n===l){if(!fe)return void Le(n=>be(e,t,n,(e,t,n,l)=>i(e,t,n,l,Oe,q.placeholders)));const a=f(e,n,l,Oe),o=xe&&xe.at===n?xe:null,s=a.has(t),c=!!o?.add.includes(t)||!o?.drop.includes(t)&&s;let u=(o?.add??[]).filter(e=>e!==t),d=(o?.drop??[]).filter(e=>e!==t);return c&&s?d.push(t):c||s||u.push(t),!c&&r&&(u=u.filter(e=>e!==r),a.has(r)&&(d=[...d.filter(e=>e!==r),r])),void we(u.length||d.length||void 0!==o?.color?{add:u,drop:d,color:o?.color,at:n}:null)}return void Le(()=>{let a=e,o=n,s=l;if(r&&!f(a,o,s,Oe).has(t)&&f(a,o,s,Oe).has(r)){const e=x(a,o,s,r,Oe);({text:a,selectionStart:o,selectionEnd:s}=e)}return x(a,o,s,t,Oe)})}if("clear"===t)return void Le(n=>be(e,t,n,(e,t,n)=>i(e,t,n,"clear",Oe)));if("link"!==t&&fe&&p(0,t)){const n=Ne(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;if(l===r){const n=f(e,l,r,Oe),a=n.has(t)||"highlight"===t&&n.has("accent"),o=xe&&xe.at===l?xe:null,s=!!o?.add.includes(t)||!o?.drop.includes(t)&&a,i=(o?.add??[]).filter(e=>e!==t),c=(o?.drop??[]).filter(e=>e!==t);return s&&a?c.push(t):s||a||i.push(t),void we(i.length||c.length?{add:i,drop:c,at:l}:null)}return void Le(n=>x(e,n?.selectionStart??l,n?.selectionEnd??r,t,Oe))}if("link"!==t){const n=K??((e,t,n,l)=>i(e,t,n,l,c,q.placeholders));return void Le(l=>be(e,t,l,n))}const n=Ne(),l=n?.selectionStart??e.length,r=n?.selectionEnd??l;De(!1),Pe({start:l,end:r,link:b(e,l,r)})},ze=J?y(e,J.start,J.end,Oe):null,Ie=J?xe&&void 0!==xe.color&&xe.at===J.start?xe.color:v(e,J.start,J.end,Oe):null,Ze=Ie?Ie.startsWith("#")?Ie:z?.find(e=>e.name===Ie)?.value:void 0,Xe=()=>{Pe(null),fe?ye.current?.focus():X.current?.focus()},Ye=t=>Ke&&/* @__PURE__ */ae(Qe,{floating:t,href:Ke.link?.href??"",editing:null!==Ke.link,onApply:t=>{const n=Ke;Pe(null),Le(()=>fe?S(e,n.start,n.end,t,Oe):E(e,n.start,n.end,t))},onRemove:()=>{const t=Ke.link,n=Ke;Pe(null),t&&Le(()=>fe?D(e,n.start,n.end,Oe):N(e,t))},onClose:Xe}),_e=O?he(O.allow,q.align):[],et="always"===H||Y||null!==Ke||Ce;/* @__PURE__ */
28
+ return oe("div",{className:"es-copy"+(k?` ${k}`:""),onFocus:()=>G(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||G(!1)},onKeyDownCapture:e=>{Ce&&"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),De(!1))},onKeyDown:e=>{const t=e.target===X.current||Boolean(e.target.closest?.(".es-rich"));if(L||!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 Te(r||e.shiftKey?"redo":"undo");const a=`${e.shiftKey?"shift+":""}${n}`;if(Z){const t={b:"bold",i:"italic",u:"underline",k:"link"}[a];if(!t||!Fe.includes(t))return;return e.preventDefault(),e.stopPropagation(),void Ue(t)}const o=Be.find(e=>e.shortcut===a);o&&(e.preventDefault(),e.stopPropagation(),Ue(o.style))},onPaste:t=>{const n=X.current;if(L||!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:Oe});Le(t=>ge(e,l,t))},style:z&&z.length>0?Object.fromEntries(z.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=X.current;t&&t.ownerDocument.activeElement===t&&_({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[et&&Z?/* @__PURE__ */oe("div",{className:"es-tb-wrap",children:[
29
+ /* @__PURE__ */ae(Ge,{words:q.toolbar??t.toolbar,align:q.align,alignmentLabel:q.alignment,ariaLabel:F??q.formatting,offered:new Set(Fe),pressed:$e,onMark:e=>Ue(e),color:z&&z.length>0?{run:Ze,open:Ce,onToggle:()=>{Pe(null),De(e=>!e)}}:void 0,linkOpen:null!==Ke,onUndo:()=>Te("undo"),alignment:O?{value:O.value,allow:O.allow,onChange:O.onChange,disabled:O.disabled}:void 0,list:{pressed:ze,onList:t=>{const{start:n,end:l}=Ae(),r=y(e,n,l,Oe);Le(()=>C(e,n,l,r===t?null:t,Oe))}},letterCase:V,disabled:L}),Ce&&z&&z.length>0?/* @__PURE__ */ae(qe,{colors:z,current:Ie,words:q.colors??t.colors,onPick:t=>{const{start:n,end:l}=Ae();if(n!==l)Le(()=>w(e,n,l,t,Oe));else{if(!fe)return;we({add:xe?.add??[],drop:xe?.drop??[],color:t,at:n})}}}):null,Ke?Ye(!0):null]}):null,Z&&I&&I.length>0?/* @__PURE__ */ae(Ve,{cells:I,words:q.cells??t.cells,readOnly:L}):null,et&&!Z?/* @__PURE__ */ae(nt,{tools:j,disabled:L,actions:P,glyphs:B,ariaLabel:F,pressed:$e,open:Ke?"link":null,onApply:Ue,align:O?/* @__PURE__ */ae(r,{options:_e,value:O.value,onChange:O.onChange,ariaLabel:q.alignment,disabled:L||O.disabled,fit:me(_e)}):null}):null,fe?/* @__PURE__ */ae(Re,{value:e,rules:Oe,multiline:u,readOnly:L,placeholder:d,ariaLabel:h,handle:ye,pending:xe??void 0,onEdit:(t,n,l)=>{se.record({text:e,start:n.start,end:n.end},l,Date.now()),we(null),ce(t)},onSelect:e=>{_(t=>t&&t.start===e.start&&t.end===e.end?t:e),!xe||e.start===xe.at&&e.end===xe.at||we(null)},onHistory:Te,onFormat:e=>{Fe.includes(e)&&Ue(e)},onCommit:l,onCancel:s}):/* @__PURE__ */ae(o,{value:e,onInput:e=>{se.record(ue(null),"type",Date.now()),ce(e)},onCommit:l,onCancel:s,multiline:u,placeholder:d,ariaLabel:h,rules:T,disabled:L,inputRef:X,className:"es-copy-box"}),Ke&&!Z?Ye(!1):null,$?$({focused:Y,insert:t=>Le(n=>ge(e,t,n))}):null,R&&u?/* @__PURE__ */oe("div",{className:"es-copy-marks",children:[
30
+ /* @__PURE__ */ae(a,{checked:de,onChange:()=>{const e=Ne();je.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:J,we(null),pe(e=>!e)},ariaLabelledBy:ve,disabled:L}),
31
+ /* @__PURE__ */ae("span",{id:ve,className:"es-copy-marks-label",children:q.showMarks??"Show marks"})]}):null]})}export{ie as COPY_ALIGNS,de as COPY_ALIGN_FIT,ue as COPY_ALIGN_GLYPHS,ce as COPY_ALIGN_LABELS,ze as COPY_CELLS,qe as ColorWindow,rt as CopyBox,Ve as CopyCells,Be as MARKUP_CLIPBOARD_TYPE,nt as MarkBar,Re as RichBox,Ue as TYPING_BURST_MS,Ge as TextToolbar,et as ariaShortcut,he as copyAlignOptions,We as createHistory,je as editVisible,ge as insertSelection,be as markSelection,Oe as markupOfRange,Ke as newLine,ke as pasteToMarkup,Ce as richLayout,Le as selectionToSource,Me as selectionToVisible,Pe as setBullet,Ne as toSource,Se as toSourceStart,Ee as toVisible,lt as useCaretEdit};
@@ -199,12 +199,12 @@ declare function copyTranslation(overlay: TranslationOverlay | null | undefined,
199
199
  * The Ground Up For Efficient Editor", 2026-09-29, step 1.1). Every function
200
200
  * takes a document and returns a new one; nothing here holds state, knows
201
201
  * about React, or touches a browser global, so a server component, a Node
202
- * script, a test and the editor's store all call the same code.
202
+ * script, a test and the easel's store all call the same code.
203
203
  *
204
204
  * find · walk · slotsOf read
205
205
  * insert · move · remove · duplicate change the tree
206
206
  * setProps · setRoot change one node's props, or the root's
207
- * normalizeData what the editor does to a document it opens
207
+ * normalizeData what the easel does to a document it opens
208
208
  * createNode · newId make a block the way the Add panel does
209
209
  * applyTranslation · … a page's other languages, kept beside it (./translate)
210
210
  *
@@ -232,7 +232,7 @@ declare function copyTranslation(overlay: TranslationOverlay | null | undefined,
232
232
  * ERRORS. An edit that names a node or slot that is not there, an index off the
233
233
  * end of a list, a move into the node's own subtree, or an insert that would
234
234
  * put a second copy of an id into the document throws a `DataError`. The
235
- * editor's store decides what an operator sees; this layer never guesses.
235
+ * easel's store decides what an operator sees; this layer never guesses.
236
236
  *
237
237
  * LEAF DISCIPLINE: no imports outside this folder, no dependency at all.
238
238
  * `crypto` is read inside `newId`, never at module evaluation.
@@ -294,7 +294,7 @@ declare function find(data: Data, config: DataConfig, id: string): Found | null;
294
294
  /** The list at an address, or `null` when no such slot exists. */
295
295
  declare function getList(data: Data, config: DataConfig, address: SlotAddress): Node[] | null;
296
296
  /**
297
- * What the editor does to a document when it opens it — the same result Puck
297
+ * What the easel does to a document when it opens it — the same result Puck
298
298
  * reaches on load, with the older formats converted (rule 4):
299
299
  *
300
300
  * - `root` holding its props directly becomes `{ props: { …those keys } }`;
@@ -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 {