route-engine-js 1.49.1 → 1.50.0
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/README.md +2 -0
- package/dist/RouteEngine.js +5 -5
- package/package.json +1 -1
package/dist/RouteEngine.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var cy=Object.create;var Ki=Object.defineProperty;var uy=Object.getOwnPropertyDescriptor;var py=Object.getOwnPropertyNames;var fy=Object.getPrototypeOf,dy=Object.prototype.hasOwnProperty;var my=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yy=(e,t)=>{for(var n in t)Ki(e,n,{get:t[n],enumerable:!0})},hy=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of py(t))!dy.call(e,a)&&a!==n&&Ki(e,a,{get:()=>t[a],enumerable:!(i=uy(t,a))||i.enumerable});return e};var gy=(e,t,n)=>(n=e!=null?cy(fy(e)):{},hy(t||!e||!e.__esModule?Ki(n,"default",{value:e,enumerable:!0}):n,e));var Uf=my(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});function Bf(e){let t=e.length,n=0,i=0,a;for(;i<t;)n++,a=e.charCodeAt(i++),a>=55296&&a<=56319&&i<t&&(a=e.charCodeAt(i),(a&64512)===56320&&i++);return n}tl.default=Bf;Bf.code='require("ajv/dist/runtime/ucs2length").default'});var Ll=Symbol.for("immer-nothing"),_l=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state");function Xe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var vt=Object.getPrototypeOf;function Ie(e){return!!e&&!!e[Le]}function Qr(e){return e?Ml(e)||Array.isArray(e)||!!e[_l]||!!e.constructor?.[_l]||Xn(e)||Gn(e):!1}var by=Object.prototype.constructor.toString();function Ml(e){if(!e||typeof e!="object")return!1;let t=vt(e);if(t===null)return!0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===by}function Yn(e){return Ie(e)||Xe(15,e),e[Le].base_}function Fn(e,t){zn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,i)=>t(i,n,e))}function zn(e){let t=e[Le];return t?t.type_:Array.isArray(e)?1:Xn(e)?2:Gn(e)?3:0}function Qi(e,t){return zn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Vl(e,t,n){let i=zn(e);i===2?e.set(t,n):i===3?e.add(n):e[t]=n}function wy(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Xn(e){return e instanceof Map}function Gn(e){return e instanceof Set}function Jr(e){return e.copy_||e.base_}function Zi(e,t){if(Xn(e))return new Map(e);if(Gn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Ml(e);if(t===!0||t==="class_only"&&!n){let i=Object.getOwnPropertyDescriptors(e);delete i[Le];let a=Reflect.ownKeys(i);for(let r=0;r<a.length;r++){let s=a[r],o=i[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(i[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[s]})}return Object.create(vt(e),i)}else{let i=vt(e);if(i!==null&&n)return{...e};let a=Object.create(i);return Object.assign(a,e)}}function so(e,t=!1){return Hn(e)||Ie(e)||!Qr(e)||(zn(e)>1&&(e.set=e.add=e.clear=e.delete=Iy),Object.freeze(e),t&&Object.entries(e).forEach(([n,i])=>so(i,!0))),e}function Iy(){Xe(2)}function Hn(e){return Object.isFrozen(e)}var vy={};function Zr(e){let t=vy[e];return t||Xe(0,e),t}var Xt;function ql(){return Xt}function ky(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Nl(e,t){t&&(Zr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function eo(e){ro(e),e.drafts_.forEach(Ay),e.drafts_=null}function ro(e){e===Xt&&(Xt=e.parent_)}function jl(e){return Xt=ky(Xt,e)}function Ay(e){let t=e[Le];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Tl(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Le].modified_&&(eo(t),Xe(4)),Qr(e)&&(e=Bn(t,e),t.parent_||Un(t,e)),t.patches_&&Zr("Patches").generateReplacementPatches_(n[Le].base_,e,t.patches_,t.inversePatches_)):e=Bn(t,n,[]),eo(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ll?e:void 0}function Bn(e,t,n){if(Hn(t))return t;let i=t[Le];if(!i)return Fn(t,(a,r)=>Dl(e,i,t,a,r,n)),t;if(i.scope_!==e)return t;if(!i.modified_)return Un(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let a=i.copy_,r=a,s=!1;i.type_===3&&(r=new Set(a),a.clear(),s=!0),Fn(r,(o,l)=>Dl(e,i,a,o,l,n,s)),Un(e,a,!1),n&&e.patches_&&Zr("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Dl(e,t,n,i,a,r,s){if(Ie(a)){let o=r&&t&&t.type_!==3&&!Qi(t.assigned_,i)?r.concat(i):void 0,l=Bn(e,a,o);if(Vl(n,i,l),Ie(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Qr(a)&&!Hn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Bn(e,a),(!t||!t.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&Un(e,a)}}function Un(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&so(t,n)}function Py(e,t){let n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:ql(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=i,r=io;n&&(a=[i],r=Gt);let{revoke:s,proxy:o}=Proxy.revocable(a,r);return i.draft_=o,i.revoke_=s,o}var io={get(e,t){if(t===Le)return e;let n=Jr(e);if(!Qi(n,t))return xy(e,n,t);let i=n[t];return e.finalized_||!Qr(i)?i:i===Wi(e.base_,t)?(Ji(e),e.copy_[t]=no(i,e)):i},has(e,t){return t in Jr(e)},ownKeys(e){return Reflect.ownKeys(Jr(e))},set(e,t,n){let i=Fl(Jr(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){let a=Wi(Jr(e),t),r=a?.[Le];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(wy(n,a)&&(n!==void 0||Qi(e.base_,t)))return!0;Ji(e),to(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Wi(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ji(e),to(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Jr(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:i.enumerable,value:n[t]}},defineProperty(){Xe(11)},getPrototypeOf(e){return vt(e.base_)},setPrototypeOf(){Xe(12)}},Gt={};Fn(io,(e,t)=>{Gt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Gt.deleteProperty=function(e,t){return Gt.set.call(this,e,t,void 0)};Gt.set=function(e,t,n){return io.set.call(this,e[0],t,n,e[0])};function Wi(e,t){let n=e[Le];return(n?Jr(n):e)[t]}function xy(e,t,n){let i=Fl(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}function Fl(e,t){if(!(t in e))return;let n=vt(e);for(;n;){let i=Object.getOwnPropertyDescriptor(n,t);if(i)return i;n=vt(n)}}function to(e){e.modified_||(e.modified_=!0,e.parent_&&to(e.parent_))}function Ji(e){e.copy_||(e.copy_=Zi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ey=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,i)=>{if(typeof t=="function"&&typeof n!="function"){let r=n;n=t;let s=this;return function(l=r,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&Xe(6),i!==void 0&&typeof i!="function"&&Xe(7);let a;if(Qr(t)){let r=jl(this),s=no(t,void 0),o=!0;try{a=n(s),o=!1}finally{o?eo(r):ro(r)}return Nl(r,i),Tl(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===Ll&&(a=void 0),this.autoFreeze_&&so(a,!0),i){let r=[],s=[];Zr("Patches").generateReplacementPatches_(t,a,r,s),i(r,s)}return a}else Xe(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...o)=>this.produceWithPatches(s,l=>t(l,...o));let i,a;return[this.produce(t,n,(s,o)=>{i=s,a=o}),i,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Qr(e)||Xe(8),Ie(e)&&(e=Ge(e));let t=jl(this),n=no(e,void 0);return n[Le].isManual_=!0,ro(t),n}finishDraft(e,t){let n=e&&e[Le];(!n||!n.isManual_)&&Xe(9);let{scope_:i}=n;return Nl(i,t),Tl(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let a=t[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(t=t.slice(n+1));let i=Zr("Patches").applyPatches_;return Ie(e)?i(e,t):this.produce(e,a=>i(a,t))}};function no(e,t){let n=Xn(e)?Zr("MapSet").proxyMap_(e,t):Gn(e)?Zr("MapSet").proxySet_(e,t):Py(e,t);return(t?t.scope_:ql()).drafts_.push(n),n}function Ge(e){return Ie(e)||Xe(10,e),Bl(e)}function Bl(e){if(!Qr(e)||Hn(e))return e;let t=e[Le],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Zi(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Zi(e,!0);return Fn(n,(i,a)=>{Vl(n,i,Bl(a))}),t&&(t.finalized_=!1),n}var qe=new Ey,Kn=qe.produce,cP=qe.produceWithPatches.bind(qe),uP=qe.setAutoFreeze.bind(qe),pP=qe.setUseStrictShallowCopy.bind(qe),fP=qe.applyPatches.bind(qe),dP=qe.createDraft.bind(qe),mP=qe.finishDraft.bind(qe);var S={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},te={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},kt={NOT:0};var V=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},De=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var oo=e=>{if(!e||e.trim()==="")throw new V("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new V(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${n}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let n of t)if(e.trim().endsWith(n))throw new V(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Ul=e=>{if(e.trim().endsWith(" in"))throw new V(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new V(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new V(`Missing iterable expression after 'in' (got: '$for ${e}')`);let i=t.includes(",")?t.split(",").map(a=>a.trim()):[t.trim()];for(let a of i){if(!a)throw new V(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new V(`Invalid loop syntax (got: '$for ${e}')`)}};var Yl=(e,t,n=!1)=>{if(t===null)return new De(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new De(`Cannot iterate over undefined value at '$for ${e}'`);let i=typeof t;return n?new De(`Cannot iterate over non-array value in loop '${e}' - got ${i} instead`):new De(`Cannot iterate over non-array value (got: ${i}) at '$for ${e}'`)},zl=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new De(`Unknown function '${e}' (${n})`)};var Sy=(e,t,n={})=>{let i={},a={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(i=n.functions||{},a=n.partials||{}):typeof n=="object"&&(i=n));let s=se(e,{functions:i,partials:a},t,{});return s===void 0?{}:s},se=(e,t,n,i)=>{let a=t.functions||t;if(e.var&&!e.type)return Pe(e.var,n,i);if(e.type===S.LITERAL)return e.value;if(e.type===S.VARIABLE)return Pe(e.path,n,i);if(e.type===S.INTERPOLATION)return Ry(e.parts,t,n,i);switch(e.type){case S.FUNCTION:return Gl(e,t,n,i);case S.BINARY:return Hl(e,t,n,i);case S.UNARY:return Kl(e,t,n,i);case S.CONDITIONAL:return Cy(e,t,n,i);case S.LOOP:return Dy(e,t,n,i);case S.OBJECT:return My(e,t,n,i);case S.ARRAY:return Vy(e,t,n,i);case S.PARTIAL:return qy(e,t,n,i);case S.PATH_REFERENCE:return Fy(e,t,n,i);default:throw new Error(`Unknown node type: ${e.type}`)}},Xl=new Map,Oy=e=>{let t=[],n="",i=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")n&&(t.push({type:"property",value:n}),n=""),i=!0;else if(r==="]"){if(i&&n){let s=n.trim();if(/^\d+$/.test(s))t.push({type:"index",value:parseInt(s,10)});else if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){let o=s.slice(1,-1);t.push({type:"property",value:o})}else t.push({type:"property",value:s});n=""}i=!1}else n+=r}return n&&t.push({type:"property",value:n}),t},Pe=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let i=Xl.get(e);if(!i){let r=[],s="",o=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(o++,s+=c):c==="]"?(o--,s+=c):c==="."&&o===0?s&&(r.push(s),s=""):s+=c}s&&r.push(s),i=[];for(let l of r){let c=Oy(l.trim());i.push(...c)}Xl.set(e,i)}let a=t;for(let r=0;r<i.length;r++){let s=i[r];if(s.type==="property"&&s.value in n){a=n[s.value];continue}if(a==null)return;(s.type==="property"||s.type==="index")&&(a=a[s.value])}return a},Ry=(e,t,n,i)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=se(r,t,n,i);a.push(s!=null?String(s):"")}return a.join("")},Gl=(e,t,n,i)=>{let a=t.functions||t,r=a[e.name];if(!r)throw zl(e.name,a);let s=e.args.map(o=>se(o,t,n,i));return r(...s)},Nr=(e,t,n,i)=>{if(e.var&&!e.type)return Pe(e.var,n,i);switch(e.type){case S.VARIABLE:return Pe(e.path,n,i);case S.LITERAL:return e.value;case S.BINARY:return Hl(e,t,n,i);case S.UNARY:return Kl(e,t,n,i);case S.FUNCTION:return Gl(e,t,n,i);default:return se(e,t,n,i)}},Hl=(e,t,n,i)=>{if(e.op===te.AND||e.op===te.OR){let s=Nr(e.left,t,n,i),o=Nr(e.right,t,n,i);switch(e.op){case te.AND:return s&&o;case te.OR:return s||o}}let a=se(e.left,t,n,i),r=se(e.right,t,n,i);switch(e.op){case te.EQ:return a==r;case te.NEQ:return a!=r;case te.GT:return a>r;case te.LT:return a<r;case te.GTE:return a>=r;case te.LTE:return a<=r;case te.IN:return Array.isArray(r)?r.includes(a):!1;case te.ADD:if(typeof a!="number"||typeof r!="number")throw new De(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case te.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new De(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Kl=(e,t,n,i)=>{let a=e.op===kt.NOT?Nr(e.operand,t,n,i):se(e.operand,t,n,i);if(e.op===kt.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},$y=(e,t,n,i)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===S.VARIABLE)if(Pe(a.path,n,i)){let s=e.bodies[0];if(s.type===S.OBJECT&&s.fast===!0&&!s.whenCondition&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?se(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===S.LITERAL)o[c]=u.value;else if(u.type===S.VARIABLE)o[c]=Pe(u.path,n,i);else if(u.type===S.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===S.VARIABLE){let d=Pe(m.path,n,i);p.push(d!=null?String(d):"")}else{let d=se(m,t,n,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=se(u,t,n,i)}return o}}else{let s=e.bodies[1];if(s.type===S.OBJECT&&s.fast===!0&&!s.whenCondition&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?se(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===S.LITERAL)o[c]=u.value;else if(u.type===S.VARIABLE)o[c]=Pe(u.path,n,i);else if(u.type===S.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===S.VARIABLE){let d=Pe(m.path,n,i);p.push(d!=null?String(d):"")}else{let d=se(m,t,n,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=se(u,t,n,i)}return o}}}return null},Cy=(e,t,n,i)=>{let a=$y(e,t,n,i);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let s=e.conditions[r];if(s===null||Nr(s,t,n,i))return se(e.bodies[r],t,n,i)}return Jl},_y=(e,t)=>{let n=e.body,i=e.itemVar;if(n.type===S.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===S.VARIABLE){let a=n.conditions[0].path,r=n.bodies[0];if(a.startsWith(i+".")){let s=a.substring(i.length+1);if(r.type===S.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c[s]){let u={};for(let p of r.properties){let m=p.key,d=p.value;if(d.type===S.LITERAL)u[m]=d.value;else if(d.type===S.VARIABLE){let f=d.path;if(f===i)u[m]=c;else if(f.startsWith(i+".")){let h=f.substring(i.length+1);u[m]=c[h]}else return null}else if(d.type===S.INTERPOLATION){let f=[],h=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===S.VARIABLE){let y=g.path;if(y===i)f.push(c!=null?String(c):"");else if(y.startsWith(i+".")){let b=y.substring(i.length+1),w=c[b];f.push(w!=null?String(w):"")}else{h=!1;break}}else{h=!1;break}if(!h)return null;u[m]=f.join("")}else return null}o.push(u)}}return o}}}return null},Ny=(e,t)=>{let n=e.body,i=e.itemVar,a=_y(e,t);if(a!==null)return a;if(n.type===S.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let o of n.properties)if(o.parsedKey)return null;let r=[],s=!0;for(let o of n.properties){let l=o.key,c=o.value;if(c.type===S.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===S.VARIABLE){let u=c.path;if(u===i)r.push({key:l,type:"item"});else if(u.startsWith(i+".")){let p=u.substring(i.length+1);if(!p.includes(".")&&!p.includes("["))r.push({key:l,type:"prop",prop:p});else{s=!1;break}}else{s=!1;break}}else if(c.type===S.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===S.VARIABLE){let p=u.path;if(p===i)r.push({key:l,type:"item_string"});else if(p.startsWith(i+".")){let m=p.substring(i.length+1);if(!m.includes(".")&&!m.includes("["))r.push({key:l,type:"prop_string",prop:m});else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}if(s){let o=new Array(t.length);if(r.length===3&&r[0].type==="prop"&&r[0].key==="id"&&r[1].type==="prop_string"&&r[1].key==="title"&&r[2].type==="prop"&&r[2].key==="completed")for(let l=0;l<t.length;l++){let c=t[l];o[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<t.length;l++){let c=t[l],u={};for(let p of r)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let m=c[p.prop];u[p.key]=m!=null?String(m):""}o[l]=u}return o}}return null},jy=(e,t,n,i,a)=>{let r=[],s=e.body;if(s.type===S.OBJECT&&s.fast!==!1){let o=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},m={...i,[o]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=i.__paths__||{});let d=e.iterable.path||"";if(i&&i.__paths__&&d){let f=d.split("."),h=f[0];h in i.__paths__&&(d=i.__paths__[h],f.length>1&&(d+="."+f.slice(1).join(".")))}m.__paths__={...m.__paths__,[o]:`${d}[${c}]`,...l&&{[l]:c}};for(let f of s.properties){let h=f.parsedKey?se(f.parsedKey,t,n,m):f.key,g=f.value;if(g.type===S.LITERAL)p[h]=g.value;else if(g.type===S.VARIABLE){let y=g.path;if(y===o)p[h]=u;else if(y===l)p[h]=c;else if(y.startsWith(o+".")){let b=y.substring(o.length+1);!b.includes(".")&&!b.includes("[")?p[h]=u[b]:p[h]=Pe(y,n,{...i,[o]:u,...l&&{[l]:c}})}else p[h]=Pe(y,n,{...i,[o]:u,...l&&{[l]:c}})}else if(g.type===S.INTERPOLATION){let y=[];for(let b of g.parts)if(typeof b=="string")y.push(b);else if(b.type===S.VARIABLE){let w=b.path,A;if(w===o)A=u;else if(w===l)A=c;else if(w.startsWith(o+".")){let k=w.substring(o.length+1);!k.includes(".")&&!k.includes("[")?A=u[k]:A=Pe(w,n,{...i,[o]:u,...l&&{[l]:c}})}else A=Pe(w,n,{...i,[o]:u,...l&&{[l]:c}});y.push(A!=null?String(A):"")}else{let w={...i,[o]:u,...l&&{[l]:c}},A=se(b,t,n,w);y.push(A!=null?String(A):"")}p[h]=y.join("")}else{let y={...i,[o]:u,...l&&{[l]:c}};p[h]=se(g,t,n,y)}}r.push(p)}return r}return null},Ty=(e,t,n)=>{let i=e.body;if(i.type===S.OBJECT&&i.properties.length===1&&i.properties[0].key==="$if item.visible"){let r=i.properties[0].value;if(r.type===S.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===S.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===S.OBJECT&&s.properties.length===2){let o=s.properties[0],l=s.properties[1];if(o.key==="id"&&o.value.type===S.VARIABLE&&o.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===S.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let m={id:p.id};p.highlighted?(m.highlight=!0,m.message=`This item is highlighted: ${p.name}`):(m.highlight=!1,m.message=p.name),c.push(m)}}return c}}}}return null},Dy=(e,t,n,i)=>{let a=se(e.iterable,t,n,i);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===S.FUNCTION){u=!0;let m=e.iterable.args.map(d=>d.type===S.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===S.VARIABLE?d.path:d.type===S.FUNCTION?`${d.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${m})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw Yl(p,a,u)}if(!e.indexVar){let c=Ty(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=Ny(e,a);if(c!==null)return c}let r=jy(e,t,n,i,a);if(r!==null)return r;let s=[],o=e.iterable.path||"";if(i&&i.__paths__&&o){let c=o.split("."),u=c[0];u in i.__paths__&&(o=i.__paths__[u],c.length>1&&(o+="."+c.slice(1).join(".")))}let l=!1;e.body.type===S.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===S.OBJECT&&c.properties.some(u=>u.key.startsWith("$if ")||u.key.startsWith("$when "))));for(let c=0;c<a.length;c++){let u=e.indexVar?{...i,[e.itemVar]:a[c],[e.indexVar]:c}:{...i,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=i.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${o}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=se(e.body,t,n,u);if(Array.isArray(p)&&p.length===1&&!l){let m=p[0];s.push(m===void 0?{}:m)}else s.push(p===void 0?{}:p)}return s},Wl=(e,t,n)=>e.type!==S.OBJECT||e.whenCondition||e.properties.length>t?!1:e.properties.every(({value:i})=>{switch(i.type){case S.LITERAL:case S.VARIABLE:return!0;case S.INTERPOLATION:return i.parts.every(a=>typeof a=="string"||a.type===S.VARIABLE);case S.OBJECT:return n&&Wl(i,5,!1);default:return!1}}),Ly=(e,t,n,i)=>{if(e.whenCondition||e.properties.length!==1||!Wl(e.properties[0].value,10,!0))return null;let a=e.properties[0],r=a.parsedKey?se(a.parsedKey,t,n,i):a.key,s=a.value,o={},l={};for(let c of s.properties){let u=c.parsedKey?se(c.parsedKey,t,n,i):c.key,p=c.value;if(p.type===S.LITERAL)l[u]=p.value;else if(p.type===S.VARIABLE)l[u]=Pe(p.path,n,i);else if(p.type===S.INTERPOLATION){let m=[];for(let d of p.parts)if(typeof d=="string")m.push(d);else if(d.type===S.VARIABLE){let f=Pe(d.path,n,i);m.push(f!=null?String(f):"")}l[u]=m.join("")}else if(p.type===S.OBJECT){let m={};for(let d of p.properties){let f=d.parsedKey?se(d.parsedKey,t,n,i):d.key,h=d.value;if(h.type===S.LITERAL)m[f]=h.value;else if(h.type===S.VARIABLE)m[f]=Pe(h.path,n,i);else if(h.type===S.INTERPOLATION){let g=[];for(let y of h.parts)if(typeof y=="string")g.push(y);else if(y.type===S.VARIABLE){let b=Pe(y.path,n,i);g.push(b!=null?String(b):"")}m[f]=g.join("")}}l[u]=m}}return o[r]=l,o},My=(e,t,n,i)=>{let a=t.functions||t;if(e.whenCondition&&!Nr(e.whenCondition,a,n,i))return;let r=Ly(e,t,n,i);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?se(u.parsedKey,t,n,i):u.key,m=u.value;if(m.type===S.LITERAL)c[p]=m.value;else if(m.type===S.VARIABLE)c[p]=Pe(m.path,n,i);else if(m.type===S.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===S.VARIABLE){let h=Pe(f.path,n,i);d.push(h!=null?String(h):"")}else{let h=se(f,t,n,i);d.push(h!=null?String(h):"")}c[p]=d.join("")}else c[p]=se(m,t,n,i)}return c}let s={},o=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=se(c.value,t,n,i);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(s,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return se(c.value,t,n,i)}else{let u=c.parsedKey?se(c.parsedKey,t,n,i):c.key,p=c.value;if(p&&p.type===S.OBJECT&&p.properties){let m=p.properties.find(d=>d.key.startsWith("$for "));if(m){let d=se(m.value,t,n,i);d!==void 0&&(s[u]=d)}else{let d=se(c.value,t,n,i);d!==void 0&&(s[u]=d)}}else{let m=se(c.value,t,n,i);(m!==void 0||p?.type===S.VARIABLE||p?.type===S.FUNCTION)&&(s[u]=m)}}return s},Jl={},Vy=(e,t,n,i)=>{let a=[];for(let r of e.items)if(r.type===S.LOOP){let s=se(r,t,n,i);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=se(r,t,n,i);s!==Jl&&s!==void 0&&a.push(s)}return a},qy=(e,t,n,i)=>{let{name:a,data:r,whenCondition:s}=e,o=t.partials||{},l=t.functions||t;if(s&&!Nr(s,l,n,i))return;if(!o[a])throw new De(`Partial '${a}' is not defined`);let c=i._partialStack||[];if(c.includes(a))throw new De(`Circular partial reference detected: ${a}`);let u=o[a],p=n,m={...i,_partialStack:[...c,a]};if(i){p={...n};for(let d of Object.keys(i))d.startsWith("_")||(p[d]=i[d])}if(r){let d=se(r,t,n,i);p={...p,...d}}return se(u,t,p,m)},Fy=(e,t,n,i)=>{let{path:a}=e,r=a.split("."),s=r[0],o=r.slice(1);if(!i||!(s in i))throw new De(`Path reference '#{${a}}' refers to '${s}' which is not a loop variable in the current scope`);if(i.__paths__||(i.__paths__={}),!(s in i.__paths__))throw new De(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=i.__paths__[s];if(typeof l=="number"){if(o.length>0)throw new De(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return o.length>0&&(l+="."+o.join(".")),l};var ao=Sy;var By=/\$\{([^}]*)\}/g,Uy=/#\{([^}]*)\}/g,Zl=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,i,a]=n,r=Yy(a,t);return{isFunction:!0,type:S.FUNCTION,name:i,args:r}},Yy=(e,t={})=>e.trim()?zy(e).map(i=>Xy(i.trim(),t)):[],zy=e=>{let t=[],n="",i=0,a=!1,r="";for(let s=0;s<e.length;s++){let o=e[s],l=s>0?e[s-1]:"";!a&&(o==='"'||o==="'")?(a=!0,r=o,n+=o):a&&o===r&&l!=="\\"?(a=!1,r="",n+=o):!a&&o==="("?(i++,n+=o):!a&&o===")"?(i--,n+=o):!a&&o===","&&i===0?(t.push(n),n=""):n+=o}return n&&t.push(n),t},Xy=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:S.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:S.LITERAL,value:parseFloat(e)};if(e==="true")return{type:S.LITERAL,value:!0};if(e==="false")return{type:S.LITERAL,value:!1};if(e==="null")return{type:S.LITERAL,value:null};let n=Zl(e,t);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let i=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,s=null;for(let{op:o,type:l}of a){let c=0;for(;c<i.length;){let u=et(i.substring(c),o);if(u===-1)break;let p=c+u;p>r&&(r=p,s={op:o,type:l}),c=p+o.length}}if(r!==-1)try{return Oe(i,t)}catch{return{type:S.VARIABLE,path:i}}return{type:S.VARIABLE,path:i}},ec=/^\w+\(.*\)$/,Gy=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Hy=e=>{if(!(!e||e.trim()===""||ec.test(e))&&Gy.test(e))throw e.includes("?")&&e.includes(":")?new V(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new V(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new V(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Ql=e=>{let t=e.trim();if(ec.test(t))throw new V(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new V(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new V(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new V(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new V(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:S.PATH_REFERENCE,path:t}},Ht=(e,t={})=>{let n=e.trim();Hy(n);let i=Zl(n,t);if(i.isFunction)return{type:i.type,name:i.name,args:i.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let a=0;for(let r of n)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:S.VARIABLE,path:n}},lo=(e,t={})=>{let n=e,i=[];(e.includes("\\${")||e.includes("\\#{"))&&(n=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),n=n.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),n=n.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${i.length}__`;return i.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${i.length}__`;return i.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(By)],r=[...n.matchAll(Uy)],s=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(s.length===0){let c=n;for(let u=0;u<i.length;u++)c=c.replace(`__ESCAPED_${u}__`,i[u]);return{type:S.LITERAL,value:c}}if(s.length===1&&s[0].match[0]===n&&i.length===0){let{match:c,type:u}=s[0];try{return u==="variable"?Ht(c[1],t):Ql(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:S.LITERAL,value:n};throw p}}let o=[],l=0;for(let{match:c,type:u}of s){let[p,m]=c,d=c.index;if(d>l){let f=n.substring(l,d);for(let h=0;h<i.length;h++)f=f.replace(`__ESCAPED_${h}__`,i[h]);f&&o.push(f)}try{let f;u==="variable"?f=Ht(m.trim(),t):f=Ql(m.trim()),o.push(f)}catch(f){if(f.message==="Invalid array index syntax")o.push(p);else throw f}l=d+p.length}if(l<n.length){let c=n.substring(l);for(let u=0;u<i.length;u++)c=c.replace(`__ESCAPED_${u}__`,i[u]);c&&o.push(c)}return{type:S.INTERPOLATION,parts:o}};var po=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),nc=e=>Object.keys(e),_e=e=>e.join("."),jr=(e,t,n)=>{let i=nc(e).filter(a=>!t.has(a));if(i.length>0)throw new V(`Unexpected key '${i[0]}' in condition JSON at '${_e(n)}'`)},Tr=(e,t)=>typeof e=="string"?lo(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?Wy(e,t):Jy(e,t):{type:S.LITERAL,value:e},Ky=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new V("$each value must be a non-empty string");let i=t.trim();if(i==="")throw new V("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new V("Empty $each body not allowed");if(n.$partial!==void 0)throw new V("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${i}`]:n}},Wy=(e,t)=>{let n=[],i=!1;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(r.$each!==void 0)try{let l=Ky(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=tc(c[0],l[c[0]],t,!0);n.push(u),i=!0;continue}}catch(l){throw l instanceof V?l:new V(l.message)}let o=Object.keys(r);if(o.length===1&&/^\$for(?::\w+)?\s/.test(o[0])){let l=tc(o[0],r[o[0]],t);n.push(l),i=!0;continue}}let s=Tr(r,t);n.push(s),(s.type===S.FUNCTION||s.type===S.CONDITIONAL||s.type===S.LOOP||s.type===S.PARTIAL||s.type===S.OBJECT&&!s.fast||s.type===S.ARRAY&&!s.fast)&&(i=!0)}return{type:S.ARRAY,items:n,fast:!i}},Jy=(e,t)=>{let n=[],i=!1,a=null,r=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new V("$partial value must be a string");if(e.$partial.trim()==="")throw new V("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let b of l)if(y===b||y.startsWith(b+" ")||y.startsWith(b+"#")){c.push(b);break}if(c.length>0)throw new V(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...m}=e,d={},f=!1;for(let[y,b]of Object.entries(m)){let w=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(w=y.slice(1)),d[w]=b,f=!0}let h=null;if(f&&(h=Tr(d,t),h.type===S.OBJECT)){let y=!1;for(let b of h.properties)if(b.value.type===S.VARIABLE||b.value.type===S.INTERPOLATION||b.value.type===S.FUNCTION||b.value.type===S.CONDITIONAL||b.value.type===S.OBJECT&&!b.value.fast||b.value.type===S.ARRAY&&!b.value.fast){y=!0;break}y&&(h.fast=!1)}let g={type:S.PARTIAL,name:u,data:h};return p!==void 0&&(g.whenCondition=rc(p,t)),g}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new V("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new V("Missing condition expression after '$when'");a=rc(c,t),i=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new V("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;s<r.length;){let[l,c]=r[s];if(l==="$when"){s++;continue}if(l==="$each")throw new V("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=Qy(r,s,t);n.push({key:l,value:u.node}),i=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new V(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new V(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new V("Missing condition expression after '$if'");{let u=Tr(c,t);(u.type===S.FUNCTION||u.type===S.CONDITIONAL||u.type===S.PARTIAL||u.type===S.OBJECT&&!u.fast||u.type===S.ARRAY&&!u.fast)&&(i=!0);let p=lo(l,t),m={key:l,value:u};(p.type!==S.LITERAL||p.value!==l)&&(m.parsedKey=p),n.push(m),s++}}}let o={type:S.OBJECT,properties:n,fast:!i};return a&&(o.whenCondition=a),o},Qy=(e,t,n={})=>{let i=[],a=[],r=t,[s,o]=e[r],l=null,c;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new V(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());oo(c);let u=Oe(c,n);for(i.push(u),a.push(Tr(o,n)),r++;r<e.length;){let[p,m]=e[r],d=!1,f;if(l?p.startsWith(`$elif#${l} `)?(f=p.substring(`$elif#${l} `.length),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(d=!0,f=null):p.startsWith("$elif ")?(f=p.substring(6),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p==="$else"||p==="$else:")&&(d=!0,f=null),d){if(f===null)i.push(null);else{oo(f);let h=Oe(f,n);i.push(h)}if(a.push(Tr(m,n)),r++,f===null)break}else break}return{node:{type:S.CONDITIONAL,conditions:i,bodies:a,id:l},nextIndex:r}},co={eq:te.EQ,neq:te.NEQ,gt:te.GT,gte:te.GTE,lt:te.LT,lte:te.LTE,in:te.IN,add:te.ADD,sub:te.SUBTRACT},uo={all:te.AND,any:te.OR},Zy=new Set(["var","literal","call","not",...Object.keys(co),...Object.keys(uo)]),eh=(e,t,n)=>{if(!Array.isArray(e))throw new V(`Condition JSON operator '${t}' at '${_e(n)}' requires an array`);if(e.length!==2)throw new V(`Condition JSON operator '${t}' at '${_e(n)}' requires exactly 2 operands`);return e},rh=(e,t,n,i,a)=>{if(!Array.isArray(e))throw new V(`Condition JSON operator '${t}' at '${_e(a)}' requires an array`);if(e.length===0)throw new V(`Condition JSON operator '${t}' at '${_e(a)}' requires at least 1 condition`);return e.map((s,o)=>Me(s,i,[...a,o])).reduce((s,o)=>({type:S.BINARY,op:n,left:s,right:o}))},th=(e,t,n)=>{let i,a;if(typeof e.call=="string")i=e.call,a=e.args??[],jr(e,new Set(["call","args"]),n);else if(po(e.call))i=e.call.name,a=e.call.args??[],jr(e,new Set(["call"]),n),jr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new V(`Condition JSON call at '${_e(n)}' requires a function name`);if(typeof i!="string"||i.trim()==="")throw new V(`Condition JSON call at '${_e(n)}' requires a non-empty function name`);if(!/^\w+$/.test(i))throw new V(`Invalid condition JSON function name '${i}' at '${_e(n)}'`);if(!Array.isArray(a))throw new V(`Condition JSON call '${i}' at '${_e(n)}' requires args to be an array`);return{type:S.FUNCTION,name:i,args:a.map((r,s)=>Me(r,t,[...n,"args",s]))}},Me=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:S.LITERAL,value:e};if(Array.isArray(e))throw new V(`Condition JSON array at '${_e(n)}' must be wrapped in an operator or { literal: [...] }`);if(!po(e))throw new V(`Invalid condition JSON value at '${_e(n)}'`);let i=nc(e);if(i.length===0)throw new V(`Condition JSON object at '${_e(n)}' must contain an operator`);let a=i.filter(s=>Zy.has(s));if(a.length===0)throw new V(`Unknown condition JSON operator '${i[0]}' at '${_e(n)}'`);if(a.length>1)throw new V(`Condition JSON at '${_e(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(jr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new V(`Condition JSON var at '${_e(n)}' requires a non-empty path`);return{type:S.VARIABLE,path:e.var}}if(r==="literal")return jr(e,new Set(["literal"]),n),{type:S.LITERAL,value:e.literal};if(r==="call")return th(e,t,n);if(r==="not")return jr(e,new Set(["not"]),n),{type:S.UNARY,op:kt.NOT,operand:Me(e.not,t,[...n,"not"])};if(r in uo)return jr(e,new Set([r]),n),rh(e[r],r,uo[r],t,[...n,r]);if(r in co){jr(e,new Set([r]),n);let s=eh(e[r],r,[...n,r]);return{type:S.BINARY,op:co[r],left:Me(s[0],t,[...n,r,0]),right:Me(s[1],t,[...n,r,1])}}throw new V(`Unknown condition JSON operator '${r}' at '${_e(n)}'`)},rc=(e,t={})=>{if(e==null)throw new V("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new V("Empty condition expression after '$when'");return Oe(e,t)}return po(e)||Array.isArray(e)?Me(e,t):{type:S.LITERAL,value:e}},Oe=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let m=0;m<c.length;m++)if(c[m]==="("?u++:c[m]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Oe(c,t)}let n=et(e,"||");if(n!==-1)return{type:S.BINARY,op:te.OR,left:Oe(e.substring(0,n).trim(),t),right:Oe(e.substring(n+2).trim(),t)};let i=et(e,"&&");if(i!==-1)return{type:S.BINARY,op:te.AND,left:Oe(e.substring(0,i).trim(),t),right:Oe(e.substring(i+2).trim(),t)};let a=[{op:">=",type:te.GTE},{op:"<=",type:te.LTE},{op:"==",type:te.EQ},{op:"!=",type:te.NEQ},{op:">",type:te.GT},{op:"<",type:te.LT},{op:" in ",type:te.IN}];for(let{op:c,type:u}of a){let p=et(e,c);if(p!==-1)return{type:S.BINARY,op:u,left:Oe(e.substring(0,p).trim(),t),right:Oe(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,o=[{op:" + ",type:te.ADD},{op:" - ",type:te.SUBTRACT}];for(let{op:c,type:u}of o){let p=0;for(;p<e.length;){let m=et(e.substring(p),c);if(m===-1)break;let d=p+m;d>r&&(r=d,s={op:c,type:u}),p=d+c.length}}if(r!==-1&&s)return{type:S.BINARY,op:s.type,left:Oe(e.substring(0,r).trim(),t),right:Oe(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(et(e,c)!==-1)throw new V(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:S.UNARY,op:kt.NOT,operand:Oe(e.substring(1).trim(),t)}:sc(e,t)},et=(e,t)=>{let n=0,i=0;for(;i<=e.length-t.length;){if(e[i]==="(")n++;else if(e[i]===")")n--;else if(n===0&&e.substring(i,i+t.length)===t)return i;i++}return-1},nh=e=>{if(e=e.trim(),e==="true")return{type:S.LITERAL,value:!0};if(e==="false")return{type:S.LITERAL,value:!1};if(e==="null")return{type:S.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:S.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:S.LITERAL,value:""};if(e==="{}")return{type:S.LITERAL,value:{}};if(e==="[]")return{type:S.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:S.LITERAL,value:t}:{type:S.VARIABLE,path:e}},sc=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return Ht(n,t);let a=nh(n);if(a.type===S.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:S.VARIABLE,path:n};try{return Ht(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},sh=(e,t=!1)=>{let n=t?"$each":"$for";try{Ul(e)}catch(i){if(i instanceof V&&t){let a=i.message.replace(/\$for/g,"$each");throw new V(a.replace("Parse Error: ",""))}throw i}},tc=(e,t,n,i=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let g=i?"$each":"$for";throw new V(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=r[1],o=r[2].trim();sh(o,i);let l=o.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=i?"$each":"$for";throw new V(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${o}')`)}let c=l[1].trim(),u=l[2].trim(),p,m=null;if(c.includes(",")){let g=c.split(",").map(y=>y.trim());if(g.length!==2)throw new V(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=g[0],m=g[1]}else p=c;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new V(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new V(`Reserved variable name: ${m}`);let f=sc(u,n),h=Tr(t,n);return{type:S.LOOP,itemVar:p,indexVar:m,iterable:f,body:h,flatten:s!=="nested"}};var ih=(e,t={})=>{let{functions:n={}}=t;return Tr(e,n)},Wn=ih;var Kt={};yy(Kt,{now:()=>oh});var oh=()=>Date.now();var ah=(e,t,n={})=>{let{functions:i={},partials:a={}}=n,r={...Kt,...i},s=Wn(e,{functions:r}),o={};for(let[l,c]of Object.entries(a))o[l]=Wn(c,{functions:r});return ao(s,t,{functions:r,partials:o})},rt=ah;var lh=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",ch=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,uh=(e,t)=>{if(lh(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new V("Empty condition expression");return Oe(e,t)}return Me(e,t)},ph=(e,t={},n={})=>{let i=ch(n),a={...Kt,...i},r=uh(e,a);return!!Nr(r,{functions:a,partials:{}},t,{})},fo=ph;var ko=Symbol("runStoreTransaction"),L=(e,t)=>e!=null&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,go="__routeEngineConditionComparison",Jn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",Dr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Jn(e,t)&&e>t,gte:(e,t)=>Jn(e,t)&&e>=t,lt:(e,t)=>Jn(e,t)&&e<t,lte:(e,t)=>Jn(e,t)&&e<=t}),fc=Object.freeze(Object.fromEntries(Object.keys(Dr).map(e=>[e,`${go}${e}`]))),fh=Object.freeze(Object.fromEntries(Object.entries(fc).map(([e,t])=>[t,Dr[e]]))),ic=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),dh=e=>{if(typeof e?.call=="string")return e.call;if(e?.call!==null&&typeof e?.call=="object"&&!Array.isArray(e.call))return e.call.name},Qn=e=>{if(Array.isArray(e))return e.map(Qn);if(e===null||typeof e!="object"||ic(e,"literal")||ic(e,"var"))return e;if(dh(e)?.startsWith(go))throw new Error(`Condition function names beginning with "${go}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[i,a]]=n,r=fc[i];if(r)return{call:r,args:a.map(Qn)}}return Object.fromEntries(n.map(([i,a])=>[i,Qn(a)]))},Jt=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),fo(Qn(e),t,{functions:fh})},mh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dc=(e,t,n={})=>{let i={},a={},{transformSelectorFirstArgument:r=h=>h,transformActionFirstArgument:s=h=>h,createTransactionalMetadata:o,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof o=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(o())}:{}},m=0,d=(h,g)=>!u||!c?h:Kn(h,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});for(let[h,g]of Object.entries(t))h!=="createInitialState"&&(h.startsWith("select")?i[h]=(...y)=>g(r(p.state,p.transactionalMetadata),...y):a[h]=(...y)=>{let b,w=p,A=Kn(p,k=>{let P=g(s(k.state,k.transactionalMetadata),...y);b=P!==void 0&&!Ie(P)?P:void 0,u&&l&&l({actionName:h,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:w.state,previousTransactionalMetadata:w.transactionalMetadata})});return m===0&&(A=d(A,w)),p=A,b});let f=h=>{if(typeof h!="function")throw new Error("Store transaction requires a callback");let g=p,y=m===0;m+=1;let b;try{b=h()}catch(w){throw m-=1,p=g,w}if(m-=1,y)try{p=d(p,g)}catch(w){throw p=g,w}return b};return{...i,...a,[ko]:f}},ts=(e,t)=>n=>{let i=e(),a=Array.isArray(n)?n:[n];return Kn(i,r=>{a.forEach(s=>{t.forEach(o=>{o(r,s)})})})};var yh=(e,t)=>{if(e.default!==void 0)return e.default;let n=["number","boolean","string","object"];if(!n.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${n.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},re=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),bo=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},xe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),hh=new Set(["pageSize","groups"]),gh=new Set(["id","variants"]),bh=new Set(["id","imageId"]),wh=new Set(["pageSize","tracks"]),Ih=new Set(["id","soundId","title","artist","album","description","coverImageId"]),vh=new Set(["pageSize","replays"]),kh=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),tt=(e,t,n)=>{Object.keys(e).forEach(i=>{if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)})},At=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Qt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!xe(t))throw new Error("resources.imageGallery must be an object");if(tt(t,hh,"resources.imageGallery"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.groups))throw new Error("resources.imageGallery.groups must be an array");let n=new Set;for(let[i,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${i}]`;if(!xe(a))throw new Error(`${r} must be an object`);if(tt(a,gh,r),At(a.id,`${r}.id`),n.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(n.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let s=new Set;for(let[o,l]of a.variants.entries()){let c=`${r}.variants[${o}]`;if(!xe(l))throw new Error(`${c} must be an object`);if(tt(l,bh,c),At(l.id,`${c}.id`),At(l.imageId,`${c}.imageId`),s.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(s.add(l.id),!re(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},Zt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!xe(t))throw new Error("resources.musicRoom must be an object");if(tt(t,wh,"resources.musicRoom"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.tracks))throw new Error("resources.musicRoom.tracks must be an array");let n=new Set;for(let[i,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${i}]`;if(!xe(a))throw new Error(`${r} must be an object`);tt(a,Ih,r);for(let l of["id","soundId","title"])At(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&At(a[l],`${r}.${l}`);if(n.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);n.add(a.id);let s=L(e?.resources?.sounds,a.soundId);if(!re(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!xe(s))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(s.playbackRate!==void 0&&(typeof s.playbackRate!="number"||!Number.isFinite(s.playbackRate)||s.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let o=s.startAt??0;if(typeof o!="number"||!Number.isFinite(o)||o<0)throw new Error(`Music room sound "${a.soundId}" startAt must be a finite non-negative number`);if(s.endAt!==void 0&&s.endAt!==null&&(typeof s.endAt!="number"||!Number.isFinite(s.endAt)||s.endAt<=o))throw new Error(`Music room sound "${a.soundId}" endAt must be a finite number greater than startAt`);if(a.coverImageId!==void 0&&!re(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Ah=(e,t,n)=>{let i=Array.isArray(n)?"array":typeof n;switch(t.type){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${i}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${i}`);return;case"string":if(typeof n!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${i}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${i}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},en=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!xe(t))throw new Error("resources.sceneReplay must be an object");if(tt(t,vh,"resources.sceneReplay"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.replays))throw new Error("resources.sceneReplay.replays must be an array");let n=e?.story?.scenes??{},i=new Set;for(let[a,r]of t.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!xe(r))throw new Error(`${s} must be an object`);tt(r,kh,s);for(let u of["sceneId","title","thumbnailImageId"])At(r[u],`${s}.${u}`);if(i.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(i.add(r.sceneId),!re(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let o=L(n,r.sceneId);if(!o)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=o.initialSectionId,c=L(o.sections,l);if(!c)throw new Error(`Scene replay scene "${r.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${r.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(r.initialVariables!==void 0){if(!xe(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let m=L(e?.resources?.variables,u);if(!m)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(Ne(m))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);Ah(u,m,p)}}}},mc=e=>{let t=Ie(e)?Ge(e):e;return structuredClone(t)},Ph=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!re(t,"nameVariableId"))return;let i=t.nameVariableId,a=n?.[i];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${i}" must resolve to a string variable`);return a},ns=({characterId:e,character:t,characterName:n,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0;if(t?.name!==void 0)return t.name;if(n!==void 0)return n;let s=Ph({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},Ne=e=>re(e,"computed"),Ao=(e,t)=>{switch(e?.type){case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);default:return!1}},rn=(e={},t={},{allowedScopes:n,preserveUnknown:i=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?i:!Ne(s)&&(!n||n.includes(s.scope))&&Ao(s,r)})),Ke=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),xh=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ke(t,n)}let a="";for(let r=1;r<e.length-1;r+=1){let s=e[r];if(s!=="\\"){if(s.charCodeAt(0)<32)throw Ke(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Ke(t,n);let o=e[r];if(o==="u"){let c=e.slice(r+1,r+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Ke(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
-
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!re(l,o))throw Ke(t,n);a+=l[o]}return a},yc=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ke(e,t);let n=[],i=0,a=()=>{let s=i;for(;i<e.length&&e[i]!=="."&&e[i]!=="["&&e[i]!=="]";)i+=1;let o=e.slice(s,i);if(o.length===0||o.trim()!==o||/\s/.test(o))throw Ke(e,t);n.push(o)},r=()=>{for(i+=1;i<e.length&&/\s/.test(e[i]);)i+=1;let s=e[i];if(/\d/.test(s??"")){let u=i;for(;i<e.length&&/\d/.test(e[i]);)i+=1;let p=e.slice(u,i);for(;i<e.length&&/\s/.test(e[i]);)i+=1;if(e[i]!=="]"||p.length>1&&p.startsWith("0"))throw Ke(e,t);i+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Ke(e,t);let o=s,l=i;i+=1;let c=!1;for(;i<e.length;){let u=e[i];if(c)c=!1;else if(u==="\\")c=!0;else if(u===o){let p=e.slice(l,i+1);for(i+=1;i<e.length&&/\s/.test(e[i]);)i+=1;if(e[i]!=="]")throw Ke(e,t);i+=1,n.push(xh(p,e,t));return}i+=1}if(c||i>=e.length)throw Ke(e,t)};for(a();i<e.length;){if(e[i]==="."){i+=1,a();continue}if(e[i]==="["){r();continue}throw Ke(e,t)}return n},mo=(e,t)=>{let n=e;for(let i of t){if(n==null||!re(n,i))return;n=n[i]}return n},hc=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=yc(e),[i,a,...r]=n;if(i==="variables"){if(!a)return t.variables;let s=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return mo(s,r)}return i==="runtime"?mo(t.runtime,n.slice(1)):mo(t,n)},gc=(e,t,n)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(n!==void 0&&t.length!==n)throw new Error(`Computed expression operator "${e}" requires ${n} operand(s)`)},wo=(e,t)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(t.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},Eh=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},rr=(e,t,n,i)=>(gc(e,t,i),t.map(a=>rs(a,n))),He=(e,t,n,i)=>{let a=rr(e,t,n,i);return a.forEach(r=>Eh(e,r)),a},Sh=(e,t,n)=>{switch(e){case"var":return hc(t,n);case"add":{let[i,a]=He(e,t,n,2);return i+a}case"sub":{let[i,a]=He(e,t,n,2);return i-a}case"mul":{let[i,a]=He(e,t,n,2);return i*a}case"div":{let[i,a]=He(e,t,n,2);return a===0?0:i/a}case"mod":{let[i,a]=He(e,t,n,2);return a===0?0:i%a}case"neg":{let[i]=He(e,t,n,1);return-i}case"round":{let[i]=He(e,t,n,1);return Math.round(i)}case"floor":{let[i]=He(e,t,n,1);return Math.floor(i)}case"ceil":{let[i]=He(e,t,n,1);return Math.ceil(i)}case"min":{let[i,a]=He(e,t,n,2);return Math.min(i,a)}case"max":{let[i,a]=He(e,t,n,2);return Math.max(i,a)}case"clamp":{let[i,a,r]=He(e,t,n,3);return Math.min(r,Math.max(a,i))}case"eq":{let[i,a]=rr(e,t,n,2);return Dr.eq(i,a)}case"neq":{let[i,a]=rr(e,t,n,2);return Dr.neq(i,a)}case"gt":{let[i,a]=rr(e,t,n,2);return Dr.gt(i,a)}case"gte":{let[i,a]=rr(e,t,n,2);return Dr.gte(i,a)}case"lt":{let[i,a]=rr(e,t,n,2);return Dr.lt(i,a)}case"lte":{let[i,a]=rr(e,t,n,2);return Dr.lte(i,a)}case"in":{let[i,a]=rr(e,t,n,2);return Array.isArray(a)?a.includes(i):!1}case"and":case"all":return wo(e,t),t.every(i=>!!rs(i,n));case"or":case"any":return wo(e,t),t.some(i=>!!rs(i,n));case"not":{let[i]=rr(e,t,n,1);return!i}case"length":{let[i]=rr(e,t,n,1);return typeof i=="string"||Array.isArray(i)?i.length:xe(i)?Object.keys(i).length:0}case"includes":{let[i,a]=rr(e,t,n,2);return typeof i=="string"?typeof a=="string"&&i.includes(a):Array.isArray(i)?i.includes(a):!1}case"literal":return mc(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},rs=(e,t={})=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let n=Object.entries(e);if(n.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[i,a]]=n;return Sh(i,a,t)},Io=(e,t)=>{if(e===null||typeof e!="object"||re(e,"literal"))return e;if(re(e,"var"))return{literal:hc(e.var,t)};if(re(e,"call"))throw new Error("Function calls are not supported in computed-variable conditions");return Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Array.isArray(i)?i.map(a=>Io(a,t)):Io(i,t)]))},Oh=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Jt(Io(e,t))},bc=(e,t)=>{if(!xe(e))throw new Error(`${t} must be an object`);let n=re(e,"expr"),i=re(e,"value");if(n===i)throw new Error(`${t} must contain exactly one of expr or value`)},yo=(e,t,n)=>(bc(e,t),re(e,"value")?mc(e.value):rs(e.expr,n)),Rh=(e,t={},n="unknown")=>{if(!xe(e))throw new Error(`Computed variable "${n}" computed must be an object`);let i=re(e,"expr"),a=re(e,"value");if(re(e,"branches")){if(i||a)throw new Error(`Computed variable "${n}" cannot combine branches with expr or value`);if(!Array.isArray(e.branches))throw new Error(`Computed variable "${n}" branches must be an array`);if(e.branches.length===0)throw new Error(`Computed variable "${n}" branches must not be empty`);if(!xe(e.default))throw new Error(`Computed variable "${n}" requires default`);for(let s=0;s<e.branches.length;s+=1){let o=e.branches[s];if(!xe(o))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!re(o,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(Oh(o.when,t))return yo(o,`Computed variable "${n}" branch ${s}`,t)}return yo(e.default,`Computed variable "${n}" default`,t)}if(i===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return yo(e,`Computed variable "${n}"`,t)},wc=(e,t,n)=>{switch(t){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(n)?"array":typeof n}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(n)?"array":typeof n}`);return;case"string":if(typeof n!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(n)?"array":typeof n}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof n}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},$h=Object.freeze({add:2,sub:2,mul:2,div:2,mod:2,neg:1,round:1,floor:1,ceil:1,min:2,max:2,clamp:3,eq:2,neq:2,gt:2,gte:2,lt:2,lte:2,in:2,not:1,length:1,includes:2}),Ch=new Set(["and","or","all","any"]),_h=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Nh=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),jh=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Th=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Ic=new WeakMap,oc=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Zn=(e,t,n)=>{for(let i of Object.keys(e))if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)},Dh=(e,t,n,i)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${i} expected type ${t}, got ${n}`)},vc=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,o,...l]=yc(e,r);if(s!=="variables"&&s!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!o)throw new Error(`${r} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!re(n,o))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${o}"`);let c=n[o];return Ne(c)&&i.add(o),l.length===0?c?.type:void 0},kc=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return oc(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let r=Object.entries(e);if(r.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[s,o]]=r;if(s==="var"){if(typeof o!="string"||o.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return vc(o,{variableId:t,variableConfigs:n,dependencies:i,path:a})}if(s==="literal"){if(typeof o=="number"&&!Number.isFinite(o))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return oc(o)}let l=$h[s];if(l===void 0&&!Ch.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?wo(s,o):gc(s,o,l);let c=o.map((u,p)=>kc(u,{variableId:t,variableConfigs:n,dependencies:i,path:`${a}.${s}[${p}]`}));if(Nh.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),_h.has(s))return"number";if(jh.has(s))return"boolean"},Lh=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Me(e)}catch(s){throw new Error(`Computed variable "${t}" ${a} is invalid: ${s.message}`,{cause:s})}let r=(s,o)=>{if(s===null||typeof s!="object"||re(s,"literal"))return;if(re(s,"var")){vc(s.var,{variableId:t,variableConfigs:n,dependencies:i,path:o});return}if(re(s,"call"))throw new Error(`Computed variable "${t}" ${o} function calls are not supported`);if(re(s,"not")){r(s.not,`${o}.not`);return}let l=Object.keys(s).find(c=>Th.has(c));s[l].forEach((c,u)=>{r(c,`${o}.${l}[${u}]`)})};r(e,a)},ho=(e,{variableId:t,variableConfig:n,variableConfigs:i,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(bc(e,`Computed variable "${t}" ${r}`),Zn(e,s,r),re(e,"value")){wc(t,n.type,e.value);return}let o=kc(e.expr,{variableId:t,variableConfigs:i,dependencies:a,path:`${r}.expr`});Dh(t,n.type,o,`${r}.expr`)},Mh=(e,t,n)=>{let i=t.computed;if(!xe(i))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=re(i,"expr"),s=re(i,"value");if(re(i,"branches")){if(Zn(i,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||s)throw new Error(`Computed variable "${e}" cannot combine branches with expr or value`);if(!Array.isArray(i.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(i.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!xe(i.default))throw new Error(`Computed variable "${e}" requires default`);return i.branches.forEach((l,c)=>{if(!xe(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Zn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!re(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);Lh(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),ho(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),ho(i.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Zn(i,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===s)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return ho(i,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},nt=(e={})=>{if(!xe(e))throw new Error("Variable configs must be an object");if(re(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(re(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if(Ne(s)){if(!xe(s))throw new Error(`Computed variable "${r}" must be an object`);if(!re(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!re(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(re(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(tn(s.scope,r),!["number","boolean","string","object"].includes(s.type))throw new Error(`Invalid variable type: ${s.type} for computed variable ${r}`);t.set(r,Mh(r,s,e))}});let n=new Set,i=[];t.forEach((r,s)=>{if(n.has(s))return;let o=[{variableId:s,dependencies:[...t.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;o.length>0;){let c=o.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){o.pop(),l.delete(c.variableId),n.add(c.variableId),i.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,n.has(u))continue;let p=l.get(u);if(p!==void 0){let m=[...o.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,o.length),o.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(i)});return Ic.set(e,a),a},Pt=({variables:e={},runtime:t={},variableConfigs:n={},eager:i=!0}={})=>{let{evaluationOrder:a}=Ic.get(n)??nt(n),r=rn(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,g])=>Ne(g)).map(([g])=>g),o=Object.create(null),l=[],c=new Map(a.map((g,y)=>[g,y])),u=-1,p=!1,m=g=>{if(re(o,g))return o[g];let y=n[g];if(!Ne(y))return re(r,g)?r[g]:void 0;let b=l.indexOf(g);if(b>=0){let w=[...l.slice(b),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${w}`)}l.push(g);try{let w=Rh(y.computed,h,g);return wc(g,y.type,w),bo(o,g,w),w}finally{l.pop()}},d=g=>{if(re(o,g))return o[g];let y=n[g];if(!Ne(y))return re(r,g)?r[g]:void 0;let b=c.get(g);if(i&&!p&&b!==void 0&&b>u){p=!0;try{for(let w=u+1;w<=b;w+=1)m(a[w]),u=w}finally{p=!1}return o[g]}return m(g)},f=new Proxy({},{get:(g,y)=>{if(typeof y=="string")return d(y)},has:(g,y)=>typeof y=="string"&&(re(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(g,y)=>{if(!(typeof y!="string"||!re(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),h={variables:f,runtime:t,resolveVariable:d};return i?(s.forEach(g=>{d(g)}),{...r,...o}):f},Vh=({variables:e={},runtime:t={},variableConfigs:n,projectData:i}={})=>{let a=n??i?.resources?.variables??{};return nt(a),Pt({variables:e,runtime:t,variableConfigs:a,eager:!0})},ss=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([i,a])=>{if(Ne(a))return;let r=yh(a,i);a.scope==="context"?bo(t,i,r):bo(n,i,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},tn=(e,t)=>{let n=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!n.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${n.join(", ")}`)},nn=(e,t,n)=>{let i={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=i[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(i).flat().includes(t))throw new Error(`Unknown operation: ${t}`);if(!a.includes(t))throw new Error(`Operation "${t}" is not valid for variable "${n}" of type "${e}". Valid operations: ${a.join(", ")}`)},qh=2,ac=12,Ac=(e=qh)=>{if(!Number.isInteger(e)||e<0||e>ac)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${ac}.`);return e},Fh=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},es=e=>typeof e=="number"&&Number.isFinite(e),is=(e,t,n,i,a={})=>{if(e==="number"){if(t==="set"&&!es(n))throw new Error(`Operation "set" requires value to be a number for variable "${i}".`);if(t==="multiply"&&!es(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${i}".`);if(t==="divide"&&!es(n))throw new Error(`Operation "divide" requires value to be a number for variable "${i}".`);if(t==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${i}".`);Ac(a.roundTo)}}},os=(e,t,n,i={})=>{let a=(s,o,l)=>{let c=s??o;if(!es(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=s=>{let o=a(s,void 0,"value");if(o===0)throw new Error(`Operation "${t}" requires value to be a non-zero number.`);return o};switch(t){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return Fh(a(e,0,"current value")/r(n),Ac(i.roundTo));case"increment":return a(e,0,"current value")+a(n,1,"value");case"decrement":return a(e,0,"current value")-a(n,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var Po=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),i=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),r={DD:i(n.getDate()),MM:i(n.getMonth()+1),MMM:mh[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:i(n.getHours()),mm:i(n.getMinutes()),ss:i(n.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>r[s])},Bh=(e,t)=>{let n=r=>r?.ui,i=n(e),a=n(t);return JSON.stringify(i)===JSON.stringify(a)?null:i&&!a?{changeType:"delete",data:e}:a&&!i?{changeType:"add",data:t}:a&&i?{changeType:"update",data:t}:null},Wt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Uh=(e,t)=>{let n=e?.character?.sprite,i=t?.character?.sprite,a=Wt(n)?n:void 0,r=Wt(i)?i:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},lc=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let n of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[n]!==void 0&&(t[n]=e[n]);for(let n of["animationName","animationSpeed","loop"])e[n]!==void 0&&(t[n]=e[n]);return t},cc=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},uc=(e,t)=>t&&!e?{changeType:"add",data:t}:e&&!t?{changeType:"delete",data:e}:e&&t&&JSON.stringify(e)!==JSON.stringify(t)?{changeType:"update",data:t}:null,Yh=(e,t)=>{let n={},i=uc(lc(e),lc(t)),a=uc(cc(e),cc(t));return i&&(n.resource=i),a&&(n.color=a),Object.keys(n).length>0?n:null},xo=(e={},t={})=>{let n={},i=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)n[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(m=>m.applyMode==="persistent");!i.includes(l)&&(l!=="sfx"||p)&&(n[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(n[l]={changeType:"update",data:u})},r=Yh(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=Bh(e.dialogue,t.dialogue);s&&(n.dialogue=s);let o=Uh(e.dialogue,t.dialogue);return o&&(n.dialogueSprite=o),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},Eo=(e={})=>{let t=structuredClone(e);if(t.sfx){let a=Array.isArray(t.sfx.channels)?t.sfx.channels.filter(r=>r.applyMode==="persistent"):[];a.length>0?t.sfx={channels:a}:delete t.sfx}t.background&&(t.background.animations?.playback?.continuity!=="persistent"&&delete t.background.animations,!t.background.resourceId&&!t.background.colorId&&delete t.background);let n=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};n("layout"),n("choice"),n("form"),n("screen"),t.dialogue?.ui&&(delete t.dialogue.ui.animations,Object.keys(t.dialogue.ui).length===0&&delete t.dialogue.ui,Object.keys(t.dialogue).length===0&&delete t.dialogue),t.dialogue?.character?.sprite&&(delete t.dialogue.character.sprite.animations,Object.keys(t.dialogue.character.sprite).length===0&&delete t.dialogue.character.sprite,Object.keys(t.dialogue.character).length===0&&delete t.dialogue.character,Object.keys(t.dialogue).length===0&&delete t.dialogue);let i=(a,r)=>{let s=t[a]?.items;Array.isArray(s)&&(t[a].items=s.map(o=>{let l={...o};return l.animations?.playback?.continuity!=="persistent"&&delete l.animations,r(l)?l:null}).filter(Boolean),t[a].items.length===0&&delete t[a])};return i("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),i("visual",a=>a.resourceId||a.text||a.layout||a.transformId||a.transform),t},zh=(e,t)=>{if(!e||!t)return;let n=e;for(let i of t.split(".")){if(n==null||i==="__proto__"||i==="prototype"||i==="constructor"||!Object.prototype.hasOwnProperty.call(Object(n),i))return;n=n[i]}return n},pc=e=>e!==null&&typeof e=="object"?structuredClone(e):e,Xh=(e,t,n)=>{if(typeof e!="string")return e;let i=Object.prototype.hasOwnProperty.call(t??{},n)?t[n]:void 0;if(e===n){if(i==null)throw new Error(`Action template binding "${n}" requires event context "${n}".`);return pc(i)}if(!e.startsWith(`${n}.`))return e;if(i==null)throw new Error(`Action template binding "${e}" requires event context "${n}".`);let a=e.slice(n.length+1),r=zh(i,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return pc(r)},Gh={conditional:new Set(["branches"]),updateProjectData:new Set(["projectData"]),showConfirmDialog:new Set(["confirmActions","cancelActions"]),form:new Set(["submitActions","cancelActions"]),submitForm:new Set(["actions"]),cancelForm:new Set(["actions"])},Hh=(e,t)=>{let n=e[e.length-1];return n?Gh[n]?.has(t)===!0:!1},vo=(e,t,n=[])=>Array.isArray(e)?e.map(i=>vo(i,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,Hh(n,i)?a:vo(a,t,[...n,i])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Xh(e,t,"_event"):rt(e,t):e,xt=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return vo(e,t)};var Kh=11102230246251565e-32,Pc=128,xc=1e3,Ec=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),sn=(e,t,n)=>{let i=Object.keys(e).find(a=>!t.has(a));if(i!==void 0)throw new Error(`${n}.${i} is not supported`)},as=(e,t)=>{if(!Ec(e))throw new Error(`${t} must be an object`)},ls=(e,t,{min:n,max:i}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(i!==void 0&&e>i)throw new Error(`${t} must be at most ${i}`);return e},Wh=(e,t,{min:n,max:i}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(i!==void 0&&e>i)throw new Error(`${t} must be at most ${i}`);return e},So=e=>{let t=structuredClone(e),n=i=>(i&&typeof i=="object"&&!Object.isFrozen(i)&&(Object.values(i).forEach(n),Object.freeze(i)),i);return n(t)},Jh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),Sc=e=>{let t=e??Jh();if(!Ec(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let n=t.nextUint32();if(!Number.isInteger(n)||n<0||n>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return n}}},Qh=(e,t)=>{let n=4294967296-4294967296%t;for(let i=0;i<Pc;i+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${Pc} rejected samples`)},Zh=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},eg=(e,t)=>{if(sn(e,new Set(["type","min","max"]),"random.distribution"),!Object.prototype.hasOwnProperty.call(e,"min"))throw new Error("random.distribution.min is required");if(!Object.prototype.hasOwnProperty.call(e,"max"))throw new Error("random.distribution.max is required");let n=ls(e.min,"random.distribution.min"),a=ls(e.max,"random.distribution.max")-n+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return So({type:"integer",value:a===1?n:n+Qh(t,a)})},rg=(e,t)=>{if(sn(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>xc)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let n=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(as(c,p),sn(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return as(c.actions,`${p}.actions`),{weight:Wh(c.weight,`${p}.weight`,{min:0})}}),i=Math.max(...n.map(({weight:c})=>c));if(i<=0)throw new Error("random weighted total weight must be positive");let a=n.map(c=>({...c,weight:c.weight/i})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(n[u].weight>0&&(c.weight===0||c.weight/r<=Kh))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Zh(t)*r,o=0,l=a.findLastIndex(({weight:c})=>c>0);for(let c=0;c<a.length;c+=1){let u=a[c];if(o+=u.weight,s<o){l=c;break}}return So({type:"weighted",outcomeIndex:l})},Oc=(e,{randomSource:t})=>{as(e,"random.distribution");let i={integer:eg,weighted:rg}[e.type];if(!i)throw new Error('random.distribution.type must be "integer" or "weighted"');return i(e,t)},cs=(e,t)=>{if(as(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")sn(e,new Set(["type","value"]),"random result"),ls(e.value,"random result.value");else if(t==="weighted")sn(e,new Set(["type","outcomeIndex"]),"random result"),ls(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:xc-1});else throw new Error(`unsupported recorded random result type: ${t}`);return So(e)};var st=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),Cc=Object.freeze([st("cleanup",["clearPendingEffects","cleanAll"]),st("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),st("decision",["submitForm","cancelForm","random:weighted","conditional"]),st("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),st("runtime",["setNextLineConfig","startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","showDialogueUI","hideDialogueUI","toggleDialogueUI","setDialogueTextSpeed","setAutoForwardDelay","setAutoForwardSpeed","setSkipUnseenText","setSkipTransitionsAndAnimations","setSoundVolume","setMusicVolume","setMuteAll","setSaveLoadPagination","incrementSaveLoadPagination","decrementSaveLoadPagination","setMenuPage","setMenuEntryPoint","showConfirmDialog","hideConfirmDialog","pushOverlay","popOverlay","replaceLastOverlay","clearOverlays","completeAchievement","setAchievementProgress","showImageGalleryVariant","moveToPreviousImageGalleryVariant","moveToNextImageGalleryVariant","clearImageGallerySelection","moveToImageGalleryPage","moveToNextImageGalleryPage","moveToPreviousImageGalleryPage","playMusicRoomTrack","playMusicRoom","pauseMusicRoom","stopMusicRoom","seekMusicRoom","playPreviousMusicRoomTrack","playNextMusicRoomTrack","clearMusicRoomSelection","moveToMusicRoomPage","moveToNextMusicRoomPage","moveToPreviousMusicRoomPage","finishSceneReplay","moveToSceneReplayPage","moveToNextSceneReplayPage","moveToPreviousSceneReplayPage","musicRoomSoundReady","musicRoomSoundProgress","musicRoomSoundComplete","musicRoomSoundError","appendPendingEffect","beginRollbackActionBatch","endRollbackActionBatch","ensureRandomReplayOccurrence","recordRandomOutcome","markRollbackCheckpointTransient","markSavedRollbackCheckpointTransient","recordCurrentDialogueHistory"]),st("persistence",["saveSlot"]),st("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),Et=new Map;Cc.forEach(e=>{e.actions.forEach(t=>{if(Et.has(t))throw new Error(`duplicate action execution key: ${t}`);Et.set(t,Et.size)})});var tg=new Set(Cc.find(({name:e})=>e==="navigation").actions),Rc=Et.get("saveSlot")-.5,$c=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",ng=(e,t)=>e<t?-1:e>t?1:0,us=e=>Object.entries(e).sort((t,n)=>{let i=$c(...t),a=$c(...n),r=Et.get(i),s=Et.get(a),o=r??Rc,l=s??Rc;return o!==l?o-l:r!==void 0&&s!==void 0?0:ng(i,a)}),ps=e=>tg.has(e),fs=e=>{let t=e.map(([n])=>n).filter(ps);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var sg=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),or=(...e)=>e.map(sg).join(":"),ds=e=>Array.isArray(e?.sounds)?e.sounds:e?.resourceId?[{id:e.resourceId,resourceId:e.resourceId,loop:e.loop??!0,volume:e.volume,startDelayMs:e.startDelayMs??0}]:[],Oo=e=>!Array.isArray(e?.sounds)&&e?.startDelayMs>0,on=(e,t)=>Oo(e)?or("bgm","legacy-delay",t.resourceId):or("bgm",t.id==="default"?t.resourceId:t.id),_c=({bgm:e,resources:t,previousBgmRender:n})=>{let i=ds(e).filter(c=>L(t.sounds,c.resourceId)),a=ds(n?.bgm).filter(c=>L(n.resources?.sounds,c.resourceId)).map((c,u)=>({sound:c,renderId:n.channel?.children[u]?.id})).filter(({renderId:c})=>c!==void 0),r=new Map,s=new Set,o=(c,u)=>{!u||s.has(u.renderId)||(r.set(c.id,u.renderId),s.add(u.renderId))};return Oo(e)===Oo(n?.bgm)&&(i.forEach(c=>o(c,a.find(u=>u.sound.id===c.id))),i.forEach(c=>{r.has(c.id)||o(c,a.find(u=>u.sound.resourceId===c.resourceId&&on(n.bgm,u.sound)===on(e,c)))})),[...i].sort((c,u)=>+(c.id==="default")-+(u.id==="default")).forEach(c=>{if(r.has(c.id))return;let u=on(e,c);s.has(u)&&(u=or("bgm",c.id)),s.has(u)&&(u=or("bgm","clip",c.id));let p=0;for(;s.has(u);)u=or("bgm","clip",c.id,++p);r.set(c.id,u),s.add(u)}),r};var Lr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),an=Object.freeze({volume:100,pan:0,playbackRate:1}),ms=["volume","pan","playbackRate"],ig=["src","startAt","endAt","startDelayMs"],Nc=(e,t)=>{if(!e)return null;let n=e.children??[];if(n.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return n[0]},_o=(e,t)=>e?.id===t?.id&&ig.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),og=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),$o=e=>Math.max(-1,Math.min(1,e)),Co=({bgm:e,resources:t,renderedSound:n,property:i})=>{let a=e?.sounds?.length===1?e.sounds[0]:e?.sounds?.find(s=>on(e,s)===n?.id),r=L(t.sounds,a?.resourceId);return a?.[i]??r?.[i]??an[i]},ag=({property:e,value:t,relative:n,bgm:i,resources:a,renderedSound:r})=>{if(!i||!r)return t;if(e==="volume"){let s=Co({bgm:i,resources:a,renderedSound:r,property:e});return t*s/100}if(e==="pan"&&!n){let s=Co({bgm:i,resources:a,renderedSound:r,property:e});return $o(t+s)}return t},lg=({authoredInitialValue:e,authoredKeyframes:t,baselineBgm:n,compiledKeyframes:i,bgm:a,resources:r,renderedSound:s})=>{if(!a||!s)return i;let o=Co({bgm:a,resources:r,renderedSound:s,property:"pan"}),l=e??n?.pan??an.pan;return i.map((c,u)=>{let p=t[u];if(p.relative!==!0)return l=p.value,c;let m=Lr(p,"startValue")?l+p.startValue:l,d=m+p.value,{relative:f,...h}=c;return l=d,{...h,...Lr(p,"startValue")?{startValue:$o(m+o)}:{},value:$o(d+o)}})},jc=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},cg=(e,t)=>({...Lr(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Tc=({property:e,authored:t,speed:n,propertyPath:i,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${i}.keyframes] The final keyframe must use an absolute finite numeric value.`);let s={keyframes:t.keyframes.map(o=>{let l=cg(o,n),c=l.relative===!0;return l.value=a({property:e,value:l.value,relative:c}),Lr(l,"startValue")&&(l.startValue=a({property:e,value:l.startValue,relative:c})),l})};return Lr(t,"initialValue")&&(s.initialValue=a({property:e,value:t.initialValue,relative:!1})),s},ug=({authored:e,bgm:t,baselineBgm:n=t,property:i,propertyPath:a,renderedSound:r,resources:s,speed:o})=>{let l=Tc({property:i,authored:e,speed:o,propertyPath:a,normalizeValue:({value:c,relative:u})=>ag({property:i,value:c,relative:u,bgm:t,resources:s,renderedSound:r})});return i==="pan"&&(l.keyframes=lg({authoredInitialValue:e.initialValue,authoredKeyframes:e.keyframes,baselineBgm:n,compiledKeyframes:l.keyframes,bgm:t,resources:s,renderedSound:r})),l},pg=({actionPath:e,compiled:t,property:n,propertyPath:i,renderedSound:a})=>{let r=a[n]??an[n],s=t.keyframes.at(-1);if(!og(s.value,r))throw new Error(`[${e}.audioEffects]
|
|
3
|
-
[${i}.keyframes] The final keyframe value must match the persistent BGM ${
|
|
1
|
+
var uy=Object.create;var Ki=Object.defineProperty;var py=Object.getOwnPropertyDescriptor;var fy=Object.getOwnPropertyNames;var dy=Object.getPrototypeOf,my=Object.prototype.hasOwnProperty;var yy=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),hy=(e,t)=>{for(var s in t)Ki(e,s,{get:t[s],enumerable:!0})},gy=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of fy(t))!my.call(e,a)&&a!==s&&Ki(e,a,{get:()=>t[a],enumerable:!(i=py(t,a))||i.enumerable});return e};var by=(e,t,s)=>(s=e!=null?uy(dy(e)):{},gy(t||!e||!e.__esModule?Ki(s,"default",{value:e,enumerable:!0}):s,e));var Yf=yy(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});function Uf(e){let t=e.length,s=0,i=0,a;for(;i<t;)s++,a=e.charCodeAt(i++),a>=55296&&a<=56319&&i<t&&(a=e.charCodeAt(i),(a&64512)===56320&&i++);return s}nl.default=Uf;Uf.code='require("ajv/dist/runtime/ucs2length").default'});var Ml=Symbol.for("immer-nothing"),Nl=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state");function Xe(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var vt=Object.getPrototypeOf;function Ie(e){return!!e&&!!e[Le]}function Qr(e){return e?Vl(e)||Array.isArray(e)||!!e[Nl]||!!e.constructor?.[Nl]||Xn(e)||Gn(e):!1}var wy=Object.prototype.constructor.toString();function Vl(e){if(!e||typeof e!="object")return!1;let t=vt(e);if(t===null)return!0;let s=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return s===Object?!0:typeof s=="function"&&Function.toString.call(s)===wy}function Yn(e){return Ie(e)||Xe(15,e),e[Le].base_}function Fn(e,t){zn(e)===0?Reflect.ownKeys(e).forEach(s=>{t(s,e[s],e)}):e.forEach((s,i)=>t(i,s,e))}function zn(e){let t=e[Le];return t?t.type_:Array.isArray(e)?1:Xn(e)?2:Gn(e)?3:0}function Qi(e,t){return zn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ql(e,t,s){let i=zn(e);i===2?e.set(t,s):i===3?e.add(s):e[t]=s}function Iy(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Xn(e){return e instanceof Map}function Gn(e){return e instanceof Set}function Jr(e){return e.copy_||e.base_}function Zi(e,t){if(Xn(e))return new Map(e);if(Gn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let s=Vl(e);if(t===!0||t==="class_only"&&!s){let i=Object.getOwnPropertyDescriptors(e);delete i[Le];let a=Reflect.ownKeys(i);for(let r=0;r<a.length;r++){let n=a[r],o=i[n];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(i[n]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[n]})}return Object.create(vt(e),i)}else{let i=vt(e);if(i!==null&&s)return{...e};let a=Object.create(i);return Object.assign(a,e)}}function so(e,t=!1){return Hn(e)||Ie(e)||!Qr(e)||(zn(e)>1&&(e.set=e.add=e.clear=e.delete=vy),Object.freeze(e),t&&Object.entries(e).forEach(([s,i])=>so(i,!0))),e}function vy(){Xe(2)}function Hn(e){return Object.isFrozen(e)}var ky={};function Zr(e){let t=ky[e];return t||Xe(0,e),t}var Xt;function Fl(){return Xt}function Ay(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function jl(e,t){t&&(Zr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function eo(e){ro(e),e.drafts_.forEach(Py),e.drafts_=null}function ro(e){e===Xt&&(Xt=e.parent_)}function Tl(e){return Xt=Ay(Xt,e)}function Py(e){let t=e[Le];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Dl(e,t){t.unfinalizedDrafts_=t.drafts_.length;let s=t.drafts_[0];return e!==void 0&&e!==s?(s[Le].modified_&&(eo(t),Xe(4)),Qr(e)&&(e=Bn(t,e),t.parent_||Un(t,e)),t.patches_&&Zr("Patches").generateReplacementPatches_(s[Le].base_,e,t.patches_,t.inversePatches_)):e=Bn(t,s,[]),eo(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ml?e:void 0}function Bn(e,t,s){if(Hn(t))return t;let i=t[Le];if(!i)return Fn(t,(a,r)=>Ll(e,i,t,a,r,s)),t;if(i.scope_!==e)return t;if(!i.modified_)return Un(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let a=i.copy_,r=a,n=!1;i.type_===3&&(r=new Set(a),a.clear(),n=!0),Fn(r,(o,l)=>Ll(e,i,a,o,l,s,n)),Un(e,a,!1),s&&e.patches_&&Zr("Patches").generatePatches_(i,s,e.patches_,e.inversePatches_)}return i.copy_}function Ll(e,t,s,i,a,r,n){if(Ie(a)){let o=r&&t&&t.type_!==3&&!Qi(t.assigned_,i)?r.concat(i):void 0,l=Bn(e,a,o);if(ql(s,i,l),Ie(l))e.canAutoFreeze_=!1;else return}else n&&s.add(a);if(Qr(a)&&!Hn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Bn(e,a),(!t||!t.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(s,i)&&Un(e,a)}}function Un(e,t,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&so(t,s)}function xy(e,t){let s=Array.isArray(e),i={type_:s?1:0,scope_:t?t.scope_:Fl(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=i,r=io;s&&(a=[i],r=Gt);let{revoke:n,proxy:o}=Proxy.revocable(a,r);return i.draft_=o,i.revoke_=n,o}var io={get(e,t){if(t===Le)return e;let s=Jr(e);if(!Qi(s,t))return Ey(e,s,t);let i=s[t];return e.finalized_||!Qr(i)?i:i===Wi(e.base_,t)?(Ji(e),e.copy_[t]=no(i,e)):i},has(e,t){return t in Jr(e)},ownKeys(e){return Reflect.ownKeys(Jr(e))},set(e,t,s){let i=Bl(Jr(e),t);if(i?.set)return i.set.call(e.draft_,s),!0;if(!e.modified_){let a=Wi(Jr(e),t),r=a?.[Le];if(r&&r.base_===s)return e.copy_[t]=s,e.assigned_[t]=!1,!0;if(Iy(s,a)&&(s!==void 0||Qi(e.base_,t)))return!0;Ji(e),to(e)}return e.copy_[t]===s&&(s!==void 0||t in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=s,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Wi(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ji(e),to(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let s=Jr(e),i=Reflect.getOwnPropertyDescriptor(s,t);return i&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:i.enumerable,value:s[t]}},defineProperty(){Xe(11)},getPrototypeOf(e){return vt(e.base_)},setPrototypeOf(){Xe(12)}},Gt={};Fn(io,(e,t)=>{Gt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Gt.deleteProperty=function(e,t){return Gt.set.call(this,e,t,void 0)};Gt.set=function(e,t,s){return io.set.call(this,e[0],t,s,e[0])};function Wi(e,t){let s=e[Le];return(s?Jr(s):e)[t]}function Ey(e,t,s){let i=Bl(t,s);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}function Bl(e,t){if(!(t in e))return;let s=vt(e);for(;s;){let i=Object.getOwnPropertyDescriptor(s,t);if(i)return i;s=vt(s)}}function to(e){e.modified_||(e.modified_=!0,e.parent_&&to(e.parent_))}function Ji(e){e.copy_||(e.copy_=Zi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Sy=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,s,i)=>{if(typeof t=="function"&&typeof s!="function"){let r=s;s=t;let n=this;return function(l=r,...c){return n.produce(l,u=>s.call(this,u,...c))}}typeof s!="function"&&Xe(6),i!==void 0&&typeof i!="function"&&Xe(7);let a;if(Qr(t)){let r=Tl(this),n=no(t,void 0),o=!0;try{a=s(n),o=!1}finally{o?eo(r):ro(r)}return jl(r,i),Dl(a,r)}else if(!t||typeof t!="object"){if(a=s(t),a===void 0&&(a=t),a===Ml&&(a=void 0),this.autoFreeze_&&so(a,!0),i){let r=[],n=[];Zr("Patches").generateReplacementPatches_(t,a,r,n),i(r,n)}return a}else Xe(1,t)},this.produceWithPatches=(t,s)=>{if(typeof t=="function")return(n,...o)=>this.produceWithPatches(n,l=>t(l,...o));let i,a;return[this.produce(t,s,(n,o)=>{i=n,a=o}),i,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Qr(e)||Xe(8),Ie(e)&&(e=Ge(e));let t=Tl(this),s=no(e,void 0);return s[Le].isManual_=!0,ro(t),s}finishDraft(e,t){let s=e&&e[Le];(!s||!s.isManual_)&&Xe(9);let{scope_:i}=s;return jl(i,t),Dl(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let s;for(s=t.length-1;s>=0;s--){let a=t[s];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}s>-1&&(t=t.slice(s+1));let i=Zr("Patches").applyPatches_;return Ie(e)?i(e,t):this.produce(e,a=>i(a,t))}};function no(e,t){let s=Xn(e)?Zr("MapSet").proxyMap_(e,t):Gn(e)?Zr("MapSet").proxySet_(e,t):xy(e,t);return(t?t.scope_:Fl()).drafts_.push(s),s}function Ge(e){return Ie(e)||Xe(10,e),Ul(e)}function Ul(e){if(!Qr(e)||Hn(e))return e;let t=e[Le],s;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,s=Zi(e,t.scope_.immer_.useStrictShallowCopy_)}else s=Zi(e,!0);return Fn(s,(i,a)=>{ql(s,i,Ul(a))}),t&&(t.finalized_=!1),s}var qe=new Sy,Kn=qe.produce,uP=qe.produceWithPatches.bind(qe),pP=qe.setAutoFreeze.bind(qe),fP=qe.setUseStrictShallowCopy.bind(qe),dP=qe.applyPatches.bind(qe),mP=qe.createDraft.bind(qe),yP=qe.finishDraft.bind(qe);var S={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},te={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},kt={NOT:0};var V=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},De=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var oo=e=>{if(!e||e.trim()==="")throw new V("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let s=e.includes("===")?"==":"!=";throw new V(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${s}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let s of t)if(e.trim().endsWith(s))throw new V(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Yl=e=>{if(e.trim().endsWith(" in"))throw new V(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new V(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,s]=e.split(" in ");if(!s||s.trim()==="")throw new V(`Missing iterable expression after 'in' (got: '$for ${e}')`);let i=t.includes(",")?t.split(",").map(a=>a.trim()):[t.trim()];for(let a of i){if(!a)throw new V(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new V(`Invalid loop syntax (got: '$for ${e}')`)}};var zl=(e,t,s=!1)=>{if(t===null)return new De(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new De(`Cannot iterate over undefined value at '$for ${e}'`);let i=typeof t;return s?new De(`Cannot iterate over non-array value in loop '${e}' - got ${i} instead`):new De(`Cannot iterate over non-array value (got: ${i}) at '$for ${e}'`)},Xl=(e,t)=>{let s=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new De(`Unknown function '${e}' (${s})`)};var Oy=(e,t,s={})=>{let i={},a={};s&&typeof s=="object"&&(s.functions!==void 0||s.partials!==void 0?(i=s.functions||{},a=s.partials||{}):typeof s=="object"&&(i=s));let n=ne(e,{functions:i,partials:a},t,{});return n===void 0?{}:n},ne=(e,t,s,i)=>{let a=t.functions||t;if(e.var&&!e.type)return Pe(e.var,s,i);if(e.type===S.LITERAL)return e.value;if(e.type===S.VARIABLE)return Pe(e.path,s,i);if(e.type===S.INTERPOLATION)return $y(e.parts,t,s,i);switch(e.type){case S.FUNCTION:return Hl(e,t,s,i);case S.BINARY:return Kl(e,t,s,i);case S.UNARY:return Wl(e,t,s,i);case S.CONDITIONAL:return _y(e,t,s,i);case S.LOOP:return Ly(e,t,s,i);case S.OBJECT:return Vy(e,t,s,i);case S.ARRAY:return qy(e,t,s,i);case S.PARTIAL:return Fy(e,t,s,i);case S.PATH_REFERENCE:return By(e,t,s,i);default:throw new Error(`Unknown node type: ${e.type}`)}},Gl=new Map,Ry=e=>{let t=[],s="",i=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")s&&(t.push({type:"property",value:s}),s=""),i=!0;else if(r==="]"){if(i&&s){let n=s.trim();if(/^\d+$/.test(n))t.push({type:"index",value:parseInt(n,10)});else if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")){let o=n.slice(1,-1);t.push({type:"property",value:o})}else t.push({type:"property",value:n});s=""}i=!1}else s+=r}return s&&t.push({type:"property",value:s}),t},Pe=(e,t,s)=>{if(!e)return;if(e in s)return s[e];let i=Gl.get(e);if(!i){let r=[],n="",o=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(o++,n+=c):c==="]"?(o--,n+=c):c==="."&&o===0?n&&(r.push(n),n=""):n+=c}n&&r.push(n),i=[];for(let l of r){let c=Ry(l.trim());i.push(...c)}Gl.set(e,i)}let a=t;for(let r=0;r<i.length;r++){let n=i[r];if(n.type==="property"&&n.value in s){a=s[n.value];continue}if(a==null)return;(n.type==="property"||n.type==="index")&&(a=a[n.value])}return a},$y=(e,t,s,i)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let n=ne(r,t,s,i);a.push(n!=null?String(n):"")}return a.join("")},Hl=(e,t,s,i)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Xl(e.name,a);let n=e.args.map(o=>ne(o,t,s,i));return r(...n)},Nr=(e,t,s,i)=>{if(e.var&&!e.type)return Pe(e.var,s,i);switch(e.type){case S.VARIABLE:return Pe(e.path,s,i);case S.LITERAL:return e.value;case S.BINARY:return Kl(e,t,s,i);case S.UNARY:return Wl(e,t,s,i);case S.FUNCTION:return Hl(e,t,s,i);default:return ne(e,t,s,i)}},Kl=(e,t,s,i)=>{if(e.op===te.AND||e.op===te.OR){let n=Nr(e.left,t,s,i),o=Nr(e.right,t,s,i);switch(e.op){case te.AND:return n&&o;case te.OR:return n||o}}let a=ne(e.left,t,s,i),r=ne(e.right,t,s,i);switch(e.op){case te.EQ:return a==r;case te.NEQ:return a!=r;case te.GT:return a>r;case te.LT:return a<r;case te.GTE:return a>=r;case te.LTE:return a<=r;case te.IN:return Array.isArray(r)?r.includes(a):!1;case te.ADD:if(typeof a!="number"||typeof r!="number")throw new De(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case te.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new De(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Wl=(e,t,s,i)=>{let a=e.op===kt.NOT?Nr(e.operand,t,s,i):ne(e.operand,t,s,i);if(e.op===kt.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Cy=(e,t,s,i)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===S.VARIABLE)if(Pe(a.path,s,i)){let n=e.bodies[0];if(n.type===S.OBJECT&&n.fast===!0&&!n.whenCondition&&n.properties.length<=5){let o={};for(let l of n.properties){let c=l.parsedKey?ne(l.parsedKey,t,s,i):l.key,u=l.value;if(u.type===S.LITERAL)o[c]=u.value;else if(u.type===S.VARIABLE)o[c]=Pe(u.path,s,i);else if(u.type===S.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===S.VARIABLE){let d=Pe(m.path,s,i);p.push(d!=null?String(d):"")}else{let d=ne(m,t,s,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=ne(u,t,s,i)}return o}}else{let n=e.bodies[1];if(n.type===S.OBJECT&&n.fast===!0&&!n.whenCondition&&n.properties.length<=5){let o={};for(let l of n.properties){let c=l.parsedKey?ne(l.parsedKey,t,s,i):l.key,u=l.value;if(u.type===S.LITERAL)o[c]=u.value;else if(u.type===S.VARIABLE)o[c]=Pe(u.path,s,i);else if(u.type===S.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===S.VARIABLE){let d=Pe(m.path,s,i);p.push(d!=null?String(d):"")}else{let d=ne(m,t,s,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=ne(u,t,s,i)}return o}}}return null},_y=(e,t,s,i)=>{let a=Cy(e,t,s,i);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let n=e.conditions[r];if(n===null||Nr(n,t,s,i))return ne(e.bodies[r],t,s,i)}return Ql},Ny=(e,t)=>{let s=e.body,i=e.itemVar;if(s.type===S.CONDITIONAL&&s.conditions.length===1&&s.conditions[0].type===S.VARIABLE){let a=s.conditions[0].path,r=s.bodies[0];if(a.startsWith(i+".")){let n=a.substring(i.length+1);if(r.type===S.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c[n]){let u={};for(let p of r.properties){let m=p.key,d=p.value;if(d.type===S.LITERAL)u[m]=d.value;else if(d.type===S.VARIABLE){let f=d.path;if(f===i)u[m]=c;else if(f.startsWith(i+".")){let h=f.substring(i.length+1);u[m]=c[h]}else return null}else if(d.type===S.INTERPOLATION){let f=[],h=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===S.VARIABLE){let y=g.path;if(y===i)f.push(c!=null?String(c):"");else if(y.startsWith(i+".")){let b=y.substring(i.length+1),w=c[b];f.push(w!=null?String(w):"")}else{h=!1;break}}else{h=!1;break}if(!h)return null;u[m]=f.join("")}else return null}o.push(u)}}return o}}}return null},jy=(e,t)=>{let s=e.body,i=e.itemVar,a=Ny(e,t);if(a!==null)return a;if(s.type===S.OBJECT&&s.properties.length<=5&&!s.whenCondition){for(let o of s.properties)if(o.parsedKey)return null;let r=[],n=!0;for(let o of s.properties){let l=o.key,c=o.value;if(c.type===S.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===S.VARIABLE){let u=c.path;if(u===i)r.push({key:l,type:"item"});else if(u.startsWith(i+".")){let p=u.substring(i.length+1);if(!p.includes(".")&&!p.includes("["))r.push({key:l,type:"prop",prop:p});else{n=!1;break}}else{n=!1;break}}else if(c.type===S.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===S.VARIABLE){let p=u.path;if(p===i)r.push({key:l,type:"item_string"});else if(p.startsWith(i+".")){let m=p.substring(i.length+1);if(!m.includes(".")&&!m.includes("["))r.push({key:l,type:"prop_string",prop:m});else{n=!1;break}}else{n=!1;break}}else{n=!1;break}}else{n=!1;break}}if(n){let o=new Array(t.length);if(r.length===3&&r[0].type==="prop"&&r[0].key==="id"&&r[1].type==="prop_string"&&r[1].key==="title"&&r[2].type==="prop"&&r[2].key==="completed")for(let l=0;l<t.length;l++){let c=t[l];o[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<t.length;l++){let c=t[l],u={};for(let p of r)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let m=c[p.prop];u[p.key]=m!=null?String(m):""}o[l]=u}return o}}return null},Ty=(e,t,s,i,a)=>{let r=[],n=e.body;if(n.type===S.OBJECT&&n.fast!==!1){let o=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},m={...i,[o]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=i.__paths__||{});let d=e.iterable.path||"";if(i&&i.__paths__&&d){let f=d.split("."),h=f[0];h in i.__paths__&&(d=i.__paths__[h],f.length>1&&(d+="."+f.slice(1).join(".")))}m.__paths__={...m.__paths__,[o]:`${d}[${c}]`,...l&&{[l]:c}};for(let f of n.properties){let h=f.parsedKey?ne(f.parsedKey,t,s,m):f.key,g=f.value;if(g.type===S.LITERAL)p[h]=g.value;else if(g.type===S.VARIABLE){let y=g.path;if(y===o)p[h]=u;else if(y===l)p[h]=c;else if(y.startsWith(o+".")){let b=y.substring(o.length+1);!b.includes(".")&&!b.includes("[")?p[h]=u[b]:p[h]=Pe(y,s,{...i,[o]:u,...l&&{[l]:c}})}else p[h]=Pe(y,s,{...i,[o]:u,...l&&{[l]:c}})}else if(g.type===S.INTERPOLATION){let y=[];for(let b of g.parts)if(typeof b=="string")y.push(b);else if(b.type===S.VARIABLE){let w=b.path,A;if(w===o)A=u;else if(w===l)A=c;else if(w.startsWith(o+".")){let k=w.substring(o.length+1);!k.includes(".")&&!k.includes("[")?A=u[k]:A=Pe(w,s,{...i,[o]:u,...l&&{[l]:c}})}else A=Pe(w,s,{...i,[o]:u,...l&&{[l]:c}});y.push(A!=null?String(A):"")}else{let w={...i,[o]:u,...l&&{[l]:c}},A=ne(b,t,s,w);y.push(A!=null?String(A):"")}p[h]=y.join("")}else{let y={...i,[o]:u,...l&&{[l]:c}};p[h]=ne(g,t,s,y)}}r.push(p)}return r}return null},Dy=(e,t,s)=>{let i=e.body;if(i.type===S.OBJECT&&i.properties.length===1&&i.properties[0].key==="$if item.visible"){let r=i.properties[0].value;if(r.type===S.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===S.VARIABLE&&r.conditions[0].path==="item.visible"){let n=r.bodies[0];if(n.type===S.OBJECT&&n.properties.length===2){let o=n.properties[0],l=n.properties[1];if(o.key==="id"&&o.value.type===S.VARIABLE&&o.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===S.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let m={id:p.id};p.highlighted?(m.highlight=!0,m.message=`This item is highlighted: ${p.name}`):(m.highlight=!1,m.message=p.name),c.push(m)}}return c}}}}return null},Ly=(e,t,s,i)=>{let a=ne(e.iterable,t,s,i);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===S.FUNCTION){u=!0;let m=e.iterable.args.map(d=>d.type===S.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===S.VARIABLE?d.path:d.type===S.FUNCTION?`${d.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${m})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw zl(p,a,u)}if(!e.indexVar){let c=Dy(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=jy(e,a);if(c!==null)return c}let r=Ty(e,t,s,i,a);if(r!==null)return r;let n=[],o=e.iterable.path||"";if(i&&i.__paths__&&o){let c=o.split("."),u=c[0];u in i.__paths__&&(o=i.__paths__[u],c.length>1&&(o+="."+c.slice(1).join(".")))}let l=!1;e.body.type===S.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===S.OBJECT&&c.properties.some(u=>u.key.startsWith("$if ")||u.key.startsWith("$when "))));for(let c=0;c<a.length;c++){let u=e.indexVar?{...i,[e.itemVar]:a[c],[e.indexVar]:c}:{...i,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=i.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${o}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=ne(e.body,t,s,u);if(Array.isArray(p)&&p.length===1&&!l){let m=p[0];n.push(m===void 0?{}:m)}else n.push(p===void 0?{}:p)}return n},Jl=(e,t,s)=>e.type!==S.OBJECT||e.whenCondition||e.properties.length>t?!1:e.properties.every(({value:i})=>{switch(i.type){case S.LITERAL:case S.VARIABLE:return!0;case S.INTERPOLATION:return i.parts.every(a=>typeof a=="string"||a.type===S.VARIABLE);case S.OBJECT:return s&&Jl(i,5,!1);default:return!1}}),My=(e,t,s,i)=>{if(e.whenCondition||e.properties.length!==1||!Jl(e.properties[0].value,10,!0))return null;let a=e.properties[0],r=a.parsedKey?ne(a.parsedKey,t,s,i):a.key,n=a.value,o={},l={};for(let c of n.properties){let u=c.parsedKey?ne(c.parsedKey,t,s,i):c.key,p=c.value;if(p.type===S.LITERAL)l[u]=p.value;else if(p.type===S.VARIABLE)l[u]=Pe(p.path,s,i);else if(p.type===S.INTERPOLATION){let m=[];for(let d of p.parts)if(typeof d=="string")m.push(d);else if(d.type===S.VARIABLE){let f=Pe(d.path,s,i);m.push(f!=null?String(f):"")}l[u]=m.join("")}else if(p.type===S.OBJECT){let m={};for(let d of p.properties){let f=d.parsedKey?ne(d.parsedKey,t,s,i):d.key,h=d.value;if(h.type===S.LITERAL)m[f]=h.value;else if(h.type===S.VARIABLE)m[f]=Pe(h.path,s,i);else if(h.type===S.INTERPOLATION){let g=[];for(let y of h.parts)if(typeof y=="string")g.push(y);else if(y.type===S.VARIABLE){let b=Pe(y.path,s,i);g.push(b!=null?String(b):"")}m[f]=g.join("")}}l[u]=m}}return o[r]=l,o},Vy=(e,t,s,i)=>{let a=t.functions||t;if(e.whenCondition&&!Nr(e.whenCondition,a,s,i))return;let r=My(e,t,s,i);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?ne(u.parsedKey,t,s,i):u.key,m=u.value;if(m.type===S.LITERAL)c[p]=m.value;else if(m.type===S.VARIABLE)c[p]=Pe(m.path,s,i);else if(m.type===S.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===S.VARIABLE){let h=Pe(f.path,s,i);d.push(h!=null?String(h):"")}else{let h=ne(f,t,s,i);d.push(h!=null?String(h):"")}c[p]=d.join("")}else c[p]=ne(m,t,s,i)}return c}let n={},o=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=ne(c.value,t,s,i);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(n,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return ne(c.value,t,s,i)}else{let u=c.parsedKey?ne(c.parsedKey,t,s,i):c.key,p=c.value;if(p&&p.type===S.OBJECT&&p.properties){let m=p.properties.find(d=>d.key.startsWith("$for "));if(m){let d=ne(m.value,t,s,i);d!==void 0&&(n[u]=d)}else{let d=ne(c.value,t,s,i);d!==void 0&&(n[u]=d)}}else{let m=ne(c.value,t,s,i);(m!==void 0||p?.type===S.VARIABLE||p?.type===S.FUNCTION)&&(n[u]=m)}}return n},Ql={},qy=(e,t,s,i)=>{let a=[];for(let r of e.items)if(r.type===S.LOOP){let n=ne(r,t,s,i);Array.isArray(n)&&r.flatten!==!1?a.push(...n):a.push(n)}else{let n=ne(r,t,s,i);n!==Ql&&n!==void 0&&a.push(n)}return a},Fy=(e,t,s,i)=>{let{name:a,data:r,whenCondition:n}=e,o=t.partials||{},l=t.functions||t;if(n&&!Nr(n,l,s,i))return;if(!o[a])throw new De(`Partial '${a}' is not defined`);let c=i._partialStack||[];if(c.includes(a))throw new De(`Circular partial reference detected: ${a}`);let u=o[a],p=s,m={...i,_partialStack:[...c,a]};if(i){p={...s};for(let d of Object.keys(i))d.startsWith("_")||(p[d]=i[d])}if(r){let d=ne(r,t,s,i);p={...p,...d}}return ne(u,t,p,m)},By=(e,t,s,i)=>{let{path:a}=e,r=a.split("."),n=r[0],o=r.slice(1);if(!i||!(n in i))throw new De(`Path reference '#{${a}}' refers to '${n}' which is not a loop variable in the current scope`);if(i.__paths__||(i.__paths__={}),!(n in i.__paths__))throw new De(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=i.__paths__[n];if(typeof l=="number"){if(o.length>0)throw new De(`Path reference '#{${a}}' - cannot access properties on index variable '${n}'`);return String(l)}return o.length>0&&(l+="."+o.join(".")),l};var ao=Oy;var Uy=/\$\{([^}]*)\}/g,Yy=/#\{([^}]*)\}/g,ec=(e,t={})=>{let s=e.match(/^(\w+)\((.*)\)$/);if(!s)return{isFunction:!1};let[,i,a]=s,r=zy(a,t);return{isFunction:!0,type:S.FUNCTION,name:i,args:r}},zy=(e,t={})=>e.trim()?Xy(e).map(i=>Gy(i.trim(),t)):[],Xy=e=>{let t=[],s="",i=0,a=!1,r="";for(let n=0;n<e.length;n++){let o=e[n],l=n>0?e[n-1]:"";!a&&(o==='"'||o==="'")?(a=!0,r=o,s+=o):a&&o===r&&l!=="\\"?(a=!1,r="",s+=o):!a&&o==="("?(i++,s+=o):!a&&o===")"?(i--,s+=o):!a&&o===","&&i===0?(t.push(s),s=""):s+=o}return s&&t.push(s),t},Gy=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:S.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:S.LITERAL,value:parseFloat(e)};if(e==="true")return{type:S.LITERAL,value:!0};if(e==="false")return{type:S.LITERAL,value:!1};if(e==="null")return{type:S.LITERAL,value:null};let s=ec(e,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};let i=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,n=null;for(let{op:o,type:l}of a){let c=0;for(;c<i.length;){let u=et(i.substring(c),o);if(u===-1)break;let p=c+u;p>r&&(r=p,n={op:o,type:l}),c=p+o.length}}if(r!==-1)try{return Oe(i,t)}catch{return{type:S.VARIABLE,path:i}}return{type:S.VARIABLE,path:i}},rc=/^\w+\(.*\)$/,Hy=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Ky=e=>{if(!(!e||e.trim()===""||rc.test(e))&&Hy.test(e))throw e.includes("?")&&e.includes(":")?new V(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new V(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new V(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Zl=e=>{let t=e.trim();if(rc.test(t))throw new V(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new V(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new V(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new V(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new V(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:S.PATH_REFERENCE,path:t}},Ht=(e,t={})=>{let s=e.trim();Ky(s);let i=ec(s,t);if(i.isFunction)return{type:i.type,name:i.name,args:i.args};if(s.includes("[")&&!/[\s+\-*/%|&?:]/.test(s)){let a=0;for(let r of s)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:S.VARIABLE,path:s}},lo=(e,t={})=>{let s=e,i=[];(e.includes("\\${")||e.includes("\\#{"))&&(s=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),s=s.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),s=s.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${i.length}__`;return i.push(u),p}),s=s.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${i.length}__`;return i.push(u),p}),s=s.replace(/\\DOUBLE_ESC_VAR/g,"\\"),s=s.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...s.matchAll(Uy)],r=[...s.matchAll(Yy)],n=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(n.length===0){let c=s;for(let u=0;u<i.length;u++)c=c.replace(`__ESCAPED_${u}__`,i[u]);return{type:S.LITERAL,value:c}}if(n.length===1&&n[0].match[0]===s&&i.length===0){let{match:c,type:u}=n[0];try{return u==="variable"?Ht(c[1],t):Zl(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:S.LITERAL,value:s};throw p}}let o=[],l=0;for(let{match:c,type:u}of n){let[p,m]=c,d=c.index;if(d>l){let f=s.substring(l,d);for(let h=0;h<i.length;h++)f=f.replace(`__ESCAPED_${h}__`,i[h]);f&&o.push(f)}try{let f;u==="variable"?f=Ht(m.trim(),t):f=Zl(m.trim()),o.push(f)}catch(f){if(f.message==="Invalid array index syntax")o.push(p);else throw f}l=d+p.length}if(l<s.length){let c=s.substring(l);for(let u=0;u<i.length;u++)c=c.replace(`__ESCAPED_${u}__`,i[u]);c&&o.push(c)}return{type:S.INTERPOLATION,parts:o}};var po=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),sc=e=>Object.keys(e),_e=e=>e.join("."),jr=(e,t,s)=>{let i=sc(e).filter(a=>!t.has(a));if(i.length>0)throw new V(`Unexpected key '${i[0]}' in condition JSON at '${_e(s)}'`)},Tr=(e,t)=>typeof e=="string"?lo(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?Jy(e,t):Qy(e,t):{type:S.LITERAL,value:e},Wy=e=>{let{$each:t,...s}=e;if(typeof t!="string")throw new V("$each value must be a non-empty string");let i=t.trim();if(i==="")throw new V("$each value must be a non-empty string");if(Object.keys(s).length===0)throw new V("Empty $each body not allowed");if(s.$partial!==void 0)throw new V("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${i}`]:s}},Jy=(e,t)=>{let s=[],i=!1;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(r.$each!==void 0)try{let l=Wy(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=nc(c[0],l[c[0]],t,!0);s.push(u),i=!0;continue}}catch(l){throw l instanceof V?l:new V(l.message)}let o=Object.keys(r);if(o.length===1&&/^\$for(?::\w+)?\s/.test(o[0])){let l=nc(o[0],r[o[0]],t);s.push(l),i=!0;continue}}let n=Tr(r,t);s.push(n),(n.type===S.FUNCTION||n.type===S.CONDITIONAL||n.type===S.LOOP||n.type===S.PARTIAL||n.type===S.OBJECT&&!n.fast||n.type===S.ARRAY&&!n.fast)&&(i=!0)}return{type:S.ARRAY,items:s,fast:!i}},Qy=(e,t)=>{let s=[],i=!1,a=null,r=Object.entries(e),n=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new V("$partial value must be a string");if(e.$partial.trim()==="")throw new V("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let b of l)if(y===b||y.startsWith(b+" ")||y.startsWith(b+"#")){c.push(b);break}if(c.length>0)throw new V(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...m}=e,d={},f=!1;for(let[y,b]of Object.entries(m)){let w=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(w=y.slice(1)),d[w]=b,f=!0}let h=null;if(f&&(h=Tr(d,t),h.type===S.OBJECT)){let y=!1;for(let b of h.properties)if(b.value.type===S.VARIABLE||b.value.type===S.INTERPOLATION||b.value.type===S.FUNCTION||b.value.type===S.CONDITIONAL||b.value.type===S.OBJECT&&!b.value.fast||b.value.type===S.ARRAY&&!b.value.fast){y=!0;break}y&&(h.fast=!1)}let g={type:S.PARTIAL,name:u,data:h};return p!==void 0&&(g.whenCondition=tc(p,t)),g}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new V("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new V("Missing condition expression after '$when'");a=tc(c,t),i=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new V("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;n<r.length;){let[l,c]=r[n];if(l==="$when"){n++;continue}if(l==="$each")throw new V("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=Zy(r,n,t);s.push({key:l,value:u.node}),i=!0,n=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new V(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new V(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new V("Missing condition expression after '$if'");{let u=Tr(c,t);(u.type===S.FUNCTION||u.type===S.CONDITIONAL||u.type===S.PARTIAL||u.type===S.OBJECT&&!u.fast||u.type===S.ARRAY&&!u.fast)&&(i=!0);let p=lo(l,t),m={key:l,value:u};(p.type!==S.LITERAL||p.value!==l)&&(m.parsedKey=p),s.push(m),n++}}}let o={type:S.OBJECT,properties:s,fast:!i};return a&&(o.whenCondition=a),o},Zy=(e,t,s={})=>{let i=[],a=[],r=t,[n,o]=e[r],l=null,c;if(n.startsWith("$if#")){let p=n.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new V(`Invalid conditional syntax: ${n}`)}else c=n.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());oo(c);let u=Oe(c,s);for(i.push(u),a.push(Tr(o,s)),r++;r<e.length;){let[p,m]=e[r],d=!1,f;if(l?p.startsWith(`$elif#${l} `)?(f=p.substring(`$elif#${l} `.length),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(d=!0,f=null):p.startsWith("$elif ")?(f=p.substring(6),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p==="$else"||p==="$else:")&&(d=!0,f=null),d){if(f===null)i.push(null);else{oo(f);let h=Oe(f,s);i.push(h)}if(a.push(Tr(m,s)),r++,f===null)break}else break}return{node:{type:S.CONDITIONAL,conditions:i,bodies:a,id:l},nextIndex:r}},co={eq:te.EQ,neq:te.NEQ,gt:te.GT,gte:te.GTE,lt:te.LT,lte:te.LTE,in:te.IN,add:te.ADD,sub:te.SUBTRACT},uo={all:te.AND,any:te.OR},eh=new Set(["var","literal","call","not",...Object.keys(co),...Object.keys(uo)]),rh=(e,t,s)=>{if(!Array.isArray(e))throw new V(`Condition JSON operator '${t}' at '${_e(s)}' requires an array`);if(e.length!==2)throw new V(`Condition JSON operator '${t}' at '${_e(s)}' requires exactly 2 operands`);return e},th=(e,t,s,i,a)=>{if(!Array.isArray(e))throw new V(`Condition JSON operator '${t}' at '${_e(a)}' requires an array`);if(e.length===0)throw new V(`Condition JSON operator '${t}' at '${_e(a)}' requires at least 1 condition`);return e.map((n,o)=>Me(n,i,[...a,o])).reduce((n,o)=>({type:S.BINARY,op:s,left:n,right:o}))},nh=(e,t,s)=>{let i,a;if(typeof e.call=="string")i=e.call,a=e.args??[],jr(e,new Set(["call","args"]),s);else if(po(e.call))i=e.call.name,a=e.call.args??[],jr(e,new Set(["call"]),s),jr(e.call,new Set(["name","args"]),[...s,"call"]);else throw new V(`Condition JSON call at '${_e(s)}' requires a function name`);if(typeof i!="string"||i.trim()==="")throw new V(`Condition JSON call at '${_e(s)}' requires a non-empty function name`);if(!/^\w+$/.test(i))throw new V(`Invalid condition JSON function name '${i}' at '${_e(s)}'`);if(!Array.isArray(a))throw new V(`Condition JSON call '${i}' at '${_e(s)}' requires args to be an array`);return{type:S.FUNCTION,name:i,args:a.map((r,n)=>Me(r,t,[...s,"args",n]))}},Me=(e,t={},s=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:S.LITERAL,value:e};if(Array.isArray(e))throw new V(`Condition JSON array at '${_e(s)}' must be wrapped in an operator or { literal: [...] }`);if(!po(e))throw new V(`Invalid condition JSON value at '${_e(s)}'`);let i=sc(e);if(i.length===0)throw new V(`Condition JSON object at '${_e(s)}' must contain an operator`);let a=i.filter(n=>eh.has(n));if(a.length===0)throw new V(`Unknown condition JSON operator '${i[0]}' at '${_e(s)}'`);if(a.length>1)throw new V(`Condition JSON at '${_e(s)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(jr(e,new Set(["var"]),s),typeof e.var!="string"||e.var.trim()==="")throw new V(`Condition JSON var at '${_e(s)}' requires a non-empty path`);return{type:S.VARIABLE,path:e.var}}if(r==="literal")return jr(e,new Set(["literal"]),s),{type:S.LITERAL,value:e.literal};if(r==="call")return nh(e,t,s);if(r==="not")return jr(e,new Set(["not"]),s),{type:S.UNARY,op:kt.NOT,operand:Me(e.not,t,[...s,"not"])};if(r in uo)return jr(e,new Set([r]),s),th(e[r],r,uo[r],t,[...s,r]);if(r in co){jr(e,new Set([r]),s);let n=rh(e[r],r,[...s,r]);return{type:S.BINARY,op:co[r],left:Me(n[0],t,[...s,r,0]),right:Me(n[1],t,[...s,r,1])}}throw new V(`Unknown condition JSON operator '${r}' at '${_e(s)}'`)},tc=(e,t={})=>{if(e==null)throw new V("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new V("Empty condition expression after '$when'");return Oe(e,t)}return po(e)||Array.isArray(e)?Me(e,t):{type:S.LITERAL,value:e}},Oe=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let m=0;m<c.length;m++)if(c[m]==="("?u++:c[m]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Oe(c,t)}let s=et(e,"||");if(s!==-1)return{type:S.BINARY,op:te.OR,left:Oe(e.substring(0,s).trim(),t),right:Oe(e.substring(s+2).trim(),t)};let i=et(e,"&&");if(i!==-1)return{type:S.BINARY,op:te.AND,left:Oe(e.substring(0,i).trim(),t),right:Oe(e.substring(i+2).trim(),t)};let a=[{op:">=",type:te.GTE},{op:"<=",type:te.LTE},{op:"==",type:te.EQ},{op:"!=",type:te.NEQ},{op:">",type:te.GT},{op:"<",type:te.LT},{op:" in ",type:te.IN}];for(let{op:c,type:u}of a){let p=et(e,c);if(p!==-1)return{type:S.BINARY,op:u,left:Oe(e.substring(0,p).trim(),t),right:Oe(e.substring(p+c.length).trim(),t)}}let r=-1,n=null,o=[{op:" + ",type:te.ADD},{op:" - ",type:te.SUBTRACT}];for(let{op:c,type:u}of o){let p=0;for(;p<e.length;){let m=et(e.substring(p),c);if(m===-1)break;let d=p+m;d>r&&(r=d,n={op:c,type:u}),p=d+c.length}}if(r!==-1&&n)return{type:S.BINARY,op:n.type,left:Oe(e.substring(0,r).trim(),t),right:Oe(e.substring(r+n.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(et(e,c)!==-1)throw new V(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:S.UNARY,op:kt.NOT,operand:Oe(e.substring(1).trim(),t)}:ic(e,t)},et=(e,t)=>{let s=0,i=0;for(;i<=e.length-t.length;){if(e[i]==="(")s++;else if(e[i]===")")s--;else if(s===0&&e.substring(i,i+t.length)===t)return i;i++}return-1},sh=e=>{if(e=e.trim(),e==="true")return{type:S.LITERAL,value:!0};if(e==="false")return{type:S.LITERAL,value:!1};if(e==="null")return{type:S.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:S.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:S.LITERAL,value:""};if(e==="{}")return{type:S.LITERAL,value:{}};if(e==="[]")return{type:S.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:S.LITERAL,value:t}:{type:S.VARIABLE,path:e}},ic=(e,t)=>{let s=e.trim();if(s.match(/^(\w+)\((.*)\)$/))return Ht(s,t);let a=sh(s);if(a.type===S.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(s))return{type:S.VARIABLE,path:s};try{return Ht(s,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},ih=(e,t=!1)=>{let s=t?"$each":"$for";try{Yl(e)}catch(i){if(i instanceof V&&t){let a=i.message.replace(/\$for/g,"$each");throw new V(a.replace("Parse Error: ",""))}throw i}},nc=(e,t,s,i=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let g=i?"$each":"$for";throw new V(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let n=r[1],o=r[2].trim();ih(o,i);let l=o.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=i?"$each":"$for";throw new V(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${o}')`)}let c=l[1].trim(),u=l[2].trim(),p,m=null;if(c.includes(",")){let g=c.split(",").map(y=>y.trim());if(g.length!==2)throw new V(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=g[0],m=g[1]}else p=c;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new V(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new V(`Reserved variable name: ${m}`);let f=ic(u,s),h=Tr(t,s);return{type:S.LOOP,itemVar:p,indexVar:m,iterable:f,body:h,flatten:n!=="nested"}};var oh=(e,t={})=>{let{functions:s={}}=t;return Tr(e,s)},Wn=oh;var Kt={};hy(Kt,{now:()=>ah});var ah=()=>Date.now();var lh=(e,t,s={})=>{let{functions:i={},partials:a={}}=s,r={...Kt,...i},n=Wn(e,{functions:r}),o={};for(let[l,c]of Object.entries(a))o[l]=Wn(c,{functions:r});return ao(n,t,{functions:r,partials:o})},rt=lh;var ch=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",uh=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,ph=(e,t)=>{if(ch(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new V("Empty condition expression");return Oe(e,t)}return Me(e,t)},fh=(e,t={},s={})=>{let i=uh(s),a={...Kt,...i},r=ph(e,a);return!!Nr(r,{functions:a,partials:{}},t,{})},fo=fh;var ko=Symbol("runStoreTransaction"),L=(e,t)=>e!=null&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,go="__routeEngineConditionComparison",Jn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",Dr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Jn(e,t)&&e>t,gte:(e,t)=>Jn(e,t)&&e>=t,lt:(e,t)=>Jn(e,t)&&e<t,lte:(e,t)=>Jn(e,t)&&e<=t}),dc=Object.freeze(Object.fromEntries(Object.keys(Dr).map(e=>[e,`${go}${e}`]))),dh=Object.freeze(Object.fromEntries(Object.entries(dc).map(([e,t])=>[t,Dr[e]]))),oc=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),mh=e=>{if(typeof e?.call=="string")return e.call;if(e?.call!==null&&typeof e?.call=="object"&&!Array.isArray(e.call))return e.call.name},Qn=e=>{if(Array.isArray(e))return e.map(Qn);if(e===null||typeof e!="object"||oc(e,"literal")||oc(e,"var"))return e;if(mh(e)?.startsWith(go))throw new Error(`Condition function names beginning with "${go}" are reserved`);let s=Object.entries(e);if(s.length===1){let[[i,a]]=s,r=dc[i];if(r)return{call:r,args:a.map(Qn)}}return Object.fromEntries(s.map(([i,a])=>[i,Qn(a)]))},Jt=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),fo(Qn(e),t,{functions:dh})},yh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],mc=(e,t,s={})=>{let i={},a={},{transformSelectorFirstArgument:r=h=>h,transformActionFirstArgument:n=h=>h,createTransactionalMetadata:o,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=s,u=typeof o=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(o())}:{}},m=0,d=(h,g)=>!u||!c?h:Kn(h,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});for(let[h,g]of Object.entries(t))h!=="createInitialState"&&(h.startsWith("select")?i[h]=(...y)=>g(r(p.state,p.transactionalMetadata),...y):a[h]=(...y)=>{let b,w=p,A=Kn(p,k=>{let P=g(n(k.state,k.transactionalMetadata),...y);b=P!==void 0&&!Ie(P)?P:void 0,u&&l&&l({actionName:h,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:w.state,previousTransactionalMetadata:w.transactionalMetadata})});return m===0&&(A=d(A,w)),p=A,b});let f=h=>{if(typeof h!="function")throw new Error("Store transaction requires a callback");let g=p,y=m===0;m+=1;let b;try{b=h()}catch(w){throw m-=1,p=g,w}if(m-=1,y)try{p=d(p,g)}catch(w){throw p=g,w}return b};return{...i,...a,[ko]:f}},ts=(e,t)=>s=>{let i=e(),a=Array.isArray(s)?s:[s];return Kn(i,r=>{a.forEach(n=>{t.forEach(o=>{o(r,n)})})})};var hh=(e,t)=>{if(e.default!==void 0)return e.default;let s=["number","boolean","string","object"];if(!s.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${s.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},ee=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),bo=(e,t,s)=>{Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0})},xe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),gh=new Set(["pageSize","groups"]),bh=new Set(["id","variants"]),wh=new Set(["id","imageId"]),Ih=new Set(["pageSize","tracks"]),vh=new Set(["id","soundId","title","artist","album","description","coverImageId"]),kh=new Set(["pageSize","replays"]),Ah=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),tt=(e,t,s)=>{Object.keys(e).forEach(i=>{if(!t.has(i))throw new Error(`${s} contains unsupported property "${i}"`)})},At=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Qt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!xe(t))throw new Error("resources.imageGallery must be an object");if(tt(t,gh,"resources.imageGallery"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.groups))throw new Error("resources.imageGallery.groups must be an array");let s=new Set;for(let[i,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${i}]`;if(!xe(a))throw new Error(`${r} must be an object`);if(tt(a,bh,r),At(a.id,`${r}.id`),s.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(s.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let n=new Set;for(let[o,l]of a.variants.entries()){let c=`${r}.variants[${o}]`;if(!xe(l))throw new Error(`${c} must be an object`);if(tt(l,wh,c),At(l.id,`${c}.id`),At(l.imageId,`${c}.imageId`),n.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(n.add(l.id),!ee(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},Zt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!xe(t))throw new Error("resources.musicRoom must be an object");if(tt(t,Ih,"resources.musicRoom"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.tracks))throw new Error("resources.musicRoom.tracks must be an array");let s=new Set;for(let[i,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${i}]`;if(!xe(a))throw new Error(`${r} must be an object`);tt(a,vh,r);for(let l of["id","soundId","title"])At(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&At(a[l],`${r}.${l}`);if(s.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);s.add(a.id);let n=L(e?.resources?.sounds,a.soundId);if(!ee(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!xe(n))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(n.playbackRate!==void 0&&(typeof n.playbackRate!="number"||!Number.isFinite(n.playbackRate)||n.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let o=n.startAt??0;if(typeof o!="number"||!Number.isFinite(o)||o<0)throw new Error(`Music room sound "${a.soundId}" startAt must be a finite non-negative number`);if(n.endAt!==void 0&&n.endAt!==null&&(typeof n.endAt!="number"||!Number.isFinite(n.endAt)||n.endAt<=o))throw new Error(`Music room sound "${a.soundId}" endAt must be a finite number greater than startAt`);if(a.coverImageId!==void 0&&!ee(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Ph=(e,t,s)=>{let i=Array.isArray(s)?"array":typeof s;switch(t.type){case"number":if(typeof s!="number"||!Number.isFinite(s))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${i}`);return;case"boolean":if(typeof s!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${i}`);return;case"string":if(typeof s!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${i}`);return;case"object":if(s===null||typeof s!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${i}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},en=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!xe(t))throw new Error("resources.sceneReplay must be an object");if(tt(t,kh,"resources.sceneReplay"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.replays))throw new Error("resources.sceneReplay.replays must be an array");let s=e?.story?.scenes??{},i=new Set;for(let[a,r]of t.replays.entries()){let n=`resources.sceneReplay.replays[${a}]`;if(!xe(r))throw new Error(`${n} must be an object`);tt(r,Ah,n);for(let u of["sceneId","title","thumbnailImageId"])At(r[u],`${n}.${u}`);if(i.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(i.add(r.sceneId),!ee(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let o=L(s,r.sceneId);if(!o)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=o.initialSectionId,c=L(o.sections,l);if(!c)throw new Error(`Scene replay scene "${r.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${r.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(r.initialVariables!==void 0){if(!xe(r.initialVariables))throw new Error(`${n}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let m=L(e?.resources?.variables,u);if(!m)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(Ne(m))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);Ph(u,m,p)}}}},yc=e=>{let t=Ie(e)?Ge(e):e;return structuredClone(t)},xh=({characterId:e,resourceCharacter:t,variables:s={}}={})=>{if(!ee(t,"nameVariableId"))return;let i=t.nameVariableId,a=s?.[i];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${i}" must resolve to a string variable`);return a},ns=({characterId:e,character:t,characterName:s,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0;if(t?.name!==void 0)return t.name;if(s!==void 0)return s;let n=xh({characterId:e,resourceCharacter:r,variables:a});return n!==void 0?n:r?.name||""},Ne=e=>ee(e,"computed"),Ao=(e,t)=>{switch(e?.type){case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);default:return!1}},rn=(e={},t={},{allowedScopes:s,preserveUnknown:i=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let n=t[a];return n===void 0?i:!Ne(n)&&(!s||s.includes(n.scope))&&Ao(n,r)})),Ke=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),Eh=(e,t,s)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ke(t,s)}let a="";for(let r=1;r<e.length-1;r+=1){let n=e[r];if(n!=="\\"){if(n.charCodeAt(0)<32)throw Ke(t,s);a+=n;continue}if(r+=1,r>=e.length-1)throw Ke(t,s);let o=e[r];if(o==="u"){let c=e.slice(r+1,r+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Ke(t,s);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
+
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!ee(l,o))throw Ke(t,s);a+=l[o]}return a},hc=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ke(e,t);let s=[],i=0,a=()=>{let n=i;for(;i<e.length&&e[i]!=="."&&e[i]!=="["&&e[i]!=="]";)i+=1;let o=e.slice(n,i);if(o.length===0||o.trim()!==o||/\s/.test(o))throw Ke(e,t);s.push(o)},r=()=>{for(i+=1;i<e.length&&/\s/.test(e[i]);)i+=1;let n=e[i];if(/\d/.test(n??"")){let u=i;for(;i<e.length&&/\d/.test(e[i]);)i+=1;let p=e.slice(u,i);for(;i<e.length&&/\s/.test(e[i]);)i+=1;if(e[i]!=="]"||p.length>1&&p.startsWith("0"))throw Ke(e,t);i+=1,s.push(p);return}if(n!=='"'&&n!=="'")throw Ke(e,t);let o=n,l=i;i+=1;let c=!1;for(;i<e.length;){let u=e[i];if(c)c=!1;else if(u==="\\")c=!0;else if(u===o){let p=e.slice(l,i+1);for(i+=1;i<e.length&&/\s/.test(e[i]);)i+=1;if(e[i]!=="]")throw Ke(e,t);i+=1,s.push(Eh(p,e,t));return}i+=1}if(c||i>=e.length)throw Ke(e,t)};for(a();i<e.length;){if(e[i]==="."){i+=1,a();continue}if(e[i]==="["){r();continue}throw Ke(e,t)}return s},mo=(e,t)=>{let s=e;for(let i of t){if(s==null||!ee(s,i))return;s=s[i]}return s},gc=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let s=hc(e),[i,a,...r]=s;if(i==="variables"){if(!a)return t.variables;let n=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return mo(n,r)}return i==="runtime"?mo(t.runtime,s.slice(1)):mo(t,s)},bc=(e,t,s)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(s!==void 0&&t.length!==s)throw new Error(`Computed expression operator "${e}" requires ${s} operand(s)`)},wo=(e,t)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(t.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},Sh=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},rr=(e,t,s,i)=>(bc(e,t,i),t.map(a=>rs(a,s))),He=(e,t,s,i)=>{let a=rr(e,t,s,i);return a.forEach(r=>Sh(e,r)),a},Oh=(e,t,s)=>{switch(e){case"var":return gc(t,s);case"add":{let[i,a]=He(e,t,s,2);return i+a}case"sub":{let[i,a]=He(e,t,s,2);return i-a}case"mul":{let[i,a]=He(e,t,s,2);return i*a}case"div":{let[i,a]=He(e,t,s,2);return a===0?0:i/a}case"mod":{let[i,a]=He(e,t,s,2);return a===0?0:i%a}case"neg":{let[i]=He(e,t,s,1);return-i}case"round":{let[i]=He(e,t,s,1);return Math.round(i)}case"floor":{let[i]=He(e,t,s,1);return Math.floor(i)}case"ceil":{let[i]=He(e,t,s,1);return Math.ceil(i)}case"min":{let[i,a]=He(e,t,s,2);return Math.min(i,a)}case"max":{let[i,a]=He(e,t,s,2);return Math.max(i,a)}case"clamp":{let[i,a,r]=He(e,t,s,3);return Math.min(r,Math.max(a,i))}case"eq":{let[i,a]=rr(e,t,s,2);return Dr.eq(i,a)}case"neq":{let[i,a]=rr(e,t,s,2);return Dr.neq(i,a)}case"gt":{let[i,a]=rr(e,t,s,2);return Dr.gt(i,a)}case"gte":{let[i,a]=rr(e,t,s,2);return Dr.gte(i,a)}case"lt":{let[i,a]=rr(e,t,s,2);return Dr.lt(i,a)}case"lte":{let[i,a]=rr(e,t,s,2);return Dr.lte(i,a)}case"in":{let[i,a]=rr(e,t,s,2);return Array.isArray(a)?a.includes(i):!1}case"and":case"all":return wo(e,t),t.every(i=>!!rs(i,s));case"or":case"any":return wo(e,t),t.some(i=>!!rs(i,s));case"not":{let[i]=rr(e,t,s,1);return!i}case"length":{let[i]=rr(e,t,s,1);return typeof i=="string"||Array.isArray(i)?i.length:xe(i)?Object.keys(i).length:0}case"includes":{let[i,a]=rr(e,t,s,2);return typeof i=="string"?typeof a=="string"&&i.includes(a):Array.isArray(i)?i.includes(a):!1}case"literal":return yc(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},rs=(e,t={})=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let s=Object.entries(e);if(s.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[i,a]]=s;return Oh(i,a,t)},Io=(e,t)=>{if(e===null||typeof e!="object"||ee(e,"literal"))return e;if(ee(e,"var"))return{literal:gc(e.var,t)};if(ee(e,"call"))throw new Error("Function calls are not supported in computed-variable conditions");return Object.fromEntries(Object.entries(e).map(([s,i])=>[s,Array.isArray(i)?i.map(a=>Io(a,t)):Io(i,t)]))},Rh=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Jt(Io(e,t))},wc=(e,t)=>{if(!xe(e))throw new Error(`${t} must be an object`);let s=ee(e,"expr"),i=ee(e,"value");if(s===i)throw new Error(`${t} must contain exactly one of expr or value`)},yo=(e,t,s)=>(wc(e,t),ee(e,"value")?yc(e.value):rs(e.expr,s)),$h=(e,t={},s="unknown")=>{if(!xe(e))throw new Error(`Computed variable "${s}" computed must be an object`);let i=ee(e,"expr"),a=ee(e,"value");if(ee(e,"branches")){if(i||a)throw new Error(`Computed variable "${s}" cannot combine branches with expr or value`);if(!Array.isArray(e.branches))throw new Error(`Computed variable "${s}" branches must be an array`);if(e.branches.length===0)throw new Error(`Computed variable "${s}" branches must not be empty`);if(!xe(e.default))throw new Error(`Computed variable "${s}" requires default`);for(let n=0;n<e.branches.length;n+=1){let o=e.branches[n];if(!xe(o))throw new Error(`Computed variable "${s}" branch ${n} must be an object`);if(!ee(o,"when"))throw new Error(`Computed variable "${s}" branch ${n} requires when`);if(Rh(o.when,t))return yo(o,`Computed variable "${s}" branch ${n}`,t)}return yo(e.default,`Computed variable "${s}" default`,t)}if(i===a)throw new Error(`Computed variable "${s}" must contain exactly one of expr, value, or branches`);return yo(e,`Computed variable "${s}"`,t)},Ic=(e,t,s)=>{switch(t){case"number":if(typeof s!="number"||!Number.isFinite(s))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(s)?"array":typeof s}`);return;case"boolean":if(typeof s!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(s)?"array":typeof s}`);return;case"string":if(typeof s!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(s)?"array":typeof s}`);return;case"object":if(s===null||typeof s!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof s}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},Ch=Object.freeze({add:2,sub:2,mul:2,div:2,mod:2,neg:1,round:1,floor:1,ceil:1,min:2,max:2,clamp:3,eq:2,neq:2,gt:2,gte:2,lt:2,lte:2,in:2,not:1,length:1,includes:2}),_h=new Set(["and","or","all","any"]),Nh=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),jh=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Th=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Dh=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),vc=new WeakMap,ac=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Zn=(e,t,s)=>{for(let i of Object.keys(e))if(!t.has(i))throw new Error(`${s} contains unsupported property "${i}"`)},Lh=(e,t,s,i)=>{if(s!==void 0&&s!==t)throw new Error(`Computed variable "${e}" ${i} expected type ${t}, got ${s}`)},kc=(e,{variableId:t,variableConfigs:s,dependencies:i,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[n,o,...l]=hc(e,r);if(n!=="variables"&&n!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!o)throw new Error(`${r} must reference a concrete ${n} member, got ${JSON.stringify(e)}`);if(n==="runtime")return;if(!ee(s,o))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${o}"`);let c=s[o];return Ne(c)&&i.add(o),l.length===0?c?.type:void 0},Ac=(e,{variableId:t,variableConfigs:s,dependencies:i,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return ac(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let r=Object.entries(e);if(r.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[n,o]]=r;if(n==="var"){if(typeof o!="string"||o.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return kc(o,{variableId:t,variableConfigs:s,dependencies:i,path:a})}if(n==="literal"){if(typeof o=="number"&&!Number.isFinite(o))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return ac(o)}let l=Ch[n];if(l===void 0&&!_h.has(n))throw new Error(`Unknown computed expression operator: ${n}`);l===void 0?wo(n,o):bc(n,o,l);let c=o.map((u,p)=>Ac(u,{variableId:t,variableConfigs:s,dependencies:i,path:`${a}.${n}[${p}]`}));if(jh.has(n)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${n}" requires numeric operands`)}),Nh.has(n))return"number";if(Th.has(n))return"boolean"},Mh=(e,{variableId:t,variableConfigs:s,dependencies:i,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Me(e)}catch(n){throw new Error(`Computed variable "${t}" ${a} is invalid: ${n.message}`,{cause:n})}let r=(n,o)=>{if(n===null||typeof n!="object"||ee(n,"literal"))return;if(ee(n,"var")){kc(n.var,{variableId:t,variableConfigs:s,dependencies:i,path:o});return}if(ee(n,"call"))throw new Error(`Computed variable "${t}" ${o} function calls are not supported`);if(ee(n,"not")){r(n.not,`${o}.not`);return}let l=Object.keys(n).find(c=>Dh.has(c));n[l].forEach((c,u)=>{r(c,`${o}.${l}[${u}]`)})};r(e,a)},ho=(e,{variableId:t,variableConfig:s,variableConfigs:i,dependencies:a,path:r,allowedKeys:n=new Set(["expr","value"])})=>{if(wc(e,`Computed variable "${t}" ${r}`),Zn(e,n,r),ee(e,"value")){Ic(t,s.type,e.value);return}let o=Ac(e.expr,{variableId:t,variableConfigs:i,dependencies:a,path:`${r}.expr`});Lh(t,s.type,o,`${r}.expr`)},Vh=(e,t,s)=>{let i=t.computed;if(!xe(i))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=ee(i,"expr"),n=ee(i,"value");if(ee(i,"branches")){if(Zn(i,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||n)throw new Error(`Computed variable "${e}" cannot combine branches with expr or value`);if(!Array.isArray(i.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(i.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!xe(i.default))throw new Error(`Computed variable "${e}" requires default`);return i.branches.forEach((l,c)=>{if(!xe(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Zn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!ee(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);Mh(l.when,{variableId:e,variableConfigs:s,dependencies:a,path:`computed.branches[${c}].when`}),ho(l,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),ho(i.default,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:"computed.default"}),a}if(Zn(i,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===n)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return ho(i,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:"computed"}),a},nt=(e={})=>{if(!xe(e))throw new Error("Variable configs must be an object");if(ee(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(ee(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,n])=>{if(Ne(n)){if(!xe(n))throw new Error(`Computed variable "${r}" must be an object`);if(!ee(n,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!ee(n,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(ee(n,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(tn(n.scope,r),!["number","boolean","string","object"].includes(n.type))throw new Error(`Invalid variable type: ${n.type} for computed variable ${r}`);t.set(r,Vh(r,n,e))}});let s=new Set,i=[];t.forEach((r,n)=>{if(s.has(n))return;let o=[{variableId:n,dependencies:[...t.get(n)??[]],nextDependencyIndex:0}],l=new Map([[n,0]]);for(;o.length>0;){let c=o.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){o.pop(),l.delete(c.variableId),s.add(c.variableId),i.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,s.has(u))continue;let p=l.get(u);if(p!==void 0){let m=[...o.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,o.length),o.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(i)});return vc.set(e,a),a},Pt=({variables:e={},runtime:t={},variableConfigs:s={},eager:i=!0}={})=>{let{evaluationOrder:a}=vc.get(s)??nt(s),r=rn(e,s,{preserveUnknown:!0}),n=Object.entries(s).filter(([,g])=>Ne(g)).map(([g])=>g),o=Object.create(null),l=[],c=new Map(a.map((g,y)=>[g,y])),u=-1,p=!1,m=g=>{if(ee(o,g))return o[g];let y=s[g];if(!Ne(y))return ee(r,g)?r[g]:void 0;let b=l.indexOf(g);if(b>=0){let w=[...l.slice(b),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${w}`)}l.push(g);try{let w=$h(y.computed,h,g);return Ic(g,y.type,w),bo(o,g,w),w}finally{l.pop()}},d=g=>{if(ee(o,g))return o[g];let y=s[g];if(!Ne(y))return ee(r,g)?r[g]:void 0;let b=c.get(g);if(i&&!p&&b!==void 0&&b>u){p=!0;try{for(let w=u+1;w<=b;w+=1)m(a[w]),u=w}finally{p=!1}return o[g]}return m(g)},f=new Proxy({},{get:(g,y)=>{if(typeof y=="string")return d(y)},has:(g,y)=>typeof y=="string"&&(ee(r,y)||n.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...n])],getOwnPropertyDescriptor:(g,y)=>{if(!(typeof y!="string"||!ee(r,y)&&!n.includes(y)))return{enumerable:!0,configurable:!0}}}),h={variables:f,runtime:t,resolveVariable:d};return i?(n.forEach(g=>{d(g)}),{...r,...o}):f},qh=({variables:e={},runtime:t={},variableConfigs:s,projectData:i}={})=>{let a=s??i?.resources?.variables??{};return nt(a),Pt({variables:e,runtime:t,variableConfigs:a,eager:!0})},ss=e=>{let t={},s={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([i,a])=>{if(Ne(a))return;let r=hh(a,i);a.scope==="context"?bo(t,i,r):bo(s,i,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:s}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:s}},tn=(e,t)=>{let s=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!s.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${s.join(", ")}`)},nn=(e,t,s)=>{let i={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=i[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${s}`);if(!Object.values(i).flat().includes(t))throw new Error(`Unknown operation: ${t}`);if(!a.includes(t))throw new Error(`Operation "${t}" is not valid for variable "${s}" of type "${e}". Valid operations: ${a.join(", ")}`)},Fh=2,lc=12,Pc=(e=Fh)=>{if(!Number.isInteger(e)||e<0||e>lc)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${lc}.`);return e},Bh=(e,t)=>{let s=10**t;return Math.round((e+Number.EPSILON)*s)/s},es=e=>typeof e=="number"&&Number.isFinite(e),is=(e,t,s,i,a={})=>{if(e==="number"){if(t==="set"&&!es(s))throw new Error(`Operation "set" requires value to be a number for variable "${i}".`);if(t==="multiply"&&!es(s))throw new Error(`Operation "multiply" requires value to be a number for variable "${i}".`);if(t==="divide"&&!es(s))throw new Error(`Operation "divide" requires value to be a number for variable "${i}".`);if(t==="divide"){if(s===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${i}".`);Pc(a.roundTo)}}},os=(e,t,s,i={})=>{let a=(n,o,l)=>{let c=n??o;if(!es(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=n=>{let o=a(n,void 0,"value");if(o===0)throw new Error(`Operation "${t}" requires value to be a non-zero number.`);return o};switch(t){case"set":return s;case"multiply":return a(e,1,"current value")*a(s,void 0,"value");case"divide":return Bh(a(e,0,"current value")/r(s),Pc(i.roundTo));case"increment":return a(e,0,"current value")+a(s,1,"value");case"decrement":return a(e,0,"current value")-a(s,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var Po=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let s=new Date(e),i=n=>String(n).padStart(2,"0"),a=String(s.getFullYear()),r={DD:i(s.getDate()),MM:i(s.getMonth()+1),MMM:yh[s.getMonth()],YYYY:a,YY:a.slice(-2),HH:i(s.getHours()),mm:i(s.getMinutes()),ss:i(s.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,n=>r[n])},Uh=(e,t)=>{let s=r=>r?.ui,i=s(e),a=s(t);return JSON.stringify(i)===JSON.stringify(a)?null:i&&!a?{changeType:"delete",data:e}:a&&!i?{changeType:"add",data:t}:a&&i?{changeType:"update",data:t}:null},Wt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Yh=(e,t)=>{let s=e?.character?.sprite,i=t?.character?.sprite,a=Wt(s)?s:void 0,r=Wt(i)?i:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},cc=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let s of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[s]!==void 0&&(t[s]=e[s]);for(let s of["animationName","animationSpeed","loop"])e[s]!==void 0&&(t[s]=e[s]);return t},uc=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},pc=(e,t)=>t&&!e?{changeType:"add",data:t}:e&&!t?{changeType:"delete",data:e}:e&&t&&JSON.stringify(e)!==JSON.stringify(t)?{changeType:"update",data:t}:null,zh=(e,t)=>{let s={},i=pc(cc(e),cc(t)),a=pc(uc(e),uc(t));return i&&(s.resource=i),a&&(s.color=a),Object.keys(s).length>0?s:null},xo=(e={},t={})=>{let s={},i=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)s[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(m=>m.applyMode==="persistent");!i.includes(l)&&(l!=="sfx"||p)&&(s[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(s[l]={changeType:"update",data:u})},r=zh(e.background,t.background);r&&(s.background=r),a("screen"),a("bgm"),a("voice");let n=Uh(e.dialogue,t.dialogue);n&&(s.dialogue=n);let o=Yh(e.dialogue,t.dialogue);return o&&(s.dialogueSprite=o),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),s},Eo=(e={})=>{let t=structuredClone(e);if(t.sfx){let a=Array.isArray(t.sfx.channels)?t.sfx.channels.filter(r=>r.applyMode==="persistent"):[];a.length>0?t.sfx={channels:a}:delete t.sfx}t.background&&(t.background.animations?.playback?.continuity!=="persistent"&&delete t.background.animations,!t.background.resourceId&&!t.background.colorId&&delete t.background);let s=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};s("layout"),s("choice"),s("form"),s("screen"),t.dialogue?.ui&&(delete t.dialogue.ui.animations,Object.keys(t.dialogue.ui).length===0&&delete t.dialogue.ui,Object.keys(t.dialogue).length===0&&delete t.dialogue),t.dialogue?.character?.sprite&&(delete t.dialogue.character.sprite.animations,Object.keys(t.dialogue.character.sprite).length===0&&delete t.dialogue.character.sprite,Object.keys(t.dialogue.character).length===0&&delete t.dialogue.character,Object.keys(t.dialogue).length===0&&delete t.dialogue);let i=(a,r)=>{let n=t[a]?.items;Array.isArray(n)&&(t[a].items=n.map(o=>{let l={...o};return l.animations?.playback?.continuity!=="persistent"&&delete l.animations,r(l)?l:null}).filter(Boolean),t[a].items.length===0&&delete t[a])};return i("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),i("visual",a=>a.resourceId||a.text||a.layout||a.transformId||a.transform),t},Xh=(e,t)=>{if(!e||!t)return;let s=e;for(let i of t.split(".")){if(s==null||i==="__proto__"||i==="prototype"||i==="constructor"||!Object.prototype.hasOwnProperty.call(Object(s),i))return;s=s[i]}return s},fc=e=>e!==null&&typeof e=="object"?structuredClone(e):e,Gh=(e,t,s)=>{if(typeof e!="string")return e;let i=Object.prototype.hasOwnProperty.call(t??{},s)?t[s]:void 0;if(e===s){if(i==null)throw new Error(`Action template binding "${s}" requires event context "${s}".`);return fc(i)}if(!e.startsWith(`${s}.`))return e;if(i==null)throw new Error(`Action template binding "${e}" requires event context "${s}".`);let a=e.slice(s.length+1),r=Xh(i,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${s}".`);return fc(r)},Hh={conditional:new Set(["branches"]),updateProjectData:new Set(["projectData"]),showConfirmDialog:new Set(["confirmActions","cancelActions"]),form:new Set(["submitActions","cancelActions"]),submitForm:new Set(["actions"]),cancelForm:new Set(["actions"])},Kh=(e,t)=>{let s=e[e.length-1];return s?Hh[s]?.has(t)===!0:!1},vo=(e,t,s=[])=>Array.isArray(e)?e.map(i=>vo(i,t,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,Kh(s,i)?a:vo(a,t,[...s,i])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Gh(e,t,"_event"):rt(e,t):e,xt=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return vo(e,t)};var Wh=11102230246251565e-32,xc=128,Ec=1e3,Sc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),sn=(e,t,s)=>{let i=Object.keys(e).find(a=>!t.has(a));if(i!==void 0)throw new Error(`${s}.${i} is not supported`)},as=(e,t)=>{if(!Sc(e))throw new Error(`${t} must be an object`)},ls=(e,t,{min:s,max:i}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(s!==void 0&&e<s)throw new Error(`${t} must be at least ${s}`);if(i!==void 0&&e>i)throw new Error(`${t} must be at most ${i}`);return e},Jh=(e,t,{min:s,max:i}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(s!==void 0&&e<s)throw new Error(`${t} must be at least ${s}`);if(i!==void 0&&e>i)throw new Error(`${t} must be at most ${i}`);return e},So=e=>{let t=structuredClone(e),s=i=>(i&&typeof i=="object"&&!Object.isFrozen(i)&&(Object.values(i).forEach(s),Object.freeze(i)),i);return s(t)},Qh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),Oc=e=>{let t=e??Qh();if(!Sc(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let s=t.nextUint32();if(!Number.isInteger(s)||s<0||s>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return s}}},Zh=(e,t)=>{let s=4294967296-4294967296%t;for(let i=0;i<xc;i+=1){let a=e.nextUint32();if(a<s)return a%t}throw new Error(`random source exhausted after ${xc} rejected samples`)},eg=e=>{let t=e.nextUint32()>>>5,s=e.nextUint32()>>>6;return(t*67108864+s)/9007199254740992},rg=(e,t)=>{if(sn(e,new Set(["type","min","max"]),"random.distribution"),!Object.prototype.hasOwnProperty.call(e,"min"))throw new Error("random.distribution.min is required");if(!Object.prototype.hasOwnProperty.call(e,"max"))throw new Error("random.distribution.max is required");let s=ls(e.min,"random.distribution.min"),a=ls(e.max,"random.distribution.max")-s+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return So({type:"integer",value:a===1?s:s+Zh(t,a)})},tg=(e,t)=>{if(sn(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>Ec)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let s=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(as(c,p),sn(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return as(c.actions,`${p}.actions`),{weight:Jh(c.weight,`${p}.weight`,{min:0})}}),i=Math.max(...s.map(({weight:c})=>c));if(i<=0)throw new Error("random weighted total weight must be positive");let a=s.map(c=>({...c,weight:c.weight/i})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(s[u].weight>0&&(c.weight===0||c.weight/r<=Wh))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let n=eg(t)*r,o=0,l=a.findLastIndex(({weight:c})=>c>0);for(let c=0;c<a.length;c+=1){let u=a[c];if(o+=u.weight,n<o){l=c;break}}return So({type:"weighted",outcomeIndex:l})},Rc=(e,{randomSource:t})=>{as(e,"random.distribution");let i={integer:rg,weighted:tg}[e.type];if(!i)throw new Error('random.distribution.type must be "integer" or "weighted"');return i(e,t)},cs=(e,t)=>{if(as(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")sn(e,new Set(["type","value"]),"random result"),ls(e.value,"random result.value");else if(t==="weighted")sn(e,new Set(["type","outcomeIndex"]),"random result"),ls(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:Ec-1});else throw new Error(`unsupported recorded random result type: ${t}`);return So(e)};var st=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),_c=Object.freeze([st("cleanup",["clearPendingEffects","cleanAll"]),st("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),st("decision",["submitForm","cancelForm","random:weighted","conditional"]),st("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),st("runtime",["setNextLineConfig","startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","showDialogueUI","hideDialogueUI","toggleDialogueUI","setDialogueTextSpeed","setAutoForwardDelay","setAutoForwardSpeed","setSkipUnseenText","setSkipTransitionsAndAnimations","setSoundVolume","setMusicVolume","setMuteAll","setSaveLoadPagination","incrementSaveLoadPagination","decrementSaveLoadPagination","setMenuPage","setMenuEntryPoint","showConfirmDialog","hideConfirmDialog","pushOverlay","popOverlay","replaceLastOverlay","clearOverlays","completeAchievement","setAchievementProgress","showImageGalleryVariant","moveToPreviousImageGalleryVariant","moveToNextImageGalleryVariant","clearImageGallerySelection","moveToImageGalleryPage","moveToNextImageGalleryPage","moveToPreviousImageGalleryPage","playMusicRoomTrack","playMusicRoom","pauseMusicRoom","stopMusicRoom","seekMusicRoom","playPreviousMusicRoomTrack","playNextMusicRoomTrack","clearMusicRoomSelection","moveToMusicRoomPage","moveToNextMusicRoomPage","moveToPreviousMusicRoomPage","finishSceneReplay","moveToSceneReplayPage","moveToNextSceneReplayPage","moveToPreviousSceneReplayPage","musicRoomSoundReady","musicRoomSoundProgress","musicRoomSoundComplete","musicRoomSoundError","appendPendingEffect","beginRollbackActionBatch","endRollbackActionBatch","ensureRandomReplayOccurrence","recordRandomOutcome","markRollbackCheckpointTransient","markSavedRollbackCheckpointTransient","recordCurrentDialogueHistory"]),st("persistence",["saveSlot"]),st("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),Et=new Map;_c.forEach(e=>{e.actions.forEach(t=>{if(Et.has(t))throw new Error(`duplicate action execution key: ${t}`);Et.set(t,Et.size)})});var ng=new Set(_c.find(({name:e})=>e==="navigation").actions),$c=Et.get("saveSlot")-.5,Cc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",sg=(e,t)=>e<t?-1:e>t?1:0,us=e=>Object.entries(e).sort((t,s)=>{let i=Cc(...t),a=Cc(...s),r=Et.get(i),n=Et.get(a),o=r??$c,l=n??$c;return o!==l?o-l:r!==void 0&&n!==void 0?0:sg(i,a)}),ps=e=>ng.has(e),fs=e=>{let t=e.map(([s])=>s).filter(ps);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var ig=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),or=(...e)=>e.map(ig).join(":"),ds=e=>Array.isArray(e?.sounds)?e.sounds:e?.resourceId?[{id:e.resourceId,resourceId:e.resourceId,loop:e.loop??!0,volume:e.volume,startDelayMs:e.startDelayMs??0}]:[],Oo=e=>!Array.isArray(e?.sounds)&&e?.startDelayMs>0,on=(e,t)=>Oo(e)?or("bgm","legacy-delay",t.resourceId):or("bgm",t.id==="default"?t.resourceId:t.id),Nc=({bgm:e,resources:t,previousBgmRender:s})=>{let i=ds(e).filter(c=>L(t.sounds,c.resourceId)),a=ds(s?.bgm).filter(c=>L(s.resources?.sounds,c.resourceId)).map((c,u)=>({sound:c,renderId:s.channel?.children[u]?.id})).filter(({renderId:c})=>c!==void 0),r=new Map,n=new Set,o=(c,u)=>{!u||n.has(u.renderId)||(r.set(c.id,u.renderId),n.add(u.renderId))};return Oo(e)===Oo(s?.bgm)&&(i.forEach(c=>o(c,a.find(u=>u.sound.id===c.id))),i.forEach(c=>{r.has(c.id)||o(c,a.find(u=>u.sound.resourceId===c.resourceId&&on(s.bgm,u.sound)===on(e,c)))})),[...i].sort((c,u)=>+(c.id==="default")-+(u.id==="default")).forEach(c=>{if(r.has(c.id))return;let u=on(e,c);n.has(u)&&(u=or("bgm",c.id)),n.has(u)&&(u=or("bgm","clip",c.id));let p=0;for(;n.has(u);)u=or("bgm","clip",c.id,++p);r.set(c.id,u),n.add(u)}),r};var Lr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),an=Object.freeze({volume:100,pan:0,playbackRate:1}),ms=["volume","pan","playbackRate"],og=["src","startAt","endAt","startDelayMs"],jc=(e,t)=>{if(!e)return null;let s=e.children??[];if(s.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return s[0]},_o=(e,t)=>e?.id===t?.id&&og.every(s=>(e?.[s]??(s==="endAt"?null:0))===(t?.[s]??(s==="endAt"?null:0))),ag=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),$o=e=>Math.max(-1,Math.min(1,e)),Co=({bgm:e,resources:t,renderedSound:s,property:i})=>{let a=e?.sounds?.length===1?e.sounds[0]:e?.sounds?.find(n=>on(e,n)===s?.id),r=L(t.sounds,a?.resourceId);return a?.[i]??r?.[i]??an[i]},lg=({property:e,value:t,relative:s,bgm:i,resources:a,renderedSound:r})=>{if(!i||!r)return t;if(e==="volume"){let n=Co({bgm:i,resources:a,renderedSound:r,property:e});return t*n/100}if(e==="pan"&&!s){let n=Co({bgm:i,resources:a,renderedSound:r,property:e});return $o(t+n)}return t},cg=({authoredInitialValue:e,authoredKeyframes:t,baselineBgm:s,compiledKeyframes:i,bgm:a,resources:r,renderedSound:n})=>{if(!a||!n)return i;let o=Co({bgm:a,resources:r,renderedSound:n,property:"pan"}),l=e??s?.pan??an.pan;return i.map((c,u)=>{let p=t[u];if(p.relative!==!0)return l=p.value,c;let m=Lr(p,"startValue")?l+p.startValue:l,d=m+p.value,{relative:f,...h}=c;return l=d,{...h,...Lr(p,"startValue")?{startValue:$o(m+o)}:{},value:$o(d+o)}})},Tc=(e,t)=>{let s=e?.playback?.speed??1;if(typeof s!="number"||!Number.isFinite(s)||s<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return s},ug=(e,t)=>({...Lr(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Dc=({property:e,authored:t,speed:s,propertyPath:i,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${i}.keyframes] The final keyframe must use an absolute finite numeric value.`);let n={keyframes:t.keyframes.map(o=>{let l=ug(o,s),c=l.relative===!0;return l.value=a({property:e,value:l.value,relative:c}),Lr(l,"startValue")&&(l.startValue=a({property:e,value:l.startValue,relative:c})),l})};return Lr(t,"initialValue")&&(n.initialValue=a({property:e,value:t.initialValue,relative:!1})),n},pg=({authored:e,bgm:t,baselineBgm:s=t,property:i,propertyPath:a,renderedSound:r,resources:n,speed:o})=>{let l=Dc({property:i,authored:e,speed:o,propertyPath:a,normalizeValue:({value:c,relative:u})=>lg({property:i,value:c,relative:u,bgm:t,resources:n,renderedSound:r})});return i==="pan"&&(l.keyframes=cg({authoredInitialValue:e.initialValue,authoredKeyframes:e.keyframes,baselineBgm:s,compiledKeyframes:l.keyframes,bgm:t,resources:n,renderedSound:r})),l},fg=({actionPath:e,compiled:t,property:s,propertyPath:i,renderedSound:a})=>{let r=a[s]??an[s],n=t.keyframes.at(-1);if(!ag(n.value,r))throw new Error(`[${e}.audioEffects]
|
|
3
|
+
[${i}.keyframes] The final keyframe value must match the persistent BGM ${s} value.`);n.value=r},Lc=({selection:e,selectionPath:t,resources:s={}})=>{if(!e)return;let i=e.resourceId,a=`resources.audioEffects.${i}`,r=L(s.audioEffects,i);if(!r)throw new Error(`[${t}.resourceId]
|
|
4
4
|
[${a}] Unknown audio effect resource "${i}".`);if(r.type!=="update")throw new Error(`[${t}]
|
|
5
|
-
[${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let
|
|
6
|
-
[${p}] Unknown audio effect resource "${u}".`);let d=jc(l,`${c}.audioEffects`),f=Nc(a,c),h=Nc(r,c);if(!f&&!h)return null;if(f&&h&&f.id!==h.id)throw new Error(`[${c}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let g=f?.id??h.id,y={sound:f,bgm:s,resources:n},b={sound:h,bgm:o,resources:i},w={};if(m.type==="transition"){if(_o(f,h))return null;for(let A of ms){let k={},P=f?m.prev?.[A]:void 0;P&&(k.exit=Ro({phase:"exit",side:y,baselineBgm:s,authored:P,property:A,propertyPath:`${p}.prev.${A}`,actionPath:c,speed:d}));let I=h?m.next?.[A]:void 0;I&&(k.enter=Ro({phase:"enter",side:b,baselineBgm:o,authored:I,property:A,propertyPath:`${p}.next.${A}`,actionPath:c,speed:d})),Object.keys(k).length>0&&(w[A]=k)}}else if(m.type==="update"){let A=dg(f,h),k=A==="enter"?s??o:s;for(let P of ms){if(!Lr(m.tween,P))continue;let I=Ro({phase:A,side:A==="exit"?y:b,baselineBgm:k,authored:m.tween[P],property:P,propertyPath:`${p}.tween.${P}`,actionPath:c,speed:d});A==="update"&&(f[P]??an[P])===(h[P]??an[P])||(w[P]={[A]:I})}}else throw new Error(`[${p}.type] Unsupported audio effect type "${m.type}".`);return Object.keys(w).length===0?null:{...fg(e,g),properties:w}},Mc=e=>{let t=e.nextResources??e.resources,n=e.occurrence;if(!n?.selection)return[];let i=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=n.selection.resourceId,s=t?.audioEffects?.[r],o=(f,h)=>h?{...f,children:[h]}:null,l=(f,h,g,y)=>{if(!Array.isArray(f?.sounds))return f;let b=g?.children?.indexOf(y)??-1,w=f.sounds.filter(A=>L(h.sounds,A.resourceId))[b];return{...f,sounds:w?[w]:[]}},c=f=>f.map(({previousSound:h,nextSound:g},y)=>mg({...e,occurrence:y===0?n:{...n,occurrenceId:`${n.occurrenceId}:${y}`},resources:t,previousBgm:l(e.previousBgm,e.previousResources??t,e.previousChannel,h),nextBgm:l(e.nextBgm,t,e.nextChannel,g),previousChannel:o(e.previousChannel,h),nextChannel:o(e.nextChannel,g)})).filter(Boolean);if(!s||!["transition","update"].includes(s.type))return c([{previousSound:i[0],nextSound:a[0]}]);let u=new Map(i.map(f=>[f.id,f]));if(s.type==="update")return a.length===0?c(i.map(f=>({previousSound:f}))):c(a.map(f=>({previousSound:u.get(f.id),nextSound:f})));let p=new Map(a.map(f=>[f.id,f])),m=[];for(let f of i){let h=p.get(f.id);(!h||!_o(f,h))&&m.push({previousSound:f,nextSound:h})}for(let f of a)u.has(f.id)||m.push({nextSound:f});if(m.length>0)return c(m);let[d]=i;return c([{previousSound:d,nextSound:p.get(d?.id)}])};var ae=e=>structuredClone(Ie(e)?Ge(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ln=e=>e?.animations?.playback?.continuity==="persistent",G=(e,t)=>ie(e??{},t)&&e[t]!==void 0,ys=e=>G(e,"alpha")||G(e,"opacity"),yg=e=>G(e,"alpha")?e.alpha:e?.opacity,Xc=e=>(G(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),hg=e=>e?.applyMode==="persistent",gg="default",bg=e=>Array.isArray(e?.channels)?e.channels.filter(hg).map(ae):[],cn=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ae(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},wg=e=>ys(e)||G(e,"blur")||G(e,"filters"),jo=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Gc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],No=["animationName","animationSpeed","loop"],Ig=e=>G(e,"transformId")||G(e,"transform")||jo.some(t=>G(e,t)),To=e=>e?.text&&G(e.text,"content")&&G(e.text,"textStyleId"),Do=e=>e?.layout&&Array.isArray(e.layout.elements),vg=e=>G(e,"text")||G(e,"layout"),Vc=(e,t)=>e.resourceId?!0:To(e)?!t?.text:Do(e)?!t?.layout:!1,kg=e=>G(e,"resourceId")||To(e)||Do(e),qc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Ag=e=>G(e,"resourceId")||G(e,"sprites")&&Array.isArray(e.sprites)&&e.sprites.length>0,Pg=(e,t)=>{let n={...ae(e),...t};if(t.text&&e.text&&(n.text={...ae(e.text),...ae(t.text)}),t.transform&&e.transform&&(n.transform={...ae(e.transform),...ae(t.transform)}),G(t,"transform")){delete n.transformId;for(let i of jo)G(t,i)||delete n[i]}else G(t,"transformId")&&delete n.transform;return n},xg=(e,t)=>{let n=[e.resourceId,e.text,e.layout].filter(i=>i!==void 0).length;if(n>1)throw n===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(G(e,"text")&&!To(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(G(e,"layout")&&!Do(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Fc=e=>Gc.some(t=>G(e,t)),Bc=e=>No.some(t=>G(e,t)),Eg=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let i of Gc)!n&&!G(e,i)&&G(t,i)&&(e[i]=t[i]),ie(e,i)&&e[i]===void 0&&delete e[i];return e},Hc=(e,t,n)=>{let i=e[n];return i?.id===t?.id?i:e.find(a=>a.id===t?.id)},Sg=(e,t)=>{if(!t)return e;let n=G(e,"transform");for(let i of jo)!n&&!G(e,i)&&G(t,i)&&(e[i]=t[i]),ie(e,i)&&e[i]===void 0&&delete e[i];return e},Og=(e,t)=>(t&&(!G(e,"opacity")&&G(t,"opacity")&&(e.opacity=t.opacity),!G(e,"blur")&&G(t,"blur")&&(e.blur=ae(t.blur)),!G(e,"filters")&&G(t,"filters")&&(e.filters=ae(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Kc=(e,t,n=[],{hasPatchFn:i=()=>!1,hasSubjectFn:a=(s,o)=>t(s,o),mergeItemFn:r}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let s=e.map((o,l)=>{let c=Hc(n,o,l),u=a(o,c),p=wg(o),m=Ig(o),d=i(o),f=ie(o,"animations"),h=Xc(ae(o));if(!u&&(p||m||d)&&c&&(h=r?r(c,h):{...ae(c),...h}),!f){let g=c?t(c):!1,y=t(h);!u&&g&&y&&ln(c)?h.animations=ae(c.animations):delete h.animations}return u?h:Og(Sg(h,c),c)}).filter(o=>t(o)||o.animations);return{hasValidItems:s.length>0,processedItems:s}},Rg=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},Wc=e=>!!e?.character&&ie(e.character,"sprite"),$g=e=>{let t={},n=!1,i=Rg(e);return i!==void 0&&(t.name=i,n=!0),Wc(e)&&(t.sprite=ae(e.character.sprite),n=!0),n?t:void 0},Uc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Yc=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:n&&!ie(t,"characterId"),zc=({previousCharacter:e,characterFields:t,hasCharacterId:n,persistCharacter:i,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:s})=>{let o={},l=e??{},c=t??{},u=s&&!n,p=u&&!r;return ie(c,"name")?o.name=c.name:(i&&!n||u)&&ie(l,"name")&&(o.name=ae(l.name)),ie(c,"sprite")?o.sprite=ae(c.sprite):(a||p)&&ie(l,"sprite")&&(o.sprite=ae(l.sprite)),Object.keys(o).length>0?o:void 0},Cg=({dialogueState:e,content:t,append:n=!1})=>{if(!n||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let i=Array.isArray(e.content)?e.content:[];i.length>0?e.initialRevealedContent=i.map(a=>ae(a)):delete e.initialRevealedContent,e.content=[...i,...t]},_g=()=>({}),Ng=(e,t)=>{if(!t.screen)return;let n=ys(t.screen),i=G(t.screen,"blur"),a=ie(t.screen,"animations");if(!n&&!i){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=yg(t.screen):G(r,"opacity")&&(s.opacity=r.opacity),i?s.blur=ae(t.screen.blur):G(r,"blur")&&(s.blur=ae(r.blur)),ie(s,"opacity")&&s.opacity===void 0&&delete s.opacity,ie(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},jg=(e,t)=>{if(t.background){let n=G(t.background,"resourceId"),i=G(t.background,"colorId"),a=ys(t.background),r=G(t.background,"blur"),s=G(t.background,"filters"),o=G(t.background,"transformId"),l=Fc(t.background),c=Bc(t.background),{animationsOnly:u,state:p}=cn(t.background,f=>G(f,"resourceId")||G(f,"colorId")||ys(f)||G(f,"blur")||G(f,"filters")||G(f,"transformId")||Fc(f)||Bc(f));if(u){e.background=e.background?{...ae(e.background),...p}:p;return}if(!n&&!i&&!a&&!r&&!s&&!o&&!l&&!c){delete e.background;return}let m=e.background,d=Xc(ae(t.background));if(!n&&m?.resourceId){d.resourceId=m.resourceId,!ie(d,"transformId")&&m.transformId&&(d.transformId=m.transformId);for(let f of No)!G(d,f)&&G(m,f)&&(d[f]=m[f])}n||Eg(d,m,{hasAuthoredTransformId:o}),!n&&!i&&m?.colorId&&(d.colorId=m.colorId),!n&&!a&&G(m,"opacity")&&(d.opacity=m.opacity),!n&&!r&&G(m,"blur")&&(d.blur=ae(m.blur)),!n&&!s&&G(m,"filters")&&(d.filters=ae(m.filters)),ie(d,"resourceId")&&d.resourceId===void 0&&delete d.resourceId,ie(d,"colorId")&&d.colorId===void 0&&delete d.colorId,ie(d,"animations")&&d.animations===void 0&&delete d.animations,ie(d,"transformId")&&d.transformId===void 0&&delete d.transformId,ie(d,"opacity")&&d.opacity===void 0&&delete d.opacity,ie(d,"blur")&&d.blur===void 0&&delete d.blur,ie(d,"filters")&&d.filters===void 0&&delete d.filters;for(let f of No)ie(d,f)&&d[f]===void 0&&delete d[f];if(!d.resourceId&&!d.colorId){delete e.background;return}!n&&m?.resourceId===d.resourceId&&m?.transformId===d.transformId&&!ie(d,"animations")&&ln(m)&&(d.animations=ae(m.animations)),e.background=d}else e.background?.animations&&!ln(e.background)&&(e.background.animations={})},Tg=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(Uc(e.dialogue),e.dialogue.mode==="adv")){e.dialogue.content=void 0,delete e.dialogue.initialRevealedContent,delete e.dialogue.textSpeed;let u=e.dialogue.persistCharacter===!0,p=Yc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=zc({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=cn(t.dialogue.ui,m=>!!m.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...t.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});t.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),t.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let i=t.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&Cg({dialogueState:e.dialogue,content:t.dialogue.content,append:i}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=Yc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=ie(t.dialogue,"characterId"),o=$g(t.dialogue),l=Wc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!i&&delete e.dialogue.characterId;let c=zc({previousCharacter:e.dialogue.character,characterFields:o,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:i});if(c?e.dialogue.character=c:delete e.dialogue.character,l||Uc(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ae(e.dialogue.character)),e.dialogue.lines.push(u)}},Dg=(e,t)=>{let n=bg(e.sfx);if(!t.sfx){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=n.filter(s=>s.id!==gg);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ae(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(t.sfx.channels.length===0){delete e.sfx;return}let i=new Set(t.sfx.channels.map(r=>r.id)),a=n.filter(r=>!i.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ae(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},Lg=(e,t,n)=>{if(t.bgm){let i=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!i||i&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=Lc({bgm:ae(t.bgm),resources:n}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},Mg=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{xg(r,Hc(n,r,s))});let{hasValidItems:i,processedItems:a}=Kc(t.visual.items,Vc,n,{hasPatchFn:vg,hasSubjectFn:kg,mergeItemFn:Pg});i?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!Vc(n)||!ln(n))?{...n,animations:{}}:n))},Vg=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!qc(a)||!ln(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:i}=Kc(t.character.items,qc,e.character?.items||[],{hasSubjectFn:Ag});n?e.character={items:i}:delete e.character},qg=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},Fg=(e,t)=>{if(t.layout){let{animationsOnly:n,state:i}=cn(t.layout,a=>!!a.resourceId);if(n){e.layout=i;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},Bg=(e,t)=>{if(t.choice){let{animationsOnly:n,state:i}=cn(t.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...i};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},Ug=(e,t)=>{if(t.form){let{animationsOnly:n,state:i}=cn(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...i};return}if(!t.form.resourceId){delete e.form;return}e.form=ae(t.form)}else e.form&&delete e.form},Yg=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},zg=(e,t)=>{if(t.voice){let n=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!n||n&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ae(t.voice)}else e.voice&&delete e.voice},Xg=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},it=(e,{resources:t,initialState:n}={})=>ts(()=>n??_g(),[Xg,Ng,jg,Dg,(r,s)=>Lg(r,s,t),Mg,Tg,Vg,qg,Fg,Bg,Ug,Yg,zg])(e);var Jc=new WeakMap,Fe=(e,t)=>{let n=Ie(e)?Ge(e):e;if(!Array.isArray(n))return-1;if(!Object.isFrozen(n))return n.findIndex(a=>a.id===t);let i=Jc.get(n);return i||(i=new Map,n.forEach((a,r)=>{i.has(a.id)||i.set(a.id,r)}),Jc.set(n,i)),i.get(t)??-1};var Qc=Object.freeze({}),Gg=64,Hg=16,Zc=4,Kg=8,eu=new WeakMap,hs=(e,t,n,i)=>{e.delete(t),e.set(t,n),e.size>i&&e.delete(e.keys().next().value)},Wg=(e,t)=>{if(!Array.isArray(t.lines)||!Object.isFrozen(e)||!Object.isFrozen(t)||!Object.isFrozen(t.lines)||e.resources&&!Object.isFrozen(e.resources))return null;let n=eu.get(e);n||(n=new Map,eu.set(e,n));let i=n.get(t);return i||(i={checkpoints:new Map,recent:new Map}),hs(n,t,i,Kg),i},ru=(e,t,n,i=0)=>{let a=t?.lines??[],r=t&&Array.isArray(a)?Wg(e,t):null,o=Fe(a,n)+i;if(o<0)return i<0?null:Qc;if(!r)return it(a.slice(0,o+1).map(u=>u.actions||{}),{resources:e.resources});let l=-1,c=Qc;for(let u of[r.checkpoints,r.recent])for(let[p,m]of u)p<=o&&p>l&&(l=p,c=m);for(let u of[o-1,o])u<=l||(c=it(a.slice(l+1,u+1).map(p=>p.actions||{}),{resources:e.resources,initialState:c}),(u+1)%Gg===0&&hs(r.checkpoints,u,c,Hg),hs(r.recent,u,c,Zc),l=u);return hs(r.recent,o,c,Zc),c};var St=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=rt(e,t);return n&&typeof n=="object"?e:typeof n=="number"||typeof n=="boolean"?String(n):n};var Jg=Object.freeze({dialogueTextSpeed:{source:"global.dialogueTextSpeed"},autoForwardDelay:{source:"global.autoForwardDelay"},autoForwardSpeed:{source:"global.autoForwardSpeed"},skipUnseenText:{source:"global.skipUnseenText"},skipTransitionsAndAnimations:{source:"global.skipTransitionsAndAnimations"},soundVolume:{source:"global.soundVolume"},musicVolume:{source:"global.musicVolume"},muteAll:{source:"global.muteAll"},localizationPackageId:{source:"global.localizationPackageId"},saveLoadPagination:{source:"context.runtime.saveLoadPagination"},menuPage:{source:"context.runtime.menuPage"},menuEntryPoint:{source:"context.runtime.menuEntryPoint"},autoMode:{source:"global.autoMode"},skipMode:{source:"global.skipMode"},dialogueUIHidden:{source:"global.dialogueUIHidden"},isLineCompleted:{source:"global.isLineCompleted"}}),Mr=Object.freeze({dialogueTextSpeed:50,autoForwardDelay:1e3,autoForwardSpeed:50,skipUnseenText:!1,skipTransitionsAndAnimations:!1,soundVolume:50,musicVolume:50,muteAll:!1,localizationPackageId:null,autoMode:!1,skipMode:!1,dialogueUIHidden:!1,isLineCompleted:!1}),un=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Qg=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),Lo=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),tu=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),Mo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),nu=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Zg=(e,t)=>{let n=Qg[e];if(n==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(n==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(n==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(n==="nullableString"){if(t!==null&&typeof t!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},gs=(e,t)=>{if(Zg(e,t),e==="autoForwardDelay"&&t<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(t<0||t>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},Vo=(e={})=>{let t=e?.config;if(t===void 0)return{...Mr};if(!nu(t))throw new Error("projectData.config must be an object");let n=Object.keys(t).find(o=>o!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let i=t.runtimeDefaults;if(i===void 0)return{...Mr};if(!nu(i))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(tu),r=Object.keys(i).find(o=>!a.has(o));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...Mr};return tu.forEach(o=>{i[o]!==void 0&&(s[o]=gs(o,i[o]))}),s},eb=(e,t)=>{if(t.startsWith("global.")){let n=t.slice(7);return e?.global?.[n]}if(t.startsWith("context.runtime.")){let n=t.slice(16),i=Array.isArray(e?.contexts)?e.contexts:[];return i[i.length-1]?.runtime?.[n]}},kr=e=>Object.fromEntries(Object.entries(Jg).map(([t,n])=>{let i=eb(e,n.source),a=i!==void 0?i:Mr[t]??un[t];return[t,a]})),ar=(e,t)=>kr(e)[t],su=(e={})=>Object.fromEntries(Lo.map(t=>[t,e[t]??Mr[t]]));var Ot=Object.freeze({VISUAL_BEHIND_BACKGROUND:10,BACKGROUND:20,VISUAL_BEHIND_CHARACTER:30,CHARACTER:40,VISUAL_BEHIND_DIALOGUE:50,DIALOGUE:60,VISUAL_BEHIND_CHOICE:70,CHOICE:80,VISUAL_FOREGROUND:90}),Ar=Object.freeze({BEHIND_BACKGROUND:Ot.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:Ot.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:Ot.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:Ot.VISUAL_BEHIND_CHOICE,FOREGROUND:Ot.VISUAL_FOREGROUND}),qo=Ar.BEHIND_DIALOGUE,Fo=Object.freeze(Object.values(Ar).sort((e,t)=>e-t));var rb={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:Po},tb=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,iu=e=>{let t=tb.exec(e);if(!t)return null;let[,n,i,a]=t;return`${n}${i?`, ${i}`:""} in __arrayOrEmpty(${a.trim()})`},pn=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return pn(t);let[n]=Object.keys(t),i=iu(n);if(!i)return pn(t);let a=`$for ${i}`,r=Array.isArray(t[n])?t[n]:[];return{[a]:pn(r)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,t==="$each"&&typeof n=="string"?iu(`$for ${n}`)??n:pn(n)])),cr=(e,t)=>{let n={functions:rb};return rt(pn(e),t,n)},Iu=({animationType:e,animationId:t,animationPath:n})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${n}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},nb=({id:e,targetId:t,animation:n,playback:i,animationPath:a="animation"})=>{let r=structuredClone(n);if(Iu({animationType:r.type,animationId:e,animationPath:a}),r.type==="transition"&&r.prev===void 0&&r.next===void 0&&r.mask===void 0)throw new Error(`[${a}] Animation "${e}" of type "transition" must define prev, next, or mask.`);if(delete r.name,delete r.playback,r.id=e,r.targetId=t,i!==void 0){let s=ab(i,`${a}.playback`);if(s!==void 0){let o=s.loop===!0?Eu(r):null;if(s.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&r.complete!==void 0)throw new Error(`[${a}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(s.loop===!0&&pb(r,a),s.loop===!0&&o===0)return null;if(s.loop===!0&&(!Number.isFinite(o)||o<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);r.playback=s}}return r},sb=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return Iu({animationType:e.type,animationId:t,animationPath:n}),e.type},ib=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},ob=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},ab=(e,t="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${t}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${t}] playback.continuity must be "render" or "persistent".`);if(e.speed!==void 0&&(typeof e.speed!="number"||!Number.isFinite(e.speed)||e.speed<=0))throw new Error(`[${t}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${t}] playback.loop must be a boolean.`);let n={};return e.continuity!==void 0&&(n.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(n.speed=e.speed),e.loop===!0&&(n.loop=!0),Object.keys(n).length>0?n:void 0},lb=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},tr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),vu=(e={})=>tr(e,"alpha")&&typeof e.alpha=="number"?e.alpha:tr(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,ku=e=>e?.playback?.continuity==="persistent",Ko=e=>Array.isArray(e)?e.map(Ko):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=Ko(e[n]),t),{}),ks=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=structuredClone(e);return t.playback&&(delete t.playback.continuity,t.playback.speed===1&&delete t.playback.speed,Object.keys(t.playback).length===0&&delete t.playback),JSON.stringify(Ko(t))},Au=(e=[])=>e.filter(t=>ku(t)).map(t=>structuredClone(t)),bs=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Pu=e=>{if(!e||typeof e!="object"||Array.isArray(e))return 0;if(e.auto!==void 0){let t=e.auto;return bs(t?.delay)+bs(t?.duration)}return Array.isArray(e.keyframes)?e.keyframes.reduce((t,n)=>t+bs(n?.delay)+bs(n?.duration),0):0},Bo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,Pu(n)),0),xu=e=>Array.isArray(e)?e.reduce((t,n)=>Math.max(t,xu(n)),0):!e||typeof e!="object"?0:Pu(e.progress),Eu=e=>Math.max(Bo(e?.tween),Bo(e?.prev?.tween),Bo(e?.next?.tween),xu(e?.mask)),cb=e=>{let t=[],n=[["tween",e?.tween],["prev.tween",e?.prev?.tween],["next.tween",e?.next?.tween]];for(let[a,r]of n)if(!(!r||typeof r!="object"||Array.isArray(r)))for(let[s,o]of Object.entries(r))Array.isArray(o?.keyframes)&&t.push([`${a}.${s}.keyframes`,o.keyframes]);let i=e?.mask?.progress?.keyframes;return Array.isArray(i)&&t.push(["mask.progress.keyframes",i]),t},ub=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0,pb=(e,t)=>{for(let[n,i]of cb(e))i.forEach((a,r)=>{let s=a?.duration;if(!ub(s))throw new Error(`[${t}.playback] playback.loop requires every keyframe duration to be a finite number of at least 0, but ${n}[${r}].duration is ${String(s)}.`)})},Su=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Eu(e)/lb(e),fb=e=>e.some(t=>t?.playback?.loop===!0),ou=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let n=new Set(t.map(ks).filter(Boolean));return e.some(i=>{if(!ku(i))return!1;let a=ks(i);return a?n.has(a):!1})},nr=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:fb(e)||r&&!t||ou({animationInstances:e,activePersistentAnimations:i})?!0:r?!1:ou({animationInstances:e,activePersistentAnimations:a}),Ou=(e,t,n,i,a)=>{if(e===void 0)return!0;let r=a.slice(0,i).filter(o=>o?.id===n).length,s=e?.[t]?.items?.filter(o=>o?.id===n).at(r);return tr(s??{},"animations")},db=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),mb=(e,t)=>{if(db(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},yb=({resources:e,animationId:t,playback:n,instanceId:i,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=L(e?.animations,t);return s?nb({id:i,targetId:a,animation:s,playback:n,animationPath:r}):null},Wo=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${t} must be an array of objects`);return e},hb=({content:e,path:t,variables:n,runtime:i})=>Wo(e,t).reduce((a,r)=>{let s=St(r.text,{variables:n,runtime:i});return a+`${s??""}`.length},0),au=(e=[])=>{let t=new Map;for(let n of e)n?.id&&t.set(n.id,(t.get(n.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,n])=>n>1).map(([n])=>n))},lu=(e,t=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let i=e?.sprites?.map(({resourceId:a})=>a)||[];return i.length===0?`character-container-${e.id}`:`character-container-${e.id}-${t}-${i.join("-")}`},$t=(e,t)=>{if(t.transformId&&t.transform)throw new Error(`Visual item "${t.id}" cannot define both transformId and transform`);if(t.transform)return t.transform;if(!t.transformId)throw new Error(`Visual item "${t.id}" requires transformId or transform`);let n=L(e.transforms,t.transformId);if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},gb=(e,t={})=>{if(!t?.transformId)return;let n=L(e.transforms,t.transformId);if(!n)throw new Error(`Transform "${t.transformId}" not found for background`);return n},bb=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],wb=(e={})=>bb.some(t=>tr(e,t)),Ru=(e={},t)=>{if(t){if(L(e.images,t))return"sprite";if(L(e.videos,t))return"video";if(L(e.spritesheets,t))return"spritesheet-animation";if(L(e.layouts,t))return"container"}},Is=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Ib=(e={})=>e.textStyles||{},vb=(e={})=>e.images||{},kb=.5,Ab=(e={},t,n)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${n}'`);return t}return Object.keys(e.animations??{})[0]},na=({id:e,resourceId:t,spritesheet:n,animationName:i,animationSpeed:a,loop:r,width:s,height:o,transform:l={}}={})=>{let c=Ab(n,i,t),u=c?n.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:o??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??kb,loop:r??u.loop??!0}}},$u=({id:e,item:t,resources:n={}}={})=>{let i=L(n.images,t.resourceId);if(i)return{type:"sprite",id:e,src:i.fileId,width:i.width,height:i.height,x:0,y:0};let a=L(n.spritesheets,t.resourceId);if(a)return na({id:e,resourceId:t.resourceId,spritesheet:a,animationName:t.animationName,animationSpeed:t.animationSpeed,loop:t.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${t.resourceId}`)},Pb=(e={})=>e.colors||{},xb=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,lt=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,at=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},Uo=(e,t,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);return e},Yo=(e,t,n,i,{minimum:a}={})=>{if(e===void 0)return i;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let r=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${t} for text style "${n}" must be ${r}`)}return e},mn=(e,t)=>{if(typeof e!="string"||!xb.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(n=>n.repeat(2)).join("")}`:e},cu=(e,t,n)=>{let i=mn(e,n);if(t===1)return i;let a=Number.parseInt(i.slice(1,3),16),r=Number.parseInt(i.slice(3,5),16),s=Number.parseInt(i.slice(5,7),16);return`rgba(${a}, ${r}, ${s}, ${t})`},Cu=(e={},t)=>{let n=L(Ib(e),t);if(!n)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let c=L(e.fonts,l);if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=L(e.colors,n.colorId);if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=Uo(n.colorAlpha,"colorAlpha",t),o={fontFamily:Array.isArray(n.fontId)?a.join(", "):a[0],fontSize:n.fontSize??16,fontWeight:n.fontWeight??"400",fontStyle:n.fontStyle??"normal",lineHeight:n.lineHeight??1.2,fill:cu(r.hex,s,`Color "${n.colorId}" for text style "${t}"`)};if(n.align!==void 0&&(o.align=n.align),n.wordWrap!==void 0&&(o.wordWrap=n.wordWrap),n.breakWords!==void 0&&(o.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(o.wordWrapWidth=n.wordWrapWidth),n.strokeColorId){let l=L(e.colors,n.strokeColorId);if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${t}"`);let c=Uo(n.strokeAlpha,"strokeAlpha",t);o.strokeColor=cu(l.hex,c,`Stroke color "${n.strokeColorId}" for text style "${t}"`)}else if(n.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(n.strokeWidth!==void 0&&(o.strokeWidth=n.strokeWidth),n.shadow!==void 0){let l=L(e.colors,n.shadow.colorId);if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${t}"`);o.shadow={color:mn(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:Uo(n.shadow.alpha,"shadow.alpha",t),blur:Yo(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:Yo(n.shadow.offsetX,"offsetX",t,2),offsetY:Yo(n.shadow.offsetY,"offsetY",t,2)}}return o},Ct=e=>Array.isArray(e)?e.map(Ct):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Ct(n)])),_t=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},Eb=new Set(["text","text-revealing"]),Sb=["fontWeight","fontStyle","textDecoration","fill"],Ob=new Set(["normal","bold","bolder","lighter"]),Rb=new Set(["normal","italic","oblique"]),$b=new Set(["none","underline"]),Cb=/^\d+(?:\.\d+)?$/,_b=e=>{if(typeof e=="string"&&Ob.has(e))return!0;let t=typeof e=="string"&&Cb.test(e)?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>=1&&t<=1e3},Nb=(e,t)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Inline textStyle at "${t}" must be an object`);let n={};for(let[i,a]of Object.entries(e)){if(!Sb.includes(i))throw new Error(`Inline textStyle.${i} is not allowed in text content runs at "${t}". Only fontWeight, fontStyle, textDecoration, and fill may be authored inline; use textStyleId for other style changes`);if(i==="fontWeight"&&!_b(a))throw new Error(`Inline textStyle.fontWeight at "${t}" must be normal, bold, bolder, lighter, or a number from 1 to 1000`);if(i==="fontStyle"&&!Rb.has(a))throw new Error(`Inline textStyle.fontStyle at "${t}" must be normal, italic, or oblique`);if(i==="textDecoration"&&!$b.has(a))throw new Error(`Inline textStyle.textDecoration at "${t}" must be none or underline`);n[i]=i==="fill"?mn(a,`Inline textStyle.fill at "${t}"`):a}return n},jb=(e,t,n)=>{let i={};for(let[r,s]of Object.entries(e))r==="textStyle"||r==="textStyleId"||_t(i,r,fn(s,t,lt(n,r)));let a;return e.textStyleId!==void 0&&(at(e.textStyleId,n,"textStyleId"),a=Cu(t,e.textStyleId)),e.textStyle!==void 0&&(a={...a,...Nb(e.textStyle,n)}),a!==void 0&&(i.textStyle=a),i},fn=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>fn(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${n}". Use textStyleId instead`);let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=Ct(r);continue}if(a!=="textStyleId"){if(a==="content"&&Array.isArray(r)&&Eb.has(e.type)){let s=lt(n,a);_t(i,a,r.map((o,l)=>o&&typeof o=="object"&&!Array.isArray(o)?jb(o,t,`${s}[${l}]`):fn(o,t,`${s}[${l}]`)));continue}_t(i,a,fn(r,t,lt(n,a)))}}return e.textStyleId!==void 0&&(at(e.textStyleId,n,"textStyleId"),i.textStyle=Cu(t,e.textStyleId)),i},sa=(e={},t)=>{let n=L(Pb(e),t);if(!n)throw new Error(`Color "${t}" not found`);return mn(n.hex,`Color "${t}"`)},_u=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",zo=(e,t,n)=>{let i=e?.[t];if(!(!i||typeof i!="object"||Array.isArray(i))&&Object.prototype.hasOwnProperty.call(i,"fill"))throw new Error(`Inline ${t}.fill is not allowed in rect layout elements at "${n}". Use ${_u(`${t}.fill`)} instead`)},Tb=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>dn(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let i={};for(let[a,r]of Object.entries(e))a!=="colorId"&&_t(i,a,dn(r,t,lt(n,a)));return e.colorId!==void 0&&(at(e.colorId,n,"colorId"),i.fill=sa(t,e.colorId)),i},dn=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>dn(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="rect"){if(Object.prototype.hasOwnProperty.call(e,"fill"))throw new Error(`Inline fill is not allowed in rect layout elements at "${n}". Use ${_u("fill")} instead`);zo(e,"hover",n),zo(e,"click",n),zo(e,"rightClick",n)}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=Ct(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){i[a]=Tb(r,t,lt(n,a));continue}_t(i,a,dn(r,t,lt(n,a)))}}return e.type==="rect"&&e.colorId!==void 0&&(at(e.colorId,n,"colorId"),i.fill=sa(t,e.colorId)),i},Xo=(e={},t)=>{let n=L(vb(e),t);return n||null},Nu=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",uu=(e,t,n,i)=>{let a=e?.[t];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,i))throw new Error(`Inline ${t}.${i} is not allowed in sprite layout elements at "${n}". Use ${Nu(`${t}.${i}`)} instead`)},pu=(e,t,n)=>{let i=e[t];e[t]={...i&&typeof i=="object"&&!Array.isArray(i)?i:{},src:n}},Jo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Jo(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${n}". Use ${Nu(a)} instead`);uu(e,"hover",n,"src"),uu(e,"click",n,"src")}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=Ct(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||_t(i,a,Jo(r,t,lt(n,a)))}if(e.type==="sprite"&&e.imageId!==void 0){at(e.imageId,n,"imageId");let a=Xo(t,e.imageId),r=a?.fileId??e.imageId;i.src=r,i.width===void 0&&a?.width!==void 0&&(i.width=a.width),i.height===void 0&&a?.height!==void 0&&(i.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(at(e.hoverImageId,n,"hoverImageId"),pu(i,"hover",Xo(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(at(e.clickImageId,n,"clickImageId"),pu(i,"click",Xo(t,e.clickImageId)?.fileId??e.clickImageId)),i},Db=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),vs=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>vs(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=Ct(e),i=typeof e.type=="string";(i||t)&&tr(e,"opacity")&&(tr(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])tr(e,a)&&(n[a]=vs(e[a]));for(let[a,r]of Object.entries(e))Db(a)&&(n[a]=vs(r,{isElementPatch:i||t}));return n},ia=(e,t={},n="root")=>vs(Jo(dn(fn(e,t,n),t,n),t,n)),Pr=ia,ct=(e=[])=>e.find(t=>t.id==="story"),ju=(e,t=new Set)=>{if(!Array.isArray(e))return t;for(let n of e)typeof n?.id=="string"&&t.add(n.id),ju(n?.children,t);return t},Tu=e=>encodeURIComponent(e).replaceAll("--","%2D%2D"),Lb=(e,t)=>{let n=Tu(typeof t=="string"&&t.length>0?t:"layout"),i=n,a=2;for(;e.claimedNamespaces.has(i);)i=`${n}-${a++}`;return e.claimedNamespaces.add(i),i},Vr=({state:e,elements:t,layoutInstanceState:n,rootId:i})=>{if(!n||!Array.isArray(t))return t;let a=Lb(n,i),r=ju(e.elements);typeof i=="string"&&r.add(i);let s=o=>Array.isArray(o)?o.map(l=>{if(!l||typeof l!="object"||Array.isArray(l))return l;let c={...l};if(typeof l.id=="string"){let u=`@layout/${a}--${Tu(l.id)}`,p=u,m=1;for(;n.usedIds.has(p)||r.has(p);)p=`${u}-${m++}`;c.id=p,n.usedIds.add(p)}return Array.isArray(l.children)&&(c.children=s(l.children)),c}):o;return s(t)},Mb="#000000",Qo="bg-cg-background-color",Vb=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?mn(n?.backgroundColor??Mb,"screen.backgroundColor"):sa(e,t.colorId),Du=(e={})=>vu(e),qb=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},oa=(e={})=>Array.isArray(e.filters)?e.filters:void 0,fu=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=Du(e),i=qb(e),a=oa(e),r={};return(t||n!==void 0)&&(r.alpha=n??1),i&&(r.blur=i),a&&(r.filters=a),r},Fb=(e={})=>vu(e),Bb=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Lu=(e={})=>{let t=Fb(e),n=Bb(e),i={};return t!==void 0&&(i.alpha=t),n&&(i.blur=n),i},ot=(e={})=>{let t=Lu(e),n=oa(e);return n&&(t.filters=n),t},du=(e,t,n,i)=>{let a=t[n]??e[n];return t[i]??e[i]??!1?(a??1)*-1:a},lr=(e={},t={})=>{let n={x:t.x??e.x,y:t.y??e.y,anchorX:t.anchorX??e.anchorX,anchorY:t.anchorY??e.anchorY,rotation:t.rotation??e.rotation,scaleX:du(e,t,"scaleX","flipX"),scaleY:du(e,t,"scaleY","flipY")},i=t.originX??e.originX,a=t.originY??e.originY;return i!==void 0&&(n.originX=i),a!==void 0&&(n.originY=a),n},Ub=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],aa=(e={})=>e.text&&tr(e.text,"content")&&tr(e.text,"textStyleId"),la=(e={})=>e.layout&&Array.isArray(e.layout.elements),mu=(e={})=>{if(e.resourceId)return e.resourceId;if(aa(e))return"text";if(la(e))return"inline-layout"},yu=(e,t={})=>typeof e=="string"?L(t.images,e)?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?L(t.images,e.imageId)?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return L(t.images,n)?.fileId??n;if(!n||typeof n!="object"||Array.isArray(n))return n;if(n.imageId){let{imageId:i,...a}=n;return{...a,src:L(t.images,i)?.fileId??i}}return typeof n.src=="string"?{...n,src:L(t.images,n.src)?.fileId??n.src}:n})}:e,Yb=({item:e,particle:t,resources:n})=>{let i=$t(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=yu(r,n)),a.texture!==void 0&&(a.texture=yu(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...lr(i,e)};return Object.assign(s,ot(e)),s},zb=e=>{let t=[e.resourceId,e.text,e.layout].filter(n=>n!==void 0).length;if(t>1)throw t===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(e.text&&!aa(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!la(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of Ub)if(tr(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},Xb=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:i=!1})=>{let a={id:Qo,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Vb({resources:e,background:t,screen:n})};if(i){let r=Du(t);r!==void 0&&(a.alpha=r);let s=oa(t);s&&(a.filters=s)}return a},Gb=(e={},t)=>t?!!(L(e.images,t)||L(e.videos,t)||L(e.spritesheets,t)||L(e.layouts,t)):!1,hu=({resources:e={},resourceId:t,colorId:n})=>{let i=Ru(e,t);return t&&(i||n===void 0)?{resourceId:t,targetId:Is({resourceId:t,kind:i})}:n!==void 0?{resourceId:Qo,targetId:Qo}:{resourceId:void 0,targetId:void 0}},Mu=100,xr=Mu,Hb="channel:bgm",Kb="channel:music-room",Wb="music-room:player",Jb="channel:voice",Qb="default",As=(e,t,n)=>{let i=new Set;e.forEach(({id:a})=>{if(i.has(a)){let r=n?` in ${n}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}i.add(a)})},Vu=(e,t)=>e*t/Mu,ca=(e={},t)=>e?.[t]??Mr[t],xs=(e={},t,n=xr)=>Vu(n,ca(e,t)),qu=(e,t,n)=>t?.muteAll===!0?0:xs(t,n,e??xr),Es=({id:e,volume:t,muted:n,pan:i,loop:a,playback:r,interruption:s,children:o,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(n??!1),pan:i??0,children:o};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),s!==void 0&&(c.interruption=s),c},ws=(e,t,n,i)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:i,Zb=["muted","pan","playbackRate","startAt","endAt"],Ss=({id:e,sound:t,resource:n,projectResources:i,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:s=!1})=>{let o={id:e,type:"sound",src:n.fileId,loop:ws(t,n,"loop",r),volume:ws(t,n,"volume",xr),startDelayMs:ws(t,n,"startDelayMs",0)};Zb.forEach(c=>{let u=ws(t,n,c,void 0);u!==void 0&&(o[c]=u)}),t.playback!==void 0&&(o.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=Dc({selection:t[c],selectionPath:`${a}.${c}`,resources:i});u&&!s&&(o[c]=u)}let l=o.startAt??0;if(o.endAt!==void 0&&o.endAt!==null&&o.endAt<l)throw new Error(`Sound "${e}" endAt (${o.endAt}) must be greater than or equal to startAt (${l}).`);return o},e0=e=>Math.max(-1,Math.min(1,e)),r0=({node:e,bgm:t,sound:n,resource:i,usesLegacySound:a})=>{a||(e.volume=Vu(t.volume??xr,e.volume??xr));let r=t.muted!==void 0,s=n.muted!==void 0||i.muted!==void 0;(r||s)&&(e.muted=t.muted===!0||e.muted===!0);let o=t.pan!==void 0,l=n.pan!==void 0||i.pan!==void 0;return(o||l)&&(e.pan=e0((t.pan??0)+(e.pan??0))),e},We=({variables:e,imageGallery:t,musicRoom:n,sceneReplay:i,runtime:a,saveSlots:r=[],dialogueState:s,includeInactiveAdvDialogue:o=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g=[],characters:y={},dialogueUIHidden:b,skipOnlyViewedLines:w,skipTransitionsAndAnimations:A}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??b??!1,isLineCompleted:a?.isLineCompleted??l??!1},P=o0({dialogueState:s,includeInactiveAdvDialogue:o,characters:y,variables:e,runtime:k}),I={variables:e,imageGallery:t,musicRoom:n,sceneReplay:i,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g,characters:y};return P&&(I.dialogue=P,I.dialogueLines=P.lines),I},gu=100,Ps=(e,t)=>{if(Array.isArray(e))return e.map(i=>Ps(i,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(i=>{n[i]=Ps(n[i],t)}),n.type==="text-revealing"?t(n):n},t0=e=>Ps(e,t=>({...t,revealEffect:"none"})),n0=e=>Ps(e,t=>{let n=Number(t.speed??t.displaySpeed),i=Number.isFinite(n)?Math.max(n,gu):gu;return{...t,speed:i,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:i}:{}}}),qr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:i=!1}={})=>t||i?t0(e):n?n0(e):e,Fu=({id:e,screen:t={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:t.width,height:t.height,x:0,y:0,click:{payload:{actions:{}}}}),Zo=e=>{if(Array.isArray(e))return e.map(Zo);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Zo(s);let n=t.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return t;let i=n.actions,a=i&&typeof i=="object"&&!Array.isArray(i)&&Object.prototype.hasOwnProperty.call(i,"nextLine")?{...i.nextLine,bypassChoice:!0}:void 0;return{...t,click:{...t.click,payload:{...n,bypassChoice:!0,...a?{actions:{...i,nextLine:a}}:{}}}}},s0=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),bu="submit",Go=(e,t,n={})=>{let i=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=i.actions&&typeof i.actions=="object"?i.actions:{},r=n.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...i,actions:r}}},ea=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>ea(c,t,n));if(!e||typeof e!="object")return e;let i=typeof e.type=="string",a=i&&e.formRole===bu,r=i&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},o={};for(let[c,u]of Object.entries(e))o[c]=ea(u,t,c==="children"?s:{});let l=o;if(l.type==="input"&&typeof l.field=="string"){let c=t?.fields?.[l.field];if(c){let u={updateFormField:{formKey:t.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:Go(l.change,u),submit:Go(l.submit,t.submitActions)}}}return l.formRole===bu||r?{...l,click:Go(l.click,t.submitActions,{replaceActions:!0})}:l},ra=(e,t)=>{if(Array.isArray(e))return e.map(i=>ra(i,t));if(!e||typeof e!="object")return e;let n={};for(let[i,a]of Object.entries(e))n[i]=ra(a,t);for(let i of s0){let a=n[i]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[i]={...n[i],payload:{...a,_interactionSource:"form"}})}return n},ta=({characterId:e,character:t,characterName:n,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0,s=ns({characterId:e,character:t,characterName:n,characters:i,variables:a});return{...r||{},...t||{},name:s}},Bu=(e=[],t={},n={})=>e.map(i=>{let a=ta({characterId:i.characterId,character:i.character,characterName:i.characterName,characters:t,variables:n}),r=typeof i.text=="string"?i.text:Array.isArray(i.content)?i.content.map(s=>s?.text??"").join(""):"";return{...i,text:r,character:a,characterName:a.name}}),i0=e=>!(!e||e.mode==="adv"&&e.content===void 0),o0=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:i,runtime:a}={})=>{if(!t&&!i0(e))return;let r=e.content===void 0?[{text:""}]:Wo(e.content,"dialogue.content"),s=e.content===void 0?0:hb({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:i,runtime:a}),o=a?.dialogueTextSpeed??Mr.dialogueTextSpeed,l=e.textSpeed??o,c=(e.lines||[]).map((p,m)=>{let d=Wo(p.content,`dialogue.lines[${m}].content`),f=ta({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:i});return{...p,textSpeed:p.textSpeed??o,content:d.map(h=>({...h,text:St(h.text,{variables:i,runtime:a})})),character:f,characterName:f.name}}),u=ta({characterId:e.characterId,character:e.character,characters:n,variables:i});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:St(p.text,{variables:i,runtime:a})})),initialRevealedCharacters:s,lines:c}},ua=({state:e,container:t,resources:n,templateData:i,layoutInstanceState:a,isLineCompleted:r=!1,skipMode:s=!1,skipTransitionsAndAnimations:o=!1})=>{let l=cr(t,i);return l.children=Vr({state:e,elements:l.children,layoutInstanceState:a,rootId:t.id}),Pr(qr(l,{isLineCompleted:r,skipMode:s,skipTransitionsAndAnimations:o}),n)},Ho=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),wu=({renderStateKeyboard:e,keyboard:t,phase:n})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([i,a])=>{let r=e[i]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[i]={...r,keydown:{payload:Ho(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[i].keyup={payload:Ho(a.keyup)});return}e[i]={...r,[n]:{payload:Ho(a)}}})},a0=(e={},t={})=>{let n={};return wu({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),wu({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},Er=({animationsDef:e,resources:t,previousResourceId:n,currentResourceId:i,previousTargetId:a,currentTargetId:r,animationPath:s,idPrefix:o})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:b})=>{let w=yb({resources:t,animationId:d,playback:f,instanceId:y,targetId:b,animationPath:s});w&&l.push(w)},u=n!=null&&n!==!1,p=i!=null&&i!==!1,m=a&&r&&a===r;mb(e,s);let d=ib(e),f=ob(e),h=L(t?.animations,d),g=sb(h,{animationId:d,animationPath:s});if(g==="update")return p&&r?c({instanceId:`${o}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${o}-animation-update`,targetId:a}),l;if(g==="transition"){let y=`${o}-animation-transition`,b=f?.continuity==="persistent"?y:`${o}-animation-in`;if(u&&p&&m)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${o}-animation-out`,targetId:a}),p&&c({instanceId:b,targetId:r})}return l},l0=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),c0=(e,{presentationState:t,previousPresentationState:n,currentLineActions:i,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:o,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:b,canRollback:w,form:A,saveSlots:k=[],layoutInstanceState:P})=>{let{elements:I,animations:x}=e;if(t.background){let T=i===void 0?!0:tr(i?.background??{},"animations"),C=I.find(de=>de.id==="story");if(!C)return e;let $=gb(a,t.background),q=$||wb(t.background),X=n?.background?.resourceId,N=n?.background?.colorId,K=t.background.resourceId??(t.background.animations?X:void 0),M=t.background.colorId??(t.background.animations?N:void 0),Q=Gb(a,K),le={...t.background,colorId:M};if((M!==void 0||Q)&&C.children.push(Xb({resources:a,background:le,screen:r,includeAlpha:!Q})),K){let{images:de={},videos:ce={},spritesheets:Z={}}=a,_=Ru(a,K),D;if(_==="sprite"?D=de[K]:_==="video"?D=ce[K]:_==="spritesheet-animation"&&(D=Z[K]),D){let F=_==="video",W=_==="spritesheet-animation",ye={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...$},ke={...fu(t.background,{includeDefaultAlpha:!0}),...lr(ye,t.background)},fe;W?fe=na({id:Is({resourceId:K,kind:_}),resourceId:K,spritesheet:D,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:ke}):fe={id:Is({resourceId:K,kind:_}),type:F?"video":"sprite",src:D.fileId,width:D.width,height:D.height,...ke},F&&(fe.loop=t.background.loop??!1,fe.volume=qu(D.volume,m,"musicVolume")),fe&&C.children.push(fe)}}if(K){let{layouts:de={}}=a,ce=de[K];if(ce){let Z={id:Is({resourceId:K,kind:"container"}),type:"container",children:ce.elements,...fu(t.background)};q&&Object.assign(Z,lr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...$},t.background));let _=cr(Z,We({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:b,canRollback:w,form:A,characters:a.characters||{},skipTransitionsAndAnimations:o}));_.children=Vr({state:e,elements:_.children,layoutInstanceState:P,rootId:Z.id}),C.children.push(Pr(qr(_,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:o}),a))}}let H=hu({resources:a,resourceId:X,colorId:N}),ne=hu({resources:a,resourceId:K,colorId:M}),ue=Er({animationsDef:t.background.animations,resources:a,previousResourceId:H.resourceId,currentResourceId:ne.resourceId,previousTargetId:H.targetId,currentTargetId:ne.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});nr({animationInstances:ue,isLineCompleted:s,skipTransitionsAndAnimations:o,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:T})&&x.push(...ue)}return e},u0=(e,{presentationState:t,previousPresentationState:n,currentLineActions:i,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(b=>b.id==="story");if(!p)return e;let m=t.character.items||[],d=n?.character?.items||[],f=au(m),h=au(d),g=new Map,y=new Map;for(let b=0;b<d.length;b++){let w=d[b],A=g.get(w.id)??[];A.push(b),g.set(w.id,A)}for(let b=0;b<m.length;b++){let w=m[b],{transformId:A,sprites:k}=w,P=y.get(w.id)??0;y.set(w.id,P+1);let I=g.get(w.id)?.[P]??-1,x=d[I],T=x?.sprites&&x.sprites.length>0,C=k&&k.length>0,$=I>=0?lu(x,I,h):void 0,q=C?lu(w,b,f):void 0,X=Ou(i,"character",w.id,b,m),N=Er({animationsDef:w.animations,resources:a,previousResourceId:$,currentResourceId:q,previousTargetId:$,currentTargetId:q,animationPath:`character.items[${b}].animations`,idPrefix:q??$??`character-${b}`});if(w.animations&&!k&&!A&&T&&nr({animationInstances:N,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:X})){u.push(...N);continue}if(w.animations&&!k&&!A)continue;if(!k||k.length===0||!A){console.warn("Character item missing sprites or transformId:",w);continue}let K=L(a.transforms,A);if(!K){console.warn("Transform not found:",A);continue}let M={type:"container",id:q,...lr(K,w),...ot(w),children:[]};for(let Q of k){let le=$u({id:`${q}-${Q.id}`,item:Q,resources:a});le&&M.children.push(le)}p.children.push(M),nr({animationInstances:N,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:X})&&u.push(...N)}}return e},Uu=(e,t)=>{if(!Fo.includes(e))throw new Error(`${t} must be one of: ${Fo.join(", ")}.`)},p0=(e,t)=>{let n=!!e.resourceId||aa(e)||la(e),i=e.layer??(n?void 0:t?.layer)??qo;return Uu(i,`Visual item "${e.id}" layer`),i},f0=(e,{presentationState:t,previousPresentationState:n,currentLineActions:i,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:m,restoredPersistentAnimations:d,autoMode:f,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:b,form:w,saveSlots:A=[],visualLayer:k,layoutInstanceState:P})=>{let{elements:I,animations:x}=e;if(t.visual&&a){let T=I.find(X=>X.id==="story");if(!T)return e;let C=t.visual.items,$=n?.visual?.items||[],q=We({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:A,dialogueState:t.dialogue,isLineCompleted:r,autoMode:f,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:b,form:w,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&Uu(k,"visualLayer");for(let[X,N]of C.entries()){let K=$.find(ce=>ce.id===N.id),M=Ou(i,"visual",N.id,X,C),Q=p0(N,K);if(k!==void 0&&Q!==k)continue;if(zb(N),N.layout){let ce=$t(a,N),Z={id:`visual-${N.id}`,type:"container",children:structuredClone(N.layout.elements),...lr(ce,N)};Object.assign(Z,ot(N)),T.children.push(ua({state:e,container:Z,resources:a,templateData:q,layoutInstanceState:P,isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}))}if(N.text){let ce=$t(a,N),Z={...structuredClone(N.text),id:`visual-${N.id}`,type:"text",...lr(ce,N)};Object.assign(Z,ot(N)),T.children.push(Pr(cr(Z,q),a))}if(N.resourceId){let{images:ce={},videos:Z={},spritesheets:_={}}=a,D=_[N.resourceId];if(D){let F=$t(a,N),W=ot(N),ye=na({id:`visual-${N.id}`,resourceId:N.resourceId,spritesheet:D,animationName:N.animationName,animationSpeed:N.animationSpeed,loop:N.loop,width:N.width,height:N.height,transform:{...lr(F,N),alpha:W.alpha??N.alpha??1,...W.blur?{blur:W.blur}:{},...W.filters?{filters:W.filters}:{}}});ye&&T.children.push(structuredClone(ye))}else{let F=ce[N.resourceId]||Z[N.resourceId];if(F){let W=Z[N.resourceId]!==void 0,ye=$t(a,N),ke={id:`visual-${N.id}`,type:W?"video":"sprite",src:F.fileId,width:F.width,height:F.height,...lr(ye,N)};Object.assign(ke,ot(N)),W&&(ke.loop=F.loop??!1,ke.volume=qu(F.volume,p,"soundVolume")),T.children.push(ke)}}}let le=!!(L(a.spritesheets,N.resourceId)||L(a.images,N.resourceId)||L(a.videos,N.resourceId));if(N.resourceId&&!le){let ce=L(a.particles,N.resourceId);ce&&T.children.push(Yb({item:N,particle:ce,resources:a}))}let H=!!L(a.particles,N.resourceId);if(N.resourceId&&!le&&!H){let{layouts:ce={}}=a,Z=L(ce,N.resourceId);if(Z){let _=$t(a,N),D={id:`visual-${N.id}`,type:"container",children:structuredClone(Z.elements),...lr(_,N)};Object.assign(D,ot(N));let F=cr(D,q);F.children=Vr({state:e,elements:F.children,layoutInstanceState:P,rootId:D.id}),T.children.push(Pr(qr(F,{isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}),a))}}let ne=mu(K),ue=mu(N),de=Er({animationsDef:N.animations,resources:a,previousResourceId:ne,currentResourceId:ue,previousTargetId:ne?`visual-${N.id}`:void 0,currentTargetId:ue?`visual-${N.id}`:void 0,animationPath:`visual.items[${N.id}].animations`,idPrefix:N.id});nr({animationInstances:de,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:m,restoredPersistentAnimations:d,isAuthoredOnCurrentLine:M})&&x.push(...de)}}return e},Rt="dialogue-character-sprite",d0=(e,{presentationState:t,previousPresentationState:n,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:o}=e,l=ct(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=Wt(c),m=Wt(u),d=Er({animationsDef:c?.animations,resources:i,previousResourceId:m?Rt:void 0,currentResourceId:p?Rt:void 0,previousTargetId:m?Rt:void 0,currentTargetId:p?Rt:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&nr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...d),e;let f=L(i.transforms,c.transformId);if(!f)return console.warn("Transform not found:",c.transformId),e;let h={type:"container",id:Rt,...lr(f),children:[]};for(let g of c.items){let y=$u({id:`${Rt}-${g.id}`,item:g,resources:i});y&&h.children.push(y)}return l.children.push(h),nr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...d),e},m0=(e,{presentationState:t,previousPresentationState:n,resources:i={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:b,activePersistentAnimations:w,saveSlots:A=[],layoutInstanceState:k})=>{let{elements:P,animations:I}=e;if(!t.dialogue||a)return e;let x=P.find(C=>C.id==="story");if(!x)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:C={}}=i,$=C[t.dialogue.ui.resourceId];if($){let q={elements:$.elements},X=We({variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:b,saveSlots:A,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,characters:i.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),N=cr(q,X),K=Pr(qr(Vr({state:e,elements:N?.elements,layoutInstanceState:k,rootId:"dialogue-container"}),{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),i);if(Array.isArray(K))for(let M of K)x.children.push(M);else K&&x.children.push(K)}}d0(e,{presentationState:t,previousPresentationState:n,resources:i,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:w});let T=Er({animationsDef:t.dialogue.ui?.animations,resources:i,previousResourceId:n?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:n?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return nr({animationInstances:T,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:w})&&I.push(...T),e},y0=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,form:y,activePersistentAnimations:b,saveSlots:w=[],layoutInstanceState:A})=>{let{elements:k,animations:P}=e;if(t.choice&&i){let I=ct(k);if(!I)return e;let x=L(i?.layouts,t.choice.resourceId);if(x&&x.elements){let C={elements:x.elements},$=We({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f??!!t.choice,isFormVisible:h,canRollback:g,form:y,characters:i.characters||{},skipTransitionsAndAnimations:s}),q=cr(C,{...$,choice:{items:(t.choice?.items??[]).map(N=>typeof N?.content!="string"?N:{...N,content:cr(N.content,$)})}}),X=Zo(Pr(qr(Vr({state:e,elements:q?.elements,layoutInstanceState:A,rootId:"choice-container"}),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),i));if(Array.isArray(X))for(let N of X)I.children.push(N);else X&&I.children.push(X)}let T=Er({animationsDef:t.choice.animations,resources:i,previousResourceId:n?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:n?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});nr({animationInstances:T,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:b})&&P.push(...T)}return e},h0=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,activePersistentAnimations:y,saveSlots:b=[],form:w,layoutInstanceState:A})=>{let{elements:k,animations:P}=e;if(!w?.resourceId||!i)return e;let I=ct(k);if(!I)return e;let x=L(i?.layouts,w.resourceId);if(!x)return console.warn(`Form layout not found: ${w.resourceId}`),e;let T={id:"form-container",type:"container",x:0,y:0,children:x.elements||[]},C={...We({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,characters:i.characters||{},skipTransitionsAndAnimations:s,form:w}),form:w},$=cr(T,C),q=ra(Pr(qr(ea($,w),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),i),w);q?.children&&(q.children=Vr({state:e,elements:q.children,layoutInstanceState:A,rootId:q.id})),q&&I.children.push(q);let X=Er({animationsDef:w.animations,resources:i,previousResourceId:n?.form?.resourceId,currentResourceId:w.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:w.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return nr({animationInstances:X,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&P.push(...X),e},g0=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],skipTransitionsAndAnimations:g,layoutInstanceState:y})=>{if(!t.control?.resourceId)return e;let b=L(n.controls,t.control.resourceId);if(!b)return e;let w=a0(b.keyboard,b.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(b.elements)||b.elements.length===0)return e;let A=ct(e.elements);if(!A)return e;let k={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:b.elements};return A.children.push(ua({state:e,container:k,resources:n,templateData:We({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:n.characters||{},skipTransitionsAndAnimations:g}),layoutInstanceState:y,isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},pa=({presentationState:e,previousBgmRender:t,resources:n={},runtime:i,variables:a,musicRoomPlayer:r,skipTransitionsAndAnimations:s=!1})=>{if(e?.bgm&&n){let o=e.bgm,l=!Array.isArray(o.sounds),c=ds(o),u=!l&&o.loop===!0,p=[];if(l||As(c,"BGM sound"),u){let f=c.find(h=>h.loop===!0);if(f)throw new Error(`BGM sound "${f.id}" cannot loop inside a looping BGM channel.`)}let m=_c({bgm:o,resources:n,previousBgmRender:t});if(c.forEach(f=>{let h=L(n.sounds,f.resourceId);if(!h)return;let g=u?{...f,loop:f.loop??!1}:f;p.push(r0({node:Ss({id:m.get(f.id),sound:g,resource:h,projectResources:n,soundPath:`bgm.sounds[${JSON.stringify(f.id)}]`,defaultLoop:!u,skipTransitionsAndAnimations:s}),bgm:o,sound:g,resource:h,usesLegacySound:l}))}),p.length===0)return null;let d=We({variables:a,runtime:i}).runtime;return Es({id:Hb,volume:ca(d,"musicVolume"),muted:!1,pan:0,loop:l?void 0:o.loop,playback:r?.bgmPlayback,interruption:o.interruption,children:p,runtime:d})}return null},b0=(e,t)=>{if(!ct(e.elements))return e;let i=pa(t);return i&&e.audio.push(i),e},w0=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:n})=>(t?.length>0&&!n&&(e.audioEffects=structuredClone(t)),e),I0=(e,{resources:t={},runtime:n,variables:i,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let s=r.tracks.find(u=>u.id===a.trackId),o=s?L(t.sounds,s.soundId):void 0;if(!s||!o)return e;let l=We({variables:i,runtime:n}).runtime,c=Ss({id:Wb,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:o,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(Es({id:Kb,volume:xs(l,"musicVolume",xr),children:[c],runtime:l})),e},v0=(e,{presentationState:t,resources:n,runtime:i,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&n){let s=t.sfx,o=Array.isArray(s.channels)?s.channels:[],l=o.map(c=>({channel:c,usesLegacyChannel:!1}));As(o,"SFX channel"),Array.isArray(s.items)&&l.push({channel:{id:Qb,sounds:s.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,m=[];if(u||As(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let d=c.sounds.find(f=>f.loop===!0);if(d)throw new Error(`SFX sound "${d.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((d,f)=>{let h=L(n.sounds,d.resourceId);if(!h)return;let g=p?{...d,loop:d.loop??!1}:d;m.push(Ss({id:u?or("sfx","default",f,d.id):or("sfx",c.id,d.id),sound:g,resource:h,projectResources:n,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(d.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),m.length!==0&&r.push(Es({id:or("channel","sfx",c.id),volume:xs(i,"soundVolume",c.volume??xr),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:m,runtime:i}))})}return e},k0=(e,t,n)=>{if(!(!t||!n))return L(L(e?.voices,t),n)},A0=(e,{presentationState:t,resources:n,currentSceneId:i,runtime:a,variables:r,skipTransitionsAndAnimations:s})=>{let{audio:o}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:xr,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,m=[];if(c||As(u,"Voice sound"),p){let f=u.find(h=>h.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(f=>{let h=k0(n,i,f.resourceId);if(!h)return;let g=p?{...f,loop:f.loop??!1}:f;m.push(Ss({id:or("voice",i,c?"default":f.id),sound:g,resource:h,projectResources:n,soundPath:`voice.sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:s}))}),m.length===0)return e;let d=We({variables:r,runtime:a}).runtime;return o.push(Es({id:Jb,volume:c?l.volume??ca(d,"soundVolume"):xs(d,"soundVolume",l.volume??xr),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:m,runtime:d})),e},P0=(e,{presentationState:t,previousPresentationState:n,resources:i={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:b,layoutInstanceState:w})=>{let{elements:A,animations:k}=e;if(t.layout){let T=ct(A);if(!T)return e;let C=L(i.layouts,t.layout.resourceId);if(!C)return e;let $={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:C.elements||[]};T.children.push(ua({state:e,container:$,resources:i,templateData:We({variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:i.characters||{},skipTransitionsAndAnimations:y}),layoutInstanceState:w,isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:y}))}let P=n?.layout?.resourceId,I=t.layout?.resourceId,x=Er({animationsDef:t.layout?.animations,resources:i,previousResourceId:P,currentResourceId:I,previousTargetId:P?`layout-${P}`:void 0,currentTargetId:I?`layout-${I}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return nr({animationInstances:x,isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:b})&&k.push(...x),e},x0=(e,{currentLineActions:t,previousPresentationState:n,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:o}=e,l=t?.screen?.animations;if(!l)return e;let c=n!=null,u=Er({animationsDef:l,resources:i,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return nr({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...u),e},E0=(e,{presentationState:t})=>{let n=ct(e.elements);return!n||!t?.screen||Object.assign(n,Lu(t.screen)),e},S0=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:h=[],saveSlots:g=[],screen:y,isLineCompleted:b,skipTransitionsAndAnimations:w,layoutInstanceState:A})=>{let{elements:k}=e;return f&&f.length>0&&f.forEach((P,I)=>{let x=L(n.layouts,P.resourceId);if(!x){console.warn(`Overlay layout not found: ${P.resourceId}`);return}let T={id:`overlayStack-${I}`,type:"container",x:0,y:0,children:[Fu({id:`overlayStack-${I}-blocker`,screen:y}),...x.elements||[]]},C=Bu(h,n.characters,i),$=We({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:g,dialogueState:t?.dialogue,isLineCompleted:b,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:C,characters:n.characters||{},skipTransitionsAndAnimations:w}),q=cr(T,$),[X,...N]=q.children||[],K=Vr({state:e,elements:N,layoutInstanceState:A,rootId:T.id}),M=Pr(qr({...q,children:K},{isLineCompleted:b,skipMode:c,skipTransitionsAndAnimations:w}),n);k.push({...M,children:X?[X,...M.children||[]]:M.children})}),e},O0=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,dialogueHistory:g=[],screen:y,isLineCompleted:b,skipTransitionsAndAnimations:w,layoutInstanceState:A})=>{let{elements:k}=e;if(!h?.resourceId)return e;let P=L(n.layouts,h.resourceId);if(!P)return console.warn(`ConfirmDialog layout not found: ${h.resourceId}`),e;let I={id:"confirmDialog",type:"container",x:0,y:0,children:[Fu({id:"confirmDialog-blocker",screen:y}),...P.elements||[]]},x=Bu(g,n.characters,i),T=cr(I,We({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:b,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,historyDialogue:x,characters:n.characters||{},skipTransitionsAndAnimations:w})),[C,...$]=T.children||[],q=Vr({state:e,elements:$,layoutInstanceState:A,rootId:I.id}),X=Pr(qr({...T,children:q},{isLineCompleted:b,skipMode:u,skipTransitionsAndAnimations:w}),n);return k.push({...X,children:C?[C,...X.children||[]]:X.children}),e},yn=e=>(t,n)=>f0(t,{...n,visualLayer:e}),R0=yn(Ar.BEHIND_BACKGROUND),$0=yn(Ar.BEHIND_CHARACTER),C0=yn(Ar.BEHIND_DIALOGUE),_0=yn(Ar.BEHIND_CHOICE),N0=yn(Ar.FOREGROUND),Yu=e=>{let n=ts(l0,[g0,R0,c0,$0,u0,C0,m0,_0,y0,h0,P0,N0,E0,x0,b0,I0,v0,A0,w0,S0,O0]),i={usedIds:new Set,claimedNamespaces:new Set},a=Array.isArray(e)?e.map(r=>({...r,layoutInstanceState:i})):{...e,layoutInstanceState:i};return n(a)};function zu(e,t=""){let n=[],i=e.length,a=0,r=0,s=-1,o=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<i;){let l=s+1+o();s=l+o(),n.push([l,s,t?parseInt(t[r++],36):0])}return n}function Xu(e,t,n){let i=0,a=t.length-1;for(;i<=a;){let r=i+a>>>1,s=n[r];if(e<t[r])a=r-1;else if(e>s>>>5)i=r+1;else return s&31}return 0}var Gu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Hu="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Ku="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Wu=65535,fa=40960,Os=126976,Zu=new Uint8Array(12288),ep=new Uint8Array(3072),rp=new Uint8Array(2816),tp,np;{let e=(a,r,s,o,l)=>{let c=r+a.length-1;for(let u=s<r?r:s,p=o>c?c:o;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),n=new Uint32Array(320),i=0;for(let[a,r,s]of zu(Gu,Hu))e(Zu,0,a,r,s),e(ep,fa,a,r,s),e(rp,Os,a,r,s),r>=65040&&!(a>=Os&&r<=129791)&&(t[i]=a,n[i++]=r<<5|s);tp=t.slice(0,i),np=n.slice(0,i)}function Ju(e){return e<12288?Zu[e]:e<fa?e<12336?e>=12330?3:0:e<12443?e===12336||e===12349?4:e>=12441?3:0:e===12951||e===12953?4:0:e<44032?ep[e-fa]:e<55204?(e-44032)%28?8:7:e<57344?e<=55238?e>=55216?13:0:e>=55243&&e<=55291?12:0:e<65024?e===64286?3:0:e<65040?3:e>=Os&&e<129792?rp[e-Os]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Xu(e,tp,np)}var sp=Uint8Array.from(Ku,Number);function j0(e){return e===2381||e===2509||e===2637||e===2765||e===2893||e===3149||e===3405||e===4153||e===6098||e===6752||e===6980||e===7083||e===43456||e===43766||e===68159||e===69939||e===70608||e===71998||e===72263||e===72345||e===73538}function Qu(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||j0(n)?e&6|16:e&6|8:e&6;case 4:return 2;case 10:return e&1^1;case 14:return(e&2)<<1|e&24;default:return 8}}function*ip(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),i=n>Wu?2:1,a=Ju(n),r=50200>>a&1?Qu(0,a,n):0,s=0,o=n,l=a;for(;i<t;){n=e.codePointAt(i);let c=n>Wu?2:1,u=Ju(n),p=sp[a<<4|u],m;p===0?m=!0:p===1?m=!1:p===2?m=!(r&1):p===3?m=!(r&4):m=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?Qu(r,u,n):0,m&&(yield{segment:e.slice(s,i),index:s,input:e,_hd:o,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=i,o=n,l=u),i+=c,a=u}yield{segment:e.slice(s),index:s,input:e,_hd:o,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*op(e){for(let t of ip(e))yield t.segment}{let e=ip("_");sp._keep=[e,e.next()]}var ap=1e3,yp=50,T0=0,lp=100,cp=50,D0=60,L0=3,M0=.5,V0=2e4,q0=[[4352,4607],[11904,11929],[11931,12019],[12032,12245],[12293,12293],[12295,12295],[12321,12329],[12334,12335],[12344,12347],[12353,12438],[12445,12447],[12449,12538],[12541,12543],[12593,12686],[12784,12830],[12896,12926],[13008,13054],[13056,13143],[13312,19903],[19968,40959],[43360,43388],[44032,55203],[55216,55238],[55243,55291],[63744,64109],[64112,64217],[65382,65391],[65393,65437],[65440,65470],[65474,65479],[65482,65487],[65490,65495],[65498,65500],[94178,94179],[94192,94198],[110576,110579],[110581,110587],[110589,110590],[110592,110882],[110898,110898],[110928,110930],[110933,110933],[110948,110951],[127488,127488],[131072,173791],[173824,178205],[178208,183981],[183984,191456],[191472,192093],[194560,195101],[196608,201546],[201552,210041]],F0=[[9,13],[32,32],[160,160],[5760,5760],[8192,8202],[8232,8233],[8239,8239],[8287,8287],[12288,12288],[65279,65279]],hp=(e,t)=>{let n=0,i=e.length-1;for(;n<=i;){let a=n+i>>1,[r,s]=e[a];if(t<r)i=a-1;else if(t>s)n=a+1;else return!0}return!1},B0=e=>{for(let t of e)if(!hp(F0,t.codePointAt(0)))return!1;return!0},U0=e=>{for(let t of e)if(hp(q0,t.codePointAt(0)))return!0;return!1},Y0=e=>Array.from(op(`${e??""}`)),z0=e=>Y0(e).reduce((t,n)=>B0(n)?t+M0:U0(n)?t+L0:t+1,0),Rs=new DataView(new ArrayBuffer(8)),X0=128,up=64n,pp=new Map,G0=e=>{let t=pp.get(e);if(t===void 0){let n=1n<<BigInt(e)+up,i=0n;for(let a=1n;n>>a!==0n;a+=1n)i+=(n>>a)/a;t=i>>up,pp.set(e,t)}return t},fp=(e,t)=>{let n=BigInt(e.toString(2).length-53),i=e>>n,a=e-(i<<n),r=1n<<n-1n;(a>r||a===r&&(i&1n)===1n)&&(i+=1n);let s=n-BigInt(t);return i===1n<<53n&&(i>>=1n,s+=1n),Rs.setBigUint64(0,s+1075n<<52n|i-(1n<<52n)),Rs.getFloat64(0)},H0=e=>{if(e===0)return 1;if(e===1)return 2;if(e===-1)return .5;Rs.setFloat64(0,e);let t=Rs.getBigUint64(0),n=Number(t>>52n&0x7ffn),i=t&(1n<<52n)-1n,a=n===0?i:i|1n<<52n,r=t>>63n===1n?-a:a,s=1075-Math.max(n,1);for(let o=X0;;o*=2){let l=1n<<BigInt(o),c=r*G0(o),u=s>=0?c>>BigInt(s):c<<BigInt(-s),p=l,m=l,d=1;for(let y=1n;p!==0n;y+=1n)p=p*u/(l*y),m+=p,d+=1;let f=BigInt(4*d+16),h=fp(m-f,o),g=fp(m+f,o);if(h===g)return h}},dp=0,mp=1,K0=e=>{let n=((Number.isFinite(e)?Math.min(lp,Math.max(T0,e)):yp)-cp)/(lp-cp);return n!==dp&&(mp=H0(n),dp=n),mp},da=({text:e="",baseDelay:t=ap,speed:n=yp}={})=>{let i=Number.isFinite(t)?Math.max(0,t):ap,a=K0(n),r=z0(e)*D0/a,s=Math.max(i,V0);return Math.min(i+r,s)};var $s={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Ap=1,Pp=6,Sr=1,jt="choice",Br="form",wn=()=>({manual:{...$s.manual},auto:{...$s.auto},applyMode:$s.applyMode}),xa=()=>({groupId:null,variantId:null,pageIndex:0}),W0="music-room:player",J0=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),Ns=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Ea=new Set,Q0=new Set(["groupId","variantId"]),Z0=new Set(["pageIndex"]),Tt=new Set,ew=new Set(["trackId"]),rw=new Set(["positionMs"]),tw=new Set(["pageIndex"]),Sa=new Set,nw=new Set(["sceneId"]),sw=new Set(["pageIndex"]),Oa=()=>({pageIndex:0}),Ra=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...wn()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},ya=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},B=e=>{let t=Ie(e)?Ge(e):e;return structuredClone(t)},U=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),js=e=>{let t=e.global.audioCommandId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal audio command counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=t+1,e.global.audioCommandId},xp=e=>{let t=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal scene replay entry counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=t+1,e.global.sceneReplayEntryId},In=(e,t,n)=>({commandId:js(e),operation:t,...n===void 0?{}:{positionMs:n}}),$a=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:js(e),operation:"resume"}),e.global.musicRoomPlayer=Ns({bgmPlayback:n})},Ep=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=L(e.projectData.resources?.achievements,t);if(!n)throw new Error(`Achievement resource "${t}" not found`);if(n.type!=="boolean"&&n.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${n.type}"`);return n},Sp=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let n=typeof e=="string"&&e.length>0,i=typeof e=="number"&&Number.isFinite(e);if(!n&&!i)throw new Error(`${t} requires a non-empty string or finite number slotId`)},ft=e=>String(e),Op=()=>({sections:[],resources:[]}),Rp=()=>({sceneIds:[]}),iw=e=>U(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Op(),ow=e=>U(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):Rp(),aw=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",lw=({sectionId:e,lineId:t,content:n,dialogueState:i,characterName:a})=>({sectionId:e,lineId:t,content:n,text:aw(n),characterId:i.characterId,character:{...i.character||{},name:a},characterName:a}),$p=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),cw=e=>U(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,Ca=e=>{if(!U(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},uw=e=>{if(!U(e?.dialogueHistory))return e.dialogueHistory=$p(e?.rollback?.timeline?.length??0),e.dialogueHistory;let t=e.dialogueHistory;return Array.isArray(t.entries)||(t.entries=[]),Number.isInteger(t.currentLength)||(t.currentLength=t.entries.length),Array.isArray(t.checkpointLengths)||(t.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),t.currentLength=Math.min(Math.max(t.currentLength,0),t.entries.length),t},_a=e=>{let t=Ca(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},pw=()=>({resourceId:void 0}),fw=e=>{if(!U(e))return e;let t={...e};return Object.prototype.hasOwnProperty.call(t,"requireComplete")&&!Object.prototype.hasOwnProperty.call(t,"requireLineCompleted")&&(t.requireLineCompleted=t.requireComplete),delete t.requireComplete,t},Qe=(e,t)=>{let n=e?.story?.scenes??{};for(let[i,a]of Object.entries(n)){let r=L(a?.sections,t);if(r)return{sceneId:i,section:r}}return{sceneId:void 0,section:void 0}},Cp=e=>{let t=e?.story?.scenes??{},n=new Map;for(let[i,a]of Object.entries(t)){let r=a?.sections??{};for(let s of Object.keys(r)){let o=n.get(s);if(o!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${o}" and "${i}". Section IDs must be globally unique.`);n.set(s,i);let l=L(r,s)?.lines,c=new Map;Array.isArray(l)&&l.forEach((u,p)=>{if(typeof u?.id=="string"){if(c.has(u.id))throw new Error(`Duplicate lineId "${u.id}" in scene "${i}", section "${s}": lines[${p}] duplicates lines[${c.get(u.id)}]. Line IDs must be unique within a section.`);c.set(u.id,p)}})}}},_p=e=>e,Np=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Ap)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},dw=(e,t={})=>{let n;try{n=Np(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let i={...t,formatVersion:n,slotId:_p(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete i.slotKey,delete i.date,i},mw=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,dw(t,n)])),yw=(e,t)=>{if(!U(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(i=>{if(!U(i))return!1;let{variableId:a,op:r,value:s,roundTo:o}=i,l=L(t?.resources?.variables,a);if(!l||Ne(l)||l.readonly===!0||l.scope!=="context")return!1;try{return nn(l.type,r,a),is(l.type,r,s,a,{roundTo:o}),r!=="set"||Ao(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},jp=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(i=>{if(!U(i)||!tk(i.type))return[];if(i.type!=="updateVariable"||t===void 0)return[i];let a=yw(i.payload,t);return a?[{...i,payload:a}]:[]});return n.length>0?n:void 0},hw=(e,t,n)=>{let{section:i}=Qe(e,t?.sectionId),r=i?.lines?.find(({id:o})=>o===t?.lineId)?.actions,s=n.split(".");for(let o of s){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(o))return;let l=Number(o);if(!Object.prototype.hasOwnProperty.call(r,l))return;r=r[l];continue}if(!U(r)||!Object.prototype.hasOwnProperty.call(r,o))return;r=r[o]}return s.at(-1)==="random"&&U(r?.distribution)?r:void 0},Tp=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let t=e.max-e.min+1;return Number.isSafeInteger(t)&&t>=1&&t<=4294967296},Dp=(e,t,n)=>e.filter(({path:i,type:a,result:r})=>{let s=hw(n,t,i);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return U(s.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let o=L(n?.resources?.variables,s.variableId);return typeof s.variableId=="string"&&o?.type==="number"&&o.scope==="context"&&o.readonly!==!0&&!Ne(o)&&Tp(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),Na=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==Sr)throw new Error(`unsupported rollback random outcome version: ${e.randomOutcomeVersion}`);if(!Array.isArray(e.randomOutcomes))throw new Error("versioned rollback random outcomes must be an array");let n=new Set,i=e.randomOutcomes.map((a,r)=>{let s=`${a?.path}\0${a?.ordinal}`;if(!U(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||n.has(s))throw new Error(`invalid rollback random outcome at index ${r}`);return n.add(s),{path:a.path,ordinal:a.ordinal,type:a.type,result:cs(B(a.result),a.type)}});return t===void 0?i:Dp(i,e,t)},gw=(e,t)=>{!U(e)||!Array.isArray(e.timeline)||e.timeline.forEach(n=>{if(!U(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let i=jp(n.executedActions,t);i?n.executedActions=i:delete n.executedActions;let a=Na(n,t);a?(n.randomOutcomeVersion=Sr,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},bw=(e,t)=>{let n=e??{};return Object.values(n).forEach(i=>{let a=i?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let s=r?.rollback?.timeline;Array.isArray(s)&&s.forEach(o=>{if(!U(o))return;let l=Na(o,t);l?(o.randomOutcomeVersion=Sr,JSON.stringify(o.randomOutcomes)!==JSON.stringify(l)&&(o.randomOutcomes=l)):(delete o.randomOutcomeVersion,delete o.randomOutcomes)})})}),n},gp=(e,t,n,i="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!U(e))throw new Error(`Malformed ${i}.${t}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${i}.${t}[${n}] entry: missing ${a}.`);if(t==="sections"){let r={sectionId:e.sectionId};if(e.lastLineId!==void 0&&e.lastLineId!==null&&typeof e.lastLineId!="string")throw new Error(`Malformed ${i}.sections[${n}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},ww=(e,t="viewedRegistry")=>{if(e===void 0)return Op();if(!U(e))throw new Error(`Malformed ${t}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${t}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${t}.resources.`);let n=e.sections??[],i=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,r)=>{let s=gp(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(i.map((a,r)=>{let s=gp(a,"resources",r,t);return[s.resourceId,s]})))}},Iw=(e,t="accountReplayRegistry")=>{if(e===void 0)return Rp();if(!U(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let n=e.sceneIds??[];return{sceneIds:[...new Set(n.map((i,a)=>{if(typeof i!="string"||i.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return i}))]}},hn=(e,t,n)=>{if(!U(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:i,lineId:a}=e;if(typeof i!="string"||i.length===0)throw new Error(`Malformed save slot ${n}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${n}: missing lineId.`);let{sceneId:r,section:s}=Qe(t,i);if(!s)throw new Error(`Malformed save slot ${n}: section "${i}" does not exist in projectData.`);if(!s.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${n}: line "${a}" does not exist in section "${i}".`);return{sceneId:r,sectionId:i,lineId:a}},Lp=e=>{let t=e.story.initialSceneId,n=L(e.story.scenes,t),i=n.initialSectionId,a=L(n.sections,i);return hn({sceneId:t,sectionId:i,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},vw=e=>{try{return Lp(e),!0}catch{return!1}},kw=(e,t,n)=>{let i=e?.pointers?.read;if(!U(i)||typeof i.sectionId!="string"||i.sectionId.length===0||typeof i.lineId!="string"||i.lineId.length===0)return hn(i,t,n);try{return hn(i,t,n)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],r=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let s=r;s>=0;s-=1)try{return hn(a[s],t,`${n} compatibility checkpoint`)}catch{}return Lp(t)}};var Mp=(e,t)=>{let{section:n}=Qe(e,t?.sectionId);return n?.lines?.find(i=>i.id===t?.lineId)},Aw=(e,t,n)=>{if(!U(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let i=[],a=[0],r=!1;if(e.entries.forEach((o,l)=>{if(!U(o))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof o.sectionId!="string"||o.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof o.lineId!="string"||o.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(o.appendToPrevious!==void 0&&typeof o.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:c}=Qe(t,o.sectionId);if(!c?.lines?.some(p=>p.id===o.lineId)){r=!1,a.push(i.length);return}i.push({sectionId:o.sectionId,lineId:o.lineId,...o.appendToPrevious===!0&&r&&i.length>0?{appendToPrevious:!0}:{}}),r=!0,a.push(i.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${n}.currentLength: must reference the retained entries.`);let s=e.checkpointLengths.map((o,l)=>{if(!Number.isInteger(o)||o<0||o>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[o]});return{entries:i,currentLength:a[e.currentLength],checkpointLengths:s}},Pw=(e,t)=>U(Mp(e,t)?.actions?.dialogue),Vp=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:i}=Qe(e,n.sectionId),a=i?.lines?.findIndex(s=>s.id===n.lineId);return typeof a!="number"||a<=0?!1:i.lines.slice(0,a).findLast(s=>U(s.actions?.dialogue))?.id===t.lineId},xw=(e,t)=>{let n=$p();return e.timeline.forEach(i=>{if(i.returnable!==!1&&Pw(t,i)){let a=Mp(t,i),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&Vp(t,r,i);n.entries.push({sectionId:i.sectionId,lineId:i.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},Ew=(e,t,n,i)=>{if(n.length!==t.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==i)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=n.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,s)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);a=r}),e},Sw=(e,t,n)=>{if(!U(e)||!Array.isArray(e.timeline))return{rollback:bn({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let i=[],a=e.timeline.flatMap((c,u)=>{if(!U(c))return[];let p=Na(c);try{let m=hn(c,n,`rollback.timeline[${u}]`),d=p?Dp(p,m,n):void 0,f=_s({sectionId:m.sectionId,lineId:m.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...d?{randomOutcomeVersion:Sr,randomOutcomes:d}:{}}),h=jp(B(c.executedActions),n);return h&&(f.executedActions=h),i.push(u),[f]}catch{return[]}});if(a.length===0)return{rollback:bn({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,s=i.indexOf(r);s<0&&(s=a.length-1);let o=a[s];if(o?.sectionId!==t.sectionId||o?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?s=c:(a.push(_s({sectionId:t.sectionId,lineId:t.lineId})),i.push(null),s=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),s):0;return{rollback:{currentIndex:s,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:i,sourceTimelineLength:e.timeline.length}},qp=(e,t,n)=>{if(!U(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let i=Da(t),a=kw(e,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!U(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!U(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?rn(B(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=Vw({loadedContextRuntime:U(e.runtime)?B(e.runtime):{}}),{rollback:o,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Sw(e.rollback,a,t),u=e.dialogueHistory===void 0?xw(o,t):Ew(Aw(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),o,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:U(e.configuration)?B(e.configuration):{},views:Array.isArray(e.views)?B(e.views):[],bgm:U(e.bgm)?B(e.bgm):{resourceId:void 0},variables:{...i,...r},...u?{dialogueHistory:u}:{},rollback:o};return s&&(p.runtime=s),p},Ow=(e,t)=>{if(!U(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((n,i)=>qp(n,t,i))}},Rw=(e,t)=>{if(!U(e))throw new Error("Malformed save slot.");let n=Np(e.formatVersion);return{...e,formatVersion:n,state:Ow(e.state,t)}},bp=(e,t,{required:n=!1}={})=>{if(e===void 0){if(n)throw new Error(`showConfirmDialog requires ${t}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${t} must be an action object`);let i=B(e),a=i.hideConfirmDialog??{};return delete i.hideConfirmDialog,{hideConfirmDialog:a,...i}},$w=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:bp(e.confirmActions,"confirmActions",{required:!0}),cancelActions:bp(e.cancelActions,"cancelActions")}},Dt=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Cw=e=>(U(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Lt=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Fp=e=>{if(!(!U(e)||!e.animations))return{animations:B(e.animations)}},_w=(e,t)=>{let n=Fp(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Nw=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},jw=(e,t)=>{let n=e?.sectionId,i=e?.lineId;if(!(!n||!i||!t))return`${n}:${i}:${t}`},Cs=e=>String(e??""),Bp=(e,t)=>{let n=Cs(t);return e?.trim===!0?n.trim():n},Tw=e=>U(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>U(t)).map(([t,n])=>[t,{id:t,...B(n)}])):{},Dw=(e,t)=>{if(!t||!U(e.global.formDrafts))return;let n=e.global.formDrafts[t];return U(n)?n:void 0},Up=(e,t)=>{let n=Cw(e);U(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let i=n[t];return U(i.values)||(i.values={}),U(i.touched)||(i.touched={}),U(i.errors)||(i.errors={}),typeof i.submitted!="boolean"&&(i.submitted=!1),i},ja=(e,t)=>{let n=Bp(e,t);return e?.required===!0&&n.length===0?"required":null},Ta=({state:e,pointer:t},n=0)=>{if(t?.sectionId==null||t?.lineId==null)return n<0?null:{};let i=Ie(e.projectData)?Ge(e.projectData):e.projectData,{section:a}=Qe(i,t.sectionId);return ru(i,a,t.lineId,n)},Lw=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let i=Nw(t),a=jw(n,i);if(!i||!a)return null;let r=Dw(e,a),s=Tw(t),o=Ka({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=Cs(o?.[d.variableId]),h=Object.prototype.hasOwnProperty.call(r?.values??{},m)?Cs(r.values[m]):f,g=r?.touched?.[m]===!0,y=ja(d,h),b=r?.submitted||g?y:null,w=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,A={id:m,variableId:d.variableId,value:h,initialValue:f,valid:!y,error:b,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...w!==void 0?{maxLength:w}:{}};y&&(p=!1),l[m]=A,c.push(A),u[m]=h}),{id:i,key:a,resourceId:t.resourceId,animations:t.animations,valid:p,submitted:r?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:B(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:B(t.cancelActions??{})}}}},Nt="line",Fr="interaction",_s=({sectionId:e,lineId:t,rollbackPolicy:n,returnable:i,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:n??"free",...typeof i=="boolean"?{returnable:i}:{},...a===Sr?{randomOutcomeVersion:Sr,randomOutcomes:B(r??[])}:{}}),Da=e=>{let t=Ie(e)?Ge(e):e,{contextVariableDefaultValues:n}=ss(t??{});return B(n)},Yp=()=>({...B(un)}),zp=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:i})=>{if(e===void 0)return{runtimeState:B(n),hasLoadedValues:!1};if(!U(e))throw new Error(`Malformed ${i}.`);let a=B(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=gs(s,B(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Mw=({projectData:e,loadedGlobalRuntime:t={}})=>zp({loadedRuntime:t,runtimeIds:Lo,defaults:Vo(e),path:"global.runtime"}).runtimeState,Vw=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=zp({loadedRuntime:e,runtimeIds:Mo,defaults:Yp(),path:"context.runtime"});return n?t:void 0},Yr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},be=e=>{let t=Yr(e);return t?.kind==="sceneReplay"&&U(t.sceneReplay)?t:null},Xp=(e,t)=>{let n=t?.sceneReplay?.sceneId,i=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(i?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=B(r)})},qw=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:B(e.global.nextLineConfig),overlayStack:B(e.global.overlayStack),confirmDialog:B(e.global.confirmDialog),formDrafts:B(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:B(e.global.pendingScreenTransition)}}),Fw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=wn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Bw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=B(t.nextLineConfig),e.global.overlayStack=B(t.overlayStack),e.global.confirmDialog=B(t.confirmDialog),e.global.formDrafts=B(t.formDrafts),e.global.isLineCompleted=t.isLineCompleted,t.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=t.isDialogueHistoryShowing,t.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=B(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=Re({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e.global.skipMode&&!n&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!n&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},Uw=e=>e.runtime?(Mo.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=B(un[t]))}),e.runtime):(e.runtime=Yp(),e.runtime),Yw=e=>su(e.global),Gp=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Yw(e)}})},La=(e,t,n)=>{let i=gs(t,n);if(t in un){let a=Yr(e);if(!a)return i;let r=Uw(a);return r[t]=i,i}return e.global[t]=i,i},Ma=({pointer:e,projectData:t,kind:n,sceneReplay:i})=>({...n===void 0?{}:{kind:n},...i===void 0?{}:{sceneReplay:B(i)},currentPointerMode:"read",pointers:{read:B(e)},configuration:{},views:[],bgm:pw(),variables:Da(t),rollback:bn({pointer:e})}),Mt=e=>e?(e.currentPointerMode="read",U(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,zw=(e,{queueRender:t=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],i=n?.pointers?.read;if(!n||!i?.sectionId||!i?.lineId)return null;let a=Ma({pointer:i,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Xw(e,{queueRender:t}),a},Xw=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,Dt(e),Lt(e),e.global.nextLineConfig=wn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,$a(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Hp=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},bn=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[_s({sectionId:e.sectionId,lineId:e.lineId})]:[]}},zr=(e,t={})=>{if(e?.rollback)return Hp(e.rollback),Array.isArray(e.rollback.timeline)||(e.rollback.timeline=[]),typeof e.rollback.currentIndex!="number"&&(e.rollback.currentIndex=e.rollback.timeline.length>0?e.rollback.timeline.length-1:-1),typeof e.rollback.isRestoring!="boolean"&&(e.rollback.isRestoring=!1),typeof e.rollback.replayStartIndex!="number"&&(e.rollback.replayStartIndex=0),e.rollback;let n=e?.pointers?.read;return e.rollback=bn({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},Ts=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let i=zr(n);if(i.isRestoring)return;let a=_a(n);i.currentIndex<i.timeline.length-1&&(i.timeline=i.timeline.slice(0,i.currentIndex+1)),i.timeline.push(_s(t)),i.currentIndex=i.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,i.currentIndex),a.checkpointLengths.push(a.currentLength))},Gw=({state:e})=>{let n=e.contexts?.[e.contexts.length-1]?.rollback;return!Array.isArray(n?.timeline)||typeof n.currentIndex!="number"?null:{checkpointIndex:n.currentIndex,checkpoint:n.timeline[n.currentIndex]??null}},Hw=({state:e},t={})=>{let{checkpointIndex:n,checkpointIdentity:i,sectionId:a,lineId:r}=t,o=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(o?.timeline)||typeof o.currentIndex!="number")return e;let l=o.timeline[n];return(Ie(l)?Yn(l):l)!==i||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},Kw=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:i,checkpointIndex:a,sectionId:r,lineId:s}=t,o=ft(n),l=e.global.saveSlots?.[o],c=Ie(l)?Yn(l):l;if(!l||c!==i)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,m=p?.rollback,d=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==s||d?.sectionId!==r||d?.lineId!==s||(d.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Kp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1],i=n?.rollback;if(!i||i.isRestoring||!Array.isArray(i.timeline)||typeof i.currentIndex!="number")return null;let a=t?.at(-1),r=typeof a?.checkpointIndex=="number"?a.checkpointIndex:i.currentIndex;if(r<0||r>=i.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&r<i.timeline.length-1){i.timeline=i.timeline.slice(0,r+1);let s=_a(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return i.timeline[r]??null},Ww=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},i={})=>{let a=i?.source===Nt?Nt:Fr,r=e.contexts?.[e.contexts.length-1],s=r?.rollback;if(!s||s.isRestoring||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"||s.currentIndex<0||s.currentIndex>=s.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(s.currentIndex<s.timeline.length-1){s.timeline=s.timeline.slice(0,s.currentIndex+1);let u=_a(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let o=r?.pointers?.read,l=n?.lineEntryId,c=a===Nt&&(n?.rollbackCheckpointLineEntryId===void 0?s.timeline[s.currentIndex]?.sectionId===o?.sectionId&&s.timeline[s.currentIndex]?.lineId===o?.lineId:n.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:s.currentIndex,source:a,...a===Nt?{lineEntryId:l,sourcePointer:o?{sectionId:o.sectionId,lineId:o.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},Jw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),Qw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let i=t?.at(-1);if(i?.source!==Nt||i.hasTrackedLineEntryCheckpoint)return e;let a=i.sourcePointer;if(!a)return e;Ts(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let s=(e.contexts?.at(-1)).rollback;return i.checkpointIndex=s.currentIndex,i.hasTrackedLineEntryCheckpoint=!0,n?.lineEntryId===i.lineEntryId&&(n.rollbackCheckpointLineEntryId=i.lineEntryId),e},Zw=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==Nt)return e;if(typeof n?.path!="string"||n.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(n.ordinal)||n.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=cs(n.result,n.type),r=Kp(e,t);if(!r)return e;if(r.randomOutcomeVersion!==Sr&&(r.randomOutcomeVersion=Sr,r.randomOutcomes=[]),r.randomOutcomes.some(({path:s,ordinal:o})=>s===n.path&&o===n.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${n.path}#${n.ordinal}`);return r.randomOutcomes.push({path:n.path,ordinal:n.ordinal,type:n.type,result:a}),e},ur=(e,t,n,i)=>{let r=i?.at(-1)?.source??Fr;if(!nk(t,r))return;let s=Kp(e,i);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:B(n)}))},ha=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let i=t?.operations??[];for(let{variableId:a,op:r,value:s,roundTo:o}of i){let l=L(e.projectData.resources?.variables,a),c=l?.scope,u=l?.type;if(Ne(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);tn(c,a),nn(u,r,a),is(u,r,s,a,{roundTo:o}),c==="context"&&(n.variables[a]=os(n.variables[a],r,s,{roundTo:o}))}},eI=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:i})=>{sk(e,n,i)})},rI=(e,t)=>{let{sectionId:n,lineId:i}=t,s=Ve({state:e},{sectionId:n})?.lines?.find(o=>o.id===i)?.actions;s&&Za(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},Wp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let i=zr(n),a=i.timeline[t];if(!a)return e;e.global.autoMode&&Pn({state:e}),e.global.skipMode&&Ur({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),i.isRestoring=!0,i.currentIndex=t;try{n.variables=Da(e.projectData),n.kind==="sceneReplay"&&(Xp(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=B($s),e.global.overlayStack=[],Dt(e),Lt(e),e.global.isLineCompleted=!0;let r=i.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&Ra(e),rI(e,i.timeline[l]),eI(e,i.timeline[l]);let s=Mt(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let o=Ca(n);o&&(o.currentLength=Math.min(o.checkpointLengths[t]??0,o.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=xp(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{i.isRestoring=!1}return e},tI=e=>{let{projectData:t}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let i=e.global??{},{saveSlots:a={},variables:r={},runtime:s={},accountViewedRegistry:o={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=i;Cp(t),Qt(t),Zt(t),en(t),nt(t?.resources?.variables??{});let u=t.story.initialSceneId,p=L(t.story.scenes,u),m=p.initialSectionId,d=L(p.sections,m),f={sceneId:u,sectionId:m,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:h}=ss(t),g={...h,...rn(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:ww(o,"accountViewedRegistry"),accountReplayRegistry:Iw(l),nextLineConfig:wn(),imageGalleryNavigation:xa(),sceneReplayNavigation:Oa(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:Ns(),saveSlots:mw(a),localizationPackages:B(c),overlayStack:[],variables:g,...Mw({projectData:t,loadedGlobalRuntime:s})},contexts:[Ma({pointer:f,projectData:t})]}},nI=({state:e})=>e.global.overlayStack||[],sI=({state:e})=>e.global.pendingEffects,Jp=({state:e})=>e.global.skipMode,iI=({state:e})=>e.global.autoMode,Qp=({state:e})=>e.global.dialogueUIHidden,wp=new WeakMap,oI=8,Zp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let i,a=U(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(a)i=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:p,lineId:m}=n.pointers.read,d=Ve({state:e},{sectionId:p});if(!d?.lines||!Array.isArray(d.lines))return[];let f=Fe(d.lines,m);i=d.lines.slice(0,f+1).map(h=>({sectionId:p,lineId:h.id}))}let r=[],s=Pt({variables:{...e.global?.variables??{},...Yr(e)?.variables??{}},runtime:kr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),o=Ie(e.projectData)?Ge(e.projectData):e.projectData,l=Object.isFrozen(o)?wp.get(o):void 0;l||(l=new Map,Object.isFrozen(o)&&wp.set(o,l));let c=new Map(l),u=p=>{let m=c.get(p.sectionId);if(!m){let{section:h}=Qe(o,p.sectionId);m={lines:Array.isArray(h?.lines)?h.lines:[],projections:new Map,nextLineIndex:0,presentationState:{}},c.set(p.sectionId,m)}if(l.delete(p.sectionId),l.set(p.sectionId,m),l.size>oI&&l.delete(l.keys().next().value),m.projections.has(p.lineId))return m.projections.get(p.lineId);let d=Fe(m.lines,p.lineId);if(d<0)return null;let f=m.lines[d].actions||{};if(!f.dialogue)return m.projections.set(p.lineId,null),null;for(;m.nextLineIndex<=d;){let h=m.lines[m.nextLineIndex],g=m.nextLineIndex===d?f:h.actions||{};m.presentationState=it([m.presentationState,g],{resources:o.resources});let y=m.presentationState.dialogue||{};m.projections.set(h.id,g.dialogue?{line:h,lineActions:g,dialogueState:{characterId:y.characterId,character:y.character,...g.dialogue.append===!0?{content:y.content}:{}}}:null),m.nextLineIndex+=1}return m.projections.get(p.lineId)??null};for(let p of i){if(!cw(p))continue;let m=u(p);if(!m)continue;let{line:d,lineActions:f,dialogueState:h}=m;if(!f.dialogue)continue;let g=ns({characterId:h.characterId,character:h.character,characters:e.projectData.resources?.characters??{},variables:s}),y=lw({sectionId:p.sectionId,lineId:d.id,content:f.dialogue.append===!0?h.content:f.dialogue.content,dialogueState:h,characterName:g}),b=r[r.length-1];if((a?p.appendToPrevious===!0:f.dialogue.append===!0)&&b?.sectionId===p.sectionId){r[r.length-1]={...r[r.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}r.push(y)}return r},aI=(e,t,n)=>{let i=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:s,sectionId:o,lineId:l}=a,c=e.global.saveSlots?.[ft(r)],u=Ie(c)?Yn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==o||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=B(n),i=!0)}i&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},lI=({state:e},t={})=>{let n=Yr(e),i=n?.pointers?.read,a=kn({state:e});if(!n||!U(a?.actions?.dialogue))return e;let r=zr(n),s=r.timeline?.[r.currentIndex],o=s?.sectionId===i?.sectionId&&s?.lineId===i?.lineId,l=Ca(n),c=l?.checkpointLengths?.[r.currentIndex],u=r.currentIndex>0?l?.checkpointLengths?.[r.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(t.reuseExistingOccurrence===!0&&p?.sectionId===i.sectionId&&p?.lineId===i.lineId||t.forceNewOccurrence!==!0&&o&&l&&c===l.currentLength&&c>u&&p?.sectionId===i.sectionId&&p?.lineId===i.lineId)return e;let m=uw(n);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&Vp(e.projectData,p,i);if(m.entries.push({sectionId:i.sectionId,lineId:i.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,o){for(;m.checkpointLengths.length<r.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[r.currentIndex]=m.currentLength}return aI(e,t.savedCheckpointOccurrences,m),e},cI=({state:e})=>e.global.confirmDialog??null,vn=({state:e},{pointer:t}={})=>{let n=t??Be({state:e})?.pointer,i=Ta({state:e,pointer:n});return Lw({state:e,form:i.form,pointer:n})},uI=({state:e},{pointer:t}={})=>!!vn({state:e},{pointer:t}),Re=({state:e},{pointer:t}={})=>{let n=vn({state:e},{pointer:t});if(n)return{source:Br,formId:n.id,formKey:n.key};let i=of({state:e,pointer:t});return i?{source:jt,resourceId:i}:null},pI=({state:e,registry:t},n)=>{let{sectionId:i,lineId:a}=n,s=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===i);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let o=Ve({state:e},{sectionId:i});if(!o||!o.lines||!Array.isArray(o.lines))return s.lastLineId===a;let l=Fe(o.lines,s.lastLineId),c=Fe(o.lines,a);return l===-1||c===-1?s.lastLineId===a:c<=l},Va=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},qa=({state:e},t)=>pI({state:e,registry:e.global.accountViewedRegistry},t),fI=({state:e},t)=>Va({registry:e.global.accountViewedRegistry},t),gn=(e,t)=>!Va({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Fa=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Ba=(e,t)=>{let n=Fa(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},ga=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!gn(e,t[a]))return t[a]},dI=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:B(t)},ef=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??xa(),i=Fa(t),a=Ba(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:gn(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:gn(e,c)}))})),o=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=t.groups.findIndex(d=>d.id===n.groupId),c=t.groups[l],u=c?.variants.findIndex(d=>d.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],m=l<0?-1:Math.floor(l/t.pageSize);p&&m===a&&!gn(e,p)&&(o={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:ga(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:ga(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:o,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},Ua=(e,t)=>!Va({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),Ya=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),za=(e,t)=>{let n=Ya(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},ba=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!Ua(e,t[a]))return t[a]},rf=e=>({trackId:e.id,soundId:e.soundId,title:e.title,artist:e.artist??null,album:e.album??null,description:e.description??null,coverImageId:e.coverImageId??null}),mI=(e,t)=>({...rf(t),locked:Ua(e,t)}),Ip=e=>{let t=Math.floor(e/1e3),n=t%60,i=Math.floor(t/60);if(i<60)return`${i}:${String(n).padStart(2,"0")}`;let a=Math.floor(i/60),r=i%60;return`${a}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},yI=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:B(t)},tf=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??Ns(),i=Ya(t),a=za(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>mI(e,u)),o=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[o],c=l?{...rf(l),canPlayPreviousTrack:ba(e,t.tracks,o,-1)!==void 0,canPlayNextTrack:ba(e,t.tracks,o,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:Ip(n.positionMs),durationText:n.durationMs===null?null:Ip(n.durationMs),canPlay:n.status!=="playing",canPause:n.status==="playing",canSeek:n.readiness==="ready"&&n.durationMs!==null}:null,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},Xa=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Ga=(e,t)=>{let n=Xa(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},hI=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:B(t)},gI=({state:e})=>be(e)!==null,bI=({state:e})=>{let t=be(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},nf=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,sf=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??Oa(),i=Xa(t),a=Ga(t,n),r=a*t.pageSize,s=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!nf(e,l.sceneId)})),o=be(e);return{isActive:o!==null,activeSceneId:o?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},wI=({state:e})=>e.global.nextLineConfig,of=({state:e,pointer:t}={})=>{let n=t??Be({state:e})?.pointer;if(!n)return;let i=n?.sectionId,a=n?.lineId,s=Ve({state:e},{sectionId:i})?.lines||[],o=Fe(s,a);if(!(o<0))for(let l=o;l>=0;l-=1){let c=s[l]?.actions;if(!c||!Object.prototype.hasOwnProperty.call(c,"choice"))return;let u=c.choice;if(u?.resourceId)return u.resourceId;if(!u?.animations||c.cleanAll)return}},af=({state:e})=>!!of({state:e}),II=({state:e})=>structuredClone(e),vI=({state:e})=>B({audioEffects:e.projectData?.resources?.audioEffects??{},sounds:e.projectData?.resources?.sounds??{}}),kI=({state:e})=>{let t=kr(e);return{runtime:t,musicRoomPlayer:B(e.global.musicRoomPlayer),skipTransitionsAndAnimations:t.skipTransitionsAndAnimations===!0||df(e)}},AI=({state:e},{sectionId:t})=>Qe(e.projectData,t).sceneId,PI=({state:e})=>B(e.projectData.resources?.achievements??{}),xI=({state:e},t)=>{let n=L(e.projectData.resources?.achievements,t?.resourceId);return n===void 0?void 0:B(n)},lf=({state:e})=>e.global.saveSlots,EI=({state:e},t)=>{let n=t?.slotId,i=ft(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0},cf=({state:e})=>B(e.global.localizationPackages),Ha=({state:e})=>kr(e),SI=({state:e},t)=>ar(e,t?.runtimeId),Ka=({state:e})=>{let t={...e.global?.variables??{},...Yr(e)?.variables??{}};return Pt({variables:t,runtime:kr(e),variableConfigs:e.projectData.resources?.variables??{}})},Be=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},Ve=({state:e},t)=>{let{sectionId:n}=t;return Qe(e.projectData,n).section},kn=({state:e})=>{let t=Be({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:i}=t.pointer,a=Ve({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines[Fe(a.lines,i)]},uf=({state:e})=>Ta({state:e,pointer:Be({state:e}).pointer}),pf=e=>{let t=kn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=kr(e),i=Pt({variables:{...e.global?.variables??{},...Yr(e)?.variables??{}},runtime:n,variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(a=>`${St(a?.text,{variables:i,runtime:n})??""}`).join("")},Or=({state:e})=>da({text:pf(e),baseDelay:ar(e,"autoForwardDelay"),speed:ar(e,"autoForwardSpeed")}),OI=({state:e})=>{let t=ff({state:e}),i=kn({state:e})?.actions??{},a=it([t??{},i],{resources:e.projectData.resources});return xo(t??{},a??{})},RI=({state:e},{sectionId:t})=>{let n=Ve({state:e},{sectionId:t});if(!n?.lines)return[];let i=[],a={};for(let r of n.lines){let s=r.actions||{},o=it([a,s],{resources:e.projectData.resources}),l=xo(a,o);i.push({id:r.id,changes:l,presentationState:o}),a=Eo(o)}return i},$I=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let i=RI({state:e},{sectionId:t});return n?{lines:i}:{lines:i.map(({presentationState:a,...r})=>r)}},ff=({state:e})=>{let t=Ta({state:e,pointer:Be({state:e}).pointer},-1);return t===null?null:Eo(t)},Wa=({state:e},{slotsPerPage:t=Pp}={})=>{let a=((Ha({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let s=0;s<t;s++){let o=a+s,l=e.global.saveSlots&&e.global.saveSlots[ft(o)]||{};r.push({...l,slotId:o})}return{saveSlots:r}},CI=lf,_I=Wa,df=e=>{let n=e.contexts?.[e.contexts.length-1]?.rollback;return!n||!Array.isArray(n.timeline)||typeof n.currentIndex!="number"?!1:n.currentIndex>=0&&n.currentIndex<n.timeline.length-1},NI=(e,t)=>{let n=e.projectData.resources?.layouts??{},a=[...[...e.global.overlayStack??[]].reverse().map(r=>r?.resourceId),t.layout?.resourceId];for(let r of a){if(typeof r!="string"||!Object.prototype.hasOwnProperty.call(n,r))continue;let s=n[r]?.paginationSize;if(Number.isInteger(s)&&s>0)return s}return Pp},jI=({state:e},t={})=>{let n=uf({state:e}),i=ff({state:e}),a=kn({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:B(r)}:a,o=r?.animations&&i===null?{}:i,{sectionId:l}=Be({state:e}).pointer,{sceneId:c}=Qe(e.projectData,l),u={...Ha({state:e}),localizationPackages:cf({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],d=vn({state:e}),f=af({state:e}),h=ef({state:e}),g=tf({state:e}),y=sf({state:e}),b=Ka({state:e}),{saveSlots:w}=Wa({state:e},{slotsPerPage:NI(e,n)}),A=df(e);return Yu({presentationState:n,previousBgmRender:t?.previousBgmRender,previousPresentationState:o,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:f,isFormVisible:!!d,canRollback:Df({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||A,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:Zp({state:e}),saveSlots:w,variables:b,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:h,musicRoom:g,sceneReplay:y,musicRoomPlayer:B(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},TI=({state:e},t)=>(e.global.confirmDialog=$w(t),e.global.pendingEffects.push({name:"render"}),e),DI=({state:e})=>(e.global.confirmDialog&&(Dt(e),e.global.pendingEffects.push({name:"render"})),e),LI=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),ur(e,"pushOverlay",n,t),e),MI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),ur(e,"popOverlay",void 0,t),e),VI=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),ur(e,"replaceLastOverlay",n,t),e),qI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],Dt(e),Lt(e),e.global.pendingEffects.push({name:"render"}),ur(e,"clearOverlays",void 0,t),e),FI=(e,{activeInteraction:t})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),t&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},An=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,_w(e,n),Lt(e);let i=Re({state:e},{pointer:t}),a=i?.source===jt,r=i?.source===Br;FI(e,{activeInteraction:i});let s=be(e),o={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=xp(e);s.sceneReplay.entryId=l,o.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(o),{isChoiceVisible:a,isFormVisible:r,activeInteraction:i}},Ds=(e,t,n)=>{!(t?.source===jt||t?.source===Br)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},mf=({state:e})=>(Re({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),Pn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),BI=({state:e})=>{let t=e.global.autoMode;return Re({state:e})&&!t||(t?Pn({state:e}):mf({state:e})),e},yf=({state:e})=>(Re({state:e})||(e.global.autoMode&&(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"})),e.global.skipMode=!0,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.pendingEffects.push({name:"render"})),e),Ur=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),UI=({state:e})=>{let t=Jp({state:e});return Re({state:e})&&!t||(t?Ur({state:e}):yf({state:e})),e},Ls=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),ur(e,"showDialogueUI",void 0,t),e),hf=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),ur(e,"hideDialogueUI",void 0,t),e),YI=e=>{let{state:t}=e;return Qp({state:t})?Ls(e):hf(e),t},Xr=(e,t,n)=>(La(e,t,n),Gp(e),e.global.pendingEffects.push({name:"render"}),e),xn=(e,t,n,i,a)=>{let r=La(e,t,n);return e.global.pendingEffects.push({name:"render"}),ur(e,i,{value:r},a),e},zI=({state:e},t)=>Xr(e,"dialogueTextSpeed",t?.value),XI=({state:e},t)=>(Xr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Re({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e),GI=({state:e},t)=>(Xr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Re({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e),HI=({state:e},t)=>Xr(e,"skipUnseenText",t?.value),KI=({state:e},t)=>Xr(e,"skipTransitionsAndAnimations",t?.value),WI=({state:e},t)=>Xr(e,"soundVolume",t?.value),JI=({state:e},t)=>Xr(e,"musicVolume",t?.value),QI=({state:e},t)=>Xr(e,"muteAll",t?.value),wa=({state:e,rollbackActionBatchStack:t},n)=>xn(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),Ia=({state:e,rollbackActionBatchStack:t})=>{let n=ar(e,"saveLoadPagination")+1;return xn(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},va=({state:e,rollbackActionBatchStack:t})=>{let n=ar(e,"saveLoadPagination")-1;return xn(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},ka=({state:e,rollbackActionBatchStack:t},n)=>xn(e,"menuPage",n?.value,"setMenuPage",t),Aa=({state:e,rollbackActionBatchStack:t},n)=>xn(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),ZI=({state:e})=>(e.global.pendingEffects=[],e),ev=({state:e},t)=>(e.global.pendingEffects.push(t),e),rv=({state:e},t)=>{if(be(e))return e;let n=t?.resourceId;return Ep(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},tv=({state:e},t)=>{if(be(e))return e;let n=t?.resourceId,i=Ep(e,n);if(i.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${n}" must be a non-negative integer`);if(!Number.isInteger(i.target)||i.target<1)throw new Error(`Achievement resource "${n}" must have a positive integer target`);let r=Math.min(a,i.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:r,target:i.target,completed:r>=i.target}}),e},gf=e=>e?.lines?.[0],bf=(e,{sectionId:t,resetStoryState:n=!1,screen:i})=>{let a=!!Fp(i),r=Ve({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=gf(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!zw(e,{queueRender:!a}))return e;let o=Re({state:e});n&&e.global.skipMode&&Ur({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=Mt(l),p=u.read;n||pt(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||zr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=bn({pointer:u.read}):Ts(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=An(e,l?.pointers?.read,{screenTransition:i});return Ds(e,o,c),e},nv=({state:e},t)=>{if(be(e))throw new Error("Cannot reset the story while a scene replay is active");return bf(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},wf=e=>(e.global.accountViewedRegistry=iw(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Ms=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(n=>({scope:n.scope,path:n.path,op:n.op,value:B(n.value)}))}})},If=(e,t)=>{Ms(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(n=>({sectionId:n.sectionId,...n.lastLineId===void 0?{}:{lineId:n.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},sv=(e,t,{sectionId:n,lineId:i})=>{if(!n||!i)return!1;let a=U(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(s=>s.sectionId===n);if(r){if(r.lastLineId===void 0)return!1;let s=Ve({state:e},{sectionId:n});if(s?.lines){let o=Fe(s.lines,r.lastLineId),l=Fe(s.lines,i);if(o===-1||l>o)return r.lastLineId===i?!1:(r.lastLineId=i,!0)}else return r.lastLineId===i?!1:(r.lastLineId=i,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:i}),!0},pt=(e,t)=>{if(be(e)||e.global.accountViewedRegistry===void 0)return;sv(e,wf(e),t)&&If(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},iv=({state:e},t)=>(pt(e,t),e.global.pendingEffects.push({name:"render"}),e),ov=({state:e},t)=>{if(be(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let i=wf(e);i.resources.find(r=>r.resourceId===n)||(i.resources.push({resourceId:n}),If(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},pr=(e,t,n)=>{if(!U(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(i=>{if(!n.has(i))throw new Error(`${e} payload contains unsupported property "${i}"`)})},Pa=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},Vs=(e,t)=>{let n=e.global.imageGalleryNavigation;n.groupId===t.groupId&&n.variantId===t.variantId&&n.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},av=({state:e},t)=>{let n="showImageGalleryVariant";pr(n,t,Q0),Pa(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&Pa(n,"variantId",t.variantId);let i=e.projectData?.resources?.imageGallery;if(i===void 0)return e;let a=i.groups.findIndex(o=>o.id===t.groupId),r=i.groups[a];if(!r)return e;let s=t.variantId===void 0?r.variants[0]:r.variants.find(o=>o.id===t.variantId);return!s||gn(e,s)||Vs(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/i.pageSize)}),e},vf=(e,t,n,i)=>{pr(i,t,Ea);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let r=e.global.imageGalleryNavigation;if(typeof r.groupId!="string"||typeof r.variantId!="string")return e;let s=a.groups.find(c=>c.id===r.groupId),o=s?.variants.findIndex(c=>c.id===r.variantId);if(!s||o===void 0||o<0)return e;let l=ga(e,s.variants,o,n);return l&&Vs(e,{...r,variantId:l.id}),e},lv=({state:e},t)=>vf(e,t,-1,"moveToPreviousImageGalleryVariant"),cv=({state:e},t)=>vf(e,t,1,"moveToNextImageGalleryVariant"),uv=({state:e},t)=>{if(pr("clearImageGallerySelection",t,Ea),e.projectData?.resources?.imageGallery===void 0)return e;let i=e.global.imageGalleryNavigation;return Vs(e,{groupId:null,variantId:null,pageIndex:i.pageIndex}),e},kf=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let i=Fa(n);if(t>=i)return e;let a=e.global.imageGalleryNavigation,r=Ba(n,a);return t===r||Vs(e,{groupId:null,variantId:null,pageIndex:t}),e},pv=({state:e},t)=>{if(pr("moveToImageGalleryPage",t,Z0),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return kf(e,t.pageIndex)},Af=(e,t,n,i)=>{pr(i,t,Ea);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Ba(a,e.global.imageGalleryNavigation)+n;return s<0?e:kf(e,s)},fv=({state:e},t)=>Af(e,t,1,"moveToNextImageGalleryPage"),dv=({state:e},t)=>Af(e,t,-1,"moveToPreviousImageGalleryPage"),Rr=(e,t,n)=>{if(!U(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(i=>{if(!n.has(i))throw new Error(`${e} payload contains unsupported property "${i}"`)})},mv=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},sr=e=>{e.global.pendingEffects.push({name:"render"})},Pf=(e,t)=>{let n=e.projectData.resources.musicRoom,i=e.global.musicRoomPlayer,a=i.trackId!==null,r=i.trackId===t.id,s=i.bgmPlayback;a||(s={commandId:js(e),operation:"pause"});let o=In(e,"play",0),l=n.tracks.indexOf(t),c=r?i.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:o,seekFallback:null,bgmPlayback:s},sr(e)},yv=({state:e},t)=>{let n="playMusicRoomTrack";Rr(n,t,ew),mv(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Ua(e,a)||Pf(e,a),e},hv=({state:e},t)=>{Rr("playMusicRoom",t,Tt);let i=e.global.musicRoomPlayer;if(i.trackId===null||i.status==="playing")return e;let a=i.status==="ended",r=i.readiness==="error",s=i.status==="paused"&&!r?"resume":"play",o=a?0:i.positionMs;return i.playback=In(e,s,s==="play"?o:void 0),i.seekFallback=null,i.status="playing",i.positionMs=o,r&&(i.readiness=i.durationMs===null?"loading":"ready"),sr(e),e},gv=({state:e},t)=>{Rr("pauseMusicRoom",t,Tt);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status!=="playing"||(i.playback=In(e,"pause"),i.seekFallback=null,i.status="paused",sr(e)),e},bv=({state:e},t)=>{Rr("stopMusicRoom",t,Tt);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status==="stopped"&&i.positionMs===0||(i.playback=In(e,"stop"),i.seekFallback=null,i.status="stopped",i.positionMs=0,sr(e)),e},wv=({state:e},t)=>{if(Rr("seekMusicRoom",t,rw),typeof t.positionMs!="number"||!Number.isFinite(t.positionMs)||t.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let i=e.global.musicRoomPlayer;if(i.trackId===null||i.readiness!=="ready"||i.durationMs===null||t.positionMs>i.durationMs)return e;let a=In(e,"seek",t.positionMs);return i.seekFallback={commandId:a.commandId,status:i.status,positionMs:i.positionMs},i.playback=a,i.positionMs=t.positionMs,t.positionMs===i.durationMs?i.status="ended":i.status==="ended"&&(i.status="stopped"),sr(e),e},xf=(e,t,n,i)=>{Rr(i,t,Tt);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let s=a.tracks.findIndex(l=>l.id===r.trackId);if(s<0)return e;let o=ba(e,a.tracks,s,n);return o&&Pf(e,o),e},Iv=({state:e},t)=>xf(e,t,-1,"playPreviousMusicRoomTrack"),vv=({state:e},t)=>xf(e,t,1,"playNextMusicRoomTrack"),kv=({state:e},t)=>{Rr("clearMusicRoomSelection",t,Tt);let i=e.global.musicRoomPlayer;if(i.trackId===null)return e;let a=i.pageIndex,r={commandId:js(e),operation:"resume"};return e.global.musicRoomPlayer={...Ns({bgmPlayback:r}),pageIndex:a},sr(e),e},Ef=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=Ya(n))return e;let i=e.global.musicRoomPlayer,a=za(n,i);return t===a||(i.pageIndex=t,sr(e)),e},Av=({state:e},t)=>{if(Rr("moveToMusicRoomPage",t,tw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Ef(e,t.pageIndex)},Sf=(e,t,n,i)=>{Rr(i,t,Tt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=za(a,e.global.musicRoomPlayer)+n;return r<0?e:Ef(e,r)},Pv=({state:e},t)=>Sf(e,t,1,"moveToNextMusicRoomPage"),xv=({state:e},t)=>Sf(e,t,-1,"moveToPreviousMusicRoomPage"),ut=e=>{let t=be(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=B(t.sceneReplay.returnState),i=t.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==i),e.contexts.pop(),Bw(e,n),e.global.pendingEffects.push({name:"render"}),!0},Ev=({state:e},t)=>{let n="startSceneReplay";if(pr(n,t,nw),Pa(n,"sceneId",t.sceneId),be(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!nf(e,a.sceneId))return e;let r=L(e.projectData.story.scenes,a.sceneId),s=r?.initialSectionId,o=L(r?.sections,s),l=o?.initialLineId??o?.lines?.[0]?.id;if(!o||!l||!o.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=qw(e);Fw(e);let u=Ma({pointer:{sceneId:a.sceneId,sectionId:s,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:c}});return Xp(e,u),e.contexts.push(u),An(e,u.pointers.read),e},Of=({state:e},t)=>{pr("finishSceneReplay",t,Sa);let i=be(e);if(i)return i.sceneReplay.finishOnNextAdvance=!0,e;if(Yr(e)?.rollback?.isRestoring===!0)return e;let r=Be({state:e})?.pointer,{sceneId:s}=Qe(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=ow(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Ms(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},Sv=({state:e},t)=>(pr("exitSceneReplay",t,Sa),ut(e),e),Rf=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=Xa(n))return e;let i=Ga(n,e.global.sceneReplayNavigation);return t===i||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},Ov=({state:e},t)=>{if(pr("moveToSceneReplayPage",t,sw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Rf(e,t.pageIndex)},$f=(e,t,n,i)=>{pr(i,t,Sa);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Ga(a,e.global.sceneReplayNavigation)+n;return r<0?e:Rf(e,r)},Rv=({state:e},t)=>$f(e,t,1,"moveToNextSceneReplayPage"),$v=({state:e},t)=>$f(e,t,-1,"moveToPreviousSceneReplayPage"),qs=(e,t)=>{let n=e.global.musicRoomPlayer;return!U(t)||t.id!==W0||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},Ja=e=>typeof e.positionMs=="number"&&Number.isFinite(e.positionMs)&&e.positionMs>=0&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>0&&e.positionMs<=e.durationMs,Cf=(e,t,n,{readiness:i=t.readiness}={})=>((t.readiness!==i||t.positionMs!==n.positionMs||t.durationMs!==n.durationMs||t.seekFallback!==null)&&(t.readiness=i,t.positionMs=n.positionMs,t.durationMs=n.durationMs,t.seekFallback=null,sr(e)),e),Cv=({state:e},t)=>{let n=qs(e,t);return!n||n.readiness!=="loading"||!Ja(t)?e:Cf(e,n,t,{readiness:"ready"})},_v=({state:e},t)=>{let n=qs(e,t);return!n||n.readiness!=="ready"||!Ja(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:Cf(e,n,t)},Nv=({state:e},t)=>{let n=qs(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!Ja(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,sr(e)),e},jv=({state:e},t)=>{let n=qs(e,t);if(!n||typeof t.errorCode!="string"||!J0.has(t.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(t.errorCode==="invalid-position"){let i=n.seekFallback;if(n.playback.operation!=="seek"||i?.commandId!==t.commandId)return e;let a=n.status!==i.status||n.positionMs!==i.positionMs;return n.status=i.status,n.positionMs=i.positionMs,n.seekFallback=null,a&&sr(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,sr(e),e},_f=({state:e,rollbackActionBatchStack:t},n)=>{let i=fw(n.manual),{auto:a,applyMode:r}=n,s=e.global.nextLineConfig.auto?.enabled,o=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;i&&a?(e.global.nextLineConfig={manual:i,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(i&&(e.global.nextLineConfig.manual=i),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,f=Re({state:e});return!u&&(a!==void 0&&(p!==s||m!==o||d!==l))&&(!f&&p===!0&&(m==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:d}}):s===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),ur(e,"setNextLineConfig",n,t),e},Tv=({state:e},t)=>{if(be(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;Sp(n,"saveSlot");let{thumbnailImage:i}=t,a=t?.savedAt,r=ft(n),s=B(e.contexts);s?.forEach(c=>{Mt(c),Hp(c.rollback),gw(c.rollback,e.projectData)});let o={contexts:s},l={formatVersion:Ap,slotId:_p(n),savedAt:typeof a=="number"?a:Date.now(),image:i,state:o};return e.global.saveSlots[r]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},Dv=({state:e},t)=>{if(be(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;Sp(n,"loadSlot");let i=ft(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0;if(a){let r=Rw(a,e.projectData);e.contexts=r.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=wn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Dt(e),Lt(e),$a(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},Lv=({state:e},t)=>{if(be(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;Cp(n),Qt(n),Zt(n),en(n),nt(n?.resources?.variables??{}),Vo(n);let i=vw(n),a=i?e.contexts?.map((s,o)=>qp(B(s),n,o)):void 0,r=i?bw(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=xa(),e.global.sceneReplayNavigation=Oa(),$a(e),i){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:o}=ss(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...o,...rn(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return Dt(e),Lt(e),i&&Object.keys(e.global.saveSlots??{}).length>0&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}}),e.global.pendingEffects.push({name:"render"}),e},Mv=({state:e},t)=>{let{l10nId:n,projectData:i}=t??{};if(n!==null&&(typeof n!="string"||n.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!U(i))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=i,La(e,"localizationPackageId",n),Gp(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Re({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},Vv=({state:e},t)=>{let{sectionId:n,lineId:i}=t;if(!i)return console.warn("jumpToLine requires lineId parameter"),e;let a=e.contexts[e.contexts.length-1];if(!a)return console.warn("No context available for jumpToLine"),e;let r=n||a.pointers.read?.sectionId;if(n&&!Ve({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=Ve({state:e},{sectionId:r});if(!s?.lines||!Array.isArray(s.lines))return console.warn(`Section ${r} has no lines`),e;if(!s.lines.find(p=>p.id===i))return console.warn(`Line not found: ${i} in section ${r}`),e;let l=Re({state:e}),c=Mt(a);c.read={sectionId:r,lineId:i};let{activeInteraction:u}=An(e,c.read);return Ds(e,l,u),e},qv=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Ls({state:e,rollbackActionBatchStack:t}),e;let i=Re({state:e});if(i?.source===jt&&n?.bypassChoice!==!0||i?.source===Br&&n?._interactionSource!==Br)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,be(e)?.sceneReplay.exitOnLineCompleted)return ut(e),e;let d=Be({state:e})?.pointer,f=d?.sectionId,h=d?.lineId;f&&h&&pt(e,{sectionId:f,lineId:h}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!i&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}});let g=e.global.nextLineConfig,y=Ve({state:e},{sectionId:f});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===h?ya(e):g?.auto?.enabled&&!i&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(be(e)?.sceneReplay.finishOnNextAdvance)return ut(e),e;let r=Be({state:e})?.pointer,s=r?.sectionId,o=Ve({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=o?.lines||[],p=Fe(c,r?.lineId)+1;if(p<c.length){let m=c[p],d=!ar(e,"skipUnseenText");if(e.global.skipMode&&d&&!qa({state:e},{sectionId:s,lineId:m.id}))return Ur({state:e}),e;if(l&&!l.rollback&&zr(l,{compatibilityAnchor:!0}),l){let h=Mt(l),g=h.read?.lineId;g&&s&&pt(e,{sectionId:s,lineId:g}),h.read={sectionId:s,lineId:m.id}}Ts(e,{sectionId:s,lineId:m.id}),Ra(e);let{activeInteraction:f}=An(e,{sectionId:s,lineId:m.id});Ds(e,i,f)}else{if(be(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),ut(e),e;e.global.autoMode&&Pn({state:e}),e.global.skipMode&&Ur({state:e}),ya(e)}return e},Fv=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,be(e)?.sceneReplay.exitOnLineCompleted)return ut(e),e;let n=Re({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}});let i=Be({state:e})?.pointer,a=i?.sectionId,r=i?.lineId;a&&r&&pt(e,{sectionId:a,lineId:r});let s=e.global.nextLineConfig;return s?.auto?.enabled&&!n&&s.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:s.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},Bv=({state:e},t)=>bf(e,{sectionId:t?.sectionId,screen:t?.screen}),Uv=({state:e,rollbackActionBatchStack:t},n)=>{let i=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!i)return Ls({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e;let a=Re({state:e});if(a?.source===jt&&n?.bypassChoice!==!0||a?.source===Br&&n?._interactionSource!==Br||a&&a.source!==jt&&a.source!==Br)return e;let r=be(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(ut(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=Be({state:e})?.pointer,o=s?.sectionId,l=Ve({state:e},{sectionId:o}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],m=Fe(u,s?.lineId)+1;if(m<u.length){let d=u[m],f=!ar(e,"skipUnseenText");if(e.global.skipMode&&f&&!qa({state:e},{sectionId:o,lineId:d.id})&&(Ur({state:e}),!i))return e;if(c&&!c.rollback&&zr(c,{compatibilityAnchor:!0}),c){let g=Mt(c),y=g.read?.lineId;y&&o&&pt(e,{sectionId:o,lineId:y}),g.read={sectionId:o,lineId:d.id}}Ts(e,{sectionId:o,lineId:d.id}),Ra(e);let{activeInteraction:h}=An(e,{sectionId:o,lineId:d.id});Ds(e,a,h)}else{if(be(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),ut(e),e;e.global.autoMode&&Pn({state:e}),e.global.skipMode&&Ur({state:e}),ya(e)}return e},Qa=(e,t={})=>{let n=vn({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},Yv=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=L(e.projectData.resources?.variables,t.variableId),i=n?.scope,a=n?.type;if(Ne(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(tn(i,t.variableId),nn(a,"set",t.variableId),be(e)&&i!=="context")throw new Error(`Cannot update ${i}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:i}},zv=(e,t)=>({id:e.id,key:e.key,valid:!0,values:B(t),fields:B(e.fields),fieldList:B(e.fieldList)}),Xv=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Be({state:e})?.pointer,n=t?.sectionId,i=t?.lineId;n&&i&&pt(e,{sectionId:n,lineId:i})},Gv=({state:e},t={})=>{let n=Qa(e,t),i=t.field;if(!n?.fields?.[i])return e;let a=Up(e,n.key),r=Cs(t.value),s=n.fields[i],o=ja(s,r);return a.values[i]=r,a.touched[i]=!0,o?a.errors[i]=o:delete a.errors[i],e.global.pendingEffects.push({name:"render"}),e},Hv=({state:e,rollbackActionBatchStack:t},n={})=>{let i=Qa(e,n);if(!i)return{submitted:!1,valid:!1,reason:"inactive"};let a=Up(e,i.key);a.submitted=!0;let r={},s={};if(Object.entries(i.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:d.value,h=ja(d,f);a.touched[m]=!0,h&&(s[m]=h),r[m]=Bp(d,f)}),a.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:B(s),form:{id:i.id,key:i.key,values:B(r)}};let o=e.contexts[e.contexts.length-1];if(o?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(i.fields).forEach(([m,d])=>{let{scope:f}=Yv(e,d),h=f==="context"?o.variables:e.global.variables,g=r[m];h[d.variableId]=os(h[d.variableId],"set",g),f==="context"&&(l=!0,u.push({variableId:d.variableId,op:"set",value:g})),(f==="device"||f==="account")&&c.push({scope:f,path:`variables.${d.variableId}`,op:"set",value:B(h[d.variableId])})}),l&&ur(e,"updateVariable",{id:"submitForm",operations:u},t),Ms(e,c);let p=zv(i,r);return Xv(e),delete e.global.formDrafts[i.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},Kv=({state:e},t={})=>{let n=Qa(e,t);return n?(delete e.global.formDrafts?.[n.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:n.id,key:n.key,values:B(n.values),fields:B(n.fields),fieldList:B(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},Wv=({state:e,rollbackActionBatchStack:t},n)=>{let{id:i,operations:a=[]}=n;if(!i)throw new Error("updateVariable requires an id field");if(typeof i!="string"||!/^[a-zA-Z0-9]+$/.test(i))throw new Error(`updateVariable id must be alphanumeric, got: "${i}"`);let r=e.contexts[e.contexts.length-1];if(r?.rollback?.isRestoring)return e;let s=!1,o=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let d=L(e.projectData.resources?.variables,c),f=d?.scope,h=d?.type;if(Ne(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(tn(f,c),nn(h,u,c),is(h,u,p,c,{roundTo:m}),be(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${c}" while a scene replay is active`);let g=f==="context"?r.variables:e.global.variables;if(f==="context"){s=!0;let y={variableId:c,op:u,value:p};m!==void 0&&(y.roundTo=m),l.push(y)}g[c]=os(g[c],u,p,{roundTo:m}),(f==="device"||f==="account")&&o.push({scope:f,path:`variables.${c}`,op:"set",value:B(g[c])})}),s&&ur(e,"updateVariable",{id:i,operations:l},t),Ms(e,o),e.global.pendingEffects.push({name:"render"}),e},Je=e=>(t,n)=>e({state:t},n),Nf=e=>({variables:Pt({variables:{...e.global?.variables??{},...Yr(e)?.variables??{}},runtime:kr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:kr(e)}),Jv=e=>{if(!U(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},Qv=(e,t,n)=>{if(!U(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!U(e.actions))throw new Error(`conditional branch at index ${t} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&t!==n-1)throw new Error("conditional else branch must be the last branch")},Zv=(e,t,n,i)=>{Jv(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(Qv(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Jt(r.when,{...Nf(e),...n?.bindings??{}}))){Za(e,r.actions,n,[...i,"branches",String(a),"actions"]);return}}},ek=(e,t,n,i)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==Sr)return;let r=i.join("."),s=n.randomOutcomeOrdinals,o=s.get(r)??0;s.set(r,o+1);let l=a.randomOutcomes?.find(p=>p.path===r&&p.ordinal===o);if(!l)return;if(t?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${r}`);let c=cs(B(l.result),l.type);if(c.type==="integer"){if(!Tp(t.distribution)||c.value<t.distribution.min||c.value>t.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${r}`);ha(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!U(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Za(e,u,n,[...i,"distribution","outcomes",String(c.outcomeIndex),"actions"])},rk={conditional:{replayLine:Zv},random:{replayLine:ek},updateVariable:{recordSources:[Fr],replayLine:ha,replayRecorded:ha,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Je(_f)},setSaveLoadPagination:{recordSources:[Fr],replayLine:Je(wa),replayRecorded:Je(wa),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Fr],replayLine:Je(Ia),replayRecorded:Je(Ia),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Fr],replayLine:Je(va),replayRecorded:Je(va),persistInSaveSlot:!0},setMenuPage:{recordSources:[Fr],replayLine:Je(ka),replayRecorded:Je(ka),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Fr],replayLine:Je(Aa),replayRecorded:Je(Aa),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Je(Of)}},Fs=e=>rk[e]??null,tk=e=>Fs(e)?.persistInSaveSlot===!0,nk=(e,t)=>{let n=Fs(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},sk=(e,t,n)=>{Fs(t)?.replayRecorded?.(e,n)},ik=(e,t,n,i,a)=>{let r=Fs(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,i,a);return}let s=i?.bindings??{},o=xt({[t]:n},{...Nf(e),...s})[t];r.replayLine(e,o)},Za=(e,t,n,i)=>{let a=us(t);fs(a);for(let[r,s]of a)ik(e,r,s,n,[...i,r])},ok=e=>e?.returnable!==!1,jf=(e,t)=>{if(t>=0)return e.currentIndex+t;let n=Math.abs(t);for(let i=e.currentIndex-1;i>=0;i-=1)if(ok(e.timeline[i])&&(n-=1,n===0))return i;return-1},Tf=({state:e},t)=>{let{offset:n}=t;if(n===void 0||typeof n!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let i=e.contexts[e.contexts.length-1];if(!i)return null;let a=i.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let r=jf(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},Df=({state:e})=>Tf({state:e},{offset:-1})!==null,ak=({state:e},t)=>{let{offset:n=-1}=t;if(n>=0)throw new Error("rollbackByOffset requires a negative offset");let i=e.contexts?.[e.contexts.length-1];if(!i)return e;let a=zr(i,{compatibilityAnchor:!i.rollback}),r=jf(a,n);return r<0||r>=a.timeline.length?e:Wp(e,r)},lk=({state:e},t)=>{let{sectionId:n,lineId:i}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=zr(a,{compatibilityAnchor:!a.rollback}),o=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===i);if(o===-1)throw new Error(`Line ${i} not found in section ${n} rollback timeline`);return o===r.currentIndex?e:Wp(e,o)},ck=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),ma=(e,t)=>{let n=e[t];if(!Number.isSafeInteger(n)||n<0)throw new RangeError(`Internal playback ${t} is invalid`);if(n===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=n+1,e[t]},vp=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,kp=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},uk=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Lf=e=>{let t=e.global?.nextLineConfig?.auto;return t?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:t.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:t.delay??1e3}},el=e=>JSON.stringify(Lf(e)),pk=({actionName:e,args:t,state:n,previousState:i})=>{let a=vp(i),r=vp(n);if(!uk(a,r)||i.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&kp(i)!==kp(n))return!0;let s=t[0]??{};if(e==="jumpToLine"){let o=s.sectionId??a?.sectionId;return typeof s.lineId=="string"&&r?.sectionId===o&&r?.lineId===s.lineId&&n.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let o=Qe(n.projectData,s.sectionId).section,l=gf(o)?.id;return typeof l=="string"&&r?.sectionId===s.sectionId&&r?.lineId===l&&n.global.isLineCompleted===!1}if(e==="loadSlot"){let o=s.slotId;return Object.prototype.hasOwnProperty.call(i.global?.saveSlots??{},ft(o))}return!1},fk=({actionName:e,args:t,state:n,transactionalMetadata:i,previousState:a})=>{if(pk({actionName:e,args:t,state:n,previousState:a})){let u=ma(i,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?i.rollbackAuthoredSuppression={lineEntryId:u,configKey:el(n)}:i.rollbackAuthoredSuppression=null,i.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let s=(a.contexts?.length??0)>(n.contexts?.length??0),o=e==="startAutoMode"||e==="startSkipMode"?Re({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!o||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&ma(i,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!o||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&ma(i,"skipSessionId")},dk=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==el(e))&&(t.rollbackAuthoredSuppression=null)},mk=({state:e,playbackOwnership:t})=>{let n=Re({state:e}),i=t.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!n&&e.global.skipMode===!0,s=Lf(e),o=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(o?.lineEntryId===i&&o.configKey===el(e)),c=a?pf(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:i},delayMs:da({text:c,baseDelay:ar(e,"autoForwardDelay"),speed:ar(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:i},delayMs:s.delayMs,trigger:s.trigger}:null}},yk=({playbackOwnership:e})=>e.lineEntryId,Mf=(e,t={})=>{let n=tI(e),i=[],a=t.createPlaybackOwnership??ck;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return dc(n,{selectPendingEffects:sI,selectSkipMode:Jp,selectAutoMode:iI,selectIsChoiceVisible:af,selectIsFormVisible:uI,selectActiveInteraction:Re,selectActiveForm:vn,selectDialogueUIHidden:Qp,selectDialogueHistory:Zp,selectConfirmDialog:cI,selectIsLineAccountViewed:qa,selectIsResourceAccountViewed:fI,selectImageGalleryConfig:dI,selectImageGallery:ef,selectMusicRoomConfig:yI,selectMusicRoom:tf,selectSceneReplayConfig:hI,selectSceneReplay:sf,selectIsSceneReplayActive:gI,selectActiveSceneReplayEntry:bI,selectNextLineConfig:wI,selectSystemState:II,selectBgmResources:vI,selectBgmPlaybackContext:kI,selectSceneIdForSection:AI,selectAchievements:PI,selectAchievement:xI,selectSaveSlotMap:lf,selectSaveSlots:CI,selectSaveSlot:EI,selectLocalizationPackages:cf,selectRuntime:Ha,selectRuntimeValue:SI,selectAllVariables:Ka,selectCurrentPointer:Be,selectSection:Ve,selectCurrentLine:kn,selectPresentationState:uf,selectAutoForwardTimerDelay:Or,selectPresentationChanges:OI,selectSectionLineChanges:$I,selectSaveSlotPage:Wa,selectCurrentPageSlots:_I,selectRenderState:jI,selectOverlayStack:nI,selectLineIdByOffset:Tf,selectCanRollback:Df,selectRollbackCursor:Gw,selectDesiredPlaybackTimers:mk,selectPlaybackLineEntryId:yk,startAutoMode:mf,stopAutoMode:Pn,toggleAutoMode:BI,startSkipMode:yf,stopSkipMode:Ur,toggleSkipMode:UI,showDialogueUI:Ls,hideDialogueUI:hf,toggleDialogueUI:YI,setDialogueTextSpeed:zI,setAutoForwardDelay:XI,setAutoForwardSpeed:GI,setSkipUnseenText:HI,setSkipTransitionsAndAnimations:KI,setSoundVolume:WI,setMusicVolume:JI,setMuteAll:QI,setSaveLoadPagination:wa,incrementSaveLoadPagination:Ia,decrementSaveLoadPagination:va,setMenuPage:ka,setMenuEntryPoint:Aa,showConfirmDialog:TI,hideConfirmDialog:DI,resetStoryAtSection:nv,clearPendingEffects:ZI,appendPendingEffect:ev,completeAchievement:rv,setAchievementProgress:tv,beginRollbackActionBatch:Ww,endRollbackActionBatch:Jw,ensureRandomReplayOccurrence:Qw,recordRandomOutcome:Zw,markRollbackCheckpointTransient:Hw,markSavedRollbackCheckpointTransient:Kw,recordCurrentDialogueHistory:lI,addViewedLine:iv,addViewedResource:ov,showImageGalleryVariant:av,moveToPreviousImageGalleryVariant:lv,moveToNextImageGalleryVariant:cv,clearImageGallerySelection:uv,moveToImageGalleryPage:pv,moveToNextImageGalleryPage:fv,moveToPreviousImageGalleryPage:dv,playMusicRoomTrack:yv,playMusicRoom:hv,pauseMusicRoom:gv,stopMusicRoom:bv,seekMusicRoom:wv,playPreviousMusicRoomTrack:Iv,playNextMusicRoomTrack:vv,clearMusicRoomSelection:kv,moveToMusicRoomPage:Av,moveToNextMusicRoomPage:Pv,moveToPreviousMusicRoomPage:xv,musicRoomSoundReady:Cv,musicRoomSoundProgress:_v,musicRoomSoundComplete:Nv,musicRoomSoundError:jv,startSceneReplay:Ev,finishSceneReplay:Of,exitSceneReplay:Sv,moveToSceneReplayPage:Ov,moveToNextSceneReplayPage:Rv,moveToPreviousSceneReplayPage:$v,setNextLineConfig:_f,saveSlot:Tv,loadSlot:Dv,updateProjectData:Lv,updateLocalizationPackage:Mv,sectionTransition:Bv,jumpToLine:Vv,nextLine:qv,markLineCompleted:Fv,rollbackToLine:lk,rollbackByOffset:ak,pushOverlay:LI,popOverlay:MI,replaceLastOverlay:VI,clearOverlays:qI,updateFormField:Gv,submitForm:Hv,cancelForm:Kv,updateVariable:Wv,nextLineFromSystem:Uv},{createTransactionalMetadata:a,updateTransactionalMetadata:fk,finalizeTransactionalMetadata:dk,transformActionFirstArgument:(s,o)=>({state:s,rollbackActionBatchStack:i,playbackOwnership:o}),transformSelectorFirstArgument:(s,o)=>({state:s,playbackOwnership:o})})};var hk="route-engine",gk="projectPersistence";var qf=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),ve=e=>Object.prototype.toString.call(e)==="[object Object]",Vf="variables.",bk=(e={})=>{let t=ve(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!ve(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lineId=="string"?{lineId:n.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!ve(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},wk=(e={})=>{let t=ve(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!ve(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lastLineId=="string"?{lastLineId:n.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!ve(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Ik=(e,t)=>{let n=wk(e),i=bk(t),a=n.sections.map(s=>({...s})),r=n.resources.map(s=>({...s}));return i.sections.forEach(s=>{let o=a.find(l=>l.sectionId===s.sectionId);if(!o){a.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(o.lastLineId!==void 0){if(s.lineId===void 0){delete o.lastLineId;return}o.lastLineId=s.lineId}}),i.resources.forEach(s=>{r.find(l=>l.resourceId===s.resourceId)||r.push({...s})}),{sections:a,resources:r}},vk=(e={})=>{let t=ve(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(i=>typeof i=="string"&&i.length>0))]}},kk=(e,t)=>{let n=vk(e),i=ve(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...i.filter(a=>typeof a=="string"&&a.length>0)])]}},Ff=(e={})=>{let t=ve(e)?e:{};return{saveSlots:ve(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:ve(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:ve(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:ve(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:ve(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:ve(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},Ak=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!ve(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let i=t.path?.startsWith(Vf)?t.path.slice(Vf.length):null;if(i!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(i.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${n}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return{scope:t.scope,path:t.path,op:t.op,value:t.value,variableId:i}}if(t.path==="viewedRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);if(!ve(t.value)||!Array.isArray(t.value.sceneIds)||t.value.sceneIds.length===0||t.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${n}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${n}].`)})},Pk=(e,t)=>{let n={};return Ak(t).forEach(i=>{if(i.path==="viewedRegistry"){n.accountViewedRegistry=Ik(n.accountViewedRegistry??e.accountViewedRegistry,i.value);return}if(i.path==="replayRegistry"){n.accountReplayRegistry=kk(n.accountReplayRegistry??e.accountReplayRegistry,i.value);return}let a=i.scope==="device"?"globalDeviceVariables":"globalAccountVariables";n[a]={...e[a],...n[a],[i.variableId]:i.value}}),n},Vt=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},xk=e=>{let t=Vt(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},Ek=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},Sk=({indexedDB:e,databaseName:t,objectStoreName:n})=>new Promise((i,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},r.onsuccess=()=>{i(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),Ok=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let i=await e;return new Promise((a,r)=>{let l=i.transaction(t,"readonly").objectStore(t).get(n);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},En=async({databasePromise:e,objectStoreName:t,namespace:n,patch:i})=>{let a=await e;return new Promise((r,s)=>{let o=a.transaction(t,"readwrite"),l=o.objectStore(t),c=l.get(n),u=!1,p=d=>{u||(u=!0,s(d))},m=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=Ff(c.result),f=typeof i=="function"?i(d):i,h={namespace:n,version:1,...qf(),...d,...f},g=l.put(h);g.onerror=()=>{p(g.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},o.oncomplete=()=>{m()},o.onerror=()=>{p(o.error??new Error(`IndexedDB transaction failed while updating namespace "${n}".`))},o.onabort=()=>{p(o.error??new Error(`IndexedDB transaction aborted while updating namespace "${n}".`))}})},Rk=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let i=await e;return new Promise((a,r)=>{let s=i.transaction(t,"readwrite"),l=s.objectStore(t).delete(n),c=!1,u=m=>{c||(c=!0,r(m))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${n}" from IndexedDB.`))},s.oncomplete=()=>{p()},s.onerror=()=>{u(s.error??new Error(`IndexedDB transaction failed while clearing namespace "${n}".`))},s.onabort=()=>{u(s.error??new Error(`IndexedDB transaction aborted while clearing namespace "${n}".`))}})},rl=(e={})=>{let{indexedDB:t,databaseName:n=hk,objectStoreName:i=gk,namespace:a}=e,r=Ek(t),s=xk(a),o=Sk({indexedDB:r,databaseName:n,objectStoreName:i});return{namespace:s,load:async()=>{let l=await Ok({databasePromise:o,objectStoreName:i,namespace:s});return{...qf(),...Ff(l)}},clear:async()=>Rk({databasePromise:o,objectStoreName:i,namespace:s}),saveSlots:async l=>En({databasePromise:o,objectStoreName:i,namespace:s,patch:{saveSlots:ve(l)?l:{}}}),saveGlobalDeviceVariables:async l=>En({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalDeviceVariables:ve(l)?l:{}}}),saveGlobalAccountVariables:async l=>En({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalAccountVariables:ve(l)?l:{}}}),saveGlobalRuntime:async l=>En({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalRuntime:ve(l)?l:{}}}),applyScopedDataUpdates:async l=>En({databasePromise:o,objectStoreName:i,namespace:s,patch:c=>Pk(c,l)})}},$k=rl;var ol=gy(Uf(),1),Qf=Zf;var Ck={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ze=Object.prototype.hasOwnProperty,_k={anyOf:[{type:"null"},{type:"object",properties:{x:{type:"number",minimum:0},y:{type:"number",minimum:0},quality:{type:"number",minimum:1},kernelSize:{type:"integer",enum:[5,7,9,11,13,15]},repeatEdgePixels:{type:"boolean"}},required:["x","y"],additionalProperties:!1}]};function Ue(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=s;if(e!==null){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[d]:r.push(d),s++}if(e.y===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[d]:r.push(d),s++}for(let d in e)if(!(d==="x"||d==="y"||d==="quality"||d==="kernelSize"||d==="repeatEdgePixels")){let f={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[f]:r.push(f),s++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:_k.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[f]:r.push(f),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let d={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=o,r!==null&&(o?r.length=o:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Ue.errors=r,s===0}var $e=ol.default.default??ol.default;function Us(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),s++}if(e.type===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[o]:r.push(o),s++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let o={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Us.errors=r,s===0}function yr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let o=e.length;for(let l=0;l<o;l++)Us(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length)}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[o]:r.push(o),s++}return yr.errors=r,s===0}var Nk={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Ys(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="continuity"||o==="speed"||o==="loop")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.continuity!==void 0){let o=e.continuity;if(typeof o!="string"){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(o==="render"||o==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Nk.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.speed!==void 0){let o=e.speed;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ys.errors=r,s===0}function pe(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="resourceId"||o==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}e.playback!==void 0&&(Ys(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return pe.errors=r,s===0}function zs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!Ze.call(Ck.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let o={instancePath:t+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let o={instancePath:t+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let o={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let o={instancePath:t+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.x!==void 0&&typeof e.x!="number"){let o={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.y!==void 0&&typeof e.y!="number"){let o={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let o={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let o={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.alpha!==void 0){let o=e.alpha;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let o=e.opacity;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Ue(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),s=r.length)),e.filters!==void 0&&(yr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?yr.errors:r.concat(yr.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return zs.errors=r,s===0}function Zf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return zs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),s=r.length),Zf.errors=r,s===0}var ed=rd;var Yf={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},zf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function Xs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(o!=="speed"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.speed!==void 0){let o=e.speed;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Xs.errors=r,s===0}function je(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="resourceId"||o==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0){let o=e.resourceId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}e.playback!==void 0&&(Xs(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return je.errors=r,s===0}function Gs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),s++}if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!Ze.call(zf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let o=e.resourceId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<-1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:zf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof o=="number"&&(o<0||isNaN(o))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Gs.errors=r,s===0}function Hs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),s++}}var c=l===s;if(c){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=o,r!==null&&(o?r.length=o:r=null);let u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),s++}}var m=p===s;if(m){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=u,r!==null&&(u?r.length=u:r=null);let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let b={};r===null?r=[b]:r.push(b),s++}}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let w={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[w]:r.push(w),s++}var g=y===s;f=g}if(!f){let y={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[y]:r.push(y),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Ze.call(Yf.properties,y)){let b={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let b=y.length;for(let w=0;w<b;w++)Gs(y[w],{instancePath:t+"/sounds/"+w,parentData:y,parentDataProperty:w,rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),s=r.length)}else{let b={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(y==="immediate"||y==="loopEnd")){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Yf.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(y<0||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(y<-1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}e.audioEffects!==void 0&&(je(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Hs.errors=r,s===0}function rd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Hs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length),rd.errors=r,s===0}var td=nd;var jk={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ks(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=s,d=!0,f=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let h;if(p.sprites===void 0&&(h="sprites")){let g={};r===null?r=[g]:r.push(g),s++}}var o=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),o){let h=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};r===null?r=[y]:r.push(y),s++}var o=h===s;d=o}if(!d){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[h]:r.push(h),s++}for(let h in p)if(!Ze.call(jk.properties.items.items.properties,h)){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),s++}if(p.id!==void 0&&typeof p.id!="string"){let h={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let h={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.x!==void 0&&typeof p.x!="number"){let h={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.y!==void 0&&typeof p.y!="number"){let h={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let h={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let h={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let h={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let h={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let h={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let h={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let h={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let h={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let h={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.alpha!==void 0){let h=p.alpha;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.opacity!==void 0){let h=p.opacity;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.blur!==void 0&&(Ue(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),s=r.length)),p.filters!==void 0&&(yr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?yr.errors:r.concat(yr.errors),s=r.length)),p.sprites!==void 0){let h=p.sprites;if(Array.isArray(h)){let g=h.length;for(let y=0;y<g;y++){let b=h[y];if(b&&typeof b=="object"&&!Array.isArray(b)){for(let w in b)if(!(w==="id"||w==="resourceId"||w==="animationName"||w==="animationSpeed"||w==="loop")){let A={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:w},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(b.id!==void 0&&typeof b.id!="string"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(b.resourceId!==void 0&&typeof b.resourceId!="string"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(b.animationName!==void 0&&typeof b.animationName!="string"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(b.animationSpeed!==void 0&&typeof b.animationSpeed!="number"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(b.loop!==void 0&&typeof b.loop!="boolean"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}}}else{let g={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[g]:r.push(g),s++}}p.animations!==void 0&&(pe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let c={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Ks.errors=r,s===0}function nd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ks(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),s=r.length),nd.errors=r,s===0}var sd=id;function Ws(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="resourceId"||o==="items"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.items!==void 0){let o=e.items;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:t+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:t+"/items/"+c+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let m=p.click;if(!(m&&typeof m=="object"&&!Array.isArray(m))){let d={instancePath:t+"/items/"+c+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let m={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ws.errors=r,s===0}function id(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ws(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),s=r.length),id.errors=r,s===0}var od=ad;function Js(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(o!=="mode"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let o={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Js.errors=r,s===0}function ad(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Js(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),s=r.length),ad.errors=r,s===0}var ld=cd;function Qs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(o!=="resourceId"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Qs.errors=r,s===0}function cd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Qs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),s=r.length),cd.errors=r,s===0}var ud=pd;var Xf={type:"object",properties:{ui:{type:"object",properties:{resourceId:{type:"string"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},mode:{type:"string",enum:["adv","nvl"]},content:{type:"array",items:{type:"object",properties:{text:{type:"string"}}}},textSpeed:{type:"number"},append:{type:"boolean"},characterId:{type:"string"},characterName:{type:"string"},persistCharacter:{type:"boolean"},persistSprite:{type:"boolean"},character:{type:"object",properties:{name:{type:"string"},sprite:{type:"object",properties:{transformId:{type:"string"},items:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},required:["id","resourceId"],additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1}},additionalProperties:!1},clear:{type:"boolean"},clearPage:{type:"boolean"}},additionalProperties:!1};function Zs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!Ze.call(Xf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.ui!==void 0){let o=e.ui;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)if(!(l==="resourceId"||l==="animations")){let c={instancePath:t+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(o.resourceId!==void 0&&typeof o.resourceId!="string"){let l={instancePath:t+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}o.animations!==void 0&&(pe(o.animations,{instancePath:t+"/ui/animations",parentData:o,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let l={instancePath:t+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.mode!==void 0){let o=e.mode;if(typeof o!="string"){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(o==="adv"||o==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:Xf.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.content!==void 0){let o=e.content;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:t+"/content/"+c+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}}else{let p={instancePath:t+"/content/"+c,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let o={instancePath:t+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let o={instancePath:t+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let o={instancePath:t+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let o={instancePath:t+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let o={instancePath:t+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let o={instancePath:t+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.character!==void 0){let o=e.character;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)if(!(l==="name"||l==="sprite")){let c={instancePath:t+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(o.name!==void 0&&typeof o.name!="string"){let l={instancePath:t+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(o.sprite!==void 0){let l=o.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={instancePath:t+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let m=c[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[d]:r.push(d),s++}if(m.resourceId===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[d]:r.push(d),s++}for(let d in m)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(m.id!==void 0&&typeof m.id!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/id",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/resourceId",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationName",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationSpeed",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}if(m.loop!==void 0&&typeof m.loop!="boolean"){let d={instancePath:t+"/character/sprite/items/"+p+"/loop",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let u={instancePath:t+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[u]:r.push(u),s++}}l.animations!==void 0&&(pe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let c={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let o={instancePath:t+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let o={instancePath:t+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Zs.errors=r,s===0}function pd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Zs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),s=r.length),pd.errors=r,s===0}var fd=dd;function ei(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="id"||o==="resourceId"||o==="fields"||o==="submitActions"||o==="cancelActions"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let o={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fields!==void 0){let o=e.fields;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/variableId",schemaPath:"#/properties/fields/additionalProperties/properties/variableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/required",schemaPath:"#/properties/fields/additionalProperties/properties/required/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/trim",schemaPath:"#/properties/fields/additionalProperties/properties/trim/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/placeholder",schemaPath:"#/properties/fields/additionalProperties/properties/placeholder/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/multiline",schemaPath:"#/properties/fields/additionalProperties/properties/multiline/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[p]:r.push(p),s++}if(typeof u=="number"&&(u<0||isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.submitActions!==void 0){let o=e.submitActions;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.cancelActions!==void 0){let o=e.cancelActions;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ei.errors=r,s===0}function dd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ei(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),s=r.length),dd.errors=r,s===0}var md=yd;function ri(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="resourceId"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ri.errors=r,s===0}function yd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ri(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),s=r.length),yd.errors=r,s===0}var hd=gd;function ti(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="alpha"||o==="opacity"||o==="blur"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.alpha!==void 0){let o=e.alpha;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let o=e.opacity;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Ue(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ti.errors=r,s===0}function gd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ti(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),s=r.length),gd.errors=r,s===0}var bd=wd;var Gf={type:"object",properties:{items:{type:"array",items:{$ref:"#/definitions/audioSound"}},channels:{type:"array",items:{type:"object",properties:{id:{type:"string",minLength:1},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},applyMode:{type:"string",enum:["singleLine","persistent"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1},Hf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function dr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),s++}if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!Ze.call(Hf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let o=e.resourceId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<-1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Hf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof o=="number"&&(o<0||isNaN(o))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return dr.errors=r,s===0}function ni(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};r===null?r=[p]:r.push(p),s++}}var c=l===s;if(c){let u={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),s++}else s=o,r!==null&&(o?r.length=o:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)dr(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length)}else{let p={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++){let d=u[m];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[f]:r.push(f),s++}if(d.sounds===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[f]:r.push(f),s++}for(let f in d)if(!(f==="id"||f==="volume"||f==="muted"||f==="pan"||f==="loop"||f==="interruption"||f==="applyMode"||f==="sounds")){let h={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(d.id!==void 0){let f=d.id;if(typeof f=="string"){if($e(f)<1){let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(d.volume!==void 0){let f=d.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),s++}if(f<0||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let f={instancePath:t+"/channels/"+m+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.pan!==void 0){let f=d.pan;if(typeof f=="number"){if(f>1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),s++}if(f<-1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={instancePath:t+"/channels/"+m+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.interruption!==void 0){let f=d.interruption;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="immediate"||f==="loopEnd")){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:Gf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.applyMode!==void 0){let f=d.applyMode;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="singleLine"||f==="persistent")){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:Gf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.sounds!==void 0){let f=d.sounds;if(Array.isArray(f)){let h=f.length;for(let g=0;g<h;g++)dr(f[g],{instancePath:t+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length)}else{let h={instancePath:t+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}}else{let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}}}else{let p={instancePath:t+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}return ni.errors=r,s===0}function wd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ni(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),s=r.length),wd.errors=r,s===0}var Id=vd;var Kf={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function si(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=s;if(typeof e!="string"){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(Array.isArray(e)){let d=e.length;for(let f=0;f<d;f++){let h=e[f];if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let g={instancePath:t+"/"+f+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let g={instancePath:t+"/"+f+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.furigana!==void 0){let g=h.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let y={instancePath:t+"/"+f+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let y={instancePath:t+"/"+f+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/"+f+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}}}else{let g={instancePath:t+"/"+f,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=o,r!==null&&(o?r.length=o:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return si.errors=r,s===0}function ii(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.id===void 0&&(b="id")){let w={};r===null?r=[w]:r.push(w),s++}}var m=p===s;if(u=u||m,!u){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.type===void 0&&(A="type")){let k={};r===null?r=[k]:r.push(k),s++}}var m=b===s;if(u=u||m,!u){let A=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.resourceId===void 0&&(P="resourceId")){let I={};r===null?r=[I]:r.push(I),s++}}var m=A===s;if(u=u||m,!u){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.layout===void 0&&(x="layout")){let T={};r===null?r=[T]:r.push(T),s++}}var m=P===s;if(u=u||m,!u){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.transformId===void 0&&(C="transformId")){let $={};r===null?r=[$]:r.push($),s++}}var m=x===s;if(u=u||m,!u){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.transform===void 0&&(q="transform")){let X={};r===null?r=[X]:r.push(X),s++}}var m=C===s;if(u=u||m,!u){let q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let N;if(e.x===void 0&&(N="x")){let K={};r===null?r=[K]:r.push(K),s++}}var m=q===s;if(u=u||m,!u){let N=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let Q={};r===null?r=[Q]:r.push(Q),s++}}var m=N===s;if(u=u||m,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let H={};r===null?r=[H]:r.push(H),s++}}var m=M===s;if(u=u||m,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ne;if(e.anchorY===void 0&&(ne="anchorY")){let ue={};r===null?r=[ue]:r.push(ue),s++}}var m=le===s;if(u=u||m,!u){let ne=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let de;if(e.scaleX===void 0&&(de="scaleX")){let ce={};r===null?r=[ce]:r.push(ce),s++}}var m=ne===s;if(u=u||m,!u){let de=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.scaleY===void 0&&(Z="scaleY")){let _={};r===null?r=[_]:r.push(_),s++}}var m=de===s;if(u=u||m,!u){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.flipX===void 0&&(D="flipX")){let F={};r===null?r=[F]:r.push(F),s++}}var m=Z===s;if(u=u||m,!u){let D=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let W;if(e.flipY===void 0&&(W="flipY")){let ye={};r===null?r=[ye]:r.push(ye),s++}}var m=D===s;if(u=u||m,!u){let W=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ke;if(e.rotation===void 0&&(ke="rotation")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var m=W===s;if(u=u||m,!u){let ke=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let he;if(e.originX===void 0&&(he="originX")){let vr={};r===null?r=[vr]:r.push(vr),s++}}var m=ke===s;if(u=u||m,!u){let he=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let er;if(e.originY===void 0&&(er="originY")){let gt={};r===null?r=[gt]:r.push(gt),s++}}var m=he===s;if(u=u||m,!u){let er=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Cr;if(e.layer===void 0&&(Cr="layer")){let Hr={};r===null?r=[Hr]:r.push(Hr),s++}}var m=er===s;if(u=u||m,!u){let Cr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let bt;if(e.alpha===void 0&&(bt="alpha")){let Bt={};r===null?r=[Bt]:r.push(Bt),s++}}var m=Cr===s;if(u=u||m,!u){let bt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Kr;if(e.opacity===void 0&&(Kr="opacity")){let wt={};r===null?r=[wt]:r.push(wt),s++}}var m=bt===s;if(u=u||m,!u){let Kr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Wr;if(e.blur===void 0&&(Wr="blur")){let Ln={};r===null?r=[Ln]:r.push(Ln),s++}}var m=Kr===s;if(u=u||m,!u){let Wr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ut;if(e.filters===void 0&&(Ut="filters")){let Yt={};r===null?r=[Yt]:r.push(Yt),s++}}var m=Wr===s;if(u=u||m,!u){let Ut=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Yi;if(e.animations===void 0&&(Yi="animations")){let Mn={};r===null?r=[Mn]:r.push(Mn),s++}}var m=Ut===s;u=u||m}}}}}}}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let b={};r===null?r=[b]:r.push(b),s++}var d=l===s;if(d){let b={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[b]:r.push(b),s++}else s=o,r!==null&&(o?r.length=o:r=null);let f=s,h=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let b={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[b]:r.push(b),s++}var y=g===s;if(h=h||y,!h){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let A={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[A]:r.push(A),s++}var y=b===s;h=h||y}if(h)s=f,r!==null&&(f?r.length=f:r=null);else{let b={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(si(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let b={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.width!==void 0&&typeof e.width!="number"){let b={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(e.height!==void 0&&typeof e.height!="number"){let b={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return ii.errors=r,s===0}function oi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"elements"},message:"must have required property 'elements'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(o!=="elements"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.elements!==void 0){let o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return oi.errors=r,s===0}var Tk={type:"object",properties:{x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},minProperties:1,additionalProperties:!1};function ai(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!Ze.call(Tk.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0&&typeof e.x!="number"){let o={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.y!==void 0&&typeof e.y!="number"){let o={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let o={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let o={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ai.errors=r,s===0}function li(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let m={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let m=p.length;for(let d=0;d<m;d++){let f=p[d],h=s,g=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.resourceId===void 0&&(I="resourceId")||f.text===void 0&&(I="text")){let x={};r===null?r=[x]:r.push(x),s++}}var o=g===s;if(o){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),s++}else s=h,r!==null&&(h?r.length=h:r=null);let y=s,b=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.resourceId===void 0&&(I="resourceId")||f.layout===void 0&&(I="layout")){let x={};r===null?r=[x]:r.push(x),s++}}var l=b===s;if(l){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),s++}else s=y,r!==null&&(y?r.length=y:r=null);let w=s,A=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.text===void 0&&(I="text")||f.layout===void 0&&(I="layout")){let x={};r===null?r=[x]:r.push(x),s++}}var c=A===s;if(c){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),s++}else s=w,r!==null&&(w?r.length=w:r=null);let k=s,P=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.transformId===void 0&&(I="transformId")||f.transform===void 0&&(I="transform")){let x={};r===null?r=[x]:r.push(x),s++}}var u=P===s;if(u){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[I]:r.push(I),s++}for(let I in f)if(!Ze.call(Kf.properties.items.items.properties,I)){let x={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),s++}if(f.id!==void 0&&typeof f.id!="string"){let I={instancePath:t+"/items/"+d+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),s++}if(f.animationName!==void 0&&typeof f.animationName!="string"){let I={instancePath:t+"/items/"+d+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),s++}if(f.animationSpeed!==void 0&&typeof f.animationSpeed!="number"){let I={instancePath:t+"/items/"+d+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.resourceId!==void 0&&typeof f.resourceId!="string"){let I={instancePath:t+"/items/"+d+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),s++}if(f.text!==void 0&&(ii(f.text,{instancePath:t+"/items/"+d+"/text",parentData:f,parentDataProperty:"text",rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),s=r.length)),f.layout!==void 0&&(oi(f.layout,{instancePath:t+"/items/"+d+"/layout",parentData:f,parentDataProperty:"layout",rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),s=r.length)),f.transformId!==void 0&&typeof f.transformId!="string"){let I={instancePath:t+"/items/"+d+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),s++}if(f.transform!==void 0&&(ai(f.transform,{instancePath:t+"/items/"+d+"/transform",parentData:f,parentDataProperty:"transform",rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),s=r.length)),f.x!==void 0&&typeof f.x!="number"){let I={instancePath:t+"/items/"+d+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.y!==void 0&&typeof f.y!="number"){let I={instancePath:t+"/items/"+d+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.anchorX!==void 0&&typeof f.anchorX!="number"){let I={instancePath:t+"/items/"+d+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.anchorY!==void 0&&typeof f.anchorY!="number"){let I={instancePath:t+"/items/"+d+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.scaleX!==void 0&&typeof f.scaleX!="number"){let I={instancePath:t+"/items/"+d+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.scaleY!==void 0&&typeof f.scaleY!="number"){let I={instancePath:t+"/items/"+d+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.flipX!==void 0&&typeof f.flipX!="boolean"){let I={instancePath:t+"/items/"+d+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[I]:r.push(I),s++}if(f.flipY!==void 0&&typeof f.flipY!="boolean"){let I={instancePath:t+"/items/"+d+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[I]:r.push(I),s++}if(f.rotation!==void 0&&typeof f.rotation!="number"){let I={instancePath:t+"/items/"+d+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.originX!==void 0&&typeof f.originX!="number"){let I={instancePath:t+"/items/"+d+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.originY!==void 0&&typeof f.originY!="number"){let I={instancePath:t+"/items/"+d+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(f.layer!==void 0){let I=f.layer;if(typeof I!="number"){let x={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),s++}if(!(I===10||I===30||I===50||I===70||I===90)){let x={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:Kf.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[x]:r.push(x),s++}}if(f.alpha!==void 0){let I=f.alpha;if(typeof I=="number"){if(I>1||isNaN(I)){let x={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[x]:r.push(x),s++}if(I<0||isNaN(I)){let x={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),s++}}else{let x={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),s++}}if(f.opacity!==void 0){let I=f.opacity;if(typeof I=="number"){if(I>1||isNaN(I)){let x={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[x]:r.push(x),s++}if(I<0||isNaN(I)){let x={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),s++}}else{let x={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),s++}}f.blur!==void 0&&(Ue(f.blur,{instancePath:t+"/items/"+d+"/blur",parentData:f,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),s=r.length)),f.filters!==void 0&&(yr(f.filters,{instancePath:t+"/items/"+d+"/filters",parentData:f,parentDataProperty:"filters",rootData:a})||(r=r===null?yr.errors:r.concat(yr.errors),s=r.length)),f.animations!==void 0&&(pe(f.animations,{instancePath:t+"/items/"+d+"/animations",parentData:f,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),s++}}}else{let m={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}return li.errors=r,s===0}function vd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return li(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?li.errors:r.concat(li.errors),s=r.length),vd.errors=r,s===0}var kd=Ad;var Dk={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},resourceId:{type:"string"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},startDelayMs:{type:"number",minimum:0}},anyOf:[{required:["resourceId"]},{required:["sounds"]}],allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}}],additionalProperties:!1};function ci(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let y={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[y]:r.push(y),s++}var u=c===s;if(l=l||u,!l){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let w={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[w]:r.push(w),s++}var u=y===s;l=l||u}if(l)s=o,r!==null&&(o?r.length=o:r=null);else{let y={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[y]:r.push(y),s++}let p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),s++}}var d=m===s;if(d){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=p,r!==null&&(p?r.length=p:r=null);let f=s,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),s++}}var g=h===s;if(g){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=f,r!==null&&(f?r.length=f:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!(y==="sounds"||y==="resourceId"||y==="volume"||y==="muted"||y==="pan"||y==="loop"||y==="interruption"||y==="startDelayMs")){let b={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let b=y.length;for(let w=0;w<b;w++)dr(y[w],{instancePath:t+"/sounds/"+w,parentData:y,parentDataProperty:w,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length)}else{let b={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(y<0||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(y<-1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(y==="immediate"||y==="loopEnd")){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Dk.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return ci.errors=r,s===0}function Ad(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ci(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),s=r.length),Ad.errors=r,s===0}var Pd=xd;var Lk={type:"object",properties:{type:{type:"string",enum:["boolean","number"]},target:{type:"integer",minimum:1},name:{type:"string",minLength:1},description:{type:"string",minLength:1},lockedName:{type:"string",minLength:1},lockedDescription:{type:"string",minLength:1},hidden:{type:"boolean"}},required:["type","name","description"],allOf:[{if:{properties:{type:{const:"number"}}},then:{required:["target"]}},{if:{properties:{type:{const:"boolean"}}},then:{not:{required:["target"]}}}],additionalProperties:!1};function ui(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};r===null?r=[g]:r.push(g),s++}var u=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),u){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let b={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[b]:r.push(b),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};r===null?r=[g]:r.push(g),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let g=s,y=s,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.target===void 0&&(A="target")){let k={};r===null?r=[k]:r.push(k),s++}}var h=b===s;if(h){let A={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[A]:r.push(A),s++}else s=y,r!==null&&(y?r.length=y:r=null);var f=g===s;m=f}if(!m){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[g]:r.push(g),s++}if(e.name===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[g]:r.push(g),s++}if(e.description===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let y={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(!(g==="boolean"||g==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Lk.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),s++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[y]:r.push(y),s++}if(typeof g=="number"&&(g<1||isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[y]:r.push(y),s++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let g={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}return ui.errors=r,s===0}function xd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ui(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),s=r.length),xd.errors=r,s===0}var Ed=Sd;var Mk={type:"object",required:["type"],$defs:{milliseconds:{type:"integer",minimum:0,maximum:9007199254740991},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{type:"number"},duration:{type:"number"},delay:{$ref:"#/$defs/milliseconds"},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}},auto:{type:"object",required:["duration"],properties:{duration:{$ref:"#/$defs/milliseconds"},delay:{$ref:"#/$defs/milliseconds"},easing:{$ref:"#/$defs/easing"}},additionalProperties:!1}},oneOf:[{required:["keyframes"],not:{required:["auto"]}},{required:["auto"],not:{anyOf:[{required:["initialValue"]},{required:["keyframes"]}]}}],additionalProperties:!1},keyframeTweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}}},required:["keyframes"],additionalProperties:!1},updateTween:{type:"object",properties:{alpha:{$ref:"#/$defs/tweenProperty"},translateX:{$ref:"#/$defs/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},x:{$ref:"#/$defs/tweenProperty"},y:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionTween:{type:"object",properties:{translateX:{$ref:"#/$defs/keyframeTweenProperty"},translateY:{$ref:"#/$defs/keyframeTweenProperty"},alpha:{$ref:"#/$defs/keyframeTweenProperty"},scaleX:{$ref:"#/$defs/keyframeTweenProperty"},scaleY:{$ref:"#/$defs/keyframeTweenProperty"},rotation:{$ref:"#/$defs/keyframeTweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/keyframeTweenProperty"},compositeMaskItem:{type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1},mask:{type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]}},properties:{name:{type:"string"},type:{type:"string",enum:["update","transition"]},complete:{type:"object",properties:{payload:{type:"object"}},additionalProperties:!0},tween:{$ref:"#/$defs/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"},mask:{oneOf:[{$ref:"#/$defs/mask"},{type:"array",minItems:1,items:{allOf:[{$ref:"#/$defs/mask"},{properties:{kind:{const:"single"}}}]}}]}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{not:{required:["tween"]},anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/animationResource.yaml"};function mr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(!(typeof e=="number"&&!(e%1)&&!isNaN(e))){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[o]:r.push(o),s++}if(typeof e=="number"){if(e>9007199254740991||isNaN(e)){let o={instancePath:t,schemaPath:"#/maximum",keyword:"maximum",params:{comparison:"<=",limit:9007199254740991},message:"must be <= 9007199254740991"};r===null?r=[o]:r.push(o),s++}if(e<0||isNaN(e)){let o={instancePath:t,schemaPath:"#/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[o]:r.push(o),s++}}return mr.errors=r,s===0}var Vk={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function yt(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(typeof e!="string"){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let o={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:Vk.enum},message:"must be equal to one of the allowed values"};r===null?r=[o]:r.push(o),s++}return yt.errors=r,s===0}function hr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[o]:r.push(o),s++}if(e.duration===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="startValue"||o==="value"||o==="duration"||o==="delay"||o==="easing"||o==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let o={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.value!==void 0&&typeof e.value!="number"){let o={instancePath:t+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let o={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.delay!==void 0&&(mr(e.delay,{instancePath:t+"/delay",parentData:e,parentDataProperty:"delay",rootData:a})||(r=r===null?mr.errors:r.concat(mr.errors),s=r.length)),e.easing!==void 0&&(yt(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?yt.errors:r.concat(yt.errors),s=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let o={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return hr.errors=r,s===0}function me(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=null,u=s,p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.auto===void 0&&(I="auto")){let x={};r===null?r=[x]:r.push(x),s++}}var d=m===s;if(d){let I={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),s++}else s=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.keyframes===void 0){let I={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[I]:r.push(I),s++}var P=u===s;P&&(l=!0,c=0);let f=s,h=s,g=s,y=s,b=!1,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.initialValue===void 0&&(I="initialValue")){let x={};r===null?r=[x]:r.push(x),s++}}var A=w===s;if(b=b||A,!b){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.keyframes===void 0&&(T="keyframes")){let C={};r===null?r=[C]:r.push(C),s++}}var A=I===s;b=b||A}if(b)s=y,r!==null&&(y?r.length=y:r=null);else{let I={};r===null?r=[I]:r.push(I),s++}var k=g===s;if(k){let I={instancePath:t,schemaPath:"#/oneOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),s++}else s=h,r!==null&&(h?r.length=h:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.auto===void 0){let I={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"auto"},message:"must have required property 'auto'"};r===null?r=[I]:r.push(I),s++}var P=f===s;if(P&&l?(l=!1,c=[c,1]):P&&(l=!0,c=1),l)s=o,r!==null&&(o?r.length=o:r=null);else{let I={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[I]:r.push(I),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let I in e)if(!(I==="initialValue"||I==="keyframes"||I==="auto")){let x={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let I={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(e.keyframes!==void 0){let I=e.keyframes;if(Array.isArray(I)){if(I.length<1){let T={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[T]:r.push(T),s++}let x=I.length;for(let T=0;T<x;T++)hr(I[T],{instancePath:t+"/keyframes/"+T,parentData:I,parentDataProperty:T,rootData:a})||(r=r===null?hr.errors:r.concat(hr.errors),s=r.length)}else{let x={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[x]:r.push(x),s++}}if(e.auto!==void 0){let I=e.auto;if(I&&typeof I=="object"&&!Array.isArray(I)){if(I.duration===void 0){let x={instancePath:t+"/auto",schemaPath:"#/properties/auto/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[x]:r.push(x),s++}for(let x in I)if(!(x==="duration"||x==="delay"||x==="easing")){let T={instancePath:t+"/auto",schemaPath:"#/properties/auto/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"};r===null?r=[T]:r.push(T),s++}I.duration!==void 0&&(mr(I.duration,{instancePath:t+"/auto/duration",parentData:I,parentDataProperty:"duration",rootData:a})||(r=r===null?mr.errors:r.concat(mr.errors),s=r.length)),I.delay!==void 0&&(mr(I.delay,{instancePath:t+"/auto/delay",parentData:I,parentDataProperty:"delay",rootData:a})||(r=r===null?mr.errors:r.concat(mr.errors),s=r.length)),I.easing!==void 0&&(yt(I.easing,{instancePath:t+"/auto/easing",parentData:I,parentDataProperty:"easing",rootData:a})||(r=r===null?yt.errors:r.concat(yt.errors),s=r.length))}else{let x={instancePath:t+"/auto",schemaPath:"#/properties/auto/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),s++}}}else{let I={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),s++}return me.errors=r,s===0}function pi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="alpha"||o==="translateX"||o==="translateY"||o==="x"||o==="y"||o==="scaleX"||o==="scaleY"||o==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.alpha!==void 0&&(me(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length)),e.translateX!==void 0&&(me(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length)),e.translateY!==void 0&&(me(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length)),e.x!==void 0&&(me(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length)),e.y!==void 0&&(me(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length)),e.scaleX!==void 0&&(me(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length)),e.scaleY!==void 0&&(me(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length)),e.rotation!==void 0&&(me(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return pi.errors=r,s===0}function Ee(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let o={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=o.length;for(let c=0;c<l;c++)hr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?hr.errors:r.concat(hr.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ee.errors=r,s===0}function fi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="translateX"||o==="translateY"||o==="alpha"||o==="scaleX"||o==="scaleY"||o==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.translateX!==void 0&&(Ee(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),s=r.length)),e.translateY!==void 0&&(Ee(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),s=r.length)),e.alpha!==void 0&&(Ee(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),s=r.length)),e.scaleX!==void 0&&(Ee(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),s=r.length)),e.scaleY!==void 0&&(Ee(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),s=r.length)),e.rotation!==void 0&&(Ee(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return fi.errors=r,s===0}function dt(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(o!=="tween"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.tween!==void 0&&(fi(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return dt.errors=r,s===0}var Bs={type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]},qk={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function di(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="texture"||o==="channel"||o==="invert")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let o={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.channel!==void 0){let o=e.channel;if(typeof o!="string"){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(o==="red"||o==="green"||o==="blue"||o==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:qk.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let o={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return di.errors=r,s===0}function mi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let o={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=o.length;for(let c=0;c<l;c++)hr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?hr.errors:r.concat(hr.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return mi.errors=r,s===0}function mt(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let w={};r===null?r=[w]:r.push(w),s++}var u=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let k={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}var u=w===s;l=u}if(!l){let w={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let w={};r===null?r=[w]:r.push(w),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let k={instancePath:t,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};r===null?r=[k]:r.push(k),s++}var f=w===s;m=f}if(!m){let w={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),s++}let h=s,g=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let w={};r===null?r=[w]:r.push(w),s++}var b=y===s;if(s=h,r!==null&&(h?r.length=h:r=null),b){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let k={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};r===null?r=[k]:r.push(k),s++}var b=w===s;g=b}if(!g){let w={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let w={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[w]:r.push(w),s++}for(let w in e)if(!Ze.call(Bs.properties,w)){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:w},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.kind!==void 0){let w=e.kind;if(typeof w!="string"){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(w==="single"||w==="sequence"||w==="composite")){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Bs.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let w={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.textures!==void 0){let w=e.textures;if(Array.isArray(w)){if(w.length<1){let k={instancePath:t+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=w.length;for(let k=0;k<A;k++)if(typeof w[k]!="string"){let P={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),s++}}else{let A={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.items!==void 0){let w=e.items;if(Array.isArray(w)){if(w.length<1){let k={instancePath:t+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=w.length;for(let k=0;k<A;k++)di(w[k],{instancePath:t+"/items/"+k,parentData:w,parentDataProperty:k,rootData:a})||(r=r===null?di.errors:r.concat(di.errors),s=r.length)}else{let A={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.combine!==void 0){let w=e.combine;if(typeof w!="string"){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(w==="max"||w==="min"||w==="multiply"||w==="add")){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Bs.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.channel!==void 0){let w=e.channel;if(typeof w!="string"){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(w==="red"||w==="green"||w==="blue"||w==="alpha")){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Bs.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let w={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let w={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[w]:r.push(w),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let w={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}e.progress!==void 0&&(mi(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),s=r.length))}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}return mt.errors=r,s===0}function yi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let A={};r===null?r=[A]:r.push(A),s++}var u=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),u){let A=s,k=s,P=s,I=s,x=!1,T=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let q={};r===null?r=[q]:r.push(q),s++}}var p=T===s;if(x=x||p,!x){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let X;if(e.next===void 0&&(X="next")){let N={};r===null?r=[N]:r.push(N),s++}}var p=$===s;if(x=x||p,!x){let X=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.mask===void 0&&(K="mask")){let M={};r===null?r=[M]:r.push(M),s++}}var p=X===s;x=x||p}}if(x)s=I,r!==null&&(I?r.length=I:r=null);else{let $={};r===null?r=[$]:r.push($),s++}var m=P===s;if(m){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let $={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[$]:r.push($),s++}var u=A===s;l=u}if(!l){let A={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[A]:r.push(A),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let A={};r===null?r=[A]:r.push(A),s++}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let A=s,k=s,P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let q={};r===null?r=[q]:r.push(q),s++}}var y=P===s;if(y){let $={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),s++}else s=k,r!==null&&(k?r.length=k:r=null);let I=s,x=!1,T=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[$]:r.push($),s++}var b=T===s;if(x=x||b,!x){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let X={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[X]:r.push(X),s++}var b=$===s;if(x=x||b,!x){let X=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let K={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[K]:r.push(K),s++}var b=X===s;x=x||b}}if(x)s=I,r!==null&&(I?r.length=I:r=null);else{let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[$]:r.push($),s++}var g=A===s;f=g}if(!f){let A={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[A]:r.push(A),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let A={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[A]:r.push(A),s++}for(let A in e)if(!(A==="name"||A==="type"||A==="complete"||A==="tween"||A==="prev"||A==="next"||A==="mask")){let k={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:A},message:"must NOT have additional properties"};r===null?r=[k]:r.push(k),s++}if(e.name!==void 0&&typeof e.name!="string"){let A={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(e.type!==void 0){let A=e.type;if(typeof A!="string"){let k={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[k]:r.push(k),s++}if(!(A==="update"||A==="transition")){let k={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Mk.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[k]:r.push(k),s++}}if(e.complete!==void 0){let A=e.complete;if(A&&typeof A=="object"&&!Array.isArray(A)){if(A.payload!==void 0){let k=A.payload;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let P={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),s++}}}else{let k={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}if(e.tween!==void 0&&(pi(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),s=r.length)),e.prev!==void 0&&(dt(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?dt.errors:r.concat(dt.errors),s=r.length)),e.next!==void 0&&(dt(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?dt.errors:r.concat(dt.errors),s=r.length)),e.mask!==void 0){let A=e.mask,k=s,P=!1,I=null,x=s;mt(A,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?mt.errors:r.concat(mt.errors),s=r.length);var w=x===s;w&&(P=!0,I=0);let T=s;if(Array.isArray(A)){if(A.length<1){let $={instancePath:t+"/mask",schemaPath:"#/properties/mask/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[$]:r.push($),s++}let C=A.length;for(let $=0;$<C;$++){let q=A[$];if(mt(q,{instancePath:t+"/mask/"+$,parentData:A,parentDataProperty:$,rootData:a})||(r=r===null?mt.errors:r.concat(mt.errors),s=r.length),q&&typeof q=="object"&&!Array.isArray(q)&&q.kind!==void 0&&q.kind!=="single"){let X={instancePath:t+"/mask/"+$+"/kind",schemaPath:"#/properties/mask/oneOf/1/items/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue:"single"},message:"must be equal to constant"};r===null?r=[X]:r.push(X),s++}}}else{let C={instancePath:t+"/mask",schemaPath:"#/properties/mask/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[C]:r.push(C),s++}var w=T===s;if(w&&P?(P=!1,I=[I,1]):w&&(P=!0,I=1),P)s=k,r!==null&&(k?r.length=k:r=null);else{let C={instancePath:t+"/mask",schemaPath:"#/properties/mask/oneOf",keyword:"oneOf",params:{passingSchemas:I},message:"must match exactly one schema in oneOf"};r===null?r=[C]:r.push(C),s++}}}else{let A={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[A]:r.push(A),s++}return yi.errors=r,s===0}function Sd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return yi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),s=r.length),Sd.errors=r,s===0}var Od=Rd;var Fk={type:"object",required:["type"],$defs:{easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},panKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:-1,maximum:1}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:-1,maximum:1}}}}]},playbackRateKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0}}}}]},volumeTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:-1,maximum:1},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},propertyTracks:{type:"object",minProperties:1,properties:{volume:{$ref:"#/$defs/volumeTweenProperty"},pan:{$ref:"#/$defs/panTweenProperty"},playbackRate:{$ref:"#/$defs/playbackRateTweenProperty"}},additionalProperties:!1}},properties:{name:{type:"string"},type:{enum:["update","transition"]},tween:{$ref:"#/$defs/propertyTracks"},prev:{$ref:"#/$defs/propertyTracks"},next:{$ref:"#/$defs/propertyTracks"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{anyOf:[{required:["prev"]},{required:["next"]}],not:{required:["tween"]}}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/audioEffectResource.yaml"};function hi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(typeof e!="number"){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}return hi.errors=r,s===0}var Bk={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function gi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(typeof e!="string"){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let o={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:Bk.enum},message:"must be equal to one of the allowed values"};r===null?r=[o]:r.push(o),s++}return gi.errors=r,s===0}function gr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[o]:r.push(o),s++}if(e.duration===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="startValue"||o==="value"||o==="duration"||o==="delay"||o==="easing"||o==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let o={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.value!==void 0&&(hi(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),s=r.length)),e.duration!==void 0){let o=e.duration;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.delay!==void 0){let o=e.delay;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.easing!==void 0&&(gi(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),s=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let o={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return gr.errors=r,s===0}function bi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;gr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?gr.errors:r.concat(gr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let b=e.value;if(typeof b=="number"){if(b>100||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(b<0||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let b=e.startValue;if(typeof b=="number"){if(b>100||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(b<0||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return bi.errors=r,s===0}function wi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let o=e.initialValue;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=o.length;for(let c=0;c<l;c++)bi(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return wi.errors=r,s===0}function Ii(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;gr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?gr.errors:r.concat(gr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let b=e.value;if(typeof b=="number"){if(b>1||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(b<-1||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let b=e.startValue;if(typeof b=="number"){if(b>1||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(b<-1||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return Ii.errors=r,s===0}function vi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let o=e.initialValue;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<-1||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=o.length;for(let c=0;c<l;c++)Ii(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return vi.errors=r,s===0}function ki(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;gr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?gr.errors:r.concat(gr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let b=e.value;if(typeof b=="number"&&(b<0||isNaN(b))){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let b=e.startValue;if(typeof b=="number"&&(b<0||isNaN(b))){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return ki.errors=r,s===0}function Ai(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let o=e.initialValue;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=o.length;for(let c=0;c<l;c++)ki(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ai.errors=r,s===0}function fr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="volume"||o==="pan"||o==="playbackRate")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.volume!==void 0&&(wi(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),s=r.length)),e.pan!==void 0&&(vi(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),s=r.length)),e.playbackRate!==void 0&&(Ai(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return fr.errors=r,s===0}function Pi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let w={};r===null?r=[w]:r.push(w),s++}var u=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),u){let w=s,A=s,k=s,P=s,I=!1,x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.prev===void 0&&(C="prev")){let $={};r===null?r=[$]:r.push($),s++}}var p=x===s;if(I=I||p,!I){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.next===void 0&&(q="next")){let X={};r===null?r=[X]:r.push(X),s++}}var p=C===s;I=I||p}if(I)s=P,r!==null&&(P?r.length=P:r=null);else{let C={};r===null?r=[C]:r.push(C),s++}var m=k===s;if(m){let C={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let C={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[C]:r.push(C),s++}var u=w===s;l=u}if(!l){let w={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let w={};r===null?r=[w]:r.push(w),s++}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let w=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.tween===void 0&&(C="tween")){let $={};r===null?r=[$]:r.push($),s++}}var y=k===s;if(y){let C={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);let P=s,I=!1,x=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[C]:r.push(C),s++}var b=x===s;if(I=I||b,!I){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let q={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[q]:r.push(q),s++}var b=C===s;I=I||b}if(I)s=P,r!==null&&(P?r.length=P:r=null);else{let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[C]:r.push(C),s++}var g=w===s;f=g}if(!f){let w={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let w={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[w]:r.push(w),s++}for(let w in e)if(!(w==="name"||w==="type"||w==="tween"||w==="prev"||w==="next")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:w},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let w={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.type!==void 0){let w=e.type;if(!(w==="update"||w==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Fk.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(fr(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),e.prev!==void 0&&(fr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),e.next!==void 0&&(fr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length))}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}return Pi.errors=r,s===0}function Rd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Pi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),s=r.length),Rd.errors=r,s===0}var $d=Cd;function xi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="name"||o==="nameVariableId"||o==="variables")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let o={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.nameVariableId!==void 0){let o=e.nameVariableId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.variables!==void 0){let o=e.variables;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/variables",schemaPath:"#/properties/variables/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return xi.errors=r,s===0}function Cd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return xi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),s=r.length),Cd.errors=r,s===0}var _d=Nd;var Uk=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function Ei(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(o!=="hex"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.hex!==void 0){let o=e.hex;if(typeof o=="string"){if(!Uk.test(o)){let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/pattern",keyword:"pattern",params:{pattern:"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"},message:'must match pattern "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"'};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ei.errors=r,s===0}function Nd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ei(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),s=r.length),Nd.errors=r,s===0}var jd=Td;function Si(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let o=e.keyboard;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyboard/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.keyup!==void 0){let o=e.keyup;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyup/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyup/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.elements!==void 0){let o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Si.errors=r,s===0}function Td(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Si(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Si.errors:r.concat(Si.errors),s=r.length),Td.errors=r,s===0}var Dd=Ld;function Oi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="fileId"||o==="fileType")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Oi.errors=r,s===0}function Ld(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Oi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Oi.errors:r.concat(Oi.errors),s=r.length),Ld.errors=r,s===0}var Md=Vd;function Ri(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}if(e.width===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[o]:r.push(o),s++}if(e.height===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="fileId"||o==="fileType"||o==="width"||o==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.width!==void 0){let o=e.width;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let o=e.height;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ri.errors=r,s===0}function Vd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ri(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ri.errors:r.concat(Ri.errors),s=r.length),Vd.errors=r,s===0}var qd=Fd;function $i(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),s++}if(e.type===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[o]:r.push(o),s++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let o={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return $i.errors=r,s===0}var Wf=new RegExp("^\\$(if .+|for .+|else)$","u"),nl={validate:Sn};function Ci(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!Wf.test(o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}for(let o in e)if(Wf.test(o)){let l=e[o];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)nl.validate(l[u],{instancePath:t+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?nl.validate.errors:r.concat(nl.validate.errors),s=r.length)}else{let c={instancePath:t+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ci.errors=r,s===0}function Sn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=s;$i(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?$i.errors:r.concat($i.errors),s=r.length);var u=c===s;if(l=l||u,!l){let p=s;Ci(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ci.errors:r.concat(Ci.errors),s=r.length);var u=p===s;l=l||u}if(l)s=o,r!==null&&(o?r.length=o:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Sn.errors=r,s===0}function _i(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let o=e.length;for(let l=0;l<o;l++)Sn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?Sn.errors:r.concat(Sn.errors),s=r.length)}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[o]:r.push(o),s++}return _i.errors=r,s===0}var sl={validate:On};function On(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(_i(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?_i.errors:r.concat(_i.errors),s=r.length)),e.children!==void 0){let o=e.children;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++)sl.validate(o[c],{instancePath:t+"/children/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?sl.validate.errors:r.concat(sl.validate.errors),s=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return On.errors=r,s===0}function Ni(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.paginationSize!==void 0){let o=e.paginationSize;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/paginationSize",schemaPath:"#/properties/paginationSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}if(typeof o=="number"&&(o<1||isNaN(o))){let l={instancePath:t+"/paginationSize",schemaPath:"#/properties/paginationSize/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[l]:r.push(l),s++}}if(e.elements!==void 0){let o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++)On(o[c],{instancePath:t+"/elements/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?On.errors:r.concat(On.errors),s=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.transitions!==void 0){let o={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ni.errors=r,s===0}function Fd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ni(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ni.errors:r.concat(Ni.errors),s=r.length),Fd.errors=r,s===0}var Bd=Ud;function ji(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=null,u=s,p=s,m=s,d=s,f=!1,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let P={};r===null?r=[P]:r.push(P),s++}}var g=h===s;if(f=f||g,!f){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.texture===void 0&&(I="texture")){let x={};r===null?r=[x]:r.push(x),s++}}var g=k===s;if(f=f||g,!f){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.behaviors===void 0&&(T="behaviors")){let C={};r===null?r=[C]:r.push(C),s++}}var g=I===s;if(f=f||g,!f){let T=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.emitter===void 0&&($="emitter")){let q={};r===null?r=[q]:r.push(q),s++}}var g=T===s;f=f||g}}}if(f)s=d,r!==null&&(d?r.length=d:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=m===s;if(y){let k={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[k]:r.push(k),s++}else s=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let k={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};r===null?r=[k]:r.push(k),s++}var w=u===s;w&&(l=!0,c=0);let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}if(e.behaviors===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};r===null?r=[k]:r.push(k),s++}if(e.emitter===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};r===null?r=[k]:r.push(k),s++}}var w=b===s;if(w&&l?(l=!1,c=[c,1]):w&&(l=!0,c=1),l)s=o,r!==null&&(o?r.length=o:r=null);else{let k={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[k]:r.push(k),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[k]:r.push(k),s++}if(e.height===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[k]:r.push(k),s++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),s++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let P={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[P]:r.push(P),s++}}else{let P={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[P]:r.push(P),s++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let P={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[P]:r.push(P),s++}}else{let P={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[P]:r.push(P),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let k={instancePath:t+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),s++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let P={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[P]:r.push(P),s++}if(k.appearance===void 0){let P={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[P]:r.push(P),s++}for(let P in k)if(!(P==="emission"||P==="movement"||P==="appearance"||P==="bounds")){let I={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};r===null?r=[I]:r.push(I),s++}if(k.emission!==void 0){let P=k.emission;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),s++}}if(k.movement!==void 0){let P=k.movement;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),s++}}if(k.appearance!==void 0){let P=k.appearance;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),s++}}if(k.bounds!==void 0){let P=k.bounds;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),s++}}}else{let P={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),s++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let P={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[P]:r.push(P),s++}if(typeof k=="number"&&(k<1||isNaN(k))){let P={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[P]:r.push(P),s++}}if(e.texture!==void 0){let k=e.texture,P=s,I=!1,x=null,T=s;if(typeof k=="string"){if($e(k)<1){let $={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[$]:r.push($),s++}}else{let $={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[$]:r.push($),s++}var A=T===s;A&&(I=!0,x=0);let C=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let $={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[$]:r.push($),s++}var A=C===s;if(A&&I?(I=!1,x=[x,1]):A&&(I=!0,x=1),I)s=P,r!==null&&(P?r.length=P:r=null);else{let $={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:x},message:"must match exactly one schema in oneOf"};r===null?r=[$]:r.push($),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let I={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[I]:r.push(I),s++}let P=k.length;for(let I=0;I<P;I++){let x=k[I];if(x&&typeof x=="object"&&!Array.isArray(x)){if(x.type===void 0){let T={instancePath:t+"/behaviors/"+I,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[T]:r.push(T),s++}for(let T in x)if(!(T==="type"||T==="config")){let C={instancePath:t+"/behaviors/"+I,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:T},message:"must NOT have additional properties"};r===null?r=[C]:r.push(C),s++}if(x.type!==void 0){let T=x.type;if(typeof T=="string"){if($e(T)<1){let C={instancePath:t+"/behaviors/"+I+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[C]:r.push(C),s++}}else{let C={instancePath:t+"/behaviors/"+I+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[C]:r.push(C),s++}}if(x.config!==void 0){let T=x.config;if(!(T&&typeof T=="object"&&!Array.isArray(T))){let C={instancePath:t+"/behaviors/"+I+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[C]:r.push(C),s++}}}else{let T={instancePath:t+"/behaviors/"+I,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[T]:r.push(T),s++}}}else{let P={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[P]:r.push(P),s++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let P={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[P]:r.push(P),s++}if(k.lifetime!==void 0){let P=k.lifetime;if(P&&typeof P=="object"&&!Array.isArray(P)){if(P.min===void 0){let I={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[I]:r.push(I),s++}if(P.max===void 0){let I={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[I]:r.push(I),s++}if(P.min!==void 0){let I=P.min;if(typeof I=="number"){if(I<0||isNaN(I)){let x={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),s++}}else{let x={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),s++}}if(P.max!==void 0){let I=P.max;if(typeof I=="number"){if(I<0||isNaN(I)){let x={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),s++}}else{let x={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),s++}}}else{let I={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),s++}}}else{let P={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),s++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}return ji.errors=r,s===0}function Ud(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ji(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ji.errors:r.concat(ji.errors),s=r.length),Ud.errors=r,s===0}var Yd=zd;var Jf={type:"object",properties:{fileId:{type:"string"},fileType:{type:"string"},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["fileId"],additionalProperties:!1};function Ti(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!Ze.call(Jf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(o<0||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(o<-1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Jf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof o=="number"&&(o<0||isNaN(o))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Ti.errors=r,s===0}function zd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ti(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ti.errors:r.concat(Ti.errors),s=r.length),zd.errors=r,s===0}var Xd=Gd;var Yk=new RegExp("^.+$","u");function Di(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[l]:r.push(l),s++}if(e.jsonData===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};r===null?r=[l]:r.push(l),s++}if(e.width===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[l]:r.push(l),s++}if(e.height===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[l]:r.push(l),s++}for(let l in e)if(!(l==="fileId"||l==="jsonData"||l==="width"||l==="height"||l==="animations")){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let l={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.jsonData!==void 0){let l=e.jsonData;if(!(l&&typeof l=="object"&&!Array.isArray(l))){let c={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}if(e.width!==void 0){let l=e.width;if(!(typeof l=="number"&&!(l%1)&&!isNaN(l))){let c={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[c]:r.push(c),s++}}if(e.height!==void 0){let l=e.height;if(!(typeof l=="number"&&!(l%1)&&!isNaN(l))){let c={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[c]:r.push(c),s++}}if(e.animations!==void 0){let l=e.animations;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(Yk.test(c)){let u=l[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.frames===void 0){let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/required",keyword:"required",params:{missingProperty:"frames"},message:"must have required property 'frames'"};r===null?r=[p]:r.push(p),s++}for(let p in u)if(!(p==="frames"||p==="animationSpeed"||p==="loop")){let m={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(u.frames!==void 0){let p=u.frames;if(Array.isArray(p)){let m=p.length;for(let d=0;d<m;d++){let f=p[d],h=s,g=!1,y=null,b=s;if(typeof f!="number"){let A={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/oneOf/0/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[A]:r.push(A),s++}var o=b===s;o&&(g=!0,y=0);let w=s;if(typeof f!="string"){let A={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/oneOf/1/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}var o=w===s;if(o&&g?(g=!1,y=[y,1]):o&&(g=!0,y=1),g)s=h,r!==null&&(h?r.length=h:r=null);else{let A={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/oneOf",keyword:"oneOf",params:{passingSchemas:y},message:"must match exactly one schema in oneOf"};r===null?r=[A]:r.push(A),s++}}}else{let m={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}}if(u.animationSpeed!==void 0&&typeof u.animationSpeed!="number"){let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/animationSpeed",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[p]:r.push(p),s++}if(u.loop!==void 0&&typeof u.loop!="boolean"){let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/loop",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[p]:r.push(p),s++}}else{let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let c={instancePath:t+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Di.errors=r,s===0}function Gd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Di(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Di.errors:r.concat(Di.errors),s=r.length),Gd.errors=r,s===0}var Hd=Kd;var il={type:"object",properties:{fontId:{oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1}}]},colorId:{type:"string"},colorAlpha:{type:"number"},fontSize:{type:"number"},fontWeight:{type:["string","number"]},fontStyle:{type:"string",enum:["normal","italic","oblique"]},lineHeight:{type:"number"},align:{type:"string"},wordWrap:{type:"boolean"},breakWords:{type:"boolean"},wordWrapWidth:{type:"number"},strokeColorId:{type:"string"},strokeAlpha:{type:"number"},strokeWidth:{type:"number"},shadow:{type:"object",properties:{colorId:{type:"string",minLength:1},alpha:{type:"number",minimum:0,maximum:1},blur:{type:"number",minimum:0},offsetX:{type:"number"},offsetY:{type:"number"}},required:["colorId"],additionalProperties:!1}},required:["fontId","fontSize","fontWeight","fontStyle","lineHeight","colorId"],additionalProperties:!1};function Li(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};r===null?r=[l]:r.push(l),s++}if(e.fontSize===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};r===null?r=[l]:r.push(l),s++}if(e.lineHeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};r===null?r=[l]:r.push(l),s++}if(e.colorId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[l]:r.push(l),s++}for(let l in e)if(!Ze.call(il.properties,l)){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.fontId!==void 0){let l=e.fontId,c=s,u=!1,p=null,m=s;if(typeof l=="string"){if($e(l)<1){let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}var o=m===s;o&&(u=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let y={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[y]:r.push(y),s++}let f=l.length;for(let y=0;y<f;y++){let b=l[y];if(typeof b=="string"){if($e(b)<1){let w={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}}let h=l.length,g;if(h>1){let y={};for(;h--;){let b=l[h];if(typeof b=="string"){if(typeof y[b]=="number"){g=y[b];let w={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:h,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+h+" are identical)"};r===null?r=[w]:r.push(w),s++;break}y[b]=h}}}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),s++}var o=d===s;if(o&&u?(u=!1,p=[p,1]):o&&(u=!0,p=1),u)s=c,r!==null&&(c?r.length=c:r=null);else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),s++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:t+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:t+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight!==void 0){let l=e.fontWeight;if(typeof l!="string"&&typeof l!="number"){let c={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:il.properties.fontWeight.type},message:"must be string,number"};r===null?r=[c]:r.push(c),s++}}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:il.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:t+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:t+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:t+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:t+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:t+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:t+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:t+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:t+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[c]:r.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if($e(c)<1){let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[u]:r.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:t+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:t+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}}else{let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Li.errors=r,s===0}function Kd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Li(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Li.errors:r.concat(Li.errors),s=r.length),Kd.errors=r,s===0}var Wd=Jd;var zk={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function Mi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!Ze.call(zk.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0){let o=e.x;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.y!==void 0){let o=e.y;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let o={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let o={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Mi.errors=r,s===0}function Jd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Mi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Mi.errors:r.concat(Mi.errors),s=r.length),Jd.errors=r,s===0}var Qd=Zd;function Vi(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}if(e.width===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[o]:r.push(o),s++}if(e.height===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="fileId"||o==="fileType"||o==="width"||o==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.width!==void 0){let o=e.width;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let o=e.height;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Vi.errors=r,s===0}function Zd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Vi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Vi.errors:r.concat(Vi.errors),s=r.length),Zd.errors=r,s===0}var Cn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),$n=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$r=e=>e===void 0?void 0:structuredClone(e),Xk=Object.freeze({achievement:"achievements",animation:"animations",audioEffect:"audioEffects",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),Gk=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Hk=Object.freeze({background:Qf,bgm:ed,character:td,choice:sd,cleanAll:od,control:ld,dialogue:ud,form:fd,layout:md,screen:hd,sfx:bd,visual:Id,voice:kd}),Kk=Object.freeze({achievement:Pd,animation:Ed,audioEffect:Od,character:$d,color:_d,control:jd,font:Dd,image:Md,layout:qd,particle:Bd,sound:Yd,spritesheet:Xd,textStyle:Hd,transform:Wd,video:Qd}),Wk=new Set(["files","language","patches"]),Jk=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Qk=new Set(["lineId","mode","payload","type"]),Zk=new Set(["mode","payload","sceneId","type"]),eA=new Set(["mode","operation","payload","resourceId","type"]),rA=new Set(["fileId","mimeType"]),J=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},ir=(e,t)=>{$n(e)||J(t,"expected an object")},al=(e,t)=>{Array.isArray(e)||J(t,"expected an array")},qt=(e,t)=>{(typeof e!="string"||e.length===0)&&J(t,"expected a non-empty string")},nm=(e,t)=>{typeof e!="string"&&J(t,"expected a string")},wr=(e,t,n)=>{for(let i of Object.keys(e))t.has(i)||J(`${n}.${i}`,"unknown field")},Ir=(e,t,n)=>{for(let i of t)Cn(e,i)||J(n,`missing required field "${i}"`)},tA=e=>e.replaceAll("~1","/").replaceAll("~0","~"),nA=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(tA);return t?.keyword==="required"?n.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&n.push(t.params.additionalProperty),n.reduce((i,a)=>/^\d+$/.test(a)?`${i}[${a}]`:`${i}.${a}`,e)},sA=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,n)=>{if(t===void 0)return n;let i=n.instancePath.split("/").length,a=t.instancePath.split("/").length;return i>a?n:t},void 0)??e[0],sm=({value:e,validator:t,path:n,contract:i})=>{if(t(e))return;let a=sA(t.errors);J(nA(n,a),`does not match ${i}: ${a?.message??"schema validation failed"}`)},qi=(e,t,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||J(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((i,a)=>qi(i,`${t}[${a}]`,n));return}Object.entries(e).forEach(([i,a])=>qi(a,`${t}.${i}`,n))}},br=(e,t)=>{e===""&&J(t,"expected a non-empty resourceId")},iA=(e,t,n)=>{let i=(s,o)=>br(s?.resourceId,`${o}.resourceId`),a=(s,o)=>(s??[]).forEach((l,c)=>br(l?.resourceId,`${o}[${c}].resourceId`)),r=(s,o)=>{br(s?.resourceId,`${o}.resourceId`),a(s?.sounds,`${o}.sounds`)};switch(e){case"background":br(t.resourceId,`${n}.resourceId`),i(t.animations,`${n}.animations`);break;case"bgm":i(t.audioEffects,`${n}.audioEffects`),r(t,n);break;case"voice":r(t,n);break;case"sfx":a(t.items,`${n}.items`),(t.channels??[]).forEach((s,o)=>a(s?.sounds,`${n}.channels[${o}].sounds`));break;case"character":(t.items??[]).forEach((s,o)=>{(s.sprites??[]).forEach((l,c)=>br(l?.resourceId,`${n}.items[${o}].sprites[${c}].resourceId`)),i(s.animations,`${n}.items[${o}].animations`)});break;case"choice":case"form":case"layout":br(t.resourceId,`${n}.resourceId`),i(t.animations,`${n}.animations`);break;case"control":br(t.resourceId,`${n}.resourceId`);break;case"dialogue":br(t.ui?.resourceId,`${n}.ui.resourceId`),i(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,o)=>br(s?.resourceId,`${n}.character.sprite.items[${o}].resourceId`)),i(t.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":i(t.animations,`${n}.animations`);break;case"visual":(t.items??[]).forEach((s,o)=>{br(s?.resourceId,`${n}.items[${o}].resourceId`),i(s?.animations,`${n}.items[${o}].animations`)});break;default:break}},Ft=(e,t)=>{qt(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&J(t,`"${e}" is not a safe ID`)},oA=(e,t)=>{qt(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&J(t,"must be a safe single filename")},Rn=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((a,r)=>Rn(a,t[r]));if(!$n(e)||!$n(t))return!1;let n=Object.keys(e).sort(),i=Object.keys(t).sort();return Rn(n,i)&&n.every(a=>Rn(e[a],t[a]))},Fi=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(i=>Fi(i,t,n)),t;if(!$n(e)||n.has(e))return t;n.add(e);for(let[i,a]of Object.entries(e))i==="fileId"&&typeof a=="string"&&t.add(a),Fi(a,t,n);return t},aA=e=>{let t=new Map;for(let[n,i]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(i?.sections??{}))for(let[s,o]of(r?.lines??[]).entries()){if(typeof o?.id!="string")continue;let l=t.get(o.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:o}),t.set(o.id,l)}return t},im=(e,t,n)=>{let i=e.get(t)??[];return i.length===0&&J(n,`lineId "${t}" does not exist in projectData`),i.length>1&&J(n,`lineId "${t}" is not globally unique in projectData`),i[0]},om=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],em=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),rm=e=>{let t=$r(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))$n(n)&&delete n.placeholder;return t},lA=(e,t,n,i)=>{e==="choice"&&!Rn(em(t),em(n))&&J(i,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Rn(rm(t),rm(n))&&J(i,"form behavior must remain identical; only presentation fields and placeholders may change")},cA=({patch:e,path:t,lineIndex:n})=>{wr(e,Jk,t),Ir(e,["type","lineId","actionType","payload"],t),Ft(e.lineId,`${t}.lineId`),qt(e.actionType,`${t}.actionType`),ir(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&J(`${t}.mode`,'line.action supports only "replace"'),Gk.has(e.actionType)||J(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let i=im(n,e.lineId,`${t}.lineId`),a=i.line?.actions?.[e.actionType];return a===void 0&&J(`${t}.actionType`,`source line "${e.lineId}" does not contain action "${e.actionType}"`),e.actionType==="dialogue"?((!Array.isArray(e.ignoreFields)||e.ignoreFields.length!==1||e.ignoreFields[0]!=="content")&&J(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),Cn(e.payload,"content")&&J(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&J(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),lA(e.actionType,a,e.payload,`${t}.payload`),sm({value:e.payload,validator:Hk[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),qi(e.payload,`${t}.payload`),iA(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:i,patch:e}},uA=(e,t)=>{al(e,t),e.forEach((n,i)=>{ir(n,`${t}[${i}]`),wr(n,new Set(["text"]),`${t}[${i}]`),Ir(n,["text"],`${t}[${i}]`),nm(n.text,`${t}[${i}].text`)})},pA=({patch:e,path:t,lineIndex:n})=>{wr(e,Qk,t),Ir(e,["type","lineId","payload"],t),Ft(e.lineId,`${t}.lineId`),ir(e.payload,`${t}.payload`),wr(e.payload,new Set(["content"]),`${t}.payload`),Ir(e.payload,["content"],`${t}.payload`),uA(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&J(`${t}.mode`,'line.dialogue supports only "replace"');let i=im(n,e.lineId,`${t}.lineId`);return i.line?.actions?.dialogue===void 0&&J(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:i,patch:e}},fA=({patch:e,path:t,projectData:n})=>(wr(e,Zk,t),Ir(e,["type","mode","sceneId","payload"],t),Ft(e.sceneId,`${t}.sceneId`),ir(e.payload,`${t}.payload`),wr(e.payload,new Set(["name"]),`${t}.payload`),Ir(e.payload,["name"],`${t}.payload`),nm(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&J(`${t}.mode`,'story.scene requires "patch"'),Cn(n?.story?.scenes??{},e.sceneId)||J(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),dA=(e,t,n)=>{ir(t,n),["font","image","sound","spritesheet","video"].includes(e)&&qt(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||J(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||J(`${n}.height`,"expected an integer")),e==="spritesheet"&&(ir(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||J(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||J(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&J(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),sm({value:t,validator:Kk[e],path:n,contract:`the resource.${e} schema`}),qi(t,n)},mA=({patch:e,path:t,projectData:n,packageFileIds:i,canonicalFileIds:a})=>{wr(e,eA,t),Ir(e,["type","resourceId","payload"],t),Ft(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=Xk[r];s||J(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&J(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&J(`${t}.operation`,'the only resource operation is "add"'),dA(r,e.payload,`${t}.payload`);let o=n?.resources?.[s]??{},l=Cn(o,e.resourceId);e.operation==="add"&&l&&J(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&J(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of Fi(e.payload))!i.has(c)&&!a.has(c)&&J(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:t,patch:e}},tm=({resources:e,collectionName:t,resourceId:n,path:i,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!Cn(e?.[t]??{},n))&&J(i,`${a} resource "${n}" was not found`)},yA=(e,t)=>{let n=$r(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=$r(a.patch.payload));let i=n.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,s=Array.isArray(r.fontId)?r.fontId:[r.fontId];s.forEach((o,l)=>tm({resources:i,collectionName:"fonts",resourceId:o,path:`${a.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[o,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])tm({resources:i,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${o}`,label:"color"})}},hA=({patch:e,path:t,projectData:n,lineIndex:i,packageFileIds:a,canonicalFileIds:r})=>{if(ir(e,t),qt(e.type,`${t}.type`),e.type==="line.action")return cA({patch:e,path:t,lineIndex:i});if(e.type==="line.dialogue")return pA({patch:e,path:t,lineIndex:i});if(e.type==="story.scene")return fA({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return mA({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});J(`${t}.type`,`unsupported patch type "${e.type}"`)},gA=(e,t)=>{al(e,t);let n=new Set;return e.forEach((i,a)=>{let r=`${t}[${a}]`;ir(i,r),wr(i,rA,r),Ir(i,["fileId"],r),oA(i.fileId,`${r}.fileId`),i.mimeType!==void 0&&(typeof i.mimeType!="string"||i.mimeType.length===0)&&J(`${r}.mimeType`,"expected a non-empty string"),n.has(i.fileId)&&J(`${r}.fileId`,`duplicate fileId "${i.fileId}"`),n.add(i.fileId)}),n},bA=({packageId:e,packageData:t,path:n,projectData:i,lineIndex:a,canonicalFileIds:r})=>{ir(t,n),wr(t,Wk,n),Ir(t,["language","files","patches"],n),qt(t.language,`${n}.language`);let s=gA(t.files,`${n}.files`);al(t.patches,`${n}.patches`);let o=new Set,l=t.patches.map((c,u)=>{let p=hA({patch:c,path:`${n}.patches[${u}]`,projectData:i,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return o.has(p.key)&&J(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),o.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},am=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};ir(t,"l10nData"),wr(t,new Set(["packages"]),"l10nData"),Ir(t,["packages"],"l10nData"),ir(t.packages,"l10nData.packages");let n=aA(e),i=Fi(e?.resources??{}),a=new Map,r=new Map;for(let[s,o]of Object.entries(t.packages)){Ft(s,`l10nData.packages.${s}`);let l=bA({packageId:s,packageData:o,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:i});for(let c of l.fileIds){i.has(c)&&J(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&J(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}yA(e,l),a.set(s,l)}return{packages:a}},wA=(e,t)=>{let{collectionName:n,patch:i}=t;e.resources[n]??={},e.resources[n][i.resourceId]=$r(i.payload)},IA=(e,t)=>{let{patch:n}=t,i=e.story.scenes[n.sceneId];i.name=n.payload.name},vA=(e,t)=>{let{location:n,patch:i}=t,a=om(e,n);if(i.actionType!=="dialogue"){a.actions[i.actionType]=$r(i.payload);return}let r=$r(n.line.actions.dialogue.content);a.actions.dialogue=$r(i.payload),r!==void 0&&(a.actions.dialogue.content=r)},kA=(e,t)=>{let{location:n,patch:i}=t,a=om(e,n);a.actions.dialogue.content=$r(i.payload.content)},lm=({projectData:e,l10nData:t})=>{let n=am({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),i=>({l10nId:i.id,language:i.data.language}))]},Bi=({projectData:e,l10nData:t,l10nId:n=null})=>{let i=am({projectData:e,l10nData:t});if(n!==null&&(Ft(n,"l10nId"),i.packages.has(n)||J("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=$r(e),r=i.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>wA(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>IA(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>vA(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>kA(a,s)),a};var ll=Object.freeze({auto:1e3,skip:80,authored:1e3}),jn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),cm=new WeakMap,AA=new ArrayBuffer(8),cl=new DataView(AA),PA=e=>{let t=cm.get(e);if(t)return t;let n={dispatchDepth:0};return cm.set(e,n),n},xA=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},EA=(e,t)=>Object.keys(e).length===t.length&&t.every(i=>Object.prototype.hasOwnProperty.call(e,i)),Gr=(e,t,n)=>{if(!xA(e)||!EA(e,t))throw new TypeError(`${n} has an invalid shape`)},_n=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},Nn=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},um=e=>{if(Nn(e,"duration"),e===0)return 0n;cl.setFloat64(0,e,!1);let t=cl.getUint32(0,!1),n=cl.getUint32(4,!1),i=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(n);if(i===0)return a;let r=1n<<52n|a,s=i-1;return r<<BigInt(s)},SA=e=>structuredClone(e),ul=(e,t)=>e===t?!0:!e||!t||e.mode!==t.mode||e.kind!==t.kind?!1:e.mode==="legacy"?e.instanceToken===t.instanceToken:e.delayMs!==t.delayMs?!1:e.kind==="auto"?e.contentKey===t.contentKey&&e.owner.sessionId===t.owner.sessionId&&e.owner.lineEntryId===t.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===t.owner.sessionId:e.trigger===t.trigger&&e.owner.lineEntryId===t.owner.lineEntryId,pl=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(Gr(t,["owner","delayMs","contentKey"],"auto timer"),Gr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),_n(t.owner.sessionId,"auto owner sessionId"),_n(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(Nn(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Gr(t,["owner","delayMs"],"skip timer"),Gr(t.owner,["sessionId"],"skip timer owner"),_n(t.owner.sessionId,"skip owner sessionId"),Nn(t.delayMs,"skip delayMs");else{if(Gr(t,["owner","delayMs","trigger"],"authored timer"),Gr(t.owner,["lineEntryId"],"authored timer owner"),_n(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(Nn(t.delayMs,"authored delayMs"),t.trigger!=="fromStart"&&t.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...SA(t)}},OA=e=>{if(Gr(e,["contractVersion","status","lineEntryId","timers"],"playback schedule"),e.contractVersion!==1)throw new TypeError("playback schedule contractVersion must be 1");if(e.status!=="settled"&&e.status!=="unsettled")throw new TypeError('playback schedule status must be "settled" or "unsettled"');if(_n(e.lineEntryId,"playback schedule lineEntryId"),e.status==="unsettled"){if(e.timers!==null)throw new TypeError("unsettled playback schedule timers must be null");return{contractVersion:1,status:"unsettled",lineEntryId:e.lineEntryId,timers:null}}Gr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:pl("auto",e.timers.auto,e.lineEntryId),skip:pl("skip",e.timers.skip,e.lineEntryId),authored:pl("authored",e.timers.authored,e.lineEntryId)};if(t.auto&&t.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:t}},fl=e=>({descriptor:e,remainingQuanta:um(e.delayMs)}),Ui=["auto","skip","authored"],pm=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:n=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof t!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let i=PA(e),a=!0,r={},s={},o=null,l=null,c=null,u=null,p=!1,m=!1,d="legacy",f={auto:null,skip:null,authored:null},h={auto:null,skip:null,authored:null},g={auto:0,skip:0,authored:0},y=()=>Ui.some(M=>f[M]),b=()=>{l=null,c=null},w=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(i.dispatchDepth>0||m){w();return}a&&r===M.lifecycleToken&&s===M.generationToken&&o===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},A=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=o;M&&(b(),o=null,u=M,e.remove(M),u===M&&(u=null))},P=()=>{f={auto:null,skip:null,authored:null}},I=()=>{P(),s={},m||k()},x=M=>{if(i.dispatchDepth>0||m){c=M,w();return}a&&r===M.lifecycleToken&&s===M.generationToken&&o===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},T=()=>{if(!a||!y()||o)return;A();let M=r,Q=s,le={},H=ue=>{if(!a||M!==r||Q!==s||le!==l||H!==o||m)return;if(!ue||typeof ue.deltaMS!="number"||!Number.isFinite(ue.deltaMS)||ue.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let de=um(ue.deltaMS);m=!0,i.dispatchDepth+=1;let ce=s,Z=null;try{let _=[];for(let D of Ui){let F=f[D];F&&(F.remainingQuanta<=de?(_.push({kind:D,descriptor:F.descriptor,revision:g[D]}),f[D]=null):F.remainingQuanta-=de)}if(_.length>0){try{t({dueKinds:_.map(({kind:D})=>D)})}catch(D){let F=n(D);if(d==="reconciled"&&F==="preCommit")for(let{kind:W,descriptor:ye}of _)h[W]=ye;else d==="legacy"&&P();throw D}if(d==="legacy")for(let D of _)D.kind==="skip"&&g.skip===D.revision&&f.skip===null&&(f.skip=fl(D.descriptor))}}catch(_){Z=_}finally{i.dispatchDepth-=1,m=!1;try{ce===s?y()?T():k():o===H&&!y()&&k()}catch(_){throw Z?new AggregateError([Z,_],"Playback attempt and ticker cleanup both failed"):_}}if(Z)throw Z},ne={callback:H,lifecycleToken:M,generationToken:Q,registrationToken:le};o=H,c=ne;try{e.add(H)}catch(ue){throw o=null,b(),P(),s={},u=H,ue}x(ne)},C=M=>{g[M]+=1,f[M]=null,h[M]=null,!y()&&!m&&k()},$=(M,Q)=>{Nn(Q,`${M} delay`),d="legacy",g[M]+=1,h[M]=null,f[M]=fl({mode:"legacy",kind:M,instanceToken:{},delayMs:Q}),T()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return $("auto",M.payload?.delay??ll.auto),!0;case"clearAutoNextTimer":return C("auto"),!0;case"startSkipNextTimer":return $("skip",M.payload?.delay??ll.skip),!0;case"clearSkipNextTimer":return C("skip"),!0;case"nextLineConfigTimer":return $("authored",M.payload?.delay??ll.authored),!0;case"clearNextLineConfigTimer":return C("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let Q;try{Q=OA(M)}catch(H){try{I()}catch(ne){throw new AggregateError([H,ne],"Playback schedule validation and cleanup both failed")}throw H}if(d="reconciled",Q.status==="unsettled"){P(),m||k();return}let le={};for(let H of Ui){let ne=Q.timers[H],ue=h[H];if(ue&&(!ne||!ul(ue,ne))&&(h[H]=null),ne&&h[H]&&ul(h[H],ne)){le[H]=null;continue}let de=f[H];le[H]=ne&&de&&ul(de.descriptor,ne)?de:ne?fl(ne):null}f=le,y()?T():m||k()},reset:()=>{let M=[o,u].filter((H,ne,ue)=>H&&ue.indexOf(H)===ne);r={},s={},b(),o=null,u=null,P(),h={auto:null,skip:null,authored:null};for(let H of Ui)g[H]+=1;d="legacy",a=!0;let Q=null,le=null;for(let H of M)try{e.remove(H)}catch(ne){Q??=ne,le??=H}if(u=le,Q)throw Q},dispose:()=>{a=!1,r={},s={},b(),P(),h={auto:null,skip:null,authored:null};let M=[o,u].filter((H,ne,ue)=>H&&ue.indexOf(H)===ne);o=null,u=null;let Q=null,le=null;for(let H of M)try{e.remove(H)}catch(ne){Q??=ne,le??=H}if(u=le,Q)throw Q}}};var RA=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),$A=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),dl="conditional",Tn="random",yl=Symbol("conditionalAutoContinue"),CA=new Set(["sectionTransition","resetStoryAtSection"]),_A=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),NA=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),jA=new Set(["nextLine","nextLineFromSystem"]),TA=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),ml="form",DA=new Set(["submitForm","cancelForm"]),LA=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),MA="showImageGalleryVariant",VA="playMusicRoomTrack",qA="startSceneReplay",FA="channel:bgm",fm=1e3,BA="routing_cycle",UA=new Set(["startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","setAutoForwardDelay","setAutoForwardSpeed","setNextLineConfig","markLineCompleted","nextLine","nextLineFromSystem","jumpToLine","sectionTransition","resetStoryAtSection","loadSlot","rollbackByOffset","rollbackToLine","startSceneReplay","exitSceneReplay","updateProjectData","updateLocalizationPackage","submitForm","cancelForm"]),Ye=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),YA=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,Dn=e=>e?.type===yl,ht=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,zA=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(i=>!Object.is(e?.[i],t?.[i]));function hl(e){let t=YA(),n,i=0,a=!1,r=0,s=null,o=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],b=[],w=!1,A=null,k=null,P=null,I=null,x=new Map,T,C,$=null,q=!1,X=!1,N=0,K=new Map,M=Sc(e.randomSource),{handlePendingEffects:Q}=e;if(typeof Q!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let le=Q.bind(Q),H=typeof Q.reconcilePlaybackScheduleV1=="function"?Q.reconcilePlaybackScheduleV1.bind(Q):null,ne=typeof Q.reset=="function"?Q.reset.bind(Q):null,ue=typeof Q.dispose=="function"?Q.dispose.bind(Q):null;if(H&&(!ne||!ue))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let de=v=>{if(X)throw new Error(`RouteEngine cannot ${v} during playback reconciliation`)},ce=v=>{if(de(v),!a||!n)throw new Error(`RouteEngine ${v} requires an active engine`)},Z=(v,E)=>{if(N===0)return;let O={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=K.get(v);(R===void 0||O[E]>O[R])&&K.set(v,E)},_=v=>{let E=K.get(v)??"preCommit";return K.delete(v),E},D=v=>{if(H){X=!0;try{let E=H(structuredClone(v));if(E!==null&&(typeof E=="object"||typeof E=="function")&&typeof E.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{X=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),W=v=>{if(!(!H||!a||!n)){q=!0;try{D(F())}catch(E){if(v){let O=new AggregateError([v,E],"Playback work and schedule invalidation both failed");throw K.delete(v),Z(O,"reconcileFailed"),O}throw Z(E,"reconcileFailed"),E}}},ye=()=>{if(!H||!q||!a||!n||o>0||l)return;let v;try{v=n.selectDesiredPlaybackTimers()}catch(E){throw Z(E,"reconcileFailed"),W(E),E}try{D({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:v})}catch(E){throw Z(E,"reconcileFailed"),W(E),E}q=!1},ke=(v=new Map,E=Date.now())=>new Map(Array.from(v.entries()).filter(([,O])=>E<O.expiresAt).map(([O,R])=>[O,{animation:structuredClone(R.animation),startedAt:R.startedAt,expiresAt:R.expiresAt}])),fe=(v=new Map)=>Array.from(v.values()).map(E=>structuredClone(E.animation)),he=(v=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,E])=>v<E.expiresAt))},vr=()=>{if(!a||o>0||l)return;l=!0;let v=0;try{for(;n.selectPendingEffects().length>0;){let E=n.selectCurrentPointer()?.pointer??null;if(v>=fm){let j=new Error(`RouteEngine exceeded ${fm} synchronous effect batches at section "${E?.sectionId}", line "${E?.lineId}". Check for an immediate routing cycle.`);throw j.code=BA,j.pointer={sectionId:E?.sectionId,lineId:E?.lineId},Z(j,"postCommitUnsettled"),W(j),j}v+=1;let O=[...n.selectPendingEffects()],R=O.map(j=>j.name!=="handleLineActions"?j:{...j,payload:{...j.payload,pointer:structuredClone(E)}});n.clearPendingEffects();try{let j=H?R.filter(Y=>!jn.has(Y.name)):R;j.length>0&&le(j)}catch(j){throw n.clearPendingEffects(),O.forEach(Y=>{n.appendPendingEffect(Y)}),Z(j,"postCommitUnsettled"),W(j),j}}}finally{l=!1}ye()},er=v=>{o+=1;let E=!1;try{let O=v();return E=!0,O}finally{o-=1,E&&vr()}},gt=()=>pa({presentationState:n.selectPresentationState(),previousBgmRender:bt(),resources:n.selectBgmResources(),...n.selectBgmPlaybackContext()}),Cr=()=>structuredClone(n.selectPresentationState()?.bgm??null),Hr=()=>n.selectBgmResources(),bt=()=>({channel:A,bgm:k,resources:P}),Bt=v=>!!v?.audioEffects,Kr=()=>structuredClone(w?A:gt()),wt=()=>w?structuredClone(k):Cr(),Wr=()=>w?structuredClone(P):Hr(),Ln=v=>n.selectSceneIdForSection({sectionId:v}),Ut=()=>{if(b.length===0)return;let v=n.selectRuntime()?.skipTransitionsAndAnimations===!0,E=new Set(v?[]:y.map(O=>O.id));b.forEach(O=>{O.status=O.effects?.some(R=>E.has(R.id))?"active":"settled"}),v&&(y=[]),b=[]},Yt=(v,E,O,R,j,Y,z)=>{let ee=n.selectPlaybackLineEntryId?.()??0,oe=(E.actionPath??["bgm"]).join("."),we=n.selectCurrentPointer()?.pointer,ge=we?.sceneId??Ln(we?.sectionId),Se=E.rollbackSource==="line"&&we?`story.scenes[${JSON.stringify(ge)}].sections[${JSON.stringify(we.sectionId)}].lines[${JSON.stringify(we.lineId)}].actions.${oe}`:oe,Ce=E.rollbackSource==="line"?`${i}:${ee}:${Se}`:null,ze=Ce?x.get(Ce):null;if(ze)return ze;g+=1;let Te={occurrenceId:`${t}:g${i}:l${ee}:audio${g}`,actionPath:Se,selection:v?.audioEffects?structuredClone(v.audioEffects):null},Ae=Hr(),_r=Mc({occurrence:Te,resources:Ae,previousResources:z??Ae,nextResources:Ae,previousChannel:O,nextChannel:R,previousBgm:j,nextBgm:Y});if(Te.effects=structuredClone(_r),Te.status=_r.length>0?"pending":"settled",y=structuredClone(_r),b.push(Te),Ce)for(x.set(Ce,Te);x.size>512;){let qn=x.keys().next().value;x.delete(qn)}return Te},Yi=({initialState:v,namespace:E})=>{de("initialize");let O=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...j}=v,Y=R===void 0?void 0:structuredClone(R),z=structuredClone(v.projectData),ee=lm({projectData:z,l10nData:Y}),oe=j.global??{};if(!Ye(oe))throw new Error("Malformed global state.");let we=oe.runtime??{};if(!Ye(we))throw new Error("Malformed global.runtime.");let ge=we.localizationPackageId;if(ge!=null&&typeof ge!="string")throw new Error("localizationPackageId requires a string or null value");let Se=new Set(ee.map(({l10nId:Ae})=>Ae).filter(Ae=>Ae!==null)),Ce=typeof ge=="string"&&Se.has(ge)?ge:null,ze=Bi({projectData:z,l10nData:Y,l10nId:Ce}),Te=Mf({...j,global:{...oe,localizationPackages:ee,runtime:{...we,localizationPackageId:Ce}},projectData:ze,initialAudioCommandId:O});ne?.(),n=Te,i+=1,a=!0,r=0,s=Vt(E),o=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],b=[],w=!1,A=null,k=null,P=null,I={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:Hr()},x=new Map,T=z,C=Y,$=Ce,q=!0,X=!1,N=0,K.clear(),n.appendPendingEffect({name:"handleLineActions"}),vr()},Mn=()=>{de("dispose"),a&&(a=!1,i+=1,n?.clearPendingEffects?.(),o=0,l=!1,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,y=[],b=[],w=!1,A=null,k=null,P=null,I=null,x=new Map,q=!1,K.clear(),ue?.())},gm=()=>s,bm=()=>n.selectPresentationState(),wm=()=>n.selectPresentationChanges(),Im=v=>n.selectSectionLineChanges(v),bl=(v={})=>{ce("rendering"),r+=1;let E=Date.now();he(E);let O=f.size>0,R=ke(d,E),j=O?ke(f,E):new Map,Y=n.selectRenderState({previousBgmRender:bt(),activePersistentAnimations:fe(R),restoredPersistentAnimations:fe(j),activeAudioEffects:structuredClone(y)}),z={...Y,id:`render-${t}-${i}-${r}`};return h.set(z.id,{builtAt:E,persistentAnimationSessions:new Map([...j.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:O,activeAudioEffectIds:y.map(ee=>ee.id),bgmPresentation:Cr(),bgmResources:Hr(),retainsActiveAudioEffects:y.length>0&&y.every(ee=>(Y.audioEffects??[]).some(oe=>oe.id===ee.id))}),z},vm=(v={})=>bl(v),km=(v={})=>bl(v),Am=v=>{if(!a||!n)return;let E=typeof v?.id=="string"&&v.id.length>0?v.id:null,O=E?h.get(E):null;E&&h.delete(E);let R=v?.audio?.find(Y=>Y?.id===FA);w=!0,A=R?structuredClone(R):null,k=structuredClone(O?.bgmPresentation??null),P=structuredClone(O?.bgmResources??null);let j=new Map;Au(v?.animations).forEach(Y=>{let z=ks(Y);if(!z)return;let ee=O?.persistentAnimationSessions?.get(z)??d.get(z),oe=Math.max(0,Su(Y)),we=ee?.startedAt??O?.builtAt??Date.now();j.set(z,{animation:structuredClone(Y),startedAt:we,expiresAt:we+oe})}),d=j,O?.usedRestoredPersistentAnimationSessions&&(f=new Map),O?.activeAudioEffectIds?.length>0&&!O.retainsActiveAudioEffects&&y.length===O.activeAudioEffectIds.length&&O.activeAudioEffectIds.every(Y=>y.some(z=>z.id===Y))&&(y=[])},Pm=()=>n.selectSystemState(),xm=()=>n.selectAchievements(),Em=v=>n.selectAchievement(v),wl=()=>n.selectSaveSlotMap(),Sm=v=>n.selectSaveSlot(v),Om=v=>n.selectSaveSlotPage(v),Rm=()=>n.selectImageGallery(),$m=()=>n.selectMusicRoom(),Cm=()=>n.selectSceneReplay(),_m=()=>n.selectIsSceneReplayActive(),sP=()=>n.selectSkipMode(),iP=()=>n.selectAutoMode(),Nm=()=>n.selectRuntime(),jm=()=>n.selectIsChoiceVisible(),Tm=()=>n.selectIsFormVisible(),Dm=()=>n.selectActiveInteraction(),Lm=()=>n.selectPendingEffects().some(v=>v?.name==="handleLineActions"||v?.name==="render"),Il=(v,E,O={})=>!Ye(E)||v!=="nextLine"?E:O.bypassChoice===!0?{...E,bypassChoice:!0}:O.interactionSource===ml?{...E,_interactionSource:ml}:E,vl=(v={})=>({type:yl,payload:Il("nextLine",{_conditionalContinuation:!0},v)}),zi=(v,E)=>Dn(v)?{type:yl,payload:{...v.payload,...E.payload}}:E,Mm=v=>{v.savedCheckpointOccurrences.forEach(E=>{n.markSavedRollbackCheckpointTransient(E)}),v.savedCheckpointOccurrences=[]},Vm=(v,E)=>{let O=p;return p=null,!O||!ht(O.pointer,v)||O.checkpointIndex!==E?.checkpointIndex||O.checkpointIdentity!==E?.checkpoint?[]:O.savedCheckpointOccurrences},qm=v=>{let E=m;return!E||!ht(E.pointer,v)?null:(m=null,E)},Fm=({actionType:v,pointerBeforeAction:E,pointerAfterAction:O,cursorBeforeAction:R,cursorAfterAction:j,wasSceneReplayActive:Y,isSceneReplayActive:z})=>{!O||!(!ht(E,O)||R?.checkpoint!==j?.checkpoint||R?.checkpointIndex!==j?.checkpointIndex||v==="jumpToLine")||(m={pointer:O,appendToPrevious:jA.has(v)&&Y===z&&E?.sectionId===O.sectionId&&E?.lineId!==O.lineId,reuseExistingOccurrence:TA.has(v),forceNewOccurrence:v==="jumpToLine"})},kl=v=>{v.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:v.rollbackCursor?.checkpointIndex,checkpointIdentity:v.rollbackCursor?.checkpoint,sectionId:v.pointer?.sectionId,lineId:v.pointer?.lineId}),Mm(v))},Bm=(v,E,O)=>_A.has(v)?v==="resetStoryAtSection"?O?.checkpoint!==E?.checkpoint:O?.checkpoint!==E?.checkpoint&&O?.checkpointIndex>E?.checkpointIndex:!1,Um=v=>{let E=u.at(-1);if(!E?.markCurrentCheckpointTransient)return;let O=n.selectSaveSlot({slotId:v?.slotId});O&&E.savedCheckpointOccurrences.push({slotId:v.slotId,saveSlotIdentity:O,checkpointIndex:E.rollbackCursor?.checkpointIndex,sectionId:E.pointer?.sectionId,lineId:E.pointer?.lineId})},Ym=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(E=>{let O=n.selectSaveSlot({slotId:E.slotId});O&&(E.saveSlotIdentity=O)})},zm=()=>{let v=u.at(-1);v&&(v.rollbackCursor=n.selectRollbackCursor?.()??null)},Xm=(v,E,O)=>{let R=u.at(-1);if(!R)return;let j=n.selectCurrentPointer()?.pointer,Y=Bm(v,E,O);if(ht(R.pointer,j)){let z=O?.checkpoint!==E?.checkpoint||O?.checkpointIndex!==E?.checkpointIndex;Y||z&&NA.has(v)?(kl(R),R.pointer=j,R.rollbackCursor=O,R.markCurrentCheckpointTransient=Y,R.savedCheckpointOccurrences=[]):z&&v==="updateProjectData"&&(R.rollbackCursor=O);return}kl(R),R.pointer=j,R.rollbackCursor=n.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=Y,R.savedCheckpointOccurrences=[]},It=(v,E)=>{if(ce(`action "${v}"`),!n[v])return;let O=E,R,j;if(v==="updateProjectData")Al(E),R=structuredClone(E.projectData),O={...E,projectData:Bi({projectData:R,l10nData:C,l10nId:$})},Al(O);else if(v==="updateLocalizationPackage"){if(j=Gm(E),j===$)return;O={l10nId:j,projectData:Bi({projectData:T,l10nData:C,l10nId:j})}}CA.has(v)&&(c+=1);let Y=n.selectAutoMode(),z=Y?n.selectRuntime():null,ee=n.selectIsSceneReplayActive?.()===!0,oe=$A.has(v)?ke(d):null,we=n.selectCurrentPointer()?.pointer??null,ge=n.selectRollbackCursor?.()??null,Se=ps(v),Ce=Se?n.selectPlaybackLineEntryId?.()??0:null,ze=Se?Kr():null,Te=Se?wt():null,Ae=Se?Wr():null,_r=!1,qn;try{qn=n[v](O),_r=!0}catch(zt){throw Z(zt,"preCommit"),zt}R!==void 0&&(T=R),j!==void 0&&($=j),RA.has(v)&&(f=oe??new Map,d=new Map,y=[]),v==="setSkipTransitionsAndAnimations"&&O?.value===!0&&(y=[]);let Rl=n.selectIsSceneReplayActive?.()===!0;ee!==Rl&&(d=new Map,f=new Map);let ay=n.selectCurrentPointer()?.pointer??null,$l=n.selectRollbackCursor?.()??null,Cl=Se?n.selectPlaybackLineEntryId?.()??0:null;Se&&Cl!==Ce&&(I={lineEntryId:Cl,channel:ze,presentation:Te,resources:Ae}),v==="saveSlot"?Um(E):v==="updateProjectData"&&Ym(),Xm(v,ge,$l),Fm({actionType:v,pointerBeforeAction:we,pointerAfterAction:ay,cursorBeforeAction:ge,cursorAfterAction:$l,wasSceneReplayActive:ee,isSceneReplayActive:Rl});let ly=n.selectAutoMode()&&(v==="updateVariable"||Y&&zA(z,n.selectRuntime()));(UA.has(v)||ly)&&(q=!0);try{vr()}catch(zt){throw _r&&Z(zt,"postCommitUnsettled"),zt}return qn},Al=v=>{if(!Object.prototype.hasOwnProperty.call(v??{},"projectData"))throw new Error("updateProjectData requires projectData");nt(v?.projectData?.resources?.variables??{}),Qt(v.projectData),Zt(v.projectData),en(v.projectData)},Gm=v=>{if(!Ye(v))throw new Error("updateLocalizationPackage requires an object payload");let E=Object.keys(v);if(E.length!==1||E[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(v.l10nId!==null&&(typeof v.l10nId!="string"||v.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return v.l10nId},Hm=(v,E,O)=>{let R=n.selectCurrentPointer()?.pointer;E!==R||O!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),It("nextLineFromSystem",v.payload))},Km=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(h),audioEffectOccurrenceSequence:g,activeAudioEffects:y,pendingAudioEffectOccurrences:b.slice(),pendingEnteredLineBgmHandoff:I?structuredClone(I):null,acceptedLineBgmActionOccurrences:new Map(x),canonicalProjectData:T,localizationPackageId:$,playbackScheduleDirty:q}),Wm=v=>{r=v.renderSequence,c=v.conditionalRoutingSequence,u=v.rollbackNavigationContexts.slice(),p=v.pendingRollbackLineEntrySaveHandoff,m=v.pendingDialogueHistoryLineEntry,d=new Map(v.persistentAnimationSessions),f=new Map(v.restoredPersistentAnimationSessions),h=new Map(v.renderPersistentAnimationMetadata),g=v.audioEffectOccurrenceSequence,y=v.activeAudioEffects,b=v.pendingAudioEffectOccurrences.slice(),I=v.pendingEnteredLineBgmHandoff?structuredClone(v.pendingEnteredLineBgmHandoff):null,x=new Map(v.acceptedLineBgmActionOccurrences),T=v.canonicalProjectData,$=v.localizationPackageId,q=v.playbackScheduleDirty},Xi=(v,E={})=>(ce("action batch"),er(()=>{let O=Km();try{return n[ko](()=>{let R,j=n.selectCurrentPointer()?.pointer??null,Y=n.selectRollbackCursor?.()??null,z=c,ee={pointer:j,rollbackCursor:Y,markCurrentCheckpointTransient:E.rollbackSource==="line",savedCheckpointOccurrences:E.savedCheckpointOccurrences?.slice()??[]};u.push(ee);try{n.beginRollbackActionBatch({source:E.rollbackSource});try{R=v()}finally{n.endRollbackActionBatch({})}Dn(R)&&Hm(R,j,z),Ut();let oe=n.selectCurrentPointer()?.pointer??null;E.rollbackSource==="line"&&ht(j,oe)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:ee.savedCheckpointOccurrences,appendToPrevious:E.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:E.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:E.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!ht(j,ee.pointer)||Y?.checkpoint!==ee.rollbackCursor?.checkpoint)&&ee.markCurrentCheckpointTransient&&ee.savedCheckpointOccurrences.length>0&&(p={pointer:ee.pointer,checkpointIndex:ee.rollbackCursor?.checkpointIndex,checkpointIdentity:ee.rollbackCursor?.checkpoint,savedCheckpointOccurrences:ee.savedCheckpointOccurrences})}})}catch(R){throw Wm(O),R}})),Gi=(v,E,O,R={})=>{if(v===dl||v===Tn)return Xi(()=>{let j={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[v],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(v===Tn)return El(E,O,j);let Y=Hi(O),z=xt({[v]:E},Y);return xl(z[v],O,j)},R);if(v==="bgm")return Xi(()=>{let j=wt(),Y=Bt(E),z=Y?Kr():null,ee=Y?Wr():null;It(v,E);let oe=Cr();Yt(E,{...R,actionPath:R.actionPath??[v]},z,Y?gt():null,j,oe,ee)},R);It(v,E)},Jm=(v,E)=>{if(v!=="nextLineFromSystem")return Gi(v,E);N+=1;try{return Gi(v,E)}finally{N=Math.max(0,N-1)}},Pl=v=>{if(v&&Object.prototype.hasOwnProperty.call(v,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Hi=v=>{if(Pl(v),!v)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:E,...O}=v,R=n.selectAllVariables?n.selectAllVariables():void 0;return{...O,_event:E,variables:R,runtime:n.selectRuntime?n.selectRuntime():{}}},Qm=v=>{if(!Ye(v))return{templatePayload:v,literalTargetIds:null};let E=n.selectImageGalleryConfig();if(!Array.isArray(E?.groups))return{templatePayload:v,literalTargetIds:null};let O=typeof v.groupId=="string"?E.groups.find(j=>j.id===v.groupId):void 0;if(!O)return{templatePayload:v,literalTargetIds:null};let R=typeof v.variantId=="string"&&O.variants.some(j=>j.id===v.variantId);return{templatePayload:{...v,groupId:null,...R?{variantId:null}:{}},literalTargetIds:{groupId:v.groupId,...R?{variantId:v.variantId}:{}}}},Zm=v=>!Ye(v)||typeof v.trackId!="string"?{templatePayload:v,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(R=>R.id===v.trackId)?{templatePayload:{...v,trackId:null},literalTargetIds:{trackId:v.trackId}}:{templatePayload:v,literalTargetIds:null},ey=v=>!Ye(v)||typeof v.sceneId!="string"?{templatePayload:v,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===v.sceneId)?{templatePayload:{...v,sceneId:null},literalTargetIds:{sceneId:v.sceneId}}:{templatePayload:v,literalTargetIds:null},ry=v=>{if(!Ye(v))throw new Error("conditional action payload must be an object");if(!Array.isArray(v.branches))throw new Error("conditional action requires branches array");if(v.branches.length===0)throw new Error("conditional action requires at least one branch")},ty=(v,E,O)=>{if(!Ye(v))throw new Error(`conditional branch at index ${E} must be an object`);if(!Ye(v.actions))throw new Error(`conditional branch at index ${E} requires actions object`);if(!Object.prototype.hasOwnProperty.call(v,"when")&&E!==O-1)throw new Error("conditional else branch must be the last branch")},xl=(v,E,O)=>{ry(v);let R=vl(O);for(let j=0;j<v.branches.length;j+=1){let Y=v.branches[j];ty(Y,j,v.branches.length);let z=Hi(E);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!Jt(Y.when,z))continue;let oe=Vn(Y.actions,E,{...O,actionPath:[...O.actionPath??[dl],"branches",String(j),"actions"]});return Dn(oe)?zi(R,oe):R}return R},ny=v=>{if(!Ye(v))throw new Error("random action payload must be an object");let E=Object.keys(v).find(O=>O!=="distribution"&&O!=="variableId");if(E!==void 0)throw new Error(`random action.${E} is not supported`);if(!Ye(v.distribution))throw new Error("random action requires distribution object");if(v.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(v,"variableId"))throw new Error("weighted random action does not support variableId")}else if(v.distribution.type==="integer"){if(typeof v.variableId!="string"||!v.variableId)throw new Error("integer random action requires variableId");let O=L(T?.resources?.variables,v.variableId);if(!O||O.type!=="number"||O.scope!=="context"||O.readonly===!0||Ne(O))throw new Error(`integer random action variableId must reference a writable context number variable: ${v.variableId}`)}},El=(v,E,O)=>{ny(v),Pl(E);let R=Oc(v.distribution,{randomSource:M});if(O.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let z=(O.actionPath??[Tn]).join("."),ee=O.randomOutcomeOrdinals??new Map,oe=ee.get(z)??0;ee.set(z,oe+1),n.recordRandomOutcome({path:z,ordinal:oe,type:R.type,result:R}),zm()}let j;R.type==="integer"?It("updateVariable",{id:"randomResult",operations:[{variableId:v.variableId,op:"set",value:R.value}]}):j=Vn(v.distribution.outcomes[R.outcomeIndex].actions,E,{...O,actionPath:[...O.actionPath??[Tn],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let Y=vl(O);return Dn(j)?zi(Y,j):Y},sy=(v,E)=>({...v??{},_form:E}),iy=(v,E,O,R)=>{let j=It(v,E),Y=j?.submitted===!0&&j.valid===!0,z=j?.cancelled===!0;if(!(!Y&&!z)&&Ye(E.actions))return Vn(E.actions,sy(O,j.form),{...R,interactionSource:ml})},Sl=(v,E,O,R)=>{if(v===Tn)return El(E,O,R);let j=Hi(O),Y={templatePayload:E,literalTargetIds:null};v===MA?Y=Qm(E):v===VA?Y=Zm(E):v===qA&&(Y=ey(E));let{templatePayload:z,literalTargetIds:ee}=Y,oe=LA.has(v)?v==="bgm"&&z?.audioEffects!==void 0?{...z,audioEffects:xt({audioEffects:z.audioEffects},j).audioEffects}:z:xt({[v]:z},j)[v],we=ee?{...oe,...ee}:oe;if(v===dl)return xl(we,O,R);let ge=Il(v,we,R);if(DA.has(v))return iy(v,ge,O,R);let Se=null,Ce=null,ze=null,Te=!1;if(v==="bgm"){let Ae=R.audioEffectHandoff,_r=Ae?.available?Ae.presentation:wt();Te=Bt(ge),Te&&Ae?.available?(Ae.available=!1,Se=structuredClone(Ae.channel),Ce=structuredClone(Ae.presentation),ze=structuredClone(Ae.resources)):Te&&(Se=Kr(),Ce=_r,ze=Wr())}if(It(v,ge),v==="bgm"){let Ae=Cr();Yt(ge,R,Se,Te?gt():null,Ce,Ae,ze)}},Vn=(v,E,O)=>{let R,j=O?.executionContext??{depth:0,pendingNavigation:null},Y=us(v);fs(Y),j.depth+=1;try{for(let[z,ee]of Y){let oe={...O,executionContext:j,actionPath:[...O?.actionPath??[],z]};if(ps(z)){let ge=j.pendingNavigation;if(ge)throw new Error(`action batch cannot execute multiple navigation actions: ${ge.actionType}, ${z}`);j.pendingNavigation={actionType:z,payload:ee,eventContext:E,options:oe};continue}let we=Sl(z,ee,E,oe);Dn(we)&&(R=zi(R,we))}}finally{j.depth-=1}if(j.depth===0&&j.pendingNavigation){let z=j.pendingNavigation;j.pendingNavigation=null,Sl(z.actionType,z.payload,z.eventContext,z.options)}return R},Ol=(v,E,O={})=>{let R={...O,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Xi(()=>Vn(v,E,R),R)},oy=v=>{let E=n.selectCurrentPointer()?.pointer;if(v!==E||n.selectActiveInteraction())return;let O=n.selectNextLineConfig();O?.auto?.enabled&&O.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:O.auto.delay}})};return{init:Yi,dispose:Mn,handleAction:Gi,handleInternalAction:Jm,handleActions:Ol,selectRenderState:vm,prepareRenderState:km,commitRenderState:Am,selectPresentationState:bm,selectPresentationChanges:wm,selectSectionLineChanges:Im,selectSystemState:Pm,selectAchievements:xm,selectAchievement:Em,selectSaveSlotMap:wl,selectSaveSlot:Sm,selectSaveSlotPage:Om,selectSaveSlots:wl,selectImageGallery:Rm,selectMusicRoom:$m,selectSceneReplay:Cm,selectIsSceneReplayActive:_m,selectRuntime:Nm,selectIsChoiceVisible:jm,selectIsFormVisible:Tm,selectActiveInteraction:Dm,selectHasPendingRenderWork:Lm,handleLineActions:v=>{ce("line action handling");let E=n.selectCurrentPointer()?.pointer;if(v?.pointer&&!ht(v.pointer,E))return!1;if(typeof v?.sceneReplaySceneId=="string"){let O=n.selectActiveSceneReplayEntry?.();if(O?.sceneId!==v.sceneReplaySceneId||O?.entryId!==v.entryId)return!1}return er(()=>{let O=n.selectCurrentPointer()?.pointer,R=n.selectPlaybackLineEntryId?.()??0,j=I?.lineEntryId===R?I:null,Y=j?{available:!0,channel:structuredClone(j.channel),presentation:structuredClone(j.presentation),resources:structuredClone(j.resources)}:null,z=n.selectRollbackCursor?.()??null,ee=p,oe=m,we=Vm(O,z),ge=qm(O),Se=n.selectCurrentLine(),Ce=!1;if(Se?.actions){try{Ol(Se.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:we,dialogueHistoryAppendToPrevious:ge?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ge?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ge?.forceNewOccurrence===!0,audioEffectHandoff:Y})}catch(ze){throw p=ee,m=oe,ze}Ce=!0}return I?.lineEntryId===R&&(I=null),oy(O),Ce})},getNamespace:gm,classifyAutomaticAttemptError:_}}var XA="music-room:player",ym=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),dm=(e,t)=>ym.has(e)&&t?._event?.id===XA,hm=({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:i,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(r)??e.selectRenderState(r);n?.(s),t.render(s),a(i)&&e.commitRenderState?.(s)},GA=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:i,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let o=i?.()??0,l=e.handleLineActions(s);(i?.()??0)===o&&hm({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},HA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},KA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},WA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},JA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},QA=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},mm={render:hm,saveSlots:HA,saveGlobalDeviceVariables:KA,saveGlobalAccountVariables:WA,saveGlobalRuntime:JA,applyScopedDataUpdates:QA,handleLineActions:GA},ZA=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),gl=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},eP=(e=[])=>{let t=new Set,n=[];for(let i=e.length-1;i>=0;i-=1){let a=e[i];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!ZA.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},rP=({getEngine:e,routeGraphics:t,ticker:n,handleUnhandledEffect:i,handlePersistenceError:a,indexedDB:r,persistence:s,namespace:o})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,m=!1,d=0,f=0,h=!0,g=pm({ticker:n,dispatchAutomaticAttempt:()=>gl(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:_=>e()?.classifyAutomaticAttemptError?.(_)??"preCommit"}),y=()=>{u=null,p=null,m=!1,d=0},b=()=>{g.reset(),f+=1,y(),h=!0},w=()=>{f+=1,h=!1,y(),g.dispose()},A=_=>h&&_===f,k=_=>{if(a){a(_);return}console.error("RouteEngine persistence write failed.",_)},P=_=>{if(s)return s;let D=Vt(_),F=l.get(D);if(F)return F;let W=rl({indexedDB:r,namespace:D});return l.set(D,W),W},I=_=>{let D=s?null:Vt(o??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=P(D),_(F))).catch(W=>{!s&&l.get(D)===F&&l.delete(D),k(W)})},x=_=>{if(!h)return;let D=typeof _?.id=="string"&&_.id.length>0?_.id:null;d+=1,u=D,m=!1},T=()=>d,C=(_={})=>{if(!h||_?.aborted===!0)return!1;let D=typeof _?.id=="string"&&_.id.length>0?_.id:null;return D?D!==u||D===p?!1:(p=D,!0):u!==null||m?!1:(m=!0,!0)},$=(_,D={})=>{if(!h)return!1;if(dm(_,D)){let W=ym.get(_),ye=e();return gl(ye,W,D?._event),!0}if(_!=="renderComplete"||!C(D))return!1;let F=e();return gl(F,"markLineCompleted",{}),!0},q=new Set(["updateFormField","submitForm","cancelForm"]),X=new Set(["updateVariable"]),N=_=>typeof _?.selectActiveInteraction=="function"?_.selectActiveInteraction():typeof _?.selectIsChoiceVisible=="function"&&_.selectIsChoiceVisible()?{source:"choice"}:null,K=_=>_?._formKey??_?.formKey,M=(_,D)=>K(_)===D?.formKey,Q=(_,D)=>!_||typeof _!="object"||Array.isArray(_)?!1:_._interactionSource===D?.source,le=(_,D)=>Q(_,D)?D.source==="form"?M(_,D):!0:!1,H=(_,D)=>!_||typeof _!="object"||Array.isArray(_)||D?.source!=="form"?!1:M(_,D),ne=(_={},D)=>Object.keys(_).length>0&&Object.entries(_).every(([F,W])=>q.has(F)?H(W,D):X.has(F)),ue=(_={},D)=>{let F=_?.actions;return D?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:ne(F,D):le(_,D)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(W=>le(W,D))},de=(_,D={})=>{if(!D?.actions)return!1;let F=N(_);return!F||F.source==="choice"?!1:!ue(D,F)},ce=({preprocessPayload:_,onEvent:D}={})=>async(F,W={})=>{if(!h)return!1;if(dm(F,W))return $(F,W),D?.(F,W);let ye=e(),ke=f,fe=d;if(de(ye,W))return D?.(F,W);let he=await _?.(F,W)??W;if(!A(ke)||e()!==ye||d!==fe)return!1;if(de(ye,he))return D?.(F,he);if($(F,he),he?.actions){let vr=he?._event?{_event:he._event}:he?.event?{_event:he.event}:void 0,er;he?.bypassChoice===!0?er={bypassChoice:!0}:he?._interactionSource&&(er={interactionSource:he._interactionSource}),er?ye.handleActions(he.actions,vr,er):ye.handleActions(he.actions,vr)}return D?.(F,he)},Z=_=>{if(!h)return;let D=f,F=e(),W=eP(_),ye=W.some(fe=>fe.name==="handleLineActions");W.forEach(fe=>{if(!mm[fe.name]&&!jn.has(fe.name)&&!i)throw new Error(`Unhandled pending effect "${fe.name}".`)});let ke={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:x,getRenderDispatchCount:T,enqueuePersistenceWrite:I,lifecycleGeneration:f,isCurrentLifecycle:A};for(let fe of W){if(!A(D))break;if(ye&&fe.name==="render")continue;if(jn.has(fe.name)){g.handleLegacyEffect(fe);continue}let he=mm[fe.name];if(he){he(ke,fe.payload);continue}i(fe,ke)}};return Z.handleRouteGraphicsEvent=$,Z.createRouteGraphicsEventHandler=ce,Z.reset=b,Z.dispose=w,Z.reconcilePlaybackScheduleV1=_=>g.reconcilePlaybackScheduleV1(_),Z},tP=rP;var nP=(e,t={})=>{let{resources:n={}}=t;return ia(e,n)};var mx=hl;export{qo as DEFAULT_VISUAL_LAYER,Ot as RENDER_LAYER,Ar as VISUAL_LAYER,tP as createEffectsHandler,$k as createIndexedDbPersistence,mx as default,Po as formatDate,Vh as resolveComputedVariables,nP as resolveLayoutReferences};
|
|
5
|
+
[${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let n=Tc(e,t),o={};for(let l of ms)Lr(r.tween,l)&&(o[l]=Dc({property:l,authored:r.tween[l],speed:n,propertyPath:`${a}.tween.${l}`}));return o},Mc=({bgm:e,resources:t={}})=>{let s=e?.audioEffects?.resourceId,i=L(t.audioEffects,s),a=i?.type==="update"?i.tween:i?.type==="transition"?i.next:void 0;if(!a||(e.sounds??[]).length===0)return e;let n=structuredClone(e);for(let o of ms){if(!Lr(a,o))continue;let l=a[o].keyframes.at(-1);typeof l?.value!="number"||!Number.isFinite(l.value)||l.relative===!0||(o==="volume"?n.volume=l.value:o==="pan"?n.pan=l.value:n.sounds.forEach(c=>{c.playbackRate=l.value}))}return n},dg=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),Ro=({phase:e,side:t,baselineBgm:s,authored:i,property:a,propertyPath:r,actionPath:n,speed:o})=>{let l=pg({authored:i,bgm:t.bgm,baselineBgm:s,property:a,propertyPath:r,renderedSound:t.sound,resources:t.resources,speed:o});return e!=="exit"&&fg({actionPath:n,compiled:l,property:a,propertyPath:r,renderedSound:t.sound}),l},mg=(e,t)=>t?!e||!_o(e,t)?"enter":"update":"exit",yg=({occurrence:e,resources:t={},previousResources:s=t,nextResources:i=t,previousChannel:a,nextChannel:r,previousBgm:n,nextBgm:o})=>{if(!e?.selection)return null;let l=e.selection,c=e.actionPath??"bgm",u=l.resourceId,p=`resources.audioEffects.${u}`,m=L(t.audioEffects,u);if(!m)throw new Error(`[${c}.audioEffects.resourceId]
|
|
6
|
+
[${p}] Unknown audio effect resource "${u}".`);let d=Tc(l,`${c}.audioEffects`),f=jc(a,c),h=jc(r,c);if(!f&&!h)return null;if(f&&h&&f.id!==h.id)throw new Error(`[${c}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let g=f?.id??h.id,y={sound:f,bgm:n,resources:s},b={sound:h,bgm:o,resources:i},w={};if(m.type==="transition"){if(_o(f,h))return null;for(let A of ms){let k={},P=f?m.prev?.[A]:void 0;P&&(k.exit=Ro({phase:"exit",side:y,baselineBgm:n,authored:P,property:A,propertyPath:`${p}.prev.${A}`,actionPath:c,speed:d}));let I=h?m.next?.[A]:void 0;I&&(k.enter=Ro({phase:"enter",side:b,baselineBgm:o,authored:I,property:A,propertyPath:`${p}.next.${A}`,actionPath:c,speed:d})),Object.keys(k).length>0&&(w[A]=k)}}else if(m.type==="update"){let A=mg(f,h),k=A==="enter"?n??o:n;for(let P of ms){if(!Lr(m.tween,P))continue;let I=Ro({phase:A,side:A==="exit"?y:b,baselineBgm:k,authored:m.tween[P],property:P,propertyPath:`${p}.tween.${P}`,actionPath:c,speed:d});A==="update"&&(f[P]??an[P])===(h[P]??an[P])||(w[P]={[A]:I})}}else throw new Error(`[${p}.type] Unsupported audio effect type "${m.type}".`);return Object.keys(w).length===0?null:{...dg(e,g),properties:w}},Vc=e=>{let t=e.nextResources??e.resources,s=e.occurrence;if(!s?.selection)return[];let i=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=s.selection.resourceId,n=t?.audioEffects?.[r],o=(f,h)=>h?{...f,children:[h]}:null,l=(f,h,g,y)=>{if(!Array.isArray(f?.sounds))return f;let b=g?.children?.indexOf(y)??-1,w=f.sounds.filter(A=>L(h.sounds,A.resourceId))[b];return{...f,sounds:w?[w]:[]}},c=f=>f.map(({previousSound:h,nextSound:g},y)=>yg({...e,occurrence:y===0?s:{...s,occurrenceId:`${s.occurrenceId}:${y}`},resources:t,previousBgm:l(e.previousBgm,e.previousResources??t,e.previousChannel,h),nextBgm:l(e.nextBgm,t,e.nextChannel,g),previousChannel:o(e.previousChannel,h),nextChannel:o(e.nextChannel,g)})).filter(Boolean);if(!n||!["transition","update"].includes(n.type))return c([{previousSound:i[0],nextSound:a[0]}]);let u=new Map(i.map(f=>[f.id,f]));if(n.type==="update")return a.length===0?c(i.map(f=>({previousSound:f}))):c(a.map(f=>({previousSound:u.get(f.id),nextSound:f})));let p=new Map(a.map(f=>[f.id,f])),m=[];for(let f of i){let h=p.get(f.id);(!h||!_o(f,h))&&m.push({previousSound:f,nextSound:h})}for(let f of a)u.has(f.id)||m.push({nextSound:f});if(m.length>0)return c(m);let[d]=i;return c([{previousSound:d,nextSound:p.get(d?.id)}])};var ce=e=>structuredClone(Ie(e)?Ge(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ln=e=>e?.animations?.playback?.continuity==="persistent",G=(e,t)=>ie(e??{},t)&&e[t]!==void 0,ys=e=>G(e,"alpha")||G(e,"opacity"),hg=e=>G(e,"alpha")?e.alpha:e?.opacity,Gc=e=>(G(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),gg=e=>e?.applyMode==="persistent",bg="default",wg=e=>Array.isArray(e?.channels)?e.channels.filter(gg).map(ce):[],cn=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ce(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Ig=e=>ys(e)||G(e,"blur")||G(e,"filters"),jo=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Hc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],No=["animationName","animationSpeed","loop"],vg=e=>G(e,"transformId")||G(e,"transform")||jo.some(t=>G(e,t)),To=e=>e?.text&&G(e.text,"content")&&G(e.text,"textStyleId"),Do=e=>e?.layout&&Array.isArray(e.layout.elements),kg=e=>G(e,"text")||G(e,"layout"),qc=(e,t)=>e.resourceId?!0:To(e)?!t?.text:Do(e)?!t?.layout:!1,Ag=e=>G(e,"resourceId")||To(e)||Do(e),Fc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Pg=e=>G(e,"resourceId")||G(e,"sprites")&&Array.isArray(e.sprites)&&e.sprites.length>0,xg=(e,t)=>{let s={...ce(e),...t};if(t.text&&e.text&&(s.text={...ce(e.text),...ce(t.text)}),t.transform&&e.transform&&(s.transform={...ce(e.transform),...ce(t.transform)}),G(t,"transform")){delete s.transformId;for(let i of jo)G(t,i)||delete s[i]}else G(t,"transformId")&&delete s.transform;return s},Eg=(e,t)=>{let s=[e.resourceId,e.text,e.layout].filter(i=>i!==void 0).length;if(s>1)throw s===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(G(e,"text")&&!To(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(G(e,"layout")&&!Do(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Bc=e=>Hc.some(t=>G(e,t)),Uc=e=>No.some(t=>G(e,t)),Sg=(e,t,{hasAuthoredTransformId:s=!1}={})=>{if(!t)return e;for(let i of Hc)!s&&!G(e,i)&&G(t,i)&&(e[i]=t[i]),ie(e,i)&&e[i]===void 0&&delete e[i];return e},Kc=(e,t,s)=>{let i=e[s];return i?.id===t?.id?i:e.find(a=>a.id===t?.id)},Og=(e,t)=>{if(!t)return e;let s=G(e,"transform");for(let i of jo)!s&&!G(e,i)&&G(t,i)&&(e[i]=t[i]),ie(e,i)&&e[i]===void 0&&delete e[i];return e},Rg=(e,t)=>(t&&(!G(e,"opacity")&&G(t,"opacity")&&(e.opacity=t.opacity),!G(e,"blur")&&G(t,"blur")&&(e.blur=ce(t.blur)),!G(e,"filters")&&G(t,"filters")&&(e.filters=ce(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Wc=(e,t,s=[],{hasPatchFn:i=()=>!1,hasSubjectFn:a=(n,o)=>t(n,o),mergeItemFn:r}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let n=e.map((o,l)=>{let c=Kc(s,o,l),u=a(o,c),p=Ig(o),m=vg(o),d=i(o),f=ie(o,"animations"),h=Gc(ce(o));if(!u&&(p||m||d)&&c&&(h=r?r(c,h):{...ce(c),...h}),!f){let g=c?t(c):!1,y=t(h);!u&&g&&y&&ln(c)?h.animations=ce(c.animations):delete h.animations}return u?h:Rg(Og(h,c),c)}).filter(o=>t(o)||o.animations);return{hasValidItems:n.length>0,processedItems:n}},$g=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},Jc=e=>!!e?.character&&ie(e.character,"sprite"),Cg=e=>{let t={},s=!1,i=$g(e);return i!==void 0&&(t.name=i,s=!0),Jc(e)&&(t.sprite=ce(e.character.sprite),s=!0),s?t:void 0},Yc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},zc=({dialogueState:e,dialogueAction:t,persistCharacter:s})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:s&&!ie(t,"characterId"),Xc=({previousCharacter:e,characterFields:t,hasCharacterId:s,persistCharacter:i,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:n})=>{let o={},l=e??{},c=t??{},u=n&&!s,p=u&&!r;return ie(c,"name")?o.name=c.name:(i&&!s||u)&&ie(l,"name")&&(o.name=ce(l.name)),ie(c,"sprite")?o.sprite=ce(c.sprite):(a||p)&&ie(l,"sprite")&&(o.sprite=ce(l.sprite)),Object.keys(o).length>0?o:void 0},_g=({dialogueState:e,content:t,append:s=!1})=>{if(!s||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let i=Array.isArray(e.content)?e.content:[];i.length>0?e.initialRevealedContent=i.map(a=>ce(a)):delete e.initialRevealedContent,e.content=[...i,...t]},Ng=()=>({}),jg=(e,t)=>{if(!t.screen)return;let s=ys(t.screen),i=G(t.screen,"blur"),a=ie(t.screen,"animations");if(!s&&!i){a||delete e.screen;return}let r=e.screen,n={};if(s?n.opacity=hg(t.screen):G(r,"opacity")&&(n.opacity=r.opacity),i?n.blur=ce(t.screen.blur):G(r,"blur")&&(n.blur=ce(r.blur)),ie(n,"opacity")&&n.opacity===void 0&&delete n.opacity,ie(n,"blur")&&n.blur===void 0&&delete n.blur,Object.keys(n).length===0){delete e.screen;return}e.screen=n},Tg=(e,t)=>{if(t.background){let s=G(t.background,"resourceId"),i=G(t.background,"colorId"),a=ys(t.background),r=G(t.background,"blur"),n=G(t.background,"filters"),o=G(t.background,"transformId"),l=Bc(t.background),c=Uc(t.background),{animationsOnly:u,state:p}=cn(t.background,f=>G(f,"resourceId")||G(f,"colorId")||ys(f)||G(f,"blur")||G(f,"filters")||G(f,"transformId")||Bc(f)||Uc(f));if(u){e.background=e.background?{...ce(e.background),...p}:p;return}if(!s&&!i&&!a&&!r&&!n&&!o&&!l&&!c){delete e.background;return}let m=e.background,d=Gc(ce(t.background));if(!s&&m?.resourceId){d.resourceId=m.resourceId,!ie(d,"transformId")&&m.transformId&&(d.transformId=m.transformId);for(let f of No)!G(d,f)&&G(m,f)&&(d[f]=m[f])}s||Sg(d,m,{hasAuthoredTransformId:o}),!s&&!i&&m?.colorId&&(d.colorId=m.colorId),!s&&!a&&G(m,"opacity")&&(d.opacity=m.opacity),!s&&!r&&G(m,"blur")&&(d.blur=ce(m.blur)),!s&&!n&&G(m,"filters")&&(d.filters=ce(m.filters)),ie(d,"resourceId")&&d.resourceId===void 0&&delete d.resourceId,ie(d,"colorId")&&d.colorId===void 0&&delete d.colorId,ie(d,"animations")&&d.animations===void 0&&delete d.animations,ie(d,"transformId")&&d.transformId===void 0&&delete d.transformId,ie(d,"opacity")&&d.opacity===void 0&&delete d.opacity,ie(d,"blur")&&d.blur===void 0&&delete d.blur,ie(d,"filters")&&d.filters===void 0&&delete d.filters;for(let f of No)ie(d,f)&&d[f]===void 0&&delete d[f];if(!d.resourceId&&!d.colorId){delete e.background;return}!s&&m?.resourceId===d.resourceId&&m?.transformId===d.transformId&&!ie(d,"animations")&&ln(m)&&(d.animations=ce(m.animations)),e.background=d}else e.background?.animations&&!ln(e.background)&&(e.background.animations={})},Dg=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(Yc(e.dialogue),e.dialogue.mode==="adv")){e.dialogue.content=void 0,delete e.dialogue.initialRevealedContent,delete e.dialogue.textSpeed;let u=e.dialogue.persistCharacter===!0,p=zc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=Xc({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let s=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=cn(t.dialogue.ui,m=>!!m.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...t.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});t.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),t.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let i=t.dialogue.append===!0&&s!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&_g({dialogueState:e.dialogue,content:t.dialogue.content,append:i}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=zc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let n=ie(t.dialogue,"characterId"),o=Cg(t.dialogue),l=Jc(t.dialogue);n?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!i&&delete e.dialogue.characterId;let c=Xc({previousCharacter:e.dialogue.character,characterFields:o,hasCharacterId:n,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:i});if(c?e.dialogue.character=c:delete e.dialogue.character,l||Yc(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ce(e.dialogue.character)),e.dialogue.lines.push(u)}},Lg=(e,t)=>{let s=wg(e.sfx);if(!t.sfx){if(s.length>0){e.sfx={channels:s};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=s.filter(n=>n.id!==bg);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ce(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(s.length>0){e.sfx={channels:s};return}delete e.sfx;return}if(t.sfx.channels.length===0){delete e.sfx;return}let i=new Set(t.sfx.channels.map(r=>r.id)),a=s.filter(r=>!i.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ce(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},Mg=(e,t,s)=>{if(t.bgm){let i=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!i||i&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=Mc({bgm:ce(t.bgm),resources:s}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},Vg=(e,t)=>{if(t.visual){let s=e.visual?.items||[];t.visual.items?.forEach((r,n)=>{Eg(r,Kc(s,r,n))});let{hasValidItems:i,processedItems:a}=Wc(t.visual.items,qc,s,{hasPatchFn:kg,hasSubjectFn:Ag,mergeItemFn:xg});i?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(s=>s.animations&&(!qc(s)||!ln(s))?{...s,animations:{}}:s))},qg=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!Fc(a)||!ln(a))?{...a,animations:{}}:a));return}let{hasValidItems:s,processedItems:i}=Wc(t.character.items,Fc,e.character?.items||[],{hasSubjectFn:Pg});s?e.character={items:i}:delete e.character},Fg=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},Bg=(e,t)=>{if(t.layout){let{animationsOnly:s,state:i}=cn(t.layout,a=>!!a.resourceId);if(s){e.layout=i;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},Ug=(e,t)=>{if(t.choice){let{animationsOnly:s,state:i}=cn(t.choice,a=>!!a.resourceId);if(s){e.choice={...e.choice,...i};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},Yg=(e,t)=>{if(t.form){let{animationsOnly:s,state:i}=cn(t.form,a=>!!a.resourceId);if(s){e.form={...e.form,...i};return}if(!t.form.resourceId){delete e.form;return}e.form=ce(t.form)}else e.form&&delete e.form},zg=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},Xg=(e,t)=>{if(t.voice){let s=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!s||s&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ce(t.voice)}else e.voice&&delete e.voice},Gg=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(s=>{delete e[s]})},it=(e,{resources:t,initialState:s}={})=>ts(()=>s??Ng(),[Gg,jg,Tg,Lg,(r,n)=>Mg(r,n,t),Vg,Dg,qg,Fg,Bg,Ug,Yg,zg,Xg])(e);var Qc=new WeakMap,Fe=(e,t)=>{let s=Ie(e)?Ge(e):e;if(!Array.isArray(s))return-1;if(!Object.isFrozen(s))return s.findIndex(a=>a.id===t);let i=Qc.get(s);return i||(i=new Map,s.forEach((a,r)=>{i.has(a.id)||i.set(a.id,r)}),Qc.set(s,i)),i.get(t)??-1};var Zc=Object.freeze({}),Hg=64,Kg=16,eu=4,Wg=8,ru=new WeakMap,hs=(e,t,s,i)=>{e.delete(t),e.set(t,s),e.size>i&&e.delete(e.keys().next().value)},Jg=(e,t)=>{if(!Array.isArray(t.lines)||!Object.isFrozen(e)||!Object.isFrozen(t)||!Object.isFrozen(t.lines)||e.resources&&!Object.isFrozen(e.resources))return null;let s=ru.get(e);s||(s=new Map,ru.set(e,s));let i=s.get(t);return i||(i={checkpoints:new Map,recent:new Map}),hs(s,t,i,Wg),i},tu=(e,t,s,i=0)=>{let a=t?.lines??[],r=t&&Array.isArray(a)?Jg(e,t):null,o=Fe(a,s)+i;if(o<0)return i<0?null:Zc;if(!r)return it(a.slice(0,o+1).map(u=>u.actions||{}),{resources:e.resources});let l=-1,c=Zc;for(let u of[r.checkpoints,r.recent])for(let[p,m]of u)p<=o&&p>l&&(l=p,c=m);for(let u of[o-1,o])u<=l||(c=it(a.slice(l+1,u+1).map(p=>p.actions||{}),{resources:e.resources,initialState:c}),(u+1)%Hg===0&&hs(r.checkpoints,u,c,Kg),hs(r.recent,u,c,eu),l=u);return hs(r.recent,o,c,eu),c};var St=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let s=rt(e,t);return s&&typeof s=="object"?e:typeof s=="number"||typeof s=="boolean"?String(s):s};var Qg=Object.freeze({dialogueTextSpeed:{source:"global.dialogueTextSpeed"},autoForwardDelay:{source:"global.autoForwardDelay"},autoForwardSpeed:{source:"global.autoForwardSpeed"},skipUnseenText:{source:"global.skipUnseenText"},skipTransitionsAndAnimations:{source:"global.skipTransitionsAndAnimations"},soundVolume:{source:"global.soundVolume"},musicVolume:{source:"global.musicVolume"},muteAll:{source:"global.muteAll"},localizationPackageId:{source:"global.localizationPackageId"},saveLoadPagination:{source:"context.runtime.saveLoadPagination"},menuPage:{source:"context.runtime.menuPage"},menuEntryPoint:{source:"context.runtime.menuEntryPoint"},autoMode:{source:"global.autoMode"},skipMode:{source:"global.skipMode"},dialogueUIHidden:{source:"global.dialogueUIHidden"},isLineCompleted:{source:"global.isLineCompleted"}}),Mr=Object.freeze({dialogueTextSpeed:50,autoForwardDelay:1e3,autoForwardSpeed:50,skipUnseenText:!1,skipTransitionsAndAnimations:!1,soundVolume:50,musicVolume:50,muteAll:!1,localizationPackageId:null,autoMode:!1,skipMode:!1,dialogueUIHidden:!1,isLineCompleted:!1}),un=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Zg=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),Lo=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),nu=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),Mo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),su=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),eb=(e,t)=>{let s=Zg[e];if(s==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(s==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(s==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(s==="nullableString"){if(t!==null&&typeof t!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},gs=(e,t)=>{if(eb(e,t),e==="autoForwardDelay"&&t<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(t<0||t>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},Vo=(e={})=>{let t=e?.config;if(t===void 0)return{...Mr};if(!su(t))throw new Error("projectData.config must be an object");let s=Object.keys(t).find(o=>o!=="runtimeDefaults");if(s)throw new Error(`projectData.config contains unsupported field "${s}"`);let i=t.runtimeDefaults;if(i===void 0)return{...Mr};if(!su(i))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(nu),r=Object.keys(i).find(o=>!a.has(o));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let n={...Mr};return nu.forEach(o=>{i[o]!==void 0&&(n[o]=gs(o,i[o]))}),n},rb=(e,t)=>{if(t.startsWith("global.")){let s=t.slice(7);return e?.global?.[s]}if(t.startsWith("context.runtime.")){let s=t.slice(16),i=Array.isArray(e?.contexts)?e.contexts:[];return i[i.length-1]?.runtime?.[s]}},kr=e=>Object.fromEntries(Object.entries(Qg).map(([t,s])=>{let i=rb(e,s.source),a=i!==void 0?i:Mr[t]??un[t];return[t,a]})),ar=(e,t)=>kr(e)[t],iu=(e={})=>Object.fromEntries(Lo.map(t=>[t,e[t]??Mr[t]]));var Ot=Object.freeze({VISUAL_BEHIND_BACKGROUND:10,BACKGROUND:20,VISUAL_BEHIND_CHARACTER:30,CHARACTER:40,VISUAL_BEHIND_DIALOGUE:50,DIALOGUE:60,VISUAL_BEHIND_CHOICE:70,CHOICE:80,VISUAL_FOREGROUND:90}),Ar=Object.freeze({BEHIND_BACKGROUND:Ot.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:Ot.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:Ot.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:Ot.VISUAL_BEHIND_CHOICE,FOREGROUND:Ot.VISUAL_FOREGROUND}),qo=Ar.BEHIND_DIALOGUE,Fo=Object.freeze(Object.values(Ar).sort((e,t)=>e-t));var tb={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,s])=>({id:t,...s})),formatDate:Po},nb=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,ou=e=>{let t=nb.exec(e);if(!t)return null;let[,s,i,a]=t;return`${s}${i?`, ${i}`:""} in __arrayOrEmpty(${a.trim()})`},pn=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return pn(t);let[s]=Object.keys(t),i=ou(s);if(!i)return pn(t);let a=`$for ${i}`,r=Array.isArray(t[s])?t[s]:[];return{[a]:pn(r)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,s])=>[t,t==="$each"&&typeof s=="string"?ou(`$for ${s}`)??s:pn(s)])),cr=(e,t)=>{let s={functions:tb};return rt(pn(e),t,s)},vu=({animationType:e,animationId:t,animationPath:s})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${s}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},sb=({id:e,targetId:t,animation:s,playback:i,animationPath:a="animation"})=>{let r=structuredClone(s);if(vu({animationType:r.type,animationId:e,animationPath:a}),r.type==="transition"&&r.prev===void 0&&r.next===void 0&&r.mask===void 0)throw new Error(`[${a}] Animation "${e}" of type "transition" must define prev, next, or mask.`);if(delete r.name,delete r.playback,r.id=e,r.targetId=t,i!==void 0){let n=lb(i,`${a}.playback`);if(n!==void 0){let o=n.loop===!0?Su(r):null;if(n.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(n.loop===!0&&r.complete!==void 0)throw new Error(`[${a}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(n.loop===!0&&fb(r,a),n.loop===!0&&o===0)return null;if(n.loop===!0&&(!Number.isFinite(o)||o<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);r.playback=n}}return r},ib=(e,{animationId:t="animation",animationPath:s="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return vu({animationType:e.type,animationId:t,animationPath:s}),e.type},ob=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},ab=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},lb=(e,t="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${t}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${t}] playback.continuity must be "render" or "persistent".`);if(e.speed!==void 0&&(typeof e.speed!="number"||!Number.isFinite(e.speed)||e.speed<=0))throw new Error(`[${t}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${t}] playback.loop must be a boolean.`);let s={};return e.continuity!==void 0&&(s.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(s.speed=e.speed),e.loop===!0&&(s.loop=!0),Object.keys(s).length>0?s:void 0},cb=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},tr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ku=(e={})=>tr(e,"alpha")&&typeof e.alpha=="number"?e.alpha:tr(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,Au=e=>e?.playback?.continuity==="persistent",Ko=e=>Array.isArray(e)?e.map(Ko):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,s)=>(t[s]=Ko(e[s]),t),{}),ks=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=structuredClone(e);return t.playback&&(delete t.playback.continuity,t.playback.speed===1&&delete t.playback.speed,Object.keys(t.playback).length===0&&delete t.playback),JSON.stringify(Ko(t))},Pu=(e=[])=>e.filter(t=>Au(t)).map(t=>structuredClone(t)),bs=e=>typeof e=="number"&&Number.isFinite(e)?e:0,xu=e=>{if(!e||typeof e!="object"||Array.isArray(e))return 0;if(e.auto!==void 0){let t=e.auto;return bs(t?.delay)+bs(t?.duration)}return Array.isArray(e.keyframes)?e.keyframes.reduce((t,s)=>t+bs(s?.delay)+bs(s?.duration),0):0},Bo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,s)=>Math.max(t,xu(s)),0),Eu=e=>Array.isArray(e)?e.reduce((t,s)=>Math.max(t,Eu(s)),0):!e||typeof e!="object"?0:xu(e.progress),Su=e=>Math.max(Bo(e?.tween),Bo(e?.prev?.tween),Bo(e?.next?.tween),Eu(e?.mask)),ub=e=>{let t=[],s=[["tween",e?.tween],["prev.tween",e?.prev?.tween],["next.tween",e?.next?.tween]];for(let[a,r]of s)if(!(!r||typeof r!="object"||Array.isArray(r)))for(let[n,o]of Object.entries(r))Array.isArray(o?.keyframes)&&t.push([`${a}.${n}.keyframes`,o.keyframes]);let i=e?.mask?.progress?.keyframes;return Array.isArray(i)&&t.push(["mask.progress.keyframes",i]),t},pb=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0,fb=(e,t)=>{for(let[s,i]of ub(e))i.forEach((a,r)=>{let n=a?.duration;if(!pb(n))throw new Error(`[${t}.playback] playback.loop requires every keyframe duration to be a finite number of at least 0, but ${s}[${r}].duration is ${String(n)}.`)})},Ou=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Su(e)/cb(e),db=e=>e.some(t=>t?.playback?.loop===!0),au=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let s=new Set(t.map(ks).filter(Boolean));return e.some(i=>{if(!Au(i))return!1;let a=ks(i);return a?s.has(a):!1})},nr=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||s?!1:db(e)||r&&!t||au({animationInstances:e,activePersistentAnimations:i})?!0:r?!1:au({animationInstances:e,activePersistentAnimations:a}),Ru=(e,t,s,i,a)=>{if(e===void 0)return!0;let r=a.slice(0,i).filter(o=>o?.id===s).length,n=e?.[t]?.items?.filter(o=>o?.id===s).at(r);return tr(n??{},"animations")},mb=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),yb=(e,t)=>{if(mb(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},hb=({resources:e,animationId:t,playback:s,instanceId:i,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let n=L(e?.animations,t);return n?sb({id:i,targetId:a,animation:n,playback:s,animationPath:r}):null},Wo=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(s=>s===null||typeof s!="object"||Array.isArray(s)))throw new Error(`${t} must be an array of objects`);return e},gb=({content:e,path:t,variables:s,runtime:i})=>Wo(e,t).reduce((a,r)=>{let n=St(r.text,{variables:s,runtime:i});return a+`${n??""}`.length},0),lu=(e=[])=>{let t=new Map;for(let s of e)s?.id&&t.set(s.id,(t.get(s.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,s])=>s>1).map(([s])=>s))},cu=(e,t=0,s=new Set)=>{if(!s.has(e?.id))return`character-container-${e.id}`;let i=e?.sprites?.map(({resourceId:a})=>a)||[];return i.length===0?`character-container-${e.id}`:`character-container-${e.id}-${t}-${i.join("-")}`},$t=(e,t)=>{if(t.transformId&&t.transform)throw new Error(`Visual item "${t.id}" cannot define both transformId and transform`);if(t.transform)return t.transform;if(!t.transformId)throw new Error(`Visual item "${t.id}" requires transformId or transform`);let s=L(e.transforms,t.transformId);if(!s)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return s},bb=(e,t={})=>{if(!t?.transformId)return;let s=L(e.transforms,t.transformId);if(!s)throw new Error(`Transform "${t.transformId}" not found for background`);return s},wb=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Ib=(e={})=>wb.some(t=>tr(e,t)),$u=(e={},t)=>{if(t){if(L(e.images,t))return"sprite";if(L(e.videos,t))return"video";if(L(e.spritesheets,t))return"spritesheet-animation";if(L(e.layouts,t))return"container"}},Is=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},vb=(e={})=>e.textStyles||{},kb=(e={})=>e.images||{},Ab=.5,Pb=(e={},t,s)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${s}'`);return t}return Object.keys(e.animations??{})[0]},sa=({id:e,resourceId:t,spritesheet:s,animationName:i,animationSpeed:a,loop:r,width:n,height:o,transform:l={}}={})=>{let c=Pb(s,i,t),u=c?s.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:n??s.width,height:o??s.height,src:s.fileId,atlas:s.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??Ab,loop:r??u.loop??!0}}},Cu=({id:e,item:t,resources:s={}}={})=>{let i=L(s.images,t.resourceId);if(i)return{type:"sprite",id:e,src:i.fileId,width:i.width,height:i.height,x:0,y:0};let a=L(s.spritesheets,t.resourceId);if(a)return sa({id:e,resourceId:t.resourceId,spritesheet:a,animationName:t.animationName,animationSpeed:t.animationSpeed,loop:t.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${t.resourceId}`)},xb=(e={})=>e.colors||{},Eb=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,lt=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,at=(e,t,s)=>{if(typeof e!="string"||e.length===0)throw new Error(`${s} at "${t}" must resolve to a non-empty string`)},Uo=(e,t,s)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${s}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${s}" must be a number between 0 and 1`);return e},Yo=(e,t,s,i,{minimum:a}={})=>{if(e===void 0)return i;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let r=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${t} for text style "${s}" must be ${r}`)}return e},mn=(e,t)=>{if(typeof e!="string"||!Eb.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(s=>s.repeat(2)).join("")}`:e},uu=(e,t,s)=>{let i=mn(e,s);if(t===1)return i;let a=Number.parseInt(i.slice(1,3),16),r=Number.parseInt(i.slice(3,5),16),n=Number.parseInt(i.slice(5,7),16);return`rgba(${a}, ${r}, ${n}, ${t})`},_u=(e={},t)=>{let s=L(vb(e),t);if(!s)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(s.fontId)?s.fontId:[s.fontId]).map(l=>{let c=L(e.fonts,l);if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=L(e.colors,s.colorId);if(!r)throw new Error(`Color "${s.colorId}" not found for text style "${t}"`);let n=Uo(s.colorAlpha,"colorAlpha",t),o={fontFamily:Array.isArray(s.fontId)?a.join(", "):a[0],fontSize:s.fontSize??16,fontWeight:s.fontWeight??"400",fontStyle:s.fontStyle??"normal",lineHeight:s.lineHeight??1.2,fill:uu(r.hex,n,`Color "${s.colorId}" for text style "${t}"`)};if(s.align!==void 0&&(o.align=s.align),s.wordWrap!==void 0&&(o.wordWrap=s.wordWrap),s.breakWords!==void 0&&(o.breakWords=s.breakWords),s.wordWrapWidth!==void 0&&(o.wordWrapWidth=s.wordWrapWidth),s.strokeColorId){let l=L(e.colors,s.strokeColorId);if(!l)throw new Error(`Stroke color "${s.strokeColorId}" not found for text style "${t}"`);let c=Uo(s.strokeAlpha,"strokeAlpha",t);o.strokeColor=uu(l.hex,c,`Stroke color "${s.strokeColorId}" for text style "${t}"`)}else if(s.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(s.strokeWidth!==void 0&&(o.strokeWidth=s.strokeWidth),s.shadow!==void 0){let l=L(e.colors,s.shadow.colorId);if(!l)throw new Error(`Shadow color "${s.shadow.colorId}" not found for text style "${t}"`);o.shadow={color:mn(l.hex,`Shadow color "${s.shadow.colorId}" for text style "${t}"`),alpha:Uo(s.shadow.alpha,"shadow.alpha",t),blur:Yo(s.shadow.blur,"blur",t,0,{minimum:0}),offsetX:Yo(s.shadow.offsetX,"offsetX",t,2),offsetY:Yo(s.shadow.offsetY,"offsetY",t,2)}}return o},Ct=e=>Array.isArray(e)?e.map(Ct):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,s])=>[t,Ct(s)])),_t=(e,t,s)=>{Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0})},Sb=new Set(["text","text-revealing"]),Ob=["fontWeight","fontStyle","textDecoration","fill"],Rb=new Set(["normal","bold","bolder","lighter"]),$b=new Set(["normal","italic","oblique"]),Cb=new Set(["none","underline"]),_b=/^\d+(?:\.\d+)?$/,Nb=e=>{if(typeof e=="string"&&Rb.has(e))return!0;let t=typeof e=="string"&&_b.test(e)?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>=1&&t<=1e3},jb=(e,t)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Inline textStyle at "${t}" must be an object`);let s={};for(let[i,a]of Object.entries(e)){if(!Ob.includes(i))throw new Error(`Inline textStyle.${i} is not allowed in text content runs at "${t}". Only fontWeight, fontStyle, textDecoration, and fill may be authored inline; use textStyleId for other style changes`);if(i==="fontWeight"&&!Nb(a))throw new Error(`Inline textStyle.fontWeight at "${t}" must be normal, bold, bolder, lighter, or a number from 1 to 1000`);if(i==="fontStyle"&&!$b.has(a))throw new Error(`Inline textStyle.fontStyle at "${t}" must be normal, italic, or oblique`);if(i==="textDecoration"&&!Cb.has(a))throw new Error(`Inline textStyle.textDecoration at "${t}" must be none or underline`);s[i]=i==="fill"?mn(a,`Inline textStyle.fill at "${t}"`):a}return s},Tb=(e,t,s)=>{let i={};for(let[r,n]of Object.entries(e))r==="textStyle"||r==="textStyleId"||_t(i,r,fn(n,t,lt(s,r)));let a;return e.textStyleId!==void 0&&(at(e.textStyleId,s,"textStyleId"),a=_u(t,e.textStyleId)),e.textStyle!==void 0&&(a={...a,...jb(e.textStyle,s)}),a!==void 0&&(i.textStyle=a),i},fn=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>fn(a,t,`${s}[${r}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${s}". Use textStyleId instead`);let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=Ct(r);continue}if(a!=="textStyleId"){if(a==="content"&&Array.isArray(r)&&Sb.has(e.type)){let n=lt(s,a);_t(i,a,r.map((o,l)=>o&&typeof o=="object"&&!Array.isArray(o)?Tb(o,t,`${n}[${l}]`):fn(o,t,`${n}[${l}]`)));continue}_t(i,a,fn(r,t,lt(s,a)))}}return e.textStyleId!==void 0&&(at(e.textStyleId,s,"textStyleId"),i.textStyle=_u(t,e.textStyleId)),i},ia=(e={},t)=>{let s=L(xb(e),t);if(!s)throw new Error(`Color "${t}" not found`);return mn(s.hex,`Color "${t}"`)},Nu=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",zo=(e,t,s)=>{let i=e?.[t];if(!(!i||typeof i!="object"||Array.isArray(i))&&Object.prototype.hasOwnProperty.call(i,"fill"))throw new Error(`Inline ${t}.fill is not allowed in rect layout elements at "${s}". Use ${Nu(`${t}.fill`)} instead`)},Db=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>dn(a,t,`${s}[${r}]`));if(!e||typeof e!="object")return e;let i={};for(let[a,r]of Object.entries(e))a!=="colorId"&&_t(i,a,dn(r,t,lt(s,a)));return e.colorId!==void 0&&(at(e.colorId,s,"colorId"),i.fill=ia(t,e.colorId)),i},dn=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>dn(a,t,`${s}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="rect"){if(Object.prototype.hasOwnProperty.call(e,"fill"))throw new Error(`Inline fill is not allowed in rect layout elements at "${s}". Use ${Nu("fill")} instead`);zo(e,"hover",s),zo(e,"click",s),zo(e,"rightClick",s)}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=Ct(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){i[a]=Db(r,t,lt(s,a));continue}_t(i,a,dn(r,t,lt(s,a)))}}return e.type==="rect"&&e.colorId!==void 0&&(at(e.colorId,s,"colorId"),i.fill=ia(t,e.colorId)),i},Xo=(e={},t)=>{let s=L(kb(e),t);return s||null},ju=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",pu=(e,t,s,i)=>{let a=e?.[t];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,i))throw new Error(`Inline ${t}.${i} is not allowed in sprite layout elements at "${s}". Use ${ju(`${t}.${i}`)} instead`)},fu=(e,t,s)=>{let i=e[t];e[t]={...i&&typeof i=="object"&&!Array.isArray(i)?i:{},src:s}},Jo=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>Jo(a,t,`${s}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${s}". Use ${ju(a)} instead`);pu(e,"hover",s,"src"),pu(e,"click",s,"src")}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=Ct(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||_t(i,a,Jo(r,t,lt(s,a)))}if(e.type==="sprite"&&e.imageId!==void 0){at(e.imageId,s,"imageId");let a=Xo(t,e.imageId),r=a?.fileId??e.imageId;i.src=r,i.width===void 0&&a?.width!==void 0&&(i.width=a.width),i.height===void 0&&a?.height!==void 0&&(i.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(at(e.hoverImageId,s,"hoverImageId"),fu(i,"hover",Xo(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(at(e.clickImageId,s,"clickImageId"),fu(i,"click",Xo(t,e.clickImageId)?.fileId??e.clickImageId)),i},Lb=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),vs=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>vs(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let s=Ct(e),i=typeof e.type=="string";(i||t)&&tr(e,"opacity")&&(tr(e,"alpha")||(s.alpha=e.opacity),delete s.opacity);for(let a of["elements","children"])tr(e,a)&&(s[a]=vs(e[a]));for(let[a,r]of Object.entries(e))Lb(a)&&(s[a]=vs(r,{isElementPatch:i||t}));return s},oa=(e,t={},s="root")=>vs(Jo(dn(fn(e,t,s),t,s),t,s)),Pr=oa,ct=(e=[])=>e.find(t=>t.id==="story"),Tu=(e,t=new Set)=>{if(!Array.isArray(e))return t;for(let s of e)typeof s?.id=="string"&&t.add(s.id),Tu(s?.children,t);return t},Du=e=>encodeURIComponent(e).replaceAll("--","%2D%2D"),Mb=(e,t)=>{let s=Du(typeof t=="string"&&t.length>0?t:"layout"),i=s,a=2;for(;e.claimedNamespaces.has(i);)i=`${s}-${a++}`;return e.claimedNamespaces.add(i),i},Vr=({state:e,elements:t,layoutInstanceState:s,rootId:i})=>{if(!s||!Array.isArray(t))return t;let a=Mb(s,i),r=Tu(e.elements);typeof i=="string"&&r.add(i);let n=o=>Array.isArray(o)?o.map(l=>{if(!l||typeof l!="object"||Array.isArray(l))return l;let c={...l};if(typeof l.id=="string"){let u=`@layout/${a}--${Du(l.id)}`,p=u,m=1;for(;s.usedIds.has(p)||r.has(p);)p=`${u}-${m++}`;c.id=p,s.usedIds.add(p)}return Array.isArray(l.children)&&(c.children=n(l.children)),c}):o;return n(t)},Vb="#000000",Qo="bg-cg-background-color",qb=({resources:e={},background:t={},screen:s})=>t?.colorId===void 0?mn(s?.backgroundColor??Vb,"screen.backgroundColor"):ia(e,t.colorId),Lu=(e={})=>ku(e),Fb=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},aa=(e={})=>Array.isArray(e.filters)?e.filters:void 0,du=(e={},{includeDefaultAlpha:t=!1}={})=>{let s=Lu(e),i=Fb(e),a=aa(e),r={};return(t||s!==void 0)&&(r.alpha=s??1),i&&(r.blur=i),a&&(r.filters=a),r},Bb=(e={})=>ku(e),Ub=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Mu=(e={})=>{let t=Bb(e),s=Ub(e),i={};return t!==void 0&&(i.alpha=t),s&&(i.blur=s),i},ot=(e={})=>{let t=Mu(e),s=aa(e);return s&&(t.filters=s),t},mu=(e,t,s,i)=>{let a=t[s]??e[s];return t[i]??e[i]??!1?(a??1)*-1:a},lr=(e={},t={})=>{let s={x:t.x??e.x,y:t.y??e.y,anchorX:t.anchorX??e.anchorX,anchorY:t.anchorY??e.anchorY,rotation:t.rotation??e.rotation,scaleX:mu(e,t,"scaleX","flipX"),scaleY:mu(e,t,"scaleY","flipY")},i=t.originX??e.originX,a=t.originY??e.originY;return i!==void 0&&(s.originX=i),a!==void 0&&(s.originY=a),s},Yb=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],la=(e={})=>e.text&&tr(e.text,"content")&&tr(e.text,"textStyleId"),ca=(e={})=>e.layout&&Array.isArray(e.layout.elements),yu=(e={})=>{if(e.resourceId)return e.resourceId;if(la(e))return"text";if(ca(e))return"inline-layout"},hu=(e,t={})=>typeof e=="string"?L(t.images,e)?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?L(t.images,e.imageId)?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(s=>{if(typeof s=="string")return L(t.images,s)?.fileId??s;if(!s||typeof s!="object"||Array.isArray(s))return s;if(s.imageId){let{imageId:i,...a}=s;return{...a,src:L(t.images,i)?.fileId??i}}return typeof s.src=="string"?{...s,src:L(t.images,s.src)?.fileId??s.src}:s})}:e,zb=({item:e,particle:t,resources:s})=>{let i=$t(s,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=hu(r,s)),a.texture!==void 0&&(a.texture=hu(a.texture,s));let n={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...lr(i,e)};return Object.assign(n,ot(e)),n},Xb=e=>{let t=[e.resourceId,e.text,e.layout].filter(s=>s!==void 0).length;if(t>1)throw t===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(e.text&&!la(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!ca(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let s of Yb)if(tr(e.text,s))throw new Error(`Visual item "${e.id}" text.${s} is reserved for the visual item`)}},Gb=({resources:e,background:t,screen:s={width:1920,height:1080},includeAlpha:i=!1})=>{let a={id:Qo,type:"rect",x:0,y:0,width:s?.width??1920,height:s?.height??1080,fill:qb({resources:e,background:t,screen:s})};if(i){let r=Lu(t);r!==void 0&&(a.alpha=r);let n=aa(t);n&&(a.filters=n)}return a},Hb=(e={},t)=>t?!!(L(e.images,t)||L(e.videos,t)||L(e.spritesheets,t)||L(e.layouts,t)):!1,gu=({resources:e={},resourceId:t,colorId:s})=>{let i=$u(e,t);return t&&(i||s===void 0)?{resourceId:t,targetId:Is({resourceId:t,kind:i})}:s!==void 0?{resourceId:Qo,targetId:Qo}:{resourceId:void 0,targetId:void 0}},Vu=100,xr=Vu,Kb="channel:bgm",Wb="channel:music-room",Jb="music-room:player",Qb="channel:voice",Zb="default",As=(e,t,s)=>{let i=new Set;e.forEach(({id:a})=>{if(i.has(a)){let r=s?` in ${s}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}i.add(a)})},qu=(e,t)=>e*t/Vu,ua=(e={},t)=>e?.[t]??Mr[t],xs=(e={},t,s=xr)=>qu(s,ua(e,t)),Fu=(e,t,s)=>t?.muteAll===!0?0:xs(t,s,e??xr),Es=({id:e,volume:t,muted:s,pan:i,loop:a,playback:r,interruption:n,children:o,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(s??!1),pan:i??0,children:o};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),n!==void 0&&(c.interruption=n),c},ws=(e,t,s,i)=>e[s]!==void 0?e[s]:t[s]!==void 0?t[s]:i,e0=["muted","pan","playbackRate","startAt","endAt"],Ss=({id:e,sound:t,resource:s,projectResources:i,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:n=!1})=>{let o={id:e,type:"sound",src:s.fileId,loop:ws(t,s,"loop",r),volume:ws(t,s,"volume",xr),startDelayMs:ws(t,s,"startDelayMs",0)};e0.forEach(c=>{let u=ws(t,s,c,void 0);u!==void 0&&(o[c]=u)}),t.playback!==void 0&&(o.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=Lc({selection:t[c],selectionPath:`${a}.${c}`,resources:i});u&&!n&&(o[c]=u)}let l=o.startAt??0;if(o.endAt!==void 0&&o.endAt!==null&&o.endAt<l)throw new Error(`Sound "${e}" endAt (${o.endAt}) must be greater than or equal to startAt (${l}).`);return o},r0=e=>Math.max(-1,Math.min(1,e)),t0=({node:e,bgm:t,sound:s,resource:i,usesLegacySound:a})=>{a||(e.volume=qu(t.volume??xr,e.volume??xr));let r=t.muted!==void 0,n=s.muted!==void 0||i.muted!==void 0;(r||n)&&(e.muted=t.muted===!0||e.muted===!0);let o=t.pan!==void 0,l=s.pan!==void 0||i.pan!==void 0;return(o||l)&&(e.pan=r0((t.pan??0)+(e.pan??0))),e},We=({variables:e,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:a,saveSlots:r=[],dialogueState:n,includeInactiveAdvDialogue:o=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g=[],characters:y={},dialogueUIHidden:b,skipOnlyViewedLines:w,skipTransitionsAndAnimations:A}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??b??!1,isLineCompleted:a?.isLineCompleted??l??!1},P=a0({dialogueState:n,includeInactiveAdvDialogue:o,characters:y,variables:e,runtime:k}),I={variables:e,imageGallery:t,musicRoom:s,sceneReplay:i,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g,characters:y};return P&&(I.dialogue=P,I.dialogueLines=P.lines),I},bu=100,Ps=(e,t)=>{if(Array.isArray(e))return e.map(i=>Ps(i,t));if(!e||typeof e!="object")return e;let s={...e};return Object.keys(s).forEach(i=>{s[i]=Ps(s[i],t)}),s.type==="text-revealing"?t(s):s},n0=e=>Ps(e,t=>({...t,revealEffect:"none"})),s0=e=>Ps(e,t=>{let s=Number(t.speed??t.displaySpeed),i=Number.isFinite(s)?Math.max(s,bu):bu;return{...t,speed:i,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:i}:{}}}),qr=(e,{isLineCompleted:t=!1,skipMode:s=!1,skipTransitionsAndAnimations:i=!1}={})=>t||i?n0(e):s?s0(e):e,Bu=({id:e,screen:t={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:t.width,height:t.height,x:0,y:0,click:{payload:{actions:{}}}}),Zo=e=>{if(Array.isArray(e))return e.map(Zo);if(!e||typeof e!="object")return e;let t={};for(let[r,n]of Object.entries(e))t[r]=Zo(n);let s=t.click?.payload;if(!s||typeof s!="object"||Array.isArray(s))return t;let i=s.actions,a=i&&typeof i=="object"&&!Array.isArray(i)&&Object.prototype.hasOwnProperty.call(i,"nextLine")?{...i.nextLine,bypassChoice:!0}:void 0;return{...t,click:{...t.click,payload:{...s,bypassChoice:!0,...a?{actions:{...i,nextLine:a}}:{}}}}},i0=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),wu="submit",Go=(e,t,s={})=>{let i=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=i.actions&&typeof i.actions=="object"?i.actions:{},r=s.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...i,actions:r}}},ea=(e,t,s={})=>{if(Array.isArray(e))return e.map(c=>ea(c,t,s));if(!e||typeof e!="object")return e;let i=typeof e.type=="string",a=i&&e.formRole===wu,r=i&&s.submitRoleAncestor,n=a||r?{submitRoleAncestor:!0}:{},o={};for(let[c,u]of Object.entries(e))o[c]=ea(u,t,c==="children"?n:{});let l=o;if(l.type==="input"&&typeof l.field=="string"){let c=t?.fields?.[l.field];if(c){let u={updateFormField:{formKey:t.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:Go(l.change,u),submit:Go(l.submit,t.submitActions)}}}return l.formRole===wu||r?{...l,click:Go(l.click,t.submitActions,{replaceActions:!0})}:l},ra=(e,t)=>{if(Array.isArray(e))return e.map(i=>ra(i,t));if(!e||typeof e!="object")return e;let s={};for(let[i,a]of Object.entries(e))s[i]=ra(a,t);for(let i of i0){let a=s[i]?.payload;!a||typeof a!="object"||Array.isArray(a)||(s[i]={...s[i],payload:{...a,_interactionSource:"form"}})}return s},ta=({characterId:e,character:t,characterName:s,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0,n=ns({characterId:e,character:t,characterName:s,characters:i,variables:a});return{...r||{},...t||{},name:n}},Uu=(e=[],t={},s={})=>e.map(i=>{let a=ta({characterId:i.characterId,character:i.character,characterName:i.characterName,characters:t,variables:s}),r=typeof i.text=="string"?i.text:Array.isArray(i.content)?i.content.map(n=>n?.text??"").join(""):"";return{...i,text:r,character:a,characterName:a.name}}),o0=e=>!(!e||e.mode==="adv"&&e.content===void 0),a0=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:s={},variables:i,runtime:a}={})=>{if(!t&&!o0(e))return;let r=e.content===void 0?[{text:""}]:Wo(e.content,"dialogue.content"),n=e.content===void 0?0:gb({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:i,runtime:a}),o=a?.dialogueTextSpeed??Mr.dialogueTextSpeed,l=e.textSpeed??o,c=(e.lines||[]).map((p,m)=>{let d=Wo(p.content,`dialogue.lines[${m}].content`),f=ta({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:s,variables:i});return{...p,textSpeed:p.textSpeed??o,content:d.map(h=>({...h,text:St(h.text,{variables:i,runtime:a})})),character:f,characterName:f.name}}),u=ta({characterId:e.characterId,character:e.character,characters:s,variables:i});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:St(p.text,{variables:i,runtime:a})})),initialRevealedCharacters:n,lines:c}},pa=({state:e,container:t,resources:s,templateData:i,layoutInstanceState:a,isLineCompleted:r=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1})=>{let l=cr(t,i);return l.children=Vr({state:e,elements:l.children,layoutInstanceState:a,rootId:t.id}),Pr(qr(l,{isLineCompleted:r,skipMode:n,skipTransitionsAndAnimations:o}),s)},Ho=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),Iu=({renderStateKeyboard:e,keyboard:t,phase:s})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([i,a])=>{let r=e[i]??{},n=s==="keydown"?a?.keydown:a?.keyup;if(s==="keydown"&&n&&typeof n=="object"){e[i]={...r,keydown:{payload:Ho(n)}},a?.keyup&&typeof a.keyup=="object"&&(e[i].keyup={payload:Ho(a.keyup)});return}e[i]={...r,[s]:{payload:Ho(a)}}})},l0=(e={},t={})=>{let s={};return Iu({renderStateKeyboard:s,keyboard:e,phase:"keydown"}),Iu({renderStateKeyboard:s,keyboard:t,phase:"keyup"}),Object.keys(s).length>0?s:void 0},Er=({animationsDef:e,resources:t,previousResourceId:s,currentResourceId:i,previousTargetId:a,currentTargetId:r,animationPath:n,idPrefix:o})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:b})=>{let w=hb({resources:t,animationId:d,playback:f,instanceId:y,targetId:b,animationPath:n});w&&l.push(w)},u=s!=null&&s!==!1,p=i!=null&&i!==!1,m=a&&r&&a===r;yb(e,n);let d=ob(e),f=ab(e),h=L(t?.animations,d),g=ib(h,{animationId:d,animationPath:n});if(g==="update")return p&&r?c({instanceId:`${o}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${o}-animation-update`,targetId:a}),l;if(g==="transition"){let y=`${o}-animation-transition`,b=f?.continuity==="persistent"?y:`${o}-animation-in`;if(u&&p&&m)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${o}-animation-out`,targetId:a}),p&&c({instanceId:b,targetId:r})}return l},c0=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),na=(e,t,s)=>{for(let i of["width","height"]){let a=e[i];if(a!==void 0&&(typeof a!="number"||!Number.isFinite(a)||a<=0))throw new Error(`${s}${i} must be a positive number`)}return{width:e.width??t?.width??1920,height:e.height??t?.height??1080}},u0=(e,{presentationState:t,previousPresentationState:s,currentLineActions:i,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:n,skipTransitionsAndAnimations:o,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:b,canRollback:w,form:A,saveSlots:k=[],layoutInstanceState:P})=>{let{elements:I,animations:x}=e;if(t.background){let D=i===void 0?!0:tr(i?.background??{},"animations"),C=I.find(de=>de.id==="story");if(!C)return e;let _=bb(a,t.background),q=_||Ib(t.background),X=s?.background?.resourceId,re=s?.background?.colorId,R=t.background.resourceId??(t.background.animations?X:void 0),M=t.background.colorId??(t.background.animations?re:void 0),J=Hb(a,R),ue={...t.background,colorId:M};if((M!==void 0||J)&&C.children.push(Gb({resources:a,background:ue,screen:r,includeAlpha:!J})),R){let{images:de={},videos:ke={},spritesheets:Q={}}=a,N=$u(a,R),T;if(N==="sprite"?T=de[R]:N==="video"?T=ke[R]:N==="spritesheet-animation"&&(T=Q[R]),T){let F=N==="video",K=N==="spritesheet-animation",ae={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,..._},ye={...du(t.background,{includeDefaultAlpha:!0}),...lr(ae,t.background)},oe;K?oe=sa({id:Is({resourceId:R,kind:N}),resourceId:R,spritesheet:T,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:ye}):oe={id:Is({resourceId:R,kind:N}),type:F?"video":"sprite",src:T.fileId,width:T.width,height:T.height,...ye},F&&(oe.loop=t.background.loop??!1,oe.volume=Fu(T.volume,m,"musicVolume")),oe&&C.children.push(oe)}}if(R){let{layouts:de={}}=a,ke=de[R];if(ke){let{width:Q,height:N}=na(ke,r,`Layout "${R}" `),T={id:Is({resourceId:R,kind:"container"}),type:"container",width:Q,height:N,children:ke.elements,...du(t.background)};q&&Object.assign(T,lr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,..._},t.background));let F=cr(T,We({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:n,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:b,canRollback:w,form:A,characters:a.characters||{},skipTransitionsAndAnimations:o}));F.children=Vr({state:e,elements:F.children,layoutInstanceState:P,rootId:T.id}),C.children.push(Pr(qr(F,{isLineCompleted:n,skipMode:g,skipTransitionsAndAnimations:o}),a))}}let H=gu({resources:a,resourceId:X,colorId:re}),se=gu({resources:a,resourceId:R,colorId:M}),pe=Er({animationsDef:t.background.animations,resources:a,previousResourceId:H.resourceId,currentResourceId:se.resourceId,previousTargetId:H.targetId,currentTargetId:se.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});nr({animationInstances:pe,isLineCompleted:n,skipTransitionsAndAnimations:o,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:D})&&x.push(...pe)}return e},p0=(e,{presentationState:t,previousPresentationState:s,currentLineActions:i,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(b=>b.id==="story");if(!p)return e;let m=t.character.items||[],d=s?.character?.items||[],f=lu(m),h=lu(d),g=new Map,y=new Map;for(let b=0;b<d.length;b++){let w=d[b],A=g.get(w.id)??[];A.push(b),g.set(w.id,A)}for(let b=0;b<m.length;b++){let w=m[b],{transformId:A,sprites:k}=w,P=y.get(w.id)??0;y.set(w.id,P+1);let I=g.get(w.id)?.[P]??-1,x=d[I],D=x?.sprites&&x.sprites.length>0,C=k&&k.length>0,_=I>=0?cu(x,I,h):void 0,q=C?cu(w,b,f):void 0,X=Ru(i,"character",w.id,b,m),re=Er({animationsDef:w.animations,resources:a,previousResourceId:_,currentResourceId:q,previousTargetId:_,currentTargetId:q,animationPath:`character.items[${b}].animations`,idPrefix:q??_??`character-${b}`});if(w.animations&&!k&&!A&&D&&nr({animationInstances:re,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:X})){u.push(...re);continue}if(w.animations&&!k&&!A)continue;if(!k||k.length===0||!A){console.warn("Character item missing sprites or transformId:",w);continue}let R=L(a.transforms,A);if(!R){console.warn("Transform not found:",A);continue}let M={type:"container",id:q,...lr(R,w),...ot(w),children:[]};for(let J of k){let ue=Cu({id:`${q}-${J.id}`,item:J,resources:a});ue&&M.children.push(ue)}p.children.push(M),nr({animationInstances:re,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:X})&&u.push(...re)}}return e},Yu=(e,t)=>{if(!Fo.includes(e))throw new Error(`${t} must be one of: ${Fo.join(", ")}.`)},f0=(e,t)=>{let s=!!e.resourceId||la(e)||ca(e),i=e.layer??(s?void 0:t?.layer)??qo;return Yu(i,`Visual item "${e.id}" layer`),i},d0=(e,{presentationState:t,previousPresentationState:s,currentLineActions:i,resources:a,screen:r,isLineCompleted:n,skipTransitionsAndAnimations:o,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:b,canRollback:w,form:A,saveSlots:k=[],visualLayer:P,layoutInstanceState:I})=>{let{elements:x,animations:D}=e;if(t.visual&&a){let C=x.find(re=>re.id==="story");if(!C)return e;let _=t.visual.items,q=s?.visual?.items||[],X=We({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:n,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:b,canRollback:w,form:A,characters:a.characters||{},skipTransitionsAndAnimations:o});P!==void 0&&Yu(P,"visualLayer");for(let[re,R]of _.entries()){let M=q.find(Q=>Q.id===R.id),J=Ru(i,"visual",R.id,re,_),ue=f0(R,M);if(P!==void 0&&ue!==P)continue;if(Xb(R),R.layout){let Q=$t(a,R),{width:N,height:T}=na(R.layout,r,`Visual item "${R.id}" layout.`),F={id:`visual-${R.id}`,type:"container",width:N,height:T,children:structuredClone(R.layout.elements),...lr(Q,R)};Object.assign(F,ot(R)),C.children.push(pa({state:e,container:F,resources:a,templateData:X,layoutInstanceState:I,isLineCompleted:n,skipMode:g,skipTransitionsAndAnimations:o}))}if(R.text){let Q=$t(a,R),N={...structuredClone(R.text),id:`visual-${R.id}`,type:"text",...lr(Q,R)};Object.assign(N,ot(R)),C.children.push(Pr(cr(N,X),a))}if(R.resourceId){let{images:Q={},videos:N={},spritesheets:T={}}=a,F=T[R.resourceId];if(F){let K=$t(a,R),ae=ot(R),ye=sa({id:`visual-${R.id}`,resourceId:R.resourceId,spritesheet:F,animationName:R.animationName,animationSpeed:R.animationSpeed,loop:R.loop,width:R.width,height:R.height,transform:{...lr(K,R),alpha:ae.alpha??R.alpha??1,...ae.blur?{blur:ae.blur}:{},...ae.filters?{filters:ae.filters}:{}}});ye&&C.children.push(structuredClone(ye))}else{let K=Q[R.resourceId]||N[R.resourceId];if(K){let ae=N[R.resourceId]!==void 0,ye=$t(a,R),oe={id:`visual-${R.id}`,type:ae?"video":"sprite",src:K.fileId,width:K.width,height:K.height,...lr(ye,R)};Object.assign(oe,ot(R)),ae&&(oe.loop=K.loop??!1,oe.volume=Fu(K.volume,m,"soundVolume")),C.children.push(oe)}}}let H=!!(L(a.spritesheets,R.resourceId)||L(a.images,R.resourceId)||L(a.videos,R.resourceId));if(R.resourceId&&!H){let Q=L(a.particles,R.resourceId);Q&&C.children.push(zb({item:R,particle:Q,resources:a}))}let se=!!L(a.particles,R.resourceId);if(R.resourceId&&!H&&!se){let{layouts:Q={}}=a,N=L(Q,R.resourceId);if(N){let T=$t(a,R),{width:F,height:K}=na(N,r,`Layout "${R.resourceId}" `),ae={id:`visual-${R.id}`,type:"container",width:F,height:K,children:structuredClone(N.elements),...lr(T,R)};Object.assign(ae,ot(R));let ye=cr(ae,X);ye.children=Vr({state:e,elements:ye.children,layoutInstanceState:I,rootId:ae.id}),C.children.push(Pr(qr(ye,{isLineCompleted:n,skipMode:g,skipTransitionsAndAnimations:o}),a))}}let pe=yu(M),de=yu(R),ke=Er({animationsDef:R.animations,resources:a,previousResourceId:pe,currentResourceId:de,previousTargetId:pe?`visual-${R.id}`:void 0,currentTargetId:de?`visual-${R.id}`:void 0,animationPath:`visual.items[${R.id}].animations`,idPrefix:R.id});nr({animationInstances:ke,isLineCompleted:n,skipTransitionsAndAnimations:o,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:J})&&D.push(...ke)}}return e},Rt="dialogue-character-sprite",m0=(e,{presentationState:t,previousPresentationState:s,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})=>{let{animations:o}=e,l=ct(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=s?.dialogue?.character?.sprite,p=Wt(c),m=Wt(u),d=Er({animationsDef:c?.animations,resources:i,previousResourceId:m?Rt:void 0,currentResourceId:p?Rt:void 0,previousTargetId:m?Rt:void 0,currentTargetId:p?Rt:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&nr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&o.push(...d),e;let f=L(i.transforms,c.transformId);if(!f)return console.warn("Transform not found:",c.transformId),e;let h={type:"container",id:Rt,...lr(f),children:[]};for(let g of c.items){let y=Cu({id:`${Rt}-${g.id}`,item:g,resources:i});y&&h.children.push(y)}return l.children.push(h),nr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&o.push(...d),e},y0=(e,{presentationState:t,previousPresentationState:s,resources:i={},dialogueUIHidden:a,autoMode:r,skipMode:n,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:b,activePersistentAnimations:w,saveSlots:A=[],layoutInstanceState:k})=>{let{elements:P,animations:I}=e;if(!t.dialogue||a)return e;let x=P.find(C=>C.id==="story");if(!x)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:C={}}=i,_=C[t.dialogue.ui.resourceId];if(_){let q={elements:_.elements},X=We({variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:b,saveSlots:A,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:r,skipMode:n,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,characters:i.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),re=cr(q,X),R=Pr(qr(Vr({state:e,elements:re?.elements,layoutInstanceState:k,rootId:"dialogue-container"}),{isLineCompleted:m,skipMode:n,skipTransitionsAndAnimations:d}),i);if(Array.isArray(R))for(let M of R)x.children.push(M);else R&&x.children.push(R)}}m0(e,{presentationState:t,previousPresentationState:s,resources:i,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:w});let D=Er({animationsDef:t.dialogue.ui?.animations,resources:i,previousResourceId:s?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:s?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return nr({animationInstances:D,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:w})&&I.push(...D),e},h0=(e,{presentationState:t,previousPresentationState:s,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,form:y,activePersistentAnimations:b,saveSlots:w=[],layoutInstanceState:A})=>{let{elements:k,animations:P}=e;if(t.choice&&i){let I=ct(k);if(!I)return e;let x=L(i?.layouts,t.choice.resourceId);if(x&&x.elements){let C={elements:x.elements},_=We({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f??!!t.choice,isFormVisible:h,canRollback:g,form:y,characters:i.characters||{},skipTransitionsAndAnimations:n}),q=cr(C,{..._,choice:{items:(t.choice?.items??[]).map(re=>typeof re?.content!="string"?re:{...re,content:cr(re.content,_)})}}),X=Zo(Pr(qr(Vr({state:e,elements:q?.elements,layoutInstanceState:A,rootId:"choice-container"}),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:n}),i));if(Array.isArray(X))for(let re of X)I.children.push(re);else X&&I.children.push(X)}let D=Er({animationsDef:t.choice.animations,resources:i,previousResourceId:s?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:s?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});nr({animationInstances:D,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:b})&&P.push(...D)}return e},g0=(e,{presentationState:t,previousPresentationState:s,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,activePersistentAnimations:y,saveSlots:b=[],form:w,layoutInstanceState:A})=>{let{elements:k,animations:P}=e;if(!w?.resourceId||!i)return e;let I=ct(k);if(!I)return e;let x=L(i?.layouts,w.resourceId);if(!x)return console.warn(`Form layout not found: ${w.resourceId}`),e;let D={id:"form-container",type:"container",x:0,y:0,children:x.elements||[]},C={...We({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,characters:i.characters||{},skipTransitionsAndAnimations:n,form:w}),form:w},_=cr(D,C),q=ra(Pr(qr(ea(_,w),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:n}),i),w);q?.children&&(q.children=Vr({state:e,elements:q.children,layoutInstanceState:A,rootId:q.id})),q&&I.children.push(q);let X=Er({animationsDef:w.animations,resources:i,previousResourceId:s?.form?.resourceId,currentResourceId:w.resourceId,previousTargetId:s?.form?.resourceId?"form-container":void 0,currentTargetId:w.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return nr({animationInstances:X,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:y})&&P.push(...X),e},b0=(e,{presentationState:t,resources:s={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:o,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],skipTransitionsAndAnimations:g,layoutInstanceState:y})=>{if(!t.control?.resourceId)return e;let b=L(s.controls,t.control.resourceId);if(!b)return e;let w=l0(b.keyboard,b.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(b.elements)||b.elements.length===0)return e;let A=ct(e.elements);if(!A)return e;let k={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:b.elements};return A.children.push(pa({state:e,container:k,resources:s,templateData:We({variables:i,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:o,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:s.characters||{},skipTransitionsAndAnimations:g}),layoutInstanceState:y,isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},fa=({presentationState:e,previousBgmRender:t,resources:s={},runtime:i,variables:a,musicRoomPlayer:r,skipTransitionsAndAnimations:n=!1})=>{if(e?.bgm&&s){let o=e.bgm,l=!Array.isArray(o.sounds),c=ds(o),u=!l&&o.loop===!0,p=[];if(l||As(c,"BGM sound"),u){let f=c.find(h=>h.loop===!0);if(f)throw new Error(`BGM sound "${f.id}" cannot loop inside a looping BGM channel.`)}let m=Nc({bgm:o,resources:s,previousBgmRender:t});if(c.forEach(f=>{let h=L(s.sounds,f.resourceId);if(!h)return;let g=u?{...f,loop:f.loop??!1}:f;p.push(t0({node:Ss({id:m.get(f.id),sound:g,resource:h,projectResources:s,soundPath:`bgm.sounds[${JSON.stringify(f.id)}]`,defaultLoop:!u,skipTransitionsAndAnimations:n}),bgm:o,sound:g,resource:h,usesLegacySound:l}))}),p.length===0)return null;let d=We({variables:a,runtime:i}).runtime;return Es({id:Kb,volume:ua(d,"musicVolume"),muted:!1,pan:0,loop:l?void 0:o.loop,playback:r?.bgmPlayback,interruption:o.interruption,children:p,runtime:d})}return null},w0=(e,t)=>{if(!ct(e.elements))return e;let i=fa(t);return i&&e.audio.push(i),e},I0=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:s})=>(t?.length>0&&!s&&(e.audioEffects=structuredClone(t)),e),v0=(e,{resources:t={},runtime:s,variables:i,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let n=r.tracks.find(u=>u.id===a.trackId),o=n?L(t.sounds,n.soundId):void 0;if(!n||!o)return e;let l=We({variables:i,runtime:s}).runtime,c=Ss({id:Jb,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:o,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(Es({id:Wb,volume:xs(l,"musicVolume",xr),children:[c],runtime:l})),e},k0=(e,{presentationState:t,resources:s,runtime:i,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&s){let n=t.sfx,o=Array.isArray(n.channels)?n.channels:[],l=o.map(c=>({channel:c,usesLegacyChannel:!1}));As(o,"SFX channel"),Array.isArray(n.items)&&l.push({channel:{id:Zb,sounds:n.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,m=[];if(u||As(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let d=c.sounds.find(f=>f.loop===!0);if(d)throw new Error(`SFX sound "${d.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((d,f)=>{let h=L(s.sounds,d.resourceId);if(!h)return;let g=p?{...d,loop:d.loop??!1}:d;m.push(Ss({id:u?or("sfx","default",f,d.id):or("sfx",c.id,d.id),sound:g,resource:h,projectResources:s,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(d.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),m.length!==0&&r.push(Es({id:or("channel","sfx",c.id),volume:xs(i,"soundVolume",c.volume??xr),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:m,runtime:i}))})}return e},A0=(e,t,s)=>{if(!(!t||!s))return L(L(e?.voices,t),s)},P0=(e,{presentationState:t,resources:s,currentSceneId:i,runtime:a,variables:r,skipTransitionsAndAnimations:n})=>{let{audio:o}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:xr,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,m=[];if(c||As(u,"Voice sound"),p){let f=u.find(h=>h.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(f=>{let h=A0(s,i,f.resourceId);if(!h)return;let g=p?{...f,loop:f.loop??!1}:f;m.push(Ss({id:or("voice",i,c?"default":f.id),sound:g,resource:h,projectResources:s,soundPath:`voice.sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:n}))}),m.length===0)return e;let d=We({variables:r,runtime:a}).runtime;return o.push(Es({id:Qb,volume:c?l.volume??ua(d,"soundVolume"):xs(d,"soundVolume",l.volume??xr),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:m,runtime:d})),e},x0=(e,{presentationState:t,previousPresentationState:s,resources:i={},variables:a,imageGallery:r,musicRoom:n,sceneReplay:o,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:b,layoutInstanceState:w})=>{let{elements:A,animations:k}=e;if(t.layout){let D=ct(A);if(!D)return e;let C=L(i.layouts,t.layout.resourceId);if(!C)return e;let _={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:C.elements||[]};D.children.push(pa({state:e,container:_,resources:i,templateData:We({variables:a,imageGallery:r,musicRoom:n,sceneReplay:o,runtime:l,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:i.characters||{},skipTransitionsAndAnimations:y}),layoutInstanceState:w,isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:y}))}let P=s?.layout?.resourceId,I=t.layout?.resourceId,x=Er({animationsDef:t.layout?.animations,resources:i,previousResourceId:P,currentResourceId:I,previousTargetId:P?`layout-${P}`:void 0,currentTargetId:I?`layout-${I}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return nr({animationInstances:x,isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:b})&&k.push(...x),e},E0=(e,{currentLineActions:t,previousPresentationState:s,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})=>{let{animations:o}=e,l=t?.screen?.animations;if(!l)return e;let c=s!=null,u=Er({animationsDef:l,resources:i,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return nr({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&o.push(...u),e},S0=(e,{presentationState:t})=>{let s=ct(e.elements);return!s||!t?.screen||Object.assign(s,Mu(t.screen)),e},O0=(e,{presentationState:t,resources:s={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:o,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:h=[],saveSlots:g=[],screen:y,isLineCompleted:b,skipTransitionsAndAnimations:w,layoutInstanceState:A})=>{let{elements:k}=e;return f&&f.length>0&&f.forEach((P,I)=>{let x=L(s.layouts,P.resourceId);if(!x){console.warn(`Overlay layout not found: ${P.resourceId}`);return}let D={id:`overlayStack-${I}`,type:"container",x:0,y:0,children:[Bu({id:`overlayStack-${I}-blocker`,screen:y}),...x.elements||[]]},C=Uu(h,s.characters,i),_=We({variables:i,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:o,saveSlots:g,dialogueState:t?.dialogue,isLineCompleted:b,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:C,characters:s.characters||{},skipTransitionsAndAnimations:w}),q=cr(D,_),[X,...re]=q.children||[],R=Vr({state:e,elements:re,layoutInstanceState:A,rootId:D.id}),M=Pr(qr({...q,children:R},{isLineCompleted:b,skipMode:c,skipTransitionsAndAnimations:w}),s);k.push({...M,children:X?[X,...M.children||[]]:M.children})}),e},R0=(e,{presentationState:t,resources:s={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:o,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,dialogueHistory:g=[],screen:y,isLineCompleted:b,skipTransitionsAndAnimations:w,layoutInstanceState:A})=>{let{elements:k}=e;if(!h?.resourceId)return e;let P=L(s.layouts,h.resourceId);if(!P)return console.warn(`ConfirmDialog layout not found: ${h.resourceId}`),e;let I={id:"confirmDialog",type:"container",x:0,y:0,children:[Bu({id:"confirmDialog-blocker",screen:y}),...P.elements||[]]},x=Uu(g,s.characters,i),D=cr(I,We({variables:i,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:o,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:b,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,historyDialogue:x,characters:s.characters||{},skipTransitionsAndAnimations:w})),[C,..._]=D.children||[],q=Vr({state:e,elements:_,layoutInstanceState:A,rootId:I.id}),X=Pr(qr({...D,children:q},{isLineCompleted:b,skipMode:u,skipTransitionsAndAnimations:w}),s);return k.push({...X,children:C?[C,...X.children||[]]:X.children}),e},yn=e=>(t,s)=>d0(t,{...s,visualLayer:e}),$0=yn(Ar.BEHIND_BACKGROUND),C0=yn(Ar.BEHIND_CHARACTER),_0=yn(Ar.BEHIND_DIALOGUE),N0=yn(Ar.BEHIND_CHOICE),j0=yn(Ar.FOREGROUND),zu=e=>{let s=ts(c0,[b0,$0,u0,C0,p0,_0,y0,N0,h0,g0,x0,j0,S0,E0,w0,v0,k0,P0,I0,O0,R0]),i={usedIds:new Set,claimedNamespaces:new Set},a=Array.isArray(e)?e.map(r=>({...r,layoutInstanceState:i})):{...e,layoutInstanceState:i};return s(a)};function Xu(e,t=""){let s=[],i=e.length,a=0,r=0,n=-1,o=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<i;){let l=n+1+o();n=l+o(),s.push([l,n,t?parseInt(t[r++],36):0])}return s}function Gu(e,t,s){let i=0,a=t.length-1;for(;i<=a;){let r=i+a>>>1,n=s[r];if(e<t[r])a=r-1;else if(e>n>>>5)i=r+1;else return n&31}return 0}var Hu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Ku="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Wu="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Ju=65535,da=40960,Os=126976,ep=new Uint8Array(12288),rp=new Uint8Array(3072),tp=new Uint8Array(2816),np,sp;{let e=(a,r,n,o,l)=>{let c=r+a.length-1;for(let u=n<r?r:n,p=o>c?c:o;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),s=new Uint32Array(320),i=0;for(let[a,r,n]of Xu(Hu,Ku))e(ep,0,a,r,n),e(rp,da,a,r,n),e(tp,Os,a,r,n),r>=65040&&!(a>=Os&&r<=129791)&&(t[i]=a,s[i++]=r<<5|n);np=t.slice(0,i),sp=s.slice(0,i)}function Qu(e){return e<12288?ep[e]:e<da?e<12336?e>=12330?3:0:e<12443?e===12336||e===12349?4:e>=12441?3:0:e===12951||e===12953?4:0:e<44032?rp[e-da]:e<55204?(e-44032)%28?8:7:e<57344?e<=55238?e>=55216?13:0:e>=55243&&e<=55291?12:0:e<65024?e===64286?3:0:e<65040?3:e>=Os&&e<129792?tp[e-Os]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Gu(e,np,sp)}var ip=Uint8Array.from(Wu,Number);function T0(e){return e===2381||e===2509||e===2637||e===2765||e===2893||e===3149||e===3405||e===4153||e===6098||e===6752||e===6980||e===7083||e===43456||e===43766||e===68159||e===69939||e===70608||e===71998||e===72263||e===72345||e===73538}function Zu(e,t,s){switch(t){case 3:return e&24?s===8204?e&6:(e&24)===16||T0(s)?e&6|16:e&6|8:e&6;case 4:return 2;case 10:return e&1^1;case 14:return(e&2)<<1|e&24;default:return 8}}function*op(e){let t=e.length;if(t===0)return;let s=e.codePointAt(0),i=s>Ju?2:1,a=Qu(s),r=50200>>a&1?Zu(0,a,s):0,n=0,o=s,l=a;for(;i<t;){s=e.codePointAt(i);let c=s>Ju?2:1,u=Qu(s),p=ip[a<<4|u],m;p===0?m=!0:p===1?m=!1:p===2?m=!(r&1):p===3?m=!(r&4):m=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?Zu(r,u,s):0,m&&(yield{segment:e.slice(n,i),index:n,input:e,_hd:o,_catBegin:l===15?0:l,_catEnd:a===15?0:a},n=i,o=s,l=u),i+=c,a=u}yield{segment:e.slice(n),index:n,input:e,_hd:o,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*ap(e){for(let t of op(e))yield t.segment}{let e=op("_");ip._keep=[e,e.next()]}var lp=1e3,hp=50,D0=0,cp=100,up=50,L0=60,M0=3,V0=.5,q0=2e4,F0=[[4352,4607],[11904,11929],[11931,12019],[12032,12245],[12293,12293],[12295,12295],[12321,12329],[12334,12335],[12344,12347],[12353,12438],[12445,12447],[12449,12538],[12541,12543],[12593,12686],[12784,12830],[12896,12926],[13008,13054],[13056,13143],[13312,19903],[19968,40959],[43360,43388],[44032,55203],[55216,55238],[55243,55291],[63744,64109],[64112,64217],[65382,65391],[65393,65437],[65440,65470],[65474,65479],[65482,65487],[65490,65495],[65498,65500],[94178,94179],[94192,94198],[110576,110579],[110581,110587],[110589,110590],[110592,110882],[110898,110898],[110928,110930],[110933,110933],[110948,110951],[127488,127488],[131072,173791],[173824,178205],[178208,183981],[183984,191456],[191472,192093],[194560,195101],[196608,201546],[201552,210041]],B0=[[9,13],[32,32],[160,160],[5760,5760],[8192,8202],[8232,8233],[8239,8239],[8287,8287],[12288,12288],[65279,65279]],gp=(e,t)=>{let s=0,i=e.length-1;for(;s<=i;){let a=s+i>>1,[r,n]=e[a];if(t<r)i=a-1;else if(t>n)s=a+1;else return!0}return!1},U0=e=>{for(let t of e)if(!gp(B0,t.codePointAt(0)))return!1;return!0},Y0=e=>{for(let t of e)if(gp(F0,t.codePointAt(0)))return!0;return!1},z0=e=>Array.from(ap(`${e??""}`)),X0=e=>z0(e).reduce((t,s)=>U0(s)?t+V0:Y0(s)?t+M0:t+1,0),Rs=new DataView(new ArrayBuffer(8)),G0=128,pp=64n,fp=new Map,H0=e=>{let t=fp.get(e);if(t===void 0){let s=1n<<BigInt(e)+pp,i=0n;for(let a=1n;s>>a!==0n;a+=1n)i+=(s>>a)/a;t=i>>pp,fp.set(e,t)}return t},dp=(e,t)=>{let s=BigInt(e.toString(2).length-53),i=e>>s,a=e-(i<<s),r=1n<<s-1n;(a>r||a===r&&(i&1n)===1n)&&(i+=1n);let n=s-BigInt(t);return i===1n<<53n&&(i>>=1n,n+=1n),Rs.setBigUint64(0,n+1075n<<52n|i-(1n<<52n)),Rs.getFloat64(0)},K0=e=>{if(e===0)return 1;if(e===1)return 2;if(e===-1)return .5;Rs.setFloat64(0,e);let t=Rs.getBigUint64(0),s=Number(t>>52n&0x7ffn),i=t&(1n<<52n)-1n,a=s===0?i:i|1n<<52n,r=t>>63n===1n?-a:a,n=1075-Math.max(s,1);for(let o=G0;;o*=2){let l=1n<<BigInt(o),c=r*H0(o),u=n>=0?c>>BigInt(n):c<<BigInt(-n),p=l,m=l,d=1;for(let y=1n;p!==0n;y+=1n)p=p*u/(l*y),m+=p,d+=1;let f=BigInt(4*d+16),h=dp(m-f,o),g=dp(m+f,o);if(h===g)return h}},mp=0,yp=1,W0=e=>{let s=((Number.isFinite(e)?Math.min(cp,Math.max(D0,e)):hp)-up)/(cp-up);return s!==mp&&(yp=K0(s),mp=s),yp},ma=({text:e="",baseDelay:t=lp,speed:s=hp}={})=>{let i=Number.isFinite(t)?Math.max(0,t):lp,a=W0(s),r=X0(e)*L0/a,n=Math.max(i,q0);return Math.min(i+r,n)};var $s={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Pp=1,xp=6,Sr=1,jt="choice",Br="form",wn=()=>({manual:{...$s.manual},auto:{...$s.auto},applyMode:$s.applyMode}),Ea=()=>({groupId:null,variantId:null,pageIndex:0}),J0="music-room:player",Q0=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),Ns=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Sa=new Set,Z0=new Set(["groupId","variantId"]),ew=new Set(["pageIndex"]),Tt=new Set,rw=new Set(["trackId"]),tw=new Set(["positionMs"]),nw=new Set(["pageIndex"]),Oa=new Set,sw=new Set(["sceneId"]),iw=new Set(["pageIndex"]),Ra=()=>({pageIndex:0}),$a=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let s=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...wn()},s&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},ha=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},B=e=>{let t=Ie(e)?Ge(e):e;return structuredClone(t)},U=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),js=e=>{let t=e.global.audioCommandId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal audio command counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=t+1,e.global.audioCommandId},Ep=e=>{let t=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal scene replay entry counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=t+1,e.global.sceneReplayEntryId},In=(e,t,s)=>({commandId:js(e),operation:t,...s===void 0?{}:{positionMs:s}}),Ca=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,s=t.bgmPlayback;t.trackId!==null&&(s={commandId:js(e),operation:"resume"}),e.global.musicRoomPlayer=Ns({bgmPlayback:s})},Sp=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let s=L(e.projectData.resources?.achievements,t);if(!s)throw new Error(`Achievement resource "${t}" not found`);if(s.type!=="boolean"&&s.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${s.type}"`);return s},Op=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let s=typeof e=="string"&&e.length>0,i=typeof e=="number"&&Number.isFinite(e);if(!s&&!i)throw new Error(`${t} requires a non-empty string or finite number slotId`)},ft=e=>String(e),Rp=()=>({sections:[],resources:[]}),$p=()=>({sceneIds:[]}),ow=e=>U(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Rp(),aw=e=>U(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):$p(),lw=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",cw=({sectionId:e,lineId:t,content:s,dialogueState:i,characterName:a})=>({sectionId:e,lineId:t,content:s,text:lw(s),characterId:i.characterId,character:{...i.character||{},name:a},characterName:a}),Cp=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),uw=e=>U(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,_a=e=>{if(!U(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},pw=e=>{if(!U(e?.dialogueHistory))return e.dialogueHistory=Cp(e?.rollback?.timeline?.length??0),e.dialogueHistory;let t=e.dialogueHistory;return Array.isArray(t.entries)||(t.entries=[]),Number.isInteger(t.currentLength)||(t.currentLength=t.entries.length),Array.isArray(t.checkpointLengths)||(t.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),t.currentLength=Math.min(Math.max(t.currentLength,0),t.entries.length),t},Na=e=>{let t=_a(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},fw=()=>({resourceId:void 0}),dw=e=>{if(!U(e))return e;let t={...e};return Object.prototype.hasOwnProperty.call(t,"requireComplete")&&!Object.prototype.hasOwnProperty.call(t,"requireLineCompleted")&&(t.requireLineCompleted=t.requireComplete),delete t.requireComplete,t},Qe=(e,t)=>{let s=e?.story?.scenes??{};for(let[i,a]of Object.entries(s)){let r=L(a?.sections,t);if(r)return{sceneId:i,section:r}}return{sceneId:void 0,section:void 0}},_p=e=>{let t=e?.story?.scenes??{},s=new Map;for(let[i,a]of Object.entries(t)){let r=a?.sections??{};for(let n of Object.keys(r)){let o=s.get(n);if(o!==void 0)throw new Error(`Duplicate sectionId "${n}" found in scenes "${o}" and "${i}". Section IDs must be globally unique.`);s.set(n,i);let l=L(r,n)?.lines,c=new Map;Array.isArray(l)&&l.forEach((u,p)=>{if(typeof u?.id=="string"){if(c.has(u.id))throw new Error(`Duplicate lineId "${u.id}" in scene "${i}", section "${n}": lines[${p}] duplicates lines[${c.get(u.id)}]. Line IDs must be unique within a section.`);c.set(u.id,p)}})}}},Np=e=>e,jp=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Pp)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},mw=(e,t={})=>{let s;try{s=jp(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let i={...t,formatVersion:s,slotId:Np(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete i.slotKey,delete i.date,i},yw=(e={})=>Object.fromEntries(Object.entries(e).map(([t,s])=>[t,mw(t,s)])),hw=(e,t)=>{if(!U(e)||!Array.isArray(e.operations))return null;let s=e.operations.filter(i=>{if(!U(i))return!1;let{variableId:a,op:r,value:n,roundTo:o}=i,l=L(t?.resources?.variables,a);if(!l||Ne(l)||l.readonly===!0||l.scope!=="context")return!1;try{return nn(l.type,r,a),is(l.type,r,n,a,{roundTo:o}),r!=="set"||Ao(l,n)}catch{return!1}});return s.length>0?{...e,operations:s}:null},Tp=(e,t)=>{if(!Array.isArray(e))return;let s=e.flatMap(i=>{if(!U(i)||!nk(i.type))return[];if(i.type!=="updateVariable"||t===void 0)return[i];let a=hw(i.payload,t);return a?[{...i,payload:a}]:[]});return s.length>0?s:void 0},gw=(e,t,s)=>{let{section:i}=Qe(e,t?.sectionId),r=i?.lines?.find(({id:o})=>o===t?.lineId)?.actions,n=s.split(".");for(let o of n){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(o))return;let l=Number(o);if(!Object.prototype.hasOwnProperty.call(r,l))return;r=r[l];continue}if(!U(r)||!Object.prototype.hasOwnProperty.call(r,o))return;r=r[o]}return n.at(-1)==="random"&&U(r?.distribution)?r:void 0},Dp=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let t=e.max-e.min+1;return Number.isSafeInteger(t)&&t>=1&&t<=4294967296},Lp=(e,t,s)=>e.filter(({path:i,type:a,result:r})=>{let n=gw(s,t,i);if(n?.distribution?.type!==a)return!1;if(a==="weighted")return U(n.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let o=L(s?.resources?.variables,n.variableId);return typeof n.variableId=="string"&&o?.type==="number"&&o.scope==="context"&&o.readonly!==!0&&!Ne(o)&&Dp(n.distribution)&&r.value>=n.distribution.min&&r.value<=n.distribution.max}return!1}),ja=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==Sr)throw new Error(`unsupported rollback random outcome version: ${e.randomOutcomeVersion}`);if(!Array.isArray(e.randomOutcomes))throw new Error("versioned rollback random outcomes must be an array");let s=new Set,i=e.randomOutcomes.map((a,r)=>{let n=`${a?.path}\0${a?.ordinal}`;if(!U(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||s.has(n))throw new Error(`invalid rollback random outcome at index ${r}`);return s.add(n),{path:a.path,ordinal:a.ordinal,type:a.type,result:cs(B(a.result),a.type)}});return t===void 0?i:Lp(i,e,t)},bw=(e,t)=>{!U(e)||!Array.isArray(e.timeline)||e.timeline.forEach(s=>{if(!U(s))return;typeof s.returnable!="boolean"&&delete s.returnable;let i=Tp(s.executedActions,t);i?s.executedActions=i:delete s.executedActions;let a=ja(s,t);a?(s.randomOutcomeVersion=Sr,s.randomOutcomes=a):(delete s.randomOutcomeVersion,delete s.randomOutcomes)})},ww=(e,t)=>{let s=e??{};return Object.values(s).forEach(i=>{let a=i?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let n=r?.rollback?.timeline;Array.isArray(n)&&n.forEach(o=>{if(!U(o))return;let l=ja(o,t);l?(o.randomOutcomeVersion=Sr,JSON.stringify(o.randomOutcomes)!==JSON.stringify(l)&&(o.randomOutcomes=l)):(delete o.randomOutcomeVersion,delete o.randomOutcomes)})})}),s},bp=(e,t,s,i="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!U(e))throw new Error(`Malformed ${i}.${t}[${s}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${i}.${t}[${s}] entry: missing ${a}.`);if(t==="sections"){let r={sectionId:e.sectionId};if(e.lastLineId!==void 0&&e.lastLineId!==null&&typeof e.lastLineId!="string")throw new Error(`Malformed ${i}.sections[${s}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},Iw=(e,t="viewedRegistry")=>{if(e===void 0)return Rp();if(!U(e))throw new Error(`Malformed ${t}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${t}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${t}.resources.`);let s=e.sections??[],i=e.resources??[];return{sections:Object.values(Object.fromEntries(s.map((a,r)=>{let n=bp(a,"sections",r,t);return[n.sectionId,n]}))),resources:Object.values(Object.fromEntries(i.map((a,r)=>{let n=bp(a,"resources",r,t);return[n.resourceId,n]})))}},vw=(e,t="accountReplayRegistry")=>{if(e===void 0)return $p();if(!U(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let s=e.sceneIds??[];return{sceneIds:[...new Set(s.map((i,a)=>{if(typeof i!="string"||i.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return i}))]}},hn=(e,t,s)=>{if(!U(e))throw new Error(`Malformed save slot ${s}.`);let{sectionId:i,lineId:a}=e;if(typeof i!="string"||i.length===0)throw new Error(`Malformed save slot ${s}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${s}: missing lineId.`);let{sceneId:r,section:n}=Qe(t,i);if(!n)throw new Error(`Malformed save slot ${s}: section "${i}" does not exist in projectData.`);if(!n.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${s}: line "${a}" does not exist in section "${i}".`);return{sceneId:r,sectionId:i,lineId:a}},Mp=e=>{let t=e.story.initialSceneId,s=L(e.story.scenes,t),i=s.initialSectionId,a=L(s.sections,i);return hn({sceneId:t,sectionId:i,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},kw=e=>{try{return Mp(e),!0}catch{return!1}},Aw=(e,t,s)=>{let i=e?.pointers?.read;if(!U(i)||typeof i.sectionId!="string"||i.sectionId.length===0||typeof i.lineId!="string"||i.lineId.length===0)return hn(i,t,s);try{return hn(i,t,s)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],r=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let n=r;n>=0;n-=1)try{return hn(a[n],t,`${s} compatibility checkpoint`)}catch{}return Mp(t)}};var Vp=(e,t)=>{let{section:s}=Qe(e,t?.sectionId);return s?.lines?.find(i=>i.id===t?.lineId)},Pw=(e,t,s)=>{if(!U(e))throw new Error(`Malformed save slot ${s}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${s}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${s}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${s}.checkpointLengths.`);let i=[],a=[0],r=!1;if(e.entries.forEach((o,l)=>{if(!U(o))throw new Error(`Malformed save slot ${s}.entries[${l}].`);if(typeof o.sectionId!="string"||o.sectionId.length===0)throw new Error(`Malformed save slot ${s}.entries[${l}]: missing sectionId.`);if(typeof o.lineId!="string"||o.lineId.length===0)throw new Error(`Malformed save slot ${s}.entries[${l}]: missing lineId.`);if(o.appendToPrevious!==void 0&&typeof o.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${s}.entries[${l}].appendToPrevious.`);let{section:c}=Qe(t,o.sectionId);if(!c?.lines?.some(p=>p.id===o.lineId)){r=!1,a.push(i.length);return}i.push({sectionId:o.sectionId,lineId:o.lineId,...o.appendToPrevious===!0&&r&&i.length>0?{appendToPrevious:!0}:{}}),r=!0,a.push(i.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${s}.currentLength: must reference the retained entries.`);let n=e.checkpointLengths.map((o,l)=>{if(!Number.isInteger(o)||o<0||o>e.entries.length)throw new Error(`Malformed save slot ${s}.checkpointLengths[${l}].`);return a[o]});return{entries:i,currentLength:a[e.currentLength],checkpointLengths:n}},xw=(e,t)=>U(Vp(e,t)?.actions?.dialogue),qp=(e,t,s)=>{if(!t||t.sectionId!==s.sectionId)return!1;let{section:i}=Qe(e,s.sectionId),a=i?.lines?.findIndex(n=>n.id===s.lineId);return typeof a!="number"||a<=0?!1:i.lines.slice(0,a).findLast(n=>U(n.actions?.dialogue))?.id===t.lineId},Ew=(e,t)=>{let s=Cp();return e.timeline.forEach(i=>{if(i.returnable!==!1&&xw(t,i)){let a=Vp(t,i),r=s.entries.at(-1),n=a.actions.dialogue.append===!0&&qp(t,r,i);s.entries.push({sectionId:i.sectionId,lineId:i.lineId,...n?{appendToPrevious:!0}:{}})}s.checkpointLengths.push(s.entries.length)}),s.currentLength=s.checkpointLengths[e.currentIndex]??0,s.entries.length>0?s:null},Sw=(e,t,s,i)=>{if(s.length!==t.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==i)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=s.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,n)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${n}]: lengths must be chronological.`);a=r}),e},Ow=(e,t,s)=>{if(!U(e)||!Array.isArray(e.timeline))return{rollback:bn({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let i=[],a=e.timeline.flatMap((c,u)=>{if(!U(c))return[];let p=ja(c);try{let m=hn(c,s,`rollback.timeline[${u}]`),d=p?Lp(p,m,s):void 0,f=_s({sectionId:m.sectionId,lineId:m.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...d?{randomOutcomeVersion:Sr,randomOutcomes:d}:{}}),h=Tp(B(c.executedActions),s);return h&&(f.executedActions=h),i.push(u),[f]}catch{return[]}});if(a.length===0)return{rollback:bn({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,n=i.indexOf(r);n<0&&(n=a.length-1);let o=a[n];if(o?.sectionId!==t.sectionId||o?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?n=c:(a.push(_s({sectionId:t.sectionId,lineId:t.lineId})),i.push(null),n=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),n):0;return{rollback:{currentIndex:n,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:i,sourceTimelineLength:e.timeline.length}},Fp=(e,t,s)=>{if(!U(e))throw new Error(`Malformed save slot contexts[${s}] entry.`);let i=La(t),a=Aw(e,t,`contexts[${s}].pointers.read`);if(e.variables!==void 0&&!U(e.variables))throw new Error(`Malformed save slot contexts[${s}].variables entry.`);if(e.runtime!==void 0&&!U(e.runtime))throw new Error(`Malformed save slot contexts[${s}].runtime entry.`);let r=e.variables?rn(B(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},n=qw({loadedContextRuntime:U(e.runtime)?B(e.runtime):{}}),{rollback:o,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Ow(e.rollback,a,t),u=e.dialogueHistory===void 0?Ew(o,t):Sw(Pw(e.dialogueHistory,t,`contexts[${s}].dialogueHistory`),o,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:U(e.configuration)?B(e.configuration):{},views:Array.isArray(e.views)?B(e.views):[],bgm:U(e.bgm)?B(e.bgm):{resourceId:void 0},variables:{...i,...r},...u?{dialogueHistory:u}:{},rollback:o};return n&&(p.runtime=n),p},Rw=(e,t)=>{if(!U(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((s,i)=>Fp(s,t,i))}},$w=(e,t)=>{if(!U(e))throw new Error("Malformed save slot.");let s=jp(e.formatVersion);return{...e,formatVersion:s,state:Rw(e.state,t)}},wp=(e,t,{required:s=!1}={})=>{if(e===void 0){if(s)throw new Error(`showConfirmDialog requires ${t}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${t} must be an action object`);let i=B(e),a=i.hideConfirmDialog??{};return delete i.hideConfirmDialog,{hideConfirmDialog:a,...i}},Cw=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:wp(e.confirmActions,"confirmActions",{required:!0}),cancelActions:wp(e.cancelActions,"cancelActions")}},Dt=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},_w=e=>(U(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Lt=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Bp=e=>{if(!(!U(e)||!e.animations))return{animations:B(e.animations)}},Nw=(e,t)=>{let s=Bp(t);if(s){e.global.pendingScreenTransition=s;return}delete e.global.pendingScreenTransition},jw=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},Tw=(e,t)=>{let s=e?.sectionId,i=e?.lineId;if(!(!s||!i||!t))return`${s}:${i}:${t}`},Cs=e=>String(e??""),Up=(e,t)=>{let s=Cs(t);return e?.trim===!0?s.trim():s},Dw=e=>U(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>U(t)).map(([t,s])=>[t,{id:t,...B(s)}])):{},Lw=(e,t)=>{if(!t||!U(e.global.formDrafts))return;let s=e.global.formDrafts[t];return U(s)?s:void 0},Yp=(e,t)=>{let s=_w(e);U(s[t])||(s[t]={values:{},touched:{},errors:{},submitted:!1});let i=s[t];return U(i.values)||(i.values={}),U(i.touched)||(i.touched={}),U(i.errors)||(i.errors={}),typeof i.submitted!="boolean"&&(i.submitted=!1),i},Ta=(e,t)=>{let s=Up(e,t);return e?.required===!0&&s.length===0?"required":null},Da=({state:e,pointer:t},s=0)=>{if(t?.sectionId==null||t?.lineId==null)return s<0?null:{};let i=Ie(e.projectData)?Ge(e.projectData):e.projectData,{section:a}=Qe(i,t.sectionId);return tu(i,a,t.lineId,s)},Mw=({state:e,form:t,pointer:s})=>{if(!t?.resourceId)return null;let i=jw(t),a=Tw(s,i);if(!i||!a)return null;let r=Lw(e,a),n=Dw(t),o=Wa({state:e}),l={},c=[],u={},p=!0;return Object.entries(n).forEach(([m,d])=>{let f=Cs(o?.[d.variableId]),h=Object.prototype.hasOwnProperty.call(r?.values??{},m)?Cs(r.values[m]):f,g=r?.touched?.[m]===!0,y=Ta(d,h),b=r?.submitted||g?y:null,w=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,A={id:m,variableId:d.variableId,value:h,initialValue:f,valid:!y,error:b,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...w!==void 0?{maxLength:w}:{}};y&&(p=!1),l[m]=A,c.push(A),u[m]=h}),{id:i,key:a,resourceId:t.resourceId,animations:t.animations,valid:p,submitted:r?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:B(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:B(t.cancelActions??{})}}}},Nt="line",Fr="interaction",_s=({sectionId:e,lineId:t,rollbackPolicy:s,returnable:i,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:s??"free",...typeof i=="boolean"?{returnable:i}:{},...a===Sr?{randomOutcomeVersion:Sr,randomOutcomes:B(r??[])}:{}}),La=e=>{let t=Ie(e)?Ge(e):e,{contextVariableDefaultValues:s}=ss(t??{});return B(s)},zp=()=>({...B(un)}),Xp=({loadedRuntime:e,runtimeIds:t,defaults:s={},path:i})=>{if(e===void 0)return{runtimeState:B(s),hasLoadedValues:!1};if(!U(e))throw new Error(`Malformed ${i}.`);let a=B(s),r=!1;return t.forEach(n=>{e[n]!==void 0&&(a[n]=gs(n,B(e[n])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Vw=({projectData:e,loadedGlobalRuntime:t={}})=>Xp({loadedRuntime:t,runtimeIds:Lo,defaults:Vo(e),path:"global.runtime"}).runtimeState,qw=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:s}=Xp({loadedRuntime:e,runtimeIds:Mo,defaults:zp(),path:"context.runtime"});return s?t:void 0},Yr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},be=e=>{let t=Yr(e);return t?.kind==="sceneReplay"&&U(t.sceneReplay)?t:null},Gp=(e,t)=>{let s=t?.sceneReplay?.sceneId,i=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===s);Object.entries(i?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=B(r)})},Fw=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:B(e.global.nextLineConfig),overlayStack:B(e.global.overlayStack),confirmDialog:B(e.global.confirmDialog),formDrafts:B(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:B(e.global.pendingScreenTransition)}}),Bw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=wn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Uw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=B(t.nextLineConfig),e.global.overlayStack=B(t.overlayStack),e.global.confirmDialog=B(t.confirmDialog),e.global.formDrafts=B(t.formDrafts),e.global.isLineCompleted=t.isLineCompleted,t.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=t.isDialogueHistoryShowing,t.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=B(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let s=Re({state:e});e.global.autoMode&&e.global.isLineCompleted&&!s&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e.global.skipMode&&!s&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!s&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},Yw=e=>e.runtime?(Mo.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=B(un[t]))}),e.runtime):(e.runtime=zp(),e.runtime),zw=e=>iu(e.global),Hp=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:zw(e)}})},Ma=(e,t,s)=>{let i=gs(t,s);if(t in un){let a=Yr(e);if(!a)return i;let r=Yw(a);return r[t]=i,i}return e.global[t]=i,i},Va=({pointer:e,projectData:t,kind:s,sceneReplay:i})=>({...s===void 0?{}:{kind:s},...i===void 0?{}:{sceneReplay:B(i)},currentPointerMode:"read",pointers:{read:B(e)},configuration:{},views:[],bgm:fw(),variables:La(t),rollback:bn({pointer:e})}),Mt=e=>e?(e.currentPointerMode="read",U(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,Xw=(e,{queueRender:t=!0}={})=>{let s=e.contexts?.[e.contexts.length-1],i=s?.pointers?.read;if(!s||!i?.sectionId||!i?.lineId)return null;let a=Va({pointer:i,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Gw(e,{queueRender:t}),a},Gw=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,Dt(e),Lt(e),e.global.nextLineConfig=wn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Ca(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Kp=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},bn=({pointer:e,replayStartIndex:t=0})=>{let s=e?.sectionId&&e?.lineId;return{currentIndex:s?0:-1,isRestoring:!1,replayStartIndex:t,timeline:s?[_s({sectionId:e.sectionId,lineId:e.lineId})]:[]}},zr=(e,t={})=>{if(e?.rollback)return Kp(e.rollback),Array.isArray(e.rollback.timeline)||(e.rollback.timeline=[]),typeof e.rollback.currentIndex!="number"&&(e.rollback.currentIndex=e.rollback.timeline.length>0?e.rollback.timeline.length-1:-1),typeof e.rollback.isRestoring!="boolean"&&(e.rollback.isRestoring=!1),typeof e.rollback.replayStartIndex!="number"&&(e.rollback.replayStartIndex=0),e.rollback;let s=e?.pointers?.read;return e.rollback=bn({pointer:s,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},Ts=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return;let i=zr(s);if(i.isRestoring)return;let a=Na(s);i.currentIndex<i.timeline.length-1&&(i.timeline=i.timeline.slice(0,i.currentIndex+1)),i.timeline.push(_s(t)),i.currentIndex=i.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,i.currentIndex),a.checkpointLengths.push(a.currentLength))},Hw=({state:e})=>{let s=e.contexts?.[e.contexts.length-1]?.rollback;return!Array.isArray(s?.timeline)||typeof s.currentIndex!="number"?null:{checkpointIndex:s.currentIndex,checkpoint:s.timeline[s.currentIndex]??null}},Kw=({state:e},t={})=>{let{checkpointIndex:s,checkpointIdentity:i,sectionId:a,lineId:r}=t,o=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(s)||!Array.isArray(o?.timeline)||typeof o.currentIndex!="number")return e;let l=o.timeline[s];return(Ie(l)?Yn(l):l)!==i||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},Ww=({state:e},t={})=>{let{slotId:s,saveSlotIdentity:i,checkpointIndex:a,sectionId:r,lineId:n}=t,o=ft(s),l=e.global.saveSlots?.[o],c=Ie(l)?Yn(l):l;if(!l||c!==i)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,m=p?.rollback,d=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==n||d?.sectionId!==r||d?.lineId!==n||(d.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Wp=(e,t)=>{let s=e.contexts?.[e.contexts.length-1],i=s?.rollback;if(!i||i.isRestoring||!Array.isArray(i.timeline)||typeof i.currentIndex!="number")return null;let a=t?.at(-1),r=typeof a?.checkpointIndex=="number"?a.checkpointIndex:i.currentIndex;if(r<0||r>=i.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&r<i.timeline.length-1){i.timeline=i.timeline.slice(0,r+1);let n=Na(s);n&&(n.checkpointLengths=n.checkpointLengths.slice(0,r+1))}return i.timeline[r]??null},Jw=({state:e,rollbackActionBatchStack:t,playbackOwnership:s},i={})=>{let a=i?.source===Nt?Nt:Fr,r=e.contexts?.[e.contexts.length-1],n=r?.rollback;if(!n||n.isRestoring||!Array.isArray(n.timeline)||typeof n.currentIndex!="number"||n.currentIndex<0||n.currentIndex>=n.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(n.currentIndex<n.timeline.length-1){n.timeline=n.timeline.slice(0,n.currentIndex+1);let u=Na(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,n.currentIndex+1))}let o=r?.pointers?.read,l=s?.lineEntryId,c=a===Nt&&(s?.rollbackCheckpointLineEntryId===void 0?n.timeline[n.currentIndex]?.sectionId===o?.sectionId&&n.timeline[n.currentIndex]?.lineId===o?.lineId:s.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:n.currentIndex,source:a,...a===Nt?{lineEntryId:l,sourcePointer:o?{sectionId:o.sectionId,lineId:o.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},Qw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),Zw=({state:e,rollbackActionBatchStack:t,playbackOwnership:s})=>{let i=t?.at(-1);if(i?.source!==Nt||i.hasTrackedLineEntryCheckpoint)return e;let a=i.sourcePointer;if(!a)return e;Ts(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let n=(e.contexts?.at(-1)).rollback;return i.checkpointIndex=n.currentIndex,i.hasTrackedLineEntryCheckpoint=!0,s?.lineEntryId===i.lineEntryId&&(s.rollbackCheckpointLineEntryId=i.lineEntryId),e},eI=({state:e,rollbackActionBatchStack:t},s)=>{if(t?.at(-1)?.source!==Nt)return e;if(typeof s?.path!="string"||s.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(s.ordinal)||s.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=cs(s.result,s.type),r=Wp(e,t);if(!r)return e;if(r.randomOutcomeVersion!==Sr&&(r.randomOutcomeVersion=Sr,r.randomOutcomes=[]),r.randomOutcomes.some(({path:n,ordinal:o})=>n===s.path&&o===s.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${s.path}#${s.ordinal}`);return r.randomOutcomes.push({path:s.path,ordinal:s.ordinal,type:s.type,result:a}),e},ur=(e,t,s,i)=>{let r=i?.at(-1)?.source??Fr;if(!sk(t,r))return;let n=Wp(e,i);n&&(Array.isArray(n.executedActions)||(n.executedActions=[]),n.executedActions.push({type:t,payload:B(s)}))},ga=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return;let i=t?.operations??[];for(let{variableId:a,op:r,value:n,roundTo:o}of i){let l=L(e.projectData.resources?.variables,a),c=l?.scope,u=l?.type;if(Ne(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);tn(c,a),nn(u,r,a),is(u,r,n,a,{roundTo:o}),c==="context"&&(s.variables[a]=os(s.variables[a],r,n,{roundTo:o}))}},rI=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:s,payload:i})=>{ik(e,s,i)})},tI=(e,t)=>{let{sectionId:s,lineId:i}=t,n=Ve({state:e},{sectionId:s})?.lines?.find(o=>o.id===i)?.actions;n&&el(e,n,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},Jp=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return e;let i=zr(s),a=i.timeline[t];if(!a)return e;e.global.autoMode&&Pn({state:e}),e.global.skipMode&&Ur({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),i.isRestoring=!0,i.currentIndex=t;try{s.variables=La(e.projectData),s.kind==="sceneReplay"&&(Gp(e,s),s.sceneReplay.finishOnNextAdvance=!1,s.sceneReplay.exitOnLineCompleted=!1),delete s.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=B($s),e.global.overlayStack=[],Dt(e),Lt(e),e.global.isLineCompleted=!0;let r=i.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&$a(e),tI(e,i.timeline[l]),rI(e,i.timeline[l]);let n=Mt(s);n.read={sectionId:a.sectionId,lineId:a.lineId};let o=_a(s);o&&(o.currentLength=Math.min(o.checkpointLengths[t]??0,o.entries.length)),s.kind==="sceneReplay"&&(s.sceneReplay.entryId=Ep(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{i.isRestoring=!1}return e},nI=e=>{let{projectData:t}=e,s=e.initialAudioCommandId??0;if(!Number.isSafeInteger(s)||s<0)throw new Error("Internal initial audio command counter is invalid");let i=e.global??{},{saveSlots:a={},variables:r={},runtime:n={},accountViewedRegistry:o={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=i;_p(t),Qt(t),Zt(t),en(t),nt(t?.resources?.variables??{});let u=t.story.initialSceneId,p=L(t.story.scenes,u),m=p.initialSectionId,d=L(p.sections,m),f={sceneId:u,sectionId:m,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:h}=ss(t),g={...h,...rn(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Iw(o,"accountViewedRegistry"),accountReplayRegistry:vw(l),nextLineConfig:wn(),imageGalleryNavigation:Ea(),sceneReplayNavigation:Ra(),sceneReplayEntryId:0,audioCommandId:s,musicRoomPlayer:Ns(),saveSlots:yw(a),localizationPackages:B(c),overlayStack:[],variables:g,...Vw({projectData:t,loadedGlobalRuntime:n})},contexts:[Va({pointer:f,projectData:t})]}},sI=({state:e})=>e.global.overlayStack||[],iI=({state:e})=>e.global.pendingEffects,Qp=({state:e})=>e.global.skipMode,oI=({state:e})=>e.global.autoMode,Zp=({state:e})=>e.global.dialogueUIHidden,Ip=new WeakMap,aI=8,ef=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],s=t[t.length-1];if(!s)return[];let i,a=U(s.dialogueHistory)&&Array.isArray(s.dialogueHistory.entries)&&Number.isInteger(s.dialogueHistory.currentLength);if(a)i=s.dialogueHistory.entries.slice(0,s.dialogueHistory.currentLength);else{let{sectionId:p,lineId:m}=s.pointers.read,d=Ve({state:e},{sectionId:p});if(!d?.lines||!Array.isArray(d.lines))return[];let f=Fe(d.lines,m);i=d.lines.slice(0,f+1).map(h=>({sectionId:p,lineId:h.id}))}let r=[],n=Pt({variables:{...e.global?.variables??{},...Yr(e)?.variables??{}},runtime:kr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),o=Ie(e.projectData)?Ge(e.projectData):e.projectData,l=Object.isFrozen(o)?Ip.get(o):void 0;l||(l=new Map,Object.isFrozen(o)&&Ip.set(o,l));let c=new Map(l),u=p=>{let m=c.get(p.sectionId);if(!m){let{section:h}=Qe(o,p.sectionId);m={lines:Array.isArray(h?.lines)?h.lines:[],projections:new Map,nextLineIndex:0,presentationState:{}},c.set(p.sectionId,m)}if(l.delete(p.sectionId),l.set(p.sectionId,m),l.size>aI&&l.delete(l.keys().next().value),m.projections.has(p.lineId))return m.projections.get(p.lineId);let d=Fe(m.lines,p.lineId);if(d<0)return null;let f=m.lines[d].actions||{};if(!f.dialogue)return m.projections.set(p.lineId,null),null;for(;m.nextLineIndex<=d;){let h=m.lines[m.nextLineIndex],g=m.nextLineIndex===d?f:h.actions||{};m.presentationState=it([m.presentationState,g],{resources:o.resources});let y=m.presentationState.dialogue||{};m.projections.set(h.id,g.dialogue?{line:h,lineActions:g,dialogueState:{characterId:y.characterId,character:y.character,...g.dialogue.append===!0?{content:y.content}:{}}}:null),m.nextLineIndex+=1}return m.projections.get(p.lineId)??null};for(let p of i){if(!uw(p))continue;let m=u(p);if(!m)continue;let{line:d,lineActions:f,dialogueState:h}=m;if(!f.dialogue)continue;let g=ns({characterId:h.characterId,character:h.character,characters:e.projectData.resources?.characters??{},variables:n}),y=cw({sectionId:p.sectionId,lineId:d.id,content:f.dialogue.append===!0?h.content:f.dialogue.content,dialogueState:h,characterName:g}),b=r[r.length-1];if((a?p.appendToPrevious===!0:f.dialogue.append===!0)&&b?.sectionId===p.sectionId){r[r.length-1]={...r[r.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}r.push(y)}return r},lI=(e,t,s)=>{let i=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:n,sectionId:o,lineId:l}=a,c=e.global.saveSlots?.[ft(r)],u=Ie(c)?Yn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==n||p?.pointers?.read?.sectionId!==o||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=B(s),i=!0)}i&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},cI=({state:e},t={})=>{let s=Yr(e),i=s?.pointers?.read,a=kn({state:e});if(!s||!U(a?.actions?.dialogue))return e;let r=zr(s),n=r.timeline?.[r.currentIndex],o=n?.sectionId===i?.sectionId&&n?.lineId===i?.lineId,l=_a(s),c=l?.checkpointLengths?.[r.currentIndex],u=r.currentIndex>0?l?.checkpointLengths?.[r.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(t.reuseExistingOccurrence===!0&&p?.sectionId===i.sectionId&&p?.lineId===i.lineId||t.forceNewOccurrence!==!0&&o&&l&&c===l.currentLength&&c>u&&p?.sectionId===i.sectionId&&p?.lineId===i.lineId)return e;let m=pw(s);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&qp(e.projectData,p,i);if(m.entries.push({sectionId:i.sectionId,lineId:i.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,o){for(;m.checkpointLengths.length<r.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[r.currentIndex]=m.currentLength}return lI(e,t.savedCheckpointOccurrences,m),e},uI=({state:e})=>e.global.confirmDialog??null,vn=({state:e},{pointer:t}={})=>{let s=t??Be({state:e})?.pointer,i=Da({state:e,pointer:s});return Mw({state:e,form:i.form,pointer:s})},pI=({state:e},{pointer:t}={})=>!!vn({state:e},{pointer:t}),Re=({state:e},{pointer:t}={})=>{let s=vn({state:e},{pointer:t});if(s)return{source:Br,formId:s.id,formKey:s.key};let i=af({state:e,pointer:t});return i?{source:jt,resourceId:i}:null},fI=({state:e,registry:t},s)=>{let{sectionId:i,lineId:a}=s,n=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===i);if(!n)return!1;if(n.lastLineId===void 0||a===void 0)return!0;let o=Ve({state:e},{sectionId:i});if(!o||!o.lines||!Array.isArray(o.lines))return n.lastLineId===a;let l=Fe(o.lines,n.lastLineId),c=Fe(o.lines,a);return l===-1||c===-1?n.lastLineId===a:c<=l},qa=({registry:e},t)=>{let{resourceId:s}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===s)},Fa=({state:e},t)=>fI({state:e,registry:e.global.accountViewedRegistry},t),dI=({state:e},t)=>qa({registry:e.global.accountViewedRegistry},t),gn=(e,t)=>!qa({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Ba=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Ua=(e,t)=>{let s=Ba(e);if(s===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),s-1)},ba=(e,t,s,i)=>{for(let a=s+i;a>=0&&a<t.length;a+=i)if(!gn(e,t[a]))return t[a]},mI=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:B(t)},rf=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let s=e.global.imageGalleryNavigation??Ea(),i=Ba(t),a=Ua(t,s),r=a*t.pageSize,n=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:gn(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:gn(e,c)}))})),o=null;if(typeof s.groupId=="string"&&typeof s.variantId=="string"){let l=t.groups.findIndex(d=>d.id===s.groupId),c=t.groups[l],u=c?.variants.findIndex(d=>d.id===s.variantId),p=u===void 0||u<0?void 0:c.variants[u],m=l<0?-1:Math.floor(l/t.pageSize);p&&m===a&&!gn(e,p)&&(o={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:ba(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:ba(e,c.variants,u,1)!==void 0})}return{pageGroups:n,selection:o,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},Ya=(e,t)=>!qa({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),za=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Xa=(e,t)=>{let s=za(e);if(s===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),s-1)},wa=(e,t,s,i)=>{for(let a=s+i;a>=0&&a<t.length;a+=i)if(!Ya(e,t[a]))return t[a]},tf=e=>({trackId:e.id,soundId:e.soundId,title:e.title,artist:e.artist??null,album:e.album??null,description:e.description??null,coverImageId:e.coverImageId??null}),yI=(e,t)=>({...tf(t),locked:Ya(e,t)}),vp=e=>{let t=Math.floor(e/1e3),s=t%60,i=Math.floor(t/60);if(i<60)return`${i}:${String(s).padStart(2,"0")}`;let a=Math.floor(i/60),r=i%60;return`${a}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`},hI=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:B(t)},nf=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let s=e.global.musicRoomPlayer??Ns(),i=za(t),a=Xa(t,s),r=a*t.pageSize,n=t.tracks.slice(r,r+t.pageSize).map(u=>yI(e,u)),o=t.tracks.findIndex(u=>u.id===s.trackId),l=t.tracks[o],c=l?{...tf(l),canPlayPreviousTrack:wa(e,t.tracks,o,-1)!==void 0,canPlayNextTrack:wa(e,t.tracks,o,1)!==void 0}:null;return{pageTracks:n,selection:c,playback:c?{status:s.status,readiness:s.readiness,positionMs:s.positionMs,durationMs:s.durationMs,positionText:vp(s.positionMs),durationText:s.durationMs===null?null:vp(s.durationMs),canPlay:s.status!=="playing",canPause:s.status==="playing",canSeek:s.readiness==="ready"&&s.durationMs!==null}:null,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},Ga=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Ha=(e,t)=>{let s=Ga(e);if(s===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),s-1)},gI=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:B(t)},bI=({state:e})=>be(e)!==null,wI=({state:e})=>{let t=be(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},sf=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,of=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let s=e.global.sceneReplayNavigation??Ra(),i=Ga(t),a=Ha(t,s),r=a*t.pageSize,n=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!sf(e,l.sceneId)})),o=be(e);return{isActive:o!==null,activeSceneId:o?.sceneReplay.sceneId??null,pageReplays:n,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},II=({state:e})=>e.global.nextLineConfig,af=({state:e,pointer:t}={})=>{let s=t??Be({state:e})?.pointer;if(!s)return;let i=s?.sectionId,a=s?.lineId,n=Ve({state:e},{sectionId:i})?.lines||[],o=Fe(n,a);if(!(o<0))for(let l=o;l>=0;l-=1){let c=n[l]?.actions;if(!c||!Object.prototype.hasOwnProperty.call(c,"choice"))return;let u=c.choice;if(u?.resourceId)return u.resourceId;if(!u?.animations||c.cleanAll)return}},lf=({state:e})=>!!af({state:e}),vI=({state:e})=>structuredClone(e),kI=({state:e})=>B({audioEffects:e.projectData?.resources?.audioEffects??{},sounds:e.projectData?.resources?.sounds??{}}),AI=({state:e})=>{let t=kr(e);return{runtime:t,musicRoomPlayer:B(e.global.musicRoomPlayer),skipTransitionsAndAnimations:t.skipTransitionsAndAnimations===!0||mf(e)}},PI=({state:e},{sectionId:t})=>Qe(e.projectData,t).sceneId,xI=({state:e})=>B(e.projectData.resources?.achievements??{}),EI=({state:e},t)=>{let s=L(e.projectData.resources?.achievements,t?.resourceId);return s===void 0?void 0:B(s)},cf=({state:e})=>e.global.saveSlots,SI=({state:e},t)=>{let s=t?.slotId,i=ft(s);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0},uf=({state:e})=>B(e.global.localizationPackages),Ka=({state:e})=>kr(e),OI=({state:e},t)=>ar(e,t?.runtimeId),Wa=({state:e})=>{let t={...e.global?.variables??{},...Yr(e)?.variables??{}};return Pt({variables:t,runtime:kr(e),variableConfigs:e.projectData.resources?.variables??{}})},Be=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],s=t[t.length-1];if(s)return{currentPointerMode:"read",pointer:s.pointers?.read}},Ve=({state:e},t)=>{let{sectionId:s}=t;return Qe(e.projectData,s).section},kn=({state:e})=>{let t=Be({state:e});if(!t?.pointer)return;let{sectionId:s,lineId:i}=t.pointer,a=Ve({state:e},{sectionId:s});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines[Fe(a.lines,i)]},pf=({state:e})=>Da({state:e,pointer:Be({state:e}).pointer}),ff=e=>{let t=kn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let s=kr(e),i=Pt({variables:{...e.global?.variables??{},...Yr(e)?.variables??{}},runtime:s,variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(a=>`${St(a?.text,{variables:i,runtime:s})??""}`).join("")},Or=({state:e})=>ma({text:ff(e),baseDelay:ar(e,"autoForwardDelay"),speed:ar(e,"autoForwardSpeed")}),RI=({state:e})=>{let t=df({state:e}),i=kn({state:e})?.actions??{},a=it([t??{},i],{resources:e.projectData.resources});return xo(t??{},a??{})},$I=({state:e},{sectionId:t})=>{let s=Ve({state:e},{sectionId:t});if(!s?.lines)return[];let i=[],a={};for(let r of s.lines){let n=r.actions||{},o=it([a,n],{resources:e.projectData.resources}),l=xo(a,o);i.push({id:r.id,changes:l,presentationState:o}),a=Eo(o)}return i},CI=({state:e},{sectionId:t,includePresentationState:s=!1})=>{let i=$I({state:e},{sectionId:t});return s?{lines:i}:{lines:i.map(({presentationState:a,...r})=>r)}},df=({state:e})=>{let t=Da({state:e,pointer:Be({state:e}).pointer},-1);return t===null?null:Eo(t)},Ja=({state:e},{slotsPerPage:t=xp}={})=>{let a=((Ka({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let n=0;n<t;n++){let o=a+n,l=e.global.saveSlots&&e.global.saveSlots[ft(o)]||{};r.push({...l,slotId:o})}return{saveSlots:r}},_I=cf,NI=Ja,mf=e=>{let s=e.contexts?.[e.contexts.length-1]?.rollback;return!s||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"?!1:s.currentIndex>=0&&s.currentIndex<s.timeline.length-1},jI=(e,t)=>{let s=e.projectData.resources?.layouts??{},a=[...[...e.global.overlayStack??[]].reverse().map(r=>r?.resourceId),t.layout?.resourceId];for(let r of a){if(typeof r!="string"||!Object.prototype.hasOwnProperty.call(s,r))continue;let n=s[r]?.paginationSize;if(Number.isInteger(n)&&n>0)return n}return xp},TI=({state:e},t={})=>{let s=pf({state:e}),i=df({state:e}),a=kn({state:e})?.actions??{},r=e.global.pendingScreenTransition,n=r?.animations?{...a,screen:B(r)}:a,o=r?.animations&&i===null?{}:i,{sectionId:l}=Be({state:e}).pointer,{sceneId:c}=Qe(e.projectData,l),u={...Ka({state:e}),localizationPackages:uf({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],d=vn({state:e}),f=lf({state:e}),h=rf({state:e}),g=nf({state:e}),y=of({state:e}),b=Wa({state:e}),{saveSlots:w}=Ja({state:e},{slotsPerPage:jI(e,s)}),A=mf(e);return zu({presentationState:s,previousBgmRender:t?.previousBgmRender,previousPresentationState:o,currentLineActions:n,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:f,isFormVisible:!!d,canRollback:Lf({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||A,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:ef({state:e}),saveSlots:w,variables:b,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:h,musicRoom:g,sceneReplay:y,musicRoomPlayer:B(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},DI=({state:e},t)=>(e.global.confirmDialog=Cw(t),e.global.pendingEffects.push({name:"render"}),e),LI=({state:e})=>(e.global.confirmDialog&&(Dt(e),e.global.pendingEffects.push({name:"render"})),e),MI=({state:e,rollbackActionBatchStack:t},s)=>(e.global.overlayStack.push(s),e.global.pendingEffects.push({name:"render"}),ur(e,"pushOverlay",s,t),e),VI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),ur(e,"popOverlay",void 0,t),e),qI=({state:e,rollbackActionBatchStack:t},s)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=s),e.global.pendingEffects.push({name:"render"}),ur(e,"replaceLastOverlay",s,t),e),FI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],Dt(e),Lt(e),e.global.pendingEffects.push({name:"render"}),ur(e,"clearOverlays",void 0,t),e),BI=(e,{activeInteraction:t})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),t&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},An=(e,t,{screenTransition:s}={})=>{e.global.isLineCompleted=!1,Nw(e,s),Lt(e);let i=Re({state:e},{pointer:t}),a=i?.source===jt,r=i?.source===Br;BI(e,{activeInteraction:i});let n=be(e),o={name:"handleLineActions"};if(typeof n?.sceneReplay?.sceneId=="string"){let l=Ep(e);n.sceneReplay.entryId=l,o.payload={sceneReplaySceneId:n.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(o),{isChoiceVisible:a,isFormVisible:r,activeInteraction:i}},Ds=(e,t,s)=>{!(t?.source===jt||t?.source===Br)||s||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},yf=({state:e})=>(Re({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),Pn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),UI=({state:e})=>{let t=e.global.autoMode;return Re({state:e})&&!t||(t?Pn({state:e}):yf({state:e})),e},hf=({state:e})=>(Re({state:e})||(e.global.autoMode&&(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"})),e.global.skipMode=!0,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.pendingEffects.push({name:"render"})),e),Ur=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),YI=({state:e})=>{let t=Qp({state:e});return Re({state:e})&&!t||(t?Ur({state:e}):hf({state:e})),e},Ls=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),ur(e,"showDialogueUI",void 0,t),e),gf=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),ur(e,"hideDialogueUI",void 0,t),e),zI=e=>{let{state:t}=e;return Zp({state:t})?Ls(e):gf(e),t},Xr=(e,t,s)=>(Ma(e,t,s),Hp(e),e.global.pendingEffects.push({name:"render"}),e),xn=(e,t,s,i,a)=>{let r=Ma(e,t,s);return e.global.pendingEffects.push({name:"render"}),ur(e,i,{value:r},a),e},XI=({state:e},t)=>Xr(e,"dialogueTextSpeed",t?.value),GI=({state:e},t)=>(Xr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Re({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e),HI=({state:e},t)=>(Xr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Re({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e),KI=({state:e},t)=>Xr(e,"skipUnseenText",t?.value),WI=({state:e},t)=>Xr(e,"skipTransitionsAndAnimations",t?.value),JI=({state:e},t)=>Xr(e,"soundVolume",t?.value),QI=({state:e},t)=>Xr(e,"musicVolume",t?.value),ZI=({state:e},t)=>Xr(e,"muteAll",t?.value),Ia=({state:e,rollbackActionBatchStack:t},s)=>xn(e,"saveLoadPagination",s?.value,"setSaveLoadPagination",t),va=({state:e,rollbackActionBatchStack:t})=>{let s=ar(e,"saveLoadPagination")+1;return xn(e,"saveLoadPagination",s,"incrementSaveLoadPagination",t),e},ka=({state:e,rollbackActionBatchStack:t})=>{let s=ar(e,"saveLoadPagination")-1;return xn(e,"saveLoadPagination",s,"decrementSaveLoadPagination",t),e},Aa=({state:e,rollbackActionBatchStack:t},s)=>xn(e,"menuPage",s?.value,"setMenuPage",t),Pa=({state:e,rollbackActionBatchStack:t},s)=>xn(e,"menuEntryPoint",s?.value,"setMenuEntryPoint",t),ev=({state:e})=>(e.global.pendingEffects=[],e),rv=({state:e},t)=>(e.global.pendingEffects.push(t),e),tv=({state:e},t)=>{if(be(e))return e;let s=t?.resourceId;return Sp(e,s),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:s}}),e},nv=({state:e},t)=>{if(be(e))return e;let s=t?.resourceId,i=Sp(e,s);if(i.type!=="number")throw new Error(`Achievement resource "${s}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${s}" must be a non-negative integer`);if(!Number.isInteger(i.target)||i.target<1)throw new Error(`Achievement resource "${s}" must have a positive integer target`);let r=Math.min(a,i.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:s,current:r,target:i.target,completed:r>=i.target}}),e},bf=e=>e?.lines?.[0],wf=(e,{sectionId:t,resetStoryState:s=!1,screen:i})=>{let a=!!Bp(i),r=Ve({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let n=bf(r);if(!n)return console.warn(`Section ${t} has no lines`),e;if(s&&!Xw(e,{queueRender:!a}))return e;let o=Re({state:e});s&&e.global.skipMode&&Ur({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=Mt(l),p=u.read;s||pt(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||zr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:n.id},s?l.rollback=bn({pointer:u.read}):Ts(e,{sectionId:t,lineId:n.id})}let{activeInteraction:c}=An(e,l?.pointers?.read,{screenTransition:i});return Ds(e,o,c),e},sv=({state:e},t)=>{if(be(e))throw new Error("Cannot reset the story while a scene replay is active");return wf(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},If=e=>(e.global.accountViewedRegistry=ow(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Ms=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(s=>({scope:s.scope,path:s.path,op:s.op,value:B(s.value)}))}})},vf=(e,t)=>{Ms(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(s=>({sectionId:s.sectionId,...s.lastLineId===void 0?{}:{lineId:s.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},iv=(e,t,{sectionId:s,lineId:i})=>{if(!s||!i)return!1;let a=U(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(n=>n.sectionId===s);if(r){if(r.lastLineId===void 0)return!1;let n=Ve({state:e},{sectionId:s});if(n?.lines){let o=Fe(n.lines,r.lastLineId),l=Fe(n.lines,i);if(o===-1||l>o)return r.lastLineId===i?!1:(r.lastLineId=i,!0)}else return r.lastLineId===i?!1:(r.lastLineId=i,!0);return!1}else return a.sections.push({sectionId:s,lastLineId:i}),!0},pt=(e,t)=>{if(be(e)||e.global.accountViewedRegistry===void 0)return;iv(e,If(e),t)&&vf(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},ov=({state:e},t)=>(pt(e,t),e.global.pendingEffects.push({name:"render"}),e),av=({state:e},t)=>{if(be(e))return e;let{resourceId:s}=t;if(e.global.accountViewedRegistry!==void 0){let i=If(e);i.resources.find(r=>r.resourceId===s)||(i.resources.push({resourceId:s}),vf(e,{sections:[],resources:[{resourceId:s}]}))}return e.global.pendingEffects.push({name:"render"}),e},pr=(e,t,s)=>{if(!U(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(i=>{if(!s.has(i))throw new Error(`${e} payload contains unsupported property "${i}"`)})},xa=(e,t,s)=>{if(typeof s!="string"||s.length===0)throw new Error(`${e} requires a non-empty ${t}`)},Vs=(e,t)=>{let s=e.global.imageGalleryNavigation;s.groupId===t.groupId&&s.variantId===t.variantId&&s.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},lv=({state:e},t)=>{let s="showImageGalleryVariant";pr(s,t,Z0),xa(s,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&xa(s,"variantId",t.variantId);let i=e.projectData?.resources?.imageGallery;if(i===void 0)return e;let a=i.groups.findIndex(o=>o.id===t.groupId),r=i.groups[a];if(!r)return e;let n=t.variantId===void 0?r.variants[0]:r.variants.find(o=>o.id===t.variantId);return!n||gn(e,n)||Vs(e,{groupId:r.id,variantId:n.id,pageIndex:Math.floor(a/i.pageSize)}),e},kf=(e,t,s,i)=>{pr(i,t,Sa);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let r=e.global.imageGalleryNavigation;if(typeof r.groupId!="string"||typeof r.variantId!="string")return e;let n=a.groups.find(c=>c.id===r.groupId),o=n?.variants.findIndex(c=>c.id===r.variantId);if(!n||o===void 0||o<0)return e;let l=ba(e,n.variants,o,s);return l&&Vs(e,{...r,variantId:l.id}),e},cv=({state:e},t)=>kf(e,t,-1,"moveToPreviousImageGalleryVariant"),uv=({state:e},t)=>kf(e,t,1,"moveToNextImageGalleryVariant"),pv=({state:e},t)=>{if(pr("clearImageGallerySelection",t,Sa),e.projectData?.resources?.imageGallery===void 0)return e;let i=e.global.imageGalleryNavigation;return Vs(e,{groupId:null,variantId:null,pageIndex:i.pageIndex}),e},Af=(e,t)=>{let s=e.projectData?.resources?.imageGallery;if(s===void 0)return e;let i=Ba(s);if(t>=i)return e;let a=e.global.imageGalleryNavigation,r=Ua(s,a);return t===r||Vs(e,{groupId:null,variantId:null,pageIndex:t}),e},fv=({state:e},t)=>{if(pr("moveToImageGalleryPage",t,ew),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Af(e,t.pageIndex)},Pf=(e,t,s,i)=>{pr(i,t,Sa);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let n=Ua(a,e.global.imageGalleryNavigation)+s;return n<0?e:Af(e,n)},dv=({state:e},t)=>Pf(e,t,1,"moveToNextImageGalleryPage"),mv=({state:e},t)=>Pf(e,t,-1,"moveToPreviousImageGalleryPage"),Rr=(e,t,s)=>{if(!U(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(i=>{if(!s.has(i))throw new Error(`${e} payload contains unsupported property "${i}"`)})},yv=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},sr=e=>{e.global.pendingEffects.push({name:"render"})},xf=(e,t)=>{let s=e.projectData.resources.musicRoom,i=e.global.musicRoomPlayer,a=i.trackId!==null,r=i.trackId===t.id,n=i.bgmPlayback;a||(n={commandId:js(e),operation:"pause"});let o=In(e,"play",0),l=s.tracks.indexOf(t),c=r?i.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/s.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:o,seekFallback:null,bgmPlayback:n},sr(e)},hv=({state:e},t)=>{let s="playMusicRoomTrack";Rr(s,t,rw),yv(s,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Ya(e,a)||xf(e,a),e},gv=({state:e},t)=>{Rr("playMusicRoom",t,Tt);let i=e.global.musicRoomPlayer;if(i.trackId===null||i.status==="playing")return e;let a=i.status==="ended",r=i.readiness==="error",n=i.status==="paused"&&!r?"resume":"play",o=a?0:i.positionMs;return i.playback=In(e,n,n==="play"?o:void 0),i.seekFallback=null,i.status="playing",i.positionMs=o,r&&(i.readiness=i.durationMs===null?"loading":"ready"),sr(e),e},bv=({state:e},t)=>{Rr("pauseMusicRoom",t,Tt);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status!=="playing"||(i.playback=In(e,"pause"),i.seekFallback=null,i.status="paused",sr(e)),e},wv=({state:e},t)=>{Rr("stopMusicRoom",t,Tt);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status==="stopped"&&i.positionMs===0||(i.playback=In(e,"stop"),i.seekFallback=null,i.status="stopped",i.positionMs=0,sr(e)),e},Iv=({state:e},t)=>{if(Rr("seekMusicRoom",t,tw),typeof t.positionMs!="number"||!Number.isFinite(t.positionMs)||t.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let i=e.global.musicRoomPlayer;if(i.trackId===null||i.readiness!=="ready"||i.durationMs===null||t.positionMs>i.durationMs)return e;let a=In(e,"seek",t.positionMs);return i.seekFallback={commandId:a.commandId,status:i.status,positionMs:i.positionMs},i.playback=a,i.positionMs=t.positionMs,t.positionMs===i.durationMs?i.status="ended":i.status==="ended"&&(i.status="stopped"),sr(e),e},Ef=(e,t,s,i)=>{Rr(i,t,Tt);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let n=a.tracks.findIndex(l=>l.id===r.trackId);if(n<0)return e;let o=wa(e,a.tracks,n,s);return o&&xf(e,o),e},vv=({state:e},t)=>Ef(e,t,-1,"playPreviousMusicRoomTrack"),kv=({state:e},t)=>Ef(e,t,1,"playNextMusicRoomTrack"),Av=({state:e},t)=>{Rr("clearMusicRoomSelection",t,Tt);let i=e.global.musicRoomPlayer;if(i.trackId===null)return e;let a=i.pageIndex,r={commandId:js(e),operation:"resume"};return e.global.musicRoomPlayer={...Ns({bgmPlayback:r}),pageIndex:a},sr(e),e},Sf=(e,t)=>{let s=e.projectData?.resources?.musicRoom;if(!s||t>=za(s))return e;let i=e.global.musicRoomPlayer,a=Xa(s,i);return t===a||(i.pageIndex=t,sr(e)),e},Pv=({state:e},t)=>{if(Rr("moveToMusicRoomPage",t,nw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Sf(e,t.pageIndex)},Of=(e,t,s,i)=>{Rr(i,t,Tt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Xa(a,e.global.musicRoomPlayer)+s;return r<0?e:Sf(e,r)},xv=({state:e},t)=>Of(e,t,1,"moveToNextMusicRoomPage"),Ev=({state:e},t)=>Of(e,t,-1,"moveToPreviousMusicRoomPage"),ut=e=>{let t=be(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let s=B(t.sceneReplay.returnState),i=t.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==i),e.contexts.pop(),Uw(e,s),e.global.pendingEffects.push({name:"render"}),!0},Sv=({state:e},t)=>{let s="startSceneReplay";if(pr(s,t,sw),xa(s,"sceneId",t.sceneId),be(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!sf(e,a.sceneId))return e;let r=L(e.projectData.story.scenes,a.sceneId),n=r?.initialSectionId,o=L(r?.sections,n),l=o?.initialLineId??o?.lines?.[0]?.id;if(!o||!l||!o.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=Fw(e);Bw(e);let u=Va({pointer:{sceneId:a.sceneId,sectionId:n,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:c}});return Gp(e,u),e.contexts.push(u),An(e,u.pointers.read),e},Rf=({state:e},t)=>{pr("finishSceneReplay",t,Oa);let i=be(e);if(i)return i.sceneReplay.finishOnNextAdvance=!0,e;if(Yr(e)?.rollback?.isRestoring===!0)return e;let r=Be({state:e})?.pointer,{sceneId:n}=Qe(e.projectData,r?.sectionId);return!(typeof n=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===n))||(e.global.accountReplayRegistry=aw(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(n))||(e.global.accountReplayRegistry.sceneIds.push(n),Ms(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[n]}}]),e.global.pendingEffects.push({name:"render"})),e},Ov=({state:e},t)=>(pr("exitSceneReplay",t,Oa),ut(e),e),$f=(e,t)=>{let s=e.projectData?.resources?.sceneReplay;if(!s||t>=Ga(s))return e;let i=Ha(s,e.global.sceneReplayNavigation);return t===i||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},Rv=({state:e},t)=>{if(pr("moveToSceneReplayPage",t,iw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return $f(e,t.pageIndex)},Cf=(e,t,s,i)=>{pr(i,t,Oa);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Ha(a,e.global.sceneReplayNavigation)+s;return r<0?e:$f(e,r)},$v=({state:e},t)=>Cf(e,t,1,"moveToNextSceneReplayPage"),Cv=({state:e},t)=>Cf(e,t,-1,"moveToPreviousSceneReplayPage"),qs=(e,t)=>{let s=e.global.musicRoomPlayer;return!U(t)||t.id!==J0||s.trackId===null||!s.playback||t.commandId!==s.playback.commandId?null:s},Qa=e=>typeof e.positionMs=="number"&&Number.isFinite(e.positionMs)&&e.positionMs>=0&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>0&&e.positionMs<=e.durationMs,_f=(e,t,s,{readiness:i=t.readiness}={})=>((t.readiness!==i||t.positionMs!==s.positionMs||t.durationMs!==s.durationMs||t.seekFallback!==null)&&(t.readiness=i,t.positionMs=s.positionMs,t.durationMs=s.durationMs,t.seekFallback=null,sr(e)),e),_v=({state:e},t)=>{let s=qs(e,t);return!s||s.readiness!=="loading"||!Qa(t)?e:_f(e,s,t,{readiness:"ready"})},Nv=({state:e},t)=>{let s=qs(e,t);return!s||s.readiness!=="ready"||!Qa(t)||s.status==="stopped"&&t.positionMs!==0||s.status==="ended"&&t.positionMs!==t.durationMs?e:_f(e,s,t)},jv=({state:e},t)=>{let s=qs(e,t);return!s||s.readiness!=="ready"||s.status!=="playing"||!Qa(t)||t.positionMs!==t.durationMs||(s.status="ended",s.positionMs=t.positionMs,s.durationMs=t.durationMs,s.seekFallback=null,sr(e)),e},Tv=({state:e},t)=>{let s=qs(e,t);if(!s||typeof t.errorCode!="string"||!Q0.has(t.errorCode)||s.readiness==="error"&&s.status==="stopped")return e;if(t.errorCode==="invalid-position"){let i=s.seekFallback;if(s.playback.operation!=="seek"||i?.commandId!==t.commandId)return e;let a=s.status!==i.status||s.positionMs!==i.positionMs;return s.status=i.status,s.positionMs=i.positionMs,s.seekFallback=null,a&&sr(e),e}return s.readiness="error",s.status="stopped",s.positionMs=0,s.seekFallback=null,sr(e),e},Nf=({state:e,rollbackActionBatchStack:t},s)=>{let i=dw(s.manual),{auto:a,applyMode:r}=s,n=e.global.nextLineConfig.auto?.enabled,o=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;i&&a?(e.global.nextLineConfig={manual:i,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(i&&(e.global.nextLineConfig.manual=i),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,f=Re({state:e});return!u&&(a!==void 0&&(p!==n||m!==o||d!==l))&&(!f&&p===!0&&(m==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:d}}):n===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),ur(e,"setNextLineConfig",s,t),e},Dv=({state:e},t)=>{if(be(e))throw new Error("Cannot save while a scene replay is active");let s=t?.slotId;Op(s,"saveSlot");let{thumbnailImage:i}=t,a=t?.savedAt,r=ft(s),n=B(e.contexts);n?.forEach(c=>{Mt(c),Kp(c.rollback),bw(c.rollback,e.projectData)});let o={contexts:n},l={formatVersion:Pp,slotId:Np(s),savedAt:typeof a=="number"?a:Date.now(),image:i,state:o};return e.global.saveSlots[r]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},Lv=({state:e},t)=>{if(be(e))throw new Error("Cannot load while a scene replay is active");let s=t?.slotId;Op(s,"loadSlot");let i=ft(s),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0;if(a){let r=$w(a,e.projectData);e.contexts=r.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=wn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Dt(e),Lt(e),Ca(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},Mv=({state:e},t)=>{if(be(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:s}=t;_p(s),Qt(s),Zt(s),en(s),nt(s?.resources?.variables??{}),Vo(s);let i=kw(s),a=i?e.contexts?.map((n,o)=>Fp(B(n),s,o)):void 0,r=i?ww(e.global.saveSlots,s):void 0;if(e.projectData=s,e.global.imageGalleryNavigation=Ea(),e.global.sceneReplayNavigation=Ra(),Ca(e),i){let n=s?.resources?.variables??{},{globalVariablesDefaultValues:o}=ss(s??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...o,...rn(e.global.variables,n,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return Dt(e),Lt(e),i&&Object.keys(e.global.saveSlots??{}).length>0&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}}),e.global.pendingEffects.push({name:"render"}),e},Vv=({state:e},t)=>{let{l10nId:s,projectData:i}=t??{};if(s!==null&&(typeof s!="string"||s.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!U(i))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=i,Ma(e,"localizationPackageId",s),Hp(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Re({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},qv=({state:e},t)=>{let{sectionId:s,lineId:i}=t;if(!i)return console.warn("jumpToLine requires lineId parameter"),e;let a=e.contexts[e.contexts.length-1];if(!a)return console.warn("No context available for jumpToLine"),e;let r=s||a.pointers.read?.sectionId;if(s&&!Ve({state:e},{sectionId:s}))return console.warn(`Section not found: ${s}`),e;let n=Ve({state:e},{sectionId:r});if(!n?.lines||!Array.isArray(n.lines))return console.warn(`Section ${r} has no lines`),e;if(!n.lines.find(p=>p.id===i))return console.warn(`Line not found: ${i} in section ${r}`),e;let l=Re({state:e}),c=Mt(a);c.read={sectionId:r,lineId:i};let{activeInteraction:u}=An(e,c.read);return Ds(e,l,u),e},Fv=({state:e,rollbackActionBatchStack:t},s)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Ls({state:e,rollbackActionBatchStack:t}),e;let i=Re({state:e});if(i?.source===jt&&s?.bypassChoice!==!0||i?.source===Br&&s?._interactionSource!==Br)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,be(e)?.sceneReplay.exitOnLineCompleted)return ut(e),e;let d=Be({state:e})?.pointer,f=d?.sectionId,h=d?.lineId;f&&h&&pt(e,{sectionId:f,lineId:h}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!i&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}});let g=e.global.nextLineConfig,y=Ve({state:e},{sectionId:f});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===h?ha(e):g?.auto?.enabled&&!i&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(be(e)?.sceneReplay.finishOnNextAdvance)return ut(e),e;let r=Be({state:e})?.pointer,n=r?.sectionId,o=Ve({state:e},{sectionId:n}),l=e.contexts[e.contexts.length-1],c=o?.lines||[],p=Fe(c,r?.lineId)+1;if(p<c.length){let m=c[p],d=!ar(e,"skipUnseenText");if(e.global.skipMode&&d&&!Fa({state:e},{sectionId:n,lineId:m.id}))return Ur({state:e}),e;if(l&&!l.rollback&&zr(l,{compatibilityAnchor:!0}),l){let h=Mt(l),g=h.read?.lineId;g&&n&&pt(e,{sectionId:n,lineId:g}),h.read={sectionId:n,lineId:m.id}}Ts(e,{sectionId:n,lineId:m.id}),$a(e);let{activeInteraction:f}=An(e,{sectionId:n,lineId:m.id});Ds(e,i,f)}else{if(be(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),ut(e),e;e.global.autoMode&&Pn({state:e}),e.global.skipMode&&Ur({state:e}),ha(e)}return e},Bv=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,be(e)?.sceneReplay.exitOnLineCompleted)return ut(e),e;let s=Re({state:e});e.global.autoMode&&!s&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}});let i=Be({state:e})?.pointer,a=i?.sectionId,r=i?.lineId;a&&r&&pt(e,{sectionId:a,lineId:r});let n=e.global.nextLineConfig;return n?.auto?.enabled&&!s&&n.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:n.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},Uv=({state:e},t)=>wf(e,{sectionId:t?.sectionId,screen:t?.screen}),Yv=({state:e,rollbackActionBatchStack:t},s)=>{let i=s?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!i)return Ls({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Or({state:e})}}),e;let a=Re({state:e});if(a?.source===jt&&s?.bypassChoice!==!0||a?.source===Br&&s?._interactionSource!==Br||a&&a.source!==jt&&a.source!==Br)return e;let r=be(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(ut(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let n=Be({state:e})?.pointer,o=n?.sectionId,l=Ve({state:e},{sectionId:o}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],m=Fe(u,n?.lineId)+1;if(m<u.length){let d=u[m],f=!ar(e,"skipUnseenText");if(e.global.skipMode&&f&&!Fa({state:e},{sectionId:o,lineId:d.id})&&(Ur({state:e}),!i))return e;if(c&&!c.rollback&&zr(c,{compatibilityAnchor:!0}),c){let g=Mt(c),y=g.read?.lineId;y&&o&&pt(e,{sectionId:o,lineId:y}),g.read={sectionId:o,lineId:d.id}}Ts(e,{sectionId:o,lineId:d.id}),$a(e);let{activeInteraction:h}=An(e,{sectionId:o,lineId:d.id});Ds(e,a,h)}else{if(be(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),ut(e),e;e.global.autoMode&&Pn({state:e}),e.global.skipMode&&Ur({state:e}),ha(e)}return e},Za=(e,t={})=>{let s=vn({state:e});return!s||t.formKey&&t.formKey!==s.key||t.formId&&t.formId!==s.id?null:s},zv=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let s=L(e.projectData.resources?.variables,t.variableId),i=s?.scope,a=s?.type;if(Ne(s))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(s?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(tn(i,t.variableId),nn(a,"set",t.variableId),be(e)&&i!=="context")throw new Error(`Cannot update ${i}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:s,scope:i}},Xv=(e,t)=>({id:e.id,key:e.key,valid:!0,values:B(t),fields:B(e.fields),fieldList:B(e.fieldList)}),Gv=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Be({state:e})?.pointer,s=t?.sectionId,i=t?.lineId;s&&i&&pt(e,{sectionId:s,lineId:i})},Hv=({state:e},t={})=>{let s=Za(e,t),i=t.field;if(!s?.fields?.[i])return e;let a=Yp(e,s.key),r=Cs(t.value),n=s.fields[i],o=Ta(n,r);return a.values[i]=r,a.touched[i]=!0,o?a.errors[i]=o:delete a.errors[i],e.global.pendingEffects.push({name:"render"}),e},Kv=({state:e,rollbackActionBatchStack:t},s={})=>{let i=Za(e,s);if(!i)return{submitted:!1,valid:!1,reason:"inactive"};let a=Yp(e,i.key);a.submitted=!0;let r={},n={};if(Object.entries(i.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:d.value,h=Ta(d,f);a.touched[m]=!0,h&&(n[m]=h),r[m]=Up(d,f)}),a.errors=n,Object.keys(n).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:B(n),form:{id:i.id,key:i.key,values:B(r)}};let o=e.contexts[e.contexts.length-1];if(o?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(i.fields).forEach(([m,d])=>{let{scope:f}=zv(e,d),h=f==="context"?o.variables:e.global.variables,g=r[m];h[d.variableId]=os(h[d.variableId],"set",g),f==="context"&&(l=!0,u.push({variableId:d.variableId,op:"set",value:g})),(f==="device"||f==="account")&&c.push({scope:f,path:`variables.${d.variableId}`,op:"set",value:B(h[d.variableId])})}),l&&ur(e,"updateVariable",{id:"submitForm",operations:u},t),Ms(e,c);let p=Xv(i,r);return Gv(e),delete e.global.formDrafts[i.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},Wv=({state:e},t={})=>{let s=Za(e,t);return s?(delete e.global.formDrafts?.[s.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:s.id,key:s.key,values:B(s.values),fields:B(s.fields),fieldList:B(s.fieldList)}}):{cancelled:!1,reason:"inactive"}},Jv=({state:e,rollbackActionBatchStack:t},s)=>{let{id:i,operations:a=[]}=s;if(!i)throw new Error("updateVariable requires an id field");if(typeof i!="string"||!/^[a-zA-Z0-9]+$/.test(i))throw new Error(`updateVariable id must be alphanumeric, got: "${i}"`);let r=e.contexts[e.contexts.length-1];if(r?.rollback?.isRestoring)return e;let n=!1,o=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let d=L(e.projectData.resources?.variables,c),f=d?.scope,h=d?.type;if(Ne(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(tn(f,c),nn(h,u,c),is(h,u,p,c,{roundTo:m}),be(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${c}" while a scene replay is active`);let g=f==="context"?r.variables:e.global.variables;if(f==="context"){n=!0;let y={variableId:c,op:u,value:p};m!==void 0&&(y.roundTo=m),l.push(y)}g[c]=os(g[c],u,p,{roundTo:m}),(f==="device"||f==="account")&&o.push({scope:f,path:`variables.${c}`,op:"set",value:B(g[c])})}),n&&ur(e,"updateVariable",{id:i,operations:l},t),Ms(e,o),e.global.pendingEffects.push({name:"render"}),e},Je=e=>(t,s)=>e({state:t},s),jf=e=>({variables:Pt({variables:{...e.global?.variables??{},...Yr(e)?.variables??{}},runtime:kr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:kr(e)}),Qv=e=>{if(!U(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},Zv=(e,t,s)=>{if(!U(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!U(e.actions))throw new Error(`conditional branch at index ${t} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&t!==s-1)throw new Error("conditional else branch must be the last branch")},ek=(e,t,s,i)=>{Qv(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(Zv(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Jt(r.when,{...jf(e),...s?.bindings??{}}))){el(e,r.actions,s,[...i,"branches",String(a),"actions"]);return}}},rk=(e,t,s,i)=>{let a=s?.checkpoint;if(a?.randomOutcomeVersion!==Sr)return;let r=i.join("."),n=s.randomOutcomeOrdinals,o=n.get(r)??0;n.set(r,o+1);let l=a.randomOutcomes?.find(p=>p.path===r&&p.ordinal===o);if(!l)return;if(t?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${r}`);let c=cs(B(l.result),l.type);if(c.type==="integer"){if(!Dp(t.distribution)||c.value<t.distribution.min||c.value>t.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${r}`);ga(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!U(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);el(e,u,s,[...i,"distribution","outcomes",String(c.outcomeIndex),"actions"])},tk={conditional:{replayLine:ek},random:{replayLine:rk},updateVariable:{recordSources:[Fr],replayLine:ga,replayRecorded:ga,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Je(Nf)},setSaveLoadPagination:{recordSources:[Fr],replayLine:Je(Ia),replayRecorded:Je(Ia),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Fr],replayLine:Je(va),replayRecorded:Je(va),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Fr],replayLine:Je(ka),replayRecorded:Je(ka),persistInSaveSlot:!0},setMenuPage:{recordSources:[Fr],replayLine:Je(Aa),replayRecorded:Je(Aa),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Fr],replayLine:Je(Pa),replayRecorded:Je(Pa),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Je(Rf)}},Fs=e=>tk[e]??null,nk=e=>Fs(e)?.persistInSaveSlot===!0,sk=(e,t)=>{let s=Fs(e)?.recordSources;return Array.isArray(s)&&s.includes(t)},ik=(e,t,s)=>{Fs(t)?.replayRecorded?.(e,s)},ok=(e,t,s,i,a)=>{let r=Fs(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,s,i,a);return}let n=i?.bindings??{},o=xt({[t]:s},{...jf(e),...n})[t];r.replayLine(e,o)},el=(e,t,s,i)=>{let a=us(t);fs(a);for(let[r,n]of a)ok(e,r,n,s,[...i,r])},ak=e=>e?.returnable!==!1,Tf=(e,t)=>{if(t>=0)return e.currentIndex+t;let s=Math.abs(t);for(let i=e.currentIndex-1;i>=0;i-=1)if(ak(e.timeline[i])&&(s-=1,s===0))return i;return-1},Df=({state:e},t)=>{let{offset:s}=t;if(s===void 0||typeof s!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let i=e.contexts[e.contexts.length-1];if(!i)return null;let a=i.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let r=Tf(a,s);if(r<0||r>=a.timeline.length)return null;let n=a.timeline[r];return{sectionId:n.sectionId,lineId:n.lineId}},Lf=({state:e})=>Df({state:e},{offset:-1})!==null,lk=({state:e},t)=>{let{offset:s=-1}=t;if(s>=0)throw new Error("rollbackByOffset requires a negative offset");let i=e.contexts?.[e.contexts.length-1];if(!i)return e;let a=zr(i,{compatibilityAnchor:!i.rollback}),r=Tf(a,s);return r<0||r>=a.timeline.length?e:Jp(e,r)},ck=({state:e},t)=>{let{sectionId:s,lineId:i}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=zr(a,{compatibilityAnchor:!a.rollback}),o=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===s&&l.lineId===i);if(o===-1)throw new Error(`Line ${i} not found in section ${s} rollback timeline`);return o===r.currentIndex?e:Jp(e,o)},uk=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),ya=(e,t)=>{let s=e[t];if(!Number.isSafeInteger(s)||s<0)throw new RangeError(`Internal playback ${t} is invalid`);if(s===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=s+1,e[t]},kp=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,Ap=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},pk=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Mf=e=>{let t=e.global?.nextLineConfig?.auto;return t?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:t.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:t.delay??1e3}},rl=e=>JSON.stringify(Mf(e)),fk=({actionName:e,args:t,state:s,previousState:i})=>{let a=kp(i),r=kp(s);if(!pk(a,r)||i.contexts?.length!==s.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&Ap(i)!==Ap(s))return!0;let n=t[0]??{};if(e==="jumpToLine"){let o=n.sectionId??a?.sectionId;return typeof n.lineId=="string"&&r?.sectionId===o&&r?.lineId===n.lineId&&s.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let o=Qe(s.projectData,n.sectionId).section,l=bf(o)?.id;return typeof l=="string"&&r?.sectionId===n.sectionId&&r?.lineId===l&&s.global.isLineCompleted===!1}if(e==="loadSlot"){let o=n.slotId;return Object.prototype.hasOwnProperty.call(i.global?.saveSlots??{},ft(o))}return!1},dk=({actionName:e,args:t,state:s,transactionalMetadata:i,previousState:a})=>{if(fk({actionName:e,args:t,state:s,previousState:a})){let u=ya(i,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?i.rollbackAuthoredSuppression={lineEntryId:u,configKey:rl(s)}:i.rollbackAuthoredSuppression=null,i.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let n=(a.contexts?.length??0)>(s.contexts?.length??0),o=e==="startAutoMode"||e==="startSkipMode"?Re({state:a}):null;s.global.autoMode===!0&&(e==="startAutoMode"&&!o||e==="toggleAutoMode"&&a.global.autoMode!==!0||n&&a.global.autoMode!==!0)&&ya(i,"autoSessionId"),s.global.skipMode===!0&&(e==="startSkipMode"&&!o||e==="toggleSkipMode"&&a.global.skipMode!==!0||n&&a.global.skipMode!==!0)&&ya(i,"skipSessionId")},mk=({state:e,transactionalMetadata:t})=>{let s=t.rollbackAuthoredSuppression;s&&(s.lineEntryId!==t.lineEntryId||s.configKey!==rl(e))&&(t.rollbackAuthoredSuppression=null)},yk=({state:e,playbackOwnership:t})=>{let s=Re({state:e}),i=t.lineEntryId,a=!s&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!s&&e.global.skipMode===!0,n=Mf(e),o=t.rollbackAuthoredSuppression,l=!s&&n.enabled&&(n.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(o?.lineEntryId===i&&o.configKey===rl(e)),c=a?ff(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:i},delayMs:ma({text:c,baseDelay:ar(e,"autoForwardDelay"),speed:ar(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:i},delayMs:n.delayMs,trigger:n.trigger}:null}},hk=({playbackOwnership:e})=>e.lineEntryId,Vf=(e,t={})=>{let s=nI(e),i=[],a=t.createPlaybackOwnership??uk;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return mc(s,{selectPendingEffects:iI,selectSkipMode:Qp,selectAutoMode:oI,selectIsChoiceVisible:lf,selectIsFormVisible:pI,selectActiveInteraction:Re,selectActiveForm:vn,selectDialogueUIHidden:Zp,selectDialogueHistory:ef,selectConfirmDialog:uI,selectIsLineAccountViewed:Fa,selectIsResourceAccountViewed:dI,selectImageGalleryConfig:mI,selectImageGallery:rf,selectMusicRoomConfig:hI,selectMusicRoom:nf,selectSceneReplayConfig:gI,selectSceneReplay:of,selectIsSceneReplayActive:bI,selectActiveSceneReplayEntry:wI,selectNextLineConfig:II,selectSystemState:vI,selectBgmResources:kI,selectBgmPlaybackContext:AI,selectSceneIdForSection:PI,selectAchievements:xI,selectAchievement:EI,selectSaveSlotMap:cf,selectSaveSlots:_I,selectSaveSlot:SI,selectLocalizationPackages:uf,selectRuntime:Ka,selectRuntimeValue:OI,selectAllVariables:Wa,selectCurrentPointer:Be,selectSection:Ve,selectCurrentLine:kn,selectPresentationState:pf,selectAutoForwardTimerDelay:Or,selectPresentationChanges:RI,selectSectionLineChanges:CI,selectSaveSlotPage:Ja,selectCurrentPageSlots:NI,selectRenderState:TI,selectOverlayStack:sI,selectLineIdByOffset:Df,selectCanRollback:Lf,selectRollbackCursor:Hw,selectDesiredPlaybackTimers:yk,selectPlaybackLineEntryId:hk,startAutoMode:yf,stopAutoMode:Pn,toggleAutoMode:UI,startSkipMode:hf,stopSkipMode:Ur,toggleSkipMode:YI,showDialogueUI:Ls,hideDialogueUI:gf,toggleDialogueUI:zI,setDialogueTextSpeed:XI,setAutoForwardDelay:GI,setAutoForwardSpeed:HI,setSkipUnseenText:KI,setSkipTransitionsAndAnimations:WI,setSoundVolume:JI,setMusicVolume:QI,setMuteAll:ZI,setSaveLoadPagination:Ia,incrementSaveLoadPagination:va,decrementSaveLoadPagination:ka,setMenuPage:Aa,setMenuEntryPoint:Pa,showConfirmDialog:DI,hideConfirmDialog:LI,resetStoryAtSection:sv,clearPendingEffects:ev,appendPendingEffect:rv,completeAchievement:tv,setAchievementProgress:nv,beginRollbackActionBatch:Jw,endRollbackActionBatch:Qw,ensureRandomReplayOccurrence:Zw,recordRandomOutcome:eI,markRollbackCheckpointTransient:Kw,markSavedRollbackCheckpointTransient:Ww,recordCurrentDialogueHistory:cI,addViewedLine:ov,addViewedResource:av,showImageGalleryVariant:lv,moveToPreviousImageGalleryVariant:cv,moveToNextImageGalleryVariant:uv,clearImageGallerySelection:pv,moveToImageGalleryPage:fv,moveToNextImageGalleryPage:dv,moveToPreviousImageGalleryPage:mv,playMusicRoomTrack:hv,playMusicRoom:gv,pauseMusicRoom:bv,stopMusicRoom:wv,seekMusicRoom:Iv,playPreviousMusicRoomTrack:vv,playNextMusicRoomTrack:kv,clearMusicRoomSelection:Av,moveToMusicRoomPage:Pv,moveToNextMusicRoomPage:xv,moveToPreviousMusicRoomPage:Ev,musicRoomSoundReady:_v,musicRoomSoundProgress:Nv,musicRoomSoundComplete:jv,musicRoomSoundError:Tv,startSceneReplay:Sv,finishSceneReplay:Rf,exitSceneReplay:Ov,moveToSceneReplayPage:Rv,moveToNextSceneReplayPage:$v,moveToPreviousSceneReplayPage:Cv,setNextLineConfig:Nf,saveSlot:Dv,loadSlot:Lv,updateProjectData:Mv,updateLocalizationPackage:Vv,sectionTransition:Uv,jumpToLine:qv,nextLine:Fv,markLineCompleted:Bv,rollbackToLine:ck,rollbackByOffset:lk,pushOverlay:MI,popOverlay:VI,replaceLastOverlay:qI,clearOverlays:FI,updateFormField:Hv,submitForm:Kv,cancelForm:Wv,updateVariable:Jv,nextLineFromSystem:Yv},{createTransactionalMetadata:a,updateTransactionalMetadata:dk,finalizeTransactionalMetadata:mk,transformActionFirstArgument:(n,o)=>({state:n,rollbackActionBatchStack:i,playbackOwnership:o}),transformSelectorFirstArgument:(n,o)=>({state:n,playbackOwnership:o})})};var gk="route-engine",bk="projectPersistence";var Ff=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),ve=e=>Object.prototype.toString.call(e)==="[object Object]",qf="variables.",wk=(e={})=>{let t=ve(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(s=>typeof s=="string"||typeof s=="number"?{sectionId:String(s)}:!ve(s)||typeof s.sectionId!="string"||s.sectionId.length===0?null:{sectionId:s.sectionId,...typeof s.lineId=="string"?{lineId:s.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(s=>typeof s=="string"||typeof s=="number"?{resourceId:String(s)}:!ve(s)||typeof s.resourceId!="string"||s.resourceId.length===0?null:{resourceId:s.resourceId}).filter(Boolean)}},Ik=(e={})=>{let t=ve(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(s=>typeof s=="string"||typeof s=="number"?{sectionId:String(s)}:!ve(s)||typeof s.sectionId!="string"||s.sectionId.length===0?null:{sectionId:s.sectionId,...typeof s.lastLineId=="string"?{lastLineId:s.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(s=>typeof s=="string"||typeof s=="number"?{resourceId:String(s)}:!ve(s)||typeof s.resourceId!="string"||s.resourceId.length===0?null:{resourceId:s.resourceId}).filter(Boolean)}},vk=(e,t)=>{let s=Ik(e),i=wk(t),a=s.sections.map(n=>({...n})),r=s.resources.map(n=>({...n}));return i.sections.forEach(n=>{let o=a.find(l=>l.sectionId===n.sectionId);if(!o){a.push({sectionId:n.sectionId,...n.lineId===void 0?{}:{lastLineId:n.lineId}});return}if(o.lastLineId!==void 0){if(n.lineId===void 0){delete o.lastLineId;return}o.lastLineId=n.lineId}}),i.resources.forEach(n=>{r.find(l=>l.resourceId===n.resourceId)||r.push({...n})}),{sections:a,resources:r}},kk=(e={})=>{let t=ve(e)?e:{},s=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(s.filter(i=>typeof i=="string"&&i.length>0))]}},Ak=(e,t)=>{let s=kk(e),i=ve(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...s.sceneIds,...i.filter(a=>typeof a=="string"&&a.length>0)])]}},Bf=(e={})=>{let t=ve(e)?e:{};return{saveSlots:ve(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:ve(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:ve(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:ve(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:ve(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:ve(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},Pk=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,s)=>{if(!ve(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${s}] entry.`);let i=t.path?.startsWith(qf)?t.path.slice(qf.length):null;if(i!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${s}].`);if(i.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${s}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);return{scope:t.scope,path:t.path,op:t.op,value:t.value,variableId:i}}if(t.path==="viewedRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${s}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${s}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);if(!ve(t.value)||!Array.isArray(t.value.sceneIds)||t.value.sceneIds.length===0||t.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${s}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${s}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${s}].`)})},xk=(e,t)=>{let s={};return Pk(t).forEach(i=>{if(i.path==="viewedRegistry"){s.accountViewedRegistry=vk(s.accountViewedRegistry??e.accountViewedRegistry,i.value);return}if(i.path==="replayRegistry"){s.accountReplayRegistry=Ak(s.accountReplayRegistry??e.accountReplayRegistry,i.value);return}let a=i.scope==="device"?"globalDeviceVariables":"globalAccountVariables";s[a]={...e[a],...s[a],[i.variableId]:i.value}}),s},Vt=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},Ek=e=>{let t=Vt(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},Sk=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},Ok=({indexedDB:e,databaseName:t,objectStoreName:s})=>new Promise((i,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let n=r.result;n.objectStoreNames.contains(s)||n.createObjectStore(s,{keyPath:"namespace"})},r.onsuccess=()=>{i(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),Rk=async({databasePromise:e,objectStoreName:t,namespace:s})=>{let i=await e;return new Promise((a,r)=>{let l=i.transaction(t,"readonly").objectStore(t).get(s);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${s}" from IndexedDB.`))}})},En=async({databasePromise:e,objectStoreName:t,namespace:s,patch:i})=>{let a=await e;return new Promise((r,n)=>{let o=a.transaction(t,"readwrite"),l=o.objectStore(t),c=l.get(s),u=!1,p=d=>{u||(u=!0,n(d))},m=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${s}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=Bf(c.result),f=typeof i=="function"?i(d):i,h={namespace:s,version:1,...Ff(),...d,...f},g=l.put(h);g.onerror=()=>{p(g.error??new Error(`Failed to persist namespace "${s}" to IndexedDB.`))}},o.oncomplete=()=>{m()},o.onerror=()=>{p(o.error??new Error(`IndexedDB transaction failed while updating namespace "${s}".`))},o.onabort=()=>{p(o.error??new Error(`IndexedDB transaction aborted while updating namespace "${s}".`))}})},$k=async({databasePromise:e,objectStoreName:t,namespace:s})=>{let i=await e;return new Promise((a,r)=>{let n=i.transaction(t,"readwrite"),l=n.objectStore(t).delete(s),c=!1,u=m=>{c||(c=!0,r(m))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${s}" from IndexedDB.`))},n.oncomplete=()=>{p()},n.onerror=()=>{u(n.error??new Error(`IndexedDB transaction failed while clearing namespace "${s}".`))},n.onabort=()=>{u(n.error??new Error(`IndexedDB transaction aborted while clearing namespace "${s}".`))}})},tl=(e={})=>{let{indexedDB:t,databaseName:s=gk,objectStoreName:i=bk,namespace:a}=e,r=Sk(t),n=Ek(a),o=Ok({indexedDB:r,databaseName:s,objectStoreName:i});return{namespace:n,load:async()=>{let l=await Rk({databasePromise:o,objectStoreName:i,namespace:n});return{...Ff(),...Bf(l)}},clear:async()=>$k({databasePromise:o,objectStoreName:i,namespace:n}),saveSlots:async l=>En({databasePromise:o,objectStoreName:i,namespace:n,patch:{saveSlots:ve(l)?l:{}}}),saveGlobalDeviceVariables:async l=>En({databasePromise:o,objectStoreName:i,namespace:n,patch:{globalDeviceVariables:ve(l)?l:{}}}),saveGlobalAccountVariables:async l=>En({databasePromise:o,objectStoreName:i,namespace:n,patch:{globalAccountVariables:ve(l)?l:{}}}),saveGlobalRuntime:async l=>En({databasePromise:o,objectStoreName:i,namespace:n,patch:{globalRuntime:ve(l)?l:{}}}),applyScopedDataUpdates:async l=>En({databasePromise:o,objectStoreName:i,namespace:n,patch:c=>xk(c,l)})}},Ck=tl;var al=by(Yf(),1),Zf=ed;var _k={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ze=Object.prototype.hasOwnProperty,Nk={anyOf:[{type:"null"},{type:"object",properties:{x:{type:"number",minimum:0},y:{type:"number",minimum:0},quality:{type:"number",minimum:1},kernelSize:{type:"integer",enum:[5,7,9,11,13,15]},repeatEdgePixels:{type:"boolean"}},required:["x","y"],additionalProperties:!1}]};function Ue(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!1,c=n;if(e!==null){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};r===null?r=[p]:r.push(p),n++}var u=c===n;if(l=l||u,!l){let p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[d]:r.push(d),n++}if(e.y===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[d]:r.push(d),n++}for(let d in e)if(!(d==="x"||d==="y"||d==="quality"||d==="kernelSize"||d==="repeatEdgePixels")){let f={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),n++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),n++}}else{let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),n++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),n++}}else{let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),n++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[f]:r.push(f),n++}}else{let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),n++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[f]:r.push(f),n++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Nk.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[f]:r.push(f),n++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let d={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),n++}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),n++}var u=p===n;l=l||u}if(l)n=o,r!==null&&(o?r.length=o:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),n++}return Ue.errors=r,n===0}var $e=al.default.default??al.default;function Us(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),n++}if(e.type===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[o]:r.push(o),n++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}if(e.type!==void 0&&e.type!=="shader"){let o={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Us.errors=r,n===0}function yr(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(Array.isArray(e)){let o=e.length;for(let l=0;l<o;l++)Us(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),n=r.length)}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[o]:r.push(o),n++}return yr.errors=r,n===0}var jk={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Ys(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="continuity"||o==="speed"||o==="loop")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.continuity!==void 0){let o=e.continuity;if(typeof o!="string"){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(!(o==="render"||o==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:jk.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}if(e.speed!==void 0){let o=e.speed;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ys.errors=r,n===0}function fe(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="resourceId"||o==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}e.playback!==void 0&&(Ys(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return fe.errors=r,n===0}function zs(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!Ze.call(_k.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let o={instancePath:t+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let o={instancePath:t+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let o={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let o={instancePath:t+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.x!==void 0&&typeof e.x!="number"){let o={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.y!==void 0&&typeof e.y!="number"){let o={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let o={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let o={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.alpha!==void 0){let o=e.alpha;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.opacity!==void 0){let o=e.opacity;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}e.blur!==void 0&&(Ue(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),n=r.length)),e.filters!==void 0&&(yr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?yr.errors:r.concat(yr.errors),n=r.length)),e.animations!==void 0&&(fe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return zs.errors=r,n===0}function ed(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return zs(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),n=r.length),ed.errors=r,n===0}var rd=td;var zf={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},Xf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function Xs(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(o!=="speed"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.speed!==void 0){let o=e.speed;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Xs.errors=r,n===0}function je(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="resourceId"||o==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.resourceId!==void 0){let o=e.resourceId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}e.playback!==void 0&&(Xs(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return je.errors=r,n===0}function Gs(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),n++}if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!Ze.call(Xf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}if(e.resourceId!==void 0){let o=e.resourceId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<-1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.startDelayMs!==void 0){let o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.playbackRate!==void 0){let o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.startAt!==void 0){let o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.endAt!==void 0){let o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Xf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}if(typeof o=="number"&&(o<0||isNaN(o))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Gs.errors=r,n===0}function Hs(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),n++}}var c=l===n;if(c){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=o,r!==null&&(o?r.length=o:r=null);let u=n,p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),n++}}var m=p===n;if(m){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=u,r!==null&&(u?r.length=u:r=null);let d=n,f=!0,h=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let b={};r===null?r=[b]:r.push(b),n++}}var g=h===n;if(n=d,r!==null&&(d?r.length=d:r=null),g){let y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let w={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[w]:r.push(w),n++}var g=y===n;f=g}if(!f){let y={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[y]:r.push(y),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Ze.call(zf.properties,y)){let b={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),n++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let b=y.length;for(let w=0;w<b;w++)Gs(y[w],{instancePath:t+"/sounds/"+w,parentData:y,parentDataProperty:w,rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),n=r.length)}else{let b={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),n++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),n++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),n++}if(!(y==="immediate"||y==="loopEnd")){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:zf.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),n++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),n++}if(y<0||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),n++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),n++}if(y<-1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}e.audioEffects!==void 0&&(je(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=r.length))}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),n++}return Hs.errors=r,n===0}function td(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Hs(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),n=r.length),td.errors=r,n===0}var nd=sd;var Tk={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ks(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),n++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=n,d=!0,f=n;if(p&&typeof p=="object"&&!Array.isArray(p)){let h;if(p.sprites===void 0&&(h="sprites")){let g={};r===null?r=[g]:r.push(g),n++}}var o=f===n;if(n=m,r!==null&&(m?r.length=m:r=null),o){let h=n;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};r===null?r=[y]:r.push(y),n++}var o=h===n;d=o}if(!d){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),n++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[h]:r.push(h),n++}for(let h in p)if(!Ze.call(Tk.properties.items.items.properties,h)){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),n++}if(p.id!==void 0&&typeof p.id!="string"){let h={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let h={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(p.x!==void 0&&typeof p.x!="number"){let h={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.y!==void 0&&typeof p.y!="number"){let h={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let h={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let h={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let h={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let h={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let h={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),n++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let h={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),n++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let h={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.originX!==void 0&&typeof p.originX!="number"){let h={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.originY!==void 0&&typeof p.originY!="number"){let h={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(p.alpha!==void 0){let h=p.alpha;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),n++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}}if(p.opacity!==void 0){let h=p.opacity;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),n++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}}if(p.blur!==void 0&&(Ue(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),n=r.length)),p.filters!==void 0&&(yr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?yr.errors:r.concat(yr.errors),n=r.length)),p.sprites!==void 0){let h=p.sprites;if(Array.isArray(h)){let g=h.length;for(let y=0;y<g;y++){let b=h[y];if(b&&typeof b=="object"&&!Array.isArray(b)){for(let w in b)if(!(w==="id"||w==="resourceId"||w==="animationName"||w==="animationSpeed"||w==="loop")){let A={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:w},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),n++}if(b.id!==void 0&&typeof b.id!="string"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),n++}if(b.resourceId!==void 0&&typeof b.resourceId!="string"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),n++}if(b.animationName!==void 0&&typeof b.animationName!="string"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),n++}if(b.animationSpeed!==void 0&&typeof b.animationSpeed!="number"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),n++}if(b.loop!==void 0&&typeof b.loop!="boolean"){let w={instancePath:t+"/items/"+u+"/sprites/"+y+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[w]:r.push(w),n++}}else{let w={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),n++}}}else{let g={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[g]:r.push(g),n++}}p.animations!==void 0&&(fe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),n++}}}else{let c={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),n++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}return Ks.errors=r,n===0}function sd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Ks(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),n=r.length),sd.errors=r,n===0}var id=od;function Ws(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="resourceId"||o==="items"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.items!==void 0){let o=e.items;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:t+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),n++}if(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:t+"/items/"+c+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),n++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let m=p.click;if(!(m&&typeof m=="object"&&!Array.isArray(m))){let d={instancePath:t+"/items/"+c+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),n++}}}else{let m={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),n++}}}else{let p={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}}else{let l={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}e.animations!==void 0&&(fe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ws.errors=r,n===0}function od(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Ws(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),n=r.length),od.errors=r,n===0}var ad=ld;function Js(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(o!=="mode"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.mode!==void 0&&typeof e.mode!="string"){let o={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Js.errors=r,n===0}function ld(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Js(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),n=r.length),ld.errors=r,n===0}var cd=ud;function Qs(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(o!=="resourceId"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Qs.errors=r,n===0}function ud(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Qs(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),n=r.length),ud.errors=r,n===0}var pd=fd;var Gf={type:"object",properties:{ui:{type:"object",properties:{resourceId:{type:"string"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},mode:{type:"string",enum:["adv","nvl"]},content:{type:"array",items:{type:"object",properties:{text:{type:"string"}}}},textSpeed:{type:"number"},append:{type:"boolean"},characterId:{type:"string"},characterName:{type:"string"},persistCharacter:{type:"boolean"},persistSprite:{type:"boolean"},character:{type:"object",properties:{name:{type:"string"},sprite:{type:"object",properties:{transformId:{type:"string"},items:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},required:["id","resourceId"],additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1}},additionalProperties:!1},clear:{type:"boolean"},clearPage:{type:"boolean"}},additionalProperties:!1};function Zs(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!Ze.call(Gf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.ui!==void 0){let o=e.ui;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)if(!(l==="resourceId"||l==="animations")){let c={instancePath:t+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),n++}if(o.resourceId!==void 0&&typeof o.resourceId!="string"){let l={instancePath:t+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}o.animations!==void 0&&(fe(o.animations,{instancePath:t+"/ui/animations",parentData:o,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let l={instancePath:t+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}if(e.mode!==void 0){let o=e.mode;if(typeof o!="string"){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(!(o==="adv"||o==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:Gf.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}if(e.content!==void 0){let o=e.content;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:t+"/content/"+c+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),n++}}else{let p={instancePath:t+"/content/"+c,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}}else{let l={instancePath:t+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let o={instancePath:t+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.append!==void 0&&typeof e.append!="boolean"){let o={instancePath:t+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let o={instancePath:t+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let o={instancePath:t+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let o={instancePath:t+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let o={instancePath:t+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.character!==void 0){let o=e.character;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)if(!(l==="name"||l==="sprite")){let c={instancePath:t+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),n++}if(o.name!==void 0&&typeof o.name!="string"){let l={instancePath:t+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(o.sprite!==void 0){let l=o.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),n++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={instancePath:t+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),n++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let m=c[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[d]:r.push(d),n++}if(m.resourceId===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[d]:r.push(d),n++}for(let d in m)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),n++}if(m.id!==void 0&&typeof m.id!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/id",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),n++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/resourceId",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),n++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationName",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),n++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationSpeed",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),n++}if(m.loop!==void 0&&typeof m.loop!="boolean"){let d={instancePath:t+"/character/sprite/items/"+p+"/loop",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),n++}}else{let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),n++}}}else{let u={instancePath:t+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[u]:r.push(u),n++}}l.animations!==void 0&&(fe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let c={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),n++}}}else{let l={instancePath:t+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let o={instancePath:t+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let o={instancePath:t+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Zs.errors=r,n===0}function fd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Zs(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),n=r.length),fd.errors=r,n===0}var dd=md;function ei(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="id"||o==="resourceId"||o==="fields"||o==="submitActions"||o==="cancelActions"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.id!==void 0&&typeof e.id!="string"){let o={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.fields!==void 0){let o=e.fields;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};r===null?r=[u]:r.push(u),n++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),n++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/variableId",schemaPath:"#/properties/fields/additionalProperties/properties/variableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),n++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/required",schemaPath:"#/properties/fields/additionalProperties/properties/required/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),n++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/trim",schemaPath:"#/properties/fields/additionalProperties/properties/trim/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),n++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/placeholder",schemaPath:"#/properties/fields/additionalProperties/properties/placeholder/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),n++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/multiline",schemaPath:"#/properties/fields/additionalProperties/properties/multiline/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),n++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[p]:r.push(p),n++}if(typeof u=="number"&&(u<0||isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[p]:r.push(p),n++}}}else{let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),n++}}else{let l={instancePath:t+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}if(e.submitActions!==void 0){let o=e.submitActions;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}if(e.cancelActions!==void 0){let o=e.cancelActions;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}e.animations!==void 0&&(fe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return ei.errors=r,n===0}function md(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return ei(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),n=r.length),md.errors=r,n===0}var yd=hd;function ri(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="resourceId"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}e.animations!==void 0&&(fe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return ri.errors=r,n===0}function hd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return ri(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),n=r.length),hd.errors=r,n===0}var gd=bd;function ti(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="alpha"||o==="opacity"||o==="blur"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.alpha!==void 0){let o=e.alpha;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.opacity!==void 0){let o=e.opacity;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}e.blur!==void 0&&(Ue(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),n=r.length)),e.animations!==void 0&&(fe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return ti.errors=r,n===0}function bd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return ti(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),n=r.length),bd.errors=r,n===0}var wd=Id;var Hf={type:"object",properties:{items:{type:"array",items:{$ref:"#/definitions/audioSound"}},channels:{type:"array",items:{type:"object",properties:{id:{type:"string",minLength:1},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},applyMode:{type:"string",enum:["singleLine","persistent"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1},Kf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function dr(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),n++}if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!Ze.call(Kf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}if(e.resourceId!==void 0){let o=e.resourceId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<-1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.startDelayMs!==void 0){let o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.playbackRate!==void 0){let o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.startAt!==void 0){let o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.endAt!==void 0){let o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Kf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}if(typeof o=="number"&&(o<0||isNaN(o))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return dr.errors=r,n===0}function ni(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};r===null?r=[p]:r.push(p),n++}}var c=l===n;if(c){let u={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),n++}else n=o,r!==null&&(o?r.length=o:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),n++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)dr(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),n=r.length)}else{let p={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),n++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++){let d=u[m];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[f]:r.push(f),n++}if(d.sounds===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[f]:r.push(f),n++}for(let f in d)if(!(f==="id"||f==="volume"||f==="muted"||f==="pan"||f==="loop"||f==="interruption"||f==="applyMode"||f==="sounds")){let h={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),n++}if(d.id!==void 0){let f=d.id;if(typeof f=="string"){if($e(f)<1){let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[h]:r.push(h),n++}}else{let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}}if(d.volume!==void 0){let f=d.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),n++}if(f<0||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}else{let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let f={instancePath:t+"/channels/"+m+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),n++}if(d.pan!==void 0){let f=d.pan;if(typeof f=="number"){if(f>1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),n++}if(f<-1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),n++}}else{let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={instancePath:t+"/channels/"+m+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),n++}if(d.interruption!==void 0){let f=d.interruption;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(!(f==="immediate"||f==="loopEnd")){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:Hf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),n++}}if(d.applyMode!==void 0){let f=d.applyMode;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(!(f==="singleLine"||f==="persistent")){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:Hf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),n++}}if(d.sounds!==void 0){let f=d.sounds;if(Array.isArray(f)){let h=f.length;for(let g=0;g<h;g++)dr(f[g],{instancePath:t+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),n=r.length)}else{let h={instancePath:t+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),n++}}}else{let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),n++}}}else{let p={instancePath:t+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),n++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),n++}return ni.errors=r,n===0}function Id(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return ni(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),n=r.length),Id.errors=r,n===0}var vd=kd;var Wf={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function si(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!1,c=n;if(typeof e!="string"){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),n++}var u=c===n;if(l=l||u,!l){let p=n;if(Array.isArray(e)){let d=e.length;for(let f=0;f<d;f++){let h=e[f];if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let g={instancePath:t+"/"+f+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let g={instancePath:t+"/"+f+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(h.furigana!==void 0){let g=h.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let y={instancePath:t+"/"+f+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let y={instancePath:t+"/"+f+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}}else{let y={instancePath:t+"/"+f+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),n++}}}else{let g={instancePath:t+"/"+f,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),n++}}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),n++}var u=p===n;l=l||u}if(l)n=o,r!==null&&(o?r.length=o:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),n++}return si.errors=r,n===0}function ii(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=n,c=n,u=!1,p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.id===void 0&&(b="id")){let w={};r===null?r=[w]:r.push(w),n++}}var m=p===n;if(u=u||m,!u){let b=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.type===void 0&&(A="type")){let k={};r===null?r=[k]:r.push(k),n++}}var m=b===n;if(u=u||m,!u){let A=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.resourceId===void 0&&(P="resourceId")){let I={};r===null?r=[I]:r.push(I),n++}}var m=A===n;if(u=u||m,!u){let P=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.layout===void 0&&(x="layout")){let D={};r===null?r=[D]:r.push(D),n++}}var m=P===n;if(u=u||m,!u){let x=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.transformId===void 0&&(C="transformId")){let _={};r===null?r=[_]:r.push(_),n++}}var m=x===n;if(u=u||m,!u){let C=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.transform===void 0&&(q="transform")){let X={};r===null?r=[X]:r.push(X),n++}}var m=C===n;if(u=u||m,!u){let q=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let re;if(e.x===void 0&&(re="x")){let R={};r===null?r=[R]:r.push(R),n++}}var m=q===n;if(u=u||m,!u){let re=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let J={};r===null?r=[J]:r.push(J),n++}}var m=re===n;if(u=u||m,!u){let M=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let ue;if(e.anchorX===void 0&&(ue="anchorX")){let H={};r===null?r=[H]:r.push(H),n++}}var m=M===n;if(u=u||m,!u){let ue=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.anchorY===void 0&&(se="anchorY")){let pe={};r===null?r=[pe]:r.push(pe),n++}}var m=ue===n;if(u=u||m,!u){let se=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let de;if(e.scaleX===void 0&&(de="scaleX")){let ke={};r===null?r=[ke]:r.push(ke),n++}}var m=se===n;if(u=u||m,!u){let de=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Q;if(e.scaleY===void 0&&(Q="scaleY")){let N={};r===null?r=[N]:r.push(N),n++}}var m=de===n;if(u=u||m,!u){let Q=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.flipX===void 0&&(T="flipX")){let F={};r===null?r=[F]:r.push(F),n++}}var m=Q===n;if(u=u||m,!u){let T=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.flipY===void 0&&(K="flipY")){let ae={};r===null?r=[ae]:r.push(ae),n++}}var m=T===n;if(u=u||m,!u){let K=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let ye;if(e.rotation===void 0&&(ye="rotation")){let oe={};r===null?r=[oe]:r.push(oe),n++}}var m=K===n;if(u=u||m,!u){let ye=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let he;if(e.originX===void 0&&(he="originX")){let vr={};r===null?r=[vr]:r.push(vr),n++}}var m=ye===n;if(u=u||m,!u){let he=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let er;if(e.originY===void 0&&(er="originY")){let gt={};r===null?r=[gt]:r.push(gt),n++}}var m=he===n;if(u=u||m,!u){let er=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Cr;if(e.layer===void 0&&(Cr="layer")){let Hr={};r===null?r=[Hr]:r.push(Hr),n++}}var m=er===n;if(u=u||m,!u){let Cr=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let bt;if(e.alpha===void 0&&(bt="alpha")){let Bt={};r===null?r=[Bt]:r.push(Bt),n++}}var m=Cr===n;if(u=u||m,!u){let bt=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Kr;if(e.opacity===void 0&&(Kr="opacity")){let wt={};r===null?r=[wt]:r.push(wt),n++}}var m=bt===n;if(u=u||m,!u){let Kr=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Wr;if(e.blur===void 0&&(Wr="blur")){let Ln={};r===null?r=[Ln]:r.push(Ln),n++}}var m=Kr===n;if(u=u||m,!u){let Wr=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ut;if(e.filters===void 0&&(Ut="filters")){let Yt={};r===null?r=[Yt]:r.push(Yt),n++}}var m=Wr===n;if(u=u||m,!u){let Ut=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Yi;if(e.animations===void 0&&(Yi="animations")){let Mn={};r===null?r=[Mn]:r.push(Mn),n++}}var m=Ut===n;u=u||m}}}}}}}}}}}}}}}}}}}}}}if(u)n=c,r!==null&&(c?r.length=c:r=null);else{let b={};r===null?r=[b]:r.push(b),n++}var d=l===n;if(d){let b={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[b]:r.push(b),n++}else n=o,r!==null&&(o?r.length=o:r=null);let f=n,h=!1,g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let b={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[b]:r.push(b),n++}var y=g===n;if(h=h||y,!h){let b=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let A={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[A]:r.push(A),n++}var y=b===n;h=h||y}if(h)n=f,r!==null&&(f?r.length=f:r=null);else{let b={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[b]:r.push(b),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(si(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),n=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let b={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),n++}if(e.width!==void 0&&typeof e.width!="number"){let b={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}if(e.height!==void 0&&typeof e.height!="number"){let b={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),n++}return ii.errors=r,n===0}function oi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"elements"},message:"must have required property 'elements'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="width"||o==="height"||o==="elements")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.width!==void 0){let o=e.width;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.height!==void 0){let o=e.height;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.elements!==void 0){let o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return oi.errors=r,n===0}var Dk={type:"object",properties:{x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},minProperties:1,additionalProperties:!1};function ai(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!Ze.call(Dk.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.x!==void 0&&typeof e.x!="number"){let o={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.y!==void 0&&typeof e.y!="number"){let o={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let o={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let o={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return ai.errors=r,n===0}function li(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let m={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let m=p.length;for(let d=0;d<m;d++){let f=p[d],h=n,g=n;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.resourceId===void 0&&(I="resourceId")||f.text===void 0&&(I="text")){let x={};r===null?r=[x]:r.push(x),n++}}var o=g===n;if(o){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),n++}else n=h,r!==null&&(h?r.length=h:r=null);let y=n,b=n;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.resourceId===void 0&&(I="resourceId")||f.layout===void 0&&(I="layout")){let x={};r===null?r=[x]:r.push(x),n++}}var l=b===n;if(l){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),n++}else n=y,r!==null&&(y?r.length=y:r=null);let w=n,A=n;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.text===void 0&&(I="text")||f.layout===void 0&&(I="layout")){let x={};r===null?r=[x]:r.push(x),n++}}var c=A===n;if(c){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),n++}else n=w,r!==null&&(w?r.length=w:r=null);let k=n,P=n;if(f&&typeof f=="object"&&!Array.isArray(f)){let I;if(f.transformId===void 0&&(I="transformId")||f.transform===void 0&&(I="transform")){let x={};r===null?r=[x]:r.push(x),n++}}var u=P===n;if(u){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),n++}else n=k,r!==null&&(k?r.length=k:r=null);if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[I]:r.push(I),n++}for(let I in f)if(!Ze.call(Wf.properties.items.items.properties,I)){let x={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),n++}if(f.id!==void 0&&typeof f.id!="string"){let I={instancePath:t+"/items/"+d+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),n++}if(f.animationName!==void 0&&typeof f.animationName!="string"){let I={instancePath:t+"/items/"+d+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),n++}if(f.animationSpeed!==void 0&&typeof f.animationSpeed!="number"){let I={instancePath:t+"/items/"+d+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.resourceId!==void 0&&typeof f.resourceId!="string"){let I={instancePath:t+"/items/"+d+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),n++}if(f.text!==void 0&&(ii(f.text,{instancePath:t+"/items/"+d+"/text",parentData:f,parentDataProperty:"text",rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),n=r.length)),f.layout!==void 0&&(oi(f.layout,{instancePath:t+"/items/"+d+"/layout",parentData:f,parentDataProperty:"layout",rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),n=r.length)),f.transformId!==void 0&&typeof f.transformId!="string"){let I={instancePath:t+"/items/"+d+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),n++}if(f.transform!==void 0&&(ai(f.transform,{instancePath:t+"/items/"+d+"/transform",parentData:f,parentDataProperty:"transform",rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),n=r.length)),f.x!==void 0&&typeof f.x!="number"){let I={instancePath:t+"/items/"+d+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.y!==void 0&&typeof f.y!="number"){let I={instancePath:t+"/items/"+d+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.anchorX!==void 0&&typeof f.anchorX!="number"){let I={instancePath:t+"/items/"+d+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.anchorY!==void 0&&typeof f.anchorY!="number"){let I={instancePath:t+"/items/"+d+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.scaleX!==void 0&&typeof f.scaleX!="number"){let I={instancePath:t+"/items/"+d+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.scaleY!==void 0&&typeof f.scaleY!="number"){let I={instancePath:t+"/items/"+d+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.flipX!==void 0&&typeof f.flipX!="boolean"){let I={instancePath:t+"/items/"+d+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[I]:r.push(I),n++}if(f.flipY!==void 0&&typeof f.flipY!="boolean"){let I={instancePath:t+"/items/"+d+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[I]:r.push(I),n++}if(f.rotation!==void 0&&typeof f.rotation!="number"){let I={instancePath:t+"/items/"+d+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.originX!==void 0&&typeof f.originX!="number"){let I={instancePath:t+"/items/"+d+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.originY!==void 0&&typeof f.originY!="number"){let I={instancePath:t+"/items/"+d+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(f.layer!==void 0){let I=f.layer;if(typeof I!="number"){let x={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),n++}if(!(I===10||I===30||I===50||I===70||I===90)){let x={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:Wf.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[x]:r.push(x),n++}}if(f.alpha!==void 0){let I=f.alpha;if(typeof I=="number"){if(I>1||isNaN(I)){let x={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[x]:r.push(x),n++}if(I<0||isNaN(I)){let x={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),n++}}else{let x={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),n++}}if(f.opacity!==void 0){let I=f.opacity;if(typeof I=="number"){if(I>1||isNaN(I)){let x={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[x]:r.push(x),n++}if(I<0||isNaN(I)){let x={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),n++}}else{let x={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),n++}}f.blur!==void 0&&(Ue(f.blur,{instancePath:t+"/items/"+d+"/blur",parentData:f,parentDataProperty:"blur",rootData:a})||(r=r===null?Ue.errors:r.concat(Ue.errors),n=r.length)),f.filters!==void 0&&(yr(f.filters,{instancePath:t+"/items/"+d+"/filters",parentData:f,parentDataProperty:"filters",rootData:a})||(r=r===null?yr.errors:r.concat(yr.errors),n=r.length)),f.animations!==void 0&&(fe(f.animations,{instancePath:t+"/items/"+d+"/animations",parentData:f,parentDataProperty:"animations",rootData:a})||(r=r===null?fe.errors:r.concat(fe.errors),n=r.length))}else{let I={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),n++}}}else{let m={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),n++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}return li.errors=r,n===0}function kd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return li(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?li.errors:r.concat(li.errors),n=r.length),kd.errors=r,n===0}var Ad=Pd;var Lk={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},resourceId:{type:"string"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},startDelayMs:{type:"number",minimum:0}},anyOf:[{required:["resourceId"]},{required:["sounds"]}],allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}}],additionalProperties:!1};function ci(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!1,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let y={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[y]:r.push(y),n++}var u=c===n;if(l=l||u,!l){let y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let w={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[w]:r.push(w),n++}var u=y===n;l=l||u}if(l)n=o,r!==null&&(o?r.length=o:r=null);else{let y={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[y]:r.push(y),n++}let p=n,m=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),n++}}var d=m===n;if(d){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=p,r!==null&&(p?r.length=p:r=null);let f=n,h=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let b={};r===null?r=[b]:r.push(b),n++}}var g=h===n;if(g){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=f,r!==null&&(f?r.length=f:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!(y==="sounds"||y==="resourceId"||y==="volume"||y==="muted"||y==="pan"||y==="loop"||y==="interruption"||y==="startDelayMs")){let b={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),n++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let b=y.length;for(let w=0;w<b;w++)dr(y[w],{instancePath:t+"/sounds/"+w,parentData:y,parentDataProperty:w,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),n=r.length)}else{let b={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),n++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),n++}if(y<0||isNaN(y)){let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),n++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),n++}if(y<-1||isNaN(y)){let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),n++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),n++}if(!(y==="immediate"||y==="loopEnd")){let b={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Lk.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),n++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),n++}return ci.errors=r,n===0}function Pd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return ci(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),n=r.length),Pd.errors=r,n===0}var xd=Ed;var Mk={type:"object",properties:{type:{type:"string",enum:["boolean","number"]},target:{type:"integer",minimum:1},name:{type:"string",minLength:1},description:{type:"string",minLength:1},lockedName:{type:"string",minLength:1},lockedDescription:{type:"string",minLength:1},hidden:{type:"boolean"}},required:["type","name","description"],allOf:[{if:{properties:{type:{const:"number"}}},then:{required:["target"]}},{if:{properties:{type:{const:"boolean"}}},then:{not:{required:["target"]}}}],additionalProperties:!1};function ui(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};r===null?r=[g]:r.push(g),n++}var u=c===n;if(n=o,r!==null&&(o?r.length=o:r=null),u){let g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let b={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[b]:r.push(b),n++}var u=g===n;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}let p=n,m=!0,d=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};r===null?r=[g]:r.push(g),n++}var f=d===n;if(n=p,r!==null&&(p?r.length=p:r=null),f){let g=n,y=n,b=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.target===void 0&&(A="target")){let k={};r===null?r=[k]:r.push(k),n++}}var h=b===n;if(h){let A={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[A]:r.push(A),n++}else n=y,r!==null&&(y?r.length=y:r=null);var f=g===n;m=f}if(!m){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[g]:r.push(g),n++}if(e.name===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[g]:r.push(g),n++}if(e.description===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[g]:r.push(g),n++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),n++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let y={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}if(!(g==="boolean"||g==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Mk.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),n++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[y]:r.push(y),n++}if(typeof g=="number"&&(g<1||isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[y]:r.push(y),n++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),n++}}else{let y={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),n++}}else{let y={instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),n++}}else{let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if($e(g)<1){let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),n++}}else{let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),n++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let g={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),n++}return ui.errors=r,n===0}function Ed(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return ui(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),n=r.length),Ed.errors=r,n===0}var Sd=Od;var Vk={type:"object",required:["type"],$defs:{milliseconds:{type:"integer",minimum:0,maximum:9007199254740991},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{type:"number"},duration:{type:"number"},delay:{$ref:"#/$defs/milliseconds"},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}},auto:{type:"object",required:["duration"],properties:{duration:{$ref:"#/$defs/milliseconds"},delay:{$ref:"#/$defs/milliseconds"},easing:{$ref:"#/$defs/easing"}},additionalProperties:!1}},oneOf:[{required:["keyframes"],not:{required:["auto"]}},{required:["auto"],not:{anyOf:[{required:["initialValue"]},{required:["keyframes"]}]}}],additionalProperties:!1},keyframeTweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}}},required:["keyframes"],additionalProperties:!1},updateTween:{type:"object",properties:{alpha:{$ref:"#/$defs/tweenProperty"},translateX:{$ref:"#/$defs/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},x:{$ref:"#/$defs/tweenProperty"},y:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionTween:{type:"object",properties:{translateX:{$ref:"#/$defs/keyframeTweenProperty"},translateY:{$ref:"#/$defs/keyframeTweenProperty"},alpha:{$ref:"#/$defs/keyframeTweenProperty"},scaleX:{$ref:"#/$defs/keyframeTweenProperty"},scaleY:{$ref:"#/$defs/keyframeTweenProperty"},rotation:{$ref:"#/$defs/keyframeTweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/keyframeTweenProperty"},compositeMaskItem:{type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1},mask:{type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]}},properties:{name:{type:"string"},type:{type:"string",enum:["update","transition"]},complete:{type:"object",properties:{payload:{type:"object"}},additionalProperties:!0},tween:{$ref:"#/$defs/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"},mask:{oneOf:[{$ref:"#/$defs/mask"},{type:"array",minItems:1,items:{allOf:[{$ref:"#/$defs/mask"},{properties:{kind:{const:"single"}}}]}}]}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{not:{required:["tween"]},anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/animationResource.yaml"};function mr(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(!(typeof e=="number"&&!(e%1)&&!isNaN(e))){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[o]:r.push(o),n++}if(typeof e=="number"){if(e>9007199254740991||isNaN(e)){let o={instancePath:t,schemaPath:"#/maximum",keyword:"maximum",params:{comparison:"<=",limit:9007199254740991},message:"must be <= 9007199254740991"};r===null?r=[o]:r.push(o),n++}if(e<0||isNaN(e)){let o={instancePath:t,schemaPath:"#/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[o]:r.push(o),n++}}return mr.errors=r,n===0}var qk={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function yt(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(typeof e!="string"){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let o={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:qk.enum},message:"must be equal to one of the allowed values"};r===null?r=[o]:r.push(o),n++}return yt.errors=r,n===0}function hr(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[o]:r.push(o),n++}if(e.duration===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="startValue"||o==="value"||o==="duration"||o==="delay"||o==="easing"||o==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let o={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.value!==void 0&&typeof e.value!="number"){let o={instancePath:t+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.duration!==void 0&&typeof e.duration!="number"){let o={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.delay!==void 0&&(mr(e.delay,{instancePath:t+"/delay",parentData:e,parentDataProperty:"delay",rootData:a})||(r=r===null?mr.errors:r.concat(mr.errors),n=r.length)),e.easing!==void 0&&(yt(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?yt.errors:r.concat(yt.errors),n=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let o={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return hr.errors=r,n===0}function me(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!1,c=null,u=n,p=n,m=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.auto===void 0&&(I="auto")){let x={};r===null?r=[x]:r.push(x),n++}}var d=m===n;if(d){let I={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),n++}else n=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.keyframes===void 0){let I={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[I]:r.push(I),n++}var P=u===n;P&&(l=!0,c=0);let f=n,h=n,g=n,y=n,b=!1,w=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.initialValue===void 0&&(I="initialValue")){let x={};r===null?r=[x]:r.push(x),n++}}var A=w===n;if(b=b||A,!b){let I=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.keyframes===void 0&&(D="keyframes")){let C={};r===null?r=[C]:r.push(C),n++}}var A=I===n;b=b||A}if(b)n=y,r!==null&&(y?r.length=y:r=null);else{let I={};r===null?r=[I]:r.push(I),n++}var k=g===n;if(k){let I={instancePath:t,schemaPath:"#/oneOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),n++}else n=h,r!==null&&(h?r.length=h:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.auto===void 0){let I={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"auto"},message:"must have required property 'auto'"};r===null?r=[I]:r.push(I),n++}var P=f===n;if(P&&l?(l=!1,c=[c,1]):P&&(l=!0,c=1),l)n=o,r!==null&&(o?r.length=o:r=null);else{let I={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[I]:r.push(I),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let I in e)if(!(I==="initialValue"||I==="keyframes"||I==="auto")){let x={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),n++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let I={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),n++}if(e.keyframes!==void 0){let I=e.keyframes;if(Array.isArray(I)){if(I.length<1){let D={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[D]:r.push(D),n++}let x=I.length;for(let D=0;D<x;D++)hr(I[D],{instancePath:t+"/keyframes/"+D,parentData:I,parentDataProperty:D,rootData:a})||(r=r===null?hr.errors:r.concat(hr.errors),n=r.length)}else{let x={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[x]:r.push(x),n++}}if(e.auto!==void 0){let I=e.auto;if(I&&typeof I=="object"&&!Array.isArray(I)){if(I.duration===void 0){let x={instancePath:t+"/auto",schemaPath:"#/properties/auto/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[x]:r.push(x),n++}for(let x in I)if(!(x==="duration"||x==="delay"||x==="easing")){let D={instancePath:t+"/auto",schemaPath:"#/properties/auto/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"};r===null?r=[D]:r.push(D),n++}I.duration!==void 0&&(mr(I.duration,{instancePath:t+"/auto/duration",parentData:I,parentDataProperty:"duration",rootData:a})||(r=r===null?mr.errors:r.concat(mr.errors),n=r.length)),I.delay!==void 0&&(mr(I.delay,{instancePath:t+"/auto/delay",parentData:I,parentDataProperty:"delay",rootData:a})||(r=r===null?mr.errors:r.concat(mr.errors),n=r.length)),I.easing!==void 0&&(yt(I.easing,{instancePath:t+"/auto/easing",parentData:I,parentDataProperty:"easing",rootData:a})||(r=r===null?yt.errors:r.concat(yt.errors),n=r.length))}else{let x={instancePath:t+"/auto",schemaPath:"#/properties/auto/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),n++}}}else{let I={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),n++}return me.errors=r,n===0}function pi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="alpha"||o==="translateX"||o==="translateY"||o==="x"||o==="y"||o==="scaleX"||o==="scaleY"||o==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}e.alpha!==void 0&&(me(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length)),e.translateX!==void 0&&(me(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length)),e.translateY!==void 0&&(me(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length)),e.x!==void 0&&(me(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length)),e.y!==void 0&&(me(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length)),e.scaleX!==void 0&&(me(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length)),e.scaleY!==void 0&&(me(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length)),e.rotation!==void 0&&(me(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?me.errors:r.concat(me.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return pi.errors=r,n===0}function Ee(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let o={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),n++}let l=o.length;for(let c=0;c<l;c++)hr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?hr.errors:r.concat(hr.errors),n=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ee.errors=r,n===0}function fi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="translateX"||o==="translateY"||o==="alpha"||o==="scaleX"||o==="scaleY"||o==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}e.translateX!==void 0&&(Ee(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),n=r.length)),e.translateY!==void 0&&(Ee(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),n=r.length)),e.alpha!==void 0&&(Ee(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),n=r.length)),e.scaleX!==void 0&&(Ee(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),n=r.length)),e.scaleY!==void 0&&(Ee(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),n=r.length)),e.rotation!==void 0&&(Ee(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?Ee.errors:r.concat(Ee.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return fi.errors=r,n===0}function dt(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(o!=="tween"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}e.tween!==void 0&&(fi(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return dt.errors=r,n===0}var Bs={type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]},Fk={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function di(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="texture"||o==="channel"||o==="invert")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.texture!==void 0&&typeof e.texture!="string"){let o={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.channel!==void 0){let o=e.channel;if(typeof o!="string"){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(!(o==="red"||o==="green"||o==="blue"||o==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Fk.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let o={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return di.errors=r,n===0}function mi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let o={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),n++}let l=o.length;for(let c=0;c<l;c++)hr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?hr.errors:r.concat(hr.errors),n=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return mi.errors=r,n===0}function mt(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let w={};r===null?r=[w]:r.push(w),n++}var u=c===n;if(n=o,r!==null&&(o?r.length=o:r=null),u){let w=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let k={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),n++}var u=w===n;l=u}if(!l){let w={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),n++}let p=n,m=!0,d=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let w={};r===null?r=[w]:r.push(w),n++}var f=d===n;if(n=p,r!==null&&(p?r.length=p:r=null),f){let w=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let k={instancePath:t,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};r===null?r=[k]:r.push(k),n++}var f=w===n;m=f}if(!m){let w={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),n++}let h=n,g=!0,y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let w={};r===null?r=[w]:r.push(w),n++}var b=y===n;if(n=h,r!==null&&(h?r.length=h:r=null),b){let w=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let k={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};r===null?r=[k]:r.push(k),n++}var b=w===n;g=b}if(!g){let w={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let w={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[w]:r.push(w),n++}for(let w in e)if(!Ze.call(Bs.properties,w)){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:w},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),n++}if(e.kind!==void 0){let w=e.kind;if(typeof w!="string"){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),n++}if(!(w==="single"||w==="sequence"||w==="composite")){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Bs.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),n++}}if(e.texture!==void 0&&typeof e.texture!="string"){let w={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),n++}if(e.textures!==void 0){let w=e.textures;if(Array.isArray(w)){if(w.length<1){let k={instancePath:t+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),n++}let A=w.length;for(let k=0;k<A;k++)if(typeof w[k]!="string"){let P={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}}else{let A={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),n++}}if(e.items!==void 0){let w=e.items;if(Array.isArray(w)){if(w.length<1){let k={instancePath:t+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),n++}let A=w.length;for(let k=0;k<A;k++)di(w[k],{instancePath:t+"/items/"+k,parentData:w,parentDataProperty:k,rootData:a})||(r=r===null?di.errors:r.concat(di.errors),n=r.length)}else{let A={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),n++}}if(e.combine!==void 0){let w=e.combine;if(typeof w!="string"){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),n++}if(!(w==="max"||w==="min"||w==="multiply"||w==="add")){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Bs.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),n++}}if(e.channel!==void 0){let w=e.channel;if(typeof w!="string"){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),n++}if(!(w==="red"||w==="green"||w==="blue"||w==="alpha")){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Bs.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),n++}}if(e.softness!==void 0&&typeof e.softness!="number"){let w={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),n++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let w={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[w]:r.push(w),n++}if(e.sample!==void 0&&typeof e.sample!="string"){let w={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),n++}e.progress!==void 0&&(mi(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),n=r.length))}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),n++}return mt.errors=r,n===0}function yi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let A={};r===null?r=[A]:r.push(A),n++}var u=c===n;if(n=o,r!==null&&(o?r.length=o:r=null),u){let A=n,k=n,P=n,I=n,x=!1,D=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let _;if(e.prev===void 0&&(_="prev")){let q={};r===null?r=[q]:r.push(q),n++}}var p=D===n;if(x=x||p,!x){let _=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let X;if(e.next===void 0&&(X="next")){let re={};r===null?r=[re]:r.push(re),n++}}var p=_===n;if(x=x||p,!x){let X=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.mask===void 0&&(R="mask")){let M={};r===null?r=[M]:r.push(M),n++}}var p=X===n;x=x||p}}if(x)n=I,r!==null&&(I?r.length=I:r=null);else{let _={};r===null?r=[_]:r.push(_),n++}var m=P===n;if(m){let _={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[_]:r.push(_),n++}else n=k,r!==null&&(k?r.length=k:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let _={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[_]:r.push(_),n++}var u=A===n;l=u}if(!l){let A={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[A]:r.push(A),n++}let d=n,f=!0,h=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let A={};r===null?r=[A]:r.push(A),n++}var g=h===n;if(n=d,r!==null&&(d?r.length=d:r=null),g){let A=n,k=n,P=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let _;if(e.tween===void 0&&(_="tween")){let q={};r===null?r=[q]:r.push(q),n++}}var y=P===n;if(y){let _={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[_]:r.push(_),n++}else n=k,r!==null&&(k?r.length=k:r=null);let I=n,x=!1,D=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let _={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[_]:r.push(_),n++}var b=D===n;if(x=x||b,!x){let _=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let X={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[X]:r.push(X),n++}var b=_===n;if(x=x||b,!x){let X=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[R]:r.push(R),n++}var b=X===n;x=x||b}}if(x)n=I,r!==null&&(I?r.length=I:r=null);else{let _={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[_]:r.push(_),n++}var g=A===n;f=g}if(!f){let A={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[A]:r.push(A),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let A={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[A]:r.push(A),n++}for(let A in e)if(!(A==="name"||A==="type"||A==="complete"||A==="tween"||A==="prev"||A==="next"||A==="mask")){let k={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:A},message:"must NOT have additional properties"};r===null?r=[k]:r.push(k),n++}if(e.name!==void 0&&typeof e.name!="string"){let A={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),n++}if(e.type!==void 0){let A=e.type;if(typeof A!="string"){let k={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[k]:r.push(k),n++}if(!(A==="update"||A==="transition")){let k={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Vk.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[k]:r.push(k),n++}}if(e.complete!==void 0){let A=e.complete;if(A&&typeof A=="object"&&!Array.isArray(A)){if(A.payload!==void 0){let k=A.payload;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let P={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),n++}}}else{let k={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),n++}}if(e.tween!==void 0&&(pi(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),n=r.length)),e.prev!==void 0&&(dt(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?dt.errors:r.concat(dt.errors),n=r.length)),e.next!==void 0&&(dt(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?dt.errors:r.concat(dt.errors),n=r.length)),e.mask!==void 0){let A=e.mask,k=n,P=!1,I=null,x=n;mt(A,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?mt.errors:r.concat(mt.errors),n=r.length);var w=x===n;w&&(P=!0,I=0);let D=n;if(Array.isArray(A)){if(A.length<1){let _={instancePath:t+"/mask",schemaPath:"#/properties/mask/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[_]:r.push(_),n++}let C=A.length;for(let _=0;_<C;_++){let q=A[_];if(mt(q,{instancePath:t+"/mask/"+_,parentData:A,parentDataProperty:_,rootData:a})||(r=r===null?mt.errors:r.concat(mt.errors),n=r.length),q&&typeof q=="object"&&!Array.isArray(q)&&q.kind!==void 0&&q.kind!=="single"){let X={instancePath:t+"/mask/"+_+"/kind",schemaPath:"#/properties/mask/oneOf/1/items/allOf/1/properties/kind/const",keyword:"const",params:{allowedValue:"single"},message:"must be equal to constant"};r===null?r=[X]:r.push(X),n++}}}else{let C={instancePath:t+"/mask",schemaPath:"#/properties/mask/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[C]:r.push(C),n++}var w=D===n;if(w&&P?(P=!1,I=[I,1]):w&&(P=!0,I=1),P)n=k,r!==null&&(k?r.length=k:r=null);else{let C={instancePath:t+"/mask",schemaPath:"#/properties/mask/oneOf",keyword:"oneOf",params:{passingSchemas:I},message:"must match exactly one schema in oneOf"};r===null?r=[C]:r.push(C),n++}}}else{let A={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[A]:r.push(A),n++}return yi.errors=r,n===0}function Od(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return yi(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),n=r.length),Od.errors=r,n===0}var Rd=$d;var Bk={type:"object",required:["type"],$defs:{easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},panKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:-1,maximum:1}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:-1,maximum:1}}}}]},playbackRateKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0}}}}]},volumeTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:-1,maximum:1},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},propertyTracks:{type:"object",minProperties:1,properties:{volume:{$ref:"#/$defs/volumeTweenProperty"},pan:{$ref:"#/$defs/panTweenProperty"},playbackRate:{$ref:"#/$defs/playbackRateTweenProperty"}},additionalProperties:!1}},properties:{name:{type:"string"},type:{enum:["update","transition"]},tween:{$ref:"#/$defs/propertyTracks"},prev:{$ref:"#/$defs/propertyTracks"},next:{$ref:"#/$defs/propertyTracks"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{anyOf:[{required:["prev"]},{required:["next"]}],not:{required:["tween"]}}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/audioEffectResource.yaml"};function hi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(typeof e!="number"){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}return hi.errors=r,n===0}var Uk={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function gi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(typeof e!="string"){let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let o={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:Uk.enum},message:"must be equal to one of the allowed values"};r===null?r=[o]:r.push(o),n++}return gi.errors=r,n===0}function gr(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[o]:r.push(o),n++}if(e.duration===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="startValue"||o==="value"||o==="duration"||o==="delay"||o==="easing"||o==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let o={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.value!==void 0&&(hi(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),n=r.length)),e.duration!==void 0){let o=e.duration;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.delay!==void 0){let o=e.delay;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.easing!==void 0&&(gi(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),n=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let o={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return gr.errors=r,n===0}function bi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;gr(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?gr.errors:r.concat(gr.errors),n=r.length);let o=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let b={};r===null?r=[b]:r.push(b),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=o,r!==null&&(o?r.length=o:r=null),p){let g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let b=e.value;if(typeof b=="number"){if(b>100||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),n++}if(b<0||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),n++}}}var p=g===n;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}let m=n,d=!0,f=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),n++}var h=f===n;if(n=m,r!==null&&(m?r.length=m:r=null),h){let g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let b=e.startValue;if(typeof b=="number"){if(b>100||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),n++}if(b<0||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),n++}}}var h=g===n;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}return bi.errors=r,n===0}function wi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.initialValue!==void 0){let o=e.initialValue;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),n++}let l=o.length;for(let c=0;c<l;c++)bi(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),n=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return wi.errors=r,n===0}function Ii(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;gr(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?gr.errors:r.concat(gr.errors),n=r.length);let o=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let b={};r===null?r=[b]:r.push(b),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=o,r!==null&&(o?r.length=o:r=null),p){let g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let b=e.value;if(typeof b=="number"){if(b>1||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),n++}if(b<-1||isNaN(b)){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),n++}}}var p=g===n;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}let m=n,d=!0,f=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),n++}var h=f===n;if(n=m,r!==null&&(m?r.length=m:r=null),h){let g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let b=e.startValue;if(typeof b=="number"){if(b>1||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),n++}if(b<-1||isNaN(b)){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),n++}}}var h=g===n;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}return Ii.errors=r,n===0}function vi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.initialValue!==void 0){let o=e.initialValue;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<-1||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),n++}let l=o.length;for(let c=0;c<l;c++)Ii(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),n=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return vi.errors=r,n===0}function ki(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;gr(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?gr.errors:r.concat(gr.errors),n=r.length);let o=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let b={};r===null?r=[b]:r.push(b),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=o,r!==null&&(o?r.length=o:r=null),p){let g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let b=e.value;if(typeof b=="number"&&(b<0||isNaN(b))){let w={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),n++}}var p=g===n;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}let m=n,d=!0,f=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),n++}var h=f===n;if(n=m,r!==null&&(m?r.length=m:r=null),h){let g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let b=e.startValue;if(typeof b=="number"&&(b<0||isNaN(b))){let w={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),n++}}var h=g===n;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}return ki.errors=r,n===0}function Ai(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.initialValue!==void 0){let o=e.initialValue;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),n++}let l=o.length;for(let c=0;c<l;c++)ki(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),n=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ai.errors=r,n===0}function fr(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="volume"||o==="pan"||o==="playbackRate")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}e.volume!==void 0&&(wi(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),n=r.length)),e.pan!==void 0&&(vi(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),n=r.length)),e.playbackRate!==void 0&&(Ai(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),n=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return fr.errors=r,n===0}function Pi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let w={};r===null?r=[w]:r.push(w),n++}var u=c===n;if(n=o,r!==null&&(o?r.length=o:r=null),u){let w=n,A=n,k=n,P=n,I=!1,x=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.prev===void 0&&(C="prev")){let _={};r===null?r=[_]:r.push(_),n++}}var p=x===n;if(I=I||p,!I){let C=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.next===void 0&&(q="next")){let X={};r===null?r=[X]:r.push(X),n++}}var p=C===n;I=I||p}if(I)n=P,r!==null&&(P?r.length=P:r=null);else{let C={};r===null?r=[C]:r.push(C),n++}var m=k===n;if(m){let C={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),n++}else n=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let C={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[C]:r.push(C),n++}var u=w===n;l=u}if(!l){let w={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),n++}let d=n,f=!0,h=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let w={};r===null?r=[w]:r.push(w),n++}var g=h===n;if(n=d,r!==null&&(d?r.length=d:r=null),g){let w=n,A=n,k=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.tween===void 0&&(C="tween")){let _={};r===null?r=[_]:r.push(_),n++}}var y=k===n;if(y){let C={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),n++}else n=A,r!==null&&(A?r.length=A:r=null);let P=n,I=!1,x=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[C]:r.push(C),n++}var b=x===n;if(I=I||b,!I){let C=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let q={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[q]:r.push(q),n++}var b=C===n;I=I||b}if(I)n=P,r!==null&&(P?r.length=P:r=null);else{let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[C]:r.push(C),n++}var g=w===n;f=g}if(!f){let w={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[w]:r.push(w),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let w={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[w]:r.push(w),n++}for(let w in e)if(!(w==="name"||w==="type"||w==="tween"||w==="prev"||w==="next")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:w},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),n++}if(e.name!==void 0&&typeof e.name!="string"){let w={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),n++}if(e.type!==void 0){let w=e.type;if(!(w==="update"||w==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Bk.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),n++}}e.tween!==void 0&&(fr(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),n=r.length)),e.prev!==void 0&&(fr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),n=r.length)),e.next!==void 0&&(fr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),n=r.length))}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),n++}return Pi.errors=r,n===0}function $d(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Pi(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),n=r.length),$d.errors=r,n===0}var Cd=_d;function xi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="name"||o==="nameVariableId"||o==="variables")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.name!==void 0&&typeof e.name!="string"){let o={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.nameVariableId!==void 0){let o=e.nameVariableId;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}if(e.variables!==void 0){let o=e.variables;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/variables",schemaPath:"#/properties/variables/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return xi.errors=r,n===0}function _d(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return xi(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),n=r.length),_d.errors=r,n===0}var Nd=jd;var Yk=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function Ei(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(o!=="hex"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.hex!==void 0){let o=e.hex;if(typeof o=="string"){if(!Yk.test(o)){let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/pattern",keyword:"pattern",params:{pattern:"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"},message:'must match pattern "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"'};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ei.errors=r,n===0}function jd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Ei(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),n=r.length),jd.errors=r,n===0}var Td=Dd;function Si(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let o=e.keyboard;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyboard/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),n++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),n++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}}else{let u={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),n++}}else{let l={instancePath:t+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}if(e.keyup!==void 0){let o=e.keyup;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyup/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyup/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}}else{let u={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),n++}}else{let l={instancePath:t+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}}if(e.elements!==void 0){let o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Si.errors=r,n===0}function Dd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Si(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Si.errors:r.concat(Si.errors),n=r.length),Dd.errors=r,n===0}var Ld=Md;function Oi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="fileId"||o==="fileType")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Oi.errors=r,n===0}function Md(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Oi(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Oi.errors:r.concat(Oi.errors),n=r.length),Md.errors=r,n===0}var Vd=qd;function Ri(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),n++}if(e.width===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[o]:r.push(o),n++}if(e.height===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="fileId"||o==="fileType"||o==="width"||o==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.width!==void 0){let o=e.width;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),n++}}if(e.height!==void 0){let o=e.height;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ri.errors=r,n===0}function qd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Ri(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Ri.errors:r.concat(Ri.errors),n=r.length),qd.errors=r,n===0}var Fd=Bd;function $i(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),n++}if(e.type===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[o]:r.push(o),n++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if($e(o)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}}if(e.type!==void 0&&e.type!=="shader"){let o={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return $i.errors=r,n===0}var Jf=new RegExp("^\\$(if .+|for .+|else)$","u"),sl={validate:Sn};function Ci(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!Jf.test(o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}for(let o in e)if(Jf.test(o)){let l=e[o];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)sl.validate(l[u],{instancePath:t+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?sl.validate.errors:r.concat(sl.validate.errors),n=r.length)}else{let c={instancePath:t+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ci.errors=r,n===0}function Sn(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!1,c=n;$i(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?$i.errors:r.concat($i.errors),n=r.length);var u=c===n;if(l=l||u,!l){let p=n;Ci(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Ci.errors:r.concat(Ci.errors),n=r.length);var u=p===n;l=l||u}if(l)n=o,r!==null&&(o?r.length=o:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),n++}return Sn.errors=r,n===0}function _i(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(Array.isArray(e)){let o=e.length;for(let l=0;l<o;l++)Sn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?Sn.errors:r.concat(Sn.errors),n=r.length)}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[o]:r.push(o),n++}return _i.errors=r,n===0}var il={validate:On};function On(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(_i(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?_i.errors:r.concat(_i.errors),n=r.length)),e.children!==void 0){let o=e.children;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++)il.validate(o[c],{instancePath:t+"/children/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?il.validate.errors:r.concat(il.validate.errors),n=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return On.errors=r,n===0}function Ni(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width!==void 0){let o=e.width;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.height!==void 0){let o=e.height;if(typeof o=="number"){if(o<=0||isNaN(o)){let l={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.paginationSize!==void 0){let o=e.paginationSize;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/paginationSize",schemaPath:"#/properties/paginationSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),n++}if(typeof o=="number"&&(o<1||isNaN(o))){let l={instancePath:t+"/paginationSize",schemaPath:"#/properties/paginationSize/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[l]:r.push(l),n++}}if(e.elements!==void 0){let o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++)On(o[c],{instancePath:t+"/elements/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?On.errors:r.concat(On.errors),n=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}if(e.transitions!==void 0){let o={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ni.errors=r,n===0}function Bd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Ni(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Ni.errors:r.concat(Ni.errors),n=r.length),Bd.errors=r,n===0}var Ud=Yd;function ji(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0,o=n,l=!1,c=null,u=n,p=n,m=n,d=n,f=!1,h=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let P={};r===null?r=[P]:r.push(P),n++}}var g=h===n;if(f=f||g,!f){let k=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.texture===void 0&&(I="texture")){let x={};r===null?r=[x]:r.push(x),n++}}var g=k===n;if(f=f||g,!f){let I=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.behaviors===void 0&&(D="behaviors")){let C={};r===null?r=[C]:r.push(C),n++}}var g=I===n;if(f=f||g,!f){let D=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let _;if(e.emitter===void 0&&(_="emitter")){let q={};r===null?r=[q]:r.push(q),n++}}var g=D===n;f=f||g}}}if(f)n=d,r!==null&&(d?r.length=d:r=null);else{let k={};r===null?r=[k]:r.push(k),n++}var y=m===n;if(y){let k={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[k]:r.push(k),n++}else n=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let k={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};r===null?r=[k]:r.push(k),n++}var w=u===n;w&&(l=!0,c=0);let b=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),n++}if(e.behaviors===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};r===null?r=[k]:r.push(k),n++}if(e.emitter===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};r===null?r=[k]:r.push(k),n++}}var w=b===n;if(w&&l?(l=!1,c=[c,1]):w&&(l=!0,c=1),l)n=o,r!==null&&(o?r.length=o:r=null);else{let k={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[k]:r.push(k),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[k]:r.push(k),n++}if(e.height===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[k]:r.push(k),n++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let P={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[P]:r.push(P),n++}}else{let P={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[P]:r.push(P),n++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let P={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[P]:r.push(P),n++}}else{let P={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[P]:r.push(P),n++}}if(e.seed!==void 0&&typeof e.seed!="number"){let k={instancePath:t+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),n++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let P={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[P]:r.push(P),n++}if(k.appearance===void 0){let P={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[P]:r.push(P),n++}for(let P in k)if(!(P==="emission"||P==="movement"||P==="appearance"||P==="bounds")){let I={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};r===null?r=[I]:r.push(I),n++}if(k.emission!==void 0){let P=k.emission;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),n++}}if(k.movement!==void 0){let P=k.movement;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),n++}}if(k.appearance!==void 0){let P=k.appearance;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),n++}}if(k.bounds!==void 0){let P=k.bounds;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let I={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),n++}}}else{let P={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),n++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let P={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[P]:r.push(P),n++}if(typeof k=="number"&&(k<1||isNaN(k))){let P={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[P]:r.push(P),n++}}if(e.texture!==void 0){let k=e.texture,P=n,I=!1,x=null,D=n;if(typeof k=="string"){if($e(k)<1){let _={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[_]:r.push(_),n++}}else{let _={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[_]:r.push(_),n++}var A=D===n;A&&(I=!0,x=0);let C=n;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let _={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[_]:r.push(_),n++}var A=C===n;if(A&&I?(I=!1,x=[x,1]):A&&(I=!0,x=1),I)n=P,r!==null&&(P?r.length=P:r=null);else{let _={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:x},message:"must match exactly one schema in oneOf"};r===null?r=[_]:r.push(_),n++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let I={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[I]:r.push(I),n++}let P=k.length;for(let I=0;I<P;I++){let x=k[I];if(x&&typeof x=="object"&&!Array.isArray(x)){if(x.type===void 0){let D={instancePath:t+"/behaviors/"+I,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[D]:r.push(D),n++}for(let D in x)if(!(D==="type"||D==="config")){let C={instancePath:t+"/behaviors/"+I,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:D},message:"must NOT have additional properties"};r===null?r=[C]:r.push(C),n++}if(x.type!==void 0){let D=x.type;if(typeof D=="string"){if($e(D)<1){let C={instancePath:t+"/behaviors/"+I+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[C]:r.push(C),n++}}else{let C={instancePath:t+"/behaviors/"+I+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[C]:r.push(C),n++}}if(x.config!==void 0){let D=x.config;if(!(D&&typeof D=="object"&&!Array.isArray(D))){let C={instancePath:t+"/behaviors/"+I+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[C]:r.push(C),n++}}}else{let D={instancePath:t+"/behaviors/"+I,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[D]:r.push(D),n++}}}else{let P={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[P]:r.push(P),n++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let P={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[P]:r.push(P),n++}if(k.lifetime!==void 0){let P=k.lifetime;if(P&&typeof P=="object"&&!Array.isArray(P)){if(P.min===void 0){let I={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[I]:r.push(I),n++}if(P.max===void 0){let I={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[I]:r.push(I),n++}if(P.min!==void 0){let I=P.min;if(typeof I=="number"){if(I<0||isNaN(I)){let x={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),n++}}else{let x={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),n++}}if(P.max!==void 0){let I=P.max;if(typeof I=="number"){if(I<0||isNaN(I)){let x={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[x]:r.push(x),n++}}else{let x={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[x]:r.push(x),n++}}}else{let I={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[I]:r.push(I),n++}}}else{let P={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),n++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),n++}return ji.errors=r,n===0}function Yd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return ji(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?ji.errors:r.concat(ji.errors),n=r.length),Yd.errors=r,n===0}var zd=Xd;var Qf={type:"object",properties:{fileId:{type:"string"},fileType:{type:"string"},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["fileId"],additionalProperties:!1};function Ti(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!Ze.call(Qf.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),n++}if(o<0||isNaN(o)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(o<-1||isNaN(o)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.startDelayMs!==void 0){let o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.playbackRate!==void 0){let o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.startAt!==void 0){let o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}if(e.endAt!==void 0){let o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Qf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}if(typeof o=="number"&&(o<0||isNaN(o))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Ti.errors=r,n===0}function Xd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Ti(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Ti.errors:r.concat(Ti.errors),n=r.length),Xd.errors=r,n===0}var Gd=Hd;var zk=new RegExp("^.+$","u");function Di(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[l]:r.push(l),n++}if(e.jsonData===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};r===null?r=[l]:r.push(l),n++}if(e.width===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[l]:r.push(l),n++}if(e.height===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[l]:r.push(l),n++}for(let l in e)if(!(l==="fileId"||l==="jsonData"||l==="width"||l==="height"||l==="animations")){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),n++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let l={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(e.jsonData!==void 0){let l=e.jsonData;if(!(l&&typeof l=="object"&&!Array.isArray(l))){let c={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),n++}}if(e.width!==void 0){let l=e.width;if(!(typeof l=="number"&&!(l%1)&&!isNaN(l))){let c={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[c]:r.push(c),n++}}if(e.height!==void 0){let l=e.height;if(!(typeof l=="number"&&!(l%1)&&!isNaN(l))){let c={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[c]:r.push(c),n++}}if(e.animations!==void 0){let l=e.animations;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(zk.test(c)){let u=l[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.frames===void 0){let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/required",keyword:"required",params:{missingProperty:"frames"},message:"must have required property 'frames'"};r===null?r=[p]:r.push(p),n++}for(let p in u)if(!(p==="frames"||p==="animationSpeed"||p==="loop")){let m={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(u.frames!==void 0){let p=u.frames;if(Array.isArray(p)){let m=p.length;for(let d=0;d<m;d++){let f=p[d],h=n,g=!1,y=null,b=n;if(typeof f!="number"){let A={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/oneOf/0/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[A]:r.push(A),n++}var o=b===n;o&&(g=!0,y=0);let w=n;if(typeof f!="string"){let A={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/oneOf/1/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),n++}var o=w===n;if(o&&g?(g=!1,y=[y,1]):o&&(g=!0,y=1),g)n=h,r!==null&&(h?r.length=h:r=null);else{let A={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/oneOf",keyword:"oneOf",params:{passingSchemas:y},message:"must match exactly one schema in oneOf"};r===null?r=[A]:r.push(A),n++}}}else{let m={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),n++}}if(u.animationSpeed!==void 0&&typeof u.animationSpeed!="number"){let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/animationSpeed",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[p]:r.push(p),n++}if(u.loop!==void 0&&typeof u.loop!="boolean"){let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1")+"/loop",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[p]:r.push(p),n++}}else{let p={instancePath:t+"/animations/"+c.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}}}else{let c={instancePath:t+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),n++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}return Di.errors=r,n===0}function Hd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Di(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Di.errors:r.concat(Di.errors),n=r.length),Hd.errors=r,n===0}var Kd=Wd;var ol={type:"object",properties:{fontId:{oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1}}]},colorId:{type:"string"},colorAlpha:{type:"number"},fontSize:{type:"number"},fontWeight:{type:["string","number"]},fontStyle:{type:"string",enum:["normal","italic","oblique"]},lineHeight:{type:"number"},align:{type:"string"},wordWrap:{type:"boolean"},breakWords:{type:"boolean"},wordWrapWidth:{type:"number"},strokeColorId:{type:"string"},strokeAlpha:{type:"number"},strokeWidth:{type:"number"},shadow:{type:"object",properties:{colorId:{type:"string",minLength:1},alpha:{type:"number",minimum:0,maximum:1},blur:{type:"number",minimum:0},offsetX:{type:"number"},offsetY:{type:"number"}},required:["colorId"],additionalProperties:!1}},required:["fontId","fontSize","fontWeight","fontStyle","lineHeight","colorId"],additionalProperties:!1};function Li(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};r===null?r=[l]:r.push(l),n++}if(e.fontSize===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};r===null?r=[l]:r.push(l),n++}if(e.fontWeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};r===null?r=[l]:r.push(l),n++}if(e.fontStyle===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};r===null?r=[l]:r.push(l),n++}if(e.lineHeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};r===null?r=[l]:r.push(l),n++}if(e.colorId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[l]:r.push(l),n++}for(let l in e)if(!Ze.call(ol.properties,l)){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),n++}if(e.fontId!==void 0){let l=e.fontId,c=n,u=!1,p=null,m=n;if(typeof l=="string"){if($e(l)<1){let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[f]:r.push(f),n++}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),n++}var o=m===n;o&&(u=!0,p=0);let d=n;if(Array.isArray(l)){if(l.length<1){let y={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[y]:r.push(y),n++}let f=l.length;for(let y=0;y<f;y++){let b=l[y];if(typeof b=="string"){if($e(b)<1){let w={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[w]:r.push(w),n++}}else{let w={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),n++}}let h=l.length,g;if(h>1){let y={};for(;h--;){let b=l[h];if(typeof b=="string"){if(typeof y[b]=="number"){g=y[b];let w={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:h,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+h+" are identical)"};r===null?r=[w]:r.push(w),n++;break}y[b]=h}}}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),n++}var o=d===n;if(o&&u?(u=!1,p=[p,1]):o&&(u=!0,p=1),u)n=c,r!==null&&(c?r.length=c:r=null);else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),n++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:t+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:t+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}if(e.fontWeight!==void 0){let l=e.fontWeight;if(typeof l!="string"&&typeof l!="number"){let c={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:ol.properties.fontWeight.type},message:"must be string,number"};r===null?r=[c]:r.push(c),n++}}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),n++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:ol.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),n++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:t+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:t+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:t+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),n++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:t+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),n++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:t+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:t+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),n++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:t+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:t+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[c]:r.push(c),n++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),n++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if($e(c)<1){let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[u]:r.push(u),n++}}else{let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),n++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[u]:r.push(u),n++}if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),n++}}else{let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),n++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),n++}}else{let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),n++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:t+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),n++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:t+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),n++}}else{let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),n++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}return Li.errors=r,n===0}function Wd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Li(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Li.errors:r.concat(Li.errors),n=r.length),Wd.errors=r,n===0}var Jd=Qd;var Xk={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function Mi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!Ze.call(Xk.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.x!==void 0){let o=e.x;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),n++}}if(e.y!==void 0){let o=e.y;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),n++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let o={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let o={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),n++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),n++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Mi.errors=r,n===0}function Qd(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Mi(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Mi.errors:r.concat(Mi.errors),n=r.length),Qd.errors=r,n===0}var Zd=em;function Vi(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),n++}if(e.width===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[o]:r.push(o),n++}if(e.height===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[o]:r.push(o),n++}for(let o in e)if(!(o==="fileId"||o==="fileType"||o==="width"||o==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),n++}if(e.width!==void 0){let o=e.width;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),n++}}if(e.height!==void 0){let o=e.height;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),n++}}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),n++}return Vi.errors=r,n===0}function em(e,{instancePath:t="",parentData:s,parentDataProperty:i,rootData:a=e}={}){let r=null,n=0;return Vi(e,{instancePath:t,parentData:s,parentDataProperty:i,rootData:a})||(r=r===null?Vi.errors:r.concat(Vi.errors),n=r.length),em.errors=r,n===0}var Cn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),$n=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$r=e=>e===void 0?void 0:structuredClone(e),Gk=Object.freeze({achievement:"achievements",animation:"animations",audioEffect:"audioEffects",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),Hk=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Kk=Object.freeze({background:Zf,bgm:rd,character:nd,choice:id,cleanAll:ad,control:cd,dialogue:pd,form:dd,layout:yd,screen:gd,sfx:wd,visual:vd,voice:Ad}),Wk=Object.freeze({achievement:xd,animation:Sd,audioEffect:Rd,character:Cd,color:Nd,control:Td,font:Ld,image:Vd,layout:Fd,particle:Ud,sound:zd,spritesheet:Gd,textStyle:Kd,transform:Jd,video:Zd}),Jk=new Set(["files","language","patches"]),Qk=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Zk=new Set(["lineId","mode","payload","type"]),eA=new Set(["mode","payload","sceneId","type"]),rA=new Set(["mode","operation","payload","resourceId","type"]),tA=new Set(["fileId","mimeType"]),W=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},ir=(e,t)=>{$n(e)||W(t,"expected an object")},ll=(e,t)=>{Array.isArray(e)||W(t,"expected an array")},qt=(e,t)=>{(typeof e!="string"||e.length===0)&&W(t,"expected a non-empty string")},sm=(e,t)=>{typeof e!="string"&&W(t,"expected a string")},wr=(e,t,s)=>{for(let i of Object.keys(e))t.has(i)||W(`${s}.${i}`,"unknown field")},Ir=(e,t,s)=>{for(let i of t)Cn(e,i)||W(s,`missing required field "${i}"`)},nA=e=>e.replaceAll("~1","/").replaceAll("~0","~"),sA=(e,t)=>{let s=(t?.instancePath??"").split("/").slice(1).map(nA);return t?.keyword==="required"?s.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&s.push(t.params.additionalProperty),s.reduce((i,a)=>/^\d+$/.test(a)?`${i}[${a}]`:`${i}.${a}`,e)},iA=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,s)=>{if(t===void 0)return s;let i=s.instancePath.split("/").length,a=t.instancePath.split("/").length;return i>a?s:t},void 0)??e[0],im=({value:e,validator:t,path:s,contract:i})=>{if(t(e))return;let a=iA(t.errors);W(sA(s,a),`does not match ${i}: ${a?.message??"schema validation failed"}`)},qi=(e,t,s=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||W(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||s.has(e))){if(s.add(e),Array.isArray(e)){e.forEach((i,a)=>qi(i,`${t}[${a}]`,s));return}Object.entries(e).forEach(([i,a])=>qi(a,`${t}.${i}`,s))}},br=(e,t)=>{e===""&&W(t,"expected a non-empty resourceId")},oA=(e,t,s)=>{let i=(n,o)=>br(n?.resourceId,`${o}.resourceId`),a=(n,o)=>(n??[]).forEach((l,c)=>br(l?.resourceId,`${o}[${c}].resourceId`)),r=(n,o)=>{br(n?.resourceId,`${o}.resourceId`),a(n?.sounds,`${o}.sounds`)};switch(e){case"background":br(t.resourceId,`${s}.resourceId`),i(t.animations,`${s}.animations`);break;case"bgm":i(t.audioEffects,`${s}.audioEffects`),r(t,s);break;case"voice":r(t,s);break;case"sfx":a(t.items,`${s}.items`),(t.channels??[]).forEach((n,o)=>a(n?.sounds,`${s}.channels[${o}].sounds`));break;case"character":(t.items??[]).forEach((n,o)=>{(n.sprites??[]).forEach((l,c)=>br(l?.resourceId,`${s}.items[${o}].sprites[${c}].resourceId`)),i(n.animations,`${s}.items[${o}].animations`)});break;case"choice":case"form":case"layout":br(t.resourceId,`${s}.resourceId`),i(t.animations,`${s}.animations`);break;case"control":br(t.resourceId,`${s}.resourceId`);break;case"dialogue":br(t.ui?.resourceId,`${s}.ui.resourceId`),i(t.ui?.animations,`${s}.ui.animations`),(t.character?.sprite?.items??[]).forEach((n,o)=>br(n?.resourceId,`${s}.character.sprite.items[${o}].resourceId`)),i(t.character?.sprite?.animations,`${s}.character.sprite.animations`);break;case"screen":i(t.animations,`${s}.animations`);break;case"visual":(t.items??[]).forEach((n,o)=>{br(n?.resourceId,`${s}.items[${o}].resourceId`),i(n?.animations,`${s}.items[${o}].animations`)});break;default:break}},Ft=(e,t)=>{qt(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&W(t,`"${e}" is not a safe ID`)},aA=(e,t)=>{qt(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&W(t,"must be a safe single filename")},Rn=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((a,r)=>Rn(a,t[r]));if(!$n(e)||!$n(t))return!1;let s=Object.keys(e).sort(),i=Object.keys(t).sort();return Rn(s,i)&&s.every(a=>Rn(e[a],t[a]))},Fi=(e,t=new Set,s=new WeakSet)=>{if(Array.isArray(e))return e.forEach(i=>Fi(i,t,s)),t;if(!$n(e)||s.has(e))return t;s.add(e);for(let[i,a]of Object.entries(e))i==="fileId"&&typeof a=="string"&&t.add(a),Fi(a,t,s);return t},lA=e=>{let t=new Map;for(let[s,i]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(i?.sections??{}))for(let[n,o]of(r?.lines??[]).entries()){if(typeof o?.id!="string")continue;let l=t.get(o.id)??[];l.push({sceneId:s,sectionId:a,lineIndex:n,line:o}),t.set(o.id,l)}return t},om=(e,t,s)=>{let i=e.get(t)??[];return i.length===0&&W(s,`lineId "${t}" does not exist in projectData`),i.length>1&&W(s,`lineId "${t}" is not globally unique in projectData`),i[0]},am=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],rm=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),tm=e=>{let t=$r(e??{});delete t.resourceId,delete t.animations;for(let s of Object.values(t.fields??{}))$n(s)&&delete s.placeholder;return t},cA=(e,t,s,i)=>{e==="choice"&&!Rn(rm(t),rm(s))&&W(i,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Rn(tm(t),tm(s))&&W(i,"form behavior must remain identical; only presentation fields and placeholders may change")},uA=({patch:e,path:t,lineIndex:s})=>{wr(e,Qk,t),Ir(e,["type","lineId","actionType","payload"],t),Ft(e.lineId,`${t}.lineId`),qt(e.actionType,`${t}.actionType`),ir(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&W(`${t}.mode`,'line.action supports only "replace"'),Hk.has(e.actionType)||W(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let i=om(s,e.lineId,`${t}.lineId`),a=i.line?.actions?.[e.actionType];return a===void 0&&W(`${t}.actionType`,`source line "${e.lineId}" does not contain action "${e.actionType}"`),e.actionType==="dialogue"?((!Array.isArray(e.ignoreFields)||e.ignoreFields.length!==1||e.ignoreFields[0]!=="content")&&W(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),Cn(e.payload,"content")&&W(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&W(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),cA(e.actionType,a,e.payload,`${t}.payload`),im({value:e.payload,validator:Kk[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),qi(e.payload,`${t}.payload`),oA(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:i,patch:e}},pA=(e,t)=>{ll(e,t),e.forEach((s,i)=>{ir(s,`${t}[${i}]`),wr(s,new Set(["text"]),`${t}[${i}]`),Ir(s,["text"],`${t}[${i}]`),sm(s.text,`${t}[${i}].text`)})},fA=({patch:e,path:t,lineIndex:s})=>{wr(e,Zk,t),Ir(e,["type","lineId","payload"],t),Ft(e.lineId,`${t}.lineId`),ir(e.payload,`${t}.payload`),wr(e.payload,new Set(["content"]),`${t}.payload`),Ir(e.payload,["content"],`${t}.payload`),pA(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&W(`${t}.mode`,'line.dialogue supports only "replace"');let i=om(s,e.lineId,`${t}.lineId`);return i.line?.actions?.dialogue===void 0&&W(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:i,patch:e}},dA=({patch:e,path:t,projectData:s})=>(wr(e,eA,t),Ir(e,["type","mode","sceneId","payload"],t),Ft(e.sceneId,`${t}.sceneId`),ir(e.payload,`${t}.payload`),wr(e.payload,new Set(["name"]),`${t}.payload`),Ir(e.payload,["name"],`${t}.payload`),sm(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&W(`${t}.mode`,'story.scene requires "patch"'),Cn(s?.story?.scenes??{},e.sceneId)||W(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),mA=(e,t,s)=>{ir(t,s),["font","image","sound","spritesheet","video"].includes(e)&&qt(t.fileId,`${s}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||W(`${s}.width`,"expected an integer"),Number.isInteger(t.height)||W(`${s}.height`,"expected an integer")),e==="spritesheet"&&(ir(t.jsonData,`${s}.jsonData`),Number.isInteger(t.width)||W(`${s}.width`,"expected an integer"),Number.isInteger(t.height)||W(`${s}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&W(`${s}.hex`,"expected an opaque #RGB or #RRGGBB color"),im({value:t,validator:Wk[e],path:s,contract:`the resource.${e} schema`}),qi(t,s)},yA=({patch:e,path:t,projectData:s,packageFileIds:i,canonicalFileIds:a})=>{wr(e,rA,t),Ir(e,["type","resourceId","payload"],t),Ft(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),n=Gk[r];n||W(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&W(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&W(`${t}.operation`,'the only resource operation is "add"'),mA(r,e.payload,`${t}.payload`);let o=s?.resources?.[n]??{},l=Cn(o,e.resourceId);e.operation==="add"&&l&&W(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&W(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of Fi(e.payload))!i.has(c)&&!a.has(c)&&W(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:n,path:t,patch:e}},nm=({resources:e,collectionName:t,resourceId:s,path:i,label:a})=>{s!==void 0&&(typeof s!="string"||s.length===0||!Cn(e?.[t]??{},s))&&W(i,`${a} resource "${s}" was not found`)},hA=(e,t)=>{let s=$r(e);for(let a of t.patches)a.kind==="resource"&&(s.resources[a.collectionName]??={},s.resources[a.collectionName][a.patch.resourceId]=$r(a.patch.payload));let i=s.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,n=Array.isArray(r.fontId)?r.fontId:[r.fontId];n.forEach((o,l)=>nm({resources:i,collectionName:"fonts",resourceId:o,path:`${a.path}.payload.fontId${n.length>1?`[${l}]`:""}`,label:"font"}));for(let[o,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])nm({resources:i,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${o}`,label:"color"})}},gA=({patch:e,path:t,projectData:s,lineIndex:i,packageFileIds:a,canonicalFileIds:r})=>{if(ir(e,t),qt(e.type,`${t}.type`),e.type==="line.action")return uA({patch:e,path:t,lineIndex:i});if(e.type==="line.dialogue")return fA({patch:e,path:t,lineIndex:i});if(e.type==="story.scene")return dA({patch:e,path:t,projectData:s});if(e.type.startsWith("resource."))return yA({patch:e,path:t,projectData:s,packageFileIds:a,canonicalFileIds:r});W(`${t}.type`,`unsupported patch type "${e.type}"`)},bA=(e,t)=>{ll(e,t);let s=new Set;return e.forEach((i,a)=>{let r=`${t}[${a}]`;ir(i,r),wr(i,tA,r),Ir(i,["fileId"],r),aA(i.fileId,`${r}.fileId`),i.mimeType!==void 0&&(typeof i.mimeType!="string"||i.mimeType.length===0)&&W(`${r}.mimeType`,"expected a non-empty string"),s.has(i.fileId)&&W(`${r}.fileId`,`duplicate fileId "${i.fileId}"`),s.add(i.fileId)}),s},wA=({packageId:e,packageData:t,path:s,projectData:i,lineIndex:a,canonicalFileIds:r})=>{ir(t,s),wr(t,Jk,s),Ir(t,["language","files","patches"],s),qt(t.language,`${s}.language`);let n=bA(t.files,`${s}.files`);ll(t.patches,`${s}.patches`);let o=new Set,l=t.patches.map((c,u)=>{let p=gA({patch:c,path:`${s}.patches[${u}]`,projectData:i,lineIndex:a,packageFileIds:n,canonicalFileIds:r});return o.has(p.key)&&W(`${s}.patches[${u}]`,`duplicate patch target "${p.key}"`),o.add(p.key),p});return{id:e,data:t,fileIds:n,patches:l}},lm=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};ir(t,"l10nData"),wr(t,new Set(["packages"]),"l10nData"),Ir(t,["packages"],"l10nData"),ir(t.packages,"l10nData.packages");let s=lA(e),i=Fi(e?.resources??{}),a=new Map,r=new Map;for(let[n,o]of Object.entries(t.packages)){Ft(n,`l10nData.packages.${n}`);let l=wA({packageId:n,packageData:o,path:`l10nData.packages.${n}`,projectData:e,lineIndex:s,canonicalFileIds:i});for(let c of l.fileIds){i.has(c)&&W(`l10nData.packages.${n}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&W(`l10nData.packages.${n}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,n)}hA(e,l),a.set(n,l)}return{packages:a}},IA=(e,t)=>{let{collectionName:s,patch:i}=t;e.resources[s]??={},e.resources[s][i.resourceId]=$r(i.payload)},vA=(e,t)=>{let{patch:s}=t,i=e.story.scenes[s.sceneId];i.name=s.payload.name},kA=(e,t)=>{let{location:s,patch:i}=t,a=am(e,s);if(i.actionType!=="dialogue"){a.actions[i.actionType]=$r(i.payload);return}let r=$r(s.line.actions.dialogue.content);a.actions.dialogue=$r(i.payload),r!==void 0&&(a.actions.dialogue.content=r)},AA=(e,t)=>{let{location:s,patch:i}=t,a=am(e,s);a.actions.dialogue.content=$r(i.payload.content)},cm=({projectData:e,l10nData:t})=>{let s=lm({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(s.packages.values(),i=>({l10nId:i.id,language:i.data.language}))]},Bi=({projectData:e,l10nData:t,l10nId:s=null})=>{let i=lm({projectData:e,l10nData:t});if(s!==null&&(Ft(s,"l10nId"),i.packages.has(s)||W("l10nId",`package "${s}" was not imported`)),s===null)return e;let a=$r(e),r=i.packages.get(s).patches;return r.filter(n=>n.kind==="resource").forEach(n=>IA(a,n)),r.filter(n=>n.kind==="story.scene").forEach(n=>vA(a,n)),r.filter(n=>n.kind==="line.action").forEach(n=>kA(a,n)),r.filter(n=>n.kind==="line.dialogue").forEach(n=>AA(a,n)),a};var cl=Object.freeze({auto:1e3,skip:80,authored:1e3}),jn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),um=new WeakMap,PA=new ArrayBuffer(8),ul=new DataView(PA),xA=e=>{let t=um.get(e);if(t)return t;let s={dispatchDepth:0};return um.set(e,s),s},EA=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},SA=(e,t)=>Object.keys(e).length===t.length&&t.every(i=>Object.prototype.hasOwnProperty.call(e,i)),Gr=(e,t,s)=>{if(!EA(e)||!SA(e,t))throw new TypeError(`${s} has an invalid shape`)},_n=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},Nn=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},pm=e=>{if(Nn(e,"duration"),e===0)return 0n;ul.setFloat64(0,e,!1);let t=ul.getUint32(0,!1),s=ul.getUint32(4,!1),i=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(s);if(i===0)return a;let r=1n<<52n|a,n=i-1;return r<<BigInt(n)},OA=e=>structuredClone(e),pl=(e,t)=>e===t?!0:!e||!t||e.mode!==t.mode||e.kind!==t.kind?!1:e.mode==="legacy"?e.instanceToken===t.instanceToken:e.delayMs!==t.delayMs?!1:e.kind==="auto"?e.contentKey===t.contentKey&&e.owner.sessionId===t.owner.sessionId&&e.owner.lineEntryId===t.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===t.owner.sessionId:e.trigger===t.trigger&&e.owner.lineEntryId===t.owner.lineEntryId,fl=(e,t,s)=>{if(t===null)return null;if(e==="auto"){if(Gr(t,["owner","delayMs","contentKey"],"auto timer"),Gr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),_n(t.owner.sessionId,"auto owner sessionId"),_n(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==s)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(Nn(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Gr(t,["owner","delayMs"],"skip timer"),Gr(t.owner,["sessionId"],"skip timer owner"),_n(t.owner.sessionId,"skip owner sessionId"),Nn(t.delayMs,"skip delayMs");else{if(Gr(t,["owner","delayMs","trigger"],"authored timer"),Gr(t.owner,["lineEntryId"],"authored timer owner"),_n(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==s)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(Nn(t.delayMs,"authored delayMs"),t.trigger!=="fromStart"&&t.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...OA(t)}},RA=e=>{if(Gr(e,["contractVersion","status","lineEntryId","timers"],"playback schedule"),e.contractVersion!==1)throw new TypeError("playback schedule contractVersion must be 1");if(e.status!=="settled"&&e.status!=="unsettled")throw new TypeError('playback schedule status must be "settled" or "unsettled"');if(_n(e.lineEntryId,"playback schedule lineEntryId"),e.status==="unsettled"){if(e.timers!==null)throw new TypeError("unsettled playback schedule timers must be null");return{contractVersion:1,status:"unsettled",lineEntryId:e.lineEntryId,timers:null}}Gr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:fl("auto",e.timers.auto,e.lineEntryId),skip:fl("skip",e.timers.skip,e.lineEntryId),authored:fl("authored",e.timers.authored,e.lineEntryId)};if(t.auto&&t.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:t}},dl=e=>({descriptor:e,remainingQuanta:pm(e.delayMs)}),Ui=["auto","skip","authored"],fm=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:s=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof t!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let i=xA(e),a=!0,r={},n={},o=null,l=null,c=null,u=null,p=!1,m=!1,d="legacy",f={auto:null,skip:null,authored:null},h={auto:null,skip:null,authored:null},g={auto:0,skip:0,authored:0},y=()=>Ui.some(M=>f[M]),b=()=>{l=null,c=null},w=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(i.dispatchDepth>0||m){w();return}a&&r===M.lifecycleToken&&n===M.generationToken&&o===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},A=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=o;M&&(b(),o=null,u=M,e.remove(M),u===M&&(u=null))},P=()=>{f={auto:null,skip:null,authored:null}},I=()=>{P(),n={},m||k()},x=M=>{if(i.dispatchDepth>0||m){c=M,w();return}a&&r===M.lifecycleToken&&n===M.generationToken&&o===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},D=()=>{if(!a||!y()||o)return;A();let M=r,J=n,ue={},H=pe=>{if(!a||M!==r||J!==n||ue!==l||H!==o||m)return;if(!pe||typeof pe.deltaMS!="number"||!Number.isFinite(pe.deltaMS)||pe.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let de=pm(pe.deltaMS);m=!0,i.dispatchDepth+=1;let ke=n,Q=null;try{let N=[];for(let T of Ui){let F=f[T];F&&(F.remainingQuanta<=de?(N.push({kind:T,descriptor:F.descriptor,revision:g[T]}),f[T]=null):F.remainingQuanta-=de)}if(N.length>0){try{t({dueKinds:N.map(({kind:T})=>T)})}catch(T){let F=s(T);if(d==="reconciled"&&F==="preCommit")for(let{kind:K,descriptor:ae}of N)h[K]=ae;else d==="legacy"&&P();throw T}if(d==="legacy")for(let T of N)T.kind==="skip"&&g.skip===T.revision&&f.skip===null&&(f.skip=dl(T.descriptor))}}catch(N){Q=N}finally{i.dispatchDepth-=1,m=!1;try{ke===n?y()?D():k():o===H&&!y()&&k()}catch(N){throw Q?new AggregateError([Q,N],"Playback attempt and ticker cleanup both failed"):N}}if(Q)throw Q},se={callback:H,lifecycleToken:M,generationToken:J,registrationToken:ue};o=H,c=se;try{e.add(H)}catch(pe){throw o=null,b(),P(),n={},u=H,pe}x(se)},C=M=>{g[M]+=1,f[M]=null,h[M]=null,!y()&&!m&&k()},_=(M,J)=>{Nn(J,`${M} delay`),d="legacy",g[M]+=1,h[M]=null,f[M]=dl({mode:"legacy",kind:M,instanceToken:{},delayMs:J}),D()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return _("auto",M.payload?.delay??cl.auto),!0;case"clearAutoNextTimer":return C("auto"),!0;case"startSkipNextTimer":return _("skip",M.payload?.delay??cl.skip),!0;case"clearSkipNextTimer":return C("skip"),!0;case"nextLineConfigTimer":return _("authored",M.payload?.delay??cl.authored),!0;case"clearNextLineConfigTimer":return C("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let J;try{J=RA(M)}catch(H){try{I()}catch(se){throw new AggregateError([H,se],"Playback schedule validation and cleanup both failed")}throw H}if(d="reconciled",J.status==="unsettled"){P(),m||k();return}let ue={};for(let H of Ui){let se=J.timers[H],pe=h[H];if(pe&&(!se||!pl(pe,se))&&(h[H]=null),se&&h[H]&&pl(h[H],se)){ue[H]=null;continue}let de=f[H];ue[H]=se&&de&&pl(de.descriptor,se)?de:se?dl(se):null}f=ue,y()?D():m||k()},reset:()=>{let M=[o,u].filter((H,se,pe)=>H&&pe.indexOf(H)===se);r={},n={},b(),o=null,u=null,P(),h={auto:null,skip:null,authored:null};for(let H of Ui)g[H]+=1;d="legacy",a=!0;let J=null,ue=null;for(let H of M)try{e.remove(H)}catch(se){J??=se,ue??=H}if(u=ue,J)throw J},dispose:()=>{a=!1,r={},n={},b(),P(),h={auto:null,skip:null,authored:null};let M=[o,u].filter((H,se,pe)=>H&&pe.indexOf(H)===se);o=null,u=null;let J=null,ue=null;for(let H of M)try{e.remove(H)}catch(se){J??=se,ue??=H}if(u=ue,J)throw J}}};var $A=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),CA=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),ml="conditional",Tn="random",hl=Symbol("conditionalAutoContinue"),_A=new Set(["sectionTransition","resetStoryAtSection"]),NA=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),jA=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),TA=new Set(["nextLine","nextLineFromSystem"]),DA=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),yl="form",LA=new Set(["submitForm","cancelForm"]),MA=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),VA="showImageGalleryVariant",qA="playMusicRoomTrack",FA="startSceneReplay",BA="channel:bgm",dm=1e3,UA="routing_cycle",YA=new Set(["startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","setAutoForwardDelay","setAutoForwardSpeed","setNextLineConfig","markLineCompleted","nextLine","nextLineFromSystem","jumpToLine","sectionTransition","resetStoryAtSection","loadSlot","rollbackByOffset","rollbackToLine","startSceneReplay","exitSceneReplay","updateProjectData","updateLocalizationPackage","submitForm","cancelForm"]),Ye=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),zA=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,Dn=e=>e?.type===hl,ht=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,XA=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(i=>!Object.is(e?.[i],t?.[i]));function gl(e){let t=zA(),s,i=0,a=!1,r=0,n=null,o=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],b=[],w=!1,A=null,k=null,P=null,I=null,x=new Map,D,C,_=null,q=!1,X=!1,re=0,R=new Map,M=Oc(e.randomSource),{handlePendingEffects:J}=e;if(typeof J!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let ue=J.bind(J),H=typeof J.reconcilePlaybackScheduleV1=="function"?J.reconcilePlaybackScheduleV1.bind(J):null,se=typeof J.reset=="function"?J.reset.bind(J):null,pe=typeof J.dispose=="function"?J.dispose.bind(J):null;if(H&&(!se||!pe))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let de=v=>{if(X)throw new Error(`RouteEngine cannot ${v} during playback reconciliation`)},ke=v=>{if(de(v),!a||!s)throw new Error(`RouteEngine ${v} requires an active engine`)},Q=(v,E)=>{if(re===0)return;let O={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},$=R.get(v);($===void 0||O[E]>O[$])&&R.set(v,E)},N=v=>{let E=R.get(v)??"preCommit";return R.delete(v),E},T=v=>{if(H){X=!0;try{let E=H(structuredClone(v));if(E!==null&&(typeof E=="object"||typeof E=="function")&&typeof E.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{X=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:s?.selectPlaybackLineEntryId?.()??0,timers:null}),K=v=>{if(!(!H||!a||!s)){q=!0;try{T(F())}catch(E){if(v){let O=new AggregateError([v,E],"Playback work and schedule invalidation both failed");throw R.delete(v),Q(O,"reconcileFailed"),O}throw Q(E,"reconcileFailed"),E}}},ae=()=>{if(!H||!q||!a||!s||o>0||l)return;let v;try{v=s.selectDesiredPlaybackTimers()}catch(E){throw Q(E,"reconcileFailed"),K(E),E}try{T({contractVersion:1,status:"settled",lineEntryId:s.selectPlaybackLineEntryId(),timers:v})}catch(E){throw Q(E,"reconcileFailed"),K(E),E}q=!1},ye=(v=new Map,E=Date.now())=>new Map(Array.from(v.entries()).filter(([,O])=>E<O.expiresAt).map(([O,$])=>[O,{animation:structuredClone($.animation),startedAt:$.startedAt,expiresAt:$.expiresAt}])),oe=(v=new Map)=>Array.from(v.values()).map(E=>structuredClone(E.animation)),he=(v=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,E])=>v<E.expiresAt))},vr=()=>{if(!a||o>0||l)return;l=!0;let v=0;try{for(;s.selectPendingEffects().length>0;){let E=s.selectCurrentPointer()?.pointer??null;if(v>=dm){let j=new Error(`RouteEngine exceeded ${dm} synchronous effect batches at section "${E?.sectionId}", line "${E?.lineId}". Check for an immediate routing cycle.`);throw j.code=UA,j.pointer={sectionId:E?.sectionId,lineId:E?.lineId},Q(j,"postCommitUnsettled"),K(j),j}v+=1;let O=[...s.selectPendingEffects()],$=O.map(j=>j.name!=="handleLineActions"?j:{...j,payload:{...j.payload,pointer:structuredClone(E)}});s.clearPendingEffects();try{let j=H?$.filter(Y=>!jn.has(Y.name)):$;j.length>0&&ue(j)}catch(j){throw s.clearPendingEffects(),O.forEach(Y=>{s.appendPendingEffect(Y)}),Q(j,"postCommitUnsettled"),K(j),j}}}finally{l=!1}ae()},er=v=>{o+=1;let E=!1;try{let O=v();return E=!0,O}finally{o-=1,E&&vr()}},gt=()=>fa({presentationState:s.selectPresentationState(),previousBgmRender:bt(),resources:s.selectBgmResources(),...s.selectBgmPlaybackContext()}),Cr=()=>structuredClone(s.selectPresentationState()?.bgm??null),Hr=()=>s.selectBgmResources(),bt=()=>({channel:A,bgm:k,resources:P}),Bt=v=>!!v?.audioEffects,Kr=()=>structuredClone(w?A:gt()),wt=()=>w?structuredClone(k):Cr(),Wr=()=>w?structuredClone(P):Hr(),Ln=v=>s.selectSceneIdForSection({sectionId:v}),Ut=()=>{if(b.length===0)return;let v=s.selectRuntime()?.skipTransitionsAndAnimations===!0,E=new Set(v?[]:y.map(O=>O.id));b.forEach(O=>{O.status=O.effects?.some($=>E.has($.id))?"active":"settled"}),v&&(y=[]),b=[]},Yt=(v,E,O,$,j,Y,z)=>{let Z=s.selectPlaybackLineEntryId?.()??0,le=(E.actionPath??["bgm"]).join("."),we=s.selectCurrentPointer()?.pointer,ge=we?.sceneId??Ln(we?.sectionId),Se=E.rollbackSource==="line"&&we?`story.scenes[${JSON.stringify(ge)}].sections[${JSON.stringify(we.sectionId)}].lines[${JSON.stringify(we.lineId)}].actions.${le}`:le,Ce=E.rollbackSource==="line"?`${i}:${Z}:${Se}`:null,ze=Ce?x.get(Ce):null;if(ze)return ze;g+=1;let Te={occurrenceId:`${t}:g${i}:l${Z}:audio${g}`,actionPath:Se,selection:v?.audioEffects?structuredClone(v.audioEffects):null},Ae=Hr(),_r=Vc({occurrence:Te,resources:Ae,previousResources:z??Ae,nextResources:Ae,previousChannel:O,nextChannel:$,previousBgm:j,nextBgm:Y});if(Te.effects=structuredClone(_r),Te.status=_r.length>0?"pending":"settled",y=structuredClone(_r),b.push(Te),Ce)for(x.set(Ce,Te);x.size>512;){let qn=x.keys().next().value;x.delete(qn)}return Te},Yi=({initialState:v,namespace:E})=>{de("initialize");let O=s?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:$,...j}=v,Y=$===void 0?void 0:structuredClone($),z=structuredClone(v.projectData),Z=cm({projectData:z,l10nData:Y}),le=j.global??{};if(!Ye(le))throw new Error("Malformed global state.");let we=le.runtime??{};if(!Ye(we))throw new Error("Malformed global.runtime.");let ge=we.localizationPackageId;if(ge!=null&&typeof ge!="string")throw new Error("localizationPackageId requires a string or null value");let Se=new Set(Z.map(({l10nId:Ae})=>Ae).filter(Ae=>Ae!==null)),Ce=typeof ge=="string"&&Se.has(ge)?ge:null,ze=Bi({projectData:z,l10nData:Y,l10nId:Ce}),Te=Vf({...j,global:{...le,localizationPackages:Z,runtime:{...we,localizationPackageId:Ce}},projectData:ze,initialAudioCommandId:O});se?.(),s=Te,i+=1,a=!0,r=0,n=Vt(E),o=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],b=[],w=!1,A=null,k=null,P=null,I={lineEntryId:s.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:Hr()},x=new Map,D=z,C=Y,_=Ce,q=!0,X=!1,re=0,R.clear(),s.appendPendingEffect({name:"handleLineActions"}),vr()},Mn=()=>{de("dispose"),a&&(a=!1,i+=1,s?.clearPendingEffects?.(),o=0,l=!1,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,y=[],b=[],w=!1,A=null,k=null,P=null,I=null,x=new Map,q=!1,R.clear(),pe?.())},bm=()=>n,wm=()=>s.selectPresentationState(),Im=()=>s.selectPresentationChanges(),vm=v=>s.selectSectionLineChanges(v),wl=(v={})=>{ke("rendering"),r+=1;let E=Date.now();he(E);let O=f.size>0,$=ye(d,E),j=O?ye(f,E):new Map,Y=s.selectRenderState({previousBgmRender:bt(),activePersistentAnimations:oe($),restoredPersistentAnimations:oe(j),activeAudioEffects:structuredClone(y)}),z={...Y,id:`render-${t}-${i}-${r}`};return h.set(z.id,{builtAt:E,persistentAnimationSessions:new Map([...j.entries(),...$.entries()]),usedRestoredPersistentAnimationSessions:O,activeAudioEffectIds:y.map(Z=>Z.id),bgmPresentation:Cr(),bgmResources:Hr(),retainsActiveAudioEffects:y.length>0&&y.every(Z=>(Y.audioEffects??[]).some(le=>le.id===Z.id))}),z},km=(v={})=>wl(v),Am=(v={})=>wl(v),Pm=v=>{if(!a||!s)return;let E=typeof v?.id=="string"&&v.id.length>0?v.id:null,O=E?h.get(E):null;E&&h.delete(E);let $=v?.audio?.find(Y=>Y?.id===BA);w=!0,A=$?structuredClone($):null,k=structuredClone(O?.bgmPresentation??null),P=structuredClone(O?.bgmResources??null);let j=new Map;Pu(v?.animations).forEach(Y=>{let z=ks(Y);if(!z)return;let Z=O?.persistentAnimationSessions?.get(z)??d.get(z),le=Math.max(0,Ou(Y)),we=Z?.startedAt??O?.builtAt??Date.now();j.set(z,{animation:structuredClone(Y),startedAt:we,expiresAt:we+le})}),d=j,O?.usedRestoredPersistentAnimationSessions&&(f=new Map),O?.activeAudioEffectIds?.length>0&&!O.retainsActiveAudioEffects&&y.length===O.activeAudioEffectIds.length&&O.activeAudioEffectIds.every(Y=>y.some(z=>z.id===Y))&&(y=[])},xm=()=>s.selectSystemState(),Em=()=>s.selectAchievements(),Sm=v=>s.selectAchievement(v),Il=()=>s.selectSaveSlotMap(),Om=v=>s.selectSaveSlot(v),Rm=v=>s.selectSaveSlotPage(v),$m=()=>s.selectImageGallery(),Cm=()=>s.selectMusicRoom(),_m=()=>s.selectSceneReplay(),Nm=()=>s.selectIsSceneReplayActive(),iP=()=>s.selectSkipMode(),oP=()=>s.selectAutoMode(),jm=()=>s.selectRuntime(),Tm=()=>s.selectIsChoiceVisible(),Dm=()=>s.selectIsFormVisible(),Lm=()=>s.selectActiveInteraction(),Mm=()=>s.selectPendingEffects().some(v=>v?.name==="handleLineActions"||v?.name==="render"),vl=(v,E,O={})=>!Ye(E)||v!=="nextLine"?E:O.bypassChoice===!0?{...E,bypassChoice:!0}:O.interactionSource===yl?{...E,_interactionSource:yl}:E,kl=(v={})=>({type:hl,payload:vl("nextLine",{_conditionalContinuation:!0},v)}),zi=(v,E)=>Dn(v)?{type:hl,payload:{...v.payload,...E.payload}}:E,Vm=v=>{v.savedCheckpointOccurrences.forEach(E=>{s.markSavedRollbackCheckpointTransient(E)}),v.savedCheckpointOccurrences=[]},qm=(v,E)=>{let O=p;return p=null,!O||!ht(O.pointer,v)||O.checkpointIndex!==E?.checkpointIndex||O.checkpointIdentity!==E?.checkpoint?[]:O.savedCheckpointOccurrences},Fm=v=>{let E=m;return!E||!ht(E.pointer,v)?null:(m=null,E)},Bm=({actionType:v,pointerBeforeAction:E,pointerAfterAction:O,cursorBeforeAction:$,cursorAfterAction:j,wasSceneReplayActive:Y,isSceneReplayActive:z})=>{!O||!(!ht(E,O)||$?.checkpoint!==j?.checkpoint||$?.checkpointIndex!==j?.checkpointIndex||v==="jumpToLine")||(m={pointer:O,appendToPrevious:TA.has(v)&&Y===z&&E?.sectionId===O.sectionId&&E?.lineId!==O.lineId,reuseExistingOccurrence:DA.has(v),forceNewOccurrence:v==="jumpToLine"})},Al=v=>{v.markCurrentCheckpointTransient&&(s.markRollbackCheckpointTransient({checkpointIndex:v.rollbackCursor?.checkpointIndex,checkpointIdentity:v.rollbackCursor?.checkpoint,sectionId:v.pointer?.sectionId,lineId:v.pointer?.lineId}),Vm(v))},Um=(v,E,O)=>NA.has(v)?v==="resetStoryAtSection"?O?.checkpoint!==E?.checkpoint:O?.checkpoint!==E?.checkpoint&&O?.checkpointIndex>E?.checkpointIndex:!1,Ym=v=>{let E=u.at(-1);if(!E?.markCurrentCheckpointTransient)return;let O=s.selectSaveSlot({slotId:v?.slotId});O&&E.savedCheckpointOccurrences.push({slotId:v.slotId,saveSlotIdentity:O,checkpointIndex:E.rollbackCursor?.checkpointIndex,sectionId:E.pointer?.sectionId,lineId:E.pointer?.lineId})},zm=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(E=>{let O=s.selectSaveSlot({slotId:E.slotId});O&&(E.saveSlotIdentity=O)})},Xm=()=>{let v=u.at(-1);v&&(v.rollbackCursor=s.selectRollbackCursor?.()??null)},Gm=(v,E,O)=>{let $=u.at(-1);if(!$)return;let j=s.selectCurrentPointer()?.pointer,Y=Um(v,E,O);if(ht($.pointer,j)){let z=O?.checkpoint!==E?.checkpoint||O?.checkpointIndex!==E?.checkpointIndex;Y||z&&jA.has(v)?(Al($),$.pointer=j,$.rollbackCursor=O,$.markCurrentCheckpointTransient=Y,$.savedCheckpointOccurrences=[]):z&&v==="updateProjectData"&&($.rollbackCursor=O);return}Al($),$.pointer=j,$.rollbackCursor=s.selectRollbackCursor?.()??null,$.markCurrentCheckpointTransient=Y,$.savedCheckpointOccurrences=[]},It=(v,E)=>{if(ke(`action "${v}"`),!s[v])return;let O=E,$,j;if(v==="updateProjectData")Pl(E),$=structuredClone(E.projectData),O={...E,projectData:Bi({projectData:$,l10nData:C,l10nId:_})},Pl(O);else if(v==="updateLocalizationPackage"){if(j=Hm(E),j===_)return;O={l10nId:j,projectData:Bi({projectData:D,l10nData:C,l10nId:j})}}_A.has(v)&&(c+=1);let Y=s.selectAutoMode(),z=Y?s.selectRuntime():null,Z=s.selectIsSceneReplayActive?.()===!0,le=CA.has(v)?ye(d):null,we=s.selectCurrentPointer()?.pointer??null,ge=s.selectRollbackCursor?.()??null,Se=ps(v),Ce=Se?s.selectPlaybackLineEntryId?.()??0:null,ze=Se?Kr():null,Te=Se?wt():null,Ae=Se?Wr():null,_r=!1,qn;try{qn=s[v](O),_r=!0}catch(zt){throw Q(zt,"preCommit"),zt}$!==void 0&&(D=$),j!==void 0&&(_=j),$A.has(v)&&(f=le??new Map,d=new Map,y=[]),v==="setSkipTransitionsAndAnimations"&&O?.value===!0&&(y=[]);let $l=s.selectIsSceneReplayActive?.()===!0;Z!==$l&&(d=new Map,f=new Map);let ly=s.selectCurrentPointer()?.pointer??null,Cl=s.selectRollbackCursor?.()??null,_l=Se?s.selectPlaybackLineEntryId?.()??0:null;Se&&_l!==Ce&&(I={lineEntryId:_l,channel:ze,presentation:Te,resources:Ae}),v==="saveSlot"?Ym(E):v==="updateProjectData"&&zm(),Gm(v,ge,Cl),Bm({actionType:v,pointerBeforeAction:we,pointerAfterAction:ly,cursorBeforeAction:ge,cursorAfterAction:Cl,wasSceneReplayActive:Z,isSceneReplayActive:$l});let cy=s.selectAutoMode()&&(v==="updateVariable"||Y&&XA(z,s.selectRuntime()));(YA.has(v)||cy)&&(q=!0);try{vr()}catch(zt){throw _r&&Q(zt,"postCommitUnsettled"),zt}return qn},Pl=v=>{if(!Object.prototype.hasOwnProperty.call(v??{},"projectData"))throw new Error("updateProjectData requires projectData");nt(v?.projectData?.resources?.variables??{}),Qt(v.projectData),Zt(v.projectData),en(v.projectData)},Hm=v=>{if(!Ye(v))throw new Error("updateLocalizationPackage requires an object payload");let E=Object.keys(v);if(E.length!==1||E[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(v.l10nId!==null&&(typeof v.l10nId!="string"||v.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return v.l10nId},Km=(v,E,O)=>{let $=s.selectCurrentPointer()?.pointer;E!==$||O!==c||(s.appendPendingEffect({name:"clearAutoNextTimer"}),s.appendPendingEffect({name:"clearNextLineConfigTimer"}),It("nextLineFromSystem",v.payload))},Wm=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(h),audioEffectOccurrenceSequence:g,activeAudioEffects:y,pendingAudioEffectOccurrences:b.slice(),pendingEnteredLineBgmHandoff:I?structuredClone(I):null,acceptedLineBgmActionOccurrences:new Map(x),canonicalProjectData:D,localizationPackageId:_,playbackScheduleDirty:q}),Jm=v=>{r=v.renderSequence,c=v.conditionalRoutingSequence,u=v.rollbackNavigationContexts.slice(),p=v.pendingRollbackLineEntrySaveHandoff,m=v.pendingDialogueHistoryLineEntry,d=new Map(v.persistentAnimationSessions),f=new Map(v.restoredPersistentAnimationSessions),h=new Map(v.renderPersistentAnimationMetadata),g=v.audioEffectOccurrenceSequence,y=v.activeAudioEffects,b=v.pendingAudioEffectOccurrences.slice(),I=v.pendingEnteredLineBgmHandoff?structuredClone(v.pendingEnteredLineBgmHandoff):null,x=new Map(v.acceptedLineBgmActionOccurrences),D=v.canonicalProjectData,_=v.localizationPackageId,q=v.playbackScheduleDirty},Xi=(v,E={})=>(ke("action batch"),er(()=>{let O=Wm();try{return s[ko](()=>{let $,j=s.selectCurrentPointer()?.pointer??null,Y=s.selectRollbackCursor?.()??null,z=c,Z={pointer:j,rollbackCursor:Y,markCurrentCheckpointTransient:E.rollbackSource==="line",savedCheckpointOccurrences:E.savedCheckpointOccurrences?.slice()??[]};u.push(Z);try{s.beginRollbackActionBatch({source:E.rollbackSource});try{$=v()}finally{s.endRollbackActionBatch({})}Dn($)&&Km($,j,z),Ut();let le=s.selectCurrentPointer()?.pointer??null;E.rollbackSource==="line"&&ht(j,le)&&s.recordCurrentDialogueHistory({savedCheckpointOccurrences:Z.savedCheckpointOccurrences,appendToPrevious:E.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:E.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:E.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!ht(j,Z.pointer)||Y?.checkpoint!==Z.rollbackCursor?.checkpoint)&&Z.markCurrentCheckpointTransient&&Z.savedCheckpointOccurrences.length>0&&(p={pointer:Z.pointer,checkpointIndex:Z.rollbackCursor?.checkpointIndex,checkpointIdentity:Z.rollbackCursor?.checkpoint,savedCheckpointOccurrences:Z.savedCheckpointOccurrences})}})}catch($){throw Jm(O),$}})),Gi=(v,E,O,$={})=>{if(v===ml||v===Tn)return Xi(()=>{let j={...$,executionContext:$.executionContext??{depth:0,pendingNavigation:null},actionPath:$.actionPath??[v],randomOutcomeOrdinals:$.randomOutcomeOrdinals??new Map};if(v===Tn)return Sl(E,O,j);let Y=Hi(O),z=xt({[v]:E},Y);return El(z[v],O,j)},$);if(v==="bgm")return Xi(()=>{let j=wt(),Y=Bt(E),z=Y?Kr():null,Z=Y?Wr():null;It(v,E);let le=Cr();Yt(E,{...$,actionPath:$.actionPath??[v]},z,Y?gt():null,j,le,Z)},$);It(v,E)},Qm=(v,E)=>{if(v!=="nextLineFromSystem")return Gi(v,E);re+=1;try{return Gi(v,E)}finally{re=Math.max(0,re-1)}},xl=v=>{if(v&&Object.prototype.hasOwnProperty.call(v,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Hi=v=>{if(xl(v),!v)return{variables:s.selectAllVariables?s.selectAllVariables():void 0,runtime:s.selectRuntime?s.selectRuntime():{}};let{_event:E,...O}=v,$=s.selectAllVariables?s.selectAllVariables():void 0;return{...O,_event:E,variables:$,runtime:s.selectRuntime?s.selectRuntime():{}}},Zm=v=>{if(!Ye(v))return{templatePayload:v,literalTargetIds:null};let E=s.selectImageGalleryConfig();if(!Array.isArray(E?.groups))return{templatePayload:v,literalTargetIds:null};let O=typeof v.groupId=="string"?E.groups.find(j=>j.id===v.groupId):void 0;if(!O)return{templatePayload:v,literalTargetIds:null};let $=typeof v.variantId=="string"&&O.variants.some(j=>j.id===v.variantId);return{templatePayload:{...v,groupId:null,...$?{variantId:null}:{}},literalTargetIds:{groupId:v.groupId,...$?{variantId:v.variantId}:{}}}},ey=v=>!Ye(v)||typeof v.trackId!="string"?{templatePayload:v,literalTargetIds:null}:s.selectMusicRoomConfig()?.tracks?.some($=>$.id===v.trackId)?{templatePayload:{...v,trackId:null},literalTargetIds:{trackId:v.trackId}}:{templatePayload:v,literalTargetIds:null},ry=v=>!Ye(v)||typeof v.sceneId!="string"?{templatePayload:v,literalTargetIds:null}:s.selectSceneReplayConfig()?.replays?.some($=>$.sceneId===v.sceneId)?{templatePayload:{...v,sceneId:null},literalTargetIds:{sceneId:v.sceneId}}:{templatePayload:v,literalTargetIds:null},ty=v=>{if(!Ye(v))throw new Error("conditional action payload must be an object");if(!Array.isArray(v.branches))throw new Error("conditional action requires branches array");if(v.branches.length===0)throw new Error("conditional action requires at least one branch")},ny=(v,E,O)=>{if(!Ye(v))throw new Error(`conditional branch at index ${E} must be an object`);if(!Ye(v.actions))throw new Error(`conditional branch at index ${E} requires actions object`);if(!Object.prototype.hasOwnProperty.call(v,"when")&&E!==O-1)throw new Error("conditional else branch must be the last branch")},El=(v,E,O)=>{ty(v);let $=kl(O);for(let j=0;j<v.branches.length;j+=1){let Y=v.branches[j];ny(Y,j,v.branches.length);let z=Hi(E);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!Jt(Y.when,z))continue;let le=Vn(Y.actions,E,{...O,actionPath:[...O.actionPath??[ml],"branches",String(j),"actions"]});return Dn(le)?zi($,le):$}return $},sy=v=>{if(!Ye(v))throw new Error("random action payload must be an object");let E=Object.keys(v).find(O=>O!=="distribution"&&O!=="variableId");if(E!==void 0)throw new Error(`random action.${E} is not supported`);if(!Ye(v.distribution))throw new Error("random action requires distribution object");if(v.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(v,"variableId"))throw new Error("weighted random action does not support variableId")}else if(v.distribution.type==="integer"){if(typeof v.variableId!="string"||!v.variableId)throw new Error("integer random action requires variableId");let O=L(D?.resources?.variables,v.variableId);if(!O||O.type!=="number"||O.scope!=="context"||O.readonly===!0||Ne(O))throw new Error(`integer random action variableId must reference a writable context number variable: ${v.variableId}`)}},Sl=(v,E,O)=>{sy(v),xl(E);let $=Rc(v.distribution,{randomSource:M});if(O.rollbackSource==="line"){s.ensureRandomReplayOccurrence({});let z=(O.actionPath??[Tn]).join("."),Z=O.randomOutcomeOrdinals??new Map,le=Z.get(z)??0;Z.set(z,le+1),s.recordRandomOutcome({path:z,ordinal:le,type:$.type,result:$}),Xm()}let j;$.type==="integer"?It("updateVariable",{id:"randomResult",operations:[{variableId:v.variableId,op:"set",value:$.value}]}):j=Vn(v.distribution.outcomes[$.outcomeIndex].actions,E,{...O,actionPath:[...O.actionPath??[Tn],"distribution","outcomes",String($.outcomeIndex),"actions"]});let Y=kl(O);return Dn(j)?zi(Y,j):Y},iy=(v,E)=>({...v??{},_form:E}),oy=(v,E,O,$)=>{let j=It(v,E),Y=j?.submitted===!0&&j.valid===!0,z=j?.cancelled===!0;if(!(!Y&&!z)&&Ye(E.actions))return Vn(E.actions,iy(O,j.form),{...$,interactionSource:yl})},Ol=(v,E,O,$)=>{if(v===Tn)return Sl(E,O,$);let j=Hi(O),Y={templatePayload:E,literalTargetIds:null};v===VA?Y=Zm(E):v===qA?Y=ey(E):v===FA&&(Y=ry(E));let{templatePayload:z,literalTargetIds:Z}=Y,le=MA.has(v)?v==="bgm"&&z?.audioEffects!==void 0?{...z,audioEffects:xt({audioEffects:z.audioEffects},j).audioEffects}:z:xt({[v]:z},j)[v],we=Z?{...le,...Z}:le;if(v===ml)return El(we,O,$);let ge=vl(v,we,$);if(LA.has(v))return oy(v,ge,O,$);let Se=null,Ce=null,ze=null,Te=!1;if(v==="bgm"){let Ae=$.audioEffectHandoff,_r=Ae?.available?Ae.presentation:wt();Te=Bt(ge),Te&&Ae?.available?(Ae.available=!1,Se=structuredClone(Ae.channel),Ce=structuredClone(Ae.presentation),ze=structuredClone(Ae.resources)):Te&&(Se=Kr(),Ce=_r,ze=Wr())}if(It(v,ge),v==="bgm"){let Ae=Cr();Yt(ge,$,Se,Te?gt():null,Ce,Ae,ze)}},Vn=(v,E,O)=>{let $,j=O?.executionContext??{depth:0,pendingNavigation:null},Y=us(v);fs(Y),j.depth+=1;try{for(let[z,Z]of Y){let le={...O,executionContext:j,actionPath:[...O?.actionPath??[],z]};if(ps(z)){let ge=j.pendingNavigation;if(ge)throw new Error(`action batch cannot execute multiple navigation actions: ${ge.actionType}, ${z}`);j.pendingNavigation={actionType:z,payload:Z,eventContext:E,options:le};continue}let we=Ol(z,Z,E,le);Dn(we)&&($=zi($,we))}}finally{j.depth-=1}if(j.depth===0&&j.pendingNavigation){let z=j.pendingNavigation;j.pendingNavigation=null,Ol(z.actionType,z.payload,z.eventContext,z.options)}return $},Rl=(v,E,O={})=>{let $={...O,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Xi(()=>Vn(v,E,$),$)},ay=v=>{let E=s.selectCurrentPointer()?.pointer;if(v!==E||s.selectActiveInteraction())return;let O=s.selectNextLineConfig();O?.auto?.enabled&&O.auto.trigger==="fromStart"&&s.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:O.auto.delay}})};return{init:Yi,dispose:Mn,handleAction:Gi,handleInternalAction:Qm,handleActions:Rl,selectRenderState:km,prepareRenderState:Am,commitRenderState:Pm,selectPresentationState:wm,selectPresentationChanges:Im,selectSectionLineChanges:vm,selectSystemState:xm,selectAchievements:Em,selectAchievement:Sm,selectSaveSlotMap:Il,selectSaveSlot:Om,selectSaveSlotPage:Rm,selectSaveSlots:Il,selectImageGallery:$m,selectMusicRoom:Cm,selectSceneReplay:_m,selectIsSceneReplayActive:Nm,selectRuntime:jm,selectIsChoiceVisible:Tm,selectIsFormVisible:Dm,selectActiveInteraction:Lm,selectHasPendingRenderWork:Mm,handleLineActions:v=>{ke("line action handling");let E=s.selectCurrentPointer()?.pointer;if(v?.pointer&&!ht(v.pointer,E))return!1;if(typeof v?.sceneReplaySceneId=="string"){let O=s.selectActiveSceneReplayEntry?.();if(O?.sceneId!==v.sceneReplaySceneId||O?.entryId!==v.entryId)return!1}return er(()=>{let O=s.selectCurrentPointer()?.pointer,$=s.selectPlaybackLineEntryId?.()??0,j=I?.lineEntryId===$?I:null,Y=j?{available:!0,channel:structuredClone(j.channel),presentation:structuredClone(j.presentation),resources:structuredClone(j.resources)}:null,z=s.selectRollbackCursor?.()??null,Z=p,le=m,we=qm(O,z),ge=Fm(O),Se=s.selectCurrentLine(),Ce=!1;if(Se?.actions){try{Rl(Se.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:we,dialogueHistoryAppendToPrevious:ge?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ge?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ge?.forceNewOccurrence===!0,audioEffectHandoff:Y})}catch(ze){throw p=Z,m=le,ze}Ce=!0}return I?.lineEntryId===$&&(I=null),ay(O),Ce})},getNamespace:bm,classifyAutomaticAttemptError:N}}var GA="music-room:player",hm=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),mm=(e,t)=>hm.has(e)&&t?._event?.id===GA,gm=({engine:e,routeGraphics:t,trackRenderDispatch:s,lifecycleGeneration:i,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let n=e.prepareRenderState?.(r)??e.selectRenderState(r);s?.(n),t.render(n),a(i)&&e.commitRenderState?.(n)},HA=({engine:e,routeGraphics:t,trackRenderDispatch:s,getRenderDispatchCount:i,lifecycleGeneration:a,isCurrentLifecycle:r},n)=>{let o=i?.()??0,l=e.handleLineActions(n);(i?.()??0)===o&&gm({engine:e,routeGraphics:t,trackRenderDispatch:s,lifecycleGeneration:a,isCurrentLifecycle:r},n)},KA=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveSlots(t?.saveSlots))},WA=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalDeviceVariables(t?.globalDeviceVariables))},JA=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalAccountVariables(t?.globalAccountVariables))},QA=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalRuntime(t?.globalRuntime))},ZA=({enqueuePersistenceWrite:e},t)=>{e(s=>{if(typeof s.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return s.applyScopedDataUpdates(t?.updates)})},ym={render:gm,saveSlots:KA,saveGlobalDeviceVariables:WA,saveGlobalAccountVariables:JA,saveGlobalRuntime:QA,applyScopedDataUpdates:ZA,handleLineActions:HA},eP=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),bl=(e,t,s)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,s)},rP=(e=[])=>{let t=new Set,s=[];for(let i=e.length-1;i>=0;i-=1){let a=e[i];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!eP.has(a.name)){s.unshift(a);continue}t.has(a.name)||(t.add(a.name),s.unshift(a))}return s},tP=({getEngine:e,routeGraphics:t,ticker:s,handleUnhandledEffect:i,handlePersistenceError:a,indexedDB:r,persistence:n,namespace:o})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,m=!1,d=0,f=0,h=!0,g=fm({ticker:s,dispatchAutomaticAttempt:()=>bl(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:N=>e()?.classifyAutomaticAttemptError?.(N)??"preCommit"}),y=()=>{u=null,p=null,m=!1,d=0},b=()=>{g.reset(),f+=1,y(),h=!0},w=()=>{f+=1,h=!1,y(),g.dispose()},A=N=>h&&N===f,k=N=>{if(a){a(N);return}console.error("RouteEngine persistence write failed.",N)},P=N=>{if(n)return n;let T=Vt(N),F=l.get(T);if(F)return F;let K=tl({indexedDB:r,namespace:T});return l.set(T,K),K},I=N=>{let T=n?null:Vt(o??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=P(T),N(F))).catch(K=>{!n&&l.get(T)===F&&l.delete(T),k(K)})},x=N=>{if(!h)return;let T=typeof N?.id=="string"&&N.id.length>0?N.id:null;d+=1,u=T,m=!1},D=()=>d,C=(N={})=>{if(!h||N?.aborted===!0)return!1;let T=typeof N?.id=="string"&&N.id.length>0?N.id:null;return T?T!==u||T===p?!1:(p=T,!0):u!==null||m?!1:(m=!0,!0)},_=(N,T={})=>{if(!h)return!1;if(mm(N,T)){let K=hm.get(N),ae=e();return bl(ae,K,T?._event),!0}if(N!=="renderComplete"||!C(T))return!1;let F=e();return bl(F,"markLineCompleted",{}),!0},q=new Set(["updateFormField","submitForm","cancelForm"]),X=new Set(["updateVariable"]),re=N=>typeof N?.selectActiveInteraction=="function"?N.selectActiveInteraction():typeof N?.selectIsChoiceVisible=="function"&&N.selectIsChoiceVisible()?{source:"choice"}:null,R=N=>N?._formKey??N?.formKey,M=(N,T)=>R(N)===T?.formKey,J=(N,T)=>!N||typeof N!="object"||Array.isArray(N)?!1:N._interactionSource===T?.source,ue=(N,T)=>J(N,T)?T.source==="form"?M(N,T):!0:!1,H=(N,T)=>!N||typeof N!="object"||Array.isArray(N)||T?.source!=="form"?!1:M(N,T),se=(N={},T)=>Object.keys(N).length>0&&Object.entries(N).every(([F,K])=>q.has(F)?H(K,T):X.has(F)),pe=(N={},T)=>{let F=N?.actions;return T?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:se(F,T):ue(N,T)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(K=>ue(K,T))},de=(N,T={})=>{if(!T?.actions)return!1;let F=re(N);return!F||F.source==="choice"?!1:!pe(T,F)},ke=({preprocessPayload:N,onEvent:T}={})=>async(F,K={})=>{if(!h)return!1;if(mm(F,K))return _(F,K),T?.(F,K);let ae=e(),ye=f,oe=d;if(de(ae,K))return T?.(F,K);let he=await N?.(F,K)??K;if(!A(ye)||e()!==ae||d!==oe)return!1;if(de(ae,he))return T?.(F,he);if(_(F,he),he?.actions){let vr=he?._event?{_event:he._event}:he?.event?{_event:he.event}:void 0,er;he?.bypassChoice===!0?er={bypassChoice:!0}:he?._interactionSource&&(er={interactionSource:he._interactionSource}),er?ae.handleActions(he.actions,vr,er):ae.handleActions(he.actions,vr)}return T?.(F,he)},Q=N=>{if(!h)return;let T=f,F=e(),K=rP(N),ae=K.some(oe=>oe.name==="handleLineActions");K.forEach(oe=>{if(!ym[oe.name]&&!jn.has(oe.name)&&!i)throw new Error(`Unhandled pending effect "${oe.name}".`)});let ye={engine:F,routeGraphics:t,ticker:s,trackRenderDispatch:x,getRenderDispatchCount:D,enqueuePersistenceWrite:I,lifecycleGeneration:f,isCurrentLifecycle:A};for(let oe of K){if(!A(T))break;if(ae&&oe.name==="render")continue;if(jn.has(oe.name)){g.handleLegacyEffect(oe);continue}let he=ym[oe.name];if(he){he(ye,oe.payload);continue}i(oe,ye)}};return Q.handleRouteGraphicsEvent=_,Q.createRouteGraphicsEventHandler=ke,Q.reset=b,Q.dispose=w,Q.reconcilePlaybackScheduleV1=N=>g.reconcilePlaybackScheduleV1(N),Q},nP=tP;var sP=(e,t={})=>{let{resources:s={}}=t;return oa(e,s)};var yx=gl;export{qo as DEFAULT_VISUAL_LAYER,Ot as RENDER_LAYER,Ar as VISUAL_LAYER,nP as createEffectsHandler,Ck as createIndexedDbPersistence,yx as default,Po as formatDate,qh as resolveComputedVariables,sP as resolveLayoutReferences};
|