@namroodinc/liquid-editorial 0.14.0 → 0.15.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 (198) hide show
  1. package/README.md +1 -1
  2. package/UPGRADING.md +47 -0
  3. package/dist/chunks/{Avatar-Dw7EWd_-.cjs → Avatar-BZGFSE6C.cjs} +2 -2
  4. package/dist/chunks/{Avatar-Dw7EWd_-.cjs.map → Avatar-BZGFSE6C.cjs.map} +1 -1
  5. package/dist/chunks/{Avatar-BToMaTdL.js → Avatar-C4W-g8nU.js} +2 -2
  6. package/dist/chunks/{Avatar-BToMaTdL.js.map → Avatar-C4W-g8nU.js.map} +1 -1
  7. package/dist/chunks/{Board-XeDG9nWP.js → Board-Cbi5FMW-.js} +2 -2
  8. package/dist/chunks/{Board-XeDG9nWP.js.map → Board-Cbi5FMW-.js.map} +1 -1
  9. package/dist/chunks/{Board-DeXtaWNO.cjs → Board-_agEjTy8.cjs} +2 -2
  10. package/dist/chunks/{Board-DeXtaWNO.cjs.map → Board-_agEjTy8.cjs.map} +1 -1
  11. package/dist/chunks/{CollectionView-Dbg4d_tA.cjs → CollectionView-BfX2Lxre.cjs} +2 -2
  12. package/dist/chunks/{CollectionView-Dbg4d_tA.cjs.map → CollectionView-BfX2Lxre.cjs.map} +1 -1
  13. package/dist/chunks/{CollectionView-C0_bTO2v.js → CollectionView-DPJGtSP5.js} +2 -2
  14. package/dist/chunks/{CollectionView-C0_bTO2v.js.map → CollectionView-DPJGtSP5.js.map} +1 -1
  15. package/dist/chunks/{ColourField-DAFzOIOq.cjs → ColourField-BVGnW8Wh.cjs} +2 -2
  16. package/dist/chunks/{ColourField-DAFzOIOq.cjs.map → ColourField-BVGnW8Wh.cjs.map} +1 -1
  17. package/dist/chunks/{ColourField-Bb8H87fg.js → ColourField-BcuARZY4.js} +6 -6
  18. package/dist/chunks/{ColourField-Bb8H87fg.js.map → ColourField-BcuARZY4.js.map} +1 -1
  19. package/dist/chunks/{DatePicker-COm1giw8.js → DatePicker-VQUsbYdo.js} +3 -3
  20. package/dist/chunks/{DatePicker-COm1giw8.js.map → DatePicker-VQUsbYdo.js.map} +1 -1
  21. package/dist/chunks/{DatePicker-DOg3iQYy.cjs → DatePicker-zA0bWVBp.cjs} +2 -2
  22. package/dist/chunks/{DatePicker-DOg3iQYy.cjs.map → DatePicker-zA0bWVBp.cjs.map} +1 -1
  23. package/dist/chunks/{Drawer-nUTJtwX_.js → Drawer-2cf0SaG4.js} +3 -3
  24. package/dist/chunks/{Drawer-nUTJtwX_.js.map → Drawer-2cf0SaG4.js.map} +1 -1
  25. package/dist/chunks/{Drawer-B2dcTh5l.cjs → Drawer-BzvSfkCL.cjs} +2 -2
  26. package/dist/chunks/{Drawer-B2dcTh5l.cjs.map → Drawer-BzvSfkCL.cjs.map} +1 -1
  27. package/dist/chunks/{EntryPicker-Ie9T47hA.js → EntryPicker-BGWxiLJ_.js} +7 -7
  28. package/dist/chunks/{EntryPicker-Ie9T47hA.js.map → EntryPicker-BGWxiLJ_.js.map} +1 -1
  29. package/dist/chunks/{EntryPicker-BwEYRtQl.cjs → EntryPicker-wVjzdlAO.cjs} +2 -2
  30. package/dist/chunks/{EntryPicker-BwEYRtQl.cjs.map → EntryPicker-wVjzdlAO.cjs.map} +1 -1
  31. package/dist/chunks/{FormEditor-DgDV5aeR.js → FormEditor-BHVJG23r.js} +2 -2
  32. package/dist/chunks/{FormEditor-DgDV5aeR.js.map → FormEditor-BHVJG23r.js.map} +1 -1
  33. package/dist/chunks/{FormEditor-D1HUnjMI.cjs → FormEditor-DjUz7qQo.cjs} +2 -2
  34. package/dist/chunks/{FormEditor-D1HUnjMI.cjs.map → FormEditor-DjUz7qQo.cjs.map} +1 -1
  35. package/dist/chunks/Icon-QLZH31JA.cjs +2 -0
  36. package/dist/chunks/Icon-QLZH31JA.cjs.map +1 -0
  37. package/dist/chunks/Icon-kLLQC54Z.js +107 -0
  38. package/dist/chunks/Icon-kLLQC54Z.js.map +1 -0
  39. package/dist/chunks/{Message-VJTPhId7.js → Message-DM6pTq7N.js} +2 -2
  40. package/dist/chunks/{Message-VJTPhId7.js.map → Message-DM6pTq7N.js.map} +1 -1
  41. package/dist/chunks/{Message-B0A5bz8V.cjs → Message-yZJDVzb8.cjs} +2 -2
  42. package/dist/chunks/{Message-B0A5bz8V.cjs.map → Message-yZJDVzb8.cjs.map} +1 -1
  43. package/dist/chunks/RichTextEditor-BgfeOrEe.cjs +2 -0
  44. package/dist/chunks/RichTextEditor-BgfeOrEe.cjs.map +1 -0
  45. package/dist/chunks/RichTextEditor-CS2ED0HP.js +2702 -0
  46. package/dist/chunks/RichTextEditor-CS2ED0HP.js.map +1 -0
  47. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs +2 -0
  48. package/dist/chunks/dialogLabel-Dx-WEEzI.cjs.map +1 -0
  49. package/dist/chunks/dialogLabel-nB1gwKz0.js +157 -0
  50. package/dist/chunks/dialogLabel-nB1gwKz0.js.map +1 -0
  51. package/dist/chunks/overlayLayer-CPd3zj_u.cjs +2 -0
  52. package/dist/chunks/overlayLayer-CPd3zj_u.cjs.map +1 -0
  53. package/dist/chunks/overlayLayer-Dv1vmfaI.js +199 -0
  54. package/dist/chunks/overlayLayer-Dv1vmfaI.js.map +1 -0
  55. package/dist/chunks/{useTooltip-Du8PutGX.js → useTooltip-COyAcujL.js} +2 -2
  56. package/dist/chunks/{useTooltip-Du8PutGX.js.map → useTooltip-COyAcujL.js.map} +1 -1
  57. package/dist/chunks/{useTooltip-ekdwMJFz.cjs → useTooltip-nEDN0ObI.cjs} +2 -2
  58. package/dist/chunks/{useTooltip-ekdwMJFz.cjs.map → useTooltip-nEDN0ObI.cjs.map} +1 -1
  59. package/dist/components/AppShell/index.cjs +1 -1
  60. package/dist/components/AppShell/index.js +1 -1
  61. package/dist/components/AssetCard/index.cjs +1 -1
  62. package/dist/components/AssetCard/index.js +1 -1
  63. package/dist/components/AssetGrid/index.cjs +1 -1
  64. package/dist/components/AssetGrid/index.js +1 -1
  65. package/dist/components/Avatar/index.cjs +1 -1
  66. package/dist/components/Avatar/index.js +1 -1
  67. package/dist/components/Banner/index.cjs +1 -1
  68. package/dist/components/Banner/index.js +1 -1
  69. package/dist/components/Board/index.cjs +1 -1
  70. package/dist/components/Board/index.js +1 -1
  71. package/dist/components/Button/index.cjs +1 -1
  72. package/dist/components/Button/index.js +1 -1
  73. package/dist/components/CollectionView/index.cjs +1 -1
  74. package/dist/components/CollectionView/index.js +1 -1
  75. package/dist/components/ColourField/index.cjs +1 -1
  76. package/dist/components/ColourField/index.js +1 -1
  77. package/dist/components/DatePicker/index.cjs +1 -1
  78. package/dist/components/DatePicker/index.js +1 -1
  79. package/dist/components/Drawer/index.cjs +1 -1
  80. package/dist/components/Drawer/index.js +1 -1
  81. package/dist/components/EditLayout/index.cjs +1 -1
  82. package/dist/components/EditLayout/index.cjs.map +1 -1
  83. package/dist/components/EditLayout/index.js +6 -7
  84. package/dist/components/EditLayout/index.js.map +1 -1
  85. package/dist/components/EntryPicker/index.cjs +1 -1
  86. package/dist/components/EntryPicker/index.js +1 -1
  87. package/dist/components/EntryPicker/style.css +1 -1
  88. package/dist/components/FormEditor/README.md +72 -34
  89. package/dist/components/FormEditor/index.cjs +1 -1
  90. package/dist/components/FormEditor/index.js +2 -2
  91. package/dist/components/Icon/icons.d.cts +5 -0
  92. package/dist/components/Icon/icons.d.cts.map +1 -1
  93. package/dist/components/Icon/icons.d.ts +5 -0
  94. package/dist/components/Icon/icons.d.ts.map +1 -1
  95. package/dist/components/Icon/index.cjs +1 -1
  96. package/dist/components/Icon/index.js +1 -1
  97. package/dist/components/Menu/index.cjs +1 -1
  98. package/dist/components/Menu/index.js +9 -9
  99. package/dist/components/Menu/index.js.map +1 -1
  100. package/dist/components/Modal/index.cjs +1 -1
  101. package/dist/components/Modal/index.js +2 -2
  102. package/dist/components/Popover/index.cjs +1 -1
  103. package/dist/components/Popover/index.cjs.map +1 -1
  104. package/dist/components/Popover/index.d.cts.map +1 -1
  105. package/dist/components/Popover/index.d.ts.map +1 -1
  106. package/dist/components/Popover/index.js +67 -64
  107. package/dist/components/Popover/index.js.map +1 -1
  108. package/dist/components/RichTextEditor/content-block-frame.d.cts +32 -0
  109. package/dist/components/RichTextEditor/content-block-frame.d.cts.map +1 -0
  110. package/dist/components/RichTextEditor/content-block-frame.d.ts +32 -0
  111. package/dist/components/RichTextEditor/content-block-frame.d.ts.map +1 -0
  112. package/dist/components/RichTextEditor/content-block-view.d.cts +3 -0
  113. package/dist/components/RichTextEditor/content-block-view.d.cts.map +1 -0
  114. package/dist/components/RichTextEditor/content-block-view.d.ts +3 -0
  115. package/dist/components/RichTextEditor/content-block-view.d.ts.map +1 -0
  116. package/dist/components/RichTextEditor/content-block.d.cts +24 -0
  117. package/dist/components/RichTextEditor/content-block.d.cts.map +1 -0
  118. package/dist/components/RichTextEditor/content-block.d.ts +24 -0
  119. package/dist/components/RichTextEditor/content-block.d.ts.map +1 -0
  120. package/dist/components/RichTextEditor/document.d.cts +10 -7
  121. package/dist/components/RichTextEditor/document.d.cts.map +1 -1
  122. package/dist/components/RichTextEditor/document.d.ts +10 -7
  123. package/dist/components/RichTextEditor/document.d.ts.map +1 -1
  124. package/dist/components/RichTextEditor/index.cjs +1 -1
  125. package/dist/components/RichTextEditor/index.d.cts +1 -1
  126. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  127. package/dist/components/RichTextEditor/index.d.ts +1 -1
  128. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  129. package/dist/components/RichTextEditor/index.js +1 -1
  130. package/dist/components/RichTextEditor/style.css +126 -49
  131. package/dist/components/RichTextEditor/table-actions.d.cts +11 -0
  132. package/dist/components/RichTextEditor/table-actions.d.cts.map +1 -0
  133. package/dist/components/RichTextEditor/table-actions.d.ts +11 -0
  134. package/dist/components/RichTextEditor/table-actions.d.ts.map +1 -0
  135. package/dist/components/RichTextEditor/table-bands.d.cts +19 -0
  136. package/dist/components/RichTextEditor/table-bands.d.cts.map +1 -0
  137. package/dist/components/RichTextEditor/table-bands.d.ts +19 -0
  138. package/dist/components/RichTextEditor/table-bands.d.ts.map +1 -0
  139. package/dist/components/RichTextEditor/table-view.d.cts +4 -0
  140. package/dist/components/RichTextEditor/table-view.d.cts.map +1 -0
  141. package/dist/components/RichTextEditor/table-view.d.ts +4 -0
  142. package/dist/components/RichTextEditor/table-view.d.ts.map +1 -0
  143. package/dist/components/RichTextEditor/tables.d.cts.map +1 -1
  144. package/dist/components/RichTextEditor/tables.d.ts.map +1 -1
  145. package/dist/components/RichTextEditor/use-embeds.d.cts.map +1 -1
  146. package/dist/components/RichTextEditor/use-embeds.d.ts.map +1 -1
  147. package/dist/components/SearchField/index.cjs +1 -1
  148. package/dist/components/SearchField/index.js +1 -1
  149. package/dist/components/Select/index.cjs +1 -1
  150. package/dist/components/Select/index.js +2 -2
  151. package/dist/components/SideNav/index.cjs +1 -1
  152. package/dist/components/SideNav/index.js +1 -1
  153. package/dist/components/SortableList/index.cjs +1 -1
  154. package/dist/components/SortableList/index.js +1 -1
  155. package/dist/components/Stepper/index.cjs +1 -1
  156. package/dist/components/Stepper/index.js +1 -1
  157. package/dist/components/SubNav/index.cjs +1 -1
  158. package/dist/components/SubNav/index.js +1 -1
  159. package/dist/components/Switch/style.css +2 -6
  160. package/dist/components/Table/index.cjs +1 -1
  161. package/dist/components/Table/index.js +1 -1
  162. package/dist/components/Time/index.cjs +1 -1
  163. package/dist/components/Time/index.js +1 -1
  164. package/dist/components/Toast/index.cjs +1 -1
  165. package/dist/components/Toast/index.js +1 -1
  166. package/dist/components/TopNav/index.cjs +1 -1
  167. package/dist/components/TopNav/index.js +1 -1
  168. package/dist/index.cjs +1 -1
  169. package/dist/index.d.cts +1 -1
  170. package/dist/index.d.cts.map +1 -1
  171. package/dist/index.d.ts +1 -1
  172. package/dist/index.d.ts.map +1 -1
  173. package/dist/index.js +17 -17
  174. package/package.json +1 -1
  175. package/dist/chunks/Icon-Bxvp1-td.js +0 -102
  176. package/dist/chunks/Icon-Bxvp1-td.js.map +0 -1
  177. package/dist/chunks/Icon-CnnTrtNb.cjs +0 -2
  178. package/dist/chunks/Icon-CnnTrtNb.cjs.map +0 -1
  179. package/dist/chunks/RichTextEditor-DPhEkDxi.js +0 -2108
  180. package/dist/chunks/RichTextEditor-DPhEkDxi.js.map +0 -1
  181. package/dist/chunks/RichTextEditor-DV7NZp_k.cjs +0 -2
  182. package/dist/chunks/RichTextEditor-DV7NZp_k.cjs.map +0 -1
  183. package/dist/chunks/dialogLabel-C153NosD.js +0 -176
  184. package/dist/chunks/dialogLabel-C153NosD.js.map +0 -1
  185. package/dist/chunks/dialogLabel-CNNQbtob.cjs +0 -2
  186. package/dist/chunks/dialogLabel-CNNQbtob.cjs.map +0 -1
  187. package/dist/chunks/overlayLayer-CtOTt1xB.cjs +0 -2
  188. package/dist/chunks/overlayLayer-CtOTt1xB.cjs.map +0 -1
  189. package/dist/chunks/overlayLayer-Og07sIyl.js +0 -180
  190. package/dist/chunks/overlayLayer-Og07sIyl.js.map +0 -1
  191. package/dist/components/RichTextEditor/storyblock-view.d.cts +0 -3
  192. package/dist/components/RichTextEditor/storyblock-view.d.cts.map +0 -1
  193. package/dist/components/RichTextEditor/storyblock-view.d.ts +0 -3
  194. package/dist/components/RichTextEditor/storyblock-view.d.ts.map +0 -1
  195. package/dist/components/RichTextEditor/storyblock.d.cts +0 -19
  196. package/dist/components/RichTextEditor/storyblock.d.cts.map +0 -1
  197. package/dist/components/RichTextEditor/storyblock.d.ts +0 -19
  198. package/dist/components/RichTextEditor/storyblock.d.ts.map +0 -1
@@ -0,0 +1,107 @@
1
+ import { forwardRef as e } from "react";
2
+ import { AlertTriangle as t, AlignCenter as n, AlignJustify as r, AlignLeft as i, AlignRight as a, Archive as ee, ArrowDown as te, ArrowLeft as o, ArrowRight as s, ArrowUp as c, AudioLines as l, Bell as u, Blocks as d, Bold as f, Calendar as p, Check as m, ChevronDown as h, ChevronLeft as g, ChevronRight as _, ChevronUp as v, ChevronsLeft as y, ChevronsRight as b, Clock as x, Code as S, Columns2PlusLeft as C, Columns2PlusRight as w, Copy as T, Download as E, ExternalLink as D, Eye as O, FileText as k, Film as A, Filter as j, FolderClosed as M, Globe as N, Grid2x2Plus as P, Grid2x2X as F, GripHorizontal as I, GripVertical as L, Heading2 as R, Heading3 as z, Home as B, Image as V, Info as H, Italic as U, KeyRound as W, LayoutGrid as G, Link as K, Link2Off as q, List as J, ListOrdered as Y, Loader2 as ne, LogIn as X, LogOut as Z, Maximize2 as re, Menu as ie, Minimize2 as ae, Minus as oe, MoreHorizontal as se, PanelLeft as ce, PanelTop as le, Pencil as ue, Pipette as de, Plus as fe, Quote as pe, Redo2 as me, RotateCcw as he, RotateCw as ge, Rows2PlusBottom as _e, Rows2PlusTop as ve, Search as ye, Settings as be, Strikethrough as xe, Table as Se, TableCellsMerge as Ce, TableCellsSplit as we, TableColumnsSplit as Te, TableRowsSplit as Ee, ToggleLeft as De, Trash2 as Oe, Undo2 as Q, Upload as ke, User as Ae, Users as je, X as Me } from "lucide-react";
3
+ import { jsx as Ne } from "react/jsx-runtime";
4
+ //#region src/components/Icon/icons.ts
5
+ var $ = {
6
+ "align-left": i,
7
+ "align-center": n,
8
+ "align-justify": r,
9
+ "align-right": a,
10
+ "alert-triangle": t,
11
+ archive: ee,
12
+ blocks: d,
13
+ film: A,
14
+ "audio-lines": l,
15
+ bold: f,
16
+ code: S,
17
+ "heading-2": R,
18
+ "heading-3": z,
19
+ italic: U,
20
+ "link-off": q,
21
+ list: J,
22
+ "list-ordered": Y,
23
+ quote: pe,
24
+ redo: me,
25
+ strikethrough: xe,
26
+ undo: Q,
27
+ "arrow-down": te,
28
+ "arrow-left": o,
29
+ "arrow-right": s,
30
+ "arrow-up": c,
31
+ calendar: p,
32
+ check: m,
33
+ "chevron-down": h,
34
+ "chevron-left": g,
35
+ "chevron-up": v,
36
+ minus: oe,
37
+ "chevron-right": _,
38
+ clock: x,
39
+ copy: T,
40
+ download: E,
41
+ eye: O,
42
+ "external-link": D,
43
+ filter: j,
44
+ bell: u,
45
+ "chevrons-left": y,
46
+ "chevrons-right": b,
47
+ "file-text": k,
48
+ folder: M,
49
+ globe: N,
50
+ home: B,
51
+ "layout-grid": G,
52
+ menu: ie,
53
+ "maximize-2": re,
54
+ "minimize-2": ae,
55
+ users: je,
56
+ "grip-horizontal": I,
57
+ "grip-vertical": L,
58
+ image: V,
59
+ info: H,
60
+ link: K,
61
+ "log-in": X,
62
+ "log-out": Z,
63
+ "key-round": W,
64
+ spinner: ne,
65
+ "more-horizontal": se,
66
+ pencil: ue,
67
+ pipette: de,
68
+ plus: fe,
69
+ "rotate-ccw": he,
70
+ "rotate-cw": ge,
71
+ search: ye,
72
+ settings: be,
73
+ "toggle-left": De,
74
+ trash: Oe,
75
+ upload: ke,
76
+ user: Ae,
77
+ "columns-2-plus-left": C,
78
+ "columns-2-plus-right": w,
79
+ "grid-2x2-plus": P,
80
+ "grid-2x2-x": F,
81
+ "panel-left": ce,
82
+ "panel-top": le,
83
+ "rows-2-plus-bottom": _e,
84
+ "rows-2-plus-top": ve,
85
+ table: Se,
86
+ "table-cells-merge": Ce,
87
+ "table-cells-split": we,
88
+ "table-columns-split": Te,
89
+ "table-rows-split": Ee,
90
+ x: Me
91
+ }, Pe = Object.keys($), Fe = e(function({ name: e, size: t = 16, className: n, ...r }, i) {
92
+ let a = $[e];
93
+ return /* @__PURE__ */ Ne(a, {
94
+ ref: i,
95
+ width: t,
96
+ height: t,
97
+ className: ["ds-icon", n].filter(Boolean).join(" "),
98
+ role: r["aria-label"] ? "img" : void 0,
99
+ "aria-hidden": !r["aria-label"] || void 0,
100
+ focusable: "false",
101
+ ...r
102
+ });
103
+ });
104
+ //#endregion
105
+ export { Pe as n, $ as r, Fe as t };
106
+
107
+ //# sourceMappingURL=Icon-kLLQC54Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon-kLLQC54Z.js","names":["icons","AlignLeft","AlignCenter","AlignJustify","AlignRight","AlertTriangle","Archive","Blocks","Film","AudioLines","Bold","Code","Heading2","Heading3","Italic","Link2Off","List","ListOrdered","Quote","Redo2","Strikethrough","Undo2","ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Calendar","Check","ChevronDown","ChevronLeft","ChevronUp","Minus","ChevronRight","Clock","Copy","Download","Eye","ExternalLink","Filter","Bell","ChevronsLeft","ChevronsRight","FileText","FolderClosed","Globe","Home","LayoutGrid","Menu","Maximize2","Minimize2","Users","GripHorizontal","GripVertical","Image","Info","Link","LogIn","LogOut","KeyRound","Loader2","MoreHorizontal","Pencil","Pipette","Plus","RotateCcw","RotateCw","Search","Settings","ToggleLeft","Trash2","Upload","User","Columns2PlusLeft","Columns2PlusRight","Grid2x2Plus","Grid2x2X","PanelLeft","PanelTop","Rows2PlusBottom","Rows2PlusTop","Table","TableCellsMerge","TableCellsSplit","TableColumnsSplit","TableRowsSplit","X","iconNames","Icon","forwardRef","rest","Glyph","name","size","className"],"sources":["../../src/components/Icon/icons.ts","../../src/components/Icon/index.tsx"],"sourcesContent":["import {\n AlignLeft,\n AlignCenter,\n AlignJustify,\n AlignRight,\n AlertTriangle,\n Blocks,\n Film,\n AudioLines,\n Bold,\n Code,\n Heading2,\n Heading3,\n Italic,\n Link2Off,\n List,\n ListOrdered,\n Quote,\n Redo2,\n Strikethrough,\n Undo2,\n Archive,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n Calendar,\n Check,\n ChevronDown,\n ChevronLeft,\n ChevronUp,\n Minus,\n ChevronRight,\n Clock,\n Copy,\n Download,\n Eye,\n ExternalLink,\n Filter,\n Bell,\n ChevronsLeft,\n ChevronsRight,\n FileText,\n FolderClosed,\n Globe,\n Home,\n LayoutGrid,\n Menu,\n Maximize2,\n Minimize2,\n Users,\n GripHorizontal,\n GripVertical,\n Image,\n Info,\n Link,\n LogIn,\n LogOut,\n KeyRound,\n Loader2,\n MoreHorizontal,\n Pencil,\n Pipette,\n Plus,\n RotateCcw,\n RotateCw,\n Search,\n Settings,\n ToggleLeft,\n Trash2,\n Upload,\n User,\n Columns2PlusLeft,\n Columns2PlusRight,\n Grid2x2Plus,\n Grid2x2X,\n PanelLeft,\n PanelTop,\n Rows2PlusBottom,\n Rows2PlusTop,\n Table,\n TableCellsMerge,\n TableCellsSplit,\n TableColumnsSplit,\n TableRowsSplit,\n X,\n} from \"lucide-react\";\n\n/**\n * The finite icon set. Adding a glyph means adding a line here — a visible\n * decision rather than an import someone typed at a call site.\n */\nexport const icons = {\n \"align-left\": AlignLeft,\n \"align-center\": AlignCenter,\n \"align-justify\": AlignJustify,\n \"align-right\": AlignRight,\n \"alert-triangle\": AlertTriangle,\n archive: Archive,\n blocks: Blocks,\n film: Film,\n \"audio-lines\": AudioLines,\n bold: Bold,\n code: Code,\n \"heading-2\": Heading2,\n \"heading-3\": Heading3,\n italic: Italic,\n \"link-off\": Link2Off,\n list: List,\n \"list-ordered\": ListOrdered,\n quote: Quote,\n redo: Redo2,\n strikethrough: Strikethrough,\n undo: Undo2,\n \"arrow-down\": ArrowDown,\n \"arrow-left\": ArrowLeft,\n \"arrow-right\": ArrowRight,\n \"arrow-up\": ArrowUp,\n calendar: Calendar,\n check: Check,\n \"chevron-down\": ChevronDown,\n \"chevron-left\": ChevronLeft,\n \"chevron-up\": ChevronUp,\n minus: Minus,\n \"chevron-right\": ChevronRight,\n clock: Clock,\n copy: Copy,\n download: Download,\n eye: Eye,\n \"external-link\": ExternalLink,\n filter: Filter,\n bell: Bell,\n \"chevrons-left\": ChevronsLeft,\n \"chevrons-right\": ChevronsRight,\n \"file-text\": FileText,\n folder: FolderClosed,\n globe: Globe,\n home: Home,\n \"layout-grid\": LayoutGrid,\n menu: Menu,\n \"maximize-2\": Maximize2,\n \"minimize-2\": Minimize2,\n users: Users,\n \"grip-horizontal\": GripHorizontal,\n \"grip-vertical\": GripVertical,\n image: Image,\n info: Info,\n link: Link,\n \"log-in\": LogIn,\n \"log-out\": LogOut,\n \"key-round\": KeyRound,\n spinner: Loader2,\n \"more-horizontal\": MoreHorizontal,\n pencil: Pencil,\n pipette: Pipette,\n plus: Plus,\n \"rotate-ccw\": RotateCcw,\n \"rotate-cw\": RotateCw,\n search: Search,\n settings: Settings,\n \"toggle-left\": ToggleLeft,\n trash: Trash2,\n upload: Upload,\n user: User,\n \"columns-2-plus-left\": Columns2PlusLeft,\n \"columns-2-plus-right\": Columns2PlusRight,\n \"grid-2x2-plus\": Grid2x2Plus,\n \"grid-2x2-x\": Grid2x2X,\n \"panel-left\": PanelLeft,\n \"panel-top\": PanelTop,\n \"rows-2-plus-bottom\": Rows2PlusBottom,\n \"rows-2-plus-top\": Rows2PlusTop,\n table: Table,\n \"table-cells-merge\": TableCellsMerge,\n \"table-cells-split\": TableCellsSplit,\n \"table-columns-split\": TableColumnsSplit,\n \"table-rows-split\": TableRowsSplit,\n x: X,\n} as const;\n\nexport type IconName = keyof typeof icons;\n\nexport const iconNames = Object.keys(icons) as IconName[];\n","import { forwardRef, type SVGProps } from \"react\";\nimport { icons, type IconName } from \"./icons\";\nimport \"./style.css\";\n\nexport type IconSize = 16 | 20 | 24;\n\nexport interface IconProps extends Omit<SVGProps<SVGSVGElement>, \"ref\"> {\n /** Glyph name from the curated set in `icons.ts`. */\n name: IconName;\n /** 16 inside controls, 20 standalone, 24 for empty states. No other sizes. */\n size?: IconSize;\n}\n\n/**\n * A glyph that clarifies an action or a status. Inherits `currentColor`, so it\n * takes its colour from the control it sits in — it never carries its own.\n */\nexport const Icon = forwardRef<SVGSVGElement, IconProps>(function Icon(\n { name, size = 16, className, ...rest },\n ref,\n) {\n const Glyph = icons[name];\n return (\n <Glyph\n ref={ref}\n width={size}\n height={size}\n className={[\"ds-icon\", className].filter(Boolean).join(\" \")}\n role={rest[\"aria-label\"] ? \"img\" : undefined}\n aria-hidden={rest[\"aria-label\"] ? undefined : true}\n focusable=\"false\"\n {...rest}\n />\n );\n});\n"],"mappings":";;;;AA4FA,IAAaA,IAAQ;CACnB,cAAcC;CACd,gBAAgBC;CAChB,iBAAiBC;CACjB,eAAeC;CACf,kBAAkBC;CAClB,SAASC;CACT,QAAQC;CACR,MAAMC;CACN,eAAeC;CACf,MAAMC;CACN,MAAMC;CACN,aAAaC;CACb,aAAaC;CACb,QAAQC;CACR,YAAYC;CACZ,MAAMC;CACN,gBAAgBC;CAChB,OAAOC;CACP,MAAMC;CACN,eAAeC;CACf,MAAMC;CACN,cAAcC;CACd,cAAcC;CACd,eAAeC;CACf,YAAYC;CACZ,UAAUC;CACV,OAAOC;CACP,gBAAgBC;CAChB,gBAAgBC;CAChB,cAAcC;CACd,OAAOC;CACP,iBAAiBC;CACjB,OAAOC;CACP,MAAMC;CACN,UAAUC;CACV,KAAKC;CACL,iBAAiBC;CACjB,QAAQC;CACR,MAAMC;CACN,iBAAiBC;CACjB,kBAAkBC;CAClB,aAAaC;CACb,QAAQC;CACR,OAAOC;CACP,MAAMC;CACN,eAAeC;CACf,MAAMC;CACN,cAAcC;CACd,cAAcC;CACd,OAAOC;CACP,mBAAmBC;CACnB,iBAAiBC;CACjB,OAAOC;CACP,MAAMC;CACN,MAAMC;CACN,UAAUC;CACV,WAAWC;CACX,aAAaC;CACb,SAASC;CACT,mBAAmBC;CACnB,QAAQC;CACR,SAASC;CACT,MAAMC;CACN,cAAcC;CACd,aAAaC;CACb,QAAQC;CACR,UAAUC;CACV,eAAeC;CACf,OAAOC;CACP,QAAQC;CACR,MAAMC;CACN,uBAAuBC;CACvB,wBAAwBC;CACxB,iBAAiBC;CACjB,cAAcC;CACd,cAAcC;CACd,aAAaC;CACb,sBAAsBC;CACtB,mBAAmBC;CACnB,OAAOC;CACP,qBAAqBC;CACrB,qBAAqBC;CACrB,uBAAuBC;CACvB,oBAAoBC;CACpB,GAAGC;AACL,GAIaC,KAAY,OAAO,KAAKtF,CAAK,GCrK7BuF,KAAOC,EAAqC,SACvD,EAAE,SAAM,UAAO,IAAI,cAAW,GAAGC,KACjC,GACA;CACA,IAAMC,IAAQ1F,EAAM2F;CACpB,OACE,mBAACD,GAAD;EACO;EACL,OAAOE;EACP,QAAQA;EACR,WAAW,CAAC,WAAWC,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC1D,MAAMJ,EAAK,gBAAgB,QAAQ,KAAA;EACnC,eAAa,GAAK,iBAAgB,KAAA;EAClC,WAAU;EACV,GAAIA;CACL,CAAA;AAEL,CAAC"}
@@ -1,4 +1,4 @@
1
- import { r as e, t } from "./Icon-Bxvp1-td.js";
1
+ import { r as e, t } from "./Icon-kLLQC54Z.js";
2
2
  import { Button as n } from "../components/Button/index.js";
3
3
  import { Fragment as r, forwardRef as i, isValidElement as a, useState as o } from "react";
4
4
  import { jsx as s, jsxs as c } from "react/jsx-runtime";
@@ -67,4 +67,4 @@ var h = (e) => e === "danger" || e === "warning" ? "alert" : "status", g = i(fun
67
67
  //#endregion
68
68
  export { g as t };
69
69
 
70
- //# sourceMappingURL=Message-VJTPhId7.js.map
70
+ //# sourceMappingURL=Message-DM6pTq7N.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Message-VJTPhId7.js","names":["icons","TONE_ICON","isBlank","node","someLeaf","child","test","isValidElement","Fragment","hasBody","leaf","hasActions","resolveIcon","icon","name","tone","toneRole","Message","forwardRef","rest","defaultRole","useState","iconName","slotClass","slot","classPrefix","Description","appearance","children","role","className","Icon","title","actions","onDismiss","Button","dismissLabel"],"sources":["../../src/internal/Message.tsx"],"sourcesContent":["import {\n forwardRef,\n Fragment,\n isValidElement,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../components/Button\";\nimport { Icon } from \"../components/Icon\";\nimport { icons, type IconName } from \"../components/Icon/icons\";\nimport \"../styles/message.css\";\n\nexport type MessageTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"review\";\n\nconst TONE_ICON: Record<MessageTone, IconName> = {\n neutral: \"info\",\n info: \"info\",\n success: \"check\",\n warning: \"alert-triangle\",\n danger: \"alert-triangle\",\n review: \"eye\",\n};\n\nexport interface MessageProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n tone?: MessageTone;\n appearance?: \"inline\" | \"floating\";\n title: string;\n /**\n * Omitted or `none` hides the icon; `auto` uses the tone's default glyph. A\n * name outside the curated icon set renders no icon rather than throwing.\n */\n icon?: IconName | \"auto\" | \"none\";\n actions?: ReactNode;\n /** Renders a dismiss control. The parent owns visibility. */\n onDismiss?: () => void;\n /** Accessible name of the dismiss control. Defaults to \"Dismiss\". */\n dismissLabel?: string;\n /** The public wrapper's block class, added beside each `ds-message__*` slot class. */\n classPrefix?: string;\n}\n\n/** Leftovers of conditional rendering: nothing visible, so no slot is reserved. */\nconst isBlank = (node: unknown) => node == null || typeof node === \"boolean\" || node === \"\";\n\n/** Whether `test` holds for any leaf, looking through arrays and fragments. */\nfunction someLeaf(node: ReactNode, test: (leaf: ReactNode) => boolean): boolean {\n if (Array.isArray(node)) {\n return node.some((child: ReactNode) => someLeaf(child, test));\n }\n if (isValidElement<{ children?: ReactNode }>(node) && node.type === Fragment) {\n return someLeaf(node.props.children, test);\n }\n return test(node);\n}\n\n// Numbers are content in the body (`0` items) but never an action: a `0` in the\n// actions slot comes from `count && <Button />`, so it reserves no row.\nconst hasBody = (node: ReactNode) => someLeaf(node, (leaf) => !isBlank(leaf));\nconst hasActions = (node: ReactNode) =>\n someLeaf(node, (leaf) => !isBlank(leaf) && typeof leaf !== \"number\");\n\nfunction resolveIcon(icon: MessageProps[\"icon\"], tone: MessageTone): IconName | undefined {\n if (icon === undefined || icon === \"none\") {\n return undefined;\n }\n const name = icon === \"auto\" ? TONE_ICON[tone] : icon;\n // Own keys only, so values such as \"constructor\" never reach Icon.\n return Object.hasOwn(icons, name) ? name : undefined;\n}\n\nconst toneRole = (tone: MessageTone) =>\n tone === \"danger\" || tone === \"warning\" ? \"alert\" : \"status\";\n\n/** Shared notification structure. Public wrappers own delivery and content policy. */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(function Message(\n {\n tone = \"neutral\",\n appearance = \"inline\",\n title,\n icon,\n actions,\n onDismiss,\n dismissLabel = \"Dismiss\",\n classPrefix,\n role,\n className,\n children,\n ...rest\n },\n ref,\n) {\n // A live region must exist before its content changes, so the default role\n // comes from the tone the message mounts with and survives later tone changes.\n const [defaultRole] = useState(() => toneRole(tone));\n const iconName = resolveIcon(icon, tone);\n const slotClass = (slot: string) =>\n [`ds-message__${slot}`, classPrefix && `${classPrefix}__${slot}`].filter(Boolean).join(\" \");\n // Plain-text toasts keep their span; JSX descriptions get a div that can hold blocks.\n const isText = typeof children === \"string\" || typeof children === \"number\";\n const Description = appearance === \"floating\" && isText ? \"span\" : \"div\";\n\n return (\n <div\n ref={ref}\n role={role ?? defaultRole}\n data-tone={tone === \"neutral\" ? undefined : tone}\n data-appearance={appearance}\n className={[\"ds-message\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {iconName && (\n <Icon\n name={iconName}\n size={20}\n className={slotClass(\"icon\")}\n />\n )}\n <div className={`${slotClass(\"body\")} ds-field-surface`}>\n <span className={slotClass(\"title\")}>{title}</span>\n {hasBody(children) && (\n <Description className={slotClass(\"description\")}>{children}</Description>\n )}\n {hasActions(actions) && <div className={slotClass(\"actions\")}>{actions}</div>}\n </div>\n {onDismiss && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n className={`${slotClass(\"dismiss\")} ds-field-surface`}\n aria-label={dismissLabel}\n onClick={onDismiss}\n />\n )}\n </div>\n );\n});\n"],"mappings":";;;;;AAeA,IAAMC,IAA2C;CAC/C,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;AACV,GAqBMC,KAAW,MAAkBC,KAAQ,QAAQ,OAAOA,KAAS,aAAaA,MAAS;AAGzF,SAASC,EAAS,GAAiB,GAA6C;CAO9E,OANI,MAAM,QAAQD,CAAI,IACbA,EAAK,MAAM,MAAqBC,EAASC,GAAOC,CAAI,CAAC,IAE1DC,EAAyCJ,CAAI,KAAKA,EAAK,SAASK,IAC3DJ,EAASD,EAAK,MAAM,UAAUG,CAAI,IAEpCA,EAAKH,CAAI;AAClB;AAIA,IAAMM,KAAW,MAAoBL,EAASD,IAAO,MAAS,CAACD,EAAQQ,CAAI,CAAC,GACtEC,KAAc,MAClBP,EAASD,IAAO,MAAS,CAACD,EAAQQ,CAAI,KAAK,OAAOA,KAAS,QAAQ;AAErE,SAASE,EAAY,GAA4B,GAAyC;CACxF,IAAIC,MAAS,KAAA,KAAaA,MAAS,QACjC;CAEF,IAAMC,IAAOD,MAAS,SAASZ,EAAUc,KAAQF;CAEjD,OAAO,OAAO,OAAOb,GAAOc,CAAI,IAAIA,IAAO,KAAA;AAC7C;AAEA,IAAME,KAAY,MAChBD,MAAS,YAAYA,MAAS,YAAY,UAAU,UAGzCE,IAAUC,EAAyC,SAC9D,EACE,UAAO,WACP,gBAAa,UACb,UACA,SACA,YACA,cACA,kBAAe,WACf,gBACA,SACA,cACA,aACA,GAAGC,KAEL,GACA;CAGA,IAAM,CAACC,KAAeC,QAAeL,EAASD,CAAI,CAAC,GAC7CO,IAAWV,EAAYC,GAAME,CAAI,GACjCQ,KAAa,MACjB,CAAC,eAAeC,KAAQC,KAAe,GAAGA,EAAY,IAAID,GAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,GAGtFE,IAAcC,MAAe,eADpB,OAAOC,KAAa,YAAY,OAAOA,KAAa,YACT,SAAS;CAEnE,OACE,kBAAC,OAAD;EACO;EACL,MAAMC,KAAQT;EACd,aAAWL,MAAS,YAAY,KAAA,IAAYA;EAC5C,mBAAiBY;EACjB,WAAW,CAAC,cAAcG,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC7D,GAAIX;EANN,UAAA;GAQGG,KACC,kBAACS,GAAD;IACE,MAAMT;IACN,MAAM;IACN,WAAWC,EAAU,MAAM;GAC5B,CAAA;GAEH,kBAAC,OAAD;IAAK,WAAW,GAAGA,EAAU,MAAM,EAAE;IAArC,UAAA;KACE,kBAAC,QAAD;MAAM,WAAWA,EAAU,OAAO;MAAI,UAAAS;KAAY,CAAA;KACjDvB,EAAQmB,CAAQ,KACf,kBAACF,GAAD;MAAa,WAAWH,EAAU,aAAa;MAAI;KAAsB,CAAA;KAE1EZ,EAAWsB,CAAO,KAAK,kBAAC,OAAD;MAAK,WAAWV,EAAU,SAAS;MAAI,UAAAU;KAAa,CAAA;IACzE;;GACJC,KACC,kBAACC,GAAD;IACE,SAAQ;IACR,MAAK;IACL,YAAA;IACA,WAAU;IACV,WAAW,GAAGZ,EAAU,SAAS,EAAE;IACnC,cAAYa;IACZ,SAASF;GACV,CAAA;EAEA;;AAET,CAAC"}
1
+ {"version":3,"file":"Message-DM6pTq7N.js","names":["icons","TONE_ICON","isBlank","node","someLeaf","child","test","isValidElement","Fragment","hasBody","leaf","hasActions","resolveIcon","icon","name","tone","toneRole","Message","forwardRef","rest","defaultRole","useState","iconName","slotClass","slot","classPrefix","Description","appearance","children","role","className","Icon","title","actions","onDismiss","Button","dismissLabel"],"sources":["../../src/internal/Message.tsx"],"sourcesContent":["import {\n forwardRef,\n Fragment,\n isValidElement,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../components/Button\";\nimport { Icon } from \"../components/Icon\";\nimport { icons, type IconName } from \"../components/Icon/icons\";\nimport \"../styles/message.css\";\n\nexport type MessageTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"review\";\n\nconst TONE_ICON: Record<MessageTone, IconName> = {\n neutral: \"info\",\n info: \"info\",\n success: \"check\",\n warning: \"alert-triangle\",\n danger: \"alert-triangle\",\n review: \"eye\",\n};\n\nexport interface MessageProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n tone?: MessageTone;\n appearance?: \"inline\" | \"floating\";\n title: string;\n /**\n * Omitted or `none` hides the icon; `auto` uses the tone's default glyph. A\n * name outside the curated icon set renders no icon rather than throwing.\n */\n icon?: IconName | \"auto\" | \"none\";\n actions?: ReactNode;\n /** Renders a dismiss control. The parent owns visibility. */\n onDismiss?: () => void;\n /** Accessible name of the dismiss control. Defaults to \"Dismiss\". */\n dismissLabel?: string;\n /** The public wrapper's block class, added beside each `ds-message__*` slot class. */\n classPrefix?: string;\n}\n\n/** Leftovers of conditional rendering: nothing visible, so no slot is reserved. */\nconst isBlank = (node: unknown) => node == null || typeof node === \"boolean\" || node === \"\";\n\n/** Whether `test` holds for any leaf, looking through arrays and fragments. */\nfunction someLeaf(node: ReactNode, test: (leaf: ReactNode) => boolean): boolean {\n if (Array.isArray(node)) {\n return node.some((child: ReactNode) => someLeaf(child, test));\n }\n if (isValidElement<{ children?: ReactNode }>(node) && node.type === Fragment) {\n return someLeaf(node.props.children, test);\n }\n return test(node);\n}\n\n// Numbers are content in the body (`0` items) but never an action: a `0` in the\n// actions slot comes from `count && <Button />`, so it reserves no row.\nconst hasBody = (node: ReactNode) => someLeaf(node, (leaf) => !isBlank(leaf));\nconst hasActions = (node: ReactNode) =>\n someLeaf(node, (leaf) => !isBlank(leaf) && typeof leaf !== \"number\");\n\nfunction resolveIcon(icon: MessageProps[\"icon\"], tone: MessageTone): IconName | undefined {\n if (icon === undefined || icon === \"none\") {\n return undefined;\n }\n const name = icon === \"auto\" ? TONE_ICON[tone] : icon;\n // Own keys only, so values such as \"constructor\" never reach Icon.\n return Object.hasOwn(icons, name) ? name : undefined;\n}\n\nconst toneRole = (tone: MessageTone) =>\n tone === \"danger\" || tone === \"warning\" ? \"alert\" : \"status\";\n\n/** Shared notification structure. Public wrappers own delivery and content policy. */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(function Message(\n {\n tone = \"neutral\",\n appearance = \"inline\",\n title,\n icon,\n actions,\n onDismiss,\n dismissLabel = \"Dismiss\",\n classPrefix,\n role,\n className,\n children,\n ...rest\n },\n ref,\n) {\n // A live region must exist before its content changes, so the default role\n // comes from the tone the message mounts with and survives later tone changes.\n const [defaultRole] = useState(() => toneRole(tone));\n const iconName = resolveIcon(icon, tone);\n const slotClass = (slot: string) =>\n [`ds-message__${slot}`, classPrefix && `${classPrefix}__${slot}`].filter(Boolean).join(\" \");\n // Plain-text toasts keep their span; JSX descriptions get a div that can hold blocks.\n const isText = typeof children === \"string\" || typeof children === \"number\";\n const Description = appearance === \"floating\" && isText ? \"span\" : \"div\";\n\n return (\n <div\n ref={ref}\n role={role ?? defaultRole}\n data-tone={tone === \"neutral\" ? undefined : tone}\n data-appearance={appearance}\n className={[\"ds-message\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {iconName && (\n <Icon\n name={iconName}\n size={20}\n className={slotClass(\"icon\")}\n />\n )}\n <div className={`${slotClass(\"body\")} ds-field-surface`}>\n <span className={slotClass(\"title\")}>{title}</span>\n {hasBody(children) && (\n <Description className={slotClass(\"description\")}>{children}</Description>\n )}\n {hasActions(actions) && <div className={slotClass(\"actions\")}>{actions}</div>}\n </div>\n {onDismiss && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n className={`${slotClass(\"dismiss\")} ds-field-surface`}\n aria-label={dismissLabel}\n onClick={onDismiss}\n />\n )}\n </div>\n );\n});\n"],"mappings":";;;;;AAeA,IAAMC,IAA2C;CAC/C,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;AACV,GAqBMC,KAAW,MAAkBC,KAAQ,QAAQ,OAAOA,KAAS,aAAaA,MAAS;AAGzF,SAASC,EAAS,GAAiB,GAA6C;CAO9E,OANI,MAAM,QAAQD,CAAI,IACbA,EAAK,MAAM,MAAqBC,EAASC,GAAOC,CAAI,CAAC,IAE1DC,EAAyCJ,CAAI,KAAKA,EAAK,SAASK,IAC3DJ,EAASD,EAAK,MAAM,UAAUG,CAAI,IAEpCA,EAAKH,CAAI;AAClB;AAIA,IAAMM,KAAW,MAAoBL,EAASD,IAAO,MAAS,CAACD,EAAQQ,CAAI,CAAC,GACtEC,KAAc,MAClBP,EAASD,IAAO,MAAS,CAACD,EAAQQ,CAAI,KAAK,OAAOA,KAAS,QAAQ;AAErE,SAASE,EAAY,GAA4B,GAAyC;CACxF,IAAIC,MAAS,KAAA,KAAaA,MAAS,QACjC;CAEF,IAAMC,IAAOD,MAAS,SAASZ,EAAUc,KAAQF;CAEjD,OAAO,OAAO,OAAOb,GAAOc,CAAI,IAAIA,IAAO,KAAA;AAC7C;AAEA,IAAME,KAAY,MAChBD,MAAS,YAAYA,MAAS,YAAY,UAAU,UAGzCE,IAAUC,EAAyC,SAC9D,EACE,UAAO,WACP,gBAAa,UACb,UACA,SACA,YACA,cACA,kBAAe,WACf,gBACA,SACA,cACA,aACA,GAAGC,KAEL,GACA;CAGA,IAAM,CAACC,KAAeC,QAAeL,EAASD,CAAI,CAAC,GAC7CO,IAAWV,EAAYC,GAAME,CAAI,GACjCQ,KAAa,MACjB,CAAC,eAAeC,KAAQC,KAAe,GAAGA,EAAY,IAAID,GAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,GAGtFE,IAAcC,MAAe,eADpB,OAAOC,KAAa,YAAY,OAAOA,KAAa,YACT,SAAS;CAEnE,OACE,kBAAC,OAAD;EACO;EACL,MAAMC,KAAQT;EACd,aAAWL,MAAS,YAAY,KAAA,IAAYA;EAC5C,mBAAiBY;EACjB,WAAW,CAAC,cAAcG,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC7D,GAAIX;EANN,UAAA;GAQGG,KACC,kBAACS,GAAD;IACE,MAAMT;IACN,MAAM;IACN,WAAWC,EAAU,MAAM;GAC5B,CAAA;GAEH,kBAAC,OAAD;IAAK,WAAW,GAAGA,EAAU,MAAM,EAAE;IAArC,UAAA;KACE,kBAAC,QAAD;MAAM,WAAWA,EAAU,OAAO;MAAI,UAAAS;KAAY,CAAA;KACjDvB,EAAQmB,CAAQ,KACf,kBAACF,GAAD;MAAa,WAAWH,EAAU,aAAa;MAAI;KAAsB,CAAA;KAE1EZ,EAAWsB,CAAO,KAAK,kBAAC,OAAD;MAAK,WAAWV,EAAU,SAAS;MAAI,UAAAU;KAAa,CAAA;IACzE;;GACJC,KACC,kBAACC,GAAD;IACE,SAAQ;IACR,MAAK;IACL,YAAA;IACA,WAAU;IACV,WAAW,GAAGZ,EAAU,SAAS,EAAE;IACnC,cAAYa;IACZ,SAASF;GACV,CAAA;EAEA;;AAET,CAAC"}
@@ -1,2 +1,2 @@
1
- const e=require("./Icon-CnnTrtNb.cjs"),t=require("../components/Button/index.cjs");let n=require("react"),r=require("react/jsx-runtime");var i={neutral:`info`,info:`info`,success:`check`,warning:`alert-triangle`,danger:`alert-triangle`,review:`eye`},a=e=>e==null||typeof e==`boolean`||e===``;function o(e,t){return Array.isArray(e)?e.some(e=>o(e,t)):(0,n.isValidElement)(e)&&e.type===n.Fragment?o(e.props.children,t):t(e)}var s=e=>o(e,e=>!a(e)),c=e=>o(e,e=>!a(e)&&typeof e!=`number`);function l(t,n){if(t===void 0||t===`none`)return;let r=t===`auto`?i[n]:t;return Object.hasOwn(e.r,r)?r:void 0}var u=e=>e===`danger`||e===`warning`?`alert`:`status`,d=(0,n.forwardRef)(function({tone:i=`neutral`,appearance:a=`inline`,title:o,icon:d,actions:f,onDismiss:p,dismissLabel:m=`Dismiss`,classPrefix:h,role:g,className:_,children:v,...y},b){let[x]=(0,n.useState)(()=>u(i)),S=l(d,i),C=e=>[`ds-message__${e}`,h&&`${h}__${e}`].filter(Boolean).join(` `),w=a===`floating`&&(typeof v==`string`||typeof v==`number`)?`span`:`div`;return(0,r.jsxs)(`div`,{ref:b,role:g??x,"data-tone":i===`neutral`?void 0:i,"data-appearance":a,className:[`ds-message`,_].filter(Boolean).join(` `),...y,children:[S&&(0,r.jsx)(e.t,{name:S,size:20,className:C(`icon`)}),(0,r.jsxs)(`div`,{className:`${C(`body`)} ds-field-surface`,children:[(0,r.jsx)(`span`,{className:C(`title`),children:o}),s(v)&&(0,r.jsx)(w,{className:C(`description`),children:v}),c(f)&&(0,r.jsx)(`div`,{className:C(`actions`),children:f})]}),p&&(0,r.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`x`,className:`${C(`dismiss`)} ds-field-surface`,"aria-label":m,onClick:p})]})});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
2
- //# sourceMappingURL=Message-B0A5bz8V.cjs.map
1
+ const e=require("./Icon-QLZH31JA.cjs"),t=require("../components/Button/index.cjs");let n=require("react"),r=require("react/jsx-runtime");var i={neutral:`info`,info:`info`,success:`check`,warning:`alert-triangle`,danger:`alert-triangle`,review:`eye`},a=e=>e==null||typeof e==`boolean`||e===``;function o(e,t){return Array.isArray(e)?e.some(e=>o(e,t)):(0,n.isValidElement)(e)&&e.type===n.Fragment?o(e.props.children,t):t(e)}var s=e=>o(e,e=>!a(e)),c=e=>o(e,e=>!a(e)&&typeof e!=`number`);function l(t,n){if(t===void 0||t===`none`)return;let r=t===`auto`?i[n]:t;return Object.hasOwn(e.r,r)?r:void 0}var u=e=>e===`danger`||e===`warning`?`alert`:`status`,d=(0,n.forwardRef)(function({tone:i=`neutral`,appearance:a=`inline`,title:o,icon:d,actions:f,onDismiss:p,dismissLabel:m=`Dismiss`,classPrefix:h,role:g,className:_,children:v,...y},b){let[x]=(0,n.useState)(()=>u(i)),S=l(d,i),C=e=>[`ds-message__${e}`,h&&`${h}__${e}`].filter(Boolean).join(` `),w=a===`floating`&&(typeof v==`string`||typeof v==`number`)?`span`:`div`;return(0,r.jsxs)(`div`,{ref:b,role:g??x,"data-tone":i===`neutral`?void 0:i,"data-appearance":a,className:[`ds-message`,_].filter(Boolean).join(` `),...y,children:[S&&(0,r.jsx)(e.t,{name:S,size:20,className:C(`icon`)}),(0,r.jsxs)(`div`,{className:`${C(`body`)} ds-field-surface`,children:[(0,r.jsx)(`span`,{className:C(`title`),children:o}),s(v)&&(0,r.jsx)(w,{className:C(`description`),children:v}),c(f)&&(0,r.jsx)(`div`,{className:C(`actions`),children:f})]}),p&&(0,r.jsx)(t.Button,{variant:`simple`,size:`sm`,isIconOnly:!0,iconStart:`x`,className:`${C(`dismiss`)} ds-field-surface`,"aria-label":m,onClick:p})]})});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
2
+ //# sourceMappingURL=Message-yZJDVzb8.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Message-B0A5bz8V.cjs","names":["isValidElement","Fragment","icons","forwardRef","useState","Icon","Button","require_Icon","require_components_Button_index","react","react_jsx_runtime","TONE_ICON","isBlank","node","someLeaf","child","test","hasBody","leaf","hasActions","resolveIcon","icon","name","tone","toneRole","Message","rest","defaultRole","iconName","slotClass","slot","classPrefix","Description","appearance","children","role","className","title","actions","onDismiss","dismissLabel"],"sources":["../../src/internal/Message.tsx"],"sourcesContent":["import {\n forwardRef,\n Fragment,\n isValidElement,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../components/Button\";\nimport { Icon } from \"../components/Icon\";\nimport { icons, type IconName } from \"../components/Icon/icons\";\nimport \"../styles/message.css\";\n\nexport type MessageTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"review\";\n\nconst TONE_ICON: Record<MessageTone, IconName> = {\n neutral: \"info\",\n info: \"info\",\n success: \"check\",\n warning: \"alert-triangle\",\n danger: \"alert-triangle\",\n review: \"eye\",\n};\n\nexport interface MessageProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n tone?: MessageTone;\n appearance?: \"inline\" | \"floating\";\n title: string;\n /**\n * Omitted or `none` hides the icon; `auto` uses the tone's default glyph. A\n * name outside the curated icon set renders no icon rather than throwing.\n */\n icon?: IconName | \"auto\" | \"none\";\n actions?: ReactNode;\n /** Renders a dismiss control. The parent owns visibility. */\n onDismiss?: () => void;\n /** Accessible name of the dismiss control. Defaults to \"Dismiss\". */\n dismissLabel?: string;\n /** The public wrapper's block class, added beside each `ds-message__*` slot class. */\n classPrefix?: string;\n}\n\n/** Leftovers of conditional rendering: nothing visible, so no slot is reserved. */\nconst isBlank = (node: unknown) => node == null || typeof node === \"boolean\" || node === \"\";\n\n/** Whether `test` holds for any leaf, looking through arrays and fragments. */\nfunction someLeaf(node: ReactNode, test: (leaf: ReactNode) => boolean): boolean {\n if (Array.isArray(node)) {\n return node.some((child: ReactNode) => someLeaf(child, test));\n }\n if (isValidElement<{ children?: ReactNode }>(node) && node.type === Fragment) {\n return someLeaf(node.props.children, test);\n }\n return test(node);\n}\n\n// Numbers are content in the body (`0` items) but never an action: a `0` in the\n// actions slot comes from `count && <Button />`, so it reserves no row.\nconst hasBody = (node: ReactNode) => someLeaf(node, (leaf) => !isBlank(leaf));\nconst hasActions = (node: ReactNode) =>\n someLeaf(node, (leaf) => !isBlank(leaf) && typeof leaf !== \"number\");\n\nfunction resolveIcon(icon: MessageProps[\"icon\"], tone: MessageTone): IconName | undefined {\n if (icon === undefined || icon === \"none\") {\n return undefined;\n }\n const name = icon === \"auto\" ? TONE_ICON[tone] : icon;\n // Own keys only, so values such as \"constructor\" never reach Icon.\n return Object.hasOwn(icons, name) ? name : undefined;\n}\n\nconst toneRole = (tone: MessageTone) =>\n tone === \"danger\" || tone === \"warning\" ? \"alert\" : \"status\";\n\n/** Shared notification structure. Public wrappers own delivery and content policy. */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(function Message(\n {\n tone = \"neutral\",\n appearance = \"inline\",\n title,\n icon,\n actions,\n onDismiss,\n dismissLabel = \"Dismiss\",\n classPrefix,\n role,\n className,\n children,\n ...rest\n },\n ref,\n) {\n // A live region must exist before its content changes, so the default role\n // comes from the tone the message mounts with and survives later tone changes.\n const [defaultRole] = useState(() => toneRole(tone));\n const iconName = resolveIcon(icon, tone);\n const slotClass = (slot: string) =>\n [`ds-message__${slot}`, classPrefix && `${classPrefix}__${slot}`].filter(Boolean).join(\" \");\n // Plain-text toasts keep their span; JSX descriptions get a div that can hold blocks.\n const isText = typeof children === \"string\" || typeof children === \"number\";\n const Description = appearance === \"floating\" && isText ? \"span\" : \"div\";\n\n return (\n <div\n ref={ref}\n role={role ?? defaultRole}\n data-tone={tone === \"neutral\" ? undefined : tone}\n data-appearance={appearance}\n className={[\"ds-message\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {iconName && (\n <Icon\n name={iconName}\n size={20}\n className={slotClass(\"icon\")}\n />\n )}\n <div className={`${slotClass(\"body\")} ds-field-surface`}>\n <span className={slotClass(\"title\")}>{title}</span>\n {hasBody(children) && (\n <Description className={slotClass(\"description\")}>{children}</Description>\n )}\n {hasActions(actions) && <div className={slotClass(\"actions\")}>{actions}</div>}\n </div>\n {onDismiss && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n className={`${slotClass(\"dismiss\")} ds-field-surface`}\n aria-label={dismissLabel}\n onClick={onDismiss}\n />\n )}\n </div>\n );\n});\n"],"mappings":"A,yIAeA,IAAMW,EAA2C,CAC/C,QAAS,OACT,KAAM,OACN,QAAS,QACT,QAAS,iBACT,OAAQ,iBACR,OAAQ,KACV,EAqBMC,EAAW,GAAkBC,GAAQ,MAAQ,OAAOA,GAAS,WAAaA,IAAS,GAGzF,SAASC,EAAS,EAAiB,EAA6C,CAO9E,OANI,MAAM,QAAQD,CAAI,EACbA,EAAK,KAAM,GAAqBC,EAASC,EAAOC,CAAI,CAAC,GAE9D,EAAIhB,EAAAA,eAAAA,CAAyCa,CAAI,GAAKA,EAAK,OAASZ,EAAAA,SAC3Da,EAASD,EAAK,MAAM,SAAUG,CAAI,EAEpCA,EAAKH,CAAI,CAClB,CAIA,IAAMI,EAAW,GAAoBH,EAASD,EAAO,GAAS,CAACD,EAAQM,CAAI,CAAC,EACtEC,EAAc,GAClBL,EAASD,EAAO,GAAS,CAACD,EAAQM,CAAI,GAAK,OAAOA,GAAS,QAAQ,EAErE,SAASE,EAAY,EAA4B,EAAyC,CACxF,GAAIC,IAAS,IAAA,IAAaA,IAAS,OACjC,OAEF,IAAMC,EAAOD,IAAS,OAASV,EAAUY,GAAQF,EAEjD,OAAO,OAAO,OAAOnB,EAAAA,EAAOoB,CAAI,EAAIA,EAAO,IAAA,EAC7C,CAEA,IAAME,EAAY,GAChBD,IAAS,UAAYA,IAAS,UAAY,QAAU,SAGzCE,GAAA,EAAUtB,EAAAA,WAAAA,CAAyC,SAC9D,CACE,OAAO,UACP,aAAa,SACb,QACA,OACA,UACA,YACA,eAAe,UACf,cACA,OACA,YACA,WACA,GAAGuB,GAEL,EACA,CAGA,GAAM,CAACC,IAAA,EAAevB,EAAAA,SAAAA,KAAeoB,EAASD,CAAI,CAAC,EAC7CK,EAAWR,EAAYC,EAAME,CAAI,EACjCM,EAAa,GACjB,CAAC,eAAeC,IAAQC,GAAe,GAAGA,EAAY,IAAID,GAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAGtFE,EAAcC,IAAe,aADpB,OAAOC,GAAa,UAAY,OAAOA,GAAa,UACT,OAAS,MAEnE,OACE,EAAAxB,EAAA,KAAA,CAAC,MAAD,CACO,MACL,KAAMyB,GAAQR,EACd,YAAWJ,IAAS,UAAY,IAAA,GAAYA,EAC5C,kBAAiBU,EACjB,UAAW,CAAC,aAAcG,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAC7D,GAAIV,EANN,SAAA,CAQGE,IACC,EAAAlB,EAAA,IAAA,CAACL,EAAAA,EAAD,CACE,KAAMuB,EACN,KAAM,GACN,UAAWC,EAAU,MAAM,CAC5B,CAAA,GAEH,EAAAnB,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,GAAGmB,EAAU,MAAM,EAAE,mBAArC,SAAA,EACE,EAAAnB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAWmB,EAAU,OAAO,EAAI,SAAAQ,CAAY,CAAA,EACjDpB,EAAQiB,CAAQ,IACf,EAAAxB,EAAA,IAAA,CAACsB,EAAD,CAAa,UAAWH,EAAU,aAAa,EAAI,UAAsB,CAAA,EAE1EV,EAAWmB,CAAO,IAAK,EAAA5B,EAAA,IAAA,CAAC,MAAD,CAAK,UAAWmB,EAAU,SAAS,EAAI,SAAAS,CAAa,CAAA,CACzE,C,GACJC,IACC,EAAA7B,EAAA,IAAA,CAACJ,EAAAA,OAAD,CACE,QAAQ,SACR,KAAK,KACL,WAAA,GACA,UAAU,IACV,UAAW,GAAGuB,EAAU,SAAS,EAAE,mBACnC,aAAYW,EACZ,QAASD,CACV,CAAA,CAEA,C,EAET,CAAC,E"}
1
+ {"version":3,"file":"Message-yZJDVzb8.cjs","names":["isValidElement","Fragment","icons","forwardRef","useState","Icon","Button","require_Icon","require_components_Button_index","react","react_jsx_runtime","TONE_ICON","isBlank","node","someLeaf","child","test","hasBody","leaf","hasActions","resolveIcon","icon","name","tone","toneRole","Message","rest","defaultRole","iconName","slotClass","slot","classPrefix","Description","appearance","children","role","className","title","actions","onDismiss","dismissLabel"],"sources":["../../src/internal/Message.tsx"],"sourcesContent":["import {\n forwardRef,\n Fragment,\n isValidElement,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Button } from \"../components/Button\";\nimport { Icon } from \"../components/Icon\";\nimport { icons, type IconName } from \"../components/Icon/icons\";\nimport \"../styles/message.css\";\n\nexport type MessageTone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"review\";\n\nconst TONE_ICON: Record<MessageTone, IconName> = {\n neutral: \"info\",\n info: \"info\",\n success: \"check\",\n warning: \"alert-triangle\",\n danger: \"alert-triangle\",\n review: \"eye\",\n};\n\nexport interface MessageProps extends Omit<HTMLAttributes<HTMLDivElement>, \"title\"> {\n tone?: MessageTone;\n appearance?: \"inline\" | \"floating\";\n title: string;\n /**\n * Omitted or `none` hides the icon; `auto` uses the tone's default glyph. A\n * name outside the curated icon set renders no icon rather than throwing.\n */\n icon?: IconName | \"auto\" | \"none\";\n actions?: ReactNode;\n /** Renders a dismiss control. The parent owns visibility. */\n onDismiss?: () => void;\n /** Accessible name of the dismiss control. Defaults to \"Dismiss\". */\n dismissLabel?: string;\n /** The public wrapper's block class, added beside each `ds-message__*` slot class. */\n classPrefix?: string;\n}\n\n/** Leftovers of conditional rendering: nothing visible, so no slot is reserved. */\nconst isBlank = (node: unknown) => node == null || typeof node === \"boolean\" || node === \"\";\n\n/** Whether `test` holds for any leaf, looking through arrays and fragments. */\nfunction someLeaf(node: ReactNode, test: (leaf: ReactNode) => boolean): boolean {\n if (Array.isArray(node)) {\n return node.some((child: ReactNode) => someLeaf(child, test));\n }\n if (isValidElement<{ children?: ReactNode }>(node) && node.type === Fragment) {\n return someLeaf(node.props.children, test);\n }\n return test(node);\n}\n\n// Numbers are content in the body (`0` items) but never an action: a `0` in the\n// actions slot comes from `count && <Button />`, so it reserves no row.\nconst hasBody = (node: ReactNode) => someLeaf(node, (leaf) => !isBlank(leaf));\nconst hasActions = (node: ReactNode) =>\n someLeaf(node, (leaf) => !isBlank(leaf) && typeof leaf !== \"number\");\n\nfunction resolveIcon(icon: MessageProps[\"icon\"], tone: MessageTone): IconName | undefined {\n if (icon === undefined || icon === \"none\") {\n return undefined;\n }\n const name = icon === \"auto\" ? TONE_ICON[tone] : icon;\n // Own keys only, so values such as \"constructor\" never reach Icon.\n return Object.hasOwn(icons, name) ? name : undefined;\n}\n\nconst toneRole = (tone: MessageTone) =>\n tone === \"danger\" || tone === \"warning\" ? \"alert\" : \"status\";\n\n/** Shared notification structure. Public wrappers own delivery and content policy. */\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(function Message(\n {\n tone = \"neutral\",\n appearance = \"inline\",\n title,\n icon,\n actions,\n onDismiss,\n dismissLabel = \"Dismiss\",\n classPrefix,\n role,\n className,\n children,\n ...rest\n },\n ref,\n) {\n // A live region must exist before its content changes, so the default role\n // comes from the tone the message mounts with and survives later tone changes.\n const [defaultRole] = useState(() => toneRole(tone));\n const iconName = resolveIcon(icon, tone);\n const slotClass = (slot: string) =>\n [`ds-message__${slot}`, classPrefix && `${classPrefix}__${slot}`].filter(Boolean).join(\" \");\n // Plain-text toasts keep their span; JSX descriptions get a div that can hold blocks.\n const isText = typeof children === \"string\" || typeof children === \"number\";\n const Description = appearance === \"floating\" && isText ? \"span\" : \"div\";\n\n return (\n <div\n ref={ref}\n role={role ?? defaultRole}\n data-tone={tone === \"neutral\" ? undefined : tone}\n data-appearance={appearance}\n className={[\"ds-message\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n {iconName && (\n <Icon\n name={iconName}\n size={20}\n className={slotClass(\"icon\")}\n />\n )}\n <div className={`${slotClass(\"body\")} ds-field-surface`}>\n <span className={slotClass(\"title\")}>{title}</span>\n {hasBody(children) && (\n <Description className={slotClass(\"description\")}>{children}</Description>\n )}\n {hasActions(actions) && <div className={slotClass(\"actions\")}>{actions}</div>}\n </div>\n {onDismiss && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n className={`${slotClass(\"dismiss\")} ds-field-surface`}\n aria-label={dismissLabel}\n onClick={onDismiss}\n />\n )}\n </div>\n );\n});\n"],"mappings":"A,yIAeA,IAAMW,EAA2C,CAC/C,QAAS,OACT,KAAM,OACN,QAAS,QACT,QAAS,iBACT,OAAQ,iBACR,OAAQ,KACV,EAqBMC,EAAW,GAAkBC,GAAQ,MAAQ,OAAOA,GAAS,WAAaA,IAAS,GAGzF,SAASC,EAAS,EAAiB,EAA6C,CAO9E,OANI,MAAM,QAAQD,CAAI,EACbA,EAAK,KAAM,GAAqBC,EAASC,EAAOC,CAAI,CAAC,GAE9D,EAAIhB,EAAAA,eAAAA,CAAyCa,CAAI,GAAKA,EAAK,OAASZ,EAAAA,SAC3Da,EAASD,EAAK,MAAM,SAAUG,CAAI,EAEpCA,EAAKH,CAAI,CAClB,CAIA,IAAMI,EAAW,GAAoBH,EAASD,EAAO,GAAS,CAACD,EAAQM,CAAI,CAAC,EACtEC,EAAc,GAClBL,EAASD,EAAO,GAAS,CAACD,EAAQM,CAAI,GAAK,OAAOA,GAAS,QAAQ,EAErE,SAASE,EAAY,EAA4B,EAAyC,CACxF,GAAIC,IAAS,IAAA,IAAaA,IAAS,OACjC,OAEF,IAAMC,EAAOD,IAAS,OAASV,EAAUY,GAAQF,EAEjD,OAAO,OAAO,OAAOnB,EAAAA,EAAOoB,CAAI,EAAIA,EAAO,IAAA,EAC7C,CAEA,IAAME,EAAY,GAChBD,IAAS,UAAYA,IAAS,UAAY,QAAU,SAGzCE,GAAA,EAAUtB,EAAAA,WAAAA,CAAyC,SAC9D,CACE,OAAO,UACP,aAAa,SACb,QACA,OACA,UACA,YACA,eAAe,UACf,cACA,OACA,YACA,WACA,GAAGuB,GAEL,EACA,CAGA,GAAM,CAACC,IAAA,EAAevB,EAAAA,SAAAA,KAAeoB,EAASD,CAAI,CAAC,EAC7CK,EAAWR,EAAYC,EAAME,CAAI,EACjCM,EAAa,GACjB,CAAC,eAAeC,IAAQC,GAAe,GAAGA,EAAY,IAAID,GAAM,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAGtFE,EAAcC,IAAe,aADpB,OAAOC,GAAa,UAAY,OAAOA,GAAa,UACT,OAAS,MAEnE,OACE,EAAAxB,EAAA,KAAA,CAAC,MAAD,CACO,MACL,KAAMyB,GAAQR,EACd,YAAWJ,IAAS,UAAY,IAAA,GAAYA,EAC5C,kBAAiBU,EACjB,UAAW,CAAC,aAAcG,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAC7D,GAAIV,EANN,SAAA,CAQGE,IACC,EAAAlB,EAAA,IAAA,CAACL,EAAAA,EAAD,CACE,KAAMuB,EACN,KAAM,GACN,UAAWC,EAAU,MAAM,CAC5B,CAAA,GAEH,EAAAnB,EAAA,KAAA,CAAC,MAAD,CAAK,UAAW,GAAGmB,EAAU,MAAM,EAAE,mBAArC,SAAA,EACE,EAAAnB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAWmB,EAAU,OAAO,EAAI,SAAAQ,CAAY,CAAA,EACjDpB,EAAQiB,CAAQ,IACf,EAAAxB,EAAA,IAAA,CAACsB,EAAD,CAAa,UAAWH,EAAU,aAAa,EAAI,UAAsB,CAAA,EAE1EV,EAAWmB,CAAO,IAAK,EAAA5B,EAAA,IAAA,CAAC,MAAD,CAAK,UAAWmB,EAAU,SAAS,EAAI,SAAAS,CAAa,CAAA,CACzE,C,GACJC,IACC,EAAA7B,EAAA,IAAA,CAACJ,EAAAA,OAAD,CACE,QAAQ,SACR,KAAK,KACL,WAAA,GACA,UAAU,IACV,UAAW,GAAGuB,EAAU,SAAS,EAAE,mBACnC,aAAYW,EACZ,QAASD,CACV,CAAA,CAEA,C,EAET,CAAC,E"}
@@ -0,0 +1,2 @@
1
+ const e=require("./colour-BmtxDlWF.cjs"),t=require("./Icon-QLZH31JA.cjs"),n=require("../components/Button/index.cjs"),r=require("./mergeRefs-CZ-SArlE.cjs"),i=require("./overlayLayer-CPd3zj_u.cjs"),a=require("./useIsomorphicLayoutEffect-XM4Ot6x5.cjs"),o=require("../components/ButtonGroup/index.cjs"),s=require("../components/Badge/index.cjs");;/* empty css */const c=require("../components/Field/index.cjs"),l=require("../components/Modal/index.cjs"),u=require("../components/TextField/index.cjs"),d=require("./EntryPicker-wVjzdlAO.cjs"),f=require("../components/Popover/index.cjs"),p=require("../components/Menu/index.cjs"),m=require("../components/Choice/index.cjs"),h=require("../components/Container/index.cjs"),g=require("./decimal-Ca7qJExZ.cjs"),_=require("./NumberField-BrWFmPkW.cjs"),v=require("../components/Select/index.cjs"),y=require("../components/Switch/index.cjs"),b=require("./Slider-BfvNPjRJ.cjs"),x=require("./ColourField-BVGnW8Wh.cjs"),S=require("./DatePicker-zA0bWVBp.cjs"),C=require("../components/TagsInput/index.cjs"),w=require("../components/SelectionCard/index.cjs");let T=require("react"),E=require("react-dom"),D=require("react/jsx-runtime"),O=require("@tiptap/react"),k=require("@tiptap/extension-placeholder"),ee=require("@tiptap/starter-kit"),te=require("@tiptap/extension-link"),A=require("@tiptap/extension-table"),j=require("@tiptap/pm/model"),M=require("@tiptap/pm/state"),N=require("@tiptap/pm/history"),P=require("@tiptap/pm/tables");function F(e,t){let n=t.querySelector(`.ds-rte__content`);if(!n)return;let r=e.view.coordsAtPos(e.state.selection.head),i=n.getBoundingClientRect();(r.top<i.top||r.bottom>i.bottom)&&(n.scrollTop+=r.top-i.top-i.height/2)}function ne({editor:e,disabled:t,isHeld:r=!1,invalid:o,label:s,labelledBy:c,expandedWidth:u,frameRef:d}){let f=i.m(`ds-rte__host`),[p,m]=(0,T.useState)(!1),[h,g]=(0,T.useState)(0),_=(0,T.useRef)(null),v=(0,T.useRef)(null),y=(0,T.useRef)(null),b=(0,T.useRef)(!1),x=(0,T.useRef)(!1),S=(0,T.useId)();p&&t&&!r&&m(!1);let C=(0,T.useCallback)(()=>{b.current=document.activeElement===y.current,m(!1)},[]);a.t(()=>{f&&(i.p(f,p?v.current:_.current),x.current!==p&&(x.current=p,t||!e?i.h(document.activeElement)&&i._(d.current,{preventScroll:!0}):(F(e,f),!p&&b.current?y.current?.focus():(e.view.focus(),e.commands.scrollIntoView()),b.current=!1)))},[f,p,e,t,d]);let w=p?`Collapse editor`:`Expand editor`;return{expanded:p,toggle:(0,D.jsx)(n.Button,{ref:y,size:`sm`,isIconOnly:!0,iconStart:p?`minimize-2`:`maximize-2`,className:`ds-rte__expand`,"aria-label":w,title:w,"aria-expanded":p,"aria-controls":p?S:void 0,isDisabled:t||!e||!f,onMouseDown:e=>e.preventDefault(),onClick:()=>{p?C():(g(d.current.getBoundingClientRect().height),m(!0))}}),surfaceSlot:e=>(0,D.jsx)(`div`,{ref:_,className:`ds-rte__slot`,children:f?(0,E.createPortal)(e,f):e}),dialog:(0,D.jsx)(l.Modal,{id:S,isOpen:p,onClose:C,title:s,hasHeader:!1,size:u===`full`?`full`:`wide`,className:`ds-rte__modal`,"data-invalid":o||void 0,"aria-labelledby":c,children:(0,D.jsx)(`div`,{ref:v,className:`ds-rte__expanded-slot`})}),frameStyle:p?{minBlockSize:h}:void 0}}var I=[`type`,`id`,`entryId`,`assetId`,`align`],L=`storyblock`;function R(e){let t=e=>typeof e==`string`&&e.trim().length>0;return[`left`,`full`,`right`].includes(e.align==null?`full`:e.align)&&(e.type===`entry`?t(e.id)&&t(e.entryId)&&e.assetId==null:e.type===`asset`&&t(e.assetId)&&e.id==null&&e.entryId==null)}function z(e){let t=e.content?.map(z),n=!!t&&t.some((t,n)=>t!==e.content[n]);return e.type!==L&&!n?e:{...e,...e.type===L?{type:`contentBlock`}:{},...n?{content:t}:{}}}function B(e){return{...e,...e.type===`contentBlock`&&e.attrs?{attrs:{type:e.attrs.type,...e.attrs.type===`entry`?{id:e.attrs.id,entryId:e.attrs.entryId}:{assetId:e.attrs.assetId},align:e.attrs.align??`full`}}:{},...e.content?{content:e.content.map(B)}:{}}}function re(e){return e.hasAttribute(`data-content-block`)?`data-content-block`:`data-${L}`}function ie(e,t){return e.getAttribute(`${re(e)}-${t.toLowerCase()}`)}var V=O.Node.create({name:`contentBlock`,group:`block`,atom:!0,draggable:!0,selectable:!0,marks:``,addAttributes(){return Object.fromEntries(I.map(e=>[e,{default:e===`align`?`full`:null,parseHTML:t=>ie(t,e),renderHTML:()=>({})}]))},parseHTML(){return[`div[data-content-block]`,`div[data-${L}]`].map(e=>({tag:e,getAttrs:e=>R(Object.fromEntries(I.map(t=>[t,ie(e,t)])))?null:!1}))},renderHTML({node:e,HTMLAttributes:t}){let n=B({type:`contentBlock`,attrs:e.attrs}).attrs;return[`div`,(0,O.mergeAttributes)(t,{"data-content-block":``,...Object.fromEntries(Object.entries(n).map(([e,t])=>[`data-content-block-${e.toLowerCase()}`,t]))})]}}),H={type:`doc`,content:[{type:`paragraph`}]},U=[ee.StarterKit.configure({link:!1,trailingNode:{notAfter:[`paragraph`,`contentBlock`]}}),te.Link.configure({openOnClick:!1,autolink:!0})];function ae(e){if(!e.size)return e;let t=[],n=!1;return e.forEach(e=>{let r=ae(e.content),i=e.attrs.colwidth==null?e.copy(r):e.type.create({...e.attrs,colwidth:null},r,e.marks);t.push(i),n||=i!==e}),n?j.Fragment.fromArray(t):e}function oe(){let e=null,t=t=>(t.state.selection.empty||(e=t.state.selection.content()),!1);return new M.Plugin({props:{handleDOMEvents:{copy:t,cut:t},transformPasted(t,n){if([e,n.dragging?.slice].some(e=>e?.eq(t)))return t;let r=ae(t.content);return r===t.content?t:new j.Slice(r,t.openStart,t.openEnd)}}})}var W=A.Table.extend({addProseMirrorPlugins(){return[...this.parent?.()??[],oe()]},renderHTML({node:e,HTMLAttributes:t}){let n=[`table`,(0,O.mergeAttributes)(this.options.HTMLAttributes,t),[`tbody`,0]];return e.firstChild?.children.some(({attrs:e})=>Array.isArray(e.colwidth)&&e.colwidth.some(Boolean))?this.parent?.({node:e,HTMLAttributes:t})??n:n}}).configure({cellMinWidth:80}),se=A.TableKit.configure({table:!1});function ce(e=V,{tables:t=!0}={},n=W){return t?[e,...U,n,se]:[e,...U]}var le={withTables:(0,O.getSchema)(ce()),withoutTables:(0,O.getSchema)(ce(V,{tables:!1}))};function G(e){let t=z(e);return t.content?.length?t:{...t,content:H.content}}function ue(e,{tables:t=!0}={}){let n=t?le.withTables:le.withoutTables;try{if(!e||typeof e!=`object`||!(`type`in e)||e.type!==`doc`)throw Error();let t=e=>{let r=n.nodes[e.type??``];if(!r||Object.keys(e).some(e=>![`type`,`attrs`,`content`,`marks`,`text`].includes(e))||e.text!==void 0&&e.type!==`text`||e.attrs&&Object.keys(e.attrs).some(e=>!Object.hasOwn(r.spec.attrs??{},e))||e.type===`contentBlock`&&(!R(e.attrs??{})||e.marks?.length))throw Error();for(let t of e.marks??[]){let e=n.marks[t.type];if(!e||Object.keys(t).some(e=>![`type`,`attrs`].includes(e))||Object.keys(t.attrs??{}).some(t=>!Object.hasOwn(e.spec.attrs??{},t)))throw Error()}e.content?.forEach(t)},r=G(e);t(r),n.nodeFromJSON(r).check()}catch{return`Unsupported or invalid rich-text document.`}}var de=`ds-content-block ds-field-surface`;function fe({action:e,groupDescription:t}){let n=(0,T.useId)(),r=[e.description&&n,e.disabled&&t].filter(Boolean);return(0,D.jsx)(p.MenuItem,{icon:e.icon,tone:e.tone,isDisabled:e.disabled,className:e.inlineIcon?`ds-content-block__inline-action`:void 0,"aria-label":e.description?e.label:void 0,"aria-describedby":r.length?r.join(` `):void 0,onClick:e.run,children:e.description?(0,D.jsxs)(`span`,{children:[e.label,(0,D.jsx)(`span`,{id:n,className:`ds-content-block__description`,children:e.description})]}):e.label})}function pe({group:{label:e,description:t,actions:r,choices:i,keepOpen:a,separate:s}}){let c=(0,T.useId)();return(0,D.jsxs)(D.Fragment,{children:[s&&(0,D.jsx)(p.MenuSeparator,{}),e&&(0,D.jsx)(p.MenuLabel,{children:e}),t&&(0,D.jsx)(`span`,{id:c,className:`ds-content-block__description ds-content-block__group-description`,children:t}),i?(0,D.jsx)(o.ButtonGroup,{"aria-label":e,children:r.map(e=>(0,D.jsx)(n.Button,{role:`menuitemradio`,"aria-checked":e.checked,"aria-label":e.label,title:e.label,size:`sm`,isIconOnly:!0,iconStart:e.icon,variant:e.checked?`primary`:`neutral`,isDisabled:e.disabled,onClick:t=>{a&&t.preventDefault(),e.run()}},e.label))}):r.map(e=>(0,D.jsx)(fe,{action:e,groupDescription:t?c:void 0},e.label))]})}function me({groups:e}){return e.map(e=>(0,D.jsx)(pe,{group:e},e.label??e.actions[0]?.label))}function he({kind:e,meta:n,isMovable:r,onSelect:i}){return(0,D.jsxs)(`span`,{className:`ds-content-block__kind`,"data-drag-handle":r?``:void 0,draggable:r||void 0,title:r?`Drag to move`:void 0,onClick:r?i:void 0,children:[r&&(0,D.jsx)(`span`,{className:`ds-content-block__grip`,"aria-hidden":`true`,children:(0,D.jsx)(t.t,{name:`grip-vertical`,size:16})}),(0,D.jsx)(s.Badge,{className:`ds-content-block__kind-label`,shape:`tag`,size:`sm`,children:e}),n&&(0,D.jsx)(`bdi`,{className:`ds-rte__block-meta`,children:n})]})}function ge({kind:e,meta:t,isSelected:r,isDisabled:i,isLocked:a,menuLabel:o,actions:s,onSelect:c}){let[l,u]=(0,T.useState)(!1),[d,f]=(0,T.useState)(`end`),[m,h]=(0,T.useState)([]),g={size:`sm`,isIconOnly:!0,iconStart:`more-horizontal`,"aria-label":o,title:o};return(0,D.jsxs)(`div`,{className:`ds-content-block__bar ds-field-surface`,onMouseDown:e=>{let t=e.target;!i&&!a&&t instanceof Element&&e.currentTarget.contains(t)&&!t.closest(`button, [data-drag-handle]`)&&(e.preventDefault(),c())},children:[(0,D.jsx)(he,{kind:e,meta:t,isMovable:!i&&!a,onSelect:c}),!i&&(a?(0,D.jsx)(n.Button,{...g,variant:`simple`,isDisabled:!0,"aria-haspopup":`menu`,"aria-expanded":!1}):(0,D.jsx)(p.Menu,{"aria-label":o,align:d,trigger:e=>(0,D.jsx)(n.Button,{...e,...g,variant:e[`aria-expanded`]?`active`:`simple`,tabIndex:r||l||e[`aria-expanded`]?0:-1,onMouseDown:e=>e.preventDefault(),onFocus:()=>u(!0),onBlur:()=>u(!1),onClick:t=>{if(!e[`aria-expanded`]){let e=getComputedStyle(t.currentTarget).direction===`rtl`;f(e?`start`:`end`),typeof s==`function`&&h(s(e))}e.onClick()}}),children:(0,D.jsx)(me,{groups:typeof s==`function`?m:s})}))]})}function K(e){return!!(e&&(e.loadPage||e.items?.length||e.onCreate))}function _e(e){return!!(e&&(e.loadPage||e.items?.length))}var q=(0,T.createContext)({views:{},disabled:!1,busy:!1,pickCount:0,replace:()=>{},seed:()=>void 0,forgetSeed:()=>{}}),ve=[],ye=[{align:`left`,icon:`align-left`,label:`Align left`},{align:`full`,icon:`align-justify`,label:`Full width`},{align:`right`,icon:`align-right`,label:`Align right`}];function be(e,t){let{views:n,seed:r,forgetSeed:i}=(0,T.useContext)(q),a=n[e],o=a?.items??ve,s=(0,T.useMemo)(()=>[t],[t]),c=(0,T.useCallback)(t=>r(e,t),[r,e]),l=d.s(s,o,a?.resolveItem,a?.refreshKey,c),u=r(e,t);(0,T.useEffect)(()=>{u&&i(e,t,u)},[i,e,t,u]);let{known:f,failures:p}=l,m=!!a?.resolveItem,h=(0,T.useMemo)(()=>d.c({selected:s,items:o,pageItems:ve,known:f,failures:p,hasResolver:m,itemLabel:e})[0],[s,o,f,p,m,e]),g=d.o(`Couldn't load ${e}`,l.status,l.error,l.retry),_=o.some(e=>e.id===t);return{view:a,item:h,missing:h.tone===`removed`||!_&&f.has(t)&&!f.get(t),failure:g}}function xe({kind:e,id:t,item:n,missing:r}){return(0,D.jsx)(`div`,{className:`ds-entry ds-content-block__body`,children:r?(0,D.jsxs)(`span`,{className:`ds-entry__body`,children:[(0,D.jsx)(`em`,{className:`ds-entry__title`,children:`Unavailable ${e}`}),(0,D.jsxs)(`span`,{className:`ds-entry__meta`,children:[(0,D.jsx)(`span`,{children:`This ${e} was deleted. Replace or remove it.`}),(0,D.jsx)(`code`,{children:t})]})]}):(0,D.jsx)(d.l,{item:n})})}function Se({node:e,selected:t,editor:n,getPos:r,updateAttributes:i}){let{disabled:a,busy:o,replace:s}=(0,T.useContext)(q),c=e.attrs.type,l=String(c===`entry`?e.attrs.entryId:e.attrs.assetId),{view:u,item:d,missing:f,failure:p}=be(c,l),m=e.attrs.align??`full`,h=!f&&!d.isUnavailable&&!d.isDisabled&&u?.onEditItem,g=t&&!a,_=()=>{let e=r();e!==void 0&&n.chain().focus().setNodeSelection(e).run()},v=()=>{let t=r();t!==void 0&&n.chain().focus().setNodeSelection(t).deleteRange({from:t,to:t+e.nodeSize}).run()},y=e=>{let t=e.target;!e.defaultPrevented&&t instanceof Element&&e.currentTarget.contains(t)&&(t.closest(`button`)?e.preventDefault():!a&&!t.closest(`[data-drag-handle]`)&&(e.preventDefault(),_()))},b=[];return h&&b.push({label:`Edit ${c}`,icon:`pencil`,run:()=>h(d)}),u?.canEmbed&&b.push({label:f?`Choose another ${c}`:`Replace`,icon:`rotate-cw`,disabled:o,run:()=>{let e=r();e!==void 0&&s(c,e)}}),(0,D.jsxs)(O.NodeViewWrapper,{className:de,"data-kind":c,"data-align":m,"data-selected":g||void 0,"data-missing":f||void 0,"data-tone":f?`removed`:d.tone,contentEditable:!1,onMouseDown:y,children:[(0,D.jsx)(ge,{kind:c,isSelected:g,isDisabled:a,isLocked:!!u?.isDialogHidden,menuLabel:`Block actions for ${f?`Unavailable ${c}`:d.title}`,onSelect:_,actions:[{label:`Alignment`,choices:!0,keepOpen:!0,actions:ye.map(e=>({label:e.label,icon:e.icon,checked:m===e.align,run:()=>i({align:e.align})}))},...b.length?[{actions:b,separate:!0}]:[],{separate:!0,actions:[{label:`Remove from field`,icon:`trash`,tone:`danger`,run:v}]}]}),(0,D.jsx)(xe,{kind:c,id:l,item:d,missing:f}),p&&(0,D.jsx)(`div`,{className:`ds-content-block__failure`,children:p})]})}var Ce=`ds-rte-embed-commit`,we=[`entry`,`asset`],Te={entry:{itemLabel:`entry`,itemsLabel:`entries`},asset:{itemLabel:`asset`,itemsLabel:`assets`}},Ee={},De=[];function Oe(e,t,n){return{type:e,align:t,...e===`entry`?{id:n.modelId,entryId:n.id}:{assetId:n.id}}}function ke(e,t,n,{replacing:r,multiple:i}){let a=e.chain().focus().setMeta(Ce,!0);return i&&a.command(({tr:e})=>((0,N.closeHistory)(e),!0)),r?a.setNodeSelection(t).updateAttributes(`contentBlock`,n[0].attrs).run():a.insertContentAt(t,n).setNodeSelection(t+n.length-1).run()}function Ae(e,t){if(t.tone===`removed`)return{label:t.removedLabel??`Removed`,description:`This ${e} was removed.`};if(t.isUnavailable)return{label:`Unavailable`,description:`This ${e} is unavailable.`};if(!R(Oe(e,`full`,t)))return{label:`Can't embed`,description:`This ${e} has no ${e===`entry`&&!t.modelId?.trim()?`model API ID`:`ID`}.`}}function je(e,t){return!t.isDisabled&&!Ae(e,t)}function Me(e,t,n,r){let i=e.flatMap(e=>{let i=r(e.item.id);return i===void 0?[e]:!i||!je(t,i)?[]:i===e.item&&Object.is(n,e.revision)?[e]:[{item:i,revision:n}]});return i.length!==e.length||i.some((t,n)=>t!==e[n])?i:e}var Ne={entry:e=>Ae(`entry`,e),asset:e=>Ae(`asset`,e)};function Pe(e,t){return e?.type.name===`contentBlock`&&e.attrs.type===t.kind&&String(t.kind===`entry`?e.attrs.entryId:e.attrs.assetId)===t.replaceId}function Fe(e){return e.flatMap(e=>e.mapping.maps)}function Ie(e,t){let n=t;for(let t of Fe(e)){let e=n,r;if(t.forEach((t,n,i,a)=>{r===void 0&&t<=e&&e<n&&n-t===a-i&&(r=i+(e-t))}),r!==void 0){n=r;continue}let i=t.mapResult(e,1);if(i.deletedAfter)return null;n=i.pos}return n}function Le(e,t,n){let r=t,i=n;for(let t of Fe(e)){if(r===i){r=i=t.map(i,-1);continue}let e=!1;if(t.forEach((t,n,a,o)=>{let s=i-r===1&&t===r&&n===i&&o-a===1;e||=t<=r&&i<=n&&!s}),r=t.map(r,1),i=t.map(i,-1),e||i<=r)return null}return{from:r,to:i}}function Re(e,t){let n=e.resolve(Math.min(t,e.content.size));return n.depth?n.after(1):n.pos}function ze(e,t,n){let r=e!==void 0,i=!!e?.resolveItem,a=!!e?.onEditItem,o=e?.refreshKey,s=e?.items,c=!!e?.isDialogHidden,l=K(e);return(0,T.useMemo)(()=>r?{resolveItem:i?t:void 0,refreshKey:o,items:s,isDialogHidden:c,canEmbed:l,onEditItem:a?n:void 0}:void 0,[r,i,a,o,s,c,l,t,n])}function Be({session:e,source:t,disabled:n,label:r,close:a,target:o,pick:s}){let{itemLabel:c,itemsLabel:l}=Te[e.kind],{multiple:u}=e,f=!!t.isCreating,[p,m]=(0,T.useState)([]),[h,g]=(0,T.useState)(``),_=i.u(p.length),v=(0,T.useMemo)(()=>e.replaceId?[e.replaceId]:p.map(({item:e})=>e.id),[e,p]),y=d.n(v,t.items??De,{...t,resolveItem:u?t.resolveItem:void 0,mode:u?`multiple`:`single`,max:void 0},{isOpen:!0,isDisabled:n||f,itemLabel:c,itemsLabel:l,close:a,recheckSelection:u,restrict:Ne[e.kind]}),b=d.o(`Couldn't load selected ${l}`,y.selection.status,y.selection.error,y.selection.retry),x=e.replaceId?`Replace`:`Embed`,S=Me(p,e.kind,t.refreshKey,e=>y.isRemote?y.selection.current.get(e):t.items?.find(t=>t.id===e)??null),C=p.length-S.length;S!==p&&m(S),C>0&&g(`${C} unavailable ${C===1?c:l} removed from selection.`);let w=!n&&!f&&y.selection.status===`ready`&&S.length>0&&C===0,E=()=>{w&&s(S)};return(0,D.jsx)(d.a,{...y.dialog,isOpen:!0,onClose:a,onToggle:e=>{let t=y.choice(e);if(!t)return;let n={item:t,revision:y.revision};u?(g(``),v.includes(e)?m(t=>t.filter(({item:t})=>t.id!==e)):(y.selection.remember([t],n.revision,[...v,e]),m(e=>[...e,n]))):s([n])},addLabel:`${x} ${u?l:c}`,confirm:u?{label:`Insert selected`,isDisabled:!w,onClick:E}:void 0,selectionNotice:h,selectionFailure:b,onCreate:t.onCreate?()=>t.onCreate?.({available:()=>_.current===0&&o.available(),commit:e=>_.current===0&&o.commit(e)}):void 0,isCreateDisabled:p.length>0,isCreating:t.isCreating,dialogTitle:t.dialogTitle,dialogDescription:`${u?`Choose ${l}`:`Choose one ${c}`} to embed in ${r}. ${t.dialogDescription??``}`.trim(),isDialogHidden:t.isDialogHidden})}function Ve(e,t=Ee,r,a){let[s,c]=(0,T.useState)(null),l=(0,T.useRef)(0),u=(0,T.useRef)({session:null,editor:null,from:0,to:0,alive:!1}),d=(0,T.useRef)(new Map),[f,p]=(0,T.useState)(0),m=(0,T.useCallback)(()=>{u.current.alive=!1,c(null)},[]),h=s?t[s.kind]:void 0,g=s&&K(h)&&(!r||h?.isCreating)?s:null;s&&!g&&c(null);let _=!!(g&&(h?.isDialogHidden||h?.isCreating)),v=i.u({editor:e,sources:t,disabled:r,busy:_});(0,T.useEffect)(()=>{if(!e||!s)return;if(u.current.session===s&&u.current.editor!==e){m();return}u.current.alive=!0;let t=({editor:e,transaction:t,appendedTransactions:n})=>{let r=[t,...n];if(!u.current.alive||!r.some(e=>e.docChanged))return;let{from:i,to:a}=u.current;if(s.replaceId===void 0){let e=Le(r,i,a);e?Object.assign(u.current,e):m();return}let o=Ie(r,i);o===null||!Pe(e.state.doc.nodeAt(o),s)?m():Object.assign(u.current,{from:o,to:o+1})};return e.on(`transaction`,t),()=>{e.off(`transaction`,t),u.current.session===s&&(u.current.alive=!1)}},[e,s,m]);let y=e=>{let{editor:t,sources:n,disabled:r}=v.current,i=n[e.kind];return!(!t||t.isDestroyed||u.current.session!==e||u.current.editor!==t||!u.current.alive||!K(i)||r&&!i?.isCreating)},b=(e,t,n=!1)=>{let r=v.current.editor,i=e.replaceId!==void 0;if(!r||!y(e)||!t.length||(!n||i)&&t.length!==1||t.some(({item:t})=>!je(e.kind,t)))return!1;let{doc:a}=r.state,o=i?a.nodeAt(u.current.from):null;if(i&&!Pe(o,e))return!1;let s=t.map(({item:t})=>({type:`contentBlock`,attrs:Oe(e.kind,o?.attrs.align??`full`,t)})),c=i?u.current.from:Re(a,u.current.to);u.current.alive=!1,d.current=new Map(t.map(t=>[`${e.kind}:${t.item.id}`,t]));let l=!1;try{l=ke(r,c,s,{replacing:i,multiple:n})}catch{l=!1}finally{m()}return l?(n&&!r.isDestroyed&&r.view.dispatch((0,N.closeHistory)(r.state.tr)),p(e=>e+1)):d.current.clear(),l},x=(e,t)=>{let{editor:n,sources:r,disabled:i,busy:a}=v.current;if(!n||i||a||!K(r[e]))return;let o=t===void 0?null:n.state.doc.nodeAt(t);if(t!==void 0&&(o?.type.name!==`contentBlock`||o.attrs.type!==e))return;let{$from:s,from:d,to:f}=n.state.selection,p={id:l.current+=1,kind:e,multiple:t===void 0&&_e(r[e]),replaceId:o?String(e===`entry`?o.attrs.entryId:o.attrs.assetId):void 0},m=t===void 0?s.depth?{from:s.before(1),to:s.after(1)}:{from:d,to:f}:{from:t,to:t+1};u.current={session:p,editor:n,...m,alive:!0},c(p)},S=i.u({open:x}),[C]=(0,T.useState)(()=>({replace:(e,t)=>S.current.open(e,t),seed:(e,t)=>d.current.get(`${e}:${t}`),forgetSeed:(e,t,n)=>{d.current.get(`${e}:${t}`)===n&&d.current.delete(`${e}:${t}`)},resolve:{entry:e=>v.current.sources.entry?.resolveItem?.(e)??null,asset:e=>v.current.sources.asset?.resolveItem?.(e)??null},edit:{entry:e=>{v.current.sources.entry?.onEditItem?.(e)},asset:e=>{v.current.sources.asset?.onEditItem?.(e)}}})),w=ze(t.entry,C.resolve.entry,C.edit.entry),E=ze(t.asset,C.resolve.asset,C.edit.asset),O=(0,T.useMemo)(()=>({views:{entry:w,asset:E},disabled:r,busy:_,pickCount:f,replace:C.replace,seed:C.seed,forgetSeed:C.forgetSeed}),[w,E,r,_,f,C]),k=we.filter(e=>K(t[e]));return{context:O,isCreating:we.some(e=>t[e]?.isCreating),toolbar:k.length>0&&(0,D.jsx)(o.ButtonGroup,{"aria-label":`Embed`,children:k.map(i=>{let a=`Embed ${_e(t[i])?Te[i].itemsLabel:i}`;return(0,D.jsx)(n.Button,{size:`sm`,isIconOnly:!0,iconStart:i===`entry`?`file-text`:`image`,"aria-label":a,title:a,"aria-pressed":g?.kind===i,variant:g?.kind===i?`primary`:`neutral`,isDisabled:r||_||!e,onClick:()=>x(i)},i)})}),dialog:e&&g&&h&&(0,D.jsx)(Be,{session:g,source:h,disabled:r,label:a,close:m,target:{available:()=>y(g),commit:e=>b(g,[{item:e,revision:v.current.sources[g.kind]?.refreshKey}])},pick:e=>b(g,e,g.multiple)},g.id)}}var He=[`wide`,`full`],Ue=[`sm`,`md`,`lg`],We=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`,`select`,`slider`,`rangeSlider`,`colour`,`radioGroup`,`checkboxGroup`,`tags`,`date`,`divider`]);function Ge(e){let t=new Set;for(let n of e.fields){if(!n.id?.trim()||t.has(n.id))throw Error(`Form field IDs must be nonempty and unique.`);if(!We.has(n.type))throw Error(`Unsupported form field type: ${n.type}`);if(`labelHint`in n)throw Error(`Field ${n.id} uses the removed labelHint; move its content into hint.`);n.type!==`divider`&&(Ke(n),tt(n),Ye(n)),t.add(n.id)}}function Ke(e){switch(e.type){case`select`:case`radioGroup`:case`checkboxGroup`:return it(e);case`slider`:case`rangeSlider`:return nt(e);case`number`:return rt(e);case`richText`:if(e.tables!==void 0&&typeof e.tables!=`boolean`)throw Error(`Rich text field ${e.id} needs a boolean tables.`)}}var qe=new Set([`shortText`,`longText`,`tags`,`asset`,`reference`]);function Je(e){return qe.has(e.type)}function Ye(e){if(Je(e)){if(e.limitDisplay!==void 0&&![`used`,`remaining`].includes(e.limitDisplay))throw Error(`Field ${e.id} needs a limitDisplay of used or remaining.`);if(e.limitVisibility!==void 0&&![`always`,`nearLimit`].includes(e.limitVisibility))throw Error(`Field ${e.id} needs a limitVisibility of always or nearLimit.`);if(e.showLimitRing!==void 0&&typeof e.showLimitRing!=`boolean`)throw Error(`Field ${e.id} needs a boolean showLimitRing.`)}}function Xe(e,t,n,r){return Je(e)?{limitDisplay:e.limitDisplay,limitVisibility:e.limitVisibility,showLimitRing:e.showLimitRing,limit:Ze(e,t,n??[],r)}:{}}function Ze(e,t,n,r){switch(e.type){case`shortText`:case`longText`:return e.maxLength===void 0?void 0:{count:$e(t).length,max:e.maxLength};case`tags`:return e.max===void 0?void 0:{count:Y(t).length,max:e.max};default:{let{mode:t,max:i}=et(e,r);return d.i(t,n.length,i)}}}function Qe(e,t,n,r){if(n!==void 0&&(e.type===`asset`||e.type===`reference`)){let{mode:t,max:i}=et(e,r);return d.r(t,n.length,i)}return e.type===`checkboxGroup`?Y(t).length:void 0}function $e(e){return typeof e==`string`?e:``}function et(e,t){let n=t?.mode??(e.multiple?`multiple`:`single`);if(!e.multiple)return{mode:n,max:n===`multiple`?1:void 0};let r=[st(e).max,t?.max].filter(e=>e!==void 0&&Number.isFinite(e));return{mode:n,max:r.length>0?Math.min(...r):void 0}}function tt(e){if(e.width!==void 0&&!Ue.includes(e.width))throw Error(`Field ${e.id} needs a width of sm, md or lg.`);if(e.type===`richText`&&e.expandedWidth!==void 0&&!He.includes(e.expandedWidth))throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`)}function nt(e){let{min:t,max:n,step:r}=b.i(e);if(![t,n,r].every(Number.isFinite)||t>=n||r<=0)throw Error(`Slider field ${e.id} needs finite min < max and a positive step.`);if(e.type===`rangeSlider`&&r>g.n(n,-t))throw Error(`Range slider ${e.id} needs room for at least one step.`)}function rt(e){let{min:t,max:n,step:r=`any`}=e;if([t,n].some(e=>e!==void 0&&!Number.isFinite(e))||t!==void 0&&n!==void 0&&t>n||r!==`any`&&!(Number.isFinite(r)&&r>0))throw Error(`Number field ${e.id} needs finite min <= max and a positive step or "any".`);if([e.decreaseLabel,e.increaseLabel].some(e=>e!==void 0&&(typeof e!=`string`||!e.trim())))throw Error(`Number field ${e.id} needs nonempty stepper labels.`)}function it(e){if(!Array.isArray(e.options)){let t=e.type===`select`?`Select`:`Choice`;throw Error(`${t} field ${e.id} needs an options array.`)}if(e.type===`select`)return;let t=e.options.map(e=>e.value);if(t.some(e=>typeof e!=`string`||!e.trim())||new Set(t).size!==t.length)throw Error(`Choice field ${e.id} needs nonempty, unique option values.`)}var at={asset:{key:`assetId`,itemLabel:`asset`,itemsLabel:`assets`},reference:{key:`entryId`,itemLabel:`entry`,itemsLabel:`entries`}};function ot(e){return e.type===`asset`||e.type===`reference`?e.picker?.label??e.label:e.label}function st(e){let t=at[e.type],{addLabel:n=`Choose ${ot(e)}`,emptyLabel:r,itemLabel:i=t.itemLabel,itemsLabel:a=t.itemsLabel,max:o,isReorderable:s}=e.picker??{};return{addLabel:n,emptyLabel:r,itemLabel:i,itemsLabel:a,max:o,isReorderable:s}}function ct(e,t){let{key:n}=at[e.type];return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>ut(e,n)?[e[n]]:[])}function lt(e){if(typeof e!=`string`)return;let t=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);if(!t)return;let n=`${t[1]}:${t[2]??`00`}.${(t[3]??``).padEnd(3,`0`)}Z`,r=new Date(n);if(Number.isFinite(r.getTime())&&r.toISOString()===n)return n}function ut(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function dt(e){return!!e.text?.trim()||e.type===`horizontalRule`||e.type===`contentBlock`||!!e.content?.some(dt)}function J(e){return`${ot(e)} is required.`}function ft(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return J(e);if((e.type===`shortText`||e.type===`longText`)&&e.maxLength!==void 0&&t.length>e.maxLength)return`Enter no more than ${e.maxLength} characters.`}function pt(e,t){let n=ue(t,{tables:e.type!==`richText`||e.tables!==!1});if(n)return n;if(e.required&&!dt(G(t)))return J(e)}function mt(e,t){if(typeof t!=`string`)return`Choose an available option.`;if(t===``)return e.required?J(e):void 0;if((e.type===`select`||e.type===`radioGroup`)&&e.options.length>0&&!e.options.some(e=>e.value===t))return`Choose an available option.`}function Y(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function ht(e,t){if(!Array.isArray(t)||!t.every(e=>typeof e==`string`&&e.trim())||new Set(t).size!==t.length)return`Enter a list of unique, nonempty text values.`;if(e.required&&!t.length)return J(e);if(e.type===`tags`&&e.max!==void 0&&t.length>e.max)return`Enter no more than ${e.max} tags.`;if(e.type===`checkboxGroup`&&e.options.length&&t.some(t=>!e.options.some(e=>e.value===t)))return`Choose available options.`}function X(e,t){if(typeof t!=`number`||!Number.isFinite(t))return`Enter a finite number.`;let{min:n,max:r}=e.type===`slider`||e.type===`rangeSlider`?b.i(e):e.type===`number`?e:{};if(n!==void 0&&t<n)return`Enter a number of at least ${n}.`;if(r!==void 0&&t>r)return`Enter a number no greater than ${r}.`}function gt(e,t){if(typeof t!=`string`)return`Enter a valid calendar date (YYYY-MM-DD).`;if(!t)return e.required?J(e):void 0;if(!S.a(t))return`Enter a valid calendar date (YYYY-MM-DD).`;if(e.type===`date`){if(e.min&&t<e.min)return`Choose a date on or after ${e.min}.`;if(e.max&&t>e.max)return`Choose a date on or before ${e.max}.`}}function _t(e,t){return typeof e==`number`&&Number.isFinite(e)?b.r(e,t):void 0}function vt(e,t){let n=e,r=_t(n?.min,t),i=_t(n?.max,t);if(r===void 0&&i===void 0)return;let[a,o]=[r??t.min,i??t.max].sort((e,t)=>e-t);return{min:a,max:o}}function yt(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return`Enter a range.`;let n=t,r=n.min,i=n.max,a=X(e,r)??X(e,i);if(a)return a;if(r>i)return`The start must not be greater than the end.`;if(e.type===`rangeSlider`&&g.n(i,-r)<b.i(e).step)return`Keep the range endpoints at least one step apart.`}function bt(t,n){return typeof n==`string`?n.trim()?e.i(n)?void 0:`Enter a valid colour.`:t.required?J(t):void 0:`Enter a valid colour.`}function xt(e,t){if(e.type!==`asset`&&e.type!==`reference`)return;let{key:n,itemLabel:r,itemsLabel:i}=at[e.type];if(!e.multiple)return ut(t,n)?void 0:`Choose an ${r}.`;if(!Array.isArray(t)||!t.every(e=>ut(e,n)))return`Choose a list of ${i}.`;if(e.required&&t.length===0)return J(e);let a=e.picker?.max;if(a!==void 0&&t.length>a)return`Choose no more than ${a} ${st(e).itemsLabel}.`}var St={shortText:ft,longText:ft,richText:pt,number:X,slider:X,rangeSlider:yt,date:gt,colour:bt,radioGroup:mt,checkboxGroup:ht,tags:ht,boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>lt(t)?void 0:`Enter a valid UTC date and time.`,select:mt,asset:xt,reference:xt};function Ct(e,t){return t===void 0?e.required?J(e):void 0:St[e.type](e,t)}function wt(e,t){return Ge(e),Object.fromEntries(e.fields.flatMap(e=>{if(e.type===`divider`)return[];let n=Ct(e,Object.hasOwn(t,e.id)?t[e.id]:void 0);return n?[[e.id,n]]:[]}))}function Tt({field:e,option:t,name:n,checked:r,isDisabled:i,invalid:a,onChange:o}){let s={name:n,value:t.value,checked:r,disabled:i||t.isDisabled,"aria-invalid":a,onChange:()=>{!i&&!t.isDisabled&&o()}};if(e.appearance===`card`){let n=e.type===`radioGroup`?w.RadioCard:w.CheckboxCard;return(0,D.jsx)(n,{...s,title:t.label,description:t.description})}let c=e.type===`radioGroup`?m.Radio:m.Checkbox;return(0,D.jsx)(c,{...s,children:(0,D.jsxs)(`span`,{children:[t.label,t.description&&(0,D.jsx)(`span`,{className:`ds-form-editor__option-description`,children:t.description})]})})}function Et({field:e,stored:t,isDisabled:r,required:i,accessibility:a,onChange:o}){let s=e.type===`checkboxGroup`,c=s?Y(t):typeof t==`string`&&t?[t]:[],l=e.appearance===`card`?w.SelectionCardGroup:m.ChoiceGroup;return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(l,{...a,label:e.label,columns:e.columns??(e.appearance===`card`?2:1),children:e.options.map(t=>(0,D.jsx)(Tt,{field:e,option:t,name:a.id,checked:c.includes(t.value),isDisabled:r,invalid:a[`aria-invalid`],onChange:()=>{o(s?c.includes(t.value)?c.filter(e=>e!==t.value):[...c,t.value]:t.value)}},t.value))}),!s&&!i&&c.length>0&&(0,D.jsxs)(n.Button,{variant:`simple`,size:`sm`,isDisabled:r,onClick:()=>o(void 0),children:[`Clear `,e.label]})]})}function Dt({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=b.i(e),o=_t(t,a);return(0,D.jsx)(b.n,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,valueText:o===void 0?e.placeholder??`Not set`:void 0,autoFocus:e.autoFocus,isDisabled:n,value:o??a.min,onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function Ot({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=b.i(e),o=vt(t,a);return(0,D.jsx)(b.t,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,minLabel:`${e.label} minimum`,maxLabel:`${e.label} maximum`,isDisabled:n,valueText:o===void 0?e.placeholder??`Not set`:void 0,hasFill:o!==void 0,value:o??{min:a.min,max:a.max},onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function kt({field:t,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s={stored:n,isDisabled:r,required:i,accessibility:a,onChange:o};switch(t.type){case`radioGroup`:case`checkboxGroup`:return(0,D.jsx)(Et,{field:t,...s});case`rangeSlider`:return(0,D.jsx)(Ot,{field:t,...s});case`slider`:return(0,D.jsx)(Dt,{field:t,...s});case`colour`:return(0,D.jsx)(x.t,{...a,required:i,placeholder:t.placeholder,presets:t.presets,showPresets:t.showPresets,picker:t.picker,placement:t.placement,readOnly:t.readOnly,autoFocus:t.autoFocus,isDisabled:r,value:typeof n==`string`?n:``,onInput:t=>{let n=t.currentTarget.value;n.trim()&&!e.i(n)&&o(n)},onValueChange:e=>o(e===``?void 0:e)});case`tags`:return(0,D.jsx)(C.TagsInput,{...a,required:i,placeholder:t.placeholder,max:t.max,isDisabled:r,value:Y(n),onValueChange:o});case`date`:return(0,D.jsx)(S.n,{...a,placeholder:t.placeholder,min:t.min,max:t.max,placement:t.placement,isDisabled:r,isClearable:!0,clearLabel:`Clear ${t.label}`,value:typeof n==`string`?n:``,onValueChange:e=>o(e===``?void 0:e)})}}function At(e,t){if(e.type===`asset`){let n=t.map(e=>({assetId:e}));return e.multiple?n:n[0]}let n=t.map(e=>({entryId:e}));return e.multiple?n:n[0]}var jt=(0,T.createContext)(null);function Mt({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){return(0,D.jsx)(_.t,{...i,required:r,isDisabled:n,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step??`any`,hasSteppers:e.hasSteppers,prefix:e.prefix,suffix:e.suffix,autoFocus:e.autoFocus,decreaseLabel:e.decreaseLabel??`Decrease ${e.label}`,increaseLabel:e.increaseLabel??`Increase ${e.label}`,value:typeof t==`number`&&Number.isFinite(t)?t:``,onValueChange:e=>{(e===``||Number.isFinite(e))&&a(e===``?void 0:e)}})}function Nt({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){let o=!r&&!e.options.some(e=>e.value===``);return(0,D.jsx)(v.Select,{...i,"aria-required":r||void 0,isDisabled:n,isInvalid:i[`aria-invalid`],options:o?[{value:``,label:e.placeholder??`None`},...e.options]:e.options,placeholder:e.placeholder,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onValueChange:e=>a(e===``?void 0:e)})}function Pt({field:e,selected:t,items:n,source:r,isDisabled:i,accessibility:a,onChange:o}){return(0,D.jsx)(d.t,{...a,...r,items:n,value:t,...st(e),...et(e,r),isDisabled:i,onValueChange:t=>o(At(e,t))})}function Ft({embeds:e,field:t,stored:n,selected:r,items:i,source:a,isDisabled:o,accessibility:{required:s,...c},onChange:l}){let d=(0,T.useContext)(jt),f={stored:n,isDisabled:o,required:s,accessibility:c,onChange:l};switch(t.type){case`shortText`:return(0,D.jsx)(u.TextField,{...c,required:s,disabled:o,placeholder:t.placeholder,type:t.inputType,maxLength:t.maxLength,readOnly:t.readOnly,autoFocus:t.autoFocus,value:$e(n),onChange:e=>l(e.target.value)});case`longText`:return(0,D.jsx)(u.TextArea,{...c,required:s,disabled:o,placeholder:t.placeholder,rows:t.rows,maxLength:t.maxLength,readOnly:t.readOnly,autoFocus:t.autoFocus,value:$e(n),onChange:e=>l(e.target.value)});case`number`:return(0,D.jsx)(Mt,{field:t,...f});case`boolean`:return(0,D.jsx)(y.Switch,{...c,isDisabled:o,autoFocus:t.autoFocus,isSelected:n===!0,onSelectedChange:l});case`dateTime`:return(0,D.jsx)(u.TextField,{...c,required:s,disabled:o,type:`datetime-local`,step:`0.001`,autoFocus:t.autoFocus,value:lt(n)?.slice(0,-1)??``,onChange:e=>l(lt(`${e.target.value}Z`))});case`richText`:if(!d)throw Error(`Rich text field ${t.id} needs FormEditor's rich-text control.`);return d({field:t,embeds:e,...f});case`select`:return(0,D.jsx)(Nt,{field:t,...f});case`asset`:case`reference`:return(0,D.jsx)(Pt,{field:t,items:i,source:a,selected:r??[],...f});default:return(0,D.jsx)(kt,{field:t,...f})}}function It({field:e,stored:t,items:n,source:r,embeds:i,isDisabled:a,error:o,isErrorVisible:s,onChange:l}){let u=(0,T.useMemo)(()=>o===void 0&&s?Ct(e,t):void 0,[o,s,e,t]),d=(0,T.useMemo)(()=>e.type===`asset`||e.type===`reference`?ct(e,t):void 0,[e,t]);return(0,D.jsx)(h.Container,{width:e.width,padded:!1,center:!1,className:`ds-form-editor__field`,children:(0,D.jsx)(c.Field,{...Xe(e,t,d,r),label:e.type===`dateTime`?`${e.label} (UTC)`:ot(e),hint:e.hint,error:o??u,isRequired:e.required,count:Qe(e,t,d,r),isGroup:d!==void 0||Lt.has(e.type),children:o=>(0,D.jsx)(Ft,{field:e,stored:t,selected:d,items:n,source:r,embeds:i,isDisabled:a,accessibility:o,onChange:l})})})}var Lt=new Set([`radioGroup`,`checkboxGroup`,`rangeSlider`]),Rt=new Set([`slider`,`rangeSlider`,`date`,`colour`]);function zt({schema:e,value:t,defaultValue:n={},onValueChange:r,pickerItems:i={},pickerSources:a={},embedSources:o={},errors:s={},isDisabled:c=!1,showAllErrors:l=!1,columns:u=1,minColumnWidth:d=`16rem`,className:f,style:p,...m}){let[h,g]=(0,T.useState)(n),[_,v]=(0,T.useState)(()=>new Set),y=t??h;(0,T.useMemo)(()=>Ge(e),[e]);let b=(e,n)=>{let i={...y};n===void 0?delete i[e]:i[e]=n,t===void 0&&g(i),v(t=>new Set(t).add(e)),r?.(i,{fieldId:e})},x=u===`auto`?{"--form-editor-min-column":d}:{"--form-editor-columns":u,"--form-editor-min-column":d};return(0,D.jsx)(`div`,{className:[`ds-form-editor`,u===`auto`&&`ds-form-editor--auto`,f].filter(Boolean).join(` `),style:{...x,...p},...m,children:e.fields.map(e=>{if(e.type===`divider`)return(0,D.jsx)(`hr`,{className:`ds-form-editor__divider`},e.id);let t=Object.hasOwn(y,e.id)?y[e.id]:void 0,n=c||!!e.isDisabled,r=n||`readOnly`in e&&!!e.readOnly,u=typeof t==`string`?t.trim()!==``:t!==void 0,d=l||_.has(e.id)||u&&Rt.has(e.type)||e.type===`number`&&typeof t==`number`;return(0,D.jsx)(It,{field:e,stored:t,items:i[e.id]??[],source:a[e.id],embeds:o[e.id],isDisabled:n,error:s[e.id],isErrorVisible:d,onChange:t=>{(!r||e.type===`richText`&&(o[e.id]?.entry?.isCreating||o[e.id]?.asset?.isCreating))&&b(e.id,t)}},e.id)})})}var Bt=50,Vt={fields:[{id:`rows`,type:`number`,label:`Rows`,required:!0,min:1,max:Bt,step:1,decreaseLabel:`Fewer rows`,increaseLabel:`More rows`},{id:`cols`,type:`number`,label:`Columns`,required:!0,min:1,max:Bt,step:1,decreaseLabel:`Fewer columns`,increaseLabel:`More columns`},{id:`withHeaderRow`,type:`boolean`,label:`Include header row`}]},Z={rows:3,cols:3},Ht={...Z,withHeaderRow:!0},Ut=`Enter a whole number.`;function Wt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=Bt?e:void 0}function Gt(e){return typeof e==`number`&&!Number.isInteger(e)?Ut:void 0}function Kt(e,t,{rows:n,cols:r,withHeaderRow:i}){e.chain().focus().command(({tr:a,dispatch:o})=>{let s=t.getBookmark().resolve(a.doc),c=(0,A.createTable)(e.schema,n,r,i),l=s instanceof M.NodeSelection?s.node.isInline?s.$to.after():s.to:null;if(l!==null){let e=a.doc.resolve(l);if(!e.parent.canReplaceWith(e.index(),e.index(),c.type))return!1}if(o){(0,N.closeHistory)(a);let e;l===null?(e=s.from+1,a.setSelection(s).replaceSelectionWith(c)):(e=l+1,a.insert(l,c)),a.setSelection(M.TextSelection.near(a.doc.resolve(e))).scrollIntoView()}return!0}).run()&&!e.isDestroyed&&(e.view.dispatch((0,N.closeHistory)(e.state.tr)),e.view.focus())}function qt({editor:e,selection:t,withHeaderRow:r,onClose:i}){let a=(0,T.useId)(),[o,s]=(0,T.useState)(()=>({...Ht,withHeaderRow:r})),[c,u]=(0,T.useState)(!1),d=Wt(o.rows),f=Wt(o.cols);return(0,D.jsx)(l.Modal,{isOpen:!0,title:`Insert table`,size:`dialog`,onClose:i,footer:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(n.Button,{onClick:i,children:`Cancel`}),(0,D.jsx)(n.Button,{variant:`primary`,type:`submit`,form:a,children:`Insert table`})]}),children:(0,D.jsx)(`form`,{id:a,noValidate:!0,onSubmit:n=>{n.preventDefault(),n.stopPropagation(),u(!0),d!==void 0&&f!==void 0&&(!e.isDestroyed&&e.isEditable&&e.state.doc.eq(t.$from.doc)&&Kt(e,t,{rows:d,cols:f,withHeaderRow:o.withHeaderRow===!0}),i())},children:(0,D.jsx)(zt,{schema:Vt,value:o,onValueChange:s,errors:{rows:Gt(o.rows),cols:Gt(o.cols)},showAllErrors:c,columns:2,minColumnWidth:`8rem`})})})}var Jt=6,Yt=8,Xt=Array.from({length:Jt},(e,t)=>t+1),Zt=Array.from({length:Yt},(e,t)=>t+1);function Qt({editor:e,selection:t}){return!e.isDestroyed&&e.isEditable&&e.state.doc.eq(t.$from.doc)}function $t({editor:e,disabled:t,inTable:r}){let[o,s]=(0,T.useState)(null),[c,l]=(0,T.useState)(!0),[u,d]=(0,T.useState)(Z),[m,h]=(0,T.useState)(Z),[g,_]=(0,T.useState)(!1),v=(0,T.useRef)(null),b=(0,T.useRef)(null),x=(0,T.useRef)(null),S=(0,T.useRef)(null),C=(0,T.useId)(),w=(0,T.useCallback)(()=>s(null),[]),E=t||!e||r,O=!E&&o?.editor===e?o:null,k=i.o(O?.mode===`grid`);return o&&!O&&s(null),(0,T.useEffect)(()=>{if(!O)return;let e=O.editor,t=()=>{Qt(O)||w()};return e.on(`transaction`,t),t(),()=>{e.off(`transaction`,t)}},[O,w]),a.t(()=>{k&&x.current?.querySelector(`button[tabindex='0']`)?.focus()},[k]),(0,T.useEffect)(()=>{if(!k)return;let e=e=>{let t=e.target;!b.current?.contains(t)&&!x.current?.contains(t)&&w()},t=e=>{e.key===`Escape`&&!e.defaultPrevented&&!e.isComposing&&(e.preventDefault(),w(),v.current?.focus())};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[k,w]),(0,D.jsxs)(`span`,{ref:b,children:[(0,D.jsx)(n.Button,{ref:v,size:`sm`,isIconOnly:!0,iconStart:`table`,variant:k?`active`:`neutral`,"aria-label":`Insert table`,title:`Insert table`,"aria-haspopup":`dialog`,"aria-expanded":k,"aria-controls":k?C:void 0,isDisabled:E,onClick:t=>{k?w():e&&(_(getComputedStyle(t.currentTarget).direction===`rtl`),d(Z),h(Z),l(!0),s({editor:e,selection:e.state.selection,mode:`grid`}))}}),(0,D.jsx)(f.Popover,{anchorRef:v,panelRef:x,id:C,isOpen:k,placement:`bottom`,align:g?`end`:`start`,role:`dialog`,"aria-label":`Insert table`,tabIndex:-1,className:`ds-rte__table-picker ds-surface-raised ds-field-surface`,children:(0,D.jsxs)(`div`,{className:`ds-rte__table-picker-content`,onKeyDown:e=>{if(e.key!==`Tab`)return;let t=e.target.hasAttribute(`data-cell`);e.shiftKey&&t?(e.preventDefault(),w(),v.current?.focus()):!e.shiftKey&&e.target===S.current&&b.current&&(e.preventDefault(),w(),i.g(b.current))},children:[(0,D.jsxs)(`div`,{className:`ds-rte__table-picker-heading`,children:[(0,D.jsx)(p.MenuLabel,{children:`Insert table`}),(0,D.jsx)(`bdi`,{dir:`ltr`,children:`${m.rows} × ${m.cols}`})]}),(0,D.jsx)(`div`,{className:`ds-rte__table-picker-grid`,role:`grid`,"aria-label":`Table size`,onKeyDown:e=>{let{rows:t,cols:n}=u,r={ArrowDown:{rows:t+1,cols:n},ArrowUp:{rows:t-1,cols:n},ArrowLeft:{rows:t,cols:n+(g?1:-1)},ArrowRight:{rows:t,cols:n+(g?-1:1)},Home:{rows:t,cols:1},End:{rows:t,cols:Yt}}[e.key];if(r){e.preventDefault();let t=Math.max(1,Math.min(Jt,r.rows)),n=Math.max(1,Math.min(Yt,r.cols));e.currentTarget.querySelector(`[data-cell="${t}:${n}"]`)?.focus()}},onMouseLeave:()=>h(u),children:Xt.map(e=>(0,D.jsx)(`div`,{role:`row`,className:`ds-rte__table-picker-row`,children:Zt.map(t=>{let r=e<=m.rows&&t<=m.cols;return(0,D.jsx)(`div`,{role:`gridcell`,children:(0,D.jsx)(n.Button,{size:`xs`,isIconOnly:!0,tabIndex:e===u.rows&&t===u.cols?0:-1,"aria-label":`${e} ${e===1?`row`:`rows`} by ${t} ${t===1?`column`:`columns`}`,"data-cell":`${e}:${t}`,variant:r?e===1&&c?`primary`:`active`:`neutral`,onMouseEnter:n=>{let r=n.currentTarget;r.parentElement?.closest(`[role='grid']`)?.contains(r.ownerDocument.activeElement)?r.focus():h({rows:e,cols:t})},onFocus:()=>{let n={rows:e,cols:t};d(n),h(n)},onClick:()=>{O&&Qt(O)&&Kt(O.editor,O.selection,{rows:e,cols:t,withHeaderRow:c}),w()}})},t)})},e))}),(0,D.jsx)(y.Switch,{isSelected:c,onSelectedChange:l,children:`Include header row`}),(0,D.jsx)(p.MenuSeparator,{}),(0,D.jsxs)(n.Button,{ref:S,size:`sm`,variant:`simple`,className:`ds-rte__table-picker-custom`,onClick:()=>{O&&(v.current?.focus(),s({...O,mode:`custom`}))},children:[`Custom size…`,(0,D.jsx)(`span`,{children:`up to 50 × 50`})]})]})}),O?.mode===`custom`&&(0,D.jsx)(qt,{editor:O.editor,selection:O.selection,withHeaderRow:c,onClose:w})]})}function en(e,t){return t===`row`?e.height:e.width}function tn(e,t){let{map:n,table:r}=e;for(let e=0;e<n.height;e+=1)for(let i=0;i<n.width;i+=1){let a=e*n.width+i,o=n.map[a];if(i>0&&o===n.map[a-1]||e>0&&o===n.map[a-n.width])continue;let s=r.nodeAt(o);s&&t(s,e,i)}}function nn(e,t){let n=new Set;tn(e,(e,r,i)=>{let a=t===`row`?r:i,o=Number(t===`row`?e.attrs.rowspan:e.attrs.colspan);for(let e=a+1;e<a+o;e+=1)n.add(e)});let r=[],i=en(e.map,t),a=0;for(let e=1;e<=i;e+=1)n.has(e)||(r.push({start:a,end:e}),a=e);return r}function rn(e,t,n){return(n<t.start||n>t.end)&&(n===0||e.some(({end:e})=>e===n))}function an(e,t,n,r){let{pos:i,map:a}=t,{start:o,end:s}=r,c=n===`row`?o*a.width:o,l=n===`row`?s*a.width-1:(a.height-1)*a.width+s-1,u=e.resolve(i+1+a.map[c]),d=e.resolve(i+1+a.map[l]);return n===`row`?P.CellSelection.rowSelection(u,d):P.CellSelection.colSelection(u,d)}function on(e,t,n,r){let{map:i,table:a}=e,o=nn(e,t),s=o.find(({start:e,end:t})=>n>=e&&n<t);if(!s||!rn(o,s,r))return null;let c=Array.from({length:en(i,t)},(e,t)=>t),l=c.splice(s.start,s.end-s.start),u=r>s.end?r-l.length:r;c.splice(u,0,...l);let d=c.map(()=>0);c.forEach((e,t)=>{d[e]=t});let f=Array.from({length:i.height},()=>new Map);return tn(e,(e,n,r)=>{let o=t===`row`?d[n]:n,s=t===`column`?d[r]:r,c=a.nodeAt(i.map[o*i.width+s])?.type??e.type;f[o].set(s,c===e.type?e:c.createChecked(e.attrs,e.content,e.marks))}),{table:a.copy(j.Fragment.fromArray(f.map((e,n)=>a.child(t===`row`?c[n]:n).copy(j.Fragment.fromArray([...e.entries()].sort(([e],[t])=>e-t).map(([,e])=>e)))))),index:d[n]}}var sn=[{align:`left`,icon:`align-left`,label:`Align left`},{align:`center`,icon:`align-center`,label:`Align centre`},{align:`right`,icon:`align-right`,label:`Align right`}];function Q(e,t){e.view.dispatch(t.scrollIntoView()),e.view.focus()}function cn({map:e,table:t,pos:n}){return{map:e,table:t,tableStart:n+1,top:0,left:0,bottom:e.height,right:e.width}}function ln({map:e,table:t},n,r){return n!==`row`||r!==0||!(0,P.rowIsHeader)(e,t,0)}function un(e,t,n,r){if(!e.isEditable||e.state.doc.nodeAt(t.pos)!==t.table||!ln(t,n,r))return;let{pos:i}=t,a=(n===`row`?P.addRow:P.addColumn)((0,N.closeHistory)(e.state.tr),cn(t),r),o=a.doc.nodeAt(i),s={table:o,pos:i,map:P.TableMap.get(o)};Q(e,a.setSelection(an(a.doc,s,n,{start:r,end:r+1})))}function dn(e,t,n,r,i){if(!e.isEditable||e.state.doc.nodeAt(t.pos)!==t.table)return!1;let a=on(t,n,n===`row`?r.top:r.left,i);if(!a)return!1;let{pos:o,table:s}=t,c=(0,N.closeHistory)(e.state.tr).replaceWith(o,o+s.nodeSize,a.table),l=P.TableMap.get(a.table),u=n===`row`?a.index:r.top,d=n===`column`?a.index:r.left,f=l.map[u*l.width+d];return Q(e,c.setSelection(new P.CellSelection(c.doc.resolve(o+1+f)))),!0}var fn={row:{group:`Row`,insertBefore:{label:`Add row above`,icon:`rows-2-plus-top`},insertAfter:{label:`Add row below`,icon:`rows-2-plus-bottom`},remove:{label:`Delete row`,icon:`table-rows-split`}},column:{group:`Column`,insertBefore:{label:`Add column before`,icon:`columns-2-plus-left`,inlineIcon:!0},insertAfter:{label:`Add column after`,icon:`columns-2-plus-right`,inlineIcon:!0},remove:{label:`Delete column`,icon:`table-columns-split`}}};function pn(e,t,n,r){let i={boundary:n?.start},a={boundary:r?.end};if(e===`row`)return[{label:`Move row up`,icon:`arrow-up`,...i},{label:`Move row down`,icon:`arrow-down`,...a}];let[o,s]=t?[a,i]:[i,a];return[{label:`Move column left`,icon:`arrow-left`,...o},{label:`Move column right`,icon:`arrow-right`,...s}]}function mn(e,t,n){return n===`row`?e.top===0&&e.bottom===t.height:e.left===0&&e.right===t.width}function hn(e,t,n,r){let{doc:i}=e.state,{map:a,pos:o}=t,s=o+1,c=a.map[0],l=n!==null,u=P.CellSelection.create(i,s+c,s+a.map[a.map.length-1]),d=M.EditorState.create({doc:i,selection:n??u}),f=n?n instanceof P.CellSelection?n.$headCell:(0,P.cellAround)(n.$head):null,p=f?f.pos-s:c,m=a.map.includes(p)?p:c,h=a.findCell(m),g=new P.CellSelection(i.resolve(s+m)),_=M.EditorState.create({doc:i,selection:g}),v=n instanceof P.CellSelection?d:_,y=(0,P.selectedRect)(v),b=t=>()=>{!e.isDestroyed&&e.isEditable&&e.state.doc===i&&t()},x=d.selection instanceof P.CellSelection?d.selection:g,S=t=>{let n=(0,N.closeHistory)(d.tr);x.forEachCell((e,r)=>{(e.attrs.align??`left`)!==t&&n.setNodeMarkup(r,null,{...e.attrs,align:t===`left`?null:t})}),n.docChanged?Q(e,n):e.view.focus()},C=new Set;x.forEachCell(e=>C.add(e.attrs.align??`left`));let w=l&&(0,P.mergeCells)(d),T=[{label:`Merge cells`,icon:`table-cells-merge`,description:w?void 0:`Drag across 2 or more cells`,disabled:!w,run:b(()=>(0,P.mergeCells)(d,t=>Q(e,t)))}];l&&(0,P.splitCell)(d)&&T.push({label:`Split cell`,icon:`table-cells-split`,run:b(()=>(0,P.splitCell)(d,t=>Q(e,t)))});let E=n=>{let{group:i,insertBefore:o,insertAfter:s,remove:c}=fn[n],u=n===`row`?h.top:h.left,d=n===`row`?h.bottom:h.right,f=mn(y,a,n),p=nn(t,n),m=p.findIndex(({start:e,end:t})=>u>=e&&u<t),g=[...pn(n,r,p[m-1],p[m+1]).map(({label:r,icon:i,boundary:a})=>({label:r,icon:i,disabled:a===void 0,run:b(()=>{a!==void 0&&dn(e,t,n,h,a)})})),{...o,disabled:!ln(t,n,u),run:b(()=>un(e,t,n,u))},{...s,run:b(()=>un(e,t,n,d))},{...c,tone:`danger`,disabled:f,run:b(()=>{l&&!f&&(n===`row`?P.deleteRow:P.deleteColumn)(v,t=>Q(e,(0,N.closeHistory)(t)))})}];return{label:i,description:l?void 0:`Select a cell first`,separate:!0,actions:l?g:g.map(e=>({...e,disabled:!0}))}},D=n=>{let r=n===`row`,{table:i,map:a}=t,o=r?(0,P.rowIsHeader)(a,i,0):(0,P.columnIsHeader)(a,i,0),s=!1,c=(0,P.toggleHeader)(n);return c(_,e=>{s=e.docChanged}),{label:`${o?`Remove`:`Add`} header ${n}`,icon:r?`panel-top`:`panel-left`,inlineIcon:!r,disabled:!s,run:b(()=>c(_,t=>Q(e,t)))}};return[{label:`Cell alignment`,choices:!0,actions:sn.map(({align:e,icon:t,label:n})=>({label:n,icon:t,checked:C.size===1&&C.has(e),run:b(()=>S(e))}))},E(`row`),E(`column`),{label:`Cells`,actions:T,separate:!0},{label:`Headers`,separate:!0,actions:[D(`row`),D(`column`)]},{separate:!0,actions:[{label:`Delete table`,icon:`grid-2x2-x`,tone:`danger`,run:b(()=>(0,P.deleteTable)(d,t=>Q(e,t)))}]}]}var gn=new M.PluginKey(`tableCellContext`),_n=new WeakMap,$=e=>e.type.spec.tableRole===`table`,vn=e=>e.type.name===`contentBlock`;function yn(e){return e instanceof M.NodeSelection&&$(e.node)||!!(0,P.findTable)(e.$from)||!!(0,P.findTable)(e.$to)}function bn(e,t){let n=e instanceof P.CellSelection?e.$anchorCell:e.$from,r=e instanceof P.CellSelection?e.$headCell:e.$to;return(0,P.findTable)(n)?.pos===t&&(0,P.findTable)(r)?.pos===t}function xn(e,t,n=!1){let{state:r}=e,i=bn(r.selection,t)?r.selection:null,a=M.NodeSelection.create(r.doc,t),o=r.tr.setSelection(a);i&&o.setMeta(gn,i),e.dispatch(n?(0,N.closeHistory)(o):o)}function Sn(e,t){let n=!1;return e.content.descendants(e=>(n||=t(e),!n)),n}function Cn({node:e,isSelected:t,frame:n,onSelect:r,actions:i}){let{disabled:o}=(0,T.useContext)(q),{height:s,width:c}=P.TableMap.get(e),l=`${s} ${s===1?`row`:`rows`}`,u=`${c} ${c===1?`column`:`columns`}`;return a.t(()=>{n.toggleAttribute(`data-selected`,t&&!o)},[o,n,t]),(0,D.jsx)(ge,{kind:`Table`,meta:`${l} · ${u}`,isSelected:t,isDisabled:o,menuLabel:`Table actions`,onSelect:r,actions:i})}var wn=new WeakMap;function Tn(e,t){wn.get(e)?.();let n=()=>{e.removeEventListener(`contextmenu`,r,!0),e.removeEventListener(`pointerdown`,n,!0),e.removeEventListener(`mousedown`,n,!0),e.removeEventListener(`keydown`,i,!0),wn.get(e)===n&&wn.delete(e)},r=e=>{e.preventDefault(),n()},i=e=>{e.key!==t&&n()};e.addEventListener(`contextmenu`,r,!0),e.addEventListener(`pointerdown`,n,!0),e.addEventListener(`mousedown`,n,!0),e.addEventListener(`keydown`,i,!0),wn.set(e,n)}function En(e){if(!e.isEditable)return null;let{selection:t}=e.state,n=t instanceof P.CellSelection?t.$headCell:t.$head,r=t instanceof M.NodeSelection&&$(t.node)?t.from:(0,P.findTable)(n)?.pos,i=r===void 0?null:e.view.nodeDOM(r);return i instanceof HTMLElement?i.querySelector(`.ds-rte__table-bar-host button`):null}var Dn=class extends A.TableView{bar;constructor({editor:e,node:t,view:n,getPos:r,HTMLAttributes:i},a){super(t,a,n,i);let o=this.dom,s=o.ownerDocument;this.dom=s.createElement(`div`),this.dom.className=de,this.dom.dataset.kind=`table`,this.dom.dataset.align=`full`,this.bar=new O.ReactRenderer(Cn,{editor:e,className:`ds-rte__table-bar-host`,props:{node:t,isSelected:!1,frame:this.dom,onSelect:()=>{let e=r();n.editable&&e!==void 0&&(xn(n,e),n.focus())},actions:t=>{let i=r(),{state:a}=n,o=i===void 0?null:a.doc.nodeAt(i);if(i===void 0||!o||!$(o))return[];let s=P.TableMap.get(o);if(!s.map.length)return[];let c=gn.getState(a),l=bn(a.selection,i)?a.selection:c&&bn(c,i)?c:null;return hn(e,{table:o,map:s,pos:i},l,t)}}}),this.bar.element.contentEditable=`false`,this.dom.append(this.bar.element,o),this.bar.element.addEventListener(`dragstart`,e=>{let t=r();n.editable&&t!==void 0&&e.dataTransfer&&e.target instanceof Element&&e.target.closest(`[data-drag-handle]`)&&(xn(n,t,!0),n.state.selection instanceof M.NodeSelection&&_n.set(n,n.state.selection),e.dataTransfer.setDragImage?.(this.dom,12,12))}),this.bar.element.addEventListener(`dragend`,()=>_n.delete(n))}update(e){return super.update(e)?(this.bar.updateProps({node:e}),!0):!1}selectNode(){this.bar.updateProps({isSelected:!0})}deselectNode(){this.bar.updateProps({isSelected:!1})}ignoreMutation(e){return this.bar.element.contains(e.target)||super.ignoreMutation(e)}stopEvent(e){return e.target instanceof Element&&this.bar.element.contains(e.target)&&![`dragstart`,`dragend`].includes(e.type)}destroy(){this.bar.destroy()}},On=W.extend({addNodeView(){return e=>new Dn(e,this.options.cellMinWidth)},addKeyboardShortcuts(){let e=this.parent?.(),t=e=>({editor:t})=>{let n=En(t);return n?(n.click(),Tn(t.view.dom.ownerDocument,e),!0):!1};return{...e,"Shift-F10":t(`F10`),ContextMenu:t(`ContextMenu`),Escape:({editor:e})=>{let t=(0,P.findTable)(e.state.selection.$from);return!e.isEditable||!t?!1:(xn(e.view,t.pos),!0)},Tab:({editor:t})=>{let{selection:n}=t.state;if(t.isEditable&&n instanceof M.NodeSelection&&$(n.node)){let e=En(t);if(e)return e.focus(),!0}return e?.Tab?.({editor:t})??!1}}},addProseMirrorPlugins(){return[new M.Plugin({props:{handlePaste(e,t,n){let{selection:r}=e.state;return(r instanceof P.CellSelection||!!(0,P.cellAround)(r.$from)||!!(0,P.cellAround)(r.$head))&&Sn(n,vn)}}}),...this.parent?.()??[],new M.Plugin({key:gn,state:{init:()=>null,apply(e,t){return e.docChanged||!(e.selection instanceof M.NodeSelection)||!$(e.selection.node)?null:e.getMeta(gn)??(t&&bn(t,e.selection.from)?t:null)}},props:{handleDrop(e,t,n,r){let i=_n.get(e);if(_n.delete(e),r&&i&&(i.$from.doc!==e.state.doc||!i.eq(e.state.selection)))return!0;let a=e.posAtCoords({left:t.clientX,top:t.clientY});if(!a)return!1;let{doc:o}=e.state,s=o.resolve(a.pos);return!!((0,P.cellAround)(s)??(a.inside>=0?(0,P.cellAround)(o.resolve(a.inside+1)):null))&&Sn(n,vn)||!!(0,P.findTable)(s)&&Sn(n,$)},handlePaste:(e,t,n)=>!!(0,P.findTable)(e.state.selection.$from)&&Sn(n,$)}})]}}).configure({allowTableNodeSelection:!0});function kn({editor:e,selection:t,onClose:r}){let[i,a]=(0,T.useState)(t.href),[o,s]=(0,T.useState)(),d=(0,T.useId)();(0,T.useEffect)(()=>{let n=()=>{e.state.doc.eq(t.document)||r()};return e.on(`transaction`,n),()=>{e.off(`transaction`,n)}},[e,t,r]);let f=()=>!e.isDestroyed&&e.isEditable&&e.state.doc.eq(t.document),p=()=>{if(!f()){r();return}let n=i.trim();if(!n||!e.can().setLink({href:n})){s(n?`Enter a valid link URL.`:`Enter a link URL.`);return}let a=e.chain().focus().setTextSelection({from:t.from,to:t.to});t.from===t.to&&!t.isEditing?a.setLink({href:n}).insertContent({type:`text`,text:n,marks:[{type:`link`,attrs:{href:n}}]}).run():a.setLink({href:n}).run(),r()};return(0,D.jsx)(l.Modal,{isOpen:!0,title:t.isEditing?`Edit link`:`Add link`,size:`dialog`,onClose:r,footer:(0,D.jsxs)(D.Fragment,{children:[t.isEditing&&(0,D.jsx)(n.Button,{variant:`danger`,onClick:()=>{f()&&e.chain().focus().setTextSelection({from:t.from,to:t.to}).unsetLink().run(),r()},children:`Remove link`}),(0,D.jsx)(n.Button,{onClick:r,children:`Cancel`}),(0,D.jsx)(n.Button,{variant:`primary`,type:`submit`,form:d,children:`Save`})]}),children:(0,D.jsx)(`form`,{id:d,noValidate:!0,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),p()},children:(0,D.jsx)(c.Field,{label:`URL`,isRequired:!0,error:o,children:e=>(0,D.jsx)(u.TextField,{...e,value:i,inputMode:`url`,autoComplete:`url`,placeholder:`https://example.com`,onChange:e=>{a(e.target.value),s(void 0)}})})})})}var An=[[{id:`bold`,icon:`bold`,label:`Bold`,run:e=>e.chain().focus().toggleBold().run(),active:e=>e.isActive(`bold`)},{id:`italic`,icon:`italic`,label:`Italic`,run:e=>e.chain().focus().toggleItalic().run(),active:e=>e.isActive(`italic`)},{id:`strike`,icon:`strikethrough`,label:`Strikethrough`,run:e=>e.chain().focus().toggleStrike().run(),active:e=>e.isActive(`strike`)},{id:`code`,icon:`code`,label:`Inline code`,run:e=>e.chain().focus().toggleCode().run(),active:e=>e.isActive(`code`)}],[{id:`h2`,icon:`heading-2`,label:`Heading`,run:e=>e.chain().focus().toggleHeading({level:2}).run(),active:e=>e.isActive(`heading`,{level:2})},{id:`h3`,icon:`heading-3`,label:`Subheading`,run:e=>e.chain().focus().toggleHeading({level:3}).run(),active:e=>e.isActive(`heading`,{level:3})},{id:`quote`,icon:`quote`,label:`Quote`,run:e=>e.chain().focus().toggleBlockquote().run(),active:e=>e.isActive(`blockquote`)}],[{id:`ul`,icon:`list`,label:`Bulleted list`,run:e=>e.chain().focus().toggleBulletList().run(),active:e=>e.isActive(`bulletList`)},{id:`ol`,icon:`list-ordered`,label:`Numbered list`,run:e=>e.chain().focus().toggleOrderedList().run(),active:e=>e.isActive(`orderedList`)}],[{id:`undo`,icon:`undo`,label:`Undo`,run:e=>e.chain().focus().undo().run()},{id:`redo`,icon:`redo`,label:`Redo`,run:e=>e.chain().focus().redo().run()}]];function jn({editor:e,state:t,disabled:r,label:i,toolbarExtra:a,openLink:s,expandControl:c,embedControl:l,tables:u}){return(0,D.jsxs)(`div`,{className:`ds-rte__toolbar ds-field-surface`,role:`toolbar`,"aria-label":`${i} formatting`,children:[An.map((i,a)=>(0,D.jsx)(o.ButtonGroup,{"aria-label":`Formatting ${a+1}`,children:i.map(i=>(0,D.jsx)(n.Button,{size:`sm`,isIconOnly:!0,iconStart:i.icon,"aria-label":i.label,title:i.label,"aria-pressed":i.active?t?.active[i.id]:void 0,variant:t?.active[i.id]?`primary`:`neutral`,isDisabled:r||!e,onClick:()=>e&&i.run(e)},i.id))},a)),(0,D.jsx)(o.ButtonGroup,{"aria-label":`Link`,children:(0,D.jsx)(n.Button,{size:`sm`,isIconOnly:!0,iconStart:`link`,"aria-label":t?.linkActive?`Edit link`:`Add link`,title:t?.linkActive?`Edit link`:`Add link`,variant:t?.linkActive?`primary`:`neutral`,isDisabled:r||!e,onClick:()=>e&&s(e.state,e.isActive(`link`)?e.state.selection.from:void 0)})}),u&&(0,D.jsx)($t,{editor:e,disabled:r,inTable:t?.tableActive??!1}),l,a,c]})}var Mn=(0,T.forwardRef)(function({scopeRef:e,className:t,expansion:n,isFocused:r,disabled:a,invalid:o,contentError:s,errorId:c,surface:l,children:u},d){return(0,D.jsx)(i.s.Provider,{value:e,children:(0,D.jsxs)(`div`,{ref:d,className:[`ds-rte`,t].filter(Boolean).join(` `),style:n.frameStyle,"data-expanded":n.expanded||void 0,"data-focused":r&&!n.expanded||void 0,"data-disabled":a||void 0,"data-invalid":o||void 0,"aria-invalid":o||void 0,children:[s&&(0,D.jsx)(`p`,{id:c,role:`alert`,className:`ds-field__error`,children:s}),n.expanded&&(0,D.jsx)(`p`,{className:`ds-rte__placeholder`,children:`Editing in expanded view. Press Esc to return.`}),n.surfaceSlot((0,D.jsx)(`div`,{className:`ds-rte__surface`,hidden:!!s,"data-expanded":n.expanded||void 0,"data-focused":r||void 0,"data-disabled":a||void 0,"data-invalid":o||void 0,children:l})),n.dialog,u]})})}),Nn=V.extend({addNodeView(){return(0,O.ReactNodeViewRenderer)(Se,{update:({oldNode:e,newNode:t,updateProps:n})=>e.attrs.type===t.attrs.type&&(e!==t&&n(),!0)})}});function Pn(e,t){return t.key!==`Escape`||t.isComposing?!1:(e.someProp(`handleKeyDown`,n=>n(e,t))&&t.preventDefault(),!0)}function Fn(e,{format:t,value:n},r,i,a){if(n===void 0&&e&&!e.isDestroyed)return t===`json`?ue(r,{tables:i})?void 0:B(e.getJSON()):i||a?e.getHTML():void 0}var In=(0,T.forwardRef)(function(e,t){let{placeholder:n=`Write something…`,size:i=`md`,expandedWidth:a=`wide`,isDisabled:o=!1,isInvalid:s=!1,label:c=`Rich text editor`,className:l,toolbarExtra:u,tables:d=!0,id:f,isRequired:p,required:m,"aria-label":h,"aria-labelledby":g,"aria-describedby":_,"aria-invalid":v}=e,y=(0,T.useRef)(null),b=(0,T.useMemo)(()=>r.t(y,t),[t]),[x,S]=(0,T.useState)(!1),[C,w]=(0,T.useState)(null),E=(0,T.useCallback)(()=>w(null),[]),[ee,te]=(0,T.useState)(()=>e.defaultValue??(e.format===`json`?H:``)),[A,j]=(0,T.useState)(!1),M=e.value===void 0?ee:e.value,N=(0,T.useMemo)(()=>e.format===`json`?ue(M,{tables:d}):void 0,[e.format,M,d]),P=(0,T.useId)(),F=s||!!N||v,I=o||!!N;I&&C&&w(null);let L=(0,T.useCallback)((e,t)=>{if(I)return;let n=t===void 0?void 0:(0,O.getMarkRange)(e.doc.resolve(t),e.schema.marks.link),r=n&&e.doc.nodeAt(n.from)?.marks.find(t=>t.type===e.schema.marks.link);w({from:n?.from??e.selection.from,to:n?.to??e.selection.to,href:r?.attrs.href??``,isEditing:!!r,document:e.doc})},[I]),R=(0,T.useMemo)(()=>({role:`textbox`,...g?{}:{"aria-label":h??c},"aria-multiline":`true`,...f?{id:f}:{},...g?{"aria-labelledby":g}:{},..._?{"aria-describedby":_}:{},...F?{"aria-invalid":String(F)}:{},...p||m?{"aria-required":`true`}:{}}),[c,h,f,g,_,F,p,m]),z=(0,T.useMemo)(()=>({attributes:R,handleDOMEvents:{keydown:Pn,click:(e,t)=>{let n=t.target instanceof Element?t.target.closest(`a`):null;return!n||!e.dom.contains(n)?!1:(t.preventDefault(),e.editable&&L(e.state,e.posAtDOM(n,0)),!0)}}}),[R,L]),re=(0,T.useMemo)(()=>[...ce(Nn,{tables:d},On),k.Placeholder.configure({placeholder:n})],[n,d]),ie=(0,T.useMemo)(()=>N?H:typeof M==`string`?M:G(M),[M,N]),V=(0,O.useEditor)({immediatelyRender:!1,editable:!I,content:ie,extensions:re,editorProps:z,onFocus:()=>S(!0),onBlur:()=>S(!1),onUpdate:({editor:t,transaction:n})=>{(!I||n.getMeta(`ds-rte-embed-commit`))&&(e.format===`json`?e.onChange?.(B(t.getJSON())):(e.value===void 0&&!t.schema.nodes.table&&j(!0),e.onChange?.(t.getHTML())))}},[d]),[U,ae]=(0,T.useState)(d);if(U!==d){ae(d),S(!1),j(!1);let t=Fn(V,e,M,U,A);t!==void 0&&te(t)}(0,T.useEffect)(()=>{V&&!V.isDestroyed&&(V.setEditable(!I,!1),V.setOptions({editorProps:z}))},[V,I,z]),(0,T.useEffect)(()=>{if(!V||V.isDestroyed||e.value===void 0||N)return;let t=typeof e.value==`string`?(0,O.createDocument)(e.value,V.schema):V.schema.nodeFromJSON(G(e.value));t.eq(V.state.doc)||V.commands.setContent(t,{emitUpdate:!1})},[V,e.value,N]);let oe=(0,O.useEditorState)({editor:V,selector:({editor:e})=>e?{active:Object.fromEntries(An.flat().map(t=>[t.id,t.active?.(e)??!1])),linkActive:e.isActive(`link`),tableActive:yn(e.state.selection)}:null}),W=Ve(V,N?void 0:e.embeds,I,c),se=ne({editor:V,disabled:I,isHeld:W.isCreating,invalid:!!F,label:h??c,labelledBy:g,expandedWidth:a,frameRef:y});return(0,D.jsx)(q.Provider,{value:W.context,children:(0,D.jsxs)(Mn,{ref:b,scopeRef:y,className:l,expansion:se,isFocused:x,disabled:I,invalid:!!F,contentError:N,errorId:P,surface:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(jn,{editor:V,state:oe,disabled:I,label:c,toolbarExtra:u,openLink:L,expandControl:se.toggle,embedControl:W.toolbar,tables:d}),(0,D.jsx)(`div`,{className:`ds-rte__content ds-field-surface`,"data-size":i,children:(0,D.jsx)(O.EditorContent,{editor:V})})]}),children:[W.dialog,V&&C&&!I&&(0,D.jsx)(kn,{editor:V,selection:C,onClose:E})]})})});Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return In}});
2
+ //# sourceMappingURL=RichTextEditor-BgfeOrEe.cjs.map