@vespercms/admin 0.0.0-stage → 0.1.0-next.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 (203) hide show
  1. package/README.md +119 -2
  2. package/dist/BodyEditor-CAGNfofv.js +3047 -0
  3. package/dist/a11y/FieldNotes.d.ts +23 -0
  4. package/dist/a11y/NotesDrawer.d.ts +23 -0
  5. package/dist/a11y/pdf.d.ts +3 -0
  6. package/dist/a11y/run.d.ts +3 -0
  7. package/dist/a11y/useNotes.d.ts +28 -0
  8. package/dist/app/App.d.ts +2 -0
  9. package/dist/app/Screen.d.ts +88 -0
  10. package/dist/app/UserMenu.d.ts +7 -0
  11. package/dist/app/api.d.ts +75 -0
  12. package/dist/app/appearance.d.ts +10 -0
  13. package/dist/app/browser-api.d.ts +17 -0
  14. package/dist/app/collection-icon.d.ts +12 -0
  15. package/dist/app/context.d.ts +23 -0
  16. package/dist/app/entries-changed.d.ts +11 -0
  17. package/dist/app/file-url.d.ts +13 -0
  18. package/dist/app/format.d.ts +4 -0
  19. package/dist/app/idb.d.ts +7 -0
  20. package/dist/app/load.d.ts +16 -0
  21. package/dist/app/media.d.ts +5 -0
  22. package/dist/app/navigation.d.ts +4 -0
  23. package/dist/app/pane-context.d.ts +19 -0
  24. package/dist/app/panes.d.ts +14 -0
  25. package/dist/app/router.d.ts +62 -0
  26. package/dist/body/BodyEditor.d.ts +42 -0
  27. package/dist/body/TableView.d.ts +2 -0
  28. package/dist/body/catalog.d.ts +47 -0
  29. package/dist/body/checks.d.ts +15 -0
  30. package/dist/body/chips.d.ts +31 -0
  31. package/dist/body/commands.d.ts +31 -0
  32. package/dist/body/document.d.ts +42 -0
  33. package/dist/body/insert.d.ts +69 -0
  34. package/dist/body/nodes.d.ts +38 -0
  35. package/dist/body/reveal.d.ts +13 -0
  36. package/dist/body/scroll.d.ts +16 -0
  37. package/dist/body/settings.d.ts +19 -0
  38. package/dist/body/shortcuts.d.ts +13 -0
  39. package/dist/body/table.d.ts +31 -0
  40. package/dist/body/ui.d.ts +30 -0
  41. package/dist/body/views.d.ts +9 -0
  42. package/dist/checks-C-0xDu-I.js +57 -0
  43. package/dist/cloud/CloudGate.d.ts +14 -0
  44. package/dist/cloud/access.d.ts +14 -0
  45. package/dist/cloud/changes.d.ts +26 -0
  46. package/dist/cloud/connection.d.ts +100 -0
  47. package/dist/cloud/editor.d.ts +44 -0
  48. package/dist/cloud/session.d.ts +62 -0
  49. package/dist/cloud/storage.d.ts +45 -0
  50. package/dist/editor/Field.d.ts +24 -0
  51. package/dist/editor/PagePicker.d.ts +20 -0
  52. package/dist/editor/arrange.d.ts +13 -0
  53. package/dist/editor/context.d.ts +23 -0
  54. package/dist/editor/copy.d.ts +9 -0
  55. package/dist/editor/reveal.d.ts +7 -0
  56. package/dist/editor/target.d.ts +21 -0
  57. package/dist/editor/values.d.ts +18 -0
  58. package/dist/geo-map-CT3OGD7O.js +110 -0
  59. package/dist/github/GitHubGate.d.ts +15 -0
  60. package/dist/github/api.d.ts +20 -0
  61. package/dist/github/cache.d.ts +2 -0
  62. package/dist/github/session.d.ts +35 -0
  63. package/dist/index.d.ts +3 -0
  64. package/dist/markdown-KUkv11EB.js +211 -0
  65. package/dist/media/MediaPicker.d.ts +28 -0
  66. package/dist/media/file-icon.d.ts +3 -0
  67. package/dist/media/formats.d.ts +23 -0
  68. package/dist/media/hygiene.d.ts +37 -0
  69. package/dist/media/upload.d.ts +31 -0
  70. package/dist/mount.d.ts +3 -0
  71. package/dist/pdf-m5s_uXJ3.js +24 -0
  72. package/dist/run-y4XRkg17.js +7 -0
  73. package/dist/schedule/ScheduleDialog.d.ts +28 -0
  74. package/dist/schedule/ScheduleSummary.d.ts +12 -0
  75. package/dist/schedule/ScheduledView.d.ts +8 -0
  76. package/dist/schedule/cloud.d.ts +21 -0
  77. package/dist/schedule/now.d.ts +5 -0
  78. package/dist/schedule/times.d.ts +37 -0
  79. package/dist/screens/EntryEditor.d.ts +13 -0
  80. package/dist/screens/EntryList.d.ts +18 -0
  81. package/dist/screens/Home.d.ts +6 -0
  82. package/dist/screens/ListPane.d.ts +6 -0
  83. package/dist/screens/MediaBrowser.d.ts +7 -0
  84. package/dist/screens/NotFound.d.ts +3 -0
  85. package/dist/screens/PageTree.d.ts +10 -0
  86. package/dist/screens/Redirects.d.ts +1 -0
  87. package/dist/screens/Unavailable.d.ts +8 -0
  88. package/dist/shortcuts-B_JMAvF9.js +4630 -0
  89. package/dist/studio.css +3 -0
  90. package/dist/studio.js +6312 -0
  91. package/dist/types.d.ts +76 -0
  92. package/dist/widgets/basic.d.ts +25 -0
  93. package/dist/widgets/crops.d.ts +43 -0
  94. package/dist/widgets/focal-point.d.ts +15 -0
  95. package/dist/widgets/geo-map.d.ts +10 -0
  96. package/dist/widgets/geo.d.ts +16 -0
  97. package/dist/widgets/group.d.ts +41 -0
  98. package/dist/widgets/icon.d.ts +9 -0
  99. package/dist/widgets/image.d.ts +16 -0
  100. package/dist/widgets/markdown-lazy.d.ts +2 -0
  101. package/dist/widgets/markdown.d.ts +2 -0
  102. package/dist/widgets/reference.d.ts +12 -0
  103. package/dist/widgets/registry.d.ts +32 -0
  104. package/dist/widgets/special.d.ts +20 -0
  105. package/dist/widgets/union.d.ts +36 -0
  106. package/package.json +63 -4
  107. package/src/a11y/FieldNotes.tsx +56 -0
  108. package/src/a11y/NotesDrawer.tsx +81 -0
  109. package/src/a11y/pdf.ts +45 -0
  110. package/src/a11y/run.ts +12 -0
  111. package/src/a11y/useNotes.ts +139 -0
  112. package/src/app/App.tsx +156 -0
  113. package/src/app/Screen.tsx +416 -0
  114. package/src/app/UserMenu.tsx +95 -0
  115. package/src/app/api.ts +176 -0
  116. package/src/app/appearance.ts +54 -0
  117. package/src/app/browser-api.ts +173 -0
  118. package/src/app/collection-icon.ts +15 -0
  119. package/src/app/context.tsx +32 -0
  120. package/src/app/entries-changed.ts +48 -0
  121. package/src/app/file-url.tsx +44 -0
  122. package/src/app/format.ts +39 -0
  123. package/src/app/idb.ts +82 -0
  124. package/src/app/load.ts +40 -0
  125. package/src/app/media.ts +20 -0
  126. package/src/app/navigation.ts +4 -0
  127. package/src/app/pane-context.ts +25 -0
  128. package/src/app/panes.tsx +513 -0
  129. package/src/app/router.ts +158 -0
  130. package/src/body/BodyEditor.tsx +1139 -0
  131. package/src/body/TableView.tsx +700 -0
  132. package/src/body/catalog.ts +198 -0
  133. package/src/body/checks.ts +83 -0
  134. package/src/body/chips.ts +150 -0
  135. package/src/body/commands.ts +191 -0
  136. package/src/body/document.ts +388 -0
  137. package/src/body/insert.tsx +301 -0
  138. package/src/body/nodes.ts +287 -0
  139. package/src/body/reveal.ts +93 -0
  140. package/src/body/scroll.ts +53 -0
  141. package/src/body/settings.tsx +510 -0
  142. package/src/body/shortcuts.ts +31 -0
  143. package/src/body/table.ts +192 -0
  144. package/src/body/ui.ts +77 -0
  145. package/src/body/views.tsx +268 -0
  146. package/src/build.ts +6 -0
  147. package/src/cloud/CloudGate.tsx +245 -0
  148. package/src/cloud/access.ts +52 -0
  149. package/src/cloud/changes.tsx +474 -0
  150. package/src/cloud/connection.ts +281 -0
  151. package/src/cloud/editor.tsx +250 -0
  152. package/src/cloud/session.ts +289 -0
  153. package/src/cloud/storage.ts +212 -0
  154. package/src/editor/Field.tsx +182 -0
  155. package/src/editor/PagePicker.tsx +102 -0
  156. package/src/editor/arrange.ts +98 -0
  157. package/src/editor/context.tsx +31 -0
  158. package/src/editor/copy.ts +30 -0
  159. package/src/editor/reveal.ts +38 -0
  160. package/src/editor/target.ts +104 -0
  161. package/src/editor/values.ts +71 -0
  162. package/src/github/GitHubGate.tsx +261 -0
  163. package/src/github/api.ts +81 -0
  164. package/src/github/cache.ts +64 -0
  165. package/src/github/session.ts +146 -0
  166. package/src/index.ts +10 -0
  167. package/src/media/MediaPicker.tsx +302 -0
  168. package/src/media/file-icon.ts +17 -0
  169. package/src/media/formats.ts +262 -0
  170. package/src/media/hygiene.ts +220 -0
  171. package/src/media/upload.ts +47 -0
  172. package/src/mount.tsx +20 -0
  173. package/src/schedule/ScheduleDialog.tsx +300 -0
  174. package/src/schedule/ScheduleSummary.tsx +59 -0
  175. package/src/schedule/ScheduledView.tsx +294 -0
  176. package/src/schedule/cloud.ts +66 -0
  177. package/src/schedule/now.ts +18 -0
  178. package/src/schedule/times.ts +133 -0
  179. package/src/screens/EntryEditor.tsx +1803 -0
  180. package/src/screens/EntryList.tsx +274 -0
  181. package/src/screens/Home.tsx +131 -0
  182. package/src/screens/ListPane.tsx +459 -0
  183. package/src/screens/MediaBrowser.tsx +253 -0
  184. package/src/screens/NotFound.tsx +19 -0
  185. package/src/screens/PageTree.tsx +718 -0
  186. package/src/screens/Redirects.tsx +522 -0
  187. package/src/screens/Unavailable.tsx +27 -0
  188. package/src/studio.css +163 -0
  189. package/src/types.ts +82 -0
  190. package/src/widgets/basic.tsx +311 -0
  191. package/src/widgets/crops.tsx +399 -0
  192. package/src/widgets/focal-point.tsx +240 -0
  193. package/src/widgets/geo-map.tsx +160 -0
  194. package/src/widgets/geo.tsx +170 -0
  195. package/src/widgets/group.tsx +827 -0
  196. package/src/widgets/icon.tsx +47 -0
  197. package/src/widgets/image.tsx +407 -0
  198. package/src/widgets/markdown-lazy.tsx +22 -0
  199. package/src/widgets/markdown.tsx +267 -0
  200. package/src/widgets/reference.tsx +196 -0
  201. package/src/widgets/registry.ts +104 -0
  202. package/src/widgets/special.tsx +286 -0
  203. package/src/widgets/union.tsx +233 -0
@@ -0,0 +1,4630 @@
1
+ import { Component as e, Suspense as t, createContext as n, createElement as r, lazy as i, useCallback as a, useContext as o, useEffect as s, useLayoutEffect as c, useMemo as l, useRef as u, useState as d } from "react";
2
+ import { Button as f, Cell as p, CheckboxButton as m, CheckboxField as h, Collection as g, Column as _, ComboBox as v, Dialog as y, Disclosure as b, DisclosurePanel as x, FieldError as S, FileTrigger as C, Header as w, Heading as T, Input as E, Label as D, Link as ee, ListBox as O, ListBoxItem as k, Menu as te, MenuItem as A, MenuSection as j, MenuTrigger as ne, Modal as M, ModalOverlay as N, Popover as P, RadioButton as F, RadioField as re, RadioGroup as I, Row as ie, Select as ae, SelectValue as oe, Separator as se, SubmenuTrigger as ce, SwitchButton as le, SwitchField as ue, Tab as de, TabList as fe, TabPanel as pe, Table as me, TableBody as he, TableHeader as ge, Tabs as _e, Tag as ve, TagGroup as ye, TagList as be, Text as xe, TextArea as Se, TextField as Ce, ToggleButton as we, Toolbar as Te, Tooltip as Ee, TooltipTrigger as De, Tree as Oe, TreeItem as ke, TreeItemContent as Ae, useDrag as je, useDragAndDrop as Me, useDrop as Ne } from "react-aria-components";
3
+ import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
4
+ import { CENTER as Pe, UPLOAD_MAX_BYTES as Fe, UPLOAD_WARN_BYTES as Ie, cropForRatio as Le, dirOf as Re, dragCorner as ze, extensionOf as Be, formatYamlSnippet as Ve, fromWallTime as He, gitBlobSha as Ue, humanize as We, imageValueOf as Ge, isImagePath as Ke, isPlainObject as B, isoWithOffset as qe, mediaReference as Je, moveRect as Ye, offsetOf as Xe, parseYamlSnippet as Ze, ratioLabel as Qe, resizeRect as $e, resolveMediaPath as et, resolveTimeZone as tt, roundFocus as nt, roundRect as rt, siteRatios as it, slugify as at, variantFor as ot, wallTime as st, zoneName as ct } from "@vespercms/core";
5
+ import lt from "dompurify";
6
+ //#region ../../node_modules/lucide/dist/esm/icons/accessibility.mjs
7
+ var ut = [
8
+ ["circle", {
9
+ cx: "16",
10
+ cy: "4",
11
+ r: "1"
12
+ }],
13
+ ["path", { d: "m18 19 1-7-6 1" }],
14
+ ["path", { d: "m5 8 3-3 5.5 3-2.36 3.5" }],
15
+ ["path", { d: "M4.24 14.5a5 5 0 0 0 6.88 6" }],
16
+ ["path", { d: "M13.76 17.5a5 5 0 0 0-6.88-6" }]
17
+ ], dt = [["path", { d: "M12 5v14" }], ["path", { d: "m19 12-7 7-7-7" }]], ft = [["path", { d: "m12 19-7-7 7-7" }], ["path", { d: "M19 12H5" }]], pt = [
18
+ ["path", { d: "m16 3 4 4-4 4" }],
19
+ ["path", { d: "M20 7H4" }],
20
+ ["path", { d: "m8 21-4-4 4-4" }],
21
+ ["path", { d: "M4 17h16" }]
22
+ ], mt = [["path", { d: "m5 12 7-7 7 7" }], ["path", { d: "M12 19V5" }]], ht = [["path", { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" }]], gt = [
23
+ ["path", { d: "M16 14v2.2l1.6 1" }],
24
+ ["path", { d: "M16 2v3" }],
25
+ ["path", { d: "M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338" }],
26
+ ["path", { d: "M3 9h5.859" }],
27
+ ["path", { d: "M8 2v3" }],
28
+ ["circle", {
29
+ cx: "16",
30
+ cy: "16",
31
+ r: "6"
32
+ }]
33
+ ], _t = [
34
+ ["path", { d: "M8 2v3" }],
35
+ ["path", { d: "M16 2v3" }],
36
+ ["rect", {
37
+ x: "3",
38
+ y: "3",
39
+ width: "18",
40
+ height: "18",
41
+ rx: "2"
42
+ }],
43
+ ["path", { d: "M3 9h18" }],
44
+ ["path", { d: "m14 13-4 4" }],
45
+ ["path", { d: "m10 13 4 4" }]
46
+ ], vt = [["path", { d: "M20 6 9 17l-5-5" }]], yt = [["path", { d: "m6 9 6 6 6-6" }]], bt = [
47
+ ["circle", {
48
+ cx: "12",
49
+ cy: "12",
50
+ r: "10"
51
+ }],
52
+ ["line", {
53
+ x1: "12",
54
+ x2: "12",
55
+ y1: "8",
56
+ y2: "12"
57
+ }],
58
+ ["line", {
59
+ x1: "12",
60
+ x2: "12.01",
61
+ y1: "16",
62
+ y2: "16"
63
+ }]
64
+ ], xt = [["path", { d: "m16 18 6-6-6-6" }], ["path", { d: "m8 6-6 6 6 6" }]], St = [["rect", {
65
+ width: "14",
66
+ height: "14",
67
+ x: "8",
68
+ y: "8",
69
+ rx: "2",
70
+ ry: "2"
71
+ }], ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }]], Ct = [
72
+ ["circle", {
73
+ cx: "12",
74
+ cy: "12",
75
+ r: "1"
76
+ }],
77
+ ["circle", {
78
+ cx: "19",
79
+ cy: "12",
80
+ r: "1"
81
+ }],
82
+ ["circle", {
83
+ cx: "5",
84
+ cy: "12",
85
+ r: "1"
86
+ }]
87
+ ], wt = [
88
+ ["path", { d: "M15 3h6v6" }],
89
+ ["path", { d: "M10 14 21 3" }],
90
+ ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }]
91
+ ], Tt = [
92
+ ["path", { d: "M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5" }],
93
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
94
+ ["path", { d: "M8 12v-1" }],
95
+ ["path", { d: "M8 18v-2" }],
96
+ ["path", { d: "M8 7V6" }],
97
+ ["circle", {
98
+ cx: "8",
99
+ cy: "20",
100
+ r: "2"
101
+ }]
102
+ ], Et = [
103
+ ["path", { d: "M11.65 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v10.35" }],
104
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
105
+ ["path", { d: "M8 20v-7l3 1.474" }],
106
+ ["circle", {
107
+ cx: "6",
108
+ cy: "20",
109
+ r: "2"
110
+ }]
111
+ ], Dt = [
112
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
113
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
114
+ ["path", { d: "M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z" }]
115
+ ], Ot = [
116
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
117
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
118
+ ["path", { d: "M9 15h6" }],
119
+ ["path", { d: "M12 18v-6" }]
120
+ ], kt = [
121
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
122
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
123
+ ["path", { d: "M8 13h2" }],
124
+ ["path", { d: "M14 13h2" }],
125
+ ["path", { d: "M8 17h2" }],
126
+ ["path", { d: "M14 17h2" }]
127
+ ], At = [
128
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
129
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
130
+ ["path", { d: "M10 9H8" }],
131
+ ["path", { d: "M16 13H8" }],
132
+ ["path", { d: "M16 17H8" }]
133
+ ], jt = [
134
+ ["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }],
135
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }],
136
+ ["path", { d: "M12 12v6" }],
137
+ ["path", { d: "m15 15-3-3-3 3" }]
138
+ ], Mt = [["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }], ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }]], Nt = [
139
+ ["path", { d: "M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1" }],
140
+ ["path", { d: "M2 13h10" }],
141
+ ["path", { d: "m9 16 3-3-3-3" }]
142
+ ], Pt = [
143
+ ["path", { d: "M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z" }],
144
+ ["path", { d: "M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z" }],
145
+ ["path", { d: "M3 5a2 2 0 0 0 2 2h3" }],
146
+ ["path", { d: "M3 3v13a2 2 0 0 0 2 2h3" }]
147
+ ], Ft = [
148
+ ["circle", {
149
+ cx: "9",
150
+ cy: "12",
151
+ r: "1"
152
+ }],
153
+ ["circle", {
154
+ cx: "9",
155
+ cy: "5",
156
+ r: "1"
157
+ }],
158
+ ["circle", {
159
+ cx: "9",
160
+ cy: "19",
161
+ r: "1"
162
+ }],
163
+ ["circle", {
164
+ cx: "15",
165
+ cy: "12",
166
+ r: "1"
167
+ }],
168
+ ["circle", {
169
+ cx: "15",
170
+ cy: "5",
171
+ r: "1"
172
+ }],
173
+ ["circle", {
174
+ cx: "15",
175
+ cy: "19",
176
+ r: "1"
177
+ }]
178
+ ], It = [
179
+ ["rect", {
180
+ width: "18",
181
+ height: "18",
182
+ x: "3",
183
+ y: "3",
184
+ rx: "2",
185
+ ry: "2"
186
+ }],
187
+ ["circle", {
188
+ cx: "9",
189
+ cy: "9",
190
+ r: "2"
191
+ }],
192
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]
193
+ ], Lt = [
194
+ ["path", { d: "M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21" }],
195
+ ["path", { d: "m14 19.5 3-3 3 3" }],
196
+ ["path", { d: "M17 22v-5.5" }],
197
+ ["circle", {
198
+ cx: "9",
199
+ cy: "9",
200
+ r: "2"
201
+ }]
202
+ ], Rt = [
203
+ ["path", { d: "m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16" }],
204
+ ["path", { d: "M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2" }],
205
+ ["circle", {
206
+ cx: "13",
207
+ cy: "7",
208
+ r: "1",
209
+ fill: "currentColor"
210
+ }],
211
+ ["rect", {
212
+ x: "8",
213
+ y: "2",
214
+ width: "14",
215
+ height: "14",
216
+ rx: "2"
217
+ }]
218
+ ], zt = [
219
+ ["line", {
220
+ x1: "19",
221
+ x2: "10",
222
+ y1: "4",
223
+ y2: "4"
224
+ }],
225
+ ["line", {
226
+ x1: "14",
227
+ x2: "5",
228
+ y1: "20",
229
+ y2: "20"
230
+ }],
231
+ ["line", {
232
+ x1: "15",
233
+ x2: "9",
234
+ y1: "4",
235
+ y2: "20"
236
+ }]
237
+ ], Bt = [["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }], ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]], Vt = [
238
+ ["path", { d: "M11 5h10" }],
239
+ ["path", { d: "M11 12h10" }],
240
+ ["path", { d: "M11 19h10" }],
241
+ ["path", { d: "M4 4h1v5" }],
242
+ ["path", { d: "M4 9h2" }],
243
+ ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" }]
244
+ ], Ht = [
245
+ ["path", { d: "M3 5h.01" }],
246
+ ["path", { d: "M3 12h.01" }],
247
+ ["path", { d: "M3 19h.01" }],
248
+ ["path", { d: "M8 5h13" }],
249
+ ["path", { d: "M8 12h13" }],
250
+ ["path", { d: "M8 19h13" }]
251
+ ], Ut = [
252
+ ["rect", {
253
+ width: "18",
254
+ height: "18",
255
+ x: "3",
256
+ y: "3",
257
+ rx: "2"
258
+ }],
259
+ ["path", { d: "M9 3v18" }],
260
+ ["path", { d: "m16 15-3-3 3-3" }]
261
+ ], Wt = [
262
+ ["rect", {
263
+ width: "18",
264
+ height: "18",
265
+ x: "3",
266
+ y: "3",
267
+ rx: "2"
268
+ }],
269
+ ["path", { d: "M9 3v18" }],
270
+ ["path", { d: "m14 9 3 3-3 3" }]
271
+ ], Gt = [["rect", {
272
+ width: "18",
273
+ height: "18",
274
+ x: "3",
275
+ y: "3",
276
+ rx: "2"
277
+ }], ["path", { d: "M9 3v18" }]], Kt = [["path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }], ["path", { d: "m15 5 4 4" }]], qt = [["path", { d: "M5 12h14" }], ["path", { d: "M12 5v14" }]], Jt = [["path", { d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }], ["path", { d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z" }]], Yt = [
278
+ ["path", { d: "M14 4a1 1 0 0 1 1-1" }],
279
+ ["path", { d: "M15 10a1 1 0 0 1-1-1" }],
280
+ ["path", { d: "M21 4a1 1 0 0 0-1-1" }],
281
+ ["path", { d: "M21 9a1 1 0 0 1-1 1" }],
282
+ ["path", { d: "m3 7 3 3 3-3" }],
283
+ ["path", { d: "M6 10V5a2 2 0 0 1 2-2h2" }],
284
+ ["rect", {
285
+ x: "3",
286
+ y: "14",
287
+ width: "7",
288
+ height: "7",
289
+ rx: "1"
290
+ }]
291
+ ], Xt = [["path", { d: "m21 21-4.34-4.34" }], ["circle", {
292
+ cx: "11",
293
+ cy: "11",
294
+ r: "8"
295
+ }]], Zt = [["path", { d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z" }], ["path", { d: "m21.854 2.147-10.94 10.939" }]], Qt = [
296
+ ["path", { d: "M10 5H3" }],
297
+ ["path", { d: "M12 19H3" }],
298
+ ["path", { d: "M14 3v4" }],
299
+ ["path", { d: "M16 17v4" }],
300
+ ["path", { d: "M21 12h-9" }],
301
+ ["path", { d: "M21 19h-5" }],
302
+ ["path", { d: "M21 5h-7" }],
303
+ ["path", { d: "M8 10v4" }],
304
+ ["path", { d: "M8 12H3" }]
305
+ ], $t = [["path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }], ["path", { d: "M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z" }]], en = [
306
+ ["path", { d: "M10 11v6" }],
307
+ ["path", { d: "M14 11v6" }],
308
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }],
309
+ ["path", { d: "M3 6h18" }],
310
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }]
311
+ ], tn = [
312
+ ["path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }],
313
+ ["path", { d: "M12 9v4" }],
314
+ ["path", { d: "M12 17h.01" }]
315
+ ], nn = [
316
+ ["path", { d: "M12 3v12" }],
317
+ ["path", { d: "m17 8-5-5-5 5" }],
318
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }]
319
+ ], rn = [["path", { d: "M18 6 6 18" }], ["path", { d: "m6 6 12 12" }]];
320
+ //#endregion
321
+ //#region ../ui/src/components/shared.tsx
322
+ function V(...e) {
323
+ return e.filter(Boolean).join(" ");
324
+ }
325
+ var H = V("outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-focus", "data-[focus-visible]:ring-6 data-[focus-visible]:ring-(color:--glow-focus)"), U = "transition-[color,background-color,border-color] duration-120 ease-out", an = V("min-h-10 w-full rounded-md border border-border-strong bg-surface-sunken px-3 py-2 text-body text-content", "outline-none data-[focused]:outline-2 data-[focused]:outline-solid data-[focused]:outline-offset-2 data-[focused]:outline-focus", "data-[focused]:ring-6 data-[focused]:ring-(color:--glow-focus)", "data-[invalid]:border-danger data-[disabled]:opacity-60");
326
+ function on({ label: e, isOptional: t }) {
327
+ return e ? /* @__PURE__ */ z(D, {
328
+ className: "block text-label text-content",
329
+ children: [e, t && /* @__PURE__ */ R(sn, {})]
330
+ }) : null;
331
+ }
332
+ function sn() {
333
+ return /* @__PURE__ */ z(L, { children: [" ", /* @__PURE__ */ R("span", {
334
+ className: "font-normal text-content-muted",
335
+ children: "(optional)"
336
+ })] });
337
+ }
338
+ function W({ description: e, errorMessage: t }) {
339
+ return /* @__PURE__ */ z(L, { children: [e && /* @__PURE__ */ R(xe, {
340
+ slot: "description",
341
+ className: "block text-small text-content-muted",
342
+ children: e
343
+ }), /* @__PURE__ */ R(S, {
344
+ className: "block text-small text-danger",
345
+ children: t
346
+ })] });
347
+ }
348
+ //#endregion
349
+ //#region ../ui/src/components/Icon.tsx
350
+ var cn = {
351
+ close: rn,
352
+ more: Ct,
353
+ drag: Ft,
354
+ chevron: yt,
355
+ check: vt,
356
+ bold: ht,
357
+ italic: zt,
358
+ bullets: Ht,
359
+ numbers: Vt,
360
+ quote: Jt,
361
+ code: xt,
362
+ link: Bt,
363
+ image: It,
364
+ add: qt,
365
+ upload: nn,
366
+ import: jt,
367
+ "replace-image": Lt,
368
+ back: ft,
369
+ "move-up": mt,
370
+ "move-down": dt,
371
+ "move-to": Nt,
372
+ duplicate: St,
373
+ "change-kind": Yt,
374
+ "list-pane": Gt,
375
+ "pane-collapse": Ut,
376
+ "pane-expand": Wt,
377
+ details: Qt,
378
+ "view-on-site": wt,
379
+ schedule: gt,
380
+ "publish-now": Zt,
381
+ unschedule: _t,
382
+ open: $t,
383
+ edit: Kt,
384
+ "add-child": Ot,
385
+ delete: en,
386
+ warning: tn,
387
+ accessibility: ut,
388
+ error: bt,
389
+ search: Xt,
390
+ media: Rt,
391
+ redirects: pt,
392
+ collection: At,
393
+ tree: Pt,
394
+ singleton: Qt,
395
+ "file-text": At,
396
+ "file-sheet": kt,
397
+ "file-archive": Tt,
398
+ "file-video": Dt,
399
+ "file-audio": Et,
400
+ file: Mt
401
+ }, ln = /* @__PURE__ */ new Set([
402
+ "path",
403
+ "circle",
404
+ "rect",
405
+ "line",
406
+ "polyline",
407
+ "polygon",
408
+ "ellipse"
409
+ ]), un = /* @__PURE__ */ new Set([
410
+ "d",
411
+ "cx",
412
+ "cy",
413
+ "r",
414
+ "rx",
415
+ "ry",
416
+ "x",
417
+ "y",
418
+ "x1",
419
+ "x2",
420
+ "y1",
421
+ "y2",
422
+ "width",
423
+ "height",
424
+ "points"
425
+ ]);
426
+ function G({ name: e, node: t, size: n = 20, className: i }) {
427
+ let a = t ?? (e ? cn[e] : []);
428
+ return /* @__PURE__ */ R("svg", {
429
+ xmlns: "http://www.w3.org/2000/svg",
430
+ viewBox: "0 0 24 24",
431
+ width: n,
432
+ height: n,
433
+ fill: "none",
434
+ stroke: "currentColor",
435
+ strokeWidth: 42 / n,
436
+ strokeLinecap: "round",
437
+ strokeLinejoin: "round",
438
+ "aria-hidden": "true",
439
+ focusable: "false",
440
+ className: V("shrink-0", i),
441
+ children: a.map(([e, t], n) => ln.has(e) ? r(e, {
442
+ key: n,
443
+ ...Object.fromEntries(Object.entries(t).filter(([e, t]) => un.has(e) && (typeof t == "string" || typeof t == "number")))
444
+ }) : null)
445
+ });
446
+ }
447
+ //#endregion
448
+ //#region ../ui/src/components/Button.tsx
449
+ var dn = {
450
+ primary: V("border-transparent bg-accent text-on-accent data-[hovered]:bg-accent-hover", "data-[hovered]:shadow-glow-accent data-[focus-visible]:shadow-glow-accent", U, "data-[hovered]:transition-[background-color,box-shadow] data-[hovered]:duration-180"),
451
+ secondary: V("border-border-strong bg-surface text-content data-[hovered]:bg-surface-sunken", U),
452
+ quiet: V("border-transparent text-accent data-[hovered]:bg-accent-subtle", U),
453
+ danger: V("border-transparent bg-danger text-on-accent data-[hovered]:opacity-90", U)
454
+ }, fn = V("inline-flex min-h-10 items-center justify-center gap-2 rounded-md border px-4 text-label", "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[pending]:cursor-progress", H);
455
+ function K({ variant: e = "secondary", className: t, children: n, pulse: r = 0, icon: i, ...a }) {
456
+ let o = u(null);
457
+ return s(() => {
458
+ let e = o.current;
459
+ if (r === 0 || !e) return;
460
+ e.classList.remove("animate-glow-pulse"), e.getBoundingClientRect(), e.classList.add("animate-glow-pulse");
461
+ let t = () => {
462
+ e.classList.remove("animate-glow-pulse");
463
+ };
464
+ return e.addEventListener("animationend", t, { once: !0 }), () => {
465
+ e.removeEventListener("animationend", t);
466
+ };
467
+ }, [r]), /* @__PURE__ */ z(f, {
468
+ ...a,
469
+ ref: o,
470
+ className: V(fn, dn[e], t),
471
+ children: [i && /* @__PURE__ */ R(G, {
472
+ name: i,
473
+ size: 18
474
+ }), n]
475
+ });
476
+ }
477
+ function pn({ variant: e = "secondary", className: t, children: n, icon: r, ...i }) {
478
+ return /* @__PURE__ */ z(ee, {
479
+ ...i,
480
+ className: V(fn, "no-underline", dn[e], t),
481
+ children: [r && /* @__PURE__ */ R(G, {
482
+ name: r,
483
+ size: 18
484
+ }), n]
485
+ });
486
+ }
487
+ function mn({ icon: e, label: t, className: n, ...r }) {
488
+ return /* @__PURE__ */ R(f, {
489
+ ...r,
490
+ "aria-label": t,
491
+ className: V("inline-flex size-10 shrink-0 items-center justify-center rounded-md border border-transparent text-content-muted", "data-[hovered]:bg-surface-sunken data-[hovered]:text-content data-[disabled]:opacity-50", U, H, n),
492
+ children: /* @__PURE__ */ R(G, { name: e })
493
+ });
494
+ }
495
+ function hn({ className: e, variant: t = "inline", icon: n, children: r, ...i }) {
496
+ return /* @__PURE__ */ R(ee, {
497
+ ...i,
498
+ className: V("cursor-pointer rounded-sm underline-offset-2", n && "inline-flex items-center gap-1", t === "inline" ? "text-accent underline data-[hovered]:text-accent-hover" : "font-semibold text-content no-underline data-[hovered]:text-accent data-[hovered]:underline", U, H, e),
499
+ children: (e) => /* @__PURE__ */ z(L, { children: [n && /* @__PURE__ */ R(G, {
500
+ name: n,
501
+ size: 16
502
+ }), typeof r == "function" ? r(e) : r] })
503
+ });
504
+ }
505
+ function gn({ accept: e, onSelect: t, children: n, variant: r = "secondary", icon: i }) {
506
+ return /* @__PURE__ */ R(C, {
507
+ acceptedFileTypes: e,
508
+ onSelect: (e) => {
509
+ let n = e?.[0];
510
+ n && t(n);
511
+ },
512
+ children: /* @__PURE__ */ R(K, {
513
+ variant: r,
514
+ ...i ? { icon: i } : {},
515
+ children: n
516
+ })
517
+ });
518
+ }
519
+ //#endregion
520
+ //#region ../ui/src/components/TextField.tsx
521
+ function _n({ label: e, description: t, errorMessage: n, placeholder: r, className: i, inputClassName: a, icon: o, ...s }) {
522
+ let c = /* @__PURE__ */ R(E, {
523
+ placeholder: r,
524
+ className: V(an, o && "pl-10", a)
525
+ });
526
+ return /* @__PURE__ */ z(Ce, {
527
+ ...s,
528
+ className: V("flex flex-col gap-2", i),
529
+ children: [
530
+ /* @__PURE__ */ R(on, { label: e }),
531
+ o ? /* @__PURE__ */ z("div", {
532
+ className: "relative",
533
+ children: [/* @__PURE__ */ R(G, {
534
+ name: o,
535
+ size: 18,
536
+ className: "pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-content-muted"
537
+ }), c]
538
+ }) : c,
539
+ /* @__PURE__ */ R(W, {
540
+ description: t,
541
+ errorMessage: n
542
+ })
543
+ ]
544
+ });
545
+ }
546
+ function vn({ label: e, description: t, errorMessage: n, placeholder: r, rows: i = 4, className: a, inputClassName: o, ...s }) {
547
+ return /* @__PURE__ */ z(Ce, {
548
+ ...s,
549
+ className: V("flex flex-col gap-2", a),
550
+ children: [
551
+ /* @__PURE__ */ R(on, { label: e }),
552
+ /* @__PURE__ */ R(Se, {
553
+ rows: i,
554
+ placeholder: r,
555
+ className: V(an, "min-h-24 resize-y", o)
556
+ }),
557
+ /* @__PURE__ */ R(W, {
558
+ description: t,
559
+ errorMessage: n
560
+ })
561
+ ]
562
+ });
563
+ }
564
+ //#endregion
565
+ //#region ../ui/src/components/overlays.tsx
566
+ var yn = "scrim fixed inset-0 z-50 data-[entering]:animate-none", bn = "glass-raised shadow-glass-overlay", xn = V("rounded-lg p-1", bn);
567
+ function Sn({ title: e, isOpen: t, onOpenChange: n, children: r, isDismissable: i = !0, role: a = "dialog", size: o = "default" }) {
568
+ return /* @__PURE__ */ R(N, {
569
+ isOpen: t,
570
+ onOpenChange: n,
571
+ isDismissable: i,
572
+ className: V(yn, "flex items-center justify-center p-4"),
573
+ children: /* @__PURE__ */ R(M, {
574
+ className: V("max-h-full w-full overflow-y-auto rounded-lg", bn, o === "wide" ? "max-w-3xl" : "max-w-lg"),
575
+ children: /* @__PURE__ */ R(y, {
576
+ role: a,
577
+ className: "flex flex-col gap-4 p-6 outline-none",
578
+ children: ({ close: t }) => /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
579
+ className: "flex items-start justify-between gap-4",
580
+ children: [/* @__PURE__ */ R(T, {
581
+ slot: "title",
582
+ className: "text-heading-2 text-content",
583
+ children: e
584
+ }), /* @__PURE__ */ R(mn, {
585
+ icon: "close",
586
+ label: "Close",
587
+ onPress: t,
588
+ className: "-mr-2 -mt-2"
589
+ })]
590
+ }), typeof r == "function" ? r(t) : r] })
591
+ })
592
+ })
593
+ });
594
+ }
595
+ function Cn({ title: e, isOpen: t, onOpenChange: n, children: r }) {
596
+ return /* @__PURE__ */ R(N, {
597
+ isOpen: t,
598
+ onOpenChange: n,
599
+ isDismissable: !0,
600
+ className: yn,
601
+ children: /* @__PURE__ */ R(M, {
602
+ className: V("fixed inset-y-0 right-0 flex w-full max-w-drawer flex-col rounded-l-lg", bn),
603
+ children: /* @__PURE__ */ R(y, {
604
+ className: "flex h-full flex-col outline-none",
605
+ children: ({ close: t }) => /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
606
+ className: "flex items-center justify-between gap-4 px-6 pt-6 pb-4",
607
+ children: [/* @__PURE__ */ R(T, {
608
+ slot: "title",
609
+ className: "text-heading-2 text-content",
610
+ children: e
611
+ }), /* @__PURE__ */ R(mn, {
612
+ icon: "close",
613
+ label: "Close",
614
+ onPress: t,
615
+ className: "-mr-2"
616
+ })]
617
+ }), /* @__PURE__ */ R("div", {
618
+ className: "flex-1 overflow-y-auto px-6 pb-6",
619
+ children: typeof r == "function" ? r(t) : r
620
+ })] })
621
+ })
622
+ })
623
+ });
624
+ }
625
+ function q({ className: e }) {
626
+ return /* @__PURE__ */ R(G, {
627
+ name: "chevron",
628
+ size: 16,
629
+ className: V("text-content-muted", e)
630
+ });
631
+ }
632
+ function wn({ text: e, children: t }) {
633
+ return /* @__PURE__ */ z(De, {
634
+ delay: 400,
635
+ closeDelay: 0,
636
+ children: [t, /* @__PURE__ */ R(Ee, {
637
+ offset: 6,
638
+ className: V("rounded-md px-2 py-1 text-small text-content", bn),
639
+ children: e
640
+ })]
641
+ });
642
+ }
643
+ var Tn = V("flex min-h-9 cursor-default items-center rounded-md px-3 text-body outline-none", "data-[focused]:bg-accent-subtle data-[disabled]:opacity-50", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"), En = "relative mt-2 before:pointer-events-none before:absolute before:inset-x-2 before:-top-1 before:border-t before:border-border before:content-['']";
644
+ function Dn(e, t, n, r) {
645
+ let i = e.indexOf(t), a = t.isDanger === !0 && i > 0 && !e[i - 1]?.isDanger || n && i === 0, o = t.items, s = /* @__PURE__ */ z(A, {
646
+ ...o ? {} : { id: t.id },
647
+ textValue: t.label,
648
+ className: V(Tn, t.isDanger ? "text-danger" : "text-content", t.isCurrent && "bg-accent-subtle shadow-glow-selected", a && En),
649
+ children: [
650
+ t.icon && /* @__PURE__ */ R(G, {
651
+ ...typeof t.icon == "string" ? { name: t.icon } : { node: t.icon },
652
+ size: 18,
653
+ className: V("mr-2", !t.isDanger && "text-content-muted")
654
+ }),
655
+ t.description ? /* @__PURE__ */ z("span", {
656
+ className: "flex min-w-0 flex-col py-1",
657
+ children: [/* @__PURE__ */ R(xe, {
658
+ slot: "label",
659
+ children: t.label
660
+ }), /* @__PURE__ */ R(xe, {
661
+ slot: "description",
662
+ className: "text-small text-content-muted",
663
+ children: t.description
664
+ })]
665
+ }) : t.label,
666
+ t.items && /* @__PURE__ */ R(q, { className: "ml-auto -rotate-90 pl-2" })
667
+ ]
668
+ });
669
+ return o ? /* @__PURE__ */ z(ce, { children: [s, /* @__PURE__ */ R(P, {
670
+ offset: -4,
671
+ className: V("max-w-sm min-w-56", xn),
672
+ children: /* @__PURE__ */ R(te, {
673
+ "aria-label": t.label,
674
+ onAction: (e) => {
675
+ r(String(e));
676
+ },
677
+ items: o,
678
+ disabledKeys: o.filter((e) => e.isDisabled).map((e) => e.id),
679
+ className: "outline-none",
680
+ children: (e) => Dn(o, e, !1, r)
681
+ })
682
+ })] }) : s;
683
+ }
684
+ function On({ label: e, items: t, onAction: n, triggerText: r, triggerIcon: i, triggerPicture: a, trigger: o, header: c, choice: l, isOpen: p, onOpenChange: m }) {
685
+ let h = new Set(l?.options.map((e) => e.id)), _ = u(null), [v, y] = d(!1), b = u(null), x = (e) => {
686
+ b.current = e;
687
+ };
688
+ s(() => {
689
+ let e = b.current;
690
+ v || e === null || (b.current = null, _.current?.querySelector("button")?.focus(), h.has(e) ? l?.onClosed?.() : n(e));
691
+ });
692
+ let S = l ? [{
693
+ id: "choice",
694
+ choice: l
695
+ }, ...t.length > 0 ? [{
696
+ id: "items",
697
+ items: t
698
+ }] : []] : [];
699
+ return /* @__PURE__ */ z(ne, {
700
+ ...p === void 0 ? {} : { isOpen: p },
701
+ onOpenChange: (e) => {
702
+ y(e), m?.(e);
703
+ },
704
+ children: [/* @__PURE__ */ R("span", {
705
+ ref: _,
706
+ className: "contents",
707
+ children: o ?? (r ? /* @__PURE__ */ z(f, {
708
+ className: V("inline-flex min-h-10 min-w-0 items-center gap-1 rounded-md border border-transparent text-body text-content data-[hovered]:bg-surface-sunken", a ? "px-2" : "px-3", "transition-[color,background-color,border-color] duration-120 ease-out", H),
709
+ children: [a ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("span", {
710
+ className: "flex",
711
+ children: a
712
+ }), /* @__PURE__ */ R("span", {
713
+ className: "sr-only",
714
+ children: r
715
+ })] }) : /* @__PURE__ */ z(L, { children: [i && /* @__PURE__ */ R(G, {
716
+ name: i,
717
+ size: 18
718
+ }), /* @__PURE__ */ R("span", {
719
+ className: "min-w-0 truncate",
720
+ children: r
721
+ })] }), /* @__PURE__ */ R(q, {})]
722
+ }) : /* @__PURE__ */ R(mn, {
723
+ icon: "more",
724
+ label: e
725
+ }))
726
+ }), /* @__PURE__ */ z(P, {
727
+ placement: o ? "bottom start" : "bottom end",
728
+ className: V("min-w-56", xn),
729
+ children: [c && /* @__PURE__ */ R("div", {
730
+ "aria-hidden": "true",
731
+ className: "mb-1 border-b border-border px-3 pt-2 pb-3",
732
+ children: c
733
+ }), l ? /* @__PURE__ */ R(te, {
734
+ "aria-label": e,
735
+ onAction: (e) => {
736
+ x(String(e));
737
+ },
738
+ items: S,
739
+ disabledKeys: t.filter((e) => e.isDisabled).map((e) => e.id),
740
+ className: "outline-none",
741
+ children: (t) => t.id === "choice" ? /* @__PURE__ */ z(j, {
742
+ id: "choice",
743
+ selectionMode: "single",
744
+ disallowEmptySelection: !0,
745
+ selectedKeys: [t.choice.selected],
746
+ onSelectionChange: (e) => {
747
+ if (e === "all") return;
748
+ let [n] = [...e];
749
+ n !== void 0 && t.choice.onChange(String(n));
750
+ },
751
+ children: [/* @__PURE__ */ R(w, {
752
+ className: "px-3 pt-1 pb-1 text-small text-content-muted",
753
+ children: t.choice.title
754
+ }), /* @__PURE__ */ R(g, {
755
+ items: t.choice.options,
756
+ children: (e) => /* @__PURE__ */ R(A, {
757
+ id: e.id,
758
+ textValue: e.label,
759
+ className: V(Tn, "gap-2 text-content"),
760
+ children: ({ isSelected: t }) => /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(G, {
761
+ name: "check",
762
+ size: 18,
763
+ className: V("text-accent", !t && "invisible")
764
+ }), e.label] })
765
+ })
766
+ })]
767
+ }) : /* @__PURE__ */ R(j, {
768
+ id: "items",
769
+ "aria-label": e,
770
+ items: t.items,
771
+ children: (e) => Dn(t.items, e, !0, x)
772
+ })
773
+ }) : /* @__PURE__ */ R(te, {
774
+ "aria-label": e,
775
+ onAction: (e) => {
776
+ x(String(e));
777
+ },
778
+ items: t,
779
+ disabledKeys: t.filter((e) => e.isDisabled).map((e) => e.id),
780
+ className: "outline-none",
781
+ children: (e) => Dn(t, e, !1, x)
782
+ })]
783
+ })]
784
+ });
785
+ }
786
+ function kn({ title: e, children: t, level: n = 2, ...r }) {
787
+ return /* @__PURE__ */ z(b, {
788
+ ...r,
789
+ className: "vesper-disclosure group border-y border-border [.vesper-disclosure+&]:border-t-0",
790
+ children: [/* @__PURE__ */ R(T, {
791
+ level: n,
792
+ className: "m-0",
793
+ children: /* @__PURE__ */ z(f, {
794
+ slot: "trigger",
795
+ className: V("flex min-h-12 w-full items-center gap-2 rounded-md text-left text-heading-3 text-content", H),
796
+ children: [/* @__PURE__ */ R(q, { className: "-rotate-90 group-data-[expanded]:rotate-0" }), e]
797
+ })
798
+ }), /* @__PURE__ */ R(x, { children: /* @__PURE__ */ R("div", {
799
+ className: "pb-6",
800
+ children: t
801
+ }) })]
802
+ });
803
+ }
804
+ //#endregion
805
+ //#region ../ui/src/components/choices.tsx
806
+ var An = V("group flex min-h-9 cursor-default items-center gap-2 rounded-md px-3 py-1 text-body text-content outline-none", "data-[focused]:bg-accent-subtle data-[selected]:bg-accent-subtle data-[selected]:shadow-glow-selected", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"), jn = V("min-w-[var(--trigger-width)]", xn);
807
+ function Mn() {
808
+ return /* @__PURE__ */ R(G, {
809
+ name: "check",
810
+ size: 16,
811
+ className: "invisible ml-auto text-accent group-data-[selected]:visible"
812
+ });
813
+ }
814
+ function Nn({ label: e, description: t, errorMessage: n, options: r, value: i, onChange: a, placeholder: o, className: s, ...c }) {
815
+ return /* @__PURE__ */ z(ae, {
816
+ ...c,
817
+ value: i,
818
+ onChange: (e) => {
819
+ a(e === null ? null : String(e));
820
+ },
821
+ placeholder: o ?? "Choose…",
822
+ className: V("flex flex-col gap-2", s),
823
+ children: [
824
+ /* @__PURE__ */ R(on, { label: e }),
825
+ /* @__PURE__ */ z(f, {
826
+ className: V(an, "flex items-center justify-between text-left", H),
827
+ children: [/* @__PURE__ */ R(oe, {
828
+ className: "truncate data-[placeholder]:text-content-muted",
829
+ children: ({ isPlaceholder: e, selectedText: t, defaultChildren: n }) => e ? n : t
830
+ }), /* @__PURE__ */ R(q, {})]
831
+ }),
832
+ /* @__PURE__ */ R(W, {
833
+ description: t,
834
+ errorMessage: n
835
+ }),
836
+ /* @__PURE__ */ R(P, {
837
+ className: jn,
838
+ children: /* @__PURE__ */ R(O, {
839
+ className: "max-h-72 overflow-auto outline-none",
840
+ items: r,
841
+ children: (e) => /* @__PURE__ */ z(k, {
842
+ id: e.value,
843
+ textValue: e.label,
844
+ className: An,
845
+ children: [e.label, /* @__PURE__ */ R(Mn, {})]
846
+ })
847
+ })
848
+ })
849
+ ]
850
+ });
851
+ }
852
+ function Pn({ label: e, description: t, errorMessage: n, options: r, value: i, onChange: a, placeholder: o, className: s, ...c }) {
853
+ let l = r.find((e) => e.value === i)?.prefix;
854
+ return /* @__PURE__ */ z(v, {
855
+ ...c,
856
+ defaultItems: r,
857
+ value: i,
858
+ onChange: (e) => {
859
+ a(e === null ? null : String(e));
860
+ },
861
+ menuTrigger: "focus",
862
+ validationBehavior: "aria",
863
+ className: V("group/combobox flex flex-col gap-2", s),
864
+ children: [
865
+ /* @__PURE__ */ R(on, { label: e }),
866
+ /* @__PURE__ */ z("div", {
867
+ className: "relative",
868
+ children: [
869
+ l && /* @__PURE__ */ R("span", {
870
+ "aria-hidden": "true",
871
+ className: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 group-data-[disabled]/combobox:opacity-60",
872
+ children: l
873
+ }),
874
+ /* @__PURE__ */ R(E, {
875
+ placeholder: o,
876
+ className: V(an, "pr-10", l ? "pl-10" : void 0)
877
+ }),
878
+ /* @__PURE__ */ R(f, {
879
+ "aria-label": "Show options",
880
+ className: V("absolute inset-y-0 right-0 flex items-center rounded-md px-3 text-content-muted", H),
881
+ children: /* @__PURE__ */ R(q, {})
882
+ })
883
+ ]
884
+ }),
885
+ /* @__PURE__ */ R(W, {
886
+ description: t,
887
+ errorMessage: n
888
+ }),
889
+ /* @__PURE__ */ R(P, {
890
+ className: jn,
891
+ children: /* @__PURE__ */ R(O, {
892
+ className: "max-h-72 overflow-auto outline-none",
893
+ children: (e) => /* @__PURE__ */ z(k, {
894
+ id: e.value,
895
+ textValue: e.label,
896
+ className: An,
897
+ children: [
898
+ e.prefix && /* @__PURE__ */ R("span", {
899
+ "aria-hidden": "true",
900
+ className: "flex shrink-0",
901
+ children: e.prefix
902
+ }),
903
+ e.label,
904
+ /* @__PURE__ */ R(Mn, {})
905
+ ]
906
+ })
907
+ })
908
+ })
909
+ ]
910
+ });
911
+ }
912
+ function Fn({ label: e, description: t, errorMessage: n, options: r, values: i, onChange: a, allowsCustomValue: o = !1, itemName: s = "item", className: c, isDisabled: u, isInvalid: p, ...m }) {
913
+ let [h, g] = d(""), _ = l(() => new Map(r.map((e) => [e.value, e])), [r]), y = r.filter((e) => !i.includes(e.value)), b = (e) => {
914
+ let t = e.trim();
915
+ t === "" || i.includes(t) || (o || _.has(t)) && (a([...i, t]), g(""));
916
+ }, x = (e) => _.get(e)?.label ?? e;
917
+ return /* @__PURE__ */ z("div", {
918
+ className: V("flex flex-col gap-2", c),
919
+ onKeyDownCapture: (e) => {
920
+ if (!(e.target instanceof HTMLInputElement)) return;
921
+ let t = e.target.value;
922
+ e.key === "Enter" && o && t.trim() !== "" && !e.target.getAttribute("aria-activedescendant") && (e.preventDefault(), e.stopPropagation(), b(t)), e.key === "Backspace" && t === "" && i.length > 0 && a(i.slice(0, -1));
923
+ },
924
+ children: [/* @__PURE__ */ z(v, {
925
+ ...m,
926
+ items: y.filter((e) => e.label.toLowerCase().includes(h.toLowerCase())),
927
+ inputValue: h,
928
+ onInputChange: g,
929
+ value: null,
930
+ onChange: (e) => {
931
+ e !== null && b(String(e));
932
+ },
933
+ allowsCustomValue: o,
934
+ isDisabled: u,
935
+ isInvalid: p,
936
+ menuTrigger: "focus",
937
+ className: "flex flex-col gap-1",
938
+ children: [
939
+ /* @__PURE__ */ R(on, { label: e }),
940
+ /* @__PURE__ */ R(E, { className: an }),
941
+ /* @__PURE__ */ R(W, {
942
+ description: t,
943
+ errorMessage: n
944
+ }),
945
+ /* @__PURE__ */ R(P, {
946
+ className: jn,
947
+ children: /* @__PURE__ */ R(O, {
948
+ className: "max-h-72 overflow-auto outline-none",
949
+ renderEmptyState: () => /* @__PURE__ */ R("p", {
950
+ className: "px-3 py-2 text-small text-content-muted",
951
+ children: o ? "Press Enter to add it" : "No matches"
952
+ }),
953
+ children: (e) => /* @__PURE__ */ R(k, {
954
+ id: e.value,
955
+ textValue: e.label,
956
+ className: An,
957
+ children: e.label
958
+ })
959
+ })
960
+ })
961
+ ]
962
+ }), i.length > 0 && /* @__PURE__ */ R(ye, {
963
+ "aria-label": typeof e == "string" ? `Selected ${e.toLowerCase()}` : "Selected",
964
+ onRemove: (e) => {
965
+ a(i.filter((t) => !e.has(t)));
966
+ },
967
+ children: /* @__PURE__ */ R(be, {
968
+ className: "flex flex-wrap gap-2",
969
+ children: i.map((e) => /* @__PURE__ */ z(ve, {
970
+ id: e,
971
+ textValue: x(e),
972
+ className: V("inline-flex items-center gap-1 rounded-sm border border-border bg-surface py-0.5 pr-0.5 pl-2 text-small text-content", H),
973
+ children: [x(e), /* @__PURE__ */ R(f, {
974
+ slot: "remove",
975
+ "aria-label": `Remove ${s}`,
976
+ className: V("inline-flex size-6 items-center justify-center rounded-sm text-content-muted data-[hovered]:bg-surface-sunken data-[hovered]:text-content", H),
977
+ children: /* @__PURE__ */ R(G, {
978
+ name: "close",
979
+ size: 16
980
+ })
981
+ })]
982
+ }, e))
983
+ })
984
+ })]
985
+ });
986
+ }
987
+ var In = V("group-data-[focus-visible]:outline-2 group-data-[focus-visible]:outline-solid group-data-[focus-visible]:outline-offset-2 group-data-[focus-visible]:outline-focus", "group-data-[focus-visible]:ring-6 group-data-[focus-visible]:ring-(color:--glow-focus)");
988
+ function Ln({ children: e, className: t, ...n }) {
989
+ return /* @__PURE__ */ R(h, {
990
+ ...n,
991
+ className: t,
992
+ children: /* @__PURE__ */ z(m, {
993
+ className: "group inline-flex items-start gap-2 text-body text-content",
994
+ children: [/* @__PURE__ */ R("span", {
995
+ "aria-hidden": "true",
996
+ className: V("mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-sm border border-border-strong bg-surface", "group-data-[selected]:border-accent group-data-[selected]:bg-accent group-data-[selected]:text-on-accent", In),
997
+ children: /* @__PURE__ */ R("svg", {
998
+ viewBox: "0 0 16 16",
999
+ className: "hidden size-4 group-data-[selected]:block",
1000
+ fill: "none",
1001
+ stroke: "currentColor",
1002
+ strokeWidth: "2",
1003
+ children: /* @__PURE__ */ R("path", { d: "M3 8l3 3 7-7" })
1004
+ })
1005
+ }), e]
1006
+ })
1007
+ });
1008
+ }
1009
+ function Rn({ children: e, className: t, ...n }) {
1010
+ return /* @__PURE__ */ R(ue, {
1011
+ ...n,
1012
+ className: t,
1013
+ children: /* @__PURE__ */ z(le, {
1014
+ className: "group inline-flex items-center gap-3 text-body text-content",
1015
+ children: [
1016
+ /* @__PURE__ */ R("span", {
1017
+ "aria-hidden": "true",
1018
+ className: V("flex h-6 w-10 shrink-0 items-center rounded-full border border-border-strong bg-surface-sunken p-0.5", "transition-[background-color,border-color] duration-120 ease-out", "group-data-[selected]:border-accent group-data-[selected]:bg-accent", In),
1019
+ children: /* @__PURE__ */ R("span", { className: "size-4 rounded-full bg-content-muted transition-transform duration-180 ease-out group-data-[selected]:translate-x-4 group-data-[selected]:bg-on-accent forced-colors:bg-[CanvasText]" })
1020
+ }),
1021
+ e,
1022
+ /* @__PURE__ */ z("span", {
1023
+ "aria-hidden": "true",
1024
+ className: "text-small text-content-muted",
1025
+ children: [/* @__PURE__ */ R("span", {
1026
+ className: "group-data-[selected]:hidden",
1027
+ children: "Off"
1028
+ }), /* @__PURE__ */ R("span", {
1029
+ className: "hidden group-data-[selected]:inline",
1030
+ children: "On"
1031
+ })]
1032
+ })
1033
+ ]
1034
+ })
1035
+ });
1036
+ }
1037
+ function zn({ label: e, description: t, errorMessage: n, options: r, value: i, onChange: a, className: o, orientation: s = "vertical", ...c }) {
1038
+ return /* @__PURE__ */ z(I, {
1039
+ ...c,
1040
+ value: i,
1041
+ onChange: a,
1042
+ orientation: s,
1043
+ className: V("flex flex-col gap-2", o),
1044
+ children: [
1045
+ e && /* @__PURE__ */ R(D, {
1046
+ className: "text-label text-content",
1047
+ children: e
1048
+ }),
1049
+ /* @__PURE__ */ R("div", {
1050
+ className: V("flex gap-x-6 gap-y-2", s === "vertical" ? "flex-col" : "flex-row flex-wrap"),
1051
+ children: r.map((e) => /* @__PURE__ */ R(re, {
1052
+ value: e.value,
1053
+ children: /* @__PURE__ */ z(F, {
1054
+ className: "group inline-flex items-center gap-2 text-body text-content",
1055
+ children: [
1056
+ /* @__PURE__ */ R("span", {
1057
+ "aria-hidden": "true",
1058
+ className: V("flex size-5 shrink-0 items-center justify-center rounded-full border border-border-strong bg-surface", "group-data-[selected]:border-accent", In),
1059
+ children: /* @__PURE__ */ R("span", { className: "hidden size-2.5 rounded-full bg-accent group-data-[selected]:block forced-colors:bg-[CanvasText]" })
1060
+ }),
1061
+ e.prefix && /* @__PURE__ */ R("span", {
1062
+ "aria-hidden": "true",
1063
+ children: e.prefix
1064
+ }),
1065
+ e.label
1066
+ ]
1067
+ })
1068
+ }, e.value))
1069
+ }),
1070
+ /* @__PURE__ */ R(W, {
1071
+ description: t,
1072
+ errorMessage: n
1073
+ })
1074
+ ]
1075
+ });
1076
+ }
1077
+ function Bn({ label: e, description: t, errorMessage: n, value: r, onChange: i, suggestions: a, placeholder: o, className: s, inputMode: c = "text", ...u }) {
1078
+ let d = r.trim().toLowerCase(), f = l(() => (d === "" ? a : a.filter((e) => e.label.toLowerCase().includes(d) || e.value.toLowerCase().includes(d))).slice(0, 50), [d, a]);
1079
+ return /* @__PURE__ */ z(v, {
1080
+ ...u,
1081
+ allowsCustomValue: !0,
1082
+ allowsEmptyCollection: !0,
1083
+ items: f,
1084
+ inputValue: r,
1085
+ onInputChange: i,
1086
+ menuTrigger: "input",
1087
+ className: V("flex flex-col gap-2", s),
1088
+ children: [
1089
+ /* @__PURE__ */ R(on, { label: e }),
1090
+ /* @__PURE__ */ R(E, {
1091
+ placeholder: o,
1092
+ inputMode: c,
1093
+ className: an
1094
+ }),
1095
+ /* @__PURE__ */ R(W, {
1096
+ description: t,
1097
+ errorMessage: n
1098
+ }),
1099
+ /* @__PURE__ */ R(P, {
1100
+ className: jn,
1101
+ children: /* @__PURE__ */ R(O, {
1102
+ className: "max-h-72 overflow-auto outline-none",
1103
+ children: (e) => /* @__PURE__ */ z(k, {
1104
+ id: e.value,
1105
+ textValue: e.value,
1106
+ className: V(An, "flex-col items-start gap-0"),
1107
+ children: [/* @__PURE__ */ R("span", {
1108
+ className: "block",
1109
+ children: e.label
1110
+ }), e.detail && /* @__PURE__ */ R("span", {
1111
+ className: "block text-small text-content-muted",
1112
+ children: e.detail
1113
+ })]
1114
+ })
1115
+ })
1116
+ })
1117
+ ]
1118
+ });
1119
+ }
1120
+ //#endregion
1121
+ //#region ../ui/src/components/data.tsx
1122
+ function Vn({ label: e, columns: t, rows: n, renderCell: r, sort: i, onSortChange: a, emptyState: o, rowHref: s }) {
1123
+ return /* @__PURE__ */ R("div", {
1124
+ className: "overflow-x-auto",
1125
+ children: /* @__PURE__ */ z(me, {
1126
+ "aria-label": e,
1127
+ ...i ? { sortDescriptor: i } : {},
1128
+ ...a ? { onSortChange: a } : {},
1129
+ className: "w-full border-separate border-spacing-0 text-left text-body",
1130
+ children: [/* @__PURE__ */ R(ge, { children: t.map((e) => /* @__PURE__ */ R(_, {
1131
+ id: e.id,
1132
+ isRowHeader: e.isRowHeader ?? !1,
1133
+ allowsSorting: e.allowsSorting ?? !1,
1134
+ className: V("bg-surface-sunken px-3 py-2 text-label text-content-muted first:rounded-l-md last:rounded-r-md", "data-[allows-sorting]:cursor-pointer", H),
1135
+ children: ({ sortDirection: t }) => /* @__PURE__ */ z("span", {
1136
+ className: "inline-flex items-center gap-1",
1137
+ children: [e.label, t && /* @__PURE__ */ R("span", {
1138
+ "aria-hidden": "true",
1139
+ children: t === "ascending" ? "↑" : "↓"
1140
+ })]
1141
+ })
1142
+ }, e.id)) }), /* @__PURE__ */ R(he, {
1143
+ items: n,
1144
+ renderEmptyState: () => /* @__PURE__ */ R("p", {
1145
+ className: "px-3 py-6 text-content-muted",
1146
+ children: o ?? "Nothing here yet."
1147
+ }),
1148
+ children: (e) => /* @__PURE__ */ R(ie, {
1149
+ id: e.id,
1150
+ ...s ? { href: s(e) } : {},
1151
+ className: V("data-[hovered]:bg-accent-subtle data-[href]:cursor-pointer", U, "outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"),
1152
+ children: t.map((t) => /* @__PURE__ */ R(p, {
1153
+ className: V("border-b border-border px-3 py-3 align-top", "outline-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus"),
1154
+ children: r(e, t.id)
1155
+ }, t.id))
1156
+ })
1157
+ })]
1158
+ })
1159
+ });
1160
+ }
1161
+ function Hn({ children: e, dot: t = !1, live: n = !0, tone: r = "neutral", className: i }) {
1162
+ return /* @__PURE__ */ z("p", {
1163
+ role: n ? "status" : void 0,
1164
+ className: V("inline-flex items-center gap-2 text-small", r === "error" ? "text-danger" : "text-content-muted", i),
1165
+ children: [t && /* @__PURE__ */ R("span", {
1166
+ "aria-hidden": "true",
1167
+ className: V("size-2 shrink-0 rounded-full", r === "error" ? "bg-danger" : "bg-content-muted")
1168
+ }), e]
1169
+ });
1170
+ }
1171
+ function Un({ title: e = "There is a problem", errors: t, focusOnMount: n = !0, focusKey: r, onGo: i }) {
1172
+ let a = u(null), o = r ?? t.length, c = t.length > 0;
1173
+ return s(() => {
1174
+ n && c && a.current?.focus();
1175
+ }, [n, o]), t.length === 0 ? null : /* @__PURE__ */ z("div", {
1176
+ ref: a,
1177
+ tabIndex: -1,
1178
+ role: "alert",
1179
+ "aria-labelledby": "vesper-error-summary-title",
1180
+ className: "rounded-md border border-danger bg-surface p-4 outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus",
1181
+ children: [/* @__PURE__ */ z("h2", {
1182
+ id: "vesper-error-summary-title",
1183
+ className: "flex items-center gap-2 text-heading-3 text-content",
1184
+ children: [/* @__PURE__ */ R(G, {
1185
+ name: "error",
1186
+ className: "text-danger"
1187
+ }), e]
1188
+ }), /* @__PURE__ */ R("ul", {
1189
+ className: "mt-2 list-disc space-y-1 pl-6 text-danger",
1190
+ children: t.map((e, t) => /* @__PURE__ */ R("li", { children: /* @__PURE__ */ R("a", {
1191
+ href: `#${e.fieldId}`,
1192
+ onClick: (t) => {
1193
+ if (i) {
1194
+ t.preventDefault(), i(e.fieldId);
1195
+ return;
1196
+ }
1197
+ let n = document.getElementById(e.fieldId);
1198
+ n && (t.preventDefault(), n.focus());
1199
+ },
1200
+ className: "text-danger underline underline-offset-2",
1201
+ children: e.message
1202
+ }) }, `${e.fieldId}:${String(t)}`))
1203
+ })]
1204
+ });
1205
+ }
1206
+ //#endregion
1207
+ //#region ../ui/src/components/Mark.tsx
1208
+ function Wn({ size: e = 20, className: t }) {
1209
+ let n = e <= 24;
1210
+ return /* @__PURE__ */ z("svg", {
1211
+ viewBox: "0 0 64 64",
1212
+ width: e,
1213
+ height: e,
1214
+ "aria-hidden": "true",
1215
+ focusable: "false",
1216
+ className: V("shrink-0", t),
1217
+ children: [
1218
+ /* @__PURE__ */ R("path", {
1219
+ d: n ? "M11 14 L29 50 L42 25" : "M12 14 L30 50 L43 25",
1220
+ fill: "none",
1221
+ stroke: "currentColor",
1222
+ strokeWidth: n ? 11 : 9,
1223
+ strokeLinecap: "round",
1224
+ strokeLinejoin: "round"
1225
+ }),
1226
+ !n && /* @__PURE__ */ R("circle", {
1227
+ cx: "51",
1228
+ cy: "12",
1229
+ r: "10",
1230
+ className: "fill-accent opacity-20 forced-colors:hidden"
1231
+ }),
1232
+ /* @__PURE__ */ R("circle", {
1233
+ cx: n ? 52 : 51,
1234
+ cy: n ? 11 : 12,
1235
+ r: n ? 7 : 5.5,
1236
+ className: "fill-accent forced-colors:fill-[CanvasText]"
1237
+ })
1238
+ ]
1239
+ });
1240
+ }
1241
+ //#endregion
1242
+ //#region ../ui/src/components/Avatar.tsx
1243
+ function Gn(e) {
1244
+ return e.replace(/^@/, "").trim().split(/\s+/).filter(Boolean).slice(0, 2).map((e) => Array.from(e)[0] ?? "").join("").toLocaleUpperCase();
1245
+ }
1246
+ function Kn({ name: e, src: t, size: n = 24, className: r }) {
1247
+ let [i, a] = d(null), o = t !== void 0 && t !== "" && i !== t;
1248
+ return /* @__PURE__ */ R("span", {
1249
+ "aria-hidden": "true",
1250
+ className: V("inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-accent-subtle font-semibold text-accent", n === 32 ? "size-8 text-small" : "size-6 text-caption", r),
1251
+ children: o ? /* @__PURE__ */ R("img", {
1252
+ src: t,
1253
+ alt: "",
1254
+ width: n,
1255
+ height: n,
1256
+ referrerPolicy: "no-referrer",
1257
+ className: "size-full object-cover",
1258
+ onError: () => {
1259
+ a(t);
1260
+ }
1261
+ }) : Gn(e)
1262
+ });
1263
+ }
1264
+ //#endregion
1265
+ //#region ../ui/src/components/Tabs.tsx
1266
+ function qn({ label: e, tabs: t, selected: n, onSelectedChange: r }) {
1267
+ return /* @__PURE__ */ z(_e, {
1268
+ selectedKey: n,
1269
+ onSelectionChange: (e) => {
1270
+ r(String(e));
1271
+ },
1272
+ className: "flex flex-col gap-6",
1273
+ children: [/* @__PURE__ */ R(fe, {
1274
+ "aria-label": e,
1275
+ className: "flex flex-wrap gap-x-6 border-b border-border",
1276
+ children: t.map((e) => /* @__PURE__ */ R(de, {
1277
+ id: e.id,
1278
+ className: V("relative -mb-px flex min-h-10 cursor-default items-center rounded-sm text-label text-content-muted outline-none", "after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:rounded-full after:content-['']", "data-[hovered]:text-content data-[hovered]:after:bg-border-strong", "data-[selected]:text-content data-[selected]:after:bg-accent", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-focus", U),
1279
+ children: e.label
1280
+ }, e.id))
1281
+ }), t.map((e) => /* @__PURE__ */ R(pe, {
1282
+ id: e.id,
1283
+ shouldForceMount: !0,
1284
+ className: "outline-none data-[inert]:hidden",
1285
+ children: /* @__PURE__ */ R("div", {
1286
+ "data-tab": e.id,
1287
+ hidden: e.id !== n,
1288
+ className: "flex flex-col gap-6",
1289
+ children: e.children
1290
+ })
1291
+ }, e.id))]
1292
+ });
1293
+ }
1294
+ //#endregion
1295
+ //#region ../ui/src/components/Toolbar.tsx
1296
+ function Jn({ label: e, children: t, className: n }) {
1297
+ return /* @__PURE__ */ R(Te, {
1298
+ "aria-label": e,
1299
+ className: V("flex flex-wrap items-center gap-1", n),
1300
+ children: t
1301
+ });
1302
+ }
1303
+ var Yn = V("inline-flex min-h-8 min-w-8 items-center justify-center rounded-sm border border-transparent px-2 text-small font-semibold text-content", "data-[hovered]:bg-surface-sunken data-[disabled]:opacity-50", U, H);
1304
+ function Xn() {
1305
+ return /* @__PURE__ */ R(se, {
1306
+ orientation: "vertical",
1307
+ className: "mx-1 h-5 self-center border-l border-border"
1308
+ });
1309
+ }
1310
+ function Zn(e) {
1311
+ return e.icon ? {
1312
+ inside: /* @__PURE__ */ R(G, {
1313
+ name: e.icon,
1314
+ size: 18
1315
+ }),
1316
+ named: { "aria-label": e.label },
1317
+ tooltip: e.shortcut ? `${e.label} · ${e.shortcut.text}` : e.label
1318
+ } : {
1319
+ inside: e.children,
1320
+ named: {},
1321
+ tooltip: null
1322
+ };
1323
+ }
1324
+ var Qn = "size-8 px-0";
1325
+ function $n(e) {
1326
+ let t = u(null), n = e?.aria;
1327
+ return s(() => {
1328
+ n ? t.current?.setAttribute("aria-keyshortcuts", n) : t.current?.removeAttribute("aria-keyshortcuts");
1329
+ }, [n]), t;
1330
+ }
1331
+ function er({ children: e, icon: t, label: n, shortcut: r, className: i, ...a }) {
1332
+ let { inside: o, named: s, tooltip: c } = Zn({
1333
+ children: e,
1334
+ icon: t,
1335
+ label: n,
1336
+ shortcut: r
1337
+ }), l = $n(r), u = /* @__PURE__ */ R(we, {
1338
+ ...a,
1339
+ ...s,
1340
+ ref: l,
1341
+ className: V(Yn, c !== null && Qn, "data-[selected]:bg-accent-subtle data-[selected]:text-accent", i),
1342
+ children: o
1343
+ });
1344
+ return c === null ? u : /* @__PURE__ */ R(wn, {
1345
+ text: c,
1346
+ children: u
1347
+ });
1348
+ }
1349
+ function tr({ children: e, icon: t, label: n, shortcut: r, className: i, ...a }) {
1350
+ let { inside: o, named: s, tooltip: c } = Zn({
1351
+ children: e,
1352
+ icon: t,
1353
+ label: n,
1354
+ shortcut: r
1355
+ }), l = $n(r), u = /* @__PURE__ */ R(f, {
1356
+ ...a,
1357
+ ...s,
1358
+ ref: l,
1359
+ className: V(Yn, c !== null && Qn, i),
1360
+ children: o
1361
+ });
1362
+ return c === null ? u : /* @__PURE__ */ R(wn, {
1363
+ text: c,
1364
+ children: u
1365
+ });
1366
+ }
1367
+ //#endregion
1368
+ //#region ../ui/src/components/Tree.tsx
1369
+ function nr({ label: e, items: t, textValue: n, renderRow: r, onAction: i, expandedKeys: a, onExpandedChange: o, dragAndDropHooks: s, onRowKeyDown: c, emptyState: l, currentKey: u, inset: d = 1 }) {
1370
+ let p = /* @__PURE__ */ new Map(), m = (e) => {
1371
+ for (let t of e) p.set(t.id, t), m(t.children);
1372
+ };
1373
+ m(t);
1374
+ let h = t.some((e) => e.children.length > 0), _ = (e) => {
1375
+ if (!c) return;
1376
+ let t = e.target.closest("[role=\"row\"]");
1377
+ if (t !== e.target) return;
1378
+ let n = p.get(t.getAttribute("data-key") ?? "");
1379
+ n && c(n, e);
1380
+ }, v = (e) => /* @__PURE__ */ z(ke, {
1381
+ id: e.id,
1382
+ textValue: n(e),
1383
+ ...i ? { onAction: () => {
1384
+ i(e);
1385
+ } } : {},
1386
+ className: V("group text-body outline-none", "data-[focus-visible]:outline-2 data-[focus-visible]:outline-solid data-[focus-visible]:-outline-offset-2 data-[focus-visible]:outline-focus", "data-[drop-target]:bg-accent-subtle data-[dragging]:opacity-50", e.id === u ? "bg-accent-subtle data-[hovered]:bg-accent-subtle-hover" : "data-[hovered]:bg-surface-sunken", U),
1387
+ children: [/* @__PURE__ */ R(Ae, { children: ({ isExpanded: t, hasChildItems: n, level: i, allowsDragging: a }) => /* @__PURE__ */ z("div", {
1388
+ className: "flex min-h-12 items-center gap-1 py-1",
1389
+ style: {
1390
+ paddingInlineStart: `calc(var(--spacing) * ${String(6 * (i - 1) + d)})`,
1391
+ paddingInlineEnd: `calc(var(--spacing) * ${String(d)})`
1392
+ },
1393
+ children: [
1394
+ a && /* @__PURE__ */ R(f, {
1395
+ slot: "drag",
1396
+ className: V("inline-flex size-8 shrink-0 cursor-grab items-center justify-center rounded-md text-content-muted data-[hovered]:text-content", "data-[disabled]:invisible", H),
1397
+ children: /* @__PURE__ */ R(G, { name: "drag" })
1398
+ }),
1399
+ n ? /* @__PURE__ */ R(f, {
1400
+ slot: "chevron",
1401
+ className: V("inline-flex size-8 shrink-0 items-center justify-center rounded-md text-content-muted data-[hovered]:bg-surface-sunken", H),
1402
+ children: /* @__PURE__ */ R(q, { className: t ? "rotate-0" : "-rotate-90" })
1403
+ }) : h && /* @__PURE__ */ R("span", {
1404
+ "aria-hidden": "true",
1405
+ className: "inline-block size-8 shrink-0"
1406
+ }),
1407
+ r(e, {
1408
+ isExpanded: t,
1409
+ hasChildItems: n,
1410
+ level: i
1411
+ })
1412
+ ]
1413
+ }) }), /* @__PURE__ */ R(g, {
1414
+ items: e.children,
1415
+ children: v
1416
+ })]
1417
+ });
1418
+ return /* @__PURE__ */ R("div", {
1419
+ onKeyDownCapture: _,
1420
+ children: /* @__PURE__ */ R(Oe, {
1421
+ "aria-label": e,
1422
+ items: t,
1423
+ ...a ? { expandedKeys: a } : {},
1424
+ ...o ? { onExpandedChange: o } : {},
1425
+ ...s ? { dragAndDropHooks: s } : {},
1426
+ renderEmptyState: () => /* @__PURE__ */ R("p", {
1427
+ className: "py-6 text-content-muted",
1428
+ style: { paddingInline: `calc(var(--spacing) * ${String(d + 2)})` },
1429
+ children: l
1430
+ }),
1431
+ className: "flex w-full flex-col gap-0.5",
1432
+ children: v
1433
+ })
1434
+ });
1435
+ }
1436
+ //#endregion
1437
+ //#region src/app/context.tsx
1438
+ var rr = "Vesper", ir = n(null);
1439
+ function J() {
1440
+ let e = o(ir);
1441
+ if (!e) throw Error("useStudio() must be used inside <App>.");
1442
+ return e;
1443
+ }
1444
+ //#endregion
1445
+ //#region src/app/format.ts
1446
+ var ar = [
1447
+ ["year", 31536e3],
1448
+ ["month", 2592e3],
1449
+ ["week", 604800],
1450
+ ["day", 86400],
1451
+ ["hour", 3600],
1452
+ ["minute", 60]
1453
+ ];
1454
+ function or(e, t = /* @__PURE__ */ new Date(), n) {
1455
+ let r = new Date(e), i = Math.round((r.getTime() - t.getTime()) / 1e3);
1456
+ if (Number.isNaN(i)) return "";
1457
+ if (Math.abs(i) < 45) return "just now";
1458
+ let a = new Intl.RelativeTimeFormat(n, { numeric: "auto" });
1459
+ for (let [e, t] of ar) if (Math.abs(i) >= t || e === "minute") return a.format(Math.round(i / t), e);
1460
+ return "just now";
1461
+ }
1462
+ function sr(e, t, n, r) {
1463
+ return `${new Intl.NumberFormat(r).format(e)} ${e === 1 ? t : n}`;
1464
+ }
1465
+ //#endregion
1466
+ //#region src/app/load.ts
1467
+ function cr(e, t = "") {
1468
+ let [n, r] = d(null), [i, o] = d(0), c = u(e);
1469
+ s(() => {
1470
+ c.current = e;
1471
+ }), s(() => {
1472
+ let e = !0;
1473
+ return c.current().then((n) => {
1474
+ e && r({
1475
+ key: t,
1476
+ load: {
1477
+ state: "ready",
1478
+ value: n
1479
+ }
1480
+ });
1481
+ }, (n) => {
1482
+ let i = n instanceof Error ? n.message : String(n);
1483
+ e && r({
1484
+ key: t,
1485
+ load: {
1486
+ state: "failed",
1487
+ message: i
1488
+ }
1489
+ });
1490
+ }), () => {
1491
+ e = !1;
1492
+ };
1493
+ }, [t, i]);
1494
+ let l = a(() => {
1495
+ o((e) => e + 1);
1496
+ }, []);
1497
+ return [n?.key === t ? n.load : { state: "loading" }, l];
1498
+ }
1499
+ //#endregion
1500
+ //#region src/editor/values.ts
1501
+ function lr(e, t) {
1502
+ let n = e;
1503
+ for (let e of t) if (n = typeof e == "number" ? Array.isArray(n) ? n[e] : void 0 : B(n) ? n[e] : void 0, n === void 0) return;
1504
+ return n;
1505
+ }
1506
+ function ur(e, t, n) {
1507
+ return dr(e, t, 0, n);
1508
+ }
1509
+ function dr(e, t, n, r) {
1510
+ if (n === t.length) return r;
1511
+ let i = t[n];
1512
+ if (typeof i == "number") {
1513
+ let a = Array.isArray(e) ? [...e] : [];
1514
+ return a[i] = dr(a[i], t, n + 1, r), a;
1515
+ }
1516
+ let a = B(e) ? { ...e } : {}, o = dr(a[i], t, n + 1, r);
1517
+ return o === void 0 ? Reflect.deleteProperty(a, i) : a[i] = o, a;
1518
+ }
1519
+ function fr(e, t = "field") {
1520
+ return `${t}.${e.map((e) => String(e).replace(/[^A-Za-z0-9_]/g, "_")).join(".")}`;
1521
+ }
1522
+ function pr(e) {
1523
+ return e.map(String).join(".");
1524
+ }
1525
+ function Y(e) {
1526
+ return e.path.at(-1) ?? "";
1527
+ }
1528
+ function mr(e) {
1529
+ let t = {};
1530
+ for (let n of e ?? []) n.default !== void 0 && !n.defaultDynamic && (t[Y(n)] = structuredClone(n.default));
1531
+ return t;
1532
+ }
1533
+ //#endregion
1534
+ //#region src/editor/context.tsx
1535
+ var hr = n(null);
1536
+ function X() {
1537
+ let e = o(hr);
1538
+ if (!e) throw Error("useEditor() must be used inside an entry editor.");
1539
+ return e;
1540
+ }
1541
+ //#endregion
1542
+ //#region src/widgets/basic.tsx
1543
+ var Z = V("min-h-10 w-full rounded-md border border-border-strong bg-surface-sunken px-3 py-2 text-body text-content", "outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus", "focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)", "aria-[invalid=true]:border-danger disabled:opacity-60");
1544
+ function gr(e) {
1545
+ return e.required ? "" : void 0;
1546
+ }
1547
+ function _r(e) {
1548
+ let { onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o } = e, s = e.value;
1549
+ return {
1550
+ id: r,
1551
+ value: typeof s == "string" ? s : typeof s == "number" || typeof s == "boolean" ? String(s) : "",
1552
+ onChange: (e) => {
1553
+ t(e.target.value === "" ? gr(n) : e.target.value);
1554
+ },
1555
+ "aria-describedby": i,
1556
+ "aria-invalid": a || void 0,
1557
+ "aria-required": n.required || void 0,
1558
+ disabled: o,
1559
+ placeholder: n.placeholder,
1560
+ autoComplete: n.autocomplete,
1561
+ className: Z
1562
+ };
1563
+ }
1564
+ function vr(e) {
1565
+ return /* @__PURE__ */ R("input", {
1566
+ type: "text",
1567
+ ..._r(e)
1568
+ });
1569
+ }
1570
+ function yr(e) {
1571
+ let t = _r(e);
1572
+ return /* @__PURE__ */ R("input", {
1573
+ type: "email",
1574
+ inputMode: "email",
1575
+ ...t,
1576
+ autoComplete: t.autoComplete ?? "email"
1577
+ });
1578
+ }
1579
+ function br(e) {
1580
+ let t = e.field.widget === "markdown" ? 8 : 3;
1581
+ return /* @__PURE__ */ R("textarea", {
1582
+ rows: t,
1583
+ ..._r(e),
1584
+ className: V(Z, "resize-y")
1585
+ });
1586
+ }
1587
+ function xr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1588
+ let [s, c] = d(e === void 0 ? "" : String(e)), l = n.constraints;
1589
+ return /* @__PURE__ */ R("input", {
1590
+ id: r,
1591
+ type: "number",
1592
+ inputMode: l?.integer ? "numeric" : "decimal",
1593
+ value: s,
1594
+ min: l?.min,
1595
+ max: l?.max,
1596
+ step: l?.step ?? (l?.integer ? 1 : "any"),
1597
+ onChange: (e) => {
1598
+ c(e.target.value), e.target.value === "" ? t(void 0) : Number.isFinite(e.target.valueAsNumber) && t(e.target.valueAsNumber);
1599
+ },
1600
+ "aria-describedby": i,
1601
+ "aria-invalid": a || void 0,
1602
+ "aria-required": n.required || void 0,
1603
+ disabled: o,
1604
+ className: V(Z, "max-w-48")
1605
+ });
1606
+ }
1607
+ function Sr({ value: e, onChange: t, id: n, describedBy: r, invalid: i, disabled: a }) {
1608
+ return /* @__PURE__ */ R(Rn, {
1609
+ id: n,
1610
+ isSelected: e === !0,
1611
+ onChange: t,
1612
+ isDisabled: a,
1613
+ isInvalid: i,
1614
+ "aria-labelledby": `${n}-label`,
1615
+ "aria-describedby": r,
1616
+ children: null
1617
+ });
1618
+ }
1619
+ function Cr(e) {
1620
+ return e instanceof Date && !Number.isNaN(e.getTime()) ? e.toISOString().slice(0, 10) : typeof e == "string" ? e.slice(0, 10) : "";
1621
+ }
1622
+ function wr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1623
+ return /* @__PURE__ */ R("input", {
1624
+ id: r,
1625
+ type: "date",
1626
+ value: Cr(e),
1627
+ onChange: (r) => {
1628
+ let i = r.target.value;
1629
+ t(i === "" ? gr(n) === "" && typeof e == "string" ? "" : void 0 : typeof e == "string" ? i : /* @__PURE__ */ new Date(`${i}T00:00:00.000Z`));
1630
+ },
1631
+ "aria-describedby": i,
1632
+ "aria-invalid": a || void 0,
1633
+ "aria-required": n.required || void 0,
1634
+ disabled: o,
1635
+ className: V(Z, "max-w-56")
1636
+ });
1637
+ }
1638
+ function Tr(e) {
1639
+ return e.constraints?.options ?? e.children?.[0]?.constraints?.options ?? [];
1640
+ }
1641
+ function Er({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1642
+ return /* @__PURE__ */ R(Nn, {
1643
+ id: r,
1644
+ "aria-labelledby": `${r}-label`,
1645
+ "aria-describedby": i,
1646
+ options: Tr(n),
1647
+ value: e ?? null,
1648
+ onChange: (e) => {
1649
+ t(e ?? void 0);
1650
+ },
1651
+ isInvalid: a,
1652
+ isDisabled: o
1653
+ });
1654
+ }
1655
+ function Dr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1656
+ return /* @__PURE__ */ R(zn, {
1657
+ id: r,
1658
+ "aria-labelledby": `${r}-label`,
1659
+ "aria-describedby": i,
1660
+ options: Tr(n),
1661
+ value: e ?? null,
1662
+ onChange: t,
1663
+ isInvalid: a,
1664
+ isDisabled: o,
1665
+ orientation: Tr(n).length <= 3 ? "horizontal" : "vertical"
1666
+ });
1667
+ }
1668
+ function Or({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1669
+ let s = Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], c = Tr(n), l = n.children?.[0]?.kind === "enum";
1670
+ return /* @__PURE__ */ R(Fn, {
1671
+ id: r,
1672
+ "aria-labelledby": `${r}-label`,
1673
+ "aria-describedby": i,
1674
+ options: l ? c : s.map((e) => ({
1675
+ value: e,
1676
+ label: e
1677
+ })),
1678
+ values: s,
1679
+ onChange: (e) => {
1680
+ t(e.length === 0 && !n.required ? void 0 : e);
1681
+ },
1682
+ allowsCustomValue: !l,
1683
+ itemName: l ? "option" : "tag",
1684
+ isInvalid: a,
1685
+ isDisabled: o
1686
+ });
1687
+ }
1688
+ function kr({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
1689
+ let [s, c] = d(() => Ve(e)), [l, u] = d(null), f = `${r}-yaml`;
1690
+ return /* @__PURE__ */ z(L, { children: [
1691
+ /* @__PURE__ */ R("textarea", {
1692
+ id: r,
1693
+ rows: Math.min(12, Math.max(3, s.split("\n").length + 1)),
1694
+ value: s,
1695
+ spellCheck: !1,
1696
+ onChange: (e) => {
1697
+ c(e.target.value);
1698
+ let n = Ze(e.target.value);
1699
+ n.ok ? (u(null), t(n.value)) : u(n.message);
1700
+ },
1701
+ "aria-describedby": [
1702
+ i,
1703
+ `${r}-raw`,
1704
+ l ? f : void 0
1705
+ ].filter(Boolean).join(" "),
1706
+ "aria-invalid": a || l !== null || void 0,
1707
+ "aria-required": n.required || void 0,
1708
+ disabled: o,
1709
+ className: V(Z, "resize-y font-mono text-small")
1710
+ }),
1711
+ /* @__PURE__ */ z("p", {
1712
+ id: `${r}-raw`,
1713
+ className: "text-small text-content-muted",
1714
+ children: ["Edited as YAML", n.unknownReason ? `: Vesper has no control for this ${n.unknownReason} field.` : "."]
1715
+ }),
1716
+ l && /* @__PURE__ */ R("p", {
1717
+ id: f,
1718
+ className: "text-small text-danger",
1719
+ children: l
1720
+ })
1721
+ ] });
1722
+ }
1723
+ //#endregion
1724
+ //#region src/widgets/geo.tsx
1725
+ var Ar = i(() => import("./geo-map-CT3OGD7O.js"));
1726
+ function jr(e) {
1727
+ if (!B(e)) return {};
1728
+ let { lat: t, lng: n } = e;
1729
+ return {
1730
+ ...typeof t == "number" ? { lat: t } : {},
1731
+ ...typeof n == "number" ? { lng: n } : {}
1732
+ };
1733
+ }
1734
+ function Mr({ value: e, onChange: n, field: r, id: i, disabled: a, invalid: o, describedBy: s }) {
1735
+ let c = jr(e), [l, u] = d(!1), f = (t, i) => {
1736
+ let a = {
1737
+ ...B(e) ? e : {},
1738
+ [t]: i
1739
+ };
1740
+ i === void 0 && Reflect.deleteProperty(a, t), n(Object.keys(a).length === 0 && !r.required ? void 0 : a);
1741
+ }, p = r.widgetOptions;
1742
+ return /* @__PURE__ */ z("div", {
1743
+ className: "flex flex-col gap-3",
1744
+ children: [/* @__PURE__ */ z("div", {
1745
+ className: "flex flex-wrap gap-4",
1746
+ children: [/* @__PURE__ */ R(Nr, {
1747
+ id: i,
1748
+ label: "Latitude",
1749
+ hint: "−90 to 90, north is positive",
1750
+ value: c.lat,
1751
+ min: -90,
1752
+ max: 90,
1753
+ onChange: (e) => {
1754
+ f("lat", e);
1755
+ },
1756
+ disabled: a,
1757
+ invalid: o,
1758
+ describedBy: s
1759
+ }), /* @__PURE__ */ R(Nr, {
1760
+ id: `${i}-lng`,
1761
+ label: "Longitude",
1762
+ hint: "−180 to 180, east is positive",
1763
+ value: c.lng,
1764
+ min: -180,
1765
+ max: 180,
1766
+ onChange: (e) => {
1767
+ f("lng", e);
1768
+ },
1769
+ disabled: a,
1770
+ invalid: o,
1771
+ describedBy: s
1772
+ })]
1773
+ }), l ? /* @__PURE__ */ R(t, {
1774
+ fallback: /* @__PURE__ */ R("p", {
1775
+ className: "text-small text-content-muted",
1776
+ children: "Loading the map…"
1777
+ }),
1778
+ children: /* @__PURE__ */ R(Ar, {
1779
+ label: r.label,
1780
+ point: c.lat !== void 0 && c.lng !== void 0 ? c : null,
1781
+ center: p?.defaultCenter,
1782
+ zoom: p?.zoom,
1783
+ disabled: a,
1784
+ onChange: (t) => {
1785
+ n({
1786
+ ...B(e) ? e : {},
1787
+ lat: t.lat,
1788
+ lng: t.lng
1789
+ });
1790
+ }
1791
+ })
1792
+ }) : /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
1793
+ variant: "quiet",
1794
+ onPress: () => {
1795
+ u(!0);
1796
+ },
1797
+ children: "Show on a map"
1798
+ }) })]
1799
+ });
1800
+ }
1801
+ function Nr({ id: e, label: t, hint: n, value: r, min: i, max: a, onChange: o, disabled: s, invalid: c, describedBy: l }) {
1802
+ let [u, f] = d(r === void 0 ? "" : String(r)), [p, m] = d(r);
1803
+ return r !== p && (m(r), f(r === void 0 ? "" : String(r))), /* @__PURE__ */ z("div", {
1804
+ className: "flex flex-col gap-1",
1805
+ children: [
1806
+ /* @__PURE__ */ R("label", {
1807
+ htmlFor: e,
1808
+ className: "text-small text-content",
1809
+ children: t
1810
+ }),
1811
+ /* @__PURE__ */ R("input", {
1812
+ id: e,
1813
+ type: "number",
1814
+ inputMode: "decimal",
1815
+ step: "any",
1816
+ min: i,
1817
+ max: a,
1818
+ value: u,
1819
+ onChange: (e) => {
1820
+ f(e.target.value);
1821
+ let t = e.target.value === "" ? void 0 : e.target.valueAsNumber;
1822
+ (t === void 0 || Number.isFinite(t)) && (m(t), o(t));
1823
+ },
1824
+ "aria-describedby": [l, `${e}-hint`].filter(Boolean).join(" "),
1825
+ "aria-invalid": c || void 0,
1826
+ disabled: s,
1827
+ className: V(Z, "w-44")
1828
+ }),
1829
+ /* @__PURE__ */ R("p", {
1830
+ id: `${e}-hint`,
1831
+ className: "text-small text-content-muted",
1832
+ children: n
1833
+ })
1834
+ ]
1835
+ });
1836
+ }
1837
+ //#endregion
1838
+ //#region src/app/file-url.tsx
1839
+ function Pr(e) {
1840
+ let { api: t } = J(), [n, r] = d(null);
1841
+ return s(() => {
1842
+ if (!e) return;
1843
+ let n = !0;
1844
+ return t.fileUrl(e).then((t) => {
1845
+ n && r({
1846
+ path: e,
1847
+ url: t
1848
+ });
1849
+ }, () => {}), () => {
1850
+ n = !1;
1851
+ };
1852
+ }, [t, e]), e && n?.path === e ? n.url : "";
1853
+ }
1854
+ function Fr({ path: e, className: t, loading: n }) {
1855
+ let r = Pr(e);
1856
+ return r ? /* @__PURE__ */ R("img", {
1857
+ src: r,
1858
+ alt: "",
1859
+ loading: n,
1860
+ className: t
1861
+ }) : /* @__PURE__ */ R("span", {
1862
+ "aria-hidden": "true",
1863
+ className: t
1864
+ });
1865
+ }
1866
+ //#endregion
1867
+ //#region src/editor/reveal.ts
1868
+ var Ir = "vesper:reveal";
1869
+ function Lr(e) {
1870
+ return e.closest("[hidden], [inert]") !== null;
1871
+ }
1872
+ function Rr(e, t = 20, n = !1) {
1873
+ let r = document.getElementById(e);
1874
+ r && !Lr(r) ? (r.scrollIntoView({ block: "center" }), r.focus()) : (r && !n && (r.dispatchEvent(new CustomEvent(Ir, { bubbles: !0 })), n = !0), t > 0 && setTimeout(() => {
1875
+ Rr(e, t - 1, n);
1876
+ }, 25));
1877
+ }
1878
+ //#endregion
1879
+ //#region src/widgets/union.tsx
1880
+ function zr(e, t) {
1881
+ return {
1882
+ [e.discriminator ?? ""]: t.value,
1883
+ ...mr(t.children)
1884
+ };
1885
+ }
1886
+ function Br(e) {
1887
+ return e == null || e === "" ? !0 : Array.isArray(e) ? e.length === 0 : B(e) && Object.values(e).every(Br);
1888
+ }
1889
+ function Vr(e, t, n, r) {
1890
+ let i = e.discriminator ?? "", a = ot(e, t), o = B(t) ? t : {}, s = mr(n.children), c = { [i]: n.value }, l = [];
1891
+ for (let e of n.children) {
1892
+ let t = Y(e), n = a?.children.find((e) => Y(e) === t), i = !a || n?.kind === e.kind ? o[t] : void 0;
1893
+ i === void 0 ? r?.[t] === void 0 ? s[t] !== void 0 && (c[t] = s[t]) : c[t] = r[t] : (c[t] = i, Br(i) || l.push(e.label));
1894
+ }
1895
+ return {
1896
+ value: c,
1897
+ kept: l,
1898
+ dropped: Object.keys(o).filter((e) => e !== i && !(e in c) && !Br(o[e])).map((e) => a?.children.find((t) => Y(t) === e)?.label ?? We(e))
1899
+ };
1900
+ }
1901
+ function Hr(e) {
1902
+ let t = (e) => e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1) ?? ""}`;
1903
+ return [e.kept.length > 0 ? `${t(e.kept)} kept.` : "", e.dropped.length > 0 ? `${t(e.dropped)} removed.` : ""].filter(Boolean).join(" ");
1904
+ }
1905
+ var Ur = [
1906
+ "title",
1907
+ "name",
1908
+ "label",
1909
+ "heading",
1910
+ "text"
1911
+ ], Wr = (e) => e.replace(/[*_`]/g, "").trim();
1912
+ function Gr(e, t) {
1913
+ let n = ot(t, e);
1914
+ if (!n) {
1915
+ let n = B(e) ? e[t.discriminator ?? ""] : void 0;
1916
+ return {
1917
+ name: typeof n == "string" && n ? `Unknown kind: ${n}` : "No kind",
1918
+ detail: ""
1919
+ };
1920
+ }
1921
+ if (!B(e)) return {
1922
+ name: n.label,
1923
+ detail: ""
1924
+ };
1925
+ let r = n.children.filter((e) => !e.hidden);
1926
+ for (let t of [
1927
+ n.summary,
1928
+ ...Ur,
1929
+ ...r.map(Y)
1930
+ ]) {
1931
+ let r = t ? e[t] : void 0;
1932
+ if (typeof r == "string" && Wr(r)) return {
1933
+ name: n.label,
1934
+ detail: Wr(r)
1935
+ };
1936
+ }
1937
+ let i = r.find((e) => e.kind === "array");
1938
+ if (i) {
1939
+ let t = e[Y(i)], r = i.label.toLowerCase(), a = /[^s]s$/.test(r) ? r.slice(0, -1) : r;
1940
+ return {
1941
+ name: n.label,
1942
+ detail: sr(Array.isArray(t) ? t.length : 0, a, r)
1943
+ };
1944
+ }
1945
+ return {
1946
+ name: n.label,
1947
+ detail: ""
1948
+ };
1949
+ }
1950
+ function Kr({ kind: e, path: t }) {
1951
+ return /* @__PURE__ */ R("div", {
1952
+ className: "flex flex-col gap-4",
1953
+ children: e.children.filter((e) => !e.hidden).map((e) => /* @__PURE__ */ R(Va, {
1954
+ field: e,
1955
+ path: [...t, Y(e)]
1956
+ }, Y(e)))
1957
+ });
1958
+ }
1959
+ var qr = "";
1960
+ function Jr(e) {
1961
+ let { value: t, onChange: n, field: r, path: i, id: a, describedBy: o, invalid: s, disabled: c, inRow: l } = e, d = u(/* @__PURE__ */ new Map()), f = ot(r, t), p = r.variants ?? [], m = f ? f.children.length > 0 ? /* @__PURE__ */ R(Kr, {
1962
+ kind: f,
1963
+ path: i
1964
+ }) : l ? /* @__PURE__ */ R("p", {
1965
+ className: "text-small text-content-muted",
1966
+ children: "This kind has nothing more to fill in."
1967
+ }) : null : t != null && !f ? /* @__PURE__ */ z("div", {
1968
+ className: "flex flex-col gap-2",
1969
+ children: [
1970
+ /* @__PURE__ */ R("label", {
1971
+ htmlFor: `${a}-yaml`,
1972
+ className: "text-label text-content",
1973
+ children: Gr(t, r).name
1974
+ }),
1975
+ /* @__PURE__ */ R("p", {
1976
+ id: `${a}-unknown`,
1977
+ className: "text-small text-content-muted",
1978
+ children: "The site has no kind by this name. Change it to one it has, or edit it here."
1979
+ }),
1980
+ /* @__PURE__ */ R(kr, {
1981
+ value: t,
1982
+ onChange: n,
1983
+ field: {
1984
+ ...r,
1985
+ unknownReason: void 0
1986
+ },
1987
+ id: `${a}-yaml`,
1988
+ describedBy: [o, `${a}-unknown`].filter(Boolean).join(" "),
1989
+ invalid: s,
1990
+ disabled: c
1991
+ })
1992
+ ]
1993
+ }) : null;
1994
+ if (l) return m;
1995
+ let h = (e) => {
1996
+ f && d.current.set(f.value, B(t) ? t : {});
1997
+ let i = p.find((t) => t.value === e);
1998
+ n(i ? Vr(r, t, i, d.current.get(i.value)).value : void 0);
1999
+ }, g = [...r.required ? [] : [{
2000
+ value: qr,
2001
+ label: "None"
2002
+ }], ...p.map((e) => ({
2003
+ value: e.value,
2004
+ label: e.label
2005
+ }))], _ = f ? f.value : t === void 0 ? qr : null, v = g.length <= 4 ? /* @__PURE__ */ R(zn, {
2006
+ id: `${a}-kind`,
2007
+ label: "Kind",
2008
+ options: g,
2009
+ value: _,
2010
+ onChange: h,
2011
+ isDisabled: c,
2012
+ orientation: g.length <= 3 ? "horizontal" : "vertical"
2013
+ }) : /* @__PURE__ */ R(Nn, {
2014
+ id: `${a}-kind`,
2015
+ label: "Kind",
2016
+ options: g,
2017
+ value: _,
2018
+ onChange: (e) => {
2019
+ h(e ?? qr);
2020
+ },
2021
+ isDisabled: c
2022
+ });
2023
+ return /* @__PURE__ */ z("div", {
2024
+ className: "flex flex-col gap-4",
2025
+ children: [
2026
+ v,
2027
+ f?.description && /* @__PURE__ */ R("p", {
2028
+ className: "text-small text-content-muted",
2029
+ children: f.description
2030
+ }),
2031
+ m
2032
+ ]
2033
+ });
2034
+ }
2035
+ //#endregion
2036
+ //#region src/widgets/group.tsx
2037
+ function Yr({ field: e, path: t }) {
2038
+ let n = (e.children ?? []).filter((e) => !e.hidden);
2039
+ return /* @__PURE__ */ R("div", {
2040
+ className: "flex flex-col gap-4",
2041
+ children: n.map((e) => /* @__PURE__ */ R(Va, {
2042
+ field: e,
2043
+ path: [...t, Y(e)]
2044
+ }, Y(e)))
2045
+ });
2046
+ }
2047
+ function Xr(e) {
2048
+ let t = e.children?.[0], n = e.label.toLowerCase(), r = t?.label && t.label !== "[]" && t.label !== "Item" ? t.label : "";
2049
+ return {
2050
+ one: r ? r.toLowerCase() : /[^s]s$/.test(n) ? n.slice(0, -1) : n,
2051
+ many: n
2052
+ };
2053
+ }
2054
+ var Zr = (e) => e.charAt(0).toLocaleUpperCase() + e.slice(1), Qr = [
2055
+ "title",
2056
+ "name",
2057
+ "label",
2058
+ "heading",
2059
+ "text"
2060
+ ];
2061
+ function $r(e) {
2062
+ return e?.kind === "image" || e?.widget === "image" || e?.inferredWidget === "image";
2063
+ }
2064
+ function ei(e) {
2065
+ return e.slice(e.lastIndexOf("/") + 1);
2066
+ }
2067
+ function ti(e) {
2068
+ let t = B(e) ? e.src : e;
2069
+ return typeof t == "string" ? t : "";
2070
+ }
2071
+ var ni = (e) => e.replace(/[*_`]/g, "").trim();
2072
+ function ri(e, t, n) {
2073
+ let r = {
2074
+ name: `${Zr(Xr(n).one)} ${String(t + 1)}`,
2075
+ key: void 0
2076
+ };
2077
+ if (typeof e == "string") return e.trim() ? {
2078
+ name: ni(e),
2079
+ key: void 0
2080
+ } : r;
2081
+ if ($r(n.children?.[0])) {
2082
+ let t = B(e) && typeof e.alt == "string" ? e.alt.trim() : "", n = ti(e);
2083
+ return t ? {
2084
+ name: t,
2085
+ key: "alt"
2086
+ } : n ? {
2087
+ name: ei(n),
2088
+ key: "src"
2089
+ } : r;
2090
+ }
2091
+ if (!B(e)) return r;
2092
+ let i = (n.children?.[0]?.children ?? []).filter((e) => !e.hidden).map(Y);
2093
+ for (let t of [
2094
+ n.summary,
2095
+ ...Qr,
2096
+ ...i
2097
+ ]) {
2098
+ if (!t) continue;
2099
+ let n = e[t];
2100
+ if (typeof n == "string" && n.trim()) return {
2101
+ name: ni(n),
2102
+ key: t
2103
+ };
2104
+ }
2105
+ return r;
2106
+ }
2107
+ function ii(e, t, n) {
2108
+ if (!B(e)) return "";
2109
+ let r = t.children ?? [], i = r.find((e) => e.kind === "array" && !e.hidden);
2110
+ if (i) {
2111
+ let t = e[Y(i)], { one: n, many: r } = Xr(i);
2112
+ return sr(Array.isArray(t) ? t.length : 0, n, r);
2113
+ }
2114
+ for (let t of r) {
2115
+ let r = Y(t), i = e[r];
2116
+ if (r !== n && !t.hidden && typeof i == "string" && i.trim()) return ni(i);
2117
+ }
2118
+ return "";
2119
+ }
2120
+ function ai(e, t) {
2121
+ if (!e) return 0;
2122
+ let n = 0;
2123
+ for (let [r, i] of e) (r === t || r.startsWith(`${t}.`)) && i.length > 0 && (n += i.length);
2124
+ return n;
2125
+ }
2126
+ function oi(e) {
2127
+ return e ? e.default !== void 0 && !e.defaultDynamic ? structuredClone(e.default) : e.kind === "object" ? {} : e.kind === "boolean" ? !1 : e.kind === "array" ? [] : e.kind === "number" ? 0 : "" : null;
2128
+ }
2129
+ var si = 0, ci = () => `item${String(++si)}`, li = "application/x-vesper-list-item";
2130
+ function ui(e) {
2131
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1) ?? ""}`;
2132
+ }
2133
+ function di({ value: e, onChange: t, field: n, path: r, disabled: i, id: a }) {
2134
+ let o = X(), c = Array.isArray(e) ? e : [], l = n.children?.[0], f = Xr(n), p = l?.kind === "union" ? l.variants ?? [] : null, m = l?.kind === "object" || p !== null || $r(l), h = n.constraints?.max, g = h !== void 0 && c.length >= h, _ = u(null), v = u(null), y = u(/* @__PURE__ */ new Map()), [b, x] = d(null), [S, C] = d(() => c.map(() => ci())), w = S;
2135
+ S.length !== c.length && (w = c.map((e, t) => S[t] ?? ci()), C(w));
2136
+ let [T, E] = d(() => /* @__PURE__ */ new Set()), [D, ee] = d(null), O = (e, t) => {
2137
+ E((n) => {
2138
+ if (n.has(e) === t) return n;
2139
+ let r = new Set(n);
2140
+ return t ? r.add(e) : r.delete(e), r;
2141
+ });
2142
+ }, [k, te] = d(o.issues);
2143
+ if (k !== o.issues) {
2144
+ te(o.issues);
2145
+ let e = w.filter((e, t) => ai(o.issues, pr([...r, t])) > 0);
2146
+ e.length > 0 && E((t) => /* @__PURE__ */ new Set([...t, ...e]));
2147
+ }
2148
+ s(() => {
2149
+ let e = v.current;
2150
+ if (!e) return;
2151
+ let t = (t) => {
2152
+ let n = t.target, r = [...e.children].findIndex((e) => e.contains(n)), i = w[r];
2153
+ i && E((e) => e.has(i) ? e : /* @__PURE__ */ new Set([...e, i]));
2154
+ };
2155
+ return e.addEventListener(Ir, t), () => {
2156
+ e.removeEventListener(Ir, t);
2157
+ };
2158
+ }, [w]);
2159
+ let A = (e) => {
2160
+ _.current && (_.current.textContent = e);
2161
+ }, j = (e) => {
2162
+ setTimeout(() => {
2163
+ e()?.focus();
2164
+ }, 0);
2165
+ }, ne = (e) => document.getElementById(`${a}-more-${e}`)?.querySelector("button") ?? null, M = (e) => () => m ? document.getElementById(`${a}-row-${e}`) : ne(e), N = (e) => {
2166
+ t(e.length === 0 && !n.required ? void 0 : e);
2167
+ }, P = (e, t) => {
2168
+ if (p && l) return Gr(e, l);
2169
+ let { name: r, key: i } = ri(e, t, n);
2170
+ return {
2171
+ name: r,
2172
+ detail: l && m ? ii(e, l, i) : ""
2173
+ };
2174
+ }, F = (e) => P(c[e] ?? null, e).name, re = (e) => p?.find((t) => t.value === e), I = (e, t) => {
2175
+ if (t < 0 || t >= c.length || i) return;
2176
+ let n = F(e), r = [...c], [a] = r.splice(e, 1);
2177
+ r.splice(t, 0, a ?? null);
2178
+ let o = [...w], [s = ci()] = o.splice(e, 1);
2179
+ o.splice(t, 0, s), C(o), N(r), A(`Moved ${n} to position ${String(t + 1)} of ${String(r.length)}.`), j(M(s));
2180
+ }, ie = (e) => {
2181
+ if (g) return;
2182
+ let t = structuredClone(c[e] ?? null), n = ci();
2183
+ C([
2184
+ ...w.slice(0, e + 1),
2185
+ n,
2186
+ ...w.slice(e + 1)
2187
+ ]), N([
2188
+ ...c.slice(0, e + 1),
2189
+ t,
2190
+ ...c.slice(e + 1)
2191
+ ]), A(`Duplicated ${F(e)} as ${f.one} ${String(e + 2)}.`), j(M(n));
2192
+ }, ae = (e) => {
2193
+ let t = F(e), n = w.filter((t, n) => n !== e), r = c.filter((t, n) => n !== e);
2194
+ C(n), N(r), A(`Removed ${t}.`);
2195
+ let i = n[Math.min(e, r.length - 1)];
2196
+ j(i ? M(i) : () => document.getElementById(`${a}-add`));
2197
+ }, oe = (e, t) => {
2198
+ if (g || i) return;
2199
+ let n = ci();
2200
+ C([
2201
+ ...w.slice(0, e),
2202
+ n,
2203
+ ...w.slice(e)
2204
+ ]), m && O(n, !0);
2205
+ let r = t && l ? zr(l, t) : oi(l);
2206
+ N([
2207
+ ...c.slice(0, e),
2208
+ r,
2209
+ ...c.slice(e)
2210
+ ]);
2211
+ let o = `${f.one} ${String(e + 1)}`;
2212
+ A(t ? `Added ${t.label}, ${o} of ${String(c.length + 1)}.` : `Added ${o}.`), j(() => document.getElementById(`${a}-panel-${n}`)?.querySelector("input, textarea, [contenteditable=\"true\"], button") ?? M(n)());
2213
+ }, [se, ce] = d(null), [le, ue] = d(null), de = (e) => {
2214
+ let t = v.current, n = se === null ? -1 : w.indexOf(se);
2215
+ if (!t || n === -1) return null;
2216
+ let r = t.getBoundingClientRect(), i = [...t.children].map((e) => e.getBoundingClientRect()), a = i.findIndex((t) => r.top + e < t.top + t.height / 2), o = a === -1 ? i.length : a, s = i[o - 1], c = i[o];
2217
+ if (o === n || o === n + 1 || !s && !c) return null;
2218
+ let l = (Number.parseFloat(getComputedStyle(t).rowGap) || 0) / 2;
2219
+ return {
2220
+ slot: o,
2221
+ top: (s && c ? (s.bottom + c.top) / 2 : s ? s.bottom + l : (c?.top ?? 0) - l) - (t.parentElement?.getBoundingClientRect() ?? r).top
2222
+ };
2223
+ }, { dropProps: fe } = Ne({
2224
+ ref: v,
2225
+ isDisabled: se === null,
2226
+ hasDropButton: !0,
2227
+ getDropOperation: (e) => e.has(li) ? "move" : "cancel",
2228
+ onDropEnter: ({ y: e }) => {
2229
+ ue(de(e));
2230
+ },
2231
+ onDropMove: ({ y: e }) => {
2232
+ let t = de(e);
2233
+ ue((e) => e?.slot === t?.slot ? e : t);
2234
+ },
2235
+ onDropExit: () => {
2236
+ ue(null);
2237
+ },
2238
+ onDrop: ({ y: e }) => {
2239
+ let t = de(e), n = se === null ? -1 : w.indexOf(se);
2240
+ ue(null), t && n !== -1 && I(n, t.slot > n ? t.slot - 1 : t.slot);
2241
+ }
2242
+ }), pe = i ? void 0 : (e) => ({
2243
+ onStart: () => {
2244
+ ce(e);
2245
+ },
2246
+ onEnd: () => {
2247
+ ce(null), ue(null);
2248
+ }
2249
+ }), me = (e, t, n = !1) => {
2250
+ let r = w[e];
2251
+ if (!l || !r || i) return;
2252
+ let a = c[e] ?? null, o = y.current.get(r) ?? /* @__PURE__ */ new Map(), s = Vr(l, a, t, o.get(t.value));
2253
+ if (s.dropped.length > 0 && !n) {
2254
+ x({
2255
+ index: e,
2256
+ itemId: r,
2257
+ from: F(e),
2258
+ to: t,
2259
+ dropped: s.dropped
2260
+ });
2261
+ return;
2262
+ }
2263
+ let u = ot(l, a);
2264
+ u && B(a) && o.set(u.value, a), y.current.set(r, o), N(c.map((t, n) => n === e ? s.value : t)), A(`Changed to ${t.label}. ${Hr(s)}`.trim()), j(M(r));
2265
+ }, he = (e, t) => (p ?? []).filter((e) => e.value !== t).map((t) => ({
2266
+ id: `${e}:${t.value}`,
2267
+ label: t.label,
2268
+ ...t.description ? { description: t.description } : {}
2269
+ })), ge = (e) => {
2270
+ let t = [{
2271
+ id: "up",
2272
+ label: "Move up",
2273
+ icon: "move-up",
2274
+ isDisabled: i || e === 0
2275
+ }, {
2276
+ id: "down",
2277
+ label: "Move down",
2278
+ icon: "move-down",
2279
+ isDisabled: i || e === c.length - 1
2280
+ }], n = [{
2281
+ id: "duplicate",
2282
+ label: "Duplicate",
2283
+ icon: "duplicate",
2284
+ isDisabled: i || g
2285
+ }, {
2286
+ id: "remove",
2287
+ label: "Remove",
2288
+ icon: "delete",
2289
+ isDanger: !0,
2290
+ isDisabled: i
2291
+ }];
2292
+ if (!p || !l) return [...t, ...n];
2293
+ let [r] = p, a = p.length === 1 && r ? {
2294
+ id: `below:${r.value}`,
2295
+ label: "Add below",
2296
+ icon: "add"
2297
+ } : {
2298
+ id: "below",
2299
+ label: "Add below",
2300
+ icon: "add",
2301
+ items: he("below")
2302
+ }, o = he("change", ot(l, c[e] ?? null)?.value);
2303
+ return [
2304
+ ...t,
2305
+ {
2306
+ ...a,
2307
+ isDisabled: i || g
2308
+ },
2309
+ ...o.length > 0 ? [{
2310
+ id: "change",
2311
+ label: "Change to",
2312
+ icon: "change-kind",
2313
+ isDisabled: i,
2314
+ items: o
2315
+ }] : [],
2316
+ ...n
2317
+ ];
2318
+ }, _e = (e) => (t) => {
2319
+ t === "up" && I(e, e - 1), t === "down" && I(e, e + 1), t === "duplicate" && ie(e), t === "remove" && ae(e);
2320
+ let n = t.startsWith("below:") ? re(t.slice(6)) : void 0;
2321
+ n && oe(e + 1, n);
2322
+ let r = t.startsWith("change:") ? re(t.slice(7)) : void 0;
2323
+ r && me(e, r);
2324
+ }, ve = (e, t, n) => /* @__PURE__ */ R(fi, {
2325
+ id: `${a}-more-${t}`,
2326
+ label: `Actions for ${n}`,
2327
+ items: ge(e),
2328
+ onAction: _e(e),
2329
+ isOpen: D === t,
2330
+ onOpenChange: (e) => {
2331
+ ee(e ? t : null);
2332
+ }
2333
+ }), ye = `Add ${f.one}`, be = c.length > 0 && w.every((e) => T.has(e));
2334
+ return /* @__PURE__ */ z("div", {
2335
+ className: "relative flex flex-col gap-3",
2336
+ children: [
2337
+ m && c.length >= 3 && /* @__PURE__ */ R("div", {
2338
+ className: "-mt-1 flex justify-end",
2339
+ children: /* @__PURE__ */ R(K, {
2340
+ variant: "quiet",
2341
+ onPress: () => {
2342
+ E(be ? /* @__PURE__ */ new Set() : new Set(w));
2343
+ },
2344
+ children: be ? "Close all" : "Open all"
2345
+ })
2346
+ }),
2347
+ c.length === 0 && /* @__PURE__ */ R("p", {
2348
+ className: "text-small text-content-muted",
2349
+ children: "None yet."
2350
+ }),
2351
+ /* @__PURE__ */ R("ol", {
2352
+ ...fe,
2353
+ ref: v,
2354
+ className: V("flex flex-col", m ? "gap-2" : "gap-3"),
2355
+ children: c.map((e, t) => {
2356
+ let n = w[t] ?? String(t), { name: i, detail: s } = P(e, t), c = p && s ? `${i}, ${s}` : i;
2357
+ if (!l) return null;
2358
+ if (!m) return /* @__PURE__ */ z("li", {
2359
+ className: "flex items-end gap-2",
2360
+ children: [/* @__PURE__ */ R("div", {
2361
+ className: "min-w-0 flex-1",
2362
+ children: /* @__PURE__ */ R(Va, {
2363
+ field: l,
2364
+ path: [...r, t],
2365
+ label: `${Zr(f.one)} ${String(t + 1)}`,
2366
+ item: "inline"
2367
+ })
2368
+ }), ve(t, n, c)]
2369
+ }, n);
2370
+ let u = pr([...r, t]);
2371
+ return /* @__PURE__ */ R("li", { children: /* @__PURE__ */ R(hi, {
2372
+ id: a,
2373
+ itemId: n,
2374
+ name: i,
2375
+ detail: s,
2376
+ problems: ai(o.issues, u),
2377
+ notes: ai(o.notes, u),
2378
+ image: $r(l) ? ti(e) : null,
2379
+ headingLevel: r.length === 1 ? 3 : null,
2380
+ isOpen: T.has(n),
2381
+ onOpenChange: (e) => {
2382
+ O(n, e);
2383
+ },
2384
+ onKeyDown: (e) => {
2385
+ e.altKey && e.key === "ArrowUp" ? (e.preventDefault(), I(t, t - 1)) : e.altKey && e.key === "ArrowDown" ? (e.preventDefault(), I(t, t + 1)) : e.shiftKey && e.key === "F10" || e.key === "ContextMenu" ? (e.preventDefault(), ee(n)) : e.continuePropagation();
2386
+ },
2387
+ menu: ve(t, n, c),
2388
+ drag: pe?.(n),
2389
+ editor: o,
2390
+ children: /* @__PURE__ */ R(Va, {
2391
+ field: l,
2392
+ path: [...r, t],
2393
+ label: i,
2394
+ item: "row"
2395
+ })
2396
+ }) }, n);
2397
+ })
2398
+ }),
2399
+ le && /* @__PURE__ */ R("span", {
2400
+ "aria-hidden": "true",
2401
+ className: "pointer-events-none absolute inset-x-0 h-0.5 -translate-y-1/2 rounded-full bg-accent",
2402
+ style: { top: le.top }
2403
+ }),
2404
+ /* @__PURE__ */ z("div", {
2405
+ className: "flex flex-col items-start gap-1",
2406
+ children: [p && p.length > 1 ? /* @__PURE__ */ R(On, {
2407
+ label: ye,
2408
+ trigger: /* @__PURE__ */ R(K, {
2409
+ id: `${a}-add`,
2410
+ icon: "add",
2411
+ isDisabled: i || g,
2412
+ children: ye
2413
+ }),
2414
+ items: he("add"),
2415
+ onAction: (e) => {
2416
+ let t = re(e.slice(4));
2417
+ t && oe(c.length, t);
2418
+ }
2419
+ }) : /* @__PURE__ */ R(K, {
2420
+ id: `${a}-add`,
2421
+ icon: "add",
2422
+ isDisabled: i || g,
2423
+ onPress: () => {
2424
+ oe(c.length, p?.[0]);
2425
+ },
2426
+ children: ye
2427
+ }), g && /* @__PURE__ */ z("p", {
2428
+ className: "text-small text-content-muted",
2429
+ children: [
2430
+ "At most ",
2431
+ sr(h, f.one, f.many),
2432
+ "."
2433
+ ]
2434
+ })]
2435
+ }),
2436
+ /* @__PURE__ */ R("p", {
2437
+ ref: _,
2438
+ role: "status",
2439
+ className: "sr-only"
2440
+ }),
2441
+ /* @__PURE__ */ R(Sn, {
2442
+ title: b ? `Change ${b.from} to ${b.to.label}?` : "",
2443
+ role: "alertdialog",
2444
+ isOpen: b !== null,
2445
+ onOpenChange: (e) => {
2446
+ e || x(null);
2447
+ },
2448
+ children: b && /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("p", {
2449
+ className: "mb-6",
2450
+ children: [
2451
+ ui(b.dropped),
2452
+ " ",
2453
+ b.dropped.length === 1 ? "has" : "have",
2454
+ " no place in",
2455
+ " ",
2456
+ b.to.label,
2457
+ ", so ",
2458
+ b.dropped.length === 1 ? "it is" : "they are",
2459
+ " removed. Changing back before you save brings ",
2460
+ b.dropped.length === 1 ? "it" : "them",
2461
+ " ",
2462
+ "back."
2463
+ ]
2464
+ }), /* @__PURE__ */ z("div", {
2465
+ className: "flex flex-wrap justify-end gap-3",
2466
+ children: [/* @__PURE__ */ R(K, {
2467
+ onPress: () => {
2468
+ x(null), j(M(b.itemId));
2469
+ },
2470
+ children: "Cancel"
2471
+ }), /* @__PURE__ */ z(K, {
2472
+ variant: "danger",
2473
+ onPress: () => {
2474
+ x(null), me(b.index, b.to, !0);
2475
+ },
2476
+ children: ["Change to ", b.to.label]
2477
+ })]
2478
+ })] })
2479
+ })
2480
+ ]
2481
+ });
2482
+ }
2483
+ function fi(e) {
2484
+ let { id: t, ...n } = e;
2485
+ return /* @__PURE__ */ R("span", {
2486
+ id: t,
2487
+ className: "flex shrink-0",
2488
+ children: /* @__PURE__ */ R(On, { ...n })
2489
+ });
2490
+ }
2491
+ function pi({ src: e, entryPath: t }) {
2492
+ let n = Pr(e ? et(e, t) : null);
2493
+ return n ? /* @__PURE__ */ R("img", {
2494
+ src: n,
2495
+ alt: "",
2496
+ className: "size-10 shrink-0 rounded-sm object-cover"
2497
+ }) : /* @__PURE__ */ R("span", {
2498
+ "aria-hidden": "true",
2499
+ className: "size-10 shrink-0 rounded-sm bg-surface-sunken"
2500
+ });
2501
+ }
2502
+ function mi({ dragProps: e, header: t }) {
2503
+ return /* @__PURE__ */ R("span", {
2504
+ ...e,
2505
+ "aria-hidden": "true",
2506
+ onDragStart: (n) => {
2507
+ e.onDragStart?.(n);
2508
+ let r = t.current;
2509
+ if (!r || n.defaultPrevented) return;
2510
+ let i = r.getBoundingClientRect();
2511
+ n.dataTransfer.setDragImage(r, n.clientX - i.left, n.clientY - i.top);
2512
+ },
2513
+ className: "ml-1 inline-flex size-8 shrink-0 cursor-grab items-center justify-center rounded-md text-content-muted hover:text-content active:cursor-grabbing",
2514
+ children: /* @__PURE__ */ R(G, { name: "drag" })
2515
+ });
2516
+ }
2517
+ function hi({ id: e, itemId: t, name: n, detail: r, problems: i, notes: a, image: o, headingLevel: s, isOpen: c, onOpenChange: l, onKeyDown: d, menu: p, drag: m, editor: h, children: g }) {
2518
+ let _ = u(null), { dragProps: v, isDragging: y } = je({
2519
+ isDisabled: !m,
2520
+ hasDragButton: !0,
2521
+ getItems: () => [{ [li]: t }],
2522
+ getAllowedDropOperations: () => ["move"],
2523
+ onDragStart: () => m?.onStart(),
2524
+ onDragEnd: () => m?.onEnd()
2525
+ }), S = /* @__PURE__ */ z(f, {
2526
+ slot: "trigger",
2527
+ id: `${e}-row-${t}`,
2528
+ onKeyDown: d,
2529
+ className: V("flex min-h-11 w-full min-w-0 items-center gap-2 rounded-md py-1 pl-2 text-left text-body text-content", H),
2530
+ children: [
2531
+ /* @__PURE__ */ R(q, { className: "shrink-0 -rotate-90 group-data-[expanded]:rotate-0" }),
2532
+ o !== null && /* @__PURE__ */ R(pi, {
2533
+ src: o,
2534
+ entryPath: h.entryPath
2535
+ }),
2536
+ /* @__PURE__ */ R("span", {
2537
+ className: "max-w-2/3 min-w-0 shrink-0 truncate",
2538
+ children: n
2539
+ }),
2540
+ r && /* @__PURE__ */ z("span", {
2541
+ className: "min-w-0 flex-1 truncate text-small text-content-muted",
2542
+ children: [
2543
+ /* @__PURE__ */ R("span", {
2544
+ className: "sr-only",
2545
+ children: ","
2546
+ }),
2547
+ " ",
2548
+ r
2549
+ ]
2550
+ }),
2551
+ i > 0 && /* @__PURE__ */ z("span", {
2552
+ className: "shrink-0 text-small text-danger",
2553
+ children: [
2554
+ /* @__PURE__ */ R("span", {
2555
+ className: "sr-only",
2556
+ children: ","
2557
+ }),
2558
+ " ",
2559
+ sr(i, "problem", "problems")
2560
+ ]
2561
+ }),
2562
+ a > 0 && /* @__PURE__ */ z("span", {
2563
+ className: "shrink-0 text-small text-content-muted",
2564
+ children: [
2565
+ /* @__PURE__ */ R("span", {
2566
+ className: "sr-only",
2567
+ children: ","
2568
+ }),
2569
+ " ",
2570
+ sr(a, "note", "notes")
2571
+ ]
2572
+ })
2573
+ ]
2574
+ });
2575
+ return /* @__PURE__ */ z(b, {
2576
+ id: t,
2577
+ isExpanded: c,
2578
+ onExpandedChange: l,
2579
+ className: V("group rounded-md border border-border bg-surface-raised", y && "opacity-50"),
2580
+ children: [/* @__PURE__ */ z("div", {
2581
+ ref: _,
2582
+ className: V("flex items-center gap-1 rounded-md bg-surface-raised pr-1", !c && "hover:bg-surface-sunken"),
2583
+ children: [
2584
+ m && /* @__PURE__ */ R(mi, {
2585
+ dragProps: v,
2586
+ header: _
2587
+ }),
2588
+ s ? /* @__PURE__ */ R(T, {
2589
+ level: s,
2590
+ className: "m-0 min-w-0 flex-1",
2591
+ children: S
2592
+ }) : /* @__PURE__ */ R("div", {
2593
+ className: "min-w-0 flex-1",
2594
+ children: S
2595
+ }),
2596
+ p
2597
+ ]
2598
+ }), /* @__PURE__ */ R(x, { children: /* @__PURE__ */ R("div", {
2599
+ id: `${e}-panel-${t}`,
2600
+ className: "border-t border-border px-4 pt-3 pb-4",
2601
+ children: g
2602
+ }) })]
2603
+ });
2604
+ }
2605
+ //#endregion
2606
+ //#region src/widgets/icon.tsx
2607
+ function gi({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
2608
+ let { manifest: s } = J(), c = l(() => {
2609
+ let e = s.icons ?? {};
2610
+ return (n.constraints?.options ?? []).map((t) => {
2611
+ let n = Object.hasOwn(e, t.value) ? e[t.value] : void 0;
2612
+ return {
2613
+ ...t,
2614
+ prefix: n ? /* @__PURE__ */ R(G, { node: n }) : /* @__PURE__ */ R("span", { className: "block size-5" })
2615
+ };
2616
+ });
2617
+ }, [n, s.icons]);
2618
+ return /* @__PURE__ */ R(Pn, {
2619
+ id: r,
2620
+ "aria-labelledby": `${r}-label`,
2621
+ "aria-describedby": i,
2622
+ options: c,
2623
+ value: typeof e == "string" ? e : null,
2624
+ onChange: (e) => {
2625
+ t(e ?? void 0);
2626
+ },
2627
+ placeholder: "Search icons",
2628
+ isRequired: n.required,
2629
+ isInvalid: a,
2630
+ isDisabled: o
2631
+ });
2632
+ }
2633
+ //#endregion
2634
+ //#region src/a11y/FieldNotes.tsx
2635
+ function _i({ note: e }) {
2636
+ return /* @__PURE__ */ z(L, { children: [
2637
+ e.subject ? `${e.subject}: ` : "",
2638
+ e.message,
2639
+ " ",
2640
+ /* @__PURE__ */ R("span", {
2641
+ className: "text-content-muted",
2642
+ children: e.why
2643
+ })
2644
+ ] });
2645
+ }
2646
+ function vi({ id: e, notes: t }) {
2647
+ return /* @__PURE__ */ R("ul", {
2648
+ id: e,
2649
+ className: "m-0 flex list-none flex-col gap-1 p-0",
2650
+ children: t.map((e, t) => /* @__PURE__ */ R("li", {
2651
+ className: "flex gap-2 text-small text-content",
2652
+ children: /* @__PURE__ */ R(bi, { children: /* @__PURE__ */ R(_i, { note: e }) })
2653
+ }, `${e.rule}:${String(t)}`))
2654
+ });
2655
+ }
2656
+ function yi({ id: e, children: t }) {
2657
+ return /* @__PURE__ */ R("p", {
2658
+ id: e,
2659
+ className: "flex gap-2 text-small text-content",
2660
+ children: /* @__PURE__ */ R(bi, { children: t })
2661
+ });
2662
+ }
2663
+ function bi({ children: e }) {
2664
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(G, {
2665
+ name: "warning",
2666
+ size: 16,
2667
+ className: "mt-0.5 text-warning"
2668
+ }), /* @__PURE__ */ z("span", { children: [/* @__PURE__ */ R("span", {
2669
+ className: "font-semibold",
2670
+ children: "Accessibility note: "
2671
+ }), e] })] });
2672
+ }
2673
+ //#endregion
2674
+ //#region src/media/formats.ts
2675
+ var Q = (e, t, n) => String.fromCharCode(...e.subarray(t, t + n));
2676
+ function xi(e) {
2677
+ if (e[0] === 255 && e[1] === 216 && e[2] === 255) return "jpeg";
2678
+ if (Q(e, 0, 8) === "‰PNG\r\n\n") return "png";
2679
+ if (Q(e, 0, 4) === "GIF8") return "gif";
2680
+ if (Q(e, 0, 4) === "RIFF" && Q(e, 8, 4) === "WEBP") return "webp";
2681
+ if (Q(e, 0, 5) === "%PDF-") return "pdf";
2682
+ if (Q(e, 4, 4) === "ftyp") {
2683
+ let t = $(e).getUint32(0), n = [Q(e, 8, 4)];
2684
+ for (let r = 16; r + 4 <= Math.min(t, e.length); r += 4) n.push(Q(e, r, 4));
2685
+ if (n.some((e) => e === "avif" || e === "avis")) return "avif";
2686
+ if (n.some((e) => [
2687
+ "heic",
2688
+ "heix",
2689
+ "hevc",
2690
+ "hevx",
2691
+ "heim",
2692
+ "heis",
2693
+ "mif1",
2694
+ "msf1"
2695
+ ].includes(e))) return "heic";
2696
+ }
2697
+ let t = new TextDecoder().decode(e.subarray(0, 1024)).replace(/^\uFEFF/, "").trimStart();
2698
+ return /^(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*(<!DOCTYPE svg[^>]*>\s*)?<svg[\s>]/i.test(t) ? "svg" : "other";
2699
+ }
2700
+ function $(e) {
2701
+ return new DataView(e.buffer, e.byteOffset, e.byteLength);
2702
+ }
2703
+ function Si(e) {
2704
+ let t = [], n = 2;
2705
+ for (; n + 4 <= e.length && e[n] === 255;) {
2706
+ let r = e[n + 1] ?? 0;
2707
+ if (r === 255) {
2708
+ n += 1;
2709
+ continue;
2710
+ }
2711
+ let i = $(e).getUint16(n + 2), a = n + 2 + i;
2712
+ if (r === 218) return {
2713
+ segments: t,
2714
+ dataStart: n
2715
+ };
2716
+ t.push({
2717
+ marker: r,
2718
+ start: n,
2719
+ end: a
2720
+ }), n = a;
2721
+ }
2722
+ return {
2723
+ segments: t,
2724
+ dataStart: n
2725
+ };
2726
+ }
2727
+ function Ci(e) {
2728
+ if (e.length < 8) return { hasLocation: !1 };
2729
+ let t = Q(e, 0, 2) === "II", n = $(e), r = (e) => n.getUint16(e, t), i = ((e) => n.getUint32(e, t))(4);
2730
+ if (i + 2 > e.length) return { hasLocation: !1 };
2731
+ let a, o = !1, s = r(i);
2732
+ for (let t = 0; t < s; t++) {
2733
+ let n = i + 2 + t * 12;
2734
+ if (n + 12 > e.length) break;
2735
+ let s = r(n);
2736
+ s === 274 && (a = r(n + 8)), s === 34853 && (o = !0);
2737
+ }
2738
+ return {
2739
+ ...a === void 0 ? {} : { orientation: a },
2740
+ hasLocation: o
2741
+ };
2742
+ }
2743
+ var wi = /* @__PURE__ */ new Set([
2744
+ 224,
2745
+ 226,
2746
+ 238
2747
+ ]);
2748
+ function Ti(e) {
2749
+ let t = {
2750
+ hasLocation: !1,
2751
+ hasMetadata: !1
2752
+ };
2753
+ for (let n of Si(e).segments) {
2754
+ let r = e.subarray(n.start + 4, n.end);
2755
+ n.marker === 225 && Q(r, 0, 6) === "Exif\0\0" && Object.assign(t, Ci(r.subarray(6))), (n.marker >= 225 && n.marker <= 239 && !wi.has(n.marker) || n.marker === 254) && (t.hasMetadata = !0), n.marker >= 192 && n.marker <= 207 && ![
2756
+ 196,
2757
+ 200,
2758
+ 204
2759
+ ].includes(n.marker) && (t.height = $(e).getUint16(n.start + 5), t.width = $(e).getUint16(n.start + 7));
2760
+ }
2761
+ return t;
2762
+ }
2763
+ function Ei(e) {
2764
+ let { segments: t, dataStart: n } = Si(e), r = [e.subarray(0, 2)];
2765
+ for (let n of t) n.marker >= 225 && n.marker <= 239 && !wi.has(n.marker) || n.marker === 254 || r.push(e.subarray(n.start, n.end));
2766
+ return r.push(e.subarray(n)), Fi(r);
2767
+ }
2768
+ var Di = /* @__PURE__ */ new Set([
2769
+ "eXIf",
2770
+ "tEXt",
2771
+ "iTXt",
2772
+ "zTXt",
2773
+ "tIME"
2774
+ ]);
2775
+ function Oi(e) {
2776
+ let t = [], n = 8;
2777
+ for (; n + 12 <= e.length;) {
2778
+ let r = $(e).getUint32(n), i = Q(e, n + 4, 4), a = n + 12 + r;
2779
+ if (t.push({
2780
+ type: i,
2781
+ start: n,
2782
+ end: a
2783
+ }), n = a, i === "IEND") break;
2784
+ }
2785
+ return t;
2786
+ }
2787
+ function ki(e) {
2788
+ let t = Oi(e), n = t.find((e) => e.type === "IHDR"), r = t.find((e) => e.type === "eXIf");
2789
+ return {
2790
+ ...n ? {
2791
+ width: $(e).getUint32(n.start + 8),
2792
+ height: $(e).getUint32(n.start + 12)
2793
+ } : {},
2794
+ ...r ? Ci(e.subarray(r.start + 8, r.end - 4)) : { hasLocation: !1 },
2795
+ hasMetadata: t.some((e) => Di.has(e.type))
2796
+ };
2797
+ }
2798
+ function Ai(e) {
2799
+ let t = [e.subarray(0, 8)];
2800
+ for (let n of Oi(e)) Di.has(n.type) || t.push(e.subarray(n.start, n.end));
2801
+ return Fi(t);
2802
+ }
2803
+ function ji(e) {
2804
+ let t = [], n = 12;
2805
+ for (; n + 8 <= e.length;) {
2806
+ let r = $(e).getUint32(n + 4, !0), i = n + 8 + r + r % 2;
2807
+ t.push({
2808
+ type: Q(e, n, 4),
2809
+ start: n,
2810
+ end: Math.min(i, e.length)
2811
+ }), n = i;
2812
+ }
2813
+ return t;
2814
+ }
2815
+ function Mi(e) {
2816
+ let t = ji(e), n = $(e), r = {
2817
+ hasLocation: !1,
2818
+ hasMetadata: t.some((e) => e.type === "EXIF" || e.type === "XMP ")
2819
+ }, i = t.find((e) => e.type === "EXIF");
2820
+ if (i) {
2821
+ let t = e.subarray(i.start + 8, i.end);
2822
+ Q(t, 0, 6) === "Exif\0\0" && (t = t.subarray(6)), Object.assign(r, Ci(t));
2823
+ }
2824
+ for (let e of t) {
2825
+ let t = e.start + 8;
2826
+ if (e.type === "VP8X") {
2827
+ r.width = 1 + (n.getUint32(t + 4, !0) & 16777215), r.height = 1 + (n.getUint32(t + 7, !0) & 16777215);
2828
+ break;
2829
+ }
2830
+ if (e.type === "VP8 ") {
2831
+ r.width = n.getUint16(t + 6, !0) & 16383, r.height = n.getUint16(t + 8, !0) & 16383;
2832
+ break;
2833
+ }
2834
+ if (e.type === "VP8L") {
2835
+ let e = n.getUint32(t + 1, !0);
2836
+ r.width = 1 + (e & 16383), r.height = 1 + (e >> 14 & 16383);
2837
+ break;
2838
+ }
2839
+ }
2840
+ return r;
2841
+ }
2842
+ function Ni(e) {
2843
+ let t = [];
2844
+ for (let n of ji(e)) {
2845
+ if (n.type === "EXIF" || n.type === "XMP ") continue;
2846
+ let r = e.slice(n.start, n.end);
2847
+ n.type === "VP8X" && (r[8] = (r[8] ?? 0) & -13), t.push(r);
2848
+ }
2849
+ let n = Fi(t), r = new Uint8Array(12 + n.length);
2850
+ return r.set(e.subarray(0, 12)), r.set(n, 12), new DataView(r.buffer).setUint32(4, r.length - 8, !0), r;
2851
+ }
2852
+ function Pi(e, t) {
2853
+ return e === "jpeg" ? Ti(t) : e === "png" ? ki(t) : e === "webp" ? Mi(t) : {
2854
+ hasLocation: !1,
2855
+ hasMetadata: !1
2856
+ };
2857
+ }
2858
+ function Fi(e) {
2859
+ let t = new Uint8Array(e.reduce((e, t) => e + t.length, 0)), n = 0;
2860
+ for (let r of e) t.set(r, n), n += r.length;
2861
+ return t;
2862
+ }
2863
+ //#endregion
2864
+ //#region src/media/hygiene.ts
2865
+ var Ii = /* @__PURE__ */ new Set([
2866
+ "jpeg",
2867
+ "png",
2868
+ "gif",
2869
+ "webp",
2870
+ "avif",
2871
+ "heic",
2872
+ "svg"
2873
+ ]);
2874
+ async function Li(e, t = {}) {
2875
+ let n = t.maxEdge ?? 3e3, r = new Uint8Array(await e.arrayBuffer()), i = xi(r);
2876
+ if (t.accept === "image" && !Ii.has(i)) return {
2877
+ ok: !1,
2878
+ message: `${e.name} isn’t an image this site can use (JPEG, PNG, WebP, AVIF, GIF or SVG).`
2879
+ };
2880
+ let a = [], o = r, s = e.name, c, l;
2881
+ if (i === "svg") {
2882
+ let e = Hi(new TextDecoder().decode(r));
2883
+ e.removed && a.push("Removed scripts and unsafe links from the SVG"), o = new TextEncoder().encode(e.svg);
2884
+ } else if (i === "heic") {
2885
+ let e = await Vi(new Blob([r]), "image/jpeg", n);
2886
+ if (!e) return {
2887
+ ok: !1,
2888
+ message: "This browser can’t convert iPhone (HEIC) photos. Export the photo as JPEG first, or upload it from Safari."
2889
+ };
2890
+ o = e.bytes, {width: c, height: l} = e, s = s.replace(/\.(heic|heif)$/i, "") + ".jpg", a.push("Converted from HEIC to JPEG", "Removed location and camera data");
2891
+ } else if (i === "jpeg" || i === "png" || i === "webp") {
2892
+ let e = Pi(i, r);
2893
+ ({width: c, height: l} = e);
2894
+ let t = (e.orientation ?? 1) !== 1, s = Math.max(e.width ?? 0, e.height ?? 0) > n;
2895
+ if (t || s) {
2896
+ let u = i === "jpeg" ? "image/jpeg" : i === "png" ? "image/png" : "image/webp", d = await Vi(new Blob([r], { type: u }), u, n);
2897
+ d ? (o = d.bytes, s && a.push(`Resized from ${String(e.width)}×${String(e.height)} to ${String(d.width)}×${String(d.height)}`), t && a.push("Turned the photo upright"), {width: c, height: l} = d) : (o = Ri(i, r), a.push("Couldn’t resize this image in this browser, so it was kept at full size"));
2898
+ } else o = Ri(i, r);
2899
+ e.hasLocation ? a.push("Removed location data") : e.hasMetadata && a.push("Removed camera and editing metadata");
2900
+ }
2901
+ return o.length > Fe ? {
2902
+ ok: !1,
2903
+ message: `${s} is ${zi(o.length)} even after processing. The limit is ${zi(Fe)}.`
2904
+ } : {
2905
+ ok: !0,
2906
+ upload: {
2907
+ bytes: o,
2908
+ name: s,
2909
+ type: i === "heic" ? "jpeg" : i,
2910
+ notes: a,
2911
+ large: o.length > Ie,
2912
+ ...c === void 0 ? {} : { width: c },
2913
+ ...l === void 0 ? {} : { height: l }
2914
+ }
2915
+ };
2916
+ }
2917
+ function Ri(e, t) {
2918
+ return e === "jpeg" ? Ei(t) : e === "png" ? Ai(t) : Ni(t);
2919
+ }
2920
+ function zi(e) {
2921
+ return `${(e / 1024 / 1024).toFixed(1)} MB`;
2922
+ }
2923
+ function Bi(e) {
2924
+ return e < 1024 ? `${String(e)} bytes` : e < 1048576 ? `${String(Math.round(e / 1024))} KB` : zi(e);
2925
+ }
2926
+ async function Vi(e, t, n) {
2927
+ if (typeof createImageBitmap != "function") return null;
2928
+ let r;
2929
+ try {
2930
+ r = await createImageBitmap(e, { imageOrientation: "from-image" });
2931
+ } catch {
2932
+ return null;
2933
+ }
2934
+ let i = Math.min(1, n / Math.max(r.width, r.height)), a = Math.round(r.width * i), o = Math.round(r.height * i), s = document.createElement("canvas");
2935
+ s.width = a, s.height = o;
2936
+ let c = s.getContext("2d");
2937
+ if (!c) return null;
2938
+ c.imageSmoothingQuality = "high", c.drawImage(r, 0, 0, a, o), r.close();
2939
+ let l = await new Promise((e) => {
2940
+ s.toBlob(e, t, t === "image/png" ? void 0 : .9);
2941
+ });
2942
+ return !l || l.type !== t ? null : {
2943
+ bytes: new Uint8Array(await l.arrayBuffer()),
2944
+ width: a,
2945
+ height: o
2946
+ };
2947
+ }
2948
+ function Hi(e) {
2949
+ let t = lt(window), n = !1;
2950
+ t.addHook("uponSanitizeElement", (e, t) => {
2951
+ if (t.tagName === "set" || /^animate/i.test(t.tagName)) {
2952
+ let t = e.getAttribute("attributeName") ?? "";
2953
+ /^(on|href$|xlink:href$)/i.test(t) && (e.parentNode?.removeChild(e), n = !0);
2954
+ }
2955
+ }), t.addHook("uponSanitizeAttribute", (e, t) => {
2956
+ /^(href|xlink:href)$/i.test(t.attrName) && /^\s*(javascript|data|vbscript):/i.test(t.attrValue) && (t.keepAttr = !1, n = !0);
2957
+ });
2958
+ let r = t.sanitize(e, {
2959
+ USE_PROFILES: {
2960
+ svg: !0,
2961
+ svgFilters: !0
2962
+ },
2963
+ FORBID_TAGS: [
2964
+ "foreignObject",
2965
+ "script",
2966
+ "iframe",
2967
+ "embed",
2968
+ "object"
2969
+ ]
2970
+ });
2971
+ return t.removed.some((e) => !("element" in e) || e.element.nodeName !== "BODY") && (n = !0), {
2972
+ svg: r.startsWith("<svg") ? r : "<svg xmlns=\"http://www.w3.org/2000/svg\"></svg>",
2973
+ removed: n
2974
+ };
2975
+ }
2976
+ //#endregion
2977
+ //#region src/media/file-icon.ts
2978
+ var Ui = [
2979
+ ["file-text", [
2980
+ "pdf",
2981
+ "doc",
2982
+ "docx",
2983
+ "odt",
2984
+ "rtf",
2985
+ "txt",
2986
+ "md",
2987
+ "mdx",
2988
+ "mdoc",
2989
+ "ppt",
2990
+ "pptx",
2991
+ "key"
2992
+ ]],
2993
+ ["file-sheet", [
2994
+ "csv",
2995
+ "tsv",
2996
+ "xls",
2997
+ "xlsx",
2998
+ "ods",
2999
+ "numbers"
3000
+ ]],
3001
+ ["file-archive", [
3002
+ "zip",
3003
+ "gz",
3004
+ "tgz",
3005
+ "tar",
3006
+ "7z",
3007
+ "rar"
3008
+ ]],
3009
+ ["file-video", [
3010
+ "mp4",
3011
+ "m4v",
3012
+ "mov",
3013
+ "webm",
3014
+ "ogv"
3015
+ ]],
3016
+ ["file-audio", [
3017
+ "mp3",
3018
+ "m4a",
3019
+ "wav",
3020
+ "ogg",
3021
+ "oga",
3022
+ "flac",
3023
+ "aac"
3024
+ ]]
3025
+ ];
3026
+ function Wi(e) {
3027
+ return Ui.find(([, t]) => t.includes(e))?.[0] ?? "file";
3028
+ }
3029
+ //#endregion
3030
+ //#region src/media/upload.ts
3031
+ async function Gi(e, t, n) {
3032
+ let r = await Li(e, n);
3033
+ if (!r.ok) return {
3034
+ step: "refused",
3035
+ message: r.message
3036
+ };
3037
+ let i = await Ue(r.upload.bytes), a = t.find((e) => e.hash === i);
3038
+ return a ? {
3039
+ step: "duplicate",
3040
+ upload: r.upload,
3041
+ existing: a.path
3042
+ } : r.upload.large ? {
3043
+ step: "confirm-large",
3044
+ upload: r.upload
3045
+ } : {
3046
+ step: "ready",
3047
+ upload: r.upload
3048
+ };
3049
+ }
3050
+ async function Ki(e, t, n, r = {}) {
3051
+ let i = await e.upload(new Blob([t.bytes]), t.name, n, r);
3052
+ return i.ok ? {
3053
+ ok: !0,
3054
+ path: i.path
3055
+ } : i;
3056
+ }
3057
+ //#endregion
3058
+ //#region src/media/MediaPicker.tsx
3059
+ function qi({ isOpen: e, onOpenChange: t, kind: n, extensions: r = [], folder: i, onChoose: a }) {
3060
+ return /* @__PURE__ */ R(Sn, {
3061
+ title: n === "image" ? "Choose an image" : "Choose a file",
3062
+ isOpen: e,
3063
+ onOpenChange: t,
3064
+ children: e && /* @__PURE__ */ R(Ji, {
3065
+ kind: n,
3066
+ extensions: r,
3067
+ folder: i,
3068
+ onChoose: (e, n) => {
3069
+ a(e, n), t(!1);
3070
+ }
3071
+ })
3072
+ });
3073
+ }
3074
+ function Ji({ kind: e, extensions: t = [], folder: n, onChoose: r }) {
3075
+ let { api: i, siteName: a, manifest: o } = J(), s = o.site.images?.maxUploadEdge, [c, f] = cr(() => i.listMedia(), "media"), [p, m] = d(null), [h, g] = d(""), _ = u(null), v = (n) => e === "image" ? Ke(n) : t.length === 0 || t.includes(Be(n)), y = l(() => {
3076
+ let e = h.trim().toLowerCase();
3077
+ return (c.state === "ready" ? c.value : []).filter((e) => v(e.path)).filter((t) => e === "" || t.path.toLowerCase().includes(e));
3078
+ }, [c, h]), b = async (e) => {
3079
+ m({
3080
+ step: "working",
3081
+ text: "Uploading…"
3082
+ });
3083
+ let t = await Ki(i, e.upload, n, { withNextSave: !0 });
3084
+ t.ok ? (f(), r(t.path, e.upload.notes)) : m({
3085
+ step: "refused",
3086
+ message: t.message
3087
+ });
3088
+ }, x = e === "image" ? "image/*,.heic,.heif" : t.length > 0 ? t.map((e) => `.${e}`).join(",") : void 0;
3089
+ return /* @__PURE__ */ z("div", {
3090
+ className: "flex flex-col gap-6",
3091
+ children: [/* @__PURE__ */ z("section", {
3092
+ "aria-labelledby": "picker-upload",
3093
+ className: "flex flex-col gap-3",
3094
+ children: [
3095
+ /* @__PURE__ */ R("h3", {
3096
+ id: "picker-upload",
3097
+ className: "text-heading-3",
3098
+ children: "Upload from your computer"
3099
+ }),
3100
+ /* @__PURE__ */ R("p", {
3101
+ className: "text-small text-content-muted",
3102
+ children: e === "image" ? `Large photos are scaled down, turned upright, and stripped of location data before they’re added to ${a}.` : `The file is added to ${n}.`
3103
+ }),
3104
+ /* @__PURE__ */ R("input", {
3105
+ ref: _,
3106
+ type: "file",
3107
+ accept: x,
3108
+ tabIndex: -1,
3109
+ "aria-hidden": "true",
3110
+ className: "sr-only",
3111
+ onChange: (t) => {
3112
+ let n = t.target.files?.[0];
3113
+ t.target.value = "", n && (m({
3114
+ step: "working",
3115
+ text: `Preparing ${n.name}…`
3116
+ }), Gi(n, c.state === "ready" ? c.value : [], {
3117
+ accept: e === "image" ? "image" : "any",
3118
+ ...s ? { maxEdge: s } : {}
3119
+ }).then((e) => {
3120
+ e.step === "ready" ? b(e) : m(e);
3121
+ }));
3122
+ }
3123
+ }),
3124
+ /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
3125
+ icon: "upload",
3126
+ onPress: () => {
3127
+ _.current?.click();
3128
+ },
3129
+ children: e === "image" ? "Upload an image" : "Upload a file"
3130
+ }) }),
3131
+ /* @__PURE__ */ R(Xi, {
3132
+ step: p,
3133
+ onUpload: (e) => void b(e),
3134
+ onReuse: r,
3135
+ onCancel: () => {
3136
+ m(null);
3137
+ }
3138
+ })
3139
+ ]
3140
+ }), /* @__PURE__ */ z("section", {
3141
+ "aria-labelledby": "picker-existing",
3142
+ className: "flex flex-col gap-3",
3143
+ children: [
3144
+ /* @__PURE__ */ R("h3", {
3145
+ id: "picker-existing",
3146
+ className: "text-heading-3",
3147
+ children: "Or choose one already in the site"
3148
+ }),
3149
+ /* @__PURE__ */ R(_n, {
3150
+ label: "Search by file name",
3151
+ type: "search",
3152
+ icon: "search",
3153
+ value: h,
3154
+ onChange: g
3155
+ }),
3156
+ c.state === "loading" && /* @__PURE__ */ R("p", {
3157
+ className: "text-small text-content-muted",
3158
+ children: "Loading files…"
3159
+ }),
3160
+ c.state === "failed" && /* @__PURE__ */ z("p", {
3161
+ role: "alert",
3162
+ className: "text-danger",
3163
+ children: ["Couldn’t list files: ", c.message]
3164
+ }),
3165
+ c.state === "ready" && y.length === 0 && /* @__PURE__ */ z("p", {
3166
+ className: "text-content-muted",
3167
+ children: [
3168
+ "No ",
3169
+ e === "image" ? "images" : "files",
3170
+ " found."
3171
+ ]
3172
+ }),
3173
+ /* @__PURE__ */ R("ul", {
3174
+ className: "grid max-h-80 grid-cols-1 gap-2 overflow-y-auto sm:grid-cols-2",
3175
+ children: y.map((e) => /* @__PURE__ */ R("li", { children: /* @__PURE__ */ R(Yi, {
3176
+ item: e,
3177
+ onChoose: r
3178
+ }) }, e.path))
3179
+ })
3180
+ ]
3181
+ })]
3182
+ });
3183
+ }
3184
+ function Yi({ item: e, onChoose: t }) {
3185
+ let n = e.path.slice(e.path.lastIndexOf("/") + 1);
3186
+ return /* @__PURE__ */ z("button", {
3187
+ type: "button",
3188
+ onClick: () => {
3189
+ t(e.path);
3190
+ },
3191
+ className: "flex w-full items-center gap-3 rounded-md border border-border p-2 text-left hover:bg-surface-sunken focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)",
3192
+ children: [Ke(e.path) ? /* @__PURE__ */ R(Fr, {
3193
+ path: e.path,
3194
+ loading: "lazy",
3195
+ className: "size-12 shrink-0 rounded-md object-cover"
3196
+ }) : /* @__PURE__ */ R("span", {
3197
+ "aria-hidden": "true",
3198
+ className: "flex size-12 shrink-0 items-center justify-center rounded-md bg-surface-sunken text-content-muted",
3199
+ children: /* @__PURE__ */ R(G, {
3200
+ name: Wi(Be(e.path)),
3201
+ size: 24
3202
+ })
3203
+ }), /* @__PURE__ */ z("span", {
3204
+ className: "min-w-0",
3205
+ children: [/* @__PURE__ */ R("span", {
3206
+ className: "block truncate font-semibold",
3207
+ children: n
3208
+ }), /* @__PURE__ */ z("span", {
3209
+ className: "block font-mono text-caption break-all text-content-muted",
3210
+ children: [
3211
+ e.path.slice(0, e.path.lastIndexOf("/")),
3212
+ " · ",
3213
+ Bi(e.size)
3214
+ ]
3215
+ })]
3216
+ })]
3217
+ });
3218
+ }
3219
+ function Xi({ step: e, onUpload: t, onReuse: n, onCancel: r }) {
3220
+ if (!e) return null;
3221
+ if (e.step === "working") return /* @__PURE__ */ R("p", {
3222
+ role: "status",
3223
+ children: e.text
3224
+ });
3225
+ if (e.step === "refused") return /* @__PURE__ */ R("p", {
3226
+ role: "alert",
3227
+ className: "text-danger",
3228
+ children: e.message
3229
+ });
3230
+ let i = e.upload.notes.length > 0 && /* @__PURE__ */ R("ul", {
3231
+ className: "list-disc pl-6 text-small text-content-muted",
3232
+ children: e.upload.notes.map((e) => /* @__PURE__ */ R("li", { children: e }, e))
3233
+ });
3234
+ return e.step === "duplicate" ? /* @__PURE__ */ z("div", {
3235
+ role: "alert",
3236
+ className: "flex flex-col gap-3 rounded-md border border-warning bg-surface-raised p-4",
3237
+ children: [/* @__PURE__ */ z("p", { children: [
3238
+ "This file is already in the site as ",
3239
+ e.existing,
3240
+ "."
3241
+ ] }), /* @__PURE__ */ z("div", {
3242
+ className: "flex flex-wrap gap-3",
3243
+ children: [/* @__PURE__ */ R(K, {
3244
+ onPress: () => {
3245
+ n(e.existing);
3246
+ },
3247
+ children: "Use the existing file"
3248
+ }), /* @__PURE__ */ R(K, {
3249
+ variant: "quiet",
3250
+ onPress: () => {
3251
+ t(e);
3252
+ },
3253
+ children: "Upload a copy anyway"
3254
+ })]
3255
+ })]
3256
+ }) : e.step === "confirm-large" ? /* @__PURE__ */ z("div", {
3257
+ role: "alert",
3258
+ className: "flex flex-col gap-3 rounded-md border border-warning bg-surface-raised p-4",
3259
+ children: [
3260
+ /* @__PURE__ */ z("p", { children: [
3261
+ e.upload.name,
3262
+ " is ",
3263
+ zi(e.upload.bytes.length),
3264
+ ". Large files make the site’s repository and pages heavier. Upload it anyway?"
3265
+ ] }),
3266
+ i,
3267
+ /* @__PURE__ */ z("div", {
3268
+ className: "flex flex-wrap gap-3",
3269
+ children: [/* @__PURE__ */ R(K, {
3270
+ onPress: () => {
3271
+ t(e);
3272
+ },
3273
+ children: "Upload it"
3274
+ }), /* @__PURE__ */ R(K, {
3275
+ variant: "quiet",
3276
+ onPress: r,
3277
+ children: "Cancel"
3278
+ })]
3279
+ })
3280
+ ]
3281
+ }) : null;
3282
+ }
3283
+ //#endregion
3284
+ //#region src/widgets/crops.tsx
3285
+ function Zi(e) {
3286
+ return e === "og" ? "Social image" : We(e);
3287
+ }
3288
+ var Qi = (e) => Math.round(e * 100);
3289
+ function $i(e) {
3290
+ return {
3291
+ width: `${String(100 / e.w)}%`,
3292
+ height: `${String(100 / e.h)}%`,
3293
+ left: `${String(-e.x / e.w * 100)}%`,
3294
+ top: `${String(-e.y / e.h * 100)}%`
3295
+ };
3296
+ }
3297
+ function ea({ id: e, src: t, size: n, value: r, ratios: i, onChange: a, disabled: o }) {
3298
+ let [s, c] = d(null), [l, u] = d("");
3299
+ if (!n) return /* @__PURE__ */ R("p", {
3300
+ className: "text-small text-content-muted",
3301
+ children: "Loading the image for the crop previews…"
3302
+ });
3303
+ let f = (t) => `${e}-crop-${t}`, p = (e) => {
3304
+ requestAnimationFrame(() => {
3305
+ document.getElementById(f(e))?.focus();
3306
+ });
3307
+ };
3308
+ return /* @__PURE__ */ z("div", {
3309
+ className: "flex flex-col gap-2",
3310
+ children: [
3311
+ /* @__PURE__ */ R("ul", {
3312
+ "aria-label": "Crops",
3313
+ className: "flex flex-wrap items-end gap-4",
3314
+ children: i.map(({ name: e, ratio: i }) => {
3315
+ let { rect: a, custom: s } = Le(r, e, i, n), l = Zi(e);
3316
+ return /* @__PURE__ */ z("li", { children: [/* @__PURE__ */ z("figure", {
3317
+ className: "flex flex-col gap-1",
3318
+ children: [/* @__PURE__ */ R("div", {
3319
+ className: "relative h-24 self-start overflow-hidden rounded-sm border border-border",
3320
+ style: { aspectRatio: String(i) },
3321
+ children: /* @__PURE__ */ R("img", {
3322
+ src: t,
3323
+ alt: "",
3324
+ draggable: !1,
3325
+ className: "absolute max-w-none",
3326
+ style: $i(a)
3327
+ })
3328
+ }), /* @__PURE__ */ z("figcaption", {
3329
+ className: "text-small text-content",
3330
+ children: [
3331
+ l,
3332
+ " · ",
3333
+ Qe(i),
3334
+ s && /* @__PURE__ */ R("span", {
3335
+ className: "text-content-muted",
3336
+ children: " · Custom crop"
3337
+ })
3338
+ ]
3339
+ })]
3340
+ }), /* @__PURE__ */ z(K, {
3341
+ id: f(e),
3342
+ variant: "quiet",
3343
+ isDisabled: o,
3344
+ className: "-ml-4",
3345
+ onPress: () => {
3346
+ c({
3347
+ name: e,
3348
+ ratio: i
3349
+ });
3350
+ },
3351
+ children: ["Adjust crop ", /* @__PURE__ */ z("span", {
3352
+ className: "sr-only",
3353
+ children: ["for ", l]
3354
+ })]
3355
+ })] }, e);
3356
+ })
3357
+ }),
3358
+ /* @__PURE__ */ R("p", {
3359
+ role: "status",
3360
+ className: "sr-only",
3361
+ children: l
3362
+ }),
3363
+ s && /* @__PURE__ */ R(aa, {
3364
+ src: t,
3365
+ size: n,
3366
+ name: s.name,
3367
+ ratio: s.ratio,
3368
+ start: Le(r, s.name, s.ratio, n),
3369
+ onClose: () => {
3370
+ c(null), p(s.name);
3371
+ },
3372
+ onApply: (e) => {
3373
+ a({
3374
+ ...r.crops,
3375
+ [s.name]: rt(e)
3376
+ }), u(`Custom crop applied to ${Zi(s.name)}.`);
3377
+ },
3378
+ onReset: () => {
3379
+ let { [s.name]: e, ...t } = r.crops;
3380
+ a(t), u(`${Zi(s.name)} crop reset to the focal point.`);
3381
+ }
3382
+ })
3383
+ ]
3384
+ });
3385
+ }
3386
+ function ta(e) {
3387
+ return `${String(Qi(e.x))}% from the left, ${String(Qi(e.y))}% from the top, ${String(Qi(e.w))}% of the width`;
3388
+ }
3389
+ var na = {
3390
+ ArrowLeft: [-1, 0],
3391
+ ArrowRight: [1, 0],
3392
+ ArrowUp: [0, -1],
3393
+ ArrowDown: [0, 1]
3394
+ }, ra = {
3395
+ ArrowRight: 1,
3396
+ ArrowDown: 1,
3397
+ ArrowLeft: -1,
3398
+ ArrowUp: -1
3399
+ }, ia = [
3400
+ {
3401
+ corner: "top-left",
3402
+ className: "-left-1.5 -top-1.5 cursor-nwse-resize"
3403
+ },
3404
+ {
3405
+ corner: "top-right",
3406
+ className: "-right-1.5 -top-1.5 cursor-nesw-resize"
3407
+ },
3408
+ {
3409
+ corner: "bottom-left",
3410
+ className: "-bottom-1.5 -left-1.5 cursor-nesw-resize"
3411
+ },
3412
+ {
3413
+ corner: "bottom-right",
3414
+ className: "-bottom-1.5 -right-1.5 cursor-nwse-resize"
3415
+ }
3416
+ ];
3417
+ function aa({ src: e, size: t, name: n, ratio: r, start: i, onClose: a, onApply: o, onReset: s }) {
3418
+ let [l, f] = d(i.rect), [p, m] = d(!1), [h, g] = d(""), _ = u(null), v = u(null), y = u(null), b = `${Zi(n)} (${Qe(r)})`;
3419
+ c(() => {
3420
+ v.current?.focus();
3421
+ }, []);
3422
+ let x = (e, t) => {
3423
+ f(e), m(!0), t && g(`Crop ${ta(e)}.`);
3424
+ }, S = (e) => {
3425
+ (p || i.custom) && o(l), e();
3426
+ }, C = (e) => {
3427
+ let t = _.current?.getBoundingClientRect();
3428
+ return !t || t.width === 0 || t.height === 0 ? null : {
3429
+ x: (e.clientX - t.left) / t.width,
3430
+ y: (e.clientY - t.top) / t.height
3431
+ };
3432
+ }, w = (e) => {
3433
+ if (e.button !== 0) return;
3434
+ let t = e.target.dataset.corner, n = C(e);
3435
+ n && (e.currentTarget.setPointerCapture(e.pointerId), y.current = t ? {
3436
+ kind: "corner",
3437
+ corner: t,
3438
+ start: l
3439
+ } : {
3440
+ kind: "move",
3441
+ from: n,
3442
+ start: l
3443
+ });
3444
+ }, T = (e) => {
3445
+ let n = y.current, i = n ? C(e) : null;
3446
+ n && i && x(n.kind === "move" ? Ye(n.start, i.x - n.from.x, i.y - n.from.y) : ze(n.start, n.corner, i, r, t), !1);
3447
+ }, E = () => {
3448
+ y.current && (y.current = null, g(`Crop ${ta(l)}.`));
3449
+ };
3450
+ return /* @__PURE__ */ R(Sn, {
3451
+ title: `Adjust the ${Zi(n)} crop`,
3452
+ size: "wide",
3453
+ isOpen: !0,
3454
+ onOpenChange: (e) => {
3455
+ e || a();
3456
+ },
3457
+ children: (n) => /* @__PURE__ */ z(L, { children: [
3458
+ /* @__PURE__ */ R("p", {
3459
+ id: "vesper-crop-help",
3460
+ className: "text-small text-content-muted",
3461
+ children: "Drag the box to move it, or a corner to resize it. With the box focused, the arrow keys move it, Shift and the arrow keys resize it, Enter applies and Escape cancels."
3462
+ }),
3463
+ /* @__PURE__ */ z("div", {
3464
+ className: "relative mx-auto w-fit max-w-full touch-none select-none",
3465
+ children: [
3466
+ /* @__PURE__ */ R("img", {
3467
+ ref: _,
3468
+ src: e,
3469
+ alt: "",
3470
+ draggable: !1,
3471
+ className: "block max-h-[60vh] max-w-full"
3472
+ }),
3473
+ /* @__PURE__ */ R("span", {
3474
+ "aria-hidden": "true",
3475
+ className: "absolute inset-x-0 top-0 bg-content/50",
3476
+ style: { height: `${String(l.y * 100)}%` }
3477
+ }),
3478
+ /* @__PURE__ */ R("span", {
3479
+ "aria-hidden": "true",
3480
+ className: "absolute inset-x-0 bottom-0 bg-content/50",
3481
+ style: { height: `${String((1 - l.y - l.h) * 100)}%` }
3482
+ }),
3483
+ /* @__PURE__ */ R("span", {
3484
+ "aria-hidden": "true",
3485
+ className: "absolute left-0 bg-content/50",
3486
+ style: {
3487
+ top: `${String(l.y * 100)}%`,
3488
+ height: `${String(l.h * 100)}%`,
3489
+ width: `${String(l.x * 100)}%`
3490
+ }
3491
+ }),
3492
+ /* @__PURE__ */ R("span", {
3493
+ "aria-hidden": "true",
3494
+ className: "absolute right-0 bg-content/50",
3495
+ style: {
3496
+ top: `${String(l.y * 100)}%`,
3497
+ height: `${String(l.h * 100)}%`,
3498
+ width: `${String((1 - l.x - l.w) * 100)}%`
3499
+ }
3500
+ }),
3501
+ /* @__PURE__ */ z("div", {
3502
+ ref: v,
3503
+ role: "application",
3504
+ tabIndex: 0,
3505
+ "aria-label": `Crop box for ${b}`,
3506
+ "aria-describedby": "vesper-crop-position vesper-crop-help",
3507
+ "data-crop-box": "",
3508
+ onKeyDown: (e) => {
3509
+ if (e.key === "Enter") {
3510
+ e.preventDefault(), S(n);
3511
+ return;
3512
+ }
3513
+ let i = na[e.key];
3514
+ !i || e.altKey || e.ctrlKey || e.metaKey || (e.preventDefault(), x(e.shiftKey ? $e(l, l.w + (ra[e.key] ?? 0) * .01, r, t) : Ye(l, i[0] * .01, i[1] * .01), !0));
3515
+ },
3516
+ onPointerDown: w,
3517
+ onPointerMove: T,
3518
+ onPointerUp: E,
3519
+ className: V("absolute cursor-move border border-on-accent outline-offset-0", H),
3520
+ style: {
3521
+ left: `${String(l.x * 100)}%`,
3522
+ top: `${String(l.y * 100)}%`,
3523
+ width: `${String(l.w * 100)}%`,
3524
+ height: `${String(l.h * 100)}%`
3525
+ },
3526
+ children: [/* @__PURE__ */ R("span", {
3527
+ "aria-hidden": "true",
3528
+ className: "absolute inset-0 border border-content/60"
3529
+ }), ia.map(({ corner: e, className: t }) => /* @__PURE__ */ R("span", {
3530
+ "aria-hidden": "true",
3531
+ "data-corner": e,
3532
+ className: V("absolute size-3 border border-content bg-on-accent", t)
3533
+ }, e))]
3534
+ })
3535
+ ]
3536
+ }),
3537
+ /* @__PURE__ */ R("p", {
3538
+ id: "vesper-crop-position",
3539
+ className: "sr-only",
3540
+ children: ta(l)
3541
+ }),
3542
+ /* @__PURE__ */ R("p", {
3543
+ role: "status",
3544
+ className: "sr-only",
3545
+ children: h
3546
+ }),
3547
+ /* @__PURE__ */ z("div", {
3548
+ className: "flex flex-wrap justify-end gap-2",
3549
+ children: [
3550
+ i.custom && /* @__PURE__ */ R(K, {
3551
+ onPress: () => {
3552
+ s(), n();
3553
+ },
3554
+ children: "Reset to focal point"
3555
+ }),
3556
+ /* @__PURE__ */ R(K, {
3557
+ variant: "quiet",
3558
+ onPress: n,
3559
+ children: "Cancel"
3560
+ }),
3561
+ /* @__PURE__ */ R(K, {
3562
+ variant: "primary",
3563
+ onPress: () => {
3564
+ S(n);
3565
+ },
3566
+ children: "Apply crop"
3567
+ })
3568
+ ]
3569
+ })
3570
+ ] })
3571
+ });
3572
+ }
3573
+ //#endregion
3574
+ //#region src/widgets/focal-point.tsx
3575
+ var oa = (e) => Math.round(e * 100);
3576
+ function sa(e) {
3577
+ let t = e ?? Pe;
3578
+ return `${String(oa(t.x))}% across, ${String(oa(t.y))}% down`;
3579
+ }
3580
+ var ca = {
3581
+ ArrowLeft: [-1, 0],
3582
+ ArrowRight: [1, 0],
3583
+ ArrowUp: [0, -1],
3584
+ ArrowDown: [0, 1]
3585
+ };
3586
+ function la({ id: e, src: t, focus: n, onChange: r, onImageSize: i, disabled: a }) {
3587
+ let o = u(null), s = u(!1), [c, l] = d(""), f = n ?? Pe, p = (e, t) => {
3588
+ let n = nt(e);
3589
+ r(n), t && l(`Focal point ${sa(n)}.`);
3590
+ }, m = (e, t) => {
3591
+ let n = o.current?.getBoundingClientRect();
3592
+ return !n || n.width === 0 || n.height === 0 ? null : {
3593
+ x: (e - n.left) / n.width,
3594
+ y: (t - n.top) / n.height
3595
+ };
3596
+ };
3597
+ return /* @__PURE__ */ z("div", {
3598
+ className: "flex flex-col gap-3",
3599
+ children: [
3600
+ /* @__PURE__ */ R("p", {
3601
+ id: `${e}-focus-help`,
3602
+ className: "text-small text-content-muted",
3603
+ children: "The focal point stays in view when the image is cropped. Click the image or drag the marker; or focus the image and use the arrow keys (Shift moves 10%)."
3604
+ }),
3605
+ /* @__PURE__ */ z("div", {
3606
+ className: "flex flex-wrap items-start gap-4",
3607
+ children: [/* @__PURE__ */ z("button", {
3608
+ type: "button",
3609
+ id: `${e}-focus`,
3610
+ "aria-label": "Focal point",
3611
+ "aria-describedby": `${e}-focus-position ${e}-focus-help`,
3612
+ disabled: a,
3613
+ onPointerDown: (e) => {
3614
+ if (a || e.button !== 0) return;
3615
+ let t = m(e.clientX, e.clientY);
3616
+ t && (s.current = !0, e.currentTarget.setPointerCapture(e.pointerId), p(t, !1));
3617
+ },
3618
+ onPointerMove: (e) => {
3619
+ if (!s.current) return;
3620
+ let t = m(e.clientX, e.clientY);
3621
+ t && p(t, !1);
3622
+ },
3623
+ onPointerUp: (e) => {
3624
+ if (!s.current) return;
3625
+ s.current = !1;
3626
+ let t = m(e.clientX, e.clientY);
3627
+ t && p(t, !0);
3628
+ },
3629
+ onKeyDown: (e) => {
3630
+ let t = ca[e.key];
3631
+ if (!t || a || e.altKey || e.ctrlKey || e.metaKey) return;
3632
+ e.preventDefault();
3633
+ let n = e.shiftKey ? .1 : .01;
3634
+ p({
3635
+ x: f.x + t[0] * n,
3636
+ y: f.y + t[1] * n
3637
+ }, !0);
3638
+ },
3639
+ className: V("relative max-w-full cursor-crosshair touch-none rounded-md disabled:cursor-not-allowed", H),
3640
+ children: [/* @__PURE__ */ R("img", {
3641
+ ref: o,
3642
+ src: t,
3643
+ alt: "",
3644
+ draggable: !1,
3645
+ onLoad: (e) => {
3646
+ let { naturalWidth: t, naturalHeight: n } = e.currentTarget;
3647
+ t > 0 && n > 0 && i?.({
3648
+ width: t,
3649
+ height: n
3650
+ });
3651
+ },
3652
+ className: "block max-h-64 max-w-full rounded-md border border-border"
3653
+ }), /* @__PURE__ */ R("span", {
3654
+ "aria-hidden": "true",
3655
+ "data-focal-marker": "",
3656
+ className: "pointer-events-none absolute -ml-3 -mt-3 size-6 rounded-full border border-on-accent bg-accent/70",
3657
+ style: {
3658
+ left: `${String(f.x * 100)}%`,
3659
+ top: `${String(f.y * 100)}%`
3660
+ }
3661
+ })]
3662
+ }), /* @__PURE__ */ z("div", {
3663
+ className: "flex flex-col gap-3",
3664
+ children: [
3665
+ /* @__PURE__ */ R(ua, {
3666
+ id: `${e}-focus-x`,
3667
+ label: "Across (%)",
3668
+ hint: "0 is the left edge, 100 the right",
3669
+ value: n ? oa(n.x) : void 0,
3670
+ placeholder: oa(Pe.x),
3671
+ disabled: a,
3672
+ onChange: (e) => {
3673
+ p({
3674
+ x: e / 100,
3675
+ y: f.y
3676
+ }, !1);
3677
+ }
3678
+ }),
3679
+ /* @__PURE__ */ R(ua, {
3680
+ id: `${e}-focus-y`,
3681
+ label: "Down (%)",
3682
+ hint: "0 is the top, 100 the bottom",
3683
+ value: n ? oa(n.y) : void 0,
3684
+ placeholder: oa(Pe.y),
3685
+ disabled: a,
3686
+ onChange: (e) => {
3687
+ p({
3688
+ x: f.x,
3689
+ y: e / 100
3690
+ }, !1);
3691
+ }
3692
+ }),
3693
+ n && /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
3694
+ variant: "quiet",
3695
+ isDisabled: a,
3696
+ onPress: () => {
3697
+ r(void 0), l("Focal point back to the center.");
3698
+ },
3699
+ children: "Use the center"
3700
+ }) })
3701
+ ]
3702
+ })]
3703
+ }),
3704
+ /* @__PURE__ */ R("p", {
3705
+ id: `${e}-focus-position`,
3706
+ className: "sr-only",
3707
+ children: n ? sa(n) : `Not set: the center, ${sa(void 0)}`
3708
+ }),
3709
+ /* @__PURE__ */ R("p", {
3710
+ role: "status",
3711
+ className: "sr-only",
3712
+ children: c
3713
+ })
3714
+ ]
3715
+ });
3716
+ }
3717
+ function ua({ id: e, label: t, hint: n, value: r, placeholder: i, disabled: a, onChange: o }) {
3718
+ let [s, c] = d(r === void 0 ? "" : String(r)), [l, u] = d(r);
3719
+ return r !== l && (u(r), c(r === void 0 ? "" : String(r))), /* @__PURE__ */ z("div", {
3720
+ className: "flex flex-col gap-1",
3721
+ children: [
3722
+ /* @__PURE__ */ R("label", {
3723
+ htmlFor: e,
3724
+ className: "text-small text-content",
3725
+ children: t
3726
+ }),
3727
+ /* @__PURE__ */ R("input", {
3728
+ id: e,
3729
+ type: "number",
3730
+ inputMode: "numeric",
3731
+ min: 0,
3732
+ max: 100,
3733
+ step: 1,
3734
+ value: s,
3735
+ placeholder: String(i),
3736
+ disabled: a,
3737
+ onChange: (e) => {
3738
+ c(e.target.value);
3739
+ let t = e.target.valueAsNumber;
3740
+ Number.isFinite(t) && t >= 0 && t <= 100 && (u(Math.round(t)), o(Math.round(t)));
3741
+ },
3742
+ "aria-describedby": `${e}-hint`,
3743
+ className: V(Z, "w-28")
3744
+ }),
3745
+ /* @__PURE__ */ R("p", {
3746
+ id: `${e}-hint`,
3747
+ className: "text-small text-content-muted",
3748
+ children: n
3749
+ })
3750
+ ]
3751
+ });
3752
+ }
3753
+ //#endregion
3754
+ //#region src/widgets/image.tsx
3755
+ function da(e, t, n) {
3756
+ return e ? Re(e) : `${t}/assets/${n}`;
3757
+ }
3758
+ function fa(e) {
3759
+ return e.slice(e.lastIndexOf("/") + 1);
3760
+ }
3761
+ function pa(e, t) {
3762
+ let n = e.widgetOptions?.ratios;
3763
+ return (Array.isArray(n) ? n.filter((e) => typeof e == "string" && e in t) : Object.keys(t)).map((e) => ({
3764
+ name: e,
3765
+ ratio: t[e] ?? 1
3766
+ }));
3767
+ }
3768
+ function ma({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o, path: s }) {
3769
+ let { manifest: c } = J(), l = X(), [u, f] = d(!1), [p, m] = d([]), [h, g] = d(null), _ = n.kind === "object", v = B(e) ? e : {}, y = _ ? v.src : e, b = typeof y == "string" ? y : "", x = b ? et(b, l.entryPath) : null, S = Pr(x), C = _ && (n.children ?? []).some((e) => e.path.at(-1) === "alt"), w = _ && (n.children ?? []).some((e) => e.path.at(-1) === "decorative"), T = v.decorative === !0, E = typeof v.alt == "string" ? v.alt : "", D = (l.notes?.get(pr(s)) ?? []).filter((e) => e.target.kind === "field" && e.target.path[s.length] === "alt"), ee = (e) => _ && (n.children ?? []).some((t) => t.path.at(-1) === e), O = ee("focus"), k = ee("crops"), [te, A] = d(null), [j, ne] = d(b);
3770
+ j !== b && (ne(b), A(null));
3771
+ let M = h === b, N = T ? "You replaced the image. Check that it’s still decorative." : "You replaced the image. Check that the alt text still describes it.", P = (e) => {
3772
+ if (e === x) return;
3773
+ let n = Je(e, l.entryPath);
3774
+ if (!_) {
3775
+ t(n);
3776
+ return;
3777
+ }
3778
+ let { focus: r, crops: i, ...a } = v;
3779
+ t({
3780
+ ...a,
3781
+ src: n
3782
+ }), b && (E !== "" || T) && g(n);
3783
+ }, F = (e) => {
3784
+ t(e);
3785
+ };
3786
+ return /* @__PURE__ */ z("div", {
3787
+ className: "flex flex-col gap-4",
3788
+ children: [
3789
+ b ? /* @__PURE__ */ z("div", {
3790
+ className: "flex flex-wrap items-start gap-4",
3791
+ children: [x ? S && /* @__PURE__ */ R("img", {
3792
+ src: S,
3793
+ alt: "",
3794
+ className: "max-h-48 max-w-full rounded-md border border-border object-contain"
3795
+ }) : /* @__PURE__ */ z("p", {
3796
+ className: "text-small text-content-muted",
3797
+ children: [
3798
+ "The studio can’t show a preview of ",
3799
+ b,
3800
+ "."
3801
+ ]
3802
+ }), /* @__PURE__ */ z("div", {
3803
+ className: "flex min-w-0 flex-col gap-2",
3804
+ children: [/* @__PURE__ */ R("p", {
3805
+ id: `${r}-file`,
3806
+ className: "font-mono text-small break-all",
3807
+ children: fa(b)
3808
+ }), /* @__PURE__ */ z("div", {
3809
+ className: "flex flex-wrap gap-2",
3810
+ children: [/* @__PURE__ */ R(K, {
3811
+ id: r,
3812
+ isDisabled: o,
3813
+ "aria-describedby": [i, `${r}-file`].filter(Boolean).join(" "),
3814
+ icon: "replace-image",
3815
+ onPress: () => {
3816
+ f(!0);
3817
+ },
3818
+ children: "Replace image"
3819
+ }), /* @__PURE__ */ R(K, {
3820
+ variant: "quiet",
3821
+ isDisabled: o,
3822
+ onPress: () => {
3823
+ m([]), g(null), t(n.required ? _ ? {
3824
+ ...v,
3825
+ src: ""
3826
+ } : "" : void 0);
3827
+ },
3828
+ children: "Remove image"
3829
+ })]
3830
+ })]
3831
+ })]
3832
+ }) : /* @__PURE__ */ R("div", { children: /* @__PURE__ */ R(K, {
3833
+ id: r,
3834
+ isDisabled: o,
3835
+ "aria-describedby": i,
3836
+ onPress: () => {
3837
+ f(!0);
3838
+ },
3839
+ children: "Choose image"
3840
+ }) }),
3841
+ p.length > 0 && /* @__PURE__ */ z("p", {
3842
+ role: "status",
3843
+ className: "text-small text-content-muted",
3844
+ children: [
3845
+ "Added. ",
3846
+ p.join(". "),
3847
+ "."
3848
+ ]
3849
+ }),
3850
+ C && !T && /* @__PURE__ */ z("div", {
3851
+ className: "flex flex-col gap-1",
3852
+ children: [
3853
+ /* @__PURE__ */ R("label", {
3854
+ htmlFor: `${r}-alt`,
3855
+ className: "text-label text-content",
3856
+ children: "Alt text"
3857
+ }),
3858
+ /* @__PURE__ */ R("textarea", {
3859
+ id: `${r}-alt`,
3860
+ rows: 2,
3861
+ value: E,
3862
+ onChange: (e) => {
3863
+ g(null), F({
3864
+ ...v,
3865
+ alt: e.target.value
3866
+ });
3867
+ },
3868
+ "aria-describedby": [
3869
+ `${r}-alt-help`,
3870
+ D.length > 0 ? `${r}-alt-a11y` : "",
3871
+ M ? `${r}-replaced` : "",
3872
+ i
3873
+ ].filter(Boolean).join(" "),
3874
+ "aria-invalid": a || void 0,
3875
+ "aria-required": "true",
3876
+ disabled: o,
3877
+ className: V(Z, "resize-y")
3878
+ }),
3879
+ /* @__PURE__ */ R("p", {
3880
+ id: `${r}-alt-help`,
3881
+ className: "text-small text-content-muted",
3882
+ children: "Describe what this image communicates on this page."
3883
+ }),
3884
+ D.length > 0 && /* @__PURE__ */ R(vi, {
3885
+ id: `${r}-alt-a11y`,
3886
+ notes: D
3887
+ }),
3888
+ M && /* @__PURE__ */ R(yi, {
3889
+ id: `${r}-replaced`,
3890
+ children: N
3891
+ })
3892
+ ]
3893
+ }),
3894
+ w && /* @__PURE__ */ R(Ln, {
3895
+ isSelected: T,
3896
+ isDisabled: o,
3897
+ "aria-describedby": T && M ? `${r}-replaced` : void 0,
3898
+ onChange: (e) => {
3899
+ if (g(null), e) F({
3900
+ ...v,
3901
+ alt: "",
3902
+ decorative: !0
3903
+ });
3904
+ else {
3905
+ let { decorative: e, ...t } = v;
3906
+ F(t);
3907
+ }
3908
+ },
3909
+ children: "Decorative image (it adds nothing a reader needs)"
3910
+ }),
3911
+ w && T && M && /* @__PURE__ */ R(yi, {
3912
+ id: `${r}-replaced`,
3913
+ children: N
3914
+ }),
3915
+ x && (O || k) && /* @__PURE__ */ R(kn, {
3916
+ title: "Focal point & crops",
3917
+ children: /* @__PURE__ */ z("div", {
3918
+ className: "flex flex-col gap-6",
3919
+ children: [
3920
+ O && S && /* @__PURE__ */ R(la, {
3921
+ id: r,
3922
+ src: S,
3923
+ focus: Ge(v).focus,
3924
+ disabled: o,
3925
+ onImageSize: A,
3926
+ onChange: (e) => {
3927
+ let { focus: t, ...n } = v;
3928
+ F(e ? {
3929
+ ...n,
3930
+ focus: e
3931
+ } : n);
3932
+ }
3933
+ }),
3934
+ k && S && /* @__PURE__ */ R(ea, {
3935
+ id: r,
3936
+ src: S,
3937
+ size: te,
3938
+ value: Ge(v),
3939
+ ratios: pa(n, it(c.site.images?.ratios)),
3940
+ disabled: o,
3941
+ onChange: (e) => {
3942
+ let { crops: t, ...n } = v;
3943
+ F(Object.keys(e).length > 0 ? {
3944
+ ...n,
3945
+ crops: e
3946
+ } : n);
3947
+ }
3948
+ }),
3949
+ k && !O && S && /* @__PURE__ */ R("img", {
3950
+ src: S,
3951
+ alt: "",
3952
+ hidden: !0,
3953
+ onLoad: (e) => {
3954
+ let { naturalWidth: t, naturalHeight: n } = e.currentTarget;
3955
+ t > 0 && n > 0 && A({
3956
+ width: t,
3957
+ height: n
3958
+ });
3959
+ }
3960
+ })
3961
+ ]
3962
+ })
3963
+ }),
3964
+ /* @__PURE__ */ R(qi, {
3965
+ isOpen: u,
3966
+ onOpenChange: f,
3967
+ kind: "image",
3968
+ folder: da(x, c.site.srcDir, l.collection.name),
3969
+ onChoose: (e, t) => {
3970
+ m(t ?? []), P(e), requestAnimationFrame(() => {
3971
+ document.getElementById(r)?.focus();
3972
+ });
3973
+ }
3974
+ })
3975
+ ]
3976
+ });
3977
+ }
3978
+ function ha(e) {
3979
+ let t = typeof e == "string" ? e.split(",") : Array.isArray(e) ? e : [], n = {
3980
+ "application/pdf": ["pdf"],
3981
+ "video/mp4": ["mp4"],
3982
+ "audio/mpeg": ["mp3"],
3983
+ "text/csv": ["csv"]
3984
+ };
3985
+ return t.flatMap((e) => {
3986
+ let t = String(e).trim().toLowerCase();
3987
+ return t.startsWith(".") ? [t.slice(1)] : n[t] ?? [];
3988
+ });
3989
+ }
3990
+ function ga({ value: e, onChange: t, field: n, id: r, describedBy: i, disabled: a }) {
3991
+ let o = X(), [s, c] = d(!1), l = typeof e == "string" ? e : "", u = l ? et(l, o.entryPath) : null, f = Pr(u), p = ha(n.widgetOptions?.accept);
3992
+ return /* @__PURE__ */ z("div", {
3993
+ className: "flex flex-col gap-2",
3994
+ children: [
3995
+ l && /* @__PURE__ */ z("p", {
3996
+ id: `${r}-file`,
3997
+ className: "text-small",
3998
+ children: [
3999
+ u && f ? /* @__PURE__ */ R("a", {
4000
+ href: f,
4001
+ target: "_blank",
4002
+ rel: "noopener noreferrer",
4003
+ className: "text-accent underline underline-offset-2",
4004
+ children: fa(l)
4005
+ }) : fa(l),
4006
+ " ",
4007
+ /* @__PURE__ */ z("span", {
4008
+ className: "text-content-muted",
4009
+ children: [
4010
+ "(",
4011
+ Be(l).toUpperCase() || "file",
4012
+ ")"
4013
+ ]
4014
+ })
4015
+ ]
4016
+ }),
4017
+ /* @__PURE__ */ z("div", {
4018
+ className: "flex flex-wrap gap-2",
4019
+ children: [/* @__PURE__ */ R(K, {
4020
+ id: r,
4021
+ isDisabled: a,
4022
+ "aria-describedby": [i, l ? `${r}-file` : ""].filter(Boolean).join(" ") || void 0,
4023
+ onPress: () => {
4024
+ c(!0);
4025
+ },
4026
+ children: l ? "Replace file" : "Choose file"
4027
+ }), l && /* @__PURE__ */ R(K, {
4028
+ variant: "quiet",
4029
+ isDisabled: a,
4030
+ onPress: () => {
4031
+ t(n.required ? "" : void 0);
4032
+ },
4033
+ children: "Remove file"
4034
+ })]
4035
+ }),
4036
+ /* @__PURE__ */ R(qi, {
4037
+ isOpen: s,
4038
+ onOpenChange: c,
4039
+ kind: "file",
4040
+ extensions: p,
4041
+ folder: u ? Re(u) : "public/files",
4042
+ onChoose: (e) => {
4043
+ t(Je(e, o.entryPath)), requestAnimationFrame(() => {
4044
+ document.getElementById(r)?.focus();
4045
+ });
4046
+ }
4047
+ })
4048
+ ]
4049
+ });
4050
+ }
4051
+ //#endregion
4052
+ //#region src/widgets/reference.tsx
4053
+ function _a(e) {
4054
+ if (typeof e == "string") return e;
4055
+ if (B(e)) {
4056
+ let t = e.id ?? e.slug;
4057
+ if (typeof t == "string") return t;
4058
+ }
4059
+ }
4060
+ function va(e, t) {
4061
+ return B(e) ? {
4062
+ ...e,
4063
+ id: t
4064
+ } : t;
4065
+ }
4066
+ function ya(e) {
4067
+ let { api: t, collection: n } = J(), r = X(), [i] = cr(() => e ? t.listEntries(e) : Promise.resolve([]), e ?? ""), a = l(() => i.state === "ready" ? i.value : [], [i]);
4068
+ return {
4069
+ options: l(() => {
4070
+ let t = a.filter((t) => e !== r.collection.name || t.id !== r.entryId), n = /* @__PURE__ */ new Map();
4071
+ for (let e of t) n.set(e.title, (n.get(e.title) ?? 0) + 1);
4072
+ return t.map((e) => ({
4073
+ value: e.id,
4074
+ label: (n.get(e.title) ?? 0) > 1 ? `${e.title} (${e.id})` : e.title
4075
+ }));
4076
+ }, [
4077
+ a,
4078
+ e,
4079
+ r.collection.name,
4080
+ r.entryId
4081
+ ]),
4082
+ load: i,
4083
+ label: (e ? n(e)?.label : void 0) ?? e ?? "entries"
4084
+ };
4085
+ }
4086
+ function ba(e, t) {
4087
+ return e.find((e) => e.value === t)?.label ?? `${t} (not found)`;
4088
+ }
4089
+ function xa(e) {
4090
+ return e.reference?.collection ?? e.children?.[0]?.reference?.collection;
4091
+ }
4092
+ function Sa({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4093
+ let { options: s, load: c, label: l } = ya(xa(n)), u = _a(e), d = u && !s.some((e) => e.value === u) ? [...s, {
4094
+ value: u,
4095
+ label: ba(s, u)
4096
+ }] : s;
4097
+ return /* @__PURE__ */ R(Pn, {
4098
+ id: r,
4099
+ "aria-labelledby": `${r}-label`,
4100
+ "aria-describedby": i,
4101
+ options: d,
4102
+ value: u ?? null,
4103
+ onChange: (n) => {
4104
+ t(n === null ? void 0 : va(e, n));
4105
+ },
4106
+ placeholder: c.state === "loading" ? "Loading…" : `Search ${l.toLowerCase()}`,
4107
+ isInvalid: a,
4108
+ isDisabled: o
4109
+ });
4110
+ }
4111
+ function Ca({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4112
+ let { options: s, load: c, label: l } = ya(xa(n)), d = Array.isArray(e) ? e : [], f = d.map(_a), p = u(null), m = (e) => {
4113
+ p.current && (p.current.textContent = e);
4114
+ }, h = (e) => {
4115
+ t(e.length === 0 && !n.required ? void 0 : e);
4116
+ }, g = (e, t) => {
4117
+ let n = [...d], [r] = n.splice(e, 1);
4118
+ n.splice(t, 0, r), h(n), m(`Moved ${ba(s, _a(r) ?? "")} to position ${String(t + 1)}.`);
4119
+ }, _ = s.filter((e) => !f.includes(e.value));
4120
+ return /* @__PURE__ */ z("div", {
4121
+ className: "flex flex-col gap-3",
4122
+ children: [
4123
+ d.length > 0 && /* @__PURE__ */ R("ol", {
4124
+ className: "flex flex-col divide-y divide-border border-y border-border",
4125
+ children: d.map((e, t) => {
4126
+ let n = ba(s, _a(e) ?? "");
4127
+ return /* @__PURE__ */ z("li", {
4128
+ className: "flex flex-wrap items-center gap-2 py-2",
4129
+ children: [
4130
+ /* @__PURE__ */ R("span", {
4131
+ className: "min-w-0 flex-1",
4132
+ children: n
4133
+ }),
4134
+ /* @__PURE__ */ R(K, {
4135
+ variant: "quiet",
4136
+ isDisabled: o || t === 0,
4137
+ onPress: () => {
4138
+ g(t, t - 1);
4139
+ },
4140
+ "aria-label": `Move ${n} up`,
4141
+ children: "Up"
4142
+ }),
4143
+ /* @__PURE__ */ R(K, {
4144
+ variant: "quiet",
4145
+ isDisabled: o || t === d.length - 1,
4146
+ onPress: () => {
4147
+ g(t, t + 1);
4148
+ },
4149
+ "aria-label": `Move ${n} down`,
4150
+ children: "Down"
4151
+ }),
4152
+ /* @__PURE__ */ R(K, {
4153
+ variant: "quiet",
4154
+ isDisabled: o,
4155
+ onPress: () => {
4156
+ h(d.filter((e, n) => n !== t)), m(`Removed ${n}.`), document.getElementById(r)?.focus();
4157
+ },
4158
+ "aria-label": `Remove ${n}`,
4159
+ children: "Remove"
4160
+ })
4161
+ ]
4162
+ }, `${String(_a(e))}-${String(t)}`);
4163
+ })
4164
+ }),
4165
+ /* @__PURE__ */ R(Pn, {
4166
+ id: r,
4167
+ "aria-labelledby": `${r}-label`,
4168
+ "aria-describedby": i,
4169
+ options: _,
4170
+ value: null,
4171
+ onChange: (e) => {
4172
+ e !== null && (h([...d, e]), m(`Added ${ba(s, e)}.`));
4173
+ },
4174
+ placeholder: c.state === "loading" ? "Loading…" : `Add from ${l.toLowerCase()}`,
4175
+ isInvalid: a,
4176
+ isDisabled: o
4177
+ }),
4178
+ /* @__PURE__ */ R("p", {
4179
+ ref: p,
4180
+ role: "status",
4181
+ className: "sr-only"
4182
+ })
4183
+ ]
4184
+ });
4185
+ }
4186
+ //#endregion
4187
+ //#region src/widgets/markdown-lazy.tsx
4188
+ var wa = i(() => import("./markdown-KUkv11EB.js").then((e) => ({ default: e.MarkdownWidget })));
4189
+ function Ta(e) {
4190
+ return /* @__PURE__ */ R(t, {
4191
+ fallback: /* @__PURE__ */ R("p", {
4192
+ role: "status",
4193
+ className: "text-small text-content-muted",
4194
+ children: "Loading the editor…"
4195
+ }),
4196
+ children: /* @__PURE__ */ R(wa, { ...e })
4197
+ });
4198
+ }
4199
+ //#endregion
4200
+ //#region src/editor/PagePicker.tsx
4201
+ var Ea = /* @__PURE__ */ new WeakMap();
4202
+ function Da() {
4203
+ let { api: e } = J(), [t, n] = d([]);
4204
+ return s(() => {
4205
+ let t = !0, r = Ea.get(e);
4206
+ return r || (r = e.listPages(), Ea.set(e, r)), r.then((e) => {
4207
+ t && n(e);
4208
+ }, () => {
4209
+ Ea.delete(e);
4210
+ }), () => {
4211
+ t = !1;
4212
+ };
4213
+ }, [e]), t;
4214
+ }
4215
+ function Oa(e) {
4216
+ return e.map((e) => ({
4217
+ value: e.url,
4218
+ label: e.title,
4219
+ detail: e.url
4220
+ }));
4221
+ }
4222
+ function ka({ onPick: e, absolute: t, fieldLabel: n, isDisabled: r }) {
4223
+ let i = Da(), [a, o] = d(!1), s = l(() => i.map((e) => ({
4224
+ value: t ? new URL(e.url, t).href : e.url,
4225
+ label: `${e.title} (${e.url})`
4226
+ })), [i, t]);
4227
+ return i.length === 0 ? null : /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R(K, {
4228
+ variant: "quiet",
4229
+ ...r ? { isDisabled: r } : {},
4230
+ onPress: () => {
4231
+ o(!0);
4232
+ },
4233
+ "aria-label": `Choose a page for ${n}`,
4234
+ children: "Choose a page…"
4235
+ }), /* @__PURE__ */ R(Sn, {
4236
+ title: "Choose a page",
4237
+ isOpen: a,
4238
+ onOpenChange: o,
4239
+ children: /* @__PURE__ */ R(Pn, {
4240
+ label: "Page",
4241
+ description: "Search by title. Its address goes in the field.",
4242
+ options: s,
4243
+ value: null,
4244
+ onChange: (t) => {
4245
+ t && (e(t), o(!1));
4246
+ }
4247
+ })
4248
+ })] });
4249
+ }
4250
+ //#endregion
4251
+ //#region src/widgets/special.tsx
4252
+ var Aa = /^#[0-9a-f]{6}$/i;
4253
+ function ja(e, ...t) {
4254
+ return [e, ...t].filter(Boolean).join(" ");
4255
+ }
4256
+ function Ma({ color: e }) {
4257
+ return /* @__PURE__ */ R("span", {
4258
+ className: "inline-block size-6 shrink-0 rounded-sm border border-border-strong",
4259
+ style: { backgroundColor: e }
4260
+ });
4261
+ }
4262
+ function Na({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4263
+ let s = n.widgetOptions?.palette, c = typeof e == "string" ? e : "";
4264
+ if (s && Object.keys(s).length > 0) {
4265
+ let e = Object.entries(s).map(([e, t]) => ({
4266
+ value: t,
4267
+ label: `${e} (${t})`,
4268
+ prefix: /* @__PURE__ */ R(Ma, { color: t })
4269
+ }));
4270
+ return c && !e.some((e) => e.value.toLowerCase() === c.toLowerCase()) && e.push({
4271
+ value: c,
4272
+ label: `Current colour (${c})`,
4273
+ prefix: /* @__PURE__ */ R(Ma, { color: c })
4274
+ }), /* @__PURE__ */ R(zn, {
4275
+ id: r,
4276
+ "aria-labelledby": `${r}-label`,
4277
+ "aria-describedby": i,
4278
+ options: e,
4279
+ value: e.find((e) => e.value.toLowerCase() === c.toLowerCase())?.value ?? null,
4280
+ onChange: t,
4281
+ isInvalid: a,
4282
+ isDisabled: o
4283
+ });
4284
+ }
4285
+ return /* @__PURE__ */ z("div", {
4286
+ className: "flex items-center gap-3",
4287
+ children: [/* @__PURE__ */ R("input", {
4288
+ id: r,
4289
+ type: "text",
4290
+ value: c,
4291
+ placeholder: "#1a73e8",
4292
+ spellCheck: !1,
4293
+ autoComplete: "off",
4294
+ onChange: (e) => {
4295
+ t(e.target.value === "" && !n.required ? void 0 : e.target.value);
4296
+ },
4297
+ "aria-describedby": i,
4298
+ "aria-invalid": a || void 0,
4299
+ "aria-required": n.required || void 0,
4300
+ disabled: o,
4301
+ className: V(Z, "max-w-40 font-mono")
4302
+ }), n.widgetOptions?.alpha !== !0 && /* @__PURE__ */ R("input", {
4303
+ type: "color",
4304
+ "aria-label": `Pick ${n.label.toLowerCase()} from a colour picker`,
4305
+ value: Aa.test(c) ? c.toLowerCase() : "#000000",
4306
+ onChange: (e) => {
4307
+ t(e.target.value);
4308
+ },
4309
+ disabled: o,
4310
+ className: "size-10 cursor-pointer rounded-md border border-border-strong bg-surface p-1 focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)"
4311
+ })]
4312
+ });
4313
+ }
4314
+ function Pa({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4315
+ let c = X(), l = typeof n.widgetOptions?.from == "string" ? n.widgetOptions.from : void 0, u = l ? c.values[l] : void 0, f = typeof u == "string" ? u : "", p = typeof e == "string" ? e : "", [m, h] = d(() => c.isNew && l !== void 0 && (p === "" || p === Fa(f)));
4316
+ s(() => {
4317
+ if (!m) return;
4318
+ let e = Fa(f);
4319
+ e !== p && t(e === "" && !n.required ? void 0 : e);
4320
+ }, [
4321
+ m,
4322
+ f,
4323
+ p,
4324
+ t,
4325
+ n.required
4326
+ ]);
4327
+ let g = c.collection.fields?.find((e) => e.path[0] === l)?.label ?? l;
4328
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("input", {
4329
+ id: r,
4330
+ type: "text",
4331
+ value: p,
4332
+ spellCheck: !1,
4333
+ autoComplete: "off",
4334
+ onChange: (e) => {
4335
+ h(!1), t(e.target.value === "" && !n.required ? void 0 : e.target.value);
4336
+ },
4337
+ "aria-describedby": ja(i, m && `${r}-follows`),
4338
+ "aria-invalid": a || void 0,
4339
+ "aria-required": n.required || void 0,
4340
+ disabled: o,
4341
+ className: V(Z, "font-mono")
4342
+ }), m && g && /* @__PURE__ */ z("p", {
4343
+ id: `${r}-follows`,
4344
+ className: "text-small text-content-muted",
4345
+ children: [
4346
+ "Follows the ",
4347
+ g.toLowerCase(),
4348
+ " until you edit it."
4349
+ ]
4350
+ })] });
4351
+ }
4352
+ function Fa(e) {
4353
+ return at(e).replaceAll("/", "-");
4354
+ }
4355
+ function Ia({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4356
+ let { manifest: s } = J(), c = typeof e == "string" ? e : "", l = /^https?:\/\/\S+$/i.test(c), u = s.site.urls?.site, d = n.format !== "url" || u !== void 0;
4357
+ return /* @__PURE__ */ z("div", {
4358
+ className: "flex flex-wrap items-center gap-3",
4359
+ children: [
4360
+ /* @__PURE__ */ R("input", {
4361
+ id: r,
4362
+ type: "url",
4363
+ inputMode: "url",
4364
+ value: c,
4365
+ placeholder: n.placeholder ?? "https://",
4366
+ onChange: (e) => {
4367
+ t(e.target.value === "" && !n.required ? void 0 : e.target.value);
4368
+ },
4369
+ "aria-describedby": i,
4370
+ "aria-invalid": a || void 0,
4371
+ "aria-required": n.required || void 0,
4372
+ disabled: o,
4373
+ className: Z
4374
+ }),
4375
+ l && /* @__PURE__ */ z("a", {
4376
+ href: c,
4377
+ target: "_blank",
4378
+ rel: "noopener noreferrer",
4379
+ className: "shrink-0 rounded-sm text-accent underline underline-offset-2 hover:text-accent-hover focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-focus focus-visible:ring-6 focus-visible:ring-(color:--glow-focus)",
4380
+ children: ["Open ", /* @__PURE__ */ z("span", {
4381
+ className: "sr-only",
4382
+ children: [c, " in a new tab"]
4383
+ })]
4384
+ }),
4385
+ d && /* @__PURE__ */ R(ka, {
4386
+ fieldLabel: n.label,
4387
+ ...n.format === "url" && u ? { absolute: u } : {},
4388
+ ...o ? { isDisabled: !0 } : {},
4389
+ onPick: (e) => {
4390
+ t(e);
4391
+ }
4392
+ })
4393
+ ]
4394
+ });
4395
+ }
4396
+ function La({ value: e, onChange: t, field: n, id: r, describedBy: i, invalid: a, disabled: o }) {
4397
+ let { manifest: s } = J(), { zone: c, isSite: l } = tt(s.site.timeZone), u = e instanceof Date ? e : typeof e == "string" && e ? new Date(e) : null, d = u !== null && !Number.isNaN(u.getTime()), f = ct(c, d ? u : /* @__PURE__ */ new Date());
4398
+ return /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ R("input", {
4399
+ id: r,
4400
+ type: "datetime-local",
4401
+ value: d ? st(u, c) : "",
4402
+ onChange: (n) => {
4403
+ if (n.target.value === "") {
4404
+ t(void 0);
4405
+ return;
4406
+ }
4407
+ let r = He(n.target.value, c);
4408
+ r && t(typeof e == "string" ? qe(r, Xe(r) ?? 0) : r);
4409
+ },
4410
+ "aria-describedby": ja(i, `${r}-zone`),
4411
+ "aria-invalid": a || void 0,
4412
+ "aria-required": n.required || void 0,
4413
+ disabled: o,
4414
+ required: n.required,
4415
+ className: V(Z, "max-w-64")
4416
+ }), /* @__PURE__ */ R("p", {
4417
+ id: `${r}-zone`,
4418
+ className: "text-small text-content-muted",
4419
+ children: l ? `Times are in ${f}, the site’s time zone.` : `Times are in your time zone, ${f}.`
4420
+ })] });
4421
+ }
4422
+ //#endregion
4423
+ //#region src/widgets/registry.ts
4424
+ var Ra = {
4425
+ text: { component: vr },
4426
+ textarea: { component: br },
4427
+ email: { component: yr },
4428
+ url: { component: Ia },
4429
+ number: { component: xr },
4430
+ switch: { component: Sr },
4431
+ date: { component: wr },
4432
+ datetime: { component: La },
4433
+ select: { component: Er },
4434
+ radio: {
4435
+ component: Dr,
4436
+ group: !0
4437
+ },
4438
+ icon: { component: gi },
4439
+ tags: { component: Or },
4440
+ multiselect: { component: Or },
4441
+ group: {
4442
+ component: Yr,
4443
+ group: !0,
4444
+ rendersChildren: !0,
4445
+ section: !0
4446
+ },
4447
+ union: {
4448
+ component: Jr,
4449
+ group: !0,
4450
+ rendersChildren: !0,
4451
+ section: !0
4452
+ },
4453
+ repeater: {
4454
+ component: di,
4455
+ group: !0,
4456
+ rendersChildren: !0,
4457
+ section: !0
4458
+ },
4459
+ raw: { component: kr },
4460
+ markdown: { component: Ta },
4461
+ slug: { component: Pa },
4462
+ color: { component: Na },
4463
+ geo: {
4464
+ component: Mr,
4465
+ group: "boxed"
4466
+ },
4467
+ reference: { component: Sa },
4468
+ references: {
4469
+ component: Ca,
4470
+ group: !0
4471
+ },
4472
+ image: {
4473
+ component: ma,
4474
+ group: "boxed",
4475
+ childControls: { alt: "-alt" }
4476
+ },
4477
+ file: {
4478
+ component: ga,
4479
+ group: !0
4480
+ }
4481
+ }, za = {
4482
+ string: "text",
4483
+ number: "number",
4484
+ boolean: "switch",
4485
+ date: "date",
4486
+ enum: "select",
4487
+ object: "group",
4488
+ union: "union",
4489
+ array: "repeater",
4490
+ reference: "reference",
4491
+ image: "image"
4492
+ };
4493
+ function Ba(e) {
4494
+ for (let t of [
4495
+ e.widget,
4496
+ e.inferredWidget,
4497
+ za[e.kind]
4498
+ ]) {
4499
+ let e = t ? Ra[t] : void 0;
4500
+ if (e) return e;
4501
+ }
4502
+ return Ra.raw;
4503
+ }
4504
+ //#endregion
4505
+ //#region src/editor/Field.tsx
4506
+ function Va({ field: e, path: n, label: r, item: i, asSection: a = !0 }) {
4507
+ let o = X(), { widgets: s } = J(), c = fr(n, o.idPrefix), l = o.issues.get(pr(n)) ?? [], u = e.widget ? s[e.widget] : void 0, d = Ba(e), f = u ? void 0 : d.childControls, p = (o.notes?.get(pr(n)) ?? []).filter((e) => {
4508
+ let t = e.target.kind === "field" ? e.target.path[n.length] : void 0;
4509
+ return !(typeof t == "string" && f && t in f);
4510
+ }), m = e.description ? `${c}-help` : void 0, h = l.length > 0 ? `${c}-error` : void 0, g = p.length > 0 ? `${c}-a11y` : void 0, _ = [
4511
+ m,
4512
+ h,
4513
+ g
4514
+ ].filter(Boolean).join(" ") || void 0, v = {
4515
+ value: lr(o.values, n),
4516
+ onChange: (e) => {
4517
+ o.setValue(n, e);
4518
+ },
4519
+ field: e,
4520
+ id: c,
4521
+ describedBy: _,
4522
+ invalid: l.length > 0,
4523
+ disabled: o.disabled || e.readOnly === !0,
4524
+ path: n
4525
+ }, y = i === "row" ? {
4526
+ ...v,
4527
+ inRow: !0
4528
+ } : v, b = u ? /* @__PURE__ */ R(Ha, {
4529
+ fallback: /* @__PURE__ */ R(d.component, { ...y }),
4530
+ name: e.widget ?? "",
4531
+ children: /* @__PURE__ */ R(t, {
4532
+ fallback: /* @__PURE__ */ R("p", {
4533
+ className: "text-small text-content-muted",
4534
+ children: "Loading…"
4535
+ }),
4536
+ children: /* @__PURE__ */ R(u, { ...v })
4537
+ })
4538
+ }) : /* @__PURE__ */ R(d.component, { ...y }), x = r ?? e.label, S = !e.required && !i && e.kind !== "boolean" && e.readOnly !== !0 ? /* @__PURE__ */ R(sn, {}) : null, C = m ? /* @__PURE__ */ R("p", {
4539
+ id: m,
4540
+ className: "text-small text-content-muted",
4541
+ children: e.description
4542
+ }) : null, w = h ? /* @__PURE__ */ R("p", {
4543
+ id: h,
4544
+ className: "text-small text-danger",
4545
+ children: l.join(" ")
4546
+ }) : null, T = g ? /* @__PURE__ */ R(vi, {
4547
+ id: g,
4548
+ notes: p
4549
+ }) : null;
4550
+ if (!u && d.group) {
4551
+ let t = d.section && n.length === 1 && a && !o.idPrefix && !i, r = d.section && (e.kind === "object" || e.kind === "union") && !t && i !== "row", s = /* @__PURE__ */ z("fieldset", {
4552
+ "aria-describedby": _,
4553
+ className: V("flex min-w-0 flex-col gap-2", t && "gap-3", r && "border-l border-border pl-4", d.group === "boxed" && !i && "rounded-md border border-border p-4"),
4554
+ children: [
4555
+ /* @__PURE__ */ R("legend", {
4556
+ id: `${c}-label`,
4557
+ tabIndex: -1,
4558
+ className: V("mb-1 outline-none", i === "row" ? "sr-only" : "text-label text-content"),
4559
+ children: t ? /* @__PURE__ */ z("h2", {
4560
+ className: "text-heading-3 text-content",
4561
+ children: [x, S]
4562
+ }) : /* @__PURE__ */ z(L, { children: [x, S] })
4563
+ }),
4564
+ C,
4565
+ b,
4566
+ w,
4567
+ T
4568
+ ]
4569
+ });
4570
+ return t ? /* @__PURE__ */ R("div", {
4571
+ className: "mt-4 border-t border-border pt-6",
4572
+ children: s
4573
+ }) : s;
4574
+ }
4575
+ return /* @__PURE__ */ z("div", {
4576
+ className: "flex min-w-0 flex-col gap-2",
4577
+ children: [
4578
+ /* @__PURE__ */ z("label", {
4579
+ id: `${c}-label`,
4580
+ htmlFor: c,
4581
+ className: "text-label text-content",
4582
+ children: [x, S]
4583
+ }),
4584
+ b,
4585
+ C,
4586
+ w,
4587
+ T
4588
+ ]
4589
+ });
4590
+ }
4591
+ var Ha = class extends e {
4592
+ state = { failed: !1 };
4593
+ static getDerivedStateFromError() {
4594
+ return { failed: !0 };
4595
+ }
4596
+ render() {
4597
+ return this.state.failed ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("p", {
4598
+ className: "text-small text-content-muted",
4599
+ children: [
4600
+ "The “",
4601
+ this.props.name,
4602
+ "” control couldn’t load, so this is a plain one."
4603
+ ]
4604
+ }), this.props.fallback] }) : this.props.children;
4605
+ }
4606
+ }, Ua = typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
4607
+ function Wa(...e) {
4608
+ let t = e.at(-1) ?? "", n = e.slice(0, -1);
4609
+ if (Ua) {
4610
+ let e = {
4611
+ Alt: "⌥",
4612
+ Shift: "⇧",
4613
+ Mod: "⌘"
4614
+ }, r = [
4615
+ "Alt",
4616
+ "Shift",
4617
+ "Mod"
4618
+ ].filter((e) => n.includes(e));
4619
+ return {
4620
+ text: `${r.map((t) => e[t]).join("")}${t}`,
4621
+ aria: [...r.map((e) => e === "Mod" ? "Meta" : e), t].join("+")
4622
+ };
4623
+ }
4624
+ return {
4625
+ text: [...n.map((e) => e === "Mod" ? "Ctrl" : e), t].join("+"),
4626
+ aria: [...n.map((e) => e === "Mod" ? "Control" : e), t].join("+")
4627
+ };
4628
+ }
4629
+ //#endregion
4630
+ export { q as $, cr as A, Jn as B, X as C, Y as D, mr as E, J as F, Un as G, qn as H, nr as I, Ln as J, Hn as K, Me as L, or as M, ir as N, pr as O, rr as P, Bn as Q, er as R, hr as S, lr as T, Kn as U, Xn as V, Wn as W, zn as X, Pn as Y, Nn as Z, Ir as _, ka as a, vn as at, Pr as b, qi as c, pn as ct, Ki as d, hn as dt, Sn as et, Wi as f, G as ft, Gr as g, Xr as h, Ba as i, xn as it, sr as j, ur as k, Xi as l, gn as lt, _i as m, H as mt, Wa as n, On as nt, Oa as o, _n as ot, Bi as p, V as pt, Vn as q, Va as r, wn as rt, Da as s, K as st, Ua as t, Cn as tt, Gi as u, mn as ut, Rr as v, fr as w, Z as x, Fr as y, tr as z };