@particle-academy/fancy-cms-ui 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/document/types.ts","../src/document/own.ts","../src/document/reduce.ts","../src/document/migrate.ts","../src/render/css.ts","../src/react/registry.tsx","../src/react/RenderNode.tsx","../src/react/CmsPage.tsx"],"names":["docChildrenOf","fractionalKey","jsx"],"mappings":";;;;;AAuCO,SAAS,UAAU,CAAA,EAA0B;AAClD,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,IAAY,MAAM,IAAA,IAAQ,OAAQ,EAAc,KAAA,KAAU,QAAA;AAChF;AAiMO,SAAS,WAAW,KAAA,EAA0D;AACnF,EAAA,IAAI,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAO,KAAA;AAChF,EAAA,MAAM,QAAS,KAAA,CAA8B,KAAA;AAC7C,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAGO,IAAM,mBAAA,GAA8C;AAAA,EACzD,IAAA,EAAM,CAAA;AAAA,EACN,EAAA,EAAI,GAAA;AAAA,EACJ,EAAA,EAAI;AACN;AAGO,SAAS,QAAA,CAAS,EAAA,EAAY,IAAA,GAAO,GAAA,EAAc;AACxD,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,GAAA,EAAK,CAAA;AAAA,IACL,MAAM,EAAE,KAAA,EAAO,UAAA,EAAY,IAAA,EAAM,YAAY,QAAA,EAAS;AAAA,IACtD,KAAA,EAAO,EAAE,IAAA,EAAM,SAAA,EAAU;AAAA,IACzB,WAAA,EAAa,CAAC,MAAA,EAAQ,IAAA,EAAM,IAAI,CAAA;AAAA,IAChC,OAAO;AAAC,GACV;AACF;;;ACtPA,IAA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,EAAmB,IAAA,CAAK,MAAA,GAAS,IAAA,CAAK,IAAA,GAAO,MAAA;AAAA,MAC7C,WAAW,IAAA,CAAK,SAAA;AAAA,MAChB,GAAI,MAAA,GAAS,EAAE,EAAA,EAAI,MAAA,KAAW,EAAC;AAAA,MAC/B,GAAG;AAAA,KACL;AAAA,IACA;AAAA,GACF;AACF;ACrDO,SAAS,OAAA,CAAQ;AAAA,EACtB,GAAA,EAAK,KAAA;AAAA,EACL,QAAA,GAAW,eAAA;AAAA,EACX,IAAA;AAAA,EACA,aAAA,GAAgB;AAClB,CAAA,EAA+B;AAK7B,EAAA,MAAM,GAAA,GAAM,QAAQ,MAAM,UAAA,CAAW,KAAK,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEpD,EAAA,4BACG,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,IAAA,aAAA,mBAAgBA,IAAC,OAAA,EAAA,EAAM,iBAAA,EAAgB,IAAI,QAAA,EAAA,UAAA,CAAW,GAAG,GAAE,CAAA,GAAW,IAAA;AAAA,IACtE,OAAA,CAAQ,GAAG,CAAA,CAAE,GAAA,CAAI,CAAC,EAAA,qBACjBA,GAAAA,CAAC,UAAA,EAAA,EAAoB,GAAA,EAAU,EAAA,EAAQ,QAAA,EAAoB,IAAA,EAAA,EAA1C,EAAsD,CACxE;AAAA,GAAA,EACH,CAAA;AAEJ","file":"chunk-SJYKJ6SG.js","sourcesContent":["/**\n * Stages document model — see `fancy-ui/docs/fancy-cms.md` §4.\n *\n * A page is a vertical stack of full-bleed **sections**; inside each, **layers**\n * are positioned by constraints (free + bold stays responsive), with stack/grid\n * containers where structure is wanted. Nodes live in a **flat map** keyed by id\n * (Figma-style) so ops target a stable identity and collab merges stay clean.\n */\n\nimport type { DocNode, DocTree } from \"@particle-academy/fancy-doc-commons\";\n\n/** A node id. Alias of doc-commons' `DocId`, kept for readability in CMS code. */\nexport type NodeId = string;\n\nexport type ScrollMode = \"snap\" | \"smooth\";\n\n/** Ordered, mobile-first. Convention: `\"base\" | \"md\" | \"lg\"`. */\nexport type Breakpoint = string;\n\nexport type Json = string | number | boolean | null | Json[] | { [key: string]: Json };\n\n/** A literal value OR a binding into the page's data context (`{ $bind: \"profile.coins\" }`). */\nexport interface Binding {\n $bind: string;\n /**\n * Which live query this path reads from — `[\"catalog\", \"products\"]`.\n *\n * Optional: a host-supplied static context is still legitimate, and every\n * document saved before this has no `$source`.\n *\n * When present it is the Live Contract's vocabulary — the same\n * `[namespace, resource, …]` shape `fancy-query`'s `liveKey()` produces —\n * NOT a CMS-local name. See `./bindings` for why that matters and for\n * `bindingSources()`, which answers \"what does this page depend on?\".\n */\n $source?: readonly (string | number)[];\n}\nexport type Bound<T> = T | Binding;\n\nexport function isBinding(v: unknown): v is Binding {\n return typeof v === \"object\" && v !== null && typeof (v as Binding).$bind === \"string\";\n}\n\n// ── Sizing ────────────────────────────────────────────────────────────────\n\nexport type LengthUnit = \"px\" | \"%\" | \"vw\" | \"vh\" | \"rem\" | \"fr\";\nexport interface Length {\n value: number;\n unit: LengthUnit;\n}\nexport type SizeMode = Length | \"fill\" | \"hug\";\n\nexport interface Constraints {\n /** Pinned offsets within a `free` parent (null = unpinned). */\n left?: Length | null;\n right?: Length | null;\n top?: Length | null;\n bottom?: Length | null;\n centerX?: boolean;\n centerY?: boolean;\n width: SizeMode;\n height: SizeMode;\n}\n\nexport type LayoutMode = \"free\" | \"stack\" | \"grid\";\n\n// ── Style (compiles deterministically to CSS in both emitters) ──────────────\n\nexport interface StyleProps {\n // box\n padding?: Length;\n margin?: Length;\n /** Left + right padding. Sorts after `padding`, so it overrides that axis. */\n paddingX?: Length;\n /** Top + bottom padding. */\n paddingY?: Length;\n /** Left + right margin; `\"auto\"` centres a node with a `maxWidth`. */\n marginX?: Length | \"auto\";\n marginY?: Length;\n radius?: Length;\n // size\n maxWidth?: Length;\n minHeight?: Length;\n aspectRatio?: string; // \"16 / 9\"\n // position\n /** Stick to the top of the viewport while scrolling (`position: sticky; top: 0`). */\n sticky?: boolean;\n zIndex?: number;\n overflow?: \"visible\" | \"hidden\" | \"auto\";\n /** Hide at this breakpoint (and up, until a later breakpoint sets `false`). */\n hidden?: boolean;\n // color / surface\n background?: string; // color | gradient | url(...)\n backgroundSize?: \"cover\" | \"contain\" | \"auto\";\n backgroundPosition?: string; // \"center\", \"top right\", \"50% 20%\"\n color?: string;\n opacity?: number;\n // typography\n fontFamily?: string;\n fontSize?: Length;\n fontWeight?: number;\n lineHeight?: number;\n textAlign?: \"left\" | \"center\" | \"right\" | \"justify\";\n letterSpacing?: Length;\n textTransform?: \"none\" | \"uppercase\" | \"lowercase\" | \"capitalize\";\n // border / shadow / effects (static)\n border?: string;\n boxShadow?: string;\n transform?: string;\n filter?: string;\n // container knobs (when layout = stack | grid); all of them per breakpoint\n gap?: Length;\n direction?: \"row\" | \"column\";\n /** Stack: wrap onto more lines when the row is full. */\n wrap?: boolean;\n columns?: number;\n /**\n * Grid: fit as many columns as are at least this wide (`auto-fit`). Responsive\n * with no breakpoints at all; wins over `columns` where both are set.\n */\n columnMin?: Length;\n align?: \"start\" | \"center\" | \"end\" | \"stretch\";\n justify?: \"start\" | \"center\" | \"end\" | \"between\" | \"around\";\n}\n\n/** Per-breakpoint overrides; `base` is required, others cascade mobile-first. */\nexport type PerBreakpoint<T> = { base: T } & Partial<Record<Breakpoint, Partial<T>>>;\n\n// ── Animation (typed for Phase 2; ignored by the static CSS emitter) ────────\n\nexport type AnimDriver = \"enter\" | \"scroll\" | \"loop\" | \"hover\" | \"click\" | \"drag\";\nexport interface Keyframe {\n at: number; // 0..1\n props: Record<string, number | string>;\n}\nexport interface Anim {\n id: string;\n driver: AnimDriver;\n keyframes: Keyframe[];\n range?: { start: number; end: number };\n ease?: string;\n duration?: number;\n delay?: number;\n stagger?: number;\n once?: boolean;\n emit?: \"css\" | \"js\";\n}\n\n// ── Actions (typed for Phase 3/4) ───────────────────────────────────────────\n\nexport type ActionEvent = \"click\" | \"submit\" | \"change\" | \"load\" | \"timer\" | \"scroll-into\" | \"hover\";\nexport type ActionHandler =\n | { kind: \"navigate\"; href: Bound<string> }\n | { kind: \"submitForm\"; endpoint: string; method?: \"post\" | \"put\" }\n | { kind: \"mutate\"; target: string; value: Bound<Json> }\n | { kind: \"callEndpoint\"; endpoint: string; method?: string }\n | { kind: \"runFlow\"; flow: string }\n | { kind: \"openModal\"; node: NodeId }\n | { kind: \"openDrawer\"; node: NodeId }\n | { kind: \"playTimeline\"; section: NodeId }\n | { kind: \"toggleNode\"; node: NodeId };\nexport interface Action {\n on: ActionEvent;\n do: ActionHandler;\n}\n\n// ── Nodes & document ────────────────────────────────────────────────────────\n\n/**\n * A page node.\n *\n * Extends {@link DocNode} from `fancy-doc-commons` rather than redeclaring it:\n * id / type / parent / order / props are the shared substrate every Fancy\n * document surface uses, and the CMS adds its own domain fields on top. That\n * is what lets `registerDocBridge` drive a CMS page and a fancy-screens screen\n * through the same tools, with no CMS-specific bridge.\n */\nexport interface Node extends DocNode<Record<string, Bound<Json>>> {\n /** Addon key: `section | text | image | shape | stack | grid | frame | <addon>`. */\n type: string;\n /** How this node arranges its children. */\n layout?: LayoutMode;\n /** How this node positions itself within its parent. */\n constraints?: PerBreakpoint<Constraints>;\n style: PerBreakpoint<StyleProps>;\n animations?: Anim[];\n actions?: Action[];\n /** Repeater: render this node once per item of a bound array. */\n repeat?: { each: Binding; as: string };\n /**\n * Host CSS class(es) applied to the node's element. The migration enabler:\n * reuse the host site's existing stylesheet for pixel-perfect reproduction\n * instead of re-deriving every rule through {@link StyleProps}.\n */\n className?: string;\n /** Derived from the addon manifest — interactive/3rd-party ⇒ hydration island. */\n island?: boolean;\n}\n\nexport interface ThemeTokens {\n name?: string;\n [key: string]: Json | undefined;\n}\n\nexport interface PageMeta {\n title: string;\n slug: string;\n scrollMode: ScrollMode;\n seo?: Record<string, string>;\n}\n\nexport interface PageDoc {\n id: string;\n /** Op counter — collab ordering + revision checkpoints. */\n seq: number;\n meta: PageMeta;\n theme: ThemeTokens;\n /** Ordered, mobile-first. */\n breakpoints: Breakpoint[];\n /**\n * Flat map — not a nested tree. This is a {@link DocTree}, so every\n * doc-commons walk (`childrenOf`, `roots`, `descendantsOf`) works on it\n * directly.\n *\n * There is no separate `sections[]` any more. Top-level order used to live in\n * its own array while every other level used fractional `order` keys, which\n * meant two ordering mechanisms that could disagree — a node could be a root\n * by `parent === null` and absent from `sections`, and then simply not\n * render. Roots are now ordered exactly like any other sibling group.\n */\n nodes: Record<NodeId, Node>;\n}\n\n/** Runtime boundary check for the one structural field every document walk needs. */\nexport function hasNodeMap(value: unknown): value is { nodes: Record<NodeId, Node> } {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n const nodes = (value as { nodes?: unknown }).nodes;\n return typeof nodes === \"object\" && nodes !== null && !Array.isArray(nodes);\n}\n\n/** Default breakpoint → min-width (px) map. `base` has no media query. */\nexport const DEFAULT_BREAKPOINTS: Record<string, number> = {\n base: 0,\n md: 768,\n lg: 1024,\n};\n\n/** A minimal empty document. */\nexport function emptyDoc(id: string, slug = \"/\"): PageDoc {\n return {\n id,\n seq: 0,\n meta: { title: \"Untitled\", slug, scrollMode: \"smooth\" },\n theme: { name: \"default\" },\n breakpoints: [\"base\", \"md\", \"lg\"],\n nodes: {},\n };\n}\n","/**\n * Own-property access for maps keyed by op-supplied strings.\n *\n * Node ids and breakpoint names arrive in ops, and an agent writes the ops. On\n * a plain object, `nodes[\"constructor\"]` is Object.prototype's constructor and\n * `nodes[\"__proto__\"] = node` replaces the map's prototype instead of adding a\n * node. These helpers see only what the document actually holds. (A computed\n * key in an object literal, `{ [id]: node }`, already creates an own property\n * even for \"__proto__\", so spreads need no help.)\n */\n\nconst has = Object.prototype.hasOwnProperty;\n\n/** The entry the map really holds under `key`, or undefined. */\nexport function own<T>(map: Record<string, T> | undefined | null, key: string): T | undefined {\n return map != null && has.call(map, key) ? map[key] : undefined;\n}\n\n/** Whether the map really holds `key`. */\nexport function hasOwn(map: Record<string, unknown> | undefined | null, key: string): boolean {\n return map != null && has.call(map, key);\n}\n\n/** Write `key` as an own, enumerable data property, whatever the key is. */\nexport function setOwn<T>(map: Record<string, T>, key: string, value: T): void {\n Object.defineProperty(map, key, { value, writable: true, enumerable: true, configurable: true });\n}\n","/**\n * The pure, total reducer. `reduce(doc, op)` returns a new document; an invalid\n * op is a **logged no-op** (returns the same doc, `seq` unchanged). That single\n * property is what makes undo, revisions, collaboration, and agent edits all\n * flow through one spine.\n *\n * Ordering: EVERY level uses the fractional `order` field among siblings,\n * including the roots. Top-level order used to live in a separate `sections`\n * array, which meant two mechanisms that could disagree — a node could be a\n * root by `parent === null` and missing from `sections`, and then simply not\n * render, with nothing reporting it.\n */\nimport {\n childrenOf as docChildrenOf,\n descendantsOf,\n fractionalKey,\n} from \"@particle-academy/fancy-doc-commons\";\nimport { hasNodeMap, type Action, type Node, type NodeId, type PageDoc, type StyleProps } from \"./types\";\nimport type { PageOp } from \"./ops\";\nimport { own, setOwn } from \"./own\";\n\nexport interface ReduceOptions {\n /** Called when an op can't apply. Default: silent. */\n onInvalid?: (op: PageOp, reason: string) => void;\n}\n\n/**\n * Children of a node (or the roots when `parent` is null), in order.\n *\n * Delegates to doc-commons so the CMS, fancy-screens and any future surface\n * walk a document the same way. Roots are no longer a special case.\n */\nexport function childrenOf(doc: PageDoc, parent: NodeId | null): Node[] {\n return docChildrenOf<Node>(doc, parent);\n}\n\n/**\n * The top-level node ids, in order.\n *\n * Replaces the old `doc.sections` array. Kept as a named helper because the two\n * things callers actually wanted from that array — \"list the roots\" and \"the\n * last root\" — read badly as `childrenOf(doc, null).map(n => n.id)` at every\n * call site.\n */\nexport function rootIds(doc: PageDoc): NodeId[] {\n if (!hasNodeMap(doc)) return [];\n return childrenOf(doc, null).map((n) => n.id);\n}\n\n/** The last top-level node, or null — the default parent for a new insert. */\nexport function lastRootId(doc: PageDoc): NodeId | null {\n const r = rootIds(doc);\n return r[r.length - 1] ?? null;\n}\n\n/** Every transitive descendant id of `id` (excludes `id`). */\nexport function descendantIds(doc: PageDoc, id: NodeId): NodeId[] {\n return descendantsOf<Node>(doc, id);\n}\n\nfunction patchNode(doc: PageDoc, id: NodeId, patch: Partial<Node>): PageDoc {\n const node = own(doc.nodes, id)!;\n return {\n ...doc,\n nodes: { ...doc.nodes, [id]: { ...node, ...patch } },\n seq: doc.seq + 1,\n };\n}\n\nexport function reduce(doc: PageDoc, op: PageOp, opts: ReduceOptions = {}): PageDoc {\n const invalid = (reason: string): PageDoc => {\n opts.onInvalid?.(op, reason);\n return doc;\n };\n\n switch (op.t) {\n case \"insert_node\": {\n if (own(doc.nodes, op.node.id)) return invalid(\"node id already exists\");\n if (op.node.parent !== null && !own(doc.nodes, op.node.parent)) return invalid(\"parent not found\");\n return {\n ...doc,\n nodes: { ...doc.nodes, [op.node.id]: op.node },\n seq: doc.seq + 1,\n };\n }\n\n case \"remove_node\": {\n if (!own(doc.nodes, op.id)) return invalid(\"node not found\");\n const dead = new Set<NodeId>([op.id, ...descendantIds(doc, op.id)]);\n const nodes: Record<NodeId, Node> = {};\n for (const id of Object.keys(doc.nodes)) {\n if (!dead.has(id)) setOwn(nodes, id, own(doc.nodes, id)!);\n }\n return {\n ...doc,\n nodes,\n seq: doc.seq + 1,\n };\n }\n\n case \"move_node\": {\n const node = own(doc.nodes, op.id);\n if (!node) return invalid(\"node not found\");\n if (op.parent === op.id) return invalid(\"cannot parent a node to itself\");\n if (op.parent !== null && !own(doc.nodes, op.parent)) return invalid(\"new parent not found\");\n if (op.parent !== null && descendantIds(doc, op.id).includes(op.parent)) {\n return invalid(\"move would create a cycle\");\n }\n return {\n ...doc,\n nodes: { ...doc.nodes, [op.id]: { ...node, parent: op.parent, order: op.order } },\n seq: doc.seq + 1,\n };\n }\n\n case \"set_node_props\": {\n const node = own(doc.nodes, op.id);\n if (!node) return invalid(\"node not found\");\n return patchNode(doc, op.id, {\n props: { ...node.props, ...op.patch } as unknown as Node[\"props\"],\n });\n }\n\n case \"set_layout\": {\n if (!own(doc.nodes, op.id)) return invalid(\"node not found\");\n return patchNode(doc, op.id, { layout: op.layout });\n }\n\n case \"set_style\": {\n const node = own(doc.nodes, op.id);\n if (!node) return invalid(\"node not found\");\n const prev = own(node.style as Record<string, Partial<StyleProps>>, op.breakpoint) ?? {};\n return patchNode(doc, op.id, {\n style: { ...node.style, [op.breakpoint]: { ...prev, ...op.patch } } as Node[\"style\"],\n });\n }\n\n case \"set_constraints\": {\n const node = own(doc.nodes, op.id);\n if (!node) return invalid(\"node not found\");\n const base = node.constraints ?? { base: { width: \"hug\", height: \"hug\" } };\n const prev = own(base as Record<string, object>, op.breakpoint) ?? {};\n return patchNode(doc, op.id, {\n constraints: { ...base, [op.breakpoint]: { ...prev, ...op.patch } } as Node[\"constraints\"],\n });\n }\n\n case \"set_animation\": {\n const node = own(doc.nodes, op.id);\n if (!node) return invalid(\"node not found\");\n const list = node.animations ?? [];\n const idx = list.findIndex((a) => a.id === op.anim.id);\n return patchNode(doc, op.id, {\n animations: idx >= 0 ? list.map((a, i) => (i === idx ? op.anim : a)) : [...list, op.anim],\n });\n }\n\n case \"remove_animation\": {\n const node = own(doc.nodes, op.id);\n if (!node) return invalid(\"node not found\");\n return patchNode(doc, op.id, {\n animations: (node.animations ?? []).filter((a) => a.id !== op.animId),\n });\n }\n\n case \"set_action\": {\n const node = own(doc.nodes, op.id);\n if (!node) return invalid(\"node not found\");\n const list = node.actions ?? [];\n let actions: Action[];\n if (op.action === null) actions = list.filter((_, i) => i !== op.index);\n else if (op.index >= list.length) actions = [...list, op.action];\n else actions = list.map((a, i) => (i === op.index ? op.action! : a));\n return patchNode(doc, op.id, { actions });\n }\n\n case \"set_meta\":\n return { ...doc, meta: { ...doc.meta, ...op.patch }, seq: doc.seq + 1 };\n\n case \"set_theme\":\n return { ...doc, theme: { ...doc.theme, ...op.patch }, seq: doc.seq + 1 };\n\n case \"reorder_roots\": {\n // Roots are ordered by their own fractional keys now, so a reorder\n // REWRITES those keys rather than replacing a list. Still validated as a\n // permutation: a partial list would silently drop roots out of the page.\n const currentRoots = childrenOf(doc, null);\n const current = new Set(currentRoots.map((n) => n.id));\n // Same length, every id a root, and no id twice: a permutation.\n const same =\n op.order.length === currentRoots.length &&\n new Set(op.order).size === op.order.length &&\n op.order.every((id) => current.has(id));\n if (!same) return invalid(\"reorder must be a permutation of the current roots\");\n\n const nodes = { ...doc.nodes };\n let prev: string | null = null;\n for (const id of op.order) {\n prev = fractionalKey(prev, null);\n setOwn(nodes, id, { ...own(nodes, id)!, order: prev });\n }\n return { ...doc, nodes, seq: doc.seq + 1 };\n }\n\n default:\n return invalid(`unknown op \"${(op as PageOp).t}\"`);\n }\n}\n\n/** Apply a sequence of ops, threading the document. */\nexport function reduceAll(doc: PageDoc, ops: PageOp[], opts?: ReduceOptions): PageDoc {\n return ops.reduce((d, op) => reduce(d, op, opts), doc);\n}\n\n/**\n * Inverse op(s) for undo, computed against the **pre-op** document. Structural\n * ops invert cleanly; merge-style ops (`set_props`/`set_style`/`set_constraints`)\n * restore the previous values of the touched keys (keys that did not previously\n * exist can't be deleted via a merge — a known Phase-0 limitation).\n */\nexport function invert(doc: PageDoc, op: PageOp): PageOp[] {\n switch (op.t) {\n case \"insert_node\":\n return [{ t: \"remove_node\", id: op.node.id }];\n\n case \"remove_node\": {\n const node = own(doc.nodes, op.id);\n if (!node) return [];\n // Re-insert the subtree parent-first, then restore section order.\n const ids = [op.id, ...descendantIds(doc, op.id)];\n const inserts: PageOp[] = ids.map((id) => ({ t: \"insert_node\", node: own(doc.nodes, id)! }));\n if (node.parent === null) {\n inserts.push({ t: \"reorder_roots\", order: childrenOf(doc, null).map((n) => n.id) });\n }\n return inserts;\n }\n\n case \"move_node\": {\n const node = own(doc.nodes, op.id);\n if (!node) return [];\n const back: PageOp[] = [{ t: \"move_node\", id: op.id, parent: node.parent, order: node.order }];\n if (node.parent === null) {\n back.push({ t: \"reorder_roots\", order: childrenOf(doc, null).map((n) => n.id) });\n }\n return back;\n }\n\n case \"set_node_props\": {\n const node = own(doc.nodes, op.id);\n if (!node) return [];\n const prev: Record<string, unknown> = {};\n for (const k of Object.keys(op.patch)) prev[k] = node.props[k];\n return [{ t: \"set_node_props\", id: op.id, patch: prev }];\n }\n\n case \"set_layout\": {\n const node = own(doc.nodes, op.id);\n if (!node) return [];\n return [{ t: \"set_layout\", id: op.id, layout: node.layout }];\n }\n\n case \"set_style\": {\n const node = own(doc.nodes, op.id);\n if (!node) return [];\n const prevBp = (node.style[op.breakpoint] ?? {}) as Record<string, unknown>;\n const prev: Partial<StyleProps> = {};\n for (const k of Object.keys(op.patch)) (prev as Record<string, unknown>)[k] = prevBp[k];\n return [{ t: \"set_style\", id: op.id, breakpoint: op.breakpoint, patch: prev }];\n }\n\n case \"set_meta\":\n return [{ t: \"set_meta\", patch: pick(doc.meta, Object.keys(op.patch)) }];\n\n case \"set_theme\":\n return [{ t: \"set_theme\", patch: pick(doc.theme, Object.keys(op.patch)) }];\n\n case \"reorder_roots\":\n return [{ t: \"reorder_roots\", order: childrenOf(doc, null).map((n) => n.id) }];\n\n default:\n return [];\n }\n}\n\nfunction pick<T extends object>(obj: T, keys: string[]): Partial<T> {\n const out: Partial<T> = {};\n for (const k of keys) (out as Record<string, unknown>)[k] = (obj as Record<string, unknown>)[k];\n return out;\n}\n","/**\n * Forward migration for documents saved before roots were ordered like every\n * other sibling group.\n *\n * ## Why this cannot be skipped\n *\n * The old model carried top-level order TWICE: a `sections: NodeId[]` array, and\n * an `order` key on every node like any other sibling. The old `reorder_sections`\n * op permuted the array and **left the order keys untouched** — so the moment a\n * user dragged a section, the two disagreed, and `sections[]` was the one that\n * won (it was what the renderer walked).\n *\n * Which means: dropping `sections[]` and falling back to the order keys does not\n * merely lose a redundant field. On every page whose sections were ever\n * rearranged, it silently reverts them to the order they were first created in.\n * The page still loads, nothing throws, and the layout is wrong.\n *\n * So the migration rewrites root `order` keys to agree with `sections[]` before\n * the array is discarded. `sections[]` is treated as authoritative for exactly\n * the reason above.\n *\n * ## Idempotent, and safe on already-migrated documents\n *\n * A doc with no `sections` is returned unchanged (same reference). Running this\n * twice is a no-op, so a host can call it unconditionally on load rather than\n * tracking a schema version.\n */\n\nimport { fractionalKey } from \"@particle-academy/fancy-doc-commons\";\nimport { emptyDoc, hasNodeMap, type NodeId, type PageDoc } from \"./types\";\nimport { own, setOwn } from \"./own\";\n\n/** A `PageDoc` as persisted before this change — with the extra array. */\nexport type LegacyPageDoc = PageDoc & { sections?: NodeId[] };\n\nexport interface MigrateResult {\n doc: PageDoc;\n /** True when the input actually carried `sections[]` and was rewritten. */\n migrated: boolean;\n /**\n * Ids listed in `sections[]` with no matching node. Skipped rather than\n * faulted — a dangling id is a stale write, and refusing to open the document\n * over it would be a worse outcome than dropping it.\n */\n danglingIds: NodeId[];\n /**\n * Roots present in `nodes` but missing from `sections[]`. Under the old model\n * these did not render at all. They are appended after the listed sections, in\n * their existing order-key order, because making a node visible is recoverable\n * and deleting one is not.\n */\n unlistedRootIds: NodeId[];\n}\n\nfunction normalizeDoc(input: unknown): LegacyPageDoc | PageDoc {\n if (hasNodeMap(input)) return input as LegacyPageDoc | PageDoc;\n\n const id =\n typeof input === \"object\" && input !== null && !Array.isArray(input) &&\n typeof (input as { id?: unknown }).id === \"string\"\n ? (input as { id: string }).id\n : \"malformed\";\n\n return emptyDoc(id);\n}\n\n/**\n * Migrate a possibly-legacy document, reporting what was found.\n *\n * Use {@link migrateDoc} unless you want the diagnostics.\n */\nexport function migrateDocVerbose(input: LegacyPageDoc | PageDoc): MigrateResult {\n const normalized = normalizeDoc(input);\n const legacy = normalized as LegacyPageDoc;\n const sections = legacy.sections;\n\n if (!Array.isArray(sections)) {\n return { doc: normalized as PageDoc, migrated: false, danglingIds: [], unlistedRootIds: [] };\n }\n\n const danglingIds: NodeId[] = [];\n const ordered: NodeId[] = [];\n const seen = new Set<NodeId>();\n\n for (const id of sections) {\n if (!own(normalized.nodes, id)) {\n danglingIds.push(id);\n continue;\n }\n // A duplicate id in the array would otherwise be minted two order keys, and\n // the second would overwrite the first — take the first occurrence.\n if (seen.has(id)) continue;\n seen.add(id);\n ordered.push(id);\n }\n\n // Roots that the array never mentioned. Sorted by their existing key so their\n // relative order is at least stable rather than dependent on object insertion.\n const unlistedRootIds = Object.values(normalized.nodes)\n .filter((n) => n.parent === null && !seen.has(n.id))\n .sort((a, b) => (a.order < b.order ? -1 : a.order > b.order ? 1 : 0))\n .map((n) => n.id);\n\n const finalOrder = [...ordered, ...unlistedRootIds];\n\n const nodes = { ...normalized.nodes };\n let prev: string | null = null;\n\n for (const id of finalOrder) {\n const key = fractionalKey(prev, null);\n setOwn(nodes, id, { ...own(nodes, id)!, order: key });\n prev = key;\n }\n\n const { sections: _dropped, ...rest } = legacy;\n\n return {\n doc: { ...rest, nodes } as PageDoc,\n migrated: true,\n danglingIds,\n unlistedRootIds,\n };\n}\n\n/**\n * Migrate a possibly-legacy document. Safe to call on every load — an\n * already-migrated document is returned unchanged, by reference.\n */\nexport function migrateDoc(input: LegacyPageDoc | PageDoc): PageDoc {\n return migrateDocVerbose(input).doc;\n}\n\n/** True when the document still carries the pre-migration `sections[]` array. */\nexport function needsMigration(input: LegacyPageDoc | PageDoc): boolean {\n return Array.isArray((input as LegacyPageDoc).sections);\n}\n","/**\n * The JS style → CSS emitter (one half of the dual-emitter pair; the PHP\n * `particle-academy/fancy-cms` mirrors it byte-for-byte). Output is\n * **deterministic**: declarations are sorted, selectors and media blocks use a\n * fixed format, and nodes are emitted in sorted-id order — so the parity harness\n * can diff the two engines' CSS exactly.\n *\n * Phase 0 covers the static subset (layout / constraints / style). Motion lands\n * in Phase 2.\n */\nimport {\n DEFAULT_BREAKPOINTS,\n hasNodeMap,\n type Constraints,\n type Length,\n type Node,\n type PageDoc,\n type SizeMode,\n type StyleProps,\n} from \"../document/types\";\nimport { own } from \"../document/own\";\n\n/**\n * A string as the contents of a double-quoted CSS string. `\\` and `\"` are\n * backslash-escaped; control characters, and `<` (so an id can never write\n * `</style>` into an inline stylesheet), become hex escapes followed by a\n * space. The selector still matches the attribute's real value.\n */\nexport function cssString(value: string): string {\n let out = \"\";\n for (const ch of value) {\n const code = ch.codePointAt(0)!;\n if (ch === \"\\\\\" || ch === '\"') out += `\\\\${ch}`;\n else if (code < 0x20 || code === 0x7f || ch === \"<\") out += `\\\\${code.toString(16)} `;\n else out += ch;\n }\n return out;\n}\n\nconst selectorFor = (id: string): string => `[data-cms=\"${cssString(id)}\"]`;\n\nconst UNITS = new Set([\"px\", \"%\", \"vw\", \"vh\", \"rem\", \"fr\"]);\n\n/** A Length as CSS, or null unless its value is a finite number and its unit a known one. */\nfunction lengthToCss(len: unknown): string | null {\n if (typeof len !== \"object\" || len === null) return null;\n const { value, unit } = len as Length;\n if (typeof value !== \"number\" || !Number.isFinite(value) || typeof unit !== \"string\" || !UNITS.has(unit)) return null;\n return `${value}${unit}`;\n}\n\nfunction sizeToCss(size: unknown): string | null {\n if (size === \"fill\") return \"100%\";\n if (size === \"hug\") return \"auto\";\n return lengthToCss(size);\n}\n\n/** A finite number as CSS, or null. */\nfunction numberToCss(value: unknown): string | null {\n return typeof value === \"number\" && Number.isFinite(value) ? String(value) : null;\n}\n\nfunction putLen(d: Record<string, string>, props: string[], len: unknown): void {\n const css = lengthToCss(len);\n if (css !== null) for (const p of props) d[p] = css;\n}\n\nconst ALIGN: Record<string, string> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n stretch: \"stretch\",\n};\nconst JUSTIFY: Record<string, string> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n between: \"space-between\",\n around: \"space-around\",\n};\n\n/**\n * A free-form value is written into a declaration verbatim, so it must not be\n * able to end that declaration or rule: no `{`, `}` or `<` anywhere, and no `;`\n * outside parentheses or quotes (`url(data:image/svg+xml;base64,…)` stays\n * legal). Returns null for a value that would escape; the declaration is then\n * dropped. The PHP emitter applies the identical rule.\n */\nexport function safeCssValue(value: string): string | null {\n if (/[{}<]/.test(value)) return null;\n let depth = 0;\n let quote: string | null = null;\n for (const ch of value) {\n if (quote) {\n if (ch === quote) quote = null;\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch;\n } else if (ch === \"(\") {\n depth++;\n } else if (ch === \")\") {\n depth = Math.max(0, depth - 1);\n } else if (ch === \";\" && depth === 0) {\n return null;\n }\n }\n return value;\n}\n\nfunction put(d: Record<string, string>, prop: string, value: string | undefined): void {\n if (value === undefined) return;\n const safe = safeCssValue(value);\n if (safe !== null) d[prop] = safe;\n}\n\nconst OVERFLOW = new Set([\"visible\", \"hidden\", \"auto\"]);\nconst TEXT_TRANSFORM = new Set([\"none\", \"uppercase\", \"lowercase\", \"capitalize\"]);\nconst BACKGROUND_SIZE = new Set([\"cover\", \"contain\", \"auto\"]);\nconst TEXT_ALIGN = new Set([\"left\", \"center\", \"right\", \"justify\"]);\nconst DIRECTIONS = new Set([\"row\", \"column\"]);\n\n/** An allowlisted keyword, or null. Keys are looked up as own properties only. */\nfunction keyword(map: Record<string, string>, value: unknown): string | null {\n return typeof value === \"string\" && Object.prototype.hasOwnProperty.call(map, value) ? map[value]! : null;\n}\n\nfunction inSet(set: Set<string>, value: unknown): string | null {\n return typeof value === \"string\" && set.has(value) ? value : null;\n}\n\n/**\n * Map StyleProps → CSS declarations (property → value). Container knobs are in\n * {@link containerDecls}. Every value passes one of three gates: a Length with a\n * known unit and a finite number, an allowlisted keyword, or\n * {@link safeCssValue} for the free-form colours, borders and font stacks.\n * Anything else emits nothing.\n */\nfunction styleDecls(style: Partial<StyleProps>): Record<string, string> {\n const d: Record<string, string> = {};\n putLen(d, [\"padding\"], style.padding);\n putLen(d, [\"padding-left\", \"padding-right\"], style.paddingX);\n putLen(d, [\"padding-top\", \"padding-bottom\"], style.paddingY);\n putLen(d, [\"margin\"], style.margin);\n if (style.marginX === \"auto\") d[\"margin-left\"] = d[\"margin-right\"] = \"auto\";\n else putLen(d, [\"margin-left\", \"margin-right\"], style.marginX);\n putLen(d, [\"margin-top\", \"margin-bottom\"], style.marginY);\n putLen(d, [\"border-radius\"], style.radius);\n putLen(d, [\"max-width\"], style.maxWidth);\n putLen(d, [\"min-height\"], style.minHeight);\n put(d, \"aspect-ratio\", typeof style.aspectRatio === \"string\" ? style.aspectRatio : undefined);\n if (style.sticky === true) {\n d[\"position\"] = \"sticky\";\n d[\"top\"] = \"0\";\n }\n if (typeof style.zIndex === \"number\" && Number.isFinite(style.zIndex)) d[\"z-index\"] = String(Math.trunc(style.zIndex));\n const overflow = inSet(OVERFLOW, style.overflow);\n if (overflow) d[\"overflow\"] = overflow;\n put(d, \"background\", typeof style.background === \"string\" ? style.background : undefined);\n const backgroundSize = inSet(BACKGROUND_SIZE, style.backgroundSize);\n if (backgroundSize) d[\"background-size\"] = backgroundSize;\n put(d, \"background-position\", typeof style.backgroundPosition === \"string\" ? style.backgroundPosition : undefined);\n put(d, \"color\", typeof style.color === \"string\" ? style.color : undefined);\n const opacity = numberToCss(style.opacity);\n if (opacity !== null) d[\"opacity\"] = opacity;\n put(d, \"font-family\", typeof style.fontFamily === \"string\" ? style.fontFamily : undefined);\n putLen(d, [\"font-size\"], style.fontSize);\n const fontWeight = numberToCss(style.fontWeight);\n if (fontWeight !== null) d[\"font-weight\"] = fontWeight;\n const lineHeight = numberToCss(style.lineHeight);\n if (lineHeight !== null) d[\"line-height\"] = lineHeight;\n const textAlign = inSet(TEXT_ALIGN, style.textAlign);\n if (textAlign) d[\"text-align\"] = textAlign;\n putLen(d, [\"letter-spacing\"], style.letterSpacing);\n const textTransform = inSet(TEXT_TRANSFORM, style.textTransform);\n if (textTransform) d[\"text-transform\"] = textTransform;\n put(d, \"border\", typeof style.border === \"string\" ? style.border : undefined);\n put(d, \"box-shadow\", typeof style.boxShadow === \"string\" ? style.boxShadow : undefined);\n put(d, \"transform\", typeof style.transform === \"string\" ? style.transform : undefined);\n put(d, \"filter\", typeof style.filter === \"string\" ? style.filter : undefined);\n putLen(d, [\"gap\"], style.gap);\n const align = keyword(ALIGN, style.align);\n if (align) d[\"align-items\"] = align;\n const justify = keyword(JUSTIFY, style.justify);\n if (justify) d[\"justify-content\"] = justify;\n return d;\n}\n\n/** The display value a node has when it is NOT hidden. */\nfunction shownDisplay(node: Node): string {\n if (node.layout === \"stack\") return \"flex\";\n if (node.layout === \"grid\") return \"grid\";\n return \"block\";\n}\n\nfunction gridColumns(style: Partial<StyleProps>): string | undefined {\n const min = lengthToCss(style.columnMin);\n if (min !== null) return `repeat(auto-fit, minmax(min(${min}, 100%), 1fr))`;\n if (typeof style.columns === \"number\" && Number.isFinite(style.columns)) return `repeat(${Math.max(1, Math.trunc(style.columns))}, 1fr)`;\n return undefined;\n}\n\n/**\n * Container behaviour. At `base` the layout's display and defaults apply; at a\n * breakpoint only what that breakpoint's style changes is emitted, so a grid can\n * go 1 -> 2 -> 3 columns and a stack column -> row.\n */\nfunction containerDecls(node: Node, style: Partial<StyleProps>, isBase: boolean): Record<string, string> {\n const d: Record<string, string> = {};\n if (node.layout === \"stack\") {\n if (isBase) d[\"display\"] = \"flex\";\n const direction = inSet(DIRECTIONS, style.direction);\n if (isBase || direction) d[\"flex-direction\"] = direction ?? \"column\";\n if (style.wrap !== undefined) d[\"flex-wrap\"] = style.wrap ? \"wrap\" : \"nowrap\";\n } else if (node.layout === \"grid\") {\n if (isBase) d[\"display\"] = \"grid\";\n const cols = gridColumns(style);\n if (isBase || cols !== undefined) d[\"grid-template-columns\"] = cols ?? \"repeat(1, 1fr)\";\n } else if (node.layout === \"free\" && isBase) {\n d[\"position\"] = \"relative\";\n }\n return d;\n}\n\n/** `hidden` decides `display` last, over the layout's own display. */\nfunction visibilityDecls(node: Node, style: Partial<StyleProps>, isBase: boolean): Record<string, string> {\n if (style.hidden === true) return { display: \"none\" };\n if (style.hidden === false && !isBase) return { display: shownDisplay(node) };\n return {};\n}\n\n/**\n * Theme tokens as custom properties: `{ color: { primary } }` -> `--cms-color-primary`.\n * `name` labels the theme and is not a token. Keys are reduced to `[a-z0-9-]`;\n * values must be strings or numbers and pass {@link safeCssValue}.\n */\nfunction themeDecls(theme: unknown): Record<string, string> {\n const d: Record<string, string> = {};\n const walk = (value: unknown, path: string[]): void => {\n if (typeof value === \"string\" || (typeof value === \"number\" && Number.isFinite(value))) {\n const key = path.map((p) => p.toLowerCase().replace(/[^a-z0-9-]/g, \"\")).filter(Boolean).join(\"-\");\n if (key) put(d, `--cms-${key}`, String(value));\n return;\n }\n if (typeof value === \"object\" && value !== null && !Array.isArray(value)) {\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) walk(v, [...path, k]);\n }\n };\n if (typeof theme === \"object\" && theme !== null && !Array.isArray(theme)) {\n for (const [k, v] of Object.entries(theme as Record<string, unknown>)) {\n if (k !== \"name\") walk(v, [k]);\n }\n }\n return d;\n}\n\n/** Self-positioning from constraints (absolute pins only inside a `free` parent). */\nfunction constraintDecls(c: Partial<Constraints>, parentFree: boolean): Record<string, string> {\n const d: Record<string, string> = {};\n const transforms: string[] = [];\n if (parentFree) {\n d[\"position\"] = \"absolute\";\n putLen(d, [\"left\"], c.left);\n putLen(d, [\"right\"], c.right);\n putLen(d, [\"top\"], c.top);\n putLen(d, [\"bottom\"], c.bottom);\n if (c.centerX) {\n d[\"left\"] = \"50%\";\n transforms.push(\"translateX(-50%)\");\n }\n if (c.centerY) {\n d[\"top\"] = \"50%\";\n transforms.push(\"translateY(-50%)\");\n }\n if (transforms.length) d[\"transform\"] = transforms.join(\" \");\n }\n const width = sizeToCss(c.width);\n if (width !== null) d[\"width\"] = width;\n const height = sizeToCss(c.height);\n if (height !== null) d[\"height\"] = height;\n return d;\n}\n\nfunction isParentFree(doc: PageDoc, node: Node): boolean {\n if (node.parent === null) return false; // sections stack in the page flow\n const parent = own(doc.nodes, node.parent);\n return !parent || parent.layout === undefined || parent.layout === \"free\";\n}\n\nfunction serializeRule(selector: string, decls: Record<string, string>, indent: string): string {\n const props = Object.keys(decls).sort();\n if (props.length === 0) return \"\";\n const body = props.map((p) => `${indent} ${p}: ${decls[p]};`).join(\"\\n\");\n return `${indent}${selector} {\\n${body}\\n${indent}}`;\n}\n\n/** Emit the full stylesheet for a document. Deterministic. */\nexport function emitDocCss(doc: PageDoc): string {\n if (!hasNodeMap(doc)) return \"\";\n\n const breakpointPx = DEFAULT_BREAKPOINTS;\n const blocks: string[] = [];\n\n const themeRule = serializeRule(\":root\", themeDecls((doc as { theme?: unknown }).theme), \"\");\n if (themeRule) blocks.push(themeRule);\n\n for (const id of Object.keys(doc.nodes).sort()) {\n const node = doc.nodes[id]!;\n const selector = selectorFor(id);\n const parentFree = isParentFree(doc, node);\n\n // base = layout, then constraints.base, then style.base (later wins), then visibility\n const base: Record<string, string> = {\n ...containerDecls(node, node.style.base, true),\n ...(node.constraints ? constraintDecls(node.constraints.base, parentFree) : {}),\n ...styleDecls(node.style.base),\n ...visibilityDecls(node, node.style.base, true),\n };\n const baseRule = serializeRule(selector, base, \"\");\n if (baseRule) blocks.push(baseRule);\n\n // per-breakpoint overrides (mobile-first, in doc order, skipping base)\n for (const bp of doc.breakpoints) {\n if (bp === \"base\") continue;\n const px = breakpointPx[bp];\n if (px === undefined) continue;\n const bpStyle = node.style[bp];\n const decls: Record<string, string> = {\n ...(bpStyle ? containerDecls(node, bpStyle, false) : {}),\n ...(node.constraints?.[bp] ? constraintDecls(node.constraints[bp]!, parentFree) : {}),\n ...(bpStyle ? styleDecls(bpStyle) : {}),\n ...(bpStyle ? visibilityDecls(node, bpStyle, false) : {}),\n };\n const inner = serializeRule(selector, decls, \" \");\n if (inner) blocks.push(`@media (min-width: ${px}px) {\\n${inner}\\n}`);\n }\n }\n\n return blocks.join(\"\\n\\n\") + (blocks.length ? \"\\n\" : \"\");\n}\n","import type { ReactNode } from \"react\";\nimport { isBinding, type Bound, type Json, type Node, type PageDoc } from \"../document/types\";\n\n/** The page data context bindings resolve against (e.g. server props, repeater `item`). */\nexport type DataContext = Record<string, unknown>;\n\nexport interface ElementContext {\n node: Node;\n doc: PageDoc;\n /** Pre-rendered child nodes, in order. */\n children: ReactNode;\n /** The data context this node renders in (page data + any repeater scope). */\n data?: DataContext;\n /** Resolve a (possibly bound) value to its raw resolved value. */\n resolve: (v: Bound<Json> | undefined) => unknown;\n /** Resolve a (possibly bound) value to a display string. */\n text: (v: Bound<Json> | undefined) => string;\n}\n\n/**\n * Renders the INNER content of a node. The outer `[data-cms]` wrapper is added\n * by {@link RenderNode}, so a renderer only returns what goes inside.\n */\nexport type ElementRenderer = (ctx: ElementContext) => ReactNode;\n\nexport type ElementRegistry = Record<string, ElementRenderer>;\n\n/** Read a dotted path (`a.b.c`) out of the data context. */\nexport function getPath(data: DataContext | undefined, path: string): unknown {\n return path.split(\".\").reduce<unknown>((o, k) => (o == null ? undefined : (o as Record<string, unknown>)[k]), data);\n}\n\n/** Resolve a value: a `{ $bind }` reads from the data context; anything else is literal. */\nexport function resolveValue(v: Bound<Json> | undefined, data?: DataContext): unknown {\n if (v === undefined || v === null) return v;\n if (isBinding(v)) return getPath(data, v.$bind);\n return v;\n}\n\n/** Landmark tags a container may opt into with `props.as`. Anything else is ignored. */\nexport const LANDMARK_TAGS = [\"section\", \"header\", \"nav\", \"main\", \"footer\", \"article\", \"aside\", \"div\"] as const;\nconst LANDMARKS = new Set<string>(LANDMARK_TAGS);\nconst CONTAINERS = new Set([\"stack\", \"grid\", \"frame\", \"shape\", \"card\"]);\nconst SAFE_SCHEMES = new Set([\"http\", \"https\", \"mailto\", \"tel\"]);\n\n/**\n * An href an author or agent wrote, or null when it must not be rendered.\n * Relative URLs, fragments and http(s)/mailto/tel pass; every other scheme\n * (`javascript:`, `data:`, `vbscript:` ...) is dropped.\n */\nexport function safeHref(raw: string): string | null {\n const href = raw.trim();\n if (!href) return null;\n // Strip control characters and whitespace a browser ignores when it reads a scheme.\n const probe = href.replace(/[\\u0000- \\u007f]+/g, \"\");\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(probe);\n if (scheme && !SAFE_SCHEMES.has(scheme[1]!.toLowerCase())) return null;\n return href;\n}\n\n/** What `props.anchor` must look like to become an `id`: a lowercase slug, 64 chars at most. */\nexport const ANCHOR_PATTERN = /^[a-z][a-z0-9-]{0,63}$/;\n\n/**\n * The in-page anchor a node declares (`props.anchor`), or null. Rendered as the\n * element's `id`, so `href=\"#pricing\"` scrolls to it. Anything that is not a\n * lowercase slug is ignored rather than rendered.\n */\nexport function anchorFor(node: Node, text: (v: Bound<Json> | undefined) => string): string | null {\n const anchor = text(node.props.anchor);\n return ANCHOR_PATTERN.test(anchor) ? anchor : null;\n}\n\n/** The element a node renders as: its tag and the attributes that tag needs. */\nexport interface ElementSpec {\n tag: string;\n attrs?: Record<string, string>;\n}\n\n/**\n * Semantic element per node. The `[data-cms]` element IS this element, so the\n * node's emitted CSS styles the real heading, paragraph, link or landmark.\n */\nexport function elementFor(node: Node, text: (v: Bound<Json> | undefined) => string): ElementSpec {\n const as = text(node.props.as);\n switch (node.type) {\n case \"heading\": {\n const level = Number(text(node.props.level) || 2);\n return { tag: Number.isInteger(level) && level >= 1 && level <= 6 ? `h${level}` : \"h2\" };\n }\n case \"text\":\n return { tag: \"p\" };\n case \"section\":\n return { tag: LANDMARKS.has(as) ? as : \"section\" };\n case \"list\":\n return { tag: text(node.props.ordered) === \"true\" ? \"ol\" : \"ul\" };\n case \"button\":\n case \"link\": {\n const href = safeHref(text(node.props.href));\n if (href === null) return { tag: node.type === \"link\" ? \"span\" : \"div\" };\n const attrs: Record<string, string> = { href };\n if (/^https?:\\/\\//i.test(href)) attrs.rel = \"noopener noreferrer\";\n return { tag: \"a\", attrs };\n }\n default:\n return { tag: CONTAINERS.has(node.type) && LANDMARKS.has(as) ? as : \"div\" };\n }\n}\n\n/** Built-in native elements. Containers render their children; leaves render content. */\nexport const defaultRegistry: ElementRegistry = {\n section: ({ children }) => children,\n stack: ({ children }) => children,\n grid: ({ children }) => children,\n frame: ({ children }) => children,\n shape: ({ children }) => children,\n card: ({ children }) => children,\n text: ({ node, text }) => text(node.props.content),\n heading: ({ node, text }) => text(node.props.content) || \"Heading\",\n // Rich text — inline-formatted HTML (gradient spans, links, <code>, …) that\n // plain `text` can't express. The author owns the markup (it's their content).\n richtext: ({ node, text }) => <div dangerouslySetInnerHTML={{ __html: text(node.props.html) }} />,\n // The [data-cms] element is already the <a> (see elementFor), so a link renders its label only.\n link: ({ node, text }) => text(node.props.content) || \"link\",\n list: ({ node, resolve }) => {\n const items = resolve(node.props.items);\n return Array.isArray(items) ? items.map((item, i) => <li key={i}>{item === null || item === undefined ? \"\" : String(item)}</li>) : null;\n },\n divider: () => <hr style={{ border: \"none\", borderTop: \"1px solid #e2e8f0\", margin: 0 }} />,\n callout: ({ node, text }) => {\n const tone = ({ info: \"#3b82f6\", success: \"#10b981\", warning: \"#f59e0b\", danger: \"#ef4444\" } as Record<string, string>)[text(node.props.variant)] ?? \"#3b82f6\";\n return (\n <div style={{ display: \"flex\", gap: 10, padding: \"12px 14px\", borderRadius: 10, background: `${tone}14`, borderLeft: `3px solid ${tone}` }}>\n <span style={{ fontSize: 13 }}>{text(node.props.content) || \"Callout\"}</span>\n </div>\n );\n },\n code: ({ node, text }) => (\n <pre style={{ margin: 0, padding: \"12px 14px\", borderRadius: 10, background: \"#0b1220\", color: \"#e2e8f0\", fontFamily: \"ui-monospace, monospace\", fontSize: 13, overflowX: \"auto\" }}>\n <code>{text(node.props.content)}</code>\n </pre>\n ),\n button: ({ node, text }) => {\n const label = text(node.props.label) || text(node.props.content) || \"Button\";\n const variant = text(node.props.variant) || \"primary\";\n return <span data-cms-button={variant} style={buttonStyle(variant)}>{label}</span>;\n },\n image: ({ node, text }) => {\n const fit = text(node.props.fit);\n return (\n <img\n src={text(node.props.src)}\n alt={text(node.props.alt)}\n loading={text(node.props.loading) === \"eager\" ? \"eager\" : \"lazy\"}\n style={{ width: \"100%\", height: \"100%\", objectFit: IMAGE_FITS.has(fit) ? (fit as \"cover\") : \"cover\", display: \"block\" }}\n />\n );\n },\n};\n\nconst IMAGE_FITS = new Set([\"cover\", \"contain\", \"fill\", \"none\", \"scale-down\"]);\n\n/**\n * A self-contained button look so the `button` primitive renders sensibly with\n * zero host CSS. Hosts that want their own button classes override the `button`\n * renderer in their registry (e.g. the sandbox maps it to `.btn .btn-primary`).\n */\nfunction buttonStyle(variant: string): import(\"react\").CSSProperties {\n const base: import(\"react\").CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"9px 16px\",\n borderRadius: 8,\n fontWeight: 600,\n fontSize: 14,\n lineHeight: 1,\n cursor: \"pointer\",\n userSelect: \"none\",\n };\n if (variant === \"ghost\") return { ...base, background: \"transparent\", color: \"inherit\", border: \"1px solid currentColor\" };\n if (variant === \"outline\") return { ...base, background: \"transparent\", color: \"#7c3aed\", border: \"1px solid #7c3aed\" };\n return { ...base, background: \"#7c3aed\", color: \"#fff\", border: \"1px solid #7c3aed\" };\n}\n","import { createElement, type ReactElement } from \"react\";\nimport type { Bound, Json, PageDoc } from \"../document/types\";\nimport { childrenOf } from \"../document/reduce\";\nimport { own } from \"../document/own\";\nimport { anchorFor, defaultRegistry, elementFor, resolveValue, type DataContext, type ElementRegistry } from \"./registry\";\n\nexport interface RenderNodeProps {\n doc: PageDoc;\n id: string;\n registry?: ElementRegistry;\n /** Data context bindings resolve against (page data + any repeater scope). */\n data?: DataContext;\n}\n\n/**\n * Render one node (and its subtree) to a `[data-cms]`-tagged element. The CSS\n * emitted by `emitDocCss` targets these `data-cms` handles. Interactive /\n * 3rd-party **islands** with no registered renderer become an empty, sized\n * placeholder the host hydrates client-side — mirroring the PHP renderer.\n *\n * `repeater` nodes are special-cased: their first child is a template rendered\n * once per item of the bound `items` array, each in a scope that exposes `item`\n * and `index` to nested `{ $bind: \"item.…\" }` bindings.\n */\nexport function RenderNode({ doc, id, registry = defaultRegistry, data }: RenderNodeProps): ReactElement | null {\n const node = own(doc.nodes, id);\n if (!node) return null;\n\n if (node.type === \"repeater\") {\n const arr = resolveValue(node.props.items as Bound<Json> | undefined, data);\n const items = Array.isArray(arr) ? arr : [];\n const template = childrenOf(doc, id)[0];\n return (\n <div data-cms={node.id} className={node.className}>\n {template\n ? items.map((item, index) => (\n <RenderNode key={index} doc={doc} id={template.id} registry={registry} data={{ ...data, item, index }} />\n ))\n : null}\n </div>\n );\n }\n\n const kids = childrenOf(doc, id).map((child) => (\n <RenderNode key={child.id} doc={doc} id={child.id} registry={registry} data={data} />\n ));\n\n const resolve = (v: Bound<Json> | undefined) => resolveValue(v, data);\n const text = (v: Bound<Json> | undefined): string => {\n const r = resolve(v);\n return r === undefined || r === null ? \"\" : String(r);\n };\n\n const renderer = registry[node.type];\n const inner = renderer ? renderer({ node, doc, children: kids, data, resolve, text }) : node.island ? null : kids;\n\n // The [data-cms] element is the semantic element itself (h1-h6, p, a, ul,\n // section, nav ...), so the node's emitted CSS styles the real element.\n const { tag, attrs } = elementFor(node, text);\n const anchor = anchorFor(node, text);\n return createElement(\n tag,\n {\n \"data-cms\": node.id,\n \"data-cms-island\": node.island ? node.type : undefined,\n className: node.className,\n ...(anchor ? { id: anchor } : {}),\n ...attrs,\n },\n inner,\n );\n}\n","import { Fragment, useMemo, type ReactElement } from \"react\";\nimport type { PageDoc } from \"../document/types\";\nimport { rootIds } from \"../document/reduce\";\nimport { migrateDoc, type LegacyPageDoc } from \"../document/migrate\";\nimport { emitDocCss } from \"../render/css\";\nimport { RenderNode } from \"./RenderNode\";\nimport { defaultRegistry, type DataContext, type ElementRegistry } from \"./registry\";\n\nexport interface CmsPageProps {\n doc: LegacyPageDoc | PageDoc;\n registry?: ElementRegistry;\n /** Data context that `{ $bind: \"…\" }` props + repeaters resolve against. */\n data?: DataContext;\n /** Inject the compiled stylesheet. Set false when the host emits CSS itself. */\n includeStyles?: boolean;\n}\n\n/** Render a full page document: the compiled stylesheet + every section. */\nexport function CmsPage({\n doc: input,\n registry = defaultRegistry,\n data,\n includeStyles = true,\n}: CmsPageProps): ReactElement {\n // Renders a pre-`sections[]` document correctly rather than in whatever order\n // its stale order keys happen to imply. The check is an `Array.isArray`, and\n // an already-migrated document comes back by reference, so the memo costs a\n // migrated host nothing.\n const doc = useMemo(() => migrateDoc(input), [input]);\n\n return (\n <Fragment>\n {includeStyles ? <style data-cms-styles=\"\">{emitDocCss(doc)}</style> : null}\n {rootIds(doc).map((id: string) => (\n <RenderNode key={id} doc={doc} id={id} registry={registry} data={data} />\n ))}\n </Fragment>\n );\n}\n"]}