@vivi2d/web 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +160 -0
  2. package/README.md +201 -0
  3. package/dist/CanvasPool-CASccukD.js +48 -0
  4. package/dist/CanvasPool-CASccukD.js.map +1 -0
  5. package/dist/CanvasRenderer-BWDoXN0L.js +5750 -0
  6. package/dist/CanvasRenderer-BWDoXN0L.js.map +1 -0
  7. package/dist/GpuStencilModesToPixi-c2lsBIrd.js +221 -0
  8. package/dist/GpuStencilModesToPixi-c2lsBIrd.js.map +1 -0
  9. package/dist/RenderTargetSystem-BCowAg_f.js +3493 -0
  10. package/dist/RenderTargetSystem-BCowAg_f.js.map +1 -0
  11. package/dist/WebGLRenderer-KKZauisz.js +2236 -0
  12. package/dist/WebGLRenderer-KKZauisz.js.map +1 -0
  13. package/dist/WebGPURenderer-xmqgPtcF.js +1632 -0
  14. package/dist/WebGPURenderer-xmqgPtcF.js.map +1 -0
  15. package/dist/auto-register.d.ts +1 -0
  16. package/dist/auto-register.js +3 -0
  17. package/dist/auto-register.js.map +1 -0
  18. package/dist/browserAll-DQ0eWekj.js +1872 -0
  19. package/dist/browserAll-DQ0eWekj.js.map +1 -0
  20. package/dist/canvasUtils-BSaR9Fot.js +210 -0
  21. package/dist/canvasUtils-BSaR9Fot.js.map +1 -0
  22. package/dist/errors.d.ts +12 -0
  23. package/dist/getTextureBatchBindGroup-BYhXfZM4.js +22 -0
  24. package/dist/getTextureBatchBindGroup-BYhXfZM4.js.map +1 -0
  25. package/dist/index-CW8mx7yF.js +18805 -0
  26. package/dist/index-CW8mx7yF.js.map +1 -0
  27. package/dist/index.d.ts +7 -0
  28. package/dist/model-loader.d.ts +42 -0
  29. package/dist/player.d.ts +85 -0
  30. package/dist/vivi-model-element.d.ts +65 -0
  31. package/dist/vivi2d.es.js +11 -0
  32. package/dist/vivi2d.es.js.map +1 -0
  33. package/dist/vivi2d.umd.js +1020 -0
  34. package/dist/vivi2d.umd.js.map +1 -0
  35. package/dist/webworkerAll-oTmmI2Qm.js +694 -0
  36. package/dist/webworkerAll-oTmmI2Qm.js.map +1 -0
  37. package/package.json +56 -0
@@ -0,0 +1,1020 @@
1
+ (function(ht){typeof define=="function"&&define.amd?define(ht):ht()})((function(){"use strict";var XP=Object.defineProperty;var YP=(ht,Ve,At)=>Ve in ht?XP(ht,Ve,{enumerable:!0,configurable:!0,writable:!0,value:At}):ht[Ve]=At;var $=(ht,Ve,At)=>YP(ht,typeof Ve!="symbol"?Ve+"":Ve,At);function Ve(r){return`${(r/1024/1024).toFixed(1)}MB`}function At(r,e,t){if(!Number.isFinite(r)||r<0)throw new Error(`${t} has an invalid size.`);if(r>e)throw new Error(`${t} is too large (${Ve(r)}, max ${Ve(e)}).`)}function ss(r,e,t){const n=new TextEncoder().encode(r).byteLength;if(n>e)throw new Error(`${t} is too large (${Ve(n)}, max ${Ve(e)}).`)}var Uo;function P(r,e,t){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(r))return;a._zod.traits.add(r),e(a,c);const l=o.prototype,u=Object.keys(l);for(let h=0;h<u.length;h++){const d=u[h];d in a||(a[d]=l[d].bind(a))}}const s=(t==null?void 0:t.Parent)??Object;class i extends s{}Object.defineProperty(i,"name",{value:r});function o(a){var c;const l=t!=null&&t.Parent?new i:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const u of l._zod.deferred)u();return l}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>{var c,l;return t!=null&&t.Parent&&a instanceof t.Parent?!0:(l=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:l.has(r)}}),Object.defineProperty(o,"name",{value:r}),o}class Nt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Lo extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(Uo=globalThis).__zod_globalConfig??(Uo.__zod_globalConfig={});const is=globalThis.__zod_globalConfig;function dt(r){return is}function zo(r){const e=Object.values(r).filter(n=>typeof n=="number");return Object.entries(r).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function os(r,e){return typeof e=="bigint"?e.toString():e}function en(r){return{get value(){{const e=r();return Object.defineProperty(this,"value",{value:e}),e}}}}function as(r){return r==null}function cs(r){const e=r.startsWith("^")?1:0,t=r.endsWith("$")?r.length-1:r.length;return r.slice(e,t)}function Tf(r,e){const t=r/e,n=Math.round(t),s=Number.EPSILON*Math.max(Math.abs(t),1);return Math.abs(t-n)<s?0:t-n}const No=Symbol("evaluating");function J(r,e,t){let n;Object.defineProperty(r,e,{get(){if(n!==No)return n===void 0&&(n=No,n=t()),n},set(s){Object.defineProperty(r,e,{value:s})},configurable:!0})}function kt(r,e,t){Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function St(...r){const e={};for(const t of r){const n=Object.getOwnPropertyDescriptors(t);Object.assign(e,n)}return Object.defineProperties({},e)}function $o(r){return JSON.stringify(r)}function Sf(r){return r.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Vo="captureStackTrace"in Error?Error.captureStackTrace:(...r)=>{};function xr(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const wf=en(()=>{var r;if(is.jitless||typeof navigator<"u"&&((r=navigator==null?void 0:navigator.userAgent)!=null&&r.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function $t(r){if(xr(r)===!1)return!1;const e=r.constructor;if(e===void 0||typeof e!="function")return!0;const t=e.prototype;return!(xr(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}function Ho(r){return $t(r)?{...r}:Array.isArray(r)?[...r]:r instanceof Map?new Map(r):r instanceof Set?new Set(r):r}const Pf=new Set(["string","number","symbol"]);function Vt(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wt(r,e,t){const n=new r._zod.constr(e??r._zod.def);return(!e||t!=null&&t.parent)&&(n._zod.parent=r),n}function I(r){const e=r;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0:e.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Ef(r){return Object.keys(r).filter(e=>r[e]._zod.optin==="optional"&&r[e]._zod.optout==="optional")}const Cf={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Mf(r,e){const t=r._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=St(r._zod.def,{get shape(){const o={};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(o[a]=t.shape[a])}return kt(this,"shape",o),o},checks:[]});return wt(r,i)}function Af(r,e){const t=r._zod.def,n=t.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=St(r._zod.def,{get shape(){const o={...r._zod.def.shape};for(const a in e){if(!(a in t.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete o[a]}return kt(this,"shape",o),o},checks:[]});return wt(r,i)}function kf(r,e){if(!$t(e))throw new Error("Invalid input to extend: expected a plain object");const t=r._zod.def.checks;if(t&&t.length>0){const i=r._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=St(r._zod.def,{get shape(){const i={...r._zod.def.shape,...e};return kt(this,"shape",i),i}});return wt(r,s)}function Rf(r,e){if(!$t(e))throw new Error("Invalid input to safeExtend: expected a plain object");const t=St(r._zod.def,{get shape(){const n={...r._zod.def.shape,...e};return kt(this,"shape",n),n}});return wt(r,t)}function If(r,e){var n;if((n=r._zod.def.checks)!=null&&n.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const t=St(r._zod.def,{get shape(){const s={...r._zod.def.shape,...e._zod.def.shape};return kt(this,"shape",s),s},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return wt(r,t)}function Bf(r,e,t){const s=e._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=St(e._zod.def,{get shape(){const a=e._zod.def.shape,c={...a};if(t)for(const l in t){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(c[l]=r?new r({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=r?new r({type:"optional",innerType:a[l]}):a[l];return kt(this,"shape",c),c},checks:[]});return wt(e,o)}function Ff(r,e,t){const n=St(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(t)for(const o in t){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(i[o]=new r({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new r({type:"nonoptional",innerType:s[o]});return kt(this,"shape",i),i}});return wt(e,n)}function Ht(r,e=0){var t;if(r.aborted===!0)return!0;for(let n=e;n<r.issues.length;n++)if(((t=r.issues[n])==null?void 0:t.continue)!==!0)return!0;return!1}function Gf(r,e=0){var t;if(r.aborted===!0)return!0;for(let n=e;n<r.issues.length;n++)if(((t=r.issues[n])==null?void 0:t.continue)===!1)return!0;return!1}function Pt(r,e){return e.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(r),t})}function tn(r){return typeof r=="string"?r:r==null?void 0:r.message}function ft(r,e,t){var c,l,u,h,d,f;const n=r.message?r.message:tn((u=(l=(c=r.inst)==null?void 0:c._zod.def)==null?void 0:l.error)==null?void 0:u.call(l,r))??tn((h=e==null?void 0:e.error)==null?void 0:h.call(e,r))??tn((d=t.customError)==null?void 0:d.call(t,r))??tn((f=t.localeError)==null?void 0:f.call(t,r))??"Invalid input",{inst:s,continue:i,input:o,...a}=r;return a.path??(a.path=[]),a.message=n,e!=null&&e.reportInput&&(a.input=o),a}function ls(r){return Array.isArray(r)?"array":typeof r=="string"?"string":"unknown"}function vr(...r){const[e,t,n]=r;return typeof e=="string"?{message:e,code:"custom",input:t,inst:n}:{...e}}const jo=(r,e)=>{r.name="$ZodError",Object.defineProperty(r,"_zod",{value:r._zod,enumerable:!1}),Object.defineProperty(r,"issues",{value:e,enumerable:!1}),r.message=JSON.stringify(e,os,2),Object.defineProperty(r,"toString",{value:()=>r.message,enumerable:!1})},Wo=P("$ZodError",jo),Xo=P("$ZodError",jo,{Parent:Error});function Of(r,e=t=>t.message){const t={},n=[];for(const s of r.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}function Df(r,e=t=>t.message){const t={_errors:[]},n=(s,i=[])=>{for(const o of s.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>n({issues:a},[...i,...o.path]));else if(o.code==="invalid_key")n({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")n({issues:o.issues},[...i,...o.path]);else{const a=[...i,...o.path];if(a.length===0)t._errors.push(e(o));else{let c=t,l=0;for(;l<a.length;){const u=a[l];l===a.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(e(o))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}}};return n(r),t}const us=r=>(e,t,n,s)=>{const i=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:t,issues:[]},i);if(o instanceof Promise)throw new Nt;if(o.issues.length){const a=new((s==null?void 0:s.Err)??r)(o.issues.map(c=>ft(c,i,dt())));throw Vo(a,s==null?void 0:s.callee),a}return o.value},hs=r=>async(e,t,n,s)=>{const i=n?{...n,async:!0}:{async:!0};let o=e._zod.run({value:t,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new((s==null?void 0:s.Err)??r)(o.issues.map(c=>ft(c,i,dt())));throw Vo(a,s==null?void 0:s.callee),a}return o.value},rn=r=>(e,t,n)=>{const s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:t,issues:[]},s);if(i instanceof Promise)throw new Nt;return i.issues.length?{success:!1,error:new(r??Wo)(i.issues.map(o=>ft(o,s,dt())))}:{success:!0,data:i.value}},Uf=rn(Xo),nn=r=>async(e,t,n)=>{const s=n?{...n,async:!0}:{async:!0};let i=e._zod.run({value:t,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new r(i.issues.map(o=>ft(o,s,dt())))}:{success:!0,data:i.value}},Lf=nn(Xo),zf=r=>(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return us(r)(e,t,s)},Nf=r=>(e,t,n)=>us(r)(e,t,n),$f=r=>async(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return hs(r)(e,t,s)},Vf=r=>async(e,t,n)=>hs(r)(e,t,n),Hf=r=>(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return rn(r)(e,t,s)},jf=r=>(e,t,n)=>rn(r)(e,t,n),Wf=r=>async(e,t,n)=>{const s=n?{...n,direction:"backward"}:{direction:"backward"};return nn(r)(e,t,s)},Xf=r=>async(e,t,n)=>nn(r)(e,t,n),Yf=/^[cC][0-9a-z]{6,}$/,Zf=/^[0-9a-z]+$/,Kf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,qf=/^[0-9a-vA-V]{20}$/,Jf=/^[A-Za-z0-9]{27}$/,Qf=/^[a-zA-Z0-9_-]{21}$/,ep=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,tp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Yo=r=>r?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${r}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,rp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,np="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function sp(){return new RegExp(np,"u")}const ip=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,op=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ap=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zo=/^[A-Za-z0-9_-]*$/,up=/^https?$/,hp=/^\+[1-9]\d{6,14}$/,Ko="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",dp=new RegExp(`^${Ko}$`);function qo(r){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof r.precision=="number"?r.precision===-1?`${e}`:r.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${r.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function fp(r){return new RegExp(`^${qo(r)}$`)}function pp(r){const e=qo({precision:r.precision}),t=["Z"];r.local&&t.push(""),r.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${t.join("|")})`;return new RegExp(`^${Ko}T(?:${n})$`)}const mp=r=>{const e=r?`[\\s\\S]{${(r==null?void 0:r.minimum)??0},${(r==null?void 0:r.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},gp=/^-?\d+$/,Jo=/^-?\d+(?:\.\d+)?$/,_p=/^(?:true|false)$/i,yp=/^[^A-Z]*$/,bp=/^[^a-z]*$/,Be=P("$ZodCheck",(r,e)=>{var t;r._zod??(r._zod={}),r._zod.def=e,(t=r._zod).onattach??(t.onattach=[])}),Qo={number:"number",bigint:"bigint",object:"date"},ea=P("$ZodCheckLessThan",(r,e)=>{Be.init(r,e);const t=Qo[typeof e.value];r._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),r._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:t,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:r,continue:!e.abort})}}),ta=P("$ZodCheckGreaterThan",(r,e)=>{Be.init(r,e);const t=Qo[typeof e.value];r._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),r._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:t,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:r,continue:!e.abort})}}),xp=P("$ZodCheckMultipleOf",(r,e)=>{Be.init(r,e),r._zod.onattach.push(t=>{var n;(n=t._zod.bag).multipleOf??(n.multipleOf=e.value)}),r._zod.check=t=>{if(typeof t.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof t.value=="bigint"?t.value%e.value===BigInt(0):Tf(t.value,e.value)===0)||t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:e.value,input:t.value,inst:r,continue:!e.abort})}}),vp=P("$ZodCheckNumberFormat",(r,e)=>{var o;Be.init(r,e),e.format=e.format||"float64";const t=(o=e.format)==null?void 0:o.includes("int"),n=t?"int":"number",[s,i]=Cf[e.format];r._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=s,c.maximum=i,t&&(c.pattern=gp)}),r._zod.check=a=>{const c=a.value;if(t){if(!Number.isInteger(c)){a.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:c,inst:r});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:r,origin:n,inclusive:!0,continue:!e.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:r,origin:n,inclusive:!0,continue:!e.abort});return}}c<s&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:r,continue:!e.abort}),c>i&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:r,continue:!e.abort})}}),Tp=P("$ZodCheckMaxLength",(r,e)=>{var t;Be.init(r,e),(t=r._zod.def).when??(t.when=n=>{const s=n.value;return!as(s)&&s.length!==void 0}),r._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),r._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const o=ls(s);n.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:r,continue:!e.abort})}}),Sp=P("$ZodCheckMinLength",(r,e)=>{var t;Be.init(r,e),(t=r._zod.def).when??(t.when=n=>{const s=n.value;return!as(s)&&s.length!==void 0}),r._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),r._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const o=ls(s);n.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:r,continue:!e.abort})}}),wp=P("$ZodCheckLengthEquals",(r,e)=>{var t;Be.init(r,e),(t=r._zod.def).when??(t.when=n=>{const s=n.value;return!as(s)&&s.length!==void 0}),r._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),r._zod.check=n=>{const s=n.value,i=s.length;if(i===e.length)return;const o=ls(s),a=i>e.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:r,continue:!e.abort})}}),sn=P("$ZodCheckStringFormat",(r,e)=>{var t,n;Be.init(r,e),r._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(t=r._zod).check??(t.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:r,continue:!e.abort})}):(n=r._zod).check??(n.check=()=>{})}),Pp=P("$ZodCheckRegex",(r,e)=>{sn.init(r,e),r._zod.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:r,continue:!e.abort})}}),Ep=P("$ZodCheckLowerCase",(r,e)=>{e.pattern??(e.pattern=yp),sn.init(r,e)}),Cp=P("$ZodCheckUpperCase",(r,e)=>{e.pattern??(e.pattern=bp),sn.init(r,e)}),Mp=P("$ZodCheckIncludes",(r,e)=>{Be.init(r,e);const t=Vt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${t}`:t);e.pattern=n,r._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),r._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:r,continue:!e.abort})}}),Ap=P("$ZodCheckStartsWith",(r,e)=>{Be.init(r,e);const t=new RegExp(`^${Vt(e.prefix)}.*`);e.pattern??(e.pattern=t),r._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(t)}),r._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:r,continue:!e.abort})}}),kp=P("$ZodCheckEndsWith",(r,e)=>{Be.init(r,e);const t=new RegExp(`.*${Vt(e.suffix)}$`);e.pattern??(e.pattern=t),r._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(t)}),r._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:r,continue:!e.abort})}}),Rp=P("$ZodCheckOverwrite",(r,e)=>{Be.init(r,e),r._zod.check=t=>{t.value=e.tx(t.value)}});class Ip{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const n=e.split(`
2
+ `).filter(o=>o),s=Math.min(...n.map(o=>o.length-o.trimStart().length)),i=n.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const e=Function,t=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new e(...t,s.join(`
3
+ `))}}const Bp={major:4,minor:4,patch:3},oe=P("$ZodType",(r,e)=>{var s;var t;r??(r={}),r._zod.def=e,r._zod.bag=r._zod.bag||{},r._zod.version=Bp;const n=[...r._zod.def.checks??[]];r._zod.traits.has("$ZodCheck")&&n.unshift(r);for(const i of n)for(const o of i._zod.onattach)o(r);if(n.length===0)(t=r._zod).deferred??(t.deferred=[]),(s=r._zod.deferred)==null||s.push(()=>{r._zod.run=r._zod.parse});else{const i=(a,c,l)=>{let u=Ht(a),h;for(const d of c){if(d._zod.def.when){if(Gf(a)||!d._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&(l==null?void 0:l.async)===!1)throw new Nt;if(h||p instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=Ht(a,f)))});else{if(a.issues.length===f)continue;u||(u=Ht(a,f))}}return h?h.then(()=>a):a},o=(a,c,l)=>{if(Ht(a))return a.aborted=!0,a;const u=i(c,n,l);if(u instanceof Promise){if(l.async===!1)throw new Nt;return u.then(h=>r._zod.parse(h,l))}return r._zod.parse(u,l)};r._zod.run=(a,c)=>{if(c.skipChecks)return r._zod.parse(a,c);if(c.direction==="backward"){const u=r._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(h=>o(h,a,c)):o(u,a,c)}const l=r._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Nt;return l.then(u=>i(u,n,c))}return i(l,n,c)}}J(r,"~standard",()=>({validate:i=>{var o;try{const a=Uf(r,i);return a.success?{value:a.data}:{issues:(o=a.error)==null?void 0:o.issues}}catch{return Lf(r,i).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}))}),ds=P("$ZodString",(r,e)=>{var t;oe.init(r,e),r._zod.pattern=[...((t=r==null?void 0:r._zod.bag)==null?void 0:t.patterns)??[]].pop()??mp(r._zod.bag),r._zod.parse=(n,s)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:r}),n}}),he=P("$ZodStringFormat",(r,e)=>{sn.init(r,e),ds.init(r,e)}),Fp=P("$ZodGUID",(r,e)=>{e.pattern??(e.pattern=tp),he.init(r,e)}),Gp=P("$ZodUUID",(r,e)=>{if(e.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Yo(n))}else e.pattern??(e.pattern=Yo());he.init(r,e)}),Op=P("$ZodEmail",(r,e)=>{e.pattern??(e.pattern=rp),he.init(r,e)}),Dp=P("$ZodURL",(r,e)=>{he.init(r,e),r._zod.check=t=>{var n;try{const s=t.value.trim();if(!e.normalize&&((n=e.protocol)==null?void 0:n.source)===up.source&&!/^https?:\/\//i.test(s)){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:r,continue:!e.abort});return}const i=new URL(s);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:t.value,inst:r,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:r,continue:!e.abort})),e.normalize?t.value=i.href:t.value=s;return}catch{t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:r,continue:!e.abort})}}}),Up=P("$ZodEmoji",(r,e)=>{e.pattern??(e.pattern=sp()),he.init(r,e)}),Lp=P("$ZodNanoID",(r,e)=>{e.pattern??(e.pattern=Qf),he.init(r,e)}),zp=P("$ZodCUID",(r,e)=>{e.pattern??(e.pattern=Yf),he.init(r,e)}),Np=P("$ZodCUID2",(r,e)=>{e.pattern??(e.pattern=Zf),he.init(r,e)}),$p=P("$ZodULID",(r,e)=>{e.pattern??(e.pattern=Kf),he.init(r,e)}),Vp=P("$ZodXID",(r,e)=>{e.pattern??(e.pattern=qf),he.init(r,e)}),Hp=P("$ZodKSUID",(r,e)=>{e.pattern??(e.pattern=Jf),he.init(r,e)}),jp=P("$ZodISODateTime",(r,e)=>{e.pattern??(e.pattern=pp(e)),he.init(r,e)}),Wp=P("$ZodISODate",(r,e)=>{e.pattern??(e.pattern=dp),he.init(r,e)}),Xp=P("$ZodISOTime",(r,e)=>{e.pattern??(e.pattern=fp(e)),he.init(r,e)}),Yp=P("$ZodISODuration",(r,e)=>{e.pattern??(e.pattern=ep),he.init(r,e)}),Zp=P("$ZodIPv4",(r,e)=>{e.pattern??(e.pattern=ip),he.init(r,e),r._zod.bag.format="ipv4"}),Kp=P("$ZodIPv6",(r,e)=>{e.pattern??(e.pattern=op),he.init(r,e),r._zod.bag.format="ipv6",r._zod.check=t=>{try{new URL(`http://[${t.value}]`)}catch{t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:r,continue:!e.abort})}}}),qp=P("$ZodCIDRv4",(r,e)=>{e.pattern??(e.pattern=ap),he.init(r,e)}),Jp=P("$ZodCIDRv6",(r,e)=>{e.pattern??(e.pattern=cp),he.init(r,e),r._zod.check=t=>{const n=t.value.split("/");try{if(n.length!==2)throw new Error;const[s,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:r,continue:!e.abort})}}});function ra(r){if(r==="")return!0;if(/\s/.test(r)||r.length%4!==0)return!1;try{return atob(r),!0}catch{return!1}}const Qp=P("$ZodBase64",(r,e)=>{e.pattern??(e.pattern=lp),he.init(r,e),r._zod.bag.contentEncoding="base64",r._zod.check=t=>{ra(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:r,continue:!e.abort})}});function em(r){if(!Zo.test(r))return!1;const e=r.replace(/[-_]/g,n=>n==="-"?"+":"/"),t=e.padEnd(Math.ceil(e.length/4)*4,"=");return ra(t)}const tm=P("$ZodBase64URL",(r,e)=>{e.pattern??(e.pattern=Zo),he.init(r,e),r._zod.bag.contentEncoding="base64url",r._zod.check=t=>{em(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:r,continue:!e.abort})}}),rm=P("$ZodE164",(r,e)=>{e.pattern??(e.pattern=hp),he.init(r,e)});function nm(r,e=null){try{const t=r.split(".");if(t.length!==3)return!1;const[n]=t;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const sm=P("$ZodJWT",(r,e)=>{he.init(r,e),r._zod.check=t=>{nm(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:r,continue:!e.abort})}}),na=P("$ZodNumber",(r,e)=>{oe.init(r,e),r._zod.pattern=r._zod.bag.pattern??Jo,r._zod.parse=(t,n)=>{if(e.coerce)try{t.value=Number(t.value)}catch{}const s=t.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return t;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return t.issues.push({expected:"number",code:"invalid_type",input:s,inst:r,...i?{received:i}:{}}),t}}),im=P("$ZodNumberFormat",(r,e)=>{vp.init(r,e),na.init(r,e)}),om=P("$ZodBoolean",(r,e)=>{oe.init(r,e),r._zod.pattern=_p,r._zod.parse=(t,n)=>{if(e.coerce)try{t.value=!!t.value}catch{}const s=t.value;return typeof s=="boolean"||t.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:r}),t}}),am=P("$ZodUnknown",(r,e)=>{oe.init(r,e),r._zod.parse=t=>t}),cm=P("$ZodNever",(r,e)=>{oe.init(r,e),r._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:r}),t)});function sa(r,e,t){r.issues.length&&e.issues.push(...Pt(t,r.issues)),e.value[t]=r.value}const lm=P("$ZodArray",(r,e)=>{oe.init(r,e),r._zod.parse=(t,n)=>{const s=t.value;if(!Array.isArray(s))return t.issues.push({expected:"array",code:"invalid_type",input:s,inst:r}),t;t.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const a=s[o],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?i.push(c.then(l=>sa(l,t,o))):sa(c,t,o)}return i.length?Promise.all(i).then(()=>t):t}});function on(r,e,t,n,s,i){const o=t in n;if(r.issues.length){if(s&&i&&!o)return;e.issues.push(...Pt(t,r.issues))}if(!o&&!s){r.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}r.value===void 0?o&&(e.value[t]=void 0):e.value[t]=r.value}function ia(r){var n,s,i,o;const e=Object.keys(r.shape);for(const a of e)if(!((o=(i=(s=(n=r.shape)==null?void 0:n[a])==null?void 0:s._zod)==null?void 0:i.traits)!=null&&o.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const t=Ef(r.shape);return{...r,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(t)}}function oa(r,e,t,n,s,i){const o=[],a=s.keySet,c=s.catchall._zod,l=c.def.type,u=c.optin==="optional",h=c.optout==="optional";for(const d in e){if(d==="__proto__"||a.has(d))continue;if(l==="never"){o.push(d);continue}const f=c.run({value:e[d],issues:[]},n);f instanceof Promise?r.push(f.then(p=>on(p,t,d,e,u,h))):on(f,t,d,e,u,h)}return o.length&&t.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),r.length?Promise.all(r).then(()=>t):t}const um=P("$ZodObject",(r,e)=>{oe.init(r,e);const t=Object.getOwnPropertyDescriptor(e,"shape");if(!(t!=null&&t.get)){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const n=en(()=>ia(e));J(r._zod,"propValues",()=>{const a=e.shape,c={};for(const l in a){const u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(const h of u.values)c[l].add(h)}}return c});const s=xr,i=e.catchall;let o;r._zod.parse=(a,c)=>{o??(o=n.value);const l=a.value;if(!s(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:r}),a;a.value={};const u=[],h=o.shape;for(const d of o.keys){const f=h[d],p=f._zod.optin==="optional",m=f._zod.optout==="optional",g=f._zod.run({value:l[d],issues:[]},c);g instanceof Promise?u.push(g.then(_=>on(_,a,d,l,p,m))):on(g,a,d,l,p,m)}return i?oa(u,l,a,c,n.value,r):u.length?Promise.all(u).then(()=>a):a}}),hm=P("$ZodObjectJIT",(r,e)=>{um.init(r,e);const t=r._zod.parse,n=en(()=>ia(e)),s=d=>{var b,v;const f=new Ip(["shape","payload","ctx"]),p=n.value,m=C=>{const S=$o(C);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};f.write("const input = payload.value;");const g=Object.create(null);let _=0;for(const C of p.keys)g[C]=`key_${_++}`;f.write("const newResult = {};");for(const C of p.keys){const S=g[C],E=$o(C),U=d[C],z=((b=U==null?void 0:U._zod)==null?void 0:b.optin)==="optional",M=((v=U==null?void 0:U._zod)==null?void 0:v.optout)==="optional";f.write(`const ${S} = ${m(C)};`),z&&M?f.write(`
4
+ if (${S}.issues.length) {
5
+ if (${E} in input) {
6
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${E}, ...iss.path] : [${E}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${S}.value === undefined) {
14
+ if (${E} in input) {
15
+ newResult[${E}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${E}] = ${S}.value;
19
+ }
20
+
21
+ `):z?f.write(`
22
+ if (${S}.issues.length) {
23
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${E}, ...iss.path] : [${E}]
26
+ })));
27
+ }
28
+
29
+ if (${S}.value === undefined) {
30
+ if (${E} in input) {
31
+ newResult[${E}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${E}] = ${S}.value;
35
+ }
36
+
37
+ `):f.write(`
38
+ const ${S}_present = ${E} in input;
39
+ if (${S}.issues.length) {
40
+ payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
41
+ ...iss,
42
+ path: iss.path ? [${E}, ...iss.path] : [${E}]
43
+ })));
44
+ }
45
+ if (!${S}_present && !${S}.issues.length) {
46
+ payload.issues.push({
47
+ code: "invalid_type",
48
+ expected: "nonoptional",
49
+ input: undefined,
50
+ path: [${E}]
51
+ });
52
+ }
53
+
54
+ if (${S}_present) {
55
+ if (${S}.value === undefined) {
56
+ newResult[${E}] = undefined;
57
+ } else {
58
+ newResult[${E}] = ${S}.value;
59
+ }
60
+ }
61
+
62
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");const y=f.compile();return(C,S)=>y(d,C,S)};let i;const o=xr,a=!is.jitless,l=a&&wf.value,u=e.catchall;let h;r._zod.parse=(d,f)=>{h??(h=n.value);const p=d.value;return o(p)?a&&l&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(i||(i=s(e.shape)),d=i(d,f),u?oa([],p,d,f,h,r):d):t(d,f):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:r}),d)}});function aa(r,e,t,n){for(const i of r)if(i.issues.length===0)return e.value=i.value,e;const s=r.filter(i=>!Ht(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:r.map(i=>i.issues.map(o=>ft(o,n,dt())))}),e)}const ca=P("$ZodUnion",(r,e)=>{oe.init(r,e),J(r._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),J(r._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),J(r._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),J(r._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){const n=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${n.map(s=>cs(s.source)).join("|")})$`)}});const t=e.options.length===1?e.options[0]._zod.run:null;r._zod.parse=(n,s)=>{if(t)return t(n,s);let i=!1;const o=[];for(const a of e.options){const c=a._zod.run({value:n.value,issues:[]},s);if(c instanceof Promise)o.push(c),i=!0;else{if(c.issues.length===0)return c;o.push(c)}}return i?Promise.all(o).then(a=>aa(a,n,r,s)):aa(o,n,r,s)}}),dm=P("$ZodDiscriminatedUnion",(r,e)=>{e.inclusive=!1,ca.init(r,e);const t=r._zod.parse;J(r._zod,"propValues",()=>{const s={};for(const i of e.options){const o=i._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(const[a,c]of Object.entries(o)){s[a]||(s[a]=new Set);for(const l of c)s[a].add(l)}}return s});const n=en(()=>{var o;const s=e.options,i=new Map;for(const a of s){const c=(o=a._zod.propValues)==null?void 0:o[e.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(a)}"`);for(const l of c){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,a)}}return i});r._zod.parse=(s,i)=>{const o=s.value;if(!xr(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:r}),s;const a=n.value.get(o==null?void 0:o[e.discriminator]);return a?a._zod.run(s,i):e.unionFallback||i.direction==="backward"?t(s,i):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:o,path:[e.discriminator],inst:r}),s)}}),fm=P("$ZodIntersection",(r,e)=>{oe.init(r,e),r._zod.parse=(t,n)=>{const s=t.value,i=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,l])=>la(t,c,l)):la(t,i,o)}});function fs(r,e){if(r===e)return{valid:!0,data:r};if(r instanceof Date&&e instanceof Date&&+r==+e)return{valid:!0,data:r};if($t(r)&&$t(e)){const t=Object.keys(e),n=Object.keys(r).filter(i=>t.indexOf(i)!==-1),s={...r,...e};for(const i of n){const o=fs(r[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(r)&&Array.isArray(e)){if(r.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let n=0;n<r.length;n++){const s=r[n],i=e[n],o=fs(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};t.push(o.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function la(r,e,t){const n=new Map;let s;for(const a of e.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else r.issues.push(a);for(const a of t.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else r.issues.push(a);const i=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&s&&r.issues.push({...s,keys:i}),Ht(r))return r;const o=fs(e.value,t.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return r.value=o.data,r}const pm=P("$ZodTuple",(r,e)=>{oe.init(r,e);const t=e.items;r._zod.parse=(n,s)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({input:i,inst:r,expected:"tuple",code:"invalid_type"}),n;n.value=[];const o=[],a=ua(t,"optin"),c=ua(t,"optout");if(!e.rest){if(i.length<a)return n.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:r,origin:"array"}),n;i.length>t.length&&n.issues.push({code:"too_big",maximum:t.length,inclusive:!0,input:i,inst:r,origin:"array"})}const l=new Array(t.length);for(let u=0;u<t.length;u++){const h=t[u]._zod.run({value:i[u],issues:[]},s);h instanceof Promise?o.push(h.then(d=>{l[u]=d})):l[u]=h}if(e.rest){let u=t.length-1;const h=i.slice(t.length);for(const d of h){u++;const f=e.rest._zod.run({value:d,issues:[]},s);f instanceof Promise?o.push(f.then(p=>ha(p,n,u))):ha(f,n,u)}}return o.length?Promise.all(o).then(()=>da(l,n,t,i,c)):da(l,n,t,i,c)}});function ua(r,e){for(let t=r.length-1;t>=0;t--)if(r[t]._zod[e]!=="optional")return t+1;return 0}function ha(r,e,t){r.issues.length&&e.issues.push(...Pt(t,r.issues)),e.value[t]=r.value}function da(r,e,t,n,s){for(let i=0;i<t.length;i++){const o=r[i],a=i<n.length;if(o.issues.length){if(!a&&i>=s){e.value.length=i;break}e.issues.push(...Pt(i,o.issues))}e.value[i]=o.value}for(let i=e.value.length-1;i>=n.length&&(t[i]._zod.optout==="optional"&&e.value[i]===void 0);i--)e.value.length=i;return e}const mm=P("$ZodRecord",(r,e)=>{oe.init(r,e),r._zod.parse=(t,n)=>{const s=t.value;if(!$t(s))return t.issues.push({expected:"record",code:"invalid_type",input:s,inst:r}),t;const i=[],o=e.keyType._zod.values;if(o){t.value={};const a=new Set;for(const l of o)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const u=e.keyType._zod.run({value:l,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length){t.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(f=>ft(f,n,dt())),input:l,path:[l],inst:r});continue}const h=u.value,d=e.valueType._zod.run({value:s[l],issues:[]},n);d instanceof Promise?i.push(d.then(f=>{f.issues.length&&t.issues.push(...Pt(l,f.issues)),t.value[h]=f.value})):(d.issues.length&&t.issues.push(...Pt(l,d.issues)),t.value[h]=d.value)}let c;for(const l in s)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:s,inst:r,keys:c})}else{t.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Jo.test(a)&&c.issues.length){const h=e.keyType._zod.run({value:Number(a),issues:[]},n);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(c=h)}if(c.issues.length){e.mode==="loose"?t.value[a]=s[a]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(h=>ft(h,n,dt())),input:a,path:[a],inst:r});continue}const u=e.valueType._zod.run({value:s[a],issues:[]},n);u instanceof Promise?i.push(u.then(h=>{h.issues.length&&t.issues.push(...Pt(a,h.issues)),t.value[c.value]=h.value})):(u.issues.length&&t.issues.push(...Pt(a,u.issues)),t.value[c.value]=u.value)}}return i.length?Promise.all(i).then(()=>t):t}}),gm=P("$ZodEnum",(r,e)=>{oe.init(r,e);const t=zo(e.entries),n=new Set(t);r._zod.values=n,r._zod.pattern=new RegExp(`^(${t.filter(s=>Pf.has(typeof s)).map(s=>typeof s=="string"?Vt(s):s.toString()).join("|")})$`),r._zod.parse=(s,i)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:t,input:o,inst:r}),s}}),_m=P("$ZodLiteral",(r,e)=>{if(oe.init(r,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);r._zod.values=t,r._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Vt(n):n?Vt(n.toString()):String(n)).join("|")})$`),r._zod.parse=(n,s)=>{const i=n.value;return t.has(i)||n.issues.push({code:"invalid_value",values:e.values,input:i,inst:r}),n}}),ym=P("$ZodTransform",(r,e)=>{oe.init(r,e),r._zod.optin="optional",r._zod.parse=(t,n)=>{if(n.direction==="backward")throw new Lo(r.constructor.name);const s=e.transform(t.value,t);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(o=>(t.value=o,t.fallback=!0,t));if(s instanceof Promise)throw new Nt;return t.value=s,t.fallback=!0,t}});function fa(r,e){return e===void 0&&(r.issues.length||r.fallback)?{issues:[],value:void 0}:r}const pa=P("$ZodOptional",(r,e)=>{oe.init(r,e),r._zod.optin="optional",r._zod.optout="optional",J(r._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),J(r._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${cs(t.source)})?$`):void 0}),r._zod.parse=(t,n)=>{if(e.innerType._zod.optin==="optional"){const s=t.value,i=e.innerType._zod.run(t,n);return i instanceof Promise?i.then(o=>fa(o,s)):fa(i,s)}return t.value===void 0?t:e.innerType._zod.run(t,n)}}),bm=P("$ZodExactOptional",(r,e)=>{pa.init(r,e),J(r._zod,"values",()=>e.innerType._zod.values),J(r._zod,"pattern",()=>e.innerType._zod.pattern),r._zod.parse=(t,n)=>e.innerType._zod.run(t,n)}),xm=P("$ZodNullable",(r,e)=>{oe.init(r,e),J(r._zod,"optin",()=>e.innerType._zod.optin),J(r._zod,"optout",()=>e.innerType._zod.optout),J(r._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${cs(t.source)}|null)$`):void 0}),J(r._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),r._zod.parse=(t,n)=>t.value===null?t:e.innerType._zod.run(t,n)}),vm=P("$ZodDefault",(r,e)=>{oe.init(r,e),r._zod.optin="optional",J(r._zod,"values",()=>e.innerType._zod.values),r._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);if(t.value===void 0)return t.value=e.defaultValue,t;const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(i=>ma(i,e)):ma(s,e)}});function ma(r,e){return r.value===void 0&&(r.value=e.defaultValue),r}const Tm=P("$ZodPrefault",(r,e)=>{oe.init(r,e),r._zod.optin="optional",J(r._zod,"values",()=>e.innerType._zod.values),r._zod.parse=(t,n)=>(n.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,n))}),Sm=P("$ZodNonOptional",(r,e)=>{oe.init(r,e),J(r._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(n=>n!==void 0)):void 0}),r._zod.parse=(t,n)=>{const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(i=>ga(i,r)):ga(s,r)}});function ga(r,e){return!r.issues.length&&r.value===void 0&&r.issues.push({code:"invalid_type",expected:"nonoptional",input:r.value,inst:e}),r}const wm=P("$ZodCatch",(r,e)=>{oe.init(r,e),r._zod.optin="optional",J(r._zod,"optout",()=>e.innerType._zod.optout),J(r._zod,"values",()=>e.innerType._zod.values),r._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(i=>(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(o=>ft(o,n,dt()))},input:t.value}),t.issues=[],t.fallback=!0),t)):(t.value=s.value,s.issues.length&&(t.value=e.catchValue({...t,error:{issues:s.issues.map(i=>ft(i,n,dt()))},input:t.value}),t.issues=[],t.fallback=!0),t)}}),Pm=P("$ZodPipe",(r,e)=>{oe.init(r,e),J(r._zod,"values",()=>e.in._zod.values),J(r._zod,"optin",()=>e.in._zod.optin),J(r._zod,"optout",()=>e.out._zod.optout),J(r._zod,"propValues",()=>e.in._zod.propValues),r._zod.parse=(t,n)=>{if(n.direction==="backward"){const i=e.out._zod.run(t,n);return i instanceof Promise?i.then(o=>an(o,e.in,n)):an(i,e.in,n)}const s=e.in._zod.run(t,n);return s instanceof Promise?s.then(i=>an(i,e.out,n)):an(s,e.out,n)}});function an(r,e,t){return r.issues.length?(r.aborted=!0,r):e._zod.run({value:r.value,issues:r.issues,fallback:r.fallback},t)}const Em=P("$ZodReadonly",(r,e)=>{oe.init(r,e),J(r._zod,"propValues",()=>e.innerType._zod.propValues),J(r._zod,"values",()=>e.innerType._zod.values),J(r._zod,"optin",()=>{var t,n;return(n=(t=e.innerType)==null?void 0:t._zod)==null?void 0:n.optin}),J(r._zod,"optout",()=>{var t,n;return(n=(t=e.innerType)==null?void 0:t._zod)==null?void 0:n.optout}),r._zod.parse=(t,n)=>{if(n.direction==="backward")return e.innerType._zod.run(t,n);const s=e.innerType._zod.run(t,n);return s instanceof Promise?s.then(_a):_a(s)}});function _a(r){return r.value=Object.freeze(r.value),r}const Cm=P("$ZodLazy",(r,e)=>{oe.init(r,e),J(r._zod,"innerType",()=>{const t=e;return t._cachedInner||(t._cachedInner=e.getter()),t._cachedInner}),J(r._zod,"pattern",()=>{var t,n;return(n=(t=r._zod.innerType)==null?void 0:t._zod)==null?void 0:n.pattern}),J(r._zod,"propValues",()=>{var t,n;return(n=(t=r._zod.innerType)==null?void 0:t._zod)==null?void 0:n.propValues}),J(r._zod,"optin",()=>{var t,n;return((n=(t=r._zod.innerType)==null?void 0:t._zod)==null?void 0:n.optin)??void 0}),J(r._zod,"optout",()=>{var t,n;return((n=(t=r._zod.innerType)==null?void 0:t._zod)==null?void 0:n.optout)??void 0}),r._zod.parse=(t,n)=>r._zod.innerType._zod.run(t,n)}),Mm=P("$ZodCustom",(r,e)=>{Be.init(r,e),oe.init(r,e),r._zod.parse=(t,n)=>t,r._zod.check=t=>{const n=t.value,s=e.fn(n);if(s instanceof Promise)return s.then(i=>ya(i,t,n,r));ya(s,t,n,r)}});function ya(r,e,t,n){if(!r){const s={code:"custom",input:t,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(vr(s))}}var ba;class Am{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const 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){const 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){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function km(){return new Am}(ba=globalThis).__zod_globalRegistry??(ba.__zod_globalRegistry=km());const Tr=globalThis.__zod_globalRegistry;function Rm(r,e){return new r({type:"string",...I(e)})}function Im(r,e){return new r({type:"string",format:"email",check:"string_format",abort:!1,...I(e)})}function xa(r,e){return new r({type:"string",format:"guid",check:"string_format",abort:!1,...I(e)})}function Bm(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,...I(e)})}function Fm(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(e)})}function Gm(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(e)})}function Om(r,e){return new r({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(e)})}function Dm(r,e){return new r({type:"string",format:"url",check:"string_format",abort:!1,...I(e)})}function Um(r,e){return new r({type:"string",format:"emoji",check:"string_format",abort:!1,...I(e)})}function Lm(r,e){return new r({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(e)})}function zm(r,e){return new r({type:"string",format:"cuid",check:"string_format",abort:!1,...I(e)})}function Nm(r,e){return new r({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(e)})}function $m(r,e){return new r({type:"string",format:"ulid",check:"string_format",abort:!1,...I(e)})}function Vm(r,e){return new r({type:"string",format:"xid",check:"string_format",abort:!1,...I(e)})}function Hm(r,e){return new r({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(e)})}function jm(r,e){return new r({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(e)})}function Wm(r,e){return new r({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(e)})}function Xm(r,e){return new r({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(e)})}function Ym(r,e){return new r({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(e)})}function Zm(r,e){return new r({type:"string",format:"base64",check:"string_format",abort:!1,...I(e)})}function Km(r,e){return new r({type:"string",format:"base64url",check:"string_format",abort:!1,...I(e)})}function qm(r,e){return new r({type:"string",format:"e164",check:"string_format",abort:!1,...I(e)})}function Jm(r,e){return new r({type:"string",format:"jwt",check:"string_format",abort:!1,...I(e)})}function Qm(r,e){return new r({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(e)})}function eg(r,e){return new r({type:"string",format:"date",check:"string_format",...I(e)})}function tg(r,e){return new r({type:"string",format:"time",check:"string_format",precision:null,...I(e)})}function rg(r,e){return new r({type:"string",format:"duration",check:"string_format",...I(e)})}function ng(r,e){return new r({type:"number",checks:[],...I(e)})}function sg(r,e){return new r({type:"number",check:"number_format",abort:!1,format:"safeint",...I(e)})}function ig(r,e){return new r({type:"boolean",...I(e)})}function og(r){return new r({type:"unknown"})}function ag(r,e){return new r({type:"never",...I(e)})}function va(r,e){return new ea({check:"less_than",...I(e),value:r,inclusive:!1})}function ps(r,e){return new ea({check:"less_than",...I(e),value:r,inclusive:!0})}function Ta(r,e){return new ta({check:"greater_than",...I(e),value:r,inclusive:!1})}function ms(r,e){return new ta({check:"greater_than",...I(e),value:r,inclusive:!0})}function Sa(r,e){return new xp({check:"multiple_of",...I(e),value:r})}function wa(r,e){return new Tp({check:"max_length",...I(e),maximum:r})}function cn(r,e){return new Sp({check:"min_length",...I(e),minimum:r})}function Pa(r,e){return new wp({check:"length_equals",...I(e),length:r})}function cg(r,e){return new Pp({check:"string_format",format:"regex",...I(e),pattern:r})}function lg(r){return new Ep({check:"string_format",format:"lowercase",...I(r)})}function ug(r){return new Cp({check:"string_format",format:"uppercase",...I(r)})}function hg(r,e){return new Mp({check:"string_format",format:"includes",...I(e),includes:r})}function dg(r,e){return new Ap({check:"string_format",format:"starts_with",...I(e),prefix:r})}function fg(r,e){return new kp({check:"string_format",format:"ends_with",...I(e),suffix:r})}function jt(r){return new Rp({check:"overwrite",tx:r})}function pg(r){return jt(e=>e.normalize(r))}function mg(){return jt(r=>r.trim())}function gg(){return jt(r=>r.toLowerCase())}function _g(){return jt(r=>r.toUpperCase())}function yg(){return jt(r=>Sf(r))}function bg(r,e,t){return new r({type:"array",element:e,...I(t)})}function xg(r,e,t){return new r({type:"custom",check:"custom",fn:e,...I(t)})}function vg(r,e){const t=Tg(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(vr(s,n.value,t._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(vr(i))}},r(n.value,n)),e);return t}function Tg(r,e){const t=new Be({check:"custom",...I(e)});return t._zod.check=r,t}function Ea(r){let e=(r==null?void 0:r.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:r.processors??{},metadataRegistry:(r==null?void 0:r.metadata)??Tr,target:e,unrepresentable:(r==null?void 0:r.unrepresentable)??"throw",override:(r==null?void 0:r.override)??(()=>{}),io:(r==null?void 0:r.io)??"output",counter:0,seen:new Map,cycles:(r==null?void 0:r.cycles)??"ref",reused:(r==null?void 0:r.reused)??"inline",external:(r==null?void 0:r.external)??void 0}}function pe(r,e,t={path:[],schemaPath:[]}){var u,h;var n;const s=r._zod.def,i=e.seen.get(r);if(i)return i.count++,t.schemaPath.includes(r)&&(i.cycle=t.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(r,o);const a=(h=(u=r._zod).toJSONSchema)==null?void 0:h.call(u);if(a)o.schema=a;else{const d={...t,schemaPath:[...t.schemaPath,r],path:t.path};if(r._zod.processJSONSchema)r._zod.processJSONSchema(e,o.schema,d);else{const p=o.schema,m=e.processors[s.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);m(r,e,p,d)}const f=r._zod.parent;f&&(o.ref||(o.ref=f),pe(f,e,d),e.seen.get(f).isParent=!0)}const c=e.metadataRegistry.get(r);return c&&Object.assign(o.schema,c),e.io==="input"&&Ae(r)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&"_prefault"in o.schema&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(r).schema}function Ca(r,e){var o,a,c,l;const t=r.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const u of r.seen.entries()){const h=(o=r.metadataRegistry.get(u[0]))==null?void 0:o.id;if(h){const d=n.get(h);if(d&&d!==u[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(h,u[0])}}const s=u=>{var m;const h=r.target==="draft-2020-12"?"$defs":"definitions";if(r.external){const g=(m=r.external.registry.get(u[0]))==null?void 0:m.id,_=r.external.uri??(b=>b);if(g)return{ref:_(g)};const y=u[1].defId??u[1].schema.id??`schema${r.counter++}`;return u[1].defId=y,{defId:y,ref:`${_("__shared")}#/${h}/${y}`}}if(u[1]===t)return{ref:"#"};const f=`#/${h}/`,p=u[1].schema.id??`__schema${r.counter++}`;return{defId:p,ref:f+p}},i=u=>{if(u[1].schema.$ref)return;const h=u[1],{ref:d,defId:f}=s(u);h.def={...h.schema},f&&(h.defId=f);const p=h.schema;for(const m in p)delete p[m];p.$ref=d};if(r.cycles==="throw")for(const u of r.seen.entries()){const h=u[1];if(h.cycle)throw new Error(`Cycle detected: #/${(a=h.cycle)==null?void 0:a.join("/")}/<root>
63
+
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of r.seen.entries()){const h=u[1];if(e===u[0]){i(u);continue}if(r.external){const f=(c=r.external.registry.get(u[0]))==null?void 0:c.id;if(e!==u[0]&&f){i(u);continue}}if((l=r.metadataRegistry.get(u[0]))==null?void 0:l.id){i(u);continue}if(h.cycle){i(u);continue}if(h.count>1&&r.reused==="ref"){i(u);continue}}}function Ma(r,e){var a,c,l,u;const t=r.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=h=>{const d=r.seen.get(h);if(d.ref===null)return;const f=d.def??d.schema,p={...f},m=d.ref;if(d.ref=null,m){n(m);const _=r.seen.get(m),y=_.schema;if(y.$ref&&(r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(y)):Object.assign(f,y),Object.assign(f,p),h._zod.parent===m)for(const v in f)v==="$ref"||v==="allOf"||v in p||delete f[v];if(y.$ref&&_.def)for(const v in f)v==="$ref"||v==="allOf"||v in _.def&&JSON.stringify(f[v])===JSON.stringify(_.def[v])&&delete f[v]}const g=h._zod.parent;if(g&&g!==m){n(g);const _=r.seen.get(g);if(_!=null&&_.schema.$ref&&(f.$ref=_.schema.$ref,_.def))for(const y in f)y==="$ref"||y==="allOf"||y in _.def&&JSON.stringify(f[y])===JSON.stringify(_.def[y])&&delete f[y]}r.override({zodSchema:h,jsonSchema:f,path:d.path??[]})};for(const h of[...r.seen.entries()].reverse())n(h[0]);const s={};if(r.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":r.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":r.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":r.target,(a=r.external)!=null&&a.uri){const h=(c=r.external.registry.get(e))==null?void 0:c.id;if(!h)throw new Error("Schema is missing an `id` property");s.$id=r.external.uri(h)}Object.assign(s,t.def??t.schema);const i=(l=r.metadataRegistry.get(e))==null?void 0:l.id;i!==void 0&&s.id===i&&delete s.id;const o=((u=r.external)==null?void 0:u.defs)??{};for(const h of r.seen.entries()){const d=h[1];d.def&&d.defId&&(d.def.id===d.defId&&delete d.def.id,o[d.defId]=d.def)}r.external||Object.keys(o).length>0&&(r.target==="draft-2020-12"?s.$defs=o:s.definitions=o);try{const h=JSON.parse(JSON.stringify(s));return Object.defineProperty(h,"~standard",{value:{...e["~standard"],jsonSchema:{input:ln(e,"input",r.processors),output:ln(e,"output",r.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function Ae(r,e){const t=e??{seen:new Set};if(t.seen.has(r))return!1;t.seen.add(r);const n=r._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ae(n.element,t);if(n.type==="set")return Ae(n.valueType,t);if(n.type==="lazy")return Ae(n.getter(),t);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ae(n.innerType,t);if(n.type==="intersection")return Ae(n.left,t)||Ae(n.right,t);if(n.type==="record"||n.type==="map")return Ae(n.keyType,t)||Ae(n.valueType,t);if(n.type==="pipe")return r._zod.traits.has("$ZodCodec")?!0:Ae(n.in,t)||Ae(n.out,t);if(n.type==="object"){for(const s in n.shape)if(Ae(n.shape[s],t))return!0;return!1}if(n.type==="union"){for(const s of n.options)if(Ae(s,t))return!0;return!1}if(n.type==="tuple"){for(const s of n.items)if(Ae(s,t))return!0;return!!(n.rest&&Ae(n.rest,t))}return!1}const Sg=(r,e={})=>t=>{const n=Ea({...t,processors:e});return pe(r,n),Ca(n,r),Ma(n,r)},ln=(r,e,t={})=>n=>{const{libraryOptions:s,target:i}=n??{},o=Ea({...s??{},target:i,io:e,processors:t});return pe(r,o),Ca(o,r),Ma(o,r)},wg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Pg=(r,e,t,n)=>{const s=t;s.type="string";const{minimum:i,maximum:o,format:a,patterns:c,contentEncoding:l}=r._zod.bag;if(typeof i=="number"&&(s.minLength=i),typeof o=="number"&&(s.maxLength=o),a&&(s.format=wg[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),l&&(s.contentEncoding=l),c&&c.size>0){const u=[...c];u.length===1?s.pattern=u[0].source:u.length>1&&(s.allOf=[...u.map(h=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Eg=(r,e,t,n)=>{const s=t,{minimum:i,maximum:o,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=r._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number";const h=typeof u=="number"&&u>=(i??Number.NEGATIVE_INFINITY),d=typeof l=="number"&&l<=(o??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";h?f?(s.minimum=u,s.exclusiveMinimum=!0):s.exclusiveMinimum=u:typeof i=="number"&&(s.minimum=i),d?f?(s.maximum=l,s.exclusiveMaximum=!0):s.exclusiveMaximum=l:typeof o=="number"&&(s.maximum=o),typeof c=="number"&&(s.multipleOf=c)},Cg=(r,e,t,n)=>{t.type="boolean"},Mg=(r,e,t,n)=>{t.not={}},Ag=(r,e,t,n)=>{},kg=(r,e,t,n)=>{const s=r._zod.def,i=zo(s.entries);i.every(o=>typeof o=="number")&&(t.type="number"),i.every(o=>typeof o=="string")&&(t.type="string"),t.enum=i},Rg=(r,e,t,n)=>{const s=r._zod.def,i=[];for(const o of s.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){const o=i[0];t.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[o]:t.const=o}else i.every(o=>typeof o=="number")&&(t.type="number"),i.every(o=>typeof o=="string")&&(t.type="string"),i.every(o=>typeof o=="boolean")&&(t.type="boolean"),i.every(o=>o===null)&&(t.type="null"),t.enum=i},Ig=(r,e,t,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Bg=(r,e,t,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Fg=(r,e,t,n)=>{const s=t,i=r._zod.def,{minimum:o,maximum:a}=r._zod.bag;typeof o=="number"&&(s.minItems=o),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=pe(i.element,e,{...n,path:[...n.path,"items"]})},Gg=(r,e,t,n)=>{var l;const s=t,i=r._zod.def;s.type="object",s.properties={};const o=i.shape;for(const u in o)s.properties[u]=pe(o[u],e,{...n,path:[...n.path,"properties",u]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(u=>{const h=i.shape[u]._zod;return e.io==="input"?h.optin===void 0:h.optout===void 0}));c.size>0&&(s.required=Array.from(c)),((l=i.catchall)==null?void 0:l._zod.def.type)==="never"?s.additionalProperties=!1:i.catchall?i.catchall&&(s.additionalProperties=pe(i.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},Og=(r,e,t,n)=>{const s=r._zod.def,i=s.inclusive===!1,o=s.options.map((a,c)=>pe(a,e,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?t.oneOf=o:t.anyOf=o},Dg=(r,e,t,n)=>{const s=r._zod.def,i=pe(s.left,e,{...n,path:[...n.path,"allOf",0]}),o=pe(s.right,e,{...n,path:[...n.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(o)?o.allOf:[o]];t.allOf=c},Ug=(r,e,t,n)=>{const s=t,i=r._zod.def;s.type="array";const o=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((d,f)=>pe(d,e,{...n,path:[...n.path,o,f]})),l=i.rest?pe(i.rest,e,{...n,path:[...n.path,a,...e.target==="openapi-3.0"?[i.items.length]:[]]}):null;e.target==="draft-2020-12"?(s.prefixItems=c,l&&(s.items=l)):e.target==="openapi-3.0"?(s.items={anyOf:c},l&&s.items.anyOf.push(l),s.minItems=c.length,l||(s.maxItems=c.length)):(s.items=c,l&&(s.additionalItems=l));const{minimum:u,maximum:h}=r._zod.bag;typeof u=="number"&&(s.minItems=u),typeof h=="number"&&(s.maxItems=h)},Lg=(r,e,t,n)=>{const s=t,i=r._zod.def;s.type="object";const o=i.keyType,a=o._zod.bag,c=a==null?void 0:a.patterns;if(i.mode==="loose"&&c&&c.size>0){const u=pe(i.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(const h of c)s.patternProperties[h.source]=u}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(s.propertyNames=pe(i.keyType,e,{...n,path:[...n.path,"propertyNames"]})),s.additionalProperties=pe(i.valueType,e,{...n,path:[...n.path,"additionalProperties"]});const l=o._zod.values;if(l){const u=[...l].filter(h=>typeof h=="string"||typeof h=="number");u.length>0&&(s.required=u)}},zg=(r,e,t,n)=>{const s=r._zod.def,i=pe(s.innerType,e,n),o=e.seen.get(r);e.target==="openapi-3.0"?(o.ref=s.innerType,t.nullable=!0):t.anyOf=[i,{type:"null"}]},Ng=(r,e,t,n)=>{const s=r._zod.def;pe(s.innerType,e,n);const i=e.seen.get(r);i.ref=s.innerType},$g=(r,e,t,n)=>{const s=r._zod.def;pe(s.innerType,e,n);const i=e.seen.get(r);i.ref=s.innerType,t.default=JSON.parse(JSON.stringify(s.defaultValue))},Vg=(r,e,t,n)=>{const s=r._zod.def;pe(s.innerType,e,n);const i=e.seen.get(r);i.ref=s.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},Hg=(r,e,t,n)=>{const s=r._zod.def;pe(s.innerType,e,n);const i=e.seen.get(r);i.ref=s.innerType;let o;try{o=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=o},jg=(r,e,t,n)=>{const s=r._zod.def,i=s.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?i?s.out:s.in:s.out;pe(o,e,n);const a=e.seen.get(r);a.ref=o},Wg=(r,e,t,n)=>{const s=r._zod.def;pe(s.innerType,e,n);const i=e.seen.get(r);i.ref=s.innerType,t.readOnly=!0},Aa=(r,e,t,n)=>{const s=r._zod.def;pe(s.innerType,e,n);const i=e.seen.get(r);i.ref=s.innerType},Xg=(r,e,t,n)=>{const s=r._zod.innerType;pe(s,e,n);const i=e.seen.get(r);i.ref=s},Yg=P("ZodISODateTime",(r,e)=>{jp.init(r,e),me.init(r,e)});function Zg(r){return Qm(Yg,r)}const Kg=P("ZodISODate",(r,e)=>{Wp.init(r,e),me.init(r,e)});function qg(r){return eg(Kg,r)}const Jg=P("ZodISOTime",(r,e)=>{Xp.init(r,e),me.init(r,e)});function Qg(r){return tg(Jg,r)}const e_=P("ZodISODuration",(r,e)=>{Yp.init(r,e),me.init(r,e)});function t_(r){return rg(e_,r)}const He=P("ZodError",(r,e)=>{Wo.init(r,e),r.name="ZodError",Object.defineProperties(r,{format:{value:t=>Df(r,t)},flatten:{value:t=>Of(r,t)},addIssue:{value:t=>{r.issues.push(t),r.message=JSON.stringify(r.issues,os,2)}},addIssues:{value:t=>{r.issues.push(...t),r.message=JSON.stringify(r.issues,os,2)}},isEmpty:{get(){return r.issues.length===0}}})},{Parent:Error}),r_=us(He),n_=hs(He),s_=rn(He),i_=nn(He),o_=zf(He),a_=Nf(He),c_=$f(He),l_=Vf(He),u_=Hf(He),h_=jf(He),d_=Wf(He),f_=Xf(He),ka=new WeakMap;function Sr(r,e,t){const n=Object.getPrototypeOf(r);let s=ka.get(n);if(s||(s=new Set,ka.set(n,s)),!s.has(e)){s.add(e);for(const i in t){const o=t[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){const a=o.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const ue=P("ZodType",(r,e)=>(oe.init(r,e),Object.assign(r["~standard"],{jsonSchema:{input:ln(r,"input"),output:ln(r,"output")}}),r.toJSONSchema=Sg(r,{}),r.def=e,r.type=e.type,Object.defineProperty(r,"_def",{value:e}),r.parse=(t,n)=>r_(r,t,n,{callee:r.parse}),r.safeParse=(t,n)=>s_(r,t,n),r.parseAsync=async(t,n)=>n_(r,t,n,{callee:r.parseAsync}),r.safeParseAsync=async(t,n)=>i_(r,t,n),r.spa=r.safeParseAsync,r.encode=(t,n)=>o_(r,t,n),r.decode=(t,n)=>a_(r,t,n),r.encodeAsync=async(t,n)=>c_(r,t,n),r.decodeAsync=async(t,n)=>l_(r,t,n),r.safeEncode=(t,n)=>u_(r,t,n),r.safeDecode=(t,n)=>h_(r,t,n),r.safeEncodeAsync=async(t,n)=>d_(r,t,n),r.safeDecodeAsync=async(t,n)=>f_(r,t,n),Sr(r,"ZodType",{check(...t){const n=this.def;return this.clone(St(n,{checks:[...n.checks??[],...t.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,n){return wt(this,t,n)},brand(){return this},register(t,n){return t.add(this,n),this},refine(t,n){return this.check(ay(t,n))},superRefine(t,n){return this.check(cy(t,n))},overwrite(t){return this.check(jt(t))},optional(){return La(this)},exactOptional(){return W_(this)},nullable(){return za(this)},nullish(){return La(za(this))},nonoptional(t){return J_(this,t)},array(){return L(this)},or(t){return hn([this,t])},and(t){return z_(this,t)},transform(t){return $a(this,H_(t))},default(t){return Z_(this,t)},prefault(t){return q_(this,t)},catch(t){return ey(this,t)},pipe(t){return $a(this,t)},readonly(){return ny(this)},describe(t){const n=this.clone();return Tr.add(n,{description:t}),n},meta(...t){if(t.length===0)return Tr.get(this);const n=this.clone();return Tr.add(n,t[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t){return t(this)}}),Object.defineProperty(r,"description",{get(){var t;return(t=Tr.get(r))==null?void 0:t.description},configurable:!0}),r)),Ra=P("_ZodString",(r,e)=>{ds.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(n,s,i)=>Pg(r,n,s);const t=r._zod.bag;r.format=t.format??null,r.minLength=t.minimum??null,r.maxLength=t.maximum??null,Sr(r,"_ZodString",{regex(...n){return this.check(cg(...n))},includes(...n){return this.check(hg(...n))},startsWith(...n){return this.check(dg(...n))},endsWith(...n){return this.check(fg(...n))},min(...n){return this.check(cn(...n))},max(...n){return this.check(wa(...n))},length(...n){return this.check(Pa(...n))},nonempty(...n){return this.check(cn(1,...n))},lowercase(n){return this.check(lg(n))},uppercase(n){return this.check(ug(n))},trim(){return this.check(mg())},normalize(...n){return this.check(pg(...n))},toLowerCase(){return this.check(gg())},toUpperCase(){return this.check(_g())},slugify(){return this.check(yg())}})}),p_=P("ZodString",(r,e)=>{ds.init(r,e),Ra.init(r,e),r.email=t=>r.check(Im(m_,t)),r.url=t=>r.check(Dm(g_,t)),r.jwt=t=>r.check(Jm(R_,t)),r.emoji=t=>r.check(Um(__,t)),r.guid=t=>r.check(xa(Ia,t)),r.uuid=t=>r.check(Bm(un,t)),r.uuidv4=t=>r.check(Fm(un,t)),r.uuidv6=t=>r.check(Gm(un,t)),r.uuidv7=t=>r.check(Om(un,t)),r.nanoid=t=>r.check(Lm(y_,t)),r.guid=t=>r.check(xa(Ia,t)),r.cuid=t=>r.check(zm(b_,t)),r.cuid2=t=>r.check(Nm(x_,t)),r.ulid=t=>r.check($m(v_,t)),r.base64=t=>r.check(Zm(M_,t)),r.base64url=t=>r.check(Km(A_,t)),r.xid=t=>r.check(Vm(T_,t)),r.ksuid=t=>r.check(Hm(S_,t)),r.ipv4=t=>r.check(jm(w_,t)),r.ipv6=t=>r.check(Wm(P_,t)),r.cidrv4=t=>r.check(Xm(E_,t)),r.cidrv6=t=>r.check(Ym(C_,t)),r.e164=t=>r.check(qm(k_,t)),r.datetime=t=>r.check(Zg(t)),r.date=t=>r.check(qg(t)),r.time=t=>r.check(Qg(t)),r.duration=t=>r.check(t_(t))});function w(r){return Rm(p_,r)}const me=P("ZodStringFormat",(r,e)=>{he.init(r,e),Ra.init(r,e)}),m_=P("ZodEmail",(r,e)=>{Op.init(r,e),me.init(r,e)}),Ia=P("ZodGUID",(r,e)=>{Fp.init(r,e),me.init(r,e)}),un=P("ZodUUID",(r,e)=>{Gp.init(r,e),me.init(r,e)}),g_=P("ZodURL",(r,e)=>{Dp.init(r,e),me.init(r,e)}),__=P("ZodEmoji",(r,e)=>{Up.init(r,e),me.init(r,e)}),y_=P("ZodNanoID",(r,e)=>{Lp.init(r,e),me.init(r,e)}),b_=P("ZodCUID",(r,e)=>{zp.init(r,e),me.init(r,e)}),x_=P("ZodCUID2",(r,e)=>{Np.init(r,e),me.init(r,e)}),v_=P("ZodULID",(r,e)=>{$p.init(r,e),me.init(r,e)}),T_=P("ZodXID",(r,e)=>{Vp.init(r,e),me.init(r,e)}),S_=P("ZodKSUID",(r,e)=>{Hp.init(r,e),me.init(r,e)}),w_=P("ZodIPv4",(r,e)=>{Zp.init(r,e),me.init(r,e)}),P_=P("ZodIPv6",(r,e)=>{Kp.init(r,e),me.init(r,e)}),E_=P("ZodCIDRv4",(r,e)=>{qp.init(r,e),me.init(r,e)}),C_=P("ZodCIDRv6",(r,e)=>{Jp.init(r,e),me.init(r,e)}),M_=P("ZodBase64",(r,e)=>{Qp.init(r,e),me.init(r,e)}),A_=P("ZodBase64URL",(r,e)=>{tm.init(r,e),me.init(r,e)}),k_=P("ZodE164",(r,e)=>{rm.init(r,e),me.init(r,e)}),R_=P("ZodJWT",(r,e)=>{sm.init(r,e),me.init(r,e)}),Ba=P("ZodNumber",(r,e)=>{na.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(n,s,i)=>Eg(r,n,s),Sr(r,"ZodNumber",{gt(n,s){return this.check(Ta(n,s))},gte(n,s){return this.check(ms(n,s))},min(n,s){return this.check(ms(n,s))},lt(n,s){return this.check(va(n,s))},lte(n,s){return this.check(ps(n,s))},max(n,s){return this.check(ps(n,s))},int(n){return this.check(Fa(n))},safe(n){return this.check(Fa(n))},positive(n){return this.check(Ta(0,n))},nonnegative(n){return this.check(ms(0,n))},negative(n){return this.check(va(0,n))},nonpositive(n){return this.check(ps(0,n))},multipleOf(n,s){return this.check(Sa(n,s))},step(n,s){return this.check(Sa(n,s))},finite(){return this}});const t=r._zod.bag;r.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,r.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,r.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),r.isFinite=!0,r.format=t.format??null});function T(r){return ng(Ba,r)}const I_=P("ZodNumberFormat",(r,e)=>{im.init(r,e),Ba.init(r,e)});function Fa(r){return sg(I_,r)}const B_=P("ZodBoolean",(r,e)=>{om.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Cg(r,t,n)});function De(r){return ig(B_,r)}const F_=P("ZodUnknown",(r,e)=>{am.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Ag()});function Ga(){return og(F_)}const G_=P("ZodNever",(r,e)=>{cm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Mg(r,t,n)});function gs(r){return ag(G_,r)}const O_=P("ZodArray",(r,e)=>{lm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Fg(r,t,n,s),r.element=e.element,Sr(r,"ZodArray",{min(t,n){return this.check(cn(t,n))},nonempty(t){return this.check(cn(1,t))},max(t,n){return this.check(wa(t,n))},length(t,n){return this.check(Pa(t,n))},unwrap(){return this.element}})});function L(r,e){return bg(O_,r,e)}const D_=P("ZodObject",(r,e)=>{hm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Gg(r,t,n,s),J(r,"shape",()=>e.shape),Sr(r,"ZodObject",{keyof(){return ae(Object.keys(this._zod.def.shape))},catchall(t){return this.clone({...this._zod.def,catchall:t})},passthrough(){return this.clone({...this._zod.def,catchall:Ga()})},loose(){return this.clone({...this._zod.def,catchall:Ga()})},strict(){return this.clone({...this._zod.def,catchall:gs()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(t){return kf(this,t)},safeExtend(t){return Rf(this,t)},merge(t){return If(this,t)},pick(t){return Mf(this,t)},omit(t){return Af(this,t)},partial(...t){return Bf(Ua,this,t[0])},required(...t){return Ff(Na,this,t[0])}})});function R(r,e){const t={type:"object",shape:r??{},...I(e)};return new D_(t)}const Oa=P("ZodUnion",(r,e)=>{ca.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Og(r,t,n,s),r.options=e.options});function hn(r,e){return new Oa({type:"union",options:r,...I(e)})}const U_=P("ZodDiscriminatedUnion",(r,e)=>{Oa.init(r,e),dm.init(r,e)});function _s(r,e,t){return new U_({type:"union",options:e,discriminator:r,...I(t)})}const L_=P("ZodIntersection",(r,e)=>{fm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Dg(r,t,n,s)});function z_(r,e){return new L_({type:"intersection",left:r,right:e})}const N_=P("ZodTuple",(r,e)=>{pm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Ug(r,t,n,s),r.rest=t=>r.clone({...r._zod.def,rest:t})});function dn(r,e,t){const n=e instanceof oe,s=n?t:e,i=n?e:null;return new N_({type:"tuple",items:r,rest:i,...I(s)})}const Da=P("ZodRecord",(r,e)=>{mm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Lg(r,t,n,s),r.keyType=e.keyType,r.valueType=e.valueType});function ys(r,e,t){return!e||!e._zod?new Da({type:"record",keyType:w(),valueType:r,...I(e)}):new Da({type:"record",keyType:r,valueType:e,...I(t)})}const bs=P("ZodEnum",(r,e)=>{gm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(n,s,i)=>kg(r,n,s),r.enum=e.entries,r.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));r.extract=(n,s)=>{const i={};for(const o of n)if(t.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new bs({...e,checks:[],...I(s),entries:i})},r.exclude=(n,s)=>{const i={...e.entries};for(const o of n)if(t.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new bs({...e,checks:[],...I(s),entries:i})}});function ae(r,e){const t=Array.isArray(r)?Object.fromEntries(r.map(n=>[n,n])):r;return new bs({type:"enum",entries:t,...I(e)})}const $_=P("ZodLiteral",(r,e)=>{_m.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Rg(r,t,n),r.values=new Set(e.values),Object.defineProperty(r,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Z(r,e){return new $_({type:"literal",values:Array.isArray(r)?r:[r],...I(e)})}const V_=P("ZodTransform",(r,e)=>{ym.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Bg(r,t),r._zod.parse=(t,n)=>{if(n.direction==="backward")throw new Lo(r.constructor.name);t.addIssue=i=>{if(typeof i=="string")t.issues.push(vr(i,t.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=t.value),o.inst??(o.inst=r),t.issues.push(vr(o))}};const s=e.transform(t.value,t);return s instanceof Promise?s.then(i=>(t.value=i,t.fallback=!0,t)):(t.value=s,t.fallback=!0,t)}});function H_(r){return new V_({type:"transform",transform:r})}const Ua=P("ZodOptional",(r,e)=>{pa.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Aa(r,t,n,s),r.unwrap=()=>r._zod.def.innerType});function La(r){return new Ua({type:"optional",innerType:r})}const j_=P("ZodExactOptional",(r,e)=>{bm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Aa(r,t,n,s),r.unwrap=()=>r._zod.def.innerType});function W_(r){return new j_({type:"optional",innerType:r})}const X_=P("ZodNullable",(r,e)=>{xm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>zg(r,t,n,s),r.unwrap=()=>r._zod.def.innerType});function za(r){return new X_({type:"nullable",innerType:r})}const Y_=P("ZodDefault",(r,e)=>{vm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>$g(r,t,n,s),r.unwrap=()=>r._zod.def.innerType,r.removeDefault=r.unwrap});function Z_(r,e){return new Y_({type:"default",innerType:r,get defaultValue(){return typeof e=="function"?e():Ho(e)}})}const K_=P("ZodPrefault",(r,e)=>{Tm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Vg(r,t,n,s),r.unwrap=()=>r._zod.def.innerType});function q_(r,e){return new K_({type:"prefault",innerType:r,get defaultValue(){return typeof e=="function"?e():Ho(e)}})}const Na=P("ZodNonOptional",(r,e)=>{Sm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Ng(r,t,n,s),r.unwrap=()=>r._zod.def.innerType});function J_(r,e){return new Na({type:"nonoptional",innerType:r,...I(e)})}const Q_=P("ZodCatch",(r,e)=>{wm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Hg(r,t,n,s),r.unwrap=()=>r._zod.def.innerType,r.removeCatch=r.unwrap});function ey(r,e){return new Q_({type:"catch",innerType:r,catchValue:typeof e=="function"?e:()=>e})}const ty=P("ZodPipe",(r,e)=>{Pm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>jg(r,t,n,s),r.in=e.in,r.out=e.out});function $a(r,e){return new ty({type:"pipe",in:r,out:e})}const ry=P("ZodReadonly",(r,e)=>{Em.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Wg(r,t,n,s),r.unwrap=()=>r._zod.def.innerType});function ny(r){return new ry({type:"readonly",innerType:r})}const sy=P("ZodLazy",(r,e)=>{Cm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Xg(r,t,n,s),r.unwrap=()=>r._zod.def.getter()});function iy(r){return new sy({type:"lazy",getter:r})}const oy=P("ZodCustom",(r,e)=>{Mm.init(r,e),ue.init(r,e),r._zod.processJSONSchema=(t,n,s)=>Ig(r,t)});function ay(r,e={}){return xg(oy,r,e)}function cy(r,e){return vg(r,e)}const Va=new Set(["__proto__","constructor","prototype"]),ly=128;function xs(r,e=0){if(e>ly)return!0;if(Array.isArray(r)){for(const t of r)if(xs(t,e+1))return!0;return!1}if(r&&typeof r=="object"){const t=r;for(const n of Object.keys(t))if(Va.has(n)||xs(t[n],e+1))return!0}return!1}const vs=w().refine(r=>!Va.has(r),{message:"Object contains a key that may cause prototype pollution"}),Ha=R({r:T(),g:T(),b:T()}),uy=ae(["normal","add","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion"]);ae(["viviMesh","group","bone","artPath"]);const hy=R({vertices:L(T()),uvs:L(T()),indices:L(T()),divisionsX:T(),divisionsY:T()}),dy=dn([T(),T(),T(),T(),T(),T()]),ja=ae(["linear","step","bezier","ellipse","sns"]),fy=ae(["angle","scaleX","scaleY"]),py=ae(["x","y","angle","scaleX","scaleY"]),my=ae(["targetX","targetY","poleTargetX","poleTargetY","influence"]),gy=ae(["sil","aa","ih","ou","eh","oh","ff","ss","pp","nn","kk"]),fn=R({frame:T(),value:T(),interpolation:ja,cp1x:T().optional(),cp1y:T().optional(),cp2x:T().optional(),cp2y:T().optional(),ellipseRatio:T().optional(),ellipseDirection:ae(["cw","ccw"]).optional(),snsOscillations:T().optional(),snsDamping:T().optional()}),_y=R({parameterId:w(),keyframes:L(fn)}),yy=R({boneId:w(),property:fy,keyframes:L(fn)}),by=R({startFrame:T(),imageId:w()}),xy=R({targetMeshId:w(),entries:L(by)}),vy=R({id:w(),name:w(),sourcePath:w(),startFrame:T(),sourceDurationSeconds:T().nullable(),gain:T(),muted:De()}),Ty=R({id:w(),name:w(),sourceAudioTrackId:w(),analysisType:Z("rms"),analysisFps:T(),samples:L(T()),targetParameterId:w().nullable(),sourcePathAtBake:w(),sourceDurationSecondsAtBake:T().nullable(),gain:T(),muted:De()}),Sy=R({controllerId:w(),targetXKeyframes:L(fn),targetYKeyframes:L(fn)}),Wa=R({id:w(),name:w(),duration:T(),fps:T(),tracks:L(_y),boneTracks:L(yy).optional(),imageSequenceTracks:L(xy).optional(),audioTracks:L(vy).optional(),lipSyncTracks:L(Ty).optional(),ikControllerTracks:L(Sy).optional()}),wy=R({id:w(),name:w(),clips:L(Wa)}),Py=R({id:w(),sourceSceneId:w(),targetSceneId:w(),mode:ae(["crossfade","additive","override"]),transitionFrames:T(),easing:ja}),Ey=_s("type",[R({type:Z("rectangle"),x:T(),y:T(),width:T(),height:T()}),R({type:Z("circle"),x:T(),y:T(),radius:T()}),R({type:Z("mesh"),meshId:w()})]),Cy=R({id:w(),name:w(),shape:Ey,tag:w().optional(),enabled:De()}),My=ae(["head","face","eyeLeft","eyeRight","eyebrowLeft","eyebrowRight","mouth","nose","hair","hairFront","hairBack","hairSide","body","armLeft","armRight","handLeft","handRight","legLeft","legRight","tail","ear","accessory","unknown"]),Ay=ae(["seeThroughImport","manual","assistant"]),ky=ae(["rigid","localBones","skinned","physics"]),Xa=R({providerId:w(),capabilityId:w(),proposalId:w(),confidence:T().optional(),convertedAt:w().optional()}),Ry=R({min:T(),max:T(),mean:T()}),Iy=dn([T().int(),T().int(),T().int(),T().int()]),By=dn([T().int(),T().int(),T().int().positive(),T().int().positive()]),Fy=dn([T().int(),T().int()]),Ya=R({label:w(),order:T().int(),psdLeafToken:w().optional(),confidence:T(),leftRightSplit:ae(["left","right","center","unknown"]),frontBackSplit:ae(["front","back","middle","unknown"]),bbox:Iy,depthStats:Ry}),Gy=R({sourceFileName:w(),sourcePath:w().optional(),originalWidth:T().int().positive(),originalHeight:T().int().positive(),trimmedBounds:By,finalOrigin:Fy,placementMode:ae(["preserveImageOffset","centerOnCanvas"]),trimTransparentBoundsApplied:De().optional(),autoGenerateMeshApplied:De()}),Oy=R({source:Z("seeThrough"),seeThrough:Ya}),Dy=R({source:Z("manualPng"),manualPng:Gy}),Za=R({x:T(),y:T(),width:T(),height:T()}),Uy=hn([R({kind:Z("maskExtractedLayer"),ownership:Z("userAccepted"),origin:Z("manualMask"),manualSplitLayerId:w(),manualSplitSourceLayerId:w(),manualSplitSourceFingerprint:w(),manualSplitMaskId:w(),maskCoverage:T(),edgeFeatherPx:T(),customLabel:w().optional(),convertedFromProviderProposal:gs().optional()}),R({kind:Z("maskExtractedLayer"),ownership:Z("userAccepted"),origin:Z("providerProposal"),manualSplitLayerId:w(),manualSplitSourceLayerId:w(),manualSplitSourceFingerprint:w(),manualSplitMaskId:w(),maskCoverage:T(),edgeFeatherPx:T(),customLabel:w().optional(),convertedFromProviderProposal:Xa.extend({convertedAt:w()})}),R({kind:Z("generatedUnderpaintLayer"),ownership:Z("userAccepted"),origin:Z("localUnderpaint"),manualSplitLayerId:w(),manualSplitSourceLayerId:w(),manualSplitSourceFingerprint:w(),underpaintBufferId:w(),bounds:Za,sourceMaskId:w().optional(),occludedByMaskId:w().optional(),acceptedAt:w(),providerAudit:gs().optional()}),R({kind:Z("generatedUnderpaintLayer"),ownership:Z("userAccepted"),origin:Z("providerUnderpaint"),manualSplitLayerId:w(),manualSplitSourceLayerId:w(),manualSplitSourceFingerprint:w(),underpaintBufferId:w(),bounds:Za,sourceMaskId:w().optional(),occludedByMaskId:w().optional(),acceptedAt:w(),providerAudit:Xa})]),Ly=Ya.transform(r=>({source:"seeThrough",seeThrough:r})),zy=hn([Oy,Dy,Ly]),pn={id:w(),name:w(),visible:De(),opacity:T(),x:T(),y:T(),width:T(),height:T(),blendMode:uy,expanded:De(),clipMaskIds:L(w()).optional(),drawOrder:T().optional(),multiplyColor:Ha.optional(),screenColor:Ha.optional(),semanticRole:My.optional(),semanticRoleSource:Ay.optional(),riggingHint:ky.optional(),manualSplitOutputMetadata:Uy.optional(),importMetadata:zy.optional(),managedTag:w().optional(),managedSignature:w().optional(),managedSourceFingerprint:w().optional(),manualSplitSourceLayerId:w().optional(),manualSplitSourceFingerprint:w().optional(),manualSplitLayerId:w().optional()},Ny=R({angle:T(),length:T(),scaleX:T(),scaleY:T()}),$y=R({x:T(),y:T(),handleInX:T(),handleInY:T(),handleOutX:T(),handleOutY:T(),width:T(),opacity:T()}),Vy=R({color:T(),baseWidth:T(),lineCap:ae(["butt","round","square"]),lineJoin:ae(["miter","round","bevel"])}),wr=iy(()=>_s("kind",[R({...pn,children:L(wr),kind:Z("viviMesh"),mesh:hy,culling:De().optional()}),R({...pn,children:L(wr),kind:Z("group")}),R({...pn,children:L(wr),kind:Z("bone"),bone:Ny,parentBoneId:w().optional()}),R({...pn,children:L(wr),kind:Z("artPath"),controlPoints:L($y),closed:De(),style:Vy})])),Hy=R({id:w(),name:w(),minValue:T(),maxValue:T(),defaultValue:T(),managedTag:w().optional(),managedSignature:w().optional(),managedSourceFingerprint:w().optional(),pairedParameterId:w().optional(),group:w().optional()}),jy=R({paramValue:T(),targetValue:T()}),Wy=_s("type",[R({type:Z("bone"),boneId:w(),property:py}),R({type:Z("ikController"),controllerId:w(),property:my})]),Xy=R({id:w(),parameterId:w(),target:Wy,managedTag:w().optional(),managedSignature:w().optional(),managedSourceFingerprint:w().optional(),bindingPoints:L(jy)}),Yy=R({boneId:w(),weight:T()}),Zy=R({managedTag:w().optional(),managedSignature:w().optional(),managedSourceFingerprint:w().optional(),manualSplitSourceLayerId:w().optional(),manualSplitSourceFingerprint:w().optional(),manualSplitLayerId:w().optional(),weights:L(L(Yy)),bindPoseInverse:ys(vs,dy)}),Ky=R({id:w(),name:w(),values:ys(vs,T()),color:w().optional(),hotkey:T().optional()}),qy=R({length:T(),mass:T(),damping:T()}),Jy=R({parameterId:w(),weight:T(),type:ae(["x","y","angle"])}),Qy=R({parameterId:w().optional(),boneId:w().optional(),pendulumIndex:T(),weight:T(),type:ae(["angle","boneAngle"])}),eb=R({id:w(),name:w(),enabled:De(),managedTag:w().optional(),managedSignature:w().optional(),managedSourceFingerprint:w().optional(),manualSplitSourceLayerId:w().optional(),manualSplitSourceFingerprint:w().optional(),manualSplitLayerId:w().optional(),pendulums:L(qy),inputs:L(Jy),outputs:L(Qy),gravityDirection:T(),gravityStrength:T(),wind:T()}),tb=R({viseme:gy,target:R({type:Z("parameter"),parameterId:w(),value:T()})}),rb=R({enabled:De(),mode:ae(["rms","viseme"]).optional(),targetParameterId:w().nullable(),source:ae(["microphone","file"]),threshold:T(),smoothing:T(),gain:T(),visemeMappings:L(tb).optional(),visemeSmoothing:T().optional()}),nb=R({parameterId:w(),operator:ae([">","<",">=","<=","==","!="]),threshold:T()}),sb=R({threshold:T(),clipId:w()}),ib=R({parameterId:w(),entries:L(sb)}),ob=R({id:w(),name:w(),clipId:w().optional(),blendTree:ib.optional(),loop:De()}),ab=R({id:w(),fromStateId:w(),toStateId:w(),conditions:L(nb),transitionDuration:T(),priority:T()}),cb=R({id:w(),name:w(),states:L(ob),transitions:L(ab),initialStateId:w(),enabled:De(),blendMode:ae(["override","additive"]).optional(),weight:T().optional()}),lb=R({boneId:w(),minAngle:T(),maxAngle:T()}),ub=R({boneId:w(),parameterId:w(),angleMin:T(),angleMax:T(),paramMin:T(),paramMax:T()}),hb=R({id:w(),name:w(),managedTag:w().optional(),managedSignature:w().optional(),managedSourceFingerprint:w().optional(),manualSplitSourceLayerId:w().optional(),manualSplitSourceFingerprint:w().optional(),manualSplitLayerId:w().optional(),solverType:ae(["twoBone","ccd"]),boneChain:L(lb),targetX:T(),targetY:T(),influence:T(),poleTargetX:T().optional(),poleTargetY:T().optional(),maxIterations:T().optional(),parameterMappings:L(ub)}),db=R({id:w(),width:T(),height:T(),sourceLayerIds:L(w())}),fb=R({name:w().optional(),width:T().optional(),height:T().optional(),sourceKind:ae(["psd","seeThrough","manualPng","vivi","vivid"]).optional(),layers:L(wr),parameters:L(Hy),clips:L(Wa).optional(),scenes:L(wy).optional(),physicsGroups:L(eb).optional(),lipsyncConfig:rb.optional(),skins:ys(vs,Zy).optional(),parameterBindings:L(Xy).optional(),sceneBlends:L(Py).optional(),ikControllers:L(hb).optional(),offscreenTargets:L(db).optional(),expressionPresets:L(Ky).optional(),colliders:L(Cy).optional(),stateMachines:L(cb).optional()}).superRefine((r,e)=>{xs(r)&&e.addIssue({code:"custom",message:"Object contains a key that may cause prototype pollution"})}),pb=R({layerId:w(),x:T(),y:T(),width:T(),height:T()}),mb=R({image:w(),width:T(),height:T(),entries:L(pb)}),gb=R({version:hn([Z(1),Z(2),Z(3),Z(4),Z(5),Z(6),Z(7),Z(8),Z(9),Z(10)]),profile:Z("publicProfileV1").optional(),project:fb,atlases:L(mb)}),F=(...r)=>r.join(""),_b=Object.freeze([F("Branded","Local","Preview","Frame"),F("Editor","Only","Preview"),F("Local","Motion","Apply","Plan"),F("Local","Motion","Draft"),F("Local","Motion","Handle"),F("Local","Motion","Region"),F("Local","Preview","Frame"),F("Local","Preview","Solver"),F("affine","Region","Fit"),F("as","Rigid","As","Possible"),F("b","b","w"),F("deformed","Vertices"),F("editor","Preview","Frame"),F("guided","Preview","Fit"),F("local","Bone"),F("local","Motion","Constraint"),F("local","Motion","Draft"),F("local","Preview","Solver"),F("motion","Handle","Draft"),F("motion","Region","Weights"),F("motion","Stress","Preview"),F("moving","Least","Squares"),F("preview","Deformed","Vertices"),F("preview","Only"),F("preview","Solver"),F("solver")]),yb=Object.freeze([F("Local","Motion","Apply","Plan"),F("Local","Motion","Draft"),F("Local","Motion","Handle"),F("Local","Motion","Region"),F("Local","Preview","Frame"),F("Local","Preview","Solver"),F("a","r","a","p"),F("a","r","a","p","Local"),F("as","Rigid","As","Possible"),F("b","b","w"),F("constrained","Affine"),F("editor","Preview","Frame"),F("guided","Preview","Fit"),F("m","l","s"),F("m","l","s","Rigid"),F("m","l","s","Similarity"),F("motion","Stress","Preview"),F("moving","Least","Squares")]),bb=Object.freeze([F("Local","Motion","Draft"),F("Local","Preview","Solver"),F("as","Rigid","As","Possible"),F("editor","Preview"),F("guided","Preview","Fit"),F("local","Motion","Draft"),F("local","Preview","Solver"),F("motion","Handle","Draft"),F("motion","Stress","Preview"),F("moving","Least","Squares"),F("preview","Deformed","Vertices"),F("preview","Only")]),xb=new Set(_b),vb=new Set(yb),Tb=bb.map(r=>[r,Ja(r)]);function Sb(r,e){const t=[];return Wt(r,e,"<root>",t,new WeakSet),wb(t)}function Wt(r,e,t,n,s){if(typeof r=="string"){qa(r,e,t,n);return}if(r instanceof Map){if(s.has(r))return;s.add(r);let i=0;for(const[o,a]of r.entries())Wt(o,e,`${t}<key:${i}>`,n,s),Wt(a,e,`${t}<value:${i}>`,n,s),i+=1;return}if(r instanceof Set){if(s.has(r))return;s.add(r);let i=0;for(const o of r.values())Wt(o,e,`${t}<entry:${i}>`,n,s),i+=1;return}if(Array.isArray(r)){if(s.has(r))return;s.add(r),r.forEach((i,o)=>{Wt(i,e,`${t}[${o}]`,n,s)});for(const i of Reflect.ownKeys(r))typeof i=="string"&&Eb(i,r.length)||Ka(r,i,e,t,n,s);return}if(Pb(r)&&!s.has(r)){s.add(r);for(const i of Reflect.ownKeys(r))Ka(r,i,e,t,n,s)}}function Ka(r,e,t,n,s,i){const o=typeof e=="symbol"?e.toString():e,a=`${n}.${o}`;if(qa(o,t,a,s),typeof e=="string"&&xb.has(e)){mn(s,t,a,e);return}const c=Object.getOwnPropertyDescriptor(r,e);if(c===void 0)return;if(!("value"in c)){(e==="kind"||e==="type")&&mn(s,t,a,o);return}const l=c.value;if((e==="kind"||e==="type")&&typeof l=="string"&&vb.has(l)){mn(s,t,a,l);return}Wt(l,t,a,s,i)}function qa(r,e,t,n){const s=Ja(r);for(const[i,o]of Tb)s.includes(o)&&mn(n,e,t,i)}function mn(r,e,t,n){r.push({code:"forbiddenLocalMotionPreviewField",context:e,path:t,marker:n,message:`${e} cannot contain editor-only local motion preview marker ${n}`})}function wb(r){const e=new Set,t=[];for(const n of r){const s=`${n.context}\0${n.path}\0${n.marker}`;e.has(s)||(e.add(s),t.push(n))}return t}function Ja(r){return r.toLowerCase().replace(/[-_.:/\s]+/g,"")}function Pb(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function Eb(r,e){const t=Number(r);return Number.isInteger(t)&&t>=0&&t<e&&String(t)===r}const V=(...r)=>r.join(""),Cb=Object.freeze(["blendShapes","correctiveDeformations","meshLinks","blendShapeWeights","blendShapeTracks","meshPoseTracks","targetBlendShapeId","solver",V("Local","Motion","Draft"),V("local","Motion","Draft"),V("motion","Handle","Draft"),V("Local","Preview","Solver"),V("local","Preview","Solver"),V("preview","Solver"),V("preview","Only"),V("Local","Motion","Region"),V("Local","Motion","Handle"),V("Local","Motion","Apply","Plan"),V("Local","Preview","Frame"),V("Branded","Local","Preview","Frame"),V("Editor","Only","Preview"),V("editor","Preview","Frame"),V("local","Bone"),V("local","Motion","Constraint"),V("motion","Region","Weights"),V("affine","Region","Fit"),V("preview","Deformed","Vertices"),V("deformed","Vertices"),V("guided","Preview","Fit"),V("motion","Stress","Preview"),V("moving","Least","Squares"),V("as","Rigid","As","Possible"),V("b","b","w")]),Mb=Object.freeze(["blendShape","latticeDeformer","morphTarget","correctiveDeformation","meshPose","meshLink",V("Local","Motion","Draft"),V("Local","Preview","Solver"),V("Local","Motion","Region"),V("Local","Motion","Handle"),V("Local","Motion","Apply","Plan"),V("Local","Preview","Frame"),V("editor","Preview","Frame"),V("constrained","Affine"),V("m","l","s"),V("m","l","s","Rigid"),V("m","l","s","Similarity"),V("a","r","a","p"),V("a","r","a","p","Local"),V("guided","Preview","Fit"),V("motion","Stress","Preview"),V("moving","Least","Squares"),V("as","Rigid","As","Possible"),V("b","b","w")]),Qa=Object.freeze(["bone","ikController"]),Ab=Object.freeze(["id","name","values","color","hotkey"]),kb="publicProfileV1";class ec extends Error{constructor(t){super(Rb(t));$(this,"issues");this.name="PublicProfileError",this.issues=t}}function Rb(r){if(r.length===0)return"public profile validation failed";const e=r[0];return`public profile validation failed: ${e.path}: ${e.message}`}function Ib(r){const e=[];return e.push(...tc(r)),r.profile!==void 0&&r.profile!==kb&&e.push({code:"unsupportedProfile",path:"profile",message:`unsupported public project profile: ${String(r.profile)}`}),e.push(...Gb(r.project,"project")),rc(e)}function tc(r){const e=[];if(!Pr(r))return e;e.push(...Sb(r,"publicProfile").map(n=>({code:"forbiddenPublicFeature",path:n.path.replace(/^<root>\./,""),message:"public project profile cannot contain editor-only local motion preview data"}))),Vb(r,e);const t=r.project;return Pr(t)&&Ss(t,"project",e,new WeakSet),rc(e)}function Bb(r){const e=tc(r);if(e.length>0)throw new ec(e)}function Fb(r){const e=Ib(r);if(e.length>0)throw new ec(e)}function Gb(r,e="project"){const t=[];return Hb(r,e,t),jb(r,e,t),t}function rc(r){const e=new Set,t=[];for(const n of r){const s=`${n.code}\0${n.path}`;e.has(s)||(e.add(s),t.push(n))}return t}function Pr(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}const Ob=new Set(Cb),Db=new Set(Mb),Ub=new Set(Qa),Lb=new Set(Ab),zb=new Set(["version","profile","project","atlases"]),Nb=new Set(["name","width","height","sourceKind","layers","parameters","clips","scenes","physicsGroups","lipsyncConfig","skins","parameterBindings","sceneBlends","ikControllers","offscreenTargets","expressionPresets","colliders","stateMachines"]);function Ts(r,e){r.push({code:"forbiddenPublicFeature",path:e,message:"public project profile only accepts layer, bone, IK, skin, physics, and parameter data"})}function nc(r,e){r.push({code:"unknownPublicField",path:e,message:"public project profile does not allow unknown fields"})}function Ss(r,e,t,n){if(Array.isArray(r)){if(n.has(r))return;n.add(r),r.forEach((s,i)=>{Ss(s,`${e}[${i}]`,t,n)});for(const s of Reflect.ownKeys(r))typeof s=="string"&&$b(s,r.length)||sc(r,s,e,t,n);return}if(Pr(r)&&!n.has(r)){n.add(r);for(const s of Reflect.ownKeys(r))sc(r,s,e,t,n)}}function $b(r,e){const t=Number(r);return Number.isInteger(t)&&t>=0&&t<e&&String(t)===r}function sc(r,e,t,n,s){const i=typeof e=="symbol"?e.toString():e,o=`${t}.${i}`,a=Object.getOwnPropertyDescriptor(r,e);if((e==="kind"||e==="type")&&a!==void 0&&!("value"in a)){Ts(n,t);return}const c=a&&"value"in a?a.value:void 0;if(typeof e=="string"&&Ob.has(e)){Ts(n,o);return}if((e==="kind"||e==="type")&&typeof c=="string"&&Db.has(c)){Ts(n,t);return}Ss(c,o,n,s)}function ic(r,e,t,n){if(Pr(r))for(const s of Reflect.ownKeys(r)){if(typeof s!="string"){nc(n,`${e}.${String(s)}`);continue}t.has(s)||nc(n,`${e}.${s}`)}}function Vb(r,e){ic(r,"<root>",zb,e),Pr(r)&&ic(r.project,"project",Nb,e)}function Hb(r,e,t){for(let n=0;n<(r.parameterBindings??[]).length;n+=1){const s=r.parameterBindings[n];Ub.has(s.target.type)||t.push({code:"forbiddenPublicFeature",path:`${e}.parameterBindings[${n}].target`,message:"parameter bindings may target bones or IK controllers only"})}}function jb(r,e,t){for(let n=0;n<(r.expressionPresets??[]).length;n+=1){const s=r.expressionPresets[n];for(const i of Object.keys(s))Lb.has(i)||t.push({code:"forbiddenPublicFeature",path:`${e}.expressionPresets[${n}].${i}`,message:"expression presets may contain parameter values only"})}}const Wb=new Set(["viviMesh","group","bone","artPath"]);function oc(r,e){for(let t=0;t<r.length;t++){const n=r[t],s=`${e}[${t}]`;if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Failed to parse .vivi file: ${s} is not an object`);const i=n;if(typeof i.kind!="string"||!Wb.has(i.kind))throw new Error(`Failed to parse .vivi file: ${s}.kind is invalid (${String(i.kind)})`);if(typeof i.id!="string"||i.id.length===0)throw new Error(`Failed to parse .vivi file: ${s}.id is invalid`);if(i.children!==void 0){if(!Array.isArray(i.children))throw new Error(`Failed to parse .vivi file: ${s}.children is not an array`);oc(i.children,`${s}.children`)}}}function Xb(r,e){for(let t=0;t<r.length;t++){const n=r[t],s=`${e}[${t}]`;if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Failed to parse .vivi file: ${s} is not an object`);const i=n;if(typeof i.layerId!="string"||i.layerId.length===0)throw new Error(`Failed to parse .vivi file: ${s}.layerId is invalid`);for(const o of["x","y","width","height"])if(typeof i[o]!="number"||!Number.isFinite(i[o]))throw new Error(`Failed to parse .vivi file: ${s}.${o} is not a finite number`);if(i.width<0||i.height<0)throw new Error(`Failed to parse .vivi file: ${s}.width/height is negative`)}}function Yb(r){for(let e=0;e<r.length;e++){const t=r[e],n=`atlases[${e}]`;if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Failed to parse .vivi file: ${n} is not an object`);const s=t;if(typeof s.image!="string")throw new Error(`Failed to parse .vivi file: ${n}.image is not a string`);if(typeof s.width!="number"||typeof s.height!="number"||!Number.isFinite(s.width)||!Number.isFinite(s.height)||s.width<=0||s.height<=0)throw new Error(`Failed to parse .vivi file: ${n}.width/height is not a valid positive number`);if(!Array.isArray(s.entries))throw new Error(`Failed to parse .vivi file: ${n}.entries is not an array`);Xb(s.entries,`${n}.entries`)}}function Zb(r){if(r.path.length===0)return"<root>";let e="";for(const t of r.path)typeof t=="number"?e+=`[${t}]`:e+=e===""?String(t):`.${String(t)}`;return e}function Kb(r){return`${Zb(r)}: ${r.message}`}function ac(r,e={}){ss(r,134217728,".vivi file");let t;try{t=JSON.parse(r)}catch{throw new Error("Failed to parse .vivi file: invalid JSON")}if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Failed to parse .vivi file: root value is not an object");const n=t;if(n.version!==1&&n.version!==2&&n.version!==3&&n.version!==4&&n.version!==5&&n.version!==6&&n.version!==7&&n.version!==8&&n.version!==9&&n.version!==10)throw new Error(`Invalid .vivi file version: ${n.version}`);if(!n.project||typeof n.project!="object")throw new Error(".vivi file is missing the project field");if(!Array.isArray(n.atlases))throw new Error(".vivi file is missing the atlases field");const s=n.project;if(!Array.isArray(s.layers))throw new Error(".vivi file is missing the layers field");if(!Array.isArray(s.parameters))throw new Error(".vivi file is missing the parameters field");if(s.name!==void 0&&typeof s.name!="string")throw new Error(".vivi file project.name is not a string");for(const a of["width","height"]){const c=s[a];if(c!==void 0&&(typeof c!="number"||!Number.isFinite(c)||c<=0))throw new Error(`.vivi file project.${a} is not a valid positive number`)}oc(s.layers,"project.layers"),Yb(n.atlases),(e.profile==="publicProfileV1"||n.profile==="publicProfileV1")&&Bb(t);const i=gb.safeParse(t);if(!i.success){const a=i.error.issues[0];throw a?new Error(`Failed to parse .vivi file: ${Kb(a)}`):new Error("Failed to parse .vivi file: schema validation error")}const o=i.data;return e.profile==="publicProfileV1"&&Fb(o),o}const Er={COORD_STRIDE:2,TRIANGLE_VERTS:3},Je={TIMESTEP:1/120,MAX_SUBSTEPS:4,MAX_ANGLE:Math.PI*2,FORCE_PROPAGATION:.5},qb={DEFAULT:500},Jb={MULTIPLY:{r:1,g:1,b:1}};function Qb(r,e,t,n,s,i,o,a){const c=(i-a)*(t-o)+(o-s)*(n-a);if(Math.abs(c)<1e-10)return!1;const l=((i-a)*(r-o)+(o-s)*(e-a))/c,u=((a-n)*(r-o)+(t-o)*(e-a))/c,h=1-l-u;return l>=0&&u>=0&&h>=0}function ex(r,e,t,n,s,i){return r>=t&&r<=t+s&&e>=n&&e<=n+i}function tx(r,e,t,n,s){const i=r-t,o=e-n;return i*i+o*o<=s*s}function rx(r,e,t){const n=r.verticesSpace==="model",s=n?e:e-r.x,i=n?t:t-r.y,o=r.vertices,a=r.indices,c=Er.COORD_STRIDE;for(let l=0;l<a.length;l+=Er.TRIANGLE_VERTS){const u=a[l],h=a[l+1],d=a[l+2],f=o[u*c],p=o[u*c+1],m=o[h*c],g=o[h*c+1],_=o[d*c],y=o[d*c+1];if(Qb(s,i,f,p,m,g,_,y))return!0}return!1}function nx(r,e,t,n){const s=cc(r,e);for(const i of s){const o=lc(i,e,t,n);if(o)return o}return null}function sx(r,e,t,n){const s=cc(r,e),i=[];for(const o of s){const a=lc(o,e,t,n);a&&i.push(a)}return i}function cc(r,e){const t=new Map;for(const[n,s]of e)t.set(n,s.drawOrder);return r.map((n,s)=>({collider:n,index:s})).filter(n=>n.collider.enabled).sort((n,s)=>{const i=uc(n.collider),o=uc(s.collider);if(i!==o)return o-i;const a=hc(n.collider,t),c=hc(s.collider,t);return a!==c?c-a:n.index-s.index}).map(n=>n.collider)}function lc(r,e,t,n){const s=r.shape;switch(s.type){case"rectangle":if(ex(t,n,s.x,s.y,s.width,s.height))return ws(r);break;case"circle":if(tx(t,n,s.x,s.y,s.radius))return ws(r);break;case"mesh":{const i=e.get(s.meshId);if(i!=null&&i.visible&&rx(i,t,n))return ws(r,s.meshId);break}}return null}function uc(r){return r.shape.type==="mesh"?0:1}function hc(r,e){return r.shape.type==="mesh"?e.get(r.shape.meshId)??0:0}function ws(r,e){return{colliderId:r.id,colliderName:r.name,tag:r.tag,meshId:e}}function ix(r){return r.kind==="bone"}function dc(r,e){return[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5]]}function ox(r){const e=Math.cos(r.bone.angle),t=Math.sin(r.bone.angle),n=r.bone.scaleX,s=r.bone.scaleY;return[e*n,t*n,-t*s,e*s,r.x,r.y]}function ax(r){const e=new Map,t=n=>{for(const s of n)ix(s)&&e.set(s.id,s),s.children.length>0&&t(s.children)};return t(r),e}function fc(r){const e=ax(r),t=new Map,n=s=>{const i=t.get(s.id);if(i)return i;const o=ox(s);let a;if(s.parentBoneId){const c=e.get(s.parentBoneId);if(c){const l=n(c);a=dc(l,o)}else a=o}else a=o;return t.set(s.id,a),a};for(const s of e.values())n(s);return t}function cx(r){return r?r.r===0&&r.g===0&&r.b===0:!0}function lx(r){return r??qb.DEFAULT}function ux(r){return r??Jb.MULTIPLY}function hx(r){const e=3*Er.COORD_STRIDE;if(r.length<e)return!1;let t=0;const n=r.length;for(let s=0;s<n;s+=Er.COORD_STRIDE){const i=(s+Er.COORD_STRIDE)%n,o=r[s],a=r[s+1],c=r[i],l=r[i+1];t+=o*l-c*a}return t<0}function pc(r){const e=[];for(const t of r)e.push(t),t.children.length>0&&e.push(...pc(t.children));return e}function dx(r,e){return mc(r,e)??[]}function mc(r,e){for(const t of r){if(t.id===e)return[t];if(t.children.length>0){const n=mc(t.children,e);if(n)return n.unshift(t),n}}return null}function fx(r,e){return r.visible?dx(e,r.id).every(n=>n.visible):!1}function px(r){return{vertices:new Float32Array(r.vertices),uvs:new Float32Array(r.uvs),indices:new Uint32Array(r.indices)}}function gn(r){return r=r%(2*Math.PI),r>=Math.PI&&(r-=2*Math.PI),r<-Math.PI&&(r+=2*Math.PI),r}function _n(r,e,t){const n=gn(r);return n<e?e:n>t?t:n}function mx(r,e,t,n,s,i,o,a,c){const l=s-r,u=i-e,h=Math.sqrt(l*l+u*u),d=Math.atan2(u,l);if(h>=t+n)return Ps(d,d,c);if(h<=Math.abs(t-n)){const v=d,C=d+Math.PI;return Ps(v,C,c)}const f=(t*t+h*h-n*n)/(2*t*h),p=Math.max(-1,Math.min(1,f));let m=Math.acos(p);if(o!==void 0&&a!==void 0){const v=o-r,C=a-e;l*C-u*v<0&&(m=-m)}const g=d+m,_=r+t*Math.cos(g),y=e+t*Math.sin(g),b=Math.atan2(i-y,s-_);return Ps(g,b,c)}function Ps(r,e,t){return t?[_n(r,t[0].minAngle,t[0].maxAngle),_n(e,t[1].minAngle,t[1].maxAngle)]:[r,e]}function gx(r,e,t,n=10,s=.5){if(r.length===0)return{solvedAngles:new Map,reached:!1};const i=r.map(h=>h.angle),o=r.map(h=>({x:h.worldX,y:h.worldY})),a=()=>{const h=r.length-1;return{x:o[h].x+r[h].length*Math.cos(i[h]),y:o[h].y+r[h].length*Math.sin(i[h])}},c=()=>{for(let h=1;h<r.length;h++){const d=h-1;o[h].x=o[d].x+r[d].length*Math.cos(i[d]),o[h].y=o[d].y+r[d].length*Math.sin(i[d])}};let l=!1;for(let h=0;h<n;h++){for(let p=r.length-1;p>=0;p--){const m=a(),g=Math.atan2(m.y-o[p].y,m.x-o[p].x),_=Math.atan2(t-o[p].y,e-o[p].x),y=gn(_-g);i[p]=i[p]+y,i[p]=_n(i[p],r[p].constraint.minAngle,r[p].constraint.maxAngle),c()}const d=a();if(Math.sqrt((d.x-e)**2+(d.y-t)**2)<s){l=!0;break}}const u=new Map;for(let h=0;h<r.length;h++)u.set(r[h].id,i[h]);return{solvedAngles:u,reached:l}}function _x(r,e,t){return r.boneChain.map(n=>{const s=e.get(n.boneId),i=s?s[4]:0,o=s?s[5]:0,a=s?Math.atan2(s[1],s[0]):0,c=t.get(n.boneId)??0;return{id:n.boneId,worldX:i,worldY:o,angle:a,length:c,constraint:n}})}function yx(r,e,t){const{targetX:n,targetY:s,influence:i}=r;if(i<=0||r.boneChain.length===0)return{solvedAngles:new Map,reached:!1};if(r.solverType==="twoBone"&&r.boneChain.length===2){const c=r.boneChain[0],l=r.boneChain[1],u=e.get(c.boneId),h=u?u[4]:0,d=u?u[5]:0,f=t.get(c.boneId)??0,p=t.get(l.boneId)??0,[m,g]=mx(h,d,f,p,n,s,r.poleTargetX,r.poleTargetY,[c,l]),_=new Map;_.set(c.boneId,m),_.set(l.boneId,g);const y=Math.sqrt((n-h)**2+(s-d)**2),b=y>=Math.abs(f-p)&&y<=f+p;return{solvedAngles:_,reached:b}}const o=_x(r,e,t);return gx(o,n,s,r.maxIterations??10)}function bx(r){const e=r.project.ikControllers;if(!e||e.length===0)return;const t=vx(r.project.layers),n=wx(r),s=fc(n),i=Tx(n);for(const o of e){const a=Cx(o,r);if(a.influence<=0)continue;const c=xx(a),l=yx(a,s,r.boneLengths);for(const[u,h]of l.solvedAngles){const d=r.boneAngles[u]??i.get(u)??0,f=Ex(u,h,l.solvedAngles,s,t),p=c.get(u),m=p?_n(f,p.minAngle,p.maxAngle):f;r.boneAngles[u]=d*(1-a.influence)+m*a.influence}}}function xx(r){return new Map(r.boneChain.map(e=>[e.boneId,e]))}function vx(r){const e=new Map,t=n=>{for(const s of n)s.kind==="bone"&&e.set(s.id,s.parentBoneId??null),s.children.length>0&&t(s.children)};return t(r),e}function Tx(r){const e=new Map,t=n=>{for(const s of n)s.kind==="bone"&&e.set(s.id,s.bone.angle),s.children.length>0&&t(s.children)};return t(r),e}function Sx(r){return Object.keys(r.boneAngles).length>0||Object.keys(r.boneX??{}).length>0||Object.keys(r.boneY??{}).length>0||Object.keys(r.boneScaleX??{}).length>0||Object.keys(r.boneScaleY??{}).length>0}function wx(r){return Sx(r)?r.project.layers.map(e=>gc(e,r)):r.project.layers}function gc(r,e){var l,u,h,d;const t=r.children.map(f=>gc(f,e));if(r.kind!=="bone")return{...r,children:t};const n={...r,children:t,bone:{...r.bone}},s=(l=e.boneX)==null?void 0:l[r.id];s!==void 0&&(n.x=s);const i=(u=e.boneY)==null?void 0:u[r.id];i!==void 0&&(n.y=i);const o=e.boneAngles[r.id];o!==void 0&&(n.bone.angle=o);const a=(h=e.boneScaleX)==null?void 0:h[r.id];a!==void 0&&(n.bone.scaleX=a);const c=(d=e.boneScaleY)==null?void 0:d[r.id];return c!==void 0&&(n.bone.scaleY=c),n}function Px(r){return r?Math.atan2(r[1],r[0]):0}function Ex(r,e,t,n,s){const i=s.get(r);if(!i)return gn(e);const o=t.get(i)??Px(n.get(i));return gn(e-o)}function Cx(r,e){var a,c,l,u,h;const t=(a=e.ikTargetX)==null?void 0:a[r.id],n=(c=e.ikTargetY)==null?void 0:c[r.id],s=(l=e.ikPoleTargetX)==null?void 0:l[r.id],i=(u=e.ikPoleTargetY)==null?void 0:u[r.id],o=(h=e.ikInfluence)==null?void 0:h[r.id];return t===void 0&&n===void 0&&s===void 0&&i===void 0&&o===void 0?r:{...r,targetX:t??r.targetX,targetY:n??r.targetY,poleTargetX:s??r.poleTargetX,poleTargetY:i??r.poleTargetY,influence:o===void 0?r.influence:Math.max(0,Math.min(1,o))}}function Mx(r){return r.pendulums.map(()=>({angle:0,angularVelocity:0}))}function Ax(r,e,t){let n=0,s=0;for(const i of r){const o=e[i.parameterId]??0,a=t[i.parameterId]??0,c=(o-a)*i.weight;switch(i.type){case"x":n+=c;break;case"y":s+=c;break;case"angle":n+=c;break}}return{x:n,y:s}}function kx(r,e,t,n){const s=r.gravityDirection*Math.PI/180,i=Math.sin(s)*r.gravityStrength,o=Math.cos(s)*r.gravityStrength;for(let a=0;a<r.pendulums.length;a++){const c=r.pendulums[a],l=e[a];if(!c||!l)continue;const u=Math.sin(l.angle),h=Math.cos(l.angle);let d=i+r.wind,f=o;if(a===0)d+=t.x,f+=t.y;else{const _=e[a-1];_&&(d+=_.angularVelocity*c.length*Je.FORCE_PROPAGATION)}const p=d*h-f*u,m=c.mass*c.length,g=m>0?p/m:0;l.angularVelocity+=g*n,l.angularVelocity*=1-c.damping,l.angle+=l.angularVelocity*n,l.angle>Je.MAX_ANGLE?(l.angle=Je.MAX_ANGLE,l.angularVelocity=0):l.angle<-Je.MAX_ANGLE&&(l.angle=-Je.MAX_ANGLE,l.angularVelocity=0)}}function Rx(r,e,t){const n={},s={},i=new Map(t.map(o=>[o.id,o]));for(const o of r){if(o.pendulumIndex<0||o.pendulumIndex>=e.length)continue;const a=e[o.pendulumIndex];if(!a)continue;const c=a.angle*o.weight;if(o.type==="boneAngle"&&o.boneId)s[o.boneId]=c;else if(o.parameterId){let l=c;const u=i.get(o.parameterId);u&&(l+=u.defaultValue,l=Math.max(u.minValue,Math.min(u.maxValue,l))),n[o.parameterId]=l}}return{parameters:n,bones:s}}function Ix(r,e,t,n,s){s+=n;let i=0;for(;s>=Je.TIMESTEP&&i<Je.MAX_SUBSTEPS;)kx(r,e,t,Je.TIMESTEP),s-=Je.TIMESTEP,i++;return s>Je.TIMESTEP*Je.MAX_SUBSTEPS&&(s=0),s}function Bx(r,e){for(const t of r.project.physicsGroups){if(!t.enabled)continue;const n=r.physicsStates.get(t.id);if(!n)continue;const s=Ax(t.inputs,r.parameterValues,r.prevParamValues),i=r.physicsAccumulators.get(t.id)??0,o=Ix(t,n,s,e,i);r.physicsAccumulators.set(t.id,o);const a=Rx(t.outputs,n,r.project.parameters);for(const[c,l]of Object.entries(a.parameters))r.parameterValues[c]=l;for(const[c,l]of Object.entries(a.bones))r.boneAngles[c]=(r.boneAngles[c]??0)+l}}function Fx(r,e,t){if(r.length===0)return t;if(r.length===1)return r[0].targetValue;const n=r[0],s=r[r.length-1];if(e<=n.paramValue)return n.targetValue;if(e>=s.paramValue)return s.targetValue;for(let i=0;i<r.length-1;i++){const o=r[i],a=r[i+1];if(e>=o.paramValue&&e<=a.paramValue){const c=(e-o.paramValue)/(a.paramValue-o.paramValue);return o.targetValue+(a.targetValue-o.targetValue)*c}}return t}function _c(r,e,t){let n=0;for(const s of r){const i=e[s.parameterId]??0,o=Fx(s.bindingPoints,i,t);n+=o-t}return t+n}function Gx(r,e,t={}){const n={},s=new Map,i=t.allowUnknown??!0,o=t.clampKnown??!1;for(const a of r)s.set(a.id,a),n[a.id]=a.defaultValue;for(const[a,c]of Object.entries(e)){const l=s.get(a);if(!l){i&&(n[a]=c);continue}if(!Number.isFinite(c)){if(t.rejectInvalid)throw new TypeError(`initial parameter must be finite: ${a}`);n[a]=c;continue}n[a]=o?Math.max(l.minValue,Math.min(l.maxValue,c)):c}return n}function Ox(r,e,t){const n=r.length/2,s=new Array(r.length).fill(0);for(let i=0;i<n;i++){const o=r[i*2],a=r[i*2+1],c=e.weights[i];if(!c||c.length===0){s[i*2]=o,s[i*2+1]=a;continue}let l=0,u=0,h=0;for(const d of c){const f=t.get(d.boneId),p=e.bindPoseInverse[d.boneId];if(!f||!p)continue;const m=dc(f,p),g=m[0]*o+m[2]*a+m[4],_=m[1]*o+m[3]*a+m[5];l+=g*d.weight,u+=_*d.weight,h+=d.weight}if(h<=1e-12){s[i*2]=o,s[i*2+1]=a;continue}if(h<1){const d=1-h;l+=o*d,u+=a*d}s[i*2]=l,s[i*2+1]=u}return s}const Dx=new Set(Qa);function yc(r){const e=new Map;for(const[t,n]of r)e.set(t,n.map(s=>({angle:s.angle,angularVelocity:s.angularVelocity})));return e}function bc(r){const e=new Map;for(const[t,n]of r)e.set(t,new Float32Array(n));return e}function xc(r){const e=new Map;for(const[t,n]of r)e.set(t,{...n,vertices:new Float32Array(n.vertices),uvs:new Float32Array(n.uvs),indices:new Uint32Array(n.indices),multiplyColor:{...n.multiplyColor},screenColor:n.screenColor?{...n.screenColor}:void 0});return e}function Ux(r,e){for(const t of Object.keys(r))delete r[t];Object.assign(r,e)}function yn(r,e){r.clear();for(const[t,n]of e)r.set(t,n)}class bn{constructor(e,t,n){$(this,"project");$(this,"atlases");$(this,"parameterValues");$(this,"allLayers");$(this,"meshStaticCache",new Map);$(this,"meshScratchVerts",new Map);$(this,"meshStates",new Map);$(this,"drawOrderScratch",[]);$(this,"drawOrderCache",[]);$(this,"boneLengths",new Map);$(this,"boneBaseX",{});$(this,"boneBaseY",{});$(this,"boneX",{});$(this,"boneY",{});$(this,"boneAngles",{});$(this,"boneScaleX",{});$(this,"boneScaleY",{});$(this,"ikTargetX",{});$(this,"ikTargetY",{});$(this,"ikPoleTargetX",{});$(this,"ikPoleTargetY",{});$(this,"ikInfluence",{});$(this,"physicsStates",new Map);$(this,"physicsAccumulators",new Map);$(this,"prevParamValues",{});this.project=e,this.atlases=t,this.allLayers=pc(e.layers??[]),this.parameterValues=Gx(e.parameters??[],(n==null?void 0:n.initialParameters)??{}),this.rebuildStaticCaches(),this.prevParamValues={...this.parameterValues};for(const s of e.physicsGroups??[])s.enabled&&(this.physicsStates.set(s.id,Mx(s)),this.physicsAccumulators.set(s.id,0));this.update()}static fromJSON(e,t){const n=ac(e,{profile:"publicProfileV1"});return bn.fromFileData(n,t)}static fromFileData(e,t){return new bn(e.project,e.atlases,t)}setParameter(e,t){const n=this.project.parameters.find(s=>s.id===e);n&&(this.parameterValues[e]=Math.max(n.minValue,Math.min(n.maxValue,t)))}setParameters(e){for(const[t,n]of Object.entries(e))this.setParameter(t,n)}resetParameters(){for(const e of this.project.parameters)this.parameterValues[e.id]=e.defaultValue}applyExpressionPreset(e){var n;const t=(n=this.project.expressionPresets)==null?void 0:n.find(s=>s.id===e);t&&this.setParameters(t.values)}hitTest(e,t){const n=this.project.colliders;return!n||n.length===0?null:nx(n,this.meshStates,e,t)}hitTestAll(e,t){const n=this.project.colliders;return!n||n.length===0?[]:sx(n,this.meshStates,e,t)}update(e=0){this.evaluatePublicParameterBindings(),e>0&&Bx({project:this.project,parameterValues:this.parameterValues,prevParamValues:this.prevParamValues,physicsStates:this.physicsStates,physicsAccumulators:this.physicsAccumulators,boneAngles:this.boneAngles},e),bx({project:this.project,boneLengths:this.boneLengths,boneAngles:this.boneAngles,boneX:this.boneX,boneY:this.boneY,boneScaleX:this.boneScaleX,boneScaleY:this.boneScaleY,ikTargetX:this.ikTargetX,ikTargetY:this.ikTargetY,ikPoleTargetX:this.ikPoleTargetX,ikPoleTargetY:this.ikPoleTargetY,ikInfluence:this.ikInfluence}),this.applyBoneOverrides(),this.computeMeshStates(),this.prevParamValues={...this.parameterValues}}createRuntimeSnapshot(){const e=new Map;for(const t of this.allLayers)t.kind==="bone"&&e.set(t.id,{x:t.x,y:t.y,angle:t.bone.angle,scaleX:t.bone.scaleX,scaleY:t.bone.scaleY});return{parameterValues:{...this.parameterValues},prevParamValues:{...this.prevParamValues},boneX:{...this.boneX},boneY:{...this.boneY},boneAngles:{...this.boneAngles},boneScaleX:{...this.boneScaleX},boneScaleY:{...this.boneScaleY},ikTargetX:{...this.ikTargetX},ikTargetY:{...this.ikTargetY},ikPoleTargetX:{...this.ikPoleTargetX},ikPoleTargetY:{...this.ikPoleTargetY},ikInfluence:{...this.ikInfluence},physicsStates:yc(this.physicsStates),physicsAccumulators:new Map(this.physicsAccumulators),meshScratchVerts:bc(this.meshScratchVerts),meshStates:xc(this.meshStates),drawOrderCache:[...this.drawOrderCache],boneLayers:e}}restoreRuntimeSnapshot(e){const t=yc(e.physicsStates),n=new Map(e.physicsAccumulators),s=bc(e.meshScratchVerts),i=xc(e.meshStates),o=[...e.drawOrderCache],a={...e.prevParamValues},c={...e.boneX},l={...e.boneY},u={...e.boneAngles},h={...e.boneScaleX},d={...e.boneScaleY},f={...e.ikTargetX},p={...e.ikTargetY},m={...e.ikPoleTargetX},g={...e.ikPoleTargetY},_={...e.ikInfluence};Ux(this.parameterValues,e.parameterValues),this.prevParamValues=a,this.boneX=c,this.boneY=l,this.boneAngles=u,this.boneScaleX=h,this.boneScaleY=d,this.ikTargetX=f,this.ikTargetY=p,this.ikPoleTargetX=m,this.ikPoleTargetY=g,this.ikInfluence=_,yn(this.physicsStates,t),yn(this.physicsAccumulators,n),yn(this.meshScratchVerts,s),yn(this.meshStates,i),this.drawOrderCache.length=0,this.drawOrderCache.push(...o);for(const y of this.allLayers){if(y.kind!=="bone")continue;const b=e.boneLayers.get(y.id);b&&(y.x=b.x,y.y=b.y,y.bone.angle=b.angle,y.bone.scaleX=b.scaleX,y.bone.scaleY=b.scaleY)}}getDrawOrder(){return this.drawOrderCache}getMeshState(e){return this.meshStates.get(e)}getAllMeshStates(){return this.meshStates}get width(){return this.project.width}get height(){return this.project.height}rebuildStaticCaches(){for(const e of this.allLayers)e.kind==="viviMesh"?(this.meshStaticCache.set(e.id,{uvs:new Float32Array(e.mesh.uvs),indices:new Uint32Array(e.mesh.indices)}),this.meshScratchVerts.set(e.id,new Float32Array(e.mesh.vertices.length))):e.kind==="bone"&&(this.boneLengths.set(e.id,e.bone.length),this.boneBaseX[e.id]=e.x,this.boneBaseY[e.id]=e.y)}evaluatePublicParameterBindings(){const e=this.project.parameterBindings??[];if(e.length===0)return;const t=new Map;for(const n of e){if(!Dx.has(n.target.type))continue;const s=n.target.type==="bone"?`bone:${n.target.boneId}:${n.target.property}`:`ik:${n.target.controllerId}:${n.target.property}`,i=t.get(s);i?i.push(n):t.set(s,[n])}for(const n of t.values()){const s=n[0].target;if(s.type==="bone"){const i=_c(n,this.parameterValues,this.getBoneBindingDefaultValue(s.boneId,s.property));this.setBoneBindingValue(s.boneId,s.property,i)}else if(s.type==="ikController"){const i=_c(n,this.parameterValues,this.getIKBindingDefaultValue(s.controllerId,s.property));this.setIKBindingValue(s.controllerId,s.property,i)}}}getBoneBindingDefaultValue(e,t){return t==="x"?this.boneBaseX[e]??0:t==="y"?this.boneBaseY[e]??0:t==="angle"?0:1}setBoneBindingValue(e,t,n){t==="x"?this.boneX[e]=n:t==="y"?this.boneY[e]=n:t==="angle"?this.boneAngles[e]=n:t==="scaleX"?this.boneScaleX[e]=n:this.boneScaleY[e]=n}getIKBindingDefaultValue(e,t){var s;const n=(s=this.project.ikControllers)==null?void 0:s.find(i=>i.id===e);return n?t==="targetX"?n.targetX:t==="targetY"?n.targetY:t==="poleTargetX"?n.poleTargetX??0:t==="poleTargetY"?n.poleTargetY??0:n.influence:t==="influence"?1:0}setIKBindingValue(e,t,n){t==="targetX"?this.ikTargetX[e]=n:t==="targetY"?this.ikTargetY[e]=n:t==="poleTargetX"?this.ikPoleTargetX[e]=n:t==="poleTargetY"?this.ikPoleTargetY[e]=n:this.ikInfluence[e]=Math.max(0,Math.min(1,n))}applyBoneOverrides(){for(const e of this.allLayers)e.kind==="bone"&&(this.boneX[e.id]!==void 0&&(e.x=this.boneX[e.id]),this.boneY[e.id]!==void 0&&(e.y=this.boneY[e.id]),this.boneAngles[e.id]!==void 0&&(e.bone.angle=this.boneAngles[e.id]),this.boneScaleX[e.id]!==void 0&&(e.bone.scaleX=this.boneScaleX[e.id]),this.boneScaleY[e.id]!==void 0&&(e.bone.scaleY=this.boneScaleY[e.id]))}computeMeshStates(){var s;const e=this.drawOrderScratch;e.length=0;const t=fc(this.project.layers),n=new Set;for(const i of this.allLayers){if(i.kind!=="viviMesh")continue;let o=this.meshScratchVerts.get(i.id);(!o||o.length!==i.mesh.vertices.length)&&(o=new Float32Array(i.mesh.vertices.length),this.meshScratchVerts.set(i.id,o)),this.computeFinalVerticesInto(i,t,o);let a=this.meshStaticCache.get(i.id);if(!a){const f=px(i.mesh);a={uvs:f.uvs,indices:f.indices},this.meshStaticCache.set(i.id,a)}const c=lx(i.drawOrder),l=fx(i,this.project.layers),u=i.culling===!0&&l&&hx(o),h=((s=this.project.skins)==null?void 0:s[i.id])!==void 0,d=h?"model":"local";this.meshStates.set(i.id,{id:i.id,vertices:new Float32Array(o),verticesSpace:d,uvs:a.uvs,indices:a.indices,x:h?0:i.x,y:h?0:i.y,opacity:i.opacity,visible:l&&!u,blendMode:i.blendMode,multiplyColor:ux(i.multiplyColor),screenColor:cx(i.screenColor)?void 0:i.screenColor,drawOrder:c,culled:u}),n.add(i.id),e.push({id:i.id,zIndex:c})}if(this.meshStates.size!==n.size)for(const i of this.meshStates.keys())n.has(i)||this.meshStates.delete(i);e.sort((i,o)=>i.zIndex-o.zIndex),this.drawOrderCache.length=e.length;for(let i=0;i<e.length;i+=1)this.drawOrderCache[i]=e[i].id}computeFinalVerticesInto(e,t,n){var a;const s=(a=this.project.skins)==null?void 0:a[e.id],i=s?Ox(e.mesh.vertices,s,t):e.mesh.vertices,o=Math.min(n.length,i.length);for(let c=0;c<o;c+=1)n[c]=i[c]}}function Lx(r){const e=jx(r);return{commands:Sc(e,0,e.length)}}async function zx(r,e,t){const n=t??{running:!0,cancelled:!1};n.running=!0,n.cancelled=!1;try{await vc(r.commands,e,n)}finally{n.running=!1}}function Nx(r){r.cancelled=!0}async function vc(r,e,t){for(const n of r){if(t.cancelled)return;await $x(n,e,t)}}async function $x(r,e,t){switch(r.type){case"setParam":e.setParameter(r.parameterId,r.value),e.update();break;case"preset":{e.applyExpressionPreset(r.presetId),e.update();break}case"presetByName":{const n=e.getPresetByName(r.name);n&&(e.applyExpressionPreset(n),e.update());break}case"wait":await Tc(r.ms,t);break;case"lerp":{const n=Math.max(1,Math.ceil(r.duration/16)),s=r.duration/n;for(let i=0;i<=n;i++){if(t.cancelled)return;const o=i/n,a=r.from+(r.to-r.from)*o;e.setParameter(r.parameterId,a),e.update(),i<n&&await Tc(s,t)}break}case"reset":e.resetParameters(),e.update();break;case"loop":{const n=r.count<=0?1/0:r.count;for(let s=0;s<n;s++){if(t.cancelled)return;await vc(r.commands,e,t)}break}}}const Vx=2147483647,Hx=50;function Tc(r,e){const t=Math.max(0,Number.isFinite(r)?r:0);return t<=0||e.cancelled?Promise.resolve():new Promise(n=>{let s=0,i=!1,o,a;const c=()=>{i||(i=!0,o!==void 0&&clearTimeout(o),a!==void 0&&clearInterval(a),n())},l=()=>{const u=t-s;if(u<=0){c();return}const h=Math.min(u,Vx);o=setTimeout(()=>{if(s+=h,e.cancelled){c();return}l()},h)};a=setInterval(()=>{e.cancelled&&c()},Math.min(Hx,t)),l()})}function jx(r){const e=[];let t=0;const n=r.trim();for(;t<n.length;){if(/\s/.test(n[t])){t++;continue}if(n[t]==="→"||n[t]==="-"&&n[t+1]===">"||n[t]==="="&&n[t+1]===">"){e.push({type:"arrow"}),t+=n[t]==="→"?1:2;continue}if(n[t]==="("){e.push({type:"lparen"}),t++;continue}if(n[t]===")"){e.push({type:"rparen"}),t++;continue}if(n[t]==="{"){e.push({type:"lbrace"}),t++;continue}if(n[t]==="}"){e.push({type:"rbrace"}),t++;continue}if(n[t]===","){e.push({type:"comma"}),t++;continue}if(n[t]==='"'||n[t]==="'"){const s=n[t];let i="";for(t++;t<n.length&&n[t]!==s;)i+=n[t],t++;t++,e.push({type:"string",value:i});continue}if(/[0-9\-.]/.test(n[t])&&(n[t]!=="-"||/[0-9.]/.test(n[t+1]??""))){let s="";for(n[t]==="-"&&(s+="-",t++);t<n.length&&/[0-9.]/.test(n[t]);)s+=n[t],t++;e.push({type:"number",value:Number(s)});continue}if(/[a-zA-Z_\u3000-\u9FFF\uF900-\uFAFF]/.test(n[t])){let s="";for(;t<n.length&&/[a-zA-Z0-9_\u3000-\u9FFF\uF900-\uFAFF]/.test(n[t]);)s+=n[t],t++;e.push({type:"ident",value:s});continue}t++}return e}function Sc(r,e,t){var i,o,a,c,l;const n=[];let s=e;for(;s<t;){const u=r[s];if(u.type==="arrow"){s++;continue}if(u.type==="ident"){const h=u.value;if(h==="wait"&&((i=r[s+1])==null?void 0:i.type)==="lparen"){const d=xn(r,s+1);n.push({type:"wait",ms:d.numbers[0]??500}),s=d.end+1;continue}if(h==="set"&&((o=r[s+1])==null?void 0:o.type)==="lparen"){const d=xn(r,s+1);n.push({type:"setParam",parameterId:d.strings[0]??"",value:d.numbers[0]??0}),s=d.end+1;continue}if(h==="lerp"&&((a=r[s+1])==null?void 0:a.type)==="lparen"){const d=xn(r,s+1);n.push({type:"lerp",parameterId:d.strings[0]??"",from:d.numbers[0]??0,to:d.numbers[1]??1,duration:d.numbers[2]??500}),s=d.end+1;continue}if(h==="loop"&&((c=r[s+1])==null?void 0:c.type)==="lparen"){const d=xn(r,s+1),f=d.numbers[0]??0,p=d.end+1;if(((l=r[p])==null?void 0:l.type)==="lbrace"){const m=Wx(r,p),g=Sc(r,p+1,m);n.push({type:"loop",count:f,commands:g}),s=m+1}else s=p;continue}if(h==="reset"){n.push({type:"reset"}),s++;continue}n.push({type:"presetByName",name:h}),s++;continue}if(u.type==="string"){n.push({type:"presetByName",name:u.value}),s++;continue}s++}return n}function xn(r,e){const t=[],n=[];let s=e+1;for(;s<r.length;){const i=r[s];if(i.type==="rparen")break;if(i.type==="comma"){s++;continue}i.type==="number"&&n.push(i.value),(i.type==="string"||i.type==="ident")&&t.push(i.value),s++}return{strings:t,numbers:n,end:s}}function Wx(r,e){let t=1,n=e+1;for(;n<r.length&&t>0;)r[n].type==="lbrace"&&t++,r[n].type==="rbrace"&&t--,t>0&&n++;return n}function wc(r){const e=[];for(const t of r){e.push(t);const n=Array.isArray(t.children)?t.children:[];n.length>0&&e.push(...wc(n))}return e}async function Xx(r){const e=new Map,t=new Map;for(const s of r.atlases){const i=await Yx(s.image,s.width,s.height);for(const o of s.entries){t.set(o.layerId,{entry:o,atlasWidth:s.width,atlasHeight:s.height});const a=document.createElement("canvas");a.width=o.width,a.height=o.height;const c=a.getContext("2d");c&&c.drawImage(i,o.x,o.y,o.width,o.height,0,0,o.width,o.height),e.set(o.layerId,a)}}const n=wc(r.project.layers);for(const s of n){if(s.kind!=="viviMesh")continue;const i=t.get(s.id);if(!i)continue;const{entry:o,atlasWidth:a,atlasHeight:c}=i,l=s.mesh.uvs;for(let u=0;u<l.length;u+=2)l[u]=(l[u]*a-o.x)/o.width||0,l[u+1]=(l[u+1]*c-o.y)/o.height||0}return e}function Yx(r,e,t){return new Promise((n,s)=>{const i=new Image;i.onload=()=>{const o=document.createElement("canvas");o.width=e,o.height=t;const a=o.getContext("2d");a&&a.drawImage(i,0,0),n(o)},i.onerror=()=>s(new Error("Failed to load atlas image")),i.src=`data:image/png;base64,${r}`})}var x=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(x||{});const Es=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},vn=(r,e)=>Es(r).priority??e,H={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Es).forEach(e=>{e.type.forEach(t=>{var n,s;return(s=(n=this._removeHandlers)[t])==null?void 0:s.call(n,e)})}),this},add(...r){return r.map(Es).forEach(e=>{e.type.forEach(t=>{var i,o;const n=this._addHandlers,s=this._queue;n[t]?(o=n[t])==null||o.call(n,e):(s[t]=s[t]||[],(i=s[t])==null||i.push(e))})}),this},handle(r,e,t){var o;const n=this._addHandlers,s=this._removeHandlers;if(n[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);n[r]=e,s[r]=t;const i=this._queue;return i[r]&&((o=i[r])==null||o.forEach(a=>e(a)),delete i[r]),this},handleByMap(r,e){return this.handle(r,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(r,e,t=-1){return this.handle(r,n=>{e.findIndex(i=>i.name===n.name)>=0||(e.push({name:n.name,value:n.ref}),e.sort((i,o)=>vn(o.value,t)-vn(i.value,t)))},n=>{const s=e.findIndex(i=>i.name===n.name);s!==-1&&e.splice(s,1)})},handleByList(r,e,t=-1){return this.handle(r,n=>{e.includes(n.ref)||(e.push(n.ref),e.sort((s,i)=>vn(i,t)-vn(s,t)))},n=>{const s=e.indexOf(n.ref);s!==-1&&e.splice(s,1)})},mixin(r,...e){for(const t of e)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(t))}};let Cr;function Pc(){if(typeof Cr=="boolean")return Cr;try{Cr=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Cr=!1}return Cr}function Ec(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Cs={exports:{}},Cc;function Zx(){return Cc||(Cc=1,(function(r){var e=Object.prototype.hasOwnProperty,t="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(t=!1));function s(c,l,u){this.fn=c,this.context=l,this.once=u||!1}function i(c,l,u,h,d){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,h||c,d),p=t?t+l:l;return c._events[p]?c._events[p].fn?c._events[p]=[c._events[p],f]:c._events[p].push(f):(c._events[p]=f,c._eventsCount++),c}function o(c,l){--c._eventsCount===0?c._events=new n:delete c._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],u,h;if(this._eventsCount===0)return l;for(h in u=this._events)e.call(u,h)&&l.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(u)):l},a.prototype.listeners=function(l){var u=t?t+l:l,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var d=0,f=h.length,p=new Array(f);d<f;d++)p[d]=h[d].fn;return p},a.prototype.listenerCount=function(l){var u=t?t+l:l,h=this._events[u];return h?h.fn?1:h.length:0},a.prototype.emit=function(l,u,h,d,f,p){var m=t?t+l:l;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,y,b;if(g.fn){switch(g.once&&this.removeListener(l,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,h),!0;case 4:return g.fn.call(g.context,u,h,d),!0;case 5:return g.fn.call(g.context,u,h,d,f),!0;case 6:return g.fn.call(g.context,u,h,d,f,p),!0}for(b=1,y=new Array(_-1);b<_;b++)y[b-1]=arguments[b];g.fn.apply(g.context,y)}else{var v=g.length,C;for(b=0;b<v;b++)switch(g[b].once&&this.removeListener(l,g[b].fn,void 0,!0),_){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,u);break;case 3:g[b].fn.call(g[b].context,u,h);break;case 4:g[b].fn.call(g[b].context,u,h,d);break;default:if(!y)for(C=1,y=new Array(_-1);C<_;C++)y[C-1]=arguments[C];g[b].fn.apply(g[b].context,y)}}return!0},a.prototype.on=function(l,u,h){return i(this,l,u,h,!1)},a.prototype.once=function(l,u,h){return i(this,l,u,h,!0)},a.prototype.removeListener=function(l,u,h,d){var f=t?t+l:l;if(!this._events[f])return this;if(!u)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===u&&(!d||p.once)&&(!h||p.context===h)&&o(this,f);else{for(var m=0,g=[],_=p.length;m<_;m++)(p[m].fn!==u||d&&!p[m].once||h&&p[m].context!==h)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(l){var u;return l?(u=t?t+l:l,this._events[u]&&o(this,u)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(Cs)),Cs.exports}var Kx=Zx();const Qe=Ec(Kx),Ms={default:-1};function ce(r="default"){return Ms[r]===void 0&&(Ms[r]=-1),++Ms[r]}var Q=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(Q||{});class Ue extends Qe{constructor(e){let{data:t,size:n}=e;const{usage:s,label:i,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ce("buffer"),this._resourceType="buffer",this._resourceId=ce("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array&&(t=new Float32Array(t)),this._data=t,n??(n=t==null?void 0:t.byteLength);const a=!!t;this.descriptor={size:n,usage:s,mappedAtCreation:a,label:i},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&Q.STATIC)}set static(e){e?this.descriptor.usage|=Q.STATIC:this.descriptor.usage&=~Q.STATIC}setDataWithSize(e,t,n){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){n&&this.emit("update",this);return}const s=this._data;if(this._data=e,this._dataInt32=null,!s||s.length!==e.length){!this.shrinkToFit&&s&&e.byteLength<s.byteLength?n&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=ce("resource"),this.emit("change",this));return}n&&this.emit("update",this)}update(e){this._updateSize=e??this._updateSize,this._updateID++,this.emit("update",this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}class As{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!Pc())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(e){const t=this.getUniformGroupData(e);e.buffer||(e.buffer=new Ue({data:new Float32Array(t.layout.size/4),usage:Q.UNIFORM|Q.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){const t=e._signature;let n=this._syncFunctionHash[t];if(!n){const s=Object.keys(e.uniformStructures).map(a=>e.uniformStructures[a]),i=this._adaptor.createUboElements(s),o=this._generateUboSync(i.uboElements);n=this._syncFunctionHash[t]={layout:i,syncFunction:o}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,n){const s=this.getUniformGroupData(e);e.buffer||(e.buffer=new Ue({data:new Float32Array(s.layout.size/4),usage:Q.UNIFORM|Q.COPY_DST}));let i=null;return t||(t=e.buffer.data,i=e.buffer.dataInt32),n||(n=0),s.syncFunction(e.uniforms,t,i,n),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;const t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}const ks={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function qx(r){const e=r.map(i=>({data:i,offset:0,size:0})),t=16;let n=0,s=0;for(let i=0;i<e.length;i++){const o=e[i];if(n=ks[o.data.type],!n)throw new Error(`Unknown type ${o.data.type}`);o.data.size>1&&(n=Math.max(n,t)*o.data.size);const a=n===12?16:n;o.size=n;const c=s%t;c>0&&t-c<a?s+=(t-c)%16:s+=(n-c%n)%n,o.offset=s,s+=n}return s=Math.ceil(s/16)*16,{uboElements:e,size:s}}const et=[{type:"mat3x3<f32>",test:r=>r.value.a!==void 0,ubo:`
65
+ var matrix = uv[name].toArray(true);
66
+ data[offset] = matrix[0];
67
+ data[offset + 1] = matrix[1];
68
+ data[offset + 2] = matrix[2];
69
+ data[offset + 4] = matrix[3];
70
+ data[offset + 5] = matrix[4];
71
+ data[offset + 6] = matrix[5];
72
+ data[offset + 8] = matrix[6];
73
+ data[offset + 9] = matrix[7];
74
+ data[offset + 10] = matrix[8];
75
+ `,uniform:`
76
+ gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
77
+ `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.width!==void 0,ubo:`
78
+ v = uv[name];
79
+ data[offset] = v.x;
80
+ data[offset + 1] = v.y;
81
+ data[offset + 2] = v.width;
82
+ data[offset + 3] = v.height;
83
+ `,uniform:`
84
+ cv = ud[name].value;
85
+ v = uv[name];
86
+ if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
87
+ cv[0] = v.x;
88
+ cv[1] = v.y;
89
+ cv[2] = v.width;
90
+ cv[3] = v.height;
91
+ gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
92
+ }
93
+ `},{type:"vec2<f32>",test:r=>r.type==="vec2<f32>"&&r.size===1&&r.value.x!==void 0,ubo:`
94
+ v = uv[name];
95
+ data[offset] = v.x;
96
+ data[offset + 1] = v.y;
97
+ `,uniform:`
98
+ cv = ud[name].value;
99
+ v = uv[name];
100
+ if (cv[0] !== v.x || cv[1] !== v.y) {
101
+ cv[0] = v.x;
102
+ cv[1] = v.y;
103
+ gl.uniform2f(ud[name].location, v.x, v.y);
104
+ }
105
+ `},{type:"vec4<f32>",test:r=>r.type==="vec4<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
106
+ v = uv[name];
107
+ data[offset] = v.red;
108
+ data[offset + 1] = v.green;
109
+ data[offset + 2] = v.blue;
110
+ data[offset + 3] = v.alpha;
111
+ `,uniform:`
112
+ cv = ud[name].value;
113
+ v = uv[name];
114
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
115
+ cv[0] = v.red;
116
+ cv[1] = v.green;
117
+ cv[2] = v.blue;
118
+ cv[3] = v.alpha;
119
+ gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
120
+ }
121
+ `},{type:"vec3<f32>",test:r=>r.type==="vec3<f32>"&&r.size===1&&r.value.red!==void 0,ubo:`
122
+ v = uv[name];
123
+ data[offset] = v.red;
124
+ data[offset + 1] = v.green;
125
+ data[offset + 2] = v.blue;
126
+ `,uniform:`
127
+ cv = ud[name].value;
128
+ v = uv[name];
129
+ if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
130
+ cv[0] = v.red;
131
+ cv[1] = v.green;
132
+ cv[2] = v.blue;
133
+ gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
134
+ }
135
+ `}];function Mc(r,e,t,n){const s=[`
136
+ var v = null;
137
+ var v2 = null;
138
+ var t = 0;
139
+ var index = 0;
140
+ var name = null;
141
+ var arrayOffset = null;
142
+ `];let i=0;for(let a=0;a<r.length;a++){const c=r[a],l=c.data.name;let u=!1,h=0;for(let d=0;d<et.length;d++)if(et[d].test(c.data)){h=c.offset/4,s.push(`name = "${l}";`,`offset += ${h-i};`,et[d][e]||et[d].ubo),u=!0;break}if(!u)if(c.data.size>1)h=c.offset/4,s.push(t(c,h-i));else{const d=n[c.data.type];h=c.offset/4,s.push(`
143
+ v = uv.${l};
144
+ offset += ${h-i};
145
+ ${d};
146
+ `)}i=h}const o=s.join(`
147
+ `);return new Function("uv","data","dataInt32","offset",o)}function Xt(r,e){return`
148
+ for (let i = 0; i < ${r*e}; i++) {
149
+ data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i];
150
+ }
151
+ `}const Ac={f32:`
152
+ data[offset] = v;`,i32:`
153
+ dataInt32[offset] = v;`,"vec2<f32>":`
154
+ data[offset] = v[0];
155
+ data[offset + 1] = v[1];`,"vec3<f32>":`
156
+ data[offset] = v[0];
157
+ data[offset + 1] = v[1];
158
+ data[offset + 2] = v[2];`,"vec4<f32>":`
159
+ data[offset] = v[0];
160
+ data[offset + 1] = v[1];
161
+ data[offset + 2] = v[2];
162
+ data[offset + 3] = v[3];`,"vec2<i32>":`
163
+ dataInt32[offset] = v[0];
164
+ dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
165
+ dataInt32[offset] = v[0];
166
+ dataInt32[offset + 1] = v[1];
167
+ dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
168
+ dataInt32[offset] = v[0];
169
+ dataInt32[offset + 1] = v[1];
170
+ dataInt32[offset + 2] = v[2];
171
+ dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
172
+ data[offset] = v[0];
173
+ data[offset + 1] = v[1];
174
+ data[offset + 4] = v[2];
175
+ data[offset + 5] = v[3];`,"mat3x3<f32>":`
176
+ data[offset] = v[0];
177
+ data[offset + 1] = v[1];
178
+ data[offset + 2] = v[2];
179
+ data[offset + 4] = v[3];
180
+ data[offset + 5] = v[4];
181
+ data[offset + 6] = v[5];
182
+ data[offset + 8] = v[6];
183
+ data[offset + 9] = v[7];
184
+ data[offset + 10] = v[8];`,"mat4x4<f32>":`
185
+ for (let i = 0; i < 16; i++) {
186
+ data[offset + i] = v[i];
187
+ }`,"mat3x2<f32>":Xt(3,2),"mat4x2<f32>":Xt(4,2),"mat2x3<f32>":Xt(2,3),"mat4x3<f32>":Xt(4,3),"mat2x4<f32>":Xt(2,4),"mat3x4<f32>":Xt(3,4)},Jx={...Ac,"mat2x2<f32>":`
188
+ data[offset] = v[0];
189
+ data[offset + 1] = v[1];
190
+ data[offset + 2] = v[2];
191
+ data[offset + 3] = v[3];
192
+ `};function Qx(r,e){const t=Math.max(ks[r.data.type]/16,1),n=r.data.value.length/r.data.size,s=(4-n%4)%4,i=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
193
+ v = uv.${r.data.name};
194
+ offset += ${e};
195
+
196
+ arrayOffset = offset;
197
+
198
+ t = 0;
199
+
200
+ for(var i=0; i < ${r.data.size*t}; i++)
201
+ {
202
+ for(var j = 0; j < ${n}; j++)
203
+ {
204
+ ${i}[arrayOffset++] = v[t++];
205
+ }
206
+ ${s!==0?`arrayOffset += ${s};`:""}
207
+ }
208
+ `}function ev(r){return Mc(r,"uboStd40",Qx,Ac)}class Rs extends As{constructor(){super({createUboElements:qx,generateUboSync:ev})}}Rs.extension={type:[x.WebGLSystem],name:"ubo"};class Tn extends Qe{constructor({buffer:e,offset:t,size:n}){super(),this.uid=ce("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=ce("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=n,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=ce("resource"),this.emit("change",this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}const Is=Object.create(null),kc=Object.create(null);function Mr(r,e){let t=kc[r];return t===void 0&&(Is[e]===void 0&&(Is[e]=1),kc[r]=t=Is[e]++),t}const Rc=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],tv=Rc.reduce((r,e)=>(r[e]=!0,r),{});function rv(r,e){switch(r){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Ic=class rf{constructor(e,t){this._touched=0,this.uid=ce("uniform"),this._resourceType="uniformGroup",this._resourceId=ce("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...rf.defaultOptions,...t},this.uniformStructures=e;const n={};for(const s in e){const i=e[s];if(i.name=s,i.size=i.size??1,!tv[i.type]){const o=i.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,c]=o;throw new Error(`Uniform type ${i.type} is not supported. Use type: '${a}', size: ${c} instead.`)}throw new Error(`Uniform type ${i.type} is not supported. Supported uniform types are: ${Rc.join(", ")}`)}i.value??(i.value=rv(i.type,i.size)),n[s]=i.value}this.uniforms=n,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=Mr(Object.keys(n).map(s=>`${s}-${e[s].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ic.defaultOptions={ubo:!1,isStatic:!1};let je=Ic;function Sn(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Bc(r){return!(r&r-1)&&!!r}function wn(r){const e={};for(const t in r)r[t]!==void 0&&(e[t]=r[t]);return e}const Fc=new Set,de="8.0.0",nv="8.3.4",Yt={quiet:!1,noColor:!1},N=((r,e,t=3)=>{if(Yt.quiet||Fc.has(e))return;let n=new Error().stack;const s=`${e}
209
+ Deprecated since v${r}`,i=typeof console.groupCollapsed=="function"&&!Yt.noColor;typeof n>"u"?console.warn("PixiJS Deprecation Warning: ",s):(n=n.split(`
210
+ `).splice(t).join(`
211
+ `),i?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",s),console.warn(n),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",s),console.warn(n))),Fc.add(e)});Object.defineProperties(N,{quiet:{get:()=>Yt.quiet,set:r=>{Yt.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Yt.noColor,set:r=>{Yt.noColor=r},enumerable:!0,configurable:!1}});const Gc=Object.create(null);function sv(r){const e=Gc[r];return e===void 0&&(Gc[r]=ce("resource")),e}const Oc=class nf extends Qe{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...nf.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){N(de,"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(){const e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=sv(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Oc.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Bs=Oc;const Dc=class sf extends Qe{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ce("textureSource"),this._resourceType="textureSource",this._resourceId=ce("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.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,e={...sf.defaultOptions,...e},this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=e.dimensions,this.viewDimension=e.viewDimension??e.dimensions,this.arrayLayerCount=e.arrayLayerCount,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=e.antialias,this.alphaMode=e.alphaMode,this.style=new Bs(wn(e)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){var t,n;this.style!==e&&((t=this._style)==null||t.off("change",this._onStyleChange,this),this._style=e,(n=this._style)==null||n.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){const 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._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var e,t;this._resourceId=ce("resource"),this.emit("change",this),this.emit("unload",this);for(const n in this._gpuData)(t=(e=this._gpuData[n])==null?void 0:e.destroy)==null||t.call(e);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{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||(n=this._resolution),e||(e=this.width),t||(t=this.height);const s=Math.round(e*n),i=Math.round(t*n);return this.width=s/n,this.height=i/n,this._resolution=n,this.pixelWidth===s&&this.pixelHeight===i?!1:(this._refreshPOT(),this.pixelWidth=s,this.pixelHeight=i,this.emit("resize",this),this._resourceId=ce("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=Bc(this.pixelWidth)&&Bc(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};Dc.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};let ve=Dc;function iv(r,e){const t=[],n=[`
212
+ var g = s.groups;
213
+ var sS = r.shader;
214
+ var p = s.glProgram;
215
+ var ugS = r.uniformGroup;
216
+ var resources;
217
+ `];let s=!1,i=0;const o=e._getProgramData(r.glProgram);for(const c in r.groups){const l=r.groups[c];t.push(`
218
+ resources = g[${c}].resources;
219
+ `);for(const u in l.resources){const h=l.resources[u];if(h instanceof je)if(h.ubo){const d=r._uniformBindMap[c][Number(u)];t.push(`
220
+ sS.bindUniformBlock(
221
+ resources[${u}],
222
+ '${d}',
223
+ ${r.glProgram._uniformBlockData[d].index}
224
+ );
225
+ `)}else t.push(`
226
+ ugS.updateUniformGroup(resources[${u}], p, sD);
227
+ `);else if(h instanceof Tn){const d=r._uniformBindMap[c][Number(u)];t.push(`
228
+ sS.bindUniformBlock(
229
+ resources[${u}],
230
+ '${d}',
231
+ ${r.glProgram._uniformBlockData[d].index}
232
+ );
233
+ `)}else if(h instanceof ve){const d=r._uniformBindMap[c][u],f=o.uniformData[d];f&&(s||(s=!0,n.push(`
234
+ var tS = r.texture;
235
+ `)),e._gl.uniform1i(f.location,i),t.push(`
236
+ tS.bind(resources[${u}], ${i});
237
+ `),i++)}}}const a=[...n,...t].join(`
238
+ `);return new Function("r","s","sD",a)}let Fs=0;const Uc=500;function W(...r){Fs!==Uc&&(Fs++,Fs===Uc?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...r))}class ov{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function Lc(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}function Gs(r){const e=new Array(r);for(let t=0;t<e.length;t++)e[t]=!1;return e}function zc(r,e){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Gs(2*e);case"bvec3":return Gs(3*e);case"bvec4":return Gs(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Nc={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function pt(r){return Nc[r]??Nc.float32}let Pn=null;const $c={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},av={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function Vc(r,e){if(!Pn){const t=Object.keys($c);Pn={};for(let n=0;n<t.length;++n){const s=t[n];Pn[r[s]]=$c[s]}}return Pn[e]}function cv(r,e){const t=Vc(r,e);return av[t]||"float32"}function lv(r,e,t=!1){const n={},s=e.getProgramParameter(r,e.ACTIVE_ATTRIBUTES);for(let o=0;o<s;o++){const a=e.getActiveAttrib(r,o);if(a.name.startsWith("gl_"))continue;const c=cv(e,a.type);n[a.name]={location:0,format:c,stride:pt(c).stride,offset:0,instance:!1,start:0}}const i=Object.keys(n);if(t){i.sort((o,a)=>o>a?1:-1);for(let o=0;o<i.length;o++)n[i[o]].location=o,e.bindAttribLocation(r,o,i[o]);e.linkProgram(r)}else for(let o=0;o<i.length;o++)n[i[o]].location=e.getAttribLocation(r,i[o]);return n}function uv(r,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const t={},n=e.getProgramParameter(r,e.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<n;s++){const i=e.getActiveUniformBlockName(r,s),o=e.getUniformBlockIndex(r,i),a=e.getActiveUniformBlockParameter(r,s,e.UNIFORM_BLOCK_DATA_SIZE);t[i]={name:i,index:o,size:a}}return t}function hv(r,e){const t={},n=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let s=0;s<n;s++){const i=e.getActiveUniform(r,s),o=i.name.replace(/\[.*?\]$/,""),a=!!i.name.match(/\[.*?\]$/),c=Vc(e,i.type);t[o]={name:o,index:s,type:c,size:i.size,isArray:a,value:zc(c,i.size)}}return t}function Hc(r,e){const t=r.getShaderSource(e).split(`
239
+ `).map((l,u)=>`${u}: ${l}`),n=r.getShaderInfoLog(e),s=n.split(`
240
+ `),i={},o=s.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!i[l]?(i[l]=!0,!0):!1),a=[""];o.forEach(l=>{t[l-1]=`%c${t[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const c=t.join(`
241
+ `);a[0]=c,console.error(n),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function dv(r,e,t,n){r.getProgramParameter(e,r.LINK_STATUS)||(r.getShaderParameter(t,r.COMPILE_STATUS)||Hc(r,t),r.getShaderParameter(n,r.COMPILE_STATUS)||Hc(r,n),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(e)))}function fv(r,e){const t=Lc(r,r.VERTEX_SHADER,e.vertex),n=Lc(r,r.FRAGMENT_SHADER,e.fragment),s=r.createProgram();r.attachShader(s,t),r.attachShader(s,n);const i=e.transformFeedbackVaryings;i&&(typeof r.transformFeedbackVaryings!="function"?W("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,i.names,i.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||dv(r,s,t,n),e._attributeData=lv(s,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=hv(s,r),e._uniformBlockData=uv(s,r),r.deleteShader(t),r.deleteShader(n);const o={};for(const c in e._uniformData){const l=e._uniformData[c];o[c]={location:r.getUniformLocation(s,c),value:zc(l.type,l.size)}}return new ov(s,o)}const En={textureCount:0,blockIndex:0};class Os{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(e,t){if(this._setProgram(e.glProgram),t)return;En.textureCount=0,En.blockIndex=0;let n=this._shaderSyncFunctions[e.glProgram._key];n||(n=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this)),this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),n(this._renderer,e,En)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,En)}bindUniformBlock(e,t,n=0){const s=this._renderer.buffer,i=this._getProgramData(this._activeProgram),o=e._bufferResource;o||this._renderer.ubo.updateUniformGroup(e);const a=e.buffer,c=s.updateBuffer(a),l=s.freeLocationForBufferBase(c);if(o){const{offset:h,size:d}=e;h===0&&d===a.data.byteLength?s.bindBufferBase(c,l):s.bindBufferRange(c,l,h)}else s.getLastBindBaseLocation(c)!==l&&s.bindBufferBase(c,l);const u=this._activeProgram._uniformBlockData[t].index;i.uniformBlockBindings[n]!==l&&(i.uniformBlockBindings[n]=l,this._renderer.gl.uniformBlockBinding(i.program,u,l))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;const t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){const t=e._key;return this._programDataHash[t]=fv(this._gl,e),this._programDataHash[t]}destroy(){for(const e of Object.keys(this._programDataHash))this._programDataHash[e].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(e,t){return iv(e,t)}resetState(){this._activeProgram=null}}Os.extension={type:[x.WebGLSystem],name:"shader"};const pv={f32:`if (cv !== v) {
242
+ cu.value = v;
243
+ gl.uniform1f(location, v);
244
+ }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
245
+ cv[0] = v[0];
246
+ cv[1] = v[1];
247
+ gl.uniform2f(location, v[0], v[1]);
248
+ }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
249
+ cv[0] = v[0];
250
+ cv[1] = v[1];
251
+ cv[2] = v[2];
252
+ gl.uniform3f(location, v[0], v[1], v[2]);
253
+ }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
254
+ cv[0] = v[0];
255
+ cv[1] = v[1];
256
+ cv[2] = v[2];
257
+ cv[3] = v[3];
258
+ gl.uniform4f(location, v[0], v[1], v[2], v[3]);
259
+ }`,i32:`if (cv !== v) {
260
+ cu.value = v;
261
+ gl.uniform1i(location, v);
262
+ }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
263
+ cv[0] = v[0];
264
+ cv[1] = v[1];
265
+ gl.uniform2i(location, v[0], v[1]);
266
+ }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
267
+ cv[0] = v[0];
268
+ cv[1] = v[1];
269
+ cv[2] = v[2];
270
+ gl.uniform3i(location, v[0], v[1], v[2]);
271
+ }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
272
+ cv[0] = v[0];
273
+ cv[1] = v[1];
274
+ cv[2] = v[2];
275
+ cv[3] = v[3];
276
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
277
+ }`,u32:`if (cv !== v) {
278
+ cu.value = v;
279
+ gl.uniform1ui(location, v);
280
+ }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
281
+ cv[0] = v[0];
282
+ cv[1] = v[1];
283
+ gl.uniform2ui(location, v[0], v[1]);
284
+ }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
285
+ cv[0] = v[0];
286
+ cv[1] = v[1];
287
+ cv[2] = v[2];
288
+ gl.uniform3ui(location, v[0], v[1], v[2]);
289
+ }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
290
+ cv[0] = v[0];
291
+ cv[1] = v[1];
292
+ cv[2] = v[2];
293
+ cv[3] = v[3];
294
+ gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
295
+ }`,bool:`if (cv !== v) {
296
+ cu.value = v;
297
+ gl.uniform1i(location, v);
298
+ }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
299
+ cv[0] = v[0];
300
+ cv[1] = v[1];
301
+ gl.uniform2i(location, v[0], v[1]);
302
+ }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
303
+ cv[0] = v[0];
304
+ cv[1] = v[1];
305
+ cv[2] = v[2];
306
+ gl.uniform3i(location, v[0], v[1], v[2]);
307
+ }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
308
+ cv[0] = v[0];
309
+ cv[1] = v[1];
310
+ cv[2] = v[2];
311
+ cv[3] = v[3];
312
+ gl.uniform4i(location, v[0], v[1], v[2], v[3]);
313
+ }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},mv={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};function gv(r,e){const t=[`
314
+ var v = null;
315
+ var cv = null;
316
+ var cu = null;
317
+ var t = 0;
318
+ var gl = renderer.gl;
319
+ var name = null;
320
+ `];for(const n in r.uniforms){if(!e[n]){r.uniforms[n]instanceof je?r.uniforms[n].ubo?t.push(`
321
+ renderer.shader.bindUniformBlock(uv.${n}, "${n}");
322
+ `):t.push(`
323
+ renderer.shader.updateUniformGroup(uv.${n});
324
+ `):r.uniforms[n]instanceof Tn&&t.push(`
325
+ renderer.shader.bindBufferResource(uv.${n}, "${n}");
326
+ `);continue}const s=r.uniformStructures[n];let i=!1;for(let o=0;o<et.length;o++){const a=et[o];if(s.type===a.type&&a.test(s)){t.push(`name = "${n}";`,et[o].uniform),i=!0;break}}if(!i){const a=(s.size===1?pv:mv)[s.type].replace("location",`ud["${n}"].location`);t.push(`
327
+ cu = ud["${n}"];
328
+ cv = cu.value;
329
+ v = uv["${n}"];
330
+ ${a};`)}}return new Function("ud","uv","renderer","syncData",t.join(`
331
+ `))}class Ds{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,n){const s=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==s.uniformDirtyGroups[e.uid])&&(s.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(s.uniformData,e.uniforms,this._renderer,n))}_getUniformSyncFunction(e,t){var n;return((n=this._uniformGroupSyncHash[e._signature])==null?void 0:n[t._key])||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){const n=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),s=this._getSignature(e,t._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(e,t._uniformData)),n[t._key]=this._cache[s],n[t._key]}_generateUniformsSync(e,t){return gv(e,t)}_getSignature(e,t,n){const s=e.uniforms,i=[`${n}-`];for(const o in s)i.push(o),t[o]&&i.push(t[o].type);return i.join("-")}destroy(){this._renderer=null,this._cache=null}}Ds.extension={type:[x.WebGLSystem],name:"uniformGroup"};const Ar={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function _v(r){const e=r.map(n=>({data:n,offset:0,size:0}));let t=0;for(let n=0;n<e.length;n++){const s=e[n];let i=Ar[s.data.type].size;const o=Ar[s.data.type].align;if(!Ar[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,o)*s.data.size),t=Math.ceil(t/o)*o,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function yv(r,e){const{size:t,align:n}=Ar[r.data.type],s=(n-t)/4,i=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
332
+ v = uv.${r.data.name};
333
+ ${e!==0?`offset += ${e};`:""}
334
+
335
+ arrayOffset = offset;
336
+
337
+ t = 0;
338
+
339
+ for(var i=0; i < ${r.data.size*(t/4)}; i++)
340
+ {
341
+ for(var j = 0; j < ${t/4}; j++)
342
+ {
343
+ ${i}[arrayOffset++] = v[t++];
344
+ }
345
+ ${s!==0?`arrayOffset += ${s};`:""}
346
+ }
347
+ `}function bv(r){return Mc(r,"uboWgsl",yv,Jx)}class Us extends As{constructor(){super({createUboElements:_v,generateUboSync:bv})}}Us.extension={type:[x.WebGPUSystem],name:"ubo"};var xv={grad:.9,turn:360,rad:360/(2*Math.PI)},mt=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Te=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*r)/t+0},We=function(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),r>t?t:r>e?r:e},jc=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Wc=function(r){return{r:We(r.r,0,255),g:We(r.g,0,255),b:We(r.b,0,255),a:We(r.a)}},Ls=function(r){return{r:Te(r.r),g:Te(r.g),b:Te(r.b),a:Te(r.a,3)}},vv=/^#([0-9a-f]{3,8})$/i,Cn=function(r){var e=r.toString(16);return e.length<2?"0"+e:e},Xc=function(r){var e=r.r,t=r.g,n=r.b,s=r.a,i=Math.max(e,t,n),o=i-Math.min(e,t,n),a=o?i===e?(t-n)/o:i===t?2+(n-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:i?o/i*100:0,v:i/255*100,a:s}},Yc=function(r){var e=r.h,t=r.s,n=r.v,s=r.a;e=e/360*6,t/=100,n/=100;var i=Math.floor(e),o=n*(1-t),a=n*(1-(e-i)*t),c=n*(1-(1-e+i)*t),l=i%6;return{r:255*[n,a,o,o,c,n][l],g:255*[c,n,n,a,o,o][l],b:255*[o,o,c,n,n,a][l],a:s}},Zc=function(r){return{h:jc(r.h),s:We(r.s,0,100),l:We(r.l,0,100),a:We(r.a)}},Kc=function(r){return{h:Te(r.h),s:Te(r.s),l:Te(r.l),a:Te(r.a,3)}},qc=function(r){return Yc((t=(e=r).s,{h:e.h,s:(t*=((n=e.l)<50?n:100-n)/100)>0?2*t/(n+t)*100:0,v:n+t,a:e.a}));var e,t,n},kr=function(r){return{h:(e=Xc(r)).h,s:(s=(200-(t=e.s))*(n=e.v)/100)>0&&s<200?t*n/100/(s<=100?s:200-s)*100:0,l:s/2,a:e.a};var e,t,n,s},Tv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Sv=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pv=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,zs={string:[[function(r){var e=vv.exec(r);return e?(r=e[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Te(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Te(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var e=wv.exec(r)||Pv.exec(r);return e?e[2]!==e[4]||e[4]!==e[6]?null:Wc({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(r){var e=Tv.exec(r)||Sv.exec(r);if(!e)return null;var t,n,s=Zc({h:(t=e[1],n=e[2],n===void 0&&(n="deg"),Number(t)*(xv[n]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return qc(s)},"hsl"]],object:[[function(r){var e=r.r,t=r.g,n=r.b,s=r.a,i=s===void 0?1:s;return mt(e)&&mt(t)&&mt(n)?Wc({r:Number(e),g:Number(t),b:Number(n),a:Number(i)}):null},"rgb"],[function(r){var e=r.h,t=r.s,n=r.l,s=r.a,i=s===void 0?1:s;if(!mt(e)||!mt(t)||!mt(n))return null;var o=Zc({h:Number(e),s:Number(t),l:Number(n),a:Number(i)});return qc(o)},"hsl"],[function(r){var e=r.h,t=r.s,n=r.v,s=r.a,i=s===void 0?1:s;if(!mt(e)||!mt(t)||!mt(n))return null;var o=(function(a){return{h:jc(a.h),s:We(a.s,0,100),v:We(a.v,0,100),a:We(a.a)}})({h:Number(e),s:Number(t),v:Number(n),a:Number(i)});return Yc(o)},"hsv"]]},Jc=function(r,e){for(var t=0;t<e.length;t++){var n=e[t][0](r);if(n)return[n,e[t][1]]}return[null,void 0]},Ev=function(r){return typeof r=="string"?Jc(r.trim(),zs.string):typeof r=="object"&&r!==null?Jc(r,zs.object):[null,void 0]},Ns=function(r,e){var t=kr(r);return{h:t.h,s:We(t.s+100*e,0,100),l:t.l,a:t.a}},$s=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},Qc=function(r,e){var t=kr(r);return{h:t.h,s:t.s,l:We(t.l+100*e,0,100),a:t.a}},Vs=(function(){function r(e){this.parsed=Ev(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Te($s(this.rgba),2)},r.prototype.isDark=function(){return $s(this.rgba)<.5},r.prototype.isLight=function(){return $s(this.rgba)>=.5},r.prototype.toHex=function(){return e=Ls(this.rgba),t=e.r,n=e.g,s=e.b,o=(i=e.a)<1?Cn(Te(255*i)):"","#"+Cn(t)+Cn(n)+Cn(s)+o;var e,t,n,s,i,o},r.prototype.toRgb=function(){return Ls(this.rgba)},r.prototype.toRgbString=function(){return e=Ls(this.rgba),t=e.r,n=e.g,s=e.b,(i=e.a)<1?"rgba("+t+", "+n+", "+s+", "+i+")":"rgb("+t+", "+n+", "+s+")";var e,t,n,s,i},r.prototype.toHsl=function(){return Kc(kr(this.rgba))},r.prototype.toHslString=function(){return e=Kc(kr(this.rgba)),t=e.h,n=e.s,s=e.l,(i=e.a)<1?"hsla("+t+", "+n+"%, "+s+"%, "+i+")":"hsl("+t+", "+n+"%, "+s+"%)";var e,t,n,s,i},r.prototype.toHsv=function(){return e=Xc(this.rgba),{h:Te(e.h),s:Te(e.s),v:Te(e.v),a:Te(e.a,3)};var e},r.prototype.invert=function(){return it({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},r.prototype.saturate=function(e){return e===void 0&&(e=.1),it(Ns(this.rgba,e))},r.prototype.desaturate=function(e){return e===void 0&&(e=.1),it(Ns(this.rgba,-e))},r.prototype.grayscale=function(){return it(Ns(this.rgba,-1))},r.prototype.lighten=function(e){return e===void 0&&(e=.1),it(Qc(this.rgba,e))},r.prototype.darken=function(e){return e===void 0&&(e=.1),it(Qc(this.rgba,-e))},r.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},r.prototype.alpha=function(e){return typeof e=="number"?it({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Te(this.rgba.a,3);var t},r.prototype.hue=function(e){var t=kr(this.rgba);return typeof e=="number"?it({h:e,s:t.s,l:t.l,a:t.a}):Te(t.h)},r.prototype.isEqual=function(e){return this.toHex()===it(e).toHex()},r})(),it=function(r){return r instanceof Vs?r:new Vs(r)},el=[],Cv=function(r){r.forEach(function(e){el.indexOf(e)<0&&(e(Vs,zs),el.push(e))})};function Mv(r,e){var t={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"},n={};for(var s in t)n[t[s]]=s;var i={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,c,l=n[this.toHex()];if(l)return l;if(o!=null&&o.closest){var u=this.toRgb(),h=1/0,d="black";if(!i.length)for(var f in t)i[f]=new r(t[f]).toRgb();for(var p in t){var m=(a=u,c=i[p],Math.pow(a.r-c.r,2)+Math.pow(a.g-c.g,2)+Math.pow(a.b-c.b,2));m<h&&(h=m,d=p)}return d}},e.string.push([function(o){var a=o.toLowerCase(),c=a==="transparent"?"#0000":t[a];return c?new r(c).toRgb():null},"name"])}Cv([Mv]);const Zt=class Jr{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(e){if(e instanceof Jr)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),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!==null?{...e}:e}_isSourceEqual(e,t){const 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?!1:e.every((i,o)=>i===t[o]);if(e!==null&&t!==null){const i=Object.keys(e),o=Object.keys(t);return i.length!==o.length?!1:i.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,n,s]=this._components;return{r:e,g:t,b:n,a:s}}toRgb(){const[e,t,n]=this._components;return{r:e,g:t,b:n}}toRgbaString(){const[e,t,n]=this.toUint8RgbArray();return`rgba(${e},${t},${n},${this.alpha})`}toUint8RgbArray(e){const[t,n,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(n*255),e[2]=Math.round(s*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[t,n,s,i]=this._components;return e[0]=t,e[1]=n,e[2]=s,e[3]=i,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[t,n,s]=this._components;return e[0]=t,e[1]=n,e[2]=s,e}toNumber(){return this._int}toBgrNumber(){const[e,t,n]=this.toUint8RgbArray();return(n<<16)+(t<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,n,s,i]=Jr._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=n,this._components[2]*=s,this._components[3]*=i,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,s=this._int>>8&255,i=this._int&255;return t&&(n=n*e+.5|0,s=s*e+.5|0,i=i*e+.5|0),(e*255<<24)+(n<<16)+(s<<8)+i}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(e){let t,n,s,i;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,n=(o>>8&255)/255,s=(o&255)/255,i=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,n,s,i=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,n,s,i=255]=e,t/=255,n/=255,s/=255,i/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=Jr.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=it(e);o.isValid()&&({r:t,g:n,b:s,a:i}=o.rgba,t/=255,n/=255,s/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=n,this._components[2]=s,this._components[3]=i,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[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((s,i)=>{e[i]=Math.min(Math.max(s,t),n)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof Jr||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};Zt.shared=new Zt,Zt._temp=new Zt,Zt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ye=Zt;const Hs=[];H.handleByNamedList(x.Environment,Hs);async function Av(r){if(!r)for(let e=0;e<Hs.length;e++){const t=Hs[e];if(t.value.test()){await t.value.load();return}}}const kv={cullArea:null,cullable:!1,cullableChildren:!0},Rv=Math.PI*2,Iv=180/Math.PI,Bv=Math.PI/180;class le{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new le(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 js.x=0,js.y=0,js}}const js=new le;class B{constructor(e=1,t=0,n=0,s=1,i=0,o=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=s,this.tx=i,this.ty=o}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,s,i,o){return this.a=e,this.b=t,this.c=n,this.d=s,this.tx=i,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const 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=t||new le;const n=e.x,s=e.y;return t.x=this.a*n+this.c*s+this.tx,t.y=this.b*n+this.d*s+this.ty,t}applyInverse(e,t){t=t||new le;const n=this.a,s=this.b,i=this.c,o=this.d,a=this.tx,c=this.ty,l=1/(n*o+i*-s),u=e.x,h=e.y;return t.x=o*l*u+-i*l*h+(c*i-a*o)*l,t.y=n*l*h+-s*l*u+(-c*n+a*s)*l,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){const t=Math.cos(e),n=Math.sin(e),s=this.a,i=this.c,o=this.tx;return this.a=s*t-this.b*n,this.b=s*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=o*t-this.ty*n,this.ty=o*n+this.ty*t,this}append(e){const t=this.a,n=this.b,s=this.c,i=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*s,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){const n=e.a,s=e.b,i=e.c,o=e.d,a=e.tx,c=e.ty,l=t.a,u=t.b,h=t.c,d=t.d;return this.a=n*l+s*h,this.b=n*u+s*d,this.c=i*l+o*h,this.d=i*u+o*d,this.tx=a*l+c*h+t.tx,this.ty=a*u+c*d+t.ty,this}setTransform(e,t,n,s,i,o,a,c,l){return this.a=Math.cos(a+l)*i,this.b=Math.sin(a+l)*i,this.c=-Math.sin(a-c)*o,this.d=Math.cos(a-c)*o,this.tx=e-(n*this.a+s*this.c),this.ty=t-(n*this.b+s*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const n=this.a,s=this.c;this.a=n*e.a+this.b*e.c,this.b=n*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*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){const t=this.a,n=this.b,s=this.c,i=this.d,o=e.pivot,a=-Math.atan2(-s,i),c=Math.atan2(n,t),l=Math.abs(a+c);return l<1e-5||Math.abs(Rv-l)<1e-5?(e.rotation=c,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=a,e.skew.y=c),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(s*s+i*i),e.position.x=this.tx+(o.x*t+o.y*s),e.position.y=this.ty+(o.x*n+o.y*i),e}invert(){const e=this.a,t=this.b,n=this.c,s=this.d,i=this.tx,o=e*s-t*n;return this.a=s/o,this.b=-t/o,this.c=-n/o,this.d=e/o,this.tx=(n*this.ty-s*i)/o,this.ty=-(e*this.ty-t*i)/o,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(){const e=new B;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}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 Gv.identity()}static get shared(){return Fv.identity()}}const Fv=new B,Gv=new B;class Ce{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(e){return new Ce(e??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))}}const Kt={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class Ov{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){var n;let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),(n=t.init)==null||n.call(t,e),t}return(e){var t;(t=e.reset)==null||t.call(e),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}}class Dv{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 Ov(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(t=>{const 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()}}const Se=new Dv;Kt.register(Se);const Uv={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){N("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(r)}};function tl(r,e,t){const n=r.length;let s;if(e>=n||t===0)return;t=e+t>n?n-e:t;const i=n-t;for(s=e;s<i;++s)r[s]=r[s+t];r.length=i}const Lv={allowChildren:!0,removeChildren(r=0,e){var i;const t=e??this.children.length,n=t-r,s=[];if(n>0&&n<=t){for(let a=t-1;a>=r;a--){const c=this.children[a];c&&(s.push(c),c.parent=null)}tl(this.children,r,t);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(s);for(let a=0;a<s.length;++a){const c=s[a];(i=c.parentRenderLayer)==null||i.detach(c),this.emit("childRemoved",c,this,a),s[a].emit("removed",this)}return s.length>0&&this._didViewChangeTick++,s}else if(n===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const e=this.getChildAt(r);return this.removeChild(e)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,e)},getChildIndex(r){const e=this.children.indexOf(r);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(r,e){this.allowChildren||N(de,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:t}=this;if(e<0||e>t.length)throw new Error(`${r}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);const n=r.parent===this;if(r.parent){const i=r.parent.children.indexOf(r);if(n){if(i===e)return r;r.parent.children.splice(i,1)}else r.removeFromParent()}e===t.length?t.push(r):t.splice(e,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(r),this.sortableChildren&&(this.sortDirty=!0),n||(this.emit("childAdded",r,this,e),r.emit("added",this)),r},swapChildren(r,e){if(r===e)return;const t=this.getChildIndex(r),n=this.getChildIndex(e);this.children[t]=e,this.children[n]=r;const s=this.renderGroup||this.parentRenderGroup;s&&(s.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(e=>this.reparentChildAt(e,this.children.length)),r[0])},reparentChildAt(r,e){if(r.parent===this)return this.setChildIndex(r,e),r;const t=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,e);const n=this.worldTransform.clone();return n.invert(),t.prepend(n),r.setFromMatrix(t),r},replaceChild(r,e){r.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(r)),e.setFromMatrix(r.localTransform),e.updateLocalTransform(),this.removeChild(r)}},zv={collectRenderables(r,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,e,t))},collectRenderablesSimple(r,e,t){const n=this.children,s=n.length;for(let i=0;i<s;i++)n[i].collectRenderables(r,e,t)},collectRenderablesWithEffects(r,e,t){const{renderPipes:n}=e;for(let s=0;s<this.effects.length;s++){const i=this.effects[s];n[i.pipe].push(i,this,r)}this.collectRenderablesSimple(r,e,t);for(let s=this.effects.length-1;s>=0;s--){const i=this.effects[s];n[i.pipe].pop(i,this,r)}}};class Mn{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}}class Nv{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++){const n=this._tests[t];if(n.test(e))return Se.get(n.maskClass,e)}return e}returnMaskEffect(e){Se.return(e)}}const Ws=new Nv;H.handleByList(x.MaskEffect,Ws._effectClasses);const $v={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,n)=>t.priority-n.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const e=this.effects.indexOf(r);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const e=this._maskEffect;(e==null?void 0:e.mask)!==r&&(e&&(this.removeEffect(e),Ws.returnMaskEffect(e),this._maskEffect=null),r!=null&&(this._maskEffect=Ws.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions={...this._maskOptions,...r},r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var i;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new Mn);r=r;const t=(r==null?void 0:r.length)>0,n=((i=e.filters)==null?void 0:i.length)>0,s=t!==n;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),s&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=r??null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new Mn),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},Vv={label:null,get name(){return N(de,"Container.name property has been removed, use Container.label instead"),this.label},set name(r){N(de,"Container.name property has been removed, use Container.label instead"),this.label=r},getChildByName(r,e=!1){return this.getChildByLabel(r,e)},getChildByLabel(r,e=!1){const t=this.children;for(let n=0;n<t.length;n++){const s=t[n];if(s.label===r||r instanceof RegExp&&r.test(s.label))return s}if(e)for(let n=0;n<t.length;n++){const i=t[n].getChildByLabel(r,!0);if(i)return i}return null},getChildrenByLabel(r,e=!1,t=[]){const n=this.children;for(let s=0;s<n.length;s++){const i=n[s];(i.label===r||r instanceof RegExp&&r.test(i.label))&&t.push(i)}if(e)for(let s=0;s<n.length;s++)n[s].getChildrenByLabel(r,!0,t);return t}},An=[new le,new le,new le,new le];class fe{constructor(e=0,t=0,n=0,s=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(n),this.height=Number(s)}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 fe(0,0,0,0)}clone(){return new fe(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,s=.5){const{width:i,height:o}=this;if(i<=0||o<=0)return!1;const a=this.x,c=this.y,l=n*(1-s),u=n-l,h=a-l,d=a+i+l,f=c-l,p=c+o+l,m=a+u,g=a+i-u,_=c+u,y=c+o-u;return e>=h&&e<=d&&t>=f&&t<=p&&!(e>m&&e<g&&t>_&&t<y)}intersects(e,t){if(!t){const U=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=U)return!1;const M=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>M}const n=this.left,s=this.right,i=this.top,o=this.bottom;if(s<=n||o<=i)return!1;const a=An[0].set(e.left,e.top),c=An[1].set(e.left,e.bottom),l=An[2].set(e.right,e.top),u=An[3].set(e.right,e.bottom);if(l.x<=a.x||c.y<=a.y)return!1;const h=Math.sign(t.a*t.d-t.b*t.c);if(h===0||(t.apply(a,a),t.apply(c,c),t.apply(l,l),t.apply(u,u),Math.max(a.x,c.x,l.x,u.x)<=n||Math.min(a.x,c.x,l.x,u.x)>=s||Math.max(a.y,c.y,l.y,u.y)<=i||Math.min(a.y,c.y,l.y,u.y)>=o))return!1;const d=h*(c.y-a.y),f=h*(a.x-c.x),p=d*n+f*i,m=d*s+f*i,g=d*n+f*o,_=d*s+f*o;if(Math.max(p,m,g,_)<=d*a.x+f*a.y||Math.min(p,m,g,_)>=d*u.x+f*u.y)return!1;const y=h*(a.y-l.y),b=h*(l.x-a.x),v=y*n+b*i,C=y*s+b*i,S=y*n+b*o,E=y*s+b*o;return!(Math.max(v,C,S,E)<=y*a.x+b*a.y||Math.min(v,C,S,E)>=y*u.x+b*u.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),s=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=s,this.height=Math.max(i-s,0),this}ceil(e=1,t=.001){const n=Math.ceil((this.x+this.width-t)*e)/e,s=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=s-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){const t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),s=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=s,this.height=i-s,this}getBounds(e){return e||(e=new fe),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const t=e.x,n=e.y,s=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&&s>=this.x&&s<this.x+this.width&&i>=this.y&&i<this.y+this.height}set(e,t,n,s){return this.x=e,this.y=t,this.width=n,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const rl=new B;class Pe{constructor(e=1/0,t=1/0,n=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=rl,this.minX=e,this.minY=t,this.maxX=n,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new fe);const 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=rl,this}set(e,t,n,s){this.minX=e,this.minY=t,this.maxX=n,this.maxY=s}addFrame(e,t,n,s,i){i||(i=this.matrix);const o=i.a,a=i.b,c=i.c,l=i.d,u=i.tx,h=i.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=o*e+c*t+u,_=a*e+l*t+h;g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),g=o*n+c*t+u,_=a*n+l*t+h,g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),g=o*e+c*s+u,_=a*e+l*s+h,g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),g=o*n+c*s+u,_=a*n+l*s+h,g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),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){const t=this.minX,n=this.minY,s=this.maxX,i=this.maxY,{a:o,b:a,c,d:l,tx:u,ty:h}=e;let d=o*t+c*n+u,f=a*t+l*n+h;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=o*s+c*n+u,f=a*s+l*n+h,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=o*t+c*i+u,f=a*t+l*i+h,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=o*s+c*i+u,f=a*s+l*i+h,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,s){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<n&&(this.minY=n),this.maxY>s&&(this.maxY=s),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 Pe(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){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const 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,s){let i=this.minX,o=this.minY,a=this.maxX,c=this.maxY;s||(s=this.matrix);const l=s.a,u=s.b,h=s.c,d=s.d,f=s.tx,p=s.ty;for(let m=t;m<n;m+=2){const g=e[m],_=e[m+1],y=l*g+h*_+f,b=u*g+d*_+p;i=y<i?y:i,o=b<o?b:o,a=y>a?y:a,c=b>c?b:c}this.minX=i,this.minY=o,this.maxX=a,this.maxY=c}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}}const ke=Se.getPool(B),gt=Se.getPool(Pe),Hv=new B,jv={getFastGlobalBounds(r,e){e||(e=new Pe),e.clear(),this._getGlobalBoundsRecursive(!!r,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(r,e,t){let n=e;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;const s=!!this.effects.length;if((this.renderGroup||s)&&(n=gt.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;n.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const i=this.children;for(let o=0;o<i.length;o++)i[o]._getGlobalBoundsRecursive(r,n,t)}if(s){let i=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(i||(i=!0,n.applyMatrix(o.worldTransform)),this.effects[a].addBounds(n,!0));i&&n.applyMatrix(o.worldTransform.copyTo(Hv).invert()),e.addBounds(n),gt.return(n)}else this.renderGroup&&(e.addBounds(n,this.relativeGroupTransform),gt.return(n))}};function Xs(r,e,t){t.clear();let n,s;return r.parent?e?n=r.parent.worldTransform:(s=ke.get().identity(),n=Ys(r,s)):n=B.IDENTITY,nl(r,t,n,e),s&&ke.return(s),t.isValid||t.set(0,0,0,0),t}function nl(r,e,t,n){var a,c;if(!r.visible||!r.measurable)return;let s;n?s=r.worldTransform:(r.updateLocalTransform(),s=ke.get(),s.appendFrom(r.localTransform,t));const i=e,o=!!r.effects.length;if(o&&(e=gt.get().clear()),r.boundsArea)e.addRect(r.boundsArea,s);else{const l=r.bounds;l&&!l.isEmpty()&&(e.matrix=s,e.addBounds(l));for(let u=0;u<r.children.length;u++)nl(r.children[u],e,s,n)}if(o){for(let l=0;l<r.effects.length;l++)(c=(a=r.effects[l]).addBounds)==null||c.call(a,e);i.addBounds(e,B.IDENTITY),gt.return(e)}n||ke.return(s)}function Ys(r,e){const t=r.parent;return t&&(Ys(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function qt(r,e){if(r===16777215||!e)return e;if(e===16777215||!r)return r;const t=r>>16&255,n=r>>8&255,s=r&255,i=e>>16&255,o=e>>8&255,a=e&255,c=t*i/255|0,l=n*o/255|0,u=s*a/255|0;return(c<<16)+(l<<8)+u}const sl=16777215;function kn(r,e){return r===sl?e:e===sl?r:qt(r,e)}function Jt(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const Wv={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,t=this.parent;for(;t;)e*=t.alpha,t=t.parent;return e},getGlobalTransform(r=new B,e){if(e)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const t=Ys(this,ke.get().identity());return r.appendFrom(this.localTransform,t),ke.return(t),r},getGlobalTint(r){if(r)return this.renderGroup?Jt(this.renderGroup.worldColor):this.parentRenderGroup?Jt(kn(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=kn(e,t.localColor),t=t.parent;return Jt(e)}};function Zs(r,e,t){return e.clear(),t||(t=B.IDENTITY),il(r,e,t,r,!0),e.isValid||e.set(0,0,0,0),e}function il(r,e,t,n,s){var c,l;let i;if(s)i=ke.get(),i=t.copyTo(i);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const u=r.localTransform;i=ke.get(),i.appendFrom(u,t)}const o=e,a=!!r.effects.length;if(a&&(e=gt.get().clear()),r.boundsArea)e.addRect(r.boundsArea,i);else{r.renderPipeId&&(e.matrix=i,e.addBounds(r.bounds));const u=r.children;for(let h=0;h<u.length;h++)il(u[h],e,i,n,!1)}if(a){for(let u=0;u<r.effects.length;u++)(l=(c=r.effects[u]).addLocalBounds)==null||l.call(c,e,n);o.addBounds(e,B.IDENTITY),gt.return(e)}ke.return(i)}function ol(r,e){const t=r.children;for(let n=0;n<t.length;n++){const s=t[n],i=s.uid,o=(s._didViewChangeTick&65535)<<16|s._didContainerChangeTick&65535,a=e.index;(e.data[a]!==i||e.data[a+1]!==o)&&(e.data[e.index]=i,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,s.children.length&&ol(s,e)}return e.didChange}const Xv=new B,Yv={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(r,e){const t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=r/e*t:this.scale.x=t},_setHeight(r,e){const t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=r/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Pe});const r=this._localBoundsCacheData;return r.index=1,r.didChange=!1,r.data[0]!==this._didViewChangeTick&&(r.didChange=!0,r.data[0]=this._didViewChangeTick),ol(this,r),r.didChange&&Zs(this,r.localBounds,Xv),r.localBounds},getBounds(r,e){return Xs(this,r,e||new Pe)}},Zv={_onRender:null,set onRender(r){const e=this.renderGroup||this.parentRenderGroup;if(!r){this._onRender&&(e==null||e.removeOnRender(this)),this._onRender=null;return}this._onRender||e==null||e.addOnRender(this),this._onRender=r},get onRender(){return this._onRender}},Kv={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(r){this._zIndex!==r&&(this._zIndex=r,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(qv))}};function qv(r,e){return r._zIndex-e._zIndex}const Jv={getGlobalPosition(r=new le,e=!1){return this.parent?this.parent.toGlobal(this._position,r,e):(r.x=this._position.x,r.y=this._position.y),r},toGlobal(r,e,t=!1){const n=this.getGlobalTransform(ke.get(),t);return e=n.apply(r,e),ke.return(n),e},toLocal(r,e,t,n){e&&(r=e.toGlobal(r,t,n));const s=this.getGlobalTransform(ke.get(),n);return t=s.applyInverse(r,t),ke.return(s),t}};class Ks{constructor(){this.uid=ce("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"])}}const Rt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],It=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Bt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Ft=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],qs=[],al=[],Rn=Math.sign;function Qv(){for(let r=0;r<16;r++){const e=[];qs.push(e);for(let t=0;t<16;t++){const n=Rn(Rt[r]*Rt[t]+Bt[r]*It[t]),s=Rn(It[r]*Rt[t]+Ft[r]*It[t]),i=Rn(Rt[r]*Bt[t]+Bt[r]*Ft[t]),o=Rn(It[r]*Bt[t]+Ft[r]*Ft[t]);for(let a=0;a<16;a++)if(Rt[a]===n&&It[a]===s&&Bt[a]===i&&Ft[a]===o){e.push(a);break}}}for(let r=0;r<16;r++){const e=new B;e.set(Rt[r],It[r],Bt[r],Ft[r],0,0),al.push(e)}}Qv();const X={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:r=>Rt[r],uY:r=>It[r],vX:r=>Bt[r],vY:r=>Ft[r],inv:r=>r&8?r&15:-r&7,add:(r,e)=>qs[r][e],sub:(r,e)=>qs[r][X.inv(e)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,e)=>Math.abs(r)*2<=Math.abs(e)?e>=0?X.S:X.N:Math.abs(e)*2<=Math.abs(r)?r>0?X.E:X.W:e>0?r>0?X.SE:X.SW:r>0?X.NE:X.NW,matrixAppendRotationInv:(r,e,t=0,n=0,s=0,i=0)=>{const o=al[X.inv(e)],a=o.a,c=o.b,l=o.c,u=o.d,h=t-Math.min(0,a*s,l*i,a*s+l*i),d=n-Math.min(0,c*s,u*i,c*s+u*i),f=r.a,p=r.b,m=r.c,g=r.d;r.a=a*f+c*m,r.b=a*p+c*g,r.c=l*f+u*m,r.d=l*p+u*g,r.tx=h*f+d*m+r.tx,r.ty=h*p+d*g+r.ty},transformRectCoords:(r,e,t,n)=>{const{x:s,y:i,width:o,height:a}=r,{x:c,y:l,width:u,height:h}=e;return t===X.E?(n.set(s+c,i+l,o,a),n):t===X.S?n.set(u-i-a+c,s+l,a,o):t===X.W?n.set(u-s-o+c,h-i-a+l,o,a):t===X.N?n.set(i+c,h-s-o+l,a,o):n.set(s+c,i+l,o,a)}},cl=()=>{};class Js extends ve{constructor(e){const t=e.resource||new Float32Array(e.width*e.height*4);let n=e.format;n||(t instanceof Float32Array?n="rgba32float":t instanceof Int32Array||t instanceof Uint32Array?n="rgba32uint":t instanceof Int16Array||t instanceof Uint16Array?n="rgba16uint":(t instanceof Int8Array,n="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}}Js.extension=x.TextureSource;const ll=new B;class ul{constructor(e,t){this.mapCoord=new B,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){var t;this._texture!==e&&((t=this._texture)==null||t.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this)),this.update()}multiplyUvs(e,t){t===void 0&&(t=e);const n=this.mapCoord;for(let s=0;s<e.length;s+=2){const i=e[s],o=e[s+1];t[s]=i*n.a+o*n.c+n.tx,t[s+1]=i*n.b+o*n.d+n.ty}return t}update(){const e=this._texture;this._updateID++;const 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);const n=e.orig,s=e.trim;s&&(ll.set(n.width/s.width,0,0,n.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(ll));const i=e.source,o=this.uClampFrame,a=this.clampMargin/i._resolution,c=this.clampOffset/i._resolution;return o[0]=(e.frame.x+a+c)/i.width,o[1]=(e.frame.y+a+c)/i.height,o[2]=(e.frame.x+e.frame.width-a+c)/i.width,o[3]=(e.frame.y+e.frame.height-a+c)/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}}class D extends Qe{constructor({source:e,label:t,frame:n,orig:s,trim:i,defaultAnchor:o,defaultBorders:a,rotate:c,dynamic:l}={}){if(super(),this.uid=ce("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new fe,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=(e==null?void 0:e.source)??new ve,this.noFrame=!n,n)this.frame.copyFrom(n);else{const{width:u,height:h}=this._source;this.frame.width=u,this.frame.height=h}this.orig=s||this.frame,this.trim=i,this.rotate=c??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!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||(this._textureMatrix=new ul(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:t}=this,{width:n,height:s}=this._source,i=t.x/n,o=t.y/s,a=t.width/n,c=t.height/s;let l=this.rotate;if(l){const u=a/2,h=c/2,d=i+u,f=o+h;l=X.add(l,X.NW),e.x0=d+u*X.uX(l),e.y0=f+h*X.uY(l),l=X.add(l,2),e.x1=d+u*X.uX(l),e.y1=f+h*X.uY(l),l=X.add(l,2),e.x2=d+u*X.uX(l),e.y2=f+h*X.uY(l),l=X.add(l,2),e.x3=d+u*X.uX(l),e.y3=f+h*X.uY(l)}else e.x0=i,e.y0=o,e.x1=i+a,e.y1=o,e.x2=i+a,e.y2=o+c,e.x3=i,e.y3=o+c}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 N(de,"Texture.baseTexture is now Texture.source"),this._source}}D.EMPTY=new D({label:"EMPTY",source:new ve({label:"EMPTY"})}),D.EMPTY.destroy=cl,D.WHITE=new D({source:new Js({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),D.WHITE.destroy=cl;let e0=0;class t0{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new Bs(this.textureOptions)}createTexture(e,t,n,s){const i=new ve({...this.textureOptions,width:e,height:t,resolution:1,antialias:n,autoGarbageCollect:!1,autoGenerateMipmaps:s});return new D({source:i,label:`texturePool_${e0++}`})}getOptimalTexture(e,t,n=1,s,i=!1){let o=Math.ceil(e*n-1e-6),a=Math.ceil(t*n-1e-6);o=Sn(o),a=Sn(a);const c=s?1:0,l=i?1:0,u=(o<<17)+(a<<2)+(l<<1)+c;this._texturePool[u]||(this._texturePool[u]=[]);let h=this._texturePool[u].pop();return h||(h=this.createTexture(o,a,s,i)),h.source._resolution=n,h.source.width=o/n,h.source.height=a/n,h.source.pixelWidth=o,h.source.pixelHeight=a,h.frame.x=0,h.frame.y=0,h.frame.width=e,h.frame.height=t,h.updateUvs(),this._poolKeyHash[h.uid]=u,h}getSameSizeTexture(e,t=!1){const n=e.source;return this.getOptimalTexture(e.width,e.height,n._resolution,t)}returnTexture(e,t=!1){const n=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[n].push(e)}clear(e){if(e=e!==!1,e)for(const t in this._texturePool){const n=this._texturePool[t];if(n)for(let s=0;s<n.length;s++)n[s].destroy(!0)}this._texturePool={}}}const Re=new t0;Kt.register(Re);class Qs{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new B,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 Ks,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const t=e.children;for(let n=0;n<t.length;n++){const s=t[n];s._updateFlags=15,this.addChild(s)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Re.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const 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){const 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.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const t=e.children;for(let n=0;n<t.length;n++)this.addChild(t[n])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const t=e.children;for(let n=0;n<t.length;n++)this.removeChild(t[n])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(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.push(e)}removeOnRender(e){this._onRenderContainers.splice(this._onRenderContainers.indexOf(e),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=[]){const 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;const n=e.children;for(let s=0;s<n.length;s++)this._getChildren(n[s],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new B),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new B),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new B),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 r0(r,e,t={}){for(const n in e)!t[n]&&e[n]!==void 0&&(r[n]=e[n])}const ei=new Ce(null),In=new Ce(null),ti=new Ce(null,1,1),Bn=new Ce(null),Fn=1,ri=2,Rr=4;class Ie extends Qe{constructor(e={}){var t,n;super(),this.uid=ce("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 B,this.relativeGroupTransform=new B,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Ce(this,0,0),this._scale=ti,this._pivot=In,this._origin=Bn,this._skew=ei,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=[],r0(this,e,{children:!0,parent:!0,effects:!0}),(t=e.children)==null||t.forEach(s=>this.addChild(s)),(n=e.parent)==null||n.addChild(this)}static mixin(e){N("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),H.mixin(Ie,e)}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||N(de,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let s=0;s<e.length;s++)this.addChild(e[s]);return e[0]}const 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 s=0;s<e.length;s++)this.removeChild(e[s]);return e[0]}const 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;const e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=Se.get(Qs,this),this.groupTransform=B.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),Se.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new B),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*Iv}set angle(e){this.rotation=e*Bv}get pivot(){return this._pivot===In&&(this._pivot=new Ce(this,0,0)),this._pivot}set pivot(e){this._pivot===In&&(this._pivot=new Ce(this,0,0),this._origin!==Bn&&W("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===ei&&(this._skew=new Ce(this,0,0)),this._skew}set skew(e){this._skew===ei&&(this._skew=new Ce(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===ti&&(this._scale=new Ce(this,1,1)),this._scale}set scale(e){this._scale===ti&&(this._scale=new Ce(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===Bn&&(this._origin=new Ce(this,0,0)),this._origin}set origin(e){this._origin===Bn&&(this._origin=new Ce(this,0,0),this._pivot!==In&&W("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){const t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||(e={});const 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){const n=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,n.width),t!==void 0&&this._setHeight(t,n.height)}_updateSkew(){const 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||1:this.scale.x,typeof e.scaleY=="number"?e.scaleY||1: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(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const t=this.localTransform,n=this._scale,s=this._pivot,i=this._origin,o=this._position,a=n._x,c=n._y,l=s._x,u=s._y,h=-i._x,d=-i._y;t.a=this._cx*a,t.b=this._sx*a,t.c=this._cy*c,t.d=this._sy*c,t.tx=o._x-(l*t.a+u*t.c)+(h*t.a+d*t.c)-h,t.ty=o._y-(l*t.b+u*t.d)+(h*t.b+d*t.d)-d}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=Fn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const n=ye.shared.setValue(e??16777215).toBgrNumber();n!==this.localColor&&(this.localColor=n,this._updateFlags|=Fn,this._onUpdate())}get tint(){return Jt(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ri,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Rr,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Rr,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=Rr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){var s;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==null?void 0:e.children)&&t)for(let i=0;i<t.length;++i)t[i].destroy(e);(s=this.renderGroup)==null||s.destroy(),this.renderGroup=null}}H.mixin(Ie,Lv,jv,Jv,Zv,Yv,$v,Vv,Kv,kv,Uv,Wv,zv);function hl(r,e,t=2){const n=e&&e.length,s=n?e[0]*t:r.length;let i=dl(r,0,s,t,!0);const o=[];if(!i||i.next===i.prev)return o;let a,c,l;if(n&&(i=a0(r,e,i,t)),r.length>80*t){a=r[0],c=r[1];let u=a,h=c;for(let d=t;d<s;d+=t){const f=r[d],p=r[d+1];f<a&&(a=f),p<c&&(c=p),f>u&&(u=f),p>h&&(h=p)}l=Math.max(u-a,h-c),l=l!==0?32767/l:0}return Ir(i,o,t,a,c,l,0),o}function dl(r,e,t,n,s){let i;if(s===y0(r,e,t,n)>0)for(let o=e;o<t;o+=n)i=gl(o/n|0,r[o],r[o+1],i);else for(let o=t-n;o>=e;o-=n)i=gl(o/n|0,r[o],r[o+1],i);return i&&Qt(i,i.next)&&(Gr(i),i=i.next),i}function Gt(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(Qt(t,t.next)||ge(t.prev,t,t.next)===0)){if(Gr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Ir(r,e,t,n,s,i,o){if(!r)return;!o&&i&&d0(r,n,s,i);let a=r;for(;r.prev!==r.next;){const c=r.prev,l=r.next;if(i?s0(r,n,s,i):n0(r)){e.push(c.i,r.i,l.i),Gr(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=i0(Gt(r),e),Ir(r,e,t,n,s,i,2)):o===2&&o0(r,e,t,n,s,i):Ir(Gt(r),e,t,n,s,i,1);break}}}function n0(r){const e=r.prev,t=r,n=r.next;if(ge(e,t,n)>=0)return!1;const s=e.x,i=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=Math.min(s,i,o),h=Math.min(a,c,l),d=Math.max(s,i,o),f=Math.max(a,c,l);let p=n.next;for(;p!==e;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Br(s,a,i,c,o,l,p.x,p.y)&&ge(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function s0(r,e,t,n){const s=r.prev,i=r,o=r.next;if(ge(s,i,o)>=0)return!1;const a=s.x,c=i.x,l=o.x,u=s.y,h=i.y,d=o.y,f=Math.min(a,c,l),p=Math.min(u,h,d),m=Math.max(a,c,l),g=Math.max(u,h,d),_=ni(f,p,e,t,n),y=ni(m,g,e,t,n);let b=r.prevZ,v=r.nextZ;for(;b&&b.z>=_&&v&&v.z<=y;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==o&&Br(a,u,c,h,l,d,b.x,b.y)&&ge(b.prev,b,b.next)>=0||(b=b.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==o&&Br(a,u,c,h,l,d,v.x,v.y)&&ge(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;b&&b.z>=_;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==o&&Br(a,u,c,h,l,d,b.x,b.y)&&ge(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==o&&Br(a,u,c,h,l,d,v.x,v.y)&&ge(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function i0(r,e){let t=r;do{const n=t.prev,s=t.next.next;!Qt(n,s)&&pl(n,t,t.next,s)&&Fr(n,s)&&Fr(s,n)&&(e.push(n.i,t.i,s.i),Gr(t),Gr(t.next),t=r=s),t=t.next}while(t!==r);return Gt(t)}function o0(r,e,t,n,s,i){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&m0(o,a)){let c=ml(o,a);o=Gt(o,o.next),c=Gt(c,c.next),Ir(o,e,t,n,s,i,0),Ir(c,e,t,n,s,i,0);return}a=a.next}o=o.next}while(o!==r)}function a0(r,e,t,n){const s=[];for(let i=0,o=e.length;i<o;i++){const a=e[i]*n,c=i<o-1?e[i+1]*n:r.length,l=dl(r,a,c,n,!1);l===l.next&&(l.steiner=!0),s.push(p0(l))}s.sort(c0);for(let i=0;i<s.length;i++)t=l0(s[i],t);return t}function c0(r,e){let t=r.x-e.x;if(t===0&&(t=r.y-e.y,t===0)){const n=(r.next.y-r.y)/(r.next.x-r.x),s=(e.next.y-e.y)/(e.next.x-e.x);t=n-s}return t}function l0(r,e){const t=u0(r,e);if(!t)return e;const n=ml(t,r);return Gt(n,n.next),Gt(t,t.next)}function u0(r,e){let t=e;const n=r.x,s=r.y;let i=-1/0,o;if(Qt(r,t))return t;do{if(Qt(r,t.next))return t.next;if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){const h=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>i&&(i=h,o=t.x<t.next.x?t:t.next,h===n))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,c=o.x,l=o.y;let u=1/0;t=o;do{if(n>=t.x&&t.x>=c&&n!==t.x&&fl(s<l?n:i,s,c,l,s<l?i:n,s,t.x,t.y)){const h=Math.abs(s-t.y)/(n-t.x);Fr(t,r)&&(h<u||h===u&&(t.x>o.x||t.x===o.x&&h0(o,t)))&&(o=t,u=h)}t=t.next}while(t!==a);return o}function h0(r,e){return ge(r.prev,r,e.prev)<0&&ge(e.next,r,r.next)<0}function d0(r,e,t,n){let s=r;do s.z===0&&(s.z=ni(s.x,s.y,e,t,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,f0(s)}function f0(r){let e,t=1;do{let n=r,s;r=null;let i=null;for(e=0;n;){e++;let o=n,a=0;for(let l=0;l<t&&(a++,o=o.nextZ,!!o);l++);let c=t;for(;a>0||c>0&&o;)a!==0&&(c===0||!o||n.z<=o.z)?(s=n,n=n.nextZ,a--):(s=o,o=o.nextZ,c--),i?i.nextZ=s:r=s,s.prevZ=i,i=s;n=o}i.nextZ=null,t*=2}while(e>1);return r}function ni(r,e,t,n,s){return r=(r-t)*s|0,e=(e-n)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function p0(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function fl(r,e,t,n,s,i,o,a){return(s-o)*(e-a)>=(r-o)*(i-a)&&(r-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(i-a)>=(s-o)*(n-a)}function Br(r,e,t,n,s,i,o,a){return!(r===o&&e===a)&&fl(r,e,t,n,s,i,o,a)}function m0(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!g0(r,e)&&(Fr(r,e)&&Fr(e,r)&&_0(r,e)&&(ge(r.prev,r,e.prev)||ge(r,e.prev,e))||Qt(r,e)&&ge(r.prev,r,r.next)>0&&ge(e.prev,e,e.next)>0)}function ge(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function Qt(r,e){return r.x===e.x&&r.y===e.y}function pl(r,e,t,n){const s=On(ge(r,e,t)),i=On(ge(r,e,n)),o=On(ge(t,n,r)),a=On(ge(t,n,e));return!!(s!==i&&o!==a||s===0&&Gn(r,t,e)||i===0&&Gn(r,n,e)||o===0&&Gn(t,r,n)||a===0&&Gn(t,e,n))}function Gn(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function On(r){return r>0?1:r<0?-1:0}function g0(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&pl(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Fr(r,e){return ge(r.prev,r,r.next)<0?ge(r,e,r.next)>=0&&ge(r,r.prev,e)>=0:ge(r,e,r.prev)<0||ge(r,r.next,e)<0}function _0(r,e){let t=r,n=!1;const s=(r.x+e.x)/2,i=(r.y+e.y)/2;do t.y>i!=t.next.y>i&&t.next.y!==t.y&&s<(t.next.x-t.x)*(i-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function ml(r,e){const t=si(r.i,r.x,r.y),n=si(e.i,e.x,e.y),s=r.next,i=e.prev;return r.next=e,e.prev=r,t.next=s,s.prev=t,n.next=t,t.prev=n,i.next=n,n.prev=i,n}function gl(r,e,t,n){const s=si(r,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Gr(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function si(r,e,t){return{i:r,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function y0(r,e,t,n){let s=0;for(let i=e,o=t-n;i<t;i+=n)s+=(r[o]-r[i])*(r[i+1]+r[o+1]),o=i;return s}const b0=hl.default||hl;var Le=(r=>(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Le||{});class _l{constructor(e){this.items=[],this._name=e}emit(e,t,n,s,i,o,a,c){const{name:l,items:u}=this;for(let h=0,d=u.length;h<d;h++)u[h][l](e,t,n,s,i,o,a,c);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){const t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const x0=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],yl=class of extends Qe{constructor(e){super(),this.tick=0,this.uid=ce("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;const t=[...x0,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(e={}){const t=e.skipExtensionImports===!0?!0:e.manageImports===!1;await Av(t),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const n in this._systemsHash)e={...this._systemsHash[n].constructor.defaultOptions,...e};e={...of.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let n=0;n<this.runners.init.items.length;n++)await this.runners.init.items[n].init(e);this._initOptions=e}render(e,t){this.tick++;let n=e;if(n instanceof Ie&&(n={container:n},t&&(N(de,"passing a second argument is deprecated, please use render options instead"),n.target=t.renderTexture)),n.target||(n.target=this.view.renderTarget),n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,n.clearColor??(n.clearColor=this.background.colorRgba),n.clear??(n.clear=this.background.clearBeforeRender)),n.clearColor){const s=Array.isArray(n.clearColor)&&n.clearColor.length===4;n.clearColor=s?n.clearColor:ye.shared.setValue(n.clearColor).toArray()}n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),n.container.visible&&(n.container.enableRenderGroup(),this.runners.prerender.emit(n),this.runners.renderStart.emit(n),this.runners.render.emit(n),this.runners.renderEnd.emit(n),this.runners.postrender.emit(n))}resize(e,t,n){const s=this.view.resolution;this.view.resize(e,t,n),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),n!==void 0&&n!==s&&this.runners.resolutionChange.emit(n)}clear(e={}){const t=this;e.target||(e.target=t.renderTarget.renderTarget),e.clearColor||(e.clearColor=this.background.colorRgba),e.clear??(e.clear=Le.ALL);const{clear:n,clearColor:s,target:i,mipLevel:o,layer:a}=e;ye.shared.setValue(s??this.background.colorRgba),t.renderTarget.clear(i,n,ye.shared.toArray(),o??0,a??0)}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...e){e.forEach(t=>{this.runners[t]=new _l(t)})}_addSystems(e){let t;for(t in e){const n=e[t];this._addSystem(n.value,n.name)}}_addSystem(e,t){const n=new e(this);if(this[t])throw new Error(`Whoops! The name "${t}" is already in use`);this[t]=n,this._systemsHash[t]=n;for(const s in this.runners)this.runners[s].add(n);return this}_addPipes(e,t){const n=t.reduce((s,i)=>(s[i.name]=i.value,s),{});e.forEach(s=>{const i=s.value,o=s.name,a=n[o];this.renderPipes[o]=new i(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e=="object"&&e.releaseGlobalResources)&&Kt.release(),Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Pc())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};yl.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let er=yl;function bl(r,e){if(!(r instanceof Ue)){let t=e?Q.INDEX:Q.VERTEX;r instanceof Array&&(e?(r=new Uint32Array(r),t=Q.INDEX|Q.COPY_DST):(r=new Float32Array(r),t=Q.VERTEX|Q.COPY_DST)),r=new Ue({data:r,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return r}function v0(r,e,t){const n=r.getAttribute(e);if(!n)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;const s=n.buffer.data;let i=1/0,o=1/0,a=-1/0,c=-1/0;const l=s.BYTES_PER_ELEMENT,u=(n.offset||0)/l,h=(n.stride||8)/l;for(let d=u;d<s.length;d+=h){const f=s[d],p=s[d+1];f>a&&(a=f),p>c&&(c=p),f<i&&(i=f),p<o&&(o=p)}return t.minX=i,t.minY=o,t.maxX=a,t.maxY=c,t}function T0(r){return(r instanceof Ue||Array.isArray(r)||r.BYTES_PER_ELEMENT)&&(r={buffer:r}),r.buffer=bl(r.buffer,!1),r}class tr extends Qe{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ce("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Pe,this._boundsDirty=!0;const{attributes:t,indexBuffer:n,topology:s}=e;if(this.buffers=[],this.attributes={},t)for(const i in t)this.addAttribute(i,t[i]);this.instanceCount=e.instanceCount??1,n&&this.addIndex(n),this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}getSize(){for(const e in this.attributes){const t=this.attributes[e];return t.buffer.data.length/(t.stride/4||t.size)}return 0}addAttribute(e,t){const n=T0(t);this.buffers.indexOf(n.buffer)===-1&&(this.buffers.push(n.buffer),n.buffer.on("update",this.onBufferUpdate,this),n.buffer.on("change",this.onBufferUpdate,this)),this.attributes[e]=n}addIndex(e){this.indexBuffer=bl(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,v0(this,"aPosition",this._bounds)):this._bounds}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!1){var t;this.emit("destroy",this),this.removeAllListeners(),e&&this.buffers.forEach(n=>n.destroy()),this.unload(),(t=this.indexBuffer)==null||t.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}class rr{constructor(e){typeof e=="number"?this.rawBinaryData=new ArrayBuffer(e):e instanceof Uint8Array?this.rawBinaryData=e.buffer:this.rawBinaryData=e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${e} isn't a valid view type`)}}}function xl(r,e=null){const t=r*6;if(t>65535?e||(e=new Uint32Array(t)):e||(e=new Uint16Array(t)),e.length!==t)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);for(let n=0,s=0;n<t;n+=6,s+=4)e[n+0]=s+0,e[n+1]=s+1,e[n+2]=s+2,e[n+3]=s+0,e[n+4]=s+2,e[n+5]=s+3;return e}function S0(r){return{dynamicUpdate:vl(r,!0),staticUpdate:vl(r,!1)}}function vl(r,e){const t=[];t.push(`
348
+
349
+ var index = 0;
350
+
351
+ for (let i = 0; i < ps.length; ++i)
352
+ {
353
+ const p = ps[i];
354
+
355
+ `);let n=0;for(const i in r){const o=r[i];if(e!==o.dynamic)continue;t.push(`offset = index + ${n}`),t.push(o.code);const a=pt(o.format);n+=a.stride/4}t.push(`
356
+ index += stride * 4;
357
+ }
358
+ `),t.unshift(`
359
+ var stride = ${n};
360
+ `);const s=t.join(`
361
+ `);return new Function("ps","f32v","u32v",s)}class w0{constructor(e){this._size=0,this._generateParticleUpdateCache={};const t=this._size=e.size??1e3,n=e.properties;let s=0,i=0;for(const u in n){const h=n[u],d=pt(h.format);h.dynamic?i+=d.stride:s+=d.stride}this._dynamicStride=i/4,this._staticStride=s/4,this.staticAttributeBuffer=new rr(t*4*s),this.dynamicAttributeBuffer=new rr(t*4*i),this.indexBuffer=xl(t);const o=new tr;let a=0,c=0;this._staticBuffer=new Ue({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:Q.VERTEX|Q.COPY_DST}),this._dynamicBuffer=new Ue({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:Q.VERTEX|Q.COPY_DST});for(const u in n){const h=n[u],d=pt(h.format);h.dynamic?(o.addAttribute(h.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:a*4,format:h.format}),a+=d.size):(o.addAttribute(h.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:c*4,format:h.format}),c+=d.size)}o.addIndex(this.indexBuffer);const l=this.getParticleUpdate(n);this._dynamicUpload=l.dynamicUpdate,this._staticUpload=l.staticUpdate,this.geometry=o}getParticleUpdate(e){const t=P0(e);return this._generateParticleUpdateCache[t]?this._generateParticleUpdateCache[t]:(this._generateParticleUpdateCache[t]=this.generateParticleUpdate(e),this._generateParticleUpdateCache[t])}generateParticleUpdate(e){return S0(e)}update(e,t){e.length>this._size&&(t=!0,this._size=Math.max(e.length,this._size*1.5|0),this.staticAttributeBuffer=new rr(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new rr(this._size*this._dynamicStride*4*4),this.indexBuffer=xl(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const n=this.dynamicAttributeBuffer;if(this._dynamicUpload(e,n.float32View,n.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,e.length*this._dynamicStride*4,!0),t){const s=this.staticAttributeBuffer;this._staticUpload(e,s.float32View,s.uint32View),this._staticBuffer.setDataWithSize(s.float32View,e.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function P0(r){const e=[];for(const t in r){const n=r[t];e.push(t,n.code,n.dynamic?"d":"s")}return e.join("_")}const E0={aVertex:(r,e,t,n,s)=>{let i=0,o=0,a=0,c=0;for(let l=0;l<r.length;++l){const u=r[l],h=u.texture,d=u.scaleX,f=u.scaleY,p=u.anchorX,m=u.anchorY,g=h.trim,_=h.orig;g?(o=g.x-p*_.width,i=o+g.width,c=g.y-m*_.height,a=c+g.height):(i=_.width*(1-p),o=_.width*-p,a=_.height*(1-m),c=_.height*-m),e[n]=o*d,e[n+1]=c*f,e[n+s]=i*d,e[n+s+1]=c*f,e[n+s*2]=i*d,e[n+s*2+1]=a*f,e[n+s*3]=o*d,e[n+s*3+1]=a*f,n+=s*4}},aPosition:(r,e,t,n,s)=>{for(let i=0;i<r.length;++i){const o=r[i],a=o.x,c=o.y;e[n]=a,e[n+1]=c,e[n+s]=a,e[n+s+1]=c,e[n+s*2]=a,e[n+s*2+1]=c,e[n+s*3]=a,e[n+s*3+1]=c,n+=s*4}},aRotation:(r,e,t,n,s)=>{for(let i=0;i<r.length;++i){const o=r[i].rotation;e[n]=o,e[n+s]=o,e[n+s*2]=o,e[n+s*3]=o,n+=s*4}},aUV:(r,e,t,n,s)=>{for(let i=0;i<r.length;++i){const o=r[i].texture.uvs;e[n]=o.x0,e[n+1]=o.y0,e[n+s]=o.x1,e[n+s+1]=o.y1,e[n+s*2]=o.x2,e[n+s*2+1]=o.y2,e[n+s*3]=o.x3,e[n+s*3+1]=o.y3,n+=s*4}},aColor:(r,e,t,n,s)=>{for(let i=0;i<r.length;++i){const o=r[i].color;t[n]=o,t[n+s]=o,t[n+s*2]=o,t[n+s*3]=o,n+=s*4}}};function C0(r){const e=Object.values(r),t=e.filter(s=>s.dynamic),n=e.filter(s=>!s.dynamic);return{dynamicUpdate:Tl(t),staticUpdate:Tl(n)}}function Tl(r){let e=0;const t=[];for(let n=0;n<r.length;n++){const s=r[n],i=pt(s.format).stride/4;e+=i,t.push({stride:i,updateFunction:s.updateFunction||E0[s.attributeName]})}return(n,s,i)=>{let o=0;for(let a=0;a<t.length;a++){const c=t[a];c.updateFunction(n,s,i,o,e),o+=c.stride}}}function M0(){return A0}function A0(r,e,t){const n=r.gl,s=r.shader,i=s._getProgramData(e.glProgram);for(const o in e.groups){const a=e.groups[o];for(const c in a.resources){const l=a.resources[c];if(l instanceof je)l.ubo?s.bindUniformBlock(l,e._uniformBindMap[o][c],t.blockIndex++):s.updateUniformGroup(l);else if(l instanceof Tn)s.bindUniformBlock(l,e._uniformBindMap[o][c],t.blockIndex++);else if(l instanceof ve){r.texture.bind(l,t.textureCount);const u=e._uniformBindMap[o][c],h=i.uniformData[u];h&&(h.value!==t.textureCount&&n.uniform1i(h.location,t.textureCount),t.textureCount++)}}}}const k0=[(r,e,t,n,s)=>{const i=n[r].toArray(!0);e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+4]=i[3],e[t+5]=i[4],e[t+6]=i[5],e[t+8]=i[6],e[t+9]=i[7],e[t+10]=i[8]},(r,e,t,n,s)=>{s=n[r],e[t]=s.x,e[t+1]=s.y,e[t+2]=s.width,e[t+3]=s.height},(r,e,t,n,s)=>{s=n[r],e[t]=s.x,e[t+1]=s.y},(r,e,t,n,s)=>{s=n[r],e[t]=s.red,e[t+1]=s.green,e[t+2]=s.blue,e[t+3]=s.alpha},(r,e,t,n,s)=>{s=n[r],e[t]=s.red,e[t+1]=s.green,e[t+2]=s.blue}],R0={f32:(r,e,t,n,s)=>{e[t]=s},i32:(r,e,t,n,s)=>{e[t]=s},"vec2<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1]},"vec3<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2]},"vec4<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3]},"mat2x2<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3]},"mat3x3<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+4]=s[3],e[t+5]=s[4],e[t+6]=s[5],e[t+8]=s[6],e[t+9]=s[7],e[t+10]=s[8]},"mat4x4<f32>":(r,e,t,n,s)=>{for(let i=0;i<16;i++)e[t+i]=s[i]},"mat3x2<f32>":(r,e,t,n,s)=>{for(let i=0;i<6;i++)e[t+(i/3|0)*4+i%3]=s[i]},"mat4x2<f32>":(r,e,t,n,s)=>{for(let i=0;i<8;i++)e[t+(i/4|0)*4+i%4]=s[i]},"mat2x3<f32>":(r,e,t,n,s)=>{for(let i=0;i<6;i++)e[t+(i/2|0)*4+i%2]=s[i]},"mat4x3<f32>":(r,e,t,n,s)=>{for(let i=0;i<12;i++)e[t+(i/4|0)*4+i%4]=s[i]},"mat2x4<f32>":(r,e,t,n,s)=>{for(let i=0;i<8;i++)e[t+(i/2|0)*4+i%2]=s[i]},"mat3x4<f32>":(r,e,t,n,s)=>{for(let i=0;i<12;i++)e[t+(i/3|0)*4+i%3]=s[i]}},I0={f32:(r,e,t,n,s)=>{e[t]=s},i32:(r,e,t,n,s)=>{e[t]=s},"vec2<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1]},"vec3<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2]},"vec4<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3]},"mat2x2<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+4]=s[2],e[t+5]=s[3]},"mat3x3<f32>":(r,e,t,n,s)=>{e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+4]=s[3],e[t+5]=s[4],e[t+6]=s[5],e[t+8]=s[6],e[t+9]=s[7],e[t+10]=s[8]},"mat4x4<f32>":(r,e,t,n,s)=>{for(let i=0;i<16;i++)e[t+i]=s[i]},"mat3x2<f32>":(r,e,t,n,s)=>{for(let i=0;i<6;i++)e[t+(i/3|0)*4+i%3]=s[i]},"mat4x2<f32>":(r,e,t,n,s)=>{for(let i=0;i<8;i++)e[t+(i/4|0)*4+i%4]=s[i]},"mat2x3<f32>":(r,e,t,n,s)=>{for(let i=0;i<6;i++)e[t+(i/2|0)*4+i%2]=s[i]},"mat4x3<f32>":(r,e,t,n,s)=>{for(let i=0;i<12;i++)e[t+(i/4|0)*4+i%4]=s[i]},"mat2x4<f32>":(r,e,t,n,s)=>{for(let i=0;i<8;i++)e[t+(i/2|0)*4+i%2]=s[i]},"mat3x4<f32>":(r,e,t,n,s)=>{for(let i=0;i<12;i++)e[t+(i/3|0)*4+i%3]=s[i]}};function B0(r){return Sl(r,I0,e=>{const t=Math.max(ks[e.data.type]/16,1),n=e.data.value.length/e.data.size,s=(4-n%4)%4;return(i,o,a,c,l)=>{let u=0;for(let h=0;h<e.data.size*t;h++){for(let d=0;d<n;d++)o[a++]=l[u++];a+=s}}})}function F0(r){return Sl(r,R0,e=>{const{size:t,align:n}=Ar[e.data.type],s=(t-n)/4;return(i,o,a,c,l)=>{let u=0;for(let h=0;h<e.data.size*(t/4);h++){for(let d=0;d<t/4;d++)o[a++]=l[u++];a+=s}}})}function Sl(r,e,t){const n={};for(const s in r){const i=r[s],o=i.data;let a=!1;n[o.name]={offset:i.offset/4,func:null};for(let c=0;c<et.length;c++){const l=et[c];if(o.type===l.type&&l.test(o)){n[o.name].func=k0[c],a=!0;break}}a||(o.size===1?n[o.name].func=e[o.type]:n[o.name].func=t(i))}return(s,i,o)=>{for(const a in n)n[a].func(a,i,o+n[a].offset,s,s[a])}}const G0={f32(r,e,t,n,s,i,o){t!==n&&(e.value=n,o.uniform1f(s[r].location,n))},"vec2<f32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1])&&(t[0]=n[0],t[1]=n[1],o.uniform2f(s[r].location,n[0],n[1]))},"vec3<f32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],o.uniform3f(s[r].location,n[0],n[1],n[2]))},"vec4<f32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],o.uniform4f(s[r].location,n[0],n[1],n[2],n[3]))},i32(r,e,t,n,s,i,o){t!==n&&(e.value=n,o.uniform1i(s[r].location,n))},"vec2<i32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1])&&(t[0]=n[0],t[1]=n[1],o.uniform2i(s[r].location,n[0],n[1]))},"vec3<i32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],o.uniform3i(s[r].location,n[0],n[1],n[2]))},"vec4<i32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],o.uniform4i(s[r].location,n[0],n[1],n[2],n[3]))},u32(r,e,t,n,s,i,o){t!==n&&(e.value=n,o.uniform1ui(s[r].location,n))},"vec2<u32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1])&&(t[0]=n[0],t[1]=n[1],o.uniform2ui(s[r].location,n[0],n[1]))},"vec3<u32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],o.uniform3ui(s[r].location,n[0],n[1],n[2]))},"vec4<u32>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],o.uniform4ui(s[r].location,n[0],n[1],n[2],n[3]))},bool(r,e,t,n,s,i,o){t!==n&&(e.value=n,o.uniform1i(s[r].location,n))},"vec2<bool>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1])&&(t[0]=n[0],t[1]=n[1],o.uniform2i(s[r].location,n[0],n[1]))},"vec3<bool>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],o.uniform3i(s[r].location,n[0],n[1],n[2]))},"vec4<bool>"(r,e,t,n,s,i,o){(t[0]!==n[0]||t[1]!==n[1]||t[2]!==n[2]||t[3]!==n[3])&&(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],o.uniform4i(s[r].location,n[0],n[1],n[2],n[3]))},"mat2x2<f32>"(r,e,t,n,s,i,o){o.uniformMatrix2fv(s[r].location,!1,n)},"mat3x3<f32>"(r,e,t,n,s,i,o){o.uniformMatrix3fv(s[r].location,!1,n)},"mat4x4<f32>"(r,e,t,n,s,i,o){o.uniformMatrix4fv(s[r].location,!1,n)}},O0={f32(r,e,t,n,s,i,o){o.uniform1fv(s[r].location,n)},"vec2<f32>"(r,e,t,n,s,i,o){o.uniform2fv(s[r].location,n)},"vec3<f32>"(r,e,t,n,s,i,o){o.uniform3fv(s[r].location,n)},"vec4<f32>"(r,e,t,n,s,i,o){o.uniform4fv(s[r].location,n)},"mat2x2<f32>"(r,e,t,n,s,i,o){o.uniformMatrix2fv(s[r].location,!1,n)},"mat3x3<f32>"(r,e,t,n,s,i,o){o.uniformMatrix3fv(s[r].location,!1,n)},"mat4x4<f32>"(r,e,t,n,s,i,o){o.uniformMatrix4fv(s[r].location,!1,n)},i32(r,e,t,n,s,i,o){o.uniform1iv(s[r].location,n)},"vec2<i32>"(r,e,t,n,s,i,o){o.uniform2iv(s[r].location,n)},"vec3<i32>"(r,e,t,n,s,i,o){o.uniform3iv(s[r].location,n)},"vec4<i32>"(r,e,t,n,s,i,o){o.uniform4iv(s[r].location,n)},u32(r,e,t,n,s,i,o){o.uniform1iv(s[r].location,n)},"vec2<u32>"(r,e,t,n,s,i,o){o.uniform2iv(s[r].location,n)},"vec3<u32>"(r,e,t,n,s,i,o){o.uniform3iv(s[r].location,n)},"vec4<u32>"(r,e,t,n,s,i,o){o.uniform4iv(s[r].location,n)},bool(r,e,t,n,s,i,o){o.uniform1iv(s[r].location,n)},"vec2<bool>"(r,e,t,n,s,i,o){o.uniform2iv(s[r].location,n)},"vec3<bool>"(r,e,t,n,s,i,o){o.uniform3iv(s[r].location,n)},"vec4<bool>"(r,e,t,n,s,i,o){o.uniform4iv(s[r].location,n)}},D0=[(r,e,t,n,s,i,o)=>{o.uniformMatrix3fv(s[r].location,!1,i[r].toArray(!0))},(r,e,t,n,s,i,o)=>{t=s[r].value,n=i[r],(t[0]!==n.x||t[1]!==n.y||t[2]!==n.width||t[3]!==n.height)&&(t[0]=n.x,t[1]=n.y,t[2]=n.width,t[3]=n.height,o.uniform4f(s[r].location,n.x,n.y,n.width,n.height))},(r,e,t,n,s,i,o)=>{t=s[r].value,n=i[r],(t[0]!==n.x||t[1]!==n.y)&&(t[0]=n.x,t[1]=n.y,o.uniform2f(s[r].location,n.x,n.y))},(r,e,t,n,s,i,o)=>{t=s[r].value,n=i[r],(t[0]!==n.red||t[1]!==n.green||t[2]!==n.blue||t[3]!==n.alpha)&&(t[0]=n.red,t[1]=n.green,t[2]=n.blue,t[3]=n.alpha,o.uniform4f(s[r].location,n.red,n.green,n.blue,n.alpha))},(r,e,t,n,s,i,o)=>{t=s[r].value,n=i[r],(t[0]!==n.red||t[1]!==n.green||t[2]!==n.blue)&&(t[0]=n.red,t[1]=n.green,t[2]=n.blue,o.uniform3f(s[r].location,n.red,n.green,n.blue))}];function U0(r,e){const t={};for(const n in r.uniformStructures){if(!e[n])continue;const s=r.uniformStructures[n];let i=!1;for(let o=0;o<et.length;o++){const a=et[o];if(s.type===a.type&&a.test(s)){t[n]=D0[o],i=!0;break}}if(!i){const o=s.size===1?G0:O0;t[n]=o[s.type]}}return(n,s,i)=>{const o=i.gl;for(const a in t){const c=s[a],l=n[a],u=n[a].value;t[a](a,l,u,c,n,s,o)}}}function L0(){Object.assign(er.prototype,{_unsafeEvalCheck(){}}),Object.assign(As.prototype,{_systemCheck(){}}),Object.assign(Ds.prototype,{_generateUniformsSync:U0}),Object.assign(Rs.prototype,{_generateUboSync:B0}),Object.assign(Us.prototype,{_generateUboSync:F0}),Object.assign(Os.prototype,{_generateShaderSync:M0}),Object.assign(w0.prototype,{generateParticleUpdate:C0})}L0();const z0={extension:{type:x.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>VP)}},N0={extension:{type:x.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>HP)}};function $0(r,e,t){const{width:n,height:s}=t.orig,i=t.trim;if(i){const o=i.width,a=i.height;r.minX=i.x-e._x*n,r.maxX=r.minX+o,r.minY=i.y-e._y*s,r.maxY=r.minY+a}else r.minX=-e._x*n,r.maxX=r.minX+n,r.minY=-e._y*s,r.maxY=r.minY+s}class ii extends Ie{constructor(e){super(e),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new Pe(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const t=this.bounds,{x:n,y:s}=e;return n>=t.minX&&n<=t.maxX&&s>=t.minY&&s<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,n){const{renderPipes:s}=t;s.blendMode.pushBlendMode(this,this.groupBlendMode,e);const o=s[this.renderPipeId];o!=null&&o.addRenderable&&o.addRenderable(this,e),this.didViewUpdate=!1;const a=this.children,c=a.length;for(let l=0;l<c;l++)a[l].collectRenderables(e,t,n);s.blendMode.popBlendMode(e)}}class nr extends ii{constructor(e=D.EMPTY){e instanceof D&&(e={texture:e});const{texture:t=D.EMPTY,anchor:n,roundPixels:s,width:i,height:o,...a}=e;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Ce({_onUpdate:()=>{this.onViewUpdate()}}),n?this.anchor=n:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=s??!1,i!==void 0&&(this.width=i),o!==void 0&&(this.height=o)}static from(e,t=!1){return e instanceof D?new nr(e):new nr(D.from(e,t))}set texture(e){e||(e=D.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return $0(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return N("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,t=this._texture,n=this._bounds,{width:s,height:i}=t.orig;n.minX=-e._x*s,n.maxX=n.minX+s,n.minY=-e._y*i,n.maxY=n.minY+i}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const n=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(n)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}const V0=new Pe;function wl(r,e,t){const n=V0;r.measurable=!0,Xs(r,t,n),e.addBoundsMask(n),r.measurable=!1}function Pl(r,e,t){const n=gt.get();r.measurable=!0;const s=ke.get().identity(),i=El(r,t,s);Zs(r,n,i),r.measurable=!1,e.addBoundsMask(n),ke.return(s),gt.return(n)}function El(r,e,t){return r?(r!==e&&(El(r.parent,e,t),r.updateLocalTransform(),t.append(r.localTransform)),t):(W("Mask bounds, renderable is not inside the root container"),t)}class Cl{constructor(e){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof nr),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(e,t){this.inverse||wl(this.mask,e,t)}addLocalBounds(e,t){Pl(this.mask,e,t)}containsPoint(e,t){const n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof nr}}Cl.extension=x.MaskEffect;class Ml{constructor(e){this.priority=0,this.pipe="colorMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}Ml.extension=x.MaskEffect;class Al{constructor(e){this.priority=0,this.pipe="stencilMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,t){wl(this.mask,e,t)}addLocalBounds(e,t){Pl(this.mask,e,t)}containsPoint(e,t){const n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof Ie}}Al.extension=x.MaskEffect;let kl={createCanvas:(r,e)=>{const t=document.createElement("canvas");return t.width=r,t.height=e,t},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,e)=>fetch(r,e),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};const te={get(){return kl},set(r){kl=r}};class ot extends ve{constructor(e){e.resource||(e.resource=te.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(e=this.width,t=this.height,n=this._resolution){const s=super.resize(e,t,n);return s&&this.resizeCanvas(),s}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}ot.extension=x.TextureSource;class Dn extends ve{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}Dn.extension=x.TextureSource;var sr=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(sr||{});class oi{constructor(e,t=null,n=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=n,this._once=s}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));const 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);const t=this.next;return this.next=e?null:t,this.previous=null,t}}const Rl=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 oi(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=sr.NORMAL){return this._addListener(new oi(e,t,n))}addOnce(e,t,n=sr.NORMAL){return this._addListener(new oi(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.match(e,t)?n=n.destroy():n=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(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const i=e-this._lastFrame|0;if(i<this._minElapsedMS)return;this._lastFrame=e-i%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*$e.targetFPMS;const n=this._head;let s=n.next;for(;s;)s=s.emit(this);n.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(Math.max(0,e)/1e3,$e.targetFPMS);this._maxElapsedMS=1/t,this._minElapsedMS&&e>this.maxFPS&&(this.maxFPS=e)}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){const e=$e._shared=new $e;e.autoStart=!0,e._protected=!0}return $e._shared}static get system(){if(!$e._system){const e=$e._system=new $e;e.autoStart=!0,e._protected=!0}return $e._system}};Rl.targetFPMS=.06;let Xe=Rl,ai;async function H0(){return ai??(ai=(async()=>{var o;const e=te.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const t=await new Promise(a=>{const c=document.createElement("video");c.onloadeddata=()=>a(c),c.onerror=()=>a(null),c.autoplay=!1,c.crossOrigin="anonymous",c.preload="auto",c.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",c.load()});if(!t)return"premultiply-alpha-on-upload";const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);const s=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const i=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,i),e.deleteFramebuffer(s),e.deleteTexture(n),(o=e.getExtension("WEBGL_lose_context"))==null||o.loseContext(),i[0]<=i[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ai}const Un=class af extends ve{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...af.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=Xe.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.isValid||e.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await H0(),this._load=new Promise((n,s)=>{this.isValid?n(this):(this._resolve=n,this._reject=s,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("loadedmetadata",this._onLoadedMetadata),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Xe.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Xe.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Xe.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Un.extension=x.TextureSource,Un.defaultOptions={...ve.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},Un.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let j0=Un;const ir=(r,e,t=!1)=>(Array.isArray(r)||(r=[r]),e?r.map(n=>typeof n=="string"||t?e(n):n):r);class W0{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||W(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const n=ir(e);let s;for(let c=0;c<this.parsers.length;c++){const l=this.parsers[c];if(l.test(t)){s=l.getCacheableAssets(n,t);break}}const i=new Map(Object.entries(s||{}));s||n.forEach(c=>{i.set(c,t)});const o=[...i.keys()],a={cacheKeys:o,keys:n};n.forEach(c=>{this._cacheMap.set(c,a)}),o.forEach(c=>{const l=s?s[c]:t;this._cache.has(c)&&this._cache.get(c)!==l&&W("[Cache] already has key:",c),this._cache.set(c,i.get(c))})}remove(e){if(!this._cacheMap.has(e)){W(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(s=>{this._cache.delete(s)}),t.keys.forEach(s=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}const or=new W0,ci=[];H.handleByList(x.TextureSource,ci);function Il(r={}){const e=r&&r.resource,t=e?r.resource:r,n=e?r:{resource:r};for(let s=0;s<ci.length;s++){const i=ci[s];if(i.test(t))return new i(n)}throw new Error(`Could not find a source type for resource: ${n.resource}`)}function X0(r={},e=!1){const t=r&&r.resource,n=t?r.resource:r,s=t?r:{resource:r};if(!e&&or.has(n))return or.get(n);const i=new D({source:Il(s)});return i.on("destroy",()=>{or.has(n)&&or.remove(n)}),e||or.set(n,i),i}function Y0(r,e=!1){return typeof r=="string"?or.get(r):r instanceof ve?new D({source:r}):X0(r,e)}D.from=Y0,ve.from=Il,H.add(Cl,Ml,Al,j0,Dn,ot,Js);var Bl=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Bl||{});function tt(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function Or(r){return r.split("?")[0].split("#")[0]}function Z0(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K0(r,e,t){return r.replace(new RegExp(Z0(e),"g"),t)}function q0(r,e){let t="",n=0,s=-1,i=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(t.length<2||n!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const c=t.lastIndexOf("/");if(c!==t.length-1){c===-1?(t="",n=0):(t=t.slice(0,c),n=t.length-1-t.lastIndexOf("/")),s=a,i=0;continue}}else if(t.length===2||t.length===1){t="",n=0,s=a,i=0;continue}}}else t.length>0?t+=`/${r.slice(s+1,a)}`:t=r.slice(s+1,a),n=a-s-1;s=a,i=0}else o===46&&i!==-1?++i:i=-1}return t}const Dr={toPosix(r){return K0(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){tt(r),r=this.toPosix(r);const e=/^file:\/\/\//.exec(r);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(r);return t?t[0]:""},toAbsolute(r,e,t){if(tt(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const n=Or(this.toPosix(e??te.get().getBaseUrl())),s=Or(this.toPosix(t??this.rootname(n)));return r=this.toPosix(r),r.startsWith("/")?Dr.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(n,r)},normalize(r){if(tt(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let e="";const t=r.startsWith("/");this.hasProtocol(r)&&(e=this.rootname(r),r=r.slice(e.length));const n=r.endsWith("/");return r=q0(r),r.length>0&&n&&(r+="/"),t?`/${r}`:e+r},isAbsolute(r){return tt(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){const n=r[t];if(tt(n),n.length>0)if(e===void 0)e=n;else{const s=r[t-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${n}`:e+=`/${n}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(tt(r),r.length===0)return".";r=this.toPosix(r);let e=r.charCodeAt(0);const t=e===47;let n=-1,s=!0;const i=this.getProtocol(r),o=r;r=r.slice(i.length);for(let a=r.length-1;a>=1;--a)if(e=r.charCodeAt(a),e===47){if(!s){n=a;break}}else s=!1;return n===-1?t?"/":this.isUrl(o)?i+r:i:t&&n===1?"//":i+r.slice(0,n)},rootname(r){tt(r),r=this.toPosix(r);let e="";if(r.startsWith("/")?e="/":e=this.getProtocol(r),this.isUrl(r)){const t=r.indexOf("/",e.length);t!==-1?e=r.slice(0,t):e=r,e.endsWith("/")||(e+="/")}return e},basename(r,e){tt(r),e&&tt(e),r=Or(this.toPosix(r));let t=0,n=-1,s=!0,i;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e.length===r.length&&e===r)return"";let o=e.length-1,a=-1;for(i=r.length-1;i>=0;--i){const c=r.charCodeAt(i);if(c===47){if(!s){t=i+1;break}}else a===-1&&(s=!1,a=i+1),o>=0&&(c===e.charCodeAt(o)?--o===-1&&(n=i):(o=-1,n=a))}return t===n?n=a:n===-1&&(n=r.length),r.slice(t,n)}for(i=r.length-1;i>=0;--i)if(r.charCodeAt(i)===47){if(!s){t=i+1;break}}else n===-1&&(s=!1,n=i+1);return n===-1?"":r.slice(t,n)},extname(r){tt(r),r=Or(this.toPosix(r));let e=-1,t=0,n=-1,s=!0,i=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){t=o+1;break}continue}n===-1&&(s=!1,n=o+1),a===46?e===-1?e=o:i!==1&&(i=1):e!==-1&&(i=-1)}return e===-1||n===-1||i===0||i===1&&e===n-1&&e===t+1?"":r.slice(e,n)},parse(r){tt(r);const e={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return e;r=Or(this.toPosix(r));let t=r.charCodeAt(0);const n=this.isAbsolute(r);let s;e.root=this.rootname(r),n||this.hasProtocol(r)?s=1:s=0;let i=-1,o=0,a=-1,c=!0,l=r.length-1,u=0;for(;l>=s;--l){if(t=r.charCodeAt(l),t===47){if(!c){o=l+1;break}continue}a===-1&&(c=!1,a=l+1),t===46?i===-1?i=l:u!==1&&(u=1):i!==-1&&(u=-1)}return i===-1||a===-1||u===0||u===1&&i===a-1&&i===o+1?a!==-1&&(o===0&&n?e.base=e.name=r.slice(1,a):e.base=e.name=r.slice(o,a)):(o===0&&n?(e.name=r.slice(1,i),e.base=r.slice(1,a)):(e.name=r.slice(o,i),e.base=r.slice(o,a)),e.ext=r.slice(i,a)),e.dir=this.dirname(r),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function Fl(r,e,t,n,s){const i=e[t];for(let o=0;o<i.length;o++){const a=i[o];t<e.length-1?Fl(r.replace(n[t],a),e,t+1,n,s):s.push(r.replace(n[t],a))}}function J0(r){const e=/\{(.*?)\}/g,t=r.match(e),n=[];if(t){const s=[];t.forEach(i=>{const o=i.substring(1,i.length-1).split(",");s.push(o)}),Fl(r,s,0,t,n)}else n.push(r);return n}const Gl=r=>!Array.isArray(r);class Ol{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(n=>`${encodeURIComponent(n)}=${encodeURIComponent(t[n])}`).join("&")}}getAlias(e){const{alias:t,src:n}=e;return ir(t||n,i=>typeof i=="string"?i:Array.isArray(i)?i.map(o=>(o==null?void 0:o.src)??o):i!=null&&i.src?i.src:i,!0)}removeAlias(e,t){this._assetMap[e]&&(t&&t!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&W("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const n=[];let s=t;Array.isArray(t)||(s=Object.entries(t).map(([i,o])=>typeof o=="string"||Array.isArray(o)?{alias:i,src:o}:{alias:i,...o})),s.forEach(i=>{const o=i.src,a=i.alias;let c;if(typeof a=="string"){const l=this._createBundleAssetId(e,a);n.push(l),c=[a,l]}else{const l=a.map(u=>this._createBundleAssetId(e,u));n.push(...l),c=[...a,...l]}this.add({...i,alias:c,src:o})}),this._bundles[e]=n}add(e){const t=[];Array.isArray(e)?t.push(...e):t.push(e);let n;n=i=>{this.hasKey(i)&&W(`[Resolver] already has key: ${i} overwriting`)},ir(t).forEach(i=>{const{src:o}=i;let{data:a,format:c,loadParser:l,parser:u}=i;const h=ir(o).map(m=>typeof m=="string"?J0(m):Array.isArray(m)?m:[m]),d=this.getAlias(i);Array.isArray(d)?d.forEach(n):n(d);const f=[],p=m=>{const g=this._parsers.find(_=>_.test(m));return{src:m,...g==null?void 0:g.parse(m)}};h.forEach(m=>{m.forEach(g=>{let _={};if(typeof g!="object"?_=p(g):(a=g.data??a,c=g.format??c,(g.loadParser||g.parser)&&(l=g.loadParser??l,u=g.parser??u),_={...p(g.src),...g}),!d)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this._buildResolvedAsset(_,{aliases:d,data:a,format:c,loadParser:l,parser:u,progressSize:i.progressSize}),f.push(_)})}),d.forEach(m=>{this._assetMap[m]=f})})}resolveBundle(e){const t=Gl(e);e=ir(e);const n={};return e.forEach(s=>{const i=this._bundles[s];if(i){const o=this.resolve(i),a={};for(const c in o){const l=o[c];a[this._extractAssetIdFromBundle(s,c)]=l}n[s]=a}}),t?n[e[0]]:n}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const n={};for(const s in t)n[s]=t[s].src;return n}return t.src}resolve(e){const t=Gl(e);e=ir(e);const n={};return e.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let i=this._assetMap[s];const o=this._getPreferredOrder(i);o==null||o.priority.forEach(a=>{o.params[a].forEach(c=>{const l=i.filter(u=>u[a]?u[a]===c:!1);l.length&&(i=l)})}),this._resolverHash[s]=i[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});n[s]=this._resolverHash[s]}),t?n[e[0]]:n}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const n=e[t],s=this._preferredOrder.find(i=>i.params.format.includes(n.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){const{aliases:n,data:s,loadParser:i,parser:o,format:a,progressSize:c}=t;return(this._basePath||this._rootPath)&&(e.src=Dr.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=n??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=i??e.loadParser,e.parser=o??e.parser,e.format=a??e.format??Q0(e.src),c!==void 0&&(e.progressSize=c),e}}Ol.RETINA_PREFIX=/@([0-9\.]+)x/;function Q0(r){return r.split(".").pop().split("?").shift().split("#").shift()}const Dl=(r,e)=>{const t=e.split("?")[1];return t&&(r+=`?${t}`),r},Ul=class Qr{constructor(e,t){this.linkedSheets=[];let n=e;(e==null?void 0:e.source)instanceof ve&&(n={texture:e,data:t});const{texture:s,data:i,cachePrefix:o=""}=n;this.cachePrefix=o,this._texture=s instanceof D?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=i;const a=parseFloat(i.meta.scale);a?(this.resolution=a,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Qr.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,t=!1){let n=e;const s=t?1/0:Qr.BATCH_SIZE;for(;n-e<s&&n<this._frameKeys.length;){const i=this._frameKeys[n],o=this._frames[i],a=o.frame;if(a){let c=null,l=null;const u=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,h=new fe(0,0,Math.floor(u.w)/this.resolution,Math.floor(u.h)/this.resolution);o.rotated?c=new fe(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):c=new fe(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(l=new fe(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[i]=new D({source:this.textureSource,frame:c,orig:h,trim:l,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:i.toString()})}n++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let n=0;n<e[t].length;n++){const s=e[t][n];this.animations[t].push(this.textures[s])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Qr.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Qr.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var t;for(const n in this.textures)this.textures[n].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((t=this._texture)==null||t.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Ul.BATCH_SIZE=1e3;let Ll=Ul;const eT=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function zl(r,e,t){const n={};if(r.forEach(s=>{n[s]=e}),Object.keys(e.textures).forEach(s=>{n[`${e.cachePrefix}${s}`]=e.textures[s]}),!t){const s=Dr.dirname(r[0]);e.linkedSheets.forEach((i,o)=>{const a=zl([`${s}/${e.data.meta.related_multi_packs[o]}`],i,!0);Object.assign(n,a)})}return n}const tT={extension:x.Asset,cache:{test:r=>r instanceof Ll,getCacheableAssets:(r,e)=>zl(r,e,!1)},resolver:{extension:{type:x.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),n=t.pop(),s=t.pop();return n==="json"&&eT.includes(s)},parse:r=>{var t;const e=r.split(".");return{resolution:parseFloat(((t=Ol.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:e[e.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:x.LoadParser,priority:Bl.Normal,name:"spritesheetLoader"},async testParse(r,e){return Dr.extname(e.src).toLowerCase()===".json"&&!!r.frames},async parse(r,e,t){var h,d;const{texture:n,imageFilename:s,textureOptions:i,cachePrefix:o}=(e==null?void 0:e.data)??{};let a=Dr.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let c;if(n instanceof D)c=n;else{const f=Dl(a+(s??r.meta.image),e.src);c=(await t.load([{src:f,data:i}]))[f]}const l=new Ll({texture:c.source,data:r,cachePrefix:o});await l.parse();const u=(h=r==null?void 0:r.meta)==null?void 0:h.related_multi_packs;if(Array.isArray(u)){const f=[];for(const m of u){if(typeof m!="string")continue;let g=a+m;(d=e.data)!=null&&d.ignoreMultiPack||(g=Dl(g,e.src),f.push(t.load({src:g,data:{textureOptions:i,ignoreMultiPack:!0}})))}const p=await Promise.all(f);l.linkedSheets=p,p.forEach(m=>{m.linkedSheets=[l].concat(l.linkedSheets.filter(g=>g!==m))})}return l},async unload(r,e,t){await t.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};H.add(tT);class Nl{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),n=this._canvas.width,s=this._canvas.height,i=t.width/n*this._renderer.resolution,o=t.height/s*this._renderer.resolution,a=t.left,c=t.top,l=`translate(${a}px, ${c}px) scale(${i}, ${o})`;l!==this._lastTransform&&(this._domElement.style.transform=l,this._lastTransform=l)},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(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const n=this.canvas.width,s=this.canvas.height,i=t.contentRect.width/n*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==i||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=i,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||Xe.shared.add(this.updateTranslation,this,sr.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Xe.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class Ur{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ur.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new le,this.page=new le,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}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 new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,n,s,i){throw new 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}}var li=/iPhone/i,$l=/iPod/i,Vl=/iPad/i,Hl=/\biOS-universal(?:.+)Mac\b/i,ui=/\bAndroid(?:.+)Mobile\b/i,jl=/Android/i,ar=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ln=/Silk/i,_t=/Windows Phone/i,Wl=/\bWindows(?:.+)ARM\b/i,Xl=/BlackBerry/i,Yl=/BB10/i,Zl=/Opera Mini/i,Kl=/\b(CriOS|Chrome)(?:.+)Mobile/i,ql=/Mobile(?:.+)Firefox\b/i,Jl=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function rT(r){return function(e){return e.test(r)}}function Ql(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,n=t.split("[FBAN");typeof n[1]<"u"&&(t=n[0]),n=t.split("Twitter"),typeof n[1]<"u"&&(t=n[0]);var s=rT(t),i={apple:{phone:s(li)&&!s(_t),ipod:s($l),tablet:!s(li)&&(s(Vl)||Jl(e))&&!s(_t),universal:s(Hl),device:(s(li)||s($l)||s(Vl)||s(Hl)||Jl(e))&&!s(_t)},amazon:{phone:s(ar),tablet:!s(ar)&&s(Ln),device:s(ar)||s(Ln)},android:{phone:!s(_t)&&s(ar)||!s(_t)&&s(ui),tablet:!s(_t)&&!s(ar)&&!s(ui)&&(s(Ln)||s(jl)),device:!s(_t)&&(s(ar)||s(Ln)||s(ui)||s(jl))||s(/\bokhttp\b/i)},windows:{phone:s(_t),tablet:s(Wl),device:s(_t)||s(Wl)},other:{blackberry:s(Xl),blackberry10:s(Yl),opera:s(Zl),firefox:s(ql),chrome:s(Kl),device:s(Xl)||s(Yl)||s(Zl)||s(ql)||s(Kl)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}const nT=(Ql.default??Ql)(globalThis.navigator),sT=9,eu=100,iT=0,oT=0,tu=2,ru=1,aT=-1e3,cT=-1e3,lT=2,hi=class cf{constructor(e,t=nT){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(){const e=document.createElement("button");e.style.width=`${ru}px`,e.style.height=`${ru}px`,e.style.position="absolute",e.style.top=`${aT}px`,e.style.left=`${cT}px`,e.style.zIndex=lT.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),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=`${iT}px`,this._div.style.left=`${oT}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=tu.toString(),this._canvasObserver=new Nl({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const 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(){var e,t;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(const n of this._children)(e=n._accessibleDiv)!=null&&e.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1;for(const n in this._pools)this._pools[n].forEach(i=>{i.parentNode&&i.parentNode.removeChild(i)}),delete this._pools[n];(t=this._div)!=null&&t.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);const t=e.children;if(t)for(let n=0;n<t.length;n++)this._updateAccessibleObjects(t[n])}init(e){const n={accessibilityOptions:{...cf.defaultOptions,...(e==null?void 0:e.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(){const 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;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const n of this._children)n._renderId===this._renderId&&t.add(this._children.indexOf(n))}for(let n=this._children.length-1;n>=0;n--){const s=this._children[n];t.has(n)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,tl(this._children,n,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let n=0;n<this._children.length;n++){const s=this._children[n];if(!s._accessibleActive||!s._accessibleDiv)continue;const i=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const a=s.worldTransform;i.style.left=`${a.tx+o.x*a.a}px`,i.style.top=`${a.ty+o.y*a.d}px`,i.style.width=`${o.width*a.a}px`,i.style.height=`${o.height*a.d}px`}else this._capHitArea(o),i.style.left=`${o.x}px`,i.style.top=`${o.y}px`,i.style.width=`${o.width}px`,i.style.height=`${o.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);const{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 n=this._getPool(e.accessibleType).pop();n?(n.innerHTML="",n.removeAttribute("title"),n.removeAttribute("aria-label"),n.tabIndex=0):(e.accessibleType==="button"?n=document.createElement("button"):(n=document.createElement(e.accessibleType),n.style.cssText=`
362
+ color: transparent;
363
+ pointer-events: none;
364
+ padding: 0;
365
+ margin: 0;
366
+ border: 0;
367
+ outline: 0;
368
+ background: transparent;
369
+ box-sizing: border-box;
370
+ user-select: none;
371
+ -webkit-user-select: none;
372
+ -moz-user-select: none;
373
+ -ms-user-select: none;
374
+ `,e.accessibleText&&(n.innerText=e.accessibleText)),n.style.width=`${eu}px`,n.style.height=`${eu}px`,n.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",n.style.position="absolute",n.style.zIndex=tu.toString(),n.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?n.setAttribute("aria-live","off"):n.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?n.setAttribute("aria-relevant","additions"):n.setAttribute("aria-relevant","text"),n.addEventListener("click",this._onClick.bind(this)),n.addEventListener("focus",this._onFocus.bind(this)),n.addEventListener("focusout",this._onFocusOut.bind(this))),n.style.pointerEvents=e.accessiblePointerEvents,n.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?n.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(n.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&n.setAttribute("aria-label",e.accessibleHint),e.interactive?n.tabIndex=e.tabIndex:n.tabIndex=0,this.debug&&this._updateDebugHTML(n),e._accessibleActive=!0,e._accessibleDiv=n,n.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv)}_dispatchEvent(e,t){const{container:n}=e.target,s=this._renderer.events.rootBoundary,i=Object.assign(new Ur(s),{target:n});s.rootTarget=this._renderer.lastObjectRendered,t.forEach(o=>s.dispatchEvent(i,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode!==sT||!this._activateOnTab||this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){var e;this._deactivate(),this._destroyTouchHook(),(e=this._canvasObserver)==null||e.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(e){e?this._activate():this._deactivate()}_getPool(e){return this._pools[e]||(this._pools[e]=[]),this._pools[e]}};hi.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"accessibility"},hi.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let uT=hi;const hT={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};let cr;function nu(){return(!cr||cr!=null&&cr.isContextLost())&&(cr=te.get().createCanvas().getContext("webgl",{})),cr}let zn;function dT(){if(!zn){zn="mediump";const r=nu();r&&r.getShaderPrecisionFormat&&(zn=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return zn}function fT(r,e,t){return e?r:t?(r=r.replace("out vec4 finalColor;",""),`
375
+
376
+ #ifdef GL_ES // This checks if it is WebGL1
377
+ #define in varying
378
+ #define finalColor gl_FragColor
379
+ #define texture texture2D
380
+ #endif
381
+ ${r}
382
+ `):`
383
+
384
+ #ifdef GL_ES // This checks if it is WebGL1
385
+ #define in attribute
386
+ #define out varying
387
+ #endif
388
+ ${r}
389
+ `}function pT(r,e,t){const n=t?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let s=t?e.requestedFragmentPrecision:e.requestedVertexPrecision;return s==="highp"&&n!=="highp"&&(s="mediump"),`precision ${s} float;
390
+ ${r}`}else if(n!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function mT(r,e){return e?`#version 300 es
391
+ ${r}`:r}const gT={},_T={};function yT(r,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";const n=t?gT:_T;return n[e]?(n[e]++,e+=`-${n[e]}`):n[e]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${e}`}
392
+ ${r}`}function bT(r,e){return e?r.replace("#version 300 es",""):r}const di={stripVersion:bT,ensurePrecision:pT,addProgramDefines:fT,setProgramName:yT,insertVersion:mT},Lr=Object.create(null),su=class ko{constructor(e){e={...ko.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,n={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:dT()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let s=e.fragment,i=e.vertex;Object.keys(di).forEach(o=>{const a=n[o];s=di[o](s,a,!0),i=di[o](i,a,!1)}),this.fragment=s,this.vertex=i,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=Mr(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,Lr[this._cacheKey]=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return Lr[t]||(Lr[t]=new ko(e),Lr[t]._cacheKey=t),Lr[t]}};su.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Ot=su;const xT={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},iu=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function ou(r,e){let t;for(;(t=iu.exec(r))!==null;){const n=xT[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:n,stride:pt(n).stride,offset:0,instance:!1,start:0}}iu.lastIndex=0}function vT(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function TT({source:r,entryPoint:e}){const t={},n=vT(r),s=n.indexOf(`fn ${e}(`);if(s===-1)return t;const i=n.indexOf("->",s);if(i===-1)return t;const o=n.substring(s,i);if(ou(o,t),Object.keys(t).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const c=a[1],l=new RegExp(`struct\\s+${c}\\s*\\{([^}]+)\\}`,"s"),u=n.match(l);u&&ou(u[1],t)}}return t}function fi(r){var h,d;const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,n=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,i=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,l=(h=r.match(e))==null?void 0:h.map(f=>({group:parseInt(f.match(t)[1],10),binding:parseInt(f.match(n)[1],10),name:f.match(s)[2],isUniform:f.match(s)[1]==="<uniform>",type:f.match(i)[1]}));if(!l)return{groups:[],structs:[]};const u=((d=r.match(o))==null?void 0:d.map(f=>{const p=f.match(c)[1],m=f.match(a).reduce((g,_)=>{const[y,b]=_.split(":");return g[y.trim()]=b.trim(),g},{});return m?{name:p,members:m}:null}).filter(({name:f})=>l.some(p=>p.type===f||p.type.includes(`<${f}>`))))??[];return{groups:l,structs:u}}var Dt=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Dt||{});function ST({groups:r}){const e=[];for(let t=0;t<r.length;t++){const n=r[t];e[n.group]||(e[n.group]=[]),n.isUniform?e[n.group].push({binding:n.binding,visibility:Dt.VERTEX|Dt.FRAGMENT,buffer:{type:"uniform"}}):n.type==="sampler"?e[n.group].push({binding:n.binding,visibility:Dt.FRAGMENT,sampler:{type:"filtering"}}):n.type==="texture_2d"||n.type.startsWith("texture_2d<")?e[n.group].push({binding:n.binding,visibility:Dt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):n.type==="texture_2d_array"||n.type.startsWith("texture_2d_array<")?e[n.group].push({binding:n.binding,visibility:Dt.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(n.type==="texture_cube"||n.type.startsWith("texture_cube<"))&&e[n.group].push({binding:n.binding,visibility:Dt.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}function wT({groups:r}){const e=[];for(let t=0;t<r.length;t++){const n=r[t];e[n.group]||(e[n.group]={}),e[n.group][n.name]=n.binding}return e}function PT(r,e){const t=new Set,n=new Set,s=[...r.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),i=[...r.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return n.has(a)?!1:(n.add(a),!0)});return{structs:s,groups:i}}const zr=Object.create(null);class Ut{constructor(e){var a,c;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:t,vertex:n,layout:s,gpuLayout:i,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=n,t.source===n.source){const l=fi(t.source);this.structsAndGroups=l}else{const l=fi(n.source),u=fi(t.source);this.structsAndGroups=PT(l,u)}this.layout=s??wT(this.structsAndGroups),this.gpuLayout=i??ST(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((c=this.layout[1])==null?void 0:c.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:e,fragment:t}=this,n=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=Mr(n,"program")}get attributeData(){return this._attributeData??(this._attributeData=TT(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,zr[this._cacheKey]=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return zr[t]||(zr[t]=new Ut(e),zr[t]._cacheKey=t),zr[t]}}class yt{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(const n in e){const s=e[n];this.setResource(s,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const e=[];let t=0;for(const n in this.resources)e[t++]=this.resources[n]._resourceId;this._key=e.join("|")}setResource(e,t){var s,i;const n=this.resources[t];e!==n&&((s=n==null?void 0:n.off)==null||s.call(n,"change",this.onResourceChange,this),(i=e.on)==null||i.call(e,"change",this.onResourceChange,this),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e,t){const n=this.resources;for(const s in n)n[s]._gcLastUsed=e,n[s]._touched=t}destroy(){var t;const e=this.resources;for(const n in e){const s=e[n];(t=s==null?void 0:s.off)==null||t.call(s,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(e){this._dirty=!0,e.destroyed?this.destroy():this._updateKey()}}var at=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(at||{});class bt extends Qe{constructor(e){super(),this.uid=ce("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:n,groups:s,resources:i,compatibleRenderers:o,groupMap:a}=e;this.gpuProgram=t,this.glProgram=n,o===void 0&&(o=0,t&&(o|=at.WEBGPU),n&&(o|=at.WEBGL)),this.compatibleRenderers=o;const c={};if(!i&&!s&&(i={}),i&&s)throw new Error("[Shader] Cannot have both resources and groups");if(!t&&s&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!t&&s&&a)for(const l in a)for(const u in a[l]){const h=a[l][u];c[h]={group:l,binding:u,name:h}}else if(t&&s&&!a){const l=t.structsAndGroups.groups;a={},l.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,c[u.name]=u})}else if(i){s={},a={},t&&t.structsAndGroups.groups.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,c[h.name]=h});let l=0;for(const u in i)c[u]||(s[99]||(s[99]=new yt,this._ownedBindGroups.push(s[99])),c[u]={group:99,binding:l,name:u},a[99]=a[99]||{},a[99][l]=u,l++);for(const u in i){const h=u;let d=i[u];!d.source&&!d._resourceType&&(d=new je(d));const f=c[h];f&&(s[f.group]||(s[f.group]=new yt,this._ownedBindGroups.push(s[f.group])),s[f.group].setResource(d,f.binding))}}this.groups=s,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(s,c)}addResource(e,t,n){var s,i;(s=this._uniformBindMap)[t]||(s[t]={}),(i=this._uniformBindMap[t])[n]||(i[n]=e),this.groups[t]||(this.groups[t]=new yt,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){const n={};for(const s in t){const i=t[s];Object.defineProperty(n,i.name,{get(){return e[i.group].getResource(i.binding)},set(o){e[i.group].setResource(o,i.binding)}})}return n}destroy(e=!1){var t,n;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&((t=this.gpuProgram)==null||t.destroy(),(n=this.glProgram)==null||n.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(s=>{s.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(e){const{gpu:t,gl:n,...s}=e;let i,o;return t&&(i=Ut.from(t)),n&&(o=Ot.from(n)),new bt({gpuProgram:i,glProgram:o,...s})}}const ET={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},pi=0,mi=1,gi=2,_i=3,yi=4,bi=5,xi=class lf{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<pi)}set blend(e){!!(this.data&1<<pi)!==e&&(this.data^=1<<pi)}get offsets(){return!!(this.data&1<<mi)}set offsets(e){!!(this.data&1<<mi)!==e&&(this.data^=1<<mi)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<gi)}set culling(e){!!(this.data&1<<gi)!==e&&(this.data^=1<<gi)}get depthTest(){return!!(this.data&1<<_i)}set depthTest(e){!!(this.data&1<<_i)!==e&&(this.data^=1<<_i)}get depthMask(){return!!(this.data&1<<bi)}set depthMask(e){!!(this.data&1<<bi)!==e&&(this.data^=1<<bi)}get clockwiseFrontFace(){return!!(this.data&1<<yi)}set clockwiseFrontFace(e){!!(this.data&1<<yi)!==e&&(this.data^=1<<yi)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=ET[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new lf;return e.depthTest=!1,e.blend=!0,e}};xi.default2d=xi.for2d();let ct=xi;const au=class Ro extends bt{constructor(e){e={...Ro.defaultOptions,...e},super(e),this.enabled=!0,this._state=ct.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,n,s){e.applyFilter(this,t,n,s)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:n,...s}=e;let i,o;return t&&(i=Ut.from(t)),n&&(o=Ot.from(n)),new Ro({gpuProgram:i,glProgram:o,...s})}};au.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let vi=au,Nn;function CT(r){return Nn!==void 0||(Nn=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r??er.defaultOptions.failIfMajorPerformanceCaveat};try{if(!te.get().getWebGLRenderingContext())return!1;let s=te.get().createCanvas().getContext("webgl",e);const i=!!((t=s==null?void 0:s.getContextAttributes())!=null&&t.stencil);if(s){const o=s.getExtension("WEBGL_lose_context");o&&o.loseContext()}return s=null,i}catch{return!1}})()),Nn}let $n;async function MT(r={}){return $n!==void 0||($n=await(async()=>{const e=te.get().getNavigator().gpu;if(!e)return!1;try{return await(await e.requestAdapter(r)).requestDevice(),!0}catch{return!1}})()),$n}const cu=["webgl","webgpu","canvas"];async function AT(r){let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),cu.forEach(i=>{i!==r.preference&&e.push(i)})):e=cu.slice();let t,n={};for(let i=0;i<e.length;i++){const o=e[i];if(o==="webgpu"&&await MT()){const{WebGPURenderer:a}=await Promise.resolve().then(()=>EP);t=a,n={...r,...r.webgpu};break}else if(o==="webgl"&&CT(r.failIfMajorPerformanceCaveat??er.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await Promise.resolve().then(()=>aP);t=a,n={...r,...r.webgl};break}else if(o==="canvas"){const{CanvasRenderer:a}=await Promise.resolve().then(()=>T1);t=a,n={...r,...r.canvasOptions};break}}if(delete n.webgpu,delete n.webgl,delete n.canvasOptions,!t)throw new Error("No available renderer for the current environment");const s=new t;return await s.init(n),s}const Vn="8.18.1";class lu{static init(){var e;(e=globalThis.__PIXI_APP_INIT__)==null||e.call(globalThis,this,Vn)}static destroy(){}}lu.extension=x.Application;class uu{constructor(e){this._renderer=e}init(){var e;(e=globalThis.__PIXI_RENDERER_INIT__)==null||e.call(globalThis,this._renderer,Vn)}destroy(){this._renderer=null}}uu.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"initHook",priority:-10};class hu{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let t,n;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,n=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:i}=this._resizeTo;t=s,n=i}this.renderer.resize(t,n),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}hu.extension=x.Application;class du{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{configurable:!0,set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,sr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?Xe.shared:new Xe,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}du.extension=x.Application,H.add(hu),H.add(du);const fu=class Io{constructor(...e){this.stage=new Ie,e[0]!==void 0&&N(de,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.stage||(this.stage=new Ie),this.renderer=await AT(e),Io._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return N(de,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var e;return(e=this.renderer.renderPipes.dom)==null?void 0:e._domElement}destroy(e=!1,t=!1){const n=Io._plugins.slice(0);n.reverse(),n.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(t),this.stage=null,this.renderer.destroy(e),this.renderer=null}};fu._plugins=[];let pu=fu;H.handleByList(x.Application,pu._plugins),H.add(lu);var Ti,mu;function kT(){if(mu)return Ti;mu=1,Ti=t;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function t(i){var o=[];return i.replace(e,function(a,c,l){var u=c.toLowerCase();for(l=s(l),u=="m"&&l.length>2&&(o.push([c].concat(l.splice(0,2))),u="l",c=c=="m"?"l":"L");;){if(l.length==r[u])return l.unshift(c),o.push(l);if(l.length<r[u])throw new Error("malformed path data");o.push([c].concat(l.splice(0,r[u])))}}),o}var n=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function s(i){var o=i.match(n);return o?o.map(Number):[]}return Ti}var RT=kT();const IT=Ec(RT);function BT(r,e){const t=IT(r),n=[];let s=null,i=0,o=0;for(let a=0;a<t.length;a++){const c=t[a],l=c[0],u=c;switch(l){case"M":i=u[1],o=u[2],e.moveTo(i,o);break;case"m":i+=u[1],o+=u[2],e.moveTo(i,o);break;case"H":i=u[1],e.lineTo(i,o);break;case"h":i+=u[1],e.lineTo(i,o);break;case"V":o=u[1],e.lineTo(i,o);break;case"v":o+=u[1],e.lineTo(i,o);break;case"L":i=u[1],o=u[2],e.lineTo(i,o);break;case"l":i+=u[1],o+=u[2],e.lineTo(i,o);break;case"C":i=u[5],o=u[6],e.bezierCurveTo(u[1],u[2],u[3],u[4],i,o);break;case"c":e.bezierCurveTo(i+u[1],o+u[2],i+u[3],o+u[4],i+u[5],o+u[6]),i+=u[5],o+=u[6];break;case"S":i=u[3],o=u[4],e.bezierCurveToShort(u[1],u[2],i,o);break;case"s":e.bezierCurveToShort(i+u[1],o+u[2],i+u[3],o+u[4]),i+=u[3],o+=u[4];break;case"Q":i=u[3],o=u[4],e.quadraticCurveTo(u[1],u[2],i,o);break;case"q":e.quadraticCurveTo(i+u[1],o+u[2],i+u[3],o+u[4]),i+=u[3],o+=u[4];break;case"T":i=u[1],o=u[2],e.quadraticCurveToShort(i,o);break;case"t":i+=u[1],o+=u[2],e.quadraticCurveToShort(i,o);break;case"A":i=u[6],o=u[7],e.arcToSvg(u[1],u[2],u[3],u[4],u[5],i,o);break;case"a":i+=u[6],o+=u[7],e.arcToSvg(u[1],u[2],u[3],u[4],u[5],i,o);break;case"Z":case"z":e.closePath(),n.length>0&&(s=n.pop(),s?(i=s.startX,o=s.startY):(i=0,o=0)),s=null;break;default:W(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&s===null&&(s={startX:i,startY:o},n.push(s))}return e}class Si{constructor(e=0,t=0,n=0){this.type="circle",this.x=e,this.y=t,this.radius=n}clone(){return new Si(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;const n=this.radius*this.radius;let s=this.x-e,i=this.y-t;return s*=s,i*=i,s+i<=n}strokeContains(e,t,n,s=.5){if(this.radius===0)return!1;const i=this.x-e,o=this.y-t,a=this.radius,c=(1-s)*n,l=Math.sqrt(i*i+o*o);return l<=a+c&&l>a-(n-c)}getBounds(e){return e||(e=new fe),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class wi{constructor(e=0,t=0,n=0,s=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=n,this.halfHeight=s}clone(){return new wi(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let n=(e-this.x)/this.halfWidth,s=(t-this.y)/this.halfHeight;return n*=n,s*=s,n+s<=1}strokeContains(e,t,n,s=.5){const{halfWidth:i,halfHeight:o}=this;if(i<=0||o<=0)return!1;const a=n*(1-s),c=n-a,l=i-c,u=o-c,h=i+a,d=o+a,f=e-this.x,p=t-this.y,m=f*f/(l*l)+p*p/(u*u),g=f*f/(h*h)+p*p/(d*d);return m>1&&g<=1}getBounds(e){return e||(e=new fe),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function FT(r,e,t,n,s,i){const o=r-t,a=e-n,c=s-t,l=i-n,u=o*c+a*l,h=c*c+l*l;let d=-1;h!==0&&(d=u/h);let f,p;d<0?(f=t,p=n):d>1?(f=s,p=i):(f=t+d*c,p=n+d*l);const m=r-f,g=e-p;return m*m+g*g}let GT,OT;class Nr{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!="number"){const n=[];for(let s=0,i=t.length;s<i;s++)n.push(t[s].x,t[s].y);t=n}this.points=t,this.closePath=!0}isClockwise(){let e=0;const t=this.points,n=t.length;for(let s=0;s<n;s+=2){const i=t[s],o=t[s+1],a=t[(s+2)%n],c=t[(s+3)%n];e+=(a-i)*(c+o)}return e<0}containsPolygon(e){const t=this.getBounds(GT),n=e.getBounds(OT);if(!t.containsRect(n))return!1;const s=e.points;for(let i=0;i<s.length;i+=2){const o=s[i],a=s[i+1];if(!this.contains(o,a))return!1}return!0}clone(){const e=this.points.slice(),t=new Nr(e);return t.closePath=this.closePath,t}contains(e,t){let n=!1;const s=this.points.length/2;for(let i=0,o=s-1;i<s;o=i++){const a=this.points[i*2],c=this.points[i*2+1],l=this.points[o*2],u=this.points[o*2+1];c>t!=u>t&&e<(l-a)*((t-c)/(u-c))+a&&(n=!n)}return n}strokeContains(e,t,n,s=.5){const i=n*n,o=i*(1-s),a=i-o,{points:c}=this,l=c.length-(this.closePath?0:2);for(let u=0;u<l;u+=2){const h=c[u],d=c[u+1],f=c[(u+2)%c.length],p=c[(u+3)%c.length],m=FT(e,t,h,d,f,p),g=Math.sign((f-h)*(t-d)-(p-d)*(e-h));if(m<=(g<0?a:o))return!0}return!1}getBounds(e){e||(e=new fe);const t=this.points;let n=1/0,s=-1/0,i=1/0,o=-1/0;for(let a=0,c=t.length;a<c;a+=2){const l=t[a],u=t[a+1];n=l<n?l:n,s=l>s?l:s,i=u<i?u:i,o=u>o?u:o}return e.x=n,e.width=s-n,e.y=i,e.height=o-i,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return N("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return N("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Hn=(r,e,t,n,s,i,o)=>{const a=r-t,c=e-n,l=Math.sqrt(a*a+c*c);return l>=s-i&&l<=s+o};class Pi{constructor(e=0,t=0,n=0,s=0,i=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=n,this.height=s,this.radius=i}getBounds(e){return e||(e=new fe),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new Pi(this.x,this.y,this.width,this.height,this.radius)}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){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){const n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+n&&t<=this.y+this.height-n||e>=this.x+n&&e<=this.x+this.width-n)return!0;let s=e-(this.x+n),i=t-(this.y+n);const o=n*n;if(s*s+i*i<=o||(s=e-(this.x+this.width-n),s*s+i*i<=o)||(i=t-(this.y+this.height-n),s*s+i*i<=o)||(s=e-(this.x+n),s*s+i*i<=o))return!0}return!1}strokeContains(e,t,n,s=.5){const{x:i,y:o,width:a,height:c,radius:l}=this,u=n*(1-s),h=n-u,d=i+l,f=o+l,p=a-l*2,m=c-l*2,g=i+a,_=o+c;return(e>=i-u&&e<=i+h||e>=g-h&&e<=g+u)&&t>=f&&t<=f+m||(t>=o-u&&t<=o+h||t>=_-h&&t<=_+u)&&e>=d&&e<=d+p?!0:e<d&&t<f&&Hn(e,t,d,f,l,h,u)||e>g-l&&t<f&&Hn(e,t,g-l,f,l,h,u)||e>g-l&&t>_-l&&Hn(e,t,g-l,_-l,l,h,u)||e<d&&t>_-l&&Hn(e,t,d,_-l,l,h,u)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const gu={};function Ei(r,e,t){let n=2166136261;for(let s=0;s<e;s++)n^=r[s].uid,n=Math.imul(n,16777619),n>>>=0;return gu[n]||DT(r,e,n,t)}function DT(r,e,t,n){const s={};let i=0;for(let a=0;a<n;a++){const c=a<e?r[a]:D.EMPTY.source;s[i++]=c.source,s[i++]=c.style}const o=new yt(s);return gu[t]=o,o}function Ci(r,e,t,n){if(t??(t=0),n??(n=Math.min(r.byteLength-t,e.byteLength)),!(t&7)&&!(n&7)){const s=n/8;new Float64Array(e,0,s).set(new Float64Array(r,t,s))}else if(!(t&3)&&!(n&3)){const s=n/4;new Float32Array(e,0,s).set(new Float32Array(r,t,s))}else new Uint8Array(e).set(new Uint8Array(r,t,n))}const UT={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var be=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(be||{});function Mi(r,e){return e.alphaMode==="no-premultiply-alpha"&&UT[r]||r}const LT=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
393
+ `);function zT(r){let e="";for(let t=0;t<r;++t)t>0&&(e+=`
394
+ else `),t<r-1&&(e+=`if(test == ${t}.0){}`);return e}function _u(r,e){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const t=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const n=LT.replace(/%forloop%/gi,zT(r));if(e.shaderSource(t,n),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS))r=r/2|0;else break}}finally{e.deleteShader(t)}return r}let lr=null;function NT(){var e;if(lr)return lr;const r=nu();return lr=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),lr=_u(lr,r),(e=r.getExtension("WEBGL_lose_context"))==null||e.loseContext(),lr}class $T{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){const t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}class VT{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new $T,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const $r=[];let jn=0;Kt.register({clear:()=>{if($r.length>0)for(const r of $r)r&&r.destroy();$r.length=0,jn=0}});function yu(){return jn>0?$r[--jn]:new VT}function bu(r){r.elements=null,$r[jn++]=r}let Vr=0;const xu=class uf{constructor(e){this.uid=ce("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],e={...uf.defaultOptions,...e},e.maxTextures||(N("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),e.maxTextures=NT());const{maxTextures:t,attributesInitialSize:n,indicesInitialSize:s}=e;this.attributeBuffer=new rr(n*4),this.indexBuffer=new Uint16Array(s),this.maxTextures=t}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)bu(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,t){const n=e._batch.textures.ids[t._source.uid];return!n&&n!==0?!1:(e._textureId=n,e.texture=t,!0)}updateElement(e){this.dirty=!0;const t=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId)}break(e){const t=this._elements;if(!t[this.elementStart])return;let n=yu(),s=n.textures;s.clear();const i=t[this.elementStart];let o=Mi(i.blendMode,i.texture._source),a=i.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const c=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,u=this.indexBuffer;let h=this._batchIndexSize,d=this._batchIndexStart,f="startBatch",p=[];const m=this.maxTextures;for(let g=this.elementStart;g<this.elementSize;++g){const _=t[g];t[g]=null;const b=_.texture._source,v=Mi(_.blendMode,b),C=o!==v||a!==_.topology;if(b._batchTick===Vr&&!C){_._textureId=b._textureBindLocation,h+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,c,l,_._attributeStart,_._textureId),this.packQuadIndex(u,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,c,l,_._attributeStart,_._textureId),this.packIndex(_,u,_._indexStart,_._attributeStart/this.vertexSize)),_._batch=n,p.push(_);continue}b._batchTick=Vr,(s.count>=m||C)&&(this._finishBatch(n,d,h-d,s,o,a,e,f,p),f="renderBatch",d=h,o=v,a=_.topology,n=yu(),s=n.textures,s.clear(),p=[],++Vr),_._textureId=b._textureBindLocation=s.count,s.ids[b.uid]=s.count,s.textures[s.count++]=b,_._batch=n,p.push(_),h+=_.indexSize,_.packAsQuad?(this.packQuadAttributes(_,c,l,_._attributeStart,_._textureId),this.packQuadIndex(u,_._indexStart,_._attributeStart/this.vertexSize)):(this.packAttributes(_,c,l,_._attributeStart,_._textureId),this.packIndex(_,u,_._indexStart,_._attributeStart/this.vertexSize))}s.count>0&&(this._finishBatch(n,d,h-d,s,o,a,e,f,p),d=h,++Vr),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=h}_finishBatch(e,t,n,s,i,o,a,c,l){e.gpuBindGroup=null,e.bindGroup=null,e.action=c,e.batcher=this,e.textures=s,e.blendMode=i,e.topology=o,e.start=t,e.size=n,e.elements=l,++Vr,this.batches[this.batchIndex++]=e,a.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){const t=Math.max(e,this.attributeBuffer.size*2),n=new rr(t);Ci(this.attributeBuffer.rawBinaryData,n.rawBinaryData),this.attributeBuffer=n}_resizeIndexBuffer(e){const t=this.indexBuffer;let n=Math.max(e,t.length*1.5);n+=n%2;const s=n>65535?new Uint32Array(n):new Uint16Array(n);if(s.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let i=0;i<t.length;i++)s[i]=t[i];else Ci(t.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(e,t,n){e[t]=n+0,e[t+1]=n+1,e[t+2]=n+2,e[t+3]=n+0,e[t+4]=n+2,e[t+5]=n+3}packIndex(e,t,n,s){const i=e.indices,o=e.indexSize,a=e.indexOffset,c=e.attributeOffset;for(let l=0;l<o;l++)t[n++]=s+i[l+a]-c}destroy(e={}){var t;if(this.batches!==null){for(let n=0;n<this.batchIndex;n++)bu(this.batches[n]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&((t=this.shader)==null||t.destroy(),this.shader=null);for(let n=0;n<this._elements.length;n++)this._elements[n]&&(this._elements[n]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};xu.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let HT=xu;const jT=new Float32Array(1),WT=new Uint32Array(1);class XT extends tr{constructor(){const t=new Ue({data:jT,label:"attribute-batch-buffer",usage:Q.VERTEX|Q.COPY_DST,shrinkToFit:!1}),n=new Ue({data:WT,label:"index-batch-buffer",usage:Q.INDEX|Q.COPY_DST,shrinkToFit:!1}),s=24;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:s,offset:0},aUV:{buffer:t,format:"float32x2",stride:s,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:s,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:s,offset:20}},indexBuffer:n})}}function vu(r,e,t){if(r)for(const n in r){const s=n.toLocaleLowerCase(),i=e[s];if(i){let o=r[n];n==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),t&&i.push(`//----${t}----//`),i.push(o)}else W(`${n} placement hook does not exist in shader`)}}const YT=/\{\{(.*?)\}\}/g;function Tu(r){var n;const e={};return(((n=r.match(YT))==null?void 0:n.map(s=>s.replace(/[{()}]/g,"")))??[]).forEach(s=>{e[s]=[]}),e}function Su(r,e){let t;const n=/@in\s+([^;]+);/g;for(;(t=n.exec(r))!==null;)e.push(t[1])}function wu(r,e,t=!1){const n=[];Su(e,n),r.forEach(a=>{a.header&&Su(a.header,n)});const s=n;t&&s.sort();const i=s.map((a,c)=>` @location(${c}) ${a},`).join(`
395
+ `);let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`
396
+ ${i}
397
+ `),o}function Pu(r,e){let t;const n=/@out\s+([^;]+);/g;for(;(t=n.exec(r))!==null;)e.push(t[1])}function ZT(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function KT(r){const e=/@.*?\s+/g;return r.replace(e,"")}function qT(r,e){const t=[];Pu(e,t),r.forEach(c=>{c.header&&Pu(c.header,t)});let n=0;const s=t.sort().map(c=>c.indexOf("builtin")>-1?c:`@location(${n++}) ${c}`).join(`,
398
+ `),i=t.sort().map(c=>` var ${KT(c)};`).join(`
399
+ `),o=`return VSOutput(
400
+ ${t.sort().map(c=>` ${ZT(c)}`).join(`,
401
+ `)});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`
402
+ ${s}
403
+ `),a=a.replace("{{start}}",`
404
+ ${i}
405
+ `),a=a.replace("{{return}}",`
406
+ ${o}
407
+ `),a}function Eu(r,e){let t=r;for(const n in e){const s=e[n];s.join(`
408
+ `).length?t=t.replace(`{{${n}}}`,`//-----${n} START-----//
409
+ ${s.join(`
410
+ `)}
411
+ //----${n} FINISH----//`):t=t.replace(`{{${n}}}`,"")}return t}const Et=Object.create(null),Ai=new Map;let JT=0;function QT({template:r,bits:e}){const t=Cu(r,e);if(Et[t])return Et[t];const{vertex:n,fragment:s}=tS(r,e);return Et[t]=Mu(n,s,e),Et[t]}function eS({template:r,bits:e}){const t=Cu(r,e);return Et[t]||(Et[t]=Mu(r.vertex,r.fragment,e)),Et[t]}function tS(r,e){const t=e.map(o=>o.vertex).filter(o=>!!o),n=e.map(o=>o.fragment).filter(o=>!!o);let s=wu(t,r.vertex,!0);s=qT(t,s);const i=wu(n,r.fragment,!0);return{vertex:s,fragment:i}}function Cu(r,e){return e.map(t=>(Ai.has(t)||Ai.set(t,JT++),Ai.get(t))).sort((t,n)=>t-n).join("-")+r.vertex+r.fragment}function Mu(r,e,t){const n=Tu(r),s=Tu(e);return t.forEach(i=>{vu(i.vertex,n,i.name),vu(i.fragment,s,i.name)}),{vertex:Eu(r,n),fragment:Eu(e,s)}}const rS=`
412
+ @in aPosition: vec2<f32>;
413
+ @in aUV: vec2<f32>;
414
+
415
+ @out @builtin(position) vPosition: vec4<f32>;
416
+ @out vUV : vec2<f32>;
417
+ @out vColor : vec4<f32>;
418
+
419
+ {{header}}
420
+
421
+ struct VSOutput {
422
+ {{struct}}
423
+ };
424
+
425
+ @vertex
426
+ fn main( {{in}} ) -> VSOutput {
427
+
428
+ var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
429
+ var modelMatrix = mat3x3<f32>(
430
+ 1.0, 0.0, 0.0,
431
+ 0.0, 1.0, 0.0,
432
+ 0.0, 0.0, 1.0
433
+ );
434
+ var position = aPosition;
435
+ var uv = aUV;
436
+
437
+ {{start}}
438
+
439
+ vColor = vec4<f32>(1., 1., 1., 1.);
440
+
441
+ {{main}}
442
+
443
+ vUV = uv;
444
+
445
+ var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
446
+
447
+ vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
448
+
449
+ vColor *= globalUniforms.uWorldColorAlpha;
450
+
451
+ {{end}}
452
+
453
+ {{return}}
454
+ };
455
+ `,nS=`
456
+ @in vUV : vec2<f32>;
457
+ @in vColor : vec4<f32>;
458
+
459
+ {{header}}
460
+
461
+ @fragment
462
+ fn main(
463
+ {{in}}
464
+ ) -> @location(0) vec4<f32> {
465
+
466
+ {{start}}
467
+
468
+ var outColor:vec4<f32>;
469
+
470
+ {{main}}
471
+
472
+ var finalColor:vec4<f32> = outColor * vColor;
473
+
474
+ {{end}}
475
+
476
+ return finalColor;
477
+ };
478
+ `,sS=`
479
+ in vec2 aPosition;
480
+ in vec2 aUV;
481
+
482
+ out vec4 vColor;
483
+ out vec2 vUV;
484
+
485
+ {{header}}
486
+
487
+ void main(void){
488
+
489
+ mat3 worldTransformMatrix = uWorldTransformMatrix;
490
+ mat3 modelMatrix = mat3(
491
+ 1.0, 0.0, 0.0,
492
+ 0.0, 1.0, 0.0,
493
+ 0.0, 0.0, 1.0
494
+ );
495
+ vec2 position = aPosition;
496
+ vec2 uv = aUV;
497
+
498
+ {{start}}
499
+
500
+ vColor = vec4(1.);
501
+
502
+ {{main}}
503
+
504
+ vUV = uv;
505
+
506
+ mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
507
+
508
+ gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
509
+
510
+ vColor *= uWorldColorAlpha;
511
+
512
+ {{end}}
513
+ }
514
+ `,iS=`
515
+
516
+ in vec4 vColor;
517
+ in vec2 vUV;
518
+
519
+ out vec4 finalColor;
520
+
521
+ {{header}}
522
+
523
+ void main(void) {
524
+
525
+ {{start}}
526
+
527
+ vec4 outColor;
528
+
529
+ {{main}}
530
+
531
+ finalColor = outColor * vColor;
532
+
533
+ {{end}}
534
+ }
535
+ `,oS={name:"global-uniforms-bit",vertex:{header:`
536
+ struct GlobalUniforms {
537
+ uProjectionMatrix:mat3x3<f32>,
538
+ uWorldTransformMatrix:mat3x3<f32>,
539
+ uWorldColorAlpha: vec4<f32>,
540
+ uResolution: vec2<f32>,
541
+ }
542
+
543
+ @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
544
+ `}},aS={name:"global-uniforms-bit",vertex:{header:`
545
+ uniform mat3 uProjectionMatrix;
546
+ uniform mat3 uWorldTransformMatrix;
547
+ uniform vec4 uWorldColorAlpha;
548
+ uniform vec2 uResolution;
549
+ `}};function ki({bits:r,name:e}){const t=QT({template:{fragment:nS,vertex:rS},bits:[oS,...r]});return Ut.from({name:e,vertex:{source:t.vertex,entryPoint:"main"},fragment:{source:t.fragment,entryPoint:"main"}})}function Ri({bits:r,name:e}){return new Ot({name:e,...eS({template:{vertex:sS,fragment:iS},bits:[aS,...r]})})}const Au={name:"color-bit",vertex:{header:`
550
+ @in aColor: vec4<f32>;
551
+ `,main:`
552
+ vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
553
+ `}},ku={name:"color-bit",vertex:{header:`
554
+ in vec4 aColor;
555
+ `,main:`
556
+ vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
557
+ `}},Ii={};function cS(r){const e=[];if(r===1)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let t=0;for(let n=0;n<r;n++)e.push(`@group(1) @binding(${t++}) var textureSource${n+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${t++}) var textureSampler${n+1}: sampler;`)}return e.join(`
558
+ `)}function lS(r){const e=[];if(r===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let t=0;t<r;t++)t===r-1?e.push(" default:{"):e.push(` case ${t}:{`),e.push(` outColor = textureSampleGrad(textureSource${t+1}, textureSampler${t+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join(`
559
+ `)}function Ru(r){return Ii[r]||(Ii[r]={name:"texture-batch-bit",vertex:{header:`
560
+ @in aTextureIdAndRound: vec2<u32>;
561
+ @out @interpolate(flat) vTextureId : u32;
562
+ `,main:`
563
+ vTextureId = aTextureIdAndRound.y;
564
+ `,end:`
565
+ if(aTextureIdAndRound.x == 1)
566
+ {
567
+ vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
568
+ }
569
+ `},fragment:{header:`
570
+ @in @interpolate(flat) vTextureId: u32;
571
+
572
+ ${cS(r)}
573
+ `,main:`
574
+ var uvDx = dpdx(vUV);
575
+ var uvDy = dpdy(vUV);
576
+
577
+ ${lS(r)}
578
+ `}}),Ii[r]}const Bi={};function uS(r){const e=[];for(let t=0;t<r;t++)t>0&&e.push("else"),t<r-1&&e.push(`if(vTextureId < ${t}.5)`),e.push("{"),e.push(` outColor = texture(uTextures[${t}], vUV);`),e.push("}");return e.join(`
579
+ `)}function Iu(r){return Bi[r]||(Bi[r]={name:"texture-batch-bit",vertex:{header:`
580
+ in vec2 aTextureIdAndRound;
581
+ out float vTextureId;
582
+
583
+ `,main:`
584
+ vTextureId = aTextureIdAndRound.y;
585
+ `,end:`
586
+ if(aTextureIdAndRound.x == 1.)
587
+ {
588
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
589
+ }
590
+ `},fragment:{header:`
591
+ in float vTextureId;
592
+
593
+ uniform sampler2D uTextures[${r}];
594
+
595
+ `,main:`
596
+
597
+ ${uS(r)}
598
+ `}}),Bi[r]}const Fi={name:"round-pixels-bit",vertex:{header:`
599
+ fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
600
+ {
601
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
602
+ }
603
+ `}},Gi={name:"round-pixels-bit",vertex:{header:`
604
+ vec2 roundPixels(vec2 position, vec2 targetSize)
605
+ {
606
+ return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
607
+ }
608
+ `}},Bu={};function Fu(r){let e=Bu[r];if(e)return e;const t=new Int32Array(r);for(let n=0;n<r;n++)t[n]=n;return e=Bu[r]=new je({uTextures:{value:t,type:"i32",size:r}},{isStatic:!0}),e}class Gu extends bt{constructor(e){const t=Ri({name:"batch",bits:[ku,Iu(e),Gi]}),n=ki({name:"batch",bits:[Au,Ru(e),Fi]});super({glProgram:t,gpuProgram:n,resources:{batchSamplers:Fu(e)}}),this.maxTextures=e}}let Hr=null;const Ou=class hf extends HT{constructor(e){super(e),this.geometry=new XT,this.name=hf.extension.name,this.vertexSize=6,Hr??(Hr=new Gu(e.maxTextures)),this.shader=Hr}packAttributes(e,t,n,s,i){const o=i<<16|e.roundPixels&65535,a=e.transform,c=a.a,l=a.b,u=a.c,h=a.d,d=a.tx,f=a.ty,{positions:p,uvs:m}=e,g=e.color,_=e.attributeOffset,y=_+e.attributeSize;for(let b=_;b<y;b++){const v=b*2,C=p[v],S=p[v+1];t[s++]=c*C+u*S+d,t[s++]=h*S+l*C+f,t[s++]=m[v],t[s++]=m[v+1],n[s++]=g,n[s++]=o}}packQuadAttributes(e,t,n,s,i){const o=e.texture,a=e.transform,c=a.a,l=a.b,u=a.c,h=a.d,d=a.tx,f=a.ty,p=e.bounds,m=p.maxX,g=p.minX,_=p.maxY,y=p.minY,b=o.uvs,v=e.color,C=i<<16|e.roundPixels&65535;t[s+0]=c*g+u*y+d,t[s+1]=h*y+l*g+f,t[s+2]=b.x0,t[s+3]=b.y0,n[s+4]=v,n[s+5]=C,t[s+6]=c*m+u*y+d,t[s+7]=h*y+l*m+f,t[s+8]=b.x1,t[s+9]=b.y1,n[s+10]=v,n[s+11]=C,t[s+12]=c*m+u*_+d,t[s+13]=h*_+l*m+f,t[s+14]=b.x2,t[s+15]=b.y2,n[s+16]=v,n[s+17]=C,t[s+18]=c*g+u*_+d,t[s+19]=h*_+l*g+f,t[s+20]=b.x3,t[s+21]=b.y3,n[s+22]=v,n[s+23]=C}_updateMaxTextures(e){this.shader.maxTextures!==e&&(Hr=new Gu(e),this.shader=Hr)}destroy(){this.shader=null,super.destroy()}};Ou.extension={type:[x.Batcher],name:"default"};let Oi=Ou;class xt{constructor(e){this.items=Object.create(null);const{renderer:t,type:n,onUnload:s,priority:i,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",n,i??0),this._onUnload=s,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){var s;if(!this.items[e.uid])return;const n=e._gpuData[this._renderer.uid];n&&((s=this._onUnload)==null||s.call(this,e,...t),n.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function hS(r,e,t,n,s,i,o,a=null){let c=0;t*=e,s*=i;const l=a.a,u=a.b,h=a.c,d=a.d,f=a.tx,p=a.ty;for(;c<o;){const m=r[t],g=r[t+1];n[s]=l*m+h*g+f,n[s+1]=u*m+d*g+p,s+=i,t+=e,c++}}function dS(r,e,t,n){let s=0;for(e*=t;s<n;)r[e]=0,r[e+1]=0,e+=t,s++}function Du(r,e,t,n,s){const i=e.a,o=e.b,a=e.c,c=e.d,l=e.tx,u=e.ty;t||(t=0),n||(n=2),s||(s=r.length/n-t);let h=t*n;for(let d=0;d<s;d++){const f=r[h],p=r[h+1];r[h]=i*f+a*p+l,r[h+1]=o*f+c*p+u,h+=n}}const fS=new B;class Di{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,n=this.renderable;return n?qt(t,n.groupColor)+(this.alpha*n.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){var e;return((e=this.renderable)==null?void 0:e.groupTransform)||fS}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const jr={extension:{type:x.ShapeBuilder,name:"circle"},build(r,e){let t,n,s,i,o,a;if(r.type==="circle"){const v=r;if(o=a=v.radius,o<=0)return!1;t=v.x,n=v.y,s=i=0}else if(r.type==="ellipse"){const v=r;if(o=v.halfWidth,a=v.halfHeight,o<=0||a<=0)return!1;t=v.x,n=v.y,s=i=0}else{const v=r,C=v.width/2,S=v.height/2;t=v.x+C,n=v.y+S,o=a=Math.max(0,Math.min(v.radius,Math.min(C,S))),s=C-o,i=S-a}if(s<0||i<0)return!1;const c=Math.ceil(2.3*Math.sqrt(o+a)),l=c*8+(s?4:0)+(i?4:0);if(l===0)return!1;if(c===0)return e[0]=e[6]=t+s,e[1]=e[3]=n+i,e[2]=e[4]=t-s,e[5]=e[7]=n-i,!0;let u=0,h=c*4+(s?2:0)+2,d=h,f=l,p=s+o,m=i,g=t+p,_=t-p,y=n+m;if(e[u++]=g,e[u++]=y,e[--h]=y,e[--h]=_,i){const v=n-m;e[d++]=_,e[d++]=v,e[--f]=v,e[--f]=g}for(let v=1;v<c;v++){const C=Math.PI/2*(v/c),S=s+Math.cos(C)*o,E=i+Math.sin(C)*a,U=t+S,z=t-S,M=n+E,A=n-E;e[u++]=U,e[u++]=M,e[--h]=M,e[--h]=z,e[d++]=z,e[d++]=A,e[--f]=A,e[--f]=U}p=s,m=i+a,g=t+p,_=t-p,y=n+m;const b=n-m;return e[u++]=g,e[u++]=y,e[--f]=b,e[--f]=g,s&&(e[u++]=_,e[u++]=y,e[--f]=b,e[--f]=_),!0},triangulate(r,e,t,n,s,i){if(r.length===0)return;let o=0,a=0;for(let u=0;u<r.length;u+=2)o+=r[u],a+=r[u+1];o/=r.length/2,a/=r.length/2;let c=n;e[c*t]=o,e[c*t+1]=a;const l=c++;for(let u=0;u<r.length;u+=2)e[c*t]=r[u],e[c*t+1]=r[u+1],u>0&&(s[i++]=c,s[i++]=l,s[i++]=c-1),c++;s[i++]=l+1,s[i++]=l,s[i++]=c-1}},pS={...jr,extension:{...jr.extension,name:"ellipse"}},mS={...jr,extension:{...jr.extension,name:"roundedRectangle"}},Uu=1e-4,Lu=1e-4;function gS(r){const e=r.length;if(e<6)return 1;let t=0;for(let n=0,s=r[e-2],i=r[e-1];n<e;n+=2){const o=r[n],a=r[n+1];t+=(o-s)*(a+i),s=o,i=a}return t<0?-1:1}function zu(r,e,t,n,s,i,o,a){const c=r-t*s,l=e-n*s,u=r+t*i,h=e+n*i;let d,f;o?(d=n,f=-t):(d=-n,f=t);const p=c+d,m=l+f,g=u+d,_=h+f;return a.push(p,m),a.push(g,_),2}function Lt(r,e,t,n,s,i,o,a){const c=t-r,l=n-e;let u=Math.atan2(c,l),h=Math.atan2(s-r,i-e);a&&u<h?u+=Math.PI*2:!a&&u>h&&(h+=Math.PI*2);let d=u;const f=h-u,p=Math.abs(f),m=Math.sqrt(c*c+l*l),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,_=f/g;if(d+=_,a){o.push(r,e),o.push(t,n);for(let y=1,b=d;y<g;y++,b+=_)o.push(r,e),o.push(r+Math.sin(b)*m,e+Math.cos(b)*m);o.push(r,e),o.push(s,i)}else{o.push(t,n),o.push(r,e);for(let y=1,b=d;y<g;y++,b+=_)o.push(r+Math.sin(b)*m,e+Math.cos(b)*m),o.push(r,e);o.push(s,i),o.push(r,e)}return g*2}function Ui(r,e,t,n,s,i){const o=Uu;if(r.length===0)return;const a=e;let c=a.alignment;if(e.alignment!==.5){let O=gS(r);c=(c-.5)*O+.5}const l=new le(r[0],r[1]),u=new le(r[r.length-2],r[r.length-1]),h=n,d=Math.abs(l.x-u.x)<o&&Math.abs(l.y-u.y)<o;if(h){r=r.slice(),d&&(r.pop(),r.pop(),u.set(r[r.length-2],r[r.length-1]));const O=(l.x+u.x)*.5,ie=(u.y+l.y)*.5;r.unshift(O,ie),r.push(O,ie)}const f=s,p=r.length/2;let m=r.length;const g=f.length/2,_=a.width/2,y=_*_,b=a.miterLimit*a.miterLimit;let v=r[0],C=r[1],S=r[2],E=r[3],U=0,z=0,M=-(C-E),A=v-S,j=0,q=0,se=Math.sqrt(M*M+A*A);M/=se,A/=se,M*=_,A*=_;const Ye=c,k=(1-Ye)*2,G=Ye*2;h||(a.cap==="round"?m+=Lt(v-M*(k-G)*.5,C-A*(k-G)*.5,v-M*k,C-A*k,v+M*G,C+A*G,f,!0)+2:a.cap==="square"&&(m+=zu(v,C,M,A,k,G,!0,f))),f.push(v-M*k,C-A*k),f.push(v+M*G,C+A*G);for(let O=1;O<p-1;++O){v=r[(O-1)*2],C=r[(O-1)*2+1],S=r[O*2],E=r[O*2+1],U=r[(O+1)*2],z=r[(O+1)*2+1],M=-(C-E),A=v-S,se=Math.sqrt(M*M+A*A),M/=se,A/=se,M*=_,A*=_,j=-(E-z),q=S-U,se=Math.sqrt(j*j+q*q),j/=se,q/=se,j*=_,q*=_;const ie=S-v,Ge=C-E,Ee=S-U,we=z-E,Ze=ie*Ee+Ge*we,Oe=Ge*Ee-we*ie,Me=Oe<0;if(Math.abs(Oe)<.001*Math.abs(Ze)){f.push(S-M*k,E-A*k),f.push(S+M*G,E+A*G),Ze>=0&&(a.join==="round"?m+=Lt(S,E,S-M*k,E-A*k,S-j*k,E-q*k,f,!1)+4:m+=2,f.push(S-j*G,E-q*G),f.push(S+j*k,E+q*k));continue}const ze=(-M+v)*(-A+E)-(-M+S)*(-A+C),nt=(-j+U)*(-q+E)-(-j+S)*(-q+z),K=(ie*nt-Ee*ze)/Oe,Ne=(we*ze-Ge*nt)/Oe,Ke=(K-S)*(K-S)+(Ne-E)*(Ne-E),xe=S+(K-S)*k,lt=E+(Ne-E)*k,st=S-(K-S)*G,qe=E-(Ne-E)*G,gr=Math.min(ie*ie+Ge*Ge,Ee*Ee+we*we),_r=Me?k:G,qr=gr+_r*_r*y;Ke<=qr?a.join==="bevel"||Ke/y>b?(Me?(f.push(xe,lt),f.push(S+M*G,E+A*G),f.push(xe,lt),f.push(S+j*G,E+q*G)):(f.push(S-M*k,E-A*k),f.push(st,qe),f.push(S-j*k,E-q*k),f.push(st,qe)),m+=2):a.join==="round"?Me?(f.push(xe,lt),f.push(S+M*G,E+A*G),m+=Lt(S,E,S+M*G,E+A*G,S+j*G,E+q*G,f,!0)+4,f.push(xe,lt),f.push(S+j*G,E+q*G)):(f.push(S-M*k,E-A*k),f.push(st,qe),m+=Lt(S,E,S-M*k,E-A*k,S-j*k,E-q*k,f,!1)+4,f.push(S-j*k,E-q*k),f.push(st,qe)):(f.push(xe,lt),f.push(st,qe)):(f.push(S-M*k,E-A*k),f.push(S+M*G,E+A*G),a.join==="round"?Me?m+=Lt(S,E,S+M*G,E+A*G,S+j*G,E+q*G,f,!0)+2:m+=Lt(S,E,S-M*k,E-A*k,S-j*k,E-q*k,f,!1)+2:a.join==="miter"&&Ke/y<=b&&(Me?(f.push(st,qe),f.push(st,qe)):(f.push(xe,lt),f.push(xe,lt)),m+=2),f.push(S-j*k,E-q*k),f.push(S+j*G,E+q*G),m+=2)}v=r[(p-2)*2],C=r[(p-2)*2+1],S=r[(p-1)*2],E=r[(p-1)*2+1],M=-(C-E),A=v-S,se=Math.sqrt(M*M+A*A),M/=se,A/=se,M*=_,A*=_,f.push(S-M*k,E-A*k),f.push(S+M*G,E+A*G),h||(a.cap==="round"?m+=Lt(S-M*(k-G)*.5,E-A*(k-G)*.5,S-M*k,E-A*k,S+M*G,E+A*G,f,!1)+2:a.cap==="square"&&(m+=zu(S,E,M,A,k,G,!1,f)));const re=Lu*Lu;for(let O=g;O<m+g-2;++O)v=f[O*2],C=f[O*2+1],S=f[(O+1)*2],E=f[(O+1)*2+1],U=f[(O+2)*2],z=f[(O+2)*2+1],!(Math.abs(v*(E-z)+S*(z-C)+U*(C-E))<re)&&i.push(O,O+1,O+2)}function _S(r,e,t,n){const s=Uu;if(r.length===0)return;const i=r[0],o=r[1],a=r[r.length-2],c=r[r.length-1],l=e||Math.abs(i-a)<s&&Math.abs(o-c)<s,u=t,h=r.length/2,d=u.length/2;for(let f=0;f<h;f++)u.push(r[f*2]),u.push(r[f*2+1]);for(let f=0;f<h-1;f++)n.push(d+f,d+f+1);l&&n.push(d+h-1,d)}function Nu(r,e,t,n,s,i,o){const a=b0(r,e,2);if(!a)return;for(let l=0;l<a.length;l+=3)i[o++]=a[l]+s,i[o++]=a[l+1]+s,i[o++]=a[l+2]+s;let c=s*n;for(let l=0;l<r.length;l+=2)t[c]=r[l],t[c+1]=r[l+1],c+=n}const yS=[],bS={extension:{type:x.ShapeBuilder,name:"polygon"},build(r,e){for(let t=0;t<r.points.length;t++)e[t]=r.points[t];return!0},triangulate(r,e,t,n,s,i){Nu(r,yS,e,t,n,s,i)}},xS={extension:{type:x.ShapeBuilder,name:"rectangle"},build(r,e){const t=r,n=t.x,s=t.y,i=t.width,o=t.height;return i>0&&o>0?(e[0]=n,e[1]=s,e[2]=n+i,e[3]=s,e[4]=n+i,e[5]=s+o,e[6]=n,e[7]=s+o,!0):!1},triangulate(r,e,t,n,s,i){let o=0;n*=t,e[n+o]=r[0],e[n+o+1]=r[1],o+=t,e[n+o]=r[2],e[n+o+1]=r[3],o+=t,e[n+o]=r[6],e[n+o+1]=r[7],o+=t,e[n+o]=r[4],e[n+o+1]=r[5],o+=t;const a=n/t;s[i++]=a,s[i++]=a+1,s[i++]=a+2,s[i++]=a+1,s[i++]=a+3,s[i++]=a+2}},vS={extension:{type:x.ShapeBuilder,name:"triangle"},build(r,e){return e[0]=r.x,e[1]=r.y,e[2]=r.x2,e[3]=r.y2,e[4]=r.x3,e[5]=r.y3,!0},triangulate(r,e,t,n,s,i){let o=0;n*=t,e[n+o]=r[0],e[n+o+1]=r[1],o+=t,e[n+o]=r[2],e[n+o+1]=r[3],o+=t,e[n+o]=r[4],e[n+o+1]=r[5];const a=n/t;s[i++]=a,s[i++]=a+1,s[i++]=a+2}},$u=[{offset:0,color:"white"},{offset:1,color:"black"}],Li=class Bo{constructor(...e){this.uid=ce("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=TS(e);t={...t.type==="radial"?Bo.defaultRadialOptions:Bo.defaultLinearOptions,...wn(t)},this._textureSize=t.textureSize,this._wrapMode=t.wrapMode,t.type==="radial"?(this.center=t.center,this.outerCenter=t.outerCenter??this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:ye.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:n,y:s}=this.end,i=n-e,o=s-t;const a=i<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(i<0){const g=e;e=n,n=g,i*=-1}if(o<0){const g=t;t=s,s=g,o*=-1}}const c=this.colorStops.length?this.colorStops:$u,l=this._textureSize,{canvas:u,context:h}=Hu(l,1),d=a?h.createLinearGradient(this._textureSize,0,0,0):h.createLinearGradient(0,0,this._textureSize,0);Vu(d,c),h.fillStyle=d,h.fillRect(0,0,l,1),this.texture=new D({source:new Dn({resource:u,addressMode:this._wrapMode})});const f=Math.sqrt(i*i+o*o),p=Math.atan2(o,i),m=new B;m.scale(f/l,1),m.rotate(p),m.translate(e,t),this.textureSpace==="local"&&m.scale(l,l),this.transform=m}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:$u,t=this._textureSize,{canvas:n,context:s}=Hu(t,t),{x:i,y:o}=this.center,{x:a,y:c}=this.outerCenter,l=this.innerRadius,u=this.outerRadius,h=a-u,d=c-u,f=t/(u*2),p=(i-h)*f,m=(o-d)*f,g=s.createRadialGradient(p,m,l*f,(a-h)*f,(c-d)*f,u*f);Vu(g,e),s.fillStyle=e[e.length-1].color,s.fillRect(0,0,t,t),s.fillStyle=g,s.translate(p,m),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-p,-m),s.fillRect(0,0,t,t),this.texture=new D({source:new Dn({resource:n,addressMode:this._wrapMode})});const _=new B;_.scale(1/f,1/f),_.translate(h,d),this.textureSpace==="local"&&_.scale(t,t),this.transform=_}destroy(){var e;(e=this.texture)==null||e.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Li.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},Li.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let ur=Li;function Vu(r,e){for(let t=0;t<e.length;t++){const n=e[t];r.addColorStop(n.offset,n.color)}}function Hu(r,e){const t=te.get().createCanvas(r,e),n=t.getContext("2d");return{canvas:t,context:n}}function TS(r){let e=r[0]??{};return(typeof e=="number"||r[1])&&(N("8.5.2","use options object instead"),e={type:"linear",start:{x:r[0],y:r[1]},end:{x:r[2],y:r[3]},textureSpace:r[4],textureSize:r[5]??ur.defaultLinearOptions.textureSize}),e}const SS=new B,wS=new fe;function ju(r,e,t,n){const s=e.matrix?r.copyFrom(e.matrix).invert():r.identity();if(e.textureSpace==="local"){const o=t.getBounds(wS);e.width&&o.pad(e.width);const{x:a,y:c}=o,l=1/o.width,u=1/o.height,h=-a*l,d=-c*u,f=s.a,p=s.b,m=s.c,g=s.d;s.a*=l,s.b*=l,s.c*=u,s.d*=u,s.tx=h*f+d*m+s.tx,s.ty=h*p+d*g+s.ty}else s.translate(e.texture.frame.x,e.texture.frame.y),s.scale(1/e.texture.source.width,1/e.texture.source.height);const i=e.texture.source.style;return!(e.fill instanceof ur)&&i.addressMode==="clamp-to-edge"&&(i.addressMode="repeat",i.update()),n&&s.append(SS.copyFrom(n).invert()),s}const hr={};H.handleByMap(x.ShapeBuilder,hr),H.add(xS,bS,vS,jr,pS,mS);const PS=new fe,ES=new B;function CS(r,e){const{geometryData:t,batches:n}=e;n.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let s=0;s<r.instructions.length;s++){const i=r.instructions[s];if(i.action==="texture")MS(i.data,n,t);else if(i.action==="fill"||i.action==="stroke"){const o=i.action==="stroke",a=i.data.path.shapePath,c=i.data.style,l=i.data.hole;o&&l&&Wu(l.shapePath,c,!0,n,t),l&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=l.shapePath.shapePrimitives),Wu(a,c,o,n,t)}}}function MS(r,e,t){const n=[],s=hr.rectangle,i=PS;i.x=r.dx,i.y=r.dy,i.width=r.dw,i.height=r.dh;const o=r.transform;if(!s.build(i,n))return;const{vertices:a,uvs:c,indices:l}=t,u=l.length,h=a.length/2;o&&Du(n,o),s.triangulate(n,a,2,h,l,u);const d=r.image,f=d.uvs;c.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=Se.get(Di);p.indexOffset=u,p.indexSize=l.length-u,p.attributeOffset=h,p.attributeSize=a.length/2-h,p.baseColor=r.style,p.alpha=r.alpha,p.texture=d,p.geometryData=t,e.push(p)}function Wu(r,e,t,n,s){const{vertices:i,uvs:o,indices:a}=s;r.shapePrimitives.forEach(({shape:c,transform:l,holes:u})=>{const h=[],d=hr[c.type];if(!d.build(c,h))return;const f=a.length,p=i.length/2;let m="triangle-list";if(l&&Du(h,l),t){const b=c.closePath??!0,v=e;v.pixelLine?(_S(h,b,i,a),m="line-list"):Ui(h,v,!1,b,i,a)}else if(u){const b=[],v=h.slice();AS(u).forEach(S=>{b.push(v.length/2),v.push(...S)}),Nu(v,b,i,2,p,a,f)}else d.triangulate(h,i,2,p,a,f);const g=o.length/2,_=e.texture;if(_!==D.WHITE){const b=ju(ES,e,c,l);hS(i,2,p,o,g,2,i.length/2-p,b)}else dS(o,g,2,i.length/2-p);const y=Se.get(Di);y.indexOffset=f,y.indexSize=a.length-f,y.attributeOffset=p,y.attributeSize=i.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=_,y.geometryData=s,y.topology=m,n.push(y)})}function AS(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t].shape,s=[];hr[n.type].build(n,s)&&e.push(s)}return e}class kS{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{Se.return(e)}),this.graphicsData&&Se.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class RS{constructor(){this.instructions=new Ks}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new Oi({maxTextures:t}),this.instructions.reset()}get geometry(){return N(nv,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const zi=class Fo{constructor(e){this._renderer=e,this._managedContexts=new xt({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Fo.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Fo.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=!!e._gpuData[this._renderer.uid],n=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&n.reset(),CS(e,n);const s=e.batchMode;e.customShader||s==="no-batch"?n.isBatchable=!1:s==="auto"?n.isBatchable=n.geometryData.vertices.length<400:n.isBatchable=!0,e.dirty=!1}return n}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=Se.get(RS,{maxTextures:this._renderer.limits.maxBatchableTextures}),n=e._gpuData[this._renderer.uid],{batches:s,geometryData:i}=n;n.graphicsData=t;const o=i.vertices.length,a=i.indices.length;for(let h=0;h<s.length;h++)s[h].applyTransform=!1;const c=t.batcher;c.ensureAttributeBuffer(o),c.ensureIndexBuffer(a),c.begin();for(let h=0;h<s.length;h++){const d=s[h];c.add(d)}c.finish(t.instructions);const l=c.geometry;l.indexBuffer.setDataWithSize(c.indexBuffer,c.indexSize,!0),l.buffers[0].setDataWithSize(c.attributeBuffer.float32View,c.attributeSize,!0);const u=c.batches;for(let h=0;h<u.length;h++){const d=u[h];d.bindGroup=Ei(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new kS;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};zi.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"graphicsContext"},zi.defaultOptions={bezierSmoothness:.5};let Ni=zi;const IS=8,Wn=11920929e-14,BS=1;function Xu(r,e,t,n,s,i,o,a,c,l){const h=Math.min(.99,Math.max(0,l??Ni.defaultOptions.bezierSmoothness));let d=(BS-h)/1;return d*=d,FS(e,t,n,s,i,o,a,c,r,d),r}function FS(r,e,t,n,s,i,o,a,c,l){$i(r,e,t,n,s,i,o,a,c,l,0),c.push(o,a)}function $i(r,e,t,n,s,i,o,a,c,l,u){if(u>IS)return;const h=(r+t)/2,d=(e+n)/2,f=(t+s)/2,p=(n+i)/2,m=(s+o)/2,g=(i+a)/2,_=(h+f)/2,y=(d+p)/2,b=(f+m)/2,v=(p+g)/2,C=(_+b)/2,S=(y+v)/2;if(u>0){let E=o-r,U=a-e;const z=Math.abs((t-o)*U-(n-a)*E),M=Math.abs((s-o)*U-(i-a)*E);if(z>Wn&&M>Wn){if((z+M)*(z+M)<=l*(E*E+U*U)){c.push(C,S);return}}else if(z>Wn){if(z*z<=l*(E*E+U*U)){c.push(C,S);return}}else if(M>Wn){if(M*M<=l*(E*E+U*U)){c.push(C,S);return}}else if(E=C-(r+o)/2,U=S-(e+a)/2,E*E+U*U<=l){c.push(C,S);return}}$i(r,e,h,d,_,y,C,S,c,l,u+1),$i(C,S,b,v,m,g,o,a,c,l,u+1)}const GS=8,OS=11920929e-14,DS=1;function US(r,e,t,n,s,i,o,a){const l=Math.min(.99,Math.max(0,a??Ni.defaultOptions.bezierSmoothness));let u=(DS-l)/1;return u*=u,LS(e,t,n,s,i,o,r,u),r}function LS(r,e,t,n,s,i,o,a){Vi(o,r,e,t,n,s,i,a,0),o.push(s,i)}function Vi(r,e,t,n,s,i,o,a,c){if(c>GS)return;const l=(e+n)/2,u=(t+s)/2,h=(n+i)/2,d=(s+o)/2,f=(l+h)/2,p=(u+d)/2;let m=i-e,g=o-t;const _=Math.abs((n-i)*g-(s-o)*m);if(_>OS){if(_*_<=a*(m*m+g*g)){r.push(f,p);return}}else if(m=f-(e+i)/2,g=p-(t+o)/2,m*m+g*g<=a){r.push(f,p);return}Vi(r,e,t,l,u,f,p,a,c+1),Vi(r,f,p,h,d,i,o,a,c+1)}function Yu(r,e,t,n,s,i,o,a){let c=Math.abs(s-i);(!o&&s>i||o&&i>s)&&(c=2*Math.PI-c),a||(a=Math.max(6,Math.floor(6*Math.pow(n,1/3)*(c/Math.PI)))),a=Math.max(a,3);let l=c/a,u=s;l*=o?-1:1;for(let h=0;h<a+1;h++){const d=Math.cos(u),f=Math.sin(u),p=e+d*n,m=t+f*n;r.push(p,m),u+=l}}function zS(r,e,t,n,s,i){const o=r[r.length-2],c=r[r.length-1]-t,l=o-e,u=s-t,h=n-e,d=Math.abs(c*h-l*u);if(d<1e-8||i===0){(r[r.length-2]!==e||r[r.length-1]!==t)&&r.push(e,t);return}const f=c*c+l*l,p=u*u+h*h,m=c*u+l*h,g=i*Math.sqrt(f)/d,_=i*Math.sqrt(p)/d,y=g*m/f,b=_*m/p,v=g*h+_*l,C=g*u+_*c,S=l*(_+y),E=c*(_+y),U=h*(g+b),z=u*(g+b),M=Math.atan2(E-C,S-v),A=Math.atan2(z-C,U-v);Yu(r,v+e,C+t,i,M,A,l*u>h*c)}const Wr=Math.PI*2,Hi={centerX:0,centerY:0,ang1:0,ang2:0},ji=({x:r,y:e},t,n,s,i,o,a,c)=>{r*=t,e*=n;const l=s*r-i*e,u=i*r+s*e;return c.x=l+o,c.y=u+a,c};function NS(r,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=e===1.5707963267948966?.551915024494:t,s=Math.cos(r),i=Math.sin(r),o=Math.cos(r+e),a=Math.sin(r+e);return[{x:s-i*n,y:i+s*n},{x:o+a*n,y:a-o*n},{x:o,y:a}]}const Zu=(r,e,t,n)=>{const s=r*n-e*t<0?-1:1;let i=r*t+e*n;return i>1&&(i=1),i<-1&&(i=-1),s*Math.acos(i)},$S=(r,e,t,n,s,i,o,a,c,l,u,h,d)=>{const f=Math.pow(s,2),p=Math.pow(i,2),m=Math.pow(u,2),g=Math.pow(h,2);let _=f*p-f*g-p*m;_<0&&(_=0),_/=f*g+p*m,_=Math.sqrt(_)*(o===a?-1:1);const y=_*s/i*h,b=_*-i/s*u,v=l*y-c*b+(r+t)/2,C=c*y+l*b+(e+n)/2,S=(u-y)/s,E=(h-b)/i,U=(-u-y)/s,z=(-h-b)/i,M=Zu(1,0,S,E);let A=Zu(S,E,U,z);a===0&&A>0&&(A-=Wr),a===1&&A<0&&(A+=Wr),d.centerX=v,d.centerY=C,d.ang1=M,d.ang2=A};function VS(r,e,t,n,s,i,o,a=0,c=0,l=0){if(i===0||o===0)return;const u=Math.sin(a*Wr/360),h=Math.cos(a*Wr/360),d=h*(e-n)/2+u*(t-s)/2,f=-u*(e-n)/2+h*(t-s)/2;if(d===0&&f===0)return;i=Math.abs(i),o=Math.abs(o);const p=Math.pow(d,2)/Math.pow(i,2)+Math.pow(f,2)/Math.pow(o,2);p>1&&(i*=Math.sqrt(p),o*=Math.sqrt(p)),$S(e,t,n,s,i,o,c,l,u,h,d,f,Hi);let{ang1:m,ang2:g}=Hi;const{centerX:_,centerY:y}=Hi;let b=Math.abs(g)/(Wr/4);Math.abs(1-b)<1e-7&&(b=1);const v=Math.max(Math.ceil(b),1);g/=v;let C=r[r.length-2],S=r[r.length-1];const E={x:0,y:0};for(let U=0;U<v;U++){const z=NS(m,g),{x:M,y:A}=ji(z[0],i,o,h,u,_,y,E),{x:j,y:q}=ji(z[1],i,o,h,u,_,y,E),{x:se,y:Ye}=ji(z[2],i,o,h,u,_,y,E);Xu(r,C,S,M,A,j,q,se,Ye),C=se,S=Ye,m+=g}}function HS(r,e,t){const n=(o,a)=>{const c=a.x-o.x,l=a.y-o.y,u=Math.sqrt(c*c+l*l),h=c/u,d=l/u;return{len:u,nx:h,ny:d}},s=(o,a)=>{o===0?r.moveTo(a.x,a.y):r.lineTo(a.x,a.y)};let i=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],c=a.radius??t;if(c<=0){s(o,a),i=a;continue}const l=e[(o+1)%e.length],u=n(a,i),h=n(a,l);if(u.len<1e-4||h.len<1e-4){s(o,a),i=a;continue}let d=Math.asin(u.nx*h.ny-u.ny*h.nx),f=1,p=!1;u.nx*h.nx-u.ny*-h.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,f=-1,p=!0):d>0&&(f=-1,p=!0);const m=d/2;let g,_=Math.abs(Math.cos(m)*c/Math.sin(m));_>Math.min(u.len/2,h.len/2)?(_=Math.min(u.len/2,h.len/2),g=Math.abs(_*Math.sin(m)/Math.cos(m))):g=c;const y=a.x+h.nx*_+-h.ny*g*f,b=a.y+h.ny*_+h.nx*g*f,v=Math.atan2(u.ny,u.nx)+Math.PI/2*f,C=Math.atan2(h.ny,h.nx)-Math.PI/2*f;o===0&&r.moveTo(y+Math.cos(v)*g,b+Math.sin(v)*g),r.arc(y,b,g,v,C,p),i=a}}function jS(r,e,t,n){const s=(a,c)=>Math.sqrt((a.x-c.x)**2+(a.y-c.y)**2),i=(a,c,l)=>({x:a.x+(c.x-a.x)*l,y:a.y+(c.y-a.y)*l}),o=e.length;for(let a=0;a<o;a++){const c=e[(a+1)%o],l=c.radius??t;if(l<=0){a===0?r.moveTo(c.x,c.y):r.lineTo(c.x,c.y);continue}const u=e[a],h=e[(a+2)%o],d=s(u,c);let f;if(d<1e-4)f=c;else{const g=Math.min(d/2,l);f=i(c,u,g/d)}const p=s(h,c);let m;if(p<1e-4)m=c;else{const g=Math.min(p/2,l);m=i(c,h,g/p)}a===0?r.moveTo(f.x,f.y):r.lineTo(f.x,f.y),r.quadraticCurveTo(c.x,c.y,m.x,m.y,n)}}const WS=new fe;class XS{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Pe,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const n=this._currentPoly.points,s=n[n.length-2],i=n[n.length-1];return(s!==e||i!==t)&&n.push(e,t),this}arc(e,t,n,s,i,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Yu(a,e,t,n,s,i,o),this}arcTo(e,t,n,s,i){this._ensurePoly();const o=this._currentPoly.points;return zS(o,e,t,n,s,i),this}arcToSvg(e,t,n,s,i,o,a){const c=this._currentPoly.points;return VS(c,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,n,s,i),this}bezierCurveTo(e,t,n,s,i,o,a){this._ensurePoly();const c=this._currentPoly;return Xu(this._currentPoly.points,c.lastX,c.lastY,e,t,n,s,i,o,a),this}quadraticCurveTo(e,t,n,s,i){this._ensurePoly();const o=this._currentPoly;return US(this._currentPoly.points,o.lastX,o.lastY,e,t,n,s,i),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));const n=this.shapePrimitives,s=n.length;for(let i=0;i<e.instructions.length;i++){const o=e.instructions[i];this[o.action](...o.data)}if(e.checkForHoles&&n.length-s>1){let i=null;for(let o=s;o<n.length;o++){const a=n[o];if(a.shape.type==="polygon"){const c=a.shape,l=i==null?void 0:i.shape;l&&l.containsPolygon(c)?(i.holes||(i.holes=[]),i.holes.push(a),n.copyWithin(o,o+1),n.length--,o--):i=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,n,s,i){return this.drawShape(new fe(e,t,n,s),i),this}circle(e,t,n,s){return this.drawShape(new Si(e,t,n),s),this}poly(e,t,n){const s=new Nr(e);return s.closePath=t,this.drawShape(s,n),this}regularPoly(e,t,n,s,i=0,o){s=Math.max(s|0,3);const a=-1*Math.PI/2+i,c=Math.PI*2/s,l=[];for(let u=0;u<s;u++){const h=a-u*c;l.push(e+n*Math.cos(h),t+n*Math.sin(h))}return this.poly(l,!0,o),this}roundPoly(e,t,n,s,i,o=0,a){if(s=Math.max(s|0,3),i<=0)return this.regularPoly(e,t,n,s,o);const c=n*Math.sin(Math.PI/s)-.001;i=Math.min(i,c);const l=-1*Math.PI/2+o,u=Math.PI*2/s,h=(s-2)*Math.PI/s/2;for(let d=0;d<s;d++){const f=d*u+l,p=e+n*Math.cos(f),m=t+n*Math.sin(f),g=f+Math.PI+h,_=f-Math.PI-h,y=p+i*Math.cos(g),b=m+i*Math.sin(g),v=p+i*Math.cos(_),C=m+i*Math.sin(_);d===0?this.moveTo(y,b):this.lineTo(y,b),this.quadraticCurveTo(p,m,v,C,a)}return this.closePath()}roundShape(e,t,n=!1,s){return e.length<3?this:(n?jS(this,e,t,s):HS(this,e,t),this.closePath())}filletRect(e,t,n,s,i){if(i===0)return this.rect(e,t,n,s);const o=Math.min(n,s)/2,a=Math.min(o,Math.max(-o,i)),c=e+n,l=t+s,u=a<0?-a:0,h=Math.abs(a);return this.moveTo(e,t+h).arcTo(e+u,t+u,e+h,t,h).lineTo(c-h,t).arcTo(c-u,t+u,c,t+h,h).lineTo(c,l-h).arcTo(c-u,l-u,e+n-h,l,h).lineTo(e+h,l).arcTo(e+u,l-u,e,l-h,h).closePath()}chamferRect(e,t,n,s,i,o){if(i<=0)return this.rect(e,t,n,s);const a=Math.min(i,Math.min(n,s)/2),c=e+n,l=t+s,u=[e+a,t,c-a,t,c,t+a,c,l-a,c-a,l,e+a,l,e,l-a,e,t+a];for(let h=u.length-1;h>=2;h-=2)u[h]===u[h-2]&&u[h-1]===u[h-3]&&u.splice(h-1,2);return this.poly(u,!0,o)}ellipse(e,t,n,s,i){return this.drawShape(new wi(e,t,n,s),i),this}roundRect(e,t,n,s,i,o){return this.drawShape(new Pi(e,t,n,s,i),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let n=this._currentPoly;return n&&this.endPoly(),n=new Nr,n.points.push(e,t),this._currentPoly=n,this}endPoly(e=!1){const t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Nr,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let n=t.shape.x,s=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const i=t.transform,o=n;n=i.a*n+i.c*s+i.tx,s=i.b*o+i.d*s+i.ty}this._currentPoly.points.push(n,s)}else this._currentPoly.points.push(0,0)}}buildPath(){const e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){const n=e.instructions[t];this[n.action](...n.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let n=0;n<t.length;n++){const s=t[n],i=s.shape.getBounds(WS);s.transform?e.addRect(i,s.transform):e.addRect(i)}return e}}class vt{constructor(e,t=!1){this.instructions=[],this.uid=ce("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?BT(e,this):this.instructions=(e==null?void 0:e.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new XS(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,n,s,i){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(le.shared);let c=0,l=0;if(!o||o.action!=="bezierCurveTo")c=a.x,l=a.y;else{c=o.data[2],l=o.data[3];const u=a.x,h=a.y;c=u+(u-c),l=h+(h-l)}return this.instructions.push({action:"bezierCurveTo",data:[c,l,e,t,n,s,i]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,n){const s=this.instructions[this.instructions.length-1],i=this.getLastPoint(le.shared);let o=0,a=0;if(!s||s.action!=="quadraticCurveTo")o=i.x,a=i.y;else{o=s.data[0],a=s.data[1];const c=i.x,l=i.y;o=c+(c-o),a=l+(l-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,n]}),this._dirty=!0,this}rect(e,t,n,s,i){return this.instructions.push({action:"rect",data:[e,t,n,s,i]}),this._dirty=!0,this}circle(e,t,n,s){return this.instructions.push({action:"circle",data:[e,t,n,s]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,n,s,i,o,a){i||(i=s/2);const c=-1*Math.PI/2+o,l=n*2,u=Math.PI*2/l,h=[];for(let d=0;d<l;d++){const f=d%2?i:s,p=d*u+c;h.push(e+f*Math.cos(p),t+f*Math.sin(p))}return this.poly(h,!0,a),this}clone(e=!1){const t=new vt;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let n=0;n<this.instructions.length;n++){const s=this.instructions[n];t.instructions.push({action:s.action,data:s.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const t=e.a,n=e.b,s=e.c,i=e.d,o=e.tx,a=e.ty;let c=0,l=0,u=0,h=0,d=0,f=0,p=0,m=0;for(let g=0;g<this.instructions.length;g++){const _=this.instructions[g],y=_.data;switch(_.action){case"moveTo":case"lineTo":c=y[0],l=y[1],y[0]=t*c+s*l+o,y[1]=n*c+i*l+a;break;case"bezierCurveTo":u=y[0],h=y[1],d=y[2],f=y[3],c=y[4],l=y[5],y[0]=t*u+s*h+o,y[1]=n*u+i*h+a,y[2]=t*d+s*f+o,y[3]=n*d+i*f+a,y[4]=t*c+s*l+o,y[5]=n*c+i*l+a;break;case"quadraticCurveTo":u=y[0],h=y[1],c=y[2],l=y[3],y[0]=t*u+s*h+o,y[1]=n*u+i*h+a,y[2]=t*c+s*l+o,y[3]=n*c+i*l+a;break;case"arcToSvg":c=y[5],l=y[6],p=y[0],m=y[1],y[0]=t*p+s*m,y[1]=n*p+i*m,y[5]=t*c+s*l+o,y[6]=n*c+i*l+a;break;case"circle":y[4]=dr(y[3],e);break;case"rect":y[4]=dr(y[4],e);break;case"ellipse":y[8]=dr(y[8],e);break;case"roundRect":y[5]=dr(y[5],e);break;case"addPath":y[0].transform(e);break;case"poly":y[2]=dr(y[2],e);break;case"regularPoly":case"chamferRect":y[5]=dr(y[5],e);break;case"closePath":break;default:W("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,n=this.instructions[t];if(!n)return e.x=0,e.y=0,e;for(;n.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;n=this.instructions[t]}switch(n.action){case"moveTo":case"lineTo":e.x=n.data[0],e.y=n.data[1];break;case"quadraticCurveTo":e.x=n.data[2],e.y=n.data[3];break;case"bezierCurveTo":e.x=n.data[4],e.y=n.data[5];break;case"arc":case"arcToSvg":e.x=n.data[5],e.y=n.data[6];break;case"addPath":n.data[0].getLastPoint(e);break}return e}}function dr(r,e){return r?r.prepend(e):e.clone()}function _e(r,e,t){const n=r.getAttribute(e);return n?Number(n):t}function YS(r,e){const t=r.querySelectorAll("defs");for(let n=0;n<t.length;n++){const s=t[n];for(let i=0;i<s.children.length;i++){const o=s.children[i];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=ZS(o);break;case"radialgradient":e.defs[o.id]=KS();break}}}}function ZS(r){const e=_e(r,"x1",0),t=_e(r,"y1",0),n=_e(r,"x2",1),s=_e(r,"y2",0),i=r.getAttribute("gradientUnits")||"objectBoundingBox",o=new ur(e,t,n,s,i==="objectBoundingBox"?"local":"global");for(let a=0;a<r.children.length;a++){const c=r.children[a],l=_e(c,"offset",0),u=ye.shared.setValue(c.getAttribute("stop-color")).toNumber();o.addColorStop(l,u)}return o}function KS(r){return W("[SVG Parser] Radial gradients are not yet supported"),new ur(0,0,1,0)}function Ku(r){const e=r.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const qu={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function Ju(r,e){const t=r.getAttribute("style"),n={},s={},i={strokeStyle:n,fillStyle:s,useFill:!1,useStroke:!1};for(const o in qu){const a=r.getAttribute(o);a&&Qu(e,i,o,a.trim())}if(t){const o=t.split(";");for(let a=0;a<o.length;a++){const c=o[a].trim(),[l,u]=c.split(":");qu[l]&&Qu(e,i,l,u.trim())}}return{strokeStyle:i.useStroke?n:null,fillStyle:i.useFill?s:null,useFill:i.useFill,useStroke:i.useStroke}}function Qu(r,e,t,n){switch(t){case"stroke":if(n!=="none"){if(n.startsWith("url(")){const s=Ku(n);e.strokeStyle.fill=r.defs[s]}else e.strokeStyle.color=ye.shared.setValue(n).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(n);break;case"fill":if(n!=="none"){if(n.startsWith("url(")){const s=Ku(n);e.fillStyle.fill=r.defs[s]}else e.fillStyle.color=ye.shared.setValue(n).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(n);break;case"stroke-opacity":e.strokeStyle.alpha=Number(n);break;case"opacity":e.fillStyle.alpha=Number(n),e.strokeStyle.alpha=Number(n);break}}function qS(r){if(r.length<=2)return!0;const e=r.map(a=>a.area).sort((a,c)=>c-a),[t,n]=e,s=e[e.length-1],i=t/n,o=n/s;return!(i>3&&o<2)}function JS(r){return r.split(/(?=[Mm])/).filter(n=>n.trim().length>0)}function QS(r){const e=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const t=e.map(Number),n=[],s=[];for(let u=0;u<t.length;u+=2)u+1<t.length&&(n.push(t[u]),s.push(t[u+1]));if(n.length===0||s.length===0)return 0;const i=Math.min(...n),o=Math.max(...n),a=Math.min(...s),c=Math.max(...s);return(o-i)*(c-a)}function eh(r,e){const t=new vt(r,!1);for(const n of t.instructions)e.instructions.push(n)}function ew(r,e){if(typeof r=="string"){const o=document.createElement("div");o.innerHTML=r.trim(),r=o.querySelector("svg")}const t={context:e,defs:{},path:new vt};YS(r,t);const n=r.children,{fillStyle:s,strokeStyle:i}=Ju(r,t);for(let o=0;o<n.length;o++){const a=n[o];a.nodeName.toLowerCase()!=="defs"&&th(a,t,s,i)}return e}function th(r,e,t,n){const s=r.children,{fillStyle:i,strokeStyle:o}=Ju(r,e);i&&t?t={...t,...i}:i&&(t=i),o&&n?n={...n,...o}:o&&(n=o);const a=!t&&!n;a&&(t={color:0});let c,l,u,h,d,f,p,m,g,_,y,b,v,C,S,E,U;switch(r.nodeName.toLowerCase()){case"path":{C=r.getAttribute("d");const z=r.getAttribute("fill-rule"),M=JS(C),A=z==="evenodd",j=M.length>1;if(A&&j){const se=M.map(k=>({path:k,area:QS(k)}));if(se.sort((k,G)=>G.area-k.area),M.length>3||!qS(se))for(let k=0;k<se.length;k++){const G=se[k],re=k===0;e.context.beginPath();const O=new vt(void 0,!0);eh(G.path,O),e.context.path(O),re?(t&&e.context.fill(t),n&&e.context.stroke(n)):e.context.cut()}else for(let k=0;k<se.length;k++){const G=se[k],re=k%2===1;e.context.beginPath();const O=new vt(void 0,!0);eh(G.path,O),e.context.path(O),re?e.context.cut():(t&&e.context.fill(t),n&&e.context.stroke(n))}}else{const se=z?z==="evenodd":!0;S=new vt(C,se),e.context.path(S),t&&e.context.fill(t),n&&e.context.stroke(n)}break}case"circle":p=_e(r,"cx",0),m=_e(r,"cy",0),g=_e(r,"r",0),e.context.ellipse(p,m,g,g),t&&e.context.fill(t),n&&e.context.stroke(n);break;case"rect":c=_e(r,"x",0),l=_e(r,"y",0),E=_e(r,"width",0),U=_e(r,"height",0),_=_e(r,"rx",0),y=_e(r,"ry",0),_||y?e.context.roundRect(c,l,E,U,_||y):e.context.rect(c,l,E,U),t&&e.context.fill(t),n&&e.context.stroke(n);break;case"ellipse":p=_e(r,"cx",0),m=_e(r,"cy",0),_=_e(r,"rx",0),y=_e(r,"ry",0),e.context.beginPath(),e.context.ellipse(p,m,_,y),t&&e.context.fill(t),n&&e.context.stroke(n);break;case"line":u=_e(r,"x1",0),h=_e(r,"y1",0),d=_e(r,"x2",0),f=_e(r,"y2",0),e.context.beginPath(),e.context.moveTo(u,h),e.context.lineTo(d,f),n&&e.context.stroke(n);break;case"polygon":v=r.getAttribute("points"),b=v.match(/-?\d+/g).map(z=>parseInt(z,10)),e.context.poly(b,!0),t&&e.context.fill(t),n&&e.context.stroke(n);break;case"polyline":v=r.getAttribute("points"),b=v.match(/-?\d+/g).map(z=>parseInt(z,10)),e.context.poly(b,!1),n&&e.context.stroke(n);break;case"g":case"svg":break;default:{W(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}a&&(t=null);for(let z=0;z<s.length;z++)th(s[z],e,t,n)}const rh={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class nh{constructor(e,t){this.uid=ce("fillPattern"),this._tick=0,this.transform=new B,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=rh[t].addressModeU,e.source.style.addressModeV=rh[t].addressModeV)}setTransform(e){const t=this.texture;this.transform.copyFrom(e),this.transform.invert(),this.transform.scale(1/t.frame.width,1/t.frame.height),this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function tw(r){return ye.isColorLike(r)}function sh(r){return r instanceof nh}function ih(r){return r instanceof ur}function rw(r){return r instanceof D}function nw(r,e,t){const n=ye.shared.setValue(e??0);return r.color=n.toNumber(),r.alpha=n.alpha===1?t.alpha:n.alpha,r.texture=D.WHITE,{...t,...r}}function sw(r,e,t){return r.texture=e,{...t,...r}}function oh(r,e,t){return r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,{...t,...r}}function ah(r,e,t){return e.buildGradient(),r.fill=e,r.color=16777215,r.texture=e.texture,r.matrix=e.transform,r.textureSpace=e.textureSpace,{...t,...r}}function iw(r,e){const t={...e,...r},n=ye.shared.setValue(t.color);return t.alpha*=n.alpha,t.color=n.toNumber(),t}function Xr(r,e){if(r==null)return null;const t={},n=r;return tw(r)?nw(t,r,e):rw(r)?sw(t,r,e):sh(r)?oh(t,r,e):ih(r)?ah(t,r,e):n.fill&&sh(n.fill)?oh(n,n.fill,e):n.fill&&ih(n.fill)?ah(n,n.fill,e):iw(n,e)}function ch(r,e){const{width:t,alignment:n,miterLimit:s,cap:i,join:o,pixelLine:a,...c}=e,l=Xr(r,c);return l?{width:t,alignment:n,miterLimit:s,cap:i,join:o,pixelLine:a,...l}:null}function ow(r,e){let t=1;const n=r.shapePath.shapePrimitives;for(let s=0;s<n.length;s++){const i=n[s].shape;if(i.type!=="polygon")continue;const o=i.points,a=o.length;if(a<6)continue;const c=i.closePath;for(let l=0;l<a;l+=2){if(!c&&(l===0||l===a-2))continue;const u=(l-2+a)%a,h=(l+2)%a,d=o[u],f=o[u+1],p=o[l],m=o[l+1],g=o[h],_=o[h+1],y=d-p,b=f-m,v=g-p,C=_-m,S=y*y+b*b,E=v*v+C*C;if(S<1e-12||E<1e-12)continue;let M=(y*v+b*C)/Math.sqrt(S*E);M<-1?M=-1:M>1&&(M=1);const A=Math.sqrt((1-M)*.5);if(A<1e-6)continue;const j=Math.min(1/A,e);j>t&&(t=j)}}return t}const aw=new le,lh=new B,Wi=class ut extends Qe{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ce("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new vt,this._transform=new B,this._fillStyle={...ut.defaultFillStyle},this._strokeStyle={...ut.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Pe,this._boundsDirty=!0}clone(){const e=new ut;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=Xr(e,ut.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=ch(e,ut.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Xr(e,ut.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Xr(e,ut.defaultStrokeStyle),this}texture(e,t,n,s,i,o){return this.instructions.push({action:"texture",data:{image:e,dx:n||0,dy:s||0,dw:i||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?ye.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new vt,this}fill(e,t){let n;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="stroke"?n=s.data.path:n=this._activePath.clone(),n?(e!=null&&(t!==void 0&&typeof e=="number"&&(N(de,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=Xr(e,ut.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(le.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const n=this.instructions[this.instructions.length-1];return this._tick===0&&(n==null?void 0:n.action)==="fill"?t=n.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=ch(e,ut.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const t=this.instructions[this.instructions.length-1-e],n=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(n);else{t.data.hole=n;break}}return this._initNextPathLocation(),this}arc(e,t,n,s,i,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,n,s,i,o),this}arcTo(e,t,n,s,i){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*n+o.c*s+o.tx,o.b*n+o.d*s+o.ty,i),this}arcToSvg(e,t,n,s,i,o,a){this._tick++;const c=this._transform;return this._activePath.arcToSvg(e,t,n,s,i,c.a*o+c.c*a+c.tx,c.b*o+c.d*a+c.ty),this}bezierCurveTo(e,t,n,s,i,o,a){this._tick++;const c=this._transform;return this._activePath.bezierCurveTo(c.a*e+c.c*t+c.tx,c.b*e+c.d*t+c.ty,c.a*n+c.c*s+c.tx,c.b*n+c.d*s+c.ty,c.a*i+c.c*o+c.tx,c.b*i+c.d*o+c.ty,a),this}closePath(){var e;return this._tick++,(e=this._activePath)==null||e.closePath(),this}ellipse(e,t,n,s){return this._tick++,this._activePath.ellipse(e,t,n,s,this._transform.clone()),this}circle(e,t,n){return this._tick++,this._activePath.circle(e,t,n,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const n=this._transform;return this._activePath.lineTo(n.a*e+n.c*t+n.tx,n.b*e+n.d*t+n.ty),this}moveTo(e,t){this._tick++;const n=this._transform,s=this._activePath.instructions,i=n.a*e+n.c*t+n.tx,o=n.b*e+n.d*t+n.ty;return s.length===1&&s[0].action==="moveTo"?(s[0].data[0]=i,s[0].data[1]=o,this):(this._activePath.moveTo(i,o),this)}quadraticCurveTo(e,t,n,s,i){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*n+o.c*s+o.tx,o.b*n+o.d*s+o.ty,i),this}rect(e,t,n,s){return this._tick++,this._activePath.rect(e,t,n,s,this._transform.clone()),this}roundRect(e,t,n,s,i){return this._tick++,this._activePath.roundRect(e,t,n,s,i,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,n,s,i=0,o){return this._tick++,this._activePath.regularPoly(e,t,n,s,i,o),this}roundPoly(e,t,n,s,i,o){return this._tick++,this._activePath.roundPoly(e,t,n,s,i,o),this}roundShape(e,t,n,s){return this._tick++,this._activePath.roundShape(e,t,n,s),this}filletRect(e,t,n,s,i){return this._tick++,this._activePath.filletRect(e,t,n,s,i),this}chamferRect(e,t,n,s,i,o){return this._tick++,this._activePath.chamferRect(e,t,n,s,i,o),this}star(e,t,n,s,i=0,o=0){return this._tick++,this._activePath.star(e,t,n,s,i,o,this._transform.clone()),this}svg(e){return this._tick++,ew(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,n,s,i,o){return e instanceof B?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,n,s,i,o),this)}transform(e,t,n,s,i,o){return e instanceof B?(this._transform.append(e),this):(lh.set(e,t,n,s,i,o),this._transform.append(lh),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){const n=this.instructions[t],s=n.action;if(s==="fill"){const i=n.data;e.addBounds(i.path.bounds)}else if(s==="texture"){const i=n.data;e.addFrame(i.dx,i.dy,i.dx+i.dw,i.dy+i.dh,i.transform)}if(s==="stroke"){const i=n.data,o=i.style.alignment;let a=i.style.width*(1-o);i.style.join==="miter"&&(a*=ow(i.path,i.style.miterLimit));const c=i.path.bounds;e.addFrame(c.minX-a,c.minY-a,c.maxX+a,c.maxY+a)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){var s;if(!this.bounds.containsPoint(e.x,e.y))return!1;const t=this.instructions;let n=!1;for(let i=0;i<t.length;i++){const o=t[i],a=o.data,c=a.path;if(!o.action||!c)continue;const l=a.style,u=c.shapePath.shapePrimitives;for(let h=0;h<u.length;h++){const d=u[h].shape;if(!l||!d)continue;const f=u[h].transform,p=f?f.applyInverse(e,aw):e;if(o.action==="fill")n=d.contains(p.x,p.y);else{const g=l;n=d.strokeContains(p.x,p.y,g.width,g.alignment)}const m=a.hole;if(m){const g=(s=m.shapePath)==null?void 0:s.shapePrimitives;if(g)for(let _=0;_<g.length;_++)g[_].shape.contains(p.x,p.y)&&(n=!1)}if(n)return!0}}return n}unload(){var e;this.emit("unload",this);for(const t in this._gpuData)(e=this._gpuData[t])==null||e.destroy();this._gpuData=Object.create(null)}destroy(e=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof e=="boolean"?e:e==null?void 0:e.texture){const n=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(n)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(n))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Wi.defaultFillStyle={color:16777215,alpha:1,texture:D.WHITE,matrix:null,fill:null,textureSpace:"local"},Wi.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:D.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Yr=Wi;class uh{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new Nl({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){const e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){const n=e[t],s=n.element;if(!n.parent||n.globalDisplayStatus<7)s==null||s.remove(),e.splice(t,1),t--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const i=n.worldTransform,o=n._anchor,a=n.width*o.x,c=n.height*o.y;s.style.transformOrigin=`${a}px ${c}px`,s.style.transform=`matrix(${i.a}, ${i.b}, ${i.c}, ${i.d}, ${i.tx-a}, ${i.ty-c})`,s.style.opacity=n.groupAlpha.toString()}}}destroy(){var e;this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++)(e=this._attachedDomElements[t].element)==null||e.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}uh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"dom"};class cw{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this._tickerAdded||!this.domElement||(Xe.system.add(this._tickerUpdate,this,sr.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Xe.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}}const Tt=new cw;class Xn extends Ur{constructor(){super(...arguments),this.client=new le,this.movement=new le,this.offset=new le,this.global=new le,this.screen=new le}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,n){return e.worldTransform.applyInverse(n||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,n,s,i,o,a,c,l,u,h,d,f,p,m){throw new Error("Method not implemented.")}}class rt extends Xn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class fr extends Xn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}fr.DOM_DELTA_PIXEL=0,fr.DOM_DELTA_LINE=1,fr.DOM_DELTA_PAGE=2;const lw=2048,uw=new le,Zr=new le;class hw{constructor(e){this.dispatch=new Qe,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((n,s)=>n.priority-s.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let n=0,s=t.length;n<s;n++)t[n].fn(e);else W(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Tt.pauseUpdate=!0;const s=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",i=this[s](this.rootTarget,this.rootTarget.eventMode,uw.set(e,t),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(e,t){if(!e.target)return;const n=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let s=0,i=n.length-1;s<i;s++)if(e.currentTarget=n[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let s=n.length-2;s>=0;s--)if(e.currentTarget=n[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,n=this._allInteractiveElements){if(n.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const s=Array.isArray(t)?t:[t];for(let i=n.length-1;i>=0;i--)s.forEach(o=>{e.currentTarget=n[i],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let n=0;n<lw&&e!==this.rootTarget&&e.parent;n++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,n,s,i,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Tt.pauseUpdate=!1),e.interactiveChildren&&e.children){const u=e.children;for(let h=u.length-1;h>=0;h--){const d=u[h],f=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,n,s,i,o||i(e,n));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=e.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(e),f.push(e)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const c=this._isInteractive(t),l=e.isInteractive();return l&&l&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:c&&!i(e,n)&&s(e,n)?l?[e]:[]:null}hitTestRecursive(e,t,n,s,i){if(this._interactivePrune(e)||i(e,n))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(Tt.pauseUpdate=!1),e.interactiveChildren&&e.children){const c=e.children,l=n;for(let u=c.length-1;u>=0;u--){const h=c[u],d=this.hitTestRecursive(h,this._isInteractive(t)?t:h.eventMode,l,s,i);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const f=e.isInteractive();return(d.length>0||f)&&d.push(e),d}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&s(e,n)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.measurable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,Zr),!e.hitArea.contains(Zr.x,Zr.y)))return!0;if(e.effects&&e.effects.length)for(let n=0;n<e.effects.length;n++){const s=e.effects[n];if(s.containsPoint&&!s.containsPoint(t,this.hitTestFn))return!0}return!1}hitTestFn(e,t){return e.hitArea?!0:e!=null&&e.containsPoint?(e.worldTransform.applyInverse(t,Zr),e.containsPoint(Zr)):!1}notifyTarget(e,t){var i,o;if(!e.currentTarget.isInteractive())return;t??(t=e.type);const n=`on${t}`;(o=(i=e.currentTarget)[n])==null||o.call(i,e);const s=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this._notifyListeners(e,s),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof rt)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const s=t.button===2;this.dispatchEvent(t,s?"rightdown":"mousedown")}const n=this.trackingData(e.pointerId);n.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){var c,l;if(!(e instanceof rt)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const n=t.pointerType==="mouse"||t.pointerType==="pen",s=this.trackingData(e.pointerId),i=this.findMountedTarget(s.overTargets);if(((c=s.overTargets)==null?void 0:c.length)>0&&i!==t.target){const u=e.type==="mousemove"?"mouseout":"pointerout",h=this.createPointerEvent(e,u,i);if(this.dispatchEvent(h,"pointerout"),n&&this.dispatchEvent(h,"mouseout"),!t.composedPath().includes(i)){const d=this.createPointerEvent(e,"pointerleave",i);for(d.eventPhase=d.AT_TARGET;d.target&&!t.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),n&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(h)}if(i!==t.target){const u=e.type==="mousemove"?"mouseover":"pointerover",h=this.clonePointerEvent(t,u);this.dispatchEvent(h,"pointerover"),n&&this.dispatchEvent(h,"mouseover");let d=i==null?void 0:i.parent;for(;d&&d!==this.rootTarget.parent&&d!==t.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const p=this.clonePointerEvent(t,"pointerenter");for(p.eventPhase=p.AT_TARGET;p.target&&p.target!==i&&p.target!==this.rootTarget.parent;)p.currentTarget=p.target,this.notifyTarget(p),n&&this.notifyTarget(p,"mouseenter"),p.target=p.target.parent;this.freeEvent(p)}this.freeEvent(h)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(t,"pointermove"),a&&o.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),a&&o.push("globaltouchmove")),n&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(l=t.target)==null?void 0:l.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){var o;if(!(e instanceof rt)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),n=this.createPointerEvent(e),s=n.pointerType==="mouse"||n.pointerType==="pen";this.dispatchEvent(n,"pointerover"),s&&this.dispatchEvent(n,"mouseover"),n.pointerType==="mouse"&&(this.cursor=(o=n.target)==null?void 0:o.cursor);const i=this.clonePointerEvent(n,"pointerenter");for(i.eventPhase=i.AT_TARGET;i.target&&i.target!==this.rootTarget.parent;)i.currentTarget=i.target,this.notifyTarget(i),s&&this.notifyTarget(i,"mouseenter"),i.target=i.target.parent;t.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(i)}mapPointerOut(e){if(!(e instanceof rt)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const n=e.pointerType==="mouse"||e.pointerType==="pen",s=this.findMountedTarget(t.overTargets),i=this.createPointerEvent(e,"pointerout",s);this.dispatchEvent(i),n&&this.dispatchEvent(i,"mouseout");const o=this.createPointerEvent(e,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),n&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(i),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof rt)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),n=this.createPointerEvent(e);if(this.dispatchEvent(n,"pointerup"),n.pointerType==="touch")this.dispatchEvent(n,"touchend");else if(n.pointerType==="mouse"||n.pointerType==="pen"){const a=n.button===2;this.dispatchEvent(n,a?"rightup":"mouseup")}const s=this.trackingData(e.pointerId),i=this.findMountedTarget(s.pressTargetsByButton[e.button]);let o=i;if(i&&!n.composedPath().includes(i)){let a=i;for(;a&&!n.composedPath().includes(a);){if(n.currentTarget=a,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch")this.notifyTarget(n,"touchendoutside");else if(n.pointerType==="mouse"||n.pointerType==="pen"){const c=n.button===2;this.notifyTarget(n,c?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(n,"click");a.target=o,a.path=null,s.clicksByButton[e.button]||(s.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const c=s.clicksByButton[e.button];if(c.target===a.target&&t-c.timeStamp<200?++c.clickCount:c.clickCount=1,c.target=a.target,c.timeStamp=t,a.detail=c.clickCount,a.pointerType==="mouse"){const l=a.button===2;this.dispatchEvent(a,l?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(n)}mapPointerUpOutside(e){if(!(e instanceof rt)){W("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),n=this.findMountedTarget(t.pressTargetsByButton[e.button]),s=this.createPointerEvent(e);if(n){let i=n;for(;i;)s.currentTarget=i,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),i=i.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(s)}mapWheel(e){if(!(e instanceof fr)){W("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let n=1;n<e.length&&e[n].parent===t;n++)t=e[n];return t}createPointerEvent(e,t,n){const s=this.allocateEvent(rt);return this.copyPointerData(e,s),this.copyMouseData(e,s),this.copyData(e,s),s.nativeEvent=e.nativeEvent,s.originalEvent=e,s.target=n??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof t=="string"&&(s.type=t),s}createWheelEvent(e){const t=this.allocateEvent(fr);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const n=this.allocateEvent(rt);return n.nativeEvent=e.nativeEvent,n.originalEvent=e.originalEvent,this.copyPointerData(e,n),this.copyMouseData(e,n),this.copyData(e,n),n.target=e.target,n.path=e.composedPath().slice(),n.type=t??n.type,n}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof rt&&t instanceof rt&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist)}copyMouseData(e,t){e instanceof Xn&&t instanceof Xn&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.defaultPrevented=!1,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){const n=e.currentTarget._events[t];if(n)if("fn"in n)n.once&&e.currentTarget.removeListener(t,n.fn,void 0,!0),n.fn.call(n.context,e);else for(let s=0,i=n.length;s<i&&!e.propagationImmediatelyStopped;s++)n[s].once&&e.currentTarget.removeListener(t,n[s].fn,void 0,!0),n[s].fn.call(n[s].context,e)}}const dw=1,fw={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Xi=class Go{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new hw(null),Tt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new rt(null),this._rootWheelEvent=new fr(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Go.defaultEventFeatures},{set:(t,n,s)=>(n==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),t[n]=s,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{canvas:t,resolution:n}=this.renderer;this.setTargetElement(t),this.resolution=n,Go._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){Tt.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||(e="default");let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;const n=this.cursorStyles[e];if(n)switch(typeof n){case"string":t&&(this.domElement.style.cursor=n);break;case"function":n(e);break;case"object":t&&Object.assign(this.domElement.style,n);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let n=0,s=t.length;n<s;n++){const i=t[n],o=this._bootstrapEvent(this._rootPointerEvent,i);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Tt.pointerMoved();const t=this._normalizeToPointerData(e);for(let n=0,s=t.length;n<s;n++){const i=this._bootstrapEvent(this._rootPointerEvent,t[n]);this.rootBoundary.mapEvent(i)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const n=t!==this.domElement?"outside":"",s=this._normalizeToPointerData(e);for(let i=0,o=s.length;i<o;i++){const a=this._bootstrapEvent(this._rootPointerEvent,s[i]);a.type+=n,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);for(let n=0,s=t.length;n<s;n++){const i=this._bootstrapEvent(this._rootPointerEvent,t[n]);this.rootBoundary.mapEvent(i)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,Tt.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Tt.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;Tt.removeTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(e,t,n){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},i=1/this.resolution;e.x=(t-s.left)*(this.domElement.width/s.width)*i,e.y=(n-s.top)*(this.domElement.height/s.height)*i}_normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let n=0,s=e.changedTouches.length;n<s;n++){const i=e.changedTouches[n];typeof i.button>"u"&&(i.button=0),typeof i.buttons>"u"&&(i.buttons=1),typeof i.isPrimary>"u"&&(i.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof i.width>"u"&&(i.width=i.radiusX||1),typeof i.height>"u"&&(i.height=i.radiusY||1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="touch"),typeof i.pointerId>"u"&&(i.pointerId=i.identifier||0),typeof i.pressure>"u"&&(i.pressure=i.force||.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),typeof i.layerX>"u"&&(i.layerX=i.offsetX=i.clientX),typeof i.layerY>"u"&&(i.layerY=i.offsetY=i.clientY),i.isNormalized=!0,i.type=e.type,i.altKey??(i.altKey=e.altKey),i.ctrlKey??(i.ctrlKey=e.ctrlKey),i.metaKey??(i.metaKey=e.metaKey),i.shiftKey??(i.shiftKey=e.shiftKey),t.push(i)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const n=e;typeof n.isPrimary>"u"&&(n.isPrimary=!0),typeof n.width>"u"&&(n.width=1),typeof n.height>"u"&&(n.height=1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="mouse"),typeof n.pointerId>"u"&&(n.pointerId=dw),typeof n.pressure>"u"&&(n.pressure=.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),n.isNormalized=!0,t.push(n)}else t.push(e);return t}normalizeWheelEvent(e){const t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=fw[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};Xi.extension={name:"events",type:[x.WebGLSystem,x.CanvasSystem,x.WebGPUSystem],priority:-1},Xi.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let hh=Xi;const pw={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??hh.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,e,t){const n=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof t=="object"?t.signal:void 0,i=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;r=n?`${r}capture`:r;const a=typeof e=="function"?e:e.handleEvent,c=this;s&&s.addEventListener("abort",()=>{c.off(r,a,o)}),i?c.once(r,a,o):c.on(r,a,o)},removeEventListener(r,e,t){const n=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,s=typeof e=="function"?void 0:e;r=n?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.off(r,e,s)},dispatchEvent(r){if(!(r instanceof Ur))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};let pr;function dh(r){const e=te.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=r,t.fillRect(0,0,6,1),e}function fh(){if(pr!==void 0)return pr;try{const r=dh("#ff00ff"),e=dh("#ffff00"),n=te.get().createCanvas(6,1).getContext("2d");n.globalCompositeOperation="multiply",n.drawImage(r,0,0),n.drawImage(e,2,0);const s=n.getImageData(2,0,1,1);if(!s)pr=!1;else{const i=s.data;pr=i[0]===255&&i[1]===0&&i[2]===0}}catch{pr=!1}return pr}const Y={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:fh(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{const e=r.source,t=e==null?void 0:e.resource;if(!t)return null;const n=e.alphaMode==="premultiplied-alpha",s=e.resourceWidth??e.pixelWidth,i=e.resourceHeight??e.pixelHeight,o=s!==e.pixelWidth||i!==e.pixelHeight;if(n){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=Y._unpremultipliedCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const a=Y._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const c=te.get().createCanvas(e.pixelWidth,e.pixelHeight),l=c.getContext("2d"),u=l.createImageData(e.pixelWidth,e.pixelHeight),h=u.data,d=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let f=0;f<h.length&&f+3<d.length;f+=4)h[f]=d[f+2],h[f+1]=d[f+1],h[f+2]=d[f],h[f+3]=d[f+3];else h.set(d.subarray(0,h.length));return l.putImageData(u,0,0),Y._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}if(n){const a=te.get().createCanvas(e.pixelWidth,e.pixelHeight),c=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,c.drawImage(t,0,0);const l=c.getImageData(0,0,a.width,a.height),u=l.data;for(let h=0;h<u.length;h+=4){const d=u[h+3];if(d>0){const f=255/d;u[h]=Math.min(255,u[h]*f+.5),u[h+1]=Math.min(255,u[h+1]*f+.5),u[h+2]=Math.min(255,u[h+2]*f+.5)}}return c.putImageData(l,0,0),Y._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=Y._canvasSourceCache.get(e);if((a==null?void 0:a.resourceId)===e._resourceId)return a.canvas;const c=te.get().createCanvas(e.pixelWidth,e.pixelHeight),l=c.getContext("2d");return c.width=e.pixelWidth,c.height=e.pixelHeight,l.drawImage(t,0,0),Y._canvasSourceCache.set(e,{canvas:c,resourceId:e._resourceId}),c}return t},getTintedCanvas:(r,e)=>{const t=r.texture,n=ye.shared.setValue(e).toHex(),s=t.tintCache||(t.tintCache={}),i=s[n],o=t.source._resourceId;if((i==null?void 0:i.tintId)===o)return i;const a=i&&"getContext"in i?i:te.get().createCanvas();return Y.tintMethod(t,e,a),a.tintId=o,s[n]=a,s[n]},getTintedPattern:(r,e)=>{const t=ye.shared.setValue(e).toHex(),n=r.patternCache||(r.patternCache={}),s=r.source._resourceId;let i=n[t];return(i==null?void 0:i.tintId)===s||(Y.canvas||(Y.canvas=te.get().createCanvas()),Y.tintMethod(r,e,Y.canvas),i=Y.canvas.getContext("2d").createPattern(Y.canvas,"repeat"),i.tintId=s,n[t]=i),i},applyPatternTransform:(r,e,t=!0)=>{if(!e)return;const n=r;if(!n.setTransform)return;const s=globalThis.DOMMatrix;if(!s)return;const i=new s([e.a,e.b,e.c,e.d,e.tx,e.ty]);n.setTransform(t?i.inverse():i)},tintWithMultiply:(r,e,t)=>{const n=t.getContext("2d"),s=r.frame.clone(),i=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=i,s.y*=i,s.width*=i,s.height*=i;const a=X.isVertical(o),c=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(c),t.height=Math.ceil(l),n.save(),n.fillStyle=ye.shared.setValue(e).toHex(),n.fillRect(0,0,c,l),n.globalCompositeOperation="multiply";const u=Y.getCanvasSource(r);if(!u){n.restore();return}o&&Y._applyInverseRotation(n,o,s.width,s.height),n.drawImage(u,s.x,s.y,s.width,s.height,0,0,s.width,s.height),n.globalCompositeOperation="destination-atop",n.drawImage(u,s.x,s.y,s.width,s.height,0,0,s.width,s.height),n.restore()},tintWithOverlay:(r,e,t)=>{const n=t.getContext("2d"),s=r.frame.clone(),i=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=i,s.y*=i,s.width*=i,s.height*=i;const a=X.isVertical(o),c=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(c),t.height=Math.ceil(l),n.save(),n.globalCompositeOperation="copy",n.fillStyle=ye.shared.setValue(e).toHex(),n.fillRect(0,0,c,l),n.globalCompositeOperation="destination-atop";const u=Y.getCanvasSource(r);if(!u){n.restore();return}o&&Y._applyInverseRotation(n,o,s.width,s.height),n.drawImage(u,s.x,s.y,s.width,s.height,0,0,s.width,s.height),n.restore()},tintWithPerPixel:(r,e,t)=>{const n=t.getContext("2d"),s=r.frame.clone(),i=r.source._resolution??r.source.resolution??1,o=r.rotate;s.x*=i,s.y*=i,s.width*=i,s.height*=i;const a=X.isVertical(o),c=a?s.height:s.width,l=a?s.width:s.height;t.width=Math.ceil(c),t.height=Math.ceil(l),n.save(),n.globalCompositeOperation="copy";const u=Y.getCanvasSource(r);if(!u){n.restore();return}o&&Y._applyInverseRotation(n,o,s.width,s.height),n.drawImage(u,s.x,s.y,s.width,s.height,0,0,s.width,s.height),n.restore();const h=e>>16&255,d=e>>8&255,f=e&255,p=n.getImageData(0,0,c,l),m=p.data;for(let g=0;g<m.length;g+=4)m[g]=m[g]*h/255,m[g+1]=m[g+1]*d/255,m[g+2]=m[g+2]*f/255;n.putImageData(p,0,0)},_applyInverseRotation:(r,e,t,n)=>{const s=X.inv(e),i=X.uX(s),o=X.uY(s),a=X.vX(s),c=X.vY(s),l=-Math.min(0,i*t,a*n,i*t+a*n),u=-Math.min(0,o*t,c*n,o*t+c*n);r.transform(i,o,a,c,l,u)}};Y.tintMethod=Y.canUseMultiply?Y.tintWithMultiply:Y.tintWithPerPixel;class mw{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const n=te.get().createCanvas();n.width=e,n.height=t;const s=n.getContext("2d");return{canvas:n,context:s}}getOptimalCanvasAndContext(e,t,n=1){e=Math.ceil(e*n-1e-6),t=Math.ceil(t*n-1e-6),e=Sn(e),t=Sn(t);const s=(e<<17)+(t<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let i=this._canvasPool[s].pop();return i||(i=this._createCanvasAndContext(e,t)),i}returnCanvasAndContext(e){const t=e.canvas,{width:n,height:s}=t,i=(n<<17)+(s<<1);e.context.resetTransform(),e.context.clearRect(0,0,n,s),this._canvasPool[i].push(e)}clear(){this._canvasPool={}}}const Yn=new mw;Kt.register(Yn);function ph(r,e,t,n,s,i,o,a){const c=o-t,l=a-n,u=s-t,h=i-n,d=r-t,f=e-n,p=c*c+l*l,m=c*u+l*h,g=c*d+l*f,_=u*u+h*h,y=u*d+h*f,b=1/(p*_-m*m),v=(_*g-m*y)*b,C=(p*y-m*g)*b;return v>=0&&C>=0&&v+C<1}const mh=new B;function gh(r,e){e.clear();const t=e.matrix;for(let n=0;n<r.length;n++){const s=r[n];if(s.globalDisplayStatus<7)continue;const i=s.renderGroup??s.parentRenderGroup;i!=null&&i.isCachedAsTexture?e.matrix=mh.copyFrom(i.textureOffsetInverseTransform).append(s.worldTransform):i!=null&&i._parentCacheAsTextureRenderGroup?e.matrix=mh.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):e.matrix=s.worldTransform,e.addBounds(s.bounds)}return e.matrix=t,e}const gw=new Pe;function _w(r,e,t,n,s=!1){const i=gw;i.minX=0,i.minY=0,i.maxX=r.width/n|0,i.maxY=r.height/n|0;const o=Re.getOptimalTexture(i.width,i.height,n,!1,s);return o.source.uploadMethodId="image",o.source.resource=r,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=e/n,o.frame.height=t/n,o.source.emit("update",o.source),o.updateUvs(),o}function _h(r){return typeof r.getCanvasFilterString=="function"}class yw{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new Pe,this.cssFilterString=""}}class yh{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){const t=this._pushFilterFrame(),n=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=n,t.container=e.container,t.cssFilterString="",n.every(c=>!c.enabled)){t.skip=!0;return}const s=[],i=1;for(const c of n){if(!c.enabled)continue;if(!_h(c)){this._warnUnsupportedFilter(c);continue}const l=c.getCanvasFilterString();if(l===null){this._warnUnsupportedFilter(c);continue}l&&s.push(l)}if(s.length===0&&i===1){t.skip=!0;return}t.cssFilterString=s.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){const c=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(t.bounds.x*c,t.bounds.y*c,t.bounds.width*c,t.bounds.height*c),o.clip()}else t.useClip=!1;t.cssFilterString&&(o.filter=a!=="none"?`${a} ${t.cssFilterString}`:t.cssFilterString)}pop(){const e=this._popFilterFrame();if(e.skip)return;const t=this._savedStates.pop();if(!t)return;const n=this.renderer.canvasContext.activeContext;e.useClip?n.restore():n.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!(t!=null&&t.length)||t.every(_=>!_.enabled))return e;const n=[],s=1;for(const _ of t){if(!_.enabled)continue;if(!_h(_)){this._warnUnsupportedFilter(_);continue}const y=_.getCanvasFilterString();if(y===null){this._warnUnsupportedFilter(_);continue}y&&n.push(y)}if(n.length===0&&s===1)return e;const i=Y.getCanvasSource(e);if(!i)return e;const o=e.frame,a=e.source._resolution??e.source.resolution??1,c=o.width,l=o.height,u=Yn.getOptimalCanvasAndContext(c,l,a),{canvas:h,context:d}=u;d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,h.width,h.height),n.length&&(d.filter=n.join(" "));const f=o.x*a,p=o.y*a,m=c*a,g=l*a;return d.drawImage(i,f,p,m,g,0,0,m,g),d.filter="none",d.globalAlpha=1,_w(h,c,l,a)}_calculateFilterArea(e,t){if(e.renderables?gh(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const n=e.container.renderGroup||e.container.parentRenderGroup,s=n==null?void 0:n.cacheToLocalTransform;s&&t.applyMatrix(s)}}_warnUnsupportedFilter(e){var n;const t=((n=e==null?void 0:e.constructor)==null?void 0:n.name)||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new yw),this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}yh.extension={type:[x.CanvasSystem],name:"filter"};var bw=`in vec2 aPosition;
609
+ out vec2 vTextureCoord;
610
+
611
+ uniform vec4 uInputSize;
612
+ uniform vec4 uOutputFrame;
613
+ uniform vec4 uOutputTexture;
614
+
615
+ vec4 filterVertexPosition( void )
616
+ {
617
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
618
+
619
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
620
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
621
+
622
+ return vec4(position, 0.0, 1.0);
623
+ }
624
+
625
+ vec2 filterTextureCoord( void )
626
+ {
627
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
628
+ }
629
+
630
+ void main(void)
631
+ {
632
+ gl_Position = filterVertexPosition();
633
+ vTextureCoord = filterTextureCoord();
634
+ }
635
+ `,xw=`in vec2 vTextureCoord;
636
+ out vec4 finalColor;
637
+ uniform sampler2D uTexture;
638
+ void main() {
639
+ finalColor = texture(uTexture, vTextureCoord);
640
+ }
641
+ `,bh=`struct GlobalFilterUniforms {
642
+ uInputSize: vec4<f32>,
643
+ uInputPixel: vec4<f32>,
644
+ uInputClamp: vec4<f32>,
645
+ uOutputFrame: vec4<f32>,
646
+ uGlobalFrame: vec4<f32>,
647
+ uOutputTexture: vec4<f32>,
648
+ };
649
+
650
+ @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
651
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
652
+ @group(0) @binding(2) var uSampler: sampler;
653
+
654
+ struct VSOutput {
655
+ @builtin(position) position: vec4<f32>,
656
+ @location(0) uv: vec2<f32>
657
+ };
658
+
659
+ fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
660
+ {
661
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
662
+
663
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
664
+ position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
665
+
666
+ return vec4(position, 0.0, 1.0);
667
+ }
668
+
669
+ fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
670
+ {
671
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
672
+ }
673
+
674
+ @vertex
675
+ fn mainVertex(
676
+ @location(0) aPosition: vec2<f32>,
677
+ ) -> VSOutput {
678
+ return VSOutput(
679
+ filterVertexPosition(aPosition),
680
+ filterTextureCoord(aPosition)
681
+ );
682
+ }
683
+
684
+ @fragment
685
+ fn mainFragment(
686
+ @location(0) uv: vec2<f32>,
687
+ ) -> @location(0) vec4<f32> {
688
+ return textureSample(uTexture, uSampler, uv);
689
+ }
690
+ `;class vw extends vi{constructor(){const e=Ut.from({vertex:{source:bh,entryPoint:"mainVertex"},fragment:{source:bh,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=Ot.from({vertex:bw,fragment:xw,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}class xh{constructor(e){this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}xh.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"filter"};const Tw=new tr({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class Sw{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new Pe,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class vh{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new je({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new yt({}),this.renderer=e}get activeBackTexture(){var e;return(e=this._activeFilterData)==null?void 0:e.backTexture}push(e){const t=this.renderer,n=e.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=n,s.container=e.container,s.outputRenderSurface=t.renderTarget.renderSurface;const i=t.renderTarget.renderTarget.colorTexture.source,o=i.resolution,a=i.antialias;if(n.every(f=>!f.enabled)){s.skip=!0;return}const c=s.bounds;if(this._calculateFilterArea(e,c),this._calculateFilterBounds(s,t.renderTarget.rootViewPort,a,o,1),s.skip)return;const l=this._getPreviousFilterData(),u=this._findFilterResolution(o);let h=0,d=0;l&&(h=l.bounds.minX,d=l.bounds.minY),this._calculateGlobalFrame(s,h,d,u,i.width,i.height),this._setupFilterTextures(s,c,t,l)}generateFilteredTexture({texture:e,filters:t}){const n=this._pushFilterData();this._activeFilterData=n,n.skip=!1,n.filters=t;const s=e.source,i=s.resolution,o=s.antialias;if(t.every(f=>!f.enabled))return n.skip=!0,e;const a=n.bounds;if(a.addRect(e.frame),this._calculateFilterBounds(n,a.rectangle,o,i,0),n.skip)return e;const c=i;this._calculateGlobalFrame(n,0,0,c,s.width,s.height),n.outputRenderSurface=Re.getOptimalTexture(a.width,a.height,n.resolution,n.antialias),n.backTexture=D.EMPTY,n.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(n,!0);const d=n.outputRenderSurface;return d.source.alphaMode="premultiplied-alpha",d}pop(){const e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&Re.returnTexture(t.backTexture),Re.returnTexture(t.inputTexture))}getBackTexture(e,t,n){const s=e.colorTexture.source._resolution,i=Re.getOptimalTexture(t.width,t.height,s,!1);let o=t.minX,a=t.minY;n&&(o-=n.minX,a-=n.minY),o=Math.floor(o*s),a=Math.floor(a*s);const c=Math.ceil(t.width*s),l=Math.ceil(t.height*s);return this.renderer.renderTarget.copyToTexture(e,i,{x:o,y:a},{width:c,height:l},{x:0,y:0}),i}applyFilter(e,t,n,s){const i=this.renderer,o=this._activeFilterData,c=o.outputRenderSurface===n,l=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let h=0,d=0;if(c){const p=this._findPreviousFilterOffset();h=p.x,d=p.y}this._updateFilterUniforms(t,n,o,h,d,u,c,s);const f=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,t,i)}calculateSpriteMatrix(e,t){const n=this._activeFilterData,s=e.set(n.inputTexture._source.width,0,0,n.inputTexture._source.height,n.bounds.minX,n.bounds.minY),i=t.worldTransform.copyTo(B.shared),o=t.renderGroup||t.parentRenderGroup;return o&&o.cacheToLocalTransform&&i.prepend(o.cacheToLocalTransform),i.invert(),s.prepend(i),s.scale(1/t.texture.orig.width,1/t.texture.orig.height),s.translate(t.anchor.x,t.anchor.y),s}destroy(){var e;(e=this._passthroughFilter)==null||e.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new vw),this._passthroughFilter}_setupBindGroupsAndRender(e,t,n){if(n.renderPipes.uniformBatch){const s=n.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:Tw,shader:e,state:e._state,topology:"triangle-list"}),n.type===at.WEBGL&&n.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,n,s){if(e.backTexture=D.EMPTY,e.inputTexture=Re.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){n.renderTarget.finishRenderPass();const i=n.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(i,t,s==null?void 0:s.bounds)}n.renderTarget.bind(e.inputTexture,!0),n.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,n,s,i,o){const a=e.globalFrame;a.x=t*s,a.y=n*s,a.width=i*s,a.height=o*s}_updateFilterUniforms(e,t,n,s,i,o,a,c){const l=this._filterGlobalUniforms.uniforms,u=l.uOutputFrame,h=l.uInputSize,d=l.uInputPixel,f=l.uInputClamp,p=l.uGlobalFrame,m=l.uOutputTexture;a?(u[0]=n.bounds.minX-s,u[1]=n.bounds.minY-i):(u[0]=0,u[1]=0),u[2]=e.frame.width,u[3]=e.frame.height,h[0]=e.source.width,h[1]=e.source.height,h[2]=1/h[0],h[3]=1/h[1],d[0]=e.source.pixelWidth,d[1]=e.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],f[0]=.5*d[2],f[1]=.5*d[3],f[2]=e.frame.width*h[2]-.5*d[2],f[3]=e.frame.height*h[3]-.5*d[3];const g=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*o,p[1]=i*o,p[2]=g.source.width*o,p[3]=g.source.height*o,t instanceof D&&(t.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!c),t instanceof D?(m[0]=t.frame.width,m[1]=t.frame.height):(m[0]=_.width,m[1]=_.height),m[2]=_.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(e){let t=this._filterStackIndex-1;for(;t>0&&this._filterStack[t].skip;)--t;return t>0&&this._filterStack[t].inputTexture?this._filterStack[t].inputTexture.source._resolution:e}_findPreviousFilterOffset(){let e=0,t=0,n=this._filterStackIndex;for(;n>0;){n--;const s=this._filterStack[n];if(!s.skip){e=s.bounds.minX,t=s.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?gh(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const s=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;s&&t.applyMatrix(s)}}_applyFiltersToTexture(e,t){const n=e.inputTexture,s=e.bounds,i=e.filters,o=e.firstEnabledIndex,a=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),o===a)i[o].apply(this,n,e.outputRenderSurface,t);else{let c=e.inputTexture;const l=Re.getOptimalTexture(s.width,s.height,c.source._resolution,!1);let u=l;for(let h=o;h<a;h++){const d=i[h];if(!d.enabled)continue;d.apply(this,c,u,!0);const f=c;c=u,u=f}i[a].apply(this,c,e.outputRenderSurface,t),Re.returnTexture(l)}}_calculateFilterBounds(e,t,n,s,i){var _;const o=this.renderer,a=e.bounds,c=e.filters;let l=1/0,u=0,h=!0,d=!1,f=!1,p=!0,m=-1,g=-1;for(let y=0;y<c.length;y++){const b=c[y];if(!b.enabled)continue;if(m===-1&&(m=y),g=y,l=Math.min(l,b.resolution==="inherit"?s:b.resolution),u+=b.padding,b.antialias==="off"?h=!1:b.antialias==="inherit"&&h&&(h=n),b.clipToViewport||(p=!1),!!!(b.compatibleRenderers&o.type)){f=!1;break}if(b.blendRequired&&!(((_=o.backBuffer)==null?void 0:_.useBackBuffer)??!0)){W("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,d||(d=b.blendRequired)}if(!f){e.skip=!0;return}if(p&&a.fitBounds(0,t.width/s,0,t.height/s),a.scale(l).ceil().scale(1/l).pad((u|0)*i),!a.isPositive){e.skip=!0;return}e.antialias=h,e.resolution=l,e.blendRequired=d,e.firstEnabledIndex=m,e.lastEnabledIndex=g}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let e,t=this._filterStackIndex-1;for(;t>0&&(t--,e=this._filterStack[t],!!e.skip););return e}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new Sw),this._filterStackIndex++,e}}vh.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"filter"};var ww=`in vec2 vMaskCoord;
691
+ in vec2 vTextureCoord;
692
+
693
+ uniform sampler2D uTexture;
694
+ uniform sampler2D uMaskTexture;
695
+
696
+ uniform float uAlpha;
697
+ uniform vec4 uMaskClamp;
698
+ uniform float uInverse;
699
+ uniform float uChannel;
700
+
701
+ out vec4 finalColor;
702
+
703
+ void main(void)
704
+ {
705
+ float clip = step(3.5,
706
+ step(uMaskClamp.x, vMaskCoord.x) +
707
+ step(uMaskClamp.y, vMaskCoord.y) +
708
+ step(vMaskCoord.x, uMaskClamp.z) +
709
+ step(vMaskCoord.y, uMaskClamp.w));
710
+
711
+ // TODO look into why this is needed
712
+ float npmAlpha = uAlpha;
713
+ vec4 original = texture(uTexture, vTextureCoord);
714
+ vec4 masky = texture(uMaskTexture, vMaskCoord);
715
+
716
+ float a;
717
+ if (uChannel == 1.0) {
718
+ a = masky.a * npmAlpha * clip;
719
+ } else {
720
+ float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
721
+ a = alphaMul * masky.r * npmAlpha * clip;
722
+ }
723
+
724
+ if (uInverse == 1.0) {
725
+ a = 1.0 - a;
726
+ }
727
+
728
+ finalColor = original * a;
729
+ }
730
+ `,Pw=`in vec2 aPosition;
731
+
732
+ out vec2 vTextureCoord;
733
+ out vec2 vMaskCoord;
734
+
735
+
736
+ uniform vec4 uInputSize;
737
+ uniform vec4 uOutputFrame;
738
+ uniform vec4 uOutputTexture;
739
+ uniform mat3 uFilterMatrix;
740
+
741
+ vec4 filterVertexPosition( vec2 aPosition )
742
+ {
743
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
744
+
745
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
746
+ position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
747
+
748
+ return vec4(position, 0.0, 1.0);
749
+ }
750
+
751
+ vec2 filterTextureCoord( vec2 aPosition )
752
+ {
753
+ return aPosition * (uOutputFrame.zw * uInputSize.zw);
754
+ }
755
+
756
+ vec2 getFilterCoord( vec2 aPosition )
757
+ {
758
+ return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
759
+ }
760
+
761
+ void main(void)
762
+ {
763
+ gl_Position = filterVertexPosition(aPosition);
764
+ vTextureCoord = filterTextureCoord(aPosition);
765
+ vMaskCoord = getFilterCoord(aPosition);
766
+ }
767
+ `,Th=`struct GlobalFilterUniforms {
768
+ uInputSize:vec4<f32>,
769
+ uInputPixel:vec4<f32>,
770
+ uInputClamp:vec4<f32>,
771
+ uOutputFrame:vec4<f32>,
772
+ uGlobalFrame:vec4<f32>,
773
+ uOutputTexture:vec4<f32>,
774
+ };
775
+
776
+ struct MaskUniforms {
777
+ uFilterMatrix:mat3x3<f32>,
778
+ uMaskClamp:vec4<f32>,
779
+ uAlpha:f32,
780
+ uInverse:f32,
781
+ uChannel:f32,
782
+ };
783
+
784
+ @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
785
+ @group(0) @binding(1) var uTexture: texture_2d<f32>;
786
+ @group(0) @binding(2) var uSampler : sampler;
787
+
788
+ @group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
789
+ @group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
790
+
791
+ struct VSOutput {
792
+ @builtin(position) position: vec4<f32>,
793
+ @location(0) uv : vec2<f32>,
794
+ @location(1) filterUv : vec2<f32>,
795
+ };
796
+
797
+ fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
798
+ {
799
+ var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
800
+
801
+ position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
802
+ position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
803
+
804
+ return vec4(position, 0.0, 1.0);
805
+ }
806
+
807
+ fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
808
+ {
809
+ return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
810
+ }
811
+
812
+ fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
813
+ {
814
+ return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
815
+ }
816
+
817
+ fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
818
+ {
819
+ return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
820
+ }
821
+
822
+ fn getSize() -> vec2<f32>
823
+ {
824
+ return gfu.uGlobalFrame.zw;
825
+ }
826
+
827
+ @vertex
828
+ fn mainVertex(
829
+ @location(0) aPosition : vec2<f32>,
830
+ ) -> VSOutput {
831
+ return VSOutput(
832
+ filterVertexPosition(aPosition),
833
+ filterTextureCoord(aPosition),
834
+ getFilterCoord(aPosition)
835
+ );
836
+ }
837
+
838
+ @fragment
839
+ fn mainFragment(
840
+ @location(0) uv: vec2<f32>,
841
+ @location(1) filterUv: vec2<f32>,
842
+ @builtin(position) position: vec4<f32>
843
+ ) -> @location(0) vec4<f32> {
844
+
845
+ var maskClamp = filterUniforms.uMaskClamp;
846
+ var uAlpha = filterUniforms.uAlpha;
847
+
848
+ var clip = step(3.5,
849
+ step(maskClamp.x, filterUv.x) +
850
+ step(maskClamp.y, filterUv.y) +
851
+ step(filterUv.x, maskClamp.z) +
852
+ step(filterUv.y, maskClamp.w));
853
+
854
+ var mask = textureSample(uMaskTexture, uSampler, filterUv);
855
+ var source = textureSample(uTexture, uSampler, uv);
856
+
857
+ var a: f32;
858
+ if (filterUniforms.uChannel == 1.0) {
859
+ a = mask.a * uAlpha * clip;
860
+ } else {
861
+ var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
862
+ a = alphaMul * mask.r * uAlpha * clip;
863
+ }
864
+
865
+ if (filterUniforms.uInverse == 1.0) {
866
+ a = 1.0 - a;
867
+ }
868
+
869
+ return source * a;
870
+ }
871
+ `;class Ew extends vi{constructor(e){const{sprite:t,...n}=e,s=new ul(t.texture),i=new je({uFilterMatrix:{value:new B,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"},uChannel:{value:e.channel==="alpha"?1:0,type:"f32"}}),o=Ut.from({vertex:{source:Th,entryPoint:"mainVertex"},fragment:{source:Th,entryPoint:"mainFragment"}}),a=Ot.from({vertex:Pw,fragment:ww,name:"mask-filter"});super({...n,gpuProgram:o,glProgram:a,clipToViewport:!1,resources:{filterUniforms:i,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=s}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(e){this.resources.filterUniforms.uniforms.uChannel=e==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(e,t,n,s){this._textureMatrix.texture=this.sprite.texture,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,e.applyFilter(this,t,n,s)}}class Cw{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Mw{constructor(){this.instructions=new Ks}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Yi=class Oo{constructor(e){this._renderer=e,this._managedContexts=new xt({renderer:e,type:"resource",name:"graphicsContext"})}init(e){Oo.defaultOptions.bezierSmoothness=(e==null?void 0:e.bezierSmoothness)??Oo.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=e._gpuData,n=!!t[this._renderer.uid],s=t[this._renderer.uid]||this._initContext(e);return(e.dirty||!n)&&(n&&s.reset(),s.isBatchable=!1,e.dirty=!1),s}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=new Mw,n=this.getGpuContext(e);return n.graphicsData=t,t.init(),t}_initContext(e){const t=new Cw;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Yi.extension={type:[x.CanvasSystem],name:"graphicsContext"},Yi.defaultOptions={bezierSmoothness:.5};let Aw=Yi;class Sh{constructor(e,t){this.state=ct.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new xt({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,t){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){e.isRenderable&&this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Sh.extension={type:[x.CanvasPipes],name:"graphics"};function Zi(r,e,t){const n=(r>>24&255)/255;e[t++]=(r&255)/255*n,e[t++]=(r>>8&255)/255*n,e[t++]=(r>>16&255)/255*n,e[t++]=n}class kw{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{Se.return(e)}),this.batches.length=0}}class wh{constructor(e,t){this.state=ct.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new xt({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){const t=e.context,n=!!e._gpuData,i=this.renderer.graphicsContext.updateGpuContext(t);return!!(i.isBatchable||n!==i.isBatchable)}addRenderable(e,t){const s=this.renderer.graphicsContext.updateGpuContext(e.context);e.didViewUpdate&&this._rebuild(e),s.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){const n=this._getGpuDataForRenderable(e).batches;for(let s=0;s<n.length;s++){const i=n[s];i._batcher.updateElement(i)}}execute(e){if(!e.isRenderable)return;const t=this.renderer,n=e.context;if(!t.graphicsContext.getGpuContext(n).batches.length)return;const i=n.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;const o=i.resources.localUniforms.uniforms;o.uTransformMatrix=e.groupTransform,o.uRound=t._roundPixels|e._roundPixels,Zi(e.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){const t=this._getGpuDataForRenderable(e),s=this.renderer.graphicsContext.updateGpuContext(e.context);t.destroy(),s.isBatchable&&this._updateBatchesForRenderable(e,t)}_addToBatcher(e,t){const n=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(e).batches;for(let i=0;i<s.length;i++){const o=s[i];n.addToBatch(o,t)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){const t=new kw;return e._gpuData[this.renderer.uid]=t,this._managedGraphics.add(e),t}_updateBatchesForRenderable(e,t){const n=e.context,i=this.renderer.graphicsContext.getGpuContext(n),o=this.renderer._roundPixels|e._roundPixels;t.batches=i.batches.map(a=>{const c=Se.get(Di);return a.copyTo(c),c.renderable=e,c.roundPixels=o,c})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}wh.extension={type:[x.WebGLPipes,x.WebGPUPipes],name:"graphics"},H.add(Sh),H.add(wh),H.add(Aw),H.add(Ni);class Zn extends ii{constructor(e){e instanceof Yr&&(e={context:e});const{context:t,roundPixels:n,...s}=e||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",t?this.context=t:(this.context=this._ownedContext=new Yr,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=n??!1}set context(e){e!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=e,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(e){return this._context.containsPoint(e)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||(e==null?void 0:e.context)===!0)&&this._context.destroy(e),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){return e?new Zn(this._context.clone()):(this._ownedContext=null,new Zn(this._context))}lineStyle(e,t,n){N(de,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const s={};return e&&(s.width=e),t&&(s.color=t),n&&(s.alpha=n),this.context.strokeStyle=s,this}beginFill(e,t){N(de,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const n={};return e!==void 0&&(n.color=e),t!==void 0&&(n.alpha=t),this.context.fillStyle=n,this}endFill(){N(de,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const e=this.context.strokeStyle;return(e.width!==Yr.defaultStrokeStyle.width||e.color!==Yr.defaultStrokeStyle.color||e.alpha!==Yr.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return N(de,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return N(de,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return N(de,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return N(de,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return N(de,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return N(de,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}const Ph=class df extends tr{constructor(...e){let t=e[0]??{};t instanceof Float32Array&&(N(de,"use new MeshGeometry({ positions, uvs, indices }) instead"),t={positions:t,uvs:e[1],indices:e[2]}),t={...df.defaultOptions,...t};const n=t.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=t.uvs;s||(t.positions?s=new Float32Array(n.length):s=new Float32Array([0,0,1,0,1,1,0,1]));const i=t.indices||new Uint32Array([0,1,2,0,2,3]),o=t.shrinkBuffersToFit,a=new Ue({data:n,label:"attribute-mesh-positions",shrinkToFit:o,usage:Q.VERTEX|Q.COPY_DST}),c=new Ue({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:Q.VERTEX|Q.COPY_DST}),l=new Ue({data:i,label:"index-mesh-buffer",shrinkToFit:o,usage:Q.INDEX|Q.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:8,offset:0},aUV:{buffer:c,format:"float32x2",stride:8,offset:0}},indexBuffer:l,topology:t.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};Ph.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Eh=Ph;class Rw{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(e){this._topology=e}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(e){this.texture!==e&&(this.texture=e,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),n=t.data;let s=n;const i=this.texture.textureMatrix;return i.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==i._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length<n.length)&&(s=this._transformedUvs=new Float32Array(n.length)),this._textureMatrixUpdateId=i._updateID,this._uvUpdateId=t._updateID,i.multiplyUvs(n,s))),s}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class Ch{destroy(){}}class Mh{constructor(e,t){this.localUniforms=new je({uTransformMatrix:{value:new B,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new yt({0:this.localUniforms}),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=this._getMeshData(e),n=t.batched,s=e.batched;if(t.batched=s,n!==s)return!0;if(s){const i=e._geometry;if(i.indices.length!==t.indexSize||i.positions.length!==t.vertexSize)return t.indexSize=i.indices.length,t.vertexSize=i.positions.length,!0;const o=this._getBatchableMesh(e);return o.texture.uid!==e._texture.uid&&(o._textureMatrixUpdateId=-1),!o._batcher.checkAndUpdateTexture(o,e._texture)}return!1}addRenderable(e,t){var i,o;const n=this.renderer.renderPipes.batch,s=this._getMeshData(e);if(e.didViewUpdate&&(s.indexSize=(i=e._geometry.indices)==null?void 0:i.length,s.vertexSize=(o=e._geometry.positions)==null?void 0:o.length),s.batched){const a=this._getBatchableMesh(e);a.setTexture(e._texture),a.geometry=e._geometry,n.addToBatch(a,t)}else n.break(t),t.add(e)}updateRenderable(e){if(e.batched){const t=this._getBatchableMesh(e);t.setTexture(e._texture),t.geometry=e._geometry,t._batcher.updateElement(t)}}execute(e){if(!e.isRenderable)return;e.state.blendMode=Mi(e.groupBlendMode,e.texture._source);const t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),Zi(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){var t,n;return(t=e._gpuData)[n=this.renderer.uid]||(t[n]=new Ch),e._gpuData[this.renderer.uid].meshData||this._initMeshData(e)}_initMeshData(e){return e._gpuData[this.renderer.uid].meshData={batched:e.batched,indexSize:0,vertexSize:0},e._gpuData[this.renderer.uid].meshData}_getBatchableMesh(e){var t,n;return(t=e._gpuData)[n=this.renderer.uid]||(t[n]=new Ch),e._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(e)}_initBatchableMesh(e){const t=new Rw;return t.renderable=e,t.setTexture(e._texture),t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,e._gpuData[this.renderer.uid].batchableMesh=t,t}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Mh.extension={type:[x.WebGLPipes,x.WebGPUPipes],name:"mesh"},H.add(Mh);class Iw extends ii{constructor(...e){let t=e[0];t instanceof tr&&(N(de,"Mesh: use new Mesh({ geometry, shader }) instead"),t={geometry:t,shader:e[1]},e[3]&&(N(de,"Mesh: drawMode argument has been removed, use geometry.topology instead"),t.geometry.topology=e[3]));const{geometry:n,shader:s,texture:i,roundPixels:o,state:a,...c}=t;super({label:"Mesh",...c}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=i??(s==null?void 0:s.texture)??D.WHITE,this.state=a??ct.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=o??!1}get material(){return N(de,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(e){this._shader!==e&&(this._shader=e,this.onViewUpdate())}get shader(){return this._shader}set geometry(e){var t;this._geometry!==e&&((t=this._geometry)==null||t.off("update",this.onViewUpdate,this),e.on("update",this.onViewUpdate,this),this._geometry=e,this.onViewUpdate())}get geometry(){return this._geometry}set texture(e){e||(e=D.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this.shader&&(this.shader.texture=e),this._texture=e,this.onViewUpdate())}get texture(){return this._texture}get batched(){return this._shader||(this.state.data&12)!==0?!1:this._geometry instanceof Eh?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(e){const{x:t,y:n}=e;if(!this.bounds.containsPoint(t,n))return!1;const s=this.geometry.getBuffer("aPosition").data,i=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const o=this.geometry.getIndex().data,a=o.length;for(let c=0;c+2<a;c+=i){const l=o[c]*2,u=o[c+1]*2,h=o[c+2]*2;if(ph(t,n,s[l],s[l+1],s[u],s[u+1],s[h],s[h+1]))return!0}}else{const o=s.length/2;for(let a=0;a+2<o;a+=i){const c=a*2,l=(a+1)*2,u=(a+2)*2;if(ph(t,n,s[c],s[c+1],s[l],s[l+1],s[u],s[u+1]))return!0}}return!1}destroy(e){var n;if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const s=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(s)}(n=this._geometry)==null||n.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null}}const Kn={name:"local-uniform-bit",vertex:{header:`
872
+
873
+ struct LocalUniforms {
874
+ uTransformMatrix:mat3x3<f32>,
875
+ uColor:vec4<f32>,
876
+ uRound:f32,
877
+ }
878
+
879
+ @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
880
+ `,main:`
881
+ vColor *= localUniforms.uColor;
882
+ modelMatrix *= localUniforms.uTransformMatrix;
883
+ `,end:`
884
+ if(localUniforms.uRound == 1)
885
+ {
886
+ vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
887
+ }
888
+ `}},Bw={...Kn,vertex:{...Kn.vertex,header:Kn.vertex.header.replace("group(1)","group(2)")}},Ah={name:"local-uniform-bit",vertex:{header:`
889
+
890
+ uniform mat3 uTransformMatrix;
891
+ uniform vec4 uColor;
892
+ uniform float uRound;
893
+ `,main:`
894
+ vColor *= uColor;
895
+ modelMatrix = uTransformMatrix;
896
+ `,end:`
897
+ if(uRound == 1.)
898
+ {
899
+ gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
900
+ }
901
+ `}};class kh{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}function Fw(){const{userAgent:r}=te.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}const Ki=class zt{static _getPatternRepeat(e,t){const n=e&&e!=="clamp-to-edge",s=t&&t!=="clamp-to-edge";return n&&s?"repeat":n?"repeat-x":s?"repeat-y":"no-repeat"}start(e,t,n){}execute(e,t){var a,c,l,u;const n=t.elements;if(!n||!n.length)return;const s=e.renderer,i=s.canvasContext,o=i.activeContext;for(let h=0;h<n.length;h++){const d=n[h];if(!d.packAsQuad)continue;const f=d,p=f.texture,m=p?Y.getCanvasSource(p):null;if(!m)continue;const g=p.source.style,_=i.smoothProperty,y=g.scaleMode!=="nearest";o[_]!==y&&(o[_]=y),i.setBlendMode(t.blendMode);const b=((a=s.globalUniforms.globalUniformData)==null?void 0:a.worldColor)??4294967295,v=f.color,C=(b>>>24&255)/255,S=(v>>>24&255)/255,E=((c=s.filter)==null?void 0:c.alphaMultiplier)??1,U=C*S*E;if(U<=0)continue;o.globalAlpha=U;const z=b&16777215,M=v&16777215,A=Jt(qt(M,z)),j=p.frame,q=g.addressModeU??g.addressMode,se=g.addressModeV??g.addressMode,Ye=zt._getPatternRepeat(q,se),k=p.source._resolution??p.source.resolution??1,G=(u=(l=f.renderable)==null?void 0:l.renderGroup)==null?void 0:u.isCachedAsTexture,re=j.x*k,O=j.y*k,ie=j.width*k,Ge=j.height*k,Ee=f.bounds,we=s.renderTarget.renderTarget.isRoot,Ze=Ee.minX,Oe=Ee.minY,Me=Ee.maxX-Ee.minX,ze=Ee.maxY-Ee.minY,nt=p.rotate,K=p.uvs,Ne=Math.min(K.x0,K.x1,K.x2,K.x3,K.y0,K.y1,K.y2,K.y3),Ke=Math.max(K.x0,K.x1,K.x2,K.x3,K.y0,K.y1,K.y2,K.y3),xe=Ye!=="no-repeat"&&(Ne<0||Ke>1),st=nt&&!(!xe&&(A!==16777215||nt));st?(zt._tempPatternMatrix.copyFrom(f.transform),X.matrixAppendRotationInv(zt._tempPatternMatrix,nt,Ze,Oe,Me,ze),i.setContextTransform(zt._tempPatternMatrix,f.roundPixels===1,void 0,G&&we)):i.setContextTransform(f.transform,f.roundPixels===1,void 0,G&&we);const qe=st?0:Ze,gr=st?0:Oe,_r=Me,qr=ze;if(xe){let rs=m;const yr=A!==16777215&&!nt,br=j.width<=p.source.width&&j.height<=p.source.height;yr&&br&&(rs=Y.getTintedCanvas({texture:p},A));const Co=o.createPattern(rs,Ye);if(!Co)continue;const Yd=_r,Zd=qr;if(Yd===0||Zd===0)continue;const Kd=1/Yd,qd=1/Zd,Jd=(K.x1-K.x0)*Kd,Qd=(K.y1-K.y0)*Kd,ef=(K.x3-K.x0)*qd,tf=(K.y3-K.y0)*qd,jP=K.x0-Jd*qe-ef*gr,WP=K.y0-Qd*qe-tf*gr,Mo=p.source.pixelWidth,Ao=p.source.pixelHeight;zt._tempPatternMatrix.set(Jd*Mo,Qd*Ao,ef*Mo,tf*Ao,jP*Mo,WP*Ao),Y.applyPatternTransform(Co,zt._tempPatternMatrix),o.fillStyle=Co,o.fillRect(qe,gr,_r,qr)}else{const yr=A!==16777215||nt?Y.getTintedCanvas({texture:p},A):m,br=yr!==m;o.drawImage(yr,br?0:re,br?0:O,br?yr.width:ie,br?yr.height:Ge,qe,gr,_r,qr)}}}};Ki._tempPatternMatrix=new B,Ki.extension={type:[x.CanvasPipesAdaptor],name:"batch"};let Gw=Ki;class Rh{constructor(){this._tempState=ct.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,n){const s=e.renderer,i=this._didUploadHash[n.uid];s.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(t,n.glProgram)}execute(e,t){const n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);const s=t.textures.textures;for(let i=0;i<t.textures.count;i++)n.texture.bind(s[i],i);n.geometry.draw(t.topology,t.size,t.start)}}Rh.extension={type:[x.WebGLPipesAdaptor],name:"batch"};const qn=ct.for2d();class Ih{start(e,t,n){const s=e.renderer,i=s.encoder,o=n.gpuProgram;this._shader=n,this._geometry=t,i.setGeometry(t,o),qn.blendMode="normal",s.pipeline.getPipeline(t,o,qn);const a=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,a,o)}execute(e,t){const n=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const c=t.textures;t.bindGroup=Ei(c.textures,c.count,s.limits.maxBatchableTextures)}qn.blendMode=t.blendMode;const o=s.bindGroup.getBindGroup(t.bindGroup,n,1),a=s.pipeline.getPipeline(this._geometry,n,qn,t.topology);t.bindGroup._touch(s.gc.now,s.tick),i.setPipeline(a),i.renderPassEncoder.setBindGroup(1,o),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}Ih.extension={type:[x.WebGPUPipesAdaptor],name:"batch"};const qi=class ff{constructor(e,t){var n,s;this.state=ct.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,(s=(n=this._adaptor).init)==null||s.call(n,this)}static getBatcher(e){return new this._availableBatchers[e]}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new Oi({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const n in this._activeBatches)this._activeBatches[n].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let n=this._activeBatches[e.batcherName];n||(n=this._activeBatches[e.batcherName]=ff.getBatcher(e.batcherName),n.begin()),this._activeBatch=n}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const n in t){const s=t[n],i=s.geometry;i.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),i.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!1)}}upload(e){const t=this._batchersByInstructionSet[e.uid];for(const n in t){const s=t[n],i=s.geometry;s.dirty&&(s.dirty=!1,i.buffers[0].update(s.attributeSize*4))}}execute(e){if(e.action==="startBatch"){const t=e.batcher,n=t.geometry,s=t.shader;this._adaptor.start(this,n,s)}this._adaptor.execute(this,e)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};qi.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"batch"},qi._availableBatchers=Object.create(null);let Ji=qi;H.handleByMap(x.Batcher,Ji._availableBatchers),H.add(Oi);const Ow={name:"texture-bit",vertex:{header:`
902
+
903
+ struct TextureUniforms {
904
+ uTextureMatrix:mat3x3<f32>,
905
+ }
906
+
907
+ @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
908
+ `,main:`
909
+ uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
910
+ `},fragment:{header:`
911
+ @group(2) @binding(0) var uTexture: texture_2d<f32>;
912
+ @group(2) @binding(1) var uSampler: sampler;
913
+
914
+
915
+ `,main:`
916
+ outColor = textureSample(uTexture, uSampler, vUV);
917
+ `}},Dw={name:"texture-bit",vertex:{header:`
918
+ uniform mat3 uTextureMatrix;
919
+ `,main:`
920
+ uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
921
+ `},fragment:{header:`
922
+ uniform sampler2D uTexture;
923
+
924
+
925
+ `,main:`
926
+ outColor = texture(uTexture, vUV);
927
+ `}},Uw=new Pe;class Lw extends Mn{constructor(){super(),this.filters=[new Ew({sprite:new nr(D.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}}class Qi{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,n){const s=this._renderer;if(s.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??"red",e.renderMaskToTexture){const i=e.mask;i.includeInBuild=!0,i.collectRenderables(n,s,null),i.includeInBuild=!1}s.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,n=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){const s=Se.get(Lw);if(s.inverse=e.inverse,s.channel=e.mask.channel,n){e.mask.mask.measurable=!0;const i=Xs(e.mask.mask,!0,Uw);e.mask.mask.measurable=!1,i.ceil();const o=t.renderTarget.renderTarget.colorTexture.source,a=Re.getOptimalTexture(i.width,i.height,o._resolution,o.antialias);t.renderTarget.push(a,!0),t.globalUniforms.push({offset:i,worldColor:4294967295});const c=s.sprite;c.texture=a,c.worldTransform.tx=i.minX,c.worldTransform.ty=i.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer,filterTexture:a})}else s.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){const s=this._activeMaskStage[this._activeMaskStage.length-1];n&&(t.type===at.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();const s=this._activeMaskStage.pop();n&&Re.returnTexture(s.filterTexture),Se.return(s.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Qi.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"alphaMask"};class Bh{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,n){this._renderer.renderPipes.batch.break(n);const s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&e.mask;const i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);const s=this._colorStack;this._colorStackIndex--;const i=s[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}Bh.extension={type:[x.CanvasPipes],name:"colorMask"};class Fh{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,n){this._renderer.renderPipes.batch.break(n);const i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,n.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);const i=this._colorStack;this._colorStackIndex--;const o=i[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,n.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}Fh.extension={type:[x.WebGLPipes,x.WebGPUPipes],name:"colorMask"};function zw(r,e,t,n,s,i){i=Math.max(0,Math.min(i,Math.min(n,s)/2)),r.moveTo(e+i,t),r.lineTo(e+n-i,t),r.quadraticCurveTo(e+n,t,e+n,t+i),r.lineTo(e+n,t+s-i),r.quadraticCurveTo(e+n,t+s,e+n-i,t+s),r.lineTo(e+i,t+s),r.quadraticCurveTo(e,t+s,e,t+s-i),r.lineTo(e,t+i),r.quadraticCurveTo(e,t,e+i,t)}function Gh(r,e){switch(e.type){case"rectangle":{const t=e;r.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;zw(r,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;r.moveTo(t.x+t.radius,t.y),r.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;r.ellipse?(r.moveTo(t.x+t.halfWidth,t.y),r.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(r.save(),r.translate(t.x,t.y),r.scale(t.halfWidth,t.halfHeight),r.moveTo(1,0),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const t=e;r.moveTo(t.x,t.y),r.lineTo(t.x2,t.y2),r.lineTo(t.x3,t.y3),r.closePath();break}case"polygon":default:{const t=e,n=t.points;if(!(n!=null&&n.length))break;r.moveTo(n[0],n[1]);for(let s=2;s<n.length;s+=2)r.lineTo(n[s],n[s+1]);t.closePath&&r.closePath();break}}}function Nw(r,e,t){const n=[],s=[],i=[],o=hr[e.type];if(!(o!=null&&o.build(e,n)))return!1;const a=e.closePath??!0;Ui(n,t,!1,a,s,i);for(let c=0;c<i.length;c+=3){const l=i[c]*2,u=i[c+1]*2,h=i[c+2]*2;r.moveTo(s[l],s[l+1]),r.lineTo(s[u],s[u+1]),r.lineTo(s[h],s[h+1]),r.closePath()}return!0}function $w(r,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const n=e[t];if(!(n!=null&&n.shape))continue;const s=n.transform,i=s&&!s.isIdentity();i&&(r.save(),r.transform(s.a,s.b,s.c,s.d,s.tx,s.ty)),Gh(r,n.shape),i&&r.restore()}return!0}class Oh{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var u,h,d;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,n=t.canvasContext,s=n==null?void 0:n.activeContext;if(!s)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&s.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const i=e.mask.mask;if(!(i instanceof Zn)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=i,a=(u=o.context)==null?void 0:u.instructions;if(!(a!=null&&a.length)){this._canvasMaskStack.push(!1);return}s.save(),n.setContextTransform(o.groupTransform,(t._roundPixels|o._roundPixels)===1),s.beginPath();let c=!1,l=!1;for(let f=0;f<a.length;f++){const p=a[f],m=p.action;if(m!=="fill"&&m!=="stroke")continue;const g=p.data,_=(h=g==null?void 0:g.path)==null?void 0:h.shapePath;if(!((d=_==null?void 0:_.shapePrimitives)!=null&&d.length))continue;const y=m==="stroke",b=_.shapePrimitives;for(let v=0;v<b.length;v++){const C=b[v];if(!(C!=null&&C.shape))continue;const S=C.transform,E=S&&!S.isIdentity();E&&(s.save(),s.transform(S.a,S.b,S.c,S.d,S.tx,S.ty)),y&&g.style?c=Nw(s,C.shape,g.style)||c:(Gh(s,C.shape),l=$w(s,C.holes)||l,c=!0),E&&s.restore()}}if(!c){s.restore(),this._canvasMaskStack.push(!1);return}l?s.clip("evenodd"):s.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),W(t))}}Oh.extension={type:[x.CanvasPipes],name:"stencilMask"};class Dh{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,n){var s;const i=e,o=this._renderer;o.renderPipes.batch.break(n),o.renderPipes.blendMode.setBlendMode(i.mask,"none",n),n.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const a=i.mask;a.includeInBuild=!0,this._maskHash.has(i)||this._maskHash.set(i,{instructionsStart:0,instructionsLength:0});const c=this._maskHash.get(i);c.instructionsStart=n.instructionSize,a.collectRenderables(n,o,null),a.includeInBuild=!1,o.renderPipes.batch.break(n),n.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const l=n.instructionSize-c.instructionsStart-1;c.instructionsLength=l;const u=o.renderTarget.renderTarget.uid;(s=this._maskStackHash)[u]??(s[u]=0)}pop(e,t,n){const s=e,i=this._renderer;i.renderPipes.batch.break(n),i.renderPipes.blendMode.setBlendMode(s.mask,"none",n),n.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(e);for(let a=0;a<o.instructionsLength;a++)n.instructions[n.instructionSize++]=n.instructions[o.instructionsStart++];n.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){var t;const n=this._renderer,s=n,i=n.renderTarget.renderTarget.uid;let o=(t=this._maskStackHash)[i]??(t[i]=0);e.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(be.RENDERING_MASK_ADD,o),o++,s.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?s.stencil.setStencilMode(be.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(be.MASK_ACTIVE,o),s.colorMask.setMask(15)):e.action==="popMaskBegin"?(s.colorMask.setMask(0),o!==0?s.stencil.setStencilMode(be.RENDERING_MASK_REMOVE,o):(s.renderTarget.clear(null,Le.STENCIL),s.stencil.setStencilMode(be.DISABLED,o)),o--):e.action==="popMaskEnd"&&(e.inverse?s.stencil.setStencilMode(be.INVERSE_MASK_ACTIVE,o):s.stencil.setStencilMode(be.MASK_ACTIVE,o),s.colorMask.setMask(15)),this._maskStackHash[i]=o}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}Dh.extension={type:[x.WebGLPipes,x.WebGPUPipes],name:"stencilMask"};const ne="source-over";function Vw(){const r=fh(),e=Object.create(null);return e.inherit=ne,e.none=ne,e.normal="source-over",e.add="lighter",e.multiply=r?"multiply":ne,e.screen=r?"screen":ne,e.overlay=r?"overlay":ne,e.darken=r?"darken":ne,e.lighten=r?"lighten":ne,e["color-dodge"]=r?"color-dodge":ne,e["color-burn"]=r?"color-burn":ne,e["hard-light"]=r?"hard-light":ne,e["soft-light"]=r?"soft-light":ne,e.difference=r?"difference":ne,e.exclusion=r?"exclusion":ne,e.saturation=r?"saturation":ne,e.color=r?"color":ne,e.luminosity=r?"luminosity":ne,e["linear-burn"]=r?"color-burn":ne,e["linear-dodge"]=r?"color-dodge":ne,e["linear-light"]=r?"hard-light":ne,e["pin-light"]=r?"hard-light":ne,e["vivid-light"]=r?"hard-light":ne,e["hard-mix"]=ne,e.negation=r?"difference":ne,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=ne,e.divide=ne,e.min=ne,e.max=ne,e}const Hw=new B;class Uh{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=Vw(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,n,s){var l;const i=s?B.IDENTITY:((l=this._renderer.globalUniforms.globalUniformData)==null?void 0:l.worldTransformMatrix)||B.IDENTITY;let o=Hw;o.copyFrom(i),o.append(e);const a=this._projTransform,c=this.activeResolution;if(n=n||c,a){const u=B.shared;u.copyFrom(o),u.prepend(a),o=u}t?this.activeContext.setTransform(o.a*n,o.b*n,o.c*n,o.d*n,o.tx*c|0,o.ty*c|0):this.activeContext.setTransform(o.a*n,o.b*n,o.c*n,o.d*n,o.tx*c,o.ty*c)}clear(e,t){const n=this.activeContext,s=this._renderer;if(n.clearRect(0,0,s.width,s.height),e){const i=ye.shared.setValue(e);n.globalAlpha=t??i.alpha,n.fillStyle=i.toHex(),n.fillRect(0,0,s.width,s.height),n.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}Uh.extension={type:[x.CanvasSystem],name:"canvasContext"};class Lh{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Lh.extension={type:[x.CanvasSystem],name:"limits"};class eo{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}eo.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"customRender"};function to(r,e){const t=r.instructionSet,n=t.instructions;for(let s=0;s<t.instructionSize;s++){const i=n[s];e[i.renderPipeId].execute(i)}}class ro{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(Se.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const n=e._batchableRenderGroup??(e._batchableRenderGroup=Se.get(kh));n.renderable=e.root,n.transform=e.root.relativeGroupTransform,n.texture=e.texture,n.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(n,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=new B().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push(e.texture,!0,null,e.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),to(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),to(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}ro.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"renderGroup"};const jw="#808080",Jn=new B,Ww=new B,Xw=new B,no=new B;function Yw(r,e,t){r.beginPath();for(let n=0;n<t.length;n+=3){const s=t[n]*2,i=t[n+1]*2,o=t[n+2]*2;r.moveTo(e[s],e[s+1]),r.lineTo(e[i],e[i+1]),r.lineTo(e[o],e[o+1]),r.closePath()}r.fill()}function Zw(r){return`#${(r&16777215).toString(16).padStart(6,"0")}`}function Kw(r,e,t,n,s,i){i=Math.max(0,Math.min(i,Math.min(n,s)/2)),r.moveTo(e+i,t),r.lineTo(e+n-i,t),r.quadraticCurveTo(e+n,t,e+n,t+i),r.lineTo(e+n,t+s-i),r.quadraticCurveTo(e+n,t+s,e+n-i,t+s),r.lineTo(e+i,t+s),r.quadraticCurveTo(e,t+s,e,t+s-i),r.lineTo(e,t+i),r.quadraticCurveTo(e,t,e+i,t)}function Qn(r,e){switch(e.type){case"rectangle":{const t=e;r.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Kw(r,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;r.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;r.ellipse?r.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(r.save(),r.translate(t.x,t.y),r.scale(t.halfWidth,t.halfHeight),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const t=e;r.moveTo(t.x,t.y),r.lineTo(t.x2,t.y2),r.lineTo(t.x3,t.y3),r.closePath();break}case"polygon":default:{const t=e,n=t.points;if(!(n!=null&&n.length))break;r.moveTo(n[0],n[1]);for(let s=2;s<n.length;s+=2)r.lineTo(n[s],n[s+1]);t.closePath&&r.closePath();break}}}function qw(r,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const n=e[t];if(!(n!=null&&n.shape))continue;const s=n.transform,i=s&&!s.isIdentity();i&&(r.save(),r.transform(s.a,s.b,s.c,s.d,s.tx,s.ty)),Qn(r,n.shape),i&&r.restore()}return!0}function Jw(r,e,t,n){const s=r.fill;if(s instanceof ur){s.buildGradient();const o=s.texture;if(o){const a=Y.getTintedPattern(o,e),c=t?no.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):no.copyFrom(s.transform);return n&&!r.textureSpace&&c.append(n),Y.applyPatternTransform(a,c),a}}if(s instanceof nh){const o=Y.getTintedPattern(s.texture,e);return Y.applyPatternTransform(o,s.transform),o}const i=r.texture;if(i&&i!==D.WHITE){if(!i.source.resource)return jw;const o=Y.getTintedPattern(i,e),a=t?no.copyFrom(t).scale(i.source.pixelWidth,i.source.pixelHeight):r.matrix;return Y.applyPatternTransform(o,a),o}return Zw(e)}class zh{constructor(){this.shader=null}contextChange(e){}execute(e,t){var y,b,v,C,S,E,U;const n=e.renderer,s=n.canvasContext,i=s.activeContext,o=t.groupTransform,a=((y=n.globalUniforms.globalUniformData)==null?void 0:y.worldColor)??4294967295,c=t.groupColorAlpha,l=(a>>>24&255)/255,u=(c>>>24&255)/255,h=((b=n.filter)==null?void 0:b.alphaMultiplier)??1,d=l*u*h;if(d<=0)return;const f=a&16777215,p=c&16777215,m=Jt(qt(p,f)),g=n._roundPixels|t._roundPixels;i.save(),s.setContextTransform(o,g===1),s.setBlendMode(t.groupBlendMode);const _=t.context.instructions;for(let z=0;z<_.length;z++){const M=_[z];if(M.action==="texture"){const re=M.data,O=re.image,ie=O?Y.getCanvasSource(O):null;if(!ie)continue;const Ge=re.alpha*d;if(Ge<=0)continue;const Ee=qt(re.style,m);i.globalAlpha=Ge;let we=ie;Ee!==16777215&&(we=Y.getTintedCanvas({texture:O},Ee));const Ze=O.frame,Oe=O.source._resolution??O.source.resolution??1;let Me=Ze.x*Oe,ze=Ze.y*Oe;const nt=Ze.width*Oe,K=Ze.height*Oe;we!==ie&&(Me=0,ze=0);const Ne=re.transform,Ke=Ne&&!Ne.isIdentity(),xe=O.rotate;Ke||xe?(Jn.copyFrom(o),Ke&&Jn.append(Ne),xe&&X.matrixAppendRotationInv(Jn,xe,re.dx,re.dy,re.dw,re.dh),s.setContextTransform(Jn,g===1)):s.setContextTransform(o,g===1),i.drawImage(we,Me,ze,we===ie?nt:we.width,we===ie?K:we.height,xe?0:re.dx,xe?0:re.dy,re.dw,re.dh),(Ke||xe)&&s.setContextTransform(o,g===1);continue}const A=M.data,j=(v=A==null?void 0:A.path)==null?void 0:v.shapePath;if(!((C=j==null?void 0:j.shapePrimitives)!=null&&C.length))continue;const q=A.style,se=qt(q.color,m),Ye=q.alpha*d;if(Ye<=0)continue;const k=M.action==="stroke";if(i.globalAlpha=Ye,k){const re=q;i.lineWidth=re.width,i.lineCap=re.cap,i.lineJoin=re.join,i.miterLimit=re.miterLimit}const G=j.shapePrimitives;if(!k&&((U=(E=(S=A.hole)==null?void 0:S.shapePath)==null?void 0:E.shapePrimitives)!=null&&U.length)){const re=G[G.length-1];re.holes=A.hole.shapePath.shapePrimitives}for(let re=0;re<G.length;re++){const O=G[re];if(!(O!=null&&O.shape))continue;const ie=O.transform,Ge=ie&&!ie.isIdentity(),Ee=q.texture&&q.texture!==D.WHITE,we=q.textureSpace==="global"?ie:null,Ze=Ee?ju(Ww,q,O.shape,we):null,Oe=Ge?Xw.copyFrom(o).append(ie):o,Me=Jw(q,se,Ze,Oe);if(Ge&&(i.save(),i.transform(ie.a,ie.b,ie.c,ie.d,ie.tx,ie.ty)),k){const ze=q;if(ze.alignment!==.5&&!ze.pixelLine){const K=[],Ne=[],Ke=[],xe=hr[O.shape.type];if(xe!=null&&xe.build(O.shape,K)){const lt=O.shape.closePath??!0;Ui(K,ze,!1,lt,Ne,Ke),i.fillStyle=Me,Yw(i,Ne,Ke)}else i.strokeStyle=Me,i.beginPath(),Qn(i,O.shape),i.stroke()}else i.strokeStyle=Me,i.beginPath(),Qn(i,O.shape),i.stroke()}else i.fillStyle=Me,i.beginPath(),Qn(i,O.shape),qw(i,O.holes)?i.fill("evenodd"):i.fill();Ge&&i.restore()}}i.restore()}destroy(){this.shader=null}}zh.extension={type:[x.CanvasPipesAdaptor],name:"graphics"};class so{constructor(e){this._renderer=e}addRenderable(e,t){const n=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n,t)}updateRenderable(e){const t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new kh;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}so.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"sprite"};const Kr={};H.handle(x.BlendMode,r=>{if(!r.name)throw new Error("BlendMode extension must have a name property");Kr[r.name]=r.ref},r=>{delete Kr[r.name]});class io{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,n){this._blendModeStack.push(t),this.setBlendMode(e,t,n)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,n){var i;const s=e instanceof Qs;if(this._activeBlendMode===t){this._isAdvanced&&e&&!s&&((i=this._renderableList)==null||i.push(e));return}this._isAdvanced&&this._endAdvancedBlendMode(n),this._activeBlendMode=t,e&&(this._isAdvanced=!!Kr[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,n))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const n=this._activeBlendMode;if(!Kr[n]){W(`Unable to assign BlendMode: '${n}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const s=this._ensureFilterEffect(n),i=e instanceof Qs,o={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:i?null:[e],container:i?e.root:null,canBundle:!1};this._renderableList=o.renderables,t.add(o)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new Mn,t.filters=[new Kr[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(const e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}io.extension={type:[x.WebGLPipes,x.WebGPUPipes,x.CanvasPipes],name:"blendMode"};function oo(r,e){e||(e=0);for(let t=e;t<r.length&&r[t];t++)r[t]=null}const Qw=new Ie,Nh=Rr|Fn|ri;function $h(r,e=!1){e1(r);const t=r.childrenToUpdate,n=r.updateTick++;for(const s in t){const i=Number(s),o=t[s],a=o.list,c=o.index;for(let l=0;l<c;l++){const u=a[l];u.parentRenderGroup===r&&u.relativeRenderGroupDepth===i&&Vh(u,n,0)}oo(a,c),o.index=0}if(e)for(let s=0;s<r.renderGroupChildren.length;s++)$h(r.renderGroupChildren[s],e)}function e1(r){const e=r.root;let t;if(r.renderGroupParent){const n=r.renderGroupParent;r.worldTransform.appendFrom(e.relativeGroupTransform,n.worldTransform),r.worldColor=kn(e.groupColor,n.worldColor),t=e.groupAlpha*n.worldAlpha}else r.worldTransform.copyFrom(e.localTransform),r.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,r.worldAlpha=t,r.worldColorAlpha=r.worldColor+((t*255|0)<<24)}function Vh(r,e,t){if(e===r.updateTick)return;r.updateTick=e,r.didChange=!1;const n=r.localTransform;r.updateLocalTransform();const s=r.parent;if(s&&!s.renderGroup?(t|=r._updateFlags,r.relativeGroupTransform.appendFrom(n,s.relativeGroupTransform),t&Nh&&Hh(r,s,t)):(t=r._updateFlags,r.relativeGroupTransform.copyFrom(n),t&Nh&&Hh(r,Qw,t)),!r.renderGroup){const i=r.children,o=i.length;for(let l=0;l<o;l++)Vh(i[l],e,t);const a=r.parentRenderGroup,c=r;c.renderPipeId&&!a.structureDidChange&&a.updateRenderable(c)}}function Hh(r,e,t){if(t&Fn){r.groupColor=kn(r.localColor,e.groupColor);let n=r.localAlpha*e.groupAlpha;n=n<0?0:n>1?1:n,r.groupAlpha=n,r.groupColorAlpha=r.groupColor+((n*255|0)<<24)}t&ri&&(r.groupBlendMode=r.localBlendMode==="inherit"?e.groupBlendMode:r.localBlendMode),t&Rr&&(r.globalDisplayStatus=r.localDisplayStatus&e.globalDisplayStatus),r._updateFlags=0}function t1(r,e){const{list:t}=r.childrenRenderablesToUpdate;let n=!1;for(let s=0;s<r.childrenRenderablesToUpdate.index;s++){const i=t[s];if(n=e[i.renderPipeId].validateRenderable(i),n)break}return r.structureDidChange=n,n}const r1=new B;class jh{constructor(e){this._renderer=e}render({container:e,transform:t}){const n=e.parent,s=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const i=this._renderer,o=r1;t&&(o.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));const a=i.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),i.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),to(e.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=n,e.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let n=e.renderGroupChildren.length-1;n>=0;n--)this._updateCachedRenderGroups(e.renderGroupChildren[n],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const n=e.root.getLocalBounds(),s=this._renderer,i=e.textureOptions.resolution||s.view.resolution,o=e.textureOptions.antialias??s.view.antialias,a=e.textureOptions.scaleMode??"linear",c=e.texture;n.ceil(),e.texture&&Re.returnTexture(e.texture,!0);const l=Re.getOptimalTexture(n.width,n.height,i,o);l._source.style=new Bs({scaleMode:a}),e.texture=l,e._textureBounds||(e._textureBounds=new Pe),e._textureBounds.copyFrom(n),c!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(Re.returnTexture(e.texture,!0),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,n=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=n,e.structureDidChange?oo(e.childrenRenderablesToUpdate.list,0):t1(e,n),$h(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!(e.isCachedAsTexture&&!e.textureNeedsUpdate))for(let s=0;s<e.renderGroupChildren.length;s++)this._updateRenderGroups(e.renderGroupChildren[s])}_updateRenderables(e){const{list:t,index:n}=e.childrenRenderablesToUpdate;for(let s=0;s<n;s++){const i=t[s];i.didViewUpdate&&e.updateRenderable(i)}oo(t,n)}_buildInstructions(e,t){const n=e.root,s=e.instructionSet;s.reset();const i=t.renderPipes?t:t.batch.renderer,o=i.renderPipes;o.batch.buildStart(s),o.blendMode.buildStart(),o.colorMask.buildStart(),n.sortableChildren&&n.sortChildren(),n.collectRenderablesWithEffects(s,i,null),o.batch.buildEnd(s),o.blendMode.buildEnd(s)}}jh.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"renderGroup"};const ao=class pf{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new ye(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...pf.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){ye.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&W("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};ao.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"background",priority:0},ao.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let n1=ao;const co={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},lo=class mf{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof Ie||e instanceof D?{target:e,...t}:{...t,...e}}async image(e){const t=te.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,mf.defaultImageOptions);const{format:t,quality:n}=e,s=this.canvas(e);if(s.toBlob!==void 0)return new Promise((i,o)=>{s.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const c=new FileReader;c.onload=()=>i(c.result),c.onerror=o,c.readAsDataURL(a)},co[t],n)});if(s.toDataURL!==void 0)return s.toDataURL(co[t],n);if(s.convertToBlob!==void 0){const i=await s.convertToBlob({type:co[t],quality:n});return new Promise((o,a)=>{const c=new FileReader;c.onload=()=>o(c.result),c.onerror=a,c.readAsDataURL(i)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){e=this._normalizeOptions(e);const t=e.target,n=this._renderer;if(t instanceof D)return n.texture.generateCanvas(t);const s=n.textureGenerator.generateTexture(e),i=n.texture.generateCanvas(s);return s.destroy(!0),i}pixels(e){e=this._normalizeOptions(e);const t=e.target,n=this._renderer,s=t instanceof D?t:n.textureGenerator.generateTexture(e),i=n.texture.getPixels(s);return t instanceof Ie&&s.destroy(!0),i}texture(e){return e=this._normalizeOptions(e),e.target instanceof D?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const t=this.canvas(e),n=document.createElement("a");n.download=e.filename??"image.png",n.href=t.toDataURL("image/png"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(e){const t=e.width??200;e=this._normalizeOptions(e);const n=this.canvas(e),s=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);const i=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",i)}destroy(){this._renderer=null}};lo.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"extract"},lo.defaultImageOptions={format:"png",quality:1};let s1=lo;class uo extends D{static create(e){const{dynamic:t,textureOptions:n,...s}=e;return new uo({...n,source:new ve(s),dynamic:t??!1})}resize(e,t,n){return this.source.resize(e,t,n),this}}const i1=new fe,o1=new Pe,a1=[0,0,0,0];class Wh{constructor(e){this._renderer=e}generateTexture(e){var u;e instanceof Ie&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,n=e.antialias||this._renderer.view.antialias,s=e.target;let i=e.clearColor;i?i=Array.isArray(i)&&i.length===4?i:ye.shared.setValue(i).toArray():i=a1;const o=((u=e.frame)==null?void 0:u.copyTo(i1))||Zs(s,o1).rectangle,a=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};o.width=Math.max(o.width,1/t)|0,o.height=Math.max(o.height,1/t)|0;const c=uo.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:n,textureOptions:a}),l=B.shared.translate(-o.x,-o.y);return this._renderer.render({container:s,transform:l,target:c,clearColor:i}),c.source.updateMipmaps(),c}destroy(){this._renderer=null}}Wh.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"textureGenerator"};function c1(r){let e=!1;for(const n in r)if(r[n]==null){e=!0;break}if(!e)return r;const t=Object.create(null);for(const n in r){const s=r[n];s&&(t[n]=s)}return t}function l1(r){let e=0;for(let t=0;t<r.length;t++)r[t]==null?e++:r[t-e]=r[t];return r.length-=e,r}const ho=class gf{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(e){e={...gf.defaultOptions,...e},this.maxUnusedTime=e.gcMaxUnusedTime,this._frequency=e.gcFrequency,this.enabled=e.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedCollections){const{context:n,collection:s,type:i}=t;i==="hash"?n[s]=c1(n[s]):n[s]=l1(n[s])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(const n of e.renderGroupChildren)this._updateInstructionGCTick(n,t)}addCollection(e,t,n){this._managedCollections.push({context:e,collection:t,type:n})}addResource(e,t){var s,i;if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,(s=e._onTouch)==null||s.call(e,this.now);return}const n=this._managedResources.length;e._gcData={index:n,type:t},e._gcLastUsed=this.now,(i=e._onTouch)==null||i.call(e,this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){const t=e._gcData;if(!t)return;const n=t.index,s=this._managedResources.length-1;if(n!==s){const i=this._managedResources[s];this._managedResources[n]=i,i._gcData.index=n}this._managedResources.length--,e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,n,s=0){this._managedResourceHashes.push({context:e,hash:t,type:n,priority:s}),this._managedResourceHashes.sort((i,o)=>i.priority-o.priority)}run(){const e=performance.now(),t=this._managedResourceHashes;for(const s of t)this.runOnHash(s,e);let n=0;for(let s=0;s<this._managedResources.length;s++){const i=this._managedResources[s];n=this.runOnResource(i,e,n)}this._managedResources.length=n}updateRenderableGCTick(e,t){var i,o;const n=e.renderGroup??e.parentRenderGroup,s=((i=n==null?void 0:n.instructionSet)==null?void 0:i.gcTick)??-1;((n==null?void 0:n.gcTick)??0)===s&&(e._gcLastUsed=t,(o=e._onTouch)==null||o.call(e,t))}runOnResource(e,t,n){const s=e._gcData;return s.type==="renderable"&&this.updateRenderableGCTick(e,t),t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect?(this._managedResources[n]=e,s.index=n,n++):(e.unload(),e._gcData=null,e._gcLastUsed=-1,e.off("unload",this.removeResource,this)),n}_createHashClone(e,t){const n=Object.create(null);for(const s in e){if(s===t)break;e[s]!==null&&(n[s]=e[s])}return n}runOnHash(e,t){var l;const{context:n,hash:s,type:i}=e,o=n[s];let a=null,c=0;for(const u in o){const h=o[u];if(h===null){c++,c===1e4&&!a&&(a=this._createHashClone(o,u));continue}if(h._gcLastUsed===-1){h._gcLastUsed=t,(l=h._onTouch)==null||l.call(h,t),a&&(a[u]=h);continue}if(i==="renderable"&&this.updateRenderableGCTick(h,t),!(t-h._gcLastUsed<this.maxUnusedTime)&&h.autoGarbageCollect){if(a||(c+1!==1e4?(o[u]=null,c++):a=this._createHashClone(o,u)),i==="renderable"){const f=h,p=f.renderGroup??f.parentRenderGroup;p&&(p.structureDidChange=!0)}h.unload(),h._gcData=null,h._gcLastUsed=-1}else a&&(a[u]=h)}a&&(n[s]=a)}destroy(){this.enabled=!1,this._managedResources.forEach(e=>{e.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};ho.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"gc",priority:0},ho.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let u1=ho;class Xh{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:n,worldColor:s,offset:i}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new B,worldColor:4294967295,offset:new le},c={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||o.size,worldTransformMatrix:n||a.worldTransformMatrix,worldColor:s||a.worldColor,offset:i||a.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);const u=l.uniforms;u.uProjectionMatrix=c.projectionMatrix,u.uResolution=c.resolution,u.uWorldTransformMatrix.copyFrom(c.worldTransformMatrix),u.uWorldTransformMatrix.tx-=c.offset.x,u.uWorldTransformMatrix.ty-=c.offset.y,Zi(c.worldColor,u.uWorldColorAlpha,0),l.update();let h;this._renderer.renderPipes.uniformBatch?h=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(h=this._bindGroupPool.pop()||new yt,this._activeBindGroups.push(h),h.setResource(l,0)),c.bindGroup=h,this._currentGlobalUniformData=c}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===at.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new je({uProjectionMatrix:{value:new B,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new B,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}Xh.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"globalUniforms"};let h1=1;class Yh{constructor(){this._tasks=[],this._offset=0}init(){Xe.system.add(this._update,this)}repeat(e,t,n=!0){const s=h1++;let i=0;return n&&(this._offset+=1e3,i=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:i,last:performance.now(),repeat:!0,id:s}),s}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){const e=performance.now();for(let t=0;t<this._tasks.length;t++){const n=this._tasks[t];if(e-n.offset-n.last>=n.duration){const s=e-n.start;n.func(s),n.last=e}}}destroy(){Xe.system.remove(this._update,this),this._tasks.length=0}}Yh.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"scheduler",priority:0};let Zh=!1;function d1(r){if(!Zh){if(te.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Vn} (${r}) http://www.pixijs.com/
928
+
929
+ `,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${Vn} - ${r} - http://www.pixijs.com/`);Zh=!0}}class fo{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===at.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),d1(t)}}}fo.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"hello",priority:-2},fo.defaultOptions={hello:!1};const po=class _f{constructor(e){this._renderer=e}init(e){e={..._f.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return N("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){N("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){N("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){N("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){N("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){N("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};po.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"renderableGC",priority:0},po.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let f1=po;const mo=class ns{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(e){e.textureGCActive!==ns.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==ns.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==ns.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};mo.extension={type:[x.WebGLSystem,x.WebGPUSystem],name:"textureGC"},mo.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let p1=mo;const Kh=class yf{constructor(e={}){if(this.uid=ce("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,e={...yf.defaultOptions,...e},this.stencil=e.stencil,this.depth=e.depth,this.isRoot=e.isRoot,typeof e.colorTextures=="number"){this._managedColorTextures=!0;for(let t=0;t<e.colorTextures;t++)this.colorTextures.push(new ve({width:e.width,height:e.height,resolution:e.resolution,antialias:e.antialias}))}else{this.colorTextures=[...e.colorTextures.map(n=>n.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(e.depthStencilTexture||this.stencil)&&(e.depthStencilTexture instanceof D||e.depthStencilTexture instanceof ve?this.depthStencilTexture=e.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ve({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(e,t,n=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((i,o)=>{s&&o===0||i.source.resize(e,t,n)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(e,t,n)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(e=>{e.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};Kh.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let go=Kh;const mr=new Map;Kt.register(mr);function qh(r,e){if(!mr.has(r)){const t=new D({source:new ot({resource:r,...e})}),n=()=>{mr.get(r)===t&&mr.delete(r)};t.once("destroy",n),t.source.once("destroy",n),mr.set(r,t)}return mr.get(r)}const _o=class bf{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(e){e={...bf.defaultOptions,...e},e.view&&(N(de,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new fe(0,0,e.width,e.height),this.canvas=e.canvas||te.get().createCanvas(),this.antialias=!!e.antialias,this.texture=qh(this.canvas,e),this.renderTarget=new go({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.resolution}resize(e,t,n){this.texture.source.resize(e,t,n),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e=="boolean"?e:!!(e!=null&&e.removeView))&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};_o.extension={type:[x.WebGLSystem,x.WebGPUSystem,x.CanvasSystem],name:"view",priority:0},_o.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const yo=[n1,Xh,fo,_o,jh,u1,p1,Wh,s1,uu,f1,Yh],Jh=[io,Ji,so,ro,Qi,Dh,Fh,eo];function m1(r,e,t,n,s,i){const o=i?1:-1;return r.identity(),r.a=1/n*2,r.d=o*(1/s*2),r.tx=-1-e*r.a,r.ty=-o-t*r.d,r}function g1(r){const e=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}class bo{constructor(e){this.rootViewPort=new fe,this.viewport=new fe,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new _l("onRenderTargetChange"),this.projectionMatrix=new B,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:n,frame:s,mipLevel:i,layer:o}){var a,c;this._renderTargetStack.length=0,this.push(e,t,n,s,i??0,o??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=g1(this.rootRenderTarget),(c=(a=this.adaptor).prerender)==null||c.call(a,this.rootRenderTarget)}postrender(){var e,t;(t=(e=this.adaptor).postrender)==null||t.call(e,this.rootRenderTarget)}bind(e,t=!0,n,s,i=0,o=0){const a=this.getRenderTarget(e),c=this.renderTarget!==a;this.renderTarget=a,this.renderSurface=e;const l=this.getGpuRenderTarget(a);(a.pixelWidth!==l.width||a.pixelHeight!==l.height)&&(this.adaptor.resizeGpuRenderTarget(a),l.width=a.pixelWidth,l.height=a.pixelHeight);const u=a.colorTexture,h=this.viewport,d=u.arrayLayerCount||1;if((o|0)!==o&&(o|=0),o<0||o>=d)throw new Error(`[RenderTargetSystem] layer ${o} is out of bounds (arrayLayerCount=${d}).`);this.mipLevel=i|0,this.layer=o|0;const f=Math.max(u.pixelWidth>>i,1),p=Math.max(u.pixelHeight>>i,1);if(!s&&e instanceof D&&(s=e.frame),s){const m=u._resolution,g=1<<Math.max(i|0,0),_=s.x*m+.5|0,y=s.y*m+.5|0,b=s.width*m+.5|0,v=s.height*m+.5|0;let C=Math.floor(_/g),S=Math.floor(y/g),E=Math.ceil(b/g),U=Math.ceil(v/g);C=Math.min(Math.max(C,0),f-1),S=Math.min(Math.max(S,0),p-1),E=Math.min(Math.max(E,1),f-C),U=Math.min(Math.max(U,1),p-S),h.x=C,h.y=S,h.width=E,h.height=U}else h.x=0,h.y=0,h.width=f,h.height=p;return m1(this.projectionMatrix,0,0,h.width/u.resolution,h.height/u.resolution,!a.isRoot),this.adaptor.startRenderPass(a,t,n,h,i,o),c&&this.onRenderTargetChange.emit(a),a}clear(e,t=Le.ALL,n,s=this.mipLevel,i=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,n,this.viewport,s,i))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=Le.ALL,n,s,i=0,o=0){const a=this.bind(e,t,n,s,i,o);return this._renderTargetStack.push({renderTarget:a,frame:s,mipLevel:i,layer:o}),a}pop(){this._renderTargetStack.pop();const e=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(e.renderTarget,!1,null,e.frame,e.mipLevel,e.layer)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,n,s,i){n.x<0&&(s.width+=n.x,i.x-=n.x,n.x=0),n.y<0&&(s.height+=n.y,i.y-=n.y,n.y=0);const{pixelWidth:o,pixelHeight:a}=e;return s.width=Math.min(s.width,o-n.x),s.height=Math.min(s.height,a-n.y),this.adaptor.copyToTexture(e,t,n,s,i)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e!==t&&e.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;return ot.test(e)&&(e=qh(e).source),e instanceof go?t=e:e instanceof ve&&(t=new go({colorTextures:[e]}),e.source instanceof ot&&(t.isRoot=!0),e.once("destroy",()=>{t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);const n=this._gpuRenderTargetHash[t.uid];n&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(n))})),this._renderSurfaceToRenderTargetHash.set(e,t),t}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this.renderSurface=null}}class _1{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:n,context:s}=this._ensureCanvas(t);return{canvas:n,context:s,width:n.width,height:n.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:n}=this._ensureCanvas(t);n.width=e.pixelWidth,n.height=e.pixelHeight}startRenderPass(e,t,n,s){const i=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=i.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,n,s)}clear(e,t,n,s){const o=this._renderTargetSystem.getGpuRenderTarget(e).context,a=s||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(a.x,a.y,a.width,a.height),n){const c=ye.shared.setValue(n);c.alpha>0&&(o.globalAlpha=c.alpha,o.fillStyle=c.toHex(),o.fillRect(a.x,a.y,a.width,a.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,n,s,i){const a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:l}=this._ensureCanvas(c),u=(i==null?void 0:i.x)??0,h=(i==null?void 0:i.y)??0;return l.drawImage(a,n.x,n.y,s.width,s.height,u,h,s.width,s.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!ot.test(t))&&(t=te.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const n=t.getContext("2d");return{canvas:t,context:n}}}class Qh extends bo{constructor(e){super(e),this.adaptor=new _1,this.adaptor.init(e,this)}}Qh.extension={type:[x.CanvasSystem],name:"renderTarget"};class ed{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=te.get().createCanvas(),n=t.getContext("2d"),s=Y.getCanvasSource(e);if(!s)return t;const i=e.frame,o=e.source._resolution??e.source.resolution??1,a=i.x*o,c=i.y*o,l=i.width*o,u=i.height*o;return t.width=Math.ceil(l),t.height=Math.ceil(u),n.drawImage(s,a,c,l,u,0,0,l,u),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}ed.extension={type:[x.CanvasSystem],name:"texture"};const y1=[...yo,Uh,Lh,ed,Qh],b1=[io,Ji,so,ro,Qi,Oh,Bh,eo],x1=[Gw,zh],td=[],rd=[],nd=[];H.handleByNamedList(x.CanvasSystem,td),H.handleByNamedList(x.CanvasPipes,rd),H.handleByNamedList(x.CanvasPipesAdaptor,nd),H.add(...y1,...b1,...x1);class v1 extends er{constructor(){const e={name:"canvas",type:at.CANVAS,systems:td,renderPipes:rd,renderPipeAdaptors:nd};super(e)}}const T1=Object.freeze(Object.defineProperty({__proto__:null,CanvasRenderer:v1},Symbol.toStringTag,{value:"Module"}));var es=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(es||{});class S1{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class sd{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new xt({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){const{_gl:n}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,n.bindBufferBase(n.UNIFORM_BUFFER,t,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const i=this._boundBufferBases[s];if(i&&i._lastBindCallId===this._bindCallId){s++;continue}break}return t=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){const t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,n,s){const{_gl:i}=this;n||(n=0),t||(t=0),this._boundBufferBases[t]=null,i.bindBufferRange(i.UNIFORM_BUFFER,t||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&Q.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?t.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,t.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,t.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];n&&(t||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:t}=this;let n=es.ARRAY_BUFFER;e.descriptor.usage&Q.INDEX?n=es.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&Q.UNIFORM&&(n=es.UNIFORM_BUFFER);const s=new S1(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}sd.extension={type:[x.WebGLSystem],name:"buffer"};const xo=class xf{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...xf.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(W("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=te.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&W("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof te.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const t=this._renderer.view.canvas;t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,t){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",t)),!n&&(n=s.getContext("webgl",t),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,t={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...t,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...t,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var t;this.gl.isContextLost()&&((t=this.extensions.loseContext)==null||t.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const t=e.getContextAttributes();t&&!t.stencil&&W("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,i=this.extensions;n.uint32Indices=s||!!i.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!i.vertexArrayObject,n.srgbTextures=s||!!i.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||W("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};xo.extension={type:[x.WebGLSystem],name:"context"},xo.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let w1=xo;function id(r,e){for(const t in r.attributes){const n=r.attributes[t],s=e[t];s?(n.format??(n.format=s.format),n.offset??(n.offset=s.offset),n.instance??(n.instance=s.instance)):W(`Attribute ${t} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}P1(r)}function P1(r){const{buffers:e,attributes:t}=r,n={},s={};for(const i in e){const o=e[i];n[o.uid]=0,s[o.uid]=0}for(const i in t){const o=t[i];n[o.buffer.uid]+=pt(o.format).stride}for(const i in t){const o=t[i];o.stride??(o.stride=n[o.buffer.uid]),o.start??(o.start=s[o.buffer.uid]),s[o.buffer.uid]+=pt(o.format).stride}}var vo=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(vo||{}),To=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(To||{}),ee=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(ee||{});const od={uint8x2:ee.UNSIGNED_BYTE,uint8x4:ee.UNSIGNED_BYTE,sint8x2:ee.BYTE,sint8x4:ee.BYTE,unorm8x2:ee.UNSIGNED_BYTE,unorm8x4:ee.UNSIGNED_BYTE,snorm8x2:ee.BYTE,snorm8x4:ee.BYTE,uint16x2:ee.UNSIGNED_SHORT,uint16x4:ee.UNSIGNED_SHORT,sint16x2:ee.SHORT,sint16x4:ee.SHORT,unorm16x2:ee.UNSIGNED_SHORT,unorm16x4:ee.UNSIGNED_SHORT,snorm16x2:ee.SHORT,snorm16x4:ee.SHORT,float16x2:ee.HALF_FLOAT,float16x4:ee.HALF_FLOAT,float32:ee.FLOAT,float32x2:ee.FLOAT,float32x3:ee.FLOAT,float32x4:ee.FLOAT,uint32:ee.UNSIGNED_INT,uint32x2:ee.UNSIGNED_INT,uint32x3:ee.UNSIGNED_INT,uint32x4:ee.UNSIGNED_INT,sint32:ee.INT,sint32x2:ee.INT,sint32x3:ee.INT,sint32x4:ee.INT};function E1(r){return od[r]??od.float32}const C1={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class M1{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ad{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new xt({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=s=>t.bindVertexArrayOES(s),e.deleteVertexArray=s=>t.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,i,o,a)=>{n.drawArraysInstancedANGLE(s,i,o,a)},e.drawElementsInstanced=(s,i,o,a,c)=>{n.drawElementsInstancedANGLE(s,i,o,a,c)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,t);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];t.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const n=e.attributes,s=t._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,t){const n=e.attributes,s=t._attributeData,i=["g",e.uid];for(const o in n)s[o]&&i.push(o,s[o].location);return i.join("-")}getVao(e,t){var n;return((n=e._gpuData[this._renderer.uid])==null?void 0:n.vaoCache[t._key])||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);const o=this.getSignature(e,t);let a=e._gpuData[this._renderer.uid];a||(a=new M1,e._gpuData[this._renderer.uid]=a,this._managedGeometries.add(e));const c=a.vaoCache;let l=c[o];if(l)return c[t._key]=l,l;id(e,t._attributeData);const u=e.buffers;l=s.createVertexArray(),s.bindVertexArray(l);for(let h=0;h<u.length;h++){const d=u[h];i.bind(d)}return this.activateVao(e,t),c[t._key]=l,c[o]=l,s.bindVertexArray(null),l}onGeometryUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!t)for(const i in s)this._activeVao!==s[i]&&this.resetState(),this.gl.deleteVertexArray(s[i])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){var a;const n=this._renderer.gl,s=this._renderer.buffer,i=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let o=null;for(const c in i){const l=i[c],u=l.buffer,h=s.getGlBuffer(u),d=t._attributeData[c];if(d){o!==h&&(s.bind(u),o=h);const f=d.location;n.enableVertexAttribArray(f);const p=pt(l.format),m=E1(l.format);if(((a=d.format)==null?void 0:a.substring(1,4))==="int"?n.vertexAttribIPointer(f,p.size,m,l.stride,l.offset):n.vertexAttribPointer(f,p.size,m,p.normalised,l.stride,l.offset),l.instance)if(this.hasInstance){const g=l.divisor??1;n.vertexAttribDivisor(f,g)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,n,s){const{gl:i}=this._renderer,o=this._activeGeometry,a=C1[e||o.topology];if(s??(s=o.instanceCount),o.indexBuffer){const c=o.indexBuffer.data.BYTES_PER_ELEMENT,l=c===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;s!==1?i.drawElementsInstanced(a,t||o.indexBuffer.data.length,l,(n||0)*c,s):i.drawElements(a,t||o.indexBuffer.data.length,l,(n||0)*c)}else s!==1?i.drawArraysInstanced(a,n||0,t||o.getSize(),s):i.drawArrays(a,n||0,t||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ad.extension={type:[x.WebGLSystem],name:"geometry"};const A1=new tr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),So=class vf{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:n}={...vf.defaultOptions,...e};this.useBackBuffer=t,this._antialias=n,this._renderer.context.supports.msaa||(W("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=ct.for2d();const s=new Ot({vertex:`
930
+ attribute vec2 aPosition;
931
+ out vec2 vUv;
932
+
933
+ void main() {
934
+ gl_Position = vec4(aPosition, 0.0, 1.0);
935
+
936
+ vUv = (aPosition + 1.0) / 2.0;
937
+
938
+ // flip dem UVs
939
+ vUv.y = 1.0 - vUv.y;
940
+ }`,fragment:`
941
+ in vec2 vUv;
942
+ out vec4 finalColor;
943
+
944
+ uniform sampler2D uTexture;
945
+
946
+ void main() {
947
+ finalColor = texture(uTexture, vUv);
948
+ }`,name:"big-triangle"});this._bigTriangleShader=new bt({glProgram:s,resources:{uTexture:D.WHITE.source}})}renderStart(e){const t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){const n=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=n.colorTexture,e.target=this._getBackBufferTexture(n.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:A1,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new D({source:new ve({width:e.width,height:e.height,resolution:e._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(e.width,e.height,e._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};So.extension={type:[x.WebGLSystem],name:"backBuffer",priority:1},So.defaultOptions={useBackBuffer:!1};let k1=So;class cd{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1)))}}cd.extension={type:[x.WebGLSystem],name:"colorMask"};class ld{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){const t=this._renderer,{geometry:n,shader:s,state:i,skipSync:o,topology:a,size:c,start:l,instanceCount:u}=e;t.shader.bind(s,o),t.geometry.bind(n,t.shader._activeProgram),i&&t.state.set(i),t.geometry.draw(a,c,l,u??n.instanceCount)}destroy(){this._renderer=null}}ld.extension={type:[x.WebGLSystem],name:"encoder"};class ud{constructor(e){this._renderer=e}contextChange(){const e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=_u(this.maxTextures,e);const t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}ud.extension={type:[x.WebGLSystem],name:"limits"};class R1{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const Ct=[];Ct[be.NONE]=void 0,Ct[be.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Ct[be.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Ct[be.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Ct[be.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Ct[be.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class hd{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:be.NONE},this._renderTargetStencilState=Object.create(null),e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this.resetState()}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:be.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=be.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){const n=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,i=Ct[e],o=this._stencilCache;if(n.stencilMode=e,n.stencilReference=t,e===be.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),(e!==o.stencilMode||o.stencilReference!==t)&&(o.stencilMode=e,o.stencilReference=t,s.stencilFunc(this._comparisonFuncMapping[i.stencilBack.compare],t,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[i.stencilBack.passOp]))}}hd.extension={type:[x.WebGLSystem],name:"stencil"};class I1{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new fe}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new fe;const e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},(n,s)=>e.COLOR_ATTACHMENT0+s)}copyToTexture(e,t,n,s,i){const o=this._renderTargetSystem,a=this._renderer,c=o.getGpuRenderTarget(e),l=a.gl;return this.finishRenderPass(e),l.bindFramebuffer(l.FRAMEBUFFER,c.resolveTargetFramebuffer),a.texture.bind(t,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,i.x,i.y,n.x,n.y,s.width,s.height),t}startRenderPass(e,t=!0,n,s,i=0,o=0){const a=this._renderTargetSystem,c=e.colorTexture,l=a.getGpuRenderTarget(e);if(o!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(i>0){if(l.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let u=s.y;e.isRoot&&(u=c.pixelHeight-s.height-s.y),e.colorTextures.forEach(f=>{this._renderer.texture.unbind(f)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,l.framebuffer),!e.isRoot&&(l._attachedMipLevel!==i||l._attachedLayer!==o)&&(e.colorTextures.forEach((f,p)=>{const m=this._renderer.texture.getGlSource(f);if(m.target===h.TEXTURE_2D){if(o!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+p,h.TEXTURE_2D,m.texture,i)}else if(m.target===h.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");h.framebufferTextureLayer(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+p,m.texture,i,o)}else if(m.target===h.TEXTURE_CUBE_MAP){if(o<0||o>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+p,h.TEXTURE_CUBE_MAP_POSITIVE_X+o,m.texture,i)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),l._attachedMipLevel=i,l._attachedLayer=o),e.colorTextures.length>1&&this._setDrawBuffers(e,h);const d=this._viewPortCache;(d.x!==s.x||d.y!==u||d.width!==s.width||d.height!==s.height)&&(d.x=s.x,d.y=u,d.width=s.width,d.height=s.height,h.viewport(s.x,u,s.width,s.height)),!l.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(l),this.clear(e,t,n)}finishRenderPass(e){const n=this._renderTargetSystem.getGpuRenderTarget(e);if(!n.msaa)return;const s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,n.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,n.framebuffer),s.blitFramebuffer(0,0,n.width,n.height,0,0,n.width,n.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)}initGpuRenderTarget(e){const n=this._renderer.gl,s=new R1;return s._attachedMipLevel=0,s._attachedLayer=0,e.colorTexture instanceof ot?(this._renderer.context.ensureCanvasSize(e.colorTexture.resource),s.framebuffer=null,s):(this._initColor(e,s),n.bindFramebuffer(n.FRAMEBUFFER,null),s)}destroyGpuRenderTarget(e){const t=this._renderer.gl;e.framebuffer&&(t.deleteFramebuffer(e.framebuffer),e.framebuffer=null),e.resolveTargetFramebuffer&&(t.deleteFramebuffer(e.resolveTargetFramebuffer),e.resolveTargetFramebuffer=null),e.depthStencilRenderBuffer&&(t.deleteRenderbuffer(e.depthStencilRenderBuffer),e.depthStencilRenderBuffer=null),e.msaaRenderBuffer.forEach(n=>{t.deleteRenderbuffer(n)}),e.msaaRenderBuffer=null}clear(e,t,n,s,i=0,o=0){if(!t)return;if(o!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const a=this._renderTargetSystem;typeof t=="boolean"&&(t=t?Le.ALL:Le.NONE);const c=this._renderer.gl;if(t&Le.COLOR){n??(n=a.defaultClearColor);const l=this._clearColorCache,u=n;(l[0]!==u[0]||l[1]!==u[1]||l[2]!==u[2]||l[3]!==u[3])&&(l[0]=u[0],l[1]=u[1],l[2]=u[2],l[3]=u[3],c.clearColor(u[0],u[1],u[2],u[3]))}c.clear(t)}resizeGpuRenderTarget(e){if(e.isRoot)return;const n=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,n),(e.stencil||e.depth)&&this._resizeStencil(n)}_initColor(e,t){const n=this._renderer,s=n.gl,i=s.createFramebuffer();if(t.resolveTargetFramebuffer=i,s.bindFramebuffer(s.FRAMEBUFFER,i),t.width=e.colorTexture.source.pixelWidth,t.height=e.colorTexture.source.pixelHeight,e.colorTextures.forEach((a,c)=>{const l=a.source;l.antialias&&(n.context.supports.msaa?t.msaa=!0:W("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),n.texture.bindSource(l,0);const u=n.texture.getGlSource(l),h=u.texture;if(u.target===s.TEXTURE_2D)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+c,s.TEXTURE_2D,h,0);else if(u.target===s.TEXTURE_2D_ARRAY){if(n.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+c,h,0,0)}else if(u.target===s.TEXTURE_CUBE_MAP)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+c,s.TEXTURE_CUBE_MAP_POSITIVE_X,h,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),t.msaa){const a=s.createFramebuffer();t.framebuffer=a,s.bindFramebuffer(s.FRAMEBUFFER,a),e.colorTextures.forEach((c,l)=>{const u=s.createRenderbuffer();t.msaaRenderBuffer[l]=u})}else t.framebuffer=i;this._resizeColor(e,t)}_resizeColor(e,t){const n=e.colorTexture.source;if(t.width=n.pixelWidth,t.height=n.pixelHeight,t._attachedMipLevel=0,t._attachedLayer=0,e.colorTextures.forEach((s,i)=>{i!==0&&s.source.resize(n.width,n.height,n._resolution)}),t.msaa){const s=this._renderer,i=s.gl,o=t.framebuffer;i.bindFramebuffer(i.FRAMEBUFFER,o),e.colorTextures.forEach((a,c)=>{const l=a.source;s.texture.bindSource(l,0);const h=s.texture.getGlSource(l).internalFormat,d=t.msaaRenderBuffer[c];i.bindRenderbuffer(i.RENDERBUFFER,d),i.renderbufferStorageMultisample(i.RENDERBUFFER,4,h,l.pixelWidth,l.pixelHeight),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+c,i.RENDERBUFFER,d)})}}_initStencil(e){if(e.framebuffer===null)return;const t=this._renderer.gl,n=t.createRenderbuffer();e.depthStencilRenderBuffer=n,t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,n),this._resizeStencil(e)}_resizeStencil(e){const t=this._renderer.gl;t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa?t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}prerender(e){const t=e.colorTexture.resource;this._renderer.context.multiView&&ot.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(this._renderer.context.multiView&&ot.test(e.colorTexture.resource)){const t=this._renderer.context.canvas,n=e.colorTexture;n.context2D.drawImage(t,0,n.pixelHeight-t.height)}}_setDrawBuffers(e,t){const n=e.colorTextures.length,s=this._drawBuffersCache[n];if(this._renderer.context.webGLVersion===1){const i=this._renderer.context.extensions.drawBuffers;i?i.drawBuffersWEBGL(s):W("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else t.drawBuffers(s)}}class dd extends bo{constructor(e){super(e),this.adaptor=new I1,this.adaptor.init(e,this)}}dd.extension={type:[x.WebGLSystem],name:"renderTarget"};function B1(r){const e={};if(e.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e.add=[r.ONE,r.ONE],e.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],e["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof te.get().getWebGLRenderingContext()))e.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],e.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const n=r.getExtension("EXT_blend_minmax");n&&(e.min=[r.ONE,r.ONE,r.ONE,r.ONE,n.MIN_EXT,n.MIN_EXT],e.max=[r.ONE,r.ONE,r.ONE,r.ONE,n.MAX_EXT,n.MAX_EXT])}return e}const F1=0,G1=1,O1=2,D1=3,U1=4,L1=5,fd=class Do{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[F1]=this.setBlend,this.map[G1]=this.setOffset,this.map[O1]=this.setCullFace,this.map[D1]=this.setDepthTest,this.map[U1]=this.setFrontFace,this.map[L1]=this.setDepthMask,this.checks=[],this.defaultState=ct.for2d(),e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){this._invertFrontFace=!e.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(e){this.gl=e,this.blendModesMap=B1(e),this.resetState()}set(e){if(e||(e=this.defaultState),this.stateId!==e.data){let t=this.stateId^e.data,n=0;for(;t;)t&1&&this.map[n].call(this,!!(e.data&1<<n)),t>>=1,n++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e||(e=this.defaultState);for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(e){this._updateCheck(Do._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(Do._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this._cullFace=e,this.gl[e?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(e){this._frontFace=e,this._frontFaceDirty=!1;const t=this._invertFrontFace?!e:e;this._glFrontFace!==t&&(this._glFrontFace=t,this.gl.frontFace(this.gl[t?"CW":"CCW"]))}setBlendMode(e){if(this.blendModesMap[e]||(e="normal"),e===this.blendMode)return;this.blendMode=e;const t=this.blendModesMap[e],n=this.gl;t.length===2?n.blendFunc(t[0],t[1]):n.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,n.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(e,t){const n=this.checks.indexOf(e);t&&n===-1?this.checks.push(e):!t&&n!==-1&&this.checks.splice(n,1)}static _checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static _checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};fd.extension={type:[x.WebGLSystem],name:"state"};let z1=fd;class N1{constructor(e){this.target=To.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=ee.UNSIGNED_BYTE,this.internalFormat=vo.RGBA,this.format=vo.RGBA,this.samplerType=0}destroy(){}}const $1={id:"buffer",upload(r,e,t,n,s,i=!1){const o=s||e.target;!i&&e.width===r.width&&e.height===r.height?t.texSubImage2D(o,0,0,0,r.width,r.height,e.format,e.type,r.resource):t.texImage2D(o,0,e.internalFormat,r.width,r.height,0,e.format,e.type,r.resource),e.width=r.width,e.height=r.height}},V1={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},H1={id:"compressed",upload(r,e,t,n,s,i){const o=s??e.target;t.pixelStorei(t.UNPACK_ALIGNMENT,4);let a=r.pixelWidth,c=r.pixelHeight;const l=!!V1[r.format];for(let u=0;u<r.resource.length;u++){const h=r.resource[u];l?t.compressedTexImage2D(o,u,e.internalFormat,a,c,0,h):t.texImage2D(o,u,e.internalFormat,a,c,0,e.format,e.type,h),a=Math.max(a>>1,1),c=Math.max(c>>1,1)}}},pd=["right","left","top","bottom","front","back"];function j1(r){return{id:"cube",upload(e,t,n,s){const i=e.faces;for(let o=0;o<pd.length;o++){const a=pd[o],c=i[a];(r[c.uploadMethodId]||r.image).upload(c,t,n,s,To.TEXTURE_CUBE_MAP_POSITIVE_X+o,(t._layerInitMask&1<<o)===0),t._layerInitMask|=1<<o}t.width=e.pixelWidth,t.height=e.pixelHeight}}}const md={id:"image",upload(r,e,t,n,s,i=!1){const o=s||e.target,a=r.pixelWidth,c=r.pixelHeight,l=r.resourceWidth,u=r.resourceHeight,h=n===2,d=i||e.width!==a||e.height!==c,f=l>=a&&u>=c,p=r.resource;(h?W1:X1)(t,o,e,a,c,l,u,p,d,f),e.width=a,e.height=c}};function W1(r,e,t,n,s,i,o,a,c,l){if(!l){c&&r.texImage2D(e,0,t.internalFormat,n,s,0,t.format,t.type,null),r.texSubImage2D(e,0,0,0,i,o,t.format,t.type,a);return}if(!c){r.texSubImage2D(e,0,0,0,t.format,t.type,a);return}r.texImage2D(e,0,t.internalFormat,n,s,0,t.format,t.type,a)}function X1(r,e,t,n,s,i,o,a,c,l){if(!l){c&&r.texImage2D(e,0,t.internalFormat,n,s,0,t.format,t.type,null),r.texSubImage2D(e,0,0,0,t.format,t.type,a);return}if(!c){r.texSubImage2D(e,0,0,0,t.format,t.type,a);return}r.texImage2D(e,0,t.internalFormat,t.format,t.type,a)}const Y1=Fw(),Z1={id:"video",upload(r,e,t,n,s,i=Y1){if(!r.isValid){const o=s??e.target;t.texImage2D(o,0,e.internalFormat,1,1,0,e.format,e.type,null);return}md.upload(r,e,t,n,s,i)}},gd={linear:9729,nearest:9728},K1={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},wo={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},q1={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function _d(r,e,t,n,s,i,o,a){const c=i;if(!a||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const l=wo[o?"clamp-to-edge":r.addressModeU],u=wo[o?"clamp-to-edge":r.addressModeV],h=wo[o?"clamp-to-edge":r.addressModeW];e[s](c,e.TEXTURE_WRAP_S,l),e[s](c,e.TEXTURE_WRAP_T,u),e.TEXTURE_WRAP_R&&e[s](c,e.TEXTURE_WRAP_R,h)}if((!a||r.magFilter!=="linear")&&e[s](c,e.TEXTURE_MAG_FILTER,gd[r.magFilter]),t){if(!a||r.mipmapFilter!=="linear"){const l=K1[r.minFilter][r.mipmapFilter];e[s](c,e.TEXTURE_MIN_FILTER,l)}}else e[s](c,e.TEXTURE_MIN_FILTER,gd[r.minFilter]);if(n&&r.maxAnisotropy>1){const l=Math.min(r.maxAnisotropy,e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[s](c,n.TEXTURE_MAX_ANISOTROPY_EXT,l)}r.compare&&e[s](c,e.TEXTURE_COMPARE_FUNC,q1[r.compare])}function J1(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}function Q1(r,e){let t={},n=r.RGBA;return r instanceof te.get().getWebGLRenderingContext()?e.srgb&&(t={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(t={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},n=r.RGBA8),{r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA,...t,rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:n,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8,...e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function eP(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function tP(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":(r==null?void 0:r.TEXTURE_3D)||null,"2d-array":(r==null?void 0:r.TEXTURE_2D_ARRAY)||null,"cube-array":(r==null?void 0:r.TEXTURE_CUBE_MAP_ARRAY)||null}}const rP=4;class yd{constructor(e){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=e,this._managedTextures=new xt({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const t={image:md,buffer:$1,video:Z1,compressed:H1};this._uploads={...t,cube:j1(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Q1(e,this._renderer.context.extensions),this._mapFormatToType=eP(e),this._mapFormatToFormat=J1(e),this._mapViewDimensionToGlTarget=tP(e)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let t=0;t<16;t++)this.bind(D.EMPTY,t)}initSource(e){this.bind(e)}bind(e,t=0){const n=e.source;e?(this.bindSource(n,t),this._useSeparateSamplers&&this._bindSampler(n.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){const n=this._gl;if(e._gcLastUsed=this._renderer.gc.now,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||(e=D.EMPTY.source);const s=this.getGlSource(e);n.bindTexture(s.target,s.texture)}}_bindSampler(e,t=0){const n=this._gl;if(!e){this._boundSamplers[t]=null,n.bindSampler(t,null);return}const s=this._getGlSampler(e);this._boundSamplers[t]!==s&&(this._boundSamplers[t]=s,n.bindSampler(t,s))}unbind(e){const t=e.source,n=this._boundTextures,s=this._gl;for(let i=0;i<n.length;i++)if(n[i]===t){this._activateLocation(i);const o=this.getGlSource(t);s.bindTexture(o.target,null),n[i]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){const t=this._gl,n=new N1(t.createTexture());if(n.type=this._mapFormatToType[e.format],n.internalFormat=this._mapFormatToInternalFormat[e.format],n.format=this._mapFormatToFormat[e.format],n.target=this._mapViewDimensionToGlTarget[e.viewDimension],n.target===null)throw new Error(`Unsupported view dimension: ${e.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(e.uploadMethodId==="cube"&&(n.target=t.TEXTURE_CUBE_MAP),e.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||e.isPowerOfTwo)){const i=Math.max(e.width,e.height);e.mipLevelCount=Math.floor(Math.log2(i))+1}return e._gpuData[this._renderer.uid]=n,this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceUpdate,this),e.on("styleChange",this.onStyleChange,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),this.updateStyle(e,!1),n}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){const n=this._gl,s=this.getGlSource(e);n.bindTexture(s.target,s.texture),this._boundTextures[this._activeTextureLocation]=e,_d(e.style,n,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",s.target,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];n&&(t||(this.unbind(e),this._gl.deleteTexture(n.texture)),e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceUpdate,this),e.off("styleChange",this.onStyleChange,this),e.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(e){const t=this._gl,n=this.getGlSource(e);t.bindTexture(n.target,n.texture),this._boundTextures[this._activeTextureLocation]=e;const s=e.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),this._uploads[e.uploadMethodId])this._uploads[e.uploadMethodId].upload(e,n,t,this._renderer.context.webGLVersion);else if(n.target===t.TEXTURE_2D)this._initEmptyTexture2D(n,e);else if(n.target===t.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(n,e);else if(n.target===t.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(n,e);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(n,e),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);const n=this.getGlSource(e);this._gl.generateMipmap(n.target)}_initEmptyTexture2D(e,t){const n=this._gl;n.texImage2D(n.TEXTURE_2D,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let s=Math.max(t.pixelWidth>>1,1),i=Math.max(t.pixelHeight>>1,1);for(let o=1;o<t.mipLevelCount;o++)n.texImage2D(n.TEXTURE_2D,o,e.internalFormat,s,i,0,e.format,e.type,null),s=Math.max(s>>1,1),i=Math.max(i>>1,1)}_initEmptyTexture2DArray(e,t){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const n=this._gl,s=Math.max(t.arrayLayerCount|0,1);n.texImage3D(n.TEXTURE_2D_ARRAY,0,e.internalFormat,t.pixelWidth,t.pixelHeight,s,0,e.format,e.type,null);let i=Math.max(t.pixelWidth>>1,1),o=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++)n.texImage3D(n.TEXTURE_2D_ARRAY,a,e.internalFormat,i,o,s,0,e.format,e.type,null),i=Math.max(i>>1,1),o=Math.max(o>>1,1)}_initEmptyTextureCube(e,t){const n=this._gl,s=6;for(let a=0;a<s;a++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let i=Math.max(t.pixelWidth>>1,1),o=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++){for(let c=0;c<s;c++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,a,e.internalFormat,i,o,0,e.format,e.type,null);i=Math.max(i>>1,1),o=Math.max(o>>1,1)}}_applyMipRange(e,t){if(this._renderer.context.webGLVersion!==2||t.mipLevelCount<=1)return;const n=this._gl,s=Math.max((t.mipLevelCount|0)-1,0);n.texParameteri(e.target,n.TEXTURE_BASE_LEVEL,0),n.texParameteri(e.target,n.TEXTURE_MAX_LEVEL,s)}_initSampler(e){const t=this._gl,n=this._gl.createSampler();return this._glSamplers[e._resourceId]=n,_d(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",n,!1,!0),this._glSamplers[e._resourceId]}_getGlSampler(e){return this._glSamplers[e._resourceId]||this._initSampler(e)}getGlSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this._initSource(e)}generateCanvas(e){const{pixels:t,width:n,height:s}=this.getPixels(e),i=te.get().createCanvas();i.width=n,i.height=s;const o=i.getContext("2d");if(o){const a=o.createImageData(n,s);a.data.set(t),o.putImageData(a,0,0)}return i}getPixels(e){const t=e.source.resolution,n=e.frame,s=Math.max(Math.round(n.width*t),1),i=Math.max(Math.round(n.height*t),1),o=new Uint8Array(rP*s*i),a=this._renderer,c=a.renderTarget.getRenderTarget(e),l=a.renderTarget.getGpuRenderTarget(c),u=a.gl;return u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),u.readPixels(Math.round(n.x*t),Math.round(n.y*t),s,i,u.RGBA,u.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:s,height:i}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(D.EMPTY.source),this._boundSamplers=Object.create(null);const e=this._gl;this._premultiplyAlpha=!1,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}yd.extension={type:[x.WebGLSystem],name:"texture"};class bd{contextChange(e){const t=new je({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new B,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),n=e.limits.maxBatchableTextures,s=Ri({name:"graphics",bits:[ku,Iu(n),Ah,Gi]});this.shader=new bt({glProgram:s,resources:{localUniforms:t,batchSamplers:Fu(n)}})}execute(e,t){const n=t.context,s=n.customShader||this.shader,i=e.renderer,o=i.graphicsContext,{batcher:a,instructions:c}=o.getContextRenderData(n);s.groups[0]=i.globalUniforms.bindGroup,i.state.set(e.state),i.shader.bind(s),i.geometry.bind(a.geometry,s.glProgram);const l=c.instructions;for(let u=0;u<c.instructionSize;u++){const h=l[u];if(h.size){for(let d=0;d<h.textures.count;d++)i.texture.bind(h.textures.textures[d],d);i.geometry.draw(h.topology,h.size,h.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}bd.extension={type:[x.WebGLPipesAdaptor],name:"graphics"};class xd{init(){const e=Ri({name:"mesh",bits:[Ah,Dw,Gi]});this._shader=new bt({glProgram:e,resources:{uTexture:D.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new B}}}})}execute(e,t){const n=e.renderer;let s=t._shader;if(s){if(!s.glProgram){W("Mesh shader has no glProgram",t.shader);return}}else{s=this._shader;const i=t.texture,o=i.source;s.resources.uTexture=o,s.resources.uSampler=o.style,s.resources.textureUniforms.uniforms.uTextureMatrix=i.textureMatrix.mapCoord}s.groups[100]=n.globalUniforms.bindGroup,s.groups[101]=e.localUniformsBindGroup,n.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}xd.extension={type:[x.WebGLPipesAdaptor],name:"mesh"};const nP=[...yo,Rs,k1,w1,ud,sd,yd,dd,ad,Ds,Os,ld,z1,hd,cd],sP=[...Jh],iP=[Rh,xd,bd],vd=[],Td=[],Sd=[];H.handleByNamedList(x.WebGLSystem,vd),H.handleByNamedList(x.WebGLPipes,Td),H.handleByNamedList(x.WebGLPipesAdaptor,Sd),H.add(...nP,...sP,...iP);class oP extends er{constructor(){const e={name:"webgl",type:at.WEBGL,systems:vd,renderPipes:Td,renderPipeAdaptors:Sd};super(e)}}const aP=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:oP},Symbol.toStringTag,{value:"Module"}));class wd{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,n){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,n)}_createBindGroup(e,t,n){const s=this._gpu.device,i=t.layout[n],o=[],a=this._renderer;for(const u in i){const h=e.resources[u]??e.resources[i[u]];let d;if(h._resourceType==="uniformGroup"){const f=h;a.ubo.updateUniformGroup(f);const p=f.buffer;d={buffer:a.buffer.getGPUBuffer(p),offset:0,size:p.descriptor.size}}else if(h._resourceType==="buffer"){const f=h;d={buffer:a.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(h._resourceType==="bufferResource"){const f=h;d={buffer:a.buffer.getGPUBuffer(f.buffer),offset:f.offset,size:f.size}}else if(h._resourceType==="textureSampler"){const f=h;d=a.texture.getGpuSampler(f)}else if(h._resourceType==="textureSource"){const f=h;d=a.texture.getTextureView(f)}o.push({binding:i[u],resource:d})}const c=a.shader.getProgramData(t).bindGroups[n],l=s.createBindGroup({layout:c,entries:o});return this._hash[e._key]=l,l}destroy(){this._hash=null,this._renderer=null}}wd.extension={type:[x.WebGPUSystem],name:"bindGroup"};class cP{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Pd{constructor(e){this._renderer=e,this._managedBuffers=new xt({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuBuffer)||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),n=e.data;return e._updateID&&n&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,n.buffer,0,(e._updateSize||n.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=ce("resource"),e.data&&(Ci(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new cP(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}Pd.extension={type:[x.WebGPUSystem],name:"buffer"};class lP{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let n=t+e*4;if(n=Math.ceil(n/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,n>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=n,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let n=0;n<e.length;n++)this.data[t/4+n]=e[n];return t}destroy(){this.data=null}}class Ed{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}Ed.extension={type:[x.WebGPUSystem],name:"colorMask"};class Po{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await te.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),n=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:n});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}Po.extension={type:[x.WebGPUSystem],name:"device"},Po.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class Cd{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,n,s){const i=this._renderer.pipeline.getPipeline(e,t,n,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,n){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(t,n,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const n=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in n)this._setVertexBuffer(parseInt(s,10),e.attributes[n[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const n in e.groups){const s=e.groups[n];t||this._syncBindGroup(s),this.setBindGroup(n,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const n=e.resources[t];n.isUniformGroup&&this._renderer.ubo.updateUniformGroup(n)}}draw(e){const{geometry:t,shader:n,state:s,topology:i,size:o,start:a,instanceCount:c,skipSync:l}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,s,i),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,l),t.indexBuffer?this.renderPassEncoder.drawIndexed(o||t.indexBuffer.data.length,c??t.instanceCount,a||0):this.renderPassEncoder.draw(o||t.getSize(),c??t.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,n={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const o=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(o.x,o.y,o.width,o.height,0,1),this.setPipeline(t);for(const a in n)this._setVertexBuffer(a,n[a]);for(const a in i)this.setBindGroup(a,i[a],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}Cd.extension={type:[x.WebGPUSystem],name:"encoder",priority:1};class Md{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}Md.extension={type:[x.WebGPUSystem],name:"limits"};class Ad{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:be.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const n=this._renderTargetStencilState[this._activeRenderTarget.uid];n.stencilMode=e,n.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Ad.extension={type:[x.WebGPUSystem],name:"stencil"};const Mt=128;class kd{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new lP({minUniformOffsetAlignment:Mt});const t=256/Mt;for(let n=0;n<t;n++){let s=Q.UNIFORM|Q.COPY_DST;n===0&&(s|=Q.COPY_SRC),this._buffers.push(new Ue({data:this._batchBuffer.data,usage:s}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);const n=e.buffer.data,s=this._batchBuffer.addEmptyGroup(n.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,s/4),this._bindGroupHash[e.uid]=this._getBindGroup(s/Mt),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);const t=e.buffer.data,n=this._batchBuffer.addGroup(t);return this._getBufferResource(n/Mt)}getArrayBindGroup(e){const t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/Mt)}getArrayBufferResource(e){const n=this._batchBuffer.addGroup(e)/Mt;return this._getBufferResource(n)}_getBufferResource(e){if(!this._bufferResources[e]){const t=this._buffers[e%2];this._bufferResources[e]=new Tn({buffer:t,offset:(e/2|0)*256,size:Mt})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){const t=new yt({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){const e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);const n=this._renderer.gpu.device.createCommandEncoder();for(let s=1;s<this._buffers.length;s++){const i=this._buffers[s];n.copyBufferToBuffer(e.getGPUBuffer(t),Mt,e.getGPUBuffer(i),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([n.finish()])}destroy(){var e;for(let t=0;t<this._bindGroups.length;t++)(e=this._bindGroups[t])==null||e.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}}kd.extension={type:[x.WebGPUPipes],name:"uniformBatch"};const uP={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function hP(r,e,t,n,s){return r<<24|e<<16|t<<10|n<<5|s}function dP(r,e,t,n,s){return t<<8|r<<5|n<<3|s<<1|e}class Rd{constructor(e){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._renderer=e}contextChange(e){this._gpu=e,this.setStencilMode(be.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=e.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=e.colorTargetCount,this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=Ct[e],this._updatePipeHash())}setPipeline(e,t,n,s){const i=this.getPipeline(e,t,n);s.setPipeline(i)}getPipeline(e,t,n,s){e._layoutKey||(id(e,t.attributeData),this._generateBufferKey(e)),s||(s=e.topology);const i=hP(e._layoutKey,t._layoutKey,n.data,n._blendModeId,uP[s]);return this._pipeCache[i]?this._pipeCache[i]:(this._pipeCache[i]=this._createPipeline(e,t,n,s),this._pipeCache[i])}_createPipeline(e,t,n,s){const i=this._gpu.device,o=this._createVertexBufferLayouts(e,t),a=this._renderer.state.getColorTargets(n,this._colorTargetCount),c=this._stencilMode===be.RENDERING_MASK_ADD?0:this._colorMask;for(let d=0;d<a.length;d++)a[d].writeMask=c;const l=this._renderer.shader.getProgramData(t).pipeline,u={vertex:{module:this._getModule(t.vertex.source),entryPoint:t.vertex.entryPoint,buffers:o},fragment:{module:this._getModule(t.fragment.source),entryPoint:t.fragment.entryPoint,targets:a},primitive:{topology:s,cullMode:n.cullMode},layout:l,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(u.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:n.depthTest,depthCompare:n.depthTest?"less":"always"}),i.createRenderPipeline(u)}_getModule(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){const t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){const t=[];let n=0;const s=Object.keys(e.attributes).sort();for(let o=0;o<s.length;o++){const a=e.attributes[s[o]];t[n++]=a.offset,t[n++]=a.format,t[n++]=a.stride,t[n++]=a.instance}const i=t.join("|");return e._layoutKey=Mr(i,"geometry"),e._layoutKey}_generateAttributeLocationsKey(e){const t=[];let n=0;const s=Object.keys(e.attributeData).sort();for(let o=0;o<s.length;o++){const a=e.attributeData[s[o]];t[n++]=a.location}const i=t.join("|");return e._attributeLocationsKey=Mr(i,"programAttributes"),e._attributeLocationsKey}getBufferNamesToBind(e,t){const n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[n])return this._bindingNamesCache[n];const s=this._createVertexBufferLayouts(e,t),i=Object.create(null),o=t.attributeData;for(let a=0;a<s.length;a++){const l=Object.values(s[a].attributes)[0].shaderLocation;for(const u in o)if(o[u].location===l){i[a]=u;break}}return this._bindingNamesCache[n]=i,i}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);const n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[n])return this._bufferLayoutsCache[n];const s=[];return e.buffers.forEach(i=>{const o={arrayStride:0,stepMode:"vertex",attributes:[]},a=o.attributes;for(const c in t.attributeData){const l=e.attributes[c];(l.divisor??1)!==1&&W(`Attribute ${c} has an invalid divisor value of '${l.divisor}'. WebGPU only supports a divisor value of 1`),l.buffer===i&&(o.arrayStride=l.stride,o.stepMode=l.instance?"instance":"vertex",a.push({shaderLocation:t.attributeData[c].location,offset:l.offset,format:l.format}))}a.length&&s.push(o)}),this._bufferLayoutsCache[n]=s,s}_updatePipeHash(){const e=dP(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[e]||(this._pipeStateCaches[e]=Object.create(null)),this._pipeCache=this._pipeStateCaches[e]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Rd.extension={type:[x.WebGPUSystem],name:"pipeline"};class fP{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class pP{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,n,s,i){const o=this._renderer,a=this._getGpuColorTexture(e),c=o.texture.getGpuSource(t.source);return o.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:n},{texture:c,origin:i},s),t}startRenderPass(e,t=!0,n,s,i=0,o=0){var u,h;const c=this._renderTargetSystem.getGpuRenderTarget(e);if(o!==0&&((u=c.msaaTextures)!=null&&u.length))throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(i>0&&((h=c.msaaTextures)!=null&&h.length))throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const l=this.getDescriptor(e,t,n,i,o);c.descriptor=l,this._renderer.pipeline.setRenderTarget(c),this._renderer.encoder.beginRenderPass(c),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);return t.contexts[0]?t.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(e.colorTextures[0].source)}getDescriptor(e,t,n,s=0,i=0){typeof t=="boolean"&&(t=t?Le.ALL:Le.NONE);const o=this._renderTargetSystem,a=o.getGpuRenderTarget(e),c=e.colorTextures.map((h,d)=>{const f=a.contexts[d];let p,m;if(f){if(i!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");p=f.getCurrentTexture().createView()}else p=this._renderer.texture.getGpuSource(h).createView({dimension:"2d",baseMipLevel:s,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1});a.msaaTextures[d]&&(m=p,p=this._renderer.texture.getTextureView(a.msaaTextures[d]));const g=t&Le.COLOR?"clear":"load";return n??(n=o.defaultClearColor),{view:p,resolveTarget:m,clearValue:n,storeOp:"store",loadOp:g}});let l;if((e.stencil||e.depth)&&!e.depthStencilTexture&&(e.ensureDepthStencilTexture(),e.depthStencilTexture.source.sampleCount=a.msaa?4:1),e.depthStencilTexture){const h=t&Le.STENCIL?"clear":"load",d=t&Le.DEPTH?"clear":"load";l={view:this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:s,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1}),stencilStoreOp:"store",stencilLoadOp:h,depthClearValue:1,depthLoadOp:d,depthStoreOp:"store"}}return{colorAttachments:c,depthStencilAttachment:l}}clear(e,t=!0,n,s,i=0,o=0){if(!t)return;const{gpu:a,encoder:c}=this._renderer,l=a.device;if(c.commandEncoder===null){const h=l.createCommandEncoder(),d=this.getDescriptor(e,t,n,i,o),f=h.beginRenderPass(d);f.setViewport(s.x,s.y,s.width,s.height,0,1),f.end();const p=h.finish();l.queue.submit([p])}else this.startRenderPass(e,t,n,s,i,o)}initGpuRenderTarget(e){e.isRoot=!0;const t=new fP;return t.colorTargetCount=e.colorTextures.length,e.colorTextures.forEach((n,s)=>{if(n instanceof ot){const i=n.resource.getContext("webgpu"),o=n.transparent?"premultiplied":"opaque";try{i.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(a){console.error(a)}t.contexts[s]=i}if(t.msaa=n.source.antialias,n.source.antialias){const i=new ve({width:0,height:0,sampleCount:4,arrayLayerCount:n.source.arrayLayerCount});t.msaaTextures[s]=i}}),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4)),t}destroyGpuRenderTarget(e){e.contexts.forEach(t=>{t.unconfigure()}),e.msaaTextures.forEach(t=>{t.destroy()}),e.msaaTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);e.depthStencilTexture&&t.msaa&&(e.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorTextures.forEach((n,s)=>{const i=t.msaaTextures[s];i==null||i.resize(n.source.width,n.source.height,n.source._resolution)})}}class Id extends bo{constructor(e){super(e),this.adaptor=new pP,this.adaptor.init(e,this)}}Id.extension={type:[x.WebGPUSystem],name:"renderTarget"};class Bd{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){const t=this._gpu.device,n=e.gpuLayout.map(i=>t.createBindGroupLayout({entries:i})),s={bindGroupLayouts:n};return this._gpuProgramData[e._layoutKey]={bindGroups:n,pipeline:t.createPipelineLayout(s)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}Bd.extension={type:[x.WebGPUSystem],name:"shader"};const Fe={};Fe.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Fe.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Fe.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Fe.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Fe.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Fe.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Fe["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Fe["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Fe["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Fe.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},Fe.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},Fe.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class Fd{constructor(){this.defaultState=new ct,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e,t){const n=Fe[e.blendMode]||Fe.normal,s=[],i={format:"bgra8unorm",writeMask:0,blend:n};for(let o=0;o<t;o++)s[o]=i;return s}destroy(){this.gpu=null}}Fd.extension={type:[x.WebGPUSystem],name:"state"};const mP={type:"image",upload(r,e,t,n=0){const s=r.resource,i=(r.pixelWidth|0)*(r.pixelHeight|0),o=s.byteLength/i;t.device.queue.writeTexture({texture:e,origin:{x:0,y:0,z:n}},s,{offset:0,rowsPerImage:r.pixelHeight,bytesPerRow:r.pixelWidth*o},{width:r.pixelWidth,height:r.pixelHeight,depthOrArrayLayers:1})}},Gd={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},gP={blockBytes:4,blockWidth:1,blockHeight:1},_P={type:"compressed",upload(r,e,t,n=0){let s=r.pixelWidth,i=r.pixelHeight;const o=Gd[r.format]||gP;for(let a=0;a<r.resource.length;a++){const c=r.resource[a],l=Math.ceil(s/o.blockWidth)*o.blockBytes;t.device.queue.writeTexture({texture:e,mipLevel:a,origin:{x:0,y:0,z:n}},c,{offset:0,bytesPerRow:l},{width:Math.ceil(s/o.blockWidth)*o.blockWidth,height:Math.ceil(i/o.blockHeight)*o.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),i=Math.max(i>>1,1)}}},Od=["right","left","top","bottom","front","back"];function yP(r){return{type:"cube",upload(e,t,n){const s=e.faces;for(let i=0;i<Od.length;i++){const o=Od[i],a=s[o];(r[a.uploadMethodId]||r.image).upload(a,t,n,i)}}}}const Dd={type:"image",upload(r,e,t,n=0){const s=r.resource;if(!s)return;if(globalThis.HTMLImageElement&&s instanceof HTMLImageElement){const c=te.get().createCanvas(s.width,s.height);c.getContext("2d").drawImage(s,0,0,s.width,s.height),r.resource=c,W("ImageSource: Image element passed, converting to canvas and replacing resource.")}const i=Math.min(e.width,r.resourceWidth||r.pixelWidth),o=Math.min(e.height,r.resourceHeight||r.pixelHeight),a=r.alphaMode==="premultiply-alpha-on-upload";t.device.queue.copyExternalImageToTexture({source:s},{texture:e,origin:{x:0,y:0,z:n},premultipliedAlpha:a},{width:i,height:o})}},bP={type:"video",upload(r,e,t,n){Dd.upload(r,e,t,n)}};class xP{constructor(e){this.device=e,this.sampler=e.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(e){let t=this.pipelines[e];return t||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:`
949
+ var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
950
+ vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
951
+
952
+ struct VertexOutput {
953
+ @builtin(position) position : vec4<f32>,
954
+ @location(0) texCoord : vec2<f32>,
955
+ };
956
+
957
+ @vertex
958
+ fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
959
+ var output : VertexOutput;
960
+ output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
961
+ output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
962
+ return output;
963
+ }
964
+
965
+ @group(0) @binding(0) var imgSampler : sampler;
966
+ @group(0) @binding(1) var img : texture_2d<f32>;
967
+
968
+ @fragment
969
+ fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
970
+ return textureSample(img, imgSampler, texCoord);
971
+ }
972
+ `})),t=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){const t=this._getMipmapPipeline(e.format);if(e.dimension==="3d"||e.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let n=e;const s=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){const c={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:s},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};n=this.device.createTexture(c)}const o=this.device.createCommandEncoder({}),a=t.getBindGroupLayout(0);for(let c=0;c<s;++c){let l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:c,arrayLayerCount:1}),u=i?1:0;for(let h=1;h<e.mipLevelCount;++h){const d=n.createView({baseMipLevel:u++,mipLevelCount:1,dimension:"2d",baseArrayLayer:c,arrayLayerCount:1}),f=o.beginRenderPass({colorAttachments:[{view:d,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),p=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:l}]});f.setPipeline(t),f.setBindGroup(0,p),f.draw(3,1,0,0),f.end(),l=d}}if(!i){const c={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:s};for(let l=1;l<e.mipLevelCount;++l)o.copyTextureToTexture({texture:n,mipLevel:l-1},{texture:e,mipLevel:l},c),c.width=Math.ceil(c.width/2),c.height=Math.ceil(c.height/2)}return this.device.queue.submit([o.finish()]),i||n.destroy(),e}}class vP{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class Ud{constructor(e){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=e,e.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new xt({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const t={image:Dd,buffer:mP,video:bP,compressed:_P};this._uploads={...t,cube:yP(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gpu=e}initSource(e){var t;return((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuTexture)||this._initSource(e)}_initSource(e){if(e.autoGenerateMipmaps){const l=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(l))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;e.uploadMethodId!=="compressed"&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);const n=Gd[e.format]||{blockWidth:1,blockHeight:1},s=Math.ceil(e.pixelWidth/n.blockWidth)*n.blockWidth,i=Math.ceil(e.pixelHeight/n.blockHeight)*n.blockHeight,o={label:e.label,size:{width:s,height:i,depthOrArrayLayers:e.arrayLayerCount},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},a=this._gpu.device.createTexture(o);return e._gpuData[this._renderer.uid]=new vP(a),this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceResize,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),a}onSourceUpdate(e){const t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onUpdateMipmaps(e){this._mipmapGenerator||(this._mipmapGenerator=new xP(this._gpu.device));const t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceUnload(e){e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceResize,this),e.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(e){e._gcLastUsed=this._renderer.gc.now;const t=e._gpuData[this._renderer.uid],n=t==null?void 0:t.gpuTexture;n?(n.width!==e.pixelWidth||n.height!==e.pixelHeight)&&(t.destroy(),this._bindGroupHash[e.uid]=null,e._gpuData[this._renderer.uid]=null,this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuTexture)||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){const t=e.source;return this._bindGroupHash[e.uid]=new yt({0:t,1:t.style,2:new je({uTextureMatrix:{type:"mat3x3<f32>",value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){const t=e.source;t._gcLastUsed=this._renderer.gc.now;let n=t._gpuData[this._renderer.uid];return n||(this.initSource(t),n=t._gpuData[this._renderer.uid]),n.textureView||(n.textureView=n.gpuTexture.createView({dimension:t.viewDimension})),n.textureView}generateCanvas(e){const t=this._renderer,n=t.gpu.device.createCommandEncoder(),s=te.get().createCanvas();s.width=e.source.pixelWidth,s.height=e.source.pixelHeight;const i=s.getContext("webgpu");return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:te.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),n.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:s.width,height:s.height}),t.gpu.device.queue.submit([n.finish()]),s}getPixels(e){const t=this.generateCanvas(e),n=Yn.getOptimalCanvasAndContext(t.width,t.height),s=n.context;s.drawImage(t,0,0);const{width:i,height:o}=t,a=s.getImageData(0,0,i,o),c=new Uint8ClampedArray(a.data.buffer);return Yn.returnCanvasAndContext(n),{pixels:c,width:i,height:o}}destroy(){this._managedTextures.destroy();for(const e of Object.keys(this._bindGroupHash)){const t=Number(e),n=this._bindGroupHash[t];n==null||n.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}Ud.extension={type:[x.WebGPUSystem],name:"texture"};class Ld{constructor(){this._maxTextures=0}contextChange(e){const t=new je({uTransformMatrix:{value:new B,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=e.limits.maxBatchableTextures;const n=ki({name:"graphics",bits:[Au,Ru(this._maxTextures),Bw,Fi]});this.shader=new bt({gpuProgram:n,resources:{localUniforms:t}})}execute(e,t){const n=t.context,s=n.customShader||this.shader,i=e.renderer,o=i.graphicsContext,{batcher:a,instructions:c}=o.getContextRenderData(n),l=i.encoder;l.setGeometry(a.geometry,s.gpuProgram);const u=i.globalUniforms.bindGroup;l.setBindGroup(0,u,s.gpuProgram);const h=i.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);l.setBindGroup(2,h,s.gpuProgram);const d=c.instructions;let f=null;for(let p=0;p<c.instructionSize;p++){const m=d[p];if(m.topology!==f&&(f=m.topology,l.setPipelineFromGeometryProgramAndState(a.geometry,s.gpuProgram,e.state,m.topology)),s.groups[1]=m.bindGroup,!m.gpuBindGroup){const g=m.textures;m.bindGroup=Ei(g.textures,g.count,this._maxTextures),m.gpuBindGroup=i.bindGroup.getBindGroup(m.bindGroup,s.gpuProgram,1)}l.setBindGroup(1,m.bindGroup,s.gpuProgram),l.renderPassEncoder.drawIndexed(m.size,1,m.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}Ld.extension={type:[x.WebGPUPipesAdaptor],name:"graphics"};class zd{init(){const e=ki({name:"mesh",bits:[Kn,Ow,Fi]});this._shader=new bt({gpuProgram:e,resources:{uTexture:D.EMPTY._source,uSampler:D.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new B}}}})}execute(e,t){const n=e.renderer;let s=t._shader;if(!s)s=this._shader,s.groups[2]=n.texture.getTextureBindGroup(t.texture);else if(!s.gpuProgram){W("Mesh shader has no gpuProgram",t.shader);return}const i=s.gpuProgram;if(i.autoAssignGlobalUniforms&&(s.groups[0]=n.globalUniforms.bindGroup),i.autoAssignLocalUniforms){const o=e.localUniforms;s.groups[1]=n.renderPipes.uniformBatch.getUniformBindGroup(o,!0)}n.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}zd.extension={type:[x.WebGPUPipesAdaptor],name:"mesh"};const TP=[...yo,Us,Cd,Po,Md,Pd,Ud,Id,Bd,Fd,Rd,Ed,Ad,wd],SP=[...Jh,kd],wP=[Ih,zd,Ld],Nd=[],$d=[],Vd=[];H.handleByNamedList(x.WebGPUSystem,Nd),H.handleByNamedList(x.WebGPUPipes,$d),H.handleByNamedList(x.WebGPUPipesAdaptor,Vd),H.add(...TP,...SP,...wP);class PP extends er{constructor(){const e={name:"webgpu",type:at.WEBGPU,systems:Nd,renderPipes:$d,renderPipeAdaptors:Vd};super(e)}}const EP=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:PP},Symbol.toStringTag,{value:"Module"}));class CP extends Iw{constructor(e){const{texture:t,vertices:n,uvs:s,indices:i,topology:o,...a}=e,c=new Eh(wn({positions:n,uvs:s,indices:i,topology:o}));super(wn({...a,texture:t,geometry:c})),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(e){this.geometry.getBuffer("aPosition").data=e}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}H.add(z0,N0);const MP={normal:"normal",add:"add",multiply:"multiply",screen:"screen",overlay:"overlay",darken:"darken",lighten:"lighten","color-dodge":"color-dodge","color dodge":"color-dodge","color-burn":"color-burn","color burn":"color-burn","hard-light":"hard-light","hard light":"hard-light","soft-light":"soft-light","soft light":"soft-light",difference:"difference",exclusion:"exclusion"};function AP(r){return MP[r]??"normal"}const kP=`
973
+ in vec2 aPosition;
974
+ in vec2 aTextureCoord;
975
+ out vec2 vTextureCoord;
976
+
977
+ uniform vec4 uInputSize;
978
+ uniform vec4 uOutputFrame;
979
+ uniform vec4 uOutputTexture;
980
+
981
+ vec4 filterVertexPosition(void) {
982
+ vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
983
+ position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
984
+ position.y = position.y * (2.0 * uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
985
+ return vec4(position, 0.0, 1.0);
986
+ }
987
+
988
+ vec2 filterTextureCoord(void) {
989
+ return aTextureCoord;
990
+ }
991
+
992
+ void main(void) {
993
+ gl_Position = filterVertexPosition();
994
+ vTextureCoord = filterTextureCoord();
995
+ }
996
+ `,RP=`
997
+ in vec2 vTextureCoord;
998
+ out vec4 finalColor;
999
+
1000
+ uniform sampler2D uTexture;
1001
+ uniform vec3 uScreenColor;
1002
+
1003
+ void main(void) {
1004
+ vec4 color = texture(uTexture, vTextureCoord);
1005
+ color.rgb = color.rgb + uScreenColor * color.a * (1.0 - color.rgb);
1006
+ finalColor = color;
1007
+ }
1008
+ `,Hd="screenColorUniforms",jd="uScreenColor";function IP(r){return new vi({glProgram:Ot.from({vertex:kP,fragment:RP,name:"screen-color-filter"}),resources:{[Hd]:{[jd]:{value:new Float32Array([r.r,r.g,r.b]),type:"vec3<f32>"}}}})}function BP(r,e){var s,i;const t=(i=(s=r.resources)==null?void 0:s[Hd])==null?void 0:i.uniforms,n=t==null?void 0:t[jd];n&&(n[0]=e.r,n[1]=e.g,n[2]=e.b)}class Eo{constructor(e){$(this,"app");$(this,"world");$(this,"meshes",new Map);$(this,"textures",new Map);$(this,"screenFilters",new Map);$(this,"model",null);$(this,"initialized",!1);this.app=e,this.world=new Ie,this.world.sortableChildren=!0,this.app.stage.addChild(this.world)}static async create(e,t){const n=new pu;await n.init({canvas:e,backgroundAlpha:t!=null&&t.transparent?0:1,backgroundColor:(t==null?void 0:t.backgroundColor)??16777215,antialias:(t==null?void 0:t.antialias)??!0,autoDensity:!0,resolution:window.devicePixelRatio||1,width:e.width,height:e.height});const s=new Eo(n);return s.initialized=!0,s}setModel(e,t){this.destroyMeshes(),this.model=e,this.destroyTextures();for(const[n,s]of t)this.textures.set(n,D.from(s));this.buildMeshes()}render(){!this.model||!this.initialized||(this.syncMeshes(),this.app.render())}resize(e,t){this.app.renderer.resize(e,t)}destroy(){this.destroyMeshes(),this.destroyTextures(),this.model=null,this.app.stage.removeChild(this.world),this.initialized=!1}screenToWorld(e,t){const n=this.world.toLocal({x:e,y:t});return{x:n.x,y:n.y}}get pixiApp(){return this.app}buildMeshes(){if(this.model)for(const e of GP(this.model)){const t=this.textures.get(e.id)??this.textures.get(e.textureId);if(!t)continue;const n=new CP({texture:t,vertices:e.vertices,uvs:e.uvs,indices:e.indices});n.label=e.id,this.applyMeshState(n,e),this.world.addChild(n),this.meshes.set(e.id,n)}}syncMeshes(){if(this.model)for(const[e,t]of this.meshes){const n=OP(this.model,e);if(!n){t.visible=!1;continue}this.applyMeshState(t,n),t.vertices=n.vertices}}applyMeshState(e,t){if(e.x=t.x,e.y=t.y,e.alpha=t.opacity,e.visible=t.visible,e.blendMode=AP(t.blendMode),e.tint=FP(t.multiplyColor),e.zIndex=t.drawOrder,t.screenColor){const n=this.screenFilters.get(t.id);if(n)BP(n,Wd(t.screenColor));else{const s=IP(Wd(t.screenColor));e.filters=[s],this.screenFilters.set(t.id,s)}}else{const n=this.screenFilters.get(t.id);n&&(e.filters=[],n.destroy(),this.screenFilters.delete(t.id))}}destroyMeshes(){for(const e of this.meshes.values())e.destroy({children:!0});this.meshes.clear();for(const e of this.screenFilters.values())e.destroy();this.screenFilters.clear()}destroyTextures(){for(const e of this.textures.values())e.destroy(!1);this.textures.clear()}}function FP(r){const e=Math.round(Math.max(0,Math.min(1,(r==null?void 0:r[0])??1))*255),t=Math.round(Math.max(0,Math.min(1,(r==null?void 0:r[1])??1))*255),n=Math.round(Math.max(0,Math.min(1,(r==null?void 0:r[2])??1))*255);return e<<16|t<<8|n}function Wd(r){return{r:r[0],g:r[1],b:r[2]}}function GP(r){return"getRenderList"in r?r.getRenderList():[...r.getAllMeshStates().values()].map(Xd)}function OP(r,e){if("getMeshSnapshot"in r)return r.getMeshSnapshot(e);const t=r.getMeshState(e);return t?Xd(t):null}function Xd(r){return{id:r.id,textureId:r.textureId??r.id,vertices:r.vertices,uvs:r.uvs,indices:r.indices,x:r.x,y:r.y,opacity:r.opacity,visible:r.visible,culled:r.culled,blendMode:DP(r.blendMode),multiplyColor:[r.multiplyColor.r,r.multiplyColor.g,r.multiplyColor.b,1],screenColor:r.screenColor?[r.screenColor.r,r.screenColor.g,r.screenColor.b,1]:null,drawOrder:r.drawOrder}}function DP(r){return r==="multiply"||r==="screen"||r==="add"?r:"normal"}const UP={width:256,height:256,format:"png",quality:.85};function LP(r,e){const t={...UP,...e},n=document.createElement("canvas");n.width=t.width,n.height=t.height;const s=n.getContext("2d");if(!s)return"";const i=r.width,o=r.height,a=Math.min(t.width/i,t.height/o),c=i*a,l=o*a,u=(t.width-c)/2,h=(t.height-l)/2;s.clearRect(0,0,t.width,t.height),s.drawImage(r,u,h,c,l);const d=`image/${t.format}`;return n.toDataURL(d,t.quality)}const zP=`
1009
+ :host {
1010
+ display: inline-block;
1011
+ overflow: hidden;
1012
+ }
1013
+ canvas {
1014
+ display: block;
1015
+ width: 100%;
1016
+ height: 100%;
1017
+ object-fit: contain;
1018
+ }
1019
+ `;async function NP(r,e){var a;const t=r.headers.get("content-length");if(t){const c=Number(t);Number.isFinite(c)&&c>0&&At(c,134217728,e)}const n=(a=r.body)==null?void 0:a.getReader();if(!n){const c=await r.text();return ss(c,134217728,e),c}const s=new TextDecoder;let i=0,o="";for(;;){const{done:c,value:l}=await n.read();if(c)break;i+=l.byteLength,At(i,134217728,e),o+=s.decode(l,{stream:!0})}return o+=s.decode(),ss(o,134217728,e),o}class ts extends HTMLElement{constructor(){super();$(this,"shadow");$(this,"canvas");$(this,"renderer",null);$(this,"_model",null);$(this,"animFrameId",0);$(this,"lastTime",0);$(this,"_loading",!1);$(this,"loadAbort",null);$(this,"scriptState",{running:!1,cancelled:!1});this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=zP,this.shadow.appendChild(t),this.canvas=document.createElement("canvas"),this.shadow.appendChild(this.canvas)}connectedCallback(){const t=this.getAttribute("src");t&&this.load(t)}disconnectedCallback(){this.dispose()}attributeChangedCallback(t,n,s){t==="src"&&s&&s!==n&&this.load(s),t==="width"&&s&&this.canvas&&(this.style.width=`${s}px`),t==="height"&&s&&this.canvas&&(this.style.height=`${s}px`)}get model(){return this._model}get project(){var t;return((t=this._model)==null?void 0:t.project)??null}get loading(){return this._loading}async load(t){var s;(s=this.loadAbort)==null||s.abort();const n=new AbortController;this.loadAbort=n,this.dispose(),this._loading=!0,this.dispatchEvent(new CustomEvent("vivi-load-start"));try{const i=await fetch(t,{credentials:"omit",mode:"cors",signal:n.signal});if(!i.ok)throw new Error(`HTTP ${i.status}: ${t}`);const o=await NP(i,"Remote .vivi model"),a=ac(o,{profile:"publicProfileV1"}),c=bn.fromFileData(a),l=await Xx(a);this.canvas.width=c.width,this.canvas.height=c.height;const u=await Eo.create(this.canvas,{backgroundColor:0,transparent:!0});u.setModel(c,l),this.renderer=u,this._model=c,this._loading=!1,c.update(),u.render(),this.startLoop(),this.dispatchEvent(new CustomEvent("load",{detail:{model:c}})),this.dispatchEvent(new CustomEvent("vivi-load",{detail:{model:c}}))}catch(i){this._loading=!1;const o=i instanceof Error?i.message:String(i);this.dispatchEvent(new CustomEvent("error",{detail:{message:o}})),this.dispatchEvent(new CustomEvent("vivi-error",{detail:{message:o}}))}}setParameter(t,n){var s;(s=this._model)==null||s.setParameter(t,n)}setParameters(t){var n;(n=this._model)==null||n.setParameters(t)}resetParameters(){var t;(t=this._model)==null||t.resetParameters()}applyExpressionPreset(t){var n;(n=this._model)==null||n.applyExpressionPreset(t)}applyPresetByHotkey(t){var s,i,o;const n=(i=(s=this._model)==null?void 0:s.project.expressionPresets)==null?void 0:i.find(a=>a.hotkey===t);n&&((o=this._model)==null||o.applyExpressionPreset(n.id))}getExpressionPresets(){var t,n;return((n=(t=this._model)==null?void 0:t.project.expressionPresets)==null?void 0:n.map(s=>({id:s.id,name:s.name,hotkey:s.hotkey})))??[]}getParameters(){var t;return((t=this._model)==null?void 0:t.project.parameters.map(n=>({id:n.id,name:n.name,min:n.minValue,max:n.maxValue,default:n.defaultValue})))??[]}screenToWorld(t,n){var s;return((s=this.renderer)==null?void 0:s.screenToWorld(t,n))??null}hitTest(t,n){var s;return((s=this._model)==null?void 0:s.hitTest(t,n))??null}async runScript(t){if(!this._model)throw new Error("Model is not loaded");this.cancelScript();const n=this._model,s={setParameter:(o,a)=>n.setParameter(o,a),setParameters:o=>n.setParameters(o),resetParameters:()=>n.resetParameters(),applyExpressionPreset:o=>n.applyExpressionPreset(o),getPresetByName:o=>{var c;const a=(c=n.project.expressionPresets)==null?void 0:c.find(l=>l.name===o);return(a==null?void 0:a.id)??null},getParameterId:o=>{const a=n.project.parameters.find(c=>c.id===o||c.name===o);return(a==null?void 0:a.id)??null},update:()=>n.update()},i=Lx(t);this.scriptState={running:!0,cancelled:!1},await zx(i,s,this.scriptState)}cancelScript(){this.scriptState.running&&Nx(this.scriptState)}get scriptRunning(){return this.scriptState.running}generateThumbnail(t){return LP(this.canvas,t)}startLoop(){this.lastTime=0;const t=n=>{var i,o;const s=this.lastTime>0?(n-this.lastTime)/1e3:0;this.lastTime=n,(i=this._model)==null||i.update(s),(o=this.renderer)==null||o.render(),this.animFrameId=requestAnimationFrame(t)};this.animFrameId=requestAnimationFrame(t)}dispose(){var t;this.animFrameId&&(cancelAnimationFrame(this.animFrameId),this.animFrameId=0),(t=this.renderer)==null||t.destroy(),this.renderer=null,this._model=null,this.lastTime=0,this.dispatchEvent(new CustomEvent("vivi-dispose"))}}$(ts,"observedAttributes",["src","width","height","autoplay"]);function $P(r="vivi-model"){return typeof customElements>"u"||customElements.get(r)||customElements.define(r,ts),ts}$P(),H.add(uT),H.mixin(Ie,hT),H.add(uh),H.add(hh),H.mixin(Ie,pw),H.add(vh,yh),H.add(xh);const VP=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),HP=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))}));
1020
+ //# sourceMappingURL=vivi2d.umd.js.map