{
  "version": 3,
  "sources": ["../../../../../node_modules/@framerjs/framer-events/lib/esm/generated/CanvasPageSelect.js", "../../../../../node_modules/@framerjs/framer-events/lib/esm/generated/VekterPerformanceBenchmark.js", "../../src/debug-utils/bench.ts", "../../src/debug-utils/fuzzer.ts", "../../src/app/headless/ConnectionGuard.ts", "../../src/document/models/CanvasTree/utils/isExportableAsSVG.ts", "../../src/utils/exportCommon.tsx", "../../src/utils/renderNodeToSVG.tsx", "../../src/canvas-sandbox-renderer/ReadonlyPopupSandbox.ts", "../../src/canvas-sandbox-renderer/SandboxRenderer.ts", "../../src/app/ScreenshotSandbox.ts", "../../src/app/headless/ensureNodeLoaded.ts", "../../src/app/headless/HeadlessScreenshots.ts", "../../src/app/HeadlessAPI.ts", "../../src/app/globals.ts", "../../src/document/components/ProjectGlobal.styles.ts", "../../src/canvas-sandbox-renderer/SandboxRPC.ts", "../../src/canvas-sandbox-renderer/IFrameSandbox.ts", "../../src/export/DebugNodeRenderer.tsx", "../../src/export/NodeRenderer.ts", "../../src/canvas-sandbox-renderer/CanvasSandboxRenderer.tsx", "../../src/canvas-sandbox-renderer/PopupSandbox.ts", "../../src/debug-utils/crash.ts", "../../src/document/components/chrome/agentPanel/AgentChatPanel.tsx", "../../src/document/components/chrome/agentPanel/components/AgentChatAiDisabledBlock.tsx", "../../src/web/pages/project/lib/convertProjectToMode.ts", "../../src/document/components/chrome/agentPanel/components/AgentChatCrdtDisabledBlock.tsx", "../../src/document/components/chrome/shared/UpsellModal/utils/useNavigateToAiCreditsPlans.ts", "../../src/document/components/chrome/agentPanel/components/AgentChatCreditLimitBlock.tsx", "../../src/document/components/chrome/agentPanel/components/AgentChatPicker.tsx", "../../src/document/components/chrome/agentPanel/components/AgentChatPicker.styles.ts", "../../src/document/components/chrome/agentPanel/components/AgentChatQuestions.tsx", "../../src/document/components/chrome/agentPanel/components/AgentChatQuestions.styles.ts", "../../src/web/pages/project/lib/setProjectReleaseChannel.ts", "../../src/document/components/chrome/agentPanel/components/AgentChatReleaseChannelBlock.tsx", "../../src/document/components/chrome/agentPanel/components/AgentPromptQueue.tsx", "../../src/document/components/chrome/agentPanel/components/AgentPromptQueue.styles.ts", "../../src/history/initClusterHistory.ts", "../../src/document/components/chrome/debugbar/crdt/saveBlobAsLocalFile.ts"],
  "sourcesContent": ["import { triggerEvent } from \"../listeners\";\nfunction createCanvasPageSelectEvent(payload) {\n  console.warn(\"[DEPRECATED] Use triggerCanvasPageSelectEvent instead of createCanvasPageSelectEvent.\");\n  return {\n    ...payload,\n    event: \"canvas_page_select\"\n  };\n}\nconst meta = {\n  track: true\n};\nfunction triggerCanvasPageSelectEvent(payload) {\n  const event = {\n    ...payload,\n    event: \"canvas_page_select\"\n  };\n  triggerEvent(event, meta);\n}\nexport {\n  createCanvasPageSelectEvent,\n  triggerCanvasPageSelectEvent\n};\n", "import { triggerEvent } from \"../listeners\";\nfunction createVekterPerformanceBenchmarkEvent(payload) {\n  console.warn(\"[DEPRECATED] Use triggerVekterPerformanceBenchmarkEvent instead of createVekterPerformanceBenchmarkEvent.\");\n  return {\n    ...payload,\n    event: \"vekter_performance_benchmark\"\n  };\n}\nconst meta = {\n  track: true\n};\nfunction triggerVekterPerformanceBenchmarkEvent(payload) {\n  const event = {\n    ...payload,\n    event: \"vekter_performance_benchmark\"\n  };\n  triggerEvent(event, meta);\n}\nexport {\n  createVekterPerformanceBenchmarkEvent,\n  triggerVekterPerformanceBenchmarkEvent\n};\n", "import type { VekterPerformanceBenchmarkPayload } from \"@framerjs/framer-events\"\nimport { createVekterPerformanceBenchmarkEvent } from \"@framerjs/framer-events\"\nimport { assert, getLogger, reportableError } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { ContextAction } from \"document/components/utils/contextActions.ts\"\nimport type { TextNode } from \"document/models/CanvasTree/index.ts\"\nimport { CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport { isTextNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport type { FrameStats } from \"document/stores/DebugStore.ts\"\nimport { Tools } from \"document/stores/ToolStore.ts\"\nimport { Metrics } from \"../app/metrics.ts\"\n\nconst log = getLogger(\"bench\")\n\n// exposes Vekter.benchZoom() or cmd+ctrl+alt+Z to zoom in/out as benchmark\n// exposes Vekter.bench() or cmd+ctrl+alt+B which creates a new doc with various elements\n\nclass Benchmark {\n\tprivate current = 0\n\tprivate scheduled: (() => unknown)[] = []\n\tprivate reports: FrameStats[] = []\n\tprivate started: number = 0\n\tprivate ended: number = 0\n\n\tconstructor(\n\t\tpublic name: string,\n\t\tprivate version: number,\n\t\tprivate engine: VekterEngine,\n\t\tprivate onComplete: (results: VekterPerformanceBenchmarkPayload) => void,\n\t\tprivate displayResults: boolean,\n\t) {}\n\n\tstep(fn: () => unknown): this {\n\t\tassert(!this.started)\n\t\tthis.scheduled.push(fn)\n\t\treturn this\n\t}\n\n\tdrag(x: number, y: number, dx: number, dy: number, STEPS = 25): this {\n\t\tthis.step(() => {\n\t\t\tthis.engine.setMouseStore(x, y, false)\n\t\t})\n\t\tfor (let i = 0; i <= STEPS; i++) {\n\t\t\tthis.step(() => {\n\t\t\t\tthis.engine.setMouseStore(x + Math.round((dx / STEPS) * i), y + Math.round((dy / STEPS) * i), true)\n\t\t\t})\n\t\t}\n\t\tthis.step(() => {\n\t\t\tthis.engine.setMouseStore(x + dx, y + dy, false)\n\t\t})\n\t\treturn this\n\t}\n\n\tstart(afterDelay = 0) {\n\t\tlog.debug(`--- bench:starting ${this.name} steps: ${this.scheduled.length} ---`)\n\t\tsetTimeout(this.runOne, afterDelay)\n\t}\n\n\tdone() {\n\t\tif (this.ended) return\n\t\tthis.ended = Date.now()\n\t\tconst duration = this.ended - this.started\n\t\tconst fps = this.scheduled.length / (duration / 1000)\n\t\tlog.info(`--- bench:done ${this.name} duration: ${(duration / 1000).toFixed(3)} seconds, fps: ${fps} ---`)\n\t\t// biome-ignore lint/suspicious/noConsole: <explanation>\n\t\t// console.table(\n\t\t//     this.reports.map(frame => {\n\t\t//         frame = { ...frame, perf: 0 }\n\t\t//         // biome-ignore lint/performance/noDelete: <explanation>\n\t\t//         delete frame.perf\n\t\t//         return frame\n\t\t//     })\n\t\t// )\n\n\t\tconst results: VekterPerformanceBenchmarkPayload = {\n\t\t\tdurationMs: duration,\n\t\t\tfps,\n\t\t\tname: this.name,\n\t\t\tversion: this.version,\n\t\t\twindowHeight: window.innerHeight,\n\t\t\twindowWidth: window.innerWidth,\n\t\t}\n\n\t\tthis.onComplete(results)\n\n\t\tif (this.displayResults) {\n\t\t\treport(results)\n\t\t}\n\t}\n\n\trunOne = (): void => {\n\t\tif (this.ended) return\n\n\t\tif (!this.started) {\n\t\t\tthis.started = Date.now()\n\t\t}\n\t\tif (this.current > 0) {\n\t\t\tthis.reports[this.current - 1] = this.engine.getLastReport()\n\t\t}\n\n\t\tconst run = this.scheduled[this.current]\n\t\tthis.current += 1\n\n\t\t// biome-ignore lint/correctness/noVoidTypeReturn: <explanation>\n\t\tif (!run) return this.done()\n\t\tthis.runOneWrapped(run)\n\t}\n\n\trunOneWrapped(run: () => unknown) {\n\t\tthis.engine.scheduler.enterEventHandling()\n\t\ttry {\n\t\t\tthis.engine.scheduler.runBeforeNextFrame(this.runOne)\n\t\t\trun()\n\t\t} catch (error) {\n\t\t\tthis.engine.scheduler.errorInEventHandler(reportableError(error))\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tthis.engine.scheduler.exitEventHandling()\n\t\t}\n\t}\n}\n\nexport async function benchZoom(engine: VekterEngine, displayResults: boolean = true) {\n\treturn new Promise<VekterPerformanceBenchmarkPayload>(resolve => {\n\t\tconst { canvasStore } = engine.stores\n\t\t// NOTE: Increment the version when changing this function.\n\t\tconst bench = new Benchmark(\"zoom\", 2, engine, resolve, displayResults)\n\t\tconst zoomLevels = [1, 2, 4, 8, 16, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.0625]\n\t\tfor (const zoomLevel of zoomLevels) {\n\t\t\tbench.step(() => {\n\t\t\t\tcanvasStore.setZoom(zoomLevel)\n\t\t\t})\n\t\t}\n\n\t\tengine.scheduler.processWhenReady(() => {\n\t\t\t// centers and zooms to 100%\n\t\t\tcanvasStore.zoomToFitAll()\n\t\t\tcanvasStore.setZoom(1)\n\t\t\tbench.start(1000)\n\t\t})\n\t})\n}\n\nexport async function benchCreate(engine: VekterEngine, displayResults: boolean = true) {\n\treturn new Promise<VekterPerformanceBenchmarkPayload>(resolve => {\n\t\t// NOTE: Increment the version when changing this function.\n\t\tconst bench = new Benchmark(\"create\", 1, engine, resolve, displayResults)\n\t\tbench.step(() => {\n\t\t\tengine.load(CanvasTree.createEmpty())\n\t\t\tengine.stores.canvasStore.setZoom(1)\n\t\t})\n\t\tbench.step(() => {\n\t\t\tengine.setTool(Tools.CreateFrame)\n\t\t})\n\t\tbench.drag(0, 0, 200, 600)\n\n\t\t// big\n\t\tbench.step(() => {\n\t\t\tengine.setTool(Tools.CreateFrame)\n\t\t})\n\t\tbench.drag(10, 10, 180, 580)\n\n\t\t// small\n\t\tbench.step(() => {\n\t\t\tengine.setTool(Tools.CreateFrame)\n\t\t})\n\t\tbench.drag(20, 20, 10, 10, 5)\n\t\tbench.step(() => {\n\t\t\tengine.setTool(Tools.CreateFrame)\n\t\t})\n\t\tbench.drag(40, 20, 10, 10, 5)\n\t\tbench.step(() => {\n\t\t\tengine.setTool(Tools.CreateFrame)\n\t\t})\n\t\tbench.drag(60, 20, 10, 10, 5)\n\t\tbench.step(() => {\n\t\t\tengine.setTool(Tools.CreateFrame)\n\t\t})\n\t\tbench.drag(80, 20, 10, 10, 5)\n\n\t\t// text\n\t\tbench.step(() => {\n\t\t\tengine.setTool(Tools.CreateText)\n\t\t})\n\t\tbench.step(() => {\n\t\t\tengine.setMouseStore(50, 100, false)\n\t\t})\n\t\tbench.step(() => {\n\t\t\tengine.setMouseStore(50, 100, true)\n\t\t})\n\t\tbench.step(() => {\n\t\t\tengine.setMouseStore(50, 100, false)\n\t\t})\n\t\tbench.step(() => {\n\t\t\tconst text = engine.tree.root.find(isTextNode)\n\t\t\tassert(text)\n\t\t\tlet { styledText } = text\n\t\t\tstyledText = styledText.withUpdatedText(\"hello world!\")\n\t\t\tengine.tree.get<TextNode<any>>(text.id)?.set({ styledText })\n\t\t})\n\t\tbench.step(() => {\n\t\t\tengine.exitTool()\n\t\t})\n\t\t// duplicate\n\t\tbench.step(() => {\n\t\t\tconst firstChild = engine.tree.root.children.at(0)\n\t\t\tassert(firstChild, \"Expected benchmark root to have a child\")\n\t\t\tengine.stores.selectionStore.set(firstChild)\n\t\t})\n\t\tfor (let i = 0; i < 20; i++) {\n\t\t\tbench.step(() => {\n\t\t\t\tContextAction.duplicateNodes(engine, engine.stores.selectionStore.ids)\n\t\t\t})\n\t\t}\n\t\tbench.step(() => {\n\t\t\tengine.stores.canvasStore.setZoom(0.5)\n\t\t})\n\t\tbench.step(() => {\n\t\t\tengine.stores.canvasStore.setZoom(0.25)\n\t\t})\n\n\t\t// select\n\t\tbench.drag(6300, -100, -1300, 800)\n\t\t// move\n\t\tbench.drag(5200, 300, -1000, -100)\n\t\tbench.step(() => {\n\t\t\tengine.stores.canvasStore.scrollToCenter(engine.stores.mouseStore.latest.canvasMousePosition)\n\t\t})\n\t\tbench.drag(4200, 200, -1000, 0)\n\t\tbench.step(() => {\n\t\t\tengine.stores.canvasStore.scrollToCenter(engine.stores.mouseStore.latest.canvasMousePosition)\n\t\t})\n\t\tbench.drag(3200, 200, -3200, -500)\n\t\tbench.step(() => {\n\t\t\tengine.stores.canvasStore.scrollToCenter(engine.stores.mouseStore.latest.canvasMousePosition)\n\t\t})\n\t\t// duplicate\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tbench.step(() => {\n\t\t\t\tContextAction.duplicateNodes(engine, engine.stores.selectionStore.ids)\n\t\t\t})\n\t\t}\n\t\t// undo\n\t\tfor (let i = 0; i < 50; i++) {\n\t\t\tbench.step(() => {\n\t\t\t\tengine.undo()\n\t\t\t})\n\t\t}\n\t\tfor (let i = 0; i < 10; i++) {\n\t\t\tbench.step(() => {\n\t\t\t\tengine.redo()\n\t\t\t})\n\t\t}\n\t\treturn bench.start()\n\t})\n}\n\nfunction report(result: VekterPerformanceBenchmarkPayload) {\n\tconst div = document.createElement(\"div\")\n\tObject.assign(div.style, {\n\t\tposition: \"fixed\",\n\t\ttop: 0,\n\t\tleft: 0,\n\t\twidth: \"100%\",\n\t\theight: \"100%\",\n\t\t\"z-index\": 1000,\n\t\t\"background-color\": \"rgba(0,0,0,0.5)\",\n\t\tdisplay: \"flex\",\n\t\t\"align-items\": \"center\",\n\t\t\"justify-content\": \"center\",\n\t\t\"user-select\": \"text\",\n\t})\n\tconst { durationMs = 0, fps = 0 } = result\n\tconst text = `duration: ${(durationMs / 1000).toFixed(2)}\\nfps: ${fps.toFixed(1)}`\n\tdiv.innerText = text\n\tdocument.body.appendChild(div)\n\tdiv.onclick = () => {\n\t\tconst el = document.createElement(\"textarea\")\n\t\tel.value = text\n\t\tdocument.body.appendChild(el)\n\t\tel.select()\n\t\tdocument.execCommand(\"copy\")\n\t\tel.remove()\n\t\tdiv.remove()\n\t}\n\n\tconst evt = createVekterPerformanceBenchmarkEvent({\n\t\tname: result.name,\n\t\tversion: result.version,\n\t\tfps: result.fps,\n\t\tdurationMs: result.durationMs,\n\t})\n\tMetrics.pushEvent(evt)\n}\n", "import { assert, getLogger, reportableError } from \"@framerjs/shared\"\nimport { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { CanvasNode, CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport { CanvasPageNode, FrameNode, WebPageNode, isVectorNode } from \"document/models/CanvasTree/index.ts\"\nimport { randomID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { RootNode } from \"document/models/CanvasTree/nodes/RootNode.ts\"\nimport { RouteSegmentRootNode } from \"document/models/CanvasTree/nodes/RouteSegmentRootNode.ts\"\nimport {\n\tisCanvasPageNode,\n\tisCodeComponentNode,\n\tisRouteSegmentNode,\n\tisRouteSegmentRootNode,\n\tisRoutesNode,\n\tisShapeContainerNode,\n\tisSmartComponentNode,\n\tisWebPageNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { withChildren } from \"document/models/CanvasTree/traits/WithChildren.ts\"\nimport { withFill } from \"document/models/CanvasTree/traits/WithFill.ts\"\nimport { isPinnable } from \"document/models/CanvasTree/traits/WithPins.ts\"\nimport { isReplicaChild } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\nimport { isRootScopeNode } from \"document/stores/ScopeStore.ts\"\n\nfunction cannotDeleteNode(tree: CanvasTree, node: CanvasNode) {\n\tconst parent = tree.get(node.parentid)\n\tassert(parent, \"node must have a parent\")\n\n\tif (isCanvasPageNode(parent)) {\n\t\tif (parent.homeNodeId === node.id) return true\n\t} else if (isWebPageNode(parent) && parent.isLoaded()) {\n\t\tif (parent.baseVariantId === node.id) return true\n\t} else if (isSmartComponentNode(parent) && parent.isLoaded()) {\n\t\tif (parent.baseVariantId === node.id) return true\n\t}\n\n\treturn false\n}\n\nexport class Fuzzer {\n\tinUndoRedo = 0\n\tinMove = 0\n\tmoveSelection?: string[]\n\trecording: string[] = []\n\n\tconstructor(\n\t\tpublic engine: VekterEngine,\n\t\tpublic prefix?: string,\n\t) {}\n\n\tprobabilities = Fuzzer.getDefaultProbabilities()\n\n\tstatic getDefaultProbabilities() {\n\t\treturn {\n\t\t\tdeletePage: 0.1,\n\t\t\taddPage: 0.1,\n\t\t\tchangePage: 0.4,\n\t\t\tdeleteNode: 0.1,\n\t\t\taddNode: 0.4,\n\t\t\tmoveNode: 0.6,\n\t\t\teditNode: 1,\n\t\t}\n\t}\n\tdoMoveSelection() {\n\t\tif (!this.moveSelection) return\n\n\t\tthis.inMove += 1\n\t\tfor (const id of this.moveSelection) {\n\t\t\tconst node = this.engine.tree.get(id)\n\t\t\tif (!node || !isPinnable(node)) continue\n\n\t\t\tconst left = (node.left || 0) + Math.sin(this.inMove / 10) * 10\n\t\t\tconst top = (node.top || 0) + Math.cos(this.inMove / 10) * 10\n\t\t\tnode.set({ left, top }, this.engine.tree)\n\t\t}\n\t}\n\n\tstep() {\n\t\tthis.recording.push(\"-\")\n\n\t\tif (Math.random() < 0.1) return\n\n\t\tif (this.inUndoRedo || Math.random() < 0.01) {\n\t\t\tthis.randomUndoRedoSequence()\n\t\t} else if (this.inMove || Math.random() < 0.1) {\n\t\t\tthis.randomMoveSequence()\n\t\t} else {\n\t\t\tdo {\n\t\t\t\tthis.randomEdit()\n\t\t\t} while (Math.random() < 0.5)\n\t\t}\n\t}\n\n\trandomUndoRedoSequence() {\n\t\tconst { undoRedoManager } = this.engine.stores\n\t\tthis.inUndoRedo += 1\n\t\tif (this.inUndoRedo < 10) {\n\t\t\tif (undoRedoManager.canUndo()) {\n\t\t\t\tconst lastChange = undoRedoManager.peekUndo()\n\t\t\t\tthis.recording.push(`undo ${lastChange?.changes.map(c => c.id)}`)\n\t\t\t\tthis.engine.undo()\n\t\t\t}\n\t\t} else if (this.inUndoRedo < 20) {\n\t\t\tif (Math.random() < 0.1) {\n\t\t\t\tthis.inUndoRedo = 0\n\t\t\t} else if (undoRedoManager.canRedo()) {\n\t\t\t\tconst lastUndoneChange = undoRedoManager.peekRedo()\n\t\t\t\tthis.recording.push(`redo ${lastUndoneChange?.changes.map(c => c.id)}`)\n\t\t\t\tthis.engine.redo()\n\t\t\t}\n\t\t} else {\n\t\t\tthis.inUndoRedo = 0\n\t\t}\n\t}\n\n\tmoveSequenceSelection: string[] = []\n\trandomMoveSequence() {\n\t\tthis.inMove += 1\n\n\t\tif (this.moveSequenceSelection.length === 0) {\n\t\t\tconst firstPage = this.engine.tree.root.children.find(\n\t\t\t\tchild => child instanceof CanvasPageNode || child instanceof WebPageNode,\n\t\t\t)\n\t\t\tassert(firstPage, \"tree must contain at least a page\")\n\n\t\t\tthis.engine.stores.scopeStore.select(firstPage.id, { keepHistory: false })\n\t\t\tfor (let i = 0; i < 10; i++) {\n\t\t\t\tconst node = this.randomChildOf(firstPage)\n\t\t\t\tif (node) {\n\t\t\t\t\tthis.moveSequenceSelection.push(node.id)\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.inMove > 100) {\n\t\t\tthis.moveSequenceSelection = []\n\t\t\tthis.inMove = 0\n\t\t\treturn\n\t\t}\n\n\t\tlet atLeastOne = false\n\t\tfor (const id of this.moveSequenceSelection) {\n\t\t\tconst node = this.engine.tree.get(id)\n\t\t\tif (!node || !isPinnable(node)) continue\n\n\t\t\tatLeastOne = true\n\t\t\tconst left = (node.left || 0) + Math.sin(this.inMove / 10) * 10\n\t\t\tconst top = (node.top || 0) + Math.cos(this.inMove / 10) * 10\n\t\t\tnode.set({ left, top }, this.engine.tree)\n\t\t}\n\n\t\tif (!atLeastOne) {\n\t\t\tthis.moveSequenceSelection = []\n\t\t\tthis.inMove = 0\n\t\t\treturn\n\t\t}\n\t}\n\n\trandomEdit() {\n\t\tif (Math.random() < this.probabilities.deletePage) return this.deletePage()\n\t\tif (Math.random() < this.probabilities.addPage) return this.addPage()\n\t\tif (Math.random() < this.probabilities.changePage) return this.changePage()\n\t\tif (Math.random() < this.probabilities.deleteNode) return this.deleteNode()\n\t\tif (Math.random() < this.probabilities.addNode) return this.addNode()\n\t\tif (Math.random() < this.probabilities.moveNode) return this.moveNode()\n\t\tif (Math.random() < this.probabilities.editNode) return this.editNode()\n\t}\n\n\trandomColor(): string {\n\t\tfunction l() {\n\t\t\treturn \"0123456789abcdef\"[Math.floor(Math.random() * 16)]\n\t\t}\n\t\treturn \"#\" + l() + l() + l() + l() + l() + l()\n\t}\n\n\trandomNode(): CanvasNode | undefined {\n\t\tlet id = randomID()\n\t\tif (this.prefix) id = this.prefix + id\n\t\treturn new FrameNode({\n\t\t\tid,\n\t\t\tfillColor: this.randomColor(),\n\t\t\tleft: Math.floor(Math.random() * 2000) - 1000,\n\t\t\ttop: Math.floor(Math.random() * 2000) - 1000,\n\t\t})\n\t}\n\n\trandomChildOf(parent: CanvasNode) {\n\t\tparent = parent.draftOrCurrent()\n\t\tlet size = 0\n\t\tfor (const _ of parent.walk()) ++size\n\t\tconst target = Math.floor(Math.random() * size)\n\t\tlet counter = 0\n\t\tfor (const node of parent.descendants()) {\n\t\t\tif (counter++ < target) continue\n\t\t\tif (!this.engine.tree.has(node.id)) continue\n\t\t\tif (this.prefix && !node.id.startsWith(this.prefix)) continue\n\t\t\treturn node\n\t\t}\n\t}\n\n\trandomTarget(canBePage = false): CanvasNode | undefined {\n\t\tconst tree = this.engine.tree\n\t\tconst target = Math.floor(Math.random() * tree.size())\n\t\tlet counter = 0\n\t\tfor (const node of tree.root.walk()) {\n\t\t\tif (counter++ >= target) {\n\t\t\t\tif (!tree.has(node.id)) continue\n\t\t\t\tconst isPageNode = node instanceof CanvasPageNode || node instanceof WebPageNode\n\t\t\t\tif (node instanceof RootNode) continue\n\t\t\t\tif (node instanceof RouteSegmentRootNode) continue\n\t\t\t\tif (!canBePage && isPageNode) continue\n\t\t\t\tif (!isPageNode && this.prefix && !node.id.startsWith(this.prefix)) continue\n\t\t\t\treturn node\n\t\t\t}\n\t\t}\n\t}\n\n\tgetPages() {\n\t\tconst allPages = this.engine.stores.scopeStore.getRootScopeNodes()\n\t\tconst prefix = this.prefix\n\t\tif (prefix) return allPages.filter(node => node.id.startsWith(prefix))\n\t\treturn allPages\n\t}\n\n\tdeletePage() {\n\t\tconst allPages = this.engine.stores.scopeStore.getRootScopeNodes()\n\t\tif (allPages.length <= 1) return\n\n\t\tconst pages = this.getPages()\n\t\tif (pages.length === 0) return\n\n\t\tconst randomIndex = Math.floor(Math.random() * pages.length)\n\t\t// biome-ignore lint/style/noNonNullAssertion: bounds are checked above\n\t\tconst page = pages[randomIndex]!\n\t\tthis.recording.push(`delete page ${page.id}`)\n\t\tthis.engine.deleteNode(page.id)\n\t}\n\n\taddPage() {\n\t\tlet id = randomID()\n\t\tif (this.prefix) id = this.prefix + id\n\t\tlet homeNodeId = randomID()\n\t\tif (this.prefix) homeNodeId = this.prefix + homeNodeId\n\t\tconst page = new CanvasPageNode({ id, homeNodeId })\n\t\tconst homeNode = new FrameNode({ id: homeNodeId })\n\t\tpage.addChild(homeNode)\n\t\tthis.engine.tree.insertNode(page, this.engine.tree.root.id)\n\t\tthis.recording.push(`add page ${page.id}`)\n\t\tthis.engine.stores.scopeStore.select(page.id, { keepHistory: false })\n\t}\n\n\tchangePage() {\n\t\tconst allPages = this.engine.stores.scopeStore.getRootScopeNodes()\n\t\tif (allPages.length === 0) return false\n\t\tconst randomIndex = Math.floor(Math.random() * allPages.length)\n\t\tconst page = allPages[randomIndex]\n\t\tif (!page) return false\n\t\tthis.recording.push(`select page ${page.id}`)\n\t\tthis.engine.stores.scopeStore.select(page.id, { keepHistory: false })\n\t\treturn true\n\t}\n\n\tdeleteNode() {\n\t\tconst target = this.randomTarget()\n\t\tif (!target) return\n\t\tif (isReplicaChild(target)) return\n\t\tif (cannotDeleteNode(this.engine.tree, target)) return\n\n\t\tthis.recording.push(`delete ${target.id}`)\n\t\tthis.engine.deleteNode(target.id)\n\t}\n\n\taddNode() {\n\t\tconst parent = this.randomTarget(true)\n\t\tif (!parent) return\n\t\tif (!withChildren(parent)) return\n\t\tif (parent.originalid) return\n\t\tif (isVectorNode(parent) || isShapeContainerNode(parent)) return\n\t\tif (isCodeComponentNode(parent)) return\n\t\tif (isRoutesNode(parent)) return\n\t\tif (isRouteSegmentNode(parent)) return\n\t\tif (isRouteSegmentRootNode(parent)) return\n\n\t\tconst node = this.randomNode()\n\t\tif (!node) return\n\t\tthis.recording.push(`add ${node.id}, to: ${parent.id}`)\n\t\tthis.engine.stores.scopeStore.insertNode(node, parent.id)\n\t}\n\n\tmoveNode() {\n\t\tconst target = this.randomTarget()\n\t\tif (!target) return\n\t\tif (isReplicaChild(target)) return\n\t\tif (isVectorNode(target)) return\n\n\t\tconst parent = this.randomTarget(true)\n\t\tif (!parent) return\n\t\tif (!withChildren(parent)) return\n\t\tif (parent.originalid) return\n\t\tif (isVectorNode(parent) || isShapeContainerNode(parent)) return\n\t\tif (isCodeComponentNode(parent)) return\n\t\tif (isRoutesNode(parent)) return\n\t\tif (isRouteSegmentNode(parent)) return\n\t\tif (isRouteSegmentRootNode(parent)) return\n\t\t// cannot move target to one of its children\n\t\tif (target.some(n => n.id === parent.id)) return\n\n\t\tconst tree = this.engine.tree\n\t\tif (tree.getScopeNodeFor(target) !== tree.getScopeNodeFor(parent) && cannotDeleteNode(tree, target)) return\n\n\t\tthis.recording.push(`move ${target.id}, to: ${parent.id}, from: ${target.parentid}`)\n\t\tthis.engine.tree.move(target.id, parent.id)\n\t}\n\n\teditNode() {\n\t\tconst target = this.randomTarget()\n\t\tif (!target) return\n\t\tif (!withFill(target)) return\n\t\tthis.recording.push(`edit ${target.id}`)\n\t\ttarget.set({ fillColor: this.randomColor() })\n\t}\n\n\trunOne = () => {\n\t\tif (!this.running) return\n\n\t\tconst engine = this.engine\n\n\t\t// Check if the document isn't readonly\n\t\tif (!engine.isDocumentEditable()) {\n\t\t\tsetTimeout(this.runOne, this.interval)\n\t\t\treturn\n\t\t}\n\n\t\tengine.scheduler.enterEventHandling()\n\t\ttry {\n\t\t\t// If we are just moving stuff around do it immediately.\n\t\t\tif (this.moveSelection) {\n\t\t\t\tthis.doMoveSelection()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Ensure we are always working on a web or page scope.\n\t\t\tif (!isRootScopeNode(engine.stores.scopeStore.active)) {\n\t\t\t\tif (this.changePage()) return\n\t\t\t\tthis.addPage()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.step()\n\t\t} catch (error) {\n\t\t\tengine.scheduler.errorInEventHandler(reportableError(error))\n\t\t} finally {\n\t\t\tengine.scheduler.exitEventHandling()\n\n\t\t\tif (engine.scheduler.eventHandlingError || engine.remoteDocument?.waitingForSync()) {\n\t\t\t\tthis.running = false\n\t\t\t}\n\n\t\t\tif (this.running) {\n\t\t\t\tsetTimeout(this.runOne, this.interval)\n\t\t\t}\n\t\t}\n\t}\n\n\trunning = false\n\tinterval = 50\n\tstart(interval = 50): this {\n\t\tthis.interval = interval\n\t\tif (this.running) return this\n\n\t\tthis.running = true\n\t\tsetTimeout(this.runOne)\n\t\treturn this\n\t}\n\n\tstartMoving(ids: string[], interval = 50): this {\n\t\tthis.moveSelection = ids\n\t\treturn this.start(interval)\n\t}\n\n\tstop = (): this => {\n\t\tthis.running = false\n\t\treturn this\n\t}\n}\n\nexport function fuzz(duration = 10, prefix?: string) {\n\tconst start = Date.now()\n\tconst engine = VekterEngine.shared()\n\tconst fuzzer = new Fuzzer(engine, prefix)\n\tconst log = getLogger(\"fuzzer\")\n\n\tlog.info(`--- fuzzer starting --- for ${duration} seconds;` + (prefix ? `with id prefix '${prefix}'` : \"\"))\n\tfunction runOne() {\n\t\tif (Date.now() - start > duration * 1000) {\n\t\t\tlog.info(\"--- fuzzer done after \" + duration + \" seconds---\")\n\t\t\treturn\n\t\t}\n\n\t\tengine.scheduler.enterEventHandling()\n\t\ttry {\n\t\t\tfuzzer.step()\n\t\t} catch (error) {\n\t\t\tengine.scheduler.errorInEventHandler(reportableError(error))\n\t\t} finally {\n\t\t\tengine.scheduler.exitEventHandling()\n\t\t}\n\n\t\tif (engine.scheduler.eventHandlingError || engine.remoteDocument?.waitingForSync()) {\n\t\t\tlog.info(\"--- fuzzer stopping after error ---\")\n\t\t\treturn\n\t\t}\n\n\t\tsetTimeout(runOne, 50)\n\t}\n\tsetTimeout(runOne)\n}\n", "import { assert, assertNever, delay } from \"@framerjs/shared\"\nimport { enrichWithLogs } from \"@framerjs/shared/src/logger.ts\"\nimport * as Sentry from \"@sentry/browser\"\nimport engine from \"document/engine.ts\"\n\ntype ConnectionResult = \"ready\" | \"failed\"\n\n// Exponential backoff with full jitter: each attempt waits up to\n// min(BACKOFF_BASE_MS * 2^attempt, BACKOFF_MAX_MS) randomized in [0, that].\n// Capped so we never sleep longer than the caller's deadline ourselves.\nconst BACKOFF_BASE_MS = 1_000\nconst BACKOFF_MAX_MS = 15_000\n// Reset the attempt counter only after the socket has been healthy for this\n// long \u2014 otherwise a momentary flicker erases the backoff and the next drop\n// (a few seconds later) gets a fresh fast retry it doesn't deserve.\nconst RESET_STABLE_MS = 10_000\n\n/**\n * Deduped reconnection guard with exponential-backoff retries.\n * Resets attempt counter on successful connect so a prior outage doesn't\n * penalize the next one.\n */\nexport class ConnectionGuard {\n\tprivate pending: Promise<ConnectionResult> | null = null\n\tprivate attempts = 0\n\tprivate nextRetryAt = 0\n\t// When the socket most recently became healthy. Used to delay the\n\t// attempt-counter reset so a momentary flicker doesn't earn a fresh fast\n\t// retry on the next drop.\n\tprivate healthySince = 0\n\n\t/** Jitter source in [0, 1). Injected so tests can drive timing deterministically. */\n\tconstructor(private readonly jitter: () => number = Math.random) {}\n\n\tget isConnected(): boolean {\n\t\tconst connected =\n\t\t\t!!engine.remoteDocument?.hasRemoteConnection() &&\n\t\t\tengine.remoteDocument?.networkReady &&\n\t\t\t!engine.stores.loadingStore.busyReconnecting\n\t\tif (!connected) {\n\t\t\t// If the just-ended healthy period crossed the stability threshold,\n\t\t\t// retire the previous outage's backoff state now \u2014 nothing polled\n\t\t\t// isConnected during the idle window to do it for us.\n\t\t\tif (this.healthySince !== 0 && Date.now() - this.healthySince >= RESET_STABLE_MS) {\n\t\t\t\tthis.attempts = 0\n\t\t\t\tthis.nextRetryAt = 0\n\t\t\t}\n\t\t\tthis.healthySince = 0\n\t\t\treturn false\n\t\t}\n\t\tif (this.healthySince === 0) this.healthySince = Date.now()\n\t\tif (Date.now() - this.healthySince >= RESET_STABLE_MS && (this.attempts > 0 || this.nextRetryAt > 0)) {\n\t\t\tthis.attempts = 0\n\t\t\tthis.nextRetryAt = 0\n\t\t}\n\t\treturn true\n\t}\n\n\tasync ensureConnected(timeoutMs = 45_000): Promise<ConnectionResult> {\n\t\tassert(!engine.scheduler.hadFatalError, \"Engine scheduler had a fatal error\")\n\t\tif (this.isConnected) return \"ready\"\n\t\tif (this.pending) return this.pending\n\n\t\tSentry.addBreadcrumb({ message: \"Reconnecting\", level: \"info\" })\n\t\tthis.pending = this.reconnect(timeoutMs).finally(() => {\n\t\t\tthis.pending = null\n\t\t})\n\n\t\tvoid this.pending.then(result => {\n\t\t\tswitch (result) {\n\t\t\t\tcase \"ready\":\n\t\t\t\t\tSentry.addBreadcrumb({ message: \"Reconnected\", level: \"info\" })\n\t\t\t\t\tbreak\n\t\t\t\tcase \"failed\":\n\t\t\t\t\tSentry.addBreadcrumb({ message: \"Reconnect failed\", level: \"error\" })\n\t\t\t\t\tbreak\n\t\t\t\tdefault:\n\t\t\t\t\tassertNever(result)\n\t\t\t}\n\t\t})\n\n\t\treturn this.pending\n\t}\n\n\tasync ensureConnectedOrThrow(timeoutMs = 45_000): Promise<void> {\n\t\tconst status = await this.ensureConnected(timeoutMs)\n\n\t\tswitch (status) {\n\t\t\tcase \"ready\":\n\t\t\t\treturn\n\t\t\tcase \"failed\": {\n\t\t\t\tconst error = new Error(\"Connection failed\")\n\t\t\t\tSentry.withScope(scope => {\n\t\t\t\t\tscope.setExtras(\n\t\t\t\t\t\tenrichWithLogs({\n\t\t\t\t\t\t\thasRemoteConnection: engine.remoteDocument?.hasRemoteConnection() ?? false,\n\t\t\t\t\t\t\tnetworkReady: engine.remoteDocument?.networkReady ?? false,\n\t\t\t\t\t\t\tbusyReconnecting: engine.stores.loadingStore.busyReconnecting,\n\t\t\t\t\t\t\treconnectAttempts: this.attempts,\n\t\t\t\t\t\t\tnavigatorOnLine: navigator.onLine,\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t\tSentry.captureException(error)\n\t\t\t\t})\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tassertNever(status)\n\t\t}\n\t}\n\n\tprivate get hasSocketConnection(): boolean {\n\t\treturn !!engine.remoteDocument?.hasRemoteConnection()\n\t}\n\n\t/** Pushes the next retry far enough into the future that the backoff\n\t *  visibly delays recovery \u2014 used to QA the rate-limited path. */\n\tdebugBurnReconnectBudget(): void {\n\t\tthis.attempts = 5\n\t\tthis.nextRetryAt = Date.now() + BACKOFF_MAX_MS\n\t}\n\n\t/** Clear retry state immediately. Debug bar's \"Reset\" button. */\n\tdebugReset(): void {\n\t\tthis.attempts = 0\n\t\tthis.nextRetryAt = 0\n\t\tthis.healthySince = 0\n\t}\n\n\t/** Snapshot of the retry state for debug-bar UX. */\n\tget debugState(): { attempts: number; nextRetryInMs: number } {\n\t\treturn {\n\t\t\tattempts: this.attempts,\n\t\t\tnextRetryInMs: Math.max(0, this.nextRetryAt - Date.now()),\n\t\t}\n\t}\n\n\tprivate scheduleNextRetry(): void {\n\t\tthis.attempts += 1\n\t\tconst ceiling = Math.min(BACKOFF_BASE_MS * 2 ** (this.attempts - 1), BACKOFF_MAX_MS)\n\t\tthis.nextRetryAt = Date.now() + this.jitter() * ceiling\n\t}\n\n\tprivate async reconnect(timeoutMs: number): Promise<ConnectionResult> {\n\t\tconst deadline = Date.now() + timeoutMs\n\t\twhile (Date.now() < deadline) {\n\t\t\tif (this.isConnected) return \"ready\"\n\n\t\t\tif (!this.hasSocketConnection) {\n\t\t\t\tconst socket = engine.remoteDocument?.socket\n\t\t\t\tif (!socket) return \"failed\"\n\n\t\t\t\tif (Date.now() >= this.nextRetryAt) {\n\t\t\t\t\tthis.scheduleNextRetry()\n\t\t\t\t\tengine.remoteDocument?.prepareForReconnect()\n\t\t\t\t\tsocket.forceReconnect()\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait delay(50)\n\t\t}\n\n\t\treturn \"failed\"\n\t}\n}\n", "import type { CanvasNode } from \"../nodes/CanvasNode.ts\"\nimport type { SVGNode } from \"../nodes/SVGNode.ts\"\nimport type ShapeContainerNode from \"../nodes/ShapeContainerNode.ts\"\nimport type { VectorNode } from \"../nodes/TreeNode.ts\"\nimport { isVectorNode } from \"../nodes/TreeNode.ts\"\nimport { isSVGNode, isShapeContainerNode } from \"../nodes/utils/nodeCheck.ts\"\nimport { hasImageFill } from \"../traits/WithFill.ts\"\n\nexport function isExportableAsSVG(node: CanvasNode): node is CanvasNode & (VectorNode | ShapeContainerNode | SVGNode) {\n\tfor (const child of node.walk()) {\n\t\tif (hasImageFill(child)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn isVectorNode(node) || isShapeContainerNode(node) || isSVGNode(node)\n}\n", "import type { AnyComponentLoader } from \"@framerjs/framer-runtime\"\nimport { assert } from \"@framerjs/shared\"\nimport { Dictionary } from \"app/dictionary.ts\"\nimport { getDefaultName } from \"document/components/utils/nodes.ts\"\nimport type { CanvasNode, SVGNode, ShapeContainerNode, VectorNode } from \"document/models/CanvasTree/index.ts\"\nimport { RectangleShapeNode, TextNode, isVectorNode } from \"document/models/CanvasTree/index.ts\"\nimport {\n\tisBooleanShapeNode,\n\tisSVGNode,\n\tisShapeContainerNode,\n\tisShapeGroupNode,\n} from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { isDynamicValue } from \"document/models/CanvasTree/traits/DynamicValue.ts\"\nimport type { CombinedVariableProviderValueMap } from \"document/models/CanvasTree/traits/VariableProvider.ts\"\nimport { hasTransparentFill } from \"document/models/CanvasTree/traits/WithFill.ts\"\nimport { removeAllTokensFromNodeTree, removeTokensFromValueMap } from \"document/models/CanvasTree/utils/tokenMap.ts\"\nimport { MotionConfig } from \"framer-motion\"\nimport { Vector } from \"library/render/presentation/Vector.tsx\"\nimport { VectorGroup } from \"library/render/presentation/VectorGroup.tsx\"\nimport { RenderTarget, executeInRenderEnvironment } from \"library/render/types/RenderEnvironment.ts\"\nimport { roundedNumberString } from \"library/render/utils/roundedNumber.ts\"\nimport * as ReactDOMServer from \"react-dom/server\"\nimport { ClassDiscriminator } from \"./withClassDiscriminator.ts\"\n\nexport function exportName(componentLoader: AnyComponentLoader, node: CanvasNode): string {\n\tconst name = node.resolveValue(\"name\") || getDefaultName(componentLoader, node)\n\tconst isEmptyString = /^\\s*$/u.test(name)\n\n\tif (isEmptyString) {\n\t\tif (node instanceof TextNode) {\n\t\t\treturn Dictionary.Text\n\t\t}\n\n\t\treturn \"Layer\"\n\t}\n\n\treturn name\n}\n\nexport interface RenderNodeToSVGOptions {\n\tnode: ShapeContainerNode | VectorNode | SVGNode\n\tisDarkMode: boolean\n\tcomponentLoader: AnyComponentLoader\n\tcombinedVariableValueMap?: CombinedVariableProviderValueMap\n\trenderTarget?: RenderTarget\n\taddNames?: boolean\n}\n\nexport function commonRenderNodeToSVG({\n\tnode,\n\trenderTarget = RenderTarget.export,\n\taddNames = false,\n\tisDarkMode,\n\tcomponentLoader,\n\tcombinedVariableValueMap,\n}: RenderNodeToSVGOptions): string {\n\tif (isSVGNode(node)) {\n\t\treturn node.svg\n\t}\n\tlet topVectorNodes: VectorNode[] = []\n\tlet includeTransform = true\n\tlet shapeContainerNode: ShapeContainerNode | null = null\n\n\tif (isShapeContainerNode(node)) {\n\t\tshapeContainerNode = node\n\t\tnode.children.map(n => {\n\t\t\tif (isVectorNode(n)) {\n\t\t\t\ttopVectorNodes.push(n)\n\t\t\t}\n\t\t})\n\t} else {\n\t\tincludeTransform = false\n\t\ttopVectorNodes.push(node)\n\t}\n\n\tconst tree = node.tree()\n\tassert(tree, \"cannot render nodes to svg without a tree\")\n\ttopVectorNodes = topVectorNodes.map(n => removeAllTokensFromNodeTree(n, tree, isDarkMode))\n\t// Any default values that are tokens will be replaced with the current value.\n\tremoveTokensFromValueMap(tree, combinedVariableValueMap, isDarkMode)\n\n\tconst result = { needsXlinks: false }\n\tconst content = topVectorNodes.map(child => {\n\t\treduceVectorNodeNeedsXlinks(child, result)\n\n\t\treturn renderVectorNode(child, includeTransform, addNames, componentLoader, combinedVariableValueMap)\n\t})\n\tlet backgroundRect: React.ReactNode | null = null\n\tconst shouldRenderBackgroundRect =\n\t\tshapeContainerNode?.fillEnabled &&\n\t\tshapeContainerNode.exportIncludesBackground &&\n\t\t!hasTransparentFill(shapeContainerNode)\n\tif (shouldRenderBackgroundRect && shapeContainerNode) {\n\t\tconst { children: _, ...rawProps } = shapeContainerNode.raw({\n\t\t\t__class: ClassDiscriminator.RectangleShapeNode,\n\t\t})\n\t\tconst rectShapeNode = new RectangleShapeNode(rawProps)\n\t\treduceVectorNodeNeedsXlinks(rectShapeNode, result)\n\t\tbackgroundRect = renderVectorNode(rectShapeNode, false, false, componentLoader, combinedVariableValueMap)\n\t}\n\n\tconst svgElement = (\n\t\t<MotionConfig isStatic>\n\t\t\t<svg\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\txmlnsXlink={result.needsXlinks ? \"http://www.w3.org/1999/xlink\" : undefined}\n\t\t\t\twidth={roundedNumberString(node.width, 3)}\n\t\t\t\theight={roundedNumberString(node.height, 3)}\n\t\t\t\tfill=\"none\"\n\t\t\t\t// Inline Vectors can overflow their bounding box. To ensure the copied svg is\n\t\t\t\t// visually identical to what was copied, we have to set overflow to match the\n\t\t\t\t// canvas.\n\t\t\t\toverflow={!isShapeContainerNode(node) ? \"visible\" : undefined}\n\t\t\t>\n\t\t\t\t{shouldRenderBackgroundRect && backgroundRect}\n\t\t\t\t{content}\n\t\t\t</svg>\n\t\t</MotionConfig>\n\t)\n\tconst renderedSVG = executeInRenderEnvironment({ target: renderTarget }, () =>\n\t\tReactDOMServer.renderToStaticMarkup(svgElement),\n\t)\n\treturn renderedSVG\n}\n\nexport function sanitizedFilename(name: string): string {\n\t// change all weird whitespace into a space\n\t// all /./ or /../ or others we change in a single /\n\treturn name\n\t\t.replace(/[\\f\\n\\r\\t\\v\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]+/gu, \" \")\n\t\t.replace(/(?:\\/|^)(?:\\.+\\/)+/gmu, \"/\")\n}\n\nfunction renderVectorNode(\n\tnode: VectorNode,\n\tincludeTransform: boolean,\n\taddNames: boolean,\n\tcomponentLoader: AnyComponentLoader,\n\tcombinedVariableValueMap: CombinedVariableProviderValueMap | undefined,\n): React.ReactNode {\n\tif (isShapeGroupNode(node)) {\n\t\tconst nodeProps = node.getProps(componentLoader, combinedVariableValueMap)\n\t\treturn (\n\t\t\t// eslint-disable-next-line @eslint-react/jsx-key-before-spread -- key must come after, as `nodeProps` might contain `key`\n\t\t\t<VectorGroup {...nodeProps} key={node.id} isRootVectorNode={false} includeTransform={includeTransform}>\n\t\t\t\t{node.children.map(n => {\n\t\t\t\t\treturn renderVectorNode(n, true, addNames, componentLoader, combinedVariableValueMap)\n\t\t\t\t})}\n\t\t\t</VectorGroup>\n\t\t)\n\t} // else\n\n\tconst props = node.getProps(componentLoader, combinedVariableValueMap)\n\t// eslint-disable-next-line @eslint-react/jsx-key-before-spread -- key must come after, as `nodeProps` might contain `key`\n\treturn <Vector {...props} key={node.id} isRootVectorNode={false} includeTransform={includeTransform} />\n}\n\nfunction reduceVectorNodeNeedsXlinks(node: VectorNode, result: { needsXlinks: boolean }) {\n\tif (result.needsXlinks) {\n\t\treturn\n\t}\n\tif (isShapeGroupNode(node) || isBooleanShapeNode(node)) {\n\t\tif (node.children) {\n\t\t\tnode.children.map(child => reduceVectorNodeNeedsXlinks(child, result))\n\t\t}\n\t}\n\tif (isShapeGroupNode(node)) {\n\t\treturn\n\t}\n\tconst { strokeEnabled, strokeAlignment, strokeWidth, fillEnabled, fillType, fillImage, boxShadows } = node\n\tconst hasInsideStroke = strokeAlignment === \"inside\" && strokeEnabled && strokeEnabled && !!strokeWidth\n\tconst hasImageFill = fillEnabled && fillType === \"image\" && fillImage !== null\n\tconst hasShadows =\n\t\tboxShadows &&\n\t\t!isDynamicValue(boxShadows) &&\n\t\tboxShadows.length > 0 &&\n\t\tboxShadows.some(shadow => shadow !== undefined)\n\tif (hasInsideStroke || hasShadows || hasImageFill) {\n\t\tresult.needsXlinks = true\n\t}\n}\n", "import type { RenderNodeToSVGOptions } from \"./exportCommon.tsx\"\nimport { commonRenderNodeToSVG } from \"./exportCommon.tsx\"\n\nexport function renderNodeToSVG(options: RenderNodeToSVGOptions): ReturnType<typeof commonRenderNodeToSVG> {\n\treturn commonRenderNodeToSVG({\n\t\t...options,\n\t})\n}\n", "import { getLogger } from \"@framerjs/shared\"\nimport { CanvasTreeVersion } from \"document/models/CanvasTree/CanvasTreeVersion.ts\"\nimport type { RenderTarget } from \"library/render/types/RenderEnvironment.ts\"\nimport { ChannelController } from \"utils/rpc/ChannelController.ts\"\nimport { type RenderedUpdate, type RendererListenerInterface, sandboxInterface } from \"utils/rpc/shared/definitions.ts\"\nimport type { ChannelInterface } from \"utils/rpc/types.ts\"\nimport type { EngineStores } from \"../document/EngineStores.ts\"\nimport type { SandboxRPC } from \"./SandboxRPC.ts\"\nimport type { SandboxConfig } from \"./sandboxConfig.ts\"\n\nconst log = getLogger(\"ReadonlyPopupSandbox\")\n\n/**\n * A one-way/readonly popup sandbox that receives render data but doesn't send\n * RPC responses back to the parent. Uses window.open() to create an isolated\n * window for screenshot capture, avoiding iframe overlap issues.\n *\n * Differences from ReadonlyIFrameSandbox:\n * - Uses window.open() instead of iframe\n * - Can be positioned and sized independently\n * - No iframe stacking/overlap issues\n * - True parallel screenshots possible\n */\nexport class ReadonlyPopupSandbox implements SandboxRPC {\n\tprivate popup: Window | null = null\n\tprivate isLoaded = false\n\tprivate loadPromise: Promise<void>\n\tprivate resolveLoad!: () => void\n\tprivate rejectLoad!: (error: Error) => void\n\n\t/** Layout measurements received from the sandbox after render */\n\tprivate measurementsReceivedResolvers: Array<() => void> = []\n\n\treadonly controller: ChannelController\n\treadonly renderer: ChannelInterface<typeof sandboxInterface.channels.renderer>\n\treadonly modules: ChannelInterface<typeof sandboxInterface.channels.modules>\n\treadonly modulesRuntime: ChannelInterface<typeof sandboxInterface.channels.modulesRuntime>\n\treadonly utils: ChannelInterface<typeof sandboxInterface.channels.utils>\n\treadonly assets: ChannelInterface<typeof sandboxInterface.channels.assets>\n\treadonly controlsVisibility: ChannelInterface<typeof sandboxInterface.channels.controlsVisibility>\n\treadonly flags: ChannelInterface<typeof sandboxInterface.channels.flags>\n\n\tconstructor(\n\t\tprivate readonly renderTarget: RenderTarget,\n\t\tprivate readonly config: SandboxConfig,\n\t\tprivate readonly id: string = `popup-${Date.now()}`,\n\t) {\n\t\tthis.controller = new ChannelController(sandboxInterface)\n\n\t\t// Set up remote channels (parent \u2192 sandbox)\n\t\tthis.renderer = this.controller.getRemote(sandboxInterface.channels.renderer)\n\t\tthis.modules = this.controller.getRemote(sandboxInterface.channels.modules)\n\t\tthis.modulesRuntime = this.controller.getRemote(sandboxInterface.channels.modulesRuntime)\n\t\tthis.utils = this.controller.getRemote(sandboxInterface.channels.utils)\n\t\tthis.assets = this.controller.getRemote(sandboxInterface.channels.assets)\n\t\tthis.controlsVisibility = this.controller.getRemote(sandboxInterface.channels.controlsVisibility)\n\t\tthis.flags = this.controller.getRemote(sandboxInterface.channels.flags)\n\n\t\t// Set up local channels - capture layout measurements from sandbox\n\t\tthis.controller.setLocal(sandboxInterface.channels.rendererListener, {\n\t\t\trenderedUpdate: (update: RenderedUpdate) => {\n\t\t\t\tlog.debug(\"Received renderedUpdate with\", update.layoutMeasurements.length, \"measurements\")\n\t\t\t\t// Resolve any pending waitForMeasurements calls\n\t\t\t\tconst resolvers = this.measurementsReceivedResolvers\n\t\t\t\tthis.measurementsReceivedResolvers = []\n\t\t\t\tresolvers.forEach(resolve => resolve())\n\t\t\t},\n\t\t\theartbeat: () => {},\n\t\t\terror: () => {},\n\t\t\tmarkLoadingPerf: () => {},\n\t\t\tmarkLoadingPerfDynamic: () => {},\n\t\t})\n\t\tthis.controller.setLocal(sandboxInterface.channels.componentsStore, {\n\t\t\tupdate: () => {},\n\t\t} as never)\n\t\tthis.controller.setLocal(sandboxInterface.channels.loadedExternalModulesStore, {\n\t\t\tsignalExternalModuleLoaded: () => {},\n\t\t} as never)\n\n\t\tthis.loadPromise = new Promise((resolve, reject) => {\n\t\t\tthis.resolveLoad = resolve\n\t\t\tthis.rejectLoad = reject\n\t\t})\n\t}\n\n\t/**\n\t * Wait for the next renderedUpdate from the sandbox. Times out after 10s.\n\t */\n\twaitForMeasurements(timeoutMs = 10000): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tconst idx = this.measurementsReceivedResolvers.indexOf(wrappedResolve)\n\t\t\t\tif (idx !== -1) this.measurementsReceivedResolvers.splice(idx, 1)\n\t\t\t\treject(new Error(\"waitForMeasurements timed out\"))\n\t\t\t}, timeoutMs)\n\n\t\t\tconst wrappedResolve = () => {\n\t\t\t\tclearTimeout(timeout)\n\t\t\t\tresolve()\n\t\t\t}\n\t\t\tthis.measurementsReceivedResolvers.push(wrappedResolve)\n\t\t})\n\t}\n\n\tgetId(): string {\n\t\treturn this.id\n\t}\n\n\tgetPopupWindow(): Window | null {\n\t\treturn this.popup\n\t}\n\n\tasync mount(width = 1920, height = 1080): Promise<void> {\n\t\tif (this.popup && !this.popup.closed) return\n\n\t\tconst features = `popup=true,left=-10000,top=-10000,width=${width},height=${height}`\n\t\tthis.popup = window.open(\"about:blank\", this.id, features)\n\n\t\tif (!this.popup) {\n\t\t\tconst error = new Error(\"ReadonlyPopupSandbox: failed to open popup window (blocked?)\")\n\t\t\tthis.rejectLoad(error)\n\t\t\tthrow error\n\t\t}\n\n\t\tthis.popup.location.href = this.config.url\n\t\tawait this.connect()\n\t}\n\n\tprivate async connect(): Promise<void> {\n\t\tif (this.isLoaded) return\n\t\tif (!this.popup) {\n\t\t\tthrow new Error(\"ReadonlyPopupSandbox: no popup window\")\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.controller.connect({\n\t\t\t\ttarget: this.popup,\n\t\t\t\turl: this.config.origin,\n\t\t\t})\n\t\t\tawait this.renderer.initialize(CanvasTreeVersion, this.renderTarget)\n\t\t\tthis.isLoaded = true\n\t\t\tthis.resolveLoad()\n\t\t} catch (error) {\n\t\t\tlog.error(\"ReadonlyPopupSandbox.connect():\", error)\n\t\t\tthis.rejectLoad(error as Error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\twaitUntilLoaded(): Promise<void> {\n\t\treturn this.loadPromise\n\t}\n\n\tasync resizeTo(width: number, height: number): Promise<void> {\n\t\tif (!this.popup || this.popup.closed) return\n\t\tthis.popup.resizeTo(Math.ceil(Math.max(width, 1)), Math.ceil(Math.max(height, 1)))\n\t}\n\n\tunmount(): void {\n\t\tif (this.popup && !this.popup.closed) {\n\t\t\tthis.popup.close()\n\t\t\tlog.debug(\"ReadonlyPopupSandbox: closed\", this.id)\n\t\t}\n\t\tthis.popup = null\n\t}\n\n\t/**\n\t * No-op: SandboxRenderer calls this but local channels are already set up\n\t * as no-op stubs in the constructor.\n\t */\n\tsetLocal(\n\t\t_stores: Pick<EngineStores, \"componentsStore\" | \"loadedExternalModulesStore\">,\n\t\t_rendererListener: RendererListenerInterface,\n\t): void {\n\t\t// Already configured in constructor with no-op stubs\n\t}\n}\n", "import { readAssetUpdatesStream } from \"@framerjs/assets\"\nimport { triggerCanvasPageSelectEvent } from \"@framerjs/framer-events\"\nimport { Assets } from \"@framerjs/framer-services\"\nimport type { Logger } from \"@framerjs/shared\"\nimport { ResolvablePromise } from \"@framerjs/shared\"\nimport { FlagsUpdaterForRPC } from \"app/FlagsUpdater.ts\"\nimport { employeesOnlySettings } from \"app/employeesOnlySettings.ts\"\nimport { experiments } from \"app/experiments.ts\"\nimport type { CanvasTransform, DocumentUpdate, SandboxUpdate } from \"canvas-sandbox/CanvasSandboxMessagesIn.ts\"\nimport type { MinMaxSize, SandboxCommand, SandboxCommandInterface } from \"canvas-sandbox/SandboxCommand.ts\"\nimport { minMaxSizeEqual } from \"canvas-sandbox/SandboxCommand.ts\"\nimport { EngineChange } from \"document/EngineChanges.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport { PartialTreeSender } from \"document/models/CanvasTree/PartialTreeSender.ts\"\nimport type { ChangeTrackingCursor } from \"document/models/CanvasTree/TreeUpdater.ts\"\nimport type { MaybeNodeID, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { setLoadWasChecked } from \"document/models/CanvasTree/nodes/ScopeNode.ts\"\nimport type { LocaleId } from \"document/models/CanvasTree/traits/WithLocales.ts\"\nimport { LoadingState } from \"document/stores/LoadingStore.ts\"\nimport type { RepeatersShowingEmptyState } from \"document/stores/RepeaterStore.ts\"\nimport { isRootScopeNode } from \"document/stores/ScopeStore.ts\"\nimport type { NodeWithPlaceholders } from \"document/stores/ToolStore.ts\"\nimport type { EffectPreviewType } from \"document/utils/EffectPreviewType.ts\"\nimport type { FontPreview } from \"document/utils/FontPreviewTypes.ts\"\nimport type { Rect } from \"library/render/types/Rect.ts\"\nimport { isShallowEqual } from \"utils/isShallowEqual.ts\"\nimport { markLoadingPerf, markLoadingPerfDynamic } from \"utils/performanceTracker.ts\"\nimport type { RenderedUpdate, SandboxError, SandboxHeartbeat } from \"utils/rpc/shared/definitions.ts\"\nimport { channelToWebOrAutomation } from \"utils/serviceChannels.ts\"\nimport type { SandboxRPC } from \"./SandboxRPC.ts\"\n\n/**\n * Represents what and how document data should be rendered.\n */\nexport interface SandboxRenderState {\n\t// Render all visible nodes of a scope node\n\trenderScope?: NodeID\n\t// Render specific nodes at custom canvas coordinates\n\trenderNodes?: Record<NodeID, Rect>\n\n\t// Base coordinates (what canvas coordinates get rendered at top/left) and zoom level\n\ttransform: CanvasTransform\n\n\t// Dark mode is used by both the canvas sandbox and image exporter, where\n\t// `editor` is not provided.\n\tisDarkMode: boolean\n\n\tisPreviewActive?: boolean\n\n\t// Optional context when rendering the editor canvas\n\teditor?: {\n\t\tselection: NodeID[]\n\t\tnodeInTextEditorId?: NodeID | null\n\t\tnodesInEffectPreview?: NodeID[]\n\t\tnodesInMoveToolRootFontSize?: Record<NodeID, number>\n\t\tactiveEffect: EffectPreviewType | null\n\t\tactiveEffectIds: NodeID[] | null\n\t\tfontPreviewByNodeId?: ReadonlyMap<NodeID, FontPreview>\n\t\tactiveOverlayNodes?: ReadonlySet<NodeID>\n\t\tnodesWithPlaceholders?: NodeWithPlaceholders[] | null\n\t\trootFontSize?: number | null\n\t\toptionalSelectedCollectionItemId: NodeID | undefined\n\t\tshouldSetMinHeight: boolean\n\t\trepeatersShowingEmptyState: RepeatersShowingEmptyState\n\t}\n}\n\n/**\n * SandboxRenderer represents a single view of the document, rendered inside a provided sandbox. It takes care of the\n * standard configuration and engine hooks needed to correctly render and update content. The specific behavior of\n * each renderer is configured through the required `renderState` function and the optional event callbacks.\n */\nexport class SandboxRenderer<Sandbox extends SandboxRPC = SandboxRPC> implements SandboxCommandInterface {\n\treadonly sandbox: Sandbox\n\tprivate readonly log: Logger\n\tprivate readonly engine: VekterEngine\n\tprivate readonly wantsEngineUpdates: boolean\n\tprivate readonly wantsTreeUpdates: boolean\n\tprivate readonly renderState: () => SandboxRenderState\n\n\tprivate partialTreeSender?: PartialTreeSender\n\tprivate timelineCursor?: ChangeTrackingCursor\n\n\t// Chunk draining state\n\tprivate chunkAbortController?: AbortController\n\tprivate chunkSessionId?: string\n\tprivate drainingPromise?: Promise<void>\n\n\t/**\n\t * @param sandbox A sandbox with an entrypoint presumed to be running CanvasSandboxApp.\n\t * @param init Required initial configuration for content rendering.\n\t */\n\tconstructor(\n\t\tsandbox: Sandbox,\n\t\tinit: {\n\t\t\tlog: Logger\n\t\t\tengine: VekterEngine\n\t\t\twantsEngineUpdates: boolean\n\t\t\twantsTreeUpdates?: boolean\n\t\t\thandleSandboxError?: (error: SandboxError) => void\n\t\t\theartbeat?: (heartbeat: SandboxHeartbeat) => void\n\t\t\trenderState: () => SandboxRenderState\n\t\t},\n\t) {\n\t\tthis.sandbox = sandbox\n\t\tthis.log = init.log\n\t\tthis.engine = init.engine\n\t\tthis.wantsEngineUpdates = init.wantsEngineUpdates\n\t\tthis.wantsTreeUpdates = init.wantsTreeUpdates ?? true\n\t\tthis.renderState = init.renderState\n\n\t\tsandbox.setLocal(init.engine.stores, {\n\t\t\trenderedUpdate: this.onRenderedUpdate,\n\t\t\terror: init.handleSandboxError ?? (() => {}),\n\t\t\theartbeat: init.heartbeat ?? (() => {}),\n\t\t\tmarkLoadingPerf,\n\t\t\tmarkLoadingPerfDynamic: (name, label) => markLoadingPerfDynamic(name, label),\n\t\t})\n\n\t\tsandbox.controller\n\t\t\t.waitUntilConnected()\n\t\t\t.then(this.onConnect)\n\t\t\t.catch(error => {\n\t\t\t\tthis.log.error(\"Failed to load sandbox:\", error)\n\t\t\t})\n\t}\n\n\t/** Called when the sandbox is ready to render. */\n\tonSandboxReady?: () => void\n\n\t/** Handle sandbox state changes (loading, loaded, failed to load). */\n\tonSandboxStateChange?: (state: LoadingState) => void = state => {\n\t\tconst failure = state.failure\n\t\tif (failure) {\n\t\t\tthis.log.reportError(failure)\n\t\t}\n\t}\n\n\t/** Handle updates that the sandbox has rendered. */\n\tonSandboxRender?: (_: RenderedUpdate) => void\n\n\t/** Puts the sandbox into an error state. */\n\tfail = (error: Error) => {\n\t\t// Cancel any ongoing chunk draining\n\t\tthis.chunkAbortController?.abort()\n\n\t\tthis.readyForRenderingPromise.reject(error)\n\t\tthis.onSandboxStateChange?.(LoadingState.failed(error))\n\t}\n\n\tprivate readyForRenderingPromise = new ResolvablePromise<void>()\n\n\tasync waitForReadyForRendering() {\n\t\tawait this.readyForRenderingPromise\n\t}\n\n\tprivate lastSandboxTreeUpdate = 0\n\n\tonRenderedUpdate = (update: RenderedUpdate): void => {\n\t\t// Verify the sandbox is receiving the tree we have sent it.\n\t\t// Note: this can fail while debugging! It seems that postMessages sent to a frame\n\t\t// that is paused in the debugger will be silently dropped!\n\t\tif (this.lastSandboxTreeUpdate) {\n\t\t\tif (this.lastSandboxTreeUpdate < update.update) {\n\t\t\t\tthis.fail(new Error(`dropped tree update: ${this.lastSandboxTreeUpdate} < ${update.update}`))\n\t\t\t\tthis.lastSandboxTreeUpdate = 0\n\t\t\t} else if (this.lastSandboxTreeUpdate === update.update) {\n\t\t\t\tthis.lastSandboxTreeUpdate = 0\n\t\t\t}\n\t\t}\n\n\t\tif (this.onSandboxRender) {\n\t\t\tthis.onSandboxRender(update)\n\t\t\t// After onSandboxRender, any dom measurements will have updated ground node caches.\n\t\t\tthis.updateGroundNodeOverflowSizes()\n\t\t}\n\n\t\t// Track scope switches events\n\t\tconst { scopeId, scopeSwitchStartTime, renderEndTime, updateEndTime } = update\n\t\tif (scopeSwitchStartTime && updateEndTime && renderEndTime) {\n\t\t\tconst updateDurationMs = Math.round(updateEndTime - scopeSwitchStartTime)\n\t\t\tconst renderDurationMs = Math.round(renderEndTime - scopeSwitchStartTime)\n\t\t\tconst { scopeSwitchStart, scopeSwitchPending, activeId } = this.engine.stores.scopeStore\n\t\t\tlet totalDurationMs = renderDurationMs\n\t\t\tlet neededLoading = false\n\t\t\tif (activeId === scopeId) {\n\t\t\t\ttotalDurationMs = performance.now() - scopeSwitchStart\n\t\t\t\tneededLoading = scopeSwitchPending\n\t\t\t}\n\n\t\t\tconst node = this.engine.tree.get(scopeId)\n\t\t\tif (node && isRootScopeNode(node)) {\n\t\t\t\ttriggerCanvasPageSelectEvent({\n\t\t\t\t\tpageId: scopeId,\n\t\t\t\t\trenderDurationMs: Math.round(renderDurationMs),\n\t\t\t\t\tupdateDurationMs: Math.round(updateDurationMs),\n\t\t\t\t\ttotalDurationMs: Math.round(totalDurationMs),\n\t\t\t\t\tneededLoading,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// Wait for a done state, and for no more isLoadingModules state, like external modules.\n\t\tconst modulesRuntimeDone = update.moduleRuntimePhase === \"LazyDone\" || update.moduleRuntimePhase === \"EagerDone\"\n\t\tif (modulesRuntimeDone && !update.isLoadingModules) {\n\t\t\tthis.setFirstModulesRuntimeDone()\n\t\t}\n\t}\n\n\tprivate onConnect = async () => {\n\t\t// Provide flags\n\t\tnew FlagsUpdaterForRPC(this.sandbox.flags, this.engine.eventListenerAbortController.signal)\n\n\t\t// Provide modules\n\t\tthis.engine.stores.modulesStore\n\t\t\t.getModulesUpdatesService()\n\t\t\t.moduleUpdatesStream({ replay: \"latest\" })\n\t\t\t.read(update =>\n\t\t\t\tthis.sandbox.modules.updateModules(\n\t\t\t\t\tupdate.patches,\n\t\t\t\t\tupdate.prioritizedModules,\n\t\t\t\t\tupdate.dependentModules,\n\t\t\t\t\tupdate.initialized,\n\t\t\t\t\tupdate.revision,\n\t\t\t\t),\n\t\t\t)\n\t\t\t.catch(this.fail)\n\n\t\t// Provide assets\n\t\treadAssetUpdatesStream(\n\t\t\tAssets.on(channelToWebOrAutomation).discover(),\n\t\t\tasync (event: Assets.AssetUpdateEvent) => {\n\t\t\t\tif (event.assets) {\n\t\t\t\t\tthis.sandbox.assets.oneway.updateAssets(event.assets)\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.engine.eventListenerAbortController.signal,\n\t\t)\n\n\t\t// Start rendering document data\n\t\tif (this.wantsEngineUpdates) {\n\t\t\tthis.engine.addSandbox(this)\n\t\t\tthis.engine.scheduler.changes.observe(EngineChange.PendingBundle, () => this.update(true))\n\t\t\tif (this.engine.loadWasCalled) {\n\t\t\t\tthis.update(true)\n\t\t\t}\n\t\t}\n\n\t\t// Good to go\n\t\tthis.log.debug(\"Initialized render sandbox\")\n\t\tthis.onSandboxReady?.()\n\t\tthis.onSandboxStateChange?.(LoadingState.loaded)\n\t\tthis.readyForRenderingPromise.resolve()\n\t}\n\n\tsendSandboxUpdate(document?: DocumentUpdate, transform?: CanvasTransform): boolean {\n\t\tif (document || transform) {\n\t\t\tconst { scheduler } = this.engine\n\t\t\tif (document?.tree) {\n\t\t\t\tthis.lastSandboxTreeUpdate = scheduler.update\n\t\t\t}\n\t\t\tif (document) {\n\t\t\t\tdocument.timestamp = Date.now()\n\t\t\t}\n\t\t\tconst message: SandboxUpdate = { type: \"SandboxUpdate\", update: scheduler.update, document, transform }\n\t\t\tthis.sandbox.renderer.oneway.updateSandbox(message)\n\t\t\treturn true\n\t\t}\n\n\t\treturn false\n\t}\n\n\tcommand(command: SandboxCommand[\"command\"], args: SandboxCommand[\"args\"]): void {\n\t\tthis.sandbox.renderer.oneway.updateSandbox({ command, args } as SandboxCommand)\n\t}\n\n\tprivate previousTransform?: CanvasTransform\n\n\tprivate previousActiveLocaleId?: LocaleId\n\tprivate previousIsReadyToRender?: boolean\n\tprivate previousPerformanceMode?: boolean\n\tprivate previousLoadedAllUserData?: boolean\n\n\tprivate previousRenderScope?: NodeID\n\tprivate previousRenderNodes?: Record<NodeID, Rect>\n\tprivate previousSelection?: NodeID[]\n\tprivate previousNodeInTextEditorId?: MaybeNodeID\n\tprivate previousNodeInEffectPreview?: NodeID[]\n\tprivate previousActiveEffect?: EffectPreviewType | null\n\tprivate previousActiveEffectIds?: NodeID[] | null\n\tprivate previousFontPreviewByNodeId?: ReadonlyMap<NodeID, FontPreview>\n\tprivate previousNodesInMoveToolRootFontSize?: Record<NodeID, number>\n\tprivate previousActiveOverlays?: ReadonlySet<NodeID>\n\tprivate previousNodesWithPlaceholders?: NodeWithPlaceholders[] | null\n\tprivate previousRootFontSize?: number | null\n\tprivate previousIsDarkMode?: boolean\n\tprivate previousOptionalSelectedCollectionItemId: NodeID | undefined\n\tprivate previousShouldSetMinHeight?: boolean\n\tprivate previousRepeatersShowingEmptyState?: RepeatersShowingEmptyState\n\tprivate previousIsPreviewActive?: boolean\n\n\tprivate firstModulesRuntimeDone = false\n\tprivate settingFirstModulesRuntimeDone = false\n\n\tsetFirstModulesRuntimeDone() {\n\t\t// Set the flag only once.\n\t\tif (this.settingFirstModulesRuntimeDone) return\n\n\t\t// Set the flag after a delay. So the sandbox actually becomes idle and has time to render.\n\t\t// It also gives the main UI some time to render. And vekter some time to settle. Before we\n\t\t// start evaluating all modules and sending back all that component loader data.\n\t\tconst DELAY_SETTING_FIRST_MODULES_RUNTIME_DONE_MS = 2_000\n\n\t\tthis.settingFirstModulesRuntimeDone = true\n\t\tconst timer = setTimeout(() => {\n\t\t\tthis.firstModulesRuntimeDone = true\n\t\t\tthis.update(true)\n\t\t}, DELAY_SETTING_FIRST_MODULES_RUNTIME_DONE_MS)\n\n\t\t// Clear the timeout if the engine is aborted.\n\t\tthis.engine.eventListenerAbortController.signal.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => {\n\t\t\t\tclearTimeout(timer)\n\t\t\t},\n\t\t\t{ once: true },\n\t\t)\n\t}\n\n\tupdate = (interactive: boolean = true): boolean => {\n\t\t// Block all updates while chunking is in progress to make chunking atomic\n\t\tif (this.drainingPromise) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst renderState = this.renderState()\n\n\t\t// Content transform\n\t\tconst transform: CanvasTransform = renderState.transform\n\t\tlet hasTransformUpdate = !isShallowEqual(transform, this.previousTransform)\n\t\tthis.previousTransform = transform\n\n\t\t// While zooming/panning live, we only transform the canvas and send no other kinds of updates.\n\t\tif (!interactive) {\n\t\t\treturn this.sendSandboxUpdate(undefined, hasTransformUpdate ? transform : undefined)\n\t\t}\n\n\t\t// Not live. See if we need to send data/state updates.\n\t\tlet hasDocumentUpdate = false\n\t\tconst document: DocumentUpdate = {}\n\n\t\t// Document data for the rendered content\n\t\tconst { treeStore, loadingStore, chromeStore, persistedUserDefaults } = this.engine.stores\n\t\tconst timeline = treeStore.timeline\n\n\t\t// What should be rendered?\n\t\tconst renderScope = \"renderScope\" in renderState ? renderState.renderScope : undefined\n\t\tif (renderScope !== this.previousRenderScope) {\n\t\t\tthis.previousRenderScope = renderScope\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.renderScope = renderScope\n\t\t}\n\n\t\tif (!this.previousRenderScope) {\n\t\t\tthis.previousRenderScope = timeline.tree.root.children.at(0)?.id ?? \"\"\n\t\t}\n\n\t\t// We dynamically switch to and from a sliced tree sender.\n\t\tconst supportsPartialTrees = !employeesOnlySettings.isOn(\"disablePartialTreeInSandbox\")\n\t\tif (!this.partialTreeSender && supportsPartialTrees) {\n\t\t\tthis.partialTreeSender = new PartialTreeSender(timeline, \"sandbox\")\n\t\t\tthis.timelineCursor = undefined\n\t\t} else if (this.partialTreeSender && !supportsPartialTrees) {\n\t\t\tthis.partialTreeSender = undefined\n\t\t}\n\n\t\tif (this.partialTreeSender) {\n\t\t\ttimeline.legacyMode = false\n\t\t\t// Update the tree on the sandbox side via the scope filter, it will either send a new tree,\n\t\t\t// or will update it via changes.\n\t\t\tconst slicedUpdate = this.partialTreeSender.update(this.previousRenderScope)\n\t\t\tif (this.wantsTreeUpdates) {\n\t\t\t\tdocument.partialTreeUpdate = slicedUpdate\n\t\t\t}\n\t\t\tif (slicedUpdate.tree) {\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\thasTransformUpdate = true\n\t\t\t\tdocument.loadedSomeUserData = loadingStore.isDocumentLoaded\n\t\t\t} else if (slicedUpdate.changes || slicedUpdate.scopes) {\n\t\t\t\thasDocumentUpdate = true\n\t\t\t} else if (slicedUpdate.treeChunks) {\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\t// Only set loading flags when chunking is complete (no more chunks)\n\t\t\t\tif (!this.partialTreeSender.hasMoreChunks()) {\n\t\t\t\t\tdocument.loadedSomeUserData = loadingStore.isDocumentLoaded\n\t\t\t\t\thasTransformUpdate = true\n\t\t\t\t} else {\n\t\t\t\t\t// Start async chunk draining (fire-and-forget)\n\t\t\t\t\tvoid this.drainChunksAsync()\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst changes = timeline.fetchForwardChanges(this.timelineCursor)\n\t\t\ttimeline.legacyMode = true\n\t\t\tif (!changes) {\n\t\t\t\t// If we don't have a cursor yet, or it became out of date, changes\n\t\t\t\t// are undefined. We then have to (re)start by getting a new cursor\n\t\t\t\t// and sending the current tree.\n\t\t\t\tthis.timelineCursor = timeline.getChangeTrackingCursor()\n\t\t\t\tthis.log.debug(\"change tracking cursor invalidated, sending full tree:\", timeline.tree.size())\n\t\t\t\ttimeline.tree.beginAllowPartialScopeAccess()\n\t\t\t\tif (this.wantsTreeUpdates) {\n\t\t\t\t\tdocument.tree = timeline.tree.toJS()\n\t\t\t\t}\n\t\t\t\ttimeline.tree.endAllowPartialScopeAccess()\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\thasTransformUpdate = true // Also send a transform in this case.\n\t\t\t\t// The tree might be a temporary, empty one if the document is still\n\t\t\t\t// loading, so we also send the loadedSomeUserData flag, so that we only\n\t\t\t\t// kick in CanvasResourceLoader when the tree reflects the document.\n\t\t\t\tdocument.loadedSomeUserData = loadingStore.isDocumentLoaded\n\t\t\t} else {\n\t\t\t\tthis.log.trace(\"change tracking cursor changes:\", changes.length)\n\t\t\t\tif (changes.length > 0) {\n\t\t\t\t\tif (this.wantsTreeUpdates) {\n\t\t\t\t\t\tdocument.changes = changes\n\t\t\t\t\t}\n\t\t\t\t\thasDocumentUpdate = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst neverLoadRest =\n\t\t\texperiments.isOn(\"debugEditWhileNeverLoadingRest\") ||\n\t\t\t(experiments.isOn(\"dataOnlyTree\") && treeStore.mode === \"crdt\")\n\t\tconst finishedFirstLoading = neverLoadRest ? loadingStore.hasMinimalEditableData : loadingStore.hasFullDocumentData\n\n\t\tif (!this.previousLoadedAllUserData && finishedFirstLoading && this.firstModulesRuntimeDone) {\n\t\t\tthis.previousLoadedAllUserData = true\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.loadedAllUserData = true\n\t\t}\n\n\t\tconst activeLocaleId = chromeStore.canvasLocaleId\n\t\tif (activeLocaleId !== this.previousActiveLocaleId) {\n\t\t\tthis.previousActiveLocaleId = activeLocaleId\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.activeLocaleId = activeLocaleId\n\t\t}\n\n\t\t// Should the content be rendered already?\n\t\tconst isReadyToRender = loadingStore.assetMapLoaded\n\t\tif (isReadyToRender !== this.previousIsReadyToRender) {\n\t\t\tthis.previousIsReadyToRender = isReadyToRender\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.isReadyToRender = isReadyToRender\n\t\t}\n\n\t\tconst performanceMode = persistedUserDefaults.performanceMode\n\t\tif (performanceMode !== this.previousPerformanceMode) {\n\t\t\tthis.previousPerformanceMode = performanceMode\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.performanceMode = performanceMode\n\t\t}\n\n\t\tconst renderNodes = \"renderNodes\" in renderState ? renderState.renderNodes : undefined\n\t\tif (!isShallowEqual(renderNodes, this.previousRenderNodes)) {\n\t\t\tthis.previousRenderNodes = renderNodes\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.renderNodes = renderNodes\n\t\t}\n\n\t\tconst isDarkMode = \"isDarkMode\" in renderState ? renderState.isDarkMode : undefined\n\t\tif (isDarkMode !== this.previousIsDarkMode) {\n\t\t\tthis.previousIsDarkMode = isDarkMode\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.isDarkMode = isDarkMode\n\t\t}\n\n\t\tconst isPreviewActive = renderState.isPreviewActive ?? false\n\t\tif (isPreviewActive !== this.previousIsPreviewActive) {\n\t\t\tthis.previousIsPreviewActive = isPreviewActive\n\t\t\thasDocumentUpdate = true\n\t\t\tdocument.isPreviewActive = isPreviewActive\n\t\t}\n\n\t\t// Additional rendering options\n\t\t{\n\t\t\tconst editorState = renderState.editor\n\n\t\t\tconst selection = editorState?.selection\n\t\t\tif (selection !== this.previousSelection) {\n\t\t\t\tthis.previousSelection = selection\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.selection = selection\n\t\t\t}\n\n\t\t\tconst nodeInTextEditorId = editorState?.nodeInTextEditorId\n\t\t\tif (nodeInTextEditorId !== this.previousNodeInTextEditorId) {\n\t\t\t\tthis.previousNodeInTextEditorId = nodeInTextEditorId\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.nodeInTextEditorId = nodeInTextEditorId\n\t\t\t}\n\n\t\t\tconst nodesInEffectPreview = editorState?.nodesInEffectPreview\n\t\t\tif (!isShallowEqual(nodesInEffectPreview, this.previousNodeInEffectPreview)) {\n\t\t\t\tthis.previousNodeInEffectPreview = nodesInEffectPreview\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.nodesInEffectPreview = nodesInEffectPreview\n\t\t\t}\n\n\t\t\tconst nodesInMoveToolBaseFontSize = editorState?.nodesInMoveToolRootFontSize\n\t\t\tif (!isShallowEqual(nodesInMoveToolBaseFontSize, this.previousNodesInMoveToolRootFontSize)) {\n\t\t\t\tthis.previousNodesInMoveToolRootFontSize = nodesInMoveToolBaseFontSize\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.nodesInMoveToolBaseFontSize = nodesInMoveToolBaseFontSize\n\t\t\t}\n\n\t\t\tconst activeEffect = editorState?.activeEffect\n\t\t\tif (activeEffect !== this.previousActiveEffect) {\n\t\t\t\tthis.previousActiveEffect = activeEffect\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.activeEffect = activeEffect\n\t\t\t}\n\n\t\t\tconst activeEffectIds = editorState?.activeEffectIds\n\t\t\tif (!isShallowEqual(activeEffectIds, this.previousActiveEffectIds)) {\n\t\t\t\tthis.previousActiveEffectIds = activeEffectIds\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.activeEffectIds = activeEffectIds ? new Set(activeEffectIds) : null\n\t\t\t}\n\n\t\t\tconst fontPreviewByNodeId = editorState?.fontPreviewByNodeId\n\t\t\tif (fontPreviewByNodeId !== this.previousFontPreviewByNodeId) {\n\t\t\t\tthis.previousFontPreviewByNodeId = fontPreviewByNodeId\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.fontPreviewByNodeId = fontPreviewByNodeId\n\t\t\t}\n\n\t\t\tconst activeOverlayNodes = editorState?.activeOverlayNodes\n\t\t\tif (activeOverlayNodes !== this.previousActiveOverlays) {\n\t\t\t\tthis.previousActiveOverlays = activeOverlayNodes\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.activeOverlayNodes = activeOverlayNodes\n\t\t\t}\n\n\t\t\tconst nodesWithPlaceholders = editorState?.nodesWithPlaceholders\n\t\t\tif (nodesWithPlaceholders !== this.previousNodesWithPlaceholders) {\n\t\t\t\tthis.previousNodesWithPlaceholders = nodesWithPlaceholders\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.nodesWithPlaceholders = nodesWithPlaceholders\n\t\t\t}\n\n\t\t\tconst rootFontSize = editorState?.rootFontSize\n\t\t\tif (rootFontSize !== this.previousRootFontSize) {\n\t\t\t\tthis.previousRootFontSize = rootFontSize\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.rootFontSize = rootFontSize\n\t\t\t}\n\n\t\t\tconst optionalSelectedCollectionItemId = editorState?.optionalSelectedCollectionItemId\n\t\t\tif (optionalSelectedCollectionItemId !== this.previousOptionalSelectedCollectionItemId) {\n\t\t\t\tthis.previousOptionalSelectedCollectionItemId = optionalSelectedCollectionItemId\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.optionalSelectedCollectionItemId = optionalSelectedCollectionItemId\n\n\t\t\t\t// If the scope is the same but collection item id changed in the same scope\n\t\t\t\t// we need to send the scope to the document anyways so it sets the cache of the collection item\n\t\t\t\t// correctly in the scope. Because on exporting we send render nodes as well, the scope id in CanvasSandboxApp\n\t\t\t\t// is not stored.\n\t\t\t\tif (renderScope && renderScope === this.previousRenderScope) {\n\t\t\t\t\tdocument.renderScope = renderScope\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst shouldSetMinHeight = editorState?.shouldSetMinHeight\n\t\t\tif (shouldSetMinHeight !== this.previousShouldSetMinHeight) {\n\t\t\t\tthis.previousShouldSetMinHeight = shouldSetMinHeight\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.shouldSetMinHeight = shouldSetMinHeight\n\t\t\t}\n\n\t\t\tconst repeatersShowingEmptyState = editorState?.repeatersShowingEmptyState\n\t\t\tconst previousRepeatersShowingEmptyState = this.previousRepeatersShowingEmptyState\n\t\t\tconst repeaterModesChanged = !isShallowEqual(repeatersShowingEmptyState, previousRepeatersShowingEmptyState)\n\t\t\tif (repeaterModesChanged) {\n\t\t\t\tthis.previousRepeatersShowingEmptyState = repeatersShowingEmptyState\n\t\t\t\thasDocumentUpdate = true\n\t\t\t\tdocument.repeatersShowingEmptyState = repeatersShowingEmptyState\n\t\t\t}\n\t\t}\n\n\t\treturn this.sendSandboxUpdate(hasDocumentUpdate ? document : undefined, hasTransformUpdate ? transform : undefined)\n\t}\n\n\tprivate async drainChunksAsync(): Promise<void> {\n\t\t// Return existing promise if already draining\n\t\tif (this.drainingPromise) {\n\t\t\treturn this.drainingPromise\n\t\t}\n\n\t\t// Create a promise lock to prevent concurrent draining\n\t\tthis.drainingPromise = this._performDraining()\n\n\t\ttry {\n\t\t\tawait this.drainingPromise\n\t\t} finally {\n\t\t\tthis.drainingPromise = undefined\n\t\t}\n\t}\n\n\tprivate async _performDraining(): Promise<void> {\n\t\t// Cancel any existing draining operation and create new controller\n\t\tthis.chunkAbortController?.abort()\n\t\tthis.chunkAbortController = new AbortController()\n\n\t\tconst sessionId = crypto.randomUUID()\n\t\tthis.chunkSessionId = sessionId\n\t\tconst signal = this.chunkAbortController.signal\n\t\tconst scopeAtStart = this.previousRenderScope\n\n\t\ttry {\n\t\t\tif (!this.partialTreeSender) return\n\n\t\t\tfor await (const chunk of this.partialTreeSender.drainChunks(signal)) {\n\t\t\t\t// Check if cancelled\n\t\t\t\tif (signal.aborted) break\n\n\t\t\t\t// Check if this session is still valid\n\t\t\t\tif (this.chunkSessionId !== sessionId) break\n\n\t\t\t\t// Check if scope changed during draining\n\t\t\t\tif (this.previousRenderScope !== scopeAtStart) break\n\n\t\t\t\tconst document: DocumentUpdate = {\n\t\t\t\t\tpartialTreeUpdate: chunk,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t}\n\n\t\t\t\t// Check if this is the last chunk\n\t\t\t\tif (!this.partialTreeSender.hasMoreChunks()) {\n\t\t\t\t\tdocument.loadedSomeUserData = this.engine.stores.loadingStore.isDocumentLoaded\n\t\t\t\t\tthis.sendSandboxUpdate(document, this.previousTransform)\n\t\t\t\t} else {\n\t\t\t\t\tthis.sendSandboxUpdate(document, undefined)\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.update(true)\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\t\t\t// Cancellation is expected, don't log as error\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// Re-throw unexpected errors\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tthis.log.debug(\"Chunk draining completed or aborted\")\n\t\t\t// Clean up if this was the active session\n\t\t\tif (this.chunkSessionId === sessionId) {\n\t\t\t\tthis.chunkAbortController = undefined\n\t\t\t\tthis.chunkSessionId = undefined\n\t\t\t}\n\t\t}\n\t}\n\n\tgroundNodeOverflowSizes: Record<string, MinMaxSize> = {}\n\tupdateGroundNodeOverflowSizes() {\n\t\tconst scope = this.engine.tree.get(this.previousRenderScope)\n\t\tsetLoadWasChecked(scope)\n\t\tconst groundNodes = scope?.children\n\t\tif (!groundNodes) return\n\n\t\tlet didChange = false\n\n\t\t// Update any ground node overflow size.\n\t\tfor (const node of groundNodes) {\n\t\t\tconst boundingBox = node.cache\n\t\t\tconst size = this.groundNodeOverflowSizes[node.id]\n\t\t\tif (!minMaxSizeEqual(boundingBox, size)) {\n\t\t\t\tdidChange = true\n\t\t\t\tthis.groundNodeOverflowSizes[node.id] = {\n\t\t\t\t\tminX: boundingBox.minX,\n\t\t\t\t\tmaxX: boundingBox.maxX,\n\t\t\t\t\tminY: boundingBox.minY,\n\t\t\t\t\tmaxY: boundingBox.maxY,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Delete any ground node that was tracked but is no longer a ground node.\n\t\tconst keys = Object.keys(this.groundNodeOverflowSizes)\n\t\tif (keys.length > groundNodes.length) {\n\t\t\tdidChange = true\n\t\t\tconst toRemove = new Set(keys)\n\t\t\tfor (const node of groundNodes) {\n\t\t\t\ttoRemove.delete(node.id)\n\t\t\t}\n\t\t\tfor (const id of toRemove) {\n\t\t\t\tdelete this.groundNodeOverflowSizes[id]\n\t\t\t}\n\t\t}\n\n\t\t// Send an update if there was a change.\n\t\tif (!didChange) return\n\t\tthis.command(\"updateGroundNodeOverflowSizes\", this.groundNodeOverflowSizes)\n\t}\n\n\t/**\n\t * Renders any state changes triggered in the `updates` handler.\n\t * Returns once the sandbox completely reflects the changes (i.e. images and fonts loaded).\n\t */\n\tasync renderUpdates(updates: () => void): Promise<void> {\n\t\tawait this.waitForReadyForRendering()\n\t\tawait this.sandbox.renderer.willStartUpdates()\n\t\tupdates()\n\t\tthis.update()\n\t\tawait this.sandbox.renderer.waitForCompleteRenderAfterUpdates()\n\t}\n}\n", "import { getLogger } from \"@framerjs/shared\"\nimport { ReadonlyPopupSandbox } from \"canvas-sandbox-renderer/ReadonlyPopupSandbox.ts\"\nimport { type SandboxRenderState, SandboxRenderer } from \"canvas-sandbox-renderer/SandboxRenderer.ts\"\nimport { sandboxConfig } from \"canvas-sandbox-renderer/sandboxConfig.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { WebPageNode } from \"document/models/CanvasTree/nodes/WebPageNode.ts\"\nimport { isWebPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { getRootFontSize } from \"document/models/CanvasTree/traits/utils/rootFontSizeHelpers.ts\"\nimport type { Rect } from \"library/render/types/Rect.ts\"\nimport { RenderTarget } from \"library/render/types/RenderEnvironment.ts\"\n\nconst log = getLogger(\"ScreenshotSandbox\")\n\ninterface ScreenshotPrepareOptions {\n\treadonly nodeId: string\n\treadonly zoom?: number\n\treadonly pixelRatio?: number\n}\n\nexport interface ScreenshotPrepareResult {\n\t/** Unique popup ID for Playwright to find the window */\n\tpopupId: string\n\t/** Final rect for screenshot (target node at zoom, positioned at origin) */\n\trect: Rect\n\tready: boolean\n\t/** The actual node ID rendered (may differ from input if WebPageNode was resolved to variant) */\n\trenderedNodeId: string\n\t/** True if the original node was a WebPageNode (page-level screenshot) */\n\tisPageScreenshot: boolean\n}\n\n/**\n * ScreenshotSandbox provides a dedicated popup window for rendering nodes for screenshot capture.\n * Uses ReadonlyPopupSandbox, which is one-way (receives data but doesn't send RPC responses),\n * allowing multiple popup sandboxes without conflicting with the main canvas.\n *\n * Popup windows avoid iframe overlap issues and enable true parallel screenshots.\n */\nexport class ScreenshotSandbox {\n\tprivate engine: VekterEngine\n\tprivate renderer: SandboxRenderer<ReadonlyPopupSandbox>\n\tprivate sandbox: ReadonlyPopupSandbox\n\tprivate renderState: SandboxRenderState = { renderNodes: {}, transform: [0, 0, 1], isDarkMode: false }\n\tprivate mounted = false\n\n\tconstructor(engine: VekterEngine, id?: string) {\n\t\tthis.engine = engine\n\t\tthis.sandbox = new ReadonlyPopupSandbox(RenderTarget.export, sandboxConfig.canvas, id)\n\n\t\tthis.renderer = new SandboxRenderer(this.sandbox, {\n\t\t\tlog: log.extend(\"renderer\"),\n\t\t\tengine: this.engine,\n\t\t\twantsEngineUpdates: true,\n\t\t\trenderState: () => this.renderState,\n\t\t})\n\t}\n\n\t/**\n\t * Mount the screenshot sandbox popup window.\n\t */\n\tasync mount(width = 800, height = 600): Promise<void> {\n\t\tif (this.mounted) return\n\n\t\tawait this.sandbox.mount(width, height)\n\t\tthis.mounted = true\n\t}\n\n\t/**\n\t * Get the popup window for Playwright to capture.\n\t */\n\tgetPopupWindow(): Window | null {\n\t\treturn this.sandbox.getPopupWindow()\n\t}\n\n\t/**\n\t * Prepare a node for screenshot capture.\n\t * Renders the ground node and offsets it so target node appears at origin.\n\t * Uses two-phase rendering: first to get measurements, then to position correctly.\n\t */\n\tasync prepareScreenshot(options: ScreenshotPrepareOptions): Promise<ScreenshotPrepareResult> {\n\t\tconst { nodeId, zoom = 1, pixelRatio = 1 } = options\n\t\tconst tree = this.engine.tree\n\t\tlet node = tree.getNode(nodeId)\n\t\tif (!node) {\n\t\t\tthrow new Error(`Node ${nodeId} doesn't exist`)\n\t\t}\n\n\t\t// WebPageNode isn't exportable directly - use its primary breakpoint variant\n\t\tlet isPageScreenshot = false\n\t\tif (isWebPageNode(node, true)) {\n\t\t\tisPageScreenshot = true\n\t\t\tconst variantId = (node as WebPageNode).baseVariantId\n\t\t\tconst variantNode = tree.getNode(variantId)\n\t\t\tif (!variantNode) {\n\t\t\t\tthrow new Error(`Primary variant ${variantId} for WebPageNode ${nodeId} doesn't exist`)\n\t\t\t}\n\t\t\tnode = variantNode\n\t\t}\n\n\t\tconst effectiveZoom = pixelRatio !== 1 ? zoom * pixelRatio : zoom\n\t\tconst groundNode = tree.getGroundNodeFor(node)\n\t\tconst groundNodeScope = tree.getScopeNodeFor(groundNode)\n\n\t\tif (!this.mounted) {\n\t\t\tawait this.mount()\n\t\t}\n\n\t\tawait this.sandbox.waitUntilLoaded()\n\t\tconst activeScope = this.engine.stores.scopeStore.active\n\n\t\t// Phase 1: Render ground node at origin to measure target position\n\t\tconst measurementsPromise = this.sandbox.waitForMeasurements()\n\n\t\tawait this.renderer.renderUpdates(() => {\n\t\t\tconst {\n\t\t\t\ttreeStore,\n\t\t\t\ttoolStore,\n\t\t\t\tmodulesStore,\n\t\t\t\tdocumentSettingsStore,\n\t\t\t\toverlayStore,\n\t\t\t\tselectionStore,\n\t\t\t\teffectStore,\n\t\t\t\trepeaterStore,\n\t\t\t} = this.engine.stores\n\n\t\t\t// Render the ground node (Desktop breakpoint) which contains our target\n\t\t\tthis.renderState.renderScope = groundNodeScope?.id\n\t\t\tthis.renderState.renderNodes = { [groundNode.id]: { x: 0, y: 0, width: 0, height: 0 } }\n\t\t\tthis.renderState.transform = [0, 0, effectiveZoom]\n\t\t\tthis.renderState.isDarkMode = documentSettingsStore.hasDarkAppearance\n\n\t\t\tthis.renderState.editor = {\n\t\t\t\tselection: selectionStore.ids,\n\t\t\t\tnodeInTextEditorId: toolStore.nodeInTextEditorId,\n\t\t\t\tnodesInEffectPreview: effectStore.nodesInEffectPreview,\n\t\t\t\tnodesInMoveToolRootFontSize: this.engine.getNodesInMoveToolRootFontSize(),\n\t\t\t\tactiveEffect: effectStore.activeEffect,\n\t\t\t\tactiveEffectIds: effectStore.activeEffectIds,\n\t\t\t\tactiveOverlayNodes: overlayStore.activeOverlays,\n\t\t\t\tnodesWithPlaceholders: toolStore.nodesWithPlaceholders,\n\t\t\t\trootFontSize: getRootFontSize(activeScope, treeStore.tree, modulesStore) ?? null,\n\t\t\t\toptionalSelectedCollectionItemId: undefined,\n\t\t\t\tshouldSetMinHeight: false,\n\t\t\t\trepeatersShowingEmptyState: repeaterStore.repeatersShowingEmptyState,\n\t\t\t}\n\t\t})\n\n\t\tawait measurementsPromise\n\n\t\t// Re-fetch node in case it changed during async operations (multiplayer)\n\t\tnode = node.draftOrCurrent()\n\n\t\t// Get actual viewport position from popup sandbox DOM\n\t\tconst targetViewportRect = await this.sandbox.renderer.getViewportRect(node.id)\n\t\tif (!targetViewportRect) {\n\t\t\tthrow new Error(`Target node ${node.id} not found in popup DOM`)\n\t\t}\n\n\t\t// targetViewportRect is in screen coordinates (already scaled by zoom)\n\t\t// Convert to canvas coordinates for renderNodes offset\n\t\tconst canvasOffsetX = targetViewportRect.x / effectiveZoom\n\t\tconst canvasOffsetY = targetViewportRect.y / effectiveZoom\n\n\t\tlog.debug(\"Phase 1 - target viewport rect:\", JSON.stringify(targetViewportRect), \"canvas offset:\", {\n\t\t\tx: canvasOffsetX,\n\t\t\ty: canvasOffsetY,\n\t\t})\n\n\t\t// Phase 2: Re-render ground node with offset so target node is at viewport origin\n\t\tawait this.renderer.renderUpdates(() => {\n\t\t\tthis.renderState.renderNodes = {\n\t\t\t\t[groundNode.id]: { x: -canvasOffsetX, y: -canvasOffsetY, width: 0, height: 0 },\n\t\t\t}\n\t\t})\n\n\t\t// finalRect uses screen coordinates directly (already scaled)\n\t\tconst finalWidth = Math.ceil(targetViewportRect.width)\n\t\tconst finalHeight = Math.ceil(targetViewportRect.height)\n\t\tconst finalRect: Rect = { x: 0, y: 0, width: finalWidth, height: finalHeight }\n\n\t\tlog.debug(\"Phase 2 - finalRect:\", JSON.stringify(finalRect))\n\n\t\treturn {\n\t\t\tpopupId: this.sandbox.getId(),\n\t\t\trect: finalRect,\n\t\t\tready: true,\n\t\t\trenderedNodeId: node.id,\n\t\t\tisPageScreenshot,\n\t\t}\n\t}\n\n\tdebugGetRenderState(): SandboxRenderState {\n\t\treturn this.renderState\n\t}\n\n\t/**\n\t * Cleanup and dispose the screenshot sandbox.\n\t */\n\tdispose(): void {\n\t\tif (!this.mounted) return\n\n\t\tthis.sandbox.unmount()\n\t\tthis.mounted = false\n\t\tlog.debug(\"Screenshot sandbox disposed\")\n\t}\n}\n", "import type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { DocumentLoader } from \"document/loader/DocumentLoader.ts\"\nimport { type CanvasNode, isScopeNode } from \"document/models/CanvasTree/index.ts\"\n\n/**\n * Ensure a node is accessible by loading scopes if needed.\n * Cancels loading early once the node is found.\n * TODO: This should be part of framer-api or framer-plugin or engine, not headless specifically. Currently plugins do not work well with shallow scope not being active scope.\n */\nexport async function ensureNodeLoaded(engine: VekterEngine, nodeId: string): Promise<CanvasNode> {\n\tconst getNode = () => engine.tree.getNode(nodeId)\n\n\tconst ensureLoaded = async (node: CanvasNode): Promise<CanvasNode> => {\n\t\tif (isScopeNode(node, true) && !node.isLoaded()) {\n\t\t\tawait node.load()\n\t\t\tconst loaded = getNode()\n\t\t\tif (!loaded) throw new Error(`Node ${nodeId} not found after loading scope`)\n\t\t\treturn loaded\n\t\t}\n\t\treturn node\n\t}\n\n\t// Fast path: node already accessible\n\tconst existing = getNode()\n\tif (existing) return ensureLoaded(existing)\n\n\t// Need to load scopes\n\tconst loader = engine.tree.getService(\"loader\") as DocumentLoader | null\n\tif (!loader || loader.numberOfScopesToLoad() === 0) {\n\t\tthrow new Error(`Node ${nodeId} not found`)\n\t}\n\n\tconst found = await new Promise<CanvasNode>((resolve, reject) => {\n\t\tlet done = false\n\t\tconst cleanup: Array<() => void> = []\n\n\t\tconst finish = (result: CanvasNode | null) => {\n\t\t\tif (done) return\n\t\t\tdone = true\n\t\t\tcleanup.forEach(fn => fn())\n\t\t\tif (result) resolve(result)\n\t\t\telse reject(new Error(`Node ${nodeId} not found`))\n\t\t}\n\n\t\tconst onScopeLoaded = () => {\n\t\t\tconst node = getNode()\n\t\t\tif (node) finish(node)\n\t\t}\n\n\t\tcleanup.push(\n\t\t\tloader.prioritizeLoadingAllData({\n\t\t\t\toperationInBackground: false,\n\t\t\t\toperationName: \"headless_ensure_node_loaded\",\n\t\t\t}),\n\t\t\t() => loader.off(\"loadedScope\", onScopeLoaded),\n\t\t\tloader.afterAllDataLoaded(() => finish(getNode())),\n\t\t)\n\t\tloader.on(\"loadedScope\", onScopeLoaded)\n\t})\n\n\treturn ensureLoaded(found)\n}\n", "import { getLogger } from \"@framerjs/shared\"\nimport { sandboxConfig } from \"canvas-sandbox-renderer/sandboxConfig.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { WebPageNode } from \"document/models/CanvasTree/nodes/WebPageNode.ts\"\nimport { isWebPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { getCanvasBoundingRectCached } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport { isExportableAsSVG } from \"document/models/CanvasTree/utils/isExportableAsSVG.ts\"\nimport { renderNodeToSVG } from \"utils/renderNodeToSVG.tsx\"\nimport { type ScreenshotPrepareResult, ScreenshotSandbox } from \"../ScreenshotSandbox.ts\"\nimport { ensureNodeLoaded } from \"./ensureNodeLoaded.ts\"\n\nconst logger = getLogger(\"HeadlessScreenshots\")\n\n/**\n * Manages screenshot capture for headless API.\n * Handles popup sandbox lifecycle and coordinates with Playwright for capture.\n */\nexport class HeadlessScreenshots {\n\tprivate screenshotSandbox: ScreenshotSandbox | null = null\n\tprivate activePopups: Map<string, ScreenshotSandbox> = new Map()\n\n\tconstructor(private readonly engine: VekterEngine) {}\n\n\t/**\n\t * Get or create the default screenshot sandbox.\n\t */\n\tgetScreenshotSandbox(): ScreenshotSandbox {\n\t\tif (!this.screenshotSandbox) {\n\t\t\tthis.screenshotSandbox = new ScreenshotSandbox(this.engine)\n\t\t}\n\t\treturn this.screenshotSandbox\n\t}\n\n\t/**\n\t * Mount the default screenshot sandbox popup.\n\t */\n\tasync mountScreenshotSandbox(): Promise<void> {\n\t\tconst sandbox = this.getScreenshotSandbox()\n\t\tawait sandbox.mount()\n\t}\n\n\t/**\n\t * Create a new popup sandbox. Each call creates an independent sandbox.\n\t */\n\tasync createPopupSandbox(id?: string): Promise<ScreenshotSandbox> {\n\t\tconst sandbox = new ScreenshotSandbox(this.engine, id)\n\t\tawait sandbox.mount()\n\t\treturn sandbox\n\t}\n\n\t/**\n\t * Creates a trigger button that opens screenshot popup when clicked.\n\t * Returns selector for Playwright to click.\n\t *\n\t * Playwright flow:\n\t * 1. Call createScreenshotTrigger() to get selector\n\t * 2. Set up waitForEvent('popup')\n\t * 3. Click the trigger\n\t * 4. Catch the popup page\n\t * 5. Call finishPrepareScreenshot with popupId\n\t */\n\tcreateScreenshotTrigger(): { selector: string; popupId: string } {\n\t\tconst popupId = `screenshot-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`\n\n\t\tconst button = document.createElement(\"button\")\n\t\tbutton.id = `screenshot-trigger-${popupId}`\n\t\tbutton.style.cssText = \"position:fixed;left:0;top:0;width:1px;height:1px;opacity:0.01;z-index:999999;\"\n\t\tbutton.setAttribute(\"data-popup-id\", popupId)\n\n\t\tconst sandbox = new ScreenshotSandbox(this.engine, popupId)\n\t\tthis.activePopups.set(popupId, sandbox)\n\n\t\tbutton.onclick = () => {\n\t\t\tsandbox.mount().catch(err => {\n\t\t\t\tlogger.error(\"Screenshot popup mount failed:\", err)\n\t\t\t})\n\t\t\tbutton.remove()\n\t\t}\n\n\t\tdocument.body.appendChild(button)\n\n\t\treturn {\n\t\t\tselector: `#screenshot-trigger-${popupId}`,\n\t\t\tpopupId,\n\t\t}\n\t}\n\n\t/**\n\t * Finish preparing screenshot after popup opened via trigger click.\n\t */\n\tasync finishPrepareScreenshot(\n\t\tpopupId: string,\n\t\tnodeId: string,\n\t\toptions?: { zoom?: number; pixelRatio?: number },\n\t): Promise<ScreenshotPrepareResult> {\n\t\tconst sandbox = this.activePopups.get(popupId)\n\t\tif (!sandbox) {\n\t\t\tthrow new Error(`No sandbox found for popup ${popupId}`)\n\t\t}\n\n\t\tawait ensureNodeLoaded(this.engine, nodeId)\n\n\t\treturn sandbox.prepareScreenshot({\n\t\t\tnodeId,\n\t\t\tzoom: options?.zoom,\n\t\t\tpixelRatio: options?.pixelRatio,\n\t\t})\n\t}\n\n\t/**\n\t * Prepare a node for screenshot capture.\n\t * Creates a new popup window for each call to support parallel screenshots.\n\t *\n\t * Note: Uses window.open() directly which may be blocked by popup blockers.\n\t * For Playwright, use createScreenshotTrigger() + click + finishPrepareScreenshot().\n\t */\n\tasync prepareScreenshot(\n\t\tnodeId: string,\n\t\toptions?: { zoom?: number; pixelRatio?: number },\n\t): Promise<ScreenshotPrepareResult> {\n\t\tawait ensureNodeLoaded(this.engine, nodeId)\n\n\t\tconst sandbox = new ScreenshotSandbox(this.engine)\n\n\t\tconst result = await sandbox.prepareScreenshot({\n\t\t\tnodeId,\n\t\t\tzoom: options?.zoom,\n\t\t\tpixelRatio: options?.pixelRatio,\n\t\t})\n\n\t\tthis.activePopups.set(result.popupId, sandbox)\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Get the sandbox URL for Playwright to create popup pages.\n\t */\n\tgetSandboxUrl(): string {\n\t\treturn sandboxConfig.canvas.url\n\t}\n\n\t/**\n\t * Get popup window reference by sandbox ID.\n\t */\n\tgetPopupWindow(popupId: string): Window | null {\n\t\tconst sandbox = this.activePopups.get(popupId)\n\t\treturn sandbox?.getPopupWindow() ?? null\n\t}\n\n\t/**\n\t * Cleanup screenshot popup(s).\n\t * If no ID provided, closes all popups.\n\t */\n\tcleanup(popupId?: string): void {\n\t\tif (popupId) {\n\t\t\tconst sandbox = this.activePopups.get(popupId)\n\t\t\tif (sandbox) {\n\t\t\t\tsandbox.dispose()\n\t\t\t\tthis.activePopups.delete(popupId)\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const sandbox of this.activePopups.values()) {\n\t\t\t\tsandbox.dispose()\n\t\t\t}\n\t\t\tthis.activePopups.clear()\n\n\t\t\tif (this.screenshotSandbox) {\n\t\t\t\tthis.screenshotSandbox.dispose()\n\t\t\t\tthis.screenshotSandbox = null\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Render a node to SVG string directly (no sandbox needed).\n\t * Only works for vector-type nodes (SVGNode, ShapeContainerNode, VectorNode).\n\t */\n\tasync renderToSVG(nodeId: string): Promise<string> {\n\t\tconst tree = this.engine.tree\n\t\tlet node = await ensureNodeLoaded(this.engine, nodeId)\n\n\t\tif (isWebPageNode(node, true)) {\n\t\t\tconst variantId = (node as WebPageNode).baseVariantId\n\t\t\tconst variantNode = tree.getNode(variantId)\n\t\t\tif (!variantNode) {\n\t\t\t\tthrow new Error(`Primary variant ${variantId} for WebPageNode ${nodeId} not found`)\n\t\t\t}\n\t\t\tnode = variantNode\n\t\t}\n\n\t\tif (!isExportableAsSVG(node)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Node ${nodeId} cannot be exported as SVG (must be a vector, shape, or SVG node without image fills)`,\n\t\t\t)\n\t\t}\n\n\t\treturn renderNodeToSVG({\n\t\t\tnode,\n\t\t\tisDarkMode: this.engine.stores.documentSettingsStore.hasDarkAppearance,\n\t\t\tcomponentLoader: this.engine.componentLoader,\n\t\t\tcombinedVariableValueMap: node.cache.getUnsafeCombinedVariableValueMap(),\n\t\t})\n\t}\n\n\t/** Debug: One-liner to test screenshot. Usage: `await HeadlessAPI.debugScreenshot('nodeId')` */\n\tasync debugScreenshot(nodeId: string, options?: { zoom?: number; pixelRatio?: number }) {\n\t\tconst trigger = this.createScreenshotTrigger()\n\t\tconst button = document.querySelector<HTMLElement>(trigger.selector)\n\t\tbutton?.click()\n\t\tconst result = await this.debugFinishScreenshot(trigger.popupId, nodeId, options)\n\t\t// biome-ignore lint/suspicious/noConsole: <explanation>\n\t\tconsole.log(JSON.stringify(result, null, 2))\n\t\treturn result\n\t}\n\n\t/** Debug: After popup is open, finish screenshot and inspect state. */\n\tasync debugFinishScreenshot(popupId: string, nodeId: string, options?: { zoom?: number; pixelRatio?: number }) {\n\t\tconst { zoom = 1, pixelRatio = 1 } = options ?? {}\n\t\tconst tree = this.engine.tree\n\n\t\tconst nodeBeforeLoad = tree.getNode(nodeId)\n\t\tconst prepareResult = await this.finishPrepareScreenshot(popupId, nodeId, { zoom, pixelRatio })\n\n\t\tconst popupWindow = this.getPopupWindow(popupId)\n\t\tconst loadedNode = tree.getNode(prepareResult.renderedNodeId)\n\t\tconst groundNode = loadedNode ? tree.getGroundNodeFor(loadedNode) : null\n\n\t\tconst mainEngineInfo =\n\t\t\tloadedNode && groundNode\n\t\t\t\t? {\n\t\t\t\t\t\tnodeRect: tree.getRect(loadedNode),\n\t\t\t\t\t\tnodeCanvasRect: getCanvasBoundingRectCached(tree, loadedNode),\n\t\t\t\t\t\tgroundCanvasRect: getCanvasBoundingRectCached(tree, groundNode),\n\t\t\t\t\t\tgroundNodeId: groundNode.id,\n\t\t\t\t\t\tgroundNodeName: groundNode.name,\n\t\t\t\t\t}\n\t\t\t\t: null\n\n\t\tconst sandbox = this.activePopups.get(popupId)\n\t\tconst renderState = sandbox?.debugGetRenderState()\n\n\t\treturn {\n\t\t\tinput: { popupId, nodeId, zoom, pixelRatio },\n\t\t\tloading: { existedBeforeLoad: !!nodeBeforeLoad },\n\t\t\tprepareResult,\n\t\t\tmainEngineInfo,\n\t\t\trenderState,\n\t\t\tpopupAvailable: !!popupWindow,\n\t\t}\n\t}\n}\n", "import { assert, ResolvablePromise } from \"@framerjs/shared\"\nimport { noop } from \"@framerjs/shared/src/noop.ts\"\nimport * as Sentry from \"@sentry/browser\"\nimport * as devalue from \"devalue\"\nimport engine from \"document/engine.ts\"\nimport { waitUntilBeforeUnloadUnblocked } from \"document/utils/beforeUnloadHandler.ts\"\nimport { getFramerRelease } from \"environment/getFramerRelease.ts\"\nimport { environment } from \"environment/index.ts\"\nimport { apiPluginManifest } from \"plugins/plugins.ts\"\nimport { HeadlessTransport } from \"plugins/transport.ts\"\nimport { perfEmitter } from \"utils/performanceTracker.ts\"\nimport { sleep } from \"utils/sleep.ts\"\nimport { isString } from \"utils/typeChecks.ts\"\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport type { PluginMessageAPI } from \"#framer-plugin/framerAPI.ts\"\n// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport { pluginMarshalTag } from \"#framer-plugin/marshal.ts\"\nimport type { PluginToVekterMessage } from \"#framer-plugin/messages.ts\"\nimport { ConnectionGuard } from \"./headless/ConnectionGuard.ts\"\nimport { HeadlessScreenshots } from \"./headless/HeadlessScreenshots.ts\"\n\ntype SendHandler = Parameters<HeadlessTransport[\"setSendHandler\"]>[0]\n\nfunction newSafeReadyPromise(): ResolvablePromise<void> {\n\tconst p = new ResolvablePromise<void>()\n\tvoid p.pending()\n\tvoid p.catch(() => {})\n\treturn p\n}\n\n// Bounds peak renderer heap during heavy mutations.\nconst gateCaps = {\n\theavyMethodInflight: 2,\n\theavyMethodQueue: 32,\n\tcodegenWipSoft: 2,\n}\n\ntype HeavyMethodName = keyof PluginMessageAPI\nexport const HEAVY_PLUGIN_METHODS: Partial<Record<HeavyMethodName, true>> = {\n\taddCollectionItems: true,\n\taddCollectionItems2: true,\n\taddManagedCollectionItems: true,\n\taddManagedCollectionItems2: true,\n\tsetCollectionItemAttributes: true,\n\tsetCollectionItemAttributes2: true,\n\tsetCollectionItemOrder: true,\n\tsetManagedCollectionItemOrder: true,\n\tremoveCollectionItems: true,\n\tremoveManagedCollectionItems: true,\n\tapplyAgentChanges: true,\n\tgetAgentContext: true,\n\treviewChangesForAgent: true,\n\tcreateCollection: true,\n\tcreateManagedCollection: true,\n\tsetManagedCollectionFields: true,\n\taddCollectionFields: true,\n\taddCollectionFields2: true,\n\tremoveCollectionFields: true,\n\tcreateLocale: true,\n\tsetLocalizationData: true,\n}\n\nasync function awaitCodegenBackpressure(): Promise<void> {\n\tconst codegenStore = engine.stores.codeGenerationStore\n\tif (!codegenStore) return\n\tconst metrics = codegenStore.getMetrics()\n\tconst workInFlight = metrics.queue + metrics.serializing + metrics.persisting\n\tif (workInFlight <= gateCaps.codegenWipSoft) return\n\tawait codegenStore.generateAndPersistAllQueuedComponents()\n}\n\ntype HeavyMethodSlot = { generation: number }\n\nclass HeavyMethodGate {\n\tprivate inflight = 0\n\t// Slots between acquire() and markDispatched(); held by code awaiting codegen,\n\t// so not yet visible to transport.pendingMethodCount.\n\tprivate preDispatch = 0\n\tprivate waiters: Array<{ resolve: () => void; reject: (err: Error) => void }> = []\n\t// Bumped on reset() so late releases from a prior session are ignored.\n\tprivate generation = 0\n\n\tasync acquire(): Promise<HeavyMethodSlot> {\n\t\tif (this.inflight >= gateCaps.heavyMethodInflight) {\n\t\t\tif (this.waiters.length >= gateCaps.heavyMethodQueue) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`HeadlessSessionOverloaded: too many concurrent plugin method invocations (queue=${this.waiters.length}, cap=${gateCaps.heavyMethodQueue}); retry with lower parallelism`,\n\t\t\t\t)\n\t\t\t}\n\t\t\t// Direct handoff from release(); inflight stays at cap so a racing acquire() can't slip past the check.\n\t\t\tconst gen = this.generation\n\t\t\tawait new Promise<void>((resolve, reject) => this.waiters.push({ resolve, reject }))\n\t\t\t// Handoff happens before reset() can reject \u2014 if the gen shifted, the prior session closed mid-wait.\n\t\t\tif (gen !== this.generation) throw new Error(\"HeadlessSessionClosed: plugin reset during gate wait\")\n\t\t} else {\n\t\t\tthis.inflight++\n\t\t}\n\t\tthis.preDispatch++\n\t\treturn { generation: this.generation }\n\t}\n\n\tmarkDispatched(slot: HeavyMethodSlot): void {\n\t\tif (slot.generation !== this.generation) return\n\t\tthis.preDispatch--\n\t}\n\n\trelease(slot: HeavyMethodSlot, dispatched: boolean): void {\n\t\tif (slot.generation !== this.generation) return\n\t\tif (!dispatched) this.preDispatch--\n\t\tconst next = this.waiters.shift()\n\t\tif (next) {\n\t\t\tnext.resolve()\n\t\t\treturn\n\t\t}\n\t\tthis.inflight--\n\t}\n\n\tisCurrent(slot: HeavyMethodSlot): boolean {\n\t\treturn slot.generation === this.generation\n\t}\n\n\t/** Reset on plugin close so a fresh session starts with an empty gate. */\n\treset(reason: string): void {\n\t\tthis.generation++\n\t\tthis.inflight = 0\n\t\tthis.preDispatch = 0\n\t\tconst waiters = this.waiters\n\t\tthis.waiters = []\n\t\tfor (const w of waiters) w.reject(new Error(`HeadlessSessionClosed: ${reason}`))\n\t}\n\n\tstats(): { inflight: number; queued: number; preDispatch: number } {\n\t\treturn { inflight: this.inflight, queued: this.waiters.length, preDispatch: this.preDispatch }\n\t}\n}\n\nfunction isHeavyMethod(message: PluginToVekterMessage): boolean {\n\tif (message.type !== \"methodInvocation\") return false\n\treturn HEAVY_PLUGIN_METHODS[message.methodName] === true\n}\n\n/** Vekter survived but cannot faithfully serve plugin-API calls. */\nfunction collectWedgeReasons(): string[] {\n\tconst reasons: string[] = []\n\tif (engine.scheduler.hadFatalError) reasons.push(\"hadFatalError\")\n\tif (engine.treeReflectsDocument === false) reasons.push(\"treeReflectsDocument=false\")\n\tconst { crashData } = engine.stores.documentSettingsStore\n\tif (crashData) reasons.push(`crashData: ${crashData.message}`)\n\treturn reasons\n}\n\n/**\n * FramerHeadlesApi service uses this class via browser automation when loading project (cold session) or when re-attaching to the tab (warm session)\n * 1. Sets handler to bridge plugin messages back to server\n * 2. Opens plugin\n */\nclass HeadlessAPI {\n\tprivate readonly transport = new HeadlessTransport()\n\tprivate readonly heavyMethodGate = new HeavyMethodGate()\n\treadonly gateCaps = gateCaps\n\treadonly screenshots = new HeadlessScreenshots(engine)\n\n\t// Expose devalue for use in Playwright evaluate contexts\n\tdevalue = devalue\n\t// Replaced on each session reconnection\n\t#handler: SendHandler = noop\n\t#ready = newSafeReadyPromise()\n\t#connectionGuard = new ConnectionGuard()\n\n\tprivate constructor() {}\n\n\tstatic maybeCreateGlobalInstance(): void {\n\t\tif (!environment.isApiPlugin) return\n\t\tHeadlessAPI.createGlobalInstanceUnchecked()\n\t\tSentry.setTag(\"headless_api\", true)\n\n\t\t// Browser dialogs block the page and can't be dismissed via remote automation.\n\t\t// Override to throw so unexpected calls are caught immediately.\n\t\twindow.confirm = (message?: string) => {\n\t\t\tconst error = new Error(`window.confirm called in headless: ${message}`)\n\t\t\tSentry.captureException(error)\n\t\t\tthrow error\n\t\t}\n\t\twindow.prompt = (message?: string) => {\n\t\t\tconst error = new Error(`window.prompt called in headless: ${message}`)\n\t\t\tSentry.captureException(error)\n\t\t\tthrow error\n\t\t}\n\n\t\t// Pre-load the ActivePlugin module to warm the module cache\n\t\tvoid import(\"plugins/ActivePlugin.ts\").catch(() => {})\n\t}\n\n\tstatic debugCreateGlobalInstance(): HeadlessAPI {\n\t\tconst ctx = window as Window & { HeadlessAPI?: HeadlessAPI | null }\n\t\treturn ctx.HeadlessAPI ?? HeadlessAPI.createGlobalInstanceUnchecked()\n\t}\n\n\tprivate static createGlobalInstanceUnchecked(): HeadlessAPI {\n\t\tconst ctx = window as Window & { HeadlessAPI?: HeadlessAPI | null }\n\t\tassert(!ctx.HeadlessAPI, \"HeadlessAPI already created\")\n\t\tconst instance = new HeadlessAPI()\n\t\tctx.HeadlessAPI = instance\n\t\treturn instance\n\t}\n\n\t/** Side-effect-free snapshot. Must not throw \u2014 backend reads it on the\n\t *  waitForVekter timeout path to know which flag stalled. */\n\tget readyFlags() {\n\t\tconst { loadingStore, chromeStore, pluginStore, treeStore, documentSettingsStore } = engine.stores\n\t\tconst hasCanvasFailure =\n\t\t\tloadingStore.canvasSandboxResourcesLoadingState.failure !== undefined ||\n\t\t\tloadingStore.canvasSandboxLoadingState.failure !== undefined\n\t\treturn {\n\t\t\tloading: loadingStore.isReady,\n\t\t\tpermissions: chromeStore.hasReceivedUserPermissions,\n\t\t\tplugin: pluginStore.hasLoaded,\n\t\t\tsandbox: loadingStore.canvasSandboxResourcesLoadingState.isLoaded,\n\t\t\t// Distinguishes `sandbox=false` \"still loading\" from\n\t\t\t// `sandbox=false, noCanvasFailure=false` \"loading finished\n\t\t\t// with an error\". A consumer that only aggregates flags via\n\t\t\t// `every(Boolean)` sees no behavior change today: the\n\t\t\t// failing case already drops `sandbox` to false. The flag\n\t\t\t// exists so the backend wait loop can fail-fast on it in a\n\t\t\t// follow-up \u2014 adding it now means that follow-up is a pure\n\t\t\t// FramerHeadlessApi change with no FramerStudio coordination.\n\t\t\tnoCanvasFailure: !hasCanvasFailure,\n\t\t\tconnection: this.#connectionGuard.isConnected,\n\t\t\teditable: !treeStore.getDataTreeOrPartialTree().isViewOnly,\n\t\t\tnoFatalError: !engine.scheduler.hadFatalError,\n\t\t\t// Without these two, a poisoned standby page passes `pageSafeToReuse`\n\t\t\t// and the next session inherits the crash UI / stale tree.\n\t\t\tnotCrashed: !documentSettingsStore.crashData,\n\t\t\ttreeReflectsDocument: engine.treeReflectsDocument,\n\t\t}\n\t}\n\n\tget isVekterReady() {\n\t\t// Hard-fail rather than keep polling a wedged engine.\n\t\tassert(!engine.scheduler.hadFatalError, \"Engine scheduler had a fatal error\")\n\t\treturn Object.values(this.readyFlags).every(Boolean)\n\t}\n\n\tgetReleaseChannel() {\n\t\treturn getFramerRelease(window)?.channel ?? \"stable\"\n\t}\n\n\tget perfMarks() {\n\t\treturn perfEmitter?.currentMarks() ?? {}\n\t}\n\n\t/** Waits until all beforeunload handlers are unblocked or the timeout is reached. */\n\twaitUntilBeforeUnloadUnblocked(options: { timeout: number; polling?: number }): Promise<boolean> {\n\t\treturn waitUntilBeforeUnloadUnblocked(options)\n\t}\n\n\t/** Plugin-method invocations Vekter is handling: transport timers (dispatched),\n\t *  plus gate-queued (not yet acquired) and pre-dispatch (acquired, awaiting codegen). */\n\tget pendingMethodCount(): number {\n\t\tconst gate = this.heavyMethodGate.stats()\n\t\treturn this.transport.pendingMethodCount + gate.queued + gate.preDispatch\n\t}\n\n\tfailPendingMethods(reason: string): void {\n\t\tthis.transport.failPendingMethods(reason)\n\t\tthis.heavyMethodGate.reset(reason)\n\t}\n\n\t/** Polls until pendingMethodCount drops to 0 or the timeout elapses, then\n\t *  returns the final count. Used by the backend right before standby release\n\t *  as a last-chance drain on abrupt disconnects. */\n\tasync waitUntilMethodsSettled({\n\t\ttimeout = 5_000,\n\t\tpolling = 50,\n\t}: { timeout?: number; polling?: number } = {}): Promise<{ settled: boolean; count: number }> {\n\t\tconst deadline = Date.now() + timeout\n\t\tlet count = this.pendingMethodCount\n\t\twhile (count > 0 && Date.now() < deadline) {\n\t\t\tawait sleep(polling)\n\t\t\tcount = this.pendingMethodCount\n\t\t}\n\t\treturn { settled: count === 0, count }\n\t}\n\n\t// Backend first sets handler then opens plugin\n\tsetSendHandler(handler: SendHandler) {\n\t\t// First call awaits plugin ready, then replaces with direct guard+handler.\n\t\t// Subsequent calls only check connection liveness.\n\t\tconst directHandler = (async message => {\n\t\t\tawait this.#connectionGuard.ensureConnectedOrThrow()\n\t\t\thandler(message)\n\t\t}) satisfies SendHandler\n\n\t\tconst ensureReady = (async message => {\n\t\t\tawait this.#ready\n\t\t\tthis.#handler = directHandler\n\t\t\tthis.transport.updateSendHandler(directHandler)\n\t\t\tawait directHandler(message)\n\t\t}) satisfies SendHandler\n\n\t\tthis.#handler = ensureReady\n\t\tthis.transport.setSendHandler(ensureReady)\n\t}\n\n\tasync openPlugin({ sessionId, clientId }: { sessionId?: string; clientId?: string }) {\n\t\t// close previous session plugin if exists\n\t\tthis.closePlugin()\n\n\t\tSentry.setTag(\"headless_session_id\", sessionId ?? \"unknown\")\n\t\tSentry.setTag(\"headless_client_id\", clientId ?? \"unknown\")\n\t\tthis.transport.setSessionContext(sessionId, clientId)\n\n\t\tSentry.addBreadcrumb({ message: \"Opening headless plugin\", level: \"info\" })\n\t\tthis.#ready = newSafeReadyPromise()\n\t\tthis.transport.setSendHandler(this.#handler)\n\n\t\tawait engine.stores.pluginStore\n\t\t\t.openPlugin(apiPluginManifest, engine, { mode: \"api\" }, this.transport, sessionId, clientId)\n\t\t\t.then(this.#ready.resolve, this.#ready.reject)\n\n\t\tconst active = engine.stores.pluginStore.activePlugin\n\n\t\tassert(active, \"Failed to open headless plugin\")\n\t\tactive.allowClose = false\n\t\tSentry.addBreadcrumb({ message: \"Headless plugin is active\", level: \"info\" })\n\n\t\t// Safety net: if the plugin ever stops for any reason (out-of-band close, health failure), fail\n\t\t// pending methods so callers get an error instead of hanging on a plugin that no longer exists.\n\t\t// Must run synchronously here: the abort fires inside ActivePlugin.stop(), right before\n\t\t// transport.stop() -> reset() forgets the in-flight timers without replying. Failing first\n\t\t// sends each a methodResponse while the timers still exist; reset() then has nothing to drop.\n\t\tactive.stopSignal.addEventListener(\n\t\t\t\"abort\",\n\t\t\t() => this.failPendingMethods(\"HeadlessSessionClosed: plugin stopped\"),\n\t\t\t{\n\t\t\t\tonce: true,\n\t\t\t},\n\t\t)\n\t}\n\n\tclosePlugin() {\n\t\tconst prev = this.#ready\n\n\t\tif (!prev.isResolved()) {\n\t\t\tSentry.addBreadcrumb({ message: \"Rejecting pending ready promise\", level: \"warning\" })\n\t\t\tprev.reject()\n\t\t}\n\n\t\tSentry.addBreadcrumb({ message: \"Closing headless plugin\", level: \"info\" })\n\t\tconst active = engine.stores.pluginStore.activePlugin\n\t\tif (active) active.allowClose = true\n\t\tengine.stores.pluginStore.closePlugin(apiPluginManifest.id)\n\t\tthis.heavyMethodGate.reset(\"plugin closed\")\n\t}\n\n\tasync receiveMessage(messageOrSerialized: PluginToVekterMessage | string): Promise<void> {\n\t\tconst message: PluginToVekterMessage = isString(messageOrSerialized)\n\t\t\t? // The plugin-marshal reviver is a no-op because the send side already\n\t\t\t\t// marshaled class instances into plain objects. We just need to tell\n\t\t\t\t// devalue to accept the tag rather than treat it as unknown.\n\t\t\t\tdevalue.parse(messageOrSerialized, { [pluginMarshalTag]: value => value })\n\t\t\t: messageOrSerialized\n\n\t\t// Fast-fail mid-session wedges; otherwise writes silently no-op through\n\t\t// the downgraded asserts in CanvasNode.ts and the agent sees \"success\".\n\t\tconst wedgeReasons = collectWedgeReasons()\n\t\tif (wedgeReasons.length > 0) {\n\t\t\tthrow new Error(`HeadlessSessionDegraded: ${wedgeReasons.join(\"; \")}`)\n\t\t}\n\n\t\t// Methods that arrive after the API plugin stopped would route into a stopped transport and\n\t\t// hang. Check the active plugin is the API plugin specifically \u2014 a different plugin being\n\t\t// active still means the headless transport is dead.\n\t\tif (engine.stores.pluginStore.activePlugin?.manifestId !== apiPluginManifest.id) {\n\t\t\tthrow new Error(\"HeadlessSessionClosed: API plugin not active\")\n\t\t}\n\n\t\tawait this.#ready\n\t\tawait this.#connectionGuard.ensureConnectedOrThrow()\n\n\t\tSentry.addBreadcrumb({\n\t\t\tmessage: \"Dispatching message to plugin\",\n\t\t\tlevel: \"info\",\n\t\t\tdata: {\n\t\t\t\ttype: message.type,\n\t\t\t\t...(\"methodName\" in message && { methodName: message.methodName }),\n\t\t\t},\n\t\t})\n\n\t\tif (!isHeavyMethod(message)) {\n\t\t\tvoid this.transport.receiveMessage(message)\n\t\t\treturn\n\t\t}\n\t\t// Pre-dispatch failures reply via methodResponse so SessionManager doesn't tear\n\t\t// the session down. Capture the session origin so a reopen mid-wait can't misroute.\n\t\tconst origin = this.transport.captureSessionOrigin()\n\t\tlet slot: HeavyMethodSlot\n\t\ttry {\n\t\t\tslot = await this.heavyMethodGate.acquire()\n\t\t} catch (err) {\n\t\t\tthis.#replyMethodError(message, err, origin)\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tawait awaitCodegenBackpressure()\n\t\t\tif (!this.heavyMethodGate.isCurrent(slot)) {\n\t\t\t\tthrow new Error(\"HeadlessSessionClosed: plugin reset during backpressure\")\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tthis.heavyMethodGate.release(slot, false)\n\t\t\tthis.#replyMethodError(message, err, origin)\n\t\t\treturn\n\t\t}\n\t\tconst dispatch = this.transport.receiveMessage(message)\n\t\tthis.heavyMethodGate.markDispatched(slot)\n\t\tvoid dispatch.finally(() => this.heavyMethodGate.release(slot, true))\n\t}\n\n\t#replyMethodError(message: PluginToVekterMessage, err: unknown, origin: number): void {\n\t\tif (message.type !== \"methodInvocation\") return\n\t\tthis.transport.replyToSessionOrigin(origin, {\n\t\t\ttype: \"methodResponse\",\n\t\t\tid: message.id,\n\t\t\tresult: null,\n\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t})\n\t}\n\n\tget isReady(): boolean {\n\t\treturn this.#ready.isResolved()\n\t}\n\n\tasync ensureConnected(timeoutMs?: number): Promise<\"ready\" | \"failed\"> {\n\t\tassert(!engine.scheduler.hadFatalError, \"Engine scheduler had a fatal error\")\n\n\t\treturn this.#connectionGuard.ensureConnected(timeoutMs)\n\t}\n\n\tdebugBurnReconnectBudget(): void {\n\t\tthis.#connectionGuard.debugBurnReconnectBudget()\n\t}\n\n\tdebugResetReconnectState(): void {\n\t\tthis.#connectionGuard.debugReset()\n\t}\n\n\tget debugReconnectState(): { attempts: number; nextRetryInMs: number } {\n\t\treturn this.#connectionGuard.debugState\n\t}\n\n\t// Screenshot methods delegated to HeadlessScreenshots\n\tgetScreenshotSandbox = () => this.screenshots.getScreenshotSandbox()\n\tmountScreenshotSandbox = () => this.screenshots.mountScreenshotSandbox()\n\tcreatePopupSandbox = (id?: string) => this.screenshots.createPopupSandbox(id)\n\tcreateScreenshotTrigger = () => this.screenshots.createScreenshotTrigger()\n\tfinishPrepareScreenshot = (popupId: string, nodeId: string, options?: { zoom?: number; pixelRatio?: number }) =>\n\t\tthis.screenshots.finishPrepareScreenshot(popupId, nodeId, options)\n\tprepareScreenshot = (nodeId: string, options?: { zoom?: number; pixelRatio?: number }) =>\n\t\tthis.screenshots.prepareScreenshot(nodeId, options)\n\tgetSandboxUrl = () => this.screenshots.getSandboxUrl()\n\tgetPopupWindow = (popupId: string) => this.screenshots.getPopupWindow(popupId)\n\tcleanupScreenshot = (popupId?: string) => this.screenshots.cleanup(popupId)\n\trenderToSVG = (nodeId: string) => this.screenshots.renderToSVG(nodeId)\n\tdebugScreenshot = (nodeId: string, options?: { zoom?: number; pixelRatio?: number }) =>\n\t\tthis.screenshots.debugScreenshot(nodeId, options)\n\tdebugFinishScreenshot = (popupId: string, nodeId: string, options?: { zoom?: number; pixelRatio?: number }) =>\n\t\tthis.screenshots.debugFinishScreenshot(popupId, nodeId, options)\n}\n\nexport { HeadlessAPI }\n", "import { setSentryMetaFunction } from \"@framerjs/framer-environment\"\nimport { setLogLevel } from \"@framerjs/shared\"\nimport { experiments } from \"app/experiments.ts\"\nimport { benchCreate, benchZoom } from \"debug-utils/bench.ts\"\nimport { fuzz } from \"debug-utils/fuzzer.ts\"\nimport { engineLog } from \"document/EngineLoggers.ts\"\nimport { ContextAction } from \"document/components/utils/contextActions.ts\"\nimport engine from \"document/engine.ts\"\nimport { getContextsForErrorReporting } from \"document/getContextsForErrorReporting.ts\"\nimport { loadDocument, loadDocumentJSON, serializeDocument, snapshotDocument } from \"document/serialization/index.ts\"\nimport { executeServerDatabaseQuery } from \"library/modules/cms/server-database/mock/executeServerDatabaseQuery.ts\"\nimport { fontStore } from \"library/render/fonts/fontStore.ts\"\nimport { loadTracing } from \"utils/tracing.ts\"\nimport { installGlobalErrorHandler } from \"./GlobalErrorHandler.ts\"\nimport { HeadlessAPI } from \"./HeadlessAPI.ts\"\nimport { browserAgentEvalsGlobal } from \"./browserAgentEvals.ts\"\n\nsetSentryMetaFunction(() => {\n\tconst data = getContextsForErrorReporting(engine)\n\treturn {\n\t\ttags: data.tags,\n\t\textras: data.meta,\n\t}\n})\nloadTracing()\ninstallGlobalErrorHandler(engine.scheduler)\n\nexport const Globals = {\n\tVekter: {\n\t\tsetLogLevel: (spec: string, replay?: boolean) => setLogLevel(spec || \"app:info\", replay),\n\t\tengine,\n\t\tbenchCreate: benchCreate.bind(benchCreate, engine),\n\t\tbenchZoom: benchZoom.bind(benchZoom, engine),\n\t\tserializeDocument: () => serializeDocument(engine),\n\t\tsnapshotDocument: () => snapshotDocument(engine),\n\t\tloadDocument: (url: URL | string) => engine.load(loadDocument(url, engine.componentLoader)),\n\t\tloadDocumentJSON: (json: unknown) => engine.load(loadDocumentJSON(json, engine.componentLoader)),\n\t\tbuild: {\n\t\t\tgitHash: process.env.GIT_HASH,\n\t\t\ttype: process.env.BUILD_TYPE,\n\t\t\tversion: process.env.VERSION,\n\t\t},\n\t\tfuzz,\n\t\tcontextActions: ContextAction,\n\t\t...(browserAgentEvalsGlobal\n\t\t\t? {\n\t\t\t\t\tevals: browserAgentEvalsGlobal,\n\t\t\t\t}\n\t\t\t: {}),\n\t\tfontStore,\n\t\tget selectedNode() {\n\t\t\treturn engine.stores.selectionStore.nodes[0]\n\t\t},\n\t\t...(experiments.isOn(\"cmsDatabase\") ? { executeServerDatabaseQuery } : {}),\n\t},\n}\n\nHeadlessAPI.maybeCreateGlobalInstance()\n\nexport type VekterGlobals = typeof Globals\n\nengineLog.info(\"Framer Starting\", {\n\ttype: process.env.BUILD_TYPE,\n\tversion: process.env.VERSION,\n})\n", "import \"ProjectGlobal.styles_rnxalp.wyw.css\"; export const overlayEditModeClassName = \"overlayEditMode\";\nexport const debugBarClassName = \"framer-debug-bar\";\nexport const globals = \"globals_g1ryte3g\";", "import { ChannelController } from \"utils/rpc/ChannelController.ts\"\nimport { type RendererListenerInterface, sandboxInterface } from \"utils/rpc/shared/definitions.ts\"\nimport type { ChannelInterface } from \"utils/rpc/types.ts\"\nimport type { EngineStores } from \"../document/EngineStores.ts\"\n\nexport class SandboxRPC {\n\treadonly controller: ChannelController\n\treadonly renderer: ChannelInterface<typeof sandboxInterface.channels.renderer>\n\treadonly modules: ChannelInterface<typeof sandboxInterface.channels.modules>\n\treadonly modulesRuntime: ChannelInterface<typeof sandboxInterface.channels.modulesRuntime>\n\treadonly utils: ChannelInterface<typeof sandboxInterface.channels.utils>\n\treadonly assets: ChannelInterface<typeof sandboxInterface.channels.assets>\n\treadonly controlsVisibility: ChannelInterface<typeof sandboxInterface.channels.controlsVisibility>\n\treadonly flags: ChannelInterface<typeof sandboxInterface.channels.flags>\n\n\tconstructor(abortSignal?: AbortSignal) {\n\t\tthis.controller = new ChannelController(sandboxInterface, abortSignal)\n\t\tthis.renderer = this.controller.getRemote(sandboxInterface.channels.renderer)\n\t\tthis.modules = this.controller.getRemote(sandboxInterface.channels.modules)\n\t\tthis.modulesRuntime = this.controller.getRemote(sandboxInterface.channels.modulesRuntime)\n\t\tthis.controlsVisibility = this.controller.getRemote(sandboxInterface.channels.controlsVisibility)\n\t\tthis.utils = this.controller.getRemote(sandboxInterface.channels.utils)\n\t\tthis.assets = this.controller.getRemote(sandboxInterface.channels.assets)\n\t\tthis.flags = this.controller.getRemote(sandboxInterface.channels.flags)\n\t}\n\n\tsetLocal(\n\t\t{\n\t\t\tcomponentsStore,\n\t\t\tloadedExternalModulesStore,\n\t\t}: Pick<EngineStores, \"componentsStore\" | \"loadedExternalModulesStore\">,\n\t\trendererListener: RendererListenerInterface,\n\t) {\n\t\tthis.controller.setLocal(sandboxInterface.channels.rendererListener, rendererListener)\n\t\tthis.controller.setLocal(sandboxInterface.channels.componentsStore, componentsStore)\n\t\tthis.controller.setLocal(sandboxInterface.channels.loadedExternalModulesStore, loadedExternalModulesStore)\n\t}\n}\n", "import { assert, getLogger } from \"@framerjs/shared\"\nimport { CanvasTreeVersion } from \"document/models/CanvasTree/CanvasTreeVersion.ts\"\nimport { environment } from \"environment/index.ts\"\nimport type { RenderTarget } from \"library/render/types/RenderEnvironment.ts\"\nimport { getIFrameAllowPolicy } from \"services/hooks/index.ts\"\nimport { sandboxInterface } from \"utils/rpc/shared/definitions.ts\"\nimport { SandboxRPC } from \"./SandboxRPC.ts\"\nimport type { SandboxConfig } from \"./sandboxConfig.ts\"\n\nconst log = getLogger(\"IFrameSandbox\")\n\n// Security settings. Be VERY careful when changing these.\nconst expectedSandboxAttributes = [\"allow-scripts\", \"allow-same-origin\"]\n\nfunction assertExpectedSandboxAttributes(values: IterableIterator<string>) {\n\tconst expected = Array.from(expectedSandboxAttributes).sort().join(\" \")\n\tconst actual = Array.from(values).sort().join(\" \")\n\tassert(expected === actual, \"Sandbox iframe must have sandbox attributes\", expected, \"has:\", actual)\n}\n\n// Verifies that the used iframe element is secure/correct.\n// Note: this was added with (future) iframe pre/sideloading in mind.\nfunction assertValidIFrame(iframe: HTMLIFrameElement) {\n\tif (environment.isTest) return\n\n\tassert(iframe.style.display === \"none\", \"IFrameSandbox iframe must be display: none\")\n\n\t// Note: the sandbox attribute can be undefined in jest-dom\n\tconst sandbox = iframe.sandbox as undefined | HTMLIFrameElement[\"sandbox\"]\n\tassert(sandbox, \"IFrameSandbox iframe must have a sandbox attribute\")\n\n\t// Verify the sandbox is secure\n\tassertExpectedSandboxAttributes(sandbox.values())\n}\n\n// When we log the url, remove query and hash, so sentry might not filter out all the logs.\nconst iframeSrcSplitRegex = /[#?]/u\nfunction iframeUrl(iframe: HTMLIFrameElement): string {\n\treturn iframe.src.split(iframeSrcSplitRegex)[0] ?? iframe.src\n}\n\n/**\n * Represents a sandbox rendered inside an iframe. Note that these sandboxes become invalid when the backing iframe\n * is moved or removed from the DOM. Make sure you keep its parent stable and present in the document (e.g. body).\n */\nexport class IFrameSandbox extends SandboxRPC {\n\tprivate iframe: HTMLIFrameElement\n\tprivate isLoaded = false\n\n\tconstructor(\n\t\tprivate readonly renderTarget: RenderTarget,\n\t\tprivate readonly config: SandboxConfig,\n\t\tprivate readonly abortSignal?: AbortSignal,\n\t) {\n\t\tsuper(abortSignal)\n\n\t\tconst iframe = document.createElement(\"iframe\")\n\t\tiframe.style.display = \"none\"\n\t\tiframe.allow = getIFrameAllowPolicy(\"editor\")\n\t\tiframe.src = config.url\n\t\tiframe.tabIndex = -1\n\t\tiframe.dataset.testid = \"canvas-iframe\"\n\n\t\t// Note: the sandbox attribute can be undefined in jest-dom\n\t\tconst sandbox = iframe.sandbox as undefined | HTMLIFrameElement[\"sandbox\"]\n\t\tfor (const attribute of expectedSandboxAttributes) {\n\t\t\tsandbox?.add(attribute)\n\t\t}\n\n\t\tassertValidIFrame(iframe)\n\t\tthis.iframe = iframe\n\n\t\tiframe.addEventListener(\"load\", this.onLoad, { signal: this.abortSignal })\n\n\t\t// If the window becomes blurred, it might be because some element in the iframe received focus,\n\t\t// so we check and release the focus when this happens.\n\t\twindow.addEventListener(\n\t\t\t\"blur\",\n\t\t\t() => {\n\t\t\t\t// Use a timeout so the blur/focus event settle, otherwise this might have no effect.\n\t\t\t\tsetTimeout(() => this.checkAndReleaseFocus())\n\t\t\t},\n\t\t\t{ signal: this.abortSignal },\n\t\t)\n\t}\n\n\tprivate checkAndReleaseFocus(): void {\n\t\tif (document.activeElement === this.iframe) {\n\t\t\tthis.iframe.blur()\n\t\t}\n\t}\n\n\tprivate onLoad = async () => {\n\t\tlog.debug(\"IFrameSandbox: contentWindow loaded\")\n\n\t\tif (this.isLoaded) {\n\t\t\tthrow Error(\"IFrameSandbox: contentWindow already loaded. Did it reload unexpectedly?\")\n\t\t}\n\n\t\tthis.isLoaded = true\n\t\tthis.iframe.style.display = \"block\"\n\n\t\t// We might have gained focus after loading things due to autoFocus=true elements. And\n\t\t// somehow the window.onblur handler isn't always reliable the first time around.\n\t\tthis.checkAndReleaseFocus()\n\n\t\ttry {\n\t\t\tif (!this.iframe.contentWindow) throw Error(\"IFrameSandbox: no contentWindow available on iframe\")\n\t\t\tawait this.controller.connect({ target: this.iframe.contentWindow, url: this.config.origin })\n\t\t\tawait this.controller\n\t\t\t\t.getRemote(sandboxInterface.channels.renderer)\n\t\t\t\t.initialize(CanvasTreeVersion, this.renderTarget)\n\t\t} catch (error) {\n\t\t\tlog.error(\"IFrameSandbox.onLoad():\", error)\n\t\t}\n\t}\n\n\tasync resizeTo(width: number, height: number): Promise<void> {\n\t\tthis.iframe.style.width = `${Math.ceil(Math.max(width, 1))}px`\n\t\tthis.iframe.style.height = `${Math.ceil(Math.max(height, 1))}px`\n\t}\n\n\taddIFrameToElement(parent: HTMLElement, customStyle?: React.CSSProperties) {\n\t\tlog.debug(\"addIFrameToElement\")\n\n\t\tif (this.iframe.parentElement) {\n\t\t\tassert(parent === this.iframe.parentElement, \"IFrameSandbox: iframe can't move between parent elements\")\n\t\t\tlog.debug(\"addIFrameToElement: already installed, showing iframe; loaded:\", this.isLoaded)\n\t\t\tthis.iframe.style.display = this.isLoaded ? \"block\" : \"none\"\n\t\t\treturn\n\t\t}\n\n\t\t// Default styling\n\t\tconst style = this.iframe.style\n\t\tstyle.height = \"100px\"\n\t\tstyle.width = \"100px\"\n\n\t\t// See https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/CSSProperty.js for a full list\n\t\tconst isUnitlessNumber: Record<string, boolean> = {\n\t\t\tzIndex: true,\n\t\t}\n\n\t\t// Custom styling\n\t\tif (customStyle) {\n\t\t\tlet property: keyof typeof customStyle\n\t\t\tfor (property in customStyle) {\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: for in loop\n\t\t\t\tconst value = customStyle[property]!\n\t\t\t\tconst cssProperty = property.replace(/[(A-Z)]/gu, \"-$&\").toLowerCase()\n\t\t\t\tconst cssValue = typeof value === \"number\" && !isUnitlessNumber[property] ? `${value}px` : `${value}`\n\t\t\t\tstyle.setProperty(cssProperty, cssValue)\n\t\t\t}\n\t\t}\n\n\t\t// Required styling\n\t\tstyle.border = \"none\"\n\t\tstyle.pointerEvents = \"none\"\n\t\tstyle.display = this.isLoaded ? \"block\" : \"none\"\n\n\t\tlog.debug(\"addIFrameToElement: iframe loading from\", iframeUrl(this.iframe))\n\t\tparent.appendChild(this.iframe)\n\t}\n\n\tremoveIFrameFromElement() {\n\t\tif (!this.iframe.parentElement) {\n\t\t\tlog.debug(\"removeIFrameFromElement: iframe not installed\")\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tthis.iframe.parentElement.removeChild(this.iframe)\n\t\t} catch (error) {\n\t\t\tlog.error(\"removeIFrameFromElement:\", error)\n\t\t}\n\t}\n\n\thideIFrame() {\n\t\tthis.iframe.style.display = \"none\"\n\t}\n}\n", "import { unhandledError } from \"@framerjs/shared\"\nimport { IFrameSandbox } from \"canvas-sandbox-renderer/IFrameSandbox.ts\"\nimport { sandboxConfig } from \"canvas-sandbox-renderer/sandboxConfig.ts\"\nimport { VekterEngine } from \"document/VekterEngine.ts\"\nimport engine from \"document/engine.ts\"\nimport type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { isVectorNode } from \"document/models/CanvasTree/index.ts\"\nimport { RenderTarget } from \"library/render/types/RenderEnvironment.ts\"\nimport { useEffect } from \"react\"\nimport { toast } from \"web/lib/toaster.ts\"\nimport { NodeRenderer } from \"./NodeRenderer.ts\"\n\nconst testIFrameStyle: React.CSSProperties = {\n\tposition: \"absolute\",\n\ttop: 0,\n\tleft: 0,\n\twidth: \"100%\",\n\theight: \"100%\",\n\tborder: \"none\",\n\ttransformOrigin: \"0 0\",\n\ttransform: \"scale(1)\",\n\tzIndex: 1001,\n\tbackground: \"rgba(0, 0, 255, 0.2)\",\n\toutline: \"1px solid blue\",\n}\n\n/**\n * Shows a test secondary renderer in an iframe overlay, reflecting the current selection. This is useful to debug\n * core ServiceSandbox/SandboxRenderer behavior independently of Electron external window integration.\n */\nexport function DebugNodeRenderer() {\n\tuseEffect(() => {\n\t\tconst sandbox = new IFrameSandbox(RenderTarget.canvas, sandboxConfig.canvas)\n\t\tconst tester = new NodeRenderer(sandbox, VekterEngine.shared())\n\t\tsandbox.addIFrameToElement(document.body, testIFrameStyle)\n\n\t\tlet lastSelectedNode: CanvasNode | null = null\n\t\tengine.scheduler.changes.observe(engine.stores.selectionStore, () => {\n\t\t\tlet node: CanvasNode | null = engine.stores.selectionStore.nodes[0] ?? null\n\t\t\tif (lastSelectedNode === node) return\n\t\t\tlastSelectedNode = node\n\n\t\t\t// We cannot render paths and shapes directly, so we find and render the container instead\n\t\t\twhile (node && isVectorNode(node)) {\n\t\t\t\tnode = engine.tree.get(node.parentid)\n\t\t\t}\n\t\t\tif (!node) return\n\n\t\t\tconst nodeId = node.id\n\t\t\ttester\n\t\t\t\t.prepareNodeSnapshot({ nodeId })\n\t\t\t\t.then(() =>\n\t\t\t\t\ttoast({\n\t\t\t\t\t\ttype: \"add\",\n\t\t\t\t\t\tvariant: \"info\",\n\t\t\t\t\t\ttext: `Ready for snapshot: ${nodeId}`,\n\t\t\t\t\t\tkey: \"image-snapshots-selection\",\n\t\t\t\t\t\ticon: \"frame\",\n\t\t\t\t\t\tduration: 500,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\t.catch(unhandledError)\n\t\t})\n\t\treturn () => sandbox.removeIFrameFromElement()\n\t}, [])\n\n\treturn null\n}\n", "import { getLogger } from \"@framerjs/shared\"\nimport type { SandboxRPC } from \"canvas-sandbox-renderer/SandboxRPC.ts\"\nimport { type SandboxRenderState, SandboxRenderer } from \"canvas-sandbox-renderer/SandboxRenderer.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { CanvasNode, CanvasTree } from \"document/models/CanvasTree/index.ts\"\nimport { isWebPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { getRootFontSize } from \"document/models/CanvasTree/traits/utils/rootFontSizeHelpers.ts\"\nimport { getCanvasBoundingRectCached } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport { isExportableAsSVG } from \"document/models/CanvasTree/utils/isExportableAsSVG.ts\"\nimport { Rect } from \"library/render/types/Rect.ts\"\nimport { renderNodeToSVG } from \"utils/renderNodeToSVG.tsx\"\nimport { getExportBoundingBox } from \"./nodeForExporting.ts\"\n\nexport interface NodeSnapshotOptions {\n\treadonly nodeId: string\n\treadonly zoom?: number\n\treadonly pixelRatio?: number\n\treadonly p3?: boolean\n}\n\nexport class NodeRenderer<Sandbox extends SandboxRPC = SandboxRPC> {\n\tprotected log = getLogger(\"node-snapshots\")\n\tprotected engine: VekterEngine\n\tprotected renderer: SandboxRenderer<Sandbox>\n\tprivate renderState: SandboxRenderState = { renderNodes: {}, transform: [0, 0, 1], isDarkMode: false }\n\n\tconstructor(sandbox: Sandbox, engine: VekterEngine) {\n\t\tthis.engine = engine\n\t\tthis.renderer = new SandboxRenderer(sandbox, {\n\t\t\tlog: this.log.extend(\"renderer\"),\n\t\t\tengine: this.engine,\n\t\t\twantsEngineUpdates: false,\n\t\t\trenderState: () => this.renderState,\n\t\t})\n\t}\n\n\trenderToSVG({ nodeId }: NodeSnapshotOptions) {\n\t\tthis.log.debug(\"preparing SVG\")\n\n\t\tconst tree = this.engine.tree\n\t\tconst node = tree.getNode(nodeId)\n\n\t\tif (!node) throw Error(`Node ${nodeId} doesn't exist`)\n\t\tif (!isExportableAsSVG(node)) throw Error(`Node ${nodeId} must be exportable as SVG`)\n\n\t\treturn renderNodeToSVG({\n\t\t\tnode,\n\t\t\tisDarkMode: this.engine.stores.documentSettingsStore.hasDarkAppearance,\n\t\t\tcomponentLoader: this.engine.componentLoader,\n\t\t\tcombinedVariableValueMap: node.cache.getUnsafeCombinedVariableValueMap(),\n\t\t})\n\t}\n\n\tasync prepareNodeSnapshot({\n\t\tnodeId,\n\t\tzoom = 1,\n\t\tpixelRatio: expectedPixelRatio = 1,\n\t}: NodeSnapshotOptions): Promise<Rect> {\n\t\tthis.log.debug(\"preparing snapshot\")\n\n\t\tconst tree = this.engine.tree\n\t\tconst node = tree.getNode(nodeId)\n\t\tif (!node) throw Error(`Node ${nodeId} doesn't exist`)\n\n\t\tconst exportingNodeRect = tree.getRect(node)\n\t\tconst snapshotViewportRect = snapshotViewportRectForNode(tree, node)\n\t\tconst visualBoundingRect = getExportBoundingBox(tree, node)\n\n\t\t// The rect of the node to render in the new export sandbox should be the current size of the node\n\t\t// but positioned relative to the origin. In most cases it is probably origin but when we do have shadows\n\t\t// or other overflow content it should be an offset from the original point.\n\t\tconst nodeRect: Rect = {\n\t\t\t...exportingNodeRect,\n\t\t\tx: snapshotViewportRect.x - visualBoundingRect.x,\n\t\t\ty: snapshotViewportRect.y - visualBoundingRect.y,\n\t\t}\n\n\t\t// If the snapshot should have a specific pixel ratio that's not available, compensate with zoom\n\t\tif (expectedPixelRatio !== 1) {\n\t\t\tzoom *= expectedPixelRatio\n\t\t}\n\n\t\t// Wait for everything to have loaded and rendered...\n\t\tthis.log.debug(\"rendering\")\n\t\tconst activeScope = this.engine.stores.scopeStore.active\n\n\t\tawait this.renderer.renderUpdates(() => {\n\t\t\tconst {\n\t\t\t\ttreeStore,\n\t\t\t\ttoolStore,\n\t\t\t\tscopeStore,\n\t\t\t\tmodulesStore,\n\t\t\t\tdocumentSettingsStore,\n\t\t\t\toverlayStore,\n\t\t\t\tselectionStore,\n\t\t\t\teffectStore,\n\t\t\t\trepeaterStore,\n\t\t\t} = this.engine.stores\n\t\t\tthis.renderState.renderScope = treeStore.treeIndex.getScopeIdFor(node.id)\n\t\t\tthis.renderState.renderNodes = { [node.id]: nodeRect }\n\t\t\tthis.renderState.transform = [0, 0, zoom]\n\t\t\tthis.renderState.isDarkMode = documentSettingsStore.hasDarkAppearance\n\t\t\tthis.renderState.editor = {\n\t\t\t\tselection: selectionStore.ids,\n\t\t\t\tnodeInTextEditorId: toolStore.nodeInTextEditorId,\n\t\t\t\tnodesInEffectPreview: effectStore.nodesInEffectPreview,\n\t\t\t\tnodesInMoveToolRootFontSize: this.engine.getNodesInMoveToolRootFontSize(),\n\t\t\t\tactiveEffect: effectStore.activeEffect,\n\t\t\t\tactiveEffectIds: effectStore.activeEffectIds,\n\t\t\t\tactiveOverlayNodes: overlayStore.activeOverlays,\n\t\t\t\tnodesWithPlaceholders: toolStore.nodesWithPlaceholders,\n\t\t\t\trootFontSize: getRootFontSize(activeScope, treeStore.tree, modulesStore) ?? null,\n\t\t\t\toptionalSelectedCollectionItemId: isWebPageNode(activeScope)\n\t\t\t\t\t? scopeStore.getSelectedCollectionItemForWebPage(activeScope)\n\t\t\t\t\t: undefined,\n\t\t\t\tshouldSetMinHeight: false,\n\t\t\t\trepeatersShowingEmptyState: repeaterStore.repeatersShowingEmptyState,\n\t\t\t}\n\t\t})\n\n\t\t// ...then we're ready to actually snapshot\n\t\treturn Rect.multiply(Rect.atOrigin(visualBoundingRect), zoom)\n\t}\n}\n\n/**\n * Get the snapshot viewport rect which is a reference rect for a node.\n *\n * This is the rect which the exported node will use as the origin, but if the node is not the ground node,\n * we need to get the rect of the ground node instead which will then in nodeForExporting\n * be used to offset the exporting node to the correct position.\n *\n * @param tree - The tree containing the node.\n * @param node - The node.\n * @returns The snapshot viewport rect for the node.\n */\nfunction snapshotViewportRectForNode(tree: CanvasTree, node: CanvasNode) {\n\tif (tree.isGroundNode(node)) return tree.getRect(node)\n\n\tconst groundNode = tree.getGroundNodeFor(node)\n\treturn getCanvasBoundingRectCached(tree, groundNode)\n}\n", "import { getAppStartTime, openNewTab } from \"@framerjs/app-shared\"\nimport { hasUnsafeSameOriginSandboxForTesting } from \"@framerjs/framer-environment/domains.ts\"\nimport { getLogger, unhandledError } from \"@framerjs/shared\"\nimport { EmployeesOnlySettings } from \"app/employeesOnlySettings.ts\"\nimport { loadDocumentMetrics } from \"app/trackDocumentLoad.ts\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport engine from \"document/engine.ts\"\nimport { isWebPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { getRootFontSize } from \"document/models/CanvasTree/traits/utils/rootFontSizeHelpers.ts\"\nimport { LoadingState } from \"document/stores/LoadingStore.ts\"\nimport { ActiveMainView } from \"document/utils/ActiveEditorType.ts\"\nimport { getTunnelId } from \"environment/getTunnelId.ts\"\nimport { DebugNodeRenderer } from \"export/DebugNodeRenderer.tsx\"\nimport { RenderTarget } from \"library/render/types/RenderEnvironment.ts\"\nimport { preloadProseMirror } from \"prosemirror/loader.ts\"\nimport React, { useEffect, useRef, useState } from \"react\"\nimport { markLoadingPerf } from \"utils/performanceTracker.ts\"\nimport type { SandboxError, SandboxHeartbeat, SandboxHeartbeatVitals } from \"utils/rpc/shared/definitions.ts\"\nimport type { Message } from \"utils/rpc/types.ts\"\nimport { isNumber } from \"utils/typeChecks.ts\"\nimport { toast } from \"web/lib/toaster.ts\"\nimport { ErrorArea, record } from \"web/lib/tracker.ts\"\nimport { IFrameSandbox } from \"./IFrameSandbox.ts\"\nimport { PopupSandbox } from \"./PopupSandbox.ts\"\nimport { SandboxRenderer } from \"./SandboxRenderer.ts\"\nimport { sandboxConfig } from \"./sandboxConfig.ts\"\n\nconst log = getLogger(\"RemountableCanvasSandboxRenderer\")\n\nexport const debugBarSandboxWindowModeKey = \"debugBarSandboxWindowMode\"\n\nexport const canvasSandboxZIndex = -1\n\nconst divStyle: React.CSSProperties = {\n\tdisplay: \"contents\",\n}\n\nconst iframeStyle: React.CSSProperties = {\n\tposition: \"absolute\",\n\ttop: 0,\n\tleft: 0,\n\twidth: \"100%\",\n\theight: \"100%\",\n\tborder: \"none\",\n\tzIndex: canvasSandboxZIndex,\n}\n\nconst HEARTBEAT_INTERVAL = 1000\n\n/**\n * Surfaces a canvas-sandbox failure to the user, Sentry, and telemetry.\n *\n * @param error The captured failure.\n * @param message User-facing toast text and Sentry/telemetry tag.\n * @param sandboxLog The renderer-scoped logger.\n */\nfunction reportCanvasSandboxFailure(\n\terror: Error,\n\t{ message, sandboxLog }: { message: string; sandboxLog: ReturnType<typeof getLogger> },\n): void {\n\tsandboxLog.reportCriticalError(error, { message })\n\trecord(\"application_error\", { area: ErrorArea.canvas, message })\n\ttoast({\n\t\ttype: \"add\",\n\t\tvariant: \"error\",\n\t\ttext: message,\n\t\tkey: \"canvas-sandbox-loading-error\",\n\t\ticon: \"error\",\n\t\tduration: Infinity,\n\t\taction: {\n\t\t\ttitle: \"Reload\",\n\t\t\tonClick: () => window.location.reload(),\n\t\t},\n\t})\n}\n\nfunction createCanvasSandbox(heartbeat: (msg: SandboxHeartbeat) => void, subWindow: Window | undefined) {\n\tconst log = getLogger(\"renderer:canvas\")\n\n\tconst {\n\t\tcanvasStore,\n\t\tchromeStore,\n\t\tscopeStore,\n\t\tdocumentSettingsStore,\n\t\teffectStore,\n\t\tfontPreviewStore,\n\t\taiGenerationStore,\n\t\ttoolStore,\n\t\toverlayStore,\n\t\tmodulesStore,\n\t\tselectionStore,\n\t\tloadingStore,\n\t\tfeedbackStore,\n\t\trepeaterStore,\n\t} = engine.stores\n\n\tlet sandbox: IFrameSandbox | PopupSandbox | undefined\n\tif (subWindow) {\n\t\tsandbox = new PopupSandbox(subWindow, RenderTarget.canvas, sandboxConfig.canvas)\n\t} else {\n\t\tsandbox = new IFrameSandbox(RenderTarget.canvas, sandboxConfig.canvas)\n\t}\n\tconst canvas = new SandboxRenderer(sandbox, {\n\t\tlog,\n\t\tengine,\n\t\twantsEngineUpdates: true,\n\t\thandleSandboxError,\n\t\theartbeat: heartbeat,\n\t\trenderState: () => {\n\t\t\tconst {\n\t\t\t\tzoom,\n\t\t\t\tliveZoom,\n\t\t\t\toffset: { x, y },\n\t\t\t} = canvasStore\n\t\t\tconst activeScope = scopeStore.active\n\t\t\treturn {\n\t\t\t\trenderScope: activeScope.id,\n\t\t\t\ttransform: [x, y, zoom, liveZoom, engine.inMoveToolAndHasMoved()],\n\t\t\t\tisDarkMode: documentSettingsStore.hasDarkAppearance,\n\t\t\t\tisPreviewActive: chromeStore.mainView === ActiveMainView.Preview,\n\t\t\t\teditor: {\n\t\t\t\t\tselection: selectionStore.ids,\n\t\t\t\t\tnodeInTextEditorId: toolStore.nodeInTextEditorId,\n\t\t\t\t\tnodesInEffectPreview: effectStore.nodesInEffectPreview,\n\t\t\t\t\tnodesInMoveToolRootFontSize: engine.getNodesInMoveToolRootFontSize(),\n\t\t\t\t\tactiveEffect: effectStore.activeEffect,\n\t\t\t\t\tactiveEffectIds: effectStore.activeEffectIds,\n\t\t\t\t\tfontPreviewByNodeId: fontPreviewStore.fontPreviewByNodeId,\n\t\t\t\t\tactiveOverlayNodes: overlayStore.activeOverlays,\n\t\t\t\t\tnodesWithPlaceholders: toolStore.nodesWithPlaceholders,\n\t\t\t\t\trootFontSize: getRootFontSize(activeScope, engine.tree, modulesStore) ?? null,\n\t\t\t\t\toptionalSelectedCollectionItemId: isWebPageNode(activeScope)\n\t\t\t\t\t\t? scopeStore.getSelectedCollectionItemForWebPage(activeScope)\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tshouldSetMinHeight: aiGenerationStore.isGeneratingPage(activeScope.id),\n\t\t\t\t\trepeatersShowingEmptyState: repeaterStore.repeatersShowingEmptyState,\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t})\n\n\tcanvas.onSandboxReady = () => {\n\t\tif (hasUnsafeSameOriginSandboxForTesting) {\n\t\t\ttoast({\n\t\t\t\ttype: \"add\",\n\t\t\t\tvariant: \"error\",\n\t\t\t\ttext: \"Canvas security has been disabled for performance testing.\",\n\t\t\t\tkey: \"canvas-security-disabled\",\n\t\t\t\ticon: \"error\",\n\t\t\t\tduration: Infinity,\n\t\t\t})\n\t\t}\n\n\t\tconst renderer = canvas.sandbox.renderer\n\t\t// `waitUntilResourcesLoaded()` resolves once the sandbox finishes\n\t\t// deferred rendering. The sandbox-side `ResolvablePromise` is only\n\t\t// ever resolved, never rejected \u2014 see `isLoadingResourcesPromise`\n\t\t// in `CanvasSandboxApp.ts`. Any rejection here is a structural RPC\n\t\t// failure (channel/method missing, serialization error), not a\n\t\t// canvas-loading failure, so surface via Sentry only.\n\t\trenderer\n\t\t\t.waitUntilResourcesLoaded()\n\t\t\t.then(() => {\n\t\t\t\tengine.stores.loadingStore.canvasSandboxResourcesLoadingState = LoadingState.loaded\n\t\t\t\tconst canvasLoadTime = Date.now() - getAppStartTime()\n\t\t\t\tmarkLoadingPerf(\"sandboxReady\")\n\t\t\t\tgetLogger(\"app\").info(`\uD83D\uDCD6 CanvasReady ${canvasLoadTime}ms (new renderer)`)\n\n\t\t\t\t// It sends the initial document load event\n\t\t\t\tloadDocumentMetrics.trackCanvasLoad(canvasLoadTime)\n\n\t\t\t\tpreloadProseMirror()\n\t\t\t})\n\t\t\t.catch(unhandledError)\n\n\t\tPromise.all([\n\t\t\trenderer.waitUntilFontsLoaded(),\n\t\t\trenderer.waitUntilPlaceholdersSettled(),\n\t\t\trenderer.waitUntilResourcesLoaded(),\n\t\t])\n\t\t\t.then(() => {\n\t\t\t\tmarkLoadingPerf(\"sandboxCanvasFirstRender\")\n\t\t\t\trecord(\"first_canvas_render\", { durationMs: Math.round(performance.now()) })\n\t\t\t})\n\t\t\t.catch(unhandledError)\n\t}\n\n\tcanvas.onSandboxStateChange = state => {\n\t\tloadingStore.canvasSandboxLoadingState = state\n\t\tfeedbackStore.canvasSandboxDidLoad(engine)\n\n\t\tif (state.isFinished) {\n\t\t\tmarkLoadingPerf(\"sandboxLoad\")\n\t\t}\n\n\t\tif (state.failure) {\n\t\t\treportCanvasSandboxFailure(state.failure, {\n\t\t\t\tmessage: \"Failed to load canvas\",\n\t\t\t\tsandboxLog: log,\n\t\t\t})\n\t\t}\n\t}\n\n\treturn canvas\n}\n\nconst GENERAL_TIMEOUT = 30_000\nconst EXTRA_HEARTBEAT_TIME_IF_DOCUMENT_HIDDEN = 10_000\nconst PERMANENT_HEARTBEAT_TIMEOUT = 60_000\nconst RECOVERY_TIME_AFTER_HEARTBEAT_TIMEOUT = 120_000\n\nconst enum SandboxFailedReason {\n\tInstallTimeout = \"sandbox not installed after 30 seconds\",\n\tConnectTimeout = \"sandbox not connected after 30 seconds\",\n\tHeartbeatTimeout = \"sandbox without first heartbeat after 30 seconds\",\n\tNextHeartbeatTimeout = \"sandbox failed to send next heartbeat\",\n\tPermanentHeartbeatTimeout = \"sandbox without heartbeat for 60 seconds\",\n}\n\n/** Manages the lifecycle of the canvas sandbox. */\nexport class CanvasSandboxController {\n\tprivate renderer: SandboxRenderer<IFrameSandbox | PopupSandbox>\n\n\t/** When enabled, sandbox errors will only be warnings. */\n\tdebugEnabled = false\n\t/** When in window mode, we open a popup window, and sandbox errors will only be warnings. */\n\tdebugSandboxInWindow = false\n\n\tprivate subWindow: Window | undefined = undefined\n\n\tprivate heartbeatInterval = 0\n\n\treloaded = 0\n\tprivate startTime = 0\n\tconnectTime = 0\n\tprivate installTime = 0\n\tprivate nextHeartbeatDeadline = 0\n\n\tprivate timeoutGracePeriod = 0\n\n\tprivate heartbeatStats = new HeartbeatStats()\n\n\tprivate lastRecoveryTime = 0\n\tprivate failed: Error | SandboxFailedReason | undefined = undefined\n\n\tstatic __shared: CanvasSandboxController | undefined = undefined\n\n\t/** Returns the shared static controller. Creating it if it does not yet exist. */\n\tstatic shared(): CanvasSandboxController {\n\t\tif (!CanvasSandboxController.__shared) {\n\t\t\tCanvasSandboxController.__shared = new CanvasSandboxController(engine)\n\t\t}\n\t\treturn CanvasSandboxController.__shared\n\t}\n\n\t/** Returns the static shared controller. Or undefined if it does not exist. */\n\tstatic getShared(): CanvasSandboxController | undefined {\n\t\treturn CanvasSandboxController.__shared\n\t}\n\n\tconstructor(readonly engine: VekterEngine) {\n\t\tconst savedWindowMode = localStorage.getItem(debugBarSandboxWindowModeKey)\n\t\tif (savedWindowMode === \"window\" && engine.stores.sessionStore.user.isFramerEmployee) {\n\t\t\tthis.debugSandboxInWindow = true\n\t\t}\n\t\tthis.renderer = this.createSandbox()\n\t}\n\n\tdebugConnect(onMessage: (msg: Message) => Promise<unknown>): Promise<void> {\n\t\treturn this.renderer.sandbox.controller.debugConnect(onMessage)\n\t}\n\n\tprivate shouldTryToRecover() {\n\t\t// Either after a heartbeat timeout.\n\t\tif (this.failed === SandboxFailedReason.PermanentHeartbeatTimeout) {\n\t\t\tif (this.lastRecoveryTime === 0) return true\n\t\t\tif (performance.now() - this.lastRecoveryTime > RECOVERY_TIME_AFTER_HEARTBEAT_TIMEOUT) return true\n\t\t\treturn false\n\t\t}\n\n\t\t// Or if the first connect failed or first heartbeat failed.\n\t\tif (this.lastRecoveryTime > 0) return false\n\t\tif (this.failed === SandboxFailedReason.ConnectTimeout) return true\n\t\tif (this.failed === SandboxFailedReason.HeartbeatTimeout) return true\n\t\treturn false\n\t}\n\n\tisDebugging() {\n\t\treturn this.debugEnabled || this.debugSandboxInWindow\n\t}\n\n\tprivate clearFailure() {\n\t\tthis.failed = undefined\n\t\ttoast({ type: \"remove\", key: \"canvas-sandbox-failed-error\" })\n\t}\n\n\tprivate fail(reason: Error | SandboxFailedReason) {\n\t\tif (this.failed) {\n\t\t\tlog.debug(\"repeated fail:\", reason)\n\t\t\treturn\n\t\t}\n\n\t\tlog.debug(\"failed:\", reason)\n\t\tthis.failed = reason\n\n\t\tif (this.isDebugging()) {\n\t\t\ttoast({\n\t\t\t\ttype: \"add\",\n\t\t\t\tvariant: \"info\",\n\t\t\t\ttext: `Debug: ${reason}`,\n\t\t\t\tkey: \"canvas-sandbox-failed-error\",\n\t\t\t\tduration: Infinity,\n\t\t\t})\n\t\t} else if (reason === SandboxFailedReason.NextHeartbeatTimeout) {\n\t\t\treportCanvasUnresponsive(this.heartbeatStats)\n\t\t} else if (this.shouldTryToRecover()) {\n\t\t\tlog.info(\"trying to reload sandbox after failure\")\n\t\t\tthis.lastRecoveryTime = performance.now()\n\t\t\tthis.clearFailure()\n\t\t\tthis.recreate()\n\t\t} else {\n\t\t\tlet message = \"Failed to load canvas\"\n\t\t\tif (reason === SandboxFailedReason.PermanentHeartbeatTimeout) {\n\t\t\t\tmessage = \"Canvas stopped responding\"\n\t\t\t}\n\n\t\t\t// Check if we're in tunnel mode and the failure is likely due to 3rd party cookie blocking\n\t\t\tconst isConnectionFailure =\n\t\t\t\treason === SandboxFailedReason.ConnectTimeout || reason === SandboxFailedReason.InstallTimeout\n\t\t\tconst tunnelId = getTunnelId()\n\t\t\tif (isConnectionFailure && tunnelId) {\n\t\t\t\tmessage = \"Failed to load canvas. This may be caused by third-party cookies being blocked.\"\n\t\t\t\tconst cookieProblemUrl =\n\t\t\t\t\t\"https://www.notion.so/framer/Getting-Started-with-FramerStudio-e6ad2dfecf094d14980eb70150932b16?source=copy_link#1f8adf6e8c96804e87dadbe35dcdb28e\"\n\t\t\t\tthis.engine.canvasSandboxFailed(reason)\n\t\t\t\tlog.reportCriticalError(reason, { message, tunnelId, possibleCookieBlocking: true })\n\t\t\t\trecord(\"application_error\", { area: ErrorArea.canvas, message })\n\t\t\t\ttoast({\n\t\t\t\t\ttype: \"add\",\n\t\t\t\t\tvariant: \"error\",\n\t\t\t\t\ttext: message,\n\t\t\t\t\tkey: \"canvas-sandbox-failed-error\",\n\t\t\t\t\tduration: Infinity,\n\t\t\t\t\taction: {\n\t\t\t\t\t\ttitle: \"Learn more\",\n\t\t\t\t\t\tonClick: () => openNewTab(cookieProblemUrl),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.engine.canvasSandboxFailed(reason)\n\t\t\tlog.reportCriticalError(reason, { message })\n\t\t\trecord(\"application_error\", { area: ErrorArea.canvas, message })\n\t\t\ttoast({\n\t\t\t\ttype: \"add\",\n\t\t\t\tvariant: \"error\",\n\t\t\t\ttext: message,\n\t\t\t\tkey: \"canvas-sandbox-failed-error\",\n\t\t\t\tduration: Infinity,\n\t\t\t\taction: {\n\t\t\t\t\ttitle: \"Reload\",\n\t\t\t\t\tonClick: () => window.location.reload(),\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate lastHeartbeatTickTime = 0\n\tprivate startHeartbeatInterval() {\n\t\tif (this.heartbeatInterval) return\n\t\tthis.lastHeartbeatTickTime = performance.now()\n\t\tthis.heartbeatInterval = window.setInterval(this.tickHeartbeat, HEARTBEAT_INTERVAL)\n\t}\n\n\tprivate stopHeartbeatInterval() {\n\t\tif (!this.heartbeatInterval) return\n\t\twindow.clearInterval(this.heartbeatInterval)\n\t\tthis.heartbeatInterval = 0\n\t}\n\n\tprivate tickHeartbeat = () => {\n\t\tif (this.startTime <= 0) {\n\t\t\tlog.warn(\"heartbeat tick without start\")\n\t\t\treturn\n\t\t}\n\n\t\tconst now = performance.now()\n\t\tconst delta = now - this.lastHeartbeatTickTime - HEARTBEAT_INTERVAL\n\t\tthis.lastHeartbeatTickTime = now\n\n\t\tif (delta > 0) {\n\t\t\tif (delta > 1000) {\n\t\t\t\tlog.debug(\"heartbeat tick delayed by:\", delta)\n\t\t\t}\n\t\t\tthis.timeoutGracePeriod += delta\n\t\t\tif (this.nextHeartbeatDeadline > 0) {\n\t\t\t\tthis.nextHeartbeatDeadline += delta\n\t\t\t}\n\t\t}\n\n\t\t// If failed from a heartbeat, we might recover, or might permanently fail.\n\t\tif (this.failed === SandboxFailedReason.NextHeartbeatTimeout) {\n\t\t\t// We clear the NEXT_HEARTBEAT_TIMEOUT state if we do receive a next heartbeat.\n\t\t\tif (now < this.nextHeartbeatDeadline) {\n\t\t\t\tlog.debug(\"clearing heartbeat timeout failure\")\n\t\t\t\tthis.clearFailure()\n\t\t\t} else if (now - this.nextHeartbeatDeadline > PERMANENT_HEARTBEAT_TIMEOUT) {\n\t\t\t\tlog.debug(\"heartbeat failure becoming permanent\")\n\t\t\t\tthis.clearFailure()\n\t\t\t\tthis.fail(SandboxFailedReason.PermanentHeartbeatTimeout)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tif (this.failed) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.installTime <= 0) {\n\t\t\tif (now - this.startTime > GENERAL_TIMEOUT + this.timeoutGracePeriod) {\n\t\t\t\tthis.fail(SandboxFailedReason.InstallTimeout)\n\t\t\t}\n\t\t} else if (this.connectTime <= 0) {\n\t\t\tif (now - this.startTime > GENERAL_TIMEOUT + this.timeoutGracePeriod) {\n\t\t\t\tthis.fail(SandboxFailedReason.ConnectTimeout)\n\t\t\t}\n\t\t} else if (this.nextHeartbeatDeadline <= 0) {\n\t\t\t// TODO: currently the sandbox starts its heartbeat after the first update. But if\n\t\t\t// vekter itself has an error, nothing will update the sandbox, and this error mode will\n\t\t\t// trigger. For now we allow being in this mode. When we remove old rpc and old\n\t\t\t// sandboxes, we should always have the sandbox send heartbeats.\n\t\t\t//\n\t\t\t// if (now - this.startTime > GENERAL_TIMEOUT) {\n\t\t\t// this.fail(SandboxFailedReason.HeartbeatTimeout)\n\t\t\t// }\n\t\t} else if (now > this.nextHeartbeatDeadline) {\n\t\t\tif (document.hidden && now - this.nextHeartbeatDeadline < EXTRA_HEARTBEAT_TIME_IF_DOCUMENT_HIDDEN) return\n\t\t\tthis.fail(SandboxFailedReason.NextHeartbeatTimeout)\n\t\t} else if (this.failed === SandboxFailedReason.NextHeartbeatTimeout) {\n\t\t\tthis.clearFailure()\n\t\t}\n\t}\n\n\tprivate handleHeartbeat = (msg: SandboxHeartbeat) => {\n\t\tconst now = performance.now()\n\t\tconst { debugStore } = this.engine.stores\n\t\tthis.heartbeatStats.updateVitals(msg.vitals)\n\t\tthis.nextHeartbeatDeadline = now + msg.next * 1.5\n\n\t\tdebugStore.addSandboxMemoryReport(this.heartbeatStats)\n\t\tdebugStore.setSandboxDomNodes(this.heartbeatStats.domNodes)\n\t}\n\n\tprivate createSandbox(): SandboxRenderer<IFrameSandbox | PopupSandbox> {\n\t\tthis.startHeartbeatInterval()\n\t\tthis.startTime = performance.now()\n\t\tthis.engine.canvasSandboxRestart()\n\n\t\tlog.debug(\"Creating sandbox in\", this.debugSandboxInWindow ? \"window\" : \"iframe\")\n\t\tif (this.debugSandboxInWindow && (!this.subWindow || this.subWindow.closed)) {\n\t\t\tconst subWindow = window.open(undefined, undefined, \"popup=true\")\n\t\t\tif (!subWindow) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"IFrameSandbox: failed to open sub window. Allow popups for this site and reload to use window mode.\",\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis.subWindow = subWindow\n\t\t}\n\n\t\tconst renderer = createCanvasSandbox(this.handleHeartbeat, this.subWindow)\n\t\trenderer.sandbox.controller\n\t\t\t.waitUntilConnected()\n\t\t\t.then(() => {\n\t\t\t\tlog.debug(\"Sandbox connected\")\n\t\t\t\tthis.connectTime = performance.now()\n\t\t\t\tthis.engine.canvasSandboxStarted(renderer)\n\t\t\t\trenderer.onSandboxRender = update => {\n\t\t\t\t\tthis.engine.canvasSandboxDidRender(update)\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(error => {\n\t\t\t\tlog.debug(\"Sandbox connection failed:\", error)\n\t\t\t\tthis.fail(error)\n\t\t\t})\n\n\t\tthis.reloaded += 1\n\t\tthis.onReload?.(this.reloaded)\n\n\t\treturn renderer\n\t}\n\n\tonReload: ((count: number) => void) | undefined = undefined\n\n\trecreate(target?: \"iframe\" | \"window\") {\n\t\tif (target && this.engine.stores.sessionStore.user.isFramerEmployee) {\n\t\t\tthis.debugSandboxInWindow = target === \"window\"\n\t\t}\n\n\t\t// Reset state.\n\t\tthis.startTime = 0\n\t\tthis.connectTime = 0\n\t\tthis.installTime = 0\n\t\tthis.nextHeartbeatDeadline = 0\n\t\tthis.timeoutGracePeriod = 0\n\n\t\t// Disconnect any old renderer callbacks.\n\t\tthis.renderer.onSandboxRender = undefined\n\t\tthis.renderer.onSandboxStateChange = undefined\n\n\t\t// And remove it from the DOM if it was installed.\n\t\tthis.uninstall()\n\n\t\t// Then create a new sandbox.\n\t\tthis.renderer = this.createSandbox()\n\t}\n\n\tinstall(element: HTMLElement, style: React.CSSProperties) {\n\t\tthis.installTime = performance.now()\n\t\tthis.startHeartbeatInterval()\n\t\tlog.debug(\"Installing sandbox\")\n\t\tthis.renderer.sandbox.addIFrameToElement(element, style)\n\t}\n\n\tuninstall() {\n\t\tlog.debug(\"Uninstalling sandbox\")\n\t\tthis.stopHeartbeatInterval()\n\t\tthis.renderer.sandbox.removeIFrameFromElement()\n\t\tif (this.subWindow) {\n\t\t\tthis.subWindow.close()\n\t\t\tthis.subWindow = undefined\n\t\t}\n\t}\n\n\thide() {\n\t\tlog.debug(\"hiding sandbox\")\n\t\tthis.renderer.sandbox.hideIFrame()\n\t}\n}\n\nexport const CanvasSandboxRenderer: React.FunctionComponent = React.memo(function CanvasSandboxRenderer() {\n\tconst divRef = useRef<HTMLIFrameElement>(null)\n\tconst [reloadCounter, setReloadCounter] = useState(0)\n\tCanvasSandboxController.shared().onReload = setReloadCounter\n\n\tuseEffect(() => {\n\t\tconst div = divRef.current\n\t\tif (!div) return\n\n\t\t// Note: the main canvas sandbox is 1) a document content renderer and 2) a compiler and\n\t\t// provider of component metadata and autolayout. It needs to be stable and available\n\t\t// independent of the app UI state.\n\t\tCanvasSandboxController.shared().install(document.body, iframeStyle)\n\t\treturn () => CanvasSandboxController.shared().hide()\n\t}, [reloadCounter])\n\n\treturn (\n\t\t<div ref={divRef} style={divStyle}>\n\t\t\t<EmployeesOnlySettings isOn=\"sandboxNodeDebugging\">\n\t\t\t\t<DebugNodeRenderer />\n\t\t\t</EmployeesOnlySettings>\n\t\t</div>\n\t)\n})\n\nconst HEARTBEAT_HISTORY_LENGTH = 12 // Two minutes in the happy case\n\nexport class HeartbeatStats {\n\tmemoryTotal = 0\n\tmemoryUsed = 0\n\tmemoryLimit = 0\n\theartbeatAverage = 0\n\tlatestHeartbeat = 0\n\tdomNodes = 0\n\n\tlastUpdate = 0\n\tupdateHistory: number[] = []\n\tupdateAverage = 0\n\n\tupdateVitals(vitals: SandboxHeartbeatVitals) {\n\t\tconst { memoryTotal, memoryUsed, memoryLimit, domNodes } = vitals\n\t\tif (isNumber(memoryTotal) && isNumber(memoryUsed) && isNumber(memoryLimit)) {\n\t\t\tthis.memoryTotal = memoryTotal\n\t\t\tthis.memoryUsed = memoryUsed\n\t\t\tthis.memoryLimit = memoryLimit\n\t\t}\n\t\tif (isNumber(domNodes)) {\n\t\t\tthis.domNodes = domNodes\n\t\t}\n\n\t\tconst now = performance.now()\n\t\tif (this.lastUpdate > 0) {\n\t\t\tthis.updateHistory.push(now - this.lastUpdate)\n\t\t\tif (this.updateHistory.length > HEARTBEAT_HISTORY_LENGTH) {\n\t\t\t\tthis.updateHistory.shift()\n\t\t\t}\n\t\t\tthis.updateAverage = this.updateHistory.reduce((a, b) => a + b, 0) / this.updateHistory.length\n\t\t}\n\t\tthis.lastUpdate = now\n\t}\n}\n\nconst canvasUnresponsiveMessage = \"Canvas is unresponsive\"\n\nfunction reportCanvasUnresponsive(stats: HeartbeatStats) {\n\tlog.reportError(new Error(canvasUnresponsiveMessage), { stats })\n\tconst {\n\t\tmemoryTotal: sandboxMemoryTotal,\n\t\tmemoryUsed: sandboxMemoryUsed,\n\t\tmemoryLimit: sandboxMemoryLimit,\n\t\theartbeatAverage: sandboxHeartbeatAverage,\n\t\tlatestHeartbeat: sandboxLatestHeartbeat,\n\t\tdomNodes: sandboxDomNodes,\n\t} = stats\n\trecord(\"canvas_unresponsive\", {\n\t\tsandboxMemoryTotal,\n\t\tsandboxMemoryUsed,\n\t\tsandboxMemoryLimit,\n\t\tsandboxHeartbeatAverage,\n\t\tsandboxLatestHeartbeat,\n\t\tsandboxDomNodes,\n\t})\n}\n\n// Extract component name from stack trace: https://regex101.com/r/aBKN58/1\nconst stackErrorSourceRegExp = /^\\s*(?:at|in) (\\S+)/\n\n/** In most cases does nothing. But if it is a GroundNodeErrorBoundary, it will show a toast. */\nfunction handleSandboxError(error: SandboxError) {\n\tif (error.type === \"GroundNodeErrorBoundary\") {\n\t\t// Detect when user returned a non-function in a\n\t\t// useEffect. Since ground nodes should rarely crash, we\n\t\t// show a toast linking to a help article.\n\t\tif (error.message.includes(\"is not a function\")) {\n\t\t\tlet text = \"We detected a problem in one of your code components/overrides\"\n\t\t\tconst match = error.stack?.match(stackErrorSourceRegExp)\n\t\t\tif (match) {\n\t\t\t\ttext += ` (${match[1]})`\n\t\t\t}\n\n\t\t\ttoast({\n\t\t\t\ttype: \"add\",\n\t\t\t\tvariant: \"error\",\n\t\t\t\ttext,\n\t\t\t\tkey: `ground-node-crash-not-a-function-${match?.[1]}`,\n\t\t\t\tduration: Infinity,\n\t\t\t\taction: {\n\t\t\t\t\ttitle: \"Learn more\",\n\t\t\t\t\tonClick() {\n\t\t\t\t\t\topenNewTab(\"https://www.framer.com/learn/destroy-is-not-a-function/\")\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t}\n}\n", "import { getLogger } from \"@framerjs/shared\"\nimport { CanvasTreeVersion } from \"document/models/CanvasTree/CanvasTreeVersion.ts\"\nimport type { RenderTarget } from \"library/render/types/RenderEnvironment.ts\"\nimport { sandboxInterface } from \"utils/rpc/shared/definitions.ts\"\nimport { SandboxRPC } from \"./SandboxRPC.ts\"\nimport type { SandboxConfig } from \"./sandboxConfig.ts\"\n\nconst log = getLogger(\"PopupSandbox\")\n\nexport class PopupSandbox extends SandboxRPC {\n\tprivate loaded = false\n\n\tconstructor(\n\t\tprivate readonly subWindow: Window,\n\t\tprivate readonly renderTarget: RenderTarget,\n\t\tprivate readonly config: SandboxConfig,\n\t) {\n\t\tsuper()\n\t}\n\n\tasync connect(): Promise<void> {\n\t\tif (this.loaded) return\n\n\t\tlog.debug(\"popup.connect\")\n\n\t\tthis.loaded = true\n\t\ttry {\n\t\t\t// This will immediately postMessage the popup, which is unlikely to be listening\n\t\t\t// because it is still loading. But it will also listen for the popup to connect with\n\t\t\t// postMessage. And the connection is established as fast as possible.\n\t\t\tawait this.controller.connect({ target: this.subWindow, url: this.config.origin })\n\t\t\tawait this.controller\n\t\t\t\t.getRemote(sandboxInterface.channels.renderer)\n\t\t\t\t.initialize(CanvasTreeVersion, this.renderTarget)\n\t\t} catch (error) {\n\t\t\tlog.error(\"IFrameSandbox.onLoad():\", error)\n\t\t}\n\t}\n\n\taddIFrameToElement() {\n\t\tlog.debug(\"popup.addIFrameToElement\")\n\t\tthis.subWindow.location.href = this.config.url\n\t\tvoid this.connect()\n\t}\n\n\tremoveIFrameFromElement() {}\n\n\thideIFrame() {}\n}\n", "import { getLogger, reportableError } from \"@framerjs/shared\"\nimport { GloballyHandledError } from \"app/GlobalErrorHandler.ts\"\nimport { fatalError, recoverFromError } from \"document/VekterEngineErrorRecovery.ts\"\nimport engine from \"document/engine.ts\"\nimport { FrameNode } from \"document/models/CanvasTree/index.ts\"\nimport { isHiddenMaster } from \"document/models/CanvasTree/traits/WithTemplate.ts\"\n\nconst logger = getLogger(\"debug:crash\")\n\nfunction crashByException() {\n\tthrow Error(\"CrashTest\")\n}\n\nfunction crashByBrokenTree() {\n\tfor (const node of engine.tree.root.children) {\n\t\tif (isHiddenMaster(node)) continue\n\t\tengine.tree.unsafeRemoveId(node.id)\n\t\tbreak\n\t}\n}\n\nfunction crashWithOutOfMemory() {\n\tlet crashingArray = new Array(1_000_000_000).fill(0)\n\tcrashingArray = crashingArray.map((el, index) => \"crash\".repeat(index))\n\treturn void crashingArray\n}\n\nfunction crashByBrokenTreeAfterTimer() {\n\tsetTimeout(crashByBrokenTree, 50)\n}\n\nfunction crashByChangingNodeChildren() {\n\tengine.tree.root.children.push(new FrameNode())\n}\n\nfunction crashByDeletingAllNodes() {\n\tfor (const screen of engine.tree.root.children) {\n\t\tengine.tree.removeNode(screen)\n\t}\n}\n\nfunction crashByRiggingTreeStore() {\n\tengine.stores.treeStore.crashSoon = true\n}\n\nfunction crashByCorruptingUndoEntries() {\n\tconst bad: any = { changes: \"undefined\", selection: undefined }\n\tengine.stores.undoRedoManager.addUndoEntry(bad)\n}\n\nfunction crashByRiggingRemoteDocument() {\n\tengine.remoteDocument?.debugCrash()\n}\n\nfunction crashByFatalError() {\n\tthrow fatalError(engine, \"Crash by fatal error.\", new Error(\"CrashTest\"))\n}\n\nfunction crashInRecoveryBlock() {\n\ttry {\n\t\tengine.scheduler.process((): void => {\n\t\t\tthrow Error(\"CrashInRecoveryBlockTest\")\n\t\t})\n\t} catch (error) {\n\t\trecoverFromError(engine, reportableError(error))\n\t}\n}\n\nfunction crashByErrorInMicroTask() {\n\tqueueMicrotask(() => {\n\t\tthrow Error(\"CrashByErrorInMicroTask\")\n\t})\n}\n\nfunction crashByReportingErrorInMicroTask() {\n\tqueueMicrotask(() => {\n\t\tthrow new GloballyHandledError(\"crashByReportingErrorInMicroTaskTest\")\n\t})\n}\n\nfunction reportError() {\n\tlogger.reportError(new Error(\"CrashTest\"))\n}\n\nfunction reportCriticalError() {\n\tlogger.reportCriticalError(new Error(\"CrashTest\"))\n}\n\nexport const crashFunctionNames = [\n\t\"crashByException\",\n\t\"crashByBrokenTree\",\n\t\"crashByBrokenTreeAfterTimer\",\n\t\"crashByChangingNodeChildren\",\n\t\"crashByDeletingAllNodes\",\n\t\"crashByCorruptingUndoEntries\",\n\t\"crashByRiggingTreeStore\",\n\t\"crashByRiggingRemoteDocument\",\n\t\"crashByFatalError\",\n\t\"crashInRecoveryBlock\",\n\t\"crashByErrorInMicroTask\",\n\t\"crashByReportingErrorInMicroTask\",\n\t\"crashWithOutOfMemory\",\n\t\"reportError\",\n\t\"reportCriticalError\",\n] as const\n\nexport type CrashFunctionName = (typeof crashFunctionNames)[number]\n\nexport const crashFunctions: Record<CrashFunctionName, () => void> = {\n\tcrashByException,\n\tcrashByBrokenTree,\n\tcrashByBrokenTreeAfterTimer,\n\tcrashByChangingNodeChildren,\n\tcrashByDeletingAllNodes,\n\tcrashByCorruptingUndoEntries,\n\tcrashByRiggingTreeStore,\n\tcrashByRiggingRemoteDocument,\n\tcrashByFatalError,\n\tcrashInRecoveryBlock,\n\tcrashByErrorInMicroTask,\n\tcrashByReportingErrorInMicroTask,\n\tcrashWithOutOfMemory,\n\treportError,\n\treportCriticalError,\n}\n\nexport function crash() {\n\tconst name = crashFunctionNames[Math.floor(Math.random() * crashFunctionNames.length)]\n\tif (!name) throw new Error(\"No crash function name\")\n\tconst fn = crashFunctions[name]\n\t// biome-ignore lint/suspicious/noConsole: <explanation>\n\tconsole.warn(\"testing crash handling: \" + name)\n\tfn()\n}\n", "import { IconAgentPlusLarge, Stack, useScrollOffsetRestorationCache } from \"@framerjs/fresco\"\nimport { dimensions } from \"@framerjs/fresco/tokens\"\nimport { unhandledError } from \"@framerjs/shared\"\nimport { emptyArray } from \"@framerjs/shared/src/emptyArray.ts\"\nimport { cx } from \"@linaria/core\"\nimport type { AgentAttachmentFile, AgentAttachmentImage } from \"app/agent/attachments.ts\"\nimport { AgentButton } from \"app/agent/components/AgentButton/AgentButton.tsx\"\nimport type { AgentInputSegment } from \"app/agent/editor/agentInputSchema.ts\"\nimport { useAgent } from \"app/agent/hooks/useAgent.ts\"\nimport type { AgentContextUsage, AgentID } from \"app/ai/agents/Agent.ts\"\nimport { getPendingClarificationQuestions } from \"app/ai/agents/getPendingClarificationQuestions.ts\"\nimport type { ClarificationAnswer } from \"app/ai/agents/tools/askClarification.ts\"\nimport type { AgentRequest } from \"app/ai/agents/types.ts\"\nimport { isAiDisabled } from \"app/ai/config/disableAi.ts\"\nimport type { LanguageModel } from \"app/ai/languageModels.ts\"\nimport type { AgentReasoningEffort } from \"app/ai/models.ts\"\nimport { Dictionary } from \"app/dictionary.ts\"\nimport type { MenuItemOptions } from \"app/menu.ts\"\nimport { ToolbarTooltip, useToolbarTooltipVariant } from \"document/components/chrome/projectbar/ToolbarTooltip.tsx\"\nimport {\n\tisAiDailyCreditLimitReached,\n\tisAiMonthlyCreditLimitReached,\n} from \"document/components/chrome/shared/UpsellModal/utils/aiCreditsUpsell.ts\"\nimport { dataIsAgentChatPanelDataAttribute } from \"document/components/chrome/shared/chromeHitTargets.ts\"\nimport { useIsCrdt } from \"document/crdt/useIsCrdt.ts\"\nimport engine from \"document/engine.ts\"\nimport type { LoadedScopeNode, NodeID } from \"document/models/CanvasTree/index.ts\"\nimport { isWebPageNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport { withBreakpointVariants } from \"document/models/CanvasTree/traits/WithBreakpointVariants.ts\"\nimport { withReplicaVariants } from \"document/models/CanvasTree/traits/WithReplicaVariants.ts\"\nimport { useEngineState } from \"document/useEngineState.ts\"\nimport { ActiveMainView } from \"document/utils/ActiveEditorType.ts\"\nimport { ModalType } from \"document/utils/ModalType.ts\"\nimport { getFramerRelease } from \"environment/getFramerRelease.ts\"\nimport React, { useCallback, useEffect, useState } from \"react\"\nimport { isNumber } from \"utils/typeChecks.ts\"\nimport { useIsViewOnly } from \"web/pages/project/permissions/useIsViewOnly.ts\"\nimport * as styles from \"./AgentChatPanel.styles.ts\"\nimport { AgentChatAiDisabledBlock } from \"./components/AgentChatAiDisabledBlock.tsx\"\nimport { AgentChatCrdtDisabledBlock } from \"./components/AgentChatCrdtDisabledBlock.tsx\"\nimport { AgentChatCreditLimitBlock } from \"./components/AgentChatCreditLimitBlock.tsx\"\nimport { AgentChatInput } from \"./components/AgentChatInput.tsx\"\nimport { AgentChatMessages } from \"./components/AgentChatMessages.tsx\"\nimport { AgentChatPicker } from \"./components/AgentChatPicker.tsx\"\nimport { AgentChatQuestions } from \"./components/AgentChatQuestions.tsx\"\nimport { AgentChatReleaseChannelBlock } from \"./components/AgentChatReleaseChannelBlock.tsx\"\nimport { AgentPromptQueue } from \"./components/AgentPromptQueue.tsx\"\n\nexport interface AgentSelectionMode {\n\tenabled: boolean\n\tsetEnabled: (enabled: boolean) => void\n}\n\nexport const AgentChatPanel = React.memo(function AgentChatPanel({\n\tselectionMode,\n}: {\n\tselectionMode?: AgentSelectionMode\n}) {\n\tconst isViewOnly = useIsViewOnly(\"canDesign\")\n\n\tconst [activeAgentId, editingQueueItemId, followMode] = engine.stores.agentStore.useState(state => {\n\t\tconst agentId = state.activeChatAgentId\n\t\tconst editingId = agentId ? (state.editingQueueItemIds[agentId] ?? null) : null\n\t\tconst followEnabled = agentId ? state.followModeAgentId === agentId : false\n\t\treturn [agentId, editingId, followEnabled] as const\n\t})\n\n\tuseEffect(() => {\n\t\tengine.scheduler.runBeforeNextFrame(() => {\n\t\t\tvoid engine.stores.agentStore.hydratePersistedAgents().catch(unhandledError)\n\t\t})\n\t}, [])\n\n\tconst agents = useEngineState(\n\t\t() => Array.from(engine.stores.agentStore.agents.values()),\n\t\t[],\n\t\t[engine.stores.agentStore],\n\t\t{\n\t\t\tdeepEqual: true,\n\t\t},\n\t)\n\n\tconst activeScopeId = useEngineState(() => engine.stores.scopeStore.active.id, [], [engine.stores.scopeStore])\n\n\tconst { agent: activeAgent, userMessageCount, getUserMessageParts } = useAgent(activeAgentId)\n\tconst clarificationQuestions = getPendingClarificationQuestions(activeAgent?.chatMessages)\n\tconst contextUsage =\n\t\tactiveAgent?.contextUsage ?? getLatestCompletedRequestContextUsage(activeAgent?.chatMessages ?? emptyArray())\n\n\tconst scrollOffsetRestorationCache = useScrollOffsetRestorationCache()\n\tconst [resetAutoScrollKey, setResetAutoScrollKey] = useState(0)\n\n\t// Clears the editing UI state without touching the queue. Callers are responsible\n\t// for calling resumeQueue / submitImmediately / removeFromQueue as needed so that\n\t// the queue mutation happens before (or instead of) an automatic drain.\n\tconst clearEditing = useCallback(() => {\n\t\tif (!activeAgent || !editingQueueItemId) return\n\t\tengine.stores.agentStore.clearEditingQueueItemId(activeAgent.id)\n\t\tengine.stores.agentStore.prefillChatInput(activeAgent.id, [], [], [])\n\t}, [activeAgent, editingQueueItemId])\n\n\tconst clearEditingAndResume = useCallback(() => {\n\t\tif (!activeAgent || !editingQueueItemId) return\n\t\tclearEditing()\n\t\tactiveAgent.resumeQueue()\n\t}, [activeAgent, editingQueueItemId, clearEditing])\n\n\tconst handleSelectAgent = useCallback((agentId: AgentID) => {\n\t\tengine.stores.agentStore.activeChatAgentId = agentId\n\t}, [])\n\n\tconst handleNewChat = useCallback(() => {\n\t\tengine.stores.agentStore.activeChatAgentId = undefined\n\t\tengine.stores.chromeStore.focusAgentChatInput?.()\n\t}, [])\n\n\tconst [aiCreditLimitReached, aiDailyLimitReached, aiDisabled] = useEngineState(\n\t\t() =>\n\t\t\t[\n\t\t\t\tisAiDailyCreditLimitReached(engine) || isAiMonthlyCreditLimitReached(engine),\n\t\t\t\tisAiDailyCreditLimitReached(engine),\n\t\t\t\tisAiDisabled(engine),\n\t\t\t] as const,\n\t\t[],\n\t\t[engine.stores.projectStore, engine.stores.sessionStore],\n\t)\n\tconst hasCrdtEnabled = useIsCrdt()\n\tconst isAlphaChannel = getFramerRelease(window)?.channel === \"alpha\" || getFramerRelease(window)?.channel === \"local\"\n\n\tconst sessionState = activeAgent?.state ?? \"idle\"\n\tconst pendingPrompts = activeAgent?.queuedPrompts ?? emptyArray()\n\tconst shouldUseToolbarTooltip = useToolbarTooltipVariant() === \"toolbar\"\n\n\tconst handlePromptSubmit = useCallback(\n\t\t(\n\t\t\tparts: readonly AgentInputSegment[],\n\t\t\tmodel: LanguageModel,\n\t\t\treasoningEffort: AgentReasoningEffort,\n\t\t\timages: readonly AgentAttachmentImage[],\n\t\t\tfiles: readonly AgentAttachmentFile[],\n\t\t) => {\n\t\t\tif (isViewOnly) return\n\n\t\t\tif (editingQueueItemId && activeAgent) {\n\t\t\t\tactiveAgent.updateQueueItem(editingQueueItemId, parts, images, model, reasoningEffort, files)\n\t\t\t\tclearEditingAndResume()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst activeScope = engine.stores.scopeStore.active\n\t\t\tconst canvasSelection = getImplicitSelectionForAgent(activeScope)\n\n\t\t\tif (activeAgent?.isBusy || !!activeAgent?.queuedPrompts?.length) {\n\t\t\t\tactiveAgent.enqueuePrompt(parts, images, model, reasoningEffort, canvasSelection, files)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tsetResetAutoScrollKey(key => key + 1)\n\t\t\tif (!activeAgent) {\n\t\t\t\tconst newAgent = engine.stores.agentStore.create({\n\t\t\t\t\tscopeId: activeScope.id,\n\t\t\t\t})\n\n\t\t\t\tengine.stores.agentStore.activeChatAgentId = newAgent.id\n\t\t\t\tvoid newAgent.send(parts, canvasSelection, model, reasoningEffort, images, files)\n\t\t\t} else {\n\t\t\t\tactiveAgent.retryLastRequest()\n\t\t\t\tvoid activeAgent.send(parts, canvasSelection, model, reasoningEffort, images, files)\n\t\t\t}\n\t\t},\n\t\t[activeAgent, editingQueueItemId, clearEditingAndResume, isViewOnly],\n\t)\n\n\tconst sendFirstQueuedPrompt = useCallback(() => {\n\t\tif (isViewOnly) return\n\t\tif (!activeAgent || editingQueueItemId) return\n\t\tconst firstPrompt = activeAgent.queuedPrompts[0]\n\t\tif (!firstPrompt) return\n\t\tsetResetAutoScrollKey(key => key + 1)\n\t\tactiveAgent.submitImmediately(firstPrompt.id)\n\t}, [activeAgent, editingQueueItemId, isViewOnly])\n\n\tconst handleQueueEdit = useCallback(\n\t\t(id: string) => {\n\t\t\tif (isViewOnly) return\n\t\t\tif (!activeAgent) return\n\t\t\tconst item = activeAgent.queuedPrompts.find(p => p.id === id)\n\t\t\tif (!item) return\n\t\t\tengine.stores.agentStore.setEditingQueueItemId(activeAgent.id, id)\n\t\t\tactiveAgent.pauseQueue()\n\t\t\tengine.stores.agentStore.prefillChatInput(\n\t\t\t\tactiveAgent.id,\n\t\t\t\titem.parts,\n\t\t\t\titem.images,\n\t\t\t\titem.files,\n\t\t\t\titem.model,\n\t\t\t\titem.reasoningEffort,\n\t\t\t)\n\t\t},\n\t\t[activeAgent, isViewOnly],\n\t)\n\n\tconst handleQueueSubmitImmediately = useCallback(\n\t\t(id: string) => {\n\t\t\tif (isViewOnly) return\n\t\t\tif (!activeAgent) return\n\t\t\tif (editingQueueItemId === id) clearEditing()\n\n\t\t\tsetResetAutoScrollKey(key => key + 1)\n\t\t\tconst shouldResumeQueue = !editingQueueItemId || editingQueueItemId === id\n\t\t\tactiveAgent.submitImmediately(id, shouldResumeQueue)\n\t\t},\n\t\t[activeAgent, editingQueueItemId, clearEditing, isViewOnly],\n\t)\n\n\tconst handleClarificationSubmit = useCallback(\n\t\t(answers: ClarificationAnswer[]) => {\n\t\t\tif (isViewOnly) return\n\t\t\tactiveAgent?.submitClarification(answers)\n\t\t},\n\t\t[activeAgent, isViewOnly],\n\t)\n\n\tconst handleQueueRemove = useCallback(\n\t\t(id: string) => {\n\t\t\tif (!activeAgent) return\n\t\t\tactiveAgent.removeFromQueue(id)\n\t\t\tif (editingQueueItemId === id) {\n\t\t\t\tclearEditing()\n\t\t\t\tactiveAgent.resumeQueue()\n\t\t\t}\n\t\t},\n\t\t[activeAgent, editingQueueItemId, clearEditing],\n\t)\n\n\tconst handleQueueMoveItem = useCallback(\n\t\t(from: number, to: number) => {\n\t\t\tactiveAgent?.moveQueueItem(from, to)\n\t\t},\n\t\t[activeAgent],\n\t)\n\n\tconst handleHeaderContextMenu = useCallback(\n\t\t(event: React.MouseEvent) => {\n\t\t\tif (!activeAgent && agents.length === 0) return\n\t\t\tevent.preventDefault()\n\n\t\t\tconst items: MenuItemOptions[] = [\n\t\t\t\t{\n\t\t\t\t\tlabel: Dictionary.Delete,\n\t\t\t\t\tenabled: !!activeAgent && !activeAgent.isBusy,\n\t\t\t\t\tclick: () => {\n\t\t\t\t\t\tif (!activeAgent) return\n\t\t\t\t\t\tconst agentId = activeAgent.id\n\t\t\t\t\t\tengine.stores.modalStore.set({\n\t\t\t\t\t\t\ttype: ModalType.Confirmation,\n\t\t\t\t\t\t\ttitle: \"Delete Chat\",\n\t\t\t\t\t\t\tdescription: \"This will permanently delete this chat and all its messages.\",\n\t\t\t\t\t\t\tconfirmLabel: Dictionary.Delete,\n\t\t\t\t\t\t\tvariant: \"destructive\",\n\t\t\t\t\t\t\tsource: \"agent_panel\",\n\t\t\t\t\t\t\tonConfirm: () => engine.stores.agentStore.dismiss(agentId),\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ type: \"separator\" },\n\t\t\t\t{\n\t\t\t\t\tlabel: Dictionary.DeleteAll,\n\t\t\t\t\tenabled: agents.length > 0 && !agents.some(a => a.isBusy),\n\t\t\t\t\tclick: () => {\n\t\t\t\t\t\tengine.stores.modalStore.set({\n\t\t\t\t\t\t\ttype: ModalType.Confirmation,\n\t\t\t\t\t\t\ttitle: \"Delete All Chats\",\n\t\t\t\t\t\t\tdescription: \"This will permanently delete all chats and their messages.\",\n\t\t\t\t\t\t\tconfirmLabel: Dictionary.DeleteAll,\n\t\t\t\t\t\t\tvariant: \"destructive\",\n\t\t\t\t\t\t\tsource: \"agent_panel\",\n\t\t\t\t\t\t\tonConfirm: () => void engine.stores.agentStore.clearHistory(),\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]\n\n\t\t\tengine.stores.contextMenuStore.show(items, {\n\t\t\t\tlocation: { x: event.clientX, y: event.clientY },\n\t\t\t})\n\t\t},\n\t\t[activeAgent, agents],\n\t)\n\n\tif (aiDisabled) {\n\t\treturn (\n\t\t\t<Stack className={styles.agentPanel} {...{ [dataIsAgentChatPanelDataAttribute]: true }}>\n\t\t\t\t<AgentChatAiDisabledBlock />\n\t\t\t</Stack>\n\t\t)\n\t}\n\n\treturn (\n\t\t<Stack className={styles.agentPanel} direction=\"column\" gap={0} {...{ [dataIsAgentChatPanelDataAttribute]: true }}>\n\t\t\t<Stack direction=\"column\" gap={10}>\n\t\t\t\t<Stack\n\t\t\t\t\tclassName={styles.header}\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\talignItems=\"center\"\n\t\t\t\t\tgap={10}\n\t\t\t\t\tonContextMenu={handleHeaderContextMenu}\n\t\t\t\t>\n\t\t\t\t\t<AgentChatPicker\n\t\t\t\t\t\tactiveAgentId={activeAgentId}\n\t\t\t\t\t\tactiveAgentTitle={activeAgent?.title}\n\t\t\t\t\t\tagents={agents}\n\t\t\t\t\t\tonSelectAgent={handleSelectAgent}\n\t\t\t\t\t\tonNewChat={handleNewChat}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<ToolbarTooltip enabled={shouldUseToolbarTooltip} text=\"Chat\" direction=\"bottom\">\n\t\t\t\t\t\t<AgentButton\n\t\t\t\t\t\t\tvariant=\"clean\"\n\t\t\t\t\t\t\tonClick={handleNewChat}\n\t\t\t\t\t\t\tclassName={styles.newChatButton}\n\t\t\t\t\t\t\tdisabled={isViewOnly}\n\t\t\t\t\t\t\taria-label=\"Chat\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<IconAgentPlusLarge />\n\t\t\t\t\t\t</AgentButton>\n\t\t\t\t\t</ToolbarTooltip>\n\t\t\t\t</Stack>\n\t\t\t\t<div className={styles.divider} />\n\t\t\t</Stack>\n\t\t\t<Stack\n\t\t\t\tclassName={cx(styles.content, isViewOnly && styles.disabled)}\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap={0}\n\t\t\t\tpaddingTop={!activeAgent ? dimensions.css.panelPadding : 0}\n\t\t\t\tinert={isViewOnly ? \"\" : undefined}\n\t\t\t>\n\t\t\t\t{/* AGENTS @TODO: Remove before launch. */}\n\t\t\t\t{!hasCrdtEnabled ? (\n\t\t\t\t\t<AgentChatCrdtDisabledBlock />\n\t\t\t\t) : !isAlphaChannel ? (\n\t\t\t\t\t<AgentChatReleaseChannelBlock />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{activeAgent && (\n\t\t\t\t\t\t\t<AgentChatMessages\n\t\t\t\t\t\t\t\tclassName={styles.messages}\n\t\t\t\t\t\t\t\tagentId={activeAgent.id}\n\t\t\t\t\t\t\t\tstate={sessionState}\n\t\t\t\t\t\t\t\trequests={activeAgent.chatMessages}\n\t\t\t\t\t\t\t\tscrollRestorationCache={scrollOffsetRestorationCache}\n\t\t\t\t\t\t\t\tactiveScopeId={activeScopeId}\n\t\t\t\t\t\t\t\tfollowMode={followMode}\n\t\t\t\t\t\t\t\tresetAutoScrollKey={resetAutoScrollKey}\n\t\t\t\t\t\t\t\thideCreditLimitError={aiCreditLimitReached}\n\t\t\t\t\t\t\t\tselectionMode={selectionMode}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t{pendingPrompts.length > 0 && (\n\t\t\t\t\t\t\t<AgentPromptQueue\n\t\t\t\t\t\t\t\tprompts={pendingPrompts}\n\t\t\t\t\t\t\t\teditingItemId={editingQueueItemId}\n\t\t\t\t\t\t\t\tonSubmitImmediately={handleQueueSubmitImmediately}\n\t\t\t\t\t\t\t\tonEdit={handleQueueEdit}\n\t\t\t\t\t\t\t\tonRemove={handleQueueRemove}\n\t\t\t\t\t\t\t\tonMoveItem={handleQueueMoveItem}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\n\t\t\t\t\t\t<React.Suspense>\n\t\t\t\t\t\t\t{aiCreditLimitReached && sessionState !== \"generating\" ? (\n\t\t\t\t\t\t\t\t<AgentChatCreditLimitBlock isDailyLimit={aiDailyLimitReached} />\n\t\t\t\t\t\t\t) : sessionState === \"waiting-for-clarification\" && clarificationQuestions ? (\n\t\t\t\t\t\t\t\t<AgentChatQuestions questions={clarificationQuestions} onSubmit={handleClarificationSubmit} />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<AgentChatInput\n\t\t\t\t\t\t\t\t\tagentId={activeAgentId}\n\t\t\t\t\t\t\t\t\tstate={sessionState}\n\t\t\t\t\t\t\t\t\tuserMessageCount={userMessageCount}\n\t\t\t\t\t\t\t\t\tgetUserMessageParts={getUserMessageParts}\n\t\t\t\t\t\t\t\t\tcontextUsage={contextUsage}\n\t\t\t\t\t\t\t\t\tonSubmit={handlePromptSubmit}\n\t\t\t\t\t\t\t\t\tonCancel={editingQueueItemId ? clearEditingAndResume : undefined}\n\t\t\t\t\t\t\t\t\tonEmptySubmit={sendFirstQueuedPrompt}\n\t\t\t\t\t\t\t\t\tselectionMode={selectionMode}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</React.Suspense>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</Stack>\n\t\t</Stack>\n\t)\n})\n\nfunction getImplicitSelectionForAgent(activeScope: LoadedScopeNode): readonly NodeID[] {\n\tif (engine.stores.chromeStore.mainView === ActiveMainView.CodeEditor) {\n\t\treturn emptyArray<NodeID>()\n\t}\n\n\treturn getSelectionForAgent(activeScope)\n}\n\nexport function getSelectionForAgent(activeScope: LoadedScopeNode): readonly NodeID[] {\n\t// If there's a selection, use it.\n\tconst selection = engine.stores.selectionStore.ids\n\tif (selection.length > 0) return selection\n\n\t// Otherwise, send the breakpoints to the agent so that it considers all sizes/makes responsive layouts.\n\tif (isWebPageNode(activeScope) && withBreakpointVariants(activeScope)) {\n\t\treturn activeScope.getTopLevelVariants().map(variant => variant.id)\n\t}\n\n\tif (withReplicaVariants(activeScope)) {\n\t\tconst primaryVariant = activeScope.getPrimaryVariant()\n\t\treturn [primaryVariant.id]\n\t}\n\treturn emptyArray<NodeID>()\n}\n\n// `activeAgent.contextUsage` is only the live agent field. After a request completes\n// or a chat is hydrated, completed request `usage.inputTokens` is the persisted source of truth.\nfunction getLatestCompletedRequestContextUsage(\n\trequests: readonly Pick<AgentRequest, \"done\" | \"model\" | \"usage\">[],\n): AgentContextUsage | undefined {\n\tfor (let index = requests.length - 1; index >= 0; index--) {\n\t\tconst request = requests[index]\n\t\tif (!request?.done || !request.model || !isNumber(request.usage?.inputTokens)) continue\n\t\treturn {\n\t\t\tmodel: request.model,\n\t\t\tinputTokens: request.usage.inputTokens,\n\t\t\tsource: \"actual\",\n\t\t}\n\t}\n\treturn undefined\n}\n", "import { AgentErrorCard } from \"./AgentErrorCard.tsx\"\n\nexport function AgentChatAiDisabledBlock() {\n\treturn (\n\t\t<AgentErrorCard title=\"AI features disabled\" message=\"An admin in your workspace has disabled all AI features.\" />\n\t)\n}\n", "import type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { TreeMode } from \"document/stores/TreeMode.ts\"\nimport { updateProject } from \"web/lib/ProjectAPI.ts\"\n\nexport async function convertProjectToMode(engine: VekterEngine, mode: TreeMode): Promise<void> {\n\tconst projectId = engine.stores.projectStore.projectId\n\n\t// The canvasfeatures notification makes the server restart the project, which reloads the page on disconnect.\n\t// TODO: Remove this legacy canvasFeatures.crdt write once CRDT is fully shipped.\n\tawait updateProject(projectId, { canvasFeatures: { crdt: mode === \"crdt\" } })\n\tengine.remoteDocument?.sendAfterFlush({\n\t\ttype: \"notifyProjectChange\",\n\t\tvalue: {\n\t\t\tscope: \"canvasfeatures\",\n\t\t},\n\t})\n}\n", "import { dimensions } from \"@framerjs/fresco/tokens\"\nimport { unhandledError } from \"@framerjs/shared\"\nimport { useAndAssertVekterEngine } from \"document/useVekterEngine.ts\"\nimport { convertProjectToMode } from \"web/pages/project/lib/convertProjectToMode.ts\"\nimport { AgentErrorCard } from \"./AgentErrorCard.tsx\"\n\nexport function AgentChatCrdtDisabledBlock() {\n\tconst engine = useAndAssertVekterEngine()\n\n\treturn (\n\t\t<div style={{ marginTop: dimensions.css.panelPadding }}>\n\t\t\t<AgentErrorCard\n\t\t\t\ttitle=\"Enable CRDT\"\n\t\t\t\tmessage=\"Agents require it\"\n\t\t\t\tactionLabel=\"Enable\"\n\t\t\t\tonLabelClick={() => {\n\t\t\t\t\tvoid convertProjectToMode(engine, \"crdt\").catch(unhandledError)\n\t\t\t\t}}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n", "import { UpsellType } from \"@framerjs/events\"\nimport { unhandledError } from \"@framerjs/shared\"\nimport { UpsellFeature } from \"document/components/chrome/siteSettings/Plans/Stripe/utils/upsell.ts\"\nimport engine from \"document/engine.ts\"\nimport { SiteSettingsTabNames } from \"document/stores/SiteSettingsStore.ts\"\nimport { useCallback } from \"react\"\nimport { usePurchaseOriginLocalStorage } from \"web/lib/usePurchaseOriginLocalStorage.ts\"\n\nexport function useNavigateToAiCreditsPlans() {\n\tconst { updatePurchaseOrigin } = usePurchaseOriginLocalStorage()\n\n\treturn useCallback(() => {\n\t\tconst { project } = engine.stores.projectStore\n\t\tconst licenseTypes = project\n\t\t\t? { projectId: project.id, site: project.license.type, team: project.teamLicenseType }\n\t\t\t: null\n\t\tif (licenseTypes) updatePurchaseOrigin(UpsellType.aiCreditsUpsell, licenseTypes, null)\n\n\t\tengine.stores.siteSettingsStore\n\t\t\t.setActiveTab({ tab: SiteSettingsTabNames.plans, upsellFeature: UpsellFeature.aiCredits })\n\t\t\t.catch(unhandledError)\n\t}, [updatePurchaseOrigin])\n}\n", "import engine from \"document/engine.ts\"\nimport { showBuyAiCreditsModal } from \"../../shared/UpsellModal/utils/aiCreditsUpsell.ts\"\nimport { useNavigateToAiCreditsPlans } from \"../../shared/UpsellModal/utils/useNavigateToAiCreditsPlans.ts\"\nimport type { AgentErrorCardProps } from \"./AgentErrorCard.tsx\"\nimport { AgentErrorCard } from \"./AgentErrorCard.tsx\"\n\ninterface AgentChatCreditLimitBlockProps {\n\tisDailyLimit: boolean\n}\n\nexport function AgentChatCreditLimitBlock({ isDailyLimit }: AgentChatCreditLimitBlockProps) {\n\tconst hasDailyLimit =\n\t\ttypeof engine.stores.projectStore.useState(state => state.resourceLimits?.aiCreditsDaily) === \"number\"\n\n\tconst navigateToPlans = useNavigateToAiCreditsPlans()\n\n\tlet cardProps: Omit<AgentErrorCardProps, \"title\" | \"message\">\n\n\tconst message = isDailyLimit\n\t\t? \"Your workspace has used all of its available credits today.\"\n\t\t: \"Your workspace has used all of its available credits this month.\"\n\n\tif (hasDailyLimit) {\n\t\tcardProps = {\n\t\t\tactionLabel: \"Upgrade\",\n\t\t\tonLabelClick: navigateToPlans,\n\t\t}\n\t} else {\n\t\tcardProps = {\n\t\t\tactionLabel: \"Buy Credits\",\n\t\t\tonLabelClick: () => showBuyAiCreditsModal(engine, \"agent_panel\"),\n\t\t}\n\t}\n\n\treturn <AgentErrorCard title=\"Out of credits\" {...cardProps} message={message} />\n}\n", "import { IconInputDropdown } from \"@framerjs/fresco\"\nimport type { Agent, AgentID } from \"app/ai/agents/Agent.ts\"\nimport { Dictionary } from \"app/dictionary.ts\"\nimport type { MenuItemOptions } from \"app/menu.ts\"\nimport engine from \"document/engine.ts\"\nimport { memo } from \"react\"\nimport { formatDistanceToNowShort } from \"web/pages/project/lib/formatDistanceToNowShort.ts\"\nimport * as styles from \"./AgentChatPicker.styles.ts\"\n\ninterface AgentChatPickerProps {\n\tactiveAgentId: AgentID | undefined\n\tactiveAgentTitle: string | undefined\n\tagents: Agent[]\n\tonSelectAgent: (agentId: AgentID) => void\n\tonNewChat: () => void\n}\n\nexport const AgentChatPicker = memo(function AgentChatPicker({\n\tactiveAgentId,\n\tactiveAgentTitle,\n\tagents,\n\tonSelectAgent,\n\tonNewChat,\n}: AgentChatPickerProps) {\n\tfunction handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n\t\tconst chatItems: MenuItemOptions[] = [...agents]\n\t\t\t.sort((agentA, agentB) => {\n\t\t\t\tconst lastMessageA = agentA.chatMessages.at(-1)?.state.messages.at(-1)\n\t\t\t\tconst lastMessageB = agentB.chatMessages.at(-1)?.state.messages.at(-1)\n\t\t\t\tconst timestampA = lastMessageA?.timestamp ?? 0\n\t\t\t\tconst timestampB = lastMessageB?.timestamp ?? 0\n\t\t\t\treturn timestampB - timestampA\n\t\t\t})\n\t\t\t.map(agent => {\n\t\t\t\tconst lastTimestamp = agent.chatMessages.at(-1)?.state.messages.at(-1)?.timestamp\n\n\t\t\t\treturn {\n\t\t\t\t\tlabel: agent.title ?? Dictionary.NewChat,\n\t\t\t\t\tbadge: lastTimestamp ? formatDistanceToNowShort(lastTimestamp, { justNow: true }) : undefined,\n\t\t\t\t\tbadgeClassName: styles.timestampBadge,\n\t\t\t\t\tclick: () => onSelectAgent(agent.id),\n\t\t\t\t}\n\t\t\t})\n\n\t\tconst menuItems: MenuItemOptions[] =\n\t\t\tchatItems.length > 0 ? chatItems : [{ label: Dictionary.NewChat, click: onNewChat }]\n\n\t\tconst { left, bottom, width } = event.currentTarget.getBoundingClientRect()\n\t\tengine.stores.contextMenuStore.show(menuItems, { location: { x: left, y: bottom + 5 }, width: width })\n\t}\n\n\treturn (\n\t\t<button type=\"button\" onClick={handleClick} aria-haspopup=\"listbox\" className={styles.button}>\n\t\t\t<span className={styles.title}>{activeAgentTitle ?? Dictionary.NewChat}</span>\n\n\t\t\t<div className={styles.chevron}>\n\t\t\t\t<IconInputDropdown />\n\t\t\t</div>\n\t\t</button>\n\t)\n})\n", "import \"AgentChatPicker.styles_xaptbi.wyw.css\"; import { cx } from \"@linaria/core\";\nimport { tabularNumbers } from \"app/styles/typography.styles.ts\";\nimport * as commonStyles from \"./AgentChat.common.styles.ts\";\nconst buttonBase = \"buttonBase_bzdd3vk\";\nexport const button = cx(buttonBase, \"button_bbhksoo\");\nexport const chevron = \"chevron_c1mnopfo\";\nexport const title = cx(commonStyles.truncatedText, \"title_t1om673z\");\nexport const timestampBadge = cx(tabularNumbers, \"timestampBadge_twtef3e\");", "import { Button, IconChevronLeft, IconChevronRight, Stack } from \"@framerjs/fresco\"\nimport { isCommandKeyPressed } from \"@framerjs/shared\"\nimport { noop } from \"@framerjs/shared/src/noop.ts\"\nimport { cx } from \"@linaria/core\"\nimport { AgentInput } from \"app/agent/components/AgentInput/AgentInput.tsx\"\nimport { useAgentInputEditorView, type AgentInputEditorAPI } from \"app/agent/editor/useAgentInputEditorView.ts\"\nimport {\n\tSKIPPED_ANSWER,\n\ttype ClarificationAnswer,\n\ttype ClarificationQuestion,\n\ttype SuggestedAnswer,\n} from \"app/ai/agents/tools/askClarification.ts\"\nimport { Dictionary } from \"app/dictionary.ts\"\nimport engine from \"document/engine.ts\"\nimport { isEditingText } from \"document/utils/isEditingText.ts\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\nimport { isString } from \"utils/typeChecks.ts\"\nimport * as commonStyles from \"./AgentChat.common.styles.ts\"\nimport * as styles from \"./AgentChatQuestions.styles.ts\"\n\ninterface AgentChatQuestionsProps {\n\tquestions: readonly ClarificationQuestion[]\n\tonSubmit: (answers: ClarificationAnswer[]) => void\n}\n\nexport function AgentChatQuestions({ questions, onSubmit }: AgentChatQuestionsProps) {\n\tconst [currentIndex, setCurrentIndex] = useState(0)\n\tconst [answers, setAnswers] = useState<Map<number, SuggestedAnswer>>(() => new Map())\n\tconst questionCount = questions.length\n\tconst currentQuestion = questions[currentIndex]\n\tconst isLastQuestion = currentIndex >= questionCount - 1\n\n\tconst submitRef = useRef<() => void>(noop)\n\tconst pendingNavigateTimeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n\tconst pendingKeyboardSubmitRef = useRef(false)\n\n\tconst editorAPI = useAgentInputEditorView({\n\t\tplaceholder: \"Something else\u2026\",\n\t\tonSubmit: function handleEditorSubmit() {\n\t\t\tsubmitRef.current()\n\t\t\treturn true\n\t\t},\n\t\tonEscape: noop,\n\t\tclearOnSubmit: false,\n\t})\n\n\tconst navigateToQuestion = useCallback(\n\t\t(nextIndex: number, nextAnswers: ReadonlyMap<number, SuggestedAnswer>) => {\n\t\t\tconst nextAnswer = nextAnswers.get(nextIndex)\n\t\t\tconst nextQuestion = questions[nextIndex]\n\t\t\tconst nextIsSuggested =\n\t\t\t\tnextQuestion?.suggestedAnswers?.some(suggestedAnswer => isSameAnswer(suggestedAnswer, nextAnswer)) ?? false\n\t\t\tif (nextAnswer && !nextIsSuggested) {\n\t\t\t\teditorAPI.setContent([isString(nextAnswer) ? nextAnswer : nextAnswer.answer])\n\t\t\t} else {\n\t\t\t\teditorAPI.setContent([])\n\t\t\t}\n\n\t\t\tsetCurrentIndex(nextIndex)\n\t\t},\n\t\t[editorAPI, questions],\n\t)\n\n\tconst handleSelectAnswer = useCallback(\n\t\t(answer: SuggestedAnswer) => {\n\t\t\teditorAPI.setContent([])\n\n\t\t\tclearTimeout(pendingNavigateTimeoutRef.current)\n\n\t\t\tconst nextAnswers = new Map(answers)\n\t\t\tnextAnswers.set(currentIndex, answer)\n\t\t\tsetAnswers(nextAnswers)\n\n\t\t\tif (!isLastQuestion) {\n\t\t\t\tpendingNavigateTimeoutRef.current = setTimeout(() => {\n\t\t\t\t\tnavigateToQuestion(currentIndex + 1, nextAnswers)\n\t\t\t\t}, 150)\n\t\t\t}\n\t\t},\n\t\t[currentIndex, isLastQuestion, editorAPI, answers, navigateToQuestion],\n\t)\n\n\tconst captureAndNavigate = useCallback(\n\t\tfunction captureAndNavigate(delta: number) {\n\t\t\tclearTimeout(pendingNavigateTimeoutRef.current)\n\n\t\t\tconst nextIndex = currentIndex + delta\n\t\t\tif (nextIndex < 0 || nextIndex >= questionCount) return\n\n\t\t\tconst text = editorAPI.getTextContent().trim()\n\t\t\tconst nextAnswers = new Map(answers)\n\t\t\tconst currentStoredAnswer = nextAnswers.get(currentIndex)\n\t\t\tconst currentStoredIsSuggested =\n\t\t\t\tcurrentQuestion?.suggestedAnswers?.some(suggestedAnswer =>\n\t\t\t\t\tisSameAnswer(suggestedAnswer, currentStoredAnswer),\n\t\t\t\t) ?? false\n\t\t\tif (text) {\n\t\t\t\tnextAnswers.set(currentIndex, text)\n\t\t\t} else if (!currentStoredIsSuggested) {\n\t\t\t\tnextAnswers.delete(currentIndex)\n\t\t\t}\n\t\t\tsetAnswers(nextAnswers)\n\t\t\teditorAPI.editorView.dom.blur() // Ensure global letter shortcuts work on the next question after leaving custom input.\n\t\t\tnavigateToQuestion(nextIndex, nextAnswers)\n\t\t},\n\t\t[currentIndex, questionCount, editorAPI, answers, currentQuestion, navigateToQuestion],\n\t)\n\n\tconst handleSubmit = useCallback(\n\t\t(answersOverride?: ReadonlyMap<number, SuggestedAnswer>) => {\n\t\t\tconst result = collectAnswers(questionCount, answersOverride ?? answers, currentIndex, editorAPI)\n\t\t\tonSubmit(result)\n\t\t},\n\t\t[questionCount, currentIndex, editorAPI, answers, onSubmit],\n\t)\n\n\tconst handleSkip = useCallback(() => {\n\t\tclearTimeout(pendingNavigateTimeoutRef.current)\n\n\t\tconst nextAnswers = new Map(answers)\n\t\tnextAnswers.delete(currentIndex)\n\t\tsetAnswers(nextAnswers)\n\t\teditorAPI.setContent([])\n\n\t\tif (isLastQuestion) {\n\t\t\thandleSubmit(nextAnswers)\n\t\t} else {\n\t\t\tnavigateToQuestion(currentIndex + 1, nextAnswers)\n\t\t}\n\t}, [currentIndex, isLastQuestion, answers, editorAPI, navigateToQuestion, handleSubmit])\n\n\tconst hasCustomText = editorAPI.isValid\n\tconst storedAnswer = answers.get(currentIndex)\n\tconst currentHasSuggested =\n\t\tcurrentQuestion?.suggestedAnswers?.some(suggestedAnswer => isSameAnswer(suggestedAnswer, storedAnswer)) ?? false\n\tconst currentAnswered = currentHasSuggested || hasCustomText\n\n\tconst handleButtonClick = useCallback(\n\t\tfunction handleButtonClick() {\n\t\t\tif (!currentAnswered) return\n\t\t\tif (isLastQuestion) {\n\t\t\t\thandleSubmit()\n\t\t\t} else {\n\t\t\t\tcaptureAndNavigate(1)\n\t\t\t}\n\t\t},\n\t\t[currentAnswered, isLastQuestion, handleSubmit, captureAndNavigate],\n\t)\n\n\tconst handleKeyboardSelectAnswer = useCallback(\n\t\t(answer: SuggestedAnswer) => {\n\t\t\tif (isLastQuestion) pendingKeyboardSubmitRef.current = true\n\t\t\thandleSelectAnswer(answer)\n\t\t},\n\t\t[isLastQuestion, handleSelectAnswer],\n\t)\n\n\tsubmitRef.current = isLastQuestion ? handleSubmit : handleButtonClick\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tclearTimeout(pendingNavigateTimeoutRef.current)\n\t\t}\n\t}, [])\n\n\tuseEffect(() => {\n\t\tif (!pendingKeyboardSubmitRef.current || !isLastQuestion || !currentAnswered) return\n\t\tpendingKeyboardSubmitRef.current = false\n\t\thandleSubmit()\n\t}, [isLastQuestion, currentAnswered, handleSubmit])\n\n\tuseAnswerKeyboardShortcuts({\n\t\tcurrentQuestion,\n\t\tonSelectAnswer: handleKeyboardSelectAnswer,\n\t\tonFocusCustomInput: useCallback(() => {\n\t\t\tclearTimeout(pendingNavigateTimeoutRef.current)\n\t\t\tsetAnswers(prev => {\n\t\t\t\tconst next = new Map(prev)\n\t\t\t\tnext.delete(currentIndex)\n\t\t\t\treturn next\n\t\t\t})\n\t\t\teditorAPI.focus()\n\t\t}, [currentIndex, editorAPI]),\n\t})\n\n\tif (!currentQuestion) return null\n\n\treturn (\n\t\t<Stack className={commonStyles.inputCard} gap={10}>\n\t\t\t<Stack direction=\"row\" gap={10} alignItems=\"center\" justifyContent=\"space-between\">\n\t\t\t\t<div className={commonStyles.title}>{Dictionary.Questions}</div>\n\n\t\t\t\t{questionCount > 1 && (\n\t\t\t\t\t<Stack direction=\"row\" gap={5} alignItems=\"center\">\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tclassName={styles.navButton}\n\t\t\t\t\t\t\tdisabled={currentIndex <= 0}\n\t\t\t\t\t\t\tonClick={() => captureAndNavigate(-1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<IconChevronLeft />\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<span className={styles.progressText}>{`${currentIndex + 1} of ${questionCount}`}</span>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tclassName={styles.navButton}\n\t\t\t\t\t\t\tdisabled={currentIndex >= questionCount - 1}\n\t\t\t\t\t\t\tonClick={() => captureAndNavigate(1)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<IconChevronRight />\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</Stack>\n\t\t\t\t)}\n\t\t\t</Stack>\n\n\t\t\t<span className={styles.question}>{currentQuestion.question}</span>\n\n\t\t\t<Stack gap={0}>\n\t\t\t\t{currentQuestion?.suggestedAnswers.map((answer, index) => (\n\t\t\t\t\t<SuggestedAnswerRow\n\t\t\t\t\t\tkey={getAnswerTitle(answer)}\n\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\tanswer={answer}\n\t\t\t\t\t\tselected={!hasCustomText && isSameAnswer(storedAnswer, answer)}\n\t\t\t\t\t\tonSelect={() => handleSelectAnswer(answer)}\n\t\t\t\t\t/>\n\t\t\t\t))}\n\t\t\t\t<CustomAnswerRow\n\t\t\t\t\tindex={currentQuestion.suggestedAnswers?.length ?? 0}\n\t\t\t\t\teditorAPI={editorAPI}\n\t\t\t\t\tselected={hasCustomText}\n\t\t\t\t\tonSkip={handleSkip}\n\t\t\t\t/>\n\t\t\t</Stack>\n\n\t\t\t<Button className={commonStyles.actionButton} enabled={currentAnswered} onClick={handleButtonClick}>\n\t\t\t\t{isLastQuestion ? Dictionary.Continue : Dictionary.Next}\n\t\t\t</Button>\n\t\t</Stack>\n\t)\n}\n\ninterface SuggestedAnswerRowProps {\n\tindex: number\n\tanswer: SuggestedAnswer\n\tselected: boolean\n\tonSelect: () => void\n}\n\nfunction SuggestedAnswerRow({ index, answer, selected, onSelect }: SuggestedAnswerRowProps) {\n\tconst answerText = getAnswerTitle(answer)\n\treturn (\n\t\t<Stack direction=\"row\" gap={10} alignItems=\"center\" className={styles.answerRow} onClick={onSelect}>\n\t\t\t<span className={cx(styles.answerLabel, selected && styles.answerLabelSelected)}>{indexToLetter(index)}</span>\n\t\t\t<span className={cx(styles.answerText, selected && styles.answerTextSelected)}>{answerText}</span>\n\t\t</Stack>\n\t)\n}\n\ninterface CustomAnswerRowProps {\n\tindex: number\n\teditorAPI: AgentInputEditorAPI\n\tselected: boolean\n\tonSkip: () => void\n}\n\nfunction CustomAnswerRow({ index, editorAPI, selected, onSkip }: CustomAnswerRowProps) {\n\treturn (\n\t\t<Stack direction=\"row\" gap={10} alignItems=\"flex-start\" className={cx(styles.answerRow, styles.customAnswerRow)}>\n\t\t\t<span className={cx(styles.answerLabel, selected && styles.answerLabelSelected)}>{indexToLetter(index)}</span>\n\t\t\t<AgentInput className={cx(styles.customInput, selected && styles.customInputSelected)} editorAPI={editorAPI} />\n\t\t\t<Button variant=\"clean\" className={styles.skipButton} onClick={onSkip}>\n\t\t\t\t{Dictionary.Skip}\n\t\t\t</Button>\n\t\t</Stack>\n\t)\n}\n\n/**\n * Keyboard shortcuts for selecting suggested answers by pressing A, B, C, etc.\n *\n * Global app accelerators are gated via `chromeStore.agentQuestionKeyboardActive`\n * so unmodified letter keys reach this handler instead of triggering canvas tools.\n */\ninterface AnswerKeyboardShortcutsOptions {\n\tcurrentQuestion: ClarificationQuestion | undefined\n\tonSelectAnswer: (answer: SuggestedAnswer) => void\n\tonFocusCustomInput: () => void\n}\n\nfunction useAnswerKeyboardShortcuts({\n\tcurrentQuestion,\n\tonSelectAnswer,\n\tonFocusCustomInput,\n}: AnswerKeyboardShortcutsOptions) {\n\tuseEffect(() => {\n\t\tengine.scheduler.processWhenReady(() => {\n\t\t\tengine.stores.chromeStore.agentQuestionKeyboardActive = true\n\t\t}, \"nonUserEvent\")\n\t\treturn () => {\n\t\t\tengine.scheduler.processWhenReady(() => {\n\t\t\t\tengine.stores.chromeStore.agentQuestionKeyboardActive = false\n\t\t\t}, \"nonUserEvent\")\n\t\t}\n\t}, [])\n\n\tuseEffect(() => {\n\t\tfunction handleKeyDown(event: KeyboardEvent) {\n\t\t\tif (event.repeat) return\n\t\t\tif (isCommandKeyPressed(event) || event.altKey || event.shiftKey) return\n\t\t\tif (isEditingText()) return\n\n\t\t\tif (event.key.length !== 1) return\n\t\t\tconst keyLetter = event.key.toUpperCase()\n\t\t\tconst keyIndex = keyLetter.charCodeAt(0) - 65\n\t\t\tif (keyIndex < 0 || keyIndex > 25) return\n\n\t\t\tconst suggestedCount = currentQuestion?.suggestedAnswers.length ?? 0\n\n\t\t\tif (keyIndex === suggestedCount) {\n\t\t\t\tevent.preventDefault()\n\t\t\t\tevent.stopPropagation()\n\t\t\t\tonFocusCustomInput()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst selectedAnswer = currentQuestion?.suggestedAnswers[keyIndex]\n\t\t\tif (!selectedAnswer) return\n\n\t\t\tevent.preventDefault()\n\t\t\tevent.stopPropagation()\n\t\t\tonSelectAnswer(selectedAnswer)\n\t\t}\n\n\t\twindow.addEventListener(\"keydown\", handleKeyDown, true)\n\t\treturn () => window.removeEventListener(\"keydown\", handleKeyDown, true)\n\t}, [currentQuestion, onSelectAnswer, onFocusCustomInput])\n}\n\n// Only safe for index 0\u201325 (A\u2013Z), which is fine since questions have few suggested answers.\nfunction indexToLetter(index: number): string {\n\treturn String.fromCharCode(index + 65)\n}\n\nfunction isSameAnswer(answerA: SuggestedAnswer | undefined, answerB: SuggestedAnswer | undefined): boolean {\n\tif (answerA === undefined || answerB === undefined) return false\n\treturn getAnswerTitle(answerA) === getAnswerTitle(answerB)\n}\n\nfunction getAnswerTitle(answer: SuggestedAnswer): string {\n\tif (isString(answer)) return answer\n\treturn answer.answer\n}\n\nfunction collectAnswers(\n\tquestionCount: number,\n\tanswers: ReadonlyMap<number, SuggestedAnswer>,\n\tcurrentIndex: number,\n\teditorAPI: AgentInputEditorAPI,\n): ClarificationAnswer[] {\n\tconst result: ClarificationAnswer[] = []\n\tfor (let i = 0; i < questionCount; i++) {\n\t\tlet answer: SuggestedAnswer | undefined\n\t\tif (i === currentIndex && editorAPI.isValid) {\n\t\t\tanswer = editorAPI.getTextContent().trim()\n\t\t} else {\n\t\t\tanswer = answers.get(i)\n\t\t}\n\t\tresult.push({ questionIndex: i, answer: answer || SKIPPED_ANSWER })\n\t}\n\treturn result\n}\n", "import \"AgentChatQuestions.styles_1qlrdxg.wyw.css\"; export const navButton = \"navButton_nc6d8ii\";\nexport const progressText = \"progressText_p1eg09a\";\nexport const question = \"question_q5jengi\";\nexport const answerLabel = \"answerLabel_ah2u0ho\";\nexport const answerLabelSelected = \"answerLabelSelected_aicwo4q\";\nexport const answerRow = \"answerRow_al8slcn\";\nexport const customAnswerRow = \"customAnswerRow_c6pyfi5\";\nexport const answerText = \"answerText_a1tgx98\";\nexport const answerTextSelected = \"answerTextSelected_a1dhktz\";\nexport const skipButton = \"skipButton_s1e26nkd\";\nexport const customInput = \"customInput_c1ub33nq\";\nexport const customInputSelected = \"customInputSelected_c1q9nwdf\";", "import engine from \"document/engine.ts\"\nimport { updateProject } from \"web/lib/ProjectAPI.ts\"\n\nexport const setProjectReleaseChannel = async (releaseChannel: \"alpha\" | \"beta\" | \"stable\" | null) => {\n\tconst projectId = engine.remoteDocument?.projectId\n\tif (!projectId) return\n\t// Update the channel in the backend.\n\tawait updateProject(projectId, { releaseChannel })\n\t// The page needs to reload for the change to take full effect in the editor.\n\twindow.location.reload()\n}\n", "import { dimensions } from \"@framerjs/fresco/tokens\"\nimport { unhandledError } from \"@framerjs/shared\"\nimport { setProjectReleaseChannel } from \"web/pages/project/lib/setProjectReleaseChannel.ts\"\nimport { AgentErrorCard } from \"./AgentErrorCard.tsx\"\n\nexport function AgentChatReleaseChannelBlock() {\n\treturn (\n\t\t<div style={{ marginTop: dimensions.css.panelPadding }}>\n\t\t\t<AgentErrorCard\n\t\t\t\ttitle=\"Switch to Alpha\"\n\t\t\t\tmessage=\"Agents require the alpha release channel\"\n\t\t\t\tactionLabel=\"Switch\"\n\t\t\t\tonLabelClick={() => {\n\t\t\t\t\tvoid setProjectReleaseChannel(\"alpha\").catch(unhandledError)\n\t\t\t\t}}\n\t\t\t/>\n\t\t</div>\n\t)\n}\n", "import { Button, IconAgentEditPencil, IconAgentTrash, IconAgentEnter, IconSectionCollapsed } from \"@framerjs/fresco\"\nimport { Sortable } from \"@framerjs/fresco/layout-transitions\"\nimport { cx } from \"@linaria/core\"\nimport type { QueuedPrompt } from \"app/ai/agents/types.ts\"\nimport { Dictionary } from \"app/dictionary.ts\"\nimport pluralize from \"pluralize\"\nimport { useCallback, useState } from \"react\"\nimport { getId } from \"utils/getId.ts\"\nimport { isString } from \"utils/typeChecks.ts\"\nimport { PromptPartsText } from \"../PromptPartsText.tsx\"\nimport * as styles from \"./AgentPromptQueue.styles.ts\"\n\ninterface AgentPromptQueueProps {\n\tprompts: readonly QueuedPrompt[]\n\teditingItemId: string | null\n\tonSubmitImmediately: (id: string) => void\n\tonEdit: (id: string) => void\n\tonRemove: (id: string) => void\n\tonMoveItem: (from: number, to: number) => void\n}\n\nexport function AgentPromptQueue({\n\tprompts,\n\teditingItemId,\n\tonSubmitImmediately,\n\tonEdit,\n\tonRemove,\n\tonMoveItem,\n}: AgentPromptQueueProps) {\n\tconst [expanded, setExpanded] = useState(true)\n\tconst toggleExpanded = useCallback(() => setExpanded(prev => !prev), [])\n\n\treturn (\n\t\t<div className={styles.container}>\n\t\t\t<Button variant=\"clean\" className={styles.header} onClick={toggleExpanded} aria-expanded={expanded}>\n\t\t\t\t<span>{prompts.length} Queued</span>\n\t\t\t\t<span className={cx(styles.chevron, !expanded && styles.chevronCollapsed)}>\n\t\t\t\t\t<IconSectionCollapsed />\n\t\t\t\t</span>\n\t\t\t</Button>\n\n\t\t\t{expanded && (\n\t\t\t\t<Sortable items={prompts} moveItem={onMoveItem} keyForItem={getId} enabled={prompts.length > 1}>\n\t\t\t\t\t{({ item: prompt, isDragEnabled }) => (\n\t\t\t\t\t\t<QueueItem\n\t\t\t\t\t\t\tprompt={prompt}\n\t\t\t\t\t\t\tisEditing={editingItemId === prompt.id}\n\t\t\t\t\t\t\tisDragEnabled={isDragEnabled}\n\t\t\t\t\t\t\tonSubmitImmediately={onSubmitImmediately}\n\t\t\t\t\t\t\tonEdit={onEdit}\n\t\t\t\t\t\t\tonRemove={onRemove}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</Sortable>\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\ninterface QueueItemProps {\n\tprompt: QueuedPrompt\n\tisEditing: boolean\n\tisDragEnabled: boolean\n\tonSubmitImmediately: (id: string) => void\n\tonEdit: (id: string) => void\n\tonRemove: (id: string) => void\n}\n\nfunction QueueItem({ prompt, isEditing, isDragEnabled, onSubmitImmediately, onEdit, onRemove }: QueueItemProps) {\n\tconst hasTextContent = prompt.parts.some(part => !isString(part) || part.trim() !== \"\")\n\tconst imageCount = prompt.images.length\n\n\treturn (\n\t\t<div className={cx(styles.item, isEditing && styles.itemEditing, isDragEnabled && styles.itemDraggable)}>\n\t\t\t<div className={styles.itemText}>\n\t\t\t\t{hasTextContent ? (\n\t\t\t\t\t<PromptPartsText parts={prompt.parts} />\n\t\t\t\t) : imageCount > 0 ? (\n\t\t\t\t\t<span className={styles.imagePlaceholder}>{`${imageCount} ${pluralize(Dictionary.Image, imageCount)}`}</span>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t<div className={styles.actions}>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"clean\"\n\t\t\t\t\tclassName={styles.actionButton}\n\t\t\t\t\tonClick={() => onSubmitImmediately(prompt.id)}\n\t\t\t\t\ttitle=\"Submit Now\"\n\t\t\t\t\taria-label=\"Submit Now\"\n\t\t\t\t>\n\t\t\t\t\t<IconAgentEnter />\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"clean\"\n\t\t\t\t\tclassName={styles.actionButton}\n\t\t\t\t\tonClick={() => onEdit(prompt.id)}\n\t\t\t\t\ttitle=\"Edit\"\n\t\t\t\t\taria-label=\"Edit\"\n\t\t\t\t>\n\t\t\t\t\t<IconAgentEditPencil />\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"clean\"\n\t\t\t\t\tclassName={styles.actionButton}\n\t\t\t\t\tonClick={() => onRemove(prompt.id)}\n\t\t\t\t\ttitle=\"Remove\"\n\t\t\t\t\taria-label=\"Remove\"\n\t\t\t\t>\n\t\t\t\t\t<IconAgentTrash />\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n", "import \"AgentPromptQueue.styles_no6xc1.wyw.css\"; import { cx } from \"@linaria/core\";\nexport const container = \"container_c1p96lsv\";\nconst text = \"text_t1c3mdtn\";\nexport const header = cx(text, \"header_h154587u\");\nexport const chevron = \"chevron_ckzmmkb\";\nexport const chevronCollapsed = \"chevronCollapsed_c1eke7m8\";\nexport const item = \"item_in2gsv9\";\nexport const itemDraggable = \"itemDraggable_i1fiieo8\";\nexport const itemEditing = \"itemEditing_iemym7o\";\nexport const imagePlaceholder = \"imagePlaceholder_iofx2qp\";\nexport const itemText = cx(text, \"itemText_i4pco9b\");\nexport const actions = \"actions_a1b7u7v2\";\nexport const actionButton = \"actionButton_a5ni35a\";", "import { employeesOnlySettings } from \"app/employeesOnlySettings.ts\"\nimport engine from \"document/engine.ts\"\nimport { DAYS, MINUTES } from \"./dataProcessing.ts\"\n\n/**\n * Configures the oldest cluster boundary based on the latest published version,\n * then starts loading history entries and polling for new ones.\n */\nexport function initClusterHistory() {\n\tengine.scheduler.processWhenReady(() => {\n\t\tconst latestVersion = engine.stores.publishStore.versions[0]\n\t\tif (latestVersion) {\n\t\t\tconst latestVersionCreatedAtMs = new Date(latestVersion.createdAt).getTime()\n\t\t\tconst autosaveBufferFromLatestMs = 2 * MINUTES\n\t\t\tconst oldestClusterTimestamp = employeesOnlySettings.isOn(\"showAdditionalAutosaves\")\n\t\t\t\t? latestVersionCreatedAtMs - 1 * DAYS\n\t\t\t\t: latestVersionCreatedAtMs + autosaveBufferFromLatestMs\n\t\t\tengine.stores.historyStore.restrictOldestClusterTo(oldestClusterTimestamp)\n\t\t}\n\t\tengine.stores.historyStore.startLoadingAndPolling()\n\t})\n}\n", "import type { Store } from \"@framerjs/crdtree2\"\nimport engine from \"document/engine.ts\"\n\nfunction downloadBlob(blob: Blob, fileName: string) {\n\tconst url = URL.createObjectURL(blob)\n\tconst a = document.createElement(\"a\")\n\ta.href = url\n\ta.download = fileName\n\tdocument.body.appendChild(a)\n\ta.click()\n\n\tdocument.body.removeChild(a)\n\tURL.revokeObjectURL(url)\n}\n\nfunction getJsonBlob(store: Store) {\n\tconst json = JSON.stringify(store.getSerializableRows())\n\treturn new Blob([json], { type: \"application/json\" })\n}\n\nfunction getBinaryBlob(store: Store) {\n\treturn new Blob([store.toBuffer()], { type: \"vnd.framer.crdt\" })\n}\nexport function saveCrdtAsLocalJsonFile() {\n\tconst timeline = engine.stores.treeStore.crdtTimeline\n\tconst blob = getJsonBlob(timeline.store)\n\tsaveBlobAsLocalFile(blob, \"store\", \"json\")\n}\nexport function saveCrdtAsLocalBinaryFile() {\n\tconst timeline = engine.stores.treeStore.crdtTimeline\n\tconst blob = getBinaryBlob(timeline.store)\n\tsaveBlobAsLocalFile(blob, \"store\", \"crdt\")\n}\nexport function saveBlobAsLocalFile(blob: Blob, prefix: string, extension: string) {\n\tconst projectName = engine.stores.projectStore.project?.title ?? engine.stores.projectStore.projectId\n\tconst date = new Date().toISOString().split(\"T\")[0]\n\tconst filename = `${prefix}-${projectName}-${date}.${extension}`\n\n\tdownloadBlob(blob, filename)\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,SAAO,IAAI,KAAK,CAAC,MAAM,SAAS,CAAC,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAChE;AACO,SAAS,0BAA0B;AACzC,QAAM,WAAW,eAAO,OAAO,UAAU;AACzC,QAAM,OAAO,YAAY,SAAS,KAAK;AACvC,sBAAoB,MAAM,SAAS,MAAM;AAC1C;AACO,SAAS,4BAA4B;AAC3C,QAAM,WAAW,eAAO,OAAO,UAAU;AACzC,QAAM,OAAO,cAAc,SAAS,KAAK;AACzC,sBAAoB,MAAM,SAAS,MAAM;AAC1C;AACO,SAAS,oBAAoB,MAAY,QAAgB,WAAmB;AAClF,QAAM,cAAc,eAAO,OAAO,aAAa,SAAS,SAAS,eAAO,OAAO,aAAa;AAC5F,QAAM,QAAO,oBAAI,KAAK,GAAE,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC;AAClD,QAAM,WAAW,GAAG,MAAM,IAAI,WAAW,IAAI,IAAI,IAAI,SAAS;AAE9D,eAAa,MAAM,QAAQ;AAC5B;",
  "names": ["text", "log", "content", "hasImageFill", "log", "document", "log", "button", "log", "import_react", "import_react", "log", "import_jsx_runtime", "log", "log", "React", "CanvasSandboxRenderer", "text", "logger", "import_react", "import_jsx_runtime", "import_jsx_runtime", "import_react", "import_jsx_runtime", "import_react", "title", "import_jsx_runtime", "AgentChatPicker", "title", "import_react", "import_jsx_runtime", "captureAndNavigate", "text", "handleButtonClick", "answerText", "import_jsx_runtime", "import_react", "header", "chevron", "actionButton", "import_jsx_runtime", "header", "chevron", "pluralize", "actionButton", "import_jsx_runtime", "React", "AgentChatPanel", "item"]
}
