@hyperframes/parsers 0.7.15 → 0.7.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/gsapWriterAcorn.ts","../src/gsapConstants.ts","../src/gsapSerialize.ts","../src/gsapParserAcorn.ts","../src/gsapInline.ts"],"sourcesContent":["// fallow-ignore-file code-duplication\n/**\n * Browser-safe GSAP write path — magic-string offset-splice.\n *\n * T6c: edits GSAP scripts by overwriting/removing byte ranges in the original\n * source. Every byte outside the edited span is preserved verbatim — no\n * pretty-printer churn. Consumes ParsedGsapAcornForWrite from gsapParserAcorn.ts.\n */\nimport MagicString from \"magic-string\";\nimport type {\n GsapAnimation,\n GsapPercentageKeyframe,\n ArcPathConfig,\n ArcPathSegment,\n} from \"./gsapSerialize.js\";\nimport {\n resolveConversionProps,\n extractArcWaypoints,\n buildMotionPathObjectCode,\n} from \"./gsapSerialize.js\";\nimport {\n parseGsapScriptAcornForWrite,\n type ParsedGsapAcornForWrite,\n type TweenCallInfo,\n} from \"./gsapParserAcorn.js\";\nimport { classifyPropertyGroup } from \"./gsapConstants.js\";\nimport type { PropertyGroupName } from \"./gsapConstants.js\";\nimport type { SplitAnimationsOptions, SplitAnimationsResult } from \"./gsapSerialize.js\";\nimport * as acornWalk from \"acorn-walk\";\n\n// acorn ESTree nodes are structurally untyped here; mirror gsapParserAcorn.ts /\n// gsapInline.ts rather than re-deriving the full ESTree union for every access.\ntype Node = any;\n\n// ── Code generation helpers ──────────────────────────────────────────────────\n\n// Local serializer for the tween-statement path, which may carry boolean/object\n// extras (stagger config). serializeValue stringifies objects to \"[object\n// Object]\", so keep this richer JSON fallback for that path. Keyframe values are\n// always number|string and use the shared serializeValue (recast parity).\nfunction valueToCode(value: unknown): string {\n if (typeof value === \"string\" && value.startsWith(\"__raw:\")) return value.slice(6);\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\") return Number.isNaN(value) ? \"0\" : String(value);\n if (typeof value === \"boolean\") return String(value);\n return JSON.stringify(value);\n}\n\nfunction safeKey(key: string): string {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n}\n\n// fallow-ignore-next-line complexity\nfunction buildTweenStatementCode(timelineVar: string, anim: Omit<GsapAnimation, \"id\">): string {\n const selector = JSON.stringify(anim.targetSelector);\n const props: Record<string, number | string> = { ...anim.properties };\n if (anim.method !== \"set\" && anim.duration !== undefined) props.duration = anim.duration;\n if (anim.ease) props.ease = anim.ease;\n const entries = Object.entries(props).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n if (anim.extras) {\n for (const [k, v] of Object.entries(anim.extras)) {\n entries.push(`${safeKey(k)}: ${valueToCode(v)}`);\n }\n }\n const objCode = `{ ${entries.join(\", \")} }`;\n const posCode = valueToCode(\n typeof anim.position === \"number\" ? anim.position : (anim.position ?? 0),\n );\n if (anim.method === \"fromTo\") {\n const fromEntries = Object.entries(anim.fromProperties ?? {}).map(\n ([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`,\n );\n return `${timelineVar}.fromTo(${selector}, { ${fromEntries.join(\", \")} }, ${objCode}, ${posCode});`;\n }\n // A base `gsap.set` is off the timeline: no timeline var, no position arg.\n if (anim.method === \"set\" && anim.global) {\n return `gsap.set(${selector}, ${objCode});`;\n }\n return `${timelineVar}.${anim.method}(${selector}, ${objCode}, ${posCode});`;\n}\n\n// ── AST node helpers ─────────────────────────────────────────────────────────\n\nfunction isObjectProperty(prop: Node): boolean {\n return prop?.type === \"ObjectProperty\" || prop?.type === \"Property\";\n}\n\nfunction propKeyName(prop: Node): string | undefined {\n return prop?.key?.name ?? prop?.key?.value;\n}\n\nfunction findPropertyNode(varsArgNode: Node, key: string): Node | undefined {\n if (varsArgNode?.type !== \"ObjectExpression\") return undefined;\n for (const prop of varsArgNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n if (propKeyName(prop) === key) return prop;\n }\n return undefined;\n}\n\n/** The `keyframes` property's ObjectExpression value, or null when not a keyframe tween. */\nfunction keyframesObjectNode(varsNode: Node): Node | null {\n const kfProp = findPropertyNode(varsNode, \"keyframes\");\n return kfProp?.value?.type === \"ObjectExpression\" ? kfProp.value : null;\n}\n\nfunction findEnclosingExpressionStatement(ancestors: Node[]): Node | null {\n for (let i = ancestors.length - 2; i >= 0; i--) {\n if (ancestors[i]?.type === \"ExpressionStatement\") return ancestors[i];\n }\n return null;\n}\n\n/** Find the VariableDeclaration statement for `tl = gsap.timeline(...)`. */\nfunction findTimelineDeclarationStatement(ast: Node, timelineVar: string): Node | null {\n let found: Node = null;\n acornWalk.simple(ast, {\n // fallow-ignore-next-line complexity\n VariableDeclaration(node: Node) {\n if (found) return;\n for (const decl of node.declarations ?? []) {\n if (\n decl.id?.name === timelineVar &&\n decl.init?.type === \"CallExpression\" &&\n decl.init.callee?.type === \"MemberExpression\" &&\n decl.init.callee.object?.name === \"gsap\" &&\n decl.init.callee.property?.name === \"timeline\"\n ) {\n found = node;\n }\n }\n },\n });\n return found;\n}\n\n// ── Property splice helpers ───────────────────────────────────────────────────\n\n/**\n * Remove a property from a properties array, handling its comma.\n * `editableProps` must be the isObjectProperty-filtered subset in source order.\n */\nfunction removeProp(ms: MagicString, propNode: Node, editableProps: Node[]): void {\n const idx = editableProps.indexOf(propNode);\n if (idx === -1) return;\n if (editableProps.length === 1) {\n ms.remove(propNode.start, propNode.end);\n } else if (idx === 0) {\n // First prop: remove from its start to next prop start (drops trailing \", \")\n ms.remove(editableProps[0].start, editableProps[1].start);\n } else {\n // Non-first: remove from prev prop end to this prop end (drops leading \", \")\n ms.remove(editableProps[idx - 1].end, propNode.end);\n }\n}\n\n/** Serialize a vars record to an object-literal source: `{ k: v, ... }`. */\nfunction buildVarsObjectCode(record: Record<string, number | string>): string {\n const entries = Object.entries(record).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n return entries.length > 0 ? `{ ${entries.join(\", \")} }` : \"{}\";\n}\n\n/** Overwrite a tween call's vars ObjectExpression with freshly-built source. */\nfunction overwriteVarsArg(ms: MagicString, call: TweenCallInfo, objCode: string): void {\n if (!call.varsArg) return;\n ms.overwrite(call.varsArg.start, call.varsArg.end, objCode);\n}\n\n/**\n * Update a property value if it exists, or append a new key: val before the\n * closing `}`. Call with the full ObjectExpression node.\n */\nfunction upsertProp(ms: MagicString, objNode: Node, key: string, value: unknown): void {\n if (objNode?.type !== \"ObjectExpression\") return;\n const existing = findPropertyNode(objNode, key);\n if (existing) {\n ms.overwrite(existing.value.start, existing.value.end, valueToCode(value));\n } else {\n const sep = objNode.properties.length > 0 ? \", \" : \"\";\n ms.appendLeft(objNode.end - 1, `${sep}${safeKey(key)}: ${valueToCode(value)}`);\n }\n}\n\n/**\n * Vars keys that are NOT editable transform/style props: builtins\n * (duration/ease/delay), dropped callbacks, and extras (stagger/yoyo/repeat/…).\n * The exact union of recast's BUILTIN_VAR_KEYS + DROPPED_VAR_KEYS + EXTRAS_KEYS,\n * so both writers classify vars keys identically. (Distinct from the keyframe-\n * conversion NON_EDITABLE_VAR_KEYS below, which intentionally omits `ease`\n * because that path re-emits ease separately.)\n */\nconst NON_EDITABLE_PROP_KEYS = new Set([\n \"duration\",\n \"ease\",\n \"delay\",\n \"onComplete\",\n \"onStart\",\n \"onUpdate\",\n \"onRepeat\",\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\n/**\n * Editable transform/style key test: anything NOT a builtin, dropped callback, or\n * extras key. Mirrors recast's isEditablePropertyKey so both writers classify\n * vars keys identically.\n */\nfunction isEditableVarKey(key: string): boolean {\n return !NON_EDITABLE_PROP_KEYS.has(key);\n}\n\n/**\n * Collect verbatim `key: value` entries to PRESERVE from a vars/keyframe\n * ObjectExpression: every property whose key `drop` does not reject, sliced from\n * source — except keys present in `overrides`, whose value is replaced. Returns\n * the entries plus the set of keys it kept, so callers can append new keys.\n */\nfunction preservedEntries(\n objNode: Node,\n source: string,\n drop: (key: string) => boolean,\n overrides: Record<string, unknown>,\n): { entries: string[]; keys: Set<string> } {\n const entries: string[] = [];\n const keys = new Set<string>();\n for (const prop of objNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\" || drop(key)) continue;\n keys.add(key);\n const code =\n key in overrides\n ? valueToCode(overrides[key])\n : source.slice(prop.value.start, prop.value.end);\n entries.push(`${safeKey(key)}: ${code}`);\n }\n return { entries, keys };\n}\n\n/**\n * Replace the editable-property keys on a vars ObjectExpression with exactly\n * `newProps`, leaving non-editable keys (duration/ease/stagger/callbacks/…)\n * untouched unless overridden in `nonEditableOverrides`. Mirrors recast's\n * reconcileEditableProperties: editable keys absent from `newProps` are DROPPED,\n * not merged. Rebuilt in a single ms.overwrite so the splice can never overlap a\n * sibling edit — non-editable updates that also target this node (duration/ease/\n * extras) are folded into the same rebuild rather than spliced separately.\n */\nfunction reconcileEditableProps(\n ms: MagicString,\n objNode: Node,\n source: string,\n newProps: Record<string, number | string>,\n nonEditableOverrides?: Record<string, unknown>,\n): void {\n if (objNode?.type !== \"ObjectExpression\") return;\n const overrides = nonEditableOverrides ?? {};\n const { entries, keys } = preservedEntries(objNode, source, isEditableVarKey, overrides);\n for (const [key, value] of Object.entries(overrides)) {\n if (!keys.has(key)) entries.push(`${safeKey(key)}: ${valueToCode(value)}`);\n }\n for (const [key, value] of Object.entries(newProps)) {\n entries.push(`${safeKey(key)}: ${valueToCode(value)}`);\n }\n ms.overwrite(objNode.start, objNode.end, `{ ${entries.join(\", \")} }`);\n}\n\n// ── Insertion helpers ─────────────────────────────────────────────────────────\n\n/** Traverse callee.object chain to check if a call ultimately roots at timelineVar. */\nfunction isTimelineRooted(node: Node, timelineVar: string): boolean {\n if (node?.type === \"Identifier\") return node.name === timelineVar;\n if (node?.type === \"CallExpression\") return isTimelineRooted(node.callee?.object, timelineVar);\n return false;\n}\n\n/**\n * Find the byte offset after which to insert a new statement (tween or label).\n * Returns null when no timeline declaration exists in the script — callers must\n * not emit `tl.xxx()` calls in that case as `tl` would be undefined at render.\n */\nfunction findInsertionPoint(parsed: ParsedGsapAcornForWrite): number | null {\n const lastLocated = parsed.located[parsed.located.length - 1];\n if (lastLocated) {\n const lastCall = lastLocated.call;\n const exprStmt = findEnclosingExpressionStatement(lastCall.ancestors);\n return exprStmt?.end ?? lastCall.node.end;\n }\n if (!parsed.hasTimeline) return null;\n const tlDecl = findTimelineDeclarationStatement(parsed.ast, parsed.timelineVar);\n return tlDecl?.end ?? (parsed.ast.end as number);\n}\n\n// ── Public write API ─────────────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nexport function updateAnimationInScript(\n script: string,\n animationId: string,\n updates: Partial<GsapAnimation> & { easeEach?: string; resetKeyframeEases?: boolean },\n): string {\n if (!Object.keys(updates).length) return script;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const ms = new MagicString(script);\n const { call }: { call: TweenCallInfo } = target;\n\n // When `properties` is present we REPLACE the editable set (recast parity:\n // editable keys absent from the update are dropped). Fold any concurrent\n // non-editable updates (duration/ease/extras) into the single varsArg rebuild\n // so their splices can't overlap the rebuild's overwrite of the whole node.\n if (updates.properties) {\n const overrides: Record<string, unknown> = {};\n if (updates.duration !== undefined) overrides.duration = updates.duration;\n if (updates.ease !== undefined) overrides.ease = updates.ease;\n if (updates.extras) Object.assign(overrides, updates.extras);\n reconcileEditableProps(ms, call.varsArg, script, updates.properties, overrides);\n } else {\n if (updates.duration !== undefined) {\n upsertProp(ms, call.varsArg, \"duration\", updates.duration);\n }\n const easeValue = updates.easeEach ?? updates.ease;\n if (easeValue !== undefined) {\n const kfNode = keyframesObjectNode(call.varsArg);\n if (kfNode) {\n upsertProp(ms, kfNode, \"easeEach\", easeValue);\n // \"Apply to all segments\": drop every per-keyframe `ease` override so the\n // single easeEach governs all segments uniformly (AE select-all + F9).\n if (updates.resetKeyframeEases) {\n for (const kfEntry of kfNode.properties ?? []) {\n if (!isObjectProperty(kfEntry)) continue;\n const val = kfEntry.value;\n if (val?.type !== \"ObjectExpression\") continue;\n const easeNode = findPropertyNode(val, \"ease\");\n if (easeNode) removeProp(ms, easeNode, val.properties);\n }\n }\n } else {\n upsertProp(ms, call.varsArg, \"ease\", easeValue);\n }\n }\n if (updates.extras) {\n for (const [key, value] of Object.entries(updates.extras)) {\n upsertProp(ms, call.varsArg, key, value);\n }\n }\n }\n\n if (updates.fromProperties && call.method === \"fromTo\" && call.fromArg) {\n // fromTo's from-vars carry only editable props — REPLACE them too (recast\n // parity). fromArg is a distinct node from varsArg, so this rebuild never\n // overlaps the varsArg edits above.\n reconcileEditableProps(ms, call.fromArg, script, updates.fromProperties);\n }\n\n if (updates.position !== undefined) {\n overwritePosition(ms, call, updates.position);\n }\n\n return ms.toString();\n}\n\n/**\n * Overwrite a tween call's numeric position argument (the positionArg the parser\n * located: 3rd arg for fromTo, else 2nd), or append one when the call has no\n * explicit position. Shared by updateAnimationInScript and the\n * shift/scalePositionsInScript timeline ops.\n */\nfunction overwritePosition(ms: MagicString, call: TweenCallInfo, position: number | string): void {\n if (call.positionArg) {\n ms.overwrite(call.positionArg.start, call.positionArg.end, valueToCode(position));\n } else {\n ms.appendLeft(call.node.end - 1, `, ${valueToCode(position)}`);\n }\n}\n\n/**\n * Shift every tween targeting `targetSelector` by `delta` seconds (clamped ≥0),\n * rewriting each call's position argument. Mirrors recast's shiftPositionsInScript\n * (used by timeline clip-move to keep GSAP positions in sync with the clip start).\n */\nexport function shiftPositionsInScript(\n script: string,\n targetSelector: string,\n delta: number,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const ms = new MagicString(script);\n let changed = false;\n for (const entry of parsed.located) {\n if (entry.animation.targetSelector !== targetSelector) continue;\n if (typeof entry.animation.position !== \"number\") continue;\n const newPos = Math.max(0, Math.round((entry.animation.position + delta) * 1000) / 1000);\n overwritePosition(ms, entry.call, newPos);\n changed = true;\n }\n return changed ? ms.toString() : script;\n}\n\n/**\n * Linearly remap every tween targeting `targetSelector` from the old clip\n * [oldStart, oldDuration] onto the new [newStart, newDuration] (position and,\n * when present, duration scaled by the duration ratio). Mirrors recast's\n * scalePositionsInScript (used by timeline clip-resize).\n */\nexport function scalePositionsInScript(\n script: string,\n targetSelector: string,\n oldStart: number,\n oldDuration: number,\n newStart: number,\n newDuration: number,\n): string {\n if (oldDuration <= 0 || newDuration <= 0) return script;\n const ratio = newDuration / oldDuration;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const ms = new MagicString(script);\n let changed = false;\n for (const entry of parsed.located) {\n if (entry.animation.targetSelector !== targetSelector) continue;\n if (typeof entry.animation.position !== \"number\") continue;\n const newPos = Math.max(\n 0,\n Math.round((newStart + (entry.animation.position - oldStart) * ratio) * 1000) / 1000,\n );\n overwritePosition(ms, entry.call, newPos);\n if (typeof entry.animation.duration === \"number\" && entry.animation.duration > 0) {\n const newDur = Math.max(0.001, Math.round(entry.animation.duration * ratio * 1000) / 1000);\n upsertProp(ms, entry.call.varsArg, \"duration\", newDur);\n }\n changed = true;\n }\n return changed ? ms.toString() : script;\n}\n\nexport function addAnimationToScript(\n script: string,\n animation: Omit<GsapAnimation, \"id\">,\n): { script: string; id: string } {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, id: \"\" };\n\n const insertionPoint = findInsertionPoint(parsed);\n if (insertionPoint === null) return { script, id: \"\" };\n\n const ms = new MagicString(script);\n const statementCode = buildTweenStatementCode(parsed.timelineVar, animation);\n ms.appendLeft(insertionPoint, \"\\n\" + statementCode);\n\n const result = ms.toString();\n const reParsed = parseGsapScriptAcornForWrite(result);\n const newId = reParsed?.located[reParsed.located.length - 1]?.id ?? \"\";\n return { script: result, id: newId };\n}\n\nexport function removeAnimationFromScript(script: string, animationId: string): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const ms = new MagicString(script);\n const N = target.call.node;\n const exprStmt = findEnclosingExpressionStatement(target.call.ancestors);\n\n if (N.callee?.object?.type !== \"CallExpression\" && exprStmt?.expression === N) {\n // Standalone `tl.method(...)` — remove the whole ExpressionStatement\n const end =\n exprStmt.end < script.length && script[exprStmt.end] === \"\\n\"\n ? exprStmt.end + 1\n : exprStmt.end;\n ms.remove(exprStmt.start, end);\n } else {\n // Chain link — splice out `.method(args)` from N.callee.object.end to N.end\n ms.remove(N.callee.object.end, N.end);\n }\n\n return ms.toString();\n}\n\n// ── Flat-tween → keyframes conversion ──────────────────────────────────────────\n//\n// Mirror recast's convertToKeyframesInScript: when the first keyframe op lands\n// on a flat to()/from()/fromTo() tween, rewrite its vars object to\n// `{ keyframes: { \"0%\": {from}, \"100%\": {to} }, <preserved non-editable keys>,\n// ease: \"none\"? }` and convert from()/fromTo() to to(). We rebuild the whole\n// vars ObjectExpression in one ms.overwrite (single-edit-per-node), so the next\n// keyframe-add re-parses cleanly.\n\n// Identity value for an editable transform/style prop (recast's CSS_IDENTITY).\nconst CSS_IDENTITY: Record<string, number> = {\n opacity: 1,\n autoAlpha: 1,\n scale: 1,\n scaleX: 1,\n scaleY: 1,\n};\n\nfunction cssIdentityValue(prop: string): number {\n return CSS_IDENTITY[prop] ?? 0;\n}\n\n// Keys NOT in the editable set — preserved verbatim on the converted vars object\n// (matches the parser's classification: builtin/dropped/extras keys).\nconst NON_EDITABLE_VAR_KEYS = new Set([\n \"duration\",\n \"delay\",\n \"onComplete\",\n \"onStart\",\n \"onUpdate\",\n \"onRepeat\",\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\n/** The CSS-identity counterpart of a props record (numbers → identity value). */\nfunction identityProps(\n properties: Record<string, number | string>,\n): Record<string, number | string> {\n const identity: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(properties)) {\n if (v != null) identity[k] = typeof v === \"number\" ? cssIdentityValue(k) : v;\n }\n return identity;\n}\n\n/** Resolve the 0%/100% endpoint records for a tween being converted. */\nfunction conversionEndpoints(animation: GsapAnimation): {\n fromProps: Record<string, number | string>;\n toProps: Record<string, number | string>;\n} {\n if (animation.method === \"from\") {\n return { fromProps: { ...animation.properties }, toProps: identityProps(animation.properties) };\n }\n if (animation.method === \"fromTo\") {\n return {\n fromProps: { ...(animation.fromProperties ?? {}) },\n toProps: { ...animation.properties },\n };\n }\n // to(): 0% is the CSS identity state, 100% is the authored props.\n return { fromProps: identityProps(animation.properties), toProps: { ...animation.properties } };\n}\n\n/** Collect preserved (non-editable) `key: value` entries from the original vars node. */\nfunction preservedVarsEntries(varsNode: Node, source: string): string[] {\n const entries: string[] = [];\n if (varsNode?.type !== \"ObjectExpression\") return entries;\n for (const prop of varsNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\" || !NON_EDITABLE_VAR_KEYS.has(key)) continue;\n entries.push(`${safeKey(key)}: ${source.slice(prop.value.start, prop.value.end)}`);\n }\n return entries;\n}\n\n/** Build the rebuilt vars-object code for a converted flat tween. */\nfunction buildConvertedVarsCode(animation: GsapAnimation, varsNode: Node, source: string): string {\n const { fromProps, toProps } = conversionEndpoints(animation);\n const easeEach = animation.ease;\n const easeEachEntry = easeEach ? `, easeEach: ${JSON.stringify(easeEach)}` : \"\";\n const kfCode = `{ \"0%\": ${recordToCode(fromProps)}, \"100%\": ${recordToCode(toProps)}${easeEachEntry} }`;\n const entries = [`keyframes: ${kfCode}`, ...preservedVarsEntries(varsNode, source)];\n if (easeEach) entries.push(`ease: \"none\"`);\n return `{ ${entries.join(\", \")} }`;\n}\n\n/** Rename a from()/fromTo() call to to(), dropping fromTo's leading from-vars arg. */\nfunction convertMethodToTo(\n ms: MagicString,\n animation: GsapAnimation,\n call: Node,\n varsNode: Node,\n): void {\n if (animation.method !== \"from\" && animation.method !== \"fromTo\") return;\n const calleeProp = call.node.callee?.property;\n if (calleeProp) ms.overwrite(calleeProp.start, calleeProp.end, \"to\");\n // Remove the from-vars arg and its trailing separator up to the to-vars arg.\n if (animation.method === \"fromTo\" && call.fromArg) ms.remove(call.fromArg.start, varsNode.start);\n}\n\nfunction convertFlatTweenToKeyframes(script: string, target: Node): string {\n const animation: GsapAnimation = target.animation;\n if (animation.keyframes || animation.method === \"set\") return script;\n const call = target.call;\n const varsNode = call.varsArg;\n if (varsNode?.type !== \"ObjectExpression\") return script;\n\n const ms = new MagicString(script);\n ms.overwrite(varsNode.start, varsNode.end, buildConvertedVarsCode(animation, varsNode, script));\n convertMethodToTo(ms, animation, call, varsNode);\n return ms.toString();\n}\n\n// ── Keyframe write ops ────────────────────────────────────────────────────────\n//\n// Design: mirror the recast writer's rebuild-the-node model. The recast writer\n// mutates AST nodes in place and re-prints, so it never has an offset-overlap\n// problem. Here we instead compute the FINAL property record for every keyframe\n// value node that must change (the target merge, `_auto` endpoint sync, and\n// backfilled siblings) against the ORIGINAL parsed AST, then emit exactly ONE\n// `ms.overwrite(valueNode.start, valueNode.end, code)` per changed node (and a\n// single insert for a brand-new key). No node is ever both overwritten and\n// appended into, so the splices can never overlap.\n\nconst PERCENTAGE_KEY_RE = /^(\\d+(?:\\.\\d+)?)%$/;\n\n// Matches recast's PCT_TOLERANCE: percentages within 2 of an existing key are\n// treated as the same keyframe (merge), not a new insert.\nconst PCT_TOLERANCE = 2;\n\nfunction percentageFromKey(key: string): number {\n const m = PERCENTAGE_KEY_RE.exec(key);\n return m ? Number.parseFloat(m[1] ?? \"0\") : Number.NaN;\n}\n\n/** Serialize a final keyframe property record (number|string values) to code. */\nfunction recordToCode(record: Record<string, number | string>): string {\n const entries = Object.entries(record).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n return `{ ${entries.join(\", \")} }`;\n}\n\n/** Percentage-keyed property nodes of a keyframes ObjectExpression, in source order. */\nfunction percentagePropsOf(kfNode: Node): Node[] {\n return (kfNode.properties ?? []).filter((p: Node) => {\n if (!isObjectProperty(p)) return false;\n const key = propKeyName(p);\n return typeof key === \"string\" && PERCENTAGE_KEY_RE.test(key);\n });\n}\n\nconst LITERAL_NODE_TYPES = new Set([\"Literal\", \"NumericLiteral\", \"StringLiteral\"]);\n\n/** Read one value node: a number/string literal, a negative number, or raw source. */\n// fallow-ignore-next-line complexity\nfunction readValueNode(v: Node, source: string): number | string {\n if (\n LITERAL_NODE_TYPES.has(v?.type) &&\n (typeof v.value === \"number\" || typeof v.value === \"string\")\n ) {\n return v.value;\n }\n if (\n v?.type === \"UnaryExpression\" &&\n v.operator === \"-\" &&\n typeof v.argument?.value === \"number\"\n ) {\n return -v.argument.value;\n }\n return `__raw:${source.slice(v.start, v.end)}`;\n}\n\n/**\n * Read a keyframe value ObjectExpression into a record, mirroring the parser's\n * `objectExpressionToRecord`: literals resolve to their value; anything else is\n * preserved as `__raw:<source>` so serializeValue round-trips it verbatim.\n * Keyframe values are literals in practice, so the raw fallback is rarely hit.\n */\nfunction valueNodeToRecord(valueNode: Node, source: string): Record<string, number | string> {\n const record: Record<string, number | string> = {};\n if (valueNode?.type !== \"ObjectExpression\") return record;\n for (const prop of valueNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\") continue;\n record[key] = readValueNode(prop.value, source);\n }\n return record;\n}\n\n/** True when a keyframe value record carries the synthetic `_auto` marker. */\nfunction recordHasAuto(record: Record<string, number | string>): boolean {\n return \"_auto\" in record;\n}\n\n/**\n * Compute `_auto` endpoint overwrites: when the new keyframe is the immediate\n * neighbor of an `_auto` 0% or 100% endpoint, that endpoint is rewritten to\n * `{ ...newProps, _auto: 1 }`. Only fires for interior keyframes. Returns the\n * percentage→overwrite map so the caller can fold these into the per-node final\n * records (never a separate splice).\n */\nfunction autoEndpointOverwrites(\n kfNode: Node,\n source: string,\n percentage: number,\n properties: Record<string, number | string>,\n): Map<any, Record<string, number | string>> {\n const result = new Map<any, Record<string, number | string>>();\n if (percentage <= 0 || percentage >= 100) return result;\n const pctProps = percentagePropsOf(kfNode);\n const allPcts = pctProps\n .map((p: Node) => percentageFromKey(propKeyName(p) ?? \"\"))\n .filter((n: number) => !Number.isNaN(n) && n !== percentage)\n .sort((a: number, b: number) => a - b);\n const leftNeighbor = allPcts.filter((p: number) => p < percentage).pop();\n const rightNeighbor = allPcts.find((p: number) => p > percentage);\n for (const endPct of [0, 100]) {\n const isNeighbor = endPct === 0 ? leftNeighbor === 0 : rightNeighbor === 100;\n if (!isNeighbor) continue;\n const endProp = pctProps.find((p: Node) => percentageFromKey(propKeyName(p) ?? \"\") === endPct);\n if (!endProp) continue;\n const rec = valueNodeToRecord(endProp.value, source);\n if (!recordHasAuto(rec)) continue;\n result.set(endProp, { ...properties, _auto: 1 });\n }\n return result;\n}\n\nfunction findKfPropByPct(kfNode: Node, percentage: number): { prop: Node; idx: number } | null {\n // Match the CLOSEST keyframe within tolerance, not the first one within range.\n // Keyframes at e.g. 0/49/50/100 are all valid (the SDK dedups to a unique\n // match at TOLERANCE=0.001 upstream); picking the first-within-PCT_TOLERANCE=2\n // would hit 49% when the caller meant 50%. Tie-break on the earliest index so\n // the choice stays deterministic.\n const props = kfNode.properties ?? [];\n let best: { prop: Node; idx: number } | null = null;\n let bestDist = Number.POSITIVE_INFINITY;\n for (let i = 0; i < props.length; i++) {\n const prop = props[i];\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\") continue;\n const dist = Math.abs(percentageFromKey(key) - percentage);\n if (dist <= PCT_TOLERANCE && dist < bestDist) {\n best = { prop, idx: i };\n bestDist = dist;\n }\n }\n return best;\n}\n\nexport function updateKeyframeInScript(\n script: string,\n animationId: string,\n percentage: number,\n properties: Record<string, number | string>,\n ease?: string,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode) return script;\n\n // Array-form keyframes (`keyframes: [{x,y}, ...]`) carry no explicit percentages\n // — GSAP distributes them evenly, and the runtime read assigns even percentages\n // (0, 100/(n-1), …). Map the percentage back to an array index and overwrite that\n // element in place (preserving the array form). Without this the function bailed\n // on the ObjectExpression check, so dragging a motion-path node on an array-form\n // tween committed nothing (server no-op).\n if (kfPropNode.value?.type === \"ArrayExpression\") {\n return updateArrayKeyframeByPct(script, kfPropNode.value, percentage, properties, ease);\n }\n if (kfPropNode.value?.type !== \"ObjectExpression\") return script;\n\n const match = findKfPropByPct(kfPropNode.value, percentage);\n if (!match) return script;\n\n const record: Record<string, number | string> = { ...properties };\n if (ease) record.ease = ease;\n const ms = new MagicString(script);\n ms.overwrite(match.prop.value.start, match.prop.value.end, recordToCode(record));\n return ms.toString();\n}\n\n// ponytail: even-spacing index map; if array keyframes ever carry per-element\n// `duration`, switch to matching the closest cumulative position.\nfunction updateArrayKeyframeByPct(\n script: string,\n arrayNode: Node,\n percentage: number,\n properties: Record<string, number | string>,\n ease?: string,\n): string {\n const elements = ((arrayNode.elements ?? []) as Array<Node | null>).filter(\n (el): el is Node => !!el && el.type === \"ObjectExpression\",\n );\n const n = elements.length;\n if (n === 0) return script;\n const idx = n > 1 ? Math.round((percentage / 100) * (n - 1)) : 0;\n const el = elements[Math.max(0, Math.min(n - 1, idx))];\n if (!el) return script;\n const merged: Record<string, number | string> = {\n ...valueNodeToRecord(el, script),\n ...properties,\n };\n if (ease) merged.ease = ease;\n const ms = new MagicString(script);\n ms.overwrite(el.start, el.end, recordToCode(merged));\n return ms.toString();\n}\n\n/**\n * Build the final property record for the keyframe at `percentage`. If a\n * keyframe already exists there, MERGE the new props over the existing record\n * (preserve untouched props, preserve `_auto`, preserve the existing per-keyframe\n * ease when the op omits one); otherwise it's just the new props.\n */\nfunction buildTargetRecord(\n existing: { prop: Node; idx: number } | null,\n source: string,\n properties: Record<string, number | string>,\n ease: string | undefined,\n): Record<string, number | string> {\n if (!existing || existing.prop.value?.type !== \"ObjectExpression\") {\n const record: Record<string, number | string> = { ...properties };\n if (ease) record.ease = ease;\n return record;\n }\n const existingRecord = valueNodeToRecord(existing.prop.value, source);\n const existingEase = typeof existingRecord.ease === \"string\" ? existingRecord.ease : undefined;\n const merged: Record<string, number | string> = { ...existingRecord };\n for (const [k, v] of Object.entries(properties)) merged[k] = v;\n const finalEase = ease ?? existingEase;\n if (finalEase) merged.ease = finalEase;\n else delete merged.ease;\n return merged;\n}\n\n/**\n * Compute the backfilled final record for one sibling keyframe: append any of\n * `newPropKeys` it's missing, using the backfill default. Returns null when\n * nothing changes (so the caller emits no overwrite for it).\n */\nfunction backfilledSiblingRecord(\n valueNode: Node,\n source: string,\n newPropKeys: string[],\n backfillDefaults: Record<string, number | string>,\n): Record<string, number | string> | null {\n if (valueNode?.type !== \"ObjectExpression\") return null;\n const record = valueNodeToRecord(valueNode, source);\n let changed = false;\n for (const pk of newPropKeys) {\n const defaultVal = backfillDefaults[pk];\n if (pk in record || defaultVal == null) continue;\n record[pk] = defaultVal;\n changed = true;\n }\n return changed ? record : null;\n}\n\n/** A located tween whose varsArg has a static keyframes ObjectExpression, or null. */\nfunction locateWithKeyframes(\n script: string,\n animationId: string,\n): { script: string; parsed: ParsedGsapAcornForWrite; target: Node; kfNode: Node } | null {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return null;\n // Converting from()/fromTo() to to() rewrites the content-derived id; match\n // recast's locateAnimationWithFallback by remapping the method segment.\n const convertedId = animationId.replace(/-from-|-fromTo-/, \"-to-\");\n const target =\n parsed.located.find((l) => l.id === animationId) ??\n parsed.located.find((l) => l.id === convertedId);\n if (!target) return null;\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode || kfPropNode.value?.type !== \"ObjectExpression\") return null;\n return { script, parsed, target, kfNode: kfPropNode.value };\n}\n\n/** Locate a tween's keyframes object, converting a flat tween first if absent. */\n// Array-form keyframes (`keyframes: [{x,y}, …]`) → even-percentage object form\n// (`{ \"0%\": {…}, \"33.3%\": {…}, … }`). Inserting a keyframe needs percentage keys,\n// which an even array can't host. Runtime-identical; mirrors the recast path.\nfunction convertArrayKeyframesToObject(script: string, target: Node): string {\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode || kfPropNode.value?.type !== \"ArrayExpression\") return script;\n const els = ((kfPropNode.value.elements ?? []) as Array<Node | null>).filter(\n (el): el is Node => !!el && el.type === \"ObjectExpression\",\n );\n const n = els.length;\n if (n === 0) return script;\n const entries = els.map((el, i) => {\n const pct = n > 1 ? Math.round((i / (n - 1)) * 1000) / 10 : 0;\n return `${JSON.stringify(`${pct}%`)}: ${script.slice(el.start, el.end)}`;\n });\n const ms = new MagicString(script);\n ms.overwrite(kfPropNode.value.start, kfPropNode.value.end, `{ ${entries.join(\", \")} }`);\n return ms.toString();\n}\n\nfunction ensureKeyframesNode(\n script: string,\n animationId: string,\n): { script: string; parsed: ParsedGsapAcornForWrite; target: Node; kfNode: Node } | null {\n const direct = locateWithKeyframes(script, animationId);\n if (direct) return direct;\n\n const parsed = parseGsapScriptAcornForWrite(script);\n const target = parsed?.located.find((l) => l.id === animationId);\n if (!target) return null;\n\n // Array-form keyframes → normalize to object form, then re-locate.\n const kfProp = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (kfProp?.value?.type === \"ArrayExpression\") {\n const normalized = convertArrayKeyframesToObject(script, target);\n if (normalized !== script) return locateWithKeyframes(normalized, animationId);\n return null;\n }\n\n // No static keyframes object — convert the flat tween, then re-locate.\n const converted = convertFlatTweenToKeyframes(script, target);\n if (converted === script) return null;\n return locateWithKeyframes(converted, animationId);\n}\n\n/**\n * Compute the sibling keyframe nodes that need a backfilled prop, excluding the\n * target keyframe and any node already being overwritten as an `_auto` endpoint.\n */\nfunction collectBackfillOverwrites(\n kfNode: Node,\n src: string,\n properties: Record<string, number | string>,\n backfillDefaults: Record<string, number | string> | undefined,\n skip: { existingProp: Node; endpoints: Map<any, unknown> },\n): Map<any, Record<string, number | string>> {\n const result = new Map<any, Record<string, number | string>>();\n if (!backfillDefaults) return result;\n const newPropKeys = Object.keys(properties);\n for (const prop of percentagePropsOf(kfNode)) {\n if (prop === skip.existingProp || skip.endpoints.has(prop)) continue;\n const rec = backfilledSiblingRecord(prop.value, src, newPropKeys, backfillDefaults);\n if (rec) result.set(prop, rec);\n }\n return result;\n}\n\nexport function addKeyframeToScript(\n script: string,\n animationId: string,\n percentage: number,\n properties: Record<string, number | string>,\n ease?: string,\n backfillDefaults?: Record<string, number | string>,\n): string {\n const located = ensureKeyframesNode(script, animationId);\n if (!located) return script;\n const { script: src, kfNode } = located;\n\n const existing = findKfPropByPct(kfNode, percentage);\n\n // Final record for the target keyframe (merge if it already exists).\n const targetRecord = buildTargetRecord(existing, src, properties, ease);\n // `_auto` endpoint syncs fire only on new inserts; a merge landing ON an\n // endpoint already preserves `_auto` via buildTargetRecord.\n const endpointOverwrites = existing\n ? new Map<any, Record<string, number | string>>()\n : autoEndpointOverwrites(kfNode, src, percentage, properties);\n // Backfilled siblings (each node changes at most once).\n const backfillOverwrites = collectBackfillOverwrites(kfNode, src, properties, backfillDefaults, {\n existingProp: existing?.prop,\n endpoints: endpointOverwrites,\n });\n\n // Emit exactly one overwrite per changed node, plus one insert for a new key.\n const ms = new MagicString(src);\n if (existing) {\n // Merge into the existing keyframe at this percentage, preserving sibling\n // properties — overwrite only the given keys. (A whole-value overwrite here\n // would silently drop other properties already keyframed at this percent.)\n if (existing.prop.value?.type === \"ObjectExpression\") {\n for (const [k, v] of Object.entries(properties)) {\n upsertProp(ms, existing.prop.value, k, v);\n }\n if (ease !== undefined) upsertProp(ms, existing.prop.value, \"ease\", ease);\n } else {\n ms.overwrite(existing.prop.value.start, existing.prop.value.end, recordToCode(targetRecord));\n }\n } else {\n insertNewKeyframe(ms, kfNode, percentage, `${percentage}%`, recordToCode(targetRecord));\n }\n for (const [prop, rec] of [...endpointOverwrites, ...backfillOverwrites]) {\n ms.overwrite(prop.value.start, prop.value.end, recordToCode(rec));\n }\n\n return ms.toString();\n}\n\n/** Insert a brand-new `\"pct%\": {...}` property in sorted order. */\nfunction insertNewKeyframe(\n ms: MagicString,\n kfNode: Node,\n percentage: number,\n pctKey: string,\n valueCode: string,\n): void {\n const allProps = (kfNode.properties ?? []).filter((p: Node) => isObjectProperty(p));\n let insertBeforeProp: Node = null;\n for (const prop of allProps) {\n const key = propKeyName(prop);\n if (typeof key === \"string\" && percentageFromKey(key) > percentage) {\n insertBeforeProp = prop;\n break;\n }\n }\n if (insertBeforeProp) {\n ms.appendLeft(insertBeforeProp.start, `${JSON.stringify(pctKey)}: ${valueCode}, `);\n } else {\n const sep = allProps.length > 0 ? \", \" : \"\";\n ms.appendLeft(kfNode.end - 1, `${sep}${JSON.stringify(pctKey)}: ${valueCode}`);\n }\n}\n\n/**\n * Rebuild a vars ObjectExpression that has just dropped below two keyframes,\n * collapsing `keyframes: {…}` back to a flat tween. Mirrors recast's\n * collapseKeyframesToFlat: drop the `keyframes` + `easeEach` keys, preserve every\n * other vars key verbatim, and splice the remaining keyframe's properties (minus\n * its per-keyframe `ease`) in as flat vars keys. Single ms.overwrite of the whole\n * vars node so the splice can't overlap the keyframe removal.\n */\nfunction collapseKeyframesToFlat(\n ms: MagicString,\n varsNode: Node,\n source: string,\n remainingRecord: Record<string, number | string>,\n): void {\n if (varsNode?.type !== \"ObjectExpression\") return;\n const dropKeyframeKeys = (key: string) => key === \"keyframes\" || key === \"easeEach\";\n const { entries } = preservedEntries(varsNode, source, dropKeyframeKeys, {});\n for (const [k, v] of Object.entries(remainingRecord)) {\n if (k !== \"ease\") entries.push(`${safeKey(k)}: ${valueToCode(v)}`);\n }\n ms.overwrite(varsNode.start, varsNode.end, `{ ${entries.join(\", \")} }`);\n}\n\n/** Implicit tween-relative percentage of array-form keyframe index `i` of `n`\n * (GSAP distributes array keyframes evenly: 0%, 1/(n-1), …, 100%). */\nfunction arrayKeyframePct(i: number, n: number): number {\n return n > 1 ? (i / (n - 1)) * 100 : 0;\n}\n\n// Array-form keyframes (`keyframes: [{x,y}, …]`) carry no explicit percentages —\n// GSAP distributes them evenly. removeKeyframeFromScript only handled the\n// object-form (`keyframes: { \"50%\": {…} }`), so removing from an array-form tween\n// was a silent no-op (and the downstream hold-sync then stranded an `hf-hold`).\n// Resolve the element by its implicit percentage and splice it out; collapse to a\n// flat tween when fewer than two remain (parity with the object-form path).\nfunction removeArrayKeyframe(\n ms: MagicString,\n varsArg: Node,\n arrNode: Node,\n script: string,\n percentage: number,\n): boolean {\n const elements: Node[] = (arrNode.elements ?? []).filter(\n (e: Node | null): e is Node => !!e && e.type === \"ObjectExpression\",\n );\n const n = elements.length;\n if (n === 0) return false;\n\n let matchIdx = -1;\n let bestDist = Number.POSITIVE_INFINITY;\n for (let i = 0; i < n; i++) {\n const dist = Math.abs(arrayKeyframePct(i, n) - percentage);\n if (dist <= PCT_TOLERANCE && dist < bestDist) {\n matchIdx = i;\n bestDist = dist;\n }\n }\n if (matchIdx === -1) return false;\n\n const remaining = elements.filter((_, i) => i !== matchIdx);\n if (remaining.length < 2) {\n const sole = remaining[0];\n const record = sole ? valueNodeToRecord(sole, script) : {};\n collapseKeyframesToFlat(ms, varsArg, script, record);\n return true;\n }\n removeProp(ms, elements[matchIdx], elements);\n return true;\n}\n\nexport function removeKeyframeFromScript(\n script: string,\n animationId: string,\n percentage: number,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode) return script;\n\n if (kfPropNode.value?.type === \"ArrayExpression\") {\n const ms = new MagicString(script);\n return removeArrayKeyframe(ms, target.call.varsArg, kfPropNode.value, script, percentage)\n ? ms.toString()\n : script;\n }\n\n if (kfPropNode.value?.type !== \"ObjectExpression\") return script;\n const kfNode = kfPropNode.value;\n\n const match = findKfPropByPct(kfNode, percentage);\n if (!match) return script;\n\n const ms = new MagicString(script);\n\n // If removing this keyframe leaves fewer than two, collapse the keyframes\n // object back to a flat tween (recast parity) instead of leaving a lone\n // keyframe. We rebuild the whole vars node, so we never also splice the kf\n // node — the two edits would overlap.\n const remaining = percentagePropsOf(kfNode).filter((p) => p !== match.prop);\n if (remaining.length < 2) {\n const sole = remaining[0];\n const record = sole ? valueNodeToRecord(sole.value, script) : {};\n collapseKeyframesToFlat(ms, target.call.varsArg, script, record);\n return ms.toString();\n }\n\n const allProps = (kfNode.properties ?? []).filter((p: Node) => isObjectProperty(p));\n removeProp(ms, match.prop, allProps);\n return ms.toString();\n}\n\nexport function removePropertyFromAnimation(\n script: string,\n animationId: string,\n property: string,\n from = false,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const { call } = target;\n const objNode = from ? (call.method === \"fromTo\" ? call.fromArg : null) : call.varsArg;\n if (!objNode) return script;\n const propNode = findPropertyNode(objNode, property);\n if (!propNode) return script;\n const allProps = (objNode.properties ?? []).filter((p: Node) => isObjectProperty(p));\n const ms = new MagicString(script);\n removeProp(ms, propNode, allProps);\n return ms.toString();\n}\n\n/**\n * Remove all keyframes from a tween, collapsing to a flat tween with one\n * keyframe's properties: the first for `from()`, the last otherwise (the\n * destination = the visible resting state).\n */\nexport function removeAllKeyframesFromScript(script: string, animationId: string): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const kfs = target.animation.keyframes?.keyframes;\n if (!kfs || kfs.length === 0) return script;\n\n const sorted = [...kfs].sort((a, b) => a.percentage - b.percentage);\n const collapse = target.call.method === \"from\" ? sorted[0] : sorted[sorted.length - 1];\n if (!collapse) return script;\n\n const ms = new MagicString(script);\n overwriteVarsArg(\n ms,\n target.call,\n buildVarsObjectCode(buildCollapsedFlatVars(target.animation, collapse)),\n );\n return ms.toString();\n}\n\n// Flat vars for a tween collapsing its keyframes onto one stop: existing\n// top-level props, then the collapse keyframe's props (skip per-keyframe\n// `ease`), then duration/ease/extras. Drops keyframes + easeEach by omission.\nfunction buildCollapsedFlatVars(\n animation: GsapAnimation,\n collapse: { properties: Record<string, number | string> },\n): Record<string, number | string> {\n const flat: Record<string, number | string> = { ...animation.properties };\n for (const [k, v] of Object.entries(collapse.properties)) {\n if (k !== \"ease\") flat[k] = v;\n }\n if (animation.duration !== undefined) flat.duration = animation.duration;\n if (animation.ease) flat.ease = animation.ease;\n for (const [k, v] of Object.entries(animation.extras ?? {})) {\n if (typeof v === \"number\" || typeof v === \"string\") flat[k] = v;\n }\n return flat;\n}\n\n/** Build the full replacement vars object for a tween being converted to keyframes. */\nfunction buildKeyframesVarsCode(\n animation: GsapAnimation,\n fromProps: Record<string, number | string>,\n toProps: Record<string, number | string>,\n varsNode: Node,\n source: string,\n setDuration?: number,\n): string {\n const fromEntries = Object.entries(fromProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n const toEntries = Object.entries(toProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n const easeEntry = animation.ease ? `, easeEach: ${JSON.stringify(animation.ease)}` : \"\";\n const kfCode = `{ \"0%\": { ${fromEntries.join(\", \")} }, \"100%\": { ${toEntries.join(\", \")} }${easeEntry} }`;\n // Preserve every non-editable key (duration/delay/callbacks/stagger/yoyo/…)\n // verbatim from source — rebuilding from the animation object alone dropped\n // `delay` (not a GsapAnimation field), shifting the tween's start time.\n let preserved = preservedVarsEntries(varsNode, source);\n // Converting a static `set` → drop its hold markers and give it a real duration\n // so the keyframes span time.\n if (setDuration !== undefined) {\n preserved = preserved.filter((e) => !/^\\s*(immediateRender|data|duration)\\s*:/.test(e));\n }\n const parts: string[] = [`keyframes: ${kfCode}`, ...preserved];\n if (setDuration !== undefined) parts.push(`duration: ${Math.max(0.001, setDuration)}`);\n if (animation.ease) parts.push(`ease: \"none\"`);\n return `{ ${parts.join(\", \")} }`;\n}\n\n/**\n * Convert a flat tween (to/from/fromTo) to percentage-keyframes format.\n * `resolvedFromValues` supplies the current DOM state: overrides the 0% endpoint\n * for `to()`, the 100% endpoint for `from()`, or merges into toProps for `fromTo()`.\n */\nexport function convertToKeyframesFromScript(\n script: string,\n animationId: string,\n resolvedFromValues?: Record<string, number | string>,\n setDuration = 1,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const { animation, call } = target;\n if (animation.keyframes) return script;\n const isSet = call.method === \"set\";\n\n const { fromProps, toProps } = resolveConversionProps(animation, resolvedFromValues);\n const ms = new MagicString(script);\n\n // A GLOBAL `gsap.set(...)` is off-timeline; rewriting only the method emits\n // `gsap.to(...)`, which fires once at load and isn't on the paused master\n // timeline (the engine can't seek/render it). Re-root onto the timeline var\n // and add the position arg the set lacks so the converted tween is seekable.\n if (isSet && animation.global) {\n const calleeObj = call.node.callee.object;\n if (calleeObj?.type === \"Identifier\") {\n ms.overwrite(calleeObj.start, calleeObj.end, parsed.timelineVar);\n }\n const args = call.node.arguments;\n if (args.length > 0 && args.length < 3) {\n ms.appendLeft(args[args.length - 1].end, \", 0\");\n }\n }\n\n // set/from/fromTo all become `to`; fromTo also drops its `from` argument.\n if (call.method === \"from\" || call.method === \"fromTo\" || isSet) {\n ms.overwrite(call.node.callee.property.start, call.node.callee.property.end, \"to\");\n }\n if (call.method === \"fromTo\" && call.fromArg) {\n ms.remove(call.fromArg.start, call.varsArg.start);\n }\n overwriteVarsArg(\n ms,\n call,\n buildKeyframesVarsCode(\n animation,\n fromProps,\n toProps,\n call.varsArg,\n script,\n isSet ? setDuration : undefined,\n ),\n );\n\n return ms.toString();\n}\n\n// ── Keyframe-object code builder ─────────────────────────────────────────────\n\n/** Build a percentage-keyframes object literal: `{ \"0%\": { x: 0 }, \"100%\": { x: 100 } }`. */\nfunction buildKeyframeObjectCode(\n keyframes: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n auto?: boolean;\n }>,\n easeEach?: string,\n): string {\n const entries = keyframes.map((kf) => {\n const props = Object.entries(kf.properties).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n if (kf.ease) props.push(`ease: ${JSON.stringify(kf.ease)}`);\n if (kf.auto) props.push(`_auto: 1`);\n return `${JSON.stringify(`${kf.percentage}%`)}: { ${props.join(\", \")} }`;\n });\n if (easeEach) entries.push(`easeEach: ${JSON.stringify(easeEach)}`);\n return `{ ${entries.join(\", \")} }`;\n}\n\n// ── Materialize keyframes ────────────────────────────────────────────────────\n\n/**\n * Replace a dynamic or static keyframes expression with a fully-resolved\n * percentage-keyframes object. Called when a user first edits a dynamically-\n * generated keyframe in the studio so it becomes statically editable.\n */\nexport function materializeKeyframesFromScript(\n script: string,\n animationId: string,\n keyframes: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n }>,\n easeEach?: string,\n resolvedSelector?: string,\n): string {\n // An empty keyframe list has no materialized form — rebuilding vars with an\n // empty keyframes object would empty the animation. No-op instead.\n if (keyframes.length === 0) return script;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const { call } = target;\n const sorted = [...keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfObjCode = buildKeyframeObjectCode(sorted, easeEach);\n const ms = new MagicString(script);\n\n if (resolvedSelector) {\n const selectorArg = call.node.arguments[0];\n if (selectorArg)\n ms.overwrite(selectorArg.start, selectorArg.end, JSON.stringify(resolvedSelector));\n }\n\n const kfProp = findPropertyNode(call.varsArg, \"keyframes\");\n if (kfProp) {\n ms.overwrite(kfProp.value.start, kfProp.value.end, kfObjCode);\n } else if (call.varsArg?.type === \"ObjectExpression\") {\n const vars = call.varsArg;\n if (vars.properties.length > 0) {\n ms.prependLeft(vars.properties[0].start, `keyframes: ${kfObjCode}, `);\n } else {\n ms.appendLeft(vars.end - 1, `keyframes: ${kfObjCode}`);\n }\n }\n\n const eachProp = findPropertyNode(call.varsArg, \"easeEach\");\n if (eachProp) {\n const allProps = (call.varsArg.properties ?? []).filter((p: Node) => isObjectProperty(p));\n removeProp(ms, eachProp, allProps);\n }\n\n return ms.toString();\n}\n\n// ── Add animation with keyframes ──────────────────────────────────────────────\n\n/** Insert a new keyframed `to()` call and return the new animation ID. */\nexport function addAnimationWithKeyframesToScript(\n script: string,\n targetSelector: string,\n position: number,\n duration: number,\n keyframes: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n auto?: boolean;\n }>,\n ease?: string,\n easeEach?: string,\n): { script: string; id: string } {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, id: \"\" };\n const insertionPoint = findInsertionPoint(parsed);\n if (insertionPoint === null) return { script, id: \"\" };\n\n const sorted = [...keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfObjCode = buildKeyframeObjectCode(sorted, easeEach);\n const varParts = [`keyframes: ${kfObjCode}`, `duration: ${valueToCode(duration)}`];\n if (ease) varParts.push(`ease: ${JSON.stringify(ease)}`);\n const stmtCode = `${parsed.timelineVar}.to(${JSON.stringify(targetSelector)}, { ${varParts.join(\", \")} }, ${valueToCode(position)});`;\n\n const ms = new MagicString(script);\n ms.appendLeft(insertionPoint, \"\\n\" + stmtCode);\n\n const result = ms.toString();\n const reParsed = parseGsapScriptAcornForWrite(result);\n const newId = reParsed?.located[reParsed.located.length - 1]?.id ?? \"\";\n return { script: result, id: newId };\n}\n\n// ── Split into property groups ────────────────────────────────────────────────\n\nfunction collectPropertyKeys(anim: GsapAnimation): Set<string> {\n const keys = new Set<string>();\n if (anim.keyframes) {\n for (const kf of anim.keyframes.keyframes) {\n for (const k of Object.keys(kf.properties)) keys.add(k);\n }\n } else {\n for (const k of Object.keys(anim.properties)) keys.add(k);\n }\n return keys;\n}\n\nfunction partitionPropertyGroups(keys: Set<string>): Map<PropertyGroupName, string[]> {\n const groups = new Map<PropertyGroupName, string[]>();\n for (const key of keys) {\n if (key === \"transformOrigin\") continue;\n const group = classifyPropertyGroup(key);\n let arr = groups.get(group);\n if (!arr) {\n arr = [];\n groups.set(group, arr);\n }\n arr.push(key);\n }\n return groups;\n}\n\nfunction assignTransformOrigin(groupProps: Map<PropertyGroupName, string[]>): void {\n let largestGroup: PropertyGroupName | undefined;\n let largestCount = 0;\n for (const [group, props] of groupProps) {\n if (props.length > largestCount) {\n largestCount = props.length;\n largestGroup = group;\n }\n }\n const largest = largestGroup ? groupProps.get(largestGroup) : undefined;\n if (largest) largest.push(\"transformOrigin\");\n}\n\nfunction filterGroupKeyframes(\n kfs: GsapPercentageKeyframe[],\n propSet: Set<string>,\n): Array<{ percentage: number; properties: Record<string, number | string>; ease?: string }> {\n const result: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n }> = [];\n for (const kf of kfs) {\n const filtered: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(kf.properties)) {\n if (propSet.has(k)) filtered[k] = v;\n }\n if (Object.keys(filtered).length > 0) {\n result.push({\n percentage: kf.percentage,\n properties: filtered,\n ...(kf.ease ? { ease: kf.ease } : {}),\n });\n }\n }\n return result;\n}\n\nfunction filterGroupProperties(\n properties: Record<string, number | string>,\n propSet: Set<string>,\n): Record<string, number | string> {\n const result: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(properties)) {\n if (propSet.has(k)) result[k] = v;\n }\n return result;\n}\n\nfunction addGroupAnimToScript(\n script: string,\n anim: GsapAnimation,\n propSet: Set<string>,\n): { script: string; id: string } {\n if (anim.keyframes) {\n const groupKeyframes = filterGroupKeyframes(anim.keyframes.keyframes, propSet);\n if (groupKeyframes.length === 0) return { script, id: \"\" };\n const pos = typeof anim.position === \"number\" ? anim.position : 0;\n return addAnimationWithKeyframesToScript(\n script,\n anim.targetSelector,\n pos,\n anim.duration ?? 0.5,\n groupKeyframes,\n anim.keyframes.easeEach ?? anim.ease,\n );\n }\n const groupProperties = filterGroupProperties(anim.properties, propSet);\n if (Object.keys(groupProperties).length === 0) return { script, id: \"\" };\n const fromProperties =\n anim.method === \"fromTo\" && anim.fromProperties\n ? filterGroupProperties(anim.fromProperties, propSet)\n : undefined;\n return addAnimationToScript(script, {\n targetSelector: anim.targetSelector,\n method: anim.method,\n position: anim.position,\n duration: anim.duration,\n ease: anim.ease,\n properties: groupProperties,\n fromProperties,\n extras: anim.extras,\n });\n}\n\n/**\n * Split a mixed-property tween into one tween per property group (position,\n * scale, visual, etc.) so each group can be edited independently.\n * Returns the updated script and the IDs of the newly-created tweens.\n */\nexport function splitIntoPropertyGroupsFromScript(\n script: string,\n animationId: string,\n): { script: string; ids: string[] } {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, ids: [animationId] };\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return { script, ids: [animationId] };\n const { animation } = target;\n\n const allPropKeys = collectPropertyKeys(animation);\n const groupProps = partitionPropertyGroups(allPropKeys);\n if (groupProps.size <= 1) return { script, ids: [animationId] };\n if (allPropKeys.has(\"transformOrigin\")) assignTransformOrigin(groupProps);\n\n let result = removeAnimationFromScript(script, animationId);\n for (const [, props] of groupProps) {\n const { script: next, id } = addGroupAnimToScript(result, animation, new Set(props));\n if (id) result = next;\n }\n\n const reParsed = parseGsapScriptAcornForWrite(result);\n const newIds = (reParsed?.located ?? [])\n .filter((l) => l.animation.targetSelector === animation.targetSelector)\n .map((l) => l.id);\n return { script: result, ids: newIds };\n}\n\n// ── Label write ops ───────────────────────────────────────────────────────────\n\n/** True when `expr` is `tl.<method>(…)` rooted at the timeline var. */\nfunction isTimelineMethodCall(expr: Node, timelineVar: string, method: string): boolean {\n return (\n expr?.type === \"CallExpression\" &&\n expr.callee?.type === \"MemberExpression\" &&\n isTimelineRooted(expr.callee.object, timelineVar) &&\n expr.callee.property?.name === method\n );\n}\n\n/** True when `expr` is `tl.addLabel(\"<name>\", …)` rooted at the timeline var. */\nfunction isAddLabelCall(expr: Node, timelineVar: string, name: string): boolean {\n const firstArg = expr?.arguments?.[0];\n return (\n isTimelineMethodCall(expr, timelineVar, \"addLabel\") &&\n firstArg?.type === \"Literal\" &&\n firstArg.value === name\n );\n}\n\n/** Every `tl.addLabel(\"<name>\", …)` ExpressionStatement in the script. */\nfunction findLabelStatements(parsed: ParsedGsapAcornForWrite, name: string): Node[] {\n const targets: Node[] = [];\n acornWalk.simple(parsed.ast, {\n ExpressionStatement(node: Node) {\n if (isAddLabelCall(node.expression, parsed.timelineVar, name)) targets.push(node);\n },\n });\n return targets;\n}\n\nexport function addLabelToScript(script: string, name: string, position: number): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n\n // If the label already exists, MOVE it (overwrite its position) rather than\n // appending a duplicate. Two same-named addLabel statements make removeLabel\n // over-remove — it deletes every match, including a pre-existing label the\n // user never touched.\n const existing = findLabelStatements(parsed, name)[0];\n if (existing) {\n const ms = new MagicString(script);\n const posArg = existing.expression.arguments?.[1];\n if (posArg) ms.overwrite(posArg.start, posArg.end, valueToCode(position));\n else ms.appendLeft(existing.expression.end - 1, `, ${valueToCode(position)}`);\n return ms.toString();\n }\n\n const insertionPoint = findInsertionPoint(parsed);\n if (insertionPoint === null) return script;\n\n const ms = new MagicString(script);\n const labelCode = `${parsed.timelineVar}.addLabel(${JSON.stringify(name)}, ${valueToCode(position)});`;\n ms.appendLeft(insertionPoint, \"\\n\" + labelCode);\n return ms.toString();\n}\n\nexport function removeLabelFromScript(script: string, name: string): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n\n const targets = findLabelStatements(parsed, name);\n if (!targets.length) return script;\n\n const ms = new MagicString(script);\n for (const target of targets) {\n const end =\n target.end < script.length && script[target.end] === \"\\n\" ? target.end + 1 : target.end;\n ms.remove(target.start, end);\n }\n return ms.toString();\n}\n\n// ── Arc path helpers ─────────────────────────────────────────────────────────\n\n/**\n * Remove a set of properties from an ObjectExpression in a single pass.\n * Groups consecutive marked props into blocks to avoid overlapping remove ranges.\n */\nfunction removePropsByKey(ms: MagicString, objNode: Node, keys: Set<string>): void {\n if (objNode?.type !== \"ObjectExpression\") return;\n const allProps = (objNode.properties ?? []).filter(isObjectProperty);\n const marked = allProps.map((p: Node) => keys.has(propKeyName(p) ?? \"\"));\n let i = 0;\n while (i < allProps.length) {\n if (!marked[i]) {\n i++;\n continue;\n }\n const blockStart = i;\n while (i < allProps.length && marked[i]) i++;\n ms.remove(...blockRemoveRange(allProps, blockStart, i));\n }\n}\n\nfunction blockRemoveRange(\n allProps: Node[],\n blockStart: number,\n blockEnd: number,\n): [number, number] {\n if (blockStart === 0 && blockEnd === allProps.length)\n return [allProps[0].start, allProps[allProps.length - 1].end];\n if (blockStart === 0) return [allProps[0].start, allProps[blockEnd].start];\n return [allProps[blockStart - 1].end, allProps[blockEnd - 1].end];\n}\n\n// fallow-ignore-next-line complexity\nfunction readLastWaypointXY(mpVal: Node): { x: number | null; y: number | null } {\n if (mpVal?.type !== \"ObjectExpression\") return { x: null, y: null };\n const pathProp = findPropertyNode(mpVal, \"path\");\n if (pathProp?.value?.type !== \"ArrayExpression\") return { x: null, y: null };\n const elems: Node[] = pathProp.value.elements ?? [];\n const last = elems[elems.length - 1];\n if (last?.type !== \"ObjectExpression\") return { x: null, y: null };\n return {\n x: readNumericLiteralNode(findPropertyNode(last, \"x\")?.value),\n y: readNumericLiteralNode(findPropertyNode(last, \"y\")?.value),\n };\n}\n\n/**\n * Read a numeric value node — a plain numeric literal or a unary-minus negative\n * literal (e.g. `-120`). Returns null for anything non-numeric. Without the\n * UnaryExpression branch, negative waypoint coords (parsed as a UnaryExpression\n * with no `.value`) would be lost when disabling an arc path.\n */\nfunction readNumericLiteralNode(v: Node): number | null {\n if (LITERAL_NODE_TYPES.has(v?.type) && typeof v.value === \"number\") return v.value;\n if (\n v?.type === \"UnaryExpression\" &&\n v.operator === \"-\" &&\n typeof v.argument?.value === \"number\"\n ) {\n return -v.argument.value;\n }\n return null;\n}\n\nfunction disableArcPath(ms: MagicString, call: TweenCallInfo): boolean {\n const mpProp = findPropertyNode(call.varsArg, \"motionPath\");\n if (!mpProp) return false;\n const { x, y } = readLastWaypointXY(mpProp.value);\n if (x === null && y === null) {\n const allProps = (call.varsArg.properties ?? []).filter(isObjectProperty);\n removeProp(ms, mpProp, allProps);\n return true;\n }\n // Overwrite the entire motionPath property with the recovered x/y pair — avoids\n // the appendLeft+remove range-boundary issue in MagicString.\n const parts: string[] = [];\n if (x !== null) parts.push(`x: ${x}`);\n if (y !== null) parts.push(`y: ${y}`);\n ms.overwrite(mpProp.start, mpProp.end, parts.join(\", \"));\n return true;\n}\n\nfunction stripXYFromKeyframes(ms: MagicString, kfPropNode: Node): void {\n if (kfPropNode?.value?.type !== \"ObjectExpression\") return;\n const xyKeys = new Set([\"x\", \"y\"]);\n for (const pctProp of (kfPropNode.value.properties ?? []).filter(isObjectProperty)) {\n const k = propKeyName(pctProp);\n if (typeof k === \"string\" && k.endsWith(\"%\") && pctProp.value?.type === \"ObjectExpression\") {\n removePropsByKey(ms, pctProp.value, xyKeys);\n }\n }\n}\n\nfunction enableArcPath(\n ms: MagicString,\n call: TweenCallInfo,\n animation: GsapAnimation,\n config: ArcPathConfig,\n): boolean {\n const waypoints = extractArcWaypoints(animation);\n if (waypoints.length < 2) return false;\n const segments: ArcPathSegment[] =\n config.segments.length === waypoints.length - 1\n ? config.segments\n : Array.from({ length: waypoints.length - 1 }, () => ({ curviness: 1 }));\n const motionPathCode = buildMotionPathObjectCode({\n waypoints,\n segments,\n autoRotate: config.autoRotate,\n });\n const vars = call.varsArg;\n if (vars?.type !== \"ObjectExpression\") return false;\n // Insert motionPath right after the opening `{` (appendRight at start+1) so the\n // insertion point can never coincide with the end boundary of the x/y removal\n // range. upsertProp would appendLeft at `end - 1`, which collides with a\n // remove-range that ends at the same offset when x/y are the only props —\n // MagicString then discards the append and the output loses everything.\n const editable = (vars.properties ?? []).filter(isObjectProperty);\n const survivesRemoval = editable.some((p: Node) => {\n const k = propKeyName(p);\n return k !== \"x\" && k !== \"y\";\n });\n const sep = survivesRemoval ? \", \" : \"\";\n ms.appendRight(vars.start + 1, ` motionPath: ${motionPathCode}${sep}`);\n stripXYFromKeyframes(ms, findPropertyNode(call.varsArg, \"keyframes\"));\n removePropsByKey(ms, call.varsArg, new Set([\"x\", \"y\"]));\n return true;\n}\n\nexport function setArcPathInScript(\n script: string,\n animationId: string,\n config: ArcPathConfig,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const ms = new MagicString(script);\n const handled = config.enabled\n ? enableArcPath(ms, target.call, target.animation, config)\n : disableArcPath(ms, target.call);\n return handled ? ms.toString() : script;\n}\n\nexport function updateArcSegmentInScript(\n script: string,\n animationId: string,\n segmentIndex: number,\n update: Partial<ArcPathSegment>,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const { call, animation } = target;\n if (!animation.arcPath?.enabled) return script;\n\n const segments = [...animation.arcPath.segments];\n const existingSeg = segments[segmentIndex];\n if (segmentIndex < 0 || segmentIndex >= segments.length || !existingSeg) return script;\n\n segments[segmentIndex] = { ...existingSeg, ...update };\n\n const waypoints = extractArcWaypoints(animation);\n if (waypoints.length < 2) return script;\n\n const motionPathCode = buildMotionPathObjectCode({\n waypoints,\n segments,\n autoRotate: animation.arcPath.autoRotate,\n });\n\n const mpProp = findPropertyNode(call.varsArg, \"motionPath\");\n if (!mpProp) return script;\n\n const ms = new MagicString(script);\n ms.overwrite(mpProp.value.start, mpProp.value.end, motionPathCode);\n return ms.toString();\n}\n\nexport function removeArcPathFromScript(script: string, animationId: string): string {\n return setArcPathInScript(script, animationId, {\n enabled: false,\n autoRotate: false,\n segments: [],\n });\n}\n\n// ── splitAnimationsInScript helpers ──────────────────────────────────────────\n\n/** Overwrite the selector (first arg) of a tween call. */\nfunction updateAnimationSelectorInScript(\n script: string,\n animationId: string,\n newSelector: string,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const selectorArg = target.call.node.arguments?.[0];\n if (!selectorArg) return script;\n const ms = new MagicString(script);\n ms.overwrite(selectorArg.start, selectorArg.end, JSON.stringify(newSelector));\n return ms.toString();\n}\n\n/**\n * Insert a `tl.set()` call immediately after the timeline declaration\n * (before existing tweens) to establish inherited state on a new element.\n */\nfunction insertInheritedStateSetInScript(\n script: string,\n selector: string,\n position: number,\n properties: Record<string, number | string>,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const props = Object.entries(properties)\n .map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`)\n .join(\", \");\n const code = `${parsed.timelineVar}.set(${JSON.stringify(selector)}, { ${props} }, ${position});`;\n const ms = new MagicString(script);\n const tlDecl = findTimelineDeclarationStatement(parsed.ast, parsed.timelineVar);\n const firstLocated = parsed.located[0];\n if (tlDecl) {\n ms.appendLeft(tlDecl.end, \"\\n\" + code);\n } else if (firstLocated) {\n const firstCall = firstLocated.call;\n const exprStmt = findEnclosingExpressionStatement(firstCall.ancestors);\n const insertAt = exprStmt?.start ?? firstCall.node.start;\n ms.prependLeft(insertAt, code + \"\\n\");\n } else {\n ms.append(\"\\n\" + code);\n }\n return ms.toString();\n}\n\n/**\n * Compute, in forward (timeline) order, the inherited-props baseline available\n * BEFORE each matching tween, plus the final cumulative state at the split point.\n * A tween contributes to later baselines when it ends at/before the split (full\n * props or last keyframe), spans the split via keyframes (kfs at/before split),\n * or spans the split as a flat tween (its interpolated midpoint). Decoupled from\n * the reverse write loop so the spanning-tween midpoint reads earlier tweens.\n */\n// fallow-ignore-next-line complexity\nfunction computeForwardBaselines(\n matching: GsapAnimation[],\n splitTime: number,\n): { before: Array<Record<string, number | string>>; final: Record<string, number | string> } {\n const before: Array<Record<string, number | string>> = [];\n const acc: Record<string, number | string> = {};\n for (const anim of matching) {\n before.push({ ...acc });\n const pos = typeof anim.position === \"number\" ? anim.position : 0;\n const dur = anim.duration ?? 0;\n const animEnd = pos + dur;\n\n if (anim.keyframes) {\n const kfs = anim.keyframes.keyframes;\n if (pos >= splitTime) {\n // Moves wholly to the new element — contributes nothing to the baseline.\n } else if (animEnd > splitTime) {\n for (const kf of kfs) {\n const kfTime = pos + (kf.percentage / 100) * dur;\n if (kfTime <= splitTime) {\n for (const [k, v] of Object.entries(kf.properties)) acc[k] = v;\n }\n }\n } else {\n const lastKf = kfs[kfs.length - 1];\n if (lastKf) {\n for (const [k, v] of Object.entries(lastKf.properties)) acc[k] = v;\n }\n }\n continue;\n }\n\n if (animEnd <= splitTime) {\n for (const [k, v] of Object.entries(anim.properties)) acc[k] = v;\n continue;\n }\n\n if (pos >= splitTime) continue;\n\n // Flat tween spanning the split — its midpoint becomes the inherited value.\n const progress = dur > 0 ? (splitTime - pos) / dur : 0;\n const fromSource = anim.fromProperties ?? acc;\n for (const [k, v] of Object.entries(anim.properties)) {\n if (typeof v !== \"number\") {\n acc[k] = v;\n continue;\n }\n const fromVal = typeof fromSource[k] === \"number\" ? (fromSource[k] as number) : 0;\n acc[k] = fromVal + (v - fromVal) * progress;\n }\n }\n return { before, final: { ...acc } };\n}\n\n// Split one tween that straddles the split point: trim the original to the\n// first half (interpolated midpoint as its new end) and add a fromTo for the\n// second half on the new element. `fromSource` is the forward baseline.\nfunction buildSpanningSplit(\n result: string,\n anim: GsapAnimation,\n pos: number,\n dur: number,\n fromSource: Record<string, number | string>,\n ctx: { splitTime: number; newSelector: string; newElementStart: number },\n): string {\n const progress = dur > 0 ? (ctx.splitTime - pos) / dur : 0;\n const midProps: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(anim.properties)) {\n if (typeof v !== \"number\") {\n midProps[k] = v;\n continue;\n }\n const fromVal = typeof fromSource[k] === \"number\" ? (fromSource[k] as number) : 0;\n midProps[k] = fromVal + (v - fromVal) * progress;\n }\n const trimmed = updateAnimationInScript(result, anim.id, {\n duration: ctx.splitTime - pos,\n properties: midProps,\n });\n return addAnimationToScript(trimmed, {\n targetSelector: ctx.newSelector,\n method: \"fromTo\",\n position: ctx.newElementStart,\n duration: pos + dur - ctx.splitTime,\n properties: { ...anim.properties },\n fromProperties: { ...midProps },\n ease: anim.ease,\n extras: anim.extras,\n }).script;\n}\n\ntype SplitCtx = {\n splitTime: number;\n originalSelector: string;\n newSelector: string;\n newElementStart: number;\n};\n\n// Decide what one matching tween does at the split point: move to the new\n// element (wholly after), stay (wholly before / keyframes before), get skipped\n// (keyframes spanning), or get interpolated in half (spanning). Returns the\n// updated script; pushes any skip reason into `skippedSelectors`.\nfunction applyTweenSplit(\n result: string,\n anim: GsapAnimation,\n baselineBefore: Record<string, number | string>,\n ctx: SplitCtx,\n skippedSelectors: string[],\n): string {\n const pos = typeof anim.position === \"number\" ? anim.position : 0;\n const dur = anim.duration ?? 0;\n const animEnd = pos + dur;\n\n if (anim.keyframes) {\n if (pos >= ctx.splitTime)\n return updateAnimationSelectorInScript(result, anim.id, ctx.newSelector);\n if (animEnd > ctx.splitTime) {\n skippedSelectors.push(`${ctx.originalSelector} (keyframes spanning split)`);\n }\n // Inherited-state for kf tweens is handled by computeForwardBaselines.\n return result;\n }\n // Wholly before the split — kept on the original element.\n if (animEnd <= ctx.splitTime) return result;\n // Wholly after — move to the new element.\n if (pos >= ctx.splitTime)\n return updateAnimationSelectorInScript(result, anim.id, ctx.newSelector);\n // Spans the split — interpolate the midpoint from the FORWARD baseline.\n const fromSource = anim.fromProperties ?? baselineBefore;\n return buildSpanningSplit(result, anim, pos, dur, fromSource, ctx);\n}\n\nexport function splitAnimationsInScript(\n script: string,\n opts: SplitAnimationsOptions,\n): SplitAnimationsResult {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, skippedSelectors: [] };\n\n const originalSelector = `#${opts.originalId}`;\n const newSelector = `#${opts.newId}`;\n\n const animations = parsed.located.map((l) => l.animation);\n const skippedSelectors: string[] = [];\n\n for (const a of animations) {\n if (a.targetSelector !== originalSelector && a.targetSelector.includes(opts.originalId)) {\n skippedSelectors.push(a.targetSelector);\n }\n }\n\n const matching = animations.filter((a) => a.targetSelector === originalSelector);\n if (matching.length === 0) return { script, skippedSelectors };\n\n let result = script;\n const newElementStart = opts.splitTime;\n\n // Forward pre-pass: compute the inherited-props baseline available BEFORE each\n // matching tween, in source/timeline order. The write loop below runs in\n // REVERSE (so updateAnimationSelectorInScript's selector edits can't shift the\n // count-based IDs of not-yet-processed tweens), but the spanning-tween midpoint\n // interpolation needs the baseline from EARLIER tweens — which a reverse\n // accumulator hasn't seen yet. Decoupling the two fixes the wrong midpoint.\n const { before: baselineBefore, final: finalInheritedProps } = computeForwardBaselines(\n matching,\n opts.splitTime,\n );\n\n // Reverse iteration: updateAnimationSelectorInScript mutates selectors which\n // can shift count-based ID suffixes for later animations.\n const ctx = { splitTime: opts.splitTime, originalSelector, newSelector, newElementStart };\n for (let i = matching.length - 1; i >= 0; i--) {\n const anim = matching[i];\n if (!anim) continue;\n result = applyTweenSplit(result, anim, baselineBefore[i] ?? {}, ctx, skippedSelectors);\n }\n\n if (Object.keys(finalInheritedProps).length > 0) {\n result = insertInheritedStateSetInScript(\n result,\n newSelector,\n newElementStart,\n finalInheritedProps,\n );\n }\n\n return { script: result, skippedSelectors };\n}\n\n// ── Unroll dynamic animations ────────────────────────────────────────────────\n\nfunction isLoopNode(node: Node): boolean {\n const t = node?.type;\n return (\n t === \"ForStatement\" ||\n t === \"ForInStatement\" ||\n t === \"ForOfStatement\" ||\n t === \"WhileStatement\"\n );\n}\n\nfunction isForEachStatement(node: Node): boolean {\n return (\n node?.type === \"ExpressionStatement\" &&\n node.expression?.type === \"CallExpression\" &&\n node.expression.callee?.property?.name === \"forEach\"\n );\n}\n\n/** The nearest enclosing loop / forEach AST node (not just its byte range). */\nfunction findEnclosingLoopNode(ancestors: Node[]): Node | null {\n for (let i = ancestors.length - 2; i >= 0; i--) {\n const node = ancestors[i];\n if (isLoopNode(node) || isForEachStatement(node)) return node;\n }\n return null;\n}\n\n/** Statements making up a loop's body block, or null when not a simple block. */\nfunction loopBodyStatements(loopNode: Node): Node[] | null {\n let body: Node;\n if (loopNode?.type === \"ExpressionStatement\") {\n // forEach(cb): body is the callback's block.\n const cb = loopNode.expression?.arguments?.[0];\n body = cb?.body;\n } else {\n body = loopNode?.body;\n }\n if (body?.type !== \"BlockStatement\") return null;\n return (body.body ?? []).filter((s: Node) => s?.type === \"ExpressionStatement\");\n}\n\n/** The loop's index identifier name (`for (let i …)`), used for per-iteration substitution. */\nfunction loopIndexVarName(loopNode: Node): string | null {\n if (loopNode?.type === \"ForStatement\") {\n const decl = loopNode.init?.declarations?.[0];\n return typeof decl?.id?.name === \"string\" ? decl.id.name : null;\n }\n return null;\n}\n\n/**\n * Rewrite one body statement's source for iteration `idx`: replace USES of the\n * loop index variable (AST Identifier nodes) with the literal index. AST-based,\n * not a text regex, so the index name appearing inside a string literal (e.g. a\n * selector \".row-i\") or as a non-computed member/key (`obj.i`, `{ i: … }`) is\n * left untouched — only real references to the variable are substituted.\n */\n// An identifier in \"binding position\" is a name, not a value reference: a\n// non-computed member property (`obj.i`) or object-literal key (`{ i: … }`).\n// Those must NOT be substituted with the iteration index.\nfunction isIndexBindingPosition(node: Node, parent: Node): boolean {\n if (parent?.type === \"MemberExpression\") return parent.property === node && !parent.computed;\n if (parent?.type === \"Property\" || parent?.type === \"ObjectProperty\") {\n return parent.key === node && !parent.computed;\n }\n return false;\n}\n\nfunction substituteLoopIndex(stmt: Node, indexVar: string, idx: number, script: string): string {\n const base = stmt.start as number;\n const src = script.slice(base, stmt.end as number);\n const ranges: Array<[number, number]> = [];\n acornWalk.ancestor(stmt, {\n Identifier(node: Node, _state: unknown, ancestors: Node[]) {\n if (node.name !== indexVar) return;\n if (isIndexBindingPosition(node, ancestors[ancestors.length - 2])) return;\n ranges.push([(node.start as number) - base, (node.end as number) - base]);\n },\n });\n if (ranges.length === 0) return src;\n ranges.sort((a, b) => b[0] - a[0]);\n let out = src;\n for (const [s, e] of ranges) out = out.slice(0, s) + String(idx) + out.slice(e);\n return out;\n}\n\nfunction buildUnrollReplacement(\n timelineVar: string,\n animation: GsapAnimation,\n elements: Array<{\n selector: string;\n keyframes: Array<{ percentage: number; properties: Record<string, number | string> }>;\n easeEach?: string;\n }>,\n): string {\n const duration = typeof animation.duration === \"number\" ? animation.duration : 8;\n const ease = typeof animation.ease === \"string\" ? animation.ease : \"none\";\n const pos = animation.position ?? 0;\n const posCode = typeof pos === \"number\" ? String(pos) : JSON.stringify(pos);\n const calls = elements.map((el) => {\n const sorted = [...el.keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfCode = buildKeyframeObjectCode(sorted, el.easeEach);\n return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${JSON.stringify(ease)} }, ${posCode});`;\n });\n return calls.join(\"\\n \");\n}\n\nexport type UnrollElement = {\n selector: string;\n keyframes: Array<{ percentage: number; properties: Record<string, number | string> }>;\n easeEach?: string;\n};\n\n/** Build one element's unrolled `tl.to(...)` call from the target animation. */\nfunction buildUnrollCallForElement(\n timelineVar: string,\n animation: GsapAnimation,\n el: UnrollElement,\n): string {\n const duration = typeof animation.duration === \"number\" ? animation.duration : 8;\n const ease = typeof animation.ease === \"string\" ? animation.ease : \"none\";\n const pos = animation.position ?? 0;\n const posCode = typeof pos === \"number\" ? String(pos) : JSON.stringify(pos);\n const sorted = [...el.keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfCode = buildKeyframeObjectCode(sorted, el.easeEach);\n return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${JSON.stringify(ease)} }, ${posCode});`;\n}\n\n/** Sentinel: the unroll cannot safely reproduce the loop body — caller no-ops. */\nconst REFUSE_UNROLL = Symbol(\"refuse-unroll\");\n\n/** Every statement in a loop's body block (unfiltered), or [] when not a block. */\nfunction loopBodyRawStatements(loopNode: Node): Node[] {\n const body =\n loopNode?.type === \"ExpressionStatement\"\n ? loopNode.expression?.arguments?.[0]?.body\n : loopNode?.body;\n return body?.type === \"BlockStatement\" ? (body.body ?? []) : [];\n}\n\n/** A node that re-binds `indexVar`: a re-declaration or a function param. */\nfunction rebindsIndex(node: Node, indexVar: string): boolean {\n if (node.type === \"VariableDeclarator\") return node.id?.name === indexVar;\n if (\n node.type === \"FunctionExpression\" ||\n node.type === \"FunctionDeclaration\" ||\n node.type === \"ArrowFunctionExpression\"\n ) {\n return (node.params ?? []).some((p: Node) => p?.name === indexVar);\n }\n return false;\n}\n\n/** Object shorthand `{ i }` — substituting the value would yield invalid `{ 0 }`. */\nfunction isShorthandIndexUse(node: Node, indexVar: string): boolean {\n return (\n (node.type === \"Property\" || node.type === \"ObjectProperty\") &&\n node.shorthand === true &&\n propKeyName(node) === indexVar\n );\n}\n\n/**\n * A sibling statement can't be safely index-substituted when it re-binds the\n * loop index (shadowing — a nested `for (let i …)`, a callback param `i`) or\n * uses it in object shorthand (`{ i }`, which would splice to the invalid\n * `{ 0 }`). substituteLoopIndex has no scope analysis, so in these cases it\n * would emit broken or wrong code — the unroll must refuse instead.\n */\nfunction hasUnsafeLoopIndexUse(stmt: Node, indexVar: string): boolean {\n let unsafe = false;\n acornWalk.full(stmt, (node: Node) => {\n if (!unsafe && (isShorthandIndexUse(node, indexVar) || rebindsIndex(node, indexVar))) {\n unsafe = true;\n }\n });\n return unsafe;\n}\n\n/** How to handle the loop body's non-target siblings when unrolling. */\nfunction unrollSiblingStrategy(\n loopNode: Node,\n targetStmt: Node,\n stmts: Node[],\n indexVar: string | null,\n): \"blanket\" | \"refuse\" | \"preserve\" {\n const siblings = stmts.filter((s) => s !== targetStmt);\n // A sibling the filtered statement list doesn't model (non-ExpressionStatement)\n // would be silently lost by either path — refuse if any exists.\n const hasUnmodeledSibling = loopBodyRawStatements(loopNode).some(\n (s) => s !== targetStmt && !stmts.includes(s),\n );\n if (siblings.length === 0 && !hasUnmodeledSibling) return \"blanket\";\n if (hasUnmodeledSibling || !indexVar) return \"refuse\";\n return siblings.some((s) => hasUnsafeLoopIndexUse(s, indexVar)) ? \"refuse\" : \"preserve\";\n}\n\n/** Emit the per-iteration unrolled lines (target → static tl.to, siblings → index-substituted). */\nfunction emitUnrolledLines(\n stmts: Node[],\n targetStmt: Node,\n elements: UnrollElement[],\n timelineVar: string,\n animation: GsapAnimation,\n indexVar: string,\n script: string,\n): string {\n const lines: string[] = [];\n for (let idx = 0; idx < elements.length; idx++) {\n const el = elements[idx];\n if (!el) continue;\n for (const stmt of stmts) {\n lines.push(\n stmt === targetStmt\n ? buildUnrollCallForElement(timelineVar, animation, el)\n : substituteLoopIndex(stmt, indexVar, idx, script),\n );\n }\n }\n return lines.join(\"\\n \");\n}\n\n/**\n * Unroll the loop body, preserving every statement that is NOT the target tween.\n * For each iteration, emit each non-target statement with the loop index\n * substituted (e.g. `tl.set(items[i], …)` → `tl.set(items[0], …)`), and replace\n * the target tween statement with that element's static `tl.to()` call.\n *\n * Returns null when a blanket overwrite is lossless (no sibling statements), and\n * REFUSE_UNROLL when siblings exist but can't be safely reproduced — a non-`for`\n * loop (no numeric index to splice), a statement we don't model, or an unsafe\n * index use (shadowing / shorthand). Refusing no-ops the unroll, which is safe:\n * the dynamic loop keeps rendering correctly, just un-flattened.\n */\nfunction buildLoopUnrollPreserving(\n script: string,\n timelineVar: string,\n animation: GsapAnimation,\n elements: UnrollElement[],\n loopNode: Node,\n targetStmt: Node,\n): string | null | typeof REFUSE_UNROLL {\n const stmts = loopBodyStatements(loopNode);\n if (!stmts || !stmts.includes(targetStmt)) return null;\n const indexVar = loopIndexVarName(loopNode);\n const strategy = unrollSiblingStrategy(loopNode, targetStmt, stmts, indexVar);\n if (strategy === \"blanket\") return null;\n if (strategy === \"refuse\" || !indexVar) return REFUSE_UNROLL;\n return emitUnrolledLines(stmts, targetStmt, elements, timelineVar, animation, indexVar, script);\n}\n\n/**\n * Replace a dynamic loop that generates multiple tween calls with individual\n * static `tl.to()` calls — one per element. Finds the loop containing the\n * animation and replaces the loop with unrolled static calls, preserving every\n * non-target statement in the loop body per iteration.\n */\nexport function unrollDynamicAnimations(\n script: string,\n animationId: string,\n elements: UnrollElement[],\n): string {\n // An empty element list has no unrolled form — replacing the loop/statement\n // with zero calls would silently delete the animation. No-op instead.\n if (elements.length === 0) return script;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const ms = new MagicString(script);\n const loopNode = findEnclosingLoopNode(target.call.ancestors);\n if (loopNode) {\n const targetStmt = findEnclosingExpressionStatement(target.call.ancestors);\n const preserving = targetStmt\n ? buildLoopUnrollPreserving(\n script,\n parsed.timelineVar,\n target.animation,\n elements,\n loopNode,\n targetStmt,\n )\n : null;\n // Siblings exist but can't be safely reproduced — leave the loop untouched\n // rather than drop or corrupt them. The op no-ops (before === after).\n if (preserving === REFUSE_UNROLL) return script;\n // Fall back to the simple whole-body replacement when the body isn't a plain\n // block of statements we can preserve.\n const replacement =\n preserving ?? buildUnrollReplacement(parsed.timelineVar, target.animation, elements);\n ms.overwrite(loopNode.start as number, loopNode.end as number, replacement);\n } else {\n const stmt = findEnclosingExpressionStatement(target.call.ancestors);\n if (!stmt) return script;\n const replacement = buildUnrollReplacement(parsed.timelineVar, target.animation, elements);\n ms.overwrite(stmt.start as number, stmt.end as number, replacement);\n }\n return ms.toString();\n}\n","/**\n * GSAP property and ease constants.\n *\n * Extracted into a standalone module so browser code can import them\n * without pulling in gsapParser (which depends on recast / @babel/parser).\n */\n\nexport const SUPPORTED_PROPS = [\n // 2D Transforms\n \"x\",\n \"y\",\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"rotation\",\n \"skewX\",\n \"skewY\",\n // 3D Transforms\n \"z\",\n \"rotationX\",\n \"rotationY\",\n \"rotationZ\",\n \"perspective\",\n \"transformPerspective\",\n \"transformOrigin\",\n // Visibility\n \"opacity\",\n \"visibility\",\n \"autoAlpha\",\n // Dimensions\n \"width\",\n \"height\",\n // Colors\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n // Box model\n \"borderRadius\",\n // Typography\n \"fontSize\",\n \"letterSpacing\",\n // Filter & Clipping\n \"filter\",\n \"clipPath\",\n // DOM content (number counters, text roll-ups)\n \"innerText\",\n];\n\n// ── Property Groups ─────────────────────────────────────────────────────────\n// Each group maps to an independent GSAP tween so editing one property\n// (e.g. drag → x/y) never contaminates another (e.g. scale, rotation).\n\nexport type PropertyGroupName = \"position\" | \"scale\" | \"size\" | \"rotation\" | \"visual\" | \"other\";\n\nexport const PROPERTY_GROUPS: Record<PropertyGroupName, ReadonlySet<string>> = {\n position: new Set([\"x\", \"y\", \"xPercent\", \"yPercent\"]),\n scale: new Set([\"scale\", \"scaleX\", \"scaleY\"]),\n size: new Set([\"width\", \"height\"]),\n rotation: new Set([\"rotation\", \"skewX\", \"skewY\"]),\n visual: new Set([\"opacity\", \"autoAlpha\"]),\n other: new Set<string>(),\n};\n\nconst PROP_TO_GROUP = new Map<string, PropertyGroupName>();\nfor (const [group, props] of Object.entries(PROPERTY_GROUPS) as [\n PropertyGroupName,\n ReadonlySet<string>,\n][]) {\n for (const p of props) PROP_TO_GROUP.set(p, group);\n}\n\nexport function classifyPropertyGroup(prop: string): PropertyGroupName {\n return PROP_TO_GROUP.get(prop) ?? \"other\";\n}\n\nexport function classifyTweenPropertyGroup(\n properties: Record<string, unknown>,\n): PropertyGroupName | undefined {\n const groups = new Set<PropertyGroupName>();\n for (const key of Object.keys(properties)) {\n // transformOrigin is a modifier; `_auto` is Studio's internal endpoint marker;\n // `data` is GSAP-reserved (carries the Studio hold-set tag). None is an animated\n // property, so none should affect the group.\n if (key === \"transformOrigin\" || key === \"_auto\" || key === \"data\") continue;\n const g = classifyPropertyGroup(key);\n groups.add(g);\n }\n if (groups.size === 1) return groups.values().next().value;\n return undefined;\n}\n\nexport const SUPPORTED_EASES = [\n \"none\",\n \"power1.in\",\n \"power1.out\",\n \"power1.inOut\",\n \"power2.in\",\n \"power2.out\",\n \"power2.inOut\",\n \"power3.in\",\n \"power3.out\",\n \"power3.inOut\",\n \"power4.in\",\n \"power4.out\",\n \"power4.inOut\",\n \"back.in\",\n \"back.out\",\n \"back.inOut\",\n \"elastic.in\",\n \"elastic.out\",\n \"elastic.inOut\",\n \"bounce.in\",\n \"bounce.out\",\n \"bounce.inOut\",\n \"expo.in\",\n \"expo.out\",\n \"expo.inOut\",\n \"spring-gentle\",\n \"spring-bouncy\",\n \"spring-stiff\",\n \"spring-wobbly\",\n \"spring-heavy\",\n \"steps(1)\",\n];\n","/**\n * Recast-free GSAP helpers: serialization, keyframe<->animation conversion,\n * validation, and shared types.\n *\n * This module MUST NOT import recast / @babel/parser. It is part of the\n * isomorphic core layer that the barrel and browser code depend on. AST\n * parsing of GSAP source lives in the Node-only `./gsapParser` module.\n */\nimport type { Keyframe, KeyframeProperties, ValidationResult } from \"./types.js\";\nimport type { PropertyGroupName } from \"./gsapConstants\";\n\nexport type GsapMethod = \"set\" | \"to\" | \"from\" | \"fromTo\";\n\n/** How a tween was constructed in source — drives display classification and editability. */\nexport type GsapProvenanceKind = \"literal\" | \"helper\" | \"loop\" | \"runtime-dynamic\";\n\n/**\n * Origin of a parsed tween. `literal` tweens map 1:1 to a source call and edit\n * directly; `helper`/`loop` tweens are expanded from a reused construct (unroll\n * to edit); `runtime-dynamic` tweens come from live introspection (override to\n * edit). Absent provenance is treated as `literal`.\n */\nexport interface GsapProvenance {\n kind: GsapProvenanceKind;\n /** Helper function name (kind === \"helper\"). */\n fn?: string;\n /** 1-based ordinal of the originating call site / loop construct in source order. */\n callSite?: number;\n /** 0-based iteration index (kind === \"loop\"). */\n iteration?: number;\n /** Source offset [start, end] of the originating call/loop, when known. */\n sourceRange?: [number, number];\n}\n\n/** How a tween's keyframes can be edited, derived from its provenance. */\nexport type KeyframeEditability = \"direct\" | \"unroll\" | \"source\";\n\n/**\n * Map provenance to an editing strategy:\n * - `direct` — literal tween, maps 1:1 to source; edit in place.\n * - `unroll` — helper/loop expansion; unroll to literal tweens, then edit.\n * - `source` — runtime-dynamic value; not statically editable, edit the code.\n */\nexport function editabilityForProvenance(provenance?: GsapProvenance): KeyframeEditability {\n if (!provenance || provenance.kind === \"literal\") return \"direct\";\n if (provenance.kind === \"runtime-dynamic\") return \"source\";\n return \"unroll\";\n}\n\nexport interface GsapAnimation {\n id: string;\n targetSelector: string;\n method: GsapMethod;\n position: number | string;\n properties: Record<string, number | string>;\n fromProperties?: Record<string, number | string>;\n duration?: number;\n ease?: string;\n /** Non-editable GSAP config (stagger, yoyo, repeat, etc.) preserved for round-trips. */\n extras?: Record<string, unknown>;\n /** Native GSAP keyframes data — present when the tween uses keyframes: { ... }. */\n keyframes?: GsapKeyframesData;\n /** Arc motion path config — present when the tween uses motionPath for curved position interpolation. */\n arcPath?: ArcPathConfig;\n /** True when the tween has a `keyframes` property that couldn't be statically resolved (dynamic). */\n hasUnresolvedKeyframes?: boolean;\n /** True when the tween's target selector couldn't be statically resolved (dynamic). */\n hasUnresolvedSelector?: boolean;\n /** Absolute start time computed by walking the timeline chain (handles +=, -=, <, >, labels). */\n resolvedStart?: number;\n /** True when no position arg was authored — the tween is sequentially placed by GSAP. */\n implicitPosition?: boolean;\n /** Which property group this tween belongs to (position, scale, size, rotation, visual, other).\n * Undefined for legacy mixed tweens that bundle multiple groups. */\n propertyGroup?: PropertyGroupName;\n /** True for a base `gsap.set(...)` (a static hold that runs immediately, OFF the\n * timeline) rather than `tl.set(...)`. Carries no timeline position and shows no\n * keyframe marker — used to persist a static value (e.g. a 3D transform) without\n * introducing a 0% keyframe. */\n global?: boolean;\n /** How this tween was constructed in source. Absent ⇒ literal. */\n provenance?: GsapProvenance;\n}\n\nexport interface GsapPercentageKeyframe {\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n}\n\nexport type GsapKeyframeFormat = \"percentage\" | \"object-array\" | \"simple-array\";\n\nexport interface GsapKeyframesData {\n format: GsapKeyframeFormat;\n keyframes: GsapPercentageKeyframe[];\n ease?: string;\n easeEach?: string;\n}\n\nexport interface ArcPathSegment {\n curviness: number;\n cp1?: { x: number; y: number };\n cp2?: { x: number; y: number };\n}\n\nexport interface ArcPathConfig {\n enabled: boolean;\n autoRotate: boolean | number;\n segments: ArcPathSegment[];\n}\n\nexport interface MotionPathShape {\n arcPath: ArcPathConfig;\n waypoints: Array<{ x: number; y: number }>;\n}\n\n/**\n * Build arcPath segments + waypoints from resolved path coordinates. Shared by\n * the AST parser (coords from literal nodes) and the runtime scanner (coords\n * from a live `vars.motionPath`), so both produce identical arc config.\n */\nexport function buildArcPath(\n coords: Array<{ x: number; y: number }>,\n curviness: number,\n autoRotate: boolean | number,\n isCubic: boolean,\n): MotionPathShape | undefined {\n const first = coords[0];\n if (coords.length < 2 || !first) return undefined;\n const segments: ArcPathSegment[] = [];\n let waypoints: Array<{ x: number; y: number }>;\n if (isCubic && coords.length >= 4) {\n // coords are [anchor, cp1, cp2, anchor, cp1, cp2, anchor, ...].\n waypoints = [first];\n for (let i = 1; i + 2 < coords.length; i += 3) {\n const cp1 = coords[i];\n const cp2 = coords[i + 1];\n const anchor = coords[i + 2];\n if (!cp1 || !cp2 || !anchor) continue;\n waypoints.push(anchor);\n segments.push({ curviness, cp1, cp2 });\n }\n } else {\n waypoints = coords;\n for (let i = 0; i < waypoints.length - 1; i++) segments.push({ curviness });\n }\n return { arcPath: { enabled: true, autoRotate, segments }, waypoints };\n}\n\nexport interface ParsedGsap {\n animations: GsapAnimation[];\n timelineVar: string;\n preamble: string;\n postamble: string;\n multipleTimelines?: boolean;\n unsupportedTimelinePattern?: boolean;\n}\n\nexport { SUPPORTED_PROPS, SUPPORTED_EASES } from \"./gsapConstants\";\n\n// ── Split-animation types (used by gsapWriterAcorn) ─────────────────────────\n\nexport interface SplitAnimationsOptions {\n originalId: string;\n newId: string;\n splitTime: number;\n elementStart: number;\n elementDuration: number;\n}\n\nexport interface SplitAnimationsResult {\n script: string;\n /** Non-ID-selector animations that the engine cannot safely retarget. */\n skippedSelectors: string[];\n}\n\n// ── Serialization ───────────────────────────────────────────────────────────\n\nexport function serializeGsapAnimations(\n animations: GsapAnimation[],\n timelineVar = \"tl\",\n options?: { includeMediaSync?: boolean; preamble?: string; postamble?: string },\n): string {\n const sorted = [...animations].sort((a, b) => {\n const aNum =\n a.resolvedStart ?? (typeof a.position === \"number\" ? a.position : Number.MAX_SAFE_INTEGER);\n const bNum =\n b.resolvedStart ?? (typeof b.position === \"number\" ? b.position : Number.MAX_SAFE_INTEGER);\n return aNum - bNum;\n });\n // fallow-ignore-next-line complexity\n const lines = sorted.map((anim) => {\n const selector = `\"${anim.targetSelector}\"`;\n const props: Record<string, number | string> = { ...anim.properties };\n if (anim.duration !== undefined) props.duration = anim.duration;\n if (anim.ease) props.ease = anim.ease;\n let propsStr = serializeObject(props);\n if (anim.extras && Object.keys(anim.extras).length > 0) {\n const extrasStr = serializeExtras(anim.extras);\n if (Object.keys(props).length === 0) {\n propsStr = `{ ${extrasStr} }`;\n } else {\n // Insert extras before the closing brace\n propsStr = propsStr.slice(0, -2) + `, ${extrasStr} }`;\n }\n }\n const posStr = typeof anim.position === \"string\" ? `\"${anim.position}\"` : anim.position;\n switch (anim.method) {\n case \"set\":\n // A global set is a base `gsap.set` — off the timeline, no position arg.\n return anim.global\n ? ` gsap.set(${selector}, ${propsStr});`\n : ` ${timelineVar}.set(${selector}, ${propsStr}, ${posStr});`;\n case \"to\":\n return ` ${timelineVar}.to(${selector}, ${propsStr}, ${posStr});`;\n case \"from\":\n return ` ${timelineVar}.from(${selector}, ${propsStr}, ${posStr});`;\n case \"fromTo\": {\n const fromStr = serializeObject(anim.fromProperties || {});\n return ` ${timelineVar}.fromTo(${selector}, ${fromStr}, ${propsStr}, ${posStr});`;\n }\n }\n });\n\n let mediaSync = \"\";\n if (options?.includeMediaSync) {\n mediaSync = `\n ${timelineVar}.eventCallback(\"onUpdate\", function() {\n const time = ${timelineVar}.time();\n document.querySelectorAll(\"video[data-start], audio[data-start]\").forEach(function(media) {\n const start = parseFloat(media.dataset.start);\n const end = parseFloat(media.dataset.end) || Infinity;\n const mediaTime = time - start;\n if (time >= start && time < end) {\n if (Math.abs(media.currentTime - mediaTime) > 0.1) {\n media.currentTime = mediaTime;\n }\n if (media.paused && !${timelineVar}.paused()) {\n media.play().catch(function() {});\n }\n } else if (!media.paused) {\n media.pause();\n }\n });\n });`;\n }\n\n const preamble = options?.preamble || `const ${timelineVar} = gsap.timeline({ paused: true });`;\n const postamble = options?.postamble ? `\\n ${options.postamble}` : \"\";\n\n return `\n ${preamble}\n${lines.join(\"\\n\")}${mediaSync}${postamble}\n `;\n}\n\nexport function serializeValue(value: unknown): string {\n if (typeof value === \"string\" && value.startsWith(\"__raw:\")) {\n return value.slice(6);\n }\n if (typeof value === \"string\") return JSON.stringify(value);\n return String(value);\n}\n\nexport function safeJsKey(key: string): string {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n}\n\nfunction serializeObject(obj: Record<string, number | string>): string {\n const entries = Object.entries(obj).map(([key, value]) => {\n return `${safeJsKey(key)}: ${serializeValue(value)}`;\n });\n return `{ ${entries.join(\", \")} }`;\n}\n\nfunction serializeExtras(extras: Record<string, unknown>): string {\n return Object.entries(extras)\n .map(([key, value]) => {\n return `${safeJsKey(key)}: ${serializeValue(value)}`;\n })\n .join(\", \");\n}\n\n// ── Element filtering ─────────────────────────────────────────────────────────\n\n/**\n * Filter animations to those targeting `#<elementId>` (id-only match). For the\n * studio panel's id-OR-selector matching, see `getAnimationsForElement` in\n * `useGsapTweenCache.ts` — distinct on purpose, hence the distinct name.\n */\nexport function getAnimationsForElementId(\n animations: GsapAnimation[],\n elementId: string,\n): GsapAnimation[] {\n const selector = `#${elementId}`;\n return animations.filter((a) => a.targetSelector === selector);\n}\n\n// ── Validation (regex-based, no AST needed) ─────────────────────────────────\n\nconst FORBIDDEN_GSAP_PATTERNS: Array<{ pattern: RegExp; message: string }> = [\n { pattern: /\\.call\\s*\\(/, message: \"call() method not allowed\" },\n { pattern: /\\.add\\s*\\(/, message: \"add() method not allowed\" },\n { pattern: /\\.addPause\\s*\\(/, message: \"addPause() method not allowed\" },\n { pattern: /gsap\\.registerEffect\\s*\\(/, message: \"registerEffect() not allowed\" },\n { pattern: /ScrollTrigger/, message: \"ScrollTrigger not allowed\" },\n { pattern: /onComplete\\s*:/, message: \"onComplete callback not allowed\" },\n { pattern: /onUpdate\\s*:/, message: \"onUpdate callback not allowed\" },\n { pattern: /onStart\\s*:/, message: \"onStart callback not allowed\" },\n { pattern: /onRepeat\\s*:/, message: \"onRepeat callback not allowed\" },\n { pattern: /onReverseComplete\\s*:/, message: \"onReverseComplete callback not allowed\" },\n { pattern: /repeat\\s*:\\s*-1/, message: \"Infinite repeat (repeat: -1) not allowed\" },\n { pattern: /Math\\.random\\s*\\(/, message: \"Random values (Math.random) not allowed\" },\n { pattern: /Date\\.now\\s*\\(/, message: \"Date-dependent values (Date.now) not allowed\" },\n { pattern: /new\\s+Date\\s*\\(/, message: \"Date constructor not allowed\" },\n { pattern: /setTimeout\\s*\\(/, message: \"setTimeout not allowed\" },\n { pattern: /setInterval\\s*\\(/, message: \"setInterval not allowed\" },\n { pattern: /requestAnimationFrame\\s*\\(/, message: \"requestAnimationFrame not allowed\" },\n];\n\nexport function validateCompositionGsap(script: string): ValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n for (const { pattern, message } of FORBIDDEN_GSAP_PATTERNS) {\n if (pattern.test(script)) errors.push(message);\n }\n if (/yoyo\\s*:\\s*true/.test(script)) {\n warnings.push(\"yoyo animations may behave unexpectedly when scrubbing\");\n }\n if (/stagger\\s*:/.test(script)) {\n warnings.push(\"stagger animations may not serialize correctly\");\n }\n return { valid: errors.length === 0, errors, warnings };\n}\n\n// ── Keyframe Conversion Helpers ─────────────────────────────────────────────\n\nexport function keyframesToGsapAnimations(\n elementId: string,\n keyframes: Keyframe[],\n elementStartTime: number,\n base?: { x?: number; y?: number; scale?: number },\n): GsapAnimation[] {\n const sorted = [...keyframes].sort((a, b) => a.time - b.time);\n const animations: GsapAnimation[] = [];\n const baseX = base?.x ?? 0;\n const baseY = base?.y ?? 0;\n const baseScale = base?.scale ?? 1;\n\n // fallow-ignore-next-line complexity\n sorted.forEach((kf, i) => {\n const absoluteTime = elementStartTime + kf.time;\n const isFirst = i === 0;\n const prevKf = i > 0 ? sorted[i - 1] : null;\n const duration = prevKf ? kf.time - prevKf.time : undefined;\n const position = prevKf ? elementStartTime + prevKf.time : absoluteTime;\n\n const properties: Record<string, number | string> = {};\n for (const [key, value] of Object.entries(kf.properties)) {\n if (typeof value !== \"number\") continue;\n if (key === \"x\") properties.x = baseX + value;\n else if (key === \"y\") properties.y = baseY + value;\n else if (key === \"scale\") properties.scale = baseScale * value;\n else properties[key] = value;\n }\n\n animations.push({\n id: `${elementId}-kf-${kf.id}`,\n targetSelector: `#${elementId}`,\n method: isFirst ? \"set\" : \"to\",\n position,\n properties,\n duration: isFirst ? undefined : duration,\n ease: kf.ease,\n });\n });\n\n return animations;\n}\n\nexport function gsapAnimationsToKeyframes(\n animations: GsapAnimation[],\n elementStartTime: number,\n options?: {\n baseX?: number;\n baseY?: number;\n baseScale?: number;\n clampTimeToZero?: boolean;\n skipBaseSet?: boolean;\n },\n): Keyframe[] {\n const validMethods: GsapMethod[] = [\"set\", \"to\", \"from\", \"fromTo\"];\n const baseX = options?.baseX ?? 0;\n const baseY = options?.baseY ?? 0;\n const baseScale = options?.baseScale ?? 1;\n const clampTimeToZero = options?.clampTimeToZero ?? true;\n const skipBaseSet = options?.skipBaseSet ?? false;\n const baseTimeEpsilon = 0.001;\n const baseValueEpsilon = 0.00001;\n\n return (\n animations\n .filter(\n (a): a is GsapAnimation & { position: number } =>\n validMethods.includes(a.method) && typeof a.position === \"number\",\n )\n // fallow-ignore-next-line complexity\n .map((a) => {\n const relativeTimeRaw = a.position - elementStartTime;\n const time = clampTimeToZero ? Math.max(0, relativeTimeRaw) : relativeTimeRaw;\n\n const properties: Partial<KeyframeProperties> = {};\n for (const [key, value] of Object.entries(a.properties)) {\n if (typeof value !== \"number\") continue;\n if (key === \"x\") properties.x = value - baseX;\n else if (key === \"y\") properties.y = value - baseY;\n else if (key === \"scale\") {\n properties.scale = baseScale !== 0 ? value / baseScale : value;\n } else {\n (properties as Record<string, number>)[key] = value;\n }\n }\n\n if (\n skipBaseSet &&\n a.method === \"set\" &&\n time < baseTimeEpsilon &&\n Object.values(properties).every(\n (v) => typeof v === \"number\" && Math.abs(v) < baseValueEpsilon,\n )\n ) {\n return null;\n }\n\n return {\n id: a.id.replace(/^.*-kf-/, \"\"),\n time,\n properties: properties as KeyframeProperties,\n ease: a.ease,\n };\n })\n .filter((kf): kf is NonNullable<typeof kf> => kf !== null)\n );\n}\n\n// ── Keyframe-conversion transforms (pure; shared by recast + acorn writers) ────\n\n/**\n * CSS identity values for properties whose \"rest\" state isn't 0 — used to\n * synthesize the missing endpoint when converting a flat tween to keyframes.\n */\nconst CSS_IDENTITY: Record<string, number> = {\n opacity: 1,\n autoAlpha: 1,\n scale: 1,\n scaleX: 1,\n scaleY: 1,\n};\n\nfunction cssIdentityValue(prop: string): number {\n return CSS_IDENTITY[prop] ?? 0;\n}\n\n/** Build the identity-endpoint map for a flat tween's properties. */\nfunction buildIdentityMap(props: Record<string, number | string>): Record<string, number | string> {\n const identity: Record<string, number | string> = {};\n for (const [key, val] of Object.entries(props)) {\n if (val != null) identity[key] = typeof val === \"number\" ? cssIdentityValue(key) : val;\n }\n return identity;\n}\n\n/**\n * Resolve the 0% (from) and 100% (to) property maps for a tween being\n * converted to percentage keyframes.\n *\n * @param resolvedFromValues — Despite the \"from\" in the name (historical), these\n * are runtime-captured DOM values that override the conversion endpoint:\n * - For to(): overrides fromProps (the 0% state / where the element is now).\n * - For from(): overrides toProps (the 100% state / where the element rests).\n * - For fromTo(): merges into toProps (the 100% endpoint the user is editing).\n */\nexport function resolveConversionProps(\n anim: GsapAnimation,\n resolvedFromValues?: Record<string, number | string>,\n): { fromProps: Record<string, number | string>; toProps: Record<string, number | string> } {\n if (anim.method === \"set\") {\n // A static hold becomes a keyframed `to` whose 0% and 100% both start at the\n // set's value — the visual is unchanged until the user edits a keyframe to\n // animate it. (The caller flips the call from `set` to `to` + adds a duration.)\n return { fromProps: { ...anim.properties }, toProps: { ...anim.properties } };\n }\n if (anim.method === \"to\") {\n const identity = buildIdentityMap(anim.properties);\n const fromProps = resolvedFromValues ? { ...identity, ...resolvedFromValues } : identity;\n return { fromProps, toProps: { ...anim.properties } };\n }\n if (anim.method === \"from\") {\n const identity = buildIdentityMap(anim.properties);\n const toProps = resolvedFromValues ? { ...identity, ...resolvedFromValues } : identity;\n return { fromProps: { ...anim.properties }, toProps };\n }\n // fromTo(fromVars, toVars): anim.fromProperties = fromVars (0% state),\n // anim.properties = toVars (100% state). resolvedFromValues contains the\n // current DOM position from a drag — it represents the NEW destination, so\n // it merges into toProps (the 100% endpoint the user is editing), NOT into\n // fromProps. This is intentional and not inverted.\n const toProps = resolvedFromValues\n ? { ...anim.properties, ...resolvedFromValues }\n : { ...anim.properties };\n return { fromProps: { ...(anim.fromProperties ?? {}) }, toProps };\n}\n\n// ── Arc path serialization helpers (shared by recast + acorn writers) ─────────\n\nfunction numericXY(props: Record<string, number | string>): { x: number; y: number } | null {\n const vx = props.x;\n const vy = props.y;\n return typeof vx === \"number\" && typeof vy === \"number\" ? { x: vx, y: vy } : null;\n}\n\nexport function extractArcWaypoints(anim: GsapAnimation): Array<{ x: number; y: number }> {\n const keyframeWps = (anim.keyframes?.keyframes ?? [])\n .map((kf) => numericXY(kf.properties))\n .filter((pt): pt is { x: number; y: number } => pt !== null);\n if (keyframeWps.length >= 2) return keyframeWps;\n const propX = anim.properties.x;\n const propY = anim.properties.y;\n if (typeof propX !== \"number\" && typeof propY !== \"number\") return keyframeWps;\n const destX = typeof propX === \"number\" ? propX : 0;\n const destY = typeof propY === \"number\" ? propY : 0;\n return [\n { x: 0, y: 0 },\n { x: destX, y: destY },\n ];\n}\n\nfunction autoRotateSuffix(autoRotate: boolean | number): string {\n if (autoRotate === true) return \", autoRotate: true\";\n if (typeof autoRotate === \"number\") return `, autoRotate: ${autoRotate}`;\n return \"\";\n}\n\nfunction cubicControlPoints(\n seg: ArcPathSegment,\n wp: { x: number; y: number },\n nextWp: { x: number; y: number },\n): string[] {\n if (seg.cp1 && seg.cp2) {\n return [`{x: ${seg.cp1.x}, y: ${seg.cp1.y}}`, `{x: ${seg.cp2.x}, y: ${seg.cp2.y}}`];\n }\n const dx = nextWp.x - wp.x;\n const dy = nextWp.y - wp.y;\n const c = seg.curviness ?? 1;\n return [\n `{x: ${wp.x + dx * 0.33}, y: ${wp.y + dy * 0.33 - c * Math.abs(dx) * 0.25}}`,\n `{x: ${wp.x + dx * 0.66}, y: ${wp.y + dy * 0.66 - c * Math.abs(dx) * 0.25}}`,\n ];\n}\n\nfunction buildCubicPathEntries(\n waypoints: Array<{ x: number; y: number }>,\n segments: ArcPathSegment[],\n): string[] {\n const first = waypoints[0];\n if (!first) return [];\n const entries = [`{x: ${first.x}, y: ${first.y}}`];\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const wp = waypoints[i];\n const nextWp = waypoints[i + 1];\n if (!seg || !wp || !nextWp) continue;\n entries.push(...cubicControlPoints(seg, wp, nextWp));\n entries.push(`{x: ${nextWp.x}, y: ${nextWp.y}}`);\n }\n return entries;\n}\n\nexport function buildMotionPathObjectCode(config: {\n waypoints: Array<{ x: number; y: number }>;\n segments: ArcPathSegment[];\n autoRotate: boolean | number;\n}): string {\n const { waypoints, segments, autoRotate } = config;\n const arSuffix = autoRotateSuffix(autoRotate);\n // GSAP's simple `path` array supports only ONE scalar `curviness` for the whole\n // path, so per-segment curviness can only be expressed in the cubic form (each\n // segment's curviness baked into its control points). Emit cubic when segments\n // carry explicit control points OR when their curviness values differ — the\n // simple branch would otherwise serialize only segments[0].curviness and drop\n // every other segment's curve.\n const hasExplicitCp = segments.some((s) => s.cp1 && s.cp2);\n const curvinessVaries = segments.some(\n (s) => (s.curviness ?? 1) !== (segments[0]?.curviness ?? 1),\n );\n if ((hasExplicitCp || curvinessVaries) && waypoints.length >= 2) {\n const pathStr = buildCubicPathEntries(waypoints, segments).join(\", \");\n return `{ path: [${pathStr}], type: \"cubic\"${arSuffix} }`;\n }\n const pathEntries = waypoints.map((wp) => `{x: ${wp.x}, y: ${wp.y}}`);\n const curviness = segments[0]?.curviness ?? 1;\n const curvPart = curviness !== 1 ? `, curviness: ${curviness}` : \"\";\n return `{ path: [${pathEntries.join(\", \")}]${curvPart}${arSuffix} }`;\n}\n","// fallow-ignore-file code-duplication\n/**\n * Browser-safe GSAP read path — acorn + acorn-walk.\n *\n * T6b oracle: produces identical ParsedGsap output to gsapParser.ts (recast).\n * Replaces recast as the shared implementation once T6d passes.\n *\n * Write path (T6c) will add magic-string splice once read parity is confirmed.\n * No Node globals, no fs, no require — safe to bundle for browser use.\n */\nimport * as acorn from \"acorn\";\nimport * as acornWalk from \"acorn-walk\";\nimport type {\n ArcPathConfig,\n GsapAnimation,\n GsapKeyframesData,\n GsapMethod,\n GsapPercentageKeyframe,\n ParsedGsap,\n} from \"./gsapSerialize.js\";\nimport { classifyTweenPropertyGroup } from \"./gsapConstants.js\";\nimport { buildArcPath } from \"./gsapSerialize.js\";\nimport { inlineComputedTimelines, readProvenance } from \"./gsapInline.js\";\n\n// Browser-safe re-exports so studio code can build arc config without importing\n// the recast parser (this acorn module is the browser-safe gsap subpath).\nexport { buildArcPath, editabilityForProvenance } from \"./gsapSerialize.js\";\nexport type {\n ArcPathConfig,\n ArcPathSegment,\n MotionPathShape,\n GsapProvenance,\n GsapProvenanceKind,\n KeyframeEditability,\n} from \"./gsapSerialize.js\";\n\nconst GSAP_METHODS = new Set<string>([\"set\", \"to\", \"from\", \"fromTo\"]);\nconst QUERY_METHODS = new Set([\"querySelector\", \"querySelectorAll\"]);\nconst ITERATION_METHODS = new Set([\"forEach\", \"map\"]);\nconst SCOPE_NODE_TYPES = new Set([\n \"Program\",\n \"FunctionDeclaration\",\n \"FunctionExpression\",\n \"ArrowFunctionExpression\",\n]);\n\n// ── Types ────────────────────────────────────────────────────────────────────\n\ntype ScopeBindings = ReadonlyMap<string, number | string | boolean>;\n/** Per-scope element bindings: scopeNode → (variable name → selector). */\ntype TargetBindings = Map<any, Map<string, string>>;\n\n// ── Value resolution ─────────────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nfunction resolveNode(\n node: any,\n scope: ReadonlyMap<string, number | string | boolean>,\n): number | string | boolean | undefined {\n if (!node) return undefined;\n if (node.type === \"NumericLiteral\" || (node.type === \"Literal\" && typeof node.value === \"number\"))\n return node.value;\n if (node.type === \"StringLiteral\" || (node.type === \"Literal\" && typeof node.value === \"string\"))\n return node.value;\n if (\n node.type === \"BooleanLiteral\" ||\n (node.type === \"Literal\" && typeof node.value === \"boolean\")\n )\n return node.value;\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument) {\n const val = resolveNode(node.argument, scope);\n return typeof val === \"number\" ? -val : undefined;\n }\n if (node.type === \"BinaryExpression\") {\n const left = resolveNode(node.left, scope);\n const right = resolveNode(node.right, scope);\n if (typeof left === \"number\" && typeof right === \"number\") {\n switch (node.operator) {\n case \"+\":\n return left + right;\n case \"-\":\n return left - right;\n case \"*\":\n return left * right;\n case \"/\":\n return right !== 0 ? left / right : undefined;\n }\n }\n if (typeof left === \"string\" && node.operator === \"+\") return left + String(right ?? \"\");\n if (typeof right === \"string\" && node.operator === \"+\") return String(left ?? \"\") + right;\n }\n if (node.type === \"Identifier\" && scope.has(node.name)) {\n return scope.get(node.name);\n }\n if (node.type === \"TemplateLiteral\" && node.expressions?.length === 0) {\n return node.quasis?.[0]?.value?.cooked ?? undefined;\n }\n return undefined;\n}\n\nfunction extractLiteralValue(node: any, scope: ScopeBindings): unknown {\n return resolveNode(node, scope);\n}\n\n// ── DOM selector resolution ───────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nfunction selectorFromQueryCall(node: any, scope: ScopeBindings): string | null {\n if (node?.type !== \"CallExpression\") return null;\n const callee = node.callee;\n if (callee?.type !== \"MemberExpression\" || callee.property?.type !== \"Identifier\") return null;\n const method = callee.property.name;\n const argValue = resolveNode(node.arguments?.[0], scope);\n if (typeof argValue !== \"string\" || argValue.length === 0) return null;\n if (QUERY_METHODS.has(method) || method === \"toArray\") return argValue;\n if (method === \"getElementById\") return `#${argValue}`;\n return null;\n}\n\n// ── Ancestor-based scope helpers (replaces NodePath walking) ──────────────────\n\n/**\n * Return the nearest ancestor node whose type is in SCOPE_NODE_TYPES.\n * `ancestors` is the acorn-walk ancestor array (root→current, current is last).\n */\nfunction enclosingScopeNodeFromAncestors(ancestors: any[]): any {\n for (let i = ancestors.length - 2; i >= 0; i--) {\n const node = ancestors[i];\n if (node && SCOPE_NODE_TYPES.has(node.type)) return node;\n }\n return null;\n}\n\n/** Scope chain innermost-first, derived from the acorn-walk ancestors array. */\nfunction scopeChainFromAncestors(ancestors: any[]): any[] {\n const chain: any[] = [];\n for (let i = ancestors.length - 1; i >= 0; i--) {\n const node = ancestors[i];\n if (node && SCOPE_NODE_TYPES.has(node.type)) chain.push(node);\n }\n return chain;\n}\n\n// ── Target bindings ───────────────────────────────────────────────────────────\n\nfunction addBinding(\n bindings: TargetBindings,\n scopeNode: any,\n name: string,\n selector: string,\n): void {\n let scoped = bindings.get(scopeNode);\n if (!scoped) {\n scoped = new Map();\n bindings.set(scopeNode, scoped);\n }\n if (!scoped.has(name)) scoped.set(name, selector);\n}\n\nfunction lookupBindingFromAncestors(\n name: string,\n ancestors: any[],\n bindings: TargetBindings,\n): string | null {\n for (const scopeNode of scopeChainFromAncestors(ancestors)) {\n const selector = bindings.get(scopeNode)?.get(name);\n if (selector !== undefined) return selector;\n }\n // Program-scope bindings are stored under null (enclosingScopeNodeFromAncestors\n // returns null when no function wrapper exists — the common case in HF scripts).\n return bindings.get(null)?.get(name) ?? null;\n}\n\nfunction isFunctionNode(node: any): boolean {\n return (\n node?.type === \"ArrowFunctionExpression\" ||\n node?.type === \"FunctionExpression\" ||\n node?.type === \"FunctionDeclaration\"\n );\n}\n\nfunction resolveCollectionSelector(\n node: any,\n ancestors: any[],\n scope: ScopeBindings,\n bindings: TargetBindings,\n): string | null {\n if (node?.type === \"Identifier\")\n return lookupBindingFromAncestors(node.name, ancestors, bindings);\n if (node?.type === \"CallExpression\") return selectorFromQueryCall(node, scope);\n return null;\n}\n\nfunction collectScopeBindings(ast: any): ScopeBindings {\n const bindings = new Map<string, number | string | boolean>();\n acornWalk.simple(ast, {\n VariableDeclarator(node: any) {\n const name = node.id?.name;\n const init = node.init;\n if (name && init) {\n const val = resolveNode(init, bindings);\n if (val !== undefined) bindings.set(name, val);\n }\n },\n });\n return bindings;\n}\n\n/**\n * Build a lexically-scoped index of element variables → selector.\n * Pass 1: direct DOM-lookup assignments.\n * Pass 2: forEach/map callback params whose collection's selector is known.\n */\nfunction collectTargetBindings(ast: any, scope: ScopeBindings): TargetBindings {\n const bindings: TargetBindings = new Map();\n\n acornWalk.ancestor(ast, {\n VariableDeclarator(node: any, _: unknown, ancestors: any[]) {\n const name = node.id?.name;\n const selector = selectorFromQueryCall(node.init, scope);\n if (name && selector !== null) {\n addBinding(bindings, enclosingScopeNodeFromAncestors(ancestors), name, selector);\n }\n },\n AssignmentExpression(node: any, _: unknown, ancestors: any[]) {\n const left = node.left;\n const selector = selectorFromQueryCall(node.right, scope);\n if (left?.type === \"Identifier\" && selector !== null) {\n addBinding(bindings, enclosingScopeNodeFromAncestors(ancestors), left.name, selector);\n }\n },\n } as any);\n\n // Pass 2: forEach/map callback params take the collection's selector.\n acornWalk.ancestor(ast, {\n // fallow-ignore-next-line complexity\n CallExpression(node: any, _: unknown, ancestors: any[]) {\n const callee = node.callee;\n if (\n callee?.type === \"MemberExpression\" &&\n callee.property?.type === \"Identifier\" &&\n ITERATION_METHODS.has(callee.property.name)\n ) {\n const collectionSelector = resolveCollectionSelector(\n callee.object,\n ancestors,\n scope,\n bindings,\n );\n const fn = node.arguments?.[0];\n const param = fn?.params?.[0];\n if (collectionSelector && param?.type === \"Identifier\" && isFunctionNode(fn)) {\n addBinding(bindings, fn, param.name, collectionSelector);\n }\n }\n },\n } as any);\n\n return bindings;\n}\n\n// fallow-ignore-next-line complexity\nfunction resolveTargetSelector(\n node: any,\n ancestors: any[],\n scope: ScopeBindings,\n bindings: TargetBindings,\n): string | null {\n if (!node) return null;\n if (node.type === \"StringLiteral\" || node.type === \"Literal\") {\n return typeof node.value === \"string\" ? node.value : null;\n }\n if (node.type === \"Identifier\") {\n return lookupBindingFromAncestors(node.name, ancestors, bindings);\n }\n if (node.type === \"CallExpression\") {\n return selectorFromQueryCall(node, scope);\n }\n if (node.type === \"ArrayExpression\") {\n const parts = node.elements\n .map((el: any) => resolveTargetSelector(el, ancestors, scope, bindings))\n .filter((s: string | null): s is string => typeof s === \"string\" && s.length > 0);\n return parts.length > 0 ? parts.join(\", \") : null;\n }\n if (node.type === \"MemberExpression\" && node.object?.type === \"Identifier\") {\n return lookupBindingFromAncestors(node.object.name, ancestors, bindings);\n }\n return null;\n}\n\n// ── ObjectExpression utilities ────────────────────────────────────────────────\n\nfunction isObjectProperty(prop: any): boolean {\n return prop?.type === \"ObjectProperty\" || prop?.type === \"Property\";\n}\n\nfunction propKeyName(prop: any): string | undefined {\n return prop?.key?.name ?? prop?.key?.value;\n}\n\nfunction findPropertyNode(varsArgNode: any, key: string): any | undefined {\n if (varsArgNode?.type !== \"ObjectExpression\") return undefined;\n for (const prop of varsArgNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n if (propKeyName(prop) === key) return prop.value;\n }\n return undefined;\n}\n\n/**\n * Extract raw source text for a property value — the offset-splice primitive.\n * Equivalent to `recast.print(node).code` for unmodified nodes.\n */\nfunction extractRawPropertySource(\n varsArgNode: any,\n key: string,\n source: string,\n): string | undefined {\n const node = findPropertyNode(varsArgNode, key);\n return node ? source.slice(node.start, node.end) : undefined;\n}\n\n// fallow-ignore-next-line complexity\nfunction objectExpressionToRecord(\n node: any,\n scope: ScopeBindings,\n source: string,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n if (node?.type !== \"ObjectExpression\") return result;\n for (const prop of node.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = prop.key?.name ?? prop.key?.value;\n if (!key) continue;\n const resolved = resolveNode(prop.value, scope);\n if (resolved !== undefined) {\n result[key] = resolved;\n } else {\n result[key] = `__raw:${source.slice(prop.value.start, prop.value.end)}`;\n }\n }\n return result;\n}\n\n// ── Timeline detection ────────────────────────────────────────────────────────\n\nfunction isGsapTimelineCall(node: any): boolean {\n return (\n node?.type === \"CallExpression\" &&\n node.callee?.type === \"MemberExpression\" &&\n node.callee.object?.name === \"gsap\" &&\n node.callee.property?.name === \"timeline\"\n );\n}\n\ninterface TimelineDefaults {\n ease?: string;\n duration?: number;\n}\n\ninterface TimelineDetection {\n timelineVar: string | null;\n timelineCount: number;\n defaults?: TimelineDefaults;\n}\n\n// fallow-ignore-next-line complexity\nfunction extractTimelineDefaults(\n callNode: any,\n scope: ScopeBindings,\n): TimelineDefaults | undefined {\n const arg = callNode.arguments?.[0];\n if (!arg || arg.type !== \"ObjectExpression\") return undefined;\n const defaultsProp = arg.properties?.find(\n (p: any) => isObjectProperty(p) && propKeyName(p) === \"defaults\",\n );\n if (!defaultsProp?.value || defaultsProp.value.type !== \"ObjectExpression\") return undefined;\n const result: TimelineDefaults = {};\n for (const prop of defaultsProp.value.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n const val = resolveNode(prop.value, scope);\n if (key === \"ease\" && typeof val === \"string\") result.ease = val;\n if (key === \"duration\" && typeof val === \"number\") result.duration = val;\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\nfunction findTimelineVar(ast: any, scope?: ScopeBindings): TimelineDetection {\n let timelineVar: string | null = null;\n let timelineCount = 0;\n let defaults: TimelineDefaults | undefined;\n const emptyScope: ScopeBindings = scope ?? new Map();\n\n acornWalk.simple(ast, {\n VariableDeclarator(node: any) {\n if (isGsapTimelineCall(node.init)) {\n timelineCount += 1;\n if (!timelineVar) {\n timelineVar = node.id?.name ?? null;\n defaults = extractTimelineDefaults(node.init, emptyScope);\n }\n }\n },\n AssignmentExpression(node: any) {\n if (isGsapTimelineCall(node.right)) {\n timelineCount += 1;\n if (!timelineVar) {\n const left = node.left;\n if (left?.type === \"Identifier\") timelineVar = left.name;\n defaults = extractTimelineDefaults(node.right, emptyScope);\n }\n }\n },\n });\n\n return { timelineVar, timelineCount, defaults };\n}\n\n// ── Tween call collection ─────────────────────────────────────────────────────\n\n/** Keys stored on dedicated GsapAnimation fields (not in properties/extras). */\nconst BUILTIN_VAR_KEYS = new Set([\"duration\", \"ease\", \"delay\"]);\n/** Keys never preserved (callbacks / advanced patterns). */\nconst DROPPED_VAR_KEYS = new Set([\"onComplete\", \"onStart\", \"onUpdate\", \"onRepeat\"]);\n/** Keys that go in `extras` — non-editable GSAP config that must survive round-trips. */\nconst EXTRAS_KEYS = new Set([\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\nexport interface TweenCallInfo {\n node: any;\n /** acorn-walk ancestor array at the call site (root→call, call is last). */\n ancestors: any[];\n method: GsapMethod;\n selector: string;\n varsArg: any;\n fromArg?: any;\n positionArg?: any;\n /** True for a base `gsap.set(...)` (off-timeline) rather than `tl.set(...)`. */\n global?: boolean;\n}\n\n/** True when callee chain is rooted at the timeline variable. */\nfunction isTimelineRootedCall(callNode: any, timelineVar: string): boolean {\n let obj = callNode.callee?.object;\n while (obj?.type === \"CallExpression\") {\n obj = obj.callee?.object;\n }\n return obj?.type === \"Identifier\" && obj.name === timelineVar;\n}\n\n/**\n * Pre-order recursive walk for tween collection.\n *\n * acorn-walk is POST-order (visitor fires after children), which reverses\n * chained calls vs recast.types.visit (PRE-order). We need pre-order to\n * match the golden ordering where the outermost chained call appears first.\n */\nfunction findAllTweenCalls(\n ast: any,\n timelineVar: string,\n scope: ScopeBindings,\n targetBindings: TargetBindings,\n): TweenCallInfo[] {\n const results: TweenCallInfo[] = [];\n\n // fallow-ignore-next-line complexity\n function visit(node: any, ancestors: readonly any[]): void {\n if (!node || typeof node !== \"object\") return;\n const nodeAncestors = [...ancestors, node];\n\n // Fire BEFORE children (pre-order) so chained outer calls come first.\n if (node.type === \"CallExpression\") {\n const callee = node.callee;\n // A base `gsap.set(\"#sel\", props)` is an off-timeline static hold — parse it as\n // an editable global `set` so a static value round-trips and re-edits in place.\n // STRING-LITERAL selectors only: variable-target holds stay surrounding source.\n const gsapSetArg = node.arguments?.[0];\n const isGlobalSet =\n callee?.type === \"MemberExpression\" &&\n callee.object?.type === \"Identifier\" &&\n callee.object.name === \"gsap\" &&\n callee.property?.type === \"Identifier\" &&\n callee.property.name === \"set\" &&\n (gsapSetArg?.type === \"StringLiteral\" ||\n (gsapSetArg?.type === \"Literal\" && typeof gsapSetArg.value === \"string\"));\n if (\n callee?.type === \"MemberExpression\" &&\n callee.property?.type === \"Identifier\" &&\n (isTimelineRootedCall(node, timelineVar) || isGlobalSet) &&\n GSAP_METHODS.has(callee.property.name)\n ) {\n const method = callee.property.name;\n const args = node.arguments;\n const selectorValue =\n args.length >= 1\n ? (resolveTargetSelector(args[0], nodeAncestors, scope, targetBindings) ??\n \"__unresolved__\")\n : \"__unresolved__\";\n\n if (method === \"fromTo\" && args.length >= 3) {\n results.push({\n node,\n ancestors: nodeAncestors,\n method: \"fromTo\",\n selector: selectorValue,\n fromArg: args[1],\n varsArg: args[2],\n positionArg: args[3],\n });\n } else if (method !== \"fromTo\" && args.length >= 2) {\n results.push({\n node,\n ancestors: nodeAncestors,\n method: method as GsapMethod,\n selector: selectorValue,\n varsArg: args[1],\n positionArg: args[2],\n ...(isGlobalSet ? { global: true } : {}),\n });\n }\n }\n }\n\n // Traverse children. Object.keys preserves insertion order, so callee\n // comes before arguments in acorn's CallExpression nodes.\n for (const key of Object.keys(node)) {\n if (key === \"type\" || key === \"start\" || key === \"end\" || key === \"loc\") continue;\n const child = (node as any)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n if (item && typeof item === \"object\" && item.type) visit(item, nodeAncestors);\n }\n } else if (child && typeof child === \"object\" && (child as any).type) {\n visit(child, nodeAncestors);\n }\n }\n }\n\n visit(ast, []);\n return results;\n}\n\n// ── Keyframes parsing ─────────────────────────────────────────────────────────\n\nconst PERCENTAGE_KEY_RE = /^(\\d+(?:\\.\\d+)?)%$/;\n\nfunction tryResolveStringProp(propValue: any, scope: ScopeBindings): string | undefined {\n const val = resolveNode(propValue, scope);\n return typeof val === \"string\" ? val : undefined;\n}\n\n// fallow-ignore-next-line complexity\nfunction parsePercentageKeyframes(\n node: any,\n scope: ScopeBindings,\n source: string,\n): GsapKeyframesData {\n const keyframes: GsapPercentageKeyframe[] = [];\n let ease: string | undefined;\n let easeEach: string | undefined;\n\n for (const prop of node.properties ?? []) {\n if (prop.type !== \"ObjectProperty\" && prop.type !== \"Property\") continue;\n const key = prop.key?.value ?? prop.key?.name;\n if (typeof key !== \"string\") continue;\n\n const pctMatch = PERCENTAGE_KEY_RE.exec(key);\n if (pctMatch) {\n const percentage = Number.parseFloat(pctMatch[1] ?? \"0\");\n const record = objectExpressionToRecord(prop.value, scope, source);\n const properties: Record<string, number | string> = {};\n let kfEase: string | undefined;\n for (const [k, v] of Object.entries(record)) {\n if (k === \"ease\" && typeof v === \"string\") {\n kfEase = v;\n } else if (typeof v === \"number\" || typeof v === \"string\") {\n properties[k] = v;\n }\n }\n keyframes.push({ percentage, properties, ...(kfEase ? { ease: kfEase } : {}) });\n } else if (key === \"ease\") {\n ease = tryResolveStringProp(prop.value, scope) ?? ease;\n } else if (key === \"easeEach\") {\n easeEach = tryResolveStringProp(prop.value, scope) ?? easeEach;\n }\n }\n\n keyframes.sort((a, b) => a.percentage - b.percentage);\n\n return {\n format: \"percentage\",\n keyframes,\n ...(ease ? { ease } : {}),\n ...(easeEach ? { easeEach } : {}),\n };\n}\n\n// fallow-ignore-next-line complexity\nfunction computeKeyframesTotalDuration(\n varsNode: any,\n scope: ScopeBindings,\n source: string,\n): number | undefined {\n const kfNode = (varsNode.properties ?? []).find(\n (p: any) => (p.key?.name ?? p.key?.value) === \"keyframes\",\n )?.value;\n if (!kfNode || kfNode.type !== \"ArrayExpression\") return undefined;\n let total = 0;\n for (const el of kfNode.elements ?? []) {\n if (!el || el.type !== \"ObjectExpression\") continue;\n const r = objectExpressionToRecord(el, scope, source);\n if (typeof r.duration === \"number\") total += r.duration;\n }\n return total > 0 ? total : undefined;\n}\n\n// fallow-ignore-next-line complexity\nfunction parseObjectArrayKeyframes(\n node: any,\n scope: ScopeBindings,\n source: string,\n): GsapKeyframesData {\n const elements = node.elements ?? [];\n const raw: Array<{\n properties: Record<string, number | string>;\n duration?: number;\n ease?: string;\n }> = [];\n\n for (const el of elements) {\n if (!el || el.type !== \"ObjectExpression\") continue;\n const record = objectExpressionToRecord(el, scope, source);\n const properties: Record<string, number | string> = {};\n let duration: number | undefined;\n let ease: string | undefined;\n for (const [k, v] of Object.entries(record)) {\n if (k === \"duration\" && typeof v === \"number\") {\n duration = v;\n } else if (k === \"ease\" && typeof v === \"string\") {\n ease = v;\n } else if (typeof v === \"number\" || typeof v === \"string\") {\n properties[k] = v;\n }\n }\n raw.push({ properties, duration, ease });\n }\n\n const totalDuration = raw.reduce((sum, r) => sum + (r.duration ?? 0), 0);\n const keyframes: GsapPercentageKeyframe[] = [];\n\n if (totalDuration > 0) {\n let cumulative = 0;\n for (const entry of raw) {\n cumulative += entry.duration ?? 0;\n const percentage = Math.round((cumulative / totalDuration) * 100);\n keyframes.push({\n percentage,\n properties: entry.properties,\n ...(entry.ease ? { ease: entry.ease } : {}),\n });\n }\n } else {\n for (let i = 0; i < raw.length; i++) {\n const entry = raw[i];\n if (!entry) continue;\n const percentage = raw.length > 1 ? Math.round((i / (raw.length - 1)) * 100) : 0;\n keyframes.push({\n percentage,\n properties: entry.properties,\n ...(entry.ease ? { ease: entry.ease } : {}),\n });\n }\n }\n\n return { format: \"object-array\", keyframes };\n}\n\n// fallow-ignore-next-line complexity\nfunction parseSimpleArrayKeyframes(node: any, scope: ScopeBindings): GsapKeyframesData {\n const arrayProps: Map<string, (number | string)[]> = new Map();\n let ease: string | undefined;\n let easeEach: string | undefined;\n\n for (const prop of node.properties ?? []) {\n if (prop.type !== \"ObjectProperty\" && prop.type !== \"Property\") continue;\n const key = prop.key?.name ?? prop.key?.value;\n if (typeof key !== \"string\") continue;\n\n if (prop.value?.type === \"ArrayExpression\") {\n const values: (number | string)[] = [];\n for (const el of prop.value.elements ?? []) {\n const val = resolveNode(el, scope);\n if (typeof val === \"number\" || typeof val === \"string\") {\n values.push(val);\n }\n }\n if (values.length > 0) arrayProps.set(key, values);\n } else if (key === \"ease\") {\n ease = tryResolveStringProp(prop.value, scope) ?? ease;\n } else if (key === \"easeEach\") {\n easeEach = tryResolveStringProp(prop.value, scope) ?? easeEach;\n }\n }\n\n const maxLen = Math.max(...[...arrayProps.values()].map((a) => a.length), 0);\n const keyframes: GsapPercentageKeyframe[] = [];\n\n for (let i = 0; i < maxLen; i++) {\n const percentage = maxLen > 1 ? Math.round((i / (maxLen - 1)) * 100) : 0;\n const properties: Record<string, number | string> = {};\n for (const [key, values] of arrayProps) {\n if (i < values.length) properties[key] = values[i] as number | string;\n }\n keyframes.push({ percentage, properties });\n }\n\n return {\n format: \"simple-array\",\n keyframes,\n ...(ease ? { ease } : {}),\n ...(easeEach ? { easeEach } : {}),\n };\n}\n\n// fallow-ignore-next-line complexity\nfunction parseKeyframesNode(\n node: any,\n scope: ScopeBindings,\n source: string,\n): GsapKeyframesData | undefined {\n if (!node) return undefined;\n\n if (node.type === \"ArrayExpression\") {\n return parseObjectArrayKeyframes(node, scope, source);\n }\n\n if (node.type !== \"ObjectExpression\") return undefined;\n\n const props = node.properties ?? [];\n let hasPercentageKey = false;\n let hasArrayValue = false;\n\n for (const prop of props) {\n if (prop.type !== \"ObjectProperty\" && prop.type !== \"Property\") continue;\n const key = prop.key?.value ?? prop.key?.name;\n if (typeof key === \"string\" && PERCENTAGE_KEY_RE.test(key)) {\n hasPercentageKey = true;\n break;\n }\n if (prop.value?.type === \"ArrayExpression\") {\n hasArrayValue = true;\n }\n }\n\n if (hasPercentageKey) return parsePercentageKeyframes(node, scope, source);\n if (hasArrayValue) return parseSimpleArrayKeyframes(node, scope);\n\n return undefined;\n}\n\n// ── MotionPath parsing ────────────────────────────────────────────────────────\n\ninterface MotionPathParseResult {\n arcPath: ArcPathConfig;\n waypoints: Array<{ x: number; y: number }>;\n}\n\n// fallow-ignore-next-line complexity\nfunction parseMotionPathNode(\n node: any,\n scope: ScopeBindings,\n source: string,\n): MotionPathParseResult | undefined {\n if (!node) return undefined;\n\n let pathNode: any;\n let autoRotate: boolean | number = false;\n let curviness = 1;\n let isCubic = false;\n\n if (node.type === \"ObjectExpression\") {\n for (const prop of node.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (key === \"path\") pathNode = prop.value;\n else if (key === \"autoRotate\") {\n const val = resolveNode(prop.value, scope);\n autoRotate = typeof val === \"number\" ? val : val === true;\n } else if (key === \"curviness\") {\n const val = resolveNode(prop.value, scope);\n if (typeof val === \"number\") curviness = val;\n } else if (key === \"type\") {\n const val = resolveNode(prop.value, scope);\n if (val === \"cubic\") isCubic = true;\n }\n }\n } else if (node.type === \"ArrayExpression\") {\n pathNode = node;\n }\n\n if (!pathNode || pathNode.type !== \"ArrayExpression\") return undefined;\n\n const elements = pathNode.elements ?? [];\n const coords: Array<{ x: number; y: number }> = [];\n for (const elem of elements) {\n if (!elem || elem.type !== \"ObjectExpression\") continue;\n const rec = objectExpressionToRecord(elem, scope, source);\n const x = typeof rec.x === \"number\" ? rec.x : undefined;\n const y = typeof rec.y === \"number\" ? rec.y : undefined;\n if (x !== undefined && y !== undefined) coords.push({ x, y });\n }\n\n return buildArcPath(coords, curviness, autoRotate, isCubic);\n}\n\n// ── Animation assembly ────────────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nfunction tweenCallToAnimation(\n call: TweenCallInfo,\n scope: ScopeBindings,\n source: string,\n): Omit<GsapAnimation, \"id\"> {\n const vars = objectExpressionToRecord(call.varsArg, scope, source);\n const properties: Record<string, number | string> = {};\n const extras: Record<string, unknown> = {};\n let keyframesData: GsapKeyframesData | undefined;\n let hasUnresolvedKeyframes = false;\n let motionPathResult: MotionPathParseResult | undefined;\n\n for (const [key, val] of Object.entries(vars)) {\n if (BUILTIN_VAR_KEYS.has(key)) continue;\n if (DROPPED_VAR_KEYS.has(key)) continue;\n\n if (key === \"keyframes\") {\n const kfNode = findPropertyNode(call.varsArg, \"keyframes\");\n keyframesData = parseKeyframesNode(kfNode, scope, source);\n if (!keyframesData && kfNode) hasUnresolvedKeyframes = true;\n continue;\n }\n\n if (key === \"motionPath\") {\n const mpNode = findPropertyNode(call.varsArg, \"motionPath\");\n motionPathResult = parseMotionPathNode(mpNode, scope, source);\n continue;\n }\n\n if (key === \"easeEach\") continue;\n\n if (EXTRAS_KEYS.has(key)) {\n const rawSource = extractRawPropertySource(call.varsArg, key, source);\n if (rawSource !== undefined) {\n extras[key] = `__raw:${rawSource}`;\n } else if (val !== undefined) {\n extras[key] = val;\n }\n continue;\n }\n\n if (typeof val === \"number\" || typeof val === \"string\") {\n properties[key] = val;\n }\n }\n\n if (keyframesData && typeof vars.easeEach === \"string\") {\n keyframesData.easeEach = vars.easeEach as string;\n }\n\n if (motionPathResult) {\n const { waypoints } = motionPathResult;\n if (!keyframesData) {\n const kf: GsapPercentageKeyframe[] = waypoints.map((wp, i) => ({\n percentage: waypoints.length > 1 ? Math.round((i / (waypoints.length - 1)) * 100) : 0,\n properties: { x: wp.x, y: wp.y },\n }));\n keyframesData = { format: \"percentage\", keyframes: kf };\n } else {\n const kfs = keyframesData.keyframes;\n if (kfs.length === waypoints.length) {\n for (let i = 0; i < kfs.length; i++) {\n const kf = kfs[i];\n const wp = waypoints[i];\n if (kf && wp) {\n kf.properties.x = wp.x;\n kf.properties.y = wp.y;\n }\n }\n }\n }\n }\n\n let fromProperties: Record<string, number | string> | undefined;\n if (call.method === \"fromTo\" && call.fromArg) {\n fromProperties = {};\n const fromVars = objectExpressionToRecord(call.fromArg, scope, source);\n for (const [key, val] of Object.entries(fromVars)) {\n if (typeof val === \"number\" || typeof val === \"string\") {\n fromProperties[key] = val;\n }\n }\n }\n\n const hasPositionArg = !!call.positionArg;\n const posVal = hasPositionArg ? extractLiteralValue(call.positionArg, scope) : 0;\n const position: number | string =\n typeof posVal === \"number\" ? posVal : typeof posVal === \"string\" ? posVal : 0;\n let duration = typeof vars.duration === \"number\" ? vars.duration : undefined;\n const ease = typeof vars.ease === \"string\" ? vars.ease : undefined;\n\n if (duration === undefined && keyframesData) {\n duration = computeKeyframesTotalDuration(call.varsArg, scope, source);\n }\n\n const anim: Omit<GsapAnimation, \"id\"> = {\n targetSelector: call.selector,\n method: call.method,\n position,\n properties,\n fromProperties,\n duration,\n ease,\n };\n if (!hasPositionArg) anim.implicitPosition = true;\n let group = classifyTweenPropertyGroup(properties);\n if (!group && keyframesData) {\n const kfProps: Record<string, unknown> = {};\n for (const kf of keyframesData.keyframes) {\n for (const k of Object.keys(kf.properties)) kfProps[k] = true;\n }\n group = classifyTweenPropertyGroup(kfProps);\n }\n if (group) anim.propertyGroup = group;\n if (call.global) anim.global = true;\n if (Object.keys(extras).length > 0) anim.extras = extras;\n if (keyframesData) anim.keyframes = keyframesData;\n if (motionPathResult) anim.arcPath = motionPathResult.arcPath;\n if (hasUnresolvedKeyframes) anim.hasUnresolvedKeyframes = true;\n if (call.selector === \"__unresolved__\") anim.hasUnresolvedSelector = true;\n const provenance = readProvenance(call.node);\n if (provenance) anim.provenance = provenance;\n return anim;\n}\n\n// ── Timeline position resolution ─────────────────────────────────────────────\n\nconst GSAP_DEFAULT_DURATION = 0.5;\n\n// fallow-ignore-next-line complexity\nfunction resolvePositionString(pos: string, cursor: number, prevStart: number): number | null {\n const trimmed = pos.trim();\n if (trimmed === \"\") return cursor;\n if (trimmed.startsWith(\"+=\")) {\n const n = Number.parseFloat(trimmed.slice(2));\n return Number.isFinite(n) ? cursor + n : null;\n }\n if (trimmed.startsWith(\"-=\")) {\n const n = Number.parseFloat(trimmed.slice(2));\n return Number.isFinite(n) ? cursor - n : null;\n }\n if (trimmed === \"<\") return prevStart;\n if (trimmed === \">\") return cursor;\n if (trimmed.startsWith(\"<\")) {\n const n = Number.parseFloat(trimmed.slice(1));\n return Number.isFinite(n) ? prevStart + n : null;\n }\n if (trimmed.startsWith(\">\")) {\n const n = Number.parseFloat(trimmed.slice(1));\n return Number.isFinite(n) ? cursor + n : null;\n }\n const n = Number.parseFloat(trimmed);\n return Number.isFinite(n) ? n : null;\n}\n\nfunction applyTimelineDefaults(\n anims: Omit<GsapAnimation, \"id\">[],\n defaults?: TimelineDefaults,\n): void {\n if (!defaults) return;\n for (const anim of anims) {\n if (anim.method === \"set\") continue;\n if (anim.duration === undefined && defaults.duration !== undefined) {\n anim.duration = defaults.duration;\n }\n if (anim.ease === undefined && defaults.ease !== undefined) {\n anim.ease = defaults.ease;\n }\n }\n}\n\n// fallow-ignore-next-line complexity\nfunction resolveTimelinePositions(anims: Omit<GsapAnimation, \"id\">[]): void {\n let cursor = 0;\n let prevStart = 0;\n for (const anim of anims) {\n // A global `gsap.set(...)` is off-timeline — applied once at load, not\n // sequenced on the master timeline. It carries no position arg, so the\n // cursor fallback would otherwise hand it the comp-end time. Pin it to 0\n // (its load-time start) and don't advance the cursor/prevStart.\n if (anim.method === \"set\" && anim.global) {\n anim.resolvedStart = 0;\n continue;\n }\n const duration = anim.method === \"set\" ? 0 : (anim.duration ?? GSAP_DEFAULT_DURATION);\n let start: number | null;\n\n if (anim.implicitPosition) {\n start = cursor;\n } else if (typeof anim.position === \"number\") {\n start = anim.position;\n } else if (typeof anim.position === \"string\") {\n start = resolvePositionString(anim.position, cursor, prevStart);\n } else {\n start = cursor;\n }\n\n if (start != null) {\n anim.resolvedStart = Math.max(0, start);\n prevStart = anim.resolvedStart;\n cursor = Math.max(cursor, anim.resolvedStart + duration);\n }\n }\n}\n\nfunction compareByLoc(a: TweenCallInfo, b: TweenCallInfo): number {\n const aLoc = a.node.callee?.property?.loc?.start;\n const bLoc = b.node.callee?.property?.loc?.start;\n if (!aLoc || !bLoc) return 0;\n return aLoc.line - bLoc.line || aLoc.column - bLoc.column;\n}\n\n// Inlined tweens carry a monotonic __hfOrder (clones share source loc, so loc\n// can't order them); they sort by that, after all literal (loc-ordered) tweens.\nfunction compareCallOrder(a: TweenCallInfo, b: TweenCallInfo): number {\n const ao = a.node.__hfOrder;\n const bo = b.node.__hfOrder;\n if (ao === undefined && bo === undefined) return compareByLoc(a, b);\n if (ao === undefined) return -1;\n if (bo === undefined) return 1;\n return ao - bo;\n}\n\nfunction sortBySourcePosition(calls: TweenCallInfo[]): void {\n calls.sort(compareCallOrder);\n}\n\n// ── Stable ID generation ──────────────────────────────────────────────────────\n\nfunction assignStableIds(anims: Omit<GsapAnimation, \"id\">[]): GsapAnimation[] {\n const counts = new Map<string, number>();\n return anims.map((anim) => {\n const posKey =\n typeof anim.position === \"number\"\n ? String(Math.round(anim.position * 1000))\n : String(anim.position);\n const groupSuffix = anim.propertyGroup ? `-${anim.propertyGroup}` : \"\";\n const base = `${anim.targetSelector}-${anim.method}-${posKey}${groupSuffix}`;\n const count = (counts.get(base) ?? 0) + 1;\n counts.set(base, count);\n const id = count === 1 ? base : `${base}-${count}`;\n return { ...anim, id };\n });\n}\n\n// ── Write-path internal parse ─────────────────────────────────────────────────\n\nexport interface ParsedGsapAcornForWrite {\n ast: any;\n timelineVar: string;\n hasTimeline: boolean;\n located: Array<{ id: string; call: TweenCallInfo; animation: GsapAnimation }>;\n}\n\n/**\n * Parse a GSAP script and return internal AST + call nodes for the write path.\n * Consumed by gsapWriterAcorn.ts (magic-string offset-splice).\n */\nexport function parseGsapScriptAcornForWrite(script: string): ParsedGsapAcornForWrite | null {\n try {\n const ast = acorn.parse(script, {\n ecmaVersion: \"latest\",\n sourceType: \"script\",\n locations: true,\n });\n const scope = collectScopeBindings(ast);\n const targetBindings = collectTargetBindings(ast, scope);\n const detection = findTimelineVar(ast, scope);\n const timelineVar = detection.timelineVar ?? \"tl\";\n const calls = findAllTweenCalls(ast, timelineVar, scope, targetBindings);\n sortBySourcePosition(calls);\n const rawAnims = calls.map((call) => tweenCallToAnimation(call, scope, script));\n applyTimelineDefaults(rawAnims, detection.defaults);\n resolveTimelinePositions(rawAnims);\n const animations = assignStableIds(rawAnims);\n const located = calls.map((call, i) => ({\n id: animations[i]!.id,\n call,\n animation: animations[i]!,\n }));\n return { ast, timelineVar, hasTimeline: detection.timelineVar !== null, located };\n } catch {\n return null;\n }\n}\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Browser-safe equivalent of `parseGsapScript` (gsapParser.ts).\n * Uses acorn + acorn-walk instead of recast + @babel/parser.\n */\nexport function parseGsapScriptAcorn(script: string): ParsedGsap {\n try {\n const ast = acorn.parse(script, {\n ecmaVersion: \"latest\",\n sourceType: \"script\",\n locations: true,\n });\n const scope = collectScopeBindings(ast);\n const detection = findTimelineVar(ast, scope);\n const timelineVar = detection.timelineVar ?? \"tl\";\n // Expand helper-built / bounded-loop timelines before analysis so their\n // tweens resolve at true positions (read path only — the write path keeps\n // original source nodes). Degrades to the un-inlined AST on any failure.\n try {\n inlineComputedTimelines(ast, timelineVar, (node) => resolveNode(node, scope));\n } catch {\n /* fall back to current behavior */\n }\n const targetBindings = collectTargetBindings(ast, scope);\n const calls = findAllTweenCalls(ast, timelineVar, scope, targetBindings);\n sortBySourcePosition(calls);\n const rawAnims = calls.map((call) => tweenCallToAnimation(call, scope, script));\n applyTimelineDefaults(rawAnims, detection.defaults);\n resolveTimelinePositions(rawAnims);\n const animations = assignStableIds(rawAnims);\n\n const timelineMatch = script.match(\n new RegExp(\n `^[\\\\s\\\\S]*?(?:const|let|var)\\\\s+${timelineVar}\\\\s*=\\\\s*gsap\\\\.timeline\\\\s*\\\\([^)]*\\\\)\\\\s*;?`,\n ),\n );\n const preamble =\n timelineMatch?.[0] ?? `const ${timelineVar} = gsap.timeline({ paused: true });`;\n\n const lastCallIdx = script.lastIndexOf(`${timelineVar}.`);\n let postamble = \"\";\n if (lastCallIdx !== -1) {\n const afterLast = script.slice(lastCallIdx);\n const endOfCall = afterLast.indexOf(\";\");\n if (endOfCall !== -1) {\n postamble = script.slice(lastCallIdx + endOfCall + 1).trim();\n }\n }\n\n const result: ParsedGsap = { animations, timelineVar, preamble, postamble };\n if (detection.timelineCount > 1) result.multipleTimelines = true;\n if (detection.timelineCount > 0 && detection.timelineVar === null)\n result.unsupportedTimelinePattern = true;\n return result;\n } catch {\n return { animations: [], timelineVar: \"tl\", preamble: \"\", postamble: \"\" };\n }\n}\n\n// ── Label extraction (WS-C) ──────────────────────────────────────────────────\n\nexport interface GsapLabelEntry {\n name: string;\n position: number;\n}\n\n/**\n * Extract all `tl.addLabel(\"name\", position)` calls from a GSAP script.\n *\n * Returns labels in source order. Position must be a numeric literal; labels\n * with non-numeric positions (e.g. label-relative offsets) are skipped.\n *\n * Pure — no side effects, no DOM, no Date.now.\n */\nexport function extractGsapLabels(script: string): GsapLabelEntry[] {\n try {\n const ast = acorn.parse(script, {\n ecmaVersion: \"latest\",\n sourceType: \"script\",\n locations: true,\n });\n const scope = collectScopeBindings(ast);\n const detection = findTimelineVar(ast, scope);\n const timelineVar = detection.timelineVar ?? \"tl\";\n\n const labels: GsapLabelEntry[] = [];\n\n acornWalk.simple(ast, {\n // fallow-ignore-next-line complexity\n ExpressionStatement(node: any) {\n const expr = node.expression;\n if (!expr || expr.type !== \"CallExpression\") return;\n const callee = expr.callee;\n // Match tl.addLabel(...)\n if (\n callee?.type !== \"MemberExpression\" ||\n callee.object?.name !== timelineVar ||\n callee.property?.name !== \"addLabel\"\n )\n return;\n const args = expr.arguments ?? [];\n const nameNode = args[0];\n const posNode = args[1];\n if (nameNode?.type !== \"Literal\" || typeof nameNode.value !== \"string\") return;\n if (!posNode) return;\n const pos = resolveNode(posNode, scope);\n if (typeof pos !== \"number\" || !Number.isFinite(pos)) return;\n labels.push({ name: nameNode.value, position: pos });\n },\n });\n\n return labels;\n } catch {\n // Labels are best-effort/supplementary, not load-bearing — a malformed or\n // unparseable script yields no labels rather than failing the caller.\n return [];\n }\n}\n","/**\n * Static evaluation for computed GSAP timelines (browser-safe, acorn/ESTree).\n *\n * The read parser resolves only literals and top-level consts, so timelines\n * built by a helper called N times or by a bounded loop collapse to position 0.\n * This module expands those constructs into a synthetic analysis AST: each\n * helper invocation and each loop iteration becomes its own concrete set of\n * `tl.*` calls, with parameters/loop-vars substituted by the call's argument\n * (or element/index) AST nodes — after which the existing parse pipeline\n * resolves positions and `motionPath` arcs unchanged.\n *\n * Substituted nodes keep their original source offsets, so downstream\n * source-slicing (raw extras, keyframes) stays correct. The substitution\n * primitives never mutate their input; `inlineComputedTimelines` rewrites the\n * Program body of the freshly-parsed AST it is handed (owned by the caller).\n */\nimport type { GsapProvenance } from \"./gsapSerialize.js\";\n\n// acorn ESTree nodes are structurally untyped; mirror gsapParserAcorn.ts.\ntype Node = any;\n\n/** Node keys that are metadata, not child AST to traverse/substitute. */\nconst SKIP_KEYS = new Set([\"type\", \"start\", \"end\", \"loc\", \"range\", \"__hfProvenance\", \"__hfOrder\"]);\n\nconst FUNCTION_TYPES = new Set([\n \"ArrowFunctionExpression\",\n \"FunctionExpression\",\n \"FunctionDeclaration\",\n]);\nconst GSAP_METHODS = new Set([\"set\", \"to\", \"from\", \"fromTo\"]);\n\n// Bounds on synthetic expansion (recursion + iteration runaway guards).\nconst MAX_DEPTH = 8;\nconst MAX_ITERS = 512;\n\nfunction isFunctionNode(node: Node): boolean {\n return !!node && FUNCTION_TYPES.has(node.type);\n}\n\nfunction isNode(x: Node): boolean {\n return !!x && typeof x === \"object\" && typeof x.type === \"string\";\n}\n\n/**\n * Apply `fn` to each child AST node, writing back its return value. Skips\n * metadata keys and key/member slots that must not be treated as values.\n * The one place array-vs-single child traversal lives, so walkers stay flat.\n */\nfunction transformChildren(node: Node, fn: (child: Node) => Node): void {\n for (const key of Object.keys(node)) {\n if (SKIP_KEYS.has(key) || isNonValueIdentifierSlot(node, key)) continue;\n const child = node[key];\n if (Array.isArray(child)) {\n for (let i = 0; i < child.length; i++) child[i] = fn(child[i]);\n } else {\n node[key] = fn(child);\n }\n }\n}\n\n/** Deep structural clone preserving `start`/`end`/`loc` (needed for source slicing). */\nexport function cloneNode<T extends Node>(node: T): T {\n return structuredClone(node);\n}\n\n// ponytail: Identifier + default + rest only. Destructured bindings (`{x}`, `[x]`)\n// aren't inlined (U2 inlines Identifier-param helpers / loop vars only), so a\n// destructuring shadow is a double-rare miss that just falls back. Add the\n// pattern cases here if that ever bites.\nfunction collectPatternNames(pattern: Node, out: Set<string>): void {\n if (pattern?.type === \"Identifier\") out.add(pattern.name);\n else if (pattern?.type === \"AssignmentPattern\") collectPatternNames(pattern.left, out);\n else if (pattern?.type === \"RestElement\") collectPatternNames(pattern.argument, out);\n}\n\n/** Every identifier name bound anywhere inside the subtree (fn params, declared vars, catch params). */\nfunction collectBoundNames(root: Node): Set<string> {\n const names = new Set<string>();\n const visit = (node: Node): Node => {\n if (!isNode(node)) return node;\n if (isFunctionNode(node)) for (const p of node.params ?? []) collectPatternNames(p, names);\n else if (node.type === \"VariableDeclarator\") collectPatternNames(node.id, names);\n else if (node.type === \"CatchClause\") collectPatternNames(node.param, names);\n transformChildren(node, visit);\n return node;\n };\n visit(root);\n return names;\n}\n\n/** A child in key/property position that must not be treated as a value identifier. */\nfunction isNonValueIdentifierSlot(node: Node, key: string): boolean {\n if (node.computed) return false;\n return (\n (node.type === \"MemberExpression\" && key === \"property\") ||\n (node.type === \"Property\" && key === \"key\")\n );\n}\n\n/**\n * Substitute bound identifiers in an already-cloned subtree, returning the\n * (possibly replaced) root. Names shadowed anywhere inside (nested function\n * params, declared vars) are dropped up front rather than tracked per scope —\n * worst case we under-substitute and the caller falls back to current behavior.\n * Never substitutes identifiers in key/member positions. Mutates the passed\n * clone in place — callers pass `cloneNode(...)`.\n */\nexport function substituteParams(node: Node, bindings: ReadonlyMap<string, Node>): Node {\n const shadowed = collectBoundNames(node);\n let effective = bindings;\n if (shadowed.size > 0) {\n effective = new Map(bindings);\n for (const name of shadowed) (effective as Map<string, Node>).delete(name);\n }\n if (effective.size === 0) return node;\n return replace(node, effective);\n}\n\nfunction replace(node: Node, bindings: ReadonlyMap<string, Node>): Node {\n if (!isNode(node)) return node;\n if (node.type === \"Identifier\" && bindings.has(node.name)) {\n return cloneNode(bindings.get(node.name));\n }\n transformChildren(node, (child) => replace(child, bindings));\n return node;\n}\n\n/** Tag a node (typically a `tl.*` CallExpression) with its construction provenance. */\nexport function tagProvenance(node: Node, provenance: GsapProvenance): Node {\n if (node && typeof node === \"object\") node.__hfProvenance = provenance;\n return node;\n}\n\n/** Read a provenance tag previously set by `tagProvenance`, if any. */\nexport function readProvenance(node: Node): GsapProvenance | undefined {\n return node?.__hfProvenance;\n}\n\n/** Synthesize a numeric `Literal` node (for loop indices, which have no source node). */\nexport function numericLiteral(value: number): Node {\n return { type: \"Literal\", value, raw: String(value) };\n}\n\n// ── Expansion engine (U2) ─────────────────────────────────────────────────────\n\n/** Resolve an expression to a literal value (top-level consts in scope, arithmetic). */\ntype LiteralResolver = (node: Node) => number | string | boolean | undefined;\n\ninterface ExpandCtx {\n helpers: Map<string, Node>;\n timelineVar: string;\n resolve: LiteralResolver;\n depth: number;\n /** Mutable source-order counter for provenance call-site ordinals. */\n site: { n: number };\n /** Mutable counter stamping expansion order onto tweens (clones share source loc). */\n order: { n: number };\n}\n\nfunction walkNodes(node: Node, fn: (n: Node) => void): void {\n if (!isNode(node)) return;\n fn(node);\n for (const key of Object.keys(node)) {\n if (SKIP_KEYS.has(key)) continue;\n const child = node[key];\n if (Array.isArray(child)) for (const c of child) walkNodes(c, fn);\n else walkNodes(child, fn);\n }\n}\n\n/** The identifier a (possibly chained) call's member expression is rooted at. */\nfunction timelineRootName(call: Node): string | null {\n let obj = call.callee?.object;\n while (obj?.type === \"CallExpression\") obj = obj.callee?.object;\n return obj?.type === \"Identifier\" ? obj.name : null;\n}\n\nfunction isTimelineRooted(call: Node, timelineVar: string): boolean {\n if (timelineRootName(call) !== timelineVar) return false;\n return (\n call.callee?.property?.type === \"Identifier\" && GSAP_METHODS.has(call.callee.property.name)\n );\n}\n\nfunction containsTimelineCall(node: Node, timelineVar: string): boolean {\n let found = false;\n walkNodes(node, (n) => {\n if (n.type === \"CallExpression\" && isTimelineRooted(n, timelineVar)) found = true;\n });\n return found;\n}\n\nfunction rangeOf(node: Node): [number, number] | undefined {\n return typeof node.start === \"number\" && typeof node.end === \"number\"\n ? [node.start, node.end]\n : undefined;\n}\n\n/** Plain identifier params + block body (shape we can inline). Timeline content checked separately. */\nfunction isShapeEligible(fn: Node): boolean {\n return (\n isFunctionNode(fn) &&\n fn.body?.type === \"BlockStatement\" &&\n !(fn.params ?? []).some((p: Node) => p.type !== \"Identifier\")\n );\n}\n\n/** True if the subtree calls any function named in `names`. */\nfunction callsAny(node: Node, names: Set<string>): boolean {\n let hit = false;\n walkNodes(node, (n) => {\n if (\n n.type === \"CallExpression\" &&\n n.callee?.type === \"Identifier\" &&\n names.has(n.callee.name)\n ) {\n hit = true;\n }\n });\n return hit;\n}\n\n/** `[name, fnNode]` if a single-declarator `const f = fn` is an inlinable-shaped helper. */\nfunction varDeclHelper(stmt: Node): [string, Node] | null {\n if (stmt.declarations?.length !== 1) return null;\n const d = stmt.declarations[0];\n return d.id?.type === \"Identifier\" && isShapeEligible(d.init) ? [d.id.name, d.init] : null;\n}\n\n/** `[name, fnNode]` if `stmt` declares an inlinable-shaped helper, else null. */\nfunction helperFromStatement(stmt: Node): [string, Node] | null {\n if (stmt.type === \"FunctionDeclaration\") {\n return stmt.id && isShapeEligible(stmt) ? [stmt.id.name, stmt] : null;\n }\n if (stmt.type === \"VariableDeclaration\") return varDeclHelper(stmt);\n return null;\n}\n\n/** Top-level functions whose shape we can inline (Identifier params + block body). */\nfunction gatherHelperCandidates(program: Node): Map<string, Node> {\n const candidates = new Map<string, Node>();\n for (const stmt of program.body ?? []) {\n const helper = helperFromStatement(stmt);\n if (helper) candidates.set(helper[0], helper[1]);\n }\n return candidates;\n}\n\n/** Names that build the timeline directly or by calling another builder (transitive closure). */\nfunction timelineBuildingNames(candidates: Map<string, Node>, timelineVar: string): Set<string> {\n const building = new Set<string>();\n for (const [name, fn] of candidates) {\n if (containsTimelineCall(fn.body, timelineVar)) building.add(name);\n }\n for (let changed = true; changed; ) {\n changed = false;\n for (const [name, fn] of candidates) {\n if (!building.has(name) && callsAny(fn.body, building)) {\n building.add(name);\n changed = true;\n }\n }\n }\n return building;\n}\n\nfunction bump(counts: Map<string, number>, key: string): void {\n counts.set(key, (counts.get(key) ?? 0) + 1);\n}\n\n/**\n * Keep only candidates safe to drop: every reference to the name is its\n * declaration or a statement-level call. (1 decl id + 1 callee id per\n * statement-level call ⇒ total occurrences with no stray uses.)\n */\nfunction safelyDroppable(program: Node, candidates: Map<string, Node>): Map<string, Node> {\n const names = new Set(candidates.keys());\n const totalIds = new Map<string, number>();\n const stmtCalls = new Map<string, number>();\n walkNodes(program, (n) => {\n if (n.type === \"Identifier\" && names.has(n.name)) bump(totalIds, n.name);\n const e = n.type === \"ExpressionStatement\" ? n.expression : undefined;\n if (\n e?.type === \"CallExpression\" &&\n e.callee?.type === \"Identifier\" &&\n names.has(e.callee.name)\n ) {\n bump(stmtCalls, e.callee.name);\n }\n });\n const safe = new Map<string, Node>();\n for (const [name, fn] of candidates) {\n if ((totalIds.get(name) ?? 0) === 1 + (stmtCalls.get(name) ?? 0)) safe.set(name, fn);\n }\n return safe;\n}\n\n/** Top-level timeline-building helpers that are safe to inline-and-drop. */\nfunction collectInlinableHelpers(program: Node, timelineVar: string): Map<string, Node> {\n const candidates = gatherHelperCandidates(program);\n if (candidates.size === 0) return candidates;\n const building = timelineBuildingNames(candidates, timelineVar);\n for (const name of [...candidates.keys()]) if (!building.has(name)) candidates.delete(name);\n if (candidates.size === 0) return candidates;\n return safelyDroppable(program, candidates);\n}\n\nfunction isHelperDecl(stmt: Node, helpers: Map<string, Node>): boolean {\n if (stmt.type === \"FunctionDeclaration\") return !!stmt.id && helpers.get(stmt.id.name) === stmt;\n if (stmt.type === \"VariableDeclaration\" && stmt.declarations?.length === 1) {\n const d = stmt.declarations[0];\n return d.id?.type === \"Identifier\" && helpers.get(d.id.name) === d.init;\n }\n return false;\n}\n\nfunction bodyStatements(node: Node): Node[] {\n if (node?.type === \"BlockStatement\") return node.body ?? [];\n return node ? [{ type: \"ExpressionStatement\", expression: node }] : [];\n}\n\n/** Tag this body's direct timeline tweens with provenance + a monotonic expansion-order stamp. */\nfunction tagTimelineCalls(stmts: Node[], prov: GsapProvenance, ctx: ExpandCtx): void {\n for (const stmt of stmts) {\n walkNodes(stmt, (n) => {\n if (n.type === \"CallExpression\" && isTimelineRooted(n, ctx.timelineVar)) {\n tagProvenance(n, { ...prov });\n n.__hfOrder = ctx.order.n++;\n }\n });\n }\n}\n\n/** Clone a body as one scope, substitute the bindings, tag provenance, recurse. */\nfunction expandBody(\n bodyStmts: Node[],\n bindings: Map<string, Node>,\n prov: GsapProvenance,\n ctx: ExpandCtx,\n): Node[] {\n const block = substituteParams(cloneNode({ type: \"BlockStatement\", body: bodyStmts }), bindings);\n tagTimelineCalls(block.body, prov, ctx);\n return expandStatements(block.body, { ...ctx, depth: ctx.depth + 1 });\n}\n\nfunction inlineHelper(call: Node, ctx: ExpandCtx): Node[] {\n const fn = ctx.helpers.get(call.callee.name);\n const bindings = new Map<string, Node>();\n (fn.params ?? []).forEach((p: Node, i: number) => {\n const arg = call.arguments?.[i];\n if (arg) bindings.set(p.name, arg);\n });\n const prov: GsapProvenance = {\n kind: \"helper\",\n fn: call.callee.name,\n callSite: ++ctx.site.n,\n sourceRange: rangeOf(call),\n };\n return expandBody(fn.body.body, bindings, prov, ctx);\n}\n\nfunction assignStep(update: Node, resolve: LiteralResolver): number | undefined {\n if (update.operator === \"+=\") return asNum(resolve(update.right));\n if (update.operator === \"-=\") {\n const s = asNum(resolve(update.right));\n return s === undefined ? undefined : -s;\n }\n // `i = i + S` — the step is the right operand of the addition.\n if (update.operator === \"=\" && update.right?.type === \"BinaryExpression\") {\n return asNum(resolve(update.right.right));\n }\n return undefined;\n}\n\n/** The loop variable a `for` update clause mutates (`i++` or `i += S`), or null. */\nfunction updatedVarName(update: Node): string | null {\n if (update?.type === \"UpdateExpression\") return update.argument?.name ?? null;\n if (update?.type === \"AssignmentExpression\") return update.left?.name ?? null;\n return null;\n}\n\nfunction loopStep(update: Node, varName: string, resolve: LiteralResolver): number | undefined {\n if (updatedVarName(update) !== varName) return undefined;\n if (update.type === \"UpdateExpression\") return update.operator === \"++\" ? 1 : -1;\n return assignStep(update, resolve);\n}\n\nfunction asNum(v: unknown): number | undefined {\n return typeof v === \"number\" && Number.isFinite(v) ? v : undefined;\n}\n\nfunction loopSatisfied(op: string, x: number, end: number): boolean {\n if (op === \"<\") return x < end;\n if (op === \"<=\") return x <= end;\n if (op === \">\") return x > end;\n if (op === \">=\") return x >= end;\n return false;\n}\n\ninterface ForHeader {\n v: string;\n start: number;\n end: number;\n op: string;\n step: number;\n}\n\n/** The single `let v = <init>` of a for-loop init clause, or null. */\nfunction forInitVar(init: Node): { name: string; initExpr: Node } | null {\n if (init?.type !== \"VariableDeclaration\" || init.declarations?.length !== 1) return null;\n const d = init.declarations[0];\n return d.id?.type === \"Identifier\" ? { name: d.id.name, initExpr: d.init } : null;\n}\n\n/** Parse `for (let v = A; v <op> B; v += S)` into resolved bounds, or null if not statically bounded. */\nfunction parseForHeader(stmt: Node, resolve: LiteralResolver): ForHeader | null {\n const iv = forInitVar(stmt.init);\n const test = stmt.test;\n if (!iv || test?.type !== \"BinaryExpression\" || test.left?.name !== iv.name) return null;\n const start = asNum(resolve(iv.initExpr));\n const end = asNum(resolve(test.right));\n const step = loopStep(stmt.update, iv.name, resolve);\n if (start === undefined || end === undefined || !step) return null;\n return { v: iv.name, start, end, op: test.operator, step };\n}\n\nfunction unrollFor(stmt: Node, ctx: ExpandCtx): Node[] | null {\n const h = parseForHeader(stmt, ctx.resolve);\n if (!h) return null;\n const body = bodyStatements(stmt.body);\n const out: Node[] = [];\n const site = ++ctx.site.n;\n let iteration = 0;\n for (let x = h.start; loopSatisfied(h.op, x, h.end); x += h.step) {\n if (iteration >= MAX_ITERS) return null;\n const prov: GsapProvenance = {\n kind: \"loop\",\n callSite: site,\n iteration,\n sourceRange: rangeOf(stmt),\n };\n out.push(...expandBody(body, new Map([[h.v, numericLiteral(x)]]), prov, ctx));\n iteration++;\n }\n return out;\n}\n\nfunction forOfVarName(left: Node): string | null {\n if (left?.type === \"VariableDeclaration\") {\n const id = left.declarations?.[0]?.id;\n return id?.type === \"Identifier\" ? id.name : null;\n }\n return left?.type === \"Identifier\" ? left.name : null;\n}\n\n/** Expand `for (const el of [literal array]) {...}` and `[literal array].forEach((el, i) => {...})`. */\nfunction unrollOverArray(\n elements: Node[],\n body: Node[],\n elName: string | null,\n idxName: string | null,\n range: [number, number] | undefined,\n ctx: ExpandCtx,\n): Node[] {\n const out: Node[] = [];\n const site = ++ctx.site.n;\n elements.forEach((el, i) => {\n if (!el) return;\n const bindings = new Map<string, Node>();\n if (elName) bindings.set(elName, el);\n if (idxName) bindings.set(idxName, numericLiteral(i));\n const prov: GsapProvenance = { kind: \"loop\", callSite: site, iteration: i, sourceRange: range };\n out.push(...expandBody(body, bindings, prov, ctx));\n });\n return out;\n}\n\nfunction unrollForOf(stmt: Node, ctx: ExpandCtx): Node[] | null {\n if (stmt.right?.type !== \"ArrayExpression\") return null;\n const elName = forOfVarName(stmt.left);\n if (!elName) return null;\n return unrollOverArray(\n stmt.right.elements ?? [],\n bodyStatements(stmt.body),\n elName,\n null,\n rangeOf(stmt),\n ctx,\n );\n}\n\n/** The (element, index) param names of a callback, or null if either is non-Identifier. */\nfunction callbackParamNames(cb: Node): { el: string | null; idx: string | null } | null {\n const names: Array<string | null> = [];\n for (const p of [cb.params?.[0], cb.params?.[1]]) {\n if (!p) names.push(null);\n else if (p.type !== \"Identifier\") return null;\n else names.push(p.name);\n }\n return { el: names[0]!, idx: names[1]! };\n}\n\n/** True for `[arrayLiteral].forEach` member callees. */\nfunction isForEachCall(callee: Node): boolean {\n return (\n callee?.type === \"MemberExpression\" &&\n callee.property?.name === \"forEach\" &&\n callee.object?.type === \"ArrayExpression\"\n );\n}\n\n/** The element array + callback of `[...].forEach(cb)`, or null. */\nfunction forEachTarget(call: Node): { elements: Node[]; cb: Node } | null {\n if (!isForEachCall(call.callee)) return null;\n const cb = call.arguments?.[0];\n return isFunctionNode(cb) ? { elements: call.callee.object.elements ?? [], cb } : null;\n}\n\nfunction unrollForEach(call: Node, ctx: ExpandCtx): Node[] | null {\n const target = forEachTarget(call);\n if (!target) return null;\n const params = callbackParamNames(target.cb);\n if (!params) return null;\n return unrollOverArray(\n target.elements,\n bodyStatements(target.cb.body),\n params.el,\n params.idx,\n rangeOf(call),\n ctx,\n );\n}\n\nfunction expandCall(call: Node, ctx: ExpandCtx): Node[] | null {\n if (call.callee?.type === \"Identifier\" && ctx.helpers.has(call.callee.name)) {\n return inlineHelper(call, ctx);\n }\n return unrollForEach(call, ctx);\n}\n\nfunction expandStatement(stmt: Node, ctx: ExpandCtx): Node[] | null {\n if (ctx.depth >= MAX_DEPTH) return null;\n if (stmt.type === \"ForStatement\") return unrollFor(stmt, ctx);\n if (stmt.type === \"ForOfStatement\") return unrollForOf(stmt, ctx);\n if (stmt.type === \"ExpressionStatement\" && stmt.expression?.type === \"CallExpression\") {\n return expandCall(stmt.expression, ctx);\n }\n return null;\n}\n\nfunction expandStatements(stmts: Node[], ctx: ExpandCtx): Node[] {\n const out: Node[] = [];\n for (const stmt of stmts) {\n const expanded = expandStatement(stmt, ctx);\n if (expanded) out.push(...expanded);\n else out.push(stmt);\n }\n return out;\n}\n\n/**\n * Rewrite the Program body so helper invocations and bounded loops that build\n * the timeline are expanded into concrete per-call / per-iteration `tl.*`\n * statements, each tagged with provenance. Mutates `ast` in place (caller owns\n * the freshly-parsed tree). Constructs it can't statically resolve are left\n * untouched, so the parser falls back to current behavior for them.\n */\nexport function inlineComputedTimelines(\n ast: Node,\n timelineVar: string,\n resolve: LiteralResolver,\n): void {\n const helpers = collectInlinableHelpers(ast, timelineVar);\n const ctx: ExpandCtx = {\n helpers,\n timelineVar,\n resolve,\n depth: 0,\n site: { n: 0 },\n order: { n: 0 },\n };\n const body = (ast.body ?? []).filter((stmt: Node) => !isHelperDecl(stmt, helpers));\n ast.body = expandStatements(body, ctx);\n}\n"],"mappings":";AAQA,OAAO,iBAAiB;;;AC8CjB,IAAM,kBAAkE;AAAA,EAC7E,UAAU,oBAAI,IAAI,CAAC,KAAK,KAAK,YAAY,UAAU,CAAC;AAAA,EACpD,OAAO,oBAAI,IAAI,CAAC,SAAS,UAAU,QAAQ,CAAC;AAAA,EAC5C,MAAM,oBAAI,IAAI,CAAC,SAAS,QAAQ,CAAC;AAAA,EACjC,UAAU,oBAAI,IAAI,CAAC,YAAY,SAAS,OAAO,CAAC;AAAA,EAChD,QAAQ,oBAAI,IAAI,CAAC,WAAW,WAAW,CAAC;AAAA,EACxC,OAAO,oBAAI,IAAY;AACzB;AAEA,IAAM,gBAAgB,oBAAI,IAA+B;AACzD,WAAW,CAAC,OAAO,KAAK,KAAK,OAAO,QAAQ,eAAe,GAGtD;AACH,aAAW,KAAK,MAAO,eAAc,IAAI,GAAG,KAAK;AACnD;AAEO,SAAS,sBA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GAAG,SAAS;AACrB;","names":["toProps","n","acornWalk","isObjectProperty","propKeyName","findPropertyNode","CSS_IDENTITY","cssIdentityValue","PERCENTAGE_KEY_RE","el","ms"]}
1
+ {"version":3,"sources":["../src/gsapWriterAcorn.ts","../src/gsapConstants.ts","../src/gsapSerialize.ts","../src/gsapParserAcorn.ts","../src/gsapInline.ts"],"sourcesContent":["// fallow-ignore-file code-duplication\n/**\n * Browser-safe GSAP write path — magic-string offset-splice.\n *\n * T6c: edits GSAP scripts by overwriting/removing byte ranges in the original\n * source. Every byte outside the edited span is preserved verbatim — no\n * pretty-printer churn. Consumes ParsedGsapAcornForWrite from gsapParserAcorn.ts.\n */\nimport MagicString from \"magic-string\";\nimport type {\n GsapAnimation,\n GsapPercentageKeyframe,\n ArcPathConfig,\n ArcPathSegment,\n} from \"./gsapSerialize.js\";\nimport {\n resolveConversionProps,\n extractArcWaypoints,\n buildMotionPathObjectCode,\n} from \"./gsapSerialize.js\";\nimport {\n parseGsapScriptAcornForWrite,\n type ParsedGsapAcornForWrite,\n type TweenCallInfo,\n} from \"./gsapParserAcorn.js\";\nimport { classifyPropertyGroup } from \"./gsapConstants.js\";\nimport type { PropertyGroupName } from \"./gsapConstants.js\";\nimport type { SplitAnimationsOptions, SplitAnimationsResult } from \"./gsapSerialize.js\";\nimport * as acornWalk from \"acorn-walk\";\n\n// acorn ESTree nodes are structurally untyped here; mirror gsapParserAcorn.ts /\n// gsapInline.ts rather than re-deriving the full ESTree union for every access.\ntype Node = any;\n\n// ── Code generation helpers ──────────────────────────────────────────────────\n\n// Local serializer for the tween-statement path, which may carry boolean/object\n// extras (stagger config). serializeValue stringifies objects to \"[object\n// Object]\", so keep this richer JSON fallback for that path. Keyframe values are\n// always number|string and use the shared serializeValue (recast parity).\nfunction valueToCode(value: unknown): string {\n if (typeof value === \"string\" && value.startsWith(\"__raw:\")) return value.slice(6);\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\") return Number.isNaN(value) ? \"0\" : String(value);\n if (typeof value === \"boolean\") return String(value);\n return JSON.stringify(value);\n}\n\nfunction safeKey(key: string): string {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n}\n\n// fallow-ignore-next-line complexity\nfunction buildTweenStatementCode(timelineVar: string, anim: Omit<GsapAnimation, \"id\">): string {\n const selector = JSON.stringify(anim.targetSelector);\n const props: Record<string, number | string> = { ...anim.properties };\n if (anim.method !== \"set\" && anim.duration !== undefined) props.duration = anim.duration;\n if (anim.ease) props.ease = anim.ease;\n const entries = Object.entries(props).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n if (anim.extras) {\n for (const [k, v] of Object.entries(anim.extras)) {\n entries.push(`${safeKey(k)}: ${valueToCode(v)}`);\n }\n }\n const objCode = `{ ${entries.join(\", \")} }`;\n const posCode = valueToCode(\n typeof anim.position === \"number\" ? anim.position : (anim.position ?? 0),\n );\n if (anim.method === \"fromTo\") {\n const fromEntries = Object.entries(anim.fromProperties ?? {}).map(\n ([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`,\n );\n return `${timelineVar}.fromTo(${selector}, { ${fromEntries.join(\", \")} }, ${objCode}, ${posCode});`;\n }\n // A base `gsap.set` is off the timeline: no timeline var, no position arg.\n if (anim.method === \"set\" && anim.global) {\n return `gsap.set(${selector}, ${objCode});`;\n }\n return `${timelineVar}.${anim.method}(${selector}, ${objCode}, ${posCode});`;\n}\n\n// ── AST node helpers ─────────────────────────────────────────────────────────\n\nfunction isObjectProperty(prop: Node): boolean {\n return prop?.type === \"ObjectProperty\" || prop?.type === \"Property\";\n}\n\nfunction propKeyName(prop: Node): string | undefined {\n return prop?.key?.name ?? prop?.key?.value;\n}\n\nfunction findPropertyNode(varsArgNode: Node, key: string): Node | undefined {\n if (varsArgNode?.type !== \"ObjectExpression\") return undefined;\n for (const prop of varsArgNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n if (propKeyName(prop) === key) return prop;\n }\n return undefined;\n}\n\n/** The `keyframes` property's ObjectExpression value, or null when not a keyframe tween. */\nfunction keyframesObjectNode(varsNode: Node): Node | null {\n const kfProp = findPropertyNode(varsNode, \"keyframes\");\n return kfProp?.value?.type === \"ObjectExpression\" ? kfProp.value : null;\n}\n\nfunction findEnclosingExpressionStatement(ancestors: Node[]): Node | null {\n for (let i = ancestors.length - 2; i >= 0; i--) {\n if (ancestors[i]?.type === \"ExpressionStatement\") return ancestors[i];\n }\n return null;\n}\n\n/** Find the VariableDeclaration statement for `tl = gsap.timeline(...)`. */\nfunction findTimelineDeclarationStatement(ast: Node, timelineVar: string): Node | null {\n let found: Node = null;\n acornWalk.simple(ast, {\n // fallow-ignore-next-line complexity\n VariableDeclaration(node: Node) {\n if (found) return;\n for (const decl of node.declarations ?? []) {\n if (\n decl.id?.name === timelineVar &&\n decl.init?.type === \"CallExpression\" &&\n decl.init.callee?.type === \"MemberExpression\" &&\n decl.init.callee.object?.name === \"gsap\" &&\n decl.init.callee.property?.name === \"timeline\"\n ) {\n found = node;\n }\n }\n },\n });\n return found;\n}\n\n// ── Property splice helpers ───────────────────────────────────────────────────\n\n/**\n * Remove a property from a properties array, handling its comma.\n * `editableProps` must be the isObjectProperty-filtered subset in source order.\n */\nfunction removeProp(ms: MagicString, propNode: Node, editableProps: Node[]): void {\n const idx = editableProps.indexOf(propNode);\n if (idx === -1) return;\n if (editableProps.length === 1) {\n ms.remove(propNode.start, propNode.end);\n } else if (idx === 0) {\n // First prop: remove from its start to next prop start (drops trailing \", \")\n ms.remove(editableProps[0].start, editableProps[1].start);\n } else {\n // Non-first: remove from prev prop end to this prop end (drops leading \", \")\n ms.remove(editableProps[idx - 1].end, propNode.end);\n }\n}\n\n/** Serialize a vars record to an object-literal source: `{ k: v, ... }`. */\nfunction buildVarsObjectCode(record: Record<string, number | string>): string {\n const entries = Object.entries(record).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n return entries.length > 0 ? `{ ${entries.join(\", \")} }` : \"{}\";\n}\n\n/** Overwrite a tween call's vars ObjectExpression with freshly-built source. */\nfunction overwriteVarsArg(ms: MagicString, call: TweenCallInfo, objCode: string): void {\n if (!call.varsArg) return;\n ms.overwrite(call.varsArg.start, call.varsArg.end, objCode);\n}\n\n/**\n * Update a property value if it exists, or append a new key: val before the\n * closing `}`. Call with the full ObjectExpression node.\n */\nfunction upsertProp(ms: MagicString, objNode: Node, key: string, value: unknown): void {\n if (objNode?.type !== \"ObjectExpression\") return;\n const existing = findPropertyNode(objNode, key);\n if (existing) {\n ms.overwrite(existing.value.start, existing.value.end, valueToCode(value));\n } else {\n const sep = objNode.properties.length > 0 ? \", \" : \"\";\n ms.appendLeft(objNode.end - 1, `${sep}${safeKey(key)}: ${valueToCode(value)}`);\n }\n}\n\n/**\n * Vars keys that are NOT editable transform/style props: builtins\n * (duration/ease/delay), dropped callbacks, and extras (stagger/yoyo/repeat/…).\n * The exact union of recast's BUILTIN_VAR_KEYS + DROPPED_VAR_KEYS + EXTRAS_KEYS,\n * so both writers classify vars keys identically. (Distinct from the keyframe-\n * conversion NON_EDITABLE_VAR_KEYS below, which intentionally omits `ease`\n * because that path re-emits ease separately.)\n */\nconst NON_EDITABLE_PROP_KEYS = new Set([\n \"duration\",\n \"ease\",\n \"delay\",\n \"onComplete\",\n \"onStart\",\n \"onUpdate\",\n \"onRepeat\",\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\n/**\n * Editable transform/style key test: anything NOT a builtin, dropped callback, or\n * extras key. Mirrors recast's isEditablePropertyKey so both writers classify\n * vars keys identically.\n */\nfunction isEditableVarKey(key: string): boolean {\n return !NON_EDITABLE_PROP_KEYS.has(key);\n}\n\n/**\n * Collect verbatim `key: value` entries to PRESERVE from a vars/keyframe\n * ObjectExpression: every property whose key `drop` does not reject, sliced from\n * source — except keys present in `overrides`, whose value is replaced. Returns\n * the entries plus the set of keys it kept, so callers can append new keys.\n */\nfunction preservedEntries(\n objNode: Node,\n source: string,\n drop: (key: string) => boolean,\n overrides: Record<string, unknown>,\n): { entries: string[]; keys: Set<string> } {\n const entries: string[] = [];\n const keys = new Set<string>();\n for (const prop of objNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\" || drop(key)) continue;\n keys.add(key);\n const code =\n key in overrides\n ? valueToCode(overrides[key])\n : source.slice(prop.value.start, prop.value.end);\n entries.push(`${safeKey(key)}: ${code}`);\n }\n return { entries, keys };\n}\n\n/**\n * Replace the editable-property keys on a vars ObjectExpression with exactly\n * `newProps`, leaving non-editable keys (duration/ease/stagger/callbacks/…)\n * untouched unless overridden in `nonEditableOverrides`. Mirrors recast's\n * reconcileEditableProperties: editable keys absent from `newProps` are DROPPED,\n * not merged. Rebuilt in a single ms.overwrite so the splice can never overlap a\n * sibling edit — non-editable updates that also target this node (duration/ease/\n * extras) are folded into the same rebuild rather than spliced separately.\n */\nfunction reconcileEditableProps(\n ms: MagicString,\n objNode: Node,\n source: string,\n newProps: Record<string, number | string>,\n nonEditableOverrides?: Record<string, unknown>,\n): void {\n if (objNode?.type !== \"ObjectExpression\") return;\n const overrides = nonEditableOverrides ?? {};\n const { entries, keys } = preservedEntries(objNode, source, isEditableVarKey, overrides);\n for (const [key, value] of Object.entries(overrides)) {\n if (!keys.has(key)) entries.push(`${safeKey(key)}: ${valueToCode(value)}`);\n }\n for (const [key, value] of Object.entries(newProps)) {\n entries.push(`${safeKey(key)}: ${valueToCode(value)}`);\n }\n ms.overwrite(objNode.start, objNode.end, `{ ${entries.join(\", \")} }`);\n}\n\n// ── Insertion helpers ─────────────────────────────────────────────────────────\n\n/** Traverse callee.object chain to check if a call ultimately roots at timelineVar. */\nfunction isTimelineRooted(node: Node, timelineVar: string, script: string): boolean {\n if (node?.type === \"Identifier\") return node.name === timelineVar;\n // Inline/member timelines: `timelineVar` is the source slice (e.g.\n // `window.__timelines[\"scene\"]`); match a MemberExpression callee by its source.\n if (node?.type === \"MemberExpression\") return script.slice(node.start, node.end) === timelineVar;\n if (node?.type === \"CallExpression\")\n return isTimelineRooted(node.callee?.object, timelineVar, script);\n return false;\n}\n\n/**\n * Find the byte offset after which to insert a new statement (tween or label).\n * Returns null when no timeline declaration exists in the script — callers must\n * not emit `tl.xxx()` calls in that case as `tl` would be undefined at render.\n */\nfunction findInsertionPoint(parsed: ParsedGsapAcornForWrite): number | null {\n const lastLocated = parsed.located[parsed.located.length - 1];\n if (lastLocated) {\n const lastCall = lastLocated.call;\n const exprStmt = findEnclosingExpressionStatement(lastCall.ancestors);\n return exprStmt?.end ?? lastCall.node.end;\n }\n if (!parsed.hasTimeline) return null;\n const tlDecl = findTimelineDeclarationStatement(parsed.ast, parsed.timelineVar);\n return tlDecl?.end ?? (parsed.ast.end as number);\n}\n\n// ── Public write API ─────────────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nexport function updateAnimationInScript(\n script: string,\n animationId: string,\n updates: Partial<GsapAnimation> & { easeEach?: string; resetKeyframeEases?: boolean },\n): string {\n if (!Object.keys(updates).length) return script;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const ms = new MagicString(script);\n const { call }: { call: TweenCallInfo } = target;\n\n // When `properties` is present we REPLACE the editable set (recast parity:\n // editable keys absent from the update are dropped). Fold any concurrent\n // non-editable updates (duration/ease/extras) into the single varsArg rebuild\n // so their splices can't overlap the rebuild's overwrite of the whole node.\n if (updates.properties) {\n const overrides: Record<string, unknown> = {};\n if (updates.duration !== undefined) overrides.duration = updates.duration;\n if (updates.ease !== undefined) overrides.ease = updates.ease;\n if (updates.extras) Object.assign(overrides, updates.extras);\n reconcileEditableProps(ms, call.varsArg, script, updates.properties, overrides);\n } else {\n if (updates.duration !== undefined) {\n upsertProp(ms, call.varsArg, \"duration\", updates.duration);\n }\n const easeValue = updates.easeEach ?? updates.ease;\n if (easeValue !== undefined) {\n const kfNode = keyframesObjectNode(call.varsArg);\n if (kfNode) {\n upsertProp(ms, kfNode, \"easeEach\", easeValue);\n // \"Apply to all segments\": drop every per-keyframe `ease` override so the\n // single easeEach governs all segments uniformly (AE select-all + F9).\n if (updates.resetKeyframeEases) {\n for (const kfEntry of kfNode.properties ?? []) {\n if (!isObjectProperty(kfEntry)) continue;\n const val = kfEntry.value;\n if (val?.type !== \"ObjectExpression\") continue;\n const easeNode = findPropertyNode(val, \"ease\");\n if (easeNode) removeProp(ms, easeNode, val.properties);\n }\n }\n } else {\n upsertProp(ms, call.varsArg, \"ease\", easeValue);\n }\n }\n if (updates.extras) {\n for (const [key, value] of Object.entries(updates.extras)) {\n upsertProp(ms, call.varsArg, key, value);\n }\n }\n }\n\n if (updates.fromProperties && call.method === \"fromTo\" && call.fromArg) {\n // fromTo's from-vars carry only editable props — REPLACE them too (recast\n // parity). fromArg is a distinct node from varsArg, so this rebuild never\n // overlaps the varsArg edits above.\n reconcileEditableProps(ms, call.fromArg, script, updates.fromProperties);\n }\n\n if (updates.position !== undefined) {\n overwritePosition(ms, call, updates.position);\n }\n\n return ms.toString();\n}\n\n/**\n * Overwrite a tween call's numeric position argument (the positionArg the parser\n * located: 3rd arg for fromTo, else 2nd), or append one when the call has no\n * explicit position. Shared by updateAnimationInScript and the\n * shift/scalePositionsInScript timeline ops.\n */\nfunction overwritePosition(ms: MagicString, call: TweenCallInfo, position: number | string): void {\n if (call.positionArg) {\n ms.overwrite(call.positionArg.start, call.positionArg.end, valueToCode(position));\n } else {\n ms.appendLeft(call.node.end - 1, `, ${valueToCode(position)}`);\n }\n}\n\n/**\n * Shift every tween targeting `targetSelector` by `delta` seconds (clamped ≥0),\n * rewriting each call's position argument. Mirrors recast's shiftPositionsInScript\n * (used by timeline clip-move to keep GSAP positions in sync with the clip start).\n */\nexport function shiftPositionsInScript(\n script: string,\n targetSelector: string,\n delta: number,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const ms = new MagicString(script);\n let changed = false;\n for (const entry of parsed.located) {\n if (entry.animation.targetSelector !== targetSelector) continue;\n if (typeof entry.animation.position !== \"number\") continue;\n const newPos = Math.max(0, Math.round((entry.animation.position + delta) * 1000) / 1000);\n overwritePosition(ms, entry.call, newPos);\n changed = true;\n }\n return changed ? ms.toString() : script;\n}\n\n/**\n * Linearly remap every tween targeting `targetSelector` from the old clip\n * [oldStart, oldDuration] onto the new [newStart, newDuration] (position and,\n * when present, duration scaled by the duration ratio). Mirrors recast's\n * scalePositionsInScript (used by timeline clip-resize).\n */\nexport function scalePositionsInScript(\n script: string,\n targetSelector: string,\n oldStart: number,\n oldDuration: number,\n newStart: number,\n newDuration: number,\n): string {\n if (oldDuration <= 0 || newDuration <= 0) return script;\n const ratio = newDuration / oldDuration;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const ms = new MagicString(script);\n let changed = false;\n for (const entry of parsed.located) {\n if (entry.animation.targetSelector !== targetSelector) continue;\n if (typeof entry.animation.position !== \"number\") continue;\n const newPos = Math.max(\n 0,\n Math.round((newStart + (entry.animation.position - oldStart) * ratio) * 1000) / 1000,\n );\n overwritePosition(ms, entry.call, newPos);\n if (typeof entry.animation.duration === \"number\" && entry.animation.duration > 0) {\n const newDur = Math.max(0.001, Math.round(entry.animation.duration * ratio * 1000) / 1000);\n upsertProp(ms, entry.call.varsArg, \"duration\", newDur);\n }\n changed = true;\n }\n return changed ? ms.toString() : script;\n}\n\nexport function addAnimationToScript(\n script: string,\n animation: Omit<GsapAnimation, \"id\">,\n): { script: string; id: string } {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, id: \"\" };\n\n const insertionPoint = findInsertionPoint(parsed);\n if (insertionPoint === null) return { script, id: \"\" };\n\n const ms = new MagicString(script);\n const statementCode = buildTweenStatementCode(parsed.timelineVar, animation);\n ms.appendLeft(insertionPoint, \"\\n\" + statementCode);\n\n const result = ms.toString();\n const reParsed = parseGsapScriptAcornForWrite(result);\n const newId = reParsed?.located[reParsed.located.length - 1]?.id ?? \"\";\n return { script: result, id: newId };\n}\n\nexport function removeAnimationFromScript(script: string, animationId: string): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const ms = new MagicString(script);\n const N = target.call.node;\n const exprStmt = findEnclosingExpressionStatement(target.call.ancestors);\n\n if (N.callee?.object?.type !== \"CallExpression\" && exprStmt?.expression === N) {\n // Standalone `tl.method(...)` — remove the whole ExpressionStatement\n const end =\n exprStmt.end < script.length && script[exprStmt.end] === \"\\n\"\n ? exprStmt.end + 1\n : exprStmt.end;\n ms.remove(exprStmt.start, end);\n } else {\n // Chain link — splice out `.method(args)` from N.callee.object.end to N.end\n ms.remove(N.callee.object.end, N.end);\n }\n\n return ms.toString();\n}\n\n// ── Flat-tween → keyframes conversion ──────────────────────────────────────────\n//\n// Mirror recast's convertToKeyframesInScript: when the first keyframe op lands\n// on a flat to()/from()/fromTo() tween, rewrite its vars object to\n// `{ keyframes: { \"0%\": {from}, \"100%\": {to} }, <preserved non-editable keys>,\n// ease: \"none\"? }` and convert from()/fromTo() to to(). We rebuild the whole\n// vars ObjectExpression in one ms.overwrite (single-edit-per-node), so the next\n// keyframe-add re-parses cleanly.\n\n// Identity value for an editable transform/style prop (recast's CSS_IDENTITY).\nconst CSS_IDENTITY: Record<string, number> = {\n opacity: 1,\n autoAlpha: 1,\n scale: 1,\n scaleX: 1,\n scaleY: 1,\n};\n\nfunction cssIdentityValue(prop: string): number {\n return CSS_IDENTITY[prop] ?? 0;\n}\n\n// Keys NOT in the editable set — preserved verbatim on the converted vars object\n// (matches the parser's classification: builtin/dropped/extras keys).\nconst NON_EDITABLE_VAR_KEYS = new Set([\n \"duration\",\n \"delay\",\n \"onComplete\",\n \"onStart\",\n \"onUpdate\",\n \"onRepeat\",\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\n/** The CSS-identity counterpart of a props record (numbers → identity value). */\nfunction identityProps(\n properties: Record<string, number | string>,\n): Record<string, number | string> {\n const identity: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(properties)) {\n if (v != null) identity[k] = typeof v === \"number\" ? cssIdentityValue(k) : v;\n }\n return identity;\n}\n\n/** Resolve the 0%/100% endpoint records for a tween being converted. */\nfunction conversionEndpoints(animation: GsapAnimation): {\n fromProps: Record<string, number | string>;\n toProps: Record<string, number | string>;\n} {\n if (animation.method === \"from\") {\n return { fromProps: { ...animation.properties }, toProps: identityProps(animation.properties) };\n }\n if (animation.method === \"fromTo\") {\n return {\n fromProps: { ...(animation.fromProperties ?? {}) },\n toProps: { ...animation.properties },\n };\n }\n // to(): 0% is the CSS identity state, 100% is the authored props.\n return { fromProps: identityProps(animation.properties), toProps: { ...animation.properties } };\n}\n\n/** Collect preserved (non-editable) `key: value` entries from the original vars node. */\nfunction preservedVarsEntries(varsNode: Node, source: string): string[] {\n const entries: string[] = [];\n if (varsNode?.type !== \"ObjectExpression\") return entries;\n for (const prop of varsNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\" || !NON_EDITABLE_VAR_KEYS.has(key)) continue;\n entries.push(`${safeKey(key)}: ${source.slice(prop.value.start, prop.value.end)}`);\n }\n return entries;\n}\n\n/** Build the rebuilt vars-object code for a converted flat tween. */\nfunction buildConvertedVarsCode(animation: GsapAnimation, varsNode: Node, source: string): string {\n const { fromProps, toProps } = conversionEndpoints(animation);\n const easeEach = animation.ease;\n const easeEachEntry = easeEach ? `, easeEach: ${JSON.stringify(easeEach)}` : \"\";\n const kfCode = `{ \"0%\": ${recordToCode(fromProps)}, \"100%\": ${recordToCode(toProps)}${easeEachEntry} }`;\n const entries = [`keyframes: ${kfCode}`, ...preservedVarsEntries(varsNode, source)];\n if (easeEach) entries.push(`ease: \"none\"`);\n return `{ ${entries.join(\", \")} }`;\n}\n\n/** Rename a from()/fromTo() call to to(), dropping fromTo's leading from-vars arg. */\nfunction convertMethodToTo(\n ms: MagicString,\n animation: GsapAnimation,\n call: Node,\n varsNode: Node,\n): void {\n if (animation.method !== \"from\" && animation.method !== \"fromTo\") return;\n const calleeProp = call.node.callee?.property;\n if (calleeProp) ms.overwrite(calleeProp.start, calleeProp.end, \"to\");\n // Remove the from-vars arg and its trailing separator up to the to-vars arg.\n if (animation.method === \"fromTo\" && call.fromArg) ms.remove(call.fromArg.start, varsNode.start);\n}\n\nfunction convertFlatTweenToKeyframes(script: string, target: Node): string {\n const animation: GsapAnimation = target.animation;\n if (animation.keyframes || animation.method === \"set\") return script;\n const call = target.call;\n const varsNode = call.varsArg;\n if (varsNode?.type !== \"ObjectExpression\") return script;\n\n const ms = new MagicString(script);\n ms.overwrite(varsNode.start, varsNode.end, buildConvertedVarsCode(animation, varsNode, script));\n convertMethodToTo(ms, animation, call, varsNode);\n return ms.toString();\n}\n\n// ── Keyframe write ops ────────────────────────────────────────────────────────\n//\n// Design: mirror the recast writer's rebuild-the-node model. The recast writer\n// mutates AST nodes in place and re-prints, so it never has an offset-overlap\n// problem. Here we instead compute the FINAL property record for every keyframe\n// value node that must change (the target merge, `_auto` endpoint sync, and\n// backfilled siblings) against the ORIGINAL parsed AST, then emit exactly ONE\n// `ms.overwrite(valueNode.start, valueNode.end, code)` per changed node (and a\n// single insert for a brand-new key). No node is ever both overwritten and\n// appended into, so the splices can never overlap.\n\nconst PERCENTAGE_KEY_RE = /^(\\d+(?:\\.\\d+)?)%$/;\n\n// Matches recast's PCT_TOLERANCE: percentages within 2 of an existing key are\n// treated as the same keyframe (merge), not a new insert.\nconst PCT_TOLERANCE = 2;\n\nfunction percentageFromKey(key: string): number {\n const m = PERCENTAGE_KEY_RE.exec(key);\n return m ? Number.parseFloat(m[1] ?? \"0\") : Number.NaN;\n}\n\n/** Serialize a final keyframe property record (number|string values) to code. */\nfunction recordToCode(record: Record<string, number | string>): string {\n const entries = Object.entries(record).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n return `{ ${entries.join(\", \")} }`;\n}\n\n/** Percentage-keyed property nodes of a keyframes ObjectExpression, in source order. */\nfunction percentagePropsOf(kfNode: Node): Node[] {\n return (kfNode.properties ?? []).filter((p: Node) => {\n if (!isObjectProperty(p)) return false;\n const key = propKeyName(p);\n return typeof key === \"string\" && PERCENTAGE_KEY_RE.test(key);\n });\n}\n\nconst LITERAL_NODE_TYPES = new Set([\"Literal\", \"NumericLiteral\", \"StringLiteral\"]);\n\n/** Read one value node: a number/string literal, a negative number, or raw source. */\n// fallow-ignore-next-line complexity\nfunction readValueNode(v: Node, source: string): number | string {\n if (\n LITERAL_NODE_TYPES.has(v?.type) &&\n (typeof v.value === \"number\" || typeof v.value === \"string\")\n ) {\n return v.value;\n }\n if (\n v?.type === \"UnaryExpression\" &&\n v.operator === \"-\" &&\n typeof v.argument?.value === \"number\"\n ) {\n return -v.argument.value;\n }\n return `__raw:${source.slice(v.start, v.end)}`;\n}\n\n/**\n * Read a keyframe value ObjectExpression into a record, mirroring the parser's\n * `objectExpressionToRecord`: literals resolve to their value; anything else is\n * preserved as `__raw:<source>` so serializeValue round-trips it verbatim.\n * Keyframe values are literals in practice, so the raw fallback is rarely hit.\n */\nfunction valueNodeToRecord(valueNode: Node, source: string): Record<string, number | string> {\n const record: Record<string, number | string> = {};\n if (valueNode?.type !== \"ObjectExpression\") return record;\n for (const prop of valueNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\") continue;\n record[key] = readValueNode(prop.value, source);\n }\n return record;\n}\n\n/** True when a keyframe value record carries the synthetic `_auto` marker. */\nfunction recordHasAuto(record: Record<string, number | string>): boolean {\n return \"_auto\" in record;\n}\n\n/**\n * Compute `_auto` endpoint overwrites: when the new keyframe is the immediate\n * neighbor of an `_auto` 0% or 100% endpoint, that endpoint is rewritten to\n * `{ ...newProps, _auto: 1 }`. Only fires for interior keyframes. Returns the\n * percentage→overwrite map so the caller can fold these into the per-node final\n * records (never a separate splice).\n */\nfunction autoEndpointOverwrites(\n kfNode: Node,\n source: string,\n percentage: number,\n properties: Record<string, number | string>,\n): Map<any, Record<string, number | string>> {\n const result = new Map<any, Record<string, number | string>>();\n if (percentage <= 0 || percentage >= 100) return result;\n const pctProps = percentagePropsOf(kfNode);\n const allPcts = pctProps\n .map((p: Node) => percentageFromKey(propKeyName(p) ?? \"\"))\n .filter((n: number) => !Number.isNaN(n) && n !== percentage)\n .sort((a: number, b: number) => a - b);\n const leftNeighbor = allPcts.filter((p: number) => p < percentage).pop();\n const rightNeighbor = allPcts.find((p: number) => p > percentage);\n for (const endPct of [0, 100]) {\n const isNeighbor = endPct === 0 ? leftNeighbor === 0 : rightNeighbor === 100;\n if (!isNeighbor) continue;\n const endProp = pctProps.find((p: Node) => percentageFromKey(propKeyName(p) ?? \"\") === endPct);\n if (!endProp) continue;\n const rec = valueNodeToRecord(endProp.value, source);\n if (!recordHasAuto(rec)) continue;\n result.set(endProp, { ...properties, _auto: 1 });\n }\n return result;\n}\n\nfunction findKfPropByPct(kfNode: Node, percentage: number): { prop: Node; idx: number } | null {\n // Match the CLOSEST keyframe within tolerance, not the first one within range.\n // Keyframes at e.g. 0/49/50/100 are all valid (the SDK dedups to a unique\n // match at TOLERANCE=0.001 upstream); picking the first-within-PCT_TOLERANCE=2\n // would hit 49% when the caller meant 50%. Tie-break on the earliest index so\n // the choice stays deterministic.\n const props = kfNode.properties ?? [];\n let best: { prop: Node; idx: number } | null = null;\n let bestDist = Number.POSITIVE_INFINITY;\n for (let i = 0; i < props.length; i++) {\n const prop = props[i];\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (typeof key !== \"string\") continue;\n const dist = Math.abs(percentageFromKey(key) - percentage);\n if (dist <= PCT_TOLERANCE && dist < bestDist) {\n best = { prop, idx: i };\n bestDist = dist;\n }\n }\n return best;\n}\n\nexport function updateKeyframeInScript(\n script: string,\n animationId: string,\n percentage: number,\n properties: Record<string, number | string>,\n ease?: string,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode) return script;\n\n // Array-form keyframes (`keyframes: [{x,y}, ...]`) carry no explicit percentages\n // — GSAP distributes them evenly, and the runtime read assigns even percentages\n // (0, 100/(n-1), …). Map the percentage back to an array index and overwrite that\n // element in place (preserving the array form). Without this the function bailed\n // on the ObjectExpression check, so dragging a motion-path node on an array-form\n // tween committed nothing (server no-op).\n if (kfPropNode.value?.type === \"ArrayExpression\") {\n return updateArrayKeyframeByPct(script, kfPropNode.value, percentage, properties, ease);\n }\n if (kfPropNode.value?.type !== \"ObjectExpression\") return script;\n\n const match = findKfPropByPct(kfPropNode.value, percentage);\n if (!match) return script;\n\n const ms = new MagicString(script);\n // MERGE the edited props into the existing keyframe, preserving properties already\n // keyframed at this percentage (z, transformPerspective, rotation, …). A whole-value\n // overwrite DROPS every prop not in this edit — e.g. editing rotationY at the 0%\n // keyframe would strip z / transformPerspective, so the lens then animates from 0 and\n // the element pops. Mirrors addKeyframeToScript's merge-into-existing branch.\n if (match.prop.value?.type === \"ObjectExpression\") {\n for (const [k, v] of Object.entries(properties)) {\n upsertProp(ms, match.prop.value, k, v);\n }\n if (ease !== undefined) upsertProp(ms, match.prop.value, \"ease\", ease);\n } else {\n const record: Record<string, number | string> = { ...properties };\n if (ease) record.ease = ease;\n ms.overwrite(match.prop.value.start, match.prop.value.end, recordToCode(record));\n }\n return ms.toString();\n}\n\n// ponytail: even-spacing index map; if array keyframes ever carry per-element\n// `duration`, switch to matching the closest cumulative position.\nfunction updateArrayKeyframeByPct(\n script: string,\n arrayNode: Node,\n percentage: number,\n properties: Record<string, number | string>,\n ease?: string,\n): string {\n const elements = ((arrayNode.elements ?? []) as Array<Node | null>).filter(\n (el): el is Node => !!el && el.type === \"ObjectExpression\",\n );\n const n = elements.length;\n if (n === 0) return script;\n const idx = n > 1 ? Math.round((percentage / 100) * (n - 1)) : 0;\n const el = elements[Math.max(0, Math.min(n - 1, idx))];\n if (!el) return script;\n const merged: Record<string, number | string> = {\n ...valueNodeToRecord(el, script),\n ...properties,\n };\n if (ease) merged.ease = ease;\n const ms = new MagicString(script);\n ms.overwrite(el.start, el.end, recordToCode(merged));\n return ms.toString();\n}\n\n/**\n * Build the final property record for the keyframe at `percentage`. If a\n * keyframe already exists there, MERGE the new props over the existing record\n * (preserve untouched props, preserve `_auto`, preserve the existing per-keyframe\n * ease when the op omits one); otherwise it's just the new props.\n */\nfunction buildTargetRecord(\n existing: { prop: Node; idx: number } | null,\n source: string,\n properties: Record<string, number | string>,\n ease: string | undefined,\n): Record<string, number | string> {\n if (!existing || existing.prop.value?.type !== \"ObjectExpression\") {\n const record: Record<string, number | string> = { ...properties };\n if (ease) record.ease = ease;\n return record;\n }\n const existingRecord = valueNodeToRecord(existing.prop.value, source);\n const existingEase = typeof existingRecord.ease === \"string\" ? existingRecord.ease : undefined;\n const merged: Record<string, number | string> = { ...existingRecord };\n for (const [k, v] of Object.entries(properties)) merged[k] = v;\n const finalEase = ease ?? existingEase;\n if (finalEase) merged.ease = finalEase;\n else delete merged.ease;\n return merged;\n}\n\n/**\n * Compute the backfilled final record for one sibling keyframe: append any of\n * `newPropKeys` it's missing, using the backfill default. Returns null when\n * nothing changes (so the caller emits no overwrite for it).\n */\nfunction backfilledSiblingRecord(\n valueNode: Node,\n source: string,\n newPropKeys: string[],\n backfillDefaults: Record<string, number | string>,\n): Record<string, number | string> | null {\n if (valueNode?.type !== \"ObjectExpression\") return null;\n const record = valueNodeToRecord(valueNode, source);\n let changed = false;\n for (const pk of newPropKeys) {\n const defaultVal = backfillDefaults[pk];\n if (pk in record || defaultVal == null) continue;\n record[pk] = defaultVal;\n changed = true;\n }\n return changed ? record : null;\n}\n\n/** A located tween whose varsArg has a static keyframes ObjectExpression, or null. */\nfunction locateWithKeyframes(\n script: string,\n animationId: string,\n): { script: string; parsed: ParsedGsapAcornForWrite; target: Node; kfNode: Node } | null {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return null;\n // Converting from()/fromTo() to to() rewrites the content-derived id; match\n // recast's locateAnimationWithFallback by remapping the method segment.\n const convertedId = animationId.replace(/-from-|-fromTo-/, \"-to-\");\n const target =\n parsed.located.find((l) => l.id === animationId) ??\n parsed.located.find((l) => l.id === convertedId);\n if (!target) return null;\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode || kfPropNode.value?.type !== \"ObjectExpression\") return null;\n return { script, parsed, target, kfNode: kfPropNode.value };\n}\n\n/** Locate a tween's keyframes object, converting a flat tween first if absent. */\n// Array-form keyframes (`keyframes: [{x,y}, …]`) → even-percentage object form\n// (`{ \"0%\": {…}, \"33.3%\": {…}, … }`). Inserting a keyframe needs percentage keys,\n// which an even array can't host. Runtime-identical; mirrors the recast path.\nfunction convertArrayKeyframesToObject(script: string, target: Node): string {\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode || kfPropNode.value?.type !== \"ArrayExpression\") return script;\n const els = ((kfPropNode.value.elements ?? []) as Array<Node | null>).filter(\n (el): el is Node => !!el && el.type === \"ObjectExpression\",\n );\n const n = els.length;\n if (n === 0) return script;\n const entries = els.map((el, i) => {\n const pct = n > 1 ? Math.round((i / (n - 1)) * 1000) / 10 : 0;\n return `${JSON.stringify(`${pct}%`)}: ${script.slice(el.start, el.end)}`;\n });\n const ms = new MagicString(script);\n ms.overwrite(kfPropNode.value.start, kfPropNode.value.end, `{ ${entries.join(\", \")} }`);\n return ms.toString();\n}\n\nfunction ensureKeyframesNode(\n script: string,\n animationId: string,\n): { script: string; parsed: ParsedGsapAcornForWrite; target: Node; kfNode: Node } | null {\n const direct = locateWithKeyframes(script, animationId);\n if (direct) return direct;\n\n const parsed = parseGsapScriptAcornForWrite(script);\n const target = parsed?.located.find((l) => l.id === animationId);\n if (!target) return null;\n\n // Array-form keyframes → normalize to object form, then re-locate.\n const kfProp = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (kfProp?.value?.type === \"ArrayExpression\") {\n const normalized = convertArrayKeyframesToObject(script, target);\n if (normalized !== script) return locateWithKeyframes(normalized, animationId);\n return null;\n }\n\n // No static keyframes object — convert the flat tween, then re-locate.\n const converted = convertFlatTweenToKeyframes(script, target);\n if (converted === script) return null;\n return locateWithKeyframes(converted, animationId);\n}\n\n/**\n * Compute the sibling keyframe nodes that need a backfilled prop, excluding the\n * target keyframe and any node already being overwritten as an `_auto` endpoint.\n */\nfunction collectBackfillOverwrites(\n kfNode: Node,\n src: string,\n properties: Record<string, number | string>,\n backfillDefaults: Record<string, number | string> | undefined,\n skip: { existingProp: Node; endpoints: Map<any, unknown> },\n): Map<any, Record<string, number | string>> {\n const result = new Map<any, Record<string, number | string>>();\n if (!backfillDefaults) return result;\n const newPropKeys = Object.keys(properties);\n for (const prop of percentagePropsOf(kfNode)) {\n if (prop === skip.existingProp || skip.endpoints.has(prop)) continue;\n const rec = backfilledSiblingRecord(prop.value, src, newPropKeys, backfillDefaults);\n if (rec) result.set(prop, rec);\n }\n return result;\n}\n\nexport function addKeyframeToScript(\n script: string,\n animationId: string,\n percentage: number,\n properties: Record<string, number | string>,\n ease?: string,\n backfillDefaults?: Record<string, number | string>,\n): string {\n const located = ensureKeyframesNode(script, animationId);\n if (!located) return script;\n const { script: src, kfNode } = located;\n\n const existing = findKfPropByPct(kfNode, percentage);\n\n // Final record for the target keyframe (merge if it already exists).\n const targetRecord = buildTargetRecord(existing, src, properties, ease);\n // `_auto` endpoint syncs fire only on new inserts; a merge landing ON an\n // endpoint already preserves `_auto` via buildTargetRecord.\n const endpointOverwrites = existing\n ? new Map<any, Record<string, number | string>>()\n : autoEndpointOverwrites(kfNode, src, percentage, properties);\n // Backfilled siblings (each node changes at most once).\n const backfillOverwrites = collectBackfillOverwrites(kfNode, src, properties, backfillDefaults, {\n existingProp: existing?.prop,\n endpoints: endpointOverwrites,\n });\n\n // Emit exactly one overwrite per changed node, plus one insert for a new key.\n const ms = new MagicString(src);\n if (existing) {\n // Merge into the existing keyframe at this percentage, preserving sibling\n // properties — overwrite only the given keys. (A whole-value overwrite here\n // would silently drop other properties already keyframed at this percent.)\n if (existing.prop.value?.type === \"ObjectExpression\") {\n for (const [k, v] of Object.entries(properties)) {\n upsertProp(ms, existing.prop.value, k, v);\n }\n if (ease !== undefined) upsertProp(ms, existing.prop.value, \"ease\", ease);\n } else {\n ms.overwrite(existing.prop.value.start, existing.prop.value.end, recordToCode(targetRecord));\n }\n } else {\n insertNewKeyframe(ms, kfNode, percentage, `${percentage}%`, recordToCode(targetRecord));\n }\n for (const [prop, rec] of [...endpointOverwrites, ...backfillOverwrites]) {\n ms.overwrite(prop.value.start, prop.value.end, recordToCode(rec));\n }\n\n return ms.toString();\n}\n\n/** Insert a brand-new `\"pct%\": {...}` property in sorted order. */\nfunction insertNewKeyframe(\n ms: MagicString,\n kfNode: Node,\n percentage: number,\n pctKey: string,\n valueCode: string,\n): void {\n const allProps = (kfNode.properties ?? []).filter((p: Node) => isObjectProperty(p));\n let insertBeforeProp: Node = null;\n for (const prop of allProps) {\n const key = propKeyName(prop);\n if (typeof key === \"string\" && percentageFromKey(key) > percentage) {\n insertBeforeProp = prop;\n break;\n }\n }\n if (insertBeforeProp) {\n ms.appendLeft(insertBeforeProp.start, `${JSON.stringify(pctKey)}: ${valueCode}, `);\n } else {\n const sep = allProps.length > 0 ? \", \" : \"\";\n ms.appendLeft(kfNode.end - 1, `${sep}${JSON.stringify(pctKey)}: ${valueCode}`);\n }\n}\n\n/**\n * Rebuild a vars ObjectExpression that has just dropped below two keyframes,\n * collapsing `keyframes: {…}` back to a flat tween. Mirrors recast's\n * collapseKeyframesToFlat: drop the `keyframes` + `easeEach` keys, preserve every\n * other vars key verbatim, and splice the remaining keyframe's properties (minus\n * its per-keyframe `ease`) in as flat vars keys. Single ms.overwrite of the whole\n * vars node so the splice can't overlap the keyframe removal.\n */\nfunction collapseKeyframesToFlat(\n ms: MagicString,\n varsNode: Node,\n source: string,\n remainingRecord: Record<string, number | string>,\n): void {\n if (varsNode?.type !== \"ObjectExpression\") return;\n const dropKeyframeKeys = (key: string) => key === \"keyframes\" || key === \"easeEach\";\n const { entries } = preservedEntries(varsNode, source, dropKeyframeKeys, {});\n for (const [k, v] of Object.entries(remainingRecord)) {\n if (k !== \"ease\") entries.push(`${safeKey(k)}: ${valueToCode(v)}`);\n }\n ms.overwrite(varsNode.start, varsNode.end, `{ ${entries.join(\", \")} }`);\n}\n\n/** Implicit tween-relative percentage of array-form keyframe index `i` of `n`\n * (GSAP distributes array keyframes evenly: 0%, 1/(n-1), …, 100%). */\nfunction arrayKeyframePct(i: number, n: number): number {\n return n > 1 ? (i / (n - 1)) * 100 : 0;\n}\n\n// Array-form keyframes (`keyframes: [{x,y}, …]`) carry no explicit percentages —\n// GSAP distributes them evenly. removeKeyframeFromScript only handled the\n// object-form (`keyframes: { \"50%\": {…} }`), so removing from an array-form tween\n// was a silent no-op (and the downstream hold-sync then stranded an `hf-hold`).\n// Resolve the element by its implicit percentage and splice it out; collapse to a\n// flat tween when fewer than two remain (parity with the object-form path).\nfunction removeArrayKeyframe(\n ms: MagicString,\n varsArg: Node,\n arrNode: Node,\n script: string,\n percentage: number,\n): boolean {\n const elements: Node[] = (arrNode.elements ?? []).filter(\n (e: Node | null): e is Node => !!e && e.type === \"ObjectExpression\",\n );\n const n = elements.length;\n if (n === 0) return false;\n\n let matchIdx = -1;\n let bestDist = Number.POSITIVE_INFINITY;\n for (let i = 0; i < n; i++) {\n const dist = Math.abs(arrayKeyframePct(i, n) - percentage);\n if (dist <= PCT_TOLERANCE && dist < bestDist) {\n matchIdx = i;\n bestDist = dist;\n }\n }\n if (matchIdx === -1) return false;\n\n const remaining = elements.filter((_, i) => i !== matchIdx);\n if (remaining.length < 2) {\n const sole = remaining[0];\n const record = sole ? valueNodeToRecord(sole, script) : {};\n collapseKeyframesToFlat(ms, varsArg, script, record);\n return true;\n }\n removeProp(ms, elements[matchIdx], elements);\n return true;\n}\n\nexport function removeKeyframeFromScript(\n script: string,\n animationId: string,\n percentage: number,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const kfPropNode = findPropertyNode(target.call.varsArg, \"keyframes\");\n if (!kfPropNode) return script;\n\n if (kfPropNode.value?.type === \"ArrayExpression\") {\n const ms = new MagicString(script);\n return removeArrayKeyframe(ms, target.call.varsArg, kfPropNode.value, script, percentage)\n ? ms.toString()\n : script;\n }\n\n if (kfPropNode.value?.type !== \"ObjectExpression\") return script;\n const kfNode = kfPropNode.value;\n\n const match = findKfPropByPct(kfNode, percentage);\n if (!match) return script;\n\n const ms = new MagicString(script);\n\n // If removing this keyframe leaves fewer than two, collapse the keyframes\n // object back to a flat tween (recast parity) instead of leaving a lone\n // keyframe. We rebuild the whole vars node, so we never also splice the kf\n // node — the two edits would overlap.\n const remaining = percentagePropsOf(kfNode).filter((p) => p !== match.prop);\n if (remaining.length < 2) {\n const sole = remaining[0];\n const record = sole ? valueNodeToRecord(sole.value, script) : {};\n collapseKeyframesToFlat(ms, target.call.varsArg, script, record);\n return ms.toString();\n }\n\n const allProps = (kfNode.properties ?? []).filter((p: Node) => isObjectProperty(p));\n removeProp(ms, match.prop, allProps);\n return ms.toString();\n}\n\nexport function removePropertyFromAnimation(\n script: string,\n animationId: string,\n property: string,\n from = false,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const { call } = target;\n const objNode = from ? (call.method === \"fromTo\" ? call.fromArg : null) : call.varsArg;\n if (!objNode) return script;\n const propNode = findPropertyNode(objNode, property);\n if (!propNode) return script;\n const allProps = (objNode.properties ?? []).filter((p: Node) => isObjectProperty(p));\n const ms = new MagicString(script);\n removeProp(ms, propNode, allProps);\n return ms.toString();\n}\n\n/**\n * Remove all keyframes from a tween, collapsing to a flat tween with one\n * keyframe's properties: the first for `from()`, the last otherwise (the\n * destination = the visible resting state).\n */\nexport function removeAllKeyframesFromScript(script: string, animationId: string): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const kfs = target.animation.keyframes?.keyframes;\n if (!kfs || kfs.length === 0) return script;\n\n const sorted = [...kfs].sort((a, b) => a.percentage - b.percentage);\n const collapse = target.call.method === \"from\" ? sorted[0] : sorted[sorted.length - 1];\n if (!collapse) return script;\n\n const ms = new MagicString(script);\n overwriteVarsArg(\n ms,\n target.call,\n buildVarsObjectCode(buildCollapsedFlatVars(target.animation, collapse)),\n );\n return ms.toString();\n}\n\n// Flat vars for a tween collapsing its keyframes onto one stop: existing\n// top-level props, then the collapse keyframe's props (skip per-keyframe\n// `ease`), then duration/ease/extras. Drops keyframes + easeEach by omission.\nfunction buildCollapsedFlatVars(\n animation: GsapAnimation,\n collapse: { properties: Record<string, number | string> },\n): Record<string, number | string> {\n const flat: Record<string, number | string> = { ...animation.properties };\n for (const [k, v] of Object.entries(collapse.properties)) {\n if (k !== \"ease\") flat[k] = v;\n }\n if (animation.duration !== undefined) flat.duration = animation.duration;\n if (animation.ease) flat.ease = animation.ease;\n for (const [k, v] of Object.entries(animation.extras ?? {})) {\n if (typeof v === \"number\" || typeof v === \"string\") flat[k] = v;\n }\n return flat;\n}\n\n/** Build the full replacement vars object for a tween being converted to keyframes. */\nfunction buildKeyframesVarsCode(\n animation: GsapAnimation,\n fromProps: Record<string, number | string>,\n toProps: Record<string, number | string>,\n varsNode: Node,\n source: string,\n setDuration?: number,\n): string {\n const fromEntries = Object.entries(fromProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n const toEntries = Object.entries(toProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n const easeEntry = animation.ease ? `, easeEach: ${JSON.stringify(animation.ease)}` : \"\";\n const kfCode = `{ \"0%\": { ${fromEntries.join(\", \")} }, \"100%\": { ${toEntries.join(\", \")} }${easeEntry} }`;\n // Preserve every non-editable key (duration/delay/callbacks/stagger/yoyo/…)\n // verbatim from source — rebuilding from the animation object alone dropped\n // `delay` (not a GsapAnimation field), shifting the tween's start time.\n let preserved = preservedVarsEntries(varsNode, source);\n // Converting a static `set` → drop its hold markers and give it a real duration\n // so the keyframes span time.\n if (setDuration !== undefined) {\n preserved = preserved.filter((e) => !/^\\s*(immediateRender|data|duration)\\s*:/.test(e));\n }\n const parts: string[] = [`keyframes: ${kfCode}`, ...preserved];\n if (setDuration !== undefined) parts.push(`duration: ${Math.max(0.001, setDuration)}`);\n if (animation.ease) parts.push(`ease: \"none\"`);\n return `{ ${parts.join(\", \")} }`;\n}\n\n/**\n * Convert a flat tween (to/from/fromTo) to percentage-keyframes format.\n * `resolvedFromValues` supplies the current DOM state: overrides the 0% endpoint\n * for `to()`, the 100% endpoint for `from()`, or merges into toProps for `fromTo()`.\n */\nexport function convertToKeyframesFromScript(\n script: string,\n animationId: string,\n resolvedFromValues?: Record<string, number | string>,\n setDuration = 1,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const { animation, call } = target;\n if (animation.keyframes) return script;\n const isSet = call.method === \"set\";\n\n const { fromProps, toProps } = resolveConversionProps(animation, resolvedFromValues);\n const ms = new MagicString(script);\n\n // A GLOBAL `gsap.set(...)` is off-timeline; rewriting only the method emits\n // `gsap.to(...)`, which fires once at load and isn't on the paused master\n // timeline (the engine can't seek/render it). Re-root onto the timeline var\n // and add the position arg the set lacks so the converted tween is seekable.\n if (isSet && animation.global) {\n const calleeObj = call.node.callee.object;\n if (calleeObj?.type === \"Identifier\") {\n ms.overwrite(calleeObj.start, calleeObj.end, parsed.timelineVar);\n }\n const args = call.node.arguments;\n if (args.length > 0 && args.length < 3) {\n ms.appendLeft(args[args.length - 1].end, \", 0\");\n }\n }\n\n // set/from/fromTo all become `to`; fromTo also drops its `from` argument.\n if (call.method === \"from\" || call.method === \"fromTo\" || isSet) {\n ms.overwrite(call.node.callee.property.start, call.node.callee.property.end, \"to\");\n }\n if (call.method === \"fromTo\" && call.fromArg) {\n ms.remove(call.fromArg.start, call.varsArg.start);\n }\n overwriteVarsArg(\n ms,\n call,\n buildKeyframesVarsCode(\n animation,\n fromProps,\n toProps,\n call.varsArg,\n script,\n isSet ? setDuration : undefined,\n ),\n );\n\n return ms.toString();\n}\n\n// ── Keyframe-object code builder ─────────────────────────────────────────────\n\n/** Build a percentage-keyframes object literal: `{ \"0%\": { x: 0 }, \"100%\": { x: 100 } }`. */\nfunction buildKeyframeObjectCode(\n keyframes: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n auto?: boolean;\n }>,\n easeEach?: string,\n): string {\n const entries = keyframes.map((kf) => {\n const props = Object.entries(kf.properties).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);\n if (kf.ease) props.push(`ease: ${JSON.stringify(kf.ease)}`);\n if (kf.auto) props.push(`_auto: 1`);\n return `${JSON.stringify(`${kf.percentage}%`)}: { ${props.join(\", \")} }`;\n });\n if (easeEach) entries.push(`easeEach: ${JSON.stringify(easeEach)}`);\n return `{ ${entries.join(\", \")} }`;\n}\n\n// ── Materialize keyframes ────────────────────────────────────────────────────\n\n/**\n * Replace a dynamic or static keyframes expression with a fully-resolved\n * percentage-keyframes object. Called when a user first edits a dynamically-\n * generated keyframe in the studio so it becomes statically editable.\n */\nexport function materializeKeyframesFromScript(\n script: string,\n animationId: string,\n keyframes: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n }>,\n easeEach?: string,\n resolvedSelector?: string,\n): string {\n // An empty keyframe list has no materialized form — rebuilding vars with an\n // empty keyframes object would empty the animation. No-op instead.\n if (keyframes.length === 0) return script;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const { call } = target;\n const sorted = [...keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfObjCode = buildKeyframeObjectCode(sorted, easeEach);\n const ms = new MagicString(script);\n\n if (resolvedSelector) {\n const selectorArg = call.node.arguments[0];\n if (selectorArg)\n ms.overwrite(selectorArg.start, selectorArg.end, JSON.stringify(resolvedSelector));\n }\n\n const kfProp = findPropertyNode(call.varsArg, \"keyframes\");\n if (kfProp) {\n ms.overwrite(kfProp.value.start, kfProp.value.end, kfObjCode);\n } else if (call.varsArg?.type === \"ObjectExpression\") {\n const vars = call.varsArg;\n if (vars.properties.length > 0) {\n ms.prependLeft(vars.properties[0].start, `keyframes: ${kfObjCode}, `);\n } else {\n ms.appendLeft(vars.end - 1, `keyframes: ${kfObjCode}`);\n }\n }\n\n const eachProp = findPropertyNode(call.varsArg, \"easeEach\");\n if (eachProp) {\n const allProps = (call.varsArg.properties ?? []).filter((p: Node) => isObjectProperty(p));\n removeProp(ms, eachProp, allProps);\n }\n\n return ms.toString();\n}\n\n// ── Add animation with keyframes ──────────────────────────────────────────────\n\n/** Insert a new keyframed `to()` call and return the new animation ID. */\nexport function addAnimationWithKeyframesToScript(\n script: string,\n targetSelector: string,\n position: number,\n duration: number,\n keyframes: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n auto?: boolean;\n }>,\n ease?: string,\n easeEach?: string,\n): { script: string; id: string } {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, id: \"\" };\n const insertionPoint = findInsertionPoint(parsed);\n if (insertionPoint === null) return { script, id: \"\" };\n\n const sorted = [...keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfObjCode = buildKeyframeObjectCode(sorted, easeEach);\n const varParts = [`keyframes: ${kfObjCode}`, `duration: ${valueToCode(duration)}`];\n if (ease) varParts.push(`ease: ${JSON.stringify(ease)}`);\n const stmtCode = `${parsed.timelineVar}.to(${JSON.stringify(targetSelector)}, { ${varParts.join(\", \")} }, ${valueToCode(position)});`;\n\n const ms = new MagicString(script);\n ms.appendLeft(insertionPoint, \"\\n\" + stmtCode);\n\n const result = ms.toString();\n const reParsed = parseGsapScriptAcornForWrite(result);\n const newId = reParsed?.located[reParsed.located.length - 1]?.id ?? \"\";\n return { script: result, id: newId };\n}\n\n// ── Split into property groups ────────────────────────────────────────────────\n\nfunction collectPropertyKeys(anim: GsapAnimation): Set<string> {\n const keys = new Set<string>();\n if (anim.keyframes) {\n for (const kf of anim.keyframes.keyframes) {\n for (const k of Object.keys(kf.properties)) keys.add(k);\n }\n } else {\n for (const k of Object.keys(anim.properties)) keys.add(k);\n }\n return keys;\n}\n\nfunction partitionPropertyGroups(keys: Set<string>): Map<PropertyGroupName, string[]> {\n const groups = new Map<PropertyGroupName, string[]>();\n for (const key of keys) {\n if (key === \"transformOrigin\") continue;\n const group = classifyPropertyGroup(key);\n let arr = groups.get(group);\n if (!arr) {\n arr = [];\n groups.set(group, arr);\n }\n arr.push(key);\n }\n return groups;\n}\n\nfunction assignTransformOrigin(groupProps: Map<PropertyGroupName, string[]>): void {\n let largestGroup: PropertyGroupName | undefined;\n let largestCount = 0;\n for (const [group, props] of groupProps) {\n if (props.length > largestCount) {\n largestCount = props.length;\n largestGroup = group;\n }\n }\n const largest = largestGroup ? groupProps.get(largestGroup) : undefined;\n if (largest) largest.push(\"transformOrigin\");\n}\n\nfunction filterGroupKeyframes(\n kfs: GsapPercentageKeyframe[],\n propSet: Set<string>,\n): Array<{ percentage: number; properties: Record<string, number | string>; ease?: string }> {\n const result: Array<{\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n }> = [];\n for (const kf of kfs) {\n const filtered: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(kf.properties)) {\n if (propSet.has(k)) filtered[k] = v;\n }\n if (Object.keys(filtered).length > 0) {\n result.push({\n percentage: kf.percentage,\n properties: filtered,\n ...(kf.ease ? { ease: kf.ease } : {}),\n });\n }\n }\n return result;\n}\n\nfunction filterGroupProperties(\n properties: Record<string, number | string>,\n propSet: Set<string>,\n): Record<string, number | string> {\n const result: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(properties)) {\n if (propSet.has(k)) result[k] = v;\n }\n return result;\n}\n\nfunction addGroupAnimToScript(\n script: string,\n anim: GsapAnimation,\n propSet: Set<string>,\n): { script: string; id: string } {\n if (anim.keyframes) {\n const groupKeyframes = filterGroupKeyframes(anim.keyframes.keyframes, propSet);\n if (groupKeyframes.length === 0) return { script, id: \"\" };\n const pos = typeof anim.position === \"number\" ? anim.position : 0;\n return addAnimationWithKeyframesToScript(\n script,\n anim.targetSelector,\n pos,\n anim.duration ?? 0.5,\n groupKeyframes,\n anim.keyframes.easeEach ?? anim.ease,\n );\n }\n const groupProperties = filterGroupProperties(anim.properties, propSet);\n if (Object.keys(groupProperties).length === 0) return { script, id: \"\" };\n const fromProperties =\n anim.method === \"fromTo\" && anim.fromProperties\n ? filterGroupProperties(anim.fromProperties, propSet)\n : undefined;\n return addAnimationToScript(script, {\n targetSelector: anim.targetSelector,\n method: anim.method,\n position: anim.position,\n duration: anim.duration,\n ease: anim.ease,\n properties: groupProperties,\n fromProperties,\n extras: anim.extras,\n });\n}\n\n/**\n * Split a mixed-property tween into one tween per property group (position,\n * scale, visual, etc.) so each group can be edited independently.\n * Returns the updated script and the IDs of the newly-created tweens.\n */\nexport function splitIntoPropertyGroupsFromScript(\n script: string,\n animationId: string,\n): { script: string; ids: string[] } {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, ids: [animationId] };\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return { script, ids: [animationId] };\n const { animation } = target;\n\n const allPropKeys = collectPropertyKeys(animation);\n const groupProps = partitionPropertyGroups(allPropKeys);\n if (groupProps.size <= 1) return { script, ids: [animationId] };\n if (allPropKeys.has(\"transformOrigin\")) assignTransformOrigin(groupProps);\n\n let result = removeAnimationFromScript(script, animationId);\n for (const [, props] of groupProps) {\n const { script: next, id } = addGroupAnimToScript(result, animation, new Set(props));\n if (id) result = next;\n }\n\n const reParsed = parseGsapScriptAcornForWrite(result);\n const newIds = (reParsed?.located ?? [])\n .filter((l) => l.animation.targetSelector === animation.targetSelector)\n .map((l) => l.id);\n return { script: result, ids: newIds };\n}\n\n// ── Label write ops ───────────────────────────────────────────────────────────\n\n/** True when `expr` is `tl.<method>(…)` rooted at the timeline var. */\nfunction isTimelineMethodCall(\n expr: Node,\n timelineVar: string,\n method: string,\n script: string,\n): boolean {\n return (\n expr?.type === \"CallExpression\" &&\n expr.callee?.type === \"MemberExpression\" &&\n isTimelineRooted(expr.callee.object, timelineVar, script) &&\n expr.callee.property?.name === method\n );\n}\n\n/** True when `expr` is `tl.addLabel(\"<name>\", …)` rooted at the timeline var. */\nfunction isAddLabelCall(expr: Node, timelineVar: string, name: string, script: string): boolean {\n const firstArg = expr?.arguments?.[0];\n return (\n isTimelineMethodCall(expr, timelineVar, \"addLabel\", script) &&\n firstArg?.type === \"Literal\" &&\n firstArg.value === name\n );\n}\n\n/** Every `tl.addLabel(\"<name>\", …)` ExpressionStatement in the script. */\nfunction findLabelStatements(\n parsed: ParsedGsapAcornForWrite,\n name: string,\n script: string,\n): Node[] {\n const targets: Node[] = [];\n acornWalk.simple(parsed.ast, {\n ExpressionStatement(node: Node) {\n if (isAddLabelCall(node.expression, parsed.timelineVar, name, script)) targets.push(node);\n },\n });\n return targets;\n}\n\nexport function addLabelToScript(script: string, name: string, position: number): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n\n // If the label already exists, MOVE it (overwrite its position) rather than\n // appending a duplicate. Two same-named addLabel statements make removeLabel\n // over-remove — it deletes every match, including a pre-existing label the\n // user never touched.\n const existing = findLabelStatements(parsed, name, script)[0];\n if (existing) {\n const ms = new MagicString(script);\n const posArg = existing.expression.arguments?.[1];\n if (posArg) ms.overwrite(posArg.start, posArg.end, valueToCode(position));\n else ms.appendLeft(existing.expression.end - 1, `, ${valueToCode(position)}`);\n return ms.toString();\n }\n\n const insertionPoint = findInsertionPoint(parsed);\n if (insertionPoint === null) return script;\n\n const ms = new MagicString(script);\n const labelCode = `${parsed.timelineVar}.addLabel(${JSON.stringify(name)}, ${valueToCode(position)});`;\n ms.appendLeft(insertionPoint, \"\\n\" + labelCode);\n return ms.toString();\n}\n\nexport function removeLabelFromScript(script: string, name: string): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n\n const targets = findLabelStatements(parsed, name, script);\n if (!targets.length) return script;\n\n const ms = new MagicString(script);\n for (const target of targets) {\n const end =\n target.end < script.length && script[target.end] === \"\\n\" ? target.end + 1 : target.end;\n ms.remove(target.start, end);\n }\n return ms.toString();\n}\n\n// ── Arc path helpers ─────────────────────────────────────────────────────────\n\n/**\n * Remove a set of properties from an ObjectExpression in a single pass.\n * Groups consecutive marked props into blocks to avoid overlapping remove ranges.\n */\nfunction removePropsByKey(ms: MagicString, objNode: Node, keys: Set<string>): void {\n if (objNode?.type !== \"ObjectExpression\") return;\n const allProps = (objNode.properties ?? []).filter(isObjectProperty);\n const marked = allProps.map((p: Node) => keys.has(propKeyName(p) ?? \"\"));\n let i = 0;\n while (i < allProps.length) {\n if (!marked[i]) {\n i++;\n continue;\n }\n const blockStart = i;\n while (i < allProps.length && marked[i]) i++;\n ms.remove(...blockRemoveRange(allProps, blockStart, i));\n }\n}\n\nfunction blockRemoveRange(\n allProps: Node[],\n blockStart: number,\n blockEnd: number,\n): [number, number] {\n if (blockStart === 0 && blockEnd === allProps.length)\n return [allProps[0].start, allProps[allProps.length - 1].end];\n if (blockStart === 0) return [allProps[0].start, allProps[blockEnd].start];\n return [allProps[blockStart - 1].end, allProps[blockEnd - 1].end];\n}\n\n// fallow-ignore-next-line complexity\nfunction readLastWaypointXY(mpVal: Node): { x: number | null; y: number | null } {\n if (mpVal?.type !== \"ObjectExpression\") return { x: null, y: null };\n const pathProp = findPropertyNode(mpVal, \"path\");\n if (pathProp?.value?.type !== \"ArrayExpression\") return { x: null, y: null };\n const elems: Node[] = pathProp.value.elements ?? [];\n const last = elems[elems.length - 1];\n if (last?.type !== \"ObjectExpression\") return { x: null, y: null };\n return {\n x: readNumericLiteralNode(findPropertyNode(last, \"x\")?.value),\n y: readNumericLiteralNode(findPropertyNode(last, \"y\")?.value),\n };\n}\n\n/**\n * Read a numeric value node — a plain numeric literal or a unary-minus negative\n * literal (e.g. `-120`). Returns null for anything non-numeric. Without the\n * UnaryExpression branch, negative waypoint coords (parsed as a UnaryExpression\n * with no `.value`) would be lost when disabling an arc path.\n */\nfunction readNumericLiteralNode(v: Node): number | null {\n if (LITERAL_NODE_TYPES.has(v?.type) && typeof v.value === \"number\") return v.value;\n if (\n v?.type === \"UnaryExpression\" &&\n v.operator === \"-\" &&\n typeof v.argument?.value === \"number\"\n ) {\n return -v.argument.value;\n }\n return null;\n}\n\nfunction disableArcPath(ms: MagicString, call: TweenCallInfo): boolean {\n const mpProp = findPropertyNode(call.varsArg, \"motionPath\");\n if (!mpProp) return false;\n const { x, y } = readLastWaypointXY(mpProp.value);\n if (x === null && y === null) {\n const allProps = (call.varsArg.properties ?? []).filter(isObjectProperty);\n removeProp(ms, mpProp, allProps);\n return true;\n }\n // Overwrite the entire motionPath property with the recovered x/y pair — avoids\n // the appendLeft+remove range-boundary issue in MagicString.\n const parts: string[] = [];\n if (x !== null) parts.push(`x: ${x}`);\n if (y !== null) parts.push(`y: ${y}`);\n ms.overwrite(mpProp.start, mpProp.end, parts.join(\", \"));\n return true;\n}\n\nfunction stripXYFromKeyframes(ms: MagicString, kfPropNode: Node): void {\n if (kfPropNode?.value?.type !== \"ObjectExpression\") return;\n const xyKeys = new Set([\"x\", \"y\"]);\n for (const pctProp of (kfPropNode.value.properties ?? []).filter(isObjectProperty)) {\n const k = propKeyName(pctProp);\n if (typeof k === \"string\" && k.endsWith(\"%\") && pctProp.value?.type === \"ObjectExpression\") {\n removePropsByKey(ms, pctProp.value, xyKeys);\n }\n }\n}\n\nfunction enableArcPath(\n ms: MagicString,\n call: TweenCallInfo,\n animation: GsapAnimation,\n config: ArcPathConfig,\n): boolean {\n const waypoints = extractArcWaypoints(animation);\n if (waypoints.length < 2) return false;\n const segments: ArcPathSegment[] =\n config.segments.length === waypoints.length - 1\n ? config.segments\n : Array.from({ length: waypoints.length - 1 }, () => ({ curviness: 1 }));\n const motionPathCode = buildMotionPathObjectCode({\n waypoints,\n segments,\n autoRotate: config.autoRotate,\n });\n const vars = call.varsArg;\n if (vars?.type !== \"ObjectExpression\") return false;\n // Insert motionPath right after the opening `{` (appendRight at start+1) so the\n // insertion point can never coincide with the end boundary of the x/y removal\n // range. upsertProp would appendLeft at `end - 1`, which collides with a\n // remove-range that ends at the same offset when x/y are the only props —\n // MagicString then discards the append and the output loses everything.\n const editable = (vars.properties ?? []).filter(isObjectProperty);\n const survivesRemoval = editable.some((p: Node) => {\n const k = propKeyName(p);\n return k !== \"x\" && k !== \"y\";\n });\n const sep = survivesRemoval ? \", \" : \"\";\n ms.appendRight(vars.start + 1, ` motionPath: ${motionPathCode}${sep}`);\n stripXYFromKeyframes(ms, findPropertyNode(call.varsArg, \"keyframes\"));\n removePropsByKey(ms, call.varsArg, new Set([\"x\", \"y\"]));\n return true;\n}\n\nexport function setArcPathInScript(\n script: string,\n animationId: string,\n config: ArcPathConfig,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const ms = new MagicString(script);\n const handled = config.enabled\n ? enableArcPath(ms, target.call, target.animation, config)\n : disableArcPath(ms, target.call);\n return handled ? ms.toString() : script;\n}\n\nexport function updateArcSegmentInScript(\n script: string,\n animationId: string,\n segmentIndex: number,\n update: Partial<ArcPathSegment>,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const { call, animation } = target;\n if (!animation.arcPath?.enabled) return script;\n\n const segments = [...animation.arcPath.segments];\n const existingSeg = segments[segmentIndex];\n if (segmentIndex < 0 || segmentIndex >= segments.length || !existingSeg) return script;\n\n segments[segmentIndex] = { ...existingSeg, ...update };\n\n const waypoints = extractArcWaypoints(animation);\n if (waypoints.length < 2) return script;\n\n const motionPathCode = buildMotionPathObjectCode({\n waypoints,\n segments,\n autoRotate: animation.arcPath.autoRotate,\n });\n\n const mpProp = findPropertyNode(call.varsArg, \"motionPath\");\n if (!mpProp) return script;\n\n const ms = new MagicString(script);\n ms.overwrite(mpProp.value.start, mpProp.value.end, motionPathCode);\n return ms.toString();\n}\n\nexport function removeArcPathFromScript(script: string, animationId: string): string {\n return setArcPathInScript(script, animationId, {\n enabled: false,\n autoRotate: false,\n segments: [],\n });\n}\n\n// ── splitAnimationsInScript helpers ──────────────────────────────────────────\n\n/** Overwrite the selector (first arg) of a tween call. */\nfunction updateAnimationSelectorInScript(\n script: string,\n animationId: string,\n newSelector: string,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n const selectorArg = target.call.node.arguments?.[0];\n if (!selectorArg) return script;\n const ms = new MagicString(script);\n ms.overwrite(selectorArg.start, selectorArg.end, JSON.stringify(newSelector));\n return ms.toString();\n}\n\n/**\n * Insert a `tl.set()` call immediately after the timeline declaration\n * (before existing tweens) to establish inherited state on a new element.\n */\nfunction insertInheritedStateSetInScript(\n script: string,\n selector: string,\n position: number,\n properties: Record<string, number | string>,\n): string {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const props = Object.entries(properties)\n .map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`)\n .join(\", \");\n const code = `${parsed.timelineVar}.set(${JSON.stringify(selector)}, { ${props} }, ${position});`;\n const ms = new MagicString(script);\n const tlDecl = findTimelineDeclarationStatement(parsed.ast, parsed.timelineVar);\n const firstLocated = parsed.located[0];\n if (tlDecl) {\n ms.appendLeft(tlDecl.end, \"\\n\" + code);\n } else if (firstLocated) {\n const firstCall = firstLocated.call;\n const exprStmt = findEnclosingExpressionStatement(firstCall.ancestors);\n const insertAt = exprStmt?.start ?? firstCall.node.start;\n ms.prependLeft(insertAt, code + \"\\n\");\n } else {\n ms.append(\"\\n\" + code);\n }\n return ms.toString();\n}\n\n/**\n * Compute, in forward (timeline) order, the inherited-props baseline available\n * BEFORE each matching tween, plus the final cumulative state at the split point.\n * A tween contributes to later baselines when it ends at/before the split (full\n * props or last keyframe), spans the split via keyframes (kfs at/before split),\n * or spans the split as a flat tween (its interpolated midpoint). Decoupled from\n * the reverse write loop so the spanning-tween midpoint reads earlier tweens.\n */\n// fallow-ignore-next-line complexity\nfunction computeForwardBaselines(\n matching: GsapAnimation[],\n splitTime: number,\n): { before: Array<Record<string, number | string>>; final: Record<string, number | string> } {\n const before: Array<Record<string, number | string>> = [];\n const acc: Record<string, number | string> = {};\n for (const anim of matching) {\n before.push({ ...acc });\n const pos = typeof anim.position === \"number\" ? anim.position : 0;\n const dur = anim.duration ?? 0;\n const animEnd = pos + dur;\n\n if (anim.keyframes) {\n const kfs = anim.keyframes.keyframes;\n if (pos >= splitTime) {\n // Moves wholly to the new element — contributes nothing to the baseline.\n } else if (animEnd > splitTime) {\n for (const kf of kfs) {\n const kfTime = pos + (kf.percentage / 100) * dur;\n if (kfTime <= splitTime) {\n for (const [k, v] of Object.entries(kf.properties)) acc[k] = v;\n }\n }\n } else {\n const lastKf = kfs[kfs.length - 1];\n if (lastKf) {\n for (const [k, v] of Object.entries(lastKf.properties)) acc[k] = v;\n }\n }\n continue;\n }\n\n if (animEnd <= splitTime) {\n for (const [k, v] of Object.entries(anim.properties)) acc[k] = v;\n continue;\n }\n\n if (pos >= splitTime) continue;\n\n // Flat tween spanning the split — its midpoint becomes the inherited value.\n const progress = dur > 0 ? (splitTime - pos) / dur : 0;\n const fromSource = anim.fromProperties ?? acc;\n for (const [k, v] of Object.entries(anim.properties)) {\n if (typeof v !== \"number\") {\n acc[k] = v;\n continue;\n }\n const fromVal = typeof fromSource[k] === \"number\" ? (fromSource[k] as number) : 0;\n acc[k] = fromVal + (v - fromVal) * progress;\n }\n }\n return { before, final: { ...acc } };\n}\n\n// Split one tween that straddles the split point: trim the original to the\n// first half (interpolated midpoint as its new end) and add a fromTo for the\n// second half on the new element. `fromSource` is the forward baseline.\nfunction buildSpanningSplit(\n result: string,\n anim: GsapAnimation,\n pos: number,\n dur: number,\n fromSource: Record<string, number | string>,\n ctx: { splitTime: number; newSelector: string; newElementStart: number },\n): string {\n const progress = dur > 0 ? (ctx.splitTime - pos) / dur : 0;\n const midProps: Record<string, number | string> = {};\n for (const [k, v] of Object.entries(anim.properties)) {\n if (typeof v !== \"number\") {\n midProps[k] = v;\n continue;\n }\n const fromVal = typeof fromSource[k] === \"number\" ? (fromSource[k] as number) : 0;\n midProps[k] = fromVal + (v - fromVal) * progress;\n }\n const trimmed = updateAnimationInScript(result, anim.id, {\n duration: ctx.splitTime - pos,\n properties: midProps,\n });\n return addAnimationToScript(trimmed, {\n targetSelector: ctx.newSelector,\n method: \"fromTo\",\n position: ctx.newElementStart,\n duration: pos + dur - ctx.splitTime,\n properties: { ...anim.properties },\n fromProperties: { ...midProps },\n ease: anim.ease,\n extras: anim.extras,\n }).script;\n}\n\ntype SplitCtx = {\n splitTime: number;\n originalSelector: string;\n newSelector: string;\n newElementStart: number;\n};\n\n// Decide what one matching tween does at the split point: move to the new\n// element (wholly after), stay (wholly before / keyframes before), get skipped\n// (keyframes spanning), or get interpolated in half (spanning). Returns the\n// updated script; pushes any skip reason into `skippedSelectors`.\nfunction applyTweenSplit(\n result: string,\n anim: GsapAnimation,\n baselineBefore: Record<string, number | string>,\n ctx: SplitCtx,\n skippedSelectors: string[],\n): string {\n const pos = typeof anim.position === \"number\" ? anim.position : 0;\n const dur = anim.duration ?? 0;\n const animEnd = pos + dur;\n\n if (anim.keyframes) {\n if (pos >= ctx.splitTime)\n return updateAnimationSelectorInScript(result, anim.id, ctx.newSelector);\n if (animEnd > ctx.splitTime) {\n skippedSelectors.push(`${ctx.originalSelector} (keyframes spanning split)`);\n }\n // Inherited-state for kf tweens is handled by computeForwardBaselines.\n return result;\n }\n // Wholly before the split — kept on the original element.\n if (animEnd <= ctx.splitTime) return result;\n // Wholly after — move to the new element.\n if (pos >= ctx.splitTime)\n return updateAnimationSelectorInScript(result, anim.id, ctx.newSelector);\n // Spans the split — interpolate the midpoint from the FORWARD baseline.\n const fromSource = anim.fromProperties ?? baselineBefore;\n return buildSpanningSplit(result, anim, pos, dur, fromSource, ctx);\n}\n\nexport function splitAnimationsInScript(\n script: string,\n opts: SplitAnimationsOptions,\n): SplitAnimationsResult {\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return { script, skippedSelectors: [] };\n\n const originalSelector = `#${opts.originalId}`;\n const newSelector = `#${opts.newId}`;\n\n const animations = parsed.located.map((l) => l.animation);\n const skippedSelectors: string[] = [];\n\n for (const a of animations) {\n if (a.targetSelector !== originalSelector && a.targetSelector.includes(opts.originalId)) {\n skippedSelectors.push(a.targetSelector);\n }\n }\n\n const matching = animations.filter((a) => a.targetSelector === originalSelector);\n if (matching.length === 0) return { script, skippedSelectors };\n\n let result = script;\n const newElementStart = opts.splitTime;\n\n // Forward pre-pass: compute the inherited-props baseline available BEFORE each\n // matching tween, in source/timeline order. The write loop below runs in\n // REVERSE (so updateAnimationSelectorInScript's selector edits can't shift the\n // count-based IDs of not-yet-processed tweens), but the spanning-tween midpoint\n // interpolation needs the baseline from EARLIER tweens — which a reverse\n // accumulator hasn't seen yet. Decoupling the two fixes the wrong midpoint.\n const { before: baselineBefore, final: finalInheritedProps } = computeForwardBaselines(\n matching,\n opts.splitTime,\n );\n\n // Reverse iteration: updateAnimationSelectorInScript mutates selectors which\n // can shift count-based ID suffixes for later animations.\n const ctx = { splitTime: opts.splitTime, originalSelector, newSelector, newElementStart };\n for (let i = matching.length - 1; i >= 0; i--) {\n const anim = matching[i];\n if (!anim) continue;\n result = applyTweenSplit(result, anim, baselineBefore[i] ?? {}, ctx, skippedSelectors);\n }\n\n if (Object.keys(finalInheritedProps).length > 0) {\n result = insertInheritedStateSetInScript(\n result,\n newSelector,\n newElementStart,\n finalInheritedProps,\n );\n }\n\n return { script: result, skippedSelectors };\n}\n\n// ── Unroll dynamic animations ────────────────────────────────────────────────\n\nfunction isLoopNode(node: Node): boolean {\n const t = node?.type;\n return (\n t === \"ForStatement\" ||\n t === \"ForInStatement\" ||\n t === \"ForOfStatement\" ||\n t === \"WhileStatement\"\n );\n}\n\nfunction isForEachStatement(node: Node): boolean {\n return (\n node?.type === \"ExpressionStatement\" &&\n node.expression?.type === \"CallExpression\" &&\n node.expression.callee?.property?.name === \"forEach\"\n );\n}\n\n/** The nearest enclosing loop / forEach AST node (not just its byte range). */\nfunction findEnclosingLoopNode(ancestors: Node[]): Node | null {\n for (let i = ancestors.length - 2; i >= 0; i--) {\n const node = ancestors[i];\n if (isLoopNode(node) || isForEachStatement(node)) return node;\n }\n return null;\n}\n\n/** Statements making up a loop's body block, or null when not a simple block. */\nfunction loopBodyStatements(loopNode: Node): Node[] | null {\n let body: Node;\n if (loopNode?.type === \"ExpressionStatement\") {\n // forEach(cb): body is the callback's block.\n const cb = loopNode.expression?.arguments?.[0];\n body = cb?.body;\n } else {\n body = loopNode?.body;\n }\n if (body?.type !== \"BlockStatement\") return null;\n return (body.body ?? []).filter((s: Node) => s?.type === \"ExpressionStatement\");\n}\n\n/** The loop's index identifier name (`for (let i …)`), used for per-iteration substitution. */\nfunction loopIndexVarName(loopNode: Node): string | null {\n if (loopNode?.type === \"ForStatement\") {\n const decl = loopNode.init?.declarations?.[0];\n return typeof decl?.id?.name === \"string\" ? decl.id.name : null;\n }\n return null;\n}\n\n/**\n * Rewrite one body statement's source for iteration `idx`: replace USES of the\n * loop index variable (AST Identifier nodes) with the literal index. AST-based,\n * not a text regex, so the index name appearing inside a string literal (e.g. a\n * selector \".row-i\") or as a non-computed member/key (`obj.i`, `{ i: … }`) is\n * left untouched — only real references to the variable are substituted.\n */\n// An identifier in \"binding position\" is a name, not a value reference: a\n// non-computed member property (`obj.i`) or object-literal key (`{ i: … }`).\n// Those must NOT be substituted with the iteration index.\nfunction isIndexBindingPosition(node: Node, parent: Node): boolean {\n if (parent?.type === \"MemberExpression\") return parent.property === node && !parent.computed;\n if (parent?.type === \"Property\" || parent?.type === \"ObjectProperty\") {\n return parent.key === node && !parent.computed;\n }\n return false;\n}\n\nfunction substituteLoopIndex(stmt: Node, indexVar: string, idx: number, script: string): string {\n const base = stmt.start as number;\n const src = script.slice(base, stmt.end as number);\n const ranges: Array<[number, number]> = [];\n acornWalk.ancestor(stmt, {\n Identifier(node: Node, _state: unknown, ancestors: Node[]) {\n if (node.name !== indexVar) return;\n if (isIndexBindingPosition(node, ancestors[ancestors.length - 2])) return;\n ranges.push([(node.start as number) - base, (node.end as number) - base]);\n },\n });\n if (ranges.length === 0) return src;\n ranges.sort((a, b) => b[0] - a[0]);\n let out = src;\n for (const [s, e] of ranges) out = out.slice(0, s) + String(idx) + out.slice(e);\n return out;\n}\n\nfunction buildUnrollReplacement(\n timelineVar: string,\n animation: GsapAnimation,\n elements: Array<{\n selector: string;\n keyframes: Array<{ percentage: number; properties: Record<string, number | string> }>;\n easeEach?: string;\n }>,\n): string {\n const duration = typeof animation.duration === \"number\" ? animation.duration : 8;\n const ease = typeof animation.ease === \"string\" ? animation.ease : \"none\";\n const pos = animation.position ?? 0;\n const posCode = typeof pos === \"number\" ? String(pos) : JSON.stringify(pos);\n const calls = elements.map((el) => {\n const sorted = [...el.keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfCode = buildKeyframeObjectCode(sorted, el.easeEach);\n return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${JSON.stringify(ease)} }, ${posCode});`;\n });\n return calls.join(\"\\n \");\n}\n\nexport type UnrollElement = {\n selector: string;\n keyframes: Array<{ percentage: number; properties: Record<string, number | string> }>;\n easeEach?: string;\n};\n\n/** Build one element's unrolled `tl.to(...)` call from the target animation. */\nfunction buildUnrollCallForElement(\n timelineVar: string,\n animation: GsapAnimation,\n el: UnrollElement,\n): string {\n const duration = typeof animation.duration === \"number\" ? animation.duration : 8;\n const ease = typeof animation.ease === \"string\" ? animation.ease : \"none\";\n const pos = animation.position ?? 0;\n const posCode = typeof pos === \"number\" ? String(pos) : JSON.stringify(pos);\n const sorted = [...el.keyframes].sort((a, b) => a.percentage - b.percentage);\n const kfCode = buildKeyframeObjectCode(sorted, el.easeEach);\n return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${JSON.stringify(ease)} }, ${posCode});`;\n}\n\n/** Sentinel: the unroll cannot safely reproduce the loop body — caller no-ops. */\nconst REFUSE_UNROLL = Symbol(\"refuse-unroll\");\n\n/** Every statement in a loop's body block (unfiltered), or [] when not a block. */\nfunction loopBodyRawStatements(loopNode: Node): Node[] {\n const body =\n loopNode?.type === \"ExpressionStatement\"\n ? loopNode.expression?.arguments?.[0]?.body\n : loopNode?.body;\n return body?.type === \"BlockStatement\" ? (body.body ?? []) : [];\n}\n\n/** A node that re-binds `indexVar`: a re-declaration or a function param. */\nfunction rebindsIndex(node: Node, indexVar: string): boolean {\n if (node.type === \"VariableDeclarator\") return node.id?.name === indexVar;\n if (\n node.type === \"FunctionExpression\" ||\n node.type === \"FunctionDeclaration\" ||\n node.type === \"ArrowFunctionExpression\"\n ) {\n return (node.params ?? []).some((p: Node) => p?.name === indexVar);\n }\n return false;\n}\n\n/** Object shorthand `{ i }` — substituting the value would yield invalid `{ 0 }`. */\nfunction isShorthandIndexUse(node: Node, indexVar: string): boolean {\n return (\n (node.type === \"Property\" || node.type === \"ObjectProperty\") &&\n node.shorthand === true &&\n propKeyName(node) === indexVar\n );\n}\n\n/**\n * A sibling statement can't be safely index-substituted when it re-binds the\n * loop index (shadowing — a nested `for (let i …)`, a callback param `i`) or\n * uses it in object shorthand (`{ i }`, which would splice to the invalid\n * `{ 0 }`). substituteLoopIndex has no scope analysis, so in these cases it\n * would emit broken or wrong code — the unroll must refuse instead.\n */\nfunction hasUnsafeLoopIndexUse(stmt: Node, indexVar: string): boolean {\n let unsafe = false;\n acornWalk.full(stmt, (node: Node) => {\n if (!unsafe && (isShorthandIndexUse(node, indexVar) || rebindsIndex(node, indexVar))) {\n unsafe = true;\n }\n });\n return unsafe;\n}\n\n/** How to handle the loop body's non-target siblings when unrolling. */\nfunction unrollSiblingStrategy(\n loopNode: Node,\n targetStmt: Node,\n stmts: Node[],\n indexVar: string | null,\n): \"blanket\" | \"refuse\" | \"preserve\" {\n const siblings = stmts.filter((s) => s !== targetStmt);\n // A sibling the filtered statement list doesn't model (non-ExpressionStatement)\n // would be silently lost by either path — refuse if any exists.\n const hasUnmodeledSibling = loopBodyRawStatements(loopNode).some(\n (s) => s !== targetStmt && !stmts.includes(s),\n );\n if (siblings.length === 0 && !hasUnmodeledSibling) return \"blanket\";\n if (hasUnmodeledSibling || !indexVar) return \"refuse\";\n return siblings.some((s) => hasUnsafeLoopIndexUse(s, indexVar)) ? \"refuse\" : \"preserve\";\n}\n\n/** Emit the per-iteration unrolled lines (target → static tl.to, siblings → index-substituted). */\nfunction emitUnrolledLines(\n stmts: Node[],\n targetStmt: Node,\n elements: UnrollElement[],\n timelineVar: string,\n animation: GsapAnimation,\n indexVar: string,\n script: string,\n): string {\n const lines: string[] = [];\n for (let idx = 0; idx < elements.length; idx++) {\n const el = elements[idx];\n if (!el) continue;\n for (const stmt of stmts) {\n lines.push(\n stmt === targetStmt\n ? buildUnrollCallForElement(timelineVar, animation, el)\n : substituteLoopIndex(stmt, indexVar, idx, script),\n );\n }\n }\n return lines.join(\"\\n \");\n}\n\n/**\n * Unroll the loop body, preserving every statement that is NOT the target tween.\n * For each iteration, emit each non-target statement with the loop index\n * substituted (e.g. `tl.set(items[i], …)` → `tl.set(items[0], …)`), and replace\n * the target tween statement with that element's static `tl.to()` call.\n *\n * Returns null when a blanket overwrite is lossless (no sibling statements), and\n * REFUSE_UNROLL when siblings exist but can't be safely reproduced — a non-`for`\n * loop (no numeric index to splice), a statement we don't model, or an unsafe\n * index use (shadowing / shorthand). Refusing no-ops the unroll, which is safe:\n * the dynamic loop keeps rendering correctly, just un-flattened.\n */\nfunction buildLoopUnrollPreserving(\n script: string,\n timelineVar: string,\n animation: GsapAnimation,\n elements: UnrollElement[],\n loopNode: Node,\n targetStmt: Node,\n): string | null | typeof REFUSE_UNROLL {\n const stmts = loopBodyStatements(loopNode);\n if (!stmts || !stmts.includes(targetStmt)) return null;\n const indexVar = loopIndexVarName(loopNode);\n const strategy = unrollSiblingStrategy(loopNode, targetStmt, stmts, indexVar);\n if (strategy === \"blanket\") return null;\n if (strategy === \"refuse\" || !indexVar) return REFUSE_UNROLL;\n return emitUnrolledLines(stmts, targetStmt, elements, timelineVar, animation, indexVar, script);\n}\n\n/**\n * Replace a dynamic loop that generates multiple tween calls with individual\n * static `tl.to()` calls — one per element. Finds the loop containing the\n * animation and replaces the loop with unrolled static calls, preserving every\n * non-target statement in the loop body per iteration.\n */\nexport function unrollDynamicAnimations(\n script: string,\n animationId: string,\n elements: UnrollElement[],\n): string {\n // An empty element list has no unrolled form — replacing the loop/statement\n // with zero calls would silently delete the animation. No-op instead.\n if (elements.length === 0) return script;\n const parsed = parseGsapScriptAcornForWrite(script);\n if (!parsed) return script;\n const target = parsed.located.find((l) => l.id === animationId);\n if (!target) return script;\n\n const ms = new MagicString(script);\n const loopNode = findEnclosingLoopNode(target.call.ancestors);\n if (loopNode) {\n const targetStmt = findEnclosingExpressionStatement(target.call.ancestors);\n const preserving = targetStmt\n ? buildLoopUnrollPreserving(\n script,\n parsed.timelineVar,\n target.animation,\n elements,\n loopNode,\n targetStmt,\n )\n : null;\n // Siblings exist but can't be safely reproduced — leave the loop untouched\n // rather than drop or corrupt them. The op no-ops (before === after).\n if (preserving === REFUSE_UNROLL) return script;\n // Fall back to the simple whole-body replacement when the body isn't a plain\n // block of statements we can preserve.\n const replacement =\n preserving ?? buildUnrollReplacement(parsed.timelineVar, target.animation, elements);\n ms.overwrite(loopNode.start as number, loopNode.end as number, replacement);\n } else {\n const stmt = findEnclosingExpressionStatement(target.call.ancestors);\n if (!stmt) return script;\n const replacement = buildUnrollReplacement(parsed.timelineVar, target.animation, elements);\n ms.overwrite(stmt.start as number, stmt.end as number, replacement);\n }\n return ms.toString();\n}\n","/**\n * GSAP property and ease constants.\n *\n * Extracted into a standalone module so browser code can import them\n * without pulling in gsapParser (which depends on recast / @babel/parser).\n */\n\nexport const SUPPORTED_PROPS = [\n // 2D Transforms\n \"x\",\n \"y\",\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"rotation\",\n \"skewX\",\n \"skewY\",\n // 3D Transforms\n \"z\",\n \"rotationX\",\n \"rotationY\",\n \"rotationZ\",\n \"perspective\",\n \"transformPerspective\",\n \"transformOrigin\",\n // Visibility\n \"opacity\",\n \"visibility\",\n \"autoAlpha\",\n // Dimensions\n \"width\",\n \"height\",\n // Colors\n \"color\",\n \"backgroundColor\",\n \"borderColor\",\n // Box model\n \"borderRadius\",\n // Typography\n \"fontSize\",\n \"letterSpacing\",\n // Filter & Clipping\n \"filter\",\n \"clipPath\",\n // DOM content (number counters, text roll-ups)\n \"innerText\",\n];\n\n// ── Property Groups ─────────────────────────────────────────────────────────\n// Each group maps to an independent GSAP tween so editing one property\n// (e.g. drag → x/y) never contaminates another (e.g. scale, rotation).\n\nexport type PropertyGroupName = \"position\" | \"scale\" | \"size\" | \"rotation\" | \"visual\" | \"other\";\n\nexport const PROPERTY_GROUPS: Record<PropertyGroupName, ReadonlySet<string>> = {\n position: new Set([\"x\", \"y\", \"xPercent\", \"yPercent\"]),\n scale: new Set([\"scale\", \"scaleX\", \"scaleY\"]),\n size: new Set([\"width\", \"height\"]),\n rotation: new Set([\"rotation\", \"skewX\", \"skewY\"]),\n visual: new Set([\"opacity\", \"autoAlpha\"]),\n other: new Set<string>(),\n};\n\nconst PROP_TO_GROUP = new Map<string, PropertyGroupName>();\nfor (const [group, props] of Object.entries(PROPERTY_GROUPS) as [\n PropertyGroupName,\n ReadonlySet<string>,\n][]) {\n for (const p of props) PROP_TO_GROUP.set(p, group);\n}\n\nexport function classifyPropertyGroup(prop: string): PropertyGroupName {\n return PROP_TO_GROUP.get(prop) ?? \"other\";\n}\n\nexport function classifyTweenPropertyGroup(\n properties: Record<string, unknown>,\n): PropertyGroupName | undefined {\n const groups = new Set<PropertyGroupName>();\n for (const key of Object.keys(properties)) {\n // transformOrigin is a modifier; `_auto` is Studio's internal endpoint marker;\n // `data` is GSAP-reserved (carries the Studio hold-set tag). None is an animated\n // property, so none should affect the group.\n if (key === \"transformOrigin\" || key === \"_auto\" || key === \"data\") continue;\n const g = classifyPropertyGroup(key);\n groups.add(g);\n }\n if (groups.size === 1) return groups.values().next().value;\n return undefined;\n}\n\nexport const SUPPORTED_EASES = [\n \"none\",\n \"power1.in\",\n \"power1.out\",\n \"power1.inOut\",\n \"power2.in\",\n \"power2.out\",\n \"power2.inOut\",\n \"power3.in\",\n \"power3.out\",\n \"power3.inOut\",\n \"power4.in\",\n \"power4.out\",\n \"power4.inOut\",\n \"back.in\",\n \"back.out\",\n \"back.inOut\",\n \"elastic.in\",\n \"elastic.out\",\n \"elastic.inOut\",\n \"bounce.in\",\n \"bounce.out\",\n \"bounce.inOut\",\n \"expo.in\",\n \"expo.out\",\n \"expo.inOut\",\n \"spring-gentle\",\n \"spring-bouncy\",\n \"spring-stiff\",\n \"spring-wobbly\",\n \"spring-heavy\",\n \"steps(1)\",\n];\n","/**\n * Recast-free GSAP helpers: serialization, keyframe<->animation conversion,\n * validation, and shared types.\n *\n * This module MUST NOT import recast / @babel/parser. It is part of the\n * isomorphic core layer that the barrel and browser code depend on. AST\n * parsing of GSAP source lives in the Node-only `./gsapParser` module.\n */\nimport type { Keyframe, KeyframeProperties, ValidationResult } from \"./types.js\";\nimport type { PropertyGroupName } from \"./gsapConstants\";\n\nexport type GsapMethod = \"set\" | \"to\" | \"from\" | \"fromTo\";\n\n/** How a tween was constructed in source — drives display classification and editability. */\nexport type GsapProvenanceKind = \"literal\" | \"helper\" | \"loop\" | \"runtime-dynamic\";\n\n/**\n * Origin of a parsed tween. `literal` tweens map 1:1 to a source call and edit\n * directly; `helper`/`loop` tweens are expanded from a reused construct (unroll\n * to edit); `runtime-dynamic` tweens come from live introspection (override to\n * edit). Absent provenance is treated as `literal`.\n */\nexport interface GsapProvenance {\n kind: GsapProvenanceKind;\n /** Helper function name (kind === \"helper\"). */\n fn?: string;\n /** 1-based ordinal of the originating call site / loop construct in source order. */\n callSite?: number;\n /** 0-based iteration index (kind === \"loop\"). */\n iteration?: number;\n /** Source offset [start, end] of the originating call/loop, when known. */\n sourceRange?: [number, number];\n}\n\n/** How a tween's keyframes can be edited, derived from its provenance. */\nexport type KeyframeEditability = \"direct\" | \"unroll\" | \"source\";\n\n/**\n * Map provenance to an editing strategy:\n * - `direct` — literal tween, maps 1:1 to source; edit in place.\n * - `unroll` — helper/loop expansion; unroll to literal tweens, then edit.\n * - `source` — runtime-dynamic value; not statically editable, edit the code.\n */\nexport function editabilityForProvenance(provenance?: GsapProvenance): KeyframeEditability {\n if (!provenance || provenance.kind === \"literal\") return \"direct\";\n if (provenance.kind === \"runtime-dynamic\") return \"source\";\n return \"unroll\";\n}\n\nexport interface GsapAnimation {\n id: string;\n targetSelector: string;\n method: GsapMethod;\n position: number | string;\n properties: Record<string, number | string>;\n fromProperties?: Record<string, number | string>;\n duration?: number;\n ease?: string;\n /** Non-editable GSAP config (stagger, yoyo, repeat, etc.) preserved for round-trips. */\n extras?: Record<string, unknown>;\n /** Native GSAP keyframes data — present when the tween uses keyframes: { ... }. */\n keyframes?: GsapKeyframesData;\n /** Arc motion path config — present when the tween uses motionPath for curved position interpolation. */\n arcPath?: ArcPathConfig;\n /** True when the tween has a `keyframes` property that couldn't be statically resolved (dynamic). */\n hasUnresolvedKeyframes?: boolean;\n /** True when the tween's target selector couldn't be statically resolved (dynamic). */\n hasUnresolvedSelector?: boolean;\n /** Absolute start time computed by walking the timeline chain (handles +=, -=, <, >, labels). */\n resolvedStart?: number;\n /** True when no position arg was authored — the tween is sequentially placed by GSAP. */\n implicitPosition?: boolean;\n /** Which property group this tween belongs to (position, scale, size, rotation, visual, other).\n * Undefined for legacy mixed tweens that bundle multiple groups. */\n propertyGroup?: PropertyGroupName;\n /** True for a base `gsap.set(...)` (a static hold that runs immediately, OFF the\n * timeline) rather than `tl.set(...)`. Carries no timeline position and shows no\n * keyframe marker — used to persist a static value (e.g. a 3D transform) without\n * introducing a 0% keyframe. */\n global?: boolean;\n /** How this tween was constructed in source. Absent ⇒ literal. */\n provenance?: GsapProvenance;\n}\n\nexport interface GsapPercentageKeyframe {\n percentage: number;\n properties: Record<string, number | string>;\n ease?: string;\n}\n\nexport type GsapKeyframeFormat = \"percentage\" | \"object-array\" | \"simple-array\";\n\nexport interface GsapKeyframesData {\n format: GsapKeyframeFormat;\n keyframes: GsapPercentageKeyframe[];\n ease?: string;\n easeEach?: string;\n}\n\nexport interface ArcPathSegment {\n curviness: number;\n cp1?: { x: number; y: number };\n cp2?: { x: number; y: number };\n}\n\nexport interface ArcPathConfig {\n enabled: boolean;\n autoRotate: boolean | number;\n segments: ArcPathSegment[];\n}\n\nexport interface MotionPathShape {\n arcPath: ArcPathConfig;\n waypoints: Array<{ x: number; y: number }>;\n}\n\n/**\n * Build arcPath segments + waypoints from resolved path coordinates. Shared by\n * the AST parser (coords from literal nodes) and the runtime scanner (coords\n * from a live `vars.motionPath`), so both produce identical arc config.\n */\nexport function buildArcPath(\n coords: Array<{ x: number; y: number }>,\n curviness: number,\n autoRotate: boolean | number,\n isCubic: boolean,\n): MotionPathShape | undefined {\n const first = coords[0];\n if (coords.length < 2 || !first) return undefined;\n const segments: ArcPathSegment[] = [];\n let waypoints: Array<{ x: number; y: number }>;\n if (isCubic && coords.length >= 4) {\n // coords are [anchor, cp1, cp2, anchor, cp1, cp2, anchor, ...].\n waypoints = [first];\n for (let i = 1; i + 2 < coords.length; i += 3) {\n const cp1 = coords[i];\n const cp2 = coords[i + 1];\n const anchor = coords[i + 2];\n if (!cp1 || !cp2 || !anchor) continue;\n waypoints.push(anchor);\n segments.push({ curviness, cp1, cp2 });\n }\n } else {\n waypoints = coords;\n for (let i = 0; i < waypoints.length - 1; i++) segments.push({ curviness });\n }\n return { arcPath: { enabled: true, autoRotate, segments }, waypoints };\n}\n\nexport interface ParsedGsap {\n animations: GsapAnimation[];\n timelineVar: string;\n preamble: string;\n postamble: string;\n multipleTimelines?: boolean;\n unsupportedTimelinePattern?: boolean;\n}\n\nexport { SUPPORTED_PROPS, SUPPORTED_EASES } from \"./gsapConstants\";\n\n// ── Split-animation types (used by gsapWriterAcorn) ─────────────────────────\n\nexport interface SplitAnimationsOptions {\n originalId: string;\n newId: string;\n splitTime: number;\n elementStart: number;\n elementDuration: number;\n}\n\nexport interface SplitAnimationsResult {\n script: string;\n /** Non-ID-selector animations that the engine cannot safely retarget. */\n skippedSelectors: string[];\n}\n\n// ── Serialization ───────────────────────────────────────────────────────────\n\nexport function serializeGsapAnimations(\n animations: GsapAnimation[],\n timelineVar = \"tl\",\n options?: { includeMediaSync?: boolean; preamble?: string; postamble?: string },\n): string {\n const sorted = [...animations].sort((a, b) => {\n const aNum =\n a.resolvedStart ?? (typeof a.position === \"number\" ? a.position : Number.MAX_SAFE_INTEGER);\n const bNum =\n b.resolvedStart ?? (typeof b.position === \"number\" ? b.position : Number.MAX_SAFE_INTEGER);\n return aNum - bNum;\n });\n // fallow-ignore-next-line complexity\n const lines = sorted.map((anim) => {\n const selector = `\"${anim.targetSelector}\"`;\n const props: Record<string, number | string> = { ...anim.properties };\n if (anim.duration !== undefined) props.duration = anim.duration;\n if (anim.ease) props.ease = anim.ease;\n let propsStr = serializeObject(props);\n if (anim.extras && Object.keys(anim.extras).length > 0) {\n const extrasStr = serializeExtras(anim.extras);\n if (Object.keys(props).length === 0) {\n propsStr = `{ ${extrasStr} }`;\n } else {\n // Insert extras before the closing brace\n propsStr = propsStr.slice(0, -2) + `, ${extrasStr} }`;\n }\n }\n const posStr = typeof anim.position === \"string\" ? `\"${anim.position}\"` : anim.position;\n switch (anim.method) {\n case \"set\":\n // A global set is a base `gsap.set` — off the timeline, no position arg.\n return anim.global\n ? ` gsap.set(${selector}, ${propsStr});`\n : ` ${timelineVar}.set(${selector}, ${propsStr}, ${posStr});`;\n case \"to\":\n return ` ${timelineVar}.to(${selector}, ${propsStr}, ${posStr});`;\n case \"from\":\n return ` ${timelineVar}.from(${selector}, ${propsStr}, ${posStr});`;\n case \"fromTo\": {\n const fromStr = serializeObject(anim.fromProperties || {});\n return ` ${timelineVar}.fromTo(${selector}, ${fromStr}, ${propsStr}, ${posStr});`;\n }\n }\n });\n\n let mediaSync = \"\";\n if (options?.includeMediaSync) {\n mediaSync = `\n ${timelineVar}.eventCallback(\"onUpdate\", function() {\n const time = ${timelineVar}.time();\n document.querySelectorAll(\"video[data-start], audio[data-start]\").forEach(function(media) {\n const start = parseFloat(media.dataset.start);\n const end = parseFloat(media.dataset.end) || Infinity;\n const mediaTime = time - start;\n if (time >= start && time < end) {\n if (Math.abs(media.currentTime - mediaTime) > 0.1) {\n media.currentTime = mediaTime;\n }\n if (media.paused && !${timelineVar}.paused()) {\n media.play().catch(function() {});\n }\n } else if (!media.paused) {\n media.pause();\n }\n });\n });`;\n }\n\n const preamble = options?.preamble || `const ${timelineVar} = gsap.timeline({ paused: true });`;\n const postamble = options?.postamble ? `\\n ${options.postamble}` : \"\";\n\n return `\n ${preamble}\n${lines.join(\"\\n\")}${mediaSync}${postamble}\n `;\n}\n\nexport function serializeValue(value: unknown): string {\n if (typeof value === \"string\" && value.startsWith(\"__raw:\")) {\n return value.slice(6);\n }\n if (typeof value === \"string\") return JSON.stringify(value);\n return String(value);\n}\n\nexport function safeJsKey(key: string): string {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n}\n\nfunction serializeObject(obj: Record<string, number | string>): string {\n const entries = Object.entries(obj).map(([key, value]) => {\n return `${safeJsKey(key)}: ${serializeValue(value)}`;\n });\n return `{ ${entries.join(\", \")} }`;\n}\n\nfunction serializeExtras(extras: Record<string, unknown>): string {\n return Object.entries(extras)\n .map(([key, value]) => {\n return `${safeJsKey(key)}: ${serializeValue(value)}`;\n })\n .join(\", \");\n}\n\n// ── Element filtering ─────────────────────────────────────────────────────────\n\n/**\n * Filter animations to those targeting `#<elementId>` (id-only match). For the\n * studio panel's id-OR-selector matching, see `getAnimationsForElement` in\n * `useGsapTweenCache.ts` — distinct on purpose, hence the distinct name.\n */\nexport function getAnimationsForElementId(\n animations: GsapAnimation[],\n elementId: string,\n): GsapAnimation[] {\n const selector = `#${elementId}`;\n return animations.filter((a) => a.targetSelector === selector);\n}\n\n// ── Validation (regex-based, no AST needed) ─────────────────────────────────\n\nconst FORBIDDEN_GSAP_PATTERNS: Array<{ pattern: RegExp; message: string }> = [\n { pattern: /\\.call\\s*\\(/, message: \"call() method not allowed\" },\n { pattern: /\\.add\\s*\\(/, message: \"add() method not allowed\" },\n { pattern: /\\.addPause\\s*\\(/, message: \"addPause() method not allowed\" },\n { pattern: /gsap\\.registerEffect\\s*\\(/, message: \"registerEffect() not allowed\" },\n { pattern: /ScrollTrigger/, message: \"ScrollTrigger not allowed\" },\n { pattern: /onComplete\\s*:/, message: \"onComplete callback not allowed\" },\n { pattern: /onUpdate\\s*:/, message: \"onUpdate callback not allowed\" },\n { pattern: /onStart\\s*:/, message: \"onStart callback not allowed\" },\n { pattern: /onRepeat\\s*:/, message: \"onRepeat callback not allowed\" },\n { pattern: /onReverseComplete\\s*:/, message: \"onReverseComplete callback not allowed\" },\n { pattern: /repeat\\s*:\\s*-1/, message: \"Infinite repeat (repeat: -1) not allowed\" },\n { pattern: /Math\\.random\\s*\\(/, message: \"Random values (Math.random) not allowed\" },\n { pattern: /Date\\.now\\s*\\(/, message: \"Date-dependent values (Date.now) not allowed\" },\n { pattern: /new\\s+Date\\s*\\(/, message: \"Date constructor not allowed\" },\n { pattern: /setTimeout\\s*\\(/, message: \"setTimeout not allowed\" },\n { pattern: /setInterval\\s*\\(/, message: \"setInterval not allowed\" },\n { pattern: /requestAnimationFrame\\s*\\(/, message: \"requestAnimationFrame not allowed\" },\n];\n\nexport function validateCompositionGsap(script: string): ValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n for (const { pattern, message } of FORBIDDEN_GSAP_PATTERNS) {\n if (pattern.test(script)) errors.push(message);\n }\n if (/yoyo\\s*:\\s*true/.test(script)) {\n warnings.push(\"yoyo animations may behave unexpectedly when scrubbing\");\n }\n if (/stagger\\s*:/.test(script)) {\n warnings.push(\"stagger animations may not serialize correctly\");\n }\n return { valid: errors.length === 0, errors, warnings };\n}\n\n// ── Keyframe Conversion Helpers ─────────────────────────────────────────────\n\nexport function keyframesToGsapAnimations(\n elementId: string,\n keyframes: Keyframe[],\n elementStartTime: number,\n base?: { x?: number; y?: number; scale?: number },\n): GsapAnimation[] {\n const sorted = [...keyframes].sort((a, b) => a.time - b.time);\n const animations: GsapAnimation[] = [];\n const baseX = base?.x ?? 0;\n const baseY = base?.y ?? 0;\n const baseScale = base?.scale ?? 1;\n\n // fallow-ignore-next-line complexity\n sorted.forEach((kf, i) => {\n const absoluteTime = elementStartTime + kf.time;\n const isFirst = i === 0;\n const prevKf = i > 0 ? sorted[i - 1] : null;\n const duration = prevKf ? kf.time - prevKf.time : undefined;\n const position = prevKf ? elementStartTime + prevKf.time : absoluteTime;\n\n const properties: Record<string, number | string> = {};\n for (const [key, value] of Object.entries(kf.properties)) {\n if (typeof value !== \"number\") continue;\n if (key === \"x\") properties.x = baseX + value;\n else if (key === \"y\") properties.y = baseY + value;\n else if (key === \"scale\") properties.scale = baseScale * value;\n else properties[key] = value;\n }\n\n animations.push({\n id: `${elementId}-kf-${kf.id}`,\n targetSelector: `#${elementId}`,\n method: isFirst ? \"set\" : \"to\",\n position,\n properties,\n duration: isFirst ? undefined : duration,\n ease: kf.ease,\n });\n });\n\n return animations;\n}\n\nexport function gsapAnimationsToKeyframes(\n animations: GsapAnimation[],\n elementStartTime: number,\n options?: {\n baseX?: number;\n baseY?: number;\n baseScale?: number;\n clampTimeToZero?: boolean;\n skipBaseSet?: boolean;\n },\n): Keyframe[] {\n const validMethods: GsapMethod[] = [\"set\", \"to\", \"from\", \"fromTo\"];\n const baseX = options?.baseX ?? 0;\n const baseY = options?.baseY ?? 0;\n const baseScale = options?.baseScale ?? 1;\n const clampTimeToZero = options?.clampTimeToZero ?? true;\n const skipBaseSet = options?.skipBaseSet ?? false;\n const baseTimeEpsilon = 0.001;\n const baseValueEpsilon = 0.00001;\n\n return (\n animations\n .filter(\n (a): a is GsapAnimation & { position: number } =>\n validMethods.includes(a.method) && typeof a.position === \"number\",\n )\n // fallow-ignore-next-line complexity\n .map((a) => {\n const relativeTimeRaw = a.position - elementStartTime;\n const time = clampTimeToZero ? Math.max(0, relativeTimeRaw) : relativeTimeRaw;\n\n const properties: Partial<KeyframeProperties> = {};\n for (const [key, value] of Object.entries(a.properties)) {\n if (typeof value !== \"number\") continue;\n if (key === \"x\") properties.x = value - baseX;\n else if (key === \"y\") properties.y = value - baseY;\n else if (key === \"scale\") {\n properties.scale = baseScale !== 0 ? value / baseScale : value;\n } else {\n (properties as Record<string, number>)[key] = value;\n }\n }\n\n if (\n skipBaseSet &&\n a.method === \"set\" &&\n time < baseTimeEpsilon &&\n Object.values(properties).every(\n (v) => typeof v === \"number\" && Math.abs(v) < baseValueEpsilon,\n )\n ) {\n return null;\n }\n\n return {\n id: a.id.replace(/^.*-kf-/, \"\"),\n time,\n properties: properties as KeyframeProperties,\n ease: a.ease,\n };\n })\n .filter((kf): kf is NonNullable<typeof kf> => kf !== null)\n );\n}\n\n// ── Keyframe-conversion transforms (pure; shared by recast + acorn writers) ────\n\n/**\n * CSS identity values for properties whose \"rest\" state isn't 0 — used to\n * synthesize the missing endpoint when converting a flat tween to keyframes.\n */\nconst CSS_IDENTITY: Record<string, number> = {\n opacity: 1,\n autoAlpha: 1,\n scale: 1,\n scaleX: 1,\n scaleY: 1,\n};\n\nfunction cssIdentityValue(prop: string): number {\n return CSS_IDENTITY[prop] ?? 0;\n}\n\n/** Build the identity-endpoint map for a flat tween's properties. */\nfunction buildIdentityMap(props: Record<string, number | string>): Record<string, number | string> {\n const identity: Record<string, number | string> = {};\n for (const [key, val] of Object.entries(props)) {\n if (val != null) identity[key] = typeof val === \"number\" ? cssIdentityValue(key) : val;\n }\n return identity;\n}\n\n/**\n * Resolve the 0% (from) and 100% (to) property maps for a tween being\n * converted to percentage keyframes.\n *\n * @param resolvedFromValues — Despite the \"from\" in the name (historical), these\n * are runtime-captured DOM values that override the conversion endpoint:\n * - For to(): overrides fromProps (the 0% state / where the element is now).\n * - For from(): overrides toProps (the 100% state / where the element rests).\n * - For fromTo(): merges into toProps (the 100% endpoint the user is editing).\n */\nexport function resolveConversionProps(\n anim: GsapAnimation,\n resolvedFromValues?: Record<string, number | string>,\n): { fromProps: Record<string, number | string>; toProps: Record<string, number | string> } {\n if (anim.method === \"set\") {\n // A static hold becomes a keyframed `to` whose 0% and 100% both start at the\n // set's value — the visual is unchanged until the user edits a keyframe to\n // animate it. (The caller flips the call from `set` to `to` + adds a duration.)\n return { fromProps: { ...anim.properties }, toProps: { ...anim.properties } };\n }\n if (anim.method === \"to\") {\n const identity = buildIdentityMap(anim.properties);\n const fromProps = resolvedFromValues ? { ...identity, ...resolvedFromValues } : identity;\n return { fromProps, toProps: { ...anim.properties } };\n }\n if (anim.method === \"from\") {\n const identity = buildIdentityMap(anim.properties);\n const toProps = resolvedFromValues ? { ...identity, ...resolvedFromValues } : identity;\n return { fromProps: { ...anim.properties }, toProps };\n }\n // fromTo(fromVars, toVars): anim.fromProperties = fromVars (0% state),\n // anim.properties = toVars (100% state). resolvedFromValues contains the\n // current DOM position from a drag — it represents the NEW destination, so\n // it merges into toProps (the 100% endpoint the user is editing), NOT into\n // fromProps. This is intentional and not inverted.\n const toProps = resolvedFromValues\n ? { ...anim.properties, ...resolvedFromValues }\n : { ...anim.properties };\n return { fromProps: { ...(anim.fromProperties ?? {}) }, toProps };\n}\n\n// ── Arc path serialization helpers (shared by recast + acorn writers) ─────────\n\nfunction numericXY(props: Record<string, number | string>): { x: number; y: number } | null {\n const vx = props.x;\n const vy = props.y;\n return typeof vx === \"number\" && typeof vy === \"number\" ? { x: vx, y: vy } : null;\n}\n\nexport function extractArcWaypoints(anim: GsapAnimation): Array<{ x: number; y: number }> {\n const keyframeWps = (anim.keyframes?.keyframes ?? [])\n .map((kf) => numericXY(kf.properties))\n .filter((pt): pt is { x: number; y: number } => pt !== null);\n if (keyframeWps.length >= 2) return keyframeWps;\n const propX = anim.properties.x;\n const propY = anim.properties.y;\n if (typeof propX !== \"number\" && typeof propY !== \"number\") return keyframeWps;\n const destX = typeof propX === \"number\" ? propX : 0;\n const destY = typeof propY === \"number\" ? propY : 0;\n return [\n { x: 0, y: 0 },\n { x: destX, y: destY },\n ];\n}\n\nfunction autoRotateSuffix(autoRotate: boolean | number): string {\n if (autoRotate === true) return \", autoRotate: true\";\n if (typeof autoRotate === \"number\") return `, autoRotate: ${autoRotate}`;\n return \"\";\n}\n\nfunction cubicControlPoints(\n seg: ArcPathSegment,\n wp: { x: number; y: number },\n nextWp: { x: number; y: number },\n): string[] {\n if (seg.cp1 && seg.cp2) {\n return [`{x: ${seg.cp1.x}, y: ${seg.cp1.y}}`, `{x: ${seg.cp2.x}, y: ${seg.cp2.y}}`];\n }\n const dx = nextWp.x - wp.x;\n const dy = nextWp.y - wp.y;\n const c = seg.curviness ?? 1;\n return [\n `{x: ${wp.x + dx * 0.33}, y: ${wp.y + dy * 0.33 - c * Math.abs(dx) * 0.25}}`,\n `{x: ${wp.x + dx * 0.66}, y: ${wp.y + dy * 0.66 - c * Math.abs(dx) * 0.25}}`,\n ];\n}\n\nfunction buildCubicPathEntries(\n waypoints: Array<{ x: number; y: number }>,\n segments: ArcPathSegment[],\n): string[] {\n const first = waypoints[0];\n if (!first) return [];\n const entries = [`{x: ${first.x}, y: ${first.y}}`];\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const wp = waypoints[i];\n const nextWp = waypoints[i + 1];\n if (!seg || !wp || !nextWp) continue;\n entries.push(...cubicControlPoints(seg, wp, nextWp));\n entries.push(`{x: ${nextWp.x}, y: ${nextWp.y}}`);\n }\n return entries;\n}\n\nexport function buildMotionPathObjectCode(config: {\n waypoints: Array<{ x: number; y: number }>;\n segments: ArcPathSegment[];\n autoRotate: boolean | number;\n}): string {\n const { waypoints, segments, autoRotate } = config;\n const arSuffix = autoRotateSuffix(autoRotate);\n // GSAP's simple `path` array supports only ONE scalar `curviness` for the whole\n // path, so per-segment curviness can only be expressed in the cubic form (each\n // segment's curviness baked into its control points). Emit cubic when segments\n // carry explicit control points OR when their curviness values differ — the\n // simple branch would otherwise serialize only segments[0].curviness and drop\n // every other segment's curve.\n const hasExplicitCp = segments.some((s) => s.cp1 && s.cp2);\n const curvinessVaries = segments.some(\n (s) => (s.curviness ?? 1) !== (segments[0]?.curviness ?? 1),\n );\n if ((hasExplicitCp || curvinessVaries) && waypoints.length >= 2) {\n const pathStr = buildCubicPathEntries(waypoints, segments).join(\", \");\n return `{ path: [${pathStr}], type: \"cubic\"${arSuffix} }`;\n }\n const pathEntries = waypoints.map((wp) => `{x: ${wp.x}, y: ${wp.y}}`);\n const curviness = segments[0]?.curviness ?? 1;\n const curvPart = curviness !== 1 ? `, curviness: ${curviness}` : \"\";\n return `{ path: [${pathEntries.join(\", \")}]${curvPart}${arSuffix} }`;\n}\n","// fallow-ignore-file code-duplication\n/**\n * Browser-safe GSAP read path — acorn + acorn-walk.\n *\n * T6b oracle: produces identical ParsedGsap output to gsapParser.ts (recast).\n * Replaces recast as the shared implementation once T6d passes.\n *\n * Write path (T6c) will add magic-string splice once read parity is confirmed.\n * No Node globals, no fs, no require — safe to bundle for browser use.\n */\nimport * as acorn from \"acorn\";\nimport * as acornWalk from \"acorn-walk\";\nimport type {\n ArcPathConfig,\n GsapAnimation,\n GsapKeyframesData,\n GsapMethod,\n GsapPercentageKeyframe,\n ParsedGsap,\n} from \"./gsapSerialize.js\";\nimport { classifyTweenPropertyGroup } from \"./gsapConstants.js\";\nimport { buildArcPath } from \"./gsapSerialize.js\";\nimport { inlineComputedTimelines, readProvenance } from \"./gsapInline.js\";\n\n// Browser-safe re-exports so studio code can build arc config without importing\n// the recast parser (this acorn module is the browser-safe gsap subpath).\nexport { buildArcPath, editabilityForProvenance } from \"./gsapSerialize.js\";\nexport type {\n ArcPathConfig,\n ArcPathSegment,\n MotionPathShape,\n GsapProvenance,\n GsapProvenanceKind,\n KeyframeEditability,\n} from \"./gsapSerialize.js\";\n\nconst GSAP_METHODS = new Set<string>([\"set\", \"to\", \"from\", \"fromTo\"]);\nconst QUERY_METHODS = new Set([\"querySelector\", \"querySelectorAll\"]);\nconst ITERATION_METHODS = new Set([\"forEach\", \"map\"]);\nconst SCOPE_NODE_TYPES = new Set([\n \"Program\",\n \"FunctionDeclaration\",\n \"FunctionExpression\",\n \"ArrowFunctionExpression\",\n]);\n\n// ── Types ────────────────────────────────────────────────────────────────────\n\ntype ScopeBindings = ReadonlyMap<string, number | string | boolean>;\n/** Per-scope element bindings: scopeNode → (variable name → selector). */\ntype TargetBindings = Map<any, Map<string, string>>;\n\n// ── Value resolution ─────────────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nfunction resolveNode(\n node: any,\n scope: ReadonlyMap<string, number | string | boolean>,\n): number | string | boolean | undefined {\n if (!node) return undefined;\n if (node.type === \"NumericLiteral\" || (node.type === \"Literal\" && typeof node.value === \"number\"))\n return node.value;\n if (node.type === \"StringLiteral\" || (node.type === \"Literal\" && typeof node.value === \"string\"))\n return node.value;\n if (\n node.type === \"BooleanLiteral\" ||\n (node.type === \"Literal\" && typeof node.value === \"boolean\")\n )\n return node.value;\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument) {\n const val = resolveNode(node.argument, scope);\n return typeof val === \"number\" ? -val : undefined;\n }\n if (node.type === \"BinaryExpression\") {\n const left = resolveNode(node.left, scope);\n const right = resolveNode(node.right, scope);\n if (typeof left === \"number\" && typeof right === \"number\") {\n switch (node.operator) {\n case \"+\":\n return left + right;\n case \"-\":\n return left - right;\n case \"*\":\n return left * right;\n case \"/\":\n return right !== 0 ? left / right : undefined;\n }\n }\n if (typeof left === \"string\" && node.operator === \"+\") return left + String(right ?? \"\");\n if (typeof right === \"string\" && node.operator === \"+\") return String(left ?? \"\") + right;\n }\n if (node.type === \"Identifier\" && scope.has(node.name)) {\n return scope.get(node.name);\n }\n if (node.type === \"TemplateLiteral\" && node.expressions?.length === 0) {\n return node.quasis?.[0]?.value?.cooked ?? undefined;\n }\n return undefined;\n}\n\nfunction extractLiteralValue(node: any, scope: ScopeBindings): unknown {\n return resolveNode(node, scope);\n}\n\n// ── DOM selector resolution ───────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nfunction selectorFromQueryCall(node: any, scope: ScopeBindings): string | null {\n if (node?.type !== \"CallExpression\") return null;\n const callee = node.callee;\n if (callee?.type !== \"MemberExpression\" || callee.property?.type !== \"Identifier\") return null;\n const method = callee.property.name;\n const argValue = resolveNode(node.arguments?.[0], scope);\n if (typeof argValue !== \"string\" || argValue.length === 0) return null;\n if (QUERY_METHODS.has(method) || method === \"toArray\") return argValue;\n if (method === \"getElementById\") return `#${argValue}`;\n return null;\n}\n\n// ── Ancestor-based scope helpers (replaces NodePath walking) ──────────────────\n\n/**\n * Return the nearest ancestor node whose type is in SCOPE_NODE_TYPES.\n * `ancestors` is the acorn-walk ancestor array (root→current, current is last).\n */\nfunction enclosingScopeNodeFromAncestors(ancestors: any[]): any {\n for (let i = ancestors.length - 2; i >= 0; i--) {\n const node = ancestors[i];\n if (node && SCOPE_NODE_TYPES.has(node.type)) return node;\n }\n return null;\n}\n\n/** Scope chain innermost-first, derived from the acorn-walk ancestors array. */\nfunction scopeChainFromAncestors(ancestors: any[]): any[] {\n const chain: any[] = [];\n for (let i = ancestors.length - 1; i >= 0; i--) {\n const node = ancestors[i];\n if (node && SCOPE_NODE_TYPES.has(node.type)) chain.push(node);\n }\n return chain;\n}\n\n// ── Target bindings ───────────────────────────────────────────────────────────\n\nfunction addBinding(\n bindings: TargetBindings,\n scopeNode: any,\n name: string,\n selector: string,\n): void {\n let scoped = bindings.get(scopeNode);\n if (!scoped) {\n scoped = new Map();\n bindings.set(scopeNode, scoped);\n }\n if (!scoped.has(name)) scoped.set(name, selector);\n}\n\nfunction lookupBindingFromAncestors(\n name: string,\n ancestors: any[],\n bindings: TargetBindings,\n): string | null {\n for (const scopeNode of scopeChainFromAncestors(ancestors)) {\n const selector = bindings.get(scopeNode)?.get(name);\n if (selector !== undefined) return selector;\n }\n // Program-scope bindings are stored under null (enclosingScopeNodeFromAncestors\n // returns null when no function wrapper exists — the common case in HF scripts).\n return bindings.get(null)?.get(name) ?? null;\n}\n\nfunction isFunctionNode(node: any): boolean {\n return (\n node?.type === \"ArrowFunctionExpression\" ||\n node?.type === \"FunctionExpression\" ||\n node?.type === \"FunctionDeclaration\"\n );\n}\n\nfunction resolveCollectionSelector(\n node: any,\n ancestors: any[],\n scope: ScopeBindings,\n bindings: TargetBindings,\n): string | null {\n if (node?.type === \"Identifier\")\n return lookupBindingFromAncestors(node.name, ancestors, bindings);\n if (node?.type === \"CallExpression\") return selectorFromQueryCall(node, scope);\n return null;\n}\n\nfunction collectScopeBindings(ast: any): ScopeBindings {\n const bindings = new Map<string, number | string | boolean>();\n acornWalk.simple(ast, {\n VariableDeclarator(node: any) {\n const name = node.id?.name;\n const init = node.init;\n if (name && init) {\n const val = resolveNode(init, bindings);\n if (val !== undefined) bindings.set(name, val);\n }\n },\n });\n return bindings;\n}\n\n/**\n * Build a lexically-scoped index of element variables → selector.\n * Pass 1: direct DOM-lookup assignments.\n * Pass 2: forEach/map callback params whose collection's selector is known.\n */\nfunction collectTargetBindings(ast: any, scope: ScopeBindings): TargetBindings {\n const bindings: TargetBindings = new Map();\n\n acornWalk.ancestor(ast, {\n VariableDeclarator(node: any, _: unknown, ancestors: any[]) {\n const name = node.id?.name;\n const selector = selectorFromQueryCall(node.init, scope);\n if (name && selector !== null) {\n addBinding(bindings, enclosingScopeNodeFromAncestors(ancestors), name, selector);\n }\n },\n AssignmentExpression(node: any, _: unknown, ancestors: any[]) {\n const left = node.left;\n const selector = selectorFromQueryCall(node.right, scope);\n if (left?.type === \"Identifier\" && selector !== null) {\n addBinding(bindings, enclosingScopeNodeFromAncestors(ancestors), left.name, selector);\n }\n },\n } as any);\n\n // Pass 2: forEach/map callback params take the collection's selector.\n acornWalk.ancestor(ast, {\n // fallow-ignore-next-line complexity\n CallExpression(node: any, _: unknown, ancestors: any[]) {\n const callee = node.callee;\n if (\n callee?.type === \"MemberExpression\" &&\n callee.property?.type === \"Identifier\" &&\n ITERATION_METHODS.has(callee.property.name)\n ) {\n const collectionSelector = resolveCollectionSelector(\n callee.object,\n ancestors,\n scope,\n bindings,\n );\n const fn = node.arguments?.[0];\n const param = fn?.params?.[0];\n if (collectionSelector && param?.type === \"Identifier\" && isFunctionNode(fn)) {\n addBinding(bindings, fn, param.name, collectionSelector);\n }\n }\n },\n } as any);\n\n return bindings;\n}\n\n// fallow-ignore-next-line complexity\nfunction resolveTargetSelector(\n node: any,\n ancestors: any[],\n scope: ScopeBindings,\n bindings: TargetBindings,\n): string | null {\n if (!node) return null;\n if (node.type === \"StringLiteral\" || node.type === \"Literal\") {\n return typeof node.value === \"string\" ? node.value : null;\n }\n if (node.type === \"Identifier\") {\n return lookupBindingFromAncestors(node.name, ancestors, bindings);\n }\n if (node.type === \"CallExpression\") {\n return selectorFromQueryCall(node, scope);\n }\n if (node.type === \"ArrayExpression\") {\n const parts = node.elements\n .map((el: any) => resolveTargetSelector(el, ancestors, scope, bindings))\n .filter((s: string | null): s is string => typeof s === \"string\" && s.length > 0);\n return parts.length > 0 ? parts.join(\", \") : null;\n }\n if (node.type === \"MemberExpression\" && node.object?.type === \"Identifier\") {\n return lookupBindingFromAncestors(node.object.name, ancestors, bindings);\n }\n return null;\n}\n\n// ── ObjectExpression utilities ────────────────────────────────────────────────\n\nfunction isObjectProperty(prop: any): boolean {\n return prop?.type === \"ObjectProperty\" || prop?.type === \"Property\";\n}\n\nfunction propKeyName(prop: any): string | undefined {\n return prop?.key?.name ?? prop?.key?.value;\n}\n\nfunction findPropertyNode(varsArgNode: any, key: string): any | undefined {\n if (varsArgNode?.type !== \"ObjectExpression\") return undefined;\n for (const prop of varsArgNode.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n if (propKeyName(prop) === key) return prop.value;\n }\n return undefined;\n}\n\n/**\n * Extract raw source text for a property value — the offset-splice primitive.\n * Equivalent to `recast.print(node).code` for unmodified nodes.\n */\nfunction extractRawPropertySource(\n varsArgNode: any,\n key: string,\n source: string,\n): string | undefined {\n const node = findPropertyNode(varsArgNode, key);\n return node ? source.slice(node.start, node.end) : undefined;\n}\n\n// fallow-ignore-next-line complexity\nfunction objectExpressionToRecord(\n node: any,\n scope: ScopeBindings,\n source: string,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n if (node?.type !== \"ObjectExpression\") return result;\n for (const prop of node.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = prop.key?.name ?? prop.key?.value;\n if (!key) continue;\n const resolved = resolveNode(prop.value, scope);\n if (resolved !== undefined) {\n result[key] = resolved;\n } else {\n result[key] = `__raw:${source.slice(prop.value.start, prop.value.end)}`;\n }\n }\n return result;\n}\n\n// ── Timeline detection ────────────────────────────────────────────────────────\n\nfunction isGsapTimelineCall(node: any): boolean {\n return (\n node?.type === \"CallExpression\" &&\n node.callee?.type === \"MemberExpression\" &&\n node.callee.object?.name === \"gsap\" &&\n node.callee.property?.name === \"timeline\"\n );\n}\n\ninterface TimelineDefaults {\n ease?: string;\n duration?: number;\n}\n\n// How the timeline is referred to in source. `identifier` is the canonical\n// `const tl = …` form; `member` is the inline `window.__timelines[\"scene\"] = …`\n// form, where the timeline IS the member expression (no variable name).\ntype TimelineRef = { kind: \"identifier\"; name: string } | { kind: \"member\"; node: any };\n\ninterface TimelineDetection {\n /** Identifier name for the canonical form, else null (member or none). */\n timelineVar: string | null;\n /** Structural reference: identifier OR member expression. Null when none found. */\n ref: TimelineRef | null;\n timelineCount: number;\n defaults?: TimelineDefaults;\n}\n\n/** The static string key of a member access (`window.__timelines[\"scene\"]` → \"scene\"), else null. */\nfunction staticMemberKey(node: any): string | null {\n if (!node || node.type !== \"MemberExpression\") return null;\n if (node.computed) {\n const p = node.property;\n if (p?.type === \"Literal\" && typeof p.value === \"string\") return p.value;\n return null; // computed non-string-literal key → not statically resolvable\n }\n return node.property?.type === \"Identifier\" ? node.property.name : null;\n}\n\n/** True when a member expression refers to a statically-resolvable timeline slot. */\nfunction isStaticMemberRef(node: any): boolean {\n return node?.type === \"MemberExpression\" && staticMemberKey(node) !== null;\n}\n\n/** Structural equality of two member-access nodes (object chain + static key), quote-insensitive. */\nfunction sameMemberAccess(a: any, b: any): boolean {\n if (a?.type !== \"MemberExpression\" || b?.type !== \"MemberExpression\") return false;\n if (staticMemberKey(a) !== staticMemberKey(b) || staticMemberKey(a) === null) return false;\n const ao = a.object;\n const bo = b.object;\n if (ao?.type === \"Identifier\" && bo?.type === \"Identifier\") return ao.name === bo.name;\n if (ao?.type === \"MemberExpression\" && bo?.type === \"MemberExpression\")\n return sameMemberAccess(ao, bo);\n return false;\n}\n\n/** The source string a tween call is rooted at: identifier name, or the member source as written. */\nfunction timelineRootSource(ref: TimelineRef, script: string): string {\n return ref.kind === \"identifier\" ? ref.name : script.slice(ref.node.start, ref.node.end);\n}\n\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n// fallow-ignore-next-line complexity\nfunction extractTimelineDefaults(\n callNode: any,\n scope: ScopeBindings,\n): TimelineDefaults | undefined {\n const arg = callNode.arguments?.[0];\n if (!arg || arg.type !== \"ObjectExpression\") return undefined;\n const defaultsProp = arg.properties?.find(\n (p: any) => isObjectProperty(p) && propKeyName(p) === \"defaults\",\n );\n if (!defaultsProp?.value || defaultsProp.value.type !== \"ObjectExpression\") return undefined;\n const result: TimelineDefaults = {};\n for (const prop of defaultsProp.value.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n const val = resolveNode(prop.value, scope);\n if (key === \"ease\" && typeof val === \"string\") result.ease = val;\n if (key === \"duration\" && typeof val === \"number\") result.duration = val;\n }\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\nfunction findTimelineVar(ast: any, scope?: ScopeBindings): TimelineDetection {\n let timelineVar: string | null = null;\n let ref: TimelineRef | null = null;\n let timelineCount = 0;\n let defaults: TimelineDefaults | undefined;\n const emptyScope: ScopeBindings = scope ?? new Map();\n\n acornWalk.simple(ast, {\n VariableDeclarator(node: any) {\n if (isGsapTimelineCall(node.init)) {\n timelineCount += 1;\n if (!ref && node.id?.type === \"Identifier\") {\n timelineVar = node.id.name;\n ref = { kind: \"identifier\", name: node.id.name };\n defaults = extractTimelineDefaults(node.init, emptyScope);\n }\n }\n },\n AssignmentExpression(node: any) {\n if (isGsapTimelineCall(node.right)) {\n timelineCount += 1;\n if (!ref) {\n const left = node.left;\n if (left?.type === \"Identifier\") {\n timelineVar = left.name;\n ref = { kind: \"identifier\", name: left.name };\n defaults = extractTimelineDefaults(node.right, emptyScope);\n } else if (isStaticMemberRef(left)) {\n // Inline form: `window.__timelines[\"scene\"] = gsap.timeline(...)`.\n ref = { kind: \"member\", node: left };\n defaults = extractTimelineDefaults(node.right, emptyScope);\n }\n }\n }\n },\n });\n\n return { timelineVar, ref, timelineCount, defaults };\n}\n\n// ── Tween call collection ─────────────────────────────────────────────────────\n\n/** Keys stored on dedicated GsapAnimation fields (not in properties/extras). */\nconst BUILTIN_VAR_KEYS = new Set([\"duration\", \"ease\", \"delay\"]);\n/** Keys never preserved (callbacks / advanced patterns). */\nconst DROPPED_VAR_KEYS = new Set([\"onComplete\", \"onStart\", \"onUpdate\", \"onRepeat\"]);\n/** Keys that go in `extras` — non-editable GSAP config that must survive round-trips. */\nconst EXTRAS_KEYS = new Set([\n \"stagger\",\n \"yoyo\",\n \"repeat\",\n \"repeatDelay\",\n \"snap\",\n \"overwrite\",\n \"immediateRender\",\n]);\n\nexport interface TweenCallInfo {\n node: any;\n /** acorn-walk ancestor array at the call site (root→call, call is last). */\n ancestors: any[];\n method: GsapMethod;\n selector: string;\n varsArg: any;\n fromArg?: any;\n positionArg?: any;\n /** True for a base `gsap.set(...)` (off-timeline) rather than `tl.set(...)`. */\n global?: boolean;\n}\n\n/** True when the callee chain is rooted at the timeline reference (identifier or member). */\nfunction isTimelineRootedCall(callNode: any, ref: TimelineRef): boolean {\n let obj = callNode.callee?.object;\n while (obj?.type === \"CallExpression\") {\n obj = obj.callee?.object;\n }\n if (ref.kind === \"identifier\") return obj?.type === \"Identifier\" && obj.name === ref.name;\n return sameMemberAccess(obj, ref.node);\n}\n\n/**\n * Pre-order recursive walk for tween collection.\n *\n * acorn-walk is POST-order (visitor fires after children), which reverses\n * chained calls vs recast.types.visit (PRE-order). We need pre-order to\n * match the golden ordering where the outermost chained call appears first.\n */\nfunction findAllTweenCalls(\n ast: any,\n ref: TimelineRef,\n scope: ScopeBindings,\n targetBindings: TargetBindings,\n): TweenCallInfo[] {\n const results: TweenCallInfo[] = [];\n\n // fallow-ignore-next-line complexity\n function visit(node: any, ancestors: readonly any[]): void {\n if (!node || typeof node !== \"object\") return;\n const nodeAncestors = [...ancestors, node];\n\n // Fire BEFORE children (pre-order) so chained outer calls come first.\n if (node.type === \"CallExpression\") {\n const callee = node.callee;\n // A base `gsap.set(\"#sel\", props)` is an off-timeline static hold — parse it as\n // an editable global `set` so a static value round-trips and re-edits in place.\n // STRING-LITERAL selectors only: variable-target holds stay surrounding source.\n const gsapSetArg = node.arguments?.[0];\n const isGlobalSet =\n callee?.type === \"MemberExpression\" &&\n callee.object?.type === \"Identifier\" &&\n callee.object.name === \"gsap\" &&\n callee.property?.type === \"Identifier\" &&\n callee.property.name === \"set\" &&\n (gsapSetArg?.type === \"StringLiteral\" ||\n (gsapSetArg?.type === \"Literal\" && typeof gsapSetArg.value === \"string\"));\n if (\n callee?.type === \"MemberExpression\" &&\n callee.property?.type === \"Identifier\" &&\n (isTimelineRootedCall(node, ref) || isGlobalSet) &&\n GSAP_METHODS.has(callee.property.name)\n ) {\n const method = callee.property.name;\n const args = node.arguments;\n const selectorValue =\n args.length >= 1\n ? (resolveTargetSelector(args[0], nodeAncestors, scope, targetBindings) ??\n \"__unresolved__\")\n : \"__unresolved__\";\n\n if (method === \"fromTo\" && args.length >= 3) {\n results.push({\n node,\n ancestors: nodeAncestors,\n method: \"fromTo\",\n selector: selectorValue,\n fromArg: args[1],\n varsArg: args[2],\n positionArg: args[3],\n });\n } else if (method !== \"fromTo\" && args.length >= 2) {\n results.push({\n node,\n ancestors: nodeAncestors,\n method: method as GsapMethod,\n selector: selectorValue,\n varsArg: args[1],\n positionArg: args[2],\n ...(isGlobalSet ? { global: true } : {}),\n });\n }\n }\n }\n\n // Traverse children. Object.keys preserves insertion order, so callee\n // comes before arguments in acorn's CallExpression nodes.\n for (const key of Object.keys(node)) {\n if (key === \"type\" || key === \"start\" || key === \"end\" || key === \"loc\") continue;\n const child = (node as any)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n if (item && typeof item === \"object\" && item.type) visit(item, nodeAncestors);\n }\n } else if (child && typeof child === \"object\" && (child as any).type) {\n visit(child, nodeAncestors);\n }\n }\n }\n\n visit(ast, []);\n return results;\n}\n\n// ── Keyframes parsing ─────────────────────────────────────────────────────────\n\nconst PERCENTAGE_KEY_RE = /^(\\d+(?:\\.\\d+)?)%$/;\n\nfunction tryResolveStringProp(propValue: any, scope: ScopeBindings): string | undefined {\n const val = resolveNode(propValue, scope);\n return typeof val === \"string\" ? val : undefined;\n}\n\n// fallow-ignore-next-line complexity\nfunction parsePercentageKeyframes(\n node: any,\n scope: ScopeBindings,\n source: string,\n): GsapKeyframesData {\n const keyframes: GsapPercentageKeyframe[] = [];\n let ease: string | undefined;\n let easeEach: string | undefined;\n\n for (const prop of node.properties ?? []) {\n if (prop.type !== \"ObjectProperty\" && prop.type !== \"Property\") continue;\n const key = prop.key?.value ?? prop.key?.name;\n if (typeof key !== \"string\") continue;\n\n const pctMatch = PERCENTAGE_KEY_RE.exec(key);\n if (pctMatch) {\n const percentage = Number.parseFloat(pctMatch[1] ?? \"0\");\n const record = objectExpressionToRecord(prop.value, scope, source);\n const properties: Record<string, number | string> = {};\n let kfEase: string | undefined;\n for (const [k, v] of Object.entries(record)) {\n if (k === \"ease\" && typeof v === \"string\") {\n kfEase = v;\n } else if (typeof v === \"number\" || typeof v === \"string\") {\n properties[k] = v;\n }\n }\n keyframes.push({ percentage, properties, ...(kfEase ? { ease: kfEase } : {}) });\n } else if (key === \"ease\") {\n ease = tryResolveStringProp(prop.value, scope) ?? ease;\n } else if (key === \"easeEach\") {\n easeEach = tryResolveStringProp(prop.value, scope) ?? easeEach;\n }\n }\n\n keyframes.sort((a, b) => a.percentage - b.percentage);\n\n return {\n format: \"percentage\",\n keyframes,\n ...(ease ? { ease } : {}),\n ...(easeEach ? { easeEach } : {}),\n };\n}\n\n// fallow-ignore-next-line complexity\nfunction computeKeyframesTotalDuration(\n varsNode: any,\n scope: ScopeBindings,\n source: string,\n): number | undefined {\n const kfNode = (varsNode.properties ?? []).find(\n (p: any) => (p.key?.name ?? p.key?.value) === \"keyframes\",\n )?.value;\n if (!kfNode || kfNode.type !== \"ArrayExpression\") return undefined;\n let total = 0;\n for (const el of kfNode.elements ?? []) {\n if (!el || el.type !== \"ObjectExpression\") continue;\n const r = objectExpressionToRecord(el, scope, source);\n if (typeof r.duration === \"number\") total += r.duration;\n }\n return total > 0 ? total : undefined;\n}\n\n// fallow-ignore-next-line complexity\nfunction parseObjectArrayKeyframes(\n node: any,\n scope: ScopeBindings,\n source: string,\n): GsapKeyframesData {\n const elements = node.elements ?? [];\n const raw: Array<{\n properties: Record<string, number | string>;\n duration?: number;\n ease?: string;\n }> = [];\n\n for (const el of elements) {\n if (!el || el.type !== \"ObjectExpression\") continue;\n const record = objectExpressionToRecord(el, scope, source);\n const properties: Record<string, number | string> = {};\n let duration: number | undefined;\n let ease: string | undefined;\n for (const [k, v] of Object.entries(record)) {\n if (k === \"duration\" && typeof v === \"number\") {\n duration = v;\n } else if (k === \"ease\" && typeof v === \"string\") {\n ease = v;\n } else if (typeof v === \"number\" || typeof v === \"string\") {\n properties[k] = v;\n }\n }\n raw.push({ properties, duration, ease });\n }\n\n const totalDuration = raw.reduce((sum, r) => sum + (r.duration ?? 0), 0);\n const keyframes: GsapPercentageKeyframe[] = [];\n\n if (totalDuration > 0) {\n let cumulative = 0;\n for (const entry of raw) {\n cumulative += entry.duration ?? 0;\n const percentage = Math.round((cumulative / totalDuration) * 100);\n keyframes.push({\n percentage,\n properties: entry.properties,\n ...(entry.ease ? { ease: entry.ease } : {}),\n });\n }\n } else {\n for (let i = 0; i < raw.length; i++) {\n const entry = raw[i];\n if (!entry) continue;\n const percentage = raw.length > 1 ? Math.round((i / (raw.length - 1)) * 100) : 0;\n keyframes.push({\n percentage,\n properties: entry.properties,\n ...(entry.ease ? { ease: entry.ease } : {}),\n });\n }\n }\n\n return { format: \"object-array\", keyframes };\n}\n\n// fallow-ignore-next-line complexity\nfunction parseSimpleArrayKeyframes(node: any, scope: ScopeBindings): GsapKeyframesData {\n const arrayProps: Map<string, (number | string)[]> = new Map();\n let ease: string | undefined;\n let easeEach: string | undefined;\n\n for (const prop of node.properties ?? []) {\n if (prop.type !== \"ObjectProperty\" && prop.type !== \"Property\") continue;\n const key = prop.key?.name ?? prop.key?.value;\n if (typeof key !== \"string\") continue;\n\n if (prop.value?.type === \"ArrayExpression\") {\n const values: (number | string)[] = [];\n for (const el of prop.value.elements ?? []) {\n const val = resolveNode(el, scope);\n if (typeof val === \"number\" || typeof val === \"string\") {\n values.push(val);\n }\n }\n if (values.length > 0) arrayProps.set(key, values);\n } else if (key === \"ease\") {\n ease = tryResolveStringProp(prop.value, scope) ?? ease;\n } else if (key === \"easeEach\") {\n easeEach = tryResolveStringProp(prop.value, scope) ?? easeEach;\n }\n }\n\n const maxLen = Math.max(...[...arrayProps.values()].map((a) => a.length), 0);\n const keyframes: GsapPercentageKeyframe[] = [];\n\n for (let i = 0; i < maxLen; i++) {\n const percentage = maxLen > 1 ? Math.round((i / (maxLen - 1)) * 100) : 0;\n const properties: Record<string, number | string> = {};\n for (const [key, values] of arrayProps) {\n if (i < values.length) properties[key] = values[i] as number | string;\n }\n keyframes.push({ percentage, properties });\n }\n\n return {\n format: \"simple-array\",\n keyframes,\n ...(ease ? { ease } : {}),\n ...(easeEach ? { easeEach } : {}),\n };\n}\n\n// fallow-ignore-next-line complexity\nfunction parseKeyframesNode(\n node: any,\n scope: ScopeBindings,\n source: string,\n): GsapKeyframesData | undefined {\n if (!node) return undefined;\n\n if (node.type === \"ArrayExpression\") {\n return parseObjectArrayKeyframes(node, scope, source);\n }\n\n if (node.type !== \"ObjectExpression\") return undefined;\n\n const props = node.properties ?? [];\n let hasPercentageKey = false;\n let hasArrayValue = false;\n\n for (const prop of props) {\n if (prop.type !== \"ObjectProperty\" && prop.type !== \"Property\") continue;\n const key = prop.key?.value ?? prop.key?.name;\n if (typeof key === \"string\" && PERCENTAGE_KEY_RE.test(key)) {\n hasPercentageKey = true;\n break;\n }\n if (prop.value?.type === \"ArrayExpression\") {\n hasArrayValue = true;\n }\n }\n\n if (hasPercentageKey) return parsePercentageKeyframes(node, scope, source);\n if (hasArrayValue) return parseSimpleArrayKeyframes(node, scope);\n\n return undefined;\n}\n\n// ── MotionPath parsing ────────────────────────────────────────────────────────\n\ninterface MotionPathParseResult {\n arcPath: ArcPathConfig;\n waypoints: Array<{ x: number; y: number }>;\n}\n\n// fallow-ignore-next-line complexity\nfunction parseMotionPathNode(\n node: any,\n scope: ScopeBindings,\n source: string,\n): MotionPathParseResult | undefined {\n if (!node) return undefined;\n\n let pathNode: any;\n let autoRotate: boolean | number = false;\n let curviness = 1;\n let isCubic = false;\n\n if (node.type === \"ObjectExpression\") {\n for (const prop of node.properties ?? []) {\n if (!isObjectProperty(prop)) continue;\n const key = propKeyName(prop);\n if (key === \"path\") pathNode = prop.value;\n else if (key === \"autoRotate\") {\n const val = resolveNode(prop.value, scope);\n autoRotate = typeof val === \"number\" ? val : val === true;\n } else if (key === \"curviness\") {\n const val = resolveNode(prop.value, scope);\n if (typeof val === \"number\") curviness = val;\n } else if (key === \"type\") {\n const val = resolveNode(prop.value, scope);\n if (val === \"cubic\") isCubic = true;\n }\n }\n } else if (node.type === \"ArrayExpression\") {\n pathNode = node;\n }\n\n if (!pathNode || pathNode.type !== \"ArrayExpression\") return undefined;\n\n const elements = pathNode.elements ?? [];\n const coords: Array<{ x: number; y: number }> = [];\n for (const elem of elements) {\n if (!elem || elem.type !== \"ObjectExpression\") continue;\n const rec = objectExpressionToRecord(elem, scope, source);\n const x = typeof rec.x === \"number\" ? rec.x : undefined;\n const y = typeof rec.y === \"number\" ? rec.y : undefined;\n if (x !== undefined && y !== undefined) coords.push({ x, y });\n }\n\n return buildArcPath(coords, curviness, autoRotate, isCubic);\n}\n\n// ── Animation assembly ────────────────────────────────────────────────────────\n\n// fallow-ignore-next-line complexity\nfunction tweenCallToAnimation(\n call: TweenCallInfo,\n scope: ScopeBindings,\n source: string,\n): Omit<GsapAnimation, \"id\"> {\n const vars = objectExpressionToRecord(call.varsArg, scope, source);\n const properties: Record<string, number | string> = {};\n const extras: Record<string, unknown> = {};\n let keyframesData: GsapKeyframesData | undefined;\n let hasUnresolvedKeyframes = false;\n let motionPathResult: MotionPathParseResult | undefined;\n\n for (const [key, val] of Object.entries(vars)) {\n if (BUILTIN_VAR_KEYS.has(key)) continue;\n if (DROPPED_VAR_KEYS.has(key)) continue;\n\n if (key === \"keyframes\") {\n const kfNode = findPropertyNode(call.varsArg, \"keyframes\");\n keyframesData = parseKeyframesNode(kfNode, scope, source);\n if (!keyframesData && kfNode) hasUnresolvedKeyframes = true;\n continue;\n }\n\n if (key === \"motionPath\") {\n const mpNode = findPropertyNode(call.varsArg, \"motionPath\");\n motionPathResult = parseMotionPathNode(mpNode, scope, source);\n continue;\n }\n\n if (key === \"easeEach\") continue;\n\n if (EXTRAS_KEYS.has(key)) {\n const rawSource = extractRawPropertySource(call.varsArg, key, source);\n if (rawSource !== undefined) {\n extras[key] = `__raw:${rawSource}`;\n } else if (val !== undefined) {\n extras[key] = val;\n }\n continue;\n }\n\n if (typeof val === \"number\" || typeof val === \"string\") {\n properties[key] = val;\n }\n }\n\n if (keyframesData && typeof vars.easeEach === \"string\") {\n keyframesData.easeEach = vars.easeEach as string;\n }\n\n if (motionPathResult) {\n const { waypoints } = motionPathResult;\n if (!keyframesData) {\n const kf: GsapPercentageKeyframe[] = waypoints.map((wp, i) => ({\n percentage: waypoints.length > 1 ? Math.round((i / (waypoints.length - 1)) * 100) : 0,\n properties: { x: wp.x, y: wp.y },\n }));\n keyframesData = { format: \"percentage\", keyframes: kf };\n } else {\n const kfs = keyframesData.keyframes;\n if (kfs.length === waypoints.length) {\n for (let i = 0; i < kfs.length; i++) {\n const kf = kfs[i];\n const wp = waypoints[i];\n if (kf && wp) {\n kf.properties.x = wp.x;\n kf.properties.y = wp.y;\n }\n }\n }\n }\n }\n\n let fromProperties: Record<string, number | string> | undefined;\n if (call.method === \"fromTo\" && call.fromArg) {\n fromProperties = {};\n const fromVars = objectExpressionToRecord(call.fromArg, scope, source);\n for (const [key, val] of Object.entries(fromVars)) {\n if (typeof val === \"number\" || typeof val === \"string\") {\n fromProperties[key] = val;\n }\n }\n }\n\n const hasPositionArg = !!call.positionArg;\n const posVal = hasPositionArg ? extractLiteralValue(call.positionArg, scope) : 0;\n const position: number | string =\n typeof posVal === \"number\" ? posVal : typeof posVal === \"string\" ? posVal : 0;\n let duration = typeof vars.duration === \"number\" ? vars.duration : undefined;\n const ease = typeof vars.ease === \"string\" ? vars.ease : undefined;\n\n if (duration === undefined && keyframesData) {\n duration = computeKeyframesTotalDuration(call.varsArg, scope, source);\n }\n\n const anim: Omit<GsapAnimation, \"id\"> = {\n targetSelector: call.selector,\n method: call.method,\n position,\n properties,\n fromProperties,\n duration,\n ease,\n };\n if (!hasPositionArg) anim.implicitPosition = true;\n let group = classifyTweenPropertyGroup(properties);\n if (!group && keyframesData) {\n const kfProps: Record<string, unknown> = {};\n for (const kf of keyframesData.keyframes) {\n for (const k of Object.keys(kf.properties)) kfProps[k] = true;\n }\n group = classifyTweenPropertyGroup(kfProps);\n }\n if (group) anim.propertyGroup = group;\n if (call.global) anim.global = true;\n if (Object.keys(extras).length > 0) anim.extras = extras;\n if (keyframesData) anim.keyframes = keyframesData;\n if (motionPathResult) anim.arcPath = motionPathResult.arcPath;\n if (hasUnresolvedKeyframes) anim.hasUnresolvedKeyframes = true;\n if (call.selector === \"__unresolved__\") anim.hasUnresolvedSelector = true;\n const provenance = readProvenance(call.node);\n if (provenance) anim.provenance = provenance;\n return anim;\n}\n\n// ── Timeline position resolution ─────────────────────────────────────────────\n\nconst GSAP_DEFAULT_DURATION = 0.5;\n\n// fallow-ignore-next-line complexity\nfunction resolvePositionString(pos: string, cursor: number, prevStart: number): number | null {\n const trimmed = pos.trim();\n if (trimmed === \"\") return cursor;\n if (trimmed.startsWith(\"+=\")) {\n const n = Number.parseFloat(trimmed.slice(2));\n return Number.isFinite(n) ? cursor + n : null;\n }\n if (trimmed.startsWith(\"-=\")) {\n const n = Number.parseFloat(trimmed.slice(2));\n return Number.isFinite(n) ? cursor - n : null;\n }\n if (trimmed === \"<\") return prevStart;\n if (trimmed === \">\") return cursor;\n if (trimmed.startsWith(\"<\")) {\n const n = Number.parseFloat(trimmed.slice(1));\n return Number.isFinite(n) ? prevStart + n : null;\n }\n if (trimmed.startsWith(\">\")) {\n const n = Number.parseFloat(trimmed.slice(1));\n return Number.isFinite(n) ? cursor + n : null;\n }\n const n = Number.parseFloat(trimmed);\n return Number.isFinite(n) ? n : null;\n}\n\nfunction applyTimelineDefaults(\n anims: Omit<GsapAnimation, \"id\">[],\n defaults?: TimelineDefaults,\n): void {\n if (!defaults) return;\n for (const anim of anims) {\n if (anim.method === \"set\") continue;\n if (anim.duration === undefined && defaults.duration !== undefined) {\n anim.duration = defaults.duration;\n }\n if (anim.ease === undefined && defaults.ease !== undefined) {\n anim.ease = defaults.ease;\n }\n }\n}\n\n// fallow-ignore-next-line complexity\nfunction resolveTimelinePositions(anims: Omit<GsapAnimation, \"id\">[]): void {\n let cursor = 0;\n let prevStart = 0;\n for (const anim of anims) {\n // A global `gsap.set(...)` is off-timeline — applied once at load, not\n // sequenced on the master timeline. It carries no position arg, so the\n // cursor fallback would otherwise hand it the comp-end time. Pin it to 0\n // (its load-time start) and don't advance the cursor/prevStart.\n if (anim.method === \"set\" && anim.global) {\n anim.resolvedStart = 0;\n continue;\n }\n const duration = anim.method === \"set\" ? 0 : (anim.duration ?? GSAP_DEFAULT_DURATION);\n let start: number | null;\n\n if (anim.implicitPosition) {\n start = cursor;\n } else if (typeof anim.position === \"number\") {\n start = anim.position;\n } else if (typeof anim.position === \"string\") {\n start = resolvePositionString(anim.position, cursor, prevStart);\n } else {\n start = cursor;\n }\n\n if (start != null) {\n anim.resolvedStart = Math.max(0, start);\n prevStart = anim.resolvedStart;\n cursor = Math.max(cursor, anim.resolvedStart + duration);\n }\n }\n}\n\nfunction compareByLoc(a: TweenCallInfo, b: TweenCallInfo): number {\n const aLoc = a.node.callee?.property?.loc?.start;\n const bLoc = b.node.callee?.property?.loc?.start;\n if (!aLoc || !bLoc) return 0;\n return aLoc.line - bLoc.line || aLoc.column - bLoc.column;\n}\n\n// Inlined tweens carry a monotonic __hfOrder (clones share source loc, so loc\n// can't order them); they sort by that, after all literal (loc-ordered) tweens.\nfunction compareCallOrder(a: TweenCallInfo, b: TweenCallInfo): number {\n const ao = a.node.__hfOrder;\n const bo = b.node.__hfOrder;\n if (ao === undefined && bo === undefined) return compareByLoc(a, b);\n if (ao === undefined) return -1;\n if (bo === undefined) return 1;\n return ao - bo;\n}\n\nfunction sortBySourcePosition(calls: TweenCallInfo[]): void {\n calls.sort(compareCallOrder);\n}\n\n// ── Stable ID generation ──────────────────────────────────────────────────────\n\nfunction assignStableIds(anims: Omit<GsapAnimation, \"id\">[]): GsapAnimation[] {\n const counts = new Map<string, number>();\n return anims.map((anim) => {\n const posKey =\n typeof anim.position === \"number\"\n ? String(Math.round(anim.position * 1000))\n : String(anim.position);\n const groupSuffix = anim.propertyGroup ? `-${anim.propertyGroup}` : \"\";\n const base = `${anim.targetSelector}-${anim.method}-${posKey}${groupSuffix}`;\n const count = (counts.get(base) ?? 0) + 1;\n counts.set(base, count);\n const id = count === 1 ? base : `${base}-${count}`;\n return { ...anim, id };\n });\n}\n\n// ── Write-path internal parse ─────────────────────────────────────────────────\n\nexport interface ParsedGsapAcornForWrite {\n ast: any;\n timelineVar: string;\n hasTimeline: boolean;\n located: Array<{ id: string; call: TweenCallInfo; animation: GsapAnimation }>;\n}\n\n/**\n * Parse a GSAP script and return internal AST + call nodes for the write path.\n * Consumed by gsapWriterAcorn.ts (magic-string offset-splice).\n */\nexport function parseGsapScriptAcornForWrite(script: string): ParsedGsapAcornForWrite | null {\n try {\n const ast = acorn.parse(script, {\n ecmaVersion: \"latest\",\n sourceType: \"script\",\n locations: true,\n });\n const scope = collectScopeBindings(ast);\n const targetBindings = collectTargetBindings(ast, scope);\n const detection = findTimelineVar(ast, scope);\n const ref: TimelineRef = detection.ref ?? { kind: \"identifier\", name: \"tl\" };\n const timelineVar = timelineRootSource(ref, script);\n const calls = findAllTweenCalls(ast, ref, scope, targetBindings);\n sortBySourcePosition(calls);\n const rawAnims = calls.map((call) => tweenCallToAnimation(call, scope, script));\n applyTimelineDefaults(rawAnims, detection.defaults);\n resolveTimelinePositions(rawAnims);\n const animations = assignStableIds(rawAnims);\n const located = calls.map((call, i) => ({\n id: animations[i]!.id,\n call,\n animation: animations[i]!,\n }));\n return { ast, timelineVar, hasTimeline: detection.ref !== null, located };\n } catch {\n return null;\n }\n}\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Browser-safe equivalent of `parseGsapScript` (gsapParser.ts).\n * Uses acorn + acorn-walk instead of recast + @babel/parser.\n */\nexport function parseGsapScriptAcorn(script: string): ParsedGsap {\n try {\n const ast = acorn.parse(script, {\n ecmaVersion: \"latest\",\n sourceType: \"script\",\n locations: true,\n });\n const scope = collectScopeBindings(ast);\n const detection = findTimelineVar(ast, scope);\n const ref: TimelineRef = detection.ref ?? { kind: \"identifier\", name: \"tl\" };\n const timelineVar = timelineRootSource(ref, script);\n // Expand helper-built / bounded-loop timelines before analysis so their\n // tweens resolve at true positions (read path only — the write path keeps\n // original source nodes). Degrades to the un-inlined AST on any failure.\n // Only the identifier form uses the helper-built pattern; inline member\n // timelines have nothing to inline, so skip (avoids mis-rooting on the member).\n if (ref.kind === \"identifier\") {\n try {\n inlineComputedTimelines(ast, timelineVar, (node) => resolveNode(node, scope));\n } catch {\n /* fall back to current behavior */\n }\n }\n const targetBindings = collectTargetBindings(ast, scope);\n const calls = findAllTweenCalls(ast, ref, scope, targetBindings);\n sortBySourcePosition(calls);\n const rawAnims = calls.map((call) => tweenCallToAnimation(call, scope, script));\n applyTimelineDefaults(rawAnims, detection.defaults);\n resolveTimelinePositions(rawAnims);\n const animations = assignStableIds(rawAnims);\n\n // Preamble = source up to and including the timeline declaration/assignment.\n // Identifier keeps the original `const|let|var <name> = …` regex (byte-stable);\n // member matches `<member source> = …`.\n const declPattern =\n ref.kind === \"identifier\"\n ? `(?:const|let|var)\\\\s+${timelineVar}\\\\s*=\\\\s*gsap\\\\.timeline\\\\s*\\\\([^)]*\\\\)\\\\s*;?`\n : `${escapeRegExp(timelineVar)}\\\\s*=\\\\s*gsap\\\\.timeline\\\\s*\\\\([^)]*\\\\)\\\\s*;?`;\n const timelineMatch = script.match(new RegExp(`^[\\\\s\\\\S]*?${declPattern}`));\n const fallbackPreamble =\n ref.kind === \"identifier\"\n ? `const ${timelineVar} = gsap.timeline({ paused: true });`\n : `${timelineVar} = gsap.timeline({ paused: true });`;\n const preamble = timelineMatch?.[0] ?? fallbackPreamble;\n\n const lastCallIdx = script.lastIndexOf(`${timelineVar}.`);\n let postamble = \"\";\n if (lastCallIdx !== -1) {\n const afterLast = script.slice(lastCallIdx);\n const endOfCall = afterLast.indexOf(\";\");\n if (endOfCall !== -1) {\n postamble = script.slice(lastCallIdx + endOfCall + 1).trim();\n }\n }\n\n const result: ParsedGsap = { animations, timelineVar, preamble, postamble };\n if (detection.timelineCount > 1) result.multipleTimelines = true;\n if (detection.timelineCount > 0 && detection.ref === null)\n result.unsupportedTimelinePattern = true;\n return result;\n } catch {\n return { animations: [], timelineVar: \"tl\", preamble: \"\", postamble: \"\" };\n }\n}\n\n// ── Label extraction (WS-C) ──────────────────────────────────────────────────\n\nexport interface GsapLabelEntry {\n name: string;\n position: number;\n}\n\n/**\n * Extract all `tl.addLabel(\"name\", position)` calls from a GSAP script.\n *\n * Returns labels in source order. Position must be a numeric literal; labels\n * with non-numeric positions (e.g. label-relative offsets) are skipped.\n *\n * Pure — no side effects, no DOM, no Date.now.\n */\nexport function extractGsapLabels(script: string): GsapLabelEntry[] {\n try {\n const ast = acorn.parse(script, {\n ecmaVersion: \"latest\",\n sourceType: \"script\",\n locations: true,\n });\n const scope = collectScopeBindings(ast);\n const detection = findTimelineVar(ast, scope);\n const ref: TimelineRef = detection.ref ?? { kind: \"identifier\", name: \"tl\" };\n\n const labels: GsapLabelEntry[] = [];\n\n acornWalk.simple(ast, {\n // fallow-ignore-next-line complexity\n ExpressionStatement(node: any) {\n const expr = node.expression;\n if (!expr || expr.type !== \"CallExpression\") return;\n const callee = expr.callee;\n // Match <timeline>.addLabel(...) for identifier or member timeline refs.\n const objMatches =\n ref.kind === \"identifier\"\n ? callee.object?.type === \"Identifier\" && callee.object.name === ref.name\n : sameMemberAccess(callee.object, ref.node);\n if (\n callee?.type !== \"MemberExpression\" ||\n !objMatches ||\n callee.property?.name !== \"addLabel\"\n )\n return;\n const args = expr.arguments ?? [];\n const nameNode = args[0];\n const posNode = args[1];\n if (nameNode?.type !== \"Literal\" || typeof nameNode.value !== \"string\") return;\n if (!posNode) return;\n const pos = resolveNode(posNode, scope);\n if (typeof pos !== \"number\" || !Number.isFinite(pos)) return;\n labels.push({ name: nameNode.value, position: pos });\n },\n });\n\n return labels;\n } catch {\n // Labels are best-effort/supplementary, not load-bearing — a malformed or\n // unparseable script yields no labels rather than failing the caller.\n return [];\n }\n}\n","/**\n * Static evaluation for computed GSAP timelines (browser-safe, acorn/ESTree).\n *\n * The read parser resolves only literals and top-level consts, so timelines\n * built by a helper called N times or by a bounded loop collapse to position 0.\n * This module expands those constructs into a synthetic analysis AST: each\n * helper invocation and each loop iteration becomes its own concrete set of\n * `tl.*` calls, with parameters/loop-vars substituted by the call's argument\n * (or element/index) AST nodes — after which the existing parse pipeline\n * resolves positions and `motionPath` arcs unchanged.\n *\n * Substituted nodes keep their original source offsets, so downstream\n * source-slicing (raw extras, keyframes) stays correct. The substitution\n * primitives never mutate their input; `inlineComputedTimelines` rewrites the\n * Program body of the freshly-parsed AST it is handed (owned by the caller).\n */\nimport type { GsapProvenance } from \"./gsapSerialize.js\";\n\n// acorn ESTree nodes are structurally untyped; mirror gsapParserAcorn.ts.\ntype Node = any;\n\n/** Node keys that are metadata, not child AST to traverse/substitute. */\nconst SKIP_KEYS = new Set([\"type\", \"start\", \"end\", \"loc\", \"range\", \"__hfProvenance\", \"__hfOrder\"]);\n\nconst FUNCTION_TYPES = new Set([\n \"ArrowFunctionExpression\",\n \"FunctionExpression\",\n \"FunctionDeclaration\",\n]);\nconst GSAP_METHODS = new Set([\"set\", \"to\", \"from\", \"fromTo\"]);\n\n// Bounds on synthetic expansion (recursion + iteration runaway guards).\nconst MAX_DEPTH = 8;\nconst MAX_ITERS = 512;\n\nfunction isFunctionNode(node: Node): boolean {\n return !!node && FUNCTION_TYPES.has(node.type);\n}\n\nfunction isNode(x: Node): boolean {\n return !!x && typeof x === \"object\" && typeof x.type === \"string\";\n}\n\n/**\n * Apply `fn` to each child AST node, writing back its return value. Skips\n * metadata keys and key/member slots that must not be treated as values.\n * The one place array-vs-single child traversal lives, so walkers stay flat.\n */\nfunction transformChildren(node: Node, fn: (child: Node) => Node): void {\n for (const key of Object.keys(node)) {\n if (SKIP_KEYS.has(key) || isNonValueIdentifierSlot(node, key)) continue;\n const child = node[key];\n if (Array.isArray(child)) {\n for (let i = 0; i < child.length; i++) child[i] = fn(child[i]);\n } else {\n node[key] = fn(child);\n }\n }\n}\n\n/** Deep structural clone preserving `start`/`end`/`loc` (needed for source slicing). */\nexport function cloneNode<T extends Node>(node: T): T {\n return structuredClone(node);\n}\n\n// ponytail: Identifier + default + rest only. Destructured bindings (`{x}`, `[x]`)\n// aren't inlined (U2 inlines Identifier-param helpers / loop vars only), so a\n// destructuring shadow is a double-rare miss that just falls back. Add the\n// pattern cases here if that ever bites.\nfunction collectPatternNames(pattern: Node, out: Set<string>): void {\n if (pattern?.type === \"Identifier\") out.add(pattern.name);\n else if (pattern?.type === \"AssignmentPattern\") collectPatternNames(pattern.left, out);\n else if (pattern?.type === \"RestElement\") collectPatternNames(pattern.argument, out);\n}\n\n/** Every identifier name bound anywhere inside the subtree (fn params, declared vars, catch params). */\nfunction collectBoundNames(root: Node): Set<string> {\n const names = new Set<string>();\n const visit = (node: Node): Node => {\n if (!isNode(node)) return node;\n if (isFunctionNode(node)) for (const p of node.params ?? []) collectPatternNames(p, names);\n else if (node.type === \"VariableDeclarator\") collectPatternNames(node.id, names);\n else if (node.type === \"CatchClause\") collectPatternNames(node.param, names);\n transformChildren(node, visit);\n return node;\n };\n visit(root);\n return names;\n}\n\n/** A child in key/property position that must not be treated as a value identifier. */\nfunction isNonValueIdentifierSlot(node: Node, key: string): boolean {\n if (node.computed) return false;\n return (\n (node.type === \"MemberExpression\" && key === \"property\") ||\n (node.type === \"Property\" && key === \"key\")\n );\n}\n\n/**\n * Substitute bound identifiers in an already-cloned subtree, returning the\n * (possibly replaced) root. Names shadowed anywhere inside (nested function\n * params, declared vars) are dropped up front rather than tracked per scope —\n * worst case we under-substitute and the caller falls back to current behavior.\n * Never substitutes identifiers in key/member positions. Mutates the passed\n * clone in place — callers pass `cloneNode(...)`.\n */\nexport function substituteParams(node: Node, bindings: ReadonlyMap<string, Node>): Node {\n const shadowed = collectBoundNames(node);\n let effective = bindings;\n if (shadowed.size > 0) {\n effective = new Map(bindings);\n for (const name of shadowed) (effective as Map<string, Node>).delete(name);\n }\n if (effective.size === 0) return node;\n return replace(node, effective);\n}\n\nfunction replace(node: Node, bindings: ReadonlyMap<string, Node>): Node {\n if (!isNode(node)) return node;\n if (node.type === \"Identifier\" && bindings.has(node.name)) {\n return cloneNode(bindings.get(node.name));\n }\n transformChildren(node, (child) => replace(child, bindings));\n return node;\n}\n\n/** Tag a node (typically a `tl.*` CallExpression) with its construction provenance. */\nexport function tagProvenance(node: Node, provenance: GsapProvenance): Node {\n if (node && typeof node === \"object\") node.__hfProvenance = provenance;\n return node;\n}\n\n/** Read a provenance tag previously set by `tagProvenance`, if any. */\nexport function readProvenance(node: Node): GsapProvenance | undefined {\n return node?.__hfProvenance;\n}\n\n/** Synthesize a numeric `Literal` node (for loop indices, which have no source node). */\nexport function numericLiteral(value: number): Node {\n return { type: \"Literal\", value, raw: String(value) };\n}\n\n// ── Expansion engine (U2) ─────────────────────────────────────────────────────\n\n/** Resolve an expression to a literal value (top-level consts in scope, arithmetic). */\ntype LiteralResolver = (node: Node) => number | string | boolean | undefined;\n\ninterface ExpandCtx {\n helpers: Map<string, Node>;\n timelineVar: string;\n resolve: LiteralResolver;\n depth: number;\n /** Mutable source-order counter for provenance call-site ordinals. */\n site: { n: number };\n /** Mutable counter stamping expansion order onto tweens (clones share source loc). */\n order: { n: number };\n}\n\nfunction walkNodes(node: Node, fn: (n: Node) => void): void {\n if (!isNode(node)) return;\n fn(node);\n for (const key of Object.keys(node)) {\n if (SKIP_KEYS.has(key)) continue;\n const child = node[key];\n if (Array.isArray(child)) for (const c of child) walkNodes(c, fn);\n else walkNodes(child, fn);\n }\n}\n\n/** The identifier a (possibly chained) call's member expression is rooted at. */\nfunction timelineRootName(call: Node): string | null {\n let obj = call.callee?.object;\n while (obj?.type === \"CallExpression\") obj = obj.callee?.object;\n return obj?.type === \"Identifier\" ? obj.name : null;\n}\n\nfunction isTimelineRooted(call: Node, timelineVar: string): boolean {\n if (timelineRootName(call) !== timelineVar) return false;\n return (\n call.callee?.property?.type === \"Identifier\" && GSAP_METHODS.has(call.callee.property.name)\n );\n}\n\nfunction containsTimelineCall(node: Node, timelineVar: string): boolean {\n let found = false;\n walkNodes(node, (n) => {\n if (n.type === \"CallExpression\" && isTimelineRooted(n, timelineVar)) found = true;\n });\n return found;\n}\n\nfunction rangeOf(node: Node): [number, number] | undefined {\n return typeof node.start === \"number\" && typeof node.end === \"number\"\n ? [node.start, node.end]\n : undefined;\n}\n\n/** Plain identifier params + block body (shape we can inline). Timeline content checked separately. */\nfunction isShapeEligible(fn: Node): boolean {\n return (\n isFunctionNode(fn) &&\n fn.body?.type === \"BlockStatement\" &&\n !(fn.params ?? []).some((p: Node) => p.type !== \"Identifier\")\n );\n}\n\n/** True if the subtree calls any function named in `names`. */\nfunction callsAny(node: Node, names: Set<string>): boolean {\n let hit = false;\n walkNodes(node, (n) => {\n if (\n n.type === \"CallExpression\" &&\n n.callee?.type === \"Identifier\" &&\n names.has(n.callee.name)\n ) {\n hit = true;\n }\n });\n return hit;\n}\n\n/** `[name, fnNode]` if a single-declarator `const f = fn` is an inlinable-shaped helper. */\nfunction varDeclHelper(stmt: Node): [string, Node] | null {\n if (stmt.declarations?.length !== 1) return null;\n const d = stmt.declarations[0];\n return d.id?.type === \"Identifier\" && isShapeEligible(d.init) ? [d.id.name, d.init] : null;\n}\n\n/** `[name, fnNode]` if `stmt` declares an inlinable-shaped helper, else null. */\nfunction helperFromStatement(stmt: Node): [string, Node] | null {\n if (stmt.type === \"FunctionDeclaration\") {\n return stmt.id && isShapeEligible(stmt) ? [stmt.id.name, stmt] : null;\n }\n if (stmt.type === \"VariableDeclaration\") return varDeclHelper(stmt);\n return null;\n}\n\n/** Top-level functions whose shape we can inline (Identifier params + block body). */\nfunction gatherHelperCandidates(program: Node): Map<string, Node> {\n const candidates = new Map<string, Node>();\n for (const stmt of program.body ?? []) {\n const helper = helperFromStatement(stmt);\n if (helper) candidates.set(helper[0], helper[1]);\n }\n return candidates;\n}\n\n/** Names that build the timeline directly or by calling another builder (transitive closure). */\nfunction timelineBuildingNames(candidates: Map<string, Node>, timelineVar: string): Set<string> {\n const building = new Set<string>();\n for (const [name, fn] of candidates) {\n if (containsTimelineCall(fn.body, timelineVar)) building.add(name);\n }\n for (let changed = true; changed; ) {\n changed = false;\n for (const [name, fn] of candidates) {\n if (!building.has(name) && callsAny(fn.body, building)) {\n building.add(name);\n changed = true;\n }\n }\n }\n return building;\n}\n\nfunction bump(counts: Map<string, number>, key: string): void {\n counts.set(key, (counts.get(key) ?? 0) + 1);\n}\n\n/**\n * Keep only candidates safe to drop: every reference to the name is its\n * declaration or a statement-level call. (1 decl id + 1 callee id per\n * statement-level call ⇒ total occurrences with no stray uses.)\n */\nfunction safelyDroppable(program: Node, candidates: Map<string, Node>): Map<string, Node> {\n const names = new Set(candidates.keys());\n const totalIds = new Map<string, number>();\n const stmtCalls = new Map<string, number>();\n walkNodes(program, (n) => {\n if (n.type === \"Identifier\" && names.has(n.name)) bump(totalIds, n.name);\n const e = n.type === \"ExpressionStatement\" ? n.expression : undefined;\n if (\n e?.type === \"CallExpression\" &&\n e.callee?.type === \"Identifier\" &&\n names.has(e.callee.name)\n ) {\n bump(stmtCalls, e.callee.name);\n }\n });\n const safe = new Map<string, Node>();\n for (const [name, fn] of candidates) {\n if ((totalIds.get(name) ?? 0) === 1 + (stmtCalls.get(name) ?? 0)) safe.set(name, fn);\n }\n return safe;\n}\n\n/** Top-level timeline-building helpers that are safe to inline-and-drop. */\nfunction collectInlinableHelpers(program: Node, timelineVar: string): Map<string, Node> {\n const candidates = gatherHelperCandidates(program);\n if (candidates.size === 0) return candidates;\n const building = timelineBuildingNames(candidates, timelineVar);\n for (const name of [...candidates.keys()]) if (!building.has(name)) candidates.delete(name);\n if (candidates.size === 0) return candidates;\n return safelyDroppable(program, candidates);\n}\n\nfunction isHelperDecl(stmt: Node, helpers: Map<string, Node>): boolean {\n if (stmt.type === \"FunctionDeclaration\") return !!stmt.id && helpers.get(stmt.id.name) === stmt;\n if (stmt.type === \"VariableDeclaration\" && stmt.declarations?.length === 1) {\n const d = stmt.declarations[0];\n return d.id?.type === \"Identifier\" && helpers.get(d.id.name) === d.init;\n }\n return false;\n}\n\nfunction bodyStatements(node: Node): Node[] {\n if (node?.type === \"BlockStatement\") return node.body ?? [];\n return node ? [{ type: \"ExpressionStatement\", expression: node }] : [];\n}\n\n/** Tag this body's direct timeline tweens with provenance + a monotonic expansion-order stamp. */\nfunction tagTimelineCalls(stmts: Node[], prov: GsapProvenance, ctx: ExpandCtx): void {\n for (const stmt of stmts) {\n walkNodes(stmt, (n) => {\n if (n.type === \"CallExpression\" && isTimelineRooted(n, ctx.timelineVar)) {\n tagProvenance(n, { ...prov });\n n.__hfOrder = ctx.order.n++;\n }\n });\n }\n}\n\n/** Clone a body as one scope, substitute the bindings, tag provenance, recurse. */\nfunction expandBody(\n bodyStmts: Node[],\n bindings: Map<string, Node>,\n prov: GsapProvenance,\n ctx: ExpandCtx,\n): Node[] {\n const block = substituteParams(cloneNode({ type: \"BlockStatement\", body: bodyStmts }), bindings);\n tagTimelineCalls(block.body, prov, ctx);\n return expandStatements(block.body, { ...ctx, depth: ctx.depth + 1 });\n}\n\nfunction inlineHelper(call: Node, ctx: ExpandCtx): Node[] {\n const fn = ctx.helpers.get(call.callee.name);\n const bindings = new Map<string, Node>();\n (fn.params ?? []).forEach((p: Node, i: number) => {\n const arg = call.arguments?.[i];\n if (arg) bindings.set(p.name, arg);\n });\n const prov: GsapProvenance = {\n kind: \"helper\",\n fn: call.callee.name,\n callSite: ++ctx.site.n,\n sourceRange: rangeOf(call),\n };\n return expandBody(fn.body.body, bindings, prov, ctx);\n}\n\nfunction assignStep(update: Node, resolve: LiteralResolver): number | undefined {\n if (update.operator === \"+=\") return asNum(resolve(update.right));\n if (update.operator === \"-=\") {\n const s = asNum(resolve(update.right));\n return s === undefined ? undefined : -s;\n }\n // `i = i + S` — the step is the right operand of the addition.\n if (update.operator === \"=\" && update.right?.type === \"BinaryExpression\") {\n return asNum(resolve(update.right.right));\n }\n return undefined;\n}\n\n/** The loop variable a `for` update clause mutates (`i++` or `i += S`), or null. */\nfunction updatedVarName(update: Node): string | null {\n if (update?.type === \"UpdateExpression\") return update.argument?.name ?? null;\n if (update?.type === \"AssignmentExpression\") return update.left?.name ?? null;\n return null;\n}\n\nfunction loopStep(update: Node, varName: string, resolve: LiteralResolver): number | undefined {\n if (updatedVarName(update) !== varName) return undefined;\n if (update.type === \"UpdateExpression\") return update.operator === \"++\" ? 1 : -1;\n return assignStep(update, resolve);\n}\n\nfunction asNum(v: unknown): number | undefined {\n return typeof v === \"number\" && Number.isFinite(v) ? v : undefined;\n}\n\nfunction loopSatisfied(op: string, x: number, end: number): boolean {\n if (op === \"<\") return x < end;\n if (op === \"<=\") return x <= end;\n if (op === \">\") return x > end;\n if (op === \">=\") return x >= end;\n return false;\n}\n\ninterface ForHeader {\n v: string;\n start: number;\n end: number;\n op: string;\n step: number;\n}\n\n/** The single `let v = <init>` of a for-loop init clause, or null. */\nfunction forInitVar(init: Node): { name: string; initExpr: Node } | null {\n if (init?.type !== \"VariableDeclaration\" || init.declarations?.length !== 1) return null;\n const d = init.declarations[0];\n return d.id?.type === \"Identifier\" ? { name: d.id.name, initExpr: d.init } : null;\n}\n\n/** Parse `for (let v = A; v <op> B; v += S)` into resolved bounds, or null if not statically bounded. */\nfunction parseForHeader(stmt: Node, resolve: LiteralResolver): ForHeader | null {\n const iv = forInitVar(stmt.init);\n const test = stmt.test;\n if (!iv || test?.type !== \"BinaryExpression\" || test.left?.name !== iv.name) return null;\n const start = asNum(resolve(iv.initExpr));\n const end = asNum(resolve(test.right));\n const step = loopStep(stmt.update, iv.name, resolve);\n if (start === undefined || end === undefined || !step) return null;\n return { v: iv.name, start, end, op: test.operator, step };\n}\n\nfunction unrollFor(stmt: Node, ctx: ExpandCtx): Node[] | null {\n const h = parseForHeader(stmt, ctx.resolve);\n if (!h) return null;\n const body = bodyStatements(stmt.body);\n const out: Node[] = [];\n const site = ++ctx.site.n;\n let iteration = 0;\n for (let x = h.start; loopSatisfied(h.op, x, h.end); x += h.step) {\n if (iteration >= MAX_ITERS) return null;\n const prov: GsapProvenance = {\n kind: \"loop\",\n callSite: site,\n iteration,\n sourceRange: rangeOf(stmt),\n };\n out.push(...expandBody(body, new Map([[h.v, numericLiteral(x)]]), prov, ctx));\n iteration++;\n }\n return out;\n}\n\nfunction forOfVarName(left: Node): string | null {\n if (left?.type === \"VariableDeclaration\") {\n const id = left.declarations?.[0]?.id;\n return id?.type === \"Identifier\" ? id.name : null;\n }\n return left?.type === \"Identifier\" ? left.name : null;\n}\n\n/** Expand `for (const el of [literal array]) {...}` and `[literal array].forEach((el, i) => {...})`. */\nfunction unrollOverArray(\n elements: Node[],\n body: Node[],\n elName: string | null,\n idxName: string | null,\n range: [number, number] | undefined,\n ctx: ExpandCtx,\n): Node[] {\n const out: Node[] = [];\n const site = ++ctx.site.n;\n elements.forEach((el, i) => {\n if (!el) return;\n const bindings = new Map<string, Node>();\n if (elName) bindings.set(elName, el);\n if (idxName) bindings.set(idxName, numericLiteral(i));\n const prov: GsapProvenance = { kind: \"loop\", callSite: site, iteration: i, sourceRange: range };\n out.push(...expandBody(body, bindings, prov, ctx));\n });\n return out;\n}\n\nfunction unrollForOf(stmt: Node, ctx: ExpandCtx): Node[] | null {\n if (stmt.right?.type !== \"ArrayExpression\") return null;\n const elName = forOfVarName(stmt.left);\n if (!elName) return null;\n return unrollOverArray(\n stmt.right.elements ?? [],\n bodyStatements(stmt.body),\n elName,\n null,\n rangeOf(stmt),\n ctx,\n );\n}\n\n/** The (element, index) param names of a callback, or null if either is non-Identifier. */\nfunction callbackParamNames(cb: Node): { el: string | null; idx: string | null } | null {\n const names: Array<string | null> = [];\n for (const p of [cb.params?.[0], cb.params?.[1]]) {\n if (!p) names.push(null);\n else if (p.type !== \"Identifier\") return null;\n else names.push(p.name);\n }\n return { el: names[0]!, idx: names[1]! };\n}\n\n/** True for `[arrayLiteral].forEach` member callees. */\nfunction isForEachCall(callee: Node): boolean {\n return (\n callee?.type === \"MemberExpression\" &&\n callee.property?.name === \"forEach\" &&\n callee.object?.type === \"ArrayExpression\"\n );\n}\n\n/** The element array + callback of `[...].forEach(cb)`, or null. */\nfunction forEachTarget(call: Node): { elements: Node[]; cb: Node } | null {\n if (!isForEachCall(call.callee)) return null;\n const cb = call.arguments?.[0];\n return isFunctionNode(cb) ? { elements: call.callee.object.elements ?? [], cb } : null;\n}\n\nfunction unrollForEach(call: Node, ctx: ExpandCtx): Node[] | null {\n const target = forEachTarget(call);\n if (!target) return null;\n const params = callbackParamNames(target.cb);\n if (!params) return null;\n return unrollOverArray(\n target.elements,\n bodyStatements(target.cb.body),\n params.el,\n params.idx,\n rangeOf(call),\n ctx,\n );\n}\n\nfunction expandCall(call: Node, ctx: ExpandCtx): Node[] | null {\n if (call.callee?.type === \"Identifier\" && ctx.helpers.has(call.callee.name)) {\n return inlineHelper(call, ctx);\n }\n return unrollForEach(call, ctx);\n}\n\nfunction expandStatement(stmt: Node, ctx: ExpandCtx): Node[] | null {\n if (ctx.depth >= MAX_DEPTH) return null;\n if (stmt.type === \"ForStatement\") return unrollFor(stmt, ctx);\n if (stmt.type === \"ForOfStatement\") return unrollForOf(stmt, ctx);\n if (stmt.type === \"ExpressionStatement\" && stmt.expression?.type === \"CallExpression\") {\n return expandCall(stmt.expression, ctx);\n }\n return null;\n}\n\nfunction expandStatements(stmts: Node[], ctx: ExpandCtx): Node[] {\n const out: Node[] = [];\n for (const stmt of stmts) {\n const expanded = expandStatement(stmt, ctx);\n if (expanded) out.push(...expanded);\n else out.push(stmt);\n }\n return out;\n}\n\n/**\n * Rewrite the Program body so helper invocations and bounded loops that build\n * the timeline are expanded into concrete per-call / per-iteration `tl.*`\n * statements, each tagged with provenance. Mutates `ast` in place (caller owns\n * the freshly-parsed tree). Constructs it can't statically resolve are left\n * untouched, so the parser falls back to current behavior for them.\n */\nexport function inlineComputedTimelines(\n ast: Node,\n timelineVar: string,\n resolve: LiteralResolver,\n): void {\n const helpers = collectInlinableHelpers(ast, timelineVar);\n const ctx: ExpandCtx = {\n helpers,\n timelineVar,\n resolve,\n depth: 0,\n site: { n: 0 },\n order: { n: 0 },\n };\n const body = (ast.body ?? []).filter((stmt: Node) => !isHelperDecl(stmt, helpers));\n ast.body = expandStatements(body, ctx);\n}\n"],"mappings":";AAQA,OAAO,iBAAiB;;;AC8CjB,IAAM,kBAAkE;AAAA,EAC7E,UAAU,oBAAI,IAAI,CAAC,KAAK,KAAK,YAAY,UAAU,CAAC;AAAA,EACpD,OAAO,oBAAI,IAAI,CAAC,SAAS,UAAU,QAAQ,CAAC;AAAA,EAC5C,MAAM,oBAAI,IAAI,CAAC,SAAS,QAAQ,CAAC;AAAA,EACjC,UAAU,oBAAI,IAAI,CAAC,YAAY,SAAS,OAAO,CAAC;AAAA,EAChD,QAAQ,oBAAI,IAAI,CAAC,WAAW,WAAW,CAAC;AAAA,EACxC,OAAO,oBAAI,IAAY;AACzB;AAEA,IAAM,gBAAgB,oBAAI,IAA+B;AACzD,WAAW,CAAC,OAAO,KAAK,KAAK,OAAO,QAAQ,eAAe,GAGtD;AACH,aAAW,KAAK,MAAO,eAAc,IAAI,GAAG,KAAK;AACnD;AAEO,SAAS,sBAAsB,MAAiC;AACr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