{
  "version": 3,
  "sources": ["../../src/app/ai/agents/evals2/scenarios/helpers.ts"],
  "sourcesContent": ["import { assert } from \"@framerjs/shared\"\nimport type { VekterEngine } from \"document/VekterEngine.ts\"\nimport type { CanvasNode } from \"document/models/CanvasTree/nodes/CanvasNode.ts\"\nimport FrameNode from \"document/models/CanvasTree/nodes/FrameNode.ts\"\nimport type { NodeID } from \"document/models/CanvasTree/nodes/NodeID.ts\"\nimport { RichTextNode } from \"document/models/CanvasTree/nodes/RichTextNode.ts\"\nimport { generateReplicaChildId } from \"document/models/CanvasTree/nodes/TemplateHelper.ts\"\nimport { withRadius } from \"document/models/CanvasTree/traits/WithRadius.ts\"\nimport type { WithReplicaVariants } from \"document/models/CanvasTree/traits/WithReplicaVariants.ts\"\nimport { isVisibleNode } from \"document/models/CanvasTree/traits/WithVisibility.ts\"\nimport { parseCSSDimension } from \"document/models/CanvasTree/traits/utils/CSSDimension.ts\"\nimport { convertFrameToCanvas } from \"document/models/CanvasTree/utils/geometry.ts\"\nimport { Rect } from \"library/index.ts\"\n\nexport function getNode(engine: VekterEngine, id: NodeID): CanvasNode {\n\tconst node = engine.tree.get(id)\n\tassert(node, `Expected fixture node '${id}' to exist.`)\n\treturn node\n}\n\nexport function getFrame(engine: VekterEngine, id: NodeID): FrameNode {\n\tconst node = getNode(engine, id)\n\tassert(node instanceof FrameNode, `Expected fixture node '${id}' to be a frame.`)\n\treturn node\n}\n\nexport function getRichText(engine: VekterEngine, id: NodeID): RichTextNode {\n\tconst node = getNode(engine, id)\n\tassert(node instanceof RichTextNode, `Expected fixture node '${id}' to be rich text.`)\n\treturn node\n}\n\nexport function getChildFrames(node: CanvasNode): FrameNode[] {\n\tconst { children } = node\n\tif (!children) return []\n\treturn children.filter((child): child is FrameNode => child instanceof FrameNode)\n}\n\nexport function getChildAt(node: CanvasNode, index: number): CanvasNode | undefined {\n\tconst { children } = node\n\tif (!children || index < 0 || index >= children.length) return undefined\n\treturn children.at(index)\n}\n\nexport function getFrameChildAt(node: CanvasNode, index: number): FrameNode | undefined {\n\tconst child = getChildAt(node, index)\n\treturn child instanceof FrameNode ? child : undefined\n}\n\nexport function getDescendantText(node: CanvasNode): string {\n\treturn Array.from(node.walk())\n\t\t.filter((descendant): descendant is RichTextNode => descendant instanceof RichTextNode)\n\t\t.map(descendant => descendant.html)\n\t\t.join(\"\\n\")\n}\n\nexport function getCenterRelativeToCanvas(engine: VekterEngine, node: CanvasNode) {\n\treturn Rect.center(convertFrameToCanvas(engine.tree, node))\n}\n\nexport function parsePx(value: unknown): number | undefined {\n\tif (typeof value === \"number\") return Number.isNaN(value) ? undefined : value\n\tif (typeof value !== \"string\") return undefined\n\n\tconst [number, unit] = parseCSSDimension(value, \"px\")\n\tif (Number.isNaN(number) || unit !== \"px\") return undefined\n\treturn number\n}\n\nexport function getRadius(engine: VekterEngine, id: NodeID): number {\n\tconst node = getNode(engine, id)\n\tassert(withRadius(node), `Expected fixture node '${id}' to support radius.`)\n\tconst radius = parsePx(node.radius)\n\tassert(radius !== undefined, `Expected fixture node '${id}' to have a radius.`)\n\treturn radius\n}\n\nexport function stringifyValue(value: unknown): string {\n\treturn typeof value === \"string\" ? value : (JSON.stringify(value) ?? \"\")\n}\n\nexport type BreakpointVariant = ReturnType<WithReplicaVariants[\"getTopLevelVariants\"]>[number]\n\n/**\n * Classifies breakpoints by width ordering: smallest = phone (mobile), middle = tablet, largest = desktop.\n * Tablet only exists with 3+ breakpoints; with two they are phone + desktop. Returns undefined when absent.\n * Works for any breakpoint scope (web page or component) since both expose `getTopLevelVariants`.\n */\nexport function getBreakpointVariant(\n\tscope: WithReplicaVariants,\n\tkind: \"mobile\" | \"tablet\" | \"desktop\",\n): BreakpointVariant | undefined {\n\tconst variants = [...scope.getTopLevelVariants()].sort((left, right) => left.width - right.width)\n\tif (kind === \"desktop\") return variants.at(-1)\n\tif (kind === \"mobile\") return variants.length >= 2 ? variants[0] : undefined\n\treturn variants.length >= 3 ? variants[1] : undefined\n}\n\n/** Returns the breakpoint variant of the given kind, asserting it exists. Call inside a check closure. */\nexport function requireBreakpointVariant(\n\tscope: WithReplicaVariants,\n\tkind: \"mobile\" | \"tablet\" | \"desktop\",\n): BreakpointVariant {\n\tconst variant = getBreakpointVariant(scope, kind)\n\tassert(variant, `Expected a ${kind} breakpoint.`)\n\treturn variant\n}\n\n/** Resolves a primary-variant node id to the equivalent node inside the given breakpoint variant. */\nexport function getNodeInBreakpoint(\n\tengine: VekterEngine,\n\tscope: WithReplicaVariants,\n\tvariant: BreakpointVariant,\n\toriginalId: string,\n): CanvasNode | undefined {\n\tconst isPrimary = variant.id === scope.getPrimaryVariant().id\n\tconst nodeId = isPrimary ? originalId : generateReplicaChildId(variant.id, originalId)\n\treturn engine.tree.get(nodeId)\n}\n\n/** Resolves a primary-variant node id inside a breakpoint, asserting the node exists. */\nexport function requireNodeInBreakpoint(\n\tengine: VekterEngine,\n\tscope: WithReplicaVariants,\n\tvariant: BreakpointVariant,\n\toriginalId: string,\n\tnodeLabel: string,\n): CanvasNode {\n\tconst node = getNodeInBreakpoint(engine, scope, variant, originalId)\n\tassert(node, `Expected ${nodeLabel} '${originalId}' in breakpoint variant '${variant.id}'.`)\n\treturn node\n}\n\n/** A node counts as visually hidden when it is not visible or has effectively no dimensions. */\nexport function isVisuallyHidden(engine: VekterEngine, node: CanvasNode): boolean {\n\tif (!isVisibleNode(node)) return true\n\tconst rect = engine.tree.getRect(node, false)\n\treturn rect.width <= 1 || rect.height <= 1\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;AAcO,SAAS,QAAQ,QAAsB,IAAwB;AACrE,QAAM,OAAO,OAAO,KAAK,IAAI,EAAE;AAC/B,SAAO,MAAM,0BAA0B,EAAE,aAAa;AACtD,SAAO;AACR;AAEO,SAAS,SAAS,QAAsB,IAAuB;AACrE,QAAM,OAAO,QAAQ,QAAQ,EAAE;AAC/B,SAAO,gBAAgB,WAAW,0BAA0B,EAAE,kBAAkB;AAChF,SAAO;AACR;AAEO,SAA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