@haiyue/animation-spec 0.2.0 → 0.2.2
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.
- package/bin/hya-live2d-convert.mjs +0 -0
- package/bin/hya-lottie-convert.mjs +0 -0
- package/dist/hya-production.d.ts +1 -0
- package/dist/hya-production.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/lottie.d.ts +1 -1
- package/dist/native3d.d.ts +1 -1
- package/dist/shared.d.ts +1300 -2
- package/package.json +93 -89
- package/schema/animation.schema.json +12 -12
- package/schema/hya-composition.schema.json +41 -0
- package/schema/responsive-layout-2d.schema.json +1 -1
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ac as AudioEventDiagnostic, ad as AudioEventDiagnosticCode, ae as AudioEventParseOptions, af as DEFAULT_HYA_COMPOSITION_LIMITS, ag as DataBindingDiagnostic, ah as DataBindingDiagnosticCode, ai as DataBindingParseOptions, aj as DataValue, ak as HYA_COMPOSITION_FORMAT, al as HYA_COMPOSITION_VERSION, am as HyaAudioEventDocument, an as HyaCompositionDiagnostic, ao as HyaCompositionDocument, ap as HyaCompositionError, aq as HyaCompositionErrorCode, ar as HyaCompositionLimits, as as HyaCompositionParseOptions, at as HyaCompositionParseResult, au as HyaCompositionPart, av as HyaCompositionPartValidator, aw as HyaCompositionPlan, ax as HyaCompositionTarget, ay as HyaCompositionValue, az as HyaDataBindingDocument, aA as HyaInteractionDocument, aB as HyaSemanticsDocument, aC as HyaStateMachineV1MigrationOptions, aD as HyaStateMachineV1MigrationResult, aE as HyaStateMachineV2Document, aF as InteractionDiagnostic, aG as InteractionDiagnosticCode, aH as InteractionParseOptions, aI as LayoutDiagnostic, aJ as LayoutDiagnosticCode, aK as LayoutParseOptions, aL as ParseStateMachineV2Options, aM as ResponsiveLayoutDocument, aN as SemanticsDiagnostic, aO as SemanticsDiagnosticCode, aP as SemanticsParseOptions, aQ as StateMachineV2Diagnostic, aR as StateMachineV2DiagnosticCode, aS as decodeResponsiveLayoutDocument, aT as encodeHyaComposition, aU as encodeResponsiveLayoutDocument, aV as isResponsiveLayoutBinary, aW as migrateHyaStateMachineV1, aX as negotiateHyaComposition, aY as parseHyaAudioEvents, aZ as parseHyaComposition, a_ as parseHyaDataBinding, a$ as parseHyaInteraction, b0 as parseHyaSemantics, b1 as parseHyaStateMachineV2, b2 as parseResponsiveLayoutDocument } from './shared.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseAnimation as e}from"./index.js";import"./chunks/expression-D1cKtNwM.js";import"./chunks/errors-Bzs3GOD9.js";import"./chunks/extensions-DxL4AxOC.js";import"./chunks/binary-DvuTJ_hy.js";const t="haiyue-composition",n=1,o=Object.freeze({maxInputBytes:67108864,maxJsonNodes:1e6,maxDepth:128,maxStringBytes:4194304,maxParts:16,maxTargets:1e5,maxRequirementsPerPart:64});class i extends Error{code;path;capability;causeCode;name="HyaCompositionError";constructor(e,t,n,o,i){super(`${n} (${t})`),this.code=e,this.path=t,this.capability=o,this.causeCode=i}}const s="haiyue-text-shaping@1";class r extends Error{code;path;name="LayoutDiagnostic";constructor(e,t,n){super(`${e} at ${t}: ${n}`),this.code=e,this.path=t}}const a=Object.freeze({maxInputBytes:67108864,maxMetadataBytes:4194304,maxAssets:4096,maxAssetBytes:268435456,maxTotalAssetBytes:1073741824,maxArtboards:8192,maxNodes:25e4,maxTextBytes:33554432,maxGlyphs:1e6,maxLines:25e4,maxLayoutPasses:64,maxNestedDepth:128,maxComponentInstances:8192,maxListItems:1e5,maxVirtualizedWindow:4096,maxNslicePatches:1e6,maxGpuBytes:536870912});function c(e,t={}){const n=Object.freeze({...a,...t.limits});!function(e){for(const[t,n]of Object.entries(e))(!Number.isSafeInteger(n)||n<1)&&q("E_LAYOUT_LIMIT",`limits.${t}`,"limit must be a positive safe integer")}(n);const o=h(e,"$");A(o,["format","version","extension","shaping","assets","textStyles","textBlocks","artboards","instances"],"$"),j(o.format,"haiyue-responsive-layout-2d","$.format"),j(o.version,1,"$.version"),j(o.extension,"org.haiyue.layout-2d@1","$.extension"),function(e,t){const n=h(e,t);A(n,["stack","backendRevision","unicodeVersion","graphemeRevision","bidiRevision"],t),j(n.stack,s,`${t}.stack`);for(const e of["backendRevision","unicodeVersion","graphemeRevision","bidiRevision"])T(n[e],`${t}.${e}`)}(o.shaping,"$.shaping");const i=E(o.assets,"$.assets"),r=E(o.textStyles,"$.textStyles"),c=E(o.textBlocks,"$.textBlocks"),J=E(o.artboards,"$.artboards"),K=E(o.instances,"$.instances");z(i.length,n.maxAssets,"$.assets"),z(J.length,n.maxArtboards,"$.artboards"),z(K.length,n.maxComponentInstances,"$.instances");const X={assetBytes:0,nodes:0,textBytes:0,nSlicePatches:0},Z=new Set,Q=new Map;i.forEach((e,t)=>{const o=function(e,t,n,o,i){const s=h(e,t),r=H(s.kind,["folder","image","font","audio","blob","manifest","text"],`${t}.kind`);A(s,["id","kind","name","mimeType","source",...{folder:["children"],image:["width","height","filter","wrapX","wrapY"],font:["family","weight","style","metrics"],audio:["duration","sampleRate","channels"],blob:["signature"],manifest:["entries"],text:["folderPath","encoding"]}[r]],t);const a=T(s.id,`${t}.id`);Y(n,a,`${t}.id`),I(s.name,`${t}.name`),I(s.mimeType,`${t}.mimeType`),"folder"!==r&&function(e,t,n,o){const i=h(e,t),s=H(i.kind,["embedded","referenced","hosted"],`${t}.kind`);if(A(i,"embedded"===s?["kind","data","integrity"]:"referenced"===s?["kind","uri","integrity"]:["kind","slot","fallbackAsset","integrity"],t),"embedded"===s){const e=function(e,t){Array.isArray(e)||e instanceof Uint8Array||q("E_LAYOUT_FORMAT",t,"expected byte array");for(let n=0;n<e.length;n++)C(e[n],0,255,`${t}[${n}]`);return e}(i.data,`${t}.data`);z(e.length,n.maxAssetBytes,`${t}.data`),o.assetBytes+=e.length,z(o.assetBytes,n.maxTotalAssetBytes,"$.assetBytes"),m(i.integrity,`${t}.integrity`)}else"referenced"===s?(T(i.uri,`${t}.uri`),m(i.integrity,`${t}.integrity`)):(T(i.slot,`${t}.slot`),x(i.fallbackAsset,`${t}.fallbackAsset`),m(i.integrity,`${t}.integrity`))}(s.source,`${t}.source`,o,i);if("folder"===r)E(s.children,`${t}.children`).forEach((e,n)=>T(e,`${t}.children[${n}]`));else if("image"===r){const e=N(s.width,`${t}.width`),n=N(s.height,`${t}.height`);(e>16384||n>16384||e*n>268435456)&&q("E_LAYOUT_LIMIT",t,"image dimensions exceed the frozen decode budget"),L(s.filter,["nearest","linear"],`${t}.filter`),L(s.wrapX,["clamp","repeat","mirror"],`${t}.wrapX`),L(s.wrapY,["clamp","repeat","mirror"],`${t}.wrapY`)}else if("font"===r)T(s.family,`${t}.family`),M(s.weight,1,1e3,`${t}.weight`),H(s.style,["normal","italic"],`${t}.style`),function(e,t){const n=h(e,t);A(n,["unitsPerEm","ascent","descent","lineGap","missingGlyph","glyphs","ligatures","kerning","axes"],t),N(n.unitsPerEm,`${t}.unitsPerEm`),v(n.ascent,`${t}.ascent`),v(n.descent,`${t}.descent`),v(n.lineGap,`${t}.lineGap`),d(n.missingGlyph,`${t}.missingGlyph`);const o=h(n.glyphs,`${t}.glyphs`);for(const[e,n]of Object.entries(o))0===e.length&&q("E_LAYOUT_SHAPING",`${t}.glyphs`,"glyph sequence must be non-empty"),d(n,`${t}.glyphs.${e}`);if(void 0!==n.ligatures)for(const[e,o]of Object.entries(h(n.ligatures,`${t}.ligatures`)))e.length<2&&q("E_LAYOUT_SHAPING",`${t}.ligatures`,"ligature sequence requires at least two code units"),d(o,`${t}.ligatures.${e}`);if(void 0!==n.kerning)for(const[e,o]of Object.entries(h(n.kerning,`${t}.kerning`)))e.includes("|")||q("E_LAYOUT_SHAPING",`${t}.kerning.${e}`,"kerning key must be left|right"),v(o,`${t}.kerning.${e}`);if(void 0!==n.axes)for(const[e,o]of Object.entries(h(n.axes,`${t}.axes`))){p(e,`${t}.axes.${e}`);const n=h(o,`${t}.axes.${e}`);A(n,["min","default","max"],`${t}.axes.${e}`);const i=v(n.min,`${t}.axes.${e}.min`),s=v(n.default,`${t}.axes.${e}.default`),r=v(n.max,`${t}.axes.${e}.max`);(i>s||s>r)&&q("E_LAYOUT_NUMBER",`${t}.axes.${e}`,"axis requires min <= default <= max")}}(s.metrics,`${t}.metrics`);else if("audio"===r)O(s.duration,`${t}.duration`),N(s.sampleRate,`${t}.sampleRate`),C(s.channels,1,64,`${t}.channels`);else if("blob"===r)I(s.signature,`${t}.signature`);else if("manifest"===r){const e=h(s.entries,`${t}.entries`);for(const[n,o]of Object.entries(e))T(n,`${t}.entries.${n}`),T(o,`${t}.entries.${n}`)}else I(s.folderPath,`${t}.folderPath`),L(s.encoding,["utf-8"],`${t}.encoding`);return s}(e,`$.assets[${t}]`,Z,n,X);Q.set(o.id,o.kind)}),function(e,t,n,o){const i=new Map;e.forEach((e,o)=>{const s=h(e,`${n}[${o}]`),r=[];"folder"===s.kind&&r.push(...E(s.children,`${n}[${o}].children`)),"manifest"===s.kind&&r.push(...Object.values(h(s.entries,`${n}[${o}].entries`)));const a=void 0===s.source?void 0:h(s.source,`${n}[${o}].source`);"hosted"===a?.kind&&void 0!==a.fallbackAsset&&r.push(a.fallbackAsset);for(const e of r)t.has(e)||q("E_LAYOUT_REFERENCE",`${n}[${o}]`,`unknown asset ${e}`);i.set(s.id,r)}),g(i,n,o)}(i,Z,"$.assets",n.maxNestedDepth);const ee=new Set;r.forEach((e,t)=>function(e,t,n,o){const i=h(e,t);A(i,["id","fontAssets","fontFamily","fontWeight","fontStyle","fontSize","lineHeight","tracking","alignment","verticalAlignment","direction","language","script","axes","features","fills","strokes","background"],t);const s=T(i.id,`${t}.id`);Y(n,s,`${t}.id`);const r=E(i.fontAssets,`${t}.fontAssets`);0===r.length&&q("E_LAYOUT_SHAPING",`${t}.fontAssets`,"font fallback chain must not be empty");r.forEach((e,n)=>{const i=T(e,`${t}.fontAssets[${n}]`);"font"!==o.get(i)&&q("E_LAYOUT_REFERENCE",`${t}.fontAssets[${n}]`,`expected font asset ${i}`)}),T(i.fontFamily,`${t}.fontFamily`),M(i.fontWeight,1,1e3,`${t}.fontWeight`),H(i.fontStyle,["normal","italic"],`${t}.fontStyle`),N(i.fontSize,`${t}.fontSize`),N(i.lineHeight,`${t}.lineHeight`),v(i.tracking,`${t}.tracking`),H(i.alignment,["start","center","end","justify"],`${t}.alignment`),L(i.verticalAlignment,["top","middle","bottom","baseline"],`${t}.verticalAlignment`),L(i.direction,["auto","ltr","rtl"],`${t}.direction`),I(i.language,`${t}.language`),I(i.script,`${t}.script`),$(i.axes,`${t}.axes`,!1),$(i.features,`${t}.features`,!0);const a=E(i.fills,`${t}.fills`);0===a.length&&q("E_LAYOUT_FORMAT",`${t}.fills`,"text style requires at least one fill");if(a.forEach((e,n)=>{const o=h(e,`${t}.fills[${n}]`);A(o,["source","opacity"],`${t}.fills[${n}]`),l(o.source,`${t}.fills[${n}].source`),R(o.opacity,0,1,`${t}.fills[${n}].opacity`)}),_(i.strokes,`${t}.strokes`).forEach((e,n)=>{const o=h(e,`${t}.strokes[${n}]`);A(o,["source","width","opacity","join"],`${t}.strokes[${n}]`),l(o.source,`${t}.strokes[${n}].source`),N(o.width,`${t}.strokes[${n}].width`),R(o.opacity,0,1,`${t}.strokes[${n}].opacity`),L(o.join,["miter","round","bevel"],`${t}.strokes[${n}].join`)}),void 0!==i.background){const e=h(i.background,`${t}.background`);A(e,["color","cornerRadius"],`${t}.background`),V(e.color,`${t}.background.color`),k(e.cornerRadius,`${t}.background.cornerRadius`)}}(e,`$.textStyles[${t}]`,ee,Q));const te=new Set;c.forEach((e,t)=>function(e,t,n,o,i){const s=h(e,t);A(s,["id","runs","width","height","wrap","overflow","paragraphSpacing","origin","verticalTrim","modifiers","input"],t);const r=T(s.id,`${t}.id`);if(Y(n,r,`${t}.id`),O(s.width,`${t}.width`),O(s.height,`${t}.height`),L(s.wrap,["none","word","grapheme"],`${t}.wrap`),L(s.overflow,["visible","clip","ellipsis"],`${t}.overflow`),k(s.paragraphSpacing,`${t}.paragraphSpacing`),B(s.origin,2,`${t}.origin`),void 0!==s.verticalTrim){const e=h(s.verticalTrim,`${t}.verticalTrim`);A(e,["top","bottom"],`${t}.verticalTrim`),O(e.top,`${t}.verticalTrim.top`),O(e.bottom,`${t}.verticalTrim.bottom`)}const a=new Set,c=E(s.runs,`${t}.runs`);0===c.length&&q("E_LAYOUT_FORMAT",`${t}.runs`,"text block requires a run");if(c.forEach((e,n)=>{const s=`${t}.runs[${n}]`,r=h(e,s);A(r,["id","style","text","valuePort"],s);const c=T(r.id,`${s}.id`);Y(a,c,`${s}.id`),G(r.style,o,`${s}.style`);const d=b(r.text,`${s}.text`);i.textBytes+=(new TextEncoder).encode(d).byteLength,x(r.valuePort,`${s}.valuePort`)}),_(s.modifiers,`${t}.modifiers`).forEach((e,n)=>function(e,t){const n=h(e,t),o=H(n.kind,["transform","follow-path"],`${t}.kind`);if(A(n,"transform"===o?["kind","range","translation","scale","rotation","origin","opacity","variables"]:["kind","range","points","radial","orient","start","end","offset"],t),function(e,t){const n=h(e,t);A(n,["start","end","units","falloffFrom","falloffTo","increment","offset","mode","strength"],t),v(n.start,`${t}.start`),v(n.end,`${t}.end`),H(n.units,["grapheme","word","line","percent"],`${t}.units`),S(n.falloffFrom,`${t}.falloffFrom`),S(n.falloffTo,`${t}.falloffTo`),S(n.increment,`${t}.increment`),S(n.offset,`${t}.offset`),L(n.mode,["clamp","repeat","mirror"],`${t}.mode`),S(n.strength,`${t}.strength`)}(n.range,`${t}.range`),"transform"===o)B(n.translation,2,`${t}.translation`),B(n.scale,2,`${t}.scale`),S(n.rotation,`${t}.rotation`),B(n.origin,2,`${t}.origin`),R(n.opacity,0,1,`${t}.opacity`),$(n.variables,`${t}.variables`,!1);else{const e=y(n.points,`${t}.points`);(e.length<4||e.length%2!=0||function(e){let t=0;for(let n=2;n<e.length;n+=2)t+=Math.hypot(e[n]-e[n-2],e[n+1]-e[n-1]);return t}(e)<=1e-8)&&q("E_LAYOUT_SHAPING",`${t}.points`,"follow path must be non-degenerate xy pairs"),U(n.radial,`${t}.radial`),U(n.orient,`${t}.orient`),S(n.start,`${t}.start`),S(n.end,`${t}.end`),S(n.offset,`${t}.offset`)}}(e,`${t}.modifiers[${n}]`)),void 0!==s.input){const e=h(s.input,`${t}.input`);A(e,["valuePort","selectionPort","cursorPort","multiline","selectionRadius"],`${t}.input`),T(e.valuePort,`${t}.input.valuePort`),x(e.selectionPort,`${t}.input.selectionPort`),x(e.cursorPort,`${t}.input.cursorPort`),U(e.multiline,`${t}.input.multiline`),k(e.selectionRadius,`${t}.input.selectionRadius`)}}(e,`$.textBlocks[${t}]`,te,ee,X)),z(X.textBytes,n.maxTextBytes,"$.textBytes");const ne=new Set;J.forEach((e,t)=>{const n=T(h(e,`$.artboards[${t}]`).id,`$.artboards[${t}].id`);Y(ne,n,`$.artboards[${t}].id`)}),J.forEach((e,t)=>function(e,t,n,o,i,s,r){const a=h(e,t);A(a,["id","name","width","height","root","nodes"],t),T(a.id,`${t}.id`),I(a.name,`${t}.name`),N(a.width,`${t}.width`),N(a.height,`${t}.height`);const c=E(a.nodes,`${t}.nodes`);r.nodes+=c.length;const d=new Set;c.forEach((e,n)=>{const o=T(h(e,`${t}.nodes[${n}]`).id,`${t}.nodes[${n}].id`);Y(d,o,`${t}.nodes[${n}].id`)});const l=G(a.root,d,`${t}.root`);c.forEach((e,a)=>function(e,t,n,o,i,s,r,a){const c=h(e,t);A(c,["id","parent","kind","style","visual","intrinsicSize","text","asset","component","list","nSlice","scroll"],t),T(c.id,`${t}.id`),x(c.parent,`${t}.parent`);const d=H(c.kind,["container","leaf","text","image","component","list","n-slice"],`${t}.kind`);(function(e,t){const n=h(e,t);A(n,["display","position","direction","writingDirection","wrap","width","height","minWidth","maxWidth","minHeight","maxHeight","aspectRatio","margin","padding","inset","gap","justify","align","justifySelf","overflow","gridColumns","gridRows","gridPlacement","reflow"],t),L(n.display,["flex","grid","none"],`${t}.display`),L(n.position,["relative","absolute"],`${t}.position`),L(n.direction,["row","column"],`${t}.direction`),L(n.writingDirection,["ltr","rtl"],`${t}.writingDirection`),U(n.wrap,`${t}.wrap`);for(const e of["width","height","minWidth","maxWidth","minHeight","maxHeight"])void 0!==n[e]&&u(n[e],`${t}.${e}`);w(n.aspectRatio,`${t}.aspectRatio`);for(const e of["margin","padding","inset"])void 0!==n[e]&&F(n[e],4,`${t}.${e}`);void 0!==n.gap&&F(n.gap,2,`${t}.gap`);L(n.justify,["start","center","end","space-between","space-around","space-evenly"],`${t}.justify`),L(n.align,["start","center","end","stretch"],`${t}.align`),L(n.justifySelf,["auto","start","center","end","stretch"],`${t}.justifySelf`),L(n.overflow,["visible","hidden","scroll"],`${t}.overflow`);for(const e of["gridColumns","gridRows"])_(n[e],`${t}.${e}`).forEach((n,o)=>{const i=h(n,`${t}.${e}[${o}]`);A(i,["min","max"],`${t}.${e}[${o}]`),u(i.min,`${t}.${e}[${o}].min`),void 0!==i.max&&u(i.max,`${t}.${e}[${o}].max`)});if(void 0!==n.gridPlacement){const e=h(n.gridPlacement,`${t}.gridPlacement`);A(e,["column","row","columnSpan","rowSpan"],`${t}.gridPlacement`),C(e.column,0,1e6,`${t}.gridPlacement.column`),C(e.row,0,1e6,`${t}.gridPlacement.row`),D(e.columnSpan,1,1e6,`${t}.gridPlacement.columnSpan`),D(e.rowSpan,1,1e6,`${t}.gridPlacement.rowSpan`)}if(void 0!==n.reflow){const e=h(n.reflow,`${t}.reflow`);A(e,["duration","easing"],`${t}.reflow`),O(e.duration,`${t}.reflow.duration`),P(e.easing,4,`${t}.reflow.easing`)}})(c.style,`${t}.style`),void 0!==c.visual&&function(e,t){const n=h(e,t);A(n,["opacity","background","borderColor","borderWidth","cornerRadius","clip"],t),R(n.opacity,0,1,`${t}.opacity`),void 0!==n.background&&V(n.background,`${t}.background`);void 0!==n.borderColor&&V(n.borderColor,`${t}.borderColor`);B(n.borderWidth,4,`${t}.borderWidth`,0),B(n.cornerRadius,4,`${t}.cornerRadius`,0),U(n.clip,`${t}.clip`)}(c.visual,`${t}.visual`);B(c.intrinsicSize,2,`${t}.intrinsicSize`,0),"text"===d?G(c.text,s,`${t}.text`):"image"===d?G(c.asset,i,`${t}.asset`):"component"===d?function(e,t,n){const o=h(e,t);if(A(o,["artboard","fit","alignment","sizing","playback","exposedInputs","exposedEvents"],t),G(o.artboard,n,`${t}.artboard`),L(o.fit,["fill","contain","cover","none","scale-down"],`${t}.fit`),B(o.alignment,2,`${t}.alignment`,-1,1),L(o.sizing,["node","leaf","layout"],`${t}.sizing`),void 0!==o.playback){const e=h(o.playback,`${t}.playback`);A(e,["mode","speed","paused","quantize","stateful","remapPort","mixPort"],`${t}.playback`);const n=H(e.mode,["simple","remap","mix"],`${t}.playback.mode`);S(e.speed,`${t}.playback.speed`),U(e.paused,`${t}.playback.paused`),w(e.quantize,`${t}.playback.quantize`),U(e.stateful,`${t}.playback.stateful`),x(e.remapPort,`${t}.playback.remapPort`),x(e.mixPort,`${t}.playback.mixPort`),("remap"===n&&void 0===e.remapPort||"mix"===n&&void 0===e.mixPort)&&q("E_LAYOUT_FORMAT",`${t}.playback`,`${n} playback requires its input port`)}for(const e of["exposedInputs","exposedEvents"])_(o[e],`${t}.${e}`).forEach((n,o)=>T(n,`${t}.${e}[${o}]`))}(c.component,`${t}.component`,o):"list"===d?function(e,t,n,o){const i=h(e,t);A(i,["dataPort","templateArtboard","direction","itemExtent","gap","virtualize","buffer","carousel"],t),T(i.dataPort,`${t}.dataPort`),G(i.templateArtboard,n,`${t}.templateArtboard`),H(i.direction,["row","column"],`${t}.direction`),N(i.itemExtent,`${t}.itemExtent`),k(i.gap,`${t}.gap`),U(i.virtualize,`${t}.virtualize`),D(i.buffer,0,o.maxVirtualizedWindow,`${t}.buffer`),U(i.carousel,`${t}.carousel`)}(c.list,`${t}.list`,o,r):"n-slice"===d&&function(e,t,n,o,i){const s=h(e,t);A(s,["source","sourceSize","xCuts","yCuts","tileModes"],t);const r=h(s.source,`${t}.source`),a=H(r.kind,["asset","node"],`${t}.source.kind`);A(r,"asset"===a?["kind","asset"]:["kind","node"],`${t}.source`),"asset"===a?G(r.asset,o,`${t}.source.asset`):G(r.node,n,`${t}.source.node`);const c=P(s.sourceSize,2,`${t}.sourceSize`,Number.EPSILON),d=y(s.xCuts,`${t}.xCuts`),u=y(s.yCuts,`${t}.yCuts`);f(d,c[0],`${t}.xCuts`),f(u,c[1],`${t}.yCuts`),i.nSlicePatches+=(d.length+1)*(u.length+1),_(s.tileModes,`${t}.tileModes`).forEach((e,n)=>H(e,["stretch","repeat","mirror"],`${t}.tileModes[${n}]`))}(c.nSlice,`${t}.nSlice`,n,i,a);void 0!==c.scroll&&function(e,t,n){const o=h(e,t);if(A(o,["axis","mode","snap","friction","elasticity","scrollbar"],t),H(o.axis,["x","y","both"],`${t}.axis`),L(o.mode,["clamped","elastic","infinite"],`${t}.mode`),w(o.snap,`${t}.snap`),k(o.friction,`${t}.friction`),k(o.elasticity,`${t}.elasticity`),void 0!==o.scrollbar){const e=h(o.scrollbar,`${t}.scrollbar`);A(e,["node","autoSize"],`${t}.scrollbar`),G(e.node,n,`${t}.scrollbar.node`),U(e.autoSize,`${t}.scrollbar.autoSize`)}}(c.scroll,`${t}.scroll`,n)}(e,`${t}.nodes[${a}]`,d,n,o,i,s,r));const $=new Map;for(const e of c){const n=h(e,`${t}.nodes[]`),o=n.id,i=n.parent;void 0===i||d.has(i)||q("E_LAYOUT_REFERENCE",t,`unknown parent ${i}`),o===l&&void 0!==i&&q("E_LAYOUT_REFERENCE",`${t}.root`,"root must not have a parent"),$.set(o,void 0===i?[]:[i])}g($,`${t}.nodes`,s.maxNestedDepth),function(e,t){const n=new Map;for(const o of e){const e=h(o,`${t}.nodes[]`),i=e.parent;if(i){const t=n.get(i)??[];t.push(e),n.set(i,t)}}for(const o of e){const e=h(o,`${t}.nodes[]`),i=h(e.style,`${t}.nodes[].style`);for(const o of["width","height"]){const s=void 0===i[o]?void 0:h(i[o],"$length");if("hug"===s?.unit)for(const i of n.get(e.id)??[]){const e=h(i.style,"$child.style"),n=void 0===e[o]?void 0:h(e[o],"$length");"percent"!==n?.unit&&"fill"!==n?.unit||q("E_LAYOUT_OSCILLATION",t,`${o} hug depends on a child ${n.unit}`)}}}}(c,t)}(e,`$.artboards[${t}]`,ne,Z,te,n,X)),z(X.nodes,n.maxNodes,"$.nodes"),z(X.nSlicePatches,n.maxNslicePatches,"$.nSlicePatches"),function(e,t,n){const o=new Map;for(const t of e){const e=h(t,"$.artboards[]"),n=[];for(const t of E(e.nodes,"$.artboards[].nodes")){const e=h(t,"$.artboards[].nodes[]");"component"===e.kind&&n.push(h(e.component,"$.component").artboard),"list"===e.kind&&n.push(h(e.list,"$.list").templateArtboard)}o.set(e.id,n)}for(const e of o.values())for(const n of e)t.has(n)||q("E_LAYOUT_REFERENCE","$.artboards",`unknown artboard ${n}`);g(o,"$.artboards",n)}(J,ne,n.maxNestedDepth);const oe=new Set;return K.forEach((e,t)=>{const n=`$.instances[${t}]`,o=h(e,n);A(o,["id","artboard","fit","alignment","transform"],n);const i=T(o.id,`${n}.id`);Y(oe,i,`${n}.id`),G(o.artboard,ne,`${n}.artboard`),L(o.fit,["fill","contain","cover","none","scale-down"],`${n}.fit`),B(o.alignment,2,`${n}.alignment`,-1,1),B(o.transform,6,`${n}.transform`)}),W(structuredClone(o))}function d(e,t){const n=h(e,t);if(A(n,["glyphId","advance","bounds","axisAdvance"],t),C(n.glyphId,0,4294967295,`${t}.glyphId`),O(n.advance,`${t}.advance`),P(n.bounds,4,`${t}.bounds`),void 0!==n.axisAdvance)for(const[e,o]of Object.entries(h(n.axisAdvance,`${t}.axisAdvance`)))p(e,`${t}.axisAdvance.${e}`),v(o,`${t}.axisAdvance.${e}`)}function u(e,t){const n=h(e,t),o=H(n.unit,["point","percent","fraction","hug","fill"],`${t}.unit`);return A(n,"hug"===o||"fill"===o?["unit"]:["unit","value"],t),"hug"!==o&&"fill"!==o&&O(n.value,`${t}.value`),n}function l(e,t){const n=h(e,t),o=H(n.kind,["solid","linear-gradient","radial-gradient"],`${t}.kind`);if(A(n,"solid"===o?["kind","color"]:"linear-gradient"===o?["kind","start","end","stops"]:["kind","center","radius","stops"],t),"solid"===o)V(n.color,`${t}.color`);else{"linear-gradient"===o?(P(n.start,2,`${t}.start`),P(n.end,2,`${t}.end`)):(P(n.center,2,`${t}.center`),N(n.radius,`${t}.radius`));const e=E(n.stops,`${t}.stops`);e.length<2&&q("E_LAYOUT_FORMAT",`${t}.stops`,"gradient requires at least two stops");let i=-1/0;e.forEach((e,n)=>{const o=h(e,`${t}.stops[${n}]`);A(o,["offset","color"],`${t}.stops[${n}]`);const s=M(o.offset,0,1,`${t}.stops[${n}].offset`);s<i&&q("E_LAYOUT_FORMAT",`${t}.stops`,"gradient stops must be ordered"),i=s,V(o.color,`${t}.stops[${n}].color`)})}return n}function $(e,t,n){if(void 0!==e)for(const[o,i]of Object.entries(h(e,t)))p(o,`${t}.${o}`),n&&"boolean"==typeof i||v(i,`${t}.${o}`)}function p(e,t){/^[\x20-\x7e]{4}$/.test(e)||q("E_LAYOUT_SHAPING",t,"OpenType tags must contain exactly four printable ASCII characters")}function m(e,t){const n=b(e,t);return/^sha256-(?:[A-Za-z0-9+/]{43}=|[a-f0-9]{64})$/.test(n)||q("E_LAYOUT_ASSET_INTEGRITY",t,"integrity must be sha256-base64 or sha256-hex"),n}function f(e,t,n){let o=0;for(const[i,s]of e.entries())s>o&&s<t||q("E_LAYOUT_FORMAT",`${n}[${i}]`,"cuts must be strictly increasing and inside the source extent"),o=s}function g(e,t,n){const o=new Map,i=(s,r)=>{if(r>n&&q("E_LAYOUT_LIMIT",t,`graph depth exceeds ${n}`),1===o.get(s)&&q("E_LAYOUT_CYCLE",t,`cycle includes ${s}`),2!==o.get(s)){o.set(s,1);for(const t of e.get(s)??[])i(t,r+1);o.set(s,2)}};for(const t of e.keys())i(t,1)}function h(e,t){return(!e||"object"!=typeof e||Array.isArray(e)||ArrayBuffer.isView(e))&&q("E_LAYOUT_FORMAT",t,"expected object"),e}function E(e,t){return Array.isArray(e)||q("E_LAYOUT_FORMAT",t,"expected array"),e}function _(e,t){return void 0===e?[]:E(e,t)}function y(e,t){return E(e,t).map((e,n)=>v(e,`${t}[${n}]`))}function A(e,t,n){for(const o of Object.keys(e))t.includes(o)||q("E_LAYOUT_FORMAT",`${n}.${o}`,"unknown property")}function b(e,t){return"string"!=typeof e&&q("E_LAYOUT_FORMAT",t,"expected string"),e}function T(e,t){const n=b(e,t);return(0===n.length||n.length>1024)&&q("E_LAYOUT_FORMAT",t,"identifier length must be 1..1024"),n}function x(e,t){return void 0===e?void 0:T(e,t)}function I(e,t){void 0!==e&&b(e,t)}function v(e,t){return"number"==typeof e&&Number.isFinite(e)||q("E_LAYOUT_NUMBER",t,"expected finite number"),e}function N(e,t){const n=v(e,t);return n<=0&&q("E_LAYOUT_NUMBER",t,"expected positive number"),n}function O(e,t){const n=v(e,t);return n<0&&q("E_LAYOUT_NUMBER",t,"expected non-negative number"),n}function M(e,t,n,o){const i=v(e,o);return(i<t||i>n)&&q("E_LAYOUT_NUMBER",o,`expected ${t}..${n}`),i}function S(e,t){void 0!==e&&v(e,t)}function w(e,t){void 0!==e&&N(e,t)}function k(e,t){void 0!==e&&O(e,t)}function R(e,t,n,o){void 0!==e&&M(e,t,n,o)}function C(e,t,n,o){const i=v(e,o);return(!Number.isSafeInteger(i)||i<t||i>n)&&q("E_LAYOUT_NUMBER",o,`expected integer ${t}..${n}`),i}function D(e,t,n,o){void 0!==e&&C(e,t,n,o)}function P(e,t,n,o=-1/0,i=1/0){const s=E(e,n);return s.length!==t&&q("E_LAYOUT_FORMAT",n,`expected ${t}-tuple`),s.map((e,t)=>M(e,o,i,`${n}[${t}]`))}function B(e,t,n,o=-1/0,i=1/0){void 0!==e&&P(e,t,n,o,i)}function F(e,t,n){const o=E(e,n);o.length!==t&&q("E_LAYOUT_FORMAT",n,`expected ${t} layout lengths`),o.forEach((e,t)=>u(e,`${n}[${t}]`))}function V(e,t){P(e,4,t,0,1)}function U(e,t){void 0!==e&&function(e,t){"boolean"!=typeof e&&q("E_LAYOUT_FORMAT",t,"expected boolean")}(e,t)}function H(e,t,n){return"string"==typeof e&&t.includes(e)||q("E_LAYOUT_FORMAT",n,`expected ${t.join("|")}`),e}function L(e,t,n){void 0!==e&&H(e,t,n)}function j(e,t,n){e!==t&&q("E_LAYOUT_FORMAT",n,`expected ${String(t)}`)}function G(e,t,n){const o=T(e,n);return t.has(o)||q("E_LAYOUT_REFERENCE",n,`unknown reference ${o}`),o}function Y(e,t,n){e.has(t)&&q("E_LAYOUT_REFERENCE",n,`duplicate id ${t}`),e.add(t)}function z(e,t,n){(!Number.isFinite(e)||e>t)&&q("E_LAYOUT_LIMIT",n,`limit ${t} exceeded by ${e}`)}function q(e,t,n){throw new r(e,t,n)}function W(e){if(e&&"object"==typeof e&&!ArrayBuffer.isView(e)&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))W(t)}return e}class J extends Error{code;path;name="DataBindingDiagnostic";constructor(e,t,n){super(`${n} (${t})`),this.code=e,this.path=t}}function K(e,t,n){throw new J(e,t,n)}const X=Object.freeze({maxEnums:1e5,maxEnumValues:1e6,maxModels:1e5,maxProperties:1e6,maxInstances:25e4,maxListItems:1e5,maxBindings:1e6,maxConverters:1e5,maxOperations:1e6,maxPathDepth:128,maxStringBytes:4194304,maxTotalTextBytes:33554432});function Z(e,t={}){const n=function(e={}){const t={...X,...e};for(const[e,n]of Object.entries(t))(!Number.isSafeInteger(n)||n<1)&&K("E_DATA_BINDING_LIMIT",`$.limits.${e}`,"limit must be a positive safe integer");return Object.freeze(t)}(t.limits),o=ae(e,"$");de(o,["format","version","extension","enums","models","instances","converters","propertyGroups","bindings","components"],"$"),ue(o.format,"haiyue-data-binding","$.format"),ue(o.version,1,"$.version"),ue(o.extension,"org.haiyue.data-binding@1","$.extension");const i=ce(o.enums,"$.enums"),s=ce(o.models,"$.models"),r=ce(o.instances,"$.instances"),a=ce(o.converters,"$.converters"),c=ce(o.propertyGroups,"$.propertyGroups"),d=ce(o.bindings,"$.bindings"),u=ce(o.components,"$.components");Ae(i.length,n.maxEnums,"$.enums"),Ae(s.length,n.maxModels,"$.models"),Ae(r.length,n.maxInstances,"$.instances"),Ae(a.length,n.maxConverters,"$.converters"),Ae(d.length,n.maxBindings,"$.bindings");const l={enumValues:0,properties:0,listItems:0,operations:0,textBytes:0},$=te(i,"$.enums"),p=te(s,"$.models"),m=te(r,"$.instances"),f=te(a,"$.converters");te(c,"$.propertyGroups"),te(u,"$.components");const g=new Map;i.forEach((e,t)=>{const o=`$.enums[${t}]`,i=ae(e,o);de(i,["id","values"],o),$e(i.id,`${o}.id`,l,n.maxStringBytes);const s=ce(i.values,`${o}.values`),r=new Set,a=new Set;l.enumValues+=s.length,Ae(l.enumValues,n.maxEnumValues,"$.enumValues"),s.forEach((e,t)=>{const i=`${o}.values[${t}]`,s=ae(e,i);de(s,["key","value"],i);const c=$e(s.key,`${i}.key`,l,n.maxStringBytes),d=he(s.value,`${i}.value`);(a.has(c)||r.has(d))&&K("E_DATA_BINDING_FORMAT",i,"enum keys and values must be unique"),a.add(c),r.add(d)}),g.set(i.id,r)});const h=new Map;s.forEach((e,t)=>{const o=`$.models[${t}]`,i=ae(e,o);de(i,["id","properties","defaultInstance"],o);const s=$e(i.id,`${o}.id`,l,n.maxStringBytes),r=ce(i.properties,`${o}.properties`),a=new Set,c=new Map;l.properties+=r.length,Ae(l.properties,n.maxProperties,"$.properties"),r.forEach((e,t)=>{const i=`${o}.properties[${t}]`,s=function(e,t,n,o,i,s){const r=ae(e,t);de(r,["id","kind","enum","model","item","defaultValue","nullable"],t);const a=$e(r.id,`${t}.id`,i,s),c=le(r.kind,["number","integer","string","boolean","color","trigger","enum","model","list","image","artboard","font","blob"],`${t}.kind`);"enum"===c?me(r.enum,n,`${t}.enum`):void 0!==r.enum&&K("E_DATA_BINDING_FORMAT",`${t}.enum`,"enum is only valid for enum properties");"model"===c?me(r.model,o,`${t}.model`):void 0!==r.model&&K("E_DATA_BINDING_FORMAT",`${t}.model`,"model is only valid for model properties");if("list"===c){const e=ae(r.item,`${t}.item`);de(e,["kind","enum","model"],`${t}.item`);const i=le(e.kind,["number","integer","string","boolean","color","enum","model","image","artboard","font","blob"],`${t}.item.kind`);"enum"===i&&me(e.enum,n,`${t}.item.enum`),"model"===i&&me(e.model,o,`${t}.item.model`)}else void 0!==r.item&&K("E_DATA_BINDING_FORMAT",`${t}.item`,"item is only valid for list properties");void 0!==r.nullable&&"boolean"!=typeof r.nullable&&K("E_DATA_BINDING_TYPE",`${t}.nullable`,"nullable must be boolean");return{...r,id:a,kind:c}}(e,i,$,p,l,n.maxStringBytes);a.has(s.id)&&K("E_DATA_BINDING_FORMAT",`${i}.id`,"duplicate property id"),void 0!==s.defaultValue&&Q(s.defaultValue,s,`${i}.defaultValue`,g,m,l,n),a.add(s.id),c.set(s.id,s)}),fe(i.defaultInstance,m,`${o}.defaultInstance`),h.set(s,c)}),function(e,t){const n=(o,i,s)=>{s>t&&K("E_DATA_BINDING_LIMIT","$.models","model depth exceeds budget"),i.has(o)&&K("E_DATA_BINDING_GRAPH","$.models",`model cycle through ${o}`);const r=new Set(i).add(o);for(const t of e.get(o)?.values()??[]){const e="model"===t.kind?t.model:"list"===t.kind&&"model"===t.item?.kind?t.item.model:void 0;e&&n(e,r,s+1)}};for(const t of e.keys())n(t,new Set,1)}(h,n.maxPathDepth),r.forEach((e,t)=>{const o=`$.instances[${t}]`,i=ae(e,o);de(i,["id","model","scope","values"],o),$e(i.id,`${o}.id`,l,n.maxStringBytes);const s=me(i.model,p,`${o}.model`);le(i.scope,["default","global","local"],`${o}.scope`);const r=ae(i.values,`${o}.values`),a=h.get(s);for(const[e,t]of Object.entries(r)){const i=a.get(e);i||K("E_DATA_BINDING_PATH",`${o}.values.${e}`,"unknown model property"),Q(t,i,`${o}.values.${e}`,g,m,l,n)}});const E=new Map(r.map((e,t)=>{const n=ae(e,`$.instances[${t}]`);return[n.id,n]}));return function(e,t,n){const o=new Set;t.forEach((e,t)=>{const n=ae(e,`$.instances[${t}]`),i=n.scope;if("default"===i||"global"===i){const e=`${n.model}:${i}`;o.has(e)&&K("E_DATA_BINDING_FORMAT",`$.instances[${t}].scope`,`model ${n.model} has multiple ${i} instances`),o.add(e)}}),e.forEach((e,t)=>{const o=ae(e,`$.models[${t}]`);if(void 0!==o.defaultInstance){const e=n.get(o.defaultInstance);e&&e.model===o.id&&"default"===e.scope||K("E_DATA_BINDING_REFERENCE",`$.models[${t}].defaultInstance`,"default instance must use the same model and default scope")}})}(s,r,E),function(e,t,n,o){const i=(e,t,n)=>{if(null!=e)if("model"===t.kind){const i=o.get(e);i&&i.model===t.model||K("E_DATA_BINDING_REFERENCE",n,`expected ${t.model} instance`)}else"list"===t.kind&&"model"===t.item?.kind&&ce(e,n).forEach((e,i)=>{const s=o.get(e);s&&s.model===t.item.model||K("E_DATA_BINDING_REFERENCE",`${n}[${i}]`,`expected ${t.item.model} instance`)})};e.forEach((e,t)=>{const o=ae(e,`$.models[${t}]`);for(const e of n.get(o.id)?.values()??[])i(e.defaultValue,e,`$.models[${t}].properties.${e.id}.defaultValue`)}),t.forEach((e,t)=>{const o=ae(e,`$.instances[${t}]`),s=ae(o.values,`$.instances[${t}].values`);for(const e of n.get(o.model)?.values()??[])i(s[e.id],e,`$.instances[${t}].values.${e.id}`)})}(s,r,h,E),a.forEach((e,t)=>function(e,t,n,o,i){const s=ae(e,t);de(s,["id","version","operations"],t),$e(s.id,`${t}.id`,o,i.maxStringBytes),ue(s.version,1,`${t}.version`);const r=ce(s.operations,`${t}.operations`);o.operations+=r.length,Ae(o.operations,i.maxOperations,"$.operations"),r.forEach((e,s)=>{const r=`${t}.operations[${s}]`,a=ae(e,r),c=le(a.op,["round","to-string","to-number","boolean-not","degrees-to-radians","normalize","range-map","string-pad","string-trim","remove-trailing-zeros","list-length","number-to-list","to-trigger","interpolate","formula","custom"],`${r}.op`);if(de(a,["op",...{round:["decimals"],"to-string":["decimals","colorFormat"],"to-number":[],"boolean-not":[],"degrees-to-radians":[],normalize:["minimum","maximum"],"range-map":["input","output","clamp"],"string-pad":["length","text","side"],"string-trim":["side"],"remove-trailing-zeros":[],"list-length":[],"number-to-list":["model"],"to-trigger":["mode"],interpolate:["duration","easing"],formula:["tokens"],custom:["protocol","port","arguments"]}[c]],r),"round"===c)_e(a.decimals,0,20,`${r}.decimals`);else if("to-string"===c)!function(e,t,n,o){void 0!==e&&_e(e,t,n,o)}(a.decimals,0,20,`${r}.decimals`),function(e,t,n){void 0!==e&&le(e,t,n)}(a.colorFormat,["hex","rgba"],`${r}.colorFormat`);else if("normalize"===c){ge(a.minimum,`${r}.minimum`)===ge(a.maximum,`${r}.maximum`)&&K("E_DATA_BINDING_NUMBER",r,"normalizer range must be non-degenerate")}else if("range-map"===c){const e=ye(a.input,2,`${r}.input`);ye(a.output,2,`${r}.output`),e[0]===e[1]&&K("E_DATA_BINDING_NUMBER",`${r}.input`,"range must be non-degenerate"),function(e,t){void 0!==e&&"boolean"!=typeof e&&K("E_DATA_BINDING_TYPE",t,"expected boolean")}(a.clamp,`${r}.clamp`)}else"string-pad"===c?(_e(a.length,0,i.maxStringBytes,`${r}.length`),pe(a.text,`${r}.text`,o,i.maxStringBytes),le(a.side,["start","end"],`${r}.side`)):"string-trim"===c?le(a.side,["start","end","both"],`${r}.side`):"number-to-list"===c?me(a.model,n,`${r}.model`):"to-trigger"===c?le(a.mode,["change","rising","falling","truthy"],`${r}.mode`):"interpolate"===c?(!function(e,t){const n=ge(e,t);n<0&&K("E_DATA_BINDING_NUMBER",t,"expected non-negative number")}(a.duration,`${r}.duration`),ye(a.easing,4,`${r}.easing`)):"formula"===c?ce(a.tokens,`${r}.tokens`).forEach((e,t)=>{const n=`${r}.tokens[${t}]`,s=ae(e,n);de(s,["kind","value"],n);const a=le(s.kind,["value","input","operator","function"],`${n}.kind`);if("number"!=typeof s.value){const e=pe(s.value,`${n}.value`,o,i.maxStringBytes);"operator"!==a||["+","-","*","/","%","^"].includes(e)||K("E_DATA_BINDING_FORMAT",`${n}.value`,"unknown formula operator"),"function"!==a||["abs","floor","ceil","sqrt"].includes(e)||K("E_DATA_BINDING_FORMAT",`${n}.value`,"unknown formula function")}else ge(s.value,`${n}.value`)}):"custom"===c&&($e(a.protocol,`${r}.protocol`,o,i.maxStringBytes),$e(a.port,`${r}.port`,o,i.maxStringBytes),void 0!==a.arguments&&se(a.arguments,`${r}.arguments`,i.maxPathDepth))})}(e,`$.converters[${t}]`,p,l,n)),c.forEach((e,t)=>{const o=`$.propertyGroups[${t}]`,i=ae(e,o);de(i,["id","version","operations"],o),$e(i.id,`${o}.id`,l,n.maxStringBytes),ue(i.version,1,`${o}.version`);const s=ce(i.operations,`${o}.operations`);l.operations+=s.length,Ae(l.operations,n.maxOperations,"$.operations"),s.forEach((e,t)=>function(e,t,n,o){const i=ae(e,t),s=le(i.op,["set","copy","trigger","list-insert","list-remove","list-move"],`${t}.op`);de(i,["op",...{set:["path","value"],copy:["from","path"],trigger:["path"],"list-insert":["path","index","value"],"list-remove":["path","index"],"list-move":["path","from","to"]}[s]],t),ne(i.path,`${t}.path`,n,o),"copy"===s&&ne(i.from,`${t}.from`,n,o);"set"!==s&&"list-insert"!==s||se(i.value,`${t}.value`,o.maxPathDepth);"index"in i&&Ee(i.index,`${t}.index`);"from"in i&&"list-move"===s&&Ee(i.from,`${t}.from`);"to"in i&&Ee(i.to,`${t}.to`)}(e,`${o}.operations[${t}]`,l,n))}),d.forEach((e,t)=>{const o=`$.bindings[${t}]`,i=ae(e,o);de(i,["id","target","targetPath","source","converter","direction"],o),$e(i.id,`${o}.id`,l,n.maxStringBytes),$e(i.target,`${o}.target`,l,n.maxStringBytes),function(e,t,n,o){const i=ce(e,t);Ae(i.length,o.maxPathDepth,t),i.forEach((e,i)=>$e(e,`${t}[${i}]`,n,o.maxStringBytes))}(i.targetPath,`${o}.targetPath`,l,n),le(i.direction,["read","write","two-way"],`${o}.direction`),fe(i.converter,f,`${o}.converter`);const s=ae(i.source,`${o}.source`);de(s,["mode","instance","model","path"],`${o}.source`);const r=le(s.mode,["explicit","default","global","auto"],`${o}.source.mode`);"explicit"===r?me(s.instance,m,`${o}.source.instance`):void 0!==s.instance&&K("E_DATA_BINDING_FORMAT",`${o}.source.instance`,"instance is only valid for explicit binding"),"explicit"!==r?me(s.model,p,`${o}.source.model`):fe(s.model,p,`${o}.source.model`);0===ne(s.path,`${o}.source.path`,l,n).length&&K("E_DATA_BINDING_PATH",`${o}.source.path`,"binding path must not be empty")}),function(e,t,n){e.forEach((e,o)=>{const i=`$.bindings[${o}]`,s=ae(e,i);0===ce(s.targetPath,`${i}.targetPath`).length&&K("E_DATA_BINDING_PATH",`${i}.targetPath`,"target path must not be empty");const r=ae(s.source,`${i}.source`),a=ce(r.path,`${i}.source.path`),c="explicit"===r.mode?n.get(r.instance):void 0,d=c?.model??r.model;c&&void 0!==r.model&&r.model!==d&&K("E_DATA_BINDING_REFERENCE",`${i}.source.model`,"explicit source model does not match its instance");let u=d;for(let e=0;e<a.length;e++){const n=a[e];"string"!=typeof n&&K("E_DATA_BINDING_PATH",`${i}.source.path[${e}]`,"model property segment must be a string");const o=t.get(u)?.get(n);if(o||K("E_DATA_BINDING_PATH",`${i}.source.path[${e}]`,`unknown property ${n}`),e===a.length-1)break;if("model"===o.kind)u=o.model;else if("list"===o.kind){"number"!=typeof a[++e]&&K("E_DATA_BINDING_PATH",`${i}.source.path[${e}]`,"list path requires a numeric index"),e<a.length-1&&("model"!==o.item?.kind&&K("E_DATA_BINDING_PATH",`${i}.source.path`,"path continues through a scalar list item"),u=o.item.model)}else K("E_DATA_BINDING_PATH",`${i}.source.path`,"path continues through a scalar property")}})}(d,h,E),u.forEach((e,t)=>{const o=`$.components[${t}]`,i=ae(e,o);de(i,["id","stateful","model","exposedProperties","exposedInputs","exposedEvents"],o),$e(i.id,`${o}.id`,l,n.maxStringBytes),ue(i.stateful,!0,`${o}.stateful`);const s=me(i.model,p,`${o}.model`),r=h.get(s);oe(i.exposedProperties,`${o}.exposedProperties`,l,n,e=>{r.has(e)||K("E_DATA_BINDING_REFERENCE",`${o}.exposedProperties`,`unknown property ${e}`)}),oe(i.exposedInputs,`${o}.exposedInputs`,l,n),oe(i.exposedEvents,`${o}.exposedEvents`,l,n)}),Ae(l.listItems,n.maxListItems,"$.listItems"),Ae(l.textBytes,n.maxTotalTextBytes,"$.textBytes"),ie(o,"$",n.maxPathDepth),re(structuredClone(o))}function Q(e,t,n,o,i,s,r){null===e&&t.nullable||ee(e,t.kind,n,t.enum,t.item,o,i,s,r)}function ee(e,t,n,o,i,s,r,a,c){if("number"===t)ge(e,n);else if("integer"===t)he(e,n);else if("string"===t)pe(e,n,a,c.maxStringBytes);else if("boolean"===t||"trigger"===t)"boolean"!=typeof e&&K("E_DATA_BINDING_TYPE",n,"expected boolean");else if("color"===t)ye(e,4,n).forEach((e,t)=>function(e,t,n,o){const i=ge(e,o);(i<t||i>n)&&K("E_DATA_BINDING_NUMBER",o,`expected ${t}..${n}`);return i}(e,0,1,`${n}[${t}]`));else if("enum"===t){const t=he(e,n);s.get(o)?.has(t)||K("E_DATA_BINDING_TYPE",n,"enum value is outside its domain")}else if("model"===t)null!==e&&me(e,r,n);else if("list"===t){const t=ce(e,n);a.listItems+=t.length,Ae(a.listItems,c.maxListItems,"$.listItems"),t.forEach((e,t)=>ee(e,i.kind,`${n}[${t}]`,i.enum,void 0,s,r,a,c))}else null!==e&&$e(e,n,a,c.maxStringBytes)}function te(e,t){const n=new Set;return e.forEach((e,o)=>{const i=$e(ae(e,`${t}[${o}]`).id,`${t}[${o}].id`);n.has(i)&&K("E_DATA_BINDING_FORMAT",`${t}[${o}].id`,"duplicate id"),n.add(i)}),n}function ne(e,t,n,o){const i=ce(e,t);return Ae(i.length,o.maxPathDepth,t),i.forEach((e,i)=>{"string"==typeof e?$e(e,`${t}[${i}]`,n,o.maxStringBytes):Ee(e,`${t}[${i}]`)}),i}function oe(e,t,n,o,i){if(void 0===e)return;const s=new Set;ce(e,t).forEach((e,r)=>{const a=$e(e,`${t}[${r}]`,n,o.maxStringBytes);s.has(a)&&K("E_DATA_BINDING_FORMAT",`${t}[${r}]`,"duplicate entry"),s.add(a),i?.(a)})}function ie(e,t,n){const o=new Set,i=(e,t,s)=>{if(s>n&&K("E_DATA_BINDING_LIMIT",t,"value depth exceeds budget"),e&&"object"==typeof e){if(o.has(e)&&K("E_DATA_BINDING_GRAPH",t,"cyclic value"),o.add(e),Array.isArray(e))e.forEach((e,n)=>i(e,`${t}[${n}]`,s+1));else for(const[n,o]of Object.entries(e))i(o,`${t}.${n}`,s+1);o.delete(e)}};i(e,t,0)}function se(e,t,n){ie(e,t,n);const o=(e,t)=>{if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e)if("number"!=typeof e)if(Array.isArray(e))e.forEach((e,n)=>o(e,`${t}[${n}]`));else if(e&&"object"==typeof e)for(const[n,i]of Object.entries(e))o(i,`${t}.${n}`);else K("E_DATA_BINDING_TYPE",t,"value must be JSON-compatible");else ge(e,t)};o(e,t)}function re(e){if(e&&"object"==typeof e&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))re(t)}return e}function ae(e,t){return e&&"object"==typeof e&&!Array.isArray(e)||K("E_DATA_BINDING_TYPE",t,"expected object"),e}function ce(e,t){return Array.isArray(e)||K("E_DATA_BINDING_TYPE",t,"expected array"),e}function de(e,t,n){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||K("E_DATA_BINDING_FORMAT",`${n}.${t}`,"unknown field")}function ue(e,t,n){e!==t&&K("E_DATA_BINDING_FORMAT",n,`expected ${String(t)}`)}function le(e,t,n){return"string"==typeof e&&t.includes(e)||K("E_DATA_BINDING_TYPE",n,`expected one of ${t.join(", ")}`),e}function $e(e,t,n,o=4194304){"string"==typeof e&&0!==e.length||K("E_DATA_BINDING_TYPE",t,"expected non-empty string");const i=(new TextEncoder).encode(e).length;return i>o&&K("E_DATA_BINDING_LIMIT",t,"string exceeds byte budget"),n&&(n.textBytes+=i),e}function pe(e,t,n,o){"string"!=typeof e&&K("E_DATA_BINDING_TYPE",t,"expected string");const i=(new TextEncoder).encode(e).length;return i>o&&K("E_DATA_BINDING_LIMIT",t,"string exceeds byte budget"),n.textBytes+=i,e}function me(e,t,n){const o=$e(e,n);return t.has(o)||K("E_DATA_BINDING_REFERENCE",n,`unknown reference ${o}`),o}function fe(e,t,n){void 0!==e&&me(e,t,n)}function ge(e,t){return"number"==typeof e&&Number.isFinite(e)||K("E_DATA_BINDING_NUMBER",t,"expected finite number"),e}function he(e,t){const n=ge(e,t);return Number.isSafeInteger(n)||K("E_DATA_BINDING_NUMBER",t,"expected safe integer"),n}function Ee(e,t){const n=he(e,t);return n<0&&K("E_DATA_BINDING_NUMBER",t,"expected non-negative integer"),n}function _e(e,t,n,o){const i=he(e,o);return(i<t||i>n)&&K("E_DATA_BINDING_NUMBER",o,`expected ${t}..${n}`),i}function ye(e,t,n){const o=ce(e,n);return o.length!==t&&K("E_DATA_BINDING_TYPE",n,`expected ${t} values`),o.map((e,t)=>ge(e,`${n}[${t}]`))}function Ae(e,t,n){e>t&&K("E_DATA_BINDING_LIMIT",n,`count ${e} exceeds ${t}`)}class be extends Error{code;path;name="InteractionDiagnostic";constructor(e,t,n){super(`${n} (${t})`),this.code=e,this.path=t}}function Te(e,t,n){throw new be(e,t,n)}const xe=Object.freeze({maxTargets:25e4,maxListeners:1e6,maxActions:4e6,maxPathDepth:128,maxEventQueue:1e6,maxEventRecursion:64,maxPointers:1024,maxPolygonPoints:1e6,maxStringBytes:4194304});function Ie(e,t={}){const n={...xe,...t.limits};for(const[e,t]of Object.entries(n))(!Number.isSafeInteger(t)||t<1)&&Te("E_INTERACTION_LIMIT",`$.limits.${e}`,"limit must be a positive safe integer");const o=Se(e,"$");if(ke(o,["format","version","extension","dragThreshold","targets","listeners","limits"],"$"),Re(o.format,"haiyue-interaction","$.format"),Re(o.version,1,"$.version"),Re(o.extension,"org.haiyue.interaction@1","$.extension"),function(e,t){const n=Fe(e,t);n<0&&Te("E_INTERACTION_NUMBER",t,"expected non-negative number")}(o.dragThreshold,"$.dragThreshold"),void 0!==o.limits){const e=Se(o.limits,"$.limits");ke(e,["maxEventQueue","maxEventRecursion","maxPointers"],"$.limits");for(const t of["maxEventQueue","maxEventRecursion","maxPointers"]){Ue(e[t],`$.limits.${t}`)>n[t]&&Te("E_INTERACTION_LIMIT",`$.limits.${t}`,"authored runtime budget exceeds host ceiling")}}const i=we(o.targets,"$.targets"),s=we(o.listeners,"$.listeners");Ge(i.length,n.maxTargets,"$.targets"),Ge(s.length,n.maxListeners,"$.listeners");const r=ve(i,"$.targets");ve(s,"$.listeners");let a=0,c=0;return i.forEach((e,t)=>{const o=`$.targets[${t}]`,i=Se(e,o);if(ke(i,["id","parent","component","order","transform","hitArea","clips","enabled","focusable","tabIndex"],o),De(i.id,`${o}.id`,n),function(e,t,n){void 0!==e&&Be(e,t,n)}(i.parent,r,`${o}.parent`),Pe(i.component,`${o}.component`,n),Ve(i.order,`${o}.order`),void 0!==i.transform){const e=He(i.transform,6,`${o}.transform`);Math.abs(e[0]*e[3]-e[1]*e[2])<1e-12&&Te("E_INTERACTION_NUMBER",`${o}.transform`,"transform must be invertible")}const s=Se(i.hitArea,`${o}.hitArea`),c=Ce(s.kind,["rect","ellipse","polygon","geometry"],`${o}.hitArea.kind`);if("rect"===c){ke(s,["kind","rect"],`${o}.hitArea`);const e=He(s.rect,4,`${o}.hitArea.rect`);(e[2]<0||e[3]<0)&&Te("E_INTERACTION_NUMBER",`${o}.hitArea.rect`,"rect size must be non-negative")}else if("ellipse"===c){ke(s,["kind","center","radius"],`${o}.hitArea`),He(s.center,2,`${o}.hitArea.center`);const e=He(s.radius,2,`${o}.hitArea.radius`);(e[0]<0||e[1]<0)&&Te("E_INTERACTION_NUMBER",`${o}.hitArea.radius`,"radius must be non-negative")}else if("polygon"===c){ke(s,["kind","points"],`${o}.hitArea`);const e=we(s.points,`${o}.hitArea.points`);e.length<3&&Te("E_INTERACTION_FORMAT",`${o}.hitArea.points`,"polygon requires at least three points"),a+=e.length,Ge(a,n.maxPolygonPoints,"$.polygonPoints"),e.forEach((e,t)=>He(e,2,`${o}.hitArea.points[${t}]`))}else ke(s,["kind","port"],`${o}.hitArea`),De(s.port,`${o}.hitArea.port`,n);void 0!==i.clips&&function(e,t,n){const o=new Set;we(e,n).forEach((e,i)=>{const s=Be(e,t,`${n}[${i}]`);o.has(s)&&Te("E_INTERACTION_FORMAT",`${n}[${i}]`,"duplicate reference"),o.add(s)})}(i.clips,r,`${o}.clips`),je(i.enabled,`${o}.enabled`),je(i.focusable,`${o}.focusable`),void 0!==i.tabIndex&&Ve(i.tabIndex,`${o}.tabIndex`)}),function(e,t){const n=new Map;e.forEach((e,t)=>{const o=Se(e,`$.targets[${t}]`);n.set(o.id,o.parent)});for(const e of n.keys()){const o=new Set;let i=e,s=0;for(;void 0!==i;)o.has(i)&&Te("E_INTERACTION_GRAPH","$.targets",`target cycle through ${i}`),++s>t&&Te("E_INTERACTION_LIMIT","$.targets","target depth exceeds budget"),o.add(i),i=n.get(i)}}(i,n.maxPathDepth),s.forEach((e,t)=>{const o=`$.listeners[${t}]`,i=Se(e,o);ke(i,["id","target","event","phases","pointerButton","key","keyPhase","modifiers","gamepad","semanticAction","actions"],o),De(i.id,`${o}.id`,n),Be(i.target,r,`${o}.target`);const s=Ce(i.event,["pointer-enter","pointer-exit","pointer-move","pointer-down","pointer-up","click","drag-start","drag","drag-end","keyboard","text-input","gamepad","focus","blur","data-change","reported-event","component-event","semantic-action"],`${o}.event`);if(Ne(i.phases,["capture","target","bubble"],`${o}.phases`),void 0!==i.pointerButton&&function(e,t,n,o){const i=Ve(e,o);(i<t||i>n)&&Te("E_INTERACTION_NUMBER",o,`expected ${t}..${n}`)}(i.pointerButton,0,31,`${o}.pointerButton`),Pe(i.key,`${o}.key`,n),Le(i.keyPhase,["down","up","repeat"],`${o}.keyPhase`),void 0!==i.modifiers&&Ne(i.modifiers,["alt","control","meta","shift"],`${o}.modifiers`,!0),void 0!==i.gamepad){const e=Se(i.gamepad,`${o}.gamepad`);ke(e,["index","control","phase"],`${o}.gamepad`),void 0!==e.index&&function(e,t){const n=Ve(e,t);n<0&&Te("E_INTERACTION_NUMBER",t,"expected non-negative integer")}(e.index,`${o}.gamepad.index`),De(e.control,`${o}.gamepad.control`,n),Ce(e.phase,["down","up","change"],`${o}.gamepad.phase`)}Le(i.semanticAction,["tap","increase","decrease","focus"],`${o}.semanticAction`),"keyboard"===s&&void 0===i.key&&Te("E_INTERACTION_FORMAT",`${o}.key`,"keyboard listener requires key"),"gamepad"===s&&void 0===i.gamepad&&Te("E_INTERACTION_FORMAT",`${o}.gamepad`,"gamepad listener requires descriptor"),"semantic-action"===s&&void 0===i.semanticAction&&Te("E_INTERACTION_FORMAT",`${o}.semanticAction`,"semantic listener requires action");const a=we(i.actions,`${o}.actions`);c+=a.length,Ge(c,n.maxActions,"$.actions"),a.forEach((e,t)=>function(e,t,n,o){const i=Se(e,t),s=Ce(i.kind,["data-set","data-trigger","property-group","state-input","state-control","report-event","audio","semantic","align-target","open-url","component-input","component-event","pointer-capture","pointer-release","focus","custom"],`${t}.kind`);ke(i,["kind",...{"data-set":["binding","value"],"data-trigger":["binding"],"property-group":["group"],"state-input":["machine","input","value"],"state-control":["machine","operation","value"],"report-event":["name","payload"],audio:["operation","target","value"],semantic:["operation","target","value"],"align-target":["target","alignment","preserveOffset"],"open-url":["url","target"],"component-input":["component","input","value"],"component-event":["component","event","payload"],"pointer-capture":[],"pointer-release":[],focus:["target"],custom:["protocol","port","arguments"]}[s]],t);for(const e of["binding","group","machine","input","name","target","component","event","protocol","port","url"])void 0!==i[e]&&De(i[e],`${t}.${e}`,o);"state-control"===s&&Ce(i.operation,["play","pause","resume","stop","reset"],`${t}.operation`);"audio"===s&&Ce(i.operation,["play","pause","stop","seek"],`${t}.operation`);"semantic"===s&&Ce(i.operation,["announce","focus","increment","decrement","activate"],`${t}.operation`);"align-target"===s&&(Be(i.target,n,`${t}.target`),He(i.alignment,2,`${t}.alignment`),"boolean"!=typeof i.preserveOffset&&Te("E_INTERACTION_FORMAT",`${t}.preserveOffset`,"expected boolean"));"open-url"===s&&Ce(i.target,["same-context","new-context"],`${t}.target`);"focus"===s&&void 0!==i.target&&Be(i.target,n,`${t}.target`);for(const e of["value","payload","arguments"])void 0!==i[e]&&Oe(i[e],`${t}.${e}`,o.maxPathDepth)}(e,`${o}.actions[${t}]`,r,n))}),Oe(o,"$",n.maxPathDepth),Me(structuredClone(o))}function ve(e,t){const n=new Set;return e.forEach((e,o)=>{const i=De(Se(e,`${t}[${o}]`).id,`${t}[${o}].id`,xe);n.has(i)&&Te("E_INTERACTION_FORMAT",`${t}[${o}].id`,"duplicate id"),n.add(i)}),n}function Ne(e,t,n,o=!1){const i=new Set,s=we(e,n);o||0!==s.length||Te("E_INTERACTION_FORMAT",n,"list must not be empty"),s.forEach((e,o)=>{const s=Ce(e,t,`${n}[${o}]`);i.has(s)&&Te("E_INTERACTION_FORMAT",`${n}[${o}]`,"duplicate entry"),i.add(s)})}function Oe(e,t,n){const o=new Set,i=(e,t,s)=>{if(s>n&&Te("E_INTERACTION_LIMIT",t,"value depth exceeds budget"),null!==e&&"string"!=typeof e&&"boolean"!=typeof e)if("number"!=typeof e){if(e&&"object"==typeof e||Te("E_INTERACTION_FORMAT",t,"value must be JSON-compatible"),o.has(e)&&Te("E_INTERACTION_GRAPH",t,"cyclic value"),o.add(e),Array.isArray(e))e.forEach((e,n)=>i(e,`${t}[${n}]`,s+1));else for(const[n,o]of Object.entries(e))i(o,`${t}.${n}`,s+1);o.delete(e)}else Fe(e,t)};i(e,t,0)}function Me(e){if(e&&"object"==typeof e&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))Me(t)}return e}function Se(e,t){return e&&"object"==typeof e&&!Array.isArray(e)||Te("E_INTERACTION_FORMAT",t,"expected object"),e}function we(e,t){return Array.isArray(e)||Te("E_INTERACTION_FORMAT",t,"expected array"),e}function ke(e,t,n){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||Te("E_INTERACTION_FORMAT",`${n}.${t}`,"unknown field")}function Re(e,t,n){e!==t&&Te("E_INTERACTION_FORMAT",n,`expected ${String(t)}`)}function Ce(e,t,n){return"string"==typeof e&&t.includes(e)||Te("E_INTERACTION_FORMAT",n,`expected one of ${t.join(", ")}`),e}function De(e,t,n){return"string"==typeof e&&0!==e.length||Te("E_INTERACTION_FORMAT",t,"expected non-empty string"),(new TextEncoder).encode(e).length>n.maxStringBytes&&Te("E_INTERACTION_LIMIT",t,"string exceeds byte budget"),e}function Pe(e,t,n){void 0!==e&&De(e,t,n)}function Be(e,t,n){const o=De(e,n,xe);return t.has(o)||Te("E_INTERACTION_REFERENCE",n,`unknown reference ${o}`),o}function Fe(e,t){return"number"==typeof e&&Number.isFinite(e)||Te("E_INTERACTION_NUMBER",t,"expected finite number"),e}function Ve(e,t){const n=Fe(e,t);return Number.isSafeInteger(n)||Te("E_INTERACTION_NUMBER",t,"expected safe integer"),n}function Ue(e,t){const n=Ve(e,t);return n<1&&Te("E_INTERACTION_NUMBER",t,"expected positive integer"),n}function He(e,t,n){const o=we(e,n);return o.length!==t&&Te("E_INTERACTION_FORMAT",n,`expected ${t} values`),o.map((e,t)=>Fe(e,`${n}[${t}]`))}function Le(e,t,n){void 0!==e&&Ce(e,t,n)}function je(e,t){void 0!==e&&"boolean"!=typeof e&&Te("E_INTERACTION_FORMAT",t,"expected boolean")}function Ge(e,t,n){e>t&&Te("E_INTERACTION_LIMIT",n,`count ${e} exceeds ${t}`)}class Ye extends Error{code;path;name="SemanticsDiagnostic";constructor(e,t,n){super(`${n} (${t})`),this.code=e,this.path=t}}function ze(e,t,n){throw new Ye(e,t,n)}function qe(e,t={}){const n=ot(t.maxNodes??25e4,"$.limits.maxNodes"),o=ot(t.maxDepth??128,"$.limits.maxDepth"),i=ot(t.maxStringBytes??4194304,"$.limits.maxStringBytes"),s=Ke(e,"$");Ze(s,["format","version","extension","nodes","reducedMotion"],"$"),Qe(s.format,"haiyue-semantics","$.format"),Qe(s.version,1,"$.version"),Qe(s.extension,"org.haiyue.semantics@1","$.extension");const r=Xe(s.nodes,"$.nodes");r.length>n&&ze("E_SEMANTICS_LIMIT","$.nodes","node count exceeds budget");const a=new Set;r.forEach((e,t)=>{const n=tt(Ke(e,`$.nodes[${t}]`).id,`$.nodes[${t}].id`,i);a.has(n)&&ze("E_SEMANTICS_FORMAT",`$.nodes[${t}].id`,"duplicate id"),a.add(n)}),r.forEach((e,t)=>{const n=`$.nodes[${t}]`,o=Ke(e,n);Ze(o,["id","target","parent","role","label","value","hint","headingLevel","traits","state","capabilities","actions","live","readingOrder","navigationOrder"],n),tt(o.id,`${n}.id`,i),tt(o.target,`${n}.target`,i),void 0!==o.parent&&function(e,t,n){const o=tt(e,n,4194304);t.has(o)||ze("E_SEMANTICS_REFERENCE",n,`unknown reference ${o}`)}(o.parent,a,`${n}.parent`);const s=et(o.role,["none","group","text","button","link","image","heading","checkbox","radio","switch","slider","progress","textbox","list","list-item","menu","menu-item","dialog"],`${n}.role`);if(void 0!==o.label&&We(o.label,`${n}.label`,["string"],i),void 0!==o.value&&We(o.value,`${n}.value`,["string","number"],i),void 0!==o.hint&&We(o.hint,`${n}.hint`,["string"],i),void 0!==o.headingLevel){const e=function(e,t){const n=nt(e,t);Number.isSafeInteger(n)||ze("E_SEMANTICS_NUMBER",t,"expected safe integer");return n}(o.headingLevel,`${n}.headingLevel`);(e<1||e>6||"heading"!==s)&&ze("E_SEMANTICS_NUMBER",`${n}.headingLevel`,"heading level 1..6 requires heading role")}if(void 0!==o.traits&&it(o.traits,["button","link","image","header","adjustable","selected","disabled"],`${n}.traits`),void 0!==o.actions&&it(o.actions,["tap","increase","decrease","focus"],`${n}.actions`),void 0!==o.live&&et(o.live,["off","polite","assertive"],`${n}.live`),nt(o.readingOrder,`${n}.readingOrder`),nt(o.navigationOrder,`${n}.navigationOrder`),void 0!==o.state){const e=Ke(o.state,`${n}.state`);Ze(e,["hidden","disabled","focused","expanded","selected","checked","mixed","toggled","required","readOnly","modal","obscured","multiline"],`${n}.state`);for(const[t,o]of Object.entries(e))We(o,`${n}.state.${t}`,["boolean"],i)}if(void 0!==o.capabilities){const e=Ke(o.capabilities,`${n}.capabilities`);Ze(e,["expandable","selectable","checkable","toggleable","requirable","enablable","focusable"],`${n}.capabilities`);for(const[t,o]of Object.entries(e))"boolean"!=typeof o&&ze("E_SEMANTICS_FORMAT",`${n}.capabilities.${t}`,"expected boolean")}}),function(e,t){const n=new Map;e.forEach((e,t)=>{const o=Ke(e,`$.nodes[${t}]`);n.set(o.id,o.parent)});for(const e of n.keys()){const o=new Set;let i=e,s=0;for(;void 0!==i;)o.has(i)&&ze("E_SEMANTICS_GRAPH","$.nodes",`semantic cycle through ${i}`),++s>t&&ze("E_SEMANTICS_LIMIT","$.nodes","semantic depth exceeds budget"),o.add(i),i=n.get(i)}}(r,o);const c=Ke(s.reducedMotion,"$.reducedMotion");if("ignore"===et(c.mode,["ignore","respect"],"$.reducedMotion.mode"))Ze(c,["mode"],"$.reducedMotion");else{Ze(c,["mode","decorative","essential","durationScale","disableParallax"],"$.reducedMotion"),et(c.decorative,["pause","stop","continue"],"$.reducedMotion.decorative"),et(c.essential,["retain","reduce"],"$.reducedMotion.essential");const e=nt(c.durationScale,"$.reducedMotion.durationScale");(e<0||e>1)&&ze("E_SEMANTICS_NUMBER","$.reducedMotion.durationScale","duration scale must be within 0..1"),"boolean"!=typeof c.disableParallax&&ze("E_SEMANTICS_FORMAT","$.reducedMotion.disableParallax","expected boolean")}return Je(structuredClone(s))}function We(e,t,n,o){const i=Ke(e,t),s=et(i.kind,["literal","binding"],`${t}.kind`);Ze(i,"literal"===s?["kind","value"]:["kind","binding"],t),"binding"===s?tt(i.binding,`${t}.binding`,o):n.includes(typeof i.value)?"number"==typeof i.value?nt(i.value,`${t}.value`):"string"==typeof i.value&&tt(i.value,`${t}.value`,o,!0):ze("E_SEMANTICS_FORMAT",`${t}.value`,`expected ${n.join(" or ")}`)}function Je(e){if(e&&"object"==typeof e&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))Je(t)}return e}function Ke(e,t){return e&&"object"==typeof e&&!Array.isArray(e)||ze("E_SEMANTICS_FORMAT",t,"expected object"),e}function Xe(e,t){return Array.isArray(e)||ze("E_SEMANTICS_FORMAT",t,"expected array"),e}function Ze(e,t,n){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||ze("E_SEMANTICS_FORMAT",`${n}.${t}`,"unknown field")}function Qe(e,t,n){e!==t&&ze("E_SEMANTICS_FORMAT",n,`expected ${String(t)}`)}function et(e,t,n){return"string"==typeof e&&t.includes(e)||ze("E_SEMANTICS_FORMAT",n,`expected one of ${t.join(", ")}`),e}function tt(e,t,n,o=!1){return("string"!=typeof e||!o&&0===e.length)&&ze("E_SEMANTICS_FORMAT",t,"expected string"),(new TextEncoder).encode(e).length>n&&ze("E_SEMANTICS_LIMIT",t,"string exceeds byte budget"),e}function nt(e,t){return"number"==typeof e&&Number.isFinite(e)||ze("E_SEMANTICS_NUMBER",t,"expected finite number"),e}function ot(e,t){return(!Number.isSafeInteger(e)||e<1)&&ze("E_SEMANTICS_LIMIT",t,"expected positive safe integer"),e}function it(e,t,n){const o=new Set;Xe(e,n).forEach((e,i)=>{const s=et(e,t,`${n}[${i}]`);o.has(s)&&ze("E_SEMANTICS_FORMAT",`${n}[${i}]`,"duplicate entry"),o.add(s)})}class st extends Error{code;path;name="AudioEventDiagnostic";constructor(e,t,n){super(`${n} (${t})`),this.code=e,this.path=t}}function rt(e,t,n){throw new st(e,t,n)}const at=Object.freeze({maxResources:4096,maxBuses:4096,maxCues:1e6,maxTimelineEvents:1e6,maxVoices:256,maxVoicesPerResource:64,maxDecodeJobs:16,maxEventTokens:1e6,maxEmbeddedBytes:268435456,maxTotalEmbeddedBytes:1073741824,maxDecodedFrames:1e9,maxDecodedBytes:536870912,maxStringBytes:4194304,maxTotalTextBytes:33554432,maxReferenceDepth:128});const ct=Object.freeze({"pcm-f32":Object.freeze(["audio/vnd.haiyue.pcm-f32"]),wav:Object.freeze(["audio/wav","audio/wave","audio/x-wav"]),mp3:Object.freeze(["audio/mpeg"]),aac:Object.freeze(["audio/aac","audio/mp4"]),opus:Object.freeze(["audio/ogg","audio/webm"]),vorbis:Object.freeze(["audio/ogg","audio/webm"]),flac:Object.freeze(["audio/flac","audio/x-flac"])});function dt(e,t={}){const n=function(e={}){const t={...at,...e};for(const[e,n]of Object.entries(t))(!Number.isSafeInteger(n)||n<1)&&rt("E_AUDIO_EVENT_LIMIT",`$.limits.${e}`,"limit must be a positive safe integer");return Object.freeze(t)}(t.limits);!function(e,t,n){const o=new Set,i=(e,t,s)=>{if(null!==e&&"object"==typeof e){if(s>n&&rt("E_AUDIO_EVENT_LIMIT",t,"reference depth budget exceeded"),o.has(e)&&rt("E_AUDIO_EVENT_GRAPH",t,"input contains a cycle"),o.add(e),Array.isArray(e))e.forEach((e,n)=>i(e,`${t}[${n}]`,s+1));else for(const[n,o]of Object.entries(e))i(o,`${t}.${n}`,s+1);o.delete(e)}};i(e,t,0)}(e,"$",n.maxReferenceDepth);const o=$t(e,"$");lt(o,["format","version","extension","playbackProfile","clock","browser","limits","voiceStealing","resources","buses","cues","timelineEvents"],"$"),mt(o.format,"haiyue-audio-events","$.format","E_AUDIO_EVENT_FORMAT"),mt(o.version,1,"$.version","E_AUDIO_EVENT_VERSION"),mt(o.extension,"org.haiyue.audio-events@1","$.extension","E_AUDIO_EVENT_FORMAT"),ft(o.playbackProfile,["sample-accurate","html-media-restricted"],"$.playbackProfile"),ft(o.voiceStealing,["reject","steal-oldest","steal-lowest-priority"],"$.voiceStealing");const i={embeddedBytes:0,decodedFrames:0,decodedBytes:0,textBytes:0},s=function(e,t){const n="$.limits",o=$t(e,n);lt(o,["maxVoices","maxVoicesPerResource","maxDecodeJobs","maxEventTokens","maxDecodedFrames","maxDecodedBytes"],n);const i={maxVoices:_t(o.maxVoices,1,t.maxVoices,`${n}.maxVoices`),maxVoicesPerResource:_t(o.maxVoicesPerResource,1,t.maxVoicesPerResource,`${n}.maxVoicesPerResource`),maxDecodeJobs:_t(o.maxDecodeJobs,1,t.maxDecodeJobs,`${n}.maxDecodeJobs`),maxEventTokens:_t(o.maxEventTokens,1,t.maxEventTokens,`${n}.maxEventTokens`),maxDecodedFrames:_t(o.maxDecodedFrames,1,t.maxDecodedFrames,`${n}.maxDecodedFrames`),maxDecodedBytes:_t(o.maxDecodedBytes,1,t.maxDecodedBytes,`${n}.maxDecodedBytes`)};i.maxVoicesPerResource>i.maxVoices&&rt("E_AUDIO_EVENT_LIMIT",`${n}.maxVoicesPerResource`,"per-resource voice limit cannot exceed the total voice limit");return i}(o.limits,n);!function(e,t){const n="$.clock",o=$t(e,n);lt(o,["sampleRate","lookAheadFrames","driftToleranceFrames","driftPolicy","lateDecodePolicy","visibilityPolicy","suspendedPolicy"],n),_t(o.sampleRate,8e3,384e3,`${n}.sampleRate`),_t(o.lookAheadFrames,1,t.maxDecodedFrames,`${n}.lookAheadFrames`),_t(o.driftToleranceFrames,0,384e3,`${n}.driftToleranceFrames`),ft(o.driftPolicy,["resync","error"],`${n}.driftPolicy`),ft(o.lateDecodePolicy,["catch-up","drop","error"],`${n}.lateDecodePolicy`),ft(o.visibilityPolicy,["continue","pause-resume"],`${n}.visibilityPolicy`),ft(o.suspendedPolicy,["queue-until-resume","error"],`${n}.suspendedPolicy`)}(o.clock,n),function(e){const t="$.browser",n=$t(e,t);lt(n,["autoplay"],t),ft(n.autoplay,["require-user-gesture","attempt"],`${t}.autoplay`)}(o.browser);const r=pt(o.resources,"$.resources"),a=pt(o.buses,"$.buses"),c=pt(o.cues,"$.cues"),d=pt(o.timelineEvents,"$.timelineEvents");At(r.length,n.maxResources,"$.resources"),At(a.length,n.maxBuses,"$.buses"),At(c.length,n.maxCues,"$.cues"),At(d.length,n.maxTimelineEvents,"$.timelineEvents");const u=ut(r,"$.resources",i,n),l=ut(a,"$.buses",i,n),$=ut(c,"$.cues",i,n);ut(d,"$.timelineEvents",i,n);const p=r.map((e,t)=>function(e,t,n,o){const i=$t(e,t);lt(i,["id","codec","mediaType","integrity","sampleRate","channels","frameLength","source"],t),gt(i.id,`${t}.id`,n,o);const s=ft(i.codec,["pcm-f32","wav","mp3","aac","opus","vorbis","flac"],`${t}.codec`),r=ht(i.mediaType,`${t}.mediaType`,n,o);ct[s].includes(r)||rt("E_AUDIO_EVENT_CODEC",`${t}.mediaType`,"media type is incompatible with codec");const a=$t(i.integrity,`${t}.integrity`);lt(a,["algorithm","digest"],`${t}.integrity`),mt(a.algorithm,"sha256",`${t}.integrity.algorithm`,"E_AUDIO_EVENT_INTEGRITY");const c=ht(a.digest,`${t}.integrity.digest`,n,o);/^[0-9a-f]{64}$/u.test(c)||rt("E_AUDIO_EVENT_INTEGRITY",`${t}.integrity.digest`,"digest must be lowercase SHA-256 hex");_t(i.sampleRate,8e3,384e3,`${t}.sampleRate`);const d=_t(i.channels,1,32,`${t}.channels`),u=Tt(_t(i.frameLength,1,o.maxDecodedFrames,`${t}.frameLength`),d,`${t}.frameLength`),l=Tt(u,4,`${t}.frameLength`);n.decodedFrames=bt(n.decodedFrames,u,"$.resources"),n.decodedBytes=bt(n.decodedBytes,l,"$.resources");const $=`${t}.source`,p=$t(i.source,$),m=ft(p.kind,["embedded","referenced","hosted"],`${$}.kind`);if("embedded"===m){lt(p,["kind","data"],$);const e=ht(p.data,`${$}.data`,n,o);/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(e)||rt("E_AUDIO_EVENT_FORMAT",`${$}.data`,"embedded data must be canonical base64");const t=function(e){if(0===e.length)return 0;const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return e.length/4*3-t}(e);0===t&&rt("E_AUDIO_EVENT_FORMAT",`${$}.data`,"embedded audio must not be empty"),At(t,o.maxEmbeddedBytes,`${$}.data`),n.embeddedBytes=bt(n.embeddedBytes,t,"$.resources")}else if("referenced"===m){lt(p,["kind","uri"],$);0===ht(p.uri,`${$}.uri`,n,o).length&&rt("E_AUDIO_EVENT_FORMAT",`${$}.uri`,"URI must not be empty")}else lt(p,["kind","key"],$),gt(p.key,`${$}.key`,n,o);return i}(e,`$.resources[${t}]`,i,n)),m=new Map(p.map(e=>[e.id,e])),f=a.map((e,t)=>function(e,t,n,o,i){const s=$t(e,t);lt(s,["id","parent","gain"],t),gt(s.id,`${t}.id`,o,i),void 0!==s.parent&&Et(s.parent,n,`${t}.parent`);return yt(s.gain,0,4,`${t}.gain`),s}(e,`$.buses[${t}]`,l,i,n));!function(e,t){const n=new Map(e.map(e=>[e.id,e.parent])),o=new Map(e.map(e=>[e.id,e.gain]));for(const i of e){const e=new Set;let s=i.id,r=0,a=1;for(;void 0!==s;)e.has(s)&&rt("E_AUDIO_EVENT_GRAPH",`$.buses.${i.id}`,"bus graph contains a cycle"),e.add(s),a*=o.get(s)??1,(!Number.isFinite(a)||a>4)&&rt("E_AUDIO_EVENT_LIMIT",`$.buses.${i.id}.gain`,"effective bus gain exceeds 4"),s=n.get(s),++r>t&&rt("E_AUDIO_EVENT_LIMIT",`$.buses.${i.id}`,"bus graph exceeds depth budget")}}(f,n.maxReferenceDepth);const g=c.map((e,t)=>function(e,t,n,o,i,s,r){const a=$t(e,t);lt(a,["id","resource","owner","bus","gain","rate","offsetFrames","durationFrames","loop","overlap","priority"],t),gt(a.id,`${t}.id`,s,r);const c=Et(a.resource,n,`${t}.resource`);gt(a.owner,`${t}.owner`,s,r),Et(a.bus,o,`${t}.bus`),yt(a.gain,0,4,`${t}.gain`),yt(a.rate,.0625,16,`${t}.rate`);const d=i.get(c),u=_t(a.offsetFrames,0,d.frameLength-1,`${t}.offsetFrames`);void 0!==a.durationFrames&&_t(a.durationFrames,1,d.frameLength-u,`${t}.durationFrames`);if(void 0!==a.loop){void 0!==a.durationFrames&&rt("E_AUDIO_EVENT_FORMAT",t,"loop iterations and durationFrames are mutually exclusive");const e=`${t}.loop`,n=$t(a.loop,e);lt(n,["startFrame","endFrame","iterations"],e);const o=_t(n.startFrame,0,d.frameLength-1,`${e}.startFrame`),i=_t(n.endFrame,1,d.frameLength,`${e}.endFrame`);(i<=o||u>=i)&&rt("E_AUDIO_EVENT_NUMBER",e,"loop range must contain the cue offset"),"infinite"!==n.iterations&&_t(n.iterations,1,1e6,`${e}.iterations`)}return ft(a.overlap,["allow","ignore","restart"],`${t}.overlap`),_t(a.priority,-1e6,1e6,`${t}.priority`),a}(e,`$.cues[${t}]`,u,l,m,i,n));return d.forEach((e,t)=>function(e,t,n,o,i){const s=$t(e,t);return lt(s,["id","clock","time","sequence","cue","operation"],t),gt(s.id,`${t}.id`,o,i),ft(s.clock,["composition","state","event"],`${t}.clock`),yt(s.time,0,Number.MAX_SAFE_INTEGER,`${t}.time`),_t(s.sequence,0,Number.MAX_SAFE_INTEGER,`${t}.sequence`),Et(s.cue,n,`${t}.cue`),ft(s.operation,["start","stop"],`${t}.operation`),s}(e,`$.timelineEvents[${t}]`,$,i,n)),At(i.embeddedBytes,n.maxTotalEmbeddedBytes,"$.resources"),At(i.decodedFrames,s.maxDecodedFrames,"$.resources"),At(i.decodedBytes,s.maxDecodedBytes,"$.resources"),At(i.textBytes,n.maxTotalTextBytes,"$"),"html-media-restricted"===o.playbackProfile&&(1===s.maxVoices&&1===s.maxVoicesPerResource||rt("E_AUDIO_EVENT_FORMAT","$.limits","restricted media profile requires single-voice limits"),g.some(e=>"ignore"!==e.overlap)&&rt("E_AUDIO_EVENT_FORMAT","$.cues","restricted media profile requires ignore overlap policy")),xt(structuredClone(o))}function ut(e,t,n,o){const i=new Set;return e.forEach((e,s)=>{const r=gt($t(e,`${t}[${s}]`).id,`${t}[${s}].id`,n,o);i.has(r)&&rt("E_AUDIO_EVENT_FORMAT",`${t}[${s}].id`,"duplicate id"),i.add(r)}),i}function lt(e,t,n){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||rt("E_AUDIO_EVENT_FORMAT",`${n}.${t}`,"unknown field");for(const o of t)o in e||["parent","durationFrames","loop"].includes(o)||rt("E_AUDIO_EVENT_FORMAT",`${n}.${o}`,"required field is missing")}function $t(e,t){return(null===e||"object"!=typeof e||Array.isArray(e))&&rt("E_AUDIO_EVENT_FORMAT",t,"expected object"),e}function pt(e,t){return Array.isArray(e)||rt("E_AUDIO_EVENT_FORMAT",t,"expected array"),e}function mt(e,t,n,o){e!==t&&rt(o,n,`expected ${JSON.stringify(t)}`)}function ft(e,t,n){return"string"==typeof e&&t.includes(e)||rt("E_AUDIO_EVENT_FORMAT",n,`expected one of ${t.join(", ")}`),e}function gt(e,t,n,o){const i=ht(e,t,n,o);return/^[A-Za-z0-9][A-Za-z0-9._:@/-]*$/u.test(i)||rt("E_AUDIO_EVENT_FORMAT",t,"invalid identifier"),i}function ht(e,t,n,o){"string"!=typeof e&&rt("E_AUDIO_EVENT_FORMAT",t,"expected string");const i=(new TextEncoder).encode(e).byteLength;return At(i,o.maxStringBytes,t),n.textBytes=bt(n.textBytes,i,"$.textBytes"),e}function Et(e,t,n){return"string"==typeof e&&t.has(e)||rt("E_AUDIO_EVENT_REFERENCE",n,"unknown reference"),e}function _t(e,t,n,o){return(!Number.isSafeInteger(e)||e<t||e>n)&&rt("E_AUDIO_EVENT_NUMBER",o,`expected integer in [${t}, ${n}]`),e}function yt(e,t,n,o){return("number"!=typeof e||!Number.isFinite(e)||e<t||e>n)&&rt("E_AUDIO_EVENT_NUMBER",o,`expected finite number in [${t}, ${n}]`),e}function At(e,t,n){e>t&&rt("E_AUDIO_EVENT_LIMIT",n,`limit ${t} exceeded by ${e}`)}function bt(e,t,n){const o=e+t;return Number.isSafeInteger(o)||rt("E_AUDIO_EVENT_LIMIT",n,"aggregate size exceeds safe integer range"),o}function Tt(e,t,n){const o=e*t;return Number.isSafeInteger(o)||rt("E_AUDIO_EVENT_LIMIT",n,"decoded size exceeds safe integer range"),o}function xt(e){if(null!==e&&"object"==typeof e&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))xt(t)}return e}const It=function e(t){if(t&&"object"==typeof t&&!Object.isFrozen(t)){Object.freeze(t);for(const n of Object.values(t))e(n)}return t}({transform:vt("transform",["number","vector"],["override","additive"],"blend","resample"),"paint-path":vt("paint-path",["number","vector","color","id"],["override","additive","discrete"],"blend","resample"),rig:vt("rig",["number","vector","boolean"],["override","additive","discrete"],"blend","resample"),"text-layout":vt("text-layout",["number","vector","color","boolean","string","id","integer","unsigned"],["override","additive","discrete"],"select","resample"),"resource-data":vt("resource-data",["number","vector","color","boolean","string","id","integer","unsigned"],["override","additive","discrete","ownership"],"transfer-owner","restore-owner"),"visibility-order":vt("visibility-order",["boolean","integer","unsigned","id"],["discrete"],"select","resample"),"event-audio-script":vt("event-audio-script",["callback"],["ownership"],"exactly-once","reset-and-replay")});function vt(e,t,n,o,i){return{family:e,valueKinds:t,policies:n,transition:o,rewind:i}}class Nt extends Error{code;path;name="StateMachineV2Diagnostic";constructor(e,t,n){super(`${n} (${t})`),this.code=e,this.path=t}}function Ot(e,t,n){throw new Nt(e,t,n)}const Mt=Object.freeze({maxChannels:1e6,maxClips:1e4,maxTracks:1e6,maxKeyframes:1e7,maxStateMachines:1e4,maxInputs:1e5,maxLayers:8192,maxStates:25e4,maxTransitions:5e5,maxConditionTerms:1e6,maxMotionDepth:128,maxComponents:8192,maxStringLength:4194304});const St="org.haiyue.animation-state-machine@2",wt="haiyue-animation-state-machine@2";function kt(e,t={}){const n=function(e={}){const t={...Mt,...e};for(const[e,n]of Object.entries(t))if(!Number.isSafeInteger(n)||n<1)throw new RangeError(`State-machine v2 limit ${e} must be a positive safe integer.`);return Object.freeze(t)}(t.limits);let o;try{o=structuredClone(e)}catch{ln("E_STATE_MACHINE_V2_FORMAT","$","document must be structured-cloneable data")}const i=qt(o,"$");Kt(i,["format","extension","channels","clips","stateMachines","components"],"$"),an(i.format,wt,"$.format"),an(i.extension,St,"$.extension");const s=Wt(i.channels,"$.channels");dn(s.length,n.maxChannels,"$.channels");const r=new Set,a=new Map;s.forEach((e,t)=>{const o=`$.channels[${t}]`,i=qt(e,o);Kt(i,["id","target","path","family","valueKind","valueSize","numericMode","defaultValue","policy","effectKind"],o);const s=Gt(i.id,r,`${o}.id`),c=cn(i.family,["transform","paint-path","rig","text-layout","resource-data","visibility-order","event-audio-script"],`${o}.family`),d=cn(i.valueKind,["number","vector","color","boolean","string","id","integer","unsigned","callback"],`${o}.valueKind`),u=cn(i.policy,["override","additive","discrete","ownership"],`${o}.policy`);(function(e,t,n){const o=It[e];return o.valueKinds.includes(t)&&o.policies.includes(n)})(c,d,u)||ln("E_STATE_MACHINE_V2_POLICY",o,`${c}/${d}/${u} has no executable policy`);const l=function(e,t,n){if("vector"!==t&&"color"!==t)return void(void 0!==e&&ln("E_STATE_MACHINE_V2_FORMAT",n,`${t} channel cannot declare valueSize`));const o=Qt(e,n);(o<1||"color"===t&&4!==o)&&ln("E_STATE_MACHINE_V2_NUMBER",n,"color"===t?"color valueSize must be 4":"valueSize must be positive");return o}(i.valueSize,d,`${o}.valueSize`);if(void 0!==i.numericMode){"angle-radians"===cn(i.numericMode,["linear","angle-radians"],`${o}.numericMode`)&&("number"!==d||"transform"!==c&&"rig"!==c)&&ln("E_STATE_MACHINE_V2_POLICY",`${o}.numericMode`,"angle-radians requires a scalar transform or rig channel")}void 0!==i.defaultValue&&Dt(i.defaultValue,d,l,`${o}.defaultValue`,n),"callback"===d?(void 0===i.effectKind&&ln("E_STATE_MACHINE_V2_POLICY",`${o}.effectKind`,"callback channel requires event, audio, or script effectKind"),cn(i.effectKind,["event","audio","script"],`${o}.effectKind`)):void 0!==i.effectKind&&ln("E_STATE_MACHINE_V2_POLICY",`${o}.effectKind`,"effectKind is only valid for callback channels"),Yt(i.target,`${o}.target`),Yt(i.path,`${o}.path`),a.set(s,i)});const c={tracks:0,keyframes:0,inputs:0,layers:0,states:0,transitions:0,conditions:0},d=Wt(i.clips,"$.clips");dn(d.length,n.maxClips,"$.clips");const u=new Set;d.forEach((e,t)=>{const o=`$.clips[${t}]`,i=qt(e,o);Kt(i,["id","name","duration","fps","quantize","workArea","tracks"],o),Gt(i.id,u,`${o}.id`),function(e,t,n){if(void 0===e)return;const o=Xt(e,t);o.length>n.maxStringLength&&ln("E_STATE_MACHINE_V2_LIMIT",t,"string exceeds limit")}(i.name,`${o}.name`,n);const s=en(i.duration,`${o}.duration`);if(void 0!==i.fps&&tn(i.fps,`${o}.fps`),sn(i.quantize,`${o}.quantize`),void 0!==i.workArea){const e=qt(i.workArea,`${o}.workArea`);Kt(e,["start","end"],`${o}.workArea`);const t=en(e.start,`${o}.workArea.start`),n=en(e.end,`${o}.workArea.end`);(n<t||n>s)&&ln("E_STATE_MACHINE_V2_NUMBER",`${o}.workArea`,"work area must be ordered inside clip duration")}const r=Wt(i.tracks,`${o}.tracks`);c.tracks+=r.length,dn(c.tracks,n.maxTracks,`${o}.tracks`);const d=new Set,l=new Set;r.forEach((e,t)=>{const i=`${o}.tracks[${t}]`,r=qt(e,i);Kt(r,["id","channel","keys"],i),Gt(r.id,d,`${i}.id`);const u=jt(r.channel,a,`${i}.channel`);l.has(u)&&ln("E_STATE_MACHINE_V2_REFERENCE",`${i}.channel`,`clip has two tracks for channel ${u}`),l.add(u);const $=a.get(u),p=Wt(r.keys,`${i}.keys`);0===p.length&&ln("E_STATE_MACHINE_V2_FORMAT",`${i}.keys`,"track requires at least one key"),c.keyframes+=p.length,dn(c.keyframes,n.maxKeyframes,`${i}.keys`);let m=-1/0;p.forEach((e,t)=>{const o=`${i}.keys[${t}]`,r=qt(e,o);Kt(r,["time","value","interpolation"],o);const a=en(r.time,`${o}.time`);(a<=m||a>s)&&ln("E_STATE_MACHINE_V2_NUMBER",`${o}.time`,"key times must be strictly increasing and inside clip duration"),m=a,Dt(r.value,$.valueKind,$.valueSize,`${o}.value`,n),t===p.length-1&&void 0!==r.interpolation&&ln("E_STATE_MACHINE_V2_FORMAT",`${o}.interpolation`,"final key cannot declare outgoing interpolation"),void 0!==r.interpolation&&function(e,t,n){const o="number"===t.valueKind||"vector"===t.valueKind||"color"===t.valueKind,i=qt(e,n),s=cn(i.kind,["linear","hold","cubic-ease","cubic-value","elastic"],`${n}.kind`);o||"hold"===s||ln("E_STATE_MACHINE_V2_POLICY",n,`${t.valueKind} keys require hold interpolation`);Ct(e,t.valueSize??1,n)}(r.interpolation,$,`${o}.interpolation`)})})});const l=Wt(i.stateMachines,"$.stateMachines");dn(l.length,n.maxStateMachines,"$.stateMachines");const $=new Set;l.forEach((e,t)=>{const o=`$.stateMachines[${t}]`,i=qt(e,o);Kt(i,["id","inputs","layers"],o),Gt(i.id,$,`${o}.id`);const s=Wt(i.inputs,`${o}.inputs`);c.inputs+=s.length,dn(c.inputs,n.maxInputs,`${o}.inputs`);const r=new Map;s.forEach((e,t)=>{const n=`${o}.inputs[${t}]`,i=qt(e,n);Kt(i,["id","type","defaultValue"],n);const s=Gt(i.id,new Set(r.keys()),`${n}.id`),a=cn(i.type,["number","integer","boolean","trigger"],`${n}.type`);r.set(s,a),"trigger"===a?void 0!==i.defaultValue&&ln("E_STATE_MACHINE_V2_FORMAT",`${n}.defaultValue`,"trigger has no default value"):"boolean"===a?on(i.defaultValue,`${n}.defaultValue`):"integer"===a?Qt(i.defaultValue,`${n}.defaultValue`):Zt(i.defaultValue,`${n}.defaultValue`)});const d=Wt(i.layers,`${o}.layers`);0===d.length&&ln("E_STATE_MACHINE_V2_GRAPH",`${o}.layers`,"state machine requires a layer"),c.layers+=d.length,dn(c.layers,n.maxLayers,`${o}.layers`);const l=new Set,p=new Set;d.forEach((e,t)=>function(e,t,n,o,i,s,r,a,c){const d=qt(e,t);Kt(d,["id","order","weight","weightInput","mode","mask","states","transitions"],t),Gt(d.id,a,`${t}.id`);const u=Qt(d.order,`${t}.order`);c.has(u)&&ln("E_STATE_MACHINE_V2_GRAPH",`${t}.order`,`duplicate layer order ${u}`);c.add(u),void 0!==d.weight&&nn(d.weight,`${t}.weight`);void 0!==d.weightInput&&Ht(d.weightInput,n,`${t}.weightInput`);void 0!==d.mode&&cn(d.mode,["override","additive"],`${t}.mode`);!function(e,t){if(void 0===e)return;const n=qt(e,t);Kt(n,["include","exclude"],t),zt(n.include,`${t}.include`),zt(n.exclude,`${t}.exclude`)}(d.mask,`${t}.mask`);const l=Wt(d.states,`${t}.states`);0===l.length&&ln("E_STATE_MACHINE_V2_GRAPH",`${t}.states`,"layer requires a state");r.states+=l.length,dn(r.states,s.maxStates,`${t}.states`);const $=new Set;l.forEach((e,r)=>{const a=`${t}.states[${r}]`,c=qt(e,a);Kt(c,["id","motion","entryEffects","exitEffects"],a),Gt(c.id,$,`${a}.id`),Rt(c.motion,`${a}.motion`,n,i,s,1),Bt(c.entryEffects,`${a}.entryEffects`,o,s),Bt(c.exitEffects,`${a}.exitEffects`,o,s)});const p=Wt(d.transitions,`${t}.transitions`);r.transitions+=p.length,dn(r.transitions,s.maxTransitions,`${t}.transitions`);const m=new Set;let f=0;p.forEach((e,a)=>{const c=`${t}.transitions[${a}]`,d=qt(e,c);Kt(d,["id","from","to","conditionGroups","exitTime","randomWeight","pauseWhenExiting","duration","destinationOffset","interruption","exitMotion","interpolation","effects"],c),Gt(d.id,m,`${c}.id`);const u=Ut(d.from,`${c}.from`),l=Ut(d.to,`${c}.to`);"@entry"===u&&f++,"@exit"===u&&ln("E_STATE_MACHINE_V2_GRAPH",`${c}.from`,"exit cannot be a transition source"),"@entry"!==l&&"@any"!==l||ln("E_STATE_MACHINE_V2_GRAPH",`${c}.to`,`${l} cannot be a transition destination`),u.startsWith("@")||$.has(u)||ln("E_STATE_MACHINE_V2_REFERENCE",`${c}.from`,`unknown state ${u}`),l.startsWith("@")||$.has(l)||ln("E_STATE_MACHINE_V2_REFERENCE",`${c}.to`,`unknown state ${l}`),"@entry"!==u||"@exit"!==l&&0===Wt(d.conditionGroups,`${c}.conditionGroups`).length||ln("E_STATE_MACHINE_V2_GRAPH",c,"entry transition must be unconditional and target a state");Wt(d.conditionGroups,`${c}.conditionGroups`).forEach((e,t)=>{const o=Wt(e,`${c}.conditionGroups[${t}]`);0===o.length&&ln("E_STATE_MACHINE_V2_GRAPH",`${c}.conditionGroups[${t}]`,"OR group cannot be empty"),r.conditions+=o.length,dn(r.conditions,s.maxConditionTerms,`${c}.conditionGroups`),o.forEach((e,o)=>function(e,t,n,o){const i=qt(e,t),s=cn(i.kind,["input","trigger","observable","custom"],`${t}.kind`);if("trigger"===s){Kt(i,["kind","input"],t);const e=Lt(i.input,n,`${t}.input`);return void("trigger"!==n.get(e)&&ln("E_STATE_MACHINE_V2_GRAPH",`${t}.input`,"trigger condition requires trigger input"))}if("input"===s){Kt(i,["kind","input","comparator","value"],t);const e=Lt(i.input,n,`${t}.input`),o=n.get(e);"trigger"===o&&ln("E_STATE_MACHINE_V2_GRAPH",`${t}.input`,"trigger input requires trigger condition");return void function(e,t,n,o){"boolean"===e?("equal"!==t&&"not-equal"!==t&&ln("E_STATE_MACHINE_V2_GRAPH",o,"boolean input only supports equality comparators"),on(n,o)):"integer"===e?Qt(n,o):Zt(n,o)}(o,Vt(i.comparator,`${t}.comparator`),i.value,`${t}.value`)}Kt(i,"observable"===s?["kind","protocol","port","comparator","value","arguments"]:["kind","protocol","port","arguments"],t),Yt(i.protocol,`${t}.protocol`),Yt(i.port,`${t}.port`),function(e,t,n){if(void 0===e)return;for(const[o,i]of Object.entries(qt(e,t)))Yt(o,`${t}.${o}`),"string"==typeof i&&i.length>n.maxStringLength&&ln("E_STATE_MACHINE_V2_LIMIT",`${t}.${o}`,"argument string exceeds limit"),Pt(i,`${t}.${o}`)}(i.arguments,`${t}.arguments`,o),"observable"===s&&(Vt(i.comparator,`${t}.comparator`),Pt(i.value,`${t}.value`))}(e,`${c}.conditionGroups[${t}][${o}]`,n,s))}),void 0!==d.exitTime&&en(d.exitTime,`${c}.exitTime`),void 0!==d.randomWeight&&nn(d.randomWeight,`${c}.randomWeight`),sn(d.pauseWhenExiting,`${c}.pauseWhenExiting`),en(d.duration,`${c}.duration`),void 0!==d.destinationOffset&&en(d.destinationOffset,`${c}.destinationOffset`),void 0!==d.interruption&&cn(d.interruption,["none","source","destination","source-then-destination","destination-then-source"],`${c}.interruption`),void 0!==d.exitMotion&&Rt(d.exitMotion,`${c}.exitMotion`,n,i,s,1),void 0!==d.interpolation&&Ct(d.interpolation,1,`${c}.interpolation`),Bt(d.effects,`${c}.effects`,o,s)}),1!==f&&ln("E_STATE_MACHINE_V2_GRAPH",`${t}.transitions`,`layer requires exactly one @entry transition; received ${f}`)}(e,`${o}.layers[${t}]`,r,a,u,n,c,l,p))});const p=void 0===i.components?[]:Wt(i.components,"$.components");dn(p.length,n.maxComponents,"$.components");const m=new Set;return p.forEach((e,t)=>{const o=`$.components[${t}]`,i=qt(e,o);Kt(i,["id","target","source","playback","exposedInputs","exposedEvents"],o),Gt(i.id,m,`${o}.id`),Yt(i.target,`${o}.target`);const s=qt(i.source,`${o}.source`),r=cn(s.kind,["clip","state-machine"],`${o}.source.kind`);Kt(s,"clip"===r?["kind","clip"]:["kind","machine"],`${o}.source`),"clip"===r?jt(s.clip,u,`${o}.source.clip`):jt(s.machine,$,`${o}.source.machine`);"state-machine"===cn(i.playback,["simple","remap","mix","state-machine"],`${o}.playback`)&&"state-machine"!==r&&ln("E_STATE_MACHINE_V2_GRAPH",`${o}.playback`,"state-machine playback requires a state-machine source"),zt(i.exposedInputs,`${o}.exposedInputs`,n),zt(i.exposedEvents,`${o}.exposedEvents`,n)}),function(e,t,n,o){const i=new Map,s=(e,t,n)=>{const o=i.get(e)??[];o.push({to:t,path:n}),i.set(e,o)},r=(e,t,o)=>{const i=qt(e,t);if("nested"===i.kind){const e=String(i.component);n.has(e)||ln("E_STATE_MACHINE_V2_REFERENCE",`${t}.component`,`unknown component ${e}`),s(o,`component:${e}`,`${t}.component`)}"blend-1d"===i.kind||"blend-2d"===i.kind?Wt(i.children,`${t}.children`).forEach((e,n)=>r(qt(e,`${t}.children[${n}]`).motion,`${t}.children[${n}].motion`,o)):"blend-additive"===i.kind&&(r(i.base,`${t}.base`,o),Wt(i.children,`${t}.children`).forEach((e,n)=>r(qt(e,`${t}.children[${n}]`).motion,`${t}.children[${n}].motion`,o)))};e.forEach((e,t)=>{const n=qt(e,`$.stateMachines[${t}]`),o=`machine:${String(n.id)}`;i.set(o,i.get(o)??[]),Wt(n.layers,`$.stateMachines[${t}].layers`).forEach((e,n)=>{const i=qt(e,"$layer");Wt(i.states,"$layer.states").forEach((e,i)=>r(qt(e,"$state").motion,`$.stateMachines[${t}].layers[${n}].states[${i}].motion`,o)),Wt(i.transitions,"$layer.transitions").forEach((e,i)=>{const s=qt(e,"$transition");void 0!==s.exitMotion&&r(s.exitMotion,`$.stateMachines[${t}].layers[${n}].transitions[${i}].exitMotion`,o)})})}),t.forEach((e,t)=>{const n=qt(e,`$.components[${t}]`),o=`component:${String(n.id)}`,r=qt(n.source,`$.components[${t}].source`);i.set(o,i.get(o)??[]),"state-machine"===r.kind&&s(o,`machine:${String(r.machine)}`,`$.components[${t}].source.machine`)});const a=new Set,c=new Set,d=(e,t,n)=>{if(t>o.maxMotionDepth&&ln("E_STATE_MACHINE_V2_LIMIT",n,`nested graph depth exceeds ${o.maxMotionDepth}`),a.has(e)&&ln("E_STATE_MACHINE_V2_GRAPH",n,`nested component cycle includes ${e}`),!c.has(e)){a.add(e);for(const n of i.get(e)??[])d(n.to,t+1,n.path);a.delete(e),c.add(e)}};for(const e of i.keys())d(e,1,"$.components")}(l,p,m,n),un(i)}function Rt(e,t,n,o,i,s){s>i.maxMotionDepth&&ln("E_STATE_MACHINE_V2_LIMIT",t,`motion depth exceeds ${i.maxMotionDepth}`);const r=qt(e,t),a=cn(r.kind,["clip","blend-1d","blend-2d","blend-additive","nested"],`${t}.kind`);if("clip"===a)return Kt(r,["kind","clip","speed","speedInput","playback","timeRemapInput"],t),jt(r.clip,o,`${t}.clip`),void 0!==r.speed&&Zt(r.speed,`${t}.speed`),void 0!==r.speedInput&&Ht(r.speedInput,n,`${t}.speedInput`),void 0!==r.playback&&cn(r.playback,["one-shot","loop","ping-pong"],`${t}.playback`),void(void 0!==r.timeRemapInput&&Ht(r.timeRemapInput,n,`${t}.timeRemapInput`));if("blend-1d"===a){Kt(r,["kind","input","children"],t),Ht(r.input,n,`${t}.input`);const e=Jt(r.children,`${t}.children`);let a=-1/0;return void e.forEach((e,r)=>{const c=`${t}.children[${r}]`,d=qt(e,c);Kt(d,["threshold","motion"],c);const u=Zt(d.threshold,`${c}.threshold`);u<=a&&ln("E_STATE_MACHINE_V2_GRAPH",`${c}.threshold`,"thresholds must be strictly increasing"),a=u,Rt(d.motion,`${c}.motion`,n,o,i,s+1)})}if("blend-2d"===a)return Kt(r,["kind","algorithm","inputX","inputY","children"],t),cn(r.algorithm,["cartesian","directional"],`${t}.algorithm`),Ht(r.inputX,n,`${t}.inputX`),Ht(r.inputY,n,`${t}.inputY`),void Jt(r.children,`${t}.children`).forEach((e,r)=>{const a=`${t}.children[${r}]`,c=qt(e,a);Kt(c,["position","motion"],a),rn(c.position,2,`${a}.position`),Rt(c.motion,`${a}.motion`,n,o,i,s+1)});if("blend-additive"===a)return Kt(r,["kind","base","children"],t),Rt(r.base,`${t}.base`,n,o,i,s+1),void Jt(r.children,`${t}.children`).forEach((e,r)=>{const a=`${t}.children[${r}]`,c=qt(e,a);Kt(c,["motion","weight","weightInput"],a),void 0===c.weight&&void 0===c.weightInput&&ln("E_STATE_MACHINE_V2_FORMAT",a,"additive child requires weight or weightInput"),void 0!==c.weight&&nn(c.weight,`${a}.weight`),void 0!==c.weightInput&&Ht(c.weightInput,n,`${a}.weightInput`),Rt(c.motion,`${a}.motion`,n,o,i,s+1)});if(Kt(r,["kind","component","speed","timeRemapInput","mixInput","playingInput","inputBindings"],t),Yt(r.component,`${t}.component`),void 0!==r.speed&&Zt(r.speed,`${t}.speed`),void 0!==r.timeRemapInput&&Ht(r.timeRemapInput,n,`${t}.timeRemapInput`),void 0!==r.mixInput&&Ht(r.mixInput,n,`${t}.mixInput`),void 0!==r.playingInput){const e=Lt(r.playingInput,n,`${t}.playingInput`);"boolean"!==n.get(e)&&ln("E_STATE_MACHINE_V2_GRAPH",`${t}.playingInput`,"playingInput must be boolean")}if(void 0!==r.inputBindings)for(const[e,o]of Object.entries(qt(r.inputBindings,`${t}.inputBindings`)))Yt(e,`${t}.inputBindings.${e}`),Lt(o,n,`${t}.inputBindings.${e}`)}function Ct(e,t,n){const o=qt(e,n),i=cn(o.kind,["linear","hold","cubic-ease","cubic-value","elastic"],`${n}.kind`);if("linear"===i||"hold"===i)Kt(o,["kind"],n);else if("cubic-ease"===i){Kt(o,["kind","controls"],n);const e=rn(o.controls,4,`${n}.controls`);(e[0]<0||e[0]>1||e[2]<0||e[2]>1)&&ln("E_STATE_MACHINE_V2_NUMBER",`${n}.controls`,"cubic easing x controls must be in [0, 1]")}else"cubic-value"===i?(Kt(o,["kind","outTangent","inTangent"],n),rn(o.outTangent,t,`${n}.outTangent`),rn(o.inTangent,t,`${n}.inTangent`)):(Kt(o,["kind","easing","amplitude","period"],n),cn(o.easing,["in","out","in-out"],`${n}.easing`),en(o.amplitude,`${n}.amplitude`),tn(o.period,`${n}.period`));return o}function Dt(e,t,n,o,i){if("callback"===t)return Ft(e,o,i),void((Array.isArray(e)||"number"==typeof e||"boolean"==typeof e)&&ln("E_STATE_MACHINE_V2_FORMAT",o,"callback value must be null, string, or record"));if("number"!==t)if("integer"!==t){if("unsigned"===t){return void(Qt(e,o)<0&&ln("E_STATE_MACHINE_V2_NUMBER",o,"unsigned value must be non-negative"))}if("boolean"!==t){if("string"===t||"id"===t){return void(Xt(e,o).length>i.maxStringLength&&ln("E_STATE_MACHINE_V2_LIMIT",o,"string exceeds limit"))}if(rn(e,n,o),"color"===t)for(const[t,n]of e.entries())(n<0||n>1)&&ln("E_STATE_MACHINE_V2_NUMBER",`${o}[${t}]`,"color component must be in [0, 1]")}else on(e,o)}else Qt(e,o);else Zt(e,o)}function Pt(e,t){null!==e&&"boolean"!=typeof e&&"string"!=typeof e&&("number"!=typeof e?Array.isArray(e)?e.forEach((e,n)=>Zt(e,`${t}[${n}]`)):ln("E_STATE_MACHINE_V2_FORMAT",t,"unsupported comparison value"):Zt(e,t))}function Bt(e,t,n,o){void 0!==e&&Wt(e,t).forEach((e,i)=>{const s=`${t}[${i}]`,r=qt(e,s);Kt(r,["channel","phase","payload"],s);const a=n.get(jt(r.channel,n,`${s}.channel`));"callback"===a.valueKind&&"ownership"===a.policy||ln("E_STATE_MACHINE_V2_POLICY",`${s}.channel`,"transition effect requires callback ownership channel"),cn(r.phase,["start","complete"],`${s}.phase`),void 0!==r.payload&&Ft(r.payload,`${s}.payload`,o)})}function Ft(e,t,n,o=0,i=new Set){if(o>n.maxMotionDepth&&ln("E_STATE_MACHINE_V2_LIMIT",t,"payload depth exceeds limit"),null!==e&&"boolean"!=typeof e)if("number"!=typeof e)if("string"!=typeof e){if(e&&"object"==typeof e&&!ArrayBuffer.isView(e)||ln("E_STATE_MACHINE_V2_FORMAT",t,"payload must contain JSON-compatible values"),i.has(e)&&ln("E_STATE_MACHINE_V2_FORMAT",t,"payload cycle is not allowed"),i.add(e),Array.isArray(e))e.forEach((e,s)=>Ft(e,`${t}[${s}]`,n,o+1,i));else for(const[s,r]of Object.entries(e))Yt(s,`${t}.${s}`),Ft(r,`${t}.${s}`,n,o+1,i);i.delete(e)}else e.length>n.maxStringLength&&ln("E_STATE_MACHINE_V2_LIMIT",t,"payload string exceeds limit");else Zt(e,t)}function Vt(e,t){return cn(e,["equal","not-equal","greater","greater-or-equal","less","less-or-equal"],t)}function Ut(e,t){const n=Yt(e,t);return n.startsWith("@")&&"@entry"!==n&&"@any"!==n&&"@exit"!==n&&ln("E_STATE_MACHINE_V2_GRAPH",t,`unknown pseudo state ${n}`),n}function Ht(e,t,n){const o=Lt(e,t,n),i=t.get(o);return"number"!==i&&"integer"!==i&&ln("E_STATE_MACHINE_V2_GRAPH",n,`input ${o} must be numeric`),o}function Lt(e,t,n){return jt(e,t,n)}function jt(e,t,n){const o=Yt(e,n);return t.has(o)||ln("E_STATE_MACHINE_V2_REFERENCE",n,`unknown reference ${o}`),o}function Gt(e,t,n){const o=Yt(e,n);return t.has(o)&&ln("E_STATE_MACHINE_V2_REFERENCE",n,`duplicate id ${o}`),t.add(o),o}function Yt(e,t){const n=Xt(e,t);return(0===n.length||n.length>1024)&&ln("E_STATE_MACHINE_V2_FORMAT",t,"identifier length must be 1..1024"),n}function zt(e,t,n){if(void 0===e)return;const o=new Set;Wt(e,t).forEach((e,i)=>{const s=Gt(e,o,`${t}[${i}]`);n&&s.length>n.maxStringLength&&ln("E_STATE_MACHINE_V2_LIMIT",`${t}[${i}]`,"string exceeds limit")})}function qt(e,t){return function(e){return!!e&&"object"==typeof e&&!Array.isArray(e)&&!ArrayBuffer.isView(e)}(e)||ln("E_STATE_MACHINE_V2_FORMAT",t,"expected object"),e}function Wt(e,t){return Array.isArray(e)||ln("E_STATE_MACHINE_V2_FORMAT",t,"expected array"),e}function Jt(e,t){const n=Wt(e,t);return 0===n.length&&ln("E_STATE_MACHINE_V2_GRAPH",t,"expected a non-empty array"),n}function Kt(e,t,n){for(const o of Object.keys(e))t.includes(o)||ln("E_STATE_MACHINE_V2_FORMAT",`${n}.${o}`,"unknown property")}function Xt(e,t){return"string"!=typeof e&&ln("E_STATE_MACHINE_V2_FORMAT",t,"expected string"),e}function Zt(e,t){return"number"==typeof e&&Number.isFinite(e)||ln("E_STATE_MACHINE_V2_NUMBER",t,"expected finite number"),e}function Qt(e,t){const n=Zt(e,t);return Number.isSafeInteger(n)||ln("E_STATE_MACHINE_V2_NUMBER",t,"expected safe integer"),n}function en(e,t){const n=Zt(e,t);return n<0&&ln("E_STATE_MACHINE_V2_NUMBER",t,"expected non-negative number"),n}function tn(e,t){const n=Zt(e,t);return n<=0&&ln("E_STATE_MACHINE_V2_NUMBER",t,"expected positive number"),n}function nn(e,t){const n=Zt(e,t);return(n<0||n>1)&&ln("E_STATE_MACHINE_V2_NUMBER",t,"expected number in [0, 1]"),n}function on(e,t){return"boolean"!=typeof e&&ln("E_STATE_MACHINE_V2_FORMAT",t,"expected boolean"),e}function sn(e,t){void 0!==e&&on(e,t)}function rn(e,t,n){const o=Wt(e,n);return o.length!==t&&ln("E_STATE_MACHINE_V2_FORMAT",n,`expected ${t}-tuple`),o.map((e,t)=>Zt(e,`${n}[${t}]`))}function an(e,t,n){e!==t&&ln("E_STATE_MACHINE_V2_FORMAT",n,`expected ${t}`)}function cn(e,t,n){return"string"==typeof e&&t.includes(e)||ln("E_STATE_MACHINE_V2_FORMAT",n,`expected ${t.join("|")}`),e}function dn(e,t,n){e>t&&ln("E_STATE_MACHINE_V2_LIMIT",n,`count ${e} exceeds ${t}`)}function un(e){if(e&&"object"==typeof e&&!ArrayBuffer.isView(e)&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))un(t)}return e}function ln(e,t,n){return Ot(e,t,n)}const $n=new Map([["org.haiyue.animation-core@1",t=>{e(t)}],["org.haiyue.layout-2d@1",e=>{c(e)}],["org.haiyue.data-binding@1",e=>{Z(e)}],["org.haiyue.interaction@1",e=>{Ie(e)}],["org.haiyue.semantics@1",e=>{qe(e)}],["org.haiyue.audio-events@1",e=>{dt(e)}],["org.haiyue.animation-state-machine@2",e=>{kt(e)}]]);function pn(e,t){let n=t?2:0;for(let o=0;o<e.length;o++){const i=e.charCodeAt(o);!t||34!==i&&92!==i?t&&i<32?n+=[8,9,10,12,13].includes(i)?2:6:i>=55296&&i<=56319&&e.charCodeAt(o+1)>=56320&&e.charCodeAt(o+1)<=57343?(n+=4,o++):n+=i>=55296&&i<=57343?t?6:3:i<128?1:i<2048?2:3:n+=2}return n}function mn(e){return null===e||"object"!=typeof e?JSON.stringify(e):Array.isArray(e)?"["+e.map(mn).join(",")+"]":"{"+Object.keys(e).sort().map(t=>JSON.stringify(t)+":"+mn(e[t])).join(",")+"}"}function fn(e,t){let n=e;if(e instanceof ArrayBuffer||e instanceof Uint8Array){if(e.byteLength>t.maxInputBytes)throw new i("E_HYA_COMPOSITION_LIMIT","$","Input byte ceiling exceeded.");try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{throw new i("E_HYA_COMPOSITION_FORMAT","$","Input is not valid UTF-8.")}}if("string"==typeof n){if(n.length>t.maxInputBytes||pn(n,!1)>t.maxInputBytes)throw new i("E_HYA_COMPOSITION_LIMIT","$","Input byte ceiling exceeded.");try{n=JSON.parse(n)}catch{throw new i("E_HYA_COMPOSITION_FORMAT","$","Input is not valid JSON.")}}return JSON.parse(mn(function(e,t){let n=0,o=0;const s=new Set,r=(e,t)=>{throw new i("E_HYA_COMPOSITION_FORMAT",e,t)},a=(e,n)=>{if(o+=e,o>t.maxInputBytes)throw new i("E_HYA_COMPOSITION_LIMIT",n,"JSON bytes exceed the input ceiling.")},c=(e,n)=>{if(e.length>t.maxStringBytes||pn(e,!1)>t.maxStringBytes)throw new i("E_HYA_COMPOSITION_LIMIT",n,"String exceeds the UTF-8 ceiling.");a(pn(e,!0),n)},d=(e,o,u)=>{if(++n>t.maxJsonNodes||u>t.maxDepth)throw new i("E_HYA_COMPOSITION_LIMIT",o,"JSON nodes or depth exceed the ceiling.");if(null===e)return void a(4,o);if("boolean"==typeof e)return void a(e?4:5,o);if("number"==typeof e)return Number.isFinite(e)||r(o,"Numbers must be finite."),void a(String(e).length,o);if("string"==typeof e)return void c(e,o);"object"!=typeof e&&r(o,"Only JSON data is allowed.");const l=e;s.has(l)&&r(o,"JSON cycles are forbidden.");const $=Array.isArray(e);if(Object.getPrototypeOf(e)===($?Array.prototype:Object.prototype)||!$&&null===Object.getPrototypeOf(e)||r(o,"Only plain objects and arrays are allowed."),$&&e.length>t.maxJsonNodes)throw new i("E_HYA_COMPOSITION_LIMIT",o,"Array exceeds the node ceiling.");const p=Reflect.ownKeys(l);if(p.length>t.maxJsonNodes+($?1:0))throw new i("E_HYA_COMPOSITION_LIMIT",o,"Object exceeds the node ceiling.");$&&p.length!==e.length+1&&r(o,"Arrays must be dense and have no extra properties."),s.add(l),a(2+Math.max(0,p.length-($?2:1)),o);for(const t of p){if($&&"length"===t)continue;if("string"!=typeof t)throw new i("E_HYA_COMPOSITION_FORMAT",o,"Symbols are forbidden.");["__proto__","prototype","constructor"].includes(t)&&r(o,"Reserved keys are forbidden.");const n=Object.getOwnPropertyDescriptor(l,t);n.enumerable&&"value"in n||r(o,"Accessors and hidden properties are forbidden."),$&&(!/^(0|[1-9][0-9]*)$/u.test(t)||Number(t)>=e.length)&&r(o,"Array property is not an index."),$||(c(t,o),a(1,o)),d(n.value,$?`${o}[${t}]`:`${o}.${t}`,u+1)}s.delete(l)};return d(e,"$",1),e}(n,t)))}function gn(e){if(e&&"object"==typeof e&&!Object.isFrozen(e)){for(const t of Object.values(e))gn(t);Object.freeze(e)}return e}function hn(e,t){throw new i("E_HYA_COMPOSITION_FORMAT",e,t)}function En(e,t){return e&&"object"==typeof e&&!Array.isArray(e)||hn(t,"Expected object."),e}function _n(e,t,n){for(const o of Object.keys(e))t.includes(o)||hn(n+"."+o,"Unknown field.");for(const o of t)o in e||hn(n+"."+o,"Missing field.")}function yn(e,t,n){if(Array.isArray(e)||hn(t,"Expected array."),e.length>n)throw new i("E_HYA_COMPOSITION_LIMIT",t,"Count ceiling exceeded.");return e}function An(e,t){return("string"!=typeof e||!e.length||e.length>256||/[\u0000-\u001f]/u.test(e))&&hn(t,"Expected a bounded stable ID."),e}function bn(e,t){const n=An(e,t);return/^[a-z0-9]+(?:[.-][a-z0-9]+)+@[1-9][0-9]*$/iu.test(n)||hn(t,"Expected a namespaced major-version ID."),n}function Tn(e,t,n,o=!1){const i=yn(e,t,n).map((e,n)=>o?bn(e,`${t}[${n}]`):An(e,`${t}[${n}]`));return new Set(i).size!==i.length&&hn(t,"Duplicate IDs are forbidden."),i}function xn(e){return void 0!==e.strict&&"boolean"!=typeof e.strict&&hn("$options.strict","Expected boolean."),!1!==e.strict}function In(n,s={}){const r=function(e={}){const t={...o};for(const[n,o]of Object.entries(e)){if(!(n in t)||!Number.isSafeInteger(o)||o<=0||o>t[n])throw new i("E_HYA_COMPOSITION_LIMIT","$options.limits."+n,"Limits may only tighten positive hard ceilings.");t[n]=o}return Object.freeze(t)}(s.limits),a=xn(s);if(s.validators)for(const e of s.validators.keys())$n.has(e)&&hn("$options.validators","Built-in format validators cannot be replaced.");const c=En(gn(fn(n,r)),"$");if(_n(c,["format","version","parts","targets"],"$"),c.format!==t&&hn("$.format","Expected haiyue-composition."),1!==c.version)throw new i("E_HYA_COMPOSITION_VERSION","$.version","Unsupported composition version.");const d=yn(c.parts,"$.parts",r.maxParts),u=new Map,l=[];for(const[t,n]of d.entries()){const o=`$.parts[${t}]`,c=En(n,o);_n(c,["id","extension","required","requires","dependencies","document"],o);const d=An(c.id,o+".id"),$=bn(c.extension,o+".extension");u.has(d)&&hn(o+".id","Duplicate part ID."),"boolean"!=typeof c.required&&hn(o+".required","Expected explicit boolean."),Tn(c.requires,o+".requires",r.maxRequirementsPerPart,!0),Tn(c.dependencies,o+".dependencies",r.maxParts);const p="org.haiyue.animation-core@1"===$&&s.coreExtensions?t=>{e(t,{extensions:s.coreExtensions})}:$n.get($)??s.validators?.get($);if(p)try{p(c.document)}catch(e){const t=e,n="string"==typeof t?.path&&t.path.startsWith("$")?t.path.slice(1):"";throw new i("E_HYA_COMPOSITION_PART",o+".document"+n,"Part validation failed.",$,"string"==typeof t?.code?t.code:void 0)}else{if(c.required||a)throw new i(c.required?"E_HYA_COMPOSITION_REQUIRED":"E_HYA_COMPOSITION_OPTIONAL",o+".extension","No format validator is registered.",$);l.push({code:"W_HYA_COMPOSITION_OPTIONAL_SKIPPED",path:o+".extension",capability:$,part:d})}u.set(d,c)}const $=new Set,p=new Set,m=e=>{if($.has(e.id))throw new i("E_HYA_COMPOSITION_GRAPH","$.parts","Part dependency cycle.",e.extension);if(!p.has(e.id)){$.add(e.id);for(const t of e.dependencies){const n=u.get(t);if(!n)throw new i("E_HYA_COMPOSITION_REFERENCE","$.parts","Missing dependency "+t,e.extension);m(n)}$.delete(e.id),p.add(e.id)}};u.forEach(m);const f=new Set,g=new Map;for(const[e,t]of yn(c.targets,"$.targets",r.maxTargets).entries()){const n=`$.targets[${e}]`,o=En(t,n);_n(o,["id","part","kind","address"],n);const s=An(o.id,n+".id"),r=An(o.part,n+".part");f.has(s)&&hn(n+".id","Duplicate target alias."),f.add(s);const a=u.get(r);if(!a)throw new i("E_HYA_COMPOSITION_REFERENCE",n+".part","Target part does not exist.");const c=yn(o.address,n+".address",2).map((e,t)=>An(e,`${n}.address[${t}]`));c.length||hn(n+".address","Target address must not be empty.");const d=o.kind;if(["animation-node","layout-node","text-block","asset","state-input","interaction-target","semantic-node","audio-cue"].includes(d)||hn(n+".kind","Unknown target kind."),!l.some(e=>e.part===r)){let e=g.get(r);if(e||(e=vn(a),g.set(r,e)),!e(d,c))throw new i("E_HYA_COMPOSITION_REFERENCE",n+".address","Target address does not exist in its typed part.",a.extension)}}const h=new Map(c.targets.map(e=>[e.id,e]));for(const[e,t]of[...u.values()].entries())if("org.haiyue.data-binding@1"===t.extension){const n=t.document.bindings;for(const[o,s]of n.entries()){const n=h.get(s.target);if(!n)throw new i("E_HYA_COMPOSITION_REFERENCE",`$.parts[${e}].document.bindings[${o}].target`,"Data target alias is not declared.",t.extension);if(n.part!==t.id&&!t.dependencies.includes(n.part))throw new i("E_HYA_COMPOSITION_GRAPH",`$.parts[${e}].dependencies`,"Data target part must be an explicit dependency.",t.extension)}}return gn({document:c,diagnostics:l})}function vn(e){const t=e.document,n=e=>new Set(e?.map(e=>e.id)??[]),o=(e,t)=>new Map(e.map(e=>[e.id,n(e[t])])),i=new Map,s=new Map;switch(e.extension){case"org.haiyue.animation-core@1":i.set("animation-node",n(t.nodes)),i.set("asset",n(t.resources));break;case"org.haiyue.layout-2d@1":s.set("layout-node",o(t.artboards,"nodes")),i.set("text-block",n(t.textBlocks)),i.set("asset",n(t.assets));break;case"org.haiyue.animation-state-machine@2":s.set("state-input",o(t.stateMachines,"inputs"));break;case"org.haiyue.interaction@1":i.set("interaction-target",n(t.targets));break;case"org.haiyue.semantics@1":i.set("semantic-node",n(t.nodes));break;case"org.haiyue.audio-events@1":i.set("audio-cue",n(t.cues))}return(e,t)=>1===t.length?!0===i.get(e)?.has(t[0]):2===t.length&&!0===s.get(e)?.get(t[0])?.has(t[1])}function Nn(e,t={}){const{document:n}=In(e,t);return(new TextEncoder).encode(mn(n))}function On(e,t,n={}){const{document:o,diagnostics:s}=In(e,n),r=[...s],a=xn(n),c=new Set(s.map(e=>e.part)),d=new Set;let u;o.parts.forEach((e,n)=>{if(c.has(e.id))return;const o=[e.extension,...e.requires].find(e=>!t.has(e));if(o){const t=o===e.extension?`$.parts[${n}].extension`:`$.parts[${n}].requires[${e.requires.indexOf(o)}]`;if(e.required||a)throw new i("E_HYA_COMPOSITION_CAPABILITY",t,"Host capability is unavailable.",o);c.add(e.id),r.push({code:"W_HYA_COMPOSITION_OPTIONAL_SKIPPED",path:t,capability:o,part:e.id})}});do{u=!1;for(const[e,t]of o.parts.entries())if(!c.has(t.id)&&t.dependencies.some(e=>c.has(e))){if(t.required||a)throw new i("E_HYA_COMPOSITION_REFERENCE",`$.parts[${e}].dependencies`,"An active part depends on a skipped part.",t.extension);c.add(t.id),u=!0,r.push({code:"W_HYA_COMPOSITION_OPTIONAL_SKIPPED",path:`$.parts[${e}].dependencies`,capability:t.extension,part:t.id})}}while(u);const l=new Map(o.parts.map(e=>[e.id,e])),$=e=>{d.has(e.id)||c.has(e.id)||(e.dependencies.forEach(e=>$(l.get(e))),d.add(e.id))};return o.parts.forEach($),gn({document:o,activeParts:[...d],targets:o.targets.filter(e=>d.has(e.part)),diagnostics:r,complete:0===r.length})}const Mn=1095522632,Sn=new TextEncoder,wn=new TextDecoder("utf-8",{fatal:!0});function kn(e){return e.byteLength>=4&&new DataView(e).getUint32(0,!0)===Mn}function Rn(e,t={}){const n=c(e,t),o=[];let i=0;const s={...n,assets:n.assets.map(e=>"embedded"===e.source?.kind?{...e,source:{...e.source,data:r(e.source.data)}}:e)};function r(e){const t=[i,e.length];return i=Vn(i,e.length,"$binary.bytes"),o.push(e),t}const d=Sn.encode(JSON.stringify(s)),u={...a,...t.limits};d.byteLength>u.maxMetadataBytes&&Hn("metadata exceeds limit","$binary.metadata");const l=Vn(40,d.byteLength,"$binary.bytes"),$=Vn(l,i,"$binary");$>u.maxInputBytes&&Hn("binary exceeds input limit","$binary");const p=new ArrayBuffer($),m=new DataView(p);m.setUint32(0,Mn,!0),m.setUint16(4,1,!0),m.setUint16(6,0,!0),m.setUint32(8,40,!0),m.setUint32(12,d.byteLength,!0),m.setUint32(16,l,!0),m.setUint32(20,i,!0),m.setUint32(24,$,!0),m.setUint32(28,0,!0),m.setUint32(32,0,!0),m.setUint32(36,0,!0),new Uint8Array(p,40,d.length).set(d);const f=new Uint8Array(p,l,i);let g=0;for(const e of o){for(let t=0;t<e.length;t++)f[g+t]=e[t];g+=e.length}return p}function Cn(e,t={}){const n={...a,...t.limits};e.byteLength>n.maxInputBytes&&Hn("input exceeds limit","$binary"),e.byteLength<40&&Un("header is truncated","$binary");const o=new DataView(e);o.getUint32(0,!0)!==Mn&&Un("magic must be HYLA","$binary.magic");const i=o.getUint16(4,!0),s=o.getUint16(6,!0);1===i&&0===s||Un(`unsupported version ${i}.${s}`,"$binary.version");const r=o.getUint32(8,!0),d=o.getUint32(12,!0),u=o.getUint32(16,!0),l=o.getUint32(20,!0),$=o.getUint32(24,!0),p=o.getUint32(28,!0),m=o.getUint32(32,!0),f=o.getUint32(36,!0);let g;0===p&&0===m&&0===f||Un("unknown flags or reserved bits","$binary.flags"),$!==e.byteLength&&Un("declared length mismatch","$binary.length"),(40!==r||d>n.maxMetadataBytes)&&Un("metadata range is invalid","$binary.metadata"),Fn(r,d,e.byteLength,"$binary.metadata"),u!==r+d&&Un("byte pool is non-canonical","$binary.bytes"),Fn(u,l,e.byteLength,"$binary.bytes"),u+l!==e.byteLength&&Un("trailing bytes are forbidden","$binary");try{g=JSON.parse(wn.decode(new Uint8Array(e,r,d)))}catch(e){Un(`invalid metadata JSON: ${e instanceof Error?e.message:String(e)}`,"$binary.metadata")}const h=Dn(g,"$binary.metadata"),E=Pn(h.assets,"$.assets"),_=[];for(const[e,t]of E.entries()){const n=Dn(t,`$.assets[${e}]`);if(void 0===n.source)continue;const o=Dn(n.source,`$.assets[${e}].source`);"embedded"===o.kind&&_.push(Bn(o.data,l,`$.assets[${e}].source.data`))}!function(e,t){let n=0;for(const[t,o]of e)t!==n&&Un("byte ranges alias, overlap, or contain gaps","$binary.bytes"),n+=o;n!==t&&Un("byte pool has unreferenced data","$binary.bytes")}(_,l);const y=new Uint8Array(e,u,l),A=structuredClone(h),b=Pn(A.assets,"$.assets");for(const[e,t]of b.entries()){const n=Dn(t,`$.assets[${e}]`);if(void 0===n.source)continue;const o=Dn(n.source,`$.assets[${e}].source`);if("embedded"===o.kind){const t=Bn(o.data,l,`$.assets[${e}].source.data`);o.data=y.subarray(t[0],t[0]+t[1])}}return c(A,t)}function Dn(e,t){return e&&"object"==typeof e&&!Array.isArray(e)||Un("expected object",t),e}function Pn(e,t){return Array.isArray(e)||Un("expected array",t),e}function Bn(e,t,n){Array.isArray(e)&&2===e.length&&e.every(e=>Number.isSafeInteger(e)&&e>=0)||Un("expected non-negative [offset,length]",n);const o=e[0],i=e[1];return(o>t||i>t-o)&&Un("range exceeds byte pool",n),[o,i]}function Fn(e,t,n,o){(e>n||t>n-e)&&Un("range exceeds input",o)}function Vn(e,t,n){const o=e+t;return(!Number.isSafeInteger(o)||o>4294967295)&&Hn("offset overflow",n),o}function Un(e,t){throw new r("E_LAYOUT_BINARY",t,e)}function Hn(e,t){throw new r("E_LAYOUT_LIMIT",t,e)}function Ln(e,t={}){const n=qn(e,"$");zn(n,["clips","stateMachine"],"$");const o=Wn(n.clips,"$.clips"),i=new Set,s=o.map((e,n)=>{const o=`$.clips[${n}]`,s=qn(e,o);zn(s,["id","name","start","duration"],o,!0);const r=function(e,t,n){t.has(e)&&no(n,`duplicate id ${e}`);return t.add(e),e}(Kn(s.id,`${o}.id`),i,`${o}.id`);return Zn(s.start,`${o}.start`),{id:r,...void 0===s.name?{}:{name:Jn(s.name,`${o}.name`)},duration:Qn(s.duration,`${o}.duration`),tracks:[...t.tracksByClip?.[r]??[]]}}),r=qn(n.stateMachine,"$.stateMachine");zn(r,["format","id","name","parameters","layers"],"$.stateMachine"),"haiyue-animation-state-machine@1"!==r.format&&no("$.stateMachine.format","expected haiyue-animation-state-machine@1");const a=Wn(r.parameters,"$.stateMachine.parameters").map((e,t)=>{const n=`$.stateMachine.parameters[${t}]`,o=qn(e,n);zn(o,["name","type","defaultValue"],n,!0);const i=Kn(o.name,`${n}.name`),s=Jn(o.type,`${n}.type`);return"trigger"===s?{id:i,type:s}:"boolean"===s?{id:i,type:s,defaultValue:to(o.defaultValue,`${n}.defaultValue`)}:"integer"===s?{id:i,type:s,defaultValue:eo(o.defaultValue,`${n}.defaultValue`)}:"float"===s?{id:i,type:"number",defaultValue:Xn(o.defaultValue,`${n}.defaultValue`)}:void no(`${n}.type`,`unsupported v1 parameter type ${s}`)}),c=new Map(a.map(e=>[e.id,e.type])),d=Wn(r.layers,"$.stateMachine.layers").map((e,t)=>{const n=`$.stateMachine.layers[${t}]`,o=qn(e,n);zn(o,["id","name","initialStateId","states","transitions","blendMode","weight","mask"],n,!0);const s=Kn(o.initialStateId,`${n}.initialStateId`),r=Wn(o.states,`${n}.states`).map((e,t)=>{const o=`${n}.states[${t}]`,s=qn(e,o);return zn(s,["id","name","motion","speed","speedParameter","loop"],o,!0),{id:Kn(s.id,`${o}.id`),motion:jn(s.motion,s,`${o}.motion`,c,i)}}),a=Wn(o.transitions,`${n}.transitions`).map((e,t)=>{const o=`${n}.transitions[${t}]`,i=qn(e,o);zn(i,["id","from","to","conditions","duration","hasExitTime","exitTime","destinationOffset","interruption"],o,!0);const s=Wn(i.conditions,`${o}.conditions`);return{id:Kn(i.id,`${o}.id`),from:"*"===i.from?"@any":Kn(i.from,`${o}.from`),to:Kn(i.to,`${o}.to`),conditionGroups:0===s.length?[]:[s.map((e,t)=>function(e,t,n){const o=qn(e,t),i=Yn(o.parameter,n,`${t}.parameter`),s=Jn(o.operator,`${t}.operator`),r=n.get(i);if("triggered"===s)return{kind:"trigger",input:i};if("is-true"===s||"is-false"===s)return{kind:"input",input:i,comparator:"equal",value:"is-true"===s};const a={greater:"greater","greater-or-equal":"greater-or-equal",less:"less","less-or-equal":"less-or-equal",equal:"equal","not-equal":"not-equal"}[s];a||no(`${t}.operator`,`unsupported operator ${s}`);const c=o.value;"boolean"===r?to(c,`${t}.value`):"integer"===r?eo(c,`${t}.value`):Xn(c,`${t}.value`);return{kind:"input",input:i,comparator:a,value:c}}(e,`${o}.conditions[${t}]`,c))],...!0===i.hasExitTime?{exitTime:Zn(i.exitTime,`${o}.exitTime`)}:{},duration:Zn(i.duration,`${o}.duration`),...void 0===i.destinationOffset?{}:{destinationOffset:Zn(i.destinationOffset,`${o}.destinationOffset`)},...void 0===i.interruption?{}:{interruption:Jn(i.interruption,`${o}.interruption`)},interpolation:{kind:"linear"}}});return{id:Kn(o.id,`${n}.id`),order:t,...void 0===o.weight?{}:{weight:Xn(o.weight,`${n}.weight`)},...void 0===o.blendMode?{}:{mode:Jn(o.blendMode,`${n}.blendMode`)},...void 0===o.mask?{}:{mask:structuredClone(o.mask)},states:r,transitions:[{id:`@entry:${s}`,from:"@entry",to:s,conditionGroups:[],duration:0},...a]}}),u={format:wt,extension:St,channels:[...t.channels??[]],clips:s,stateMachines:[{id:Kn(r.id,"$.stateMachine.id"),inputs:a,layers:d}]},l=[{code:"W_STATE_MACHINE_V1_MIGRATED",path:"$.stateMachine.format",message:"The v1 graph was normalized to state-machine v2; runtime execution uses only the v2 sampler."}];return void 0!==t.channels&&void 0!==t.tracksByClip||l.push({code:"W_STATE_MACHINE_V1_CHANNEL_POLICY_REQUIRED",path:"$.clips",message:"The graph is migrated, but parent HYA tracks require compiler-supplied v2 channel policies before visual execution."}),Object.freeze({document:kt(u),diagnostics:Object.freeze(l.map(e=>Object.freeze(e)))})}function jn(e,t,n,o,i){const s=qn(e,n),r=Jn(s.kind,`${n}.kind`);if("clip"===r){const e=Kn(s.clipId,`${n}.clipId`);return i.has(e)||no(`${n}.clipId`,`unknown clip ${e}`),a={kind:"clip",clip:e},{...a,...void 0===t.speed?{}:{speed:Xn(t.speed,`${n}.__state.speed`)},...void 0===t.speedParameter?{}:{speedInput:Yn(t.speedParameter,o,`${n}.__state.speedParameter`)},...void 0===t.loop?{}:{playback:Gn(t.loop,`${n}.__state.loop`)}}}var a;return"blend-1d"===r?{kind:r,input:Yn(s.parameter,o,`${n}.parameter`),children:Wn(s.children,`${n}.children`).map((e,s)=>{const r=qn(e,`${n}.children[${s}]`);return{threshold:Xn(r.threshold,`${n}.children[${s}].threshold`),motion:jn(r.motion,t,`${n}.children[${s}].motion`,o,i)}})}:"blend-2d"===r?{kind:r,algorithm:Jn(s.algorithm,`${n}.algorithm`),inputX:Yn(s.parameterX,o,`${n}.parameterX`),inputY:Yn(s.parameterY,o,`${n}.parameterY`),children:Wn(s.children,`${n}.children`).map((e,s)=>{const r=qn(e,`${n}.children[${s}]`),a=Wn(r.position,`${n}.children[${s}].position`);return 2!==a.length&&no(`${n}.children[${s}].position`,"expected two values"),{position:[Xn(a[0],`${n}.children[${s}].position[0]`),Xn(a[1],`${n}.children[${s}].position[1]`)],motion:jn(r.motion,t,`${n}.children[${s}].motion`,o,i)}})}:void no(`${n}.kind`,`unsupported v1 motion ${r}`)}function Gn(e,t){const n=Jn(e,t);return"once"===n?"one-shot":"repeat"===n?"loop":"ping-pong"===n?n:void no(t,`unsupported loop ${n}`)}function Yn(e,t,n){const o=Kn(e,n);return t.has(o)||no(n,`unknown input ${o}`),o}function zn(e,t,n,o=!1){for(const o of Object.keys(e))t.includes(o)||no(`${n}.${o}`,"unknown v1 property");if(!o)for(const o of t)o in e||no(`${n}.${o}`,"missing v1 property")}function qn(e,t){return(!e||"object"!=typeof e||Array.isArray(e)||ArrayBuffer.isView(e))&&no(t,"expected object"),e}function Wn(e,t){return Array.isArray(e)||no(t,"expected array"),e}function Jn(e,t){return"string"!=typeof e&&no(t,"expected string"),e}function Kn(e,t){const n=Jn(e,t);return n||no(t,"expected non-empty identifier"),n}function Xn(e,t){return"number"==typeof e&&Number.isFinite(e)||no(t,"expected finite number"),e}function Zn(e,t){const n=Xn(e,t);return n<0&&no(t,"expected non-negative number"),n}function Qn(e,t){const n=Xn(e,t);return n<=0&&no(t,"expected positive number"),n}function eo(e,t){const n=Xn(e,t);return Number.isSafeInteger(n)||no(t,"expected safe integer"),n}function to(e,t){return"boolean"!=typeof e&&no(t,"expected boolean"),e}function no(e,t){return Ot("E_STATE_MACHINE_V2_MIGRATION",e,t)}export{st as AudioEventDiagnostic,o as DEFAULT_HYA_COMPOSITION_LIMITS,J as DataBindingDiagnostic,t as HYA_COMPOSITION_FORMAT,n as HYA_COMPOSITION_VERSION,i as HyaCompositionError,be as InteractionDiagnostic,r as LayoutDiagnostic,Ye as SemanticsDiagnostic,Nt as StateMachineV2Diagnostic,Cn as decodeResponsiveLayoutDocument,Nn as encodeHyaComposition,Rn as encodeResponsiveLayoutDocument,kn as isResponsiveLayoutBinary,Ln as migrateHyaStateMachineV1,On as negotiateHyaComposition,dt as parseHyaAudioEvents,In as parseHyaComposition,Z as parseHyaDataBinding,Ie as parseHyaInteraction,qe as parseHyaSemantics,kt as parseHyaStateMachineV2,c as parseResponsiveLayoutDocument};//# sourceMappingURL=hya-production.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { b3 as ANIMATION_FILE_EXTENSION, b4 as ANIMATION_FORMAT, b5 as ANIMATION_MIME_TYPE, b6 as ANIMATION_VECTOR_SHAPE_EXTENSION_ID, b7 as ANIMATION_VERSION, b8 as AnimationAudioComponent, b9 as AnimationAudioResource, ba as AnimationBinaryResource, bb as AnimationBlurEffect, bc as AnimationCanvas, bd as AnimationColorMatrixEffect, be as AnimationComponent, bf as AnimationComposite, bg as AnimationCompositeKind, bh as AnimationCompositeLayer, bi as AnimationCompositeMode, bj as AnimationCompositeOperation, bk as AnimationCompositeStack, bl as AnimationCoordinateSystem, bm as AnimationDocument, bn as AnimationDropShadowEffect, bo as AnimationEndBehavior, bp as AnimationExtensionComponent, bq as AnimationExtensionHandler, br as AnimationExtensionRegistry, bs as AnimationExtensionValidationContext, bt as AnimationFillEffect, bu as AnimationFillRule, bv as AnimationFormatError, bw as AnimationFormatErrorCode, bx as AnimationImageResource, by as AnimationInterpolation, bz as AnimationLayerEffect, bA as AnimationNode, bB as AnimationOpacityEffect, bC as AnimationParseLimits, bD as AnimationParseOptions, bE as AnimationParticle2DComponent, bF as AnimationPath2DComponent, bG as AnimationPathCommand, bH as AnimationResource, bI as AnimationSafeExpressionContext, bJ as AnimationSafeExpressionInstruction, bK as AnimationSafeExpressionProgram, bL as AnimationShape2DComponent, bM as AnimationSource, bN as AnimationSprite2DComponent, bO as AnimationText2DComponent, bP as AnimationTextAnimator, bQ as AnimationTextDocumentKeyframe, bR as AnimationTextRangeSelector, bS as AnimationTextSelectorShape, bT as AnimationTextSelectorUnits, bU as AnimationTextStyleRun, bV as AnimationTintEffect, bW as AnimationTrack, bX as AnimationTrackProperty, bY as AnimationTransform2D, bZ as AnimationVectorFeather, b_ as AnimationVectorGradientPaint, b$ as AnimationVectorShapeComponent, c0 as AnimationVectorSolidPaint, c1 as AnimationVectorStrokePaint, c2 as AnimationVectorValueTrack, c3 as HYA_SAFE_EXPRESSION_VERSION, c4 as HYA_STATE_MACHINE_CHANNEL_REGISTRY, c5 as HYA_STATE_MACHINE_EXTENSION_ID, c6 as HyaAnimationClipRange, c7 as HyaStateMachineBindingMask, c8 as HyaStateMachineBlendMode, c9 as HyaStateMachineChannelCapability, ca as HyaStateMachineChannelId, cb as HyaStateMachineChannelKind, cc as HyaStateMachineChannelSupport, cd as HyaStateMachineCondition, ce as HyaStateMachineDefinition, cf as HyaStateMachineExtension, cg as HyaStateMachineLayer, ch as HyaStateMachineLoopMode, ci as HyaStateMachineMotion, cj as HyaStateMachineParameter, ck as HyaStateMachineState, cl as HyaStateMachineTransition, cm as ParsedAnimation, cn as ParsedAnimationTrack, co as decodeAnimationBinary, cp as encodeAnimationBinary, cq as evaluateSafeExpression, cr as extensionIdFromComponentType, cs as hyaStateMachineChannelCapability, ct as isAnimationBinary, cu as parseAnimation, cv as parseHyaStateMachineExtension, cw as safeExpressionDataResources, cx as validateExtensionId } from './shared.js';
|
package/dist/lottie.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { cy as LottieConversionDiagnostic, cz as LottieConversionOptions, cA as LottieConversionResult, cB as LottieFontMetrics, cC as LottieFontRequirement, cD as LottieWebFontMapping, cE as convertLottie, cF as convertLottieDocument, cG as inspectLottieFonts } from './shared.js';
|
package/dist/native3d.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { cH as NATIVE_3D_ANIMATION_EXTENSION_ID, cI as NATIVE_3D_ANIMATION_FORMAT, cJ as NATIVE_3D_CLIP_FORMAT, cK as NATIVE_3D_STATE_MACHINE_FORMAT, cL as Native3DAnimationDiagnosticCode, cM as Native3DAnimationFormatError, cN as Native3DAnimationParseOptions, cO as Native3DAnimationPayload, cP as Native3DAnimationSource, cQ as Native3DBinding, cR as Native3DBindingTarget, cS as Native3DCameraComponent, cT as Native3DCameraProjection, cU as Native3DClip, cV as Native3DComponent, cW as Native3DCoordinateSystem, cX as Native3DEvent, cY as Native3DMaterial, cZ as Native3DModelComponent, c_ as Native3DNode, c$ as Native3DParseLimits, d0 as Native3DParticleComponent, d1 as Native3DParticleDescriptor, d2 as Native3DPrimitiveComponent, d3 as Native3DQuaternion, d4 as Native3DScalarRange, d5 as Native3DStateMachine, d6 as Native3DStateMachineCondition, d7 as Native3DStateMachineLayer, d8 as Native3DStateMachineMotion, d9 as Native3DStateMachineParameter, da as Native3DStateMachineState, db as Native3DStateMachineTransition, dc as Native3DTrack, dd as Native3DTransform, de as Native3DVec2, df as Native3DVec3, dg as Native3DVec4, dh as Native3DViewport, di as ParsedNative3DAnimation, dj as createNative3DAnimationExtensionHandler, dk as parseNative3DAnimation, dl as parseNative3DAnimationPayload } from './shared.js';
|