@neta-art/cohub-cli 10.27.1 → 10.28.1

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.
@@ -53,7 +53,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
53
53
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=j,c=!Ke.jitless,l=c&&M.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?wr([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Dr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!_e(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Se(e,r,qe())))}),t)}const Or=I(`$ZodUnion`,(e,t)=>{Cn.init(e,t),Le(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),Le(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Le(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),Le(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>_(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Dr(t,r,e,i)):Dr(o,r,e,i)}});function kr(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}const Ar=I(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Or.init(e,t);let n=e._zod.parse;Le(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||x(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=S(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=h(()=>kr(t));e._zod.parse=(i,a)=>{let o=i.value;if(!j(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),jr=I(`$ZodIntersection`,(e,t)=>{Cn.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Nr(e,t,n)):Nr(e,i,a)}});function Mr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(te(e)&&te(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Mr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Mr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Nr(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Mr(t.value,n.value);if(!c.valid){if(_e(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Pr=I(`$ZodRecord`,(e,t)=>{Cn.init(e,t);let n=Ke.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!te(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Se(e,i,qe())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...ye(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...ye(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Zt.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Se(e,i,qe())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...ye(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...ye(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Fr=I(`$ZodEnum`,(e,t)=>{Cn.init(e,t);let n=d(t.entries),r=new Set(n);e._zod.values=r,Le(e,`pattern`,e=>{let t=d(e.def.entries).filter(e=>ne.has(typeof e));return RegExp(t.length?`^(${t.map(e=>re(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ir=I(`$ZodLiteral`,(e,t)=>{Cn.init(e,t);let n=new Set(t.values);e._zod.values=n,Le(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?re(e):e?re(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Lr=I(`$ZodTransform`,(e,t)=>{Cn.init(e,t),e._zod.optin=`optional`,Ke.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ge(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new We;return n.value=i,n}});function Rr(e,t){return e.value=t.issues.length?void 0:t.value,e}const zr=I(`$ZodOptional`,(e,t)=>{Cn.init(e,t),Le(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,Le(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),Le(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${_(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Rr(e,t)):Rr(e,r)}return t.innerType._zod.run(e,n)}}),Br=I(`$ZodExactOptional`,(e,t)=>{zr.init(e,t),Le(e,`values`,e=>e.def.innerType._zod.values),Le(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Vr=I(`$ZodNullable`,(e,t)=>{Cn.init(e,t),Le(e,`optin`,e=>e.def.innerType._zod.optin),Le(e,`optout`,e=>e.def.innerType._zod.optout),Le(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${_(t.source)}|null)$`):void 0}),Le(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Hr=I(`$ZodDefault`,(e,t)=>{Cn.init(e,t),e._zod.optin=`defaulted`,Le(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ur(e,t)):Ur(r,t)}});function Ur(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Wr=I(`$ZodPrefault`,(e,t)=>{Cn.init(e,t),e._zod.optin=`defaulted`,Le(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Gr=I(`$ZodNonOptional`,(e,t)=>{Cn.init(e,t),Le(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Kr(t,e)):Kr(i,e)}});function Kr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function qr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Se(e,r,qe()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Jr=I(`$ZodCatch`,(e,t)=>{Cn.init(e,t),Le(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),Le(e,`optout`,e=>e.def.innerType._zod.optout),Le(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>qr(e,r,t,n)):qr(e,r,t,n)}}),Yr=I(`$ZodPipe`,(e,t)=>{Cn.init(e,t),Le(e,`values`,e=>e.def.in._zod.values),Le(e,`optin`,e=>e.def.in._zod.optin),Le(e,`optout`,e=>e.def.out._zod.optout),Le(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Xr(e,t.in,n)):Xr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Xr(e,t.out,n)):Xr(r,t.out,n)}});function Xr(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Zr=I(`$ZodReadonly`,(e,t)=>{Cn.init(e,t),Le(e,`propValues`,e=>e.def.innerType._zod.propValues),Le(e,`values`,e=>e.def.innerType._zod.values),Le(e,`optin`,e=>e.def.innerType?._zod?.optin),Le(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Qr):Qr(r)}});function Qr(e){return e.memo||(e.value=Object.freeze(e.value)),e}const $r=I(`$ZodLazy`,(e,t)=>{Cn.init(e,t),b(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),Le(e,`pattern`,e=>e.innerType?._zod?.pattern),Le(e,`propValues`,e=>e.innerType?._zod?.propValues),Le(e,`optin`,e=>e.innerType?._zod?.optin??void 0),Le(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),ei=I(`$ZodCustom`,(e,t)=>{nn.init(e,t),Cn.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ti(t,n,r,e));ti(i,n,r,e)}});function ti(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(De(e))}}var ni=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};const ri=`~memo`,ii=[];function ai(e){return typeof e==`object`&&!!e}function oi(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}const si=new WeakMap;function ci(e,t,n){let r=si.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=ci(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?ci(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=S(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?ci(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),li(e,i)}function li(e,t){return t!==1&&si.set(e,t===2),t}function ui(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let di;const fi=[],pi={alloc(e,t,n){let r=di;if(!r)return n;di=void 0;let i={value:n,issues:null};return r.set(t.value,i),fi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&hi(n,e.value))throw new ni;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=ci(e,new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!ai(l))return t(s,c);let u=c[ri];u||(u={buckets:new WeakMap,backEdges:void 0},c[ri]=u);let d;i===c?d=a:(d=ui(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...oi(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;di=d;let p=fi.length,m=t(s,c);di=void 0;let h=fi.length>p?fi.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?oi(e.issues):ii),e)):(h&&(h.issues=m.issues.length?oi(m.issues):ii),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function mi(){return pi}function hi(e,t){let n=e[ri]?.backEdges;return n!==void 0&&ai(t)&&n.has(t)}const gi=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Ee(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${ae(e.values[0])}`:`Invalid option: expected one of ${f(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${f(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function _i(){return{localeError:gi()}}var vi,yi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function bi(){return new yi}(vi=globalThis).__zod_globalRegistry??(vi.__zod_globalRegistry=bi());const xi=globalThis.__zod_globalRegistry;function Si(e){return e.checks&&=[...e.checks],e}function Ci(e,t){return new e(Si({type:`string`,...P(t)}))}function wi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...P(t)})}function Ti(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...P(t)})}function Ei(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...P(t)})}function Di(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...P(t)})}function Oi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...P(t)})}function ki(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...P(t)})}function Ai(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...P(t)})}function ji(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...P(t)})}function Mi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...P(t)})}function Ni(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...P(t)})}function Pi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...P(t)})}function Fi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...P(t)})}function Ii(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...P(t)})}function Li(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...P(t)})}function Ri(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...P(t)})}function zi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...P(t)})}function Bi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...P(t)})}function Vi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...P(t)})}function Hi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...P(t)})}function Ui(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...P(t)})}function Wi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...P(t)})}function Gi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...P(t)})}function Ki(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...P(t)})}function qi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...P(t)})}function Ji(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...P(t)})}function Yi(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...P(t)})}function Xi(e,t){return new e(Si({type:`number`,checks:[],...P(t)}))}function Zi(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...P(t)})}function Qi(e,t){return new e({type:`boolean`,...P(t)})}function $i(e,t){return new e({type:`null`,...P(t)})}function ea(e){return new e({type:`unknown`})}function ta(e,t){return new e({type:`never`,...P(t)})}function na(e,t){return new on({check:`less_than`,...P(t),value:e,inclusive:!1})}function ra(e,t){return new on({check:`less_than`,...P(t),value:e,inclusive:!0})}function ia(e,t){return new sn({check:`greater_than`,...P(t),value:e,inclusive:!1})}function aa(e,t){return new sn({check:`greater_than`,...P(t),value:e,inclusive:!0})}function oa(e,t){return new cn({check:`multiple_of`,...P(t),value:e})}function sa(e,t){return new un({check:`max_length`,...P(t),maximum:e})}function ca(e,t){return new dn({check:`min_length`,...P(t),minimum:e})}function la(e,t){return new fn({check:`length_equals`,...P(t),length:e})}function ua(e,t){return new mn({check:`string_format`,format:`regex`,...P(t),pattern:e})}function da(e){return new hn({check:`string_format`,format:`lowercase`,...P(e)})}function fa(e){return new gn({check:`string_format`,format:`uppercase`,...P(e)})}function pa(e,t){return new _n({check:`string_format`,format:`includes`,...P(t),includes:e})}function ma(e,t){return new vn({check:`string_format`,format:`starts_with`,...P(t),prefix:e})}function ha(e,t){return new yn({check:`string_format`,format:`ends_with`,...P(t),suffix:e})}function ga(e){return new bn({check:`overwrite`,tx:e})}function _a(e){return ga(t=>t.normalize(e))}function va(){return ga(e=>e.trim())}function ya(){return ga(e=>e.toLowerCase())}function ba(){return ga(e=>e.toUpperCase())}function xa(){return ga(e=>A(e))}function Sa(e,t,n){return new e({type:`array`,element:t,...P(n)})}function Ca(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...P(n)})}function wa(e,t){let n=Ta(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(De(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(De(r))}},e(t.value,t)),t);return n}function Ta(e,t){let n=new nn({check:`custom`,...P(t)});return n._zod.check=e,n}function Ea(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&x(e,t,n[t]);return e}function Da(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??xi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Oa(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function ka(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,ka(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Ea(o.schema,c),t.io===`input`&&za(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Aa(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ja(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Aa(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Aa(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
54
54
 
55
55
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ma(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Ma(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Na=new Set([`type`,`properties`,`required`,`additionalProperties`]),Pa=[`oneOf`,`anyOf`];function Fa(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ia(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Na.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Fa(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}x(n,r,e.length===1?e[0]:Ia(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Fa(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function La(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Na)if(t in e)return;let n=t.filter(e=>Pa.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ia(t);else{let e=n[0],i=Pa.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ia([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Ea(e,r))}function Ra(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Ea(i,s),Ea(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Ma(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])La(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Ea(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,x(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Va(t,`input`,e.processors),output:Va(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function za(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return za(r.element,n);if(r.type===`set`)return za(r.valueType,n);if(r.type===`lazy`)return za(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return za(r.innerType,n);if(r.type===`intersection`)return za(r.left,n)||za(r.right,n);if(r.type===`record`||r.type===`map`)return za(r.keyType,n)||za(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:za(r.in,n)||za(r.out,n);if(r.type===`object`){for(let e in r.shape)if(za(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(za(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(za(e,n))return!0;return!!(r.rest&&za(r.rest,n))}return!1}const Ba=(e,t={})=>n=>{let r=Da({...n,processors:t});return ka(e,r),ja(r,e),Ra(r,e)},Va=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Da({...i??{},target:a,io:t,processors:n});return ka(e,o),ja(o,e),Ra(o,e)},Ha=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ua=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Wa=(e,t)=>{Ha(e,`minimum`,t),Ua(e,`maximum`,t)},Ga=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ka=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},qa=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Ja=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ya=(e,t)=>Ha(e,`minimum`,t.minimum),Xa=(e,t)=>Ua(e,`maximum`,t.maximum),Za=e=>(t,n)=>{Ja(t,n.format);let[r,i]=e[n.format];Ha(t,`minimum`,r),Ua(t,`maximum`,i)},Qa={greater_than:(e,t)=>Ha(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ua(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ga(e,t.value),number_format:Za(F),bigint_format:Za(se),min_length:Ya,max_length:Xa,length_equals:(e,t)=>Wa(e,t.length),min_size:Ya,max_size:Xa,size_equals:(e,t)=>Wa(e,t.size),string_format:(e,t)=>{Ja(e,t.format),t.pattern&&Ka(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>qa(e,t.mime)};function $a(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Qa[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Ha(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Ha(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ua(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ua(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ga(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&qa(t,i.mime);for(let e of i.patterns??[])Ka(t,e);return t}const eo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},to=new Map([[ar,zt],[sr,Bt]]),no=e=>to.get(e)??e,ro=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=$a(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=eo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(no);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},io=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=$a(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Oa(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},ao=(e,t,n,r)=>{n.type=`boolean`},oo=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},so=(e,t,n,r)=>{n.not={}},co=(e,t,n,r)=>{let i=e._zod.def,a=d(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},lo=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Oa(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Oa(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},uo=(e,t,n,r)=>{Oa(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},fo=(e,t,n,r)=>{Oa(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},po=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=$a(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=ka(a.element,t,{...r,path:[...r.path,`items`]})};function mo(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?mo(t.out):t.type===`catch`?mo(t.innerType):e._zod.optin}const ho=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Oa(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)x(i.properties,e,ka(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?mo(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ka(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},go=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ka(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},_o=(e,t,n,r)=>{let i=e._zod.def,a=ka(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ka(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function vo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=vo(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>vo(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Zt:Xt).source),p):p}const yo=new WeakMap;function bo(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of yo.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=vo(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const xo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=$a(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=ka(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)x(i.patternProperties,no(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=ka(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=yo.get(t);n||(n=[],yo.set(t,n),t.deferred.push(()=>bo(t))),n.push(e)}i.additionalProperties=ka(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&mo(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},So=(e,t,n,r)=>{let i=e._zod.def,a=ka(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Co=(e,t,n,r)=>{let i=e._zod.def;ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wo=Symbol();function To(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Oa(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),wo):JSON.parse(o)}const Eo=(e,t,n,r)=>{let i=e._zod.def;ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=To(i.defaultValue,e,t,n,r);o!==wo&&(n.default=o)},Do=(e,t,n,r)=>{let i=e._zod.def;ka(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=To(i.defaultValue,e,t,n,r);o!==wo&&(n._prefault=o)},Oo=(e,t,n,r)=>{let i=e._zod.def;ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Oa(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},ko=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;ka(o,t,r);let s=t.seen.get(e);s.ref=o},Ao=(e,t,n,r)=>{let i=e._zod.def;ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},jo=(e,t,n,r)=>{let i=e._zod.def;ka(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mo=(e,t,n,r)=>{let i=e._zod.innerType;ka(i,t,r);let a=t.seen.get(e);a.ref=i},No=new WeakSet([Object.prototype,Error.prototype]);function Po(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const Fo=I(`ZodError`,(e,t)=>{et.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);No.has(n)||(No.add(n),Po(n,`format`,e=>t=>rt(e,t)),Po(n,`flatten`,e=>t=>nt(e,t)),Po(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,p,2)}),Po(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,p,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Io=at(Fo),Lo=ot(Fo),Ro=st(Fo),zo=lt(Fo),Bo=ht(Fo),Vo=gt(Fo),Ho=_t(Fo),Uo=vt(Fo),Wo=yt(Fo),Go=bt(Fo),Ko=xt(Fo),qo=St(Fo);function Jo(){Ke.localeError||qe(_i())}function Yo(){Ke.memoizer||qe({memoizer:mi()})}const Xo=I(`ZodType`,(e,t)=>(Jo(),Cn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(O(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ie(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(_c(e,t))},superRefine(e,t){return this.check(vc(e,t))},overwrite(e){return this.check(ga(e))},optional(){return Zs(this)},exactOptional(){return $s(this)},nullable(){return tc(this)},nullish(){return Zs(tc(this))},nonoptional(e){return sc(this,e)},array(){return Is(this)},or(e){return zs([this,e])},and(e){return Us(this,e)},transform(e){return dc(this,Ys(e))},default(e){return rc(this,e)},prefault(e){return ac(this,e)},catch(e){return lc(this,e)},pipe(e){return dc(this,e)},readonly(){return pc(this)},describe(e){let t=this.clone();return xi.add(t,{description:e}),t},meta(...e){if(e.length===0)return xi.get(this);let t=this.clone();return xi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Ae(this,`~standard`,{...En(this),jsonSchema:{input:Va(this,`input`),output:Va(this,`output`)}})},set"~standard"(e){ke(this,`~standard`,e)},parse:function e(t,n){return Io(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Lo(this,t,n,{callee:e})},safeParse(e,t){return Ro(this,e,t)},async safeParseAsync(e,t){return zo(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ke(this,`spa`,e)},validate(e,t){return ft(this,e,t)},validateAsync(e,t){return mt(this,e,t)},encode:function e(t,n){return Bo(this,t,n,{callee:e})},decode:function e(t,n){return Vo(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ho(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Uo(this,t,n,{callee:e})},safeEncode(e,t){return Wo(this,e,t)},safeDecode(e,t){return Go(this,e,t)},async safeEncodeAsync(e,t){return Ko(this,e,t)},async safeDecodeAsync(e,t){return qo(this,e,t)},toJSONSchema(e){return Ba(this,{})(e)},get description(){return xi.get(this)?.description},get _def(){return this._zod.def}}),Zo=I(`_ZodString`,(e,t)=>{Dn.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r)},je({format:e=>$a(e).format??null,minLength:e=>$a(e).minimum??null,maxLength:e=>$a(e).maximum??null},{regex(...e){return this.check(ua(...e))},includes(...e){return this.check(pa(...e))},startsWith(...e){return this.check(ma(...e))},endsWith(...e){return this.check(ha(...e))},min(...e){return this.check(ca(...e))},max(...e){return this.check(sa(...e))},length(...e){return this.check(la(...e))},nonempty(...e){return this.check(ca(1,...e))},lowercase(e){return this.check(da(e))},uppercase(e){return this.check(fa(e))},trim(){return this.check(va())},normalize(...e){return this.check(_a(...e))},toLowerCase(){return this.check(ya())},toUpperCase(){return this.check(ba())},slugify(){return this.check(xa())}})),Qo=I(`ZodString`,(e,t)=>{Dn.init(e,t),Zo.init(e,t)},{email(e){return this.check(wi(is,e))},url(e){return this.check(Ai(ss,e))},jwt(e){return this.check(Gi(Ss,e))},emoji(e){return this.check(ji(cs,e))},guid(e){return this.check(Ti(as,e))},uuid(e){return this.check(Ei(os,e))},uuidv4(e){return this.check(Di(os,e))},uuidv6(e){return this.check(Oi(os,e))},uuidv7(e){return this.check(ki(os,e))},nanoid(e){return this.check(Mi(ls,e))},cuid(e){return this.check(Ni(us,e))},cuid2(e){return this.check(Pi(ds,e))},ulid(e){return this.check(Fi(fs,e))},base64(e){return this.check(Hi(ys,e))},base64url(e){return this.check(Ui(bs,e))},xid(e){return this.check(Ii(ps,e))},ksuid(e){return this.check(Li(ms,e))},ipv4(e){return this.check(Ri(hs,e))},ipv6(e){return this.check(zi(gs,e))},cidrv4(e){return this.check(Bi(_s,e))},cidrv6(e){return this.check(Vi(vs,e))},e164(e){return this.check(Wi(xs,e))},datetime(e){return this.check(Ki(es,e))},date(e){return this.check(qi(ts,e))},time(e){return this.check(Ji(ns,e))},duration(e){return this.check(Yi(rs,e))}});function L(e){return Ci(Qo,e)}const $o=I(`ZodStringFormat`,(e,t)=>{On.init(e,t),Zo.init(e,t)}),es=I(`ZodISODateTime`,(e,t)=>{qn.init(e,t),$o.init(e,t)}),ts=I(`ZodISODate`,(e,t)=>{Jn.init(e,t),$o.init(e,t)}),ns=I(`ZodISOTime`,(e,t)=>{Yn.init(e,t),$o.init(e,t)}),rs=I(`ZodISODuration`,(e,t)=>{Xn.init(e,t),$o.init(e,t)}),is=I(`ZodEmail`,(e,t)=>{jn.init(e,t),$o.init(e,t)}),as=I(`ZodGUID`,(e,t)=>{kn.init(e,t),$o.init(e,t)}),os=I(`ZodUUID`,(e,t)=>{An.init(e,t),$o.init(e,t)}),ss=I(`ZodURL`,(e,t)=>{zn.init(e,t),$o.init(e,t)}),cs=I(`ZodEmoji`,(e,t)=>{Bn.init(e,t),$o.init(e,t)}),ls=I(`ZodNanoID`,(e,t)=>{Vn.init(e,t),$o.init(e,t)}),us=I(`ZodCUID`,(e,t)=>{Hn.init(e,t),$o.init(e,t)}),ds=I(`ZodCUID2`,(e,t)=>{Un.init(e,t),$o.init(e,t)}),fs=I(`ZodULID`,(e,t)=>{Wn.init(e,t),$o.init(e,t)}),ps=I(`ZodXID`,(e,t)=>{Gn.init(e,t),$o.init(e,t)}),ms=I(`ZodKSUID`,(e,t)=>{Kn.init(e,t),$o.init(e,t)}),hs=I(`ZodIPv4`,(e,t)=>{Zn.init(e,t),$o.init(e,t)}),gs=I(`ZodIPv6`,(e,t)=>{er.init(e,t),$o.init(e,t)}),_s=I(`ZodCIDRv4`,(e,t)=>{tr.init(e,t),$o.init(e,t)}),vs=I(`ZodCIDRv6`,(e,t)=>{rr.init(e,t),$o.init(e,t)}),ys=I(`ZodBase64`,(e,t)=>{or.init(e,t),$o.init(e,t)}),bs=I(`ZodBase64URL`,(e,t)=>{lr.init(e,t),$o.init(e,t)}),xs=I(`ZodE164`,(e,t)=>{ur.init(e,t),$o.init(e,t)}),Ss=I(`ZodJWT`,(e,t)=>{fr.init(e,t),$o.init(e,t)}),Cs=I(`ZodNumber`,(e,t)=>{pr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r),e.isFinite=!0},je({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=$a(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=$a(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=$a(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>$a(e).format??null},{gt(e,t){return this.check(ia(e,t))},gte(e,t){return this.check(aa(e,t))},min(e,t){return this.check(aa(e,t))},lt(e,t){return this.check(na(e,t))},lte(e,t){return this.check(ra(e,t))},max(e,t){return this.check(ra(e,t))},int(e){return this.check(Es(e))},safe(e){return this.check(Es(e))},positive(e){return this.check(ia(0,e))},nonnegative(e){return this.check(aa(0,e))},negative(e){return this.check(na(0,e))},nonpositive(e){return this.check(ra(0,e))},multipleOf(e,t){return this.check(oa(e,t))},step(e,t){return this.check(oa(e,t))},finite(){return this}}));function ws(e){return Xi(Cs,e)}const Ts=I(`ZodNumberFormat`,(e,t)=>{mr.init(e,t),Cs.init(e,t)});function Es(e){return Zi(Ts,e)}const Ds=I(`ZodBoolean`,(e,t)=>{hr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,n,r)});function Os(e){return Qi(Ds,e)}const ks=I(`ZodNull`,(e,t)=>{gr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r)});function As(e){return $i(ks,e)}const js=I(`ZodUnknown`,(e,t)=>{_r.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ms(){return ea(js)}const Ns=I(`ZodNever`,(e,t)=>{vr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r)});function Ps(e){return ta(Ns,e)}const Fs=I(`ZodArray`,(e,t)=>{Yo(),br.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r),e.element=t.element},{min(e,t){return this.check(ca(e,t))},nonempty(e){return this.check(ca(1,e))},max(e,t){return this.check(sa(e,t))},length(e,t){return this.check(la(e,t))},unwrap(){return this.element}});function Is(e,t){return Sa(Fs,e,t)}const Ls=I(`ZodObject`,(e,t)=>{Yo(),Er.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),Re(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(O(this._zod.def,{catchall:e}))},passthrough(){return this.clone(O(this._zod.def,{catchall:Ms()}))},loose(){return this.clone(O(this._zod.def,{catchall:Ms()}))},strict(){return this.clone(O(this._zod.def,{catchall:Ps()}))},strip(){return this.clone(O(this._zod.def,{catchall:void 0}))},extend(e){return de(this,e)},safeExtend(e){return pe(this,e)},merge(e){return me(this,e)},pick(e){return ce(this,e)},omit(e){return ue(this,e)},partial(...e){return he(Xs,this,e[0])},exactPartial(...e){return he(Qs,this,e[0],`exactPartial`)},required(...e){return ge(oc,this,e[0])}});function R(e,t){let n={type:`object`,shape:e??{},...P(t)};return new Ls(n)}const Rs=I(`ZodUnion`,(e,t)=>{Or.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),e.options=t.options});function zs(e,t){return new Rs({type:`union`,options:e,...P(t)})}const Bs=I(`ZodDiscriminatedUnion`,(e,t)=>{Rs.init(e,t),Ar.init(e,t)});function Vs(e,t,n){return new Bs({type:`union`,options:t,discriminator:e,...P(n)})}const Hs=I(`ZodIntersection`,(e,t)=>{jr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r)});function Us(e,t){return new Hs({type:`intersection`,left:e,right:t})}const Ws=I(`ZodRecord`,(e,t)=>{Yo(),Pr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Gs(e,t,n){return!t||!t._zod?new Ws({type:`record`,keyType:L(),valueType:e,...P(t)}):new Ws({type:`record`,keyType:e,valueType:t,...P(n)})}const Ks=I(`ZodEnum`,(e,t)=>{Fr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ks({...t,checks:[],...P(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ks({...t,checks:[],...P(r),entries:i})}});function z(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ks({type:`enum`,entries:n,...P(t)})}const qs=I(`ZodLiteral`,(e,t)=>{Ir.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function B(e,t){return new qs({type:`literal`,values:Array.isArray(e)?e:[e],...P(t)})}const Js=I(`ZodTransform`,(e,t)=>{Yo(),Lr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ge(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(De(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(De(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Ys(e){return new Js({type:`transform`,transform:e})}const Xs=I(`ZodOptional`,(e,t)=>{zr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e){return new Xs({type:`optional`,innerType:e})}const Qs=I(`ZodExactOptional`,(e,t)=>{Br.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $s(e){return new Qs({type:`optional`,innerType:e})}const ec=I(`ZodNullable`,(e,t)=>{Vr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tc(e){return new ec({type:`nullable`,innerType:e})}const nc=I(`ZodDefault`,(e,t)=>{Hr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function rc(e,t){return new nc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():N(t)}})}const ic=I(`ZodPrefault`,(e,t)=>{Wr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ac(e,t){return new ic({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():N(t)}})}const oc=I(`ZodNonOptional`,(e,t)=>{Gr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sc(e,t){return new oc({type:`nonoptional`,innerType:e,...P(t)})}const cc=I(`ZodCatch`,(e,t)=>{Jr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lc(e,t){return new cc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:ze(t)})}const uc=I(`ZodPipe`,(e,t)=>{Yr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.in=t.in,e.out=t.out});function dc(e,t){return new uc({type:`pipe`,in:e,out:t})}const fc=I(`ZodReadonly`,(e,t)=>{Zr.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new fc({type:`readonly`,innerType:e})}const mc=I(`ZodLazy`,(e,t)=>{$r.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mo(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function hc(e){return new mc({type:`lazy`,getter:e})}const gc=I(`ZodCustom`,(e,t)=>{ei.init(e,t),Xo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r)});function _c(e,t={}){return Ca(gc,e,t)}function vc(e,t){return wa(e,t)}function yc(e){let t=hc(()=>zs([L(e),ws(),Os(),As(),Is(t),Gs(L(),t)]));return t}const bc=2.5,xc={width:1600,height:900},Sc={width:240,height:160},Cc={frame:{width:480,height:320},shape:{width:200,height:140},image:{width:480,height:270},video:{width:480,height:270},audio:{width:320,height:112},file:{width:260,height:132},task:{width:480,height:270},session:{width:320,height:176},effect:{width:240,height:240},custom:{width:480,height:320}};function wc(e){return{...Object.hasOwn(Cc,e)?Cc[e]:Sc}}const Tc=`"Geist Variable", "Geist", "Noto Sans CJK SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Noto Sans Math", "Noto Sans Symbols 2", "DejaVu Sans", "FreeSans", "FreeSerif", sans-serif`,Ec=`"Geist Mono Variable", "Geist Mono", "Fira Code", ui-monospace, "Noto Sans Mono CJK SC", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Noto Sans Math", "DejaVu Sans", "FreeSans", "FreeSerif", monospace`;function Dc(e){let t=e.split(`.`).map(Number);return t.length===4&&t.every(e=>Number.isInteger(e)&&e>=0&&e<=255)?t:null}function Oc(e){let t=Dc(e);if(!t)return!1;let[n,r,i]=t;return n===0||n===10||n===127||n===100&&r>=64&&r<=127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===192&&r===0&&(i===0||i===2)||n===192&&r===88&&i===99||n===198&&(r===18||r===19)||n===198&&r===51&&i===100||n===203&&r===0&&i===113||n>=224}function kc(e){let[t,n,r]=e.toLowerCase().split(`::`);if(r!==void 0)return null;let i=t?t.split(`:`).filter(Boolean):[],a=n?n.split(`:`).filter(Boolean):[],o=8-i.length-a.length;if(o<0||n===void 0&&o!==0)return null;let s=[...i,...Array.from({length:o},()=>`0`),...a];return s.length!==8||s.some(e=>!/^[0-9a-f]{1,4}$/.test(e))?null:s.map(e=>e.padStart(4,`0`))}function Ac(e){let t=kc(e);if(!t||t.every(e=>e===`0000`)||t.slice(0,7).every(e=>e===`0000`)&&t[7]===`0001`)return!0;if(t.slice(0,5).every(e=>e===`0000`)&&t[5]===`ffff`){let e=Number.parseInt(t[6]??`0`,16),n=Number.parseInt(t[7]??`0`,16);return Oc(`${e>>8}.${e&255}.${n>>8}.${n&255}`)}if(t.slice(0,6).every(e=>e===`0000`))return!0;let n=Number.parseInt(t[0]??`0`,16);return(n&65024)==64512||(n&65472)==65152||(n&65472)==65216||(n&65280)==65280||t[0]===`2001`&&t[1]===`0db8`}function jc(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``).replace(/\.$/,``);return Dc(t)?!Oc(t):t.includes(`:`)&&!Ac(t)}function Mc(e){let t=e.toLowerCase().replace(/^\[|\]$/g,``).replace(/\.$/,``);return t===`localhost`||t.endsWith(`.localhost`)||t.endsWith(`.local`)||t.endsWith(`.internal`)?!0:Dc(t)||t.includes(`:`)?!jc(t):!1}function Nc(e){if(typeof e!=`string`)return;let t=e.trim();if(!(!t||t.length>4096))try{let e=new URL(t);if(e.protocol!==`https:`&&e.protocol!==`http:`||e.username||e.password||Mc(e.hostname))return;let n=e.toString();return n.length<=4096?n:void 0}catch{return}}L().max(4096).refine(e=>Nc(e)!==void 0,{message:`URL must be a public HTTP(S) URL without credentials`});const Pc=`camera`,Fc=L().min(1).max(160).regex(/^[^\s/]+$/,`ids must not contain whitespace or '/'`),Ic=Fc.refine(e=>e!==Pc,`"camera" is reserved`),Lc=ws().finite(),Rc=Lc.nonnegative(),zc=Lc.min(0).max(1),Bc=R({x:Lc,y:Lc}).strict(),Vc=R({width:Lc.positive(),height:Lc.positive()}).strict(),Hc=[`brand`,`neutral`,`black`,`white`,`blue`,`green`,`amber`,`violet`,`rose`],Uc=new Set(`transparent aliceblue antiquewhite aqua aquamarine azure beige bisque blanchedalmond blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray grey greenyellow honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat whitesmoke yellow yellowgreen`.split(` `));function Wc(e){let t=e.trim().toLowerCase();return Hc.includes(t)||Uc.has(t)||/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)||/^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)$/.test(t)}const Gc=L().max(120).refine(Wc,`expected a palette token or a CSS color`),Kc=zs([Gc,R({light:Gc,dark:Gc}).strict()]).describe(`Palette token (follows the theme), CSS color, or { light, dark }.`),qc=[`solid`,`dashed`,`dotted`],Jc=[`normal`,`multiply`,`screen`,`add`],Yc=R({blur:Lc.min(0).max(256).optional().describe(`Blur radius in board units, as CSS blur().`),brightness:Lc.min(0).max(10).optional().describe(`1 keeps the color, 0 is black.`),contrast:Lc.min(0).max(10).optional().describe(`1 keeps the color, 0 is flat gray.`),saturate:Lc.min(0).max(10).optional().describe(`1 keeps the color, 0 is gray, above 1 is vivid.`),hue:Lc.min(-3600).max(3600).optional().describe(`Hue rotation in degrees.`),grayscale:zc.optional(),sepia:zc.optional(),invert:zc.optional()}).strict().describe(`CSS filters, applied in this order. On a frame, filter, shadow and blend treat the frame and its contents as one layer.`),Xc={opacity:.35,blur:16,x:0,y:8},Zc=R({color:Kc.optional().describe(`Defaults to black.`),opacity:zc.optional().describe(`Defaults to 0.35.`),blur:Lc.min(0).max(256).optional().describe(`Softness in board units, as CSS drop-shadow(); defaults to 16.`),x:Lc.min(-1024).max(1024).optional(),y:Lc.min(-1024).max(1024).optional().describe(`Defaults to 8.`)}).strict().describe(`A drop shadow following the item's visible shape; with no offset and a bright color it glows.`),Qc=R({fill:Kc.optional(),fillOpacity:zc.optional().describe(`Fill opacity, independent of the item's opacity.`),stroke:Kc.optional(),strokeWidth:Lc.min(0).max(64).optional(),dash:z(qc).optional(),radius:Rc.optional().describe(`Corner radius in board units.`),trim:zc.optional().describe(`Fraction of the outline drawn; animate 0 → 1 to draw it in.`),filter:Yc.optional(),shadow:Zc.optional(),blend:z(Jc).optional().describe(`How the item mixes with what is under it.`)}).strict();function $c(e){return e.length>0&&e.length<=4096&&!e.startsWith(`/`)&&!/^[a-z][a-z\d+.-]*:/i.test(e.trimStart())&&!e.includes(`\\`)&&e.split(`/`).every(e=>e.length>0&&e!==`.`&&e!==`..`)}const el=L().refine($c,`src must be a relative Space file path`);function tl(e){return $c(e)?{kind:`file`,value:e}:Nc(e)?{kind:`url`,value:e}:null}const nl=L().max(4096).refine(e=>tl(e)!==null,`src must be a public HTTP(S) URL or relative Space file path`).describe(`Prefer a public HTTP(S) URL; a Space path relative to the workspace root also works.`),rl=R({src:el.refine(e=>/\.m?js$/.test(e),`script src must be a .js or .mjs module`).describe(`A .js or .mjs Space file.`),params:Gs(L(),yc()).default({}).describe(`Values the module reads as params.`),targets:Gs(L().min(1).max(80),Ic).default({}).describe(`Named items the module can reach, as ctx.targets.`),seed:L().min(1).max(160).optional().describe(`Seed for ctx.random() and shaders; defaults to the owner's id.`),enabled:Os().default(!0)}).strict().describe("A JavaScript module attached to an item or the Board; `cohub boards schema script` lists its API."),il={script:rl.optional(),parent:Ic.optional().describe(`A frame id; position becomes relative to the frame, and the item moves with it.`),z:Lc.optional().describe(`Order among siblings; new items go on top.`),position:Bc.default({x:0,y:0}),rotation:Lc.default(0),scale:zs([Lc,Bc]).default(1),origin:Bc.default({x:.5,y:.5}).describe(`Rotation and scale origin as fractions of the size.`),opacity:zc.default(1),visible:Os().optional().describe(`false hides the item and its children; key it on a timeline to show the item only for a span.`),style:Qc.default({}),locked:Os().optional(),autoplay:Os().optional().describe(`true shows live content as the Board opens: an app runs, a video loops muted, a 3D model renders. Ignored for other items and for a video whose props.time follows a timeline.`),metadata:Gs(L(),Ms()).optional()},al=e=>({...il,size:Vc.default({...e})}),ol={...il},sl=Lc.min(2).max(512),cl=[`left`,`center`,`right`],ll=[`char`,`word`,`line`],ul=[`cut`,`fade`,`rise`],dl=[`rectangle`,`rounded`,`ellipse`,`diamond`,`triangle`,`path`],fl=R({...al(Cc.frame),type:B(`frame`),props:R({label:L().max(280).default(``),decoration:z([`frame`,`none`]).optional().describe(`none hides the title, border and background: an invisible group whose tracks move every child; with a label it is also a page viewers step to.`),clip:Os().default(!0).describe(`Hide children outside the frame.`)}).strict().prefault({})}).strict(),pl=R({...ol,type:B(`text`),props:R({text:L().default(``),fontSize:sl.default(24),fontWeight:Lc.min(100).max(900).default(500),font:L().min(1).max(120).default(`sans`).describe(`sans, serif, mono, or a font family name.`),align:z(cl).default(`left`),lineHeight:Lc.min(.5).max(4).default(4/3),width:Lc.positive().optional().describe(`Wrap width; the height follows the text.`),reveal:zc.default(1).describe(`Fraction of the text shown; animate 0 → 1 to type it.`),revealBy:z(ll).optional().describe(`What reveal counts: char (default), word or line.`),revealMotion:z(ul).optional().describe(`How each unit appears: cut (default), fade or rise.`),caret:Os().default(!1).describe(`Blink a caret while the text is being revealed.`)}).strict().prefault({})}).strict(),ml=R({...al(Cc.shape),type:B(`shape`),props:R({geometry:z(dl).default(`rectangle`),path:L().min(1).max(2e5).optional().describe(`SVG path data for path geometry, fitted to the item size.`),text:L().default(``),fontSize:sl.default(20),align:z(cl).default(`center`)}).strict().refine(e=>e.geometry!==`path`||!!e.path,{message:`path geometry requires props.path`,path:[`path`]}).prefault({})}).strict(),hl=R({x:Lc,y:Lc,p:zc.default(.5).describe(`Pen pressure.`)}).strict(),gl=R({...ol,type:B(`draw`),props:R({points:Is(hl).min(1).max(1e5).describe(`Stroke points relative to position; the size follows them.`)}).strict()}).strict(),_l=zs([Bc,R({item:Ic,anchor:zs([B(`auto`),R({side:z([`top`,`right`,`bottom`,`left`]),offset:zc.default(.5)}).strict(),R({x:zc,y:zc}).strict()]).default(`auto`).describe(`auto uses the side facing the other end; or a side with an offset, or a point as fractions of the item.`),port:L().min(1).max(120).optional()}).strict()]).describe(`A point relative to position, or { item } to follow that item.`),vl=[`straight`,`curve`,`orthogonal`],yl=R({...ol,type:B(`arrow`),props:R({start:_l,end:_l,route:z(vl).default(`straight`),bend:Lc.min(-.85).max(.85).default(0).describe(`Sideways curve as a fraction of the length; the sign picks the side.`),waypoints:Is(Bc).max(64).default([]).describe(`Points the route passes through.`),arrowStart:Os().default(!1),arrowEnd:Os().default(!0),label:L().max(280).default(``),fontSize:sl.default(14),relation:L().max(64).regex(/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/,`relation must be a lowercase slug`).optional().describe(`What the arrow means, as a slug such as triggers or depends-on.`)}).strict()}).strict(),bl={src:nl,snapshot:R({title:L().optional(),mimeType:L().optional(),size:Rc.optional(),mtimeMs:Rc.optional(),naturalWidth:Lc.positive().optional(),naturalHeight:Lc.positive().optional(),durationMs:Rc.optional(),excerpt:L().optional(),coverPath:L().optional(),coverUrl:L().optional()}).strict().describe(`Cached facts for an instant preview; filled in when the media loads.`).optional()},xl=R({taskRunId:L().min(1).max(160),artifactId:L().min(1).max(240)}).strict().describe(`The generation run and result this media came from.`),Sl={...bl,origin:xl.optional()},Cl={...Sl,time:Rc.optional().describe(`Playback position in milliseconds; animate props.time to play it on a timeline. It sounds while its time moves forward.`),volume:zc.optional().describe(`Loudness from 0 to 1; defaults to 1. Animate it to fade.`)},wl=R({x:zc,y:zc,w:zc,h:zc}).strict().describe(`Region shown, as fractions of the image. Without it the whole image fits inside size.`),Tl=R({...al(Cc.image),type:B(`image`),props:R({...Sl,crop:wl.optional()}).strict()}).strict(),El=R({...al(Cc.video),type:B(`video`),props:R(Cl).strict()}).strict(),Dl=R({...al(Cc.audio),type:B(`audio`),props:R(Cl).strict()}).strict(),Ol=R({...al(Cc.file),type:B(`file`),props:R(bl).strict()}).strict(),kl=L().max(4096).url(),Al={id:L().min(1).max(240),title:L().max(240).optional(),url:kl,mimeType:L().max(160).optional()},jl=Vs(`type`,[R({...Al,type:B(`image`),naturalWidth:Lc.positive().optional(),naturalHeight:Lc.positive().optional()}).strict(),R({...Al,type:B(`video`),previewUrl:kl.optional(),durationMs:ws().int().positive().optional(),naturalWidth:Lc.positive().optional(),naturalHeight:Lc.positive().optional()}).strict(),R({...Al,type:B(`audio`),previewUrl:kl.optional(),durationMs:ws().int().positive().optional()}).strict(),R({id:L().min(1).max(240),type:B(`text`),title:L().max(240).optional(),textExcerpt:L().min(1).max(480)}).strict()]),Ml=R({taskType:L().min(1).max(120),status:z([`pending`,`running`,`completed`,`failed`]),title:L().min(1).max(240),model:L().max(160).optional(),promptExcerpt:L().max(480).optional(),errorExcerpt:L().max(240).optional(),artifactCount:ws().int().nonnegative(),artifacts:Is(jl).max(6).default([]),startedAt:L().max(64).optional(),updatedAt:L().optional()}).strict(),Nl=R({...al(Cc.task),type:B(`task`),props:R({taskRunId:L().min(1).max(160).describe(`The generation run shown; the server keeps the card's status and results up to date.`),snapshot:Ml.describe(`Maintained by the server; omit it.`)}).strict()}).strict(),Pl=R({title:L().max(255).default(``),excerpt:L().max(480).optional().describe(`The latest message as plain text.`),source:L().max(120).optional().describe(`Where the chat runs: web, cli or a channel.`),issue:z([`failed`,`lost`]).optional().describe(`How the last run ended when it did not finish.`),errorExcerpt:L().max(240).optional(),activityAt:L().max(64).optional()}).strict(),Fl=R({...al(Cc.session),type:B(`session`),props:R({sessionId:L().min(1).max(160).describe(`The chat shown; the server keeps its title, latest message and status up to date.`),snapshot:Pl.describe(`Maintained by the server; omit it.`)}).strict()}).strict(),Il=[`particles`,`trail`,`impact`,`flash`,`glow`],Ll=[`circle`,`square`,`star`,`heart`,`spark`],Rl=R({...al(Cc.effect),type:B(`effect`),props:R({kind:z(Il),rate:Rc.max(2e4).default(40),life:Lc.positive().max(6e4).default(1200),particleSize:Lc.positive().max(512).default(6),speed:Rc.max(1e4).default(120),direction:Lc.default(-90),spread:Lc.min(0).max(360).default(360),gravity:Lc.default(0),intensity:Rc.max(10).default(1),follow:Ic.optional().describe(`trail: the item to follow.`),seed:L().min(1).max(160).optional().describe(`Makes procedural motion repeatable.`),shape:z(Ll).optional().describe(`particles and impact: circle by default; square and star tumble, spark streaks along its motion.`),colors:Is(Kc).min(1).max(8).optional().describe(`particles and impact: each particle picks one; defaults to style.fill.`)}).strict()}).strict(),zl=R({...al(Cc.custom),type:B(`custom`),script:rl,props:R({}).strict().default({})}).strict(),Bl=/^[a-z][a-z0-9]*(?:\.[a-z0-9-]+)+$/,Vl=R({title:L().max(500).optional(),excerpt:L().max(2e3).optional(),cover:nl.optional().describe(`An image for the card.`),src:nl.optional().describe(`The file or page the card stands for.`)}).strict().describe(`How a client without this type's renderer shows the card, and what it refers to. The type's own client keeps it current.`),Hl=R({...al(Sc),type:L().regex(Bl),props:Gs(L(),Ms()).default({}),preview:Vl.optional()}).strict(),Ul={frame:fl,text:pl,shape:ml,draw:gl,arrow:yl,image:Tl,video:El,audio:Dl,file:Ol,task:Nl,session:Fl,effect:Rl,custom:zl},Wl=Object.keys(Ul);function Gl(e){return Object.hasOwn(Ul,e)}function Kl(e){return Gl(e.type)}function ql(e){return Kl(e)?null:e.preview??null}function Jl(e){return Gl(e)?Ul[e]:Bl.test(e)?Hl:null}function Yl(e,t){return e.issues.map(e=>({severity:`error`,code:`INVALID_ITEM`,path:[t,...e.path.map(String)].filter(Boolean).join(`.`),message:e.code===`unrecognized_keys`?`unknown ${e.keys.length===1?`property`:`properties`} ${e.keys.join(`, `)}`:e.message}))}const Xl=()=>!0;function Zl(e){return(t,n)=>Object.hasOwn(Ql(e,t)??{},n)}function Ql(e,t){let n=e;for(let e of t)n=n&&typeof n==`object`?n[e]:void 0;return n&&typeof n==`object`?n:null}function $l(e,t,n){if(!e||typeof e!=`object`)return e;let r=Array.isArray(e)?[...e]:{...e};if(t.length===0)for(let e of n)delete r[e];else r[t[0]]=$l(r[t[0]],t.slice(1),n);return r}function eu(e,t,n){let r=[],i=t;for(;;){let t=e.safeParse(i);if(t.success){for(let e of r){let n=Ql(t.data,e.path);n&&(n[e.key]=e.value)}return t}if(!n)return t;let a=!1;for(let e of t.error.issues){if(e.code!==`unrecognized_keys`)continue;let t=e.keys.filter(t=>t!==`__proto__`&&n(e.path,t));if(!t.length)continue;let o=Ql(i,e.path);for(let n of t)r.push({path:e.path,key:n,value:o?.[n]});i=$l(i,e.path,t),a=!0}if(!a)return t}}function tu(e,t=`item`,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e.type:void 0;if(typeof r!=`string`)return{ok:!1,diagnostics:[{severity:`error`,code:`INVALID_ITEM`,path:`${t}.type`,message:`type is required`}]};let i=Jl(r);if(!i)return{ok:!1,diagnostics:[{severity:`error`,code:`INVALID_ITEM`,path:`${t}.type`,message:`unknown type ${r}; expected ${Wl.join(`, `)} or a namespaced extension type`}]};let a=eu(i,e,n);return a.success?{ok:!0,item:a.data}:{ok:!1,diagnostics:Yl(a.error,t)}}const nu=new Set([`linear`,`ease`,`ease-in`,`ease-out`,`ease-in-out`,`step-start`,`step-end`]);function ru(e){let t=e.trim();if(nu.has(t))return!0;let n=/^cubic-bezier\(\s*([^,()]+),\s*([^,()]+),\s*([^,()]+),\s*([^,()]+)\)$/.exec(t);if(n){let[e,,t]=n.slice(1).map(Number);return n.slice(1).every(e=>Number.isFinite(Number(e)))&&e>=0&&e<=1&&t>=0&&t<=1}return/^steps\(\s*[1-9]\d*\s*(?:,\s*(?:start|end|jump-start|jump-end|jump-none|jump-both)\s*)?\)$/.test(t)}const iu=L().max(120).refine(ru,`expected a CSS easing: linear, ease-in-out, cubic-bezier(…) or steps(…)`),au=R({at:Rc.describe(`Time in milliseconds.`),value:Ms(),ease:iu.optional().describe(`Easing into this keyframe: a CSS keyword, cubic-bezier() or steps(); defaults to linear.`)}).strict(),ou=R({target:L().min(1).max(160).describe(`An item id, camera, a Board script id, or another animation id (its time property nests that timeline).`),property:L().min(1).max(200).describe(`JSON path in the target, e.g. position, opacity, style.fill, props.text; params.<name> for a Board script.`),keyframes:Is(au).min(1).max(1e5).describe(`Ordered by at. The value holds before the first and after the last keyframe.`),composite:z([`replace`,`add`]).default(`replace`).describe(`replace: the latest-started track wins. add: positions and rotations add; scale and opacity multiply.`),interpolation:z([`auto`,`step`,`spline`]).default(`auto`).describe(`auto blends numbers, vectors and colors and steps other values; spline smooths position paths.`),orient:Os().optional().describe(`Rotate the item along its path.`)}).strict().superRefine((e,t)=>{for(let n=1;n<e.keyframes.length;n+=1)(e.keyframes[n]?.at??0)<(e.keyframes[n-1]?.at??0)&&t.addIssue({code:`custom`,message:`keyframes must be ordered by at`,path:[`keyframes`,n,`at`]})}),su=R({at:Rc,label:L().max(280).optional(),pause:Os().optional().describe(`Hold shared playback here until next.`)}).strict(),cu=R({name:L().max(280).optional(),duration:Lc.positive().max(864e5).describe(`Milliseconds; a new animation without it ends at its last keyframe.`),play:z([`manual`,`auto`,`always`]).default(`manual`).describe(`manual: only shared playback starts it. auto: plays when the Board opens. always: loops continuously.`),delay:Rc.default(0),loop:Os().default(!1),end:z([`hold`,`reset`]).default(`hold`).describe(`hold keeps the last frame; reset returns to the start.`),markers:Is(su).max(1e4).default([]).describe(`Labeled points on this timeline; a nested animation's markers do not carry over.`),viewport:R({width:ws().int().positive().max(8192),height:ws().int().positive().max(8192)}).strict().optional().describe(`Screen pixels the camera tracks are framed for, ${xc.width}x${xc.height} by default. Every screen and export shows that framing, scaled to fit.`)}).strict();cu.extend({tracks:Gs(Fc,ou).default({})}).strict();const lu=[`fade-in`,`rise`,`drop`,`pop`,`deal`],uu=R({color:Kc.optional(),pattern:z([`none`,`dots`,`grid`]).optional().describe(`Spaced by grid.size; omit to follow the theme.`),image:R({src:nl,fit:z([`cover`,`contain`,`repeat`]).default(`cover`).describe(`cover and contain fill the view; repeat tiles the Board at one board unit per image pixel.`),opacity:zc.optional()}).strict().optional()}).strict().describe(`Layers drawn under every item: color, then image, then pattern. Without a color or image the theme's backdrop shows.`),du=R({vignette:zc.optional().describe(`Darkens the edges of the view.`),grain:zc.optional().describe(`Film grain over the view.`)}).strict().describe(`Screen effects over every item, for viewers and exports alike.`),fu=R({title:L().min(1).max(255).optional(),background:uu.default({}),grid:R({size:Lc.min(4).max(512).default(24).describe(`Pattern spacing and snap step, in board units.`),snap:Os().default(!1).describe(`Snap moved and resized items to the grid.`)}).strict().optional(),atmosphere:du.optional(),enter:R({preset:z(lu),duration:Lc.positive().max(1e4).optional()}).strict().optional().describe(`Motion for items as they are added.`),scripts:Gs(Ic,rl).refine(e=>Object.keys(e).length<=32,`A Board takes at most 32 scripts of its own.`).optional().describe(`Modules attached to the Board itself, by id: every item is in their scope and they draw over the whole view. Ids are shared with items and animations.`)}).strict(),pu=Gs(L(),Ms()),mu=R({board:pu.nullable().optional(),items:Gs(Ic,pu.nullable()).optional(),animations:Gs(Ic,pu.and(R({tracks:Gs(Fc,pu.nullable()).optional()})).nullable()).optional()}).strict();function hu(e){let t={text:1,image:2,audio:3,video:4}[e.type];return e.type===`text`?[t,e.textExcerpt.length]:e.type===`image`?[t,(e.naturalWidth??0)*(e.naturalHeight??0)]:[t,+!!e.previewUrl,+!!e.durationMs,e.durationMs??0]}function gu(e,t){let n=hu(e),r=hu(t);for(let e=0;e<Math.max(n.length,r.length);e+=1){let t=(r[e]??0)-(n[e]??0);if(t!==0)return t}return 0}function _u(e){let t;for(let n of e)(!t||gu(n,t)<0)&&(t=n);return t}function vu(e){if(e?.type===`image`)return e.url;if(e?.type===`video`||e?.type===`audio`)return e.previewUrl}const yu=[1,0,0,1,0,0];function bu(e,t){let[n,r,i,a,o,s]=e,[c,l,u,d,f,p]=t;return[n*c+i*l,r*c+a*l,n*u+i*d,r*u+a*d,n*f+i*p+o,r*f+a*p+s]}function xu(e){let[t,n,r,i,a,o]=e,s=t*i-n*r||1e-12;return[i/s,-n/s,-r/s,t/s,(r*o-i*a)/s,(n*a-t*o)/s]}function Su(e,t){let[n,r,i,a,o,s]=e;return{x:n*t.x+i*t.y+o,y:r*t.x+a*t.y+s}}function Cu([e,t,n,r]){let i=e*r-t*n<0;return{rotation:Math.atan2(i?-t:t,i?-e:e)*180/Math.PI,mirrored:i}}function wu(e){return typeof e==`number`?{x:e,y:e}:e}let Tu;function Eu(e){Tu=e,ju.clear()}function Du(e){return e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=129791||e>=131072&&e<=262141}function Ou(e,t){let n=0;for(let t of e){let e=t.codePointAt(0)??0;t===` `?n+=.28:Du(e)?n+=1:/[il.,:;'|!]/.test(t)?n+=.3:/[mwMW@]/.test(t)?n+=.85:/[A-Z0-9]/.test(t)?n+=.64:n+=.55}return n*t}function ku(e,{fontSize:t},n){let r=e=>Ou(e,t),i=e.split(`
56
- `),a=n?i.flatMap(e=>Au(e,n,r)):i;return{lines:a,width:a.reduce((e,t)=>Math.max(e,r(t)),0)}}function Au(e,t,n){if(!e)return[``];let r=e.match(/[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\uff00-\uff60]|[^\s\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\uff00-\uff60]+|\s+/g)??[e],i=[],a=``;for(let e of r){let r=a+e;if(!a||n(r.trimEnd())<=t){a=r;continue}i.push(a.trimEnd()),a=/^\s+$/.test(e)?``:e}return i.push(a.trimEnd()),i}const ju=new Map;function Mu(e){return Math.min(512,Math.max(2,e))}function Nu(e){let t=Mu(e.fontSize??24),n=`${t}|${e.fontWeight}|${e.font}|${e.lineHeight}|${e.width??``}|${e.text}`,r=ju.get(n);if(r)return r;let i={fontSize:t,fontWeight:e.fontWeight??500,font:e.font??`sans`},{lines:a,width:o}=(Tu??ku)(e.text||``,i,e.width||void 0),s=t*(e.lineHeight??4/3),c={width:Math.max(e.width??0,o,t*.5),height:Math.max(1,a.length)*s,lines:a,lineHeight:s};return ju.size>=4096&&ju.clear(),ju.set(n,c),c}function Pu(e,t){let n=Math.min(1,Math.max(0,t));return Math.max(.5,e/2*(.5+n))}function Fu(e,t){if(e.length===0)return{x:0,y:0,width:1,height:1};let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of e){let e=Pu(t,o.p);n=Math.min(n,o.x-e),r=Math.min(r,o.y-e),i=Math.max(i,o.x+e),a=Math.max(a,o.y+e)}return{x:n,y:r,width:Math.max(1,i-n),height:Math.max(1,a-r)}}function Iu(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);return Number.isFinite(t)?{x:t,y:n,width:Math.max(1,r-t),height:Math.max(1,i-n)}:{x:0,y:0,width:1,height:1}}function Lu(e){return typeof e.item==`string`}function Ru(e){if(e.type!==`arrow`)return[];let t=e.props,n=[t.start,t.end].filter(Lu).map(e=>e.item);return[...new Set(n)]}function zu(e,t,n){let r={x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(!n)return r;let i=t.x-e.x,a=t.y-e.y,o=Math.hypot(i,a)||1,s=n*o;return{x:r.x+-a/o*s,y:r.y+i/o*s}}function Bu(e,t){let n=e,r=new Map,i=new Map,a=new Map;function o(e,t=0){let r=i.get(e);if(r)return r;let a=n(e);if(!a)return yu;let c=bu(a.parent&&t<64&&n(a.parent)?o(a.parent,t+1):yu,s(e));return i.set(e,c),c}function s(e){let t=n(e);if(!t)return yu;if(t.type===`arrow`)return Vu(t.position);let r=c(e),i=wu(t.scale),a=t.rotation*Math.PI/180,o=Math.cos(a),s=Math.sin(a),l=r.x+t.origin.x*r.width,u=r.y+t.origin.y*r.height,d=o*i.x,f=s*i.x,p=-s*i.y,m=o*i.y;return[d,f,p,m,t.position.x+l-(d*l+p*u),t.position.y+u-(f*l+m*u)]}function c(e,t=0){let i=r.get(e);if(i)return i;let a=n(e),o;if(!a)o={x:0,y:0,width:1,height:1};else if(`size`in a&&a.size)o={x:0,y:0,width:a.size.width,height:a.size.height};else if(a.type===`text`){let e=Nu(a.props);o={x:0,y:0,width:e.width,height:e.height}}else if(a.type===`draw`)o=Fu(a.props.points,a.style.strokeWidth??4);else if(a.type===`arrow`){let e=a.props,n=xu(bu(l(a,t),Vu(a.position))),r=Lu(e.start)?Su(n,u(a,e.start,e.end,t)):e.start,i=Lu(e.end)?Su(n,u(a,e.end,e.start,t)):e.end,s=[r,i,...e.waypoints];e.bend&&s.push(zu(r,i,e.bend));let c=Iu(s),d=Math.max(8,(a.style.strokeWidth??2.5)*2);o={x:c.x-d,y:c.y-d,width:c.width+d*2,height:c.height+d*2}}else o={x:0,y:0,...wc(a.type)};return r.set(e,o),o}function l(e,t){return e.parent&&t<64&&n(e.parent)?o(e.parent,t+1):yu}function u(e,t,r,i){let a=n(t.item),o=bu(l(e,i),Vu(e.position));if(!a||a.type===`arrow`||i>=64)return Su(o,{x:0,y:0});let s=d(t.item,i+1),c=Lu(r)?n(r.item)&&n(r.item)?.type!==`arrow`?Hu(d(r.item,i+1)):Hu(s):Su(o,r);return qu(s,t.anchor,c)}function d(e,t=0){c(e,t);let n=r.get(e),i=o(e,t),[a,s,l,u]=i,d=Su(i,{x:n.x+n.width/2,y:n.y+n.height/2}),f=n.width*Math.hypot(a,s),p=n.height*Math.hypot(l,u),{rotation:m,mirrored:h}=Cu(i);return{x:d.x-f/2,y:d.y-p/2,width:f,height:p,rotation:m,...h?{mirrored:h}:{}}}function f(e){let t=a.get(e);if(t)return t;let n=c(e),r=o(e),i=Iu([Su(r,{x:n.x,y:n.y}),Su(r,{x:n.x+n.width,y:n.y}),Su(r,{x:n.x+n.width,y:n.y+n.height}),Su(r,{x:n.x,y:n.y+n.height})]);return a.set(e,i),i}function p(e){n=e}function m(e){if(!e){r.clear(),i.clear(),a.clear();return}let n=[...e],o=new Set;for(;n.length;){let e=n.pop();if(!o.has(e)&&(o.add(e),r.delete(e),i.delete(e),a.delete(e),t))for(let r of t(e))n.push(r)}}return{has:e=>n(e)!==void 0,box:e=>c(e),matrix:e=>o(e),localMatrix:e=>s(e),parentMatrix:e=>{let t=n(e);return t?l(t,0):yu},bounds:f,frame:e=>d(e),arrowEnd:(e,t)=>{let r=n(e);if(r?.type!==`arrow`)return{x:0,y:0};let i=r,[a,s]=t===`start`?[i.props.start,i.props.end]:[i.props.end,i.props.start];return Lu(a)?u(i,a,s,0):Su(o(e),a)},invalidate:m,setLookup:p}}function Vu(e){return[1,0,0,1,e.x,e.y]}function Hu(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Uu(e,t,n){if(!n)return e;let r=n*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=e.x-t.x,s=e.y-t.y;return{x:t.x+o*i-s*a,y:t.y+o*a+s*i}}function Wu(e,t,n){return Uu({x:e.x+t*e.width,y:e.y+n*e.height},Hu(e),e.rotation)}function Gu(e,t){let n=Uu(t,Hu(e),-e.rotation),r=Hu(e),i=(n.x-r.x)/Math.max(e.width/2,1e-4),a=(n.y-r.y)/Math.max(e.height/2,1e-4);return Math.abs(i)>=Math.abs(a)?i>=0?`right`:`left`:a>=0?`bottom`:`top`}function Ku(e,t){switch(e){case`top`:return{x:t,y:0};case`bottom`:return{x:t,y:1};case`left`:return{x:0,y:t};default:return{x:1,y:t}}}function qu(e,t,n){if(t===`auto`){let t=Ku(Gu(e,n),.5);return Wu(e,t.x,t.y)}if(`side`in t){let n=Ku(t.side,t.offset);return Wu(e,n.x,n.y)}return Wu(e,t.x,t.y)}function Ju(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return Number.isNaN(e)&&Number.isNaN(t);let n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r)return e.length===t.length&&e.every((e,n)=>Ju(e,t[n]));let i=e,a=t,o=Object.keys(i);return o.length===Object.keys(a).length&&o.every(e=>Object.hasOwn(a,e)&&Ju(i[e],a[e]))}function Yu(e,t){let n=e[t];return n||(n={},e[t]=n),n}function Xu(){return{items:{},animations:{},tracks:{}}}function Zu(e){for(let[t,n]of Object.entries(e))(n===void 0||Qu(n)&&Object.keys(n).length===0)&&delete e[t];return e}function Qu(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $u(e,t){if(!Qu(t))return t;let n=Qu(e)?{...e}:{};for(let[e,r]of Object.entries(t))r===null?delete n[e]:n[e]=$u(n[e],r);return n}function ed(e){return e._zod.def}function td(e){let t=e;for(let e=0;e<16;e+=1){let e=ed(t);if(e.type===`optional`||e.type==="default"||e.type===`nullable`||e.type===`readonly`||e.type===`prefault`)t=e.innerType;else if(e.type===`pipe`)t=e.in;else return t}return t}function nd(e){let t=ed(td(e));return t.type===`object`?t.shape:null}function rd(e,t){let n=e;for(let e of t){let t=ed(td(n));if(t.type===`object`){let r=t.shape;if(!Object.hasOwn(r,e))return null;n=r[e]}else if(t.type===`record`)n=t.valueType;else if(t.type===`union`){let r=t.options.find(t=>nd(t)?.[e]);if(!r)return null;n=nd(r)[e]}else return null}return n}const id=new Set([`type`,`parent`,`z`,`locked`,`autoplay`,`metadata`,`script`]),ad={focus:{kind:`discrete`,schema:zs([L().min(1),R({x:ws().finite(),y:ws().finite(),width:ws().finite().positive(),height:ws().finite().positive()}).strict()]).describe(`Item id or world-space rect to fit with 48 px padding; holds until the next focus keyframe.`)},zoom:{kind:`number`,schema:ws().finite().positive().describe(`Pixels per world unit; overrides the zoom computed by focus.`),multiplicative:!0},center:{kind:`vec2`,schema:Bc.describe(`World-space viewport center; overrides focus positioning using the resolved zoom.`)},shake:{kind:`number`,schema:ws().finite().nonnegative().describe(`Shake amplitude in screen pixels, applied after focus, zoom and center.`)}},od={time:{kind:`number`,schema:ws().finite().nonnegative()}},sd={kind:`discrete`,schema:yc().describe(`Numbers blend and colors mix between keyframes; other values step.`)};function cd(e,t){let n=t[t.length-1];if(t.length===1&&n===`scale`)return`scale`;if(e===Kc||td(e)===Kc)return`color`;if(ed(td(e)).type===`number`)return`number`;let r=nd(e);return r&&Object.keys(r).length===2&&`x`in r&&`y`in r?`vec2`:`discrete`}function ld(e,t){if(e===`camera`){let e=ad[t];return e?{ok:!0,spec:e}:{ok:!1,message:`camera has no property ${t}; expected ${Object.keys(ad).join(`, `)}`}}if(e===`animation`){let e=od[t];return e?{ok:!0,spec:e}:{ok:!1,message:`animations are driven through time`}}if(e===`script`)return/^params\.[^.]+$/.test(t)?{ok:!0,spec:sd}:{ok:!1,message:`Board scripts animate params.<name>, not ${t}`};if(/^script\.params\.[^.]+$/.test(t))return{ok:!0,spec:sd};let n=t.split(`.`);if(n.some(e=>!e)||id.has(n[0]))return{ok:!1,message:`${t} cannot be animated`};let r=Jl(e);if(!r)return{ok:!1,message:`unknown item type ${e}`};if(!Gl(e)&&n[0]===`props`)return{ok:!0,spec:{kind:`discrete`,schema:Ms()}};let i=rd(r,n);if(!i)return{ok:!1,message:`${e} has no property ${t}`};let a=cd(i,n);return{ok:!0,spec:{kind:a,schema:td(i),...t===`opacity`||a===`scale`?{multiplicative:!0}:{}}}}function ud(e){let t=0;for(let n of e){let e=n?.keyframes;if(Array.isArray(e))for(let n of e){let e=n?.at;typeof e==`number`&&Number.isFinite(e)&&(t=Math.max(t,e))}}return t>0?t:void 0}function dd(e){let t=new Set([e.target]);if(e.target===`camera`&&e.property===`focus`)for(let n of e.keyframes)typeof n.value==`string`&&t.add(n.value);return t.delete(Pc),[...t]}function fd(e,t){if(t.has(e.target))return null;if(e.target!==`camera`||e.property!==`focus`)return e;let n=e.keyframes.filter(e=>typeof e.value!=`string`||!t.has(e.value));return n.length===e.keyframes.length?e:n.length?{...e,keyframes:n}:null}function pd(e,t,n){return{severity:`error`,code:t,path:e,message:n}}const md=[`fill`,`fillOpacity`,`stroke`,`strokeWidth`,`dash`,`radius`,`trim`];function hd(e,t,n,r){let[i,a]=t.type===`text`?[md.filter(e=>e!==`fill`),`text draws only its fill color`]:t.type===`file`?[md,`file cards follow the theme`]:t.type===`frame`&&t.props.decoration===`none`?[md,`a frame with decoration "none" draws no box; put a shape inside it instead`]:[[],``],o=Qu(n.style)?n.style:{},s=r||Qu(n.props)&&`decoration`in n.props,c=i.filter(e=>t.style[e]!==void 0&&(s||e in o));return c.length?{severity:`warning`,code:`STYLE_NOT_DRAWN`,path:`items.${e}.style`,message:`${c.join(`, `)} ${c.length===1?`has`:`have`} no effect: ${a}.`}:null}function gd(e){if(!(`id`in e))return e;let{id:t,...n}=e;return n}function _d(e,t,n={}){let r=mu.safeParse(t);if(!r.success)return{ok:!1,diagnostics:r.error.issues.map(e=>pd(e.path.map(String).join(`.`),`INVALID_PATCH`,e.message))};let i=r.data,a=[],o=[],s=e=>n.keepUnknown?Xl:e?Zl(e):void 0,c=new Map,l=new Map,u=new Map,d,f=t=>c.has(t)?c.get(t)??void 0:e.item(t),p=t=>l.has(t)?l.get(t)??void 0:e.animation(t),m=(e,t,n)=>{let r=u.get(e)??new Map;r.set(t,n),u.set(e,r)},h=(t,n)=>{let r=u.get(t);return r?.has(n)?r.get(n)??void 0:e.track(t,n)};if(i.board!==void 0){let t=i.board===null?{}:$u(e.settings(),i.board),n=eu(fu,t,s(e.settings()));if(n.success)d=n.data;else for(let e of n.error.issues)a.push(pd([`board`,...e.path.map(String)].join(`.`),`INVALID_BOARD`,e.message))}let g=new Map;for(let[t,n]of Object.entries(i.items??{})){if(n===null){e.item(t)&&c.set(t,null);continue}let r=e.item(t),i=gd(n),l=!r||typeof i.type==`string`&&i.type!==r.type,u=l?{...i}:$u(r,i);if(u.z===void 0){let t=typeof u.parent==`string`?u.parent:void 0,n=t??``,i=g.get(n)??e.maxZ(t);u.z=r?.z??i+1,r||g.set(n,i+1)}let d=tu(u,`items.${t}`,s(l?void 0:r));if(!d.ok){a.push(...d.diagnostics);continue}if(r&&Ju(r,d.item))continue;c.set(t,d.item);let f=hd(t,d.item,i,l);f&&o.push(f)}for(let[t,n]of Object.entries(i.animations??{})){if(n===null){if(!e.animation(t))continue;l.set(t,null);for(let n of e.trackIds(t))m(t,n,null);continue}let{tracks:r,...i}=gd(n);if(e.item(t)||c.get(t)){a.push(pd(`animations.${t}`,`ID_CONFLICT`,`${t} is already an item id`));continue}let o=e.animation(t);if(!o||Object.keys(i).length>0){let n=o?$u(o,i):{...i,...i.duration===void 0?{duration:ud([...Object.values(r??{}),...e.trackIds(t).map(n=>e.track(t,n))])}:{}},c=eu(cu,n,s(o));if(!c.success){for(let e of c.error.issues)a.push(pd([`animations`,t,...e.path.map(String)].join(`.`),`INVALID_ANIMATION`,e.message));continue}(!o||!Ju(o,c.data))&&l.set(t,c.data)}for(let[n,i]of Object.entries(r??{})){let r=e.track(t,n);if(i===null){r&&m(t,n,null);continue}let o=eu(ou,r?$u(r,i):i,s(r));if(!o.success){for(let e of o.error.issues)a.push(pd([`animations`,t,`tracks`,n,...e.path.map(String)].join(`.`),`INVALID_TRACK`,e.message));continue}(!r||!Ju(r,o.data))&&m(t,n,o.data)}}for(let e of c.keys())c.get(e)&&p(e)&&a.push(pd(`items.${e}`,`ID_CONFLICT`,`${e} is already an animation id`));let _=(d??e.settings()).scripts??{},v=e=>Object.hasOwn(_,e);for(let e of Object.keys(_)){let t=f(e)?`an item`:p(e)?`an animation`:null;if(!t)continue;let n=c.get(e)?`items.${e}`:l.get(e)?`animations.${e}`:`board.scripts.${e}`;a.push(pd(n,`ID_CONFLICT`,n.startsWith(`board`)?`${e} is already ${t} id`:`${e} is already a Board script id`))}if(a.length)return{ok:!1,diagnostics:a};let y=[...c].filter(([,e])=>e===null).map(([e])=>e),b=Bu(t=>f(t)??e.item(t)),x=[...y];for(;x.length;){let t=x.pop();for(let r of e.children(t))c.has(r)&&c.get(r)?.parent!==t||(n.cascade?c.get(r)!==null&&(c.set(r,null),x.push(r)):a.push(pd(`items.${t}`,`ITEM_REFERENCED`,`${t} still has child ${r}; delete it too or use cascade`)));for(let r of e.binders(t)){let e=f(r);if(e?.type!==`arrow`)continue;let i={...e.props};for(let e of[`start`,`end`]){let a=i[e];if(!Lu(a)||a.item!==t)continue;let o=n.resolveArrowEnd?.(r,e)??b.arrowEnd(r,e);i[e]=Su(xu(b.matrix(r)),o)}c.set(r,{...e,props:i})}for(let r of e.trackRefs(t)){let e=h(r.animation,r.track);!e||!dd(e).includes(t)||(n.cascade?m(r.animation,r.track,fd(e,new Set([t]))):a.push(pd(`items.${t}`,`ITEM_REFERENCED`,`${t} is animated by ${r.animation}.${r.track}; delete the track or use cascade`)))}}for(let t of Object.keys(e.settings().scripts??{}))if(!v(t))for(let r of e.trackRefs(t))h(r.animation,r.track)?.target===t&&(n.cascade?m(r.animation,r.track,null):a.push(pd(`board.scripts.${t}`,`SCRIPT_REFERENCED`,`${t} is animated by ${r.animation}.${r.track}; delete the track or use cascade`)));for(let[t,r]of l)if(r===null)for(let r of e.trackRefs(t))r.animation!==t&&h(r.animation,r.track)!==void 0&&(n.cascade?m(r.animation,r.track,null):a.push(pd(`animations.${t}`,`ANIMATION_REFERENCED`,`${t} is nested in ${r.animation}.${r.track}; delete the track or use cascade`)));let S={...e,trackIds:t=>[...new Set([...e.trackIds(t),...u.get(t)?.keys()??[]])]},C=new Map(c),w=[];for(let[t,n]of c)n&&n.parent!==e.item(t)?.parent&&w.push(...e.children(t));let T=new Set;for(;w.length;){let t=w.pop();T.has(t)||(T.add(t),C.set(t,f(t)??null),w.push(...e.children(t)))}for(let[e,t]of C)if(t){if(t.parent!==void 0){let n=f(t.parent);if(!n)a.push(pd(`items.${e}.parent`,`PARENT_NOT_FOUND`,`parent ${t.parent} does not exist`));else if(n.type!==`frame`)a.push(pd(`items.${e}.parent`,`INVALID_PARENT`,`parent ${t.parent} is a ${n.type}; only frames contain items`));else{let n=t.parent;for(let t=0;n;t+=1){if(t>=64){a.push(pd(`items.${e}.parent`,`PARENT_DEPTH`,`parent hierarchy exceeds 64 levels`));break}if(n===e){a.push(pd(`items.${e}.parent`,`PARENT_CYCLE`,`${e} cannot be inside itself`));break}n=f(n)?.parent}}}for(let n of Ru(t)){let t=f(n);t?(n===e||t.type===`arrow`)&&a.push(pd(`items.${e}.props`,`INVALID_BINDING`,`arrows bind to items other than arrows`)):a.push(pd(`items.${e}.props`,`BINDING_NOT_FOUND`,`bound item ${n} does not exist`))}}for(let[t,r]of c)if(!(!r||!e.item(t)||e.item(t)?.type===r.type)){if(r.type!==`frame`)for(let n of e.children(t))f(n)?.parent===t&&a.push(pd(`items.${n}.parent`,`INVALID_PARENT`,`${t} is not a frame`));if(r.type===`arrow`)for(let n of e.binders(t)){let e=f(n);e&&Ru(e).includes(t)&&a.push(pd(`items.${n}.props`,`INVALID_BINDING`,`arrows cannot bind to arrows`))}for(let r of e.trackRefs(t)){let e=h(r.animation,r.track);e&&a.push(...vd(`animations.${r.animation}.tracks.${r.track}`,r.animation,e,f,p,h,v,S,n.keepUnknown))}}for(let[t,r]of u){if(!p(t)){for(let[e,n]of r)n&&a.push(pd(`animations.${t}.tracks.${e}`,`ANIMATION_NOT_FOUND`,`animation ${t} does not exist`));continue}for(let[i,o]of r){if(!o)continue;let r=n.keepUnknown||e.track(t,i)?.property===o.property;a.push(...vd(`animations.${t}.tracks.${i}`,t,o,f,p,h,v,S,r))}}if(a.length)return{ok:!1,diagnostics:a};let E=Xu(),D=Xu();d&&!Ju(d,e.settings())&&(E.board=e.settings(),D.board=d);for(let[t,n]of c){let r=e.item(t)??null;Ju(r,n)||(E.items[t]=r,D.items[t]=n)}for(let[t,n]of l)E.animations[t]=e.animation(t)??null,D.animations[t]=n;for(let[t,n]of u)for(let[r,i]of n){let n=e.track(t,r)??null;Ju(n,i)||(Yu(E.tracks,t)[r]=n,Yu(D.tracks,t)[r]=i)}return{ok:!0,before:Zu(E),after:Zu(D),diagnostics:o}}function vd(e,t,n,r,i,a,o,s,c=!1){let l=[],u;if(n.target===`camera`)u=Pc;else if(r(n.target))u=r(n.target).type;else if(i(n.target)){if(u=`animation`,n.target===t||yd(n.target,t,i,a,s))return[pd(`${e}.target`,`ANIMATION_CYCLE`,`${t} cannot contain itself through ${n.target}`)]}else if(o(n.target))u=`script`;else return[pd(`${e}.target`,`TARGET_NOT_FOUND`,`target ${n.target} is not an item, animation, Board script or camera`)];if(!c&&n.property.startsWith(`script.`)&&!r(n.target)?.script)return[pd(`${e}.property`,`INVALID_PROPERTY`,`${n.target} has no script to animate`)];let d=ld(u,n.property);if(!d.ok)return c?[]:[pd(`${e}.property`,`INVALID_PROPERTY`,d.message)];for(let[t,i]of n.keyframes.entries()){let a=d.spec.schema.safeParse(i.value);if(!a.success){l.push(pd(`${e}.keyframes.${t}.value`,`INVALID_KEYFRAME`,a.error.issues[0]?.message??`invalid value`));continue}n.property===`focus`&&typeof i.value==`string`&&!r(i.value)&&l.push(pd(`${e}.keyframes.${t}.value`,`TARGET_NOT_FOUND`,`focus item ${i.value} does not exist`))}return n.interpolation===`spline`&&d.spec.kind!==`vec2`&&l.push(pd(`${e}.interpolation`,`INVALID_TRACK`,`spline interpolation needs a position-like property`)),l}function yd(e,t,n,r,i){let a=new Set,o=[e];for(;o.length;){let e=o.pop();if(e===t)return!0;if(!(a.has(e)||!n(e))){a.add(e);for(let t of i.trackIds(e)){let i=r(e,t);i&&i.property===`time`&&n(i.target)&&o.push(i.target)}}}return!1}function bd(e){let t=null,n=null,r=null,i=()=>{if(!t){t=new Map,n=new Map,r=new Map;for(let[r,i]of Object.entries(e.items)){i.parent&&t.set(i.parent,[...t.get(i.parent)??[],r]);for(let e of Ru(i))n.set(e,[...n.get(e)??[],r])}for(let[t,n]of Object.entries(e.animations))for(let[e,i]of Object.entries(n.tracks))for(let n of dd(i))r.set(n,[...r.get(n)??[],{animation:t,track:e}])}};return{settings:()=>e.board,item:t=>e.items[t],animation:t=>{let n=e.animations[t];if(!n)return;let{tracks:r,...i}=n;return i},track:(t,n)=>e.animations[t]?.tracks[n],trackIds:t=>Object.keys(e.animations[t]?.tracks??{}),children:e=>(i(),t?.get(e)??[]),binders:e=>(i(),n?.get(e)??[]),trackRefs:e=>(i(),r?.get(e)??[]),maxZ:t=>{let n=0;for(let r of Object.values(e.items))r.parent===t&&(r.z??0)>n&&(n=r.z??0);return n}}}function xd(e,t){let n=t.items?{...e.items}:e.items;for(let[e,r]of Object.entries(t.items??{}))r?n[e]=r:delete n[e];let r=t.animations||t.tracks?{...e.animations}:e.animations;for(let[e,n]of Object.entries(t.animations??{}))n?r[e]={...n,tracks:r[e]?.tracks??{}}:delete r[e];for(let[e,n]of Object.entries(t.tracks??{})){let t=r[e];if(!t)continue;let i={...t.tracks};for(let[e,t]of Object.entries(n))t?i[e]=t:delete i[e];r[e]={...t,tracks:i}}return{board:t.board??e.board,items:n,animations:r}}function Sd(e,t,n={}){let r=_d(bd(e),t,n);return r.ok?{ok:!0,document:xd(e,r.after),before:r.before,after:r.after}:r}function Cd(e,t={}){if(!Qu(e))return{ok:!1,diagnostics:[pd(``,`INVALID_DOCUMENT`,`expected an object`)]};let n=Sd({board:fu.parse({}),items:{},animations:{}},{...Qu(e.board)?{board:e.board}:{},...Qu(e.items)?{items:e.items}:{},...Qu(e.animations)?{animations:e.animations}:{}},t);return n.ok?{ok:!0,document:n.document}:n}R({kind:B(`cohub.board.manifest`),version:B(1),boardId:L().uuid(),title:L().min(1).max(255)});const wd=[`items`,`animations`],Td=R({x:ws().finite(),y:ws().finite(),width:ws().finite().positive(),height:ws().finite().positive()}).strict();R({only:Is(z(wd)).optional(),rect:Td.optional(),within:Ic.optional(),items:Is(L().min(1)).max(5e4).optional(),animations:Is(L().min(1)).max(1e4).optional(),limit:ws().int().min(1).max(5e4).optional(),cursor:L().min(1).optional(),since:ws().int().nonnegative().optional()}).strict().refine(e=>!(e.cursor&&(e.rect||e.within)),{path:[`cursor`],message:`cursor pages by id, so it cannot be combined with rect or within`}).refine(e=>e.since===void 0||Object.entries(e).every(([e,t])=>e===`since`||t===void 0),{path:[`since`],message:`since syncs the whole Board, so it cannot be combined with other read options`}),R({patch:mu,replace:Os().default(!1),cascade:Os().default(!1),dryRun:Os().default(!1),baseVersion:ws().int().nonnegative().optional(),mutationId:L().min(1).max(160).optional(),clientId:L().min(1).max(160).optional()}).strict(),R({path:L().min(1),title:L().min(1).max(255).optional(),document:mu.optional(),mutationId:L().max(160).optional()}).strict(),R({before:ws().int().positive().optional(),limit:ws().int().min(1).max(500).default(200)}).strict();const Ed=L().min(1).max(160);Vs(`type`,[R({commandId:Ed,type:B(`play`),animationId:L().min(1),position:ws().finite().nonnegative().optional(),timeScale:ws().finite().positive().max(4).optional(),seed:L().min(1).max(160).optional()}).strict(),R({commandId:Ed,type:B(`pause`)}).strict(),R({commandId:Ed,type:B(`resume`)}).strict(),R({commandId:Ed,type:B(`seek`),position:ws().finite().nonnegative()}).strict(),R({commandId:Ed,type:B(`next`)}).strict(),R({commandId:Ed,type:B(`stop`)}).strict()]);const Dd=L().min(1).max(160),Od=ws().finite(),kd=Od.min(-1e9).max(1e9),Ad=Od.positive().max(1e8),jd=Od.min(.05).max(8),Md=R({x:kd,y:kd}),Nd=Md.extend({p:Od.min(0).max(1)}),Pd=R({x:kd,y:kd,width:Ad,height:Ad,rotation:Od}),Fd=R({x:kd,y:kd,width:Ad,height:Ad,zoom:jd}),Id=R({itemId:Dd,frame:Pd}),Ld=R({type:B(`state`),client:R({formFactor:z([`desktop`,`mobile`]),scripts:Os().optional()}).optional(),cursor:Md.extend({pointerType:z([`mouse`,`pen`,`touch`]),pressed:Os().optional()}).nullable(),viewport:Fd.nullable().optional(),tool:L().min(1).max(40),selection:R({ids:Is(Dd).max(64),count:ws().int().nonnegative().max(5e4),bounds:Pd.nullable()}),editingId:Dd.nullable()}),Rd=Vs(`kind`,[R({kind:B(`draw`),id:Dd,itemId:Dd,color:L().min(1).max(64),size:Od.positive().max(256),from:ws().int().nonnegative().max(1e5),points:Is(Nd).min(1).max(64)}),R({kind:B(`arrow`),id:Dd,itemId:Dd,start:Md,current:Md,startItemId:Dd.nullable().default(null),endItemId:Dd.nullable().default(null),color:L().min(1).max(64),size:Od.positive().max(256).default(bc)}),R({kind:B(`box`),id:Dd,itemId:Dd,shape:z([`shape`,`frame`]),start:Md,current:Md,color:L().min(1).max(64),geometry:L().min(1).max(40).default(`rectangle`)}),R({kind:B(`transform`),id:Dd,mode:z([`translate`,`resize`,`rotate`,`arrow`]),items:Is(Id).max(64),bounds:Pd.nullable()})]),zd=[`heart`,`star`,`spark`,`confetti`],Bd=1024,Vd=Vs(`type`,[Ld,R({type:B(`gesture`),gesture:Rd}),R({type:B(`gesture.end`),gestureId:Dd,resultingItemIds:Is(Dd).max(64)}),R({type:B(`gesture.cancel`),gestureId:Dd}),R({type:B(`reaction`),reaction:z(zd),at:Md}),R({type:B(`script`),owner:Dd,event:L().min(1).max(64),data:yc().refine(e=>JSON.stringify(e).length<=Bd,`Broadcast data exceeds ${Bd} characters of JSON.`)})]);R({spaceId:L().uuid(),boardId:L().uuid(),seq:ws().int().nonnegative(),update:Vd});const Hd={".txt":`text/plain`,".md":`text/markdown`,".markdown":`text/markdown`,".json":`application/json`,".jsonl":`application/x-ndjson`,".csv":`text/csv`,".board":`application/json`,".js":`text/javascript`,".mjs":`text/javascript`,".cjs":`text/javascript`,".ts":`text/typescript`,".tsx":`text/tsx`,".jsx":`text/jsx`,".svelte":`text/x-svelte`,".css":`text/css`,".scss":`text/x-scss`,".html":`text/html`,".htm":`text/html`,".xml":`application/xml`,".yaml":`application/yaml`,".yml":`application/yaml`,".toml":`application/toml`,".ini":`text/plain`,".env":`text/plain`,".sh":`text/x-shellscript`,".bash":`text/x-shellscript`,".py":`text/x-python`,".go":`text/x-go`,".rs":`text/x-rust`,".java":`text/x-java-source`,".c":`text/x-c`,".h":`text/x-c`,".cpp":`text/x-c++src`,".hpp":`text/x-c++hdr`,".sql":`application/sql`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".avif":`image/avif`,".bmp":`image/bmp`,".ico":`image/x-icon`,".mp4":`video/mp4`,".webm":`video/webm`,".mov":`video/quicktime`,".m4v":`video/x-m4v`,".ogv":`video/ogg`,".avi":`video/x-msvideo`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".ogg":`audio/ogg`,".m4a":`audio/mp4`,".aac":`audio/aac`,".flac":`audio/flac`,".opus":`audio/ogg`,".glb":`model/gltf-binary`,".gltf":`model/gltf+json`,".stl":`model/stl`,".obj":`model/obj`,".3mf":`model/3mf`,".usdz":`model/vnd.usdz+zip`,".mtl":`text/plain`,".pdf":`application/pdf`,".wasm":`application/wasm`,".woff":`font/woff`,".woff2":`font/woff2`,".zip":`application/zip`,".gz":`application/gzip`,".tar":`application/x-tar`,".rar":`application/vnd.rar`,".7z":`application/x-7z-compressed`,".exe":`application/x-msdownload`,".dmg":`application/x-apple-diskimage`,".deb":`application/vnd.debian.binary-package`,".rpm":`application/x-rpm`},Ud={dockerfile:`text/x-dockerfile`,makefile:`text/x-makefile`};function Wd(e){let t=(e.split(/[\\/]/).pop()??``).toLowerCase(),n=Object.hasOwn(Ud,t)?Ud[t]:void 0;if(n)return n;let r=t.lastIndexOf(`.`);return(r>0?Hd[t.slice(r)]:void 0)||(t.startsWith(`.`)?`text/plain`:null)}function Gd(e){return e&&e.split(`;`)[0]?.trim().toLowerCase()||null}const Kd={"model/gltf-binary":`glb`,"model/gltf+json":`gltf`,"model/stl":`stl`,"model/obj":`obj`};function qd(e,t){let n=e=>{let t=Gd(e);return t&&Object.hasOwn(Kd,t)?Kd[t]:void 0};return n(Wd(e))??n(t)??null}const Jd=[`motion`,`gamepad`,`microphone`,`camera`,`location`],Yd=[`below`,`above`,`filter`],Xd=[`normal`,`add`,`screen`,`multiply`],Zd=new WeakMap;function Qd(e){let t=e.board?.scripts,n=Zd.get(e.items);if(n&&n.scripts===t)return n.list;let r=[];for(let[e,n]of Object.entries(t??{}))n.enabled&&r.push({id:e,script:n,item:null});for(let[t,n]of Object.entries(e.items))n.script?.enabled&&r.push({id:t,script:n.script,item:n});return Zd.set(e.items,{scripts:t,list:r}),r}function $d(e,t){return!!(e.board?.scripts&&Object.hasOwn(e.board.scripts,t))}function ef(e,t){if(e===t)return!0;if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!ef(e[n],t[n]))return!1;return!0}let n=e,r=t,i=0;for(let e of Object.keys(n))if(n[e]!==void 0&&(i+=1,!ef(n[e],r[e])))return!1;for(let e of Object.keys(r))r[e]!==void 0&&--i;return i===0}const tf=new WeakMap,nf=new WeakMap;function rf(e){let t=tf.get(e);if(!t){t=new Map;for(let[n,r]of Object.entries(e)){if(!r.parent)continue;let e=t.get(r.parent);e?e.push(n):t.set(r.parent,[n])}tf.set(e,t)}return t}function af(e,t){return $d(e,t)?e.board?.scripts?.[t]:e.items[t]?.script}function of(e,t){if($d(e,t)){let t=nf.get(e.items);return t||(t=new Set(Object.keys(e.items)),nf.set(e.items,t)),t}let n=e.items[t],r=new Set([t]);for(let t of Object.values(n?.script?.targets??{}))e.items[t]&&r.add(t);if(n?.type!==`frame`)return r;let i=rf(e.items),a=new Set([t]),o=[t];for(let e=0;o.length&&e<64;e++)for(let e of o.splice(0))for(let t of i.get(e)??[])a.has(t)||(a.add(t),r.add(t),o.push(t));return r}function sf(e,t,n,r){let i={},a=!1;for(let o of n){let n=t.items[o],s=e.get(o);!n||s===n||(e.set(o,n),!(s&&ef(s,n))&&(i[o]=n,a=!0,r?.(o,s?`changed`:`added`)))}if(e.size>n.size)for(let t of e.keys())n.has(t)||(e.delete(t),i[t]=null,a=!0,r?.(t,`removed`));return a?i:null}const cf={"browser:devicemotion":`motion`,"browser:deviceorientation":`motion`,"browser:deviceorientationabsolute":`motion`,"browser:gamepads":`gamepad`,"browser:audio":`microphone`,"browser:video":`camera`,"browser:position":`location`},lf=e=>Object.hasOwn(cf,e)?cf[e]:void 0,uf=new Set([`browser:gamepads`,`browser:position`,`browser:video`]),df=e=>uf.has(e);function ff(e){return Object.fromEntries(Jd.map(t=>[t,e]))}const pf={mode:`export`,pointer:`fine`,orientation:`landscape`,angle:0,reducedMotion:!1,locale:null,senses:ff(`unavailable`)};function mf(e){e.type===`browser:video`&&e.data.frame?.close?.()}const hf=`$f32`;function gf(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Float32Array(n.buffer)}function _f(e){let t=JSON.parse(e,(e,t)=>t&&typeof t==`object`&&typeof t[hf]==`string`&&Object.keys(t).length===1?gf(t[hf]):t),n=t?.inputs;if(t?.version!==1||!Array.isArray(n))throw Error(`Not a Board input recording: expected { version: 1, inputs: [...] }.`);let r=0;for(let[e,t]of n.entries()){if(!t||typeof t.t!=`number`||!(t.t>=r)||typeof t.type!=`string`||!lf(t.type)||t.type===`browser:video`)throw Error(`inputs[${e}] needs a t no earlier than the one before and a browser event type other than browser:video.`);r=t.t}return t}function vf(e,t,n){if(!e)return[];let r=[];for(let{t:i,type:a,data:o}of e.inputs){if(i>n)break;i>t&&r.push({type:a,data:o})}return r}function yf(e,t){if(e.type!==t.type)return!1;if(t.type===`viewchange`||t.type===`selectionchange`||t.type===`peerschange`||df(t.type))return!0;if(t.type===`pointermove`)return e.pointerId===t.pointerId;if(t.type!==`gesture`)return!1;let n=e.data,r=t.data;return n.id===r.id&&n.phase===`update`&&r.phase===`update`}function bf(e,t){return!e||t.type===`viewchange`||e.listens.includes(t.type)}function xf(e,t){let n=e.length-1;for(;n>=0&&!yf(e[n],t);)n--;return n>=0&&(t.type!==`pointermove`||n===e.length-1)&&mf(e.splice(n,1)[0]),e.length>=128?(mf(t),!1):(e.push(t),!0)}function Sf(e,t,n){let r=n;if(!r||typeof r.target!=`string`||typeof r.type!=`string`||!r.type)throw Error(`emit() takes a target id and an event type.`);let{target:i,type:a}=r;if(!$d(e,i)&&!of(e,t).has(i))throw Error(`emit() from ${t} cannot reach ${i}: it is neither in scope nor a Board script.`);let o=typeof r.depth==`number`&&Number.isSafeInteger(r.depth)&&r.depth>0?r.depth:1;if(o>16)throw Error(`emit(${i}, "${a}") from ${t} is ${o} handlers deep, past the limit of 16: handlers keep answering each other. Emit from onFrame() to send it on the next step.`);return{target:i,event:{type:a,data:r.data,depth:o,...r.remote===!0?{remote:!0}:{}}}}const Cf=/^(pointer|key|browser:)|^(click|focus|blur|change|selectionchange|transformend|viewchange|envchange|gesture|peerschange)$/;function wf(e){let t=e,n=t?.type;if(typeof n!=`string`||!n||n.length>64)throw Error(`broadcast() takes an event type of 1–64 characters.`);if(Cf.test(n))throw Error(`broadcast("${n}"): input and host event types are reserved.`);let r;try{r=JSON.stringify(t?.data??null)}catch{}if(r===void 0)throw Error(`broadcast("${n}") data must be JSON.`);if(r.length>1024)throw Error(`broadcast("${n}") data exceeds ${Bd} characters of JSON.`);let i=typeof t?.depth==`number`&&Number.isSafeInteger(t.depth)&&t.depth>0?t.depth:1;if(i>16)throw Error(`broadcast("${n}") is ${i} handlers deep, past the limit of 16: handlers keep answering each other. Broadcast from onFrame() to send it on the next step.`);return{type:n,data:JSON.parse(r),depth:i,peer:null}}function Tf(e){let t=[],n=0,r=new Map;return{get size(){return t.length},push(i,a,o){let s=r.get(a)??0;if(s>=128)throw Error(`emit(${a}, "${o.type}") from ${i}: ${a} already has 128 events waiting.`);r.set(a,s+1),t.push({rank:e().get(i)??2**53-1,seq:n++,target:a,event:o})},take(){let e=t.sort((e,t)=>e.rank-t.rank||e.seq-t.seq);t=[],r.clear();let n=new Map;for(let{target:t,event:r}of e)n.set(t,[...n.get(t)??[],r]);return n}}}function V(e,t){return{x:e,y:t}}const Ef={x:0,y:0,zoom:1};function Df(e,t=.001){let n=Number.isFinite(e)?e:Ef.zoom;return Math.min(8,Math.max(t,n))}function Of(e,t=Ef){let n=Number.isFinite(t.x)?t.x:Ef.x,r=Number.isFinite(t.y)?t.y:Ef.y,i=Number.isFinite(t.zoom)?Df(t.zoom):Ef.zoom;return{x:Number.isFinite(e.x)?e.x:n,y:Number.isFinite(e.y)?e.y:r,zoom:Number.isFinite(e.zoom)?Df(e.zoom):i}}function kf(e){return e*Math.PI/180}function Af(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function jf(e){return V(e.x+e.width/2,e.y+e.height/2)}function Mf(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Nf(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}}function Pf(e,t,n){let r=Math.cos(n),i=Math.sin(n),a=e.x-t.x,o=e.y-t.y;return{x:t.x+a*r-o*i,y:t.y+a*i+o*r}}function Ff(e,t){let n=(t?.filter?.blur??0)*3,r=t?.shadow;if(!n&&!r)return e;let i=r?(r.blur??Xc.blur)*1.5:0,a=r?r.x??Xc.x:0,o=r?r.y??Xc.y:0,s=n+Math.max(0,i-a),c=n+Math.max(0,i-o);return{x:e.x-s,y:e.y-c,width:e.width+s+n+Math.max(0,i+a),height:e.height+c+n+Math.max(0,i+o)}}function If(e){let t=e.rotation||0;if(t===0)return Af(e);let n=jf(Af(e)),r=e.width/2,i=e.height/2,a=kf(t),o=Math.abs(Math.cos(a)),s=Math.abs(Math.sin(a)),c=r*o+i*s,l=r*s+i*o;return{x:n.x-c,y:n.y-l,width:c*2,height:l*2}}function Lf(e,t){let n=Df(e.zoom);return Of({x:t.width/2-e.centerX*n,y:t.height/2-e.centerY*n,zoom:n})}function Rf(e,t,n={}){let r=Math.max(0,Number.isFinite(n.padding)?n.padding:32),i=Math.max(1,t.width-r*2),a=Math.max(1,t.height-r*2),o=n.fit===`cover`?Math.max(i/e.width,a/e.height):Math.min(i/e.width,a/e.height),s=Df(n.minZoom??0),c=Df(n.maxZoom??8),l=Math.min(Math.max(o,Math.min(s,c)),Math.max(s,c)),u=jf(e);return Lf({centerX:u.x,centerY:u.y,zoom:l},t)}function zf(e,t){if(typeof e!=`string`)return e;let n=t(e);return n?If(n):null}function Bf(e,t,n,r={}){let i=zf(e,t);return i?Rf(i,n,r):null}const Vf={passes:16,source:65536,sprites:65536,stateEdge:1024,texel:1024,uniformSlots:128},Hf={float:1,int:1,vec2:2,vec3:3,vec4:4},Uf=/^[A-Za-z][A-Za-z0-9_]{0,62}$/;function Wf(e){let t=[],n=0;for(let[r,i]of Object.entries(e??{})){if(!Uf.test(r)||r.includes(`__`))throw Error(`Invalid uniform name: ${r}`);let e=typeof i==`string`?/^(float|int|vec2|vec3|vec4)(?:\[(\d{1,3})\])?$/.exec(i):null;if(!e)throw Error(`Uniform ${r} must be float, int, vec2, vec3 or vec4, optionally with [length].`);let a=e[1],o=e[2]===void 0?null:Number(e[2]);if(o!==null&&(o<1||o>256))throw Error(`Uniform ${r} takes 1 to 256 elements.`);n+=o??1,t.push({name:r,type:a,length:o})}if(n>Vf.uniformSlots)throw Error(`Shader uniforms take at most ${Vf.uniformSlots} vectors.`);return t}function Gf(e,t){let n=Hf[e.type]*(e.length??1);if(t===void 0)return Array(n).fill(0);let r=typeof t==`number`?[t]:[...t];if(e.length===null?r.length!==n:r.length>n||r.length%Hf[e.type])return null;for(;r.length<n;)r.push(0);return r}function Kf(e,t){return t.layer??e.layer??`above`}function qf(e,t){return(e.name===void 0?void 0:t?.[e.name])??e.enabled??!0}function Jf(e){let t=[];for(let[n,r]of Object.entries(e??{}))!Uf.test(n)||n.includes(`__`)||(r.type===`number`||r.type===`boolean`?t.push({name:n,type:`float`}):r.type===`color`&&t.push({name:n,type:`vec4`}));return t}function Yf(e){if(!e||typeof e!=`object`)throw Error(`shader must be an object.`);let t=e;if(t.layer!==void 0&&!Yd.includes(t.layer))throw Error(`shader.layer must be ${Yd.join(`, `)}.`);if(t.surfaces!==void 0&&typeof t.surfaces!=`boolean`)throw Error(`shader.surfaces must be a boolean.`);if(!Array.isArray(t.passes)||t.passes.length<1||t.passes.length>Vf.passes)throw Error(`shader.passes takes 1 to ${Vf.passes} passes.`);let n=new Set;for(let e of t.passes){if(!e||typeof e.glsl!=`string`||!e.glsl.trim())throw Error(`Each shader pass needs glsl source.`);if(e.glsl.length>Vf.source)throw Error(`A shader pass exceeds 64 KB of source.`);if(e.layer!==void 0&&!Yd.includes(e.layer))throw Error(`A pass layer must be ${Yd.join(`, `)}.`);if(e.sprites!==void 0){if(!Number.isSafeInteger(e.sprites)||e.sprites<1||e.sprites>Vf.sprites)throw Error(`sprites must be an integer from 1 to ${Vf.sprites}.`);if(Kf(t,e)===`filter`)throw Error(`Filter passes draw over the owner's box; they cannot draw sprites.`)}if(e.texel!==void 0){if(typeof e.texel!=`number`||!(e.texel>0&&e.texel<=Vf.texel))throw Error(`texel must be a number above 0 and up to ${Vf.texel}.`);if(e.sprites!==void 0||Kf(t,e)===`filter`)throw Error(`texel shades a pass over its box; sprite and filter passes cannot take it.`)}if(e.name!==void 0){if(typeof e.name!=`string`||!Uf.test(e.name))throw Error(`Invalid pass name: ${String(e.name)}`);if(n.has(e.name))throw Error(`Pass names must be unique: ${e.name}`);n.add(e.name)}if(e.enabled!==void 0&&typeof e.enabled!=`boolean`)throw Error(`A pass's enabled must be a boolean.`);if(e.enabled===!1&&e.name===void 0)throw Error(`A pass that starts off needs a name to turn it on.`);if(e.blend!==void 0&&!Xd.includes(e.blend))throw Error(`blend must be ${Xd.join(`, `)}.`)}Wf(t.uniforms);let r=t.state;if(r!==void 0){if(!r||typeof r.glsl!=`string`||!r.glsl.trim())throw Error(`shader.state needs glsl source.`);if(r.glsl.length>Vf.source)throw Error(`shader.state exceeds 64 KB of source.`);for(let e of[r.width,r.height])if(!Number.isSafeInteger(e)||e<1||e>Vf.stateEdge)throw Error(`shader.state width and height must be integers from 1 to ${Vf.stateEdge}.`);if(r.precision!==void 0&&r.precision!==`byte`&&r.precision!==`half`)throw Error(`shader.state.precision must be byte or half.`);let e=r.bounds;if(e!==void 0&&!(e&&[e.x,e.y].every(Number.isFinite)&&[e.width,e.height].every(e=>Number.isFinite(e)&&e>0)))throw Error(`shader.state.bounds must be { x, y, width, height } with a positive size.`)}}const Xf=new WeakMap;function Zf(e){let t=Xf.get(e);if(t===void 0){let n=JSON.stringify(e),r=2166136261,i=5381;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);r=Math.imul(r^t,16777619)>>>0,i=(Math.imul(i,33)^t)>>>0}t=`${n.length.toString(36)}.${r.toString(36)}.${i.toString(36)}`,Xf.set(e,t)}return t}function Qf(e){let t=tu(e);if(!t.ok)throw Error(t.diagnostics[0]?.message??`Invalid script item.`);return t.item}function $f(e,t){return ep(e,t)??Qf($u(e,t))}function ep(e,t){let n={...e};for(let r in t){let i=t[r];if(r===`position`){if(!i||typeof i!=`object`)return null;let{x:t=e.position.x,y:r=e.position.y,...a}=i;if(!Number.isFinite(t)||!Number.isFinite(r))return null;for(let e in a)return null;n.position={x:t,y:r};continue}if(r===`rotation`||r===`z`){if(!Number.isFinite(i))return null}else if(r===`opacity`){if(typeof i!=`number`||!(i>=0&&i<=1))return null}else if(r!==`visible`||typeof i!=`boolean`)return null;n[r]=i}return n}const tp=new Set([`position`,`size`,`rotation`,`scale`,`opacity`,`style`,`props`,`z`]),np=new Set([`default`,`pointer`,`grab`,`grabbing`,`crosshair`,`text`,`move`,`ew-resize`,`ns-resize`,`not-allowed`]),rp=new Set([`select`,`hand`,`text`,`shape`,`draw`,`arrow`,`frame`]);function ip(e){if(!e||typeof e!=`object`||!e.patches||!e.world||!e.screen||!e.hits||!Array.isArray(e.listens))throw Error(`Invalid script output.`);if(e.anchor){let{item:t,point:n}=e.anchor;if(typeof t!=`string`||!t||n&&![n.x,n.y].every(e=>Number.isFinite(e)&&e>=0&&e<=1))throw Error(`Invalid screen scene anchor.`)}if(e.shader!==void 0&&Yf(e.shader),e.frameRate!==void 0&&!(Number.isFinite(e.frameRate)&&e.frameRate>=1&&e.frameRate<=60))throw Error(`frameRate must be a number from 1 to 60.`);if(e.parameters){if(Object.keys(e.parameters).length>64)throw Error(`A script may declare at most 64 parameters.`);for(let t of Object.values(e.parameters)){if(!t||![`number`,`boolean`,`string`,`color`].includes(t.type))throw Error(`Invalid script parameter type.`);if(t.label!==void 0&&typeof t.label!=`string`)throw Error(`Invalid script parameter label.`);if([t.min,t.max,t.step].some(e=>e!==void 0&&!Number.isFinite(e)))throw Error(`Invalid script parameter range.`)}}if(Object.keys(e.world).some(t=>Object.hasOwn(e.screen,t)))throw Error(`Temporary item IDs must be unique across scenes.`);if(Object.keys(e.world).length+Object.keys(e.screen).length>1e3||Object.keys(e.hits).length>1e3)throw Error(`A script may create at most 1000 temporary items or hit regions.`);for(let t of Object.values(e.patches))if(!t||typeof t!=`object`||Object.keys(t).some(e=>!tp.has(e)))throw Error(`Scripts may only present ${[...tp].join(`, `)}.`);for(let t of Object.values(e.hits)){if(!t||typeof t!=`object`)throw Error(`Invalid script hit region.`);if(t.cursor&&!np.has(t.cursor))throw Error(`Invalid script cursor.`);if(t.tools!==void 0&&(!Array.isArray(t.tools)||t.tools.some(e=>!rp.has(e))))throw Error(`Invalid script hit tools.`);if(`target`in t){if(t.target!==`self`||`item`in t||`x`in t)throw Error(`Invalid script hit target.`)}else if(`item`in t){if(typeof t.item!=`string`||!(Object.hasOwn(e.world,t.item)||Object.hasOwn(e.screen,t.item))||`x`in t)throw Error(`Hit items must belong to the temporary scene.`)}else if(![t.x,t.y,t.width,t.height].every(Number.isFinite)||t.width<0||t.height<0)throw Error(`Invalid script hit region.`)}}function ap(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619)>>>0;return`~script-${t.toString(36)}-`}const op=new WeakMap,sp=new WeakMap;function cp(e,t){return Qd(e).map(({id:e})=>e).filter(e=>t.has(e))}function lp(e,t){let n=sp.get(e);n||(n=new Map,sp.set(e,n));let r=n.get(t);return r||(r=of(e,t),n.set(t,r)),r}function up(e,t,n,r,i){let a=new Map,o=new Map(Object.entries(i).map(([e,t])=>[e,Qf(t)])),s=0;for(let[i,c]of o){if(!/^[a-zA-Z0-9_-]{1,80}$/.test(i))throw Error(`Temporary IDs must be 1–80 letters, digits, underscores or hyphens.`);if(c.script)throw Error(`Temporary items cannot start scripts.`);if(c.parent&&!o.has(c.parent))throw Error(`Temporary parents must belong to the same scene.`);let l=c.parent,u=new Set([i]);for(;l;){if(u.has(l))throw Error(`Temporary parents must not form a cycle.`);u.add(l);let e=o.get(l);if(!e)throw Error(`Temporary parent is missing.`);if(e.type!==`frame`)throw Error(`Only frames can contain temporary items.`);l=e.parent}let d=`${n}${i}`;if(e.items[d])throw Error(`Temporary item ID conflicts with the document.`);let f={...c,parent:c.parent?`${n}${c.parent}`:r,z:c.z??s++};if(f.type===`arrow`){let e=e=>`item`in e&&o.has(e.item)?{...e,item:`${n}${e.item}`}:e;if([f.props.start,f.props.end].some(e=>`item`in e&&!o.has(e.item)&&!t.has(e.item)))continue;f.props={...f.props,start:e(f.props.start),end:e(f.props.end)}}a.set(d,f)}return{root:r,items:a}}function dp(e,t,n){let r=op.get(n);if(r?.document===e&&r.owner===t)return r;let i=lp(e,t);if(ip(n),$d(e,t)&&Object.values(n.hits).some(e=>!(`item`in e)))throw Error(`A Board script takes input only on its scene items.`);let a=new Map;for(let[t,r]of Object.entries(n.patches)){let n=e.items[t];n&&i.has(t)&&a.set(t,{base:n,item:$f(n,r)})}let o=ap(t),s={document:e,owner:t,world:up(e,i,o,`${o}~world`,n.world),screen:up(e,i,o,`${o}~screen`,n.screen),presented:a};return op.set(n,s),s}function fp(e,t,n,r=new Map,i,a,o){let s=new Map(r),c=new Map;if(n.size===0)return s;let l=cp(e,n);for(let[r,o]of l.entries()){let l=n.get(o);if(l)try{let n=new Map,a=dp(e,o,l);for(let[t,r]of a.presented){let i=s.get(t)??e.items[t];if(!i)continue;let o=r;o.base!==i&&(o={base:i,item:$f(i,l.patches[t]??{})},a.presented.set(t,o)),n.set(t,o.item)}let u=$d(e,o),d=n.get(o)??s.get(o)??e.items[o];if(u&&a.world.items.size){n.set(a.world.root,Qf({type:`frame`,size:{width:1,height:1},z:1e8+r,props:{decoration:`none`,clip:!1}}));for(let[e,t]of a.world.items)n.set(e,t)}else if(d&&a.world.items.size){let e=t.layout.box(o);n.set(a.world.root,Qf({type:`frame`,parent:d.parent,position:d.position,rotation:d.rotation,scale:d.scale,origin:d.origin,opacity:d.opacity,size:{width:Math.max(1,e.width),height:Math.max(1,e.height)},z:(d.z??0)+.001,props:{decoration:`none`,clip:!1}}));for(let[e,t]of a.world.items)n.set(e,t)}if(i&&a.screen.items.size){n.set(a.screen.root,Qf({type:`frame`,position:{x:0,y:0},scale:1/i.zoom,origin:{x:0,y:0},size:{width:1,height:1},z:1e9+r,props:{decoration:`none`,clip:!1}}));for(let[e,t]of a.screen.items)n.set(e,t);c.set(o,a.screen.root)}for(let[e,t]of n)s.set(e,t)}catch(e){if(!a)throw e;a(o,e)}}if(c.size){let t=o??Bu(t=>s.get(t)??e.items[t]);for(let[r,a]of c){let o=s.get(a),c=n.get(r)?.anchor;if(!c&&$d(e,r)){o&&s.set(a,{...o,position:{x:-(i?.x??0)/(i?.zoom??1),y:-(i?.y??0)/(i?.zoom??1)}});continue}let l=c?.item??r,u=!!e.items[l]&&lp(e,r).has(l),d=u?t.box(l):{width:0,height:0};o&&s.set(a,{...o,opacity:u?o.opacity:0,position:u?Su(t.matrix(l),{x:(c?.point?.x??0)*d.width,y:(c?.point?.y??0)*d.height}):o.position})}}return s}function pp(e,t,n){let r=`item`in n?`${ap(t)}${n.item}`:t,i=e.get(r);if(!i||e.opacity(r)<=0)return null;let a=e.layout.box(r);return{id:r,item:i,rect:`x`in n?n:{x:0,y:0,width:a.width,height:a.height}}}function mp(e,t,n,r){let{x:i,y:a,width:o,height:s}=t.rect;if(o<=0||s<=0)return!1;let c=e.layout.matrix(t.id),l=[Su(c,{x:i,y:a}),Su(c,{x:i+o,y:a}),Su(c,{x:i,y:a+s}),Su(c,{x:i+o,y:a+s})],u=l.map(e=>e.x*n.zoom+n.x),d=l.map(e=>e.y*n.zoom+n.y);return Math.max(...u)>0&&Math.min(...u)<r.width&&Math.max(...d)>0&&Math.min(...d)<r.height}const hp=e=>e;function gp(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i;return e=>{if(e<=0)return 0;if(e>=1)return 1;let t=e;for(let n=0;n<8;n+=1){let n=u(t)-e;if(Math.abs(n)<1e-6)return d(t);let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;t=e;for(let i=0;i<32;i+=1){let i=u(t);if(Math.abs(i-e)<1e-6)break;i<e?n=t:r=t,t=(n+r)/2}return d(t)}}function _p(e,t){let n=t===`jump-none`?e-1:t===`jump-both`?e+1:e,r=t===`start`||t===`jump-start`||t===`jump-both`;return t=>{if(t>=1)return 1;let i=Math.floor(t*e)+ +!!r;return Math.min(1,Math.max(0,i/Math.max(1,n)))}}const vp={linear:hp,ease:gp(.25,.1,.25,1),"ease-in":gp(.42,0,1,1),"ease-out":gp(0,0,.58,1),"ease-in-out":gp(.42,0,.58,1),"step-start":_p(1,`start`),"step-end":_p(1,`end`)},yp=new Map;function bp(e){if(!e)return hp;let t=e.trim(),n=vp[t];if(n)return n;let r=yp.get(t);if(r)return r;let i=hp,a=/^cubic-bezier\(([^)]+)\)$/.exec(t),o=/^steps\(\s*(\d+)\s*(?:,\s*([a-z-]+)\s*)?\)$/.exec(t);if(a?.[1]){let[e=0,t=0,n=1,r=1]=a[1].split(`,`).map(Number);i=gp(e,t,n,r)}else o?.[1]&&(i=_p(Number(o[1]),o[2]??`end`));return yp.size>512&&yp.clear(),yp.set(t,i),i}function xp(e,t){let n=Math.max(0,t-e.delay);return e.loop||e.play===`always`?e.duration>0?n%e.duration:0:n<=e.duration?n:e.end===`reset`?null:e.duration}function Sp(e){let t=e.keyframes.map(e=>e.value);return t.every(e=>typeof e==`number`)?`number`:t.every(e=>Kc.safeParse(e).success)?`color`:`discrete`}function Cp(e,t,n,r){let i=ld(r,n.property);if(!i.ok)return null;let a=r===`script`||n.property.startsWith(`script.params.`)?Sp(n):i.spec.kind,o=new Float64Array(n.keyframes.length),s=[],c=[];return n.keyframes.forEach((e,t)=>{o[t]=e.at,s.push(e.value),c.push(bp(e.ease))}),{id:t,animationId:e,target:n.target,property:n.property,path:n.property.split(`.`),kind:a,multiplicative:!!i.spec.multiplicative,composite:n.composite,spline:n.interpolation===`spline`&&a===`vec2`,step:n.interpolation===`step`||a===`discrete`,orient:!!n.orient&&a===`vec2`&&n.property===`position`,times:o,values:s,eases:c,start:o[0]??0}}function wp(e){let t=new Map;for(let[n,r]of Object.entries(e.animations))t.set(n,Tp(n,r,e));let n=new Map([...t.keys()].map(e=>[e,0]));for(let e of t.values())for(let t of e.children)n.set(t.target,(n.get(t.target)??0)+1);let r=[...t.keys()].filter(e=>n.get(e)===0).sort();for(let e=0;e<r.length;e+=1){let i=t.get(r[e]);for(let e of i?.children??[]){let t=(n.get(e.target)??1)-1;n.set(e.target,t),t===0&&r.push(e.target)}}if(r.length!==t.size)throw Error(`Animation graph contains a cycle`);return{animations:t,document:e,order:r}}function Tp(e,t,n){let{tracks:r,...i}=t,a=[],o=[];for(let[t,i]of Object.entries(r).sort(([e],[t])=>e<t?-1:+(e>t))){let r=i.target===`camera`?Pc:n.animations[i.target]?`animation`:n.board.scripts?.[i.target]?`script`:n.items[i.target]?.type;if(!r)continue;let s=Cp(e,t,i,r);s&&(r===`animation`?o:a).push(s)}return{id:e,header:i,tracks:a,children:o}}function Ep(e,t){let n=0,r=e.length-1;if(t<e[0])return-1;if(t>=e[r])return r;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n}function Dp(e){return!!e&&typeof e==`object`&&typeof e.x==`number`&&typeof e.y==`number`}function Op(e){return typeof e==`number`?{x:e,y:e}:Dp(e)?e:{x:0,y:0}}const kp=(e,t,n)=>e+(t-e)*n;function Ap(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function jp(e){return`#${Math.max(0,Math.min(16777215,Math.round(e))).toString(16).padStart(6,`0`)}`}function Mp(e,t,n,r){let i=r(e),a=r(t);if(i===null||a===null)return n<1?e:t;let o=typeof i==`number`?{color:i,alpha:1}:i,s=typeof a==`number`?{color:a,alpha:1}:a,c=kp(o.alpha,s.alpha,n),l=e=>c>0?Math.round(kp((o.color>>e&255)*o.alpha,(s.color>>e&255)*s.alpha,n)/c):0,u=jp(l(16)<<16|l(8)<<8|l(0));return c>=1?u:`${u}${Math.round(Math.max(0,c)*255).toString(16).padStart(2,`0`)}`}function Np(e){if(typeof e!=`string`)return null;let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t?.[1])return null;let n=t[1].length===3?[...t[1]].map(e=>e+e).join(``):t[1];return Number.parseInt(n,16)}function Pp(e){if(typeof e==`string`){if(e.trim().toLowerCase()===`transparent`)return{color:0,alpha:0};let t=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(e.trim());if(t?.[1]){let e=t[1].length===4?[...t[1]].map(e=>e+e).join(``):t[1];return{color:Number.parseInt(e.slice(0,6),16),alpha:Number.parseInt(e.slice(6),16)/255}}}return Np(e)}function Fp(e,t,n,r){let{times:i,values:a}=e,o=a[t],s=a[t+1],c=i[t],l=i[t+1];if(s===void 0||l<=c)return o;let u=e.eases[t+1]((n-c)/(l-c));if(e.step)return u>=1?s:o;switch(e.kind){case`number`:return typeof o==`number`&&typeof s==`number`?kp(o,s,u):o;case`vec2`:case`scale`:{if(e.kind===`scale`&&typeof o==`number`&&typeof s==`number`)return kp(o,s,u);let n=Op(o),r=Op(s);if(e.spline){let e=Op(a[t-1]??o),i=Op(a[t+2]??s);return{x:Ap(e.x,n.x,r.x,i.x,u),y:Ap(e.y,n.y,r.y,i.y,u)}}return{x:kp(n.x,r.x,u),y:kp(n.y,r.y,u)}}case`color`:return Mp(o,s,u,r);default:return u>=1?s:o}}function Ip(e,t,n=Pp){let r=Ep(e.times,t);return r<0?e.values[0]:Fp(e,r,t,n)}function Lp(e,t,n){let r=Math.max(1,(e.times[e.times.length-1]-e.start)/1e3),i=Op(Ip(e,Math.max(e.start,t-r),n)),a=Op(Ip(e,t+r,n));return Math.hypot(a.x-i.x,a.y-i.y)<1e-6?null:Math.atan2(a.y-i.y,a.x-i.x)*180/Math.PI}function Rp(e,t){let n=e;for(let e of t){if(typeof n==`number`&&(e===`x`||e===`y`))return n;if(!n||typeof n!=`object`)return;n=n[e]}return n}function zp(e,t,n,r=0){let i=t[r];if(r===t.length-1)return{...e,[i]:n};let a=e[i];typeof a==`number`&&(a={x:a,y:a});let o=a&&typeof a==`object`?a:{};return{...e,[i]:zp(o,t,n,r+1)}}function Bp(e,t,n){if(e.composite!==`add`)return n;if(e.kind===`number`)return typeof t!=`number`||typeof n!=`number`?n:e.multiplicative?t*n:t+n;if(e.kind===`vec2`||e.kind===`scale`){if(e.multiplicative){if(typeof t==`number`&&typeof n==`number`)return t*n;let e=Op(t??1),r=Op(n);return{x:e.x*r.x,y:e.y*r.y}}let r=Op(t),i=Op(n);return{x:r.x+i.x,y:r.y+i.y}}return n}function Vp(e,t,n,r){let i=t-e.start,a=r-n.start;if(i>=0!=a>=0)return i>=0;let o=Math.abs(i),s=Math.abs(a);return o===s?e.id>n.id:o<s}function Hp(e,t,n={}){let r=n.resolveColor??Pp,i=new Map(t instanceof Map?t:Object.entries(t)),a=new Map;for(let t of e.order){let n=e.animations.get(t),o=i.get(t);if(!(!n||o===void 0))for(let e of n.children){let n=Ip(e,o,r);typeof n==`number`&&(i.set(e.target,Math.max(0,n)),a.set(e.target,t))}}let o=new Map;for(let[t,n]of i){let r=e.animations.get(t);if(r)for(let e of r.tracks){let r=`${e.target}\u0000${e.property}`,i=o.get(r);if(i||(i={target:e.target,path:e.path,winnerTime:0,adds:[]},o.set(r,i)),e.composite===`add`){i.adds.push([e,n]),i.source??=t;continue}(!i.winner||Vp(e,n,i.winner,i.winnerTime))&&(i.winner=e,i.winnerTime=n,i.source=t)}}let s=new Map,c=new Map,l={},u,d=[...o.values()].sort((e,t)=>e.path.length-t.path.length);for(let t of d){let n=t.target===Pc,i=n?void 0:e.document.board.scripts?.[t.target],a=n||i||t.path[0]!==`script`?void 0:e.document.items[t.target]?.script,o=i||a?c.get(t.target)??i??a:void 0;if(t.path[0]===`script`&&!a)continue;let d=a?t.path.slice(1):t.path,f=n||o?void 0:s.get(t.target)??e.document.items[t.target];if(!n&&!o&&!f)continue;let p=n?l[d[0]]:Rp(o??f,d),m=null;t.winner&&(p=Ip(t.winner,t.winnerTime,r),t.winner.orient&&(m=[t.winner,t.winnerTime]));for(let[e,n]of t.adds)p=Bp(e,p,Ip(e,n,r)),e.orient&&!m&&(m=[e,n]);if(n){l[t.path[0]]=p,u??=t.source;continue}if(o){c.set(t.target,zp(o,d,p));continue}let h=zp(f,t.path,p);if(m){let e=Lp(m[0],m[1],r);e!==null&&(h={...h,rotation:f.rotation+e})}s.set(t.target,h)}let f,p=new Set;for(let t=u;t&&!f&&!p.has(t);t=a.get(t))p.add(t),f=e.document.animations[t]?.viewport;return{items:s,scripts:c,camera:l,cameraViewport:f,times:i}}const Up=1e3/30;function Wp(e){let t=[];for(let n of Object.values(e.board.scripts??{}))t.push(n.params);for(let n of Object.values(e.items))n.script&&t.push(n.script.params);return JSON.stringify(t)}function Gp(e){return Object.values(e.animations).some(e=>Object.values(e.tracks).some(e=>/^(script\.)?params\./.test(e.property)))}function Kp(e,t){if(t.size===0)return e;let n=e.board.scripts,r=e.board,i=e.items;for(let[a,o]of t){let t=n?.[a];if(t){r===e.board&&(r={...r,scripts:{...n}}),r.scripts[a]={...t,params:o.params};continue}let s=i[a];s?.script&&(i===e.items&&(i={...i}),i[a]={...s,script:{...s.script,params:o.params}})}return r===e.board&&i===e.items?e:{...e,board:r,items:i}}function qp(e,t){let n=Kp(e,t.scripts);if(t.items.size===0)return n;let r={...n.items};for(let[i,a]of t.items){let t=n.items[i]?.script;r[i]=t&&t!==e.items[i]?.script?{...a,script:t}:a}return{...n,items:r}}function Jp(e){let t=new Map;for(let[n,r]of Object.entries(e)){let i=r.parent&&e[r.parent]&&r.parent!==n?r.parent:``,a=t.get(i)??[];a.push(n),t.set(i,a)}let n=(t,n)=>(e[t]?.z??0)-(e[n]?.z??0)||(t<n?-1:+(t>n));for(let e of t.values())e.sort(n);let r=[],i=new Set,a=e=>{if(!i.has(e)){i.add(e),r.push(e);for(let n of t.get(e)??[])a(n)}};for(let e of t.get(``)??[])a(e);for(let t of Object.keys(e))a(t);return r}function Yp(e,t){let n=e.items,r=new Map,i=new Map;for(let[e,t]of Object.entries(n)){let a=t.parent&&n[t.parent]?t.parent:``,o=r.get(a)??[];o.push(e),r.set(a,o);for(let n of Ru(t))i.set(n,[...i.get(n)??[],e])}let a=Bu(e=>n[e],e=>[...r.get(e)??[],...i.get(e)??[]]),o=new Map,s=(e,r=0)=>{let i=o.get(e);if(i!==void 0)return i;let a=n[e],c=t?.get(e),l=!!(a&&c&&Qp(c)===a)&&r<64;if(l&&a?.parent&&n[a.parent]&&(l=s(a.parent,r+1)),l&&a)for(let e of Ru(a))n[e]&&!s(e,r+1)&&(l=!1);return o.set(e,l),l},c=Jp(n),l=[],u=new Map,d=new Map;for(let e of c){let r=n[e],i=(s(e)?t?.get(e):void 0)??$p(e,r,a);d.set(e,l.length),l.push(i),u.set(e,i)}return{items:l,get:e=>u.get(e),indexOf:e=>d.get(e)??-1,layout:a,children:e=>r.get(e??``)??[],descendants:e=>{let t=[],n=new Set([e]),i=[...r.get(e)??[]];for(;i.length;){let e=i.pop();n.has(e)||(n.add(e),t.push(e),i.push(...r.get(e)??[]))}return t},binders:e=>i.get(e)??[],opacity:e=>Xp(e=>n[e],e),shown:e=>Xp(e=>n[e],e,!0)>0}}function Xp(e,t,n=!1){let r=1,i=t;for(let t=0;i&&t<64;t+=1){let t=e(i);if(!t)break;if(t.visible===!1)return 0;n||(r*=t.opacity),i=t.parent}return r}const Zp=new WeakMap;function Qp(e){return Zp.get(e)}function $p(e,t,n){let r={...t,id:e,frame:n.frame(e)};return Zp.set(r,t),r}function em(e,t,n={}){let r=t?e.animations[t]:void 0;if(t&&!r)throw Error(`Animation ${t} does not exist.`);let i=wp(e),a=new Map,o=new Map;function s(a){let o=new Map;for(let[e,t]of i.animations)t.header.play===`always`&&o.set(e,xp(t.header,a)??0);t&&r&&o.set(t,Math.min(a,r.duration));let s=Hp(i,o,n);return{document:qp(e,s),evaluation:s}}function c(e){if(!Number.isFinite(e)||e<0)throw Error(`Animation time must be finite and non-negative.`);let t=a.get(e);if(!t){t=s(e);let n=a.keys().next().value;a.size>=64&&n!==void 0&&a.delete(n),a.set(e,t)}return t}let l;return{frameAt(e,t){let n=`${t}:${e}`;if(o.has(n))return o.get(n);let r=c(t).document,i={},a=[e];for(;a.length;){let e=a.pop();if(!e||i[e])continue;let t=r.items[e];t&&(i[e]=t,t.parent&&a.push(t.parent),a.push(...Ru(t)))}let s=Yp({...r,items:i}).get(e)?.frame;return o.size>=2048&&o.clear(),o.set(n,s),s},at(e){if(l?.time===e)return l.value;let t=c(e),n,r={...t,get scene(){return n??=Yp(t.document),n}};return l={time:e,value:r},r}}}function tm(e,t=xc){return Math.min(e.width/t.width,e.height/t.height)}function nm(e,t,n,r,i={x:0,y:0,zoom:1},a=xc){let o=tm(n,a);if(!(o>0)||Object.keys(e).length===0)return i;let s=(n.width-a.width*o)/2,c=(n.height-a.height*o)/2,l={x:(i.x-s)/o,y:(i.y-c)/o,zoom:i.zoom/o},u=e.focus===void 0?l:Bf(e.focus,t,a,{padding:48})??l;return e.zoom!==void 0&&(u={...u,zoom:e.zoom}),e.center&&(u=Lf({centerX:e.center.x,centerY:e.center.y,zoom:u.zoom},a)),e.shake&&(u={...u,x:u.x+Math.sin(r/1e3*91.3)*e.shake,y:u.y+Math.cos(r/1e3*77.9)*e.shake}),{x:u.x*o+s,y:u.y*o+c,zoom:u.zoom*o}}const rm=.5,im={top:V(0,-1),right:V(1,0),bottom:V(0,1),left:V(-1,0)};function am(e,t){if(!t)return e;let n=t*Math.PI/180,r=Math.cos(n),i=Math.sin(n);return V(e.x*r-e.y*i,e.x*i+e.y*r)}function om(e,t){let n=[[`left`,e],[`right`,1-e],[`top`,t],[`bottom`,1-t]];return n.sort((e,t)=>e[1]-t[1]),n[0]?.[0]??`right`}function sm(e){return V(e.x+e.width/2,e.y+e.height/2)}function cm(e,t,n,r=4){let i,a;e===`auto`?(i=Gu(t,n),a=Ku(i,.5)):`side`in e?(i=e.side,a=Ku(i,e.offset)):(a=e,i=om(e.x,e.y));let o=Wu(t,a.x,a.y),s=am(im[i],t.rotation);return{point:V(o.x+s.x*r,o.y+s.y*r),normal:s}}function lm(e,t){let n=Su(e,t);return V(n.x,n.y)}function um(e,t,n,r){let i=lm(n,{x:0,y:0}),a=(()=>{if(!Lu(t))return lm(n,t);let e=r(t.item);return e?sm(e):i})();if(Lu(e)){let t=r(e.item);if(t)return{...cm(e.anchor,t,a),item:e.item}}let o=Lu(e)?i:lm(n,e),s=o.x-a.x,c=o.y-a.y,l=Math.hypot(s,c)||1;return{point:o,normal:V(s/l,c/l)}}function dm(e,t,n){let r=[];for(let i=0;i<=20;i+=1){let a=i/20,o=1-a;r.push(V(o*o*e.x+2*o*a*t.x+a*a*n.x,o*o*e.y+2*o*a*t.y+a*a*n.y))}return r}function fm(e,t){let n=Math.abs(e.normal.x)>Math.abs(e.normal.y),r=Math.abs(t.normal.x)>Math.abs(t.normal.y),i=e.point,a=t.point;if(n&&r){let e=i.x+(a.x-i.x)*rm;return[i,V(e,i.y),V(e,a.y),a]}if(!n&&!r){let e=i.y+(a.y-i.y)*rm;return[i,V(i.x,e),V(a.x,e),a]}return n?[i,V(a.x,i.y),a]:[i,V(i.x,a.y),a]}function pm(e,t,n){if(n)return zu(e.point,t.point,n);let r=V((e.point.x+t.point.x)/2,(e.point.y+t.point.y)/2),i=[e,t].filter(e=>e.item).map(e=>e.normal);if(!i.length)return r;let a=i.reduce((e,t)=>e+t.x,0)/i.length,o=i.reduce((e,t)=>e+t.y,0)/i.length,s=Math.hypot(a,o);if(s<1e-4)return r;let c=Math.hypot(t.point.x-e.point.x,t.point.y-e.point.y),l=Math.min(c*.18,96);return V(r.x+a/s*l,r.y+o/s*l)}function mm(e){let t=Math.max(Math.min(e.width,e.height)*.45,24),n=e.x+e.width+4,r=e.y-4,i=e.y+e.height*.3,a=e.x+e.width*.7;return[V(a,r),V(a,r-t),V(n+t,r-t),V(n+t,i),V(n,i)]}function hm(e,t,n){let{props:r}=e;if(Lu(r.start)&&Lu(r.end)&&r.start.item===r.end.item){let e=n(r.start.item);if(e){let t=mm(e),n=t[0],i=t[t.length-1];return{start:{point:n,normal:V(0,-1),item:r.start.item},end:{point:i,normal:V(1,0),item:r.end.item},path:t,mid:t[2]}}}let i=um(r.start,r.end,t,n),a=um(r.end,r.start,t,n),o;return o=r.waypoints.length?[i.point,...r.waypoints.map(e=>lm(t,e)),a.point]:r.route===`orthogonal`?fm(i,a):r.route===`straight`&&!r.bend?[i.point,a.point]:dm(i.point,pm(i,a,r.bend),a.point),{start:i,end:a,path:o,mid:bm(o)}}function gm(e,t){let n=e=>t.get(e)?.frame,r=t.layout.matrix(e.id),i=ym(e,r,n),a=_m.get(e);if(a&&a.key===i)return a.resolved;let o=hm(e,r,n);return _m.set(e,{key:i,resolved:o}),o}const _m=new WeakMap;function vm(e){return e?`${e.x},${e.y},${e.width},${e.height},${e.rotation}`:`-`}function ym(e,t,n){let{start:r,end:i}=e.props;return`${t.join(`,`)}|${Lu(r)?vm(n(r.item)):``}|${Lu(i)?vm(n(i.item)):``}`}function bm(e){if(e.length===0)return V(0,0);if(e.length===1)return e[0];let t=0;for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];t+=Math.hypot(i.x-r.x,i.y-r.y)}let n=0,r=t/2;for(let t=0;t<e.length-1;t+=1){let i=e[t],a=e[t+1],o=Math.hypot(a.x-i.x,a.y-i.y);if(n+o>=r){let e=o>0?(r-n)/o:0;return V(i.x+(a.x-i.x)*e,i.y+(a.y-i.y)*e)}n+=o}return e[e.length-1]}function xm(e,t){if(e.length<2)return e[0]??V(0,0);let n=[],r=0;for(let t=0;t<e.length-1;t+=1){let i=e[t],a=e[t+1],o=Math.hypot(a.x-i.x,a.y-i.y);n.push(o),r+=o}let i=Math.min(1,Math.max(0,t))*r;for(let t=0;t<n.length;t+=1){let r=n[t];if(i<=r){let n=e[t],a=e[t+1],o=r>0?i/r:0;return V(n.x+(a.x-n.x)*o,n.y+(a.y-n.y)*o)}i-=r}return e[e.length-1]}function Sm(e,t=bc){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of e.path)n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x),a=Math.max(a,t.y);let o=Math.max(8,t*2);return{x:n-o,y:r-o,width:Math.max(1,i-n+o*2),height:Math.max(1,a-r+o*2)}}const{PI:Cm}=Math;Cm+1e-4;const{min:wm}=Math,Tm=Pu,Em=Fu;function Dm(e,t){if(t===void 0||t>=1)return e;if(t<=0)return[];if(e.length<2)return e;let n=0;for(let t=1;t<e.length;t+=1){let r=e[t-1],i=e[t];n+=Math.hypot(i.x-r.x,i.y-r.y)}let r=n*t,i=[e[0]];for(let t=1;t<e.length;t+=1){let n=e[t-1],a=e[t],o=Math.hypot(a.x-n.x,a.y-n.y);if(o>=r){let e=o>0?r/o:0;return i.push({x:n.x+(a.x-n.x)*e,y:n.y+(a.y-n.y)*e,p:n.p+(a.p-n.p)*e}),i}i.push(a),r-=o}return i}function Om(e,t){if(t===0||t===e.length-1)return!0;let n=e[t-1],r=e[t],i=e[t+1];if(!n||!r||!i)return!1;let a=r.x-n.x,o=r.y-n.y,s=i.x-r.x,c=i.y-r.y,l=Math.hypot(a,o),u=Math.hypot(s,c);return l<1e-6||u<1e-6||(a*s+o*c)/(l*u)<.92}function km(e,t){let n=e[t],r=e[t+1];if(!n||!r)return null;let i=Math.hypot(r.x-n.x,r.y-n.y);return i<1e-6?null:{x:-(r.y-n.y)/i,y:(r.x-n.x)/i}}function Am(e,t,n){if(Om(e,t))return n;let r=km(e,t-1),i=km(e,t);if(!r||!i)return n;let a=r.x+i.x,o=r.y+i.y,s=Math.hypot(a,o);if(s<1e-6)return n;let c=1/Math.max(.5,(a*n.x+o*n.y)/s);return{x:a/s*c,y:o/s*c}}function jm(e){let t=new Float32Array(1664),n=new Float32Array(832),r=new Uint32Array(1920),i=new Float64Array(64),a=new Uint32Array(128),o=null,s=0,c=0,l=0;function u(e,t){if(e.length>=t)return e;let n=new e.constructor(Math.max(t,e.length*2));return n.set(e),n}function d(e,r,i){return t[c*2]=e,t[c*2+1]=r,n[c]=i,c++}function f(e,t,n){r[l++]=e,r[l++]=t,r[l++]=n}function p(a,o){t=u(t,(c+13)*2),n=u(n,c+13),r=u(r,l+30);let s=a[o],p=i[o]??0,m=Tm(e,s.p);if(Om(a,o)){let e=d(s.x,s.y,p);for(let e=0;e<8;e+=1){let t=e/8*Math.PI*2;d(s.x+Math.cos(t)*m,s.y+Math.sin(t)*m,p)}for(let t=0;t<8;t+=1)f(e,e+1+t,e+1+(t+1)%8)}let h=a[o+1],g=km(a,o);if(!h||!g)return;let _=Am(a,o,g),v=Am(a,o+1,g),y=i[o+1]??p,b=Tm(e,h.p),x=d(s.x+_.x*m,s.y+_.y*m,p),S=d(s.x-_.x*m,s.y-_.y*m,p),C=d(h.x+v.x*b,h.y+v.y*b,y),w=d(h.x-v.x*b,h.y-v.y*b,y);f(x,S,C),f(S,w,C)}return{build(e){let d=e.length,f=e===o&&d>=s?Math.max(0,s-2):0;o=e,s=d,i=u(i,d),a=u(a,d*2),c=f>0?a[f*2]:0,l=f>0?a[f*2+1]:0;for(let t=f;t<d;t+=1){let n=e[t-1],r=e[t];i[t]=n?i[t-1]+Math.hypot(r.x-n.x,r.y-n.y):0}for(let t=f;t<d;t+=1)a[t*2]=c,a[t*2+1]=l,p(e,t);return{positions:t.subarray(0,c*2),indices:r.subarray(0,l),distances:n.subarray(0,c),length:d?i[d-1]:0}}}}const Mm=[192,384,768,1536];function Nm(e){return Mm.find(t=>t>=e)??1536}function Pm(e){if(!/^[a-z][a-z\d+.-]*:/i.test(e))return e.split(`/`).filter(Boolean).pop()||e;try{let t=new URL(e),n=t.pathname.split(`/`).filter(Boolean).pop()||t.hostname;try{return decodeURIComponent(n)}catch{return n}}catch{return e.split(`/`).filter(Boolean).pop()||e}}function Fm(e,t){let n=tl(e);return n?qd(n.kind===`url`?n.value.split(/[?#]/,1)[0]??``:n.value,t):null}function Im(e){return e?.type===`file`&&Fm(e.props.src,e.props.snapshot?.mimeType)!==null}function Lm(e){if(e.type===`image`){let t=tl(e.props.src);return t?`${t.kind}:${t.value}`:null}if(e.type===`file`){let t=e.props.snapshot;return t?.coverUrl?`url:${t.coverUrl}`:t?.coverPath?`file:${t.coverPath}`:null}if(e.type===`task`){let t=vu(_u(e.props.snapshot.artifacts));return t?`url:${t}`:null}let t=ql(e)?.cover,n=t?tl(t):null;return n?`${n.kind}:${n.value}`:null}const Rm=[`video`,`model`];function zm(e,t,n){return t?t.kind===`url`?`${e}-url:${encodeURIComponent(t.value)}`:`${e}:${encodeURIComponent(t.value)}:${n??`unknown`}`:null}function Bm(e){let t=_u(e.props.snapshot.artifacts),n=vu(t);return n?`url:${n}`:t?.type===`video`?zm(`video`,{kind:`url`,value:t.url},void 0):null}function Vm(e){let t=e.type===`task`?_u(e.props.snapshot.artifacts):e.type===`image`||e.type===`video`?e.props.snapshot:null;return t&&`naturalWidth`in t&&t.naturalWidth&&t.naturalHeight?{width:t.naturalWidth,height:t.naturalHeight}:null}function Hm(e){return e.type===`task`?Bm(e):e.type===`video`?zm(`video`,tl(e.props.src),e.props.snapshot?.mtimeMs):e.type===`file`&&Im(e)?zm(`model`,tl(e.props.src),e.props.snapshot?.mtimeMs):Lm(e)}function Um(e){let t=e;if(e.startsWith(`local:`)){let n=e.indexOf(`:`,6);if(n<0)return null;t=e.slice(n+1)}if(!t.startsWith(`cover:`))return Wm(t);let n=Wm(t.slice(6));return n?.media===`image`?{...n,fit:`cover`}:null}function Wm(e){try{for(let t of Rm){if(e.startsWith(`${t}-url:`))return{kind:`url`,media:t,value:decodeURIComponent(e.slice(t.length+5))};if(e.startsWith(`${t}:`)){let n=e.lastIndexOf(`:`);return n>t.length?{kind:`file`,media:t,value:decodeURIComponent(e.slice(t.length+1,n))}:null}}}catch{return null}return e.startsWith(`file:`)?{kind:`file`,media:`image`,value:e.slice(5)}:e.startsWith(`url:`)?{kind:`url`,media:`image`,value:e.slice(4)}:null}function Gm(e,t){let n=e.type===`image`?e.props.crop:void 0;return Math.max(e.frame.width/(n?.w||1),e.frame.height/(n?.h||1))*t}function Km(e,t){let n=Gm(e,t);return n<=64?64:n>1536?1/0:Nm(n)}const qm=256*1024**2;function Jm(e,t){let n=e.type===`image`?e.props.crop:void 0,r=Gm(e,t),i=Km(e,t),a=Number.isFinite(i)&&r>0?i/r:1,o=Math.ceil(e.frame.width/(n?.w||1)*t*a),s=Math.ceil(e.frame.height/(n?.h||1)*t*a),c=Vm(e);return Math.min(o*s,c?c.width*c.height:1/0)*4}function Ym(e,t,n){let r=n.maxBytes??qm,i=new Map;for(let r of e){let e=t(r);if(!e)continue;let a=Jm(r,n.scale);a>(i.get(e)?.need??-1)&&i.set(e,{item:r,need:a})}let a={items:[],keys:[],omittedKeys:[]},o=0;for(let[e,{item:t,need:n}]of i){if(o+n>r){a.omittedKeys.push(e);continue}o+=n,a.keys.push(e),a.items.push(t)}return a}function Xm(e){let t=Cd(e,{keepUnknown:!0});if(!t.ok)throw Error(`Invalid Board document: ${t.diagnostics.map(e=>`${e.path}: ${e.message}`).join(`; `)}`);return t.document}function Zm(e,t){let n=Ff(e.type===`arrow`?Sm(gm(e,t),e.style.strokeWidth):If(e.frame),e.style),r=e.parent;for(let e=0;r&&n&&e<64;e+=1){let e=t.get(r);if(e?.type!==`frame`)break;e.props.clip!==!1&&(n=Qm(n,If(e.frame))),n&&=Ff(n,e.style),r=e.parent}return n}function Qm(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i>n&&a>r?{x:n,y:r,width:i-n,height:a-r}:null}function $m(e,t){let n=new Map,r=t=>(n.has(t.id)||n.set(t.id,Zm(t,e)),n.get(t.id)??null),i=(e,t)=>{if(e.type===`effect`&&e.props.kind===`trail`&&e.props.follow)return!0;let n=r(e);return n!==null&&Mf(n,t)},a=e=>Nf(e.flatMap(e=>r(e)??[]));switch(t.kind){case`all`:return{items:[...e.items],rect:a(e.items),padding:null};case`items`:{let n=new Set(t.ids.flatMap(t=>e.get(t)?[t,...e.descendants(t)]:[]));for(let t of[...n])for(let r of e.binders(t)){let t=e.get(r);t&&Ru(t).every(e=>n.has(e))&&n.add(r)}let r=e.items.filter(e=>n.has(e.id));return{items:r,rect:a(r),padding:null}}case`frame`:{let n=e.get(t.id);if(!n)return{items:[],rect:null,padding:null};let r=If(n.frame);return{items:e.items.filter(e=>e.id===t.id||i(e,r)),rect:r,padding:0,page:t.id}}case`rect`:{let n=t.rect;return{items:e.items.filter(e=>i(e,n)),rect:n,padding:0}}}}function eh(e,t,n,r){let i=Math.min(n/t.width,n/t.height),a=Math.sqrt(r/(t.width*t.height));return Math.min(e,i,a)}function th(e){let{region:t,scale:n=2,maxEdge:r=8192,maxPixels:i=32e6}=e,a=$m(e.scene,t);if(!a.rect)return null;let o=e.padding??a.padding??32,s={x:a.rect.x-o,y:a.rect.y-o,width:Math.max(1,a.rect.width+o*2),height:Math.max(1,a.rect.height+o*2)},c=Number.isFinite(n)&&n>0?n:2,l=eh(c,s,r,i);return{world:s,scale:l,requestedScale:n,width:Math.max(1,Math.floor(s.width*l)),height:Math.max(1,Math.floor(s.height*l)),items:a.items,clamped:l<c-1e-6,...a.page?{page:a.page}:{}}}function nh(e){let{world:t,scale:n,width:r,height:i}=e;return{camera:{x:-t.x*n,y:-t.y*n,zoom:n},width:r,height:i,safeRect:{x:0,y:0,width:r,height:i}}}const rh=new Set([`md`,`mdx`,`markdown`,`txt`,`rst`,`adoc`,`org`]),ih=new Set([`json`,`jsonc`,`jsonl`,`yaml`,`yml`,`toml`,`csv`,`tsv`,`xml`,`ndjson`]),ah=new Set(`ts.tsx.js.jsx.mjs.cjs.py.go.rs.java.kt.swift.rb.php.c.h.hh.hpp.cpp.cc.cs.scala.lua.sh.bash.zsh.fish.vue.svelte.css.scss.less.html.htm.sql.graphql.proto.zig.dart.r`.split(`.`)),oh=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`,`bmp`,`ico`,`mp4`,`webm`,`mov`,`m4v`,`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`pdf`,`zip`,`gz`,`tgz`]);function sh(e){let t=uh(e),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}function ch(e){return e?e.split(`;`)[0]?.trim().toLowerCase()??``:``}function lh(e,t){let n=ch(t);if(n){if(n===`text/markdown`||n===`text/x-markdown`||n===`text/plain`||n===`text/x-rst`)return`doc`;if(n===`application/json`||n===`application/yaml`||n===`application/x-yaml`||n===`application/toml`||n===`application/csv`||n===`application/xml`||n===`text/csv`||n===`text/xml`||n===`text/yaml`||n===`application/x-ndjson`)return`data`;if(n.startsWith(`image/`)||n.startsWith(`video/`)||n.startsWith(`audio/`)||n===`application/pdf`||n===`application/zip`||n===`application/gzip`)return`media`;if(n.startsWith(`text/x-`)||n===`application/javascript`||n===`application/typescript`||n===`text/javascript`||n===`text/css`||n===`text/html`||n===`application/sql`)return`code`}let r=sh(e);return rh.has(r)?`doc`:ih.has(r)?`data`:ah.has(r)?`code`:oh.has(r)?`media`:n.startsWith(`text/`)?`doc`:`other`}function uh(e){return Pm(e)}function dh(e){let t=uh(e),n=t.lastIndexOf(`.`);return n<=0?t:t.slice(0,n)}function fh(e){return e?e.coverPath||e.coverUrl?`cover`:e.excerpt?`text`:`blank`:`blank`}function ph(e){if(mh(e))return`LINK`;let t=uh(e),n=t.lastIndexOf(`.`);return n<=0?(t.replace(/^\./,``)||`file`).toUpperCase():t.slice(n+1).toUpperCase()}function mh(e){if(!/^https?:\/\//i.test(e))return!1;try{let t=new URL(e).pathname.split(`/`).filter(Boolean).pop()??``;return!/\.[a-z\d]{1,8}$/i.test(t)}catch{return!1}}function hh(e){if(e===void 0||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${t[r]}`}function gh(e,t){let n=ph(e),r=hh(t);return n&&r?`${n} · ${r}`:r||n}function _h(e,t){switch(e){case`doc`:return t.text;case`code`:return t.rare;case`data`:return t.epic;case`media`:return t.legendary;default:return t.muted}}const vh={dark:{colorScheme:`dark`,palette:{bg:1053203,surface:2369321,hover:2500907,border:3158838,brand:14564909,activity:14564909,error:15950429,warning:15580004,text:15330286,muted:10198947,rare:6009047,epic:2070983,legendary:15580004},colors:{brand:{stroke:14564909,fill:14564909,label:15330286},neutral:{stroke:10198947,fill:10198947,label:15330286},black:{stroke:0,fill:0,label:15330286},white:{stroke:16777215,fill:16777215,label:15330286},blue:{stroke:6009047,fill:6009047,label:15330286},green:{stroke:7065501,fill:7065501,label:15330286},amber:{stroke:15580004,fill:15580004,label:15330286},violet:{stroke:11971577,fill:11971577,label:15330286},rose:{stroke:15950429,fill:15950429,label:15330286}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:2566444,size:2}}},light:{colorScheme:`light`,palette:{bg:16251130,surface:16777215,hover:15330029,border:14409442,brand:13582898,activity:13582898,error:10165794,warning:8804608,text:66050,muted:6251625,rare:24458,epic:19325,legendary:8804608},colors:{brand:{stroke:13582898,fill:13582898,label:66050},neutral:{stroke:6251625,fill:6251625,label:66050},black:{stroke:0,fill:0,label:66050},white:{stroke:16777215,fill:16777215,label:66050},blue:{stroke:24458,fill:24458,label:66050},green:{stroke:26685,fill:26685,label:66050},amber:{stroke:8804608,fill:8804608,label:66050},violet:{stroke:6904238,fill:6904238,label:66050},rose:{stroke:10165794,fill:10165794,label:66050}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:15001321,size:2}}},"solarized-dark":{colorScheme:`dark`,palette:{bg:70677,surface:859936,hover:1057828,border:1582887,brand:34240,activity:34240,error:15950429,warning:14790474,text:12572374,muted:6848639,rare:2206648,epic:38821,legendary:14790474},colors:{brand:{stroke:34240,fill:34240,label:12572374},neutral:{stroke:6848639,fill:6848639,label:12572374},black:{stroke:0,fill:0,label:12572374},white:{stroke:16777215,fill:16777215,label:12572374},blue:{stroke:2206648,fill:2206648,label:12572374},green:{stroke:9481815,fill:9481815,label:12572374},amber:{stroke:14790474,fill:14790474,label:12572374},violet:{stroke:11182560,fill:11182560,label:12572374},rose:{stroke:15950429,fill:15950429,label:12572374}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:1122594,size:2}}},"solarized-light":{colorScheme:`light`,palette:{bg:16775902,surface:16446169,hover:15920337,border:14341313,brand:31924,activity:31924,error:10363429,warning:8936704,text:2110772,muted:5860973,rare:28541,epic:23659,legendary:8936704},colors:{brand:{stroke:31924,fill:31924,label:2110772},neutral:{stroke:5860973,fill:5860973,label:2110772},black:{stroke:0,fill:0,label:2110772},white:{stroke:16777215,fill:16777215,label:2110772},blue:{stroke:28541,fill:28541,label:2110772},green:{stroke:4809217,fill:4809217,label:2110772},amber:{stroke:8936704,fill:8936704,label:2110772},violet:{stroke:6904995,fill:6904995,label:2110772},rose:{stroke:10363429,fill:10363429,label:2110772}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:15130570,size:2}}},"neta-studio":{colorScheme:`dark`,palette:{bg:329221,surface:1249814,hover:1973788,border:1842202,brand:3900150,activity:15524306,error:15562341,warning:15449187,text:16314853,muted:7630695,rare:9235170,epic:7266776,legendary:15449187},colors:{brand:{stroke:15524306,fill:15524306,label:16314853},neutral:{stroke:15524306,fill:15524306,label:16314853},black:{stroke:0,fill:0,label:16314853},white:{stroke:16777215,fill:16777215,label:16314853},blue:{stroke:9235170,fill:9235170,label:16314853},green:{stroke:8177036,fill:8177036,label:16314853},amber:{stroke:15449187,fill:15449187,label:16314853},violet:{stroke:11971327,fill:11971327,label:16314853},rose:{stroke:15562341,fill:15562341,label:16314853}},style:{selection:{outset:0},frameLabelSize:16}},"neta-pixel":{colorScheme:`light`,palette:{bg:16185078,surface:16777215,hover:16185078,border:15527149,brand:1824230,activity:434355,error:13705029,warning:9725440,text:1447704,muted:7566452,rare:31378,epic:31378,legendary:9725440},colors:{brand:{stroke:1447704,fill:1447704,label:1447704},neutral:{stroke:7566452,fill:7566452,label:1447704},black:{stroke:0,fill:0,label:1447704},white:{stroke:16777215,fill:16777215,label:1447704},blue:{stroke:6010853,fill:6010853,label:1447704},green:{stroke:9683613,fill:9683613,label:1447704},amber:{stroke:14264410,fill:14264410,label:1447704},violet:{stroke:11441117,fill:11441117,label:1447704},rose:{stroke:15043210,fill:15043210,label:1447704}},style:{corner:`pixel`,shadow:{color:1447704,alpha:.1,blur:20,y:0},selection:{width:1.5,outset:0,dash:0,handle:`square`,handleSize:8},media:`framed`,progress:`mosaic`,icons:`pixel`,motion:`stepped`,font:`"Figtree Variable", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif`,frameLabelSize:16},backdrop:{pattern:{kind:`dots`,pitch:24,color:14935011,size:2,shape:`square`}}},"neta-pixel-dark":{colorScheme:`dark`,palette:{bg:1118739,surface:1842463,hover:2237220,border:2763565,brand:1824230,activity:3142143,error:16740488,warning:16766287,text:16185078,muted:9079436,rare:1824230,epic:1824230,legendary:16766287},colors:{brand:{stroke:16185078,fill:16185078,label:16185078},neutral:{stroke:9079436,fill:9079436,label:16185078},black:{stroke:0,fill:0,label:16185078},white:{stroke:16777215,fill:16777215,label:16185078},blue:{stroke:6010853,fill:6010853,label:16185078},green:{stroke:9683613,fill:9683613,label:16185078},amber:{stroke:14264410,fill:14264410,label:16185078},violet:{stroke:11441117,fill:11441117,label:16185078},rose:{stroke:15043210,fill:15043210,label:16185078}},style:{corner:`pixel`,shadow:{color:0,alpha:.4,blur:20,y:0},selection:{width:1.5,outset:0,dash:0,handle:`square`,handleSize:8},media:`framed`,progress:`mosaic`,icons:`pixel`,motion:`stepped`,font:`"Figtree Variable", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif`,frameLabelSize:16},backdrop:{pattern:{kind:`dots`,pitch:24,color:3816512,size:2,shape:`square`}}}},yh={brand:`Brand`,neutral:`Neutral`,black:`Black`,white:`White`,blue:`Blue`,green:`Green`,amber:`Amber`,violet:`Violet`,rose:`Rose`},bh=Hc.map(e=>({id:e,label:yh[e],dark:{...vh.dark.colors[e]},light:{...vh.light.colors[e]}})),xh=new Map(bh.map(e=>[e.id,e]));function Sh(e){return typeof e==`string`&&xh.has(e)}function Ch(e,t){return((Sh(e)?xh.get(e):void 0)??xh.get(`brand`))[t]}function wh(e){let t={};for(let n of bh)t[n.id]=n[e];return t}function Th(e,t,n=`dark`){return e&&Sh(t)&&e[t]?e[t]:e?e.brand:Ch(t,n)}function Eh(e,t,n,r,i,a=`stroke`){let o=typeof e==`object`&&e?e[r]:e;if(o===void 0)return Th(n,t,r)[a];let s=o.trim().toLowerCase();return Sh(s)?Th(n,s,r)[a]:i(o)??Th(n,t,r)[a]}function Dh(e,t){return e===`sans`||e===`serif`||e===`mono`?t[e]:`"${e.replaceAll(`"`,``)}", ${t.sans}`}function Oh(e,t){return Nu({text:e.text,fontSize:e.fontSize,fontWeight:500,font:`sans`,lineHeight:1.4,width:Math.max(1,t-16)})}function kh(e){return{x:4,y:-(e+6)}}var H,Ah,jh,U,W=o((()=>{H=(e=>(e.Application=`application`,e.WebGLPipes=`webgl-pipes`,e.WebGLPipesAdaptor=`webgl-pipes-adaptor`,e.WebGLSystem=`webgl-system`,e.WebGPUPipes=`webgpu-pipes`,e.WebGPUPipesAdaptor=`webgpu-pipes-adaptor`,e.WebGPUSystem=`webgpu-system`,e.CanvasSystem=`canvas-system`,e.CanvasPipesAdaptor=`canvas-pipes-adaptor`,e.CanvasPipes=`canvas-pipes`,e.Asset=`asset`,e.LoadParser=`load-parser`,e.ResolveParser=`resolve-parser`,e.CacheParser=`cache-parser`,e.DetectionParser=`detection-parser`,e.MaskEffect=`mask-effect`,e.BlendMode=`blend-mode`,e.TextureSource=`texture-source`,e.TextureUploaderWebGL=`texture-uploader-webgl`,e.TextureUploaderWebGPU=`texture-uploader-webgpu`,e.Environment=`environment`,e.ShapeBuilder=`shape-builder`,e.Batcher=`batcher`,e))(H||{}),Ah=e=>{if(typeof e==`function`||typeof e==`object`&&e.extension){if(!e.extension)throw Error(`Extension class must have an extension object`);e={...typeof e.extension==`object`?e.extension:{type:e.extension},ref:e}}if(typeof e==`object`)e={...e};else throw Error(`Invalid extension type`);return typeof e.type==`string`&&(e.type=[e.type]),e},jh=(e,t)=>Ah(e).priority??t,U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(Ah).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...e){return e.map(Ah).forEach(e=>{e.type.forEach(t=>{let n=this._addHandlers,r=this._queue;n[t]?n[t]?.(e):(r[t]=r[t]||[],r[t]?.push(e))})}),this},handle(e,t,n){let r=this._addHandlers,i=this._removeHandlers;if(r[e]||i[e])throw Error(`Extension type ${e} already has a handler`);r[e]=t,i[e]=n;let a=this._queue;return a[e]&&(a[e]?.forEach(e=>t(e)),delete a[e]),this},handleByMap(e,t){return this.handle(e,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,e=>{t.findIndex(t=>t.name===e.name)>=0||(t.push({name:e.name,value:e.ref}),t.sort((e,t)=>jh(t.value,n)-jh(e.value,n)))},e=>{let n=t.findIndex(t=>t.name===e.name);n!==-1&&t.splice(n,1)})},handleByList(e,t,n=-1){return this.handle(e,e=>{t.includes(e.ref)||(t.push(e.ref),t.sort((e,t)=>jh(t,n)-jh(e,n)))},e=>{let n=t.indexOf(e.ref);n!==-1&&t.splice(n,1)})},mixin(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}}})),Mh=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),Nh,Ph,Fh=o((()=>{Nh=u(Mh(),1),Ph=Nh.default})),Ih,Lh,Rh,zh,Bh,Vh,Hh,Uh,Wh,Gh,Kh,qh,Jh,Yh,Xh,Zh,Qh,$h,eg,tg,ng,rg,ig,ag,og,sg,cg,lg,ug,dg=o((()=>{Ih={grad:.9,turn:360,rad:360/(2*Math.PI)},Lh=function(e){return typeof e==`string`?e.length>0:typeof e==`number`},Rh=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n+0},zh=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},Bh=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},Vh=function(e){return{r:zh(e.r,0,255),g:zh(e.g,0,255),b:zh(e.b,0,255),a:zh(e.a)}},Hh=function(e){return{r:Rh(e.r),g:Rh(e.g),b:Rh(e.b),a:Rh(e.a,3)}},Uh=/^#([0-9a-f]{3,8})$/i,Wh=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Gh=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:60*(s<0?s+6:s),s:a?o/a*100:0,v:a/255*100,a:i}},Kh=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:255*[r,s,o,o,c,r][l],g:255*[c,r,r,s,o,o][l],b:255*[o,o,c,r,r,s][l],a:i}},qh=function(e){return{h:Bh(e.h),s:zh(e.s,0,100),l:zh(e.l,0,100),a:zh(e.a)}},Jh=function(e){return{h:Rh(e.h),s:Rh(e.s),l:Rh(e.l),a:Rh(e.a,3)}},Yh=function(e){return Kh((n=(t=e).s,{h:t.h,s:(n*=((r=t.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:t.a}));var t,n,r},Xh=function(e){return{h:(t=Gh(e)).h,s:(i=(200-(n=t.s))*(r=t.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,r,i},Zh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$h=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,eg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tg={string:[[function(e){var t=Uh.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Rh(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?Rh(parseInt(e.substr(6,2),16)/255,2):1}:null:null},`hex`],[function(e){var t=$h.exec(e)||eg.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:Vh({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},`rgb`],[function(e){var t=Zh.exec(e)||Qh.exec(e);if(!t)return null;var n,r;return Yh(qh({h:(n=t[1],r=t[2],r===void 0&&(r=`deg`),Number(n)*(Ih[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}))},`hsl`]],object:[[function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i===void 0?1:i;return Lh(t)&&Lh(n)&&Lh(r)?Vh({r:Number(t),g:Number(n),b:Number(r),a:Number(a)}):null},`rgb`],[function(e){var t=e.h,n=e.s,r=e.l,i=e.a,a=i===void 0?1:i;return!Lh(t)||!Lh(n)||!Lh(r)?null:Yh(qh({h:Number(t),s:Number(n),l:Number(r),a:Number(a)}))},`hsl`],[function(e){var t=e.h,n=e.s,r=e.v,i=e.a,a=i===void 0?1:i;return!Lh(t)||!Lh(n)||!Lh(r)?null:Kh(function(e){return{h:Bh(e.h),s:zh(e.s,0,100),v:zh(e.v,0,100),a:zh(e.a)}}({h:Number(t),s:Number(n),v:Number(r),a:Number(a)}))},`hsv`]]},ng=function(e,t){for(var n=0;n<t.length;n++){var r=t[n][0](e);if(r)return[r,t[n][1]]}return[null,void 0]},rg=function(e){return typeof e==`string`?ng(e.trim(),tg.string):typeof e==`object`&&e?ng(e,tg.object):[null,void 0]},ig=function(e,t){var n=Xh(e);return{h:n.h,s:zh(n.s+100*t,0,100),l:n.l,a:n.a}},ag=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},og=function(e,t){var n=Xh(e);return{h:n.h,s:n.s,l:zh(n.l+100*t,0,100),a:n.a}},sg=function(){function e(e){this.parsed=rg(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return Rh(ag(this.rgba),2)},e.prototype.isDark=function(){return ag(this.rgba)<.5},e.prototype.isLight=function(){return ag(this.rgba)>=.5},e.prototype.toHex=function(){return e=Hh(this.rgba),t=e.r,n=e.g,r=e.b,a=(i=e.a)<1?Wh(Rh(255*i)):``,`#`+Wh(t)+Wh(n)+Wh(r)+a;var e,t,n,r,i,a},e.prototype.toRgb=function(){return Hh(this.rgba)},e.prototype.toRgbString=function(){return e=Hh(this.rgba),t=e.r,n=e.g,r=e.b,(i=e.a)<1?`rgba(`+t+`, `+n+`, `+r+`, `+i+`)`:`rgb(`+t+`, `+n+`, `+r+`)`;var e,t,n,r,i},e.prototype.toHsl=function(){return Jh(Xh(this.rgba))},e.prototype.toHslString=function(){return e=Jh(Xh(this.rgba)),t=e.h,n=e.s,r=e.l,(i=e.a)<1?`hsla(`+t+`, `+n+`%, `+r+`%, `+i+`)`:`hsl(`+t+`, `+n+`%, `+r+`%)`;var e,t,n,r,i},e.prototype.toHsv=function(){return e=Gh(this.rgba),{h:Rh(e.h),s:Rh(e.s),v:Rh(e.v),a:Rh(e.a,3)};var e},e.prototype.invert=function(){return cg({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return e===void 0&&(e=.1),cg(ig(this.rgba,e))},e.prototype.desaturate=function(e){return e===void 0&&(e=.1),cg(ig(this.rgba,-e))},e.prototype.grayscale=function(){return cg(ig(this.rgba,-1))},e.prototype.lighten=function(e){return e===void 0&&(e=.1),cg(og(this.rgba,e))},e.prototype.darken=function(e){return e===void 0&&(e=.1),cg(og(this.rgba,-e))},e.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return typeof e==`number`?cg({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Rh(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=Xh(this.rgba);return typeof e==`number`?cg({h:e,s:t.s,l:t.l,a:t.a}):Rh(t.h)},e.prototype.isEqual=function(e){return this.toHex()===cg(e).toHex()},e}(),cg=function(e){return e instanceof sg?e:new sg(e)},lg=[],ug=function(e){e.forEach(function(e){lg.indexOf(e)<0&&(e(sg,tg),lg.push(e))})}}));function fg(e,t){var n={white:`#ffffff`,bisque:`#ffe4c4`,blue:`#0000ff`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,antiquewhite:`#faebd7`,aqua:`#00ffff`,azure:`#f0ffff`,whitesmoke:`#f5f5f5`,papayawhip:`#ffefd5`,plum:`#dda0dd`,blanchedalmond:`#ffebcd`,black:`#000000`,gold:`#ffd700`,goldenrod:`#daa520`,gainsboro:`#dcdcdc`,cornsilk:`#fff8dc`,cornflowerblue:`#6495ed`,burlywood:`#deb887`,aquamarine:`#7fffd4`,beige:`#f5f5dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkkhaki:`#bdb76b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,peachpuff:`#ffdab9`,darkmagenta:`#8b008b`,darkred:`#8b0000`,darkorchid:`#9932cc`,darkorange:`#ff8c00`,darkslateblue:`#483d8b`,gray:`#808080`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,wheat:`#f5deb3`,firebrick:`#b22222`,floralwhite:`#fffaf0`,ghostwhite:`#f8f8ff`,darkviolet:`#9400d3`,magenta:`#ff00ff`,green:`#008000`,dodgerblue:`#1e90ff`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,blueviolet:`#8a2be2`,forestgreen:`#228b22`,lawngreen:`#7cfc00`,indianred:`#cd5c5c`,indigo:`#4b0082`,fuchsia:`#ff00ff`,brown:`#a52a2a`,maroon:`#800000`,mediumblue:`#0000cd`,lightcoral:`#f08080`,darkturquoise:`#00ced1`,lightcyan:`#e0ffff`,ivory:`#fffff0`,lightyellow:`#ffffe0`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,linen:`#faf0e6`,mediumaquamarine:`#66cdaa`,lemonchiffon:`#fffacd`,lime:`#00ff00`,khaki:`#f0e68c`,mediumseagreen:`#3cb371`,limegreen:`#32cd32`,mediumspringgreen:`#00fa9a`,lightskyblue:`#87cefa`,lightblue:`#add8e6`,midnightblue:`#191970`,lightpink:`#ffb6c1`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,mintcream:`#f5fffa`,lightslategray:`#778899`,lightslategrey:`#778899`,navajowhite:`#ffdead`,navy:`#000080`,mediumvioletred:`#c71585`,powderblue:`#b0e0e6`,palegoldenrod:`#eee8aa`,oldlace:`#fdf5e6`,paleturquoise:`#afeeee`,mediumturquoise:`#48d1cc`,mediumorchid:`#ba55d3`,rebeccapurple:`#663399`,lightsteelblue:`#b0c4de`,mediumslateblue:`#7b68ee`,thistle:`#d8bfd8`,tan:`#d2b48c`,orchid:`#da70d6`,mediumpurple:`#9370db`,purple:`#800080`,pink:`#ffc0cb`,skyblue:`#87ceeb`,springgreen:`#00ff7f`,palegreen:`#98fb98`,red:`#ff0000`,yellow:`#ffff00`,slateblue:`#6a5acd`,lavenderblush:`#fff0f5`,peru:`#cd853f`,palevioletred:`#db7093`,violet:`#ee82ee`,teal:`#008080`,slategray:`#708090`,slategrey:`#708090`,aliceblue:`#f0f8ff`,darkseagreen:`#8fbc8f`,darkolivegreen:`#556b2f`,greenyellow:`#adff2f`,seagreen:`#2e8b57`,seashell:`#fff5ee`,tomato:`#ff6347`,silver:`#c0c0c0`,sienna:`#a0522d`,lavender:`#e6e6fa`,lightgreen:`#90ee90`,orange:`#ffa500`,orangered:`#ff4500`,steelblue:`#4682b4`,royalblue:`#4169e1`,turquoise:`#40e0d0`,yellowgreen:`#9acd32`,salmon:`#fa8072`,saddlebrown:`#8b4513`,sandybrown:`#f4a460`,rosybrown:`#bc8f8f`,darksalmon:`#e9967a`,lightgoldenrodyellow:`#fafad2`,snow:`#fffafa`,lightgrey:`#d3d3d3`,lightgray:`#d3d3d3`,dimgray:`#696969`,dimgrey:`#696969`,olivedrab:`#6b8e23`,olive:`#808000`},r={};for(var i in n)r[n[i]]=i;var a={};e.prototype.toName=function(t){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return`transparent`;var i,o,s=r[this.toHex()];if(s)return s;if(t?.closest){var c=this.toRgb(),l=1/0,u=`black`;if(!a.length)for(var d in n)a[d]=new e(n[d]).toRgb();for(var f in n){var p=(i=c,o=a[f],(i.r-o.r)**2+(i.g-o.g)**2+(i.b-o.b)**2);p<l&&(l=p,u=f)}return u}},t.string.push([function(t){var r=t.toLowerCase(),i=r===`transparent`?`#0000`:n[r];return i?new e(i).toRgb():null},`name`])}var pg=o((()=>{})),mg,hg,gg=o((()=>{dg(),pg(),ug([fg]),mg=class e{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(t){if(t instanceof e)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else if(t===null)throw Error(`Cannot set Color#value to null`);else(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}get value(){return this._value}_cloneSource(e){return typeof e==`string`||typeof e==`number`||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e==`object`&&e?{...e}:e}_isSourceEqual(e,t){let n=typeof e;if(n!==typeof t)return!1;if(n===`number`||n===`string`||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length===t.length&&e.every((e,n)=>e===t[n]);if(e!==null&&t!==null){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}return e===t}toRgba(){let[e,t,n,r]=this._components;return{r:e,g:t,b:n,a:r}}toRgb(){let[e,t,n]=this._components;return{r:e,g:t,b:n}}toRgbaString(){let[e,t,n]=this.toUint8RgbArray();return`rgba(${e},${t},${n},${this.alpha})`}toUint8RgbArray(e){let[t,n,r]=this._components;return this._arrayRgb||=[],e||=this._arrayRgb,e[0]=Math.round(t*255),e[1]=Math.round(n*255),e[2]=Math.round(r*255),e}toArray(e){this._arrayRgba||=[],e||=this._arrayRgba;let[t,n,r,i]=this._components;return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}toRgbArray(e){this._arrayRgb||=[],e||=this._arrayRgb;let[t,n,r]=this._components;return e[0]=t,e[1]=n,e[2]=r,e}toNumber(){return this._int}toBgrNumber(){let[e,t,n]=this.toUint8RgbArray();return(n<<16)+(t<<8)+e}toLittleEndianNumber(){let e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(t){let[n,r,i,a]=e._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=r,this._components[2]*=i,this._components[3]*=a,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let n=this._int>>16&255,r=this._int>>8&255,i=this._int&255;return t&&(n=n*e+.5|0,r=r*e+.5|0,i=i*e+.5|0),(e*255<<24)+(n<<16)+(r<<8)+i}toHex(){let e=this._int.toString(16);return`#${`000000`.substring(0,6-e.length)+e}`}toHexa(){let e=Math.round(this._components[3]*255).toString(16);return this.toHex()+`00`.substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(t){let n,r,i,a;if((typeof t==`number`||t instanceof Number)&&t>=0&&t<=16777215){let e=t;n=(e>>16&255)/255,r=(e>>8&255)/255,i=(e&255)/255,a=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,r,i,a=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,r,i,a=255]=t,n/=255,r/=255,i/=255,a/=255;else if(typeof t==`string`||typeof t==`object`){if(typeof t==`string`){let n=e.HEX_PATTERN.exec(t);n&&(t=`#${n[2]}`)}let o=cg(t);o.isValid()&&({r:n,g:r,b:i,a}=o.rgba,n/=255,r/=255,i/=255)}if(n!==void 0)this._components[0]=n,this._components[1]=r,this._components[2]=i,this._components[3]=a,this._refreshInt();else throw Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[e,t,n]=this._components;this._int=(e*255<<16)+(t*255<<8)+(n*255|0)}_clamp(e,t=0,n=1){return typeof e==`number`?Math.min(Math.max(e,t),n):(e.forEach((r,i)=>{e[i]=Math.min(Math.max(r,t),n)}),e)}static isColorLike(t){return typeof t==`number`||typeof t==`string`||t instanceof Number||t instanceof e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}},mg.shared=new mg,mg._temp=new mg,mg.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i,hg=mg})),_g,vg=o((()=>{_g={cullArea:null,cullable:!1,cullableChildren:!0}})),yg,bg,xg,Sg=o((()=>{yg=Math.PI*2,bg=180/Math.PI,xg=Math.PI/180})),Cg,wg,Tg=o((()=>{Cg=class e{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new e(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return wg.x=0,wg.y=0,wg}},wg=new Cg})),G,Eg,Dg,K=o((()=>{Sg(),Tg(),G=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}toArray(e,t){this.array||=new Float32Array(9);let n=t||this.array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}apply(e,t){t||=new Cg;let n=e.x,r=e.y;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}applyInverse(e,t){t||=new Cg;let n=this.a,r=this.b,i=this.c,a=this.d,o=this.tx,s=this.ty,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(yg-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+(a.x*t+a.y*r),e.position.y=this.ty+(a.x*n+a.y*i),e}invert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let t=new e;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Dg.identity()}static get shared(){return Eg.identity()}},Eg=new G,Dg=new G})),Og,kg=o((()=>{Og=class e{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(t){return new e(t??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}}));function Ag(e=`default`){return jg[e]===void 0&&(jg[e]=-1),++jg[e]}var jg,Mg=o((()=>{jg={default:-1}})),Ng,Pg,Fg,Ig,q,Lg=o((()=>{Ng=new Set,Pg=`8.0.0`,Fg=`8.3.4`,Ig={quiet:!1,noColor:!1},q=((e,t,n=3)=>{if(Ig.quiet||Ng.has(t))return;let r=Error().stack,i=`${t}
56
+ `),a=n?i.flatMap(e=>Au(e,n,r)):i;return{lines:a,width:a.reduce((e,t)=>Math.max(e,r(t)),0)}}function Au(e,t,n){if(!e)return[``];let r=e.match(/[\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\uff00-\uff60]|[^\s\u1100-\u115f\u2e80-\ua4cf\uac00-\ud7a3\uf900-\ufaff\uff00-\uff60]+|\s+/g)??[e],i=[],a=``;for(let e of r){let r=a+e;if(!a||n(r.trimEnd())<=t){a=r;continue}i.push(a.trimEnd()),a=/^\s+$/.test(e)?``:e}return i.push(a.trimEnd()),i}const ju=new Map;function Mu(e){return Math.min(512,Math.max(2,e))}function Nu(e){let t=Mu(e.fontSize??24),n=`${t}|${e.fontWeight}|${e.font}|${e.lineHeight}|${e.width??``}|${e.text}`,r=ju.get(n);if(r)return r;let i={fontSize:t,fontWeight:e.fontWeight??500,font:e.font??`sans`},{lines:a,width:o}=(Tu??ku)(e.text||``,i,e.width||void 0),s=t*(e.lineHeight??4/3),c={width:Math.max(e.width??0,o,t*.5),height:Math.max(1,a.length)*s,lines:a,lineHeight:s};return ju.size>=4096&&ju.clear(),ju.set(n,c),c}function Pu(e,t){let n=Math.min(1,Math.max(0,t));return Math.max(.5,e/2*(.5+n))}function Fu(e,t){if(e.length===0)return{x:0,y:0,width:1,height:1};let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of e){let e=Pu(t,o.p);n=Math.min(n,o.x-e),r=Math.min(r,o.y-e),i=Math.max(i,o.x+e),a=Math.max(a,o.y+e)}return{x:n,y:r,width:Math.max(1,i-n),height:Math.max(1,a-r)}}function Iu(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);return Number.isFinite(t)?{x:t,y:n,width:Math.max(1,r-t),height:Math.max(1,i-n)}:{x:0,y:0,width:1,height:1}}function Lu(e){return typeof e.item==`string`}function Ru(e){if(e.type!==`arrow`)return[];let t=e.props,n=[t.start,t.end].filter(Lu).map(e=>e.item);return[...new Set(n)]}function zu(e,t,n){let r={x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(!n)return r;let i=t.x-e.x,a=t.y-e.y,o=Math.hypot(i,a)||1,s=n*o;return{x:r.x+-a/o*s,y:r.y+i/o*s}}function Bu(e,t){let n=e,r=new Map,i=new Map,a=new Map;function o(e,t=0){let r=i.get(e);if(r)return r;let a=n(e);if(!a)return yu;let c=bu(a.parent&&t<64&&n(a.parent)?o(a.parent,t+1):yu,s(e));return i.set(e,c),c}function s(e){let t=n(e);if(!t)return yu;if(t.type===`arrow`)return Vu(t.position);let r=c(e),i=wu(t.scale),a=t.rotation*Math.PI/180,o=Math.cos(a),s=Math.sin(a),l=r.x+t.origin.x*r.width,u=r.y+t.origin.y*r.height,d=o*i.x,f=s*i.x,p=-s*i.y,m=o*i.y;return[d,f,p,m,t.position.x+l-(d*l+p*u),t.position.y+u-(f*l+m*u)]}function c(e,t=0){let i=r.get(e);if(i)return i;let a=n(e),o;if(!a)o={x:0,y:0,width:1,height:1};else if(`size`in a&&a.size)o={x:0,y:0,width:a.size.width,height:a.size.height};else if(a.type===`text`){let e=Nu(a.props);o={x:0,y:0,width:e.width,height:e.height}}else if(a.type===`draw`)o=Fu(a.props.points,a.style.strokeWidth??4);else if(a.type===`arrow`){let e=a.props,n=xu(bu(l(a,t),Vu(a.position))),r=Lu(e.start)?Su(n,u(a,e.start,e.end,t)):e.start,i=Lu(e.end)?Su(n,u(a,e.end,e.start,t)):e.end,s=[r,i,...e.waypoints];e.bend&&s.push(zu(r,i,e.bend));let c=Iu(s),d=Math.max(8,(a.style.strokeWidth??2.5)*2);o={x:c.x-d,y:c.y-d,width:c.width+d*2,height:c.height+d*2}}else o={x:0,y:0,...wc(a.type)};return r.set(e,o),o}function l(e,t){return e.parent&&t<64&&n(e.parent)?o(e.parent,t+1):yu}function u(e,t,r,i){let a=n(t.item),o=bu(l(e,i),Vu(e.position));if(!a||a.type===`arrow`||i>=64)return Su(o,{x:0,y:0});let s=d(t.item,i+1),c=Lu(r)?n(r.item)&&n(r.item)?.type!==`arrow`?Hu(d(r.item,i+1)):Hu(s):Su(o,r);return qu(s,t.anchor,c)}function d(e,t=0){c(e,t);let n=r.get(e),i=o(e,t),[a,s,l,u]=i,d=Su(i,{x:n.x+n.width/2,y:n.y+n.height/2}),f=n.width*Math.hypot(a,s),p=n.height*Math.hypot(l,u),{rotation:m,mirrored:h}=Cu(i);return{x:d.x-f/2,y:d.y-p/2,width:f,height:p,rotation:m,...h?{mirrored:h}:{}}}function f(e){let t=a.get(e);if(t)return t;let n=c(e),r=o(e),i=Iu([Su(r,{x:n.x,y:n.y}),Su(r,{x:n.x+n.width,y:n.y}),Su(r,{x:n.x+n.width,y:n.y+n.height}),Su(r,{x:n.x,y:n.y+n.height})]);return a.set(e,i),i}function p(e){n=e}function m(e){if(!e){r.clear(),i.clear(),a.clear();return}let n=[...e],o=new Set;for(;n.length;){let e=n.pop();if(!o.has(e)&&(o.add(e),r.delete(e),i.delete(e),a.delete(e),t))for(let r of t(e))n.push(r)}}return{has:e=>n(e)!==void 0,box:e=>c(e),matrix:e=>o(e),localMatrix:e=>s(e),parentMatrix:e=>{let t=n(e);return t?l(t,0):yu},bounds:f,frame:e=>d(e),arrowEnd:(e,t)=>{let r=n(e);if(r?.type!==`arrow`)return{x:0,y:0};let i=r,[a,s]=t===`start`?[i.props.start,i.props.end]:[i.props.end,i.props.start];return Lu(a)?u(i,a,s,0):Su(o(e),a)},invalidate:m,setLookup:p}}function Vu(e){return[1,0,0,1,e.x,e.y]}function Hu(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Uu(e,t,n){if(!n)return e;let r=n*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=e.x-t.x,s=e.y-t.y;return{x:t.x+o*i-s*a,y:t.y+o*a+s*i}}function Wu(e,t,n){return Uu({x:e.x+t*e.width,y:e.y+n*e.height},Hu(e),e.rotation)}function Gu(e,t){let n=Uu(t,Hu(e),-e.rotation),r=Hu(e),i=(n.x-r.x)/Math.max(e.width/2,1e-4),a=(n.y-r.y)/Math.max(e.height/2,1e-4);return Math.abs(i)>=Math.abs(a)?i>=0?`right`:`left`:a>=0?`bottom`:`top`}function Ku(e,t){switch(e){case`top`:return{x:t,y:0};case`bottom`:return{x:t,y:1};case`left`:return{x:0,y:t};default:return{x:1,y:t}}}function qu(e,t,n){if(t===`auto`){let t=Ku(Gu(e,n),.5);return Wu(e,t.x,t.y)}if(`side`in t){let n=Ku(t.side,t.offset);return Wu(e,n.x,n.y)}return Wu(e,t.x,t.y)}function Ju(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return Number.isNaN(e)&&Number.isNaN(t);let n=Array.isArray(e),r=Array.isArray(t);if(n!==r)return!1;if(n&&r)return e.length===t.length&&e.every((e,n)=>Ju(e,t[n]));let i=e,a=t,o=Object.keys(i);return o.length===Object.keys(a).length&&o.every(e=>Object.hasOwn(a,e)&&Ju(i[e],a[e]))}function Yu(e,t){let n=e[t];return n||(n={},e[t]=n),n}function Xu(){return{items:{},animations:{},tracks:{}}}function Zu(e){for(let[t,n]of Object.entries(e))(n===void 0||Qu(n)&&Object.keys(n).length===0)&&delete e[t];return e}function Qu(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $u(e,t){if(!Qu(t))return t;let n=Qu(e)?{...e}:{};for(let[e,r]of Object.entries(t))r===null?delete n[e]:n[e]=$u(n[e],r);return n}function ed(e){return e._zod.def}function td(e){let t=e;for(let e=0;e<16;e+=1){let e=ed(t);if(e.type===`optional`||e.type==="default"||e.type===`nullable`||e.type===`readonly`||e.type===`prefault`)t=e.innerType;else if(e.type===`pipe`)t=e.in;else return t}return t}function nd(e){let t=ed(td(e));return t.type===`object`?t.shape:null}function rd(e,t){let n=e;for(let e of t){let t=ed(td(n));if(t.type===`object`){let r=t.shape;if(!Object.hasOwn(r,e))return null;n=r[e]}else if(t.type===`record`)n=t.valueType;else if(t.type===`union`){let r=t.options.find(t=>nd(t)?.[e]);if(!r)return null;n=nd(r)[e]}else return null}return n}const id=new Set([`type`,`parent`,`z`,`locked`,`autoplay`,`metadata`,`script`]),ad={focus:{kind:`discrete`,schema:zs([L().min(1),R({x:ws().finite(),y:ws().finite(),width:ws().finite().positive(),height:ws().finite().positive()}).strict()]).describe(`Item id or world-space rect to fit with 48 px padding; holds until the next focus keyframe.`)},zoom:{kind:`number`,schema:ws().finite().positive().describe(`Pixels per world unit; overrides the zoom computed by focus.`),multiplicative:!0},center:{kind:`vec2`,schema:Bc.describe(`World-space viewport center; overrides focus positioning using the resolved zoom.`)},shake:{kind:`number`,schema:ws().finite().nonnegative().describe(`Shake amplitude in screen pixels, applied after focus, zoom and center.`)}},od={time:{kind:`number`,schema:ws().finite().nonnegative()}},sd={kind:`discrete`,schema:yc().describe(`Numbers blend and colors mix between keyframes; other values step.`)};function cd(e,t){let n=t[t.length-1];if(t.length===1&&n===`scale`)return`scale`;if(e===Kc||td(e)===Kc)return`color`;if(ed(td(e)).type===`number`)return`number`;let r=nd(e);return r&&Object.keys(r).length===2&&`x`in r&&`y`in r?`vec2`:`discrete`}function ld(e,t){if(e===`camera`){let e=ad[t];return e?{ok:!0,spec:e}:{ok:!1,message:`camera has no property ${t}; expected ${Object.keys(ad).join(`, `)}`}}if(e===`animation`){let e=od[t];return e?{ok:!0,spec:e}:{ok:!1,message:`animations are driven through time`}}if(e===`script`)return/^params\.[^.]+$/.test(t)?{ok:!0,spec:sd}:{ok:!1,message:`Board scripts animate params.<name>, not ${t}`};if(/^script\.params\.[^.]+$/.test(t))return{ok:!0,spec:sd};let n=t.split(`.`);if(n.some(e=>!e)||id.has(n[0]))return{ok:!1,message:`${t} cannot be animated`};let r=Jl(e);if(!r)return{ok:!1,message:`unknown item type ${e}`};if(!Gl(e)&&n[0]===`props`)return{ok:!0,spec:{kind:`discrete`,schema:Ms()}};let i=rd(r,n);if(!i)return{ok:!1,message:`${e} has no property ${t}`};let a=cd(i,n);return{ok:!0,spec:{kind:a,schema:td(i),...t===`opacity`||a===`scale`?{multiplicative:!0}:{}}}}function ud(e){let t=0;for(let n of e){let e=n?.keyframes;if(Array.isArray(e))for(let n of e){let e=n?.at;typeof e==`number`&&Number.isFinite(e)&&(t=Math.max(t,e))}}return t>0?t:void 0}function dd(e){let t=new Set([e.target]);if(e.target===`camera`&&e.property===`focus`)for(let n of e.keyframes)typeof n.value==`string`&&t.add(n.value);return t.delete(Pc),[...t]}function fd(e,t){if(t.has(e.target))return null;if(e.target!==`camera`||e.property!==`focus`)return e;let n=e.keyframes.filter(e=>typeof e.value!=`string`||!t.has(e.value));return n.length===e.keyframes.length?e:n.length?{...e,keyframes:n}:null}function pd(e,t,n){return{severity:`error`,code:t,path:e,message:n}}const md=[`fill`,`fillOpacity`,`stroke`,`strokeWidth`,`dash`,`radius`,`trim`];function hd(e,t,n,r){let[i,a]=t.type===`text`?[md.filter(e=>e!==`fill`),`text draws only its fill color`]:t.type===`file`?[md,`file cards follow the theme`]:t.type===`frame`&&t.props.decoration===`none`?[md,`a frame with decoration "none" draws no box; put a shape inside it instead`]:[[],``],o=Qu(n.style)?n.style:{},s=r||Qu(n.props)&&`decoration`in n.props,c=i.filter(e=>t.style[e]!==void 0&&(s||e in o));return c.length?{severity:`warning`,code:`STYLE_NOT_DRAWN`,path:`items.${e}.style`,message:`${c.join(`, `)} ${c.length===1?`has`:`have`} no effect: ${a}.`}:null}function gd(e){if(!(`id`in e))return e;let{id:t,...n}=e;return n}function _d(e,t,n={}){let r=mu.safeParse(t);if(!r.success)return{ok:!1,diagnostics:r.error.issues.map(e=>pd(e.path.map(String).join(`.`),`INVALID_PATCH`,e.message))};let i=r.data,a=[],o=[],s=e=>n.keepUnknown?Xl:e?Zl(e):void 0,c=new Map,l=new Map,u=new Map,d,f=t=>c.has(t)?c.get(t)??void 0:e.item(t),p=t=>l.has(t)?l.get(t)??void 0:e.animation(t),m=(e,t,n)=>{let r=u.get(e)??new Map;r.set(t,n),u.set(e,r)},h=(t,n)=>{let r=u.get(t);return r?.has(n)?r.get(n)??void 0:e.track(t,n)};if(i.board!==void 0){let t=i.board===null?{}:$u(e.settings(),i.board),n=eu(fu,t,s(e.settings()));if(n.success)d=n.data;else for(let e of n.error.issues)a.push(pd([`board`,...e.path.map(String)].join(`.`),`INVALID_BOARD`,e.message))}let g=new Map;for(let[t,n]of Object.entries(i.items??{})){if(n===null){e.item(t)&&c.set(t,null);continue}let r=e.item(t),i=gd(n),l=!r||typeof i.type==`string`&&i.type!==r.type,u=l?{...i}:$u(r,i);if(u.z===void 0){let t=typeof u.parent==`string`?u.parent:void 0,n=t??``,i=g.get(n)??e.maxZ(t);u.z=r?.z??i+1,r||g.set(n,i+1)}let d=tu(u,`items.${t}`,s(l?void 0:r));if(!d.ok){a.push(...d.diagnostics);continue}if(r&&Ju(r,d.item))continue;c.set(t,d.item);let f=hd(t,d.item,i,l);f&&o.push(f)}for(let[t,n]of Object.entries(i.animations??{})){if(n===null){if(!e.animation(t))continue;l.set(t,null);for(let n of e.trackIds(t))m(t,n,null);continue}let{tracks:r,...i}=gd(n);if(e.item(t)||c.get(t)){a.push(pd(`animations.${t}`,`ID_CONFLICT`,`${t} is already an item id`));continue}let o=e.animation(t);if(!o||Object.keys(i).length>0){let n=o?$u(o,i):{...i,...i.duration===void 0?{duration:ud([...Object.values(r??{}),...e.trackIds(t).map(n=>e.track(t,n))])}:{}},c=eu(cu,n,s(o));if(!c.success){for(let e of c.error.issues)a.push(pd([`animations`,t,...e.path.map(String)].join(`.`),`INVALID_ANIMATION`,e.message));continue}(!o||!Ju(o,c.data))&&l.set(t,c.data)}for(let[n,i]of Object.entries(r??{})){let r=e.track(t,n);if(i===null){r&&m(t,n,null);continue}let o=eu(ou,r?$u(r,i):i,s(r));if(!o.success){for(let e of o.error.issues)a.push(pd([`animations`,t,`tracks`,n,...e.path.map(String)].join(`.`),`INVALID_TRACK`,e.message));continue}(!r||!Ju(r,o.data))&&m(t,n,o.data)}}for(let e of c.keys())c.get(e)&&p(e)&&a.push(pd(`items.${e}`,`ID_CONFLICT`,`${e} is already an animation id`));let _=(d??e.settings()).scripts??{},v=e=>Object.hasOwn(_,e);for(let e of Object.keys(_)){let t=f(e)?`an item`:p(e)?`an animation`:null;if(!t)continue;let n=c.get(e)?`items.${e}`:l.get(e)?`animations.${e}`:`board.scripts.${e}`;a.push(pd(n,`ID_CONFLICT`,n.startsWith(`board`)?`${e} is already ${t} id`:`${e} is already a Board script id`))}if(a.length)return{ok:!1,diagnostics:a};let y=[...c].filter(([,e])=>e===null).map(([e])=>e),b=Bu(t=>f(t)??e.item(t)),x=[...y];for(;x.length;){let t=x.pop();for(let r of e.children(t))c.has(r)&&c.get(r)?.parent!==t||(n.cascade?c.get(r)!==null&&(c.set(r,null),x.push(r)):a.push(pd(`items.${t}`,`ITEM_REFERENCED`,`${t} still has child ${r}; delete it too or use cascade`)));for(let r of e.binders(t)){let e=f(r);if(e?.type!==`arrow`)continue;let i={...e.props};for(let e of[`start`,`end`]){let a=i[e];if(!Lu(a)||a.item!==t)continue;let o=n.resolveArrowEnd?.(r,e)??b.arrowEnd(r,e);i[e]=Su(xu(b.matrix(r)),o)}c.set(r,{...e,props:i})}for(let r of e.trackRefs(t)){let e=h(r.animation,r.track);!e||!dd(e).includes(t)||(n.cascade?m(r.animation,r.track,fd(e,new Set([t]))):a.push(pd(`items.${t}`,`ITEM_REFERENCED`,`${t} is animated by ${r.animation}.${r.track}; delete the track or use cascade`)))}}for(let t of Object.keys(e.settings().scripts??{}))if(!v(t))for(let r of e.trackRefs(t))h(r.animation,r.track)?.target===t&&(n.cascade?m(r.animation,r.track,null):a.push(pd(`board.scripts.${t}`,`SCRIPT_REFERENCED`,`${t} is animated by ${r.animation}.${r.track}; delete the track or use cascade`)));for(let[t,r]of l)if(r===null)for(let r of e.trackRefs(t))r.animation!==t&&h(r.animation,r.track)?.target===t&&(n.cascade?m(r.animation,r.track,null):a.push(pd(`animations.${t}`,`ANIMATION_REFERENCED`,`${t} is nested in ${r.animation}.${r.track}; delete the track or use cascade`)));let S={...e,trackIds:t=>[...new Set([...e.trackIds(t),...u.get(t)?.keys()??[]])]},C=new Map(c),w=[];for(let[t,n]of c)n&&n.parent!==e.item(t)?.parent&&w.push(...e.children(t));let T=new Set;for(;w.length;){let t=w.pop();T.has(t)||(T.add(t),C.set(t,f(t)??null),w.push(...e.children(t)))}for(let[e,t]of C)if(t){if(t.parent!==void 0){let n=f(t.parent);if(!n)a.push(pd(`items.${e}.parent`,`PARENT_NOT_FOUND`,`parent ${t.parent} does not exist`));else if(n.type!==`frame`)a.push(pd(`items.${e}.parent`,`INVALID_PARENT`,`parent ${t.parent} is a ${n.type}; only frames contain items`));else{let n=t.parent;for(let t=0;n;t+=1){if(t>=64){a.push(pd(`items.${e}.parent`,`PARENT_DEPTH`,`parent hierarchy exceeds 64 levels`));break}if(n===e){a.push(pd(`items.${e}.parent`,`PARENT_CYCLE`,`${e} cannot be inside itself`));break}n=f(n)?.parent}}}for(let n of Ru(t)){let t=f(n);t?(n===e||t.type===`arrow`)&&a.push(pd(`items.${e}.props`,`INVALID_BINDING`,`arrows bind to items other than arrows`)):a.push(pd(`items.${e}.props`,`BINDING_NOT_FOUND`,`bound item ${n} does not exist`))}}for(let[t,r]of c)if(!(!r||!e.item(t)||e.item(t)?.type===r.type)){if(r.type!==`frame`)for(let n of e.children(t))f(n)?.parent===t&&a.push(pd(`items.${n}.parent`,`INVALID_PARENT`,`${t} is not a frame`));if(r.type===`arrow`)for(let n of e.binders(t)){let e=f(n);e&&Ru(e).includes(t)&&a.push(pd(`items.${n}.props`,`INVALID_BINDING`,`arrows cannot bind to arrows`))}for(let r of e.trackRefs(t)){let e=h(r.animation,r.track);e&&a.push(...vd(`animations.${r.animation}.tracks.${r.track}`,r.animation,e,f,p,h,v,S,n.keepUnknown))}}for(let[t,r]of u){if(!p(t)){for(let[e,n]of r)n&&a.push(pd(`animations.${t}.tracks.${e}`,`ANIMATION_NOT_FOUND`,`animation ${t} does not exist`));continue}for(let[i,o]of r){if(!o)continue;let r=n.keepUnknown||e.track(t,i)?.property===o.property;a.push(...vd(`animations.${t}.tracks.${i}`,t,o,f,p,h,v,S,r))}}if(a.length)return{ok:!1,diagnostics:a};let E=Xu(),D=Xu();d&&!Ju(d,e.settings())&&(E.board=e.settings(),D.board=d);for(let[t,n]of c){let r=e.item(t)??null;Ju(r,n)||(E.items[t]=r,D.items[t]=n)}for(let[t,n]of l)E.animations[t]=e.animation(t)??null,D.animations[t]=n;for(let[t,n]of u)for(let[r,i]of n){let n=e.track(t,r)??null;Ju(n,i)||(Yu(E.tracks,t)[r]=n,Yu(D.tracks,t)[r]=i)}return{ok:!0,before:Zu(E),after:Zu(D),diagnostics:o}}function vd(e,t,n,r,i,a,o,s,c=!1){let l=[],u;if(n.target===`camera`)u=Pc;else if(r(n.target))u=r(n.target).type;else if(i(n.target)){if(u=`animation`,n.target===t||yd(n.target,t,i,a,s))return[pd(`${e}.target`,`ANIMATION_CYCLE`,`${t} cannot contain itself through ${n.target}`)]}else if(o(n.target))u=`script`;else return[pd(`${e}.target`,`TARGET_NOT_FOUND`,`target ${n.target} is not an item, animation, Board script or camera`)];if(!c&&n.property.startsWith(`script.`)&&!r(n.target)?.script)return[pd(`${e}.property`,`INVALID_PROPERTY`,`${n.target} has no script to animate`)];let d=ld(u,n.property);if(!d.ok)return c?[]:[pd(`${e}.property`,`INVALID_PROPERTY`,d.message)];for(let[t,i]of n.keyframes.entries()){let a=d.spec.schema.safeParse(i.value);if(!a.success){l.push(pd(`${e}.keyframes.${t}.value`,`INVALID_KEYFRAME`,a.error.issues[0]?.message??`invalid value`));continue}n.property===`focus`&&typeof i.value==`string`&&!r(i.value)&&l.push(pd(`${e}.keyframes.${t}.value`,`TARGET_NOT_FOUND`,`focus item ${i.value} does not exist`))}return n.interpolation===`spline`&&d.spec.kind!==`vec2`&&l.push(pd(`${e}.interpolation`,`INVALID_TRACK`,`spline interpolation needs a position-like property`)),l}function yd(e,t,n,r,i){let a=new Set,o=[e];for(;o.length;){let e=o.pop();if(e===t)return!0;if(!(a.has(e)||!n(e))){a.add(e);for(let t of i.trackIds(e)){let i=r(e,t);i&&i.property===`time`&&n(i.target)&&o.push(i.target)}}}return!1}function bd(e){let t=null,n=null,r=null,i=()=>{if(!t){t=new Map,n=new Map,r=new Map;for(let[r,i]of Object.entries(e.items)){i.parent&&t.set(i.parent,[...t.get(i.parent)??[],r]);for(let e of Ru(i))n.set(e,[...n.get(e)??[],r])}for(let[t,n]of Object.entries(e.animations))for(let[e,i]of Object.entries(n.tracks))for(let n of dd(i))r.set(n,[...r.get(n)??[],{animation:t,track:e}])}};return{settings:()=>e.board,item:t=>e.items[t],animation:t=>{let n=e.animations[t];if(!n)return;let{tracks:r,...i}=n;return i},track:(t,n)=>e.animations[t]?.tracks[n],trackIds:t=>Object.keys(e.animations[t]?.tracks??{}),children:e=>(i(),t?.get(e)??[]),binders:e=>(i(),n?.get(e)??[]),trackRefs:e=>(i(),r?.get(e)??[]),maxZ:t=>{let n=0;for(let r of Object.values(e.items))r.parent===t&&(r.z??0)>n&&(n=r.z??0);return n}}}function xd(e,t){let n=t.items?{...e.items}:e.items;for(let[e,r]of Object.entries(t.items??{}))r?n[e]=r:delete n[e];let r=t.animations||t.tracks?{...e.animations}:e.animations;for(let[e,n]of Object.entries(t.animations??{}))n?r[e]={...n,tracks:r[e]?.tracks??{}}:delete r[e];for(let[e,n]of Object.entries(t.tracks??{})){let t=r[e];if(!t)continue;let i={...t.tracks};for(let[e,t]of Object.entries(n))t?i[e]=t:delete i[e];r[e]={...t,tracks:i}}return{board:t.board??e.board,items:n,animations:r}}function Sd(e,t,n={}){let r=_d(bd(e),t,n);return r.ok?{ok:!0,document:xd(e,r.after),before:r.before,after:r.after}:r}function Cd(e,t={}){if(!Qu(e))return{ok:!1,diagnostics:[pd(``,`INVALID_DOCUMENT`,`expected an object`)]};let n=Sd({board:fu.parse({}),items:{},animations:{}},{...Qu(e.board)?{board:e.board}:{},...Qu(e.items)?{items:e.items}:{},...Qu(e.animations)?{animations:e.animations}:{}},t);return n.ok?{ok:!0,document:n.document}:n}R({kind:B(`cohub.board.manifest`),version:B(1),boardId:L().uuid(),title:L().min(1).max(255)});const wd=[`items`,`animations`],Td=R({x:ws().finite(),y:ws().finite(),width:ws().finite().positive(),height:ws().finite().positive()}).strict();R({only:Is(z(wd)).optional(),rect:Td.optional(),within:Ic.optional(),items:Is(L().min(1)).max(5e4).optional(),animations:Is(L().min(1)).max(1e4).optional(),limit:ws().int().min(1).max(5e4).optional(),cursor:L().min(1).optional(),since:ws().int().nonnegative().optional()}).strict().refine(e=>!(e.cursor&&(e.rect||e.within)),{path:[`cursor`],message:`cursor pages by id, so it cannot be combined with rect or within`}).refine(e=>e.since===void 0||Object.entries(e).every(([e,t])=>e===`since`||t===void 0),{path:[`since`],message:`since syncs the whole Board, so it cannot be combined with other read options`}),R({patch:mu,replace:Os().default(!1),cascade:Os().default(!1),dryRun:Os().default(!1),baseVersion:ws().int().nonnegative().optional(),mutationId:L().min(1).max(160).optional(),clientId:L().min(1).max(160).optional()}).strict(),R({path:L().min(1),title:L().min(1).max(255).optional(),document:mu.optional(),mutationId:L().max(160).optional()}).strict(),R({before:ws().int().positive().optional(),limit:ws().int().min(1).max(500).default(200)}).strict();const Ed=L().min(1).max(160);Vs(`type`,[R({commandId:Ed,type:B(`play`),animationId:L().min(1),position:ws().finite().nonnegative().optional(),timeScale:ws().finite().positive().max(4).optional(),seed:L().min(1).max(160).optional()}).strict(),R({commandId:Ed,type:B(`pause`)}).strict(),R({commandId:Ed,type:B(`resume`)}).strict(),R({commandId:Ed,type:B(`seek`),position:ws().finite().nonnegative()}).strict(),R({commandId:Ed,type:B(`next`)}).strict(),R({commandId:Ed,type:B(`stop`)}).strict()]);const Dd=L().min(1).max(160),Od=ws().finite(),kd=Od.min(-1e9).max(1e9),Ad=Od.positive().max(1e8),jd=Od.min(.05).max(8),Md=R({x:kd,y:kd}),Nd=Md.extend({p:Od.min(0).max(1)}),Pd=R({x:kd,y:kd,width:Ad,height:Ad,rotation:Od}),Fd=R({x:kd,y:kd,width:Ad,height:Ad,zoom:jd}),Id=R({itemId:Dd,frame:Pd}),Ld=R({type:B(`state`),client:R({formFactor:z([`desktop`,`mobile`]),scripts:Os().optional()}).optional(),cursor:Md.extend({pointerType:z([`mouse`,`pen`,`touch`]),pressed:Os().optional()}).nullable(),viewport:Fd.nullable().optional(),tool:L().min(1).max(40),selection:R({ids:Is(Dd).max(64),count:ws().int().nonnegative().max(5e4),bounds:Pd.nullable()}),editingId:Dd.nullable()}),Rd=Vs(`kind`,[R({kind:B(`draw`),id:Dd,itemId:Dd,color:L().min(1).max(64),size:Od.positive().max(256),from:ws().int().nonnegative().max(1e5),points:Is(Nd).min(1).max(64)}),R({kind:B(`arrow`),id:Dd,itemId:Dd,start:Md,current:Md,startItemId:Dd.nullable().default(null),endItemId:Dd.nullable().default(null),color:L().min(1).max(64),size:Od.positive().max(256).default(bc)}),R({kind:B(`box`),id:Dd,itemId:Dd,shape:z([`shape`,`frame`]),start:Md,current:Md,color:L().min(1).max(64),geometry:L().min(1).max(40).default(`rectangle`)}),R({kind:B(`transform`),id:Dd,mode:z([`translate`,`resize`,`rotate`,`arrow`]),items:Is(Id).max(64),bounds:Pd.nullable()})]),zd=[`heart`,`star`,`spark`,`confetti`],Bd=1024,Vd=Vs(`type`,[Ld,R({type:B(`gesture`),gesture:Rd}),R({type:B(`gesture.end`),gestureId:Dd,resultingItemIds:Is(Dd).max(64)}),R({type:B(`gesture.cancel`),gestureId:Dd}),R({type:B(`reaction`),reaction:z(zd),at:Md}),R({type:B(`script`),owner:Dd,event:L().min(1).max(64),data:yc().refine(e=>JSON.stringify(e).length<=Bd,`Broadcast data exceeds ${Bd} characters of JSON.`)})]);R({spaceId:L().uuid(),boardId:L().uuid(),seq:ws().int().nonnegative(),update:Vd});const Hd={".txt":`text/plain`,".md":`text/markdown`,".markdown":`text/markdown`,".json":`application/json`,".jsonl":`application/x-ndjson`,".csv":`text/csv`,".board":`application/json`,".js":`text/javascript`,".mjs":`text/javascript`,".cjs":`text/javascript`,".ts":`text/typescript`,".tsx":`text/tsx`,".jsx":`text/jsx`,".svelte":`text/x-svelte`,".css":`text/css`,".scss":`text/x-scss`,".html":`text/html`,".htm":`text/html`,".xml":`application/xml`,".yaml":`application/yaml`,".yml":`application/yaml`,".toml":`application/toml`,".ini":`text/plain`,".env":`text/plain`,".sh":`text/x-shellscript`,".bash":`text/x-shellscript`,".py":`text/x-python`,".go":`text/x-go`,".rs":`text/x-rust`,".java":`text/x-java-source`,".c":`text/x-c`,".h":`text/x-c`,".cpp":`text/x-c++src`,".hpp":`text/x-c++hdr`,".sql":`application/sql`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".avif":`image/avif`,".bmp":`image/bmp`,".ico":`image/x-icon`,".mp4":`video/mp4`,".webm":`video/webm`,".mov":`video/quicktime`,".m4v":`video/x-m4v`,".ogv":`video/ogg`,".avi":`video/x-msvideo`,".mp3":`audio/mpeg`,".wav":`audio/wav`,".ogg":`audio/ogg`,".m4a":`audio/mp4`,".aac":`audio/aac`,".flac":`audio/flac`,".opus":`audio/ogg`,".glb":`model/gltf-binary`,".gltf":`model/gltf+json`,".stl":`model/stl`,".obj":`model/obj`,".3mf":`model/3mf`,".usdz":`model/vnd.usdz+zip`,".mtl":`text/plain`,".pdf":`application/pdf`,".wasm":`application/wasm`,".woff":`font/woff`,".woff2":`font/woff2`,".zip":`application/zip`,".gz":`application/gzip`,".tar":`application/x-tar`,".rar":`application/vnd.rar`,".7z":`application/x-7z-compressed`,".exe":`application/x-msdownload`,".dmg":`application/x-apple-diskimage`,".deb":`application/vnd.debian.binary-package`,".rpm":`application/x-rpm`},Ud={dockerfile:`text/x-dockerfile`,makefile:`text/x-makefile`};function Wd(e){let t=(e.split(/[\\/]/).pop()??``).toLowerCase(),n=Object.hasOwn(Ud,t)?Ud[t]:void 0;if(n)return n;let r=t.lastIndexOf(`.`);return(r>0?Hd[t.slice(r)]:void 0)||(t.startsWith(`.`)?`text/plain`:null)}function Gd(e){return e&&e.split(`;`)[0]?.trim().toLowerCase()||null}const Kd={"model/gltf-binary":`glb`,"model/gltf+json":`gltf`,"model/stl":`stl`,"model/obj":`obj`};function qd(e,t){let n=e=>{let t=Gd(e);return t&&Object.hasOwn(Kd,t)?Kd[t]:void 0};return n(Wd(e))??n(t)??null}const Jd=[`motion`,`gamepad`,`microphone`,`camera`,`location`],Yd=[`below`,`above`,`filter`],Xd=[`normal`,`add`,`screen`,`multiply`],Zd=new WeakMap;function Qd(e){let t=e.board?.scripts,n=Zd.get(e.items);if(n&&n.scripts===t)return n.list;let r=[];for(let[e,n]of Object.entries(t??{}))n.enabled&&r.push({id:e,script:n,item:null});for(let[t,n]of Object.entries(e.items))n.script?.enabled&&r.push({id:t,script:n.script,item:n});return Zd.set(e.items,{scripts:t,list:r}),r}function $d(e,t){return!!(e.board?.scripts&&Object.hasOwn(e.board.scripts,t))}function ef(e,t){if(e===t)return!0;if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!ef(e[n],t[n]))return!1;return!0}let n=e,r=t,i=0;for(let e of Object.keys(n))if(n[e]!==void 0&&(i+=1,!ef(n[e],r[e])))return!1;for(let e of Object.keys(r))r[e]!==void 0&&--i;return i===0}const tf=new WeakMap,nf=new WeakMap;function rf(e){let t=tf.get(e);if(!t){t=new Map;for(let[n,r]of Object.entries(e)){if(!r.parent)continue;let e=t.get(r.parent);e?e.push(n):t.set(r.parent,[n])}tf.set(e,t)}return t}function af(e,t){return $d(e,t)?e.board?.scripts?.[t]:e.items[t]?.script}function of(e,t){if($d(e,t)){let t=nf.get(e.items);return t||(t=new Set(Object.keys(e.items)),nf.set(e.items,t)),t}let n=e.items[t],r=new Set([t]);for(let t of Object.values(n?.script?.targets??{}))e.items[t]&&r.add(t);if(n?.type!==`frame`)return r;let i=rf(e.items),a=new Set([t]),o=[t];for(let e=0;o.length&&e<64;e++)for(let e of o.splice(0))for(let t of i.get(e)??[])a.has(t)||(a.add(t),r.add(t),o.push(t));return r}function sf(e,t,n,r){let i={},a=!1;for(let o of n){let n=t.items[o],s=e.get(o);!n||s===n||(e.set(o,n),!(s&&ef(s,n))&&(i[o]=n,a=!0,r?.(o,s?`changed`:`added`)))}if(e.size>n.size)for(let t of e.keys())n.has(t)||(e.delete(t),i[t]=null,a=!0,r?.(t,`removed`));return a?i:null}const cf={"browser:devicemotion":`motion`,"browser:deviceorientation":`motion`,"browser:deviceorientationabsolute":`motion`,"browser:gamepads":`gamepad`,"browser:audio":`microphone`,"browser:video":`camera`,"browser:position":`location`},lf=e=>Object.hasOwn(cf,e)?cf[e]:void 0,uf=new Set([`browser:gamepads`,`browser:position`,`browser:video`]),df=e=>uf.has(e);function ff(e){return Object.fromEntries(Jd.map(t=>[t,e]))}const pf={mode:`export`,pointer:`fine`,orientation:`landscape`,angle:0,reducedMotion:!1,locale:null,senses:ff(`unavailable`)};function mf(e){e.type===`browser:video`&&e.data.frame?.close?.()}const hf=`$f32`;function gf(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Float32Array(n.buffer)}function _f(e){let t=JSON.parse(e,(e,t)=>t&&typeof t==`object`&&typeof t[hf]==`string`&&Object.keys(t).length===1?gf(t[hf]):t),n=t?.inputs;if(t?.version!==1||!Array.isArray(n))throw Error(`Not a Board input recording: expected { version: 1, inputs: [...] }.`);let r=0;for(let[e,t]of n.entries()){if(!t||typeof t.t!=`number`||!(t.t>=r)||typeof t.type!=`string`||!lf(t.type)||t.type===`browser:video`)throw Error(`inputs[${e}] needs a t no earlier than the one before and a browser event type other than browser:video.`);r=t.t}return t}function vf(e,t,n){if(!e)return[];let r=[];for(let{t:i,type:a,data:o}of e.inputs){if(i>n)break;i>t&&r.push({type:a,data:o})}return r}function yf(e,t){if(e.type!==t.type)return!1;if(t.type===`viewchange`||t.type===`selectionchange`||t.type===`peerschange`||df(t.type))return!0;if(t.type===`pointermove`)return e.pointerId===t.pointerId;if(t.type!==`gesture`)return!1;let n=e.data,r=t.data;return n.id===r.id&&n.phase===`update`&&r.phase===`update`}function bf(e,t){return!e||t.type===`viewchange`||e.listens.includes(t.type)}function xf(e,t){let n=e.length-1;for(;n>=0&&!yf(e[n],t);)n--;return n>=0&&(t.type!==`pointermove`||n===e.length-1)&&mf(e.splice(n,1)[0]),e.length>=128?(mf(t),!1):(e.push(t),!0)}function Sf(e,t,n){let r=n;if(!r||typeof r.target!=`string`||typeof r.type!=`string`||!r.type)throw Error(`emit() takes a target id and an event type.`);let{target:i,type:a}=r;if(!$d(e,i)&&!of(e,t).has(i))throw Error(`emit() from ${t} cannot reach ${i}: it is neither in scope nor a Board script.`);let o=typeof r.depth==`number`&&Number.isSafeInteger(r.depth)&&r.depth>0?r.depth:1;if(o>16)throw Error(`emit(${i}, "${a}") from ${t} is ${o} handlers deep, past the limit of 16: handlers keep answering each other. Emit from onFrame() to send it on the next step.`);return{target:i,event:{type:a,data:r.data,depth:o,...r.remote===!0?{remote:!0}:{}}}}const Cf=/^(pointer|key|browser:)|^(click|focus|blur|change|selectionchange|transformend|viewchange|envchange|gesture|peerschange)$/;function wf(e){let t=e,n=t?.type;if(typeof n!=`string`||!n||n.length>64)throw Error(`broadcast() takes an event type of 1–64 characters.`);if(Cf.test(n))throw Error(`broadcast("${n}"): input and host event types are reserved.`);let r;try{r=JSON.stringify(t?.data??null)}catch{}if(r===void 0)throw Error(`broadcast("${n}") data must be JSON.`);if(r.length>1024)throw Error(`broadcast("${n}") data exceeds ${Bd} characters of JSON.`);let i=typeof t?.depth==`number`&&Number.isSafeInteger(t.depth)&&t.depth>0?t.depth:1;if(i>16)throw Error(`broadcast("${n}") is ${i} handlers deep, past the limit of 16: handlers keep answering each other. Broadcast from onFrame() to send it on the next step.`);return{type:n,data:JSON.parse(r),depth:i,peer:null}}function Tf(e){let t=[],n=0,r=new Map;return{get size(){return t.length},push(i,a,o){let s=r.get(a)??0;if(s>=128)throw Error(`emit(${a}, "${o.type}") from ${i}: ${a} already has 128 events waiting.`);r.set(a,s+1),t.push({rank:e().get(i)??2**53-1,seq:n++,target:a,event:o})},take(){let e=t.sort((e,t)=>e.rank-t.rank||e.seq-t.seq);t=[],r.clear();let n=new Map;for(let{target:t,event:r}of e)n.set(t,[...n.get(t)??[],r]);return n}}}function V(e,t){return{x:e,y:t}}const Ef={x:0,y:0,zoom:1};function Df(e,t=.001){let n=Number.isFinite(e)?e:Ef.zoom;return Math.min(8,Math.max(t,n))}function Of(e,t=Ef){let n=Number.isFinite(t.x)?t.x:Ef.x,r=Number.isFinite(t.y)?t.y:Ef.y,i=Number.isFinite(t.zoom)?Df(t.zoom):Ef.zoom;return{x:Number.isFinite(e.x)?e.x:n,y:Number.isFinite(e.y)?e.y:r,zoom:Number.isFinite(e.zoom)?Df(e.zoom):i}}function kf(e){return e*Math.PI/180}function Af(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function jf(e){return V(e.x+e.width/2,e.y+e.height/2)}function Mf(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Nf(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);return{x:t,y:n,width:r-t,height:i-n}}function Pf(e,t,n){let r=Math.cos(n),i=Math.sin(n),a=e.x-t.x,o=e.y-t.y;return{x:t.x+a*r-o*i,y:t.y+a*i+o*r}}function Ff(e,t){let n=(t?.filter?.blur??0)*3,r=t?.shadow;if(!n&&!r)return e;let i=r?(r.blur??Xc.blur)*1.5:0,a=r?r.x??Xc.x:0,o=r?r.y??Xc.y:0,s=n+Math.max(0,i-a),c=n+Math.max(0,i-o);return{x:e.x-s,y:e.y-c,width:e.width+s+n+Math.max(0,i+a),height:e.height+c+n+Math.max(0,i+o)}}function If(e){let t=e.rotation||0;if(t===0)return Af(e);let n=jf(Af(e)),r=e.width/2,i=e.height/2,a=kf(t),o=Math.abs(Math.cos(a)),s=Math.abs(Math.sin(a)),c=r*o+i*s,l=r*s+i*o;return{x:n.x-c,y:n.y-l,width:c*2,height:l*2}}function Lf(e,t){let n=Df(e.zoom);return Of({x:t.width/2-e.centerX*n,y:t.height/2-e.centerY*n,zoom:n})}function Rf(e,t,n={}){let r=Math.max(0,Number.isFinite(n.padding)?n.padding:32),i=Math.max(1,t.width-r*2),a=Math.max(1,t.height-r*2),o=n.fit===`cover`?Math.max(i/e.width,a/e.height):Math.min(i/e.width,a/e.height),s=Df(n.minZoom??0),c=Df(n.maxZoom??8),l=Math.min(Math.max(o,Math.min(s,c)),Math.max(s,c)),u=jf(e);return Lf({centerX:u.x,centerY:u.y,zoom:l},t)}function zf(e,t){if(typeof e!=`string`)return e;let n=t(e);return n?If(n):null}function Bf(e,t,n,r={}){let i=zf(e,t);return i?Rf(i,n,r):null}const Vf={passes:16,source:65536,sprites:65536,stateEdge:1024,texel:1024,uniformSlots:128},Hf={float:1,int:1,vec2:2,vec3:3,vec4:4},Uf=/^[A-Za-z][A-Za-z0-9_]{0,62}$/;function Wf(e){let t=[],n=0;for(let[r,i]of Object.entries(e??{})){if(!Uf.test(r)||r.includes(`__`))throw Error(`Invalid uniform name: ${r}`);let e=typeof i==`string`?/^(float|int|vec2|vec3|vec4)(?:\[(\d{1,3})\])?$/.exec(i):null;if(!e)throw Error(`Uniform ${r} must be float, int, vec2, vec3 or vec4, optionally with [length].`);let a=e[1],o=e[2]===void 0?null:Number(e[2]);if(o!==null&&(o<1||o>256))throw Error(`Uniform ${r} takes 1 to 256 elements.`);n+=o??1,t.push({name:r,type:a,length:o})}if(n>Vf.uniformSlots)throw Error(`Shader uniforms take at most ${Vf.uniformSlots} vectors.`);return t}function Gf(e,t){let n=Hf[e.type]*(e.length??1);if(t===void 0)return Array(n).fill(0);let r=typeof t==`number`?[t]:[...t];if(e.length===null?r.length!==n:r.length>n||r.length%Hf[e.type])return null;for(;r.length<n;)r.push(0);return r}function Kf(e,t){return t.layer??e.layer??`above`}function qf(e,t){return(e.name===void 0?void 0:t?.[e.name])??e.enabled??!0}function Jf(e){let t=[];for(let[n,r]of Object.entries(e??{}))!Uf.test(n)||n.includes(`__`)||(r.type===`number`||r.type===`boolean`?t.push({name:n,type:`float`}):r.type===`color`&&t.push({name:n,type:`vec4`}));return t}function Yf(e){if(!e||typeof e!=`object`)throw Error(`shader must be an object.`);let t=e;if(t.layer!==void 0&&!Yd.includes(t.layer))throw Error(`shader.layer must be ${Yd.join(`, `)}.`);if(t.surfaces!==void 0&&typeof t.surfaces!=`boolean`)throw Error(`shader.surfaces must be a boolean.`);if(!Array.isArray(t.passes)||t.passes.length<1||t.passes.length>Vf.passes)throw Error(`shader.passes takes 1 to ${Vf.passes} passes.`);let n=new Set;for(let e of t.passes){if(!e||typeof e.glsl!=`string`||!e.glsl.trim())throw Error(`Each shader pass needs glsl source.`);if(e.glsl.length>Vf.source)throw Error(`A shader pass exceeds 64 KB of source.`);if(e.layer!==void 0&&!Yd.includes(e.layer))throw Error(`A pass layer must be ${Yd.join(`, `)}.`);if(e.sprites!==void 0){if(!Number.isSafeInteger(e.sprites)||e.sprites<1||e.sprites>Vf.sprites)throw Error(`sprites must be an integer from 1 to ${Vf.sprites}.`);if(Kf(t,e)===`filter`)throw Error(`Filter passes draw over the owner's box; they cannot draw sprites.`)}if(e.texel!==void 0){if(typeof e.texel!=`number`||!(e.texel>0&&e.texel<=Vf.texel))throw Error(`texel must be a number above 0 and up to ${Vf.texel}.`);if(e.sprites!==void 0||Kf(t,e)===`filter`)throw Error(`texel shades a pass over its box; sprite and filter passes cannot take it.`)}if(e.name!==void 0){if(typeof e.name!=`string`||!Uf.test(e.name))throw Error(`Invalid pass name: ${String(e.name)}`);if(n.has(e.name))throw Error(`Pass names must be unique: ${e.name}`);n.add(e.name)}if(e.enabled!==void 0&&typeof e.enabled!=`boolean`)throw Error(`A pass's enabled must be a boolean.`);if(e.enabled===!1&&e.name===void 0)throw Error(`A pass that starts off needs a name to turn it on.`);if(e.blend!==void 0&&!Xd.includes(e.blend))throw Error(`blend must be ${Xd.join(`, `)}.`)}Wf(t.uniforms);let r=t.state;if(r!==void 0){if(!r||typeof r.glsl!=`string`||!r.glsl.trim())throw Error(`shader.state needs glsl source.`);if(r.glsl.length>Vf.source)throw Error(`shader.state exceeds 64 KB of source.`);for(let e of[r.width,r.height])if(!Number.isSafeInteger(e)||e<1||e>Vf.stateEdge)throw Error(`shader.state width and height must be integers from 1 to ${Vf.stateEdge}.`);if(r.precision!==void 0&&r.precision!==`byte`&&r.precision!==`half`)throw Error(`shader.state.precision must be byte or half.`);let e=r.bounds;if(e!==void 0&&!(e&&[e.x,e.y].every(Number.isFinite)&&[e.width,e.height].every(e=>Number.isFinite(e)&&e>0)))throw Error(`shader.state.bounds must be { x, y, width, height } with a positive size.`)}}const Xf=new WeakMap;function Zf(e){let t=Xf.get(e);if(t===void 0){let n=JSON.stringify(e),r=2166136261,i=5381;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);r=Math.imul(r^t,16777619)>>>0,i=(Math.imul(i,33)^t)>>>0}t=`${n.length.toString(36)}.${r.toString(36)}.${i.toString(36)}`,Xf.set(e,t)}return t}function Qf(e){let t=tu(e);if(!t.ok)throw Error(t.diagnostics[0]?.message??`Invalid script item.`);return t.item}function $f(e,t){return ep(e,t)??Qf($u(e,t))}function ep(e,t){let n={...e};for(let r in t){let i=t[r];if(r===`position`){if(!i||typeof i!=`object`)return null;let{x:t=e.position.x,y:r=e.position.y,...a}=i;if(!Number.isFinite(t)||!Number.isFinite(r))return null;for(let e in a)return null;n.position={x:t,y:r};continue}if(r===`rotation`||r===`z`){if(!Number.isFinite(i))return null}else if(r===`opacity`){if(typeof i!=`number`||!(i>=0&&i<=1))return null}else if(r!==`visible`||typeof i!=`boolean`)return null;n[r]=i}return n}const tp=new Set([`position`,`size`,`rotation`,`scale`,`opacity`,`style`,`props`,`z`]),np=new Set([`default`,`pointer`,`grab`,`grabbing`,`crosshair`,`text`,`move`,`ew-resize`,`ns-resize`,`not-allowed`]),rp=new Set([`select`,`hand`,`text`,`shape`,`draw`,`arrow`,`frame`]);function ip(e){if(!e||typeof e!=`object`||!e.patches||!e.world||!e.screen||!e.hits||!Array.isArray(e.listens))throw Error(`Invalid script output.`);if(e.anchor){let{item:t,point:n}=e.anchor;if(typeof t!=`string`||!t||n&&![n.x,n.y].every(e=>Number.isFinite(e)&&e>=0&&e<=1))throw Error(`Invalid screen scene anchor.`)}if(e.shader!==void 0&&Yf(e.shader),e.frameRate!==void 0&&!(Number.isFinite(e.frameRate)&&e.frameRate>=1&&e.frameRate<=60))throw Error(`frameRate must be a number from 1 to 60.`);if(e.parameters){if(Object.keys(e.parameters).length>64)throw Error(`A script may declare at most 64 parameters.`);for(let t of Object.values(e.parameters)){if(!t||![`number`,`boolean`,`string`,`color`].includes(t.type))throw Error(`Invalid script parameter type.`);if(t.label!==void 0&&typeof t.label!=`string`)throw Error(`Invalid script parameter label.`);if([t.min,t.max,t.step].some(e=>e!==void 0&&!Number.isFinite(e)))throw Error(`Invalid script parameter range.`)}}if(Object.keys(e.world).some(t=>Object.hasOwn(e.screen,t)))throw Error(`Temporary item IDs must be unique across scenes.`);if(Object.keys(e.world).length+Object.keys(e.screen).length>1e3||Object.keys(e.hits).length>1e3)throw Error(`A script may create at most 1000 temporary items or hit regions.`);for(let t of Object.values(e.patches))if(!t||typeof t!=`object`||Object.keys(t).some(e=>!tp.has(e)))throw Error(`Scripts may only present ${[...tp].join(`, `)}.`);for(let t of Object.values(e.hits)){if(!t||typeof t!=`object`)throw Error(`Invalid script hit region.`);if(t.cursor&&!np.has(t.cursor))throw Error(`Invalid script cursor.`);if(t.tools!==void 0&&(!Array.isArray(t.tools)||t.tools.some(e=>!rp.has(e))))throw Error(`Invalid script hit tools.`);if(`target`in t){if(t.target!==`self`||`item`in t||`x`in t)throw Error(`Invalid script hit target.`)}else if(`item`in t){if(typeof t.item!=`string`||!(Object.hasOwn(e.world,t.item)||Object.hasOwn(e.screen,t.item))||`x`in t)throw Error(`Hit items must belong to the temporary scene.`)}else if(![t.x,t.y,t.width,t.height].every(Number.isFinite)||t.width<0||t.height<0)throw Error(`Invalid script hit region.`)}}function ap(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619)>>>0;return`~script-${t.toString(36)}-`}const op=new WeakMap,sp=new WeakMap;function cp(e,t){return Qd(e).map(({id:e})=>e).filter(e=>t.has(e))}function lp(e,t){let n=sp.get(e);n||(n=new Map,sp.set(e,n));let r=n.get(t);return r||(r=of(e,t),n.set(t,r)),r}function up(e,t,n,r,i){let a=new Map,o=new Map(Object.entries(i).map(([e,t])=>[e,Qf(t)])),s=0;for(let[i,c]of o){if(!/^[a-zA-Z0-9_-]{1,80}$/.test(i))throw Error(`Temporary IDs must be 1–80 letters, digits, underscores or hyphens.`);if(c.script)throw Error(`Temporary items cannot start scripts.`);if(c.parent&&!o.has(c.parent))throw Error(`Temporary parents must belong to the same scene.`);let l=c.parent,u=new Set([i]);for(;l;){if(u.has(l))throw Error(`Temporary parents must not form a cycle.`);u.add(l);let e=o.get(l);if(!e)throw Error(`Temporary parent is missing.`);if(e.type!==`frame`)throw Error(`Only frames can contain temporary items.`);l=e.parent}let d=`${n}${i}`;if(e.items[d])throw Error(`Temporary item ID conflicts with the document.`);let f={...c,parent:c.parent?`${n}${c.parent}`:r,z:c.z??s++};if(f.type===`arrow`){let e=e=>`item`in e&&o.has(e.item)?{...e,item:`${n}${e.item}`}:e;if([f.props.start,f.props.end].some(e=>`item`in e&&!o.has(e.item)&&!t.has(e.item)))continue;f.props={...f.props,start:e(f.props.start),end:e(f.props.end)}}a.set(d,f)}return{root:r,items:a}}function dp(e,t,n){let r=op.get(n);if(r?.document===e&&r.owner===t)return r;let i=lp(e,t);if(ip(n),$d(e,t)&&Object.values(n.hits).some(e=>!(`item`in e)))throw Error(`A Board script takes input only on its scene items.`);let a=new Map;for(let[t,r]of Object.entries(n.patches)){let n=e.items[t];n&&i.has(t)&&a.set(t,{base:n,item:$f(n,r)})}let o=ap(t),s={document:e,owner:t,world:up(e,i,o,`${o}~world`,n.world),screen:up(e,i,o,`${o}~screen`,n.screen),presented:a};return op.set(n,s),s}function fp(e,t,n,r=new Map,i,a,o){let s=new Map(r),c=new Map;if(n.size===0)return s;let l=cp(e,n);for(let[r,o]of l.entries()){let l=n.get(o);if(l)try{let n=new Map,a=dp(e,o,l);for(let[t,r]of a.presented){let i=s.get(t)??e.items[t];if(!i)continue;let o=r;o.base!==i&&(o={base:i,item:$f(i,l.patches[t]??{})},a.presented.set(t,o)),n.set(t,o.item)}let u=$d(e,o),d=n.get(o)??s.get(o)??e.items[o];if(u&&a.world.items.size){n.set(a.world.root,Qf({type:`frame`,size:{width:1,height:1},z:1e8+r,props:{decoration:`none`,clip:!1}}));for(let[e,t]of a.world.items)n.set(e,t)}else if(d&&a.world.items.size){let e=t.layout.box(o);n.set(a.world.root,Qf({type:`frame`,parent:d.parent,position:d.position,rotation:d.rotation,scale:d.scale,origin:d.origin,opacity:d.opacity,size:{width:Math.max(1,e.width),height:Math.max(1,e.height)},z:(d.z??0)+.001,props:{decoration:`none`,clip:!1}}));for(let[e,t]of a.world.items)n.set(e,t)}if(i&&a.screen.items.size){n.set(a.screen.root,Qf({type:`frame`,position:{x:0,y:0},scale:1/i.zoom,origin:{x:0,y:0},size:{width:1,height:1},z:1e9+r,props:{decoration:`none`,clip:!1}}));for(let[e,t]of a.screen.items)n.set(e,t);c.set(o,a.screen.root)}for(let[e,t]of n)s.set(e,t)}catch(e){if(!a)throw e;a(o,e)}}if(c.size){let t=o??Bu(t=>s.get(t)??e.items[t]);for(let[r,a]of c){let o=s.get(a),c=n.get(r)?.anchor;if(!c&&$d(e,r)){o&&s.set(a,{...o,position:{x:-(i?.x??0)/(i?.zoom??1),y:-(i?.y??0)/(i?.zoom??1)}});continue}let l=c?.item??r,u=!!e.items[l]&&lp(e,r).has(l),d=u?t.box(l):{width:0,height:0};o&&s.set(a,{...o,opacity:u?o.opacity:0,position:u?Su(t.matrix(l),{x:(c?.point?.x??0)*d.width,y:(c?.point?.y??0)*d.height}):o.position})}}return s}function pp(e,t,n){let r=`item`in n?`${ap(t)}${n.item}`:t,i=e.get(r);if(!i||e.opacity(r)<=0)return null;let a=e.layout.box(r);return{id:r,item:i,rect:`x`in n?n:{x:0,y:0,width:a.width,height:a.height}}}function mp(e,t,n,r){let{x:i,y:a,width:o,height:s}=t.rect;if(o<=0||s<=0)return!1;let c=e.layout.matrix(t.id),l=[Su(c,{x:i,y:a}),Su(c,{x:i+o,y:a}),Su(c,{x:i,y:a+s}),Su(c,{x:i+o,y:a+s})],u=l.map(e=>e.x*n.zoom+n.x),d=l.map(e=>e.y*n.zoom+n.y);return Math.max(...u)>0&&Math.min(...u)<r.width&&Math.max(...d)>0&&Math.min(...d)<r.height}const hp=e=>e;function gp(e,t,n,r){let i=3*e,a=3*(n-e)-i,o=1-i-a,s=3*t,c=3*(r-t)-s,l=1-s-c,u=e=>((o*e+a)*e+i)*e,d=e=>((l*e+c)*e+s)*e,f=e=>(3*o*e+2*a)*e+i;return e=>{if(e<=0)return 0;if(e>=1)return 1;let t=e;for(let n=0;n<8;n+=1){let n=u(t)-e;if(Math.abs(n)<1e-6)return d(t);let r=f(t);if(Math.abs(r)<1e-6)break;t-=n/r}let n=0,r=1;t=e;for(let i=0;i<32;i+=1){let i=u(t);if(Math.abs(i-e)<1e-6)break;i<e?n=t:r=t,t=(n+r)/2}return d(t)}}function _p(e,t){let n=t===`jump-none`?e-1:t===`jump-both`?e+1:e,r=t===`start`||t===`jump-start`||t===`jump-both`;return t=>{if(t>=1)return 1;let i=Math.floor(t*e)+ +!!r;return Math.min(1,Math.max(0,i/Math.max(1,n)))}}const vp={linear:hp,ease:gp(.25,.1,.25,1),"ease-in":gp(.42,0,1,1),"ease-out":gp(0,0,.58,1),"ease-in-out":gp(.42,0,.58,1),"step-start":_p(1,`start`),"step-end":_p(1,`end`)},yp=new Map;function bp(e){if(!e)return hp;let t=e.trim(),n=vp[t];if(n)return n;let r=yp.get(t);if(r)return r;let i=hp,a=/^cubic-bezier\(([^)]+)\)$/.exec(t),o=/^steps\(\s*(\d+)\s*(?:,\s*([a-z-]+)\s*)?\)$/.exec(t);if(a?.[1]){let[e=0,t=0,n=1,r=1]=a[1].split(`,`).map(Number);i=gp(e,t,n,r)}else o?.[1]&&(i=_p(Number(o[1]),o[2]??`end`));return yp.size>512&&yp.clear(),yp.set(t,i),i}function xp(e,t){let n=Math.max(0,t-e.delay);return e.loop||e.play===`always`?e.duration>0?n%e.duration:0:n<=e.duration?n:e.end===`reset`?null:e.duration}function Sp(e){let t=e.keyframes.map(e=>e.value);return t.every(e=>typeof e==`number`)?`number`:t.every(e=>Kc.safeParse(e).success)?`color`:`discrete`}function Cp(e,t,n,r){let i=ld(r,n.property);if(!i.ok)return null;let a=r===`script`||n.property.startsWith(`script.params.`)?Sp(n):i.spec.kind,o=new Float64Array(n.keyframes.length),s=[],c=[];return n.keyframes.forEach((e,t)=>{o[t]=e.at,s.push(e.value),c.push(bp(e.ease))}),{id:t,animationId:e,target:n.target,property:n.property,path:n.property.split(`.`),kind:a,multiplicative:!!i.spec.multiplicative,composite:n.composite,spline:n.interpolation===`spline`&&a===`vec2`,step:n.interpolation===`step`||a===`discrete`,orient:!!n.orient&&a===`vec2`&&n.property===`position`,times:o,values:s,eases:c,start:o[0]??0}}function wp(e){let t=new Map;for(let[n,r]of Object.entries(e.animations))t.set(n,Tp(n,r,e));let n=new Map([...t.keys()].map(e=>[e,0]));for(let e of t.values())for(let t of e.children)n.set(t.target,(n.get(t.target)??0)+1);let r=[...t.keys()].filter(e=>n.get(e)===0).sort();for(let e=0;e<r.length;e+=1){let i=t.get(r[e]);for(let e of i?.children??[]){let t=(n.get(e.target)??1)-1;n.set(e.target,t),t===0&&r.push(e.target)}}if(r.length!==t.size)throw Error(`Animation graph contains a cycle`);return{animations:t,document:e,order:r}}function Tp(e,t,n){let{tracks:r,...i}=t,a=[],o=[];for(let[t,i]of Object.entries(r).sort(([e],[t])=>e<t?-1:+(e>t))){let r=i.target===`camera`?Pc:n.animations[i.target]?`animation`:n.board.scripts?.[i.target]?`script`:n.items[i.target]?.type;if(!r)continue;let s=Cp(e,t,i,r);s&&(r===`animation`?o:a).push(s)}return{id:e,header:i,tracks:a,children:o}}function Ep(e,t){let n=0,r=e.length-1;if(t<e[0])return-1;if(t>=e[r])return r;for(;n<r;){let i=n+r+1>>1;e[i]<=t?n=i:r=i-1}return n}function Dp(e){return!!e&&typeof e==`object`&&typeof e.x==`number`&&typeof e.y==`number`}function Op(e){return typeof e==`number`?{x:e,y:e}:Dp(e)?e:{x:0,y:0}}const kp=(e,t,n)=>e+(t-e)*n;function Ap(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function jp(e){return`#${Math.max(0,Math.min(16777215,Math.round(e))).toString(16).padStart(6,`0`)}`}function Mp(e,t,n,r){let i=r(e),a=r(t);if(i===null||a===null)return n<1?e:t;let o=typeof i==`number`?{color:i,alpha:1}:i,s=typeof a==`number`?{color:a,alpha:1}:a,c=kp(o.alpha,s.alpha,n),l=e=>c>0?Math.round(kp((o.color>>e&255)*o.alpha,(s.color>>e&255)*s.alpha,n)/c):0,u=jp(l(16)<<16|l(8)<<8|l(0));return c>=1?u:`${u}${Math.round(Math.max(0,c)*255).toString(16).padStart(2,`0`)}`}function Np(e){if(typeof e!=`string`)return null;let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t?.[1])return null;let n=t[1].length===3?[...t[1]].map(e=>e+e).join(``):t[1];return Number.parseInt(n,16)}function Pp(e){if(typeof e==`string`){if(e.trim().toLowerCase()===`transparent`)return{color:0,alpha:0};let t=/^#([0-9a-f]{4}|[0-9a-f]{8})$/i.exec(e.trim());if(t?.[1]){let e=t[1].length===4?[...t[1]].map(e=>e+e).join(``):t[1];return{color:Number.parseInt(e.slice(0,6),16),alpha:Number.parseInt(e.slice(6),16)/255}}}return Np(e)}function Fp(e,t,n,r){let{times:i,values:a}=e,o=a[t],s=a[t+1],c=i[t],l=i[t+1];if(s===void 0||l<=c)return o;let u=e.eases[t+1]((n-c)/(l-c));if(e.step)return u>=1?s:o;switch(e.kind){case`number`:return typeof o==`number`&&typeof s==`number`?kp(o,s,u):o;case`vec2`:case`scale`:{if(e.kind===`scale`&&typeof o==`number`&&typeof s==`number`)return kp(o,s,u);let n=Op(o),r=Op(s);if(e.spline){let e=Op(a[t-1]??o),i=Op(a[t+2]??s);return{x:Ap(e.x,n.x,r.x,i.x,u),y:Ap(e.y,n.y,r.y,i.y,u)}}return{x:kp(n.x,r.x,u),y:kp(n.y,r.y,u)}}case`color`:return Mp(o,s,u,r);default:return u>=1?s:o}}function Ip(e,t,n=Pp){let r=Ep(e.times,t);return r<0?e.values[0]:Fp(e,r,t,n)}function Lp(e,t,n){let r=Math.max(1,(e.times[e.times.length-1]-e.start)/1e3),i=Op(Ip(e,Math.max(e.start,t-r),n)),a=Op(Ip(e,t+r,n));return Math.hypot(a.x-i.x,a.y-i.y)<1e-6?null:Math.atan2(a.y-i.y,a.x-i.x)*180/Math.PI}function Rp(e,t){let n=e;for(let e of t){if(typeof n==`number`&&(e===`x`||e===`y`))return n;if(!n||typeof n!=`object`)return;n=n[e]}return n}function zp(e,t,n,r=0){let i=t[r];if(r===t.length-1)return{...e,[i]:n};let a=e[i];typeof a==`number`&&(a={x:a,y:a});let o=a&&typeof a==`object`?a:{};return{...e,[i]:zp(o,t,n,r+1)}}function Bp(e,t,n){if(e.composite!==`add`)return n;if(e.kind===`number`)return typeof t!=`number`||typeof n!=`number`?n:e.multiplicative?t*n:t+n;if(e.kind===`vec2`||e.kind===`scale`){if(e.multiplicative){if(typeof t==`number`&&typeof n==`number`)return t*n;let e=Op(t??1),r=Op(n);return{x:e.x*r.x,y:e.y*r.y}}let r=Op(t),i=Op(n);return{x:r.x+i.x,y:r.y+i.y}}return n}function Vp(e,t,n,r){let i=t-e.start,a=r-n.start;if(i>=0!=a>=0)return i>=0;let o=Math.abs(i),s=Math.abs(a);return o===s?e.id>n.id:o<s}function Hp(e,t,n={}){let r=n.resolveColor??Pp,i=new Map(t instanceof Map?t:Object.entries(t)),a=new Map;for(let t of e.order){let n=e.animations.get(t),o=i.get(t);if(!(!n||o===void 0))for(let e of n.children){let n=Ip(e,o,r);typeof n==`number`&&(i.set(e.target,Math.max(0,n)),a.set(e.target,t))}}let o=new Map;for(let[t,n]of i){let r=e.animations.get(t);if(r)for(let e of r.tracks){let r=`${e.target}\u0000${e.property}`,i=o.get(r);if(i||(i={target:e.target,path:e.path,winnerTime:0,adds:[]},o.set(r,i)),e.composite===`add`){i.adds.push([e,n]),i.source??=t;continue}(!i.winner||Vp(e,n,i.winner,i.winnerTime))&&(i.winner=e,i.winnerTime=n,i.source=t)}}let s=new Map,c=new Map,l={},u,d=[...o.values()].sort((e,t)=>e.path.length-t.path.length);for(let t of d){let n=t.target===Pc,i=n?void 0:e.document.board.scripts?.[t.target],a=n||i||t.path[0]!==`script`?void 0:e.document.items[t.target]?.script,o=i||a?c.get(t.target)??i??a:void 0;if(t.path[0]===`script`&&!a)continue;let d=a?t.path.slice(1):t.path,f=n||o?void 0:s.get(t.target)??e.document.items[t.target];if(!n&&!o&&!f)continue;let p=n?l[d[0]]:Rp(o??f,d),m=null;t.winner&&(p=Ip(t.winner,t.winnerTime,r),t.winner.orient&&(m=[t.winner,t.winnerTime]));for(let[e,n]of t.adds)p=Bp(e,p,Ip(e,n,r)),e.orient&&!m&&(m=[e,n]);if(n){l[t.path[0]]=p,u??=t.source;continue}if(o){c.set(t.target,zp(o,d,p));continue}let h=zp(f,t.path,p);if(m){let e=Lp(m[0],m[1],r);e!==null&&(h={...h,rotation:f.rotation+e})}s.set(t.target,h)}let f,p=new Set;for(let t=u;t&&!f&&!p.has(t);t=a.get(t))p.add(t),f=e.document.animations[t]?.viewport;return{items:s,scripts:c,camera:l,cameraViewport:f,times:i}}const Up=1e3/30;function Wp(e){let t=[];for(let n of Object.values(e.board.scripts??{}))t.push(n.params);for(let n of Object.values(e.items))n.script&&t.push(n.script.params);return JSON.stringify(t)}function Gp(e){return Object.values(e.animations).some(e=>Object.values(e.tracks).some(e=>/^(script\.)?params\./.test(e.property)))}function Kp(e,t){if(t.size===0)return e;let n=e.board.scripts,r=e.board,i=e.items;for(let[a,o]of t){let t=n?.[a];if(t){r===e.board&&(r={...r,scripts:{...n}}),r.scripts[a]={...t,params:o.params};continue}let s=i[a];s?.script&&(i===e.items&&(i={...i}),i[a]={...s,script:{...s.script,params:o.params}})}return r===e.board&&i===e.items?e:{...e,board:r,items:i}}function qp(e,t){let n=Kp(e,t.scripts);if(t.items.size===0)return n;let r={...n.items};for(let[i,a]of t.items){let t=n.items[i]?.script;r[i]=t&&t!==e.items[i]?.script?{...a,script:t}:a}return{...n,items:r}}function Jp(e){let t=new Map;for(let[n,r]of Object.entries(e)){let i=r.parent&&e[r.parent]&&r.parent!==n?r.parent:``,a=t.get(i)??[];a.push(n),t.set(i,a)}let n=(t,n)=>(e[t]?.z??0)-(e[n]?.z??0)||(t<n?-1:+(t>n));for(let e of t.values())e.sort(n);let r=[],i=new Set,a=e=>{if(!i.has(e)){i.add(e),r.push(e);for(let n of t.get(e)??[])a(n)}};for(let e of t.get(``)??[])a(e);for(let t of Object.keys(e))a(t);return r}function Yp(e,t){let n=e.items,r=new Map,i=new Map;for(let[e,t]of Object.entries(n)){let a=t.parent&&n[t.parent]?t.parent:``,o=r.get(a)??[];o.push(e),r.set(a,o);for(let n of Ru(t))i.set(n,[...i.get(n)??[],e])}let a=Bu(e=>n[e],e=>[...r.get(e)??[],...i.get(e)??[]]),o=new Map,s=(e,r=0)=>{let i=o.get(e);if(i!==void 0)return i;let a=n[e],c=t?.get(e),l=!!(a&&c&&Qp(c)===a)&&r<64;if(l&&a?.parent&&n[a.parent]&&(l=s(a.parent,r+1)),l&&a)for(let e of Ru(a))n[e]&&!s(e,r+1)&&(l=!1);return o.set(e,l),l},c=Jp(n),l=[],u=new Map,d=new Map;for(let e of c){let r=n[e],i=(s(e)?t?.get(e):void 0)??$p(e,r,a);d.set(e,l.length),l.push(i),u.set(e,i)}return{items:l,get:e=>u.get(e),indexOf:e=>d.get(e)??-1,layout:a,children:e=>r.get(e??``)??[],descendants:e=>{let t=[],n=new Set([e]),i=[...r.get(e)??[]];for(;i.length;){let e=i.pop();n.has(e)||(n.add(e),t.push(e),i.push(...r.get(e)??[]))}return t},binders:e=>i.get(e)??[],opacity:e=>Xp(e=>n[e],e),shown:e=>Xp(e=>n[e],e,!0)>0}}function Xp(e,t,n=!1){let r=1,i=t;for(let t=0;i&&t<64;t+=1){let t=e(i);if(!t)break;if(t.visible===!1)return 0;n||(r*=t.opacity),i=t.parent}return r}const Zp=new WeakMap;function Qp(e){return Zp.get(e)}function $p(e,t,n){let r={...t,id:e,frame:n.frame(e)};return Zp.set(r,t),r}function em(e,t,n={}){let r=t?e.animations[t]:void 0;if(t&&!r)throw Error(`Animation ${t} does not exist.`);let i=wp(e),a=new Map,o=new Map;function s(a){let o=new Map;for(let[e,t]of i.animations)t.header.play===`always`&&o.set(e,xp(t.header,a)??0);t&&r&&o.set(t,Math.min(a,r.duration));let s=Hp(i,o,n);return{document:qp(e,s),evaluation:s}}function c(e){if(!Number.isFinite(e)||e<0)throw Error(`Animation time must be finite and non-negative.`);let t=a.get(e);if(!t){t=s(e);let n=a.keys().next().value;a.size>=64&&n!==void 0&&a.delete(n),a.set(e,t)}return t}let l;return{frameAt(e,t){let n=`${t}:${e}`;if(o.has(n))return o.get(n);let r=c(t).document,i={},a=[e];for(;a.length;){let e=a.pop();if(!e||i[e])continue;let t=r.items[e];t&&(i[e]=t,t.parent&&a.push(t.parent),a.push(...Ru(t)))}let s=Yp({...r,items:i}).get(e)?.frame;return o.size>=2048&&o.clear(),o.set(n,s),s},at(e){if(l?.time===e)return l.value;let t=c(e),n,r={...t,get scene(){return n??=Yp(t.document),n}};return l={time:e,value:r},r}}}function tm(e,t=xc){return Math.min(e.width/t.width,e.height/t.height)}function nm(e,t,n,r,i={x:0,y:0,zoom:1},a=xc){let o=tm(n,a);if(!(o>0)||Object.keys(e).length===0)return i;let s=(n.width-a.width*o)/2,c=(n.height-a.height*o)/2,l={x:(i.x-s)/o,y:(i.y-c)/o,zoom:i.zoom/o},u=e.focus===void 0?l:Bf(e.focus,t,a,{padding:48})??l;return e.zoom!==void 0&&(u={...u,zoom:e.zoom}),e.center&&(u=Lf({centerX:e.center.x,centerY:e.center.y,zoom:u.zoom},a)),e.shake&&(u={...u,x:u.x+Math.sin(r/1e3*91.3)*e.shake,y:u.y+Math.cos(r/1e3*77.9)*e.shake}),{x:u.x*o+s,y:u.y*o+c,zoom:u.zoom*o}}const rm=.5,im={top:V(0,-1),right:V(1,0),bottom:V(0,1),left:V(-1,0)};function am(e,t){if(!t)return e;let n=t*Math.PI/180,r=Math.cos(n),i=Math.sin(n);return V(e.x*r-e.y*i,e.x*i+e.y*r)}function om(e,t){let n=[[`left`,e],[`right`,1-e],[`top`,t],[`bottom`,1-t]];return n.sort((e,t)=>e[1]-t[1]),n[0]?.[0]??`right`}function sm(e){return V(e.x+e.width/2,e.y+e.height/2)}function cm(e,t,n,r=4){let i,a;e===`auto`?(i=Gu(t,n),a=Ku(i,.5)):`side`in e?(i=e.side,a=Ku(i,e.offset)):(a=e,i=om(e.x,e.y));let o=Wu(t,a.x,a.y),s=am(im[i],t.rotation);return{point:V(o.x+s.x*r,o.y+s.y*r),normal:s}}function lm(e,t){let n=Su(e,t);return V(n.x,n.y)}function um(e,t,n,r){let i=lm(n,{x:0,y:0}),a=(()=>{if(!Lu(t))return lm(n,t);let e=r(t.item);return e?sm(e):i})();if(Lu(e)){let t=r(e.item);if(t)return{...cm(e.anchor,t,a),item:e.item}}let o=Lu(e)?i:lm(n,e),s=o.x-a.x,c=o.y-a.y,l=Math.hypot(s,c)||1;return{point:o,normal:V(s/l,c/l)}}function dm(e,t,n){let r=[];for(let i=0;i<=20;i+=1){let a=i/20,o=1-a;r.push(V(o*o*e.x+2*o*a*t.x+a*a*n.x,o*o*e.y+2*o*a*t.y+a*a*n.y))}return r}function fm(e,t){let n=Math.abs(e.normal.x)>Math.abs(e.normal.y),r=Math.abs(t.normal.x)>Math.abs(t.normal.y),i=e.point,a=t.point;if(n&&r){let e=i.x+(a.x-i.x)*rm;return[i,V(e,i.y),V(e,a.y),a]}if(!n&&!r){let e=i.y+(a.y-i.y)*rm;return[i,V(i.x,e),V(a.x,e),a]}return n?[i,V(a.x,i.y),a]:[i,V(i.x,a.y),a]}function pm(e,t,n){if(n)return zu(e.point,t.point,n);let r=V((e.point.x+t.point.x)/2,(e.point.y+t.point.y)/2),i=[e,t].filter(e=>e.item).map(e=>e.normal);if(!i.length)return r;let a=i.reduce((e,t)=>e+t.x,0)/i.length,o=i.reduce((e,t)=>e+t.y,0)/i.length,s=Math.hypot(a,o);if(s<1e-4)return r;let c=Math.hypot(t.point.x-e.point.x,t.point.y-e.point.y),l=Math.min(c*.18,96);return V(r.x+a/s*l,r.y+o/s*l)}function mm(e){let t=Math.max(Math.min(e.width,e.height)*.45,24),n=e.x+e.width+4,r=e.y-4,i=e.y+e.height*.3,a=e.x+e.width*.7;return[V(a,r),V(a,r-t),V(n+t,r-t),V(n+t,i),V(n,i)]}function hm(e,t,n){let{props:r}=e;if(Lu(r.start)&&Lu(r.end)&&r.start.item===r.end.item){let e=n(r.start.item);if(e){let t=mm(e),n=t[0],i=t[t.length-1];return{start:{point:n,normal:V(0,-1),item:r.start.item},end:{point:i,normal:V(1,0),item:r.end.item},path:t,mid:t[2]}}}let i=um(r.start,r.end,t,n),a=um(r.end,r.start,t,n),o;return o=r.waypoints.length?[i.point,...r.waypoints.map(e=>lm(t,e)),a.point]:r.route===`orthogonal`?fm(i,a):r.route===`straight`&&!r.bend?[i.point,a.point]:dm(i.point,pm(i,a,r.bend),a.point),{start:i,end:a,path:o,mid:bm(o)}}function gm(e,t){let n=e=>t.get(e)?.frame,r=t.layout.matrix(e.id),i=ym(e,r,n),a=_m.get(e);if(a&&a.key===i)return a.resolved;let o=hm(e,r,n);return _m.set(e,{key:i,resolved:o}),o}const _m=new WeakMap;function vm(e){return e?`${e.x},${e.y},${e.width},${e.height},${e.rotation}`:`-`}function ym(e,t,n){let{start:r,end:i}=e.props;return`${t.join(`,`)}|${Lu(r)?vm(n(r.item)):``}|${Lu(i)?vm(n(i.item)):``}`}function bm(e){if(e.length===0)return V(0,0);if(e.length===1)return e[0];let t=0;for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];t+=Math.hypot(i.x-r.x,i.y-r.y)}let n=0,r=t/2;for(let t=0;t<e.length-1;t+=1){let i=e[t],a=e[t+1],o=Math.hypot(a.x-i.x,a.y-i.y);if(n+o>=r){let e=o>0?(r-n)/o:0;return V(i.x+(a.x-i.x)*e,i.y+(a.y-i.y)*e)}n+=o}return e[e.length-1]}function xm(e,t){if(e.length<2)return e[0]??V(0,0);let n=[],r=0;for(let t=0;t<e.length-1;t+=1){let i=e[t],a=e[t+1],o=Math.hypot(a.x-i.x,a.y-i.y);n.push(o),r+=o}let i=Math.min(1,Math.max(0,t))*r;for(let t=0;t<n.length;t+=1){let r=n[t];if(i<=r){let n=e[t],a=e[t+1],o=r>0?i/r:0;return V(n.x+(a.x-n.x)*o,n.y+(a.y-n.y)*o)}i-=r}return e[e.length-1]}function Sm(e,t=bc){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of e.path)n=Math.min(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.x),a=Math.max(a,t.y);let o=Math.max(8,t*2);return{x:n-o,y:r-o,width:Math.max(1,i-n+o*2),height:Math.max(1,a-r+o*2)}}const{PI:Cm}=Math;Cm+1e-4;const{min:wm}=Math,Tm=Pu,Em=Fu;function Dm(e,t){if(t===void 0||t>=1)return e;if(t<=0)return[];if(e.length<2)return e;let n=0;for(let t=1;t<e.length;t+=1){let r=e[t-1],i=e[t];n+=Math.hypot(i.x-r.x,i.y-r.y)}let r=n*t,i=[e[0]];for(let t=1;t<e.length;t+=1){let n=e[t-1],a=e[t],o=Math.hypot(a.x-n.x,a.y-n.y);if(o>=r){let e=o>0?r/o:0;return i.push({x:n.x+(a.x-n.x)*e,y:n.y+(a.y-n.y)*e,p:n.p+(a.p-n.p)*e}),i}i.push(a),r-=o}return i}function Om(e,t){if(t===0||t===e.length-1)return!0;let n=e[t-1],r=e[t],i=e[t+1];if(!n||!r||!i)return!1;let a=r.x-n.x,o=r.y-n.y,s=i.x-r.x,c=i.y-r.y,l=Math.hypot(a,o),u=Math.hypot(s,c);return l<1e-6||u<1e-6||(a*s+o*c)/(l*u)<.92}function km(e,t){let n=e[t],r=e[t+1];if(!n||!r)return null;let i=Math.hypot(r.x-n.x,r.y-n.y);return i<1e-6?null:{x:-(r.y-n.y)/i,y:(r.x-n.x)/i}}function Am(e,t,n){if(Om(e,t))return n;let r=km(e,t-1),i=km(e,t);if(!r||!i)return n;let a=r.x+i.x,o=r.y+i.y,s=Math.hypot(a,o);if(s<1e-6)return n;let c=1/Math.max(.5,(a*n.x+o*n.y)/s);return{x:a/s*c,y:o/s*c}}function jm(e){let t=new Float32Array(1664),n=new Float32Array(832),r=new Uint32Array(1920),i=new Float64Array(64),a=new Uint32Array(128),o=null,s=0,c=0,l=0;function u(e,t){if(e.length>=t)return e;let n=new e.constructor(Math.max(t,e.length*2));return n.set(e),n}function d(e,r,i){return t[c*2]=e,t[c*2+1]=r,n[c]=i,c++}function f(e,t,n){r[l++]=e,r[l++]=t,r[l++]=n}function p(a,o){t=u(t,(c+13)*2),n=u(n,c+13),r=u(r,l+30);let s=a[o],p=i[o]??0,m=Tm(e,s.p);if(Om(a,o)){let e=d(s.x,s.y,p);for(let e=0;e<8;e+=1){let t=e/8*Math.PI*2;d(s.x+Math.cos(t)*m,s.y+Math.sin(t)*m,p)}for(let t=0;t<8;t+=1)f(e,e+1+t,e+1+(t+1)%8)}let h=a[o+1],g=km(a,o);if(!h||!g)return;let _=Am(a,o,g),v=Am(a,o+1,g),y=i[o+1]??p,b=Tm(e,h.p),x=d(s.x+_.x*m,s.y+_.y*m,p),S=d(s.x-_.x*m,s.y-_.y*m,p),C=d(h.x+v.x*b,h.y+v.y*b,y),w=d(h.x-v.x*b,h.y-v.y*b,y);f(x,S,C),f(S,w,C)}return{build(e){let d=e.length,f=e===o&&d>=s?Math.max(0,s-2):0;o=e,s=d,i=u(i,d),a=u(a,d*2),c=f>0?a[f*2]:0,l=f>0?a[f*2+1]:0;for(let t=f;t<d;t+=1){let n=e[t-1],r=e[t];i[t]=n?i[t-1]+Math.hypot(r.x-n.x,r.y-n.y):0}for(let t=f;t<d;t+=1)a[t*2]=c,a[t*2+1]=l,p(e,t);return{positions:t.subarray(0,c*2),indices:r.subarray(0,l),distances:n.subarray(0,c),length:d?i[d-1]:0}}}}const Mm=[192,384,768,1536];function Nm(e){return Mm.find(t=>t>=e)??1536}function Pm(e){if(!/^[a-z][a-z\d+.-]*:/i.test(e))return e.split(`/`).filter(Boolean).pop()||e;try{let t=new URL(e),n=t.pathname.split(`/`).filter(Boolean).pop()||t.hostname;try{return decodeURIComponent(n)}catch{return n}}catch{return e.split(`/`).filter(Boolean).pop()||e}}function Fm(e,t){let n=tl(e);return n?qd(n.kind===`url`?n.value.split(/[?#]/,1)[0]??``:n.value,t):null}function Im(e){return e?.type===`file`&&Fm(e.props.src,e.props.snapshot?.mimeType)!==null}function Lm(e){if(e.type===`image`){let t=tl(e.props.src);return t?`${t.kind}:${t.value}`:null}if(e.type===`file`){let t=e.props.snapshot;return t?.coverUrl?`url:${t.coverUrl}`:t?.coverPath?`file:${t.coverPath}`:null}if(e.type===`task`){let t=vu(_u(e.props.snapshot.artifacts));return t?`url:${t}`:null}let t=ql(e)?.cover,n=t?tl(t):null;return n?`${n.kind}:${n.value}`:null}const Rm=[`video`,`model`];function zm(e,t,n){return t?t.kind===`url`?`${e}-url:${encodeURIComponent(t.value)}`:`${e}:${encodeURIComponent(t.value)}:${n??`unknown`}`:null}function Bm(e){let t=_u(e.props.snapshot.artifacts),n=vu(t);return n?`url:${n}`:t?.type===`video`?zm(`video`,{kind:`url`,value:t.url},void 0):null}function Vm(e){let t=e.type===`task`?_u(e.props.snapshot.artifacts):e.type===`image`||e.type===`video`?e.props.snapshot:null;return t&&`naturalWidth`in t&&t.naturalWidth&&t.naturalHeight?{width:t.naturalWidth,height:t.naturalHeight}:null}function Hm(e){return e.type===`task`?Bm(e):e.type===`video`?zm(`video`,tl(e.props.src),e.props.snapshot?.mtimeMs):e.type===`file`&&Im(e)?zm(`model`,tl(e.props.src),e.props.snapshot?.mtimeMs):Lm(e)}function Um(e){let t=e;if(e.startsWith(`local:`)){let n=e.indexOf(`:`,6);if(n<0)return null;t=e.slice(n+1)}if(!t.startsWith(`cover:`))return Wm(t);let n=Wm(t.slice(6));return n?.media===`image`?{...n,fit:`cover`}:null}function Wm(e){try{for(let t of Rm){if(e.startsWith(`${t}-url:`))return{kind:`url`,media:t,value:decodeURIComponent(e.slice(t.length+5))};if(e.startsWith(`${t}:`)){let n=e.lastIndexOf(`:`);return n>t.length?{kind:`file`,media:t,value:decodeURIComponent(e.slice(t.length+1,n))}:null}}}catch{return null}return e.startsWith(`file:`)?{kind:`file`,media:`image`,value:e.slice(5)}:e.startsWith(`url:`)?{kind:`url`,media:`image`,value:e.slice(4)}:null}function Gm(e,t){let n=e.type===`image`?e.props.crop:void 0;return Math.max(e.frame.width/(n?.w||1),e.frame.height/(n?.h||1))*t}function Km(e,t){let n=Gm(e,t);return n<=64?64:n>1536?1/0:Nm(n)}const qm=256*1024**2;function Jm(e,t){let n=e.type===`image`?e.props.crop:void 0,r=Gm(e,t),i=Km(e,t),a=Number.isFinite(i)&&r>0?i/r:1,o=Math.ceil(e.frame.width/(n?.w||1)*t*a),s=Math.ceil(e.frame.height/(n?.h||1)*t*a),c=Vm(e);return Math.min(o*s,c?c.width*c.height:1/0)*4}function Ym(e,t,n){let r=n.maxBytes??qm,i=new Map;for(let r of e){let e=t(r);if(!e)continue;let a=Jm(r,n.scale);a>(i.get(e)?.need??-1)&&i.set(e,{item:r,need:a})}let a={items:[],keys:[],omittedKeys:[]},o=0;for(let[e,{item:t,need:n}]of i){if(o+n>r){a.omittedKeys.push(e);continue}o+=n,a.keys.push(e),a.items.push(t)}return a}function Xm(e){let t=Cd(e,{keepUnknown:!0});if(!t.ok)throw Error(`Invalid Board document: ${t.diagnostics.map(e=>`${e.path}: ${e.message}`).join(`; `)}`);return t.document}function Zm(e,t){let n=Ff(e.type===`arrow`?Sm(gm(e,t),e.style.strokeWidth):If(e.frame),e.style),r=e.parent;for(let e=0;r&&n&&e<64;e+=1){let e=t.get(r);if(e?.type!==`frame`)break;e.props.clip!==!1&&(n=Qm(n,If(e.frame))),n&&=Ff(n,e.style),r=e.parent}return n}function Qm(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i>n&&a>r?{x:n,y:r,width:i-n,height:a-r}:null}function $m(e,t){let n=new Map,r=t=>(n.has(t.id)||n.set(t.id,Zm(t,e)),n.get(t.id)??null),i=(e,t)=>{if(e.type===`effect`&&e.props.kind===`trail`&&e.props.follow)return!0;let n=r(e);return n!==null&&Mf(n,t)},a=e=>Nf(e.flatMap(e=>r(e)??[]));switch(t.kind){case`all`:return{items:[...e.items],rect:a(e.items),padding:null};case`items`:{let n=new Set(t.ids.flatMap(t=>e.get(t)?[t,...e.descendants(t)]:[]));for(let t of[...n])for(let r of e.binders(t)){let t=e.get(r);t&&Ru(t).every(e=>n.has(e))&&n.add(r)}let r=e.items.filter(e=>n.has(e.id));return{items:r,rect:a(r),padding:null}}case`frame`:{let n=e.get(t.id);if(!n)return{items:[],rect:null,padding:null};let r=If(n.frame);return{items:e.items.filter(e=>e.id===t.id||i(e,r)),rect:r,padding:0,page:t.id}}case`rect`:{let n=t.rect;return{items:e.items.filter(e=>i(e,n)),rect:n,padding:0}}}}function eh(e,t,n,r){let i=Math.min(n/t.width,n/t.height),a=Math.sqrt(r/(t.width*t.height));return Math.min(e,i,a)}function th(e){let{region:t,scale:n=2,maxEdge:r=8192,maxPixels:i=32e6}=e,a=$m(e.scene,t);if(!a.rect)return null;let o=e.padding??a.padding??32,s={x:a.rect.x-o,y:a.rect.y-o,width:Math.max(1,a.rect.width+o*2),height:Math.max(1,a.rect.height+o*2)},c=Number.isFinite(n)&&n>0?n:2,l=eh(c,s,r,i);return{world:s,scale:l,requestedScale:n,width:Math.max(1,Math.floor(s.width*l)),height:Math.max(1,Math.floor(s.height*l)),items:a.items,clamped:l<c-1e-6,...a.page?{page:a.page}:{}}}function nh(e){let{world:t,scale:n,width:r,height:i}=e;return{camera:{x:-t.x*n,y:-t.y*n,zoom:n},width:r,height:i,safeRect:{x:0,y:0,width:r,height:i}}}const rh=new Set([`md`,`mdx`,`markdown`,`txt`,`rst`,`adoc`,`org`]),ih=new Set([`json`,`jsonc`,`jsonl`,`yaml`,`yml`,`toml`,`csv`,`tsv`,`xml`,`ndjson`]),ah=new Set(`ts.tsx.js.jsx.mjs.cjs.py.go.rs.java.kt.swift.rb.php.c.h.hh.hpp.cpp.cc.cs.scala.lua.sh.bash.zsh.fish.vue.svelte.css.scss.less.html.htm.sql.graphql.proto.zig.dart.r`.split(`.`)),oh=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`avif`,`svg`,`bmp`,`ico`,`mp4`,`webm`,`mov`,`m4v`,`mp3`,`wav`,`ogg`,`m4a`,`flac`,`aac`,`pdf`,`zip`,`gz`,`tgz`]);function sh(e){let t=uh(e),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}function ch(e){return e?e.split(`;`)[0]?.trim().toLowerCase()??``:``}function lh(e,t){let n=ch(t);if(n){if(n===`text/markdown`||n===`text/x-markdown`||n===`text/plain`||n===`text/x-rst`)return`doc`;if(n===`application/json`||n===`application/yaml`||n===`application/x-yaml`||n===`application/toml`||n===`application/csv`||n===`application/xml`||n===`text/csv`||n===`text/xml`||n===`text/yaml`||n===`application/x-ndjson`)return`data`;if(n.startsWith(`image/`)||n.startsWith(`video/`)||n.startsWith(`audio/`)||n===`application/pdf`||n===`application/zip`||n===`application/gzip`)return`media`;if(n.startsWith(`text/x-`)||n===`application/javascript`||n===`application/typescript`||n===`text/javascript`||n===`text/css`||n===`text/html`||n===`application/sql`)return`code`}let r=sh(e);return rh.has(r)?`doc`:ih.has(r)?`data`:ah.has(r)?`code`:oh.has(r)?`media`:n.startsWith(`text/`)?`doc`:`other`}function uh(e){return Pm(e)}function dh(e){let t=uh(e),n=t.lastIndexOf(`.`);return n<=0?t:t.slice(0,n)}function fh(e){return e?e.coverPath||e.coverUrl?`cover`:e.excerpt?`text`:`blank`:`blank`}function ph(e){if(mh(e))return`LINK`;let t=uh(e),n=t.lastIndexOf(`.`);return n<=0?(t.replace(/^\./,``)||`file`).toUpperCase():t.slice(n+1).toUpperCase()}function mh(e){if(!/^https?:\/\//i.test(e))return!1;try{let t=new URL(e).pathname.split(`/`).filter(Boolean).pop()??``;return!/\.[a-z\d]{1,8}$/i.test(t)}catch{return!1}}function hh(e){if(e===void 0||!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${t[r]}`}function gh(e,t){let n=ph(e),r=hh(t);return n&&r?`${n} · ${r}`:r||n}function _h(e,t){switch(e){case`doc`:return t.text;case`code`:return t.rare;case`data`:return t.epic;case`media`:return t.legendary;default:return t.muted}}const vh={dark:{colorScheme:`dark`,palette:{bg:1053203,surface:2369321,hover:2500907,border:3158838,brand:14564909,activity:14564909,error:15950429,warning:15580004,text:15330286,muted:10198947,rare:6009047,epic:2070983,legendary:15580004},colors:{brand:{stroke:14564909,fill:14564909,label:15330286},neutral:{stroke:10198947,fill:10198947,label:15330286},black:{stroke:0,fill:0,label:15330286},white:{stroke:16777215,fill:16777215,label:15330286},blue:{stroke:6009047,fill:6009047,label:15330286},green:{stroke:7065501,fill:7065501,label:15330286},amber:{stroke:15580004,fill:15580004,label:15330286},violet:{stroke:11971577,fill:11971577,label:15330286},rose:{stroke:15950429,fill:15950429,label:15330286}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:2566444,size:2}}},light:{colorScheme:`light`,palette:{bg:16251130,surface:16777215,hover:15330029,border:14409442,brand:13582898,activity:13582898,error:10165794,warning:8804608,text:66050,muted:6251625,rare:24458,epic:19325,legendary:8804608},colors:{brand:{stroke:13582898,fill:13582898,label:66050},neutral:{stroke:6251625,fill:6251625,label:66050},black:{stroke:0,fill:0,label:66050},white:{stroke:16777215,fill:16777215,label:66050},blue:{stroke:24458,fill:24458,label:66050},green:{stroke:26685,fill:26685,label:66050},amber:{stroke:8804608,fill:8804608,label:66050},violet:{stroke:6904238,fill:6904238,label:66050},rose:{stroke:10165794,fill:10165794,label:66050}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:15001321,size:2}}},"solarized-dark":{colorScheme:`dark`,palette:{bg:70677,surface:859936,hover:1057828,border:1582887,brand:34240,activity:34240,error:15950429,warning:14790474,text:12572374,muted:6848639,rare:2206648,epic:38821,legendary:14790474},colors:{brand:{stroke:34240,fill:34240,label:12572374},neutral:{stroke:6848639,fill:6848639,label:12572374},black:{stroke:0,fill:0,label:12572374},white:{stroke:16777215,fill:16777215,label:12572374},blue:{stroke:2206648,fill:2206648,label:12572374},green:{stroke:9481815,fill:9481815,label:12572374},amber:{stroke:14790474,fill:14790474,label:12572374},violet:{stroke:11182560,fill:11182560,label:12572374},rose:{stroke:15950429,fill:15950429,label:12572374}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:1122594,size:2}}},"solarized-light":{colorScheme:`light`,palette:{bg:16775902,surface:16446169,hover:15920337,border:14341313,brand:31924,activity:31924,error:10363429,warning:8936704,text:2110772,muted:5860973,rare:28541,epic:23659,legendary:8936704},colors:{brand:{stroke:31924,fill:31924,label:2110772},neutral:{stroke:5860973,fill:5860973,label:2110772},black:{stroke:0,fill:0,label:2110772},white:{stroke:16777215,fill:16777215,label:2110772},blue:{stroke:28541,fill:28541,label:2110772},green:{stroke:4809217,fill:4809217,label:2110772},amber:{stroke:8936704,fill:8936704,label:2110772},violet:{stroke:6904995,fill:6904995,label:2110772},rose:{stroke:10363429,fill:10363429,label:2110772}},style:{},backdrop:{pattern:{kind:`dots`,pitch:24,color:15130570,size:2}}},"neta-studio":{colorScheme:`dark`,palette:{bg:329221,surface:1249814,hover:1973788,border:1842202,brand:3900150,activity:15524306,error:15562341,warning:15449187,text:16314853,muted:7630695,rare:9235170,epic:7266776,legendary:15449187},colors:{brand:{stroke:15524306,fill:15524306,label:16314853},neutral:{stroke:15524306,fill:15524306,label:16314853},black:{stroke:0,fill:0,label:16314853},white:{stroke:16777215,fill:16777215,label:16314853},blue:{stroke:9235170,fill:9235170,label:16314853},green:{stroke:8177036,fill:8177036,label:16314853},amber:{stroke:15449187,fill:15449187,label:16314853},violet:{stroke:11971327,fill:11971327,label:16314853},rose:{stroke:15562341,fill:15562341,label:16314853}},style:{selection:{outset:0},frameLabelSize:16}},"neta-pixel":{colorScheme:`light`,palette:{bg:16185078,surface:16777215,hover:16185078,border:15527149,brand:1824230,activity:434355,error:13705029,warning:9725440,text:1447704,muted:7566452,rare:31378,epic:31378,legendary:9725440},colors:{brand:{stroke:1447704,fill:1447704,label:1447704},neutral:{stroke:7566452,fill:7566452,label:1447704},black:{stroke:0,fill:0,label:1447704},white:{stroke:16777215,fill:16777215,label:1447704},blue:{stroke:6010853,fill:6010853,label:1447704},green:{stroke:9683613,fill:9683613,label:1447704},amber:{stroke:14264410,fill:14264410,label:1447704},violet:{stroke:11441117,fill:11441117,label:1447704},rose:{stroke:15043210,fill:15043210,label:1447704}},style:{corner:`pixel`,shadow:{color:1447704,alpha:.1,blur:20,y:0},selection:{width:1.5,outset:0,dash:0,handle:`square`,handleSize:8},media:`framed`,progress:`mosaic`,icons:`pixel`,motion:`stepped`,font:`"Figtree Variable", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif`,frameLabelSize:16},backdrop:{pattern:{kind:`dots`,pitch:24,color:14935011,size:2,shape:`square`}}},"neta-pixel-dark":{colorScheme:`dark`,palette:{bg:1118739,surface:1842463,hover:2237220,border:2763565,brand:1824230,activity:3142143,error:16740488,warning:16766287,text:16185078,muted:9079436,rare:1824230,epic:1824230,legendary:16766287},colors:{brand:{stroke:16185078,fill:16185078,label:16185078},neutral:{stroke:9079436,fill:9079436,label:16185078},black:{stroke:0,fill:0,label:16185078},white:{stroke:16777215,fill:16777215,label:16185078},blue:{stroke:6010853,fill:6010853,label:16185078},green:{stroke:9683613,fill:9683613,label:16185078},amber:{stroke:14264410,fill:14264410,label:16185078},violet:{stroke:11441117,fill:11441117,label:16185078},rose:{stroke:15043210,fill:15043210,label:16185078}},style:{corner:`pixel`,shadow:{color:0,alpha:.4,blur:20,y:0},selection:{width:1.5,outset:0,dash:0,handle:`square`,handleSize:8},media:`framed`,progress:`mosaic`,icons:`pixel`,motion:`stepped`,font:`"Figtree Variable", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif`,frameLabelSize:16},backdrop:{pattern:{kind:`dots`,pitch:24,color:3816512,size:2,shape:`square`}}}},yh={brand:`Brand`,neutral:`Neutral`,black:`Black`,white:`White`,blue:`Blue`,green:`Green`,amber:`Amber`,violet:`Violet`,rose:`Rose`},bh=Hc.map(e=>({id:e,label:yh[e],dark:{...vh.dark.colors[e]},light:{...vh.light.colors[e]}})),xh=new Map(bh.map(e=>[e.id,e]));function Sh(e){return typeof e==`string`&&xh.has(e)}function Ch(e,t){return((Sh(e)?xh.get(e):void 0)??xh.get(`brand`))[t]}function wh(e){let t={};for(let n of bh)t[n.id]=n[e];return t}function Th(e,t,n=`dark`){return e&&Sh(t)&&e[t]?e[t]:e?e.brand:Ch(t,n)}function Eh(e,t,n,r,i,a=`stroke`){let o=typeof e==`object`&&e?e[r]:e;if(o===void 0)return Th(n,t,r)[a];let s=o.trim().toLowerCase();return Sh(s)?Th(n,s,r)[a]:i(o)??Th(n,t,r)[a]}function Dh(e,t){return e===`sans`||e===`serif`||e===`mono`?t[e]:`"${e.replaceAll(`"`,``)}", ${t.sans}`}function Oh(e,t){return Nu({text:e.text,fontSize:e.fontSize,fontWeight:500,font:`sans`,lineHeight:1.4,width:Math.max(1,t-16)})}function kh(e){return{x:4,y:-(e+6)}}var H,Ah,jh,U,W=o((()=>{H=(e=>(e.Application=`application`,e.WebGLPipes=`webgl-pipes`,e.WebGLPipesAdaptor=`webgl-pipes-adaptor`,e.WebGLSystem=`webgl-system`,e.WebGPUPipes=`webgpu-pipes`,e.WebGPUPipesAdaptor=`webgpu-pipes-adaptor`,e.WebGPUSystem=`webgpu-system`,e.CanvasSystem=`canvas-system`,e.CanvasPipesAdaptor=`canvas-pipes-adaptor`,e.CanvasPipes=`canvas-pipes`,e.Asset=`asset`,e.LoadParser=`load-parser`,e.ResolveParser=`resolve-parser`,e.CacheParser=`cache-parser`,e.DetectionParser=`detection-parser`,e.MaskEffect=`mask-effect`,e.BlendMode=`blend-mode`,e.TextureSource=`texture-source`,e.TextureUploaderWebGL=`texture-uploader-webgl`,e.TextureUploaderWebGPU=`texture-uploader-webgpu`,e.Environment=`environment`,e.ShapeBuilder=`shape-builder`,e.Batcher=`batcher`,e))(H||{}),Ah=e=>{if(typeof e==`function`||typeof e==`object`&&e.extension){if(!e.extension)throw Error(`Extension class must have an extension object`);e={...typeof e.extension==`object`?e.extension:{type:e.extension},ref:e}}if(typeof e==`object`)e={...e};else throw Error(`Invalid extension type`);return typeof e.type==`string`&&(e.type=[e.type]),e},jh=(e,t)=>Ah(e).priority??t,U={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(Ah).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...e){return e.map(Ah).forEach(e=>{e.type.forEach(t=>{let n=this._addHandlers,r=this._queue;n[t]?n[t]?.(e):(r[t]=r[t]||[],r[t]?.push(e))})}),this},handle(e,t,n){let r=this._addHandlers,i=this._removeHandlers;if(r[e]||i[e])throw Error(`Extension type ${e} already has a handler`);r[e]=t,i[e]=n;let a=this._queue;return a[e]&&(a[e]?.forEach(e=>t(e)),delete a[e]),this},handleByMap(e,t){return this.handle(e,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,e=>{t.findIndex(t=>t.name===e.name)>=0||(t.push({name:e.name,value:e.ref}),t.sort((e,t)=>jh(t.value,n)-jh(e.value,n)))},e=>{let n=t.findIndex(t=>t.name===e.name);n!==-1&&t.splice(n,1)})},handleByList(e,t,n=-1){return this.handle(e,e=>{t.includes(e.ref)||(t.push(e.ref),t.sort((e,t)=>jh(t,n)-jh(e,n)))},e=>{let n=t.indexOf(e.ref);n!==-1&&t.splice(n,1)})},mixin(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}}})),Mh=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),Nh,Ph,Fh=o((()=>{Nh=u(Mh(),1),Ph=Nh.default})),Ih,Lh,Rh,zh,Bh,Vh,Hh,Uh,Wh,Gh,Kh,qh,Jh,Yh,Xh,Zh,Qh,$h,eg,tg,ng,rg,ig,ag,og,sg,cg,lg,ug,dg=o((()=>{Ih={grad:.9,turn:360,rad:360/(2*Math.PI)},Lh=function(e){return typeof e==`string`?e.length>0:typeof e==`number`},Rh=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n+0},zh=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},Bh=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},Vh=function(e){return{r:zh(e.r,0,255),g:zh(e.g,0,255),b:zh(e.b,0,255),a:zh(e.a)}},Hh=function(e){return{r:Rh(e.r),g:Rh(e.g),b:Rh(e.b),a:Rh(e.a,3)}},Uh=/^#([0-9a-f]{3,8})$/i,Wh=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Gh=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:60*(s<0?s+6:s),s:a?o/a*100:0,v:a/255*100,a:i}},Kh=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:255*[r,s,o,o,c,r][l],g:255*[c,r,r,s,o,o][l],b:255*[o,o,c,r,r,s][l],a:i}},qh=function(e){return{h:Bh(e.h),s:zh(e.s,0,100),l:zh(e.l,0,100),a:zh(e.a)}},Jh=function(e){return{h:Rh(e.h),s:Rh(e.s),l:Rh(e.l),a:Rh(e.a,3)}},Yh=function(e){return Kh((n=(t=e).s,{h:t.h,s:(n*=((r=t.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:t.a}));var t,n,r},Xh=function(e){return{h:(t=Gh(e)).h,s:(i=(200-(n=t.s))*(r=t.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,r,i},Zh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qh=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,$h=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,eg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tg={string:[[function(e){var t=Uh.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Rh(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?Rh(parseInt(e.substr(6,2),16)/255,2):1}:null:null},`hex`],[function(e){var t=$h.exec(e)||eg.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:Vh({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},`rgb`],[function(e){var t=Zh.exec(e)||Qh.exec(e);if(!t)return null;var n,r;return Yh(qh({h:(n=t[1],r=t[2],r===void 0&&(r=`deg`),Number(n)*(Ih[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}))},`hsl`]],object:[[function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i===void 0?1:i;return Lh(t)&&Lh(n)&&Lh(r)?Vh({r:Number(t),g:Number(n),b:Number(r),a:Number(a)}):null},`rgb`],[function(e){var t=e.h,n=e.s,r=e.l,i=e.a,a=i===void 0?1:i;return!Lh(t)||!Lh(n)||!Lh(r)?null:Yh(qh({h:Number(t),s:Number(n),l:Number(r),a:Number(a)}))},`hsl`],[function(e){var t=e.h,n=e.s,r=e.v,i=e.a,a=i===void 0?1:i;return!Lh(t)||!Lh(n)||!Lh(r)?null:Kh(function(e){return{h:Bh(e.h),s:zh(e.s,0,100),v:zh(e.v,0,100),a:zh(e.a)}}({h:Number(t),s:Number(n),v:Number(r),a:Number(a)}))},`hsv`]]},ng=function(e,t){for(var n=0;n<t.length;n++){var r=t[n][0](e);if(r)return[r,t[n][1]]}return[null,void 0]},rg=function(e){return typeof e==`string`?ng(e.trim(),tg.string):typeof e==`object`&&e?ng(e,tg.object):[null,void 0]},ig=function(e,t){var n=Xh(e);return{h:n.h,s:zh(n.s+100*t,0,100),l:n.l,a:n.a}},ag=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},og=function(e,t){var n=Xh(e);return{h:n.h,s:n.s,l:zh(n.l+100*t,0,100),a:n.a}},sg=function(){function e(e){this.parsed=rg(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return Rh(ag(this.rgba),2)},e.prototype.isDark=function(){return ag(this.rgba)<.5},e.prototype.isLight=function(){return ag(this.rgba)>=.5},e.prototype.toHex=function(){return e=Hh(this.rgba),t=e.r,n=e.g,r=e.b,a=(i=e.a)<1?Wh(Rh(255*i)):``,`#`+Wh(t)+Wh(n)+Wh(r)+a;var e,t,n,r,i,a},e.prototype.toRgb=function(){return Hh(this.rgba)},e.prototype.toRgbString=function(){return e=Hh(this.rgba),t=e.r,n=e.g,r=e.b,(i=e.a)<1?`rgba(`+t+`, `+n+`, `+r+`, `+i+`)`:`rgb(`+t+`, `+n+`, `+r+`)`;var e,t,n,r,i},e.prototype.toHsl=function(){return Jh(Xh(this.rgba))},e.prototype.toHslString=function(){return e=Jh(Xh(this.rgba)),t=e.h,n=e.s,r=e.l,(i=e.a)<1?`hsla(`+t+`, `+n+`%, `+r+`%, `+i+`)`:`hsl(`+t+`, `+n+`%, `+r+`%)`;var e,t,n,r,i},e.prototype.toHsv=function(){return e=Gh(this.rgba),{h:Rh(e.h),s:Rh(e.s),v:Rh(e.v),a:Rh(e.a,3)};var e},e.prototype.invert=function(){return cg({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return e===void 0&&(e=.1),cg(ig(this.rgba,e))},e.prototype.desaturate=function(e){return e===void 0&&(e=.1),cg(ig(this.rgba,-e))},e.prototype.grayscale=function(){return cg(ig(this.rgba,-1))},e.prototype.lighten=function(e){return e===void 0&&(e=.1),cg(og(this.rgba,e))},e.prototype.darken=function(e){return e===void 0&&(e=.1),cg(og(this.rgba,-e))},e.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return typeof e==`number`?cg({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Rh(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=Xh(this.rgba);return typeof e==`number`?cg({h:e,s:t.s,l:t.l,a:t.a}):Rh(t.h)},e.prototype.isEqual=function(e){return this.toHex()===cg(e).toHex()},e}(),cg=function(e){return e instanceof sg?e:new sg(e)},lg=[],ug=function(e){e.forEach(function(e){lg.indexOf(e)<0&&(e(sg,tg),lg.push(e))})}}));function fg(e,t){var n={white:`#ffffff`,bisque:`#ffe4c4`,blue:`#0000ff`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,antiquewhite:`#faebd7`,aqua:`#00ffff`,azure:`#f0ffff`,whitesmoke:`#f5f5f5`,papayawhip:`#ffefd5`,plum:`#dda0dd`,blanchedalmond:`#ffebcd`,black:`#000000`,gold:`#ffd700`,goldenrod:`#daa520`,gainsboro:`#dcdcdc`,cornsilk:`#fff8dc`,cornflowerblue:`#6495ed`,burlywood:`#deb887`,aquamarine:`#7fffd4`,beige:`#f5f5dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkkhaki:`#bdb76b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,peachpuff:`#ffdab9`,darkmagenta:`#8b008b`,darkred:`#8b0000`,darkorchid:`#9932cc`,darkorange:`#ff8c00`,darkslateblue:`#483d8b`,gray:`#808080`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,wheat:`#f5deb3`,firebrick:`#b22222`,floralwhite:`#fffaf0`,ghostwhite:`#f8f8ff`,darkviolet:`#9400d3`,magenta:`#ff00ff`,green:`#008000`,dodgerblue:`#1e90ff`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,blueviolet:`#8a2be2`,forestgreen:`#228b22`,lawngreen:`#7cfc00`,indianred:`#cd5c5c`,indigo:`#4b0082`,fuchsia:`#ff00ff`,brown:`#a52a2a`,maroon:`#800000`,mediumblue:`#0000cd`,lightcoral:`#f08080`,darkturquoise:`#00ced1`,lightcyan:`#e0ffff`,ivory:`#fffff0`,lightyellow:`#ffffe0`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,linen:`#faf0e6`,mediumaquamarine:`#66cdaa`,lemonchiffon:`#fffacd`,lime:`#00ff00`,khaki:`#f0e68c`,mediumseagreen:`#3cb371`,limegreen:`#32cd32`,mediumspringgreen:`#00fa9a`,lightskyblue:`#87cefa`,lightblue:`#add8e6`,midnightblue:`#191970`,lightpink:`#ffb6c1`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,mintcream:`#f5fffa`,lightslategray:`#778899`,lightslategrey:`#778899`,navajowhite:`#ffdead`,navy:`#000080`,mediumvioletred:`#c71585`,powderblue:`#b0e0e6`,palegoldenrod:`#eee8aa`,oldlace:`#fdf5e6`,paleturquoise:`#afeeee`,mediumturquoise:`#48d1cc`,mediumorchid:`#ba55d3`,rebeccapurple:`#663399`,lightsteelblue:`#b0c4de`,mediumslateblue:`#7b68ee`,thistle:`#d8bfd8`,tan:`#d2b48c`,orchid:`#da70d6`,mediumpurple:`#9370db`,purple:`#800080`,pink:`#ffc0cb`,skyblue:`#87ceeb`,springgreen:`#00ff7f`,palegreen:`#98fb98`,red:`#ff0000`,yellow:`#ffff00`,slateblue:`#6a5acd`,lavenderblush:`#fff0f5`,peru:`#cd853f`,palevioletred:`#db7093`,violet:`#ee82ee`,teal:`#008080`,slategray:`#708090`,slategrey:`#708090`,aliceblue:`#f0f8ff`,darkseagreen:`#8fbc8f`,darkolivegreen:`#556b2f`,greenyellow:`#adff2f`,seagreen:`#2e8b57`,seashell:`#fff5ee`,tomato:`#ff6347`,silver:`#c0c0c0`,sienna:`#a0522d`,lavender:`#e6e6fa`,lightgreen:`#90ee90`,orange:`#ffa500`,orangered:`#ff4500`,steelblue:`#4682b4`,royalblue:`#4169e1`,turquoise:`#40e0d0`,yellowgreen:`#9acd32`,salmon:`#fa8072`,saddlebrown:`#8b4513`,sandybrown:`#f4a460`,rosybrown:`#bc8f8f`,darksalmon:`#e9967a`,lightgoldenrodyellow:`#fafad2`,snow:`#fffafa`,lightgrey:`#d3d3d3`,lightgray:`#d3d3d3`,dimgray:`#696969`,dimgrey:`#696969`,olivedrab:`#6b8e23`,olive:`#808000`},r={};for(var i in n)r[n[i]]=i;var a={};e.prototype.toName=function(t){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return`transparent`;var i,o,s=r[this.toHex()];if(s)return s;if(t?.closest){var c=this.toRgb(),l=1/0,u=`black`;if(!a.length)for(var d in n)a[d]=new e(n[d]).toRgb();for(var f in n){var p=(i=c,o=a[f],(i.r-o.r)**2+(i.g-o.g)**2+(i.b-o.b)**2);p<l&&(l=p,u=f)}return u}},t.string.push([function(t){var r=t.toLowerCase(),i=r===`transparent`?`#0000`:n[r];return i?new e(i).toRgb():null},`name`])}var pg=o((()=>{})),mg,hg,gg=o((()=>{dg(),pg(),ug([fg]),mg=class e{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(t){if(t instanceof e)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else if(t===null)throw Error(`Cannot set Color#value to null`);else(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}get value(){return this._value}_cloneSource(e){return typeof e==`string`||typeof e==`number`||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e==`object`&&e?{...e}:e}_isSourceEqual(e,t){let n=typeof e;if(n!==typeof t)return!1;if(n===`number`||n===`string`||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length===t.length&&e.every((e,n)=>e===t[n]);if(e!==null&&t!==null){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}return e===t}toRgba(){let[e,t,n,r]=this._components;return{r:e,g:t,b:n,a:r}}toRgb(){let[e,t,n]=this._components;return{r:e,g:t,b:n}}toRgbaString(){let[e,t,n]=this.toUint8RgbArray();return`rgba(${e},${t},${n},${this.alpha})`}toUint8RgbArray(e){let[t,n,r]=this._components;return this._arrayRgb||=[],e||=this._arrayRgb,e[0]=Math.round(t*255),e[1]=Math.round(n*255),e[2]=Math.round(r*255),e}toArray(e){this._arrayRgba||=[],e||=this._arrayRgba;let[t,n,r,i]=this._components;return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}toRgbArray(e){this._arrayRgb||=[],e||=this._arrayRgb;let[t,n,r]=this._components;return e[0]=t,e[1]=n,e[2]=r,e}toNumber(){return this._int}toBgrNumber(){let[e,t,n]=this.toUint8RgbArray();return(n<<16)+(t<<8)+e}toLittleEndianNumber(){let e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(t){let[n,r,i,a]=e._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=r,this._components[2]*=i,this._components[3]*=a,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let n=this._int>>16&255,r=this._int>>8&255,i=this._int&255;return t&&(n=n*e+.5|0,r=r*e+.5|0,i=i*e+.5|0),(e*255<<24)+(n<<16)+(r<<8)+i}toHex(){let e=this._int.toString(16);return`#${`000000`.substring(0,6-e.length)+e}`}toHexa(){let e=Math.round(this._components[3]*255).toString(16);return this.toHex()+`00`.substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(t){let n,r,i,a;if((typeof t==`number`||t instanceof Number)&&t>=0&&t<=16777215){let e=t;n=(e>>16&255)/255,r=(e>>8&255)/255,i=(e&255)/255,a=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,r,i,a=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,r,i,a=255]=t,n/=255,r/=255,i/=255,a/=255;else if(typeof t==`string`||typeof t==`object`){if(typeof t==`string`){let n=e.HEX_PATTERN.exec(t);n&&(t=`#${n[2]}`)}let o=cg(t);o.isValid()&&({r:n,g:r,b:i,a}=o.rgba,n/=255,r/=255,i/=255)}if(n!==void 0)this._components[0]=n,this._components[1]=r,this._components[2]=i,this._components[3]=a,this._refreshInt();else throw Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[e,t,n]=this._components;this._int=(e*255<<16)+(t*255<<8)+(n*255|0)}_clamp(e,t=0,n=1){return typeof e==`number`?Math.min(Math.max(e,t),n):(e.forEach((r,i)=>{e[i]=Math.min(Math.max(r,t),n)}),e)}static isColorLike(t){return typeof t==`number`||typeof t==`string`||t instanceof Number||t instanceof e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}},mg.shared=new mg,mg._temp=new mg,mg.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i,hg=mg})),_g,vg=o((()=>{_g={cullArea:null,cullable:!1,cullableChildren:!0}})),yg,bg,xg,Sg=o((()=>{yg=Math.PI*2,bg=180/Math.PI,xg=Math.PI/180})),Cg,wg,Tg=o((()=>{Cg=class e{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new e(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return wg.x=0,wg.y=0,wg}},wg=new Cg})),G,Eg,Dg,K=o((()=>{Sg(),Tg(),G=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}toArray(e,t){this.array||=new Float32Array(9);let n=t||this.array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}apply(e,t){t||=new Cg;let n=e.x,r=e.y;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}applyInverse(e,t){t||=new Cg;let n=this.a,r=this.b,i=this.c,a=this.d,o=this.tx,s=this.ty,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(yg-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+(a.x*t+a.y*r),e.position.y=this.ty+(a.x*n+a.y*i),e}invert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let t=new e;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Dg.identity()}static get shared(){return Eg.identity()}},Eg=new G,Dg=new G})),Og,kg=o((()=>{Og=class e{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(t){return new e(t??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}}));function Ag(e=`default`){return jg[e]===void 0&&(jg[e]=-1),++jg[e]}var jg,Mg=o((()=>{jg={default:-1}})),Ng,Pg,Fg,Ig,q,Lg=o((()=>{Ng=new Set,Pg=`8.0.0`,Fg=`8.3.4`,Ig={quiet:!1,noColor:!1},q=((e,t,n=3)=>{if(Ig.quiet||Ng.has(t))return;let r=Error().stack,i=`${t}
57
57
  Deprecated since v${e}`,a=typeof console.groupCollapsed==`function`&&!Ig.noColor;r===void 0?console.warn(`PixiJS Deprecation Warning: `,i):(r=r.split(`
58
58
  `).splice(n).join(`
59
59
  `),a?(console.groupCollapsed(`%cPixiJS Deprecation Warning: %c%s`,`color:#614108;background:#fffbe6`,`font-weight:normal;color:#614108;background:#fffbe6`,i),console.warn(r),console.groupEnd()):(console.warn(`PixiJS Deprecation Warning: `,i),console.warn(r))),Ng.add(t)}),Object.defineProperties(q,{quiet:{get:()=>Ig.quiet,set:e=>{Ig.quiet=e},enumerable:!0,configurable:!1},noColor:{get:()=>Ig.noColor,set:e=>{Ig.noColor=e},enumerable:!0,configurable:!1}})}));function J(...e){Rg!==zg&&(Rg++,Rg===zg?console.warn(`PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS.`):console.warn(`PixiJS Warning: `,...e))}var Rg,zg,Bg=o((()=>{Rg=0,zg=500})),Vg,Hg=o((()=>{Vg={_registeredResources:new Set,register(e){this._registeredResources.add(e)},unregister(e){this._registeredResources.delete(e)},release(){this._registeredResources.forEach(e=>e.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(e){return this._registeredResources.has(e)},reset(){this._registeredResources.clear()}}})),Ug,Wg=o((()=>{Ug=class{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}})),Gg,Kg,qg=o((()=>{Hg(),Wg(),Gg=class{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Ug(e)),this._poolsByClass.get(e)}stats(){let e={};return this._poolsByClass.forEach(t=>{let n=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[n]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}},Kg=new Gg,Vg.register(Kg)})),Jg,Yg=o((()=>{Lg(),Jg={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(e){typeof e==`boolean`&&e===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(e===!0?{}:e))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(e){q(`v8.6.0`,`cacheAsBitmap is deprecated, use cacheAsTexture instead.`),this.cacheAsTexture(e)}}}));function Xg(e,t,n){let r=e.length,i;if(t>=r||n===0)return;n=t+n>r?r-t:n;let a=r-n;for(i=t;i<a;++i)e[i]=e[i+n];e.length=a}var Zg=o((()=>{})),Qg,$g=o((()=>{Zg(),Lg(),Qg={allowChildren:!0,removeChildren(e=0,t){let n=t??this.children.length,r=n-e,i=[];if(r>0&&r<=n){for(let t=n-1;t>=e;t--){let e=this.children[t];e&&(i.push(e),e.parent=null)}Xg(this.children,e,n);let t=this.renderGroup||this.parentRenderGroup;t&&t.removeChildren(i);for(let e=0;e<i.length;++e){let t=i[e];t.parentRenderLayer?.detach(t),this.emit(`childRemoved`,t,this,e),i[e].emit(`removed`,this)}return i.length>0&&this._didViewChangeTick++,i}if(r===0&&this.children.length===0)return i;throw RangeError(`removeChildren: numeric values are outside the acceptable range.`)},removeChildAt(e){let t=this.getChildAt(e);return this.removeChild(t)},getChildAt(e){if(e<0||e>=this.children.length)throw Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]},setChildIndex(e,t){if(t<0||t>=this.children.length)throw Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(e),this.addChildAt(e,t)},getChildIndex(e){let t=this.children.indexOf(e);if(t===-1)throw Error(`The supplied Container must be a child of the caller`);return t},addChildAt(e,t){this.allowChildren||q(Pg,`addChildAt: Only Containers will be allowed to add children in v8.0.0`);let{children:n}=this;if(t<0||t>n.length)throw Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${n.length}`);let r=e.parent===this;if(e.parent){let n=e.parent.children.indexOf(e);if(r){if(n===t)return e;e.parent.children.splice(n,1)}else e.removeFromParent()}t===n.length?n.push(e):n.splice(t,0,e);let i=this.renderGroup||this.parentRenderGroup;return this.sortableChildren&&(this.sortDirty=!0),r?(i&&(i.structureDidChange=!0),e):(e.parent=this,e.didChange=!0,e._updateFlags=15,i&&i.addChild(e),this.emit(`childAdded`,e,this,t),e.emit(`added`,this),e)},swapChildren(e,t){if(e===t)return;let n=this.getChildIndex(e),r=this.getChildIndex(t);this.children[n]=t,this.children[r]=e;let i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...e){return e.length===1?this.reparentChildAt(e[0],this.children.length):(e.forEach(e=>this.reparentChildAt(e,this.children.length)),e[0])},reparentChildAt(e,t){if(e.parent===this)return this.setChildIndex(e,t),e;let n=e.worldTransform.clone();e.removeFromParent(),this.addChildAt(e,t);let r=this.worldTransform.clone();return r.invert(),n.prepend(r),e.setFromMatrix(n),e},replaceChild(e,t){e.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(e)),t.setFromMatrix(e.localTransform),t.updateLocalTransform(),this.removeChild(e)}}})),e_,t_=o((()=>{e_={collectRenderables(e,t,n){this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(e,t,n):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,e):this.collectRenderablesWithEffects(e,t,n))},collectRenderablesSimple(e,t,n){let r=this.children,i=r.length;for(let a=0;a<i;a++)r[a].collectRenderables(e,t,n)},collectRenderablesWithEffects(e,t,n){let{renderPipes:r}=t;for(let t=0;t<this.effects.length;t++){let n=this.effects[t];r[n.pipe].push(n,this,e)}this.collectRenderablesSimple(e,t,n);for(let t=this.effects.length-1;t>=0;t--){let n=this.effects[t];r[n.pipe].pop(n,this,e)}}}})),n_,r_=o((()=>{n_=class{constructor(){this.pipe=`filter`,this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}})),i_,a_,o_=o((()=>{W(),qg(),i_=class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){let n=this._tests[t];if(n.test(e))return Kg.get(n.maskClass,e)}return e}returnMaskEffect(e){Kg.return(e)}},a_=new i_,U.handleByList(H.MaskEffect,a_._effectClasses)})),s_,c_=o((()=>{r_(),o_(),s_={_maskEffect:null,_maskOptions:{inverse:!1,channel:`red`},_filterEffect:null,effects:[],_markStructureAsChanged(){let e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0)},addEffect(e){this.effects.indexOf(e)===-1&&(this.effects.push(e),this.effects.sort((e,t)=>e.priority-t.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(e){let t=this.effects.indexOf(e);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(e){let t=this._maskEffect;t?.mask!==e&&(t&&(this.removeEffect(t),a_.returnMaskEffect(t),this._maskEffect=null),e!=null&&(this._maskEffect=a_.getMaskEffect(e),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(e){this._maskOptions={...this._maskOptions,...e},e.mask&&(this.mask=e.mask),this._markStructureAsChanged()},set filters(e){!Array.isArray(e)&&e&&(e=[e]);let t=this._filterEffect||=new n_;e=e;let n=e?.length>0,r=n!==t.filters?.length>0;e=Array.isArray(e)?e.slice(0):e,t.filters=Object.freeze(e),r&&(n?this.addEffect(t):(this.removeEffect(t),t.filters=e??null))},get filters(){return this._filterEffect?.filters},set filterArea(e){this._filterEffect||=new n_,this._filterEffect.filterArea=e},get filterArea(){return this._filterEffect?.filterArea}}})),l_,u_=o((()=>{Lg(),l_={label:null,get name(){return q(Pg,`Container.name property has been removed, use Container.label instead`),this.label},set name(e){q(Pg,`Container.name property has been removed, use Container.label instead`),this.label=e},getChildByName(e,t=!1){return this.getChildByLabel(e,t)},getChildByLabel(e,t=!1){let n=this.children;for(let t=0;t<n.length;t++){let r=n[t];if(r.label===e||e instanceof RegExp&&e.test(r.label))return r}if(t)for(let t=0;t<n.length;t++){let r=n[t].getChildByLabel(e,!0);if(r)return r}return null},getChildrenByLabel(e,t=!1,n=[]){let r=this.children;for(let t=0;t<r.length;t++){let i=r[t];(i.label===e||e instanceof RegExp&&e.test(i.label))&&n.push(i)}if(t)for(let t=0;t<r.length;t++)r[t].getChildrenByLabel(e,!0,n);return n}}})),d_,f_,p_=o((()=>{Tg(),d_=[new Cg,new Cg,new Cg,new Cg],f_=class e{constructor(e=0,t=0,n=0,r=0){this.type=`rectangle`,this.x=Number(e),this.y=Number(t),this.width=Number(n),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new e(0,0,0,0)}clone(){return new e(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,n,r=.5){let{width:i,height:a}=this;if(i<=0||a<=0)return!1;let o=this.x,s=this.y,c=n*(1-r),l=n-c,u=o-c,d=o+i+c,f=s-c,p=s+a+c,m=o+l,h=o+i-l,g=s+l,_=s+a-l;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>m&&e<h&&t>g&&t<_)}intersects(e,t){if(!t){let t=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=t)return!1;let n=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>n}let n=this.left,r=this.right,i=this.top,a=this.bottom;if(r<=n||a<=i)return!1;let o=d_[0].set(e.left,e.top),s=d_[1].set(e.left,e.bottom),c=d_[2].set(e.right,e.top),l=d_[3].set(e.right,e.bottom);if(c.x<=o.x||s.y<=o.y)return!1;let u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(o,o),t.apply(s,s),t.apply(c,c),t.apply(l,l),Math.max(o.x,s.x,c.x,l.x)<=n||Math.min(o.x,s.x,c.x,l.x)>=r||Math.max(o.y,s.y,c.y,l.y)<=i||Math.min(o.y,s.y,c.y,l.y)>=a))return!1;let d=u*(s.y-o.y),f=u*(o.x-s.x),p=d*n+f*i,m=d*r+f*i,h=d*n+f*a,g=d*r+f*a;if(Math.max(p,m,h,g)<=d*o.x+f*o.y||Math.min(p,m,h,g)>=d*l.x+f*l.y)return!1;let _=u*(o.y-c.y),v=u*(c.x-o.x),y=_*n+v*i,b=_*r+v*i,x=_*n+v*a,S=_*r+v*a;return!(Math.max(y,b,x,S)<=_*o.x+v*o.y||Math.min(y,b,x,S)>=_*l.x+v*l.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){let t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),i=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(n-t,0),this.y=r,this.height=Math.max(i-r,0),this}ceil(e=1,t=.001){let n=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=n-this.x,this.height=r-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){let t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),i=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=n-t,this.y=r,this.height=i-r,this}getBounds(t){return t||=new e,t.copyFrom(this),t}containsRect(e){if(this.width<=0||this.height<=0)return!1;let t=e.x,n=e.y,r=e.x+e.width,i=e.y+e.height;return t>=this.x&&t<this.x+this.width&&n>=this.y&&n<this.y+this.height&&r>=this.x&&r<=this.x+this.width&&i>=this.y&&i<=this.y+this.height}set(e,t,n,r){return this.x=e,this.y=t,this.width=n,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}})),m_,h_,g_=o((()=>{K(),p_(),m_=new G,h_=class e{constructor(e=1/0,t=1/0,n=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=m_,this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||=new f_;let e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=m_,this}set(e,t,n,r){this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}addFrame(e,t,n,r,i){i||=this.matrix;let a=i.a,o=i.b,s=i.c,c=i.d,l=i.tx,u=i.ty,d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,h=a*e+s*t+l,g=o*e+c*t+u;h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*t+l,g=o*n+c*t+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*e+s*r+l,g=o*e+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*r+l,g=o*n+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){let t=this.minX,n=this.minY,r=this.maxX,i=this.maxY,{a,b:o,c:s,d:c,tx:l,ty:u}=e,d=a*t+s*n+l,f=o*t+c*n+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=a*r+s*n+l,f=o*r+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*t+s*i+l,f=o*t+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+s*i+l,f=o*r+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,n,r){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<n&&(this.minY=n),this.maxY>r&&(this.maxY=r),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new e(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){let t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){let t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,t,n,r){let i=this.minX,a=this.minY,o=this.maxX,s=this.maxY;r||=this.matrix;let c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let r=t;r<n;r+=2){let t=e[r],n=e[r+1],m=c*t+u*n+f,h=l*t+d*n+p;i=m<i?m:i,a=h<a?h:a,o=m>o?m:o,s=h>s?h:s}this.minX=i,this.minY=a,this.maxX=o,this.maxY=s}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}})),__,v_,y_=o((()=>{K(),qg(),g_(),__=Kg.getPool(G),v_=Kg.getPool(h_)})),b_,x_,S_=o((()=>{K(),g_(),y_(),b_=new G,x_={getFastGlobalBounds(e,t){t||=new h_,t.clear(),this._getGlobalBoundsRecursive(!!e,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);let n=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(n.worldTransform),t},_getGlobalBoundsRecursive(e,t,n){let r=t;if(e&&this.parentRenderLayer&&this.parentRenderLayer!==n||this.localDisplayStatus!==7||!this.measurable)return;let i=!!this.effects.length;if((this.renderGroup||i)&&(r=v_.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){let e=this.bounds;r.addFrame(e.minX,e.minY,e.maxX,e.maxY,this.groupTransform)}let t=this.children;for(let i=0;i<t.length;i++)t[i]._getGlobalBoundsRecursive(e,r,n)}if(i){let e=!1,n=this.renderGroup||this.parentRenderGroup;for(let t=0;t<this.effects.length;t++)this.effects[t].addBounds&&(e||(e=!0,r.applyMatrix(n.worldTransform)),this.effects[t].addBounds(r,!0));e&&r.applyMatrix(n.worldTransform.copyTo(b_).invert()),t.addBounds(r),v_.return(r)}else this.renderGroup&&(t.addBounds(r,this.relativeGroupTransform),v_.return(r))}}}));function C_(e,t,n){n.clear();let r,i;return e.parent?t?r=e.parent.worldTransform:(i=__.get().identity(),r=T_(e,i)):r=G.IDENTITY,w_(e,n,r,t),i&&__.return(i),n.isValid||n.set(0,0,0,0),n}function w_(e,t,n,r){if(!e.visible||!e.measurable)return;let i;r?i=e.worldTransform:(e.updateLocalTransform(),i=__.get(),i.appendFrom(e.localTransform,n));let a=t,o=!!e.effects.length;if(o&&(t=v_.get().clear()),e.boundsArea)t.addRect(e.boundsArea,i);else{let n=e.bounds;n&&!n.isEmpty()&&(t.matrix=i,t.addBounds(n));for(let n=0;n<e.children.length;n++)w_(e.children[n],t,i,r)}if(o){for(let n=0;n<e.effects.length;n++)e.effects[n].addBounds?.(t);a.addBounds(t,G.IDENTITY),v_.return(t)}r||__.return(i)}function T_(e,t){let n=e.parent;return n&&(T_(n,t),n.updateLocalTransform(),t.append(n.localTransform)),t}var E_=o((()=>{K(),y_()}));function D_(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;let n=e>>16&255,r=e>>8&255,i=e&255,a=t>>16&255,o=t>>8&255,s=t&255,c=n*a/255|0,l=r*o/255|0,u=i*s/255|0;return(c<<16)+(l<<8)+u}var O_=o((()=>{}));function k_(e,t){return e===A_?t:t===A_?e:D_(e,t)}var A_,j_=o((()=>{O_(),A_=16777215}));function M_(e){return((e&255)<<16)+(e&65280)+(e>>16&255)}var N_,P_=o((()=>{K(),E_(),y_(),j_(),N_={getGlobalAlpha(e){if(e)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,n=this.parent;for(;n;)t*=n.alpha,n=n.parent;return t},getGlobalTransform(e=new G,t){if(t)return e.copyFrom(this.worldTransform);this.updateLocalTransform();let n=T_(this,__.get().identity());return e.appendFrom(this.localTransform,n),__.return(n),e},getGlobalTint(e){if(e)return this.renderGroup?M_(this.renderGroup.worldColor):this.parentRenderGroup?M_(k_(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,n=this.parent;for(;n;)t=k_(t,n.localColor),n=n.parent;return M_(t)}}}));function F_(e,t,n){return t.clear(),n||=G.IDENTITY,I_(e,t,n,e,!0),t.isValid||t.set(0,0,0,0),t}function I_(e,t,n,r,i){let a;if(i)a=__.get(),a=n.copyTo(a);else{if(!e.visible||!e.measurable)return;e.updateLocalTransform();let t=e.localTransform;a=__.get(),a.appendFrom(t,n)}let o=t,s=!!e.effects.length;if(s&&(t=v_.get().clear()),e.boundsArea)t.addRect(e.boundsArea,a);else{e.renderPipeId&&(t.matrix=a,t.addBounds(e.bounds));let n=e.children;for(let e=0;e<n.length;e++)I_(n[e],t,a,r,!1)}if(s){for(let n=0;n<e.effects.length;n++)e.effects[n].addLocalBounds?.(t,r);o.addBounds(t,G.IDENTITY),v_.return(t)}__.return(a)}var L_=o((()=>{K(),y_()}));function R_(e,t){let n=e.children;for(let e=0;e<n.length;e++){let r=n[e],i=r.uid,a=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,o=t.index;(t.data[o]!==i||t.data[o+1]!==a)&&(t.data[t.index]=i,t.data[t.index+1]=a,t.didChange=!0),t.index=o+2,r.children.length&&R_(r,t)}return t.didChange}var z_=o((()=>{})),B_,V_,H_=o((()=>{K(),g_(),E_(),L_(),z_(),B_=new G,V_={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(e,t){let n=Math.sign(this.scale.x)||1;t===0?this.scale.x=n:this.scale.x=e/t*n},_setHeight(e,t){let n=Math.sign(this.scale.y)||1;t===0?this.scale.y=n:this.scale.y=e/t*n},getLocalBounds(){this._localBoundsCacheData||={data:[],index:1,didChange:!1,localBounds:new h_};let e=this._localBoundsCacheData;return e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick&&(e.didChange=!0,e.data[0]=this._didViewChangeTick),R_(this,e),e.didChange&&F_(this,e.localBounds,B_),e.localBounds},getBounds(e,t){return C_(this,e,t||new h_)}}})),U_,W_=o((()=>{U_={_onRender:null,set onRender(e){let t=this.renderGroup||this.parentRenderGroup;if(!e){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=e},get onRender(){return this._onRender}}}));function G_(e,t){return e._zIndex-t._zIndex}var K_,q_=o((()=>{K_={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(e){this._zIndex!==e&&(this._zIndex=e,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(G_))}}})),J_,Y_=o((()=>{Tg(),y_(),J_={getGlobalPosition(e=new Cg,t=!1){return this.parent?this.parent.toGlobal(this._position,e,t):(e.x=this._position.x,e.y=this._position.y),e},toGlobal(e,t,n=!1){let r=this.getGlobalTransform(__.get(),n);return t=r.apply(e,t),__.return(r),t},toLocal(e,t,n,r){t&&(e=t.toGlobal(e,n,r));let i=this.getGlobalTransform(__.get(),r);return n=i.applyInverse(e,n),__.return(i),n}}})),X_,Z_=o((()=>{Mg(),X_=class{constructor(){this.uid=Ag(`instructionSet`),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,[`type`,`action`])}}}));function Q_(e){return e+=+(e===0),--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function $_(e){return!(e&e-1)&&!!e}var ev=o((()=>{}));function tv(e){let t={};for(let n in e)e[n]!==void 0&&(t[n]=e[n]);return t}var nv=o((()=>{}));function rv(e){let t=iv[e];return t===void 0&&(iv[e]=Ag(`resource`)),t}var iv,av,ov,sv=o((()=>{Fh(),Mg(),Lg(),iv=Object.create(null),av=class e extends Ph{constructor(t={}){super(),this._resourceType=`textureSampler`,this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...e.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){q(Pg,`TextureStyle.wrapMode is now TextureStyle.addressMode`),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,16),this._maxAnisotropy>1&&(this.scaleMode=`linear`)}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit(`change`,this)}_generateResourceId(){let e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=rv(e),this._resourceId}destroy(){this.destroyed=!0,this.emit(`destroy`,this),this.emit(`change`,this),this.removeAllListeners()}},av.defaultOptions={addressMode:`clamp-to-edge`,scaleMode:`linear`},ov=av})),cv,lv,uv=o((()=>{Fh(),ev(),nv(),Mg(),sv(),cv=class e extends Ph{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=Ag(`textureSource`),this._resourceType=`textureSource`,this._resourceId=Ag(`resource`),this.uploadMethodId=`unknown`,this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format=`rgba8unorm`,this.dimension=`2d`,this.viewDimension=`2d`,this.arrayLayerCount=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...e.defaultOptions,...t},this.label=t.label??``,this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,this.pixelWidth=t.width?t.width*this._resolution:this.resource?this.resourceWidth??1:1,this.pixelHeight=t.height?t.height*this._resolution:this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=t.transient??!1,this.alphaMode=t.alphaMode,this.style=new ov(tv(t)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){this.style!==e&&(this._ownsStyle=!1,this._style?.off(`change`,this._onStyleChange,this),this._style=e,this._style?.on(`change`,this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit(`styleChange`,this)}update(){if(this.resource){let e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit(`update`,this)}destroy(){this.destroyed=!0,this.unload(),this.emit(`destroy`,this),this._style&&=(this._ownsStyle&&this._style.destroy(),null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=Ag(`resource`),this.emit(`change`,this),this.emit(`unload`,this);for(let e in this._gpuData)this._gpuData[e]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){let{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){let{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,n){n||=this._resolution,e||=this.width,t||=this.height;let r=Math.round(e*n),i=Math.round(t*n);return this.width=r/n,this.height=i/n,this._resolution=n,this.pixelWidth===r&&this.pixelHeight===i?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=i,this.emit(`resize`,this),this._resourceId=Ag(`resource`),this.emit(`change`,this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit(`updateMipmaps`,this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=$_(this.pixelWidth)&&$_(this.pixelHeight)}static test(e){throw Error(`Unimplemented`)}},cv.defaultOptions={resolution:1,format:`bgra8unorm`,alphaMode:`premultiply-alpha-on-upload`,dimensions:`2d`,viewDimension:`2d`,arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1},lv=cv}));function dv(){for(let e=0;e<16;e++){let t=[];gv.push(t);for(let n=0;n<16;n++){let r=vv(fv[e]*fv[n]+mv[e]*pv[n]),i=vv(pv[e]*fv[n]+hv[e]*pv[n]),a=vv(fv[e]*mv[n]+mv[e]*hv[n]),o=vv(pv[e]*mv[n]+hv[e]*hv[n]);for(let e=0;e<16;e++)if(fv[e]===r&&pv[e]===i&&mv[e]===a&&hv[e]===o){t.push(e);break}}}for(let e=0;e<16;e++){let t=new G;t.set(fv[e],pv[e],mv[e],hv[e],0,0),_v.push(t)}}var fv,pv,mv,hv,gv,_v,vv,yv,bv=o((()=>{K(),fv=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],pv=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],mv=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],hv=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],gv=[],_v=[],vv=Math.sign,dv(),yv={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:e=>fv[e],uY:e=>pv[e],vX:e=>mv[e],vY:e=>hv[e],inv:e=>e&8?e&15:-e&7,add:(e,t)=>gv[e][t],sub:(e,t)=>gv[e][yv.inv(t)],rotate180:e=>e^4,isVertical:e=>(e&3)==2,byDirection:(e,t)=>Math.abs(e)*2<=Math.abs(t)?t>=0?yv.S:yv.N:Math.abs(t)*2<=Math.abs(e)?e>0?yv.E:yv.W:t>0?e>0?yv.SE:yv.SW:e>0?yv.NE:yv.NW,matrixAppendRotationInv:(e,t,n=0,r=0,i=0,a=0)=>{let o=_v[yv.inv(t)],s=o.a,c=o.b,l=o.c,u=o.d,d=n-Math.min(0,s*i,l*a,s*i+l*a),f=r-Math.min(0,c*i,u*a,c*i+u*a),p=e.a,m=e.b,h=e.c,g=e.d;e.a=s*p+c*h,e.b=s*m+c*g,e.c=l*p+u*h,e.d=l*m+u*g,e.tx=d*p+f*h+e.tx,e.ty=d*m+f*g+e.ty},transformRectCoords:(e,t,n,r)=>{let{x:i,y:a,width:o,height:s}=e,{x:c,y:l,width:u,height:d}=t;return n===yv.E?(r.set(i+c,a+l,o,s),r):n===yv.S?r.set(u-a-s+c,i+l,s,o):n===yv.W?r.set(u-i-o+c,d-a-s+l,o,s):n===yv.N?r.set(a+c,d-i-o+l,s,o):r.set(i+c,a+l,o,s)}}})),xv,Sv=o((()=>{xv=()=>{}})),Cv,wv=o((()=>{W(),uv(),Cv=class extends lv{constructor(e){let t=e.resource||new Float32Array(e.width*e.height*4),n=e.format;n||=t instanceof Float32Array?`rgba32float`:t instanceof Int32Array||t instanceof Uint32Array?`rgba32uint`:t instanceof Int16Array||t instanceof Uint16Array?`rgba16uint`:(t instanceof Int8Array,`bgra8unorm`),super({...e,resource:t,format:n}),this.uploadMethodId=`buffer`}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}},Cv.extension=H.TextureSource})),Tv,Ev,Dv=o((()=>{K(),Tv=new G,Ev=class{constructor(e,t){this.mapCoord=new G,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,this.clampMargin=t===void 0?e.width<10?0:.5:t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture?.removeListener(`update`,this.update,this),this._texture=e,this._texture.addListener(`update`,this.update,this)),this.update()}destroy(){this._texture?.removeListener(`update`,this.update,this),this._texture=null}multiplyUvs(e,t){t===void 0&&(t=e);let n=this.mapCoord;for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];t[r]=i*n.a+a*n.c+n.tx,t[r+1]=i*n.b+a*n.d+n.ty}return t}update(){let e=this._texture;this._updateID++;let t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);let n=e.orig,r=e.trim;r&&(Tv.set(n.width/r.width,0,0,n.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(Tv));let i=e.source,a=this.uClampFrame,o=this.clampMargin/i._resolution,s=this.clampOffset/i._resolution;return a[0]=(e.frame.x+o+s)/i.width,a[1]=(e.frame.y+o+s)/i.height,a[2]=(e.frame.x+e.frame.width-o+s)/i.width,a[3]=(e.frame.y+e.frame.height-o+s)/i.height,this.uClampOffset[0]=this.clampOffset/i.pixelWidth,this.uClampOffset[1]=this.clampOffset/i.pixelHeight,this.isSimple=e.frame.width===i.width&&e.frame.height===i.height&&e.rotate===0,!0}}})),Y,Ov=o((()=>{Fh(),bv(),p_(),Mg(),Lg(),Sv(),wv(),uv(),Dv(),Y=class extends Ph{constructor({source:e,label:t,frame:n,orig:r,trim:i,defaultAnchor:a,defaultBorders:o,rotate:s,dynamic:c}={}){if(super(),this.uid=Ag(`texture`),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new f_,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new lv,this.noFrame=!n,n)this.frame.copyFrom(n);else{let{width:e,height:t}=this._source;this.frame.width=e,this.frame.height=t}this.orig=r||this.frame,this.trim=i,this.rotate=s??0,this.defaultAnchor=a,this.defaultBorders=o,this.destroyed=!1,this.dynamic=c||!1,this.updateUvs()}set source(e){this._source&&this._source.off(`resize`,this.update,this),this._source=e,e.on(`resize`,this.update,this),this.emit(`update`,this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||=new Ev(this),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){let{uvs:e,frame:t}=this,{width:n,height:r}=this._source,i=t.x/n,a=t.y/r,o=t.width/n,s=t.height/r,c=this.rotate;if(c){let t=o/2,n=s/2,r=i+t,l=a+n;c=yv.add(c,yv.NW),e.x0=r+t*yv.uX(c),e.y0=l+n*yv.uY(c),c=yv.add(c,2),e.x1=r+t*yv.uX(c),e.y1=l+n*yv.uY(c),c=yv.add(c,2),e.x2=r+t*yv.uX(c),e.y2=l+n*yv.uY(c),c=yv.add(c,2),e.x3=r+t*yv.uX(c),e.y3=l+n*yv.uY(c)}else e.x0=i,e.y0=a,e.x1=i+o,e.y1=a,e.x2=i+o,e.y2=a+s,e.x3=i,e.y3=a+s}destroy(e=!1){this._source&&(this._source.off(`resize`,this.update,this),e&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit(`destroy`,this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit(`update`,this)}get baseTexture(){return q(Pg,`Texture.baseTexture is now Texture.source`),this._source}},Y.EMPTY=new Y({label:`EMPTY`,source:new lv({label:`EMPTY`})}),Y.EMPTY.destroy=xv,Y.WHITE=new Y({source:new Cv({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:`premultiply-alpha-on-upload`,label:`WHITE`}),label:`WHITE`}),Y.WHITE.destroy=xv})),kv,Av,jv,Mv=o((()=>{ev(),Hg(),uv(),Ov(),sv(),kv=0,Av=class{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new ov(this.textureOptions)}createTexture(e,t,n,r){let i=new lv({...this.textureOptions,width:e,height:t,resolution:1,antialias:n,autoGarbageCollect:!1,autoGenerateMipmaps:r});return new Y({source:i,label:`texturePool_${kv++}`})}getOptimalTexture(e,t,n=1,r,i=!1){let a=Math.ceil(e*n-1e-6),o=Math.ceil(t*n-1e-6);a=Q_(a),o=Q_(o);let s=+!!r,c=+!!i,l=(a<<17)+(o<<2)+(c<<1)+s;this._texturePool[l]||(this._texturePool[l]=[]);let u=this._texturePool[l].pop();return u||=this.createTexture(a,o,r,i),u.source._resolution=n,u.source.width=a/n,u.source.height=o/n,u.source.pixelWidth=a,u.source.pixelHeight=o,u.frame.x=0,u.frame.y=0,u.frame.width=e,u.frame.height=t,u.updateUvs(),this._poolKeyHash[u.uid]=l,u}getSameSizeTexture(e,t=!1){let n=e.source;return this.getOptimalTexture(e.width,e.height,n._resolution,t)}returnTexture(e,t=!1){let n=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[n].push(e)}clear(e){if(e=e!==!1,e)for(let e in this._texturePool){let t=this._texturePool[e];if(t)for(let e=0;e<t.length;e++)t[e].destroy(!0)}this._texturePool={}}},jv=new Av,Vg.register(jv)})),Nv,Pv=o((()=>{K(),Z_(),Mv(),Nv=class{constructor(){this.renderPipeId=`renderGroup`,this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new G,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new X_,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;let t=e.children;for(let e=0;e<t.length;e++){let n=t[e];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&=(jv.returnTexture(this.texture,!0),null)}updateCacheTexture(){this.textureNeedsUpdate=!0;let e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(let e in this.childrenToUpdate){let t=this.childrenToUpdate[e];t.list.fill(null),t.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){let t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.relativeRenderGroupDepth=e.parent===this.root?1:e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);let t=e.children;for(let e=0;e<t.length;e++)this.addChild(t[e])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}let t=e.children;for(let e=0;e<t.length;e++)this.removeChild(t[e])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]},t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.indexOf(e)===-1&&this._onRenderContainers.push(e)}removeOnRender(e){let t=this._onRenderContainers.indexOf(e);t!==-1&&this._onRenderContainers.splice(t,1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(e=[]){let t=this.root.children;for(let n=0;n<t.length;n++)this._getChildren(t[n],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;let n=e.children;for(let e=0;e<n.length;e++)this._getChildren(n[e],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||=new G,this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||=new G,this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;let e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||=new G,this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}}));function Fv(e,t,n={}){for(let r in t)!n[r]&&t[r]!==void 0&&(e[r]=t[r])}var Iv=o((()=>{})),Lv,Rv,zv,Bv,X,Vv=o((()=>{Fh(),gg(),vg(),W(),K(),Sg(),kg(),Mg(),Lg(),Bg(),qg(),Yg(),$g(),t_(),c_(),u_(),S_(),P_(),H_(),W_(),q_(),Y_(),Pv(),Iv(),Lv=new Og(null),Rv=new Og(null),zv=new Og(null,1,1),Bv=new Og(null),X=class e extends Ph{constructor(e={}){super(),this.uid=Ag(`renderable`),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new G,this.relativeGroupTransform=new G,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Og(this,0,0),this._scale=zv,this._pivot=Rv,this._origin=Bv,this._skew=Lv,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode=`inherit`,this.groupBlendMode=`normal`,this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Fv(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach(e=>this.addChild(e)),e.parent?.addChild(this)}static mixin(t){q(`8.8.0`,`Container.mixin is deprecated, please use extensions.mixin instead.`),U.mixin(e,t)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||q(Pg,`addChild: Only Containers will be allowed to add children in v8.0.0`),e.length>1){for(let t=0;t<e.length;t++)this.addChild(e[t]);return e[0]}let t=e[0],n=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),n&&(n.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,n&&n.addChild(t),this.emit(`childAdded`,t,this,this.children.length-1),t.emit(`added`,this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let t=0;t<e.length;t++)this.removeChild(e[t]);return e[0]}let t=e[0],n=this.children.indexOf(t);return n>-1&&(this._didViewChangeTick++,this.children.splice(n,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit(`childRemoved`,t,this,n),t.emit(`removed`,this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Kg.get(Nv,this),this.groupTransform=G.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),Kg.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||=new G,this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*bg}set angle(e){this.rotation=e*xg}get pivot(){return this._pivot===Rv&&(this._pivot=new Og(this,0,0)),this._pivot}set pivot(e){this._pivot===Rv&&(this._pivot=new Og(this,0,0),this._origin!==Bv&&J(`Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.`)),typeof e==`number`?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===Lv&&(this._skew=new Og(this,0,0)),this._skew}set skew(e){this._skew===Lv&&(this._skew=new Og(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===zv&&(this._scale=new Og(this,1,1)),this._scale}set scale(e){this._scale===zv&&(this._scale=new Og(this,0,0)),typeof e==`string`&&(e=parseFloat(e)),typeof e==`number`?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===Bv&&(this._origin=new Og(this,0,0)),this._origin}set origin(e){this._origin===Bv&&(this._origin=new Og(this,0,0),this._pivot!==Rv&&J(`Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.`)),typeof e==`number`?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){let t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){let t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||={};let t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){let n=this.getLocalBounds();typeof e==`object`?(t=e.height??e.width,e=e.width):t??=e,e!==void 0&&this._setWidth(e,n.width),t!==void 0&&this._setHeight(t,n.height)}_updateSkew(){let e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x==`number`?e.x:this.position.x,typeof e.y==`number`?e.y:this.position.y),this.scale.set(typeof e.scaleX==`number`?e.scaleX:this.scale.x,typeof e.scaleY==`number`?e.scaleY:this.scale.y),this.rotation=typeof e.rotation==`number`?e.rotation:this.rotation,this.skew.set(typeof e.skewX==`number`?e.skewX:this.skew.x,typeof e.skewY==`number`?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX==`number`?e.pivotX:this.pivot.x,typeof e.pivotY==`number`?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX==`number`?e.originX:this.origin.x,typeof e.originY==`number`?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;let t=this.localTransform,n=this._scale,r=this._pivot,i=this._origin,a=this._position,o=n._x,s=n._y,c=r._x,l=r._y,u=-i._x,d=-i._y;t.a=this._cx*o,t.b=this._sx*o,t.c=this._cy*s,t.d=this._sy*s,t.tx=a._x-(c*t.a+l*t.c)+(u*t.a+d*t.c)-u,t.ty=a._y-(c*t.b+l*t.d)+(u*t.b+d*t.d)-d}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){let t=hg.shared.setValue(e??16777215).toBgrNumber();t!==this.localColor&&(this.localColor=t,this._updateFlags|=1,this._onUpdate())}get tint(){return M_(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate(),this.emit(`visibleChanged`,e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){let t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=+!!e;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit(`destroyed`,this),this.removeAllListeners(),(typeof e==`boolean`?e:e?.children)&&t)for(let n=0;n<t.length;++n)t[n].destroy(e);this.renderGroup?.destroy(),this.renderGroup=null}},U.mixin(X,Qg,x_,J_,U_,V_,s_,l_,K_,_g,Jg,N_,e_)})),Hv,Uv=o((()=>{Hv=(e=>(e[e.INTERACTION=50]=`INTERACTION`,e[e.HIGH=25]=`HIGH`,e[e.NORMAL=0]=`NORMAL`,e[e.LOW=-25]=`LOW`,e[e.UTILITY=-50]=`UTILITY`,e))(Hv||{})})),Wv,Gv=o((()=>{Wv=class{constructor(e,t=null,n=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=n,this._once=r}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));let t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let t=this.next;return this.next=e?null:t,this.previous=null,t}}})),Kv,qv,Jv=o((()=>{Uv(),Gv(),Kv=class e{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Wv(null,null,1/0),this.deltaMS=1/e.targetFPMS,this.elapsedMS=1/e.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,t,n=Hv.NORMAL){return this._addListener(new Wv(e,t,n))}addOnce(e,t,n=Hv.NORMAL){return this._addListener(new Wv(e,t,n,!0))}_addListener(e){let t=this._head.next,n=this._head;if(!t)e.connect(n);else{for(;t;){if(e.priority>t.priority){e.connect(n);break}n=t,t=t.next}e.previous||e.connect(n)}return this._startIfPossible(),this}remove(e,t){let n=this._head.next;for(;n;)n=n.match(e,t)?n.destroy():n.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){let e=t-this._lastFrame|0;if(e<this._minElapsedMS)return;this._lastFrame=t-e%this._minElapsedMS}this.deltaMS=n,this.deltaTime=this.deltaMS*e.targetFPMS;let r=this._head,i=r.next;for(;i;)i=i.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let n=Math.min(Math.max(0,t)/1e3,e.targetFPMS);this._maxElapsedMS=1/n,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!e._shared){let t=e._shared=new e;t.autoStart=!0,t._protected=!0}return e._shared}static get system(){if(!e._system){let t=e._system=new e;t.autoStart=!0,t._protected=!0}return e._system}},Kv.targetFPMS=.06,qv=Kv})),Yv,Xv=o((()=>{Uv(),Jv(),Yv=class{constructor(e){this._lastTransform=``,this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let e=this._canvas.getBoundingClientRect(),t=this._canvas.width,n=this._canvas.height,r=e.width/t*this._renderer.resolution,i=e.height/n*this._renderer.resolution,a=`translate(${e.left}px, ${e.top}px) scale(${r}, ${i})`;a!==this._lastTransform&&(this._domElement.style.transform=a,this._lastTransform=a)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){`ResizeObserver`in globalThis?(this._observer&&=(this._observer.disconnect(),null),this._observer=new ResizeObserver(e=>{for(let t of e){if(t.target!==this._canvas)continue;let e=this.canvas.width,n=this.canvas.height,r=t.contentRect.width/e*this._renderer.resolution,i=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==r||this._lastScaleY!==i)&&(this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=i)}}),this._observer.observe(this._canvas)):this._tickerAttached||qv.shared.add(this.updateTranslation,this,Hv.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&qv.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform=``,this._lastScaleX=null,this._lastScaleY=null}}})),Zv,Qv=o((()=>{Tg(),Zv=class e{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=e.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Cg,this.page=new Cg,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,n){throw Error(`initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}initUIEvent(e,t,n,r,i){throw Error(`initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}}));function $v(e){return function(t){return t.test(e)}}function ey(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=$v(n),a={apple:{phone:i(ty)&&!i(ly),ipod:i(ny),tablet:!i(ty)&&(i(ry)||gy(t))&&!i(ly),universal:i(iy),device:(i(ty)||i(ny)||i(ry)||i(iy)||gy(t))&&!i(ly)},amazon:{phone:i(sy),tablet:!i(sy)&&i(cy),device:i(sy)||i(cy)},android:{phone:!i(ly)&&i(sy)||!i(ly)&&i(ay),tablet:!i(ly)&&!i(sy)&&!i(ay)&&(i(cy)||i(oy)),device:!i(ly)&&(i(sy)||i(cy)||i(ay)||i(oy))||i(/\bokhttp\b/i)},windows:{phone:i(ly),tablet:i(uy),device:i(ly)||i(uy)},other:{blackberry:i(dy),blackberry10:i(fy),opera:i(py),firefox:i(hy),chrome:i(my),device:i(dy)||i(fy)||i(py)||i(hy)||i(my)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var ty,ny,ry,iy,ay,oy,sy,cy,ly,uy,dy,fy,py,my,hy,gy,_y=o((()=>{ty=/iPhone/i,ny=/iPod/i,ry=/iPad/i,iy=/\biOS-universal(?:.+)Mac\b/i,ay=/\bAndroid(?:.+)Mobile\b/i,oy=/Android/i,sy=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,cy=/Silk/i,ly=/Windows Phone/i,uy=/\bWindows(?:.+)ARM\b/i,dy=/BlackBerry/i,fy=/BB10/i,py=/Opera Mini/i,my=/\b(CriOS|Chrome)(?:.+)Mobile/i,hy=/Mobile(?:.+)Firefox\b/i,gy=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`}})),vy=o((()=>{_y(),_y()})),yy,by=o((()=>{vy(),yy=(ey.default??ey)(globalThis.navigator)})),xy,Sy,Cy,wy,Ty,Ey,Dy,Oy,ky,Ay,jy,My=o((()=>{Xv(),Qv(),W(),by(),Zg(),xy=9,Sy=100,Cy=0,wy=0,Ty=2,Ey=1,Dy=-1e3,Oy=-1e3,ky=2,Ay=class e{constructor(e,t=yy){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let e=document.createElement(`button`);e.style.width=`${Ey}px`,e.style.height=`${Ey}px`,e.style.position=`absolute`,e.style.top=`${Dy}px`,e.style.left=`${Oy}px`,e.style.zIndex=ky.toString(),e.style.backgroundColor=`#FF0000`,e.title=`select to enable accessibility for this content`,e.addEventListener(`focus`,()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&=(document.body.removeChild(this._hookDiv),null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement(`div`),this._div.style.position=`absolute`,this._div.style.top=`${Cy}px`,this._div.style.left=`${wy}px`,this._div.style.pointerEvents=`none`,this._div.style.zIndex=Ty.toString(),this._canvasObserver=new Yv({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener(`mousemove`,this._boundOnMouseMove,!0);let e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{let t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener(`mousemove`,this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(let e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(let e in this._pools)this._pools[e].forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);let t=e.children;if(t)for(let e=0;e<t.length;e++)this._updateAccessibleObjects(t[e])}init(t){let n={accessibilityOptions:{...e.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=n.accessibilityOptions.debug,this._activateOnTab=n.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=n.accessibilityOptions.deactivateOnMouseMove,n.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){let e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;let t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(let e of this._children)e._renderId===this._renderId&&t.add(this._children.indexOf(e))}for(let e=this._children.length-1;e>=0;e--){let n=this._children[e];t.has(e)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,Xg(this._children,e,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let e=0;e<this._children.length;e++){let t=this._children[e];if(!t._accessibleActive||!t._accessibleDiv)continue;let n=t._accessibleDiv,r=t.hitArea||t.getBounds().rectangle;if(t.hitArea){let e=t.worldTransform;n.style.left=`${e.tx+r.x*e.a}px`,n.style.top=`${e.ty+r.y*e.d}px`,n.style.width=`${r.width*e.a}px`,n.style.height=`${r.height*e.d}px`}else this._capHitArea(r),n.style.left=`${r.x}px`,n.style.top=`${r.y}px`,n.style.width=`${r.width}px`,n.style.height=`${r.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);let{width:t,height:n}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>n&&(e.height=n-e.y)}_addChild(e){let t=this._getPool(e.accessibleType).pop();t?(t.innerHTML=``,t.removeAttribute(`title`),t.removeAttribute(`aria-label`),t.tabIndex=0):(e.accessibleType===`button`?t=document.createElement(`button`):(t=document.createElement(e.accessibleType),t.style.cssText=`
package/dist/build.json CHANGED
@@ -1 +1 @@
1
- {"commit":"d3e094e","rootCommands":[["auth","Authentication management"],["boards","Read, write, animate and export Boards (by id or .board path)"],["profile","Manage your profile"],["me","Account-level data across your spaces"],["prompt [options] [content...]","Send or schedule a prompt in a space"],["completion [options] [content...]","Raw LLM completion with full message control"],["decision [options] [state...]","Answer yes/no, choice and score questions about text or images"],["spaces","Space management"],["labels","Manage personal labels"],["runtime","Connect a local workspace"],["generate [options] [prompt]","Generate multimodal outputs"],["models","List available LLM and multimodal models"],["prompts","Prompt template management"],["public","Upload and manage public Space files"],["skills","Skill management"],["search [options] [query]","Search spaces, chats, and label items"],["references","Inspect resource references (forks, mentions, tool calls, mods, file access)"],["referrals [options]","View and manage your referral link"],["tasks","Task runs"],["cron-jobs","Scheduled jobs"],["apps|works","App management"],["rooms","Take part in App rooms: join, read and publish events, set presence"],["feedback [options] [message...]","Send feedback or a bug report to the Cohub team"],["desktop","Drive the Cohub desktop that started this chat"],["version [options]","This CLI, the cohub on PATH, and the versions running Runtimes serve"]]}
1
+ {"commit":"ffe5450","rootCommands":[["auth","Authentication management"],["boards","Read, write, animate and export Boards (by id or .board path)"],["profile","Manage your profile"],["me","Account-level data across your spaces"],["prompt [options] [content...]","Send or schedule a prompt in a space"],["completion [options] [content...]","Raw LLM completion with full message control"],["decision [options] [state...]","Answer yes/no, choice and score questions about text or images"],["spaces","Space management"],["labels","Manage personal labels"],["runtime","Connect a local workspace"],["generate [options] [prompt]","Generate multimodal outputs"],["models","List available LLM and multimodal models"],["prompts","Prompt template management"],["public","Upload and manage public Space files"],["skills","Skill management"],["search [options] [query]","Search spaces, chats, and label items"],["references","Inspect resource references (forks, mentions, tool calls, mods, file access)"],["referrals [options]","View and manage your referral link"],["tasks","Task runs"],["cron-jobs","Scheduled jobs"],["apps|works","App management"],["rooms","Take part in App rooms: join, read and publish events, set presence"],["feedback [options] [message...]","Send feedback or a bug report to the Cohub team"],["desktop","Drive the Cohub desktop that started this chat"],["version [options]","This CLI, the cohub on PATH, and the versions running Runtimes serve"]]}
@@ -37969,7 +37969,7 @@ function diffBoardEdits(from, to, ids) {
37969
37969
  const BOARD_INPUT = {
37970
37970
  dragSlop: {
37971
37971
  mouse: 4,
37972
- touch: 8,
37972
+ touch: 12,
37973
37973
  pen: 8
37974
37974
  },
37975
37975
  tapMs: 300,
@@ -37984,6 +37984,7 @@ const BOARD_INPUT = {
37984
37984
  flingSampleMs: 80,
37985
37985
  flingDecay: .95,
37986
37986
  flingStop: .02,
37987
+ flingCatch: .1,
37987
37988
  swipeDistance: .2,
37988
37989
  swipeVelocity: .4,
37989
37990
  edgeZone: 32,
@@ -38854,8 +38855,9 @@ function createCameraModule(ctx) {
38854
38855
  motion = next;
38855
38856
  if (!frame) frame = requestAnimationFrame(step);
38856
38857
  }
38858
+ /** True when it halted a fling still fast enough that a press should only catch it. */
38857
38859
  function stop() {
38858
- const flinging = motion?.kind === "fling";
38860
+ const flinging = motion?.kind === "fling" && Math.hypot(motion.vx, motion.vy) >= BOARD_INPUT.flingCatch;
38859
38861
  motion = null;
38860
38862
  if (frame) cancelAnimationFrame(frame);
38861
38863
  frame = 0;
@@ -40005,6 +40007,7 @@ function createInteractionModule(ctx) {
40005
40007
  let travelled = false;
40006
40008
  let samples = [];
40007
40009
  let penSeen = false;
40010
+ let touchAway = false;
40008
40011
  function transformEnd(gesture, cancelled) {
40009
40012
  if (!transformListeners.size || !("moved" in gesture) || !gesture.moved) return;
40010
40013
  let event;
@@ -40022,7 +40025,7 @@ function createInteractionModule(ctx) {
40022
40025
  for (const listener of transformListeners) listener(event);
40023
40026
  }
40024
40027
  function activate(itemId, at, pointerType, selected) {
40025
- if (performance.now() - at > BOARD_INPUT.tapMs || !state.scene.get(itemId)) return;
40028
+ if (performance.now() - at > BOARD_INPUT.longPressMs || !state.scene.get(itemId)) return;
40026
40029
  for (const listener of activationListeners) listener({
40027
40030
  itemId,
40028
40031
  pointerType,
@@ -40035,8 +40038,11 @@ function createInteractionModule(ctx) {
40035
40038
  function movable(item) {
40036
40039
  return Boolean(item && !ctx.query.isLocked(item) && registry.capabilities(item).canMove);
40037
40040
  }
40038
- function opensOnTap(item) {
40039
- return registry.activation(item, browsing()) === "tap";
40041
+ function opensOnTap(item, pointerType = state.hoverPointerType) {
40042
+ return registry.activation(item, browsing(), pointerType) === "tap";
40043
+ }
40044
+ function handPicks(pointerType) {
40045
+ return isTouchLikePointer(pointerType) || options.readonly === true || options.handClick === "pick";
40040
40046
  }
40041
40047
  function holdsFrame(pointerType) {
40042
40048
  const view = ctx.frames.view();
@@ -40227,10 +40233,14 @@ function createInteractionModule(ctx) {
40227
40233
  function plainPrimary(event) {
40228
40234
  return event.button === 0 && !event.shiftKey && !event.metaKey && !event.ctrlKey && !event.altKey;
40229
40235
  }
40230
- function pressCard(event) {
40236
+ function opensNow(item, pointerType, hand) {
40237
+ if (!hand) return options.readonly === true || !ctx.selection.carries(item.id);
40238
+ return pointerType !== "mouse" || options.handClick !== "pick" || state.selection.includes(item.id);
40239
+ }
40240
+ function pressCard(event, hand = false) {
40231
40241
  if (!plainPrimary(event)) return false;
40232
40242
  const item = ctx.query.pickAt(event.world, event.pointerType);
40233
- if (!item || !options.readonly && ctx.selection.carries(item.id) || !opensOnTap(item)) return false;
40243
+ if (!item || !opensOnTap(item, event.pointerType) || !opensNow(item, event.pointerType, hand)) return false;
40234
40244
  state.interaction = {
40235
40245
  type: "pressing",
40236
40246
  itemId: item.id,
@@ -40248,7 +40258,7 @@ function createInteractionModule(ctx) {
40248
40258
  const dx = event.screen.x - gesture.start.x;
40249
40259
  const dy = event.screen.y - gesture.start.y;
40250
40260
  const item = state.scene.get(gesture.itemId);
40251
- if (!(!options.readonly && !ctx.frames.view()?.present && (state.tool === "select" || state.tool === "play") && movable(item))) {
40261
+ if (!(!touchAway && !options.readonly && !ctx.frames.view()?.present && (state.tool === "select" || state.tool === "play") && movable(item))) {
40252
40262
  state.interaction = {
40253
40263
  type: "panning",
40254
40264
  start: gesture.start,
@@ -40285,6 +40295,7 @@ function createInteractionModule(ctx) {
40285
40295
  const id = gesture.type === "pressing" ? gesture.itemId : gesture.type === "panning" && !gesture.moved ? gesture.tapSelection?.targetId : null;
40286
40296
  const item = id ? state.scene.get(id) : null;
40287
40297
  if (!movable(item)) return null;
40298
+ if (touchAway) ctx.chosenTool = null;
40288
40299
  state.selection = [item.id];
40289
40300
  state.tool = "select";
40290
40301
  state.interaction = {
@@ -40306,10 +40317,13 @@ function createInteractionModule(ctx) {
40306
40317
  const reach = portHitRadius("touch") / zoom;
40307
40318
  return visiblePorts().some((port) => Math.hypot(port.point.x - point.x, port.point.y - point.y) <= reach);
40308
40319
  }
40309
- function browseByTouch(event) {
40310
- if (options.readonly || event.pointerType !== "touch" || state.tool !== "select") return;
40311
- if (keepsSelection(event.world)) return;
40312
- if (ctx.chosenTool === "select" && state.selection.length === 0) return;
40320
+ /** A touch away from the selection browses like the hand; only a tap there drops the selection. */
40321
+ function touchesAway(event) {
40322
+ if (options.readonly || event.pointerType !== "touch" || state.tool !== "select") return false;
40323
+ if (keepsSelection(event.world)) return false;
40324
+ return ctx.chosenTool !== "select" || state.selection.length > 0;
40325
+ }
40326
+ function returnToHand() {
40313
40327
  state.selection = [];
40314
40328
  state.tool = "hand";
40315
40329
  ctx.chosenTool = null;
@@ -40369,6 +40383,7 @@ function createInteractionModule(ctx) {
40369
40383
  pointerType: event.pointerType
40370
40384
  };
40371
40385
  travelled = false;
40386
+ touchAway = false;
40372
40387
  samples = [];
40373
40388
  if (event.pointerType === "pen") penSeen = true;
40374
40389
  const touch = isTouchLikePointer(event.pointerType);
@@ -40392,14 +40407,15 @@ function createInteractionModule(ctx) {
40392
40407
  };
40393
40408
  return;
40394
40409
  }
40395
- browseByTouch(event);
40410
+ touchAway = touchesAway(event);
40396
40411
  const { tool, spaceHeld } = state;
40397
40412
  if (tool === "play") return play(event);
40398
40413
  const additive = event.shiftKey || event.metaKey || event.ctrlKey;
40399
- if (!spaceHeld && (tool === "hand" || options.readonly) && pressCard(event)) return;
40414
+ const hand = tool === "hand" || touchAway;
40415
+ if (!spaceHeld && (hand || options.readonly) && pressCard(event, hand)) return;
40400
40416
  const fingerOnPenCanvas = tool === "draw" && event.pointerType === "touch" && penSeen;
40401
- if (tool === "hand" || spaceHeld || event.button === 1 || fingerOnPenCanvas) {
40402
- const picks = tool === "hand" && !spaceHeld && event.button === 0 && (touch || options.readonly);
40417
+ if (hand || spaceHeld || event.button === 1 || fingerOnPenCanvas) {
40418
+ const picks = hand && !spaceHeld && event.button === 0 && handPicks(event.pointerType);
40403
40419
  state.interaction = {
40404
40420
  type: "panning",
40405
40421
  start: event.screen,
@@ -40540,7 +40556,7 @@ function createInteractionModule(ctx) {
40540
40556
  at,
40541
40557
  select: [item.id]
40542
40558
  };
40543
- if (plainPrimary(event) && opensOnTap(item) && (!selected || selection.length === 1)) tap = {
40559
+ if (plainPrimary(event) && opensOnTap(item, event.pointerType) && (!selected || selection.length === 1)) tap = {
40544
40560
  at,
40545
40561
  activate: item.id
40546
40562
  };
@@ -40867,6 +40883,7 @@ function createInteractionModule(ctx) {
40867
40883
  if (Math.abs(state.camera.zoom / gesture.origin.zoom - 1) > .01) ctx.frames.refit(true);
40868
40884
  else ctx.frames.swipe(event.screen.x - gesture.start.x, event.screen.y - gesture.start.y, vx, vy);
40869
40885
  } else if (tap && !gesture.moved) {
40886
+ if (touchAway) returnToHand();
40870
40887
  const target = tap.targetId && state.scene.get(tap.targetId) ? tap.targetId : null;
40871
40888
  if (tap.additive && target) ctx.selection.toggle(target);
40872
40889
  else state.selection = target ? [target] : [];
@@ -40878,7 +40895,8 @@ function createInteractionModule(ctx) {
40878
40895
  break;
40879
40896
  }
40880
40897
  case "pressing":
40881
- activate(gesture.itemId, gesture.at, gesture.pointerType, false);
40898
+ if (touchAway) returnToHand();
40899
+ activate(gesture.itemId, gesture.at, gesture.pointerType, state.selection.includes(gesture.itemId));
40882
40900
  break;
40883
40901
  case "translating":
40884
40902
  if (gesture.moved) land(gesture);
@@ -40957,6 +40975,7 @@ function createInteractionModule(ctx) {
40957
40975
  } : null;
40958
40976
  }),
40959
40977
  opensOnTap,
40978
+ handPicks,
40960
40979
  pointerDown,
40961
40980
  pointerMove,
40962
40981
  pointerUp,
@@ -42240,6 +42259,7 @@ function createBoardEditor(options) {
42240
42259
  itemAt: tracked(["scene", "camera"], query.itemAt),
42241
42260
  pickAt: tracked(["scene", "camera"], query.pickAt),
42242
42261
  opensOnTap: tracked(["scene"], interaction.opensOnTap),
42262
+ handPicks: interaction.handPicks,
42243
42263
  itemById: tracked(["scene"], query.itemById),
42244
42264
  labelItemAt: tracked([
42245
42265
  "scene",
@@ -6110,6 +6110,17 @@ var SpaceUsageApi = class {
6110
6110
  return this.transport.request(`/api/spaces/${this.spaceId}/usage?${params.toString()}`, { fetch: customFetch });
6111
6111
  }
6112
6112
  };
6113
+ var SpaceOverviewApi = class {
6114
+ transport;
6115
+ spaceId;
6116
+ constructor(transport, spaceId) {
6117
+ this.transport = transport;
6118
+ this.spaceId = spaceId;
6119
+ }
6120
+ get(customFetch) {
6121
+ return this.transport.request(`/api/spaces/${this.spaceId}/overview`, { fetch: customFetch });
6122
+ }
6123
+ };
6113
6124
  var SpaceActivityApi = class {
6114
6125
  transport;
6115
6126
  spaceId;
@@ -6568,6 +6579,7 @@ var SpaceClient = class {
6568
6579
  checkpoints;
6569
6580
  usage;
6570
6581
  activity;
6582
+ overview;
6571
6583
  channels;
6572
6584
  mods;
6573
6585
  webhooks;
@@ -6593,6 +6605,7 @@ var SpaceClient = class {
6593
6605
  this.checkpoints = createSpaceCheckpointsApi(transport, id);
6594
6606
  this.usage = new SpaceUsageApi(transport, id);
6595
6607
  this.activity = new SpaceActivityApi(transport, id);
6608
+ this.overview = new SpaceOverviewApi(transport, id);
6596
6609
  this.channels = new SpaceChannelsApi(transport, id);
6597
6610
  this.mods = new SpaceModsApi(transport, id);
6598
6611
  this.webhooks = new SpaceWebhooksApi(transport, id);
@@ -11239,7 +11252,7 @@ attach: attachAppEmbed },
11239
11252
  };
11240
11253
  }
11241
11254
  };
11242
- const USERNAME_PATTERN = /^(?!-)(?!.*--)[a-z0-9-]{1,39}(?<!-)$/;
11255
+ const USERNAME_PATTERN = /^(?!.*--)[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$/;
11243
11256
  const SPACE_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9_-]{0,78}[a-z0-9])?$/;
11244
11257
  /**
11245
11258
  * Platform-owned path segments that must not be newly assigned to public
@@ -11252,12 +11265,14 @@ const RESERVED_PLATFORM_PATH_SEGMENTS = Object.freeze([
11252
11265
  "auth",
11253
11266
  "callback",
11254
11267
  "changelog",
11268
+ "dev",
11255
11269
  "docs",
11256
11270
  "explore",
11257
11271
  "invite",
11258
11272
  "landing",
11259
11273
  "login",
11260
11274
  "logout",
11275
+ "mobile",
11261
11276
  "new",
11262
11277
  "org",
11263
11278
  "pricing",
package/dist/chunks/id.js CHANGED
@@ -2040,7 +2040,7 @@ function applyBoardPatch(state, input, options = {}) {
2040
2040
  for (const [id, value] of nextAnimations) {
2041
2041
  if (value !== null) continue;
2042
2042
  for (const ref of state.trackRefs(id)) {
2043
- if (ref.animation === id || track(ref.animation, ref.track) === void 0) continue;
2043
+ if (ref.animation === id || track(ref.animation, ref.track)?.target !== id) continue;
2044
2044
  if (options.cascade) setTrack(ref.animation, ref.track, null);
2045
2045
  else diagnostics.push(error(`animations.${id}`, "ANIMATION_REFERENCED", `${id} is nested in ${ref.animation}.${ref.track}; delete the track or use cascade`));
2046
2046
  }
@@ -1,5 +1,5 @@
1
1
  import { C as MODEL_THINKING_LEVELS, i as isApprovalMode, t as APPROVAL_MODES, w as isModelThinkingLevel, x as harnessSchema } from "./runtime.js";
2
- import { C as error, Ct as splitDisplayText, D as json, E as handleHttp, M as truncateText, N as warn, O as jsonRequested, St as normalizeDisplayPoint, T as formatLocalDateTime, _ as failSpaceTarget, _t as displayActStepSchema, b as resolveSpace, bt as DISPLAY_SYSTEM_ACTIONS, ct as buildSpaceInvitePath, dt as localWorkspaceHttpError, g as explicitSpace, gt as DISPLAY_RECORDINGS_DIR, ht as DISPLAY_HANDOVER_WAIT_MS, j as table, k as ok, mt as DISPLAY_HANDOVER_MAX_MS, pt as DISPLAY_HANDOVER_DEFAULT_MS, r as createRealtimeClient, t as createClient, ut as LocalWorkspaceUnavailableError, vt as DISPLAY_ELEMENT_REF_PATTERN, w as formatEpochMs, x as resolveSpaceRef, yt as DISPLAY_ELEMENT_ROLES } from "./client.js";
2
+ import { C as error, Ct as splitDisplayText, D as json, E as handleHttp, L as authSource, M as truncateText, N as warn, O as jsonRequested, St as normalizeDisplayPoint, T as formatLocalDateTime, _ as failSpaceTarget, _t as displayActStepSchema, b as resolveSpace, bt as DISPLAY_SYSTEM_ACTIONS, ct as buildSpaceInvitePath, dt as localWorkspaceHttpError, g as explicitSpace, gt as DISPLAY_RECORDINGS_DIR, ht as DISPLAY_HANDOVER_WAIT_MS, j as table, k as ok, mt as DISPLAY_HANDOVER_MAX_MS, pt as DISPLAY_HANDOVER_DEFAULT_MS, r as createRealtimeClient, t as createClient, ut as LocalWorkspaceUnavailableError, vt as DISPLAY_ELEMENT_REF_PATTERN, w as formatEpochMs, x as resolveSpaceRef, yt as DISPLAY_ELEMENT_ROLES } from "./client.js";
3
3
  import { n as uploadChatImageAsset, o as UPLOAD_MAX_FILE_BYTES, r as uploadLikeStickerAsset, t as uploadAvatarAsset } from "./avatar.js";
4
4
  import { o as mimeTypeForPath } from "./id.js";
5
5
  import { d as normalizeRequestSource, l as joinApiUrl, p as isUuidLike } from "./app-realtime.js";
@@ -1536,6 +1536,7 @@ function registerSpaceWallet(spaces) {
1536
1536
  ]);
1537
1537
  console.log(`Public funding: ${value.publicFunding ? "on" : "off"}`);
1538
1538
  if (value.transfer) console.log(`Transferable balance: ${usd(value.transfer.allowanceUsd)} (whole dollars, ${usd(value.transfer.minUsd)}–${usd(value.transfer.maxUsd)})`);
1539
+ else console.log(authSource() === "execution-token" ? "Transferable balance: requires a signed-in user session (unset COHUB_EXECUTION_TOKEN, then run `cohub auth login`)" : "Transferable balance: unavailable");
1539
1540
  } catch (cause) {
1540
1541
  handleHttp(cause);
1541
1542
  }
@@ -3080,6 +3081,41 @@ const LABEL_RESOURCE_TYPES = [
3080
3081
  ];
3081
3082
  /** Table cell width for space descriptions; `--json` keeps the full value. */
3082
3083
  const SPACE_DESCRIPTION_COLUMN_WIDTH = 40;
3084
+ function printSpaceOverview({ apps, schedules, days }) {
3085
+ const revenue = apps.revenue ? `$${apps.revenue.usd.toFixed(2)}${apps.revenue.partial ? "+" : ""}` : void 0;
3086
+ const runs = schedules ? `${schedules.runs} in ${days}d, ${schedules.failed} failed` : void 0;
3087
+ console.log();
3088
+ table([{
3089
+ ...apps,
3090
+ revenue,
3091
+ active: schedules?.active,
3092
+ runs
3093
+ }], [
3094
+ {
3095
+ key: "count",
3096
+ label: "Apps"
3097
+ },
3098
+ {
3099
+ key: "views",
3100
+ label: "Views"
3101
+ },
3102
+ {
3103
+ key: "likes",
3104
+ label: "Likes"
3105
+ },
3106
+ ...revenue ? [{
3107
+ key: "revenue",
3108
+ label: "Revenue"
3109
+ }] : [],
3110
+ ...schedules ? [{
3111
+ key: "active",
3112
+ label: "Schedules"
3113
+ }, {
3114
+ key: "runs",
3115
+ label: "Runs"
3116
+ }] : []
3117
+ ]);
3118
+ }
3083
3119
  function parseInteger(value, name, options = {}) {
3084
3120
  if (!/^-?\d+$/.test(value.trim())) return error(`Invalid ${name}`, `${name} must be an integer`);
3085
3121
  const parsed = Number.parseInt(value, 10);
@@ -3613,8 +3649,11 @@ function registerSpaces(program) {
3613
3649
  const spaceId = id?.trim() || await resolveSpace(spacesCmd);
3614
3650
  const client = createClient();
3615
3651
  try {
3616
- const space = await client.spaces.get(spaceId);
3617
- if (jsonRequested(opts)) return json(space);
3652
+ const [space, overview] = await Promise.all([client.spaces.get(spaceId), client.space(spaceId).overview.get().catch(() => null)]);
3653
+ if (jsonRequested(opts)) return json({
3654
+ ...space,
3655
+ overview
3656
+ });
3618
3657
  const usage = space.workspaceUsage;
3619
3658
  const storage = usage ? `${usage.bytes === null ? "-" : formatBytes(usage.bytes)} (${usage.status})` : void 0;
3620
3659
  const likeSticker = space.publicProfile?.likeSticker?.url;
@@ -3657,6 +3696,7 @@ function registerSpaces(program) {
3657
3696
  label: "Like sticker"
3658
3697
  }] : []
3659
3698
  ]);
3699
+ if (overview) printSpaceOverview(overview);
3660
3700
  } catch (e) {
3661
3701
  handleHttp(e);
3662
3702
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "10.27.1",
3
+ "version": "10.28.1",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -33,7 +33,7 @@
33
33
  "@fontsource-variable/figtree": "^5.3.0",
34
34
  "@fontsource-variable/geist": "^5.3.0",
35
35
  "@fontsource-variable/geist-mono": "^5.3.0",
36
- "@neta-art/cohub": "13.18.0",
36
+ "@neta-art/cohub": "13.20.0",
37
37
  "@types/node": "26.6.4",
38
38
  "@types/ws": "^8.18.1",
39
39
  "commander": "^15.0.0",