@bettercms-ai/kit 2.0.5 → 2.0.6
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.
|
@@ -7,7 +7,7 @@ import { useCatalogComponents } from "./catalog.js";
|
|
|
7
7
|
import { ComponentPanel, closeComponentPanel, openComponentPanel, useComponentPanel } from "./component-panel.js";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { IconAdjustmentsHorizontal, IconAlertTriangle, IconArrowBarToDown, IconArrowBarToUp, IconArrowUpRight, IconCheck, IconComponents, IconCopy, IconDots, IconGripVertical, IconLayoutNavbarCollapse, IconLayoutNavbarExpand, IconLink, IconRefresh, IconReplace, IconRestore, IconTrash, IconUnlink } from "@tabler/icons-react";
|
|
10
|
+
import { IconAdjustmentsHorizontal, IconAlertTriangle, IconArrowBarToDown, IconArrowBarToUp, IconArrowUpRight, IconCheck, IconComponents, IconCopy, IconDots, IconEye, IconEyeOff, IconGripVertical, IconLayoutNavbarCollapse, IconLayoutNavbarExpand, IconLink, IconRefresh, IconReplace, IconRestore, IconTrash, IconUnlink } from "@tabler/icons-react";
|
|
11
11
|
//#region src/controls/rich-text/component-card.tsx
|
|
12
12
|
/**
|
|
13
13
|
* The embedded component card (V2 features/blocks/instance-card.tsx + instance-ui.tsx StateChip / MissingNote / dialogs),
|
|
@@ -123,7 +123,8 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
123
123
|
const changed = detached && !missing && laterThan(info?.publishedAt, m.sourcePublishedAt);
|
|
124
124
|
const state = detached ? `Detached${changed ? ", Shared version changed" : ""}` : missing ? "Missing block" : edited || m.variant ? "Edited here" : "Shared";
|
|
125
125
|
const requiredEmpty = !missing && !detached && (info?.fields ?? []).some((f) => f.required && blank(f.key in overrides ? overrides[f.key] : f.value));
|
|
126
|
-
const
|
|
126
|
+
const hidden = m.visible === false;
|
|
127
|
+
const label = `${name} block${known ? `, ${state}` : ""}${known && !missing && !detached && places != null ? `, ${placesShort(places)}` : ""}${requiredEmpty ? `. ${REQUIRED_EMPTY}` : ""}${hidden ? `${requiredEmpty ? "" : "."} Hidden on your site` : ""}`;
|
|
127
128
|
const rows = detached ? copyRows(own, info?.fields, m.variant) : previewRows(missing, info?.fields, overrides, variant);
|
|
128
129
|
const image = missing || detached || edited || variant ? null : info?.image || null;
|
|
129
130
|
const liveProps = React.useMemo(() => detached ? own : {
|
|
@@ -207,6 +208,7 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
207
208
|
props: JSON.stringify(copy.props),
|
|
208
209
|
...copy.blocks !== void 0 ? { blocks: copy.blocks } : {},
|
|
209
210
|
...copy.sourcePublishedAt ? { sourcePublishedAt: copy.sourcePublishedAt } : {},
|
|
211
|
+
...cur.visible !== void 0 ? { visible: cur.visible } : {},
|
|
210
212
|
...cur.extra !== void 0 ? { extra: cur.extra } : {}
|
|
211
213
|
}), "Make a separate copy", title, "It keeps its content and no longer follows the shared block.");
|
|
212
214
|
} catch (e) {
|
|
@@ -225,6 +227,7 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
225
227
|
...cur.name !== void 0 ? { name: info?.name ?? cur.name } : {},
|
|
226
228
|
...mode === "keep" && Object.keys(kept).length ? { overrides: JSON.stringify(kept) } : {},
|
|
227
229
|
...mode === "keep" && cur.variant !== void 0 ? { variant: cur.variant } : {},
|
|
230
|
+
...cur.visible !== void 0 ? { visible: cur.visible } : {},
|
|
228
231
|
...cur.extra !== void 0 ? { extra: cur.extra } : {}
|
|
229
232
|
}), "Use shared version again", `${name} is shared again`, mode === "keep" && n ? `${n} ${n === 1 ? "edit" : "edits"} kept here.` : "It shows the block's content.");
|
|
230
233
|
};
|
|
@@ -249,9 +252,15 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
249
252
|
ref: to.id,
|
|
250
253
|
name: next.name || to.name,
|
|
251
254
|
overrides: JSON.stringify(kept),
|
|
255
|
+
...cur.visible !== void 0 ? { visible: cur.visible } : {},
|
|
252
256
|
...cur.extra !== void 0 ? { extra: cur.extra } : {}
|
|
253
257
|
}), `Swap to ${to.name}`, `Swapped to ${to.name}`, n ? `Kept ${n} ${n === 1 ? "edit" : "edits"} made here.` : "It shows the block's own content.");
|
|
254
258
|
};
|
|
259
|
+
/** "Show on site": one undo step, the toast offers it back. Showing again writes `visible: true`, as an insert does. */
|
|
260
|
+
const toggleVisible = () => commit((cur) => ({
|
|
261
|
+
...cur,
|
|
262
|
+
visible: hidden
|
|
263
|
+
}), hidden ? "Show on your site" : "Hide on your site", hidden ? `${name} is back on your site` : `${name} is hidden on your site`, hidden ? "Readers see it in this place again." : "It stays here with its values. Readers don't see it.");
|
|
255
264
|
const copyLink = () => {
|
|
256
265
|
if (!href) return;
|
|
257
266
|
navigator.clipboard?.writeText(href).catch(() => {});
|
|
@@ -322,6 +331,7 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
322
331
|
requiredEmpty,
|
|
323
332
|
compact
|
|
324
333
|
}) : null;
|
|
334
|
+
const chips = (compact) => /* @__PURE__ */ jsxs(Fragment, { children: [chip(compact), hidden ? /* @__PURE__ */ jsx(HiddenChip, { compact }) : null] });
|
|
325
335
|
return /* @__PURE__ */ jsxs("div", {
|
|
326
336
|
ref: cardRef,
|
|
327
337
|
role: "group",
|
|
@@ -334,6 +344,7 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
334
344
|
"data-instance-card": "",
|
|
335
345
|
"data-rt-isolate": "",
|
|
336
346
|
"data-state": detached ? "detached" : missing ? "missing" : known ? "linked" : void 0,
|
|
347
|
+
"data-hidden": hidden ? "" : void 0,
|
|
337
348
|
onKeyDown,
|
|
338
349
|
onClick: (e) => {
|
|
339
350
|
if (!e.currentTarget.contains(e.target) || e.target.closest("button,a,[role=menuitem],[role=note],[role=alert]")) return;
|
|
@@ -372,7 +383,7 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
372
383
|
className: "min-w-0 shrink truncate text-kit-sm font-medium text-kit-fg",
|
|
373
384
|
children: name
|
|
374
385
|
}),
|
|
375
|
-
|
|
386
|
+
chips(narrow),
|
|
376
387
|
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
377
388
|
/* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, { render: /* @__PURE__ */ jsx(IconButton, {
|
|
378
389
|
size: "sm",
|
|
@@ -388,6 +399,11 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
388
399
|
onClick: () => openPanel(),
|
|
389
400
|
children: "Edit properties"
|
|
390
401
|
}) : null,
|
|
402
|
+
!ro ? /* @__PURE__ */ jsx(MenuItem, {
|
|
403
|
+
icon: hidden ? /* @__PURE__ */ jsx(IconEye, { stroke: 1.5 }) : /* @__PURE__ */ jsx(IconEyeOff, { stroke: 1.5 }),
|
|
404
|
+
onClick: toggleVisible,
|
|
405
|
+
children: hidden ? "Show on your site" : "Hide on your site"
|
|
406
|
+
}) : null,
|
|
391
407
|
editAll ? /* @__PURE__ */ jsx(MenuItem, {
|
|
392
408
|
icon: /* @__PURE__ */ jsx(IconArrowUpRight, { stroke: 1.5 }),
|
|
393
409
|
onClick: editAll.run,
|
|
@@ -527,7 +543,10 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
527
543
|
})
|
|
528
544
|
]
|
|
529
545
|
}) : null,
|
|
530
|
-
collapsed ? null : preview,
|
|
546
|
+
collapsed ? null : hidden && preview ? /* @__PURE__ */ jsx("div", {
|
|
547
|
+
className: "opacity-50",
|
|
548
|
+
children: preview
|
|
549
|
+
}) : preview,
|
|
531
550
|
canCopy ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DetachDialog, {
|
|
532
551
|
open: dialog === "detach",
|
|
533
552
|
name,
|
|
@@ -561,7 +580,7 @@ function ComponentCard({ m, el, ctx, use, overrides, set }) {
|
|
|
561
580
|
}) : null,
|
|
562
581
|
open ? /* @__PURE__ */ jsx(ComponentPanel, {
|
|
563
582
|
name,
|
|
564
|
-
chip:
|
|
583
|
+
chip: chips(false),
|
|
565
584
|
anchor: cardEl,
|
|
566
585
|
open,
|
|
567
586
|
editAll,
|
|
@@ -653,6 +672,25 @@ function StateChip({ missing, places, edited, layout, requiredEmpty, compact })
|
|
|
653
672
|
});
|
|
654
673
|
}
|
|
655
674
|
var CHIP = "inline-flex h-6 shrink-0 items-center gap-1 rounded-kit-md text-[13px] leading-none whitespace-nowrap";
|
|
675
|
+
/** "Show on site" off: fg-3, the eye-off glyph. Never by colour alone: the words (or, narrow, their screen-reader copy) say it. */
|
|
676
|
+
function HiddenChip({ compact }) {
|
|
677
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
678
|
+
content: "Readers don't see this block. It stays here with its values. Choose Show on your site in the block's menu to bring it back.",
|
|
679
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
680
|
+
"data-hidden-chip": "",
|
|
681
|
+
className: cn(CHIP, "px-1 text-kit-fg-3"),
|
|
682
|
+
tabIndex: -1,
|
|
683
|
+
children: [/* @__PURE__ */ jsx(IconEyeOff, {
|
|
684
|
+
className: "size-3.5 shrink-0",
|
|
685
|
+
stroke: 1.5,
|
|
686
|
+
"aria-hidden": true
|
|
687
|
+
}), compact ? /* @__PURE__ */ jsx("span", {
|
|
688
|
+
className: "sr-only",
|
|
689
|
+
children: "Hidden on your site"
|
|
690
|
+
}) : "Hidden on your site"]
|
|
691
|
+
})
|
|
692
|
+
});
|
|
693
|
+
}
|
|
656
694
|
/** V2 StateChip, detached: fg-3, the unlink glyph. */
|
|
657
695
|
function DetachedChip({ name, compact }) {
|
|
658
696
|
return /* @__PURE__ */ jsx(Tooltip, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-card.js","names":[],"sources":["../../../src/controls/rich-text/component-card.tsx"],"sourcesContent":["/**\n * The embedded component card (V2 features/blocks/instance-card.tsx + instance-ui.tsx StateChip / MissingNote / dialogs),\n * drawn when the host can look the component up (KitServices.useComponentInfo, component-services.ts):\n *\n * ┌ [icon] Inline CTA 🔗 2 places · ● Edited here ⋯ ┐ 36px strip\n * ├ ⚠ The original \"Product card\" was deleted. … [Keep as a separate copy] [Remove] ┤ missing only\n * │ the component itself, drawn live with this place's values (KitServices.ComponentPreview), else │\n * │ its snapshot where this place shows exactly that, else its fields; at most 240px, faded │\n * └──────────────────────────────────────────────────────────────────────────────┘\n *\n * Every state comes from the lookup or the stored copy: \"Missing component\" only when the library says there is no\n * such component, the count only when the host measured it, \"Edited here\" only for overrides of fields the component\n * has, \"Detached\" for a separate copy (V2 instances.ts `detached`), and \"Shared version changed\" only when the\n * component's current version (`info.publishedAt`) differs from the one the copy was taken from.\n *\n * A separate copy is made through the host (`copyComponent`, which answers what readers see now) and written as ONE\n * undo step (V2 detachNow: \"Make a separate copy\"); \"Use shared version again\" (V2 RelinkDialog) keeps this place's\n * edits as overrides or drops them, also one step. A host without `copyComponent` offers neither.\n *\n * Deviation from V2: V2 shows \"Shared version changed\" on a LINKED instance after a breaking release (instances.ts\n * `pending`). A linked instance here follows every publish of its component, so there is nothing to review; the\n * notice is drawn on a separate copy instead, whose source moved on, and it opens \"Use shared version again\".\n */\nimport * as React from \"react\";\nimport {\n IconAdjustmentsHorizontal, IconAlertTriangle, IconArrowBarToDown, IconArrowBarToUp, IconArrowUpRight, IconCheck, IconComponents, IconCopy, IconDots,\n IconGripVertical, IconLayoutNavbarCollapse, IconLayoutNavbarExpand, IconLink, IconRefresh, IconReplace, IconRestore, IconTrash, IconUnlink,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { eventKey } from \"../../lib/key-event\";\nimport { useKitServices, type KitServices } from \"../../context\";\nimport { Button, IconButton } from \"../../ui/button\";\nimport {\n Menu, MenuContent, MenuItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Tooltip,\n} from \"../../ui/overlay\";\nimport type { KitComponentField, KitComponentInfo, KitComponentPreviewProps, KitInsertableComponent } from \"../component-services\";\nimport type { ComponentModel, IslandEl } from \"./dom\";\nimport type { IslandCtx } from \"./blocks\";\nimport { useCatalogComponents } from \"./catalog\";\nimport { ComponentPanel, closeComponentPanel, openComponentPanel, useComponentPanel } from \"./component-panel\";\n\n/** V2 NARROW: at or under this card width the scope chip shows its icon only. */\nconst NARROW = 480;\n/** V2 PREVIEW_CAP: the preview at rest is at most this tall, faded when its content is taller. */\nconst PREVIEW_H = 240;\n\nconst placesShort = (n: number) => `${n} ${n === 1 ? \"place\" : \"places\"}`;\n\nfunction useWidth(ref: React.RefObject<HTMLElement | null>) {\n const [w, setW] = React.useState(0);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setW(el.clientWidth);\n if (typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => setW(el.clientWidth));\n ro.observe(el);\n return () => ro.disconnect();\n }, [ref]);\n return w;\n}\n\n/** A stored value as one line of reading text, or null when it has none (lists, empty values, flags). */\nfunction readable(v: unknown): string | null {\n if (typeof v === \"number\") return String(v);\n if (typeof v === \"string\") {\n // an inline image (an icon prop) is kilobytes of base64, never readable text\n if (v.startsWith(\"data:image/\")) return \"Image\";\n // tags become spaces; the parser then decodes what is left (`l'Excellence` → l'Excellence, → space)\n const decoded = new DOMParser().parseFromString(v.replace(/<[^>]+>/g, \" \"), \"text/html\").body.textContent ?? \"\";\n const t = decoded.replace(/\\s+/g, \" \").trim();\n return t || null;\n }\n if (v && typeof v === \"object\" && !Array.isArray(v)) {\n // a rich-text value is { html, value, format }; an image { url, altText }\n // truthy, not `??`: an empty label must not hide the html or url after it\n const o = v as { label?: unknown; text?: unknown; title?: unknown; altText?: unknown; href?: unknown; url?: unknown; html?: unknown };\n return readable(o.label || o.text || o.title || o.altText || o.href || o.url || o.html);\n }\n return null;\n}\n\nconst parseObj = (s: string | undefined): Record<string, unknown> => {\n try {\n const v = s ? (JSON.parse(s) as unknown) : {};\n return v && typeof v === \"object\" && !Array.isArray(v) ? (v as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n};\n/** True when `a` is a later instant than `b`; false when either is absent or unreadable (never a made-up \"changed\"). */\nconst laterThan = (a: string | null | undefined, b: string | undefined) => {\n const x = a ? Date.parse(a) : NaN;\n const y = b ? Date.parse(b) : NaN;\n return Number.isFinite(x) && Number.isFinite(y) && x > y;\n};\nconst same = (a: unknown, b: unknown) => a === b || JSON.stringify(a) === JSON.stringify(b);\n\ntype UseComponentInfo = NonNullable<KitServices[\"useComponentInfo\"]>;\n/**\n * \"Collapse preview\", remembered per component (V2 instance-card): read before the first render, so a reload never\n * draws the preview and then folds it away. Storage that is absent or throws reads as expanded.\n */\nfunction useCollapsed(ref: string | undefined): [boolean, (next: boolean) => void] {\n const key = ref ? `bcms:card-collapsed:${ref}` : null;\n const [collapsed, setState] = React.useState(() => {\n try {\n return !!key && globalThis.localStorage?.getItem(key) === \"1\";\n } catch {\n return false;\n }\n });\n const set = React.useCallback(\n (next: boolean) => {\n setState(next);\n if (!key) return;\n try {\n if (next) globalThis.localStorage?.setItem(key, \"1\");\n else globalThis.localStorage?.removeItem(key);\n } catch {\n // not remembered; the card still folds for this session\n }\n },\n [key],\n );\n return [collapsed, set];\n}\n\ntype SetComponent = (patch: Partial<ComponentModel> | ((m: ComponentModel) => ComponentModel), label: string, record?: boolean) => void;\n\nexport function ComponentCard({\n m, el, ctx, use, overrides, set,\n}: { m: ComponentModel; el: IslandEl; ctx: IslandCtx; use: UseComponentInfo; overrides: Record<string, unknown>; set: SetComponent }) {\n const { copyComponent, toast, ComponentPreview, IconGlyph, componentVariantMember, ComponentSettings, openComponent, componentHref } = useKitServices();\n // a linked place's layout is its family's member component (a variant is its own component): the card reads and\n // draws that member, as V2 draws the instance in its variant. No member → the layout stays named in the rows.\n const member = !m.detached && m.ref && m.variant ? componentVariantMember?.(m.ref, m.variant) : undefined;\n const ref = member ?? m.ref;\n const variant = member ? undefined : m.variant;\n const { info, loading, error } = use(ref ?? \"\");\n const card = React.useRef<HTMLDivElement | null>(null);\n const width = useWidth(card);\n const narrow = !!width && width <= NARROW;\n const [collapsed, setCollapsed] = useCollapsed(m.ref);\n const [dialog, setDialog] = React.useState<null | \"detach\" | \"relink\">(null);\n const [busy, setBusy] = React.useState(false);\n const detached = !!m.detached;\n const own = React.useMemo(() => parseObj(m.props), [m.props]);\n const missing = !ref || !!info?.missing;\n const name = info && !info.missing ? info.name : m.name || info?.name || \"Block\";\n const fieldKeys = new Set((info?.fields ?? []).map((f) => f.key));\n const edited = missing || detached ? 0 : Object.keys(overrides).filter((k) => fieldKeys.has(k)).length;\n const places = info?.places;\n const known = !!info || missing;\n // compared as instants, not strings: the same publish can be spelled two ways (precision, offset)\n const changed = detached && !missing && laterThan(info?.publishedAt, m.sourcePublishedAt);\n const state = detached ? `Detached${changed ? \", Shared version changed\" : \"\"}` : missing ? \"Missing block\" : edited || m.variant ? \"Edited here\" : \"Shared\";\n // V2 instance-ui: a required prop this place leaves empty marks the scope chip, never by colour alone\n const requiredEmpty = !missing && !detached && (info?.fields ?? []).some((f) => f.required && blank(f.key in overrides ? overrides[f.key] : f.value));\n const label = `${name} block${known ? `, ${state}` : \"\"}${known && !missing && !detached && places != null ? `, ${placesShort(places)}` : \"\"}${requiredEmpty ? `. ${REQUIRED_EMPTY}` : \"\"}`;\n const rows = detached ? copyRows(own, info?.fields, m.variant) : previewRows(missing, info?.fields, overrides, variant);\n // the picture is the component with its own values (the host's snapshot): drawn only where this place shows exactly\n // that. A separate copy, an edited place or another layout would be shown content it doesn't have, so those list\n // their values instead.\n const image = missing || detached || edited || variant ? null : info?.image || null;\n // V2 draws the component itself in the card, with this place's values (linked, edited or a separate copy): the host's\n // live renderer where it has one. Another layout lists its values (the renderer draws the component's own layout).\n const liveProps = React.useMemo(\n () => (detached ? own : { ...Object.fromEntries((info?.fields ?? []).flatMap((f) => (f.value !== undefined ? [[f.key, f.value]] : []))), ...overrides }),\n [detached, own, info?.fields, overrides],\n );\n const live = ComponentPreview && ref && info && !missing && !variant ? { Preview: ComponentPreview, ref } : null;\n const preview = live ? (\n <LivePreview Preview={live.Preview} componentId={live.ref} title={name} props={liveProps} rows={rows} />\n ) : image || rows.length ? (\n <PreviewWindow image={image} rows={rows} />\n ) : null;\n const canCopy = !!copyComponent && !!m.ref && !ctx.readOnly;\n const ro = !!ctx.readOnly;\n const linked = !missing && !detached;\n const open = useComponentPanel(el);\n const editing = !!open;\n const [cardEl, setCardEl] = React.useState<HTMLDivElement | null>(null);\n const cardRef = React.useCallback((n: HTMLDivElement | null) => {\n card.current = n;\n if (n) setCardEl(n);\n }, []);\n const openPanel = React.useCallback((focusKey?: string | null) => openComponentPanel(el, focusKey ?? null), [el]);\n const closePanel = React.useCallback(() => closeComponentPanel(el), [el]);\n const focusCard = React.useCallback(() => requestAnimationFrame(() => card.current?.focus({ preventScroll: true })), []);\n // removing the component closes its panel\n React.useEffect(() => () => closeComponentPanel(el), [el]);\n const swappable = useCatalogComponents()?.components ?? [];\n const [swapTo, setSwapTo] = React.useState<KitInsertableComponent | null>(null);\n const editAll = openComponent && m.ref && info && linked\n ? { label: places != null && places > 1 ? `Edit for all ${places} places` : \"Edit the shared block\", run: () => openComponent(m.ref!) }\n : undefined;\n const href = m.ref ? componentHref?.(m.ref, m.id) : undefined;\n const hasEdits = linked && (Object.keys(overrides).length > 0 || !!m.variant);\n\n /**\n * The change as ONE undo step (IslandCtx.step: the dock's toolbar Undo, this toast's Undo and ⌘Z in the body are one\n * undo), and the toast that offers it back.\n */\n const commit = (patch: (cur: ComponentModel) => ComponentModel, label: string, title: string, description: string) => {\n const before = el.__rt as ComponentModel | undefined;\n const undo = ctx.step\n ? ctx.step(label, () => (set(patch, label, false), el), before)\n : (set(patch, label), () => (ctx.undo?.() ? (true as const) : \"Changes made after it come first. Press ⌘Z to undo them.\"));\n toast?.(title, {\n description,\n action: {\n label: \"Undo\",\n onClick: () => {\n const r = undo();\n if (r !== true) ctx.notify(\"Nothing was undone\", r);\n },\n },\n });\n };\n\n /** V2 detachNow: this place keeps what readers see now and stops following the component, as one undo step. */\n const detach = async (title: string) => {\n if (!copyComponent || !m.ref || busy) return;\n setBusy(true);\n try {\n const copy = await copyComponent(m.ref, { overrides, ...(m.variant ? { variant: m.variant } : {}) });\n commit(\n (cur) => ({\n id: cur.id,\n ref: cur.ref,\n ...(cur.name !== undefined || info?.name ? { name: cur.name ?? info?.name } : {}),\n ...(cur.variant !== undefined ? { variant: cur.variant } : {}),\n detached: true,\n props: JSON.stringify(copy.props),\n ...(copy.blocks !== undefined ? { blocks: copy.blocks } : {}),\n ...(copy.sourcePublishedAt ? { sourcePublishedAt: copy.sourcePublishedAt } : {}),\n ...(cur.extra !== undefined ? { extra: cur.extra } : {}),\n }),\n \"Make a separate copy\",\n title,\n \"It keeps its content and no longer follows the shared block.\",\n );\n } catch (e) {\n ctx.notify(\"This place couldn't keep its own copy\", e instanceof Error ? e.message : String(e));\n } finally {\n setBusy(false);\n }\n };\n\n /** V2 instanceOps.relink: keep = what differs from the component becomes overrides; reset = the component's content. */\n const relink = (mode: \"keep\" | \"reset\") => {\n const kept = copyEdits(m, own, info?.fields);\n const n = Object.keys(kept).length;\n commit(\n (cur) => ({\n id: cur.id,\n ref: cur.ref,\n ...(cur.name !== undefined ? { name: info?.name ?? cur.name } : {}),\n ...(mode === \"keep\" && Object.keys(kept).length ? { overrides: JSON.stringify(kept) } : {}),\n ...(mode === \"keep\" && cur.variant !== undefined ? { variant: cur.variant } : {}),\n ...(cur.extra !== undefined ? { extra: cur.extra } : {}),\n }),\n \"Use shared version again\",\n `${name} is shared again`,\n mode === \"keep\" && n ? `${n} ${n === 1 ? \"edit\" : \"edits\"} kept here.` : \"It shows the block's content.\",\n );\n };\n\n /** V2 instanceOps.resetAll: this place's overrides and its layout go, as one undo step. */\n const resetAll = () =>\n commit(\n (cur) => {\n const { variant: _v, ...rest } = cur;\n return { ...rest, overrides: \"{}\" };\n },\n \"Reset all edits here\",\n `Back to the shared ${name}`,\n \"This place shows the block's content again.\",\n );\n\n /**\n * V2 instanceOps.swap, once the new component's fields are known (SwapResolver): this place's edits stay only where the\n * new component declares a field with that key; everything else is the new component's own content. One undo step.\n */\n const swap = (to: KitInsertableComponent, next: KitComponentInfo) => {\n const keys = new Set((next.fields ?? []).map((f) => f.key));\n const src = detached ? own : overrides;\n const kept = Object.fromEntries(Object.entries(src).filter(([k]) => keys.has(k)));\n const n = Object.keys(kept).length;\n commit(\n (cur) => ({ id: cur.id, ref: to.id, name: next.name || to.name, overrides: JSON.stringify(kept), ...(cur.extra !== undefined ? { extra: cur.extra } : {}) }),\n `Swap to ${to.name}`,\n `Swapped to ${to.name}`,\n n ? `Kept ${n} ${n === 1 ? \"edit\" : \"edits\"} made here.` : \"It shows the block's own content.\",\n );\n };\n\n const copyLink = () => {\n if (!href) return;\n void navigator.clipboard?.writeText(href).catch(() => {});\n toast?.success(\"Link copied\", { description: `Opens this page scrolled to the ${name}.` });\n };\n\n /** The panel's form writes this place: overrides (or the layout) as one undo step each, through the island's model. */\n const onOverrides = (next: Record<string, unknown>) => {\n const changed = [...new Set([...Object.keys(next), ...Object.keys(overrides)])].find((k) => !same(next[k], overrides[k]));\n // an object patch with one label per field: the editor's history merges a burst of typing into ONE step (V2 D54)\n set({ overrides: JSON.stringify(next) }, changed ? `Edit ${changed}` : \"Edit block properties\");\n };\n const onVariant = (variant: string | undefined) =>\n set(\n (cur) => {\n const { variant: _v, ...rest } = cur;\n return variant ? { ...rest, variant } : rest;\n },\n \"Change layout\",\n );\n\n /** V2 instance card keys, on the focused card itself (fields and the portalled panel keep their own). */\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.defaultPrevented || e.target !== card.current) return;\n const mod = e.metaKey || e.ctrlKey;\n const k = eventKey(e);\n if (mod && k === \"z\") {\n e.preventDefault();\n e.stopPropagation();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n return;\n }\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n openPanel();\n return;\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n if (editing) closePanel();\n else ctx.exit(el);\n return;\n }\n if (ro) return;\n if (mod && k === \"d\" && ctx.duplicate) {\n e.preventDefault();\n e.stopPropagation();\n ctx.duplicate(el);\n } else if (e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") && ctx.move) {\n e.preventDefault();\n ctx.move(el, e.key === \"ArrowUp\" ? -1 : 1);\n focusCard();\n } else if (e.key === \"Backspace\" || e.key === \"Delete\") {\n e.preventDefault();\n ctx.remove(el);\n }\n };\n\n const chip = (compact: boolean) =>\n detached ? (\n <>\n <DetachedChip name={name} compact={compact} />\n {changed ? <ChangedChip name={name} compact={compact} onReview={canCopy ? () => setDialog(\"relink\") : undefined} /> : null}\n </>\n ) : known ? (\n <StateChip missing={missing} places={places} edited={edited} layout={!!m.variant} requiredEmpty={requiredEmpty} compact={compact} />\n ) : null;\n\n return (\n <div\n ref={cardRef}\n role=\"group\"\n tabIndex={0}\n aria-label={label}\n aria-roledescription=\"component\"\n aria-haspopup=\"dialog\"\n aria-expanded={editing}\n aria-busy={busy || undefined}\n data-instance-card=\"\"\n data-rt-isolate=\"\"\n data-state={detached ? \"detached\" : missing ? \"missing\" : known ? \"linked\" : undefined}\n onKeyDown={onKeyDown}\n onClick={(e) => {\n // a click on the card (not on its controls) opens its properties, V2 instance card\n if (!e.currentTarget.contains(e.target as Node) || (e.target as HTMLElement).closest(\"button,a,[role=menuitem],[role=note],[role=alert]\")) return;\n // on a listed value, with that field focused (the live preview is inert, so it is found by position)\n openPanel(propKeyAt(e.currentTarget, e.clientX, e.clientY));\n }}\n className={cn(\n // V2 instance-card.tsx:223 transition-colors (the focus ring stays the kit's keyboard ring, DESIGN focus rule)\n \"group/inst relative cursor-pointer rounded-kit-lg border bg-kit-control-bg text-left focus-visible:outline-offset-2 transition-colors duration-150 motion-reduce:transition-none\",\n editing\n ? \"border-transparent shadow-[0_0_0_2px_var(--kit-accent)]\"\n : missing && !detached\n ? \"border-kit-warning-line\"\n : \"border-kit-line hover:border-kit-line-strong\",\n )}\n >\n {/* Strip (V2): drag grip (hover / focus, always on touch) · icon · name · scope chip · ⋯ */}\n <div className=\"flex h-9 select-none items-center gap-1.5 pl-1 pr-1\">\n {ro || !ctx.drag ? (\n <span className=\"w-1\" />\n ) : (\n <Tooltip content=\"Drag to move\">\n <button\n type=\"button\"\n aria-label={`Move ${name}`}\n tabIndex={-1}\n onPointerDown={(e) => ctx.drag?.(el, e)}\n className=\"flex h-7 w-4 shrink-0 cursor-grab touch-none pointer-coarse:size-11 items-center justify-center rounded-kit-sm text-kit-fg-4 opacity-0 transition-opacity duration-150 hover:text-kit-fg-2 active:cursor-grabbing motion-reduce:transition-none group-hover/inst:opacity-100 group-focus-within/inst:opacity-100 pointer-coarse:opacity-100 [&_svg]:size-3.5\"\n >\n <IconGripVertical stroke={1.5} />\n </button>\n </Tooltip>\n )}\n {info?.icon && IconGlyph ? (\n <span aria-hidden className=\"flex size-[15px] shrink-0 text-kit-fg-2 [&_svg]:size-full\">\n <IconGlyph name={info.icon} className=\"size-[15px]\" />\n </span>\n ) : (\n <IconComponents size={15} stroke={1.5} className=\"shrink-0 text-kit-fg-2\" aria-hidden />\n )}\n <span className=\"min-w-0 shrink truncate text-kit-sm font-medium text-kit-fg\">{name}</span>\n {chip(narrow)}\n <span className=\"flex-1\" />\n <Menu>\n <MenuTrigger\n render={\n <IconButton size=\"sm\" className=\"shrink-0\" label={`${name} actions`}>\n <IconDots stroke={1.5} />\n </IconButton>\n }\n />\n <MenuContent align=\"end\" className=\"w-64\">\n {ComponentSettings ? (\n <MenuItem icon={<IconAdjustmentsHorizontal stroke={1.5} />} onClick={() => openPanel()}>\n Edit properties\n </MenuItem>\n ) : null}\n {editAll ? (\n <MenuItem icon={<IconArrowUpRight stroke={1.5} />} onClick={editAll.run}>\n {editAll.label}\n </MenuItem>\n ) : null}\n {!ro && hasEdits ? (\n <MenuItem icon={<IconRestore stroke={1.5} />} onClick={resetAll}>\n Reset all edits here\n </MenuItem>\n ) : null}\n {canCopy && info && !missing && !detached ? (\n <MenuItem icon={<IconUnlink stroke={1.5} />} disabled={busy} onClick={() => setDialog(\"detach\")}>\n Make a separate copy\n </MenuItem>\n ) : null}\n {canCopy && missing && !detached ? (\n <MenuItem icon={<IconUnlink stroke={1.5} />} disabled={busy} onClick={() => void detach(\"Kept as a separate copy\")}>\n Keep as a separate copy\n </MenuItem>\n ) : null}\n {canCopy && info && !missing && detached ? (\n <MenuItem icon={<IconLink stroke={1.5} />} onClick={() => setDialog(\"relink\")}>\n Use shared version again\n </MenuItem>\n ) : null}\n {!ro && swappable.length ? (\n <MenuSub>\n <MenuSubTrigger icon={<IconReplace stroke={1.5} />}>Swap block</MenuSubTrigger>\n <MenuSubContent className=\"max-h-[320px] w-60 overflow-y-auto\">\n {swappable.map((c) => {\n const on = c.id === m.ref;\n return (\n <MenuItem key={c.id} icon={<IconComponents stroke={1.5} />} disabled={on || !!swapTo} onClick={() => setSwapTo(c)}>\n <span className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"truncate\">{c.name}</span>\n {on ? <IconCheck className=\"size-3.5 shrink-0 text-kit-fg-2\" stroke={2} aria-label=\"Current\" /> : null}\n </span>\n </MenuItem>\n );\n })}\n </MenuSubContent>\n </MenuSub>\n ) : null}\n {preview ? (\n <MenuItem icon={collapsed ? <IconLayoutNavbarExpand stroke={1.5} /> : <IconLayoutNavbarCollapse stroke={1.5} />} onClick={() => setCollapsed(!collapsed)}>\n {collapsed ? \"Show preview\" : \"Collapse preview\"}\n </MenuItem>\n ) : null}\n <MenuSeparator />\n {!ro && ctx.duplicate ? (\n <MenuItem icon={<IconCopy stroke={1.5} />} shortcut=\"⌘D\" onClick={() => ctx.duplicate?.(el)}>\n Duplicate\n </MenuItem>\n ) : null}\n {!ro && ctx.move ? (\n <>\n <MenuItem icon={<IconArrowBarToUp stroke={1.5} />} shortcut=\"⌥↑\" disabled={!el.previousElementSibling} onClick={() => ctx.move?.(el, -1)}>\n Move up\n </MenuItem>\n <MenuItem icon={<IconArrowBarToDown stroke={1.5} />} shortcut=\"⌥↓\" disabled={!el.nextElementSibling} onClick={() => ctx.move?.(el, 1)}>\n Move down\n </MenuItem>\n </>\n ) : null}\n {href ? (\n <MenuItem icon={<IconLink stroke={1.5} />} onClick={copyLink}>\n Copy link\n </MenuItem>\n ) : null}\n {!ro ? (\n <>\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} shortcut=\"⌫\" onClick={() => ctx.remove(el)}>\n Remove\n </MenuItem>\n </>\n ) : null}\n </MenuContent>\n </Menu>\n </div>\n {error ? (\n <div role=\"alert\" className=\"flex items-center gap-2 border-t border-kit-line-subtle px-3 py-2.5 text-kit-sm text-kit-fg-2\">\n <IconAlertTriangle className=\"size-4 shrink-0 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0 flex-1\">{error}</span>\n </div>\n ) : null}\n {missing && !detached && !loading ? (\n <div className=\"flex flex-wrap items-center gap-2 border-t border-kit-line-subtle px-3 py-2.5 text-kit-sm\" role=\"note\">\n <IconAlertTriangle className=\"size-4 shrink-0 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0 flex-1 text-kit-fg-2\">The original “{name}” was deleted. Readers see nothing in this place.</span>\n {ctx.readOnly ? null : (\n <span className=\"flex shrink-0 items-center gap-1.5\">\n {canCopy ? (\n <Button size=\"xs\" variant=\"secondary\" loading={busy} onClick={() => void detach(\"Kept as a separate copy\")}>\n Keep as a separate copy\n </Button>\n ) : null}\n <Button size=\"xs\" variant=\"danger-ghost\" onClick={() => ctx.remove(el)}>\n Remove\n </Button>\n </span>\n )}\n </div>\n ) : null}\n {collapsed ? null : preview}\n {canCopy ? (\n <>\n <DetachDialog\n open={dialog === \"detach\"}\n name={name}\n places={places}\n onClose={() => setDialog(null)}\n onConfirm={() => {\n setDialog(null);\n void detach(`Separate copy of ${name}`);\n }}\n />\n <RelinkDialog\n open={dialog === \"relink\"}\n name={name}\n kept={Object.keys(copyEdits(m, own, info?.fields)).length}\n onClose={() => setDialog(null)}\n onConfirm={(mode) => {\n setDialog(null);\n relink(mode);\n }}\n />\n </>\n ) : null}\n {swapTo ? (\n <SwapResolver\n use={use}\n to={swapTo}\n onReady={(next) => {\n setSwapTo(null);\n swap(swapTo, next);\n }}\n onFail={(why) => {\n setSwapTo(null);\n ctx.notify(`Couldn't swap to ${swapTo.name}`, why);\n }}\n />\n ) : null}\n {open ? (\n <ComponentPanel\n name={name}\n chip={chip(false)}\n anchor={cardEl}\n open={open}\n editAll={editAll}\n onClose={closePanel}\n focusBack={focusCard}\n settings={{\n componentId: m.ref ?? \"\",\n overrides,\n ...(m.variant ? { variant: m.variant } : {}),\n ...(detached ? { detached: { props: own } } : {}),\n // a separate copy keeps the values it was made with (its frozen blocks are drawn from them): read-only here\n readOnly: ro || detached || missing,\n onOverrides,\n onVariant,\n }}\n />\n ) : null}\n </div>\n );\n}\n\n/**\n * A separate copy's EDITS, which it keeps as overrides when it follows the component again: its values that differ from\n * the snapshot taken when the copy was made, never from the component as it is now (a republish since is not an edit\n * of this place; the owner saw \"2 fields stay as they are\" with nothing edited).\n *\n * A copy made here stores that snapshot: its values (`props`) with the blocks drawn from them (`blocks`), and no\n * surface edits a copy's values afterwards, so it has no edits. Copy markup from V2 stores no snapshot (no `blocks`):\n * its values that differ from the component's, on fields the component has (V2 instanceOps.relink).\n */\nfunction copyEdits(m: ComponentModel, own: Record<string, unknown>, fields: KitComponentField[] | undefined): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n if (m.blocks !== undefined) return out;\n for (const f of fields ?? []) if (f.key in own && !same(own[f.key], f.value)) out[f.key] = own[f.key];\n return out;\n}\n\nconst REQUIRED_EMPTY = \"Required field empty.\";\n/** Nothing an author would call filled in: no value, blank text, an empty list. */\nconst blank = (v: unknown) => v == null || (typeof v === \"string\" && !v.trim()) || (Array.isArray(v) && v.length === 0);\n\n/** V2 StateChip: 13px, neutral, not a pill; the missing chip is the one tinted state. */\nfunction StateChip({ missing, places, edited, layout, requiredEmpty, compact }: { missing: boolean; places?: number; edited: number; layout?: boolean; requiredEmpty?: boolean; compact: boolean }) {\n const base = CHIP;\n if (missing) {\n return (\n <Tooltip content=\"The block was deleted. Readers see nothing in this place.\">\n <span className={cn(base, \"bg-kit-warning-soft px-1.5 text-kit-warning-fg\")}>\n <IconAlertTriangle className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Missing block</span> : \"Missing block\"}\n </span>\n </Tooltip>\n );\n }\n const count = places ? placesShort(places) : null;\n const tip = `Changes here apply only to this place. Edit the block to change ${places && places > 1 ? `all ${places}` : \"it everywhere\"}.${\n edited ? ` ${edited} ${edited === 1 ? \"field\" : \"fields\"} edited here.` : \"\"}${layout ? \" Its layout is set here.\" : \"\"}${requiredEmpty ? ` ${REQUIRED_EMPTY}` : \"\"\n }`;\n return (\n <Tooltip content={tip}>\n <span className={cn(base, \"px-1 text-kit-fg-2\")} tabIndex={-1}>\n {requiredEmpty ? <span data-required-empty className=\"size-1.5 shrink-0 rounded-full bg-kit-danger-fg\" aria-hidden /> : null}\n <IconLink className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Shared{count ? `, ${count}` : \"\"}</span> : count ?? \"Shared\"}\n {!compact && count ? <span className=\"sr-only\">, shared</span> : null}\n {edited || layout ? (\n <>\n <span className=\"ml-1 size-1.5 shrink-0 rounded-full bg-kit-accent\" aria-hidden />\n {compact ? <span className=\"sr-only\">, edited here</span> : <span>Edited here</span>}\n </>\n ) : null}\n </span>\n </Tooltip>\n );\n}\n\nconst CHIP = \"inline-flex h-6 shrink-0 items-center gap-1 rounded-kit-md text-[13px] leading-none whitespace-nowrap\";\n\n/** V2 StateChip, detached: fg-3, the unlink glyph. */\nfunction DetachedChip({ name, compact }: { name: string; compact: boolean }) {\n return (\n <Tooltip content={`A separate copy. Changes to ${name} don't reach it.`}>\n <span className={cn(CHIP, \"px-1 text-kit-fg-3\")} tabIndex={-1}>\n <IconUnlink className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Detached</span> : \"Detached\"}\n </span>\n </Tooltip>\n );\n}\n\n/** V2 StateChip, update: a quiet button that opens the way back to the shared version. */\nfunction ChangedChip({ name, compact, onReview }: { name: string; compact: boolean; onReview?: () => void }) {\n return (\n <Tooltip content={`${name} changed since this copy was made.`}>\n <button\n type=\"button\"\n onClick={onReview}\n disabled={!onReview}\n className={cn(CHIP, \"px-1 text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg disabled:hover:bg-transparent\")}\n >\n <IconRefresh className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Shared version changed</span> : \"Shared version changed\"}\n </button>\n </Tooltip>\n );\n}\n\n/** V2 useInstanceDialogs \"detach\": confirm before this place stops following the component. */\nfunction DetachDialog({ open, name, places, onClose, onConfirm }: { open: boolean; name: string; places?: number; onClose: () => void; onConfirm: () => void }) {\n const others = places != null ? places - 1 : null;\n return (\n <Modal open={open} onOpenChange={(o) => !o && onClose()}>\n <ModalContent size=\"sm\">\n <ModalHeader title={`Make a separate copy of ${name}?`} description=\"This place keeps its current content and stops following the shared block.\" />\n {others != null ? (\n <ModalBody className=\"pt-2 text-kit-sm text-kit-fg-2\">\n {others > 0 ? `The other ${others === 1 ? \"place stays\" : `${others} places stay`} shared.` : \"No other place uses it.\"}\n </ModalBody>\n ) : null}\n <ModalFooter>\n <Button variant=\"ghost\" onClick={onClose}>\n Cancel\n </Button>\n <Button variant=\"primary\" autoFocus onClick={onConfirm}>\n Make a copy\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n );\n}\n\n/** V2 RelinkDialog: keep this place's edits as overrides, or take the component's content. */\nfunction RelinkDialog({ open, name, kept, onClose, onConfirm }: { open: boolean; name: string; kept: number; onClose: () => void; onConfirm: (mode: \"keep\" | \"reset\") => void }) {\n const [mode, setMode] = React.useState<\"keep\" | \"reset\">(\"keep\");\n React.useEffect(() => {\n if (open) setMode(\"keep\");\n }, [open]);\n const rows: { v: \"keep\" | \"reset\"; title: string; line: string }[] = [\n {\n v: \"keep\",\n title: \"Keep my edits here\",\n line: kept ? `${kept} ${kept === 1 ? \"field stays\" : \"fields stay\"} as ${kept === 1 ? \"it is\" : \"they are\"}; everything else follows ${name} again.` : `Nothing differs, so it simply follows ${name} again.`,\n },\n { v: \"reset\", title: `Use ${name}'s content`, line: \"Drops the edits made here. Undo is one click away.\" },\n ];\n return (\n <Modal open={open} onOpenChange={(o) => !o && onClose()}>\n <ModalContent size=\"sm\">\n <ModalHeader title={`Use the shared ${name} again?`} description=\"This place follows the shared block again.\" />\n <ModalBody className=\"pt-3\">\n <div\n role=\"radiogroup\"\n aria-label=\"Use shared version again\"\n className=\"flex flex-col divide-y divide-kit-line overflow-hidden rounded-kit-lg border border-kit-line\"\n onKeyDown={(e) => {\n // a radio group moves with the arrow keys (one tab stop, the checked row)\n if (![\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"].includes(e.key)) return;\n e.preventDefault();\n const next = mode === \"keep\" ? \"reset\" : \"keep\";\n setMode(next);\n (e.currentTarget.querySelector(`[data-mode=\"${next}\"]`) as HTMLElement | null)?.focus();\n }}\n >\n {rows.map((row) => (\n <button\n key={row.v}\n type=\"button\"\n role=\"radio\"\n data-mode={row.v}\n tabIndex={mode === row.v ? 0 : -1}\n aria-checked={mode === row.v}\n onClick={() => setMode(row.v)}\n className={cn(\"flex min-h-14 items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-kit-hover\", mode === row.v && \"bg-kit-subtle\")}\n >\n <span className={cn(\"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border\", mode === row.v ? \"border-kit-control-checked\" : \"border-kit-line-strong\")}>\n {mode === row.v ? <span className=\"size-2 rounded-full bg-kit-fg\" /> : null}\n </span>\n <span className=\"min-w-0\">\n <span className=\"block text-kit-sm font-medium text-kit-fg\">{row.title}</span>\n <span className=\"block text-kit-xs text-kit-fg-3\">{row.line}</span>\n </span>\n </button>\n ))}\n </div>\n </ModalBody>\n <ModalFooter>\n <Button variant=\"ghost\" onClick={onClose}>\n Cancel\n </Button>\n <Button variant=\"primary\" onClick={() => onConfirm(mode)}>\n Use shared version\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n );\n}\n\ninterface Row {\n key: string;\n label: string;\n text: string;\n}\n\n/**\n * What the window lists when there is no picture: each field's value as this place shows it (its override, else the\n * component's own), then the layout this place draws it in. A missing component has only what this place stored: its\n * overrides, named by their keys, and its layout.\n */\n/** A choice field's value as its option's label (BUG-8: a select whose values are ids listed the id); others as they are. */\nfunction chosen(f: KitComponentField, v: unknown): unknown {\n if (!f.options) return v;\n const label = (x: unknown) => f.options!.find((o) => o.value === x)?.label ?? x;\n return Array.isArray(v) ? v.map(label).join(\", \") : label(v);\n}\n\nfunction previewRows(missing: boolean, fields: KitComponentField[] | undefined, overrides: Record<string, unknown>, variant?: string): Row[] {\n const out: Row[] = [];\n if (missing || !fields) {\n for (const [key, v] of Object.entries(overrides)) {\n const text = readable(v);\n if (text) out.push({ key, label: key, text });\n }\n } else {\n for (const f of fields) {\n const text = readable(chosen(f, f.key in overrides ? overrides[f.key] : f.value));\n if (text) out.push({ key: f.key, label: f.label, text });\n }\n }\n if (variant) out.push({ key: \"__variant\", label: \"Layout\", text: variant });\n return out;\n}\n\n/**\n * A separate copy's values (V2 `props`) in the component's field order. A field the copy doesn't hold draws the\n * component's value for it, as V2's renderer does for a copy (it draws the def with `props`, defaults for the rest);\n * a value the component no longer has a field for follows, under its key. Then its layout.\n */\nfunction copyRows(own: Record<string, unknown>, fields: KitComponentField[] | undefined, variant?: string): Row[] {\n const out: Row[] = [];\n const push = (key: string, label: string, v: unknown) => {\n const text = readable(v);\n if (text) out.push({ key, label, text });\n };\n for (const f of fields ?? []) push(f.key, f.label, chosen(f, f.key in own ? own[f.key] : f.value));\n for (const [key, v] of Object.entries(own)) if (!fields?.some((f) => f.key === key)) push(key, key, v);\n if (variant) out.push({ key: \"__variant\", label: \"Layout\", text: variant });\n return out;\n}\n\n/**\n * The preview's frame: under the card's header, capped at PREVIEW_H (its top border inside, as V2's CappedPreview).\n * The cap lifts instantly on hover: a height animation is layout work every frame (canvas revamp V937).\n */\nconst PREVIEW_CHROME = \"group/cap relative max-h-[240px] overflow-hidden rounded-b-kit-lg border-t border-kit-line-subtle\";\n\n/**\n * V2 instance-card CappedPreview: at most 240px, faded at its foot when the content is taller; hover shows its full\n * height. Measured a frame after each resize, so a frame or picture that sizes itself late is read once settled.\n */\nfunction CappedPreview({ live, children }: { live?: boolean; children: React.ReactNode }) {\n const inner = React.useRef<HTMLDivElement>(null);\n const [tall, setTall] = React.useState(false);\n // a live frame is the site: on V2's light site paper in both themes; a listing or picture stays on the themed chrome\n const [site, setSite] = React.useState(false);\n React.useLayoutEffect(() => {\n const el = inner.current;\n if (!el) return;\n let raf = 0;\n const measure = () => {\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(() => {\n setTall(el.offsetHeight > PREVIEW_H + 1);\n setSite(!!el.querySelector(\"iframe\"));\n });\n };\n measure();\n const ro = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(measure);\n ro?.observe(el);\n // the frame can mount without a size change (the shell keeps its remembered height), so a mount re-measures too\n const mo = typeof MutationObserver === \"undefined\" ? null : new MutationObserver(measure);\n mo?.observe(el, { childList: true, subtree: true });\n return () => {\n ro?.disconnect();\n mo?.disconnect();\n cancelAnimationFrame(raf);\n };\n }, []);\n return (\n <div\n data-instance-preview=\"\"\n data-live={live ? \"\" : undefined}\n data-tall={tall ? \"\" : undefined}\n data-site={site ? \"\" : undefined}\n className={cn(PREVIEW_CHROME, site ? \"bg-kit-site-paper\" : \"bg-kit-subtle\", tall && \"can-hover:hover:max-h-[2400px]\")}\n >\n <div ref={inner}>{children}</div>\n {/* V2's fade: inside the capped box, into its paper (the site paper under a live frame, else the chrome) */}\n {tall ? (\n <div\n aria-hidden\n className={cn(\n \"pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-b from-transparent transition-opacity duration-150 ease-out can-hover:group-hover/cap:opacity-0 motion-reduce:transition-none\",\n site ? \"to-kit-site-paper\" : \"to-kit-subtle\",\n )}\n />\n ) : null}\n </div>\n );\n}\n\nfunction PreviewWindow({ image, rows }: { image: string | null; rows: Row[] }) {\n return (\n <CappedPreview>\n <PreviewBody image={image} rows={rows} />\n </CappedPreview>\n );\n}\n\n/**\n * The component drawn live by the host (KitServices.ComponentPreview), mounted once the card is on screen. Its height is\n * reserved from the start (PREVIEW_H), so the card never moves while it loads; where the host cannot draw it, the values\n * are listed under the reason.\n */\nfunction LivePreview({\n Preview,\n componentId,\n title,\n props,\n rows,\n}: {\n Preview: React.ComponentType<KitComponentPreviewProps>;\n componentId: string;\n title: string;\n props: Record<string, unknown>;\n rows: Row[];\n}) {\n const box = React.useRef<HTMLDivElement>(null);\n const [seen, setSeen] = React.useState(() => typeof IntersectionObserver === \"undefined\");\n React.useEffect(() => {\n const el = box.current;\n if (seen || !el) return;\n const io = new IntersectionObserver((entries) => {\n if (entries.some((e) => e.isIntersecting)) setSeen(true);\n });\n io.observe(el);\n return () => io.disconnect();\n }, [seen]);\n return (\n <CappedPreview live>\n <div ref={box}>\n {seen ? (\n <Preview componentId={componentId} title={title} props={props} fallback={(reason) => <PreviewBody image={null} rows={rows} note={reason} />} />\n ) : (\n <div aria-hidden style={{ height: PREVIEW_H }} />\n )}\n </div>\n </CappedPreview>\n );\n}\n\nfunction PreviewBody({ image, rows, note }: { image: string | null; rows: Row[]; note?: string }) {\n // a picture's height is unknown until it loads: the cap is held until then, so the card doesn't jump when it lands\n const [loaded, setLoaded] = React.useState(!image);\n return (\n <div style={!loaded ? { height: PREVIEW_H } : undefined}>\n {image ? (\n // the whole width, scaled to the card like V2's frame (top-left origin): never cropped at the sides\n <img src={image} alt=\"\" className=\"block h-auto w-full\" draggable={false} onLoad={() => setLoaded(true)} onError={() => setLoaded(true)} />\n ) : (\n <>\n {note ? <p className=\"px-4 pt-3 text-kit-xs text-kit-fg-3\">{note}</p> : null}\n <dl className=\"flex flex-col gap-3 px-4 py-3.5\">\n {rows.map((r) => (\n // a click on a listed value opens the panel on that field (the card reads it by position: propKeyAt)\n <div key={r.key} data-prop-key={r.key === \"__variant\" ? undefined : r.key} className=\"min-w-0\">\n <dt className=\"truncate text-kit-xs text-kit-fg-3\">{r.label}</dt>\n <dd className=\"mt-0.5 line-clamp-3 text-kit-sm text-kit-fg\">{r.text}</dd>\n </div>\n ))}\n </dl>\n </>\n )}\n </div>\n );\n}\n\n/** The listed value (`data-prop-key`) under a point of the card, else null. */\nfunction propKeyAt(root: HTMLElement, x: number, y: number): string | null {\n for (const row of root.querySelectorAll<HTMLElement>(\"[data-prop-key]\")) {\n const r = row.getBoundingClientRect();\n if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) return row.dataset.propKey ?? null;\n }\n return null;\n}\n\n/**\n * Swap component: the new component's fields come from the same lookup the card reads (KitServices.useComponentInfo, a\n * hook, so it is asked from a component of its own). Answers once, when they are known.\n */\nfunction SwapResolver({\n use, to, onReady, onFail,\n}: {\n use: UseComponentInfo;\n to: KitInsertableComponent;\n onReady: (info: KitComponentInfo) => void;\n onFail: (why: string) => void;\n}) {\n const { info, error } = use(to.id);\n const done = React.useRef(false);\n React.useEffect(() => {\n if (done.current) return;\n if (error) {\n done.current = true;\n onFail(error);\n } else if (info?.missing) {\n done.current = true;\n onFail(\"The library has no such block.\");\n } else if (info) {\n done.current = true;\n onReady(info);\n }\n });\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,SAAS;;AAEf,IAAM,YAAY;AAElB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,oBAAC,MAAD;KAAI,WAAU;KAAsC,UAAA,EAAE;IAAU,CAAA,GAChE,oBAAC,MAAD;KAAI,WAAU;KAA+C,UAAA,EAAE;IAAS,CAAA,CACrE;GAHK,GAAA,EAAE,GAGP,CACN;EACC,CAAA,CACJ,EAAA,CAAA;CAED,CAAA;AAET;;AAGA,SAAS,UAAU,MAAmB,GAAW,GAA0B;CACzE,KAAK,MAAM,OAAO,KAAK,iBAA8B,iBAAiB,GAAG;EACvE,MAAM,IAAI,IAAI,sBAAsB;EACpC,IAAI,KAAK,EAAE,QAAQ,KAAK,EAAE,SAAS,KAAK,EAAE,OAAO,KAAK,EAAE,QAAQ,OAAO,IAAI,QAAQ,WAAW;CAChG;CACA,OAAO;AACT;;;;;AAMA,SAAS,aAAa,EACpB,KAAK,IAAI,SAAS,UAMjB;CACD,MAAM,EAAE,MAAM,UAAU,IAAI,GAAG,EAAE;CACjC,MAAM,OAAO,MAAM,OAAO,KAAK;CAC/B,MAAM,gBAAgB;EACpB,IAAI,KAAK,SAAS;EAClB,IAAI,OAAO;GACT,KAAK,UAAU;GACf,OAAO,KAAK;EACd,OAAO,IAAI,MAAM,SAAS;GACxB,KAAK,UAAU;GACf,OAAO,gCAAgC;EACzC,OAAO,IAAI,MAAM;GACf,KAAK,UAAU;GACf,QAAQ,IAAI;EACd;CACF,CAAC;CACD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"component-card.js","names":[],"sources":["../../../src/controls/rich-text/component-card.tsx"],"sourcesContent":["/**\n * The embedded component card (V2 features/blocks/instance-card.tsx + instance-ui.tsx StateChip / MissingNote / dialogs),\n * drawn when the host can look the component up (KitServices.useComponentInfo, component-services.ts):\n *\n * ┌ [icon] Inline CTA 🔗 2 places · ● Edited here ⋯ ┐ 36px strip\n * ├ ⚠ The original \"Product card\" was deleted. … [Keep as a separate copy] [Remove] ┤ missing only\n * │ the component itself, drawn live with this place's values (KitServices.ComponentPreview), else │\n * │ its snapshot where this place shows exactly that, else its fields; at most 240px, faded │\n * └──────────────────────────────────────────────────────────────────────────────┘\n *\n * Every state comes from the lookup or the stored copy: \"Missing component\" only when the library says there is no\n * such component, the count only when the host measured it, \"Edited here\" only for overrides of fields the component\n * has, \"Detached\" for a separate copy (V2 instances.ts `detached`), and \"Shared version changed\" only when the\n * component's current version (`info.publishedAt`) differs from the one the copy was taken from.\n *\n * A separate copy is made through the host (`copyComponent`, which answers what readers see now) and written as ONE\n * undo step (V2 detachNow: \"Make a separate copy\"); \"Use shared version again\" (V2 RelinkDialog) keeps this place's\n * edits as overrides or drops them, also one step. A host without `copyComponent` offers neither.\n *\n * Deviation from V2: V2 shows \"Shared version changed\" on a LINKED instance after a breaking release (instances.ts\n * `pending`). A linked instance here follows every publish of its component, so there is nothing to review; the\n * notice is drawn on a separate copy instead, whose source moved on, and it opens \"Use shared version again\".\n */\nimport * as React from \"react\";\nimport {\n IconAdjustmentsHorizontal, IconAlertTriangle, IconArrowBarToDown, IconArrowBarToUp, IconArrowUpRight, IconCheck, IconComponents, IconCopy, IconDots, IconEye, IconEyeOff,\n IconGripVertical, IconLayoutNavbarCollapse, IconLayoutNavbarExpand, IconLink, IconRefresh, IconReplace, IconRestore, IconTrash, IconUnlink,\n} from \"@tabler/icons-react\";\nimport { cn } from \"../../lib/cn\";\nimport { eventKey } from \"../../lib/key-event\";\nimport { useKitServices, type KitServices } from \"../../context\";\nimport { Button, IconButton } from \"../../ui/button\";\nimport {\n Menu, MenuContent, MenuItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Tooltip,\n} from \"../../ui/overlay\";\nimport type { KitComponentField, KitComponentInfo, KitComponentPreviewProps, KitInsertableComponent } from \"../component-services\";\nimport type { ComponentModel, IslandEl } from \"./dom\";\nimport type { IslandCtx } from \"./blocks\";\nimport { useCatalogComponents } from \"./catalog\";\nimport { ComponentPanel, closeComponentPanel, openComponentPanel, useComponentPanel } from \"./component-panel\";\n\n/** V2 NARROW: at or under this card width the scope chip shows its icon only. */\nconst NARROW = 480;\n/** V2 PREVIEW_CAP: the preview at rest is at most this tall, faded when its content is taller. */\nconst PREVIEW_H = 240;\n\nconst placesShort = (n: number) => `${n} ${n === 1 ? \"place\" : \"places\"}`;\n\nfunction useWidth(ref: React.RefObject<HTMLElement | null>) {\n const [w, setW] = React.useState(0);\n React.useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n setW(el.clientWidth);\n if (typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => setW(el.clientWidth));\n ro.observe(el);\n return () => ro.disconnect();\n }, [ref]);\n return w;\n}\n\n/** A stored value as one line of reading text, or null when it has none (lists, empty values, flags). */\nfunction readable(v: unknown): string | null {\n if (typeof v === \"number\") return String(v);\n if (typeof v === \"string\") {\n // an inline image (an icon prop) is kilobytes of base64, never readable text\n if (v.startsWith(\"data:image/\")) return \"Image\";\n // tags become spaces; the parser then decodes what is left (`l'Excellence` → l'Excellence, → space)\n const decoded = new DOMParser().parseFromString(v.replace(/<[^>]+>/g, \" \"), \"text/html\").body.textContent ?? \"\";\n const t = decoded.replace(/\\s+/g, \" \").trim();\n return t || null;\n }\n if (v && typeof v === \"object\" && !Array.isArray(v)) {\n // a rich-text value is { html, value, format }; an image { url, altText }\n // truthy, not `??`: an empty label must not hide the html or url after it\n const o = v as { label?: unknown; text?: unknown; title?: unknown; altText?: unknown; href?: unknown; url?: unknown; html?: unknown };\n return readable(o.label || o.text || o.title || o.altText || o.href || o.url || o.html);\n }\n return null;\n}\n\nconst parseObj = (s: string | undefined): Record<string, unknown> => {\n try {\n const v = s ? (JSON.parse(s) as unknown) : {};\n return v && typeof v === \"object\" && !Array.isArray(v) ? (v as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n};\n/** True when `a` is a later instant than `b`; false when either is absent or unreadable (never a made-up \"changed\"). */\nconst laterThan = (a: string | null | undefined, b: string | undefined) => {\n const x = a ? Date.parse(a) : NaN;\n const y = b ? Date.parse(b) : NaN;\n return Number.isFinite(x) && Number.isFinite(y) && x > y;\n};\nconst same = (a: unknown, b: unknown) => a === b || JSON.stringify(a) === JSON.stringify(b);\n\ntype UseComponentInfo = NonNullable<KitServices[\"useComponentInfo\"]>;\n/**\n * \"Collapse preview\", remembered per component (V2 instance-card): read before the first render, so a reload never\n * draws the preview and then folds it away. Storage that is absent or throws reads as expanded.\n */\nfunction useCollapsed(ref: string | undefined): [boolean, (next: boolean) => void] {\n const key = ref ? `bcms:card-collapsed:${ref}` : null;\n const [collapsed, setState] = React.useState(() => {\n try {\n return !!key && globalThis.localStorage?.getItem(key) === \"1\";\n } catch {\n return false;\n }\n });\n const set = React.useCallback(\n (next: boolean) => {\n setState(next);\n if (!key) return;\n try {\n if (next) globalThis.localStorage?.setItem(key, \"1\");\n else globalThis.localStorage?.removeItem(key);\n } catch {\n // not remembered; the card still folds for this session\n }\n },\n [key],\n );\n return [collapsed, set];\n}\n\ntype SetComponent = (patch: Partial<ComponentModel> | ((m: ComponentModel) => ComponentModel), label: string, record?: boolean) => void;\n\nexport function ComponentCard({\n m, el, ctx, use, overrides, set,\n}: { m: ComponentModel; el: IslandEl; ctx: IslandCtx; use: UseComponentInfo; overrides: Record<string, unknown>; set: SetComponent }) {\n const { copyComponent, toast, ComponentPreview, IconGlyph, componentVariantMember, ComponentSettings, openComponent, componentHref } = useKitServices();\n // a linked place's layout is its family's member component (a variant is its own component): the card reads and\n // draws that member, as V2 draws the instance in its variant. No member → the layout stays named in the rows.\n const member = !m.detached && m.ref && m.variant ? componentVariantMember?.(m.ref, m.variant) : undefined;\n const ref = member ?? m.ref;\n const variant = member ? undefined : m.variant;\n const { info, loading, error } = use(ref ?? \"\");\n const card = React.useRef<HTMLDivElement | null>(null);\n const width = useWidth(card);\n const narrow = !!width && width <= NARROW;\n const [collapsed, setCollapsed] = useCollapsed(m.ref);\n const [dialog, setDialog] = React.useState<null | \"detach\" | \"relink\">(null);\n const [busy, setBusy] = React.useState(false);\n const detached = !!m.detached;\n const own = React.useMemo(() => parseObj(m.props), [m.props]);\n const missing = !ref || !!info?.missing;\n const name = info && !info.missing ? info.name : m.name || info?.name || \"Block\";\n const fieldKeys = new Set((info?.fields ?? []).map((f) => f.key));\n const edited = missing || detached ? 0 : Object.keys(overrides).filter((k) => fieldKeys.has(k)).length;\n const places = info?.places;\n const known = !!info || missing;\n // compared as instants, not strings: the same publish can be spelled two ways (precision, offset)\n const changed = detached && !missing && laterThan(info?.publishedAt, m.sourcePublishedAt);\n const state = detached ? `Detached${changed ? \", Shared version changed\" : \"\"}` : missing ? \"Missing block\" : edited || m.variant ? \"Edited here\" : \"Shared\";\n // V2 instance-ui: a required prop this place leaves empty marks the scope chip, never by colour alone\n const requiredEmpty = !missing && !detached && (info?.fields ?? []).some((f) => f.required && blank(f.key in overrides ? overrides[f.key] : f.value));\n // \"Show on site\" off (`fields.visible: false`): the place stays in the body, with its values, and off the published page\n const hidden = m.visible === false;\n const label = `${name} block${known ? `, ${state}` : \"\"}${known && !missing && !detached && places != null ? `, ${placesShort(places)}` : \"\"}${requiredEmpty ? `. ${REQUIRED_EMPTY}` : \"\"}${hidden ? `${requiredEmpty ? \"\" : \".\"} Hidden on your site` : \"\"}`;\n const rows = detached ? copyRows(own, info?.fields, m.variant) : previewRows(missing, info?.fields, overrides, variant);\n // the picture is the component with its own values (the host's snapshot): drawn only where this place shows exactly\n // that. A separate copy, an edited place or another layout would be shown content it doesn't have, so those list\n // their values instead.\n const image = missing || detached || edited || variant ? null : info?.image || null;\n // V2 draws the component itself in the card, with this place's values (linked, edited or a separate copy): the host's\n // live renderer where it has one. Another layout lists its values (the renderer draws the component's own layout).\n const liveProps = React.useMemo(\n () => (detached ? own : { ...Object.fromEntries((info?.fields ?? []).flatMap((f) => (f.value !== undefined ? [[f.key, f.value]] : []))), ...overrides }),\n [detached, own, info?.fields, overrides],\n );\n const live = ComponentPreview && ref && info && !missing && !variant ? { Preview: ComponentPreview, ref } : null;\n const preview = live ? (\n <LivePreview Preview={live.Preview} componentId={live.ref} title={name} props={liveProps} rows={rows} />\n ) : image || rows.length ? (\n <PreviewWindow image={image} rows={rows} />\n ) : null;\n const canCopy = !!copyComponent && !!m.ref && !ctx.readOnly;\n const ro = !!ctx.readOnly;\n const linked = !missing && !detached;\n const open = useComponentPanel(el);\n const editing = !!open;\n const [cardEl, setCardEl] = React.useState<HTMLDivElement | null>(null);\n const cardRef = React.useCallback((n: HTMLDivElement | null) => {\n card.current = n;\n if (n) setCardEl(n);\n }, []);\n const openPanel = React.useCallback((focusKey?: string | null) => openComponentPanel(el, focusKey ?? null), [el]);\n const closePanel = React.useCallback(() => closeComponentPanel(el), [el]);\n const focusCard = React.useCallback(() => requestAnimationFrame(() => card.current?.focus({ preventScroll: true })), []);\n // removing the component closes its panel\n React.useEffect(() => () => closeComponentPanel(el), [el]);\n const swappable = useCatalogComponents()?.components ?? [];\n const [swapTo, setSwapTo] = React.useState<KitInsertableComponent | null>(null);\n const editAll = openComponent && m.ref && info && linked\n ? { label: places != null && places > 1 ? `Edit for all ${places} places` : \"Edit the shared block\", run: () => openComponent(m.ref!) }\n : undefined;\n const href = m.ref ? componentHref?.(m.ref, m.id) : undefined;\n const hasEdits = linked && (Object.keys(overrides).length > 0 || !!m.variant);\n\n /**\n * The change as ONE undo step (IslandCtx.step: the dock's toolbar Undo, this toast's Undo and ⌘Z in the body are one\n * undo), and the toast that offers it back.\n */\n const commit = (patch: (cur: ComponentModel) => ComponentModel, label: string, title: string, description: string) => {\n const before = el.__rt as ComponentModel | undefined;\n const undo = ctx.step\n ? ctx.step(label, () => (set(patch, label, false), el), before)\n : (set(patch, label), () => (ctx.undo?.() ? (true as const) : \"Changes made after it come first. Press ⌘Z to undo them.\"));\n toast?.(title, {\n description,\n action: {\n label: \"Undo\",\n onClick: () => {\n const r = undo();\n if (r !== true) ctx.notify(\"Nothing was undone\", r);\n },\n },\n });\n };\n\n /** V2 detachNow: this place keeps what readers see now and stops following the component, as one undo step. */\n const detach = async (title: string) => {\n if (!copyComponent || !m.ref || busy) return;\n setBusy(true);\n try {\n const copy = await copyComponent(m.ref, { overrides, ...(m.variant ? { variant: m.variant } : {}) });\n commit(\n (cur) => ({\n id: cur.id,\n ref: cur.ref,\n ...(cur.name !== undefined || info?.name ? { name: cur.name ?? info?.name } : {}),\n ...(cur.variant !== undefined ? { variant: cur.variant } : {}),\n detached: true,\n props: JSON.stringify(copy.props),\n ...(copy.blocks !== undefined ? { blocks: copy.blocks } : {}),\n ...(copy.sourcePublishedAt ? { sourcePublishedAt: copy.sourcePublishedAt } : {}),\n ...(cur.visible !== undefined ? { visible: cur.visible } : {}),\n ...(cur.extra !== undefined ? { extra: cur.extra } : {}),\n }),\n \"Make a separate copy\",\n title,\n \"It keeps its content and no longer follows the shared block.\",\n );\n } catch (e) {\n ctx.notify(\"This place couldn't keep its own copy\", e instanceof Error ? e.message : String(e));\n } finally {\n setBusy(false);\n }\n };\n\n /** V2 instanceOps.relink: keep = what differs from the component becomes overrides; reset = the component's content. */\n const relink = (mode: \"keep\" | \"reset\") => {\n const kept = copyEdits(m, own, info?.fields);\n const n = Object.keys(kept).length;\n commit(\n (cur) => ({\n id: cur.id,\n ref: cur.ref,\n ...(cur.name !== undefined ? { name: info?.name ?? cur.name } : {}),\n ...(mode === \"keep\" && Object.keys(kept).length ? { overrides: JSON.stringify(kept) } : {}),\n ...(mode === \"keep\" && cur.variant !== undefined ? { variant: cur.variant } : {}),\n ...(cur.visible !== undefined ? { visible: cur.visible } : {}),\n ...(cur.extra !== undefined ? { extra: cur.extra } : {}),\n }),\n \"Use shared version again\",\n `${name} is shared again`,\n mode === \"keep\" && n ? `${n} ${n === 1 ? \"edit\" : \"edits\"} kept here.` : \"It shows the block's content.\",\n );\n };\n\n /** V2 instanceOps.resetAll: this place's overrides and its layout go, as one undo step. */\n const resetAll = () =>\n commit(\n (cur) => {\n const { variant: _v, ...rest } = cur;\n return { ...rest, overrides: \"{}\" };\n },\n \"Reset all edits here\",\n `Back to the shared ${name}`,\n \"This place shows the block's content again.\",\n );\n\n /**\n * V2 instanceOps.swap, once the new component's fields are known (SwapResolver): this place's edits stay only where the\n * new component declares a field with that key; everything else is the new component's own content. One undo step.\n */\n const swap = (to: KitInsertableComponent, next: KitComponentInfo) => {\n const keys = new Set((next.fields ?? []).map((f) => f.key));\n const src = detached ? own : overrides;\n const kept = Object.fromEntries(Object.entries(src).filter(([k]) => keys.has(k)));\n const n = Object.keys(kept).length;\n commit(\n (cur) => ({ id: cur.id, ref: to.id, name: next.name || to.name, overrides: JSON.stringify(kept), ...(cur.visible !== undefined ? { visible: cur.visible } : {}), ...(cur.extra !== undefined ? { extra: cur.extra } : {}) }),\n `Swap to ${to.name}`,\n `Swapped to ${to.name}`,\n n ? `Kept ${n} ${n === 1 ? \"edit\" : \"edits\"} made here.` : \"It shows the block's own content.\",\n );\n };\n\n /** \"Show on site\": one undo step, the toast offers it back. Showing again writes `visible: true`, as an insert does. */\n const toggleVisible = () =>\n commit(\n (cur) => ({ ...cur, visible: hidden }),\n hidden ? \"Show on your site\" : \"Hide on your site\",\n hidden ? `${name} is back on your site` : `${name} is hidden on your site`,\n hidden ? \"Readers see it in this place again.\" : \"It stays here with its values. Readers don't see it.\",\n );\n\n const copyLink = () => {\n if (!href) return;\n void navigator.clipboard?.writeText(href).catch(() => {});\n toast?.success(\"Link copied\", { description: `Opens this page scrolled to the ${name}.` });\n };\n\n /** The panel's form writes this place: overrides (or the layout) as one undo step each, through the island's model. */\n const onOverrides = (next: Record<string, unknown>) => {\n const changed = [...new Set([...Object.keys(next), ...Object.keys(overrides)])].find((k) => !same(next[k], overrides[k]));\n // an object patch with one label per field: the editor's history merges a burst of typing into ONE step (V2 D54)\n set({ overrides: JSON.stringify(next) }, changed ? `Edit ${changed}` : \"Edit block properties\");\n };\n const onVariant = (variant: string | undefined) =>\n set(\n (cur) => {\n const { variant: _v, ...rest } = cur;\n return variant ? { ...rest, variant } : rest;\n },\n \"Change layout\",\n );\n\n /** V2 instance card keys, on the focused card itself (fields and the portalled panel keep their own). */\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.defaultPrevented || e.target !== card.current) return;\n const mod = e.metaKey || e.ctrlKey;\n const k = eventKey(e);\n if (mod && k === \"z\") {\n e.preventDefault();\n e.stopPropagation();\n if (e.shiftKey) ctx.redo?.();\n else ctx.undo?.();\n return;\n }\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n openPanel();\n return;\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n if (editing) closePanel();\n else ctx.exit(el);\n return;\n }\n if (ro) return;\n if (mod && k === \"d\" && ctx.duplicate) {\n e.preventDefault();\n e.stopPropagation();\n ctx.duplicate(el);\n } else if (e.altKey && (e.key === \"ArrowUp\" || e.key === \"ArrowDown\") && ctx.move) {\n e.preventDefault();\n ctx.move(el, e.key === \"ArrowUp\" ? -1 : 1);\n focusCard();\n } else if (e.key === \"Backspace\" || e.key === \"Delete\") {\n e.preventDefault();\n ctx.remove(el);\n }\n };\n\n const chip = (compact: boolean) =>\n detached ? (\n <>\n <DetachedChip name={name} compact={compact} />\n {changed ? <ChangedChip name={name} compact={compact} onReview={canCopy ? () => setDialog(\"relink\") : undefined} /> : null}\n </>\n ) : known ? (\n <StateChip missing={missing} places={places} edited={edited} layout={!!m.variant} requiredEmpty={requiredEmpty} compact={compact} />\n ) : null;\n const chips = (compact: boolean) => (\n <>\n {chip(compact)}\n {hidden ? <HiddenChip compact={compact} /> : null}\n </>\n );\n\n return (\n <div\n ref={cardRef}\n role=\"group\"\n tabIndex={0}\n aria-label={label}\n aria-roledescription=\"component\"\n aria-haspopup=\"dialog\"\n aria-expanded={editing}\n aria-busy={busy || undefined}\n data-instance-card=\"\"\n data-rt-isolate=\"\"\n data-state={detached ? \"detached\" : missing ? \"missing\" : known ? \"linked\" : undefined}\n data-hidden={hidden ? \"\" : undefined}\n onKeyDown={onKeyDown}\n onClick={(e) => {\n // a click on the card (not on its controls) opens its properties, V2 instance card\n if (!e.currentTarget.contains(e.target as Node) || (e.target as HTMLElement).closest(\"button,a,[role=menuitem],[role=note],[role=alert]\")) return;\n // on a listed value, with that field focused (the live preview is inert, so it is found by position)\n openPanel(propKeyAt(e.currentTarget, e.clientX, e.clientY));\n }}\n className={cn(\n // V2 instance-card.tsx:223 transition-colors (the focus ring stays the kit's keyboard ring, DESIGN focus rule)\n \"group/inst relative cursor-pointer rounded-kit-lg border bg-kit-control-bg text-left focus-visible:outline-offset-2 transition-colors duration-150 motion-reduce:transition-none\",\n editing\n ? \"border-transparent shadow-[0_0_0_2px_var(--kit-accent)]\"\n : missing && !detached\n ? \"border-kit-warning-line\"\n : \"border-kit-line hover:border-kit-line-strong\",\n )}\n >\n {/* Strip (V2): drag grip (hover / focus, always on touch) · icon · name · scope chip · ⋯ */}\n <div className=\"flex h-9 select-none items-center gap-1.5 pl-1 pr-1\">\n {ro || !ctx.drag ? (\n <span className=\"w-1\" />\n ) : (\n <Tooltip content=\"Drag to move\">\n <button\n type=\"button\"\n aria-label={`Move ${name}`}\n tabIndex={-1}\n onPointerDown={(e) => ctx.drag?.(el, e)}\n className=\"flex h-7 w-4 shrink-0 cursor-grab touch-none pointer-coarse:size-11 items-center justify-center rounded-kit-sm text-kit-fg-4 opacity-0 transition-opacity duration-150 hover:text-kit-fg-2 active:cursor-grabbing motion-reduce:transition-none group-hover/inst:opacity-100 group-focus-within/inst:opacity-100 pointer-coarse:opacity-100 [&_svg]:size-3.5\"\n >\n <IconGripVertical stroke={1.5} />\n </button>\n </Tooltip>\n )}\n {info?.icon && IconGlyph ? (\n <span aria-hidden className=\"flex size-[15px] shrink-0 text-kit-fg-2 [&_svg]:size-full\">\n <IconGlyph name={info.icon} className=\"size-[15px]\" />\n </span>\n ) : (\n <IconComponents size={15} stroke={1.5} className=\"shrink-0 text-kit-fg-2\" aria-hidden />\n )}\n <span className=\"min-w-0 shrink truncate text-kit-sm font-medium text-kit-fg\">{name}</span>\n {chips(narrow)}\n <span className=\"flex-1\" />\n <Menu>\n <MenuTrigger\n render={\n <IconButton size=\"sm\" className=\"shrink-0\" label={`${name} actions`}>\n <IconDots stroke={1.5} />\n </IconButton>\n }\n />\n <MenuContent align=\"end\" className=\"w-64\">\n {ComponentSettings ? (\n <MenuItem icon={<IconAdjustmentsHorizontal stroke={1.5} />} onClick={() => openPanel()}>\n Edit properties\n </MenuItem>\n ) : null}\n {!ro ? (\n <MenuItem icon={hidden ? <IconEye stroke={1.5} /> : <IconEyeOff stroke={1.5} />} onClick={toggleVisible}>\n {hidden ? \"Show on your site\" : \"Hide on your site\"}\n </MenuItem>\n ) : null}\n {editAll ? (\n <MenuItem icon={<IconArrowUpRight stroke={1.5} />} onClick={editAll.run}>\n {editAll.label}\n </MenuItem>\n ) : null}\n {!ro && hasEdits ? (\n <MenuItem icon={<IconRestore stroke={1.5} />} onClick={resetAll}>\n Reset all edits here\n </MenuItem>\n ) : null}\n {canCopy && info && !missing && !detached ? (\n <MenuItem icon={<IconUnlink stroke={1.5} />} disabled={busy} onClick={() => setDialog(\"detach\")}>\n Make a separate copy\n </MenuItem>\n ) : null}\n {canCopy && missing && !detached ? (\n <MenuItem icon={<IconUnlink stroke={1.5} />} disabled={busy} onClick={() => void detach(\"Kept as a separate copy\")}>\n Keep as a separate copy\n </MenuItem>\n ) : null}\n {canCopy && info && !missing && detached ? (\n <MenuItem icon={<IconLink stroke={1.5} />} onClick={() => setDialog(\"relink\")}>\n Use shared version again\n </MenuItem>\n ) : null}\n {!ro && swappable.length ? (\n <MenuSub>\n <MenuSubTrigger icon={<IconReplace stroke={1.5} />}>Swap block</MenuSubTrigger>\n <MenuSubContent className=\"max-h-[320px] w-60 overflow-y-auto\">\n {swappable.map((c) => {\n const on = c.id === m.ref;\n return (\n <MenuItem key={c.id} icon={<IconComponents stroke={1.5} />} disabled={on || !!swapTo} onClick={() => setSwapTo(c)}>\n <span className=\"flex w-full items-center justify-between gap-2\">\n <span className=\"truncate\">{c.name}</span>\n {on ? <IconCheck className=\"size-3.5 shrink-0 text-kit-fg-2\" stroke={2} aria-label=\"Current\" /> : null}\n </span>\n </MenuItem>\n );\n })}\n </MenuSubContent>\n </MenuSub>\n ) : null}\n {preview ? (\n <MenuItem icon={collapsed ? <IconLayoutNavbarExpand stroke={1.5} /> : <IconLayoutNavbarCollapse stroke={1.5} />} onClick={() => setCollapsed(!collapsed)}>\n {collapsed ? \"Show preview\" : \"Collapse preview\"}\n </MenuItem>\n ) : null}\n <MenuSeparator />\n {!ro && ctx.duplicate ? (\n <MenuItem icon={<IconCopy stroke={1.5} />} shortcut=\"⌘D\" onClick={() => ctx.duplicate?.(el)}>\n Duplicate\n </MenuItem>\n ) : null}\n {!ro && ctx.move ? (\n <>\n <MenuItem icon={<IconArrowBarToUp stroke={1.5} />} shortcut=\"⌥↑\" disabled={!el.previousElementSibling} onClick={() => ctx.move?.(el, -1)}>\n Move up\n </MenuItem>\n <MenuItem icon={<IconArrowBarToDown stroke={1.5} />} shortcut=\"⌥↓\" disabled={!el.nextElementSibling} onClick={() => ctx.move?.(el, 1)}>\n Move down\n </MenuItem>\n </>\n ) : null}\n {href ? (\n <MenuItem icon={<IconLink stroke={1.5} />} onClick={copyLink}>\n Copy link\n </MenuItem>\n ) : null}\n {!ro ? (\n <>\n <MenuSeparator />\n <MenuItem danger icon={<IconTrash stroke={1.5} />} shortcut=\"⌫\" onClick={() => ctx.remove(el)}>\n Remove\n </MenuItem>\n </>\n ) : null}\n </MenuContent>\n </Menu>\n </div>\n {error ? (\n <div role=\"alert\" className=\"flex items-center gap-2 border-t border-kit-line-subtle px-3 py-2.5 text-kit-sm text-kit-fg-2\">\n <IconAlertTriangle className=\"size-4 shrink-0 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0 flex-1\">{error}</span>\n </div>\n ) : null}\n {missing && !detached && !loading ? (\n <div className=\"flex flex-wrap items-center gap-2 border-t border-kit-line-subtle px-3 py-2.5 text-kit-sm\" role=\"note\">\n <IconAlertTriangle className=\"size-4 shrink-0 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0 flex-1 text-kit-fg-2\">The original “{name}” was deleted. Readers see nothing in this place.</span>\n {ctx.readOnly ? null : (\n <span className=\"flex shrink-0 items-center gap-1.5\">\n {canCopy ? (\n <Button size=\"xs\" variant=\"secondary\" loading={busy} onClick={() => void detach(\"Kept as a separate copy\")}>\n Keep as a separate copy\n </Button>\n ) : null}\n <Button size=\"xs\" variant=\"danger-ghost\" onClick={() => ctx.remove(el)}>\n Remove\n </Button>\n </span>\n )}\n </div>\n ) : null}\n {collapsed ? null : hidden && preview ? <div className=\"opacity-50\">{preview}</div> : preview}\n {canCopy ? (\n <>\n <DetachDialog\n open={dialog === \"detach\"}\n name={name}\n places={places}\n onClose={() => setDialog(null)}\n onConfirm={() => {\n setDialog(null);\n void detach(`Separate copy of ${name}`);\n }}\n />\n <RelinkDialog\n open={dialog === \"relink\"}\n name={name}\n kept={Object.keys(copyEdits(m, own, info?.fields)).length}\n onClose={() => setDialog(null)}\n onConfirm={(mode) => {\n setDialog(null);\n relink(mode);\n }}\n />\n </>\n ) : null}\n {swapTo ? (\n <SwapResolver\n use={use}\n to={swapTo}\n onReady={(next) => {\n setSwapTo(null);\n swap(swapTo, next);\n }}\n onFail={(why) => {\n setSwapTo(null);\n ctx.notify(`Couldn't swap to ${swapTo.name}`, why);\n }}\n />\n ) : null}\n {open ? (\n <ComponentPanel\n name={name}\n chip={chips(false)}\n anchor={cardEl}\n open={open}\n editAll={editAll}\n onClose={closePanel}\n focusBack={focusCard}\n settings={{\n componentId: m.ref ?? \"\",\n overrides,\n ...(m.variant ? { variant: m.variant } : {}),\n ...(detached ? { detached: { props: own } } : {}),\n // a separate copy keeps the values it was made with (its frozen blocks are drawn from them): read-only here\n readOnly: ro || detached || missing,\n onOverrides,\n onVariant,\n }}\n />\n ) : null}\n </div>\n );\n}\n\n/**\n * A separate copy's EDITS, which it keeps as overrides when it follows the component again: its values that differ from\n * the snapshot taken when the copy was made, never from the component as it is now (a republish since is not an edit\n * of this place; the owner saw \"2 fields stay as they are\" with nothing edited).\n *\n * A copy made here stores that snapshot: its values (`props`) with the blocks drawn from them (`blocks`), and no\n * surface edits a copy's values afterwards, so it has no edits. Copy markup from V2 stores no snapshot (no `blocks`):\n * its values that differ from the component's, on fields the component has (V2 instanceOps.relink).\n */\nfunction copyEdits(m: ComponentModel, own: Record<string, unknown>, fields: KitComponentField[] | undefined): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n if (m.blocks !== undefined) return out;\n for (const f of fields ?? []) if (f.key in own && !same(own[f.key], f.value)) out[f.key] = own[f.key];\n return out;\n}\n\nconst REQUIRED_EMPTY = \"Required field empty.\";\n/** Nothing an author would call filled in: no value, blank text, an empty list. */\nconst blank = (v: unknown) => v == null || (typeof v === \"string\" && !v.trim()) || (Array.isArray(v) && v.length === 0);\n\n/** V2 StateChip: 13px, neutral, not a pill; the missing chip is the one tinted state. */\nfunction StateChip({ missing, places, edited, layout, requiredEmpty, compact }: { missing: boolean; places?: number; edited: number; layout?: boolean; requiredEmpty?: boolean; compact: boolean }) {\n const base = CHIP;\n if (missing) {\n return (\n <Tooltip content=\"The block was deleted. Readers see nothing in this place.\">\n <span className={cn(base, \"bg-kit-warning-soft px-1.5 text-kit-warning-fg\")}>\n <IconAlertTriangle className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Missing block</span> : \"Missing block\"}\n </span>\n </Tooltip>\n );\n }\n const count = places ? placesShort(places) : null;\n const tip = `Changes here apply only to this place. Edit the block to change ${places && places > 1 ? `all ${places}` : \"it everywhere\"}.${\n edited ? ` ${edited} ${edited === 1 ? \"field\" : \"fields\"} edited here.` : \"\"}${layout ? \" Its layout is set here.\" : \"\"}${requiredEmpty ? ` ${REQUIRED_EMPTY}` : \"\"\n }`;\n return (\n <Tooltip content={tip}>\n <span className={cn(base, \"px-1 text-kit-fg-2\")} tabIndex={-1}>\n {requiredEmpty ? <span data-required-empty className=\"size-1.5 shrink-0 rounded-full bg-kit-danger-fg\" aria-hidden /> : null}\n <IconLink className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Shared{count ? `, ${count}` : \"\"}</span> : count ?? \"Shared\"}\n {!compact && count ? <span className=\"sr-only\">, shared</span> : null}\n {edited || layout ? (\n <>\n <span className=\"ml-1 size-1.5 shrink-0 rounded-full bg-kit-accent\" aria-hidden />\n {compact ? <span className=\"sr-only\">, edited here</span> : <span>Edited here</span>}\n </>\n ) : null}\n </span>\n </Tooltip>\n );\n}\n\nconst CHIP = \"inline-flex h-6 shrink-0 items-center gap-1 rounded-kit-md text-[13px] leading-none whitespace-nowrap\";\n\n/** \"Show on site\" off: fg-3, the eye-off glyph. Never by colour alone: the words (or, narrow, their screen-reader copy) say it. */\nfunction HiddenChip({ compact }: { compact: boolean }) {\n return (\n <Tooltip content=\"Readers don't see this block. It stays here with its values. Choose Show on your site in the block's menu to bring it back.\">\n <span data-hidden-chip=\"\" className={cn(CHIP, \"px-1 text-kit-fg-3\")} tabIndex={-1}>\n <IconEyeOff className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Hidden on your site</span> : \"Hidden on your site\"}\n </span>\n </Tooltip>\n );\n}\n\n/** V2 StateChip, detached: fg-3, the unlink glyph. */\nfunction DetachedChip({ name, compact }: { name: string; compact: boolean }) {\n return (\n <Tooltip content={`A separate copy. Changes to ${name} don't reach it.`}>\n <span className={cn(CHIP, \"px-1 text-kit-fg-3\")} tabIndex={-1}>\n <IconUnlink className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Detached</span> : \"Detached\"}\n </span>\n </Tooltip>\n );\n}\n\n/** V2 StateChip, update: a quiet button that opens the way back to the shared version. */\nfunction ChangedChip({ name, compact, onReview }: { name: string; compact: boolean; onReview?: () => void }) {\n return (\n <Tooltip content={`${name} changed since this copy was made.`}>\n <button\n type=\"button\"\n onClick={onReview}\n disabled={!onReview}\n className={cn(CHIP, \"px-1 text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg disabled:hover:bg-transparent\")}\n >\n <IconRefresh className=\"size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {compact ? <span className=\"sr-only\">Shared version changed</span> : \"Shared version changed\"}\n </button>\n </Tooltip>\n );\n}\n\n/** V2 useInstanceDialogs \"detach\": confirm before this place stops following the component. */\nfunction DetachDialog({ open, name, places, onClose, onConfirm }: { open: boolean; name: string; places?: number; onClose: () => void; onConfirm: () => void }) {\n const others = places != null ? places - 1 : null;\n return (\n <Modal open={open} onOpenChange={(o) => !o && onClose()}>\n <ModalContent size=\"sm\">\n <ModalHeader title={`Make a separate copy of ${name}?`} description=\"This place keeps its current content and stops following the shared block.\" />\n {others != null ? (\n <ModalBody className=\"pt-2 text-kit-sm text-kit-fg-2\">\n {others > 0 ? `The other ${others === 1 ? \"place stays\" : `${others} places stay`} shared.` : \"No other place uses it.\"}\n </ModalBody>\n ) : null}\n <ModalFooter>\n <Button variant=\"ghost\" onClick={onClose}>\n Cancel\n </Button>\n <Button variant=\"primary\" autoFocus onClick={onConfirm}>\n Make a copy\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n );\n}\n\n/** V2 RelinkDialog: keep this place's edits as overrides, or take the component's content. */\nfunction RelinkDialog({ open, name, kept, onClose, onConfirm }: { open: boolean; name: string; kept: number; onClose: () => void; onConfirm: (mode: \"keep\" | \"reset\") => void }) {\n const [mode, setMode] = React.useState<\"keep\" | \"reset\">(\"keep\");\n React.useEffect(() => {\n if (open) setMode(\"keep\");\n }, [open]);\n const rows: { v: \"keep\" | \"reset\"; title: string; line: string }[] = [\n {\n v: \"keep\",\n title: \"Keep my edits here\",\n line: kept ? `${kept} ${kept === 1 ? \"field stays\" : \"fields stay\"} as ${kept === 1 ? \"it is\" : \"they are\"}; everything else follows ${name} again.` : `Nothing differs, so it simply follows ${name} again.`,\n },\n { v: \"reset\", title: `Use ${name}'s content`, line: \"Drops the edits made here. Undo is one click away.\" },\n ];\n return (\n <Modal open={open} onOpenChange={(o) => !o && onClose()}>\n <ModalContent size=\"sm\">\n <ModalHeader title={`Use the shared ${name} again?`} description=\"This place follows the shared block again.\" />\n <ModalBody className=\"pt-3\">\n <div\n role=\"radiogroup\"\n aria-label=\"Use shared version again\"\n className=\"flex flex-col divide-y divide-kit-line overflow-hidden rounded-kit-lg border border-kit-line\"\n onKeyDown={(e) => {\n // a radio group moves with the arrow keys (one tab stop, the checked row)\n if (![\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"].includes(e.key)) return;\n e.preventDefault();\n const next = mode === \"keep\" ? \"reset\" : \"keep\";\n setMode(next);\n (e.currentTarget.querySelector(`[data-mode=\"${next}\"]`) as HTMLElement | null)?.focus();\n }}\n >\n {rows.map((row) => (\n <button\n key={row.v}\n type=\"button\"\n role=\"radio\"\n data-mode={row.v}\n tabIndex={mode === row.v ? 0 : -1}\n aria-checked={mode === row.v}\n onClick={() => setMode(row.v)}\n className={cn(\"flex min-h-14 items-start gap-3 px-3 py-2.5 text-left transition-colors hover:bg-kit-hover\", mode === row.v && \"bg-kit-subtle\")}\n >\n <span className={cn(\"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border\", mode === row.v ? \"border-kit-control-checked\" : \"border-kit-line-strong\")}>\n {mode === row.v ? <span className=\"size-2 rounded-full bg-kit-fg\" /> : null}\n </span>\n <span className=\"min-w-0\">\n <span className=\"block text-kit-sm font-medium text-kit-fg\">{row.title}</span>\n <span className=\"block text-kit-xs text-kit-fg-3\">{row.line}</span>\n </span>\n </button>\n ))}\n </div>\n </ModalBody>\n <ModalFooter>\n <Button variant=\"ghost\" onClick={onClose}>\n Cancel\n </Button>\n <Button variant=\"primary\" onClick={() => onConfirm(mode)}>\n Use shared version\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n );\n}\n\ninterface Row {\n key: string;\n label: string;\n text: string;\n}\n\n/**\n * What the window lists when there is no picture: each field's value as this place shows it (its override, else the\n * component's own), then the layout this place draws it in. A missing component has only what this place stored: its\n * overrides, named by their keys, and its layout.\n */\n/** A choice field's value as its option's label (BUG-8: a select whose values are ids listed the id); others as they are. */\nfunction chosen(f: KitComponentField, v: unknown): unknown {\n if (!f.options) return v;\n const label = (x: unknown) => f.options!.find((o) => o.value === x)?.label ?? x;\n return Array.isArray(v) ? v.map(label).join(\", \") : label(v);\n}\n\nfunction previewRows(missing: boolean, fields: KitComponentField[] | undefined, overrides: Record<string, unknown>, variant?: string): Row[] {\n const out: Row[] = [];\n if (missing || !fields) {\n for (const [key, v] of Object.entries(overrides)) {\n const text = readable(v);\n if (text) out.push({ key, label: key, text });\n }\n } else {\n for (const f of fields) {\n const text = readable(chosen(f, f.key in overrides ? overrides[f.key] : f.value));\n if (text) out.push({ key: f.key, label: f.label, text });\n }\n }\n if (variant) out.push({ key: \"__variant\", label: \"Layout\", text: variant });\n return out;\n}\n\n/**\n * A separate copy's values (V2 `props`) in the component's field order. A field the copy doesn't hold draws the\n * component's value for it, as V2's renderer does for a copy (it draws the def with `props`, defaults for the rest);\n * a value the component no longer has a field for follows, under its key. Then its layout.\n */\nfunction copyRows(own: Record<string, unknown>, fields: KitComponentField[] | undefined, variant?: string): Row[] {\n const out: Row[] = [];\n const push = (key: string, label: string, v: unknown) => {\n const text = readable(v);\n if (text) out.push({ key, label, text });\n };\n for (const f of fields ?? []) push(f.key, f.label, chosen(f, f.key in own ? own[f.key] : f.value));\n for (const [key, v] of Object.entries(own)) if (!fields?.some((f) => f.key === key)) push(key, key, v);\n if (variant) out.push({ key: \"__variant\", label: \"Layout\", text: variant });\n return out;\n}\n\n/**\n * The preview's frame: under the card's header, capped at PREVIEW_H (its top border inside, as V2's CappedPreview).\n * The cap lifts instantly on hover: a height animation is layout work every frame (canvas revamp V937).\n */\nconst PREVIEW_CHROME = \"group/cap relative max-h-[240px] overflow-hidden rounded-b-kit-lg border-t border-kit-line-subtle\";\n\n/**\n * V2 instance-card CappedPreview: at most 240px, faded at its foot when the content is taller; hover shows its full\n * height. Measured a frame after each resize, so a frame or picture that sizes itself late is read once settled.\n */\nfunction CappedPreview({ live, children }: { live?: boolean; children: React.ReactNode }) {\n const inner = React.useRef<HTMLDivElement>(null);\n const [tall, setTall] = React.useState(false);\n // a live frame is the site: on V2's light site paper in both themes; a listing or picture stays on the themed chrome\n const [site, setSite] = React.useState(false);\n React.useLayoutEffect(() => {\n const el = inner.current;\n if (!el) return;\n let raf = 0;\n const measure = () => {\n cancelAnimationFrame(raf);\n raf = requestAnimationFrame(() => {\n setTall(el.offsetHeight > PREVIEW_H + 1);\n setSite(!!el.querySelector(\"iframe\"));\n });\n };\n measure();\n const ro = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(measure);\n ro?.observe(el);\n // the frame can mount without a size change (the shell keeps its remembered height), so a mount re-measures too\n const mo = typeof MutationObserver === \"undefined\" ? null : new MutationObserver(measure);\n mo?.observe(el, { childList: true, subtree: true });\n return () => {\n ro?.disconnect();\n mo?.disconnect();\n cancelAnimationFrame(raf);\n };\n }, []);\n return (\n <div\n data-instance-preview=\"\"\n data-live={live ? \"\" : undefined}\n data-tall={tall ? \"\" : undefined}\n data-site={site ? \"\" : undefined}\n className={cn(PREVIEW_CHROME, site ? \"bg-kit-site-paper\" : \"bg-kit-subtle\", tall && \"can-hover:hover:max-h-[2400px]\")}\n >\n <div ref={inner}>{children}</div>\n {/* V2's fade: inside the capped box, into its paper (the site paper under a live frame, else the chrome) */}\n {tall ? (\n <div\n aria-hidden\n className={cn(\n \"pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-b from-transparent transition-opacity duration-150 ease-out can-hover:group-hover/cap:opacity-0 motion-reduce:transition-none\",\n site ? \"to-kit-site-paper\" : \"to-kit-subtle\",\n )}\n />\n ) : null}\n </div>\n );\n}\n\nfunction PreviewWindow({ image, rows }: { image: string | null; rows: Row[] }) {\n return (\n <CappedPreview>\n <PreviewBody image={image} rows={rows} />\n </CappedPreview>\n );\n}\n\n/**\n * The component drawn live by the host (KitServices.ComponentPreview), mounted once the card is on screen. Its height is\n * reserved from the start (PREVIEW_H), so the card never moves while it loads; where the host cannot draw it, the values\n * are listed under the reason.\n */\nfunction LivePreview({\n Preview,\n componentId,\n title,\n props,\n rows,\n}: {\n Preview: React.ComponentType<KitComponentPreviewProps>;\n componentId: string;\n title: string;\n props: Record<string, unknown>;\n rows: Row[];\n}) {\n const box = React.useRef<HTMLDivElement>(null);\n const [seen, setSeen] = React.useState(() => typeof IntersectionObserver === \"undefined\");\n React.useEffect(() => {\n const el = box.current;\n if (seen || !el) return;\n const io = new IntersectionObserver((entries) => {\n if (entries.some((e) => e.isIntersecting)) setSeen(true);\n });\n io.observe(el);\n return () => io.disconnect();\n }, [seen]);\n return (\n <CappedPreview live>\n <div ref={box}>\n {seen ? (\n <Preview componentId={componentId} title={title} props={props} fallback={(reason) => <PreviewBody image={null} rows={rows} note={reason} />} />\n ) : (\n <div aria-hidden style={{ height: PREVIEW_H }} />\n )}\n </div>\n </CappedPreview>\n );\n}\n\nfunction PreviewBody({ image, rows, note }: { image: string | null; rows: Row[]; note?: string }) {\n // a picture's height is unknown until it loads: the cap is held until then, so the card doesn't jump when it lands\n const [loaded, setLoaded] = React.useState(!image);\n return (\n <div style={!loaded ? { height: PREVIEW_H } : undefined}>\n {image ? (\n // the whole width, scaled to the card like V2's frame (top-left origin): never cropped at the sides\n <img src={image} alt=\"\" className=\"block h-auto w-full\" draggable={false} onLoad={() => setLoaded(true)} onError={() => setLoaded(true)} />\n ) : (\n <>\n {note ? <p className=\"px-4 pt-3 text-kit-xs text-kit-fg-3\">{note}</p> : null}\n <dl className=\"flex flex-col gap-3 px-4 py-3.5\">\n {rows.map((r) => (\n // a click on a listed value opens the panel on that field (the card reads it by position: propKeyAt)\n <div key={r.key} data-prop-key={r.key === \"__variant\" ? undefined : r.key} className=\"min-w-0\">\n <dt className=\"truncate text-kit-xs text-kit-fg-3\">{r.label}</dt>\n <dd className=\"mt-0.5 line-clamp-3 text-kit-sm text-kit-fg\">{r.text}</dd>\n </div>\n ))}\n </dl>\n </>\n )}\n </div>\n );\n}\n\n/** The listed value (`data-prop-key`) under a point of the card, else null. */\nfunction propKeyAt(root: HTMLElement, x: number, y: number): string | null {\n for (const row of root.querySelectorAll<HTMLElement>(\"[data-prop-key]\")) {\n const r = row.getBoundingClientRect();\n if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) return row.dataset.propKey ?? null;\n }\n return null;\n}\n\n/**\n * Swap component: the new component's fields come from the same lookup the card reads (KitServices.useComponentInfo, a\n * hook, so it is asked from a component of its own). Answers once, when they are known.\n */\nfunction SwapResolver({\n use, to, onReady, onFail,\n}: {\n use: UseComponentInfo;\n to: KitInsertableComponent;\n onReady: (info: KitComponentInfo) => void;\n onFail: (why: string) => void;\n}) {\n const { info, error } = use(to.id);\n const done = React.useRef(false);\n React.useEffect(() => {\n if (done.current) return;\n if (error) {\n done.current = true;\n onFail(error);\n } else if (info?.missing) {\n done.current = true;\n onFail(\"The library has no such block.\");\n } else if (info) {\n done.current = true;\n onReady(info);\n }\n });\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,SAAS;;AAEf,IAAM,YAAY;AAElB,IAAM,eAAe,MAAc,GAAG,EAAE,GAAG,MAAM,IAAI,UAAU;AAE/D,SAAS,SAAS,KAA0C;CAC1D,MAAM,CAAC,GAAG,QAAQ,MAAM,SAAS,CAAC;CAClC,MAAM,sBAAsB;EAC1B,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,KAAK,GAAG,WAAW;EACnB,IAAI,OAAO,mBAAmB,aAAa;EAC3C,MAAM,KAAK,IAAI,qBAAqB,KAAK,GAAG,WAAW,CAAC;EACxD,GAAG,QAAQ,EAAE;EACb,aAAa,GAAG,WAAW;CAC7B,GAAG,CAAC,GAAG,CAAC;CACR,O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AAQ,WAAW;CAChG;CACA,OAAO;AACT;;;;;AAMA,SAAS,aAAa,EACpB,KAAK,IAAI,SAAS,UAMjB;CACD,MAAM,EAAE,MAAM,UAAU,IAAI,GAAG,EAAE;CACjC,MAAM,OAAO,MAAM,OAAO,KAAK;CAC/B,MAAM,gBAAgB;EACpB,IAAI,KAAK,SAAS;EAClB,IAAI,OAAO;GACT,KAAK,UAAU;GACf,OAAO,KAAK;EACd,OAAO,IAAI,MAAM,SAAS;GACxB,KAAK,UAAU;GACf,OAAO,gCAAgC;EACzC,OAAO,IAAI,MAAM;GACf,KAAK,UAAU;GACf,QAAQ,IAAI;EACd;CACF,CAAC;CACD,OAAO;AACT"}
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
* data-id data-name data-overrides data-variant>` — a linked instance of a project component, shown as a card.
|
|
37
37
|
* A separate copy (V2 instances.ts `detach`) adds {detached, props, blocks, sourcePublishedAt}:
|
|
38
38
|
* `data-detached="true" data-props data-blocks data-source-published-at`, and carries no overrides.
|
|
39
|
+
* "Show on site" is {visible} (`data-visible`): false keeps the place in the body and off the published
|
|
40
|
+
* page; absent reads as shown.
|
|
39
41
|
* A key the stored block holds is an attribute or element that is present; a key it lacks is absent, so an untouched
|
|
40
42
|
* block reads back exactly as stored.
|
|
41
43
|
* V2's gallery, columns, footnotes, contents, related posts and author bio have no stored form in production and are
|
|
@@ -211,6 +213,8 @@ export interface ComponentModel {
|
|
|
211
213
|
blocks?: string;
|
|
212
214
|
/** the version of the component the copy was taken from (`fields.sourcePublishedAt`) */
|
|
213
215
|
sourcePublishedAt?: string;
|
|
216
|
+
/** "Show on site" (`fields.visible`): false keeps this place in the body and leaves it off the published page; absent reads as shown */
|
|
217
|
+
visible?: boolean;
|
|
214
218
|
extra?: string;
|
|
215
219
|
}
|
|
216
220
|
export interface IslandModels {
|
|
@@ -38,6 +38,8 @@ import { boolLabels, cellText, cellValue, emptyTable, formatNumber, isCellObject
|
|
|
38
38
|
* data-id data-name data-overrides data-variant>` — a linked instance of a project component, shown as a card.
|
|
39
39
|
* A separate copy (V2 instances.ts `detach`) adds {detached, props, blocks, sourcePublishedAt}:
|
|
40
40
|
* `data-detached="true" data-props data-blocks data-source-published-at`, and carries no overrides.
|
|
41
|
+
* "Show on site" is {visible} (`data-visible`): false keeps the place in the body and off the published
|
|
42
|
+
* page; absent reads as shown.
|
|
41
43
|
* A key the stored block holds is an attribute or element that is present; a key it lacks is absent, so an untouched
|
|
42
44
|
* block reads back exactly as stored.
|
|
43
45
|
* V2's gallery, columns, footnotes, contents, related posts and author bio have no stored form in production and are
|
|
@@ -229,7 +231,8 @@ function defaultModel(kind, extra) {
|
|
|
229
231
|
}),
|
|
230
232
|
component: () => ({
|
|
231
233
|
id: rid("ci"),
|
|
232
|
-
overrides: "{}"
|
|
234
|
+
overrides: "{}",
|
|
235
|
+
visible: true
|
|
233
236
|
}),
|
|
234
237
|
gallery: () => ({
|
|
235
238
|
layout: "grid",
|
|
@@ -362,7 +365,7 @@ function renderStatic(kind, model) {
|
|
|
362
365
|
const m = model;
|
|
363
366
|
const label = m.name || "Component";
|
|
364
367
|
const copy = m.detached ? ` data-detached="true"${attr("data-props", m.props)}${attr("data-blocks", m.blocks)}${attr("data-source-published-at", m.sourcePublishedAt)}` : "";
|
|
365
|
-
return `<div data-rt="component"${attr("data-ref", m.ref)} data-id="${escAttr(m.id)}"${attr("data-name", m.name)}${attr("data-overrides", m.overrides)}${attr("data-variant", m.variant)}${copy}${xAttr(m.extra)}>⧉ ${esc(label)} · ${m.detached ? "detached copy" : "component"}</div>`;
|
|
368
|
+
return `<div data-rt="component"${attr("data-ref", m.ref)} data-id="${escAttr(m.id)}"${attr("data-name", m.name)}${attr("data-overrides", m.overrides)}${attr("data-variant", m.variant)}${m.visible === void 0 ? "" : ` data-visible="${m.visible}"`}${copy}${xAttr(m.extra)}>⧉ ${esc(label)} · ${m.detached ? "detached copy" : "component"}</div>`;
|
|
366
369
|
}
|
|
367
370
|
}
|
|
368
371
|
}
|
|
@@ -998,6 +1001,8 @@ function parseIsland(kind, el) {
|
|
|
998
1001
|
if (overrides !== void 0) m.overrides = overrides;
|
|
999
1002
|
const variant = attrOf(el, "data-variant");
|
|
1000
1003
|
if (variant !== void 0) m.variant = variant;
|
|
1004
|
+
const visible = el.getAttribute("data-visible");
|
|
1005
|
+
if (visible === "true" || visible === "false") m.visible = visible === "true";
|
|
1001
1006
|
if (el.getAttribute("data-detached") === "true") {
|
|
1002
1007
|
m.detached = true;
|
|
1003
1008
|
const props = attrOf(el, "data-props");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","names":[],"sources":["../../../src/controls/rich-text/dom.ts"],"sourcesContent":["/**\n * RICH TEXT · DOM layer (V2 HEAD controls/rich-text/dom.ts). The field value is clean, semantic HTML; rich blocks are\n * \"islands\" while editing.\n *\n * Live DOM = the HTML, with every rich block swapped for a `div[data-rt-island=\"kind\"]` (contenteditable=false) that\n * React renders into through a portal. The island's model lives on the element (`el.__rt`).\n * Stored = `serialize()` swaps each island back for its static HTML (`renderStatic`). The static form is the markup\n * production's own renderer writes for the same block, so the host's ingest reads it back as that block.\n * Loading = `hydrate()` turns that markup back into islands, so a re-mount restores them.\n *\n * Only the blocks production stores are islands here. Each one's markup is what the host's codec renders the stored\n * block as and reads back (features/dock-v2/richTextCodec.ts); `data-extra` carries, opaque, whatever of the stored block\n * the editor does not edit, so nothing it holds is dropped by an edit elsewhere.\n * image `bcmsBlock` builtin:image: address, alt text, caption, alignment, size, link\n * (`<figure data-rt=\"image\" data-align data-size><a href><img src alt></a><figcaption>`)\n * table production's Portable Text table (rows of cells, a header row, header cells, and the V2 table's caption,\n * note, row groups and column groups), drawn with the kit's table editor (V2 TableBlock), stored as the markup\n * production's renderer writes (`<caption>`, `th[scope=colgroup data-group]`, a `<tbody data-key>` per row\n * group under a `th[scope=rowgroup]` row, `<figure data-rt=\"table\">…<p data-notes>` for the note; footnotes\n * fold into the note as `[1] …`, as production's ingest folds V2's). A cell's closing\n * footnote markers (`<sup data-footnote>`) ride the cell as written (`marks`). A table whose cells hold\n * other inline formatting the table value has no place for (a term, bold) is not an island: it stays\n * markup in the body, edited in place, so the formatting survives.\n * pullquote V2 article block (CPO D55), `<figure data-rt=\"pullquote\">` → a `pullQuote` block.\n * takeaways V2 article block (CPO D55), `<aside data-rt=\"takeaways\"><p data-title>…<ul><li>…` → a `keyTakeaways` block\n * {title?, points} (written in the text itself, V2 TakeawaysEditor).\n * callout `bcmsBlock` builtin:callout {tone, title, message}: `<div data-rt=\"callout\" data-callout><p data-title>…\n * <div data-body><p>…` (the message is plain text: paragraphs and line breaks)\n * toggle `bcmsBlock` builtin:toggle {title, body}: `<details data-rt=\"toggle\"><summary>…<div data-body><p>…`\n * video the `video` block {src, title}: `<div data-rt=\"video\" data-url data-title>`\n * embed V2's article Embed {url, title, aspect}: `<figure data-rt=\"embed\" data-url data-title data-aspect><a href>…`\n * (embed.tsx). Stored today as `bcmsBlock` builtin:video {url, title}, which keeps no aspect; the PT\n * `embed` block (plan RT3) does.\n * file the `file` block {src, name, size}: `<div data-rt=\"file\" data-url data-name data-size>`\n * component `bcmsBlock` \"component\" {componentId, overrides, variant} (CPO D28): `<div data-rt=\"component\" data-ref\n * data-id data-name data-overrides data-variant>` — a linked instance of a project component, shown as a card.\n * A separate copy (V2 instances.ts `detach`) adds {detached, props, blocks, sourcePublishedAt}:\n * `data-detached=\"true\" data-props data-blocks data-source-published-at`, and carries no overrides.\n * A key the stored block holds is an attribute or element that is present; a key it lacks is absent, so an untouched\n * block reads back exactly as stored.\n * V2's gallery, columns, footnotes, contents, related posts and author bio have no stored form in production and are\n * not offered.\n */\n\nimport { boolLabels, cellText, cellValue, emptyTable, formatNumber, isCellObject, isObjLike, normalizeTable, parseTableElement, tkey, toBool, toNumber, type TableCell, type TableColumn, type TableColumnType, type TableGroup, type TableLink, type TableRow, type TableValue } from \"../../schema/table\";\n\nexport const esc = (s: string) => s.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\");\nexport const escAttr = (s: string) => esc(s).replace(/\"/g, \""\");\nlet seq = 0;\nexport const rid = (p = \"r\") => `${p}${Date.now().toString(36)}${(seq++).toString(36)}`;\n\n/* ── Island models ─────────────────────────────────────────────────── */\nexport type ImageAlign = \"full\" | \"center\" | \"left\" | \"right\";\nexport type ImageSize = \"s\" | \"m\" | \"l\" | \"full\";\nexport const IMAGE_ALIGNS: readonly ImageAlign[] = [\"full\", \"center\", \"left\", \"right\"];\nexport const IMAGE_SIZES: readonly ImageSize[] = [\"s\", \"m\", \"l\", \"full\"];\n/** Every optional key is absent when the stored block lacks it (see the header). */\nexport interface ImageModel {\n src: string;\n /** absent only on a stored block that never had one (every new image has alt text, empty or not) */\n alt?: string;\n caption?: string;\n align?: ImageAlign;\n size?: ImageSize;\n href?: string;\n /** RT9: how much is cut from each edge, 0–1 of the source (image-url's crop) */\n crop?: ImageCrop;\n /** RT9: the subject, 0–1 of the source (image-url's focal) */\n focal?: { x: number; y: number };\n /** the stored block's other keys, opaque to the editor */\n extra?: string;\n}\n/** RT9: image-url's crop, each edge a 0–1 fraction of the source. */\nexport interface ImageCrop {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n/**\n * RT9: an image's framing as production writes it on the `<img>` (richtext richTextImageFrame): `data-src` the stored\n * url when the drawn one carries the crop, `data-crop` \"top,right,bottom,left\" and `data-focal` \"x,y\", each 0–1.\n */\nexport function readImageFrame(img: Element | null): { src: string; crop?: ImageCrop; focal?: { x: number; y: number } } {\n const src = img?.getAttribute(\"data-src\") ?? img?.getAttribute(\"src\") ?? \"\";\n const nums = (raw: string | null | undefined, n: number) => {\n const v = (raw ?? \"\").split(\",\").map((x) => Number(x));\n return raw && v.length === n && v.every((x) => Number.isFinite(x) && x >= 0 && x <= 1) ? v : null;\n };\n const c = nums(img?.getAttribute(\"data-crop\"), 4);\n const f = nums(img?.getAttribute(\"data-focal\"), 2);\n return {\n src,\n ...(c && c[0] + c[2] < 1 && c[1] + c[3] < 1 ? { crop: { top: c[0], right: c[1], bottom: c[2], left: c[3] } } : {}),\n ...(f ? { focal: { x: f[0], y: f[1] } } : {}),\n };\n}\nconst frameAttrs = (crop?: ImageCrop, focal?: { x: number; y: number }) =>\n `${crop ? ` data-crop=\"${[crop.top, crop.right, crop.bottom, crop.left].join(\",\")}\"` : \"\"}${focal ? ` data-focal=\"${focal.x},${focal.y}\"` : \"\"}`;\n/** A table island IS the kit's table value (V2 TableModel); only what production's table keeps is stored (see above). */\nexport type TableModel = TableValue;\n/** V2 PullQuoteModel (article.ts). */\nexport interface PullQuoteModel {\n quote: string;\n name: string;\n role: string;\n link: string;\n}\n/** V2 TakeawaysModel (article.ts): the title over the list and one plain string per point. */\nexport interface TakeawaysModel {\n title: string;\n points: string[];\n}\nexport type CalloutTone = \"info\" | \"tip\" | \"warning\";\nexport const CALLOUT_TONES: readonly CalloutTone[] = [\"info\", \"tip\", \"warning\"];\nexport interface CalloutModel {\n /** the stored tone, as written (the editor offers info, tip and warning) */\n tone?: string;\n title?: string;\n /** plain text: paragraphs split by a blank line, line breaks kept */\n body?: string;\n extra?: string;\n}\nexport interface ToggleModel {\n title?: string;\n body?: string;\n extra?: string;\n}\nexport interface VideoModel {\n url?: string;\n title?: string;\n extra?: string;\n}\n/** V2 EmbedModel (article.ts); `aspect` absent draws 16:9 (embed.tsx). */\nexport interface EmbedModel {\n url?: string;\n title?: string;\n aspect?: \"16:9\" | \"4:3\" | \"1:1\" | \"9:16\";\n /** the title is also the figure's aria-label, as production writes it (RT3) and a new embed does; kept as found */\n labelled?: true;\n extra?: string;\n}\nconst EMBED_ASPECT_VALUES: readonly string[] = [\"16:9\", \"4:3\", \"1:1\", \"9:16\"];\n/* V2 article.ts embed providers: detected from the link, for the editor's placeholder (nothing third-party loads in it) */\nexport type EmbedProvider = \"youtube\" | \"vimeo\" | \"x\" | \"codepen\" | \"figma\" | \"maps\" | \"spotify\" | \"podcast\" | \"audio\" | \"link\";\nexport interface EmbedInfo {\n provider: EmbedProvider;\n label: string;\n /** frame = a sized player · post = a social post card · audio = a slim player · link = a link card */\n shape: \"frame\" | \"post\" | \"audio\" | \"link\";\n host: string;\n}\nconst hostOf = (url: string) => {\n try {\n return new URL(url).hostname.replace(/^www\\./, \"\");\n } catch {\n return \"\";\n }\n};\nexport function detectEmbed(url: string): EmbedInfo {\n const u = url.trim();\n const host = hostOf(u);\n const is = (re: RegExp) => re.test(u);\n if (is(/(?:youtube\\.com\\/(?:watch\\?|embed\\/|shorts\\/|live\\/)|youtu\\.be\\/)/i)) return { provider: \"youtube\", label: \"YouTube\", shape: \"frame\", host };\n if (is(/vimeo\\.com\\/(?:video\\/)?\\d+/i)) return { provider: \"vimeo\", label: \"Vimeo\", shape: \"frame\", host };\n if (is(/(?:twitter|x)\\.com\\/[^/]+\\/status\\/\\d+/i)) return { provider: \"x\", label: \"X post\", shape: \"post\", host };\n if (is(/codepen\\.io\\/[^/]+\\/(?:pen|embed)\\//i)) return { provider: \"codepen\", label: \"CodePen\", shape: \"frame\", host };\n if (is(/figma\\.com\\/(?:file|design|proto|board)\\//i)) return { provider: \"figma\", label: \"Figma\", shape: \"frame\", host };\n if (is(/(?:google\\.[a-z.]+\\/maps|maps\\.app\\.goo\\.gl|goo\\.gl\\/maps)/i)) return { provider: \"maps\", label: \"Google Maps\", shape: \"frame\", host };\n if (is(/open\\.spotify\\.com\\/(?:episode|track|show|playlist|album)\\//i)) return { provider: \"spotify\", label: \"Spotify\", shape: \"audio\", host };\n if (is(/podcasts\\.apple\\.com\\//i)) return { provider: \"podcast\", label: \"Apple Podcasts\", shape: \"audio\", host };\n if (is(/\\.(?:mp3|m4a|wav|ogg|aac)(?:\\?|$)/i)) return { provider: \"audio\", label: \"Audio\", shape: \"audio\", host };\n return { provider: \"link\", label: host || \"Link\", shape: \"link\", host };\n}\n/** V2's article Gallery (plan RT4): `<figure data-rt=\"gallery\" data-layout><ul><li><figure><img src alt><figcaption>`. */\nexport interface GalleryIslandModel {\n layout?: \"grid\" | \"carousel\";\n /** `_key` is the editor's own (rows keep their identity while edited); src, alt and caption are what is stored */\n images: { _key: string; src: string; alt?: string; caption?: string; crop?: ImageCrop; focal?: { x: number; y: number } }[];\n extra?: string;\n}\n/** V2's article Table of contents (plan RT5): `<nav data-rt=\"toc\" data-depth><p data-title>`; the list is derived. */\nexport interface TocIslandModel {\n title?: string;\n depth?: \"2\" | \"3\";\n extra?: string;\n}\n/** V2's Columns (plan RT7): `<div data-rt=\"columns\" data-gap data-cols><div data-col=\"true\">…</div></div>`, text only. */\nexport interface ColumnsIslandModel {\n gap?: \"s\" | \"m\" | \"l\";\n /** each column's HTML (paragraphs and marks); `id` is the editor's own */\n cols: { id: string; html: string }[];\n extra?: string;\n}\n/** V2's Author bio (plan RT8): `<aside data-rt=\"author\" data-author>`; name, avatar and bio are resolved, never stored. */\nexport interface AuthorIslandModel {\n author?: string;\n extra?: string;\n}\n/** V2's Related posts (plan RT8): `<aside data-rt=\"related\" data-mode data-count data-posts>`; the list is resolved. */\nexport interface RelatedIslandModel {\n title?: string;\n mode?: \"topic\" | \"newest\" | \"manual\";\n count?: number;\n posts: string[];\n extra?: string;\n}\nexport interface FileModel {\n url?: string;\n name?: string;\n size?: number;\n extra?: string;\n}\n/** A linked instance of a project component (CPO D28): its library id, its own id, its name and its overrides. */\nexport interface ComponentModel {\n /** the component it links to (`fields.componentId`) */\n ref?: string;\n /** this instance (the block's key) */\n id: string;\n /** the component's name when it was placed (`schemaLabel`) */\n name?: string;\n /** the fields this instance overrides, as stored JSON */\n overrides?: string;\n /** the layout this instance draws the component in (V2's per-instance variant, `fields.variant`) */\n variant?: string;\n /** V2 `detached`: a separate copy that no longer follows the component (`fields.detached`) */\n detached?: boolean;\n /** a separate copy's values as readers see them, as stored JSON (V2 `props`, `fields.props`) */\n props?: string;\n /** a separate copy's frozen block tree, as stored JSON (`fields.blocks`); the editor never edits it */\n blocks?: string;\n /** the version of the component the copy was taken from (`fields.sourcePublishedAt`) */\n sourcePublishedAt?: string;\n extra?: string;\n}\nexport interface IslandModels {\n image: ImageModel;\n table: TableModel;\n pullquote: PullQuoteModel;\n takeaways: TakeawaysModel;\n callout: CalloutModel;\n toggle: ToggleModel;\n video: VideoModel;\n embed: EmbedModel;\n file: FileModel;\n component: ComponentModel;\n gallery: GalleryIslandModel;\n toc: TocIslandModel;\n columns: ColumnsIslandModel;\n author: AuthorIslandModel;\n related: RelatedIslandModel;\n}\nexport type IslandKind = keyof IslandModels;\nexport const ISLAND_KINDS: IslandKind[] = [\"image\", \"table\", \"pullquote\", \"takeaways\", \"callout\", \"toggle\", \"video\", \"embed\", \"file\", \"component\", \"gallery\", \"toc\", \"columns\", \"author\", \"related\"];\nexport type IslandEl = HTMLElement & {\n __rt?: IslandModels[IslandKind];\n __rtFocus?: boolean;\n /** the mounted island's own setter: restores a model from the editor's history (undo / redo) */\n __rtSet?: (m: IslandModels[IslandKind]) => void;\n};\n\nexport function defaultModel<K extends IslandKind>(kind: K, extra?: Partial<IslandModels[K]>): IslandModels[K] {\n const base: { [P in IslandKind]: () => IslandModels[P] } = {\n image: () => ({ src: \"\", alt: \"\" }),\n table: () => emptyTable(3, 2),\n pullquote: () => ({ quote: \"\", name: \"\", role: \"\", link: \"\" }),\n takeaways: () => ({ title: \"Key takeaways\", points: [\"\"] }),\n callout: () => ({ tone: \"info\", title: \"\", body: \"\" }),\n toggle: () => ({ title: \"\", body: \"\" }),\n video: () => ({ url: \"\" }),\n embed: () => ({ url: \"\", title: \"\", labelled: true }),\n file: () => ({ url: \"\", name: \"\" }),\n component: () => ({ id: rid(\"ci\"), overrides: \"{}\" }),\n // V2 article.ts ARTICLE_DEFAULTS\n gallery: () => ({ layout: \"grid\", images: [] }),\n toc: () => ({ title: \"In this article\", depth: \"3\" }),\n columns: () => ({ gap: \"m\", cols: [{ id: rid(\"col\"), html: \"\" }, { id: rid(\"col\"), html: \"\" }] }),\n author: () => ({ author: \"\" }),\n related: () => ({ title: \"Related stories\", mode: \"topic\", count: 3, posts: [] }),\n };\n if (kind === \"table\") return { ...base.table(), ...(extra ?? {}), id: tkey(\"tbl\") } as IslandModels[K];\n return { ...base[kind](), ...(extra ?? {}) } as IslandModels[K];\n}\n\n/** Deep copy (Duplicate). A copied table or component instance gets its own id. */\nexport const cloneModel = <K extends IslandKind>(kind: K, m: IslandModels[K]): IslandModels[K] => {\n const c = JSON.parse(JSON.stringify(m)) as IslandModels[K];\n if (kind === \"table\") (c as TableModel).id = tkey(\"tbl\");\n if (kind === \"component\") (c as ComponentModel).id = rid(\"ci\");\n return c;\n};\n\n/* ── plain text ⇄ paragraphs (a callout's message, a toggle's body) ── */\n/** \"a\\nb\\n\\nc\" → `<p>a<br>b</p><p>c</p>`. Split on exactly one blank line, so any text reads back as written. */\nexport const textToParas = (s: string) =>\n s\n .split(\"\\n\\n\")\n .map((p) => `<p>${esc(p).replace(/\\n/g, \"<br>\")}</p>`)\n .join(\"\");\n/** The inverse of textToParas: each paragraph's text, its line breaks kept. */\nexport function parasToText(el: Element): string {\n const ps = Array.from(el.children).filter((c) => c.tagName === \"P\");\n const text = (n: Element) => {\n const c = n.cloneNode(true) as Element;\n c.querySelectorAll(\"br\").forEach((br) => br.replaceWith(\"\\n\"));\n return (c.textContent ?? \"\").replace(/\\u200b/g, \"\");\n };\n return ps.length ? ps.map(text).join(\"\\n\\n\") : text(el);\n}\n\n/* ── Static HTML (stored) ──────────────────────────────────────────── */\n/** An image is `<figure><img src alt></figure>`: production's renderer writes exactly this, and its ingest reads it. */\nconst xAttr = (extra?: string) => (extra ? ` data-extra=\"${escAttr(extra)}\"` : \"\");\nconst attr = (name: string, v: string | number | undefined) => (v === undefined ? \"\" : ` ${name}=\"${escAttr(String(v))}\"`);\n\nexport function renderStatic(kind: IslandKind, model: unknown): string {\n switch (kind) {\n case \"image\": {\n const m = model as ImageModel;\n const img = m.src ? `<img src=\"${escAttr(m.src)}\"${attr(\"alt\", m.alt)}${frameAttrs(m.crop, m.focal)}>` : \"\";\n const linked = img && m.href !== undefined ? `<a href=\"${escAttr(m.href)}\">${img}</a>` : img;\n const cap = m.caption !== undefined ? `<figcaption>${esc(m.caption)}</figcaption>` : \"\";\n return `<figure data-rt=\"image\"${attr(\"data-align\", m.align)}${attr(\"data-size\", m.size)}${xAttr(m.extra)}>${linked}${cap}</figure>`;\n }\n case \"table\":\n return renderStoredTable(model as TableModel);\n case \"pullquote\": {\n // V2 article.ts renderArticle(\"pullquote\")\n const m = model as PullQuoteModel;\n const name = m.name ? (m.link ? `<a href=\"${escAttr(m.link)}\" data-name>${esc(m.name)}</a>` : `<span data-name>${esc(m.name)}</span>`) : \"\";\n const role = m.role ? `<span data-role>${esc(m.role)}</span>` : \"\";\n const cap = name || role ? `<figcaption>${name}${name && role ? \", \" : \"\"}${role}</figcaption>` : \"\";\n return `<figure data-rt=\"pullquote\"><blockquote${m.link ? ` cite=\"${escAttr(m.link)}\"` : \"\"}><p>${esc(m.quote)}</p></blockquote>${cap}</figure>`;\n }\n case \"takeaways\": {\n // V2 article.ts renderArticle(\"takeaways\")\n const m = model as TakeawaysModel;\n const pts = m.points.map((p) => p.trim()).filter(Boolean);\n return `<aside data-rt=\"takeaways\">${m.title ? `<p data-title>${esc(m.title)}</p>` : \"\"}<ul>${pts.map((p) => `<li>${esc(p)}</li>`).join(\"\")}</ul></aside>`;\n }\n case \"callout\": {\n const m = model as CalloutModel;\n const title = m.title !== undefined ? `<p data-title=\"true\">${esc(m.title)}</p>` : \"\";\n const body = m.body !== undefined ? `<div data-body=\"true\">${textToParas(m.body)}</div>` : \"\";\n return `<div data-rt=\"callout\"${attr(\"data-callout\", m.tone)}${xAttr(m.extra)}>${title}${body}</div>`;\n }\n case \"toggle\": {\n const m = model as ToggleModel;\n const title = m.title !== undefined ? `<summary>${esc(m.title)}</summary>` : \"\";\n const body = m.body !== undefined ? `<div data-body=\"true\">${textToParas(m.body)}</div>` : \"\";\n return `<details data-rt=\"toggle\"${xAttr(m.extra)}>${title}${body}</details>`;\n }\n case \"video\": {\n const m = model as VideoModel;\n return `<div data-rt=\"video\"${attr(\"data-url\", m.url)}${attr(\"data-title\", m.title)}${xAttr(m.extra)}>${m.url ? `<a href=\"${escAttr(m.url)}\">${esc(m.title || m.url)}</a>` : \"\"}</div>`;\n }\n case \"embed\": {\n // V2 article.ts renderArticle(\"embed\"), with the stored block's keys (no provider or shape: see the header)\n const m = model as EmbedModel;\n // aria-label carries the title as production writes it (its ingest reads it before the link's words)\n return `<figure data-rt=\"embed\"${attr(\"data-url\", m.url)}${attr(\"data-title\", m.title)}${m.labelled ? attr(\"aria-label\", m.title ?? \"\") : \"\"}${attr(\"data-aspect\", m.aspect)}${xAttr(m.extra)}>${m.url ? `<a href=\"${escAttr(m.url)}\">${esc(m.title || m.url)}</a>` : \"\"}</figure>`;\n }\n case \"gallery\": {\n // V2 article.ts renderArticle(\"gallery\"); an image not yet chosen is a <li> with no <img> (V2 reads it so)\n const m = model as GalleryIslandModel;\n const items = m.images\n .map((x) => `<li><figure>${x.src ? `<img src=\"${escAttr(x.src)}\" alt=\"${escAttr(x.alt ?? \"\")}\"${frameAttrs(x.crop, x.focal)}>` : \"\"}${x.caption ? `<figcaption>${esc(x.caption)}</figcaption>` : \"\"}</figure></li>`)\n .join(\"\");\n return `<figure data-rt=\"gallery\"${attr(\"data-layout\", m.layout)}${xAttr(m.extra)}><ul>${items}</ul></figure>`;\n }\n case \"toc\": {\n // V2 article.ts renderArticle(\"toc\"): the list is the body's outline, derived where it is drawn, so none is stored\n const m = model as TocIslandModel;\n const title = (m.title ?? \"\").trim();\n return `<nav data-rt=\"toc\"${attr(\"data-depth\", m.depth)} aria-label=\"${escAttr(title || \"Table of contents\")}\"${xAttr(m.extra)}>${title ? `<p data-title>${esc(title)}</p>` : \"\"}<ol></ol></nav>`;\n }\n case \"columns\": {\n // V2 dom.ts renderStatic(\"columns\")\n const m = model as ColumnsIslandModel;\n return `<div data-rt=\"columns\"${attr(\"data-gap\", m.gap)} data-cols=\"${m.cols.length}\"${xAttr(m.extra)}>${m.cols.map((c) => `<div data-col=\"true\">${c.html}</div>`).join(\"\")}</div>`;\n }\n case \"author\": {\n // V2 article.ts renderArticle(\"author\") without the resolved entry: the reference is what is stored\n const m = model as AuthorIslandModel;\n return `<aside data-rt=\"author\"${attr(\"data-author\", m.author)}${xAttr(m.extra)}></aside>`;\n }\n case \"related\": {\n // V2 article.ts renderArticle(\"related\") without the resolved list: title, mode, count and picks are stored\n const m = model as RelatedIslandModel;\n return `<aside data-rt=\"related\"${attr(\"data-mode\", m.mode)}${attr(\"data-count\", m.count)} data-posts=\"${escAttr(m.posts.join(\",\"))}\"${xAttr(m.extra)}>${m.title ? `<p data-title>${esc(m.title)}</p>` : \"\"}</aside>`;\n }\n case \"file\": {\n const m = model as FileModel;\n const link = m.url && m.name ? `<a href=\"${escAttr(m.url)}\" download>${esc(m.name)}</a>` : \"\";\n return `<div data-rt=\"file\"${attr(\"data-url\", m.url)}${attr(\"data-name\", m.name)}${attr(\"data-size\", m.size)}${xAttr(m.extra)}>${link}</div>`;\n }\n case \"component\": {\n const m = model as ComponentModel;\n const label = m.name || \"Component\";\n const copy = m.detached ? ` data-detached=\"true\"${attr(\"data-props\", m.props)}${attr(\"data-blocks\", m.blocks)}${attr(\"data-source-published-at\", m.sourcePublishedAt)}` : \"\";\n return `<div data-rt=\"component\"${attr(\"data-ref\", m.ref)} data-id=\"${escAttr(m.id)}\"${attr(\"data-name\", m.name)}${attr(\"data-overrides\", m.overrides)}${attr(\"data-variant\", m.variant)}${copy}${xAttr(m.extra)}>⧉ ${esc(label)} · ${m.detached ? \"detached copy\" : \"component\"}</div>`;\n }\n }\n}\n\n/* The V2 table's group rows, read as production's ingest reads them (@bettercms-ai/richtext ingest.ts). */\nconst words = (el: Element | null | undefined) => (el?.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\nconst scopeIs = (c: Element, scope: string) => c.tagName === \"TH\" && (c.getAttribute(\"scope\") ?? \"\").toLowerCase() === scope;\n/** In `<thead>`: a `th[scope=colgroup]`, every other cell an empty `<td>`. A site's own two-row header stays rows. */\nconst isColumnGroupRow = (tr: HTMLTableRowElement) =>\n tr.parentElement?.tagName === \"THEAD\" &&\n Array.from(tr.cells).some((c) => scopeIs(c, \"colgroup\")) &&\n Array.from(tr.cells).every((c) => scopeIs(c, \"colgroup\") || (c.tagName === \"TD\" && !words(c)));\n/**\n * One `th[scope=rowgroup]` and nothing else, OPENING its own `<tbody>` with a body row after it (what production and\n * V2 write). A site's own `scope=rowgroup` row anywhere else stays a row, as production's ingest keeps it.\n */\nconst isRowGroupRow = (tr: HTMLTableRowElement) => {\n const body = tr.parentElement;\n if (tr.cells.length !== 1 || !scopeIs(tr.cells[0], \"rowgroup\") || body?.tagName !== \"TBODY\") return false;\n const rows = Array.from(body.children).filter((r) => r.tagName === \"TR\");\n return rows[0] === tr && rows.length > 1;\n};\nconst KEY = /^[A-Za-z0-9-]{1,32}$/;\n\n/* ── Typed columns and cells (V2 schema/table.ts; production's Portable Text table: a first-row cell's `column`, a row's and a\n * cell's `type`, a cell's `value`, the package's typedCellView) ── */\n/** The column types a rich-text table stores: V2's island offers these (table-editor.tsx:80-86 TYPE_UI, the non-dev ones). */\nexport const STORED_COLUMN_TYPES: readonly TableColumnType[] = [\"text\", \"number\", \"money\", \"boolean\", \"rating\", \"link\"];\nconst storedType = (v: unknown): TableColumnType | undefined => (STORED_COLUMN_TYPES as readonly unknown[]).includes(v) ? (v as TableColumnType) : undefined;\n/** A column's type and settings as stored (V2 TableColumn's keys). */\nexport type ColumnSettings = Partial<Pick<TableColumn, \"type\" | \"description\" | \"unit\" | \"currency\" | \"decimals\" | \"align\" | \"trueLabel\" | \"falseLabel\" | \"max\">>;\n/** The settings a kit column stores: none for a plain text or link column, else its type and every setting it has. */\nexport function columnSettings(c: TableColumn): ColumnSettings | undefined {\n const s: ColumnSettings = {\n ...(c.description ? { description: c.description } : {}),\n ...(c.unit ? { unit: c.unit } : {}),\n ...(c.currency ? { currency: c.currency } : {}),\n ...(c.decimals != null ? { decimals: c.decimals } : {}),\n ...(c.align ? { align: c.align } : {}),\n ...(c.trueLabel ? { trueLabel: c.trueLabel } : {}),\n ...(c.falseLabel ? { falseLabel: c.falseLabel } : {}),\n ...(c.max != null ? { max: c.max } : {}),\n };\n const type = storedType(c.type) ?? \"text\";\n return type === \"text\" || type === \"link\" ? (Object.keys(s).length ? { type, ...s } : undefined) : { type, ...s };\n}\n/** A `<col>`'s attributes, V2 renderTableHtml's order (schema/table.ts:511-526): the column's settings, data-sortable among them. */\nexport function colAttrs(c: ColumnSettings | undefined, sortable: boolean): string {\n return [\n c ? ` data-type=\"${c.type ?? \"text\"}\"` : \"\",\n c?.unit ? ` data-unit=\"${escAttr(c.unit)}\"` : \"\",\n c?.currency ? ` data-currency=\"${escAttr(c.currency)}\"` : \"\",\n c?.decimals != null ? ` data-decimals=\"${c.decimals}\"` : \"\",\n c?.align ? ` data-align=\"${c.align}\"` : \"\",\n sortable ? ' data-sortable=\"true\"' : \"\",\n c?.trueLabel ? ` data-true=\"${escAttr(c.trueLabel)}\"` : \"\",\n c?.falseLabel ? ` data-false=\"${escAttr(c.falseLabel)}\"` : \"\",\n c?.max != null ? ` data-max=\"${c.max}\"` : \"\",\n c?.description ? ` data-description=\"${escAttr(c.description)}\"` : \"\",\n ].join(\"\");\n}\n/** A `<col data-type …>` read back, as V2 parseTableElement reads it; undefined without a data-type. */\nexport function colSettingsOf(col: Element): ColumnSettings | undefined {\n const d = (n: string) => col.getAttribute(`data-${n}`) ?? undefined;\n const type = storedType(d(\"type\"));\n if (!type) return undefined;\n const int = (n: string, lo: number, hi: number) => {\n const v = Number(d(n));\n return d(n) !== undefined && Number.isInteger(v) && v >= lo && v <= hi ? v : undefined;\n };\n const align = d(\"align\");\n return {\n type,\n ...(d(\"unit\") ? { unit: d(\"unit\") } : {}),\n ...(d(\"currency\") && /^[A-Z]{3}$/.test(d(\"currency\")!) ? { currency: d(\"currency\") } : {}),\n ...(int(\"decimals\", 0, 10) !== undefined ? { decimals: int(\"decimals\", 0, 10) } : {}),\n ...(align === \"start\" || align === \"center\" || align === \"end\" ? { align } : {}),\n ...(d(\"true\") ? { trueLabel: d(\"true\") } : {}),\n ...(d(\"false\") ? { falseLabel: d(\"false\") } : {}),\n ...(int(\"max\", 1, 10) !== undefined ? { max: int(\"max\", 1, 10) } : {}),\n ...(d(\"description\") ? { description: d(\"description\") } : {}),\n };\n}\nconst NUMERIC = new Set<TableColumnType>([\"number\", \"money\", \"rating\"]);\n/** V2 alignOf (schema/table.ts:365). */\nconst alignOf = (c: ColumnSettings | undefined, t: TableColumnType) => c?.align ?? (NUMERIC.has(t) ? \"end\" : \"start\");\nexport const isValueType = (t: TableColumnType) => t === \"boolean\" || NUMERIC.has(t);\nconst asColumn = (c: ColumnSettings | undefined): TableColumn => ({ _key: \"\", label: \"\", ...c, type: c?.type ?? \"text\" });\n/** V2 cellText for a typed cell: the words it says (what a stored typed cell's blocks hold). */\nexport const typedWords = (c: ColumnSettings | undefined, type: TableColumnType, value: unknown): string =>\n value == null || value === \"\" ? \"\" : cellText(asColumn(c), undefined, { value, type } as TableCell);\n/**\n * What one cell of a typed table draws, as production's renderer writes it (the package's typedCellView, V2 cellHtml\n * schema/table.ts:369-437 and the column header at :564): `lead` attributes before data-label / data-highlight, `tail` after,\n * and the markup when the cell is empty or of a value type (undefined: the cell draws its own text or link).\n */\nexport function typedCellView(column: ColumnSettings | undefined, rowType: TableColumnType | undefined, cellType: TableColumnType | undefined, value: unknown, header: boolean, inHead: boolean): { lead: string; tail: string; inner?: string } {\n if (inHead) {\n const a = alignOf(column, column?.type ?? \"text\");\n return { lead: a !== \"start\" ? ` data-align=\"${a}\"` : \"\", tail: column?.description ? ` title=\"${escAttr(column.description)}\"` : \"\" };\n }\n const type = cellType ?? rowType ?? column?.type ?? \"text\";\n const words = typeof value === \"string\" ? value.replace(/\\s+/g, \" \").trim() : value;\n let tail = cellType ? ` data-type=\"${cellType}\"` : \"\";\n let inner: string | undefined;\n if (words == null || words === \"\") {\n inner = header ? \"\" : '<span aria-hidden=\"true\" class=\"bt-dash\">—</span><span class=\"bt-sr\">No value</span>';\n tail += ' data-empty=\"\"';\n } else if (type === \"boolean\") {\n const b = toBool(words);\n if (b == null) inner = esc(String(words));\n else {\n const { yes, no } = boolLabels(asColumn(column));\n inner = `<span aria-hidden=\"true\" class=\"bt-bool\" data-bool=\"${b}\">${b ? \"✓\" : \"–\"}</span><span class=\"bt-sr\">${esc(b ? yes : no)}</span>`;\n tail += ` data-value=\"${b}\"`;\n }\n } else if (type === \"rating\") {\n const n = toNumber(words);\n if (n == null) inner = esc(String(words));\n else {\n inner = `<span aria-hidden=\"true\" class=\"bt-star\">★</span> ${esc(formatNumber(n, 1).replace(/\\.0$/, \"\"))}<span class=\"bt-dim\"> / ${column?.max ?? 5}</span>`;\n tail += ` data-value=\"${n}\"`;\n }\n } else if (type === \"number\" || type === \"money\") {\n const n = toNumber(words);\n inner = esc(typedWords(column, type, words));\n if (n != null) tail += ` data-value=\"${n}\"`;\n }\n const a = alignOf(column, type);\n if (a !== \"start\") tail += ` data-align=\"${a}\"`;\n return { lead: \"\", tail, ...(inner === undefined ? {} : { inner }) };\n}\n/** A typed cell read back (V2 readCell): data-empty is no value; data-value a number or true / false for a value type. */\nexport function typedValueOf(cell: Element, type: TableColumnType): number | boolean | \"\" | undefined {\n if (cell.hasAttribute(\"data-empty\")) return \"\";\n const raw = cell.getAttribute(\"data-value\");\n if (raw === null || !isValueType(type)) return undefined;\n if (type === \"boolean\") return raw === \"true\";\n return raw.trim() !== \"\" && Number.isFinite(Number(raw)) ? Number(raw) : undefined;\n}\nexport const typeAttrOf = (el: Element): TableColumnType | undefined => storedType(el.getAttribute(\"data-type\"));\n\n/**\n * Production's table markup → the table value, cell for cell (renderStoredTable's inverse): the plain `<table>`, or\n * the `<figure data-rt=\"table\">` around one with its note. The V2 reader (parseTableElement) is not used here: it reads\n * a one-column row as a row-group heading and a caption-less grid by guesses that a stored table never meant.\n */\nexport function parseStoredTable(src: Element): TableModel {\n const fig = src.tagName === \"FIGURE\" ? src : null;\n const table = fig ? fig.querySelector(\":scope > table\")! : src;\n const t = emptyTable(0, 0);\n const trs = Array.from(table.querySelectorAll<HTMLTableRowElement>(\":scope > thead > tr, :scope > tbody > tr, :scope > tfoot > tr, :scope > tr\"));\n const groupRow = trs.find(isColumnGroupRow);\n const grid = trs.filter((tr) => tr !== groupRow && !isRowGroupRow(tr));\n const head = grid.filter((tr) => tr.parentElement?.tagName === \"THEAD\");\n const body = grid.filter((tr) => tr.parentElement?.tagName !== \"THEAD\");\n const width = Math.max(1, ...grid.map((tr) => tr.cells.length));\n const headCells = head.length ? Array.from(head[head.length - 1].cells) : [];\n t.headerRow = head.length > 0;\n t.headerColumn = body.length > 0 && body.every((tr) => tr.cells[0]?.tagName === \"TH\");\n t.caption = words(table.querySelector(\":scope > caption\"));\n // \"Visitors can search rows\": production's figure carries data-filter (V2 renderTableHtml)\n if (fig?.getAttribute(\"data-filter\") === \"true\") t.filterable = true;\n // \"On phones\" / \"Keep column names in view\": the figure's data-responsive (stack, cards) / data-sticky, as V2 reads them\n const resp = fig?.getAttribute(\"data-responsive\");\n if (resp === \"stack\" || resp === \"cards\") t.design = { ...t.design, responsive: resp };\n if (fig?.getAttribute(\"data-sticky\") === \"true\") t.design = { ...t.design, sticky: true };\n // \"Help search engines read this as\": the figure's data-jsonld (+ axis, price row), as V2 parseTableElement reads it\n const ld = fig?.getAttribute(\"data-jsonld\");\n if (ld === \"ItemList\" || ld === \"Dataset\" || ld === \"Offers\") {\n const axis = fig?.getAttribute(\"data-jsonld-axis\");\n const price = fig?.getAttribute(\"data-jsonld-price\");\n t.jsonLd = { type: ld, ...(axis === \"rows\" || axis === \"columns\" ? { axis } : {}), ...(price ? { priceRow: price } : {}) };\n }\n // \"Visitors can sort columns\": the column's <col data-sortable=\"true\">; a <colgroup> without <col>s spans its `span`\n const sortable = new Set<number>();\n // A typed column's <col data-type …> (V2 renderTableHtml): its type and settings\n const settings: (ColumnSettings | undefined)[] = [];\n let colAt = 0;\n for (const g of Array.from(table.querySelectorAll(\":scope > colgroup\"))) {\n const list = Array.from(g.querySelectorAll(\":scope > col\"));\n if (!list.length) colAt += Math.max(1, Number(g.getAttribute(\"span\")) || 1);\n for (const col of list) {\n const w = Math.max(1, Number(col.getAttribute(\"span\")) || 1);\n if (col.getAttribute(\"data-sortable\") === \"true\") for (let i = 0; i < w; i++) sortable.add(colAt + i);\n for (let i = 0; i < w; i++) settings[colAt + i] = colSettingsOf(col);\n colAt += w;\n }\n }\n // \"Highlight this column\": production stamps `data-highlight` on every cell of the column (its first row names it)\n t.columns = Array.from({ length: width }, (_, i) => ({ _key: tkey(\"c\"), label: words(headCells[i]), ...settings[i], type: settings[i]?.type ?? (\"text\" as const), ...(grid[0]?.cells[i]?.getAttribute(\"data-highlight\") === \"true\" ? { highlight: true } : {}), ...(sortable.has(i) ? { sortable: true } : {}) }));\n // Footnotes (production 0.10 / V2: `<ol data-footnotes>` of `<li data-key>`), before the cells that name them\n const footnoteEls = Array.from(fig?.querySelectorAll(\"[data-footnotes] > li\") ?? []);\n if (footnoteEls.length) t.footnotes = footnoteEls.map((li) => ({ _key: li.getAttribute(\"data-key\") || tkey(\"f\"), text: words(li) }));\n const cellOf = (cell: HTMLTableCellElement | undefined, col: TableColumn, rowType: TableColumnType | undefined): TableRow[\"cells\"][string] => {\n if (!cell) return \"\";\n const { rest: c, marks } = splitMarks(cell);\n // a typed cell (V2 cellHtml): its own type, its value (data-value), data-empty for none\n // a table footnote's marker (`<sup><a href=\"#<key>-fn-<n>\">`) is the cell's note, not its words\n let mark: number | undefined;\n for (const sup of Array.from(c.querySelectorAll(\"sup\"))) {\n const n = /-fn-(\\d+)$/.exec(sup.querySelector(\"a\")?.getAttribute(\"href\") ?? \"\")?.[1];\n if (!n) continue;\n mark ??= Number(n);\n sup.remove();\n }\n const named = cell.getAttribute(\"data-note\") ?? (mark ? t.footnotes?.[mark - 1]?._key : undefined);\n const note = named && t.footnotes?.some((f) => f._key === named) ? named : undefined;\n const own = typeAttrOf(cell);\n const typed = typedValueOf(cell, own ?? rowType ?? col.type);\n const text = words(c);\n const a = c.children.length === 1 && c.firstElementChild?.tagName === \"A\" && c.firstElementChild.textContent?.trim() === text ? c.firstElementChild : null;\n const value = typed !== undefined ? typed : a ? { label: text, href: a.getAttribute(\"href\") ?? \"\" } : text;\n return own || marks || note ? { value, ...(own ? { type: own } : {}), ...(note ? { note } : {}), ...(marks ? { marks } : {}) } : value;\n };\n // A group's key rides the markup (`th[data-group]`, `<tbody data-key>`), so a save keeps it; the same key met again\n // (a group split by a loose row or column) is the same group.\n const groupOf = (list: TableGroup[], own: string | null, prefix: string, label: string): TableGroup => {\n const k = (own ?? \"\").trim();\n const found = k ? list.find((g) => g._key === k) : undefined;\n if (found) return found;\n const g = { _key: k && k.length <= 64 && !list.some((x) => x._key === k) ? k : tkey(prefix), label };\n list.push(g);\n return g;\n };\n // column groups: the columns each `th[scope=colgroup]` spans\n if (groupRow) {\n const groups: TableGroup[] = [];\n let at = 0;\n for (const c of Array.from(groupRow.cells)) {\n const span = Math.max(1, c.colSpan || 1);\n if (c.tagName === \"TH\") {\n const g = groupOf(groups, c.getAttribute(\"data-group\"), \"g\", words(c));\n for (let i = at; i < at + span && i < width; i++) t.columns[i].group = g._key;\n }\n at += span;\n }\n t.columnGroups = groups;\n }\n // row groups: a label row opens a group for the rows after it in its own <tbody>\n const rowGroups: TableGroup[] = [];\n let current: { key: string; body: Element | null } | undefined;\n t.rows = [];\n for (const tr of trs) {\n if (tr === groupRow || tr.parentElement?.tagName === \"THEAD\") continue;\n if (isRowGroupRow(tr)) {\n const g = groupOf(rowGroups, tr.parentElement?.getAttribute(\"data-key\") ?? null, \"rg\", words(tr.cells[0]));\n current = { key: g._key, body: tr.parentElement };\n continue;\n }\n if (current && current.body !== tr.parentElement) current = undefined;\n // the totals row is production's <tfoot>; \"Highlight this row\" its tr[data-highlight]\n const footer = tr.parentElement?.tagName === \"TFOOT\";\n // the row's type (V2 `<tr data-type>`)\n const rowType = typeAttrOf(tr);\n t.rows.push({\n _key: tkey(\"r\"),\n cells: Object.fromEntries(t.columns.map((col, i) => [col._key, cellOf(tr.cells[i], col, rowType)])),\n ...(rowType ? { type: rowType } : {}),\n ...(current && !footer ? { group: current.key } : {}),\n ...(footer ? { footer: true } : {}),\n ...(tr.getAttribute(\"data-highlight\") === \"true\" ? { highlight: true } : {}),\n });\n }\n if (rowGroups.length) t.rowGroups = rowGroups;\n // the note: the figure's own `<p data-notes>`, or inside V2's `<div class=\"bt-notes\">` when the table has footnotes\n const note = fig?.querySelector(\":scope > [data-notes], :scope > .bt-notes > [data-notes]\");\n const box = fig?.querySelector(\":scope > .bt-notes\");\n // whitespace collapsed, as production's ingest reads it: the note renders as one paragraph\n const notes = words(note);\n if (notes) t.notes = notes;\n // the stored table's key rides the notes' id (`<key>-notes`), so a save keeps it\n const own = (box?.getAttribute(\"id\") ?? note?.getAttribute(\"id\") ?? table.getAttribute(\"aria-describedby\") ?? \"\").replace(/-notes$/, \"\");\n if (KEY.test(own)) t.id = own;\n // a link cell's column is a link column, so the editor draws (and the renderer writes) the link\n t.columns.forEach((col, i) => {\n if (settings[i]) return;\n const vals = t.rows.map((r) => r.cells[col._key]).filter((v) => v !== \"\");\n if (vals.length && vals.every((v) => isObjLike(v))) col.type = \"link\";\n });\n return t;\n}\n\n/**\n * The table as production's renderer writes a Portable Text table (@bettercms-ai/richtext html.ts tableHtml): a header\n * row in <thead>, header cells of the first column as <th>, every cell its text (a link cell its link). A caption, a\n * note or a group adds what that renderer writes for it, in the order the rows are held (an unedited stored table\n * comes back as it was; the editor's row list writes V2's order, loose rows first). An empty group has no row to label\n * and is not written, as production's renderer writes none. The totals rows are a <tfoot> after every <tbody>; a\n * highlighted row is `<tr data-highlight=\"true\">` and a highlighted column `data-highlight=\"true\"` on each of its cells\n * (production 0.10, the V2 table's markup). A sortable column is its `<col data-sortable=\"true\">` (one `<col>` per column,\n * inside each column group's `<colgroup>`), and \"Visitors can search rows\" the figure's `data-filter=\"true\"`.\n */\nexport function renderStoredTable(input: TableModel): string {\n const t = normalizeTable(input);\n const cols = t.columns;\n // typed columns and cells (V2's types): the column's settings, written as production's renderer writes a typed table\n const settings = cols.map(columnSettings);\n const typed =\n settings.some(Boolean) || t.rows.some((r) => !!storedType(r.type) || Object.values(r.cells).some((c) => isCellObject(c) && !!storedType(c.type)));\n const cell = (row: TableRow, c: TableColumn, i: number, header: boolean) => {\n const raw = row.cells[c._key];\n const v = cellValue(raw);\n const text = esc(cellText(c, row, raw));\n const marks = isCellObject(raw) && typeof raw.marks === \"string\" ? raw.marks : \"\";\n const plain = (isObjLike(v) && typeof (v as TableLink).href === \"string\" && (v as TableLink).href ? `<a href=\"${escAttr((v as TableLink).href)}\">${text}</a>` : text) + marks;\n const tag = header ? \"th\" : \"td\";\n const fn = noted(row, c);\n if (!typed) return `<${tag}${hi(c)}${fn.attr}>${plain}${fn.sup}</${tag}>`;\n const view = typedCellView(settings[i], storedType(row.type), isCellObject(raw) ? storedType(raw.type) : undefined, isObjLike(v) ? cellText(c, row, raw) : v, header, false);\n // V2 cellHtml's order: data-type, data-value / data-empty, data-note, data-align; the footnote marker after the value\n const tail = view.tail.replace(/( data-align=\"[^\"]*\")?$/, `${fn.attr}$1`);\n return `<${tag}${view.lead}${hi(c)}${tail}>${view.inner === undefined ? plain : view.inner + marks}${fn.sup}</${tag}>`;\n };\n const hi = (c: TableColumn) => (c.highlight ? ' data-highlight=\"true\"' : \"\");\n // a footnote: the cell's data-note and production's (V2's) marker after its words\n const fnOf = new Map((t.footnotes ?? []).map((f, i) => [f._key, i + 1]));\n const noted = (row: TableRow, c: TableColumn) => {\n const raw = row.cells[c._key];\n const key = isCellObject(raw) ? raw.note : undefined;\n const n = key ? fnOf.get(key) : undefined;\n return n ? { attr: ` data-note=\"${escAttr(key!)}\"`, sup: `<sup><a href=\"#${escAttr(t.id ?? \"tbl\")}-fn-${n}\" aria-label=\"Note ${n}\">${n}</a></sup>` } : { attr: \"\", sup: \"\" };\n };\n const rowHtml = (row: TableRow) =>\n `<tr${typed && storedType(row.type) ? ` data-type=\"${row.type}\"` : \"\"}${row.highlight ? ' data-highlight=\"true\"' : \"\"}>${cols.map((c, i) => cell(row, c, i, i === 0 && t.headerColumn)).join(\"\")}</tr>`;\n const headRow = `<tr>${cols\n .map((c, i) => {\n const view = typed ? typedCellView(settings[i], undefined, undefined, undefined, true, true) : { lead: \"\", tail: \"\" };\n return `<th${view.lead}${hi(c)}${view.tail}>${esc(c.label)}</th>`;\n })\n .join(\"\")}</tr>`;\n const body = t.rows.filter((r) => !r.footer);\n const tfoot = t.rows.some((r) => r.footer) ? `<tfoot>${t.rows.filter((r) => r.footer).map(rowHtml).join(\"\")}</tfoot>` : \"\";\n const span = (name: string, n: number) => (n > 1 ? ` ${name}=\"${n}\"` : \"\");\n const colLabels = new Map((t.columnGroups ?? []).map((g) => [g._key, String(g.label ?? \"\")]));\n const rowLabels = new Map((t.rowGroups ?? []).map((g) => [g._key, String(g.label ?? \"\")]));\n const runs = <T,>(items: T[], keyOf: (x: T) => string | undefined) => {\n const out: { key?: string; items: T[] }[] = [];\n for (const x of items) {\n const key = keyOf(x);\n const last = out[out.length - 1];\n if (last && last.key === key) last.items.push(x);\n else out.push({ key, items: [x] });\n }\n return out.some((r) => r.key !== undefined) ? out : [];\n };\n const colRuns = runs(cols, (c) => (c.group && colLabels.has(c.group) ? c.group : undefined));\n const rowRuns = runs(body, (r) => (r.group && rowLabels.has(r.group) ? r.group : undefined));\n const caption = t.caption.trim();\n const notes = (t.notes ?? \"\").trim();\n const footnotes = t.footnotes ?? [];\n const sortable = cols.some((c) => c.sortable) || settings.some(Boolean);\n const filter = !!t.filterable;\n const ld = t.jsonLd && t.jsonLd.type !== \"none\" ? t.jsonLd : null;\n const resp = t.design?.responsive === \"stack\" || t.design?.responsive === \"cards\" ? t.design.responsive : null;\n const sticky = !!t.design?.sticky;\n if (!caption && !notes && !footnotes.length && !colRuns.length && !rowRuns.length && !sortable && !filter && !ld && !resp && !sticky && !typed) {\n const out: string[] = [\"<table>\"];\n if (t.headerRow) out.push(`<thead>${headRow}</thead>`);\n out.push(`${body.length || !tfoot ? `<tbody>${body.map(rowHtml).join(\"\")}</tbody>` : \"\"}${tfoot}</table>`);\n return out.join(\"\");\n }\n const notesId = notes || footnotes.length ? `${t.id}-notes` : \"\";\n const out: string[] = [`<table${notesId ? ` aria-describedby=\"${escAttr(notesId)}\"` : \"\"}>`];\n if (caption) out.push(`<caption>${esc(caption)}</caption>`);\n if (sortable) {\n let at = 0;\n const widths = colRuns.length ? colRuns.map((r) => r.items.length) : [cols.length];\n out.push(widths.map((w) => `<colgroup>${cols.slice(at, (at += w)).map((c, k) => `<col${colAttrs(settings[at - w + k], !!c.sortable)}>`).join(\"\")}</colgroup>`).join(\"\"));\n } else out.push(colRuns.map((r) => `<colgroup${span(\"span\", r.items.length)}></colgroup>`).join(\"\"));\n const groupRow = colRuns.length\n ? `<tr>${colRuns.map((r) => (r.key === undefined ? \"<td></td>\".repeat(r.items.length) : `<th scope=\"colgroup\"${span(\"colspan\", r.items.length)} data-group=\"${escAttr(r.key)}\">${esc(colLabels.get(r.key)!)}</th>`)).join(\"\")}</tr>`\n : \"\";\n if (groupRow || t.headerRow) out.push(`<thead>${groupRow}${t.headerRow ? headRow : \"\"}</thead>`);\n if (rowRuns.length)\n for (const r of rowRuns)\n out.push(`<tbody${r.key === undefined ? \"\" : ` data-key=\"${escAttr(r.key)}\"`}>${r.key === undefined ? \"\" : `<tr><th scope=\"rowgroup\"${span(\"colspan\", cols.length)}>${esc(rowLabels.get(r.key)!)}</th></tr>`}${r.items.map(rowHtml).join(\"\")}</tbody>`);\n else if (body.length) out.push(`<tbody>${body.map(rowHtml).join(\"\")}</tbody>`);\n out.push(`${tfoot}</table>`);\n const html = out.join(\"\");\n if (!notes && !footnotes.length && !filter && !ld && !resp && !sticky) return html;\n const designAttrs = `${resp ? ` data-responsive=\"${resp}\"` : \"\"}${sticky ? ' data-sticky=\"true\"' : \"\"}`;\n const ldAttrs = ld ? ` data-jsonld=\"${ld.type}\"${ld.axis ? ` data-jsonld-axis=\"${ld.axis}\"` : \"\"}${ld.priceRow ? ` data-jsonld-price=\"${escAttr(ld.priceRow)}\"` : \"\"}` : \"\";\n return `<figure data-rt=\"table\"${designAttrs}${filter ? ' data-filter=\"true\"' : \"\"}${ldAttrs}>${html}${\n footnotes.length\n ? `<div class=\"bt-notes\" id=\"${escAttr(notesId)}\">${notes ? `<p data-notes>${esc(notes)}</p>` : \"\"}<ol data-footnotes>${footnotes.map((f, i) => `<li id=\"${escAttr(t.id ?? \"tbl\")}-fn-${i + 1}\" data-key=\"${escAttr(f._key)}\">${esc(f.text)}</li>`).join(\"\")}</ol></div>`\n : notes ? `<p data-notes id=\"${escAttr(notesId)}\">${esc(notes)}</p>` : \"\"\n }</figure>`;\n}\n\n/* ── Detect + parse (static HTML → model) ──────────────────────────── */\n/** The footnote markers closing a cell (`<sup data-footnote>` holding only text), and the cell without them. */\nfunction splitMarks(c: Element): { rest: Element; marks: string } {\n const rest = c.cloneNode(true) as Element;\n const marks: string[] = [];\n for (let n = rest.lastChild; n; n = rest.lastChild) {\n if (n.nodeType === 3 && !(n.textContent ?? \"\").trim() && marks.length) n.remove();\n else if (n.nodeType === 1 && (n as Element).tagName === \"SUP\" && (n as Element).hasAttribute(\"data-footnote\") && !(n as Element).children.length) {\n marks.unshift((n as Element).outerHTML);\n n.remove();\n } else break;\n }\n return { rest, marks: marks.join(\"\") };\n}\n/** A cell the table value can hold: text, line breaks, or one link around its text, then any footnote markers. */\nconst plainCell = (cell: Element) => {\n // a typed cell's markup is V2 cellHtml's (the check mark, star or dash and its words), read from data-value / data-empty\n if (cell.hasAttribute(\"data-value\") || cell.hasAttribute(\"data-empty\")) return true;\n const c = splitMarks(cell).rest;\n return (\n Array.from(c.childNodes).every((n) => n.nodeType === 3 || (n.nodeType === 1 && (n as Element).tagName === \"BR\")) ||\n (c.children.length === 1 && c.firstElementChild!.tagName === \"A\" && c.firstElementChild!.children.length === 0 && (c.textContent ?? \"\").trim() === (c.firstElementChild!.textContent ?? \"\").trim())\n );\n};\n\nexport function detectKind(el: Element): IslandKind | null {\n const rt = el.getAttribute(\"data-rt\");\n if (rt === \"table\") return el.tagName === \"TABLE\" && !Array.from(el.querySelectorAll(\"td,th\")).every(plainCell) ? null : \"table\";\n if (rt && (ISLAND_KINDS as string[]).includes(rt)) return rt as IslandKind;\n // a quote with an attribution is a pull quote (V2 detectArticle; legacy: <blockquote><p>…</p><cite>…</cite></blockquote>)\n if (el.tagName === \"BLOCKQUOTE\" && el.querySelector(\":scope > cite\")) return \"pullquote\";\n if (el.tagName === \"TABLE\") return Array.from(el.querySelectorAll(\"td,th\")).every(plainCell) ? \"table\" : null;\n if (el.tagName === \"FIGURE\" && el.querySelector(\":scope > table, :scope > .bt-scroll > table\")) return \"table\";\n // a figure that is only an image (optionally linked, optionally captioned)\n if (el.tagName === \"FIGURE\") {\n const kids = Array.from(el.children);\n const media = kids.filter((k) => k.tagName !== \"FIGCAPTION\");\n const m = media[0];\n if (media.length === 1 && kids.length - media.length <= 1 && (m.tagName === \"IMG\" || (m.tagName === \"A\" && m.children.length === 1 && m.firstElementChild!.tagName === \"IMG\"))) return \"image\";\n }\n return null;\n}\n\nconst attrOf = (el: Element, name: string) => (el.hasAttribute(name) ? el.getAttribute(name)! : undefined);\nconst oneOf = <T extends string>(list: readonly T[], v: string | undefined): T | undefined => (v !== undefined && (list as readonly string[]).includes(v) ? (v as T) : undefined);\n\nexport function parseIsland(kind: IslandKind, el: HTMLElement): IslandModels[IslandKind] {\n switch (kind) {\n case \"image\": {\n const img = el.querySelector(\"img\");\n const a = img?.parentElement?.tagName === \"A\" ? img.parentElement : null;\n const cap = el.querySelector(\":scope > figcaption\");\n const frame = readImageFrame(img);\n const m: ImageModel = { src: frame.src };\n if (img?.hasAttribute(\"alt\")) m.alt = img.getAttribute(\"alt\")!;\n if (frame.crop) m.crop = frame.crop;\n if (frame.focal) m.focal = frame.focal;\n if (cap) m.caption = (cap.textContent ?? \"\").replace(/\\u200b/g, \"\");\n const align = oneOf(IMAGE_ALIGNS, attrOf(el, \"data-align\"));\n const size = oneOf(IMAGE_SIZES, attrOf(el, \"data-size\"));\n if (align) m.align = align;\n if (size) m.size = size;\n if (a) m.href = a.getAttribute(\"href\") ?? \"\";\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"table\":\n // production's own figure holds its <table> directly; V2's (pasted) wraps it in a scroll region\n if (el.matches(\"figure[data-rt=table]\")) return el.querySelector(\":scope > table\") ? parseStoredTable(el) : parseTableElement(el);\n return parseStoredTable(el.matches(\"table\") ? el : el.querySelector(\"table\")!);\n case \"pullquote\": {\n // V2 article.ts parseArticle(\"pullquote\"): a legacy pull quote IS the <blockquote> (no <figure> around it)\n const text = (n: Element | null) => (n?.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n const bq = el.matches(\"blockquote\") ? el : el.querySelector(\"blockquote\");\n const cap = el.querySelector(\"figcaption\");\n const nameEl = cap?.querySelector(\"[data-name]\") ?? el.querySelector(\"blockquote > cite, cite\");\n let role = text(cap?.querySelector(\"[data-role]\") ?? null);\n // legacy <cite>Name, role</cite>\n let name = text(nameEl);\n if (!cap && name.includes(\",\")) [name, role] = [name.slice(0, name.indexOf(\",\")).trim(), name.slice(name.indexOf(\",\") + 1).trim()];\n const quoteEl = bq?.cloneNode(true) as HTMLElement | undefined;\n quoteEl?.querySelectorAll(\"cite\").forEach((c) => c.remove());\n return { quote: text(quoteEl ?? null), name, role, link: bq?.getAttribute(\"cite\") ?? nameEl?.getAttribute(\"href\") ?? \"\" };\n }\n case \"takeaways\": {\n // V2 article.ts parseArticle(\"takeaways\"): an empty list still holds a line to type in\n const text = (n: Element | null) => (n?.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n const pts = Array.from(el.querySelectorAll(\"li\")).map((li) => text(li));\n return { title: text(el.querySelector(\"[data-title]\")), points: pts.length ? pts : [\"\"] };\n }\n case \"callout\": {\n const title = el.querySelector(\":scope > [data-title]\");\n const body = el.querySelector(\":scope > [data-body]\");\n const m: CalloutModel = {};\n const tone = attrOf(el, \"data-callout\");\n if (tone !== undefined) m.tone = tone;\n if (title) m.title = (title.textContent ?? \"\").replace(/\\u200b/g, \"\");\n if (body) m.body = parasToText(body);\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"toggle\": {\n const title = el.querySelector(\":scope > summary\");\n const body = el.querySelector(\":scope > [data-body]\");\n const m: ToggleModel = {};\n if (title) m.title = (title.textContent ?? \"\").replace(/\\u200b/g, \"\");\n if (body) m.body = parasToText(body);\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"video\": {\n const m: VideoModel = {};\n const url = attrOf(el, \"data-url\");\n const title = attrOf(el, \"data-title\");\n if (url !== undefined) m.url = url;\n if (title !== undefined) m.title = title;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"embed\": {\n const m: EmbedModel = {};\n const url = attrOf(el, \"data-url\");\n // production writes the title as aria-label (RT3); the kit's own markup as data-title too\n const title = attrOf(el, \"data-title\") ?? attrOf(el, \"aria-label\");\n const aspect = attrOf(el, \"data-aspect\");\n if (url !== undefined) m.url = url;\n if (title !== undefined) m.title = title;\n if (aspect !== undefined && EMBED_ASPECT_VALUES.includes(aspect)) m.aspect = aspect as EmbedModel[\"aspect\"];\n if (el.hasAttribute(\"aria-label\")) m.labelled = true;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"gallery\": {\n const m: GalleryIslandModel = { images: [] };\n const layout = attrOf(el, \"data-layout\");\n if (layout === \"grid\" || layout === \"carousel\") m.layout = layout;\n m.images = Array.from(el.querySelectorAll(\"li\")).map((li) => {\n const img = li.querySelector(\"img\");\n const caption = li.querySelector(\"figcaption\")?.textContent ?? undefined;\n const frame = readImageFrame(img);\n return {\n _key: rid(\"g\"),\n src: frame.src,\n ...(img ? { alt: img.getAttribute(\"alt\") ?? \"\" } : {}),\n ...(caption ? { caption } : {}),\n ...(frame.crop ? { crop: frame.crop } : {}),\n ...(frame.focal ? { focal: frame.focal } : {}),\n };\n });\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"toc\": {\n const m: TocIslandModel = {};\n const title = el.querySelector(\"[data-title]\")?.textContent?.trim();\n if (title) m.title = title;\n const depth = attrOf(el, \"data-depth\");\n if (depth === \"2\" || depth === \"3\") m.depth = depth;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"columns\": {\n const m: ColumnsIslandModel = { cols: Array.from(el.children).filter((c) => c.hasAttribute(\"data-col\")).map((c) => ({ id: rid(\"col\"), html: c.innerHTML })) };\n const gap = attrOf(el, \"data-gap\");\n if (gap === \"s\" || gap === \"m\" || gap === \"l\") m.gap = gap;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"author\": {\n const m: AuthorIslandModel = {};\n const author = attrOf(el, \"data-author\");\n if (author !== undefined) m.author = author;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"related\": {\n // production's placeholder carries the title as an attribute, a drawn list (and V2) as [data-title]\n const m: RelatedIslandModel = { posts: (attrOf(el, \"data-posts\") ?? \"\").split(\",\").map((x) => x.trim()).filter(Boolean) };\n const title = (attrOf(el, \"data-title\") ?? el.querySelector(\"[data-title]\")?.textContent ?? \"\").trim();\n if (title) m.title = title;\n const mode = attrOf(el, \"data-mode\");\n if (mode === \"topic\" || mode === \"newest\" || mode === \"manual\") m.mode = mode;\n else if (mode === \"auto\") m.mode = \"topic\"; // V2's Automatic\n const count = Number(attrOf(el, \"data-count\"));\n if (Number.isInteger(count) && count > 0) m.count = count;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"file\": {\n const m: FileModel = {};\n const url = attrOf(el, \"data-url\");\n const name = attrOf(el, \"data-name\");\n const size = attrOf(el, \"data-size\");\n if (url !== undefined) m.url = url;\n if (name !== undefined) m.name = name;\n if (size !== undefined && Number.isFinite(Number(size))) m.size = Number(size);\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"component\": {\n // V2 markup: data-ref is the library component, data-id this instance; a legacy one names only data-block\n const m: ComponentModel = { id: attrOf(el, \"data-id\") || rid(\"ci\") };\n const ref = attrOf(el, \"data-ref\") ?? attrOf(el, \"data-block\");\n const name = attrOf(el, \"data-name\");\n const overrides = attrOf(el, \"data-overrides\");\n if (ref !== undefined) m.ref = ref;\n if (name !== undefined) m.name = name;\n if (overrides !== undefined) m.overrides = overrides;\n const variant = attrOf(el, \"data-variant\");\n if (variant !== undefined) m.variant = variant;\n if (el.getAttribute(\"data-detached\") === \"true\") {\n m.detached = true;\n const props = attrOf(el, \"data-props\");\n const blocks = attrOf(el, \"data-blocks\");\n const at = attrOf(el, \"data-source-published-at\");\n if (props !== undefined) m.props = props;\n if (blocks !== undefined) m.blocks = blocks;\n if (at !== undefined) m.sourcePublishedAt = at;\n }\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n }\n}\n\nexport function createIsland<K extends IslandKind>(kind: K, model: IslandModels[K]): IslandEl {\n const el = document.createElement(\"div\") as IslandEl;\n el.setAttribute(\"data-rt-island\", kind);\n el.setAttribute(\"contenteditable\", \"false\");\n el.__rt = model;\n return el;\n}\n\n/** Static block HTML → islands (top level only). Keeps a writable line after a trailing island or rule. */\nexport function hydrate(root: HTMLElement) {\n for (const ch of Array.from(root.children)) {\n if (ch.hasAttribute(\"data-rt-island\")) continue;\n const k = detectKind(ch);\n if (!k) continue;\n ch.replaceWith(createIsland(k, parseIsland(k, ch as HTMLElement)));\n }\n // loose top-level inline content → a paragraph (a single-paragraph field stores its text inline, with no <p>)\n let run: Node[] = [];\n const flush = (before: Node | null) => {\n if (run.some((n) => (n.textContent ?? \"\").trim() || (n.nodeType === 1 && (n as Element).tagName !== \"BR\"))) {\n const p = document.createElement(\"p\");\n root.insertBefore(p, before);\n run.forEach((n) => p.append(n));\n } else run.forEach((n) => n.parentNode === root && n.nodeType === 3 && root.removeChild(n));\n run = [];\n };\n for (const n of Array.from(root.childNodes)) {\n const block = n.nodeType === 1 && (BLOCK_TAGS.has((n as Element).tagName) || (n as Element).hasAttribute(\"data-rt-island\"));\n if (block) flush(n);\n else if (n.nodeType === 1 || n.nodeType === 3) run.push(n);\n }\n flush(null);\n if (!root.firstElementChild) root.innerHTML = \"<p><br></p>\";\n const last = root.lastElementChild;\n if (last && (last.hasAttribute(\"data-rt-island\") || last.tagName === \"HR\")) {\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n root.append(p);\n }\n}\n\nconst BLOCK_TAGS = new Set([\"P\", \"H1\", \"H2\", \"H3\", \"H4\", \"H5\", \"H6\", \"BLOCKQUOTE\", \"PRE\", \"UL\", \"OL\", \"HR\", \"FIGURE\", \"TABLE\", \"DIV\", \"DETAILS\", \"SECTION\", \"ASIDE\", \"NAV\"]);\nconst isEmptyP = (el: Element) => el.tagName === \"P\" && (el.innerHTML === \"\" || el.innerHTML === \"<br>\");\n\n/** Live DOM → stored HTML. */\nexport function serialize(root: HTMLElement): string {\n const clone = root.cloneNode(true) as HTMLElement;\n const live = Array.from(root.children);\n Array.from(clone.children).forEach((c, i) => {\n if (!c.hasAttribute(\"data-rt-island\")) return;\n const l = live[i] as IslandEl;\n const kind = c.getAttribute(\"data-rt-island\") as IslandKind;\n const model = l.__rt;\n if (!model) return c.remove();\n const tpl = document.createElement(\"template\");\n tpl.innerHTML = renderStatic(kind, model);\n c.replaceWith(tpl.content);\n });\n clone.querySelectorAll(\"[data-hint]\").forEach((n) => n.removeAttribute(\"data-hint\"));\n // a task item's role and aria-checked are the editor's (checklist.tsx syncTaskA11y), never stored\n clone.querySelectorAll(\"ul[data-task] > li\").forEach((li) => (li.removeAttribute(\"role\"), li.removeAttribute(\"aria-checked\")));\n while (clone.children.length > 1 && clone.lastElementChild && isEmptyP(clone.lastElementChild)) clone.lastElementChild.remove();\n const html = clone.innerHTML.replace(//g, \"\");\n return html === \"<p><br></p>\" || html === \"<p></p>\" ? \"\" : html;\n}\n\n/** The HTML exactly as the editor would store it after opening `html` (load → hydrate → serialize), with no edit. */\nexport function editorRoundTrip(html: string): string {\n const el = document.createElement(\"div\");\n el.innerHTML = sanitize(html || \"\") || \"<p><br></p>\";\n hydrate(el);\n return serialize(el);\n}\n\n/** Strip scripts, event handlers and script URLs from HTML we did not author (paste, Markdown, loaded values). */\nexport function sanitize(html: string): string {\n if (!/[<&]/.test(html)) return html;\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(\"script,style,iframe,object,embed,link,meta,form,input,button,textarea,select,noscript\").forEach((n) => n.remove());\n doc.body.querySelectorAll(\"*\").forEach((el) => {\n for (const a of Array.from(el.attributes)) {\n const n = a.name.toLowerCase();\n if (n.startsWith(\"on\")) el.removeAttribute(a.name);\n else if ((n === \"href\" || n === \"src\" || n === \"xlink:href\") && /^\\s*(javascript|vbscript|data:text)/i.test(a.value)) el.removeAttribute(a.name);\n }\n });\n return doc.body.innerHTML;\n}\n\n/* ── Selection helpers ─────────────────────────────────────────────── */\nexport const TEXT_BLOCKS = new Set([\"P\", \"H1\", \"H2\", \"H3\", \"H4\", \"H5\", \"H6\", \"BLOCKQUOTE\", \"PRE\", \"LI\", \"DIV\"]);\n\nexport function topBlock(root: HTMLElement | null, node: Node | null): HTMLElement | null {\n if (!root) return null;\n let n: Node | null = node;\n while (n && n.parentNode !== root) n = n.parentNode;\n return n && n.nodeType === 1 ? (n as HTMLElement) : null;\n}\n\n/** Nearest text-ish block element around a node, inside root. */\nexport function closestBlock(root: HTMLElement, node: Node | null): HTMLElement | null {\n let n: Node | null = node;\n while (n && n !== root) {\n if (n.nodeType === 1 && TEXT_BLOCKS.has((n as HTMLElement).tagName) && (n as HTMLElement).closest(\"[data-rt-island]\") === null) return n as HTMLElement;\n n = n.parentNode;\n }\n return null;\n}\n\nexport function placeCaret(el: Node, atEnd = true) {\n const s = window.getSelection();\n if (!s) return;\n const r = document.createRange();\n r.selectNodeContents(el);\n r.collapse(!atEnd);\n s.removeAllRanges();\n s.addRange(r);\n}\n\nexport function textBeforeCaret(block: HTMLElement): string | null {\n const s = window.getSelection();\n if (!s || !s.rangeCount) return null;\n const r = s.getRangeAt(0);\n if (!block.contains(r.startContainer)) return null;\n const pre = document.createRange();\n pre.selectNodeContents(block);\n pre.setEnd(r.startContainer, r.startOffset);\n return pre.toString();\n}\n\nexport function editingHost(n: Node | null): HTMLElement | null {\n const el = n ? (n.nodeType === 1 ? (n as HTMLElement) : n.parentElement) : null;\n return el?.closest<HTMLElement>('[contenteditable=\"true\"],[contenteditable=\"plaintext-only\"]') ?? null;\n}\n\n/** A range's box. Browsers measure a collapsed caret as an empty rect, and some engines cannot measure ranges at all: then\n * the box of the element the range sits in. */\nexport function rangeRect(r: Range, fallback: Element | null): DOMRect {\n let rect: DOMRect | null = null;\n try {\n rect = r.getBoundingClientRect();\n } catch {\n rect = null;\n }\n if (rect && (rect.width || rect.height)) return rect;\n const host = r.startContainer.nodeType === 1 ? (r.startContainer as Element) : r.startContainer.parentElement;\n return (host ?? fallback ?? document.body).getBoundingClientRect();\n}\n\nexport const isEmptyHtml = (html: string) => !html.replace(/<(?!img|hr|figure|table|details|div data-rt)[^>]*>/g, \"\").replace(/ /g, \"\").trim();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,OAAO,MAAc,EAAE,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AACrG,IAAa,WAAW,MAAc,IAAI,CAAC,CA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AK;AACpG;;;AAIA,SAAgB,UAAU,GAAU,UAAmC;CACrE,IAAI,OAAuB;CAC3B,IAAI;EACF,OAAO,EAAE,sBAAsB;CACjC,QAAQ;EACN,OAAO;CACT;CACA,IAAI,SAAS,KAAK,SAAS,KAAK,SAAS,OAAO;CAEhD,SADa,EAAE,eAAe,aAAa,IAAK,EAAE,iBAA6B,EAAE,eAAe,kBAChF,YAAY,SAAS,KAAA,CAAM,sBAAsB;AACnE;AAEA,IAAa,eAAe,SAAiB,CAAC,KAAK,QAAQ,uDAAuD,EAAE,CAAC,CAAC,QAAQ,WAAW,EAAE,CAAC,CAAC,KAAK"}
|
|
1
|
+
{"version":3,"file":"dom.js","names":[],"sources":["../../../src/controls/rich-text/dom.ts"],"sourcesContent":["/**\n * RICH TEXT · DOM layer (V2 HEAD controls/rich-text/dom.ts). The field value is clean, semantic HTML; rich blocks are\n * \"islands\" while editing.\n *\n * Live DOM = the HTML, with every rich block swapped for a `div[data-rt-island=\"kind\"]` (contenteditable=false) that\n * React renders into through a portal. The island's model lives on the element (`el.__rt`).\n * Stored = `serialize()` swaps each island back for its static HTML (`renderStatic`). The static form is the markup\n * production's own renderer writes for the same block, so the host's ingest reads it back as that block.\n * Loading = `hydrate()` turns that markup back into islands, so a re-mount restores them.\n *\n * Only the blocks production stores are islands here. Each one's markup is what the host's codec renders the stored\n * block as and reads back (features/dock-v2/richTextCodec.ts); `data-extra` carries, opaque, whatever of the stored block\n * the editor does not edit, so nothing it holds is dropped by an edit elsewhere.\n * image `bcmsBlock` builtin:image: address, alt text, caption, alignment, size, link\n * (`<figure data-rt=\"image\" data-align data-size><a href><img src alt></a><figcaption>`)\n * table production's Portable Text table (rows of cells, a header row, header cells, and the V2 table's caption,\n * note, row groups and column groups), drawn with the kit's table editor (V2 TableBlock), stored as the markup\n * production's renderer writes (`<caption>`, `th[scope=colgroup data-group]`, a `<tbody data-key>` per row\n * group under a `th[scope=rowgroup]` row, `<figure data-rt=\"table\">…<p data-notes>` for the note; footnotes\n * fold into the note as `[1] …`, as production's ingest folds V2's). A cell's closing\n * footnote markers (`<sup data-footnote>`) ride the cell as written (`marks`). A table whose cells hold\n * other inline formatting the table value has no place for (a term, bold) is not an island: it stays\n * markup in the body, edited in place, so the formatting survives.\n * pullquote V2 article block (CPO D55), `<figure data-rt=\"pullquote\">` → a `pullQuote` block.\n * takeaways V2 article block (CPO D55), `<aside data-rt=\"takeaways\"><p data-title>…<ul><li>…` → a `keyTakeaways` block\n * {title?, points} (written in the text itself, V2 TakeawaysEditor).\n * callout `bcmsBlock` builtin:callout {tone, title, message}: `<div data-rt=\"callout\" data-callout><p data-title>…\n * <div data-body><p>…` (the message is plain text: paragraphs and line breaks)\n * toggle `bcmsBlock` builtin:toggle {title, body}: `<details data-rt=\"toggle\"><summary>…<div data-body><p>…`\n * video the `video` block {src, title}: `<div data-rt=\"video\" data-url data-title>`\n * embed V2's article Embed {url, title, aspect}: `<figure data-rt=\"embed\" data-url data-title data-aspect><a href>…`\n * (embed.tsx). Stored today as `bcmsBlock` builtin:video {url, title}, which keeps no aspect; the PT\n * `embed` block (plan RT3) does.\n * file the `file` block {src, name, size}: `<div data-rt=\"file\" data-url data-name data-size>`\n * component `bcmsBlock` \"component\" {componentId, overrides, variant} (CPO D28): `<div data-rt=\"component\" data-ref\n * data-id data-name data-overrides data-variant>` — a linked instance of a project component, shown as a card.\n * A separate copy (V2 instances.ts `detach`) adds {detached, props, blocks, sourcePublishedAt}:\n * `data-detached=\"true\" data-props data-blocks data-source-published-at`, and carries no overrides.\n * \"Show on site\" is {visible} (`data-visible`): false keeps the place in the body and off the published\n * page; absent reads as shown.\n * A key the stored block holds is an attribute or element that is present; a key it lacks is absent, so an untouched\n * block reads back exactly as stored.\n * V2's gallery, columns, footnotes, contents, related posts and author bio have no stored form in production and are\n * not offered.\n */\n\nimport { boolLabels, cellText, cellValue, emptyTable, formatNumber, isCellObject, isObjLike, normalizeTable, parseTableElement, tkey, toBool, toNumber, type TableCell, type TableColumn, type TableColumnType, type TableGroup, type TableLink, type TableRow, type TableValue } from \"../../schema/table\";\n\nexport const esc = (s: string) => s.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\");\nexport const escAttr = (s: string) => esc(s).replace(/\"/g, \""\");\nlet seq = 0;\nexport const rid = (p = \"r\") => `${p}${Date.now().toString(36)}${(seq++).toString(36)}`;\n\n/* ── Island models ─────────────────────────────────────────────────── */\nexport type ImageAlign = \"full\" | \"center\" | \"left\" | \"right\";\nexport type ImageSize = \"s\" | \"m\" | \"l\" | \"full\";\nexport const IMAGE_ALIGNS: readonly ImageAlign[] = [\"full\", \"center\", \"left\", \"right\"];\nexport const IMAGE_SIZES: readonly ImageSize[] = [\"s\", \"m\", \"l\", \"full\"];\n/** Every optional key is absent when the stored block lacks it (see the header). */\nexport interface ImageModel {\n src: string;\n /** absent only on a stored block that never had one (every new image has alt text, empty or not) */\n alt?: string;\n caption?: string;\n align?: ImageAlign;\n size?: ImageSize;\n href?: string;\n /** RT9: how much is cut from each edge, 0–1 of the source (image-url's crop) */\n crop?: ImageCrop;\n /** RT9: the subject, 0–1 of the source (image-url's focal) */\n focal?: { x: number; y: number };\n /** the stored block's other keys, opaque to the editor */\n extra?: string;\n}\n/** RT9: image-url's crop, each edge a 0–1 fraction of the source. */\nexport interface ImageCrop {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n/**\n * RT9: an image's framing as production writes it on the `<img>` (richtext richTextImageFrame): `data-src` the stored\n * url when the drawn one carries the crop, `data-crop` \"top,right,bottom,left\" and `data-focal` \"x,y\", each 0–1.\n */\nexport function readImageFrame(img: Element | null): { src: string; crop?: ImageCrop; focal?: { x: number; y: number } } {\n const src = img?.getAttribute(\"data-src\") ?? img?.getAttribute(\"src\") ?? \"\";\n const nums = (raw: string | null | undefined, n: number) => {\n const v = (raw ?? \"\").split(\",\").map((x) => Number(x));\n return raw && v.length === n && v.every((x) => Number.isFinite(x) && x >= 0 && x <= 1) ? v : null;\n };\n const c = nums(img?.getAttribute(\"data-crop\"), 4);\n const f = nums(img?.getAttribute(\"data-focal\"), 2);\n return {\n src,\n ...(c && c[0] + c[2] < 1 && c[1] + c[3] < 1 ? { crop: { top: c[0], right: c[1], bottom: c[2], left: c[3] } } : {}),\n ...(f ? { focal: { x: f[0], y: f[1] } } : {}),\n };\n}\nconst frameAttrs = (crop?: ImageCrop, focal?: { x: number; y: number }) =>\n `${crop ? ` data-crop=\"${[crop.top, crop.right, crop.bottom, crop.left].join(\",\")}\"` : \"\"}${focal ? ` data-focal=\"${focal.x},${focal.y}\"` : \"\"}`;\n/** A table island IS the kit's table value (V2 TableModel); only what production's table keeps is stored (see above). */\nexport type TableModel = TableValue;\n/** V2 PullQuoteModel (article.ts). */\nexport interface PullQuoteModel {\n quote: string;\n name: string;\n role: string;\n link: string;\n}\n/** V2 TakeawaysModel (article.ts): the title over the list and one plain string per point. */\nexport interface TakeawaysModel {\n title: string;\n points: string[];\n}\nexport type CalloutTone = \"info\" | \"tip\" | \"warning\";\nexport const CALLOUT_TONES: readonly CalloutTone[] = [\"info\", \"tip\", \"warning\"];\nexport interface CalloutModel {\n /** the stored tone, as written (the editor offers info, tip and warning) */\n tone?: string;\n title?: string;\n /** plain text: paragraphs split by a blank line, line breaks kept */\n body?: string;\n extra?: string;\n}\nexport interface ToggleModel {\n title?: string;\n body?: string;\n extra?: string;\n}\nexport interface VideoModel {\n url?: string;\n title?: string;\n extra?: string;\n}\n/** V2 EmbedModel (article.ts); `aspect` absent draws 16:9 (embed.tsx). */\nexport interface EmbedModel {\n url?: string;\n title?: string;\n aspect?: \"16:9\" | \"4:3\" | \"1:1\" | \"9:16\";\n /** the title is also the figure's aria-label, as production writes it (RT3) and a new embed does; kept as found */\n labelled?: true;\n extra?: string;\n}\nconst EMBED_ASPECT_VALUES: readonly string[] = [\"16:9\", \"4:3\", \"1:1\", \"9:16\"];\n/* V2 article.ts embed providers: detected from the link, for the editor's placeholder (nothing third-party loads in it) */\nexport type EmbedProvider = \"youtube\" | \"vimeo\" | \"x\" | \"codepen\" | \"figma\" | \"maps\" | \"spotify\" | \"podcast\" | \"audio\" | \"link\";\nexport interface EmbedInfo {\n provider: EmbedProvider;\n label: string;\n /** frame = a sized player · post = a social post card · audio = a slim player · link = a link card */\n shape: \"frame\" | \"post\" | \"audio\" | \"link\";\n host: string;\n}\nconst hostOf = (url: string) => {\n try {\n return new URL(url).hostname.replace(/^www\\./, \"\");\n } catch {\n return \"\";\n }\n};\nexport function detectEmbed(url: string): EmbedInfo {\n const u = url.trim();\n const host = hostOf(u);\n const is = (re: RegExp) => re.test(u);\n if (is(/(?:youtube\\.com\\/(?:watch\\?|embed\\/|shorts\\/|live\\/)|youtu\\.be\\/)/i)) return { provider: \"youtube\", label: \"YouTube\", shape: \"frame\", host };\n if (is(/vimeo\\.com\\/(?:video\\/)?\\d+/i)) return { provider: \"vimeo\", label: \"Vimeo\", shape: \"frame\", host };\n if (is(/(?:twitter|x)\\.com\\/[^/]+\\/status\\/\\d+/i)) return { provider: \"x\", label: \"X post\", shape: \"post\", host };\n if (is(/codepen\\.io\\/[^/]+\\/(?:pen|embed)\\//i)) return { provider: \"codepen\", label: \"CodePen\", shape: \"frame\", host };\n if (is(/figma\\.com\\/(?:file|design|proto|board)\\//i)) return { provider: \"figma\", label: \"Figma\", shape: \"frame\", host };\n if (is(/(?:google\\.[a-z.]+\\/maps|maps\\.app\\.goo\\.gl|goo\\.gl\\/maps)/i)) return { provider: \"maps\", label: \"Google Maps\", shape: \"frame\", host };\n if (is(/open\\.spotify\\.com\\/(?:episode|track|show|playlist|album)\\//i)) return { provider: \"spotify\", label: \"Spotify\", shape: \"audio\", host };\n if (is(/podcasts\\.apple\\.com\\//i)) return { provider: \"podcast\", label: \"Apple Podcasts\", shape: \"audio\", host };\n if (is(/\\.(?:mp3|m4a|wav|ogg|aac)(?:\\?|$)/i)) return { provider: \"audio\", label: \"Audio\", shape: \"audio\", host };\n return { provider: \"link\", label: host || \"Link\", shape: \"link\", host };\n}\n/** V2's article Gallery (plan RT4): `<figure data-rt=\"gallery\" data-layout><ul><li><figure><img src alt><figcaption>`. */\nexport interface GalleryIslandModel {\n layout?: \"grid\" | \"carousel\";\n /** `_key` is the editor's own (rows keep their identity while edited); src, alt and caption are what is stored */\n images: { _key: string; src: string; alt?: string; caption?: string; crop?: ImageCrop; focal?: { x: number; y: number } }[];\n extra?: string;\n}\n/** V2's article Table of contents (plan RT5): `<nav data-rt=\"toc\" data-depth><p data-title>`; the list is derived. */\nexport interface TocIslandModel {\n title?: string;\n depth?: \"2\" | \"3\";\n extra?: string;\n}\n/** V2's Columns (plan RT7): `<div data-rt=\"columns\" data-gap data-cols><div data-col=\"true\">…</div></div>`, text only. */\nexport interface ColumnsIslandModel {\n gap?: \"s\" | \"m\" | \"l\";\n /** each column's HTML (paragraphs and marks); `id` is the editor's own */\n cols: { id: string; html: string }[];\n extra?: string;\n}\n/** V2's Author bio (plan RT8): `<aside data-rt=\"author\" data-author>`; name, avatar and bio are resolved, never stored. */\nexport interface AuthorIslandModel {\n author?: string;\n extra?: string;\n}\n/** V2's Related posts (plan RT8): `<aside data-rt=\"related\" data-mode data-count data-posts>`; the list is resolved. */\nexport interface RelatedIslandModel {\n title?: string;\n mode?: \"topic\" | \"newest\" | \"manual\";\n count?: number;\n posts: string[];\n extra?: string;\n}\nexport interface FileModel {\n url?: string;\n name?: string;\n size?: number;\n extra?: string;\n}\n/** A linked instance of a project component (CPO D28): its library id, its own id, its name and its overrides. */\nexport interface ComponentModel {\n /** the component it links to (`fields.componentId`) */\n ref?: string;\n /** this instance (the block's key) */\n id: string;\n /** the component's name when it was placed (`schemaLabel`) */\n name?: string;\n /** the fields this instance overrides, as stored JSON */\n overrides?: string;\n /** the layout this instance draws the component in (V2's per-instance variant, `fields.variant`) */\n variant?: string;\n /** V2 `detached`: a separate copy that no longer follows the component (`fields.detached`) */\n detached?: boolean;\n /** a separate copy's values as readers see them, as stored JSON (V2 `props`, `fields.props`) */\n props?: string;\n /** a separate copy's frozen block tree, as stored JSON (`fields.blocks`); the editor never edits it */\n blocks?: string;\n /** the version of the component the copy was taken from (`fields.sourcePublishedAt`) */\n sourcePublishedAt?: string;\n /** \"Show on site\" (`fields.visible`): false keeps this place in the body and leaves it off the published page; absent reads as shown */\n visible?: boolean;\n extra?: string;\n}\nexport interface IslandModels {\n image: ImageModel;\n table: TableModel;\n pullquote: PullQuoteModel;\n takeaways: TakeawaysModel;\n callout: CalloutModel;\n toggle: ToggleModel;\n video: VideoModel;\n embed: EmbedModel;\n file: FileModel;\n component: ComponentModel;\n gallery: GalleryIslandModel;\n toc: TocIslandModel;\n columns: ColumnsIslandModel;\n author: AuthorIslandModel;\n related: RelatedIslandModel;\n}\nexport type IslandKind = keyof IslandModels;\nexport const ISLAND_KINDS: IslandKind[] = [\"image\", \"table\", \"pullquote\", \"takeaways\", \"callout\", \"toggle\", \"video\", \"embed\", \"file\", \"component\", \"gallery\", \"toc\", \"columns\", \"author\", \"related\"];\nexport type IslandEl = HTMLElement & {\n __rt?: IslandModels[IslandKind];\n __rtFocus?: boolean;\n /** the mounted island's own setter: restores a model from the editor's history (undo / redo) */\n __rtSet?: (m: IslandModels[IslandKind]) => void;\n};\n\nexport function defaultModel<K extends IslandKind>(kind: K, extra?: Partial<IslandModels[K]>): IslandModels[K] {\n const base: { [P in IslandKind]: () => IslandModels[P] } = {\n image: () => ({ src: \"\", alt: \"\" }),\n table: () => emptyTable(3, 2),\n pullquote: () => ({ quote: \"\", name: \"\", role: \"\", link: \"\" }),\n takeaways: () => ({ title: \"Key takeaways\", points: [\"\"] }),\n callout: () => ({ tone: \"info\", title: \"\", body: \"\" }),\n toggle: () => ({ title: \"\", body: \"\" }),\n video: () => ({ url: \"\" }),\n embed: () => ({ url: \"\", title: \"\", labelled: true }),\n file: () => ({ url: \"\", name: \"\" }),\n // a fresh insert is on the site (\"Show on site\", `visible: true`), the shape the dashboard's classic insert writes\n component: () => ({ id: rid(\"ci\"), overrides: \"{}\", visible: true }),\n // V2 article.ts ARTICLE_DEFAULTS\n gallery: () => ({ layout: \"grid\", images: [] }),\n toc: () => ({ title: \"In this article\", depth: \"3\" }),\n columns: () => ({ gap: \"m\", cols: [{ id: rid(\"col\"), html: \"\" }, { id: rid(\"col\"), html: \"\" }] }),\n author: () => ({ author: \"\" }),\n related: () => ({ title: \"Related stories\", mode: \"topic\", count: 3, posts: [] }),\n };\n if (kind === \"table\") return { ...base.table(), ...(extra ?? {}), id: tkey(\"tbl\") } as IslandModels[K];\n return { ...base[kind](), ...(extra ?? {}) } as IslandModels[K];\n}\n\n/** Deep copy (Duplicate). A copied table or component instance gets its own id. */\nexport const cloneModel = <K extends IslandKind>(kind: K, m: IslandModels[K]): IslandModels[K] => {\n const c = JSON.parse(JSON.stringify(m)) as IslandModels[K];\n if (kind === \"table\") (c as TableModel).id = tkey(\"tbl\");\n if (kind === \"component\") (c as ComponentModel).id = rid(\"ci\");\n return c;\n};\n\n/* ── plain text ⇄ paragraphs (a callout's message, a toggle's body) ── */\n/** \"a\\nb\\n\\nc\" → `<p>a<br>b</p><p>c</p>`. Split on exactly one blank line, so any text reads back as written. */\nexport const textToParas = (s: string) =>\n s\n .split(\"\\n\\n\")\n .map((p) => `<p>${esc(p).replace(/\\n/g, \"<br>\")}</p>`)\n .join(\"\");\n/** The inverse of textToParas: each paragraph's text, its line breaks kept. */\nexport function parasToText(el: Element): string {\n const ps = Array.from(el.children).filter((c) => c.tagName === \"P\");\n const text = (n: Element) => {\n const c = n.cloneNode(true) as Element;\n c.querySelectorAll(\"br\").forEach((br) => br.replaceWith(\"\\n\"));\n return (c.textContent ?? \"\").replace(/\\u200b/g, \"\");\n };\n return ps.length ? ps.map(text).join(\"\\n\\n\") : text(el);\n}\n\n/* ── Static HTML (stored) ──────────────────────────────────────────── */\n/** An image is `<figure><img src alt></figure>`: production's renderer writes exactly this, and its ingest reads it. */\nconst xAttr = (extra?: string) => (extra ? ` data-extra=\"${escAttr(extra)}\"` : \"\");\nconst attr = (name: string, v: string | number | undefined) => (v === undefined ? \"\" : ` ${name}=\"${escAttr(String(v))}\"`);\n\nexport function renderStatic(kind: IslandKind, model: unknown): string {\n switch (kind) {\n case \"image\": {\n const m = model as ImageModel;\n const img = m.src ? `<img src=\"${escAttr(m.src)}\"${attr(\"alt\", m.alt)}${frameAttrs(m.crop, m.focal)}>` : \"\";\n const linked = img && m.href !== undefined ? `<a href=\"${escAttr(m.href)}\">${img}</a>` : img;\n const cap = m.caption !== undefined ? `<figcaption>${esc(m.caption)}</figcaption>` : \"\";\n return `<figure data-rt=\"image\"${attr(\"data-align\", m.align)}${attr(\"data-size\", m.size)}${xAttr(m.extra)}>${linked}${cap}</figure>`;\n }\n case \"table\":\n return renderStoredTable(model as TableModel);\n case \"pullquote\": {\n // V2 article.ts renderArticle(\"pullquote\")\n const m = model as PullQuoteModel;\n const name = m.name ? (m.link ? `<a href=\"${escAttr(m.link)}\" data-name>${esc(m.name)}</a>` : `<span data-name>${esc(m.name)}</span>`) : \"\";\n const role = m.role ? `<span data-role>${esc(m.role)}</span>` : \"\";\n const cap = name || role ? `<figcaption>${name}${name && role ? \", \" : \"\"}${role}</figcaption>` : \"\";\n return `<figure data-rt=\"pullquote\"><blockquote${m.link ? ` cite=\"${escAttr(m.link)}\"` : \"\"}><p>${esc(m.quote)}</p></blockquote>${cap}</figure>`;\n }\n case \"takeaways\": {\n // V2 article.ts renderArticle(\"takeaways\")\n const m = model as TakeawaysModel;\n const pts = m.points.map((p) => p.trim()).filter(Boolean);\n return `<aside data-rt=\"takeaways\">${m.title ? `<p data-title>${esc(m.title)}</p>` : \"\"}<ul>${pts.map((p) => `<li>${esc(p)}</li>`).join(\"\")}</ul></aside>`;\n }\n case \"callout\": {\n const m = model as CalloutModel;\n const title = m.title !== undefined ? `<p data-title=\"true\">${esc(m.title)}</p>` : \"\";\n const body = m.body !== undefined ? `<div data-body=\"true\">${textToParas(m.body)}</div>` : \"\";\n return `<div data-rt=\"callout\"${attr(\"data-callout\", m.tone)}${xAttr(m.extra)}>${title}${body}</div>`;\n }\n case \"toggle\": {\n const m = model as ToggleModel;\n const title = m.title !== undefined ? `<summary>${esc(m.title)}</summary>` : \"\";\n const body = m.body !== undefined ? `<div data-body=\"true\">${textToParas(m.body)}</div>` : \"\";\n return `<details data-rt=\"toggle\"${xAttr(m.extra)}>${title}${body}</details>`;\n }\n case \"video\": {\n const m = model as VideoModel;\n return `<div data-rt=\"video\"${attr(\"data-url\", m.url)}${attr(\"data-title\", m.title)}${xAttr(m.extra)}>${m.url ? `<a href=\"${escAttr(m.url)}\">${esc(m.title || m.url)}</a>` : \"\"}</div>`;\n }\n case \"embed\": {\n // V2 article.ts renderArticle(\"embed\"), with the stored block's keys (no provider or shape: see the header)\n const m = model as EmbedModel;\n // aria-label carries the title as production writes it (its ingest reads it before the link's words)\n return `<figure data-rt=\"embed\"${attr(\"data-url\", m.url)}${attr(\"data-title\", m.title)}${m.labelled ? attr(\"aria-label\", m.title ?? \"\") : \"\"}${attr(\"data-aspect\", m.aspect)}${xAttr(m.extra)}>${m.url ? `<a href=\"${escAttr(m.url)}\">${esc(m.title || m.url)}</a>` : \"\"}</figure>`;\n }\n case \"gallery\": {\n // V2 article.ts renderArticle(\"gallery\"); an image not yet chosen is a <li> with no <img> (V2 reads it so)\n const m = model as GalleryIslandModel;\n const items = m.images\n .map((x) => `<li><figure>${x.src ? `<img src=\"${escAttr(x.src)}\" alt=\"${escAttr(x.alt ?? \"\")}\"${frameAttrs(x.crop, x.focal)}>` : \"\"}${x.caption ? `<figcaption>${esc(x.caption)}</figcaption>` : \"\"}</figure></li>`)\n .join(\"\");\n return `<figure data-rt=\"gallery\"${attr(\"data-layout\", m.layout)}${xAttr(m.extra)}><ul>${items}</ul></figure>`;\n }\n case \"toc\": {\n // V2 article.ts renderArticle(\"toc\"): the list is the body's outline, derived where it is drawn, so none is stored\n const m = model as TocIslandModel;\n const title = (m.title ?? \"\").trim();\n return `<nav data-rt=\"toc\"${attr(\"data-depth\", m.depth)} aria-label=\"${escAttr(title || \"Table of contents\")}\"${xAttr(m.extra)}>${title ? `<p data-title>${esc(title)}</p>` : \"\"}<ol></ol></nav>`;\n }\n case \"columns\": {\n // V2 dom.ts renderStatic(\"columns\")\n const m = model as ColumnsIslandModel;\n return `<div data-rt=\"columns\"${attr(\"data-gap\", m.gap)} data-cols=\"${m.cols.length}\"${xAttr(m.extra)}>${m.cols.map((c) => `<div data-col=\"true\">${c.html}</div>`).join(\"\")}</div>`;\n }\n case \"author\": {\n // V2 article.ts renderArticle(\"author\") without the resolved entry: the reference is what is stored\n const m = model as AuthorIslandModel;\n return `<aside data-rt=\"author\"${attr(\"data-author\", m.author)}${xAttr(m.extra)}></aside>`;\n }\n case \"related\": {\n // V2 article.ts renderArticle(\"related\") without the resolved list: title, mode, count and picks are stored\n const m = model as RelatedIslandModel;\n return `<aside data-rt=\"related\"${attr(\"data-mode\", m.mode)}${attr(\"data-count\", m.count)} data-posts=\"${escAttr(m.posts.join(\",\"))}\"${xAttr(m.extra)}>${m.title ? `<p data-title>${esc(m.title)}</p>` : \"\"}</aside>`;\n }\n case \"file\": {\n const m = model as FileModel;\n const link = m.url && m.name ? `<a href=\"${escAttr(m.url)}\" download>${esc(m.name)}</a>` : \"\";\n return `<div data-rt=\"file\"${attr(\"data-url\", m.url)}${attr(\"data-name\", m.name)}${attr(\"data-size\", m.size)}${xAttr(m.extra)}>${link}</div>`;\n }\n case \"component\": {\n const m = model as ComponentModel;\n const label = m.name || \"Component\";\n const copy = m.detached ? ` data-detached=\"true\"${attr(\"data-props\", m.props)}${attr(\"data-blocks\", m.blocks)}${attr(\"data-source-published-at\", m.sourcePublishedAt)}` : \"\";\n return `<div data-rt=\"component\"${attr(\"data-ref\", m.ref)} data-id=\"${escAttr(m.id)}\"${attr(\"data-name\", m.name)}${attr(\"data-overrides\", m.overrides)}${attr(\"data-variant\", m.variant)}${m.visible === undefined ? \"\" : ` data-visible=\"${m.visible}\"`}${copy}${xAttr(m.extra)}>⧉ ${esc(label)} · ${m.detached ? \"detached copy\" : \"component\"}</div>`;\n }\n }\n}\n\n/* The V2 table's group rows, read as production's ingest reads them (@bettercms-ai/richtext ingest.ts). */\nconst words = (el: Element | null | undefined) => (el?.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\nconst scopeIs = (c: Element, scope: string) => c.tagName === \"TH\" && (c.getAttribute(\"scope\") ?? \"\").toLowerCase() === scope;\n/** In `<thead>`: a `th[scope=colgroup]`, every other cell an empty `<td>`. A site's own two-row header stays rows. */\nconst isColumnGroupRow = (tr: HTMLTableRowElement) =>\n tr.parentElement?.tagName === \"THEAD\" &&\n Array.from(tr.cells).some((c) => scopeIs(c, \"colgroup\")) &&\n Array.from(tr.cells).every((c) => scopeIs(c, \"colgroup\") || (c.tagName === \"TD\" && !words(c)));\n/**\n * One `th[scope=rowgroup]` and nothing else, OPENING its own `<tbody>` with a body row after it (what production and\n * V2 write). A site's own `scope=rowgroup` row anywhere else stays a row, as production's ingest keeps it.\n */\nconst isRowGroupRow = (tr: HTMLTableRowElement) => {\n const body = tr.parentElement;\n if (tr.cells.length !== 1 || !scopeIs(tr.cells[0], \"rowgroup\") || body?.tagName !== \"TBODY\") return false;\n const rows = Array.from(body.children).filter((r) => r.tagName === \"TR\");\n return rows[0] === tr && rows.length > 1;\n};\nconst KEY = /^[A-Za-z0-9-]{1,32}$/;\n\n/* ── Typed columns and cells (V2 schema/table.ts; production's Portable Text table: a first-row cell's `column`, a row's and a\n * cell's `type`, a cell's `value`, the package's typedCellView) ── */\n/** The column types a rich-text table stores: V2's island offers these (table-editor.tsx:80-86 TYPE_UI, the non-dev ones). */\nexport const STORED_COLUMN_TYPES: readonly TableColumnType[] = [\"text\", \"number\", \"money\", \"boolean\", \"rating\", \"link\"];\nconst storedType = (v: unknown): TableColumnType | undefined => (STORED_COLUMN_TYPES as readonly unknown[]).includes(v) ? (v as TableColumnType) : undefined;\n/** A column's type and settings as stored (V2 TableColumn's keys). */\nexport type ColumnSettings = Partial<Pick<TableColumn, \"type\" | \"description\" | \"unit\" | \"currency\" | \"decimals\" | \"align\" | \"trueLabel\" | \"falseLabel\" | \"max\">>;\n/** The settings a kit column stores: none for a plain text or link column, else its type and every setting it has. */\nexport function columnSettings(c: TableColumn): ColumnSettings | undefined {\n const s: ColumnSettings = {\n ...(c.description ? { description: c.description } : {}),\n ...(c.unit ? { unit: c.unit } : {}),\n ...(c.currency ? { currency: c.currency } : {}),\n ...(c.decimals != null ? { decimals: c.decimals } : {}),\n ...(c.align ? { align: c.align } : {}),\n ...(c.trueLabel ? { trueLabel: c.trueLabel } : {}),\n ...(c.falseLabel ? { falseLabel: c.falseLabel } : {}),\n ...(c.max != null ? { max: c.max } : {}),\n };\n const type = storedType(c.type) ?? \"text\";\n return type === \"text\" || type === \"link\" ? (Object.keys(s).length ? { type, ...s } : undefined) : { type, ...s };\n}\n/** A `<col>`'s attributes, V2 renderTableHtml's order (schema/table.ts:511-526): the column's settings, data-sortable among them. */\nexport function colAttrs(c: ColumnSettings | undefined, sortable: boolean): string {\n return [\n c ? ` data-type=\"${c.type ?? \"text\"}\"` : \"\",\n c?.unit ? ` data-unit=\"${escAttr(c.unit)}\"` : \"\",\n c?.currency ? ` data-currency=\"${escAttr(c.currency)}\"` : \"\",\n c?.decimals != null ? ` data-decimals=\"${c.decimals}\"` : \"\",\n c?.align ? ` data-align=\"${c.align}\"` : \"\",\n sortable ? ' data-sortable=\"true\"' : \"\",\n c?.trueLabel ? ` data-true=\"${escAttr(c.trueLabel)}\"` : \"\",\n c?.falseLabel ? ` data-false=\"${escAttr(c.falseLabel)}\"` : \"\",\n c?.max != null ? ` data-max=\"${c.max}\"` : \"\",\n c?.description ? ` data-description=\"${escAttr(c.description)}\"` : \"\",\n ].join(\"\");\n}\n/** A `<col data-type …>` read back, as V2 parseTableElement reads it; undefined without a data-type. */\nexport function colSettingsOf(col: Element): ColumnSettings | undefined {\n const d = (n: string) => col.getAttribute(`data-${n}`) ?? undefined;\n const type = storedType(d(\"type\"));\n if (!type) return undefined;\n const int = (n: string, lo: number, hi: number) => {\n const v = Number(d(n));\n return d(n) !== undefined && Number.isInteger(v) && v >= lo && v <= hi ? v : undefined;\n };\n const align = d(\"align\");\n return {\n type,\n ...(d(\"unit\") ? { unit: d(\"unit\") } : {}),\n ...(d(\"currency\") && /^[A-Z]{3}$/.test(d(\"currency\")!) ? { currency: d(\"currency\") } : {}),\n ...(int(\"decimals\", 0, 10) !== undefined ? { decimals: int(\"decimals\", 0, 10) } : {}),\n ...(align === \"start\" || align === \"center\" || align === \"end\" ? { align } : {}),\n ...(d(\"true\") ? { trueLabel: d(\"true\") } : {}),\n ...(d(\"false\") ? { falseLabel: d(\"false\") } : {}),\n ...(int(\"max\", 1, 10) !== undefined ? { max: int(\"max\", 1, 10) } : {}),\n ...(d(\"description\") ? { description: d(\"description\") } : {}),\n };\n}\nconst NUMERIC = new Set<TableColumnType>([\"number\", \"money\", \"rating\"]);\n/** V2 alignOf (schema/table.ts:365). */\nconst alignOf = (c: ColumnSettings | undefined, t: TableColumnType) => c?.align ?? (NUMERIC.has(t) ? \"end\" : \"start\");\nexport const isValueType = (t: TableColumnType) => t === \"boolean\" || NUMERIC.has(t);\nconst asColumn = (c: ColumnSettings | undefined): TableColumn => ({ _key: \"\", label: \"\", ...c, type: c?.type ?? \"text\" });\n/** V2 cellText for a typed cell: the words it says (what a stored typed cell's blocks hold). */\nexport const typedWords = (c: ColumnSettings | undefined, type: TableColumnType, value: unknown): string =>\n value == null || value === \"\" ? \"\" : cellText(asColumn(c), undefined, { value, type } as TableCell);\n/**\n * What one cell of a typed table draws, as production's renderer writes it (the package's typedCellView, V2 cellHtml\n * schema/table.ts:369-437 and the column header at :564): `lead` attributes before data-label / data-highlight, `tail` after,\n * and the markup when the cell is empty or of a value type (undefined: the cell draws its own text or link).\n */\nexport function typedCellView(column: ColumnSettings | undefined, rowType: TableColumnType | undefined, cellType: TableColumnType | undefined, value: unknown, header: boolean, inHead: boolean): { lead: string; tail: string; inner?: string } {\n if (inHead) {\n const a = alignOf(column, column?.type ?? \"text\");\n return { lead: a !== \"start\" ? ` data-align=\"${a}\"` : \"\", tail: column?.description ? ` title=\"${escAttr(column.description)}\"` : \"\" };\n }\n const type = cellType ?? rowType ?? column?.type ?? \"text\";\n const words = typeof value === \"string\" ? value.replace(/\\s+/g, \" \").trim() : value;\n let tail = cellType ? ` data-type=\"${cellType}\"` : \"\";\n let inner: string | undefined;\n if (words == null || words === \"\") {\n inner = header ? \"\" : '<span aria-hidden=\"true\" class=\"bt-dash\">—</span><span class=\"bt-sr\">No value</span>';\n tail += ' data-empty=\"\"';\n } else if (type === \"boolean\") {\n const b = toBool(words);\n if (b == null) inner = esc(String(words));\n else {\n const { yes, no } = boolLabels(asColumn(column));\n inner = `<span aria-hidden=\"true\" class=\"bt-bool\" data-bool=\"${b}\">${b ? \"✓\" : \"–\"}</span><span class=\"bt-sr\">${esc(b ? yes : no)}</span>`;\n tail += ` data-value=\"${b}\"`;\n }\n } else if (type === \"rating\") {\n const n = toNumber(words);\n if (n == null) inner = esc(String(words));\n else {\n inner = `<span aria-hidden=\"true\" class=\"bt-star\">★</span> ${esc(formatNumber(n, 1).replace(/\\.0$/, \"\"))}<span class=\"bt-dim\"> / ${column?.max ?? 5}</span>`;\n tail += ` data-value=\"${n}\"`;\n }\n } else if (type === \"number\" || type === \"money\") {\n const n = toNumber(words);\n inner = esc(typedWords(column, type, words));\n if (n != null) tail += ` data-value=\"${n}\"`;\n }\n const a = alignOf(column, type);\n if (a !== \"start\") tail += ` data-align=\"${a}\"`;\n return { lead: \"\", tail, ...(inner === undefined ? {} : { inner }) };\n}\n/** A typed cell read back (V2 readCell): data-empty is no value; data-value a number or true / false for a value type. */\nexport function typedValueOf(cell: Element, type: TableColumnType): number | boolean | \"\" | undefined {\n if (cell.hasAttribute(\"data-empty\")) return \"\";\n const raw = cell.getAttribute(\"data-value\");\n if (raw === null || !isValueType(type)) return undefined;\n if (type === \"boolean\") return raw === \"true\";\n return raw.trim() !== \"\" && Number.isFinite(Number(raw)) ? Number(raw) : undefined;\n}\nexport const typeAttrOf = (el: Element): TableColumnType | undefined => storedType(el.getAttribute(\"data-type\"));\n\n/**\n * Production's table markup → the table value, cell for cell (renderStoredTable's inverse): the plain `<table>`, or\n * the `<figure data-rt=\"table\">` around one with its note. The V2 reader (parseTableElement) is not used here: it reads\n * a one-column row as a row-group heading and a caption-less grid by guesses that a stored table never meant.\n */\nexport function parseStoredTable(src: Element): TableModel {\n const fig = src.tagName === \"FIGURE\" ? src : null;\n const table = fig ? fig.querySelector(\":scope > table\")! : src;\n const t = emptyTable(0, 0);\n const trs = Array.from(table.querySelectorAll<HTMLTableRowElement>(\":scope > thead > tr, :scope > tbody > tr, :scope > tfoot > tr, :scope > tr\"));\n const groupRow = trs.find(isColumnGroupRow);\n const grid = trs.filter((tr) => tr !== groupRow && !isRowGroupRow(tr));\n const head = grid.filter((tr) => tr.parentElement?.tagName === \"THEAD\");\n const body = grid.filter((tr) => tr.parentElement?.tagName !== \"THEAD\");\n const width = Math.max(1, ...grid.map((tr) => tr.cells.length));\n const headCells = head.length ? Array.from(head[head.length - 1].cells) : [];\n t.headerRow = head.length > 0;\n t.headerColumn = body.length > 0 && body.every((tr) => tr.cells[0]?.tagName === \"TH\");\n t.caption = words(table.querySelector(\":scope > caption\"));\n // \"Visitors can search rows\": production's figure carries data-filter (V2 renderTableHtml)\n if (fig?.getAttribute(\"data-filter\") === \"true\") t.filterable = true;\n // \"On phones\" / \"Keep column names in view\": the figure's data-responsive (stack, cards) / data-sticky, as V2 reads them\n const resp = fig?.getAttribute(\"data-responsive\");\n if (resp === \"stack\" || resp === \"cards\") t.design = { ...t.design, responsive: resp };\n if (fig?.getAttribute(\"data-sticky\") === \"true\") t.design = { ...t.design, sticky: true };\n // \"Help search engines read this as\": the figure's data-jsonld (+ axis, price row), as V2 parseTableElement reads it\n const ld = fig?.getAttribute(\"data-jsonld\");\n if (ld === \"ItemList\" || ld === \"Dataset\" || ld === \"Offers\") {\n const axis = fig?.getAttribute(\"data-jsonld-axis\");\n const price = fig?.getAttribute(\"data-jsonld-price\");\n t.jsonLd = { type: ld, ...(axis === \"rows\" || axis === \"columns\" ? { axis } : {}), ...(price ? { priceRow: price } : {}) };\n }\n // \"Visitors can sort columns\": the column's <col data-sortable=\"true\">; a <colgroup> without <col>s spans its `span`\n const sortable = new Set<number>();\n // A typed column's <col data-type …> (V2 renderTableHtml): its type and settings\n const settings: (ColumnSettings | undefined)[] = [];\n let colAt = 0;\n for (const g of Array.from(table.querySelectorAll(\":scope > colgroup\"))) {\n const list = Array.from(g.querySelectorAll(\":scope > col\"));\n if (!list.length) colAt += Math.max(1, Number(g.getAttribute(\"span\")) || 1);\n for (const col of list) {\n const w = Math.max(1, Number(col.getAttribute(\"span\")) || 1);\n if (col.getAttribute(\"data-sortable\") === \"true\") for (let i = 0; i < w; i++) sortable.add(colAt + i);\n for (let i = 0; i < w; i++) settings[colAt + i] = colSettingsOf(col);\n colAt += w;\n }\n }\n // \"Highlight this column\": production stamps `data-highlight` on every cell of the column (its first row names it)\n t.columns = Array.from({ length: width }, (_, i) => ({ _key: tkey(\"c\"), label: words(headCells[i]), ...settings[i], type: settings[i]?.type ?? (\"text\" as const), ...(grid[0]?.cells[i]?.getAttribute(\"data-highlight\") === \"true\" ? { highlight: true } : {}), ...(sortable.has(i) ? { sortable: true } : {}) }));\n // Footnotes (production 0.10 / V2: `<ol data-footnotes>` of `<li data-key>`), before the cells that name them\n const footnoteEls = Array.from(fig?.querySelectorAll(\"[data-footnotes] > li\") ?? []);\n if (footnoteEls.length) t.footnotes = footnoteEls.map((li) => ({ _key: li.getAttribute(\"data-key\") || tkey(\"f\"), text: words(li) }));\n const cellOf = (cell: HTMLTableCellElement | undefined, col: TableColumn, rowType: TableColumnType | undefined): TableRow[\"cells\"][string] => {\n if (!cell) return \"\";\n const { rest: c, marks } = splitMarks(cell);\n // a typed cell (V2 cellHtml): its own type, its value (data-value), data-empty for none\n // a table footnote's marker (`<sup><a href=\"#<key>-fn-<n>\">`) is the cell's note, not its words\n let mark: number | undefined;\n for (const sup of Array.from(c.querySelectorAll(\"sup\"))) {\n const n = /-fn-(\\d+)$/.exec(sup.querySelector(\"a\")?.getAttribute(\"href\") ?? \"\")?.[1];\n if (!n) continue;\n mark ??= Number(n);\n sup.remove();\n }\n const named = cell.getAttribute(\"data-note\") ?? (mark ? t.footnotes?.[mark - 1]?._key : undefined);\n const note = named && t.footnotes?.some((f) => f._key === named) ? named : undefined;\n const own = typeAttrOf(cell);\n const typed = typedValueOf(cell, own ?? rowType ?? col.type);\n const text = words(c);\n const a = c.children.length === 1 && c.firstElementChild?.tagName === \"A\" && c.firstElementChild.textContent?.trim() === text ? c.firstElementChild : null;\n const value = typed !== undefined ? typed : a ? { label: text, href: a.getAttribute(\"href\") ?? \"\" } : text;\n return own || marks || note ? { value, ...(own ? { type: own } : {}), ...(note ? { note } : {}), ...(marks ? { marks } : {}) } : value;\n };\n // A group's key rides the markup (`th[data-group]`, `<tbody data-key>`), so a save keeps it; the same key met again\n // (a group split by a loose row or column) is the same group.\n const groupOf = (list: TableGroup[], own: string | null, prefix: string, label: string): TableGroup => {\n const k = (own ?? \"\").trim();\n const found = k ? list.find((g) => g._key === k) : undefined;\n if (found) return found;\n const g = { _key: k && k.length <= 64 && !list.some((x) => x._key === k) ? k : tkey(prefix), label };\n list.push(g);\n return g;\n };\n // column groups: the columns each `th[scope=colgroup]` spans\n if (groupRow) {\n const groups: TableGroup[] = [];\n let at = 0;\n for (const c of Array.from(groupRow.cells)) {\n const span = Math.max(1, c.colSpan || 1);\n if (c.tagName === \"TH\") {\n const g = groupOf(groups, c.getAttribute(\"data-group\"), \"g\", words(c));\n for (let i = at; i < at + span && i < width; i++) t.columns[i].group = g._key;\n }\n at += span;\n }\n t.columnGroups = groups;\n }\n // row groups: a label row opens a group for the rows after it in its own <tbody>\n const rowGroups: TableGroup[] = [];\n let current: { key: string; body: Element | null } | undefined;\n t.rows = [];\n for (const tr of trs) {\n if (tr === groupRow || tr.parentElement?.tagName === \"THEAD\") continue;\n if (isRowGroupRow(tr)) {\n const g = groupOf(rowGroups, tr.parentElement?.getAttribute(\"data-key\") ?? null, \"rg\", words(tr.cells[0]));\n current = { key: g._key, body: tr.parentElement };\n continue;\n }\n if (current && current.body !== tr.parentElement) current = undefined;\n // the totals row is production's <tfoot>; \"Highlight this row\" its tr[data-highlight]\n const footer = tr.parentElement?.tagName === \"TFOOT\";\n // the row's type (V2 `<tr data-type>`)\n const rowType = typeAttrOf(tr);\n t.rows.push({\n _key: tkey(\"r\"),\n cells: Object.fromEntries(t.columns.map((col, i) => [col._key, cellOf(tr.cells[i], col, rowType)])),\n ...(rowType ? { type: rowType } : {}),\n ...(current && !footer ? { group: current.key } : {}),\n ...(footer ? { footer: true } : {}),\n ...(tr.getAttribute(\"data-highlight\") === \"true\" ? { highlight: true } : {}),\n });\n }\n if (rowGroups.length) t.rowGroups = rowGroups;\n // the note: the figure's own `<p data-notes>`, or inside V2's `<div class=\"bt-notes\">` when the table has footnotes\n const note = fig?.querySelector(\":scope > [data-notes], :scope > .bt-notes > [data-notes]\");\n const box = fig?.querySelector(\":scope > .bt-notes\");\n // whitespace collapsed, as production's ingest reads it: the note renders as one paragraph\n const notes = words(note);\n if (notes) t.notes = notes;\n // the stored table's key rides the notes' id (`<key>-notes`), so a save keeps it\n const own = (box?.getAttribute(\"id\") ?? note?.getAttribute(\"id\") ?? table.getAttribute(\"aria-describedby\") ?? \"\").replace(/-notes$/, \"\");\n if (KEY.test(own)) t.id = own;\n // a link cell's column is a link column, so the editor draws (and the renderer writes) the link\n t.columns.forEach((col, i) => {\n if (settings[i]) return;\n const vals = t.rows.map((r) => r.cells[col._key]).filter((v) => v !== \"\");\n if (vals.length && vals.every((v) => isObjLike(v))) col.type = \"link\";\n });\n return t;\n}\n\n/**\n * The table as production's renderer writes a Portable Text table (@bettercms-ai/richtext html.ts tableHtml): a header\n * row in <thead>, header cells of the first column as <th>, every cell its text (a link cell its link). A caption, a\n * note or a group adds what that renderer writes for it, in the order the rows are held (an unedited stored table\n * comes back as it was; the editor's row list writes V2's order, loose rows first). An empty group has no row to label\n * and is not written, as production's renderer writes none. The totals rows are a <tfoot> after every <tbody>; a\n * highlighted row is `<tr data-highlight=\"true\">` and a highlighted column `data-highlight=\"true\"` on each of its cells\n * (production 0.10, the V2 table's markup). A sortable column is its `<col data-sortable=\"true\">` (one `<col>` per column,\n * inside each column group's `<colgroup>`), and \"Visitors can search rows\" the figure's `data-filter=\"true\"`.\n */\nexport function renderStoredTable(input: TableModel): string {\n const t = normalizeTable(input);\n const cols = t.columns;\n // typed columns and cells (V2's types): the column's settings, written as production's renderer writes a typed table\n const settings = cols.map(columnSettings);\n const typed =\n settings.some(Boolean) || t.rows.some((r) => !!storedType(r.type) || Object.values(r.cells).some((c) => isCellObject(c) && !!storedType(c.type)));\n const cell = (row: TableRow, c: TableColumn, i: number, header: boolean) => {\n const raw = row.cells[c._key];\n const v = cellValue(raw);\n const text = esc(cellText(c, row, raw));\n const marks = isCellObject(raw) && typeof raw.marks === \"string\" ? raw.marks : \"\";\n const plain = (isObjLike(v) && typeof (v as TableLink).href === \"string\" && (v as TableLink).href ? `<a href=\"${escAttr((v as TableLink).href)}\">${text}</a>` : text) + marks;\n const tag = header ? \"th\" : \"td\";\n const fn = noted(row, c);\n if (!typed) return `<${tag}${hi(c)}${fn.attr}>${plain}${fn.sup}</${tag}>`;\n const view = typedCellView(settings[i], storedType(row.type), isCellObject(raw) ? storedType(raw.type) : undefined, isObjLike(v) ? cellText(c, row, raw) : v, header, false);\n // V2 cellHtml's order: data-type, data-value / data-empty, data-note, data-align; the footnote marker after the value\n const tail = view.tail.replace(/( data-align=\"[^\"]*\")?$/, `${fn.attr}$1`);\n return `<${tag}${view.lead}${hi(c)}${tail}>${view.inner === undefined ? plain : view.inner + marks}${fn.sup}</${tag}>`;\n };\n const hi = (c: TableColumn) => (c.highlight ? ' data-highlight=\"true\"' : \"\");\n // a footnote: the cell's data-note and production's (V2's) marker after its words\n const fnOf = new Map((t.footnotes ?? []).map((f, i) => [f._key, i + 1]));\n const noted = (row: TableRow, c: TableColumn) => {\n const raw = row.cells[c._key];\n const key = isCellObject(raw) ? raw.note : undefined;\n const n = key ? fnOf.get(key) : undefined;\n return n ? { attr: ` data-note=\"${escAttr(key!)}\"`, sup: `<sup><a href=\"#${escAttr(t.id ?? \"tbl\")}-fn-${n}\" aria-label=\"Note ${n}\">${n}</a></sup>` } : { attr: \"\", sup: \"\" };\n };\n const rowHtml = (row: TableRow) =>\n `<tr${typed && storedType(row.type) ? ` data-type=\"${row.type}\"` : \"\"}${row.highlight ? ' data-highlight=\"true\"' : \"\"}>${cols.map((c, i) => cell(row, c, i, i === 0 && t.headerColumn)).join(\"\")}</tr>`;\n const headRow = `<tr>${cols\n .map((c, i) => {\n const view = typed ? typedCellView(settings[i], undefined, undefined, undefined, true, true) : { lead: \"\", tail: \"\" };\n return `<th${view.lead}${hi(c)}${view.tail}>${esc(c.label)}</th>`;\n })\n .join(\"\")}</tr>`;\n const body = t.rows.filter((r) => !r.footer);\n const tfoot = t.rows.some((r) => r.footer) ? `<tfoot>${t.rows.filter((r) => r.footer).map(rowHtml).join(\"\")}</tfoot>` : \"\";\n const span = (name: string, n: number) => (n > 1 ? ` ${name}=\"${n}\"` : \"\");\n const colLabels = new Map((t.columnGroups ?? []).map((g) => [g._key, String(g.label ?? \"\")]));\n const rowLabels = new Map((t.rowGroups ?? []).map((g) => [g._key, String(g.label ?? \"\")]));\n const runs = <T,>(items: T[], keyOf: (x: T) => string | undefined) => {\n const out: { key?: string; items: T[] }[] = [];\n for (const x of items) {\n const key = keyOf(x);\n const last = out[out.length - 1];\n if (last && last.key === key) last.items.push(x);\n else out.push({ key, items: [x] });\n }\n return out.some((r) => r.key !== undefined) ? out : [];\n };\n const colRuns = runs(cols, (c) => (c.group && colLabels.has(c.group) ? c.group : undefined));\n const rowRuns = runs(body, (r) => (r.group && rowLabels.has(r.group) ? r.group : undefined));\n const caption = t.caption.trim();\n const notes = (t.notes ?? \"\").trim();\n const footnotes = t.footnotes ?? [];\n const sortable = cols.some((c) => c.sortable) || settings.some(Boolean);\n const filter = !!t.filterable;\n const ld = t.jsonLd && t.jsonLd.type !== \"none\" ? t.jsonLd : null;\n const resp = t.design?.responsive === \"stack\" || t.design?.responsive === \"cards\" ? t.design.responsive : null;\n const sticky = !!t.design?.sticky;\n if (!caption && !notes && !footnotes.length && !colRuns.length && !rowRuns.length && !sortable && !filter && !ld && !resp && !sticky && !typed) {\n const out: string[] = [\"<table>\"];\n if (t.headerRow) out.push(`<thead>${headRow}</thead>`);\n out.push(`${body.length || !tfoot ? `<tbody>${body.map(rowHtml).join(\"\")}</tbody>` : \"\"}${tfoot}</table>`);\n return out.join(\"\");\n }\n const notesId = notes || footnotes.length ? `${t.id}-notes` : \"\";\n const out: string[] = [`<table${notesId ? ` aria-describedby=\"${escAttr(notesId)}\"` : \"\"}>`];\n if (caption) out.push(`<caption>${esc(caption)}</caption>`);\n if (sortable) {\n let at = 0;\n const widths = colRuns.length ? colRuns.map((r) => r.items.length) : [cols.length];\n out.push(widths.map((w) => `<colgroup>${cols.slice(at, (at += w)).map((c, k) => `<col${colAttrs(settings[at - w + k], !!c.sortable)}>`).join(\"\")}</colgroup>`).join(\"\"));\n } else out.push(colRuns.map((r) => `<colgroup${span(\"span\", r.items.length)}></colgroup>`).join(\"\"));\n const groupRow = colRuns.length\n ? `<tr>${colRuns.map((r) => (r.key === undefined ? \"<td></td>\".repeat(r.items.length) : `<th scope=\"colgroup\"${span(\"colspan\", r.items.length)} data-group=\"${escAttr(r.key)}\">${esc(colLabels.get(r.key)!)}</th>`)).join(\"\")}</tr>`\n : \"\";\n if (groupRow || t.headerRow) out.push(`<thead>${groupRow}${t.headerRow ? headRow : \"\"}</thead>`);\n if (rowRuns.length)\n for (const r of rowRuns)\n out.push(`<tbody${r.key === undefined ? \"\" : ` data-key=\"${escAttr(r.key)}\"`}>${r.key === undefined ? \"\" : `<tr><th scope=\"rowgroup\"${span(\"colspan\", cols.length)}>${esc(rowLabels.get(r.key)!)}</th></tr>`}${r.items.map(rowHtml).join(\"\")}</tbody>`);\n else if (body.length) out.push(`<tbody>${body.map(rowHtml).join(\"\")}</tbody>`);\n out.push(`${tfoot}</table>`);\n const html = out.join(\"\");\n if (!notes && !footnotes.length && !filter && !ld && !resp && !sticky) return html;\n const designAttrs = `${resp ? ` data-responsive=\"${resp}\"` : \"\"}${sticky ? ' data-sticky=\"true\"' : \"\"}`;\n const ldAttrs = ld ? ` data-jsonld=\"${ld.type}\"${ld.axis ? ` data-jsonld-axis=\"${ld.axis}\"` : \"\"}${ld.priceRow ? ` data-jsonld-price=\"${escAttr(ld.priceRow)}\"` : \"\"}` : \"\";\n return `<figure data-rt=\"table\"${designAttrs}${filter ? ' data-filter=\"true\"' : \"\"}${ldAttrs}>${html}${\n footnotes.length\n ? `<div class=\"bt-notes\" id=\"${escAttr(notesId)}\">${notes ? `<p data-notes>${esc(notes)}</p>` : \"\"}<ol data-footnotes>${footnotes.map((f, i) => `<li id=\"${escAttr(t.id ?? \"tbl\")}-fn-${i + 1}\" data-key=\"${escAttr(f._key)}\">${esc(f.text)}</li>`).join(\"\")}</ol></div>`\n : notes ? `<p data-notes id=\"${escAttr(notesId)}\">${esc(notes)}</p>` : \"\"\n }</figure>`;\n}\n\n/* ── Detect + parse (static HTML → model) ──────────────────────────── */\n/** The footnote markers closing a cell (`<sup data-footnote>` holding only text), and the cell without them. */\nfunction splitMarks(c: Element): { rest: Element; marks: string } {\n const rest = c.cloneNode(true) as Element;\n const marks: string[] = [];\n for (let n = rest.lastChild; n; n = rest.lastChild) {\n if (n.nodeType === 3 && !(n.textContent ?? \"\").trim() && marks.length) n.remove();\n else if (n.nodeType === 1 && (n as Element).tagName === \"SUP\" && (n as Element).hasAttribute(\"data-footnote\") && !(n as Element).children.length) {\n marks.unshift((n as Element).outerHTML);\n n.remove();\n } else break;\n }\n return { rest, marks: marks.join(\"\") };\n}\n/** A cell the table value can hold: text, line breaks, or one link around its text, then any footnote markers. */\nconst plainCell = (cell: Element) => {\n // a typed cell's markup is V2 cellHtml's (the check mark, star or dash and its words), read from data-value / data-empty\n if (cell.hasAttribute(\"data-value\") || cell.hasAttribute(\"data-empty\")) return true;\n const c = splitMarks(cell).rest;\n return (\n Array.from(c.childNodes).every((n) => n.nodeType === 3 || (n.nodeType === 1 && (n as Element).tagName === \"BR\")) ||\n (c.children.length === 1 && c.firstElementChild!.tagName === \"A\" && c.firstElementChild!.children.length === 0 && (c.textContent ?? \"\").trim() === (c.firstElementChild!.textContent ?? \"\").trim())\n );\n};\n\nexport function detectKind(el: Element): IslandKind | null {\n const rt = el.getAttribute(\"data-rt\");\n if (rt === \"table\") return el.tagName === \"TABLE\" && !Array.from(el.querySelectorAll(\"td,th\")).every(plainCell) ? null : \"table\";\n if (rt && (ISLAND_KINDS as string[]).includes(rt)) return rt as IslandKind;\n // a quote with an attribution is a pull quote (V2 detectArticle; legacy: <blockquote><p>…</p><cite>…</cite></blockquote>)\n if (el.tagName === \"BLOCKQUOTE\" && el.querySelector(\":scope > cite\")) return \"pullquote\";\n if (el.tagName === \"TABLE\") return Array.from(el.querySelectorAll(\"td,th\")).every(plainCell) ? \"table\" : null;\n if (el.tagName === \"FIGURE\" && el.querySelector(\":scope > table, :scope > .bt-scroll > table\")) return \"table\";\n // a figure that is only an image (optionally linked, optionally captioned)\n if (el.tagName === \"FIGURE\") {\n const kids = Array.from(el.children);\n const media = kids.filter((k) => k.tagName !== \"FIGCAPTION\");\n const m = media[0];\n if (media.length === 1 && kids.length - media.length <= 1 && (m.tagName === \"IMG\" || (m.tagName === \"A\" && m.children.length === 1 && m.firstElementChild!.tagName === \"IMG\"))) return \"image\";\n }\n return null;\n}\n\nconst attrOf = (el: Element, name: string) => (el.hasAttribute(name) ? el.getAttribute(name)! : undefined);\nconst oneOf = <T extends string>(list: readonly T[], v: string | undefined): T | undefined => (v !== undefined && (list as readonly string[]).includes(v) ? (v as T) : undefined);\n\nexport function parseIsland(kind: IslandKind, el: HTMLElement): IslandModels[IslandKind] {\n switch (kind) {\n case \"image\": {\n const img = el.querySelector(\"img\");\n const a = img?.parentElement?.tagName === \"A\" ? img.parentElement : null;\n const cap = el.querySelector(\":scope > figcaption\");\n const frame = readImageFrame(img);\n const m: ImageModel = { src: frame.src };\n if (img?.hasAttribute(\"alt\")) m.alt = img.getAttribute(\"alt\")!;\n if (frame.crop) m.crop = frame.crop;\n if (frame.focal) m.focal = frame.focal;\n if (cap) m.caption = (cap.textContent ?? \"\").replace(/\\u200b/g, \"\");\n const align = oneOf(IMAGE_ALIGNS, attrOf(el, \"data-align\"));\n const size = oneOf(IMAGE_SIZES, attrOf(el, \"data-size\"));\n if (align) m.align = align;\n if (size) m.size = size;\n if (a) m.href = a.getAttribute(\"href\") ?? \"\";\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"table\":\n // production's own figure holds its <table> directly; V2's (pasted) wraps it in a scroll region\n if (el.matches(\"figure[data-rt=table]\")) return el.querySelector(\":scope > table\") ? parseStoredTable(el) : parseTableElement(el);\n return parseStoredTable(el.matches(\"table\") ? el : el.querySelector(\"table\")!);\n case \"pullquote\": {\n // V2 article.ts parseArticle(\"pullquote\"): a legacy pull quote IS the <blockquote> (no <figure> around it)\n const text = (n: Element | null) => (n?.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n const bq = el.matches(\"blockquote\") ? el : el.querySelector(\"blockquote\");\n const cap = el.querySelector(\"figcaption\");\n const nameEl = cap?.querySelector(\"[data-name]\") ?? el.querySelector(\"blockquote > cite, cite\");\n let role = text(cap?.querySelector(\"[data-role]\") ?? null);\n // legacy <cite>Name, role</cite>\n let name = text(nameEl);\n if (!cap && name.includes(\",\")) [name, role] = [name.slice(0, name.indexOf(\",\")).trim(), name.slice(name.indexOf(\",\") + 1).trim()];\n const quoteEl = bq?.cloneNode(true) as HTMLElement | undefined;\n quoteEl?.querySelectorAll(\"cite\").forEach((c) => c.remove());\n return { quote: text(quoteEl ?? null), name, role, link: bq?.getAttribute(\"cite\") ?? nameEl?.getAttribute(\"href\") ?? \"\" };\n }\n case \"takeaways\": {\n // V2 article.ts parseArticle(\"takeaways\"): an empty list still holds a line to type in\n const text = (n: Element | null) => (n?.textContent ?? \"\").replace(/\\s+/g, \" \").trim();\n const pts = Array.from(el.querySelectorAll(\"li\")).map((li) => text(li));\n return { title: text(el.querySelector(\"[data-title]\")), points: pts.length ? pts : [\"\"] };\n }\n case \"callout\": {\n const title = el.querySelector(\":scope > [data-title]\");\n const body = el.querySelector(\":scope > [data-body]\");\n const m: CalloutModel = {};\n const tone = attrOf(el, \"data-callout\");\n if (tone !== undefined) m.tone = tone;\n if (title) m.title = (title.textContent ?? \"\").replace(/\\u200b/g, \"\");\n if (body) m.body = parasToText(body);\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"toggle\": {\n const title = el.querySelector(\":scope > summary\");\n const body = el.querySelector(\":scope > [data-body]\");\n const m: ToggleModel = {};\n if (title) m.title = (title.textContent ?? \"\").replace(/\\u200b/g, \"\");\n if (body) m.body = parasToText(body);\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"video\": {\n const m: VideoModel = {};\n const url = attrOf(el, \"data-url\");\n const title = attrOf(el, \"data-title\");\n if (url !== undefined) m.url = url;\n if (title !== undefined) m.title = title;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"embed\": {\n const m: EmbedModel = {};\n const url = attrOf(el, \"data-url\");\n // production writes the title as aria-label (RT3); the kit's own markup as data-title too\n const title = attrOf(el, \"data-title\") ?? attrOf(el, \"aria-label\");\n const aspect = attrOf(el, \"data-aspect\");\n if (url !== undefined) m.url = url;\n if (title !== undefined) m.title = title;\n if (aspect !== undefined && EMBED_ASPECT_VALUES.includes(aspect)) m.aspect = aspect as EmbedModel[\"aspect\"];\n if (el.hasAttribute(\"aria-label\")) m.labelled = true;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"gallery\": {\n const m: GalleryIslandModel = { images: [] };\n const layout = attrOf(el, \"data-layout\");\n if (layout === \"grid\" || layout === \"carousel\") m.layout = layout;\n m.images = Array.from(el.querySelectorAll(\"li\")).map((li) => {\n const img = li.querySelector(\"img\");\n const caption = li.querySelector(\"figcaption\")?.textContent ?? undefined;\n const frame = readImageFrame(img);\n return {\n _key: rid(\"g\"),\n src: frame.src,\n ...(img ? { alt: img.getAttribute(\"alt\") ?? \"\" } : {}),\n ...(caption ? { caption } : {}),\n ...(frame.crop ? { crop: frame.crop } : {}),\n ...(frame.focal ? { focal: frame.focal } : {}),\n };\n });\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"toc\": {\n const m: TocIslandModel = {};\n const title = el.querySelector(\"[data-title]\")?.textContent?.trim();\n if (title) m.title = title;\n const depth = attrOf(el, \"data-depth\");\n if (depth === \"2\" || depth === \"3\") m.depth = depth;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"columns\": {\n const m: ColumnsIslandModel = { cols: Array.from(el.children).filter((c) => c.hasAttribute(\"data-col\")).map((c) => ({ id: rid(\"col\"), html: c.innerHTML })) };\n const gap = attrOf(el, \"data-gap\");\n if (gap === \"s\" || gap === \"m\" || gap === \"l\") m.gap = gap;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"author\": {\n const m: AuthorIslandModel = {};\n const author = attrOf(el, \"data-author\");\n if (author !== undefined) m.author = author;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"related\": {\n // production's placeholder carries the title as an attribute, a drawn list (and V2) as [data-title]\n const m: RelatedIslandModel = { posts: (attrOf(el, \"data-posts\") ?? \"\").split(\",\").map((x) => x.trim()).filter(Boolean) };\n const title = (attrOf(el, \"data-title\") ?? el.querySelector(\"[data-title]\")?.textContent ?? \"\").trim();\n if (title) m.title = title;\n const mode = attrOf(el, \"data-mode\");\n if (mode === \"topic\" || mode === \"newest\" || mode === \"manual\") m.mode = mode;\n else if (mode === \"auto\") m.mode = \"topic\"; // V2's Automatic\n const count = Number(attrOf(el, \"data-count\"));\n if (Number.isInteger(count) && count > 0) m.count = count;\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"file\": {\n const m: FileModel = {};\n const url = attrOf(el, \"data-url\");\n const name = attrOf(el, \"data-name\");\n const size = attrOf(el, \"data-size\");\n if (url !== undefined) m.url = url;\n if (name !== undefined) m.name = name;\n if (size !== undefined && Number.isFinite(Number(size))) m.size = Number(size);\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n case \"component\": {\n // V2 markup: data-ref is the library component, data-id this instance; a legacy one names only data-block\n const m: ComponentModel = { id: attrOf(el, \"data-id\") || rid(\"ci\") };\n const ref = attrOf(el, \"data-ref\") ?? attrOf(el, \"data-block\");\n const name = attrOf(el, \"data-name\");\n const overrides = attrOf(el, \"data-overrides\");\n if (ref !== undefined) m.ref = ref;\n if (name !== undefined) m.name = name;\n if (overrides !== undefined) m.overrides = overrides;\n const variant = attrOf(el, \"data-variant\");\n if (variant !== undefined) m.variant = variant;\n const visible = el.getAttribute(\"data-visible\");\n if (visible === \"true\" || visible === \"false\") m.visible = visible === \"true\";\n if (el.getAttribute(\"data-detached\") === \"true\") {\n m.detached = true;\n const props = attrOf(el, \"data-props\");\n const blocks = attrOf(el, \"data-blocks\");\n const at = attrOf(el, \"data-source-published-at\");\n if (props !== undefined) m.props = props;\n if (blocks !== undefined) m.blocks = blocks;\n if (at !== undefined) m.sourcePublishedAt = at;\n }\n const extra = attrOf(el, \"data-extra\");\n if (extra) m.extra = extra;\n return m;\n }\n }\n}\n\nexport function createIsland<K extends IslandKind>(kind: K, model: IslandModels[K]): IslandEl {\n const el = document.createElement(\"div\") as IslandEl;\n el.setAttribute(\"data-rt-island\", kind);\n el.setAttribute(\"contenteditable\", \"false\");\n el.__rt = model;\n return el;\n}\n\n/** Static block HTML → islands (top level only). Keeps a writable line after a trailing island or rule. */\nexport function hydrate(root: HTMLElement) {\n for (const ch of Array.from(root.children)) {\n if (ch.hasAttribute(\"data-rt-island\")) continue;\n const k = detectKind(ch);\n if (!k) continue;\n ch.replaceWith(createIsland(k, parseIsland(k, ch as HTMLElement)));\n }\n // loose top-level inline content → a paragraph (a single-paragraph field stores its text inline, with no <p>)\n let run: Node[] = [];\n const flush = (before: Node | null) => {\n if (run.some((n) => (n.textContent ?? \"\").trim() || (n.nodeType === 1 && (n as Element).tagName !== \"BR\"))) {\n const p = document.createElement(\"p\");\n root.insertBefore(p, before);\n run.forEach((n) => p.append(n));\n } else run.forEach((n) => n.parentNode === root && n.nodeType === 3 && root.removeChild(n));\n run = [];\n };\n for (const n of Array.from(root.childNodes)) {\n const block = n.nodeType === 1 && (BLOCK_TAGS.has((n as Element).tagName) || (n as Element).hasAttribute(\"data-rt-island\"));\n if (block) flush(n);\n else if (n.nodeType === 1 || n.nodeType === 3) run.push(n);\n }\n flush(null);\n if (!root.firstElementChild) root.innerHTML = \"<p><br></p>\";\n const last = root.lastElementChild;\n if (last && (last.hasAttribute(\"data-rt-island\") || last.tagName === \"HR\")) {\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n root.append(p);\n }\n}\n\nconst BLOCK_TAGS = new Set([\"P\", \"H1\", \"H2\", \"H3\", \"H4\", \"H5\", \"H6\", \"BLOCKQUOTE\", \"PRE\", \"UL\", \"OL\", \"HR\", \"FIGURE\", \"TABLE\", \"DIV\", \"DETAILS\", \"SECTION\", \"ASIDE\", \"NAV\"]);\nconst isEmptyP = (el: Element) => el.tagName === \"P\" && (el.innerHTML === \"\" || el.innerHTML === \"<br>\");\n\n/** Live DOM → stored HTML. */\nexport function serialize(root: HTMLElement): string {\n const clone = root.cloneNode(true) as HTMLElement;\n const live = Array.from(root.children);\n Array.from(clone.children).forEach((c, i) => {\n if (!c.hasAttribute(\"data-rt-island\")) return;\n const l = live[i] as IslandEl;\n const kind = c.getAttribute(\"data-rt-island\") as IslandKind;\n const model = l.__rt;\n if (!model) return c.remove();\n const tpl = document.createElement(\"template\");\n tpl.innerHTML = renderStatic(kind, model);\n c.replaceWith(tpl.content);\n });\n clone.querySelectorAll(\"[data-hint]\").forEach((n) => n.removeAttribute(\"data-hint\"));\n // a task item's role and aria-checked are the editor's (checklist.tsx syncTaskA11y), never stored\n clone.querySelectorAll(\"ul[data-task] > li\").forEach((li) => (li.removeAttribute(\"role\"), li.removeAttribute(\"aria-checked\")));\n while (clone.children.length > 1 && clone.lastElementChild && isEmptyP(clone.lastElementChild)) clone.lastElementChild.remove();\n const html = clone.innerHTML.replace(//g, \"\");\n return html === \"<p><br></p>\" || html === \"<p></p>\" ? \"\" : html;\n}\n\n/** The HTML exactly as the editor would store it after opening `html` (load → hydrate → serialize), with no edit. */\nexport function editorRoundTrip(html: string): string {\n const el = document.createElement(\"div\");\n el.innerHTML = sanitize(html || \"\") || \"<p><br></p>\";\n hydrate(el);\n return serialize(el);\n}\n\n/** Strip scripts, event handlers and script URLs from HTML we did not author (paste, Markdown, loaded values). */\nexport function sanitize(html: string): string {\n if (!/[<&]/.test(html)) return html;\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(\"script,style,iframe,object,embed,link,meta,form,input,button,textarea,select,noscript\").forEach((n) => n.remove());\n doc.body.querySelectorAll(\"*\").forEach((el) => {\n for (const a of Array.from(el.attributes)) {\n const n = a.name.toLowerCase();\n if (n.startsWith(\"on\")) el.removeAttribute(a.name);\n else if ((n === \"href\" || n === \"src\" || n === \"xlink:href\") && /^\\s*(javascript|vbscript|data:text)/i.test(a.value)) el.removeAttribute(a.name);\n }\n });\n return doc.body.innerHTML;\n}\n\n/* ── Selection helpers ─────────────────────────────────────────────── */\nexport const TEXT_BLOCKS = new Set([\"P\", \"H1\", \"H2\", \"H3\", \"H4\", \"H5\", \"H6\", \"BLOCKQUOTE\", \"PRE\", \"LI\", \"DIV\"]);\n\nexport function topBlock(root: HTMLElement | null, node: Node | null): HTMLElement | null {\n if (!root) return null;\n let n: Node | null = node;\n while (n && n.parentNode !== root) n = n.parentNode;\n return n && n.nodeType === 1 ? (n as HTMLElement) : null;\n}\n\n/** Nearest text-ish block element around a node, inside root. */\nexport function closestBlock(root: HTMLElement, node: Node | null): HTMLElement | null {\n let n: Node | null = node;\n while (n && n !== root) {\n if (n.nodeType === 1 && TEXT_BLOCKS.has((n as HTMLElement).tagName) && (n as HTMLElement).closest(\"[data-rt-island]\") === null) return n as HTMLElement;\n n = n.parentNode;\n }\n return null;\n}\n\nexport function placeCaret(el: Node, atEnd = true) {\n const s = window.getSelection();\n if (!s) return;\n const r = document.createRange();\n r.selectNodeContents(el);\n r.collapse(!atEnd);\n s.removeAllRanges();\n s.addRange(r);\n}\n\nexport function textBeforeCaret(block: HTMLElement): string | null {\n const s = window.getSelection();\n if (!s || !s.rangeCount) return null;\n const r = s.getRangeAt(0);\n if (!block.contains(r.startContainer)) return null;\n const pre = document.createRange();\n pre.selectNodeContents(block);\n pre.setEnd(r.startContainer, r.startOffset);\n return pre.toString();\n}\n\nexport function editingHost(n: Node | null): HTMLElement | null {\n const el = n ? (n.nodeType === 1 ? (n as HTMLElement) : n.parentElement) : null;\n return el?.closest<HTMLElement>('[contenteditable=\"true\"],[contenteditable=\"plaintext-only\"]') ?? null;\n}\n\n/** A range's box. Browsers measure a collapsed caret as an empty rect, and some engines cannot measure ranges at all: then\n * the box of the element the range sits in. */\nexport function rangeRect(r: Range, fallback: Element | null): DOMRect {\n let rect: DOMRect | null = null;\n try {\n rect = r.getBoundingClientRect();\n } catch {\n rect = null;\n }\n if (rect && (rect.width || rect.height)) return rect;\n const host = r.startContainer.nodeType === 1 ? (r.startContainer as Element) : r.startContainer.parentElement;\n return (host ?? fallback ?? document.body).getBoundingClientRect();\n}\n\nexport const isEmptyHtml = (html: string) => !html.replace(/<(?!img|hr|figure|table|details|div data-rt)[^>]*>/g, \"\").replace(/ /g, \"\").trim();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,IAAa,OAAO,MAAc,EAAE,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AACrG,IAAa,WAAW,MAAc,IAAI,CAAC,CAAC,CAAC,QAAQ,MAAM,QAAQ;AACnE,IAAI,MAAM;AACV,IAAa,OAAO,IAAI,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,KAAK,MAAA,CAAO,SAAS,EAAE;AAKpF,IAAa,eAAsC;CAAC;CAAQ;CAAU;CAAQ;AAAO;AACrF,IAAa,cAAoC;CAAC;CAAK;CAAK;CAAK;AAAM;;;;;AA4BvE,SAAgB,eAAe,KAA0F;CACvH,MAAM,MAAM,KAAK,aAAa,UAAU,KAAK,KAAK,aAAa,KAAK,KAAK;CACzE,MAAM,QAAQ,KAAgC,MAAc;EAC1D,MAAM,KAAK,OAAO,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,OAAO,CAAC,CAAC;EACrD,OAAO,OAAO,EAAE,WAAW,KAAK,EAAE,OAAO,MAAM,OAAO,SAAS,CAAC,KAAK,KAAK,KAAK,KAAK,CAAC,IAAI,IAAI;CAC/F;CACA,MAAM,IAAI,KAAK,KAAK,aAAa,WAAW,GAAG,CAAC;CAChD,MAAM,IAAI,KAAK,KAAK,aAAa,YAAY,GAAG,CAAC;CACjD,OAAO;EACL;EACA,GAAI,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM;GAAE,KAAK,EAAE;GAAI,OAAO,EAAE;GAAI,QAAQ,EAAE;GAAI,MAAM,EAAE;EAA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