{
  "version": 3,
  "sources": ["../../../../../node_modules/@framerjs/framer-events/lib/esm/generated/ComponentCanvasEnter.js", "../../src/document/components/utils/sortInRouteSegmentOrder.ts", "../../src/document/stores/ScopeStore.ts", "../../src/document/components/chrome/siteSettings/Redirects/validateRedirects.ts", "../../src/document/components/utils/getReadableWebPageLinkPaths.ts", "../../src/document/models/CanvasTree/nodes/utils/redirectRouteNode.ts", "../../src/code-generation/getPublishedWebPageLayoutTemplateControlProps.ts", "../../src/export/exportLayoutTemplates.ts"],
  "sourcesContent": ["import { triggerEvent } from \"../listeners\";\nfunction createComponentCanvasEnterEvent(payload) {\n  console.warn(\"[DEPRECATED] Use triggerComponentCanvasEnterEvent instead of createComponentCanvasEnterEvent.\");\n  return {\n    ...payload,\n    event: \"component_canvas_enter\"\n  };\n}\nconst meta = {\n  track: true\n};\nfunction triggerComponentCanvasEnterEvent(payload) {\n  const event = {\n    ...payload,\n    event: \"component_canvas_enter\"\n  };\n  triggerEvent(event, meta);\n}\nexport {\n  createComponentCanvasEnterEvent,\n  triggerComponentCanvasEnterEvent\n};\n", "import type { CanvasTree, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { getRouteSegmentRootNode } from \"document/models/CanvasTree/nodes/RouteSegmentRootNode.utils.ts\"\nimport type { AnyWebPageNode } from \"document/models/CanvasTree/nodes/WebPageNode.ts\"\n\nexport function sortInRouteSegmentOrder<T extends AnyWebPageNode>(tree: CanvasTree, webPages: Iterable<T>): T[] {\n\tconst webPagesById: Map<NodeID, T> = new Map()\n\tconst abVariantsByControlId: Map<NodeID, T[]> = new Map()\n\n\tfor (const page of webPages) {\n\t\tif (page.abTestingParentId) {\n\t\t\tlet variants = abVariantsByControlId.get(page.abTestingParentId)\n\t\t\tif (!variants) {\n\t\t\t\tvariants = []\n\t\t\t\tabVariantsByControlId.set(page.abTestingParentId, variants)\n\t\t\t}\n\t\t\tvariants.push(page)\n\t\t} else {\n\t\t\twebPagesById.set(page.id, page)\n\t\t}\n\t}\n\n\tconst webPagesInRouteSegmentOrder: T[] = []\n\n\tfor (const webPageId of getRouteSegmentRootNode(tree).getWebPageIdToRawPathMap(tree).keys()) {\n\t\tconst webPage = webPagesById.get(webPageId)\n\t\tif (webPage) {\n\t\t\twebPagesInRouteSegmentOrder.push(webPage)\n\t\t\t// A/B Variants are not referenced from route segments,\n\t\t\t// so we have to insert them manually after each control page\n\t\t\tconst abVariants = abVariantsByControlId.get(webPage.id)\n\t\t\tif (abVariants) {\n\t\t\t\twebPagesInRouteSegmentOrder.push(...abVariants)\n\t\t\t}\n\t\t}\n\t}\n\treturn webPagesInRouteSegmentOrder\n}\n", "import { triggerComponentCanvasEnterEvent } from \"@framerjs/framer-events\"\nimport type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport { ReadonlyMap, assert, emptyArray, getLogger } from \"@framerjs/shared\"\nimport { EngineStore } from \"document/EngineStore.ts\"\nimport { getScopeTypeForScope, type BaseScopeStore } from \"document/base-engine/BaseScopeStore.ts\"\nimport { sortInRouteSegmentOrder } from \"document/components/utils/sortInRouteSegmentOrder.ts\"\nimport {\n\tcanRenderPageTypeBeforeDocumentHasFullyLoaded,\n\tgetFirstPageNodeAccordingToUI,\n} from \"document/firstScopeFinder.ts\"\nimport type {\n\tAnyCanvasPageNode,\n\tAnyScopeNode,\n\tAnySmartComponentNode,\n\tAnyWebPageNode,\n\tCanvasNode,\n\tCanvasTree,\n\tLoadedScopeNode,\n\tMaybeNodeID,\n\tNodeID,\n\tShallowScopeNode,\n\tShallowWebPageNode,\n\tSmartComponentNode,\n} from \"document/models/CanvasTree/index.ts\"\nimport { ScopeNode, isScopeNode } from \"document/models/CanvasTree/index.ts\"\nimport type { AnyDesignPageNode } from \"document/models/CanvasTree/nodes/DesignPageNode.ts\"\nimport type { AnyLayoutTemplateNode, LayoutTemplateNode } from \"document/models/CanvasTree/nodes/LayoutTemplateNode.ts\"\nimport { isContentNode } from \"document/models/CanvasTree/nodes/TreeNode.ts\"\nimport type { VectorSetNode } from \"document/models/CanvasTree/nodes/VectorSetNode.ts\"\nimport {\n\tisCanvasPageNode,\n\tisCollectionNode,\n\tisContentManagementNode,\n\tisDesignPageNode,\n\tisLayoutTemplateNode,\n\tisSmartComponentNode,\n\tisVectorSetNode,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { createOverlayWithEventOrTriggerAction } from \"document/models/CanvasTree/nodes/utils/overlayCreationHelpers.ts\"\nimport { isFixedOrRelativeOverlay } from \"document/models/CanvasTree/nodes/utils/overlayHelpers.ts\"\nimport type { WithCollectionDataSource } from \"document/models/CanvasTree/traits/WithCollectionDataSource.ts\"\nimport { hasCollectionDataSource } from \"document/models/CanvasTree/traits/WithCollectionDataSource.ts\"\nimport { hasFloatingPosition } from \"document/models/CanvasTree/traits/WithFloatingPosition.ts\"\nimport { isHiddenMaster } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { HardCodedCodeIdentifier } from \"document/models/CanvasTree/traits/utils/hardCodedCodeComponentIdentifiers.ts\"\nimport type { ActiveContentPanelTab } from \"document/utils/ActiveEditorType.ts\"\nimport { ScopeType } from \"document/utils/scopeType.ts\"\nimport type { Point } from \"library/render/types/Point.ts\"\nimport type { NonUndefinedRecord } from \"utils/NonUndefined.ts\"\nimport { isShallowArrayEqual } from \"utils/isShallowEqual.ts\"\nimport { isString } from \"utils/typeChecks.ts\"\nimport { record } from \"web/lib/tracker.ts\"\nimport { setLoadWasChecked } from \"../models/CanvasTree/nodes/ScopeNode.ts\"\nimport type { AIGenerationStore } from \"./AIGenerationStore.ts\"\nimport type { CanvasStore } from \"./CanvasStore.ts\"\nimport type { ChromeStore } from \"./ChromeStore.ts\"\nimport type { CodeGenerationStore } from \"./CodeGenerationStore.ts\"\nimport type { ContentManagementStore } from \"./ContentManagementStore.ts\"\nimport type { InsertSidebarStore } from \"./InsertSidebarStore.ts\"\nimport type { ModulesStore } from \"./ModulesStore.ts\"\nimport type { OverlayStore } from \"./OverlayStore.ts\"\nimport type { SelectionStore } from \"./SelectionStore.ts\"\nimport type { TreeStore } from \"./TreeStore.ts\"\n\nconst log = getLogger(\"ScopeStore\")\n\ninterface CanvasViewportState {\n\tzoom: number\n\toffset: Point\n}\n\nexport interface SelectScopeOptions {\n\t/**\n\t * `true` if you want to preserve `#componentHistory`, `false` if you want to reset it.\n\t * `#componentHistory` is a stack of nodes in hierarchical order, ultimately responsible for\n\t * what's shown in `BreadcrumbBar`, via `isolatedCanvasNodes`. Use `true` if the scope you're\n\t * selecting is reached through the currently active scope, use `false` otherwise (most cases).\n\t */\n\tkeepHistory: boolean\n\tactivateContentPanel?: ActiveContentPanelTab\n\tcollectionItemId?: string\n\tagent?: boolean\n}\n\nenum RootScopeType {\n\tCanvasPage = \"CanvasPage\",\n\tWebPage = \"WebPage\",\n\tDesignPage = \"DesignPage\",\n}\n\ntype RootScopeNode = AnyCanvasPageNode | AnyWebPageNode | AnyDesignPageNode\n\nexport function isRootScopeNode(node: CanvasNode | AnyScopeNode): node is RootScopeNode {\n\treturn isCanvasPageNode(node, true) || isWebPageNode(node, true) || isDesignPageNode(node, true)\n}\n\nexport class ScopeStore extends EngineStore implements BaseScopeStore {\n\t// We use the activeIndex to get a fallback scope when the scope with the activeId was deleted from the tree\n\t#activeIndex = 0\n\tprivate isCheckingActivePage = true\n\t#mostRecentCanvasPageId: string = \"\"\n\t#mostRecentWebPageId: string = \"\"\n\t#mostRecentDesignPageId: string = \"\"\n\t#previousActiveScopeId: NodeID = \"\"\n\t#componentHistory: NodeID[] = []\n\t#onIsolatedCanvas = false\n\t#onCollectionPage = false\n\n\t#canvasViewportState = new Map<string, CanvasViewportState>()\n\t#selectionState = new Map<string, NodeID[]>()\n\n\tprivate loadingActiveId?: string\n\tprivate _activeId: string\n\n\tscopeSwitchStart = 0\n\tscopeSwitchPending = false\n\n\t// Private but not prefixed with # to enable store updates on changes\n\tprivate scopeIdToSelectedCollectionItem: ReadonlyMap<NodeID, NodeID> = new Map()\n\n\t/** The id of the current scope. */\n\tget activeId(): NodeID {\n\t\treturn this._activeId\n\t}\n\n\t/** The id of the scope being switched to while a switch is in flight, otherwise the current active scope.\n\t *  loadingActiveId is only authoritative while scopeSwitchPending is true \u2014 it isn't cleared when a switch aborts. */\n\tget pendingOrActiveId(): NodeID {\n\t\tif (this.scopeSwitchPending && this.loadingActiveId !== undefined) {\n\t\t\treturn this.loadingActiveId\n\t\t}\n\t\treturn this._activeId\n\t}\n\n\t/** The active scope node, which is the currently active page in the project. It will be a draft version if the scope has had edits already. This is a getter that will do some validation. */\n\tget active(): LoadedScopeNode {\n\t\t// we type cast here because we know that the activeId is always a fully loaded scope\n\t\tconst scopeNode = this.getScopeNode(this._activeId)\n\t\tassert(scopeNode.isLoaded(), \"Scope must be fully loaded\")\n\t\treturn scopeNode\n\t}\n\n\tprivate rootScopeType = RootScopeType.CanvasPage\n\n\tprivate get rootNode() {\n\t\treturn this.treeStore.tree.root\n\t}\n\n\tconstructor(\n\t\tprivate readonly componentLoader: ComponentLoader,\n\t\tprivate readonly treeStore: TreeStore,\n\t\tprivate readonly canvasStore: CanvasStore,\n\t\tprivate readonly selection: SelectionStore,\n\t\tprivate readonly chromeStore: ChromeStore,\n\t\tprivate readonly contentManagementStore: ContentManagementStore,\n\t\tprivate readonly overlayStore: OverlayStore,\n\t\tprivate readonly codeGenerationStore: CodeGenerationStore,\n\t\tprivate readonly insertSidebarStore: InsertSidebarStore,\n\t\tprivate readonly modulesStore: ModulesStore,\n\t\tprivate readonly aiGenerationStore: AIGenerationStore,\n\t\tprivate readonly onUserScopeSwitch: () => void,\n\t) {\n\t\tsuper()\n\n\t\t// Select first page by default.\n\t\tconst firstPage = this.getFirstPageNodeAccordingToUI()\n\t\tthis._activeId = firstPage.id\n\t\tsetLoadWasChecked(firstPage)\n\t\tif (isCanvasPageNode(firstPage)) {\n\t\t\tthis.#mostRecentCanvasPageId = firstPage.id\n\t\t} else if (isWebPageNode(firstPage)) {\n\t\t\tthis.#mostRecentWebPageId = firstPage.id\n\t\t} else if (isDesignPageNode(firstPage)) {\n\t\t\tthis.#mostRecentDesignPageId = firstPage.id\n\t\t}\n\n\t\tconst scopeNodes = this.getScopeNodes()\n\t\tthis.#activeIndex = scopeNodes.indexOf(firstPage)\n\t\tassert(firstPage.loaded, \"Scope must be fully loaded\")\n\t\tinsertSidebarStore.onScopeChange({\n\t\t\tscope: firstPage.loaded,\n\t\t\thasCanvasPageNodes: this.hasCanvasPageNodes(),\n\t\t\thasWebPageNodes: this.hasWebPageNodes(),\n\t\t})\n\n\t\tthis.modulesStore.setActiveScope(this._activeId)\n\t}\n\n\tget checkingActivePage() {\n\t\treturn this.isCheckingActivePage\n\t}\n\n\tdocumentDidLoad() {\n\t\tthis.isCheckingActivePage = false\n\t}\n\n\tget scopeType(): ScopeType {\n\t\treturn getScopeTypeForScope(this.active)\n\t}\n\n\tgetScopeNode(id: string): ShallowScopeNode {\n\t\tconst scopeNode = this.treeStore.tree.get<ShallowScopeNode>(id)\n\t\tassert(scopeNode instanceof ScopeNode, \"Node, \", id, \"is not a ScopeNode\")\n\t\treturn scopeNode\n\t}\n\n\tgetScopeNodes(): AnyScopeNode[] {\n\t\treturn this.treeStore.tree.root.children.filter(isScopeNode)\n\t}\n\n\tgetCanvasPageNodes(): AnyCanvasPageNode[] {\n\t\treturn getCanvasPageNodes(this.treeStore.tree)\n\t}\n\n\tgetDesignPageNodes(): AnyDesignPageNode[] {\n\t\treturn this.rootNode.children.filter(isDesignPageNode)\n\t}\n\n\tgetKitPageNodes(): AnyWebPageNode[] {\n\t\tconst kitPages: AnyWebPageNode[] = []\n\t\tfor (const node of this.rootNode.children) {\n\t\t\tif (!isWebPageNode(node)) continue\n\t\t\tif (!node.kitPage) continue\n\t\t\tkitPages.push(node)\n\t\t}\n\t\treturn kitPages\n\t}\n\n\tgetSmartComponentNodes(): AnySmartComponentNode[] {\n\t\treturn this.rootNode.children.filter(isSmartComponentNode)\n\t}\n\n\tgetLayoutTemplateNodes(): AnyLayoutTemplateNode[] {\n\t\treturn this.rootNode.children.filter(isLayoutTemplateNode)\n\t}\n\n\tgetWebPageNodes(): AnyWebPageNode[] {\n\t\treturn getWebPageNodes(this.treeStore.tree)\n\t}\n\n\tgetWebPageNodesWithoutCollection(): AnyWebPageNode[] {\n\t\treturn getWebPageNodesWithoutCollection(this.treeStore.tree)\n\t}\n\n\tgetWebPageNodesWithCollection(sorted = false): (ShallowWebPageNode & NonUndefinedRecord<WithCollectionDataSource>)[] {\n\t\treturn getWebPageNodesWithCollection(this.treeStore.tree, sorted)\n\t}\n\n\thasPages(): {\n\t\thasSitesPages: boolean\n\t\thasCMSPages: boolean\n\t\thasCanvasPages: boolean\n\t\thasDesignPages: boolean\n\t\thasKitPages: boolean\n\t} {\n\t\tlet hasSitesPages = false\n\t\tlet hasCMSPages = false\n\t\tlet hasCanvasPages = false\n\t\tlet hasDesignPages = false\n\t\tlet hasKitPages = false\n\t\tfor (const node of this.rootNode.children) {\n\t\t\tif (isCanvasPageNode(node)) hasCanvasPages = true\n\t\t\tif (isDesignPageNode(node)) hasDesignPages = true\n\t\t\tif (isWebPageNode(node)) {\n\t\t\t\tif (node.kitPage) {\n\t\t\t\t\thasKitPages = true\n\t\t\t\t} else if (node.dataIdentifier) {\n\t\t\t\t\thasCMSPages = true\n\t\t\t\t} else {\n\t\t\t\t\thasSitesPages = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (hasSitesPages && hasCMSPages && hasCanvasPages && hasDesignPages && hasKitPages) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn { hasSitesPages, hasCMSPages, hasCanvasPages, hasDesignPages, hasKitPages }\n\t}\n\n\tprivate hasCanvasPageNodes(): boolean {\n\t\treturn this.rootNode.children.some(isCanvasPageNode)\n\t}\n\n\tprivate hasWebPageNodes(): boolean {\n\t\treturn this.rootNode.children.some(isWebPageNode)\n\t}\n\n\tgetRootScopeNodes(): RootScopeNode[] {\n\t\t// TODO Check and handle shallow/fully loaded scope state\n\t\t// fix type casting as root node children should be typed correctly\n\t\treturn this.rootNode.children.filter(isRootScopeNode) as unknown as RootScopeNode[]\n\t}\n\n\t/** Gets the first possible page, according to the Pages panel order. */\n\tprivate getFirstPageNodeAccordingToUI(tree = this.treeStore.tree): RootScopeNode {\n\t\tconst { children, homePageNodeId } = tree.root\n\t\treturn getFirstPageNodeAccordingToUI(children, homePageNodeId)\n\t}\n\n\tgetFirstWebPageNode(): AnyWebPageNode | undefined {\n\t\ttry {\n\t\t\tconst node = this.getFirstPageNodeAccordingToUI()\n\t\t\tif (isWebPageNode(node)) {\n\t\t\t\treturn node\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore.\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate changeActive(tree: CanvasTree, scope: LoadedScopeNode, index: number) {\n\t\t// Note this method receives a canvas tree, which might be different from treeStore.tree, so\n\t\t// we have to be careful not to accidentally mix the two.\n\n\t\tif (this._activeId) {\n\t\t\tconst activeScope = tree.get(this._activeId)\n\n\t\t\t// Save canvas viewport. Ensure the same viewport when toggling between A/B variants\n\t\t\tconst id =\n\t\t\t\tisWebPageNode(activeScope) && activeScope.abTestingParentId ? activeScope.abTestingParentId : this._activeId\n\t\t\tthis.#canvasViewportState.set(id, { zoom: this.canvasStore.zoom, offset: this.canvasStore.offset })\n\n\t\t\t// Save canvas selection\n\t\t\tthis.#selectionState.set(this._activeId, this.selection.ids)\n\n\t\t\tif (isSmartComponentNode(activeScope)) {\n\t\t\t\trecord(\"component_canvas_exit\", { componentId: this._activeId })\n\t\t\t}\n\t\t}\n\n\t\tthis.#previousActiveScopeId = this._activeId\n\n\t\t// Change scope\n\t\tthis.#activeIndex = index\n\t\tthis._activeId = scope.id\n\t\tsetLoadWasChecked(scope)\n\t\tthis.codeGenerationStore.changeScope()\n\t\tthis.modulesStore.changeScope(scope)\n\n\t\tif (isDesignPageNode(scope)) {\n\t\t\tthis.rootScopeType = RootScopeType.DesignPage\n\t\t\tthis.#mostRecentDesignPageId = scope.id\n\t\t\tthis.#componentHistory = []\n\t\t\tthis.#onIsolatedCanvas = false\n\t\t\tthis.#onCollectionPage = false\n\t\t} else if (isCanvasPageNode(scope)) {\n\t\t\tthis.rootScopeType = RootScopeType.CanvasPage\n\t\t\tthis.#mostRecentCanvasPageId = scope.id\n\t\t\tthis.#componentHistory = []\n\t\t\tthis.#onIsolatedCanvas = false\n\t\t\tthis.#onCollectionPage = false\n\t\t} else if (isWebPageNode(scope)) {\n\t\t\tthis.rootScopeType = RootScopeType.WebPage\n\t\t\tthis.#mostRecentWebPageId = scope.id\n\t\t\tthis.#componentHistory = []\n\t\t\tthis.#onIsolatedCanvas = false\n\t\t\tthis.#onCollectionPage = hasCollectionDataSource(scope)\n\t\t} else if (isSmartComponentNode(scope) || isLayoutTemplateNode(scope) || isVectorSetNode(scope)) {\n\t\t\tconst indexInHistory = this.#componentHistory.indexOf(scope.id)\n\t\t\tif (indexInHistory === -1) {\n\t\t\t\tthis.#componentHistory.push(scope.id)\n\t\t\t} else {\n\t\t\t\tthis.#componentHistory.splice(indexInHistory + 1)\n\t\t\t}\n\t\t\tthis.#onIsolatedCanvas = this.#componentHistory.length > 0\n\t\t\tthis.#onCollectionPage = false\n\t\t\ttriggerComponentCanvasEnterEvent({\n\t\t\t\tcomponentId: scope.id,\n\t\t\t})\n\t\t}\n\n\t\t// Restore canvas viewport. Ensure the same viewport when toggling between A/B variants\n\t\tconst canvasViewport = this.#canvasViewportState.get(\n\t\t\tisWebPageNode(scope) && scope.abTestingParentId ? scope.abTestingParentId : scope.id,\n\t\t)\n\t\tif (canvasViewport) {\n\t\t\tthis.canvasStore.updateCanvas(canvasViewport.offset, canvasViewport.zoom)\n\t\t} else {\n\t\t\tthis.canvasStore.zoomAfterScopeSwitch(tree, scope)\n\t\t}\n\n\t\t// Restore canvas selection\n\t\tconst canvasSelection = this.#selectionState.get(scope.id)\n\t\tif (canvasSelection) {\n\t\t\tthis.selection.set(canvasSelection)\n\t\t} else {\n\t\t\tthis.selection.clear()\n\t\t}\n\n\t\t// When entering the CMS scope with no selection, fall back to selecting the first collection\n\t\tif (isContentManagementNode(scope) && (!canvasSelection || canvasSelection.length === 0)) {\n\t\t\tconst firstCollection = scope.children.find(isCollectionNode)\n\t\t\tif (firstCollection) {\n\t\t\t\tthis.selection.set(firstCollection)\n\t\t\t}\n\t\t}\n\n\t\tthis.overlayStore.hideAll()\n\n\t\tthis.insertSidebarStore.onScopeChange({\n\t\t\tscope,\n\t\t\thasWebPageNodes: this.hasWebPageNodes(),\n\t\t\thasCanvasPageNodes: this.hasCanvasPageNodes(),\n\t\t})\n\t\tthis.treeStore.setHighlight(null)\n\n\t\t// Not using this.scopeType, as that will indirectly use treeStore.tree.\n\t\tconst scopeType = getScopeTypeForScope(scope)\n\t\tthis.chromeStore.onChangeScopeType(scopeType)\n\t\tthis.contentManagementStore.onChangeScopeType(scopeType)\n\t\tthis.aiGenerationStore.setCurrentSessionId(scopeType === ScopeType.DesignPage ? scope.id : undefined)\n\t}\n\n\t/** @param keepHistory - See {@link SelectScopeOptions.keepHistory}. */\n\tselect(id: string, { keepHistory, activateContentPanel, collectionItemId, agent = false }: SelectScopeOptions) {\n\t\tif (agent === false) this.onUserScopeSwitch()\n\n\t\tthis.loadingActiveId = id\n\t\tthis.scopeSwitchStart = performance.now()\n\n\t\tconst switchScope = () => {\n\t\t\tthis.scopeSwitchPending = false\n\t\t\t// Make sure the switch callback is still valid before doing any work.\n\t\t\tif (this.loadingActiveId !== id) return\n\n\t\t\tif (this._activeId === id) return\n\n\t\t\tconst scopeNodes = this.getScopeNodes()\n\t\t\tconst index = scopeNodes.findIndex(scope => scope.id === id)\n\n\t\t\t// It might happen that a scope that we can switch to is actually deleted by further diffs.\n\t\t\tif (index < 0) return\n\n\t\t\tconst latestTree = this.treeStore.tree.latestTree()\n\t\t\tconst scope = latestTree.getNode(id)\n\t\t\tassert(isScopeNode(scope), \"Tree must contain scope node\", id)\n\t\t\tlet loadedScope: LoadedScopeNode\n\t\t\tif (!scope.isLoaded()) {\n\t\t\t\t/*\n                 if we don't have a loader, and scope is shallow,\n                    we are in the wrong state in our app,\n                    so let's report this to sentry without throwing an error\n                */\n\t\t\t\tif (!this.treeStore.tree.getService(\"loader\")) {\n\t\t\t\t\tlog.reportError(\n\t\t\t\t\t\tnew ReferenceError(\"Loader service is not available in the tree but scope is not loaded\"),\n\t\t\t\t\t\t{ message: \"Scope must be fully loaded\" },\n\t\t\t\t\t\t{ shallowScopes: \"true\" },\n\t\t\t\t\t)\n\t\t\t\t\tloadedScope = scope as unknown as LoadedScopeNode\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError(\"Scope must be fully loaded\")\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tloadedScope = scope.loaded\n\t\t\t}\n\n\t\t\tif (!keepHistory) {\n\t\t\t\tthis.#componentHistory = []\n\t\t\t}\n\n\t\t\tif (isString(collectionItemId) && isWebPageNode(scope)) {\n\t\t\t\tthis.setSelectedCollectionItemForWebPage(scope.id, collectionItemId)\n\t\t\t}\n\n\t\t\tif (activateContentPanel) {\n\t\t\t\tthis.chromeStore.contentPanelTab = activateContentPanel\n\t\t\t}\n\n\t\t\tthis.changeActive(this.treeStore.tree, loadedScope, index)\n\t\t}\n\n\t\t// If the tree has a loader, and the scope we are switching to hasn't loaded yet, request it\n\t\t// to be loaded soon, and wait for it before switching.\n\t\tconst loader = this.treeStore.tree.getService(\"loader\")\n\t\tif (loader && !loader.hasLoadedScope(id)) {\n\t\t\tthis.scopeSwitchPending = true\n\t\t\tloader.prioritizeLoadingScope(id, () => this.scheduler.processWhenReady(switchScope))\n\t\t\treturn\n\t\t}\n\n\t\tswitchScope()\n\t}\n\n\tselectByNode(id: string) {\n\t\tconst node = this.treeStore.tree.get(id)\n\t\tif (node === null) return\n\n\t\tlet scope: AnyScopeNode | null\n\t\tif (isScopeNode(node)) {\n\t\t\tscope = node\n\t\t} else {\n\t\t\tscope = this.treeStore.tree.getScopeNodeFor(node)\n\t\t}\n\t\tif (scope === null) return\n\n\t\tthis.select(scope.id, { keepHistory: false })\n\t}\n\n\tselectScopeByAgent(id: NodeID) {\n\t\tthis.select(id, { keepHistory: false, agent: true })\n\t}\n\n\tselectPreviousActiveScope() {\n\t\tconst previousScope = this.treeStore.tree.get(this.#previousActiveScopeId)\n\t\tthis.select(previousScope?.id ?? this.getFirstPageNodeAccordingToUI().id, { keepHistory: false })\n\t}\n\n\t/**\n\t * Used to find active scope before removing the active node\n\t */\n\tfindNextActiveScopeBeforeRemove(tree = this.treeStore.tree): ShallowScopeNode | undefined {\n\t\tconst scopeNodes = tree.root.children.filter(c => isScopeNode(c) && c.id !== this.activeId) as ShallowScopeNode[]\n\t\tconst index = this.findNextAvailablePageIndex(scopeNodes, this.#activeIndex)\n\t\treturn scopeNodes[index]\n\t}\n\n\tfindNextActiveScope(tree = this.treeStore.tree) {\n\t\tconst rootNode = tree.root\n\t\t// FIXME: We now have so many scope nodes and UI sections (CMS, Smart\n\t\t// Component, Web Page, Web Page with Collection, etc) that using this\n\t\t// list to pick the next available scope node will feel quite random. We\n\t\t// need to come up with a better solution for this.\n\t\tconst scopeNodes = rootNode.children.filter(isScopeNode)\n\n\t\tassert(\n\t\t\trootNode.children.some(isRootScopeNode),\n\t\t\t\"validateActiveScope: Tree must contain at least one Canvas Page or Web Page\",\n\t\t)\n\t\tlet index = scopeNodes.findIndex(scope => scope.id === this._activeId)\n\n\t\t// If the active scope is deleted, fall back to the next available page.\n\t\t// If there's no page after the deleted one, pick the last page.\n\t\tif (index === -1) {\n\t\t\tindex = this.findNextAvailablePageIndex(scopeNodes, this.#activeIndex)\n\t\t}\n\t\treturn [scopeNodes[index], index] as const\n\t}\n\n\tvalidateActiveScope(tree = this.treeStore.tree, allowShallow = false): ScopeNode {\n\t\tconst [scopeNode, index] = this.findNextActiveScope(tree)\n\t\tassert(scopeNode, \"ScopeNode must be defined\")\n\t\tif (!allowShallow) assert(scopeNode.isLoaded(), \"Scope must be fully parsed\")\n\t\tthis.#activeIndex = index\n\n\t\tconst loadedScope = scopeNode as unknown as LoadedScopeNode\n\t\tif (scopeNode.id !== this._activeId) {\n\t\t\tthis.scopeSwitchStart = performance.now()\n\t\t\tthis.scopeSwitchPending = false\n\t\t\tthis.changeActive(tree, loadedScope, index)\n\t\t}\n\n\t\treturn loadedScope\n\t}\n\n\tprivate switchScope(tree = this.treeStore.tree, id: string) {\n\t\tconst scopeNodes = tree.root.children.filter(isScopeNode)\n\t\tconst index = scopeNodes.findIndex(node => node.id === id)\n\t\tconst scopeNode = scopeNodes[index]\n\t\tassert(scopeNode?.isLoaded(), \"Scope must be fully parsed\")\n\t\tthis.#activeIndex = index\n\n\t\tif (scopeNode.id !== this._activeId) {\n\t\t\tthis.scopeSwitchStart = performance.now()\n\t\t\tthis.scopeSwitchPending = false\n\t\t\tthis.changeActive(tree, scopeNode, index)\n\t\t}\n\t}\n\n\tprivate findNextAvailablePageIndex(scopeNodes: ShallowScopeNode[], startIndex: number): number {\n\t\tconst canvasPageIndexes: number[] = []\n\t\tconst webPageIndexes: number[] = []\n\t\tfor (let index = 0; index < scopeNodes.length; index++) {\n\t\t\tconst scopeNode = scopeNodes[index]\n\t\t\tif (isWebPageNode(scopeNode)) {\n\t\t\t\twebPageIndexes.push(index)\n\t\t\t} else if (isCanvasPageNode(scopeNode)) {\n\t\t\t\tcanvasPageIndexes.push(index)\n\t\t\t}\n\t\t}\n\t\tconst isWeb = this.rootScopeType === RootScopeType.WebPage\n\t\tconst mainIndexes = isWeb ? webPageIndexes : canvasPageIndexes\n\t\tconst secondaryIndexes = isWeb ? canvasPageIndexes : webPageIndexes\n\n\t\treturn findNextAvailableNumber(mainIndexes.length > 0 ? mainIndexes : secondaryIndexes, startIndex)\n\t}\n\n\trenameScope(id: string, name: string) {\n\t\tconst scopeNode = this.getScopeNode(id)\n\t\tscopeNode.set({ name })\n\t}\n\n\tprivate getActiveScopeNodeForReset(tree = this.treeStore.tree, nodeIdToOpen: MaybeNodeID = null): LoadedScopeNode {\n\t\tif (nodeIdToOpen) {\n\t\t\tconst scopeToOpen = tree.getScopeNodeFor(tree.get(nodeIdToOpen))\n\t\t\tif (canRenderPageTypeBeforeDocumentHasFullyLoaded(scopeToOpen) && scopeToOpen?.isValid()) return scopeToOpen\n\t\t}\n\n\t\tconst firstPage = this.getFirstPageNodeAccordingToUI(tree)\n\t\tif (isWebPageNode(firstPage) && firstPage.isValid() && firstPage.loaded) {\n\t\t\treturn firstPage.loaded\n\t\t}\n\n\t\tif ((isCanvasPageNode(firstPage) || isDesignPageNode(firstPage)) && firstPage.loaded) {\n\t\t\treturn firstPage.loaded\n\t\t}\n\n\t\tlog.warn(\"getActiveScopeNodeForReset: falling back to scanning for a useful scope to make active\")\n\t\t// Here we prefer web or canvas pages over smart components.\n\t\tfor (const child of tree.root.children) {\n\t\t\tif (isCanvasPageNode(child) && child.isValid() && child.loaded) return child.loaded\n\t\t\tif (isWebPageNode(child) && child.isValid() && child.loaded) return child.loaded\n\t\t}\n\t\tfor (const child of tree.root.children) {\n\t\t\tif (isSmartComponentNode(child) && child.isValid() && child.loaded) return child.loaded\n\t\t}\n\n\t\tthrow Error(\"Document does not have any scopes that can be set to active.\")\n\t}\n\n\tresetActiveScope(tree = this.treeStore.tree, nodeIdToOpen: MaybeNodeID = undefined) {\n\t\tconst scopeNodeToOpen = this.getActiveScopeNodeForReset(tree, nodeIdToOpen)\n\t\tif (scopeNodeToOpen.id === this._activeId) return\n\n\t\t// Reset internal state before running changeActive.\n\t\tthis._activeId = \"\"\n\t\tthis.#mostRecentCanvasPageId = \"\"\n\t\tthis.#mostRecentDesignPageId = \"\"\n\t\tthis.#mostRecentWebPageId = \"\"\n\t\tthis.#previousActiveScopeId = \"\"\n\t\tthis.#canvasViewportState.clear()\n\t\tthis.#selectionState.clear()\n\n\t\tassert(scopeNodeToOpen.isLoaded(), \"Scope must be fully parsed\")\n\t\tconst index = tree.root.children.indexOf(scopeNodeToOpen)\n\t\tthis.scopeSwitchStart = performance.now()\n\t\tthis.scopeSwitchPending = false\n\t\tthis.changeActive(tree, scopeNodeToOpen, index)\n\t}\n\n\tmovePage(id: NodeID, toIndex: number) {\n\t\tconst scopeNode = this.getScopeNode(id)\n\n\t\t// The toIndex is the index in the getScopeNodes array but the rootNode also contains hidden masters and SmartComponentNodes and WebPageNodes.\n\t\tconst pageNodes = this.getAllPageNodesOfScope(scopeNode)\n\n\t\tconst toNode = pageNodes[toIndex]\n\t\tassert(toNode, `Trying to move a page node to an invalid index: ${toIndex}, total: ${pageNodes.length} page nodes.`)\n\t\tconst rootIndex = this.rootNode.children.findIndex(node => node.id === toNode.id)\n\n\t\tassert(scopeNode.parentid, \"Scope node has no parentid\")\n\t\tassert(rootIndex !== -1, \"Cant find scope in root node\")\n\t\tthis.treeStore.tree.moveNode(scopeNode, scopeNode.parentid, rootIndex)\n\t}\n\n\tgetAllPageNodesOfScope(scopeNode: AnyScopeNode): readonly AnyScopeNode[] {\n\t\tif (isDesignPageNode(scopeNode)) return this.getDesignPageNodes()\n\t\tif (isCanvasPageNode(scopeNode)) return this.getCanvasPageNodes()\n\t\tif (isWebPageNode(scopeNode) && scopeNode.kitPage) return this.getKitPageNodes()\n\n\t\tassert(!scopeNode, \"Scope is not movable\")\n\n\t\treturn emptyArray<AnyScopeNode>()\n\t}\n\n\tprivate getParentId(node: CanvasNode, parentId?: NodeID | null, scopeId?: NodeID) {\n\t\tconst rootNodeId = this.rootNode.id\n\t\tif (node instanceof ScopeNode || isHiddenMaster(node)) {\n\t\t\treturn rootNodeId\n\t\t}\n\n\t\tconst scopeNode = scopeId ? this.getScopeNode(scopeId) : this.active\n\t\tif (isContentManagementNode(scopeNode)) {\n\t\t\tassert(isContentNode(node), \"ContentManagementNode only accepts content nodes\")\n\t\t}\n\n\t\tif (parentId === rootNodeId) {\n\t\t\treturn scopeNode.id\n\t\t}\n\n\t\treturn parentId ?? scopeNode.id\n\t}\n\n\tinsertNode(\n\t\tnode: CanvasNode,\n\t\tparentId?: NodeID | null,\n\t\tposition?: number,\n\t\tsourceNodeId?: NodeID /* If provided, the node will be positioned right after the source node (in each replicas) */,\n\t\tscopeId?: NodeID /* If provided, the parent id will be the scope id instead of the active scope id */,\n\t\ttree = this.treeStore.tree,\n\t) {\n\t\tparentId = this.getParentId(node, parentId, scopeId)\n\t\tif (isFixedOrRelativeOverlay(node)) {\n\t\t\tcreateOverlayWithEventOrTriggerAction(\n\t\t\t\tthis.componentLoader,\n\t\t\t\t{\n\t\t\t\t\tcodeGenerationStore: this.codeGenerationStore,\n\t\t\t\t\ttreeStore: this.treeStore,\n\t\t\t\t},\n\t\t\t\thasFloatingPosition(node)\n\t\t\t\t\t? HardCodedCodeIdentifier.showRelativeOverlayAction\n\t\t\t\t\t: HardCodedCodeIdentifier.showOverlayAction,\n\t\t\t\tparentId,\n\t\t\t\tnode,\n\t\t\t)\n\t\t}\n\n\t\ttree.insertNode(node, parentId, position, sourceNodeId)\n\t}\n\n\tinsertNodes(nodes: CanvasNode[]) {\n\t\tfor (const node of nodes) {\n\t\t\tthis.insertNode(node, node.parentid)\n\t\t}\n\t}\n\n\tmoveNode(\n\t\tnode: CanvasNode,\n\t\tparentId?: NodeID | null,\n\t\tposition?: number,\n\t\tsourceNodeId?: NodeID,\n\t\tscopeId?: NodeID,\n\t\ttree: CanvasTree = this.treeStore.tree,\n\t) {\n\t\tparentId = this.getParentId(node, parentId, scopeId)\n\t\ttree.moveNode(node, parentId, position, sourceNodeId)\n\t}\n\n\tremoveNode(node: CanvasNode): void {\n\t\tconst tree = this.treeStore.getDataTreeOrPartialTree()\n\t\tif (node.id !== this._activeId) {\n\t\t\ttree.removeNode(node)\n\t\t\treturn\n\t\t}\n\n\t\tconst shallowScopeNode = this.findNextActiveScopeBeforeRemove(this.treeStore.tree)\n\t\tassert(shallowScopeNode, \"No scope found to switch to after remove\")\n\t\tconst nextId = shallowScopeNode.id\n\n\t\tif (shallowScopeNode.isLoaded()) {\n\t\t\tthis.switchScope(this.treeStore.tree, nextId)\n\t\t\ttree.removeNode(node)\n\t\t\treturn\n\t\t}\n\n\t\t// We need to load the next scope, before we can delete current node.\n\t\tthis.loadingActiveId = nextId\n\t\tthis.scopeSwitchPending = true\n\n\t\t// Because other things might switch to yet another scope, that also needs loading, we need\n\t\t// to repeat until `this._activeId` is no longer `node.id`.\n\t\tconst loadSwitchAndRemove = () => {\n\t\t\tassert(this.loadingActiveId, \"Loading active id is not set\")\n\t\t\tconst loadingActiveNode = this.treeStore.tree.get<ScopeNode>(this.loadingActiveId)\n\t\t\tassert(loadingActiveNode, \"Loading active node is not available:\", this.loadingActiveId)\n\t\t\tvoid loadingActiveNode.load().then(() => {\n\t\t\t\tthis.scheduler.processWhenReady(() => {\n\t\t\t\t\tif (node.id !== this._activeId) {\n\t\t\t\t\t\tconst latestTree = this.treeStore.getDataTreeOrPartialTree()\n\t\t\t\t\t\tlatestTree.remove(node.id)\n\t\t\t\t\t\tif (this.loadingActiveId === nextId) {\n\t\t\t\t\t\t\tthis.switchScope(this.treeStore.tree, nextId)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (this.scopeSwitchPending && this.loadingActiveId) {\n\t\t\t\t\t\t// If node is current, and there is a loading scope, repeat waiting for it.\n\t\t\t\t\t\tloadSwitchAndRemove()\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If node is current, and there is no loading scope, then repeat from\n\t\t\t\t\t\t// removeNode, that will pick and potentially repeat waiting yet again.\n\t\t\t\t\t\tthis.removeNode(node)\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\tloadSwitchAndRemove()\n\t}\n\n\tsetSelectedCollectionItemForWebPage(webPageNodeId: NodeID, itemId: NodeID) {\n\t\t// This may get called at project load, where the tree isn't available yet\n\t\t// In that case, assume the WebPageNode will exist once we have a tree\n\t\tconst webPageNode = this.treeStore.tree.getNodeWithTrait(webPageNodeId, isWebPageNode)\n\n\t\t// For A/B variants, store under the parent ID to preserve selection across variants\n\t\tconst storeId = webPageNode?.abTestingParentId ?? webPageNodeId\n\t\tconst previousItemId = this.scopeIdToSelectedCollectionItem.get(storeId)\n\n\t\tif (previousItemId === itemId) return\n\n\t\t// Recreate map to trigger an observable change for rendering.\n\t\tconst current = this.scopeIdToSelectedCollectionItem\n\t\tthis.scopeIdToSelectedCollectionItem = ReadonlyMap.set(current, storeId, itemId)\n\t}\n\n\tgetSelectedCollectionItemForWebPage(webPageNode: AnyWebPageNode): NodeID | undefined {\n\t\t// For A/B variants, resolve for the parent ID to preserve selection across variants\n\t\treturn this.scopeIdToSelectedCollectionItem.get(webPageNode.abTestingParentId ?? webPageNode.id)\n\t}\n\n\tgetMostRecentPage(): RootScopeNode {\n\t\tswitch (this.rootScopeType) {\n\t\t\tcase RootScopeType.CanvasPage: {\n\t\t\t\tconst pageNode = this.treeStore.tree.get(this.#mostRecentCanvasPageId)\n\t\t\t\tif (isCanvasPageNode(pageNode)) return pageNode\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase RootScopeType.DesignPage: {\n\t\t\t\tconst pageNode = this.treeStore.tree.get(this.#mostRecentDesignPageId)\n\t\t\t\tif (isDesignPageNode(pageNode)) return pageNode\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase RootScopeType.WebPage: {\n\t\t\t\tconst webPage = this.treeStore.tree.get(this.#mostRecentWebPageId)\n\t\t\t\tif (webPage && isScopeNode(webPage) && isWebPageNode(webPage)) return webPage\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn this.getFirstPageNodeAccordingToUI()\n\t}\n\n\tprivate getComponentHistory(): (SmartComponentNode | LayoutTemplateNode | VectorSetNode)[] {\n\t\tif (this.#componentHistory.length === 0) return []\n\n\t\tconst active = this.active\n\t\tif (!(isSmartComponentNode(active) || isLayoutTemplateNode(active) || isVectorSetNode(active))) return []\n\n\t\tconst result: (SmartComponentNode | LayoutTemplateNode | VectorSetNode)[] = []\n\t\tlet lastNode: SmartComponentNode | LayoutTemplateNode | VectorSetNode | undefined\n\n\t\tfor (const id of this.#componentHistory) {\n\t\t\tconst node = this.treeStore.tree.getNode(id)\n\t\t\t// TODO Check and handle shallow/fully loaded scope state\n\t\t\t// this should be probably assert, but we will change and verify it later\n\t\t\tif ((isSmartComponentNode(node) || isLayoutTemplateNode(node) || isVectorSetNode(node)) && node.isLoaded()) {\n\t\t\t\tresult.push(node)\n\t\t\t\tlastNode = node\n\t\t\t}\n\t\t}\n\n\t\treturn lastNode === active ? result : [active]\n\t}\n\n\tget onIsolatedCanvas(): boolean {\n\t\treturn this.#onIsolatedCanvas\n\t}\n\n\tget onCollectionPage(): boolean {\n\t\treturn this.#onCollectionPage\n\t}\n\n\t#cachedIsolatedCanvasNodes: readonly AnyScopeNode[] = []\n\n\tisolatedCanvasNodes(): readonly ShallowScopeNode[] {\n\t\tconst currentScope = this.active\n\n\t\tlet isolatedCanvasNodes: AnyScopeNode[]\n\n\t\tif (isRootScopeNode(currentScope)) {\n\t\t\tisolatedCanvasNodes = [currentScope]\n\t\t} else {\n\t\t\tisolatedCanvasNodes = [this.getMostRecentPage(), ...this.getComponentHistory()]\n\t\t}\n\n\t\tif (isShallowArrayEqual(this.#cachedIsolatedCanvasNodes, isolatedCanvasNodes)) {\n\t\t\treturn this.#cachedIsolatedCanvasNodes as ShallowScopeNode[]\n\t\t}\n\n\t\tthis.#cachedIsolatedCanvasNodes = isolatedCanvasNodes\n\t\treturn isolatedCanvasNodes as ShallowScopeNode[]\n\t}\n\n\t/**\n\t * Returns the top-most web page node, as it appears in the breadcrumb bar.\n\t */\n\tgetTopMostWebPageNode(): AnyWebPageNode | undefined {\n\t\tfor (const node of this.isolatedCanvasNodes()) {\n\t\t\tif (isWebPageNode(node)) {\n\t\t\t\treturn node\n\t\t\t}\n\t\t}\n\t}\n\n\tcanGoBack = (): boolean => {\n\t\treturn this.#onIsolatedCanvas\n\t}\n\n\tgoBack = () => {\n\t\tconst isolatedCanvasNodes = Array.from(this.isolatedCanvasNodes())\n\t\tisolatedCanvasNodes.pop() // Remove current scope\n\t\tconst previousScope = isolatedCanvasNodes.pop()\n\t\tif (previousScope) this.select(previousScope.id, { keepHistory: false })\n\t}\n}\n\nfunction findNextAvailableNumber(sortedNumbers: number[], currentNumber: number): number {\n\tfor (const num of sortedNumbers) {\n\t\tif (num < currentNumber) continue\n\t\treturn num\n\t}\n\n\treturn Math.max(...sortedNumbers)\n}\n\nexport function getCanvasPageNodes(tree: CanvasTree): AnyCanvasPageNode[] {\n\treturn tree.root.children.filter(isCanvasPageNode)\n}\n\nexport function getWebPageNodes(tree: CanvasTree): AnyWebPageNode[] {\n\treturn tree.root.children.filter(\n\t\t(node): node is CanvasNode & AnyWebPageNode => isWebPageNode(node, true) && !node.kitPage,\n\t)\n}\n\nexport function getWebPageNodesWithoutCollection(tree: CanvasTree): AnyWebPageNode[] {\n\treturn tree.root.children.filter(\n\t\t(node): node is CanvasNode & AnyWebPageNode => isWebPageNode(node, true) && !node.dataIdentifier && !node.kitPage,\n\t)\n}\n\nexport function getWebPageNodesWithCollection(\n\ttree: CanvasTree,\n\tsorted = false,\n): (ShallowWebPageNode & NonUndefinedRecord<WithCollectionDataSource>)[] {\n\ttype ReturnT = (ShallowWebPageNode & NonUndefinedRecord<WithCollectionDataSource>)[]\n\tconst webPages = tree.root.children.filter(\n\t\t(node): node is ShallowWebPageNode & NonUndefinedRecord<WithCollectionDataSource> =>\n\t\t\tBoolean(isWebPageNode(node) && node.dataIdentifier),\n\t) as ReturnT\n\n\tif (!sorted) {\n\t\treturn webPages\n\t}\n\n\treturn sortInRouteSegmentOrder(tree, webPages)\n}\n", "import type { CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport type { LinkToWebPage } from \"document/models/CanvasTree/traits/utils/Link.ts\"\nimport { isLinkToWebPage } from \"document/models/CanvasTree/traits/utils/Link.ts\"\nimport { isValidURLWithoutProtocol } from \"document/utils/domainValidation.ts\"\nimport { SlugBehavior, getResolvedLinkToWebPage } from \"document/utils/getResolvedLinkToWebPage.ts\"\nimport type { ValidationResult } from \"web/pages/projects/components/Domains/validation/ValidationResult.ts\"\nimport { validatePathOrURL } from \"web/pages/projects/components/Domains/validation/validatePathOrURL.ts\"\n\nconst genericErrorMessage = \"Please enter a valid URL\"\n\nexport function validateRedirectTo(\n\ttree: CanvasTree,\n\tto: string | LinkToWebPage,\n\tnormalizedFromValue?: string,\n): ValidationResult<string | LinkToWebPage> {\n\tif (isLinkToWebPage(to)) {\n\t\tif (normalizedFromValue) {\n\t\t\tconst resolvedToValue = getResolvedLinkToWebPage(tree, to, SlugBehavior.Resolve)\n\t\t\tif (normalizedFromValue === resolvedToValue) {\n\t\t\t\treturn { result: \"error\", message: \"Can\u2019t be the same as the old URL\" }\n\t\t\t}\n\t\t}\n\t\treturn { result: \"ok\", normalizedValue: to }\n\t}\n\n\tconst validationResult = validatePathOrURL(to, \"URL\", { blockInvalidCharacters: \"spaces-only\" })\n\tif (validationResult.result !== \"ok\") {\n\t\treturn validationResult\n\t}\n\n\tto = validationResult.normalizedValue\n\n\tif (to === normalizedFromValue) {\n\t\treturn { result: \"error\", message: \"Can\u2019t be the same as the old URL\" }\n\t}\n\n\t// Check if it's a valid relative URL that starts with \"/\" (including \"//\").\n\tif (to.startsWith(\"/\")) {\n\t\ttry {\n\t\t\tnew URL(to, \"https://example.com\")\n\t\t\treturn { result: \"ok\", normalizedValue: to }\n\t\t} catch {\n\t\t\treturn { result: \"error\", message: genericErrorMessage }\n\t\t}\n\t}\n\n\t// This check needs to come before the absolute URL check, because\n\t// \"framer.com:8080\" is technically a valid absolute URL, but we want it\n\t// treated as a host+pathname combo that needs prefixing.\n\tif (isValidURLWithoutProtocol(to)) {\n\t\treturn { result: \"ok\", normalizedValue: `https://${to}` }\n\t}\n\n\t// Check if it's a valid absolute URL.\n\ttry {\n\t\tnew URL(to)\n\t\treturn { result: \"ok\", normalizedValue: to }\n\t} catch {\n\t\treturn { result: \"error\", message: genericErrorMessage }\n\t}\n}\n", "import type { PageLinkAndLocaleId } from \"document/components/utils/convertPathVariablesToReadablePath.ts\"\nimport type { CanvasTree } from \"document/models/CanvasTree/CanvasTree.ts\"\nimport { defaultLocaleId } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport { isLinkToWebPage } from \"document/models/CanvasTree/traits/utils/Link.ts\"\nimport { pathVariablesRegExpGlobal } from \"library/router/pathVariables.ts\"\nimport { getCollectionForIdentifier } from \"utils/getCollectionForIdentifier.ts\"\nimport { getRouterLocale } from \"utils/getRouterLocales.ts\"\nimport { getCollectionItemSelectorFromLink } from \"./getCollectionItemSelectorFromLink.ts\"\nimport { webPageNodeForLink } from \"./getLinkDataIdentifiers.ts\"\nimport { getRawWebPagePath } from \"./getWebPagePath.ts\"\n\nexport type ReadableWebPageLinkPaths = ReadonlyMap<PageLinkAndLocaleId, string | null>\n\n/**\n * Converts web page links into human-readable URL paths for publication. Handles locale prefixes,\n * collection item slugs, and path variables to generate the actual URLs that users will see in\n * their browser.\n *\n * @examples\n * - { link: { webPageId: \"home123\" }, localeId: \"en\" } => \"/\"\n * - { link: { webPageId: \"about456\" }, localeId: \"es\" } => \"/es/about\"\n * - { link: { webPageId: \"blog789\", collectionItemSelector: { identifier: \"posts\", collectionItemId: \"item1\" } }, localeId: \"en\" } => \"/blog/my-first-post\"\n *\n * @param tree - The canvas tree containing page and locale information\n * @param linksWithLocale - Array of page links paired with their locale IDs\n *\n * @returns Map where keys are the input links and values are readable URL paths (or null if path\n * cannot be determined)\n */\nexport function getReadableWebPageLinkPaths(\n\ttree: CanvasTree,\n\tlinksWithLocale: PageLinkAndLocaleId[],\n): ReadableWebPageLinkPaths {\n\tconst result = new Map<PageLinkAndLocaleId, string | null>()\n\tfor (const linkWithLocale of linksWithLocale) {\n\t\tconst { link, localeId } = linkWithLocale\n\t\tconst collectionItemSelector = isLinkToWebPage(link) ? getCollectionItemSelectorFromLink(link) : undefined\n\t\tconst webPageNode = webPageNodeForLink(tree, link)\n\t\tif (!webPageNode) {\n\t\t\tresult.set(linkWithLocale, null)\n\t\t\tcontinue\n\t\t}\n\n\t\tlet localePrefix = \"\"\n\t\tif (localeId && localeId !== defaultLocaleId) {\n\t\t\tconst locale = tree.root.getNonDefaultLocale(localeId)\n\t\t\tif (!locale || !locale.slug) continue\n\t\t\tlocalePrefix = `/${locale.slug}`\n\t\t}\n\n\t\tif (webPageNode.id === tree.root.homePageNodeId) {\n\t\t\tresult.set(linkWithLocale, `${localePrefix}/`)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst pagePath = getRawWebPagePath(tree, webPageNode)\n\t\tif (!pagePath) {\n\t\t\tresult.set(linkWithLocale, null)\n\t\t\tcontinue\n\t\t}\n\n\t\tif (collectionItemSelector?.identifier) {\n\t\t\tconst collectionNode = getCollectionForIdentifier(tree, collectionItemSelector?.identifier)\n\t\t\tif (collectionNode) {\n\t\t\t\tconst activeRouterLocale = getRouterLocale(tree, localeId)\n\t\t\t\tconst itemToSlug = collectionNode.getItemToSlug(activeRouterLocale)\n\t\t\t\tconst itemSlug = itemToSlug[collectionItemSelector.collectionItemId]\n\t\t\t\tif (itemSlug) {\n\t\t\t\t\tconst readablePath = pagePath.replace(pathVariablesRegExpGlobal, itemSlug)\n\t\t\t\t\tresult.set(linkWithLocale, localePrefix + readablePath)\n\t\t\t\t} else {\n\t\t\t\t\tresult.set(linkWithLocale, null)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tresult.set(linkWithLocale, localePrefix + pagePath)\n\t}\n\n\treturn result\n}\n", "import { getNonDefaultLocaleIdForPath } from \"document/components/chrome/siteSettings/Redirects/getNonDefaultLocaleForPath.ts\"\nimport type { PageLinkAndLocaleId } from \"document/components/utils/convertPathVariablesToReadablePath.ts\"\nimport type { Locale } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport { isString } from \"utils/typeChecks.ts\"\nimport { isLinkToWebPage } from \"../../traits/utils/Link.ts\"\nimport type { RedirectRouteNode } from \"../RedirectRouteNode.ts\"\n\nexport interface WebPageLinkWithLocaleInfo {\n\tlinksWithLocale: PageLinkAndLocaleId[]\n\tlinkWithLocaleByRedirect: Map<RedirectRouteNode, PageLinkAndLocaleId>\n}\n\n/**\n * Extracts web page links with their associated locale information from redirect route nodes.\n * Filters out non-web page redirects and determines the appropriate locale for each redirect\n * based on its path.\n *\n * @param redirects - Array of redirect route nodes to process\n * @param locales - Available locales for the site, used to determine locale from redirect paths\n * @returns Object containing both a flat array of links with locale info and a map linking\n * each redirect to its corresponding page link with locale\n *\n * @example\n * Input: redirects with web page targets\n * [\n *   { path: \"/old-about\", to: { webPageId: \"about123\" } },\n *   { path: \"/es/viejo-acerca\", to: { webPageId: \"about123\" } }\n * ]\n * Output:\n * {\n *   linksWithLocale: [\n *     { link: { webPageId: \"about123\" }, localeId: undefined },\n *     { link: { webPageId: \"about123\" }, localeId: \"es\" }\n *   ],\n *   linkWithLocaleByRedirect: Map([\n *     [redirect1, { link: { webPageId: \"about123\" }, localeId: undefined }],\n *     [redirect2, { link: { webPageId: \"about123\" }, localeId: \"es\" }]\n *   ])\n * }\n */\nexport function getWebPageLinksWithLocaleInfo(\n\tredirects: readonly RedirectRouteNode[],\n\tlocales: readonly Locale[] | undefined,\n): WebPageLinkWithLocaleInfo {\n\tconst result: WebPageLinkWithLocaleInfo = {\n\t\tlinksWithLocale: [],\n\t\tlinkWithLocaleByRedirect: new Map(),\n\t}\n\n\tfor (const redirect of redirects) {\n\t\tif (!isLinkToWebPage(redirect.to)) continue\n\n\t\tconst linkWithLocale: PageLinkAndLocaleId = {\n\t\t\tlink: redirect.to,\n\t\t\tlocaleId: getNonDefaultLocaleIdForPath(redirect.path, locales),\n\t\t}\n\n\t\tresult.linksWithLocale.push(linkWithLocale)\n\t\tresult.linkWithLocaleByRedirect.set(redirect, linkWithLocale)\n\t}\n\n\treturn result\n}\n\nexport function getRedirectToPath(\n\tredirect: RedirectRouteNode,\n\tgetReadableWebPageLinkPathForRedirect: (redirect: RedirectRouteNode) => string | null,\n): string | null {\n\tconst readableWebPageLinkPath = getReadableWebPageLinkPathForRedirect(redirect)\n\tif (readableWebPageLinkPath) return readableWebPageLinkPath\n\tif (isString(redirect.to)) return redirect.to\n\treturn null\n}\n", "import type { ComponentLoader, VerifiedPropertyControls } from \"@framerjs/framer-runtime\"\nimport { hasDefaultAssetReference, hasVekterDefault, isDefaultResponsiveImage } from \"@framerjs/framer-runtime/sandbox\"\nimport { assert, isEmptyObject } from \"@framerjs/shared\"\nimport { AssetCollector } from \"code-generation/utils/AssetCollector.ts\"\nimport { getCursorHash } from \"code-generation/utils/CustomCursorCollector.ts\"\nimport {\n\ttype LinkCollector,\n\ttype SerializableUnresolvedLink,\n\tcreateLink,\n\tcreateLinkHash,\n} from \"code-generation/utils/LinkCollector.ts\"\nimport type { AnyWebPageNode, CanvasTree, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { compileRichTextForCodeGeneration } from \"document/models/CanvasTree/nodes/utils/compileRichText.tsx\"\nimport { isComputedValue } from \"document/models/CanvasTree/traits/ComputedValue.ts\"\nimport { isVariableReference } from \"document/models/CanvasTree/traits/VariableReference.ts\"\nimport { fallbackAltText } from \"document/models/CanvasTree/traits/WithAltText.ts\"\nimport type { LocaleId } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport { type LinkToWebPage, getLink, isLinkToURL } from \"document/models/CanvasTree/traits/utils/Link.ts\"\nimport { isResolvedCollectionItemSelector } from \"document/models/CanvasTree/traits/utils/ResolvedCollectionItemSelector.ts\"\nimport {\n\ttype LocalizedTextValue,\n\ttype LocalizedValues,\n\tisNonNullLocalizedValue,\n} from \"document/models/LocalizedValue.ts\"\nimport { type ControlProps, withLocalizableControlPropValue } from \"document/models/controlProps/ControlProp.ts\"\nimport { isFontValue, styleForFontValue } from \"document/models/controlProps/FontControlPropValue.ts\"\nimport { getResolvedControlPropValues } from \"document/models/controlProps/getResolvedControlPropValues.ts\"\nimport { isRichTextDocument } from \"document/models/richText/richTextStorage.ts\"\nimport type { AssetStore } from \"document/stores/AssetStore.ts\"\nimport type { ModulesStore } from \"document/stores/ModulesStore.ts\"\nimport { isUnresolvedLink } from \"library/modules/ResolveLinks.tsx\"\nimport type { RelativeNumber } from \"library/render/types/RelativeNumber.ts\"\nimport { isObject, isString, isUndefined } from \"utils/typeChecks.ts\"\nimport type { SerializableRecord, SerializableValue } from \"./js/SerializableValue.ts\"\nimport { js } from \"./js/js.ts\"\nimport { SafeJS } from \"./js/serializeJS.ts\"\nimport type { BindingCollector } from \"./utils/BindingCollector.ts\"\nimport { ColorCollector } from \"./utils/CSSVariableDefinitionCollector.ts\"\nimport { JSXDeclarationCollector } from \"./utils/DeclarationCollector.ts\"\nimport type { ImportCollector } from \"./utils/ImportCollector.ts\"\nimport { addImageAlt } from \"./utils/valueTransformCollector/functions/addImageAlt.ts\"\n\n/**\n * Collects links and scroll section refs that need to be resolved from a slug at runtime.\n */\nclass UnresolvedLinkCollector {\n\tconstructor(\n\t\tprivate readonly imports: ImportCollector,\n\t\tprivate readonly declarations: JSXDeclarationCollector,\n\t) {}\n\n\tlinks = new Map<NodeID, Set<string>>()\n\tscrollSectionRefs = new Map<NodeID, Set<string>>()\n\n\tprivate collect<T>(type: \"link\" | \"scrollSectionRef\", templateId: NodeID, key: string, value: T) {\n\t\tif (!isUnresolvedLink(value)) return\n\t\tconst collection = type === \"link\" ? this.links : this.scrollSectionRefs\n\t\tconst list = collection.get(templateId) ?? new Set()\n\t\tlist.add(key)\n\t\tcollection.set(templateId, list)\n\t}\n\n\tcollectLink(templateId: NodeID, key: string, value: SerializableUnresolvedLink) {\n\t\tthis.collect(\"link\", templateId, key, value)\n\t\treturn value\n\t}\n\n\tcollectScrollSectionRef(templateId: NodeID, key: string, value: SerializableUnresolvedLink) {\n\t\tthis.collect(\"scrollSectionRef\", templateId, key, value)\n\t\treturn value\n\t}\n\n\tvalues(templateId: NodeID) {\n\t\tconst linkBindingsToResolve: SafeJS[] = []\n\t\tconst resolvedLinkBindings: SerializableRecord = {}\n\t\tconst binding = js`resolvedLinks`\n\n\t\tconst links = this.links.get(templateId)\n\t\tif (links?.size) {\n\t\t\tfor (const key of links) {\n\t\t\t\tresolvedLinkBindings[key] = js`${binding}[${linkBindingsToResolve.length}]`\n\t\t\t\tlinkBindingsToResolve.push(js`props[${key}]`)\n\t\t\t}\n\t\t}\n\n\t\tconst scrollSectionRefs = this.scrollSectionRefs.get(templateId)\n\t\tif (scrollSectionRefs?.size) {\n\t\t\tconst siteRef = this.declarations.component.dedupe(\n\t\t\t\t\"siteRef\",\n\t\t\t\tSafeJS.fn(\n\t\t\t\t\tthis.imports.addImport(\"framer\", {\n\t\t\t\t\t\texportSpecifier: \"useSiteRefs\",\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t)\n\t\t\tfor (const key of scrollSectionRefs) {\n\t\t\t\tresolvedLinkBindings[key] = SafeJS.fn(siteRef, js`${binding}[${linkBindingsToResolve.length}]`)\n\t\t\t\tlinkBindingsToResolve.push(js`props[${key}]`)\n\t\t\t}\n\t\t}\n\n\t\tif (isEmptyObject(resolvedLinkBindings)) return undefined\n\n\t\treturn {\n\t\t\tResolveLinks: this.imports.addImport(\"framer\", {\n\t\t\t\texportSpecifier: \"ResolveLinks\",\n\t\t\t}),\n\t\t\tbinding,\n\t\t\tlinks: linkBindingsToResolve,\n\t\t\tprops: resolvedLinkBindings,\n\t\t}\n\t}\n}\n\ninterface Context {\n\tbindings: BindingCollector\n\ttree: CanvasTree\n\tcomponentLoader: ComponentLoader\n\timports: ImportCollector\n\tassets: AssetCollector\n\tdeclarations: JSXDeclarationCollector\n\tmodulesStore: ModulesStore\n\tunresolvedLinks: UnresolvedLinkCollector\n\twideGamutColors: ColorCollector\n}\n\nexport function createWebPageLayoutTemplateContext(\n\ttree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n\tmodulesStore: ModulesStore,\n\tassetStore: AssetStore,\n\timports: ImportCollector,\n\tbindings: BindingCollector,\n): Context {\n\tconst declarations = new JSXDeclarationCollector(bindings)\n\n\treturn {\n\t\tbindings,\n\t\timports,\n\t\tdeclarations,\n\t\ttree,\n\t\tcomponentLoader,\n\t\tmodulesStore: modulesStore,\n\t\tassets: new AssetCollector(assetStore.assetMap),\n\t\tunresolvedLinks: new UnresolvedLinkCollector(imports, declarations),\n\t\twideGamutColors: new ColorCollector(),\n\t}\n}\n\nfunction toLocalizedValueObject(\n\tlocalizedValues: LocalizedValues<LocalizedTextValue>,\n\tget: (localeId: LocaleId) => SerializableValue | undefined,\n) {\n\tconst values: Record<string, unknown> = {}\n\n\tfor (const localeId in localizedValues) {\n\t\tvalues[localeId] = get(localeId)\n\t}\n\n\treturn values as SerializableValue\n}\n\nfunction makeAddLocalizedValue(ctx: Pick<Context, \"declarations\" | \"imports\">) {\n\treturn <T extends SerializableValue>(\n\t\tvalue: T,\n\t\tlocalizedValues: LocalizedValues<LocalizedTextValue> | undefined,\n\t\tget: (localeId: LocaleId) => SerializableValue | undefined,\n\t): T | SafeJS => {\n\t\tif (isUndefined(localizedValues)) return value\n\t\tconst obj = toLocalizedValueObject(localizedValues, get)\n\t\tif (!obj || !isObject(obj) || isEmptyObject(obj)) return value\n\n\t\tconst fn = ctx.declarations.file.dedupe(\n\t\t\t\"getLocalizedValue\",\n\t\t\tjs`(values, locale) => {${js.joinLines(\n\t\t\t\tjs`while (locale) {${js.joinLines(\n\t\t\t\t\tjs`const value = values[locale.id]`,\n\t\t\t\t\tjs`if (value) return value`,\n\t\t\t\t\tjs`locale = locale.fallback`,\n\t\t\t\t)}}`,\n\t\t\t)}}`,\n\t\t)\n\n\t\tconst useLocaleInfo = ctx.imports.addImport(\"framer\", {\n\t\t\texportSpecifier: \"useLocaleInfo\",\n\t\t})\n\n\t\tconst { activeLocale } = ctx.declarations.component.dedupe({ activeLocale: undefined }, SafeJS.fn(useLocaleInfo))\n\n\t\tconst localizedValuesBinding = ctx.declarations.file.dedupe(\"localizedValues\", obj)\n\t\treturn js`${SafeJS.fn(fn, localizedValuesBinding, activeLocale)} ?? ${value}`\n\t}\n}\n\nexport function getPublishedWebPageLayoutTemplateControlProps(\n\tnode: AnyWebPageNode,\n\tcontrols: VerifiedPropertyControls,\n\tcontrolProps: ControlProps,\n\ttemplateId: NodeID,\n\t{ declarations, tree, componentLoader, modulesStore, assets, imports, unresolvedLinks, wideGamutColors }: Context,\n) {\n\tconst addLocalizedValue = makeAddLocalizedValue({\n\t\tdeclarations,\n\t\timports,\n\t})\n\n\treturn getResolvedControlPropValues(controls, controlProps, {\n\t\tresolveAsset: (value, control, controlProp, resolveImage) => {\n\t\t\tlet src: string | undefined\n\n\t\t\tconst defaultAssetReference = hasDefaultAssetReference(control) ? control.__defaultAssetReference : undefined\n\n\t\t\t// Components will handle their own defaults.\n\t\t\tif (value !== defaultAssetReference) {\n\t\t\t\tconst asset = resolveImage ? assets.resolveResponsiveImage(value) : assets.resolve(value)\n\t\t\t\tsrc = asset?.src\n\t\t\t}\n\n\t\t\tif (!withLocalizableControlPropValue(controlProp) || isUndefined(src)) return src\n\n\t\t\treturn addLocalizedValue(src, controlProp.valueLocalized, localeId => {\n\t\t\t\tconst localizedValue = controlProp.valueLocalized?.[localeId]?.value\n\t\t\t\tif (!isString(localizedValue)) return\n\n\t\t\t\t// Components will handle their own defaults.\n\t\t\t\tif (localizedValue === defaultAssetReference) return js`undefined`\n\n\t\t\t\tconst asset = resolveImage ? assets.resolveResponsiveImage(localizedValue) : assets.resolve(localizedValue)\n\t\t\t\treturn asset?.src\n\t\t\t})\n\t\t},\n\t\tresolveResponsiveImage: (value, control, controlProp) => {\n\t\t\tlet defaultAssetReference: string | undefined\n\t\t\tlet defaultPositionX: RelativeNumber | undefined\n\t\t\tlet defaultPositionY: RelativeNumber | undefined\n\n\t\t\tif (hasVekterDefault(control) && isDefaultResponsiveImage(control.__vekterDefault)) {\n\t\t\t\tdefaultAssetReference = control.__vekterDefault.assetReference\n\t\t\t\tdefaultPositionX = control.__vekterDefault.positionX\n\t\t\t\tdefaultPositionY = control.__vekterDefault.positionY\n\t\t\t} else if (hasDefaultAssetReference(control)) {\n\t\t\t\tdefaultAssetReference = control.__defaultAssetReference\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tvalue === defaultAssetReference &&\n\t\t\t\tcontrolProp.positionX === defaultPositionX &&\n\t\t\t\tcontrolProp.positionY === defaultPositionY\n\t\t\t) {\n\t\t\t\t// Components will handle their own defaults.\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst localizedAsset = SafeJS.fromValue(assets.resolveResponsiveImage(value, { focalPoint: controlProp }))\n\n\t\t\tconst localized = addLocalizedValue(localizedAsset, controlProp.valueLocalized, localeId => {\n\t\t\t\tconst localizedValue = controlProp.valueLocalized?.[localeId]\n\t\t\t\tif (!isNonNullLocalizedValue(localizedValue)) return\n\t\t\t\tif (!isString(localizedValue.value)) return\n\n\t\t\t\t// Components will handle their own defaults.\n\t\t\t\tif (\n\t\t\t\t\tlocalizedValue.value === defaultAssetReference &&\n\t\t\t\t\tlocalizedValue.imageFocalPoint?.positionX === defaultPositionX &&\n\t\t\t\t\tlocalizedValue.imageFocalPoint?.positionY === defaultPositionY\n\t\t\t\t) {\n\t\t\t\t\treturn js`undefined`\n\t\t\t\t}\n\n\t\t\t\tconst resolvedAsset = assets.resolveResponsiveImage(localizedValue.value, {\n\t\t\t\t\tfocalPoint: localizedValue.imageFocalPoint,\n\t\t\t\t})\n\t\t\t\treturn SafeJS.fromValue(resolvedAsset)\n\t\t\t})\n\n\t\t\treturn SafeJS.fn(\n\t\t\t\tdeclarations.file.dedupe(\"wrapInAddImageAlt\", addImageAlt),\n\t\t\t\tlocalized,\n\t\t\t\taddLocalizedValue(controlProp.alt ?? fallbackAltText, controlProp.altLocalized, localeId => {\n\t\t\t\t\tconst localizedValue = controlProp.altLocalized?.[localeId]?.value\n\t\t\t\t\treturn isString(localizedValue) ? localizedValue : undefined\n\t\t\t\t}),\n\t\t\t)\n\t\t},\n\n\t\tresolveDynamicValue: (_dynamicValue, _control) => {\n\t\t\t// Layout Template Control Props do not support dynamic values.\n\t\t\treturn undefined\n\t\t},\n\t\tresolveLink: (key, controlProp) => {\n\t\t\tif (isComputedValue(controlProp.value)) return undefined\n\n\t\t\tconst linkValue = getLink(controlProp.value)\n\t\t\tif (isUndefined(linkValue)) return undefined\n\n\t\t\tif (isLinkToURL(linkValue)) {\n\t\t\t\tconst localizedValues = controlProp.valueLocalized\n\t\t\t\tif (!localizedValues) return linkValue.url\n\t\t\t\treturn addLocalizedValue(linkValue.url, localizedValues, localeId => {\n\t\t\t\t\tconst localizedValue = localizedValues[localeId]?.value\n\t\t\t\t\treturn isString(localizedValue) ? localizedValue : undefined\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn unresolvedLinks.collectLink(templateId, key, {\n\t\t\t\thref: createLink(linkValue, tree, componentLoader, modulesStore),\n\t\t\t})\n\t\t},\n\t\tresolvePageScope: _link => {\n\t\t\t// Layout Template Control Props do not support page scope controls.\n\t\t\treturn undefined\n\t\t},\n\t\tresolveLocalizedValue: (value, localizedValues) => {\n\t\t\tassert(!isRichTextDocument(value), \"Rich text documents must be resolved through resolveRichText.\")\n\t\t\treturn addLocalizedValue(value, localizedValues, localeId => {\n\t\t\t\tconst localizedValue = localizedValues?.[localeId]?.value\n\t\t\t\treturn isString(localizedValue) ? localizedValue : undefined\n\t\t\t})\n\t\t},\n\t\tresolveRichText: (value, htmlLocalized) => {\n\t\t\tconst links: Pick<LinkCollector, \"create\"> = {\n\t\t\t\tcreate: link => {\n\t\t\t\t\t// Variables can't be provided to Layout Templates.\n\t\t\t\t\tif (isUndefined(link) || isVariableReference(link)) return undefined\n\t\t\t\t\tif (isLinkToURL(link)) return link.url || undefined\n\t\t\t\t\treturn createLink(link, tree, componentLoader, modulesStore)\n\t\t\t\t},\n\t\t\t}\n\n\t\t\tconst options = {\n\t\t\t\tcollectors: { imports, assets, links },\n\t\t\t\tnodeId: node.getPrimaryId(),\n\t\t\t\tuseCreateElement: true,\n\t\t\t}\n\n\t\t\tconst defaultJSX = declarations.file.dedupe(\"text\", compileRichTextForCodeGeneration(value, options))\n\n\t\t\treturn addLocalizedValue(defaultJSX, htmlLocalized, localeId => {\n\t\t\t\tif (!htmlLocalized) return\n\n\t\t\t\tconst localizedValue = htmlLocalized[localeId]\n\t\t\t\tif (!isNonNullLocalizedValue(localizedValue)) return\n\t\t\t\treturn compileRichTextForCodeGeneration(localizedValue.value, options)\n\t\t\t})\n\t\t},\n\t\tresolveFont: (_controlKey, value) => {\n\t\t\tif (!isFontValue(value)) return {}\n\t\t\treturn styleForFontValue(value)\n\t\t},\n\t\tresolveScrollSectionRef: (key, value) => {\n\t\t\tif (isUndefined(value) || isVariableReference(value) || !isString(value.target)) return undefined\n\n\t\t\tconst { target, collectionItem } = value\n\n\t\t\t// Variables can't be provided to Layout Templates.\n\t\t\tif (!target || isVariableReference(target)) return undefined\n\n\t\t\t// Always link to the control page in case of A/B variant\n\t\t\tconst webPageId = node.abTestingParentId ?? node.id\n\t\t\tconst link: LinkToWebPage = {\n\t\t\t\ttype: \"webPage\",\n\t\t\t\twebPageId,\n\t\t\t\thash: target,\n\t\t\t\thashVariables: isResolvedCollectionItemSelector(collectionItem)\n\t\t\t\t\t? { [collectionItem.key]: collectionItem }\n\t\t\t\t\t: undefined,\n\t\t\t}\n\n\t\t\treturn unresolvedLinks.collectScrollSectionRef(templateId, key, {\n\t\t\t\thref: {\n\t\t\t\t\t...createLinkHash(link, tree, componentLoader, modulesStore),\n\t\t\t\t\twebPageId,\n\t\t\t\t},\n\t\t\t\trefKey: true,\n\t\t\t})\n\t\t},\n\t\tresolveCustomCursor: (_key, value) => {\n\t\t\t// Variables can't be provided to Layout Templates.\n\t\t\tif (isUndefined(value) || isVariableReference(value)) return undefined\n\t\t\treturn getCursorHash(value, tree)\n\t\t},\n\t\tresolveVectorSetItem: value => {\n\t\t\tif (isUndefined(value) || isVariableReference(value)) return undefined\n\t\t\treturn imports.addModuleImport(value, { absolute: true })\n\t\t},\n\t\tresolveColor: value => {\n\t\t\treturn wideGamutColors.resolveColor(value)\n\t\t},\n\t})\n}\n", "import hash from \"@emotion/hash\"\nimport type { ComponentLoader } from \"@framerjs/framer-runtime\"\nimport { AnnotationKey } from \"@framerjs/framer-runtime/crossorigin\"\nimport { isBoolean } from \"@framerjs/fresco/src/components/utils/typeCheck\"\nimport { assert, ModuleType, isEmptyObject, isLocalModuleIdentifier, parseModuleIdentifier } from \"@framerjs/shared\"\nimport { createMediaQueryFromBreakpoint } from \"code-generation/components/helpers/breakpoints.ts\"\nimport {\n\tcreateWebPageLayoutTemplateContext,\n\tgetPublishedWebPageLayoutTemplateControlProps,\n} from \"code-generation/getPublishedWebPageLayoutTemplateControlProps.ts\"\nimport {\n\ttype SerializableRecord,\n\ttype SerializableValue,\n\tisSerializableValue,\n} from \"code-generation/js/SerializableValue.ts\"\nimport { js } from \"code-generation/js/js.ts\"\nimport { SafeJS, SerializableObject, SortBehavior, serializeJS } from \"code-generation/js/serializeJS.ts\"\nimport { difference } from \"code-generation/jsx/difference.ts\"\nimport type { BindingCollector } from \"code-generation/utils/BindingCollector.ts\"\nimport type { ImportCollector } from \"code-generation/utils/ImportCollector.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { resetNodeOverrides } from \"document/components/chrome/properties/utils/resetNodeOverrides.ts\"\nimport { defaultStackLayoutForLayoutTemplate } from \"document/components/utils/getPrimaryBreakpointProps.ts\"\nimport type { CanvasTree, LoadedWebPageNode } from \"document/models/CanvasTree/index.ts\"\nimport type { CanvasNode } from \"document/models/CanvasTree/nodes/CanvasNode.ts\"\nimport type {\n\tAnyLayoutTemplateNode,\n\tLoadedLayoutTemplateNode,\n} from \"document/models/CanvasTree/nodes/LayoutTemplateNode.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { isLayoutTemplateNode, isSlotNode, isWebPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { TraitType } from \"document/models/CanvasTree/traits/TraitType.ts\"\nimport {\n\ttype Breakpoints,\n\tisBreakpoints,\n\twithBreakpointVariants,\n} from \"document/models/CanvasTree/traits/WithBreakpointVariants.ts\"\nimport { withChildren } from \"document/models/CanvasTree/traits/WithChildren.ts\"\nimport { cursorDefaults } from \"document/models/CanvasTree/traits/WithCursor.ts\"\nimport { flowEffectDefaults } from \"document/models/CanvasTree/traits/WithFlowEffect.ts\"\nimport { hasLayoutTemplate } from \"document/models/CanvasTree/traits/WithLayoutTemplate.ts\"\nimport {\n\tgetInheritedVariablesValueMap,\n\tgetNodeUpdateResolvingDynamicValues,\n} from \"document/models/CanvasTree/utils/getNodeUpdateResolvingDynamicValues.ts\"\nimport type { AssetStore } from \"document/stores/AssetStore.ts\"\nimport type { ModulesStore } from \"document/stores/ModulesStore.ts\"\nimport { webPageAcceptsLayoutTemplate } from \"utils/layoutTemplates.ts\"\nimport { safeTagName } from \"utils/names.ts\"\nimport { isFunction, isNull, isUndefined } from \"utils/typeChecks.ts\"\nimport { record } from \"web/lib/tracker.ts\"\n\ntype WebPageId = NodeID\n\nfunction breakpointHashesForLayoutTemplateAnnotation(breakpoints: Breakpoints) {\n\tconst values: { hash: string; mediaQuery: string | undefined }[] = []\n\n\tfor (const id in breakpoints) {\n\t\tconst breakpoint = breakpoints[id]\n\t\tif (!breakpoint) continue\n\n\t\tvalues.push({\n\t\t\thash: hash(id),\n\t\t\tmediaQuery: createMediaQueryFromBreakpoint(breakpoint),\n\t\t})\n\t}\n\n\treturn values\n}\n\nfunction createLayoutTemplateCase(\n\tLayoutTemplate: SafeJS,\n\twebPageIds: WebPageId[],\n\tunresolvedLinks: { ResolveLinks: SafeJS; binding: SafeJS; links: SafeJS[]; props: SerializableRecord } | undefined,\n\timports: ImportCollector,\n): SafeJS {\n\tconst props = new SerializableObject({\n\t\tstyle: js`style`,\n\t\t// The key tells React that different switch cases are the same Component.\n\t\tkey: serializeJS(LayoutTemplate),\n\t})\n\n\tSerializableObject.addSpreadAtStart(props, js`props`)\n\tconst createElement = js`${imports.addImport(\"react\", { exportSpecifier: \"*\", importBinding: \"React\" })}.createElement`\n\tif (!unresolvedLinks) {\n\t\treturn wrapInSwitchCase(\n\t\t\twebPageIds,\n\t\t\tjs`return ${SafeJS.fn(createElement, LayoutTemplate, props, js`children(true)`)};`,\n\t\t)\n\t}\n\n\tSerializableObject.assign(props, unresolvedLinks.props)\n\n\tconst { ResolveLinks, binding, links } = unresolvedLinks\n\n\treturn wrapInSwitchCase(\n\t\twebPageIds,\n\t\tjs`return ${SafeJS.fn(\n\t\t\tcreateElement,\n\t\t\tResolveLinks,\n\t\t\tnew SerializableObject({ links: links }, SortBehavior.Unsorted),\n\t\t\tjs`(${binding}) => ${SafeJS.fn(createElement, LayoutTemplate, props, js`children(true)`)}`,\n\t\t)};`,\n\t)\n}\n\nexport function getAppliedLocalLayoutTemplates(tree: CanvasTree, screens: CanvasNode[]): AnyLayoutTemplateNode[] {\n\tconst nodes: AnyLayoutTemplateNode[] = []\n\n\tfor (const screen of screens) {\n\t\tif (!isWebPageNode(screen) || !hasLayoutTemplate(screen)) continue\n\t\tconst parsedIdentifier = parseModuleIdentifier(screen.layoutTemplateIdentifier)\n\t\tif (!isLocalModuleIdentifier(parsedIdentifier) || parsedIdentifier.type !== ModuleType.LayoutTemplate) continue\n\n\t\tconst templateNode = tree.getNodeWithTrait(parsedIdentifier.localIdName, isLayoutTemplateNode)\n\t\tif (!templateNode) continue\n\n\t\tnodes.push(templateNode)\n\t}\n\n\treturn nodes\n}\n\ninterface PropsComparison {\n\tbinding: SafeJS\n\tvalue: Record<string, unknown>\n}\n\nexport function exportLayoutTemplates(\n\ttree: CanvasTree,\n\tcomponentLoader: ComponentLoader,\n\tmodulesStore: ModulesStore,\n\tassetStore: AssetStore,\n\tscreens: CanvasNode[],\n\timports: ImportCollector,\n\tbindings: BindingCollector,\n\toptions: { lazy?: boolean } = {},\n): { binding: SafeJS; declarations: SafeJS; css: string } | undefined {\n\tconst webPageToTemplateId: Record<NodeID, NodeID> = {}\n\tconst templateIdToWebPageIds: Record<NodeID, NodeID[]> = {}\n\tconst templateIdToBinding: Record<NodeID, SafeJS> = {}\n\tconst breakpoints = new Map<NodeID, Breakpoints>()\n\tconst webPageProps: Record<WebPageId, SerializableValue> = {}\n\tconst ctx = createWebPageLayoutTemplateContext(tree, componentLoader, modulesStore, assetStore, imports, bindings)\n\tconst propsBinding = ctx.bindings.create(\"props\")\n\tconst templatePropComparisons: Record<NodeID, PropsComparison> = {}\n\tconst seen = new Set<NodeID>()\n\tconst Template = ctx.bindings.create(\"Template\")\n\n\tconst homePage = tree.getNodeWithTrait(tree.root.homePageNodeId, isWebPageNode)\n\tif (!isWebPageNode(homePage)) return\n\n\t// Start iterating through the homepage to create a comparison props object for each template.\n\tfor (const node of [homePage, ...screens]) {\n\t\tif (!isWebPageNode(node, true) || !hasLayoutTemplate(node) || seen.has(node.id)) continue\n\t\tconst parsedIdentifier = parseModuleIdentifier(node.layoutTemplateIdentifier)\n\t\tif (!isLocalModuleIdentifier(parsedIdentifier) || parsedIdentifier.type !== ModuleType.LayoutTemplate) continue\n\n\t\t// Skip a template if it is no longer in the tree.\n\t\tconst templateNode = tree.getNodeWithTrait(parsedIdentifier.localIdName, isLayoutTemplateNode)\n\t\tif (!templateNode) continue\n\n\t\tseen.add(node.id)\n\n\t\tconst module = modulesStore.getPersistedModuleByLocalId(parsedIdentifier.localId)\n\t\tconst url = module?.moduleURL\n\t\tassert(url, \"An applied Layout Template must have a module URL.\")\n\n\t\tconst breakpointsAnnotation = modulesStore\n\t\t\t.forType(ModuleType.LayoutTemplate)\n\t\t\t.getByLocalId(parsedIdentifier.localId)\n\t\t\t.annotations(\n\t\t\t\tcomponentLoader.componentForIdentifier(node.layoutTemplateIdentifier),\n\t\t\t\tparsedIdentifier.exportSpecifier,\n\t\t\t)?.[AnnotationKey.FramerBreakpoints]\n\n\t\tif (isBreakpoints(breakpointsAnnotation)) breakpoints.set(parsedIdentifier.localIdName, breakpointsAnnotation)\n\n\t\tconst controls = componentLoader.componentForIdentifier(node.layoutTemplateIdentifier)?.properties\n\t\tassert(controls, \"An applied Layout Template must have controls.\")\n\n\t\tconst props = getPublishedWebPageLayoutTemplateControlProps(\n\t\t\tnode,\n\t\t\tcontrols,\n\t\t\t// @TODO - In future, consider resolving controls from static annotations.\n\t\t\tnode.getControlProps(controls),\n\t\t\ttemplateNode.id,\n\t\t\tctx,\n\t\t)\n\n\t\t// Compare to the props of the first web page that uses this template. This will always be\n\t\t// the home page for pages inheriting the root template.\n\t\tconst comparison = templatePropComparisons[templateNode.id]\n\t\tconst diff = difference(props, comparison?.value, \"js\")\n\n\t\tif (comparison?.value && !isEmptyObject(props) && (!diff || isEmptyObject(diff))) {\n\t\t\t// If the props are identical to the props of the first web page that uses this template,\n\t\t\t// then record a reference to those props.\n\t\t\twebPageProps[node.id] = comparison.binding\n\t\t} else if (isSerializableValue(diff) && !isEmptyObject(diff)) {\n\t\t\t// If there is a difference between the props of the first web page that uses this\n\t\t\t// template, and the props of this web page, create a binding that spreads the original\n\t\t\t// props, before inlining the difference keys.\n\t\t\tconst binding = ctx.declarations.component.dedupe(\"props\", createSpreadPropsDiffBinding(diff, comparison))\n\n\t\t\twebPageProps[node.id] = binding\n\t\t\ttemplatePropComparisons[templateNode.id] ??= { binding, value: diff }\n\t\t}\n\n\t\t// Track which webpages are using this template.\n\t\twebPageToTemplateId[node.id] = parsedIdentifier.localIdName\n\n\t\tconst webPageIds = templateIdToWebPageIds[parsedIdentifier.localIdName] ?? []\n\t\twebPageIds.push(node.id)\n\t\ttemplateIdToWebPageIds[parsedIdentifier.localIdName] = webPageIds\n\n\t\t// If we have already seen this template, no need to import it again.\n\t\tif (parsedIdentifier.localIdName in templateIdToBinding) continue\n\n\t\t// We always import all templates into every webpage. This means we\n\t\t// don't need a solution to preload a lazy template for a route when\n\t\t// navigating to an unloaded page with an unloaded template. We could\n\t\t// try to optimize that in the future if it becomes common to have many\n\t\t// templates in a single site, but likely there will only be a few\n\t\t// templates.\n\t\t// As an option, the caller may choose to emit lazy imports instead,\n\t\t// for contexts like agent screenshots where we know we don't need to support\n\t\t// fast navigations.\n\t\ttemplateIdToBinding[parsedIdentifier.localIdName] = ctx.imports.addImport(url, {\n\t\t\texportSpecifier: \"default\",\n\t\t\timportBinding: safeTagName(templateNode.resolveValue(\"name\") ?? \"Template\"),\n\t\t\tlazy: options.lazy,\n\t\t})\n\t}\n\n\t// If we have imported no Layout Templates, we don't need to generate any code for Publishing.\n\tif (isEmptyObject(templateIdToWebPageIds)) return undefined\n\n\tconst componentFunctionCases: SafeJS[] = []\n\tconst ssgFunctionCases: SafeJS[] = []\n\n\tfor (const templateId in templateIdToWebPageIds) {\n\t\tconst webPageIds = templateIdToWebPageIds[templateId]\n\t\tconst layoutTemplateBinding = templateIdToBinding[templateId]\n\t\tif (!layoutTemplateBinding || !webPageIds) continue\n\n\t\tcomponentFunctionCases.push(\n\t\t\tcreateLayoutTemplateCase(layoutTemplateBinding, webPageIds, ctx.unresolvedLinks.values(templateId), ctx.imports),\n\t\t)\n\n\t\t// Create a case for all the webpages that use this template, recording\n\t\t// its breakpoints. This allows SSG to create the appropriate hidden-xxx\n\t\t// class names, rewrite responsive images, and cleanup unused\n\t\t// breakpoints. If a template doesn't have breakpoints, we will fallback\n\t\t// to the default case.\n\t\tconst breakpointHashes = breakpoints.get(templateId)\n\t\tif (!breakpointHashes) continue\n\n\t\tssgFunctionCases.push(\n\t\t\twrapInSwitchCase(webPageIds, js`return ${breakpointHashesForLayoutTemplateAnnotation(breakpointHashes)}`),\n\t\t)\n\t}\n\n\tconst props = ctx.declarations.component.dedupe(\"templateProps\", webPageProps)\n\tconst cssRules = ctx.wideGamutColors.getWideGamutColorRules(\"body\")\n\n\treturn {\n\t\tbinding: Template,\n\t\tcss: cssRules.length ? `@supports (color: color(display-p3 1 1 1)) { ${cssRules.join(\" \")} }` : \"\",\n\t\tdeclarations: js.joinLines(\n\t\t\t...ctx.declarations.file.list(),\n\t\t\tjs`function ${Template}({webPageId, children, style, ...rest}) {${js.joinLines(\n\t\t\t\t...ctx.declarations.component.list(),\n\t\t\t\tjs`const ${propsBinding} = ${props}[webPageId] ?? {}`,\n\t\t\t\tjs`switch (webPageId) {${js.joinLines(...componentFunctionCases, js`default: { return children(false) }`)}}`,\n\t\t\t)}}`,\n\t\t\tjs`export function getLayoutTemplateBreakpoints(routeId) {${js.joinLines(\n\t\t\t\tjs`switch (routeId) {${js.joinLines(...ssgFunctionCases, js`default: { return undefined }`)}}}`,\n\t\t\t)}`,\n\t\t),\n\t}\n}\n\nfunction createSpreadPropsDiffBinding(\n\tdiff: Record<string, SerializableValue | undefined>,\n\tcomparison?: PropsComparison,\n) {\n\tif (!comparison) return diff\n\n\tconst obj = new SerializableObject(diff)\n\tSerializableObject.addSpreadAtStart(obj, comparison.binding)\n\treturn obj\n}\n\nexport function getSlotNodeIndex(layoutTemplate: LoadedLayoutTemplateNode): number | undefined {\n\tconst templateBreakpoint = layoutTemplate.getPrimaryVariant()\n\tif (!templateBreakpoint || !withChildren(templateBreakpoint)) return\n\treturn templateBreakpoint.children.findIndex(n => isSlotNode(n))\n}\n\nfunction wrapInSwitchCase(cases: string[], value: SafeJS): SafeJS {\n\treturn js.joinLines(...cases.map(value => js`case ${value}:`), value)\n}\n\nexport function ensureAllBreakpointsAreVerticalStack(tree: CanvasTree, loadedScope: LoadedWebPageNode) {\n\tif (!withBreakpointVariants(loadedScope)) return\n\n\t// Update the primary, and reset all replica layout overrides\n\tconst primaryVariant = loadedScope.getPrimaryVariant()\n\tprimaryVariant.set(defaultStackLayoutForLayoutTemplate)\n\tresetNodeOverrides(tree, loadedScope.getReplicaVariants(), [TraitType.Layout, TraitType.Padding])\n}\n\nexport function removeFlowEffectFromBreakpoints(tree: CanvasTree, loadedScope: LoadedWebPageNode) {\n\tif (!withBreakpointVariants(loadedScope)) return\n\n\tconst primaryVariant = loadedScope.getPrimaryVariant()\n\tprimaryVariant.set({ ...flowEffectDefaults })\n\tresetNodeOverrides(tree, loadedScope.getReplicaVariants(), [TraitType.FlowEffect])\n}\n\nexport function clearCustomCursorFromGroundNode(tree: CanvasTree, loadedScope: LoadedWebPageNode) {\n\tif (!withBreakpointVariants(loadedScope)) return\n\n\tconst primaryVariant = loadedScope.getPrimaryVariant()\n\tprimaryVariant.set({ ...cursorDefaults })\n\tresetNodeOverrides(tree, loadedScope.getReplicaVariants(), [TraitType.Cursor, TraitType.CustomCursor])\n}\n\n/**\n * When applying a Layout Template to the home page, all other Web Pages that\n * don't already have an override set will inherit the Layout Template. To\n * ensure we don't apply the new Layout Template to pages that can't accept one\n * { @see webPageAcceptsLayoutTemplate }, we analyze pages that may inherit it.\n * We try to first use the module annotations, otherwise analyzing the tree.\n * This allows us to minimize the number of shallow scopes to load.\n */\nexport function getInfoForWebPagesInheritingLayoutTemplate(engine: VekterEngine) {\n\tconst incompatible = new Set<NodeID>()\n\tconst shallow = new Set<NodeID>()\n\tconst treeStore = engine.stores.treeStore\n\tconst tree = treeStore.getDataTreeOrLoadedTree()\n\n\tfor (const scope of tree.root.children) {\n\t\tif (scope.id === engine.tree.root.homePageNodeId) continue\n\t\tif (!isWebPageNode(scope) || !isUndefined(scope.layoutTemplateIdentifierOverride)) continue\n\n\t\tconst acceptsLayoutTemplate = engine.stores.modulesStore\n\t\t\t.forType(ModuleType.Screen)\n\t\t\t.getByStableName(scope.id)\n\t\t\t?.annotations(engine.componentLoader.componentForIdentifier(scope.instanceIdentifier), \"default\")?.[\n\t\t\tAnnotationKey.FramerAcceptsLayoutTemplate\n\t\t]\n\n\t\tif (isBoolean(acceptsLayoutTemplate)) {\n\t\t\tif (acceptsLayoutTemplate === false) incompatible.add(scope.id)\n\t\t\tcontinue\n\t\t}\n\n\t\tif (scope.isLoaded()) {\n\t\t\tif (webPageAcceptsLayoutTemplate(scope) === false) incompatible.add(scope.id)\n\t\t\tcontinue\n\t\t}\n\n\t\tshallow.add(scope.id)\n\t}\n\n\treturn {\n\t\tincompatible,\n\t\tshallow,\n\t} as const\n}\n\n/**\n * When determining which Web Pages can inherit the Root Layout Template, some\n * Web Pages may not have a FramerAcceptsLayoutTemplate annotation, and so will\n * need to be fully loaded in order to analyze if they are compatible with\n * layout templates.\n */\nexport async function getLayoutTemplateIncompatibleShallowWebPageNodes(\n\tengine: VekterEngine,\n\tshallowWebPageNodes: Set<NodeID>,\n): Promise<Set<NodeID>> {\n\tconst incompatible = new Set<NodeID>()\n\tconst scopes = Array.from(shallowWebPageNodes).map(id => engine.tree.getNodeWithTrait(id, isWebPageNode))\n\tconst loadedScopes = await engine.tree.loadScopes(scopes)\n\tfor (const scope of loadedScopes) {\n\t\tif (isNull(scope) || webPageAcceptsLayoutTemplate(scope)) {\n\t\t\tcontinue\n\t\t}\n\t\tincompatible.add(scope.id)\n\t}\n\n\treturn incompatible\n}\n\nfunction applyLayoutTemplateExcludingIncompatibleWebPages(\n\tengine: VekterEngine,\n\tscope: LoadedWebPageNode,\n\tlayoutTemplate: AnyLayoutTemplateNode | (() => LoadedLayoutTemplateNode),\n\tnode: CanvasNode | undefined = undefined,\n\tincompatible: Set<NodeID> = new Set(),\n): void {\n\tconst isCreating = isFunction(layoutTemplate)\n\tconst template = isCreating ? layoutTemplate() : layoutTemplate\n\n\tconst target = scope.id === engine.tree.root.homePageNodeId ? engine.tree.root : engine.tree.current(scope)\n\tif (!target) return\n\n\tfor (const id of incompatible) {\n\t\tengine.tree.getNodeWithTrait(id, isWebPageNode)?.set({ layoutTemplateIdentifierOverride: null })\n\t}\n\n\ttarget.set({ layoutTemplateIdentifier: template.instanceIdentifier })\n\tensureAllBreakpointsAreVerticalStack(engine.tree, scope)\n\tclearCustomCursorFromGroundNode(engine.tree, scope)\n\tremoveFlowEffectFromBreakpoints(engine.tree, scope)\n\n\tif (isCreating) engine.stores.scopeStore.select(template.id, { keepHistory: false })\n\n\tif (!node) return\n\n\tassert(template.isLoaded(), \"Layout Templates: template must be loaded to add a child.\")\n\n\tconst slotIndex = getSlotNodeIndex(template)\n\n\tconst activeBundleHash = engine.componentLoader.activeBundleHash\n\tif (!activeBundleHash) return\n\n\tconst values = getInheritedVariablesValueMap(\n\t\tengine.tree,\n\t\tengine.componentLoader,\n\t\tactiveBundleHash,\n\t\tengine.stores.treeStore.sandboxRepeaterData,\n\t\tnode.id,\n\t)\n\tconst current = engine.tree.current(node)\n\tif (!current) return\n\n\tfor (const replacement of current.walk()) {\n\t\tconst update = getNodeUpdateResolvingDynamicValues(engine.tree, scope.id, replacement, values)\n\t\tif (!update) continue\n\t\treplacement.set(update)\n\t}\n\n\tengine.tree.moveNode(node, template.baseVariantId, slotIndex)\n\tengine.stores.selectionStore.set(node.id)\n}\n\n/**\n * Apply a Layout Template to a Web Page. If the Web Page is the home page,\n * handle inheritance, applying the Template only to Web Pages that can accept\n * it in a single tree commit.\n *\n * @param node - A node to move into a newly created Layout Template.\n */\nexport async function applyLayoutTemplate(\n\tengine: VekterEngine,\n\tscope: LoadedWebPageNode,\n\tlayoutTemplate: () => LoadedLayoutTemplateNode,\n\tnode?: CanvasNode,\n): Promise<void>\nexport async function applyLayoutTemplate(\n\tengine: VekterEngine,\n\tscope: LoadedWebPageNode,\n\tlayoutTemplate: AnyLayoutTemplateNode,\n): Promise<void>\nexport async function applyLayoutTemplate(\n\tengine: VekterEngine,\n\tscope: LoadedWebPageNode,\n\tlayoutTemplate: AnyLayoutTemplateNode | (() => LoadedLayoutTemplateNode),\n\tnode?: CanvasNode,\n): Promise<void> {\n\tif (scope.id === engine.tree.root.homePageNodeId) {\n\t\tconst { incompatible, shallow } = getInfoForWebPagesInheritingLayoutTemplate(engine)\n\t\tif (shallow.size === 0) {\n\t\t\tapplyLayoutTemplateExcludingIncompatibleWebPages(engine, scope, layoutTemplate, node, incompatible)\n\t\t} else {\n\t\t\tconst shallowIncompatible = await getLayoutTemplateIncompatibleShallowWebPageNodes(engine, shallow)\n\t\t\tconst allIncompatible = new Set([...incompatible, ...shallowIncompatible])\n\n\t\t\tengine.scheduler.process(() => {\n\t\t\t\tapplyLayoutTemplateExcludingIncompatibleWebPages(engine, scope, layoutTemplate, node, allIncompatible)\n\t\t\t})\n\t\t}\n\n\t\trecord(\"layout_template_apply\", { onHomePage: true })\n\t} else {\n\t\tapplyLayoutTemplateExcludingIncompatibleWebPages(engine, scope, layoutTemplate, node)\n\t\trecord(\"layout_template_apply\", { onHomePage: false })\n\t}\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAM,OAAO;AAAA,EACX,OAAO;AACT;AACA,SAAS,iCAAiC,SAAS;AACjD,QAAM,QAAQ;AAAA,IACZ,GAAG;AAAA,IACH,OAAO;AAAA,EACT;AACA,eAAa,OAAO,IAAI;AAC1B;;;ACbO,SAAS,wBAAkD,MAAkB,UAA4B;AAC/G,QAAM,eAA+B,oBAAI,IAAI;AAC7C,QAAM,wBAA0C,oBAAI,IAAI;AAExD,aAAW,QAAQ,UAAU;AAC5B,QAAI,KAAK,mBAAmB;AAC3B,UAAI,WAAW,sBAAsB,IAAI,KAAK,iBAAiB;AAC/D,UAAI,CAAC,UAAU;AACd,mBAAW,CAAC;AACZ,8BAAsB,IAAI,KAAK,mBAAmB,QAAQ;AAAA,MAC3D;AACA,eAAS,KAAK,IAAI;AAAA,IACnB,OAAO;AACN,mBAAa,IAAI,KAAK,IAAI,IAAI;AAAA,IAC/B;AAAA,EACD;AAEA,QAAM,8BAAmC,CAAC;AAE1C,aAAW,aAAa,wBAAwB,IAAI,EAAE,yBAAyB,IAAI,EAAE,KAAK,GAAG;AAC5F,UAAM,UAAU,aAAa,IAAI,SAAS;AAC1C,QAAI,SAAS;AACZ,kCAA4B,KAAK,OAAO;AAGxC,YAAM,aAAa,sBAAsB,IAAI,QAAQ,EAAE;AACvD,UAAI,YAAY;AACf,oCAA4B,KAAK,GAAG,UAAU;AAAA,MAC/C;AAAA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