@aglyn/besigner-ui 1.0.0 → 1.1.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.
@@ -16,7 +16,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
16
16
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
17
  * See the License for the specific language governing permissions and
18
18
  * limitations under the License.
19
- */ import { buildComponentDefaultIconPaths, buildComponentDefaultTokens, buildComponentDefaultValues, composeReusableComponentNodes, displayBindingTokens, FORM_COMPONENT_ID, hasBindings, HostViewType, LAYOUT_SLOT_COMPONENT_ID, NODE_ROOT_ID, placedFormPlacement, resolveBindings, resolveComponentPropTokens, REUSABLE_INSTANCE_COMPONENT_ID } from "@aglyn/aglyn";
19
+ */ import { buildComponentDefaultIconPaths, buildComponentDefaultTokens, buildComponentDefaultValues, composeReusableComponentNodes, displayBindingTokens, FORM_COMPONENT_ID, hasBindings, HostViewType, isNodeHiddenByHost, LAYOUT_SLOT_COMPONENT_ID, NODE_ROOT_ID, placedFormPlacement, resolveBindings, resolveComponentPropTokens, REUSABLE_INSTANCE_COMPONENT_ID } from "@aglyn/aglyn";
20
20
  import { Branch, Leaf, RendererComponents, Stem, Trunk } from "@aglyn/aglyn-node-renderer";
21
21
  import * as Besigner from "@aglyn/besigner";
22
22
  import { alpha, Box, useTheme } from "@mui/material";
@@ -27,6 +27,7 @@ import { requestAttributeFocus } from "../utils/attribute-focus-request.js";
27
27
  import BindingPickerContext from "../contexts/binding-picker-context.js";
28
28
  import CanvasChromeThemeContext from "../contexts/canvas-chrome-theme-context.js";
29
29
  import CanvasRevealContext, { CanvasMutedClassesContext } from "../contexts/canvas-reveal-context.js";
30
+ import CanvasHostTokensContext from "../contexts/canvas-host-tokens-context.js";
30
31
  import ComponentPromotionContext from "../contexts/component-promotion-context.js";
31
32
  import { useRenderedCanvasElements } from "../contexts/rendered-canvas-elements.js";
32
33
  import useAglynBesignerFlag from "../hooks/use-aglyn-besigner-flag.js";
@@ -57,10 +58,14 @@ import { REPEAT_COPY_ATTR } from "../utils/repeat-copy.js";
57
58
  const { node } = props, rest = _object_without_properties_loose(props, [
58
59
  "node"
59
60
  ]);
61
+ const host = useContext(CanvasHostTokensContext);
60
62
  const withBindings = useNodeWithBindings(node);
61
63
  const withHostTokens = useNodeWithHostTokens(withBindings);
62
64
  const withRecord = useNodeWithRepeatRecord(withHostTokens);
63
65
  const shown = useNodeWithMediaAssetFacts(withRecord);
66
+ // What the site's own values hide is not on the published page (AGL-4119),
67
+ // and these nodes are never selected, so here it is simply not drawn.
68
+ if (host && isNodeHiddenByHost(node == null ? void 0 : node.props, host)) return null;
64
69
  return /*#__PURE__*/ _jsx(Leaf, _extends({
65
70
  ref: ref,
66
71
  node: shown
@@ -380,6 +385,7 @@ export const NodeLeaf = observer(/*#__PURE__*/ forwardRef((props, ref)=>{
380
385
  // context rather than the flag itself: the canvas subscribes once and
381
386
  // every leaf reads the result.
382
387
  const revealedNodeIds = useContext(CanvasRevealContext);
388
+ const canvasHost = useContext(CanvasHostTokensContext);
383
389
  const mutedClasses = useContext(CanvasMutedClassesContext);
384
390
  // WYSIWYG bindings (AGL-97): resolve variable/function tokens
385
391
  // live on the rendered copy (selection/dnd keep the original node).
@@ -729,6 +735,19 @@ export const NodeLeaf = observer(/*#__PURE__*/ forwardRef((props, ref)=>{
729
735
  repeatPreview,
730
736
  shownLeafNode
731
737
  ]);
738
+ /**
739
+ * What the site's own values hide (AGL-4119), like a header's logo on a
740
+ * site that has none, or its name on one that does. The canvas shows what
741
+ * a visitor sees, and an element picked in the hierarchy shows for as long
742
+ * as it is being worked on, so it stays an ordinary element to edit.
743
+ * Through `hidden` on the render copy, never on the node that is saved.
744
+ */ const hostHidden = Boolean(canvasHost) && isNodeHiddenByHost(node == null ? void 0 : node.props, canvasHost) && !Besigner.focus.isNodeOrDescendantSelected(node) && !(revealedNodeIds == null ? void 0 : revealedNodeIds.some((id)=>id === (node == null ? void 0 : node.$id)));
745
+ const drawnNode = useMemo(()=>hostHidden ? _extends({}, leafNode, {
746
+ hidden: true
747
+ }) : leafNode, [
748
+ hostHidden,
749
+ leafNode
750
+ ]);
732
751
  return /*#__PURE__*/ _jsx(DraggableDroppable, {
733
752
  node: node,
734
753
  type: Besigner.DragType.CANVAS,
@@ -736,7 +755,7 @@ export const NodeLeaf = observer(/*#__PURE__*/ forwardRef((props, ref)=>{
736
755
  disableDragging: !Besigner.dnd.canDragNode(node),
737
756
  children: /*#__PURE__*/ _jsxs(Leaf, _extends({
738
757
  ref: registerElement,
739
- node: leafNode,
758
+ node: drawnNode,
740
759
  "data-aglyn-selected": Besigner.focus.isNodeSelected(node),
741
760
  // Present while the selection lives in this node's subtree (the
742
761
  // node itself or any descendant). Canvas-aware components (nav
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/node-leaf.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n buildComponentDefaultIconPaths,\n buildComponentDefaultTokens,\n buildComponentDefaultValues,\n composeReusableComponentNodes,\n displayBindingTokens,\n FORM_COMPONENT_ID,\n hasBindings,\n HostViewType,\n LAYOUT_SLOT_COMPONENT_ID,\n NODE_ROOT_ID,\n placedFormPlacement,\n resolveBindings,\n resolveComponentPropTokens,\n REUSABLE_INSTANCE_COMPONENT_ID,\n} from '@aglyn/aglyn'\nimport {\n Branch,\n Leaf,\n type LeafProps,\n RendererComponents,\n Stem,\n Trunk,\n} from '@aglyn/aglyn-node-renderer'\nimport * as Besigner from '@aglyn/besigner'\nimport { alpha, Box, useTheme } from '@mui/material'\nimport type { Theme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\nimport {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport useAglynBesignerPanel from '../hooks/use-aglyn-besigner-panel'\nimport { requestAttributeFocus } from '../utils/attribute-focus-request'\nimport BindingPickerContext from '../contexts/binding-picker-context'\nimport CanvasChromeThemeContext from '../contexts/canvas-chrome-theme-context'\nimport CanvasRevealContext, {\n CanvasMutedClassesContext,\n} from '../contexts/canvas-reveal-context'\nimport ComponentPromotionContext from '../contexts/component-promotion-context'\nimport { useRenderedCanvasElements } from '../contexts/rendered-canvas-elements'\nimport useAglynBesignerFlag from '../hooks/use-aglyn-besigner-flag'\nimport { useNodeWithMediaAssetFacts } from '../hooks/use-media-asset-facts-overlay'\nimport useNodeWithBindings from '../hooks/use-node-with-bindings'\nimport useNodeWithHostTokens from '../hooks/use-node-with-host-tokens'\nimport {\n useNodeWithRepeatRecord,\n useRepeatCopies,\n useRepeatPreview,\n} from '../hooks/use-repeat-preview'\nimport {\n RepeatRecordContext,\n RepeatTemplateContext,\n} from '../contexts/repeat-record-context'\nimport {\n isNodeHiddenOnSite,\n isNodeRevealedOnCanvas,\n} from '../utils/canvas-reveal'\nimport { stripMutedClasses } from '../utils/muted-classes'\nimport DraggableDroppable from './dnd/draggable-droppable'\nimport EmptyDocumentSlot from './empty-document-slot'\nimport { REPEAT_COPY_ATTR } from '../utils/repeat-copy'\n\n/**\n * The plain `Leaf`, drawing a node the way the published page composes it: its\n * site variables and functions resolved (AGL-3480), its host variables filled\n * in from the site being edited (AGL-2881), and a placed image or film with\n * its DAM asset's current facts (AGL-2838, AGL-2856).\n *\n * For the nodes the canvas renders that are not canvas nodes — a component\n * instance's definition, a placed form's design, the layout chrome — and so\n * never reach `NodeLeaf`. A header's `{{var:…}}` phone number still has to\n * read as the number, a footer's `{{host.businessName}}` as the site's name,\n * an asset inside one of them still has to show the shape the published page\n * gives it, and a film its poster. Bindings before host tokens, the order the\n * published page composes in.\n */\nexport const MediaFactsLeaf = forwardRef<any, LeafProps>((props, ref) => {\n const { node, ...rest } = props\n const withBindings = useNodeWithBindings(node)\n const withHostTokens = useNodeWithHostTokens(withBindings)\n const withRecord = useNodeWithRepeatRecord(withHostTokens)\n const shown = useNodeWithMediaAssetFacts(withRecord)\n return <Leaf ref={ref} node={shown} {...rest} />\n})\nMediaFactsLeaf.displayName = 'MediaFactsLeaf'\n\n/**\n * Renderer overrides for the inside of a component instance (AGL-1251).\n *\n * The plain `Leaf` (through `MediaFactsLeaf`), deliberately, where the canvas\n * otherwise uses `NodeLeaf`: the definition's nodes are NOT in the canvas, so\n * anything that made them draggable, selectable or droppable would be reaching\n * for canvas state that has no entry for them. Rendering them inert is not a\n * restriction bolted on afterwards — it is the only thing these nodes can be.\n */\nconst INERT_RENDERER = {\n TrunkComponent: Trunk,\n StemComponent: Stem,\n BranchComponent: Branch,\n LeafComponent: MediaFactsLeaf,\n}\n\n/**\n * Nested-object form of a normalized node map, which is what `Branch` walks\n * (`node.children`). Cycle-safe via `seen`: a definition that somehow\n * referenced an ancestor would otherwise recurse until the stack gave out.\n */\nexport function denormalizeTree(\n nodes: Record<string, any>,\n rootId: string,\n seen: Set<string> = new Set(),\n): any {\n const node = nodes?.[rootId]\n if (!node || seen.has(rootId)) return undefined\n seen.add(rootId)\n const childIds = Array.isArray(node.nodes) ? node.nodes : []\n return {\n ...node,\n children: childIds\n .map((childId: string) => denormalizeTree(nodes, childId, seen))\n .filter(Boolean),\n }\n}\n\nexport interface NodeLeafProps extends LeafProps {}\n\n/**\n * The console's theme for chrome drawn inside the canvas, or — outside one,\n * as in a spec — the theme in force.\n *\n * Inside the canvas `useTheme()` is the SITE's theme: editor chrome read from\n * it would repaint itself whenever a subscriber restyled their site, and the\n * slot marker once rendered pink instead of the console's blue that way.\n * See {@link CanvasChromeThemeContext}.\n */\nfunction useChromeTheme(): Theme {\n const theme = useTheme()\n return useContext(CanvasChromeThemeContext) ?? theme\n}\n\n/**\n * Visible placement marker for the LayoutSlot while editing a layout. The\n * slot is a passthrough at runtime, so without this it disappears once it\n * has children and designers lose track of where screen content lands.\n */\nconst SlotMarker = ({ caption }: { caption?: string }) => {\n const accent = useChromeTheme().palette.primary.main\n return (\n <Box\n aria-hidden\n data-aglyn-slot-marker=\"\"\n sx={{\n m: 1,\n p: 2,\n minHeight: 64,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 0.5,\n borderWidth: 2,\n borderStyle: 'dashed',\n // Brand blue on a faint tint, not a grey dashed box: the slot is the\n // one region the layout does not own, and it should not read as just\n // another empty container.\n borderColor: accent,\n backgroundColor: alpha(accent, 0.06),\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n textAlign: 'center',\n }}\n >\n <Box component=\"span\" sx={{ color: accent, fontWeight: 'fontWeightBold' }}>\n {'◇ layout-slot'}\n </Box>\n <Box component=\"span\">{caption || 'Page content renders here'}</Box>\n </Box>\n )\n}\n\n/**\n * A repeat copy's root as the canvas draws it: hidden from assistive\n * technology, since it repeats what the real element already says, stamped so\n * {@link repeatCopyCss} can outline it, and titled so the pointer is told what\n * it is over — a click on a copy selects the element it repeats, which with no\n * word of explanation looks like the canvas picking the wrong thing.\n */\nfunction asRepeatCopy(copy: any, label: string) {\n return {\n ...copy,\n props: {\n ...copy.props,\n 'aria-hidden': true,\n [REPEAT_COPY_ATTR]: '',\n title:\n `A copy for the next record of ${label}. ` +\n 'Click to select the element it repeats — edit that one, and every copy follows.',\n },\n }\n}\n\n/**\n * The copies' outline: dashed `rest` grey, and dashed `hover` grey on the\n * copies of the element being pointed at — the real one or a copy of it.\n */\nfunction repeatCopyCss(rest: string, hover: string, hovered?: string) {\n const copy = `[${REPEAT_COPY_ATTR}]`\n return (\n `${copy}{outline:1px dashed ${rest};outline-offset:-1px}` +\n (hovered\n ? `${copy}[data-aglyn$=\"__${hovered}\"]{outline-color:${hover}}`\n : '')\n )\n}\n\n/**\n * What the badge says, and what hovering it explains (AGL-3111).\n *\n * The short line names the source and what the page gets. The two states that\n * render nothing on the published page (AGL-3496) say so in plain words, and\n * their explanation says why and where to fix it — \"Dataset not found ·\n * hidden on the live site\" told an author something was wrong and nothing\n * about what, or what to do.\n */\nexport function repeatBadgeText({\n label,\n count,\n missing,\n}: {\n label: string\n count: number\n missing?: boolean\n}): { text: string; explanation: string } {\n const fix =\n 'Click this badge to fix it: it opens Repeat over dataset in the Attributes panel, where you choose another.'\n if (missing) {\n return {\n text: `⟳ ${label} not available · not shown on your site`,\n explanation:\n `This element repeats once per record of a ${label.toLowerCase()} this site can’t read — ` +\n 'it was deleted, or it isn’t shared with this site. Until that changes, your published page shows none of it. ' +\n fix,\n }\n }\n if (!count) {\n return {\n text: `⟳ Repeats ${label} · no records match · not shown on your site`,\n explanation:\n `No record of ${label} matches this repeat, so your published page shows none of it. ` +\n 'Add records to the dataset, or click this badge and loosen the Repeat filter in the Attributes panel.',\n }\n }\n return {\n text: `⟳ Repeats ${label} · ${count} ${count === 1 ? 'record' : 'records'}`,\n explanation:\n `This element repeats once per record of ${label}: ${count} on your published page. ` +\n 'Edit the first one; the copies after it follow.',\n }\n}\n\n/**\n * The repeat badge (AGL-3111), in the console's chrome colours rather than\n * the site's — see {@link useChromeTheme}. It cannot reach a published page:\n * only `NodeLeaf` draws it, and a published page is composed from stored nodes\n * and rendered through the plain `Leaf`.\n *\n * It takes the pointer, unlike the rest of the chrome here, so hovering it can\n * explain itself, and a click on it selects the repeating element and opens\n * Repeat over dataset in the Attributes panel — the setting it talks about.\n */\nconst RepeatBadge = ({\n nodeId,\n label,\n count,\n missing,\n}: {\n nodeId: string\n label: string\n count: number\n missing?: boolean\n}) => {\n const chrome = useChromeTheme()\n const [, setRightPanel] = useAglynBesignerPanel('panelRight')\n // The setter is a new function every render; the listener reads it here.\n const setRightPanelRef = useRef(setRightPanel)\n setRightPanelRef.current = setRightPanel\n const badgeRef = useRef<HTMLDivElement>(null)\n // A native listener, as everywhere on this canvas: React delegates at the\n // root container and the canvas is a closed shadow root. On the PRESS, not\n // the click: the press selects the repeating element (it bubbles to that\n // element's own handlers), the selection's overlay then covers the badge,\n // and the release lands on the overlay — a `click` never reaches the badge.\n useEffect(() => {\n const badge = badgeRef.current\n if (!badge) return undefined\n const open = (event: Event) => {\n // A secondary button opens the context menu instead.\n if (((event as PointerEvent).button ?? 0) > 0) return\n requestAttributeFocus(nodeId, 'repeatDataset')\n try {\n setRightPanelRef.current((prev) => ({\n ...prev,\n toggled: true,\n tab: Besigner.BesignerPanelTabFlag.ELEMENT_PROPS_FORM,\n }))\n } catch {\n // No besigner app around this leaf, so no panel to open.\n }\n }\n badge.addEventListener('pointerdown', open)\n return () => badge.removeEventListener('pointerdown', open)\n }, [nodeId])\n // The slate where it exists — the console's theme always has it — and the\n // primary where a bare theme does not (a spec, a host without the console).\n const tone = count\n ? (chrome.palette.tertiary ?? chrome.palette.primary)\n : chrome.palette.warning\n const { text, explanation } = repeatBadgeText({ label, count, missing })\n const radius = chrome.shape.borderRadius\n return (\n <Box\n ref={badgeRef}\n aria-hidden\n data-aglyn-repeat-badge=\"\"\n data-aglyn-repeat-empty={count ? undefined : ''}\n title={explanation}\n sx={{\n // Out of the element's own layout: a badge that took part in a flex row\n // would move the design it is describing.\n position: 'absolute',\n top: 0,\n right: 0,\n zIndex: 2,\n cursor: 'pointer',\n px: 0.75,\n py: 0.25,\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n borderBottomLeftRadius: typeof radius === 'number' ? `${radius}px` : radius,\n backgroundColor: tone.main,\n color: tone.contrastText,\n fontFamily: chrome.typography.fontFamily,\n fontSize: chrome.typography.caption.fontSize,\n fontWeight: chrome.typography.fontWeightBold,\n lineHeight: chrome.typography.caption.lineHeight,\n // A Stack's spacing gives every child after the first a top margin,\n // which moved the badge down off the corner; doubled to outrank it.\n '&&': { m: 0 },\n }}\n >\n {text}\n </Box>\n )\n}\n\nexport const NodeLeaf = observer(\n forwardRef<any, NodeLeafProps>((props, ref) => {\n const { node, children, ...rest } = props\n const [viewType] = useAglynBesignerFlag('viewType')\n // The canvas element registry, finally given a WRITER (AGL-2486).\n //\n // `RenderedCanvasElementsProvider` has existed since the registry was\n // introduced and `setElementRef`/`deleteElementRef` were called from\n // NOWHERE in the repo — `elements.current` was `{}` for the life of every\n // session. Everything that reads it therefore read an empty map and\n // failed the only way an empty map can: silently.\n //\n // Two features were void because of it, and neither logged anything:\n //\n // `usePresence`'s cursor broadcast resolves the canvas root through\n // this registry and bails with `if (!root) return`, so no editor has\n // EVER written a cursor position. Confirmed against production RTDB on\n // 2026-08-22: three live presence entries across three rooms, not one\n // carrying `cursorX`/`cursorY`.\n //\n // `CollaboratorOverlays` resolves both the canvas root and each peer's\n // selected node here, so `placements` was always empty and the overlay\n // returned null. Confirmed live in the running console: a collaborator\n // entry carrying both a cursor and a selection rendered its avatar and\n // drew no cursor, no selection box and no name label.\n //\n // Registering here rather than in the renderer keeps it to the canvas:\n // `NodeLeaf` is the besigner's leaf component, so component-definition\n // previews (which render the plain `Leaf` through `INERT_RENDERER`) stay\n // out of the registry — they are not in the canvas and must not be\n // addressable as though they were.\n //\n // `NODE_ROOT_ID` and `CANVAS_ROOT_ELEMENT_ID` are the same string\n // (`'_@_'`), so keying on `$id` registers the canvas root under the id\n // the cursor code already looks for, with no special case.\n const { elements, setElementRef, deleteElementRef } =\n useRenderedCanvasElements()\n const $id = node?.$id\n // What THIS leaf last put in the registry. A remount can hand the new\n // element its ref before the old one is cleared, so an unconditional\n // delete on `null` would evict the live registration and put the\n // registry back to the state this whole change exists to fix.\n const registered = useRef<Element | null>(null)\n const registerElement = useCallback(\n (element: unknown) => {\n // Forward FIRST and unconditionally: dnd and the renderer already\n // depend on this ref, and registration must never change what they\n // observe.\n if (typeof ref === 'function') ref(element)\n else if (ref) (ref as { current: unknown }).current = element\n if (!$id) return\n if (element instanceof Element) {\n registered.current = element\n setElementRef($id, {\n $id,\n node: element,\n dragHandle: undefined,\n } as never)\n return\n }\n // Cleared (or never a DOM element — a class instance, say). Only\n // withdraw the registration if it is still OURS.\n const current = elements?.current?.[$id]?.node\n if (!registered.current || current === registered.current) {\n deleteElementRef($id)\n }\n registered.current = null\n },\n [ref, $id, elements, setElementRef, deleteElementRef],\n )\n const showSlotMarker =\n node?.componentId === LAYOUT_SLOT_COMPONENT_ID &&\n viewType === HostViewType.LAYOUT\n // A document with no nodes has nothing to aim at. Wrapped in a shared\n // layout it is worse than empty — the slot passes its children straight\n // through, so the root collapses to a zero-height strip between locked\n // chrome and the nav renders directly into the footer. Hung off the ROOT\n // leaf, which is already inside `DraggableDroppable`, so giving it height\n // is all a drop needs to resolve against the document root.\n const showEmptyDocumentSlot =\n node?.$id === NODE_ROOT_ID &&\n !node?.nodes?.length &&\n viewType !== HostViewType.LAYOUT\n\n // Nodes the author has opened up for designing (AGL-592). Through a\n // context rather than the flag itself: the canvas subscribes once and\n // every leaf reads the result.\n const revealedNodeIds = useContext(CanvasRevealContext)\n const mutedClasses = useContext(CanvasMutedClassesContext)\n\n // WYSIWYG bindings (AGL-97): resolve variable/function tokens\n // live on the rendered copy (selection/dnd keep the original node).\n // Bound nodes are flagged either way so editors can spot them.\n const [resolveFlag] = useAglynBesignerFlag('resolveBindings')\n const { variables, functions, componentProps } = useContext(\n BindingPickerContext,\n )\n const boundProps = useMemo(\n () =>\n Object.entries(node?.props ?? {}).filter(\n ([, value]) => typeof value === 'string' && hasBindings(value),\n ),\n // MobX props are observable; the JSON string keys the memo cheaply.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [node, JSON.stringify(node?.props ?? {})],\n )\n /**\n * A component editor draws with the definition's OWN defaults\n * (AGL-2870), so `{{prop.headline}}` shows the headline and a film with a\n * default source actually plays.\n *\n * Only props that HAVE a default are substituted. One without stays a\n * visible token, which is the signal an author needs: the slot is real\n * and nothing fills it yet. Substituting `''` there would draw an empty\n * component and hide the very thing they still have to decide.\n *\n * On a screen this path does nothing — the props belong to the component\n * route, and an instance is composed through `composeReusableComponentNodes`\n * below, which is the single substitution path a published page uses.\n */\n const defaultPropTokens = useMemo(\n () => buildComponentDefaultTokens(componentProps),\n [componentProps],\n )\n // The paths of the default icons, which a field bound to an icon property\n // draws with — the editor has no reason to have loaded the icon catalog.\n const defaultIconPaths = useMemo(\n () => buildComponentDefaultIconPaths(componentProps),\n [componentProps],\n )\n // The values the defaults hand their bound fields (AGL-2893), so a list\n // stays a list and a theme multiple a number on the editor's canvas too.\n const defaultValues = useMemo(\n () => buildComponentDefaultValues(componentProps),\n [componentProps],\n )\n const renderNode = useMemo(() => {\n const hasDeclaredProps = Boolean(componentProps?.length)\n if (\n !boundProps.length ||\n (!Object.keys(variables ?? {}).length &&\n !Object.keys(functions ?? {}).length &&\n !hasDeclaredProps)\n ) {\n return node\n }\n const resolved: Record<string, unknown> = { ...(node?.props ?? {}) }\n for (const [key, value] of boundProps) {\n // Resolve toggle off → show friendly token text: id tokens map to\n // the referent's CURRENT name (AGL-186), never raw doc ids.\n resolved[key] =\n resolveFlag === false\n ? displayBindingTokens(\n value as string,\n (variables ?? {}) as any,\n (functions ?? {}) as any,\n )\n : resolveBindings(\n value as string,\n (variables ?? {}) as any,\n (functions ?? {}) as any,\n )\n }\n const next = { ...node, props: resolved }\n if (!hasDeclaredProps) return next\n // Through the same substitution a placed instance uses, keyed by this\n // node alone — one code path deciding what a token becomes, never two\n // that could disagree.\n //\n // The raw-token view substitutes no defaults: an author who turned\n // resolution OFF asked to see the tokens, and a default is a resolved\n // value like any other. A field bound to a Yes/no property still\n // receives a yes or a no there, because a switch has no way to show a\n // token and reads the token's text as a yes.\n return (\n resolveComponentPropTokens(\n { [String(node?.$id)]: next as any },\n componentProps,\n resolveFlag === false ? undefined : defaultPropTokens,\n resolveFlag === false ? undefined : defaultIconPaths,\n resolveFlag === false ? undefined : defaultValues,\n )[String(node?.$id)] ?? next\n )\n }, [\n node,\n boundProps,\n resolveFlag,\n variables,\n functions,\n componentProps,\n defaultPropTokens,\n defaultIconPaths,\n defaultValues,\n ])\n\n // Host variables (AGL-2881), filled in on the same render copy and after\n // the bindings and the component's own defaults, which is the order the\n // published page composes in: a default that names the host resolves\n // too. The raw-token view reaches this leaf as no site at all\n // (`CanvasHostTokensProvider`), so its tokens stay as written. Keyed by\n // `boundProps`, which follows the observable props this copy reads.\n const hostResolvedNode = useNodeWithHostTokens(renderNode, boundProps)\n\n // Classes switched off for comparison (AGL-2486). Composed onto the SAME\n // render copy the binding resolution builds, never onto the canvas node:\n // selection, the hierarchy and every save keep reading the element's real\n // class list, and the canvas paints without the switched-off names.\n const renderNodeUnclassed = useMemo(\n () =>\n stripMutedClasses(hostResolvedNode as never, node?.$id, mutedClasses),\n [hostResolvedNode, node, mutedClasses],\n )\n\n /**\n * The record a repeat above this one is drawing (AGL-3111).\n *\n * Applied in the same place, and for the same reason, as the host tokens\n * and the DAM facts above: the published page substitutes `{{item.*}}`\n * when it composes, so the canvas substitutes it on the render copy while\n * the node keeps the tokens every save writes.\n */\n const withRepeatRecord = useNodeWithRepeatRecord(renderNodeUnclassed)\n\n // A placed asset's shape, and a film's length and poster, as its DAM\n // document records them NOW (AGL-2838, AGL-2856). The published page lays\n // the asset over the node when it is composed, so the canvas lays it over\n // the same render copy: a replace shows here as it shows to a visitor,\n // while selection, the panels and every save keep reading the node's\n // stored props.\n const shownNode = useNodeWithMediaAssetFacts(withRepeatRecord)\n\n /**\n * What this element repeats over, and the copies it draws (AGL-3111).\n *\n * The first record's copy is the element's own children — real canvas\n * nodes an author selects, drags and edits — with that record laid over\n * their render copies through {@link RepeatRecordContext}. Records 2..n\n * are inert pictures of the same template, built by the page's own\n * expansion. Editing the template therefore edits every copy, because\n * there is only ever one.\n */\n const repeatPreview = useRepeatPreview(node)\n const repeatCopies = useRepeatCopies(node, repeatPreview)\n const theme = useTheme()\n // Only a leaf drawing copies reads the hover, so only those re-render as\n // the pointer moves; the id is CSS-safe or ignored.\n const hovered = repeatCopies.length\n ? Besigner.focus.getHovered()?.$id\n : undefined\n const hoveredInRepeat =\n hovered && /^[\\w-]+$/.test(hovered) ? hovered : undefined\n const firstRecord = useMemo(\n () =>\n // No record to draw (AGL-3496): the template shows as written, and\n // the badge says the live site renders none of it.\n repeatPreview?.records.length\n ? {\n record: repeatPreview.records[0],\n model: repeatPreview.dataset?.model,\n datasetsByKey: repeatPreview.datasetsByKey,\n }\n : undefined,\n [repeatPreview],\n )\n\n // A component instance renders its definition (AGL-1251) instead of the\n // named dashed box. Authors placed a hero and saw a grey rectangle, so\n // the props they filled in were invisible until Preview.\n //\n // Rendered, never grafted: the definition's nodes stay out of the canvas\n // entirely. That is what makes this safe — there is nothing to lock,\n // nothing to strip before a save, and no way for a definition's node to\n // be persisted into the document that placed it. Same shape as the\n // binding resolution above, which renders a resolved copy while\n // selection and dnd keep the original node.\n const { definitions, formDesigns } = useContext(ComponentPromotionContext)\n const instanceTree = useMemo(() => {\n if (node?.componentId !== REUSABLE_INSTANCE_COMPONENT_ID) {\n return undefined\n }\n // Already expanded into this canvas — the layout-chrome store grafts\n // before it loads (AGL-1218), so its instances arrive with children.\n // Rendering here too would draw the nav twice.\n if (node?.nodes?.length) return undefined\n const props = (node?.props ?? {}) as { refId?: string }\n const definition = props.refId ? definitions?.[props.refId] : undefined\n if (!definition?.nodes || !definition?.rootId) return undefined\n // Plain snapshot: props are MobX observables and the graft reads nested\n // `propValues` off them. The placement's classes stay out of it, as its\n // `sx` does: this leaf already renders both on the element around the\n // preview, and the graft joins a placement's classes onto the root it\n // becomes. Handed them here, the preview's root would apply every class\n // a second time, and keep `aglyn-hidden` collapsed inside a placement\n // the canvas has revealed for designing.\n const { className: _placementClasses, ...snapshotProps } = JSON.parse(\n JSON.stringify(node.props ?? {}),\n ) as Record<string, unknown>\n // Reuse the real graft so the canvas resolves `{{prop.*}}` exactly as\n // the published page will — one substitution path, not a second one\n // that could disagree about which value wins.\n const composed = composeReusableComponentNodes(\n {\n [node.$id]: {\n $id: node.$id,\n componentId: REUSABLE_INSTANCE_COMPONENT_ID,\n props: snapshotProps,\n // Root style overrides (AGL-1306) ride the same snapshot so\n // the canvas renders the SAME merged root sx the published\n // page will — the graft is the one merge point.\n ...(node.styleOverrides && {\n styleOverrides: JSON.parse(JSON.stringify(node.styleOverrides)),\n }),\n // Attribute overrides ride the same snapshot for the same\n // reason (AGL-1899). Leaving them out is invisible rather than\n // broken: Preview and tenant SSR compose from the stored node\n // and WOULD apply them, so the canvas alone would draw the\n // component's own attributes and disagree with both.\n ...(node.attrOverrides && {\n attrOverrides: JSON.parse(JSON.stringify(node.attrOverrides)),\n }),\n nodes: [],\n } as any,\n },\n // The host's WHOLE definitions map, not just this instance's own\n // (AGL-1898). A definition may contain instances of OTHER\n // definitions, and `composeReusableComponentNodes` expands those —\n // but only the ones it is handed. Preview, tenant SSR and the\n // layout-chrome graft all pass the full map, so a one-entry map\n // here made the canvas the only surface that left a nested\n // component as an unexpanded placeholder.\n //\n // It also silently voided propagation for the inner component:\n // publishing a shared button re-rendered every canvas showing it\n // directly and none of the ones showing it through the nav that\n // contains it — which is the case a shared component is usually in.\n //\n // Safe to widen because the `nodes` argument above is this ONE\n // instance: the extra definitions can only be reached from inside\n // the subtree being grafted, never applied to some other node.\n definitions as any,\n )\n // The graft puts the definition's root IN the instance's place rather\n // than under it (AGL-2521), so the component to draw is at the\n // instance's own id. Reading `nodes[0]` here would render the root's\n // FIRST CHILD and drop the component's outer element with its siblings.\n const grafted = composed[node.$id]\n return grafted && grafted.componentId !== REUSABLE_INSTANCE_COMPONENT_ID\n ? denormalizeTree(composed, node.$id)\n : undefined\n // Observable props/overrides: the JSON strings key the memo, as above.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n node,\n JSON.stringify(node?.props ?? {}),\n JSON.stringify(node?.styleOverrides ?? {}),\n JSON.stringify(node?.attrOverrides ?? {}),\n definitions,\n ])\n\n /**\n * A placed form draws its ENTITY'S published fields, not the page's copy\n * of them (`docs/specs/reusable-forms.md`).\n *\n * The same render-copy treatment the instance above gets, and for the same\n * reason: the entity's nodes stay out of the canvas, so there is nothing to\n * lock, nothing to strip before a save, and no way for a form's fields to\n * be persisted into the screen that placed it.\n *\n * It runs the REAL graft rather than reading `design.nodes` directly, so a\n * component nested inside the form design expands here exactly as it will\n * on the published page — one resolution path, not a second that could\n * disagree.\n *\n * When it resolves, the node's own children are not rendered (below): the\n * published page discards them, and a canvas that drew both would show the\n * author a page that does not exist. Where the entity has no published\n * design the memo is `undefined`, the children render, and the form the\n * author drew is the form they see — which is every form built before the\n * entity existed.\n */\n const placedForm = useMemo(() => {\n if (node?.componentId !== FORM_COMPONENT_ID) return undefined\n const formId = (node?.props as { formId?: unknown } | undefined)?.formId\n if (typeof formId !== 'string' || !formId) return undefined\n const composed = composeReusableComponentNodes(\n {\n [node.$id]: {\n $id: node.$id,\n componentId: FORM_COMPONENT_ID,\n // Plain snapshot: props are MobX observables, as above.\n props: JSON.parse(JSON.stringify(node.props ?? {})),\n // The placement's own sx and its per-page override slices\n // (AGL-3285) ride the snapshot as they do for an instance above:\n // the replacement below is what this leaf draws, so a slice left\n // out here would render on Preview and the live page but not on\n // the canvas.\n ...(node.sx !== undefined && {\n sx: JSON.parse(JSON.stringify(node.sx)),\n }),\n // Joined with the design root's by the graft (AGL-3494), so the\n // replacement's class list is the whole one the page draws.\n ...(typeof (node as { className?: unknown }).className ===\n 'string' && {\n className: (node as { className?: unknown }).className,\n }),\n ...(node.styleOverrides && {\n styleOverrides: JSON.parse(JSON.stringify(node.styleOverrides)),\n }),\n ...(node.attrOverrides && {\n attrOverrides: JSON.parse(JSON.stringify(node.attrOverrides)),\n }),\n nodes: [],\n } as any,\n },\n // Component definitions ride along so an instance INSIDE the form\n // design expands; the map is safe to pass whole for the reason the\n // instance graft above states — the one node handed in is this form.\n definitions as any,\n [placedFormPlacement(formDesigns as any)],\n )\n /*\n * The composed REPLACEMENT is the node the published page draws in this\n * placement's place — the design's root, carrying the placement's id\n * (AGL-2521) — and its children are the design's own.\n *\n * Reading the replacement rather than the placement is what keeps the\n * canvas honest about the element itself. A real form design is a\n * container holding the `form` node, so the placement's `form` used to\n * be drawn AROUND the design's: two `<form>` elements nested, each\n * drawing its own send button, where a visitor sees one. Taking only\n * the first child also dropped everything a design put beside its form.\n */\n const replacement = composed[node.$id]\n const childIds = (replacement?.nodes as string[] | undefined) ?? []\n if (!replacement || !childIds.length) return undefined\n const trees = childIds\n .map((childId) => denormalizeTree(composed, childId))\n .filter(Boolean)\n return trees.length ? { replacement, trees } : undefined\n // Observable props: the JSON string keys the memo, as above.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n node,\n JSON.stringify(node?.props ?? {}),\n JSON.stringify(node?.sx ?? {}),\n (node as { className?: unknown } | undefined)?.className,\n JSON.stringify(node?.styleOverrides ?? {}),\n JSON.stringify(node?.attrOverrides ?? {}),\n definitions,\n formDesigns,\n ])\n\n /**\n * The element this leaf DRAWS, once a placed form resolves.\n *\n * The published page renders the entity's root here, not the placement:\n * the two denote the same element and the graft merges them. The canvas\n * draws the same one, so an author sees the form their visitors will. As\n * with the DAM facts and the host tokens above, this is a render copy —\n * selection, the panels and every save keep reading `node`.\n */\n const shownLeafNode = useMemo(\n () =>\n placedForm\n ? ({\n ...(shownNode as Record<string, unknown>),\n componentId: placedForm.replacement.componentId,\n props: (placedForm.replacement.props ?? {}) as never,\n ...(placedForm.replacement.sx === undefined\n ? {}\n : { sx: placedForm.replacement.sx }),\n // The design root's classes joined with the placement's\n // (AGL-3494), as the published page draws them.\n ...((placedForm.replacement as { className?: unknown })\n .className === undefined\n ? {}\n : {\n className: (placedForm.replacement as { className?: unknown })\n .className,\n }),\n } as typeof shownNode)\n : shownNode,\n [placedForm, shownNode],\n )\n\n /**\n * A repeating element is the box its badge is placed in.\n *\n * The badge sits at the element's top right, which only holds when the\n * element is positioned; in a plain Stack it attached to the nearest\n * positioned ancestor instead, so two repeats in one container drew both\n * badges in the same corner, the second over the first. The canvas copy\n * gets `position: relative` — never the stored node, and never over a\n * position the author set.\n */\n const leafNode = useMemo(() => {\n if (!repeatPreview) return shownLeafNode\n const sx = (shownLeafNode as { sx?: unknown })?.sx\n if (sx != null && (typeof sx !== 'object' || Array.isArray(sx))) {\n return shownLeafNode\n }\n if (sx && 'position' in (sx as Record<string, unknown>)) {\n return shownLeafNode\n }\n return {\n ...(shownLeafNode as Record<string, unknown>),\n sx: { ...((sx as Record<string, unknown> | undefined) ?? {}), position: 'relative' },\n } as typeof shownLeafNode\n }, [repeatPreview, shownLeafNode])\n\n return (\n <DraggableDroppable\n node={node}\n type={Besigner.DragType.CANVAS}\n accept={Object.values(Besigner.DragType)}\n disableDragging={!Besigner.dnd.canDragNode(node)}\n >\n <Leaf\n ref={registerElement}\n node={leafNode as typeof node}\n data-aglyn-selected={Besigner.focus.isNodeSelected(node)}\n // Present while the selection lives in this node's subtree (the\n // node itself or any descendant). Canvas-aware components (nav\n // menus, drawers) read this neutral leaf attribute to expand\n // only while they are being authored (AGL-571). Presence-based\n // (''/undefined) so unaffected leaves carry no attribute.\n data-aglyn-selected-within={\n Besigner.focus.isNodeOrDescendantSelected(node) ? '' : undefined\n }\n // Present on an element that carries the hidden class while the\n // canvas is showing it anyway (AGL-592) — the flag the canvas\n // stylesheet checks before collapsing it. Stamped on the hidden\n // element itself, so no wrapper a component renders around its\n // children can come between the two.\n data-aglyn-revealed={\n isNodeHiddenOnSite(node) &&\n isNodeRevealedOnCanvas(node, revealedNodeIds)\n ? ''\n : undefined\n }\n data-aglyn-bound={boundProps.length ? '' : undefined}\n {...rest}\n >\n {/* A resolved form entity REPLACES the page's own fields, exactly\n as the published page composes it — see `placedForm`. */}\n {placedForm ? null : firstRecord ? (\n // The template IS the first copy: the real children, drawing the\n // first record. Provided around them rather than applied to them,\n // so every descendant leaf resolves its own tokens the way the\n // page's substitution walks the whole cloned subtree.\n <RepeatRecordContext.Provider value={firstRecord}>\n {children}\n </RepeatRecordContext.Provider>\n ) : repeatPreview ? (\n // No record to draw (AGL-3496): the template as written, its\n // `{{item.*}}` tokens drawn as named chips.\n <RepeatTemplateContext.Provider value>\n {children}\n </RepeatTemplateContext.Provider>\n ) : (\n children\n )}\n {repeatCopies.length ? (\n // The copies are drawn as the live page draws them: siblings of\n // the real children, in this element's own layout. They used to\n // sit in a wrapper box, which took one share of the parent's\n // spacing for all of them, so Sam and Jordan stacked tight under\n // a gap that only Avery got.\n //\n // Inert, like the component and form previews below: a copy is a\n // picture of the template, not a document, so nothing in it is\n // ever selected. A click on one goes to the element it draws —\n // this leaf's own handlers redirect it (`repeatCopyAt`).\n <>\n {/* Their outline, as CSS rather than as a wrapper: a dimmed,\n dashed GREY, so a copy never reads as the element — the\n real one keeps the canvas's hover and selection colours.\n Dashed when hovered too, only darker; solid is the\n selection's alone. MUI's Stack spacing skips <style>\n children, so this costs the layout nothing. */}\n <style>\n {repeatCopyCss(\n alpha(theme.palette.grey[500], 0.6),\n alpha(theme.palette.grey[800], 0.9),\n hoveredInRepeat,\n )}\n </style>\n <RendererComponents.Provider value={INERT_RENDERER as any}>\n {repeatCopies.map((copy) => (\n <Stem\n key={copy.$id}\n node={asRepeatCopy(copy, repeatPreview?.label ?? '')}\n />\n ))}\n </RendererComponents.Provider>\n </>\n ) : null}\n {repeatPreview ? (\n <RepeatBadge\n nodeId={node.$id}\n label={repeatPreview.label}\n count={repeatPreview.records.length}\n missing={repeatPreview.missing}\n />\n ) : null}\n {placedForm ? (\n // Inert and click-through like the instance preview below: the\n // fields belong to the form, and they are edited in the form's own\n // besigner, so the only selectable thing here is the placement.\n <Box sx={{ pointerEvents: 'none' }} data-aglyn-form-preview=\"\">\n <RendererComponents.Provider value={INERT_RENDERER as any}>\n {placedForm.trees.map((tree) => (\n <Stem key={tree.$id} node={tree} />\n ))}\n </RendererComponents.Provider>\n </Box>\n ) : null}\n {instanceTree ? (\n // `pointerEvents: none` so a click anywhere on the rendered\n // component still lands on the instance beneath it — the\n // instance is the only thing here that can be selected, and the\n // only thing whose Attributes are editable.\n <Box sx={{ pointerEvents: 'none' }} data-aglyn-component-preview=\"\">\n <RendererComponents.Provider value={INERT_RENDERER as any}>\n <Stem node={instanceTree} />\n </RendererComponents.Provider>\n </Box>\n ) : null}\n {showSlotMarker ? (\n <SlotMarker\n caption={node?.props?.['caption'] as string | undefined}\n />\n ) : null}\n {showEmptyDocumentSlot ? <EmptyDocumentSlot /> : null}\n </Leaf>\n </DraggableDroppable>\n )\n }),\n)\nNodeLeaf.displayName = 'BesignerLeafComponent'\nNodeLeaf.aglyn = true\n\nexport default NodeLeaf\n"],"names":["buildComponentDefaultIconPaths","buildComponentDefaultTokens","buildComponentDefaultValues","composeReusableComponentNodes","displayBindingTokens","FORM_COMPONENT_ID","hasBindings","HostViewType","LAYOUT_SLOT_COMPONENT_ID","NODE_ROOT_ID","placedFormPlacement","resolveBindings","resolveComponentPropTokens","REUSABLE_INSTANCE_COMPONENT_ID","Branch","Leaf","RendererComponents","Stem","Trunk","Besigner","alpha","Box","useTheme","observer","forwardRef","useCallback","useContext","useEffect","useMemo","useRef","useAglynBesignerPanel","requestAttributeFocus","BindingPickerContext","CanvasChromeThemeContext","CanvasRevealContext","CanvasMutedClassesContext","ComponentPromotionContext","useRenderedCanvasElements","useAglynBesignerFlag","useNodeWithMediaAssetFacts","useNodeWithBindings","useNodeWithHostTokens","useNodeWithRepeatRecord","useRepeatCopies","useRepeatPreview","RepeatRecordContext","RepeatTemplateContext","isNodeHiddenOnSite","isNodeRevealedOnCanvas","stripMutedClasses","DraggableDroppable","EmptyDocumentSlot","REPEAT_COPY_ATTR","MediaFactsLeaf","props","ref","node","rest","withBindings","withHostTokens","withRecord","shown","displayName","INERT_RENDERER","TrunkComponent","StemComponent","BranchComponent","LeafComponent","denormalizeTree","nodes","rootId","seen","Set","has","undefined","add","childIds","Array","isArray","children","map","childId","filter","Boolean","useChromeTheme","theme","SlotMarker","caption","accent","palette","primary","main","aria-hidden","data-aglyn-slot-marker","sx","m","p","minHeight","display","flexDirection","alignItems","justifyContent","gap","borderWidth","borderStyle","borderColor","backgroundColor","borderRadius","color","fontSize","textAlign","component","fontWeight","asRepeatCopy","copy","label","title","repeatCopyCss","hover","hovered","repeatBadgeText","count","missing","fix","text","explanation","toLowerCase","RepeatBadge","nodeId","chrome","setRightPanel","setRightPanelRef","current","badgeRef","badge","open","event","button","prev","toggled","tab","BesignerPanelTabFlag","ELEMENT_PROPS_FORM","addEventListener","removeEventListener","tone","tertiary","warning","radius","shape","data-aglyn-repeat-badge","data-aglyn-repeat-empty","position","top","right","zIndex","cursor","px","py","maxWidth","overflow","textOverflow","whiteSpace","borderBottomLeftRadius","contrastText","fontFamily","typography","fontWeightBold","lineHeight","NodeLeaf","viewType","elements","setElementRef","deleteElementRef","$id","registered","registerElement","element","Element","dragHandle","showSlotMarker","componentId","LAYOUT","showEmptyDocumentSlot","length","revealedNodeIds","mutedClasses","resolveFlag","variables","functions","componentProps","boundProps","Object","entries","value","JSON","stringify","defaultPropTokens","defaultIconPaths","defaultValues","renderNode","hasDeclaredProps","keys","resolved","key","next","String","hostResolvedNode","renderNodeUnclassed","withRepeatRecord","shownNode","repeatPreview","repeatCopies","focus","getHovered","hoveredInRepeat","test","firstRecord","records","record","model","dataset","datasetsByKey","definitions","formDesigns","instanceTree","definition","refId","parse","className","_placementClasses","snapshotProps","composed","styleOverrides","attrOverrides","grafted","placedForm","formId","replacement","trees","shownLeafNode","leafNode","type","DragType","CANVAS","accept","values","disableDragging","dnd","canDragNode","data-aglyn-selected","isNodeSelected","data-aglyn-selected-within","isNodeOrDescendantSelected","data-aglyn-revealed","data-aglyn-bound","Provider","style","grey","pointerEvents","data-aglyn-form-preview","tree","data-aglyn-component-preview","aglyn"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,8BAA8B,EAC9BC,2BAA2B,EAC3BC,2BAA2B,EAC3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gE;8BAChE,KAACvN;oBAAIyE,IAAI;wBAAEqK,eAAe;oBAAO;oBAAGC,2BAAwB;8BAC1D,cAAA,KAACpP,mBAAmBgP,QAAQ;wBAAC9D,OAAOnI;kCACjC6K,WAAWG,KAAK,CAAC/J,GAAG,CAAC,CAACqL,qBACrB,KAACpP;gCAAoBuC,MAAM6M;+BAAhBA,KAAKvF,GAAG;;qBAIvB;gBACHmD,eACC,4DAA4D;gBAC5D,yDAAyD;gBACzD,gEAAgE;gBAChE,4CAA4C;8BAC5C,KAAC5M;oBAAIyE,IAAI;wBAAEqK,eAAe;oBAAO;oBAAGG,gCAA6B;8BAC/D,cAAA,KAACtP,mBAAmBgP,QAAQ;wBAAC9D,OAAOnI;kCAClC,cAAA,KAAC9C;4BAAKuC,MAAMyK;;;qBAGd;gBACH7C,+BACC,KAAC9F;oBACCC,OAAO,EAAE/B,yBAAAA,cAAAA,KAAMF,KAAK,qBAAXE,WAAa,CAAC,UAAU;qBAEjC;gBACH+H,sCAAwB,KAACpI,yBAAuB;;;;AAIzD,IACD;AACDsH,SAAS3G,WAAW,GAAG;AACvB2G,SAAS8F,KAAK,GAAG;AAEjB,eAAe9F,SAAQ"}
1
+ {"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/node-leaf.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n buildComponentDefaultIconPaths,\n buildComponentDefaultTokens,\n buildComponentDefaultValues,\n composeReusableComponentNodes,\n displayBindingTokens,\n FORM_COMPONENT_ID,\n hasBindings,\n HostViewType,\n isNodeHiddenByHost,\n LAYOUT_SLOT_COMPONENT_ID,\n NODE_ROOT_ID,\n placedFormPlacement,\n resolveBindings,\n resolveComponentPropTokens,\n REUSABLE_INSTANCE_COMPONENT_ID,\n} from '@aglyn/aglyn'\nimport {\n Branch,\n Leaf,\n type LeafProps,\n RendererComponents,\n Stem,\n Trunk,\n} from '@aglyn/aglyn-node-renderer'\nimport * as Besigner from '@aglyn/besigner'\nimport { alpha, Box, useTheme } from '@mui/material'\nimport type { Theme } from '@mui/material/styles'\nimport { observer } from 'mobx-react-lite'\nimport {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport useAglynBesignerPanel from '../hooks/use-aglyn-besigner-panel'\nimport { requestAttributeFocus } from '../utils/attribute-focus-request'\nimport BindingPickerContext from '../contexts/binding-picker-context'\nimport CanvasChromeThemeContext from '../contexts/canvas-chrome-theme-context'\nimport CanvasRevealContext, {\n CanvasMutedClassesContext,\n} from '../contexts/canvas-reveal-context'\nimport CanvasHostTokensContext from '../contexts/canvas-host-tokens-context'\nimport ComponentPromotionContext from '../contexts/component-promotion-context'\nimport { useRenderedCanvasElements } from '../contexts/rendered-canvas-elements'\nimport useAglynBesignerFlag from '../hooks/use-aglyn-besigner-flag'\nimport { useNodeWithMediaAssetFacts } from '../hooks/use-media-asset-facts-overlay'\nimport useNodeWithBindings from '../hooks/use-node-with-bindings'\nimport useNodeWithHostTokens from '../hooks/use-node-with-host-tokens'\nimport {\n useNodeWithRepeatRecord,\n useRepeatCopies,\n useRepeatPreview,\n} from '../hooks/use-repeat-preview'\nimport {\n RepeatRecordContext,\n RepeatTemplateContext,\n} from '../contexts/repeat-record-context'\nimport {\n isNodeHiddenOnSite,\n isNodeRevealedOnCanvas,\n} from '../utils/canvas-reveal'\nimport { stripMutedClasses } from '../utils/muted-classes'\nimport DraggableDroppable from './dnd/draggable-droppable'\nimport EmptyDocumentSlot from './empty-document-slot'\nimport { REPEAT_COPY_ATTR } from '../utils/repeat-copy'\n\n/**\n * The plain `Leaf`, drawing a node the way the published page composes it: its\n * site variables and functions resolved (AGL-3480), its host variables filled\n * in from the site being edited (AGL-2881), and a placed image or film with\n * its DAM asset's current facts (AGL-2838, AGL-2856).\n *\n * For the nodes the canvas renders that are not canvas nodes — a component\n * instance's definition, a placed form's design, the layout chrome — and so\n * never reach `NodeLeaf`. A header's `{{var:…}}` phone number still has to\n * read as the number, a footer's `{{host.businessName}}` as the site's name,\n * an asset inside one of them still has to show the shape the published page\n * gives it, and a film its poster. Bindings before host tokens, the order the\n * published page composes in.\n */\nexport const MediaFactsLeaf = forwardRef<any, LeafProps>((props, ref) => {\n const { node, ...rest } = props\n const host = useContext(CanvasHostTokensContext)\n const withBindings = useNodeWithBindings(node)\n const withHostTokens = useNodeWithHostTokens(withBindings)\n const withRecord = useNodeWithRepeatRecord(withHostTokens)\n const shown = useNodeWithMediaAssetFacts(withRecord)\n // What the site's own values hide is not on the published page (AGL-4119),\n // and these nodes are never selected, so here it is simply not drawn.\n if (host && isNodeHiddenByHost(node?.props, host)) return null\n return <Leaf ref={ref} node={shown} {...rest} />\n})\nMediaFactsLeaf.displayName = 'MediaFactsLeaf'\n\n/**\n * Renderer overrides for the inside of a component instance (AGL-1251).\n *\n * The plain `Leaf` (through `MediaFactsLeaf`), deliberately, where the canvas\n * otherwise uses `NodeLeaf`: the definition's nodes are NOT in the canvas, so\n * anything that made them draggable, selectable or droppable would be reaching\n * for canvas state that has no entry for them. Rendering them inert is not a\n * restriction bolted on afterwards — it is the only thing these nodes can be.\n */\nconst INERT_RENDERER = {\n TrunkComponent: Trunk,\n StemComponent: Stem,\n BranchComponent: Branch,\n LeafComponent: MediaFactsLeaf,\n}\n\n/**\n * Nested-object form of a normalized node map, which is what `Branch` walks\n * (`node.children`). Cycle-safe via `seen`: a definition that somehow\n * referenced an ancestor would otherwise recurse until the stack gave out.\n */\nexport function denormalizeTree(\n nodes: Record<string, any>,\n rootId: string,\n seen: Set<string> = new Set(),\n): any {\n const node = nodes?.[rootId]\n if (!node || seen.has(rootId)) return undefined\n seen.add(rootId)\n const childIds = Array.isArray(node.nodes) ? node.nodes : []\n return {\n ...node,\n children: childIds\n .map((childId: string) => denormalizeTree(nodes, childId, seen))\n .filter(Boolean),\n }\n}\n\nexport interface NodeLeafProps extends LeafProps {}\n\n/**\n * The console's theme for chrome drawn inside the canvas, or — outside one,\n * as in a spec — the theme in force.\n *\n * Inside the canvas `useTheme()` is the SITE's theme: editor chrome read from\n * it would repaint itself whenever a subscriber restyled their site, and the\n * slot marker once rendered pink instead of the console's blue that way.\n * See {@link CanvasChromeThemeContext}.\n */\nfunction useChromeTheme(): Theme {\n const theme = useTheme()\n return useContext(CanvasChromeThemeContext) ?? theme\n}\n\n/**\n * Visible placement marker for the LayoutSlot while editing a layout. The\n * slot is a passthrough at runtime, so without this it disappears once it\n * has children and designers lose track of where screen content lands.\n */\nconst SlotMarker = ({ caption }: { caption?: string }) => {\n const accent = useChromeTheme().palette.primary.main\n return (\n <Box\n aria-hidden\n data-aglyn-slot-marker=\"\"\n sx={{\n m: 1,\n p: 2,\n minHeight: 64,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 0.5,\n borderWidth: 2,\n borderStyle: 'dashed',\n // Brand blue on a faint tint, not a grey dashed box: the slot is the\n // one region the layout does not own, and it should not read as just\n // another empty container.\n borderColor: accent,\n backgroundColor: alpha(accent, 0.06),\n borderRadius: 1,\n color: 'text.secondary',\n fontSize: 13,\n textAlign: 'center',\n }}\n >\n <Box component=\"span\" sx={{ color: accent, fontWeight: 'fontWeightBold' }}>\n {'◇ layout-slot'}\n </Box>\n <Box component=\"span\">{caption || 'Page content renders here'}</Box>\n </Box>\n )\n}\n\n/**\n * A repeat copy's root as the canvas draws it: hidden from assistive\n * technology, since it repeats what the real element already says, stamped so\n * {@link repeatCopyCss} can outline it, and titled so the pointer is told what\n * it is over — a click on a copy selects the element it repeats, which with no\n * word of explanation looks like the canvas picking the wrong thing.\n */\nfunction asRepeatCopy(copy: any, label: string) {\n return {\n ...copy,\n props: {\n ...copy.props,\n 'aria-hidden': true,\n [REPEAT_COPY_ATTR]: '',\n title:\n `A copy for the next record of ${label}. ` +\n 'Click to select the element it repeats — edit that one, and every copy follows.',\n },\n }\n}\n\n/**\n * The copies' outline: dashed `rest` grey, and dashed `hover` grey on the\n * copies of the element being pointed at — the real one or a copy of it.\n */\nfunction repeatCopyCss(rest: string, hover: string, hovered?: string) {\n const copy = `[${REPEAT_COPY_ATTR}]`\n return (\n `${copy}{outline:1px dashed ${rest};outline-offset:-1px}` +\n (hovered\n ? `${copy}[data-aglyn$=\"__${hovered}\"]{outline-color:${hover}}`\n : '')\n )\n}\n\n/**\n * What the badge says, and what hovering it explains (AGL-3111).\n *\n * The short line names the source and what the page gets. The two states that\n * render nothing on the published page (AGL-3496) say so in plain words, and\n * their explanation says why and where to fix it — \"Dataset not found ·\n * hidden on the live site\" told an author something was wrong and nothing\n * about what, or what to do.\n */\nexport function repeatBadgeText({\n label,\n count,\n missing,\n}: {\n label: string\n count: number\n missing?: boolean\n}): { text: string; explanation: string } {\n const fix =\n 'Click this badge to fix it: it opens Repeat over dataset in the Attributes panel, where you choose another.'\n if (missing) {\n return {\n text: `⟳ ${label} not available · not shown on your site`,\n explanation:\n `This element repeats once per record of a ${label.toLowerCase()} this site can’t read — ` +\n 'it was deleted, or it isn’t shared with this site. Until that changes, your published page shows none of it. ' +\n fix,\n }\n }\n if (!count) {\n return {\n text: `⟳ Repeats ${label} · no records match · not shown on your site`,\n explanation:\n `No record of ${label} matches this repeat, so your published page shows none of it. ` +\n 'Add records to the dataset, or click this badge and loosen the Repeat filter in the Attributes panel.',\n }\n }\n return {\n text: `⟳ Repeats ${label} · ${count} ${count === 1 ? 'record' : 'records'}`,\n explanation:\n `This element repeats once per record of ${label}: ${count} on your published page. ` +\n 'Edit the first one; the copies after it follow.',\n }\n}\n\n/**\n * The repeat badge (AGL-3111), in the console's chrome colours rather than\n * the site's — see {@link useChromeTheme}. It cannot reach a published page:\n * only `NodeLeaf` draws it, and a published page is composed from stored nodes\n * and rendered through the plain `Leaf`.\n *\n * It takes the pointer, unlike the rest of the chrome here, so hovering it can\n * explain itself, and a click on it selects the repeating element and opens\n * Repeat over dataset in the Attributes panel — the setting it talks about.\n */\nconst RepeatBadge = ({\n nodeId,\n label,\n count,\n missing,\n}: {\n nodeId: string\n label: string\n count: number\n missing?: boolean\n}) => {\n const chrome = useChromeTheme()\n const [, setRightPanel] = useAglynBesignerPanel('panelRight')\n // The setter is a new function every render; the listener reads it here.\n const setRightPanelRef = useRef(setRightPanel)\n setRightPanelRef.current = setRightPanel\n const badgeRef = useRef<HTMLDivElement>(null)\n // A native listener, as everywhere on this canvas: React delegates at the\n // root container and the canvas is a closed shadow root. On the PRESS, not\n // the click: the press selects the repeating element (it bubbles to that\n // element's own handlers), the selection's overlay then covers the badge,\n // and the release lands on the overlay — a `click` never reaches the badge.\n useEffect(() => {\n const badge = badgeRef.current\n if (!badge) return undefined\n const open = (event: Event) => {\n // A secondary button opens the context menu instead.\n if (((event as PointerEvent).button ?? 0) > 0) return\n requestAttributeFocus(nodeId, 'repeatDataset')\n try {\n setRightPanelRef.current((prev) => ({\n ...prev,\n toggled: true,\n tab: Besigner.BesignerPanelTabFlag.ELEMENT_PROPS_FORM,\n }))\n } catch {\n // No besigner app around this leaf, so no panel to open.\n }\n }\n badge.addEventListener('pointerdown', open)\n return () => badge.removeEventListener('pointerdown', open)\n }, [nodeId])\n // The slate where it exists — the console's theme always has it — and the\n // primary where a bare theme does not (a spec, a host without the console).\n const tone = count\n ? (chrome.palette.tertiary ?? chrome.palette.primary)\n : chrome.palette.warning\n const { text, explanation } = repeatBadgeText({ label, count, missing })\n const radius = chrome.shape.borderRadius\n return (\n <Box\n ref={badgeRef}\n aria-hidden\n data-aglyn-repeat-badge=\"\"\n data-aglyn-repeat-empty={count ? undefined : ''}\n title={explanation}\n sx={{\n // Out of the element's own layout: a badge that took part in a flex row\n // would move the design it is describing.\n position: 'absolute',\n top: 0,\n right: 0,\n zIndex: 2,\n cursor: 'pointer',\n px: 0.75,\n py: 0.25,\n maxWidth: '100%',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n borderBottomLeftRadius: typeof radius === 'number' ? `${radius}px` : radius,\n backgroundColor: tone.main,\n color: tone.contrastText,\n fontFamily: chrome.typography.fontFamily,\n fontSize: chrome.typography.caption.fontSize,\n fontWeight: chrome.typography.fontWeightBold,\n lineHeight: chrome.typography.caption.lineHeight,\n // A Stack's spacing gives every child after the first a top margin,\n // which moved the badge down off the corner; doubled to outrank it.\n '&&': { m: 0 },\n }}\n >\n {text}\n </Box>\n )\n}\n\nexport const NodeLeaf = observer(\n forwardRef<any, NodeLeafProps>((props, ref) => {\n const { node, children, ...rest } = props\n const [viewType] = useAglynBesignerFlag('viewType')\n // The canvas element registry, finally given a WRITER (AGL-2486).\n //\n // `RenderedCanvasElementsProvider` has existed since the registry was\n // introduced and `setElementRef`/`deleteElementRef` were called from\n // NOWHERE in the repo — `elements.current` was `{}` for the life of every\n // session. Everything that reads it therefore read an empty map and\n // failed the only way an empty map can: silently.\n //\n // Two features were void because of it, and neither logged anything:\n //\n // `usePresence`'s cursor broadcast resolves the canvas root through\n // this registry and bails with `if (!root) return`, so no editor has\n // EVER written a cursor position. Confirmed against production RTDB on\n // 2026-08-22: three live presence entries across three rooms, not one\n // carrying `cursorX`/`cursorY`.\n //\n // `CollaboratorOverlays` resolves both the canvas root and each peer's\n // selected node here, so `placements` was always empty and the overlay\n // returned null. Confirmed live in the running console: a collaborator\n // entry carrying both a cursor and a selection rendered its avatar and\n // drew no cursor, no selection box and no name label.\n //\n // Registering here rather than in the renderer keeps it to the canvas:\n // `NodeLeaf` is the besigner's leaf component, so component-definition\n // previews (which render the plain `Leaf` through `INERT_RENDERER`) stay\n // out of the registry — they are not in the canvas and must not be\n // addressable as though they were.\n //\n // `NODE_ROOT_ID` and `CANVAS_ROOT_ELEMENT_ID` are the same string\n // (`'_@_'`), so keying on `$id` registers the canvas root under the id\n // the cursor code already looks for, with no special case.\n const { elements, setElementRef, deleteElementRef } =\n useRenderedCanvasElements()\n const $id = node?.$id\n // What THIS leaf last put in the registry. A remount can hand the new\n // element its ref before the old one is cleared, so an unconditional\n // delete on `null` would evict the live registration and put the\n // registry back to the state this whole change exists to fix.\n const registered = useRef<Element | null>(null)\n const registerElement = useCallback(\n (element: unknown) => {\n // Forward FIRST and unconditionally: dnd and the renderer already\n // depend on this ref, and registration must never change what they\n // observe.\n if (typeof ref === 'function') ref(element)\n else if (ref) (ref as { current: unknown }).current = element\n if (!$id) return\n if (element instanceof Element) {\n registered.current = element\n setElementRef($id, {\n $id,\n node: element,\n dragHandle: undefined,\n } as never)\n return\n }\n // Cleared (or never a DOM element — a class instance, say). Only\n // withdraw the registration if it is still OURS.\n const current = elements?.current?.[$id]?.node\n if (!registered.current || current === registered.current) {\n deleteElementRef($id)\n }\n registered.current = null\n },\n [ref, $id, elements, setElementRef, deleteElementRef],\n )\n const showSlotMarker =\n node?.componentId === LAYOUT_SLOT_COMPONENT_ID &&\n viewType === HostViewType.LAYOUT\n // A document with no nodes has nothing to aim at. Wrapped in a shared\n // layout it is worse than empty — the slot passes its children straight\n // through, so the root collapses to a zero-height strip between locked\n // chrome and the nav renders directly into the footer. Hung off the ROOT\n // leaf, which is already inside `DraggableDroppable`, so giving it height\n // is all a drop needs to resolve against the document root.\n const showEmptyDocumentSlot =\n node?.$id === NODE_ROOT_ID &&\n !node?.nodes?.length &&\n viewType !== HostViewType.LAYOUT\n\n // Nodes the author has opened up for designing (AGL-592). Through a\n // context rather than the flag itself: the canvas subscribes once and\n // every leaf reads the result.\n const revealedNodeIds = useContext(CanvasRevealContext)\n const canvasHost = useContext(CanvasHostTokensContext)\n const mutedClasses = useContext(CanvasMutedClassesContext)\n\n // WYSIWYG bindings (AGL-97): resolve variable/function tokens\n // live on the rendered copy (selection/dnd keep the original node).\n // Bound nodes are flagged either way so editors can spot them.\n const [resolveFlag] = useAglynBesignerFlag('resolveBindings')\n const { variables, functions, componentProps } = useContext(\n BindingPickerContext,\n )\n const boundProps = useMemo(\n () =>\n Object.entries(node?.props ?? {}).filter(\n ([, value]) => typeof value === 'string' && hasBindings(value),\n ),\n // MobX props are observable; the JSON string keys the memo cheaply.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [node, JSON.stringify(node?.props ?? {})],\n )\n /**\n * A component editor draws with the definition's OWN defaults\n * (AGL-2870), so `{{prop.headline}}` shows the headline and a film with a\n * default source actually plays.\n *\n * Only props that HAVE a default are substituted. One without stays a\n * visible token, which is the signal an author needs: the slot is real\n * and nothing fills it yet. Substituting `''` there would draw an empty\n * component and hide the very thing they still have to decide.\n *\n * On a screen this path does nothing — the props belong to the component\n * route, and an instance is composed through `composeReusableComponentNodes`\n * below, which is the single substitution path a published page uses.\n */\n const defaultPropTokens = useMemo(\n () => buildComponentDefaultTokens(componentProps),\n [componentProps],\n )\n // The paths of the default icons, which a field bound to an icon property\n // draws with — the editor has no reason to have loaded the icon catalog.\n const defaultIconPaths = useMemo(\n () => buildComponentDefaultIconPaths(componentProps),\n [componentProps],\n )\n // The values the defaults hand their bound fields (AGL-2893), so a list\n // stays a list and a theme multiple a number on the editor's canvas too.\n const defaultValues = useMemo(\n () => buildComponentDefaultValues(componentProps),\n [componentProps],\n )\n const renderNode = useMemo(() => {\n const hasDeclaredProps = Boolean(componentProps?.length)\n if (\n !boundProps.length ||\n (!Object.keys(variables ?? {}).length &&\n !Object.keys(functions ?? {}).length &&\n !hasDeclaredProps)\n ) {\n return node\n }\n const resolved: Record<string, unknown> = { ...(node?.props ?? {}) }\n for (const [key, value] of boundProps) {\n // Resolve toggle off → show friendly token text: id tokens map to\n // the referent's CURRENT name (AGL-186), never raw doc ids.\n resolved[key] =\n resolveFlag === false\n ? displayBindingTokens(\n value as string,\n (variables ?? {}) as any,\n (functions ?? {}) as any,\n )\n : resolveBindings(\n value as string,\n (variables ?? {}) as any,\n (functions ?? {}) as any,\n )\n }\n const next = { ...node, props: resolved }\n if (!hasDeclaredProps) return next\n // Through the same substitution a placed instance uses, keyed by this\n // node alone — one code path deciding what a token becomes, never two\n // that could disagree.\n //\n // The raw-token view substitutes no defaults: an author who turned\n // resolution OFF asked to see the tokens, and a default is a resolved\n // value like any other. A field bound to a Yes/no property still\n // receives a yes or a no there, because a switch has no way to show a\n // token and reads the token's text as a yes.\n return (\n resolveComponentPropTokens(\n { [String(node?.$id)]: next as any },\n componentProps,\n resolveFlag === false ? undefined : defaultPropTokens,\n resolveFlag === false ? undefined : defaultIconPaths,\n resolveFlag === false ? undefined : defaultValues,\n )[String(node?.$id)] ?? next\n )\n }, [\n node,\n boundProps,\n resolveFlag,\n variables,\n functions,\n componentProps,\n defaultPropTokens,\n defaultIconPaths,\n defaultValues,\n ])\n\n // Host variables (AGL-2881), filled in on the same render copy and after\n // the bindings and the component's own defaults, which is the order the\n // published page composes in: a default that names the host resolves\n // too. The raw-token view reaches this leaf as no site at all\n // (`CanvasHostTokensProvider`), so its tokens stay as written. Keyed by\n // `boundProps`, which follows the observable props this copy reads.\n const hostResolvedNode = useNodeWithHostTokens(renderNode, boundProps)\n\n // Classes switched off for comparison (AGL-2486). Composed onto the SAME\n // render copy the binding resolution builds, never onto the canvas node:\n // selection, the hierarchy and every save keep reading the element's real\n // class list, and the canvas paints without the switched-off names.\n const renderNodeUnclassed = useMemo(\n () =>\n stripMutedClasses(hostResolvedNode as never, node?.$id, mutedClasses),\n [hostResolvedNode, node, mutedClasses],\n )\n\n /**\n * The record a repeat above this one is drawing (AGL-3111).\n *\n * Applied in the same place, and for the same reason, as the host tokens\n * and the DAM facts above: the published page substitutes `{{item.*}}`\n * when it composes, so the canvas substitutes it on the render copy while\n * the node keeps the tokens every save writes.\n */\n const withRepeatRecord = useNodeWithRepeatRecord(renderNodeUnclassed)\n\n // A placed asset's shape, and a film's length and poster, as its DAM\n // document records them NOW (AGL-2838, AGL-2856). The published page lays\n // the asset over the node when it is composed, so the canvas lays it over\n // the same render copy: a replace shows here as it shows to a visitor,\n // while selection, the panels and every save keep reading the node's\n // stored props.\n const shownNode = useNodeWithMediaAssetFacts(withRepeatRecord)\n\n /**\n * What this element repeats over, and the copies it draws (AGL-3111).\n *\n * The first record's copy is the element's own children — real canvas\n * nodes an author selects, drags and edits — with that record laid over\n * their render copies through {@link RepeatRecordContext}. Records 2..n\n * are inert pictures of the same template, built by the page's own\n * expansion. Editing the template therefore edits every copy, because\n * there is only ever one.\n */\n const repeatPreview = useRepeatPreview(node)\n const repeatCopies = useRepeatCopies(node, repeatPreview)\n const theme = useTheme()\n // Only a leaf drawing copies reads the hover, so only those re-render as\n // the pointer moves; the id is CSS-safe or ignored.\n const hovered = repeatCopies.length\n ? Besigner.focus.getHovered()?.$id\n : undefined\n const hoveredInRepeat =\n hovered && /^[\\w-]+$/.test(hovered) ? hovered : undefined\n const firstRecord = useMemo(\n () =>\n // No record to draw (AGL-3496): the template shows as written, and\n // the badge says the live site renders none of it.\n repeatPreview?.records.length\n ? {\n record: repeatPreview.records[0],\n model: repeatPreview.dataset?.model,\n datasetsByKey: repeatPreview.datasetsByKey,\n }\n : undefined,\n [repeatPreview],\n )\n\n // A component instance renders its definition (AGL-1251) instead of the\n // named dashed box. Authors placed a hero and saw a grey rectangle, so\n // the props they filled in were invisible until Preview.\n //\n // Rendered, never grafted: the definition's nodes stay out of the canvas\n // entirely. That is what makes this safe — there is nothing to lock,\n // nothing to strip before a save, and no way for a definition's node to\n // be persisted into the document that placed it. Same shape as the\n // binding resolution above, which renders a resolved copy while\n // selection and dnd keep the original node.\n const { definitions, formDesigns } = useContext(ComponentPromotionContext)\n const instanceTree = useMemo(() => {\n if (node?.componentId !== REUSABLE_INSTANCE_COMPONENT_ID) {\n return undefined\n }\n // Already expanded into this canvas — the layout-chrome store grafts\n // before it loads (AGL-1218), so its instances arrive with children.\n // Rendering here too would draw the nav twice.\n if (node?.nodes?.length) return undefined\n const props = (node?.props ?? {}) as { refId?: string }\n const definition = props.refId ? definitions?.[props.refId] : undefined\n if (!definition?.nodes || !definition?.rootId) return undefined\n // Plain snapshot: props are MobX observables and the graft reads nested\n // `propValues` off them. The placement's classes stay out of it, as its\n // `sx` does: this leaf already renders both on the element around the\n // preview, and the graft joins a placement's classes onto the root it\n // becomes. Handed them here, the preview's root would apply every class\n // a second time, and keep `aglyn-hidden` collapsed inside a placement\n // the canvas has revealed for designing.\n const { className: _placementClasses, ...snapshotProps } = JSON.parse(\n JSON.stringify(node.props ?? {}),\n ) as Record<string, unknown>\n // Reuse the real graft so the canvas resolves `{{prop.*}}` exactly as\n // the published page will — one substitution path, not a second one\n // that could disagree about which value wins.\n const composed = composeReusableComponentNodes(\n {\n [node.$id]: {\n $id: node.$id,\n componentId: REUSABLE_INSTANCE_COMPONENT_ID,\n props: snapshotProps,\n // Root style overrides (AGL-1306) ride the same snapshot so\n // the canvas renders the SAME merged root sx the published\n // page will — the graft is the one merge point.\n ...(node.styleOverrides && {\n styleOverrides: JSON.parse(JSON.stringify(node.styleOverrides)),\n }),\n // Attribute overrides ride the same snapshot for the same\n // reason (AGL-1899). Leaving them out is invisible rather than\n // broken: Preview and tenant SSR compose from the stored node\n // and WOULD apply them, so the canvas alone would draw the\n // component's own attributes and disagree with both.\n ...(node.attrOverrides && {\n attrOverrides: JSON.parse(JSON.stringify(node.attrOverrides)),\n }),\n nodes: [],\n } as any,\n },\n // The host's WHOLE definitions map, not just this instance's own\n // (AGL-1898). A definition may contain instances of OTHER\n // definitions, and `composeReusableComponentNodes` expands those —\n // but only the ones it is handed. Preview, tenant SSR and the\n // layout-chrome graft all pass the full map, so a one-entry map\n // here made the canvas the only surface that left a nested\n // component as an unexpanded placeholder.\n //\n // It also silently voided propagation for the inner component:\n // publishing a shared button re-rendered every canvas showing it\n // directly and none of the ones showing it through the nav that\n // contains it — which is the case a shared component is usually in.\n //\n // Safe to widen because the `nodes` argument above is this ONE\n // instance: the extra definitions can only be reached from inside\n // the subtree being grafted, never applied to some other node.\n definitions as any,\n )\n // The graft puts the definition's root IN the instance's place rather\n // than under it (AGL-2521), so the component to draw is at the\n // instance's own id. Reading `nodes[0]` here would render the root's\n // FIRST CHILD and drop the component's outer element with its siblings.\n const grafted = composed[node.$id]\n return grafted && grafted.componentId !== REUSABLE_INSTANCE_COMPONENT_ID\n ? denormalizeTree(composed, node.$id)\n : undefined\n // Observable props/overrides: the JSON strings key the memo, as above.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n node,\n JSON.stringify(node?.props ?? {}),\n JSON.stringify(node?.styleOverrides ?? {}),\n JSON.stringify(node?.attrOverrides ?? {}),\n definitions,\n ])\n\n /**\n * A placed form draws its ENTITY'S published fields, not the page's copy\n * of them (`docs/specs/reusable-forms.md`).\n *\n * The same render-copy treatment the instance above gets, and for the same\n * reason: the entity's nodes stay out of the canvas, so there is nothing to\n * lock, nothing to strip before a save, and no way for a form's fields to\n * be persisted into the screen that placed it.\n *\n * It runs the REAL graft rather than reading `design.nodes` directly, so a\n * component nested inside the form design expands here exactly as it will\n * on the published page — one resolution path, not a second that could\n * disagree.\n *\n * When it resolves, the node's own children are not rendered (below): the\n * published page discards them, and a canvas that drew both would show the\n * author a page that does not exist. Where the entity has no published\n * design the memo is `undefined`, the children render, and the form the\n * author drew is the form they see — which is every form built before the\n * entity existed.\n */\n const placedForm = useMemo(() => {\n if (node?.componentId !== FORM_COMPONENT_ID) return undefined\n const formId = (node?.props as { formId?: unknown } | undefined)?.formId\n if (typeof formId !== 'string' || !formId) return undefined\n const composed = composeReusableComponentNodes(\n {\n [node.$id]: {\n $id: node.$id,\n componentId: FORM_COMPONENT_ID,\n // Plain snapshot: props are MobX observables, as above.\n props: JSON.parse(JSON.stringify(node.props ?? {})),\n // The placement's own sx and its per-page override slices\n // (AGL-3285) ride the snapshot as they do for an instance above:\n // the replacement below is what this leaf draws, so a slice left\n // out here would render on Preview and the live page but not on\n // the canvas.\n ...(node.sx !== undefined && {\n sx: JSON.parse(JSON.stringify(node.sx)),\n }),\n // Joined with the design root's by the graft (AGL-3494), so the\n // replacement's class list is the whole one the page draws.\n ...(typeof (node as { className?: unknown }).className ===\n 'string' && {\n className: (node as { className?: unknown }).className,\n }),\n ...(node.styleOverrides && {\n styleOverrides: JSON.parse(JSON.stringify(node.styleOverrides)),\n }),\n ...(node.attrOverrides && {\n attrOverrides: JSON.parse(JSON.stringify(node.attrOverrides)),\n }),\n nodes: [],\n } as any,\n },\n // Component definitions ride along so an instance INSIDE the form\n // design expands; the map is safe to pass whole for the reason the\n // instance graft above states — the one node handed in is this form.\n definitions as any,\n [placedFormPlacement(formDesigns as any)],\n )\n /*\n * The composed REPLACEMENT is the node the published page draws in this\n * placement's place — the design's root, carrying the placement's id\n * (AGL-2521) — and its children are the design's own.\n *\n * Reading the replacement rather than the placement is what keeps the\n * canvas honest about the element itself. A real form design is a\n * container holding the `form` node, so the placement's `form` used to\n * be drawn AROUND the design's: two `<form>` elements nested, each\n * drawing its own send button, where a visitor sees one. Taking only\n * the first child also dropped everything a design put beside its form.\n */\n const replacement = composed[node.$id]\n const childIds = (replacement?.nodes as string[] | undefined) ?? []\n if (!replacement || !childIds.length) return undefined\n const trees = childIds\n .map((childId) => denormalizeTree(composed, childId))\n .filter(Boolean)\n return trees.length ? { replacement, trees } : undefined\n // Observable props: the JSON string keys the memo, as above.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n node,\n JSON.stringify(node?.props ?? {}),\n JSON.stringify(node?.sx ?? {}),\n (node as { className?: unknown } | undefined)?.className,\n JSON.stringify(node?.styleOverrides ?? {}),\n JSON.stringify(node?.attrOverrides ?? {}),\n definitions,\n formDesigns,\n ])\n\n /**\n * The element this leaf DRAWS, once a placed form resolves.\n *\n * The published page renders the entity's root here, not the placement:\n * the two denote the same element and the graft merges them. The canvas\n * draws the same one, so an author sees the form their visitors will. As\n * with the DAM facts and the host tokens above, this is a render copy —\n * selection, the panels and every save keep reading `node`.\n */\n const shownLeafNode = useMemo(\n () =>\n placedForm\n ? ({\n ...(shownNode as Record<string, unknown>),\n componentId: placedForm.replacement.componentId,\n props: (placedForm.replacement.props ?? {}) as never,\n ...(placedForm.replacement.sx === undefined\n ? {}\n : { sx: placedForm.replacement.sx }),\n // The design root's classes joined with the placement's\n // (AGL-3494), as the published page draws them.\n ...((placedForm.replacement as { className?: unknown })\n .className === undefined\n ? {}\n : {\n className: (placedForm.replacement as { className?: unknown })\n .className,\n }),\n } as typeof shownNode)\n : shownNode,\n [placedForm, shownNode],\n )\n\n /**\n * A repeating element is the box its badge is placed in.\n *\n * The badge sits at the element's top right, which only holds when the\n * element is positioned; in a plain Stack it attached to the nearest\n * positioned ancestor instead, so two repeats in one container drew both\n * badges in the same corner, the second over the first. The canvas copy\n * gets `position: relative` — never the stored node, and never over a\n * position the author set.\n */\n const leafNode = useMemo(() => {\n if (!repeatPreview) return shownLeafNode\n const sx = (shownLeafNode as { sx?: unknown })?.sx\n if (sx != null && (typeof sx !== 'object' || Array.isArray(sx))) {\n return shownLeafNode\n }\n if (sx && 'position' in (sx as Record<string, unknown>)) {\n return shownLeafNode\n }\n return {\n ...(shownLeafNode as Record<string, unknown>),\n sx: { ...((sx as Record<string, unknown> | undefined) ?? {}), position: 'relative' },\n } as typeof shownLeafNode\n }, [repeatPreview, shownLeafNode])\n /**\n * What the site's own values hide (AGL-4119), like a header's logo on a\n * site that has none, or its name on one that does. The canvas shows what\n * a visitor sees, and an element picked in the hierarchy shows for as long\n * as it is being worked on, so it stays an ordinary element to edit.\n * Through `hidden` on the render copy, never on the node that is saved.\n */\n const hostHidden =\n Boolean(canvasHost) &&\n isNodeHiddenByHost(node?.props, canvasHost) &&\n !Besigner.focus.isNodeOrDescendantSelected(node) &&\n !revealedNodeIds?.some((id) => id === node?.$id)\n const drawnNode = useMemo(\n () => (hostHidden ? ({ ...(leafNode as Record<string, unknown>), hidden: true } as typeof leafNode) : leafNode),\n [hostHidden, leafNode],\n )\n\n return (\n <DraggableDroppable\n node={node}\n type={Besigner.DragType.CANVAS}\n accept={Object.values(Besigner.DragType)}\n disableDragging={!Besigner.dnd.canDragNode(node)}\n >\n <Leaf\n ref={registerElement}\n node={drawnNode as typeof node}\n data-aglyn-selected={Besigner.focus.isNodeSelected(node)}\n // Present while the selection lives in this node's subtree (the\n // node itself or any descendant). Canvas-aware components (nav\n // menus, drawers) read this neutral leaf attribute to expand\n // only while they are being authored (AGL-571). Presence-based\n // (''/undefined) so unaffected leaves carry no attribute.\n data-aglyn-selected-within={\n Besigner.focus.isNodeOrDescendantSelected(node) ? '' : undefined\n }\n // Present on an element that carries the hidden class while the\n // canvas is showing it anyway (AGL-592) — the flag the canvas\n // stylesheet checks before collapsing it. Stamped on the hidden\n // element itself, so no wrapper a component renders around its\n // children can come between the two.\n data-aglyn-revealed={\n isNodeHiddenOnSite(node) &&\n isNodeRevealedOnCanvas(node, revealedNodeIds)\n ? ''\n : undefined\n }\n data-aglyn-bound={boundProps.length ? '' : undefined}\n {...rest}\n >\n {/* A resolved form entity REPLACES the page's own fields, exactly\n as the published page composes it — see `placedForm`. */}\n {placedForm ? null : firstRecord ? (\n // The template IS the first copy: the real children, drawing the\n // first record. Provided around them rather than applied to them,\n // so every descendant leaf resolves its own tokens the way the\n // page's substitution walks the whole cloned subtree.\n <RepeatRecordContext.Provider value={firstRecord}>\n {children}\n </RepeatRecordContext.Provider>\n ) : repeatPreview ? (\n // No record to draw (AGL-3496): the template as written, its\n // `{{item.*}}` tokens drawn as named chips.\n <RepeatTemplateContext.Provider value>\n {children}\n </RepeatTemplateContext.Provider>\n ) : (\n children\n )}\n {repeatCopies.length ? (\n // The copies are drawn as the live page draws them: siblings of\n // the real children, in this element's own layout. They used to\n // sit in a wrapper box, which took one share of the parent's\n // spacing for all of them, so Sam and Jordan stacked tight under\n // a gap that only Avery got.\n //\n // Inert, like the component and form previews below: a copy is a\n // picture of the template, not a document, so nothing in it is\n // ever selected. A click on one goes to the element it draws —\n // this leaf's own handlers redirect it (`repeatCopyAt`).\n <>\n {/* Their outline, as CSS rather than as a wrapper: a dimmed,\n dashed GREY, so a copy never reads as the element — the\n real one keeps the canvas's hover and selection colours.\n Dashed when hovered too, only darker; solid is the\n selection's alone. MUI's Stack spacing skips <style>\n children, so this costs the layout nothing. */}\n <style>\n {repeatCopyCss(\n alpha(theme.palette.grey[500], 0.6),\n alpha(theme.palette.grey[800], 0.9),\n hoveredInRepeat,\n )}\n </style>\n <RendererComponents.Provider value={INERT_RENDERER as any}>\n {repeatCopies.map((copy) => (\n <Stem\n key={copy.$id}\n node={asRepeatCopy(copy, repeatPreview?.label ?? '')}\n />\n ))}\n </RendererComponents.Provider>\n </>\n ) : null}\n {repeatPreview ? (\n <RepeatBadge\n nodeId={node.$id}\n label={repeatPreview.label}\n count={repeatPreview.records.length}\n missing={repeatPreview.missing}\n />\n ) : null}\n {placedForm ? (\n // Inert and click-through like the instance preview below: the\n // fields belong to the form, and they are edited in the form's own\n // besigner, so the only selectable thing here is the placement.\n <Box sx={{ pointerEvents: 'none' }} data-aglyn-form-preview=\"\">\n <RendererComponents.Provider value={INERT_RENDERER as any}>\n {placedForm.trees.map((tree) => (\n <Stem key={tree.$id} node={tree} />\n ))}\n </RendererComponents.Provider>\n </Box>\n ) : null}\n {instanceTree ? (\n // `pointerEvents: none` so a click anywhere on the rendered\n // component still lands on the instance beneath it — the\n // instance is the only thing here that can be selected, and the\n // only thing whose Attributes are editable.\n <Box sx={{ pointerEvents: 'none' }} data-aglyn-component-preview=\"\">\n <RendererComponents.Provider value={INERT_RENDERER as any}>\n <Stem node={instanceTree} />\n </RendererComponents.Provider>\n </Box>\n ) : null}\n {showSlotMarker ? (\n <SlotMarker\n caption={node?.props?.['caption'] as string | undefined}\n />\n ) : null}\n {showEmptyDocumentSlot ? <EmptyDocumentSlot /> : null}\n </Leaf>\n </DraggableDroppable>\n )\n }),\n)\nNodeLeaf.displayName = 'BesignerLeafComponent'\nNodeLeaf.aglyn = true\n\nexport default NodeLeaf\n"],"names":["buildComponentDefaultIconPaths","buildComponentDefaultTokens","buildComponentDefaultValues","composeReusableComponentNodes","displayBindingTokens","FORM_COMPONENT_ID","hasBindings","HostViewType","isNodeHiddenByHost","LAYOUT_SLOT_COMPONENT_ID","NODE_ROOT_ID","placedFormPlacement","resolveBindings","resolveComponentPropTokens","REUSABLE_INSTANCE_COMPONENT_ID","Branch","Leaf","RendererComponents","Stem","Trunk","Besigner","alpha","Box","useTheme","observer","forwardRef","useCallback","useContext","useEffect","useMemo","useRef","useAglynBesignerPanel","requestAttributeFocus","BindingPickerContext","CanvasChromeThemeContext","CanvasRevealContext","CanvasMutedClassesContext","CanvasHostTokensContext","ComponentPromotionContext","useRenderedCanvasElements","useAglynBesignerFlag","useNodeWithMediaAssetFacts","useNodeWithBindings","useNodeWithHostTokens","useNodeWithRepeatRecord","useRepeatCopies","useRepeatPreview","RepeatRecordContext","RepeatTemplateContext","isNodeHiddenOnSite","isNodeRevealedOnCanvas","stripMutedClasses","DraggableDroppable","EmptyDocumentSlot","REPEAT_COPY_ATTR","MediaFactsLeaf","props","ref","node","rest","host","withBindings","withHostTokens","withRecord","shown","displayName","INERT_RENDERER","TrunkComponent","StemComponent","BranchComponent","LeafComponent","denormalizeTree","nodes","rootId","seen","Set","has","undefined","add","childIds","Array","isArray","children","map","childId","filter","Boolean","useChromeTheme","theme","SlotMarker","caption","accent","palette","primary","main","aria-hidden","data-aglyn-slot-marker","sx","m","p","minHeight","display","flexDirection","alignItems","justifyContent","gap","borderWidth","borderStyle","borderColor","backgroundColor","borderRadius","color","fontSize","textAlign","component","fontWeight","asRepeatCopy","copy","label","title","repeatCopyCss","hover","hovered","repeatBadgeText","count","missing","fix","text","explanation","toLowerCase","RepeatBadge","nodeId","chrome","setRightPanel","setRightPanelRef","current","badgeRef","badge","open","event","button","prev","toggled","tab","BesignerPanelTabFlag","ELEMENT_PROPS_FORM","addEventListener","removeEventListener","tone","tertiary","warning","radius","shape","data-aglyn-repeat-badge","data-aglyn-repeat-empty","position","top","right","zIndex","cursor","px","py","maxWidth","overflow","textOverflow","whiteSpace","borderBottomLeftRadius","contrastText","fontFamily","typography","fontWeightBold","lineHeight","NodeLeaf","viewType","elements","setElementRef","deleteElementRef","$id","registered","registerElement","element","Element","dragHandle","showSlotMarker","componentId","LAYOUT","showEmptyDocumentSlot","length","revealedNodeIds","canvasHost","mutedClasses","resolveFlag","variables","functions","componentProps","boundProps","Object","entries","value","JSON","stringify","defaultPropTokens","defaultIconPaths","defaultValues","renderNode","hasDeclaredProps","keys","resolved","key","next","String","hostResolvedNode","renderNodeUnclassed","withRepeatRecord","shownNode","repeatPreview","repeatCopies","focus","getHovered","hoveredInRepeat","test","firstRecord","records","record","model","dataset","datasetsByKey","definitions","formDesigns","instanceTree","definition","refId","parse","className","_placementClasses","snapshotProps","composed","styleOverrides","attrOverrides","grafted","placedForm","formId","replacement","trees","shownLeafNode","leafNode","hostHidden","isNodeOrDescendantSelected","some","id","drawnNode","hidden","type","DragType","CANVAS","accept","values","disableDragging","dnd","canDragNode","data-aglyn-selected","isNodeSelected","data-aglyn-selected-within","data-aglyn-revealed","data-aglyn-bound","Provider","style","grey","pointerEvents","data-aglyn-form-preview","tree","data-aglyn-component-preview","aglyn"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,8BAA8B,EAC9BC,2BAA2B,EAC3BC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,oBAAoB,EACpBC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,kBAAkB,EAClBC,wBAAwB,EACxBC,YAAY,EACZC,mBAAmB,EACnBC,eAAe,EACfC,0BAA0B,EAC1BC,8BAA8B,QACzB,eAAc;AACrB,SACEC,MAAM,EACNC,IAAI,EAEJC,kBAAkB,EAClBC,IAAI,EACJC,KAAK,QACA,6BAA4B;AACnC,YAAYC,cAAc,kBAAiB;AAC3C,SAASC,KAAK,EAAEC,GAAG,EAAEC,QAAQ,QAAQ,gBAAe;AAEpD,S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