route-engine-js 1.42.1 → 1.43.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.
@@ -1,6 +1,6 @@
1
- var lm=Object.defineProperty;var cm=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),um=(e,t)=>{for(var n in t)lm(e,n,{get:t[n],enumerable:!0})};var Kp=cm(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});function Hp(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}_a.default=Hp;Hp.code='require("ajv/dist/runtime/ucs2length").default'});var ul=Symbol.for("immer-nothing"),il=Symbol.for("immer-draftable"),_e=Symbol.for("immer-state");function Ue(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var nt=Object.getPrototypeOf;function Ae(e){return!!e&&!!e[_e]}function Dr(e){return e?pl(e)||Array.isArray(e)||!!e[il]||!!e.constructor?.[il]||Cn(e)||_n(e):!1}var pm=Object.prototype.constructor.toString();function pl(e){if(!e||typeof e!="object")return!1;let t=nt(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)===pm}function Rn(e){return Ae(e)||Ue(15,e),e[_e].base_}function xn(e,t){$n(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,i)=>t(i,n,e))}function $n(e){let t=e[_e];return t?t.type_:Array.isArray(e)?1:Cn(e)?2:_n(e)?3:0}function ji(e,t){return $n(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function fl(e,t,n){let i=$n(e);i===2?e.set(t,n):i===3?e.add(n):e[t]=n}function fm(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Cn(e){return e instanceof Map}function _n(e){return e instanceof Set}function Nr(e){return e.copy_||e.base_}function Ni(e,t){if(Cn(e))return new Map(e);if(_n(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=pl(e);if(t===!0||t==="class_only"&&!n){let i=Object.getOwnPropertyDescriptors(e);delete i[_e];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(nt(e),i)}else{let i=nt(e);if(i!==null&&n)return{...e};let a=Object.create(i);return Object.assign(a,e)}}function qi(e,t=!1){return jn(e)||Ae(e)||!Dr(e)||($n(e)>1&&(e.set=e.add=e.clear=e.delete=dm),Object.freeze(e),t&&Object.entries(e).forEach(([n,i])=>qi(i,!0))),e}function dm(){Ue(2)}function jn(e){return Object.isFrozen(e)}var mm={};function Tr(e){let t=mm[e];return t||Ue(0,e),t}var Rt;function dl(){return Rt}function ym(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ol(e,t){t&&(Tr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Di(e){Ti(e),e.drafts_.forEach(hm),e.drafts_=null}function Ti(e){e===Rt&&(Rt=e.parent_)}function al(e){return Rt=ym(Rt,e)}function hm(e){let t=e[_e];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ll(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[_e].modified_&&(Di(t),Ue(4)),Dr(e)&&(e=Sn(t,e),t.parent_||On(t,e)),t.patches_&&Tr("Patches").generateReplacementPatches_(n[_e].base_,e,t.patches_,t.inversePatches_)):e=Sn(t,n,[]),Di(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ul?e:void 0}function Sn(e,t,n){if(jn(t))return t;let i=t[_e];if(!i)return xn(t,(a,r)=>cl(e,i,t,a,r,n)),t;if(i.scope_!==e)return t;if(!i.modified_)return On(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),xn(r,(o,l)=>cl(e,i,a,o,l,n,s)),On(e,a,!1),n&&e.patches_&&Tr("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function cl(e,t,n,i,a,r,s){if(Ae(a)){let o=r&&t&&t.type_!==3&&!ji(t.assigned_,i)?r.concat(i):void 0,l=Sn(e,a,o);if(fl(n,i,l),Ae(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Dr(a)&&!jn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Sn(e,a),(!t||!t.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&On(e,a)}}function On(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qi(t,n)}function gm(e,t){let n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:dl(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=i,r=Vi;n&&(a=[i],r=$t);let{revoke:s,proxy:o}=Proxy.revocable(a,r);return i.draft_=o,i.revoke_=s,o}var Vi={get(e,t){if(t===_e)return e;let n=Nr(e);if(!ji(n,t))return bm(e,n,t);let i=n[t];return e.finalized_||!Dr(i)?i:i===Ci(e.base_,t)?(_i(e),e.copy_[t]=Mi(i,e)):i},has(e,t){return t in Nr(e)},ownKeys(e){return Reflect.ownKeys(Nr(e))},set(e,t,n){let i=ml(Nr(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){let a=Ci(Nr(e),t),r=a?.[_e];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(fm(n,a)&&(n!==void 0||ji(e.base_,t)))return!0;_i(e),Li(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 Ci(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,_i(e),Li(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Nr(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:i.enumerable,value:n[t]}},defineProperty(){Ue(11)},getPrototypeOf(e){return nt(e.base_)},setPrototypeOf(){Ue(12)}},$t={};xn(Vi,(e,t)=>{$t[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});$t.deleteProperty=function(e,t){return $t.set.call(this,e,t,void 0)};$t.set=function(e,t,n){return Vi.set.call(this,e[0],t,n,e[0])};function Ci(e,t){let n=e[_e];return(n?Nr(n):e)[t]}function bm(e,t,n){let i=ml(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}function ml(e,t){if(!(t in e))return;let n=nt(e);for(;n;){let i=Object.getOwnPropertyDescriptor(n,t);if(i)return i;n=nt(n)}}function Li(e){e.modified_||(e.modified_=!0,e.parent_&&Li(e.parent_))}function _i(e){e.copy_||(e.copy_=Ni(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var wm=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"&&Ue(6),i!==void 0&&typeof i!="function"&&Ue(7);let a;if(Dr(t)){let r=al(this),s=Mi(t,void 0),o=!0;try{a=n(s),o=!1}finally{o?Di(r):Ti(r)}return ol(r,i),ll(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===ul&&(a=void 0),this.autoFreeze_&&qi(a,!0),i){let r=[],s=[];Tr("Patches").generateReplacementPatches_(t,a,r,s),i(r,s)}return a}else Ue(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){Dr(e)||Ue(8),Ae(e)&&(e=br(e));let t=al(this),n=Mi(e,void 0);return n[_e].isManual_=!0,Ti(t),n}finishDraft(e,t){let n=e&&e[_e];(!n||!n.isManual_)&&Ue(9);let{scope_:i}=n;return ol(i,t),ll(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=Tr("Patches").applyPatches_;return Ae(e)?i(e,t):this.produce(e,a=>i(a,t))}};function Mi(e,t){let n=Cn(e)?Tr("MapSet").proxyMap_(e,t):_n(e)?Tr("MapSet").proxySet_(e,t):gm(e,t);return(t?t.scope_:dl()).drafts_.push(n),n}function br(e){return Ae(e)||Ue(10,e),yl(e)}function yl(e){if(!Dr(e)||jn(e))return e;let t=e[_e],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ni(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ni(e,!0);return xn(n,(i,a)=>{fl(n,i,yl(a))}),t&&(t.finalized_=!1),n}var Te=new wm,Nn=Te.produce,Pk=Te.produceWithPatches.bind(Te),Ek=Te.setAutoFreeze.bind(Te),xk=Te.setUseStrictShallowCopy.bind(Te),Sk=Te.applyPatches.bind(Te),Ok=Te.createDraft.bind(Te),Rk=Te.finishDraft.bind(Te);var x={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},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},st={NOT:0};var T=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ce=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Fi=e=>{if(!e||e.trim()==="")throw new T("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new T(`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 T(`Incomplete comparison expression - missing right operand (got: '${e}')`)},hl=e=>{if(e.trim().endsWith(" in"))throw new T(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new T(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new T(`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 T(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new T(`Invalid loop syntax (got: '$for ${e}')`)}};var gl=(e,t,n=!1)=>{if(t===null)return new Ce(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ce(`Cannot iterate over undefined value at '$for ${e}'`);let i=typeof t;return n?new Ce(`Cannot iterate over non-array value in loop '${e}' - got ${i} instead`):new Ce(`Cannot iterate over non-array value (got: ${i}) at '$for ${e}'`)},bl=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ce(`Unknown function '${e}' (${n})`)};var Im=(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=ne(e,{functions:i,partials:a},t,{});return s===void 0?{}:s},ne=(e,t,n,i)=>{let a=t.functions||t;if(e.var&&!e.type)return ve(e.var,n,i);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return ve(e.path,n,i);if(e.type===x.INTERPOLATION)return km(e.parts,t,n,i);switch(e.type){case x.FUNCTION:return Il(e,t,n,i);case x.BINARY:return vl(e,t,n,i);case x.UNARY:return kl(e,t,n,i);case x.CONDITIONAL:return Pm(e,t,n,i);case x.LOOP:return Rm(e,t,n,i);case x.OBJECT:return Cm(e,t,n,i);case x.ARRAY:return _m(e,t,n,i);case x.PARTIAL:return jm(e,t,n,i);case x.PATH_REFERENCE:return Nm(e,t,n,i);default:throw new Error(`Unknown node type: ${e.type}`)}},wl=new Map,vm=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},ve=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let i=wl.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=vm(l.trim());i.push(...c)}wl.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},km=(e,t,n,i)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=ne(r,t,n,i);a.push(s!=null?String(s):"")}return a.join("")},Il=(e,t,n,i)=>{let a=t.functions||t,r=a[e.name];if(!r)throw bl(e.name,a);let s=e.args.map(o=>ne(o,t,n,i));return r(...s)},wr=(e,t,n,i)=>{if(e.var&&!e.type)return ve(e.var,n,i);switch(e.type){case x.VARIABLE:return ve(e.path,n,i);case x.LITERAL:return e.value;case x.BINARY:return vl(e,t,n,i);case x.UNARY:return kl(e,t,n,i);case x.FUNCTION:return Il(e,t,n,i);default:return ne(e,t,n,i)}},vl=(e,t,n,i)=>{if(e.op===ee.AND||e.op===ee.OR){let s=wr(e.left,t,n,i),o=wr(e.right,t,n,i);switch(e.op){case ee.AND:return s&&o;case ee.OR:return s||o}}let a=ne(e.left,t,n,i),r=ne(e.right,t,n,i);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new Ce(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ce(`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===st.NOT?wr(e.operand,t,n,i):ne(e.operand,t,n,i);if(e.op===st.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Am=(e,t,n,i)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(ve(a.path,n,i)){let s=e.bodies[0];if(s.type===x.OBJECT&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===x.LITERAL)o[c]=u.value;else if(u.type===x.VARIABLE)o[c]=ve(u.path,n,i);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ve(d.path,n,i);p.push(f!=null?String(f):"")}else{let f=ne(d,t,n,i);p.push(f!=null?String(f):"")}o[c]=p.join("")}else o[c]=ne(u,t,n,i)}return o}}else{let s=e.bodies[1];if(s.type===x.OBJECT&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===x.LITERAL)o[c]=u.value;else if(u.type===x.VARIABLE)o[c]=ve(u.path,n,i);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ve(d.path,n,i);p.push(f!=null?String(f):"")}else{let f=ne(d,t,n,i);p.push(f!=null?String(f):"")}o[c]=p.join("")}else o[c]=ne(u,t,n,i)}return o}}}return null},Pm=(e,t,n,i)=>{let a=Am(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||wr(s,t,n,i))return ne(e.bodies[r],t,n,i)}return Al},Em=(e,t)=>{let n=e.body,i=e.itemVar;if(n.type===x.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===x.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===x.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 d=p.key,f=p.value;if(f.type===x.LITERAL)u[d]=f.value;else if(f.type===x.VARIABLE){let m=f.path;if(m===i)u[d]=c;else if(m.startsWith(i+".")){let b=m.substring(i.length+1);u[d]=c[b]}else return null}else if(f.type===x.INTERPOLATION){let m=[],b=!0;for(let h of f.parts)if(typeof h=="string")m.push(h);else if(h.type===x.VARIABLE){let y=h.path;if(y===i)m.push(c!=null?String(c):"");else if(y.startsWith(i+".")){let w=y.substring(i.length+1),g=c[w];m.push(g!=null?String(g):"")}else{b=!1;break}}else{b=!1;break}if(!b)return null;u[d]=m.join("")}else return null}o.push(u)}}return o}}}return null},xm=(e,t)=>{let n=e.body,i=e.itemVar,a=Em(e,t);if(a!==null)return a;if(n.type===x.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===x.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===x.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===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===i)r.push({key:l,type:"item_string"});else if(p.startsWith(i+".")){let d=p.substring(i.length+1);if(!d.includes(".")&&!d.includes("["))r.push({key:l,type:"prop_string",prop:d});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 d=c[p.prop];u[p.key]=d!=null?String(d):""}o[l]=u}return o}}return null},Sm=(e,t,n,i,a)=>{let r=[],s=e.body;if(s.type===x.OBJECT&&s.fast!==!1){let o=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},d={...i,[o]:u,...l&&{[l]:c}};d.__paths__||(d.__paths__=i.__paths__||{});let f=e.iterable.path||"";if(i&&i.__paths__&&f){let m=f.split("."),b=m[0];b in i.__paths__&&(f=i.__paths__[b],m.length>1&&(f+="."+m.slice(1).join(".")))}d.__paths__={...d.__paths__,[o]:`${f}[${c}]`,...l&&{[l]:c}};for(let m of s.properties){let b=m.parsedKey?ne(m.parsedKey,t,n,d):m.key,h=m.value;if(h.type===x.LITERAL)p[b]=h.value;else if(h.type===x.VARIABLE){let y=h.path;if(y===o)p[b]=u;else if(y===l)p[b]=c;else if(y.startsWith(o+".")){let w=y.substring(o.length+1);!w.includes(".")&&!w.includes("[")?p[b]=u[w]:p[b]=ve(y,n,{...i,[o]:u,...l&&{[l]:c}})}else p[b]=ve(y,n,{...i,[o]:u,...l&&{[l]:c}})}else if(h.type===x.INTERPOLATION){let y=[];for(let w of h.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=w.path,E;if(g===o)E=u;else if(g===l)E=c;else if(g.startsWith(o+".")){let k=g.substring(o.length+1);!k.includes(".")&&!k.includes("[")?E=u[k]:E=ve(g,n,{...i,[o]:u,...l&&{[l]:c}})}else E=ve(g,n,{...i,[o]:u,...l&&{[l]:c}});y.push(E!=null?String(E):"")}else{let g={...i,[o]:u,...l&&{[l]:c}},E=ne(w,t,n,g);y.push(E!=null?String(E):"")}p[b]=y.join("")}else{let y={...i,[o]:u,...l&&{[l]:c}};p[b]=ne(h,t,n,y)}}r.push(p)}return r}return null},Om=(e,t,n)=>{let i=e.body;if(i.type===x.OBJECT&&i.properties.length===1&&i.properties[0].key==="$if item.visible"){let r=i.properties[0].value;if(r.type===x.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===x.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===x.OBJECT&&s.properties.length===2){let o=s.properties[0],l=s.properties[1];if(o.key==="id"&&o.value.type===x.VARIABLE&&o.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===x.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let d={id:p.id};p.highlighted?(d.highlight=!0,d.message=`This item is highlighted: ${p.name}`):(d.highlight=!1,d.message=p.name),c.push(d)}}return c}}}}return null},Rm=(e,t,n,i)=>{let a=ne(e.iterable,t,n,i);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let d=e.iterable.args.map(f=>f.type===x.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===x.VARIABLE?f.path:f.type===x.FUNCTION?`${f.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${d})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw gl(p,a,u)}if(!e.indexVar){let c=Om(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=xm(e,a);if(c!==null)return c}let r=Sm(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===x.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===x.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,n,u);if(Array.isArray(p)&&p.length===1&&!l){let d=p[0];s.push(d===void 0?{}:d)}else s.push(p===void 0?{}:p)}return s},$m=(e,t,n,i)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?ne(a.parsedKey,t,n,i):a.key,s=a.value;if(s.type===x.OBJECT&&s.properties.length<=10&&!s.whenCondition){let o={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?ne(u.parsedKey,t,n,i):u.key,d=u.value;if(d.type===x.LITERAL)l[p]=d.value;else if(d.type===x.VARIABLE)l[p]=ve(d.path,n,i);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let b=ve(m.path,n,i);f.push(b!=null?String(b):"")}else{c=!1;break}if(!c)break;l[p]=f.join("")}else if(d.type===x.OBJECT&&d.properties.length<=5){let f={};for(let m of d.properties){let b=m.key,h=m.value;if(h.type===x.LITERAL)f[b]=h.value;else if(h.type===x.VARIABLE)f[b]=ve(h.path,n,i);else if(h.type===x.INTERPOLATION){let y=[];for(let w of h.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=ve(w.path,n,i);y.push(g!=null?String(g):"")}else{c=!1;break}if(!c)break;f[b]=y.join("")}else{c=!1;break}}if(!c)break;l[p]=f}else{c=!1;break}}if(c)return o[r]=l,o}}return null},Cm=(e,t,n,i)=>{let a=t.functions||t;if(e.whenCondition&&!wr(e.whenCondition,a,n,i))return;let r=$m(e,t,n,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,n,i):u.key,d=u.value;if(d.type===x.LITERAL)c[p]=d.value;else if(d.type===x.VARIABLE)c[p]=ve(d.path,n,i);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let b=ve(m.path,n,i);f.push(b!=null?String(b):"")}else{let b=ne(m,t,n,i);f.push(b!=null?String(b):"")}c[p]=f.join("")}else c[p]=ne(d,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=ne(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 ne(c.value,t,n,i)}else{let u=c.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(d=>d.key.startsWith("$for "));if(p){let d=ne(p.value,t,n,i);d!==void 0&&(s[c.key]=d)}else{let d=ne(c.value,t,n,i);d!==void 0&&(s[c.key]=d)}}else{let p=c.parsedKey?ne(c.parsedKey,t,n,i):c.key,d=ne(c.value,t,n,i);d!==void 0&&(s[p]=d)}}return s},Al={},_m=(e,t,n,i)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let s=ne(r,t,n,i);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=ne(r,t,n,i);s!==Al&&s!==void 0&&a.push(s)}return a},jm=(e,t,n,i)=>{let{name:a,data:r,whenCondition:s}=e,o=t.partials||{},l=t.functions||t;if(s&&!wr(s,l,n,i))return;if(!o[a])throw new Ce(`Partial '${a}' is not defined`);let c=i._partialStack||[];if(c.includes(a))throw new Ce(`Circular partial reference detected: ${a}`);let u=o[a],p=n,d={...i,_partialStack:[...c,a]};if(i){p={...n};for(let f of Object.keys(i))f.startsWith("_")||(p[f]=i[f])}if(r){let f=ne(r,t,n,i);p={...p,...f}}return ne(u,t,p,d)},Nm=(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 Ce(`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 Ce(`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 Ce(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return o.length>0&&(l+="."+o.join(".")),l};var Ui=Im;var Dm=/\$\{([^}]*)\}/g,Tm=/#\{([^}]*)\}/g,El=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,i,a]=n,r=Lm(a,t);return{isFunction:!0,type:x.FUNCTION,name:i,args:r}},Lm=(e,t={})=>e.trim()?Mm(e).map(i=>qm(i.trim(),t)):[],Mm=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},qm=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:x.LITERAL,value:parseFloat(e)};if(e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};let n=El(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=Lr(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 Pe(i,t)}catch{return{type:x.VARIABLE,path:i}}return{type:x.VARIABLE,path:i}},xl=/^\w+\(.*\)$/,Vm=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Fm=e=>{if(!(!e||e.trim()===""||xl.test(e))&&Vm.test(e))throw e.includes("?")&&e.includes(":")?new T(`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 T(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new T(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Pl=e=>{let t=e.trim();if(xl.test(t))throw new T(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new T(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new T(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new T(`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 T(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:t}},Ct=(e,t={})=>{let n=e.trim();Fm(n);let i=El(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:x.VARIABLE,path:n}},Bi=(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(Dm)],r=[...n.matchAll(Tm)],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:x.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"?Ct(c[1],t):Pl(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:n};throw p}}let o=[],l=0;for(let{match:c,type:u}of s){let[p,d]=c,f=c.index;if(f>l){let m=n.substring(l,f);for(let b=0;b<i.length;b++)m=m.replace(`__ESCAPED_${b}__`,i[b]);m&&o.push(m)}try{let m;u==="variable"?m=Ct(d.trim(),t):m=Pl(d.trim()),o.push(m)}catch(m){if(m.message==="Invalid array index syntax")o.push(p);else throw m}l=f+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:x.INTERPOLATION,parts:o}};var Xi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Rl=e=>Object.keys(e),Oe=e=>e.join("."),Ir=(e,t,n)=>{let i=Rl(e).filter(a=>!t.has(a));if(i.length>0)throw new T(`Unexpected key '${i[0]}' in condition JSON at '${Oe(n)}'`)},vr=(e,t)=>typeof e=="string"?Bi(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?Bm(e,t):Ym(e,t):{type:x.LITERAL,value:e},Um=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new T("$each value must be a non-empty string");let i=t.trim();if(i==="")throw new T("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new T("Empty $each body not allowed");if(n.$partial!==void 0)throw new T("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${i}`]:n}},Bm=(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=Um(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=Ol(c[0],l[c[0]],t,!0);n.push(u),i=!0;continue}}catch(l){throw l instanceof T?l:new T(l.message)}let o=Object.keys(r);if(o.length===1&&/^\$for(?::\w+)?\s/.test(o[0])){let l=Ol(o[0],r[o[0]],t);n.push(l),i=!0;continue}}let s=vr(r,t);n.push(s),(s.type===x.FUNCTION||s.type===x.CONDITIONAL||s.type===x.LOOP||s.type===x.PARTIAL||s.type===x.OBJECT&&!s.fast||s.type===x.ARRAY&&!s.fast)&&(i=!0)}return{type:x.ARRAY,items:n,fast:!i}},Ym=(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 T("$partial value must be a string");if(e.$partial.trim()==="")throw new T("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let w of l)if(y===w||y.startsWith(w+" ")||y.startsWith(w+"#")){c.push(w);break}if(c.length>0)throw new T(`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,...d}=e,f={},m=!1;for(let[y,w]of Object.entries(d)){let g=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(g=y.slice(1)),f[g]=w,m=!0}let b=null;if(m&&(b=vr(f,t),b.type===x.OBJECT)){let y=!1;for(let w of b.properties)if(w.value.type===x.VARIABLE||w.value.type===x.INTERPOLATION||w.value.type===x.FUNCTION||w.value.type===x.CONDITIONAL||w.value.type===x.OBJECT&&!w.value.fast||w.value.type===x.ARRAY&&!w.value.fast){y=!0;break}y&&(b.fast=!1)}let h={type:x.PARTIAL,name:u,data:b};return p!==void 0&&(h.whenCondition=Sl(p,t)),h}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new T("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new T("Missing condition expression after '$when'");a=Sl(c,t),i=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new T("'$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 T("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=zm(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 T(`$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 T(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new T("Missing condition expression after '$if'");{let u=vr(c,t);(u.type===x.FUNCTION||u.type===x.CONDITIONAL||u.type===x.PARTIAL||u.type===x.OBJECT&&!u.fast||u.type===x.ARRAY&&!u.fast)&&(i=!0);let p=Bi(l,t),d={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(d.parsedKey=p),n.push(d),s++}}}let o={type:x.OBJECT,properties:n,fast:!i};return a&&(o.whenCondition=a),o},zm=(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 T(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Fi(c);let u=Pe(c,n);for(i.push(u),a.push(vr(o,n)),r++;r<e.length;){let[p,d]=e[r],f=!1,m;if(l?p.startsWith(`$elif#${l} `)?(m=p.substring(`$elif#${l} `.length),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(f=!0,m=null):p.startsWith("$elif ")?(m=p.substring(6),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p==="$else"||p==="$else:")&&(f=!0,m=null),f){if(m===null)i.push(null);else{Fi(m);let b=Pe(m,n);i.push(b)}if(a.push(vr(d,n)),r++,m===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:i,bodies:a,id:l},nextIndex:r}},Yi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},zi={all:ee.AND,any:ee.OR},Xm=new Set(["var","literal","call","not",...Object.keys(Yi),...Object.keys(zi)]),Gm=(e,t,n)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${Oe(n)}' requires an array`);if(e.length!==2)throw new T(`Condition JSON operator '${t}' at '${Oe(n)}' requires exactly 2 operands`);return e},Hm=(e,t,n,i,a)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${Oe(a)}' requires an array`);if(e.length===0)throw new T(`Condition JSON operator '${t}' at '${Oe(a)}' requires at least 1 condition`);return e.map((s,o)=>je(s,i,[...a,o])).reduce((s,o)=>({type:x.BINARY,op:n,left:s,right:o}))},Km=(e,t,n)=>{let i,a;if(typeof e.call=="string")i=e.call,a=e.args??[],Ir(e,new Set(["call","args"]),n);else if(Xi(e.call))i=e.call.name,a=e.call.args??[],Ir(e,new Set(["call"]),n),Ir(e.call,new Set(["name","args"]),[...n,"call"]);else throw new T(`Condition JSON call at '${Oe(n)}' requires a function name`);if(typeof i!="string"||i.trim()==="")throw new T(`Condition JSON call at '${Oe(n)}' requires a non-empty function name`);if(!/^\w+$/.test(i))throw new T(`Invalid condition JSON function name '${i}' at '${Oe(n)}'`);if(!Array.isArray(a))throw new T(`Condition JSON call '${i}' at '${Oe(n)}' requires args to be an array`);return{type:x.FUNCTION,name:i,args:a.map((r,s)=>je(r,t,[...n,"args",s]))}},je=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:x.LITERAL,value:e};if(Array.isArray(e))throw new T(`Condition JSON array at '${Oe(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Xi(e))throw new T(`Invalid condition JSON value at '${Oe(n)}'`);let i=Rl(e);if(i.length===0)throw new T(`Condition JSON object at '${Oe(n)}' must contain an operator`);let a=i.filter(s=>Xm.has(s));if(a.length===0)throw new T(`Unknown condition JSON operator '${i[0]}' at '${Oe(n)}'`);if(a.length>1)throw new T(`Condition JSON at '${Oe(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(Ir(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new T(`Condition JSON var at '${Oe(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return Ir(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(r==="call")return Km(e,t,n);if(r==="not")return Ir(e,new Set(["not"]),n),{type:x.UNARY,op:st.NOT,operand:je(e.not,t,[...n,"not"])};if(r in zi)return Ir(e,new Set([r]),n),Hm(e[r],r,zi[r],t,[...n,r]);if(r in Yi){Ir(e,new Set([r]),n);let s=Gm(e[r],r,[...n,r]);return{type:x.BINARY,op:Yi[r],left:je(s[0],t,[...n,r,0]),right:je(s[1],t,[...n,r,1])}}throw new T(`Unknown condition JSON operator '${r}' at '${Oe(n)}'`)},Sl=(e,t={})=>{if(e==null)throw new T("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression after '$when'");return Pe(e,t)}return Xi(e)||Array.isArray(e)?je(e,t):{type:x.LITERAL,value:e}},Pe=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let d=0;d<c.length;d++)if(c[d]==="("?u++:c[d]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Pe(c,t)}let n=Lr(e,"||");if(n!==-1)return{type:x.BINARY,op:ee.OR,left:Pe(e.substring(0,n).trim(),t),right:Pe(e.substring(n+2).trim(),t)};let i=Lr(e,"&&");if(i!==-1)return{type:x.BINARY,op:ee.AND,left:Pe(e.substring(0,i).trim(),t),right:Pe(e.substring(i+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Lr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Pe(e.substring(0,p).trim(),t),right:Pe(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,o=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of o){let p=0;for(;p<e.length;){let d=Lr(e.substring(p),c);if(d===-1)break;let f=p+d;f>r&&(r=f,s={op:c,type:u}),p=f+c.length}}if(r!==-1&&s)return{type:x.BINARY,op:s.type,left:Pe(e.substring(0,r).trim(),t),right:Pe(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Lr(e,c)!==-1)throw new T(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:st.NOT,operand:Pe(e.substring(1).trim(),t)}:$l(e,t)},Lr=(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},Wm=e=>{if(e=e.trim(),e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:x.LITERAL,value:""};if(e==="{}")return{type:x.LITERAL,value:{}};if(e==="[]")return{type:x.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:x.LITERAL,value:t}:{type:x.VARIABLE,path:e}},$l=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return Ct(n,t);let a=Wm(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return Ct(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Jm=(e,t=!1)=>{let n=t?"$each":"$for";try{hl(e)}catch(i){if(i instanceof T&&t){let a=i.message.replace(/\$for/g,"$each");throw new T(a.replace("Parse Error: ",""))}throw i}},Ol=(e,t,n,i=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let h=i?"$each":"$for";throw new T(`Invalid loop syntax (got: '${e.replace("$for",h)}')`)}let s=r[1],o=r[2].trim();Jm(o,i);let l=o.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let h=i?"$each":"$for";throw new T(`Invalid loop syntax - missing 'in' keyword (got: '${h} ${o}')`)}let c=l[1].trim(),u=l[2].trim(),p,d=null;if(c.includes(",")){let h=c.split(",").map(y=>y.trim());if(h.length!==2)throw new T(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=h[0],d=h[1]}else p=c;let f=["this","undefined","null","true","false"];if(f.includes(p))throw new T(`Reserved variable name: ${p}`);if(d&&f.includes(d))throw new T(`Reserved variable name: ${d}`);let m=$l(u,n),b=vr(t,n);return{type:x.LOOP,itemVar:p,indexVar:d,iterable:m,body:b,flatten:s!=="nested"}};var Qm=(e,t={})=>{let{functions:n={}}=t;return vr(e,n)},Dn=Qm;var _t={};um(_t,{now:()=>Zm});var Zm=()=>Date.now();var ey=(e,t,n={})=>{let{functions:i={},partials:a={}}=n,r={..._t,...i},s=Dn(e,{functions:r}),o={};for(let[l,c]of Object.entries(a))o[l]=Dn(c,{functions:r});return Ui(s,t,{functions:r,partials:o})},Mr=ey;var ry=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",ty=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,ny=(e,t)=>{if(ry(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression");return Pe(e,t)}return je(e,t)},sy=(e,t={},n={})=>{let i=ty(n),a={..._t,...i},r=ny(e,a);return!!wr(r,{functions:a,partials:{}},t,{})},Gi=sy;var to=Symbol("runStoreTransaction"),Ji="__routeEngineConditionComparison",Tn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",kr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Tn(e,t)&&e>t,gte:(e,t)=>Tn(e,t)&&e>=t,lt:(e,t)=>Tn(e,t)&&e<t,lte:(e,t)=>Tn(e,t)&&e<=t}),Ml=Object.freeze(Object.fromEntries(Object.keys(kr).map(e=>[e,`${Ji}${e}`]))),iy=Object.freeze(Object.fromEntries(Object.entries(Ml).map(([e,t])=>[t,kr[e]]))),Cl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),oy=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},Ln=e=>{if(Array.isArray(e))return e.map(Ln);if(e===null||typeof e!="object"||Cl(e,"literal")||Cl(e,"var"))return e;if(oy(e)?.startsWith(Ji))throw new Error(`Condition function names beginning with "${Ji}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[i,a]]=n,r=Ml[i];if(r)return{call:r,args:a.map(Ln)}}return Object.fromEntries(n.map(([i,a])=>[i,Ln(a)]))},Nt=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return je(e),Gi(Ln(e),t,{functions:iy})},ay=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ql=(e,t,n={})=>{let i={},a={},{transformSelectorFirstArgument:r=b=>b,transformActionFirstArgument:s=b=>b,createTransactionalMetadata:o,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof o=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(o())}:{}},d=0,f=(b,h)=>!u||!c?b:Nn(b,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:h.state,previousTransactionalMetadata:h.transactionalMetadata})});for(let[b,h]of Object.entries(t))b!=="createInitialState"&&(b.startsWith("select")?i[b]=(...y)=>h(r(p.state,p.transactionalMetadata),...y):a[b]=(...y)=>{let w,g=p,E=Nn(p,k=>{let P=h(s(k.state,k.transactionalMetadata),...y);w=P!==void 0&&!Ae(P)?P:void 0,u&&l&&l({actionName:b,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});return d===0&&(E=f(E,g)),p=E,w});let m=b=>{if(typeof b!="function")throw new Error("Store transaction requires a callback");let h=p,y=d===0;d+=1;let w;try{w=b()}catch(g){throw d-=1,p=h,g}if(d-=1,y)try{p=f(p,h)}catch(g){throw p=h,g}return w};return{...i,...a,[to]:m}},Fn=(e,t)=>n=>{let i=e(),a=Array.isArray(n)?n:[n];return Nn(i,r=>{a.forEach(s=>{t.forEach(o=>{o(r,s)})})})};var ly=(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{}}},J=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Qi=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},ke=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),cy=new Set(["pageSize","groups"]),uy=new Set(["id","variants"]),py=new Set(["id","imageId"]),fy=new Set(["pageSize","tracks"]),dy=new Set(["id","soundId","title","artist","album","description","coverImageId"]),my=new Set(["pageSize","replays"]),yy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),qr=(e,t,n)=>{Object.keys(e).forEach(i=>{if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)})},it=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Dt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!ke(t))throw new Error("resources.imageGallery must be an object");if(qr(t,cy,"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(!ke(a))throw new Error(`${r} must be an object`);if(qr(a,uy,r),it(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(!ke(l))throw new Error(`${c} must be an object`);if(qr(l,py,c),it(l.id,`${c}.id`),it(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),!J(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},Tt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!ke(t))throw new Error("resources.musicRoom must be an object");if(qr(t,fy,"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(!ke(a))throw new Error(`${r} must be an object`);qr(a,dy,r);for(let l of["id","soundId","title"])it(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&it(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=e?.resources?.sounds?.[a.soundId];if(!J(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!ke(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&&!J(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},hy=(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}"`)}},Lt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!ke(t))throw new Error("resources.sceneReplay must be an object");if(qr(t,my,"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(!ke(r))throw new Error(`${s} must be an object`);qr(r,yy,s);for(let u of["sceneId","title","thumbnailImageId"])it(r[u],`${s}.${u}`);if(i.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(i.add(r.sceneId),!J(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let o=n[r.sceneId];if(!o)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=o.initialSectionId,c=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(!ke(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let d=e?.resources?.variables?.[u];if(!d)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(Re(d))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(d.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(d.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);hy(u,d,p)}}}},Vl=e=>{let t=Ae(e)?br(e):e;return structuredClone(t)},gy=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!J(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},Un=({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=gy({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},Re=e=>J(e,"computed"),no=(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}},Mt=(e={},t={},{allowedScopes:n,preserveUnknown:i=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?i:!Re(s)&&(!n||n.includes(s.scope))&&no(s,r)})),Ye=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),by=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ye(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 Ye(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Ye(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 Ye(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
2
- `,r:"\r",t:" ",b:"\b",f:"\f"};if(!J(l,o))throw Ye(t,n);a+=l[o]}return a},Fl=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ye(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 Ye(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 Ye(e,t);i+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Ye(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 Ye(e,t);i+=1,n.push(by(p,e,t));return}i+=1}if(c||i>=e.length)throw Ye(e,t)};for(a();i<e.length;){if(e[i]==="."){i+=1,a();continue}if(e[i]==="["){r();continue}throw Ye(e,t)}return n},Hi=(e,t)=>{let n=e;for(let i of t){if(n==null||!J(n,i))return;n=n[i]}return n},Ul=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Fl(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 Hi(s,r)}return i==="runtime"?Hi(t.runtime,n.slice(1)):Hi(t,n)},Bl=(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)`)},Zi=(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`)},wy=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Ge=(e,t,n,i)=>(Bl(e,t,i),t.map(a=>Vn(a,n))),Be=(e,t,n,i)=>{let a=Ge(e,t,n,i);return a.forEach(r=>wy(e,r)),a},Iy=(e,t,n)=>{switch(e){case"var":return Ul(t,n);case"add":{let[i,a]=Be(e,t,n,2);return i+a}case"sub":{let[i,a]=Be(e,t,n,2);return i-a}case"mul":{let[i,a]=Be(e,t,n,2);return i*a}case"div":{let[i,a]=Be(e,t,n,2);return i/a}case"mod":{let[i,a]=Be(e,t,n,2);return i%a}case"neg":{let[i]=Be(e,t,n,1);return-i}case"round":{let[i]=Be(e,t,n,1);return Math.round(i)}case"floor":{let[i]=Be(e,t,n,1);return Math.floor(i)}case"ceil":{let[i]=Be(e,t,n,1);return Math.ceil(i)}case"min":{let[i,a]=Be(e,t,n,2);return Math.min(i,a)}case"max":{let[i,a]=Be(e,t,n,2);return Math.max(i,a)}case"clamp":{let[i,a,r]=Be(e,t,n,3);return Math.min(r,Math.max(a,i))}case"eq":{let[i,a]=Ge(e,t,n,2);return kr.eq(i,a)}case"neq":{let[i,a]=Ge(e,t,n,2);return kr.neq(i,a)}case"gt":{let[i,a]=Ge(e,t,n,2);return kr.gt(i,a)}case"gte":{let[i,a]=Ge(e,t,n,2);return kr.gte(i,a)}case"lt":{let[i,a]=Ge(e,t,n,2);return kr.lt(i,a)}case"lte":{let[i,a]=Ge(e,t,n,2);return kr.lte(i,a)}case"in":{let[i,a]=Ge(e,t,n,2);return Array.isArray(a)?a.includes(i):!1}case"and":case"all":return Zi(e,t),t.every(i=>!!Vn(i,n));case"or":case"any":return Zi(e,t),t.some(i=>!!Vn(i,n));case"not":{let[i]=Ge(e,t,n,1);return!i}case"length":{let[i]=Ge(e,t,n,1);return typeof i=="string"||Array.isArray(i)?i.length:ke(i)?Object.keys(i).length:0}case"includes":{let[i,a]=Ge(e,t,n,2);return typeof i=="string"?typeof a=="string"&&i.includes(a):Array.isArray(i)?i.includes(a):!1}case"literal":return Vl(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Vn=(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 Iy(i,a,t)},eo=(e,t)=>{if(e===null||typeof e!="object"||J(e,"literal"))return e;if(J(e,"var"))return{literal:Ul(e.var,t)};if(J(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=>eo(a,t)):eo(i,t)]))},vy=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return je(e),Nt(eo(e,t))},Yl=(e,t)=>{if(!ke(e))throw new Error(`${t} must be an object`);let n=J(e,"expr"),i=J(e,"value");if(n===i)throw new Error(`${t} must contain exactly one of expr or value`)},Ki=(e,t,n)=>(Yl(e,t),J(e,"value")?Vl(e.value):Vn(e.expr,n)),ky=(e,t={},n="unknown")=>{if(!ke(e))throw new Error(`Computed variable "${n}" computed must be an object`);let i=J(e,"expr"),a=J(e,"value");if(J(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(!ke(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(!ke(o))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!J(o,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(vy(o.when,t))return Ki(o,`Computed variable "${n}" branch ${s}`,t)}return Ki(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 Ki(e,`Computed variable "${n}"`,t)},zl=(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}`)}},Ay=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}),Py=new Set(["and","or","all","any"]),Ey=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),xy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Sy=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Oy=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Xl=new WeakMap,_l=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Mn=(e,t,n)=>{for(let i of Object.keys(e))if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)},Ry=(e,t,n,i)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${i} expected type ${t}, got ${n}`)},Gl=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,o,...l]=Fl(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(!J(n,o))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${o}"`);let c=n[o];return Re(c)&&i.add(o),l.length===0?c?.type:void 0},Hl=(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 _l(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 Gl(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 _l(o)}let l=Ay[s];if(l===void 0&&!Py.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?Zi(s,o):Bl(s,o,l);let c=o.map((u,p)=>Hl(u,{variableId:t,variableConfigs:n,dependencies:i,path:`${a}.${s}[${p}]`}));if(xy.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Ey.has(s))return"number";if(Sy.has(s))return"boolean"},$y=(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{je(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"||J(s,"literal"))return;if(J(s,"var")){Gl(s.var,{variableId:t,variableConfigs:n,dependencies:i,path:o});return}if(J(s,"call"))throw new Error(`Computed variable "${t}" ${o} function calls are not supported`);if(J(s,"not")){r(s.not,`${o}.not`);return}let l=Object.keys(s).find(c=>Oy.has(c));s[l].forEach((c,u)=>{r(c,`${o}.${l}[${u}]`)})};r(e,a)},Wi=(e,{variableId:t,variableConfig:n,variableConfigs:i,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(Yl(e,`Computed variable "${t}" ${r}`),Mn(e,s,r),J(e,"value")){zl(t,n.type,e.value);return}let o=Hl(e.expr,{variableId:t,variableConfigs:i,dependencies:a,path:`${r}.expr`});Ry(t,n.type,o,`${r}.expr`)},Cy=(e,t,n)=>{let i=t.computed;if(!ke(i))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=J(i,"expr"),s=J(i,"value");if(J(i,"branches")){if(Mn(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(!ke(i.default))throw new Error(`Computed variable "${e}" requires default`);return i.branches.forEach((l,c)=>{if(!ke(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Mn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!J(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);$y(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),Wi(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),Wi(i.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Mn(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 Wi(i,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},Vr=(e={})=>{if(!ke(e))throw new Error("Variable configs must be an object");if(J(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(J(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if(Re(s)){if(!ke(s))throw new Error(`Computed variable "${r}" must be an object`);if(!J(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!J(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(J(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(qt(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,Cy(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 d=[...o.slice(p).map(({variableId:f})=>f),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${d}`)}l.set(u,o.length),o.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(i)});return Xl.set(e,a),a},ot=({variables:e={},runtime:t={},variableConfigs:n={},eager:i=!0}={})=>{let{evaluationOrder:a}=Xl.get(n)??Vr(n),r=Mt(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,h])=>Re(h)).map(([h])=>h),o=Object.create(null),l=[],c=new Map(a.map((h,y)=>[h,y])),u=-1,p=!1,d=h=>{if(J(o,h))return o[h];let y=n[h];if(!Re(y))return J(r,h)?r[h]:void 0;let w=l.indexOf(h);if(w>=0){let g=[...l.slice(w),h].join(" -> ");throw new Error(`Computed variable cycle detected: ${g}`)}l.push(h);try{let g=ky(y.computed,b,h);return zl(h,y.type,g),Qi(o,h,g),g}finally{l.pop()}},f=h=>{if(J(o,h))return o[h];let y=n[h];if(!Re(y))return J(r,h)?r[h]:void 0;let w=c.get(h);if(i&&!p&&w!==void 0&&w>u){p=!0;try{for(let g=u+1;g<=w;g+=1)d(a[g]),u=g}finally{p=!1}return o[h]}return d(h)},m=new Proxy({},{get:(h,y)=>{if(typeof y=="string")return f(y)},has:(h,y)=>typeof y=="string"&&(J(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(h,y)=>{if(!(typeof y!="string"||!J(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),b={variables:m,runtime:t,resolveVariable:f};return i?(s.forEach(h=>{f(h)}),{...r,...o}):m},_y=({variables:e={},runtime:t={},variableConfigs:n,projectData:i}={})=>{let a=n??i?.resources?.variables??{};return Vr(a),ot({variables:e,runtime:t,variableConfigs:a,eager:!0})},Bn=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([i,a])=>{if(Re(a))return;let r=ly(a,i);a.scope==="context"?Qi(t,i,r):Qi(n,i,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},qt=(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(", ")}`)},Vt=(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(", ")}`)},jy=2,jl=12,Kl=(e=jy)=>{if(!Number.isInteger(e)||e<0||e>jl)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${jl}.`);return e},Ny=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},qn=e=>typeof e=="number"&&Number.isFinite(e),Yn=(e,t,n,i,a={})=>{if(e==="number"){if(t==="set"&&!qn(n))throw new Error(`Operation "set" requires value to be a number for variable "${i}".`);if(t==="multiply"&&!qn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${i}".`);if(t==="divide"&&!qn(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}".`);Kl(a.roundTo)}}},zn=(e,t,n,i={})=>{let a=(s,o,l)=>{let c=s??o;if(!qn(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 Ny(a(e,0,"current value")/r(n),Kl(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 so=(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:ay[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])},Dy=(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},jt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Ty=(e,t)=>{let n=e?.character?.sprite,i=t?.character?.sprite,a=jt(n)?n:void 0,r=jt(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},Nl=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},Dl=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Tl=(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,Ly=(e,t)=>{let n={},i=Tl(Nl(e),Nl(t)),a=Tl(Dl(e),Dl(t));return i&&(n.resource=i),a&&(n.color=a),Object.keys(n).length>0?n:null},io=(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(d=>d.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=Ly(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=Dy(e.dialogue,t.dialogue);s&&(n.dialogue=s);let o=Ty(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},oo=(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},My=(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},Ll=e=>e!==null&&typeof e=="object"?structuredClone(e):e,qy=(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 Ll(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=My(i,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return Ll(r)},Vy={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"])},Fy=(e,t)=>{let n=e[e.length-1];return n?Vy[n]?.has(t)===!0:!1},ro=(e,t,n=[])=>Array.isArray(e)?e.map(i=>ro(i,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,Fy(n,i)?a:ro(a,t,[...n,i])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?qy(e,t,"_event"):Mr(e,t):e,Ft=(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 ro(e,t)};var Uy=11102230246251565e-32,Wl=128,Jl=1e3,Ql=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ut=(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`)},Xn=(e,t)=>{if(!Ql(e))throw new Error(`${t} must be an object`)},Gn=(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},By=(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},ao=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)},Yy=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),Zl=e=>{let t=e??Yy();if(!Ql(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}}},zy=(e,t)=>{let n=4294967296-4294967296%t;for(let i=0;i<Wl;i+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${Wl} rejected samples`)},Xy=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},Gy=(e,t)=>{if(Ut(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=Gn(e.min,"random.distribution.min"),a=Gn(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 ao({type:"integer",value:a===1?n:n+zy(t,a)})},Hy=(e,t)=>{if(Ut(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>Jl)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(Xn(c,p),Ut(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Xn(c.actions,`${p}.actions`),{weight:By(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<=Uy))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Xy(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 ao({type:"weighted",outcomeIndex:l})},ec=(e,{randomSource:t})=>{Xn(e,"random.distribution");let i={integer:Gy,weighted:Hy}[e.type];if(!i)throw new Error('random.distribution.type must be "integer" or "weighted"');return i(e,t)},Hn=(e,t)=>{if(Xn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Ut(e,new Set(["type","value"]),"random result"),Gn(e.value,"random result.value");else if(t==="weighted")Ut(e,new Set(["type","outcomeIndex"]),"random result"),Gn(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:Jl-1});else throw new Error(`unsupported recorded random result type: ${t}`);return ao(e)};var Fr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),nc=Object.freeze([Fr("cleanup",["clearPendingEffects","cleanAll"]),Fr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Fr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Fr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Fr("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"]),Fr("persistence",["saveSlot"]),Fr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),at=new Map;nc.forEach(e=>{e.actions.forEach(t=>{if(at.has(t))throw new Error(`duplicate action execution key: ${t}`);at.set(t,at.size)})});var Ky=new Set(nc.find(({name:e})=>e==="navigation").actions),rc=at.get("saveSlot")-.5,tc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",Wy=(e,t)=>e<t?-1:e>t?1:0,Kn=e=>Object.entries(e).sort((t,n)=>{let i=tc(...t),a=tc(...n),r=at.get(i),s=at.get(a),o=r??rc,l=s??rc;return o!==l?o-l:r!==void 0&&s!==void 0?0:Wy(i,a)}),Wn=e=>Ky.has(e),Jn=e=>{let t=e.map(([n])=>n).filter(Wn);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var ce=e=>structuredClone(Ae(e)?br(e):e),se=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Bt=e=>e?.animations?.playback?.continuity==="persistent",z=(e,t)=>se(e??{},t)&&e[t]!==void 0,Qn=e=>z(e,"alpha")||z(e,"opacity"),Jy=e=>z(e,"alpha")?e.alpha:e?.opacity,pc=e=>(z(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),Qy=e=>e?.applyMode==="persistent",Zy="default",eh=e=>Array.isArray(e?.channels)?e.channels.filter(Qy).map(ce):[],Yt=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ce(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},rh=e=>Qn(e)||z(e,"blur")||z(e,"filters"),co=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],fc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],lo=["animationName","animationSpeed","loop"],th=e=>z(e,"transformId")||z(e,"transform")||co.some(t=>z(e,t)),dc=e=>e?.text&&z(e.text,"content")&&z(e.text,"textStyleId"),mc=e=>e?.layout&&Array.isArray(e.layout.elements),nh=e=>z(e,"text")||z(e,"layout"),sc=(e,t)=>e.resourceId?!0:dc(e)?!t?.text:mc(e)?!t?.layout:!1,ic=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,sh=(e,t)=>{let n={...ce(e),...t};if(t.text&&e.text&&(n.text={...ce(e.text),...ce(t.text)}),t.transform&&e.transform&&(n.transform={...ce(e.transform),...ce(t.transform)}),z(t,"transform")){delete n.transformId;for(let i of co)z(t,i)||delete n[i]}else z(t,"transformId")&&delete n.transform;return n},ih=(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(z(e,"text")&&!dc(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(z(e,"layout")&&!mc(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},oc=e=>fc.some(t=>z(e,t)),ac=e=>lo.some(t=>z(e,t)),oh=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let i of fc)!n&&!z(e,i)&&z(t,i)&&(e[i]=t[i]),se(e,i)&&e[i]===void 0&&delete e[i];return e},yc=(e,t,n)=>{let i=e[n];return i?.id===t?.id?i:e.find(a=>a.id===t?.id)},ah=(e,t)=>{if(!t)return e;let n=z(e,"transform");for(let i of co)!n&&!z(e,i)&&z(t,i)&&(e[i]=t[i]),se(e,i)&&e[i]===void 0&&delete e[i];return e},lh=(e,t)=>(t&&(!z(e,"opacity")&&z(t,"opacity")&&(e.opacity=t.opacity),!z(e,"blur")&&z(t,"blur")&&(e.blur=ce(t.blur)),!z(e,"filters")&&z(t,"filters")&&(e.filters=ce(t.filters)),se(e,"opacity")&&e.opacity===void 0&&delete e.opacity,se(e,"blur")&&e.blur===void 0&&delete e.blur,se(e,"filters")&&e.filters===void 0&&delete e.filters),e),hc=(e,t,n=[],{hasPatchFn:i=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let r=e.map((s,o)=>{let l=yc(n,s,o),c=t(s,l),u=rh(s),p=th(s),d=i(s),f=se(s,"animations"),m=pc(ce(s));if(!c&&(u||p||d)&&l&&(m=a?a(l,m):{...ce(l),...m}),!f){let b=l?t(l):!1,h=t(m);b&&h&&Bt(l)?m.animations=ce(l.animations):delete m.animations}return lh(ah(m,l),l)}).filter(s=>t(s)||s.animations);return{hasValidItems:r.length>0,processedItems:r}},ch=e=>{if(e){if(e.character&&se(e.character,"name"))return e.character.name;if(se(e,"characterName"))return e.characterName}},gc=e=>!!e?.character&&se(e.character,"sprite"),uh=e=>{let t={},n=!1,i=ch(e);return i!==void 0&&(t.name=i,n=!0),gc(e)&&(t.sprite=ce(e.character.sprite),n=!0),n?t:void 0},lc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},cc=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>se(t,"persistSprite")?t.persistSprite===!0:se(e,"persistSprite")?e.persistSprite===!0:n&&!se(t,"characterId"),uc=({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 se(c,"name")?o.name=c.name:(i&&!n||u)&&se(l,"name")&&(o.name=ce(l.name)),se(c,"sprite")?o.sprite=ce(c.sprite):(a||p)&&se(l,"sprite")&&(o.sprite=ce(l.sprite)),Object.keys(o).length>0?o:void 0},ph=({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=>ce(a)):delete e.initialRevealedContent,e.content=[...i,...t]},fh=()=>({}),dh=(e,t)=>{if(!t.screen)return;let n=Qn(t.screen),i=z(t.screen,"blur"),a=se(t.screen,"animations");if(!n&&!i){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=Jy(t.screen):z(r,"opacity")&&(s.opacity=r.opacity),i?s.blur=ce(t.screen.blur):z(r,"blur")&&(s.blur=ce(r.blur)),se(s,"opacity")&&s.opacity===void 0&&delete s.opacity,se(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},mh=(e,t)=>{if(t.background){let n=z(t.background,"resourceId"),i=z(t.background,"colorId"),a=Qn(t.background),r=z(t.background,"blur"),s=z(t.background,"filters"),o=z(t.background,"transformId"),l=oc(t.background),c=ac(t.background),{animationsOnly:u,state:p}=Yt(t.background,m=>z(m,"resourceId")||z(m,"colorId")||Qn(m)||z(m,"blur")||z(m,"filters")||z(m,"transformId")||oc(m)||ac(m));if(u){e.background=e.background?{...ce(e.background),...p}:p;return}if(!n&&!i&&!a&&!r&&!s&&!o&&!l&&!c){delete e.background;return}let d=e.background,f=pc(ce(t.background));if(!n&&d?.resourceId){f.resourceId=d.resourceId,!se(f,"transformId")&&d.transformId&&(f.transformId=d.transformId);for(let m of lo)!z(f,m)&&z(d,m)&&(f[m]=d[m])}oh(f,d,{hasAuthoredTransformId:o}),!i&&d?.colorId&&(f.colorId=d.colorId),!a&&z(d,"opacity")&&(f.opacity=d.opacity),!r&&z(d,"blur")&&(f.blur=ce(d.blur)),!s&&z(d,"filters")&&(f.filters=ce(d.filters)),se(f,"resourceId")&&f.resourceId===void 0&&delete f.resourceId,se(f,"colorId")&&f.colorId===void 0&&delete f.colorId,se(f,"animations")&&f.animations===void 0&&delete f.animations,se(f,"transformId")&&f.transformId===void 0&&delete f.transformId,se(f,"opacity")&&f.opacity===void 0&&delete f.opacity,se(f,"blur")&&f.blur===void 0&&delete f.blur,se(f,"filters")&&f.filters===void 0&&delete f.filters;for(let m of lo)se(f,m)&&f[m]===void 0&&delete f[m];if(!f.resourceId&&!f.colorId){delete e.background;return}d?.resourceId===f.resourceId&&d?.transformId===f.transformId&&!se(f,"animations")&&Bt(d)&&(f.animations=ce(d.animations)),e.background=f}else e.background?.animations&&!Bt(e.background)&&(e.background.animations={})},yh=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(lc(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=cc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=uc({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}=Yt(t.dialogue.ui,d=>!!d.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&&ph({dialogueState:e.dialogue,content:t.dialogue.content,append:i}),se(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=se(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=cc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});se(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=se(t.dialogue,"characterId"),o=uh(t.dialogue),l=gc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!i&&delete e.dialogue.characterId;let c=uc({previousCharacter:e.dialogue.character,characterFields:o,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:se(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:i});if(c?e.dialogue.character=c:delete e.dialogue.character,l||lc(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)}},hh=(e,t)=>{let n=eh(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!==Zy);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(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(ce(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},gh=(e,t)=>{if(t.bgm){let n=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!n||n&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=ce(t.bgm),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},bh=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{ih(r,yc(n,r,s))});let{hasValidItems:i,processedItems:a}=hc(t.visual.items,sc,n,{hasPatchFn:nh,mergeItemFn:sh});i?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!sc(n)||!Bt(n))?{...n,animations:{}}:n))},wh=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!ic(a)||!Bt(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:i}=hc(t.character.items,ic,e.character?.items||[]);n?e.character={items:i}:delete e.character},Ih=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},vh=(e,t)=>{if(t.layout){let{animationsOnly:n,state:i}=Yt(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},kh=(e,t)=>{if(t.choice){let{animationsOnly:n,state:i}=Yt(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},Ah=(e,t)=>{if(t.form){let{animationsOnly:n,state:i}=Yt(t.form,a=>!!a.resourceId);if(n){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},Ph=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},Eh=(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=ce(t.voice)}else e.voice&&delete e.voice},xh=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},Ur=e=>Fn(fh,[xh,dh,mh,hh,gh,bh,yh,wh,Ih,vh,kh,Ah,Ph,Eh])(e);var lt=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Mr(e,t);return n&&typeof n=="object"?e:n};var Sh=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"}}),Ar=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}),zt=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Oh=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"}),uo=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),bc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),po=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),wc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Rh=(e,t)=>{let n=Oh[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}"`)},Zn=(e,t)=>{if(Rh(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},fo=(e={})=>{let t=e?.config;if(t===void 0)return{...Ar};if(!wc(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{...Ar};if(!wc(i))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(bc),r=Object.keys(i).find(o=>!a.has(o));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...Ar};return bc.forEach(o=>{i[o]!==void 0&&(s[o]=Zn(o,i[o]))}),s},$h=(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]}},Pr=e=>Object.fromEntries(Object.entries(Sh).map(([t,n])=>{let i=$h(e,n.source),a=i!==void 0?i:Ar[t]??zt[t];return[t,a]})),Ze=(e,t)=>Pr(e)[t],Ic=(e={})=>Object.fromEntries(uo.map(t=>[t,e[t]??Ar[t]]));var ct=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}),cr=Object.freeze({BEHIND_BACKGROUND:ct.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:ct.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:ct.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:ct.VISUAL_BEHIND_CHOICE,FOREGROUND:ct.VISUAL_FOREGROUND}),mo=cr.BEHIND_DIALOGUE,yo=Object.freeze(Object.values(cr).sort((e,t)=>e-t));var Ch={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:so},_h=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,Xt=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return Xt(t);let[n]=Object.keys(t),i=_h.exec(n);if(!i)return Xt(t);let[,a,r,s]=i,o=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[o]:Xt(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Xt(n)])),ur=(e,t)=>{let n={functions:Ch};return Mr(Xt(e),t,n)},Dc=({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".`)},jh=({id:e,targetId:t,animation:n,playback:i,animationPath:a="animation"})=>{let r=structuredClone(n);if(Dc({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,i!==void 0){let s=Lh(i,`${a}.playback`);if(s!==void 0){let o=s.loop===!0?Vc(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&&(!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},Nh=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return Dc({animationType:e.type,animationId:t,animationPath:n}),e.type},Dh=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Th=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Lh=(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},Mh=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},He=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Tc=(e={})=>He(e,"alpha")&&typeof e.alpha=="number"?e.alpha:He(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,Lc=e=>e?.playback?.continuity==="persistent",Ao=e=>Array.isArray(e)?e.map(Ao):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=Ao(e[n]),t),{}),ns=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(Ao(t))},Mc=(e=[])=>e.filter(t=>Lc(t)).map(t=>structuredClone(t)),qc=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,n)=>{let i=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return t+i},0):0,ho=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,qc(n)),0),Vc=e=>Math.max(ho(e?.tween),ho(e?.prev?.tween),ho(e?.next?.tween),qc(e?.mask?.progress)),Fc=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Vc(e)/Mh(e),qh=e=>e.some(t=>t?.playback?.loop===!0),vc=({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(ns).filter(Boolean));return e.some(i=>{if(!Lc(i))return!1;let a=ns(i);return a?n.has(a):!1})},Ke=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:qh(e)||r&&!t||vc({animationInstances:e,activePersistentAnimations:i})?!0:r?!1:vc({animationInstances:e,activePersistentAnimations:a}),Uc=(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 He(s??{},"animations")},Vh=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Fh=(e,t)=>{if(Vh(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Uh=({resources:e,animationId:t,playback:n,instanceId:i,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=e?.animations?.[t];return s?jh({id:i,targetId:a,animation:s,playback:n,animationPath:r}):null},Po=(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},Bh=({content:e,path:t,variables:n})=>Po(e,t).reduce((i,a)=>{let r=lt(a.text,{variables:n});return i+`${r??""}`.length},0),kc=(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))},Ac=(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("-")}`},pt=(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=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},Yh=(e,t={})=>{if(!t?.transformId)return;let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for background`);return n},zh=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Xh=(e={})=>zh.some(t=>He(e,t)),Bc=(e={},t)=>{if(t){if(e.images?.[t])return"sprite";if(e.videos?.[t])return"video";if(e.spritesheets?.[t])return"spritesheet-animation";if(e.layouts?.[t])return"container"}},rs=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Gh=(e={})=>e.textStyles||{},Hh=(e={})=>e.images||{},Kh=.5,Wh=(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]},_o=({id:e,resourceId:t,spritesheet:n,animationName:i,animationSpeed:a,loop:r,width:s,height:o,transform:l={}}={})=>{let c=Wh(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??Kh,loop:r??u.loop??!0}}},Yc=({id:e,item:t,resources:n={}}={})=>{let i=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=n.spritesheets?.[t.resourceId];if(a)return _o({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}`)},Jh=(e={})=>e.colors||{},Qh=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Ht=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,ft=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},go=(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},bo=(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},os=(e,t)=>{if(typeof e!="string"||!Qh.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},Pc=(e,t,n)=>{let i=os(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})`},Zh=(e={},t)=>{let n=Gh(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=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=e.colors?.[n.colorId];if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=go(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:Pc(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=e.colors?.[n.strokeColorId];if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${t}"`);let c=go(n.strokeAlpha,"strokeAlpha",t);o.strokeColor=Pc(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=e.colors?.[n.shadow.colorId];if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${t}"`);o.shadow={color:os(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:go(n.shadow.alpha,"shadow.alpha",t),blur:bo(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:bo(n.shadow.offsetX,"offsetX",t,2),offsetY:bo(n.shadow.offsetY,"offsetY",t,2)}}return o},dt=e=>Array.isArray(e)?e.map(dt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,dt(n)])),Eo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Eo(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]=dt(r);continue}a!=="textStyleId"&&(i[a]=Eo(r,t,Ht(n,a)))}return e.textStyleId!==void 0&&(ft(e.textStyleId,n,"textStyleId"),i.textStyle=Zh(t,e.textStyleId)),i},jo=(e={},t)=>{let n=Jh(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return os(n.hex,`Color "${t}"`)},zc=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",wo=(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 ${zc(`${t}.fill`)} instead`)},eg=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Kt(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let i={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(i[a]=Kt(r,t,Ht(n,a)));return e.colorId!==void 0&&(ft(e.colorId,n,"colorId"),i.fill=jo(t,e.colorId)),i},Kt=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Kt(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 ${zc("fill")} instead`);wo(e,"hover",n),wo(e,"click",n),wo(e,"rightClick",n)}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=dt(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){i[a]=eg(r,t,Ht(n,a));continue}i[a]=Kt(r,t,Ht(n,a))}}return e.type==="rect"&&e.colorId!==void 0&&(ft(e.colorId,n,"colorId"),i.fill=jo(t,e.colorId)),i},Io=(e={},t)=>{let n=Hh(e)?.[t];return n||null},Xc=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Ec=(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 ${Xc(`${t}.${i}`)} instead`)},xc=(e,t,n)=>{let i=e[t];e[t]={...i&&typeof i=="object"&&!Array.isArray(i)?i:{},src:n}},xo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>xo(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 ${Xc(a)} instead`);Ec(e,"hover",n,"src"),Ec(e,"click",n,"src")}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=dt(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(i[a]=xo(r,t,Ht(n,a)))}if(e.type==="sprite"&&e.imageId!==void 0){ft(e.imageId,n,"imageId");let a=Io(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&&(ft(e.hoverImageId,n,"hoverImageId"),xc(i,"hover",Io(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(ft(e.clickImageId,n,"clickImageId"),xc(i,"click",Io(t,e.clickImageId)?.fileId??e.clickImageId)),i},rg=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),ts=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>ts(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=dt(e),i=typeof e.type=="string";(i||t)&&He(e,"opacity")&&(He(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])He(e,a)&&(n[a]=ts(e[a]));for(let[a,r]of Object.entries(e))rg(a)&&(n[a]=ts(r,{isElementPatch:i||t}));return n},No=(e,t={},n="root")=>ts(xo(Kt(Eo(e,t,n),t,n),t,n)),pr=No,Yr=(e=[])=>e.find(t=>t.id==="story"),tg="#000000",So="bg-cg-background-color",ng=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?os(n?.backgroundColor??tg,"screen.backgroundColor"):jo(e,t.colorId),Gc=(e={})=>Tc(e),sg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Do=(e={})=>Array.isArray(e.filters)?e.filters:void 0,Sc=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=Gc(e),i=sg(e),a=Do(e),r={};return(t||n!==void 0)&&(r.alpha=n??1),i&&(r.blur=i),a&&(r.filters=a),r},ig=(e={})=>Tc(e),og=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Hc=(e={})=>{let t=ig(e),n=og(e),i={};return t!==void 0&&(i.alpha=t),n&&(i.blur=n),i},Br=(e={})=>{let t=Hc(e),n=Do(e);return n&&(t.filters=n),t},Oc=(e,t,n,i)=>{let a=t[n]??e[n];return t[i]??e[i]??!1?(a??1)*-1:a},er=(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:Oc(e,t,"scaleX","flipX"),scaleY:Oc(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},ag=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],To=(e={})=>e.text&&He(e.text,"content")&&He(e.text,"textStyleId"),Lo=(e={})=>e.layout&&Array.isArray(e.layout.elements),Rc=(e={})=>{if(e.resourceId)return e.resourceId;if(To(e))return"text";if(Lo(e))return"inline-layout"},$c=(e,t={})=>typeof e=="string"?t.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?t.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return 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:t.images?.[i]?.fileId??i}}return typeof n.src=="string"?{...n,src:t.images?.[n.src]?.fileId??n.src}:n})}:e,lg=({item:e,particle:t,resources:n})=>{let i=pt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=$c(r,n)),a.texture!==void 0&&(a.texture=$c(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...er(i,e)};return Object.assign(s,Br(e)),s},cg=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&&!To(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Lo(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of ag)if(He(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},ug=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:i=!1})=>{let a={id:So,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:ng({resources:e,background:t,screen:n})};if(i){let r=Gc(t);r!==void 0&&(a.alpha=r);let s=Do(t);s&&(a.filters=s)}return a},pg=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,Cc=({resources:e={},resourceId:t,colorId:n})=>{let i=Bc(e,t);return t&&(i||n===void 0)?{resourceId:t,targetId:rs({resourceId:t,kind:i})}:n!==void 0?{resourceId:So,targetId:So}:{resourceId:void 0,targetId:void 0}},Kc=100,Er=Kc,fg="channel:bgm",dg="channel:music-room",mg="music-room:player",yg="channel:voice",hg="default",gg=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Gt=(...e)=>e.map(gg).join(":"),ss=(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)})},Wc=(e,t)=>e*t/Kc,Mo=(e={},t)=>e?.[t]??Ar[t],qo=(e={},t,n=Er)=>Wc(n,Mo(e,t)),as=({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},es=(e,t,n,i)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:i,bg=["muted","pan","playbackRate","startAt","endAt"],ls=({id:e,sound:t,resource:n,defaultLoop:i=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:es(t,n,"loop",i),volume:es(t,n,"volume",Er),startDelayMs:es(t,n,"startDelayMs",0)};bg.forEach(s=>{let o=es(t,n,s,void 0);o!==void 0&&(a[s]=o)}),t.playback!==void 0&&(a.playback=structuredClone(t.playback));let r=a.startAt??0;if(a.endAt!==void 0&&a.endAt!==null&&a.endAt<r)throw new Error(`Sound "${e}" endAt (${a.endAt}) must be greater than or equal to startAt (${r}).`);return a},wg=e=>Math.max(-1,Math.min(1,e)),Ig=({node:e,bgm:t,sound:n,resource:i,usesLegacySound:a})=>{a||(e.volume=Wc(t.volume??Er,e.volume??Er));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=wg((t.pan??0)+(e.pan??0))),e},ze=({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:d,canRollback:f,confirmDialog:m,form:b,historyDialogue:h=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:g,skipTransitionsAndAnimations:E}={})=>{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??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},P=Eg({dialogueState:s,includeInactiveAdvDialogue:o,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:n,sceneReplay:i,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:d,canRollback:f,confirmDialog:m,form:b,historyDialogue:h,characters:y};return P&&(v.dialogue=P,v.dialogueLines=P.lines),v},_c=100,is=(e,t)=>{if(Array.isArray(e))return e.map(i=>is(i,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(i=>{n[i]=is(n[i],t)}),n.type==="text-revealing"?t(n):n},vg=e=>is(e,t=>({...t,revealEffect:"none"})),kg=e=>is(e,t=>{let n=Number(t.speed??t.displaySpeed),i=Number.isFinite(n)?Math.max(n,_c):_c;return{...t,speed:i,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:i}:{}}}),xr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:i=!1}={})=>t||i?vg(e):n?kg(e):e,Jc=({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:{}}}}),Oo=e=>{if(Array.isArray(e))return e.map(Oo);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Oo(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}}:{}}}}},Ag=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),jc="submit",vo=(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}}},Ro=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>Ro(c,t,n));if(!e||typeof e!="object")return e;let i=typeof e.type=="string",a=i&&e.formRole===jc,r=i&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},o={};for(let[c,u]of Object.entries(e))o[c]=Ro(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:vo(l.change,u),submit:vo(l.submit,t.submitActions)}}}return l.formRole===jc||r?{...l,click:vo(l.click,t.submitActions,{replaceActions:!0})}:l},$o=(e,t)=>{if(Array.isArray(e))return e.map(i=>$o(i,t));if(!e||typeof e!="object")return e;let n={};for(let[i,a]of Object.entries(e))n[i]=$o(a,t);for(let i of Ag){let a=n[i]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[i]={...n[i],payload:{...a,_interactionSource:"form"}})}return n},Co=({characterId:e,character:t,characterName:n,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0,s=Un({characterId:e,character:t,characterName:n,characters:i,variables:a});return{...r||{},...t||{},name:s}},Qc=(e=[],t={},n={})=>e.map(i=>{let a=Co({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}}),Pg=e=>!(!e||e.mode==="adv"&&e.content===void 0),Eg=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:i,runtime:a}={})=>{if(!t&&!Pg(e))return;let r=e.content===void 0?[{text:""}]:Po(e.content,"dialogue.content"),s=e.content===void 0?0:Bh({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:i}),o=a?.dialogueTextSpeed??Ar.dialogueTextSpeed,l=e.textSpeed??o,c=(e.lines||[]).map((p,d)=>{let f=Po(p.content,`dialogue.lines[${d}].content`),m=Co({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:i});return{...p,textSpeed:p.textSpeed??o,content:f.map(b=>({...b,text:lt(b.text,{variables:i})})),character:m,characterName:m.name}}),u=Co({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:lt(p.text,{variables:i})})),initialRevealedCharacters:s,lines:c}},Vo=({container:e,resources:t,templateData:n,isLineCompleted:i=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=ur(e,n);return pr(xr(s,{isLineCompleted:i,skipMode:a,skipTransitionsAndAnimations:r}),t)},ko=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),Nc=({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:ko(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[i].keyup={payload:ko(a.keyup)});return}e[i]={...r,[n]:{payload:ko(a)}}})},xg=(e={},t={})=>{let n={};return Nc({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Nc({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},fr=({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:w})=>{let g=Uh({resources:t,animationId:f,playback:m,instanceId:y,targetId:w,animationPath:s});g&&l.push(g)},u=n!=null&&n!==!1,p=i!=null&&i!==!1,d=a&&r&&a===r;Fh(e,s);let f=Dh(e),m=Th(e),b=t?.animations?.[f],h=Nh(b,{animationId:f,animationPath:s});if(h==="update")return p&&r?c({instanceId:`${o}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${o}-animation-update`,targetId:a}),l;if(h==="transition"){let y=`${o}-animation-transition`,w=m?.continuity==="persistent"?y:`${o}-animation-in`;if(u&&p&&d)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${o}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},Sg=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),Og=(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:d,activePersistentAnimations:f,restoredPersistentAnimations:m,autoMode:b,skipMode:h,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:E,saveSlots:k=[]})=>{let{elements:P,animations:v}=e;if(t.background){let O=i===void 0?!0:He(i?.background??{},"animations"),L=P.find(ie=>ie.id==="story");if(!L)return e;let $=Yh(a,t.background),D=$||Xh(t.background),U=n?.background?.resourceId,_=n?.background?.colorId,G=t.background.resourceId??(t.background.animations?U:void 0),ae=t.background.colorId??(t.background.animations?_:void 0),M=pg(a,G),Q={...t.background,colorId:ae};if((ae!==void 0||M)&&L.children.push(ug({resources:a,background:Q,screen:r,includeAlpha:!M})),G){let{images:ie={},videos:K={},spritesheets:pe={}}=a,oe=Bc(a,G),C;if(oe==="sprite"?C=ie[G]:oe==="video"?C=K[G]:oe==="spritesheet-animation"&&(C=pe[G]),C){let j=oe==="video",F=oe==="spritesheet-animation",W={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...$},fe={...Sc(t.background,{includeDefaultAlpha:!0}),...er(W,t.background)},Se;F?Se=_o({id:rs({resourceId:G,kind:oe}),resourceId:G,spritesheet:C,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:fe}):Se={id:rs({resourceId:G,kind:oe}),type:j?"video":"sprite",src:C.fileId,width:C.width,height:C.height,...fe},j&&(Se.loop=t.background.loop??!1,Se.volume=C.volume??50),Se&&L.children.push(Se)}}if(G){let{layouts:ie={}}=a,K=ie[G];if(K){let pe={id:rs({resourceId:G,kind:"container"}),type:"container",children:K.elements,...Sc(t.background)};D&&Object.assign(pe,er({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...$},t.background));let oe=ur(pe,ze({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:d,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:b,skipMode:h,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:E,characters:a.characters||{},skipTransitionsAndAnimations:o}));L.children.push(pr(xr(oe,{isLineCompleted:s,skipMode:h,skipTransitionsAndAnimations:o}),a))}}let le=Cc({resources:a,resourceId:U,colorId:_}),X=Cc({resources:a,resourceId:G,colorId:ae}),Z=fr({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:X.resourceId,previousTargetId:le.targetId,currentTargetId:X.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ke({animationInstances:Z,isLineCompleted:s,skipTransitionsAndAnimations:o,activePersistentAnimations:f,restoredPersistentAnimations:m,isAuthoredOnCurrentLine:O})&&v.push(...Z)}return e},Rg=(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(w=>w.id==="story");if(!p)return e;let d=t.character.items||[],f=n?.character?.items||[],m=kc(d),b=kc(f),h=new Map,y=new Map;for(let w=0;w<f.length;w++){let g=f[w],E=h.get(g.id)??[];E.push(w),h.set(g.id,E)}for(let w=0;w<d.length;w++){let g=d[w],{transformId:E,sprites:k}=g,P=y.get(g.id)??0;y.set(g.id,P+1);let v=h.get(g.id)?.[P]??-1,O=f[v],L=O?.sprites&&O.sprites.length>0,$=k&&k.length>0,D=v>=0?Ac(O,v,b):void 0,U=$?Ac(g,w,m):void 0,_=Uc(i,"character",g.id,w,d),G=fr({animationsDef:g.animations,resources:a,previousResourceId:D,currentResourceId:U,previousTargetId:D,currentTargetId:U,animationPath:`character.items[${w}].animations`,idPrefix:U??D??`character-${w}`});if(g.animations&&!k&&!E&&L&&Ke({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})){u.push(...G);continue}if(g.animations&&!k&&!E)continue;if(!k||k.length===0||!E){console.warn("Character item missing sprites or transformId:",g);continue}let ae=a.transforms[E];if(!ae){console.warn("Transform not found:",E);continue}let M={type:"container",id:U,...er(ae,g),...Br(g),children:[]};for(let Q of k){let le=Yc({id:`${U}-${Q.id}`,item:Q,resources:a});le&&M.children.push(le)}p.children.push(M),Ke({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})&&u.push(...G)}}return e},Zc=(e,t)=>{if(!yo.includes(e))throw new Error(`${t} must be one of: ${yo.join(", ")}.`)},$g=(e,t)=>{let n=!!e.resourceId||To(e)||Lo(e),i=e.layer??(n?void 0:t?.layer)??mo;return Zc(i,`Visual item "${e.id}" layer`),i},Cg=(e,{presentationState:t,previousPresentationState:n,currentLineActions:i,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:m,skipMode:b,isChoiceVisible:h,isFormVisible:y,canRollback:w,form:g,saveSlots:E=[],visualLayer:k})=>{let{elements:P,animations:v}=e;if(t.visual&&a){let O=P.find(U=>U.id==="story");if(!O)return e;let L=t.visual.items,$=n?.visual?.items||[],D=ze({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:E,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:b,isChoiceVisible:h,isFormVisible:y,canRollback:w,form:g,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&Zc(k,"visualLayer");for(let[U,_]of L.entries()){let G=$.find(K=>K.id===_.id),ae=Uc(i,"visual",_.id,U,L),M=$g(_,G);if(k!==void 0&&M!==k)continue;if(cg(_),_.layout){let K=pt(a,_),pe={id:`visual-${_.id}`,type:"container",children:structuredClone(_.layout.elements),...er(K,_)};Object.assign(pe,Br(_)),O.children.push(Vo({container:pe,resources:a,templateData:D,isLineCompleted:r,skipMode:b,skipTransitionsAndAnimations:s}))}if(_.text){let K=pt(a,_),pe={...structuredClone(_.text),id:`visual-${_.id}`,type:"text",...er(K,_)};Object.assign(pe,Br(_)),O.children.push(pr(ur(pe,D),a))}if(_.resourceId){let{images:K={},videos:pe={},spritesheets:oe={}}=a,C=oe[_.resourceId];if(C){let j=pt(a,_),F=Br(_),W=_o({id:`visual-${_.id}`,resourceId:_.resourceId,spritesheet:C,animationName:_.animationName,animationSpeed:_.animationSpeed,loop:_.loop,width:_.width,height:_.height,transform:{...er(j,_),alpha:F.alpha??_.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});W&&O.children.push(structuredClone(W))}else{let j=K[_.resourceId]||pe[_.resourceId];if(j){let F=pe[_.resourceId]!==void 0,W=pt(a,_),fe={id:`visual-${_.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...er(W,_)};Object.assign(fe,Br(_)),F&&(fe.loop=j.loop??!1,fe.volume=j.volume??50),O.children.push(fe)}}}let Q=!!(a.spritesheets?.[_.resourceId]||a.images?.[_.resourceId]||a.videos?.[_.resourceId]);if(_.resourceId&&!Q){let K=a.particles?.[_.resourceId];K&&O.children.push(lg({item:_,particle:K,resources:a}))}let le=!!a.particles?.[_.resourceId];if(_.resourceId&&!Q&&!le){let{layouts:K={}}=a,pe=K[_.resourceId];if(pe){let oe=pt(a,_),C={id:`visual-${_.id}`,type:"container",children:structuredClone(pe.elements),...er(oe,_)};Object.assign(C,Br(_));let j=ur(C,D);O.children.push(pr(xr(j,{isLineCompleted:r,skipMode:b,skipTransitionsAndAnimations:s}),a))}}let X=Rc(G),Z=Rc(_),ie=fr({animationsDef:_.animations,resources:a,previousResourceId:X,currentResourceId:Z,previousTargetId:X?`visual-${_.id}`:void 0,currentTargetId:Z?`visual-${_.id}`:void 0,animationPath:`visual.items[${_.id}].animations`,idPrefix:_.id});Ke({animationInstances:ie,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:ae})&&v.push(...ie)}}return e},ut="dialogue-character-sprite",_g=(e,{presentationState:t,previousPresentationState:n,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:o}=e,l=Yr(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=jt(c),d=jt(u),f=fr({animationsDef:c?.animations,resources:i,previousResourceId:d?ut:void 0,currentResourceId:p?ut:void 0,previousTargetId:d?ut:void 0,currentTargetId:p?ut:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&d&&Ke({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...f),e;let m=i.transforms?.[c.transformId];if(!m)return console.warn("Transform not found:",c.transformId),e;let b={type:"container",id:ut,...er(m),children:[]};for(let h of c.items){let y=Yc({id:`${ut}-${h.id}`,item:h,resources:i});y&&b.children.push(y)}return l.children.push(b),Ke({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...f),e},jg=(e,{presentationState:t,previousPresentationState:n,resources:i={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:d,skipTransitionsAndAnimations:f,variables:m,imageGallery:b,musicRoom:h,sceneReplay:y,runtime:w,activePersistentAnimations:g,saveSlots:E=[]})=>{let{elements:k,animations:P}=e;if(!t.dialogue||a)return e;let v=k.find(L=>L.id==="story");if(!v)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:L={}}=i,$=L[t.dialogue.ui.resourceId];if($){let D={elements:$.elements},U=ze({variables:m,imageGallery:b,musicRoom:h,sceneReplay:y,runtime:w,saveSlots:E,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:d,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,characters:i.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:f}),_=ur(D,U),G=pr(xr(_?.elements,{isLineCompleted:d,skipMode:s,skipTransitionsAndAnimations:f}),i);if(Array.isArray(G))for(let ae of G)v.children.push(ae);else G&&v.children.push(G)}}_g(e,{presentationState:t,previousPresentationState:n,resources:i,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:g});let O=fr({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 Ke({animationInstances:O,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:g})&&P.push(...O),e},Ng=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:b,canRollback:h,form:y,activePersistentAnimations:w,saveSlots:g=[]})=>{let{elements:E,animations:k}=e;if(t.choice&&i){let P=Yr(E);if(!P)return e;let v=i?.layouts?.[t.choice.resourceId];if(v&&v.elements){let L={elements:v.elements},$=ur(L,{...ze({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m??!!t.choice,isFormVisible:b,canRollback:h,form:y,characters:i.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),D=Oo(pr(xr($?.elements,{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:s}),i));if(Array.isArray(D))for(let U of D)P.children.push(U);else D&&P.children.push(D)}let O=fr({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"});Ke({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...O)}return e},Dg=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:b,canRollback:h,activePersistentAnimations:y,saveSlots:w=[],form:g})=>{let{elements:E,animations:k}=e;if(!g?.resourceId||!i)return e;let P=Yr(E);if(!P)return e;let v=i?.layouts?.[g.resourceId];if(!v)return console.warn(`Form layout not found: ${g.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},L={...ze({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:b,canRollback:h,characters:i.characters||{},skipTransitionsAndAnimations:s,form:g}),form:g},$=ur(O,L),D=$o(pr(xr(Ro($,g),{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:s}),i),g);D&&P.children.push(D);let U=fr({animationsDef:g.animations,resources:i,previousResourceId:n?.form?.resourceId,currentResourceId:g.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:g.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return Ke({animationInstances:U,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&k.push(...U),e},Tg=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:b=[],skipTransitionsAndAnimations:h})=>{if(!t.control?.resourceId)return e;let y=n.controls?.[t.control.resourceId];if(!y)return e;let w=xg(y.keyboard,y.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(y.elements)||y.elements.length===0)return e;let g=Yr(e.elements);if(!g)return e;let E={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return g.children.push(Vo({container:E,resources:n,templateData:ze({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:n.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:h})),e},Fo=({presentationState:e,resources:t={},runtime:n,variables:i,musicRoomPlayer:a})=>{if(e?.bgm&&t){let r=e.bgm,s=!Array.isArray(r.sounds),o=s?r.resourceId?[{id:"default",resourceId:r.resourceId,loop:r.loop??!0,volume:r.volume,startDelayMs:r.startDelayMs??0}]:[]:r.sounds,l=!s&&r.loop===!0,c=[];if(s||ss(o,"BGM sound"),l){let p=o.find(d=>d.loop===!0);if(p)throw new Error(`BGM sound "${p.id}" cannot loop inside a looping BGM channel.`)}if(o.forEach(p=>{let d=t.sounds?.[p.resourceId];if(!d)return;let f=l?{...p,loop:p.loop??!1}:p;c.push(Ig({node:ls({id:Gt("bgm",s?"default":p.id),sound:f,resource:d,defaultLoop:!l}),bgm:r,sound:f,resource:d,usesLegacySound:s}))}),c.length===0)return null;let u=ze({variables:i,runtime:n}).runtime;return as({id:fg,volume:Mo(u,"musicVolume"),muted:!1,pan:0,loop:s?void 0:r.loop,playback:a?.bgmPlayback,interruption:r.interruption,children:c,runtime:u})}return null},Lg=(e,t)=>{if(!Yr(e.elements))return e;let i=Fo(t);return i&&e.audio.push(i),e},Mg=(e,{activeAudioEffect:t,skipTransitionsAndAnimations:n})=>(t&&!n&&(e.audioEffects=[structuredClone(t)]),e),qg=(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?t.sounds?.[s.soundId]:void 0;if(!s||!o)return e;let l=ze({variables:i,runtime:n}).runtime,c=ls({id:mg,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:o});return e.audio.push(as({id:dg,volume:qo(l,"musicVolume",Er),children:[c],runtime:l})),e},Vg=(e,{presentationState:t,resources:n,runtime:i})=>{let{audio:a}=e;if(t.sfx&&n){let r=t.sfx,s=Array.isArray(r.channels)?r.channels:[],o=s.map(l=>({channel:l,usesLegacyChannel:!1}));ss(s,"SFX channel"),Array.isArray(r.items)&&o.push({channel:{id:hg,sounds:r.items},usesLegacyChannel:!0}),o.forEach(({channel:l,usesLegacyChannel:c})=>{let u=!c&&l.loop===!0,p=[];if(c||ss(l.sounds,"SFX sound",`SFX channel "${l.id}"`),u){let d=l.sounds.find(f=>f.loop===!0);if(d)throw new Error(`SFX sound "${d.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((d,f)=>{let m=n.sounds?.[d.resourceId];if(!m)return;let b=u?{...d,loop:d.loop??!1}:d;p.push(ls({id:c?Gt("sfx","default",f,d.id):Gt("sfx",l.id,d.id),sound:b,resource:m,defaultLoop:u?!1:void 0}))}),p.length!==0&&a.push(as({id:Gt("channel","sfx",l.id),volume:qo(i,"soundVolume",l.volume??Er),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:c?void 0:l.interruption,children:p,runtime:i}))})}return e},Fg=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},Ug=(e,{presentationState:t,resources:n,currentSceneId:i,runtime:a,variables:r})=>{let{audio:s}=e;if(!t?.voice)return e;let o=t.voice,l=!Array.isArray(o.sounds),c=l?o.resourceId?[{id:"default",resourceId:o.resourceId,loop:o.loop??!1,volume:Er,startDelayMs:o.startDelayMs??0}]:[]:o.sounds,u=!l&&o.loop===!0,p=[];if(l||ss(c,"Voice sound"),u){let f=c.find(m=>m.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(c.forEach(f=>{let m=Fg(n,i,f.resourceId);if(!m)return;let b=u?{...f,loop:f.loop??!1}:f;p.push(ls({id:Gt("voice",i,l?"default":f.id),sound:b,resource:m,defaultLoop:u?!1:void 0}))}),p.length===0)return e;let d=ze({variables:r,runtime:a}).runtime;return s.push(as({id:yg,volume:l?o.volume??Mo(d,"soundVolume"):qo(d,"soundVolume",o.volume??Er),muted:o.muted,pan:o.pan,loop:l?void 0:o.loop,interruption:o.interruption,children:p,runtime:d})),e},Bg=(e,{presentationState:t,previousPresentationState:n,resources:i={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:b=[],isLineCompleted:h,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:g,animations:E}=e;if(t.layout){let O=Yr(g);if(!O)return e;let L=i.layouts?.[t.layout.resourceId];if(!L)return e;let $={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:L.elements||[]};O.children.push(Vo({container:$,resources:i,templateData:ze({variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:h,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:i.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:h,skipMode:u,skipTransitionsAndAnimations:y}))}let k=n?.layout?.resourceId,P=t.layout?.resourceId,v=fr({animationsDef:t.layout?.animations,resources:i,previousResourceId:k,currentResourceId:P,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:P?`layout-${P}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ke({animationInstances:v,isLineCompleted:h,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&E.push(...v),e},Yg=(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=fr({animationsDef:l,resources:i,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ke({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...u),e},zg=(e,{presentationState:t})=>{let n=Yr(e.elements);return!n||!t?.screen||Object.assign(n,Hc(t.screen)),e},Xg=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,overlayStack:m=[],dialogueHistory:b=[],saveSlots:h=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:E}=e;return m&&m.length>0&&m.forEach((k,P)=>{let v=n.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${P}`,type:"container",x:0,y:0,children:[Jc({id:`overlayStack-${P}-blocker`,screen:y}),...v.elements||[]]},L=Qc(b,n.characters,i),$=ze({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:h,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,historyDialogue:L,characters:n.characters||{},skipTransitionsAndAnimations:g}),D=ur(O,$),[U,..._]=D.children||[],G=pr(xr({...D,children:_},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:g}),n);E.push({...G,children:U?[U,...G.children||[]]:G.children})}),e},Gg=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:b,dialogueHistory:h=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:E}=e;if(!b?.resourceId)return e;let k=n.layouts?.[b.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${b.resourceId}`),e;let P={id:"confirmDialog",type:"container",x:0,y:0,children:[Jc({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=Qc(h,n.characters,i),O=ur(P,ze({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:b,historyDialogue:v,characters:n.characters||{},skipTransitionsAndAnimations:g})),[L,...$]=O.children||[],D=pr(xr({...O,children:$},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:g}),n);return E.push({...D,children:L?[L,...D.children||[]]:D.children}),e},Wt=e=>(t,n)=>Cg(t,{...n,visualLayer:e}),Hg=Wt(cr.BEHIND_BACKGROUND),Kg=Wt(cr.BEHIND_CHARACTER),Wg=Wt(cr.BEHIND_DIALOGUE),Jg=Wt(cr.BEHIND_CHOICE),Qg=Wt(cr.FOREGROUND),eu=e=>Fn(Sg,[Tg,Hg,Og,Kg,Rg,Wg,jg,Jg,Ng,Dg,Bg,Qg,zg,Yg,Lg,qg,Vg,Ug,Mg,Xg,Gg])(e);function ru(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 tu(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 nu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",su="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",iu="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var ou=65535,Uo=40960,cs=126976,cu=new Uint8Array(12288),uu=new Uint8Array(3072),pu=new Uint8Array(2816),fu,du;{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 ru(nu,su))e(cu,0,a,r,s),e(uu,Uo,a,r,s),e(pu,cs,a,r,s),r>=65040&&!(a>=cs&&r<=129791)&&(t[i]=a,n[i++]=r<<5|s);fu=t.slice(0,i),du=n.slice(0,i)}function au(e){return e<12288?cu[e]:e<Uo?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?uu[e-Uo]: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>=cs&&e<129792?pu[e-cs]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:tu(e,fu,du)}var mu=Uint8Array.from(iu,Number);function Zg(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 lu(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||Zg(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*yu(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),i=n>ou?2:1,a=au(n),r=50200>>a&1?lu(0,a,n):0,s=0,o=n,l=a;for(;i<t;){n=e.codePointAt(i);let c=n>ou?2:1,u=au(n),p=mu[a<<4|u],d;p===0?d=!0:p===1?d=!1:p===2?d=!(r&1):p===3?d=!(r&4):d=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?lu(r,u,n):0,d&&(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*hu(e){for(let t of yu(e))yield t.segment}{let e=yu("_");mu._keep=[e,e.next()]}var gu=1e3,vu=50,eb=0,bu=100,wu=50,rb=60,tb=3,nb=.5,sb=2e4,ib=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,ob=/^\s+$/u,Iu,ab=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(hu(t)):(Iu??=new n(void 0,{granularity:"grapheme"}),Array.from(Iu.segment(t),({segment:i})=>i))},lb=e=>ab(e).reduce((t,n)=>ob.test(n)?t+nb:ib.test(n)?t+tb:t+1,0),cb=e=>2**(((Number.isFinite(e)?Math.min(bu,Math.max(eb,e)):vu)-wu)/(bu-wu)),Bo=({text:e="",baseDelay:t=gu,speed:n=vu}={})=>{let i=Number.isFinite(t)?Math.max(0,t):gu,a=cb(n),r=lb(e)*rb/a,s=Math.max(i,sb);return Math.min(i+r,s)};var us={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Su=1,dr=1,yt="choice",Or="form",en=()=>({manual:{...us.manual},auto:{...us.auto},applyMode:us.applyMode}),ra=()=>({groupId:null,variantId:null,pageIndex:0}),ub="music-room:player",pb=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),ds=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),ta=new Set,fb=new Set(["groupId","variantId"]),db=new Set(["pageIndex"]),ht=new Set,mb=new Set(["trackId"]),yb=new Set(["positionMs"]),hb=new Set(["pageIndex"]),na=new Set,gb=new Set(["sceneId"]),bb=new Set(["pageIndex"]),sa=()=>({pageIndex:0}),ia=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...en()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},zo=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let t=Ae(e)?br(e):e;return structuredClone(t)},q=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ms=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},Ou=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},rn=(e,t,n)=>({commandId:ms(e),operation:t,...n===void 0?{}:{positionMs:n}}),oa=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:ms(e),operation:"resume"}),e.global.musicRoomPlayer=ds({bgmPlayback:n})},Ru=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=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},$u=(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`)},Gr=e=>String(e),Cu=()=>({sections:[],resources:[]}),_u=()=>({sceneIds:[]}),wb=e=>q(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Cu(),Ib=e=>q(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):_u(),vb=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",kb=({sectionId:e,lineId:t,content:n,dialogueState:i,characterName:a})=>({sectionId:e,lineId:t,content:n,text:vb(n),characterId:i.characterId,character:{...i.character||{},name:a},characterName:a}),ju=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),Ab=e=>q(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,aa=e=>{if(!q(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},Pb=e=>{if(!q(e?.dialogueHistory))return e.dialogueHistory=ju(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},la=e=>{let t=aa(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},Eb=()=>({resourceId:void 0}),xb=e=>{if(!q(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},mr=(e,t)=>{let n=e?.story?.scenes??{};for(let[i,a]of Object.entries(n))if(a?.sections?.[t])return{sceneId:i,section:a.sections[t]};return{sceneId:void 0,section:void 0}},Nu=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)}}},Du=e=>e,Tu=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Su)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},Sb=(e,t={})=>{let n;try{n=Tu(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let i={...t,formatVersion:n,slotId:Du(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete i.slotKey,delete i.date,i},Ob=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Sb(t,n)])),Rb=(e,t)=>{if(!q(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(i=>{if(!q(i))return!1;let{variableId:a,op:r,value:s,roundTo:o}=i,l=t?.resources?.variables?.[a];if(!l||Re(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Vt(l.type,r,a),Yn(l.type,r,s,a,{roundTo:o}),r!=="set"||no(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},Lu=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(i=>{if(!q(i)||!dI(i.type))return[];if(i.type!=="updateVariable"||t===void 0)return[i];let a=Rb(i.payload,t);return a?[{...i,payload:a}]:[]});return n.length>0?n:void 0},$b=(e,t,n)=>{let{section:i}=mr(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(!q(r)||!Object.prototype.hasOwnProperty.call(r,o))return;r=r[o]}return s.at(-1)==="random"&&q(r?.distribution)?r:void 0},Mu=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},qu=(e,t,n)=>e.filter(({path:i,type:a,result:r})=>{let s=$b(n,t,i);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return q(s.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let o=n?.resources?.variables?.[s.variableId];return typeof s.variableId=="string"&&o?.type==="number"&&o.scope==="context"&&o.readonly!==!0&&!Re(o)&&Mu(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),ca=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==dr)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(!q(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:Hn(V(a.result),a.type)}});return t===void 0?i:qu(i,e,t)},Cb=(e,t)=>{!q(e)||!Array.isArray(e.timeline)||e.timeline.forEach(n=>{if(!q(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let i=Lu(n.executedActions,t);i?n.executedActions=i:delete n.executedActions;let a=ca(n,t);a?(n.randomOutcomeVersion=dr,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},_b=(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(!q(o))return;let l=ca(o,t);l?(o.randomOutcomeVersion=dr,JSON.stringify(o.randomOutcomes)!==JSON.stringify(l)&&(o.randomOutcomes=l)):(delete o.randomOutcomeVersion,delete o.randomOutcomes)})})}),n},ku=(e,t,n,i="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!q(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}},jb=(e,t="viewedRegistry")=>{if(e===void 0)return Cu();if(!q(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=ku(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(i.map((a,r)=>{let s=ku(a,"resources",r,t);return[s.resourceId,s]})))}},Nb=(e,t="accountReplayRegistry")=>{if(e===void 0)return _u();if(!q(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}))]}},Jt=(e,t,n)=>{if(!q(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}=mr(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}},Vu=e=>{let t=e.story.initialSceneId,n=e.story.scenes[t],i=n.initialSectionId,a=n.sections[i];return Jt({sceneId:t,sectionId:i,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},Db=e=>{try{return Vu(e),!0}catch{return!1}},Tb=(e,t,n)=>{let i=e?.pointers?.read;if(!q(i)||typeof i.sectionId!="string"||i.sectionId.length===0||typeof i.lineId!="string"||i.lineId.length===0)return Jt(i,t,n);try{return Jt(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 Jt(a[s],t,`${n} compatibility checkpoint`)}catch{}return Vu(t)}};var Fu=(e,t)=>{let{section:n}=mr(e,t?.sectionId);return n?.lines?.find(i=>i.id===t?.lineId)},Lb=(e,t,n)=>{if(!q(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(!q(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}=mr(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}},Mb=(e,t)=>q(Fu(e,t)?.actions?.dialogue),Uu=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:i}=mr(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=>q(s.actions?.dialogue))?.id===t.lineId},qb=(e,t)=>{let n=ju();return e.timeline.forEach(i=>{if(i.returnable!==!1&&Mb(t,i)){let a=Fu(t,i),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&Uu(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},Vb=(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},Fb=(e,t,n)=>{if(!q(e)||!Array.isArray(e.timeline))return{rollback:Zt({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let i=[],a=e.timeline.flatMap((c,u)=>{if(!q(c))return[];let p=ca(c);try{let d=Jt(c,n,`rollback.timeline[${u}]`),f=p?qu(p,d,n):void 0,m=fs({sectionId:d.sectionId,lineId:d.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...f?{randomOutcomeVersion:dr,randomOutcomes:f}:{}}),b=Lu(V(c.executedActions),n);return b&&(m.executedActions=b),i.push(u),[m]}catch{return[]}});if(a.length===0)return{rollback:Zt({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(fs({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}},Bu=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let i=pa(t),a=Tb(e,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!q(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!q(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?Mt(V(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=ew({loadedContextRuntime:q(e.runtime)?V(e.runtime):{}}),{rollback:o,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Fb(e.rollback,a,t),u=e.dialogueHistory===void 0?qb(o,t):Vb(Lb(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),o,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:q(e.configuration)?V(e.configuration):{},views:Array.isArray(e.views)?V(e.views):[],bgm:q(e.bgm)?V(e.bgm):{resourceId:void 0},variables:{...i,...r},...u?{dialogueHistory:u}:{},rollback:o};return s&&(p.runtime=s),p},Ub=(e,t)=>{if(!q(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)=>Bu(n,t,i))}},Bb=(e,t)=>{if(!q(e))throw new Error("Malformed save slot.");let n=Tu(e.formatVersion);return{...e,formatVersion:n,state:Ub(e.state,t)}},Au=(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=V(e),a=i.hideConfirmDialog??{};return delete i.hideConfirmDialog,{hideConfirmDialog:a,...i}},Yb=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:Au(e.confirmActions,"confirmActions",{required:!0}),cancelActions:Au(e.cancelActions,"cancelActions")}},gt=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},zb=e=>(q(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),bt=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Yu=e=>{if(!(!q(e)||!e.animations))return{animations:V(e.animations)}},Xb=(e,t)=>{let n=Yu(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Gb=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},Hb=(e,t)=>{let n=e?.sectionId,i=e?.lineId;if(!(!n||!i||!t))return`${n}:${i}:${t}`},ps=e=>String(e??""),zu=(e,t)=>{let n=ps(t);return e?.trim===!0?n.trim():n},Kb=e=>q(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>q(t)).map(([t,n])=>[t,{id:t,...V(n)}])):{},Wb=(e,t)=>{if(!t||!q(e.global.formDrafts))return;let n=e.global.formDrafts[t];return q(n)?n:void 0},Xu=(e,t)=>{let n=zb(e);q(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let i=n[t];return q(i.values)||(i.values={}),q(i.touched)||(i.touched={}),q(i.errors)||(i.errors={}),typeof i.submitted!="boolean"&&(i.submitted=!1),i},ua=(e,t)=>{let n=zu(e,t);return e?.required===!0&&n.length===0?"required":null},Jb=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let i=Ee({state:e},{sectionId:t.sectionId})?.lines||[],a=i.findIndex(r=>r.id===t.lineId);return a<0?{}:Ur(i.slice(0,a+1).map(r=>r.actions||{}))},Qb=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let i=Gb(t),a=Hb(n,i);if(!i||!a)return null;let r=Wb(e,a),s=Kb(t),o=Pa({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([d,f])=>{let m=ps(o?.[f.variableId]),b=Object.prototype.hasOwnProperty.call(r?.values??{},d)?ps(r.values[d]):m,h=r?.touched?.[d]===!0,y=ua(f,b),w=r?.submitted||h?y:null,g=typeof f.maxLength=="number"?Math.max(0,Math.round(f.maxLength)):void 0,E={id:d,variableId:f.variableId,value:b,initialValue:m,valid:!y,error:w,touched:h,required:f.required===!0,trim:f.trim===!0,placeholder:f.placeholder===void 0?"":String(f.placeholder),multiline:f.multiline===!0,...g!==void 0?{maxLength:g}:{}};y&&(p=!1),l[d]=E,c.push(E),u[d]=b}),{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:V(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:V(t.cancelActions??{})}}}},mt="line",Sr="interaction",fs=({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===dr?{randomOutcomeVersion:dr,randomOutcomes:V(r??[])}:{}}),pa=e=>{let t=Ae(e)?br(e):e,{contextVariableDefaultValues:n}=Bn(t??{});return V(n)},Gu=()=>({...V(zt)}),Hu=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:i})=>{if(e===void 0)return{runtimeState:V(n),hasLoadedValues:!1};if(!q(e))throw new Error(`Malformed ${i}.`);let a=V(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=Zn(s,V(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Zb=({projectData:e,loadedGlobalRuntime:t={}})=>Hu({loadedRuntime:t,runtimeIds:uo,defaults:fo(e),path:"global.runtime"}).runtimeState,ew=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=Hu({loadedRuntime:e,runtimeIds:po,defaults:Gu(),path:"context.runtime"});return n?t:void 0},$r=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},he=e=>{let t=$r(e);return t?.kind==="sceneReplay"&&q(t.sceneReplay)?t:null},Ku=(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]=V(r)})},rw=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:V(e.global.nextLineConfig),overlayStack:V(e.global.overlayStack),confirmDialog:V(e.global.confirmDialog),formDrafts:V(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:V(e.global.pendingScreenTransition)}}),tw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=en(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},nw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=V(t.nextLineConfig),e.global.overlayStack=V(t.overlayStack),e.global.confirmDialog=V(t.confirmDialog),e.global.formDrafts=V(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=V(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=xe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({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}})},sw=e=>e.runtime?(po.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=V(zt[t]))}),e.runtime):(e.runtime=Gu(),e.runtime),iw=e=>Ic(e.global),Wu=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:iw(e)}})},fa=(e,t,n)=>{let i=Zn(t,n);if(t in zt){let a=$r(e);if(!a)return i;let r=sw(a);return r[t]=i,i}return e.global[t]=i,i},da=({pointer:e,projectData:t,kind:n,sceneReplay:i})=>({...n===void 0?{}:{kind:n},...i===void 0?{}:{sceneReplay:V(i)},currentPointerMode:"read",pointers:{read:V(e)},configuration:{},views:[],bgm:Eb(),variables:pa(t),rollback:Zt({pointer:e})}),wt=e=>e?(e.currentPointerMode="read",q(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,ow=(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=da({pointer:i,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,aw(e,{queueRender:t}),a},aw=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,gt(e),bt(e),e.global.nextLineConfig=en(),e.global.overlayStack=[],e.global.isLineCompleted=!0,oa(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Ju=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},Zt=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[fs({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Cr=(e,t={})=>{if(e?.rollback)return Ju(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=Zt({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},ys=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let i=Cr(n);if(i.isRestoring)return;let a=la(n);i.currentIndex<i.timeline.length-1&&(i.timeline=i.timeline.slice(0,i.currentIndex+1)),i.timeline.push(fs(t)),i.currentIndex=i.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,i.currentIndex),a.checkpointLengths.push(a.currentLength))},lw=({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}},cw=({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(Ae(l)?Rn(l):l)!==i||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},uw=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:i,checkpointIndex:a,sectionId:r,lineId:s}=t,o=Gr(n),l=e.global.saveSlots?.[o],c=Ae(l)?Rn(l):l;if(!l||c!==i)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,d=p?.rollback,f=d?.timeline?.[a];return!Number.isInteger(a)||d?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==s||f?.sectionId!==r||f?.lineId!==s||(f.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Qu=(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=la(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return i.timeline[r]??null},pw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},i={})=>{let a=i?.source===mt?mt:Sr,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=la(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let o=r?.pointers?.read,l=n?.lineEntryId,c=a===mt&&(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===mt?{lineEntryId:l,sourcePointer:o?{sectionId:o.sectionId,lineId:o.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},fw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),dw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let i=t?.at(-1);if(i?.source!==mt||i.hasTrackedLineEntryCheckpoint)return e;let a=i.sourcePointer;if(!a)return e;ys(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},mw=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==mt)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=Hn(n.result,n.type),r=Qu(e,t);if(!r)return e;if(r.randomOutcomeVersion!==dr&&(r.randomOutcomeVersion=dr,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},rr=(e,t,n,i)=>{let r=i?.at(-1)?.source??Sr;if(!mI(t,r))return;let s=Qu(e,i);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:V(n)}))},Xo=(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=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(Re(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);qt(c,a),Vt(u,r,a),Yn(u,r,s,a,{roundTo:o}),c==="context"&&(n.variables[a]=zn(n.variables[a],r,s,{roundTo:o}))}},yw=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:i})=>{yI(e,n,i)})},hw=(e,t)=>{let{sectionId:n,lineId:i}=t,s=Ee({state:e},{sectionId:n})?.lines?.find(o=>o.id===i)?.actions;s&&Oa(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},Zu=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let i=Cr(n),a=i.timeline[t];if(!a)return e;e.global.autoMode&&on({state:e}),e.global.skipMode&&Rr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),i.isRestoring=!0,i.currentIndex=t;try{n.variables=pa(e.projectData),n.kind==="sceneReplay"&&(Ku(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=V(us),e.global.overlayStack=[],gt(e),bt(e),e.global.isLineCompleted=!0;let r=i.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&ia(e),hw(e,i.timeline[l]),yw(e,i.timeline[l]);let s=wt(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let o=aa(n);o&&(o.currentLength=Math.min(o.checkpointLengths[t]??0,o.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Ou(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{i.isRestoring=!1}return e},gw=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;Nu(t),Dt(t),Tt(t),Lt(t),Vr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],d=p.initialSectionId,f=p.sections[d],m={sceneId:u,sectionId:d,lineId:f.initialLineId??f.lines[0].id},{globalVariablesDefaultValues:b}=Bn(t),h={...b,...Mt(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:jb(o,"accountViewedRegistry"),accountReplayRegistry:Nb(l),nextLineConfig:en(),imageGalleryNavigation:ra(),sceneReplayNavigation:sa(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:ds(),saveSlots:Ob(a),localizationPackages:V(c),overlayStack:[],variables:h,...Zb({projectData:t,loadedGlobalRuntime:s})},contexts:[da({pointer:m,projectData:t})]}},bw=({state:e})=>e.global.overlayStack||[],ww=({state:e})=>e.global.pendingEffects,ep=({state:e})=>e.global.skipMode,Iw=({state:e})=>e.global.autoMode,rp=({state:e})=>e.global.dialogueUIHidden,tp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let i,a=q(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:c,lineId:u}=n.pointers.read,p=Ee({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let d=p.lines.findIndex(f=>f.id===u);i=p.lines.slice(0,d+1).map(f=>({sectionId:c,lineId:f.id}))}let r=[],s=ot({variables:{...e.global?.variables??{},...$r(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),o=new Map,l=c=>{let u=o.get(c.sectionId);if(!u){let d=Ee({state:e},{sectionId:c.sectionId}),f=Array.isArray(d?.lines)?d.lines:[];u={lines:f,lineIndexes:new Map(f.map((m,b)=>[m.id,b])),projections:new Map,nextLineIndex:0,presentationState:{}},o.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let d=u.lines[u.nextLineIndex],f=d.actions||{};u.presentationState=Ur([u.presentationState,f]),u.projections.set(d.id,{line:d,lineActions:f,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of i){if(!Ab(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:d,dialogueState:f}=u;if(!d.dialogue)continue;let m=Un({characterId:f.characterId,character:f.character,characters:e.projectData.resources?.characters??{},variables:s}),b=kb({sectionId:c.sectionId,lineId:p.id,content:d.dialogue.append===!0?f.content:d.dialogue.content,dialogueState:f,characterName:m}),h=r[r.length-1];if((a?c.appendToPrevious===!0:d.dialogue.append===!0)&&h?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:b.content,text:b.text,characterId:b.characterId,character:b.character,characterName:b.characterName};continue}r.push(b)}return r},vw=(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?.[Gr(r)],u=Ae(c)?Rn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==o||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=V(n),i=!0)}i&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},kw=({state:e},t={})=>{let n=$r(e),i=n?.pointers?.read,a=nn({state:e});if(!n||!q(a?.actions?.dialogue))return e;let r=Cr(n),s=r.timeline?.[r.currentIndex],o=s?.sectionId===i?.sectionId&&s?.lineId===i?.lineId,l=aa(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 d=Pb(n);d.currentLength<d.entries.length&&(d.entries=d.entries.slice(0,d.currentLength));let f=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&Uu(e.projectData,p,i);if(d.entries.push({sectionId:i.sectionId,lineId:i.lineId,...f?{appendToPrevious:!0}:{}}),d.currentLength=d.entries.length,o){for(;d.checkpointLengths.length<r.timeline.length;)d.checkpointLengths.push(d.checkpointLengths.at(-1)??0);d.checkpointLengths[r.currentIndex]=d.currentLength}return vw(e,t.savedCheckpointOccurrences,d),e},Aw=({state:e})=>e.global.confirmDialog??null,tn=({state:e},{pointer:t}={})=>{let n=t??Le({state:e})?.pointer,i=Jb({state:e,pointer:n});return Qb({state:e,form:i.form,pointer:n})},Pw=({state:e},{pointer:t}={})=>!!tn({state:e},{pointer:t}),xe=({state:e},{pointer:t}={})=>{let n=tn({state:e},{pointer:t});if(n)return{source:Or,formId:n.id,formKey:n.key};let i=lp({state:e,pointer:t});return i?{source:yt,resourceId:i}:null},Ew=({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=Ee({state:e},{sectionId:i});if(!o||!o.lines||!Array.isArray(o.lines))return s.lastLineId===a;let l=o.lines.findIndex(u=>u.id===s.lastLineId),c=o.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},ma=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},ya=({state:e},t)=>Ew({state:e,registry:e.global.accountViewedRegistry},t),xw=({state:e},t)=>ma({registry:e.global.accountViewedRegistry},t),Qt=(e,t)=>!ma({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),ha=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),ga=(e,t)=>{let n=ha(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Go=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!Qt(e,t[a]))return t[a]},Sw=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:V(t)},np=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??ra(),i=ha(t),a=ga(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:Qt(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:Qt(e,c)}))})),o=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=t.groups.findIndex(f=>f.id===n.groupId),c=t.groups[l],u=c?.variants.findIndex(f=>f.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],d=l<0?-1:Math.floor(l/t.pageSize);p&&d===a&&!Qt(e,p)&&(o={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:Go(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:Go(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:o,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},ba=(e,t)=>!ma({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),wa=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Ia=(e,t)=>{let n=wa(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Ho=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!ba(e,t[a]))return t[a]},sp=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}),Ow=(e,t)=>({...sp(t),locked:ba(e,t)}),Pu=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")}`},Rw=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:V(t)},ip=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??ds(),i=wa(t),a=Ia(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>Ow(e,u)),o=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[o],c=l?{...sp(l),canPlayPreviousTrack:Ho(e,t.tracks,o,-1)!==void 0,canPlayNextTrack:Ho(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:Pu(n.positionMs),durationText:n.durationMs===null?null:Pu(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}}},va=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),ka=(e,t)=>{let n=va(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},$w=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:V(t)},Cw=({state:e})=>he(e)!==null,_w=({state:e})=>{let t=he(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},op=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,ap=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??sa(),i=va(t),a=ka(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:!op(e,l.sceneId)})),o=he(e);return{isActive:o!==null,activeSceneId:o?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},jw=({state:e})=>e.global.nextLineConfig,lp=({state:e,pointer:t}={})=>{let n=t??Le({state:e})?.pointer;if(!n)return;let i=n?.sectionId,a=n?.lineId,s=Ee({state:e},{sectionId:i})?.lines||[],o=s.findIndex(c=>c.id===a);if(o<0)return;let l;for(let c of s.slice(0,o+1)){let u=c?.actions;if(u?.cleanAll&&(l=void 0),!u||!Object.prototype.hasOwnProperty.call(u,"choice")){l=void 0;continue}let p=u.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},cp=({state:e})=>!!lp({state:e}),Nw=({state:e})=>structuredClone(e),Dw=({state:e})=>V(e.projectData.resources?.achievements??{}),Tw=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:V(n)},up=({state:e})=>e.global.saveSlots,Lw=({state:e},t)=>{let n=t?.slotId,i=Gr(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0},pp=({state:e})=>V(e.global.localizationPackages),Aa=({state:e})=>Pr(e),Mw=({state:e},t)=>Ze(e,t?.runtimeId),Pa=({state:e})=>{let t={...e.global?.variables??{},...$r(e)?.variables??{}};return ot({variables:t,runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{}})},Le=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},Ee=({state:e},t)=>{let{sectionId:n}=t;return mr(e.projectData,n).section},nn=({state:e})=>{let t=Le({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:i}=t.pointer,a=Ee({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===i)},fp=({state:e})=>{let{sectionId:t,lineId:n}=Le({state:e}).pointer,a=Ee({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===n),o=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(d=>{p[d]=u[d]}),p});return Ur(o)},dp=e=>{let t=nn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=ot({variables:{...e.global?.variables??{},...$r(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(i=>`${lt(i?.text,{variables:n})??""}`).join("")},yr=({state:e})=>Bo({text:dp(e),baseDelay:Ze(e,"autoForwardDelay"),speed:Ze(e,"autoForwardSpeed")}),qw=({state:e})=>{let t=mp({state:e}),i=nn({state:e})?.actions??{},a=Ur([t??{},i]);return io(t??{},a??{})},Vw=({state:e},{sectionId:t})=>{let n=Ee({state:e},{sectionId:t});if(!n?.lines)return[];let i=[],a={};for(let r of n.lines){let s=r.actions||{},o=Ur([a,s]),l=io(a,o);i.push({id:r.id,changes:l,presentationState:o}),a=oo(o)}return i},Fw=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let i=Vw({state:e},{sectionId:t});return n?{lines:i}:{lines:i.map(({presentationState:a,...r})=>r)}},mp=({state:e})=>{let{sectionId:t,lineId:n}=Le({state:e}).pointer,a=Ee({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===n);if(r<=0)return null;let o=a.slice(0,r).map(l=>{let c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return oo(Ur(o))},Ea=({state:e},{slotsPerPage:t=6}={})=>{let a=((Aa({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[Gr(o)]||{};r.push({...l,slotId:o})}return{saveSlots:r}},Uw=up,Bw=Ea,Yw=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},zw=({state:e},t={})=>{let n=fp({state:e}),i=mp({state:e}),a=nn({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:V(r)}:a,o=r?.animations&&i===null?{}:i,{sectionId:l}=Le({state:e}).pointer,{sceneId:c}=mr(e.projectData,l),u={...Aa({state:e}),localizationPackages:pp({state:e})},p=t?.activePersistentAnimations??[],d=t?.restoredPersistentAnimations??[],f=tn({state:e}),m=cp({state:e}),b=np({state:e}),h=ip({state:e}),y=ap({state:e}),w=Pa({state:e}),{saveSlots:g}=Ea({state:e}),E=Yw(e);return eu({presentationState:n,previousPresentationState:o,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:m,isFormVisible:!!f,canRollback:Lp({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:f,dialogueHistory:tp({state:e}),saveSlots:g,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:d,imageGallery:b,musicRoom:h,sceneReplay:y,musicRoomPlayer:V(e.global.musicRoomPlayer),activeAudioEffect:t?.activeAudioEffect??null})},Xw=({state:e},t)=>(e.global.confirmDialog=Yb(t),e.global.pendingEffects.push({name:"render"}),e),Gw=({state:e})=>(e.global.confirmDialog&&(gt(e),e.global.pendingEffects.push({name:"render"})),e),Hw=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),rr(e,"pushOverlay",n,t),e),Kw=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),rr(e,"popOverlay",void 0,t),e),Ww=({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"}),rr(e,"replaceLastOverlay",n,t),e),Jw=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],gt(e),bt(e),e.global.pendingEffects.push({name:"render"}),rr(e,"clearOverlays",void 0,t),e),Qw=(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"})},sn=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Xb(e,n),bt(e);let i=xe({state:e},{pointer:t}),a=i?.source===yt,r=i?.source===Or;Qw(e,{activeInteraction:i});let s=he(e),o={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Ou(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}},hs=(e,t,n)=>{!(t?.source===yt||t?.source===Or)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},yp=({state:e})=>(xe({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:yr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),on=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Zw=({state:e})=>{let t=e.global.autoMode;return xe({state:e})&&!t||(t?on({state:e}):yp({state:e})),e},hp=({state:e})=>(xe({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),Rr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),e0=({state:e})=>{let t=ep({state:e});return xe({state:e})&&!t||(t?Rr({state:e}):hp({state:e})),e},gs=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),rr(e,"showDialogueUI",void 0,t),e),gp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),rr(e,"hideDialogueUI",void 0,t),e),r0=e=>{let{state:t}=e;return rp({state:t})?gs(e):gp(e),t},_r=(e,t,n)=>(fa(e,t,n),Wu(e),e.global.pendingEffects.push({name:"render"}),e),an=(e,t,n,i,a)=>{let r=fa(e,t,n);return e.global.pendingEffects.push({name:"render"}),rr(e,i,{value:r},a),e},t0=({state:e},t)=>_r(e,"dialogueTextSpeed",t?.value),n0=({state:e},t)=>(_r(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e),s0=({state:e},t)=>(_r(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e),i0=({state:e},t)=>_r(e,"skipUnseenText",t?.value),o0=({state:e},t)=>_r(e,"skipTransitionsAndAnimations",t?.value),a0=({state:e},t)=>_r(e,"soundVolume",t?.value),l0=({state:e},t)=>_r(e,"musicVolume",t?.value),c0=({state:e},t)=>_r(e,"muteAll",t?.value),Ko=({state:e,rollbackActionBatchStack:t},n)=>an(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),Wo=({state:e,rollbackActionBatchStack:t})=>{let n=Ze(e,"saveLoadPagination")+1;return an(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},Jo=({state:e,rollbackActionBatchStack:t})=>{let n=Ze(e,"saveLoadPagination")-1;return an(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},Qo=({state:e,rollbackActionBatchStack:t},n)=>an(e,"menuPage",n?.value,"setMenuPage",t),Zo=({state:e,rollbackActionBatchStack:t},n)=>an(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),u0=({state:e})=>(e.global.pendingEffects=[],e),p0=({state:e},t)=>(e.global.pendingEffects.push(t),e),f0=({state:e},t)=>{if(he(e))return e;let n=t?.resourceId;return Ru(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},d0=({state:e},t)=>{if(he(e))return e;let n=t?.resourceId,i=Ru(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},bp=e=>e?.lines?.[0],wp=(e,{sectionId:t,resetStoryState:n=!1,screen:i})=>{let a=!!Yu(i),r=Ee({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=bp(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!ow(e,{queueRender:!a}))return e;let o=xe({state:e});n&&e.global.skipMode&&Rr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=wt(l),p=u.read;n||Xr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Cr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=Zt({pointer:u.read}):ys(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=sn(e,l?.pointers?.read,{screenTransition:i});return hs(e,o,c),e},m0=({state:e},t)=>{if(he(e))throw new Error("Cannot reset the story while a scene replay is active");return wp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},Ip=e=>(e.global.accountViewedRegistry=wb(e.global.accountViewedRegistry),e.global.accountViewedRegistry),bs=(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:V(n.value)}))}})},vp=(e,t)=>{bs(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:[]}}])},y0=(e,t,{sectionId:n,lineId:i})=>{if(!n||!i)return!1;let a=q(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=Ee({state:e},{sectionId:n});if(s?.lines){let o=s.lines.findIndex(c=>c.id===r.lastLineId),l=s.lines.findIndex(c=>c.id===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},Xr=(e,t)=>{if(he(e)||e.global.accountViewedRegistry===void 0)return;y0(e,Ip(e),t)&&vp(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},h0=({state:e},t)=>(Xr(e,t),e.global.pendingEffects.push({name:"render"}),e),g0=({state:e},t)=>{if(he(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let i=Ip(e);i.resources.find(r=>r.resourceId===n)||(i.resources.push({resourceId:n}),vp(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},tr=(e,t,n)=>{if(!q(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}"`)})},ea=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},ws=(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"}))},b0=({state:e},t)=>{let n="showImageGalleryVariant";tr(n,t,fb),ea(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&ea(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||Qt(e,s)||ws(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/i.pageSize)}),e},kp=(e,t,n,i)=>{tr(i,t,ta);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=Go(e,s.variants,o,n);return l&&ws(e,{...r,variantId:l.id}),e},w0=({state:e},t)=>kp(e,t,-1,"moveToPreviousImageGalleryVariant"),I0=({state:e},t)=>kp(e,t,1,"moveToNextImageGalleryVariant"),v0=({state:e},t)=>{if(tr("clearImageGallerySelection",t,ta),e.projectData?.resources?.imageGallery===void 0)return e;let i=e.global.imageGalleryNavigation;return ws(e,{groupId:null,variantId:null,pageIndex:i.pageIndex}),e},Ap=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let i=ha(n);if(t>=i)return e;let a=e.global.imageGalleryNavigation,r=ga(n,a);return t===r||ws(e,{groupId:null,variantId:null,pageIndex:t}),e},k0=({state:e},t)=>{if(tr("moveToImageGalleryPage",t,db),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Ap(e,t.pageIndex)},Pp=(e,t,n,i)=>{tr(i,t,ta);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=ga(a,e.global.imageGalleryNavigation)+n;return s<0?e:Ap(e,s)},A0=({state:e},t)=>Pp(e,t,1,"moveToNextImageGalleryPage"),P0=({state:e},t)=>Pp(e,t,-1,"moveToPreviousImageGalleryPage"),hr=(e,t,n)=>{if(!q(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}"`)})},E0=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},We=e=>{e.global.pendingEffects.push({name:"render"})},Ep=(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:ms(e),operation:"pause"});let o=rn(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},We(e)},x0=({state:e},t)=>{let n="playMusicRoomTrack";hr(n,t,mb),E0(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||ba(e,a)||Ep(e,a),e},S0=({state:e},t)=>{hr("playMusicRoom",t,ht);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=rn(e,s,s==="play"?o:void 0),i.seekFallback=null,i.status="playing",i.positionMs=o,r&&(i.readiness=i.durationMs===null?"loading":"ready"),We(e),e},O0=({state:e},t)=>{hr("pauseMusicRoom",t,ht);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status!=="playing"||(i.playback=rn(e,"pause"),i.seekFallback=null,i.status="paused",We(e)),e},R0=({state:e},t)=>{hr("stopMusicRoom",t,ht);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status==="stopped"&&i.positionMs===0||(i.playback=rn(e,"stop"),i.seekFallback=null,i.status="stopped",i.positionMs=0,We(e)),e},$0=({state:e},t)=>{if(hr("seekMusicRoom",t,yb),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=rn(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"),We(e),e},xp=(e,t,n,i)=>{hr(i,t,ht);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=Ho(e,a.tracks,s,n);return o&&Ep(e,o),e},C0=({state:e},t)=>xp(e,t,-1,"playPreviousMusicRoomTrack"),_0=({state:e},t)=>xp(e,t,1,"playNextMusicRoomTrack"),j0=({state:e},t)=>{hr("clearMusicRoomSelection",t,ht);let i=e.global.musicRoomPlayer;if(i.trackId===null)return e;let a=i.pageIndex,r={commandId:ms(e),operation:"resume"};return e.global.musicRoomPlayer={...ds({bgmPlayback:r}),pageIndex:a},We(e),e},Sp=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=wa(n))return e;let i=e.global.musicRoomPlayer,a=Ia(n,i);return t===a||(i.pageIndex=t,We(e)),e},N0=({state:e},t)=>{if(hr("moveToMusicRoomPage",t,hb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Sp(e,t.pageIndex)},Op=(e,t,n,i)=>{hr(i,t,ht);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Ia(a,e.global.musicRoomPlayer)+n;return r<0?e:Sp(e,r)},D0=({state:e},t)=>Op(e,t,1,"moveToNextMusicRoomPage"),T0=({state:e},t)=>Op(e,t,-1,"moveToPreviousMusicRoomPage"),zr=e=>{let t=he(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=V(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(),nw(e,n),e.global.pendingEffects.push({name:"render"}),!0},L0=({state:e},t)=>{let n="startSceneReplay";if(tr(n,t,gb),ea(n,"sceneId",t.sceneId),he(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||!op(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],s=r?.initialSectionId,o=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=rw(e);tw(e);let u=da({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 Ku(e,u),e.contexts.push(u),sn(e,u.pointers.read),e},Rp=({state:e},t)=>{tr("finishSceneReplay",t,na);let i=he(e);if(i)return i.sceneReplay.finishOnNextAdvance=!0,e;if($r(e)?.rollback?.isRestoring===!0)return e;let r=Le({state:e})?.pointer,{sceneId:s}=mr(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=Ib(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),bs(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},M0=({state:e},t)=>(tr("exitSceneReplay",t,na),zr(e),e),$p=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=va(n))return e;let i=ka(n,e.global.sceneReplayNavigation);return t===i||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},q0=({state:e},t)=>{if(tr("moveToSceneReplayPage",t,bb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return $p(e,t.pageIndex)},Cp=(e,t,n,i)=>{tr(i,t,na);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=ka(a,e.global.sceneReplayNavigation)+n;return r<0?e:$p(e,r)},V0=({state:e},t)=>Cp(e,t,1,"moveToNextSceneReplayPage"),F0=({state:e},t)=>Cp(e,t,-1,"moveToPreviousSceneReplayPage"),Is=(e,t)=>{let n=e.global.musicRoomPlayer;return!q(t)||t.id!==ub||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},xa=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,_p=(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,We(e)),e),U0=({state:e},t)=>{let n=Is(e,t);return!n||n.readiness!=="loading"||!xa(t)?e:_p(e,n,t,{readiness:"ready"})},B0=({state:e},t)=>{let n=Is(e,t);return!n||n.readiness!=="ready"||!xa(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:_p(e,n,t)},Y0=({state:e},t)=>{let n=Is(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!xa(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,We(e)),e},z0=({state:e},t)=>{let n=Is(e,t);if(!n||typeof t.errorCode!="string"||!pb.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&&We(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,We(e),e},jp=({state:e,rollbackActionBatchStack:t},n)=>{let i=xb(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,d=e.global.nextLineConfig.auto?.trigger,f=e.global.nextLineConfig.auto?.delay,m=xe({state:e});return!u&&(a!==void 0&&(p!==s||d!==o||f!==l))&&(!m&&p===!0&&(d==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:f}}):s===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),rr(e,"setNextLineConfig",n,t),e},X0=({state:e},t)=>{if(he(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;$u(n,"saveSlot");let{thumbnailImage:i}=t,a=t?.savedAt,r=Gr(n),s=V(e.contexts);s?.forEach(c=>{wt(c),Ju(c.rollback),Cb(c.rollback,e.projectData)});let o={contexts:s},l={formatVersion:Su,slotId:Du(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},G0=({state:e},t)=>{if(he(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;$u(n,"loadSlot");let i=Gr(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0;if(a){let r=Bb(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=en(),e.global.overlayStack=[],e.global.isLineCompleted=!0,gt(e),bt(e),oa(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},H0=({state:e},t)=>{if(he(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;Nu(n),Dt(n),Tt(n),Lt(n),Vr(n?.resources?.variables??{}),fo(n);let i=Db(n),a=i?e.contexts?.map((s,o)=>Bu(V(s),n,o)):void 0,r=i?_b(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=ra(),e.global.sceneReplayNavigation=sa(),oa(e),i){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:o}=Bn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...o,...Mt(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return gt(e),bt(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},K0=({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(!q(i))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=i,fa(e,"localizationPackageId",n),Wu(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},W0=({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&&!Ee({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=Ee({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=xe({state:e}),c=wt(a);c.read={sectionId:r,lineId:i};let{activeInteraction:u}=sn(e,c.read);return hs(e,l,u),e},J0=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return gs({state:e,rollbackActionBatchStack:t}),e;let i=xe({state:e});if(i?.source===yt&&n?.bypassChoice!==!0||i?.source===Or&&n?._interactionSource!==Or)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,he(e)?.sceneReplay.exitOnLineCompleted)return zr(e),e;let f=Le({state:e})?.pointer,m=f?.sectionId,b=f?.lineId;m&&b&&Xr(e,{sectionId:m,lineId:b}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!i&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}});let h=e.global.nextLineConfig,y=Ee({state:e},{sectionId:m});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===b?zo(e):h?.auto?.enabled&&!i&&h.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:h.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(he(e)?.sceneReplay.finishOnNextAdvance)return zr(e),e;let r=Le({state:e})?.pointer,s=r?.sectionId,o=Ee({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=o?.lines||[],p=c.findIndex(d=>d.id===r?.lineId)+1;if(p<c.length){let d=c[p],f=!Ze(e,"skipUnseenText");if(e.global.skipMode&&f&&!ya({state:e},{sectionId:s,lineId:d.id}))return Rr({state:e}),e;if(l&&!l.rollback&&Cr(l,{compatibilityAnchor:!0}),l){let b=wt(l),h=b.read?.lineId;h&&s&&Xr(e,{sectionId:s,lineId:h}),b.read={sectionId:s,lineId:d.id}}ys(e,{sectionId:s,lineId:d.id}),ia(e);let{activeInteraction:m}=sn(e,{sectionId:s,lineId:d.id});hs(e,i,m)}else{if(he(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),zr(e),e;e.global.autoMode&&on({state:e}),e.global.skipMode&&Rr({state:e}),zo(e)}return e},Q0=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,he(e)?.sceneReplay.exitOnLineCompleted)return zr(e),e;let n=xe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}});let i=Le({state:e})?.pointer,a=i?.sectionId,r=i?.lineId;a&&r&&Xr(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},Z0=({state:e},t)=>wp(e,{sectionId:t?.sectionId,screen:t?.screen}),eI=({state:e,rollbackActionBatchStack:t},n)=>{let i=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!i)return gs({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e;let a=xe({state:e});if(a?.source===yt&&n?.bypassChoice!==!0||a?.source===Or&&n?._interactionSource!==Or||a&&a.source!==yt&&a.source!==Or)return e;let r=he(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(zr(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=Le({state:e})?.pointer,o=s?.sectionId,l=Ee({state:e},{sectionId:o}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],d=u.findIndex(f=>f.id===s?.lineId)+1;if(d<u.length){let f=u[d],m=!Ze(e,"skipUnseenText");if(e.global.skipMode&&m&&!ya({state:e},{sectionId:o,lineId:f.id})&&(Rr({state:e}),!i))return e;if(c&&!c.rollback&&Cr(c,{compatibilityAnchor:!0}),c){let h=wt(c),y=h.read?.lineId;y&&o&&Xr(e,{sectionId:o,lineId:y}),h.read={sectionId:o,lineId:f.id}}ys(e,{sectionId:o,lineId:f.id}),ia(e);let{activeInteraction:b}=sn(e,{sectionId:o,lineId:f.id});hs(e,a,b)}else{if(he(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),zr(e),e;e.global.autoMode&&on({state:e}),e.global.skipMode&&Rr({state:e}),zo(e)}return e},Sa=(e,t={})=>{let n=tn({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},rI=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=e.projectData.resources?.variables?.[t.variableId],i=n?.scope,a=n?.type;if(Re(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(qt(i,t.variableId),Vt(a,"set",t.variableId),he(e)&&i!=="context")throw new Error(`Cannot update ${i}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:i}},tI=(e,t)=>({id:e.id,key:e.key,valid:!0,values:V(t),fields:V(e.fields),fieldList:V(e.fieldList)}),nI=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Le({state:e})?.pointer,n=t?.sectionId,i=t?.lineId;n&&i&&Xr(e,{sectionId:n,lineId:i})},sI=({state:e},t={})=>{let n=Sa(e,t),i=t.field;if(!n?.fields?.[i])return e;let a=Xu(e,n.key),r=ps(t.value),s=n.fields[i],o=ua(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},iI=({state:e,rollbackActionBatchStack:t},n={})=>{let i=Sa(e,n);if(!i)return{submitted:!1,valid:!1,reason:"inactive"};let a=Xu(e,i.key);a.submitted=!0;let r={},s={};if(Object.entries(i.fields).forEach(([d,f])=>{let m=Object.prototype.hasOwnProperty.call(a.values,d)?a.values[d]:f.value,b=ua(f,m);a.touched[d]=!0,b&&(s[d]=b),r[d]=zu(f,m)}),a.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:V(s),form:{id:i.id,key:i.key,values:V(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(([d,f])=>{let{scope:m}=rI(e,f),b=m==="context"?o.variables:e.global.variables,h=r[d];b[f.variableId]=zn(b[f.variableId],"set",h),m==="context"&&(l=!0,u.push({variableId:f.variableId,op:"set",value:h})),(m==="device"||m==="account")&&c.push({scope:m,path:`variables.${f.variableId}`,op:"set",value:V(b[f.variableId])})}),l&&rr(e,"updateVariable",{id:"submitForm",operations:u},t),bs(e,c);let p=tI(i,r);return nI(e),delete e.global.formDrafts[i.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},oI=({state:e},t={})=>{let n=Sa(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:V(n.values),fields:V(n.fields),fieldList:V(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},aI=({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:d})=>{let f=e.projectData.resources?.variables?.[c],m=f?.scope,b=f?.type;if(Re(f))throw new Error(`Cannot update computed variable: ${c}`);if(f?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(qt(m,c),Vt(b,u,c),Yn(b,u,p,c,{roundTo:d}),he(e)&&m!=="context")throw new Error(`Cannot update ${m}-scoped variable "${c}" while a scene replay is active`);let h=m==="context"?r.variables:e.global.variables;if(m==="context"){s=!0;let y={variableId:c,op:u,value:p};d!==void 0&&(y.roundTo=d),l.push(y)}h[c]=zn(h[c],u,p,{roundTo:d}),(m==="device"||m==="account")&&o.push({scope:m,path:`variables.${c}`,op:"set",value:V(h[c])})}),s&&rr(e,"updateVariable",{id:i,operations:l},t),bs(e,o),e.global.pendingEffects.push({name:"render"}),e},Xe=e=>(t,n)=>e({state:t},n),Np=e=>({variables:ot({variables:{...e.global?.variables??{},...$r(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Pr(e)}),lI=e=>{if(!q(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")},cI=(e,t,n)=>{if(!q(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!q(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")},uI=(e,t,n,i)=>{lI(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(cI(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Nt(r.when,{...Np(e),...n?.bindings??{}}))){Oa(e,r.actions,n,[...i,"branches",String(a),"actions"]);return}}},pI=(e,t,n,i)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==dr)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=Hn(V(l.result),l.type);if(c.type==="integer"){if(!Mu(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}`);Xo(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!q(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Oa(e,u,n,[...i,"distribution","outcomes",String(c.outcomeIndex),"actions"])},fI={conditional:{replayLine:uI},random:{replayLine:pI},updateVariable:{recordSources:[Sr],replayLine:Xo,replayRecorded:Xo,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Xe(jp)},setSaveLoadPagination:{recordSources:[Sr],replayLine:Xe(Ko),replayRecorded:Xe(Ko),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Sr],replayLine:Xe(Wo),replayRecorded:Xe(Wo),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Sr],replayLine:Xe(Jo),replayRecorded:Xe(Jo),persistInSaveSlot:!0},setMenuPage:{recordSources:[Sr],replayLine:Xe(Qo),replayRecorded:Xe(Qo),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Sr],replayLine:Xe(Zo),replayRecorded:Xe(Zo),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Xe(Rp)}},vs=e=>fI[e]??null,dI=e=>vs(e)?.persistInSaveSlot===!0,mI=(e,t)=>{let n=vs(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},yI=(e,t,n)=>{vs(t)?.replayRecorded?.(e,n)},hI=(e,t,n,i,a)=>{let r=vs(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,i,a);return}let s=i?.bindings??{},o=Ft({[t]:n},{...Np(e),...s})[t];r.replayLine(e,o)},Oa=(e,t,n,i)=>{let a=Kn(t);Jn(a);for(let[r,s]of a)hI(e,r,s,n,[...i,r])},gI=e=>e?.returnable!==!1,Dp=(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(gI(e.timeline[i])&&(n-=1,n===0))return i;return-1},Tp=({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=Dp(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},Lp=({state:e})=>Tp({state:e},{offset:-1})!==null,bI=({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=Cr(i,{compatibilityAnchor:!i.rollback}),r=Dp(a,n);return r<0||r>=a.timeline.length?e:Zu(e,r)},wI=({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=Cr(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:Zu(e,o)},II=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),Yo=(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]},Eu=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,xu=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},vI=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Mp=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}},Ra=e=>JSON.stringify(Mp(e)),kI=({actionName:e,args:t,state:n,previousState:i})=>{let a=Eu(i),r=Eu(n);if(!vI(a,r)||i.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&xu(i)!==xu(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=mr(n.projectData,s.sectionId).section,l=bp(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??{},Gr(o))}return!1},AI=({actionName:e,args:t,state:n,transactionalMetadata:i,previousState:a})=>{if(kI({actionName:e,args:t,state:n,previousState:a})){let u=Yo(i,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?i.rollbackAuthoredSuppression={lineEntryId:u,configKey:Ra(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"?xe({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!o||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&Yo(i,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!o||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&Yo(i,"skipSessionId")},PI=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==Ra(e))&&(t.rollbackAuthoredSuppression=null)},EI=({state:e,playbackOwnership:t})=>{let n=xe({state:e}),i=t.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!n&&e.global.skipMode===!0,s=Mp(e),o=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(o?.lineEntryId===i&&o.configKey===Ra(e)),c=a?dp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:i},delayMs:Bo({text:c,baseDelay:Ze(e,"autoForwardDelay"),speed:Ze(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}},xI=({playbackOwnership:e})=>e.lineEntryId,qp=(e,t={})=>{let n=gw(e),i=[],a=t.createPlaybackOwnership??II;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return ql(n,{selectPendingEffects:ww,selectSkipMode:ep,selectAutoMode:Iw,selectIsChoiceVisible:cp,selectIsFormVisible:Pw,selectActiveInteraction:xe,selectActiveForm:tn,selectDialogueUIHidden:rp,selectDialogueHistory:tp,selectConfirmDialog:Aw,selectIsLineAccountViewed:ya,selectIsResourceAccountViewed:xw,selectImageGalleryConfig:Sw,selectImageGallery:np,selectMusicRoomConfig:Rw,selectMusicRoom:ip,selectSceneReplayConfig:$w,selectSceneReplay:ap,selectIsSceneReplayActive:Cw,selectActiveSceneReplayEntry:_w,selectNextLineConfig:jw,selectSystemState:Nw,selectAchievements:Dw,selectAchievement:Tw,selectSaveSlotMap:up,selectSaveSlots:Uw,selectSaveSlot:Lw,selectLocalizationPackages:pp,selectRuntime:Aa,selectRuntimeValue:Mw,selectAllVariables:Pa,selectCurrentPointer:Le,selectSection:Ee,selectCurrentLine:nn,selectPresentationState:fp,selectAutoForwardTimerDelay:yr,selectPresentationChanges:qw,selectSectionLineChanges:Fw,selectSaveSlotPage:Ea,selectCurrentPageSlots:Bw,selectRenderState:zw,selectOverlayStack:bw,selectLineIdByOffset:Tp,selectCanRollback:Lp,selectRollbackCursor:lw,selectDesiredPlaybackTimers:EI,selectPlaybackLineEntryId:xI,startAutoMode:yp,stopAutoMode:on,toggleAutoMode:Zw,startSkipMode:hp,stopSkipMode:Rr,toggleSkipMode:e0,showDialogueUI:gs,hideDialogueUI:gp,toggleDialogueUI:r0,setDialogueTextSpeed:t0,setAutoForwardDelay:n0,setAutoForwardSpeed:s0,setSkipUnseenText:i0,setSkipTransitionsAndAnimations:o0,setSoundVolume:a0,setMusicVolume:l0,setMuteAll:c0,setSaveLoadPagination:Ko,incrementSaveLoadPagination:Wo,decrementSaveLoadPagination:Jo,setMenuPage:Qo,setMenuEntryPoint:Zo,showConfirmDialog:Xw,hideConfirmDialog:Gw,resetStoryAtSection:m0,clearPendingEffects:u0,appendPendingEffect:p0,completeAchievement:f0,setAchievementProgress:d0,beginRollbackActionBatch:pw,endRollbackActionBatch:fw,ensureRandomReplayOccurrence:dw,recordRandomOutcome:mw,markRollbackCheckpointTransient:cw,markSavedRollbackCheckpointTransient:uw,recordCurrentDialogueHistory:kw,addViewedLine:h0,addViewedResource:g0,showImageGalleryVariant:b0,moveToPreviousImageGalleryVariant:w0,moveToNextImageGalleryVariant:I0,clearImageGallerySelection:v0,moveToImageGalleryPage:k0,moveToNextImageGalleryPage:A0,moveToPreviousImageGalleryPage:P0,playMusicRoomTrack:x0,playMusicRoom:S0,pauseMusicRoom:O0,stopMusicRoom:R0,seekMusicRoom:$0,playPreviousMusicRoomTrack:C0,playNextMusicRoomTrack:_0,clearMusicRoomSelection:j0,moveToMusicRoomPage:N0,moveToNextMusicRoomPage:D0,moveToPreviousMusicRoomPage:T0,musicRoomSoundReady:U0,musicRoomSoundProgress:B0,musicRoomSoundComplete:Y0,musicRoomSoundError:z0,startSceneReplay:L0,finishSceneReplay:Rp,exitSceneReplay:M0,moveToSceneReplayPage:q0,moveToNextSceneReplayPage:V0,moveToPreviousSceneReplayPage:F0,setNextLineConfig:jp,saveSlot:X0,loadSlot:G0,updateProjectData:H0,updateLocalizationPackage:K0,sectionTransition:Z0,jumpToLine:W0,nextLine:J0,markLineCompleted:Q0,rollbackToLine:wI,rollbackByOffset:bI,pushOverlay:Hw,popOverlay:Kw,replaceLastOverlay:Ww,clearOverlays:Jw,updateFormField:sI,submitForm:iI,cancelForm:oI,updateVariable:aI,nextLineFromSystem:eI},{createTransactionalMetadata:a,updateTransactionalMetadata:AI,finalizeTransactionalMetadata:PI,transformActionFirstArgument:(s,o)=>({state:s,rollbackActionBatchStack:i,playbackOwnership:o}),transformSelectorFirstArgument:(s,o)=>({state:s,playbackOwnership:o})})};var SI="route-engine",OI="projectPersistence";var Fp=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),Ie=e=>Object.prototype.toString.call(e)==="[object Object]",Vp="variables.",RI=(e={})=>{let t=Ie(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!Ie(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)}:!Ie(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},$I=(e={})=>{let t=Ie(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!Ie(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)}:!Ie(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},CI=(e,t)=>{let n=$I(e),i=RI(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}},_I=(e={})=>{let t=Ie(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(i=>typeof i=="string"&&i.length>0))]}},jI=(e,t)=>{let n=_I(e),i=Ie(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...i.filter(a=>typeof a=="string"&&a.length>0)])]}},Up=(e={})=>{let t=Ie(e)?e:{};return{saveSlots:Ie(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:Ie(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:Ie(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:Ie(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:Ie(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:Ie(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},NI=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!Ie(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let i=t.path?.startsWith(Vp)?t.path.slice(Vp.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(!Ie(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}].`)})},DI=(e,t)=>{let n={};return NI(t).forEach(i=>{if(i.path==="viewedRegistry"){n.accountViewedRegistry=CI(n.accountViewedRegistry??e.accountViewedRegistry,i.value);return}if(i.path==="replayRegistry"){n.accountReplayRegistry=jI(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},It=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},TI=e=>{let t=It(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},LI=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},MI=({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}".`))}}),qI=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.`))}})},ln=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=f=>{u||(u=!0,s(f))},d=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let f=Up(c.result),m=typeof i=="function"?i(f):i,b={namespace:n,version:1,...Fp(),...f,...m},h=l.put(b);h.onerror=()=>{p(h.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},o.oncomplete=()=>{d()},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}".`))}})},VI=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=d=>{c||(c=!0,r(d))},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}".`))}})},$a=(e={})=>{let{indexedDB:t,databaseName:n=SI,objectStoreName:i=OI,namespace:a}=e,r=LI(t),s=TI(a),o=MI({indexedDB:r,databaseName:n,objectStoreName:i});return{namespace:s,load:async()=>{let l=await qI({databasePromise:o,objectStoreName:i,namespace:s});return{...Fp(),...Up(l)}},clear:async()=>VI({databasePromise:o,objectStoreName:i,namespace:s}),saveSlots:async l=>ln({databasePromise:o,objectStoreName:i,namespace:s,patch:{saveSlots:Ie(l)?l:{}}}),saveGlobalDeviceVariables:async l=>ln({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalDeviceVariables:Ie(l)?l:{}}}),saveGlobalAccountVariables:async l=>ln({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalAccountVariables:Ie(l)?l:{}}}),saveGlobalRuntime:async l=>ln({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalRuntime:Ie(l)?l:{}}}),applyScopedDataUpdates:async l=>ln({databasePromise:o,objectStoreName:i,namespace:s,patch:c=>DI(c,l)})}},FI=$a;var Xp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ca=Object.freeze({volume:100,pan:0,playbackRate:1}),UI=["src","startAt","endAt","startDelayMs"],Bp=(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]},BI=(e,t)=>e?.id===t?.id&&UI.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),YI=(e,t)=>JSON.stringify(e)===JSON.stringify(t),zI=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.audioEffects.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},XI=(e,t,n)=>({...Xp(e,"startValue")?{startValue:e.startValue}:{},value:e.value==="target"?n:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Yp=(e,t,n,i)=>{if(e)return{...t==="enter"?{initialValue:0}:{},keyframes:[{value:t==="exit"?0:i,delay:(e.delay??0)/n,duration:e.duration/n,easing:e.easing??"linear"}]}},GI=({property:e,authored:t,target:n,speed:i,resourcePath:a})=>{let r=t.keyframes.at(-1);if(r?.value!=="target"||r.relative===!0)throw new Error(`[${a}.tween.${e}.keyframes] The final keyframe must use the absolute value "target".`);return{keyframes:t.keyframes.map(s=>XI(s,i,n))}},zp=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),Gp=({occurrence:e,resources:t={},previousChannel:n,nextChannel:i})=>{if(!e?.selection)return null;let a=e.selection,r=e.actionPath??"bgm",s=a.resourceId,o=`resources.audioEffects.${s}`,l=t.audioEffects?.[s];if(!l)throw new Error(`[${r}.audioEffects.resourceId]
3
- [${o}] Unknown audio effect resource "${s}".`);let c=zI(a,r),u=Bp(n,r),p=Bp(i,r);if(!u&&!p)return null;if(u&&p&&u.id!==p.id)throw new Error(`[${r}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let d=u?.id??p.id,f=BI(u,p),m=YI(u,p);if(l.type==="transition"){if(f){if(m)return null;throw new Error(`[${r}.audioEffects]
4
- [${o}] Audio effect resource "${s}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let h={},y=Yp(u?l.prev?.fade:void 0,"exit",c,0),w=Yp(p?l.next?.fade:void 0,"enter",c,p?.volume??Ca.volume);return y&&(h.exit=y),w&&(h.enter=w),Object.keys(h).length===0?null:{...zp(e,d),properties:{volume:h}}}if(l.type!=="update")throw new Error(`[${o}.type] Unsupported audio effect type "${l.type}".`);if(!u||!p||!f)throw new Error(`[${r}.audioEffects]
5
- [${o}] Audio effect resource "${s}" has type "update", but the BGM action changes source identity. Use a transition resource.`);if(m)return null;let b={};for(let h of["volume","pan","playbackRate"]){if(!Xp(l.tween,h))continue;let y=u[h]??Ca[h],w=p[h]??Ca[h];Object.is(y,w)||(b[h]={update:GI({property:h,authored:l.tween[h],target:w,speed:c,resourcePath:o})})}if(Object.keys(b).length===0)throw new Error(`[${r}.audioEffects]
6
- [${o}] Audio update resource "${s}" does not animate a BGM sound property changed by this action.`);return{...zp(e,d),properties:b}};var sf=of;var HI={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},Je=Object.prototype.hasOwnProperty,KI={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 qe(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 f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[f]:r.push(f),s++}if(e.y===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[f]:r.push(f),s++}for(let f in e)if(!(f==="x"||f==="y"||f==="quality"||f==="kernelSize"||f==="repeatEdgePixels")){let m={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.x!==void 0){let f=e.x;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.y!==void 0){let f=e.y;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.quality!==void 0){let f=e.quality;if(typeof f=="number"){if(f<1||isNaN(f)){let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.kernelSize!==void 0){let f=e.kernelSize;if(!(typeof f=="number"&&!(f%1)&&!isNaN(f))){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[m]:r.push(m),s++}if(!(f===5||f===7||f===9||f===11||f===13||f===15)){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:KI.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[m]:r.push(m),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let f={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),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 qe.errors=r,s===0}var $e=Kp().default;function As(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 As.errors=r,s===0}function nr(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++)As(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?As.errors:r.concat(As.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 nr.errors=r,s===0}var WI={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Ps(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:WI.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 Ps.errors=r,s===0}function ue(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&&(Ps(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ps.errors:r.concat(Ps.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 ue.errors=r,s===0}function Es(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(!Je.call(HI.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&&(qe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),e.filters!==void 0&&(nr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length)),e.animations!==void 0&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Es.errors=r,s===0}function of(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Es(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Es.errors:r.concat(Es.errors),s=r.length),of.errors=r,s===0}var af=lf;var Wp={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},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},Jp={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}},required:["id","resourceId"],additionalProperties:!1};function Me(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(!Je.call(Jp.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:Jp.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 Me.errors=r,s===0}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 Ss(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 Ss.errors=r,s===0}function Os(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 w={};r===null?r=[w]:r.push(w),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 w={};r===null?r=[w]:r.push(w),s++}}var d=p===s;if(d){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 f=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let w={};r===null?r=[w]:r.push(w),s++}}var h=b===s;if(s=f,r!==null&&(f?r.length=f:r=null),h){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let g={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),s++}var h=y===s;m=h}if(!m){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(!Je.call(Wp.properties,y)){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let g=0;g<w;g++)Me(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?Me.errors:r.concat(Me.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Wp.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}e.audioEffects!==void 0&&(Ss(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?Ss.errors:r.concat(Ss.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 Os.errors=r,s===0}function lf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Os(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Os.errors:r.concat(Os.errors),s=r.length),lf.errors=r,s===0}var cf=uf;var JI={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 Rs(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],d=s,f=!0,m=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let b;if(p.sprites===void 0&&(b="sprites")){let h={};r===null?r=[h]:r.push(h),s++}}var o=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),o){let b=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=b===s;f=o}if(!f){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[b]:r.push(b),s++}for(let b in p)if(!Je.call(JI.properties.items.items.properties,b)){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(p.id!==void 0&&typeof p.id!="string"){let b={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let b={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(p.x!==void 0&&typeof p.x!="number"){let b={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.y!==void 0&&typeof p.y!="number"){let b={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let b={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let b={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let b={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let b={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let b={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let b={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let b={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let b={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let b={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.alpha!==void 0){let b=p.alpha;if(typeof b=="number"){if(b>1||isNaN(b)){let h={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=[h]:r.push(h),s++}if(b<0||isNaN(b)){let h={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=[h]:r.push(h),s++}}else{let h={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(p.opacity!==void 0){let b=p.opacity;if(typeof b=="number"){if(b>1||isNaN(b)){let h={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=[h]:r.push(h),s++}if(b<0||isNaN(b)){let h={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=[h]:r.push(h),s++}}else{let h={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(p.blur!==void 0&&(qe(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),p.filters!==void 0&&(nr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length)),p.sprites!==void 0){let b=p.sprites;if(Array.isArray(b)){let h=b.length;for(let y=0;y<h;y++){let w=b[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let g in w)if(!(g==="id"||g==="resourceId"||g==="animationName"||g==="animationSpeed"||g==="loop")){let E={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(w.id!==void 0&&typeof w.id!="string"){let g={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=[g]:r.push(g),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let g={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=[g]:r.push(g),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let g={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=[g]:r.push(g),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let g={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=[g]:r.push(g),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let g={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=[g]:r.push(g),s++}}else{let g={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=[g]:r.push(g),s++}}}else{let h={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}p.animations!==void 0&&(ue(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.errors),s=r.length))}else{let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),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 Rs.errors=r,s===0}function uf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Rs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Rs.errors:r.concat(Rs.errors),s=r.length),uf.errors=r,s===0}var pf=ff;function $s(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 d={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),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 d=p.click;if(!(d&&typeof d=="object"&&!Array.isArray(d))){let f={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=[f]:r.push(f),s++}}}else{let d={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),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&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 $s.errors=r,s===0}function ff(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return $s(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?$s.errors:r.concat($s.errors),s=r.length),ff.errors=r,s===0}var df=mf;function Cs(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 Cs.errors=r,s===0}function mf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Cs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Cs.errors:r.concat(Cs.errors),s=r.length),mf.errors=r,s===0}var yf=hf;function _s(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"){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 _s.errors=r,s===0}function hf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return _s(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),s=r.length),hf.errors=r,s===0}var gf=bf;var Qp={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 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(!Je.call(Qp.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&&(ue(o.animations,{instancePath:t+"/ui/animations",parentData:o,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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:Qp.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 d=c[p];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={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=[f]:r.push(f),s++}if(d.resourceId===void 0){let f={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=[f]:r.push(f),s++}for(let f in d)if(!(f==="id"||f==="resourceId"||f==="animationName"||f==="animationSpeed"||f==="loop")){let m={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(d.id!==void 0&&typeof d.id!="string"){let f={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=[f]:r.push(f),s++}if(d.resourceId!==void 0&&typeof d.resourceId!="string"){let f={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=[f]:r.push(f),s++}if(d.animationName!==void 0&&typeof d.animationName!="string"){let f={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=[f]:r.push(f),s++}if(d.animationSpeed!==void 0&&typeof d.animationSpeed!="number"){let f={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=[f]:r.push(f),s++}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={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=[f]:r.push(f),s++}}else{let f={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=[f]:r.push(f),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&&(ue(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 js.errors=r,s===0}function bf(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),bf.errors=r,s===0}var wf=If;function Ns(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&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Ns.errors=r,s===0}function If(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ns(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),s=r.length),If.errors=r,s===0}var vf=kf;function Ds(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&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Ds.errors=r,s===0}function kf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ds(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),s=r.length),kf.errors=r,s===0}var Af=Pf;function Ts(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&&(qe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),e.animations!==void 0&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Ts.errors=r,s===0}function Pf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ts(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),s=r.length),Pf.errors=r,s===0}var Ef=xf;var Zp={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};function Ls(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 d=0;d<p;d++)Me(u[d],{instancePath:t+"/items/"+d,parentData:u,parentDataProperty:d,rootData:a})||(r=r===null?Me.errors:r.concat(Me.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 d=0;d<p;d++){let f=u[d];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[m]:r.push(m),s++}if(f.sounds===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[m]:r.push(m),s++}for(let m in f)if(!(m==="id"||m==="volume"||m==="muted"||m==="pan"||m==="loop"||m==="interruption"||m==="applyMode"||m==="sounds")){let b={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),s++}if(f.id!==void 0){let m=f.id;if(typeof m=="string"){if($e(m)<1){let b={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}}if(f.volume!==void 0){let m=f.volume;if(typeof m=="number"){if(m>100||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(m<0||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/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+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(f.muted!==void 0&&typeof f.muted!="boolean"){let m={instancePath:t+"/channels/"+d+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(f.pan!==void 0){let m=f.pan;if(typeof m=="number"){if(m>1||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(m<-1||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/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+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(f.loop!==void 0&&typeof f.loop!="boolean"){let m={instancePath:t+"/channels/"+d+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(f.interruption!==void 0){let m=f.interruption;if(typeof m!="string"){let b={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(m==="immediate"||m==="loopEnd")){let b={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:Zp.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(f.applyMode!==void 0){let m=f.applyMode;if(typeof m!="string"){let b={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(m==="singleLine"||m==="persistent")){let b={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:Zp.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(f.sounds!==void 0){let m=f.sounds;if(Array.isArray(m)){let b=m.length;for(let h=0;h<b;h++)Me(m[h],{instancePath:t+"/channels/"+d+"/sounds/"+h,parentData:m,parentDataProperty:h,rootData:a})||(r=r===null?Me.errors:r.concat(Me.errors),s=r.length)}else{let b={instancePath:t+"/channels/"+d+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),s++}}}else{let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),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 Ls.errors=r,s===0}function xf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ls(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),s=r.length),xf.errors=r,s===0}var Sf=Of;var ef={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 Ms(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 f=e.length;for(let m=0;m<f;m++){let b=e[m];if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.text!==void 0&&typeof b.text!="string"){let h={instancePath:t+"/"+m+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(b.textStyleId!==void 0&&typeof b.textStyleId!="string"){let h={instancePath:t+"/"+m+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(b.furigana!==void 0){let h=b.furigana;if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let y={instancePath:t+"/"+m+"/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(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let y={instancePath:t+"/"+m+"/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+"/"+m+"/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 h={instancePath:t+"/"+m,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),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 Ms.errors=r,s===0}function qs(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 w;if(e.id===void 0&&(w="id")){let g={};r===null?r=[g]:r.push(g),s++}}var d=p===s;if(u=u||d,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.type===void 0&&(E="type")){let k={};r===null?r=[k]:r.push(k),s++}}var d=w===s;if(u=u||d,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.resourceId===void 0&&(P="resourceId")){let v={};r===null?r=[v]:r.push(v),s++}}var d=E===s;if(u=u||d,!u){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let L={};r===null?r=[L]:r.push(L),s++}}var d=P===s;if(u=u||d,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.transformId===void 0&&($="transformId")){let D={};r===null?r=[D]:r.push(D),s++}}var d=O===s;if(u=u||d,!u){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.transform===void 0&&(U="transform")){let _={};r===null?r=[_]:r.push(_),s++}}var d=$===s;if(u=u||d,!u){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.x===void 0&&(G="x")){let ae={};r===null?r=[ae]:r.push(ae),s++}}var d=U===s;if(u=u||d,!u){let G=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 d=G===s;if(u=u||d,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let X={};r===null?r=[X]:r.push(X),s++}}var d=M===s;if(u=u||d,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.anchorY===void 0&&(Z="anchorY")){let ie={};r===null?r=[ie]:r.push(ie),s++}}var d=le===s;if(u=u||d,!u){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.scaleX===void 0&&(K="scaleX")){let pe={};r===null?r=[pe]:r.push(pe),s++}}var d=Z===s;if(u=u||d,!u){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let oe;if(e.scaleY===void 0&&(oe="scaleY")){let C={};r===null?r=[C]:r.push(C),s++}}var d=K===s;if(u=u||d,!u){let oe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.flipX===void 0&&(j="flipX")){let F={};r===null?r=[F]:r.push(F),s++}}var d=oe===s;if(u=u||d,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let W;if(e.flipY===void 0&&(W="flipY")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var d=j===s;if(u=u||d,!u){let W=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Se;if(e.rotation===void 0&&(Se="rotation")){let be={};r===null?r=[be]:r.push(be),s++}}var d=W===s;if(u=u||d,!u){let Se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let lr={};r===null?r=[lr]:r.push(lr),s++}}var d=Se===s;if(u=u||d,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Fe;if(e.originY===void 0&&(Fe="originY")){let wn={};r===null?r=[wn]:r.push(wn),s++}}var d=me===s;if(u=u||d,!u){let Fe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let At;if(e.layer===void 0&&(At="layer")){let Pt={};r===null?r=[Pt]:r.push(Pt),s++}}var d=Fe===s;if(u=u||d,!u){let At=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Et;if(e.alpha===void 0&&(Et="alpha")){let In={};r===null?r=[In]:r.push(In),s++}}var d=At===s;if(u=u||d,!u){let Et=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let xt;if(e.opacity===void 0&&(xt="opacity")){let vn={};r===null?r=[vn]:r.push(vn),s++}}var d=Et===s;if(u=u||d,!u){let xt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let St;if(e.blur===void 0&&(St="blur")){let kn={};r===null?r=[kn]:r.push(kn),s++}}var d=xt===s;if(u=u||d,!u){let St=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Zr;if(e.filters===void 0&&(Zr="filters")){let An={};r===null?r=[An]:r.push(An),s++}}var d=St===s;if(u=u||d,!u){let Zr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let xi;if(e.animations===void 0&&(xi="animations")){let Pn={};r===null?r=[Pn]:r.push(Pn),s++}}var d=Zr===s;u=u||d}}}}}}}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),s++}var f=l===s;if(f){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),s++}else s=o,r!==null&&(o?r.length=o:r=null);let m=s,b=!1,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[w]:r.push(w),s++}var y=h===s;if(b=b||y,!b){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let E={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[E]:r.push(E),s++}var y=w===s;b=b||y}if(b)s=m,r!==null&&(m?r.length=m:r=null);else{let w={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Ms(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}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 qs.errors=r,s===0}function Vs(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 Vs.errors=r,s===0}var QI={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 Fs(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(!Je.call(QI.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 Fs.errors=r,s===0}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)){for(let p in e)if(p!=="items"){let d={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let d=p.length;for(let f=0;f<d;f++){let m=p[f],b=s,h=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),s++}}var o=h===s;if(o){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=b,r!==null&&(b?r.length=b:r=null);let y=s,w=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var l=w===s;if(l){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=y,r!==null&&(y?r.length=y:r=null);let g=s,E=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.text===void 0&&(v="text")||m.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var c=E===s;if(c){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=g,r!==null&&(g?r.length=g:r=null);let k=s,P=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.transformId===void 0&&(v="transformId")||m.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),s++}}var u=P===s;if(u){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),s++}for(let v in m)if(!Je.call(ef.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),s++}if(m.id!==void 0&&typeof m.id!="string"){let v={instancePath:t+"/items/"+f+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let v={instancePath:t+"/items/"+f+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let v={instancePath:t+"/items/"+f+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let v={instancePath:t+"/items/"+f+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.text!==void 0&&(qs(m.text,{instancePath:t+"/items/"+f+"/text",parentData:m,parentDataProperty:"text",rootData:a})||(r=r===null?qs.errors:r.concat(qs.errors),s=r.length)),m.layout!==void 0&&(Vs(m.layout,{instancePath:t+"/items/"+f+"/layout",parentData:m,parentDataProperty:"layout",rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),s=r.length)),m.transformId!==void 0&&typeof m.transformId!="string"){let v={instancePath:t+"/items/"+f+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.transform!==void 0&&(Fs(m.transform,{instancePath:t+"/items/"+f+"/transform",parentData:m,parentDataProperty:"transform",rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),s=r.length)),m.x!==void 0&&typeof m.x!="number"){let v={instancePath:t+"/items/"+f+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.y!==void 0&&typeof m.y!="number"){let v={instancePath:t+"/items/"+f+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.anchorX!==void 0&&typeof m.anchorX!="number"){let v={instancePath:t+"/items/"+f+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.anchorY!==void 0&&typeof m.anchorY!="number"){let v={instancePath:t+"/items/"+f+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.scaleX!==void 0&&typeof m.scaleX!="number"){let v={instancePath:t+"/items/"+f+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.scaleY!==void 0&&typeof m.scaleY!="number"){let v={instancePath:t+"/items/"+f+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.flipX!==void 0&&typeof m.flipX!="boolean"){let v={instancePath:t+"/items/"+f+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(m.flipY!==void 0&&typeof m.flipY!="boolean"){let v={instancePath:t+"/items/"+f+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(m.rotation!==void 0&&typeof m.rotation!="number"){let v={instancePath:t+"/items/"+f+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.originX!==void 0&&typeof m.originX!="number"){let v={instancePath:t+"/items/"+f+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.originY!==void 0&&typeof m.originY!="number"){let v={instancePath:t+"/items/"+f+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.layer!==void 0){let v=m.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:ef.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),s++}}if(m.alpha!==void 0){let v=m.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(m.opacity!==void 0){let v=m.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}m.blur!==void 0&&(qe(m.blur,{instancePath:t+"/items/"+f+"/blur",parentData:m,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),m.filters!==void 0&&(nr(m.filters,{instancePath:t+"/items/"+f+"/filters",parentData:m,parentDataProperty:"filters",rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length)),m.animations!==void 0&&(ue(m.animations,{instancePath:t+"/items/"+f+"/animations",parentData:m,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.errors),s=r.length))}else{let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let d={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),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 Us.errors=r,s===0}function Of(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Us(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length),Of.errors=r,s===0}var Rf=$f;var ZI={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 Bs(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 g={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),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,d=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 w={};r===null?r=[w]:r.push(w),s++}}var f=d===s;if(f){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 m=s,b=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 w={};r===null?r=[w]:r.push(w),s++}}var h=b===s;if(h){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=m,r!==null&&(m?r.length=m: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 w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let g=0;g<w;g++)Me(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?Me.errors:r.concat(Me.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:ZI.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 Bs.errors=r,s===0}function $f(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Bs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),s=r.length),$f.errors=r,s===0}var Cf=_f;var ev={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 Ys(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 h={};r===null?r=[h]:r.push(h),s++}var u=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),u){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[w]:r.push(w),s++}var u=h===s;l=u}if(!l){let h={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let p=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let h={};r===null?r=[h]:r.push(h),s++}var m=f===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let h=s,y=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.target===void 0&&(E="target")){let k={};r===null?r=[k]:r.push(k),s++}}var b=w===s;if(b){let E={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[E]:r.push(E),s++}else s=y,r!==null&&(y?r.length=y:r=null);var m=h===s;d=m}if(!d){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[h]:r.push(h),s++}if(e.name===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[h]:r.push(h),s++}if(e.description===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[h]:r.push(h),s++}for(let h in e)if(!(h==="type"||h==="target"||h==="name"||h==="description"||h==="lockedName"||h==="lockedDescription"||h==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let h=e.type;if(typeof h!="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(!(h==="boolean"||h==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:ev.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 h=e.target;if(!(typeof h=="number"&&!(h%1)&&!isNaN(h))){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 h=="number"&&(h<1||isNaN(h))){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 h=e.name;if(typeof h=="string"){if($e(h)<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 h=e.description;if(typeof h=="string"){if($e(h)<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 h=e.lockedName;if(typeof h=="string"){if($e(h)<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 h=e.lockedDescription;if(typeof h=="string"){if($e(h)<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 h={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}return Ys.errors=r,s===0}function _f(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ys(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length),_f.errors=r,s===0}var jf=Nf;var rv={type:"object",required:["type"],$defs:{keyframe:{type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},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"]},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{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"},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/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},alpha:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/tweenProperty"},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:{$ref:"#/$defs/mask"}},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"};var tv={type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},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"]},relative:{type:"boolean"}},additionalProperties:!1};function Wr(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==="value"||o==="duration"||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.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.easing!==void 0){let o=e.easing;if(typeof o!="string"){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(o==="linear"||o==="easeInQuad"||o==="easeOutQuad"||o==="easeInOutQuad"||o==="easeInCubic"||o==="easeOutCubic"||o==="easeInOutCubic"||o==="easeInQuart"||o==="easeOutQuart"||o==="easeInOutQuart"||o==="easeInQuint"||o==="easeOutQuint"||o==="easeInOutQuint"||o==="easeInSine"||o==="easeOutSine"||o==="easeInOutSine"||o==="easeInExpo"||o==="easeOutExpo"||o==="easeInOutExpo"||o==="easeInCirc"||o==="easeOutCirc"||o==="easeInOutCirc"||o==="easeInBack"||o==="easeOutBack"||o==="easeInOutBack"||o==="easeInBounce"||o==="easeOutBounce"||o==="easeInOutBounce"||o==="easeInElastic"||o==="easeOutElastic"||o==="easeInOutElastic")){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:tv.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(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 Wr.errors=r,s===0}function re(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++)Wr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Wr.errors:r.concat(Wr.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 re.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)){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==="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&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.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 Xs(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&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.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 Xs.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.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&&(Xs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",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 Hr.errors=r,s===0}var ks={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"]}}]},nv={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};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.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:nv.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 Gs.errors=r,s===0}function Hs(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++)Wr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Wr.errors:r.concat(Wr.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 Hs.errors=r,s===0}function Ks(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 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.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=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,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let g={};r===null?r=[g]:r.push(g),s++}var m=f===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let g=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 m=g===s;d=m}if(!d){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 b=s,h=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let g={};r===null?r=[g]:r.push(g),s++}var w=y===s;if(s=b,r!==null&&(b?r.length=b:r=null),w){let g=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 w=g===s;h=w}if(!h){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++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!Je.call(ks.properties,g)){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.kind!==void 0){let g=e.kind;if(typeof g!="string"){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="single"||g==="sequence"||g==="composite")){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:ks.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let g={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.textures!==void 0){let g=e.textures;if(Array.isArray(g)){if(g.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 E=g.length;for(let k=0;k<E;k++)if(typeof g[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 E={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.items!==void 0){let g=e.items;if(Array.isArray(g)){if(g.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 E=g.length;for(let k=0;k<E;k++)Gs(g[k],{instancePath:t+"/items/"+k,parentData:g,parentDataProperty:k,rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),s=r.length)}else{let E={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.combine!==void 0){let g=e.combine;if(typeof g!="string"){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="max"||g==="min"||g==="multiply"||g==="add")){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:ks.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.channel!==void 0){let g=e.channel;if(typeof g!="string"){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="red"||g==="green"||g==="blue"||g==="alpha")){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:ks.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let g={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let g={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let g={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}e.progress!==void 0&&(Hs(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length))}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 Ks.errors=r,s===0}function Ws(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 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,E=s,k=s,P=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=$===s;if(v=v||p,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let ae={};r===null?r=[ae]:r.push(ae),s++}}var p=U===s;v=v||p}}if(v)s=P,r!==null&&(P?r.length=P:r=null);else{let $={};r===null?r=[$]:r.push($),s++}var d=k===s;if(d){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),s++}else s=E,r!==null&&(E?r.length=E: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=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 f=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var h=b===s;if(s=f,r!==null&&(f?r.length=f:r=null),h){let g=s,E=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===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=E,r!==null&&(E?r.length=E:r=null);let P=s,v=!1,O=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 w=O===s;if(v=v||w,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=$===s;if(v=v||w,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[G]:r.push(G),s++}var w=U===s;v=v||w}}if(v)s=P,r!==null&&(P?r.length=P: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 h=g===s;m=h}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++}for(let g in e)if(!(g==="name"||g==="type"||g==="complete"||g==="tween"||g==="prev"||g==="next"||g==="mask")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let E={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="update"||g==="transition")){let E={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:rv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.complete!==void 0){let g=e.complete;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.payload!==void 0){let E=g.payload;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let k={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}}else{let E={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}e.tween!==void 0&&(zs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),s=r.length)),e.prev!==void 0&&(Hr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Hr.errors:r.concat(Hr.errors),s=r.length)),e.next!==void 0&&(Hr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Hr.errors:r.concat(Hr.errors),s=r.length)),e.mask!==void 0&&(Ks(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),s=r.length))}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 Ws.errors=r,s===0}function Nf(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),Nf.errors=r,s===0}var Df=Tf;var sv={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"]},fade:{type:"object",required:["duration"],properties:{delay:{type:"number",minimum:0},duration:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"}},additionalProperties:!1},transitionSide:{type:"object",minProperties:1,properties:{fade:{$ref:"#/$defs/fade"}},additionalProperties:!1},keyframeValue:{oneOf:[{type:"number"},{const:"target"}]},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:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},updateTween:{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/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"}},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 Js(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=null,u=s;if(typeof e!="number"){let f={instancePath:t,schemaPath:"#/oneOf/0/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}var d=u===s;d&&(l=!0,c=0);let p=s;if(e!=="target"){let f={instancePath:t,schemaPath:"#/oneOf/1/const",keyword:"const",params:{allowedValue:"target"},message:"must be equal to constant"};r===null?r=[f]:r.push(f),s++}var d=p===s;if(d&&l?(l=!1,c=[c,1]):d&&(l=!0,c=1),l)s=o,r!==null&&(o?r.length=o:r=null);else{let f={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),s++}return Js.errors=r,s===0}var iv={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 Jr(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:iv.enum},message:"must be equal to one of the allowed values"};r===null?r=[o]:r.push(o),s++}return Jr.errors=r,s===0}function sr(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&&(Js(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?Js.errors:r.concat(Js.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&&(Jr(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?Jr.errors:r.concat(Jr.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 sr.errors=r,s===0}function Qs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;sr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?sr.errors:r.concat(sr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),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 h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>100||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>100||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var b=h===s;f=b}if(!f){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}return Qs.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)){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!=="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.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++)Qs(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.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 Zs.errors=r,s===0}function ei(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;sr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?sr.errors:r.concat(sr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),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 h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>1||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>1||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var b=h===s;f=b}if(!f){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}return ei.errors=r,s===0}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.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!=="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.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++)ei(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?ei.errors:r.concat(ei.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 ri.errors=r,s===0}function ti(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;sr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?sr.errors:r.concat(sr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),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 h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"&&(w<0||isNaN(w))){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"&&(w<0||isNaN(w))){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var b=h===s;f=b}if(!f){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}return ti.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.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!=="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.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++)ti(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?ti.errors:r.concat(ti.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 ni.errors=r,s===0}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(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&&(Zs(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),s=r.length)),e.pan!==void 0&&(ri(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),s=r.length)),e.playbackRate!==void 0&&(ni(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?ni.errors:r.concat(ni.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 si.errors=r,s===0}function ii(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.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==="delay"||o==="duration"||o==="easing")){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.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.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++}}e.easing!==void 0&&(Jr(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?Jr.errors:r.concat(Jr.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 ii.errors=r,s===0}function Kr(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!=="fade"){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.fade!==void 0&&(ii(e.fade,{instancePath:t+"/fade",parentData:e,parentDataProperty:"fade",rootData:a})||(r=r===null?ii.errors:r.concat(ii.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 Kr.errors=r,s===0}function oi(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 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,E=s,k=s,P=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=$===s;v=v||p}if(v)s=P,r!==null&&(P?r.length=P:r=null);else{let $={};r===null?r=[$]:r.push($),s++}var d=k===s;if(d){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),s++}else s=E,r!==null&&(E?r.length=E: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=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 f=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var h=b===s;if(s=f,r!==null&&(f?r.length=f:r=null),h){let g=s,E=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===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=E,r!==null&&(E?r.length=E:r=null);let P=s,v=!1,O=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 w=O===s;if(v=v||w,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=$===s;v=v||w}if(v)s=P,r!==null&&(P?r.length=P: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 h=g===s;m=h}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++}for(let g in e)if(!(g==="name"||g==="type"||g==="tween"||g==="prev"||g==="next")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(!(g==="update"||g==="transition")){let E={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:sv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}e.tween!==void 0&&(si(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),s=r.length)),e.prev!==void 0&&(Kr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Kr.errors:r.concat(Kr.errors),s=r.length)),e.next!==void 0&&(Kr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Kr.errors:r.concat(Kr.errors),s=r.length))}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 oi.errors=r,s===0}function Tf(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),Tf.errors=r,s===0}var Lf=Mf;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)){for(let o in e)if(!(o==="name"||o==="nameVariableId")){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++}}}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 Mf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ai(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),s=r.length),Mf.errors=r,s===0}var qf=Vf;var ov=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");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.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(!ov.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 li.errors=r,s===0}function Vf(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),Vf.errors=r,s===0}var Ff=Uf;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(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 d={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=[d]:r.push(d),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 d={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=[d]:r.push(d),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 ci.errors=r,s===0}function Uf(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),Uf.errors=r,s===0}var Bf=Yf;function ui(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 ui.errors=r,s===0}function Yf(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),Yf.errors=r,s===0}var zf=Xf;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(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 pi.errors=r,s===0}function Xf(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),Xf.errors=r,s===0}var Gf=Hf;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(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 fi.errors=r,s===0}var rf=new RegExp("^\\$(if .+|for .+|else)$","u"),ja={validate:cn};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(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(!rf.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(rf.test(o)){let l=e[o];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)ja.validate(l[u],{instancePath:t+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?ja.validate.errors:r.concat(ja.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 di.errors=r,s===0}function cn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=s;fi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),s=r.length);var u=c===s;if(l=l||u,!l){let p=s;di(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?di.errors:r.concat(di.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 cn.errors=r,s===0}function mi(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++)cn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?cn.errors:r.concat(cn.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 mi.errors=r,s===0}var Na={validate:un};function un(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&&(mi(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?mi.errors:r.concat(mi.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++)Na.validate(o[c],{instancePath:t+"/children/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Na.validate.errors:r.concat(Na.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 un.errors=r,s===0}function yi(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=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++)un(o[c],{instancePath:t+"/elements/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?un.errors:r.concat(un.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 yi.errors=r,s===0}function Hf(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),Hf.errors=r,s===0}var Kf=Wf;function hi(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,d=s,f=s,m=!1,b=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 h=b===s;if(m=m||h,!m){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.texture===void 0&&(v="texture")){let O={};r===null?r=[O]:r.push(O),s++}}var h=k===s;if(m=m||h,!m){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.behaviors===void 0&&(L="behaviors")){let $={};r===null?r=[$]:r.push($),s++}}var h=v===s;if(m=m||h,!m){let L=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.emitter===void 0&&(D="emitter")){let U={};r===null?r=[U]:r.push(U),s++}}var h=L===s;m=m||h}}}if(m)s=f,r!==null&&(f?r.length=f:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=d===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 g=u===s;g&&(l=!0,c=0);let w=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 g=w===s;if(g&&l?(l=!1,c=[c,1]):g&&(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 v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),s++}if(k.emission!==void 0){let P=k.emission;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.movement!==void 0){let P=k.movement;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.appearance!==void 0){let P=k.appearance;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.bounds!==void 0){let P=k.bounds;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),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,v=!1,O=null,L=s;if(typeof k=="string"){if($e(k)<1){let D={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=[D]:r.push(D),s++}}else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[D]:r.push(D),s++}var E=L===s;E&&(v=!0,O=0);let $=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[D]:r.push(D),s++}var E=$===s;if(E&&v?(v=!1,O=[O,1]):E&&(v=!0,O=1),v)s=P,r!==null&&(P?r.length=P:r=null);else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[D]:r.push(D),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let v={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let P=k.length;for(let v=0;v<P;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[L]:r.push(L),s++}for(let L in O)if(!(L==="type"||L==="config")){let $={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:L},message:"must NOT have additional properties"};r===null?r=[$]:r.push($),s++}if(O.type!==void 0){let L=O.type;if(typeof L=="string"){if($e(L)<1){let $={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[$]:r.push($),s++}}else{let $={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[$]:r.push($),s++}}if(O.config!==void 0){let L=O.config;if(!(L&&typeof L=="object"&&!Array.isArray(L))){let $={instancePath:t+"/behaviors/"+v+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[$]:r.push($),s++}}}else{let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[L]:r.push(L),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 v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),s++}if(P.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),s++}if(P.min!==void 0){let v=P.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={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=[O]:r.push(O),s++}}else{let O={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=[O]:r.push(O),s++}}if(P.max!==void 0){let v=P.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={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=[O]:r.push(O),s++}}else{let O={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=[O]:r.push(O),s++}}}else{let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),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 hi.errors=r,s===0}function Wf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return hi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),s=r.length),Wf.errors=r,s===0}var Jf=Qf;var tf={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 gi(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(!Je.call(tf.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:tf.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 gi.errors=r,s===0}function Qf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return gi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),s=r.length),Qf.errors=r,s===0}var Zf=ed;var av=new RegExp("^.+$","u");function bi(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.jsonData===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};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==="jsonData"||o==="width"||o==="height"||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.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.jsonData!==void 0){let o=e.jsonData;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),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++}}if(e.animations!==void 0){let o=e.animations;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)if(av.test(l)){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="loop")){let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++)if(typeof u[d]!="number"){let f={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}else{let p={instancePath:t+"/animations/"+l.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=[p]:r.push(p),s++}}if(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}}else{let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}}}else{let l={instancePath:t+"/animations",schemaPath:"#/properties/animations/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 bi.errors=r,s===0}function ed(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return bi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),s=r.length),ed.errors=r,s===0}var rd=td;var nf={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"},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 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.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(!Je.call(nf.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,d=s;if(typeof l=="string"){if($e(l)<1){let m={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=[m]:r.push(m),s++}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[m]:r.push(m),s++}var o=d===s;o&&(u=!0,p=0);let f=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 m=l.length;for(let y=0;y<m;y++){let w=l[y];if(typeof w=="string"){if($e(w)<1){let g={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=[g]:r.push(g),s++}}else{let g={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}}let b=l.length,h;if(b>1){let y={};for(;b--;){let w=l[b];if(typeof w=="string"){if(typeof y[w]=="number"){h=y[w];let g={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:b,j:h},message:"must NOT have duplicate items (items ## "+h+" and "+b+" are identical)"};r===null?r=[g]:r.push(g),s++;break}y[w]=b}}}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}var o=f===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 m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[m]:r.push(m),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&&typeof e.fontWeight!="string"){let l={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),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:nf.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 wi.errors=r,s===0}function td(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return wi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),s=r.length),td.errors=r,s===0}var nd=sd;var lv={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 Ii(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(!Je.call(lv.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 Ii.errors=r,s===0}function sd(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ii(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),s=r.length),sd.errors=r,s===0}var id=od;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 od(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),od.errors=r,s===0}var dn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),fn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),gr=e=>e===void 0?void 0:structuredClone(e),cv=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"}),uv=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),pv=Object.freeze({background:sf,bgm:af,character:cf,choice:pf,cleanAll:df,control:yf,dialogue:gf,form:wf,layout:vf,screen:Af,sfx:Ef,visual:Sf,voice:Rf}),fv=Object.freeze({achievement:Cf,animation:jf,audioEffect:Df,character:Lf,color:qf,control:Ff,font:Bf,image:zf,layout:Gf,particle:Kf,sound:Jf,spritesheet:Zf,textStyle:rd,transform:nd,video:id}),dv=new Set(["files","language","patches"]),mv=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),yv=new Set(["lineId","mode","payload","type"]),hv=new Set(["mode","payload","sceneId","type"]),gv=new Set(["mode","operation","payload","resourceId","type"]),bv=new Set(["fileId","mimeType"]),H=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},Qe=(e,t)=>{fn(e)||H(t,"expected an object")},Da=(e,t)=>{Array.isArray(e)||H(t,"expected an array")},vt=(e,t)=>{(typeof e!="string"||e.length===0)&&H(t,"expected a non-empty string")},ud=(e,t)=>{typeof e!="string"&&H(t,"expected a string")},or=(e,t,n)=>{for(let i of Object.keys(e))t.has(i)||H(`${n}.${i}`,"unknown field")},ar=(e,t,n)=>{for(let i of t)dn(e,i)||H(n,`missing required field "${i}"`)},wv=e=>e.replaceAll("~1","/").replaceAll("~0","~"),Iv=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(wv);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)},vv=(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],pd=({value:e,validator:t,path:n,contract:i})=>{if(t(e))return;let a=vv(t.errors);H(Iv(n,a),`does not match ${i}: ${a?.message??"schema validation failed"}`)},ki=(e,t,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||H(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)=>ki(i,`${t}[${a}]`,n));return}Object.entries(e).forEach(([i,a])=>ki(a,`${t}.${i}`,n))}},ir=(e,t)=>{e===""&&H(t,"expected a non-empty resourceId")},kv=(e,t,n)=>{let i=(s,o)=>ir(s?.resourceId,`${o}.resourceId`),a=(s,o)=>(s??[]).forEach((l,c)=>ir(l?.resourceId,`${o}[${c}].resourceId`)),r=(s,o)=>{ir(s?.resourceId,`${o}.resourceId`),a(s?.sounds,`${o}.sounds`)};switch(e){case"background":ir(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)=>ir(l?.resourceId,`${n}.items[${o}].sprites[${c}].resourceId`)),i(s.animations,`${n}.items[${o}].animations`)});break;case"choice":case"form":case"layout":ir(t.resourceId,`${n}.resourceId`),i(t.animations,`${n}.animations`);break;case"control":ir(t.resourceId,`${n}.resourceId`);break;case"dialogue":ir(t.ui?.resourceId,`${n}.ui.resourceId`),i(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,o)=>ir(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)=>{ir(s?.resourceId,`${n}.items[${o}].resourceId`),i(s?.animations,`${n}.items[${o}].animations`)});break;default:break}},kt=(e,t)=>{vt(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&H(t,`"${e}" is not a safe ID`)},Av=(e,t)=>{vt(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&H(t,"must be a safe single filename")},pn=(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)=>pn(a,t[r]));if(!fn(e)||!fn(t))return!1;let n=Object.keys(e).sort(),i=Object.keys(t).sort();return pn(n,i)&&n.every(a=>pn(e[a],t[a]))},Ai=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(i=>Ai(i,t,n)),t;if(!fn(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),Ai(a,t,n);return t},Pv=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},fd=(e,t,n)=>{let i=e.get(t)??[];return i.length===0&&H(n,`lineId "${t}" does not exist in projectData`),i.length>1&&H(n,`lineId "${t}" is not globally unique in projectData`),i[0]},dd=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],ad=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),ld=e=>{let t=gr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))fn(n)&&delete n.placeholder;return t},Ev=(e,t,n,i)=>{e==="choice"&&!pn(ad(t),ad(n))&&H(i,"choice item IDs and events must remain identical to the source action"),e==="form"&&!pn(ld(t),ld(n))&&H(i,"form behavior must remain identical; only presentation fields and placeholders may change")},xv=({patch:e,path:t,lineIndex:n})=>{or(e,mv,t),ar(e,["type","lineId","actionType","payload"],t),kt(e.lineId,`${t}.lineId`),vt(e.actionType,`${t}.actionType`),Qe(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.action supports only "replace"'),uv.has(e.actionType)||H(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let i=fd(n,e.lineId,`${t}.lineId`),a=i.line?.actions?.[e.actionType];return a===void 0&&H(`${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")&&H(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),dn(e.payload,"content")&&H(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&H(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),Ev(e.actionType,a,e.payload,`${t}.payload`),pd({value:e.payload,validator:pv[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),ki(e.payload,`${t}.payload`),kv(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:i,patch:e}},Sv=(e,t)=>{Da(e,t),e.forEach((n,i)=>{Qe(n,`${t}[${i}]`),or(n,new Set(["text"]),`${t}[${i}]`),ar(n,["text"],`${t}[${i}]`),ud(n.text,`${t}[${i}].text`)})},Ov=({patch:e,path:t,lineIndex:n})=>{or(e,yv,t),ar(e,["type","lineId","payload"],t),kt(e.lineId,`${t}.lineId`),Qe(e.payload,`${t}.payload`),or(e.payload,new Set(["content"]),`${t}.payload`),ar(e.payload,["content"],`${t}.payload`),Sv(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.dialogue supports only "replace"');let i=fd(n,e.lineId,`${t}.lineId`);return i.line?.actions?.dialogue===void 0&&H(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:i,patch:e}},Rv=({patch:e,path:t,projectData:n})=>(or(e,hv,t),ar(e,["type","mode","sceneId","payload"],t),kt(e.sceneId,`${t}.sceneId`),Qe(e.payload,`${t}.payload`),or(e.payload,new Set(["name"]),`${t}.payload`),ar(e.payload,["name"],`${t}.payload`),ud(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&H(`${t}.mode`,'story.scene requires "patch"'),dn(n?.story?.scenes??{},e.sceneId)||H(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),$v=(e,t,n)=>{Qe(t,n),["font","image","sound","spritesheet","video"].includes(e)&&vt(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="spritesheet"&&(Qe(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&H(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),pd({value:t,validator:fv[e],path:n,contract:`the resource.${e} schema`}),ki(t,n)},Cv=({patch:e,path:t,projectData:n,packageFileIds:i,canonicalFileIds:a})=>{or(e,gv,t),ar(e,["type","resourceId","payload"],t),kt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=cv[r];s||H(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&H(`${t}.operation`,'the only resource operation is "add"'),$v(r,e.payload,`${t}.payload`);let o=n?.resources?.[s]??{},l=dn(o,e.resourceId);e.operation==="add"&&l&&H(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&H(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of Ai(e.payload))!i.has(c)&&!a.has(c)&&H(`${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}},cd=({resources:e,collectionName:t,resourceId:n,path:i,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!dn(e?.[t]??{},n))&&H(i,`${a} resource "${n}" was not found`)},_v=(e,t)=>{let n=gr(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=gr(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)=>cd({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]])cd({resources:i,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${o}`,label:"color"})}},jv=({patch:e,path:t,projectData:n,lineIndex:i,packageFileIds:a,canonicalFileIds:r})=>{if(Qe(e,t),vt(e.type,`${t}.type`),e.type==="line.action")return xv({patch:e,path:t,lineIndex:i});if(e.type==="line.dialogue")return Ov({patch:e,path:t,lineIndex:i});if(e.type==="story.scene")return Rv({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return Cv({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});H(`${t}.type`,`unsupported patch type "${e.type}"`)},Nv=(e,t)=>{Da(e,t);let n=new Set;return e.forEach((i,a)=>{let r=`${t}[${a}]`;Qe(i,r),or(i,bv,r),ar(i,["fileId"],r),Av(i.fileId,`${r}.fileId`),i.mimeType!==void 0&&(typeof i.mimeType!="string"||i.mimeType.length===0)&&H(`${r}.mimeType`,"expected a non-empty string"),n.has(i.fileId)&&H(`${r}.fileId`,`duplicate fileId "${i.fileId}"`),n.add(i.fileId)}),n},Dv=({packageId:e,packageData:t,path:n,projectData:i,lineIndex:a,canonicalFileIds:r})=>{Qe(t,n),or(t,dv,n),ar(t,["language","files","patches"],n),vt(t.language,`${n}.language`);let s=Nv(t.files,`${n}.files`);Da(t.patches,`${n}.patches`);let o=new Set,l=t.patches.map((c,u)=>{let p=jv({patch:c,path:`${n}.patches[${u}]`,projectData:i,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return o.has(p.key)&&H(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),o.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},md=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};Qe(t,"l10nData"),or(t,new Set(["packages"]),"l10nData"),ar(t,["packages"],"l10nData"),Qe(t.packages,"l10nData.packages");let n=Pv(e),i=Ai(e?.resources??{}),a=new Map,r=new Map;for(let[s,o]of Object.entries(t.packages)){kt(s,`l10nData.packages.${s}`);let l=Dv({packageId:s,packageData:o,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:i});for(let c of l.fileIds){i.has(c)&&H(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&H(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}_v(e,l),a.set(s,l)}return{packages:a}},Tv=(e,t)=>{let{collectionName:n,patch:i}=t;e.resources[n]??={},e.resources[n][i.resourceId]=gr(i.payload)},Lv=(e,t)=>{let{patch:n}=t,i=e.story.scenes[n.sceneId];i.name=n.payload.name},Mv=(e,t)=>{let{location:n,patch:i}=t,a=dd(e,n);if(i.actionType!=="dialogue"){a.actions[i.actionType]=gr(i.payload);return}let r=gr(n.line.actions.dialogue.content);a.actions.dialogue=gr(i.payload),r!==void 0&&(a.actions.dialogue.content=r)},qv=(e,t)=>{let{location:n,patch:i}=t,a=dd(e,n);a.actions.dialogue.content=gr(i.payload.content)},yd=({projectData:e,l10nData:t})=>{let n=md({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),i=>({l10nId:i.id,language:i.data.language}))]},Pi=({projectData:e,l10nData:t,l10nId:n=null})=>{let i=md({projectData:e,l10nData:t});if(n!==null&&(kt(n,"l10nId"),i.packages.has(n)||H("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=gr(e),r=i.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>Tv(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>Lv(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>Mv(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>qv(a,s)),a};var Ta=Object.freeze({auto:1e3,skip:80,authored:1e3}),hn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),hd=new WeakMap,Vv=new ArrayBuffer(8),La=new DataView(Vv),Fv=e=>{let t=hd.get(e);if(t)return t;let n={dispatchDepth:0};return hd.set(e,n),n},Uv=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Bv=(e,t)=>Object.keys(e).length===t.length&&t.every(i=>Object.prototype.hasOwnProperty.call(e,i)),jr=(e,t,n)=>{if(!Uv(e)||!Bv(e,t))throw new TypeError(`${n} has an invalid shape`)},mn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},yn=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},gd=e=>{if(yn(e,"duration"),e===0)return 0n;La.setFloat64(0,e,!1);let t=La.getUint32(0,!1),n=La.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)},Yv=e=>structuredClone(e),Ma=(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,qa=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(jr(t,["owner","delayMs","contentKey"],"auto timer"),jr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),mn(t.owner.sessionId,"auto owner sessionId"),mn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(yn(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")jr(t,["owner","delayMs"],"skip timer"),jr(t.owner,["sessionId"],"skip timer owner"),mn(t.owner.sessionId,"skip owner sessionId"),yn(t.delayMs,"skip delayMs");else{if(jr(t,["owner","delayMs","trigger"],"authored timer"),jr(t.owner,["lineEntryId"],"authored timer owner"),mn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(yn(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,...Yv(t)}},zv=e=>{if(jr(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(mn(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}}jr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:qa("auto",e.timers.auto,e.lineEntryId),skip:qa("skip",e.timers.skip,e.lineEntryId),authored:qa("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}},Va=e=>({descriptor:e,remainingQuanta:gd(e.delayMs)}),Ei=["auto","skip","authored"],bd=({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=Fv(e),a=!0,r={},s={},o=null,l=null,c=null,u=null,p=!1,d=!1,f="legacy",m={auto:null,skip:null,authored:null},b={auto:null,skip:null,authored:null},h={auto:0,skip:0,authored:0},y=()=>Ei.some(M=>m[M]),w=()=>{l=null,c=null},g=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(i.dispatchDepth>0||d){g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&o===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},E=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=o;M&&(w(),o=null,u=M,e.remove(M),u===M&&(u=null))},P=()=>{m={auto:null,skip:null,authored:null}},v=()=>{P(),s={},d||k()},O=M=>{if(i.dispatchDepth>0||d){c=M,g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&o===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},L=()=>{if(!a||!y()||o)return;E();let M=r,Q=s,le={},X=ie=>{if(!a||M!==r||Q!==s||le!==l||X!==o||d)return;if(!ie||typeof ie.deltaMS!="number"||!Number.isFinite(ie.deltaMS)||ie.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let K=gd(ie.deltaMS);d=!0,i.dispatchDepth+=1;let pe=s,oe=null;try{let C=[];for(let j of Ei){let F=m[j];F&&(F.remainingQuanta<=K?(C.push({kind:j,descriptor:F.descriptor,revision:h[j]}),m[j]=null):F.remainingQuanta-=K)}if(C.length>0){try{t({dueKinds:C.map(({kind:j})=>j)})}catch(j){let F=n(j);if(f==="reconciled"&&F==="preCommit")for(let{kind:W,descriptor:fe}of C)b[W]=fe;else f==="legacy"&&P();throw j}if(f==="legacy")for(let j of C)j.kind==="skip"&&h.skip===j.revision&&m.skip===null&&(m.skip=Va(j.descriptor))}}catch(C){oe=C}finally{i.dispatchDepth-=1,d=!1;try{pe===s?y()?L():k():o===X&&!y()&&k()}catch(C){throw oe?new AggregateError([oe,C],"Playback attempt and ticker cleanup both failed"):C}}if(oe)throw oe},Z={callback:X,lifecycleToken:M,generationToken:Q,registrationToken:le};o=X,c=Z;try{e.add(X)}catch(ie){throw o=null,w(),P(),s={},u=X,ie}O(Z)},$=M=>{h[M]+=1,m[M]=null,b[M]=null,!y()&&!d&&k()},D=(M,Q)=>{yn(Q,`${M} delay`),f="legacy",h[M]+=1,b[M]=null,m[M]=Va({mode:"legacy",kind:M,instanceToken:{},delayMs:Q}),L()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return D("auto",M.payload?.delay??Ta.auto),!0;case"clearAutoNextTimer":return $("auto"),!0;case"startSkipNextTimer":return D("skip",M.payload?.delay??Ta.skip),!0;case"clearSkipNextTimer":return $("skip"),!0;case"nextLineConfigTimer":return D("authored",M.payload?.delay??Ta.authored),!0;case"clearNextLineConfigTimer":return $("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let Q;try{Q=zv(M)}catch(X){try{v()}catch(Z){throw new AggregateError([X,Z],"Playback schedule validation and cleanup both failed")}throw X}if(f="reconciled",Q.status==="unsettled"){P(),d||k();return}let le={};for(let X of Ei){let Z=Q.timers[X],ie=b[X];if(ie&&(!Z||!Ma(ie,Z))&&(b[X]=null),Z&&b[X]&&Ma(b[X],Z)){le[X]=null;continue}let K=m[X];le[X]=Z&&K&&Ma(K.descriptor,Z)?K:Z?Va(Z):null}m=le,y()?L():d||k()},reset:()=>{let M=[o,u].filter((X,Z,ie)=>X&&ie.indexOf(X)===Z);r={},s={},w(),o=null,u=null,P(),b={auto:null,skip:null,authored:null};for(let X of Ei)h[X]+=1;f="legacy",a=!0;let Q=null,le=null;for(let X of M)try{e.remove(X)}catch(Z){Q??=Z,le??=X}if(u=le,Q)throw Q},dispose:()=>{a=!1,r={},s={},w(),P(),b={auto:null,skip:null,authored:null};let M=[o,u].filter((X,Z,ie)=>X&&ie.indexOf(X)===Z);o=null,u=null;let Q=null,le=null;for(let X of M)try{e.remove(X)}catch(Z){Q??=Z,le??=X}if(u=le,Q)throw Q}}};var Xv=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),Gv=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Fa="conditional",gn="random",Ba=Symbol("conditionalAutoContinue"),Hv=new Set(["sectionTransition","resetStoryAtSection"]),Kv=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),Wv=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Jv=new Set(["nextLine","nextLineFromSystem"]),Qv=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Ua="form",Zv=new Set(["submitForm","cancelForm"]),ek="showImageGalleryVariant",rk="playMusicRoomTrack",tk="startSceneReplay",nk="channel:bgm",sk=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"]),Ve=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ik=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,bn=e=>e?.type===Ba,Qr=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,ok=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(i=>!Object.is(e?.[i],t?.[i]));function Ya(e){let t=ik(),n,i=0,a=!1,r=0,s=null,o=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,b=new Map,h=0,y=null,w=[],g=!1,E=null,k=null,P=new Map,v,O,L=null,$=!1,D=!1,U=0,_=new Map,G=Zl(e.randomSource),{handlePendingEffects:ae}=e;if(typeof ae!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let M=ae.bind(ae),Q=typeof ae.reconcilePlaybackScheduleV1=="function"?ae.reconcilePlaybackScheduleV1.bind(ae):null,le=typeof ae.reset=="function"?ae.reset.bind(ae):null,X=typeof ae.dispose=="function"?ae.dispose.bind(ae):null;if(Q&&(!le||!X))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let Z=I=>{if(D)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ie=I=>{if(Z(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},K=(I,A)=>{if(U===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=_.get(I);(R===void 0||S[A]>S[R])&&_.set(I,A)},pe=I=>{let A=_.get(I)??"preCommit";return _.delete(I),A},oe=I=>{if(Q){D=!0;try{let A=Q(structuredClone(I));if(A!==null&&(typeof A=="object"||typeof A=="function")&&typeof A.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{D=!1}}},C=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),j=I=>{if(!(!Q||!a||!n)){$=!0;try{oe(C())}catch(A){if(I){let S=new AggregateError([I,A],"Playback work and schedule invalidation both failed");throw _.delete(I),K(S,"reconcileFailed"),S}throw K(A,"reconcileFailed"),A}}},F=()=>{if(!Q||!$||!a||!n||o>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(A){throw K(A,"reconcileFailed"),j(A),A}try{oe({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(A){throw K(A,"reconcileFailed"),j(A),A}$=!1},W=(I=new Map,A=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>A<S.expiresAt).map(([S,R])=>[S,{animation:structuredClone(R.animation),startedAt:R.startedAt,expiresAt:R.expiresAt}])),fe=(I=new Map)=>Array.from(I.values()).map(A=>structuredClone(A.animation)),Se=(I=Date.now())=>{f=new Map(Array.from(f.entries()).filter(([,A])=>I<A.expiresAt))},be=()=>{if(a&&!(o>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let I=n.selectCurrentPointer()?.pointer??null,A=[...n.selectPendingEffects()],S=A.map(R=>R.name!=="handleLineActions"?R:{...R,payload:{...R.payload,pointer:structuredClone(I)}});n.clearPendingEffects();try{let R=Q?S.filter(N=>!hn.has(N.name)):S;R.length>0&&M(R)}catch(R){throw n.clearPendingEffects(),A.forEach(N=>{n.appendPendingEffect(N)}),K(R,"postCommitUnsettled"),j(R),R}}}finally{l=!1}F()}},me=I=>{o+=1;let A=!1;try{let S=I();return A=!0,S}finally{o-=1,A&&be()}},lr=()=>{let I=n.selectSystemState();return Fo({presentationState:n.selectPresentationState(),resources:I.projectData?.resources,runtime:n.selectRuntime(),musicRoomPlayer:I.global?.musicRoomPlayer})},Fe=()=>structuredClone(g?E:lr()),wn=I=>{let A=n.selectSystemState().projectData?.story?.scenes??{};return Object.entries(A).find(([,S])=>S?.sections?.[I])?.[0]},At=()=>{if(w.length===0)return;let I=n.selectRuntime()?.skipTransitionsAndAnimations===!0,A=I?null:y?.id;w.forEach(S=>{S.status=S.effect?.id===A?"active":"settled"}),I&&(y=null),w=[]},Pt=(I,A,S,R)=>{I?.audioEffects||(y=null);let N=n.selectPlaybackLineEntryId?.()??0,Y=(A.actionPath??["bgm"]).join("."),B=n.selectCurrentPointer()?.pointer,te=B?.sceneId??wn(B?.sectionId),de=A.rollbackSource==="line"&&B?`story.scenes[${JSON.stringify(te)}].sections[${JSON.stringify(B.sectionId)}].lines[${JSON.stringify(B.lineId)}].actions.${Y}`:Y,ye=A.rollbackSource==="line"?`${i}:${N}:${de}`:null,we=ye?P.get(ye):null;if(we)return we;h+=1;let ge={occurrenceId:`${t}:g${i}:l${N}:audio${h}`,actionPath:de,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Ne=n.selectSystemState().projectData?.resources,De=Gp({occurrence:ge,resources:Ne,previousChannel:S,nextChannel:R});if(ge.effect=De?structuredClone(De):null,ge.status=De?"pending":"settled",y=De?structuredClone(De):null,w.push(ge),ye)for(P.set(ye,ge);P.size>512;){let rt=P.keys().next().value;P.delete(rt)}return ge},Et=({initialState:I,namespace:A})=>{Z("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...N}=I,Y=R===void 0?void 0:structuredClone(R),B=structuredClone(I.projectData),te=yd({projectData:B,l10nData:Y}),de=N.global??{};if(!Ve(de))throw new Error("Malformed global state.");let ye=de.runtime??{};if(!Ve(ye))throw new Error("Malformed global.runtime.");let we=ye.localizationPackageId;if(we!=null&&typeof we!="string")throw new Error("localizationPackageId requires a string or null value");let ge=new Set(te.map(({l10nId:tt})=>tt).filter(tt=>tt!==null)),Ne=typeof we=="string"&&ge.has(we)?we:null,De=Pi({projectData:B,l10nData:Y,l10nId:Ne}),rt=qp({...N,global:{...de,localizationPackages:te,runtime:{...ye,localizationPackageId:Ne}},projectData:De,initialAudioCommandId:S});le?.(),n=rt,i+=1,a=!0,r=0,s=It(A),o=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,b=new Map,h=0,y=null,w=[],g=!1,E=null,k={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null},P=new Map,v=B,O=Y,L=Ne,$=!0,D=!1,U=0,_.clear(),n.appendPendingEffect({name:"handleLineActions"}),be()},In=()=>{Z("dispose"),a&&(a=!1,i+=1,n?.clearPendingEffects?.(),o=0,l=!1,u=[],p=null,d=null,f=new Map,m=new Map,b=new Map,y=null,w=[],g=!1,E=null,k=null,P=new Map,$=!1,_.clear(),X?.())},xt=()=>s,vn=()=>n.selectPresentationState(),St=()=>n.selectPresentationChanges(),kn=I=>n.selectSectionLineChanges(I),Zr=(I={})=>{ie("rendering"),r+=1;let A=Date.now();Se(A);let S=m.size>0,R=W(f,A),N=S?W(m,A):new Map,Y=n.selectRenderState({activePersistentAnimations:fe(R),restoredPersistentAnimations:fe(N),activeAudioEffect:y?structuredClone(y):null}),B={...Y,id:`render-${t}-${i}-${r}`};return b.set(B.id,{builtAt:A,persistentAnimationSessions:new Map([...N.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectId:y?.id??null,retainsActiveAudioEffect:!!y&&(Y.audioEffects??[]).some(te=>te.id===y.id)}),B},An=(I={})=>Zr(I),xi=(I={})=>Zr(I),Pn=I=>{if(!a||!n)return;let A=I?.audio?.find(Y=>Y?.id===nk);g=!0,E=A?structuredClone(A):null;let S=typeof I?.id=="string"&&I.id.length>0?I.id:null,R=S?b.get(S):null;S&&b.delete(S);let N=new Map;Mc(I?.animations).forEach(Y=>{let B=ns(Y);if(!B)return;let te=R?.persistentAnimationSessions?.get(B)??f.get(B),de=Math.max(0,Fc(Y)),ye=te?.startedAt??R?.builtAt??Date.now();N.set(B,{animation:structuredClone(Y),startedAt:ye,expiresAt:ye+de})}),f=N,R?.usedRestoredPersistentAnimationSessions&&(m=new Map),R?.activeAudioEffectId&&!R.retainsActiveAudioEffect&&y?.id===R.activeAudioEffectId&&(y=null)},Ad=()=>n.selectSystemState(),Pd=()=>n.selectAchievements(),Ed=I=>n.selectAchievement(I),Xa=()=>n.selectSaveSlotMap(),xd=I=>n.selectSaveSlot(I),Sd=I=>n.selectSaveSlotPage(I),Od=()=>n.selectImageGallery(),Rd=()=>n.selectMusicRoom(),$d=()=>n.selectSceneReplay(),Cd=()=>n.selectIsSceneReplayActive(),wk=()=>n.selectSkipMode(),Ik=()=>n.selectAutoMode(),_d=()=>n.selectRuntime(),jd=()=>n.selectIsChoiceVisible(),Nd=()=>n.selectIsFormVisible(),Dd=()=>n.selectActiveInteraction(),Td=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),Ga=(I,A,S={})=>!Ve(A)||I!=="nextLine"?A:S.bypassChoice===!0?{...A,bypassChoice:!0}:S.interactionSource===Ua?{...A,_interactionSource:Ua}:A,Ha=(I={})=>({type:Ba,payload:Ga("nextLine",{_conditionalContinuation:!0},I)}),Si=(I,A)=>bn(I)?{type:Ba,payload:{...I.payload,...A.payload}}:A,Ld=I=>{I.savedCheckpointOccurrences.forEach(A=>{n.markSavedRollbackCheckpointTransient(A)}),I.savedCheckpointOccurrences=[]},Md=(I,A)=>{let S=p;return p=null,!S||!Qr(S.pointer,I)||S.checkpointIndex!==A?.checkpointIndex||S.checkpointIdentity!==A?.checkpoint?[]:S.savedCheckpointOccurrences},qd=I=>{let A=d;return!A||!Qr(A.pointer,I)?null:(d=null,A)},Vd=({actionType:I,pointerBeforeAction:A,pointerAfterAction:S,cursorBeforeAction:R,cursorAfterAction:N,wasSceneReplayActive:Y,isSceneReplayActive:B})=>{!S||!(!Qr(A,S)||R?.checkpoint!==N?.checkpoint||R?.checkpointIndex!==N?.checkpointIndex||I==="jumpToLine")||(d={pointer:S,appendToPrevious:Jv.has(I)&&Y===B&&A?.sectionId===S.sectionId&&A?.lineId!==S.lineId,reuseExistingOccurrence:Qv.has(I),forceNewOccurrence:I==="jumpToLine"})},Ka=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),Ld(I))},Fd=(I,A,S)=>Kv.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==A?.checkpoint:S?.checkpoint!==A?.checkpoint&&S?.checkpointIndex>A?.checkpointIndex:!1,Ud=I=>{let A=u.at(-1);if(!A?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&A.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:A.rollbackCursor?.checkpointIndex,sectionId:A.pointer?.sectionId,lineId:A.pointer?.lineId})},Bd=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(A=>{let S=n.selectSaveSlot({slotId:A.slotId});S&&(A.saveSlotIdentity=S)})},Yd=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},zd=(I,A,S)=>{let R=u.at(-1);if(!R)return;let N=n.selectCurrentPointer()?.pointer,Y=Fd(I,A,S);if(Qr(R.pointer,N)){let B=S?.checkpoint!==A?.checkpoint||S?.checkpointIndex!==A?.checkpointIndex;Y||B&&Wv.has(I)?(Ka(R),R.pointer=N,R.rollbackCursor=S,R.markCurrentCheckpointTransient=Y,R.savedCheckpointOccurrences=[]):B&&I==="updateProjectData"&&(R.rollbackCursor=S);return}Ka(R),R.pointer=N,R.rollbackCursor=n.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=Y,R.savedCheckpointOccurrences=[]},et=(I,A)=>{if(ie(`action "${I}"`),!n[I])return;let S=A,R,N;if(I==="updateProjectData")Wa(A),R=structuredClone(A.projectData),S={...A,projectData:Pi({projectData:R,l10nData:O,l10nId:L})},Wa(S);else if(I==="updateLocalizationPackage"){if(N=Xd(A),N===L)return;S={l10nId:N,projectData:Pi({projectData:v,l10nData:O,l10nId:N})}}Hv.has(I)&&(c+=1);let Y=n.selectAutoMode(),B=Y?n.selectRuntime():null,te=n.selectIsSceneReplayActive?.()===!0,de=Gv.has(I)?W(f):null,ye=n.selectCurrentPointer()?.pointer??null,we=n.selectRollbackCursor?.()??null,ge=Wn(I),Ne=ge?n.selectPlaybackLineEntryId?.()??0:null,De=ge?Fe():null,rt=!1,tt;try{tt=n[I](S),rt=!0}catch(Ot){throw K(Ot,"preCommit"),Ot}R!==void 0&&(v=R),N!==void 0&&(L=N),Xv.has(I)&&(m=de??new Map,f=new Map,y=null),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=null);let tl=n.selectIsSceneReplayActive?.()===!0;te!==tl&&(f=new Map,m=new Map);let om=n.selectCurrentPointer()?.pointer??null,nl=n.selectRollbackCursor?.()??null,sl=ge?n.selectPlaybackLineEntryId?.()??0:null;ge&&sl!==Ne&&(k={lineEntryId:sl,channel:De}),I==="saveSlot"?Ud(A):I==="updateProjectData"&&Bd(),zd(I,we,nl),Vd({actionType:I,pointerBeforeAction:ye,pointerAfterAction:om,cursorBeforeAction:we,cursorAfterAction:nl,wasSceneReplayActive:te,isSceneReplayActive:tl});let am=n.selectAutoMode()&&(I==="updateVariable"||Y&&ok(B,n.selectRuntime()));(sk.has(I)||am)&&($=!0);try{be()}catch(Ot){throw rt&&K(Ot,"postCommitUnsettled"),Ot}return tt},Wa=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Vr(I?.projectData?.resources?.variables??{}),Dt(I.projectData),Tt(I.projectData),Lt(I.projectData)},Xd=I=>{if(!Ve(I))throw new Error("updateLocalizationPackage requires an object payload");let A=Object.keys(I);if(A.length!==1||A[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(I.l10nId!==null&&(typeof I.l10nId!="string"||I.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return I.l10nId},Gd=(I,A,S)=>{let R=n.selectCurrentPointer()?.pointer;A!==R||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),et("nextLineFromSystem",I.payload))},Hd=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:d,persistentAnimationSessions:new Map(f),restoredPersistentAnimationSessions:new Map(m),renderPersistentAnimationMetadata:new Map(b),audioEffectOccurrenceSequence:h,activeAudioEffect:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:k?structuredClone(k):null,acceptedLineBgmActionOccurrences:new Map(P),canonicalProjectData:v,localizationPackageId:L,playbackScheduleDirty:$}),Kd=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,d=I.pendingDialogueHistoryLineEntry,f=new Map(I.persistentAnimationSessions),m=new Map(I.restoredPersistentAnimationSessions),b=new Map(I.renderPersistentAnimationMetadata),h=I.audioEffectOccurrenceSequence,y=I.activeAudioEffect,w=I.pendingAudioEffectOccurrences.slice(),k=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,P=new Map(I.acceptedLineBgmActionOccurrences),v=I.canonicalProjectData,L=I.localizationPackageId,$=I.playbackScheduleDirty},Oi=(I,A={})=>(ie("action batch"),me(()=>{let S=Hd();try{return n[to](()=>{let R,N=n.selectCurrentPointer()?.pointer??null,Y=n.selectRollbackCursor?.()??null,B=c,te={pointer:N,rollbackCursor:Y,markCurrentCheckpointTransient:A.rollbackSource==="line",savedCheckpointOccurrences:A.savedCheckpointOccurrences?.slice()??[]};u.push(te);try{n.beginRollbackActionBatch({source:A.rollbackSource});try{R=I()}finally{n.endRollbackActionBatch({})}bn(R)&&Gd(R,N,B),At();let de=n.selectCurrentPointer()?.pointer??null;A.rollbackSource==="line"&&Qr(N,de)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:te.savedCheckpointOccurrences,appendToPrevious:A.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:A.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:A.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!Qr(N,te.pointer)||Y?.checkpoint!==te.rollbackCursor?.checkpoint)&&te.markCurrentCheckpointTransient&&te.savedCheckpointOccurrences.length>0&&(p={pointer:te.pointer,checkpointIndex:te.rollbackCursor?.checkpointIndex,checkpointIdentity:te.rollbackCursor?.checkpoint,savedCheckpointOccurrences:te.savedCheckpointOccurrences})}})}catch(R){throw Kd(S),R}})),Ri=(I,A,S,R={})=>{if(I===Fa||I===gn)return Oi(()=>{let N={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[I],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(I===gn)return Za(A,S,N);let Y=$i(S),B=Ft({[I]:A},Y);return Qa(B[I],S,N)},R);if(I==="bgm")return Oi(()=>{let N=A?.audioEffects?Fe():null;et(I,A),Pt(A,{...R,actionPath:R.actionPath??[I]},N,A?.audioEffects?lr():null)},R);et(I,A)},Wd=(I,A)=>{if(I!=="nextLineFromSystem")return Ri(I,A);U+=1;try{return Ri(I,A)}finally{U=Math.max(0,U-1)}},Ja=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},$i=I=>{if(Ja(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:A,...S}=I,R=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:A,variables:R,runtime:n.selectRuntime?n.selectRuntime():{}}},Jd=I=>{if(!Ve(I))return{templatePayload:I,literalTargetIds:null};let A=n.selectImageGalleryConfig();if(!Array.isArray(A?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?A.groups.find(N=>N.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let R=typeof I.variantId=="string"&&S.variants.some(N=>N.id===I.variantId);return{templatePayload:{...I,groupId:null,...R?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...R?{variantId:I.variantId}:{}}}},Qd=I=>!Ve(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(R=>R.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Zd=I=>!Ve(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},em=I=>{if(!Ve(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},rm=(I,A,S)=>{if(!Ve(I))throw new Error(`conditional branch at index ${A} must be an object`);if(!Ve(I.actions))throw new Error(`conditional branch at index ${A} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&A!==S-1)throw new Error("conditional else branch must be the last branch")},Qa=(I,A,S)=>{em(I);let R=Ha(S);for(let N=0;N<I.branches.length;N+=1){let Y=I.branches[N];rm(Y,N,I.branches.length);let B=$i(A);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!Nt(Y.when,B))continue;let de=En(Y.actions,A,{...S,actionPath:[...S.actionPath??[Fa],"branches",String(N),"actions"]});return bn(de)?Si(R,de):R}return R},tm=I=>{if(!Ve(I))throw new Error("random action payload must be an object");let A=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(A!==void 0)throw new Error(`random action.${A} is not supported`);if(!Ve(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=v?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||Re(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},Za=(I,A,S)=>{tm(I),Ja(A);let R=ec(I.distribution,{randomSource:G});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let B=(S.actionPath??[gn]).join("."),te=S.randomOutcomeOrdinals??new Map,de=te.get(B)??0;te.set(B,de+1),n.recordRandomOutcome({path:B,ordinal:de,type:R.type,result:R}),Yd()}let N;R.type==="integer"?et("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:R.value}]}):N=En(I.distribution.outcomes[R.outcomeIndex].actions,A,{...S,actionPath:[...S.actionPath??[gn],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let Y=Ha(S);return bn(N)?Si(Y,N):Y},nm=(I,A)=>({...I??{},_form:A}),sm=(I,A,S,R)=>{let N=et(I,A),Y=N?.submitted===!0&&N.valid===!0,B=N?.cancelled===!0;if(!(!Y&&!B)&&Ve(A.actions))return En(A.actions,nm(S,N.form),{...R,interactionSource:Ua})},el=(I,A,S,R)=>{if(I===gn)return Za(A,S,R);let N=$i(S),Y={templatePayload:A,literalTargetIds:null};I===ek?Y=Jd(A):I===rk?Y=Qd(A):I===tk&&(Y=Zd(A));let{templatePayload:B,literalTargetIds:te}=Y,ye=Ft({[I]:B},N)[I],we=te?{...ye,...te}:ye;if(I===Fa)return Qa(we,S,R);let ge=Ga(I,we,R);if(Zv.has(I))return sm(I,ge,S,R);let Ne=null;if(I==="bgm"&&ge?.audioEffects){let De=R.audioEffectHandoff;De?.available?(De.available=!1,Ne=structuredClone(De.channel)):Ne=Fe()}et(I,ge),I==="bgm"&&Pt(ge,R,Ne,ge?.audioEffects?lr():null)},En=(I,A,S)=>{let R,N=S?.executionContext??{depth:0,pendingNavigation:null},Y=Kn(I);Jn(Y),N.depth+=1;try{for(let[B,te]of Y){let de={...S,executionContext:N,actionPath:[...S?.actionPath??[],B]};if(Wn(B)){let we=N.pendingNavigation;if(we)throw new Error(`action batch cannot execute multiple navigation actions: ${we.actionType}, ${B}`);N.pendingNavigation={actionType:B,payload:te,eventContext:A,options:de};continue}let ye=el(B,te,A,de);bn(ye)&&(R=Si(R,ye))}}finally{N.depth-=1}if(N.depth===0&&N.pendingNavigation){let B=N.pendingNavigation;N.pendingNavigation=null,el(B.actionType,B.payload,B.eventContext,B.options)}return R},rl=(I,A,S={})=>{let R={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Oi(()=>En(I,A,R),R)},im=I=>{let A=n.selectCurrentPointer()?.pointer;if(I!==A||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:Et,dispose:In,handleAction:Ri,handleInternalAction:Wd,handleActions:rl,selectRenderState:An,prepareRenderState:xi,commitRenderState:Pn,selectPresentationState:vn,selectPresentationChanges:St,selectSectionLineChanges:kn,selectSystemState:Ad,selectAchievements:Pd,selectAchievement:Ed,selectSaveSlotMap:Xa,selectSaveSlot:xd,selectSaveSlotPage:Sd,selectSaveSlots:Xa,selectImageGallery:Od,selectMusicRoom:Rd,selectSceneReplay:$d,selectIsSceneReplayActive:Cd,selectRuntime:_d,selectIsChoiceVisible:jd,selectIsFormVisible:Nd,selectActiveInteraction:Dd,selectHasPendingRenderWork:Td,handleLineActions:I=>{ie("line action handling");let A=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!Qr(I.pointer,A))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return me(()=>{let S=n.selectCurrentPointer()?.pointer,R=n.selectPlaybackLineEntryId?.()??0,N=k?.lineEntryId===R?k:null,Y=n.selectRollbackCursor?.()??null,B=p,te=d,de=Md(S,Y),ye=qd(S),we=n.selectCurrentLine(),ge=!1;if(we?.actions){try{rl(we.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:de,dialogueHistoryAppendToPrevious:ye?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ye?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ye?.forceNewOccurrence===!0,audioEffectHandoff:N?{available:!0,channel:structuredClone(N.channel)}:null})}catch(Ne){throw p=B,d=te,Ne}ge=!0}return k?.lineEntryId===R&&(k=null),im(S),ge})},getNamespace:xt,classifyAutomaticAttemptError:pe}}var ak="music-room:player",vd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),wd=(e,t)=>vd.has(e)&&t?._event?.id===ak,kd=({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)},lk=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:i,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let o=i?.()??0,l=e.handleLineActions(s);(i?.()??0)===o&&kd({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},ck=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},uk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},pk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},fk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},dk=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},Id={render:kd,saveSlots:ck,saveGlobalDeviceVariables:uk,saveGlobalAccountVariables:pk,saveGlobalRuntime:fk,applyScopedDataUpdates:dk,handleLineActions:lk},mk=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),za=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},yk=(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(!mk.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},hk=({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,d=!1,f=0,m=0,b=!0,h=bd({ticker:n,dispatchAutomaticAttempt:()=>za(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:C=>e()?.classifyAutomaticAttemptError?.(C)??"preCommit"}),y=()=>{u=null,p=null,d=!1,f=0},w=()=>{h.reset(),m+=1,y(),b=!0},g=()=>{m+=1,b=!1,y(),h.dispose()},E=C=>b&&C===m,k=C=>{if(a){a(C);return}console.error("RouteEngine persistence write failed.",C)},P=C=>{if(s)return s;let j=It(C),F=l.get(j);if(F)return F;let W=$a({indexedDB:r,namespace:j});return l.set(j,W),W},v=C=>{let j=s?null:It(o??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=P(j),C(F))).catch(W=>{!s&&l.get(j)===F&&l.delete(j),k(W)})},O=C=>{if(!b)return;let j=typeof C?.id=="string"&&C.id.length>0?C.id:null;f+=1,u=j,d=!1},L=()=>f,$=(C={})=>{if(!b||C?.aborted===!0)return!1;let j=typeof C?.id=="string"&&C.id.length>0?C.id:null;return j?j!==u||j===p?!1:(p=j,!0):u!==null||d?!1:(d=!0,!0)},D=(C,j={})=>{if(!b)return!1;if(wd(C,j)){let W=vd.get(C),fe=e();return za(fe,W,j?._event),!0}if(C!=="renderComplete"||!$(j))return!1;let F=e();return za(F,"markLineCompleted",{}),!0},U=new Set(["updateFormField","submitForm","cancelForm"]),_=new Set(["updateVariable"]),G=C=>typeof C?.selectActiveInteraction=="function"?C.selectActiveInteraction():typeof C?.selectIsChoiceVisible=="function"&&C.selectIsChoiceVisible()?{source:"choice"}:null,ae=C=>C?._formKey??C?.formKey,M=(C,j)=>ae(C)===j?.formKey,Q=(C,j)=>!C||typeof C!="object"||Array.isArray(C)?!1:C._interactionSource===j?.source,le=(C,j)=>Q(C,j)?j.source==="form"?M(C,j):!0:!1,X=(C,j)=>!C||typeof C!="object"||Array.isArray(C)||j?.source!=="form"?!1:M(C,j),Z=(C={},j)=>Object.keys(C).length>0&&Object.entries(C).every(([F,W])=>U.has(F)?X(W,j):_.has(F)),ie=(C={},j)=>{let F=C?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:Z(F,j):le(C,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(W=>le(W,j))},K=(C,j={})=>{if(!j?.actions)return!1;let F=G(C);return!F||F.source==="choice"?!1:!ie(j,F)},pe=({preprocessPayload:C,onEvent:j}={})=>async(F,W={})=>{if(!b)return!1;if(wd(F,W))return D(F,W),j?.(F,W);let fe=e(),Se=m,be=f;if(K(fe,W))return j?.(F,W);let me=await C?.(F,W)??W;if(!E(Se)||e()!==fe||f!==be)return!1;if(K(fe,me))return j?.(F,me);if(D(F,me),me?.actions){let lr=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,Fe;me?.bypassChoice===!0?Fe={bypassChoice:!0}:me?._interactionSource&&(Fe={interactionSource:me._interactionSource}),Fe?fe.handleActions(me.actions,lr,Fe):fe.handleActions(me.actions,lr)}return j?.(F,me)},oe=C=>{if(!b)return;let j=m,F=e(),W=yk(C),fe=W.some(be=>be.name==="handleLineActions");W.forEach(be=>{if(!Id[be.name]&&!hn.has(be.name)&&!i)throw new Error(`Unhandled pending effect "${be.name}".`)});let Se={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:L,enqueuePersistenceWrite:v,lifecycleGeneration:m,isCurrentLifecycle:E};for(let be of W){if(!E(j))break;if(fe&&be.name==="render")continue;if(hn.has(be.name)){h.handleLegacyEffect(be);continue}let me=Id[be.name];if(me){me(Se,be.payload);continue}i(be,Se)}};return oe.handleRouteGraphicsEvent=D,oe.createRouteGraphicsEventHandler=pe,oe.reset=w,oe.dispose=g,oe.reconcilePlaybackScheduleV1=C=>h.reconcilePlaybackScheduleV1(C),oe},gk=hk;var bk=(e,t={})=>{let{resources:n={}}=t;return No(e,n)};var yP=Ya;export{mo as DEFAULT_VISUAL_LAYER,ct as RENDER_LAYER,cr as VISUAL_LAYER,gk as createEffectsHandler,FI as createIndexedDbPersistence,yP as default,so as formatDate,_y as resolveComputedVariables,bk as resolveLayoutReferences};
1
+ var fm=Object.defineProperty;var dm=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mm=(e,t)=>{for(var n in t)fm(e,n,{get:t[n],enumerable:!0})};var Zp=dm(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});function Qp(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}Na.default=Qp;Qp.code='require("ajv/dist/runtime/ucs2length").default'});var fl=Symbol.for("immer-nothing"),al=Symbol.for("immer-draftable"),_e=Symbol.for("immer-state");function Ue(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var st=Object.getPrototypeOf;function Ae(e){return!!e&&!!e[_e]}function Dr(e){return e?dl(e)||Array.isArray(e)||!!e[al]||!!e.constructor?.[al]||jn(e)||Nn(e):!1}var ym=Object.prototype.constructor.toString();function dl(e){if(!e||typeof e!="object")return!1;let t=st(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)===ym}function Cn(e){return Ae(e)||Ue(15,e),e[_e].base_}function On(e,t){_n(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,i)=>t(i,n,e))}function _n(e){let t=e[_e];return t?t.type_:Array.isArray(e)?1:jn(e)?2:Nn(e)?3:0}function Ti(e,t){return _n(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function ml(e,t,n){let i=_n(e);i===2?e.set(t,n):i===3?e.add(n):e[t]=n}function hm(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function jn(e){return e instanceof Map}function Nn(e){return e instanceof Set}function Nr(e){return e.copy_||e.base_}function Li(e,t){if(jn(e))return new Map(e);if(Nn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=dl(e);if(t===!0||t==="class_only"&&!n){let i=Object.getOwnPropertyDescriptors(e);delete i[_e];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(st(e),i)}else{let i=st(e);if(i!==null&&n)return{...e};let a=Object.create(i);return Object.assign(a,e)}}function Ui(e,t=!1){return Dn(e)||Ae(e)||!Dr(e)||(_n(e)>1&&(e.set=e.add=e.clear=e.delete=gm),Object.freeze(e),t&&Object.entries(e).forEach(([n,i])=>Ui(i,!0))),e}function gm(){Ue(2)}function Dn(e){return Object.isFrozen(e)}var bm={};function Tr(e){let t=bm[e];return t||Ue(0,e),t}var Ct;function yl(){return Ct}function wm(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ll(e,t){t&&(Tr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Mi(e){qi(e),e.drafts_.forEach(Im),e.drafts_=null}function qi(e){e===Ct&&(Ct=e.parent_)}function cl(e){return Ct=wm(Ct,e)}function Im(e){let t=e[_e];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ul(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[_e].modified_&&(Mi(t),Ue(4)),Dr(e)&&(e=Rn(t,e),t.parent_||$n(t,e)),t.patches_&&Tr("Patches").generateReplacementPatches_(n[_e].base_,e,t.patches_,t.inversePatches_)):e=Rn(t,n,[]),Mi(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==fl?e:void 0}function Rn(e,t,n){if(Dn(t))return t;let i=t[_e];if(!i)return On(t,(a,r)=>pl(e,i,t,a,r,n)),t;if(i.scope_!==e)return t;if(!i.modified_)return $n(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),On(r,(o,l)=>pl(e,i,a,o,l,n,s)),$n(e,a,!1),n&&e.patches_&&Tr("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function pl(e,t,n,i,a,r,s){if(Ae(a)){let o=r&&t&&t.type_!==3&&!Ti(t.assigned_,i)?r.concat(i):void 0,l=Rn(e,a,o);if(ml(n,i,l),Ae(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Dr(a)&&!Dn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Rn(e,a),(!t||!t.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&$n(e,a)}}function $n(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ui(t,n)}function vm(e,t){let n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:yl(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=i,r=Bi;n&&(a=[i],r=_t);let{revoke:s,proxy:o}=Proxy.revocable(a,r);return i.draft_=o,i.revoke_=s,o}var Bi={get(e,t){if(t===_e)return e;let n=Nr(e);if(!Ti(n,t))return km(e,n,t);let i=n[t];return e.finalized_||!Dr(i)?i:i===Ni(e.base_,t)?(Di(e),e.copy_[t]=Fi(i,e)):i},has(e,t){return t in Nr(e)},ownKeys(e){return Reflect.ownKeys(Nr(e))},set(e,t,n){let i=hl(Nr(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){let a=Ni(Nr(e),t),r=a?.[_e];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(hm(n,a)&&(n!==void 0||Ti(e.base_,t)))return!0;Di(e),Vi(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 Ni(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Di(e),Vi(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Nr(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:i.enumerable,value:n[t]}},defineProperty(){Ue(11)},getPrototypeOf(e){return st(e.base_)},setPrototypeOf(){Ue(12)}},_t={};On(Bi,(e,t)=>{_t[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});_t.deleteProperty=function(e,t){return _t.set.call(this,e,t,void 0)};_t.set=function(e,t,n){return Bi.set.call(this,e[0],t,n,e[0])};function Ni(e,t){let n=e[_e];return(n?Nr(n):e)[t]}function km(e,t,n){let i=hl(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}function hl(e,t){if(!(t in e))return;let n=st(e);for(;n;){let i=Object.getOwnPropertyDescriptor(n,t);if(i)return i;n=st(n)}}function Vi(e){e.modified_||(e.modified_=!0,e.parent_&&Vi(e.parent_))}function Di(e){e.copy_||(e.copy_=Li(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Am=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"&&Ue(6),i!==void 0&&typeof i!="function"&&Ue(7);let a;if(Dr(t)){let r=cl(this),s=Fi(t,void 0),o=!0;try{a=n(s),o=!1}finally{o?Mi(r):qi(r)}return ll(r,i),ul(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===fl&&(a=void 0),this.autoFreeze_&&Ui(a,!0),i){let r=[],s=[];Tr("Patches").generateReplacementPatches_(t,a,r,s),i(r,s)}return a}else Ue(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){Dr(e)||Ue(8),Ae(e)&&(e=br(e));let t=cl(this),n=Fi(e,void 0);return n[_e].isManual_=!0,qi(t),n}finishDraft(e,t){let n=e&&e[_e];(!n||!n.isManual_)&&Ue(9);let{scope_:i}=n;return ll(i,t),ul(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=Tr("Patches").applyPatches_;return Ae(e)?i(e,t):this.produce(e,a=>i(a,t))}};function Fi(e,t){let n=jn(e)?Tr("MapSet").proxyMap_(e,t):Nn(e)?Tr("MapSet").proxySet_(e,t):vm(e,t);return(t?t.scope_:yl()).drafts_.push(n),n}function br(e){return Ae(e)||Ue(10,e),gl(e)}function gl(e){if(!Dr(e)||Dn(e))return e;let t=e[_e],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Li(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Li(e,!0);return On(n,(i,a)=>{ml(n,i,gl(a))}),t&&(t.finalized_=!1),n}var Te=new Am,Tn=Te.produce,Rk=Te.produceWithPatches.bind(Te),$k=Te.setAutoFreeze.bind(Te),Ck=Te.setUseStrictShallowCopy.bind(Te),_k=Te.applyPatches.bind(Te),jk=Te.createDraft.bind(Te),Nk=Te.finishDraft.bind(Te);var x={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},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},it={NOT:0};var T=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ce=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Yi=e=>{if(!e||e.trim()==="")throw new T("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new T(`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 T(`Incomplete comparison expression - missing right operand (got: '${e}')`)},bl=e=>{if(e.trim().endsWith(" in"))throw new T(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new T(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new T(`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 T(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new T(`Invalid loop syntax (got: '$for ${e}')`)}};var wl=(e,t,n=!1)=>{if(t===null)return new Ce(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ce(`Cannot iterate over undefined value at '$for ${e}'`);let i=typeof t;return n?new Ce(`Cannot iterate over non-array value in loop '${e}' - got ${i} instead`):new Ce(`Cannot iterate over non-array value (got: ${i}) at '$for ${e}'`)},Il=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ce(`Unknown function '${e}' (${n})`)};var Pm=(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=ne(e,{functions:i,partials:a},t,{});return s===void 0?{}:s},ne=(e,t,n,i)=>{let a=t.functions||t;if(e.var&&!e.type)return ve(e.var,n,i);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return ve(e.path,n,i);if(e.type===x.INTERPOLATION)return xm(e.parts,t,n,i);switch(e.type){case x.FUNCTION:return kl(e,t,n,i);case x.BINARY:return Al(e,t,n,i);case x.UNARY:return Pl(e,t,n,i);case x.CONDITIONAL:return Om(e,t,n,i);case x.LOOP:return jm(e,t,n,i);case x.OBJECT:return Dm(e,t,n,i);case x.ARRAY:return Tm(e,t,n,i);case x.PARTIAL:return Lm(e,t,n,i);case x.PATH_REFERENCE:return Mm(e,t,n,i);default:throw new Error(`Unknown node type: ${e.type}`)}},vl=new Map,Em=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},ve=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let i=vl.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=Em(l.trim());i.push(...c)}vl.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},xm=(e,t,n,i)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=ne(r,t,n,i);a.push(s!=null?String(s):"")}return a.join("")},kl=(e,t,n,i)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Il(e.name,a);let s=e.args.map(o=>ne(o,t,n,i));return r(...s)},wr=(e,t,n,i)=>{if(e.var&&!e.type)return ve(e.var,n,i);switch(e.type){case x.VARIABLE:return ve(e.path,n,i);case x.LITERAL:return e.value;case x.BINARY:return Al(e,t,n,i);case x.UNARY:return Pl(e,t,n,i);case x.FUNCTION:return kl(e,t,n,i);default:return ne(e,t,n,i)}},Al=(e,t,n,i)=>{if(e.op===ee.AND||e.op===ee.OR){let s=wr(e.left,t,n,i),o=wr(e.right,t,n,i);switch(e.op){case ee.AND:return s&&o;case ee.OR:return s||o}}let a=ne(e.left,t,n,i),r=ne(e.right,t,n,i);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new Ce(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ce(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Pl=(e,t,n,i)=>{let a=e.op===it.NOT?wr(e.operand,t,n,i):ne(e.operand,t,n,i);if(e.op===it.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Sm=(e,t,n,i)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(ve(a.path,n,i)){let s=e.bodies[0];if(s.type===x.OBJECT&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===x.LITERAL)o[c]=u.value;else if(u.type===x.VARIABLE)o[c]=ve(u.path,n,i);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ve(d.path,n,i);p.push(f!=null?String(f):"")}else{let f=ne(d,t,n,i);p.push(f!=null?String(f):"")}o[c]=p.join("")}else o[c]=ne(u,t,n,i)}return o}}else{let s=e.bodies[1];if(s.type===x.OBJECT&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===x.LITERAL)o[c]=u.value;else if(u.type===x.VARIABLE)o[c]=ve(u.path,n,i);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ve(d.path,n,i);p.push(f!=null?String(f):"")}else{let f=ne(d,t,n,i);p.push(f!=null?String(f):"")}o[c]=p.join("")}else o[c]=ne(u,t,n,i)}return o}}}return null},Om=(e,t,n,i)=>{let a=Sm(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||wr(s,t,n,i))return ne(e.bodies[r],t,n,i)}return El},Rm=(e,t)=>{let n=e.body,i=e.itemVar;if(n.type===x.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===x.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===x.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 d=p.key,f=p.value;if(f.type===x.LITERAL)u[d]=f.value;else if(f.type===x.VARIABLE){let m=f.path;if(m===i)u[d]=c;else if(m.startsWith(i+".")){let b=m.substring(i.length+1);u[d]=c[b]}else return null}else if(f.type===x.INTERPOLATION){let m=[],b=!0;for(let h of f.parts)if(typeof h=="string")m.push(h);else if(h.type===x.VARIABLE){let y=h.path;if(y===i)m.push(c!=null?String(c):"");else if(y.startsWith(i+".")){let w=y.substring(i.length+1),g=c[w];m.push(g!=null?String(g):"")}else{b=!1;break}}else{b=!1;break}if(!b)return null;u[d]=m.join("")}else return null}o.push(u)}}return o}}}return null},$m=(e,t)=>{let n=e.body,i=e.itemVar,a=Rm(e,t);if(a!==null)return a;if(n.type===x.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===x.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===x.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===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===i)r.push({key:l,type:"item_string"});else if(p.startsWith(i+".")){let d=p.substring(i.length+1);if(!d.includes(".")&&!d.includes("["))r.push({key:l,type:"prop_string",prop:d});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 d=c[p.prop];u[p.key]=d!=null?String(d):""}o[l]=u}return o}}return null},Cm=(e,t,n,i,a)=>{let r=[],s=e.body;if(s.type===x.OBJECT&&s.fast!==!1){let o=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},d={...i,[o]:u,...l&&{[l]:c}};d.__paths__||(d.__paths__=i.__paths__||{});let f=e.iterable.path||"";if(i&&i.__paths__&&f){let m=f.split("."),b=m[0];b in i.__paths__&&(f=i.__paths__[b],m.length>1&&(f+="."+m.slice(1).join(".")))}d.__paths__={...d.__paths__,[o]:`${f}[${c}]`,...l&&{[l]:c}};for(let m of s.properties){let b=m.parsedKey?ne(m.parsedKey,t,n,d):m.key,h=m.value;if(h.type===x.LITERAL)p[b]=h.value;else if(h.type===x.VARIABLE){let y=h.path;if(y===o)p[b]=u;else if(y===l)p[b]=c;else if(y.startsWith(o+".")){let w=y.substring(o.length+1);!w.includes(".")&&!w.includes("[")?p[b]=u[w]:p[b]=ve(y,n,{...i,[o]:u,...l&&{[l]:c}})}else p[b]=ve(y,n,{...i,[o]:u,...l&&{[l]:c}})}else if(h.type===x.INTERPOLATION){let y=[];for(let w of h.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=w.path,E;if(g===o)E=u;else if(g===l)E=c;else if(g.startsWith(o+".")){let k=g.substring(o.length+1);!k.includes(".")&&!k.includes("[")?E=u[k]:E=ve(g,n,{...i,[o]:u,...l&&{[l]:c}})}else E=ve(g,n,{...i,[o]:u,...l&&{[l]:c}});y.push(E!=null?String(E):"")}else{let g={...i,[o]:u,...l&&{[l]:c}},E=ne(w,t,n,g);y.push(E!=null?String(E):"")}p[b]=y.join("")}else{let y={...i,[o]:u,...l&&{[l]:c}};p[b]=ne(h,t,n,y)}}r.push(p)}return r}return null},_m=(e,t,n)=>{let i=e.body;if(i.type===x.OBJECT&&i.properties.length===1&&i.properties[0].key==="$if item.visible"){let r=i.properties[0].value;if(r.type===x.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===x.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===x.OBJECT&&s.properties.length===2){let o=s.properties[0],l=s.properties[1];if(o.key==="id"&&o.value.type===x.VARIABLE&&o.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===x.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let d={id:p.id};p.highlighted?(d.highlight=!0,d.message=`This item is highlighted: ${p.name}`):(d.highlight=!1,d.message=p.name),c.push(d)}}return c}}}}return null},jm=(e,t,n,i)=>{let a=ne(e.iterable,t,n,i);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let d=e.iterable.args.map(f=>f.type===x.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===x.VARIABLE?f.path:f.type===x.FUNCTION?`${f.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${d})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw wl(p,a,u)}if(!e.indexVar){let c=_m(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=$m(e,a);if(c!==null)return c}let r=Cm(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===x.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===x.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,n,u);if(Array.isArray(p)&&p.length===1&&!l){let d=p[0];s.push(d===void 0?{}:d)}else s.push(p===void 0?{}:p)}return s},Nm=(e,t,n,i)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?ne(a.parsedKey,t,n,i):a.key,s=a.value;if(s.type===x.OBJECT&&s.properties.length<=10&&!s.whenCondition){let o={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?ne(u.parsedKey,t,n,i):u.key,d=u.value;if(d.type===x.LITERAL)l[p]=d.value;else if(d.type===x.VARIABLE)l[p]=ve(d.path,n,i);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let b=ve(m.path,n,i);f.push(b!=null?String(b):"")}else{c=!1;break}if(!c)break;l[p]=f.join("")}else if(d.type===x.OBJECT&&d.properties.length<=5){let f={};for(let m of d.properties){let b=m.key,h=m.value;if(h.type===x.LITERAL)f[b]=h.value;else if(h.type===x.VARIABLE)f[b]=ve(h.path,n,i);else if(h.type===x.INTERPOLATION){let y=[];for(let w of h.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=ve(w.path,n,i);y.push(g!=null?String(g):"")}else{c=!1;break}if(!c)break;f[b]=y.join("")}else{c=!1;break}}if(!c)break;l[p]=f}else{c=!1;break}}if(c)return o[r]=l,o}}return null},Dm=(e,t,n,i)=>{let a=t.functions||t;if(e.whenCondition&&!wr(e.whenCondition,a,n,i))return;let r=Nm(e,t,n,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,n,i):u.key,d=u.value;if(d.type===x.LITERAL)c[p]=d.value;else if(d.type===x.VARIABLE)c[p]=ve(d.path,n,i);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let b=ve(m.path,n,i);f.push(b!=null?String(b):"")}else{let b=ne(m,t,n,i);f.push(b!=null?String(b):"")}c[p]=f.join("")}else c[p]=ne(d,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=ne(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 ne(c.value,t,n,i)}else{let u=c.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(d=>d.key.startsWith("$for "));if(p){let d=ne(p.value,t,n,i);d!==void 0&&(s[c.key]=d)}else{let d=ne(c.value,t,n,i);d!==void 0&&(s[c.key]=d)}}else{let p=c.parsedKey?ne(c.parsedKey,t,n,i):c.key,d=ne(c.value,t,n,i);d!==void 0&&(s[p]=d)}}return s},El={},Tm=(e,t,n,i)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let s=ne(r,t,n,i);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=ne(r,t,n,i);s!==El&&s!==void 0&&a.push(s)}return a},Lm=(e,t,n,i)=>{let{name:a,data:r,whenCondition:s}=e,o=t.partials||{},l=t.functions||t;if(s&&!wr(s,l,n,i))return;if(!o[a])throw new Ce(`Partial '${a}' is not defined`);let c=i._partialStack||[];if(c.includes(a))throw new Ce(`Circular partial reference detected: ${a}`);let u=o[a],p=n,d={...i,_partialStack:[...c,a]};if(i){p={...n};for(let f of Object.keys(i))f.startsWith("_")||(p[f]=i[f])}if(r){let f=ne(r,t,n,i);p={...p,...f}}return ne(u,t,p,d)},Mm=(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 Ce(`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 Ce(`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 Ce(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return o.length>0&&(l+="."+o.join(".")),l};var zi=Pm;var qm=/\$\{([^}]*)\}/g,Vm=/#\{([^}]*)\}/g,Sl=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,i,a]=n,r=Fm(a,t);return{isFunction:!0,type:x.FUNCTION,name:i,args:r}},Fm=(e,t={})=>e.trim()?Um(e).map(i=>Bm(i.trim(),t)):[],Um=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},Bm=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:x.LITERAL,value:parseFloat(e)};if(e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};let n=Sl(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=Lr(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 Pe(i,t)}catch{return{type:x.VARIABLE,path:i}}return{type:x.VARIABLE,path:i}},Ol=/^\w+\(.*\)$/,Ym=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,zm=e=>{if(!(!e||e.trim()===""||Ol.test(e))&&Ym.test(e))throw e.includes("?")&&e.includes(":")?new T(`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 T(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new T(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},xl=e=>{let t=e.trim();if(Ol.test(t))throw new T(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new T(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new T(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new T(`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 T(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:t}},jt=(e,t={})=>{let n=e.trim();zm(n);let i=Sl(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:x.VARIABLE,path:n}},Xi=(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(qm)],r=[...n.matchAll(Vm)],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:x.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"?jt(c[1],t):xl(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:n};throw p}}let o=[],l=0;for(let{match:c,type:u}of s){let[p,d]=c,f=c.index;if(f>l){let m=n.substring(l,f);for(let b=0;b<i.length;b++)m=m.replace(`__ESCAPED_${b}__`,i[b]);m&&o.push(m)}try{let m;u==="variable"?m=jt(d.trim(),t):m=xl(d.trim()),o.push(m)}catch(m){if(m.message==="Invalid array index syntax")o.push(p);else throw m}l=f+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:x.INTERPOLATION,parts:o}};var Ki=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Cl=e=>Object.keys(e),Oe=e=>e.join("."),Ir=(e,t,n)=>{let i=Cl(e).filter(a=>!t.has(a));if(i.length>0)throw new T(`Unexpected key '${i[0]}' in condition JSON at '${Oe(n)}'`)},vr=(e,t)=>typeof e=="string"?Xi(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?Gm(e,t):Hm(e,t):{type:x.LITERAL,value:e},Xm=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new T("$each value must be a non-empty string");let i=t.trim();if(i==="")throw new T("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new T("Empty $each body not allowed");if(n.$partial!==void 0)throw new T("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${i}`]:n}},Gm=(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=Xm(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=$l(c[0],l[c[0]],t,!0);n.push(u),i=!0;continue}}catch(l){throw l instanceof T?l:new T(l.message)}let o=Object.keys(r);if(o.length===1&&/^\$for(?::\w+)?\s/.test(o[0])){let l=$l(o[0],r[o[0]],t);n.push(l),i=!0;continue}}let s=vr(r,t);n.push(s),(s.type===x.FUNCTION||s.type===x.CONDITIONAL||s.type===x.LOOP||s.type===x.PARTIAL||s.type===x.OBJECT&&!s.fast||s.type===x.ARRAY&&!s.fast)&&(i=!0)}return{type:x.ARRAY,items:n,fast:!i}},Hm=(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 T("$partial value must be a string");if(e.$partial.trim()==="")throw new T("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let w of l)if(y===w||y.startsWith(w+" ")||y.startsWith(w+"#")){c.push(w);break}if(c.length>0)throw new T(`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,...d}=e,f={},m=!1;for(let[y,w]of Object.entries(d)){let g=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(g=y.slice(1)),f[g]=w,m=!0}let b=null;if(m&&(b=vr(f,t),b.type===x.OBJECT)){let y=!1;for(let w of b.properties)if(w.value.type===x.VARIABLE||w.value.type===x.INTERPOLATION||w.value.type===x.FUNCTION||w.value.type===x.CONDITIONAL||w.value.type===x.OBJECT&&!w.value.fast||w.value.type===x.ARRAY&&!w.value.fast){y=!0;break}y&&(b.fast=!1)}let h={type:x.PARTIAL,name:u,data:b};return p!==void 0&&(h.whenCondition=Rl(p,t)),h}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new T("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new T("Missing condition expression after '$when'");a=Rl(c,t),i=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new T("'$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 T("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=Km(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 T(`$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 T(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new T("Missing condition expression after '$if'");{let u=vr(c,t);(u.type===x.FUNCTION||u.type===x.CONDITIONAL||u.type===x.PARTIAL||u.type===x.OBJECT&&!u.fast||u.type===x.ARRAY&&!u.fast)&&(i=!0);let p=Xi(l,t),d={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(d.parsedKey=p),n.push(d),s++}}}let o={type:x.OBJECT,properties:n,fast:!i};return a&&(o.whenCondition=a),o},Km=(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 T(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Yi(c);let u=Pe(c,n);for(i.push(u),a.push(vr(o,n)),r++;r<e.length;){let[p,d]=e[r],f=!1,m;if(l?p.startsWith(`$elif#${l} `)?(m=p.substring(`$elif#${l} `.length),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(f=!0,m=null):p.startsWith("$elif ")?(m=p.substring(6),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p==="$else"||p==="$else:")&&(f=!0,m=null),f){if(m===null)i.push(null);else{Yi(m);let b=Pe(m,n);i.push(b)}if(a.push(vr(d,n)),r++,m===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:i,bodies:a,id:l},nextIndex:r}},Gi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},Hi={all:ee.AND,any:ee.OR},Wm=new Set(["var","literal","call","not",...Object.keys(Gi),...Object.keys(Hi)]),Jm=(e,t,n)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${Oe(n)}' requires an array`);if(e.length!==2)throw new T(`Condition JSON operator '${t}' at '${Oe(n)}' requires exactly 2 operands`);return e},Qm=(e,t,n,i,a)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${Oe(a)}' requires an array`);if(e.length===0)throw new T(`Condition JSON operator '${t}' at '${Oe(a)}' requires at least 1 condition`);return e.map((s,o)=>je(s,i,[...a,o])).reduce((s,o)=>({type:x.BINARY,op:n,left:s,right:o}))},Zm=(e,t,n)=>{let i,a;if(typeof e.call=="string")i=e.call,a=e.args??[],Ir(e,new Set(["call","args"]),n);else if(Ki(e.call))i=e.call.name,a=e.call.args??[],Ir(e,new Set(["call"]),n),Ir(e.call,new Set(["name","args"]),[...n,"call"]);else throw new T(`Condition JSON call at '${Oe(n)}' requires a function name`);if(typeof i!="string"||i.trim()==="")throw new T(`Condition JSON call at '${Oe(n)}' requires a non-empty function name`);if(!/^\w+$/.test(i))throw new T(`Invalid condition JSON function name '${i}' at '${Oe(n)}'`);if(!Array.isArray(a))throw new T(`Condition JSON call '${i}' at '${Oe(n)}' requires args to be an array`);return{type:x.FUNCTION,name:i,args:a.map((r,s)=>je(r,t,[...n,"args",s]))}},je=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:x.LITERAL,value:e};if(Array.isArray(e))throw new T(`Condition JSON array at '${Oe(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Ki(e))throw new T(`Invalid condition JSON value at '${Oe(n)}'`);let i=Cl(e);if(i.length===0)throw new T(`Condition JSON object at '${Oe(n)}' must contain an operator`);let a=i.filter(s=>Wm.has(s));if(a.length===0)throw new T(`Unknown condition JSON operator '${i[0]}' at '${Oe(n)}'`);if(a.length>1)throw new T(`Condition JSON at '${Oe(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(Ir(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new T(`Condition JSON var at '${Oe(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return Ir(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(r==="call")return Zm(e,t,n);if(r==="not")return Ir(e,new Set(["not"]),n),{type:x.UNARY,op:it.NOT,operand:je(e.not,t,[...n,"not"])};if(r in Hi)return Ir(e,new Set([r]),n),Qm(e[r],r,Hi[r],t,[...n,r]);if(r in Gi){Ir(e,new Set([r]),n);let s=Jm(e[r],r,[...n,r]);return{type:x.BINARY,op:Gi[r],left:je(s[0],t,[...n,r,0]),right:je(s[1],t,[...n,r,1])}}throw new T(`Unknown condition JSON operator '${r}' at '${Oe(n)}'`)},Rl=(e,t={})=>{if(e==null)throw new T("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression after '$when'");return Pe(e,t)}return Ki(e)||Array.isArray(e)?je(e,t):{type:x.LITERAL,value:e}},Pe=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let d=0;d<c.length;d++)if(c[d]==="("?u++:c[d]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Pe(c,t)}let n=Lr(e,"||");if(n!==-1)return{type:x.BINARY,op:ee.OR,left:Pe(e.substring(0,n).trim(),t),right:Pe(e.substring(n+2).trim(),t)};let i=Lr(e,"&&");if(i!==-1)return{type:x.BINARY,op:ee.AND,left:Pe(e.substring(0,i).trim(),t),right:Pe(e.substring(i+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Lr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Pe(e.substring(0,p).trim(),t),right:Pe(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,o=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of o){let p=0;for(;p<e.length;){let d=Lr(e.substring(p),c);if(d===-1)break;let f=p+d;f>r&&(r=f,s={op:c,type:u}),p=f+c.length}}if(r!==-1&&s)return{type:x.BINARY,op:s.type,left:Pe(e.substring(0,r).trim(),t),right:Pe(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Lr(e,c)!==-1)throw new T(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:it.NOT,operand:Pe(e.substring(1).trim(),t)}:_l(e,t)},Lr=(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},ey=e=>{if(e=e.trim(),e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:x.LITERAL,value:""};if(e==="{}")return{type:x.LITERAL,value:{}};if(e==="[]")return{type:x.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:x.LITERAL,value:t}:{type:x.VARIABLE,path:e}},_l=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return jt(n,t);let a=ey(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return jt(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},ry=(e,t=!1)=>{let n=t?"$each":"$for";try{bl(e)}catch(i){if(i instanceof T&&t){let a=i.message.replace(/\$for/g,"$each");throw new T(a.replace("Parse Error: ",""))}throw i}},$l=(e,t,n,i=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let h=i?"$each":"$for";throw new T(`Invalid loop syntax (got: '${e.replace("$for",h)}')`)}let s=r[1],o=r[2].trim();ry(o,i);let l=o.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let h=i?"$each":"$for";throw new T(`Invalid loop syntax - missing 'in' keyword (got: '${h} ${o}')`)}let c=l[1].trim(),u=l[2].trim(),p,d=null;if(c.includes(",")){let h=c.split(",").map(y=>y.trim());if(h.length!==2)throw new T(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=h[0],d=h[1]}else p=c;let f=["this","undefined","null","true","false"];if(f.includes(p))throw new T(`Reserved variable name: ${p}`);if(d&&f.includes(d))throw new T(`Reserved variable name: ${d}`);let m=_l(u,n),b=vr(t,n);return{type:x.LOOP,itemVar:p,indexVar:d,iterable:m,body:b,flatten:s!=="nested"}};var ty=(e,t={})=>{let{functions:n={}}=t;return vr(e,n)},Ln=ty;var Nt={};mm(Nt,{now:()=>ny});var ny=()=>Date.now();var sy=(e,t,n={})=>{let{functions:i={},partials:a={}}=n,r={...Nt,...i},s=Ln(e,{functions:r}),o={};for(let[l,c]of Object.entries(a))o[l]=Ln(c,{functions:r});return zi(s,t,{functions:r,partials:o})},Mr=sy;var iy=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",oy=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,ay=(e,t)=>{if(iy(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression");return Pe(e,t)}return je(e,t)},ly=(e,t={},n={})=>{let i=oy(n),a={...Nt,...i},r=ay(e,a);return!!wr(r,{functions:a,partials:{}},t,{})},Wi=ly;var io=Symbol("runStoreTransaction"),eo="__routeEngineConditionComparison",Mn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",kr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Mn(e,t)&&e>t,gte:(e,t)=>Mn(e,t)&&e>=t,lt:(e,t)=>Mn(e,t)&&e<t,lte:(e,t)=>Mn(e,t)&&e<=t}),Vl=Object.freeze(Object.fromEntries(Object.keys(kr).map(e=>[e,`${eo}${e}`]))),cy=Object.freeze(Object.fromEntries(Object.entries(Vl).map(([e,t])=>[t,kr[e]]))),jl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),uy=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"||jl(e,"literal")||jl(e,"var"))return e;if(uy(e)?.startsWith(eo))throw new Error(`Condition function names beginning with "${eo}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[i,a]]=n,r=Vl[i];if(r)return{call:r,args:a.map(qn)}}return Object.fromEntries(n.map(([i,a])=>[i,qn(a)]))},Tt=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return je(e),Wi(qn(e),t,{functions:cy})},py=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Fl=(e,t,n={})=>{let i={},a={},{transformSelectorFirstArgument:r=b=>b,transformActionFirstArgument:s=b=>b,createTransactionalMetadata:o,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof o=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(o())}:{}},d=0,f=(b,h)=>!u||!c?b:Tn(b,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:h.state,previousTransactionalMetadata:h.transactionalMetadata})});for(let[b,h]of Object.entries(t))b!=="createInitialState"&&(b.startsWith("select")?i[b]=(...y)=>h(r(p.state,p.transactionalMetadata),...y):a[b]=(...y)=>{let w,g=p,E=Tn(p,k=>{let P=h(s(k.state,k.transactionalMetadata),...y);w=P!==void 0&&!Ae(P)?P:void 0,u&&l&&l({actionName:b,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});return d===0&&(E=f(E,g)),p=E,w});let m=b=>{if(typeof b!="function")throw new Error("Store transaction requires a callback");let h=p,y=d===0;d+=1;let w;try{w=b()}catch(g){throw d-=1,p=h,g}if(d-=1,y)try{p=f(p,h)}catch(g){throw p=h,g}return w};return{...i,...a,[io]:m}},Bn=(e,t)=>n=>{let i=e(),a=Array.isArray(n)?n:[n];return Tn(i,r=>{a.forEach(s=>{t.forEach(o=>{o(r,s)})})})};var fy=(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{}}},J=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),ro=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},ke=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),dy=new Set(["pageSize","groups"]),my=new Set(["id","variants"]),yy=new Set(["id","imageId"]),hy=new Set(["pageSize","tracks"]),gy=new Set(["id","soundId","title","artist","album","description","coverImageId"]),by=new Set(["pageSize","replays"]),wy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),qr=(e,t,n)=>{Object.keys(e).forEach(i=>{if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)})},ot=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Lt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!ke(t))throw new Error("resources.imageGallery must be an object");if(qr(t,dy,"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(!ke(a))throw new Error(`${r} must be an object`);if(qr(a,my,r),ot(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(!ke(l))throw new Error(`${c} must be an object`);if(qr(l,yy,c),ot(l.id,`${c}.id`),ot(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),!J(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},Mt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!ke(t))throw new Error("resources.musicRoom must be an object");if(qr(t,hy,"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(!ke(a))throw new Error(`${r} must be an object`);qr(a,gy,r);for(let l of["id","soundId","title"])ot(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&ot(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=e?.resources?.sounds?.[a.soundId];if(!J(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!ke(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&&!J(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Iy=(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}"`)}},qt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!ke(t))throw new Error("resources.sceneReplay must be an object");if(qr(t,by,"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(!ke(r))throw new Error(`${s} must be an object`);qr(r,wy,s);for(let u of["sceneId","title","thumbnailImageId"])ot(r[u],`${s}.${u}`);if(i.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(i.add(r.sceneId),!J(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let o=n[r.sceneId];if(!o)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=o.initialSectionId,c=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(!ke(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let d=e?.resources?.variables?.[u];if(!d)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(Re(d))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(d.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(d.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);Iy(u,d,p)}}}},Ul=e=>{let t=Ae(e)?br(e):e;return structuredClone(t)},vy=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!J(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},Yn=({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=vy({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},Re=e=>J(e,"computed"),oo=(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}},Vt=(e={},t={},{allowedScopes:n,preserveUnknown:i=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?i:!Re(s)&&(!n||n.includes(s.scope))&&oo(s,r)})),Ye=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),ky=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ye(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 Ye(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Ye(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 Ye(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
2
+ `,r:"\r",t:" ",b:"\b",f:"\f"};if(!J(l,o))throw Ye(t,n);a+=l[o]}return a},Bl=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ye(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 Ye(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 Ye(e,t);i+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Ye(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 Ye(e,t);i+=1,n.push(ky(p,e,t));return}i+=1}if(c||i>=e.length)throw Ye(e,t)};for(a();i<e.length;){if(e[i]==="."){i+=1,a();continue}if(e[i]==="["){r();continue}throw Ye(e,t)}return n},Ji=(e,t)=>{let n=e;for(let i of t){if(n==null||!J(n,i))return;n=n[i]}return n},Yl=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Bl(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 Ji(s,r)}return i==="runtime"?Ji(t.runtime,n.slice(1)):Ji(t,n)},zl=(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)`)},to=(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`)},Ay=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Ge=(e,t,n,i)=>(zl(e,t,i),t.map(a=>Un(a,n))),Be=(e,t,n,i)=>{let a=Ge(e,t,n,i);return a.forEach(r=>Ay(e,r)),a},Py=(e,t,n)=>{switch(e){case"var":return Yl(t,n);case"add":{let[i,a]=Be(e,t,n,2);return i+a}case"sub":{let[i,a]=Be(e,t,n,2);return i-a}case"mul":{let[i,a]=Be(e,t,n,2);return i*a}case"div":{let[i,a]=Be(e,t,n,2);return i/a}case"mod":{let[i,a]=Be(e,t,n,2);return i%a}case"neg":{let[i]=Be(e,t,n,1);return-i}case"round":{let[i]=Be(e,t,n,1);return Math.round(i)}case"floor":{let[i]=Be(e,t,n,1);return Math.floor(i)}case"ceil":{let[i]=Be(e,t,n,1);return Math.ceil(i)}case"min":{let[i,a]=Be(e,t,n,2);return Math.min(i,a)}case"max":{let[i,a]=Be(e,t,n,2);return Math.max(i,a)}case"clamp":{let[i,a,r]=Be(e,t,n,3);return Math.min(r,Math.max(a,i))}case"eq":{let[i,a]=Ge(e,t,n,2);return kr.eq(i,a)}case"neq":{let[i,a]=Ge(e,t,n,2);return kr.neq(i,a)}case"gt":{let[i,a]=Ge(e,t,n,2);return kr.gt(i,a)}case"gte":{let[i,a]=Ge(e,t,n,2);return kr.gte(i,a)}case"lt":{let[i,a]=Ge(e,t,n,2);return kr.lt(i,a)}case"lte":{let[i,a]=Ge(e,t,n,2);return kr.lte(i,a)}case"in":{let[i,a]=Ge(e,t,n,2);return Array.isArray(a)?a.includes(i):!1}case"and":case"all":return to(e,t),t.every(i=>!!Un(i,n));case"or":case"any":return to(e,t),t.some(i=>!!Un(i,n));case"not":{let[i]=Ge(e,t,n,1);return!i}case"length":{let[i]=Ge(e,t,n,1);return typeof i=="string"||Array.isArray(i)?i.length:ke(i)?Object.keys(i).length:0}case"includes":{let[i,a]=Ge(e,t,n,2);return typeof i=="string"?typeof a=="string"&&i.includes(a):Array.isArray(i)?i.includes(a):!1}case"literal":return Ul(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Un=(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 Py(i,a,t)},no=(e,t)=>{if(e===null||typeof e!="object"||J(e,"literal"))return e;if(J(e,"var"))return{literal:Yl(e.var,t)};if(J(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=>no(a,t)):no(i,t)]))},Ey=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return je(e),Tt(no(e,t))},Xl=(e,t)=>{if(!ke(e))throw new Error(`${t} must be an object`);let n=J(e,"expr"),i=J(e,"value");if(n===i)throw new Error(`${t} must contain exactly one of expr or value`)},Qi=(e,t,n)=>(Xl(e,t),J(e,"value")?Ul(e.value):Un(e.expr,n)),xy=(e,t={},n="unknown")=>{if(!ke(e))throw new Error(`Computed variable "${n}" computed must be an object`);let i=J(e,"expr"),a=J(e,"value");if(J(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(!ke(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(!ke(o))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!J(o,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(Ey(o.when,t))return Qi(o,`Computed variable "${n}" branch ${s}`,t)}return Qi(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 Qi(e,`Computed variable "${n}"`,t)},Gl=(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}`)}},Sy=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}),Oy=new Set(["and","or","all","any"]),Ry=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),$y=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Cy=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),_y=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Hl=new WeakMap,Nl=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Vn=(e,t,n)=>{for(let i of Object.keys(e))if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)},jy=(e,t,n,i)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${i} expected type ${t}, got ${n}`)},Kl=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,o,...l]=Bl(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(!J(n,o))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${o}"`);let c=n[o];return Re(c)&&i.add(o),l.length===0?c?.type:void 0},Wl=(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 Nl(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 Kl(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 Nl(o)}let l=Sy[s];if(l===void 0&&!Oy.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?to(s,o):zl(s,o,l);let c=o.map((u,p)=>Wl(u,{variableId:t,variableConfigs:n,dependencies:i,path:`${a}.${s}[${p}]`}));if($y.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Ry.has(s))return"number";if(Cy.has(s))return"boolean"},Ny=(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{je(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"||J(s,"literal"))return;if(J(s,"var")){Kl(s.var,{variableId:t,variableConfigs:n,dependencies:i,path:o});return}if(J(s,"call"))throw new Error(`Computed variable "${t}" ${o} function calls are not supported`);if(J(s,"not")){r(s.not,`${o}.not`);return}let l=Object.keys(s).find(c=>_y.has(c));s[l].forEach((c,u)=>{r(c,`${o}.${l}[${u}]`)})};r(e,a)},Zi=(e,{variableId:t,variableConfig:n,variableConfigs:i,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(Xl(e,`Computed variable "${t}" ${r}`),Vn(e,s,r),J(e,"value")){Gl(t,n.type,e.value);return}let o=Wl(e.expr,{variableId:t,variableConfigs:i,dependencies:a,path:`${r}.expr`});jy(t,n.type,o,`${r}.expr`)},Dy=(e,t,n)=>{let i=t.computed;if(!ke(i))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=J(i,"expr"),s=J(i,"value");if(J(i,"branches")){if(Vn(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(!ke(i.default))throw new Error(`Computed variable "${e}" requires default`);return i.branches.forEach((l,c)=>{if(!ke(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Vn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!J(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);Ny(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),Zi(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),Zi(i.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Vn(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 Zi(i,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},Vr=(e={})=>{if(!ke(e))throw new Error("Variable configs must be an object");if(J(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(J(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if(Re(s)){if(!ke(s))throw new Error(`Computed variable "${r}" must be an object`);if(!J(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!J(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(J(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(Ft(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,Dy(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 d=[...o.slice(p).map(({variableId:f})=>f),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${d}`)}l.set(u,o.length),o.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(i)});return Hl.set(e,a),a},at=({variables:e={},runtime:t={},variableConfigs:n={},eager:i=!0}={})=>{let{evaluationOrder:a}=Hl.get(n)??Vr(n),r=Vt(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,h])=>Re(h)).map(([h])=>h),o=Object.create(null),l=[],c=new Map(a.map((h,y)=>[h,y])),u=-1,p=!1,d=h=>{if(J(o,h))return o[h];let y=n[h];if(!Re(y))return J(r,h)?r[h]:void 0;let w=l.indexOf(h);if(w>=0){let g=[...l.slice(w),h].join(" -> ");throw new Error(`Computed variable cycle detected: ${g}`)}l.push(h);try{let g=xy(y.computed,b,h);return Gl(h,y.type,g),ro(o,h,g),g}finally{l.pop()}},f=h=>{if(J(o,h))return o[h];let y=n[h];if(!Re(y))return J(r,h)?r[h]:void 0;let w=c.get(h);if(i&&!p&&w!==void 0&&w>u){p=!0;try{for(let g=u+1;g<=w;g+=1)d(a[g]),u=g}finally{p=!1}return o[h]}return d(h)},m=new Proxy({},{get:(h,y)=>{if(typeof y=="string")return f(y)},has:(h,y)=>typeof y=="string"&&(J(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(h,y)=>{if(!(typeof y!="string"||!J(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),b={variables:m,runtime:t,resolveVariable:f};return i?(s.forEach(h=>{f(h)}),{...r,...o}):m},Ty=({variables:e={},runtime:t={},variableConfigs:n,projectData:i}={})=>{let a=n??i?.resources?.variables??{};return Vr(a),at({variables:e,runtime:t,variableConfigs:a,eager:!0})},zn=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([i,a])=>{if(Re(a))return;let r=fy(a,i);a.scope==="context"?ro(t,i,r):ro(n,i,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},Ft=(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(", ")}`)},Ut=(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(", ")}`)},Ly=2,Dl=12,Jl=(e=Ly)=>{if(!Number.isInteger(e)||e<0||e>Dl)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Dl}.`);return e},My=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},Fn=e=>typeof e=="number"&&Number.isFinite(e),Xn=(e,t,n,i,a={})=>{if(e==="number"){if(t==="set"&&!Fn(n))throw new Error(`Operation "set" requires value to be a number for variable "${i}".`);if(t==="multiply"&&!Fn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${i}".`);if(t==="divide"&&!Fn(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}".`);Jl(a.roundTo)}}},Gn=(e,t,n,i={})=>{let a=(s,o,l)=>{let c=s??o;if(!Fn(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 My(a(e,0,"current value")/r(n),Jl(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 ao=(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:py[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])},qy=(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},Dt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Vy=(e,t)=>{let n=e?.character?.sprite,i=t?.character?.sprite,a=Dt(n)?n:void 0,r=Dt(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},Tl=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},Ll=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Ml=(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,Fy=(e,t)=>{let n={},i=Ml(Tl(e),Tl(t)),a=Ml(Ll(e),Ll(t));return i&&(n.resource=i),a&&(n.color=a),Object.keys(n).length>0?n:null},lo=(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(d=>d.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=Fy(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=qy(e.dialogue,t.dialogue);s&&(n.dialogue=s);let o=Vy(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},co=(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},Uy=(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},ql=e=>e!==null&&typeof e=="object"?structuredClone(e):e,By=(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 ql(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=Uy(i,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return ql(r)},Yy={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"])},zy=(e,t)=>{let n=e[e.length-1];return n?Yy[n]?.has(t)===!0:!1},so=(e,t,n=[])=>Array.isArray(e)?e.map(i=>so(i,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,zy(n,i)?a:so(a,t,[...n,i])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?By(e,t,"_event"):Mr(e,t):e,Bt=(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 so(e,t)};var Xy=11102230246251565e-32,Ql=128,Zl=1e3,ec=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Yt=(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`)},Hn=(e,t)=>{if(!ec(e))throw new Error(`${t} must be an object`)},Kn=(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},Gy=(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},uo=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)},Hy=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),rc=e=>{let t=e??Hy();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}}},Ky=(e,t)=>{let n=4294967296-4294967296%t;for(let i=0;i<Ql;i+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${Ql} rejected samples`)},Wy=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},Jy=(e,t)=>{if(Yt(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=Kn(e.min,"random.distribution.min"),a=Kn(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 uo({type:"integer",value:a===1?n:n+Ky(t,a)})},Qy=(e,t)=>{if(Yt(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>Zl)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(Hn(c,p),Yt(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Hn(c.actions,`${p}.actions`),{weight:Gy(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<=Xy))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Wy(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 uo({type:"weighted",outcomeIndex:l})},tc=(e,{randomSource:t})=>{Hn(e,"random.distribution");let i={integer:Jy,weighted:Qy}[e.type];if(!i)throw new Error('random.distribution.type must be "integer" or "weighted"');return i(e,t)},Wn=(e,t)=>{if(Hn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Yt(e,new Set(["type","value"]),"random result"),Kn(e.value,"random result.value");else if(t==="weighted")Yt(e,new Set(["type","outcomeIndex"]),"random result"),Kn(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:Zl-1});else throw new Error(`unsupported recorded random result type: ${t}`);return uo(e)};var Fr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),ic=Object.freeze([Fr("cleanup",["clearPendingEffects","cleanAll"]),Fr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Fr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Fr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Fr("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"]),Fr("persistence",["saveSlot"]),Fr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),lt=new Map;ic.forEach(e=>{e.actions.forEach(t=>{if(lt.has(t))throw new Error(`duplicate action execution key: ${t}`);lt.set(t,lt.size)})});var Zy=new Set(ic.find(({name:e})=>e==="navigation").actions),nc=lt.get("saveSlot")-.5,sc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",eh=(e,t)=>e<t?-1:e>t?1:0,Jn=e=>Object.entries(e).sort((t,n)=>{let i=sc(...t),a=sc(...n),r=lt.get(i),s=lt.get(a),o=r??nc,l=s??nc;return o!==l?o-l:r!==void 0&&s!==void 0?0:eh(i,a)}),Qn=e=>Zy.has(e),Zn=e=>{let t=e.map(([n])=>n).filter(Qn);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var es=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ct=Object.freeze({volume:100,pan:0,playbackRate:1}),cc=["volume","pan","playbackRate"],rh=["src","startAt","endAt","startDelayMs"],oc=(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]},th=(e,t)=>e?.id===t?.id&&rh.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),nh=(e,t)=>JSON.stringify(e)===JSON.stringify(t),sh=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),ih=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.audioEffects.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},uc=(e,t)=>({...es(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}:{}}),oh=(e,t,n)=>{let i=uc(e,t);return i.value=i.value*n/100,es(i,"startValue")&&(i.startValue=i.startValue*n/100),i},ac=(e,t,n,i,a)=>{if(!e)return;let r=e.keyframes;if(r){if(r.some(o=>o.relative===!0))throw new Error(`[${a}.keyframes] Transition fade keyframes must use absolute values.`);if(t==="enter"&&r.at(-1)?.value!==100)throw new Error(`[${a}.keyframes] The final incoming transition fade value must be 100.`);let s=r.map(o=>oh(o,n,i));return t==="enter"&&(s.at(-1).value=i),{...t==="enter"?{initialValue:0}:{},keyframes:s}}return{...t==="enter"?{initialValue:0}:{},keyframes:[{value:t==="exit"?0:i,delay:(e.delay??0)/n,duration:e.duration/n,easing:e.easing??"linear"}]}},ah=({property:e,authored:t,speed:n,resourcePath:i})=>{let a=t.keyframes.at(-1);if(typeof a?.value!="number"||!Number.isFinite(a.value)||a.relative===!0)throw new Error(`[${i}.tween.${e}.keyframes] The final keyframe must use an absolute finite numeric value.`);return{keyframes:t.keyframes.map(r=>uc(r,n))}},pc=({bgm:e,resources:t={}})=>{let n=e?.audioEffects?.resourceId,i=t.audioEffects?.[n];if(i?.type!=="update"||(e.sounds??[]).length!==1)return e;let r=structuredClone(e),s=r.sounds[0];for(let o of cc){if(!es(i.tween,o))continue;let l=i.tween[o].keyframes.at(-1);typeof l?.value!="number"||!Number.isFinite(l.value)||l.relative===!0||(o==="volume"?(r.volume=l.value,s.volume=ct.volume):o==="pan"?(r.pan=l.value,s.pan=ct.pan):s.playbackRate=l.value)}return r},lc=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),fc=({occurrence:e,resources:t={},previousChannel:n,nextChannel:i})=>{if(!e?.selection)return null;let a=e.selection,r=e.actionPath??"bgm",s=a.resourceId,o=`resources.audioEffects.${s}`,l=t.audioEffects?.[s];if(!l)throw new Error(`[${r}.audioEffects.resourceId]
3
+ [${o}] Unknown audio effect resource "${s}".`);let c=ih(a,r),u=oc(n,r),p=oc(i,r);if(!u&&!p)return null;if(u&&p&&u.id!==p.id)throw new Error(`[${r}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let d=u?.id??p.id,f=th(u,p),m=nh(u,p);if(l.type==="transition"){if(f){if(m)return null;throw new Error(`[${r}.audioEffects]
4
+ [${o}] Audio effect resource "${s}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let h={},y=ac(u?l.prev?.fade:void 0,"exit",c,u?.volume??ct.volume,`${o}.prev.fade`),w=ac(p?l.next?.fade:void 0,"enter",c,p?.volume??ct.volume,`${o}.next.fade`);return y&&(h.exit=y),w&&(h.enter=w),Object.keys(h).length===0?null:{...lc(e,d),properties:{volume:h}}}if(l.type!=="update")throw new Error(`[${o}.type] Unsupported audio effect type "${l.type}".`);if(!u||!p||!f)throw new Error(`[${r}.audioEffects]
5
+ [${o}] Audio effect resource "${s}" has type "update", but the BGM action changes source identity. Use a transition resource.`);let b={};for(let h of cc){if(!es(l.tween,h))continue;let y=ah({property:h,authored:l.tween[h],speed:c,resourcePath:o}),w=p[h]??ct[h],g=y.keyframes.at(-1).value;if(!sh(g,w))throw new Error(`[${r}.audioEffects]
6
+ [${o}.tween.${h}.keyframes] The final keyframe value must match the persistent BGM ${h} value.`);y.keyframes.at(-1).value=w,(u[h]??ct[h])!==w&&(b[h]={update:y})}return Object.keys(b).length===0?null:{...lc(e,d),properties:b}};var ce=e=>structuredClone(Ae(e)?br(e):e),se=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),zt=e=>e?.animations?.playback?.continuity==="persistent",z=(e,t)=>se(e??{},t)&&e[t]!==void 0,rs=e=>z(e,"alpha")||z(e,"opacity"),lh=e=>z(e,"alpha")?e.alpha:e?.opacity,Ic=e=>(z(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),ch=e=>e?.applyMode==="persistent",uh="default",ph=e=>Array.isArray(e?.channels)?e.channels.filter(ch).map(ce):[],Xt=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ce(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},fh=e=>rs(e)||z(e,"blur")||z(e,"filters"),fo=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],vc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],po=["animationName","animationSpeed","loop"],dh=e=>z(e,"transformId")||z(e,"transform")||fo.some(t=>z(e,t)),kc=e=>e?.text&&z(e.text,"content")&&z(e.text,"textStyleId"),Ac=e=>e?.layout&&Array.isArray(e.layout.elements),mh=e=>z(e,"text")||z(e,"layout"),dc=(e,t)=>e.resourceId?!0:kc(e)?!t?.text:Ac(e)?!t?.layout:!1,mc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,yh=(e,t)=>{let n={...ce(e),...t};if(t.text&&e.text&&(n.text={...ce(e.text),...ce(t.text)}),t.transform&&e.transform&&(n.transform={...ce(e.transform),...ce(t.transform)}),z(t,"transform")){delete n.transformId;for(let i of fo)z(t,i)||delete n[i]}else z(t,"transformId")&&delete n.transform;return n},hh=(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(z(e,"text")&&!kc(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(z(e,"layout")&&!Ac(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},yc=e=>vc.some(t=>z(e,t)),hc=e=>po.some(t=>z(e,t)),gh=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let i of vc)!n&&!z(e,i)&&z(t,i)&&(e[i]=t[i]),se(e,i)&&e[i]===void 0&&delete e[i];return e},Pc=(e,t,n)=>{let i=e[n];return i?.id===t?.id?i:e.find(a=>a.id===t?.id)},bh=(e,t)=>{if(!t)return e;let n=z(e,"transform");for(let i of fo)!n&&!z(e,i)&&z(t,i)&&(e[i]=t[i]),se(e,i)&&e[i]===void 0&&delete e[i];return e},wh=(e,t)=>(t&&(!z(e,"opacity")&&z(t,"opacity")&&(e.opacity=t.opacity),!z(e,"blur")&&z(t,"blur")&&(e.blur=ce(t.blur)),!z(e,"filters")&&z(t,"filters")&&(e.filters=ce(t.filters)),se(e,"opacity")&&e.opacity===void 0&&delete e.opacity,se(e,"blur")&&e.blur===void 0&&delete e.blur,se(e,"filters")&&e.filters===void 0&&delete e.filters),e),Ec=(e,t,n=[],{hasPatchFn:i=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let r=e.map((s,o)=>{let l=Pc(n,s,o),c=t(s,l),u=fh(s),p=dh(s),d=i(s),f=se(s,"animations"),m=Ic(ce(s));if(!c&&(u||p||d)&&l&&(m=a?a(l,m):{...ce(l),...m}),!f){let b=l?t(l):!1,h=t(m);b&&h&&zt(l)?m.animations=ce(l.animations):delete m.animations}return wh(bh(m,l),l)}).filter(s=>t(s)||s.animations);return{hasValidItems:r.length>0,processedItems:r}},Ih=e=>{if(e){if(e.character&&se(e.character,"name"))return e.character.name;if(se(e,"characterName"))return e.characterName}},xc=e=>!!e?.character&&se(e.character,"sprite"),vh=e=>{let t={},n=!1,i=Ih(e);return i!==void 0&&(t.name=i,n=!0),xc(e)&&(t.sprite=ce(e.character.sprite),n=!0),n?t:void 0},gc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},bc=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>se(t,"persistSprite")?t.persistSprite===!0:se(e,"persistSprite")?e.persistSprite===!0:n&&!se(t,"characterId"),wc=({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 se(c,"name")?o.name=c.name:(i&&!n||u)&&se(l,"name")&&(o.name=ce(l.name)),se(c,"sprite")?o.sprite=ce(c.sprite):(a||p)&&se(l,"sprite")&&(o.sprite=ce(l.sprite)),Object.keys(o).length>0?o:void 0},kh=({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=>ce(a)):delete e.initialRevealedContent,e.content=[...i,...t]},Ah=()=>({}),Ph=(e,t)=>{if(!t.screen)return;let n=rs(t.screen),i=z(t.screen,"blur"),a=se(t.screen,"animations");if(!n&&!i){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=lh(t.screen):z(r,"opacity")&&(s.opacity=r.opacity),i?s.blur=ce(t.screen.blur):z(r,"blur")&&(s.blur=ce(r.blur)),se(s,"opacity")&&s.opacity===void 0&&delete s.opacity,se(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},Eh=(e,t)=>{if(t.background){let n=z(t.background,"resourceId"),i=z(t.background,"colorId"),a=rs(t.background),r=z(t.background,"blur"),s=z(t.background,"filters"),o=z(t.background,"transformId"),l=yc(t.background),c=hc(t.background),{animationsOnly:u,state:p}=Xt(t.background,m=>z(m,"resourceId")||z(m,"colorId")||rs(m)||z(m,"blur")||z(m,"filters")||z(m,"transformId")||yc(m)||hc(m));if(u){e.background=e.background?{...ce(e.background),...p}:p;return}if(!n&&!i&&!a&&!r&&!s&&!o&&!l&&!c){delete e.background;return}let d=e.background,f=Ic(ce(t.background));if(!n&&d?.resourceId){f.resourceId=d.resourceId,!se(f,"transformId")&&d.transformId&&(f.transformId=d.transformId);for(let m of po)!z(f,m)&&z(d,m)&&(f[m]=d[m])}gh(f,d,{hasAuthoredTransformId:o}),!i&&d?.colorId&&(f.colorId=d.colorId),!a&&z(d,"opacity")&&(f.opacity=d.opacity),!r&&z(d,"blur")&&(f.blur=ce(d.blur)),!s&&z(d,"filters")&&(f.filters=ce(d.filters)),se(f,"resourceId")&&f.resourceId===void 0&&delete f.resourceId,se(f,"colorId")&&f.colorId===void 0&&delete f.colorId,se(f,"animations")&&f.animations===void 0&&delete f.animations,se(f,"transformId")&&f.transformId===void 0&&delete f.transformId,se(f,"opacity")&&f.opacity===void 0&&delete f.opacity,se(f,"blur")&&f.blur===void 0&&delete f.blur,se(f,"filters")&&f.filters===void 0&&delete f.filters;for(let m of po)se(f,m)&&f[m]===void 0&&delete f[m];if(!f.resourceId&&!f.colorId){delete e.background;return}d?.resourceId===f.resourceId&&d?.transformId===f.transformId&&!se(f,"animations")&&zt(d)&&(f.animations=ce(d.animations)),e.background=f}else e.background?.animations&&!zt(e.background)&&(e.background.animations={})},xh=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(gc(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=bc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=wc({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}=Xt(t.dialogue.ui,d=>!!d.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&&kh({dialogueState:e.dialogue,content:t.dialogue.content,append:i}),se(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=se(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=bc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});se(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=se(t.dialogue,"characterId"),o=vh(t.dialogue),l=xc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!i&&delete e.dialogue.characterId;let c=wc({previousCharacter:e.dialogue.character,characterFields:o,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:se(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:i});if(c?e.dialogue.character=c:delete e.dialogue.character,l||gc(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)}},Sh=(e,t)=>{let n=ph(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!==uh);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(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(ce(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},Oh=(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=pc({bgm:ce(t.bgm),resources:n}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},Rh=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{hh(r,Pc(n,r,s))});let{hasValidItems:i,processedItems:a}=Ec(t.visual.items,dc,n,{hasPatchFn:mh,mergeItemFn:yh});i?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!dc(n)||!zt(n))?{...n,animations:{}}:n))},$h=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!mc(a)||!zt(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:i}=Ec(t.character.items,mc,e.character?.items||[]);n?e.character={items:i}:delete e.character},Ch=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},_h=(e,t)=>{if(t.layout){let{animationsOnly:n,state:i}=Xt(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},jh=(e,t)=>{if(t.choice){let{animationsOnly:n,state:i}=Xt(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},Nh=(e,t)=>{if(t.form){let{animationsOnly:n,state:i}=Xt(t.form,a=>!!a.resourceId);if(n){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},Dh=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},Th=(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=ce(t.voice)}else e.voice&&delete e.voice},Lh=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},Ur=(e,{resources:t}={})=>Bn(Ah,[Lh,Ph,Eh,Sh,(a,r)=>Oh(a,r,t),Rh,xh,$h,Ch,_h,jh,Nh,Dh,Th])(e);var ut=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Mr(e,t);return n&&typeof n=="object"?e:n};var Mh=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"}}),Ar=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}),Gt=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),qh=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"}),mo=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Sc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),yo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Oc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Vh=(e,t)=>{let n=qh[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}"`)},ts=(e,t)=>{if(Vh(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},ho=(e={})=>{let t=e?.config;if(t===void 0)return{...Ar};if(!Oc(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{...Ar};if(!Oc(i))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(Sc),r=Object.keys(i).find(o=>!a.has(o));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...Ar};return Sc.forEach(o=>{i[o]!==void 0&&(s[o]=ts(o,i[o]))}),s},Fh=(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]}},Pr=e=>Object.fromEntries(Object.entries(Mh).map(([t,n])=>{let i=Fh(e,n.source),a=i!==void 0?i:Ar[t]??Gt[t];return[t,a]})),Ze=(e,t)=>Pr(e)[t],Rc=(e={})=>Object.fromEntries(mo.map(t=>[t,e[t]??Ar[t]]));var pt=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}),cr=Object.freeze({BEHIND_BACKGROUND:pt.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:pt.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:pt.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:pt.VISUAL_BEHIND_CHOICE,FOREGROUND:pt.VISUAL_FOREGROUND}),go=cr.BEHIND_DIALOGUE,bo=Object.freeze(Object.values(cr).sort((e,t)=>e-t));var Uh={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:ao},Bh=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,Ht=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return Ht(t);let[n]=Object.keys(t),i=Bh.exec(n);if(!i)return Ht(t);let[,a,r,s]=i,o=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[o]:Ht(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Ht(n)])),ur=(e,t)=>{let n={functions:Uh};return Mr(Ht(e),t,n)},Yc=({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".`)},Yh=({id:e,targetId:t,animation:n,playback:i,animationPath:a="animation"})=>{let r=structuredClone(n);if(Yc({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,i!==void 0){let s=Hh(i,`${a}.playback`);if(s!==void 0){let o=s.loop===!0?Kc(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&&(!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},zh=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return Yc({animationType:e.type,animationId:t,animationPath:n}),e.type},Xh=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Gh=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Hh=(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},Kh=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},He=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),zc=(e={})=>He(e,"alpha")&&typeof e.alpha=="number"?e.alpha:He(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,Xc=e=>e?.playback?.continuity==="persistent",xo=e=>Array.isArray(e)?e.map(xo):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=xo(e[n]),t),{}),os=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(xo(t))},Gc=(e=[])=>e.filter(t=>Xc(t)).map(t=>structuredClone(t)),Hc=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,n)=>{let i=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return t+i},0):0,wo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,Hc(n)),0),Kc=e=>Math.max(wo(e?.tween),wo(e?.prev?.tween),wo(e?.next?.tween),Hc(e?.mask?.progress)),Wc=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Kc(e)/Kh(e),Wh=e=>e.some(t=>t?.playback?.loop===!0),$c=({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(os).filter(Boolean));return e.some(i=>{if(!Xc(i))return!1;let a=os(i);return a?n.has(a):!1})},Ke=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:Wh(e)||r&&!t||$c({animationInstances:e,activePersistentAnimations:i})?!0:r?!1:$c({animationInstances:e,activePersistentAnimations:a}),Jc=(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 He(s??{},"animations")},Jh=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Qh=(e,t)=>{if(Jh(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Zh=({resources:e,animationId:t,playback:n,instanceId:i,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=e?.animations?.[t];return s?Yh({id:i,targetId:a,animation:s,playback:n,animationPath:r}):null},So=(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},eg=({content:e,path:t,variables:n})=>So(e,t).reduce((i,a)=>{let r=ut(a.text,{variables:n});return i+`${r??""}`.length},0),Cc=(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))},_c=(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("-")}`},dt=(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=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},rg=(e,t={})=>{if(!t?.transformId)return;let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for background`);return n},tg=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],ng=(e={})=>tg.some(t=>He(e,t)),Qc=(e={},t)=>{if(t){if(e.images?.[t])return"sprite";if(e.videos?.[t])return"video";if(e.spritesheets?.[t])return"spritesheet-animation";if(e.layouts?.[t])return"container"}},ss=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},sg=(e={})=>e.textStyles||{},ig=(e={})=>e.images||{},og=.5,ag=(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]},Do=({id:e,resourceId:t,spritesheet:n,animationName:i,animationSpeed:a,loop:r,width:s,height:o,transform:l={}}={})=>{let c=ag(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??og,loop:r??u.loop??!0}}},Zc=({id:e,item:t,resources:n={}}={})=>{let i=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=n.spritesheets?.[t.resourceId];if(a)return Do({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}`)},lg=(e={})=>e.colors||{},cg=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Wt=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,mt=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},Io=(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},vo=(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},cs=(e,t)=>{if(typeof e!="string"||!cg.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},jc=(e,t,n)=>{let i=cs(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})`},ug=(e={},t)=>{let n=sg(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=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=e.colors?.[n.colorId];if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=Io(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:jc(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=e.colors?.[n.strokeColorId];if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${t}"`);let c=Io(n.strokeAlpha,"strokeAlpha",t);o.strokeColor=jc(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=e.colors?.[n.shadow.colorId];if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${t}"`);o.shadow={color:cs(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:Io(n.shadow.alpha,"shadow.alpha",t),blur:vo(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:vo(n.shadow.offsetX,"offsetX",t,2),offsetY:vo(n.shadow.offsetY,"offsetY",t,2)}}return o},yt=e=>Array.isArray(e)?e.map(yt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,yt(n)])),Oo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Oo(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]=yt(r);continue}a!=="textStyleId"&&(i[a]=Oo(r,t,Wt(n,a)))}return e.textStyleId!==void 0&&(mt(e.textStyleId,n,"textStyleId"),i.textStyle=ug(t,e.textStyleId)),i},To=(e={},t)=>{let n=lg(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return cs(n.hex,`Color "${t}"`)},eu=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",ko=(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 ${eu(`${t}.fill`)} instead`)},pg=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Jt(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let i={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(i[a]=Jt(r,t,Wt(n,a)));return e.colorId!==void 0&&(mt(e.colorId,n,"colorId"),i.fill=To(t,e.colorId)),i},Jt=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Jt(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 ${eu("fill")} instead`);ko(e,"hover",n),ko(e,"click",n),ko(e,"rightClick",n)}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=yt(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){i[a]=pg(r,t,Wt(n,a));continue}i[a]=Jt(r,t,Wt(n,a))}}return e.type==="rect"&&e.colorId!==void 0&&(mt(e.colorId,n,"colorId"),i.fill=To(t,e.colorId)),i},Ao=(e={},t)=>{let n=ig(e)?.[t];return n||null},ru=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Nc=(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 ${ru(`${t}.${i}`)} instead`)},Dc=(e,t,n)=>{let i=e[t];e[t]={...i&&typeof i=="object"&&!Array.isArray(i)?i:{},src:n}},Ro=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Ro(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 ${ru(a)} instead`);Nc(e,"hover",n,"src"),Nc(e,"click",n,"src")}let i={};for(let[a,r]of Object.entries(e)){if(a==="filters"){i[a]=yt(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(i[a]=Ro(r,t,Wt(n,a)))}if(e.type==="sprite"&&e.imageId!==void 0){mt(e.imageId,n,"imageId");let a=Ao(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&&(mt(e.hoverImageId,n,"hoverImageId"),Dc(i,"hover",Ao(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(mt(e.clickImageId,n,"clickImageId"),Dc(i,"click",Ao(t,e.clickImageId)?.fileId??e.clickImageId)),i},fg=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),is=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>is(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=yt(e),i=typeof e.type=="string";(i||t)&&He(e,"opacity")&&(He(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])He(e,a)&&(n[a]=is(e[a]));for(let[a,r]of Object.entries(e))fg(a)&&(n[a]=is(r,{isElementPatch:i||t}));return n},Lo=(e,t={},n="root")=>is(Ro(Jt(Oo(e,t,n),t,n),t,n)),pr=Lo,Yr=(e=[])=>e.find(t=>t.id==="story"),dg="#000000",$o="bg-cg-background-color",mg=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?cs(n?.backgroundColor??dg,"screen.backgroundColor"):To(e,t.colorId),tu=(e={})=>zc(e),yg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Mo=(e={})=>Array.isArray(e.filters)?e.filters:void 0,Tc=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=tu(e),i=yg(e),a=Mo(e),r={};return(t||n!==void 0)&&(r.alpha=n??1),i&&(r.blur=i),a&&(r.filters=a),r},hg=(e={})=>zc(e),gg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},nu=(e={})=>{let t=hg(e),n=gg(e),i={};return t!==void 0&&(i.alpha=t),n&&(i.blur=n),i},Br=(e={})=>{let t=nu(e),n=Mo(e);return n&&(t.filters=n),t},Lc=(e,t,n,i)=>{let a=t[n]??e[n];return t[i]??e[i]??!1?(a??1)*-1:a},er=(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:Lc(e,t,"scaleX","flipX"),scaleY:Lc(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},bg=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],qo=(e={})=>e.text&&He(e.text,"content")&&He(e.text,"textStyleId"),Vo=(e={})=>e.layout&&Array.isArray(e.layout.elements),Mc=(e={})=>{if(e.resourceId)return e.resourceId;if(qo(e))return"text";if(Vo(e))return"inline-layout"},qc=(e,t={})=>typeof e=="string"?t.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?t.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return 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:t.images?.[i]?.fileId??i}}return typeof n.src=="string"?{...n,src:t.images?.[n.src]?.fileId??n.src}:n})}:e,wg=({item:e,particle:t,resources:n})=>{let i=dt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=qc(r,n)),a.texture!==void 0&&(a.texture=qc(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...er(i,e)};return Object.assign(s,Br(e)),s},Ig=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&&!qo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Vo(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of bg)if(He(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},vg=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:i=!1})=>{let a={id:$o,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:mg({resources:e,background:t,screen:n})};if(i){let r=tu(t);r!==void 0&&(a.alpha=r);let s=Mo(t);s&&(a.filters=s)}return a},kg=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,Vc=({resources:e={},resourceId:t,colorId:n})=>{let i=Qc(e,t);return t&&(i||n===void 0)?{resourceId:t,targetId:ss({resourceId:t,kind:i})}:n!==void 0?{resourceId:$o,targetId:$o}:{resourceId:void 0,targetId:void 0}},su=100,Er=su,Ag="channel:bgm",Pg="channel:music-room",Eg="music-room:player",xg="channel:voice",Sg="default",Og=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Kt=(...e)=>e.map(Og).join(":"),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)})},iu=(e,t)=>e*t/su,Fo=(e={},t)=>e?.[t]??Ar[t],Uo=(e={},t,n=Er)=>iu(n,Fo(e,t)),us=({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},ns=(e,t,n,i)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:i,Rg=["muted","pan","playbackRate","startAt","endAt"],ps=({id:e,sound:t,resource:n,defaultLoop:i=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:ns(t,n,"loop",i),volume:ns(t,n,"volume",Er),startDelayMs:ns(t,n,"startDelayMs",0)};Rg.forEach(s=>{let o=ns(t,n,s,void 0);o!==void 0&&(a[s]=o)}),t.playback!==void 0&&(a.playback=structuredClone(t.playback));let r=a.startAt??0;if(a.endAt!==void 0&&a.endAt!==null&&a.endAt<r)throw new Error(`Sound "${e}" endAt (${a.endAt}) must be greater than or equal to startAt (${r}).`);return a},$g=e=>Math.max(-1,Math.min(1,e)),Cg=({node:e,bgm:t,sound:n,resource:i,usesLegacySound:a})=>{a||(e.volume=iu(t.volume??Er,e.volume??Er));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=$g((t.pan??0)+(e.pan??0))),e},ze=({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:d,canRollback:f,confirmDialog:m,form:b,historyDialogue:h=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:g,skipTransitionsAndAnimations:E}={})=>{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??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},P=Tg({dialogueState:s,includeInactiveAdvDialogue:o,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:n,sceneReplay:i,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:d,canRollback:f,confirmDialog:m,form:b,historyDialogue:h,characters:y};return P&&(v.dialogue=P,v.dialogueLines=P.lines),v},Fc=100,ls=(e,t)=>{if(Array.isArray(e))return e.map(i=>ls(i,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(i=>{n[i]=ls(n[i],t)}),n.type==="text-revealing"?t(n):n},_g=e=>ls(e,t=>({...t,revealEffect:"none"})),jg=e=>ls(e,t=>{let n=Number(t.speed??t.displaySpeed),i=Number.isFinite(n)?Math.max(n,Fc):Fc;return{...t,speed:i,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:i}:{}}}),xr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:i=!1}={})=>t||i?_g(e):n?jg(e):e,ou=({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:{}}}}),Co=e=>{if(Array.isArray(e))return e.map(Co);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Co(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}}:{}}}}},Ng=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Uc="submit",Po=(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}}},_o=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>_o(c,t,n));if(!e||typeof e!="object")return e;let i=typeof e.type=="string",a=i&&e.formRole===Uc,r=i&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},o={};for(let[c,u]of Object.entries(e))o[c]=_o(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:Po(l.change,u),submit:Po(l.submit,t.submitActions)}}}return l.formRole===Uc||r?{...l,click:Po(l.click,t.submitActions,{replaceActions:!0})}:l},jo=(e,t)=>{if(Array.isArray(e))return e.map(i=>jo(i,t));if(!e||typeof e!="object")return e;let n={};for(let[i,a]of Object.entries(e))n[i]=jo(a,t);for(let i of Ng){let a=n[i]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[i]={...n[i],payload:{...a,_interactionSource:"form"}})}return n},No=({characterId:e,character:t,characterName:n,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0,s=Yn({characterId:e,character:t,characterName:n,characters:i,variables:a});return{...r||{},...t||{},name:s}},au=(e=[],t={},n={})=>e.map(i=>{let a=No({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}}),Dg=e=>!(!e||e.mode==="adv"&&e.content===void 0),Tg=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:i,runtime:a}={})=>{if(!t&&!Dg(e))return;let r=e.content===void 0?[{text:""}]:So(e.content,"dialogue.content"),s=e.content===void 0?0:eg({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:i}),o=a?.dialogueTextSpeed??Ar.dialogueTextSpeed,l=e.textSpeed??o,c=(e.lines||[]).map((p,d)=>{let f=So(p.content,`dialogue.lines[${d}].content`),m=No({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:i});return{...p,textSpeed:p.textSpeed??o,content:f.map(b=>({...b,text:ut(b.text,{variables:i})})),character:m,characterName:m.name}}),u=No({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:ut(p.text,{variables:i})})),initialRevealedCharacters:s,lines:c}},Bo=({container:e,resources:t,templateData:n,isLineCompleted:i=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=ur(e,n);return pr(xr(s,{isLineCompleted:i,skipMode:a,skipTransitionsAndAnimations:r}),t)},Eo=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),Bc=({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:Eo(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[i].keyup={payload:Eo(a.keyup)});return}e[i]={...r,[n]:{payload:Eo(a)}}})},Lg=(e={},t={})=>{let n={};return Bc({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Bc({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},fr=({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:w})=>{let g=Zh({resources:t,animationId:f,playback:m,instanceId:y,targetId:w,animationPath:s});g&&l.push(g)},u=n!=null&&n!==!1,p=i!=null&&i!==!1,d=a&&r&&a===r;Qh(e,s);let f=Xh(e),m=Gh(e),b=t?.animations?.[f],h=zh(b,{animationId:f,animationPath:s});if(h==="update")return p&&r?c({instanceId:`${o}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${o}-animation-update`,targetId:a}),l;if(h==="transition"){let y=`${o}-animation-transition`,w=m?.continuity==="persistent"?y:`${o}-animation-in`;if(u&&p&&d)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${o}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},Mg=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),qg=(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:d,activePersistentAnimations:f,restoredPersistentAnimations:m,autoMode:b,skipMode:h,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:E,saveSlots:k=[]})=>{let{elements:P,animations:v}=e;if(t.background){let O=i===void 0?!0:He(i?.background??{},"animations"),L=P.find(ie=>ie.id==="story");if(!L)return e;let $=rg(a,t.background),D=$||ng(t.background),U=n?.background?.resourceId,_=n?.background?.colorId,G=t.background.resourceId??(t.background.animations?U:void 0),ae=t.background.colorId??(t.background.animations?_:void 0),M=kg(a,G),Q={...t.background,colorId:ae};if((ae!==void 0||M)&&L.children.push(vg({resources:a,background:Q,screen:r,includeAlpha:!M})),G){let{images:ie={},videos:K={},spritesheets:pe={}}=a,oe=Qc(a,G),C;if(oe==="sprite"?C=ie[G]:oe==="video"?C=K[G]:oe==="spritesheet-animation"&&(C=pe[G]),C){let j=oe==="video",F=oe==="spritesheet-animation",W={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...$},fe={...Tc(t.background,{includeDefaultAlpha:!0}),...er(W,t.background)},Se;F?Se=Do({id:ss({resourceId:G,kind:oe}),resourceId:G,spritesheet:C,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:fe}):Se={id:ss({resourceId:G,kind:oe}),type:j?"video":"sprite",src:C.fileId,width:C.width,height:C.height,...fe},j&&(Se.loop=t.background.loop??!1,Se.volume=C.volume??50),Se&&L.children.push(Se)}}if(G){let{layouts:ie={}}=a,K=ie[G];if(K){let pe={id:ss({resourceId:G,kind:"container"}),type:"container",children:K.elements,...Tc(t.background)};D&&Object.assign(pe,er({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...$},t.background));let oe=ur(pe,ze({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:d,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:b,skipMode:h,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:E,characters:a.characters||{},skipTransitionsAndAnimations:o}));L.children.push(pr(xr(oe,{isLineCompleted:s,skipMode:h,skipTransitionsAndAnimations:o}),a))}}let le=Vc({resources:a,resourceId:U,colorId:_}),X=Vc({resources:a,resourceId:G,colorId:ae}),Z=fr({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:X.resourceId,previousTargetId:le.targetId,currentTargetId:X.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ke({animationInstances:Z,isLineCompleted:s,skipTransitionsAndAnimations:o,activePersistentAnimations:f,restoredPersistentAnimations:m,isAuthoredOnCurrentLine:O})&&v.push(...Z)}return e},Vg=(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(w=>w.id==="story");if(!p)return e;let d=t.character.items||[],f=n?.character?.items||[],m=Cc(d),b=Cc(f),h=new Map,y=new Map;for(let w=0;w<f.length;w++){let g=f[w],E=h.get(g.id)??[];E.push(w),h.set(g.id,E)}for(let w=0;w<d.length;w++){let g=d[w],{transformId:E,sprites:k}=g,P=y.get(g.id)??0;y.set(g.id,P+1);let v=h.get(g.id)?.[P]??-1,O=f[v],L=O?.sprites&&O.sprites.length>0,$=k&&k.length>0,D=v>=0?_c(O,v,b):void 0,U=$?_c(g,w,m):void 0,_=Jc(i,"character",g.id,w,d),G=fr({animationsDef:g.animations,resources:a,previousResourceId:D,currentResourceId:U,previousTargetId:D,currentTargetId:U,animationPath:`character.items[${w}].animations`,idPrefix:U??D??`character-${w}`});if(g.animations&&!k&&!E&&L&&Ke({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})){u.push(...G);continue}if(g.animations&&!k&&!E)continue;if(!k||k.length===0||!E){console.warn("Character item missing sprites or transformId:",g);continue}let ae=a.transforms[E];if(!ae){console.warn("Transform not found:",E);continue}let M={type:"container",id:U,...er(ae,g),...Br(g),children:[]};for(let Q of k){let le=Zc({id:`${U}-${Q.id}`,item:Q,resources:a});le&&M.children.push(le)}p.children.push(M),Ke({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})&&u.push(...G)}}return e},lu=(e,t)=>{if(!bo.includes(e))throw new Error(`${t} must be one of: ${bo.join(", ")}.`)},Fg=(e,t)=>{let n=!!e.resourceId||qo(e)||Vo(e),i=e.layer??(n?void 0:t?.layer)??go;return lu(i,`Visual item "${e.id}" layer`),i},Ug=(e,{presentationState:t,previousPresentationState:n,currentLineActions:i,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:m,skipMode:b,isChoiceVisible:h,isFormVisible:y,canRollback:w,form:g,saveSlots:E=[],visualLayer:k})=>{let{elements:P,animations:v}=e;if(t.visual&&a){let O=P.find(U=>U.id==="story");if(!O)return e;let L=t.visual.items,$=n?.visual?.items||[],D=ze({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:E,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:b,isChoiceVisible:h,isFormVisible:y,canRollback:w,form:g,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&lu(k,"visualLayer");for(let[U,_]of L.entries()){let G=$.find(K=>K.id===_.id),ae=Jc(i,"visual",_.id,U,L),M=Fg(_,G);if(k!==void 0&&M!==k)continue;if(Ig(_),_.layout){let K=dt(a,_),pe={id:`visual-${_.id}`,type:"container",children:structuredClone(_.layout.elements),...er(K,_)};Object.assign(pe,Br(_)),O.children.push(Bo({container:pe,resources:a,templateData:D,isLineCompleted:r,skipMode:b,skipTransitionsAndAnimations:s}))}if(_.text){let K=dt(a,_),pe={...structuredClone(_.text),id:`visual-${_.id}`,type:"text",...er(K,_)};Object.assign(pe,Br(_)),O.children.push(pr(ur(pe,D),a))}if(_.resourceId){let{images:K={},videos:pe={},spritesheets:oe={}}=a,C=oe[_.resourceId];if(C){let j=dt(a,_),F=Br(_),W=Do({id:`visual-${_.id}`,resourceId:_.resourceId,spritesheet:C,animationName:_.animationName,animationSpeed:_.animationSpeed,loop:_.loop,width:_.width,height:_.height,transform:{...er(j,_),alpha:F.alpha??_.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});W&&O.children.push(structuredClone(W))}else{let j=K[_.resourceId]||pe[_.resourceId];if(j){let F=pe[_.resourceId]!==void 0,W=dt(a,_),fe={id:`visual-${_.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...er(W,_)};Object.assign(fe,Br(_)),F&&(fe.loop=j.loop??!1,fe.volume=j.volume??50),O.children.push(fe)}}}let Q=!!(a.spritesheets?.[_.resourceId]||a.images?.[_.resourceId]||a.videos?.[_.resourceId]);if(_.resourceId&&!Q){let K=a.particles?.[_.resourceId];K&&O.children.push(wg({item:_,particle:K,resources:a}))}let le=!!a.particles?.[_.resourceId];if(_.resourceId&&!Q&&!le){let{layouts:K={}}=a,pe=K[_.resourceId];if(pe){let oe=dt(a,_),C={id:`visual-${_.id}`,type:"container",children:structuredClone(pe.elements),...er(oe,_)};Object.assign(C,Br(_));let j=ur(C,D);O.children.push(pr(xr(j,{isLineCompleted:r,skipMode:b,skipTransitionsAndAnimations:s}),a))}}let X=Mc(G),Z=Mc(_),ie=fr({animationsDef:_.animations,resources:a,previousResourceId:X,currentResourceId:Z,previousTargetId:X?`visual-${_.id}`:void 0,currentTargetId:Z?`visual-${_.id}`:void 0,animationPath:`visual.items[${_.id}].animations`,idPrefix:_.id});Ke({animationInstances:ie,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:ae})&&v.push(...ie)}}return e},ft="dialogue-character-sprite",Bg=(e,{presentationState:t,previousPresentationState:n,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:o}=e,l=Yr(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=Dt(c),d=Dt(u),f=fr({animationsDef:c?.animations,resources:i,previousResourceId:d?ft:void 0,currentResourceId:p?ft:void 0,previousTargetId:d?ft:void 0,currentTargetId:p?ft:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&d&&Ke({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...f),e;let m=i.transforms?.[c.transformId];if(!m)return console.warn("Transform not found:",c.transformId),e;let b={type:"container",id:ft,...er(m),children:[]};for(let h of c.items){let y=Zc({id:`${ft}-${h.id}`,item:h,resources:i});y&&b.children.push(y)}return l.children.push(b),Ke({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...f),e},Yg=(e,{presentationState:t,previousPresentationState:n,resources:i={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:d,skipTransitionsAndAnimations:f,variables:m,imageGallery:b,musicRoom:h,sceneReplay:y,runtime:w,activePersistentAnimations:g,saveSlots:E=[]})=>{let{elements:k,animations:P}=e;if(!t.dialogue||a)return e;let v=k.find(L=>L.id==="story");if(!v)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:L={}}=i,$=L[t.dialogue.ui.resourceId];if($){let D={elements:$.elements},U=ze({variables:m,imageGallery:b,musicRoom:h,sceneReplay:y,runtime:w,saveSlots:E,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:d,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,characters:i.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:f}),_=ur(D,U),G=pr(xr(_?.elements,{isLineCompleted:d,skipMode:s,skipTransitionsAndAnimations:f}),i);if(Array.isArray(G))for(let ae of G)v.children.push(ae);else G&&v.children.push(G)}}Bg(e,{presentationState:t,previousPresentationState:n,resources:i,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:g});let O=fr({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 Ke({animationInstances:O,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:g})&&P.push(...O),e},zg=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:b,canRollback:h,form:y,activePersistentAnimations:w,saveSlots:g=[]})=>{let{elements:E,animations:k}=e;if(t.choice&&i){let P=Yr(E);if(!P)return e;let v=i?.layouts?.[t.choice.resourceId];if(v&&v.elements){let L={elements:v.elements},$=ur(L,{...ze({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m??!!t.choice,isFormVisible:b,canRollback:h,form:y,characters:i.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),D=Co(pr(xr($?.elements,{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:s}),i));if(Array.isArray(D))for(let U of D)P.children.push(U);else D&&P.children.push(D)}let O=fr({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"});Ke({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...O)}return e},Xg=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:b,canRollback:h,activePersistentAnimations:y,saveSlots:w=[],form:g})=>{let{elements:E,animations:k}=e;if(!g?.resourceId||!i)return e;let P=Yr(E);if(!P)return e;let v=i?.layouts?.[g.resourceId];if(!v)return console.warn(`Form layout not found: ${g.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},L={...ze({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:b,canRollback:h,characters:i.characters||{},skipTransitionsAndAnimations:s,form:g}),form:g},$=ur(O,L),D=jo(pr(xr(_o($,g),{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:s}),i),g);D&&P.children.push(D);let U=fr({animationsDef:g.animations,resources:i,previousResourceId:n?.form?.resourceId,currentResourceId:g.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:g.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return Ke({animationInstances:U,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&k.push(...U),e},Gg=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:b=[],skipTransitionsAndAnimations:h})=>{if(!t.control?.resourceId)return e;let y=n.controls?.[t.control.resourceId];if(!y)return e;let w=Lg(y.keyboard,y.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(y.elements)||y.elements.length===0)return e;let g=Yr(e.elements);if(!g)return e;let E={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return g.children.push(Bo({container:E,resources:n,templateData:ze({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:n.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:h})),e},Yo=({presentationState:e,resources:t={},runtime:n,variables:i,musicRoomPlayer:a})=>{if(e?.bgm&&t){let r=e.bgm,s=!Array.isArray(r.sounds),o=s?r.resourceId?[{id:"default",resourceId:r.resourceId,loop:r.loop??!0,volume:r.volume,startDelayMs:r.startDelayMs??0}]:[]:r.sounds,l=!s&&r.loop===!0,c=[];if(s||as(o,"BGM sound"),l){let p=o.find(d=>d.loop===!0);if(p)throw new Error(`BGM sound "${p.id}" cannot loop inside a looping BGM channel.`)}if(o.forEach(p=>{let d=t.sounds?.[p.resourceId];if(!d)return;let f=l?{...p,loop:p.loop??!1}:p;c.push(Cg({node:ps({id:Kt("bgm",s?"default":p.id),sound:f,resource:d,defaultLoop:!l}),bgm:r,sound:f,resource:d,usesLegacySound:s}))}),c.length===0)return null;let u=ze({variables:i,runtime:n}).runtime;return us({id:Ag,volume:Fo(u,"musicVolume"),muted:!1,pan:0,loop:s?void 0:r.loop,playback:a?.bgmPlayback,interruption:r.interruption,children:c,runtime:u})}return null},Hg=(e,t)=>{if(!Yr(e.elements))return e;let i=Yo(t);return i&&e.audio.push(i),e},Kg=(e,{activeAudioEffect:t,skipTransitionsAndAnimations:n})=>(t&&!n&&(e.audioEffects=[structuredClone(t)]),e),Wg=(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?t.sounds?.[s.soundId]:void 0;if(!s||!o)return e;let l=ze({variables:i,runtime:n}).runtime,c=ps({id:Eg,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:o});return e.audio.push(us({id:Pg,volume:Uo(l,"musicVolume",Er),children:[c],runtime:l})),e},Jg=(e,{presentationState:t,resources:n,runtime:i})=>{let{audio:a}=e;if(t.sfx&&n){let r=t.sfx,s=Array.isArray(r.channels)?r.channels:[],o=s.map(l=>({channel:l,usesLegacyChannel:!1}));as(s,"SFX channel"),Array.isArray(r.items)&&o.push({channel:{id:Sg,sounds:r.items},usesLegacyChannel:!0}),o.forEach(({channel:l,usesLegacyChannel:c})=>{let u=!c&&l.loop===!0,p=[];if(c||as(l.sounds,"SFX sound",`SFX channel "${l.id}"`),u){let d=l.sounds.find(f=>f.loop===!0);if(d)throw new Error(`SFX sound "${d.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((d,f)=>{let m=n.sounds?.[d.resourceId];if(!m)return;let b=u?{...d,loop:d.loop??!1}:d;p.push(ps({id:c?Kt("sfx","default",f,d.id):Kt("sfx",l.id,d.id),sound:b,resource:m,defaultLoop:u?!1:void 0}))}),p.length!==0&&a.push(us({id:Kt("channel","sfx",l.id),volume:Uo(i,"soundVolume",l.volume??Er),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:c?void 0:l.interruption,children:p,runtime:i}))})}return e},Qg=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},Zg=(e,{presentationState:t,resources:n,currentSceneId:i,runtime:a,variables:r})=>{let{audio:s}=e;if(!t?.voice)return e;let o=t.voice,l=!Array.isArray(o.sounds),c=l?o.resourceId?[{id:"default",resourceId:o.resourceId,loop:o.loop??!1,volume:Er,startDelayMs:o.startDelayMs??0}]:[]:o.sounds,u=!l&&o.loop===!0,p=[];if(l||as(c,"Voice sound"),u){let f=c.find(m=>m.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(c.forEach(f=>{let m=Qg(n,i,f.resourceId);if(!m)return;let b=u?{...f,loop:f.loop??!1}:f;p.push(ps({id:Kt("voice",i,l?"default":f.id),sound:b,resource:m,defaultLoop:u?!1:void 0}))}),p.length===0)return e;let d=ze({variables:r,runtime:a}).runtime;return s.push(us({id:xg,volume:l?o.volume??Fo(d,"soundVolume"):Uo(d,"soundVolume",o.volume??Er),muted:o.muted,pan:o.pan,loop:l?void 0:o.loop,interruption:o.interruption,children:p,runtime:d})),e},eb=(e,{presentationState:t,previousPresentationState:n,resources:i={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:b=[],isLineCompleted:h,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:g,animations:E}=e;if(t.layout){let O=Yr(g);if(!O)return e;let L=i.layouts?.[t.layout.resourceId];if(!L)return e;let $={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:L.elements||[]};O.children.push(Bo({container:$,resources:i,templateData:ze({variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:h,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:i.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:h,skipMode:u,skipTransitionsAndAnimations:y}))}let k=n?.layout?.resourceId,P=t.layout?.resourceId,v=fr({animationsDef:t.layout?.animations,resources:i,previousResourceId:k,currentResourceId:P,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:P?`layout-${P}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ke({animationInstances:v,isLineCompleted:h,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&E.push(...v),e},rb=(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=fr({animationsDef:l,resources:i,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ke({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...u),e},tb=(e,{presentationState:t})=>{let n=Yr(e.elements);return!n||!t?.screen||Object.assign(n,nu(t.screen)),e},nb=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,overlayStack:m=[],dialogueHistory:b=[],saveSlots:h=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:E}=e;return m&&m.length>0&&m.forEach((k,P)=>{let v=n.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${P}`,type:"container",x:0,y:0,children:[ou({id:`overlayStack-${P}-blocker`,screen:y}),...v.elements||[]]},L=au(b,n.characters,i),$=ze({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:h,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,historyDialogue:L,characters:n.characters||{},skipTransitionsAndAnimations:g}),D=ur(O,$),[U,..._]=D.children||[],G=pr(xr({...D,children:_},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:g}),n);E.push({...G,children:U?[U,...G.children||[]]:G.children})}),e},sb=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:b,dialogueHistory:h=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:E}=e;if(!b?.resourceId)return e;let k=n.layouts?.[b.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${b.resourceId}`),e;let P={id:"confirmDialog",type:"container",x:0,y:0,children:[ou({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=au(h,n.characters,i),O=ur(P,ze({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:b,historyDialogue:v,characters:n.characters||{},skipTransitionsAndAnimations:g})),[L,...$]=O.children||[],D=pr(xr({...O,children:$},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:g}),n);return E.push({...D,children:L?[L,...D.children||[]]:D.children}),e},Qt=e=>(t,n)=>Ug(t,{...n,visualLayer:e}),ib=Qt(cr.BEHIND_BACKGROUND),ob=Qt(cr.BEHIND_CHARACTER),ab=Qt(cr.BEHIND_DIALOGUE),lb=Qt(cr.BEHIND_CHOICE),cb=Qt(cr.FOREGROUND),cu=e=>Bn(Mg,[Gg,ib,qg,ob,Vg,ab,Yg,lb,zg,Xg,eb,cb,tb,rb,Hg,Wg,Jg,Zg,Kg,nb,sb])(e);function uu(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 pu(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 fu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",du="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",mu="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var yu=65535,zo=40960,fs=126976,bu=new Uint8Array(12288),wu=new Uint8Array(3072),Iu=new Uint8Array(2816),vu,ku;{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 uu(fu,du))e(bu,0,a,r,s),e(wu,zo,a,r,s),e(Iu,fs,a,r,s),r>=65040&&!(a>=fs&&r<=129791)&&(t[i]=a,n[i++]=r<<5|s);vu=t.slice(0,i),ku=n.slice(0,i)}function hu(e){return e<12288?bu[e]:e<zo?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?wu[e-zo]: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>=fs&&e<129792?Iu[e-fs]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:pu(e,vu,ku)}var Au=Uint8Array.from(mu,Number);function ub(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 gu(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||ub(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*Pu(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),i=n>yu?2:1,a=hu(n),r=50200>>a&1?gu(0,a,n):0,s=0,o=n,l=a;for(;i<t;){n=e.codePointAt(i);let c=n>yu?2:1,u=hu(n),p=Au[a<<4|u],d;p===0?d=!0:p===1?d=!1:p===2?d=!(r&1):p===3?d=!(r&4):d=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?gu(r,u,n):0,d&&(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*Eu(e){for(let t of Pu(e))yield t.segment}{let e=Pu("_");Au._keep=[e,e.next()]}var xu=1e3,$u=50,pb=0,Su=100,Ou=50,fb=60,db=3,mb=.5,yb=2e4,hb=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,gb=/^\s+$/u,Ru,bb=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Eu(t)):(Ru??=new n(void 0,{granularity:"grapheme"}),Array.from(Ru.segment(t),({segment:i})=>i))},wb=e=>bb(e).reduce((t,n)=>gb.test(n)?t+mb:hb.test(n)?t+db:t+1,0),Ib=e=>2**(((Number.isFinite(e)?Math.min(Su,Math.max(pb,e)):$u)-Ou)/(Su-Ou)),Xo=({text:e="",baseDelay:t=xu,speed:n=$u}={})=>{let i=Number.isFinite(t)?Math.max(0,t):xu,a=Ib(n),r=wb(e)*fb/a,s=Math.max(i,yb);return Math.min(i+r,s)};var ds={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Tu=1,dr=1,gt="choice",Or="form",tn=()=>({manual:{...ds.manual},auto:{...ds.auto},applyMode:ds.applyMode}),sa=()=>({groupId:null,variantId:null,pageIndex:0}),vb="music-room:player",kb=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),hs=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),ia=new Set,Ab=new Set(["groupId","variantId"]),Pb=new Set(["pageIndex"]),bt=new Set,Eb=new Set(["trackId"]),xb=new Set(["positionMs"]),Sb=new Set(["pageIndex"]),oa=new Set,Ob=new Set(["sceneId"]),Rb=new Set(["pageIndex"]),aa=()=>({pageIndex:0}),la=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...tn()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},Ho=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let t=Ae(e)?br(e):e;return structuredClone(t)},q=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),gs=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},Lu=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},nn=(e,t,n)=>({commandId:gs(e),operation:t,...n===void 0?{}:{positionMs:n}}),ca=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:gs(e),operation:"resume"}),e.global.musicRoomPlayer=hs({bgmPlayback:n})},Mu=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=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},qu=(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`)},Gr=e=>String(e),Vu=()=>({sections:[],resources:[]}),Fu=()=>({sceneIds:[]}),$b=e=>q(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Vu(),Cb=e=>q(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):Fu(),_b=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",jb=({sectionId:e,lineId:t,content:n,dialogueState:i,characterName:a})=>({sectionId:e,lineId:t,content:n,text:_b(n),characterId:i.characterId,character:{...i.character||{},name:a},characterName:a}),Uu=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),Nb=e=>q(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,ua=e=>{if(!q(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},Db=e=>{if(!q(e?.dialogueHistory))return e.dialogueHistory=Uu(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},pa=e=>{let t=ua(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},Tb=()=>({resourceId:void 0}),Lb=e=>{if(!q(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},mr=(e,t)=>{let n=e?.story?.scenes??{};for(let[i,a]of Object.entries(n))if(a?.sections?.[t])return{sceneId:i,section:a.sections[t]};return{sceneId:void 0,section:void 0}},Bu=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)}}},Yu=e=>e,zu=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Tu)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},Mb=(e,t={})=>{let n;try{n=zu(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let i={...t,formatVersion:n,slotId:Yu(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete i.slotKey,delete i.date,i},qb=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Mb(t,n)])),Vb=(e,t)=>{if(!q(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(i=>{if(!q(i))return!1;let{variableId:a,op:r,value:s,roundTo:o}=i,l=t?.resources?.variables?.[a];if(!l||Re(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Ut(l.type,r,a),Xn(l.type,r,s,a,{roundTo:o}),r!=="set"||oo(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},Xu=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(i=>{if(!q(i)||!PI(i.type))return[];if(i.type!=="updateVariable"||t===void 0)return[i];let a=Vb(i.payload,t);return a?[{...i,payload:a}]:[]});return n.length>0?n:void 0},Fb=(e,t,n)=>{let{section:i}=mr(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(!q(r)||!Object.prototype.hasOwnProperty.call(r,o))return;r=r[o]}return s.at(-1)==="random"&&q(r?.distribution)?r:void 0},Gu=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},Hu=(e,t,n)=>e.filter(({path:i,type:a,result:r})=>{let s=Fb(n,t,i);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return q(s.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let o=n?.resources?.variables?.[s.variableId];return typeof s.variableId=="string"&&o?.type==="number"&&o.scope==="context"&&o.readonly!==!0&&!Re(o)&&Gu(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),fa=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==dr)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(!q(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:Wn(V(a.result),a.type)}});return t===void 0?i:Hu(i,e,t)},Ub=(e,t)=>{!q(e)||!Array.isArray(e.timeline)||e.timeline.forEach(n=>{if(!q(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let i=Xu(n.executedActions,t);i?n.executedActions=i:delete n.executedActions;let a=fa(n,t);a?(n.randomOutcomeVersion=dr,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},Bb=(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(!q(o))return;let l=fa(o,t);l?(o.randomOutcomeVersion=dr,JSON.stringify(o.randomOutcomes)!==JSON.stringify(l)&&(o.randomOutcomes=l)):(delete o.randomOutcomeVersion,delete o.randomOutcomes)})})}),n},Cu=(e,t,n,i="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!q(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}},Yb=(e,t="viewedRegistry")=>{if(e===void 0)return Vu();if(!q(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=Cu(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(i.map((a,r)=>{let s=Cu(a,"resources",r,t);return[s.resourceId,s]})))}},zb=(e,t="accountReplayRegistry")=>{if(e===void 0)return Fu();if(!q(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}))]}},Zt=(e,t,n)=>{if(!q(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}=mr(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}},Ku=e=>{let t=e.story.initialSceneId,n=e.story.scenes[t],i=n.initialSectionId,a=n.sections[i];return Zt({sceneId:t,sectionId:i,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},Xb=e=>{try{return Ku(e),!0}catch{return!1}},Gb=(e,t,n)=>{let i=e?.pointers?.read;if(!q(i)||typeof i.sectionId!="string"||i.sectionId.length===0||typeof i.lineId!="string"||i.lineId.length===0)return Zt(i,t,n);try{return Zt(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 Zt(a[s],t,`${n} compatibility checkpoint`)}catch{}return Ku(t)}};var Wu=(e,t)=>{let{section:n}=mr(e,t?.sectionId);return n?.lines?.find(i=>i.id===t?.lineId)},Hb=(e,t,n)=>{if(!q(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(!q(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}=mr(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}},Kb=(e,t)=>q(Wu(e,t)?.actions?.dialogue),Ju=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:i}=mr(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=>q(s.actions?.dialogue))?.id===t.lineId},Wb=(e,t)=>{let n=Uu();return e.timeline.forEach(i=>{if(i.returnable!==!1&&Kb(t,i)){let a=Wu(t,i),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&Ju(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},Jb=(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},Qb=(e,t,n)=>{if(!q(e)||!Array.isArray(e.timeline))return{rollback:rn({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let i=[],a=e.timeline.flatMap((c,u)=>{if(!q(c))return[];let p=fa(c);try{let d=Zt(c,n,`rollback.timeline[${u}]`),f=p?Hu(p,d,n):void 0,m=ys({sectionId:d.sectionId,lineId:d.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...f?{randomOutcomeVersion:dr,randomOutcomes:f}:{}}),b=Xu(V(c.executedActions),n);return b&&(m.executedActions=b),i.push(u),[m]}catch{return[]}});if(a.length===0)return{rollback:rn({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(ys({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}},Qu=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let i=ma(t),a=Gb(e,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!q(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!q(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?Vt(V(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=pw({loadedContextRuntime:q(e.runtime)?V(e.runtime):{}}),{rollback:o,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Qb(e.rollback,a,t),u=e.dialogueHistory===void 0?Wb(o,t):Jb(Hb(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),o,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:q(e.configuration)?V(e.configuration):{},views:Array.isArray(e.views)?V(e.views):[],bgm:q(e.bgm)?V(e.bgm):{resourceId:void 0},variables:{...i,...r},...u?{dialogueHistory:u}:{},rollback:o};return s&&(p.runtime=s),p},Zb=(e,t)=>{if(!q(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)=>Qu(n,t,i))}},ew=(e,t)=>{if(!q(e))throw new Error("Malformed save slot.");let n=zu(e.formatVersion);return{...e,formatVersion:n,state:Zb(e.state,t)}},_u=(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=V(e),a=i.hideConfirmDialog??{};return delete i.hideConfirmDialog,{hideConfirmDialog:a,...i}},rw=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:_u(e.confirmActions,"confirmActions",{required:!0}),cancelActions:_u(e.cancelActions,"cancelActions")}},wt=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},tw=e=>(q(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),It=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Zu=e=>{if(!(!q(e)||!e.animations))return{animations:V(e.animations)}},nw=(e,t)=>{let n=Zu(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},sw=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},iw=(e,t)=>{let n=e?.sectionId,i=e?.lineId;if(!(!n||!i||!t))return`${n}:${i}:${t}`},ms=e=>String(e??""),ep=(e,t)=>{let n=ms(t);return e?.trim===!0?n.trim():n},ow=e=>q(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>q(t)).map(([t,n])=>[t,{id:t,...V(n)}])):{},aw=(e,t)=>{if(!t||!q(e.global.formDrafts))return;let n=e.global.formDrafts[t];return q(n)?n:void 0},rp=(e,t)=>{let n=tw(e);q(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let i=n[t];return q(i.values)||(i.values={}),q(i.touched)||(i.touched={}),q(i.errors)||(i.errors={}),typeof i.submitted!="boolean"&&(i.submitted=!1),i},da=(e,t)=>{let n=ep(e,t);return e?.required===!0&&n.length===0?"required":null},lw=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let i=Ee({state:e},{sectionId:t.sectionId})?.lines||[],a=i.findIndex(r=>r.id===t.lineId);return a<0?{}:Ur(i.slice(0,a+1).map(r=>r.actions||{}),{resources:e.projectData.resources})},cw=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let i=sw(t),a=iw(n,i);if(!i||!a)return null;let r=aw(e,a),s=ow(t),o=Sa({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([d,f])=>{let m=ms(o?.[f.variableId]),b=Object.prototype.hasOwnProperty.call(r?.values??{},d)?ms(r.values[d]):m,h=r?.touched?.[d]===!0,y=da(f,b),w=r?.submitted||h?y:null,g=typeof f.maxLength=="number"?Math.max(0,Math.round(f.maxLength)):void 0,E={id:d,variableId:f.variableId,value:b,initialValue:m,valid:!y,error:w,touched:h,required:f.required===!0,trim:f.trim===!0,placeholder:f.placeholder===void 0?"":String(f.placeholder),multiline:f.multiline===!0,...g!==void 0?{maxLength:g}:{}};y&&(p=!1),l[d]=E,c.push(E),u[d]=b}),{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:V(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:V(t.cancelActions??{})}}}},ht="line",Sr="interaction",ys=({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===dr?{randomOutcomeVersion:dr,randomOutcomes:V(r??[])}:{}}),ma=e=>{let t=Ae(e)?br(e):e,{contextVariableDefaultValues:n}=zn(t??{});return V(n)},tp=()=>({...V(Gt)}),np=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:i})=>{if(e===void 0)return{runtimeState:V(n),hasLoadedValues:!1};if(!q(e))throw new Error(`Malformed ${i}.`);let a=V(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=ts(s,V(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},uw=({projectData:e,loadedGlobalRuntime:t={}})=>np({loadedRuntime:t,runtimeIds:mo,defaults:ho(e),path:"global.runtime"}).runtimeState,pw=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=np({loadedRuntime:e,runtimeIds:yo,defaults:tp(),path:"context.runtime"});return n?t:void 0},$r=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},he=e=>{let t=$r(e);return t?.kind==="sceneReplay"&&q(t.sceneReplay)?t:null},sp=(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]=V(r)})},fw=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:V(e.global.nextLineConfig),overlayStack:V(e.global.overlayStack),confirmDialog:V(e.global.confirmDialog),formDrafts:V(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:V(e.global.pendingScreenTransition)}}),dw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=tn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},mw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=V(t.nextLineConfig),e.global.overlayStack=V(t.overlayStack),e.global.confirmDialog=V(t.confirmDialog),e.global.formDrafts=V(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=V(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=xe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({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}})},yw=e=>e.runtime?(yo.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=V(Gt[t]))}),e.runtime):(e.runtime=tp(),e.runtime),hw=e=>Rc(e.global),ip=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:hw(e)}})},ya=(e,t,n)=>{let i=ts(t,n);if(t in Gt){let a=$r(e);if(!a)return i;let r=yw(a);return r[t]=i,i}return e.global[t]=i,i},ha=({pointer:e,projectData:t,kind:n,sceneReplay:i})=>({...n===void 0?{}:{kind:n},...i===void 0?{}:{sceneReplay:V(i)},currentPointerMode:"read",pointers:{read:V(e)},configuration:{},views:[],bgm:Tb(),variables:ma(t),rollback:rn({pointer:e})}),vt=e=>e?(e.currentPointerMode="read",q(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,gw=(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=ha({pointer:i,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,bw(e,{queueRender:t}),a},bw=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,wt(e),It(e),e.global.nextLineConfig=tn(),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"})},op=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},rn=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[ys({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Cr=(e,t={})=>{if(e?.rollback)return op(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=rn({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},bs=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let i=Cr(n);if(i.isRestoring)return;let a=pa(n);i.currentIndex<i.timeline.length-1&&(i.timeline=i.timeline.slice(0,i.currentIndex+1)),i.timeline.push(ys(t)),i.currentIndex=i.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,i.currentIndex),a.checkpointLengths.push(a.currentLength))},ww=({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}},Iw=({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(Ae(l)?Cn(l):l)!==i||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},vw=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:i,checkpointIndex:a,sectionId:r,lineId:s}=t,o=Gr(n),l=e.global.saveSlots?.[o],c=Ae(l)?Cn(l):l;if(!l||c!==i)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,d=p?.rollback,f=d?.timeline?.[a];return!Number.isInteger(a)||d?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==s||f?.sectionId!==r||f?.lineId!==s||(f.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},ap=(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=pa(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return i.timeline[r]??null},kw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},i={})=>{let a=i?.source===ht?ht:Sr,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=pa(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let o=r?.pointers?.read,l=n?.lineEntryId,c=a===ht&&(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===ht?{lineEntryId:l,sourcePointer:o?{sectionId:o.sectionId,lineId:o.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},Aw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),Pw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let i=t?.at(-1);if(i?.source!==ht||i.hasTrackedLineEntryCheckpoint)return e;let a=i.sourcePointer;if(!a)return e;bs(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},Ew=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==ht)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=Wn(n.result,n.type),r=ap(e,t);if(!r)return e;if(r.randomOutcomeVersion!==dr&&(r.randomOutcomeVersion=dr,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},rr=(e,t,n,i)=>{let r=i?.at(-1)?.source??Sr;if(!EI(t,r))return;let s=ap(e,i);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:V(n)}))},Ko=(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=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(Re(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Ft(c,a),Ut(u,r,a),Xn(u,r,s,a,{roundTo:o}),c==="context"&&(n.variables[a]=Gn(n.variables[a],r,s,{roundTo:o}))}},xw=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:i})=>{xI(e,n,i)})},Sw=(e,t)=>{let{sectionId:n,lineId:i}=t,s=Ee({state:e},{sectionId:n})?.lines?.find(o=>o.id===i)?.actions;s&&Ca(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},lp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let i=Cr(n),a=i.timeline[t];if(!a)return e;e.global.autoMode&&ln({state:e}),e.global.skipMode&&Rr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),i.isRestoring=!0,i.currentIndex=t;try{n.variables=ma(e.projectData),n.kind==="sceneReplay"&&(sp(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=V(ds),e.global.overlayStack=[],wt(e),It(e),e.global.isLineCompleted=!0;let r=i.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&la(e),Sw(e,i.timeline[l]),xw(e,i.timeline[l]);let s=vt(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let o=ua(n);o&&(o.currentLength=Math.min(o.checkpointLengths[t]??0,o.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Lu(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{i.isRestoring=!1}return e},Ow=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;Bu(t),Lt(t),Mt(t),qt(t),Vr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],d=p.initialSectionId,f=p.sections[d],m={sceneId:u,sectionId:d,lineId:f.initialLineId??f.lines[0].id},{globalVariablesDefaultValues:b}=zn(t),h={...b,...Vt(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Yb(o,"accountViewedRegistry"),accountReplayRegistry:zb(l),nextLineConfig:tn(),imageGalleryNavigation:sa(),sceneReplayNavigation:aa(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:hs(),saveSlots:qb(a),localizationPackages:V(c),overlayStack:[],variables:h,...uw({projectData:t,loadedGlobalRuntime:s})},contexts:[ha({pointer:m,projectData:t})]}},Rw=({state:e})=>e.global.overlayStack||[],$w=({state:e})=>e.global.pendingEffects,cp=({state:e})=>e.global.skipMode,Cw=({state:e})=>e.global.autoMode,up=({state:e})=>e.global.dialogueUIHidden,pp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let i,a=q(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:c,lineId:u}=n.pointers.read,p=Ee({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let d=p.lines.findIndex(f=>f.id===u);i=p.lines.slice(0,d+1).map(f=>({sectionId:c,lineId:f.id}))}let r=[],s=at({variables:{...e.global?.variables??{},...$r(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),o=new Map,l=c=>{let u=o.get(c.sectionId);if(!u){let d=Ee({state:e},{sectionId:c.sectionId}),f=Array.isArray(d?.lines)?d.lines:[];u={lines:f,lineIndexes:new Map(f.map((m,b)=>[m.id,b])),projections:new Map,nextLineIndex:0,presentationState:{}},o.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let d=u.lines[u.nextLineIndex],f=d.actions||{};u.presentationState=Ur([u.presentationState,f],{resources:e.projectData.resources}),u.projections.set(d.id,{line:d,lineActions:f,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of i){if(!Nb(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:d,dialogueState:f}=u;if(!d.dialogue)continue;let m=Yn({characterId:f.characterId,character:f.character,characters:e.projectData.resources?.characters??{},variables:s}),b=jb({sectionId:c.sectionId,lineId:p.id,content:d.dialogue.append===!0?f.content:d.dialogue.content,dialogueState:f,characterName:m}),h=r[r.length-1];if((a?c.appendToPrevious===!0:d.dialogue.append===!0)&&h?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:b.content,text:b.text,characterId:b.characterId,character:b.character,characterName:b.characterName};continue}r.push(b)}return r},_w=(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?.[Gr(r)],u=Ae(c)?Cn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==o||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=V(n),i=!0)}i&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},jw=({state:e},t={})=>{let n=$r(e),i=n?.pointers?.read,a=on({state:e});if(!n||!q(a?.actions?.dialogue))return e;let r=Cr(n),s=r.timeline?.[r.currentIndex],o=s?.sectionId===i?.sectionId&&s?.lineId===i?.lineId,l=ua(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 d=Db(n);d.currentLength<d.entries.length&&(d.entries=d.entries.slice(0,d.currentLength));let f=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&Ju(e.projectData,p,i);if(d.entries.push({sectionId:i.sectionId,lineId:i.lineId,...f?{appendToPrevious:!0}:{}}),d.currentLength=d.entries.length,o){for(;d.checkpointLengths.length<r.timeline.length;)d.checkpointLengths.push(d.checkpointLengths.at(-1)??0);d.checkpointLengths[r.currentIndex]=d.currentLength}return _w(e,t.savedCheckpointOccurrences,d),e},Nw=({state:e})=>e.global.confirmDialog??null,sn=({state:e},{pointer:t}={})=>{let n=t??Le({state:e})?.pointer,i=lw({state:e,pointer:n});return cw({state:e,form:i.form,pointer:n})},Dw=({state:e},{pointer:t}={})=>!!sn({state:e},{pointer:t}),xe=({state:e},{pointer:t}={})=>{let n=sn({state:e},{pointer:t});if(n)return{source:Or,formId:n.id,formKey:n.key};let i=gp({state:e,pointer:t});return i?{source:gt,resourceId:i}:null},Tw=({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=Ee({state:e},{sectionId:i});if(!o||!o.lines||!Array.isArray(o.lines))return s.lastLineId===a;let l=o.lines.findIndex(u=>u.id===s.lastLineId),c=o.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},ga=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},ba=({state:e},t)=>Tw({state:e,registry:e.global.accountViewedRegistry},t),Lw=({state:e},t)=>ga({registry:e.global.accountViewedRegistry},t),en=(e,t)=>!ga({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),wa=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Ia=(e,t)=>{let n=wa(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Wo=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!en(e,t[a]))return t[a]},Mw=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:V(t)},fp=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??sa(),i=wa(t),a=Ia(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:en(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:en(e,c)}))})),o=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=t.groups.findIndex(f=>f.id===n.groupId),c=t.groups[l],u=c?.variants.findIndex(f=>f.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],d=l<0?-1:Math.floor(l/t.pageSize);p&&d===a&&!en(e,p)&&(o={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:Wo(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:Wo(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:o,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},va=(e,t)=>!ga({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),ka=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Aa=(e,t)=>{let n=ka(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Jo=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!va(e,t[a]))return t[a]},dp=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}),qw=(e,t)=>({...dp(t),locked:va(e,t)}),ju=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")}`},Vw=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:V(t)},mp=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??hs(),i=ka(t),a=Aa(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>qw(e,u)),o=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[o],c=l?{...dp(l),canPlayPreviousTrack:Jo(e,t.tracks,o,-1)!==void 0,canPlayNextTrack:Jo(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:ju(n.positionMs),durationText:n.durationMs===null?null:ju(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}}},Pa=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Ea=(e,t)=>{let n=Pa(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Fw=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:V(t)},Uw=({state:e})=>he(e)!==null,Bw=({state:e})=>{let t=he(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},yp=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,hp=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??aa(),i=Pa(t),a=Ea(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:!yp(e,l.sceneId)})),o=he(e);return{isActive:o!==null,activeSceneId:o?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},Yw=({state:e})=>e.global.nextLineConfig,gp=({state:e,pointer:t}={})=>{let n=t??Le({state:e})?.pointer;if(!n)return;let i=n?.sectionId,a=n?.lineId,s=Ee({state:e},{sectionId:i})?.lines||[],o=s.findIndex(c=>c.id===a);if(o<0)return;let l;for(let c of s.slice(0,o+1)){let u=c?.actions;if(u?.cleanAll&&(l=void 0),!u||!Object.prototype.hasOwnProperty.call(u,"choice")){l=void 0;continue}let p=u.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},bp=({state:e})=>!!gp({state:e}),zw=({state:e})=>structuredClone(e),Xw=({state:e})=>V(e.projectData.resources?.achievements??{}),Gw=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:V(n)},wp=({state:e})=>e.global.saveSlots,Hw=({state:e},t)=>{let n=t?.slotId,i=Gr(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0},Ip=({state:e})=>V(e.global.localizationPackages),xa=({state:e})=>Pr(e),Kw=({state:e},t)=>Ze(e,t?.runtimeId),Sa=({state:e})=>{let t={...e.global?.variables??{},...$r(e)?.variables??{}};return at({variables:t,runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{}})},Le=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},Ee=({state:e},t)=>{let{sectionId:n}=t;return mr(e.projectData,n).section},on=({state:e})=>{let t=Le({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:i}=t.pointer,a=Ee({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===i)},vp=({state:e})=>{let{sectionId:t,lineId:n}=Le({state:e}).pointer,a=Ee({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===n),o=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(d=>{p[d]=u[d]}),p});return Ur(o,{resources:e.projectData.resources})},kp=e=>{let t=on({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=at({variables:{...e.global?.variables??{},...$r(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(i=>`${ut(i?.text,{variables:n})??""}`).join("")},yr=({state:e})=>Xo({text:kp(e),baseDelay:Ze(e,"autoForwardDelay"),speed:Ze(e,"autoForwardSpeed")}),Ww=({state:e})=>{let t=Ap({state:e}),i=on({state:e})?.actions??{},a=Ur([t??{},i],{resources:e.projectData.resources});return lo(t??{},a??{})},Jw=({state:e},{sectionId:t})=>{let n=Ee({state:e},{sectionId:t});if(!n?.lines)return[];let i=[],a={};for(let r of n.lines){let s=r.actions||{},o=Ur([a,s],{resources:e.projectData.resources}),l=lo(a,o);i.push({id:r.id,changes:l,presentationState:o}),a=co(o)}return i},Qw=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let i=Jw({state:e},{sectionId:t});return n?{lines:i}:{lines:i.map(({presentationState:a,...r})=>r)}},Ap=({state:e})=>{let{sectionId:t,lineId:n}=Le({state:e}).pointer,a=Ee({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===n);if(r<=0)return null;let o=a.slice(0,r).map(l=>{let c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return co(Ur(o,{resources:e.projectData.resources}))},Oa=({state:e},{slotsPerPage:t=6}={})=>{let a=((xa({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[Gr(o)]||{};r.push({...l,slotId:o})}return{saveSlots:r}},Zw=wp,e0=Oa,r0=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},t0=({state:e},t={})=>{let n=vp({state:e}),i=Ap({state:e}),a=on({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:V(r)}:a,o=r?.animations&&i===null?{}:i,{sectionId:l}=Le({state:e}).pointer,{sceneId:c}=mr(e.projectData,l),u={...xa({state:e}),localizationPackages:Ip({state:e})},p=t?.activePersistentAnimations??[],d=t?.restoredPersistentAnimations??[],f=sn({state:e}),m=bp({state:e}),b=fp({state:e}),h=mp({state:e}),y=hp({state:e}),w=Sa({state:e}),{saveSlots:g}=Oa({state:e}),E=r0(e);return cu({presentationState:n,previousPresentationState:o,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:m,isFormVisible:!!f,canRollback:Xp({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:f,dialogueHistory:pp({state:e}),saveSlots:g,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:d,imageGallery:b,musicRoom:h,sceneReplay:y,musicRoomPlayer:V(e.global.musicRoomPlayer),activeAudioEffect:t?.activeAudioEffect??null})},n0=({state:e},t)=>(e.global.confirmDialog=rw(t),e.global.pendingEffects.push({name:"render"}),e),s0=({state:e})=>(e.global.confirmDialog&&(wt(e),e.global.pendingEffects.push({name:"render"})),e),i0=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),rr(e,"pushOverlay",n,t),e),o0=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),rr(e,"popOverlay",void 0,t),e),a0=({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"}),rr(e,"replaceLastOverlay",n,t),e),l0=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],wt(e),It(e),e.global.pendingEffects.push({name:"render"}),rr(e,"clearOverlays",void 0,t),e),c0=(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,nw(e,n),It(e);let i=xe({state:e},{pointer:t}),a=i?.source===gt,r=i?.source===Or;c0(e,{activeInteraction:i});let s=he(e),o={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Lu(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}},ws=(e,t,n)=>{!(t?.source===gt||t?.source===Or)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Pp=({state:e})=>(xe({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:yr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),ln=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),u0=({state:e})=>{let t=e.global.autoMode;return xe({state:e})&&!t||(t?ln({state:e}):Pp({state:e})),e},Ep=({state:e})=>(xe({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),Rr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),p0=({state:e})=>{let t=cp({state:e});return xe({state:e})&&!t||(t?Rr({state:e}):Ep({state:e})),e},Is=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),rr(e,"showDialogueUI",void 0,t),e),xp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),rr(e,"hideDialogueUI",void 0,t),e),f0=e=>{let{state:t}=e;return up({state:t})?Is(e):xp(e),t},_r=(e,t,n)=>(ya(e,t,n),ip(e),e.global.pendingEffects.push({name:"render"}),e),cn=(e,t,n,i,a)=>{let r=ya(e,t,n);return e.global.pendingEffects.push({name:"render"}),rr(e,i,{value:r},a),e},d0=({state:e},t)=>_r(e,"dialogueTextSpeed",t?.value),m0=({state:e},t)=>(_r(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e),y0=({state:e},t)=>(_r(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e),h0=({state:e},t)=>_r(e,"skipUnseenText",t?.value),g0=({state:e},t)=>_r(e,"skipTransitionsAndAnimations",t?.value),b0=({state:e},t)=>_r(e,"soundVolume",t?.value),w0=({state:e},t)=>_r(e,"musicVolume",t?.value),I0=({state:e},t)=>_r(e,"muteAll",t?.value),Qo=({state:e,rollbackActionBatchStack:t},n)=>cn(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),Zo=({state:e,rollbackActionBatchStack:t})=>{let n=Ze(e,"saveLoadPagination")+1;return cn(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},ea=({state:e,rollbackActionBatchStack:t})=>{let n=Ze(e,"saveLoadPagination")-1;return cn(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},ra=({state:e,rollbackActionBatchStack:t},n)=>cn(e,"menuPage",n?.value,"setMenuPage",t),ta=({state:e,rollbackActionBatchStack:t},n)=>cn(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),v0=({state:e})=>(e.global.pendingEffects=[],e),k0=({state:e},t)=>(e.global.pendingEffects.push(t),e),A0=({state:e},t)=>{if(he(e))return e;let n=t?.resourceId;return Mu(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},P0=({state:e},t)=>{if(he(e))return e;let n=t?.resourceId,i=Mu(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},Sp=e=>e?.lines?.[0],Op=(e,{sectionId:t,resetStoryState:n=!1,screen:i})=>{let a=!!Zu(i),r=Ee({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=Sp(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!gw(e,{queueRender:!a}))return e;let o=xe({state:e});n&&e.global.skipMode&&Rr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=vt(l),p=u.read;n||Xr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Cr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=rn({pointer:u.read}):bs(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=an(e,l?.pointers?.read,{screenTransition:i});return ws(e,o,c),e},E0=({state:e},t)=>{if(he(e))throw new Error("Cannot reset the story while a scene replay is active");return Op(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},Rp=e=>(e.global.accountViewedRegistry=$b(e.global.accountViewedRegistry),e.global.accountViewedRegistry),vs=(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:V(n.value)}))}})},$p=(e,t)=>{vs(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:[]}}])},x0=(e,t,{sectionId:n,lineId:i})=>{if(!n||!i)return!1;let a=q(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=Ee({state:e},{sectionId:n});if(s?.lines){let o=s.lines.findIndex(c=>c.id===r.lastLineId),l=s.lines.findIndex(c=>c.id===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},Xr=(e,t)=>{if(he(e)||e.global.accountViewedRegistry===void 0)return;x0(e,Rp(e),t)&&$p(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},S0=({state:e},t)=>(Xr(e,t),e.global.pendingEffects.push({name:"render"}),e),O0=({state:e},t)=>{if(he(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let i=Rp(e);i.resources.find(r=>r.resourceId===n)||(i.resources.push({resourceId:n}),$p(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},tr=(e,t,n)=>{if(!q(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}"`)})},na=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},ks=(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"}))},R0=({state:e},t)=>{let n="showImageGalleryVariant";tr(n,t,Ab),na(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&na(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||en(e,s)||ks(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/i.pageSize)}),e},Cp=(e,t,n,i)=>{tr(i,t,ia);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=Wo(e,s.variants,o,n);return l&&ks(e,{...r,variantId:l.id}),e},$0=({state:e},t)=>Cp(e,t,-1,"moveToPreviousImageGalleryVariant"),C0=({state:e},t)=>Cp(e,t,1,"moveToNextImageGalleryVariant"),_0=({state:e},t)=>{if(tr("clearImageGallerySelection",t,ia),e.projectData?.resources?.imageGallery===void 0)return e;let i=e.global.imageGalleryNavigation;return ks(e,{groupId:null,variantId:null,pageIndex:i.pageIndex}),e},_p=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let i=wa(n);if(t>=i)return e;let a=e.global.imageGalleryNavigation,r=Ia(n,a);return t===r||ks(e,{groupId:null,variantId:null,pageIndex:t}),e},j0=({state:e},t)=>{if(tr("moveToImageGalleryPage",t,Pb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return _p(e,t.pageIndex)},jp=(e,t,n,i)=>{tr(i,t,ia);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Ia(a,e.global.imageGalleryNavigation)+n;return s<0?e:_p(e,s)},N0=({state:e},t)=>jp(e,t,1,"moveToNextImageGalleryPage"),D0=({state:e},t)=>jp(e,t,-1,"moveToPreviousImageGalleryPage"),hr=(e,t,n)=>{if(!q(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}"`)})},T0=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},We=e=>{e.global.pendingEffects.push({name:"render"})},Np=(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:gs(e),operation:"pause"});let o=nn(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},We(e)},L0=({state:e},t)=>{let n="playMusicRoomTrack";hr(n,t,Eb),T0(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||va(e,a)||Np(e,a),e},M0=({state:e},t)=>{hr("playMusicRoom",t,bt);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=nn(e,s,s==="play"?o:void 0),i.seekFallback=null,i.status="playing",i.positionMs=o,r&&(i.readiness=i.durationMs===null?"loading":"ready"),We(e),e},q0=({state:e},t)=>{hr("pauseMusicRoom",t,bt);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status!=="playing"||(i.playback=nn(e,"pause"),i.seekFallback=null,i.status="paused",We(e)),e},V0=({state:e},t)=>{hr("stopMusicRoom",t,bt);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status==="stopped"&&i.positionMs===0||(i.playback=nn(e,"stop"),i.seekFallback=null,i.status="stopped",i.positionMs=0,We(e)),e},F0=({state:e},t)=>{if(hr("seekMusicRoom",t,xb),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=nn(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"),We(e),e},Dp=(e,t,n,i)=>{hr(i,t,bt);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=Jo(e,a.tracks,s,n);return o&&Np(e,o),e},U0=({state:e},t)=>Dp(e,t,-1,"playPreviousMusicRoomTrack"),B0=({state:e},t)=>Dp(e,t,1,"playNextMusicRoomTrack"),Y0=({state:e},t)=>{hr("clearMusicRoomSelection",t,bt);let i=e.global.musicRoomPlayer;if(i.trackId===null)return e;let a=i.pageIndex,r={commandId:gs(e),operation:"resume"};return e.global.musicRoomPlayer={...hs({bgmPlayback:r}),pageIndex:a},We(e),e},Tp=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=ka(n))return e;let i=e.global.musicRoomPlayer,a=Aa(n,i);return t===a||(i.pageIndex=t,We(e)),e},z0=({state:e},t)=>{if(hr("moveToMusicRoomPage",t,Sb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Tp(e,t.pageIndex)},Lp=(e,t,n,i)=>{hr(i,t,bt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Aa(a,e.global.musicRoomPlayer)+n;return r<0?e:Tp(e,r)},X0=({state:e},t)=>Lp(e,t,1,"moveToNextMusicRoomPage"),G0=({state:e},t)=>Lp(e,t,-1,"moveToPreviousMusicRoomPage"),zr=e=>{let t=he(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=V(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(),mw(e,n),e.global.pendingEffects.push({name:"render"}),!0},H0=({state:e},t)=>{let n="startSceneReplay";if(tr(n,t,Ob),na(n,"sceneId",t.sceneId),he(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||!yp(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],s=r?.initialSectionId,o=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=fw(e);dw(e);let u=ha({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 sp(e,u),e.contexts.push(u),an(e,u.pointers.read),e},Mp=({state:e},t)=>{tr("finishSceneReplay",t,oa);let i=he(e);if(i)return i.sceneReplay.finishOnNextAdvance=!0,e;if($r(e)?.rollback?.isRestoring===!0)return e;let r=Le({state:e})?.pointer,{sceneId:s}=mr(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=Cb(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),vs(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},K0=({state:e},t)=>(tr("exitSceneReplay",t,oa),zr(e),e),qp=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=Pa(n))return e;let i=Ea(n,e.global.sceneReplayNavigation);return t===i||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},W0=({state:e},t)=>{if(tr("moveToSceneReplayPage",t,Rb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return qp(e,t.pageIndex)},Vp=(e,t,n,i)=>{tr(i,t,oa);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Ea(a,e.global.sceneReplayNavigation)+n;return r<0?e:qp(e,r)},J0=({state:e},t)=>Vp(e,t,1,"moveToNextSceneReplayPage"),Q0=({state:e},t)=>Vp(e,t,-1,"moveToPreviousSceneReplayPage"),As=(e,t)=>{let n=e.global.musicRoomPlayer;return!q(t)||t.id!==vb||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},Ra=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,Fp=(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,We(e)),e),Z0=({state:e},t)=>{let n=As(e,t);return!n||n.readiness!=="loading"||!Ra(t)?e:Fp(e,n,t,{readiness:"ready"})},eI=({state:e},t)=>{let n=As(e,t);return!n||n.readiness!=="ready"||!Ra(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:Fp(e,n,t)},rI=({state:e},t)=>{let n=As(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!Ra(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,We(e)),e},tI=({state:e},t)=>{let n=As(e,t);if(!n||typeof t.errorCode!="string"||!kb.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&&We(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,We(e),e},Up=({state:e,rollbackActionBatchStack:t},n)=>{let i=Lb(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,d=e.global.nextLineConfig.auto?.trigger,f=e.global.nextLineConfig.auto?.delay,m=xe({state:e});return!u&&(a!==void 0&&(p!==s||d!==o||f!==l))&&(!m&&p===!0&&(d==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:f}}):s===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),rr(e,"setNextLineConfig",n,t),e},nI=({state:e},t)=>{if(he(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;qu(n,"saveSlot");let{thumbnailImage:i}=t,a=t?.savedAt,r=Gr(n),s=V(e.contexts);s?.forEach(c=>{vt(c),op(c.rollback),Ub(c.rollback,e.projectData)});let o={contexts:s},l={formatVersion:Tu,slotId:Yu(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},sI=({state:e},t)=>{if(he(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;qu(n,"loadSlot");let i=Gr(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},i)?e.global.saveSlots[i]:void 0;if(a){let r=ew(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=tn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,wt(e),It(e),ca(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},iI=({state:e},t)=>{if(he(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;Bu(n),Lt(n),Mt(n),qt(n),Vr(n?.resources?.variables??{}),ho(n);let i=Xb(n),a=i?e.contexts?.map((s,o)=>Qu(V(s),n,o)):void 0,r=i?Bb(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=sa(),e.global.sceneReplayNavigation=aa(),ca(e),i){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:o}=zn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...o,...Vt(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return wt(e),It(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},oI=({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(!q(i))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=i,ya(e,"localizationPackageId",n),ip(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},aI=({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&&!Ee({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=Ee({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=xe({state:e}),c=vt(a);c.read={sectionId:r,lineId:i};let{activeInteraction:u}=an(e,c.read);return ws(e,l,u),e},lI=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Is({state:e,rollbackActionBatchStack:t}),e;let i=xe({state:e});if(i?.source===gt&&n?.bypassChoice!==!0||i?.source===Or&&n?._interactionSource!==Or)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,he(e)?.sceneReplay.exitOnLineCompleted)return zr(e),e;let f=Le({state:e})?.pointer,m=f?.sectionId,b=f?.lineId;m&&b&&Xr(e,{sectionId:m,lineId:b}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!i&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}});let h=e.global.nextLineConfig,y=Ee({state:e},{sectionId:m});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===b?Ho(e):h?.auto?.enabled&&!i&&h.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:h.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(he(e)?.sceneReplay.finishOnNextAdvance)return zr(e),e;let r=Le({state:e})?.pointer,s=r?.sectionId,o=Ee({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=o?.lines||[],p=c.findIndex(d=>d.id===r?.lineId)+1;if(p<c.length){let d=c[p],f=!Ze(e,"skipUnseenText");if(e.global.skipMode&&f&&!ba({state:e},{sectionId:s,lineId:d.id}))return Rr({state:e}),e;if(l&&!l.rollback&&Cr(l,{compatibilityAnchor:!0}),l){let b=vt(l),h=b.read?.lineId;h&&s&&Xr(e,{sectionId:s,lineId:h}),b.read={sectionId:s,lineId:d.id}}bs(e,{sectionId:s,lineId:d.id}),la(e);let{activeInteraction:m}=an(e,{sectionId:s,lineId:d.id});ws(e,i,m)}else{if(he(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),zr(e),e;e.global.autoMode&&ln({state:e}),e.global.skipMode&&Rr({state:e}),Ho(e)}return e},cI=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,he(e)?.sceneReplay.exitOnLineCompleted)return zr(e),e;let n=xe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}});let i=Le({state:e})?.pointer,a=i?.sectionId,r=i?.lineId;a&&r&&Xr(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},uI=({state:e},t)=>Op(e,{sectionId:t?.sectionId,screen:t?.screen}),pI=({state:e,rollbackActionBatchStack:t},n)=>{let i=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!i)return Is({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:yr({state:e})}}),e;let a=xe({state:e});if(a?.source===gt&&n?.bypassChoice!==!0||a?.source===Or&&n?._interactionSource!==Or||a&&a.source!==gt&&a.source!==Or)return e;let r=he(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(zr(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=Le({state:e})?.pointer,o=s?.sectionId,l=Ee({state:e},{sectionId:o}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],d=u.findIndex(f=>f.id===s?.lineId)+1;if(d<u.length){let f=u[d],m=!Ze(e,"skipUnseenText");if(e.global.skipMode&&m&&!ba({state:e},{sectionId:o,lineId:f.id})&&(Rr({state:e}),!i))return e;if(c&&!c.rollback&&Cr(c,{compatibilityAnchor:!0}),c){let h=vt(c),y=h.read?.lineId;y&&o&&Xr(e,{sectionId:o,lineId:y}),h.read={sectionId:o,lineId:f.id}}bs(e,{sectionId:o,lineId:f.id}),la(e);let{activeInteraction:b}=an(e,{sectionId:o,lineId:f.id});ws(e,a,b)}else{if(he(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),zr(e),e;e.global.autoMode&&ln({state:e}),e.global.skipMode&&Rr({state:e}),Ho(e)}return e},$a=(e,t={})=>{let n=sn({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},fI=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=e.projectData.resources?.variables?.[t.variableId],i=n?.scope,a=n?.type;if(Re(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(Ft(i,t.variableId),Ut(a,"set",t.variableId),he(e)&&i!=="context")throw new Error(`Cannot update ${i}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:i}},dI=(e,t)=>({id:e.id,key:e.key,valid:!0,values:V(t),fields:V(e.fields),fieldList:V(e.fieldList)}),mI=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Le({state:e})?.pointer,n=t?.sectionId,i=t?.lineId;n&&i&&Xr(e,{sectionId:n,lineId:i})},yI=({state:e},t={})=>{let n=$a(e,t),i=t.field;if(!n?.fields?.[i])return e;let a=rp(e,n.key),r=ms(t.value),s=n.fields[i],o=da(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},hI=({state:e,rollbackActionBatchStack:t},n={})=>{let i=$a(e,n);if(!i)return{submitted:!1,valid:!1,reason:"inactive"};let a=rp(e,i.key);a.submitted=!0;let r={},s={};if(Object.entries(i.fields).forEach(([d,f])=>{let m=Object.prototype.hasOwnProperty.call(a.values,d)?a.values[d]:f.value,b=da(f,m);a.touched[d]=!0,b&&(s[d]=b),r[d]=ep(f,m)}),a.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:V(s),form:{id:i.id,key:i.key,values:V(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(([d,f])=>{let{scope:m}=fI(e,f),b=m==="context"?o.variables:e.global.variables,h=r[d];b[f.variableId]=Gn(b[f.variableId],"set",h),m==="context"&&(l=!0,u.push({variableId:f.variableId,op:"set",value:h})),(m==="device"||m==="account")&&c.push({scope:m,path:`variables.${f.variableId}`,op:"set",value:V(b[f.variableId])})}),l&&rr(e,"updateVariable",{id:"submitForm",operations:u},t),vs(e,c);let p=dI(i,r);return mI(e),delete e.global.formDrafts[i.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},gI=({state:e},t={})=>{let n=$a(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:V(n.values),fields:V(n.fields),fieldList:V(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},bI=({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:d})=>{let f=e.projectData.resources?.variables?.[c],m=f?.scope,b=f?.type;if(Re(f))throw new Error(`Cannot update computed variable: ${c}`);if(f?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Ft(m,c),Ut(b,u,c),Xn(b,u,p,c,{roundTo:d}),he(e)&&m!=="context")throw new Error(`Cannot update ${m}-scoped variable "${c}" while a scene replay is active`);let h=m==="context"?r.variables:e.global.variables;if(m==="context"){s=!0;let y={variableId:c,op:u,value:p};d!==void 0&&(y.roundTo=d),l.push(y)}h[c]=Gn(h[c],u,p,{roundTo:d}),(m==="device"||m==="account")&&o.push({scope:m,path:`variables.${c}`,op:"set",value:V(h[c])})}),s&&rr(e,"updateVariable",{id:i,operations:l},t),vs(e,o),e.global.pendingEffects.push({name:"render"}),e},Xe=e=>(t,n)=>e({state:t},n),Bp=e=>({variables:at({variables:{...e.global?.variables??{},...$r(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Pr(e)}),wI=e=>{if(!q(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")},II=(e,t,n)=>{if(!q(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!q(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")},vI=(e,t,n,i)=>{wI(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(II(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Tt(r.when,{...Bp(e),...n?.bindings??{}}))){Ca(e,r.actions,n,[...i,"branches",String(a),"actions"]);return}}},kI=(e,t,n,i)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==dr)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=Wn(V(l.result),l.type);if(c.type==="integer"){if(!Gu(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}`);Ko(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!q(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Ca(e,u,n,[...i,"distribution","outcomes",String(c.outcomeIndex),"actions"])},AI={conditional:{replayLine:vI},random:{replayLine:kI},updateVariable:{recordSources:[Sr],replayLine:Ko,replayRecorded:Ko,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Xe(Up)},setSaveLoadPagination:{recordSources:[Sr],replayLine:Xe(Qo),replayRecorded:Xe(Qo),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Sr],replayLine:Xe(Zo),replayRecorded:Xe(Zo),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Sr],replayLine:Xe(ea),replayRecorded:Xe(ea),persistInSaveSlot:!0},setMenuPage:{recordSources:[Sr],replayLine:Xe(ra),replayRecorded:Xe(ra),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Sr],replayLine:Xe(ta),replayRecorded:Xe(ta),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Xe(Mp)}},Ps=e=>AI[e]??null,PI=e=>Ps(e)?.persistInSaveSlot===!0,EI=(e,t)=>{let n=Ps(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},xI=(e,t,n)=>{Ps(t)?.replayRecorded?.(e,n)},SI=(e,t,n,i,a)=>{let r=Ps(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,i,a);return}let s=i?.bindings??{},o=Bt({[t]:n},{...Bp(e),...s})[t];r.replayLine(e,o)},Ca=(e,t,n,i)=>{let a=Jn(t);Zn(a);for(let[r,s]of a)SI(e,r,s,n,[...i,r])},OI=e=>e?.returnable!==!1,Yp=(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(OI(e.timeline[i])&&(n-=1,n===0))return i;return-1},zp=({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=Yp(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},Xp=({state:e})=>zp({state:e},{offset:-1})!==null,RI=({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=Cr(i,{compatibilityAnchor:!i.rollback}),r=Yp(a,n);return r<0||r>=a.timeline.length?e:lp(e,r)},$I=({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=Cr(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:lp(e,o)},CI=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),Go=(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]},Nu=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,Du=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},_I=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Gp=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}},_a=e=>JSON.stringify(Gp(e)),jI=({actionName:e,args:t,state:n,previousState:i})=>{let a=Nu(i),r=Nu(n);if(!_I(a,r)||i.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&Du(i)!==Du(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=mr(n.projectData,s.sectionId).section,l=Sp(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??{},Gr(o))}return!1},NI=({actionName:e,args:t,state:n,transactionalMetadata:i,previousState:a})=>{if(jI({actionName:e,args:t,state:n,previousState:a})){let u=Go(i,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?i.rollbackAuthoredSuppression={lineEntryId:u,configKey:_a(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"?xe({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!o||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&Go(i,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!o||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&Go(i,"skipSessionId")},DI=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==_a(e))&&(t.rollbackAuthoredSuppression=null)},TI=({state:e,playbackOwnership:t})=>{let n=xe({state:e}),i=t.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!n&&e.global.skipMode===!0,s=Gp(e),o=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(o?.lineEntryId===i&&o.configKey===_a(e)),c=a?kp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:i},delayMs:Xo({text:c,baseDelay:Ze(e,"autoForwardDelay"),speed:Ze(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}},LI=({playbackOwnership:e})=>e.lineEntryId,Hp=(e,t={})=>{let n=Ow(e),i=[],a=t.createPlaybackOwnership??CI;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return Fl(n,{selectPendingEffects:$w,selectSkipMode:cp,selectAutoMode:Cw,selectIsChoiceVisible:bp,selectIsFormVisible:Dw,selectActiveInteraction:xe,selectActiveForm:sn,selectDialogueUIHidden:up,selectDialogueHistory:pp,selectConfirmDialog:Nw,selectIsLineAccountViewed:ba,selectIsResourceAccountViewed:Lw,selectImageGalleryConfig:Mw,selectImageGallery:fp,selectMusicRoomConfig:Vw,selectMusicRoom:mp,selectSceneReplayConfig:Fw,selectSceneReplay:hp,selectIsSceneReplayActive:Uw,selectActiveSceneReplayEntry:Bw,selectNextLineConfig:Yw,selectSystemState:zw,selectAchievements:Xw,selectAchievement:Gw,selectSaveSlotMap:wp,selectSaveSlots:Zw,selectSaveSlot:Hw,selectLocalizationPackages:Ip,selectRuntime:xa,selectRuntimeValue:Kw,selectAllVariables:Sa,selectCurrentPointer:Le,selectSection:Ee,selectCurrentLine:on,selectPresentationState:vp,selectAutoForwardTimerDelay:yr,selectPresentationChanges:Ww,selectSectionLineChanges:Qw,selectSaveSlotPage:Oa,selectCurrentPageSlots:e0,selectRenderState:t0,selectOverlayStack:Rw,selectLineIdByOffset:zp,selectCanRollback:Xp,selectRollbackCursor:ww,selectDesiredPlaybackTimers:TI,selectPlaybackLineEntryId:LI,startAutoMode:Pp,stopAutoMode:ln,toggleAutoMode:u0,startSkipMode:Ep,stopSkipMode:Rr,toggleSkipMode:p0,showDialogueUI:Is,hideDialogueUI:xp,toggleDialogueUI:f0,setDialogueTextSpeed:d0,setAutoForwardDelay:m0,setAutoForwardSpeed:y0,setSkipUnseenText:h0,setSkipTransitionsAndAnimations:g0,setSoundVolume:b0,setMusicVolume:w0,setMuteAll:I0,setSaveLoadPagination:Qo,incrementSaveLoadPagination:Zo,decrementSaveLoadPagination:ea,setMenuPage:ra,setMenuEntryPoint:ta,showConfirmDialog:n0,hideConfirmDialog:s0,resetStoryAtSection:E0,clearPendingEffects:v0,appendPendingEffect:k0,completeAchievement:A0,setAchievementProgress:P0,beginRollbackActionBatch:kw,endRollbackActionBatch:Aw,ensureRandomReplayOccurrence:Pw,recordRandomOutcome:Ew,markRollbackCheckpointTransient:Iw,markSavedRollbackCheckpointTransient:vw,recordCurrentDialogueHistory:jw,addViewedLine:S0,addViewedResource:O0,showImageGalleryVariant:R0,moveToPreviousImageGalleryVariant:$0,moveToNextImageGalleryVariant:C0,clearImageGallerySelection:_0,moveToImageGalleryPage:j0,moveToNextImageGalleryPage:N0,moveToPreviousImageGalleryPage:D0,playMusicRoomTrack:L0,playMusicRoom:M0,pauseMusicRoom:q0,stopMusicRoom:V0,seekMusicRoom:F0,playPreviousMusicRoomTrack:U0,playNextMusicRoomTrack:B0,clearMusicRoomSelection:Y0,moveToMusicRoomPage:z0,moveToNextMusicRoomPage:X0,moveToPreviousMusicRoomPage:G0,musicRoomSoundReady:Z0,musicRoomSoundProgress:eI,musicRoomSoundComplete:rI,musicRoomSoundError:tI,startSceneReplay:H0,finishSceneReplay:Mp,exitSceneReplay:K0,moveToSceneReplayPage:W0,moveToNextSceneReplayPage:J0,moveToPreviousSceneReplayPage:Q0,setNextLineConfig:Up,saveSlot:nI,loadSlot:sI,updateProjectData:iI,updateLocalizationPackage:oI,sectionTransition:uI,jumpToLine:aI,nextLine:lI,markLineCompleted:cI,rollbackToLine:$I,rollbackByOffset:RI,pushOverlay:i0,popOverlay:o0,replaceLastOverlay:a0,clearOverlays:l0,updateFormField:yI,submitForm:hI,cancelForm:gI,updateVariable:bI,nextLineFromSystem:pI},{createTransactionalMetadata:a,updateTransactionalMetadata:NI,finalizeTransactionalMetadata:DI,transformActionFirstArgument:(s,o)=>({state:s,rollbackActionBatchStack:i,playbackOwnership:o}),transformSelectorFirstArgument:(s,o)=>({state:s,playbackOwnership:o})})};var MI="route-engine",qI="projectPersistence";var Wp=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),Ie=e=>Object.prototype.toString.call(e)==="[object Object]",Kp="variables.",VI=(e={})=>{let t=Ie(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!Ie(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)}:!Ie(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},FI=(e={})=>{let t=Ie(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!Ie(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)}:!Ie(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},UI=(e,t)=>{let n=FI(e),i=VI(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}},BI=(e={})=>{let t=Ie(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(i=>typeof i=="string"&&i.length>0))]}},YI=(e,t)=>{let n=BI(e),i=Ie(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...i.filter(a=>typeof a=="string"&&a.length>0)])]}},Jp=(e={})=>{let t=Ie(e)?e:{};return{saveSlots:Ie(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:Ie(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:Ie(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:Ie(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:Ie(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:Ie(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},zI=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!Ie(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let i=t.path?.startsWith(Kp)?t.path.slice(Kp.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(!Ie(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}].`)})},XI=(e,t)=>{let n={};return zI(t).forEach(i=>{if(i.path==="viewedRegistry"){n.accountViewedRegistry=UI(n.accountViewedRegistry??e.accountViewedRegistry,i.value);return}if(i.path==="replayRegistry"){n.accountReplayRegistry=YI(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},kt=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},GI=e=>{let t=kt(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},HI=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},KI=({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}".`))}}),WI=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.`))}})},un=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=f=>{u||(u=!0,s(f))},d=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let f=Jp(c.result),m=typeof i=="function"?i(f):i,b={namespace:n,version:1,...Wp(),...f,...m},h=l.put(b);h.onerror=()=>{p(h.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},o.oncomplete=()=>{d()},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}".`))}})},JI=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=d=>{c||(c=!0,r(d))},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}".`))}})},ja=(e={})=>{let{indexedDB:t,databaseName:n=MI,objectStoreName:i=qI,namespace:a}=e,r=HI(t),s=GI(a),o=KI({indexedDB:r,databaseName:n,objectStoreName:i});return{namespace:s,load:async()=>{let l=await WI({databasePromise:o,objectStoreName:i,namespace:s});return{...Wp(),...Jp(l)}},clear:async()=>JI({databasePromise:o,objectStoreName:i,namespace:s}),saveSlots:async l=>un({databasePromise:o,objectStoreName:i,namespace:s,patch:{saveSlots:Ie(l)?l:{}}}),saveGlobalDeviceVariables:async l=>un({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalDeviceVariables:Ie(l)?l:{}}}),saveGlobalAccountVariables:async l=>un({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalAccountVariables:Ie(l)?l:{}}}),saveGlobalRuntime:async l=>un({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalRuntime:Ie(l)?l:{}}}),applyScopedDataUpdates:async l=>un({databasePromise:o,objectStoreName:i,namespace:s,patch:c=>XI(c,l)})}},QI=ja;var cf=uf;var ZI={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},Je=Object.prototype.hasOwnProperty,ev={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 qe(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 f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[f]:r.push(f),s++}if(e.y===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[f]:r.push(f),s++}for(let f in e)if(!(f==="x"||f==="y"||f==="quality"||f==="kernelSize"||f==="repeatEdgePixels")){let m={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.x!==void 0){let f=e.x;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.y!==void 0){let f=e.y;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.quality!==void 0){let f=e.quality;if(typeof f=="number"){if(f<1||isNaN(f)){let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.kernelSize!==void 0){let f=e.kernelSize;if(!(typeof f=="number"&&!(f%1)&&!isNaN(f))){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[m]:r.push(m),s++}if(!(f===5||f===7||f===9||f===11||f===13||f===15)){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:ev.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[m]:r.push(m),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let f={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),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 qe.errors=r,s===0}var $e=Zp().default;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)){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 xs.errors=r,s===0}function nr(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++)xs(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,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:"array"},message:"must be array"};r===null?r=[o]:r.push(o),s++}return nr.errors=r,s===0}var rv={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Ss(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:rv.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 Ss.errors=r,s===0}function ue(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&&(Ss(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ss.errors:r.concat(Ss.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 ue.errors=r,s===0}function Os(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(!Je.call(ZI.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&&(qe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),e.filters!==void 0&&(nr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length)),e.animations!==void 0&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Os.errors=r,s===0}function uf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Os(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Os.errors:r.concat(Os.errors),s=r.length),uf.errors=r,s===0}var pf=ff;var ef={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},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},rf={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}},required:["id","resourceId"],additionalProperties:!1};function Me(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(!Je.call(rf.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:rf.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 Me.errors=r,s===0}function Rs(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 Rs.errors=r,s===0}function $s(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&&(Rs(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Rs.errors:r.concat(Rs.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 $s.errors=r,s===0}function Cs(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 w={};r===null?r=[w]:r.push(w),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 w={};r===null?r=[w]:r.push(w),s++}}var d=p===s;if(d){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 f=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let w={};r===null?r=[w]:r.push(w),s++}}var h=b===s;if(s=f,r!==null&&(f?r.length=f:r=null),h){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let g={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),s++}var h=y===s;m=h}if(!m){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(!Je.call(ef.properties,y)){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let g=0;g<w;g++)Me(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?Me.errors:r.concat(Me.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:ef.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}e.audioEffects!==void 0&&($s(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?$s.errors:r.concat($s.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 Cs.errors=r,s===0}function ff(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Cs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Cs.errors:r.concat(Cs.errors),s=r.length),ff.errors=r,s===0}var df=mf;var tv={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 _s(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],d=s,f=!0,m=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let b;if(p.sprites===void 0&&(b="sprites")){let h={};r===null?r=[h]:r.push(h),s++}}var o=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),o){let b=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=b===s;f=o}if(!f){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[b]:r.push(b),s++}for(let b in p)if(!Je.call(tv.properties.items.items.properties,b)){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(p.id!==void 0&&typeof p.id!="string"){let b={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let b={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(p.x!==void 0&&typeof p.x!="number"){let b={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.y!==void 0&&typeof p.y!="number"){let b={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let b={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let b={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let b={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let b={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let b={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let b={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let b={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let b={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let b={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.alpha!==void 0){let b=p.alpha;if(typeof b=="number"){if(b>1||isNaN(b)){let h={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=[h]:r.push(h),s++}if(b<0||isNaN(b)){let h={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=[h]:r.push(h),s++}}else{let h={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(p.opacity!==void 0){let b=p.opacity;if(typeof b=="number"){if(b>1||isNaN(b)){let h={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=[h]:r.push(h),s++}if(b<0||isNaN(b)){let h={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=[h]:r.push(h),s++}}else{let h={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(p.blur!==void 0&&(qe(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),p.filters!==void 0&&(nr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length)),p.sprites!==void 0){let b=p.sprites;if(Array.isArray(b)){let h=b.length;for(let y=0;y<h;y++){let w=b[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let g in w)if(!(g==="id"||g==="resourceId"||g==="animationName"||g==="animationSpeed"||g==="loop")){let E={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(w.id!==void 0&&typeof w.id!="string"){let g={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=[g]:r.push(g),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let g={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=[g]:r.push(g),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let g={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=[g]:r.push(g),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let g={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=[g]:r.push(g),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let g={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=[g]:r.push(g),s++}}else{let g={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=[g]:r.push(g),s++}}}else{let h={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}p.animations!==void 0&&(ue(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.errors),s=r.length))}else{let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),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 _s.errors=r,s===0}function mf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return _s(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),s=r.length),mf.errors=r,s===0}var yf=hf;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==="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 d={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),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 d=p.click;if(!(d&&typeof d=="object"&&!Array.isArray(d))){let f={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=[f]:r.push(f),s++}}}else{let d={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),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&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 js.errors=r,s===0}function hf(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),hf.errors=r,s===0}var gf=bf;function Ns(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 Ns.errors=r,s===0}function bf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ns(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),s=r.length),bf.errors=r,s===0}var wf=If;function Ds(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"){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 Ds.errors=r,s===0}function If(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ds(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),s=r.length),If.errors=r,s===0}var vf=kf;var tf={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 Ts(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(!Je.call(tf.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&&(ue(o.animations,{instancePath:t+"/ui/animations",parentData:o,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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:tf.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 d=c[p];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={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=[f]:r.push(f),s++}if(d.resourceId===void 0){let f={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=[f]:r.push(f),s++}for(let f in d)if(!(f==="id"||f==="resourceId"||f==="animationName"||f==="animationSpeed"||f==="loop")){let m={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(d.id!==void 0&&typeof d.id!="string"){let f={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=[f]:r.push(f),s++}if(d.resourceId!==void 0&&typeof d.resourceId!="string"){let f={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=[f]:r.push(f),s++}if(d.animationName!==void 0&&typeof d.animationName!="string"){let f={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=[f]:r.push(f),s++}if(d.animationSpeed!==void 0&&typeof d.animationSpeed!="number"){let f={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=[f]:r.push(f),s++}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={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=[f]:r.push(f),s++}}else{let f={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=[f]:r.push(f),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&&(ue(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Ts.errors=r,s===0}function kf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ts(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),s=r.length),kf.errors=r,s===0}var Af=Pf;function Ls(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&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Ls.errors=r,s===0}function Pf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ls(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),s=r.length),Pf.errors=r,s===0}var Ef=xf;function Ms(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&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 Ms.errors=r,s===0}function xf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ms(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),s=r.length),xf.errors=r,s===0}var Sf=Of;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==="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&&(qe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),e.animations!==void 0&&(ue(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.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 qs.errors=r,s===0}function Of(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),Of.errors=r,s===0}var Rf=$f;var nf={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};function Vs(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 d=0;d<p;d++)Me(u[d],{instancePath:t+"/items/"+d,parentData:u,parentDataProperty:d,rootData:a})||(r=r===null?Me.errors:r.concat(Me.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 d=0;d<p;d++){let f=u[d];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[m]:r.push(m),s++}if(f.sounds===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[m]:r.push(m),s++}for(let m in f)if(!(m==="id"||m==="volume"||m==="muted"||m==="pan"||m==="loop"||m==="interruption"||m==="applyMode"||m==="sounds")){let b={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),s++}if(f.id!==void 0){let m=f.id;if(typeof m=="string"){if($e(m)<1){let b={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}}if(f.volume!==void 0){let m=f.volume;if(typeof m=="number"){if(m>100||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(m<0||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/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+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(f.muted!==void 0&&typeof f.muted!="boolean"){let m={instancePath:t+"/channels/"+d+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(f.pan!==void 0){let m=f.pan;if(typeof m=="number"){if(m>1||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(m<-1||isNaN(m)){let b={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/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+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(f.loop!==void 0&&typeof f.loop!="boolean"){let m={instancePath:t+"/channels/"+d+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(f.interruption!==void 0){let m=f.interruption;if(typeof m!="string"){let b={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(m==="immediate"||m==="loopEnd")){let b={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:nf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(f.applyMode!==void 0){let m=f.applyMode;if(typeof m!="string"){let b={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(m==="singleLine"||m==="persistent")){let b={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:nf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(f.sounds!==void 0){let m=f.sounds;if(Array.isArray(m)){let b=m.length;for(let h=0;h<b;h++)Me(m[h],{instancePath:t+"/channels/"+d+"/sounds/"+h,parentData:m,parentDataProperty:h,rootData:a})||(r=r===null?Me.errors:r.concat(Me.errors),s=r.length)}else{let b={instancePath:t+"/channels/"+d+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),s++}}}else{let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),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 Vs.errors=r,s===0}function $f(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Vs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),s=r.length),$f.errors=r,s===0}var Cf=_f;var sf={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 Fs(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 f=e.length;for(let m=0;m<f;m++){let b=e[m];if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.text!==void 0&&typeof b.text!="string"){let h={instancePath:t+"/"+m+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(b.textStyleId!==void 0&&typeof b.textStyleId!="string"){let h={instancePath:t+"/"+m+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(b.furigana!==void 0){let h=b.furigana;if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let y={instancePath:t+"/"+m+"/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(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let y={instancePath:t+"/"+m+"/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+"/"+m+"/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 h={instancePath:t+"/"+m,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),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 Fs.errors=r,s===0}function Us(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 w;if(e.id===void 0&&(w="id")){let g={};r===null?r=[g]:r.push(g),s++}}var d=p===s;if(u=u||d,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.type===void 0&&(E="type")){let k={};r===null?r=[k]:r.push(k),s++}}var d=w===s;if(u=u||d,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.resourceId===void 0&&(P="resourceId")){let v={};r===null?r=[v]:r.push(v),s++}}var d=E===s;if(u=u||d,!u){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let L={};r===null?r=[L]:r.push(L),s++}}var d=P===s;if(u=u||d,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.transformId===void 0&&($="transformId")){let D={};r===null?r=[D]:r.push(D),s++}}var d=O===s;if(u=u||d,!u){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.transform===void 0&&(U="transform")){let _={};r===null?r=[_]:r.push(_),s++}}var d=$===s;if(u=u||d,!u){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.x===void 0&&(G="x")){let ae={};r===null?r=[ae]:r.push(ae),s++}}var d=U===s;if(u=u||d,!u){let G=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 d=G===s;if(u=u||d,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let X={};r===null?r=[X]:r.push(X),s++}}var d=M===s;if(u=u||d,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.anchorY===void 0&&(Z="anchorY")){let ie={};r===null?r=[ie]:r.push(ie),s++}}var d=le===s;if(u=u||d,!u){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.scaleX===void 0&&(K="scaleX")){let pe={};r===null?r=[pe]:r.push(pe),s++}}var d=Z===s;if(u=u||d,!u){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let oe;if(e.scaleY===void 0&&(oe="scaleY")){let C={};r===null?r=[C]:r.push(C),s++}}var d=K===s;if(u=u||d,!u){let oe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.flipX===void 0&&(j="flipX")){let F={};r===null?r=[F]:r.push(F),s++}}var d=oe===s;if(u=u||d,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let W;if(e.flipY===void 0&&(W="flipY")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var d=j===s;if(u=u||d,!u){let W=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Se;if(e.rotation===void 0&&(Se="rotation")){let be={};r===null?r=[be]:r.push(be),s++}}var d=W===s;if(u=u||d,!u){let Se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let lr={};r===null?r=[lr]:r.push(lr),s++}}var d=Se===s;if(u=u||d,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Fe;if(e.originY===void 0&&(Fe="originY")){let vn={};r===null?r=[vn]:r.push(vn),s++}}var d=me===s;if(u=u||d,!u){let Fe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Et;if(e.layer===void 0&&(Et="layer")){let xt={};r===null?r=[xt]:r.push(xt),s++}}var d=Fe===s;if(u=u||d,!u){let Et=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let St;if(e.alpha===void 0&&(St="alpha")){let kn={};r===null?r=[kn]:r.push(kn),s++}}var d=Et===s;if(u=u||d,!u){let St=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ot;if(e.opacity===void 0&&(Ot="opacity")){let An={};r===null?r=[An]:r.push(An),s++}}var d=St===s;if(u=u||d,!u){let Ot=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Rt;if(e.blur===void 0&&(Rt="blur")){let Pn={};r===null?r=[Pn]:r.push(Pn),s++}}var d=Ot===s;if(u=u||d,!u){let Rt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let et;if(e.filters===void 0&&(et="filters")){let En={};r===null?r=[En]:r.push(En),s++}}var d=Rt===s;if(u=u||d,!u){let et=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ri;if(e.animations===void 0&&(Ri="animations")){let xn={};r===null?r=[xn]:r.push(xn),s++}}var d=et===s;u=u||d}}}}}}}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),s++}var f=l===s;if(f){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),s++}else s=o,r!==null&&(o?r.length=o:r=null);let m=s,b=!1,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[w]:r.push(w),s++}var y=h===s;if(b=b||y,!b){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let E={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[E]:r.push(E),s++}var y=w===s;b=b||y}if(b)s=m,r!==null&&(m?r.length=m:r=null);else{let w={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Fs(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}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 Us.errors=r,s===0}function Bs(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 Bs.errors=r,s===0}var nv={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 Ys(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(!Je.call(nv.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 Ys.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 p in e)if(p!=="items"){let d={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let d=p.length;for(let f=0;f<d;f++){let m=p[f],b=s,h=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),s++}}var o=h===s;if(o){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=b,r!==null&&(b?r.length=b:r=null);let y=s,w=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var l=w===s;if(l){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=y,r!==null&&(y?r.length=y:r=null);let g=s,E=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.text===void 0&&(v="text")||m.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var c=E===s;if(c){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=g,r!==null&&(g?r.length=g:r=null);let k=s,P=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.transformId===void 0&&(v="transformId")||m.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),s++}}var u=P===s;if(u){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),s++}for(let v in m)if(!Je.call(sf.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),s++}if(m.id!==void 0&&typeof m.id!="string"){let v={instancePath:t+"/items/"+f+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let v={instancePath:t+"/items/"+f+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let v={instancePath:t+"/items/"+f+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let v={instancePath:t+"/items/"+f+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.text!==void 0&&(Us(m.text,{instancePath:t+"/items/"+f+"/text",parentData:m,parentDataProperty:"text",rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length)),m.layout!==void 0&&(Bs(m.layout,{instancePath:t+"/items/"+f+"/layout",parentData:m,parentDataProperty:"layout",rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),s=r.length)),m.transformId!==void 0&&typeof m.transformId!="string"){let v={instancePath:t+"/items/"+f+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.transform!==void 0&&(Ys(m.transform,{instancePath:t+"/items/"+f+"/transform",parentData:m,parentDataProperty:"transform",rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length)),m.x!==void 0&&typeof m.x!="number"){let v={instancePath:t+"/items/"+f+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.y!==void 0&&typeof m.y!="number"){let v={instancePath:t+"/items/"+f+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.anchorX!==void 0&&typeof m.anchorX!="number"){let v={instancePath:t+"/items/"+f+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.anchorY!==void 0&&typeof m.anchorY!="number"){let v={instancePath:t+"/items/"+f+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.scaleX!==void 0&&typeof m.scaleX!="number"){let v={instancePath:t+"/items/"+f+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.scaleY!==void 0&&typeof m.scaleY!="number"){let v={instancePath:t+"/items/"+f+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.flipX!==void 0&&typeof m.flipX!="boolean"){let v={instancePath:t+"/items/"+f+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(m.flipY!==void 0&&typeof m.flipY!="boolean"){let v={instancePath:t+"/items/"+f+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(m.rotation!==void 0&&typeof m.rotation!="number"){let v={instancePath:t+"/items/"+f+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.originX!==void 0&&typeof m.originX!="number"){let v={instancePath:t+"/items/"+f+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.originY!==void 0&&typeof m.originY!="number"){let v={instancePath:t+"/items/"+f+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.layer!==void 0){let v=m.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:sf.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),s++}}if(m.alpha!==void 0){let v=m.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(m.opacity!==void 0){let v=m.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}m.blur!==void 0&&(qe(m.blur,{instancePath:t+"/items/"+f+"/blur",parentData:m,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),m.filters!==void 0&&(nr(m.filters,{instancePath:t+"/items/"+f+"/filters",parentData:m,parentDataProperty:"filters",rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length)),m.animations!==void 0&&(ue(m.animations,{instancePath:t+"/items/"+f+"/animations",parentData:m,parentDataProperty:"animations",rootData:a})||(r=r===null?ue.errors:r.concat(ue.errors),s=r.length))}else{let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let d={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),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 zs.errors=r,s===0}function _f(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),_f.errors=r,s===0}var jf=Nf;var sv={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 Xs(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 g={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),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,d=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 w={};r===null?r=[w]:r.push(w),s++}}var f=d===s;if(f){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 m=s,b=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 w={};r===null?r=[w]:r.push(w),s++}}var h=b===s;if(h){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=m,r!==null&&(m?r.length=m: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 w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let g=0;g<w;g++)Me(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?Me.errors:r.concat(Me.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:sv.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),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 Xs.errors=r,s===0}function Nf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Xs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),s=r.length),Nf.errors=r,s===0}var Df=Tf;var iv={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 Gs(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 h={};r===null?r=[h]:r.push(h),s++}var u=c===s;if(s=o,r!==null&&(o?r.length=o:r=null),u){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[w]:r.push(w),s++}var u=h===s;l=u}if(!l){let h={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let p=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let h={};r===null?r=[h]:r.push(h),s++}var m=f===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let h=s,y=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.target===void 0&&(E="target")){let k={};r===null?r=[k]:r.push(k),s++}}var b=w===s;if(b){let E={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[E]:r.push(E),s++}else s=y,r!==null&&(y?r.length=y:r=null);var m=h===s;d=m}if(!d){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[h]:r.push(h),s++}if(e.name===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[h]:r.push(h),s++}if(e.description===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[h]:r.push(h),s++}for(let h in e)if(!(h==="type"||h==="target"||h==="name"||h==="description"||h==="lockedName"||h==="lockedDescription"||h==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let h=e.type;if(typeof h!="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(!(h==="boolean"||h==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:iv.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 h=e.target;if(!(typeof h=="number"&&!(h%1)&&!isNaN(h))){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 h=="number"&&(h<1||isNaN(h))){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 h=e.name;if(typeof h=="string"){if($e(h)<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 h=e.description;if(typeof h=="string"){if($e(h)<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 h=e.lockedName;if(typeof h=="string"){if($e(h)<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 h=e.lockedDescription;if(typeof h=="string"){if($e(h)<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 h={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}return Gs.errors=r,s===0}function Tf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Gs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),s=r.length),Tf.errors=r,s===0}var Lf=Mf;var ov={type:"object",required:["type"],$defs:{keyframe:{type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},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"]},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{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"},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/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},alpha:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/tweenProperty"},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:{$ref:"#/$defs/mask"}},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"};var av={type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},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"]},relative:{type:"boolean"}},additionalProperties:!1};function Wr(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==="value"||o==="duration"||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.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.easing!==void 0){let o=e.easing;if(typeof o!="string"){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(o==="linear"||o==="easeInQuad"||o==="easeOutQuad"||o==="easeInOutQuad"||o==="easeInCubic"||o==="easeOutCubic"||o==="easeInOutCubic"||o==="easeInQuart"||o==="easeOutQuart"||o==="easeInOutQuart"||o==="easeInQuint"||o==="easeOutQuint"||o==="easeInOutQuint"||o==="easeInSine"||o==="easeOutSine"||o==="easeInOutSine"||o==="easeInExpo"||o==="easeOutExpo"||o==="easeInOutExpo"||o==="easeInCirc"||o==="easeOutCirc"||o==="easeInOutCirc"||o==="easeInBack"||o==="easeOutBack"||o==="easeInOutBack"||o==="easeInBounce"||o==="easeOutBounce"||o==="easeInOutBounce"||o==="easeInElastic"||o==="easeOutElastic"||o==="easeInOutElastic")){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:av.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(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 Wr.errors=r,s===0}function re(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++)Wr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Wr.errors:r.concat(Wr.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 re.errors=r,s===0}function Hs(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==="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&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.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 Hs.errors=r,s===0}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)){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&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.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 Ks.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.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&&(Ks(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.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 Hr.errors=r,s===0}var Es={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"]}}]},lv={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};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)){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:lv.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 Ws.errors=r,s===0}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)){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++)Wr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Wr.errors:r.concat(Wr.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 Js.errors=r,s===0}function Qs(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 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.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=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,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let g={};r===null?r=[g]:r.push(g),s++}var m=f===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let g=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 m=g===s;d=m}if(!d){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 b=s,h=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let g={};r===null?r=[g]:r.push(g),s++}var w=y===s;if(s=b,r!==null&&(b?r.length=b:r=null),w){let g=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 w=g===s;h=w}if(!h){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++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!Je.call(Es.properties,g)){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.kind!==void 0){let g=e.kind;if(typeof g!="string"){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="single"||g==="sequence"||g==="composite")){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Es.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let g={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.textures!==void 0){let g=e.textures;if(Array.isArray(g)){if(g.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 E=g.length;for(let k=0;k<E;k++)if(typeof g[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 E={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.items!==void 0){let g=e.items;if(Array.isArray(g)){if(g.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 E=g.length;for(let k=0;k<E;k++)Ws(g[k],{instancePath:t+"/items/"+k,parentData:g,parentDataProperty:k,rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),s=r.length)}else{let E={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.combine!==void 0){let g=e.combine;if(typeof g!="string"){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="max"||g==="min"||g==="multiply"||g==="add")){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Es.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.channel!==void 0){let g=e.channel;if(typeof g!="string"){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="red"||g==="green"||g==="blue"||g==="alpha")){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Es.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let g={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let g={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let g={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}e.progress!==void 0&&(Js(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),s=r.length))}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 Qs.errors=r,s===0}function Zs(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 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,E=s,k=s,P=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=$===s;if(v=v||p,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let ae={};r===null?r=[ae]:r.push(ae),s++}}var p=U===s;v=v||p}}if(v)s=P,r!==null&&(P?r.length=P:r=null);else{let $={};r===null?r=[$]:r.push($),s++}var d=k===s;if(d){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),s++}else s=E,r!==null&&(E?r.length=E: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=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 f=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var h=b===s;if(s=f,r!==null&&(f?r.length=f:r=null),h){let g=s,E=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===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=E,r!==null&&(E?r.length=E:r=null);let P=s,v=!1,O=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 w=O===s;if(v=v||w,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=$===s;if(v=v||w,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[G]:r.push(G),s++}var w=U===s;v=v||w}}if(v)s=P,r!==null&&(P?r.length=P: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 h=g===s;m=h}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++}for(let g in e)if(!(g==="name"||g==="type"||g==="complete"||g==="tween"||g==="prev"||g==="next"||g==="mask")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let E={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="update"||g==="transition")){let E={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:ov.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.complete!==void 0){let g=e.complete;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.payload!==void 0){let E=g.payload;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let k={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}}else{let E={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}e.tween!==void 0&&(Hs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length)),e.prev!==void 0&&(Hr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Hr.errors:r.concat(Hr.errors),s=r.length)),e.next!==void 0&&(Hr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Hr.errors:r.concat(Hr.errors),s=r.length)),e.mask!==void 0&&(Qs(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),s=r.length))}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 Zs.errors=r,s===0}function Mf(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),Mf.errors=r,s===0}var qf=Vf;var cv={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"]},fade:{oneOf:[{type:"object",required:["duration"],properties:{delay:{type:"number",minimum:0},duration:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"}},additionalProperties:!1},{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/fadeKeyframe"}}},additionalProperties:!1}]},transitionSide:{type:"object",minProperties:1,properties:{fade:{$ref:"#/$defs/fade"}},additionalProperties:!1},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}}}}]},fadeKeyframe:{allOf:[{$ref:"#/$defs/boundedKeyframe"},{not:{properties:{relative:{const:!0}},required:["relative"]}}]},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:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},updateTween:{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/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"}},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 ei(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 ei.errors=r,s===0}var uv={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 Jr(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:uv.enum},message:"must be equal to one of the allowed values"};r===null?r=[o]:r.push(o),s++}return Jr.errors=r,s===0}function sr(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&&(ei(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?ei.errors:r.concat(ei.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&&(Jr(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?Jr.errors:r.concat(Jr.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 sr.errors=r,s===0}function Qr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;sr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?sr.errors:r.concat(sr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),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 h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>100||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>100||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var b=h===s;f=b}if(!f){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}return Qr.errors=r,s===0}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.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!=="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.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++)Qr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Qr.errors:r.concat(Qr.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 ri.errors=r,s===0}function ti(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;sr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?sr.errors:r.concat(sr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),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 h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>1||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>1||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var b=h===s;f=b}if(!f){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}return ti.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.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!=="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.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++)ti(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?ti.errors:r.concat(ti.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 ni.errors=r,s===0}function si(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;sr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?sr.errors:r.concat(sr.errors),s=r.length);let o=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),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 h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"&&(w<0||isNaN(w))){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"&&(w<0||isNaN(w))){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var b=h===s;f=b}if(!f){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}return si.errors=r,s===0}function ii(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!=="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.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++)si(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?si.errors:r.concat(si.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 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(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&&(ri(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),s=r.length)),e.pan!==void 0&&(ni(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),s=r.length)),e.playbackRate!==void 0&&(ii(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?ii.errors:r.concat(ii.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 oi.errors=r,s===0}function ai(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;Qr(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Qr.errors:r.concat(Qr.errors),s=r.length);let o=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.relative===void 0&&(u="relative")){let p={};r===null?r=[p]:r.push(p),s++}else if(e.relative!==void 0&&e.relative!==!0){let p={};r===null?r=[p]:r.push(p),s++}}var c=l===s;if(c){let u={instancePath:t,schemaPath:"#/allOf/1/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);return ai.errors=r,s===0}function li(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=null,u=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.duration===void 0){let f={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[f]:r.push(f),s++}for(let f in e)if(!(f==="delay"||f==="duration"||f==="easing")){let m={instancePath:t,schemaPath:"#/oneOf/0/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.delay!==void 0){let f=e.delay;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/delay",schemaPath:"#/oneOf/0/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/delay",schemaPath:"#/oneOf/0/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.duration!==void 0){let f=e.duration;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/duration",schemaPath:"#/oneOf/0/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/duration",schemaPath:"#/oneOf/0/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}e.easing!==void 0&&(Jr(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?Jr.errors:r.concat(Jr.errors),s=r.length))}else{let f={instancePath:t,schemaPath:"#/oneOf/0/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}var d=u===s;d&&(l=!0,c=0);let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let f={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[f]:r.push(f),s++}for(let f in e)if(f!=="keyframes"){let m={instancePath:t,schemaPath:"#/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.keyframes!==void 0){let f=e.keyframes;if(Array.isArray(f)){if(f.length<1){let b={instancePath:t+"/keyframes",schemaPath:"#/oneOf/1/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[b]:r.push(b),s++}let m=f.length;for(let b=0;b<m;b++)ai(f[b],{instancePath:t+"/keyframes/"+b,parentData:f,parentDataProperty:b,rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),s=r.length)}else{let m={instancePath:t+"/keyframes",schemaPath:"#/oneOf/1/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}}}else{let f={instancePath:t,schemaPath:"#/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}var d=p===s;if(d&&l?(l=!1,c=[c,1]):d&&(l=!0,c=1),l)s=o,r!==null&&(o?r.length=o:r=null);else{let f={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),s++}return li.errors=r,s===0}function Kr(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!=="fade"){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.fade!==void 0&&(li(e.fade,{instancePath:t+"/fade",parentData:e,parentDataProperty:"fade",rootData:a})||(r=r===null?li.errors:r.concat(li.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 Kr.errors=r,s===0}function ci(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 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,E=s,k=s,P=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=$===s;v=v||p}if(v)s=P,r!==null&&(P?r.length=P:r=null);else{let $={};r===null?r=[$]:r.push($),s++}var d=k===s;if(d){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),s++}else s=E,r!==null&&(E?r.length=E: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=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 f=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var h=b===s;if(s=f,r!==null&&(f?r.length=f:r=null),h){let g=s,E=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===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=E,r!==null&&(E?r.length=E:r=null);let P=s,v=!1,O=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 w=O===s;if(v=v||w,!v){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=$===s;v=v||w}if(v)s=P,r!==null&&(P?r.length=P: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 h=g===s;m=h}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++}for(let g in e)if(!(g==="name"||g==="type"||g==="tween"||g==="prev"||g==="next")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(!(g==="update"||g==="transition")){let E={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:cv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}e.tween!==void 0&&(oi(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),s=r.length)),e.prev!==void 0&&(Kr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Kr.errors:r.concat(Kr.errors),s=r.length)),e.next!==void 0&&(Kr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Kr.errors:r.concat(Kr.errors),s=r.length))}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 ci.errors=r,s===0}function Vf(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),Vf.errors=r,s===0}var Ff=Uf;function ui(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")){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++}}}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 ui.errors=r,s===0}function Uf(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),Uf.errors=r,s===0}var Bf=Yf;var pv=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");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(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(!pv.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 pi.errors=r,s===0}function Yf(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),Yf.errors=r,s===0}var zf=Xf;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(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 d={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=[d]:r.push(d),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 d={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=[d]:r.push(d),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 fi.errors=r,s===0}function Xf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return fi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),s=r.length),Xf.errors=r,s===0}var Gf=Hf;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 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 di.errors=r,s===0}function Hf(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),Hf.errors=r,s===0}var Kf=Wf;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.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 mi.errors=r,s===0}function Wf(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),Wf.errors=r,s===0}var Jf=Qf;function yi(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 yi.errors=r,s===0}var of=new RegExp("^\\$(if .+|for .+|else)$","u"),Da={validate:pn};function hi(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(!of.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(of.test(o)){let l=e[o];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)Da.validate(l[u],{instancePath:t+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?Da.validate.errors:r.concat(Da.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 hi.errors=r,s===0}function pn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=s;yi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),s=r.length);var u=c===s;if(l=l||u,!l){let p=s;hi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?hi.errors:r.concat(hi.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 pn.errors=r,s===0}function gi(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++)pn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?pn.errors:r.concat(pn.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 gi.errors=r,s===0}var Ta={validate:fn};function fn(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&&(gi(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?gi.errors:r.concat(gi.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++)Ta.validate(o[c],{instancePath:t+"/children/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Ta.validate.errors:r.concat(Ta.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 fn.errors=r,s===0}function bi(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=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++)fn(o[c],{instancePath:t+"/elements/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?fn.errors:r.concat(fn.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 bi.errors=r,s===0}function Qf(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return bi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),s=r.length),Qf.errors=r,s===0}var Zf=ed;function wi(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,d=s,f=s,m=!1,b=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 h=b===s;if(m=m||h,!m){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.texture===void 0&&(v="texture")){let O={};r===null?r=[O]:r.push(O),s++}}var h=k===s;if(m=m||h,!m){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.behaviors===void 0&&(L="behaviors")){let $={};r===null?r=[$]:r.push($),s++}}var h=v===s;if(m=m||h,!m){let L=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.emitter===void 0&&(D="emitter")){let U={};r===null?r=[U]:r.push(U),s++}}var h=L===s;m=m||h}}}if(m)s=f,r!==null&&(f?r.length=f:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=d===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 g=u===s;g&&(l=!0,c=0);let w=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 g=w===s;if(g&&l?(l=!1,c=[c,1]):g&&(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 v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),s++}if(k.emission!==void 0){let P=k.emission;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.movement!==void 0){let P=k.movement;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.appearance!==void 0){let P=k.appearance;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.bounds!==void 0){let P=k.bounds;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),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,v=!1,O=null,L=s;if(typeof k=="string"){if($e(k)<1){let D={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=[D]:r.push(D),s++}}else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[D]:r.push(D),s++}var E=L===s;E&&(v=!0,O=0);let $=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[D]:r.push(D),s++}var E=$===s;if(E&&v?(v=!1,O=[O,1]):E&&(v=!0,O=1),v)s=P,r!==null&&(P?r.length=P:r=null);else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[D]:r.push(D),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let v={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let P=k.length;for(let v=0;v<P;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[L]:r.push(L),s++}for(let L in O)if(!(L==="type"||L==="config")){let $={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:L},message:"must NOT have additional properties"};r===null?r=[$]:r.push($),s++}if(O.type!==void 0){let L=O.type;if(typeof L=="string"){if($e(L)<1){let $={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[$]:r.push($),s++}}else{let $={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[$]:r.push($),s++}}if(O.config!==void 0){let L=O.config;if(!(L&&typeof L=="object"&&!Array.isArray(L))){let $={instancePath:t+"/behaviors/"+v+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[$]:r.push($),s++}}}else{let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[L]:r.push(L),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 v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),s++}if(P.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),s++}if(P.min!==void 0){let v=P.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={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=[O]:r.push(O),s++}}else{let O={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=[O]:r.push(O),s++}}if(P.max!==void 0){let v=P.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={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=[O]:r.push(O),s++}}else{let O={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=[O]:r.push(O),s++}}}else{let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),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 wi.errors=r,s===0}function ed(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return wi(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),s=r.length),ed.errors=r,s===0}var rd=td;var af={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 Ii(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(!Je.call(af.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:af.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 Ii.errors=r,s===0}function td(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ii(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),s=r.length),td.errors=r,s===0}var nd=sd;var fv=new RegExp("^.+$","u");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.jsonData===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};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==="jsonData"||o==="width"||o==="height"||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.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.jsonData!==void 0){let o=e.jsonData;if(!(o&&typeof o=="object"&&!Array.isArray(o))){let l={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),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++}}if(e.animations!==void 0){let o=e.animations;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)if(fv.test(l)){let c=o[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="loop")){let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++)if(typeof u[d]!="number"){let f={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}else{let p={instancePath:t+"/animations/"+l.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=[p]:r.push(p),s++}}if(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}}else{let u={instancePath:t+"/animations/"+l.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=[u]:r.push(u),s++}}}else{let l={instancePath:t+"/animations",schemaPath:"#/properties/animations/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 vi.errors=r,s===0}function sd(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),sd.errors=r,s===0}var id=od;var lf={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"},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 ki(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(!Je.call(lf.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,d=s;if(typeof l=="string"){if($e(l)<1){let m={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=[m]:r.push(m),s++}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[m]:r.push(m),s++}var o=d===s;o&&(u=!0,p=0);let f=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 m=l.length;for(let y=0;y<m;y++){let w=l[y];if(typeof w=="string"){if($e(w)<1){let g={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=[g]:r.push(g),s++}}else{let g={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}}let b=l.length,h;if(b>1){let y={};for(;b--;){let w=l[b];if(typeof w=="string"){if(typeof y[w]=="number"){h=y[w];let g={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:b,j:h},message:"must NOT have duplicate items (items ## "+h+" and "+b+" are identical)"};r===null?r=[g]:r.push(g),s++;break}y[w]=b}}}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}var o=f===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 m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[m]:r.push(m),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&&typeof e.fontWeight!="string"){let l={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),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:lf.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 ki.errors=r,s===0}function od(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ki(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),s=r.length),od.errors=r,s===0}var ad=ld;var dv={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 Ai(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(!Je.call(dv.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 Ai.errors=r,s===0}function ld(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ai(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),s=r.length),ld.errors=r,s===0}var cd=ud;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(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 Pi.errors=r,s===0}function ud(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),ud.errors=r,s===0}var yn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),mn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),gr=e=>e===void 0?void 0:structuredClone(e),mv=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"}),yv=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),hv=Object.freeze({background:cf,bgm:pf,character:df,choice:yf,cleanAll:gf,control:wf,dialogue:vf,form:Af,layout:Ef,screen:Sf,sfx:Rf,visual:Cf,voice:jf}),gv=Object.freeze({achievement:Df,animation:Lf,audioEffect:qf,character:Ff,color:Bf,control:zf,font:Gf,image:Kf,layout:Jf,particle:Zf,sound:rd,spritesheet:nd,textStyle:id,transform:ad,video:cd}),bv=new Set(["files","language","patches"]),wv=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Iv=new Set(["lineId","mode","payload","type"]),vv=new Set(["mode","payload","sceneId","type"]),kv=new Set(["mode","operation","payload","resourceId","type"]),Av=new Set(["fileId","mimeType"]),H=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},Qe=(e,t)=>{mn(e)||H(t,"expected an object")},La=(e,t)=>{Array.isArray(e)||H(t,"expected an array")},At=(e,t)=>{(typeof e!="string"||e.length===0)&&H(t,"expected a non-empty string")},md=(e,t)=>{typeof e!="string"&&H(t,"expected a string")},or=(e,t,n)=>{for(let i of Object.keys(e))t.has(i)||H(`${n}.${i}`,"unknown field")},ar=(e,t,n)=>{for(let i of t)yn(e,i)||H(n,`missing required field "${i}"`)},Pv=e=>e.replaceAll("~1","/").replaceAll("~0","~"),Ev=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(Pv);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)},xv=(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],yd=({value:e,validator:t,path:n,contract:i})=>{if(t(e))return;let a=xv(t.errors);H(Ev(n,a),`does not match ${i}: ${a?.message??"schema validation failed"}`)},Ei=(e,t,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||H(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)=>Ei(i,`${t}[${a}]`,n));return}Object.entries(e).forEach(([i,a])=>Ei(a,`${t}.${i}`,n))}},ir=(e,t)=>{e===""&&H(t,"expected a non-empty resourceId")},Sv=(e,t,n)=>{let i=(s,o)=>ir(s?.resourceId,`${o}.resourceId`),a=(s,o)=>(s??[]).forEach((l,c)=>ir(l?.resourceId,`${o}[${c}].resourceId`)),r=(s,o)=>{ir(s?.resourceId,`${o}.resourceId`),a(s?.sounds,`${o}.sounds`)};switch(e){case"background":ir(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)=>ir(l?.resourceId,`${n}.items[${o}].sprites[${c}].resourceId`)),i(s.animations,`${n}.items[${o}].animations`)});break;case"choice":case"form":case"layout":ir(t.resourceId,`${n}.resourceId`),i(t.animations,`${n}.animations`);break;case"control":ir(t.resourceId,`${n}.resourceId`);break;case"dialogue":ir(t.ui?.resourceId,`${n}.ui.resourceId`),i(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,o)=>ir(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)=>{ir(s?.resourceId,`${n}.items[${o}].resourceId`),i(s?.animations,`${n}.items[${o}].animations`)});break;default:break}},Pt=(e,t)=>{At(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&H(t,`"${e}" is not a safe ID`)},Ov=(e,t)=>{At(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&H(t,"must be a safe single filename")},dn=(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)=>dn(a,t[r]));if(!mn(e)||!mn(t))return!1;let n=Object.keys(e).sort(),i=Object.keys(t).sort();return dn(n,i)&&n.every(a=>dn(e[a],t[a]))},xi=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(i=>xi(i,t,n)),t;if(!mn(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),xi(a,t,n);return t},Rv=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},hd=(e,t,n)=>{let i=e.get(t)??[];return i.length===0&&H(n,`lineId "${t}" does not exist in projectData`),i.length>1&&H(n,`lineId "${t}" is not globally unique in projectData`),i[0]},gd=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],pd=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),fd=e=>{let t=gr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))mn(n)&&delete n.placeholder;return t},$v=(e,t,n,i)=>{e==="choice"&&!dn(pd(t),pd(n))&&H(i,"choice item IDs and events must remain identical to the source action"),e==="form"&&!dn(fd(t),fd(n))&&H(i,"form behavior must remain identical; only presentation fields and placeholders may change")},Cv=({patch:e,path:t,lineIndex:n})=>{or(e,wv,t),ar(e,["type","lineId","actionType","payload"],t),Pt(e.lineId,`${t}.lineId`),At(e.actionType,`${t}.actionType`),Qe(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.action supports only "replace"'),yv.has(e.actionType)||H(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let i=hd(n,e.lineId,`${t}.lineId`),a=i.line?.actions?.[e.actionType];return a===void 0&&H(`${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")&&H(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),yn(e.payload,"content")&&H(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&H(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),$v(e.actionType,a,e.payload,`${t}.payload`),yd({value:e.payload,validator:hv[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Ei(e.payload,`${t}.payload`),Sv(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:i,patch:e}},_v=(e,t)=>{La(e,t),e.forEach((n,i)=>{Qe(n,`${t}[${i}]`),or(n,new Set(["text"]),`${t}[${i}]`),ar(n,["text"],`${t}[${i}]`),md(n.text,`${t}[${i}].text`)})},jv=({patch:e,path:t,lineIndex:n})=>{or(e,Iv,t),ar(e,["type","lineId","payload"],t),Pt(e.lineId,`${t}.lineId`),Qe(e.payload,`${t}.payload`),or(e.payload,new Set(["content"]),`${t}.payload`),ar(e.payload,["content"],`${t}.payload`),_v(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.dialogue supports only "replace"');let i=hd(n,e.lineId,`${t}.lineId`);return i.line?.actions?.dialogue===void 0&&H(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:i,patch:e}},Nv=({patch:e,path:t,projectData:n})=>(or(e,vv,t),ar(e,["type","mode","sceneId","payload"],t),Pt(e.sceneId,`${t}.sceneId`),Qe(e.payload,`${t}.payload`),or(e.payload,new Set(["name"]),`${t}.payload`),ar(e.payload,["name"],`${t}.payload`),md(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&H(`${t}.mode`,'story.scene requires "patch"'),yn(n?.story?.scenes??{},e.sceneId)||H(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),Dv=(e,t,n)=>{Qe(t,n),["font","image","sound","spritesheet","video"].includes(e)&&At(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="spritesheet"&&(Qe(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&H(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),yd({value:t,validator:gv[e],path:n,contract:`the resource.${e} schema`}),Ei(t,n)},Tv=({patch:e,path:t,projectData:n,packageFileIds:i,canonicalFileIds:a})=>{or(e,kv,t),ar(e,["type","resourceId","payload"],t),Pt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=mv[r];s||H(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&H(`${t}.operation`,'the only resource operation is "add"'),Dv(r,e.payload,`${t}.payload`);let o=n?.resources?.[s]??{},l=yn(o,e.resourceId);e.operation==="add"&&l&&H(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&H(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of xi(e.payload))!i.has(c)&&!a.has(c)&&H(`${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}},dd=({resources:e,collectionName:t,resourceId:n,path:i,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!yn(e?.[t]??{},n))&&H(i,`${a} resource "${n}" was not found`)},Lv=(e,t)=>{let n=gr(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=gr(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)=>dd({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]])dd({resources:i,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${o}`,label:"color"})}},Mv=({patch:e,path:t,projectData:n,lineIndex:i,packageFileIds:a,canonicalFileIds:r})=>{if(Qe(e,t),At(e.type,`${t}.type`),e.type==="line.action")return Cv({patch:e,path:t,lineIndex:i});if(e.type==="line.dialogue")return jv({patch:e,path:t,lineIndex:i});if(e.type==="story.scene")return Nv({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return Tv({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});H(`${t}.type`,`unsupported patch type "${e.type}"`)},qv=(e,t)=>{La(e,t);let n=new Set;return e.forEach((i,a)=>{let r=`${t}[${a}]`;Qe(i,r),or(i,Av,r),ar(i,["fileId"],r),Ov(i.fileId,`${r}.fileId`),i.mimeType!==void 0&&(typeof i.mimeType!="string"||i.mimeType.length===0)&&H(`${r}.mimeType`,"expected a non-empty string"),n.has(i.fileId)&&H(`${r}.fileId`,`duplicate fileId "${i.fileId}"`),n.add(i.fileId)}),n},Vv=({packageId:e,packageData:t,path:n,projectData:i,lineIndex:a,canonicalFileIds:r})=>{Qe(t,n),or(t,bv,n),ar(t,["language","files","patches"],n),At(t.language,`${n}.language`);let s=qv(t.files,`${n}.files`);La(t.patches,`${n}.patches`);let o=new Set,l=t.patches.map((c,u)=>{let p=Mv({patch:c,path:`${n}.patches[${u}]`,projectData:i,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return o.has(p.key)&&H(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),o.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},bd=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};Qe(t,"l10nData"),or(t,new Set(["packages"]),"l10nData"),ar(t,["packages"],"l10nData"),Qe(t.packages,"l10nData.packages");let n=Rv(e),i=xi(e?.resources??{}),a=new Map,r=new Map;for(let[s,o]of Object.entries(t.packages)){Pt(s,`l10nData.packages.${s}`);let l=Vv({packageId:s,packageData:o,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:i});for(let c of l.fileIds){i.has(c)&&H(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&H(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}Lv(e,l),a.set(s,l)}return{packages:a}},Fv=(e,t)=>{let{collectionName:n,patch:i}=t;e.resources[n]??={},e.resources[n][i.resourceId]=gr(i.payload)},Uv=(e,t)=>{let{patch:n}=t,i=e.story.scenes[n.sceneId];i.name=n.payload.name},Bv=(e,t)=>{let{location:n,patch:i}=t,a=gd(e,n);if(i.actionType!=="dialogue"){a.actions[i.actionType]=gr(i.payload);return}let r=gr(n.line.actions.dialogue.content);a.actions.dialogue=gr(i.payload),r!==void 0&&(a.actions.dialogue.content=r)},Yv=(e,t)=>{let{location:n,patch:i}=t,a=gd(e,n);a.actions.dialogue.content=gr(i.payload.content)},wd=({projectData:e,l10nData:t})=>{let n=bd({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),i=>({l10nId:i.id,language:i.data.language}))]},Si=({projectData:e,l10nData:t,l10nId:n=null})=>{let i=bd({projectData:e,l10nData:t});if(n!==null&&(Pt(n,"l10nId"),i.packages.has(n)||H("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=gr(e),r=i.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>Fv(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>Uv(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>Bv(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>Yv(a,s)),a};var Ma=Object.freeze({auto:1e3,skip:80,authored:1e3}),bn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Id=new WeakMap,zv=new ArrayBuffer(8),qa=new DataView(zv),Xv=e=>{let t=Id.get(e);if(t)return t;let n={dispatchDepth:0};return Id.set(e,n),n},Gv=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Hv=(e,t)=>Object.keys(e).length===t.length&&t.every(i=>Object.prototype.hasOwnProperty.call(e,i)),jr=(e,t,n)=>{if(!Gv(e)||!Hv(e,t))throw new TypeError(`${n} has an invalid shape`)},hn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},gn=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},vd=e=>{if(gn(e,"duration"),e===0)return 0n;qa.setFloat64(0,e,!1);let t=qa.getUint32(0,!1),n=qa.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)},Kv=e=>structuredClone(e),Va=(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,Fa=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(jr(t,["owner","delayMs","contentKey"],"auto timer"),jr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),hn(t.owner.sessionId,"auto owner sessionId"),hn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(gn(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")jr(t,["owner","delayMs"],"skip timer"),jr(t.owner,["sessionId"],"skip timer owner"),hn(t.owner.sessionId,"skip owner sessionId"),gn(t.delayMs,"skip delayMs");else{if(jr(t,["owner","delayMs","trigger"],"authored timer"),jr(t.owner,["lineEntryId"],"authored timer owner"),hn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(gn(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,...Kv(t)}},Wv=e=>{if(jr(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(hn(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}}jr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:Fa("auto",e.timers.auto,e.lineEntryId),skip:Fa("skip",e.timers.skip,e.lineEntryId),authored:Fa("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}},Ua=e=>({descriptor:e,remainingQuanta:vd(e.delayMs)}),Oi=["auto","skip","authored"],kd=({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=Xv(e),a=!0,r={},s={},o=null,l=null,c=null,u=null,p=!1,d=!1,f="legacy",m={auto:null,skip:null,authored:null},b={auto:null,skip:null,authored:null},h={auto:0,skip:0,authored:0},y=()=>Oi.some(M=>m[M]),w=()=>{l=null,c=null},g=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(i.dispatchDepth>0||d){g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&o===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},E=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=o;M&&(w(),o=null,u=M,e.remove(M),u===M&&(u=null))},P=()=>{m={auto:null,skip:null,authored:null}},v=()=>{P(),s={},d||k()},O=M=>{if(i.dispatchDepth>0||d){c=M,g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&o===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},L=()=>{if(!a||!y()||o)return;E();let M=r,Q=s,le={},X=ie=>{if(!a||M!==r||Q!==s||le!==l||X!==o||d)return;if(!ie||typeof ie.deltaMS!="number"||!Number.isFinite(ie.deltaMS)||ie.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let K=vd(ie.deltaMS);d=!0,i.dispatchDepth+=1;let pe=s,oe=null;try{let C=[];for(let j of Oi){let F=m[j];F&&(F.remainingQuanta<=K?(C.push({kind:j,descriptor:F.descriptor,revision:h[j]}),m[j]=null):F.remainingQuanta-=K)}if(C.length>0){try{t({dueKinds:C.map(({kind:j})=>j)})}catch(j){let F=n(j);if(f==="reconciled"&&F==="preCommit")for(let{kind:W,descriptor:fe}of C)b[W]=fe;else f==="legacy"&&P();throw j}if(f==="legacy")for(let j of C)j.kind==="skip"&&h.skip===j.revision&&m.skip===null&&(m.skip=Ua(j.descriptor))}}catch(C){oe=C}finally{i.dispatchDepth-=1,d=!1;try{pe===s?y()?L():k():o===X&&!y()&&k()}catch(C){throw oe?new AggregateError([oe,C],"Playback attempt and ticker cleanup both failed"):C}}if(oe)throw oe},Z={callback:X,lifecycleToken:M,generationToken:Q,registrationToken:le};o=X,c=Z;try{e.add(X)}catch(ie){throw o=null,w(),P(),s={},u=X,ie}O(Z)},$=M=>{h[M]+=1,m[M]=null,b[M]=null,!y()&&!d&&k()},D=(M,Q)=>{gn(Q,`${M} delay`),f="legacy",h[M]+=1,b[M]=null,m[M]=Ua({mode:"legacy",kind:M,instanceToken:{},delayMs:Q}),L()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return D("auto",M.payload?.delay??Ma.auto),!0;case"clearAutoNextTimer":return $("auto"),!0;case"startSkipNextTimer":return D("skip",M.payload?.delay??Ma.skip),!0;case"clearSkipNextTimer":return $("skip"),!0;case"nextLineConfigTimer":return D("authored",M.payload?.delay??Ma.authored),!0;case"clearNextLineConfigTimer":return $("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let Q;try{Q=Wv(M)}catch(X){try{v()}catch(Z){throw new AggregateError([X,Z],"Playback schedule validation and cleanup both failed")}throw X}if(f="reconciled",Q.status==="unsettled"){P(),d||k();return}let le={};for(let X of Oi){let Z=Q.timers[X],ie=b[X];if(ie&&(!Z||!Va(ie,Z))&&(b[X]=null),Z&&b[X]&&Va(b[X],Z)){le[X]=null;continue}let K=m[X];le[X]=Z&&K&&Va(K.descriptor,Z)?K:Z?Ua(Z):null}m=le,y()?L():d||k()},reset:()=>{let M=[o,u].filter((X,Z,ie)=>X&&ie.indexOf(X)===Z);r={},s={},w(),o=null,u=null,P(),b={auto:null,skip:null,authored:null};for(let X of Oi)h[X]+=1;f="legacy",a=!0;let Q=null,le=null;for(let X of M)try{e.remove(X)}catch(Z){Q??=Z,le??=X}if(u=le,Q)throw Q},dispose:()=>{a=!1,r={},s={},w(),P(),b={auto:null,skip:null,authored:null};let M=[o,u].filter((X,Z,ie)=>X&&ie.indexOf(X)===Z);o=null,u=null;let Q=null,le=null;for(let X of M)try{e.remove(X)}catch(Z){Q??=Z,le??=X}if(u=le,Q)throw Q}}};var Jv=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),Qv=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Ba="conditional",wn="random",za=Symbol("conditionalAutoContinue"),Zv=new Set(["sectionTransition","resetStoryAtSection"]),ek=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),rk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),tk=new Set(["nextLine","nextLineFromSystem"]),nk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Ya="form",sk=new Set(["submitForm","cancelForm"]),ik="showImageGalleryVariant",ok="playMusicRoomTrack",ak="startSceneReplay",lk="channel:bgm",ck=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"]),Ve=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),uk=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,In=e=>e?.type===za,Zr=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,pk=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(i=>!Object.is(e?.[i],t?.[i]));function Xa(e){let t=uk(),n,i=0,a=!1,r=0,s=null,o=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,b=new Map,h=0,y=null,w=[],g=!1,E=null,k=null,P=new Map,v,O,L=null,$=!1,D=!1,U=0,_=new Map,G=rc(e.randomSource),{handlePendingEffects:ae}=e;if(typeof ae!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let M=ae.bind(ae),Q=typeof ae.reconcilePlaybackScheduleV1=="function"?ae.reconcilePlaybackScheduleV1.bind(ae):null,le=typeof ae.reset=="function"?ae.reset.bind(ae):null,X=typeof ae.dispose=="function"?ae.dispose.bind(ae):null;if(Q&&(!le||!X))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let Z=I=>{if(D)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ie=I=>{if(Z(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},K=(I,A)=>{if(U===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=_.get(I);(R===void 0||S[A]>S[R])&&_.set(I,A)},pe=I=>{let A=_.get(I)??"preCommit";return _.delete(I),A},oe=I=>{if(Q){D=!0;try{let A=Q(structuredClone(I));if(A!==null&&(typeof A=="object"||typeof A=="function")&&typeof A.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{D=!1}}},C=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),j=I=>{if(!(!Q||!a||!n)){$=!0;try{oe(C())}catch(A){if(I){let S=new AggregateError([I,A],"Playback work and schedule invalidation both failed");throw _.delete(I),K(S,"reconcileFailed"),S}throw K(A,"reconcileFailed"),A}}},F=()=>{if(!Q||!$||!a||!n||o>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(A){throw K(A,"reconcileFailed"),j(A),A}try{oe({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(A){throw K(A,"reconcileFailed"),j(A),A}$=!1},W=(I=new Map,A=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>A<S.expiresAt).map(([S,R])=>[S,{animation:structuredClone(R.animation),startedAt:R.startedAt,expiresAt:R.expiresAt}])),fe=(I=new Map)=>Array.from(I.values()).map(A=>structuredClone(A.animation)),Se=(I=Date.now())=>{f=new Map(Array.from(f.entries()).filter(([,A])=>I<A.expiresAt))},be=()=>{if(a&&!(o>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let I=n.selectCurrentPointer()?.pointer??null,A=[...n.selectPendingEffects()],S=A.map(R=>R.name!=="handleLineActions"?R:{...R,payload:{...R.payload,pointer:structuredClone(I)}});n.clearPendingEffects();try{let R=Q?S.filter(N=>!bn.has(N.name)):S;R.length>0&&M(R)}catch(R){throw n.clearPendingEffects(),A.forEach(N=>{n.appendPendingEffect(N)}),K(R,"postCommitUnsettled"),j(R),R}}}finally{l=!1}F()}},me=I=>{o+=1;let A=!1;try{let S=I();return A=!0,S}finally{o-=1,A&&be()}},lr=()=>{let I=n.selectSystemState();return Yo({presentationState:n.selectPresentationState(),resources:I.projectData?.resources,runtime:n.selectRuntime(),musicRoomPlayer:I.global?.musicRoomPlayer})},Fe=()=>structuredClone(g?E:lr()),vn=I=>{let A=n.selectSystemState().projectData?.story?.scenes??{};return Object.entries(A).find(([,S])=>S?.sections?.[I])?.[0]},Et=()=>{if(w.length===0)return;let I=n.selectRuntime()?.skipTransitionsAndAnimations===!0,A=I?null:y?.id;w.forEach(S=>{S.status=S.effect?.id===A?"active":"settled"}),I&&(y=null),w=[]},xt=(I,A,S,R)=>{I?.audioEffects||(y=null);let N=n.selectPlaybackLineEntryId?.()??0,Y=(A.actionPath??["bgm"]).join("."),B=n.selectCurrentPointer()?.pointer,te=B?.sceneId??vn(B?.sectionId),de=A.rollbackSource==="line"&&B?`story.scenes[${JSON.stringify(te)}].sections[${JSON.stringify(B.sectionId)}].lines[${JSON.stringify(B.lineId)}].actions.${Y}`:Y,ye=A.rollbackSource==="line"?`${i}:${N}:${de}`:null,we=ye?P.get(ye):null;if(we)return we;h+=1;let ge={occurrenceId:`${t}:g${i}:l${N}:audio${h}`,actionPath:de,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Ne=n.selectSystemState().projectData?.resources,De=fc({occurrence:ge,resources:Ne,previousChannel:S,nextChannel:R});if(ge.effect=De?structuredClone(De):null,ge.status=De?"pending":"settled",y=De?structuredClone(De):null,w.push(ge),ye)for(P.set(ye,ge);P.size>512;){let tt=P.keys().next().value;P.delete(tt)}return ge},St=({initialState:I,namespace:A})=>{Z("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...N}=I,Y=R===void 0?void 0:structuredClone(R),B=structuredClone(I.projectData),te=wd({projectData:B,l10nData:Y}),de=N.global??{};if(!Ve(de))throw new Error("Malformed global state.");let ye=de.runtime??{};if(!Ve(ye))throw new Error("Malformed global.runtime.");let we=ye.localizationPackageId;if(we!=null&&typeof we!="string")throw new Error("localizationPackageId requires a string or null value");let ge=new Set(te.map(({l10nId:nt})=>nt).filter(nt=>nt!==null)),Ne=typeof we=="string"&&ge.has(we)?we:null,De=Si({projectData:B,l10nData:Y,l10nId:Ne}),tt=Hp({...N,global:{...de,localizationPackages:te,runtime:{...ye,localizationPackageId:Ne}},projectData:De,initialAudioCommandId:S});le?.(),n=tt,i+=1,a=!0,r=0,s=kt(A),o=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,b=new Map,h=0,y=null,w=[],g=!1,E=null,k={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null},P=new Map,v=B,O=Y,L=Ne,$=!0,D=!1,U=0,_.clear(),n.appendPendingEffect({name:"handleLineActions"}),be()},kn=()=>{Z("dispose"),a&&(a=!1,i+=1,n?.clearPendingEffects?.(),o=0,l=!1,u=[],p=null,d=null,f=new Map,m=new Map,b=new Map,y=null,w=[],g=!1,E=null,k=null,P=new Map,$=!1,_.clear(),X?.())},Ot=()=>s,An=()=>n.selectPresentationState(),Rt=()=>n.selectPresentationChanges(),Pn=I=>n.selectSectionLineChanges(I),et=(I={})=>{ie("rendering"),r+=1;let A=Date.now();Se(A);let S=m.size>0,R=W(f,A),N=S?W(m,A):new Map,Y=n.selectRenderState({activePersistentAnimations:fe(R),restoredPersistentAnimations:fe(N),activeAudioEffect:y?structuredClone(y):null}),B={...Y,id:`render-${t}-${i}-${r}`};return b.set(B.id,{builtAt:A,persistentAnimationSessions:new Map([...N.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectId:y?.id??null,retainsActiveAudioEffect:!!y&&(Y.audioEffects??[]).some(te=>te.id===y.id)}),B},En=(I={})=>et(I),Ri=(I={})=>et(I),xn=I=>{if(!a||!n)return;let A=I?.audio?.find(Y=>Y?.id===lk);g=!0,E=A?structuredClone(A):null;let S=typeof I?.id=="string"&&I.id.length>0?I.id:null,R=S?b.get(S):null;S&&b.delete(S);let N=new Map;Gc(I?.animations).forEach(Y=>{let B=os(Y);if(!B)return;let te=R?.persistentAnimationSessions?.get(B)??f.get(B),de=Math.max(0,Wc(Y)),ye=te?.startedAt??R?.builtAt??Date.now();N.set(B,{animation:structuredClone(Y),startedAt:ye,expiresAt:ye+de})}),f=N,R?.usedRestoredPersistentAnimationSessions&&(m=new Map),R?.activeAudioEffectId&&!R.retainsActiveAudioEffect&&y?.id===R.activeAudioEffectId&&(y=null)},Sd=()=>n.selectSystemState(),Od=()=>n.selectAchievements(),Rd=I=>n.selectAchievement(I),Ha=()=>n.selectSaveSlotMap(),$d=I=>n.selectSaveSlot(I),Cd=I=>n.selectSaveSlotPage(I),_d=()=>n.selectImageGallery(),jd=()=>n.selectMusicRoom(),Nd=()=>n.selectSceneReplay(),Dd=()=>n.selectIsSceneReplayActive(),Pk=()=>n.selectSkipMode(),Ek=()=>n.selectAutoMode(),Td=()=>n.selectRuntime(),Ld=()=>n.selectIsChoiceVisible(),Md=()=>n.selectIsFormVisible(),qd=()=>n.selectActiveInteraction(),Vd=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),Ka=(I,A,S={})=>!Ve(A)||I!=="nextLine"?A:S.bypassChoice===!0?{...A,bypassChoice:!0}:S.interactionSource===Ya?{...A,_interactionSource:Ya}:A,Wa=(I={})=>({type:za,payload:Ka("nextLine",{_conditionalContinuation:!0},I)}),$i=(I,A)=>In(I)?{type:za,payload:{...I.payload,...A.payload}}:A,Fd=I=>{I.savedCheckpointOccurrences.forEach(A=>{n.markSavedRollbackCheckpointTransient(A)}),I.savedCheckpointOccurrences=[]},Ud=(I,A)=>{let S=p;return p=null,!S||!Zr(S.pointer,I)||S.checkpointIndex!==A?.checkpointIndex||S.checkpointIdentity!==A?.checkpoint?[]:S.savedCheckpointOccurrences},Bd=I=>{let A=d;return!A||!Zr(A.pointer,I)?null:(d=null,A)},Yd=({actionType:I,pointerBeforeAction:A,pointerAfterAction:S,cursorBeforeAction:R,cursorAfterAction:N,wasSceneReplayActive:Y,isSceneReplayActive:B})=>{!S||!(!Zr(A,S)||R?.checkpoint!==N?.checkpoint||R?.checkpointIndex!==N?.checkpointIndex||I==="jumpToLine")||(d={pointer:S,appendToPrevious:tk.has(I)&&Y===B&&A?.sectionId===S.sectionId&&A?.lineId!==S.lineId,reuseExistingOccurrence:nk.has(I),forceNewOccurrence:I==="jumpToLine"})},Ja=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),Fd(I))},zd=(I,A,S)=>ek.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==A?.checkpoint:S?.checkpoint!==A?.checkpoint&&S?.checkpointIndex>A?.checkpointIndex:!1,Xd=I=>{let A=u.at(-1);if(!A?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&A.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:A.rollbackCursor?.checkpointIndex,sectionId:A.pointer?.sectionId,lineId:A.pointer?.lineId})},Gd=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(A=>{let S=n.selectSaveSlot({slotId:A.slotId});S&&(A.saveSlotIdentity=S)})},Hd=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},Kd=(I,A,S)=>{let R=u.at(-1);if(!R)return;let N=n.selectCurrentPointer()?.pointer,Y=zd(I,A,S);if(Zr(R.pointer,N)){let B=S?.checkpoint!==A?.checkpoint||S?.checkpointIndex!==A?.checkpointIndex;Y||B&&rk.has(I)?(Ja(R),R.pointer=N,R.rollbackCursor=S,R.markCurrentCheckpointTransient=Y,R.savedCheckpointOccurrences=[]):B&&I==="updateProjectData"&&(R.rollbackCursor=S);return}Ja(R),R.pointer=N,R.rollbackCursor=n.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=Y,R.savedCheckpointOccurrences=[]},rt=(I,A)=>{if(ie(`action "${I}"`),!n[I])return;let S=A,R,N;if(I==="updateProjectData")Qa(A),R=structuredClone(A.projectData),S={...A,projectData:Si({projectData:R,l10nData:O,l10nId:L})},Qa(S);else if(I==="updateLocalizationPackage"){if(N=Wd(A),N===L)return;S={l10nId:N,projectData:Si({projectData:v,l10nData:O,l10nId:N})}}Zv.has(I)&&(c+=1);let Y=n.selectAutoMode(),B=Y?n.selectRuntime():null,te=n.selectIsSceneReplayActive?.()===!0,de=Qv.has(I)?W(f):null,ye=n.selectCurrentPointer()?.pointer??null,we=n.selectRollbackCursor?.()??null,ge=Qn(I),Ne=ge?n.selectPlaybackLineEntryId?.()??0:null,De=ge?Fe():null,tt=!1,nt;try{nt=n[I](S),tt=!0}catch($t){throw K($t,"preCommit"),$t}R!==void 0&&(v=R),N!==void 0&&(L=N),Jv.has(I)&&(m=de??new Map,f=new Map,y=null),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=null);let sl=n.selectIsSceneReplayActive?.()===!0;te!==sl&&(f=new Map,m=new Map);let um=n.selectCurrentPointer()?.pointer??null,il=n.selectRollbackCursor?.()??null,ol=ge?n.selectPlaybackLineEntryId?.()??0:null;ge&&ol!==Ne&&(k={lineEntryId:ol,channel:De}),I==="saveSlot"?Xd(A):I==="updateProjectData"&&Gd(),Kd(I,we,il),Yd({actionType:I,pointerBeforeAction:ye,pointerAfterAction:um,cursorBeforeAction:we,cursorAfterAction:il,wasSceneReplayActive:te,isSceneReplayActive:sl});let pm=n.selectAutoMode()&&(I==="updateVariable"||Y&&pk(B,n.selectRuntime()));(ck.has(I)||pm)&&($=!0);try{be()}catch($t){throw tt&&K($t,"postCommitUnsettled"),$t}return nt},Qa=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Vr(I?.projectData?.resources?.variables??{}),Lt(I.projectData),Mt(I.projectData),qt(I.projectData)},Wd=I=>{if(!Ve(I))throw new Error("updateLocalizationPackage requires an object payload");let A=Object.keys(I);if(A.length!==1||A[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(I.l10nId!==null&&(typeof I.l10nId!="string"||I.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return I.l10nId},Jd=(I,A,S)=>{let R=n.selectCurrentPointer()?.pointer;A!==R||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),rt("nextLineFromSystem",I.payload))},Qd=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:d,persistentAnimationSessions:new Map(f),restoredPersistentAnimationSessions:new Map(m),renderPersistentAnimationMetadata:new Map(b),audioEffectOccurrenceSequence:h,activeAudioEffect:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:k?structuredClone(k):null,acceptedLineBgmActionOccurrences:new Map(P),canonicalProjectData:v,localizationPackageId:L,playbackScheduleDirty:$}),Zd=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,d=I.pendingDialogueHistoryLineEntry,f=new Map(I.persistentAnimationSessions),m=new Map(I.restoredPersistentAnimationSessions),b=new Map(I.renderPersistentAnimationMetadata),h=I.audioEffectOccurrenceSequence,y=I.activeAudioEffect,w=I.pendingAudioEffectOccurrences.slice(),k=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,P=new Map(I.acceptedLineBgmActionOccurrences),v=I.canonicalProjectData,L=I.localizationPackageId,$=I.playbackScheduleDirty},Ci=(I,A={})=>(ie("action batch"),me(()=>{let S=Qd();try{return n[io](()=>{let R,N=n.selectCurrentPointer()?.pointer??null,Y=n.selectRollbackCursor?.()??null,B=c,te={pointer:N,rollbackCursor:Y,markCurrentCheckpointTransient:A.rollbackSource==="line",savedCheckpointOccurrences:A.savedCheckpointOccurrences?.slice()??[]};u.push(te);try{n.beginRollbackActionBatch({source:A.rollbackSource});try{R=I()}finally{n.endRollbackActionBatch({})}In(R)&&Jd(R,N,B),Et();let de=n.selectCurrentPointer()?.pointer??null;A.rollbackSource==="line"&&Zr(N,de)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:te.savedCheckpointOccurrences,appendToPrevious:A.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:A.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:A.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!Zr(N,te.pointer)||Y?.checkpoint!==te.rollbackCursor?.checkpoint)&&te.markCurrentCheckpointTransient&&te.savedCheckpointOccurrences.length>0&&(p={pointer:te.pointer,checkpointIndex:te.rollbackCursor?.checkpointIndex,checkpointIdentity:te.rollbackCursor?.checkpoint,savedCheckpointOccurrences:te.savedCheckpointOccurrences})}})}catch(R){throw Zd(S),R}})),_i=(I,A,S,R={})=>{if(I===Ba||I===wn)return Ci(()=>{let N={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[I],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(I===wn)return rl(A,S,N);let Y=ji(S),B=Bt({[I]:A},Y);return el(B[I],S,N)},R);if(I==="bgm")return Ci(()=>{let N=A?.audioEffects?Fe():null;rt(I,A),xt(A,{...R,actionPath:R.actionPath??[I]},N,A?.audioEffects?lr():null)},R);rt(I,A)},em=(I,A)=>{if(I!=="nextLineFromSystem")return _i(I,A);U+=1;try{return _i(I,A)}finally{U=Math.max(0,U-1)}},Za=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},ji=I=>{if(Za(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:A,...S}=I,R=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:A,variables:R,runtime:n.selectRuntime?n.selectRuntime():{}}},rm=I=>{if(!Ve(I))return{templatePayload:I,literalTargetIds:null};let A=n.selectImageGalleryConfig();if(!Array.isArray(A?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?A.groups.find(N=>N.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let R=typeof I.variantId=="string"&&S.variants.some(N=>N.id===I.variantId);return{templatePayload:{...I,groupId:null,...R?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...R?{variantId:I.variantId}:{}}}},tm=I=>!Ve(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(R=>R.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},nm=I=>!Ve(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},sm=I=>{if(!Ve(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},im=(I,A,S)=>{if(!Ve(I))throw new Error(`conditional branch at index ${A} must be an object`);if(!Ve(I.actions))throw new Error(`conditional branch at index ${A} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&A!==S-1)throw new Error("conditional else branch must be the last branch")},el=(I,A,S)=>{sm(I);let R=Wa(S);for(let N=0;N<I.branches.length;N+=1){let Y=I.branches[N];im(Y,N,I.branches.length);let B=ji(A);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!Tt(Y.when,B))continue;let de=Sn(Y.actions,A,{...S,actionPath:[...S.actionPath??[Ba],"branches",String(N),"actions"]});return In(de)?$i(R,de):R}return R},om=I=>{if(!Ve(I))throw new Error("random action payload must be an object");let A=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(A!==void 0)throw new Error(`random action.${A} is not supported`);if(!Ve(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=v?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||Re(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},rl=(I,A,S)=>{om(I),Za(A);let R=tc(I.distribution,{randomSource:G});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let B=(S.actionPath??[wn]).join("."),te=S.randomOutcomeOrdinals??new Map,de=te.get(B)??0;te.set(B,de+1),n.recordRandomOutcome({path:B,ordinal:de,type:R.type,result:R}),Hd()}let N;R.type==="integer"?rt("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:R.value}]}):N=Sn(I.distribution.outcomes[R.outcomeIndex].actions,A,{...S,actionPath:[...S.actionPath??[wn],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let Y=Wa(S);return In(N)?$i(Y,N):Y},am=(I,A)=>({...I??{},_form:A}),lm=(I,A,S,R)=>{let N=rt(I,A),Y=N?.submitted===!0&&N.valid===!0,B=N?.cancelled===!0;if(!(!Y&&!B)&&Ve(A.actions))return Sn(A.actions,am(S,N.form),{...R,interactionSource:Ya})},tl=(I,A,S,R)=>{if(I===wn)return rl(A,S,R);let N=ji(S),Y={templatePayload:A,literalTargetIds:null};I===ik?Y=rm(A):I===ok?Y=tm(A):I===ak&&(Y=nm(A));let{templatePayload:B,literalTargetIds:te}=Y,ye=Bt({[I]:B},N)[I],we=te?{...ye,...te}:ye;if(I===Ba)return el(we,S,R);let ge=Ka(I,we,R);if(sk.has(I))return lm(I,ge,S,R);let Ne=null;if(I==="bgm"&&ge?.audioEffects){let De=R.audioEffectHandoff;De?.available?(De.available=!1,Ne=structuredClone(De.channel)):Ne=Fe()}rt(I,ge),I==="bgm"&&xt(ge,R,Ne,ge?.audioEffects?lr():null)},Sn=(I,A,S)=>{let R,N=S?.executionContext??{depth:0,pendingNavigation:null},Y=Jn(I);Zn(Y),N.depth+=1;try{for(let[B,te]of Y){let de={...S,executionContext:N,actionPath:[...S?.actionPath??[],B]};if(Qn(B)){let we=N.pendingNavigation;if(we)throw new Error(`action batch cannot execute multiple navigation actions: ${we.actionType}, ${B}`);N.pendingNavigation={actionType:B,payload:te,eventContext:A,options:de};continue}let ye=tl(B,te,A,de);In(ye)&&(R=$i(R,ye))}}finally{N.depth-=1}if(N.depth===0&&N.pendingNavigation){let B=N.pendingNavigation;N.pendingNavigation=null,tl(B.actionType,B.payload,B.eventContext,B.options)}return R},nl=(I,A,S={})=>{let R={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Ci(()=>Sn(I,A,R),R)},cm=I=>{let A=n.selectCurrentPointer()?.pointer;if(I!==A||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:St,dispose:kn,handleAction:_i,handleInternalAction:em,handleActions:nl,selectRenderState:En,prepareRenderState:Ri,commitRenderState:xn,selectPresentationState:An,selectPresentationChanges:Rt,selectSectionLineChanges:Pn,selectSystemState:Sd,selectAchievements:Od,selectAchievement:Rd,selectSaveSlotMap:Ha,selectSaveSlot:$d,selectSaveSlotPage:Cd,selectSaveSlots:Ha,selectImageGallery:_d,selectMusicRoom:jd,selectSceneReplay:Nd,selectIsSceneReplayActive:Dd,selectRuntime:Td,selectIsChoiceVisible:Ld,selectIsFormVisible:Md,selectActiveInteraction:qd,selectHasPendingRenderWork:Vd,handleLineActions:I=>{ie("line action handling");let A=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!Zr(I.pointer,A))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return me(()=>{let S=n.selectCurrentPointer()?.pointer,R=n.selectPlaybackLineEntryId?.()??0,N=k?.lineEntryId===R?k:null,Y=n.selectRollbackCursor?.()??null,B=p,te=d,de=Ud(S,Y),ye=Bd(S),we=n.selectCurrentLine(),ge=!1;if(we?.actions){try{nl(we.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:de,dialogueHistoryAppendToPrevious:ye?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ye?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ye?.forceNewOccurrence===!0,audioEffectHandoff:N?{available:!0,channel:structuredClone(N.channel)}:null})}catch(Ne){throw p=B,d=te,Ne}ge=!0}return k?.lineEntryId===R&&(k=null),cm(S),ge})},getNamespace:Ot,classifyAutomaticAttemptError:pe}}var fk="music-room:player",Ed=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Ad=(e,t)=>Ed.has(e)&&t?._event?.id===fk,xd=({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)},dk=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:i,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let o=i?.()??0,l=e.handleLineActions(s);(i?.()??0)===o&&xd({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},mk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},yk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},hk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},gk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},bk=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},Pd={render:xd,saveSlots:mk,saveGlobalDeviceVariables:yk,saveGlobalAccountVariables:hk,saveGlobalRuntime:gk,applyScopedDataUpdates:bk,handleLineActions:dk},wk=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Ga=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},Ik=(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(!wk.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},vk=({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,d=!1,f=0,m=0,b=!0,h=kd({ticker:n,dispatchAutomaticAttempt:()=>Ga(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:C=>e()?.classifyAutomaticAttemptError?.(C)??"preCommit"}),y=()=>{u=null,p=null,d=!1,f=0},w=()=>{h.reset(),m+=1,y(),b=!0},g=()=>{m+=1,b=!1,y(),h.dispose()},E=C=>b&&C===m,k=C=>{if(a){a(C);return}console.error("RouteEngine persistence write failed.",C)},P=C=>{if(s)return s;let j=kt(C),F=l.get(j);if(F)return F;let W=ja({indexedDB:r,namespace:j});return l.set(j,W),W},v=C=>{let j=s?null:kt(o??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=P(j),C(F))).catch(W=>{!s&&l.get(j)===F&&l.delete(j),k(W)})},O=C=>{if(!b)return;let j=typeof C?.id=="string"&&C.id.length>0?C.id:null;f+=1,u=j,d=!1},L=()=>f,$=(C={})=>{if(!b||C?.aborted===!0)return!1;let j=typeof C?.id=="string"&&C.id.length>0?C.id:null;return j?j!==u||j===p?!1:(p=j,!0):u!==null||d?!1:(d=!0,!0)},D=(C,j={})=>{if(!b)return!1;if(Ad(C,j)){let W=Ed.get(C),fe=e();return Ga(fe,W,j?._event),!0}if(C!=="renderComplete"||!$(j))return!1;let F=e();return Ga(F,"markLineCompleted",{}),!0},U=new Set(["updateFormField","submitForm","cancelForm"]),_=new Set(["updateVariable"]),G=C=>typeof C?.selectActiveInteraction=="function"?C.selectActiveInteraction():typeof C?.selectIsChoiceVisible=="function"&&C.selectIsChoiceVisible()?{source:"choice"}:null,ae=C=>C?._formKey??C?.formKey,M=(C,j)=>ae(C)===j?.formKey,Q=(C,j)=>!C||typeof C!="object"||Array.isArray(C)?!1:C._interactionSource===j?.source,le=(C,j)=>Q(C,j)?j.source==="form"?M(C,j):!0:!1,X=(C,j)=>!C||typeof C!="object"||Array.isArray(C)||j?.source!=="form"?!1:M(C,j),Z=(C={},j)=>Object.keys(C).length>0&&Object.entries(C).every(([F,W])=>U.has(F)?X(W,j):_.has(F)),ie=(C={},j)=>{let F=C?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:Z(F,j):le(C,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(W=>le(W,j))},K=(C,j={})=>{if(!j?.actions)return!1;let F=G(C);return!F||F.source==="choice"?!1:!ie(j,F)},pe=({preprocessPayload:C,onEvent:j}={})=>async(F,W={})=>{if(!b)return!1;if(Ad(F,W))return D(F,W),j?.(F,W);let fe=e(),Se=m,be=f;if(K(fe,W))return j?.(F,W);let me=await C?.(F,W)??W;if(!E(Se)||e()!==fe||f!==be)return!1;if(K(fe,me))return j?.(F,me);if(D(F,me),me?.actions){let lr=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,Fe;me?.bypassChoice===!0?Fe={bypassChoice:!0}:me?._interactionSource&&(Fe={interactionSource:me._interactionSource}),Fe?fe.handleActions(me.actions,lr,Fe):fe.handleActions(me.actions,lr)}return j?.(F,me)},oe=C=>{if(!b)return;let j=m,F=e(),W=Ik(C),fe=W.some(be=>be.name==="handleLineActions");W.forEach(be=>{if(!Pd[be.name]&&!bn.has(be.name)&&!i)throw new Error(`Unhandled pending effect "${be.name}".`)});let Se={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:L,enqueuePersistenceWrite:v,lifecycleGeneration:m,isCurrentLifecycle:E};for(let be of W){if(!E(j))break;if(fe&&be.name==="render")continue;if(bn.has(be.name)){h.handleLegacyEffect(be);continue}let me=Pd[be.name];if(me){me(Se,be.payload);continue}i(be,Se)}};return oe.handleRouteGraphicsEvent=D,oe.createRouteGraphicsEventHandler=pe,oe.reset=w,oe.dispose=g,oe.reconcilePlaybackScheduleV1=C=>h.reconcilePlaybackScheduleV1(C),oe},kk=vk;var Ak=(e,t={})=>{let{resources:n={}}=t;return Lo(e,n)};var vP=Xa;export{go as DEFAULT_VISUAL_LAYER,pt as RENDER_LAYER,cr as VISUAL_LAYER,kk as createEffectsHandler,QI as createIndexedDbPersistence,vP as default,ao as formatDate,Ty as resolveComputedVariables,Ak as resolveLayoutReferences};