@linxin666/dsh-pet 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +66 -3
- package/README.zh.md +66 -3
- package/assets/whale/pet.json +169 -20
- package/assets/whale-refined/pet.json +17 -2
- package/lib/client.js +438 -21
- package/lib/client.js.map +1 -1
- package/lib/index.js +752 -36
- package/lib/live2d-vendor.js +995 -0
- package/lib/live2d-vendor.js.map +1 -0
- package/lib/types/client/PetDockEntry.d.ts.map +1 -1
- package/lib/types/client/PetDockEntry.js +2 -1
- package/lib/types/client/PetSettingsCard.d.ts +10 -0
- package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PetSettingsCard.js +22 -1
- package/lib/types/client/PetSprite.d.ts +7 -1
- package/lib/types/client/PetSprite.d.ts.map +1 -1
- package/lib/types/client/PetSprite.js +17 -8
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +5 -0
- package/lib/types/client/locales.d.ts +10 -0
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js +10 -0
- package/lib/types/client/phase-stream.d.ts +22 -0
- package/lib/types/client/phase-stream.d.ts.map +1 -0
- package/lib/types/client/phase-stream.js +28 -0
- package/lib/types/client/renderers/PetRendererSwitch.d.ts +25 -0
- package/lib/types/client/renderers/PetRendererSwitch.d.ts.map +1 -0
- package/lib/types/client/renderers/PetRendererSwitch.js +24 -0
- package/lib/types/client/renderers/live2d/Live2dVisualMount.d.ts +22 -0
- package/lib/types/client/renderers/live2d/Live2dVisualMount.d.ts.map +1 -0
- package/lib/types/client/renderers/live2d/Live2dVisualMount.js +75 -0
- package/lib/types/client/renderers/live2d/runtime.d.ts +89 -0
- package/lib/types/client/renderers/live2d/runtime.d.ts.map +1 -0
- package/lib/types/client/renderers/live2d/runtime.js +63 -0
- package/lib/types/client/renderers/live2d/vendor-entry.d.ts +15 -0
- package/lib/types/client/renderers/live2d/vendor-entry.d.ts.map +1 -0
- package/lib/types/client/renderers/live2d/vendor-entry.js +14 -0
- package/lib/types/client/renderers/live2d.d.ts +52 -0
- package/lib/types/client/renderers/live2d.d.ts.map +1 -0
- package/lib/types/client/renderers/live2d.js +180 -0
- package/lib/types/client/renderers/registry.d.ts +32 -0
- package/lib/types/client/renderers/registry.d.ts.map +1 -0
- package/lib/types/client/renderers/registry.js +49 -0
- package/lib/types/contracts/renderer.d.ts +50 -0
- package/lib/types/contracts/renderer.d.ts.map +1 -0
- package/lib/types/contracts/renderer.js +15 -0
- package/lib/types/manifest-v2.d.ts +129 -0
- package/lib/types/manifest-v2.d.ts.map +1 -0
- package/lib/types/manifest-v2.js +387 -0
- package/lib/types/model3.d.ts +26 -0
- package/lib/types/model3.d.ts.map +1 -0
- package/lib/types/model3.js +96 -0
- package/lib/types/registry.d.ts +57 -3
- package/lib/types/registry.d.ts.map +1 -1
- package/lib/types/registry.js +208 -33
- package/lib/types/routes.d.ts +39 -2
- package/lib/types/routes.d.ts.map +1 -1
- package/lib/types/routes.js +183 -12
- package/lib/types/service.d.ts +5 -1
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +4 -0
- package/package.json +3 -1
- package/src/client/PetDockEntry.tsx +19 -11
- package/src/client/PetSettingsCard.tsx +39 -0
- package/src/client/PetSprite.test.tsx +11 -0
- package/src/client/PetSprite.tsx +24 -9
- package/src/client/index.ts +6 -0
- package/src/client/locales.ts +10 -0
- package/src/client/phase-stream.test.ts +76 -0
- package/src/client/phase-stream.ts +39 -0
- package/src/client/renderers/PetRendererSwitch.test.tsx +66 -0
- package/src/client/renderers/PetRendererSwitch.tsx +48 -0
- package/src/client/renderers/live2d/Live2dVisualMount.tsx +98 -0
- package/src/client/renderers/live2d/runtime.test.ts +61 -0
- package/src/client/renderers/live2d/runtime.ts +119 -0
- package/src/client/renderers/live2d/vendor-entry.ts +14 -0
- package/src/client/renderers/live2d.test.ts +242 -0
- package/src/client/renderers/live2d.ts +218 -0
- package/src/client/renderers/registry.ts +58 -0
- package/src/client/settings-section.module.css +23 -0
- package/src/contracts/renderer.ts +54 -0
- package/src/manifest-v2.test.ts +251 -0
- package/src/manifest-v2.ts +414 -0
- package/src/model3.test.ts +79 -0
- package/src/model3.ts +91 -0
- package/src/registry.test.ts +215 -2
- package/src/registry.ts +246 -34
- package/src/routes.ts +202 -13
- package/src/service.ts +6 -0
|
@@ -0,0 +1,995 @@
|
|
|
1
|
+
var __dshPetLive2d=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},c=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),f,p,m,h,g=s((()=>{f=(e=>(e.Application=`application`,e.WebGLPipes=`webgl-pipes`,e.WebGLPipesAdaptor=`webgl-pipes-adaptor`,e.WebGLSystem=`webgl-system`,e.WebGPUPipes=`webgpu-pipes`,e.WebGPUPipesAdaptor=`webgpu-pipes-adaptor`,e.WebGPUSystem=`webgpu-system`,e.CanvasSystem=`canvas-system`,e.CanvasPipesAdaptor=`canvas-pipes-adaptor`,e.CanvasPipes=`canvas-pipes`,e.Asset=`asset`,e.LoadParser=`load-parser`,e.ResolveParser=`resolve-parser`,e.CacheParser=`cache-parser`,e.DetectionParser=`detection-parser`,e.MaskEffect=`mask-effect`,e.BlendMode=`blend-mode`,e.TextureSource=`texture-source`,e.TextureUploaderWebGL=`texture-uploader-webgl`,e.TextureUploaderWebGPU=`texture-uploader-webgpu`,e.Environment=`environment`,e.ShapeBuilder=`shape-builder`,e.Batcher=`batcher`,e))(f||{}),p=e=>{if(typeof e==`function`||typeof e==`object`&&e.extension){if(!e.extension)throw Error(`Extension class must have an extension object`);e={...typeof e.extension==`object`?e.extension:{type:e.extension},ref:e}}if(typeof e==`object`)e={...e};else throw Error(`Invalid extension type`);return typeof e.type==`string`&&(e.type=[e.type]),e},m=(e,t)=>p(e).priority??t,h={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(p).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...e){return e.map(p).forEach(e=>{e.type.forEach(t=>{let n=this._addHandlers,r=this._queue;n[t]?n[t]?.(e):(r[t]=r[t]||[],r[t]?.push(e))})}),this},handle(e,t,n){let r=this._addHandlers,i=this._removeHandlers;if(r[e]||i[e])throw Error(`Extension type ${e} already has a handler`);r[e]=t,i[e]=n;let a=this._queue;return a[e]&&(a[e]?.forEach(e=>t(e)),delete a[e]),this},handleByMap(e,t){return this.handle(e,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,e=>{t.findIndex(t=>t.name===e.name)>=0||(t.push({name:e.name,value:e.ref}),t.sort((e,t)=>m(t.value,n)-m(e.value,n)))},e=>{let n=t.findIndex(t=>t.name===e.name);n!==-1&&t.splice(n,1)})},handleByList(e,t,n=-1){return this.handle(e,e=>{t.includes(e.ref)||(t.push(e.ref),t.sort((e,t)=>m(t,n)-m(e,n)))},e=>{let n=t.indexOf(e.ref);n!==-1&&t.splice(n,1)})},mixin(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}}})),_=c(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),v,y,b=s((()=>{v=d(_(),1),y=v.default})),x,S,C,w,ee,T,E,te,ne,re,ie,D,O,ae,oe,se,ce,le,k,ue,de,fe,pe,me,he,ge,_e,ve,ye,be=s((()=>{x={grad:.9,turn:360,rad:360/(2*Math.PI)},S=function(e){return typeof e==`string`?e.length>0:typeof e==`number`},C=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n+0},w=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},ee=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},T=function(e){return{r:w(e.r,0,255),g:w(e.g,0,255),b:w(e.b,0,255),a:w(e.a)}},E=function(e){return{r:C(e.r),g:C(e.g),b:C(e.b),a:C(e.a,3)}},te=/^#([0-9a-f]{3,8})$/i,ne=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},re=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:60*(s<0?s+6:s),s:a?o/a*100:0,v:a/255*100,a:i}},ie=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:255*[r,s,o,o,c,r][l],g:255*[c,r,r,s,o,o][l],b:255*[o,o,c,r,r,s][l],a:i}},D=function(e){return{h:ee(e.h),s:w(e.s,0,100),l:w(e.l,0,100),a:w(e.a)}},O=function(e){return{h:C(e.h),s:C(e.s),l:C(e.l),a:C(e.a,3)}},ae=function(e){return ie((n=(t=e).s,{h:t.h,s:(n*=((r=t.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:t.a}));var t,n,r},oe=function(e){return{h:(t=re(e)).h,s:(i=(200-(n=t.s))*(r=t.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:t.a};var t,n,r,i},se=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ce=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,le=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,k=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ue={string:[[function(e){var t=te.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?C(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?C(parseInt(e.substr(6,2),16)/255,2):1}:null:null},`hex`],[function(e){var t=le.exec(e)||k.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:T({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},`rgb`],[function(e){var t=se.exec(e)||ce.exec(e);if(!t)return null;var n,r;return ae(D({h:(n=t[1],r=t[2],r===void 0&&(r=`deg`),Number(n)*(x[r]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)}))},`hsl`]],object:[[function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i===void 0?1:i;return S(t)&&S(n)&&S(r)?T({r:Number(t),g:Number(n),b:Number(r),a:Number(a)}):null},`rgb`],[function(e){var t=e.h,n=e.s,r=e.l,i=e.a,a=i===void 0?1:i;return!S(t)||!S(n)||!S(r)?null:ae(D({h:Number(t),s:Number(n),l:Number(r),a:Number(a)}))},`hsl`],[function(e){var t=e.h,n=e.s,r=e.v,i=e.a,a=i===void 0?1:i;return!S(t)||!S(n)||!S(r)?null:ie(function(e){return{h:ee(e.h),s:w(e.s,0,100),v:w(e.v,0,100),a:w(e.a)}}({h:Number(t),s:Number(n),v:Number(r),a:Number(a)}))},`hsv`]]},de=function(e,t){for(var n=0;n<t.length;n++){var r=t[n][0](e);if(r)return[r,t[n][1]]}return[null,void 0]},fe=function(e){return typeof e==`string`?de(e.trim(),ue.string):typeof e==`object`&&e?de(e,ue.object):[null,void 0]},pe=function(e,t){var n=oe(e);return{h:n.h,s:w(n.s+100*t,0,100),l:n.l,a:n.a}},me=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},he=function(e,t){var n=oe(e);return{h:n.h,s:n.s,l:w(n.l+100*t,0,100),a:n.a}},ge=function(){function e(e){this.parsed=fe(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return C(me(this.rgba),2)},e.prototype.isDark=function(){return me(this.rgba)<.5},e.prototype.isLight=function(){return me(this.rgba)>=.5},e.prototype.toHex=function(){return e=E(this.rgba),t=e.r,n=e.g,r=e.b,a=(i=e.a)<1?ne(C(255*i)):``,`#`+ne(t)+ne(n)+ne(r)+a;var e,t,n,r,i,a},e.prototype.toRgb=function(){return E(this.rgba)},e.prototype.toRgbString=function(){return e=E(this.rgba),t=e.r,n=e.g,r=e.b,(i=e.a)<1?`rgba(`+t+`, `+n+`, `+r+`, `+i+`)`:`rgb(`+t+`, `+n+`, `+r+`)`;var e,t,n,r,i},e.prototype.toHsl=function(){return O(oe(this.rgba))},e.prototype.toHslString=function(){return e=O(oe(this.rgba)),t=e.h,n=e.s,r=e.l,(i=e.a)<1?`hsla(`+t+`, `+n+`%, `+r+`%, `+i+`)`:`hsl(`+t+`, `+n+`%, `+r+`%)`;var e,t,n,r,i},e.prototype.toHsv=function(){return e=re(this.rgba),{h:C(e.h),s:C(e.s),v:C(e.v),a:C(e.a,3)};var e},e.prototype.invert=function(){return _e({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return e===void 0&&(e=.1),_e(pe(this.rgba,e))},e.prototype.desaturate=function(e){return e===void 0&&(e=.1),_e(pe(this.rgba,-e))},e.prototype.grayscale=function(){return _e(pe(this.rgba,-1))},e.prototype.lighten=function(e){return e===void 0&&(e=.1),_e(he(this.rgba,e))},e.prototype.darken=function(e){return e===void 0&&(e=.1),_e(he(this.rgba,-e))},e.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return typeof e==`number`?_e({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):C(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=oe(this.rgba);return typeof e==`number`?_e({h:e,s:t.s,l:t.l,a:t.a}):C(t.h)},e.prototype.isEqual=function(e){return this.toHex()===_e(e).toHex()},e}(),_e=function(e){return e instanceof ge?e:new ge(e)},ve=[],ye=function(e){e.forEach(function(e){ve.indexOf(e)<0&&(e(ge,ue),ve.push(e))})}}));function xe(e,t){var n={white:`#ffffff`,bisque:`#ffe4c4`,blue:`#0000ff`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,antiquewhite:`#faebd7`,aqua:`#00ffff`,azure:`#f0ffff`,whitesmoke:`#f5f5f5`,papayawhip:`#ffefd5`,plum:`#dda0dd`,blanchedalmond:`#ffebcd`,black:`#000000`,gold:`#ffd700`,goldenrod:`#daa520`,gainsboro:`#dcdcdc`,cornsilk:`#fff8dc`,cornflowerblue:`#6495ed`,burlywood:`#deb887`,aquamarine:`#7fffd4`,beige:`#f5f5dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkkhaki:`#bdb76b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,peachpuff:`#ffdab9`,darkmagenta:`#8b008b`,darkred:`#8b0000`,darkorchid:`#9932cc`,darkorange:`#ff8c00`,darkslateblue:`#483d8b`,gray:`#808080`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,wheat:`#f5deb3`,firebrick:`#b22222`,floralwhite:`#fffaf0`,ghostwhite:`#f8f8ff`,darkviolet:`#9400d3`,magenta:`#ff00ff`,green:`#008000`,dodgerblue:`#1e90ff`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,blueviolet:`#8a2be2`,forestgreen:`#228b22`,lawngreen:`#7cfc00`,indianred:`#cd5c5c`,indigo:`#4b0082`,fuchsia:`#ff00ff`,brown:`#a52a2a`,maroon:`#800000`,mediumblue:`#0000cd`,lightcoral:`#f08080`,darkturquoise:`#00ced1`,lightcyan:`#e0ffff`,ivory:`#fffff0`,lightyellow:`#ffffe0`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,linen:`#faf0e6`,mediumaquamarine:`#66cdaa`,lemonchiffon:`#fffacd`,lime:`#00ff00`,khaki:`#f0e68c`,mediumseagreen:`#3cb371`,limegreen:`#32cd32`,mediumspringgreen:`#00fa9a`,lightskyblue:`#87cefa`,lightblue:`#add8e6`,midnightblue:`#191970`,lightpink:`#ffb6c1`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,mintcream:`#f5fffa`,lightslategray:`#778899`,lightslategrey:`#778899`,navajowhite:`#ffdead`,navy:`#000080`,mediumvioletred:`#c71585`,powderblue:`#b0e0e6`,palegoldenrod:`#eee8aa`,oldlace:`#fdf5e6`,paleturquoise:`#afeeee`,mediumturquoise:`#48d1cc`,mediumorchid:`#ba55d3`,rebeccapurple:`#663399`,lightsteelblue:`#b0c4de`,mediumslateblue:`#7b68ee`,thistle:`#d8bfd8`,tan:`#d2b48c`,orchid:`#da70d6`,mediumpurple:`#9370db`,purple:`#800080`,pink:`#ffc0cb`,skyblue:`#87ceeb`,springgreen:`#00ff7f`,palegreen:`#98fb98`,red:`#ff0000`,yellow:`#ffff00`,slateblue:`#6a5acd`,lavenderblush:`#fff0f5`,peru:`#cd853f`,palevioletred:`#db7093`,violet:`#ee82ee`,teal:`#008080`,slategray:`#708090`,slategrey:`#708090`,aliceblue:`#f0f8ff`,darkseagreen:`#8fbc8f`,darkolivegreen:`#556b2f`,greenyellow:`#adff2f`,seagreen:`#2e8b57`,seashell:`#fff5ee`,tomato:`#ff6347`,silver:`#c0c0c0`,sienna:`#a0522d`,lavender:`#e6e6fa`,lightgreen:`#90ee90`,orange:`#ffa500`,orangered:`#ff4500`,steelblue:`#4682b4`,royalblue:`#4169e1`,turquoise:`#40e0d0`,yellowgreen:`#9acd32`,salmon:`#fa8072`,saddlebrown:`#8b4513`,sandybrown:`#f4a460`,rosybrown:`#bc8f8f`,darksalmon:`#e9967a`,lightgoldenrodyellow:`#fafad2`,snow:`#fffafa`,lightgrey:`#d3d3d3`,lightgray:`#d3d3d3`,dimgray:`#696969`,dimgrey:`#696969`,olivedrab:`#6b8e23`,olive:`#808000`},r={};for(var i in n)r[n[i]]=i;var a={};e.prototype.toName=function(t){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return`transparent`;var i,o,s=r[this.toHex()];if(s)return s;if(t?.closest){var c=this.toRgb(),l=1/0,u=`black`;if(!a.length)for(var d in n)a[d]=new e(n[d]).toRgb();for(var f in n){var p=(i=c,o=a[f],(i.r-o.r)**2+(i.g-o.g)**2+(i.b-o.b)**2);p<l&&(l=p,u=f)}return u}},t.string.push([function(t){var r=t.toLowerCase(),i=r===`transparent`?`#0000`:n[r];return i?new e(i).toRgb():null},`name`])}var Se=s((()=>{})),Ce,A,we=s((()=>{be(),Se(),ye([xe]),Ce=class e{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(t){if(t instanceof e)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else if(t===null)throw Error(`Cannot set Color#value to null`);else(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}get value(){return this._value}_cloneSource(e){return typeof e==`string`||typeof e==`number`||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e==`object`&&e?{...e}:e}_isSourceEqual(e,t){let n=typeof e;if(n!==typeof t)return!1;if(n===`number`||n===`string`||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length===t.length&&e.every((e,n)=>e===t[n]);if(e!==null&&t!==null){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}return e===t}toRgba(){let[e,t,n,r]=this._components;return{r:e,g:t,b:n,a:r}}toRgb(){let[e,t,n]=this._components;return{r:e,g:t,b:n}}toRgbaString(){let[e,t,n]=this.toUint8RgbArray();return`rgba(${e},${t},${n},${this.alpha})`}toUint8RgbArray(e){let[t,n,r]=this._components;return this._arrayRgb||=[],e||=this._arrayRgb,e[0]=Math.round(t*255),e[1]=Math.round(n*255),e[2]=Math.round(r*255),e}toArray(e){this._arrayRgba||=[],e||=this._arrayRgba;let[t,n,r,i]=this._components;return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e}toRgbArray(e){this._arrayRgb||=[],e||=this._arrayRgb;let[t,n,r]=this._components;return e[0]=t,e[1]=n,e[2]=r,e}toNumber(){return this._int}toBgrNumber(){let[e,t,n]=this.toUint8RgbArray();return(n<<16)+(t<<8)+e}toLittleEndianNumber(){let e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(t){let[n,r,i,a]=e._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=r,this._components[2]*=i,this._components[3]*=a,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let n=this._int>>16&255,r=this._int>>8&255,i=this._int&255;return t&&(n=n*e+.5|0,r=r*e+.5|0,i=i*e+.5|0),(e*255<<24)+(n<<16)+(r<<8)+i}toHex(){let e=this._int.toString(16);return`#${`000000`.substring(0,6-e.length)+e}`}toHexa(){let e=Math.round(this._components[3]*255).toString(16);return this.toHex()+`00`.substring(0,2-e.length)+e}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(t){let n,r,i,a;if((typeof t==`number`||t instanceof Number)&&t>=0&&t<=16777215){let e=t;n=(e>>16&255)/255,r=(e>>8&255)/255,i=(e&255)/255,a=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,r,i,a=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,r,i,a=255]=t,n/=255,r/=255,i/=255,a/=255;else if(typeof t==`string`||typeof t==`object`){if(typeof t==`string`){let n=e.HEX_PATTERN.exec(t);n&&(t=`#${n[2]}`)}let o=_e(t);o.isValid()&&({r:n,g:r,b:i,a}=o.rgba,n/=255,r/=255,i/=255)}if(n!==void 0)this._components[0]=n,this._components[1]=r,this._components[2]=i,this._components[3]=a,this._refreshInt();else throw Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[e,t,n]=this._components;this._int=(e*255<<16)+(t*255<<8)+(n*255|0)}_clamp(e,t=0,n=1){return typeof e==`number`?Math.min(Math.max(e,t),n):(e.forEach((r,i)=>{e[i]=Math.min(Math.max(r,t),n)}),e)}static isColorLike(t){return typeof t==`number`||typeof t==`string`||t instanceof Number||t instanceof e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}},Ce.shared=new Ce,Ce._temp=new Ce,Ce.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i,A=Ce})),Te,Ee=s((()=>{Te={cullArea:null,cullable:!1,cullableChildren:!0}})),De,Oe,ke,Ae=s((()=>{De=Math.PI*2,Oe=180/Math.PI,ke=Math.PI/180})),je,Me,Ne=s((()=>{je=class e{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new e(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Me.x=0,Me.y=0,Me}},Me=new je})),j,Pe,Fe,M=s((()=>{Ae(),Ne(),j=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}toArray(e,t){this.array||=new Float32Array(9);let n=t||this.array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}apply(e,t){t||=new je;let n=e.x,r=e.y;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}applyInverse(e,t){t||=new je;let n=this.a,r=this.b,i=this.c,a=this.d,o=this.tx,s=this.ty,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(De-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+(a.x*t+a.y*r),e.position.y=this.ty+(a.x*n+a.y*i),e}invert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let t=new e;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Fe.identity()}static get shared(){return Pe.identity()}},Pe=new j,Fe=new j})),Ie,Le=s((()=>{Ie=class e{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(t){return new e(t??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}}));function Re(e=`default`){return ze[e]===void 0&&(ze[e]=-1),++ze[e]}var ze,Be=s((()=>{ze={default:-1}})),Ve,N,He,Ue,P,We=s((()=>{Ve=new Set,N=`8.0.0`,He=`8.3.4`,Ue={quiet:!1,noColor:!1},P=((e,t,n=3)=>{if(Ue.quiet||Ve.has(t))return;let r=Error().stack,i=`${t}
|
|
2
|
+
Deprecated since v${e}`,a=typeof console.groupCollapsed==`function`&&!Ue.noColor;r===void 0?console.warn(`PixiJS Deprecation Warning: `,i):(r=r.split(`
|
|
3
|
+
`).splice(n).join(`
|
|
4
|
+
`),a?(console.groupCollapsed(`%cPixiJS Deprecation Warning: %c%s`,`color:#614108;background:#fffbe6`,`font-weight:normal;color:#614108;background:#fffbe6`,i),console.warn(r),console.groupEnd()):(console.warn(`PixiJS Deprecation Warning: `,i),console.warn(r))),Ve.add(t)}),Object.defineProperties(P,{quiet:{get:()=>Ue.quiet,set:e=>{Ue.quiet=e},enumerable:!0,configurable:!1},noColor:{get:()=>Ue.noColor,set:e=>{Ue.noColor=e},enumerable:!0,configurable:!1}})}));function F(...e){Ge!==Ke&&(Ge++,Ge===Ke?console.warn(`PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS.`):console.warn(`PixiJS Warning: `,...e))}var Ge,Ke,I=s((()=>{Ge=0,Ke=500})),qe,Je=s((()=>{qe={_registeredResources:new Set,register(e){this._registeredResources.add(e)},unregister(e){this._registeredResources.delete(e)},release(){this._registeredResources.forEach(e=>e.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(e){return this._registeredResources.has(e)},reset(){this._registeredResources.clear()}}})),Ye,Xe=s((()=>{Ye=class{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}})),Ze,Qe,$e=s((()=>{Je(),Xe(),Ze=class{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Ye(e)),this._poolsByClass.get(e)}stats(){let e={};return this._poolsByClass.forEach(t=>{let n=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[n]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}},Qe=new Ze,qe.register(Qe)})),et,tt=s((()=>{We(),et={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(e){typeof e==`boolean`&&e===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(e===!0?{}:e))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(e){P(`v8.6.0`,`cacheAsBitmap is deprecated, use cacheAsTexture instead.`),this.cacheAsTexture(e)}}}));function nt(e,t,n){let r=e.length,i;if(t>=r||n===0)return;n=t+n>r?r-t:n;let a=r-n;for(i=t;i<a;++i)e[i]=e[i+n];e.length=a}var rt=s((()=>{})),it,at=s((()=>{rt(),We(),it={allowChildren:!0,removeChildren(e=0,t){let n=t??this.children.length,r=n-e,i=[];if(r>0&&r<=n){for(let t=n-1;t>=e;t--){let e=this.children[t];e&&(i.push(e),e.parent=null)}nt(this.children,e,n);let t=this.renderGroup||this.parentRenderGroup;t&&t.removeChildren(i);for(let e=0;e<i.length;++e){let t=i[e];t.parentRenderLayer?.detach(t),this.emit(`childRemoved`,t,this,e),i[e].emit(`removed`,this)}return i.length>0&&this._didViewChangeTick++,i}else if(r===0&&this.children.length===0)return i;throw RangeError(`removeChildren: numeric values are outside the acceptable range.`)},removeChildAt(e){let t=this.getChildAt(e);return this.removeChild(t)},getChildAt(e){if(e<0||e>=this.children.length)throw Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]},setChildIndex(e,t){if(t<0||t>=this.children.length)throw Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(e),this.addChildAt(e,t)},getChildIndex(e){let t=this.children.indexOf(e);if(t===-1)throw Error(`The supplied Container must be a child of the caller`);return t},addChildAt(e,t){this.allowChildren||P(N,`addChildAt: Only Containers will be allowed to add children in v8.0.0`);let{children:n}=this;if(t<0||t>n.length)throw Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${n.length}`);let r=e.parent===this;if(e.parent){let n=e.parent.children.indexOf(e);if(r){if(n===t)return e;e.parent.children.splice(n,1)}else e.removeFromParent()}t===n.length?n.push(e):n.splice(t,0,e),e.parent=this,e.didChange=!0,e._updateFlags=15;let i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(e),this.sortableChildren&&(this.sortDirty=!0),r?e:(this.emit(`childAdded`,e,this,t),e.emit(`added`,this),e)},swapChildren(e,t){if(e===t)return;let n=this.getChildIndex(e),r=this.getChildIndex(t);this.children[n]=t,this.children[r]=e;let i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...e){return e.length===1?this.reparentChildAt(e[0],this.children.length):(e.forEach(e=>this.reparentChildAt(e,this.children.length)),e[0])},reparentChildAt(e,t){if(e.parent===this)return this.setChildIndex(e,t),e;let n=e.worldTransform.clone();e.removeFromParent(),this.addChildAt(e,t);let r=this.worldTransform.clone();return r.invert(),n.prepend(r),e.setFromMatrix(n),e},replaceChild(e,t){e.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(e)),t.setFromMatrix(e.localTransform),t.updateLocalTransform(),this.removeChild(e)}}})),ot,st=s((()=>{ot={collectRenderables(e,t,n){this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(e,t,n):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,e):this.collectRenderablesWithEffects(e,t,n))},collectRenderablesSimple(e,t,n){let r=this.children,i=r.length;for(let a=0;a<i;a++)r[a].collectRenderables(e,t,n)},collectRenderablesWithEffects(e,t,n){let{renderPipes:r}=t;for(let t=0;t<this.effects.length;t++){let n=this.effects[t];r[n.pipe].push(n,this,e)}this.collectRenderablesSimple(e,t,n);for(let t=this.effects.length-1;t>=0;t--){let n=this.effects[t];r[n.pipe].pop(n,this,e)}}}})),ct,lt=s((()=>{ct=class{constructor(){this.pipe=`filter`,this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}})),ut,dt,ft=s((()=>{g(),$e(),ut=class{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){let n=this._tests[t];if(n.test(e))return Qe.get(n.maskClass,e)}return e}returnMaskEffect(e){Qe.return(e)}},dt=new ut,h.handleByList(f.MaskEffect,dt._effectClasses)})),pt,mt=s((()=>{lt(),ft(),pt={_maskEffect:null,_maskOptions:{inverse:!1,channel:`red`},_filterEffect:null,effects:[],_markStructureAsChanged(){let e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0)},addEffect(e){this.effects.indexOf(e)===-1&&(this.effects.push(e),this.effects.sort((e,t)=>e.priority-t.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(e){let t=this.effects.indexOf(e);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(e){let t=this._maskEffect;t?.mask!==e&&(t&&(this.removeEffect(t),dt.returnMaskEffect(t),this._maskEffect=null),e!=null&&(this._maskEffect=dt.getMaskEffect(e),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(e){this._maskOptions={...this._maskOptions,...e},e.mask&&(this.mask=e.mask),this._markStructureAsChanged()},set filters(e){!Array.isArray(e)&&e&&(e=[e]);let t=this._filterEffect||=new ct;e=e;let n=e?.length>0,r=n!==t.filters?.length>0;e=Array.isArray(e)?e.slice(0):e,t.filters=Object.freeze(e),r&&(n?this.addEffect(t):(this.removeEffect(t),t.filters=e??null))},get filters(){return this._filterEffect?.filters},set filterArea(e){this._filterEffect||=new ct,this._filterEffect.filterArea=e},get filterArea(){return this._filterEffect?.filterArea}}})),ht,gt=s((()=>{We(),ht={label:null,get name(){return P(N,`Container.name property has been removed, use Container.label instead`),this.label},set name(e){P(N,`Container.name property has been removed, use Container.label instead`),this.label=e},getChildByName(e,t=!1){return this.getChildByLabel(e,t)},getChildByLabel(e,t=!1){let n=this.children;for(let t=0;t<n.length;t++){let r=n[t];if(r.label===e||e instanceof RegExp&&e.test(r.label))return r}if(t)for(let t=0;t<n.length;t++){let r=n[t].getChildByLabel(e,!0);if(r)return r}return null},getChildrenByLabel(e,t=!1,n=[]){let r=this.children;for(let t=0;t<r.length;t++){let i=r[t];(i.label===e||e instanceof RegExp&&e.test(i.label))&&n.push(i)}if(t)for(let t=0;t<r.length;t++)r[t].getChildrenByLabel(e,!0,n);return n}}})),_t,vt,yt=s((()=>{Ne(),_t=[new je,new je,new je,new je],vt=class e{constructor(e=0,t=0,n=0,r=0){this.type=`rectangle`,this.x=Number(e),this.y=Number(t),this.width=Number(n),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new e(0,0,0,0)}clone(){return new e(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,n,r=.5){let{width:i,height:a}=this;if(i<=0||a<=0)return!1;let o=this.x,s=this.y,c=n*(1-r),l=n-c,u=o-c,d=o+i+c,f=s-c,p=s+a+c,m=o+l,h=o+i-l,g=s+l,_=s+a-l;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>m&&e<h&&t>g&&t<_)}intersects(e,t){if(!t){let t=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=t)return!1;let n=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>n}let n=this.left,r=this.right,i=this.top,a=this.bottom;if(r<=n||a<=i)return!1;let o=_t[0].set(e.left,e.top),s=_t[1].set(e.left,e.bottom),c=_t[2].set(e.right,e.top),l=_t[3].set(e.right,e.bottom);if(c.x<=o.x||s.y<=o.y)return!1;let u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(o,o),t.apply(s,s),t.apply(c,c),t.apply(l,l),Math.max(o.x,s.x,c.x,l.x)<=n||Math.min(o.x,s.x,c.x,l.x)>=r||Math.max(o.y,s.y,c.y,l.y)<=i||Math.min(o.y,s.y,c.y,l.y)>=a))return!1;let d=u*(s.y-o.y),f=u*(o.x-s.x),p=d*n+f*i,m=d*r+f*i,h=d*n+f*a,g=d*r+f*a;if(Math.max(p,m,h,g)<=d*o.x+f*o.y||Math.min(p,m,h,g)>=d*l.x+f*l.y)return!1;let _=u*(o.y-c.y),v=u*(c.x-o.x),y=_*n+v*i,b=_*r+v*i,x=_*n+v*a,S=_*r+v*a;return!(Math.max(y,b,x,S)<=_*o.x+v*o.y||Math.min(y,b,x,S)>=_*l.x+v*l.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){let t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),i=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(n-t,0),this.y=r,this.height=Math.max(i-r,0),this}ceil(e=1,t=.001){let n=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=n-this.x,this.height=r-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){let t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),i=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=n-t,this.y=r,this.height=i-r,this}getBounds(t){return t||=new e,t.copyFrom(this),t}containsRect(e){if(this.width<=0||this.height<=0)return!1;let t=e.x,n=e.y,r=e.x+e.width,i=e.y+e.height;return t>=this.x&&t<this.x+this.width&&n>=this.y&&n<this.y+this.height&&r>=this.x&&r<this.x+this.width&&i>=this.y&&i<this.y+this.height}set(e,t,n,r){return this.x=e,this.y=t,this.width=n,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}})),bt,xt,St=s((()=>{M(),yt(),bt=new j,xt=class e{constructor(e=1/0,t=1/0,n=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=bt,this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||=new vt;let e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=bt,this}set(e,t,n,r){this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}addFrame(e,t,n,r,i){i||=this.matrix;let a=i.a,o=i.b,s=i.c,c=i.d,l=i.tx,u=i.ty,d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,h=a*e+s*t+l,g=o*e+c*t+u;h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*t+l,g=o*n+c*t+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*e+s*r+l,g=o*e+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*r+l,g=o*n+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){let t=this.minX,n=this.minY,r=this.maxX,i=this.maxY,{a,b:o,c:s,d:c,tx:l,ty:u}=e,d=a*t+s*n+l,f=o*t+c*n+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=a*r+s*n+l,f=o*r+c*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*t+s*i+l,f=o*t+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+s*i+l,f=o*r+c*i+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,n,r){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<n&&(this.minY=n),this.maxY>r&&(this.maxY=r),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new e(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){let t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){let t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,t,n,r){let i=this.minX,a=this.minY,o=this.maxX,s=this.maxY;r||=this.matrix;let c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let r=t;r<n;r+=2){let t=e[r],n=e[r+1],m=c*t+u*n+f,h=l*t+d*n+p;i=m<i?m:i,a=h<a?h:a,o=m>o?m:o,s=h>s?h:s}this.minX=i,this.minY=a,this.maxX=o,this.maxY=s}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}})),Ct,wt,Tt=s((()=>{M(),$e(),St(),Ct=Qe.getPool(j),wt=Qe.getPool(xt)})),Et,Dt,Ot=s((()=>{M(),St(),Tt(),Et=new j,Dt={getFastGlobalBounds(e,t){t||=new xt,t.clear(),this._getGlobalBoundsRecursive(!!e,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);let n=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(n.worldTransform),t},_getGlobalBoundsRecursive(e,t,n){let r=t;if(e&&this.parentRenderLayer&&this.parentRenderLayer!==n||this.localDisplayStatus!==7||!this.measurable)return;let i=!!this.effects.length;if((this.renderGroup||i)&&(r=wt.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){let e=this.bounds;r.addFrame(e.minX,e.minY,e.maxX,e.maxY,this.groupTransform)}let t=this.children;for(let i=0;i<t.length;i++)t[i]._getGlobalBoundsRecursive(e,r,n)}if(i){let e=!1,n=this.renderGroup||this.parentRenderGroup;for(let t=0;t<this.effects.length;t++)this.effects[t].addBounds&&(e||(e=!0,r.applyMatrix(n.worldTransform)),this.effects[t].addBounds(r,!0));e&&r.applyMatrix(n.worldTransform.copyTo(Et).invert()),t.addBounds(r),wt.return(r)}else this.renderGroup&&(t.addBounds(r,this.relativeGroupTransform),wt.return(r))}}}));function kt(e,t,n){n.clear();let r,i;return e.parent?t?r=e.parent.worldTransform:(i=Ct.get().identity(),r=jt(e,i)):r=j.IDENTITY,At(e,n,r,t),i&&Ct.return(i),n.isValid||n.set(0,0,0,0),n}function At(e,t,n,r){if(!e.visible||!e.measurable)return;let i;r?i=e.worldTransform:(e.updateLocalTransform(),i=Ct.get(),i.appendFrom(e.localTransform,n));let a=t,o=!!e.effects.length;if(o&&(t=wt.get().clear()),e.boundsArea)t.addRect(e.boundsArea,i);else{let n=e.bounds;n&&!n.isEmpty()&&(t.matrix=i,t.addBounds(n));for(let n=0;n<e.children.length;n++)At(e.children[n],t,i,r)}if(o){for(let n=0;n<e.effects.length;n++)e.effects[n].addBounds?.(t);a.addBounds(t,j.IDENTITY),wt.return(t)}r||Ct.return(i)}function jt(e,t){let n=e.parent;return n&&(jt(n,t),n.updateLocalTransform(),t.append(n.localTransform)),t}var Mt=s((()=>{M(),Tt()}));function Nt(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;let n=e>>16&255,r=e>>8&255,i=e&255,a=t>>16&255,o=t>>8&255,s=t&255,c=n*a/255|0,l=r*o/255|0,u=i*s/255|0;return(c<<16)+(l<<8)+u}var Pt=s((()=>{}));function Ft(e,t){return e===It?t:t===It?e:Nt(e,t)}var It,Lt=s((()=>{Pt(),It=16777215}));function Rt(e){return((e&255)<<16)+(e&65280)+(e>>16&255)}var zt,Bt=s((()=>{M(),Mt(),Tt(),Lt(),zt={getGlobalAlpha(e){if(e)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,n=this.parent;for(;n;)t*=n.alpha,n=n.parent;return t},getGlobalTransform(e=new j,t){if(t)return e.copyFrom(this.worldTransform);this.updateLocalTransform();let n=jt(this,Ct.get().identity());return e.appendFrom(this.localTransform,n),Ct.return(n),e},getGlobalTint(e){if(e)return this.renderGroup?Rt(this.renderGroup.worldColor):this.parentRenderGroup?Rt(Ft(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,n=this.parent;for(;n;)t=Ft(t,n.localColor),n=n.parent;return Rt(t)}}}));function Vt(e,t,n){return t.clear(),n||=j.IDENTITY,Ht(e,t,n,e,!0),t.isValid||t.set(0,0,0,0),t}function Ht(e,t,n,r,i){let a;if(i)a=Ct.get(),a=n.copyTo(a);else{if(!e.visible||!e.measurable)return;e.updateLocalTransform();let t=e.localTransform;a=Ct.get(),a.appendFrom(t,n)}let o=t,s=!!e.effects.length;if(s&&(t=wt.get().clear()),e.boundsArea)t.addRect(e.boundsArea,a);else{e.renderPipeId&&(t.matrix=a,t.addBounds(e.bounds));let n=e.children;for(let e=0;e<n.length;e++)Ht(n[e],t,a,r,!1)}if(s){for(let n=0;n<e.effects.length;n++)e.effects[n].addLocalBounds?.(t,r);o.addBounds(t,j.IDENTITY),wt.return(t)}Ct.return(a)}var Ut=s((()=>{M(),Tt()}));function Wt(e,t){let n=e.children;for(let e=0;e<n.length;e++){let r=n[e],i=r.uid,a=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,o=t.index;(t.data[o]!==i||t.data[o+1]!==a)&&(t.data[t.index]=i,t.data[t.index+1]=a,t.didChange=!0),t.index=o+2,r.children.length&&Wt(r,t)}return t.didChange}var Gt=s((()=>{})),Kt,qt,Jt=s((()=>{M(),St(),Mt(),Ut(),Gt(),Kt=new j,qt={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(e,t){let n=Math.sign(this.scale.x)||1;t===0?this.scale.x=n:this.scale.x=e/t*n},_setHeight(e,t){let n=Math.sign(this.scale.y)||1;t===0?this.scale.y=n:this.scale.y=e/t*n},getLocalBounds(){this._localBoundsCacheData||={data:[],index:1,didChange:!1,localBounds:new xt};let e=this._localBoundsCacheData;return e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick&&(e.didChange=!0,e.data[0]=this._didViewChangeTick),Wt(this,e),e.didChange&&Vt(this,e.localBounds,Kt),e.localBounds},getBounds(e,t){return kt(this,e,t||new xt)}}})),Yt,Xt=s((()=>{Yt={_onRender:null,set onRender(e){let t=this.renderGroup||this.parentRenderGroup;if(!e){this._onRender&&t?.removeOnRender(this),this._onRender=null;return}this._onRender||t?.addOnRender(this),this._onRender=e},get onRender(){return this._onRender}}}));function Zt(e,t){return e._zIndex-t._zIndex}var Qt,$t=s((()=>{Qt={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(e){this._zIndex!==e&&(this._zIndex=e,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(Zt))}}})),en,tn=s((()=>{Ne(),Tt(),en={getGlobalPosition(e=new je,t=!1){return this.parent?this.parent.toGlobal(this._position,e,t):(e.x=this._position.x,e.y=this._position.y),e},toGlobal(e,t,n=!1){let r=this.getGlobalTransform(Ct.get(),n);return t=r.apply(e,t),Ct.return(r),t},toLocal(e,t,n,r){t&&(e=t.toGlobal(e,n,r));let i=this.getGlobalTransform(Ct.get(),r);return n=i.applyInverse(e,n),Ct.return(i),n}}})),nn,rn=s((()=>{Be(),nn=class{constructor(){this.uid=Re(`instructionSet`),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,[`type`,`action`])}}}));function an(e){return e+=+(e===0),--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function on(e){return!(e&e-1)&&!!e}var sn=s((()=>{}));function cn(e){let t={};for(let n in e)e[n]!==void 0&&(t[n]=e[n]);return t}var ln=s((()=>{}));function un(e){let t=dn[e];return t===void 0&&(dn[e]=Re(`resource`)),t}var dn,fn,pn,mn=s((()=>{b(),Be(),We(),dn=Object.create(null),fn=class e extends y{constructor(t={}){super(),this._resourceType=`textureSampler`,this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...e.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){P(N,`TextureStyle.wrapMode is now TextureStyle.addressMode`),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,16),this._maxAnisotropy>1&&(this.scaleMode=`linear`)}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit(`change`,this)}_generateResourceId(){let e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=un(e),this._resourceId}destroy(){this.destroyed=!0,this.emit(`destroy`,this),this.emit(`change`,this),this.removeAllListeners()}},fn.defaultOptions={addressMode:`clamp-to-edge`,scaleMode:`linear`},pn=fn})),hn,gn,_n=s((()=>{b(),sn(),ln(),Be(),mn(),hn=class e extends y{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=Re(`textureSource`),this._resourceType=`textureSource`,this._resourceId=Re(`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.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...e.defaultOptions,...t},this.label=t.label??``,this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.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=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=t.transient??!1,this.alphaMode=t.alphaMode,this.style=new pn(cn(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(e){this.style!==e&&(this._style?.off(`change`,this._onStyleChange,this),this._style=e,this._style?.on(`change`,this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit(`styleChange`,this)}update(){if(this.resource){let e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit(`update`,this)}destroy(){this.destroyed=!0,this.unload(),this.emit(`destroy`,this),this._style&&=(this._style.destroy(),null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=Re(`resource`),this.emit(`change`,this),this.emit(`unload`,this);for(let e in this._gpuData)this._gpuData[e]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){let{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){let{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,n){n||=this._resolution,e||=this.width,t||=this.height;let r=Math.round(e*n),i=Math.round(t*n);return this.width=r/n,this.height=i/n,this._resolution=n,this.pixelWidth===r&&this.pixelHeight===i?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=i,this.emit(`resize`,this),this._resourceId=Re(`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=on(this.pixelWidth)&&on(this.pixelHeight)}static test(e){throw Error(`Unimplemented`)}},hn.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},gn=hn}));function vn(){for(let e=0;e<16;e++){let t=[];Cn.push(t);for(let n=0;n<16;n++){let r=Tn(yn[e]*yn[n]+xn[e]*bn[n]),i=Tn(bn[e]*yn[n]+Sn[e]*bn[n]),a=Tn(yn[e]*xn[n]+xn[e]*Sn[n]),o=Tn(bn[e]*xn[n]+Sn[e]*Sn[n]);for(let e=0;e<16;e++)if(yn[e]===r&&bn[e]===i&&xn[e]===a&&Sn[e]===o){t.push(e);break}}}for(let e=0;e<16;e++){let t=new j;t.set(yn[e],bn[e],xn[e],Sn[e],0,0),wn.push(t)}}var yn,bn,xn,Sn,Cn,wn,Tn,L,En=s((()=>{M(),yn=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],bn=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],xn=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Sn=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Cn=[],wn=[],Tn=Math.sign,vn(),L={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:e=>yn[e],uY:e=>bn[e],vX:e=>xn[e],vY:e=>Sn[e],inv:e=>e&8?e&15:-e&7,add:(e,t)=>Cn[e][t],sub:(e,t)=>Cn[e][L.inv(t)],rotate180:e=>e^4,isVertical:e=>(e&3)==2,byDirection:(e,t)=>Math.abs(e)*2<=Math.abs(t)?t>=0?L.S:L.N:Math.abs(t)*2<=Math.abs(e)?e>0?L.E:L.W:t>0?e>0?L.SE:L.SW:e>0?L.NE:L.NW,matrixAppendRotationInv:(e,t,n=0,r=0,i=0,a=0)=>{let o=wn[L.inv(t)],s=o.a,c=o.b,l=o.c,u=o.d,d=n-Math.min(0,s*i,l*a,s*i+l*a),f=r-Math.min(0,c*i,u*a,c*i+u*a),p=e.a,m=e.b,h=e.c,g=e.d;e.a=s*p+c*h,e.b=s*m+c*g,e.c=l*p+u*h,e.d=l*m+u*g,e.tx=d*p+f*h+e.tx,e.ty=d*m+f*g+e.ty},transformRectCoords:(e,t,n,r)=>{let{x:i,y:a,width:o,height:s}=e,{x:c,y:l,width:u,height:d}=t;return n===L.E?(r.set(i+c,a+l,o,s),r):n===L.S?r.set(u-a-s+c,i+l,s,o):n===L.W?r.set(u-i-o+c,d-a-s+l,o,s):n===L.N?r.set(a+c,d-i-o+l,s,o):r.set(i+c,a+l,o,s)}}})),Dn,On=s((()=>{Dn=()=>{}})),kn,An=s((()=>{g(),_n(),kn=class extends gn{constructor(e){let t=e.resource||new Float32Array(e.width*e.height*4),n=e.format;n||=t instanceof Float32Array?`rgba32float`:t instanceof Int32Array||t instanceof Uint32Array?`rgba32uint`:t instanceof Int16Array||t instanceof Uint16Array?`rgba16uint`:(t instanceof Int8Array,`bgra8unorm`),super({...e,resource:t,format:n}),this.uploadMethodId=`buffer`}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}},kn.extension=f.TextureSource})),jn,Mn,Nn=s((()=>{M(),jn=new j,Mn=class{constructor(e,t){this.mapCoord=new j,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,t===void 0?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture?.removeListener(`update`,this.update,this),this._texture=e,this._texture.addListener(`update`,this.update,this)),this.update()}multiplyUvs(e,t){t===void 0&&(t=e);let n=this.mapCoord;for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];t[r]=i*n.a+a*n.c+n.tx,t[r+1]=i*n.b+a*n.d+n.ty}return t}update(){let e=this._texture;this._updateID++;let t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);let n=e.orig,r=e.trim;r&&(jn.set(n.width/r.width,0,0,n.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(jn));let i=e.source,a=this.uClampFrame,o=this.clampMargin/i._resolution,s=this.clampOffset/i._resolution;return a[0]=(e.frame.x+o+s)/i.width,a[1]=(e.frame.y+o+s)/i.height,a[2]=(e.frame.x+e.frame.width-o+s)/i.width,a[3]=(e.frame.y+e.frame.height-o+s)/i.height,this.uClampOffset[0]=this.clampOffset/i.pixelWidth,this.uClampOffset[1]=this.clampOffset/i.pixelHeight,this.isSimple=e.frame.width===i.width&&e.frame.height===i.height&&e.rotate===0,!0}}})),R,z=s((()=>{b(),En(),yt(),Be(),We(),On(),An(),_n(),Nn(),R=class extends y{constructor({source:e,label:t,frame:n,orig:r,trim:i,defaultAnchor:a,defaultBorders:o,rotate:s,dynamic:c}={}){if(super(),this.uid=Re(`texture`),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new vt,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new gn,this.noFrame=!n,n)this.frame.copyFrom(n);else{let{width:e,height:t}=this._source;this.frame.width=e,this.frame.height=t}this.orig=r||this.frame,this.trim=i,this.rotate=s??0,this.defaultAnchor=a,this.defaultBorders=o,this.destroyed=!1,this.dynamic=c||!1,this.updateUvs()}set source(e){this._source&&this._source.off(`resize`,this.update,this),this._source=e,e.on(`resize`,this.update,this),this.emit(`update`,this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||=new Mn(this),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){let{uvs:e,frame:t}=this,{width:n,height:r}=this._source,i=t.x/n,a=t.y/r,o=t.width/n,s=t.height/r,c=this.rotate;if(c){let t=o/2,n=s/2,r=i+t,l=a+n;c=L.add(c,L.NW),e.x0=r+t*L.uX(c),e.y0=l+n*L.uY(c),c=L.add(c,2),e.x1=r+t*L.uX(c),e.y1=l+n*L.uY(c),c=L.add(c,2),e.x2=r+t*L.uX(c),e.y2=l+n*L.uY(c),c=L.add(c,2),e.x3=r+t*L.uX(c),e.y3=l+n*L.uY(c)}else e.x0=i,e.y0=a,e.x1=i+o,e.y1=a,e.x2=i+o,e.y2=a+s,e.x3=i,e.y3=a+s}destroy(e=!1){this._source&&(this._source.off(`resize`,this.update,this),e&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit(`destroy`,this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit(`update`,this)}get baseTexture(){return P(N,`Texture.baseTexture is now Texture.source`),this._source}},R.EMPTY=new R({label:`EMPTY`,source:new gn({label:`EMPTY`})}),R.EMPTY.destroy=Dn,R.WHITE=new R({source:new kn({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:`premultiply-alpha-on-upload`,label:`WHITE`}),label:`WHITE`}),R.WHITE.destroy=Dn})),Pn,Fn,In,Ln=s((()=>{sn(),Je(),_n(),z(),mn(),Pn=0,Fn=class{constructor(e){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=e||{},this.enableFullScreen=!1,this.textureStyle=new pn(this.textureOptions)}createTexture(e,t,n,r){return new R({source:new gn({...this.textureOptions,width:e,height:t,resolution:1,antialias:n,autoGarbageCollect:!1,autoGenerateMipmaps:r}),label:`texturePool_${Pn++}`})}getOptimalTexture(e,t,n=1,r,i=!1){let a=Math.ceil(e*n-1e-6),o=Math.ceil(t*n-1e-6);a=an(a),o=an(o);let s=+!!r,c=+!!i,l=(a<<17)+(o<<2)+(c<<1)+s;this._texturePool[l]||(this._texturePool[l]=[]);let u=this._texturePool[l].pop();return u||=this.createTexture(a,o,r,i),u.source._resolution=n,u.source.width=a/n,u.source.height=o/n,u.source.pixelWidth=a,u.source.pixelHeight=o,u.frame.x=0,u.frame.y=0,u.frame.width=e,u.frame.height=t,u.updateUvs(),this._poolKeyHash[u.uid]=l,u}getSameSizeTexture(e,t=!1){let n=e.source;return this.getOptimalTexture(e.width,e.height,n._resolution,t)}returnTexture(e,t=!1){let n=this._poolKeyHash[e.uid];t&&(e.source.style=this.textureStyle),this._texturePool[n].push(e)}clear(e){if(e=e!==!1,e)for(let e in this._texturePool){let t=this._texturePool[e];if(t)for(let e=0;e<t.length;e++)t[e].destroy(!0)}this._texturePool={}}},In=new Fn,qe.register(In)})),Rn,zn=s((()=>{M(),rn(),Ln(),Rn=class{constructor(){this.renderPipeId=`renderGroup`,this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new j,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 nn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;let t=e.children;for(let e=0;e<t.length;e++){let n=t[e];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&=(In.returnTexture(this.texture,!0),null)}updateCacheTexture(){this.textureNeedsUpdate=!0;let e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(let e in this.childrenToUpdate){let t=this.childrenToUpdate[e];t.list.fill(null),t.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){let t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.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);let t=e.children;for(let e=0;e<t.length;e++)this.addChild(t[e])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}let t=e.children;for(let e=0;e<t.length;e++)this.removeChild(t[e])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]},t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.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=[]){let t=this.root.children;for(let n=0;n<t.length;n++)this._getChildren(t[n],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;let n=e.children;for(let e=0;e<n.length;e++)this._getChildren(n[e],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||=new j,this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||=new j,this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;let e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||=new j,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 Bn(e,t,n={}){for(let r in t)!n[r]&&t[r]!==void 0&&(e[r]=t[r])}var Vn=s((()=>{})),Hn,Un,Wn,Gn,Kn,qn=s((()=>{b(),we(),Ee(),g(),M(),Ae(),Le(),Be(),We(),I(),$e(),tt(),at(),st(),mt(),gt(),Ot(),Bt(),Jt(),Xt(),$t(),tn(),zn(),Vn(),Hn=new Ie(null),Un=new Ie(null),Wn=new Ie(null,1,1),Gn=new Ie(null),Kn=class e extends y{constructor(e={}){super(),this.uid=Re(`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 j,this.relativeGroupTransform=new j,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Ie(this,0,0),this._scale=Wn,this._pivot=Un,this._origin=Gn,this._skew=Hn,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=[],Bn(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach(e=>this.addChild(e)),e.parent?.addChild(this)}static mixin(t){P(`8.8.0`,`Container.mixin is deprecated, please use extensions.mixin instead.`),h.mixin(e,t)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||P(N,`addChild: Only Containers will be allowed to add children in v8.0.0`),e.length>1){for(let t=0;t<e.length;t++)this.addChild(e[t]);return e[0]}let t=e[0],n=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),n&&(n.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,n&&n.addChild(t),this.emit(`childAdded`,t,this,this.children.length-1),t.emit(`added`,this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let t=0;t<e.length;t++)this.removeChild(e[t]);return e[0]}let t=e[0],n=this.children.indexOf(t);return n>-1&&(this._didViewChangeTick++,this.children.splice(n,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit(`childRemoved`,t,this,n),t.emit(`removed`,this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Qe.get(Rn,this),this.groupTransform=j.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),Qe.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||=new j,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*Oe}set angle(e){this.rotation=e*ke}get pivot(){return this._pivot===Un&&(this._pivot=new Ie(this,0,0)),this._pivot}set pivot(e){this._pivot===Un&&(this._pivot=new Ie(this,0,0),this._origin!==Gn&&F(`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===Hn&&(this._skew=new Ie(this,0,0)),this._skew}set skew(e){this._skew===Hn&&(this._skew=new Ie(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===Wn&&(this._scale=new Ie(this,1,1)),this._scale}set scale(e){this._scale===Wn&&(this._scale=new Ie(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===Gn&&(this._origin=new Ie(this,0,0)),this._origin}set origin(e){this._origin===Gn&&(this._origin=new Ie(this,0,0),this._pivot!==Un&&F(`Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.`)),typeof e==`number`?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){let t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){let t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||={};let t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){let n=this.getLocalBounds();typeof e==`object`?(t=e.height??e.width,e=e.width):t??=e,e!==void 0&&this._setWidth(e,n.width),t!==void 0&&this._setHeight(t,n.height)}_updateSkew(){let e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x==`number`?e.x:this.position.x,typeof e.y==`number`?e.y:this.position.y),this.scale.set(typeof e.scaleX==`number`?e.scaleX:this.scale.x,typeof e.scaleY==`number`?e.scaleY:this.scale.y),this.rotation=typeof e.rotation==`number`?e.rotation:this.rotation,this.skew.set(typeof e.skewX==`number`?e.skewX:this.skew.x,typeof e.skewY==`number`?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX==`number`?e.pivotX:this.pivot.x,typeof e.pivotY==`number`?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX==`number`?e.originX:this.origin.x,typeof e.originY==`number`?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;let t=this.localTransform,n=this._scale,r=this._pivot,i=this._origin,a=this._position,o=n._x,s=n._y,c=r._x,l=r._y,u=-i._x,d=-i._y;t.a=this._cx*o,t.b=this._sx*o,t.c=this._cy*s,t.d=this._sy*s,t.tx=a._x-(c*t.a+l*t.c)+(u*t.a+d*t.c)-u,t.ty=a._y-(c*t.b+l*t.d)+(u*t.b+d*t.d)-d}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){let t=A.shared.setValue(e??16777215).toBgrNumber();t!==this.localColor&&(this.localColor=t,this._updateFlags|=1,this._onUpdate())}get tint(){return Rt(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate(),this.emit(`visibleChanged`,e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){let t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=+!!e;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit(`destroyed`,this),this.removeAllListeners(),(typeof e==`boolean`?e:e?.children)&&t)for(let n=0;n<t.length;++n)t[n].destroy(e);this.renderGroup?.destroy(),this.renderGroup=null}},h.mixin(Kn,it,Dt,en,Yt,qt,pt,ht,Qt,Te,et,zt,ot)})),Jn,Yn=s((()=>{Jn=(e=>(e[e.INTERACTION=50]=`INTERACTION`,e[e.HIGH=25]=`HIGH`,e[e.NORMAL=0]=`NORMAL`,e[e.LOW=-25]=`LOW`,e[e.UTILITY=-50]=`UTILITY`,e))(Jn||{})})),Xn,Zn=s((()=>{Xn=class{constructor(e,t=null,n=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=n,this._once=r}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));let t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let t=this.next;return this.next=e?null:t,this.previous=null,t}}})),Qn,$n,er=s((()=>{Yn(),Zn(),Qn=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 Xn(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=Jn.NORMAL){return this._addListener(new Xn(e,t,n))}addOnce(e,t,n=Jn.NORMAL){return this._addListener(new Xn(e,t,n,!0))}_addListener(e){let t=this._head.next,n=this._head;if(!t)e.connect(n);else{for(;t;){if(e.priority>t.priority){e.connect(n);break}n=t,t=t.next}e.previous||e.connect(n)}return this._startIfPossible(),this}remove(e,t){let n=this._head.next;for(;n;)n=n.match(e,t)?n.destroy():n.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){let e=t-this._lastFrame|0;if(e<this._minElapsedMS)return;this._lastFrame=t-e%this._minElapsedMS}this.deltaMS=n,this.deltaTime=this.deltaMS*e.targetFPMS;let r=this._head,i=r.next;for(;i;)i=i.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let n=Math.min(Math.max(0,t)/1e3,e.targetFPMS);this._maxElapsedMS=1/n,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!e._shared){let t=e._shared=new e;t.autoStart=!0,t._protected=!0}return e._shared}static get system(){if(!e._system){let t=e._system=new e;t.autoStart=!0,t._protected=!0}return e._system}},Qn.targetFPMS=.06,$n=Qn})),tr,nr=s((()=>{Yn(),er(),tr=class{constructor(e){this._lastTransform=``,this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let e=this._canvas.getBoundingClientRect(),t=this._canvas.width,n=this._canvas.height,r=e.width/t*this._renderer.resolution,i=e.height/n*this._renderer.resolution,a=`translate(${e.left}px, ${e.top}px) scale(${r}, ${i})`;a!==this._lastTransform&&(this._domElement.style.transform=a,this._lastTransform=a)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){`ResizeObserver`in globalThis?(this._observer&&=(this._observer.disconnect(),null),this._observer=new ResizeObserver(e=>{for(let t of e){if(t.target!==this._canvas)continue;let e=this.canvas.width,n=this.canvas.height,r=t.contentRect.width/e*this._renderer.resolution,i=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==r||this._lastScaleY!==i)&&(this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=i)}}),this._observer.observe(this._canvas)):this._tickerAttached||$n.shared.add(this.updateTranslation,this,Jn.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&$n.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform=``,this._lastScaleX=null,this._lastScaleY=null}}})),rr,ir=s((()=>{Ne(),rr=class e{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=e.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new je,this.page=new je,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,n){throw Error(`initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}initUIEvent(e,t,n,r,i){throw Error(`initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}}));function ar(e){return function(t){return t.test(e)}}function or(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=ar(n),a={apple:{phone:i(sr)&&!i(hr),ipod:i(cr),tablet:!i(sr)&&(i(lr)||Sr(t))&&!i(hr),universal:i(ur),device:(i(sr)||i(cr)||i(lr)||i(ur)||Sr(t))&&!i(hr)},amazon:{phone:i(pr),tablet:!i(pr)&&i(mr),device:i(pr)||i(mr)},android:{phone:!i(hr)&&i(pr)||!i(hr)&&i(dr),tablet:!i(hr)&&!i(pr)&&!i(dr)&&(i(mr)||i(fr)),device:!i(hr)&&(i(pr)||i(mr)||i(dr)||i(fr))||i(/\bokhttp\b/i)},windows:{phone:i(hr),tablet:i(gr),device:i(hr)||i(gr)},other:{blackberry:i(_r),blackberry10:i(vr),opera:i(yr),firefox:i(xr),chrome:i(br),device:i(_r)||i(vr)||i(yr)||i(xr)||i(br)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr=s((()=>{sr=/iPhone/i,cr=/iPod/i,lr=/iPad/i,ur=/\biOS-universal(?:.+)Mac\b/i,dr=/\bAndroid(?:.+)Mobile\b/i,fr=/Android/i,pr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,mr=/Silk/i,hr=/Windows Phone/i,gr=/\bWindows(?:.+)ARM\b/i,_r=/BlackBerry/i,vr=/BB10/i,yr=/Opera Mini/i,br=/\b(CriOS|Chrome)(?:.+)Mobile/i,xr=/Mobile(?:.+)Firefox\b/i,Sr=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`}})),wr=s((()=>{Cr(),Cr()})),Tr,Er=s((()=>{wr(),Tr=(or.default??or)(globalThis.navigator)})),Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr=s((()=>{nr(),ir(),g(),Er(),rt(),Dr=9,Or=100,kr=0,Ar=0,jr=2,Mr=1,Nr=-1e3,Pr=-1e3,Fr=2,Ir=class e{constructor(e,t=Tr){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let e=document.createElement(`button`);e.style.width=`${Mr}px`,e.style.height=`${Mr}px`,e.style.position=`absolute`,e.style.top=`${Nr}px`,e.style.left=`${Pr}px`,e.style.zIndex=Fr.toString(),e.style.backgroundColor=`#FF0000`,e.title=`select to enable accessibility for this content`,e.addEventListener(`focus`,()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&=(document.body.removeChild(this._hookDiv),null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement(`div`),this._div.style.position=`absolute`,this._div.style.top=`${kr}px`,this._div.style.left=`${Ar}px`,this._div.style.pointerEvents=`none`,this._div.style.zIndex=jr.toString(),this._canvasObserver=new tr({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener(`mousemove`,this._boundOnMouseMove,!0);let e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{let t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener(`mousemove`,this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener(`keydown`,this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(let e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(let e in this._pools)this._pools[e].forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);let t=e.children;if(t)for(let e=0;e<t.length;e++)this._updateAccessibleObjects(t[e])}init(t){let n={accessibilityOptions:{...e.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=n.accessibilityOptions.debug,this._activateOnTab=n.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=n.accessibilityOptions.deactivateOnMouseMove,n.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){let e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;let t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(let e of this._children)e._renderId===this._renderId&&t.add(this._children.indexOf(e))}for(let e=this._children.length-1;e>=0;e--){let n=this._children[e];t.has(e)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,nt(this._children,e,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let e=0;e<this._children.length;e++){let t=this._children[e];if(!t._accessibleActive||!t._accessibleDiv)continue;let n=t._accessibleDiv,r=t.hitArea||t.getBounds().rectangle;if(t.hitArea){let e=t.worldTransform;n.style.left=`${e.tx+r.x*e.a}px`,n.style.top=`${e.ty+r.y*e.d}px`,n.style.width=`${r.width*e.a}px`,n.style.height=`${r.height*e.d}px`}else this._capHitArea(r),n.style.left=`${r.x}px`,n.style.top=`${r.y}px`,n.style.width=`${r.width}px`,n.style.height=`${r.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);let{width:t,height:n}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>n&&(e.height=n-e.y)}_addChild(e){let t=this._getPool(e.accessibleType).pop();t?(t.innerHTML=``,t.removeAttribute(`title`),t.removeAttribute(`aria-label`),t.tabIndex=0):(e.accessibleType===`button`?t=document.createElement(`button`):(t=document.createElement(e.accessibleType),t.style.cssText=`
|
|
5
|
+
color: transparent;
|
|
6
|
+
pointer-events: none;
|
|
7
|
+
padding: 0;
|
|
8
|
+
margin: 0;
|
|
9
|
+
border: 0;
|
|
10
|
+
outline: 0;
|
|
11
|
+
background: transparent;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
user-select: none;
|
|
14
|
+
-webkit-user-select: none;
|
|
15
|
+
-moz-user-select: none;
|
|
16
|
+
-ms-user-select: none;
|
|
17
|
+
`,e.accessibleText&&(t.innerText=e.accessibleText)),t.style.width=`${Or}px`,t.style.height=`${Or}px`,t.style.backgroundColor=this.debug?`rgba(255,255,255,0.5)`:`transparent`,t.style.position=`absolute`,t.style.zIndex=jr.toString(),t.style.borderStyle=`none`,navigator.userAgent.toLowerCase().includes(`chrome`)?t.setAttribute(`aria-live`,`off`):t.setAttribute(`aria-live`,`polite`),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute(`aria-relevant`,`additions`):t.setAttribute(`aria-relevant`,`text`),t.addEventListener(`click`,this._onClick.bind(this)),t.addEventListener(`focus`,this._onFocus.bind(this)),t.addEventListener(`focusout`,this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute(`aria-label`,e.accessibleHint),e.interactive?t.tabIndex=e.tabIndex:t.tabIndex=0,this.debug&&this._updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv)}_dispatchEvent(e,t){let{container:n}=e.target,r=this._renderer.events.rootBoundary,i=Object.assign(new rr(r),{target:n});r.rootTarget=this._renderer.lastObjectRendered,t.forEach(e=>r.dispatchEvent(i,e))}_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!==Dr||!this._activateOnTab||this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.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]}},Ir.extension={type:[f.WebGLSystem,f.WebGPUSystem],name:`accessibility`},Ir.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0},Lr=Ir})),zr,Br=s((()=>{zr={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:`button`,accessibleText:null,accessiblePointerEvents:`auto`,accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}})),Vr=s((()=>{g(),qn(),Rr(),Br(),h.add(Lr),h.mixin(Kn,zr)})),Hr,Ur=s((()=>{g(),nr(),Hr=class{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 tr({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){let e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){let n=e[t],r=n.element;if(!n.parent||n.globalDisplayStatus<7)r?.remove(),e.splice(t,1),t--;else{this._domElement.contains(r)||(r.style.position=`absolute`,r.style.pointerEvents=`auto`,this._domElement.appendChild(r));let e=n.worldTransform,t=n._anchor,i=n.width*t.x,a=n.height*t.y;r.style.transformOrigin=`${i}px ${a}px`,r.style.transform=`matrix(${e.a}, ${e.b}, ${e.c}, ${e.d}, ${e.tx-i}, ${e.ty-a})`,r.style.opacity=n.groupAlpha.toString()}}}destroy(){this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)this._attachedDomElements[e].element?.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}},Hr.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`dom`}})),Wr,Gr=s((()=>{St(),qn(),Wr=class extends Kn{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 xt(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}containsPoint(e){let t=this.bounds,{x:n,y:r}=e;return n>=t.minX&&n<=t.maxX&&r>=t.minY&&r<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){this.emit(`unload`,this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,n){let{renderPipes:r}=t;r.blendMode.pushBlendMode(this,this.groupBlendMode,e);let i=r[this.renderPipeId];i?.addRenderable&&i.addRenderable(this,e),this.didViewUpdate=!1;let a=this.children,o=a.length;for(let r=0;r<o;r++)a[r].collectRenderables(e,t,n);r.blendMode.popBlendMode(e)}}})),Kr=s((()=>{g(),Ur(),nr(),Ne(),Gr(),h.add(Hr)})),qr,Jr,Yr=s((()=>{Yn(),er(),qr=class{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||($n.system.add(this._tickerUpdate,this,Jn.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&=($n.system.remove(this._tickerUpdate,this),!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}let 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}},Jr=new qr})),Xr,Zr=s((()=>{Ne(),ir(),Xr=class extends rr{constructor(){super(...arguments),this.client=new je,this.movement=new je,this.offset=new je,this.global=new je,this.screen=new je}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,r,i,a,o,s,c,l,u,d,f,p,m){throw Error(`Method not implemented.`)}}})),Qr,$r=s((()=>{Zr(),Qr=class extends Xr{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 Error(`getPredictedEvents is not supported!`)}}})),ei,ti=s((()=>{Zr(),ei=class extends Xr{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}},ei.DOM_DELTA_PIXEL=0,ei.DOM_DELTA_LINE=1,ei.DOM_DELTA_PAGE=2})),ni,ri,ii,ai,oi=s((()=>{b(),Ne(),I(),Yr(),Zr(),$r(),ti(),ni=2048,ri=new je,ii=new je,ai=class{constructor(e){this.dispatch=new y,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((e,t)=>e.priority-t.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;let t=this.mappingTable[e.type];if(t)for(let n=0,r=t.length;n<r;n++)t[n].fn(e);else F(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Jr.pauseUpdate=!0;let n=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?`hitTestMoveRecursive`:`hitTestRecursive`,r=this[n](this.rootTarget,this.rootTarget.eventMode,ri.set(e,t),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(e,t){if(!e.target)return;let n=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let r=0,i=n.length-1;r<i;r++)if(e.currentTarget=n[r],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 r=n.length-2;r>=0;r--)if(e.currentTarget=n[r],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;let r=Array.isArray(t)?t:[t];for(let t=n.length-1;t>=0;t--)r.forEach(r=>{e.currentTarget=n[t],this.notifyTarget(e,r)})}propagationPath(e){let t=[e];for(let n=0;n<ni&&e!==this.rootTarget&&e.parent;n++){if(!e.parent)throw Error(`Cannot find propagation path to disconnected target`);t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,n,r,i,a=!1){let o=!1;if(this._interactivePrune(e))return null;if((e.eventMode===`dynamic`||t===`dynamic`)&&(Jr.pauseUpdate=!1),e.interactiveChildren&&e.children){let s=e.children;for(let c=s.length-1;c>=0;c--){let l=s[c],u=this.hitTestMoveRecursive(l,this._isInteractive(t)?t:l.eventMode,n,r,i,a||i(e,n));if(u){if(u.length>0&&!u[u.length-1].parent)continue;let t=e.isInteractive();(u.length>0||t)&&(t&&this._allInteractiveElements.push(e),u.push(e)),this._hitElements.length===0&&(this._hitElements=u),o=!0}}}let s=this._isInteractive(t),c=e.isInteractive();return c&&c&&this._allInteractiveElements.push(e),a||this._hitElements.length>0?null:o?this._hitElements:s&&!i(e,n)&&r(e,n)?c?[e]:[]:null}hitTestRecursive(e,t,n,r,i){if(this._interactivePrune(e)||i(e,n))return null;if((e.eventMode===`dynamic`||t===`dynamic`)&&(Jr.pauseUpdate=!1),e.interactiveChildren&&e.children){let a=e.children,o=n;for(let n=a.length-1;n>=0;n--){let s=a[n],c=this.hitTestRecursive(s,this._isInteractive(t)?t:s.eventMode,o,r,i);if(c){if(c.length>0&&!c[c.length-1].parent)continue;let t=e.isInteractive();return(c.length>0||t)&&c.push(e),c}}}let a=this._isInteractive(t),o=e.isInteractive();return a&&r(e,n)?o?[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,ii),!e.hitArea.contains(ii.x,ii.y)))return!0;if(e.effects&&e.effects.length)for(let n=0;n<e.effects.length;n++){let r=e.effects[n];if(r.containsPoint&&!r.containsPoint(t,this.hitTestFn))return!0}return!1}hitTestFn(e,t){return e.hitArea?!0:e?.containsPoint?(e.worldTransform.applyInverse(t,ii),e.containsPoint(ii)):!1}notifyTarget(e,t){if(!e.currentTarget.isInteractive())return;t??=e.type;let n=`on${t}`;e.currentTarget[n]?.(e);let r=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this._notifyListeners(e,r),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof Qr)){F(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.createPointerEvent(e);if(this.dispatchEvent(t,`pointerdown`),t.pointerType===`touch`)this.dispatchEvent(t,`touchstart`);else if(t.pointerType===`mouse`||t.pointerType===`pen`){let e=t.button===2;this.dispatchEvent(t,e?`rightdown`:`mousedown`)}let n=this.trackingData(e.pointerId);n.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof Qr)){F(`EventBoundary cannot map a non-pointer event as a pointer event`);return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;let t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;let n=t.pointerType===`mouse`||t.pointerType===`pen`,r=this.trackingData(e.pointerId),i=this.findMountedTarget(r.overTargets);if(r.overTargets?.length>0&&i!==t.target){let r=e.type===`mousemove`?`mouseout`:`pointerout`,a=this.createPointerEvent(e,r,i);if(this.dispatchEvent(a,`pointerout`),n&&this.dispatchEvent(a,`mouseout`),!t.composedPath().includes(i)){let r=this.createPointerEvent(e,`pointerleave`,i);for(r.eventPhase=r.AT_TARGET;r.target&&!t.composedPath().includes(r.target);)r.currentTarget=r.target,this.notifyTarget(r),n&&this.notifyTarget(r,`mouseleave`),r.target=r.target.parent;this.freeEvent(r)}this.freeEvent(a)}if(i!==t.target){let r=e.type===`mousemove`?`mouseover`:`pointerover`,a=this.clonePointerEvent(t,r);this.dispatchEvent(a,`pointerover`),n&&this.dispatchEvent(a,`mouseover`);let o=i?.parent;for(;o&&o!==this.rootTarget.parent&&o!==t.target;)o=o.parent;if(!o||o===this.rootTarget.parent){let e=this.clonePointerEvent(t,`pointerenter`);for(e.eventPhase=e.AT_TARGET;e.target&&e.target!==i&&e.target!==this.rootTarget.parent;)e.currentTarget=e.target,this.notifyTarget(e),n&&this.notifyTarget(e,`mouseenter`),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(a)}let a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push(`pointermove`):this.dispatchEvent(t,`pointermove`),o&&a.push(`globalpointermove`),t.pointerType===`touch`&&(this.moveOnAll?a.splice(1,0,`touchmove`):this.dispatchEvent(t,`touchmove`),o&&a.push(`globaltouchmove`)),n&&(this.moveOnAll?a.splice(1,0,`mousemove`):this.dispatchEvent(t,`mousemove`),o&&a.push(`globalmousemove`),this.cursor=t.target?.cursor),a.length>0&&this.all(t,a),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof Qr)){F(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.trackingData(e.pointerId),n=this.createPointerEvent(e),r=n.pointerType===`mouse`||n.pointerType===`pen`;this.dispatchEvent(n,`pointerover`),r&&this.dispatchEvent(n,`mouseover`),n.pointerType===`mouse`&&(this.cursor=n.target?.cursor);let 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),r&&this.notifyTarget(i,`mouseenter`),i.target=i.target.parent;t.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(i)}mapPointerOut(e){if(!(e instanceof Qr)){F(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.trackingData(e.pointerId);if(t.overTargets){let n=e.pointerType===`mouse`||e.pointerType===`pen`,r=this.findMountedTarget(t.overTargets),i=this.createPointerEvent(e,`pointerout`,r);this.dispatchEvent(i),n&&this.dispatchEvent(i,`mouseout`);let a=this.createPointerEvent(e,`pointerleave`,r);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),n&&this.notifyTarget(a,`mouseleave`),a.target=a.target.parent;t.overTargets=null,this.freeEvent(i),this.freeEvent(a)}this.cursor=null}mapPointerUp(e){if(!(e instanceof Qr)){F(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let 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`){let e=n.button===2;this.dispatchEvent(n,e?`rightup`:`mouseup`)}let r=this.trackingData(e.pointerId),i=this.findMountedTarget(r.pressTargetsByButton[e.button]),a=i;if(i&&!n.composedPath().includes(i)){let t=i;for(;t&&!n.composedPath().includes(t);){if(n.currentTarget=t,this.notifyTarget(n,`pointerupoutside`),n.pointerType===`touch`)this.notifyTarget(n,`touchendoutside`);else if(n.pointerType===`mouse`||n.pointerType===`pen`){let e=n.button===2;this.notifyTarget(n,e?`rightupoutside`:`mouseupoutside`)}t=t.parent}delete r.pressTargetsByButton[e.button],a=t}if(a){let i=this.clonePointerEvent(n,`click`);i.target=a,i.path=null,r.clicksByButton[e.button]||(r.clicksByButton[e.button]={clickCount:0,target:i.target,timeStamp:t});let o=r.clicksByButton[e.button];if(o.target===i.target&&t-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=i.target,o.timeStamp=t,i.detail=o.clickCount,i.pointerType===`mouse`){let e=i.button===2;this.dispatchEvent(i,e?`rightclick`:`click`)}else i.pointerType===`touch`&&this.dispatchEvent(i,`tap`);this.dispatchEvent(i,`pointertap`),this.freeEvent(i)}this.freeEvent(n)}mapPointerUpOutside(e){if(!(e instanceof Qr)){F(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.trackingData(e.pointerId),n=this.findMountedTarget(t.pressTargetsByButton[e.button]),r=this.createPointerEvent(e);if(n){let i=n;for(;i;)r.currentTarget=i,this.notifyTarget(r,`pointerupoutside`),r.pointerType===`touch`?this.notifyTarget(r,`touchendoutside`):(r.pointerType===`mouse`||r.pointerType===`pen`)&&this.notifyTarget(r,r.button===2?`rightupoutside`:`mouseupoutside`),i=i.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(r)}mapWheel(e){if(!(e instanceof ei)){F(`EventBoundary cannot map a non-wheel event as a wheel event`);return}let 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){let r=this.allocateEvent(Qr);return this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.nativeEvent=e.nativeEvent,r.originalEvent=e,r.target=n??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof t==`string`&&(r.type=t),r}createWheelEvent(e){let t=this.allocateEvent(ei);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){let n=this.allocateEvent(Qr);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 Qr&&t instanceof Qr&&(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 Xr&&t instanceof Xr&&(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,[]);let 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 Error(`It is illegal to free an event not managed by this EventBoundary!`);let t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){let 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 r=0,i=n.length;r<i&&!e.propagationImmediatelyStopped;r++)n[r].once&&e.currentTarget.removeListener(t,n[r].fn,void 0,!0),n[r].fn.call(n[r].context,e)}}})),si,ci,li,ui,di=s((()=>{g(),oi(),Yr(),$r(),ti(),si=1,ci={touchstart:`pointerdown`,touchend:`pointerup`,touchendoutside:`pointerupoutside`,touchmove:`pointermove`,touchcancel:`pointercancel`},li=class e{constructor(t){this.supportsTouchEvents=`ontouchstart`in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new ai(null),Jr.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Qr(null),this._rootWheelEvent=new ei(null),this.cursorStyles={default:`inherit`,pointer:`pointer`},this.features=new Proxy({...e.defaultEventFeatures},{set:(e,t,n)=>(t===`globalMove`&&(this.rootBoundary.enableGlobalMoveEvents=n),e[t]=n,!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(t){let{canvas:n,resolution:r}=this.renderer;this.setTargetElement(n),this.resolution=r,e._defaultEventMode=t.eventMode??`passive`,Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){Jr.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||=`default`;let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;let 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;let t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!(`cancelable`in e))&&e.preventDefault();for(let e=0,n=t.length;e<n;e++){let n=t[e],r=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(r)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Jr.pointerMoved();let t=this._normalizeToPointerData(e);for(let e=0,n=t.length;e<n;e++){let n=this._bootstrapEvent(this._rootPointerEvent,t[e]);this.rootBoundary.mapEvent(n)}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]);let n=t===this.domElement?``:`outside`,r=this._normalizeToPointerData(e);for(let e=0,t=r.length;e<t;e++){let t=this._bootstrapEvent(this._rootPointerEvent,r[e]);t.type+=n,this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=this._normalizeToPointerData(e);for(let e=0,n=t.length;e<n;e++){let n=this._bootstrapEvent(this._rootPointerEvent,t[e]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;let t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,Jr.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Jr.addTickerListener();let 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;Jr.removeTickerListener();let 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){let r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},i=1/this.resolution;e.x=(t-r.left)*(this.domElement.width/r.width)*i,e.y=(n-r.top)*(this.domElement.height/r.height)*i}_normalizeToPointerData(e){let t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches[n];r.button===void 0&&(r.button=0),r.buttons===void 0&&(r.buttons=1),r.isPrimary===void 0&&(r.isPrimary=e.touches.length===1&&e.type===`touchstart`),r.width===void 0&&(r.width=r.radiusX||1),r.height===void 0&&(r.height=r.radiusY||1),r.tiltX===void 0&&(r.tiltX=0),r.tiltY===void 0&&(r.tiltY=0),r.pointerType===void 0&&(r.pointerType=`touch`),r.pointerId===void 0&&(r.pointerId=r.identifier||0),r.pressure===void 0&&(r.pressure=r.force||.5),r.twist===void 0&&(r.twist=0),r.tangentialPressure===void 0&&(r.tangentialPressure=0),r.layerX===void 0&&(r.layerX=r.offsetX=r.clientX),r.layerY===void 0&&(r.layerY=r.offsetY=r.clientY),r.isNormalized=!0,r.type=e.type,r.altKey??=e.altKey,r.ctrlKey??=e.ctrlKey,r.metaKey??=e.metaKey,r.shiftKey??=e.shiftKey,t.push(r)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){let n=e;n.isPrimary===void 0&&(n.isPrimary=!0),n.width===void 0&&(n.width=1),n.height===void 0&&(n.height=1),n.tiltX===void 0&&(n.tiltX=0),n.tiltY===void 0&&(n.tiltY=0),n.pointerType===void 0&&(n.pointerType=`mouse`),n.pointerId===void 0&&(n.pointerId=si),n.pressure===void 0&&(n.pressure=.5),n.twist===void 0&&(n.twist=0),n.tangentialPressure===void 0&&(n.tangentialPressure=0),n.isNormalized=!0,t.push(n)}else t.push(e);return t}normalizeWheelEvent(e){let 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=ci[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}},li.extension={name:`events`,type:[f.WebGLSystem,f.CanvasSystem,f.WebGPUSystem],priority:-1},li.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0},ui=li})),fi,pi=s((()=>{di(),ir(),fi={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(e){this.eventMode=e?`static`:`passive`},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??ui.defaultEventMode},set eventMode(e){this._internalEventMode=e},isInteractive(){return this.eventMode===`static`||this.eventMode===`dynamic`},interactiveChildren:!0,hitArea:null,addEventListener(e,t,n){let r=typeof n==`boolean`&&n||typeof n==`object`&&n.capture,i=typeof n==`object`?n.signal:void 0,a=typeof n==`object`&&n.once===!0,o=typeof t==`function`?void 0:t;e=r?`${e}capture`:e;let s=typeof t==`function`?t:t.handleEvent,c=this;i&&i.addEventListener(`abort`,()=>{c.off(e,s,o)}),a?c.once(e,s,o):c.on(e,s,o)},removeEventListener(e,t,n){let r=typeof n==`boolean`&&n||typeof n==`object`&&n.capture,i=typeof t==`function`?void 0:t;e=r?`${e}capture`:e,t=typeof t==`function`?t:t.handleEvent,this.off(e,t,i)},dispatchEvent(e){if(!(e instanceof rr))throw Error(`Container cannot propagate events outside of the Federated Events API`);return e.defaultPrevented=!1,e.path=null,e.target=this,e.manager.dispatchEvent(e),!e.defaultPrevented}}})),mi=s((()=>{g(),qn(),di(),pi(),h.add(ui),h.mixin(Kn,fi)})),hi,gi=s((()=>{hi=(e=>(e[e.Low=0]=`Low`,e[e.Normal=1]=`Normal`,e[e.High=2]=`High`,e))(hi||{})})),_i,vi=s((()=>{_i={createCanvas:(e,t)=>{let n=document.createElement(`canvas`);return n.width=e,n.height=t,n},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(e,t)=>fetch(e,t),parseXML:e=>new DOMParser().parseFromString(e,`text/xml`)}})),yi,B,V=s((()=>{vi(),yi=_i,B={get(){return yi},set(e){yi=e}}}));function bi(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received ${JSON.stringify(e)}`)}function xi(e){return e.split(`?`)[0].split(`#`)[0]}function Si(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ci(e,t,n){return e.replace(new RegExp(Si(t),`g`),n)}function wi(e,t){let n=``,r=0,i=-1,a=0,o=-1;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(!(i===s-1||a===1))if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}var Ti,Ei=s((()=>{V(),Ti={toPosix(e){return Ci(e,`\\`,`/`)},isUrl(e){return/^https?:/.test(this.toPosix(e))},isDataUrl(e){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(e)},isBlobUrl(e){return e.startsWith(`blob:`)},hasProtocol(e){return/^[^/:]+:/.test(this.toPosix(e))},getProtocol(e){bi(e),e=this.toPosix(e);let t=/^file:\/\/\//.exec(e);if(t)return t[0];let n=/^[^/:]+:\/{0,2}/.exec(e);return n?n[0]:``},toAbsolute(e,t,n){if(bi(e),this.isDataUrl(e)||this.isBlobUrl(e))return e;let r=xi(this.toPosix(t??B.get().getBaseUrl())),i=xi(this.toPosix(n??this.rootname(r)));return e=this.toPosix(e),e.startsWith(`/`)?Ti.join(i,e.slice(1)):this.isAbsolute(e)?e:this.join(r,e)},normalize(e){if(bi(e),e.length===0)return`.`;if(this.isDataUrl(e)||this.isBlobUrl(e))return e;e=this.toPosix(e);let t=``,n=e.startsWith(`/`);this.hasProtocol(e)&&(t=this.rootname(e),e=e.slice(t.length));let r=e.endsWith(`/`);return e=wi(e,!1),e.length>0&&r&&(e+=`/`),n?`/${e}`:t+e},isAbsolute(e){return bi(e),e=this.toPosix(e),this.hasProtocol(e)?!0:e.startsWith(`/`)},join(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n];if(bi(r),r.length>0)if(t===void 0)t=r;else{let i=e[n-1]??``;this.joinExtensions.includes(this.extname(i).toLowerCase())?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?`.`:this.normalize(t)},dirname(e){if(bi(e),e.length===0)return`.`;e=this.toPosix(e);let t=e.charCodeAt(0),n=t===47,r=-1,i=!0,a=this.getProtocol(e),o=e;e=e.slice(a.length);for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:this.isUrl(o)?a+e:a:n&&r===1?`//`:a+e.slice(0,r)},rootname(e){bi(e),e=this.toPosix(e);let t=``;if(t=e.startsWith(`/`)?`/`:this.getProtocol(e),this.isUrl(e)){let n=e.indexOf(`/`,t.length);t=n===-1?e:e.slice(0,n),t.endsWith(`/`)||(t+=`/`)}return t},basename(e,t){bi(e),t&&bi(t),e=xi(this.toPosix(e));let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)},extname(e){bi(e),e=xi(this.toPosix(e));let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},parse(e){bi(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;e=xi(this.toPosix(e));let n=e.charCodeAt(0),r=this.isAbsolute(e),i;t.root=this.rootname(e),i=r||this.hasProtocol(e)?1:0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),t.dir=this.dirname(e),t},sep:`/`,delimiter:`:`,joinExtensions:[`.html`]}})),Di,Oi=s((()=>{Di=(e,t,n=!1)=>(Array.isArray(e)||(e=[e]),t?e.map(e=>typeof e==`string`||n?t(e):e):e)}));function ki(e,t,n,r,i){let a=t[n];for(let o=0;o<a.length;o++){let s=a[o];n<t.length-1?ki(e.replace(r[n],s),t,n+1,r,i):i.push(e.replace(r[n],s))}}function Ai(e){let t=e.match(/\{(.*?)\}/g),n=[];if(t){let r=[];t.forEach(e=>{let t=e.substring(1,e.length-1).split(`,`);r.push(t)}),ki(e,r,0,t,n)}else n.push(e);return n}var ji=s((()=>{})),Mi,Ni=s((()=>{Mi=e=>!Array.isArray(e)}));function Pi(e){return e.split(`.`).pop().split(`?`).shift().split(`#`).shift()}var Fi,Ii=s((()=>{I(),Ei(),Oi(),ji(),Ni(),Fi=class{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 Error(`[Resolver] GenerateBundleAssetId are not working correctly`)}prefer(...e){e.forEach(e=>{this._preferredOrder.push(e),e.priority||=Object.keys(e.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{let t=e;this._defaultSearchParams=Object.keys(t).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join(`&`)}}getAlias(e){let{alias:t,src:n}=e;return Di(t||n,e=>typeof e==`string`?e:Array.isArray(e)?e.map(e=>e?.src??e):e?.src?e.src:e,!0)}removeAlias(e,t){this._assetMap[e]&&(t&&t!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&F(`[Resolver] Manifest already exists, this will be overwritten`),this._manifest=e,e.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(e,t){let n=[],r=t;Array.isArray(t)||(r=Object.entries(t).map(([e,t])=>typeof t==`string`||Array.isArray(t)?{alias:e,src:t}:{alias:e,...t})),r.forEach(t=>{let r=t.src,i=t.alias,a;if(typeof i==`string`){let t=this._createBundleAssetId(e,i);n.push(t),a=[i,t]}else{let t=i.map(t=>this._createBundleAssetId(e,t));n.push(...t),a=[...i,...t]}this.add({...t,alias:a,src:r})}),this._bundles[e]=n}add(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e);let n=e=>{this.hasKey(e)&&F(`[Resolver] already has key: ${e} overwriting`)};Di(t).forEach(e=>{let{src:t}=e,{data:r,format:i,loadParser:a,parser:o}=e,s=Di(t).map(e=>typeof e==`string`?Ai(e):Array.isArray(e)?e:[e]),c=this.getAlias(e);Array.isArray(c)?c.forEach(n):n(c);let l=[],u=e=>({src:e,...this._parsers.find(t=>t.test(e))?.parse(e)});s.forEach(t=>{t.forEach(t=>{let n={};if(typeof t==`object`?(r=t.data??r,i=t.format??i,(t.loadParser||t.parser)&&(a=t.loadParser??a,o=t.parser??o),n={...u(t.src),...t}):n=u(t),!c)throw Error(`[Resolver] alias is undefined for this asset: ${n.src}`);n=this._buildResolvedAsset(n,{aliases:c,data:r,format:i,loadParser:a,parser:o,progressSize:e.progressSize}),l.push(n)})}),c.forEach(e=>{this._assetMap[e]=l})})}resolveBundle(e){let t=Mi(e);e=Di(e);let n={};return e.forEach(e=>{let t=this._bundles[e];if(t){let r=this.resolve(t),i={};for(let t in r){let n=r[t];i[this._extractAssetIdFromBundle(e,t)]=n}n[e]=i}}),t?n[e[0]]:n}resolveUrl(e){let t=this.resolve(e);if(typeof e!=`string`){let e={};for(let n in t)e[n]=t[n].src;return e}return t.src}resolve(e){let t=Mi(e);e=Di(e);let n={};return e.forEach(e=>{if(!this._resolverHash[e])if(this._assetMap[e]){let t=this._assetMap[e],n=this._getPreferredOrder(t);n?.priority.forEach(e=>{n.params[e].forEach(n=>{let r=t.filter(t=>t[e]?t[e]===n:!1);r.length&&(t=r)})}),this._resolverHash[e]=t[0]}else this._resolverHash[e]=this._buildResolvedAsset({alias:[e],src:e},{});n[e]=this._resolverHash[e]}),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++){let n=e[t],r=this._preferredOrder.find(e=>e.params.format.includes(n.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(e){return this._defaultSearchParams?`${e}${/\?/.test(e)?`&`:`?`}${this._defaultSearchParams}`:e}_buildResolvedAsset(e,t){let{aliases:n,data:r,loadParser:i,parser:a,format:o,progressSize:s}=t;return(this._basePath||this._rootPath)&&(e.src=Ti.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=n??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...r||{},...e.data},e.loadParser=i??e.loadParser,e.parser=a??e.parser,e.format=o??e.format??Pi(e.src),s!==void 0&&(e.progressSize=s),e}},Fi.RETINA_PREFIX=/@([0-9\.]+)x/})),Li,Ri=s((()=>{Li=(e,t)=>{let n=t.split(`?`)[1];return n&&(e+=`?${n}`),e}})),zi,Bi,Vi=s((()=>{yt(),_n(),z(),zi=class e{constructor(e,t){this.linkedSheets=[];let n=e;e?.source instanceof gn&&(n={texture:e,data:t});let{texture:r,data:i,cachePrefix:a=``}=n;this.cachePrefix=a,this._texture=r instanceof R?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=i;let o=parseFloat(i.meta.scale);o?(this.resolution=o,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=e.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,n=!1){let r=t,i=n?1/0:e.BATCH_SIZE;for(;r-t<i&&r<this._frameKeys.length;){let e=this._frameKeys[r],t=this._frames[e],n=t.frame;if(n){let r=null,i=null,a=t.trimmed!==!1&&t.sourceSize?t.sourceSize:t.frame,o=new vt(0,0,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution);r=t.rotated?new vt(Math.floor(n.x)/this.resolution,Math.floor(n.y)/this.resolution,Math.floor(n.h)/this.resolution,Math.floor(n.w)/this.resolution):new vt(Math.floor(n.x)/this.resolution,Math.floor(n.y)/this.resolution,Math.floor(n.w)/this.resolution,Math.floor(n.h)/this.resolution),t.trimmed!==!1&&t.spriteSourceSize&&(i=new vt(Math.floor(t.spriteSourceSize.x)/this.resolution,Math.floor(t.spriteSourceSize.y)/this.resolution,Math.floor(n.w)/this.resolution,Math.floor(n.h)/this.resolution)),this.textures[e]=new R({source:this.textureSource,frame:r,orig:o,trim:i,rotate:t.rotated?2:0,defaultAnchor:t.anchor,defaultBorders:t.borders,label:e.toString()})}r++}}_processAnimations(){let e=this.data.animations||{};for(let t in e){this.animations[t]=[];for(let n=0;n<e[t].length;n++){let r=e[t][n];this.animations[t].push(this.textures[r])}}}_parseComplete(){let e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*e.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*e.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){for(let e in this.textures)this.textures[e].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}},zi.BATCH_SIZE=1e3,Bi=zi}));function Hi(e,t,n){let r={};if(e.forEach(e=>{r[e]=t}),Object.keys(t.textures).forEach(e=>{r[`${t.cachePrefix}${e}`]=t.textures[e]}),!n){let n=Ti.dirname(e[0]);t.linkedSheets.forEach((e,i)=>{let a=Hi([`${n}/${t.data.meta.related_multi_packs[i]}`],e,!0);Object.assign(r,a)})}return r}var Ui,Wi,Gi=s((()=>{gi(),Ii(),Ri(),g(),z(),Ei(),Vi(),Ui=[`jpg`,`png`,`jpeg`,`avif`,`webp`,`basis`,`etc2`,`bc7`,`bc6h`,`bc5`,`bc4`,`bc3`,`bc2`,`bc1`,`eac`,`astc`],Wi={extension:f.Asset,cache:{test:e=>e instanceof Bi,getCacheableAssets:(e,t)=>Hi(e,t,!1)},resolver:{extension:{type:f.ResolveParser,name:`resolveSpritesheet`},test:e=>{let t=e.split(`?`)[0].split(`.`),n=t.pop(),r=t.pop();return n===`json`&&Ui.includes(r)},parse:e=>{let t=e.split(`.`);return{resolution:parseFloat(Fi.RETINA_PREFIX.exec(e)?.[1]??`1`),format:t[t.length-2],src:e}}},loader:{name:`spritesheetLoader`,id:`spritesheet`,extension:{type:f.LoadParser,priority:hi.Normal,name:`spritesheetLoader`},async testParse(e,t){return Ti.extname(t.src).toLowerCase()===`.json`&&!!e.frames},async parse(e,t,n){let{texture:r,imageFilename:i,textureOptions:a,cachePrefix:o}=t?.data??{},s=Ti.dirname(t.src);s&&s.lastIndexOf(`/`)!==s.length-1&&(s+=`/`);let c;if(r instanceof R)c=r;else{let r=Li(s+(i??e.meta.image),t.src);c=(await n.load([{src:r,data:a}]))[r]}let l=new Bi({texture:c.source,data:e,cachePrefix:o});await l.parse();let u=e?.meta?.related_multi_packs;if(Array.isArray(u)){let e=[];for(let r of u){if(typeof r!=`string`)continue;let i=s+r;t.data?.ignoreMultiPack||(i=Li(i,t.src),e.push(n.load({src:i,data:{textureOptions:a,ignoreMultiPack:!0}})))}let r=await Promise.all(e);l.linkedSheets=r,r.forEach(e=>{e.linkedSheets=[l].concat(l.linkedSheets.filter(t=>t!==e))})}return l},async unload(e,t,n){await n.unload(e.textureSource._sourceOrigin),e.destroy(!1)}}}})),Ki=s((()=>{g(),Gi(),h.add(Wi)}));function qi(e,t,n){let{width:r,height:i}=n.orig,a=n.trim;if(a){let n=a.width,o=a.height;e.minX=a.x-t._x*r,e.maxX=e.minX+n,e.minY=a.y-t._y*i,e.maxY=e.minY+o}else e.minX=-t._x*r,e.maxX=e.minX+r,e.minY=-t._y*i,e.maxY=e.minY+i}var Ji=s((()=>{})),Yi,Xi=s((()=>{Le(),z(),Ji(),We(),Gr(),Yi=class e extends Wr{constructor(e=R.EMPTY){e instanceof R&&(e={texture:e});let{texture:t=R.EMPTY,anchor:n,roundPixels:r,width:i,height:a,...o}=e;super({label:`Sprite`,...o}),this.renderPipeId=`sprite`,this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Ie({_onUpdate:()=>{this.onViewUpdate()}}),n?this.anchor=n:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=r??!1,i!==void 0&&(this.width=i),a!==void 0&&(this.height=a)}static from(t,n=!1){return t instanceof R?new e(t):new e(R.from(t,n))}set texture(e){e||=R.EMPTY;let 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 qi(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return P(`8.6.1`,`Sprite.sourceBounds is deprecated, use visualBounds instead.`),this.visualBounds}updateBounds(){let e=this._anchor,t=this._texture,n=this._bounds,{width:r,height:i}=t.orig;n.minX=-e._x*r,n.maxX=n.minX+r,n.minY=-e._y*i,n.maxY=n.minY+i}destroy(e=!1){if(super.destroy(e),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._texture.destroy(t)}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.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??=e,e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}}));function Zi(e,t,n){let r=Qi;e.measurable=!0,kt(e,n,r),t.addBoundsMask(r),e.measurable=!1}var Qi,$i=s((()=>{St(),Mt(),Qi=new xt}));function ea(e,t,n){let r=wt.get();e.measurable=!0;let i=Ct.get().identity();Vt(e,r,ta(e,n,i)),e.measurable=!1,t.addBoundsMask(r),Ct.return(i),wt.return(r)}function ta(e,t,n){return e?(e!==t&&(ta(e.parent,t,n),e.updateLocalTransform(),n.append(e.localTransform)),n):(F(`Mask bounds, renderable is not inside the root container`),n)}var na=s((()=>{Ut(),Tt(),I()})),ra,ia=s((()=>{g(),Xi(),$i(),na(),ra=class{constructor(e){this.priority=0,this.inverse=!1,this.channel=`red`,this.pipe=`alphaMask`,e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof Yi),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||Zi(this.mask,e,t)}addLocalBounds(e,t){ea(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof Yi}},ra.extension=f.MaskEffect})),aa,oa=s((()=>{g(),aa=class{constructor(e){this.priority=0,this.pipe=`colorMask`,e?.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e==`number`}},aa.extension=f.MaskEffect})),sa,ca=s((()=>{g(),qn(),$i(),na(),sa=class{constructor(e){this.priority=0,this.pipe=`stencilMask`,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){Zi(this.mask,e,t)}addLocalBounds(e,t){ea(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof Kn}},sa.extension=f.MaskEffect})),la,ua=s((()=>{V(),g(),_n(),la=class extends gn{constructor(e){e.resource||=B.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){let r=super.resize(e,t,n);return r&&this.resizeCanvas(),r}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||=this.resource.getContext(`2d`)}},la.extension=f.TextureSource})),da,fa=s((()=>{g(),_n(),da=class extends gn{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}},da.extension=f.TextureSource}));async function pa(){return ma??=(async()=>{let e=B.get().createCanvas(1,1).getContext(`webgl`);if(!e)return`premultiply-alpha-on-upload`;let t=await new Promise(e=>{let t=document.createElement(`video`);t.onloadeddata=()=>e(t),t.onerror=()=>e(null),t.autoplay=!1,t.crossOrigin=`anonymous`,t.preload=`auto`,t.src=`data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=`,t.load()});if(!t)return`premultiply-alpha-on-upload`;let n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),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);let i=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,i),e.deleteFramebuffer(r),e.deleteTexture(n),e.getExtension(`WEBGL_lose_context`)?.loseContext(),i[0]<=i[3]?`premultiplied-alpha`:`premultiply-alpha-on-upload`})(),ma}var ma,ha=s((()=>{V()})),ga,_a,va=s((()=>{g(),er(),ha(),_n(),ga=class e extends gn{constructor(t){super(t),this.isReady=!1,this.uploadMethodId=`video`,t={...e.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.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),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){let e=$n.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;let 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 pa(),this._load=new Promise((n,r)=>{this.isValid?n(this):(this._resolve=n,this._reject=r,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(){let 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),void 0),this._mediaReady()}_mediaReady(){let 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();let 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&&($n.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||($n.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&($n.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}},ga.extension=f.TextureSource,ga.defaultOptions={...gn.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},ga.MIME_TYPES={ogv:`video/ogg`,mov:`video/quicktime`,m4v:`video/mp4`},_a=ga})),ya,H,ba=s((()=>{I(),Oi(),ya=class{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){let t=this._cache.get(e);return t||F(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){let n=Di(e),r;for(let e=0;e<this.parsers.length;e++){let i=this.parsers[e];if(i.test(t)){r=i.getCacheableAssets(n,t);break}}let i=new Map(Object.entries(r||{}));r||n.forEach(e=>{i.set(e,t)});let a=[...i.keys()],o={cacheKeys:a,keys:n};n.forEach(e=>{this._cacheMap.set(e,o)}),a.forEach(e=>{let n=r?r[e]:t;this._cache.has(e)&&this._cache.get(e)!==n&&F(`[Cache] already has key:`,e),this._cache.set(e,i.get(e))})}remove(e){if(!this._cacheMap.has(e)){F(`[Assets] Asset id ${e} was not found in the Cache`);return}let t=this._cacheMap.get(e);t.cacheKeys.forEach(e=>{this._cache.delete(e)}),t.keys.forEach(e=>{this._cacheMap.delete(e)})}get parsers(){return this._parsers}},H=new ya}));function xa(e={}){let t=e&&e.resource,n=t?e.resource:e,r=t?e:{resource:e};for(let e=0;e<wa.length;e++){let t=wa[e];if(t.test(n))return new t(r)}throw Error(`Could not find a source type for resource: ${r.resource}`)}function Sa(e={},t=!1){let n=e&&e.resource,r=n?e.resource:e,i=n?e:{resource:e};if(!t&&H.has(r))return H.get(r);let a=new R({source:xa(i)});return a.on(`destroy`,()=>{H.has(r)&&H.remove(r)}),t||H.set(r,a),a}function Ca(e,t=!1){return typeof e==`string`?H.get(e):e instanceof gn?new R({source:e}):Sa(e,t)}var wa,Ta=s((()=>{ba(),g(),_n(),z(),wa=[],h.handleByList(f.TextureSource,wa),R.from=Ca,gn.from=xa})),Ea=s((()=>{g(),ia(),oa(),ca(),An(),ua(),fa(),va(),Ta(),h.add(ra,aa,sa,_a,da,la,kn)}));function Da(e){let t=B.get().createCanvas(6,1),n=t.getContext(`2d`);return n.fillStyle=e,n.fillRect(0,0,6,1),t}function Oa(){if(ka!==void 0)return ka;try{let e=Da(`#ff00ff`),t=Da(`#ffff00`),n=B.get().createCanvas(6,1).getContext(`2d`);n.globalCompositeOperation=`multiply`,n.drawImage(e,0,0),n.drawImage(t,2,0);let r=n.getImageData(2,0,1,1);if(!r)ka=!1;else{let e=r.data;ka=e[0]===255&&e[1]===0&&e[2]===0}}catch{ka=!1}return ka}var ka,Aa=s((()=>{V()})),U,ja=s((()=>{we(),V(),En(),Aa(),U={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Oa(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:e=>{let t=e.source,n=t?.resource;if(!n)return null;let r=t.alphaMode===`premultiplied-alpha`,i=t.resourceWidth??t.pixelWidth,a=t.resourceHeight??t.pixelHeight,o=i!==t.pixelWidth||a!==t.pixelHeight;if(r){if((n instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&n instanceof OffscreenCanvas)&&!o)return n;let e=U._unpremultipliedCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){let e=U._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let r=B.get().createCanvas(t.pixelWidth,t.pixelHeight),i=r.getContext(`2d`),a=i.createImageData(t.pixelWidth,t.pixelHeight),o=a.data,s=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(t.format===`bgra8unorm`)for(let e=0;e<o.length&&e+3<s.length;e+=4)o[e]=s[e+2],o[e+1]=s[e+1],o[e+2]=s[e],o[e+3]=s[e+3];else o.set(s.subarray(0,o.length));return i.putImageData(a,0,0),U._canvasSourceCache.set(t,{canvas:r,resourceId:t._resourceId}),r}if(r){let e=B.get().createCanvas(t.pixelWidth,t.pixelHeight),r=e.getContext(`2d`,{willReadFrequently:!0});e.width=t.pixelWidth,e.height=t.pixelHeight,r.drawImage(n,0,0);let i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let e=0;e<a.length;e+=4){let t=a[e+3];if(t>0){let n=255/t;a[e]=Math.min(255,a[e]*n+.5),a[e+1]=Math.min(255,a[e+1]*n+.5),a[e+2]=Math.min(255,a[e+2]*n+.5)}}return r.putImageData(i,0,0),U._unpremultipliedCache.set(t,{canvas:e,resourceId:t._resourceId}),e}if(o){let e=U._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let r=B.get().createCanvas(t.pixelWidth,t.pixelHeight),i=r.getContext(`2d`);return r.width=t.pixelWidth,r.height=t.pixelHeight,i.drawImage(n,0,0),U._canvasSourceCache.set(t,{canvas:r,resourceId:t._resourceId}),r}return n},getTintedCanvas:(e,t)=>{let n=e.texture,r=A.shared.setValue(t).toHex(),i=n.tintCache||={},a=i[r],o=n.source._resourceId;if(a?.tintId===o)return a;let s=a&&`getContext`in a?a:B.get().createCanvas();if(U.tintMethod(n,t,s),s.tintId=o,U.convertTintToImage&&s.toDataURL!==void 0){let e=B.get().createImage();e.src=s.toDataURL(),e.tintId=o,i[r]=e}else i[r]=s;return i[r]},getTintedPattern:(e,t)=>{let n=A.shared.setValue(t).toHex(),r=e.patternCache||={},i=e.source._resourceId,a=r[n];return a?.tintId===i?a:(U.canvas||=B.get().createCanvas(),U.tintMethod(e,t,U.canvas),a=U.canvas.getContext(`2d`).createPattern(U.canvas,`repeat`),a.tintId=i,r[n]=a,a)},applyPatternTransform:(e,t,n=!0)=>{if(!t)return;let r=e;if(!r.setTransform)return;let i=globalThis.DOMMatrix;if(!i)return;let a=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);r.setTransform(n?a.inverse():a)},tintWithMultiply:(e,t,n)=>{let r=n.getContext(`2d`),i=e.frame.clone(),a=e.source._resolution??e.source.resolution??1,o=e.rotate;i.x*=a,i.y*=a,i.width*=a,i.height*=a;let s=L.isVertical(o),c=s?i.height:i.width,l=s?i.width:i.height;n.width=Math.ceil(c),n.height=Math.ceil(l),r.save(),r.fillStyle=A.shared.setValue(t).toHex(),r.fillRect(0,0,c,l),r.globalCompositeOperation=`multiply`;let u=U.getCanvasSource(e);if(!u){r.restore();return}o&&U._applyInverseRotation(r,o,i.width,i.height),r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.globalCompositeOperation=`destination-atop`,r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithOverlay:(e,t,n)=>{let r=n.getContext(`2d`),i=e.frame.clone(),a=e.source._resolution??e.source.resolution??1,o=e.rotate;i.x*=a,i.y*=a,i.width*=a,i.height*=a;let s=L.isVertical(o),c=s?i.height:i.width,l=s?i.width:i.height;n.width=Math.ceil(c),n.height=Math.ceil(l),r.save(),r.globalCompositeOperation=`copy`,r.fillStyle=A.shared.setValue(t).toHex(),r.fillRect(0,0,c,l),r.globalCompositeOperation=`destination-atop`;let u=U.getCanvasSource(e);if(!u){r.restore();return}o&&U._applyInverseRotation(r,o,i.width,i.height),r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithPerPixel:(e,t,n)=>{let r=n.getContext(`2d`),i=e.frame.clone(),a=e.source._resolution??e.source.resolution??1,o=e.rotate;i.x*=a,i.y*=a,i.width*=a,i.height*=a;let s=L.isVertical(o),c=s?i.height:i.width,l=s?i.width:i.height;n.width=Math.ceil(c),n.height=Math.ceil(l),r.save(),r.globalCompositeOperation=`copy`;let u=U.getCanvasSource(e);if(!u){r.restore();return}o&&U._applyInverseRotation(r,o,i.width,i.height),r.drawImage(u,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore();let d=t>>16&255,f=t>>8&255,p=t&255,m=r.getImageData(0,0,c,l),h=m.data;for(let e=0;e<h.length;e+=4)h[e]=h[e]*d/255,h[e+1]=h[e+1]*f/255,h[e+2]=h[e+2]*p/255;r.putImageData(m,0,0)},_applyInverseRotation:(e,t,n,r)=>{let i=L.inv(t),a=L.uX(i),o=L.uY(i),s=L.vX(i),c=L.vY(i),l=-Math.min(0,a*n,s*r,a*n+s*r),u=-Math.min(0,o*n,c*r,o*n+c*r);e.transform(a,o,s,c,l,u)}},U.tintMethod=U.canUseMultiply?U.tintWithMultiply:U.tintWithPerPixel})),Ma,Na,Pa=s((()=>{V(),sn(),Je(),Ma=class{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){let n=B.get().createCanvas();return n.width=e,n.height=t,{canvas:n,context:n.getContext(`2d`)}}getOptimalCanvasAndContext(e,t,n=1){e=Math.ceil(e*n-1e-6),t=Math.ceil(t*n-1e-6),e=an(e),t=an(t);let r=(e<<17)+(t<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let i=this._canvasPool[r].pop();return i||=this._createCanvasAndContext(e,t),i}returnCanvasAndContext(e){let{width:t,height:n}=e.canvas,r=(t<<17)+(n<<1);e.context.resetTransform(),e.context.clearRect(0,0,t,n),this._canvasPool[r].push(e)}clear(){this._canvasPool={}}},Na=new Ma,qe.register(Na)}));function Fa(e,t,n,r,i,a){let o=e-n,s=t-r,c=i-n,l=a-r,u=o*c+s*l,d=c*c+l*l,f=-1;d!==0&&(f=u/d);let p,m;f<0?(p=n,m=r):f>1?(p=i,m=a):(p=n+f*c,m=r+f*l);let h=e-p,g=t-m;return h*h+g*g}var Ia=s((()=>{})),La,Ra=s((()=>{yt(),La=class e{constructor(e=0,t=0,n=0){this.type=`circle`,this.x=e,this.y=t,this.radius=n}clone(){return new e(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;let n=this.radius*this.radius,r=this.x-e,i=this.y-t;return r*=r,i*=i,r+i<=n}strokeContains(e,t,n,r=.5){if(this.radius===0)return!1;let i=this.x-e,a=this.y-t,o=this.radius,s=(1-r)*n,c=Math.sqrt(i*i+a*a);return c<=o+s&&c>o-(n-s)}getBounds(e){return e||=new vt,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}]`}}})),za,Ba=s((()=>{yt(),za=class e{constructor(e=0,t=0,n=0,r=0){this.type=`ellipse`,this.x=e,this.y=t,this.halfWidth=n,this.halfHeight=r}clone(){return new e(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,r=(t-this.y)/this.halfHeight;return n*=n,r*=r,n+r<=1}strokeContains(e,t,n,r=.5){let{halfWidth:i,halfHeight:a}=this;if(i<=0||a<=0)return!1;let o=n*(1-r),s=n-o,c=i-s,l=a-s,u=i+o,d=a+o,f=e-this.x,p=t-this.y,m=f*f/(c*c)+p*p/(l*l),h=f*f/(u*u)+p*p/(d*d);return m>1&&h<=1}getBounds(e){return e||=new vt,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}]`}}})),Va,Ha,Ua,Wa=s((()=>{We(),Ia(),yt(),Ua=class e{constructor(...e){this.type=`polygon`;let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!=`number`){let e=[];for(let n=0,r=t.length;n<r;n++)e.push(t[n].x,t[n].y);t=e}this.points=t,this.closePath=!0}isClockwise(){let e=0,t=this.points,n=t.length;for(let r=0;r<n;r+=2){let i=t[r],a=t[r+1],o=t[(r+2)%n],s=t[(r+3)%n];e+=(o-i)*(s+a)}return e<0}containsPolygon(e){let t=this.getBounds(Va),n=e.getBounds(Ha);if(!t.containsRect(n))return!1;let r=e.points;for(let e=0;e<r.length;e+=2){let t=r[e],n=r[e+1];if(!this.contains(t,n))return!1}return!0}clone(){let t=this.points.slice(),n=new e(t);return n.closePath=this.closePath,n}contains(e,t){let n=!1,r=this.points.length/2;for(let i=0,a=r-1;i<r;a=i++){let r=this.points[i*2],o=this.points[i*2+1],s=this.points[a*2],c=this.points[a*2+1];o>t!=c>t&&e<(s-r)*((t-o)/(c-o))+r&&(n=!n)}return n}strokeContains(e,t,n,r=.5){let i=n*n,a=i*(1-r),o=i-a,{points:s}=this,c=s.length-(this.closePath?0:2);for(let n=0;n<c;n+=2){let r=s[n],i=s[n+1],c=s[(n+2)%s.length],l=s[(n+3)%s.length];if(Fa(e,t,r,i,c,l)<=(Math.sign((c-r)*(t-i)-(l-i)*(e-r))<0?o:a))return!0}return!1}getBounds(e){e||=new vt;let t=this.points,n=1/0,r=-1/0,i=1/0,a=-1/0;for(let e=0,o=t.length;e<o;e+=2){let o=t[e],s=t[e+1];n=o<n?o:n,r=o>r?o:r,i=s<i?s:i,a=s>a?s:a}return e.x=n,e.width=r-n,e.y=i,e.height=a-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 P(`8.11.0`,`Polygon.lastX is deprecated, please use Polygon.lastX instead.`),this.points[this.points.length-2]}get y(){return P(`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]}}})),Ga,Ka,qa=s((()=>{yt(),Ga=(e,t,n,r,i,a,o)=>{let s=e-n,c=t-r,l=Math.sqrt(s*s+c*c);return l>=i-a&&l<=i+o},Ka=class e{constructor(e=0,t=0,n=0,r=0,i=20){this.type=`roundedRectangle`,this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i}getBounds(e){return e||=new vt,e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new e(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){let 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 r=e-(this.x+n),i=t-(this.y+n),a=n*n;if(r*r+i*i<=a||(r=e-(this.x+this.width-n),r*r+i*i<=a)||(i=t-(this.y+this.height-n),r*r+i*i<=a)||(r=e-(this.x+n),r*r+i*i<=a))return!0}return!1}strokeContains(e,t,n,r=.5){let{x:i,y:a,width:o,height:s,radius:c}=this,l=n*(1-r),u=n-l,d=i+c,f=a+c,p=o-c*2,m=s-c*2,h=i+o,g=a+s;return(e>=i-l&&e<=i+u||e>=h-u&&e<=h+l)&&t>=f&&t<=f+m||(t>=a-l&&t<=a+u||t>=g-u&&t<=g+l)&&e>=d&&e<=d+p||e<d&&t<f&&Ga(e,t,d,f,c,u,l)||e>h-c&&t<f&&Ga(e,t,h-c,f,c,u,l)||e>h-c&&t>g-c&&Ga(e,t,h-c,g-c,c,u,l)||e<d&&t>g-c&&Ga(e,t,d,g-c,c,u,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}}));function Ja(e,t){t.clear();let n=t.matrix;for(let n=0;n<e.length;n++){let r=e[n];if(r.globalDisplayStatus<7)continue;let i=r.renderGroup??r.parentRenderGroup;i?.isCachedAsTexture?t.matrix=Ya.copyFrom(i.textureOffsetInverseTransform).append(r.worldTransform):i?._parentCacheAsTextureRenderGroup?t.matrix=Ya.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform):t.matrix=r.worldTransform,t.addBounds(r.bounds)}return t.matrix=n,t}var Ya,Xa=s((()=>{M(),Ya=new j}));function Za(e,t,n,r,i=!1){let a=Qa;a.minX=0,a.minY=0,a.maxX=e.width/r|0,a.maxY=e.height/r|0;let o=In.getOptimalTexture(a.width,a.height,r,!1,i);return o.source.uploadMethodId=`image`,o.source.resource=e,o.source.alphaMode=`premultiply-alpha-on-upload`,o.frame.width=t/r,o.frame.height=n/r,o.source.emit(`update`,o.source),o.updateUvs(),o}var Qa,$a=s((()=>{Ln(),St(),Qa=new xt}));function eo(e){return typeof e.getCanvasFilterString==`function`}var to,no,ro=s((()=>{g(),ja(),Pa(),St(),Xa(),$a(),to=class{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new xt,this.cssFilterString=``}},no=class{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let 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(e=>!e.enabled)){t.skip=!0;return}let r=[];for(let e of n){if(!e.enabled)continue;if(!eo(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();if(t===null){this._warnUnsupportedFilter(e);continue}t&&r.push(t)}if(r.length===0){t.skip=!0;return}t.cssFilterString=r.join(` `),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let i=this.renderer.canvasContext.activeContext,a=i.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){let e=this.renderer.canvasContext.activeResolution||1;i.save(),i.setTransform(1,0,0,1,0,0),i.beginPath(),i.rect(t.bounds.x*e,t.bounds.y*e,t.bounds.width*e,t.bounds.height*e),i.clip()}else t.useClip=!1;t.cssFilterString&&(i.filter=a===`none`?t.cssFilterString:`${a} ${t.cssFilterString}`)}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let n=this.renderer.canvasContext.activeContext;e.useClip?n.restore():n.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(e=>!e.enabled))return e;let n=[];for(let e of t){if(!e.enabled)continue;if(!eo(e)){this._warnUnsupportedFilter(e);continue}let t=e.getCanvasFilterString();if(t===null){this._warnUnsupportedFilter(e);continue}t&&n.push(t)}if(n.length===0)return e;let r=U.getCanvasSource(e);if(!r)return e;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.width,s=i.height,{canvas:c,context:l}=Na.getOptimalCanvasAndContext(o,s,a);l.setTransform(1,0,0,1,0,0),l.clearRect(0,0,c.width,c.height),n.length&&(l.filter=n.join(` `));let u=i.x*a,d=i.y*a,f=o*a,p=s*a;return l.drawImage(r,u,d,f,p,0,0,f,p),l.filter=`none`,l.globalAlpha=1,Za(c,o,s,a)}_calculateFilterArea(e,t){if(e.renderables?Ja(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){let n=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;n&&t.applyMatrix(n)}}_warnUnsupportedFilter(e){let t=e?.constructor?.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||=this._filterStack[this._filterStackIndex]=new to,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}},no.extension={type:[f.CanvasSystem],name:`filter`}})),io,ao=s((()=>{g(),io=class{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}},io.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`filter`}}));function oo(e,t){let n=co[e];return n===void 0&&(so[t]===void 0&&(so[t]=1),co[e]=n=so[t]++),n}var so,co,lo=s((()=>{so=Object.create(null),co=Object.create(null)}));function uo(){return(!fo||fo?.isContextLost())&&(fo=B.get().createCanvas().getContext(`webgl`,{})),fo}var fo,po=s((()=>{V()}));function mo(){if(!ho){ho=`mediump`;let e=uo();e&&e.getShaderPrecisionFormat&&(ho=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision?`highp`:`mediump`)}return ho}var ho,go=s((()=>{po()}));function _o(e,t,n){return t?e:n?(e=e.replace(`out vec4 finalColor;`,``),`
|
|
18
|
+
|
|
19
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
20
|
+
#define in varying
|
|
21
|
+
#define finalColor gl_FragColor
|
|
22
|
+
#define texture texture2D
|
|
23
|
+
#endif
|
|
24
|
+
${e}
|
|
25
|
+
`):`
|
|
26
|
+
|
|
27
|
+
#ifdef GL_ES // This checks if it is WebGL1
|
|
28
|
+
#define in attribute
|
|
29
|
+
#define out varying
|
|
30
|
+
#endif
|
|
31
|
+
${e}
|
|
32
|
+
`}var vo=s((()=>{}));function yo(e,t,n){let r=n?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(e.substring(0,9)!==`precision`){let i=n?t.requestedFragmentPrecision:t.requestedVertexPrecision;return i===`highp`&&r!==`highp`&&(i=`mediump`),`precision ${i} float;
|
|
33
|
+
${e}`}else if(r!==`highp`&&e.substring(0,15)===`precision highp`)return e.replace(`precision highp`,`precision mediump`);return e}var bo=s((()=>{}));function xo(e,t){return t?`#version 300 es
|
|
34
|
+
${e}`:e}var So=s((()=>{}));function Co(e,{name:t=`pixi-program`},n=!0){t=t.replace(/\s+/g,`-`),t+=n?`-fragment`:`-vertex`;let r=n?wo:To;return r[t]?(r[t]++,t+=`-${r[t]}`):r[t]=1,e.indexOf(`#define SHADER_NAME`)===-1?`${`#define SHADER_NAME ${t}`}
|
|
35
|
+
${e}`:e}var wo,To,Eo=s((()=>{wo={},To={}}));function Do(e,t){return t?e.replace(`#version 300 es`,``):e}var Oo=s((()=>{})),ko,Ao,jo,Mo,No=s((()=>{lo(),go(),vo(),bo(),So(),Eo(),Oo(),ko={stripVersion:Do,ensurePrecision:yo,addProgramDefines:_o,setProgramName:Co,insertVersion:xo},Ao=Object.create(null),jo=class e{constructor(t){t={...e.defaultOptions,...t};let n=t.fragment.indexOf(`#version 300 es`)!==-1,r={stripVersion:n,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:`highp`,maxSupportedFragmentPrecision:mo()},setProgramName:{name:t.name},addProgramDefines:n,insertVersion:n},i=t.fragment,a=t.vertex;Object.keys(ko).forEach(e=>{let t=r[e];i=ko[e](i,t,!0),a=ko[e](a,t,!1)}),this.fragment=i,this.vertex=a,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=oo(`${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,Ao[this._cacheKey]=null}static from(t){let n=`${t.vertex}:${t.fragment}`;return Ao[n]||(Ao[n]=new e(t),Ao[n]._cacheKey=n),Ao[n]}},jo.defaultOptions={preferredVertexPrecision:`highp`,preferredFragmentPrecision:`mediump`},Mo=jo}));function Po(e){return Fo[e]??Fo.float32}var Fo,Io=s((()=>{Fo={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 Lo(e,t){let n;for(;(n=Vo.exec(e))!==null;){let e=Bo[n[3]]??`float32`;t[n[2]]={location:parseInt(n[1],10),format:e,stride:Po(e).stride,offset:0,instance:!1,start:0}}Vo.lastIndex=0}function Ro(e){return e.replace(/\/\/.*$/gm,``).replace(/\/\*[\s\S]*?\*\//g,``)}function zo({source:e,entryPoint:t}){let n={},r=Ro(e),i=r.indexOf(`fn ${t}(`);if(i===-1)return n;let a=r.indexOf(`->`,i);if(a===-1)return n;let o=r.substring(i,a);if(Lo(o,n),Object.keys(n).length===0){let e=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(e){let t=e[1],i=RegExp(`struct\\s+${t}\\s*\\{([^}]+)\\}`,`s`),a=r.match(i);a&&Lo(a[1],n)}}return n}var Bo,Vo,Ho=s((()=>{Io(),Bo={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`},Vo=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g}));function Uo(e){let t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,r=/@binding\((\d+)\)/,i=/var(<[^>]+>)? (\w+)/,a=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,s=/(\w+)\s*:\s*([\w\<\>]+)/g,c=/struct\s+(\w+)/,l=e.match(t)?.map(e=>({group:parseInt(e.match(n)[1],10),binding:parseInt(e.match(r)[1],10),name:e.match(i)[2],isUniform:e.match(i)[1]===`<uniform>`,type:e.match(a)[1]}));return l?{groups:l,structs:e.match(o)?.map(e=>{let t=e.match(c)[1],n=e.match(s).reduce((e,t)=>{let[n,r]=t.split(`:`);return e[n.trim()]=r.trim(),e},{});return n?{name:t,members:n}:null}).filter(({name:e})=>l.some(t=>t.type===e||t.type.includes(`<${e}>`)))??[]}:{groups:[],structs:[]}}var Wo=s((()=>{})),Go,Ko=s((()=>{Go=(e=>(e[e.VERTEX=1]=`VERTEX`,e[e.FRAGMENT=2]=`FRAGMENT`,e[e.COMPUTE=4]=`COMPUTE`,e))(Go||{})}));function qo({groups:e}){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t[r.group]||(t[r.group]=[]),r.isUniform?t[r.group].push({binding:r.binding,visibility:Go.VERTEX|Go.FRAGMENT,buffer:{type:`uniform`}}):r.type===`sampler`?t[r.group].push({binding:r.binding,visibility:Go.FRAGMENT,sampler:{type:`filtering`}}):r.type===`texture_2d`||r.type.startsWith(`texture_2d<`)?t[r.group].push({binding:r.binding,visibility:Go.FRAGMENT,texture:{sampleType:`float`,viewDimension:`2d`,multisampled:!1}}):r.type===`texture_2d_array`||r.type.startsWith(`texture_2d_array<`)?t[r.group].push({binding:r.binding,visibility:Go.FRAGMENT,texture:{sampleType:`float`,viewDimension:`2d-array`,multisampled:!1}}):(r.type===`texture_cube`||r.type.startsWith(`texture_cube<`))&&t[r.group].push({binding:r.binding,visibility:Go.FRAGMENT,texture:{sampleType:`float`,viewDimension:`cube`,multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}var Jo=s((()=>{Ko()}));function Yo({groups:e}){let t=[];for(let n=0;n<e.length;n++){let r=e[n];t[r.group]||(t[r.group]={}),t[r.group][r.name]=r.binding}return t}var Xo=s((()=>{}));function Zo(e,t){let n=new Set,r=new Set;return{structs:[...e.structs,...t.structs].filter(e=>n.has(e.name)?!1:(n.add(e.name),!0)),groups:[...e.groups,...t.groups].filter(e=>{let t=`${e.name}-${e.binding}`;return r.has(t)?!1:(r.add(t),!0)})}}var Qo=s((()=>{})),$o,es,ts=s((()=>{lo(),Ho(),Wo(),Jo(),Xo(),Qo(),$o=Object.create(null),es=class e{constructor(e){this._layoutKey=0,this._attributeLocationsKey=0;let{fragment:t,vertex:n,layout:r,gpuLayout:i,name:a}=e;if(this.name=a,this.fragment=t,this.vertex=n,t.source===n.source){let e=Uo(t.source);this.structsAndGroups=e}else{let e=Uo(n.source),r=Uo(t.source);this.structsAndGroups=Zo(e,r)}this.layout=r??Yo(this.structsAndGroups),this.gpuLayout=i??qo(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){let{vertex:e,fragment:t}=this,n=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=oo(n,`program`)}get attributeData(){return this._attributeData??=zo(this.vertex),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,$o[this._cacheKey]=null}static from(t){let n=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return $o[n]||($o[n]=new e(t),$o[n]._cacheKey=n),$o[n]}}})),ns,rs=s((()=>{ns=class{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(let n in e){let r=e[n];this.setResource(r,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;let e=[],t=0;for(let n in this.resources)e[t++]=this.resources[n]._resourceId;this._key=e.join(`|`)}setResource(e,t){let n=this.resources[t];e!==n&&(n?.off?.(`change`,this.onResourceChange,this),e.on?.(`change`,this.onResourceChange,this),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e,t){let n=this.resources;for(let r in n)n[r]._gcLastUsed=e,n[r]._touched=t}destroy(){let e=this.resources;for(let t in e)e[t]?.off?.(`change`,this.onResourceChange,this);this.resources=null}onResourceChange(e){this._dirty=!0,e.destroyed?this.destroy():this._updateKey()}}})),is,as=s((()=>{is=(e=>(e[e.WEBGL=1]=`WEBGL`,e[e.WEBGPU=2]=`WEBGPU`,e[e.CANVAS=4]=`CANVAS`,e[e.BOTH=3]=`BOTH`,e))(is||{})})),os,ss,cs=s((()=>{os=[`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>`],ss=os.reduce((e,t)=>(e[t]=!0,e),{})}));function ls(e,t){switch(e){case`f32`:return 0;case`vec2<f32>`:return new Float32Array(2*t);case`vec3<f32>`:return new Float32Array(3*t);case`vec4<f32>`:return new Float32Array(4*t);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}var us=s((()=>{})),ds,fs,ps=s((()=>{Be(),lo(),cs(),us(),ds=class e{constructor(t,n){this._touched=0,this.uid=Re(`uniform`),this._resourceType=`uniformGroup`,this._resourceId=Re(`resource`),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,n={...e.defaultOptions,...n},this.uniformStructures=t;let r={};for(let e in t){let n=t[e];if(n.name=e,n.size=n.size??1,!ss[n.type]){let e=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(e){let[,t,r]=e;throw Error(`Uniform type ${n.type} is not supported. Use type: '${t}', size: ${r} instead.`)}throw Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${os.join(`, `)}`)}n.value??=ls(n.type,n.size),r[e]=n.value}this.uniforms=r,this._dirtyId=1,this.ubo=n.ubo,this.isStatic=n.isStatic,this._signature=oo(Object.keys(r).map(e=>`${e}-${t[e].type}`).join(`-`),`uniform-group`)}update(){this._dirtyId++}},ds.defaultOptions={ubo:!1,isStatic:!1},fs=ds})),ms,hs=s((()=>{b(),Be(),No(),rs(),ts(),as(),ps(),ms=class e extends y{constructor(e){super(),this.uid=Re(`shader`),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:n,groups:r,resources:i,compatibleRenderers:a,groupMap:o}=e;this.gpuProgram=t,this.glProgram=n,a===void 0&&(a=0,t&&(a|=is.WEBGPU),n&&(a|=is.WEBGL)),this.compatibleRenderers=a;let s={};if(!i&&!r&&(i={}),i&&r)throw Error(`[Shader] Cannot have both resources and groups`);if(!t&&r&&!o)throw Error(`[Shader] No group map or WebGPU shader provided - consider using resources instead.`);if(!t&&r&&o)for(let e in o)for(let t in o[e]){let n=o[e][t];s[n]={group:e,binding:t,name:n}}else if(t&&r&&!o){let e=t.structsAndGroups.groups;o={},e.forEach(e=>{o[e.group]=o[e.group]||{},o[e.group][e.binding]=e.name,s[e.name]=e})}else if(i){r={},o={},t&&t.structsAndGroups.groups.forEach(e=>{o[e.group]=o[e.group]||{},o[e.group][e.binding]=e.name,s[e.name]=e});let e=0;for(let t in i)s[t]||(r[99]||(r[99]=new ns,this._ownedBindGroups.push(r[99])),s[t]={group:99,binding:e,name:t},o[99]=o[99]||{},o[99][e]=t,e++);for(let e in i){let t=e,n=i[e];!n.source&&!n._resourceType&&(n=new fs(n));let a=s[t];a&&(r[a.group]||(r[a.group]=new ns,this._ownedBindGroups.push(r[a.group])),r[a.group].setResource(n,a.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,s)}addResource(e,t,n){var r,i;(r=this._uniformBindMap)[t]||(r[t]={}),(i=this._uniformBindMap[t])[n]||(i[n]=e),this.groups[t]||(this.groups[t]=new ns,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){let n={};for(let r in t){let i=t[r];Object.defineProperty(n,i.name,{get(){return e[i.group].getResource(i.binding)},set(t){e[i.group].setResource(t,i.binding)}})}return n}destroy(e=!1){this._destroyed||(this._destroyed=!0,this.emit(`destroy`,this),e&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(e=>{e.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){let{gpu:n,gl:r,...i}=t,a,o;return n&&(a=es.from(n)),r&&(o=Mo.from(r)),new e({gpuProgram:a,glProgram:o,...i})}}})),gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts=s((()=>{gs={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},_s=0,vs=1,ys=2,bs=3,xs=4,Ss=5,Cs=class e{constructor(){this.data=0,this.blendMode=`normal`,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<_s)}set blend(e){!!(this.data&1<<_s)!==e&&(this.data^=1<<_s)}get offsets(){return!!(this.data&1<<vs)}set offsets(e){!!(this.data&1<<vs)!==e&&(this.data^=1<<vs)}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<<ys)}set culling(e){!!(this.data&1<<ys)!==e&&(this.data^=1<<ys)}get depthTest(){return!!(this.data&1<<bs)}set depthTest(e){!!(this.data&1<<bs)!==e&&(this.data^=1<<bs)}get depthMask(){return!!(this.data&1<<Ss)}set depthMask(e){!!(this.data&1<<Ss)!==e&&(this.data^=1<<Ss)}get clockwiseFrontFace(){return!!(this.data&1<<xs)}set clockwiseFrontFace(e){!!(this.data&1<<xs)!==e&&(this.data^=1<<xs)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==`none`,this._blendMode=e,this._blendModeId=gs[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(){let t=new e;return t.depthTest=!1,t.blend=!0,t}},Cs.default2d=Cs.for2d(),ws=Cs})),Es,Ds,Os=s((()=>{No(),ts(),hs(),Ts(),Es=class e extends ms{constructor(t){t={...e.defaultOptions,...t},super(t),this.enabled=!0,this._state=ws.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias==`boolean`?this.antialias=t.antialias?`on`:`off`:this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource(`uTexture`,0,1),t.blendRequired&&this.addResource(`uBackTexture`,0,3)}apply(e,t,n,r){e.applyFilter(this,t,n,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(t){let{gpu:n,gl:r,...i}=t,a,o;return n&&(a=es.from(n)),r&&(o=Mo.from(r)),new e({gpuProgram:a,glProgram:o,...i})}},Es.defaultOptions={blendMode:`normal`,resolution:1,padding:0,antialias:`off`,blendRequired:!1,clipToViewport:!0},Ds=Es})),ks,As=s((()=>{ks=`in vec2 aPosition;
|
|
36
|
+
out vec2 vTextureCoord;
|
|
37
|
+
|
|
38
|
+
uniform vec4 uInputSize;
|
|
39
|
+
uniform vec4 uOutputFrame;
|
|
40
|
+
uniform vec4 uOutputTexture;
|
|
41
|
+
|
|
42
|
+
vec4 filterVertexPosition( void )
|
|
43
|
+
{
|
|
44
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
45
|
+
|
|
46
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
47
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
48
|
+
|
|
49
|
+
return vec4(position, 0.0, 1.0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
vec2 filterTextureCoord( void )
|
|
53
|
+
{
|
|
54
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void main(void)
|
|
58
|
+
{
|
|
59
|
+
gl_Position = filterVertexPosition();
|
|
60
|
+
vTextureCoord = filterTextureCoord();
|
|
61
|
+
}
|
|
62
|
+
`})),js,Ms=s((()=>{js=`in vec2 vTextureCoord;
|
|
63
|
+
out vec4 finalColor;
|
|
64
|
+
uniform sampler2D uTexture;
|
|
65
|
+
void main() {
|
|
66
|
+
finalColor = texture(uTexture, vTextureCoord);
|
|
67
|
+
}
|
|
68
|
+
`})),Ns,Ps=s((()=>{Ns=`struct GlobalFilterUniforms {
|
|
69
|
+
uInputSize: vec4<f32>,
|
|
70
|
+
uInputPixel: vec4<f32>,
|
|
71
|
+
uInputClamp: vec4<f32>,
|
|
72
|
+
uOutputFrame: vec4<f32>,
|
|
73
|
+
uGlobalFrame: vec4<f32>,
|
|
74
|
+
uOutputTexture: vec4<f32>,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
|
|
78
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
79
|
+
@group(0) @binding(2) var uSampler: sampler;
|
|
80
|
+
|
|
81
|
+
struct VSOutput {
|
|
82
|
+
@builtin(position) position: vec4<f32>,
|
|
83
|
+
@location(0) uv: vec2<f32>
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
|
|
87
|
+
{
|
|
88
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
89
|
+
|
|
90
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
91
|
+
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
92
|
+
|
|
93
|
+
return vec4(position, 0.0, 1.0);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
|
|
97
|
+
{
|
|
98
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@vertex
|
|
102
|
+
fn mainVertex(
|
|
103
|
+
@location(0) aPosition: vec2<f32>,
|
|
104
|
+
) -> VSOutput {
|
|
105
|
+
return VSOutput(
|
|
106
|
+
filterVertexPosition(aPosition),
|
|
107
|
+
filterTextureCoord(aPosition)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@fragment
|
|
112
|
+
fn mainFragment(
|
|
113
|
+
@location(0) uv: vec2<f32>,
|
|
114
|
+
) -> @location(0) vec4<f32> {
|
|
115
|
+
return textureSample(uTexture, uSampler, uv);
|
|
116
|
+
}
|
|
117
|
+
`})),Fs,Is=s((()=>{No(),ts(),Os(),As(),Ms(),Ps(),Fs=class extends Ds{constructor(){let e=es.from({vertex:{source:Ns,entryPoint:`mainVertex`},fragment:{source:Ns,entryPoint:`mainFragment`},name:`passthrough-filter`}),t=Mo.from({vertex:ks,fragment:js,name:`passthrough-filter`});super({gpuProgram:e,glProgram:t})}}})),Ls,Rs=s((()=>{Ls=(e=>(e[e.MAP_READ=1]=`MAP_READ`,e[e.MAP_WRITE=2]=`MAP_WRITE`,e[e.COPY_SRC=4]=`COPY_SRC`,e[e.COPY_DST=8]=`COPY_DST`,e[e.INDEX=16]=`INDEX`,e[e.VERTEX=32]=`VERTEX`,e[e.UNIFORM=64]=`UNIFORM`,e[e.STORAGE=128]=`STORAGE`,e[e.INDIRECT=256]=`INDIRECT`,e[e.QUERY_RESOLVE=512]=`QUERY_RESOLVE`,e[e.STATIC=1024]=`STATIC`,e))(Ls||{})})),zs,Bs=s((()=>{b(),Be(),Rs(),zs=class extends y{constructor(e){let{data:t,size:n}=e,{usage:r,label:i,shrinkToFit:a}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=Re(`buffer`),this._resourceType=`buffer`,this._resourceId=Re(`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??=t?.byteLength;let o=!!t;this.descriptor={size:n,usage:r,mappedAtCreation:o,label:i},this.shrinkToFit=a??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||=new Int32Array(this.data.buffer),this._dataInt32}get static(){return!!(this.descriptor.usage&Ls.STATIC)}set static(e){e?this.descriptor.usage|=Ls.STATIC:this.descriptor.usage&=~Ls.STATIC}setDataWithSize(e,t,n){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){n&&this.emit(`update`,this);return}let r=this._data;if(this._data=e,this._dataInt32=null,!r||r.length!==e.length){!this.shrinkToFit&&r&&e.byteLength<r.byteLength?n&&this.emit(`update`,this):(this.descriptor.size=e.byteLength,this._resourceId=Re(`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(){this.emit(`unload`,this);for(let e in this._gpuData)this._gpuData[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()}}}));function Vs(e,t){if(!(e instanceof zs)){let n=t?Ls.INDEX:Ls.VERTEX;e instanceof Array&&(t?(e=new Uint32Array(e),n=Ls.INDEX|Ls.COPY_DST):(e=new Float32Array(e),n=Ls.VERTEX|Ls.COPY_DST)),e=new zs({data:e,label:t?`index-mesh-buffer`:`vertex-mesh-buffer`,usage:n})}return e}var Hs=s((()=>{Bs(),Rs()}));function Us(e,t,n){let r=e.getAttribute(t);if(!r)return n.minX=0,n.minY=0,n.maxX=0,n.maxY=0,n;let i=r.buffer.data,a=1/0,o=1/0,s=-1/0,c=-1/0,l=i.BYTES_PER_ELEMENT,u=(r.offset||0)/l,d=(r.stride||8)/l;for(let e=u;e<i.length;e+=d){let t=i[e],n=i[e+1];t>s&&(s=t),n>c&&(c=n),t<a&&(a=t),n<o&&(o=n)}return n.minX=a,n.minY=o,n.maxX=s,n.maxY=c,n}var Ws=s((()=>{}));function Gs(e){return(e instanceof zs||Array.isArray(e)||e.BYTES_PER_ELEMENT)&&(e={buffer:e}),e.buffer=Vs(e.buffer,!1),e}var Ks,qs=s((()=>{b(),St(),Be(),Bs(),Hs(),Ws(),Ks=class extends y{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Re(`geometry`),this._layoutKey=0,this.instanceCount=1,this._bounds=new xt,this._boundsDirty=!0;let{attributes:t,indexBuffer:n,topology:r}=e;if(this.buffers=[],this.attributes={},t)for(let e in t)this.addAttribute(e,t[e]);this.instanceCount=e.instanceCount??1,n&&this.addIndex(n),this.topology=r||`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(let e in this.attributes){let t=this.attributes[e];return t.buffer.data.length/(t.stride/4||t.size)}return 0}addAttribute(e,t){let n=Gs(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=Vs(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,Us(this,`aPosition`,this._bounds)):this._bounds}unload(){this.emit(`unload`,this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){this.emit(`destroy`,this),this.removeAllListeners(),e&&this.buffers.forEach(e=>e.destroy()),this.unload(),this.indexBuffer?.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}})),Js,Ys,Xs,Zs=s((()=>{g(),Is(),M(),rs(),qs(),ps(),z(),Ln(),as(),St(),Xa(),I(),Js=new Ks({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])}),Ys=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new xt,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}},Xs=class{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new fs({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 ns({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,n=e.filterEffect.filters,r=this._pushFilterData();r.skip=!1,r.filters=n,r.container=e.container,r.outputRenderSurface=t.renderTarget.renderSurface;let i=t.renderTarget.renderTarget.colorTexture.source,a=i.resolution,o=i.antialias;if(n.every(e=>!e.enabled)){r.skip=!0;return}let s=r.bounds;if(this._calculateFilterArea(e,s),this._calculateFilterBounds(r,t.renderTarget.rootViewPort,o,a,1),r.skip)return;let c=this._getPreviousFilterData(),l=this._findFilterResolution(a),u=0,d=0;c&&(u=c.bounds.minX,d=c.bounds.minY),this._calculateGlobalFrame(r,u,d,l,i.width,i.height),this._setupFilterTextures(r,s,t,c)}generateFilteredTexture({texture:e,filters:t}){let n=this._pushFilterData();this._activeFilterData=n,n.skip=!1,n.filters=t;let r=e.source,i=r.resolution,a=r.antialias;if(t.every(e=>!e.enabled))return n.skip=!0,e;let o=n.bounds;if(o.addRect(e.frame),this._calculateFilterBounds(n,o.rectangle,a,i,0),n.skip)return e;let s=i;this._calculateGlobalFrame(n,0,0,s,r.width,r.height),n.outputRenderSurface=In.getOptimalTexture(o.width,o.height,n.resolution,n.antialias),n.backTexture=R.EMPTY,n.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(n,!0);let c=n.outputRenderSurface;return c.source.alphaMode=`premultiplied-alpha`,c}pop(){let e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&In.returnTexture(t.backTexture),In.returnTexture(t.inputTexture))}getBackTexture(e,t,n){let r=e.colorTexture.source._resolution,i=In.getOptimalTexture(t.width,t.height,r,!1),a=t.minX,o=t.minY;n&&(a-=n.minX,o-=n.minY),a=Math.floor(a*r),o=Math.floor(o*r);let s=Math.ceil(t.width*r),c=Math.ceil(t.height*r);return this.renderer.renderTarget.copyToTexture(e,i,{x:a,y:o},{width:s,height:c},{x:0,y:0}),i}applyFilter(e,t,n,r){let i=this.renderer,a=this._activeFilterData,o=a.outputRenderSurface===n,s=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(s),l=0,u=0;if(o){let e=this._findPreviousFilterOffset();l=e.x,u=e.y}this._updateFilterUniforms(t,n,a,l,u,c,o,r);let d=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,t,i)}calculateSpriteMatrix(e,t){let n=this._activeFilterData,r=e.set(n.inputTexture._source.width,0,0,n.inputTexture._source.height,n.bounds.minX,n.bounds.minY),i=t.worldTransform.copyTo(j.shared),a=t.renderGroup||t.parentRenderGroup;return a&&a.cacheToLocalTransform&&i.prepend(a.cacheToLocalTransform),i.invert(),r.prepend(i),r.scale(1/t.texture.orig.width,1/t.texture.orig.height),r.translate(t.anchor.x,t.anchor.y),r}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??=new Fs,this._passthroughFilter}_setupBindGroupsAndRender(e,t,n){if(n.renderPipes.uniformBatch){let e=n.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(e,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:Js,shader:e,state:e._state,topology:`triangle-list`}),n.type===is.WEBGL&&n.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,n,r){if(e.backTexture=R.EMPTY,e.inputTexture=In.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){n.renderTarget.finishRenderPass();let i=n.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(i,t,r?.bounds)}n.renderTarget.bind(e.inputTexture,!0),n.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,n,r,i,a){let o=e.globalFrame;o.x=t*r,o.y=n*r,o.width=i*r,o.height=a*r}_updateFilterUniforms(e,t,n,r,i,a,o,s){let c=this._filterGlobalUniforms.uniforms,l=c.uOutputFrame,u=c.uInputSize,d=c.uInputPixel,f=c.uInputClamp,p=c.uGlobalFrame,m=c.uOutputTexture;o?(l[0]=n.bounds.minX-r,l[1]=n.bounds.minY-i):(l[0]=0,l[1]=0),l[2]=e.frame.width,l[3]=e.frame.height,u[0]=e.source.width,u[1]=e.source.height,u[2]=1/u[0],u[3]=1/u[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*u[2]-.5*d[2],f[3]=e.frame.height*u[3]-.5*d[3];let h=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=r*a,p[1]=i*a,p[2]=h.source.width*a,p[3]=h.source.height*a,t instanceof R&&(t.source.resource=null);let g=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!s),t instanceof R?(m[0]=t.frame.width,m[1]=t.frame.height):(m[0]=g.width,m[1]=g.height),m[2]=g.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--;let r=this._filterStack[n];if(!r.skip){e=r.bounds.minX,t=r.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?Ja(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){let n=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;n&&t.applyMatrix(n)}}_applyFiltersToTexture(e,t){let n=e.inputTexture,r=e.bounds,i=e.filters,a=e.firstEnabledIndex,o=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),a===o)i[a].apply(this,n,e.outputRenderSurface,t);else{let n=e.inputTexture,s=In.getOptimalTexture(r.width,r.height,n.source._resolution,!1),c=s;for(let e=a;e<o;e++){let t=i[e];if(!t.enabled)continue;t.apply(this,n,c,!0);let r=n;n=c,c=r}i[o].apply(this,n,e.outputRenderSurface,t),In.returnTexture(s)}}_calculateFilterBounds(e,t,n,r,i){let a=this.renderer,o=e.bounds,s=e.filters,c=1/0,l=0,u=!0,d=!1,f=!1,p=!0,m=-1,h=-1;for(let e=0;e<s.length;e++){let t=s[e];if(t.enabled){if(m===-1&&(m=e),h=e,c=Math.min(c,t.resolution===`inherit`?r:t.resolution),l+=t.padding,t.antialias===`off`?u=!1:t.antialias===`inherit`&&(u&&=n),t.clipToViewport||(p=!1),!(t.compatibleRenderers&a.type)){f=!1;break}if(t.blendRequired&&!(a.backBuffer?.useBackBuffer??!0)){F("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,d||=t.blendRequired}}if(!f){e.skip=!0;return}if(p&&o.fitBounds(0,t.width/r,0,t.height/r),o.scale(c).ceil().scale(1/c).pad((l|0)*i),!o.isPositive){e.skip=!0;return}e.antialias=u,e.resolution=c,e.blendRequired=d,e.firstEnabledIndex=m,e.lastEnabledIndex=h}_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||=this._filterStack[this._filterStackIndex]=new Ys,this._filterStackIndex++,e}},Xs.extension={type:[f.WebGLSystem,f.WebGPUSystem],name:`filter`}})),Qs=s((()=>{g(),ro(),ao(),Zs(),h.add(Xs,no),h.add(io)})),$s=l({}),ec=s((()=>{Vr(),Kr(),mi(),Ki(),Ea(),Qs()}));g();let tc={extension:{type:f.Environment,name:`browser`,priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>(ec(),$s))}};var nc=l({}),rc=s((()=>{Ki(),Ea(),Qs()}));g();let ic={extension:{type:f.Environment,name:`webworker`,priority:0},test:()=>typeof self<`u`&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(rc(),nc))}};async function ac(e){if(!e)for(let e=0;e<oc.length;e++){let t=oc[e];if(t.value.test()){await t.value.load();return}}}var oc,sc=s((()=>{g(),oc=[],h.handleByNamedList(f.Environment,oc)}));function cc(){if(typeof lc==`boolean`)return lc;try{lc=Function(`param1`,`param2`,`param3`,`return param1[param2] === param3;`)({a:`b`},`a`,`b`)===!0}catch{lc=!1}return lc}var lc,uc=s((()=>{}));function dc(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length;Jc.size&&Jc.clear();let a=fc(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s=0,c=0,l=0;if(r&&(a=yc(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return mc(a,o,s,c,l),o}function fc(e,t,n,r,i){let a=null;if(i===qc(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=Wc(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=Wc(i/r|0,e[i],e[i+1],a);return a&&Lc(a,a.next)&&(Gc(a),a=a.next),a}function pc(e,t=e){let n=t===e,r=e,i;do i=!1,r!==r.next&&(Jc.size===0||!Jc.has(r))&&(Lc(r,r.next)||Ic(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),Yc=!0,Gc(r),r=r.prev,i=!0):(n||r!==t)&&(r=r.next,i=!n);while(i||r!==t);return t}function mc(e,t,n,r,i){i&&kc(e,n,r,i);let a=e,o=!1;for(;e.prev!==e.next;){let s=e.prev,c=e.next;if(Ic(s,e,c)<0&&(i?gc(e,n,r,i):hc(e))){t.push(s.i,e.i,c.i),Gc(e),e=c,a=c;continue}if(e=c,e===a){if(Yc=!1,e=pc(e),Yc){a=e;continue}if(!o){e=_c(e,t),a=e,o=!0;continue}vc(e,t,n,r,i);break}}}function hc(e){let t=e.prev,n=e,r=e.next,i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&!(i===m.x&&s===m.y)&&Pc(i,s,a,c,o,l,m.x,m.y)&&Ic(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function gc(e,t,n,r){let i=e.prev,a=e,o=e.next,s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=Mc(p,m,t,n,r),v=Mc(h,g,t,n,r),y=e.prevZ;for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==o&&!(s===y.x&&u===y.y)&&Pc(s,u,c,d,l,f,y.x,y.y)&&Ic(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let b=e.nextZ;for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==o&&!(s===b.x&&u===b.y)&&Pc(s,u,c,d,l,f,b.x,b.y)&&Ic(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function _c(e,t){let n=e,r=!1;do{let i=n.prev,a=n.next.next;Rc(i,n,n.next,a,!1)&&Vc(i,a)&&Vc(a,i)&&(t.push(i.i,n.i,a.i),Gc(n),Gc(n.next),n=e=a,r=!0),n=n.next}while(n!==e);return r?pc(n):n}function vc(e,t,n,r,i){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Fc(a,e)){let o=Uc(a,e);a=pc(a,a.next),o=pc(o,o.next),mc(a,t,n,r,i),mc(o,t,n,r,i);return}e=e.next}a=a.next}while(a!==e)}function yc(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=fc(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&Jc.add(o),i.push(Nc(o))}i.sort(bc),Sc(e.length/r,t.length),Cc(n,n),Xc=!0;for(let e=0;e<i.length;e++)n=xc(i[e],n);return Xc=!1,pc(n)}function bc(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function xc(e,t){let n=Dc(e,t);if(!n)return t;let r=Uc(n,e),i=r.next;return Cc(n,i.next),pc(r,r.next),pc(n,n.next)}function Sc(e,t){let n=Math.ceil((e+2*t)/Zc)+t+2;Qc.length<n*4&&(Qc=new Float64Array(n*4)),$c=0}function Cc(e,t){let n=e;do{let e=$c++;el[e]=n;let r=1/0,i=1/0,a=-1/0,o=-1/0,s=0;do{let t=n.next;n.z=e,n.x<r&&(r=n.x),n.x>a&&(a=n.x),n.y<i&&(i=n.y),n.y>o&&(o=n.y),t.x<r&&(r=t.x),t.x>a&&(a=t.x),t.y<i&&(i=t.y),t.y>o&&(o=t.y),n=t}while(++s<Zc&&n!==t);tl[e]=n;let c=e*4;Qc[c]=r,Qc[c+1]=i,Qc[c+2]=a,Qc[c+3]=o}while(n!==t)}function wc(e,t){let n=e.z*4;t.x<Qc[n]&&(Qc[n]=t.x),t.y<Qc[n+1]&&(Qc[n+1]=t.y),t.x>Qc[n+2]&&(Qc[n+2]=t.x),t.y>Qc[n+3]&&(Qc[n+3]=t.y)}function Tc(e){let t=tl[e];for(;t.prev.next!==t;)t=t.next;return tl[e]=t,t}function Ec(e){let t=el[e];for(;t.prev.next!==t;)t=t.next;return el[e]=t,t}function Dc(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(Lc(e,n))return n;for(let t=0,s=0;t<$c;t++,s+=4){if(i<Qc[s+1]||i>Qc[s+3]||Qc[s]>r||Qc[s+2]<=a)continue;let c=Tc(t);n=Ec(t);do{if(n.prev.next===n){if(Lc(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}}n=n.next}while(n!==c)}if(!o)return null;let s=o.x,c=o.y,l=Math.min(i,c),u=Math.max(i,c),d=1/0;for(let t=0,f=0;t<$c;t++,f+=4){if(Qc[f+2]<s||Qc[f]>r||Qc[f+3]<l||Qc[f+1]>u)continue;let p=Tc(t);n=Ec(t);do{if(n.prev.next===n&&r>=n.x&&n.x>=s&&r!==n.x&&Pc(i<c?r:a,i,s,c,i<c?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);(Vc(n,e)||n.y===i&&n.next.y===i&&n.next.x>r)&&(t<d||t===d&&(n.x>o.x||n.x===o.x&&Oc(o,n)))&&(o=n,d=t)}n=n.next}while(n!==p)}return o}function Oc(e,t){return Ic(e.prev,e,t.prev)<0&&Ic(t.next,e,e.next)<0}function kc(e,t,n,r){let i=e,a=0;do i.z=Mc(i.x,i.y,t,n,r),nl[a++]=i,i=i.next;while(i!==e);Ac(a);let o=null;for(let e=0;e<a;e++){let t=nl[e];t.prevZ=o,o&&(o.nextZ=t),o=t}o.nextZ=null}function Ac(e){if(e<=32){for(let t=1;t<e;t++){let e=nl[t],n=e.z,r=t-1;for(;r>=0&&nl[r].z>n;)nl[r+1]=nl[r],r--;nl[r+1]=e}return}il.length<e&&(il=new Uint32Array(e),al=new Uint32Array(e),rl=Array(e));for(let t=0;t<e;t++)il[t]=nl[t].z;jc(e,nl,il,rl,al,0),jc(e,rl,al,nl,il,8),jc(e,nl,il,rl,al,16),jc(e,rl,al,nl,il,24)}function jc(e,t,n,r,i,a){ol.fill(0);for(let t=0;t<e;t++)ol[n[t]>>>a&255]++;let o=0;for(let e=0;e<256;e++){let t=ol[e];ol[e]=o,o+=t}for(let o=0;o<e;o++){let e=n[o],s=ol[e>>>a&255]++;r[s]=t[o],i[s]=e}}function Mc(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Nc(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Pc(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function Fc(e,t){let n=Lc(e,t)&&Ic(e.prev,e,e.next)>0&&Ic(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||Vc(e,t)&&Vc(t,e)&&(Ic(e.prev,e,t.prev)!==0||Ic(e,t.prev,t)!==0))&&!Bc(e,t)&&(n||Hc(e,t))}function Ic(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Lc(e,t){return e.x===t.x&&e.y===t.y}function Rc(e,t,n,r,i=!0){let a=Ic(e,t,n),o=Ic(e,t,r),s=Ic(n,r,e),c=Ic(n,r,t);return(a>0&&o<0||a<0&&o>0)&&(s>0&&c<0||s<0&&c>0)?!0:i?!!(a===0&&zc(e,n,t)||o===0&&zc(e,r,t)||s===0&&zc(n,e,r)||c===0&&zc(n,t,r)):!1}function zc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Bc(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=e;do{let s=o.next;if(o.x>r&&s.x>r||o.x<n&&s.x<n||o.y>a&&s.y>a||o.y<i&&s.y<i){o=s;continue}if(o.i!==e.i&&s.i!==e.i&&o.i!==t.i&&s.i!==t.i&&Rc(o,s,e,t))return!0;o=s}while(o!==e);return!1}function Vc(e,t){return Ic(e.prev,e,e.next)<0?Ic(e,t,e.next)>=0&&Ic(e,e.prev,t)>=0:Ic(e,t,e.prev)<0||Ic(e,e.next,t)<0}function Hc(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{let e=n.next;n.y>a!=e.y>a&&i<(e.x-n.x)*(a-n.y)/(e.y-n.y)+n.x&&(r=!r),n=e}while(n!==e);return r}function Uc(e,t){let n=Kc(e.i,e.x,e.y),r=Kc(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Wc(e,t,n,r){let i=Kc(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Gc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),Xc&&wc(e.prev,e.next)}function Kc(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function qc(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}var Jc,Yc,Xc,Zc,Qc,$c,el,tl,nl,rl,il,al,ol,sl=s((()=>{Jc=new Set,Yc=!1,Xc=!1,Zc=16,Qc=new Float64Array,$c=0,el=[],tl=[],nl=[],rl=[],il=new Uint32Array,al=new Uint32Array,ol=new Uint32Array(256)})),cl,ll=s((()=>{sl(),b(),cl=dc.default||dc})),ul,dl=s((()=>{ul=(e=>(e[e.NONE=0]=`NONE`,e[e.COLOR=16384]=`COLOR`,e[e.STENCIL=1024]=`STENCIL`,e[e.DEPTH=256]=`DEPTH`,e[e.COLOR_DEPTH=16640]=`COLOR_DEPTH`,e[e.COLOR_STENCIL=17408]=`COLOR_STENCIL`,e[e.DEPTH_STENCIL=1280]=`DEPTH_STENCIL`,e[e.ALL=17664]=`ALL`,e))(ul||{})})),fl,pl=s((()=>{fl=class{constructor(e){this.items=[],this._name=e}emit(e,t,n,r,i,a,o,s){let{name:c,items:l}=this;for(let u=0,d=l.length;u<d;u++)l[u][c](e,t,n,r,i,a,o,s);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){let 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}}})),ml,hl,gl,_l=s((()=>{we(),sc(),qn(),uc(),Be(),We(),Je(),dl(),pl(),b(),ml=[`init`,`destroy`,`contextChange`,`resolutionChange`,`resetState`,`renderEnd`,`renderStart`,`render`,`update`,`postrender`,`prerender`],hl=class e extends y{constructor(e){super(),this.tick=0,this.uid=Re(`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;let t=[...ml,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(t={}){await ac(t.skipExtensionImports===!0||t.manageImports===!1),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(let e in this._systemsHash)t={...this._systemsHash[e].constructor.defaultOptions,...t};t={...e.defaultOptions,...t},this._roundPixels=+!!t.roundPixels;for(let e=0;e<this.runners.init.items.length;e++)await this.runners.init.items[e].init(t);this._initOptions=t}render(e,t){this.tick++;let n=e;if(n instanceof Kn&&(n={container:n},t&&(P(N,`passing a second argument is deprecated, please use render options instead`),n.target=t.renderTexture)),n.target||=this.view.renderTarget,n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,n.clearColor??=this.background.colorRgba,n.clear??=this.background.clearBeforeRender),n.clearColor){let e=Array.isArray(n.clearColor)&&n.clearColor.length===4;n.clearColor=e?n.clearColor:A.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){let r=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!==r&&this.runners.resolutionChange.emit(n)}clear(e={}){let t=this;e.target||=t.renderTarget.renderTarget,e.clearColor||=this.background.colorRgba,e.clear??=ul.ALL;let{clear:n,clearColor:r,target:i,mipLevel:a,layer:o}=e;A.shared.setValue(r??this.background.colorRgba),t.renderTarget.clear(i,n,A.shared.toArray(),a??0,o??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(e=>{this.runners[e]=new fl(e)})}_addSystems(e){let t;for(t in e){let n=e[t];this._addSystem(n.value,n.name)}}_addSystem(e,t){let n=new e(this);if(this[t])throw Error(`Whoops! The name "${t}" is already in use`);this[t]=n,this._systemsHash[t]=n;for(let e in this.runners)this.runners[e].add(n);return this}_addPipes(e,t){let n=t.reduce((e,t)=>(e[t.name]=t.value,e),{});e.forEach(e=>{let t=e.value,r=e.name,i=n[r];this.renderPipes[r]=new t(this,i?new i:null),this.runners.destroy.add(this.renderPipes[r])})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e==`object`&&e.releaseGlobalResources)&&qe.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!cc())throw Error(`Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.`)}resetState(){this.runners.resetState.emit()}},hl.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1},gl=hl}));V(),_l();let vl;function yl(e){return vl===void 0&&(vl=(()=>{let t={stencil:!0,failIfMajorPerformanceCaveat:e??gl.defaultOptions.failIfMajorPerformanceCaveat};try{if(!B.get().getWebGLRenderingContext())return!1;let e=B.get().createCanvas().getContext(`webgl`,t),n=!!e?.getContextAttributes()?.stencil;if(e){let t=e.getExtension(`WEBGL_lose_context`);t&&t.loseContext()}return e=null,n}catch{return!1}})()),vl}V();let bl;async function xl(e={}){return bl===void 0&&(bl=await(async()=>{let t=B.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(e)).requestDevice(),!0}catch{return!1}})()),bl}function Sl(e,t,n){let r=2166136261;for(let n=0;n<t;n++)r^=e[n].uid,r=Math.imul(r,16777619),r>>>=0;return wl[r]||Cl(e,t,r,n)}function Cl(e,t,n,r){let i={},a=0;for(let n=0;n<r;n++){let r=n<t?e[n]:R.EMPTY.source;i[a++]=r.source,i[a++]=r.style}let o=new ns(i);return wl[n]=o,o}var wl,Tl=s((()=>{rs(),z(),wl={}}));function El(e,t,n){if(e)for(let r in e){let i=t[r.toLocaleLowerCase()];if(i){let t=e[r];r===`header`&&(t=t.replace(/@in\s+[^;]+;\s*/g,``).replace(/@out\s+[^;]+;\s*/g,``)),n&&i.push(`//----${n}----//`),i.push(t)}else F(`${r} placement hook does not exist in shader`)}}var Dl=s((()=>{I()}));function Ol(e){let t={};return(e.match(kl)?.map(e=>e.replace(/[{()}]/g,``))??[]).forEach(e=>{t[e]=[]}),t}var kl,Al=s((()=>{kl=/\{\{(.*?)\}\}/g}));function jl(e,t){let n,r=/@in\s+([^;]+);/g;for(;(n=r.exec(e))!==null;)t.push(n[1])}function Ml(e,t,n=!1){let r=[];jl(t,r),e.forEach(e=>{e.header&&jl(e.header,r)});let i=r;n&&i.sort();let a=i.map((e,t)=>` @location(${t}) ${e},`).join(`
|
|
118
|
+
`),o=t.replace(/@in\s+[^;]+;\s*/g,``);return o=o.replace(`{{in}}`,`
|
|
119
|
+
${a}
|
|
120
|
+
`),o}var Nl=s((()=>{}));function Pl(e,t){let n,r=/@out\s+([^;]+);/g;for(;(n=r.exec(e))!==null;)t.push(n[1])}function Fl(e){let t=/\b(\w+)\s*:/g.exec(e);return t?t[1]:``}function Il(e){return e.replace(/@.*?\s+/g,``)}function Ll(e,t){let n=[];Pl(t,n),e.forEach(e=>{e.header&&Pl(e.header,n)});let r=0,i=n.sort().map(e=>e.indexOf(`builtin`)>-1?e:`@location(${r++}) ${e}`).join(`,
|
|
121
|
+
`),a=n.sort().map(e=>` var ${Il(e)};`).join(`
|
|
122
|
+
`),o=`return VSOutput(
|
|
123
|
+
${n.sort().map(e=>` ${Fl(e)}`).join(`,
|
|
124
|
+
`)});`,s=t.replace(/@out\s+[^;]+;\s*/g,``);return s=s.replace(`{{struct}}`,`
|
|
125
|
+
${i}
|
|
126
|
+
`),s=s.replace(`{{start}}`,`
|
|
127
|
+
${a}
|
|
128
|
+
`),s=s.replace(`{{return}}`,`
|
|
129
|
+
${o}
|
|
130
|
+
`),s}var Rl=s((()=>{}));function zl(e,t){let n=e;for(let e in t){let r=t[e];n=r.join(`
|
|
131
|
+
`).length?n.replace(`{{${e}}}`,`//-----${e} START-----//
|
|
132
|
+
${r.join(`
|
|
133
|
+
`)}
|
|
134
|
+
//----${e} FINISH----//`):n.replace(`{{${e}}}`,``)}return n}var Bl=s((()=>{}));function Vl({template:e,bits:t}){let n=Wl(e,t);if(Kl[n])return Kl[n];let{vertex:r,fragment:i}=Ul(e,t);return Kl[n]=Gl(r,i,t),Kl[n]}function Hl({template:e,bits:t}){let n=Wl(e,t);return Kl[n]||(Kl[n]=Gl(e.vertex,e.fragment,t)),Kl[n]}function Ul(e,t){let n=t.map(e=>e.vertex).filter(e=>!!e),r=t.map(e=>e.fragment).filter(e=>!!e),i=Ml(n,e.vertex,!0);i=Ll(n,i);let a=Ml(r,e.fragment,!0);return{vertex:i,fragment:a}}function Wl(e,t){return t.map(e=>(ql.has(e)||ql.set(e,Jl++),ql.get(e))).sort((e,t)=>e-t).join(`-`)+e.vertex+e.fragment}function Gl(e,t,n){let r=Ol(e),i=Ol(t);return n.forEach(e=>{El(e.vertex,r,e.name),El(e.fragment,i,e.name)}),{vertex:zl(e,r),fragment:zl(t,i)}}var Kl,ql,Jl,Yl=s((()=>{Dl(),Al(),Nl(),Rl(),Bl(),Kl=Object.create(null),ql=new Map,Jl=0})),Xl,Zl,Ql,$l,eu=s((()=>{Xl=`
|
|
135
|
+
@in aPosition: vec2<f32>;
|
|
136
|
+
@in aUV: vec2<f32>;
|
|
137
|
+
|
|
138
|
+
@out @builtin(position) vPosition: vec4<f32>;
|
|
139
|
+
@out vUV : vec2<f32>;
|
|
140
|
+
@out vColor : vec4<f32>;
|
|
141
|
+
|
|
142
|
+
{{header}}
|
|
143
|
+
|
|
144
|
+
struct VSOutput {
|
|
145
|
+
{{struct}}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
@vertex
|
|
149
|
+
fn main( {{in}} ) -> VSOutput {
|
|
150
|
+
|
|
151
|
+
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
|
152
|
+
var modelMatrix = mat3x3<f32>(
|
|
153
|
+
1.0, 0.0, 0.0,
|
|
154
|
+
0.0, 1.0, 0.0,
|
|
155
|
+
0.0, 0.0, 1.0
|
|
156
|
+
);
|
|
157
|
+
var position = aPosition;
|
|
158
|
+
var uv = aUV;
|
|
159
|
+
|
|
160
|
+
{{start}}
|
|
161
|
+
|
|
162
|
+
vColor = vec4<f32>(1., 1., 1., 1.);
|
|
163
|
+
|
|
164
|
+
{{main}}
|
|
165
|
+
|
|
166
|
+
vUV = uv;
|
|
167
|
+
|
|
168
|
+
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
169
|
+
|
|
170
|
+
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
|
171
|
+
|
|
172
|
+
vColor *= globalUniforms.uWorldColorAlpha;
|
|
173
|
+
|
|
174
|
+
{{end}}
|
|
175
|
+
|
|
176
|
+
{{return}}
|
|
177
|
+
};
|
|
178
|
+
`,Zl=`
|
|
179
|
+
@in vUV : vec2<f32>;
|
|
180
|
+
@in vColor : vec4<f32>;
|
|
181
|
+
|
|
182
|
+
{{header}}
|
|
183
|
+
|
|
184
|
+
@fragment
|
|
185
|
+
fn main(
|
|
186
|
+
{{in}}
|
|
187
|
+
) -> @location(0) vec4<f32> {
|
|
188
|
+
|
|
189
|
+
{{start}}
|
|
190
|
+
|
|
191
|
+
var outColor:vec4<f32>;
|
|
192
|
+
|
|
193
|
+
{{main}}
|
|
194
|
+
|
|
195
|
+
var finalColor:vec4<f32> = outColor * vColor;
|
|
196
|
+
|
|
197
|
+
{{end}}
|
|
198
|
+
|
|
199
|
+
return finalColor;
|
|
200
|
+
};
|
|
201
|
+
`,Ql=`
|
|
202
|
+
in vec2 aPosition;
|
|
203
|
+
in vec2 aUV;
|
|
204
|
+
|
|
205
|
+
out vec4 vColor;
|
|
206
|
+
out vec2 vUV;
|
|
207
|
+
|
|
208
|
+
{{header}}
|
|
209
|
+
|
|
210
|
+
void main(void){
|
|
211
|
+
|
|
212
|
+
mat3 worldTransformMatrix = uWorldTransformMatrix;
|
|
213
|
+
mat3 modelMatrix = mat3(
|
|
214
|
+
1.0, 0.0, 0.0,
|
|
215
|
+
0.0, 1.0, 0.0,
|
|
216
|
+
0.0, 0.0, 1.0
|
|
217
|
+
);
|
|
218
|
+
vec2 position = aPosition;
|
|
219
|
+
vec2 uv = aUV;
|
|
220
|
+
|
|
221
|
+
{{start}}
|
|
222
|
+
|
|
223
|
+
vColor = vec4(1.);
|
|
224
|
+
|
|
225
|
+
{{main}}
|
|
226
|
+
|
|
227
|
+
vUV = uv;
|
|
228
|
+
|
|
229
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
230
|
+
|
|
231
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
232
|
+
|
|
233
|
+
vColor *= uWorldColorAlpha;
|
|
234
|
+
|
|
235
|
+
{{end}}
|
|
236
|
+
}
|
|
237
|
+
`,$l=`
|
|
238
|
+
|
|
239
|
+
in vec4 vColor;
|
|
240
|
+
in vec2 vUV;
|
|
241
|
+
|
|
242
|
+
out vec4 finalColor;
|
|
243
|
+
|
|
244
|
+
{{header}}
|
|
245
|
+
|
|
246
|
+
void main(void) {
|
|
247
|
+
|
|
248
|
+
{{start}}
|
|
249
|
+
|
|
250
|
+
vec4 outColor;
|
|
251
|
+
|
|
252
|
+
{{main}}
|
|
253
|
+
|
|
254
|
+
finalColor = outColor * vColor;
|
|
255
|
+
|
|
256
|
+
{{end}}
|
|
257
|
+
}
|
|
258
|
+
`})),tu,nu,ru=s((()=>{tu={name:`global-uniforms-bit`,vertex:{header:`
|
|
259
|
+
struct GlobalUniforms {
|
|
260
|
+
uProjectionMatrix:mat3x3<f32>,
|
|
261
|
+
uWorldTransformMatrix:mat3x3<f32>,
|
|
262
|
+
uWorldColorAlpha: vec4<f32>,
|
|
263
|
+
uResolution: vec2<f32>,
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
267
|
+
`}},nu={name:`global-uniforms-bit`,vertex:{header:`
|
|
268
|
+
uniform mat3 uProjectionMatrix;
|
|
269
|
+
uniform mat3 uWorldTransformMatrix;
|
|
270
|
+
uniform vec4 uWorldColorAlpha;
|
|
271
|
+
uniform vec2 uResolution;
|
|
272
|
+
`}}}));function iu({bits:e,name:t}){let n=Vl({template:{fragment:Zl,vertex:Xl},bits:[tu,...e]});return es.from({name:t,vertex:{source:n.vertex,entryPoint:`main`},fragment:{source:n.fragment,entryPoint:`main`}})}function au({bits:e,name:t}){return new Mo({name:t,...Hl({template:{vertex:Ql,fragment:$l},bits:[nu,...e]})})}var ou=s((()=>{No(),ts(),Yl(),eu(),ru()})),su,cu,lu=s((()=>{su={name:`color-bit`,vertex:{header:`
|
|
273
|
+
@in aColor: vec4<f32>;
|
|
274
|
+
`,main:`
|
|
275
|
+
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
276
|
+
`}},cu={name:`color-bit`,vertex:{header:`
|
|
277
|
+
in vec4 aColor;
|
|
278
|
+
`,main:`
|
|
279
|
+
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
280
|
+
`}}}));function uu(e){let t=[];if(e===1)t.push(`@group(1) @binding(0) var textureSource1: texture_2d<f32>;`),t.push(`@group(1) @binding(1) var textureSampler1: sampler;`);else{let n=0;for(let r=0;r<e;r++)t.push(`@group(1) @binding(${n++}) var textureSource${r+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${n++}) var textureSampler${r+1}: sampler;`)}return t.join(`
|
|
281
|
+
`)}function du(e){let t=[];if(e===1)t.push(`outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);`);else{t.push(`switch vTextureId {`);for(let n=0;n<e;n++)n===e-1?t.push(` default:{`):t.push(` case ${n}:{`),t.push(` outColor = textureSampleGrad(textureSource${n+1}, textureSampler${n+1}, vUV, uvDx, uvDy);`),t.push(` break;}`);t.push(`}`)}return t.join(`
|
|
282
|
+
`)}function fu(e){return hu[e]||(hu[e]={name:`texture-batch-bit`,vertex:{header:`
|
|
283
|
+
@in aTextureIdAndRound: vec2<u32>;
|
|
284
|
+
@out @interpolate(flat) vTextureId : u32;
|
|
285
|
+
`,main:`
|
|
286
|
+
vTextureId = aTextureIdAndRound.y;
|
|
287
|
+
`,end:`
|
|
288
|
+
if(aTextureIdAndRound.x == 1)
|
|
289
|
+
{
|
|
290
|
+
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
291
|
+
}
|
|
292
|
+
`},fragment:{header:`
|
|
293
|
+
@in @interpolate(flat) vTextureId: u32;
|
|
294
|
+
|
|
295
|
+
${uu(e)}
|
|
296
|
+
`,main:`
|
|
297
|
+
var uvDx = dpdx(vUV);
|
|
298
|
+
var uvDy = dpdy(vUV);
|
|
299
|
+
|
|
300
|
+
${du(e)}
|
|
301
|
+
`}}),hu[e]}function pu(e){let t=[];for(let n=0;n<e;n++)n>0&&t.push(`else`),n<e-1&&t.push(`if(vTextureId < ${n}.5)`),t.push(`{`),t.push(` outColor = texture(uTextures[${n}], vUV);`),t.push(`}`);return t.join(`
|
|
302
|
+
`)}function mu(e){return gu[e]||(gu[e]={name:`texture-batch-bit`,vertex:{header:`
|
|
303
|
+
in vec2 aTextureIdAndRound;
|
|
304
|
+
out float vTextureId;
|
|
305
|
+
|
|
306
|
+
`,main:`
|
|
307
|
+
vTextureId = aTextureIdAndRound.y;
|
|
308
|
+
`,end:`
|
|
309
|
+
if(aTextureIdAndRound.x == 1.)
|
|
310
|
+
{
|
|
311
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
312
|
+
}
|
|
313
|
+
`},fragment:{header:`
|
|
314
|
+
in float vTextureId;
|
|
315
|
+
|
|
316
|
+
uniform sampler2D uTextures[${e}];
|
|
317
|
+
|
|
318
|
+
`,main:`
|
|
319
|
+
|
|
320
|
+
${pu(e)}
|
|
321
|
+
`}}),gu[e]}var hu,gu,_u=s((()=>{hu={},gu={}})),vu,yu,bu,xu=s((()=>{vu={name:`local-uniform-bit`,vertex:{header:`
|
|
322
|
+
|
|
323
|
+
struct LocalUniforms {
|
|
324
|
+
uTransformMatrix:mat3x3<f32>,
|
|
325
|
+
uColor:vec4<f32>,
|
|
326
|
+
uRound:f32,
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
330
|
+
`,main:`
|
|
331
|
+
vColor *= localUniforms.uColor;
|
|
332
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
333
|
+
`,end:`
|
|
334
|
+
if(localUniforms.uRound == 1)
|
|
335
|
+
{
|
|
336
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
337
|
+
}
|
|
338
|
+
`}},yu={...vu,vertex:{...vu.vertex,header:vu.vertex.header.replace(`group(1)`,`group(2)`)}},bu={name:`local-uniform-bit`,vertex:{header:`
|
|
339
|
+
|
|
340
|
+
uniform mat3 uTransformMatrix;
|
|
341
|
+
uniform vec4 uColor;
|
|
342
|
+
uniform float uRound;
|
|
343
|
+
`,main:`
|
|
344
|
+
vColor *= uColor;
|
|
345
|
+
modelMatrix = uTransformMatrix;
|
|
346
|
+
`,end:`
|
|
347
|
+
if(uRound == 1.)
|
|
348
|
+
{
|
|
349
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
350
|
+
}
|
|
351
|
+
`}}})),Su,Cu,wu=s((()=>{Su={name:`round-pixels-bit`,vertex:{header:`
|
|
352
|
+
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
353
|
+
{
|
|
354
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
355
|
+
}
|
|
356
|
+
`}},Cu={name:`round-pixels-bit`,vertex:{header:`
|
|
357
|
+
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
358
|
+
{
|
|
359
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
360
|
+
}
|
|
361
|
+
`}}})),Tu,Eu=s((()=>{g(),M(),Tl(),ou(),lu(),_u(),xu(),wu(),hs(),ps(),Tu=class{constructor(){this._maxTextures=0}contextChange(e){let t=new fs({uTransformMatrix:{value:new j,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}});this._maxTextures=e.limits.maxBatchableTextures;let n=iu({name:`graphics`,bits:[su,fu(this._maxTextures),yu,Su]});this.shader=new ms({gpuProgram:n,resources:{localUniforms:t}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{batcher:a,instructions:o}=i.graphicsContext.getContextRenderData(n),s=i.encoder;s.setGeometry(a.geometry,r.gpuProgram);let c=i.globalUniforms.bindGroup;s.setBindGroup(0,c,r.gpuProgram);let l=i.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);s.setBindGroup(2,l,r.gpuProgram);let u=o.instructions,d=null;for(let t=0;t<o.instructionSize;t++){let n=u[t];if(n.topology!==d&&(d=n.topology,s.setPipelineFromGeometryProgramAndState(a.geometry,r.gpuProgram,e.state,n.topology)),r.groups[1]=n.bindGroup,!n.gpuBindGroup){let e=n.textures;n.bindGroup=Sl(e.textures,e.count,this._maxTextures),n.gpuBindGroup=i.bindGroup.getBindGroup(n.bindGroup,r.gpuProgram,1)}s.setBindGroup(1,n.bindGroup,r.gpuProgram),s.renderPassEncoder.drawIndexed(n.size,1,n.start)}}destroy(){this.shader.destroy(!0),this.shader=null}},Tu.extension={type:[f.WebGPUPipesAdaptor],name:`graphics`}})),Du,Ou,ku=s((()=>{Du={name:`texture-bit`,vertex:{header:`
|
|
362
|
+
|
|
363
|
+
struct TextureUniforms {
|
|
364
|
+
uTextureMatrix:mat3x3<f32>,
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
368
|
+
`,main:`
|
|
369
|
+
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
370
|
+
`},fragment:{header:`
|
|
371
|
+
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
372
|
+
@group(2) @binding(1) var uSampler: sampler;
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
`,main:`
|
|
376
|
+
outColor = textureSample(uTexture, uSampler, vUV);
|
|
377
|
+
`}},Ou={name:`texture-bit`,vertex:{header:`
|
|
378
|
+
uniform mat3 uTextureMatrix;
|
|
379
|
+
`,main:`
|
|
380
|
+
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
381
|
+
`},fragment:{header:`
|
|
382
|
+
uniform sampler2D uTexture;
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
`,main:`
|
|
386
|
+
outColor = texture(uTexture, vUV);
|
|
387
|
+
`}}})),Au,ju=s((()=>{g(),M(),ou(),xu(),wu(),ku(),hs(),z(),I(),Au=class{init(){let e=iu({name:`mesh`,bits:[vu,Du,Su]});this._shader=new ms({gpuProgram:e,resources:{uTexture:R.EMPTY._source,uSampler:R.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new j}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r)r=this._shader,r.groups[2]=n.texture.getTextureBindGroup(t.texture);else if(!r.gpuProgram){F(`Mesh shader has no gpuProgram`,t.shader);return}let i=r.gpuProgram;if(i.autoAssignGlobalUniforms&&(r.groups[0]=n.globalUniforms.bindGroup),i.autoAssignLocalUniforms){let t=e.localUniforms;r.groups[1]=n.renderPipes.uniformBatch.getUniformBindGroup(t,!0)}n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}},Au.extension={type:[f.WebGPUPipesAdaptor],name:`mesh`}})),Mu,Nu,Pu=s((()=>{g(),Ts(),Tl(),Mu=ws.for2d(),Nu=class{start(e,t,n){let r=e.renderer,i=r.encoder,a=n.gpuProgram;this._shader=n,this._geometry=t,i.setGeometry(t,a),Mu.blendMode=`normal`,r.pipeline.getPipeline(t,a,Mu);let o=r.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,a)}execute(e,t){let n=this._shader.gpuProgram,r=e.renderer,i=r.encoder;if(!t.bindGroup){let e=t.textures;t.bindGroup=Sl(e.textures,e.count,r.limits.maxBatchableTextures)}Mu.blendMode=t.blendMode;let a=r.bindGroup.getBindGroup(t.bindGroup,n,1),o=r.pipeline.getPipeline(this._geometry,n,Mu,t.topology);t.bindGroup._touch(r.gc.now,r.tick),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,a),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}},Nu.extension={type:[f.WebGPUPipesAdaptor],name:`batch`}})),Fu,Iu=s((()=>{g(),Fu=class{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}},Fu.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`customRender`}})),Lu,Ru=s((()=>{Lu=class{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 zu(e,t){let n=e.instructionSet,r=n.instructions;for(let e=0;e<n.instructionSize;e++){let n=r[e];t[n.renderPipeId].execute(n)}}var Bu=s((()=>{})),Vu,Hu=s((()=>{g(),M(),$e(),Ru(),Bu(),Vu=class{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&&=(Qe.return(e._batchableRenderGroup),null),t.add(e)}_addRenderableCacheAsTexture(e,t){let n=e._batchableRenderGroup??=Qe.get(Lu);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;let t=new j().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}}),zu(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}),zu(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}},Vu.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`renderGroup`}}));function Uu(e,t){t||=0;for(let n=t;n<e.length&&e[n];n++)e[n]=null}var Wu=s((()=>{}));function Gu(e,t=!1){Ku(e);let n=e.childrenToUpdate,r=e.updateTick++;for(let t in n){let i=Number(t),a=n[t],o=a.list,s=a.index;for(let t=0;t<s;t++){let n=o[t];n.parentRenderGroup===e&&n.relativeRenderGroupDepth===i&&qu(n,r,0)}Uu(o,s),a.index=0}if(t)for(let n=0;n<e.renderGroupChildren.length;n++)Gu(e.renderGroupChildren[n],t)}function Ku(e){let t=e.root,n;if(e.renderGroupParent){let r=e.renderGroupParent;e.worldTransform.appendFrom(t.relativeGroupTransform,r.worldTransform),e.worldColor=Ft(t.groupColor,r.worldColor),n=t.groupAlpha*r.worldAlpha}else e.worldTransform.copyFrom(t.localTransform),e.worldColor=t.localColor,n=t.localAlpha;n=n<0?0:n>1?1:n,e.worldAlpha=n,e.worldColorAlpha=e.worldColor+((n*255|0)<<24)}function qu(e,t,n){if(t===e.updateTick)return;e.updateTick=t,e.didChange=!1;let r=e.localTransform;e.updateLocalTransform();let i=e.parent;if(i&&!i.renderGroup?(n|=e._updateFlags,e.relativeGroupTransform.appendFrom(r,i.relativeGroupTransform),n&Xu&&Ju(e,i,n)):(n=e._updateFlags,e.relativeGroupTransform.copyFrom(r),n&Xu&&Ju(e,Yu,n)),!e.renderGroup){let r=e.children,i=r.length;for(let e=0;e<i;e++)qu(r[e],t,n);let a=e.parentRenderGroup,o=e;o.renderPipeId&&!a.structureDidChange&&a.updateRenderable(o)}}function Ju(e,t,n){if(n&1){e.groupColor=Ft(e.localColor,t.groupColor);let n=e.localAlpha*t.groupAlpha;n=n<0?0:n>1?1:n,e.groupAlpha=n,e.groupColorAlpha=e.groupColor+((n*255|0)<<24)}n&2&&(e.groupBlendMode=e.localBlendMode===`inherit`?t.groupBlendMode:e.localBlendMode),n&4&&(e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus),e._updateFlags=0}var Yu,Xu,Zu=s((()=>{qn(),Wu(),Lt(),Yu=new Kn,Xu=7}));function Qu(e,t){let{list:n}=e.childrenRenderablesToUpdate,r=!1;for(let i=0;i<e.childrenRenderablesToUpdate.index;i++){let e=n[i];if(r=t[e.renderPipeId].validateRenderable(e),r)break}return e.structureDidChange=r,r}var $u=s((()=>{})),ed,td,nd=s((()=>{g(),M(),Ln(),mn(),St(),Wu(),Bu(),Zu(),$u(),ed=new j,td=class{constructor(e){this._renderer=e}render({container:e,transform:t}){let n=e.parent,r=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;let i=this._renderer,a=ed;t&&(a.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));let o=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}),zu(e.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(a),e.parent=n,e.renderGroup.renderGroupParent=r}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){let t=e.root.getLocalBounds(),n=this._renderer,r=e.textureOptions.resolution||n.view.resolution,i=e.textureOptions.antialias??n.view.antialias,a=e.textureOptions.scaleMode??`linear`,o=e.texture;t.ceil(),e.texture&&In.returnTexture(e.texture,!0);let s=In.getOptimalTexture(t.width,t.height,r,i);s._source.style=new pn({scaleMode:a}),e.texture=s,e._textureBounds||=new xt,e._textureBounds.copyFrom(t),o!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&=(In.returnTexture(e.texture,!0),null)}_updateRenderGroups(e){let t=this._renderer,n=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=n,e.structureDidChange?Uu(e.childrenRenderablesToUpdate.list,0):Qu(e,n),Gu(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 t=0;t<e.renderGroupChildren.length;t++)this._updateRenderGroups(e.renderGroupChildren[t])}_updateRenderables(e){let{list:t,index:n}=e.childrenRenderablesToUpdate;for(let r=0;r<n;r++){let n=t[r];n.didViewUpdate&&e.updateRenderable(n)}Uu(t,n)}_buildInstructions(e,t){let n=e.root,r=e.instructionSet;r.reset();let i=t.renderPipes?t:t.batch.renderer,a=i.renderPipes;a.batch.buildStart(r),a.blendMode.buildStart(),a.colorMask.buildStart(),n.sortableChildren&&n.sortChildren(),n.collectRenderablesWithEffects(r,i,null),a.batch.buildEnd(r),a.blendMode.buildEnd(r)}},td.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`renderGroup`}})),rd,id=s((()=>{g(),Ru(),rd=class{constructor(e){this._renderer=e}addRenderable(e,t){let n=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n,t)}updateRenderable(e){let t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){let 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){let t=new Lu;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}},rd.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`sprite`}})),ad,od=s((()=>{b(),ad=`8.19.0`})),sd,cd,ld=s((()=>{g(),od(),sd=class{static init(){globalThis.__PIXI_APP_INIT__?.(this,ad)}static destroy(){}},sd.extension=f.Application,cd=class{constructor(e){this._renderer=e}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,ad)}destroy(){this._renderer=null}},cd.extension={type:[f.WebGLSystem,f.WebGPUSystem],name:`initHook`,priority:-10}})),ud,dd=s((()=>{ud=class{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||=new Int8Array(this.rawBinaryData),this._int8View}get uint8View(){return this._uint8View||=new Uint8Array(this.rawBinaryData),this._uint8View}get int16View(){return this._int16View||=new Int16Array(this.rawBinaryData),this._int16View}get int32View(){return this._int32View||=new Int32Array(this.rawBinaryData),this._int32View}get float64View(){return this._float64Array||=new Float64Array(this.rawBinaryData),this._float64Array}get bigUint64View(){return 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 Error(`${e} isn't a valid view type`)}}}}));function fd(e,t,n,r){if(n??=0,r??=Math.min(e.byteLength-n,t.byteLength),!(n&7)&&!(r&7)){let i=r/8;new Float64Array(t,0,i).set(new Float64Array(e,n,i))}else if(!(n&3)&&!(r&3)){let i=r/4;new Float32Array(t,0,i).set(new Float32Array(e,n,i))}else new Uint8Array(t).set(new Uint8Array(e,n,r))}var pd=s((()=>{})),md,hd,gd=s((()=>{md={normal:`normal-npm`,add:`add-npm`,screen:`screen-npm`},hd=(e=>(e[e.DISABLED=0]=`DISABLED`,e[e.RENDERING_MASK_ADD=1]=`RENDERING_MASK_ADD`,e[e.MASK_ACTIVE=2]=`MASK_ACTIVE`,e[e.INVERSE_MASK_ACTIVE=3]=`INVERSE_MASK_ACTIVE`,e[e.RENDERING_MASK_REMOVE=4]=`RENDERING_MASK_REMOVE`,e[e.NONE=5]=`NONE`,e))(hd||{})}));function _d(e,t){return t.alphaMode===`no-premultiply-alpha`&&md[e]||e}var vd=s((()=>{gd()}));function yd(e){let t=``;for(let n=0;n<e;++n)n>0&&(t+=`
|
|
388
|
+
else `),n<e-1&&(t+=`if(test == ${n}.0){}`);return t}function bd(e,t){if(e===0)throw Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");let n=t.createShader(t.FRAGMENT_SHADER);try{for(;;){let r=xd.replace(/%forloop%/gi,yd(e));if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))e=e/2|0;else break}}finally{t.deleteShader(n)}return e}var xd,Sd=s((()=>{xd=[`precision mediump float;`,`void main(void){`,`float test = 0.1;`,`%forloop%`,`gl_FragColor = vec4(0.0);`,`}`].join(`
|
|
389
|
+
`)}));function Cd(){if(wd)return wd;let e=uo();return wd=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),wd=bd(wd,e),e.getExtension(`WEBGL_lose_context`)?.loseContext(),wd}var wd,Td=s((()=>{po(),Sd(),wd=null})),Ed,Dd=s((()=>{Ed=class{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){let t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}}}));function Od(){return Md>0?jd[--Md]:new Ad}function kd(e){e.elements=null,jd[Md++]=e}var Ad,jd,Md,Nd,Pd,Fd,Id=s((()=>{Be(),dd(),We(),Je(),pd(),vd(),Td(),Dd(),Ad=class{constructor(){this.renderPipeId=`batch`,this.action=`startBatch`,this.start=0,this.size=0,this.textures=new Ed,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}},jd=[],Md=0,qe.register({clear:()=>{if(jd.length>0)for(let e of jd)e&&e.destroy();jd.length=0,Md=0}}),Nd=0,Pd=class e{constructor(t){this.uid=Re(`batcher`),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...e.defaultOptions,...t},t.maxTextures||(P(`v8.8.0`,`maxTextures is a required option for Batcher now, please pass it in the options`),t.maxTextures=Cd());let{maxTextures:n,attributesInitialSize:r,indicesInitialSize:i}=t;this.attributeBuffer=new ud(r*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=n}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)kd(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){let 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;let 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){let t=this._elements;if(!t[this.elementStart])return;let n=Od(),r=n.textures;r.clear();let i=t[this.elementStart],a=_d(i.blendMode,i.texture._source),o=i.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);let s=this.attributeBuffer.float32View,c=this.attributeBuffer.uint32View,l=this.indexBuffer,u=this._batchIndexSize,d=this._batchIndexStart,f=`startBatch`,p=[],m=this.maxTextures;for(let i=this.elementStart;i<this.elementSize;++i){let h=t[i];t[i]=null;let g=h.texture._source,_=_d(h.blendMode,g),v=a!==_||o!==h.topology;if(g._batchTick===Nd&&!v){h._textureId=g._textureBindLocation,u+=h.indexSize,h.packAsQuad?(this.packQuadAttributes(h,s,c,h._attributeStart,h._textureId),this.packQuadIndex(l,h._indexStart,h._attributeStart/this.vertexSize)):(this.packAttributes(h,s,c,h._attributeStart,h._textureId),this.packIndex(h,l,h._indexStart,h._attributeStart/this.vertexSize)),h._batch=n,p.push(h);continue}g._batchTick=Nd,(r.count>=m||v)&&(this._finishBatch(n,d,u-d,r,a,o,e,f,p),f=`renderBatch`,d=u,a=_,o=h.topology,n=Od(),r=n.textures,r.clear(),p=[],++Nd),h._textureId=g._textureBindLocation=r.count,r.ids[g.uid]=r.count,r.textures[r.count++]=g,h._batch=n,p.push(h),u+=h.indexSize,h.packAsQuad?(this.packQuadAttributes(h,s,c,h._attributeStart,h._textureId),this.packQuadIndex(l,h._indexStart,h._attributeStart/this.vertexSize)):(this.packAttributes(h,s,c,h._attributeStart,h._textureId),this.packIndex(h,l,h._indexStart,h._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(n,d,u-d,r,a,o,e,f,p),d=u,++Nd),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(e,t,n,r,i,a,o,s,c){e.gpuBindGroup=null,e.bindGroup=null,e.action=s,e.batcher=this,e.textures=r,e.blendMode=i,e.topology=a,e.start=t,e.size=n,e.elements=c,++Nd,this.batches[this.batchIndex++]=e,o.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){let t=new ud(Math.max(e,this.attributeBuffer.size*2));fd(this.attributeBuffer.rawBinaryData,t.rawBinaryData),this.attributeBuffer=t}_resizeIndexBuffer(e){let t=this.indexBuffer,n=Math.max(e,t.length*1.5);n+=n%2;let r=n>65535?new Uint32Array(n):new Uint16Array(n);if(r.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let e=0;e<t.length;e++)r[e]=t[e];else fd(t.buffer,r.buffer);this.indexBuffer=r}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,r){let i=e.indices,a=e.indexSize,o=e.indexOffset,s=e.attributeOffset;for(let e=0;e<a;e++)t[n++]=r+i[e+o]-s}destroy(e={}){if(this.batches!==null){for(let e=0;e<this.batchIndex;e++)kd(this.batches[e]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&(this.shader?.destroy(),this.shader=null);for(let e=0;e<this._elements.length;e++)this._elements[e]&&(this._elements[e]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}},Pd.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6},Fd=Pd})),Ld,Rd,zd,Bd=s((()=>{Bs(),Rs(),qs(),Ld=new Float32Array(1),Rd=new Uint32Array(1),zd=class extends Ks{constructor(){let e=new zs({data:Ld,label:`attribute-batch-buffer`,usage:Ls.VERTEX|Ls.COPY_DST,shrinkToFit:!1}),t=new zs({data:Rd,label:`index-batch-buffer`,usage:Ls.INDEX|Ls.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:e,format:`float32x2`,stride:24,offset:0},aUV:{buffer:e,format:`float32x2`,stride:24,offset:8},aColor:{buffer:e,format:`unorm8x4`,stride:24,offset:16},aTextureIdAndRound:{buffer:e,format:`uint16x2`,stride:24,offset:20}},indexBuffer:t})}}}));function Vd(e){let t=Hd[e];if(t)return t;let n=new Int32Array(e);for(let t=0;t<e;t++)n[t]=t;return t=Hd[e]=new fs({uTextures:{value:n,type:`i32`,size:e}},{isStatic:!0}),t}var Hd,Ud=s((()=>{ps(),Hd={}})),Wd,Gd=s((()=>{ou(),lu(),_u(),wu(),Ud(),hs(),Wd=class extends ms{constructor(e){let t=au({name:`batch`,bits:[cu,mu(e),Cu]}),n=iu({name:`batch`,bits:[su,fu(e),Su]});super({glProgram:t,gpuProgram:n,resources:{batchSamplers:Vd(e)}}),this.maxTextures=e}}})),Kd,qd,Jd,Yd=s((()=>{g(),Id(),Bd(),Gd(),Kd=null,qd=class e extends Fd{constructor(t){super(t),this.geometry=new zd,this.name=e.extension.name,this.vertexSize=6,Kd??=new Wd(t.maxTextures),this.shader=Kd}packAttributes(e,t,n,r,i){let a=i<<16|e.roundPixels&65535,o=e.transform,s=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,{positions:p,uvs:m}=e,h=e.color,g=e.attributeOffset,_=g+e.attributeSize;for(let e=g;e<_;e++){let i=e*2,o=p[i],g=p[i+1];t[r++]=s*o+l*g+d,t[r++]=u*g+c*o+f,t[r++]=m[i],t[r++]=m[i+1],n[r++]=h,n[r++]=a}}packQuadAttributes(e,t,n,r,i){let a=e.texture,o=e.transform,s=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,p=e.bounds,m=p.maxX,h=p.minX,g=p.maxY,_=p.minY,v=a.uvs,y=e.color,b=i<<16|e.roundPixels&65535;t[r+0]=s*h+l*_+d,t[r+1]=u*_+c*h+f,t[r+2]=v.x0,t[r+3]=v.y0,n[r+4]=y,n[r+5]=b,t[r+6]=s*m+l*_+d,t[r+7]=u*_+c*m+f,t[r+8]=v.x1,t[r+9]=v.y1,n[r+10]=y,n[r+11]=b,t[r+12]=s*m+l*g+d,t[r+13]=u*g+c*m+f,t[r+14]=v.x2,t[r+15]=v.y2,n[r+16]=y,n[r+17]=b,t[r+18]=s*h+l*g+d,t[r+19]=u*g+c*h+f,t[r+20]=v.x3,t[r+21]=v.y3,n[r+22]=y,n[r+23]=b}_updateMaxTextures(e){this.shader.maxTextures!==e&&(Kd=new Wd(e),this.shader=Kd)}destroy(){this.shader=null,super.destroy()}},qd.extension={type:[f.Batcher],name:`default`},Jd=qd})),Xd,Zd,Qd=s((()=>{g(),Ts(),Yd(),Xd=class e{constructor(e,t){this.state=ws.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init?.(this)}static getBatcher(e,t){return new this._availableBatchers[e]({maxTextures:t})}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||=new Jd({maxTextures:this.renderer.limits.maxBatchableTextures})),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(let e in this._activeBatches)this._activeBatches[e].begin()}addToBatch(t,n){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(n);let r=this._activeBatches[t.batcherName];r||(r=this._activeBatches[t.batcherName]=e.getBatcher(t.batcherName,this.renderer.limits.maxBatchableTextures),r.begin()),this._activeBatch=r}this._activeBatch.add(t)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);let t=this._activeBatches;for(let e in t){let n=t[e],r=n.geometry;r.indexBuffer.setDataWithSize(n.indexBuffer,n.indexSize,!0),r.buffers[0].setDataWithSize(n.attributeBuffer.float32View,n.attributeSize,!1)}}upload(e){let t=this._batchersByInstructionSet[e.uid];for(let e in t){let n=t[e],r=n.geometry;n.dirty&&(n.dirty=!1,r.buffers[0].update(n.attributeSize*4))}}execute(e){if(e.action===`startBatch`){let t=e.batcher,n=t.geometry,r=t.shader;this._adaptor.start(this,n,r)}this._adaptor.execute(this,e)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(let e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}},Xd.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`batch`},Xd._availableBatchers=Object.create(null),Zd=Xd,h.handleByMap(f.Batcher,Zd._availableBatchers),h.add(Jd)})),$d,ef=s((()=>{$d=`in vec2 vMaskCoord;
|
|
390
|
+
in vec2 vTextureCoord;
|
|
391
|
+
|
|
392
|
+
uniform sampler2D uTexture;
|
|
393
|
+
uniform sampler2D uMaskTexture;
|
|
394
|
+
|
|
395
|
+
uniform float uAlpha;
|
|
396
|
+
uniform vec4 uMaskClamp;
|
|
397
|
+
uniform float uInverse;
|
|
398
|
+
uniform float uChannel;
|
|
399
|
+
|
|
400
|
+
out vec4 finalColor;
|
|
401
|
+
|
|
402
|
+
void main(void)
|
|
403
|
+
{
|
|
404
|
+
float clip = step(3.5,
|
|
405
|
+
step(uMaskClamp.x, vMaskCoord.x) +
|
|
406
|
+
step(uMaskClamp.y, vMaskCoord.y) +
|
|
407
|
+
step(vMaskCoord.x, uMaskClamp.z) +
|
|
408
|
+
step(vMaskCoord.y, uMaskClamp.w));
|
|
409
|
+
|
|
410
|
+
// TODO look into why this is needed
|
|
411
|
+
float npmAlpha = uAlpha;
|
|
412
|
+
vec4 original = texture(uTexture, vTextureCoord);
|
|
413
|
+
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
|
414
|
+
|
|
415
|
+
float a;
|
|
416
|
+
if (uChannel == 1.0) {
|
|
417
|
+
a = masky.a * npmAlpha * clip;
|
|
418
|
+
} else {
|
|
419
|
+
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
420
|
+
a = alphaMul * masky.r * npmAlpha * clip;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (uInverse == 1.0) {
|
|
424
|
+
a = 1.0 - a;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
finalColor = original * a;
|
|
428
|
+
}
|
|
429
|
+
`})),tf,nf=s((()=>{tf=`in vec2 aPosition;
|
|
430
|
+
|
|
431
|
+
out vec2 vTextureCoord;
|
|
432
|
+
out vec2 vMaskCoord;
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
uniform vec4 uInputSize;
|
|
436
|
+
uniform vec4 uOutputFrame;
|
|
437
|
+
uniform vec4 uOutputTexture;
|
|
438
|
+
uniform mat3 uFilterMatrix;
|
|
439
|
+
|
|
440
|
+
vec4 filterVertexPosition( vec2 aPosition )
|
|
441
|
+
{
|
|
442
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
443
|
+
|
|
444
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
445
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
446
|
+
|
|
447
|
+
return vec4(position, 0.0, 1.0);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
vec2 filterTextureCoord( vec2 aPosition )
|
|
451
|
+
{
|
|
452
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
vec2 getFilterCoord( vec2 aPosition )
|
|
456
|
+
{
|
|
457
|
+
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
void main(void)
|
|
461
|
+
{
|
|
462
|
+
gl_Position = filterVertexPosition(aPosition);
|
|
463
|
+
vTextureCoord = filterTextureCoord(aPosition);
|
|
464
|
+
vMaskCoord = getFilterCoord(aPosition);
|
|
465
|
+
}
|
|
466
|
+
`})),rf,af=s((()=>{rf=`struct GlobalFilterUniforms {
|
|
467
|
+
uInputSize:vec4<f32>,
|
|
468
|
+
uInputPixel:vec4<f32>,
|
|
469
|
+
uInputClamp:vec4<f32>,
|
|
470
|
+
uOutputFrame:vec4<f32>,
|
|
471
|
+
uGlobalFrame:vec4<f32>,
|
|
472
|
+
uOutputTexture:vec4<f32>,
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
struct MaskUniforms {
|
|
476
|
+
uFilterMatrix:mat3x3<f32>,
|
|
477
|
+
uMaskClamp:vec4<f32>,
|
|
478
|
+
uAlpha:f32,
|
|
479
|
+
uInverse:f32,
|
|
480
|
+
uChannel:f32,
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
484
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
485
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
486
|
+
|
|
487
|
+
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
|
488
|
+
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
|
489
|
+
|
|
490
|
+
struct VSOutput {
|
|
491
|
+
@builtin(position) position: vec4<f32>,
|
|
492
|
+
@location(0) uv : vec2<f32>,
|
|
493
|
+
@location(1) filterUv : vec2<f32>,
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
497
|
+
{
|
|
498
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
499
|
+
|
|
500
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
501
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
502
|
+
|
|
503
|
+
return vec4(position, 0.0, 1.0);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
507
|
+
{
|
|
508
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
512
|
+
{
|
|
513
|
+
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
517
|
+
{
|
|
518
|
+
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
fn getSize() -> vec2<f32>
|
|
522
|
+
{
|
|
523
|
+
return gfu.uGlobalFrame.zw;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
@vertex
|
|
527
|
+
fn mainVertex(
|
|
528
|
+
@location(0) aPosition : vec2<f32>,
|
|
529
|
+
) -> VSOutput {
|
|
530
|
+
return VSOutput(
|
|
531
|
+
filterVertexPosition(aPosition),
|
|
532
|
+
filterTextureCoord(aPosition),
|
|
533
|
+
getFilterCoord(aPosition)
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
@fragment
|
|
538
|
+
fn mainFragment(
|
|
539
|
+
@location(0) uv: vec2<f32>,
|
|
540
|
+
@location(1) filterUv: vec2<f32>,
|
|
541
|
+
@builtin(position) position: vec4<f32>
|
|
542
|
+
) -> @location(0) vec4<f32> {
|
|
543
|
+
|
|
544
|
+
var maskClamp = filterUniforms.uMaskClamp;
|
|
545
|
+
var uAlpha = filterUniforms.uAlpha;
|
|
546
|
+
|
|
547
|
+
var clip = step(3.5,
|
|
548
|
+
step(maskClamp.x, filterUv.x) +
|
|
549
|
+
step(maskClamp.y, filterUv.y) +
|
|
550
|
+
step(filterUv.x, maskClamp.z) +
|
|
551
|
+
step(filterUv.y, maskClamp.w));
|
|
552
|
+
|
|
553
|
+
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
|
554
|
+
var source = textureSample(uTexture, uSampler, uv);
|
|
555
|
+
|
|
556
|
+
var a: f32;
|
|
557
|
+
if (filterUniforms.uChannel == 1.0) {
|
|
558
|
+
a = mask.a * uAlpha * clip;
|
|
559
|
+
} else {
|
|
560
|
+
var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
|
|
561
|
+
a = alphaMul * mask.r * uAlpha * clip;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (filterUniforms.uInverse == 1.0) {
|
|
565
|
+
a = 1.0 - a;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return source * a;
|
|
569
|
+
}
|
|
570
|
+
`})),of,sf=s((()=>{M(),No(),ts(),ps(),Nn(),Os(),ef(),nf(),af(),of=class extends Ds{constructor(e){let{sprite:t,...n}=e,r=new Mn(t.texture),i=new fs({uFilterMatrix:{value:new j,type:`mat3x3<f32>`},uMaskClamp:{value:r.uClampFrame,type:`vec4<f32>`},uAlpha:{value:1,type:`f32`},uInverse:{value:+!!e.inverse,type:`f32`},uChannel:{value:+(e.channel===`alpha`),type:`f32`}}),a=es.from({vertex:{source:rf,entryPoint:`mainVertex`},fragment:{source:rf,entryPoint:`mainFragment`}}),o=Mo.from({vertex:tf,fragment:$d,name:`mask-filter`});super({...n,gpuProgram:a,glProgram:o,clipToViewport:!1,resources:{filterUniforms:i,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=r}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=+!!e}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(e){this.resources.filterUniforms.uniforms.uChannel=+(e===`alpha`)}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?`alpha`:`red`}apply(e,t,n,r){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,r)}}})),cf,lf,uf,df=s((()=>{g(),lt(),sf(),St(),Mt(),Xi(),$e(),z(),Ln(),as(),cf=new xt,lf=class extends ct{constructor(){super(),this.filters=[new of({sprite:new Yi(R.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}},uf=class{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,n){let r=this._renderer;if(r.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){let t=e.mask;t.includeInBuild=!0,t.collectRenderables(n,r,null),t.includeInBuild=!1}r.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){let t=this._renderer,n=e.mask.renderMaskToTexture;if(e.action===`pushMaskBegin`){let r=Qe.get(lf);if(r.inverse=e.inverse,r.channel=e.mask.channel,n){e.mask.mask.measurable=!0;let n=kt(e.mask.mask,!0,cf);e.mask.mask.measurable=!1,n.ceil();let i=t.renderTarget.renderTarget.colorTexture.source,a=In.getOptimalTexture(n.width,n.height,i._resolution,i.antialias);t.renderTarget.push(a,!0),t.globalUniforms.push({offset:n,worldColor:4294967295});let o=r.sprite;o.texture=a,o.worldTransform.tx=n.minX,o.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer,filterTexture:a})}else r.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer})}else if(e.action===`pushMaskEnd`){let e=this._activeMaskStage[this._activeMaskStage.length-1];n&&(t.type===is.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:`filter`,action:`pushFilter`,container:e.maskedContainer,filterEffect:e.filterEffect,canBundle:!1})}else if(e.action===`popMaskEnd`){t.filter.pop();let e=this._activeMaskStage.pop();n&&In.returnTexture(e.filterTexture),Qe.return(e.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}},uf.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`alphaMask`}})),ff,pf=s((()=>{g(),ff=class{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);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let 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);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}},ff.extension={type:[f.WebGLPipes,f.WebGPUPipes],name:`colorMask`}})),mf,hf=s((()=>{g(),dl(),gd(),mf=class{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,n){var r;let i=e,a=this._renderer;a.renderPipes.batch.break(n),a.renderPipes.blendMode.setBlendMode(i.mask,`none`,n),n.add({renderPipeId:`stencilMask`,action:`pushMaskBegin`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let o=i.mask;o.includeInBuild=!0,this._maskHash.has(i)||this._maskHash.set(i,{instructionsStart:0,instructionsLength:0});let s=this._maskHash.get(i);s.instructionsStart=n.instructionSize,o.collectRenderables(n,a,null),o.includeInBuild=!1,a.renderPipes.batch.break(n),n.add({renderPipeId:`stencilMask`,action:`pushMaskEnd`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1}),s.instructionsLength=n.instructionSize-s.instructionsStart-1;let c=a.renderTarget.renderTarget.uid;(r=this._maskStackHash)[c]??(r[c]=0)}pop(e,t,n){let r=e,i=this._renderer;i.renderPipes.batch.break(n),i.renderPipes.blendMode.setBlendMode(r.mask,`none`,n),n.add({renderPipeId:`stencilMask`,action:`popMaskBegin`,inverse:t._maskOptions.inverse,canBundle:!1});let a=this._maskHash.get(e);for(let e=0;e<a.instructionsLength;e++)n.instructions[n.instructionSize++]=n.instructions[a.instructionsStart++];n.add({renderPipeId:`stencilMask`,action:`popMaskEnd`,canBundle:!1})}execute(e){var t;let n=this._renderer,r=n,i=n.renderTarget.renderTarget.uid,a=(t=this._maskStackHash)[i]??(t[i]=0);e.action===`pushMaskBegin`?(r.renderTarget.ensureDepthStencil(),r.stencil.setStencilMode(hd.RENDERING_MASK_ADD,a),a++,r.colorMask.setMask(0)):e.action===`pushMaskEnd`?(e.inverse?r.stencil.setStencilMode(hd.INVERSE_MASK_ACTIVE,a):r.stencil.setStencilMode(hd.MASK_ACTIVE,a),r.colorMask.setMask(15)):e.action===`popMaskBegin`?(r.colorMask.setMask(0),a===0?(r.renderTarget.clear(null,ul.STENCIL),r.stencil.setStencilMode(hd.DISABLED,a)):r.stencil.setStencilMode(hd.RENDERING_MASK_REMOVE,a),a--):e.action===`popMaskEnd`&&(e.inverse?r.stencil.setStencilMode(hd.INVERSE_MASK_ACTIVE,a):r.stencil.setStencilMode(hd.MASK_ACTIVE,a),r.colorMask.setMask(15)),this._maskStackHash[i]=a}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}},mf.extension={type:[f.WebGLPipes,f.WebGPUPipes],name:`stencilMask`}})),gf,_f,vf=s((()=>{we(),g(),I(),gf=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new A(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...e.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){A.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&F(`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(){}},gf.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`background`,priority:0},gf.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},_f=gf})),yf,bf,xf=s((()=>{g(),lt(),zn(),I(),yf={},h.handle(f.BlendMode,e=>{if(!e.name)throw Error(`BlendMode extension must have a name property`);yf[e.name]=e.ref},e=>{delete yf[e.name]}),bf=class{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();let t=this._blendModeStack[this._activeBlendMode.length-1]??`normal`;this.setBlendMode(null,t,e)}setBlendMode(e,t,n){let r=e instanceof Rn;if(this._activeBlendMode===t){this._isAdvanced&&e&&!r&&this._renderableList?.push(e);return}this._isAdvanced&&this._endAdvancedBlendMode(n),this._activeBlendMode=t,e&&(this._isAdvanced=!!yf[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,n))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);let n=this._activeBlendMode;if(!yf[n]){F(`Unable to assign BlendMode: '${n}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let r=this._ensureFilterEffect(n),i=e instanceof Rn,a={renderPipeId:`filter`,action:`pushFilter`,filterEffect:r,renderables:i?null:[e],container:i?e.root:null,canBundle:!1};this._renderableList=a.renderables,t.add(a)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new ct,t.filters=[new yf[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(let e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}},bf.extension={type:[f.WebGLPipes,f.WebGPUPipes,f.CanvasPipes],name:`blendMode`}})),Sf,Cf,wf,Tf=s((()=>{V(),g(),qn(),z(),Sf={png:`image/png`,jpg:`image/jpeg`,webp:`image/webp`},Cf=class e{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof Kn||e instanceof R?{target:e,...t}:{...t,...e}}async image(e){let t=B.get().createImage();return t.src=await this.base64(e),t}async base64(t){t=this._normalizeOptions(t,e.defaultImageOptions);let{format:n,quality:r}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((e,t)=>{i.toBlob(n=>{if(!n){t(Error(`ICanvas.toBlob failed!`));return}let r=new FileReader;r.onload=()=>e(r.result),r.onerror=t,r.readAsDataURL(n)},Sf[n],r)});if(i.toDataURL!==void 0)return i.toDataURL(Sf[n],r);if(i.convertToBlob!==void 0){let e=await i.convertToBlob({type:Sf[n],quality:r});return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}throw Error(`Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented`)}canvas(e){e=this._normalizeOptions(e);let t=e.target,n=this._renderer;if(t instanceof R)return n.texture.generateCanvas(t);let r=n.textureGenerator.generateTexture(e),i=n.texture.generateCanvas(r);return r.destroy(!0),i}pixels(e){e=this._normalizeOptions(e);let t=e.target,n=this._renderer,r=t instanceof R?t:n.textureGenerator.generateTexture(e),i=n.texture.getPixels(r);return t instanceof Kn&&r.destroy(!0),i}texture(e){return e=this._normalizeOptions(e),e.target instanceof R?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);let 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){let t=e.width??200;e=this._normalizeOptions(e);let n=this.canvas(e),r=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);let i=[`font-size: 1px;`,`padding: ${t}px 300px;`,`background: url(${r}) no-repeat;`,`background-size: contain;`].join(` `);console.log(`%c `,i)}destroy(){this._renderer=null}},Cf.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`extract`},Cf.defaultImageOptions={format:`png`,quality:1},wf=Cf})),Ef,Df=s((()=>{_n(),z(),Ef=class e extends R{static create(t){let{dynamic:n,textureOptions:r,...i}=t;return new e({...r,source:new gn(i),dynamic:n??!1})}resize(e,t,n){return this.source.resize(e,t,n),this}}})),Of,kf,Af,jf,Mf=s((()=>{we(),g(),M(),yt(),St(),Ut(),qn(),Df(),Of=new vt,kf=new xt,Af=[0,0,0,0],jf=class{constructor(e){this._renderer=e}generateTexture(e){e instanceof Kn&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});let t=e.resolution||this._renderer.resolution,n=e.antialias||this._renderer.view.antialias,r=e.target,i=e.clearColor;i=i?Array.isArray(i)&&i.length===4?i:A.shared.setValue(i).toArray():Af;let a=e.frame?.copyTo(Of)||Vt(r,kf).rectangle,o=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};a.width=Math.max(a.width,1/t)|0,a.height=Math.max(a.height,1/t)|0;let s=Ef.create({...e.textureSourceOptions,width:a.width,height:a.height,resolution:t,antialias:n,textureOptions:o}),c=j.shared.translate(-a.x,-a.y);return this._renderer.render({container:r,transform:c,target:s,clearColor:i}),s.source.updateMipmaps(),s}destroy(){this._renderer=null}},jf.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`textureGenerator`}}));function Nf(e){let t=!1;for(let n in e)if(e[n]==null){t=!0;break}if(!t)return e;let n=Object.create(null);for(let t in e){let r=e[t];r&&(n[t]=r)}return n}function Pf(e){let t=0;for(let n=0;n<e.length;n++)e[n]==null?t++:e[n-t]=e[n];return e.length-=t,e}var Ff=s((()=>{})),If,Lf,Rf=s((()=>{g(),Ff(),If=class e{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.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(let e of this._managedCollections){let{context:t,collection:n,type:r}=e;r===`hash`?t[n]=Nf(t[n]):t[n]=Pf(t[n])}},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(let n of e.renderGroupChildren)this._updateInstructionGCTick(n,t)}addCollection(e,t,n){this._managedCollections.push({context:e,collection:t,type:n})}addResource(e,t){if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,e._onTouch?.(this.now);return}e._gcData={index:this._managedResources.length,type:t},e._gcLastUsed=this.now,e._onTouch?.(this.now),e.once(`unload`,this.removeResource,this),this._managedResources.push(e)}removeResource(e){let t=e._gcData;if(!t)return;let n=t.index,r=this._managedResources.length-1;if(n!==r){let e=this._managedResources[r];this._managedResources[n]=e,e._gcData.index=n}this._managedResources.length--,e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,n,r=0){this._managedResourceHashes.push({context:e,hash:t,type:n,priority:r}),this._managedResourceHashes.sort((e,t)=>e.priority-t.priority)}run(){let e=performance.now(),t=this._managedResourceHashes;for(let n of t)this.runOnHash(n,e);let n=0;for(let t=0;t<this._managedResources.length;t++){let r=this._managedResources[t];n=this.runOnResource(r,e,n)}this._managedResources.length=n}updateRenderableGCTick(e,t){let n=e.renderGroup??e.parentRenderGroup,r=n?.instructionSet?.gcTick??-1;(n?.gcTick??0)===r&&(e._gcLastUsed=t,e._onTouch?.(t))}runOnResource(e,t,n){let r=e._gcData;return r.type===`renderable`&&this.updateRenderableGCTick(e,t),t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect?(this._managedResources[n]=e,r.index=n,n++):(e.unload(),e._gcData=null,e._gcLastUsed=-1,e.off(`unload`,this.removeResource,this)),n}_createHashClone(e,t){let n=Object.create(null);for(let r in e){if(r===t)break;e[r]!==null&&(n[r]=e[r])}return n}runOnHash(e,t){let{context:n,hash:r,type:i}=e,a=n[r],o=null,s=0;for(let e in a){let n=a[e];if(n===null){s++,s===1e4&&!o&&(o=this._createHashClone(a,e));continue}if(n._gcLastUsed===-1){n._gcLastUsed=t,n._onTouch?.(t),o&&(o[e]=n);continue}if(i===`renderable`&&this.updateRenderableGCTick(n,t),!(t-n._gcLastUsed<this.maxUnusedTime)&&n.autoGarbageCollect){if(i===`renderable`){let e=n,t=e.renderGroup??e.parentRenderGroup;t&&(t.structureDidChange=!0)}n.unload(),n._gcData=null,n._gcLastUsed=-1,o||(s+1===1e4?o=this._createHashClone(a,e):(a[e]=null,s++))}else o&&(o[e]=n)}o&&(n[r]=o)}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}},If.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`gc`,priority:0},If.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4},Lf=If}));function zf(e,t,n){let r=(e>>24&255)/255;t[n++]=(e&255)/255*r,t[n++]=(e>>8&255)/255*r,t[n++]=(e>>16&255)/255*r,t[n++]=r}var Bf=s((()=>{})),Vf,Hf=s((()=>{g(),M(),Ne(),Bf(),rs(),as(),ps(),Vf=class{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:r,offset:i}){let a=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:a,worldTransformMatrix:new j,worldColor:4294967295,offset:new je},s={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||a.size,worldTransformMatrix:n||o.worldTransformMatrix,worldColor:r||o.worldColor,offset:i||o.offset,bindGroup:null},c=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(c);let l=c.uniforms;l.uProjectionMatrix=s.projectionMatrix,l.uResolution=s.resolution,l.uWorldTransformMatrix.copyFrom(s.worldTransformMatrix),l.uWorldTransformMatrix.tx-=s.offset.x,l.uWorldTransformMatrix.ty-=s.offset.y,zf(s.worldColor,l.uWorldColorAlpha,0),c.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c,!1):(u=this._bindGroupPool.pop()||new ns,this._activeBindGroups.push(u),u.setResource(c,0)),s.bindGroup=u,this._currentGlobalUniformData=s}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===is.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 fs({uProjectionMatrix:{value:new j,type:`mat3x3<f32>`},uWorldTransformMatrix:{value:new j,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}},Vf.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`globalUniforms`}})),Uf,Wf,Gf=s((()=>{g(),er(),Uf=1,Wf=class{constructor(){this._tasks=[],this._offset=0}init(){$n.system.add(this._update,this)}repeat(e,t,n=!0){let r=Uf++,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:r}),r}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){let e=performance.now();for(let t=0;t<this._tasks.length;t++){let n=this._tasks[t];if(e-n.offset-n.last>=n.duration){let t=e-n.start;n.func(t),n.last=e}}}destroy(){$n.system.remove(this._update,this),this._tasks.length=0}},Wf.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`scheduler`,priority:0}}));function Kf(e){if(!qf){if(B.get().getNavigator().userAgent.toLowerCase().indexOf(`chrome`)>-1){let t=[`%c %c %c %c %c PixiJS %c v${ad} (${e}) http://www.pixijs.com/
|
|
571
|
+
|
|
572
|
+
`,`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(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${ad} - ${e} - http://www.pixijs.com/`);qf=!0}}var qf,Jf=s((()=>{V(),od(),qf=!1})),Yf,Xf=s((()=>{g(),Jf(),as(),Yf=class{constructor(e){this._renderer=e}init(e){if(e.hello){let e=this._renderer.name;this._renderer.type===is.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Kf(e)}}},Yf.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`hello`,priority:-2},Yf.defaultOptions={hello:!1}})),Zf,Qf,$f=s((()=>{g(),We(),Zf=class e{constructor(e){this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return P(`8.15.0`,`RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead.`),this._renderer.gc.enabled}set enabled(e){P(`8.15.0`,`RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead.`),this._renderer.gc.enabled=e}addManagedHash(e,t){P(`8.15.0`,`RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead.`),this._renderer.gc.addCollection(e,t,`hash`)}addManagedArray(e,t){P(`8.15.0`,`RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead.`),this._renderer.gc.addCollection(e,t,`array`)}addRenderable(e){P(`8.15.0`,`RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead.`),this._renderer.gc.addResource(e,`renderable`)}run(){P(`8.15.0`,`RenderableGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.run()}destroy(){this._renderer=null}},Zf.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`renderableGC`,priority:0},Zf.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4},Qf=Zf})),ep,tp,np=s((()=>{g(),We(),ep=class e{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){P(`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){P(`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){P(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`)}get active(){return this._renderer.gc.enabled}set active(e){P(`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(t){t.textureGCActive!==e.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==e.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==e.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){P(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.run()}destroy(){this._renderer=null}},ep.extension={type:[f.WebGLSystem,f.WebGPUSystem],name:`textureGC`},ep.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600},tp=ep})),rp,ip,ap=s((()=>{Be(),_n(),z(),rp=class e{constructor(t={}){if(this.uid=Re(`renderTarget`),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...e.defaultOptions,...t},this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures==`number`){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new gn({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map(e=>e.source)];let e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on(`resize`,this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof R||t.depthStencilTexture instanceof gn?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){let 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||=new gn({width:this.width,height:this.height,resolution:this.resolution,format:`depth24plus-stencil8`,autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1})}resize(e,t,n=this.resolution,r=!1){this.dirtyId++,this.colorTextures.forEach((i,a)=>{r&&a===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)}},rp.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1},ip=rp}));function op(e,t){if(!sp.has(e)){let n=new R({source:new la({resource:e,...t})}),r=()=>{sp.get(e)===n&&sp.delete(e)};n.once(`destroy`,r),n.source.once(`destroy`,r),sp.set(e,n)}return sp.get(e)}var sp,cp=s((()=>{Je(),ua(),z(),sp=new Map,qe.register(sp)})),lp,up,dp=s((()=>{V(),g(),yt(),We(),ap(),cp(),lp=class e{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(t){t={...e.defaultOptions,...t},t.view&&(P(N,`ViewSystem.view has been renamed to ViewSystem.canvas`),t.canvas=t.view),this.screen=new vt(0,0,t.width,t.height),this.canvas=t.canvas||B.get().createCanvas(),this.antialias=!!t.antialias,this.texture=op(this.canvas,t),this.renderTarget=new ip({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.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?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}},lp.extension={type:[f.WebGLSystem,f.WebGPUSystem,f.CanvasSystem],name:`view`,priority:0},lp.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1},up=lp})),fp,pp,mp=s((()=>{Iu(),Hu(),nd(),id(),ld(),Qd(),df(),pf(),hf(),vf(),xf(),Tf(),Mf(),Rf(),Hf(),Gf(),Xf(),$f(),np(),dp(),fp=[_f,Vf,Yf,up,td,Lf,tp,jf,wf,cd,Qf,Wf],pp=[bf,Zd,rd,Vu,uf,mf,ff,Fu]})),hp,gp=s((()=>{g(),hp=class{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){let r=this._gpu.device,i=t.layout[n],a=[],o=this._renderer;for(let t in i){let n=e.resources[t]??e.resources[i[t]],r;if(n._resourceType===`uniformGroup`){let e=n;o.ubo.updateUniformGroup(e);let t=e.buffer;r={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if(n._resourceType===`buffer`){let e=n;r={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if(n._resourceType===`bufferResource`){let e=n;r={buffer:o.buffer.getGPUBuffer(e.buffer),offset:e.offset,size:e.size}}else if(n._resourceType===`textureSampler`){let e=n;r=o.texture.getGpuSampler(e)}else if(n._resourceType===`textureSource`){let e=n;r=o.texture.getTextureView(e)}a.push({binding:i[t],resource:r})}let s=o.shader.getProgramData(t).bindGroups[n],c=r.createBindGroup({layout:s,entries:a});return this._hash[e._key]=c,c}destroy(){this._hash=null,this._renderer=null}},hp.extension={type:[f.WebGPUSystem],name:`bindGroup`}})),_p,vp=s((()=>{_p=class{constructor(e){this.items=Object.create(null);let{renderer:t,type:n,onUnload:r,priority:i,name:a}=e;this._renderer=t,t.gc.addResourceHash(this,`items`,n,i??0),this._onUnload=r,this.name=a}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){if(!this.items[e.uid])return;let n=e._gpuData[this._renderer.uid];n&&(this._onUnload?.(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}}})),yp,bp,xp=s((()=>{g(),vp(),Be(),pd(),yp=class{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}},bp=class{constructor(e){this._renderer=e,this._managedBuffers=new _p({renderer:e,type:`resource`,onUnload:this.onBufferUnload.bind(this),name:`gpuBuffer`})}contextChange(e){this._gpu=e}getGPUBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(e)}updateBuffer(e){let 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){let t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=Re(`resource`),e.data&&(fd(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new yp(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}},bp.extension={type:[f.WebGPUSystem],name:`buffer`}})),Sp,Cp=s((()=>{g(),Sp=class{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}},Sp.extension={type:[f.WebGPUSystem],name:`colorMask`}})),wp,Tp=s((()=>{V(),g(),wp=class{constructor(e){this._renderer=e}async init(e){return this._initPromise||=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(e=>{this.gpu=e,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT==`number`},this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){let t=await B.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),n=[`texture-compression-bc`,`texture-compression-astc`,`texture-compression-etc2`].filter(e=>t.features.has(e));return{adapter:t,device:await t.requestDevice({requiredFeatures:n})}}destroy(){this.gpu=null,this.extensions=null,this._renderer=null}},wp.extension={type:[f.WebGPUSystem],name:`device`},wp.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1}})),Ep,Dp=s((()=>{g(),Ep=class{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,r){let i=this._renderer.pipeline.getPipeline(e,t,n,r);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;let 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);let r=this._renderer.bindGroup.getBindGroup(t,n,e);this.renderPassEncoder.setBindGroup(e,r)}setGeometry(e,t){let n=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let t in n)this._setVertexBuffer(parseInt(t,10),e.attributes[n[t]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(let n in e.groups){let r=e.groups[n];t||this._syncBindGroup(r),this.setBindGroup(n,r,e.gpuProgram)}}_syncBindGroup(e){for(let t in e.resources){let n=e.resources[t];n.isUniformGroup&&this._renderer.ubo.updateUniformGroup(n)}}draw(e){let{geometry:t,shader:n,state:r,topology:i,size:a,start:o,instanceCount:s,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,r,i),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(a||t.indexBuffer.data.length,s??t.instanceCount,o||0):this.renderPassEncoder.draw(a||t.getSize(),s??t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&=(this.renderPassEncoder.end(),null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){let 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);let t=this._boundPipeline,n={...this._boundVertexBuffer},r=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();let a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(t);for(let e in n)this._setVertexBuffer(e,n[e]);for(let e in i)this.setBindGroup(e,i[e],null);this._setIndexBuffer(r)}_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}},Ep.extension={type:[f.WebGPUSystem],name:`encoder`,priority:1}})),Op,kp=s((()=>{g(),Op=class{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}},Op.extension={type:[f.WebGPUSystem],name:`limits`}})),Ap,jp=s((()=>{g(),gd(),Ap=class{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||=this._renderTargetStencilState[e.uid]={stencilMode:hd.DISABLED,stencilReference:0},this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let n=this._renderTargetStencilState[this._activeRenderTarget.uid];n.stencilMode=e,n.stencilReference=t;let r=this._renderer;r.pipeline.setStencilMode(e),r.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}},Ap.extension={type:[f.WebGPUSystem],name:`stencil`}})),Mp,Np=s((()=>{uc(),Bs(),Rs(),Mp=class{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!cc())throw Error(`Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.`)}ensureUniformGroup(e){let t=this.getUniformGroupData(e);e.buffer||=new zs({data:new Float32Array(t.layout.size/4),usage:Ls.UNIFORM|Ls.COPY_DST})}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){let t=e._signature,n=this._syncFunctionHash[t];if(!n){let r=Object.keys(e.uniformStructures).map(t=>e.uniformStructures[t]),i=this._adaptor.createUboElements(r),a=this._generateUboSync(i.uboElements);n=this._syncFunctionHash[t]={layout:i,syncFunction:a}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,n){let r=this.getUniformGroupData(e);e.buffer||=new zs({data:new Float32Array(r.layout.size/4),usage:Ls.UNIFORM|Ls.COPY_DST});let i=null;return t||(t=e.buffer.data,i=e.buffer.dataInt32),n||=0,r.syncFunction(e.uniforms,t,i,n),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;let t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}}));function Pp(e){let t=e.map(e=>({data:e,offset:0,size:0})),n=0;for(let e=0;e<t.length;e++){let r=t[e],i=Fp[r.data.type].size,a=Fp[r.data.type].align;if(!Fp[r.data.type])throw Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${r.data.type}`);r.data.size>1&&(i=Math.max(i,a)*r.data.size),n=Math.ceil(n/a)*a,r.size=i,r.offset=n,n+=i}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}var Fp,Ip=s((()=>{Fp={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}}})),Lp,Rp=s((()=>{Lp=[{type:`mat3x3<f32>`,test:e=>e.value.a!==void 0,ubo:`
|
|
573
|
+
var matrix = uv[name].toArray(true);
|
|
574
|
+
data[offset] = matrix[0];
|
|
575
|
+
data[offset + 1] = matrix[1];
|
|
576
|
+
data[offset + 2] = matrix[2];
|
|
577
|
+
data[offset + 4] = matrix[3];
|
|
578
|
+
data[offset + 5] = matrix[4];
|
|
579
|
+
data[offset + 6] = matrix[5];
|
|
580
|
+
data[offset + 8] = matrix[6];
|
|
581
|
+
data[offset + 9] = matrix[7];
|
|
582
|
+
data[offset + 10] = matrix[8];
|
|
583
|
+
`,uniform:`
|
|
584
|
+
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
585
|
+
`},{type:`vec4<f32>`,test:e=>e.type===`vec4<f32>`&&e.size===1&&e.value.width!==void 0,ubo:`
|
|
586
|
+
v = uv[name];
|
|
587
|
+
data[offset] = v.x;
|
|
588
|
+
data[offset + 1] = v.y;
|
|
589
|
+
data[offset + 2] = v.width;
|
|
590
|
+
data[offset + 3] = v.height;
|
|
591
|
+
`,uniform:`
|
|
592
|
+
cv = ud[name].value;
|
|
593
|
+
v = uv[name];
|
|
594
|
+
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
595
|
+
cv[0] = v.x;
|
|
596
|
+
cv[1] = v.y;
|
|
597
|
+
cv[2] = v.width;
|
|
598
|
+
cv[3] = v.height;
|
|
599
|
+
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
600
|
+
}
|
|
601
|
+
`},{type:`vec2<f32>`,test:e=>e.type===`vec2<f32>`&&e.size===1&&e.value.x!==void 0,ubo:`
|
|
602
|
+
v = uv[name];
|
|
603
|
+
data[offset] = v.x;
|
|
604
|
+
data[offset + 1] = v.y;
|
|
605
|
+
`,uniform:`
|
|
606
|
+
cv = ud[name].value;
|
|
607
|
+
v = uv[name];
|
|
608
|
+
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
609
|
+
cv[0] = v.x;
|
|
610
|
+
cv[1] = v.y;
|
|
611
|
+
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
612
|
+
}
|
|
613
|
+
`},{type:`vec4<f32>`,test:e=>e.type===`vec4<f32>`&&e.size===1&&e.value.red!==void 0,ubo:`
|
|
614
|
+
v = uv[name];
|
|
615
|
+
data[offset] = v.red;
|
|
616
|
+
data[offset + 1] = v.green;
|
|
617
|
+
data[offset + 2] = v.blue;
|
|
618
|
+
data[offset + 3] = v.alpha;
|
|
619
|
+
`,uniform:`
|
|
620
|
+
cv = ud[name].value;
|
|
621
|
+
v = uv[name];
|
|
622
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
623
|
+
cv[0] = v.red;
|
|
624
|
+
cv[1] = v.green;
|
|
625
|
+
cv[2] = v.blue;
|
|
626
|
+
cv[3] = v.alpha;
|
|
627
|
+
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
628
|
+
}
|
|
629
|
+
`},{type:`vec3<f32>`,test:e=>e.type===`vec3<f32>`&&e.size===1&&e.value.red!==void 0,ubo:`
|
|
630
|
+
v = uv[name];
|
|
631
|
+
data[offset] = v.red;
|
|
632
|
+
data[offset + 1] = v.green;
|
|
633
|
+
data[offset + 2] = v.blue;
|
|
634
|
+
`,uniform:`
|
|
635
|
+
cv = ud[name].value;
|
|
636
|
+
v = uv[name];
|
|
637
|
+
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
638
|
+
cv[0] = v.red;
|
|
639
|
+
cv[1] = v.green;
|
|
640
|
+
cv[2] = v.blue;
|
|
641
|
+
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
642
|
+
}
|
|
643
|
+
`}]}));function zp(e,t,n,r){let i=[`
|
|
644
|
+
var v = null;
|
|
645
|
+
var v2 = null;
|
|
646
|
+
var t = 0;
|
|
647
|
+
var index = 0;
|
|
648
|
+
var name = null;
|
|
649
|
+
var arrayOffset = null;
|
|
650
|
+
`],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.data.name,l=!1,u=0;for(let e=0;e<Lp.length;e++)if(Lp[e].test(s.data)){u=s.offset/4,i.push(`name = "${c}";`,`offset += ${u-a};`,Lp[e][t]||Lp[e].ubo),l=!0;break}if(!l)if(s.data.size>1)u=s.offset/4,i.push(n(s,u-a));else{let e=r[s.data.type];u=s.offset/4,i.push(`
|
|
651
|
+
v = uv.${c};
|
|
652
|
+
offset += ${u-a};
|
|
653
|
+
${e};
|
|
654
|
+
`)}a=u}let o=i.join(`
|
|
655
|
+
`);return Function(`uv`,`data`,`dataInt32`,`offset`,o)}var Bp=s((()=>{Rp()}));function Vp(e,t){return`
|
|
656
|
+
for (let i = 0; i < ${e*t}; i++) {
|
|
657
|
+
data[offset + (((i / ${e})|0) * 4) + (i % ${e})] = v[i];
|
|
658
|
+
}
|
|
659
|
+
`}var Hp,Up,Wp=s((()=>{Hp={f32:`
|
|
660
|
+
data[offset] = v;`,i32:`
|
|
661
|
+
dataInt32[offset] = v;`,"vec2<f32>":`
|
|
662
|
+
data[offset] = v[0];
|
|
663
|
+
data[offset + 1] = v[1];`,"vec3<f32>":`
|
|
664
|
+
data[offset] = v[0];
|
|
665
|
+
data[offset + 1] = v[1];
|
|
666
|
+
data[offset + 2] = v[2];`,"vec4<f32>":`
|
|
667
|
+
data[offset] = v[0];
|
|
668
|
+
data[offset + 1] = v[1];
|
|
669
|
+
data[offset + 2] = v[2];
|
|
670
|
+
data[offset + 3] = v[3];`,"vec2<i32>":`
|
|
671
|
+
dataInt32[offset] = v[0];
|
|
672
|
+
dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
|
|
673
|
+
dataInt32[offset] = v[0];
|
|
674
|
+
dataInt32[offset + 1] = v[1];
|
|
675
|
+
dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
|
|
676
|
+
dataInt32[offset] = v[0];
|
|
677
|
+
dataInt32[offset + 1] = v[1];
|
|
678
|
+
dataInt32[offset + 2] = v[2];
|
|
679
|
+
dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
|
|
680
|
+
data[offset] = v[0];
|
|
681
|
+
data[offset + 1] = v[1];
|
|
682
|
+
data[offset + 4] = v[2];
|
|
683
|
+
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
|
684
|
+
data[offset] = v[0];
|
|
685
|
+
data[offset + 1] = v[1];
|
|
686
|
+
data[offset + 2] = v[2];
|
|
687
|
+
data[offset + 4] = v[3];
|
|
688
|
+
data[offset + 5] = v[4];
|
|
689
|
+
data[offset + 6] = v[5];
|
|
690
|
+
data[offset + 8] = v[6];
|
|
691
|
+
data[offset + 9] = v[7];
|
|
692
|
+
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
|
693
|
+
for (let i = 0; i < 16; i++) {
|
|
694
|
+
data[offset + i] = v[i];
|
|
695
|
+
}`,"mat3x2<f32>":Vp(3,2),"mat4x2<f32>":Vp(4,2),"mat2x3<f32>":Vp(2,3),"mat4x3<f32>":Vp(4,3),"mat2x4<f32>":Vp(2,4),"mat3x4<f32>":Vp(3,4)},Up={...Hp,"mat2x2<f32>":`
|
|
696
|
+
data[offset] = v[0];
|
|
697
|
+
data[offset + 1] = v[1];
|
|
698
|
+
data[offset + 2] = v[2];
|
|
699
|
+
data[offset + 3] = v[3];
|
|
700
|
+
`}}));function Gp(e,t){let{size:n,align:r}=Fp[e.data.type],i=(r-n)/4,a=e.data.type.indexOf(`i32`)>=0?`dataInt32`:`data`;return`
|
|
701
|
+
v = uv.${e.data.name};
|
|
702
|
+
${t===0?``:`offset += ${t};`}
|
|
703
|
+
|
|
704
|
+
arrayOffset = offset;
|
|
705
|
+
|
|
706
|
+
t = 0;
|
|
707
|
+
|
|
708
|
+
for(var i=0; i < ${e.data.size*(n/4)}; i++)
|
|
709
|
+
{
|
|
710
|
+
for(var j = 0; j < ${n/4}; j++)
|
|
711
|
+
{
|
|
712
|
+
${a}[arrayOffset++] = v[t++];
|
|
713
|
+
}
|
|
714
|
+
${i===0?``:`arrayOffset += ${i};`}
|
|
715
|
+
}
|
|
716
|
+
`}var Kp=s((()=>{Ip()}));function qp(e){return zp(e,`uboWgsl`,Gp,Up)}var Jp=s((()=>{Bp(),Wp(),Kp()})),Yp,Xp=s((()=>{g(),Np(),Ip(),Jp(),Yp=class extends Mp{constructor(){super({createUboElements:Pp,generateUboSync:qp})}},Yp.extension={type:[f.WebGPUSystem],name:`ubo`}})),Zp,Qp=s((()=>{b(),Be(),Zp=class extends y{constructor({buffer:e,offset:t,size:n}){super(),this.uid=Re(`buffer`),this._resourceType=`bufferResource`,this._touched=0,this._resourceId=Re(`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=Re(`resource`),this.emit(`change`,this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit(`change`,this),this.buffer=null,this.removeAllListeners()}}})),$p,em=s((()=>{$p=class{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 Error(`UniformBufferBatch: array is too large: ${e*4}`);let t=this.byteIndex,n=t+e*4;if(n=Math.ceil(n/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,n>this.data.length*4)throw Error(`UniformBufferBatch: ubo batch got too big`);return this.byteIndex=n,t}addGroup(e){let 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}}})),tm,nm,rm=s((()=>{g(),Bs(),Qp(),Rs(),em(),rs(),tm=128,nm=class{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new $p({minUniformOffsetAlignment:tm});let t=256/tm;for(let e=0;e<t;e++){let t=Ls.UNIFORM|Ls.COPY_DST;e===0&&(t|=Ls.COPY_SRC),this._buffers.push(new zs({data:this._batchBuffer.data,usage:t}))}}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);let n=e.buffer.data,r=this._batchBuffer.addEmptyGroup(n.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,r/4),this._bindGroupHash[e.uid]=this._getBindGroup(r/tm),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);let t=e.buffer.data,n=this._batchBuffer.addGroup(t);return this._getBufferResource(n/tm)}getArrayBindGroup(e){let t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/tm)}getArrayBufferResource(e){let t=this._batchBuffer.addGroup(e)/tm;return this._getBufferResource(t)}_getBufferResource(e){if(!this._bufferResources[e]){let t=this._buffers[e%2];this._bufferResources[e]=new Zp({buffer:t,offset:(e/2|0)*256,size:tm})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){let t=new ns({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){let e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);let n=this._renderer.gpu.device.createCommandEncoder();for(let r=1;r<this._buffers.length;r++){let i=this._buffers[r];n.copyBufferToBuffer(e.getGPUBuffer(t),tm,e.getGPUBuffer(i),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([n.finish()])}destroy(){for(let e=0;e<this._bindGroups.length;e++)this._bindGroups[e]?.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}},nm.extension={type:[f.WebGPUPipes],name:`uniformBatch`}}));function im(e,t){for(let n in e.attributes){let r=e.attributes[n],i=t[n];i?(r.format??=i.format,r.offset??=i.offset,r.instance??=i.instance):F(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}am(e)}function am(e){let{buffers:t,attributes:n}=e,r={},i={};for(let e in t){let n=t[e];r[n.uid]=0,i[n.uid]=0}for(let e in n){let t=n[e];r[t.buffer.uid]+=Po(t.format).stride}for(let e in n){let t=n[e];t.stride??=r[t.buffer.uid],t.start??=i[t.buffer.uid],i[t.buffer.uid]+=Po(t.format).stride}}var om=s((()=>{I(),Io()})),sm,cm=s((()=>{gd(),sm=[],sm[hd.NONE]=void 0,sm[hd.DISABLED]={stencilWriteMask:0,stencilReadMask:0},sm[hd.RENDERING_MASK_ADD]={stencilFront:{compare:`equal`,passOp:`increment-clamp`},stencilBack:{compare:`equal`,passOp:`increment-clamp`}},sm[hd.RENDERING_MASK_REMOVE]={stencilFront:{compare:`equal`,passOp:`decrement-clamp`},stencilBack:{compare:`equal`,passOp:`decrement-clamp`}},sm[hd.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:`equal`,passOp:`keep`},stencilBack:{compare:`equal`,passOp:`keep`}},sm[hd.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:`not-equal`,passOp:`keep`},stencilBack:{compare:`not-equal`,passOp:`keep`}}}));function lm(e,t,n,r,i){return e<<24|t<<16|n<<10|r<<5|i}function um(e,t,n,r,i){return n<<8|e<<5|r<<3|i<<1|t}var dm,fm,pm=s((()=>{g(),I(),om(),gd(),lo(),cm(),dm={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4},fm=class{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(hd.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=+!!e.descriptor.depthStencilAttachment,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=sm[e],this._updatePipeHash())}setPipeline(e,t,n,r){let i=this.getPipeline(e,t,n);r.setPipeline(i)}getPipeline(e,t,n,r){e._layoutKey||(im(e,t.attributeData),this._generateBufferKey(e)),r||=e.topology;let i=lm(e._layoutKey,t._layoutKey,n.data,n._blendModeId,dm[r]);return this._pipeCache[i]||(this._pipeCache[i]=this._createPipeline(e,t,n,r)),this._pipeCache[i]}_createPipeline(e,t,n,r){let i=this._gpu.device,a=this._createVertexBufferLayouts(e,t),o=this._renderer.state.getColorTargets(n,this._colorTargetCount),s=this._stencilMode===hd.RENDERING_MASK_ADD?0:this._colorMask;for(let e=0;e<o.length;e++)o[e].writeMask=s;let c=this._renderer.shader.getProgramData(t).pipeline,l={vertex:{module:this._getModule(t.vertex.source),entryPoint:t.vertex.entryPoint,buffers:a},fragment:{module:this._getModule(t.fragment.source),entryPoint:t.fragment.entryPoint,targets:o},primitive:{topology:r,cullMode:n.cullMode},layout:c,multisample:{count:this._multisampleCount},label:`PIXI Pipeline`};return this._depthStencilAttachment&&(l.depthStencil={...this._stencilState,format:`depth24plus-stencil8`,depthWriteEnabled:n.depthTest,depthCompare:n.depthTest?`less`:`always`}),i.createRenderPipeline(l)}_getModule(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){let t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){let t=[],n=0,r=Object.keys(e.attributes).sort();for(let i=0;i<r.length;i++){let a=e.attributes[r[i]];t[n++]=a.offset,t[n++]=a.format,t[n++]=a.stride,t[n++]=a.instance}return e._layoutKey=oo(t.join(`|`),`geometry`),e._layoutKey}_generateAttributeLocationsKey(e){let t=[],n=0,r=Object.keys(e.attributeData).sort();for(let i=0;i<r.length;i++){let a=e.attributeData[r[i]];t[n++]=a.location}return e._attributeLocationsKey=oo(t.join(`|`),`programAttributes`),e._attributeLocationsKey}getBufferNamesToBind(e,t){let n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[n])return this._bindingNamesCache[n];let r=this._createVertexBufferLayouts(e,t),i=Object.create(null),a=t.attributeData;for(let e=0;e<r.length;e++){let t=Object.values(r[e].attributes)[0].shaderLocation;for(let n in a)if(a[n].location===t){i[e]=n;break}}return this._bindingNamesCache[n]=i,i}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);let n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[n])return this._bufferLayoutsCache[n];let r=[];return e.buffers.forEach(n=>{let i={arrayStride:0,stepMode:`vertex`,attributes:[]},a=i.attributes;for(let r in t.attributeData){let o=e.attributes[r];(o.divisor??1)!==1&&F(`Attribute ${r} has an invalid divisor value of '${o.divisor}'. WebGPU only supports a divisor value of 1`),o.buffer===n&&(i.arrayStride=o.stride,i.stepMode=o.instance?`instance`:`vertex`,a.push({shaderLocation:t.attributeData[r].location,offset:o.offset,format:o.format}))}a.length&&r.push(i)}),this._bufferLayoutsCache[n]=r,r}_updatePipeHash(){let e=um(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}},fm.extension={type:[f.WebGPUSystem],name:`pipeline`}}));function mm(e,t,n,r,i,a){let o=a?1:-1;return e.identity(),e.a=1/r*2,e.d=o*(1/i*2),e.tx=-1-t*e.a,e.ty=-o-n*e.d,e}var hm=s((()=>{}));function gm(e){let t=e.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var _m=s((()=>{})),vm,ym=s((()=>{M(),yt(),dl(),hm(),pl(),ua(),_n(),z(),cp(),_m(),ap(),vm=class{constructor(e){this.rootViewPort=new vt,this.viewport=new vt,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new fl(`onRenderTargetChange`),this.projectionMatrix=new j,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:r,mipLevel:i,layer:a}){this._renderTargetStack.length=0,this.push(e,t,n,r,i??0,a??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=gm(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,n,r,i=0,a=0){let o=this.getRenderTarget(e),s=this.renderTarget!==o;this.renderTarget=o,this.renderSurface=e;let c=this.getGpuRenderTarget(o);(o.pixelWidth!==c.width||o.pixelHeight!==c.height)&&(this.adaptor.resizeGpuRenderTarget(o),c.width=o.pixelWidth,c.height=o.pixelHeight);let l=o.colorTexture,u=this.viewport,d=l.arrayLayerCount||1;if((a|0)!==a&&(a|=0),a<0||a>=d)throw Error(`[RenderTargetSystem] layer ${a} is out of bounds (arrayLayerCount=${d}).`);this.mipLevel=i|0,this.layer=a|0;let f=Math.max(l.pixelWidth>>i,1),p=Math.max(l.pixelHeight>>i,1);if(!r&&e instanceof R&&(r=e.frame),r){let e=l._resolution,t=1<<Math.max(i|0,0),n=r.x*e+.5|0,a=r.y*e+.5|0,o=r.width*e+.5|0,s=r.height*e+.5|0,c=Math.floor(n/t),d=Math.floor(a/t),m=Math.ceil(o/t),h=Math.ceil(s/t);c=Math.min(Math.max(c,0),f-1),d=Math.min(Math.max(d,0),p-1),m=Math.min(Math.max(m,1),f-c),h=Math.min(Math.max(h,1),p-d),u.x=c,u.y=d,u.width=m,u.height=h}else u.x=0,u.y=0,u.width=f,u.height=p;return mm(this.projectionMatrix,0,0,u.width/l.resolution,u.height/l.resolution,!o.isRoot),this.adaptor.startRenderPass(o,t,n,u,i,a),s&&this.onRenderTargetChange.emit(o),o}clear(e,t=ul.ALL,n,r=this.mipLevel,i=this.layer){t&&(e&&=this.getRenderTarget(e),this.adaptor.clear(e||this.renderTarget,t,n,this.viewport,r,i))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=ul.ALL,n,r,i=0,a=0){let o=this.bind(e,t,n,r,i,a);return this._renderTargetStack.push({renderTarget:o,frame:r,mipLevel:i,layer:a}),o}pop(){this._renderTargetStack.pop();let 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,r,i){n.x<0&&(r.width+=n.x,i.x-=n.x,n.x=0),n.y<0&&(r.height+=n.y,i.y-=n.y,n.y=0);let{pixelWidth:a,pixelHeight:o}=e;return r.width=Math.min(r.width,a-n.x),r.height=Math.min(r.height,o-n.y),this.adaptor.copyToTexture(e,t,n,r,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 la.test(e)&&(e=op(e).source),e instanceof ip?t=e:e instanceof gn&&(t=new ip({colorTextures:[e]}),e.source instanceof la&&(t.isRoot=!0),e.once(`destroy`,()=>{t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);let 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}}})),bm,xm=s((()=>{bm=class{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}})),Sm,Cm=s((()=>{dl(),ua(),_n(),xm(),Sm=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,n,r,i){let a=this._renderer,o=this._getGpuColorTexture(e),s=a.texture.getGpuSource(t.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:n},{texture:s,origin:i},r),t}startRenderPass(e,t=!0,n,r,i=0,a=0){let o=this._renderTargetSystem.getGpuRenderTarget(e);if(a!==0&&o.msaaTextures?.length)throw Error(`[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.`);if(i>0&&o.msaaTextures?.length)throw Error(`[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.`);o.descriptor=this.getDescriptor(e,t,n,i,a),this._renderer.pipeline.setRenderTarget(o),this._renderer.encoder.beginRenderPass(o),this._renderer.encoder.setViewport(r)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(e){let 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,r=0,i=0){typeof t==`boolean`&&(t=t?ul.ALL:ul.NONE);let a=this._renderTargetSystem,o=a.getGpuRenderTarget(e),s=e.colorTextures.map((e,s)=>{let c=o.contexts[s],l,u;if(c){if(i!==0)throw Error(`[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.`);l=c.getCurrentTexture().createView()}else l=this._renderer.texture.getGpuSource(e).createView({dimension:`2d`,baseMipLevel:r,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1});let d=!1;o.msaaTextures[s]&&(u=l,l=this._renderer.texture.getTextureView(o.msaaTextures[s]),d=o.msaaTextures[s].transient);let f=t&ul.COLOR?`clear`:`load`;return n??=a.defaultClearColor,{view:l,resolveTarget:u,clearValue:n,storeOp:d?`discard`:`store`,loadOp:f}}),c;if((e.stencil||e.depth)&&!e.depthStencilTexture&&(e.ensureDepthStencilTexture(),e.depthStencilTexture.source.sampleCount=o.msaa?4:1,e.depthStencilTexture.source.transient=!!o.msaaTextures[0]?.transient),e.depthStencilTexture){let n=t&ul.STENCIL?`clear`:`load`,a=t&ul.DEPTH?`clear`:`load`,o=e.depthStencilTexture.source.transient?`discard`:`store`;c={view:this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView({dimension:`2d`,baseMipLevel:r,mipLevelCount:1,baseArrayLayer:i,arrayLayerCount:1}),stencilStoreOp:o,stencilLoadOp:n,depthClearValue:1,depthLoadOp:a,depthStoreOp:o}}return{colorAttachments:s,depthStencilAttachment:c}}clear(e,t=!0,n,r,i=0,a=0){if(!t)return;let{gpu:o,encoder:s}=this._renderer,c=o.device;if(s.commandEncoder===null){let o=c.createCommandEncoder(),s=this.getDescriptor(e,t,n,i,a),l=o.beginRenderPass(s);l.setViewport(r.x,r.y,r.width,r.height,0,1),l.end();let u=o.finish();c.queue.submit([u])}else this.startRenderPass(e,t,n,r,i,a)}initGpuRenderTarget(e){e.isRoot=!0;let t=new bm;return t.colorTargetCount=e.colorTextures.length,e.colorTextures.forEach((e,n)=>{if(e instanceof la){let r=e.resource.getContext(`webgpu`),i=e.transparent?`premultiplied`:`opaque`;try{r.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:`bgra8unorm`,alphaMode:i})}catch(e){console.error(e)}t.contexts[n]=r}if(t.msaa=e.source.antialias,e.source.antialias){let r=new gn({width:0,height:0,sampleCount:4,transient:e.source.transient,arrayLayerCount:e.source.arrayLayerCount});t.msaaTextures[n]=r}}),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4,e.depthStencilTexture.source.transient=!!t.msaaTextures[0]?.transient)),t}destroyGpuRenderTarget(e){e.contexts.forEach(e=>{e.unconfigure()}),e.msaaTextures.forEach(e=>{e.destroy()}),e.msaaTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);e.depthStencilTexture&&t.msaa&&(e.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorTextures.forEach((e,n)=>{t.msaaTextures[n]?.resize(e.source.width,e.source.height,e.source._resolution)})}}})),wm,Tm=s((()=>{g(),ym(),Cm(),wm=class extends vm{constructor(e){super(e),this.adaptor=new Sm,this.adaptor.init(e,this)}},wm.extension={type:[f.WebGPUSystem],name:`renderTarget`}})),Em,Dm=s((()=>{g(),Em=class{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){let t=this._gpu.device,n=e.gpuLayout.map(e=>t.createBindGroupLayout({entries:e})),r={bindGroupLayouts:n};return this._gpuProgramData[e._layoutKey]={bindGroups:n,pipeline:t.createPipelineLayout(r)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}},Em.extension={type:[f.WebGPUSystem],name:`shader`}})),Om,km=s((()=>{Om={},Om.normal={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}},Om.add={alpha:{srcFactor:`src-alpha`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one`,operation:`add`}},Om.multiply={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`dst`,dstFactor:`one-minus-src-alpha`,operation:`add`}},Om.screen={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src`,operation:`add`}},Om.overlay={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src`,operation:`add`}},Om.none={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`zero`,dstFactor:`zero`,operation:`add`}},Om[`normal-npm`]={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one-minus-src-alpha`,operation:`add`}},Om[`add-npm`]={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one`,operation:`add`}},Om[`screen-npm`]={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one-minus-src`,operation:`add`}},Om.erase={alpha:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`zero`,dstFactor:`one-minus-src`,operation:`add`}},Om.min={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`min`},color:{srcFactor:`one`,dstFactor:`one`,operation:`min`}},Om.max={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`max`},color:{srcFactor:`one`,dstFactor:`one`,operation:`max`}}})),Am,jm=s((()=>{g(),Ts(),km(),Am=class{constructor(){this.defaultState=new ws,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e,t){let n=Om[e.blendMode]||Om.normal,r=[],i={format:`bgra8unorm`,writeMask:0,blend:n};for(let e=0;e<t;e++)r[e]=i;return r}destroy(){this.gpu=null}},Am.extension={type:[f.WebGPUSystem],name:`state`}})),Mm,Nm=s((()=>{Mm={type:`image`,upload(e,t,n,r=0){let i=e.resource,a=(e.pixelWidth|0)*(e.pixelHeight|0),o=i.byteLength/a;n.device.queue.writeTexture({texture:t,origin:{x:0,y:0,z:r}},i,{offset:0,rowsPerImage:e.pixelHeight,bytesPerRow:e.pixelWidth*o},{width:e.pixelWidth,height:e.pixelHeight,depthOrArrayLayers:1})}}})),Pm,Fm,Im,Lm=s((()=>{Pm={"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}},Fm={blockBytes:4,blockWidth:1,blockHeight:1},Im={type:`compressed`,upload(e,t,n,r=0){let i=e.pixelWidth,a=e.pixelHeight,o=Pm[e.format]||Fm;for(let s=0;s<e.resource.length;s++){let c=e.resource[s],l=Math.ceil(i/o.blockWidth)*o.blockBytes;n.device.queue.writeTexture({texture:t,mipLevel:s,origin:{x:0,y:0,z:r}},c,{offset:0,bytesPerRow:l},{width:Math.ceil(i/o.blockWidth)*o.blockWidth,height:Math.ceil(a/o.blockHeight)*o.blockHeight,depthOrArrayLayers:1}),i=Math.max(i>>1,1),a=Math.max(a>>1,1)}}}}));function Rm(e){return{type:`cube`,upload(t,n,r){let i=t.faces;for(let t=0;t<zm.length;t++){let a=i[zm[t]];(e[a.uploadMethodId]||e.image).upload(a,n,r,t)}}}}var zm,Bm=s((()=>{zm=[`right`,`left`,`top`,`bottom`,`front`,`back`]})),Vm,Hm=s((()=>{V(),I(),Vm={type:`image`,upload(e,t,n,r=0){let i=e.resource;if(!i)return;if(globalThis.HTMLImageElement&&i instanceof HTMLImageElement){let t=B.get().createCanvas(i.width,i.height);t.getContext(`2d`).drawImage(i,0,0,i.width,i.height),e.resource=t,F(`ImageSource: Image element passed, converting to canvas and replacing resource.`)}let a=Math.min(t.width,e.resourceWidth||e.pixelWidth),o=Math.min(t.height,e.resourceHeight||e.pixelHeight),s=e.alphaMode===`premultiply-alpha-on-upload`;n.device.queue.copyExternalImageToTexture({source:i},{texture:t,origin:{x:0,y:0,z:r},premultipliedAlpha:s},{width:a,height:o})}}})),Um,Wm=s((()=>{Hm(),Um={type:`video`,upload(e,t,n,r){Vm.upload(e,t,n,r)}}})),Gm,Km=s((()=>{Gm=class{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.device.createShaderModule({code:`
|
|
717
|
+
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
718
|
+
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
|
|
719
|
+
|
|
720
|
+
struct VertexOutput {
|
|
721
|
+
@builtin(position) position : vec4<f32>,
|
|
722
|
+
@location(0) texCoord : vec2<f32>,
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
@vertex
|
|
726
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
|
|
727
|
+
var output : VertexOutput;
|
|
728
|
+
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
|
|
729
|
+
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
|
|
730
|
+
return output;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
@group(0) @binding(0) var imgSampler : sampler;
|
|
734
|
+
@group(0) @binding(1) var img : texture_2d<f32>;
|
|
735
|
+
|
|
736
|
+
@fragment
|
|
737
|
+
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
|
738
|
+
return textureSample(img, imgSampler, texCoord);
|
|
739
|
+
}
|
|
740
|
+
`}),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){let t=this._getMipmapPipeline(e.format);if(e.dimension===`3d`||e.dimension===`1d`)throw Error(`Generating mipmaps for non-2d textures is currently unsupported!`);let n=e,r=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){let t={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};n=this.device.createTexture(t)}let a=this.device.createCommandEncoder({}),o=t.getBindGroupLayout(0);for(let s=0;s<r;++s){let r=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),c=+!!i;for(let i=1;i<e.mipLevelCount;++i){let e=n.createView({baseMipLevel:c++,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),i=a.beginRenderPass({colorAttachments:[{view:e,storeOp:`store`,loadOp:`clear`,clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:r}]});i.setPipeline(t),i.setBindGroup(0,l),i.draw(3,1,0,0),i.end(),r=e}}if(!i){let t={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r};for(let r=1;r<e.mipLevelCount;++r)a.copyTextureToTexture({texture:n,mipLevel:r-1},{texture:e,mipLevel:r},t),t.width=Math.ceil(t.width/2),t.height=Math.ceil(t.height/2)}return this.device.queue.submit([a.finish()]),i||n.destroy(),e}}})),qm,Jm,Ym,Xm=s((()=>{V(),g(),vp(),ps(),Pa(),rs(),Nm(),Lm(),Bm(),Hm(),Wm(),Km(),qm=class{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}},Jm=class e{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,`_bindGroupHash`,`hash`),this._managedTextures=new _p({renderer:t,type:`resource`,onUnload:this.onSourceUnload.bind(this),name:`gpuTextureSource`});let n={image:Vm,buffer:Mm,video:Um,compressed:Im,...e.uploadExtensions};this._uploads={...n,cube:Rm(n)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gpu=e}initSource(e){return e._gpuData[this._renderer.uid]?.gpuTexture||this._initSource(e)}_initSource(e){if(e.autoGenerateMipmaps){let t=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(t))+1}let t;e.sampleCount>1?(t=GPUTextureUsage.RENDER_ATTACHMENT,e.transient&&this._renderer.device.extensions.transientAttachment&&(t|=GPUTextureUsage.TRANSIENT_ATTACHMENT)):(t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,e.uploadMethodId!==`compressed`&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC));let n=Pm[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(e.pixelWidth/n.blockWidth)*n.blockWidth,i=Math.ceil(e.pixelHeight/n.blockHeight)*n.blockHeight,a={label:e.label,size:{width:r,height:i,depthOrArrayLayers:e.arrayLayerCount},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},o=this._gpu.device.createTexture(a);return e._gpuData[this._renderer.uid]=new qm(o),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),o}onSourceUpdate(e){let 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||=new Gm(this._gpu.device);let 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;let t=e._gpuData[this._renderer.uid],n=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){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuTexture||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){let t=e.source;return this._bindGroupHash[e.uid]=new ns({0:t,1:t.style,2:new fs({uTextureMatrix:{type:`mat3x3<f32>`,value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){let t=e.source;t._gcLastUsed=this._renderer.gc.now;let n=t._gpuData[this._renderer.uid];return n||=(this.initSource(t),t._gpuData[this._renderer.uid]),n.textureView||=n.gpuTexture.createView({dimension:t.viewDimension}),n.textureView}generateCanvas(e){let t=this._renderer,n=t.gpu.device.createCommandEncoder(),r=B.get().createCanvas();r.width=e.source.pixelWidth,r.height=e.source.pixelHeight;let i=r.getContext(`webgpu`);return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:B.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:`premultiplied`}),n.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:r.width,height:r.height}),t.gpu.device.queue.submit([n.finish()]),r}getPixels(e){let t=this.generateCanvas(e),n=Na.getOptimalCanvasAndContext(t.width,t.height),r=n.context;r.drawImage(t,0,0);let{width:i,height:a}=t,o=r.getImageData(0,0,i,a),s=new Uint8ClampedArray(o.data.buffer);return Na.returnCanvasAndContext(n),{pixels:s,width:i,height:a}}destroy(){this._managedTextures.destroy();for(let e of Object.keys(this._bindGroupHash)){let t=Number(e);this._bindGroupHash[t]?.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}},Jm.extension={type:[f.WebGPUSystem],name:`texture`},Jm.uploadExtensions=Object.create(null),Ym=Jm,h.handleByMap(f.TextureUploaderWebGPU,Ym.uploadExtensions)})),Zm=l({WebGPURenderer:()=>ih}),Qm,$m,eh,th,nh,rh,ih,ah=s((()=>{g(),Eu(),ju(),Pu(),_l(),mp(),as(),gp(),xp(),Cp(),Tp(),Dp(),kp(),jp(),Xp(),rm(),pm(),Tm(),Dm(),jm(),Xm(),Qm=[...fp,Yp,Ep,wp,Op,bp,Ym,wm,Em,Am,fm,Sp,Ap,hp],$m=[...pp,nm],eh=[Nu,Au,Tu],th=[],nh=[],rh=[],h.handleByNamedList(f.WebGPUSystem,th),h.handleByNamedList(f.WebGPUPipes,nh),h.handleByNamedList(f.WebGPUPipesAdaptor,rh),h.add(...Qm,...$m,...eh),ih=class extends gl{constructor(){let e={name:`webgpu`,type:is.WEBGPU,systems:th,renderPipes:nh,renderPipeAdaptors:rh};super(e)}}})),oh,sh=s((()=>{g(),M(),ou(),lu(),_u(),xu(),wu(),Ud(),hs(),ps(),oh=class{contextChange(e){let t=new fs({uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uTransformMatrix:{value:new j,type:`mat3x3<f32>`},uRound:{value:0,type:`f32`}}),n=e.limits.maxBatchableTextures,r=au({name:`graphics`,bits:[cu,mu(n),bu,Cu]});this.shader=new ms({glProgram:r,resources:{localUniforms:t,batchSamplers:Vd(n)}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{batcher:a,instructions:o}=i.graphicsContext.getContextRenderData(n);r.groups[0]=i.globalUniforms.bindGroup,i.state.set(e.state),i.shader.bind(r),i.geometry.bind(a.geometry,r.glProgram);let s=o.instructions;for(let e=0;e<o.instructionSize;e++){let t=s[e];if(t.size){for(let e=0;e<t.textures.count;e++)i.texture.bind(t.textures.textures[e],e);i.geometry.draw(t.topology,t.size,t.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}},oh.extension={type:[f.WebGLPipesAdaptor],name:`graphics`}})),ch,lh=s((()=>{g(),M(),ou(),xu(),wu(),ku(),hs(),z(),I(),ch=class{init(){let e=au({name:`mesh`,bits:[bu,Ou,Cu]});this._shader=new ms({glProgram:e,resources:{uTexture:R.EMPTY.source,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new j}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r){r=this._shader;let e=t.texture,n=e.source;r.resources.uTexture=n,r.resources.uSampler=n.style,r.resources.textureUniforms.uniforms.uTextureMatrix=e.textureMatrix.mapCoord}else if(!r.glProgram){F(`Mesh shader has no glProgram`,t.shader);return}r.groups[100]=n.globalUniforms.bindGroup,r.groups[101]=e.localUniformsBindGroup,n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}},ch.extension={type:[f.WebGLPipesAdaptor],name:`mesh`}})),uh,dh=s((()=>{g(),Ts(),uh=class{constructor(){this._tempState=ws.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,n){let r=e.renderer,i=this._didUploadHash[n.uid];r.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),r.shader.updateUniformGroup(r.globalUniforms.uniformGroup),r.geometry.bind(t,n.glProgram)}execute(e,t){let n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);let r=t.textures.textures;for(let e=0;e<t.textures.count;e++)n.texture.bind(r[e],e);n.geometry.draw(t.topology,t.size,t.start)}},uh.extension={type:[f.WebGLPipesAdaptor],name:`batch`}})),fh,ph=s((()=>{fh=(e=>(e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e))(fh||{})})),mh,hh=s((()=>{mh=class{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}}})),gh,_h=s((()=>{g(),vp(),Rs(),ph(),hh(),gh=class{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new _p({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){let{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){let{_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,r=this._nextBindBaseIndex;for(;n<2;){r>=this._maxBindings&&(r=this._minBaseLocation,n++);let e=this._boundBufferBases[r];if(e&&e._lastBindCallId===this._bindCallId){r++;continue}break}return t=r,this._nextBindBaseIndex=r+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){let t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,n,r){let{_gl:i}=this;n||=0,t||=0,this._boundBufferBases[t]=null,i.bindBufferRange(i.UNIFORM_BUFFER,t||0,e.buffer,n*256,r||256)}updateBuffer(e){let{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);let r=e.data,i=e.descriptor.usage&Ls.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return r?n.byteLength>=r.byteLength?t.bufferSubData(n.type,0,r,0,e._updateSize/r.BYTES_PER_ELEMENT):(n.byteLength=r.byteLength,t.bufferData(n.type,r,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){let n=e._gpuData[this._renderer.uid];n&&(t||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){let{_gl:t}=this,n=fh.ARRAY_BUFFER;e.descriptor.usage&Ls.INDEX?n=fh.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&Ls.UNIFORM&&(n=fh.UNIFORM_BUFFER);let r=new mh(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=r,this._managedBuffers.add(e),r}resetState(){this._boundBufferBases=Object.create(null)}},gh.extension={type:[f.WebGLSystem],name:`buffer`}})),vh,yh,bh=s((()=>{V(),g(),I(),vh=class e{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(t){t={...e.defaultOptions,...t};let n=this.multiView=t.multiView;if(t.context&&n&&(F(`Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together.`),n=!1),n?this.canvas=B.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{let e=this._renderer.background.alpha<1,n=t.premultipliedAlpha??!0,r=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:n,antialias:r,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??`default`})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&F(`multiView is disabled, but targetCanvas is not the main canvas`);return}let{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 B.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);let t=this._renderer.view.canvas;t.addEventListener(`webglcontextlost`,this.handleContextLost,!1),t.addEventListener(`webglcontextrestored`,this.handleContextRestored,!1)}createContext(e,t){let n,r=this.canvas;if(e===2&&(n=r.getContext(`webgl2`,t)),!n&&(n=r.getContext(`webgl`,t),!n))throw Error(`This browser does not support WebGL. Try using the canvas renderer`);this.gl=n,this.initFromContext(this.gl)}getExtensions(){let{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`)};let n=e.getExtension(`WEBGL_provoking_vertex`);n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){let e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener(`webglcontextlost`,this.handleContextLost),e.removeEventListener(`webglcontextrestored`,this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){let t=e.getContextAttributes();t&&!t.stencil&&F(`Provided WebGL context does not have a stencil buffer, masks may not render correctly`);let n=this.supports,r=this.webGLVersion===2,i=this.extensions;n.uint32Indices=r||!!i.uint32ElementIndex,n.uniformBufferObject=r,n.vertexArrayObject=r||!!i.vertexArrayObject,n.srgbTextures=r||!!i.srgb,n.nonPowOf2wrapping=r,n.nonPowOf2mipmaps=r,n.msaa=r,n.uint32Indices||F(`Provided WebGL context does not support 32 index buffer, large scenes may not render correctly`)}},vh.extension={type:[f.WebGLSystem],name:`context`},vh.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1},yh=vh})),xh,Sh,W,Ch=s((()=>{xh=(e=>(e[e.RGBA=6408]=`RGBA`,e[e.RGB=6407]=`RGB`,e[e.RG=33319]=`RG`,e[e.RED=6403]=`RED`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.ALPHA=6406]=`ALPHA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e))(xh||{}),Sh=(e=>(e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e))(Sh||{}),W=(e=>(e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.BYTE=5120]=`BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.INT=5124]=`INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.HALF_FLOAT=36193]=`HALF_FLOAT`,e))(W||{})}));function wh(e){return Th[e]??Th.float32}var Th,Eh=s((()=>{Ch(),Th={uint8x2:W.UNSIGNED_BYTE,uint8x4:W.UNSIGNED_BYTE,sint8x2:W.BYTE,sint8x4:W.BYTE,unorm8x2:W.UNSIGNED_BYTE,unorm8x4:W.UNSIGNED_BYTE,snorm8x2:W.BYTE,snorm8x4:W.BYTE,uint16x2:W.UNSIGNED_SHORT,uint16x4:W.UNSIGNED_SHORT,sint16x2:W.SHORT,sint16x4:W.SHORT,unorm16x2:W.UNSIGNED_SHORT,unorm16x4:W.UNSIGNED_SHORT,snorm16x2:W.SHORT,snorm16x4:W.SHORT,float16x2:W.HALF_FLOAT,float16x4:W.HALF_FLOAT,float32:W.FLOAT,float32x2:W.FLOAT,float32x3:W.FLOAT,float32x4:W.FLOAT,uint32:W.UNSIGNED_INT,uint32x2:W.UNSIGNED_INT,uint32x3:W.UNSIGNED_INT,uint32x4:W.UNSIGNED_INT,sint32:W.INT,sint32x2:W.INT,sint32x3:W.INT,sint32x4:W.INT}})),Dh,Oh,kh,Ah=s((()=>{g(),vp(),Io(),om(),Eh(),Dh={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5},Oh=class{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}},kh=class{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new _p({renderer:e,type:`resource`,onUnload:this.onGeometryUnload.bind(this),name:`glGeometry`})}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw Error(`[PixiJS] Vertex Array Objects are not supported on this device`);this.destroyAll(!0);let t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=e=>t.bindVertexArrayOES(e),e.deleteVertexArray=e=>t.deleteVertexArrayOES(e));let n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(e,t,r,i)=>{n.drawArraysInstancedANGLE(e,t,r,i)},e.drawElementsInstanced=(e,t,r,i,a)=>{n.drawElementsInstancedANGLE(e,t,r,i,a)},e.vertexAttribDivisor=(e,t)=>n.vertexAttribDivisorANGLE(e,t)),this._activeGeometry=null,this._activeVao=null}bind(e,t){let n=this.gl;this._activeGeometry=e;let r=this.getVao(e,t);this._activeVao!==r&&(this._activeVao=r,n.bindVertexArray(r)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n];t.updateBuffer(r)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){let n=e.attributes,r=t._attributeData;for(let e in r)if(!n[e])throw Error(`shader and geometry incompatible, geometry missing the "${e}" attribute`)}getSignature(e,t){let n=e.attributes,r=t._attributeData,i=[`g`,e.uid];for(let e in n)r[e]&&i.push(e,r[e].location);return i.join(`-`)}getVao(e,t){return e._gpuData[this._renderer.uid]?.vaoCache[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){let r=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);let a=this.getSignature(e,t),o=e._gpuData[this._renderer.uid];o||(o=new Oh,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));let s=o.vaoCache,c=s[a];if(c)return s[t._key]=c,c;im(e,t._attributeData);let l=e.buffers;c=r.createVertexArray(),r.bindVertexArray(c);for(let e=0;e<l.length;e++){let t=l[e];i.bind(t)}return this.activateVao(e,t),s[t._key]=c,s[a]=c,r.bindVertexArray(null),c}onGeometryUnload(e,t=!1){let n=e._gpuData[this._renderer.uid];if(!n)return;let r=n.vaoCache;if(!t)for(let e in r)this._activeVao!==r[e]&&this.resetState(),this.gl.deleteVertexArray(r[e])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){let n=this._renderer.gl,r=this._renderer.buffer,i=e.attributes;e.indexBuffer&&r.bind(e.indexBuffer);let a=null;for(let e in i){let o=i[e],s=o.buffer,c=r.getGlBuffer(s),l=t._attributeData[e];if(l){a!==c&&(r.bind(s),a=c);let e=l.location;n.enableVertexAttribArray(e);let t=Po(o.format),i=wh(o.format);if(l.format?.substring(1,4)===`int`?n.vertexAttribIPointer(e,t.size,i,o.stride,o.offset):n.vertexAttribPointer(e,t.size,i,t.normalised,o.stride,o.offset),o.instance)if(this.hasInstance){let t=o.divisor??1;n.vertexAttribDivisor(e,t)}else throw Error(`geometry error, GPU Instancing is not supported on this device`)}}}draw(e,t,n,r){let{gl:i}=this._renderer,a=this._activeGeometry,o=Dh[e||a.topology];if(r??=a.instanceCount,a.indexBuffer){let e=a.indexBuffer.data.BYTES_PER_ELEMENT,s=e===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;r===1?i.drawElements(o,t||a.indexBuffer.data.length,s,(n||0)*e):i.drawElementsInstanced(o,t||a.indexBuffer.data.length,s,(n||0)*e,r)}else r===1?i.drawArrays(o,n||0,t||a.getSize()):i.drawArraysInstanced(o,n||0,t||a.getSize(),r);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}},kh.extension={type:[f.WebGLSystem],name:`geometry`}})),jh,Mh,Nh,Ph=s((()=>{g(),I(),qs(),hs(),Ts(),_n(),z(),No(),jh=new Ks({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Mh=class e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(t={}){let{useBackBuffer:n,antialias:r}={...e.defaultOptions,...t};this.useBackBuffer=n,this._antialias=r,this._renderer.context.supports.msaa||(F(`antialiasing, is not supported on when using the back buffer`),this._antialias=!1),this._state=ws.for2d();let i=new Mo({vertex:`
|
|
741
|
+
attribute vec2 aPosition;
|
|
742
|
+
out vec2 vUv;
|
|
743
|
+
|
|
744
|
+
void main() {
|
|
745
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
746
|
+
|
|
747
|
+
vUv = (aPosition + 1.0) / 2.0;
|
|
748
|
+
|
|
749
|
+
// flip dem UVs
|
|
750
|
+
vUv.y = 1.0 - vUv.y;
|
|
751
|
+
}`,fragment:`
|
|
752
|
+
in vec2 vUv;
|
|
753
|
+
out vec4 finalColor;
|
|
754
|
+
|
|
755
|
+
uniform sampler2D uTexture;
|
|
756
|
+
|
|
757
|
+
void main() {
|
|
758
|
+
finalColor = texture(uTexture, vUv);
|
|
759
|
+
}`,name:`big-triangle`});this._bigTriangleShader=new ms({glProgram:i,resources:{uTexture:R.WHITE.source}})}renderStart(e){let t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){let t=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=t.colorTexture,e.target=this._getBackBufferTexture(t.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let 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:jh,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new R({source:new gn({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(),null)}},Mh.extension={type:[f.WebGLSystem],name:`backBuffer`,priority:1},Mh.defaultOptions={useBackBuffer:!1},Nh=Mh})),Fh,Ih=s((()=>{g(),Fh=class{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)))}},Fh.extension={type:[f.WebGLSystem],name:`colorMask`}})),Lh,Rh=s((()=>{g(),Lh=class{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){let t=this._renderer,{geometry:n,shader:r,state:i,skipSync:a,topology:o,size:s,start:c,instanceCount:l}=e;t.shader.bind(r,a),t.geometry.bind(n,t.shader._activeProgram),i&&t.state.set(i),t.geometry.draw(o,s,c,l??n.instanceCount)}destroy(){this._renderer=null}},Lh.extension={type:[f.WebGLSystem],name:`encoder`}})),zh,Bh=s((()=>{g(),Sd(),zh=class{constructor(e){this._renderer=e}contextChange(){let e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=bd(this.maxTextures,e);let t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}},zh.extension={type:[f.WebGLSystem],name:`limits`}})),Vh,Hh=s((()=>{g(),cm(),gd(),Vh=class{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:hd.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||=this._renderTargetStencilState[e.uid]={stencilMode:hd.DISABLED,stencilReference:0},this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=hd.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){let n=this._renderTargetStencilState[this._activeRenderTarget.uid],r=this._gl,i=sm[e],a=this._stencilCache;if(n.stencilMode=e,n.stencilReference=t,e===hd.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,r.disable(r.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,r.enable(r.STENCIL_TEST)),(e!==a.stencilMode||a.stencilReference!==t)&&(a.stencilMode=e,a.stencilReference=t,r.stencilFunc(this._comparisonFuncMapping[i.stencilBack.compare],t,255),r.stencilOp(r.KEEP,r.KEEP,this._stencilOpsMapping[i.stencilBack.passOp]))}},Vh.extension={type:[f.WebGLSystem],name:`stencil`}}));function Uh(e){let t=e.map(e=>({data:e,offset:0,size:0})),n=0,r=0;for(let e=0;e<t.length;e++){let i=t[e];if(n=Wh[i.data.type],!n)throw Error(`Unknown type ${i.data.type}`);i.data.size>1&&(n=Math.max(n,16)*i.data.size);let a=n===12?16:n;i.size=n;let o=r%16;o>0&&16-o<a?r+=(16-o)%16:r+=(n-o%n)%n,i.offset=r,r+=n}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}var Wh,Gh=s((()=>{Wh={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 Kh(e,t){let n=Math.max(Wh[e.data.type]/16,1),r=e.data.value.length/e.data.size,i=(4-r%4)%4,a=e.data.type.indexOf(`i32`)>=0?`dataInt32`:`data`;return`
|
|
760
|
+
v = uv.${e.data.name};
|
|
761
|
+
offset += ${t};
|
|
762
|
+
|
|
763
|
+
arrayOffset = offset;
|
|
764
|
+
|
|
765
|
+
t = 0;
|
|
766
|
+
|
|
767
|
+
for(var i=0; i < ${e.data.size*n}; i++)
|
|
768
|
+
{
|
|
769
|
+
for(var j = 0; j < ${r}; j++)
|
|
770
|
+
{
|
|
771
|
+
${a}[arrayOffset++] = v[t++];
|
|
772
|
+
}
|
|
773
|
+
${i===0?``:`arrayOffset += ${i};`}
|
|
774
|
+
}
|
|
775
|
+
`}var qh=s((()=>{Gh()}));function Jh(e){return zp(e,`uboStd40`,Kh,Hp)}var Yh=s((()=>{Bp(),Wp(),qh()})),Xh,Zh=s((()=>{g(),Np(),Gh(),Yh(),Xh=class extends Mp{constructor(){super({createUboElements:Uh,generateUboSync:Jh})}},Xh.extension={type:[f.WebGLSystem],name:`ubo`}})),Qh,$h=s((()=>{Qh=class{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}})),eg,tg=s((()=>{yt(),I(),ua(),dl(),$h(),eg=class{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new vt}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new vt;let e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},(t,n)=>e.COLOR_ATTACHMENT0+n)}copyToTexture(e,t,n,r,i){let a=this._renderTargetSystem,o=this._renderer,s=a.getGpuRenderTarget(e),c=o.gl;return this.finishRenderPass(e),c.bindFramebuffer(c.FRAMEBUFFER,s.resolveTargetFramebuffer),o.texture.bind(t,0),c.copyTexSubImage2D(c.TEXTURE_2D,0,i.x,i.y,n.x,n.y,r.width,r.height),t}startRenderPass(e,t=!0,n,r,i=0,a=0){let o=this._renderTargetSystem,s=e.colorTexture,c=o.getGpuRenderTarget(e);if(a!==0&&this._renderer.context.webGLVersion<2)throw Error(`[RenderTargetSystem] Rendering to array layers requires WebGL2.`);if(i>0){if(c.msaa)throw Error(`[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.`);if(this._renderer.context.webGLVersion<2)throw Error(`[RenderTargetSystem] Rendering to mip levels requires WebGL2.`)}let l=r.y;e.isRoot&&(l=s.pixelHeight-r.height-r.y),e.colorTextures.forEach(e=>{this._renderer.texture.unbind(e)});let u=this._renderer.gl;u.bindFramebuffer(u.FRAMEBUFFER,c.framebuffer),!e.isRoot&&(c._attachedMipLevel!==i||c._attachedLayer!==a)&&(e.colorTextures.forEach((e,t)=>{let n=this._renderer.texture.getGlSource(e);if(n.target===u.TEXTURE_2D){if(a!==0)throw Error(`[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.`);u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+t,u.TEXTURE_2D,n.texture,i)}else if(n.target===u.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw Error(`[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.`);u.framebufferTextureLayer(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+t,n.texture,i,a)}else if(n.target===u.TEXTURE_CUBE_MAP){if(a<0||a>5)throw Error(`[RenderTargetSystem] Cube map layer must be between 0 and 5.`);u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+t,u.TEXTURE_CUBE_MAP_POSITIVE_X+a,n.texture,i)}else throw Error(`[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.`)}),c._attachedMipLevel=i,c._attachedLayer=a),e.colorTextures.length>1&&this._setDrawBuffers(e,u);let d=this._viewPortCache;(d.x!==r.x||d.y!==l||d.width!==r.width||d.height!==r.height)&&(d.x=r.x,d.y=l,d.width=r.width,d.height=r.height,u.viewport(r.x,l,r.width,r.height)),!c.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(c),this.clear(e,t,n)}finishRenderPass(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);if(!t.msaa)return;let n=this._renderer.gl;n.bindFramebuffer(n.FRAMEBUFFER,t.resolveTargetFramebuffer),n.bindFramebuffer(n.READ_FRAMEBUFFER,t.framebuffer),n.blitFramebuffer(0,0,t.width,t.height,0,0,t.width,t.height,n.COLOR_BUFFER_BIT,n.NEAREST),n.bindFramebuffer(n.FRAMEBUFFER,t.framebuffer)}initGpuRenderTarget(e){let t=this._renderer.gl,n=new Qh;return n._attachedMipLevel=0,n._attachedLayer=0,e.colorTexture instanceof la?(this._renderer.context.ensureCanvasSize(e.colorTexture.resource),n.framebuffer=null,n):(this._initColor(e,n),t.bindFramebuffer(t.FRAMEBUFFER,null),n)}destroyGpuRenderTarget(e){let t=this._renderer.gl;e.framebuffer&&=(t.deleteFramebuffer(e.framebuffer),null),e.resolveTargetFramebuffer&&=(t.deleteFramebuffer(e.resolveTargetFramebuffer),null),e.depthStencilRenderBuffer&&=(t.deleteRenderbuffer(e.depthStencilRenderBuffer),null),e.msaaRenderBuffer.forEach(e=>{t.deleteRenderbuffer(e)}),e.msaaRenderBuffer=null}clear(e,t,n,r,i=0,a=0){if(!t)return;if(a!==0)throw Error(`[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.`);let o=this._renderTargetSystem;typeof t==`boolean`&&(t=t?ul.ALL:ul.NONE);let s=this._renderer.gl;if(t&ul.COLOR){n??=o.defaultClearColor;let e=this._clearColorCache,t=n;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3])&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],s.clearColor(t[0],t[1],t[2],t[3]))}s.clear(t)}resizeGpuRenderTarget(e){if(e.isRoot)return;let t=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,t),(e.stencil||e.depth)&&this._resizeStencil(t)}_initColor(e,t){let n=this._renderer,r=n.gl,i=r.createFramebuffer();if(t.resolveTargetFramebuffer=i,r.bindFramebuffer(r.FRAMEBUFFER,i),t.width=e.colorTexture.source.pixelWidth,t.height=e.colorTexture.source.pixelHeight,e.colorTextures.forEach((e,i)=>{let a=e.source;a.antialias&&(n.context.supports.msaa?t.msaa=!0:F(`[RenderTexture] Antialiasing on textures is not supported in WebGL1`)),n.texture.bindSource(a,0);let o=n.texture.getGlSource(a),s=o.texture;if(o.target===r.TEXTURE_2D)r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,r.TEXTURE_2D,s,0);else if(o.target===r.TEXTURE_2D_ARRAY){if(n.context.webGLVersion<2)throw Error(`[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.`);r.framebufferTextureLayer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,s,0,0)}else if(o.target===r.TEXTURE_CUBE_MAP)r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,r.TEXTURE_CUBE_MAP_POSITIVE_X,s,0);else throw Error(`[RenderTargetSystem] Unsupported texture target for framebuffer attachment.`)}),t.msaa){let n=r.createFramebuffer();t.framebuffer=n,r.bindFramebuffer(r.FRAMEBUFFER,n),e.colorTextures.forEach((e,n)=>{let i=r.createRenderbuffer();t.msaaRenderBuffer[n]=i})}else t.framebuffer=i;this._resizeColor(e,t)}_resizeColor(e,t){let n=e.colorTexture.source;if(t.width=n.pixelWidth,t.height=n.pixelHeight,t._attachedMipLevel=0,t._attachedLayer=0,e.colorTextures.forEach((e,t)=>{t!==0&&e.source.resize(n.width,n.height,n._resolution)}),t.msaa){let n=this._renderer,r=n.gl,i=t.framebuffer;r.bindFramebuffer(r.FRAMEBUFFER,i),e.colorTextures.forEach((e,i)=>{let a=e.source;n.texture.bindSource(a,0);let o=n.texture.getGlSource(a).internalFormat,s=t.msaaRenderBuffer[i];r.bindRenderbuffer(r.RENDERBUFFER,s),r.renderbufferStorageMultisample(r.RENDERBUFFER,4,o,a.pixelWidth,a.pixelHeight),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,r.RENDERBUFFER,s)})}}_initStencil(e){if(e.framebuffer===null)return;let 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){let 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){let t=e.colorTexture.resource;this._renderer.context.multiView&&la.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(this._renderer.context.multiView&&la.test(e.colorTexture.resource)){let t=this._renderer.context.canvas,n=e.colorTexture;n.context2D.drawImage(t,0,n.pixelHeight-t.height)}}_setDrawBuffers(e,t){let n=e.colorTextures.length,r=this._drawBuffersCache[n];if(this._renderer.context.webGLVersion===1){let e=this._renderer.context.extensions.drawBuffers;e?e.drawBuffersWEBGL(r):F(`[RenderTexture] This WebGL1 context does not support rendering to multiple targets`)}else t.drawBuffers(r)}}})),ng,rg=s((()=>{g(),ym(),tg(),ng=class extends vm{constructor(e){super(e),this.adaptor=new eg,this.adaptor.init(e,this)}},ng.extension={type:[f.WebGLSystem],name:`renderTarget`}}));function ig(e,t){let n=[],r=[`
|
|
776
|
+
var g = s.groups;
|
|
777
|
+
var sS = r.shader;
|
|
778
|
+
var p = s.glProgram;
|
|
779
|
+
var ugS = r.uniformGroup;
|
|
780
|
+
var resources;
|
|
781
|
+
`],i=!1,a=0,o=t._getProgramData(e.glProgram);for(let s in e.groups){let c=e.groups[s];n.push(`
|
|
782
|
+
resources = g[${s}].resources;
|
|
783
|
+
`);for(let l in c.resources){let u=c.resources[l];if(u instanceof fs)if(u.ubo){let t=e._uniformBindMap[s][Number(l)];n.push(`
|
|
784
|
+
sS.bindUniformBlock(
|
|
785
|
+
resources[${l}],
|
|
786
|
+
'${t}',
|
|
787
|
+
${e.glProgram._uniformBlockData[t].index}
|
|
788
|
+
);
|
|
789
|
+
`)}else n.push(`
|
|
790
|
+
ugS.updateUniformGroup(resources[${l}], p, sD);
|
|
791
|
+
`);else if(u instanceof Zp){let t=e._uniformBindMap[s][Number(l)];n.push(`
|
|
792
|
+
sS.bindUniformBlock(
|
|
793
|
+
resources[${l}],
|
|
794
|
+
'${t}',
|
|
795
|
+
${e.glProgram._uniformBlockData[t].index}
|
|
796
|
+
);
|
|
797
|
+
`)}else if(u instanceof gn){let c=e._uniformBindMap[s][l],u=o.uniformData[c];u&&(i||(i=!0,r.push(`
|
|
798
|
+
var tS = r.texture;
|
|
799
|
+
`)),t._gl.uniform1i(u.location,a),n.push(`
|
|
800
|
+
tS.bind(resources[${l}], ${a});
|
|
801
|
+
`),a++)}}}let s=[...r,...n].join(`
|
|
802
|
+
`);return Function(`r`,`s`,`sD`,s)}var ag=s((()=>{Qp(),ps(),_n()})),og,sg=s((()=>{og=class{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 cg(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var lg=s((()=>{}));function ug(e){let t=Array(e);for(let e=0;e<t.length;e++)t[e]=!1;return t}function dg(e,t){switch(e){case`float`:return 0;case`vec2`:return new Float32Array(2*t);case`vec3`:return new Float32Array(3*t);case`vec4`:return new Float32Array(4*t);case`int`:case`uint`:case`sampler2D`:case`sampler2DArray`:return 0;case`ivec2`:return new Int32Array(2*t);case`ivec3`:return new Int32Array(3*t);case`ivec4`:return new Int32Array(4*t);case`uvec2`:return new Uint32Array(2*t);case`uvec3`:return new Uint32Array(3*t);case`uvec4`:return new Uint32Array(4*t);case`bool`:return!1;case`bvec2`:return ug(2*t);case`bvec3`:return ug(3*t);case`bvec4`:return ug(4*t);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}var fg=s((()=>{}));function pg(e,t){if(!hg){let t=Object.keys(gg);hg={};for(let n=0;n<t.length;++n){let r=t[n];hg[e[r]]=gg[r]}}return hg[t]}function mg(e,t){let n=pg(e,t);return _g[n]||`float32`}var hg,gg,_g,vg=s((()=>{hg=null,gg={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`},_g={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 yg(e,t,n=!1){let r={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){let i=t.getActiveAttrib(e,n);if(i.name.startsWith(`gl_`))continue;let a=mg(t,i.type);r[i.name]={location:0,format:a,stride:Po(a).stride,offset:0,instance:!1,start:0}}let a=Object.keys(r);if(n){a.sort((e,t)=>e>t?1:-1);for(let n=0;n<a.length;n++)r[a[n]].location=n,t.bindAttribLocation(e,n,a[n]);t.linkProgram(e)}else for(let n=0;n<a.length;n++)r[a[n]].location=t.getAttribLocation(e,a[n]);return r}var bg=s((()=>{Io(),vg()}));function xg(e,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};let n={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<r;i++){let r=t.getActiveUniformBlockName(e,i);n[r]={name:r,index:t.getUniformBlockIndex(e,r),size:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_DATA_SIZE)}}return n}var Sg=s((()=>{}));function Cg(e,t){let n={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<r;i++){let r=t.getActiveUniform(e,i),a=r.name.replace(/\[.*?\]$/,``),o=!!r.name.match(/\[.*?\]$/),s=pg(t,r.type);n[a]={name:a,index:i,type:s,size:r.size,isArray:o,value:dg(s,r.size)}}return n}var wg=s((()=>{fg(),vg()}));function Tg(e,t){let n=e.getShaderSource(t);if(n===null){console.error(`PixiJS Error: Could not retrieve shader source (WebGL context may be lost).`);return}let r=n.split(`
|
|
803
|
+
`).map((e,t)=>`${t}: ${e}`),i=e.getShaderInfoLog(t)??``,a=i.split(`
|
|
804
|
+
`),o={},s=a.map(e=>parseFloat(e.replace(/^ERROR\: 0\:([\d]+)\:.*$/,`$1`))).filter(e=>e&&!o[e]?(o[e]=!0,!0):!1),c=[``];s.forEach(e=>{r[e-1]=`%c${r[e-1]}%c`,c.push(`background: #FF0000; color:#FFFFFF; font-size: 10px`,`font-size: 10px`)}),c[0]=r.join(`
|
|
805
|
+
`),console.error(i),console.groupCollapsed(`click to view full shader code`),console.warn(...c),console.groupEnd()}function Eg(e,t,n,r){e.getProgramParameter(t,e.LINK_STATUS)||(e.getShaderParameter(n,e.COMPILE_STATUS)||Tg(e,n),e.getShaderParameter(r,e.COMPILE_STATUS)||Tg(e,r),console.error(`PixiJS Error: Could not initialize shader.`),e.getProgramInfoLog(t)!==``&&console.warn(`PixiJS Warning: gl.getProgramInfoLog()`,e.getProgramInfoLog(t)))}var Dg=s((()=>{}));function Og(e,t){let n=cg(e,e.VERTEX_SHADER,t.vertex),r=cg(e,e.FRAGMENT_SHADER,t.fragment),i=e.createProgram();e.attachShader(i,n),e.attachShader(i,r);let a=t.transformFeedbackVaryings;a&&(typeof e.transformFeedbackVaryings==`function`?e.transformFeedbackVaryings(i,a.names,a.bufferMode===`separate`?e.SEPARATE_ATTRIBS:e.INTERLEAVED_ATTRIBS):F(`TransformFeedback is not supported but TransformFeedbackVaryings are given.`)),e.linkProgram(i),e.getProgramParameter(i,e.LINK_STATUS)||Eg(e,i,n,r),t._attributeData=yg(i,e,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Cg(i,e),t._uniformBlockData=xg(i,e),e.deleteShader(n),e.deleteShader(r);let o={};for(let n in t._uniformData){let r=t._uniformData[n];o[n]={location:e.getUniformLocation(i,n),value:dg(r.type,r.size)}}return new og(i,o)}var kg=s((()=>{I(),sg(),lg(),fg(),bg(),Sg(),wg(),Dg()})),Ag,jg,Mg=s((()=>{g(),ag(),kg(),Ag={textureCount:0,blockIndex:0},jg=class{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;Ag.textureCount=0,Ag.blockIndex=0;let n=this._shaderSyncFunctions[e.glProgram._key];n||=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this),this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),n(this._renderer,e,Ag)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,Ag)}bindUniformBlock(e,t,n=0){let r=this._renderer.buffer,i=this._getProgramData(this._activeProgram),a=e._bufferResource;a||this._renderer.ubo.updateUniformGroup(e);let o=e.buffer,s=r.updateBuffer(o),c=r.freeLocationForBufferBase(s);if(a){let{offset:t,size:n}=e;t===0&&n===o.data.byteLength?r.bindBufferBase(s,c):r.bindBufferRange(s,c,t)}else r.getLastBindBaseLocation(s)!==c&&r.bindBufferBase(s,c);let l=this._activeProgram._uniformBlockData[t].index;i.uniformBlockBindings[n]!==c&&(i.uniformBlockBindings[n]=c,this._renderer.gl.uniformBlockBinding(i.program,l,c))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;let t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){let t=e._key;return this._programDataHash[t]=Og(this._gl,e),this._programDataHash[t]}destroy(){for(let 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 ig(e,t)}resetState(){this._activeProgram=null}},jg.extension={type:[f.WebGLSystem],name:`shader`}})),Ng,Pg,Fg=s((()=>{Ng={f32:`if (cv !== v) {
|
|
806
|
+
cu.value = v;
|
|
807
|
+
gl.uniform1f(location, v);
|
|
808
|
+
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
809
|
+
cv[0] = v[0];
|
|
810
|
+
cv[1] = v[1];
|
|
811
|
+
gl.uniform2f(location, v[0], v[1]);
|
|
812
|
+
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
813
|
+
cv[0] = v[0];
|
|
814
|
+
cv[1] = v[1];
|
|
815
|
+
cv[2] = v[2];
|
|
816
|
+
gl.uniform3f(location, v[0], v[1], v[2]);
|
|
817
|
+
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
818
|
+
cv[0] = v[0];
|
|
819
|
+
cv[1] = v[1];
|
|
820
|
+
cv[2] = v[2];
|
|
821
|
+
cv[3] = v[3];
|
|
822
|
+
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
823
|
+
}`,i32:`if (cv !== v) {
|
|
824
|
+
cu.value = v;
|
|
825
|
+
gl.uniform1i(location, v);
|
|
826
|
+
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
827
|
+
cv[0] = v[0];
|
|
828
|
+
cv[1] = v[1];
|
|
829
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
830
|
+
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
831
|
+
cv[0] = v[0];
|
|
832
|
+
cv[1] = v[1];
|
|
833
|
+
cv[2] = v[2];
|
|
834
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
835
|
+
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
836
|
+
cv[0] = v[0];
|
|
837
|
+
cv[1] = v[1];
|
|
838
|
+
cv[2] = v[2];
|
|
839
|
+
cv[3] = v[3];
|
|
840
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
841
|
+
}`,u32:`if (cv !== v) {
|
|
842
|
+
cu.value = v;
|
|
843
|
+
gl.uniform1ui(location, v);
|
|
844
|
+
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
845
|
+
cv[0] = v[0];
|
|
846
|
+
cv[1] = v[1];
|
|
847
|
+
gl.uniform2ui(location, v[0], v[1]);
|
|
848
|
+
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
849
|
+
cv[0] = v[0];
|
|
850
|
+
cv[1] = v[1];
|
|
851
|
+
cv[2] = v[2];
|
|
852
|
+
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
853
|
+
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
854
|
+
cv[0] = v[0];
|
|
855
|
+
cv[1] = v[1];
|
|
856
|
+
cv[2] = v[2];
|
|
857
|
+
cv[3] = v[3];
|
|
858
|
+
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
859
|
+
}`,bool:`if (cv !== v) {
|
|
860
|
+
cu.value = v;
|
|
861
|
+
gl.uniform1i(location, v);
|
|
862
|
+
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
863
|
+
cv[0] = v[0];
|
|
864
|
+
cv[1] = v[1];
|
|
865
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
866
|
+
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
867
|
+
cv[0] = v[0];
|
|
868
|
+
cv[1] = v[1];
|
|
869
|
+
cv[2] = v[2];
|
|
870
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
871
|
+
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
872
|
+
cv[0] = v[0];
|
|
873
|
+
cv[1] = v[1];
|
|
874
|
+
cv[2] = v[2];
|
|
875
|
+
cv[3] = v[3];
|
|
876
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
877
|
+
}`,"mat2x2<f32>":`gl.uniformMatrix2fv(location, false, v);`,"mat3x3<f32>":`gl.uniformMatrix3fv(location, false, v);`,"mat4x4<f32>":`gl.uniformMatrix4fv(location, false, v);`},Pg={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 Ig(e,t){let n=[`
|
|
878
|
+
var v = null;
|
|
879
|
+
var cv = null;
|
|
880
|
+
var cu = null;
|
|
881
|
+
var t = 0;
|
|
882
|
+
var gl = renderer.gl;
|
|
883
|
+
var name = null;
|
|
884
|
+
`];for(let r in e.uniforms){if(!t[r]){e.uniforms[r]instanceof fs?e.uniforms[r].ubo?n.push(`
|
|
885
|
+
renderer.shader.bindUniformBlock(uv.${r}, "${r}");
|
|
886
|
+
`):n.push(`
|
|
887
|
+
renderer.shader.updateUniformGroup(uv.${r});
|
|
888
|
+
`):e.uniforms[r]instanceof Zp&&n.push(`
|
|
889
|
+
renderer.shader.bindBufferResource(uv.${r}, "${r}");
|
|
890
|
+
`);continue}let i=e.uniformStructures[r],a=!1;for(let e=0;e<Lp.length;e++){let t=Lp[e];if(i.type===t.type&&t.test(i)){n.push(`name = "${r}";`,Lp[e].uniform),a=!0;break}}if(!a){let e=(i.size===1?Ng:Pg)[i.type].replace(`location`,`ud["${r}"].location`);n.push(`
|
|
891
|
+
cu = ud["${r}"];
|
|
892
|
+
cv = cu.value;
|
|
893
|
+
v = uv["${r}"];
|
|
894
|
+
${e};`)}}return Function(`ud`,`uv`,`renderer`,`syncData`,n.join(`
|
|
895
|
+
`))}var Lg=s((()=>{Qp(),ps(),Rp(),Fg()})),Rg,zg=s((()=>{g(),Lg(),Rg=class{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,n){let r=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==r.uniformDirtyGroups[e.uid])&&(r.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(r.uniformData,e.uniforms,this._renderer,n))}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){let n=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),r=this._getSignature(e,t._uniformData,`u`);return this._cache[r]||(this._cache[r]=this._generateUniformsSync(e,t._uniformData)),n[t._key]=this._cache[r],n[t._key]}_generateUniformsSync(e,t){return Ig(e,t)}_getSignature(e,t,n){let r=e.uniforms,i=[`${n}-`];for(let e in r)i.push(e),t[e]&&i.push(t[e].type);return i.join(`-`)}destroy(){this._renderer=null,this._cache=null}},Rg.extension={type:[f.WebGLSystem],name:`uniformGroup`}}));function Bg(e){let t={};if(t.normal=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t.add=[e.ONE,e.ONE],t.multiply=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.screen=[e.ONE,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t[`normal-npm`]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t[`add-npm`]=[e.SRC_ALPHA,e.ONE,e.ONE,e.ONE],t[`screen-npm`]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.erase=[e.ZERO,e.ONE_MINUS_SRC_ALPHA],!(e instanceof B.get().getWebGLRenderingContext()))t.min=[e.ONE,e.ONE,e.ONE,e.ONE,e.MIN,e.MIN],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,e.MAX,e.MAX];else{let n=e.getExtension(`EXT_blend_minmax`);n&&(t.min=[e.ONE,e.ONE,e.ONE,e.ONE,n.MIN_EXT,n.MIN_EXT],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,n.MAX_EXT,n.MAX_EXT])}return t}var Vg=s((()=>{V()})),Hg,Ug,Wg,Gg,Kg,qg,Jg,Yg,Xg=s((()=>{g(),Ts(),Vg(),Hg=0,Ug=1,Wg=2,Gg=3,Kg=4,qg=5,Jg=class e{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=`none`,this._blendEq=!1,this.map=[],this.map[Hg]=this.setBlend,this.map[Ug]=this.setOffset,this.map[Wg]=this.setCullFace,this.map[Gg]=this.setDepthTest,this.map[Kg]=this.setFrontFace,this.map[qg]=this.setDepthMask,this.checks=[],this.defaultState=ws.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=Bg(e),this.resetState()}set(e){if(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||=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(t){this._updateCheck(e._checkBlendMode,t),this.gl[t?`enable`:`disable`](this.gl.BLEND)}setOffset(t){this._updateCheck(e._checkPolygonOffset,t),this.gl[t?`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;let 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;let 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){let 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}},Jg.extension={type:[f.WebGLSystem],name:`state`},Yg=Jg})),Zg,Qg=s((()=>{Ch(),Zg=class{constructor(e){this.target=Sh.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=W.UNSIGNED_BYTE,this.internalFormat=xh.RGBA,this.format=xh.RGBA,this.samplerType=0}destroy(){}}})),$g,e_=s((()=>{$g={id:`buffer`,upload(e,t,n,r,i,a=!1){let o=i||t.target;!a&&t.width===e.width&&t.height===e.height?n.texSubImage2D(o,0,0,0,e.width,e.height,t.format,t.type,e.resource):n.texImage2D(o,0,t.internalFormat,e.width,e.height,0,t.format,t.type,e.resource),t.width=e.width,t.height=e.height}}})),t_,n_,r_=s((()=>{t_={"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},n_={id:`compressed`,upload(e,t,n,r,i,a){let o=i??t.target;n.pixelStorei(n.UNPACK_ALIGNMENT,4);let s=e.pixelWidth,c=e.pixelHeight,l=!!t_[e.format];for(let r=0;r<e.resource.length;r++){let i=e.resource[r];l?n.compressedTexImage2D(o,r,t.internalFormat,s,c,0,i):n.texImage2D(o,r,t.internalFormat,s,c,0,t.format,t.type,i),s=Math.max(s>>1,1),c=Math.max(c>>1,1)}}}}));function i_(e){return{id:`cube`,upload(t,n,r,i){let a=t.faces;for(let t=0;t<a_.length;t++){let o=a[a_[t]];(e[o.uploadMethodId]||e.image).upload(o,n,r,i,Sh.TEXTURE_CUBE_MAP_POSITIVE_X+t,(n._layerInitMask&1<<t)==0),n._layerInitMask|=1<<t}n.width=t.pixelWidth,n.height=t.pixelHeight}}}var a_,o_=s((()=>{Ch(),a_=[`right`,`left`,`top`,`bottom`,`front`,`back`]}));function s_(e,t,n,r,i,a,o,s,c,l){if(!l){c&&e.texImage2D(t,0,n.internalFormat,r,i,0,n.format,n.type,null),e.texSubImage2D(t,0,0,0,a,o,n.format,n.type,s);return}if(!c){e.texSubImage2D(t,0,0,0,n.format,n.type,s);return}e.texImage2D(t,0,n.internalFormat,r,i,0,n.format,n.type,s)}function c_(e,t,n,r,i,a,o,s,c,l){if(!l){c&&e.texImage2D(t,0,n.internalFormat,r,i,0,n.format,n.type,null),e.texSubImage2D(t,0,0,0,n.format,n.type,s);return}if(!c){e.texSubImage2D(t,0,0,0,n.format,n.type,s);return}e.texImage2D(t,0,n.internalFormat,n.format,n.type,s)}var l_,u_=s((()=>{l_={id:`image`,upload(e,t,n,r,i,a=!1){let o=i||t.target,s=e.pixelWidth,c=e.pixelHeight,l=e.resourceWidth,u=e.resourceHeight,d=r===2,f=a||t.width!==s||t.height!==c,p=l>=s&&u>=c,m=e.resource;(d?s_:c_)(n,o,t,s,c,l,u,m,f,p),t.width=s,t.height=c}}}));function d_(){let{userAgent:e}=B.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}var f_=s((()=>{V()})),p_,m_,h_=s((()=>{f_(),u_(),p_=d_(),m_={id:`video`,upload(e,t,n,r,i,a=p_){if(!e.isValid){let e=i??t.target;n.texImage2D(e,0,t.internalFormat,1,1,0,t.format,t.type,null);return}l_.upload(e,t,n,r,i,a)}}})),g_,__,v_,y_,b_=s((()=>{g_={linear:9729,nearest:9728},__={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},v_={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},y_={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519}}));function x_(e,t,n,r,i,a,o,s){let c=a;if(!s||e.addressModeU!==`repeat`||e.addressModeV!==`repeat`||e.addressModeW!==`repeat`){let n=v_[o?`clamp-to-edge`:e.addressModeU],r=v_[o?`clamp-to-edge`:e.addressModeV],a=v_[o?`clamp-to-edge`:e.addressModeW];t[i](c,t.TEXTURE_WRAP_S,n),t[i](c,t.TEXTURE_WRAP_T,r),t.TEXTURE_WRAP_R&&t[i](c,t.TEXTURE_WRAP_R,a)}if((!s||e.magFilter!==`linear`)&&t[i](c,t.TEXTURE_MAG_FILTER,g_[e.magFilter]),n){if(!s||e.mipmapFilter!==`linear`){let n=__[e.minFilter][e.mipmapFilter];t[i](c,t.TEXTURE_MIN_FILTER,n)}}else t[i](c,t.TEXTURE_MIN_FILTER,g_[e.minFilter]);if(r&&e.maxAnisotropy>1){let n=Math.min(e.maxAnisotropy,t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](c,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}e.compare&&t[i](c,t.TEXTURE_COMPARE_FUNC,y_[e.compare])}var S_=s((()=>{b_()}));function C_(e){return{r8unorm:e.RED,r8snorm:e.RED,r8uint:e.RED,r8sint:e.RED,r16uint:e.RED,r16sint:e.RED,r16float:e.RED,rg8unorm:e.RG,rg8snorm:e.RG,rg8uint:e.RG,rg8sint:e.RG,r32uint:e.RED,r32sint:e.RED,r32float:e.RED,rg16uint:e.RG,rg16sint:e.RG,rg16float:e.RG,rgba8unorm:e.RGBA,"rgba8unorm-srgb":e.RGBA,rgba8snorm:e.RGBA,rgba8uint:e.RGBA,rgba8sint:e.RGBA,bgra8unorm:e.RGBA,"bgra8unorm-srgb":e.RGBA,rgb9e5ufloat:e.RGB,rgb10a2unorm:e.RGBA,rg11b10ufloat:e.RGB,rg32uint:e.RG,rg32sint:e.RG,rg32float:e.RG,rgba16uint:e.RGBA,rgba16sint:e.RGBA,rgba16float:e.RGBA,rgba32uint:e.RGBA,rgba32sint:e.RGBA,rgba32float:e.RGBA,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT,depth24plus:e.DEPTH_COMPONENT,"depth24plus-stencil8":e.DEPTH_STENCIL,depth32float:e.DEPTH_COMPONENT,"depth32float-stencil8":e.DEPTH_STENCIL}}var w_=s((()=>{}));function T_(e,t){let n={},r=e.RGBA;return e instanceof B.get().getWebGLRenderingContext()?t.srgb&&(n={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(n={"rgba8unorm-srgb":e.SRGB8_ALPHA8,"bgra8unorm-srgb":e.SRGB8_ALPHA8},r=e.RGBA8),{r8unorm:e.R8,r8snorm:e.R8_SNORM,r8uint:e.R8UI,r8sint:e.R8I,r16uint:e.R16UI,r16sint:e.R16I,r16float:e.R16F,rg8unorm:e.RG8,rg8snorm:e.RG8_SNORM,rg8uint:e.RG8UI,rg8sint:e.RG8I,r32uint:e.R32UI,r32sint:e.R32I,r32float:e.R32F,rg16uint:e.RG16UI,rg16sint:e.RG16I,rg16float:e.RG16F,rgba8unorm:e.RGBA,...n,rgba8snorm:e.RGBA8_SNORM,rgba8uint:e.RGBA8UI,rgba8sint:e.RGBA8I,bgra8unorm:r,rgb9e5ufloat:e.RGB9_E5,rgb10a2unorm:e.RGB10_A2,rg11b10ufloat:e.R11F_G11F_B10F,rg32uint:e.RG32UI,rg32sint:e.RG32I,rg32float:e.RG32F,rgba16uint:e.RGBA16UI,rgba16sint:e.RGBA16I,rgba16float:e.RGBA16F,rgba32uint:e.RGBA32UI,rgba32sint:e.RGBA32I,rgba32float:e.RGBA32F,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT16,depth24plus:e.DEPTH_COMPONENT24,"depth24plus-stencil8":e.DEPTH24_STENCIL8,depth32float:e.DEPTH_COMPONENT32F,"depth32float-stencil8":e.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}var E_=s((()=>{V()}));function D_(e){return{r8unorm:e.UNSIGNED_BYTE,r8snorm:e.BYTE,r8uint:e.UNSIGNED_BYTE,r8sint:e.BYTE,r16uint:e.UNSIGNED_SHORT,r16sint:e.SHORT,r16float:e.HALF_FLOAT,rg8unorm:e.UNSIGNED_BYTE,rg8snorm:e.BYTE,rg8uint:e.UNSIGNED_BYTE,rg8sint:e.BYTE,r32uint:e.UNSIGNED_INT,r32sint:e.INT,r32float:e.FLOAT,rg16uint:e.UNSIGNED_SHORT,rg16sint:e.SHORT,rg16float:e.HALF_FLOAT,rgba8unorm:e.UNSIGNED_BYTE,"rgba8unorm-srgb":e.UNSIGNED_BYTE,rgba8snorm:e.BYTE,rgba8uint:e.UNSIGNED_BYTE,rgba8sint:e.BYTE,bgra8unorm:e.UNSIGNED_BYTE,"bgra8unorm-srgb":e.UNSIGNED_BYTE,rgb9e5ufloat:e.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:e.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:e.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:e.UNSIGNED_INT,rg32sint:e.INT,rg32float:e.FLOAT,rgba16uint:e.UNSIGNED_SHORT,rgba16sint:e.SHORT,rgba16float:e.HALF_FLOAT,rgba32uint:e.UNSIGNED_INT,rgba32sint:e.INT,rgba32float:e.FLOAT,stencil8:e.UNSIGNED_BYTE,depth16unorm:e.UNSIGNED_SHORT,depth24plus:e.UNSIGNED_INT,"depth24plus-stencil8":e.UNSIGNED_INT_24_8,depth32float:e.FLOAT,"depth32float-stencil8":e.FLOAT_32_UNSIGNED_INT_24_8_REV}}var O_=s((()=>{}));function k_(e){return{"2d":e.TEXTURE_2D,cube:e.TEXTURE_CUBE_MAP,"1d":null,"3d":e?.TEXTURE_3D||null,"2d-array":e?.TEXTURE_2D_ARRAY||null,"cube-array":e?.TEXTURE_CUBE_MAP_ARRAY||null}}var A_=s((()=>{})),j_,M_,N_,P_=s((()=>{V(),g(),vp(),z(),Qg(),e_(),r_(),o_(),u_(),h_(),S_(),w_(),E_(),O_(),A_(),j_=4,M_=class e{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new _p({renderer:t,type:`resource`,onUnload:this.onSourceUnload.bind(this),name:`glTexture`});let n={image:l_,buffer:$g,video:m_,compressed:n_,...e.uploadExtensions};this._uploads={...n,cube:i_(n)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=T_(e,this._renderer.context.extensions),this._mapFormatToType=D_(e),this._mapFormatToFormat=C_(e),this._mapViewDimensionToGlTarget=k_(e)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(R.EMPTY,e)}initSource(e){this.bind(e)}bind(e,t=0){let 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){let n=this._gl;if(e._gcLastUsed=this._renderer.gc.now,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||=R.EMPTY.source;let r=this.getGlSource(e);n.bindTexture(r.target,r.texture)}}_bindSampler(e,t=0){let n=this._gl;if(!e){this._boundSamplers[t]=null,n.bindSampler(t,null);return}let r=this._getGlSampler(e);this._boundSamplers[t]!==r&&(this._boundSamplers[t]=r,n.bindSampler(t,r))}unbind(e){let t=e.source,n=this._boundTextures,r=this._gl;for(let e=0;e<n.length;e++)if(n[e]===t){this._activateLocation(e);let i=this.getGlSource(t);r.bindTexture(i.target,null),n[e]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){let t=this._gl,n=new Zg(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 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)){let t=Math.max(e.width,e.height);e.mipLevelCount=Math.floor(Math.log2(t))+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){let n=this._gl,r=this.getGlSource(e);n.bindTexture(r.target,r.texture),this._boundTextures[this._activeTextureLocation]=e,x_(e.style,n,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,`texParameteri`,r.target,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e,t=!1){let 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){let t=this._gl,n=this.getGlSource(e);t.bindTexture(n.target,n.texture),this._boundTextures[this._activeTextureLocation]=e;let r=e.alphaMode===`premultiply-alpha-on-upload`;if(this._premultiplyAlpha!==r&&(this._premultiplyAlpha=r,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r)),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 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);let n=this.getGlSource(e);this._gl.generateMipmap(n.target)}_initEmptyTexture2D(e,t){let n=this._gl;n.texImage2D(n.TEXTURE_2D,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let r=Math.max(t.pixelWidth>>1,1),i=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++)n.texImage2D(n.TEXTURE_2D,a,e.internalFormat,r,i,0,e.format,e.type,null),r=Math.max(r>>1,1),i=Math.max(i>>1,1)}_initEmptyTexture2DArray(e,t){if(this._renderer.context.webGLVersion!==2)throw Error(`[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.`);let n=this._gl,r=Math.max(t.arrayLayerCount|0,1);n.texImage3D(n.TEXTURE_2D_ARRAY,0,e.internalFormat,t.pixelWidth,t.pixelHeight,r,0,e.format,e.type,null);let i=Math.max(t.pixelWidth>>1,1),a=Math.max(t.pixelHeight>>1,1);for(let o=1;o<t.mipLevelCount;o++)n.texImage3D(n.TEXTURE_2D_ARRAY,o,e.internalFormat,i,a,r,0,e.format,e.type,null),i=Math.max(i>>1,1),a=Math.max(a>>1,1)}_initEmptyTextureCube(e,t){let n=this._gl;for(let r=0;r<6;r++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let r=Math.max(t.pixelWidth>>1,1),i=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++){for(let t=0;t<6;t++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,a,e.internalFormat,r,i,0,e.format,e.type,null);r=Math.max(r>>1,1),i=Math.max(i>>1,1)}}_applyMipRange(e,t){if(this._renderer.context.webGLVersion!==2||t.mipLevelCount<=1)return;let n=this._gl,r=Math.max((t.mipLevelCount|0)-1,0);n.texParameteri(e.target,n.TEXTURE_BASE_LEVEL,0),n.texParameteri(e.target,n.TEXTURE_MAX_LEVEL,r)}_initSampler(e){let t=this._gl,n=this._gl.createSampler();return this._glSamplers[e._resourceId]=n,x_(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){let{pixels:t,width:n,height:r}=this.getPixels(e),i=B.get().createCanvas();i.width=n,i.height=r;let a=i.getContext(`2d`);if(a){let e=a.createImageData(n,r);e.data.set(t),a.putImageData(e,0,0)}return i}getPixels(e){let t=e.source.resolution,n=e.frame,r=Math.max(Math.round(n.width*t),1),i=Math.max(Math.round(n.height*t),1),a=new Uint8Array(j_*r*i),o=this._renderer,s=o.renderTarget.getRenderTarget(e),c=o.renderTarget.getGpuRenderTarget(s),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,c.resolveTargetFramebuffer),l.readPixels(Math.round(n.x*t),Math.round(n.y*t),r,i,l.RGBA,l.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:r,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(R.EMPTY.source),this._boundSamplers=Object.create(null);let e=this._gl;this._premultiplyAlpha=!1,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}},M_.extension={type:[f.WebGLSystem],name:`texture`},M_.uploadExtensions=Object.create(null),N_=M_,h.handleByMap(f.TextureUploaderWebGL,N_.uploadExtensions)})),F_=l({WebGLRenderer:()=>H_}),I_,L_,R_,z_,B_,V_,H_,U_=s((()=>{g(),sh(),lh(),dh(),_l(),mp(),as(),_h(),bh(),Ah(),Ph(),Ih(),Rh(),Bh(),Hh(),Zh(),rg(),Mg(),zg(),Xg(),P_(),I_=[...fp,Xh,Nh,yh,zh,gh,N_,ng,kh,Rg,jg,Lh,Yg,Vh,Fh],L_=[...pp],R_=[uh,ch,oh],z_=[],B_=[],V_=[],h.handleByNamedList(f.WebGLSystem,z_),h.handleByNamedList(f.WebGLPipes,B_),h.handleByNamedList(f.WebGLPipesAdaptor,V_),h.add(...I_,...L_,...R_),H_=class extends gl{constructor(){let e={name:`webgl`,type:is.WEBGL,systems:z_,renderPipes:B_,renderPipeAdaptors:V_};super(e)}}})),W_,G_,K_=s((()=>{W_=1e-4,G_=1e-4}));function q_(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}var J_=s((()=>{}));function Y_(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function X_(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}function Z_(e,t,n,r,i,a){let o=W_;if(e.length===0)return;let s=t,c=s.alignment;if(t.alignment!==.5){let t=q_(e);n&&(t*=-1),c=(c-.5)*t+.5}let l=new je(e[0],e[1]),u=new je(e[e.length-2],e[e.length-1]),d=r,f=Math.abs(l.x-u.x)<o&&Math.abs(l.y-u.y)<o;if(d){e=e.slice(),f&&(e.pop(),e.pop(),u.set(e[e.length-2],e[e.length-1]));let t=(l.x+u.x)*.5,n=(u.y+l.y)*.5;e.unshift(t,n),e.push(t,n)}let p=i,m=e.length/2,h=e.length,g=p.length/2,_=s.width/2,v=_*_,y=s.miterLimit*s.miterLimit,b=e[0],x=e[1],S=e[2],C=e[3],w=0,ee=0,T=-(x-C),E=b-S,te=0,ne=0,re=Math.sqrt(T*T+E*E);T/=re,E/=re,T*=_,E*=_;let ie=c,D=(1-ie)*2,O=ie*2;d||(s.cap===`round`?h+=X_(b-T*(D-O)*.5,x-E*(D-O)*.5,b-T*D,x-E*D,b+T*O,x+E*O,p,!0)+2:s.cap===`square`&&(h+=Y_(b,x,T,E,D,O,!0,p))),p.push(b-T*D,x-E*D),p.push(b+T*O,x+E*O);for(let t=1;t<m-1;++t){b=e[(t-1)*2],x=e[(t-1)*2+1],S=e[t*2],C=e[t*2+1],w=e[(t+1)*2],ee=e[(t+1)*2+1],T=-(x-C),E=b-S,re=Math.sqrt(T*T+E*E),T/=re,E/=re,T*=_,E*=_,te=-(C-ee),ne=S-w,re=Math.sqrt(te*te+ne*ne),te/=re,ne/=re,te*=_,ne*=_;let n=S-b,r=x-C,i=S-w,a=ee-C,o=n*i+r*a,c=r*i-a*n,l=c<0;if(Math.abs(c)<.001*Math.abs(o)){p.push(S-T*D,C-E*D),p.push(S+T*O,C+E*O),o>=0&&(s.join===`round`?h+=X_(S,C,S-T*D,C-E*D,S-te*D,C-ne*D,p,!1)+4:h+=2,p.push(S-te*O,C-ne*O),p.push(S+te*D,C+ne*D));continue}let u=(-T+b)*(-E+C)-(-T+S)*(-E+x),d=(-te+w)*(-ne+C)-(-te+S)*(-ne+ee),f=(n*d-i*u)/c,m=(a*u-r*d)/c,g=(f-S)*(f-S)+(m-C)*(m-C),ie=S+(f-S)*D,ae=C+(m-C)*D,oe=S-(f-S)*O,se=C-(m-C)*O,ce=Math.min(n*n+r*r,i*i+a*a),le=l?D:O;g<=ce+le*le*v?s.join===`bevel`||g/v>y?(l?(p.push(ie,ae),p.push(S+T*O,C+E*O),p.push(ie,ae),p.push(S+te*O,C+ne*O)):(p.push(S-T*D,C-E*D),p.push(oe,se),p.push(S-te*D,C-ne*D),p.push(oe,se)),h+=2):s.join===`round`?l?(p.push(ie,ae),p.push(S+T*O,C+E*O),h+=X_(S,C,S+T*O,C+E*O,S+te*O,C+ne*O,p,!0)+4,p.push(ie,ae),p.push(S+te*O,C+ne*O)):(p.push(S-T*D,C-E*D),p.push(oe,se),h+=X_(S,C,S-T*D,C-E*D,S-te*D,C-ne*D,p,!1)+4,p.push(S-te*D,C-ne*D),p.push(oe,se)):(p.push(ie,ae),p.push(oe,se)):(p.push(S-T*D,C-E*D),p.push(S+T*O,C+E*O),s.join===`round`?l?h+=X_(S,C,S+T*O,C+E*O,S+te*O,C+ne*O,p,!0)+2:h+=X_(S,C,S-T*D,C-E*D,S-te*D,C-ne*D,p,!1)+2:s.join===`miter`&&g/v<=y&&(l?(p.push(oe,se),p.push(oe,se)):(p.push(ie,ae),p.push(ie,ae)),h+=2),p.push(S-te*D,C-ne*D),p.push(S+te*O,C+ne*O),h+=2)}b=e[(m-2)*2],x=e[(m-2)*2+1],S=e[(m-1)*2],C=e[(m-1)*2+1],T=-(x-C),E=b-S,re=Math.sqrt(T*T+E*E),T/=re,E/=re,T*=_,E*=_,p.push(S-T*D,C-E*D),p.push(S+T*O,C+E*O),d||(s.cap===`round`?h+=X_(S-T*(D-O)*.5,C-E*(D-O)*.5,S-T*D,C-E*D,S+T*O,C+E*O,p,!1)+2:s.cap===`square`&&(h+=Y_(S,C,T,E,D,O,!1,p)));let ae=G_*G_;for(let e=g;e<h+g-2;++e)b=p[e*2],x=p[e*2+1],S=p[(e+1)*2],C=p[(e+1)*2+1],w=p[(e+2)*2],ee=p[(e+2)*2+1],!(Math.abs(b*(C-ee)+S*(ee-x)+w*(x-C))<ae)&&a.push(e,e+1,e+2)}var Q_=s((()=>{Ne(),K_(),J_()}));function $_(e,t){for(let n=0;n<t.length;n++){let r=t[n];e.addColorStop(r.offset,r.color)}}function ev(e,t){let n=B.get().createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`)}}function tv(e){let t=e[0]??{};return(typeof t==`number`||e[1])&&(P(`8.5.2`,`use options object instead`),t={type:`linear`,start:{x:e[0],y:e[1]},end:{x:e[2],y:e[3]},textureSpace:e[4],textureSize:e[5]??iv.defaultLinearOptions.textureSize}),t}var nv,rv,iv,av=s((()=>{we(),V(),M(),fa(),z(),Be(),We(),ln(),nv=[{offset:0,color:`white`},{offset:1,color:`black`}],rv=class e{constructor(...t){this.uid=Re(`fillGradient`),this._tick=0,this.type=`linear`,this.colorStops=[];let n=tv(t);n={...n.type===`radial`?e.defaultRadialOptions:e.defaultLinearOptions,...cn(n)},this._textureSize=n.textureSize,this._wrapMode=n.wrapMode,n.type===`radial`?(this.center=n.center,this.outerCenter=n.outerCenter??this.center,this.innerRadius=n.innerRadius,this.outerRadius=n.outerRadius,this.scale=n.scale,this.rotation=n.rotation):(this.start=n.start,this.end=n.end),this.textureSpace=n.textureSpace,this.type=n.type,n.colorStops.forEach(e=>{this.addColorStop(e.offset,e.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:A.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:n,y:r}=this.end,i=n-e,a=r-t,o=i<0||a<0;if(this._wrapMode===`clamp-to-edge`){if(i<0){let t=e;e=n,n=t,i*=-1}if(a<0){let e=t;t=r,r=e,a*=-1}}let s=this.colorStops.length?this.colorStops:nv,c=this._textureSize,{canvas:l,context:u}=ev(c,1),d=o?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);$_(d,s),u.fillStyle=d,u.fillRect(0,0,c,1),this.texture=new R({source:new da({resource:l,addressMode:this._wrapMode})});let f=Math.sqrt(i*i+a*a),p=Math.atan2(a,i),m=new j;m.scale(f/c,1),m.rotate(p),m.translate(e,t),this.textureSpace===`local`&&m.scale(c,c),this.transform=m}buildGradient(){this.texture||this._tick++,this.type===`linear`?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;let e=this.colorStops.length?this.colorStops:nv,t=this._textureSize,{canvas:n,context:r}=ev(t,t),{x:i,y:a}=this.center,{x:o,y:s}=this.outerCenter,c=this.innerRadius,l=this.outerRadius,u=o-l,d=s-l,f=t/(l*2),p=(i-u)*f,m=(a-d)*f,h=r.createRadialGradient(p,m,c*f,(o-u)*f,(s-d)*f,l*f);$_(h,e),r.fillStyle=e[e.length-1].color,r.fillRect(0,0,t,t),r.fillStyle=h,r.translate(p,m),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-p,-m),r.fillRect(0,0,t,t),this.texture=new R({source:new da({resource:n,addressMode:this._wrapMode})});let g=new j;this.textureSpace===`local`?g.scale(2*l,2*l):g.scale(1/f,1/f),g.translate(u,d),this.transform=g}destroy(){this.texture?.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}`}},rv.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:`local`,type:`linear`,textureSize:256,wrapMode:`clamp-to-edge`},rv.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:`local`,type:`radial`,textureSize:256,wrapMode:`clamp-to-edge`},iv=rv}));function ov(e){return e.texture!==void 0}var sv,cv,lv=s((()=>{M(),Be(),sv={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`}},cv=class{constructor(e,t){this.uid=Re(`fillPattern`),this._tick=0,this.transform=new j;let n=ov(e)?e:{texture:e,repetition:t};this.texture=n.texture,this.textureSpace=n.textureSpace??`global`;let r=n.repetition;r&&(this.texture.source.style.addressModeU=sv[r].addressModeU,this.texture.source.style.addressModeV=sv[r].addressModeV)}setTransform(e){if(e){if(this.transform.equals(e))return;this.transform.copyFrom(e)}else{if(this.transform.isIdentity())return;this.transform.identity()}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 uv(e,t,n,r,i,a,o,s=null){let c=0;n*=t,i*=a;let l=s.a,u=s.b,d=s.c,f=s.d,p=s.tx,m=s.ty;for(;c<o;){let o=e[n],s=e[n+1];r[i]=l*o+d*s+p,r[i+1]=u*o+f*s+m,i+=a,n+=t,c++}}function dv(e,t,n,r){let i=0;for(t*=n;i<r;)e[t]=0,e[t+1]=0,t+=n,i++}var fv=s((()=>{}));function pv(e,t,n,r,i){let a=t.a,o=t.b,s=t.c,c=t.d,l=t.tx,u=t.ty;n||=0,r||=2,i||=e.length/r-n;let d=n*r;for(let t=0;t<i;t++){let t=e[d],n=e[d+1];e[d]=a*t+s*n+l,e[d+1]=o*t+c*n+u,d+=r}}var mv=s((()=>{})),hv,gv,_v=s((()=>{M(),Pt(),hv=new j,gv=class{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(){let e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,n=this.renderable;return n?Nt(t,n.groupColor)+(this.alpha*n.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||hv}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}}})),vv,yv,bv,xv=s((()=>{g(),vv={extension:{type:f.ShapeBuilder,name:`circle`},build(e,t){let n,r,i,a,o,s;if(e.type===`circle`){let t=e;if(o=s=t.radius,o<=0)return!1;n=t.x,r=t.y,i=a=0}else if(e.type===`ellipse`){let t=e;if(o=t.halfWidth,s=t.halfHeight,o<=0||s<=0)return!1;n=t.x,r=t.y,i=a=0}else{let t=e,c=t.width/2,l=t.height/2;n=t.x+c,r=t.y+l,o=s=Math.max(0,Math.min(t.radius,Math.min(c,l))),i=c-o,a=l-s}if(i<0||a<0)return!1;let c=Math.ceil(2.3*Math.sqrt(o+s)),l=c*8+(i?4:0)+(a?4:0);if(l===0)return!1;if(c===0)return t[0]=t[6]=n+i,t[1]=t[3]=r+a,t[2]=t[4]=n-i,t[5]=t[7]=r-a,!0;let u=0,d=c*4+(i?2:0)+2,f=d,p=l,m=i+o,h=a,g=n+m,_=n-m,v=r+h;if(t[u++]=g,t[u++]=v,t[--d]=v,t[--d]=_,a){let e=r-h;t[f++]=_,t[f++]=e,t[--p]=e,t[--p]=g}for(let e=1;e<c;e++){let l=Math.PI/2*(e/c),m=i+Math.cos(l)*o,h=a+Math.sin(l)*s,g=n+m,_=n-m,v=r+h,y=r-h;t[u++]=g,t[u++]=v,t[--d]=v,t[--d]=_,t[f++]=_,t[f++]=y,t[--p]=y,t[--p]=g}m=i,h=a+s,g=n+m,_=n-m,v=r+h;let y=r-h;return t[u++]=g,t[u++]=v,t[--p]=y,t[--p]=g,i&&(t[u++]=_,t[u++]=v,t[--p]=y,t[--p]=_),!0},triangulate(e,t,n,r,i,a){if(e.length===0)return;let o=0,s=0;for(let t=0;t<e.length;t+=2)o+=e[t],s+=e[t+1];o/=e.length/2,s/=e.length/2;let c=r;t[c*n]=o,t[c*n+1]=s;let l=c++;for(let r=0;r<e.length;r+=2)t[c*n]=e[r],t[c*n+1]=e[r+1],r>0&&(i[a++]=c,i[a++]=l,i[a++]=c-1),c++;i[a++]=l+1,i[a++]=l,i[a++]=c-1}},yv={...vv,extension:{...vv.extension,name:`ellipse`}},bv={...vv,extension:{...vv.extension,name:`roundedRectangle`}}}));function Sv(e,t,n,r){let i=W_;if(e.length===0)return;let a=e[0],o=e[1],s=e[e.length-2],c=e[e.length-1],l=t||Math.abs(a-s)<i&&Math.abs(o-c)<i,u=n,d=e.length/2,f=u.length/2;for(let t=0;t<d;t++)u.push(e[t*2]),u.push(e[t*2+1]);for(let e=0;e<d-1;e++)r.push(f+e,f+e+1);l&&r.push(f+d-1,f)}var Cv=s((()=>{K_()}));function wv(e,t,n,r,i,a,o){let s=cl(e,t,2);if(!s)return;for(let e=0;e<s.length;e+=3)a[o++]=s[e]+i,a[o++]=s[e+1]+i,a[o++]=s[e+2]+i;let c=i*r;for(let t=0;t<e.length;t+=2)n[c]=e[t],n[c+1]=e[t+1],c+=r}var Tv=s((()=>{ll()})),Ev,Dv,Ov=s((()=>{g(),Tv(),Ev=[],Dv={extension:{type:f.ShapeBuilder,name:`polygon`},build(e,t){for(let n=0;n<e.points.length;n++)t[n]=e.points[n];return!0},triangulate(e,t,n,r,i,a){wv(e,Ev,t,n,r,i,a)}}})),kv,Av=s((()=>{g(),kv={extension:{type:f.ShapeBuilder,name:`rectangle`},build(e,t){let n=e,r=n.x,i=n.y,a=n.width,o=n.height;return a>0&&o>0?(t[0]=r,t[1]=i,t[2]=r+a,t[3]=i,t[4]=r+a,t[5]=i+o,t[6]=r,t[7]=i+o,!0):!1},triangulate(e,t,n,r,i,a){let o=0;r*=n,t[r+o]=e[0],t[r+o+1]=e[1],o+=n,t[r+o]=e[2],t[r+o+1]=e[3],o+=n,t[r+o]=e[6],t[r+o+1]=e[7],o+=n,t[r+o]=e[4],t[r+o+1]=e[5],o+=n;let s=r/n;i[a++]=s,i[a++]=s+1,i[a++]=s+2,i[a++]=s+1,i[a++]=s+3,i[a++]=s+2}}})),jv,Mv=s((()=>{g(),jv={extension:{type:f.ShapeBuilder,name:`triangle`},build(e,t){return t[0]=e.x,t[1]=e.y,t[2]=e.x2,t[3]=e.y2,t[4]=e.x3,t[5]=e.y3,!0},triangulate(e,t,n,r,i,a){let o=0;r*=n,t[r+o]=e[0],t[r+o+1]=e[1],o+=n,t[r+o]=e[2],t[r+o+1]=e[3],o+=n,t[r+o]=e[4],t[r+o+1]=e[5];let s=r/n;i[a++]=s,i[a++]=s+1,i[a++]=s+2}}}));function Nv(e,t,n,r){let i=t.matrix?e.copyFrom(t.matrix).invert():e.identity();if(t.textureSpace===`local`){let e=n.getBounds(Fv);t.width&&e.pad(t.width);let{x:r,y:a}=e,o=1/e.width,s=1/e.height,c=-r*o,l=-a*s,u=i.a,d=i.b,f=i.c,p=i.d;i.a*=o,i.b*=o,i.c*=s,i.d*=s,i.tx=c*u+l*f+i.tx,i.ty=c*d+l*p+i.ty}else i.translate(t.texture.frame.x,t.texture.frame.y),i.scale(1/t.texture.source.width,1/t.texture.source.height);let a=t.texture.source.style;return!(t.fill instanceof iv)&&a.addressMode===`clamp-to-edge`&&(a.addressMode=`repeat`,a.update()),r&&i.append(Pv.copyFrom(r).invert()),i}var Pv,Fv,Iv=s((()=>{M(),yt(),av(),Pv=new j,Fv=new vt}));function Lv(e,t){let{geometryData:n,batches:r}=t;r.length=0,n.indices.length=0,n.vertices.length=0,n.uvs.length=0;for(let t=0;t<e.instructions.length;t++){let i=e.instructions[t];if(i.action===`texture`)Rv(i.data,r,n);else if(i.action===`fill`||i.action===`stroke`){let e=i.action===`stroke`,t=i.data.path.shapePath,a=i.data.style,o=i.data.hole;e&&o&&zv(o.shapePath,a,!0,r,n),o&&(t.shapePrimitives[t.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),zv(t,a,e,r,n)}}}function Rv(e,t,n){let r=[],i=Vv.rectangle,a=Hv;a.x=e.dx,a.y=e.dy,a.width=e.dw,a.height=e.dh;let o=e.transform;if(!i.build(a,r))return;let{vertices:s,uvs:c,indices:l}=n,u=l.length,d=s.length/2;o&&pv(r,o),i.triangulate(r,s,2,d,l,u);let f=e.image,p=f.uvs;c.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);let m=Qe.get(gv);m.indexOffset=u,m.indexSize=l.length-u,m.attributeOffset=d,m.attributeSize=s.length/2-d,m.baseColor=e.style,m.alpha=e.alpha,m.texture=f,m.geometryData=n,t.push(m)}function zv(e,t,n,r,i){let{vertices:a,uvs:o,indices:s}=i;e.shapePrimitives.forEach(({shape:e,transform:c,holes:l})=>{let u=[],d=Vv[e.type];if(!d.build(e,u))return;let f=s.length,p=a.length/2,m=`triangle-list`;if(c&&pv(u,c),n){let n=e.closePath??!0,r=t;r.pixelLine?(Sv(u,n,a,s),m=`line-list`):Z_(u,r,!1,n,a,s)}else if(l){let e=[],t=u.slice();Bv(l).forEach(n=>{e.push(t.length/2),t.push(...n)}),wv(t,e,a,2,p,s,f)}else d.triangulate(u,a,2,p,s,f);let h=o.length/2,g=t.texture;if(g!==R.WHITE){let n=Nv(Uv,t,e,c);uv(a,2,p,o,h,2,a.length/2-p,n)}else dv(o,h,2,a.length/2-p);let _=Qe.get(gv);_.indexOffset=f,_.indexSize=s.length-f,_.attributeOffset=p,_.attributeSize=a.length/2-p,_.baseColor=t.color,_.alpha=t.alpha,_.texture=g,_.geometryData=i,_.topology=m,r.push(_)})}function Bv(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n].shape,i=[];Vv[r.type].build(r,i)&&t.push(i)}return t}var Vv,Hv,Uv,Wv=s((()=>{g(),M(),yt(),fv(),mv(),z(),$e(),_v(),xv(),Q_(),Cv(),Ov(),Av(),Mv(),Iv(),Tv(),Vv={},h.handleByMap(f.ShapeBuilder,Vv),h.add(kv,Dv,jv,vv,yv,bv),Hv=new vt,Uv=new j}));function Gv(e,t,n){e.beginPath();for(let r=0;r<n.length;r+=3){let i=n[r]*2,a=n[r+1]*2,o=n[r+2]*2;e.moveTo(t[i],t[i+1]),e.lineTo(t[a],t[a+1]),e.lineTo(t[o],t[o+1]),e.closePath()}e.fill()}function Kv(e){return`#${(e&16777215).toString(16).padStart(6,`0`)}`}function qv(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function Jv(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;qv(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function Yv(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),Jv(e,r.shape),a&&e.restore()}return!0}function Xv(e,t,n,r){let i=e.fill;if(i instanceof iv){i.buildGradient();let a=i.texture;if(a){let o=U.getTintedPattern(a,t),s=n?ty.copyFrom(n).scale(a.source.pixelWidth,a.source.pixelHeight):ty.copyFrom(i.transform);return r&&!e.textureSpace&&s.append(r),U.applyPatternTransform(o,s),o}}if(i instanceof cv){let e=U.getTintedPattern(i.texture,t);return U.applyPatternTransform(e,i.transform,!1),e}let a=e.texture;if(a&&a!==R.WHITE){if(!a.source.resource)return Zv;let r=U.getTintedPattern(a,t),i=n?ty.copyFrom(n).scale(a.source.pixelWidth,a.source.pixelHeight):e.matrix;return U.applyPatternTransform(r,i),r}return Kv(t)}var Zv,Qv,$v,ey,ty,ny,ry=s((()=>{g(),En(),M(),ja(),z(),Bt(),Pt(),Q_(),av(),lv(),Wv(),Iv(),Zv=`#808080`,Qv=new j,$v=new j,ey=new j,ty=new j,ny=class{constructor(){this.shader=null}contextChange(e){}execute(e,t){let n=e.renderer,r=n.canvasContext,i=r.activeContext,a=t.groupTransform,o=n.globalUniforms.globalUniformData?.worldColor??4294967295,s=t.groupColorAlpha,c=(o>>>24&255)/255,l=(s>>>24&255)/255,u=n.filter?.alphaMultiplier??1,d=c*l*u;if(d<=0)return;let f=o&16777215,p=Rt(Nt(s&16777215,f)),m=n._roundPixels|t._roundPixels;i.save(),r.setContextTransform(a,m===1),r.setBlendMode(t.groupBlendMode);let h=t.context.instructions;for(let e=0;e<h.length;e++){let t=h[e];if(t.action===`texture`){let e=t.data,n=e.image,o=n?U.getCanvasSource(n):null;if(!o)continue;let s=e.alpha*d;if(s<=0)continue;let c=Nt(e.style,p);i.globalAlpha=s;let l=o;c!==16777215&&(l=U.getTintedCanvas({texture:n},c));let u=n.frame,f=n.source._resolution??n.source.resolution??1,h=u.x*f,g=u.y*f,_=u.width*f,v=u.height*f;l!==o&&(h=0,g=0);let y=e.transform,b=y&&!y.isIdentity(),x=n.rotate;b||x?(Qv.copyFrom(a),b&&Qv.append(y),x&&L.matrixAppendRotationInv(Qv,x,e.dx,e.dy,e.dw,e.dh),r.setContextTransform(Qv,m===1)):r.setContextTransform(a,m===1),i.drawImage(l,h,g,l===o?_:l.width,l===o?v:l.height,x?0:e.dx,x?0:e.dy,e.dw,e.dh),(b||x)&&r.setContextTransform(a,m===1);continue}let n=t.data,o=n?.path?.shapePath;if(!o?.shapePrimitives?.length)continue;let s=n.style,c=Nt(s.color,p),l=s.alpha*d;if(l<=0)continue;let u=t.action===`stroke`;if(i.globalAlpha=l,u){let e=s;i.lineWidth=e.width,i.lineCap=e.cap,i.lineJoin=e.join,i.miterLimit=e.miterLimit}let f=o.shapePrimitives;if(!u&&n.hole?.shapePath?.shapePrimitives?.length){let e=f[f.length-1];e.holes=n.hole.shapePath.shapePrimitives}for(let e=0;e<f.length;e++){let t=f[e];if(!t?.shape)continue;let n=t.transform,r=n&&!n.isIdentity(),o=s.texture&&s.texture!==R.WHITE,l=s.textureSpace===`global`?n:null,d=Xv(s,c,o?Nv($v,s,t.shape,l):null,r?ey.copyFrom(a).append(n):a);if(r&&(i.save(),i.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),u){let e=s;if(e.alignment!==.5&&!e.pixelLine){let n=[],r=[],a=[];Vv[t.shape.type]?.build(t.shape,n)?(Z_(n,e,!1,t.shape.closePath??!0,r,a),i.fillStyle=d,Gv(i,r,a)):(i.strokeStyle=d,i.beginPath(),Jv(i,t.shape),i.stroke())}else i.strokeStyle=d,i.beginPath(),Jv(i,t.shape),i.stroke()}else i.fillStyle=d,i.beginPath(),Jv(i,t.shape),Yv(i,t.holes)?i.fill(`evenodd`):i.fill();r&&i.restore()}}i.restore()}destroy(){this.shader=null}},ny.extension={type:[f.CanvasPipesAdaptor],name:`graphics`}})),iy,ay,oy=s((()=>{g(),En(),M(),Bt(),Pt(),ja(),iy=class e{static _getPatternRepeat(e,t){let n=e&&e!==`clamp-to-edge`,r=t&&t!==`clamp-to-edge`;return n&&r?`repeat`:n?`repeat-x`:r?`repeat-y`:`no-repeat`}start(e,t,n){}execute(t,n){let r=n.elements;if(!r||!r.length)return;let i=t.renderer,a=i.canvasContext,o=a.activeContext;for(let t=0;t<r.length;t++){let s=r[t];if(!s.packAsQuad)continue;let c=s,l=c.texture,u=l?U.getCanvasSource(l):null;if(!u)continue;let d=l.source.style,f=a.smoothProperty,p=d.scaleMode!==`nearest`;o[f]!==p&&(o[f]=p),a.setBlendMode(n.blendMode);let m=i.globalUniforms.globalUniformData?.worldColor??4294967295,h=c.color,g=(m>>>24&255)/255,_=(h>>>24&255)/255,v=i.filter?.alphaMultiplier??1,y=g*_*v;if(y<=0)continue;o.globalAlpha=y;let b=m&16777215,x=Rt(Nt(h&16777215,b)),S=l.frame,C=d.addressModeU??d.addressMode,w=d.addressModeV??d.addressMode,ee=e._getPatternRepeat(C,w),T=l.source._resolution??l.source.resolution??1,E=c.renderable?.renderGroup?.isCachedAsTexture,te=S.x*T,ne=S.y*T,re=S.width*T,ie=S.height*T,D=c.bounds,O=i.renderTarget.renderTarget.isRoot,ae=D.minX,oe=D.minY,se=D.maxX-D.minX,ce=D.maxY-D.minY,le=l.rotate,k=l.uvs,ue=Math.min(k.x0,k.x1,k.x2,k.x3,k.y0,k.y1,k.y2,k.y3),de=Math.max(k.x0,k.x1,k.x2,k.x3,k.y0,k.y1,k.y2,k.y3),fe=ee!==`no-repeat`&&(ue<0||de>1),pe=le&&!(!fe&&(x!==16777215||le));pe?(e._tempPatternMatrix.copyFrom(c.transform),L.matrixAppendRotationInv(e._tempPatternMatrix,le,ae,oe,se,ce),a.setContextTransform(e._tempPatternMatrix,c.roundPixels===1,void 0,E&&O)):a.setContextTransform(c.transform,c.roundPixels===1,void 0,E&&O);let me=se,he=ce,ge=pe?0:ae,_e=pe?0:oe;if(!pe&&c.roundPixels===1&&(ge|=0,_e|=0),fe){let t=u,n=x!==16777215&&!le,r=S.width<=l.source.width&&S.height<=l.source.height;n&&r&&(t=U.getTintedCanvas({texture:l},x));let i=o.createPattern(t,ee);if(!i)continue;let a=me,s=he;if(a===0||s===0)continue;let c=1/a,d=1/s,f=(k.x1-k.x0)*c,p=(k.y1-k.y0)*c,m=(k.x3-k.x0)*d,h=(k.y3-k.y0)*d,g=k.x0-f*ge-m*_e,_=k.y0-p*ge-h*_e,v=l.source.pixelWidth,y=l.source.pixelHeight;e._tempPatternMatrix.set(f*v,p*y,m*v,h*y,g*v,_*y),U.applyPatternTransform(i,e._tempPatternMatrix),o.fillStyle=i,o.fillRect(ge,_e,me,he)}else{let e=x!==16777215||le?U.getTintedCanvas({texture:l},x):u,t=e!==u;o.drawImage(e,t?0:te,t?0:ne,t?e.width:re,t?e.height:ie,ge,_e,me,he)}}}},iy._tempPatternMatrix=new j,iy.extension={type:[f.CanvasPipesAdaptor],name:`batch`},ay=iy})),sy,cy=s((()=>{g(),sy=class{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);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let 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);let r=this._colorStack;this._colorStackIndex--;let i=r[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}},sy.extension={type:[f.CanvasPipes],name:`colorMask`}}));function ly(e){let t=[];return e.replace(fy,(e,n,r)=>{let i=n.toLowerCase(),a=n,o=uy(r);for(i===`m`&&o.length>2&&(t.push([a,...o.splice(0,2)]),i=`l`,a=a===`m`?`l`:`L`);;){if(o.length===dy[i])return t.push([a,...o]),``;if(o.length<dy[i])throw Error(`malformed path data`);t.push([a,...o.splice(0,dy[i])])}}),t}function uy(e){let t=e.match(py);return t?t.map(Number):[]}var dy,fy,py,my=s((()=>{dy={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},fy=/([astvzqmhlc])([^astvzqmhlc]*)/gi,py=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi}));function hy(e,t){let n=ly(e),r=[],i=null,a=0,o=0;for(let e=0;e<n.length;e++){let s=n[e],c=s[0],l=s;switch(c){case`M`:a=l[1],o=l[2],t.moveTo(a,o);break;case`m`:a+=l[1],o+=l[2],t.moveTo(a,o);break;case`H`:a=l[1],t.lineTo(a,o);break;case`h`:a+=l[1],t.lineTo(a,o);break;case`V`:o=l[1],t.lineTo(a,o);break;case`v`:o+=l[1],t.lineTo(a,o);break;case`L`:a=l[1],o=l[2],t.lineTo(a,o);break;case`l`:a+=l[1],o+=l[2],t.lineTo(a,o);break;case`C`:a=l[5],o=l[6],t.bezierCurveTo(l[1],l[2],l[3],l[4],a,o);break;case`c`:t.bezierCurveTo(a+l[1],o+l[2],a+l[3],o+l[4],a+l[5],o+l[6]),a+=l[5],o+=l[6];break;case`S`:a=l[3],o=l[4],t.bezierCurveToShort(l[1],l[2],a,o);break;case`s`:t.bezierCurveToShort(a+l[1],o+l[2],a+l[3],o+l[4]),a+=l[3],o+=l[4];break;case`Q`:a=l[3],o=l[4],t.quadraticCurveTo(l[1],l[2],a,o);break;case`q`:t.quadraticCurveTo(a+l[1],o+l[2],a+l[3],o+l[4]),a+=l[3],o+=l[4];break;case`T`:a=l[1],o=l[2],t.quadraticCurveToShort(a,o);break;case`t`:a+=l[1],o+=l[2],t.quadraticCurveToShort(a,o);break;case`A`:a=l[6],o=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],a,o);break;case`a`:a+=l[6],o+=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],a,o);break;case`Z`:case`z`:t.closePath(),r.length>0&&(i=r.pop(),i?(a=i.startX,o=i.startY):(a=0,o=0)),i=null;break;default:F(`Unknown SVG path command: ${c}`)}c!==`Z`&&c!==`z`&&i===null&&(i={startX:a,startY:o},r.push(i))}return t}var gy=s((()=>{my(),I()})),_y,vy,yy,by,xy=s((()=>{g(),Tl(),Yd(),rn(),vp(),We(),$e(),Wv(),_y=class{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{Qe.return(e)}),this.graphicsData&&Qe.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}},vy=class{constructor(){this.instructions=new nn}init(e){let t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new Jd({maxTextures:t}),this.instructions.reset()}get geometry(){return P(He,`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}},yy=class e{constructor(e){this._renderer=e,this._managedContexts=new _p({renderer:e,type:`resource`,name:`graphicsContext`})}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){let t=!!e._gpuData[this._renderer.uid],n=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&n.reset(),Lv(e,n);let r=e.batchMode;e.customShader||r===`no-batch`?n.isBatchable=!1:r===`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){let t=Qe.get(vy,{maxTextures:this._renderer.limits.maxBatchableTextures}),n=e._gpuData[this._renderer.uid],{batches:r,geometryData:i}=n;n.graphicsData=t;let a=i.vertices.length,o=i.indices.length;for(let e=0;e<r.length;e++)r[e].applyTransform=!1;let s=t.batcher;s.ensureAttributeBuffer(a),s.ensureIndexBuffer(o),s.begin();for(let e=0;e<r.length;e++){let t=r[e];s.add(t)}s.finish(t.instructions);let c=s.geometry;c.indexBuffer.setDataWithSize(s.indexBuffer,s.indexSize,!0),c.buffers[0].setDataWithSize(s.attributeBuffer.float32View,s.attributeSize,!0);let l=s.batches;for(let e=0;e<l.length;e++){let t=l[e];t.bindGroup=Sl(t.textures.textures,t.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){let t=new _y;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}},yy.extension={type:[f.WebGLSystem,f.WebGPUSystem],name:`graphicsContext`},yy.defaultOptions={bezierSmoothness:.5},by=yy}));function Sy(e,t,n,r,i,a,o,s,c,l){let u=Math.min(.99,Math.max(0,l??by.defaultOptions.bezierSmoothness)),d=(Dy-u)/1;return d*=d,Cy(t,n,r,i,a,o,s,c,e,d),e}function Cy(e,t,n,r,i,a,o,s,c,l){wy(e,t,n,r,i,a,o,s,c,l,0),c.push(o,s)}function wy(e,t,n,r,i,a,o,s,c,l,u){if(u>Ty)return;let d=(e+n)/2,f=(t+r)/2,p=(n+i)/2,m=(r+a)/2,h=(i+o)/2,g=(a+s)/2,_=(d+p)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(_+y)/2,S=(v+b)/2;if(u>0){let u=o-e,d=s-t,f=Math.abs((n-o)*d-(r-s)*u),p=Math.abs((i-o)*d-(a-s)*u);if(f>Ey&&p>Ey){if((f+p)*(f+p)<=l*(u*u+d*d)){c.push(x,S);return}}else if(f>Ey){if(f*f<=l*(u*u+d*d)){c.push(x,S);return}}else if(p>Ey){if(p*p<=l*(u*u+d*d)){c.push(x,S);return}}else if(u=x-(e+o)/2,d=S-(t+s)/2,u*u+d*d<=l){c.push(x,S);return}}wy(e,t,d,f,_,v,x,S,c,l,u+1),wy(x,S,y,b,h,g,o,s,c,l,u+1)}var Ty,Ey,Dy,Oy=s((()=>{xy(),Ty=8,Ey=1.1920929e-7,Dy=1}));function ky(e,t,n,r,i,a,o,s){let c=Math.min(.99,Math.max(0,s??by.defaultOptions.bezierSmoothness)),l=(Py-c)/1;return l*=l,Ay(t,n,r,i,a,o,e,l),e}function Ay(e,t,n,r,i,a,o,s){jy(o,e,t,n,r,i,a,s,0),o.push(i,a)}function jy(e,t,n,r,i,a,o,s,c){if(c>My)return;let l=(t+r)/2,u=(n+i)/2,d=(r+a)/2,f=(i+o)/2,p=(l+d)/2,m=(u+f)/2,h=a-t,g=o-n,_=Math.abs((r-a)*g-(i-o)*h);if(_>Ny){if(_*_<=s*(h*h+g*g)){e.push(p,m);return}}else if(h=p-(t+a)/2,g=m-(n+o)/2,h*h+g*g<=s){e.push(p,m);return}jy(e,t,n,l,u,p,m,s,c+1),jy(e,p,m,d,f,a,o,s,c+1)}var My,Ny,Py,Fy=s((()=>{xy(),My=8,Ny=1.1920929e-7,Py=1}));function Iy(e,t,n,r,i,a,o,s){let c=Math.abs(i-a);(!o&&i>a||o&&a>i)&&(c=2*Math.PI-c),s||=Math.max(6,Math.floor(6*r**(1/3)*(c/Math.PI))),s=Math.max(s,3);let l=c/s,u=i;l*=o?-1:1;for(let i=0;i<s+1;i++){let i=Math.cos(u),a=Math.sin(u),o=t+i*r,s=n+a*r;e.push(o,s),u+=l}}var Ly=s((()=>{}));function Ry(e,t,n,r,i,a){let o=e[e.length-2],s=e[e.length-1]-n,c=o-t,l=i-n,u=r-t,d=Math.abs(s*u-c*l);if(d<1e-8||a===0){(e[e.length-2]!==t||e[e.length-1]!==n)&&e.push(t,n);return}let f=s*s+c*c,p=l*l+u*u,m=s*l+c*u,h=a*Math.sqrt(f)/d,g=a*Math.sqrt(p)/d,_=h*m/f,v=g*m/p,y=h*u+g*c,b=h*l+g*s,x=c*(g+_),S=s*(g+_),C=u*(h+v),w=l*(h+v),ee=Math.atan2(S-b,x-y),T=Math.atan2(w-b,C-y);Iy(e,y+t,b+n,a,ee,T,c*l>u*s)}var zy=s((()=>{Ly()}));function By(e,t){let n=t===-1.5707963267948966?-.551915024494:4/3*Math.tan(t/4),r=t===1.5707963267948966?.551915024494:n,i=Math.cos(e),a=Math.sin(e),o=Math.cos(e+t),s=Math.sin(e+t);return[{x:i-a*r,y:a+i*r},{x:o+s*r,y:s-o*r},{x:o,y:s}]}function Vy(e,t,n,r,i,a,o,s=0,c=0,l=0){if(a===0||o===0)return;let u=Math.sin(s*Hy/360),d=Math.cos(s*Hy/360),f=d*(t-r)/2+u*(n-i)/2,p=-u*(t-r)/2+d*(n-i)/2;if(f===0&&p===0)return;a=Math.abs(a),o=Math.abs(o);let m=f**2/a**2+p**2/o**2;m>1&&(a*=Math.sqrt(m),o*=Math.sqrt(m)),Ky(t,n,r,i,a,o,c,l,u,d,f,p,Uy);let{ang1:h,ang2:g}=Uy,{centerX:_,centerY:v}=Uy,y=Math.abs(g)/(Hy/4);Math.abs(1-y)<1e-7&&(y=1);let b=Math.max(Math.ceil(y),1);g/=b;let x=e[e.length-2],S=e[e.length-1],C={x:0,y:0};for(let t=0;t<b;t++){let t=By(h,g),{x:n,y:r}=Wy(t[0],a,o,d,u,_,v,C),{x:i,y:s}=Wy(t[1],a,o,d,u,_,v,C),{x:c,y:l}=Wy(t[2],a,o,d,u,_,v,C);Sy(e,x,S,n,r,i,s,c,l),x=c,S=l,h+=g}}var Hy,Uy,Wy,Gy,Ky,qy=s((()=>{Oy(),Hy=Math.PI*2,Uy={centerX:0,centerY:0,ang1:0,ang2:0},Wy=({x:e,y:t},n,r,i,a,o,s,c)=>{e*=n,t*=r;let l=i*e-a*t,u=a*e+i*t;return c.x=l+o,c.y=u+s,c},Gy=(e,t,n,r)=>{let i=e*r-t*n<0?-1:1,a=e*n+t*r;return a>1&&(a=1),a<-1&&(a=-1),i*Math.acos(a)},Ky=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=i**2,m=a**2,h=u**2,g=d**2,_=p*m-p*g-m*h;_<0&&(_=0),_/=p*g+m*h,_=Math.sqrt(_)*(o===s?-1:1);let v=_*i/a*d,y=_*-a/i*u,b=l*v-c*y+(e+n)/2,x=c*v+l*y+(t+r)/2,S=(u-v)/i,C=(d-y)/a,w=(-u-v)/i,ee=(-d-y)/a,T=Gy(1,0,S,C),E=Gy(S,C,w,ee);s===0&&E>0&&(E-=Hy),s===1&&E<0&&(E+=Hy),f.centerX=b,f.centerY=x,f.ang1=T,f.ang2=E}}));function Jy(e,t,n){let r=(e,t)=>{let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r);return{len:i,nx:n/i,ny:r/i}},i=(t,n)=>{t===0?e.moveTo(n.x,n.y):e.lineTo(n.x,n.y)},a=t[t.length-1];for(let o=0;o<t.length;o++){let s=t[o%t.length],c=s.radius??n;if(c<=0){i(o,s),a=s;continue}let l=t[(o+1)%t.length],u=r(s,a),d=r(s,l);if(u.len<1e-4||d.len<1e-4){i(o,s),a=s;continue}let f=Math.asin(u.nx*d.ny-u.ny*d.nx),p=1,m=!1;u.nx*d.nx-u.ny*-d.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,p=-1,m=!0):f>0&&(p=-1,m=!0);let h=f/2,g,_=Math.abs(Math.cos(h)*c/Math.sin(h));_>Math.min(u.len/2,d.len/2)?(_=Math.min(u.len/2,d.len/2),g=Math.abs(_*Math.sin(h)/Math.cos(h))):g=c;let v=s.x+d.nx*_+-d.ny*g*p,y=s.y+d.ny*_+d.nx*g*p,b=Math.atan2(u.ny,u.nx)+Math.PI/2*p,x=Math.atan2(d.ny,d.nx)-Math.PI/2*p;o===0&&e.moveTo(v+Math.cos(b)*g,y+Math.sin(b)*g),e.arc(v,y,g,b,x,m),a=s}}function Yy(e,t,n,r){let i=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),a=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),o=t.length;for(let s=0;s<o;s++){let c=t[(s+1)%o],l=c.radius??n;if(l<=0){s===0?e.moveTo(c.x,c.y):e.lineTo(c.x,c.y);continue}let u=t[s],d=t[(s+2)%o],f=i(u,c),p;p=f<1e-4?c:a(c,u,Math.min(f/2,l)/f);let m=i(d,c),h;h=m<1e-4?c:a(c,d,Math.min(m/2,l)/m),s===0?e.moveTo(p.x,p.y):e.lineTo(p.x,p.y),e.quadraticCurveTo(c.x,c.y,h.x,h.y,r)}}var Xy=s((()=>{})),Zy,Qy,$y=s((()=>{Ra(),Ba(),Wa(),yt(),qa(),St(),Oy(),Fy(),Ly(),zy(),qy(),Xy(),Zy=new vt,Qy=class{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new xt,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();let n=this._currentPoly.points,r=n[n.length-2],i=n[n.length-1];return(r!==e||i!==t)&&n.push(e,t),this}arc(e,t,n,r,i,a){this._ensurePoly(!1);let o=this._currentPoly.points;return Iy(o,e,t,n,r,i,a),this}arcTo(e,t,n,r,i){this._ensurePoly();let a=this._currentPoly.points;return Ry(a,e,t,n,r,i),this}arcToSvg(e,t,n,r,i,a,o){let s=this._currentPoly.points;return Vy(s,this._currentPoly.lastX,this._currentPoly.lastY,a,o,e,t,n,r,i),this}bezierCurveTo(e,t,n,r,i,a,o){this._ensurePoly();let s=this._currentPoly;return Sy(this._currentPoly.points,s.lastX,s.lastY,e,t,n,r,i,a,o),this}quadraticCurveTo(e,t,n,r,i){this._ensurePoly();let a=this._currentPoly;return ky(this._currentPoly.points,a.lastX,a.lastY,e,t,n,r,i),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));let n=this.shapePrimitives,r=n.length;for(let t=0;t<e.instructions.length;t++){let n=e.instructions[t];this[n.action](...n.data)}if(e.checkForHoles&&n.length-r>1){let e=null;for(let t=r;t<n.length;t++){let r=n[t];if(r.shape.type===`polygon`){let i=r.shape,a=e?.shape;a&&a.containsPolygon(i)?(e.holes||=[],e.holes.push(r),n.copyWithin(t,t+1),n.length--,t--):e=r}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,n,r,i){return this.drawShape(new vt(e,t,n,r),i),this}circle(e,t,n,r){return this.drawShape(new La(e,t,n),r),this}poly(e,t,n){let r=new Ua(e);return r.closePath=t,this.drawShape(r,n),this}regularPoly(e,t,n,r,i=0,a){r=Math.max(r|0,3);let o=-1*Math.PI/2+i,s=Math.PI*2/r,c=[];for(let i=0;i<r;i++){let r=o-i*s;c.push(e+n*Math.cos(r),t+n*Math.sin(r))}return this.poly(c,!0,a),this}roundPoly(e,t,n,r,i,a=0,o){if(r=Math.max(r|0,3),i<=0)return this.regularPoly(e,t,n,r,a);let s=n*Math.sin(Math.PI/r)-.001;i=Math.min(i,s);let c=-1*Math.PI/2+a,l=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let a=0;a<r;a++){let r=a*l+c,s=e+n*Math.cos(r),d=t+n*Math.sin(r),f=r+Math.PI+u,p=r-Math.PI-u,m=s+i*Math.cos(f),h=d+i*Math.sin(f),g=s+i*Math.cos(p),_=d+i*Math.sin(p);a===0?this.moveTo(m,h):this.lineTo(m,h),this.quadraticCurveTo(s,d,g,_,o)}return this.closePath()}roundShape(e,t,n=!1,r){return e.length<3?this:(n?Yy(this,e,t,r):Jy(this,e,t),this.closePath())}filletRect(e,t,n,r,i){if(i===0)return this.rect(e,t,n,r);let a=Math.min(n,r)/2,o=Math.min(a,Math.max(-a,i)),s=e+n,c=t+r,l=o<0?-o:0,u=Math.abs(o);return this.moveTo(e,t+u).arcTo(e+l,t+l,e+u,t,u).lineTo(s-u,t).arcTo(s-l,t+l,s,t+u,u).lineTo(s,c-u).arcTo(s-l,c-l,e+n-u,c,u).lineTo(e+u,c).arcTo(e+l,c-l,e,c-u,u).closePath()}chamferRect(e,t,n,r,i,a){if(i<=0)return this.rect(e,t,n,r);let o=Math.min(i,Math.min(n,r)/2),s=e+n,c=t+r,l=[e+o,t,s-o,t,s,t+o,s,c-o,s-o,c,e+o,c,e,c-o,e,t+o];for(let e=l.length-1;e>=2;e-=2)l[e]===l[e-2]&&l[e-1]===l[e-3]&&l.splice(e-1,2);return this.poly(l,!0,a)}ellipse(e,t,n,r,i){return this.drawShape(new za(e,t,n,r),i),this}roundRect(e,t,n,r,i,a){return this.drawShape(new Ka(e,t,n,r,i),a),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 Ua,n.points.push(e,t),this._currentPoly=n,this}endPoly(e=!1){let 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 Ua,e)){let e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let t=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){let r=e.transform,i=t;t=r.a*t+r.c*n+r.tx,n=r.b*i+r.d*n+r.ty}this._currentPoly.points.push(t,n)}else this._currentPoly.points.push(0,0)}}buildPath(){let e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){let n=e.instructions[t];this[n.action](...n.data)}this.finish()}get bounds(){let e=this._bounds;e.clear();let t=this.shapePrimitives;for(let n=0;n<t.length;n++){let r=t[n],i=r.shape.getBounds(Zy);r.transform?e.addRect(i,r.transform):e.addRect(i)}return e}}}));function eb(e,t){return e?e.prepend(t):t.clone()}var tb,nb=s((()=>{Ne(),Be(),I(),gy(),$y(),tb=class e{constructor(e,t=!1){this.instructions=[],this.uid=Re(`graphicsPath`),this._dirty=!0,this.checkForHoles=t,typeof e==`string`?hy(e,this):this.instructions=e?.slice()??[]}get shapePath(){return this._shapePath||=new Qy(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,r,i){let a=this.instructions[this.instructions.length-1],o=this.getLastPoint(je.shared),s=0,c=0;if(!a||a.action!==`bezierCurveTo`)s=o.x,c=o.y;else{s=a.data[2],c=a.data[3];let e=o.x,t=o.y;s=e+(e-s),c=t+(t-c)}return this.instructions.push({action:`bezierCurveTo`,data:[s,c,e,t,n,r,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){let r=this.instructions[this.instructions.length-1],i=this.getLastPoint(je.shared),a=0,o=0;if(!r||r.action!==`quadraticCurveTo`)a=i.x,o=i.y;else{a=r.data[0],o=r.data[1];let e=i.x,t=i.y;a=e+(e-a),o=t+(t-o)}return this.instructions.push({action:`quadraticCurveTo`,data:[a,o,e,t,n]}),this._dirty=!0,this}rect(e,t,n,r,i){return this.instructions.push({action:`rect`,data:[e,t,n,r,i]}),this._dirty=!0,this}circle(e,t,n,r){return this.instructions.push({action:`circle`,data:[e,t,n,r]}),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,r,i,a,o){i||=r/2;let s=-1*Math.PI/2+a,c=n*2,l=Math.PI*2/c,u=[];for(let n=0;n<c;n++){let a=n%2?i:r,o=n*l+s;u.push(e+a*Math.cos(o),t+a*Math.sin(o))}return this.poly(u,!0,o),this}clone(t=!1){let n=new e;if(n.checkForHoles=this.checkForHoles,!t)n.instructions=this.instructions.slice();else for(let e=0;e<this.instructions.length;e++){let t=this.instructions[e];n.instructions.push({action:t.action,data:t.data.slice()})}return n}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;let t=e.a,n=e.b,r=e.c,i=e.d,a=e.tx,o=e.ty,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;for(let h=0;h<this.instructions.length;h++){let g=this.instructions[h],_=g.data;switch(g.action){case`moveTo`:case`lineTo`:s=_[0],c=_[1],_[0]=t*s+r*c+a,_[1]=n*s+i*c+o;break;case`bezierCurveTo`:l=_[0],u=_[1],d=_[2],f=_[3],s=_[4],c=_[5],_[0]=t*l+r*u+a,_[1]=n*l+i*u+o,_[2]=t*d+r*f+a,_[3]=n*d+i*f+o,_[4]=t*s+r*c+a,_[5]=n*s+i*c+o;break;case`quadraticCurveTo`:l=_[0],u=_[1],s=_[2],c=_[3],_[0]=t*l+r*u+a,_[1]=n*l+i*u+o,_[2]=t*s+r*c+a,_[3]=n*s+i*c+o;break;case`arcToSvg`:s=_[5],c=_[6],p=_[0],m=_[1],_[0]=t*p+r*m,_[1]=n*p+i*m,_[5]=t*s+r*c+a,_[6]=n*s+i*c+o;break;case`circle`:_[4]=eb(_[3],e);break;case`rect`:_[4]=eb(_[4],e);break;case`ellipse`:_[8]=eb(_[8],e);break;case`roundRect`:_[5]=eb(_[5],e);break;case`addPath`:_[0].transform(e);break;case`poly`:_[2]=eb(_[2],e);break;case`regularPoly`:case`chamferRect`:_[5]=eb(_[5],e);break;case`closePath`:break;default:F(`unknown transform action`,g.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 rb(e,t,n){let r=e.getAttribute(t);return r?Number(r):n}var ib=s((()=>{}));function ab(e,t){let n=e.querySelectorAll(`defs`);for(let e=0;e<n.length;e++){let r=n[e];for(let e=0;e<r.children.length;e++){let n=r.children[e];switch(n.nodeName.toLowerCase()){case`lineargradient`:t.defs[n.id]=ob(n);break;case`radialgradient`:t.defs[n.id]=sb(n);break;default:break}}}}function ob(e){let t=new iv(rb(e,`x1`,0),rb(e,`y1`,0),rb(e,`x2`,1),rb(e,`y2`,0),(e.getAttribute(`gradientUnits`)||`objectBoundingBox`)===`objectBoundingBox`?`local`:`global`);for(let n=0;n<e.children.length;n++){let r=e.children[n],i=rb(r,`offset`,0),a=A.shared.setValue(r.getAttribute(`stop-color`)).toNumber();t.addColorStop(i,a)}return t}function sb(e){return F(`[SVG Parser] Radial gradients are not yet supported`),new iv(0,0,1,0)}var cb=s((()=>{we(),I(),av(),ib()}));function lb(e){let t=e.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:``}var ub=s((()=>{}));function db(e,t){let n=e.getAttribute(`style`),r={},i={},a={strokeStyle:r,fillStyle:i,useFill:!1,useStroke:!1};for(let n in pb){let r=e.getAttribute(n);r&&fb(t,a,n,r.trim())}if(n){let e=n.split(`;`);for(let n=0;n<e.length;n++){let[r,i]=e[n].trim().split(`:`);pb[r]&&fb(t,a,r,i.trim())}}return{strokeStyle:a.useStroke?r:null,fillStyle:a.useFill?i:null,useFill:a.useFill,useStroke:a.useStroke}}function fb(e,t,n,r){switch(n){case`stroke`:if(r!==`none`){if(r.startsWith(`url(`)){let n=lb(r);t.strokeStyle.fill=e.defs[n]}else t.strokeStyle.color=A.shared.setValue(r).toNumber();t.useStroke=!0}break;case`stroke-width`:t.strokeStyle.width=Number(r);break;case`fill`:if(r!==`none`){if(r.startsWith(`url(`)){let n=lb(r);t.fillStyle.fill=e.defs[n]}else t.fillStyle.color=A.shared.setValue(r).toNumber();t.useFill=!0}break;case`fill-opacity`:t.fillStyle.alpha=Number(r);break;case`stroke-opacity`:t.strokeStyle.alpha=Number(r);break;case`opacity`:t.fillStyle.alpha=Number(r),t.strokeStyle.alpha=Number(r);break}}var pb,mb=s((()=>{we(),ub(),pb={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 hb(e){if(e.length<=2)return!0;let t=e.map(e=>e.area).sort((e,t)=>t-e),[n,r]=t,i=t[t.length-1],a=n/r,o=r/i;return!(a>3&&o<2)}var gb=s((()=>{}));function _b(e){return e.split(/(?=[Mm])/).filter(e=>e.trim().length>0)}function vb(e){let t=e.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;let n=t.map(Number),r=[],i=[];for(let e=0;e<n.length;e+=2)e+1<n.length&&(r.push(n[e]),i.push(n[e+1]));if(r.length===0||i.length===0)return 0;let a=Math.min(...r),o=Math.max(...r),s=Math.min(...i),c=Math.max(...i);return(o-a)*(c-s)}function yb(e,t){let n=new tb(e,!1);for(let e of n.instructions)t.instructions.push(e)}var bb=s((()=>{nb()}));function xb(e,t){if(typeof e==`string`){let t=document.createElement(`div`);t.innerHTML=e.trim(),e=t.querySelector(`svg`)}let n={context:t,defs:{},path:new tb};ab(e,n);let r=e.children,{fillStyle:i,strokeStyle:a}=db(e,n);for(let e=0;e<r.length;e++){let t=r[e];t.nodeName.toLowerCase()!==`defs`&&Sb(t,n,i,a)}return t}function Sb(e,t,n,r){let i=e.children,{fillStyle:a,strokeStyle:o}=db(e,t);a&&n?n={...n,...a}:a&&(n=a),o&&r?r={...r,...o}:o&&(r=o);let s=!n&&!r;s&&(n={color:0});let c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w;switch(e.nodeName.toLowerCase()){case`path`:{x=e.getAttribute(`d`);let i=e.getAttribute(`fill-rule`),a=_b(x),o=i===`evenodd`,s=a.length>1;if(o&&s){let e=a.map(e=>({path:e,area:vb(e)}));if(e.sort((e,t)=>t.area-e.area),a.length>3||!hb(e))for(let i=0;i<e.length;i++){let a=e[i],o=i===0;t.context.beginPath();let s=new tb(void 0,!0);yb(a.path,s),t.context.path(s),o?(n&&t.context.fill(n),r&&t.context.stroke(r)):t.context.cut()}else for(let i=0;i<e.length;i++){let a=e[i],o=i%2==1;t.context.beginPath();let s=new tb(void 0,!0);yb(a.path,s),t.context.path(s),o?t.context.cut():(n&&t.context.fill(n),r&&t.context.stroke(r))}}else S=new tb(x,!i||i===`evenodd`),t.context.path(S),n&&t.context.fill(n),r&&t.context.stroke(r);break}case`circle`:m=rb(e,`cx`,0),h=rb(e,`cy`,0),g=rb(e,`r`,0),t.context.ellipse(m,h,g,g),n&&t.context.fill(n),r&&t.context.stroke(r);break;case`rect`:c=rb(e,`x`,0),l=rb(e,`y`,0),C=rb(e,`width`,0),w=rb(e,`height`,0),_=rb(e,`rx`,0),v=rb(e,`ry`,0),_||v?t.context.roundRect(c,l,C,w,_||v):t.context.rect(c,l,C,w),n&&t.context.fill(n),r&&t.context.stroke(r);break;case`ellipse`:m=rb(e,`cx`,0),h=rb(e,`cy`,0),_=rb(e,`rx`,0),v=rb(e,`ry`,0),t.context.beginPath(),t.context.ellipse(m,h,_,v),n&&t.context.fill(n),r&&t.context.stroke(r);break;case`line`:u=rb(e,`x1`,0),d=rb(e,`y1`,0),f=rb(e,`x2`,0),p=rb(e,`y2`,0),t.context.beginPath(),t.context.moveTo(u,d),t.context.lineTo(f,p),r&&t.context.stroke(r);break;case`polygon`:b=e.getAttribute(`points`),y=b.match(/-?\d+/g).map(e=>parseInt(e,10)),t.context.poly(y,!0),n&&t.context.fill(n),r&&t.context.stroke(r);break;case`polyline`:b=e.getAttribute(`points`),y=b.match(/-?\d+/g).map(e=>parseInt(e,10)),t.context.poly(y,!1),r&&t.context.stroke(r);break;case`g`:case`svg`:break;default:F(`[SVG parser] <${e.nodeName}> elements unsupported`);break}s&&(n=null);for(let e=0;e<i.length;e++)Sb(i[e],t,n,r)}var Cb=s((()=>{I(),nb(),cb(),ib(),mb(),gb(),bb()}));function wb(e){return A.isColorLike(e)}function Tb(e){return e instanceof cv}function Eb(e){return e instanceof iv}function Db(e){return e instanceof R}function Ob(e,t,n){let r=A.shared.setValue(t??0);return e.color=r.toNumber(),e.alpha=r.alpha===1?n.alpha:r.alpha,e.texture=R.WHITE,{...n,...e}}function kb(e,t,n){return e.texture=t,{...n,...e}}function Ab(e,t,n){return e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,e.textureSpace=t.textureSpace,{...n,...e}}function jb(e,t,n){return t.buildGradient(),e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,e.textureSpace=t.textureSpace,{...n,...e}}function Mb(e,t){let n={...t,...e},r=A.shared.setValue(n.color);return n.alpha*=r.alpha,n.color=r.toNumber(),n}function Nb(e,t){if(e==null)return null;let n={},r=e;return wb(e)?Ob(n,e,t):Db(e)?kb(n,e,t):Tb(e)?Ab(n,e,t):Eb(e)?jb(n,e,t):r.fill&&Tb(r.fill)?Ab(r,r.fill,t):r.fill&&Eb(r.fill)?jb(r,r.fill,t):Mb(r,t)}function Pb(e,t){let{width:n,alignment:r,miterLimit:i,cap:a,join:o,pixelLine:s,...c}=t,l=Nb(e,c);return l?{width:n,alignment:r,miterLimit:i,cap:a,join:o,pixelLine:s,...l}:null}var Fb=s((()=>{we(),z(),av(),lv()}));function Ib(e,t){let n=1,r=e.shapePath.shapePrimitives;for(let e=0;e<r.length;e++){let i=r[e].shape;if(i.type!==`polygon`)continue;let a=i.points,o=a.length;if(o<6)continue;let s=i.closePath;for(let e=0;e<o;e+=2){if(!s&&(e===0||e===o-2))continue;let r=(e-2+o)%o,i=(e+2)%o,c=a[r],l=a[r+1],u=a[e],d=a[e+1],f=a[i],p=a[i+1],m=c-u,h=l-d,g=f-u,_=p-d,v=m*m+h*h,y=g*g+_*_;if(v<1e-12||y<1e-12)continue;let b=(m*g+h*_)/Math.sqrt(v*y);b<-1?b=-1:b>1&&(b=1);let x=Math.sqrt((1-b)*.5);if(x<1e-6)continue;let S=Math.min(1/x,t);S>n&&(n=S)}}return n}var Lb=s((()=>{})),Rb,zb,Bb,Vb,Hb=s((()=>{b(),we(),M(),Ne(),z(),Be(),We(),St(),nb(),Cb(),Fb(),Lb(),Rb=new je,zb=new j,Bb=class e extends y{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Re(`graphicsContext`),this.dirty=!0,this.batchMode=`auto`,this.instructions=[],this.destroyed=!1,this._activePath=new tb,this._transform=new j,this._fillStyle={...e.defaultFillStyle},this._strokeStyle={...e.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new xt,this._boundsDirty=!0}clone(){let t=new e;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=Nb(t,e.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Pb(t,e.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Nb(t,e.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Nb(t,e.defaultStrokeStyle),this}texture(e,t,n,r,i,a){return this.instructions.push({action:`texture`,data:{image:e,dx:n||0,dy:r||0,dw:i||e.frame.width,dh:a||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?A.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new tb,this}fill(t,n){let r,i=this.instructions[this.instructions.length-1];return r=this._tick===0&&i?.action===`stroke`?i.data.path:this._activePath.clone(),r?(t!=null&&(n!==void 0&&typeof t==`number`&&(P(N,`GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead`),t={color:t,alpha:n}),this._fillStyle=Nb(t,e.defaultFillStyle)),this.instructions.push({action:`fill`,data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){let{x:e,y:t}=this._activePath.getLastPoint(je.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(t){let n,r=this.instructions[this.instructions.length-1];return n=this._tick===0&&r?.action===`fill`?r.data.path:this._activePath.clone(),n?(t!=null&&(this._strokeStyle=Pb(t,e.defaultStrokeStyle)),this.instructions.push({action:`stroke`,data:{style:this.strokeStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){let 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,r,i,a){this._tick++;let o=this._transform;return this._activePath.arc(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,n,r,i,a),this}arcTo(e,t,n,r,i){this._tick++;let a=this._transform;return this._activePath.arcTo(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,i),this}arcToSvg(e,t,n,r,i,a,o){this._tick++;let s=this._transform;return this._activePath.arcToSvg(e,t,n,r,i,s.a*a+s.c*o+s.tx,s.b*a+s.d*o+s.ty),this}bezierCurveTo(e,t,n,r,i,a,o){this._tick++;let s=this._transform;return this._activePath.bezierCurveTo(s.a*e+s.c*t+s.tx,s.b*e+s.d*t+s.ty,s.a*n+s.c*r+s.tx,s.b*n+s.d*r+s.ty,s.a*i+s.c*a+s.tx,s.b*i+s.d*a+s.ty,o),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(e,t,n,r){return this._tick++,this._activePath.ellipse(e,t,n,r,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++;let 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++;let n=this._transform,r=this._activePath.instructions,i=n.a*e+n.c*t+n.tx,a=n.b*e+n.d*t+n.ty;return r.length===1&&r[0].action===`moveTo`?(r[0].data[0]=i,r[0].data[1]=a,this):(this._activePath.moveTo(i,a),this)}quadraticCurveTo(e,t,n,r,i){this._tick++;let a=this._transform;return this._activePath.quadraticCurveTo(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,i),this}rect(e,t,n,r){return this._tick++,this._activePath.rect(e,t,n,r,this._transform.clone()),this}roundRect(e,t,n,r,i){return this._tick++,this._activePath.roundRect(e,t,n,r,i,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,n,r,i=0,a){return this._tick++,this._activePath.regularPoly(e,t,n,r,i,a),this}roundPoly(e,t,n,r,i,a){return this._tick++,this._activePath.roundPoly(e,t,n,r,i,a),this}roundShape(e,t,n,r){return this._tick++,this._activePath.roundShape(e,t,n,r),this}filletRect(e,t,n,r,i){return this._tick++,this._activePath.filletRect(e,t,n,r,i),this}chamferRect(e,t,n,r,i,a){return this._tick++,this._activePath.chamferRect(e,t,n,r,i,a),this}star(e,t,n,r,i=0,a=0){return this._tick++,this._activePath.star(e,t,n,r,i,a,this._transform.clone()),this}svg(e){return this._tick++,xb(e,this),this}restore(){let 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,r,i,a){return e instanceof j?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,n,r,i,a),this)}transform(e,t,n,r,i,a){return e instanceof j?(this._transform.append(e),this):(zb.set(e,t,n,r,i,a),this._transform.append(zb),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;let e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){let n=this.instructions[t],r=n.action;if(r===`fill`){let t=n.data;e.addBounds(t.path.bounds)}else if(r===`texture`){let t=n.data;e.addFrame(t.dx,t.dy,t.dx+t.dw,t.dy+t.dh,t.transform)}if(r===`stroke`){let t=n.data,r=t.style.alignment,i=t.style.width*(1-r);t.style.join===`miter`&&(i*=Ib(t.path,t.style.miterLimit));let a=t.path.bounds;e.addFrame(a.minX-i,a.minY-i,a.maxX+i,a.maxY+i)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;let t=this.instructions,n=!1;for(let r=0;r<t.length;r++){let i=t[r],a=i.data,o=a.path;if(!i.action||!o)continue;let s=a.style,c=o.shapePath.shapePrimitives;for(let t=0;t<c.length;t++){let r=c[t].shape;if(!s||!r)continue;let o=c[t].transform,l=o?o.applyInverse(e,Rb):e;if(i.action===`fill`)n=r.contains(l.x,l.y);else{let e=s;n=r.strokeContains(l.x,l.y,e.width,e.alignment)}let u=a.hole;if(u){let e=u.shapePath?.shapePrimitives;if(e)for(let t=0;t<e.length;t++)e[t].shape.contains(l.x,l.y)&&(n=!1)}if(n)return!0}}return n}unload(){this.emit(`unload`,this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){if(!this.destroyed){if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit(`destroy`,this),this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&`uid`in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(t)),this._strokeStyle.texture&&(this._strokeStyle.fill&&`uid`in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(t))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}}},Bb.defaultFillStyle={color:16777215,alpha:1,texture:R.WHITE,matrix:null,fill:null,textureSpace:`local`},Bb.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:`butt`,join:`miter`,texture:R.WHITE,matrix:null,fill:null,textureSpace:`local`,pixelLine:!1},Vb=Bb})),Ub,Wb,Gb,Kb,qb=s((()=>{g(),rn(),vp(),Ub=class{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&=(this.graphicsData.destroy(),null)}destroy(){this.reset()}},Wb=class{constructor(){this.instructions=new nn}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}},Gb=class e{constructor(e){this._renderer=e,this._managedContexts=new _p({renderer:e,type:`resource`,name:`graphicsContext`})}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(e){return this.getGpuContext(e).graphicsData||this._initContextRenderData(e)}updateGpuContext(e){let t=e._gpuData,n=!!t[this._renderer.uid],r=t[this._renderer.uid]||this._initContext(e);return(e.dirty||!n)&&(n&&r.reset(),r.isBatchable=!1,e.dirty=!1),r}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){let t=new Wb,n=this.getGpuContext(e);return n.graphicsData=t,t.init(),t}_initContext(e){let t=new Ub;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}},Gb.extension={type:[f.CanvasSystem],name:`graphicsContext`},Gb.defaultOptions={bezierSmoothness:.5},Kb=Gb})),Jb,Yb=s((()=>{g(),Ts(),vp(),Jb=class{constructor(e,t){this.state=ws.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new _p({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}},Jb.extension={type:[f.CanvasPipes],name:`graphics`}})),Xb,Zb,Qb=s((()=>{g(),Ts(),vp(),$e(),Bf(),_v(),Xb=class{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(e=>{Qe.return(e)}),this.batches.length=0}},Zb=class{constructor(e,t){this.state=ws.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new _p({renderer:e,type:`renderable`,priority:-1,name:`graphics`})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){let t=e.context,n=!!e._gpuData,r=this.renderer.graphicsContext.updateGpuContext(t);return!!(r.isBatchable||n!==r.isBatchable)}addRenderable(e,t){let n=this.renderer.graphicsContext.updateGpuContext(e.context);e.didViewUpdate&&this._rebuild(e),n.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){let t=this._getGpuDataForRenderable(e).batches;for(let e=0;e<t.length;e++){let n=t[e];n._batcher.updateElement(n)}}execute(e){if(!e.isRenderable)return;let t=this.renderer,n=e.context;if(!t.graphicsContext.getGpuContext(n).batches.length)return;let r=n.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;let i=r.resources.localUniforms.uniforms;i.uTransformMatrix=e.groupTransform,i.uRound=t._roundPixels|e._roundPixels,zf(e.groupColorAlpha,i.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){let t=this._getGpuDataForRenderable(e),n=this.renderer.graphicsContext.updateGpuContext(e.context);t.destroy(),n.isBatchable&&this._updateBatchesForRenderable(e,t)}_addToBatcher(e,t){let n=this.renderer.renderPipes.batch,r=this._getGpuDataForRenderable(e).batches;for(let e=0;e<r.length;e++){let i=r[e];n.addToBatch(i,t)}}_getGpuDataForRenderable(e){return e._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(e)}_initGpuDataForRenderable(e){let t=new Xb;return e._gpuData[this.renderer.uid]=t,this._managedGraphics.add(e),t}_updateBatchesForRenderable(e,t){let n=e.context,r=this.renderer.graphicsContext.getGpuContext(n),i=this.renderer._roundPixels|e._roundPixels;t.batches=r.batches.map(t=>{let n=Qe.get(gv);return t.copyTo(n),n.renderable=e,n.roundPixels=i,n})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}},Zb.extension={type:[f.WebGLPipes,f.WebGPUPipes],name:`graphics`}})),$b=s((()=>{g(),qb(),Yb(),xy(),Qb(),h.add(Jb),h.add(Zb),h.add(Kb),h.add(by)})),ex,tx=s((()=>{We(),Gr(),Hb(),$b(),ex=class e extends Wr{constructor(e){e instanceof Vb&&(e={context:e});let{context:t,roundPixels:n,...r}=e||{};super({label:`Graphics`,...r}),this.renderPipeId=`graphics`,t?this.context=t:(this.context=this._ownedContext=new Vb,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?.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(t=!1){return t?new e(this._context.clone()):(this._ownedContext=null,new e(this._context))}lineStyle(e,t,n){P(N,`Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.`);let r={};return e&&(r.width=e),t&&(r.color=t),n&&(r.alpha=n),this.context.strokeStyle=r,this}beginFill(e,t){P(N,`Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.`);let n={};return e!==void 0&&(n.color=e),t!==void 0&&(n.alpha=t),this.context.fillStyle=n,this}endFill(){P(N,`Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.`),this.context.fill();let e=this.context.strokeStyle;return(e.width!==Vb.defaultStrokeStyle.width||e.color!==Vb.defaultStrokeStyle.color||e.alpha!==Vb.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return P(N,`Graphics#drawCircle has been renamed to Graphics#circle`),this._callContextMethod(`circle`,e)}drawEllipse(...e){return P(N,`Graphics#drawEllipse has been renamed to Graphics#ellipse`),this._callContextMethod(`ellipse`,e)}drawPolygon(...e){return P(N,`Graphics#drawPolygon has been renamed to Graphics#poly`),this._callContextMethod(`poly`,e)}drawRect(...e){return P(N,`Graphics#drawRect has been renamed to Graphics#rect`),this._callContextMethod(`rect`,e)}drawRoundedRect(...e){return P(N,`Graphics#drawRoundedRect has been renamed to Graphics#roundRect`),this._callContextMethod(`roundRect`,e)}drawStar(...e){return P(N,`Graphics#drawStar has been renamed to Graphics#star`),this._callContextMethod(`star`,e)}}}));function nx(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function rx(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;nx(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.moveTo(n.x+n.radius,n.y),e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?(e.moveTo(n.x+n.halfWidth,n.y),e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2)):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.moveTo(1,0),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function ix(e,t,n){let r=[],i=[],a=[];if(!Vv[t.type]?.build(t,r))return!1;Z_(r,n,!1,t.closePath??!0,i,a);for(let t=0;t<a.length;t+=3){let n=a[t]*2,r=a[t+1]*2,o=a[t+2]*2;e.moveTo(i[n],i[n+1]),e.lineTo(i[r],i[r+1]),e.lineTo(i[o],i[o+1]),e.closePath()}return!0}function ax(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),rx(e,r.shape),a&&e.restore()}return!0}var ox,sx=s((()=>{g(),Q_(),tx(),Wv(),I(),ox=class{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){if(e.action!==`pushMaskBegin`&&e.action!==`popMaskEnd`)return;let t=this._renderer,n=t.canvasContext,r=n?.activeContext;if(!r)return;if(e.action===`popMaskEnd`){this._canvasMaskStack.pop()&&r.restore();return}e.inverse&&this._warnOnce(`inverse`,`CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.`);let i=e.mask.mask;if(!(i instanceof ex)){this._warnOnce(`nonGraphics`,`CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask.`),this._canvasMaskStack.push(!1);return}let a=i,o=a.context?.instructions;if(!o?.length){this._canvasMaskStack.push(!1);return}r.save(),n.setContextTransform(a.groupTransform,(t._roundPixels|a._roundPixels)===1),r.beginPath();let s=!1,c=!1;for(let e=0;e<o.length;e++){let t=o[e],n=t.action;if(n!==`fill`&&n!==`stroke`)continue;let i=t.data,a=i?.path?.shapePath;if(!a?.shapePrimitives?.length)continue;let l=n===`stroke`,u=a.shapePrimitives;for(let e=0;e<u.length;e++){let t=u[e];if(!t?.shape)continue;let n=t.transform,a=n&&!n.isIdentity();a&&(r.save(),r.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),l&&i.style?s=ix(r,t.shape,i.style)||s:(rx(r,t.shape),c=ax(r,t.holes)||c,s=!0),a&&r.restore()}}if(!s){r.restore(),this._canvasMaskStack.push(!1);return}c?r.clip(`evenodd`):r.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),F(t))}},ox.extension={type:[f.CanvasPipes],name:`stencilMask`}}));function cx(){let e=Oa(),t=Object.create(null);return t.inherit=G,t.none=G,t.normal=`source-over`,t.add=`lighter`,t.multiply=e?`multiply`:G,t.screen=e?`screen`:G,t.overlay=e?`overlay`:G,t.darken=e?`darken`:G,t.lighten=e?`lighten`:G,t[`color-dodge`]=e?`color-dodge`:G,t[`color-burn`]=e?`color-burn`:G,t[`hard-light`]=e?`hard-light`:G,t[`soft-light`]=e?`soft-light`:G,t.difference=e?`difference`:G,t.exclusion=e?`exclusion`:G,t.saturation=e?`saturation`:G,t.color=e?`color`:G,t.luminosity=e?`luminosity`:G,t[`linear-burn`]=e?`color-burn`:G,t[`linear-dodge`]=e?`color-dodge`:G,t[`linear-light`]=e?`hard-light`:G,t[`pin-light`]=e?`hard-light`:G,t[`vivid-light`]=e?`hard-light`:G,t[`hard-mix`]=G,t.negation=e?`difference`:G,t[`normal-npm`]=t.normal,t[`add-npm`]=t.add,t[`screen-npm`]=t.screen,t.erase=`destination-out`,t.subtract=G,t.divide=G,t.min=G,t.max=G,t}var G,lx=s((()=>{Aa(),G=`source-over`})),ux,dx,fx=s((()=>{we(),g(),M(),lx(),ux=new j,dx=class{constructor(e){this.activeResolution=1,this.smoothProperty=`imageSmoothingEnabled`,this.blendModes=cx(),this._activeBlendMode=`normal`,this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){let 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){let e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty=`webkitImageSmoothingEnabled`:e.mozImageSmoothingEnabled?this.smoothProperty=`mozImageSmoothingEnabled`:e.oImageSmoothingEnabled?this.smoothProperty=`oImageSmoothingEnabled`:e.msImageSmoothingEnabled&&(this.smoothProperty=`msImageSmoothingEnabled`)}}setContextTransform(e,t,n,r){let i=r?j.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||j.IDENTITY,a=ux;a.copyFrom(i),a.append(e);let o=this._projTransform,s=this.activeResolution;if(n||=s,o){let e=j.shared;e.copyFrom(a),e.prepend(o),a=e}t?this.activeContext.setTransform(a.a*n,a.b*n,a.c*n,a.d*n,a.tx*s|0,a.ty*s|0):this.activeContext.setTransform(a.a*n,a.b*n,a.c*n,a.d*n,a.tx*s,a.ty*s)}clear(e,t){let n=this.activeContext,r=this._renderer;if(n.clearRect(0,0,r.width,r.height),e){let i=A.shared.setValue(e);n.globalAlpha=t??i.alpha,n.fillStyle=i.toHex(),n.fillRect(0,0,r.width,r.height),n.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;let 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()}},dx.extension={type:[f.CanvasSystem],name:`canvasContext`}})),px,mx=s((()=>{g(),px=class{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}},px.extension={type:[f.CanvasSystem],name:`limits`}})),hx,gx=s((()=>{we(),V(),ua(),hx=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){let t=e.colorTexture,{canvas:n,context:r}=this._ensureCanvas(t);return{canvas:n,context:r,width:n.width,height:n.height}}resizeGpuRenderTarget(e){let t=e.colorTexture,{canvas:n}=this._ensureCanvas(t);n.width=e.pixelWidth,n.height=e.pixelHeight}startRenderPass(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=i.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,n,r)}clear(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e).context,a=r||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(i.setTransform(1,0,0,1,0,0),i.clearRect(a.x,a.y,a.width,a.height),n){let e=A.shared.setValue(n);e.alpha>0&&(i.globalAlpha=e.alpha,i.fillStyle=e.toHex(),i.fillRect(a.x,a.y,a.width,a.height),i.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,n,r,i){let a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,o=t.source,{context:s}=this._ensureCanvas(o),c=i?.x??0,l=i?.y??0;return s.drawImage(a,n.x,n.y,r.width,r.height,c,l,r.width,r.height),o.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!la.test(t))&&(t=B.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);let n=t.getContext(`2d`);return{canvas:t,context:n}}}})),_x,vx=s((()=>{g(),ym(),gx(),_x=class extends vm{constructor(e){super(e),this.adaptor=new hx,this.adaptor.init(e,this)}},_x.extension={type:[f.CanvasSystem],name:`renderTarget`}})),yx,bx=s((()=>{V(),g(),ja(),yx=class{constructor(e){}init(){}initSource(e){}generateCanvas(e){let t=B.get().createCanvas(),n=t.getContext(`2d`),r=U.getCanvasSource(e);if(!r)return t;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.x*a,s=i.y*a,c=i.width*a,l=i.height*a;return t.width=Math.ceil(c),t.height=Math.ceil(l),n.drawImage(r,o,s,c,l,0,0,c,l),t}getPixels(e){let 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(){}},yx.extension={type:[f.CanvasSystem],name:`texture`}})),xx=l({CanvasRenderer:()=>Ox}),Sx,Cx,wx,Tx,Ex,Dx,Ox,kx=s((()=>{g(),Iu(),Hu(),ry(),id(),oy(),Qd(),df(),cy(),sx(),xf(),_l(),mp(),as(),fx(),mx(),vx(),bx(),Sx=[...fp,dx,px,yx,_x],Cx=[bf,Zd,rd,Vu,uf,ox,sy,Fu],wx=[ay,ny],Tx=[],Ex=[],Dx=[],h.handleByNamedList(f.CanvasSystem,Tx),h.handleByNamedList(f.CanvasPipes,Ex),h.handleByNamedList(f.CanvasPipesAdaptor,Dx),h.add(...Sx,...Cx,...wx),Ox=class extends gl{constructor(){let e={name:`canvas`,type:is.CANVAS,systems:Tx,renderPipes:Ex,renderPipeAdaptors:Dx};super(e)}}}));_l();let Ax=[`webgl`,`webgpu`,`canvas`];async function jx(e){let t=[];e.preference?Array.isArray(e.preference)?t=e.preference.slice():(t.push(e.preference),Ax.forEach(n=>{n!==e.preference&&t.push(n)})):t=Ax.slice();let n,r={};for(let i=0;i<t.length;i++){let a=t[i];if(a===`webgpu`&&await xl()){let{WebGPURenderer:t}=await Promise.resolve().then(()=>(ah(),Zm));n=t,r={...e,...e.webgpu};break}else if(a===`webgl`&&yl(e.failIfMajorPerformanceCaveat??gl.defaultOptions.failIfMajorPerformanceCaveat)){let{WebGLRenderer:t}=await Promise.resolve().then(()=>(U_(),F_));n=t,r={...e,...e.webgl};break}else if(a===`canvas`){let{CanvasRenderer:t}=await Promise.resolve().then(()=>(kx(),xx));n=t,r={...e,...e.canvasOptions};break}}if(delete r.webgpu,delete r.webgl,delete r.canvasOptions,!n)throw Error(`No available renderer for the current environment`);let i=new n;return await i.init(r),i}g();var Mx=class{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener(`resize`,this.queueResize),this._resizeTo=e,e&&(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),null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,t;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,t=globalThis.innerHeight;else{let{clientWidth:n,clientHeight:r}=this._resizeTo;e=n,t=r}this.renderer.resize(e,t),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}};Mx.extension=f.Application,g(),Yn(),er();var Nx=class{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Jn.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?$n.shared:new $n,e.autoStart&&this.start()}static destroy(){if(this._ticker){let e=this._ticker;this.ticker=null,e.destroy()}}};Nx.extension=f.Application,g(),h.add(Mx),h.add(Nx),g(),qn(),ld(),We();let Px=class e{constructor(...e){this.stage=new Kn,e[0]!==void 0&&P(N,`Application constructor options are deprecated, please use Application.init() instead.`)}async init(t){t={...t},this.stage||=new Kn,this.renderer=await jx(t),e._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return P(N,`Application.view is deprecated, please use Application.canvas instead.`),this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){return this.renderer.renderPipes.dom?._domElement}destroy(t=!1,n=!1){let r=e._plugins.slice(0);r.reverse(),r.forEach(e=>{e.destroy.call(this)}),this.stage.destroy(n),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Px._plugins=[];let Fx=Px;h.handleByList(f.Application,Fx._plugins),h.add(sd);let Ix={test(e){return typeof e==`string`&&e.startsWith(`info face=`)},parse(e){let t=e.match(/^[a-z]+\s+.+$/gm),n={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(let e in t){let r=t[e].match(/^[a-z]+/gm)[0],i=t[e].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),a={};for(let e in i){let t=i[e].split(`=`),n=t[0],r=t[1].replace(/"/gm,``),o=parseFloat(r);a[n]=isNaN(o)?r:o}n[r].push(a)}let r={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:``,distanceField:null,baseLineOffset:0},[i]=n.info,[a]=n.common,[o]=n.distanceField??[];o&&(r.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),r.fontSize=parseInt(i.size,10),r.fontFamily=i.face,r.lineHeight=parseInt(a.lineHeight,10);let s=n.page;for(let e=0;e<s.length;e++)r.pages.push({id:parseInt(s[e].id,10)||0,file:s[e].file});let c={};r.baseLineOffset=r.lineHeight-parseInt(a.base,10);let l=n.char;for(let e=0;e<l.length;e++){let t=l[e],n=parseInt(t.id,10),i=t.letter??t.char??String.fromCharCode(n);i===`space`&&(i=` `),c[n]=i,r.chars[i]={id:n,page:parseInt(t.page,10)||0,x:parseInt(t.x,10),y:parseInt(t.y,10),width:parseInt(t.width,10),height:parseInt(t.height,10),xOffset:parseInt(t.xoffset,10),yOffset:parseInt(t.yoffset,10),xAdvance:parseInt(t.xadvance,10),kerning:{}}}let u=n.kerning||[];for(let e=0;e<u.length;e++){let t=parseInt(u[e].first,10),n=parseInt(u[e].second,10),i=parseInt(u[e].amount,10);r.chars[c[n]]&&(r.chars[c[n]].kerning[c[t]]=i)}return r}},Lx={test(e){let t=e;return typeof t!=`string`&&`getElementsByTagName`in t&&t.getElementsByTagName(`page`).length&&t.getElementsByTagName(`info`)[0].getAttribute(`face`)!==null},parse(e){let t={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:``,distanceField:null,baseLineOffset:0},n=e.getElementsByTagName(`info`)[0],r=e.getElementsByTagName(`common`)[0],i=e.getElementsByTagName(`distanceField`)[0];i&&(t.distanceField={type:i.getAttribute(`fieldType`),range:parseInt(i.getAttribute(`distanceRange`),10)});let a=e.getElementsByTagName(`page`),o=e.getElementsByTagName(`char`),s=e.getElementsByTagName(`kerning`);t.fontSize=parseInt(n.getAttribute(`size`),10),t.fontFamily=n.getAttribute(`face`),t.lineHeight=parseInt(r.getAttribute(`lineHeight`),10);for(let e=0;e<a.length;e++)t.pages.push({id:parseInt(a[e].getAttribute(`id`),10)||0,file:a[e].getAttribute(`file`)});let c={};t.baseLineOffset=t.lineHeight-parseInt(r.getAttribute(`base`),10);for(let e=0;e<o.length;e++){let n=o[e],r=parseInt(n.getAttribute(`id`),10),i=n.getAttribute(`letter`)??n.getAttribute(`char`)??String.fromCharCode(r);i===`space`&&(i=` `),c[r]=i,t.chars[i]={id:r,page:parseInt(n.getAttribute(`page`),10)||0,x:parseInt(n.getAttribute(`x`),10),y:parseInt(n.getAttribute(`y`),10),width:parseInt(n.getAttribute(`width`),10),height:parseInt(n.getAttribute(`height`),10),xOffset:parseInt(n.getAttribute(`xoffset`),10),yOffset:parseInt(n.getAttribute(`yoffset`),10),xAdvance:parseInt(n.getAttribute(`xadvance`),10),kerning:{}}}for(let e=0;e<s.length;e++){let n=parseInt(s[e].getAttribute(`first`),10),r=parseInt(s[e].getAttribute(`second`),10),i=parseInt(s[e].getAttribute(`amount`),10);t.chars[c[r]]&&(t.chars[c[r]].kerning[c[n]]=i)}return t}};V();let Rx={test(e){return typeof e==`string`&&e.match(/<font(\s|>)/)?Lx.test(B.get().parseXML(e)):!1},parse(e){return Lx.parse(B.get().parseXML(e))}};var zx,Bx=s((()=>{b(),We(),zx=class extends y{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily=``,this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:`none`,range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return P(N,`BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead.`),this.fontFamily}get pageTextures(){return P(N,`BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.`),this.pages}get size(){return P(N,`BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead.`),this.fontMetrics.fontSize}get distanceFieldRange(){return P(N,`BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead.`),this.distanceField.range}get distanceFieldType(){return P(N,`BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead.`),this.distanceField.type}destroy(e=!1){this.emit(`destroy`,this),this.removeAllListeners();for(let e in this.chars)this.chars[e].texture?.destroy();this.chars=null,e&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}}}));
|
|
896
|
+
/**
|
|
897
|
+
* tiny-lru
|
|
898
|
+
*
|
|
899
|
+
* @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
|
|
900
|
+
* @license BSD-3-Clause
|
|
901
|
+
* @version 11.4.7
|
|
902
|
+
*/
|
|
903
|
+
function Vx(e=1e3,t=0,n=!1){if(isNaN(e)||e<0)throw TypeError(`Invalid max value`);if(isNaN(t)||t<0)throw TypeError(`Invalid ttl value`);if(typeof n!=`boolean`)throw TypeError(`Invalid resetTtl value`);return new Hx(e,t,n)}var Hx,Ux=s((()=>{Hx=class{constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){let t=this.items[e];delete this.items[e],this.size--,t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=[r,this.get(r)]}return t}evict(e=!1){if(e||this.size>0){let e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t=this.items[e];if(t!==void 0){if(this.ttl>0&&t.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(t),t.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){let e=Array(this.size),t=this.first,n=0;for(;t!==null;)e[n++]=t.key,t=t.next;return e}setWithEvicted(e,t,n=this.resetTtl){let r=null;if(this.has(e))this.set(e,t,!0,n);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(e,t,n=!1,r=this.resetTtl){let i=this.items[e];return n||i!==void 0?(i.value=t,n===!1&&r&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(i)):(this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},++this.size===1?this.first=i:this.last.next=i,this.last=i),this}values(e=this.keys()){let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=this.get(e[n]);return t}}}));function Wx(e){return!!e.tagStyles&&Object.keys(e.tagStyles).length>0}function Gx(e){return e.includes(`<`)}function Kx(e,t){return e.clone().assign(t)}function qx(e,t){let n=[],r=t.tagStyles;if(!Wx(t)||!Gx(e))return n.push({text:e,style:t}),n;let i=[t],a=[],o=``,s=0;for(;s<e.length;){let t=e[s];if(t===`<`){let c=e.indexOf(`>`,s);if(c===-1){o+=t,s++;continue}let l=e.indexOf(`<`,s+1);if(l!==-1&&l<c){o+=t,s++;continue}let u=e.slice(s+1,c);if(u.startsWith(`/`)){let t=u.slice(1).trim();if(a.length>0&&a[a.length-1]===t){o.length>0&&(n.push({text:o,style:i[i.length-1]}),o=``),i.pop(),a.pop(),s=c+1;continue}else{o+=e.slice(s,c+1),s=c+1;continue}}else{let t=u.trim();if(r[t]){o.length>0&&(n.push({text:o,style:i[i.length-1]}),o=``);let e=i[i.length-1],l=Kx(e,r[t]);i.push(l),a.push(t),s=c+1;continue}else{o+=e.slice(s,c+1),s=c+1;continue}}}else o+=t,s++}return o.length>0&&n.push({text:o,style:i[i.length-1]}),n}var Jx=s((()=>{}));function Yx(e){return typeof e==`string`&&aS.has(e.charCodeAt(0))}function Xx(e,t){return typeof e==`string`&&sS.has(e.charCodeAt(0))}function Zx(e){return typeof e==`string`&&lS.has(e.charCodeAt(0))}function Qx(e){return typeof e==`string`&&dS.has(e.charCodeAt(0))}function $x(e){return e===`normal`||e===`pre-line`}function eS(e){return e===`normal`}function tS(e){if(typeof e!=`string`)return``;let t=e.length-1;for(;t>=0&&Xx(e[t]);)t--;return t<e.length-1?e.slice(0,t+1):e}function nS(e){let t=[],n=[];if(typeof e!=`string`)return t;for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(Xx(i,a)||Yx(i)){n.length>0&&(t.push(n.join(``)),n.length=0),i===`\r`&&a===`
|
|
904
|
+
`?(t.push(`\r
|
|
905
|
+
`),r++):t.push(i);continue}n.push(i),Qx(i)&&a&&!Xx(a)&&!Yx(a)&&(t.push(n.join(``)),n.length=0)}return n.length>0&&t.push(n.join(``)),t}function rS(e,t,n,r){let i=n(e),a=[];for(let n=0;n<i.length;n++){let o=i[n],s=o,c=1;for(;i[n+c];){let a=i[n+c];if(!r(s,a,e,n,t))o+=a,s=a,c++;else break}n+=c-1,a.push(o)}return a}var iS,aS,oS,sS,cS,lS,uS,dS,fS,pS,mS=s((()=>{iS=[10,13],aS=new Set(iS),oS=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],sS=new Set(oS),cS=[9,32],lS=new Set(cS),uS=[45,8208,8211,8212,173],dS=new Set(uS),fS=/(\r\n|\r|\n)/,pS=/(?:\r\n|\r|\n)/}));function hS(e,t,n,r,i,a,o,s,c){let l=qx(e,t);if(eS(t.whiteSpace))for(let e=0;e<l.length;e++){let t=l[e];l[e]={text:t.text.replace(vS,` `),style:t.style}}let u=[],d=[];for(let e of l){let t=e.text.split(fS);for(let n=0;n<t.length;n++){let r=t[n];r===`\r
|
|
906
|
+
`||r===`\r`||r===`
|
|
907
|
+
`?(u.push(d),d=[]):r.length>0&&d.push({text:r,style:e.style})}}(d.length>0||u.length===0)&&u.push(d);let f=n?gS(u,t,r,a,s,c):u,p=[],m=[],h=[],g=[],_=[],v=0,y=t._fontString,b=o(y);b.fontSize===0&&(b.fontSize=t.fontSize,b.ascent=t.fontSize);let x=``,S=!!t.dropShadow,C=t._stroke?.width||0;for(let e of f){let n=0,a=b.ascent,s=b.descent,c=``;for(let t of e){let e=t.style._fontString,l=o(e);e!==x&&(r.font=e,x=e);let u=i(t.text,t.style.letterSpacing,r);n+=u,a=Math.max(a,l.ascent),s=Math.max(s,l.descent),c+=t.text;let d=t.style._stroke?.width||0;d>C&&(C=d),!S&&t.style.dropShadow&&(S=!0)}e.length===0&&(a=b.ascent,s=b.descent),p.push(n),m.push(a),h.push(s),_.push(c);let l=t.lineHeight||a+s;g.push(l+t.leading),v=Math.max(v,n)}let w=C,ee=v+w+(t.dropShadow?t.dropShadow.distance:0),T=0;for(let e=0;e<g.length;e++)T+=g[e];return T=Math.max(T,g[0]+w),{width:ee,height:T+(t.dropShadow?t.dropShadow.distance:0),lines:_,lineWidths:p,lineHeight:(t.lineHeight||b.fontSize)+t.leading,maxLineWidth:v,fontProperties:b,runsByLine:f,lineAscents:m,lineDescents:h,lineHeights:g,hasDropShadow:S}}function gS(e,t,n,r,i,a){let{letterSpacing:o,whiteSpace:s,wordWrapWidth:c,breakWords:l}=t,u=$x(s),d=c+o,f={},p=``,m=(e,t)=>{let i=`${e}|${t.styleKey}`,a=f[i];if(a===void 0){let o=t._fontString;o!==p&&(n.font=o,p=o),a=r(e,t.letterSpacing,n)+t.letterSpacing,f[i]=a}return a},h=[];for(let t of e){let e=_S(t),n=h.length,r=t=>{let n=0,r=t;do{let{token:t,style:i}=e[r];n+=m(t,i),r++}while(r<e.length&&e[r].continuesFromPrevious);return n},o=t=>{let n=[],r=t;do n.push({token:e[r].token,style:e[r].style}),r++;while(r<e.length&&e[r].continuesFromPrevious);return n},s=[],c=0,f=!u,p=null,g=()=>{p&&p.text.length>0&&s.push(p),p=null},_=()=>{if(g(),s.length>0){let e=s[s.length-1];e.text=tS(e.text),e.text.length===0&&s.pop()}h.push(s),s=[],c=0,f=!1};for(let t=0;t<e.length;t++){let{token:n,style:v,continuesFromPrevious:y}=e[t],b=m(n,v);if(u){let e=Xx(n),t=p?.text[p.text.length-1]??s[s.length-1]?.text.slice(-1)??``,r=t?Xx(t):!1;if(e&&r)continue}let x=!y,S=x?r(t):b;if(S>d&&x)if(c>0&&_(),l){let e=o(t);for(let t=0;t<e.length;t++){let n=e[t].token,r=e[t].style,o=rS(n,l,a,i);for(let e of o){let t=m(e,r);t+c>d&&_(),!p||p.style!==r?(g(),p={text:e,style:r}):p.text+=e,c+=t}}t+=e.length-1}else{let e=o(t);g(),h.push(e.map(e=>({text:e.token,style:e.style}))),f=!1,t+=e.length-1}else if(S+c>d&&x){if(Xx(n)){f=!1;continue}_(),p={text:n,style:v},c=b}else if(y&&!l)!p||p.style!==v?(g(),p={text:n,style:v}):p.text+=n,c+=b;else{let e=Xx(n);if(c===0&&e&&!f)continue;!p||p.style!==v?(g(),p={text:n,style:v}):p.text+=n,c+=b}}if(g(),s.length>0){let e=s[s.length-1];e.text=tS(e.text),e.text.length===0&&s.pop()}(s.length>0||h.length===n)&&h.push(s)}return h}function _S(e){let t=[],n=!1;for(let r of e){let e=nS(r.text),i=!0;for(let a of e){let e=Xx(a)||Yx(a),o=i&&n&&!e;t.push({token:a,style:r.style,continuesFromPrevious:o}),n=!e,i=!1}}return t}var vS,yS=s((()=>{Jx(),mS(),vS=/\r\n|\r|\n/g}));function bS(e,t,n,r,i){let a=n[e];return typeof a!=`number`&&(a=i(e,t,r)+t,n[e]=a),a}function xS(e,t,n,r,i,a,o){let s=n.getContext(`2d`,SS);s.font=t._fontString;let c=0,l=``,u=[],d=Object.create(null),{letterSpacing:f,whiteSpace:p}=t,m=$x(p),h=eS(p),g=!m,_=t.wordWrapWidth+f,v=nS(e);for(let e=0;e<v.length;e++){let n=v[e];if(Yx(n)){if(!h){u.push(tS(l)),g=!m,l=``,c=0;continue}n=` `}if(m){let e=Xx(n),t=Xx(l[l.length-1]);if(e&&t)continue}let p=bS(n,f,d,s,r);if(p>_)if(l!==``&&(u.push(tS(l)),l=``,c=0),i(n,t.breakWords)){let e=rS(n,t.breakWords,o,a);for(let t of e){let e=bS(t,f,d,s,r);e+c>_&&(u.push(tS(l)),g=!1,l=``,c=0),l+=t,c+=e}}else l.length>0&&(u.push(tS(l)),l=``,c=0),u.push(tS(n)),g=!1,l=``,c=0;else p+c>_&&(g=!1,u.push(tS(l)),l=``,c=0),(l.length>0||!Xx(n)||g)&&(l+=n,c+=p)}let y=tS(l);return y.length>0&&u.push(y),u.join(`
|
|
908
|
+
`)}var SS,CS=s((()=>{mS(),SS={willReadFrequently:!0}})),wS,TS,ES,DS=s((()=>{Ux(),V(),yS(),Jx(),mS(),CS(),wS={willReadFrequently:!0},TS=class e{static get experimentalLetterSpacingSupported(){let t=e._experimentalLetterSpacingSupported;if(t===void 0){let n=B.get().getCanvasRenderingContext2D().prototype;t=e._experimentalLetterSpacingSupported=`letterSpacing`in n||`textLetterSpacing`in n}return t}constructor(e,t,n,r,i,a,o,s,c,l){this.text=e,this.style=t,this.width=n,this.height=r,this.lines=i,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=s,this.fontProperties=c,l&&(this.runsByLine=l.runsByLine,this.lineAscents=l.lineAscents,this.lineDescents=l.lineDescents,this.lineHeights=l.lineHeights,this.hasDropShadow=l.hasDropShadow)}static measureText(t=` `,n,r=e._canvas,i=n.wordWrap){let a=`${t}-${n.styleKey}-wordWrap-${i}`;if(e._measurementCache.has(a))return e._measurementCache.get(a);if(Wx(n)&&Gx(t)){let r=hS(t,n,i,e._context,e._measureText,e._measureTextAdvance,e.measureFont,e.canBreakChars,e.wordWrapSplit),o=new e(t,n,r.width,r.height,r.lines,r.lineWidths,r.lineHeight,r.maxLineWidth,r.fontProperties,{runsByLine:r.runsByLine,lineAscents:r.lineAscents,lineDescents:r.lineDescents,lineHeights:r.lineHeights,hasDropShadow:r.hasDropShadow});return e._measurementCache.set(a,o),o}let o=n._fontString,s=e.measureFont(o);s.fontSize===0&&(s.fontSize=n.fontSize,s.ascent=n.fontSize,s.descent=0);let c=e._context;c.font=o;let l=(i?e._wordWrap(t,n,r):t).split(pS),u=Array(l.length),d=0;for(let t=0;t<l.length;t++){let r=e._measureText(l[t],n.letterSpacing,c);u[t]=r,d=Math.max(d,r)}let f=n._stroke?.width??0,p=n.lineHeight||s.fontSize,m=e._adjustWidthForStyle(d,n),h=Math.max(p,s.fontSize+f)+(l.length-1)*(p+n.leading),g=e._adjustHeightForStyle(h,n),_=new e(t,n,m,g,l,u,p+n.leading,d,s);return e._measurementCache.set(a,_),_}static _adjustWidthForStyle(e,t){let n=e+(t._stroke?.width||0);return t.dropShadow&&(n+=t.dropShadow.distance),n}static _adjustHeightForStyle(e,t){let n=e;return t.dropShadow&&(n+=t.dropShadow.distance),n}static _measureText(t,n,r){let{metricWidth:i,metrics:a,letterSpacingVal:o}=e._measureTextCore(t,n,r),s=-(a.actualBoundingBoxLeft??0),c=(a.actualBoundingBoxRight??0)-s;return a.width>0&&(c+=o),Math.max(i,c)}static _measureTextAdvance(t,n,r){return e._measureTextCore(t,n,r).metricWidth}static _measureTextCore(t,n,r){let i=!1;e.experimentalLetterSpacingSupported&&(e.experimentalLetterSpacing?(r.letterSpacing=`${n}px`,r.textLetterSpacing=`${n}px`,i=!0):(r.letterSpacing=`0px`,r.textLetterSpacing=`0px`));let a=r.measureText(t),o=a.width,s=0;return o>0&&(s=i?-n:(e.graphemeSegmenter(t).length-1)*n,o+=s),{metricWidth:o,metrics:a,letterSpacingVal:s}}static _wordWrap(t,n,r=e._canvas){return xS(t,n,r,e._measureTextAdvance,e.canBreakWords,e.canBreakChars,e.wordWrapSplit)}static isBreakingSpace(e,t){return Xx(e,t)}static canBreakWords(e,t){return t}static canBreakChars(e,t,n,r,i){return!0}static wordWrapSplit(t){return e.graphemeSegmenter(t)}static measureFont(t){if(e._fonts[t])return e._fonts[t];let n=e._context;n.font=t;let r=n.measureText(e.METRICS_STRING+e.BASELINE_SYMBOL),i=r.actualBoundingBoxAscent??0,a=r.actualBoundingBoxDescent??0,o={ascent:i,descent:a,fontSize:i+a};return e._fonts[t]=o,o}static clearMetrics(t=``){t?delete e._fonts[t]:e._fonts={}}static get _canvas(){if(!e.__canvas){let t;try{let n=new OffscreenCanvas(0,0);if(n.getContext(`2d`,wS)?.measureText)return e.__canvas=n,n;t=B.get().createCanvas()}catch{t=B.get().createCanvas()}t.width=t.height=10,e.__canvas=t}return e.__canvas}static get _context(){return e.__context||=e._canvas.getContext(`2d`,wS),e.__context}},TS.METRICS_STRING=`|ÉqÅ`,TS.BASELINE_SYMBOL=`M`,TS.BASELINE_MULTIPLIER=1.4,TS.HEIGHT_MULTIPLIER=2,TS.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter==`function`){let e=new Intl.Segmenter;return t=>{let n=e.segment(t),r=[],i=0;for(let e of n)r[i++]=e.segment;return r}}return e=>[...e]})(),TS.experimentalLetterSpacing=!1,TS._fonts={},TS._measurementCache=Vx(1e3),ES=TS}));function OS(e){let t=typeof e.fontSize==`number`?`${e.fontSize}px`:e.fontSize,n=e.fontFamily;Array.isArray(e.fontFamily)||(n=e.fontFamily.split(`,`));for(let e=n.length-1;e>=0;e--){let t=n[e].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!kS.includes(t)&&(t=`"${t}"`),n[e]=t}return`${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(`,`)}`}var kS,AS=s((()=>{kS=[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`]}));function jS(e){let t=e;if(typeof t.dropShadow==`boolean`&&t.dropShadow){let n=NS.defaultDropShadow;e.dropShadow={alpha:t.dropShadowAlpha??n.alpha,angle:t.dropShadowAngle??n.angle,blur:t.dropShadowBlur??n.blur,color:t.dropShadowColor??n.color,distance:t.dropShadowDistance??n.distance}}if(t.strokeThickness!==void 0){P(N,`strokeThickness is now a part of stroke`);let n=t.stroke,r={};if(A.isColorLike(n))r.color=n;else if(n instanceof iv||n instanceof cv)r.fill=n;else if(Object.hasOwnProperty.call(n,`color`)||Object.hasOwnProperty.call(n,`fill`))r=n;else throw Error(`Invalid stroke value.`);e.stroke={...r,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(P(N,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw Error(`Invalid fill value. Expected an array of colors for gradient fill.`);t.fill.length!==t.fillGradientStops.length&&F(`The number of fill colors must match the number of fill gradient stops.`);let n=new iv({start:{x:0,y:0},end:{x:0,y:1},textureSpace:`local`}),r=t.fillGradientStops.slice(),i=t.fill.map(e=>A.shared.setValue(e).toNumber());r.forEach((e,t)=>{n.addColorStop(e,i[t])}),e.fill={fill:n}}}var MS,NS,PS=s((()=>{b(),we(),Be(),We(),I(),av(),lv(),Hb(),Fb(),AS(),MS=class e extends y{constructor(t={}){super(),this.uid=Re(`textStyle`),this._tick=0,this._cachedFontString=null,jS(t),t instanceof e&&(t=t._toObject());let n={...e.defaultTextStyle,...t};for(let e in n){let t=e;this[t]=n[e]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(typeof t==`object`&&t?this._dropShadow=this._createProxy({...e.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...e.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e==`string`?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Vb.defaultFillStyle,...e},()=>{this._fill=Nb({...this._originalFill},Vb.defaultFillStyle)})),this._fill=Nb(e===0?`black`:e,Vb.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Vb.defaultStrokeStyle,...e},()=>{this._stroke=Pb({...this._originalStroke},Vb.defaultStrokeStyle)})),this._stroke=Pb(e,Vb.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit(`update`,this)}reset(){let t=e.defaultTextStyle;for(let e in t)this[e]=t[e]}assign(e){for(let t in e){let n=t;this[n]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=OS(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new e(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){if(this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(t),this._originalFill?.texture&&this._originalFill.texture.destroy(t),this._stroke?.texture&&this._stroke.texture.destroy(t),this._originalStroke?.texture&&this._originalStroke.texture.destroy(t)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(e,n,r)=>e[n]===r?!0:(e[n]=r,t?.(n,r),this.update(),!0)})}_isFillStyle(e){return(e??null)!==null&&!(A.isColorLike(e)||e instanceof iv||e instanceof cv)}},MS.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:`black`,distance:5},MS.defaultTextStyle={align:`left`,breakWords:!1,dropShadow:null,fill:`black`,fontFamily:`Arial`,fontSize:26,fontStyle:`normal`,fontVariant:`normal`,fontWeight:`normal`,leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:`alphabetic`,trim:!1,whiteSpace:`pre`,wordWrap:!1,wordWrapWidth:100},NS=MS}));function FS(e,t,n,r=0,i=0,a=0){if(e.texture===R.WHITE&&!e.fill)return A.shared.setValue(e.color).setAlpha(e.alpha??1).toHexa();if(!e.fill){let n=t.createPattern(e.texture.source.resource,`repeat`),r=e.matrix.copyTo(j.shared);return r.scale(e.texture.source.pixelWidth,e.texture.source.pixelHeight),n.setTransform(r),n}else if(e.fill instanceof cv){let n=e.fill,r=t.createPattern(n.texture.source.resource,`repeat`);return U.applyPatternTransform(r,n.transform,!1),r}else if(e.fill instanceof iv){let o=e.fill,s=o.type===`linear`,c=o.textureSpace===`local`,l=1,u=1;c&&n&&(l=n.width+r,u=n.height+r);let d,f=!1;if(s){let{start:e,end:n}=o;d=t.createLinearGradient(e.x*l+i,e.y*u+a,n.x*l+i,n.y*u+a),f=Math.abs(n.x-e.x)<Math.abs((n.y-e.y)*.1)}else{let{center:e,innerRadius:n,outerCenter:r,outerRadius:s}=o;d=t.createRadialGradient(e.x*l+i,e.y*u+a,n*l,r.x*l+i,r.y*u+a,s*l)}if(f&&c&&n){let e=n.lineHeight/u;for(let t=0;t<n.lines.length;t++){let i=(t*n.lineHeight+r/2)/u;o.colorStops.forEach(t=>{let n=i+t.offset*e;n=Math.max(0,Math.min(1,n)),d.addColorStop(Math.floor(n*IS)/IS,A.shared.setValue(t.color).toHex())})}}else o.colorStops.forEach(e=>{d.addColorStop(e.offset,A.shared.setValue(e.color).toHex())});return d}return F(`FillStyle not recognised`,e),`red`}var IS,LS=s((()=>{we(),M(),ja(),z(),I(),av(),lv(),IS=1e5})),RS,zS,BS=s((()=>{we(),yt(),Pa(),fa(),z(),mn(),We(),DS(),AS(),LS(),PS(),Bx(),RS=class e extends zx{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;let n={...e.defaultOptions,...t};this._textureSize=n.textureSize,this._mipmap=n.mipmap;let r=n.style.clone();n.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=R.WHITE,r._fill.fill=null),this.applyFillAsTint=n.overrideFill;let i=r.fontSize;r.fontSize=this.baseMeasurementFontSize;let a=OS(r);n.overrideSize?(r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/i),r.dropShadow&&(r.dropShadow.blur*=this.baseRenderedFontSize/i,r.dropShadow.distance*=this.baseRenderedFontSize/i)):r.fontSize=this.baseRenderedFontSize=i,this._style=r,this._skipKerning=n.skipKerning??!1,this.resolution=n.resolution??1,this._padding=n.padding??4,n.textureStyle&&(this._textureStyle=n.textureStyle instanceof pn?n.textureStyle:new pn(n.textureStyle)),this.fontMetrics=ES.measureFont(a),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(e){let t=ES.graphemeSegmenter(e).filter(e=>!this._currentChars.includes(e)).filter((e,t,n)=>n.indexOf(e)===t);if(!t.length)return;this._currentChars=[...this._currentChars,...t];let n;n=this._currentPageIndex===-1?this._nextPage():this.pages[this._currentPageIndex];let{canvas:r,context:i}=n.canvasAndContext,a=n.texture.source,o=this._style,s=this._currentX,c=this._currentY,l=this._currentMaxCharHeight,u=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=(o.dropShadow?.distance??0)+(o._stroke?.width??0),f=this._padding+d,p=!1,m=r.width/this.resolution,h=r.height/this.resolution;for(let e=0;e<t.length;e++){let n=t[e],d=ES.measureText(n,o,r,!1);d.lineHeight=d.height;let g=d.width*u,_=Math.ceil((o.fontStyle===`italic`?2:1)*g),v=d.height*u,y=_+f*2,b=v+f*2;if(p=!1,n!==`
|
|
909
|
+
`&&n!==`\r`&&n!==` `&&n!==` `&&(p=!0,l=Math.ceil(Math.max(b,l))),s+y>m&&(c+=l,l=b,s=0,c+l>h)){a.update();let e=this._nextPage();r=e.canvasAndContext.canvas,i=e.canvasAndContext.context,a=e.texture.source,s=0,c=0,l=0}let x=i.measureText(n).width/u;if(this.chars[n]={id:n.codePointAt(0),xOffset:-(f/u),yOffset:-(f/u),xAdvance:x,kerning:{}},p){this._drawGlyph(i,d,s+f,c+f,u,o);let e=a.width*u,t=a.height*u,r=new vt(s/e*a.width,c/t*a.height,y/e*a.width,b/t*a.height);this.chars[n].texture=new R({source:a,frame:r}),s+=Math.ceil(y)}}a.update(),this._currentX=s,this._currentY=c,this._currentMaxCharHeight=l,this._skipKerning||this._applyKerning(t,i,u)}get pageTextures(){return P(N,`BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.`),this.pages}_applyKerning(e,t,n){let r=this._measureCache;for(let i=0;i<e.length;i++){let a=e[i];for(let e=0;e<this._currentChars.length;e++){let i=this._currentChars[e],o=r[a];o||=r[a]=t.measureText(a).width;let s=r[i];s||=r[i]=t.measureText(i).width;let c=t.measureText(a+i).width,l=c-(o+s);l&&this.chars[a]&&(this.chars[a].kerning[i]=l/n),c=t.measureText(a+i).width,l=c-(o+s),l&&this.chars[i]&&(this.chars[i].kerning[a]=l/n)}}}_nextPage(){this._currentPageIndex++;let e=this.resolution,t=Na.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(t.context,this._style,e);let n=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r=new R({source:new da({resource:t.canvas,resolution:n,alphaMode:`premultiply-alpha-on-upload`,autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(r.source.style=this._textureStyle);let i={canvasAndContext:t,texture:r};return this.pages[this._currentPageIndex]=i,i}_setupContext(e,t,n){t.fontSize=this.baseRenderedFontSize,e.scale(n,n),e.font=OS(t),t.fontSize=this.baseMeasurementFontSize,e.textBaseline=t.textBaseline;let r=t._stroke,i=r?.width??0;if(r&&(e.lineWidth=i,e.lineJoin=r.join,e.miterLimit=r.miterLimit,e.strokeStyle=FS(r,e)),t._fill&&(e.fillStyle=FS(t._fill,e)),t.dropShadow){let r=t.dropShadow,i=A.shared.setValue(r.color).toArray(),a=r.blur*n,o=r.distance*n;e.shadowColor=`rgba(${i[0]*255},${i[1]*255},${i[2]*255},${r.alpha})`,e.shadowBlur=a,e.shadowOffsetX=Math.cos(r.angle)*o,e.shadowOffsetY=Math.sin(r.angle)*o}else e.shadowColor=`black`,e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,t,n,r,i,a){let o=t.text,s=t.fontProperties,c=(a._stroke?.width??0)*i,l=n+c/2,u=r-c/2,d=s.descent*i,f=t.lineHeight*i,p=!1;a.stroke&&c&&(p=!0,e.strokeText(o,l,u+f-d));let{shadowBlur:m,shadowOffsetX:h,shadowOffsetY:g}=e;a._fill&&(p&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.fillText(o,l,u+f-d)),p&&(e.shadowBlur=m,e.shadowOffsetX=h,e.shadowOffsetY=g)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{canvasAndContext:t,texture:n}=this.pages[e];Na.returnCanvasAndContext(t),n.destroy(!0)}this.pages=null}},RS.defaultOptions={textureSize:512,style:new NS,mipmap:!0},zS=RS}));function VS(e,t,n,r){let i={width:0,height:0,offsetY:0,scale:t.fontSize/n.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};i.offsetY=n.baseLineOffset;let a=i.lines[0],o=null,s=!0,c={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},l=n.baseMeasurementFontSize/t.fontSize,u=t.letterSpacing*l,d=t.wordWrapWidth*l,f=t.lineHeight?t.lineHeight*l:n.lineHeight,p=t.wordWrap&&t.breakWords,m=$x(t.whiteSpace),h=eS(t.whiteSpace);if(m||h){let t=[],n=m;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\r`||i===`
|
|
910
|
+
`)if(h)i===`\r`&&e[r+1]===`
|
|
911
|
+
`&&r++,i=` `;else{m&&(n=!0),t.push(i);continue}if(Xx(i))if(m&&Zx(i)){if(n)continue;n=!0,t.push(` `)}else n=!1,t.push(i);else n=!1,t.push(i)}e=t}let g=e=>{let t=a.width;for(let n=0;n<c.index;n++){let r=e.positions[n];a.chars.push(e.chars[n]),a.charPositions.push(r+t)}a.width+=e.width,(c.index>0||!m)&&(s=!1),c.width=0,c.index=0,c.chars.length=0},_=()=>{let e=a.chars.length-1;if(r){let t=a.chars[e];for(;Zx(t);)a.width-=n.chars[t].xAdvance,a.spacesIndex.pop(),t=a.chars[--e]}i.width=Math.max(i.width,a.width),a={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},s=!0,i.lines.push(a),i.height+=f},v=e=>e-u>d;for(let r=0;r<e.length+1;r++){let i,l=r===e.length;l||(i=e[r]);let d=n.chars[i];if(/(?:\s)/.test(i)||i===`\r`||i===`
|
|
912
|
+
`||l){if(!s&&t.wordWrap&&v(a.width+c.width)?(_(),g(c),!l&&d&&a.charPositions.push(0)):(c.start=a.width,g(c),!l&&d&&a.charPositions.push(0)),i===`\r`||i===`
|
|
913
|
+
`)_();else if(!l&&d){let e=d.xAdvance+(d.kerning?.[o]||0)+u;a.width+=e,a.spaceWidth=e,a.spacesIndex.push(a.charPositions.length),a.chars.push(i)}}else if(d){let e=d.kerning?.[o]||0,n=d.xAdvance+e+u;p&&v(c.width+n)&&(s||_(),g(c),_()),c.positions[c.index++]=c.width+e,c.chars.push(i),c.width+=n,Qx(i)&&(!s&&t.wordWrap&&v(a.width+c.width)&&_(),g(c))}o=i}return _(),t.align===`center`?HS(i):t.align===`right`?US(i):t.align===`justify`&&WS(i),i}function HS(e){for(let t=0;t<e.lines.length;t++){let n=e.lines[t],r=e.width/2-n.width/2;for(let e=0;e<n.charPositions.length;e++)n.charPositions[e]+=r}}function US(e){for(let t=0;t<e.lines.length;t++){let n=e.lines[t],r=e.width-n.width;for(let e=0;e<n.charPositions.length;e++)n.charPositions[e]+=r}}function WS(e){let t=e.width;for(let n=0;n<e.lines.length-2;n++){let r=e.lines[n],i=0,a=r.spacesIndex[i++],o=0,s=r.spacesIndex.length,c=(t-r.width)/s;for(let e=0;e<r.charPositions.length;e++)e===a&&(a=r.spacesIndex[i++],o+=c),r.charPositions[e]+=o}}var GS=s((()=>{mS()}));function KS(e){if(e===``)return[];typeof e==`string`&&(e=[e]);let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(Array.isArray(r)){if(r.length!==2)throw Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw Error(`[BitmapFont]: Invalid character delimiter.`);let e=r[0].charCodeAt(0),n=r[1].charCodeAt(0);if(n<e)throw Error(`[BitmapFont]: Invalid character range.`);for(let r=e,i=n;r<=i;r++)t.push(String.fromCharCode(r))}else t.push(...Array.from(r))}if(t.length===0)throw Error(`[BitmapFont]: Empty set when resolving characters.`);return t}var qS=s((()=>{})),JS,YS,XS,ZS=s((()=>{Ux(),ba(),We(),I(),DS(),PS(),BS(),GS(),qS(),JS=0,YS=class{constructor(){this.ALPHA=[[`a`,`z`],[`A`,`Z`],` `],this.NUMERIC=[[`0`,`9`]],this.ALPHANUMERIC=[[`a`,`z`],[`A`,`Z`],[`0`,`9`],` `],this.ASCII=[[` `,`~`]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1,textureStyle:null},this.measureCache=Vx(1e3)}getFont(e,t){let n=`${t.fontFamily}-bitmap`,r=!0;if(H.has(n)){let t=H.get(n);return t.ensureCharacters?.(e),t}if(t._fill.fill&&!t._stroke?(n+=t._fill.fill.styleKey,r=!1):(t._stroke||t.dropShadow)&&(n=`${t.styleKey}-bitmap`,r=!1),n+=`-${t.fontStyle}`,n+=`-${t.fontVariant}`,n+=`-${t.fontWeight}`,!H.has(n)){let e=Object.create(t);e._lineHeight=0;let i=new zS({style:e,overrideFill:r,overrideSize:!0,...this.defaultOptions});JS++,JS>50&&F(`BitmapText`,`You have dynamically created ${JS} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),i.once(`destroy`,()=>{JS--,H.remove(n)}),H.set(n,i)}let i=H.get(n);return i.ensureCharacters?.(e),i}getLayout(e,t,n=!0){let r=this.getFont(e,t),i=`${e}-${t.styleKey}-${n}`;if(this.measureCache.has(i))return this.measureCache.get(i);let a=VS(ES.graphemeSegmenter(e),t,r,n);return this.measureCache.set(i,a),a}measureText(e,t,n=!0){return this.getLayout(e,t,n)}install(...e){let t=e[0];typeof t==`string`&&(t={name:t,style:e[1],chars:e[2]?.chars,resolution:e[2]?.resolution,padding:e[2]?.padding,skipKerning:e[2]?.skipKerning},P(N,`BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})`));let n=t?.name;if(!n)throw Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};let r=t.style,i=r instanceof NS?r:new NS(r),a=new zS({style:i,overrideFill:t.dynamicFill??this._canUseTintForStyle(i),skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1,textureStyle:t.textureStyle}),o=KS(t.chars);return a.ensureCharacters(o.join(``)),H.set(`${n}-bitmap`,a),a.once(`destroy`,()=>H.remove(`${n}-bitmap`)),a}uninstall(e){let t=`${e}-bitmap`,n=H.get(t);n&&n.destroy()}_canUseTintForStyle(e){return!e._stroke&&(!e.dropShadow||e.dropShadow.color===0)&&!e._fill.fill&&e._fill.color===16777215}},XS=new YS})),QS=l({BitmapFont:()=>$S}),$S,eC=s((()=>{En(),yt(),z(),Bx(),ZS(),$S=class extends zx{constructor(e,t){super();let{textures:n,data:r}=e;Object.keys(r.pages).forEach(e=>{let t=r.pages[parseInt(e,10)],i=n[t.id];this.pages.push({texture:i})}),Object.keys(r.chars).forEach(e=>{let t=r.chars[e],{frame:i,source:a,rotate:o}=n[t.page],s=new R({frame:L.transformRectCoords(t,i,o,new vt),orig:new vt(0,0,t.width,t.height),source:a,rotate:o});this.chars[e]={id:e.codePointAt(0),xOffset:t.xOffset,yOffset:t.yOffset,xAdvance:t.xAdvance,kerning:t.kerning??{},texture:s}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:`none`,range:0},this.url=t}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{texture:t}=this.pages[e];t.destroy(!0)}this.pages=null}static install(e){XS.install(e)}static uninstall(e){XS.uninstall(e)}}}));gi(),Ri(),V(),g(),Ei();let tC=[`.xml`,`.fnt`],nC={extension:{type:f.CacheParser,name:`cacheBitmapFont`},test:e=>!!e?.pages&&!!e?.chars&&typeof e?.fontFamily==`string`&&e.fontFamily!==``,getCacheableAssets(e,t){let n={};return e.forEach(e=>{n[e]=t,n[`${e}-bitmap`]=t}),n[`${t.fontFamily}-bitmap`]=t,n}},rC={extension:{type:f.LoadParser,priority:hi.Normal},name:`loadBitmapFont`,id:`bitmap-font`,test(e){return tC.includes(Ti.extname(e).toLowerCase())},async testParse(e){return Ix.test(e)||Rx.test(e)},async parse(e,t,n){let r=Ix.test(e)?Ix.parse(e):Rx.parse(e),{src:i}=t,{pages:a}=r,o=[],s=r.distanceField?{scaleMode:`linear`,alphaMode:`premultiply-alpha-on-upload`,autoGenerateMipmaps:!1,resolution:1}:{};for(let e=0;e<a.length;++e){let t=a[e].file,n=Ti.join(Ti.dirname(i),t);n=Li(n,i),o.push({src:n,data:s})}let[c,{BitmapFont:l}]=await Promise.all([n.load(o),Promise.resolve().then(()=>(eC(),QS))]);return new l({data:r,textures:o.map(e=>c[e.src])},i)},async load(e,t){return await(await B.get().fetch(e)).text()},async unload(e,t,n){await Promise.all(e.pages.map(e=>n.unload(e.texture.source._sourceOrigin))),e.destroy()}};var iC=class{constructor(e,t=!1){this._loader=e,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=t}add(e){e.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log(`[BackgroundLoader] assets: `,this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;let e=[],t=Math.min(this._assetList.length,this._maxConcurrent);for(let n=0;n<t;n++)e.push(this._assetList.pop());await this._loader.load(e),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(e){this._isActive!==e&&(this._isActive=e,e&&!this._isLoading&&this._next())}};g(),z();let aC={extension:{type:f.CacheParser,name:`cacheTextureArray`},test:e=>Array.isArray(e)&&e.every(e=>e instanceof R),getCacheableAssets:(e,t)=>{let n={};return e.forEach(e=>{t.forEach((t,r)=>{n[e+(r===0?``:r+1)]=t})}),n}};async function oC(e){if(`Image`in globalThis)return new Promise(t=>{let n=new Image;n.onload=()=>{t(!0)},n.onerror=()=>{t(!1)},n.src=e});if(`createImageBitmap`in globalThis&&`fetch`in globalThis){try{let t=await(await fetch(e)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}g();let sC={extension:{type:f.DetectionParser,priority:1},test:async()=>oC(`data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=`),add:async e=>[...e,`avif`],remove:async e=>e.filter(e=>e!==`avif`)};g();let cC=[`png`,`jpg`,`jpeg`],lC={extension:{type:f.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async e=>[...e,...cC],remove:async e=>e.filter(e=>!cC.includes(e))},uC=`WorkerGlobalScope`in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function dC(e){return!uC&&document.createElement(`video`).canPlayType(e)!==``}g();let fC={extension:{type:f.DetectionParser,priority:0},test:async()=>dC(`video/mp4`),add:async e=>[...e,`mp4`,`m4v`],remove:async e=>e.filter(e=>e!==`mp4`&&e!==`m4v`)};g();let pC={extension:{type:f.DetectionParser,priority:0},test:async()=>dC(`video/ogg`),add:async e=>[...e,`ogv`],remove:async e=>e.filter(e=>e!==`ogv`)};g();let mC={extension:{type:f.DetectionParser,priority:0},test:async()=>dC(`video/webm`),add:async e=>[...e,`webm`],remove:async e=>e.filter(e=>e!==`webm`)};g();let hC={extension:{type:f.DetectionParser,priority:0},test:async()=>oC(`data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=`),add:async e=>[...e,`webp`],remove:async e=>e.filter(e=>e!==`webp`)};I(),Ei(),Oi(),Ni();let gC=class e{constructor(){this.loadOptions={...e.defaultOptions},this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(e,t,n)=>(this._parsersValidated=!1,e[t]=n,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(e,t){let n={promise:null,parser:null};return n.promise=(async()=>{let r=null,i=null;if((t.parser||t.loadParser)&&(i=this._parserHash[t.parser||t.loadParser],t.loadParser&&F(`[Assets] "loadParser" is deprecated, use "parser" instead for ${e}`),i||F(`[Assets] specified load parser "${t.parser||t.loadParser}" not found while loading ${e}`)),!i){for(let n=0;n<this.parsers.length;n++){let r=this.parsers[n];if(r.load&&r.test?.(e,t,this)){i=r;break}}if(!i)return F(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}r=await i.load(e,t,this),n.parser=i;for(let e=0;e<this.parsers.length;e++){let i=this.parsers[e];i.parse&&i.parse&&await i.testParse?.(r,t,this)&&(r=await i.parse(r,t,this)||r,n.parser=i)}return r})(),n}async load(t,n){this._parsersValidated||this._validateParsers();let{onProgress:r,onError:i,strategy:a,retryCount:o,retryDelay:s}=typeof n==`function`?{...e.defaultOptions,...this.loadOptions,onProgress:n}:{...e.defaultOptions,...this.loadOptions,...n||{}},c=0,l={},u=Mi(t),d=Di(t,e=>({alias:[e],src:e,data:{}})),f=d.reduce((e,t)=>e+(t.progressSize||1),0),p=d.map(async e=>{let t=Ti.toAbsolute(e.src);l[e.src]||(await this._loadAssetWithRetry(t,e,{onProgress:r,onError:i,strategy:a,retryCount:o,retryDelay:s},l),c+=e.progressSize||1,r&&r(c/f))});return await Promise.all(p),u?l[d[0].src]:l}async unload(e){let t=Di(e,e=>({alias:[e],src:e})).map(async e=>{let t=Ti.toAbsolute(e.src),n=this.promiseCache[t];if(n){let r=await n.promise;delete this.promiseCache[t],await n.parser?.unload?.(r,e,this)}});await Promise.all(t)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(e=>e.name||e.id).reduce((e,t)=>(!t.name&&!t.id?F(`[Assets] parser should have an id`):(e[t.name]||e[t.id])&&F(`[Assets] parser id conflict "${t.id}"`),e[t.name]=t,t.id&&(e[t.id]=t),e),{})}async _loadAssetWithRetry(e,t,n,r){let i=0,{onError:a,strategy:o,retryCount:s,retryDelay:c}=n,l=e=>new Promise(t=>setTimeout(t,e));for(;;)try{this.promiseCache[e]||(this.promiseCache[e]=this._getLoadPromiseAndParser(e,t)),r[t.src]=await this.promiseCache[e].promise;return}catch(n){if(delete this.promiseCache[e],delete r[t.src],i++,o===`retry`&&!(o!==`retry`||i>s)){a&&a(n,t),await l(c);continue}if(o===`skip`){a&&a(n,t);return}a&&a(n,t);let u=Error(`[Loader.load] Failed to load ${e}.
|
|
914
|
+
${n}`);throw n instanceof Error&&n.stack&&(u.stack=n.stack),u}}};gC.defaultOptions={onProgress:void 0,onError:void 0,strategy:`throw`,retryCount:3,retryDelay:250};let _C=gC;function vC(e,t){if(Array.isArray(t)){for(let n of t)if(e.startsWith(`data:${n}`))return!0;return!1}return e.startsWith(`data:${t}`)}Ei();function yC(e,t){let n=e.split(`?`)[0],r=Ti.extname(n).toLowerCase();return Array.isArray(t)?t.includes(r):r===t}V(),g(),gi();let bC={extension:{type:f.LoadParser,priority:hi.Low},name:`loadJson`,id:`json`,test(e){return vC(e,`application/json`)||yC(e,`.json`)},async load(e){return await(await B.get().fetch(e)).json()}};V(),g(),gi();let xC={name:`loadTxt`,id:`text`,extension:{type:f.LoadParser,priority:hi.Low,name:`loadTxt`},test(e){return vC(e,`text/plain`)||yC(e,`.txt`)},async load(e){return await(await B.get().fetch(e)).text()}};V(),g(),I(),Ei(),ba(),gi();let SC=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],CC=[`.ttf`,`.otf`,`.woff`,`.woff2`],wC=[`font/ttf`,`font/otf`,`font/woff`,`font/woff2`],TC=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function EC(e){let t=Ti.extname(e),n=Ti.basename(e,t).replace(/(-|_)/g,` `).toLowerCase().split(` `).map(e=>e.charAt(0).toUpperCase()+e.slice(1)),r=n.length>0;for(let e of n)if(!e.match(TC)){r=!1;break}let i=n.join(` `);return r||(i=`"${i.replace(/[\\"]/g,`\\$&`)}"`),i}let DC=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function OC(e){return DC.test(e)?e:encodeURI(e)}let kC={extension:{type:f.LoadParser,priority:hi.Low},name:`loadWebFont`,id:`web-font`,test(e){return vC(e,wC)||yC(e,CC)},async load(e,t){let n=B.get().getFontFaceSet();if(n){let r=[],i=t.data?.family??EC(e),a=t.data?.weights?.filter(e=>SC.includes(e))??[`normal`],o=t.data??{};for(let t=0;t<a.length;t++){let s=a[t],c=new FontFace(i,`url('${OC(e)}')`,{...o,weight:s});await c.load(),n.add(c),r.push(c)}return H.has(`${i}-and-url`)?H.get(`${i}-and-url`).entries.push({url:e,faces:r}):H.set(`${i}-and-url`,{entries:[{url:e,faces:r}]}),r.length===1?r[0]:r}return F(`[loadWebFont] FontFace API is not supported. Skipping loading font`),null},unload(e){let t=Array.isArray(e)?e:[e],n=t[0].family,r=H.get(`${n}-and-url`),i=r.entries.find(e=>e.faces.some(e=>t.indexOf(e)!==-1));i.faces=i.faces.filter(e=>t.indexOf(e)===-1),i.faces.length===0&&(r.entries=r.entries.filter(e=>e!==i)),t.forEach(e=>{B.get().getFontFaceSet().delete(e)}),r.entries.length===0&&H.remove(`${n}-and-url`)}};Ii();function AC(e,t=1){let n=Fi.RETINA_PREFIX?.exec(e);return n?parseFloat(n[1]):t}z(),I(),ba();function jC(e,t,n){e.label=n,e._sourceOrigin=n;let r=new R({source:e,label:n}),i=()=>{delete t.promiseCache[n],H.has(n)&&H.remove(n)};return r.source.once(`destroy`,()=>{t.promiseCache[n]&&(F(`[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource.`),i())}),r.once(`destroy`,()=>{e.destroyed||(F(`[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture.`),i())}),r}V(),g(),fa(),Hb(),gi();let MC={extension:{type:f.LoadParser,priority:hi.Low,name:`loadSVG`},name:`loadSVG`,id:`svg`,config:{crossOrigin:`anonymous`,parseAsGraphicsContext:!1},test(e){return vC(e,`image/svg+xml`)||yC(e,`.svg`)},async load(e,t,n){return t.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?PC(e):NC(e,t,n,this.config.crossOrigin)},unload(e){e.destroy(!0)}};async function NC(e,t,n,r){let i=await B.get().fetch(e),a=B.get().createImage();a.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await i.text())}`,a.crossOrigin=r,await a.decode();let o=t.data?.width??a.width,s=t.data?.height??a.height,c=t.data?.resolution||AC(e),l=Math.ceil(o*c),u=Math.ceil(s*c),d=B.get().createCanvas(l,u),f=d.getContext(`2d`);f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(a,0,0,o*c,s*c);let{parseAsGraphicsContext:p,...m}=t.data??{};return jC(new da({resource:d,alphaMode:`premultiply-alpha-on-upload`,resolution:c,...m}),n,e)}async function PC(e){let t=await(await B.get().fetch(e)).text(),n=new Vb;return n.svg(t),n}let FC=null;var IC=class{constructor(){FC||=URL.createObjectURL(new Blob([`(function () {
|
|
915
|
+
'use strict';
|
|
916
|
+
|
|
917
|
+
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
|
|
918
|
+
async function checkImageBitmap() {
|
|
919
|
+
try {
|
|
920
|
+
if (typeof createImageBitmap !== "function") return false;
|
|
921
|
+
const response = await fetch(WHITE_PNG);
|
|
922
|
+
const imageBlob = await response.blob();
|
|
923
|
+
const imageBitmap = await createImageBitmap(imageBlob);
|
|
924
|
+
return imageBitmap.width === 1 && imageBitmap.height === 1;
|
|
925
|
+
} catch (_e) {
|
|
926
|
+
return false;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
void checkImageBitmap().then((result) => {
|
|
930
|
+
self.postMessage(result);
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
})();
|
|
934
|
+
`],{type:`application/javascript`})),this.worker=new Worker(FC)}};IC.revokeObjectURL=function(){FC&&=(URL.revokeObjectURL(FC),null)};let LC=null;var RC=class{constructor(){LC||=URL.createObjectURL(new Blob([`(function () {
|
|
935
|
+
'use strict';
|
|
936
|
+
|
|
937
|
+
async function loadImageBitmap(url, alphaMode) {
|
|
938
|
+
const response = await fetch(url);
|
|
939
|
+
if (!response.ok) {
|
|
940
|
+
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
|
|
941
|
+
}
|
|
942
|
+
const imageBlob = await response.blob();
|
|
943
|
+
return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
|
|
944
|
+
}
|
|
945
|
+
self.onmessage = async (event) => {
|
|
946
|
+
try {
|
|
947
|
+
const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
|
|
948
|
+
self.postMessage({
|
|
949
|
+
data: imageBitmap,
|
|
950
|
+
uuid: event.data.uuid,
|
|
951
|
+
id: event.data.id
|
|
952
|
+
}, [imageBitmap]);
|
|
953
|
+
} catch (e) {
|
|
954
|
+
self.postMessage({
|
|
955
|
+
error: e,
|
|
956
|
+
uuid: event.data.uuid,
|
|
957
|
+
id: event.data.id
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
|
|
962
|
+
})();
|
|
963
|
+
`],{type:`application/javascript`})),this.worker=new Worker(LC)}};RC.revokeObjectURL=function(){LC&&=(URL.revokeObjectURL(LC),null)};let zC=0,BC,VC=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported===void 0&&(this._isImageBitmapSupported=new Promise(e=>{let{worker:t}=new IC;t.addEventListener(`message`,n=>{t.terminate(),IC.revokeObjectURL(),e(n.data)})})),this._isImageBitmapSupported}loadImageBitmap(e,t){return this._run(`loadImageBitmap`,[e,t?.data?.alphaMode])}async _initWorkers(){this._initialized||=!0}_getWorker(){BC===void 0&&(BC=navigator.hardwareConcurrency||4);let e=this._workerPool.pop();return!e&&this._createdWorkers<BC&&(this._createdWorkers++,e=new RC().worker,e.addEventListener(`message`,e=>{this._complete(e.data),this._returnWorker(e.target),this._next()})),e}_returnWorker(e){this._workerPool.push(e)}_complete(e){this._resolveHash[e.uuid]&&(e.error===void 0?this._resolveHash[e.uuid].resolve(e.data):this._resolveHash[e.uuid].reject(e.error),delete this._resolveHash[e.uuid])}async _run(e,t){await this._initWorkers();let n=new Promise((n,r)=>{this._queue.push({id:e,arguments:t,resolve:n,reject:r})});return this._next(),n}_next(){if(!this._queue.length)return;let e=this._getWorker();if(!e)return;let t=this._queue.pop(),n=t.id;this._resolveHash[zC]={resolve:t.resolve,reject:t.reject},e.postMessage({data:t.arguments,uuid:zC++,id:n})}reset(){this._workerPool.forEach(e=>e.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:e})=>{e?.(Error(`WorkerManager has been reset before completion`))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}};V(),g(),fa(),gi();let HC=[`.jpeg`,`.jpg`,`.png`,`.webp`,`.avif`],UC=[`image/jpeg`,`image/png`,`image/webp`,`image/avif`];async function WC(e,t){let n=await B.get().fetch(e);if(!n.ok)throw Error(`[loadImageBitmap] Failed to fetch ${e}: ${n.status} ${n.statusText}`);let r=await n.blob();return t?.data?.alphaMode===`premultiplied-alpha`?createImageBitmap(r,{premultiplyAlpha:`none`}):createImageBitmap(r)}let GC={name:`loadTextures`,id:`texture`,extension:{type:f.LoadParser,priority:hi.High,name:`loadTextures`},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:`anonymous`},test(e){return vC(e,UC)||yC(e,HC)},async load(e,t,n){let r=null;return r=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await VC.isImageBitmapSupported()?await VC.loadImageBitmap(e,t):await WC(e,t):await new Promise((t,n)=>{r=B.get().createImage(),r.crossOrigin=this.config.crossOrigin,r.src=e,r.complete?t(r):(r.onload=()=>{t(r)},r.onerror=n)}),jC(new da({resource:r,alphaMode:`premultiply-alpha-on-upload`,resolution:t.data?.resolution||AC(e),...t.data}),n,e)},unload(e){e.destroy(!0)}};g(),va(),ha();let KC=[`.mp4`,`.m4v`,`.webm`,`.ogg`,`.ogv`,`.h264`,`.avi`,`.mov`],qC,JC;function YC(e,t,n){n===void 0&&!t.startsWith(`data:`)?e.crossOrigin=ZC(t):n!==!1&&(e.crossOrigin=typeof n==`string`?n:`anonymous`)}function XC(e){return new Promise((t,n)=>{e.addEventListener(`canplaythrough`,r),e.addEventListener(`error`,i),e.load();function r(){a(),t()}function i(e){a(),n(e)}function a(){e.removeEventListener(`canplaythrough`,r),e.removeEventListener(`error`,i)}})}function ZC(e,t=globalThis.location){if(e.startsWith(`data:`))return``;t||=globalThis.location;let n=new URL(e,document.baseURI);return n.hostname!==t.hostname||n.port!==t.port||n.protocol!==t.protocol?`anonymous`:``}function QC(){let e=[],t=[];for(let n of KC){let r=_a.MIME_TYPES[n.substring(1)]||`video/${n.substring(1)}`;dC(r)&&(e.push(n),t.includes(r)||t.push(r))}return{validVideoExtensions:e,validVideoMime:t}}let $C={name:`loadVideo`,id:`video`,extension:{type:f.LoadParser,name:`loadVideo`},test(e){if(!qC||!JC){let{validVideoExtensions:e,validVideoMime:t}=QC();qC=e,JC=t}let t=vC(e,JC),n=yC(e,qC);return t||n},async load(e,t,n){let r={..._a.defaultOptions,resolution:t.data?.resolution||AC(e),alphaMode:t.data?.alphaMode||await pa(),...t.data},i=document.createElement(`video`),a={preload:r.autoLoad===!1?void 0:`auto`,"webkit-playsinline":r.playsinline===!1?void 0:``,playsinline:r.playsinline===!1?void 0:``,muted:r.muted===!0?``:void 0,loop:r.loop===!0?``:void 0,autoplay:r.autoPlay===!1?void 0:``};Object.keys(a).forEach(e=>{let t=a[e];t!==void 0&&i.setAttribute(e,t)}),r.muted===!0&&(i.muted=!0),YC(i,e,r.crossorigin);let o=document.createElement(`source`),s;if(r.mime)s=r.mime;else if(e.startsWith(`data:`))s=e.slice(5,e.indexOf(`;`));else if(!e.startsWith(`blob:`)){let t=e.split(`?`)[0].slice(e.lastIndexOf(`.`)+1).toLowerCase();s=_a.MIME_TYPES[t]||`video/${t}`}return o.src=e,s&&(o.type=s),new Promise((a,s)=>{r.preload&&!r.autoPlay&&i.load(),i.addEventListener(`canplay`,c),i.addEventListener(`error`,l),o.addEventListener(`error`,l),i.appendChild(o);async function c(){let o=new _a({...r,resource:i});u(),t.data.preload&&await XC(i),a(jC(o,n,e))}function l(e){u(),s(e)}function u(){i.removeEventListener(`canplay`,c),i.removeEventListener(`error`,l),o.removeEventListener(`error`,l)}})},unload(e){e.destroy(!0)}};g(),Ii();let ew={extension:{type:f.ResolveParser,name:`resolveTexture`},test:GC.test,parse:e=>({resolution:parseFloat(Fi.RETINA_PREFIX.exec(e)?.[1]??`1`),format:e.split(`.`).pop(),src:e})};g(),Ii();let tw={extension:{type:f.ResolveParser,priority:-2,name:`resolveJson`},test:e=>Fi.RETINA_PREFIX.test(e)&&e.endsWith(`.json`),parse:ew.parse};g(),I(),ba(),Ii(),Oi(),Ni();let nw=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Fi,this.loader=new _C,this.cache=H,this._backgroundLoader=new iC(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(e={}){if(this._initialized){F(`[Assets]AssetManager already initialized, did you load before calling this Assets.init()?`);return}if(this._initialized=!0,e.defaultSearchParams&&this.resolver.setDefaultSearchParams(e.defaultSearchParams),e.basePath&&(this.resolver.basePath=e.basePath),e.bundleIdentifier&&this.resolver.setBundleIdentifier(e.bundleIdentifier),e.manifest){let t=e.manifest;typeof t==`string`&&(t=await this.load(t)),this.resolver.addManifest(t)}let t=e.texturePreference?.resolution??1,n=typeof t==`number`?[t]:t,r=await this._detectFormats({preferredFormats:e.texturePreference?.format,skipDetections:e.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:n}}),e.preferences&&this.setPreferences(e.preferences),e.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...e.loadOptions})}add(e){this.resolver.add(e)}async load(e,t){this._initialized||await this.init();let n=Mi(e),r=Di(e).map(e=>{if(typeof e!=`string`){let t=this.resolver.getAlias(e);return t.some(e=>!this.resolver.hasKey(e))&&this.add(e),Array.isArray(t)?t[0]:t}return this.resolver.hasKey(e)||this.add({alias:e,src:e}),e}),i=this.resolver.resolve(r),a=await this._mapLoadToResolve(i,t);return n?a[r[0]]:a}addBundle(e,t){this.resolver.addBundle(e,t)}async loadBundle(e,t){this._initialized||await this.init();let n=!1;typeof e==`string`&&(n=!0,e=[e]);let r=this.resolver.resolveBundle(e),i={},a=Object.keys(r),o=0,s=[],c=()=>{t?.(s.reduce((e,t)=>e+t,0)/o)},l=a.map((e,t)=>{let n=r[e],a=Object.values(n),l=[...new Set(a.flat())].reduce((e,t)=>e+(t.progressSize||1),0);return s.push(0),o+=l,this._mapLoadToResolve(n,e=>{s[t]=e*l,c()}).then(t=>{i[e]=t})});return await Promise.all(l),n?i[e[0]]:i}async backgroundLoad(e){this._initialized||await this.init(),typeof e==`string`&&(e=[e]);let t=this.resolver.resolve(e);this._backgroundLoader.add(Object.values(t))}async backgroundLoadBundle(e){this._initialized||await this.init(),typeof e==`string`&&(e=[e]);let t=this.resolver.resolveBundle(e);Object.values(t).forEach(e=>{this._backgroundLoader.add(Object.values(e))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(e){if(typeof e==`string`)return H.get(e);let t={};for(let n=0;n<e.length;n++)t[n]=H.get(e[n]);return t}async _mapLoadToResolve(e,t){let n=[...new Set(Object.values(e))];this._backgroundLoader.active=!1;let r=await this.loader.load(n,t);this._backgroundLoader.active=!0;let i={};return n.forEach(e=>{let t=r[e.src],n=[e.src];e.alias&&n.push(...e.alias),n.forEach(e=>{i[e]=t}),H.set(n,t)}),i}async unload(e){this._initialized||await this.init();let t=Di(e).map(e=>typeof e==`string`?e:e.src),n=this.resolver.resolve(t);await this._unloadFromResolved(n)}async unloadBundle(e){this._initialized||await this.init(),e=Di(e);let t=this.resolver.resolveBundle(e),n=Object.keys(t).map(e=>this._unloadFromResolved(t[e]));await Promise.all(n)}async _unloadFromResolved(e){let t=Object.values(e);t.forEach(e=>{H.remove(e.src)}),await this.loader.unload(t)}async _detectFormats(e){let t=[];e.preferredFormats&&(t=Array.isArray(e.preferredFormats)?e.preferredFormats:[e.preferredFormats]);for(let n of e.detections)e.skipDetections||await n.test()?t=await n.add(t):e.skipDetections||(t=await n.remove(t));return t=t.filter((e,n)=>t.indexOf(e)===n),t}get detections(){return this._detections}setPreferences(e){this.loader.parsers.forEach(t=>{t.config&&Object.keys(t.config).filter(t=>t in e).forEach(n=>{t.config[n]=e[n]})})}};h.handleByList(f.LoadParser,nw.loader.parsers).handleByList(f.ResolveParser,nw.resolver.parsers).handleByList(f.CacheParser,nw.cache.parsers).handleByList(f.DetectionParser,nw.detections),h.add(aC,lC,sC,hC,fC,pC,mC,bC,xC,kC,MC,GC,$C,rC,nC,ew,tw);let rw={loader:f.LoadParser,resolver:f.ResolveParser,cache:f.CacheParser,detection:f.DetectionParser};h.handle(f.Asset,e=>{let t=e.ref;Object.entries(rw).filter(([e])=>!!t[e]).forEach(([e,n])=>h.add(Object.assign(t[e],{extension:t[e].extension??n})))},e=>{let t=e.ref;Object.keys(rw).filter(e=>!!t[e]).forEach(e=>h.remove(t[e]))}),U_(),M(),Le();var iw=class{constructor({matrix:e,observer:t}={}){this.dirty=!0,this._matrix=e??new j,this.observer=t,this.position=new Ie(this,0,0),this.scale=new Ie(this,1,1),this.pivot=new Ie(this,0,0),this.skew=new Ie(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){let e=this._matrix;return this.dirty?(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this.dirty=!1,e):e}_onUpdate(e){this.dirty=!0,e===this.skew&&this.updateSkew(),this.observer?._onUpdate(this)}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this.dirty=!0}toString(){return`[pixi.js/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`}setFromMatrix(e){e.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this.skew))}};g(),Ea(),Ki(),V(),M(),Le(),Ne(),ua(),z(),Ta(),St(),qn(),er(),b(),h.add(tc,ic);var aw=c((()=>{throw Error(`@pixi/sound is not bundled: motion sounds and lip sync land post-M3 (pet-center M3)`)})),ow=Object.defineProperty,sw=Object.defineProperties,cw=Object.getOwnPropertyDescriptors,lw=Object.getOwnPropertySymbols,uw=Object.prototype.hasOwnProperty,dw=Object.prototype.propertyIsEnumerable,fw=Math.pow,pw=(e,t,n)=>t in e?ow(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mw=(e,t)=>{for(var n in t||={})uw.call(t,n)&&pw(e,n,t[n]);if(lw)for(var n of lw(t))dw.call(t,n)&&pw(e,n,t[n]);return e},hw=(e,t)=>sw(e,cw(t)),K=(e,t,n)=>pw(e,typeof t==`symbol`?t:t+``,n),q=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())});let gw=class e{constructor(e=0){e<1?(this._ptr=[],this._capacity=0,this._size=0):(this._ptr=Array(e),this._capacity=e,this._size=0)}at(e){return this._ptr[e]}set(e,t){this._ptr[e]=t}get(e=0){let t=[];for(let n=e;n<this._size;n++)t.push(this._ptr[n]);return t}pushBack(t){this._size>=this._capacity&&this.prepareCapacity(this._capacity==0?e.DefaultSize:this._capacity*2),this._ptr[this._size++]=t}clear(){this._ptr.length=0,this._size=0}getSize(){return this._size}assign(e,t){this._size<e&&this.prepareCapacity(e);for(let n=0;n<e;n++)this._ptr[n]=t;this._size=e}resize(e,t=null){this.updateSize(e,t,!0)}updateSize(e,t=null,n=!0){if(this._size<e)if(this.prepareCapacity(e),n)for(let n=this._size;n<e;n++)typeof t==`function`?this._ptr[n]=JSON.parse(JSON.stringify(new t)):this._ptr[n]=t;else for(let n=this._size;n<e;n++)this._ptr[n]=t;else{let t=this._size-e;this._ptr.splice(this._size-t,t)}this._size=e}insert(e,t,n){let r=e._index,i=t._index,a=n._index,o=a-i;this.prepareCapacity(this._size+o);let s=this._size-r;if(s>0)for(let e=0;e<s;e++)this._ptr.splice(r+e,0,null);for(let e=i;e<a;e++,r++)this._ptr[r]=t._vector._ptr[e];this._size+=o}remove(e){return e<0||this._size<=e?!1:(this._ptr.splice(e,1),--this._size,!0)}erase(e){let t=e._index;return t<0||this._size<=t?e:(this._ptr.splice(t,1),--this._size,new _w(this,t))}prepareCapacity(e){e>this._capacity&&(this._capacity==0?(this._ptr=Array(e),this._capacity=e):(this._ptr.length=e,this._capacity=e))}begin(){return this._size==0?this.end():new _w(this,0)}end(){return new _w(this,this._size)}getOffset(t){let n=new e;return n._ptr=this.get(t),n._size=this.get(t).length,n._capacity=this.get(t).length,n}};gw.DefaultSize=10;let J=gw,_w=class e{constructor(e,t){this._vector=e??null,this._index=t??0}set(e){return this._index=e._index,this._vector=e._vector,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new e(this._vector,this._index++)}decrement(){return new e(this._vector,this._index--)}ptr(){return this._vector._ptr[this._index]}substitution(e){return this._index=e._index,this._vector=e._vector,this}notEqual(e){return this._index!=e._index||this._vector!=e._vector}};var vw;(e=>{e.csmVector=J,e.iterator=_w})(vw||={});var yw=class{append(e,t){return this.s+=t===void 0?e:e.substr(0,t),this}expansion(e,t){for(let n=0;n<e;n++)this.append(t);return this}getBytes(){return encodeURIComponent(this.s).replace(/%../g,`x`).length}getLength(){return this.s.length}isLess(e){return this.s<e.s}isGreat(e){return this.s>e.s}isEqual(e){return this.s==e}isEmpty(){return this.s.length==0}constructor(e){this.s=e}},bw;(e=>{e.csmString=yw})(bw||={});var xw=class e{static createIdInternal(t){return new e(t)}getString(){return this._id}isEqual(t){return typeof t==`string`?this._id.isEqual(t):t instanceof yw?this._id.isEqual(t.s):t instanceof e&&this._id.isEqual(t._id.s)}isNotEqual(t){return typeof t==`string`?!this._id.isEqual(t):t instanceof yw?!this._id.isEqual(t.s):t instanceof e&&!this._id.isEqual(t._id.s)}constructor(e){if(typeof e==`string`){this._id=new yw(e);return}this._id=e}},Sw;(e=>{e.CubismId=xw})(Sw||={});var Cw=class{constructor(){this._ids=new J}release(){for(let e=0;e<this._ids.getSize();++e)this._ids.set(e,void 0);this._ids=null}registerIds(e){for(let t=0;t<e.length;t++)this.registerId(e[t])}registerId(e){let t=null;if(typeof e==`string`){if((t=this.findId(e))!=null)return t;t=xw.createIdInternal(e),this._ids.pushBack(t)}else return this.registerId(e.s);return t}getId(e){return this.registerId(e)}isExist(e){return typeof e==`string`?this.findId(e)!=null:this.isExist(e.s)}findId(e){for(let t=0;t<this._ids.getSize();++t)if(this._ids.at(t).getString().isEqual(e))return this._ids.at(t);return null}},ww;(e=>{e.CubismIdManager=Cw})(ww||={});var Tw=class e{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(e,t,n){let r=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);for(let n=0;n<4;++n)for(let i=0;i<4;++i)for(let a=0;a<4;++a)r[i+n*4]+=e[a+n*4]*t[i+a*4];for(let e=0;e<16;++e)n[e]=r[e]}loadIdentity(){let e=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(e)}setMatrix(e){for(let t=0;t<16;++t)this._tr[t]=e[t]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(e){return this._tr[0]*e+this._tr[12]}transformY(e){return this._tr[5]*e+this._tr[13]}invertTransformX(e){return(e-this._tr[12])/this._tr[0]}invertTransformY(e){return(e-this._tr[13])/this._tr[5]}translateRelative(t,n){let r=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,n,0,1]);e.multiply(r,this._tr,this._tr)}translate(e,t){this._tr[12]=e,this._tr[13]=t}translateX(e){this._tr[12]=e}translateY(e){this._tr[13]=e}scaleRelative(t,n){let r=new Float32Array([t,0,0,0,0,n,0,0,0,0,1,0,0,0,0,1]);e.multiply(r,this._tr,this._tr)}scale(e,t){this._tr[0]=e,this._tr[5]=t}multiplyByMatrix(t){e.multiply(t.getArray(),this._tr,this._tr)}clone(){let t=new e;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}},Ew;(e=>{e.CubismMatrix44=Tw})(Ew||={});var Dw=class{constructor(e,t,n,r){this.x=e,this.y=t,this.width=n,this.height=r}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}expand(e,t){this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2}},Ow;(e=>{e.csmRect=Dw})(Ow||={});var kw=class{static create(){return null}static delete(e){}initialize(e){this._model=e}drawModel(){this.getModel()!=null&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(e){this._mvpMatrix4x4.setMatrix(e.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(e,t,n,r){e<0?e=0:e>1&&(e=1),t<0?t=0:t>1&&(t=1),n<0?n=0:n>1&&(n=1),r<0?r=0:r>1&&(r=1),this._modelColor.r=e,this._modelColor.g=t,this._modelColor.b=n,this._modelColor.a=r}getModelColor(){return JSON.parse(JSON.stringify(this._modelColor))}getModelColorWithOpacity(e){let t=this.getModelColor();return t.a*=e,this.isPremultipliedAlpha()&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}setIsPremultipliedAlpha(e){this._isPremultipliedAlpha=e}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(e){this._isCulling=e}isCulling(){return this._isCulling}setAnisotropy(e){this._anisotropy=e}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(e){this._useHighPrecisionMask=e}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._model=null,this._modelColor=new jw,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new Tw,this._mvpMatrix4x4.loadIdentity()}},Aw=(e=>(e[e.CubismBlendMode_Normal=0]=`CubismBlendMode_Normal`,e[e.CubismBlendMode_Additive=1]=`CubismBlendMode_Additive`,e[e.CubismBlendMode_Multiplicative=2]=`CubismBlendMode_Multiplicative`,e))(Aw||{}),jw=class{constructor(e=1,t=1,n=1,r=1){this.r=e,this.g=t,this.b=n,this.a=r}},Mw=class{constructor(e,t){this._clippingIdList=e,this._clippingIdCount=t,this._allClippedDrawRect=new Dw,this._layoutBounds=new Dw,this._clippedDrawableIndexList=[],this._matrixForMask=new Tw,this._matrixForDraw=new Tw,this._bufferIndex=0}release(){this._layoutBounds!=null&&(this._layoutBounds=null),this._allClippedDrawRect!=null&&(this._allClippedDrawRect=null),this._clippedDrawableIndexList!=null&&(this._clippedDrawableIndexList=null)}addClippedDrawable(e){this._clippedDrawableIndexList.push(e)}},Nw;(e=>{e.CubismBlendMode=Aw,e.CubismRenderer=kw,e.CubismTextureColor=jw})(Nw||={});let Pw=Object.freeze(Object.defineProperty({__proto__:null,CSM_LOG_LEVEL:0,CSM_LOG_LEVEL_DEBUG:1,CSM_LOG_LEVEL_ERROR:4,CSM_LOG_LEVEL_INFO:2,CSM_LOG_LEVEL_OFF:5,CSM_LOG_LEVEL_VERBOSE:0,CSM_LOG_LEVEL_WARNING:3},Symbol.toStringTag,{value:`Module`})),Fw=(e,t,n)=>{Vw.print(e,`[CSM]`+t,n)},Iw=(e,t,n)=>{Fw(e,t+`
|
|
964
|
+
`,n)},Lw=e=>{console.assert(e)},Rw,zw,Y,Bw;Rw=(e,...t)=>{Iw(mT.LogLevel_Debug,`[D]`+e,t)},zw=(e,...t)=>{Iw(mT.LogLevel_Info,`[I]`+e,t)},Y=(e,...t)=>{Iw(mT.LogLevel_Warning,`[W]`+e,t)},Bw=(e,...t)=>{Iw(mT.LogLevel_Error,`[E]`+e,t)};var Vw=class{static print(e,t,n){if(e<pT.getLoggingLevel())return;let r=pT.coreLogFunction;r&&r(t.replace(/\{(\d+)\}/g,(e,t)=>n[t]))}static dumpBytes(e,t,n){for(let r=0;r<n;r++)r%16==0&&r>0?this.print(e,`
|
|
965
|
+
`):r%8==0&&r>0&&this.print(e,` `),this.print(e,`{0} `,[t[r]&255]);this.print(e,`
|
|
966
|
+
`)}constructor(){}},Hw;(e=>{e.CubismDebug=Vw})(Hw||={});var Uw=class{constructor(e,t){this.first=e??null,this.second=t??null}};let Ww=class e{constructor(e){e==null||e<1?(this._keyValues=[],this._dummyValue=null,this._size=0):(this._keyValues=Array(e),this._size=e)}release(){this.clear()}appendKey(e){let t=-1;for(let n=0;n<this._size;n++)if(this._keyValues[n].first==e){t=n;break}if(t!=-1){Y("The key `{0}` is already append.",e);return}this.prepareCapacity(this._size+1,!1),this._keyValues[this._size]=new Uw(e),this._size+=1}getValue(e){let t=-1;for(let n=0;n<this._size;n++)if(this._keyValues[n].first==e){t=n;break}return t>=0?this._keyValues[t].second:(this.appendKey(e),this._keyValues[this._size-1].second)}setValue(e,t){let n=-1;for(let t=0;t<this._size;t++)if(this._keyValues[t].first==e){n=t;break}n>=0?this._keyValues[n].second=t:(this.appendKey(e),this._keyValues[this._size-1].second=t)}isExist(e){for(let t=0;t<this._size;t++)if(this._keyValues[t].first==e)return!0;return!1}clear(){this._keyValues=void 0,this._keyValues=null,this._keyValues=[],this._size=0}getSize(){return this._size}prepareCapacity(t,n){t>this._keyValues.length&&(this._keyValues.length==0?(!n&&t<e.DefaultSize&&(t=e.DefaultSize),this._keyValues.length=t):(!n&&t<this._keyValues.length*2&&(t=this._keyValues.length*2),this._keyValues.length=t))}begin(){return new Kw(this,0)}end(){return new Kw(this,this._size)}erase(e){let t=e._index;return t<0||this._size<=t?e:(this._keyValues.splice(t,1),--this._size,new Kw(this,t))}dumpAsInt(){for(let e=0;e<this._size;e++)Rw(`{0} ,`,this._keyValues[e]),Rw(`
|
|
967
|
+
`)}};Ww.DefaultSize=10;let Gw=Ww;var Kw=class e{constructor(e,t){this._map=e??new Gw,this._index=t??0}set(e){return this._index=e._index,this._map=e._map,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new e(this._map,this._index++)}decrement(){let t=new e(this._map,this._index);return this._map=t._map,this._index=t._index,this}ptr(){return this._map._keyValues[this._index]}notEqual(e){return this._index!=e._index||this._map!=e._map}},qw;(e=>{e.csmMap=Gw,e.csmPair=Uw,e.iterator=Kw})(qw||={});var Jw=class e{static parseJsonObject(t,n){return Object.keys(t).forEach(r=>{if(typeof t[r]==`boolean`){let e=!!t[r];n.put(r,new $w(e))}else if(typeof t[r]==`string`){let e=String(t[r]);n.put(r,new eT(e))}else if(typeof t[r]==`number`){let e=Number(t[r]);n.put(r,new Qw(e))}else t[r]instanceof Array?n.put(r,e.parseJsonArray(t[r])):t[r]instanceof Object?n.put(r,e.parseJsonObject(t[r],new iT)):t[r]==null?n.put(r,new nT):n.put(r,t[r])}),n}static parseJsonArray(e){let t=new rT;return Object.keys(e).forEach(n=>{if(typeof Number(n)==`number`)if(typeof e[n]==`boolean`){let r=!!e[n];t.add(new $w(r))}else if(typeof e[n]==`string`){let r=String(e[n]);t.add(new eT(r))}else if(typeof e[n]==`number`){let r=Number(e[n]);t.add(new Qw(r))}else e[n]instanceof Array?t.add(this.parseJsonArray(e[n])):e[n]instanceof Object?t.add(this.parseJsonObject(e[n],new iT)):e[n]==null?t.add(new nT):t.add(e[n]);else if(e[n]instanceof Array)t.add(this.parseJsonArray(e[n]));else if(e[n]instanceof Object)t.add(this.parseJsonObject(e[n],new iT));else if(e[n]==null)t.add(new nT);else{let r=Array(e[n]);for(let e=0;e<r.length;e++)t.add(r[e])}}),t}};let Yw=`Error: type mismatch`,Xw=class e{constructor(){}getRawString(e,t){return this.getString(e,t)}toInt(e=0){return e}toFloat(e=0){return e}toBoolean(e=!1){return e}getSize(){return 0}getArray(e=null){return e}getVector(e=new J){return e}getMap(e){return e}getValueByIndex(t){return e.errorValue.setErrorNotForClientCall(Yw)}getValueByString(t){return e.nullValue.setErrorNotForClientCall(Yw)}getKeys(){return e.dummyKeys}isError(){return!1}isNull(){return!1}isBool(){return!1}isFloat(){return!1}isString(){return!1}isArray(){return!1}isMap(){return!1}equals(e){return!1}isStatic(){return!1}setErrorNotForClientCall(e){return tT.errorValue}static staticInitializeNotForClientCall(){$w.trueValue=new $w(!0),$w.falseValue=new $w(!1),e.errorValue=new tT(`ERROR`,!0),e.nullValue=new nT,e.dummyKeys=new J}static staticReleaseNotForClientCall(){$w.trueValue=null,$w.falseValue=null,e.errorValue=null,e.nullValue=null,e.dummyKeys=null}};var Zw=class e{constructor(e,t){this._parseCallback=Jw.parseJsonObject,this._error=null,this._lineCount=0,this._root=null,e!=null&&this.parseBytes(e,t,this._parseCallback)}static create(t,n){let r=new e;return r.parseBytes(t,n,r._parseCallback)?r:(e.delete(r),null)}static delete(e){}getRoot(){return this._root}static arrayBufferToString(e){let t=new Uint8Array(e),n=``;for(let e=0,r=t.length;e<r;++e)n+=`%`+this.pad(t[e].toString(16));return n=decodeURIComponent(n),n}static pad(e){return e.length<2?`0`+e:e}parseBytes(t,n,r){let i=[,],a=e.arrayBufferToString(t);if(r==null?this._root=this.parseValue(a,n,0,i):this._root=r(JSON.parse(a),new iT),this._error){let e=`\0`;return e=`Json parse error : @line `+(this._lineCount+1)+`
|
|
968
|
+
`,this._root=new eT(e),zw(`{0}`,this._root.getRawString()),!1}else if(this._root==null)return this._root=new tT(new yw(this._error),!1),!1;return!0}getParseError(){return this._error}checkEndOfFile(){return this._root.getArray()[1].equals(`EOF`)}parseValue(e,t,n,r){if(this._error)return null;let i=null,a=n,o;for(;a<t;a++)switch(e[a]){case`-`:case`.`:case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:{let t=[,];return o=oT(e.slice(a),t),r[0]=e.indexOf(t[0]),new Qw(o)}case`"`:return new eT(this.parseString(e,t,a+1,r));case`[`:return i=this.parseArray(e,t,a+1,r),i;case`{`:return i=this.parseObject(e,t,a+1,r),i;case`n`:return a+3<t?(i=new nT,r[0]=a+4):this._error=`parse null`,i;case`t`:return a+3<t?(i=$w.trueValue,r[0]=a+4):this._error=`parse true`,i;case`f`:return a+4<t?(i=$w.falseValue,r[0]=a+5):this._error=`illegal ',' position`,i;case`,`:return this._error=`illegal ',' position`,null;case`]`:return r[0]=a,null;case`
|
|
969
|
+
`:this._lineCount++}return this._error=`illegal end of value`,null}parseString(e,t,n,r){if(this._error)return null;if(!e)return this._error=`string is null`,null;let i=n,a,o,s=new yw(``),c=n;for(;i<t;i++)switch(a=e[i],a){case`"`:return r[0]=i+1,s.append(e.slice(c),i-c),s.s;case`//`:if(i++,i-1>c&&s.append(e.slice(c),i-c),c=i+1,i<t)switch(o=e[i],o){case`\\`:s.expansion(1,`\\`);break;case`"`:s.expansion(1,`"`);break;case`/`:s.expansion(1,`/`);break;case`b`:s.expansion(1,`\b`);break;case`f`:s.expansion(1,`\f`);break;case`n`:s.expansion(1,`
|
|
970
|
+
`);break;case`r`:s.expansion(1,`\r`);break;case`t`:s.expansion(1,` `);break;case`u`:this._error=`parse string/unicord escape not supported`;break}else this._error=`parse string/escape error`}return this._error=`parse string/illegal end`,null}parseObject(e,t,n,r){if(this._error)return null;if(!e)return this._error=`buffer is null`,null;let i=new iT,a=``,o=n,s=``,c=[,],l=!1;for(;o<t;o++){FOR_LOOP:for(;o<t;o++)switch(s=e[o],s){case`"`:if(a=this.parseString(e,t,o+1,c),this._error)return null;o=c[0],l=!0;break FOR_LOOP;case`}`:return r[0]=o+1,i;case`:`:this._error=`illegal ':' position`;break;case`
|
|
971
|
+
`:this._lineCount++}if(!l)return this._error=`key not found`,null;l=!1;FOR_LOOP2:for(;o<t;o++)switch(s=e[o],s){case`:`:l=!0,o++;break FOR_LOOP2;case`}`:this._error=`illegal '}' position`;break;case`
|
|
972
|
+
`:this._lineCount++}if(!l)return this._error=`':' not found`,null;let n=this.parseValue(e,t,o,c);if(this._error)return null;o=c[0],i.put(a,n);FOR_LOOP3:for(;o<t;o++)switch(s=e[o],s){case`,`:break FOR_LOOP3;case`}`:return r[0]=o+1,i;case`
|
|
973
|
+
`:this._lineCount++}}return this._error=`illegal end of perseObject`,null}parseArray(e,t,n,r){if(this._error)return null;if(!e)return this._error=`buffer is null`,null;let i=new rT,a=n,o,s=[,];for(;a<t;a++){let n=this.parseValue(e,t,a,s);if(this._error)return null;a=s[0],n&&i.add(n);FOR_LOOP:for(;a<t;a++)switch(o=e[a],o){case`,`:break FOR_LOOP;case`]`:return r[0]=a+1,i;case`
|
|
974
|
+
`:++this._lineCount}}return i=void 0,this._error=`illegal end of parseObject`,null}},Qw=class extends Xw{constructor(e){super(),this._value=e}isFloat(){return!0}getString(e,t){return this._value=NaN,this._stringBuffer=`\0`,this._stringBuffer}toInt(e=0){return parseInt(this._value.toString())}toFloat(e=0){return this._value}equals(e){return typeof e==`number`&&!Math.round(e)&&e==this._value}},$w=class extends Xw{isBool(){return!0}toBoolean(e=!1){return this._boolValue}getString(e,t){return this._stringBuffer=this._boolValue?`true`:`false`,this._stringBuffer}equals(e){return typeof e==`boolean`&&e==this._boolValue}isStatic(){return!0}constructor(e){super(),this._boolValue=e}},eT=class extends Xw{constructor(e){super(),typeof e==`string`&&(this._stringBuffer=e),e instanceof yw&&(this._stringBuffer=e.s)}isString(){return!0}getString(e,t){return this._stringBuffer}equals(e){return typeof e==`string`?this._stringBuffer==e:e instanceof yw&&this._stringBuffer==e.s}},tT=class extends eT{isStatic(){return this._isStatic}setErrorNotForClientCall(e){return this._stringBuffer=e,this}constructor(e,t){super(e),this._isStatic=t}isError(){return!0}},nT=class extends Xw{isNull(){return!0}getString(e,t){return this._stringBuffer}isStatic(){return!0}setErrorNotForClientCall(e){return this._stringBuffer=e,tT.nullValue}constructor(){super(),this._stringBuffer=`NullValue`}},rT=class extends Xw{constructor(){super(),this._array=new J}release(){for(let e=this._array.begin();e.notEqual(this._array.end());e.preIncrement()){let t=e.ptr();t&&!t.isStatic()&&(t=void 0,t=null)}}isArray(){return!0}getValueByIndex(e){return e<0||this._array.getSize()<=e?Xw.errorValue.setErrorNotForClientCall(`Error: index out of bounds`):this._array.at(e)??Xw.nullValue}getValueByString(e){return Xw.errorValue.setErrorNotForClientCall(Yw)}getString(e,t){let n=t+`[
|
|
975
|
+
`;for(let e=this._array.begin();e.notEqual(this._array.end());e.increment()){let n=e.ptr();this._stringBuffer+=t+``+n.getString(t+` `)+`
|
|
976
|
+
`}return this._stringBuffer=n+t+`]
|
|
977
|
+
`,this._stringBuffer}add(e){this._array.pushBack(e)}getVector(e=null){return this._array}getSize(){return this._array.getSize()}},iT=class extends Xw{constructor(){super(),this._map=new Gw}release(){let e=this._map.begin();for(;e.notEqual(this._map.end());){let t=e.ptr().second;t&&!t.isStatic()&&(t=void 0,t=null),e.preIncrement()}}isMap(){return!0}getValueByString(e){if(e instanceof yw)return this._map.getValue(e.s)??Xw.nullValue;for(let t=this._map.begin();t.notEqual(this._map.end());t.preIncrement())if(t.ptr().first==e)return t.ptr().second==null?Xw.nullValue:t.ptr().second;return Xw.nullValue}getValueByIndex(e){return Xw.errorValue.setErrorNotForClientCall(Yw)}getString(e,t){this._stringBuffer=t+`{
|
|
978
|
+
`;let n=this._map.begin();for(;n.notEqual(this._map.end());){let e=n.ptr().first,r=n.ptr().second;this._stringBuffer+=t+` `+e+` : `+r.getString(t+` `)+`
|
|
979
|
+
`,n.preIncrement()}return this._stringBuffer+=t+`}
|
|
980
|
+
`,this._stringBuffer}getMap(e){return this._map}put(e,t){this._map.setValue(e,t)}getKeys(){if(!this._keys){this._keys=new J;let e=this._map.begin();for(;e.notEqual(this._map.end());){let t=e.ptr().first;this._keys.pushBack(t),e.preIncrement()}}return this._keys}getSize(){return this._keys.getSize()}},aT;(e=>{e.CubismJson=Zw,e.JsonArray=rT,e.JsonBoolean=$w,e.JsonError=tT,e.JsonFloat=Qw,e.JsonMap=iT,e.JsonNullvalue=nT,e.JsonString=eT,e.Value=Xw})(aT||={});function oT(e,t){let n=0;for(let t=1;;t++){let r=e.slice(t-1,t);if(r==`e`||r==`-`||r==`E`)continue;let i=e.substring(0,t),a=Number(i);if(isNaN(a))break;n=t}let r=parseFloat(e);return isNaN(r)&&(r=NaN),t[0]=e.slice(n),r}let sT=!1,cT=!1,lT=null,uT=null,dT=Object.freeze({vertexOffset:0,vertexStep:2});function fT(e){e&&=void 0}var pT=class{static startUp(e=null){if(sT)return zw(`CubismFramework.startUp() is already done.`),sT;if(lT=e,lT!=null&&Live2DCubismCore.Logging.csmSetLogFunction(lT.logFunction),sT=!0,sT){let e=Live2DCubismCore.Version.csmGetVersion(),t=(e&4278190080)>>24,n=(e&16711680)>>16,r=e&65535,i=e;zw(`Live2D Cubism Core version: {0}.{1}.{2} ({3})`,(`00`+t).slice(-2),(`00`+n).slice(-2),(`0000`+r).slice(-4),i)}return zw(`CubismFramework.startUp() is complete.`),sT}static cleanUp(){sT=!1,cT=!1,lT=null,uT=null}static initialize(e=0){if(Lw(sT),!sT){Y(`CubismFramework is not started.`);return}if(cT){Y(`CubismFramework.initialize() skipped, already initialized.`);return}Xw.staticInitializeNotForClientCall(),uT=new Cw,Live2DCubismCore.Memory.initializeAmountOfMemory(e),cT=!0,zw(`CubismFramework.initialize() is complete.`)}static dispose(){if(Lw(sT),!sT){Y(`CubismFramework is not started.`);return}if(!cT){Y(`CubismFramework.dispose() skipped, not initialized.`);return}Xw.staticReleaseNotForClientCall(),uT.release(),uT=null,kw.staticRelease(),cT=!1,zw(`CubismFramework.dispose() is complete.`)}static isStarted(){return sT}static isInitialized(){return cT}static coreLogFunction(e){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(e)}static getLoggingLevel(){return lT==null?5:lT.loggingLevel}static getIdManager(){return uT}constructor(){}},mT=(e=>(e[e.LogLevel_Verbose=0]=`LogLevel_Verbose`,e[e.LogLevel_Debug=1]=`LogLevel_Debug`,e[e.LogLevel_Info=2]=`LogLevel_Info`,e[e.LogLevel_Warning=3]=`LogLevel_Warning`,e[e.LogLevel_Error=4]=`LogLevel_Error`,e[e.LogLevel_Off=5]=`LogLevel_Off`,e))(mT||{}),hT;(e=>{e.Constant=dT,e.csmDelete=fT,e.CubismFramework=pT})(hT||={});let gT={LOG_LEVEL_VERBOSE:0,LOG_LEVEL_WARNING:1,LOG_LEVEL_ERROR:2,LOG_LEVEL_NONE:999,logLevel:1,sound:!0,fftSize:512,motionSync:!0,motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500,preserveExpressionOnMotion:!0,cubism:Pw},X={log(e,...t){gT.logLevel<=gT.LOG_LEVEL_VERBOSE&&console.log(`[${e}]`,...t)},warn(e,...t){gT.logLevel<=gT.LOG_LEVEL_WARNING&&console.warn(`[${e}]`,...t)},error(e,...t){gT.logLevel<=gT.LOG_LEVEL_ERROR&&console.error(`[${e}]`,...t)}};function _T(e,t,n){return e<t?t:e>n?n:e}function vT(e){return e*1024*1024}function yT(e,t,n,r,i){let a=t[r];a!==null&&typeof a===e&&(n[i]=a)}function bT(e,t,n,r,i){let a=t[r];Array.isArray(a)&&(n[i]=a.filter(t=>t!==null&&typeof t===e))}function xT(e,t){t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!==`constructor`&&Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))})})}function ST(e){let t=e.lastIndexOf(`/`);return t!=-1&&(e=e.slice(0,t)),t=e.lastIndexOf(`/`),t!==-1&&(e=e.slice(t+1)),e}function CT(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}let wT=/^[a-zA-Z][a-zA-Z0-9+.-]*:/;function TT(e,t){if(!t)return e;if(wT.test(t))return t;if(t.startsWith(`/`))return wT.test(e)?new URL(t,e).toString():t;if(wT.test(e))return new URL(t,e).toString();let n=`http://example.com`,r=e.startsWith(`/`)?n+e:`${n}/${e}`,i=new URL(t,r),a=i.pathname+i.search+i.hash;return!e.startsWith(`/`)&&a.startsWith(`/`)&&(a=a.slice(1)),a}var ET=class extends y{constructor(e,t){super(),K(this,`expressionDataType`,`json`),K(this,`tag`),K(this,`settings`),K(this,`expressions`,[]),K(this,`defaultExpression`),K(this,`currentExpression`),K(this,`reserveExpressionIndex`,-1),K(this,`destroyed`,!1),this.settings=e,this.tag=`ExpressionManager(${e.name})`}init(){this.defaultExpression=this.createDefaultExpression(),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}createDefaultExpression(){return this.createExpression({},void 0)}loadExpression(e){return q(this,null,function*(){if(!this.definitions[e]){X.warn(this.tag,`Undefined expression at [${e}]`);return}if(this.expressions[e]===null){X.warn(this.tag,`Cannot set expression at [${e}] because it's already failed in loading.`);return}if(this.expressions[e])return this.expressions[e];let t=yield this._loadExpression(e);return this.expressions[e]=t,t})}_loadExpression(e){throw Error(`Not implemented.`)}setRandomExpression(){return q(this,null,function*(){if(this.definitions.length){let e=[];for(let t=0;t<this.definitions.length;t++)this.expressions[t]!==null&&this.expressions[t]!==this.currentExpression&&t!==this.reserveExpressionIndex&&e.push(t);if(e.length){let t=Math.floor(Math.random()*e.length);return this.setExpression(t)}}return!1})}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(e){return q(this,null,function*(){if(typeof e!=`number`&&(e=this.getExpressionIndex(e)),!(e>-1&&e<this.definitions.length)||e===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=e;let t=yield this.loadExpression(e);return!t||this.reserveExpressionIndex!==e?!1:(this.reserveExpressionIndex=-1,this.currentExpression=t,this._setExpression(t),!0)})}update(e,t){return!this.isFinished()&&this.updateParameters(e,t)}destroy(){this.destroyed=!0,this.emit(`destroy`);let e=this;e.definitions=void 0,e.expressions=void 0}};let DT=.01;var OT=class{constructor(){K(this,`targetX`,0),K(this,`targetY`,0),K(this,`x`,0),K(this,`y`,0),K(this,`vx`,0),K(this,`vy`,0)}focus(e,t,n=!1){this.targetX=_T(e,-1,1),this.targetY=_T(t,-1,1),n&&(this.x=this.targetX,this.y=this.targetY)}update(e){let t=this.targetX-this.x,n=this.targetY-this.y;if(Math.abs(t)<DT&&Math.abs(n)<DT)return;let r=Math.sqrt(fw(t,2)+fw(n,2)),i=5.333333333333333/(1e3/e),a=t/r*i-this.vx,o=n/r*i-this.vy,s=Math.sqrt(fw(a,2)+fw(o,2)),c=i*.006666666666666667*e;s>c&&(a*=c/s,o*=c/s),this.vx+=a,this.vy+=o;let l=Math.sqrt(fw(this.vx,2)+fw(this.vy,2)),u=.5*(Math.sqrt(fw(c,2)+8*c*r)-c);l>u&&(this.vx*=u/l,this.vy*=u/l),this.x+=this.vx,this.y+=this.vy}},kT=class{constructor(e){K(this,`json`),K(this,`name`),K(this,`url`),K(this,`pose`),K(this,`physics`),this.json=e,this.url=e.url,this.name=ST(this.url)}normalizeName(){(!this.name||this.name.toLowerCase()===`name`)&&(this.name=ST(this.url))}setModelName(...e){for(let t of e){let e=typeof t==`string`?t.trim():``;if(e&&e.toLowerCase()!==`name`){this.name=e;return}}this.normalizeName()}getFileStem(e){return e?e.split(/[/\\]/).filter(Boolean).pop()?.replace(/\.[^.]+$/,``):void 0}resolveURL(e){return TT(this.url,e)}replaceFiles(e){this.moc=e(this.moc,`moc`),this.pose!==void 0&&(this.pose=e(this.pose,`pose`)),this.physics!==void 0&&(this.physics=e(this.physics,`physics`));for(let t=0;t<this.textures.length;t++)this.textures[t]=e(this.textures[t],`textures[${t}]`)}getDefinedFiles(){let e=[];return this.replaceFiles(t=>(e.push(t),t)),e}validateFiles(e){let t=(t,n)=>{let r=this.resolveURL(t);if(!e.includes(r)){if(n)throw Error(`File "${t}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(e=>t(e,!0)),this.getDefinedFiles().filter(e=>t(e,!1))}},AT=(e=>(e[e.NONE=0]=`NONE`,e[e.IDLE=1]=`IDLE`,e[e.NORMAL=2]=`NORMAL`,e[e.FORCE=3]=`FORCE`,e))(AT||{}),jT=class{constructor(){K(this,`tag`),K(this,`debug`,!1),K(this,`currentPriority`,0),K(this,`reservePriority`,0),K(this,`currentGroup`),K(this,`currentIndex`),K(this,`reservedGroup`),K(this,`reservedIndex`),K(this,`reservedIdleGroup`),K(this,`reservedIdleIndex`)}reserve(e,t,n){if(n<=0)return X.log(this.tag,`Cannot start a motion with MotionPriority.NONE.`),!1;if(e===this.currentGroup&&t===this.currentIndex)return X.log(this.tag,`Motion is already playing.`,this.dump(e,t)),!1;if(e===this.reservedGroup&&t===this.reservedIndex||e===this.reservedIdleGroup&&t===this.reservedIdleIndex)return X.log(this.tag,`Motion is already reserved.`,this.dump(e,t)),!1;if(n===1){if(this.currentPriority!==0)return X.log(this.tag,`Cannot start idle motion because another motion is playing.`,this.dump(e,t)),!1;if(this.reservedIdleGroup!==void 0)return X.log(this.tag,`Cannot start idle motion because another idle motion has reserved.`,this.dump(e,t)),!1;this.setReservedIdle(e,t)}else{if(n<3){if(n<=this.currentPriority)return X.log(this.tag,`Cannot start motion because another motion is playing as an equivalent or higher priority.`,this.dump(e,t)),!1;if(n<=this.reservePriority)return X.log(this.tag,`Cannot start motion because another motion has reserved as an equivalent or higher priority.`,this.dump(e,t)),!1}this.setReserved(e,t,n)}return!0}start(e,t,n,r){if(r===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return X.log(this.tag,`Cannot start idle motion because another motion is playing.`,this.dump(t,n)),!1}else{if(t!==this.reservedGroup||n!==this.reservedIndex)return X.log(this.tag,`Cannot start motion because another motion has taken the place.`,this.dump(t,n)),!1;this.setReserved(void 0,void 0,0)}return e?(this.setCurrent(t,n,r),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(e,t,n){this.currentPriority=n,this.currentGroup=e,this.currentIndex=t}setReserved(e,t,n){this.reservePriority=n,this.reservedGroup=e,this.reservedIndex=t}setReservedIdle(e,t){this.reservedIdleGroup=e,this.reservedIdleIndex=t}isActive(e,t){return e===this.currentGroup&&t===this.currentIndex||e===this.reservedGroup&&t===this.reservedIndex||e===this.reservedIdleGroup&&t===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!gT.preserveExpressionOnMotion&&this.currentPriority>1}dump(e,t){return this.debug?`
|
|
981
|
+
<Requested> group = "${e}", index = ${t}
|
|
982
|
+
`+[`currentPriority`,`reservePriority`,`currentGroup`,`currentIndex`,`reservedGroup`,`reservedIndex`,`reservedIdleGroup`,`reservedIdleIndex`].map(e=>`[`+e+`] `+this[e]).join(`
|
|
983
|
+
`):``}};let MT=`SoundManager`,NT=.5,PT=0,FT,IT=new WeakSet;function LT(e){if(!IT.has(e)){try{e.disableAutoPause=!0}catch(e){X.warn(MT,`Failed to disable @pixi/sound auto pause.`,e)}IT.add(e)}return e}function RT(){return typeof PIXI<`u`?PIXI==null?void 0:PIXI.sound:void 0}function zT(){return q(this,null,function*(){let e=RT();return e?LT(e):(FT??=Promise.resolve().then(()=>d(aw(),1)).then(({sound:e})=>LT(e)).catch(e=>(X.warn(MT,`@pixi/sound is not available. Load pixi-sound.js before using motion sounds, speak(), or lip sync.`,e),null)),FT)})}function BT(e,t){try{e.remove(t)}catch(e){X.warn(MT,`Failed to remove sound "${t}".`,e)}}function VT(e){try{e.destroy()}catch(e){X.warn(MT,`Failed to destroy audio.`,e)}}function HT(e){let t=e.media.buffer;if(!(!t||typeof t!=`object`))return typeof t.getChannelData==`function`?t:void 0}var UT=class{static get volume(){return this._volume}static set volume(e){this._volume=(e>1?1:e<0?0:e)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(e,t){return q(this,null,function*(){let n=null,r;try{if(n=yield zT(),!n)throw Error(`@pixi/sound is not available`);r=`live2d-sound-${PT++}`;let t=n,i=r,a=yield new Promise((n,r)=>{let a=t.add(i,{url:e,volume:this._volume,preload:!0,loaded:(t,i)=>{if(t){r(t);return}let o=i??a;if(!o){r(Error(`Error: ${e} failed to load`));return}if(!HT(o)){r(Error(`Error: ${e} is not WebAudioMedia`));return}n(o)}})});return this.aliases.set(a,{alias:i,library:t}),this.audios.push(a),a}catch(i){return n&&r&&BT(n,r),X.warn(MT,`Error occurred on "${e}"`,i),t?.(i),null}})}static play(e,t){e.play({singleInstance:!0,complete:()=>{t?.(),this.dispose(e)}})}static addAnalyzer(e,t){let n=HT(e);if(!n){X.warn(MT,`Cannot create audio analyzer because WebAudio media is unavailable.`);return}let r=t.createBufferSource();r.buffer=n;let i=t.createAnalyser();return i.fftSize=gT.fftSize,i.minDecibels=-90,i.maxDecibels=-10,i.smoothingTimeConstant=.85,r.connect(i),r.start(0),this.analysers.push(i),i}static analyze(e){if(!e)return parseFloat(Math.random().toFixed(1));let t=new Float32Array(e.fftSize);e.getFloatTimeDomainData(t);let n=0;for(let e=0;e<t.length;e++)n+=fw(t[e],2);let r=Math.sqrt(n/t.length),i=20*Math.log10(r||fw(10,-100/20)),a=Math.min(Math.max((i-e.minDecibels)/(e.maxDecibels-e.minDecibels),0),1);return parseFloat(a.toFixed(1))}static dispose(e){try{e.pause()}catch(e){X.warn(MT,`Failed to pause audio.`,e)}let t=this.aliases.get(e);t?(BT(t.library,t.alias),this.aliases.delete(e)):VT(e),CT(this.audios,e)}static destroy(){for(let e=this.contexts.length-1;e>=0;e--)this.contexts[e]?.close().catch(e=>{X.warn(MT,`Failed to close AudioContext.`,e)});for(let e=this.audios.length-1;e>=0;e--)this.dispose(this.audios[e])}};K(UT,`audios`,[]),K(UT,`analysers`,[]),K(UT,`contexts`,[]),K(UT,`aliases`,new WeakMap),K(UT,`_volume`,NT);var WT=class extends y{constructor(e){super(),K(this,`tag`),K(this,`settings`),K(this,`motionGroups`,{}),K(this,`state`,new jT),K(this,`currentAudio`),K(this,`currentAnalyzer`),K(this,`currentContext`),K(this,`playing`,!1),K(this,`destroyed`,!1),K(this,`parent`),this.settings=e.settings,this.tag=`MotionManager(${this.settings.name})`,this.state.tag=this.tag,this.parent=e}init(e){e?.idleMotionGroup&&(this.groups.idle=e.idleMotionGroup),this.setupMotions(e),this.stopAllMotions()}setupMotions(e){if(!this.definitions){X.warn(this.tag,`Motion definitions are not initialized.`);return}for(let e of Object.keys(this.definitions))this.motionGroups[e]=[];let t;switch(e?.motionPreload){case`NONE`:return;case`ALL`:t=Object.keys(this.definitions);break;default:t=[this.groups.idle];break}for(let e of t){let t=this.definitions[e];if(t)for(let n=0;n<t.length;n++)this.loadMotion(e,n)}}loadMotion(e,t){return q(this,null,function*(){var n;if(this.destroyed||!this.getMotionDefinition(e,t))return;let r=(n=this.motionGroups)[e]??(n[e]=[]);if(r[t]===null){X.warn(this.tag,`Cannot start motion at "${e}"[${t}] because it's already failed in loading.`);return}if(r[t])return r[t];let i=yield this._loadMotion(e,t);if(!this.destroyed)return r[t]=i??null,i})}_loadMotion(e,t){throw Error(`Not implemented.`)}initializeAudio(e,t){this.currentAudio=e,UT.volume=t,this.currentContext=e.context.audioContext,this.currentAnalyzer=UT.addAnalyzer(this.currentAudio,this.currentContext)}speak(e){return q(this,arguments,function*(e,{volume:t=NT,expression:n,resetExpression:r=!0,onFinish:i,onError:a}={}){if(!gT.sound)return!1;let o;if(this.currentAudio&&this.currentAudio.isPlaying)return!1;let s,c=e&&e.startsWith(`data:`);if(e&&!c){let t=document.createElement(`a`);t.href=e,e=t.href,s=e}else s=`data:audio/`;let l=e;if(l)try{if(o=yield UT.add(l,(e,t=this)=>{X.error(this.tag,`Error during audio playback:`,e),a?.(e),r&&n&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0}),!o)return!1;this.initializeAudio(o,t)}catch(e){return X.warn(this.tag,`Failed to create audio`,s,e),!1}if(o){let e=!0;try{gT.motionSync&&UT.play(o,()=>{i?.(),r&&n&&this.expressionManager&&this.expressionManager.resetExpression(),this.currentAudio=void 0})}catch(t){X.warn(this.tag,`Failed to play audio`,o.url,t),e=!1}if(!e)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),n&&this.expressionManager&&(yield this.expressionManager.setExpression(n)),this.playing=!0,!0})}startMotion(e,t){return q(this,arguments,function*(e,t,n=AT.NORMAL,{sound:r=void 0,volume:i=NT,expression:a=void 0,resetExpression:o=!0,onFinish:s,onError:c,ignoreParamIds:l=[],loop:u=void 0}={}){if(this.destroyed||!this.state.reserve(e,t,n)||this.currentAudio&&this.currentAudio.isPlaying&&n!=AT.FORCE)return!1;let d=this.getMotionDefinition(e,t);if(!d)return!1;this.currentAudio&&UT.dispose(this.currentAudio);let f,p,m=r&&r.startsWith(`data:`);if(r&&!m){let e=document.createElement(`a`);e.href=r,r=e.href,p=r}else p=this.getSoundFile(d),p&&=this.settings.resolveURL(p);let h=p;if(h)try{f=yield UT.add(h,(e,t=this)=>{X.error(this.tag,`Error during audio playback:`,e),c?.(e),o&&a&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0}),f&&this.initializeAudio(f,i)}catch(e){X.warn(this.tag,`Failed to create audio`,p,e)}let g=yield this.loadMotion(e,t);if(f&&gT.motionSync)try{UT.play(f,(e=this)=>{s?.(),o&&a&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0})}catch(e){X.warn(this.tag,`Failed to play audio`,f.url,e)}return this.state.start(g,e,t,n)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),X.log(this.tag,`Start motion:`,this.getMotionName(d)),this.emit(`motionStart`,e,t,f),a&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(a)),this.playing=!0,g&&this._startMotion(g,void 0,l,u),!0):(f&&(UT.dispose(f),this.currentAudio=void 0),!1)})}startRandomMotion(e,t){return q(this,arguments,function*(e,t,{sound:n,volume:r=NT,expression:i,resetExpression:a=!0,onFinish:o,onError:s,loop:c=void 0}={}){if(this.destroyed)return!1;let l=this.definitions?.[e];if(l?.length){let u=[],d=this.motionGroups[e]??[];for(let t=0;t<l.length;t++)d[t]!==null&&!this.state.isActive(e,t)&&u.push(t);if(u.length){let l=u[Math.floor(Math.random()*u.length)];return this.startMotion(e,l,t,{sound:n,volume:r,expression:i,resetExpression:a,onFinish:o,onError:s,loop:c})}}return!1})}stopSpeaking(){this.currentAudio&&=(UT.dispose(this.currentAudio),void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(e,t){var n;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit(`motionFinish`)),this.state.shouldOverrideExpression()&&((n=this.expressionManager)==null||n.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,AT.IDLE)),this.updateParameters(e,t)}mouthSync(){return this.currentAnalyzer?UT.analyze(this.currentAnalyzer):0}destroy(){var e;this.destroyed=!0,this.emit(`destroy`),this.stopAllMotions(),(e=this.expressionManager)==null||e.destroy();let t=this;t.definitions=void 0,t.motionGroups=void 0}getMotionAndApplyExpression(e,t,n){return q(this,null,function*(){if(this.destroyed||!this.state.reserve(e,t,AT.FORCE))return null;let r=this.getMotionDefinition(e,t);if(!r)return null;this.currentAudio&&UT.dispose(this.currentAudio);let i=yield this.loadMotion(e,t);return this.state.start(i,e,t,AT.FORCE)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),X.log(this.tag,`Start motion:`,this.getMotionName(r)),this.emit(`motionStart`,e,t,void 0),n&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(n)),i):null})}getMotionDefinition(e,t){let n=this.definitions?.[e]?.[t];return n||X.warn(this.tag,`Undefined motion at "${e}"[${t}]`),n}};function GT(e,t){e.a=t,e.b=0,e.c=0,e.d=t}function KT(e){let t=[];for(let[n,r]of Object.entries(e))typeof r==`number`&&t.push([n,r]);return t}function qT(e,t,n,r){let i=mw({width:2,height:2},r),a=i.width??2,o=i.height??2;e.identity(),e.scale(a/2,o/2);let s=t*e.a,c=n*e.d,l=i.x!==void 0&&i.x-a/2||i.centerX!==void 0&&i.centerX||i.left!==void 0&&i.left-a/2||i.right!==void 0&&i.right+a/2||0,u=i.y!==void 0&&i.y-o/2||i.centerY!==void 0&&i.centerY||i.top!==void 0&&i.top-o/2||i.bottom!==void 0&&i.bottom+o/2||0;return e.translate(s*l,-c*u),{width:s,height:c}}function JT(e,t){return 2*t*e.scale}function YT(e){return 2*e.scale}function XT(e,t,n){e.scale=n/(2*t)}function ZT(e,t){e.scale=t/2}function QT(e,t){e.x=t}function $T(e,t){e.y=t}function eE(e,t,n){QT(e,n-JT(e,t)/2)}function tE(e,t){$T(e,t-YT(e)/2)}function nE(e,t,n){QT(e,n-JT(e,t))}function rE(e,t){$T(e,t-YT(e))}function iE(e,t,n,r){if(t<=0||n<=0)return e.identity(),{width:0,height:0};let i=KT(r),a=t/n,o={scale:1,x:0,y:0};for(let[e,t]of i)e===`width`?XT(o,a,t):e===`height`&&ZT(o,t);for(let[e,t]of i)e===`x`?QT(o,t):e===`y`?$T(o,t):e===`centerX`?eE(o,a,t):e===`centerY`?tE(o,t):e===`top`?$T(o,t):e===`bottom`?rE(o,t):e===`left`?QT(o,t):e===`right`&&nE(o,a,t);let s=n/2,c=2*a/2;return e.identity(),GT(e,o.scale),e.tx=s*(o.x+c)-t*o.scale/2,e.ty=s*(1-o.y)-n*o.scale/2,{width:t*o.scale,height:n*o.scale}}function aE(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=typeof e.id==`string`?e.id:typeof e.Id==`string`?e.Id:void 0,a=typeof e.name==`string`?e.name:typeof e.Name==`string`?e.Name:void 0;!i||!a||n.push({id:i,name:a,index:t(i)})}return n}let oE={x:0,y:0,width:0,height:0};var sE=class extends y{constructor(){super(...arguments),K(this,`focusController`,new OT),K(this,`pose`),K(this,`physics`),K(this,`originalWidth`,0),K(this,`originalHeight`,0),K(this,`width`,0),K(this,`height`,0),K(this,`localTransform`,new j),K(this,`drawingMatrix`,new j),K(this,`hitAreas`,{}),K(this,`textureFlipY`,!1),K(this,`viewport`,[0,0,0,0]),K(this,`destroyed`,!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){let e=this,t=this.getSize();e.originalWidth=t[0],e.originalHeight=t[1];let n=qT(this.localTransform,this.originalWidth,this.originalHeight,this.getLayout());e.width=n.width,e.height=n.height}setupHitAreas(){let e=this.getHitAreaDefs();this.hitAreas={};for(let t of e)t.name&&(this.hitAreas[t.name]=t)}hitTest(e,t){return Object.keys(this.hitAreas).filter(n=>this.isHit(n,e,t))}isHit(e,t,n){let r=this.hitAreas[e];if(!r)return!1;let i=r.index;if(i<0){if(!r.id||(i=this.getDrawableIndex(r.id),i<0))return!1;r.index=i}let a=this.getDrawableBounds(i,oE);return a.x<=t&&t<=a.x+a.width&&a.y<=n&&n<=a.y+a.height}getDrawableBounds(e,t){let n=this.getDrawableVertices(e),r=n[0],i=n[0],a=n[1],o=n[1];for(let e=0;e<n.length;e+=2){let t=n[e],s=n[e+1];r=Math.min(t,r),i=Math.max(t,i),a=Math.min(s,a),o=Math.max(s,o)}return t??={},t.x=r,t.y=a,t.width=i-r,t.height=o-a,t}updateTransform(e){this.drawingMatrix.copyFrom(e).append(this.localTransform)}update(e,t){this.focusController.update(e)}destroy(){this.destroyed=!0,this.emit(`destroy`),this.motionManager.destroy(),this.motionManager=void 0,this.parallelMotionManager.forEach(e=>e.destroy()),this.parallelMotionManager=[]}updateMotions(e,t){this.emit(`beforeMotionUpdate`);let n=this.motionManager.update(e,t),r=this.parallelMotionManager.map(n=>n.update(e,t)),i=n||r.reduce((e,t)=>e||t,!1);return this.emit(`afterMotionUpdate`),i}},cE=class extends Error{constructor(e,t,n,r=!1){super(e),this.url=t,this.status=n,this.aborted=r}};let lE=class e{static createXHR(t,n,r,i,a){let o=new XMLHttpRequest;if(e.allXhrSet.add(o),t){let n=e.xhrMap.get(t);n?n.add(o):(n=new Set([o]),e.xhrMap.set(t,n))}return o.open(`GET`,n),o.responseType=r,o.onload=()=>{var e;(o.status===200||o.status===0)&&o.response?i(o.response):(e=o.onerror)==null||e.call(o,new ProgressEvent(`error`))},o.onerror=()=>{X.warn(`XHRLoader`,`Failed to load resource as ${o.responseType} (Status ${o.status}): ${n}`),a(new cE(`Network error.`,n,o.status))},o.onabort=()=>a(new cE(`Aborted.`,n,o.status,!0)),o.onloadend=()=>{var n;e.allXhrSet.delete(o),t&&((n=e.xhrMap.get(t))==null||n.delete(o))},o}static cancelXHRs(){var t;(t=e.xhrMap.get(this))==null||t.forEach(t=>{t.abort(),e.allXhrSet.delete(t)}),e.xhrMap.delete(this)}static release(){e.allXhrSet.forEach(e=>e.abort()),e.allXhrSet.clear(),e.xhrMap=new WeakMap}};K(lE,`xhrMap`,new WeakMap),K(lE,`allXhrSet`,new Set),K(lE,`loader`,e=>new Promise((t,n)=>{let r=e.target,i=e.target&&typeof lE.cancelXHRs==`function`?lE.cancelXHRs.bind(e.target):void 0,a=lE.createXHR(e.target,e.settings?e.settings.resolveURL(e.url):e.url,e.type,n=>{e.result=n,t()},n);if(e.target&&i&&typeof r.listeners==`function`&&typeof r.once==`function`){let e=r.listeners(`destroy`);(!Array.isArray(e)||!e.includes(i))&&r.once(`destroy`,i)}a.send()}));let uE=lE;function dE(e,t){let n=-1;return r(0);function r(i,a){if(a)return Promise.reject(a);if(i<=n)return Promise.reject(Error(`next() called multiple times`));n=i;let o=e[i];if(!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,i+1)))}catch(e){let t=e instanceof Error?e:Error(String(e));return Promise.reject(t)}}}var fE=class{static load(e){return q(this,null,function*(){return yield dE(this.middlewares,e),e.result})}};K(fE,`middlewares`,[uE.loader]);var pE=class e extends kT{constructor(t){if(super(t),K(this,`moc`),K(this,`textures`),K(this,`layout`),K(this,`hitAreas`),K(this,`initParams`),K(this,`initOpacities`),K(this,`expressions`),K(this,`motions`,{}),!e.isValidJSON(t))throw TypeError(`Invalid JSON.`);this.moc=t.model,bT(`string`,t,this,`textures`,`textures`),this.copy(t)}static isValidJSON(e){if(!e||typeof e!=`object`)return!1;let t=Array.isArray(e.textures)?e.textures.every(e=>typeof e==`string`):!1;return typeof e.model==`string`&&t}copy(e){yT(`string`,e,this,`name`,`name`),yT(`string`,e,this,`pose`,`pose`),yT(`string`,e,this,`physics`,`physics`),yT(`object`,e,this,`layout`,`layout`),yT(`object`,e,this,`motions`,`motions`),bT(`object`,e,this,`hit_areas`,`hitAreas`),bT(`object`,e,this,`expressions`,`expressions`),bT(`object`,e,this,`init_params`,`initParams`),bT(`object`,e,this,`init_opacities`,`initOpacities`);let t=this.getFileStem(this.moc);this.setModelName(this.name,t)}replaceFiles(e){super.replaceFiles(e);for(let[t,n]of Object.entries(this.motions))for(let r=0;r<n.length;r++)n[r].file=e(n[r].file,`motions.${t}[${r}].file`),n[r].sound!==void 0&&(n[r].sound=e(n[r].sound,`motions.${t}[${r}].sound`));if(this.expressions)for(let t=0;t<this.expressions.length;t++)this.expressions[t].file=e(this.expressions[t].file,`expressions[${t}].file`)}};function mE({lod:e,effectiveScale:t,textureWidth:n,textureHeight:r,lodScaleThreshold:i,lodTextureSizeThreshold:a,lodMaxLevel:o}){if(hE(e)!==`single-auto`||!Number.isFinite(t)||t<=0)return;let s=Math.floor(n),c=Math.floor(r);if(s<=1||c<=1||t>=_E(i,.5))return;let l=_E(a,4096);if(Math.max(s,c)<l)return;let u=Math.round(Math.log2(1/t)),d=Math.max(1,Math.floor(Math.log2(Math.max(s,c)))),f=Math.min(d,vE(o,d)),p=yE(Math.max(1,u),1,f),m=fw(2,p);return{level:p,width:Math.max(1,Math.round(s/m)),height:Math.max(1,Math.round(c/m))}}function hE(e){return e===!1||e===`single-auto`?e:`full`}function gE(e){return e===`nearest`?`nearest`:`linear`}function _E(e,t){return e!==void 0&&Number.isFinite(e)&&e>0?e:t}function vE(e,t){return e!==void 0&&Number.isFinite(e)&&e>=1?Math.floor(e):t}function yE(e,t,n){return Math.min(n,Math.max(t,e))}function bE(e,t={}){let n=GC.config,r=n?.crossOrigin,i=n?.preferCreateImageBitmap,a=n?.preferWorkers;return t.crossOrigin!==void 0&&n&&(n.crossOrigin=t.crossOrigin),t.preferCreateImageBitmap===!1&&n&&(n.preferCreateImageBitmap=!1,n.preferWorkers=!1),nw.load({src:e,data:{autoGenerateMipmaps:hE(t.lod)===`full`}}).catch(e=>{throw e instanceof Error?e:Error(`Texture loading error`,{cause:e})}).finally(()=>{n&&(n.crossOrigin=r??n.crossOrigin,t.preferCreateImageBitmap===!1&&(n.preferCreateImageBitmap=i??n.preferCreateImageBitmap,n.preferWorkers=a??n.preferWorkers))})}function xE(){}let SE=`Live2DFactory`,CE=(e,t)=>q(null,null,function*(){if(typeof e.source==`string`){let t=yield fE.load({url:e.source,type:`json`,target:e.live2dModel});t.url=typeof t.url==`string`?t.url:e.source,e.source=t,e.live2dModel.emit(`settingsJSONLoaded`,t)}return t()}),wE=(e,t)=>q(null,null,function*(){if(e.source instanceof kT)return e.settings=e.source,t();if(typeof e.source==`object`){let n=ME.findRuntime(e.source);if(n){let r=n.createModelSettings(e.source);return e.settings=r,e.live2dModel.emit(`settingsLoaded`,r),t()}}let n=e.source&&typeof e.source.url==`string`?e.source.url:void 0,r=ME.runtimes.map(e=>e.version).join(`, `);if(ME.runtimes.length===0)throw TypeError([`Unknown settings format: no Live2D runtimes registered.`,`Import a published runtime entry before loading models (e.g. "<package>/cubism" for Cubism 3/4/5, "<package>/cubism-legacy" for Cubism 2).`,n?`Settings URL: ${n}`:void 0].filter(Boolean).join(`
|
|
984
|
+
`));let i=(()=>{try{return!e.source||typeof e.source!=`object`||Array.isArray(e.source)?void 0:Object.keys(e.source).slice(0,30).join(`, `)}catch{return}})();throw TypeError([`Unknown settings format: no matching runtime found for the loaded settings JSON.`,r?`Registered runtimes (versions): ${r}`:void 0,i?`Settings JSON keys: ${i}`:void 0,n?`Settings URL: ${n}`:void 0].filter(Boolean).join(`
|
|
985
|
+
`))}),TE=(e,t)=>{if(e.settings){let n=ME.findRuntime(e.settings);if(n)return n.ready().then(()=>t())}return t()},EE=(e,t)=>q(null,null,function*(){yield t();let n=e.internalModel;if(n){let t=e.settings,r=ME.findRuntime(t);if(r){let i=[],a=t instanceof pE?`json`:`arraybuffer`;t.pose&&i.push(fE.load({settings:t,url:t.pose,type:a,target:n}).then(t=>{n.pose=r.createPose(n.coreModel,t),e.live2dModel.emit(`poseLoaded`,n.pose)}).catch(t=>{e.live2dModel.emit(`poseLoadError`,t),X.warn(SE,`Failed to load pose.`,t)})),t.physics&&i.push(fE.load({settings:t,url:t.physics,type:a,target:n}).then(t=>{n.physics=r.createPhysics(n.coreModel,t),e.live2dModel.emit(`physicsLoaded`,n.physics)}).catch(t=>{e.live2dModel.emit(`physicsLoadError`,t),X.warn(SE,`Failed to load physics.`,t)})),i.length&&(yield Promise.all(i))}}}),DE=(e,t)=>q(null,null,function*(){if(e.settings){let n=e.live2dModel,r=mw({crossOrigin:e.options.crossOrigin},e.options.textureOptions);e.settings instanceof pE&&(r.preferCreateImageBitmap=!1);let i=Promise.all(e.settings.textures.map(t=>bE(e.settings.resolveURL(t),r)));if(i.catch(xE),yield t(),e.internalModel)n.internalModel=e.internalModel,n.emit(`modelLoaded`,e.internalModel);else throw TypeError(`Missing internal model.`);n.textures=yield i,n.emit(`textureLoaded`,n.textures)}else throw TypeError(`Missing settings.`)}),OE=(e,t)=>q(null,null,function*(){let n=e.settings;if(n instanceof kT){let r=ME.findRuntime(n);if(!r)throw TypeError(`Unknown model settings.`);let i=yield fE.load({settings:n,url:n.moc,type:`arraybuffer`,target:e.live2dModel});if(!r.isValidMoc(i))throw Error(`Invalid moc data`);let a=r.createCoreModel(i);return e.internalModel=r.createInternalModel(a,n,e.options),t()}throw TypeError(`Missing settings.`)}),kE=class e{static resolveURL(t,n){let r=e.filesMap[t]?.[n];if(r===void 0)throw Error(`Cannot find this file from uploaded files: `+n);return r}static upload(t,n){let r={};for(let e of n.getDefinedFiles()){let i=decodeURI(TT(n.url,e)),a=t.find(e=>e.webkitRelativePath===i);a&&(r[e]=URL.createObjectURL(a))}e.filesMap[n._objectURL]=r}static createSettings(t){return q(this,null,function*(){let n=t.find(e=>e.name.endsWith(`model.json`)||e.name.endsWith(`model3.json`));if(!n)throw TypeError(`Settings file not found`);let r=yield e.readText(n),i=JSON.parse(r);i.url=n.webkitRelativePath;let a=ME.findRuntime(i);if(!a)throw Error(`Unknown settings JSON`);let o=a.createModelSettings(i);return o._objectURL=URL.createObjectURL(n),o})}static readText(e){return q(this,null,function*(){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsText(e,`utf8`)})})}};K(kE,`live2dFactory`),K(kE,`filesMap`,{}),K(kE,`factory`,(e,t)=>q(null,null,function*(){if(Array.isArray(e.source)&&e.source[0]instanceof File){let t=e.source,n=t.settings;if(!n)n=yield kE.createSettings(t);else if(!n._objectURL)throw Error(`"_objectURL" must be specified in ModelSettings`);n.validateFiles(t.map(e=>encodeURI(e.webkitRelativePath))),kE.upload(t,n),n.resolveURL=function(e){return kE.resolveURL(this._objectURL,e)},e.source=n,e.live2dModel.once(`modelLoaded`,e=>{e.once(`destroy`,function(){let e=this.settings._objectURL;if(URL.revokeObjectURL(e),kE.filesMap[e])for(let t of Object.values(kE.filesMap[e]))URL.revokeObjectURL(t);delete kE.filesMap[e]})})}return t()}));let AE=kE,jE=class e{static registerRuntime(t){e.runtimes.push(t),e.runtimes.sort((e,t)=>t.version-e.version)}static findRuntime(t){for(let n of e.runtimes)if(n.test(t))return n}static setupLive2DModel(t,n,r){return q(this,null,function*(){let i=new Promise(e=>t.once(`textureLoaded`,e)),a=new Promise(e=>t.once(`modelLoaded`,e)),o=Promise.all([i,a]).then(()=>t.emit(`ready`));yield dE(e.live2DModelMiddlewares,{live2dModel:t,source:n,options:r||{}}),yield o,t.emit(`load`)})}static loadMotion(t,n,r){let i=e=>t.emit(`motionLoadError`,n,r,e);try{let a=t.definitions[n]?.[r];if(!a)return Promise.resolve(void 0);t.once(`destroy`,()=>e.releaseMotionTasks(t));let o=e.motionTasksMap.get(t);o||(o={},e.motionTasksMap.set(t,o));let s=o[n];s||(s=[],o[n]=s);let c=t.getMotionFile(a);return s[r]??(s[r]=fE.load({url:c,settings:t.settings,type:t.motionDataType,target:t}).then(i=>{let o=e.motionTasksMap.get(t)?.[n];o&&(o[r]=void 0);let s=i,c=t.createMotion(s,n,a);return t.emit(`motionLoaded`,n,r,c),c}).catch(e=>{X.warn(t.tag,`Failed to load motion: ${c}
|
|
986
|
+
`,e),i(e)})),s[r]}catch(e){X.warn(t.tag,`Failed to load motion at "${n}"[${r}]
|
|
987
|
+
`,e),i(e)}return Promise.resolve(void 0)}static loadExpression(t,n){let r=e=>t.emit(`expressionLoadError`,n,e);try{let i=t.definitions[n];if(!i)return Promise.resolve(void 0);t.once(`destroy`,()=>e.releaseExpressionTasks(t));let a=e.expressionTasksMap.get(t);a||(a=[],e.expressionTasksMap.set(t,a));let o=t.getExpressionFile(i),s=t.expressionDataType??`json`;return a[n]??(a[n]=fE.load({url:o,settings:t.settings,type:s,target:t}).then(r=>{let a=e.expressionTasksMap.get(t);a&&(a[n]=void 0);let o=r,s=t.createExpression(o,i);return t.emit(`expressionLoaded`,n,s),s}).catch(e=>{X.warn(t.tag,`Failed to load expression: ${o}
|
|
988
|
+
`,e),r(e)})),a[n]}catch(e){X.warn(t.tag,`Failed to load expression at [${n}]
|
|
989
|
+
`,e),r(e)}return Promise.resolve(void 0)}static releaseMotionTasks(t){e.motionTasksMap.delete(t)}static releaseExpressionTasks(t){e.expressionTasksMap.delete(t)}};K(jE,`runtimes`,[]),K(jE,`urlToJSON`,CE),K(jE,`jsonToSettings`,wE),K(jE,`waitUntilReady`,TE),K(jE,`setupOptionals`,EE),K(jE,`setupEssentials`,DE),K(jE,`createInternalModel`,OE),K(jE,`live2DModelMiddlewares`,[AE.factory,CE,wE,TE,EE,DE,OE]),K(jE,`motionTasksMap`,new WeakMap),K(jE,`expressionTasksMap`,new WeakMap);let ME=jE;WT.prototype._loadMotion=function(e,t){return ME.loadMotion(this,e,t)},ET.prototype._loadExpression=function(e){return ME.loadExpression(this,e)},AE.live2dFactory=ME;let NE=class e{constructor(t,{autoUpdate:n=!0,autoHitTest:r=!0,autoFocus:i=!0,autoInteract:a,ticker:o}={}){K(this,`model`),K(this,`destroyed`,!1),K(this,`_ticker`),K(this,`_autoUpdate`,!1),K(this,`_autoHitTest`,!1),K(this,`_autoFocus`,!1),o??=e.defaultTicker??(typeof PIXI<`u`?PIXI.Ticker.shared:$n.shared),a!==void 0&&(r=a,i=a,X.warn(t.tag,`options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.`)),this.model=t,this.ticker=o,this.autoUpdate=n,this.autoHitTest=r,this.autoFocus=i,(r||i)&&(this.model.eventMode=`static`)}get ticker(){return this._ticker}set ticker(e){var t,n;this._ticker&&this._ticker.remove(FE,this),this._ticker=e,this._autoUpdate&&((t=this._ticker)==null||t.add(FE,this),(n=this._ticker)==null||n.start())}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){var t;this.destroyed||(e?this._ticker?(this._ticker.add(FE,this),this._autoUpdate=!0):X.warn(this.model.tag,`No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI).`):((t=this._ticker)==null||t.remove(FE,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(e){e!==this.autoHitTest&&(e?this.model.on(`pointertap`,IE,this):this.model.off(`pointertap`,IE,this),this._autoHitTest=e)}get autoFocus(){return this._autoFocus}set autoFocus(e){e!==this.autoFocus&&(e?(this.model.on(`globalpointermove`,LE,this),this.model.on(`pointermove`,LE,this)):(this.model.off(`globalpointermove`,LE,this),this.model.off(`pointermove`,LE,this)),this._autoFocus=e)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(e){this.autoHitTest=e,this.autoFocus=e}onTickerUpdate(){let e=this.ticker.deltaMS;this.model.update(e)}onTap(e){this.model.tap(e.global.x,e.global.y)}onPointerMove(e){this.model.focus(e.global.x,e.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};K(NE,`defaultTicker`);let PE=NE;function FE(){this.onTickerUpdate()}function IE(e){this.onTap(e)}function LE(e){this.onPointerMove(e)}var RE=class extends iw{};let zE=new je,BE=new j,VE=new j,HE={x:0,y:0,width:0,height:0},UE=new xt,WE=!1;var GE=class{constructor(e){this.renderer=e}addPrepare(e,t){var n,r;(r=(n=this.renderer.renderPipes.batch)?.break)==null||r.call(n,t),t.add({renderPipeId:`live2d`,action:`prepare`,canBundle:!1,prepare:e})}addRenderable(e,t){var n,r;(r=(n=this.renderer.renderPipes.batch)?.break)==null||r.call(n,t),t.add(e)}execute(e){if(!(e instanceof ZE)){e.prepare();return}let t=e;!t.visible||t.alpha<=0||t.renderLive2D(this.renderer)}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}destroy(){}};K(GE,`extension`,{type:[f.WebGLPipes],name:`live2d`});let KE=GE;function qE(e){let t=e;t.renderPipes.live2d||(WE||(WE=!0,console.warn("[untitled-pixi-live2d-engine] Lazy Live2D render pipe registration is deprecated. Register Live2DPlugin explicitly with `extensions.add(Live2DPlugin)` before creating the Pixi renderer.")),t.renderPipes.live2d=new GE(e))}function JE(e){return Math.max(Math.hypot(e.a,e.b),Math.hypot(e.c,e.d))}function YE(e){if(!e||typeof e!=`object`)return!1;let{width:t,height:n}=e;return typeof t==`number`&&t>0&&typeof n==`number`&&n>0}function XE(e,t,n,r,i){let a=e.source.resource;if(!YE(a))return;let o=B.get().createCanvas(n,r),s=o.getContext(`2d`);if(!s)return;try{s.clearRect(0,0,n,r),s.imageSmoothingEnabled=i!==`nearest`,`imageSmoothingQuality`in s&&i!==`nearest`&&(s.imageSmoothingQuality=`high`),s.drawImage(a,0,0,e.source.pixelWidth,e.source.pixelHeight,0,0,n,r)}catch{return}let c=`${e.label??e.source.label??`Live2DTexture`} LOD ${t}`;return new R({label:c,source:new la({resource:o,width:n,height:r,resolution:1,scaleMode:gE(i),autoGenerateMipmaps:!1,label:c})})}var ZE=class extends Kn{constructor(e){super(),K(this,`renderPipeId`,`live2d`),K(this,`tag`,`Live2DModel(uninitialized)`),K(this,`internalModel`),K(this,`textures`,[]),K(this,`textureOptions`),K(this,`anchorMode`),K(this,`textureLODStates`,[]),K(this,`textureLODFailures`,[]),K(this,`transform`,new RE),K(this,`anchor`),K(this,`_bounds`,new xt),K(this,`_boundsDirty`,!0),K(this,`_boundsRetryAfterDraw`,!1),K(this,`gl`,null),K(this,`elapsedTime`,0),K(this,`deltaTime`,0),K(this,`automator`),K(this,`currentGlId`,0),K(this,`renderLive2D`,e=>{if(!(e instanceof H_))throw Error(`Renderer is not supported`);e.geometry.resetState(),e.shader.resetState(),e.texture.resetState();let t=!1;this.gl!==e.gl&&(this.gl=e.gl,this.internalModel.updateWebGLContext(e.gl,this.generateUID()),t=!0);let{projectionMatrix:n,offset:r,worldTransformMatrix:i}=e.globalUniforms.globalUniformData,a=VE.copyFrom(i).append(this.groupTransform),o=JE(a)*e.resolution;for(let n=0;n<this.textures.length;n++){let r=this.textures[n],i=this.resolveTextureForRender(n,r,o);try{this.uploadTextureForRender(e,i,t)}catch{if(i===r)throw Error(`Failed to upload Live2D texture.`);let a=this.textureLODStates[n];a?.texture===i&&(this.markTextureLODFailure(n,r,a.level),this.destroyTextureLODState(n)),i=r,this.uploadTextureForRender(e,i,t)}this.internalModel.bindTexture(n,e.texture.getGlSource(i.source).texture)}let s=e.renderTarget.viewport,c=e.renderTarget.renderTarget,l=s.y;c?.isRoot&&(l=c.colorTexture.source.pixelHeight-s.height-s.y),this.internalModel.viewport=[s.x,l,s.width,s.height];let u=this.deltaTime;this.deltaTime=0,u&&this.internalModel.update(u,this.elapsedTime),a.tx-=r?.x??0,a.ty-=r?.y??0;let d=BE.copyFrom(n).append(a);this.internalModel.updateTransform(d),this.internalModel.draw(e.gl),this._boundsRetryAfterDraw&&this.updateDrawableBounds(!0),e.state.resetState(),e.texture.resetState();let f=e.renderTarget?.defaultClearColor,p=e.renderTarget?.adaptor?._clearColorCache;f&&(e.gl.clearColor(f[0],f[1],f[2],f[3]),p&&(p[0]=f[0],p[1]=f[1],p[2]=f[2],p[3]=f[3]))}),this.textureOptions=e?.textureOptions,this.anchorMode=e?.anchorMode??`canvas`,this.anchor=new Ie({_onUpdate:()=>this.onAnchorChange()},0,0),this.automator=new PE(this,e),this.once(`modelLoaded`,()=>this.initializeOnModelLoad(e))}get isRenderable(){return!0}get canBundle(){return!1}static from(e,t){return q(this,null,function*(){let n=new this(t);return yield ME.setupLive2DModel(n,e,t),n})}static fromSync(e,t){let n=new this(t);return ME.setupLive2DModel(n,e,t).then(()=>(t?.onLoad)?.call(t)).catch(e=>(t?.onError)?.call(t,e)),n}static registerTicker(e){PE.defaultTicker=e.shared}get bounds(){return this.internalModel?(this._boundsDirty&&this.updateDrawableBounds(),this._bounds):(this._bounds.set(0,0,0,0),this._bounds)}updateDrawableBounds(e=!1){if(!this.internalModel){this._bounds.set(0,0,0,0),this._boundsDirty=!1;return}let t=this.internalModel.getDrawableIDs();UE.clear();for(let e=0;e<t.length;e++){let n=t[e],r=this.internalModel.getDrawableIndex(n);if(r<0)continue;let i=this.internalModel.getDrawableBounds(r,HE);!Number.isFinite(i.x)||!Number.isFinite(i.y)||!Number.isFinite(i.width)||!Number.isFinite(i.height)||UE.addFrame(i.x,i.y,i.x+i.width,i.y+i.height,j.IDENTITY)}if(this._bounds.clear(),UE.isValid&&UE.isPositive)this._bounds.addFrame(UE.minX,UE.minY,UE.maxX,UE.maxY,this.internalModel.localTransform),this._boundsRetryAfterDraw=!1;else{let e=this.internalModel.originalWidth||this.internalModel.width,t=this.internalModel.originalHeight||this.internalModel.height;this._bounds.addFrame(0,0,e,t,this.internalModel.localTransform),this._boundsRetryAfterDraw=!0}this._boundsDirty=!1,this._didViewChangeTick++,e&&this.anchorMode===`drawable`&&this.onAnchorChange()}prepareForRender(){if(!this.internalModel)return;let e=this.deltaTime;this.deltaTime=0,e&&this.internalModel.update(e,this.elapsedTime),this.updateDrawableBounds()}generateUID(){return++this.currentGlId}collectRenderables(e,t,n){var r,i,a,o;if(this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild)return;this.sortableChildren&&this.sortChildren(),qE(t);let s=t.renderPipes,c=()=>{s.live2d.addRenderable(this,e)},l=()=>{let r=this.children,i=r.length;for(let a=0;a<i;a++)r[a].collectRenderables(e,t,n)},u=this.effects;if(u){u.length&&s.live2d.addPrepare(()=>this.prepareForRender(),e);for(let t=0;t<u.length;t++){let n=u[t],a=n.filters;if(a)for(let e of a)e&&typeof e.resolution==`number`&&e.resolution===1&&(e.resolution=`inherit`);(i=(r=s[n.pipe])?.push)==null||i.call(r,n,this,e)}c(),l();for(let t=u.length-1;t>=0;t--){let n=u[t];(o=(a=s[n.pipe])?.pop)==null||o.call(a,n,this,e)}}else c(),l()}initializeOnModelLoad(e){this.tag=`Live2DModel(${this.internalModel.settings.name})`,this.updateDrawableBounds(!0),this.anchorMode===`canvas`&&this.onAnchorChange()}onAnchorChange(){if(!(!this.internalModel||!this.pivot))if(this.anchorMode===`drawable`){let e=this.bounds;this.pivot.set(e.minX+this.anchor.x*e.width,e.minY+this.anchor.y*e.height)}else this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(e,t,n){return q(this,arguments,function*(e,t,n,{sound:r=void 0,volume:i=NT,expression:a=void 0,resetExpression:o=!0,onFinish:s,onError:c,loop:l=void 0}={}){return t===void 0?this.internalModel.motionManager.startRandomMotion(e,n,{sound:r,volume:i,expression:a,resetExpression:o,onFinish:s,onError:c,loop:l}):this.internalModel.motionManager.startMotion(e,t,n,{sound:r,volume:i,expression:a,resetExpression:o,onFinish:s,onError:c,loop:l})})}motionLastFrame(e,t){return q(this,arguments,function*(e,t,{expression:n=void 0}={}){return this.internalModel.motionManager.motionLastFrame(e,t,{expression:n})})}parallelMotion(e){return q(this,null,function*(){this.internalModel.extendParallelMotionManager(e.length);let t=e.map((e,t)=>this.internalModel.parallelMotionManager[t].startMotion(e.group,e.index,e.priority,{ignoreParamIds:e.ignoreParamIds,loop:e.loop})),n=[];for(let e of t)n.push(yield e);return n})}parallelLastFrame(e){return q(this,null,function*(){this.internalModel.extendParallelMotionManager(e.length);let t=e.map((e,t)=>this.internalModel.parallelMotionManager[t].playMotionLastFrame(e.group,e.index)),n=[];for(let e of t)n.push(yield e);return n})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(e,{volume:t=NT,expression:n,resetExpression:r=!0,onFinish:i,onError:a}={}){return this.internalModel.motionManager.speak(e,{volume:t,expression:n,resetExpression:r,onFinish:i,onError:a})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(e){return this.internalModel.motionManager.expressionManager?e===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(e):Promise.resolve(!1)}focus(e,t,n=!1){zE.x=e,zE.y=t,this.toModelPosition(zE,zE,!0);let r=zE.x/this.internalModel.originalWidth*2-1,i=zE.y/this.internalModel.originalHeight*2-1,a=Math.atan2(i,r);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),n)}tap(e,t){let n=this.hitTest(e,t);n.length&&this.emit(`hit`,n)}hitTest(e,t){return zE.x=e,zE.y=t,this.toModelPosition(zE,zE),this.internalModel.hitTest(zE.x,zE.y)}toModelPosition(e,t=e.clone(),n){return n||this.updateLocalTransform(),this.toLocal(e,void 0,t,n),this.internalModel.localTransform.applyInverse(t,t),t}containsPoint(e){return this.bounds.containsPoint(e.x,e.y)}_calculateBounds(){if(!this.internalModel){this.getBounds().set(0,0,0,0);return}let e=this.bounds;this.getBounds().addFrame(e.minX,e.minY,e.maxX,e.maxY,this.transform.matrix)}update(e){this.deltaTime+=e,this.elapsedTime+=e}resolveTextureForRender(e,t,n){let r=mE(hw(mw({},this.textureOptions),{effectiveScale:n,textureWidth:t.source.pixelWidth,textureHeight:t.source.pixelHeight}));if(!r)return t;let i=this.textureLODFailures[e];if(i?.source===t&&i.levels.has(r.level))return t;let a=this.textureLODStates[e];if(a?.source===t&&a.level===r.level&&!a.texture.destroyed)return a.texture;this.destroyTextureLODState(e);let o=XE(t,r.level,r.width,r.height,this.textureOptions?.lodFilter);return o?(this.textureLODStates[e]={source:t,level:r.level,texture:o},o):(this.markTextureLODFailure(e,t,r.level),t)}markTextureLODFailure(e,t,n){let r=this.textureLODFailures[e];r?.source!==t&&(r={source:t,levels:new Set},this.textureLODFailures[e]=r),r.levels.add(n)}destroyTextureLODState(e){let t=this.textureLODStates[e];t&&(t.texture.destroy(!0),this.textureLODStates[e]=void 0)}destroyTextureLODStates(){for(let e=0;e<this.textureLODStates.length;e++)this.destroyTextureLODState(e);this.textureLODFailures.length=0}uploadTextureForRender(e,t,n){let r=!!t.source._gpuData[e.uid];(n||!r)&&(e.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),e.texture.bind(t,0))}destroy(e){this.emit(`destroy`),this.destroyTextureLODStates(),e?.texture&&this.textures.forEach(t=>t.destroy(e.baseTexture)),this.automator.destroy(),this.internalModel.destroy(),super.destroy(e)}};if(typeof window>`u`||window.Live2DCubismCore===void 0)throw Error(`Could not find Cubism runtime. This plugin requires live2dcubismcore.js to be loaded.`);var Z=class e{constructor(e,t){this.x=e,this.y=t,this.x=e??0,this.y=t??0}add(t){let n=new e(0,0);return n.x=this.x+t.x,n.y=this.y+t.y,n}substract(t){let n=new e(0,0);return n.x=this.x-t.x,n.y=this.y-t.y,n}multiply(t){let n=new e(0,0);return n.x=this.x*t.x,n.y=this.y*t.y,n}multiplyByScaler(t){return this.multiply(new e(t,t))}division(t){let n=new e(0,0);return n.x=this.x/t.x,n.y=this.y/t.y,n}divisionByScalar(t){return this.division(new e(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(e){return Math.sqrt((this.x-e.x)*(this.x-e.x)+(this.y-e.y)*(this.y-e.y))}dot(e){return this.x*e.x+this.y*e.y}normalize(){let e=(this.x*this.x+this.y*this.y)**.5;this.x/=e,this.y/=e}isEqual(e){return this.x==e.x&&this.y==e.y}isNotEqual(e){return!this.isEqual(e)}},QE;(e=>{e.CubismVector2=Z})(QE||={});let $E=class e{static range(e,t,n){return e<t?e=t:e>n&&(e=n),e}static sin(e){return Math.sin(e)}static cos(e){return Math.cos(e)}static abs(e){return Math.abs(e)}static sqrt(e){return Math.sqrt(e)}static cbrt(e){if(e===0)return e;let t=e,n=t<0;n&&(t=-t);let r;return t===1/0?r=1/0:(r=Math.exp(Math.log(t)/3),r=(t/(r*r)+2*r)/3),n?-r:r}static getEasingSine(e){return e<0?0:e>1?1:.5-.5*this.cos(e*Math.PI)}static max(e,t){return e>t?e:t}static min(e,t){return e>t?t:e}static clamp(e,t,n){return e<t?t:n<e?n:e}static degreesToRadian(e){return e/180*Math.PI}static radianToDegrees(e){return e*180/Math.PI}static directionToRadian(e,t){let n=Math.atan2(t.y,t.x)-Math.atan2(e.y,e.x);for(;n<-Math.PI;)n+=Math.PI*2;for(;n>Math.PI;)n-=Math.PI*2;return n}static directionToDegrees(e,t){let n=this.directionToRadian(e,t),r=this.radianToDegrees(n);return t.x-e.x>0&&(r=-r),r}static radianToDirection(e){let t=new Z;return t.x=this.sin(e),t.y=this.cos(e),t}static quadraticEquation(t,n,r){return this.abs(t)<e.Epsilon?this.abs(n)<e.Epsilon?-r:-r/n:-(n+this.sqrt(n*n-4*t*r))/(2*t)}static cardanoAlgorithmForBezier(t,n,r,i){if(this.abs(t)<e.Epsilon)return this.range(this.quadraticEquation(n,r,i),0,1);let a=n/t,o=r/t,s=i/t,c=(3*o-a*a)/3,l=c/3,u=(2*a*a*a-9*a*o+27*s)/27,d=u/2,f=d*d+l*l*l,p=.5,m=.51;if(f<0){let e=-c/3,t=e*e*e,n=this.sqrt(t),r=-u/(2*n),i=this.range(r,-1,1),o=Math.acos(i),s=2*this.cbrt(n),l=s*this.cos(o/3)-a/3;if(this.abs(l-p)<m)return this.range(l,0,1);let d=s*this.cos((o+2*Math.PI)/3)-a/3;if(this.abs(d-p)<m)return this.range(d,0,1);let f=s*this.cos((o+4*Math.PI)/3)-a/3;return this.range(f,0,1)}if(f==0){let e;e=d<0?this.cbrt(-d):-this.cbrt(d);let t=2*e-a/3;if(this.abs(t-p)<m)return this.range(t,0,1);let n=-e-a/3;return this.range(n,0,1)}let h=this.sqrt(f),g=this.cbrt(h-d)-this.cbrt(h+d)-a/3;return this.range(g,0,1)}static mod(e,t){if(!isFinite(e)||t===0||isNaN(e)||isNaN(t))return console.warn(`divided: ${e}, divisor: ${t} mod() returns 'NaN'.`),NaN;let n=Math.abs(e),r=Math.abs(t),i=n-Math.floor(n/r)*r;return i*=Math.sign(e),i}constructor(){}};$E.Epsilon=1e-5;let Q=$E;var eD;(e=>{e.CubismMath=Q})(eD||={});var tD=class{constructor(){this.setBeganMotionHandler=e=>this._onBeganMotion=e,this.getBeganMotionHandler=()=>this._onBeganMotion,this.setFinishedMotionHandler=e=>this._onFinishedMotion=e,this.getFinishedMotionHandler=()=>this._onFinishedMotion,this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._isLoop=!1,this._isLoopFadeIn=!0,this._previousLoopState=this._isLoop,this._firedEventValues=new J}static delete(e){e.release(),e=null}release(){this._weight=0}updateParameters(e,t,n){if(!t.isAvailable()||t.isFinished())return;this.setupMotionQueueEntry(t,n);let r=this.updateFadeWeight(t,n);this.doUpdateParameters(e,n,r,t),t.getEndTime()>0&&t.getEndTime()<n&&t.setIsFinished(!0)}setupMotionQueueEntry(e,t){e==null||e.isStarted()||e.isAvailable()&&(e.setIsStarted(!0),e.setStartTime(t-this._offsetSeconds),e.setFadeInStartTime(t),e.getEndTime()<0&&this.adjustEndTime(e),e._motion._onBeganMotion&&e._motion._onBeganMotion(e._motion))}updateFadeWeight(e,t){e??Vw.print(mT.LogLevel_Error,`motionQueueEntry is null.`);let n=this._weight,r=this._fadeInSeconds==0?1:Q.getEasingSine((t-e.getFadeInStartTime())/this._fadeInSeconds),i=this._fadeOutSeconds==0||e.getEndTime()<0?1:Q.getEasingSine((e.getEndTime()-t)/this._fadeOutSeconds);return n=n*r*i,e.setState(t,n),Lw(0<=n&&n<=1),n}setFadeInTime(e){this._fadeInSeconds=e}setFadeOutTime(e){this._fadeOutSeconds=e}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(e){this._weight=e}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(e){this._offsetSeconds=e}setLoop(e){this._isLoop=e}getLoop(){return this._isLoop}setLoopFadeIn(e){this._isLoopFadeIn=e}getLoopFadeIn(){return this._isLoopFadeIn}getFiredEvent(e,t){return this._firedEventValues}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(e){return null}getModelOpacityValue(){return 1}adjustEndTime(e){let t=this.getDuration(),n=t<=0?-1:e.getStartTime()+t;e.setEndTime(n)}},nD;(e=>{e.ACubismMotion=tD})(nD||={});let rD=`Parameters`,iD=`Blend`,aD=class e extends tD{static create(t,n){let r=new e;return r.parse(t,n),r}doUpdateParameters(e,t,n,r){for(let t=0;t<this._parameters.getSize();++t){let r=this._parameters.at(t);switch(r.blendType){case 0:e.addParameterValueById(r.parameterId,r.value,n);break;case 1:e.multiplyParameterValueById(r.parameterId,r.value,n);break;case 2:e.setParameterValueById(r.parameterId,r.value,n);break}}}calculateExpressionParameters(t,n,r,i,a,o){if(!(r==null||i==null)&&r.isAvailable()){this._fadeWeight=this.updateFadeWeight(r,n);for(let n=0;n<i.getSize();++n){let r=i.at(n);if(r.parameterId==null)continue;let s=r.overwriteValue=t.getParameterValueById(r.parameterId),c=this.getExpressionParameters(),l=-1;for(let e=0;e<c.getSize();++e)if(r.parameterId==c.at(e).parameterId){l=e;break}if(l<0){a==0?(r.additiveValue=e.DefaultAdditiveValue,r.multiplyValue=e.DefaultMultiplyValue,r.overwriteValue=s):(r.additiveValue=this.calculateValue(r.additiveValue,e.DefaultAdditiveValue,o),r.multiplyValue=this.calculateValue(r.multiplyValue,e.DefaultMultiplyValue,o),r.overwriteValue=this.calculateValue(r.overwriteValue,s,o));continue}let u=c.at(l).value,d,f,p;switch(c.at(l).blendType){case 0:d=u,f=e.DefaultMultiplyValue,p=s;break;case 1:d=e.DefaultAdditiveValue,f=u,p=s;break;case 2:d=e.DefaultAdditiveValue,f=e.DefaultMultiplyValue,p=u;break;default:return}a==0?(r.additiveValue=d,r.multiplyValue=f,r.overwriteValue=p):(r.additiveValue=r.additiveValue*(1-o)+d*o,r.multiplyValue=r.multiplyValue*(1-o)+f*o,r.overwriteValue=r.overwriteValue*(1-o)+p*o)}}}getExpressionParameters(){return this._parameters}getFadeWeight(){return this._fadeWeight}parse(e,t){let n=Zw.create(e,t);if(!n)return;let r=n.getRoot();this.setFadeInTime(r.getValueByString(`FadeInTime`).toFloat(1)),this.setFadeOutTime(r.getValueByString(`FadeOutTime`).toFloat(1));let i=r.getValueByString(rD).getSize();this._parameters.prepareCapacity(i);for(let e=0;e<i;++e){let t=r.getValueByString(rD).getValueByIndex(e),n=pT.getIdManager().getId(t.getValueByString(`Id`).getRawString()),i=t.getValueByString(`Value`).toFloat(),a;a=t.getValueByString(iD).isNull()||t.getValueByString(iD).getString()==`Add`?0:t.getValueByString(iD).getString()==`Multiply`?1:t.getValueByString(iD).getString()==`Overwrite`?2:0;let o=new cD;o.parameterId=n,o.blendType=a,o.value=i,this._parameters.pushBack(o)}Zw.delete(n)}calculateValue(e,t,n){return e*(1-n)+t*n}constructor(){super(),this._parameters=new J,this._fadeWeight=0}};aD.DefaultAdditiveValue=0,aD.DefaultMultiplyValue=1;let oD=aD;var sD=(e=>(e[e.Additive=0]=`Additive`,e[e.Multiply=1]=`Multiply`,e[e.Overwrite=2]=`Overwrite`,e))(sD||{}),cD=class{},lD;(e=>{e.CubismExpressionMotion=oD,e.ExpressionBlendType=sD,e.ExpressionParameter=cD})(lD||={});var uD=class{constructor(){this._autoDelete=!1,this._motion=null,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&tD.delete(this._motion)}setFadeOut(e){this._fadeOutSeconds=e,this._isTriggeredFadeOut=!0}startFadeOut(e,t){let n=t+e;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||n<this._endTimeSeconds)&&(this._endTimeSeconds=n)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(e){this._startTimeSeconds=e}setFadeInStartTime(e){this._fadeInStartTimeSeconds=e}setEndTime(e){this._endTimeSeconds=e}setIsFinished(e){this._finished=e}setIsStarted(e){this._started=e}isAvailable(){return this._available}setIsAvailable(e){this._available=e}setState(e,t){this._stateTimeSeconds=e,this._stateWeight=t}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(e){this._lastEventCheckSeconds=e}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}getCubismMotion(){return this._motion}},dD;(e=>{e.CubismMotionQueueEntry=uD})(dD||={});var fD=class{constructor(){this._userTimeSeconds=0,this._eventCallBack=null,this._eventCustomData=null,this._motions=new J}release(){for(let e=0;e<this._motions.getSize();++e)this._motions.at(e)&&(this._motions.at(e).release(),this._motions.set(e,null));this._motions=null}startMotion(e,t,n){if(e==null)return pD;let r=null;for(let e=0;e<this._motions.getSize();++e)r=this._motions.at(e),r?.setFadeOut(r._motion.getFadeOutTime());return r=new uD,r._autoDelete=t,r._motion=e,this._motions.pushBack(r),r._motionQueueEntryHandle}isFinished(){for(let e=this._motions.begin();e.notEqual(this._motions.end());){let t=e.ptr();if(t==null){e=this._motions.erase(e);continue}if(t._motion==null){t.release(),t=null,e=this._motions.erase(e);continue}if(t.isFinished())e.preIncrement();else return!1}return!0}isFinishedByHandle(e){for(let t=this._motions.begin();t.notEqual(this._motions.end());t.increment()){let n=t.ptr();if(n!=null&&n._motionQueueEntryHandle==e&&!n.isFinished())return!1}return!0}stopAllMotions(){for(let e=this._motions.begin();e.notEqual(this._motions.end());){let t=e.ptr();if(t==null){e=this._motions.erase(e);continue}t.release(),t=null,e=this._motions.erase(e)}}getCubismMotionQueueEntries(){return this._motions}getCubismMotionQueueEntry(e){for(let t=this._motions.begin();t.notEqual(this._motions.end());t.preIncrement()){let n=t.ptr();if(n!=null&&n._motionQueueEntryHandle==e)return n}return null}setEventCallback(e,t=null){this._eventCallBack=e,this._eventCustomData=t}doUpdateMotion(e,t){let n=!1;for(let r=this._motions.begin();r.notEqual(this._motions.end());){let i=r.ptr();if(i==null){r=this._motions.erase(r);continue}let a=i._motion;if(a==null){i.release(),i=null,r=this._motions.erase(r);continue}a.updateParameters(e,i,t),n=!0;let o=a.getFiredEvent(i.getLastCheckEventSeconds()-i.getStartTime(),t-i.getStartTime());for(let e=0;e<o.getSize();++e)this._eventCallBack(this,o.at(e),this._eventCustomData);i.setLastCheckEventSeconds(t),i.isFinished()?(i.release(),i=null,r=this._motions.erase(r)):(i.isTriggeredFadeOut()&&i.startFadeOut(i.getFadeOutSeconds(),t),r.preIncrement())}return n}};let pD=-1;var mD;(e=>{e.CubismMotionQueueManager=fD,e.InvalidMotionQueueEntryHandleValue=-1})(mD||={});var hD=class extends ET{constructor(e,t){super(e,t),K(this,`expressionDataType`,`arraybuffer`),K(this,`queueManager`,new fD),K(this,`definitions`),this.definitions=e.expressions?.filter(e=>!!e&&typeof e.File==`string`)??[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(e){return this.definitions.findIndex(t=>t.Name===e)}getExpressionFile(e){return e.File}createExpression(e,t){return oD.create(e,e.byteLength)}_setExpression(e){return this.queueManager.startMotion(e,!1)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(e,t){return this.queueManager.doUpdateMotion(e,t)}createDefaultExpression(){let e=new TextEncoder().encode(JSON.stringify({FadeInTime:0,FadeOutTime:0,Parameters:[]})).buffer;return oD.create(e,e.byteLength)}},gD=(e=>(e[e.CubismMotionCurveTarget_Model=0]=`CubismMotionCurveTarget_Model`,e[e.CubismMotionCurveTarget_Parameter=1]=`CubismMotionCurveTarget_Parameter`,e[e.CubismMotionCurveTarget_PartOpacity=2]=`CubismMotionCurveTarget_PartOpacity`,e))(gD||{}),_D=(e=>(e[e.CubismMotionSegmentType_Linear=0]=`CubismMotionSegmentType_Linear`,e[e.CubismMotionSegmentType_Bezier=1]=`CubismMotionSegmentType_Bezier`,e[e.CubismMotionSegmentType_Stepped=2]=`CubismMotionSegmentType_Stepped`,e[e.CubismMotionSegmentType_InverseStepped=3]=`CubismMotionSegmentType_InverseStepped`,e))(_D||{}),vD=class{constructor(){this.time=0,this.value=0}},yD=class{constructor(){this.evaluate=null,this.basePointIndex=0,this.segmentType=0}},bD=class{constructor(){this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}},xD=class{constructor(){this.fireTime=0}},SD=class{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=new J,this.segments=new J,this.points=new J,this.events=new J}},CD;(e=>{e.CubismMotionCurve=bD,e.CubismMotionCurveTarget=gD,e.CubismMotionData=SD,e.CubismMotionEvent=xD,e.CubismMotionPoint=vD,e.CubismMotionSegment=yD,e.CubismMotionSegmentType=_D})(CD||={});let wD=`Meta`,TD=`Curves`,ED=`FadeInTime`,DD=`FadeOutTime`,OD=`Segments`,kD=`UserData`;var AD=class{constructor(e,t){this._json=Zw.create(e,t)}release(){Zw.delete(this._json)}getMotionDuration(){return this._json.getRoot().getValueByString(wD).getValueByString(`Duration`).toFloat()}isMotionLoop(){return this._json.getRoot().getValueByString(wD).getValueByString(`Loop`).toBoolean()}hasConsistency(){let e=!0;if(!this._json||!this._json.getRoot())return!1;let t=this._json.getRoot().getValueByString(TD).getVector().getSize(),n=0,r=0;for(let e=0;e<t;++e)for(let t=0;t<this.getMotionCurveSegmentCount(e);){switch(t==0&&(r+=1,t+=2),this.getMotionCurveSegment(e,t)){case _D.CubismMotionSegmentType_Linear:r+=1,t+=3;break;case _D.CubismMotionSegmentType_Bezier:r+=3,t+=7;break;case _D.CubismMotionSegmentType_Stepped:r+=1,t+=3;break;case _D.CubismMotionSegmentType_InverseStepped:r+=1,t+=3;break;default:Lw(0);break}++n}return t!=this.getMotionCurveCount()&&(Y(`The number of curves does not match the metadata.`),e=!1),n!=this.getMotionTotalSegmentCount()&&(Y(`The number of segment does not match the metadata.`),e=!1),r!=this.getMotionTotalPointCount()&&(Y(`The number of point does not match the metadata.`),e=!1),e}getEvaluationOptionFlag(e){return e==0&&this._json.getRoot().getValueByString(wD).getValueByString(`AreBeziersRestricted`).toBoolean()}getMotionCurveCount(){return this._json.getRoot().getValueByString(wD).getValueByString(`CurveCount`).toInt()}getMotionFps(){return this._json.getRoot().getValueByString(wD).getValueByString(`Fps`).toFloat()}getMotionTotalSegmentCount(){return this._json.getRoot().getValueByString(wD).getValueByString(`TotalSegmentCount`).toInt()}getMotionTotalPointCount(){return this._json.getRoot().getValueByString(wD).getValueByString(`TotalPointCount`).toInt()}isExistMotionFadeInTime(){return!this._json.getRoot().getValueByString(wD).getValueByString(ED).isNull()}isExistMotionFadeOutTime(){return!this._json.getRoot().getValueByString(wD).getValueByString(DD).isNull()}getMotionFadeInTime(){return this._json.getRoot().getValueByString(wD).getValueByString(ED).toFloat()}getMotionFadeOutTime(){return this._json.getRoot().getValueByString(wD).getValueByString(DD).toFloat()}getMotionCurveTarget(e){return this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(`Target`).getRawString()}getMotionCurveId(e){return pT.getIdManager().getId(this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(`Id`).getRawString())}isExistMotionCurveFadeInTime(e){return!this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(ED).isNull()}isExistMotionCurveFadeOutTime(e){return!this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(DD).isNull()}getMotionCurveFadeInTime(e){return this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(ED).toFloat()}getMotionCurveFadeOutTime(e){return this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(DD).toFloat()}getMotionCurveSegmentCount(e){return this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(OD).getVector().getSize()}getMotionCurveSegment(e,t){return this._json.getRoot().getValueByString(TD).getValueByIndex(e).getValueByString(OD).getValueByIndex(t).toFloat()}getEventCount(){return this._json.getRoot().getValueByString(wD).getValueByString(`UserDataCount`).toInt()}getTotalEventValueSize(){return this._json.getRoot().getValueByString(wD).getValueByString(`TotalUserDataSize`).toInt()}getEventTime(e){return this._json.getRoot().getValueByString(kD).getValueByIndex(e).getValueByString(`Time`).toFloat()}getEventValue(e){return new yw(this._json.getRoot().getValueByString(kD).getValueByIndex(e).getValueByString(`Value`).getRawString())}},jD=(e=>(e[e.EvaluationOptionFlag_AreBeziersRistricted=0]=`EvaluationOptionFlag_AreBeziersRistricted`,e))(jD||{}),MD;(e=>{e.CubismMotionJson=AD})(MD||={});let ND=`Opacity`;function PD(e,t,n){let r=new vD;return r.time=e.time+(t.time-e.time)*n,r.value=e.value+(t.value-e.value)*n,r}function FD(e,t){let n=(t-e[0].time)/(e[1].time-e[0].time);return n<0&&(n=0),e[0].value+(e[1].value-e[0].value)*n}function ID(e,t){let n=(t-e[0].time)/(e[3].time-e[0].time);n<0&&(n=0);let r=PD(e[0],e[1],n),i=PD(e[1],e[2],n),a=PD(e[2],e[3],n);return PD(PD(r,i,n),PD(i,a,n),n).value}function LD(e,t){let n=t,r=e[0].time,i=e[3].time,a=e[1].time,o=e[2].time,s=i-3*o+3*a-r,c=3*o-6*a+3*r,l=3*a-3*r,u=r-n,d=Q.cardanoAlgorithmForBezier(s,c,l,u),f=PD(e[0],e[1],d),p=PD(e[1],e[2],d),m=PD(e[2],e[3],d);return PD(PD(f,p,d),PD(p,m,d),d).value}function RD(e,t){return e[0].value}function zD(e,t){return e[1].value}function BD(e,t,n,r,i){let a=e.curves.at(t),o=-1,s=a.baseSegmentIndex+a.segmentCount,c=0;for(let t=a.baseSegmentIndex;t<s;++t)if(c=e.segments.at(t).basePointIndex+(e.segments.at(t).segmentType==_D.CubismMotionSegmentType_Bezier?3:1),e.points.at(c).time>n){o=t;break}if(o==-1)return r&&n<i?VD(e,s-1,e.segments.at(a.baseSegmentIndex).basePointIndex,c,n,i):e.points.at(c).value;let l=e.segments.at(o);return l.evaluate(e.points.get(l.basePointIndex),n)}function VD(e,t,n,r,i,a){let o=[new vD,new vD];{let t=e.points.at(r);o[0].time=t.time,o[0].value=t.value}{let t=e.points.at(n);o[1].time=a,o[1].value=t.value}switch(e.segments.at(t).segmentType){case _D.CubismMotionSegmentType_Linear:case _D.CubismMotionSegmentType_Bezier:default:return FD(o,i);case _D.CubismMotionSegmentType_Stepped:return RD(o);case _D.CubismMotionSegmentType_InverseStepped:return zD(o)}}var HD=class e extends tD{constructor(){super(),this._motionBehavior=1,this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._motionData=null,this._modelCurveIdEyeBlink=null,this._modelCurveIdLipSync=null,this._modelCurveIdOpacity=null,this._eyeBlinkParameterIds=null,this._lipSyncParameterIds=null,this._modelOpacity=1,this._debugMode=!1}static create(t,n,r,i,a=!1){let o=new e;if(o.parse(t,n,a),o._motionData)o._sourceFrameRate=o._motionData.fps,o._loopDurationSeconds=o._motionData.duration,o._onFinishedMotion=r,o._onBeganMotion=i;else return fT(o),null;return o}doUpdateParameters(e,t,n,r){this._modelCurveIdEyeBlink??=pT.getIdManager().getId(`EyeBlink`),this._modelCurveIdLipSync??=pT.getIdManager().getId(`LipSync`),this._modelCurveIdOpacity??=pT.getIdManager().getId(ND),this._motionBehavior===1&&this._previousLoopState!==this._isLoop&&(this.adjustEndTime(r),this._previousLoopState=this._isLoop);let i=t-r.getStartTime();i<0&&(i=0);let a=Number.MAX_VALUE,o=Number.MAX_VALUE,s=0,c=0;this._eyeBlinkParameterIds.getSize()>64&&Rw(`too many eye blink targets : {0}`,this._eyeBlinkParameterIds.getSize()),this._lipSyncParameterIds.getSize()>64&&Rw(`too many lip sync targets : {0}`,this._lipSyncParameterIds.getSize());let l=this._fadeInSeconds<=0?1:Q.getEasingSine((t-r.getFadeInStartTime())/this._fadeInSeconds),u=this._fadeOutSeconds<=0||r.getEndTime()<0?1:Q.getEasingSine((r.getEndTime()-t)/this._fadeOutSeconds),d,f,p,m=i,h=this._motionData.duration,g=this._motionBehavior===1&&this._isLoop;if(this._isLoop)for(this._motionBehavior===1&&(h+=1/this._motionData.fps);m>h;)m-=h;let _=this._motionData.curves;for(f=0;f<this._motionData.curveCount&&_.at(f).type==gD.CubismMotionCurveTarget_Model;++f)d=BD(this._motionData,f,m,g,h),_.at(f).id==this._modelCurveIdEyeBlink?o=d:_.at(f).id==this._modelCurveIdLipSync?a=d:_.at(f).id==this._modelCurveIdOpacity&&(this._modelOpacity=d,e.setModelOapcity(this.getModelOpacityValue()));for(;f<this._motionData.curveCount&&_.at(f).type==gD.CubismMotionCurveTarget_Parameter;++f){if(p=e.getParameterIndex(_.at(f).id),p==-1)continue;let i=e.getParameterValueByIndex(p);if(d=BD(this._motionData,f,m,g,h),o!=Number.MAX_VALUE){for(let e=0;e<this._eyeBlinkParameterIds.getSize()&&e<64;++e)if(this._eyeBlinkParameterIds.at(e)==_.at(f).id){d*=o,c|=1<<e;break}}if(a!=Number.MAX_VALUE){for(let e=0;e<this._lipSyncParameterIds.getSize()&&e<64;++e)if(this._lipSyncParameterIds.at(e)==_.at(f).id){d+=a,s|=1<<e;break}}e.isRepeat(p)&&(d=e.getParameterRepeatValue(p,d));let v;if(_.at(f).fadeInTime<0&&_.at(f).fadeOutTime<0)v=i+(d-i)*n;else{let e,n;e=_.at(f).fadeInTime<0?l:_.at(f).fadeInTime==0?1:Q.getEasingSine((t-r.getFadeInStartTime())/_.at(f).fadeInTime),n=_.at(f).fadeOutTime<0?u:_.at(f).fadeOutTime==0||r.getEndTime()<0?1:Q.getEasingSine((r.getEndTime()-t)/_.at(f).fadeOutTime);let a=this._weight*e*n;v=i+(d-i)*a}e.setParameterValueByIndex(p,v,1)}if(o!=Number.MAX_VALUE)for(let t=0;t<this._eyeBlinkParameterIds.getSize()&&t<64;++t){let r=e.getParameterValueById(this._eyeBlinkParameterIds.at(t));if(c>>t&1)continue;let i=r+(o-r)*n;e.setParameterValueById(this._eyeBlinkParameterIds.at(t),i)}if(a!=Number.MAX_VALUE)for(let t=0;t<this._lipSyncParameterIds.getSize()&&t<64;++t){let r=e.getParameterValueById(this._lipSyncParameterIds.at(t));if(s>>t&1)continue;let i=r+(a-r)*n;e.setParameterValueById(this._lipSyncParameterIds.at(t),i)}for(;f<this._motionData.curveCount&&_.at(f).type==gD.CubismMotionCurveTarget_PartOpacity;++f)p=e.getParameterIndex(_.at(f).id),p!=-1&&(d=BD(this._motionData,f,m,g,h),e.setParameterValueByIndex(p,d));i>=h&&(this._isLoop?this.updateForNextLoop(r,t,m):(this._onFinishedMotion&&this._onFinishedMotion(this),r.setIsFinished(!0))),this._lastWeight=n}setIsLoop(e){Y(`setIsLoop() is a deprecated function. Please use setLoop().`),this._isLoop=e}isLoop(){return Y(`isLoop() is a deprecated function. Please use getLoop().`),this._isLoop}setIsLoopFadeIn(e){Y(`setIsLoopFadeIn() is a deprecated function. Please use setLoopFadeIn().`),this._isLoopFadeIn=e}isLoopFadeIn(){return Y(`isLoopFadeIn() is a deprecated function. Please use getLoopFadeIn().`),this._isLoopFadeIn}setMotionBehavior(e){this._motionBehavior=e}getMotionBehavior(){return this._motionBehavior}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(e,t){let n=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(e==n.at(r).id){n.at(r).fadeInTime=t;return}}setParameterFadeOutTime(e,t){let n=this._motionData.curves;for(let r=0;r<this._motionData.curveCount;++r)if(e==n.at(r).id){n.at(r).fadeOutTime=t;return}}getParameterFadeInTime(e){let t=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(e==t.at(n).id)return t.at(n).fadeInTime;return-1}getParameterFadeOutTime(e){let t=this._motionData.curves;for(let n=0;n<this._motionData.curveCount;++n)if(e==t.at(n).id)return t.at(n).fadeOutTime;return-1}setEffectIds(e,t){this._eyeBlinkParameterIds=e,this._lipSyncParameterIds=t}release(){this._motionData=void 0,this._motionData=null}updateForNextLoop(e,t,n){switch(this._motionBehavior){case 1:default:e.setStartTime(t-n),this._isLoopFadeIn&&e.setFadeInStartTime(t-n),this._onFinishedMotion!=null&&this._onFinishedMotion(this);break;case 0:e.setStartTime(t),this._isLoopFadeIn&&e.setFadeInStartTime(t);break}}parse(e,t,n=!1){let r=new AD(e,t);if(!r){r.release(),r=void 0;return}if(n&&!r.hasConsistency()){r.release(),Bw(`Inconsistent motion3.json.`);return}this._motionData=new SD,this._motionData.duration=r.getMotionDuration(),this._motionData.loop=r.isMotionLoop(),this._motionData.curveCount=r.getMotionCurveCount(),this._motionData.fps=r.getMotionFps(),this._motionData.eventCount=r.getEventCount();let i=r.getEvaluationOptionFlag(jD.EvaluationOptionFlag_AreBeziersRistricted);r.isExistMotionFadeInTime()?this._fadeInSeconds=r.getMotionFadeInTime()<0?1:r.getMotionFadeInTime():this._fadeInSeconds=1,r.isExistMotionFadeOutTime()?this._fadeOutSeconds=r.getMotionFadeOutTime()<0?1:r.getMotionFadeOutTime():this._fadeOutSeconds=1,this._motionData.curves.updateSize(this._motionData.curveCount,bD,!0),this._motionData.segments.updateSize(r.getMotionTotalSegmentCount(),yD,!0),this._motionData.points.updateSize(r.getMotionTotalPointCount(),vD,!0),this._motionData.events.updateSize(this._motionData.eventCount,xD,!0);let a=0,o=0;for(let e=0;e<this._motionData.curveCount;++e){r.getMotionCurveTarget(e)==`Model`?this._motionData.curves.at(e).type=gD.CubismMotionCurveTarget_Model:r.getMotionCurveTarget(e)==`Parameter`?this._motionData.curves.at(e).type=gD.CubismMotionCurveTarget_Parameter:r.getMotionCurveTarget(e)==`PartOpacity`?this._motionData.curves.at(e).type=gD.CubismMotionCurveTarget_PartOpacity:Y(`Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!`),this._motionData.curves.at(e).id=r.getMotionCurveId(e),this._motionData.curves.at(e).baseSegmentIndex=o,this._motionData.curves.at(e).fadeInTime=r.isExistMotionCurveFadeInTime(e)?r.getMotionCurveFadeInTime(e):-1,this._motionData.curves.at(e).fadeOutTime=r.isExistMotionCurveFadeOutTime(e)?r.getMotionCurveFadeOutTime(e):-1;for(let t=0;t<r.getMotionCurveSegmentCount(e);){switch(t==0?(this._motionData.segments.at(o).basePointIndex=a,this._motionData.points.at(a).time=r.getMotionCurveSegment(e,t),this._motionData.points.at(a).value=r.getMotionCurveSegment(e,t+1),a+=1,t+=2):this._motionData.segments.at(o).basePointIndex=a-1,r.getMotionCurveSegment(e,t)){case _D.CubismMotionSegmentType_Linear:this._motionData.segments.at(o).segmentType=_D.CubismMotionSegmentType_Linear,this._motionData.segments.at(o).evaluate=FD,this._motionData.points.at(a).time=r.getMotionCurveSegment(e,t+1),this._motionData.points.at(a).value=r.getMotionCurveSegment(e,t+2),a+=1,t+=3;break;case _D.CubismMotionSegmentType_Bezier:this._motionData.segments.at(o).segmentType=_D.CubismMotionSegmentType_Bezier,i?this._motionData.segments.at(o).evaluate=ID:this._motionData.segments.at(o).evaluate=LD,this._motionData.points.at(a).time=r.getMotionCurveSegment(e,t+1),this._motionData.points.at(a).value=r.getMotionCurveSegment(e,t+2),this._motionData.points.at(a+1).time=r.getMotionCurveSegment(e,t+3),this._motionData.points.at(a+1).value=r.getMotionCurveSegment(e,t+4),this._motionData.points.at(a+2).time=r.getMotionCurveSegment(e,t+5),this._motionData.points.at(a+2).value=r.getMotionCurveSegment(e,t+6),a+=3,t+=7;break;case _D.CubismMotionSegmentType_Stepped:this._motionData.segments.at(o).segmentType=_D.CubismMotionSegmentType_Stepped,this._motionData.segments.at(o).evaluate=RD,this._motionData.points.at(a).time=r.getMotionCurveSegment(e,t+1),this._motionData.points.at(a).value=r.getMotionCurveSegment(e,t+2),a+=1,t+=3;break;case _D.CubismMotionSegmentType_InverseStepped:this._motionData.segments.at(o).segmentType=_D.CubismMotionSegmentType_InverseStepped,this._motionData.segments.at(o).evaluate=zD,this._motionData.points.at(a).time=r.getMotionCurveSegment(e,t+1),this._motionData.points.at(a).value=r.getMotionCurveSegment(e,t+2),a+=1,t+=3;break;default:Lw(0);break}++this._motionData.curves.at(e).segmentCount,++o}}for(let e=0;e<r.getEventCount();++e)this._motionData.events.at(e).fireTime=r.getEventTime(e),this._motionData.events.at(e).value=r.getEventValue(e);r.release(),r=void 0,r=null}getFiredEvent(e,t){this._firedEventValues.updateSize(0);for(let n=0;n<this._motionData.eventCount;++n)this._motionData.events.at(n).fireTime>e&&this._motionData.events.at(n).fireTime<=t&&this._firedEventValues.pushBack(new yw(this._motionData.events.at(n).value.s));return this._firedEventValues}isExistModelOpacity(){for(let e=0;e<this._motionData.curveCount;e++){let t=this._motionData.curves.at(e);if(t.type==gD.CubismMotionCurveTarget_Model&&t.id.getString().s.localeCompare(ND)==0)return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let e=0;e<this._motionData.curveCount;e++){let t=this._motionData.curves.at(e);if(t.type==gD.CubismMotionCurveTarget_Model&&t.id.getString().s.localeCompare(ND)==0)return e}return-1}getModelOpacityId(e){if(e!=-1){let t=this._motionData.curves.at(e);if(t.type==gD.CubismMotionCurveTarget_Model&&t.id.getString().s.localeCompare(ND)==0)return pT.getIdManager().getId(t.id.getString().s)}return null}getModelOpacityValue(){return this._modelOpacity}setDebugMode(e){this._debugMode=e}},UD;(e=>{e.CubismMotion=HD})(UD||={});function WD(e,t,n){let r=e.startMotion(n,!1),i=e.getCubismMotionQueueEntry(r);if(!i)return!1;i.setStartTime(0),i.setFadeInStartTime(0);let a=n.getDuration(),o=i.getStartTime()+a;return n.doUpdateParameters(t.coreModel,o,1,i),i.setIsFinished(!0),!0}var GD=class extends WT{constructor(e){super(e),K(this,`definitions`),K(this,`groups`,{idle:`Idle`}),K(this,`motionDataType`,`arraybuffer`),K(this,`queueManager`,new fD),K(this,`expressionManager`),K(this,`eyeBlinkIds`),K(this,`lipSyncIds`,[`ParamMouthOpenY`]),this.definitions=e.settings.motions??{},this.eyeBlinkIds=e.settings.getEyeBlinkParameters()||[];let t=e.settings.getLipSyncParameters();t?.length&&(this.lipSyncIds=t),this.init(e.options)}init(e){super.init(e),this.settings.expressions&&(this.expressionManager=new hD(this.settings,e)),this.queueManager.setEventCallback((e,t)=>{let n=typeof t==`string`?t:typeof t==`number`?String(t):t&&typeof t==`object`?t.s:`undefined`;this.emit(`motion:`+n)})}isFinished(){return this.queueManager.isFinished()}_startMotion(e,t,n,r){if(e.setFinishedMotionHandler(t),e.setLoop(r??e._motionData.loop),n&&n.length>0){let t=e._motionData.curves,r=XD(t),i=qD(t);for(let e=0;e<i;e++){let i=JD(t,e);if(!i)continue;let a=YD(i);(!a||!n.includes(a))&&ZD(r,i)}e._motionData.curves=r,e._motionData.curveCount=qD(r)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(e,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(e,t,n){let r=!!this.parent.options.checkMotionConsistency,i=HD.create(e,e.byteLength,void 0,void 0,r),a=new AD(e,e.byteLength);i.setLoop(a.isMotionLoop());let o=(t===this.groups.idle?gT.idleMotionFadingDuration:gT.motionFadingDuration)/1e3;return a.getMotionFadeInTime()===void 0&&i.setFadeInTime(n.FadeInTime>0?n.FadeInTime:o),a.getMotionFadeOutTime()===void 0&&i.setFadeOutTime(n.FadeOutTime>0?n.FadeOutTime:o),i.setEffectIds(this.createIdVector(this.eyeBlinkIds),this.createIdVector(this.lipSyncIds)),i}getMotionFile(e){return e.File}getMotionName(e){return e.File}getSoundFile(e){return e.Sound}updateParameters(e,t){return this.queueManager.doUpdateMotion(e,t)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}motionLastFrame(e,t){return q(this,arguments,function*(e,t,{expression:n=void 0}={}){let r=yield this.getMotionAndApplyExpression(e,t,n);return r?(this.playing=!0,WD(this.queueManager,this.parent,r),this.playing=!1,!0):!1})}createIdVector(e){let t=new J,n=pT.getIdManager();for(let r of e)t.pushBack(n.getId(r));return t}};function KD(e){return typeof e.pushBack==`function`}function qD(e){return KD(e)?e.getSize():e.length}function JD(e,t){return KD(e)?e.at(t):e[t]}function YD(e){if(!e||typeof e!=`object`)return;let t=e.id;if(typeof t==`string`)return t;if(t&&typeof t.getString==`function`)return t.getString().s}function XD(e){return KD(e)?new J:[]}function ZD(e,t){KD(e)?e.pushBack(t):e.push(t)}var QD=class extends y{constructor(e){super(),K(this,`tag`),K(this,`manager`),K(this,`settings`),K(this,`state`,new jT),K(this,`playing`,!1),K(this,`destroyed`,!1),K(this,`parent`),this.settings=e.settings,this.tag=`ParallelMotionManager(${this.settings.name})`,this.state.tag=this.tag,this.manager=e.motionManager,this.parent=e}startMotion(e,t){return q(this,arguments,function*(e,t,n=AT.NORMAL,r={}){let{ignoreParamIds:i=[],loop:a}=Array.isArray(r)?{ignoreParamIds:r,loop:void 0}:r;if(!this.state.reserve(e,t,n))return!1;let o=this.manager.definitions[e]?.[t];if(!o)return!1;let s=yield this.manager.loadMotion(e,t);return this.state.start(s,e,t,n)?(X.log(this.tag,`Start motion:`,this.getMotionName(o)),this.emit(`motionStart`,e,t,void 0),this.playing=!0,this._startMotion(s,void 0,i,a),!0):!1})}startRandomMotion(e,t){return q(this,arguments,function*(e,t,{loop:n=void 0}={}){let r=this.manager.definitions[e];if(r?.length){let i=[],a=this.manager.motionGroups[e]??[];for(let t=0;t<r.length;t++)a[t]!==null&&!this.state.isActive(e,t)&&i.push(t);if(i.length){let r=i[Math.floor(Math.random()*i.length)];return this.startMotion(e,r,t,{loop:n})}}return!1})}stopAllMotions(){this._stopAllMotions(),this.state.reset()}update(e,t){return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit(`motionFinish`)),this.state.complete()),this.updateParameters(e,t)}destroy(){this.destroyed=!0,this.emit(`destroy`),this.stopAllMotions()}},$D=class extends QD{constructor(e){super(e),K(this,`queueManager`,new fD),this.init()}init(){this.queueManager.setEventCallback((e,t)=>{let n=typeof t==`string`?t:typeof t==`number`?String(t):t&&typeof t==`object`?t.s:`undefined`;this.emit(`motion:`+n)})}isFinished(){return this.queueManager.isFinished()}_startMotion(e,t,n,r){if(e.setFinishedMotionHandler(t),e.setLoop(r??e._motionData.loop),n&&n.length>0){let t=e._motionData.curves,r=iO(t),i=tO(t);for(let e=0;e<i;e++){let i=nO(t,e);if(!i)continue;let a=rO(i);(!a||!n.includes(a))&&aO(r,i)}e._motionData.curves=r,e._motionData.curveCount=tO(r)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(e,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(e,t){return this.queueManager.doUpdateMotion(e,t)}getMotionName(e){return e.File}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}playMotionLastFrame(e,t){return q(this,null,function*(){if(!this.state.reserve(e,t,AT.FORCE))return!1;let n=this.manager.definitions[e]?.[t];if(!n)return!1;let r=yield this.manager.loadMotion(e,t);return this.state.start(r,e,t,AT.FORCE)?(X.log(this.tag,`Start motion:`,this.getMotionName(n)),this.emit(`motionStart`,e,t,void 0),this.playing=!0,this.queueManager.stopAllMotions(),WD(this.queueManager,this.parent,r)?(this.playing=!1,!0):(this.playing=!1,!1)):!1})}};function eO(e){return typeof e.pushBack==`function`}function tO(e){return eO(e)?e.getSize():e.length}function nO(e,t){return eO(e)?e.at(t):e[t]}function rO(e){if(!e||typeof e!=`object`)return;let t=e.id;if(typeof t==`string`)return t;if(t&&typeof t.getString==`function`)return t.getString().s}function iO(e){return eO(e)?new J:[]}function aO(e,t){eO(e)?e.pushBack(t):e.push(t)}let $=Object.freeze({HitAreaPrefix:`HitArea`,HitAreaHead:`Head`,HitAreaBody:`Body`,PartsIdCore:`Parts01Core`,PartsArmPrefix:`Parts01Arm_`,PartsArmLPrefix:`Parts01ArmL_`,PartsArmRPrefix:`Parts01ArmR_`,ParamAngleX:`ParamAngleX`,ParamAngleY:`ParamAngleY`,ParamAngleZ:`ParamAngleZ`,ParamEyeLOpen:`ParamEyeLOpen`,ParamEyeLSmile:`ParamEyeLSmile`,ParamEyeROpen:`ParamEyeROpen`,ParamEyeRSmile:`ParamEyeRSmile`,ParamEyeBallX:`ParamEyeBallX`,ParamEyeBallY:`ParamEyeBallY`,ParamEyeBallForm:`ParamEyeBallForm`,ParamBrowLY:`ParamBrowLY`,ParamBrowRY:`ParamBrowRY`,ParamBrowLX:`ParamBrowLX`,ParamBrowRX:`ParamBrowRX`,ParamBrowLAngle:`ParamBrowLAngle`,ParamBrowRAngle:`ParamBrowRAngle`,ParamBrowLForm:`ParamBrowLForm`,ParamBrowRForm:`ParamBrowRForm`,ParamMouthForm:`ParamMouthForm`,ParamMouthOpenY:`ParamMouthOpenY`,ParamCheek:`ParamCheek`,ParamBodyAngleX:`ParamBodyAngleX`,ParamBodyAngleY:`ParamBodyAngleY`,ParamBodyAngleZ:`ParamBodyAngleZ`,ParamBreath:`ParamBreath`,ParamArmLA:`ParamArmLA`,ParamArmRA:`ParamArmRA`,ParamArmLB:`ParamArmLB`,ParamArmRB:`ParamArmRB`,ParamHandL:`ParamHandL`,ParamHandR:`ParamHandR`,ParamHairFront:`ParamHairFront`,ParamHairSide:`ParamHairSide`,ParamHairBack:`ParamHairBack`,ParamHairFluffy:`ParamHairFluffy`,ParamShoulderY:`ParamShoulderY`,ParamBustX:`ParamBustX`,ParamBustY:`ParamBustY`,ParamBaseX:`ParamBaseX`,ParamBaseY:`ParamBaseY`,ParamNONE:`NONE:`});var oO;(e=>{e.HitAreaBody=$.HitAreaBody,e.HitAreaHead=$.HitAreaHead,e.HitAreaPrefix=$.HitAreaPrefix,e.ParamAngleX=$.ParamAngleX,e.ParamAngleY=$.ParamAngleY,e.ParamAngleZ=$.ParamAngleZ,e.ParamArmLA=$.ParamArmLA,e.ParamArmLB=$.ParamArmLB,e.ParamArmRA=$.ParamArmRA,e.ParamArmRB=$.ParamArmRB,e.ParamBaseX=$.ParamBaseX,e.ParamBaseY=$.ParamBaseY,e.ParamBodyAngleX=$.ParamBodyAngleX,e.ParamBodyAngleY=$.ParamBodyAngleY,e.ParamBodyAngleZ=$.ParamBodyAngleZ,e.ParamBreath=$.ParamBreath,e.ParamBrowLAngle=$.ParamBrowLAngle,e.ParamBrowLForm=$.ParamBrowLForm,e.ParamBrowLX=$.ParamBrowLX,e.ParamBrowLY=$.ParamBrowLY,e.ParamBrowRAngle=$.ParamBrowRAngle,e.ParamBrowRForm=$.ParamBrowRForm,e.ParamBrowRX=$.ParamBrowRX,e.ParamBrowRY=$.ParamBrowRY,e.ParamBustX=$.ParamBustX,e.ParamBustY=$.ParamBustY,e.ParamCheek=$.ParamCheek,e.ParamEyeBallForm=$.ParamEyeBallForm,e.ParamEyeBallX=$.ParamEyeBallX,e.ParamEyeBallY=$.ParamEyeBallY,e.ParamEyeLOpen=$.ParamEyeLOpen,e.ParamEyeLSmile=$.ParamEyeLSmile,e.ParamEyeROpen=$.ParamEyeROpen,e.ParamEyeRSmile=$.ParamEyeRSmile,e.ParamHairBack=$.ParamHairBack,e.ParamHairFluffy=$.ParamHairFluffy,e.ParamHairFront=$.ParamHairFront,e.ParamHairSide=$.ParamHairSide,e.ParamHandL=$.ParamHandL,e.ParamHandR=$.ParamHandR,e.ParamMouthForm=$.ParamMouthForm,e.ParamMouthOpenY=$.ParamMouthOpenY,e.ParamNONE=$.ParamNONE,e.ParamShoulderY=$.ParamShoulderY,e.PartsArmLPrefix=$.PartsArmLPrefix,e.PartsArmPrefix=$.PartsArmPrefix,e.PartsArmRPrefix=$.PartsArmRPrefix,e.PartsIdCore=$.PartsIdCore})(oO||={});var sO=class e{static create(){return new e}static delete(e){}setParameters(e){this._breathParameters=e}getParameters(){return this._breathParameters}updateParameters(e,t){this._currentTime+=t;let n=this._currentTime*2*Math.PI;for(let t=0;t<this._breathParameters.getSize();++t){let r=this._breathParameters.at(t);e.addParameterValueById(r.parameterId,r.offset+r.peak*Math.sin(n/r.cycle),r.weight)}}constructor(){this._currentTime=0}},cO=class{constructor(e,t,n,r,i){this.parameterId=e??null,this.offset=t??0,this.peak=n??0,this.cycle=r??0,this.weight=i??0}},lO;(e=>{e.BreathParameterData=cO,e.CubismBreath=sO})(lO||={});let uO=class e{static create(t=null){return new e(t)}static delete(e){}setBlinkingInterval(e){this._blinkingIntervalSeconds=e}setBlinkingSetting(e,t,n){this._closingSeconds=e,this._closedSeconds=t,this._openingSeconds=n}setParameterIds(e){this._parameterIds=e}getParameterIds(){return this._parameterIds}updateParameters(t,n){this._userTimeSeconds+=n;let r,i=0;switch(this._blinkingState){case 2:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,i>=1&&(i=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),r=1-i;break;case 3:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,i>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),r=0;break;case 4:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,i>=1&&(i=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),r=i;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),r=1;break;default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),r=1;break}e.CloseIfZero||(r=-r);for(let e=0;e<this._parameterIds.getSize();++e)t.setParameterValueById(this._parameterIds.at(e),r)}constructor(e){if(this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new J,e!=null)for(let t=0;t<e.getEyeBlinkParameterCount();++t)this._parameterIds.pushBack(e.getEyeBlinkParameterId(t))}determinNextBlinkingTiming(){let e=Math.random();return this._userTimeSeconds+e*(2*this._blinkingIntervalSeconds-1)}};uO.CloseIfZero=!0;let dO=uO;var fO=(e=>(e[e.EyeState_First=0]=`EyeState_First`,e[e.EyeState_Interval=1]=`EyeState_Interval`,e[e.EyeState_Closing=2]=`EyeState_Closing`,e[e.EyeState_Closed=3]=`EyeState_Closed`,e[e.EyeState_Opening=4]=`EyeState_Opening`,e))(fO||{}),pO;(e=>{e.CubismEyeBlink=dO,e.EyeState=fO})(pO||={});var mO=class{constructor(e){this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=new J,this._clippingContextListForDraw=new J,this._channelColors=new J,this._tmpBoundsOnModel=new Dw,this._tmpMatrix=new Tw,this._tmpMatrixForMask=new Tw,this._tmpMatrixForDraw=new Tw,this._clippingContexttConstructor=e;let t=new jw;t.r=1,t.g=0,t.b=0,t.a=0,this._channelColors.pushBack(t),t=new jw,t.r=0,t.g=1,t.b=0,t.a=0,this._channelColors.pushBack(t),t=new jw,t.r=0,t.g=0,t.b=1,t.a=0,this._channelColors.pushBack(t),t=new jw,t.r=0,t.g=0,t.b=0,t.a=1,this._channelColors.pushBack(t)}release(){for(let e=0;e<this._clippingContextListForMask.getSize();e++)this._clippingContextListForMask.at(e)&&(this._clippingContextListForMask.at(e).release(),this._clippingContextListForMask.set(e,void 0)),this._clippingContextListForMask.set(e,null);this._clippingContextListForMask=null;for(let e=0;e<this._clippingContextListForDraw.getSize();e++)this._clippingContextListForDraw.set(e,null);this._clippingContextListForDraw=null;for(let e=0;e<this._channelColors.getSize();e++)this._channelColors.set(e,null);this._channelColors=null,this._clearedFrameBufferFlags!=null&&this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=null}initialize(e,t){t%1!=0&&(Y(`The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer.`),t=~~t),t<1&&Y(`The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1.`),this._renderTextureCount=t<1?1:t,this._clearedFrameBufferFlags=new J(this._renderTextureCount);for(let t=0;t<e.getDrawableCount();t++){if(e.getDrawableMaskCounts()[t]<=0){this._clippingContextListForDraw.pushBack(null);continue}let n=this.findSameClip(e.getDrawableMasks()[t],e.getDrawableMaskCounts()[t]);n??(n=new this._clippingContexttConstructor(this,e.getDrawableMasks()[t],e.getDrawableMaskCounts()[t]),this._clippingContextListForMask.pushBack(n)),n.addClippedDrawable(t),this._clippingContextListForDraw.pushBack(n)}}findSameClip(e,t){for(let n=0;n<this._clippingContextListForMask.getSize();n++){let r=this._clippingContextListForMask.at(n),i=r._clippingIdCount;if(i!=t)continue;let a=0;for(let t=0;t<i;t++){let n=r._clippingIdList[t];for(let t=0;t<i;t++)if(e[t]==n){a++;break}}if(a==i)return r}return null}setupMatrixForHighPrecision(e,t){let n=0;for(let t=0;t<this._clippingContextListForMask.getSize();t++){let r=this._clippingContextListForMask.at(t);this.calcClippedDrawTotalBounds(e,r),r._isUsing&&n++}if(n>0){if(this.setupLayoutBounds(0),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount){this._clearedFrameBufferFlags.clear();for(let e=0;e<this._renderTextureCount;e++)this._clearedFrameBufferFlags.pushBack(!1)}else for(let e=0;e<this._renderTextureCount;e++)this._clearedFrameBufferFlags.set(e,!1);for(let n=0;n<this._clippingContextListForMask.getSize();n++){let r=this._clippingContextListForMask.at(n),i=r._allClippedDrawRect,a=r._layoutBounds,o=.05,s=0,c=0,l=e.getPixelsPerUnit(),u=r.getClippingManager().getClippingMaskBufferSize(),d=a.width*u,f=a.height*u;this._tmpBoundsOnModel.setRect(i),this._tmpBoundsOnModel.width*l>d?(this._tmpBoundsOnModel.expand(i.width*o,0),s=a.width/this._tmpBoundsOnModel.width):s=l/d,this._tmpBoundsOnModel.height*l>f?(this._tmpBoundsOnModel.expand(0,i.height*o),c=a.height/this._tmpBoundsOnModel.height):c=l/f,this.createMatrixForMask(t,a,s,c),r._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),r._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray())}}}createMatrixForMask(e,t,n,r){this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(t.x,t.y),this._tmpMatrix.scaleRelative(n,r),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(t.x,t.y*(e?-1:1)),this._tmpMatrix.scaleRelative(n,r*(e?-1:1)),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray())}setupLayoutBounds(e){let t=this._renderTextureCount<=1?36:32*this._renderTextureCount;if(e<=0||e>t){e>t&&Bw(`not supported mask count : {0}
|
|
990
|
+
[Details] render texture count : {1}, mask count : {2}`,e-t,this._renderTextureCount,e);for(let e=0;e<this._clippingContextListForMask.getSize();e++){let t=this._clippingContextListForMask.at(e);t._layoutChannelIndex=0,t._layoutBounds.x=0,t._layoutBounds.y=0,t._layoutBounds.width=1,t._layoutBounds.height=1,t._bufferIndex=0}return}let n=this._renderTextureCount<=1?9:8,r=e/this._renderTextureCount,i=e%this._renderTextureCount;r=Math.ceil(r);let a=r/4,o=r%4;a=~~a;let s=0;for(let r=0;r<this._renderTextureCount;r++)for(let c=0;c<4;c++){let l=a+ +(c<o),u=o+(a<1?-1:0);if(c==u&&i>0&&(l-=r<i?0:1),l!=0)if(l==1){let e=this._clippingContextListForMask.at(s++);e._layoutChannelIndex=c,e._layoutBounds.x=0,e._layoutBounds.y=0,e._layoutBounds.width=1,e._layoutBounds.height=1,e._bufferIndex=r}else if(l==2)for(let e=0;e<l;e++){let t=e%2;t=~~t;let n=this._clippingContextListForMask.at(s++);n._layoutChannelIndex=c,n._layoutBounds.x=t*.5,n._layoutBounds.y=0,n._layoutBounds.width=.5,n._layoutBounds.height=1,n._bufferIndex=r}else if(l<=4)for(let e=0;e<l;e++){let t=e%2,n=e/2;t=~~t,n=~~n;let i=this._clippingContextListForMask.at(s++);i._layoutChannelIndex=c,i._layoutBounds.x=t*.5,i._layoutBounds.y=n*.5,i._layoutBounds.width=.5,i._layoutBounds.height=.5,i._bufferIndex=r}else if(l<=n)for(let e=0;e<l;e++){let t=e%3,n=e/3;t=~~t,n=~~n;let i=this._clippingContextListForMask.at(s++);i._layoutChannelIndex=c,i._layoutBounds.x=t/3,i._layoutBounds.y=n/3,i._layoutBounds.width=1/3,i._layoutBounds.height=1/3,i._bufferIndex=r}else{Bw(`not supported mask count : {0}
|
|
991
|
+
[Details] render texture count : {1}, mask count : {2}`,e-t,this._renderTextureCount,e);for(let e=0;e<l;e++){let e=this._clippingContextListForMask.at(s++);e._layoutChannelIndex=0,e._layoutBounds.x=0,e._layoutBounds.y=0,e._layoutBounds.width=1,e._layoutBounds.height=1,e._bufferIndex=0}}}}calcClippedDrawTotalBounds(e,t){let n=Number.MAX_VALUE,r=Number.MAX_VALUE,i=Number.MIN_VALUE,a=Number.MIN_VALUE,o=t._clippedDrawableIndexList.length;for(let s=0;s<o;s++){let o=t._clippedDrawableIndexList[s],c=e.getDrawableVertexCount(o),l=e.getDrawableVertices(o),u=Number.MAX_VALUE,d=Number.MAX_VALUE,f=-Number.MAX_VALUE,p=-Number.MAX_VALUE,m=c*dT.vertexStep;for(let e=dT.vertexOffset;e<m;e+=dT.vertexStep){let t=l[e],n=l[e+1];t<u&&(u=t),t>f&&(f=t),n<d&&(d=n),n>p&&(p=n)}if(u!=Number.MAX_VALUE)if(u<n&&(n=u),d<r&&(r=d),f>i&&(i=f),p>a&&(a=p),n==Number.MAX_VALUE)t._allClippedDrawRect.x=0,t._allClippedDrawRect.y=0,t._allClippedDrawRect.width=0,t._allClippedDrawRect.height=0,t._isUsing=!1;else{t._isUsing=!0;let e=i-n,o=a-r;t._allClippedDrawRect.x=n,t._allClippedDrawRect.y=r,t._allClippedDrawRect.width=e,t._allClippedDrawRect.height=o}}}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}getChannelFlagAsColor(e){return this._channelColors.at(e)}setClippingMaskBufferSize(e){this._clippingMaskBufferSize=e}};let hO;var gO=class{constructor(){this._shaderSets=new J}release(){this.releaseShaderProgram()}setupShaderProgramForDraw(e,t,n){e.isPremultipliedAlpha()||Bw(`NoPremultipliedAlpha is not allowed`),this._shaderSets.getSize()==0&&this.generateShaders();let r,i,a,o,s=e.getClippingContextBufferForDraw()!=null,c=t.getDrawableInvertedMaskBit(n),l=s?c?2:1:0,u;switch(t.getDrawableBlendMode(n)){case Aw.CubismBlendMode_Normal:default:u=this._shaderSets.at(1+l),r=this.gl.ONE,i=this.gl.ONE_MINUS_SRC_ALPHA,a=this.gl.ONE,o=this.gl.ONE_MINUS_SRC_ALPHA;break;case Aw.CubismBlendMode_Additive:u=this._shaderSets.at(4+l),r=this.gl.ONE,i=this.gl.ONE,a=this.gl.ZERO,o=this.gl.ONE;break;case Aw.CubismBlendMode_Multiplicative:u=this._shaderSets.at(7+l),r=this.gl.DST_COLOR,i=this.gl.ONE_MINUS_SRC_ALPHA,a=this.gl.ZERO,o=this.gl.ONE;break}this.gl.useProgram(u.shaderProgram),e._bufferData.vertex??(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex);let d=t.getDrawableVertices(n);this.gl.bufferData(this.gl.ARRAY_BUFFER,d,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(u.attributePositionLocation),this.gl.vertexAttribPointer(u.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),e._bufferData.uv??(e._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.uv);let f=t.getDrawableVertexUvs(n);if(this.gl.bufferData(this.gl.ARRAY_BUFFER,f,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(u.attributeTexCoordLocation),this.gl.vertexAttribPointer(u.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),s){this.gl.activeTexture(this.gl.TEXTURE1);let t=e.getClippingContextBufferForDraw().getClippingManager().getColorBuffer().at(e.getClippingContextBufferForDraw()._bufferIndex);this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.uniform1i(u.samplerTexture1Location,1),this.gl.uniformMatrix4fv(u.uniformClipMatrixLocation,!1,e.getClippingContextBufferForDraw()._matrixForDraw.getArray());let n=e.getClippingContextBufferForDraw()._layoutChannelIndex,r=e.getClippingContextBufferForDraw().getClippingManager().getChannelFlagAsColor(n);this.gl.uniform4f(u.uniformChannelFlagLocation,r.r,r.g,r.b,r.a)}let p=t.getDrawableTextureIndex(n),m=e.getBindedTextures().getValue(p);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,m),this.gl.uniform1i(u.samplerTexture0Location,0);let h=e.getMvpMatrix();this.gl.uniformMatrix4fv(u.uniformMatrixLocation,!1,h.getArray());let g=e.getModelColorWithOpacity(t.getDrawableOpacity(n)),_=t.getMultiplyColor(n),v=t.getScreenColor(n);this.gl.uniform4f(u.uniformBaseColorLocation,g.r,g.g,g.b,g.a),this.gl.uniform4f(u.uniformMultiplyColorLocation,_.r,_.g,_.b,_.a),this.gl.uniform4f(u.uniformScreenColorLocation,v.r,v.g,v.b,v.a),e._bufferData.index??(e._bufferData.index=this.gl.createBuffer());let y=t.getDrawableVertexIndices(n);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,e._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,y,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(r,i,a,o)}setupShaderProgramForMask(e,t,n){e.isPremultipliedAlpha()||Bw(`NoPremultipliedAlpha is not allowed`),this._shaderSets.getSize()==0&&this.generateShaders();let r=this._shaderSets.at(0);this.gl.useProgram(r.shaderProgram),e._bufferData.vertex??(e._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.vertex);let i=t.getDrawableVertices(n);this.gl.bufferData(this.gl.ARRAY_BUFFER,i,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(r.attributePositionLocation),this.gl.vertexAttribPointer(r.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),e._bufferData.uv??(e._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.uv);let a=t.getDrawableTextureIndex(n),o=e.getBindedTextures().getValue(a);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,o),this.gl.uniform1i(r.samplerTexture0Location,0),e._bufferData.uv??(e._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e._bufferData.uv);let s=t.getDrawableVertexUvs(n);this.gl.bufferData(this.gl.ARRAY_BUFFER,s,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(r.attributeTexCoordLocation),this.gl.vertexAttribPointer(r.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),e.getClippingContextBufferForMask();let c=e.getClippingContextBufferForMask()._layoutChannelIndex,l=e.getClippingContextBufferForMask().getClippingManager().getChannelFlagAsColor(c);this.gl.uniform4f(r.uniformChannelFlagLocation,l.r,l.g,l.b,l.a),this.gl.uniformMatrix4fv(r.uniformClipMatrixLocation,!1,e.getClippingContextBufferForMask()._matrixForMask.getArray());let u=e.getClippingContextBufferForMask()._layoutBounds;this.gl.uniform4f(r.uniformBaseColorLocation,u.x*2-1,u.y*2-1,u.getRight()*2-1,u.getBottom()*2-1);let d=t.getMultiplyColor(n),f=t.getScreenColor(n);this.gl.uniform4f(r.uniformMultiplyColorLocation,d.r,d.g,d.b,d.a),this.gl.uniform4f(r.uniformScreenColorLocation,f.r,f.g,f.b,f.a);let p=this.gl.ZERO,m=this.gl.ONE_MINUS_SRC_COLOR,h=this.gl.ZERO,g=this.gl.ONE_MINUS_SRC_ALPHA;e._bufferData.index??(e._bufferData.index=this.gl.createBuffer());let _=t.getDrawableVertexIndices(n);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,e._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,_,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(p,m,h,g)}releaseShaderProgram(){for(let e=0;e<this._shaderSets.getSize();e++)this.gl.deleteProgram(this._shaderSets.at(e).shaderProgram),this._shaderSets.at(e).shaderProgram=0,this._shaderSets.set(e,void 0),this._shaderSets.set(e,null)}generateShaders(){for(let e=0;e<10;e++)this._shaderSets.pushBack(new vO);this._shaderSets.at(0).shaderProgram=this.loadShaderProgram(bO,xO),this._shaderSets.at(1).shaderProgram=this.loadShaderProgram(SO,wO),this._shaderSets.at(2).shaderProgram=this.loadShaderProgram(CO,TO),this._shaderSets.at(3).shaderProgram=this.loadShaderProgram(CO,EO),this._shaderSets.at(4).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(5).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(6).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(7).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(8).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(9).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(0).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,`a_position`),this._shaderSets.at(0).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,`a_texCoord`),this._shaderSets.at(0).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,`s_texture0`),this._shaderSets.at(0).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,`u_clipMatrix`),this._shaderSets.at(0).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,`u_channelFlag`),this._shaderSets.at(0).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,`u_baseColor`),this._shaderSets.at(0).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,`u_multiplyColor`),this._shaderSets.at(0).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,`u_screenColor`),this._shaderSets.at(1).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,`a_position`),this._shaderSets.at(1).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,`a_texCoord`),this._shaderSets.at(1).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,`s_texture0`),this._shaderSets.at(1).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,`u_matrix`),this._shaderSets.at(1).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,`u_baseColor`),this._shaderSets.at(1).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,`u_multiplyColor`),this._shaderSets.at(1).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,`u_screenColor`),this._shaderSets.at(2).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,`a_position`),this._shaderSets.at(2).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,`a_texCoord`),this._shaderSets.at(2).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`s_texture0`),this._shaderSets.at(2).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`s_texture1`),this._shaderSets.at(2).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`u_matrix`),this._shaderSets.at(2).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`u_clipMatrix`),this._shaderSets.at(2).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`u_channelFlag`),this._shaderSets.at(2).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`u_baseColor`),this._shaderSets.at(2).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`u_multiplyColor`),this._shaderSets.at(2).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,`u_screenColor`),this._shaderSets.at(3).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,`a_position`),this._shaderSets.at(3).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,`a_texCoord`),this._shaderSets.at(3).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`s_texture0`),this._shaderSets.at(3).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`s_texture1`),this._shaderSets.at(3).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`u_matrix`),this._shaderSets.at(3).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`u_clipMatrix`),this._shaderSets.at(3).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`u_channelFlag`),this._shaderSets.at(3).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`u_baseColor`),this._shaderSets.at(3).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`u_multiplyColor`),this._shaderSets.at(3).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,`u_screenColor`),this._shaderSets.at(4).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,`a_position`),this._shaderSets.at(4).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,`a_texCoord`),this._shaderSets.at(4).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,`s_texture0`),this._shaderSets.at(4).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,`u_matrix`),this._shaderSets.at(4).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,`u_baseColor`),this._shaderSets.at(4).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,`u_multiplyColor`),this._shaderSets.at(4).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,`u_screenColor`),this._shaderSets.at(5).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,`a_position`),this._shaderSets.at(5).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,`a_texCoord`),this._shaderSets.at(5).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`s_texture0`),this._shaderSets.at(5).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`s_texture1`),this._shaderSets.at(5).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`u_matrix`),this._shaderSets.at(5).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`u_clipMatrix`),this._shaderSets.at(5).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`u_channelFlag`),this._shaderSets.at(5).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`u_baseColor`),this._shaderSets.at(5).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`u_multiplyColor`),this._shaderSets.at(5).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,`u_screenColor`),this._shaderSets.at(6).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,`a_position`),this._shaderSets.at(6).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,`a_texCoord`),this._shaderSets.at(6).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`s_texture0`),this._shaderSets.at(6).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`s_texture1`),this._shaderSets.at(6).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`u_matrix`),this._shaderSets.at(6).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`u_clipMatrix`),this._shaderSets.at(6).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`u_channelFlag`),this._shaderSets.at(6).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`u_baseColor`),this._shaderSets.at(6).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`u_multiplyColor`),this._shaderSets.at(6).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,`u_screenColor`),this._shaderSets.at(7).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,`a_position`),this._shaderSets.at(7).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,`a_texCoord`),this._shaderSets.at(7).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,`s_texture0`),this._shaderSets.at(7).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,`u_matrix`),this._shaderSets.at(7).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,`u_baseColor`),this._shaderSets.at(7).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,`u_multiplyColor`),this._shaderSets.at(7).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,`u_screenColor`),this._shaderSets.at(8).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,`a_position`),this._shaderSets.at(8).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,`a_texCoord`),this._shaderSets.at(8).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`s_texture0`),this._shaderSets.at(8).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`s_texture1`),this._shaderSets.at(8).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`u_matrix`),this._shaderSets.at(8).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`u_clipMatrix`),this._shaderSets.at(8).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`u_channelFlag`),this._shaderSets.at(8).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`u_baseColor`),this._shaderSets.at(8).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`u_multiplyColor`),this._shaderSets.at(8).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,`u_screenColor`),this._shaderSets.at(9).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,`a_position`),this._shaderSets.at(9).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,`a_texCoord`),this._shaderSets.at(9).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`s_texture0`),this._shaderSets.at(9).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`s_texture1`),this._shaderSets.at(9).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`u_matrix`),this._shaderSets.at(9).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`u_clipMatrix`),this._shaderSets.at(9).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`u_channelFlag`),this._shaderSets.at(9).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`u_baseColor`),this._shaderSets.at(9).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`u_multiplyColor`),this._shaderSets.at(9).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,`u_screenColor`)}loadShaderProgram(e,t){let n=this.gl.createProgram(),r=this.compileShaderSource(this.gl.VERTEX_SHADER,e);if(!r)return Bw(`Vertex shader compile error!`),0;let i=this.compileShaderSource(this.gl.FRAGMENT_SHADER,t);return i?(this.gl.attachShader(n,r),this.gl.attachShader(n,i),this.gl.linkProgram(n),this.gl.getProgramParameter(n,this.gl.LINK_STATUS)?(this.gl.deleteShader(r),this.gl.deleteShader(i),n):(Bw(`Failed to link program: {0}`,n),this.gl.deleteShader(r),r=0,this.gl.deleteShader(i),i=0,n&&=(this.gl.deleteProgram(n),0),0)):(Bw(`Vertex shader compile error!`),0)}compileShaderSource(e,t){let n=t,r=this.gl.createShader(e);if(this.gl.shaderSource(r,n),this.gl.compileShader(r),!r){let e=this.gl.getShaderInfoLog(r);Bw(`Shader compile log: {0} `,e)}return this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS)?r:(this.gl.deleteShader(r),null)}setGl(e){this.gl=e}},_O=class e{static getInstance(){return hO??=new e,hO}static deleteInstance(){hO&&=(hO.release(),null)}constructor(){this._shaderMap=new Gw}release(){for(let e=this._shaderMap.begin();e.notEqual(this._shaderMap.end());e.preIncrement())e.ptr().second.release();this._shaderMap.clear()}getShader(e){return this._shaderMap.getValue(e)}setGlContext(e){if(!this._shaderMap.isExist(e)){let t=new gO;t.setGl(e),this._shaderMap.setValue(e,t)}}},vO=class{},yO=(e=>(e[e.ShaderNames_SetupMask=0]=`ShaderNames_SetupMask`,e[e.ShaderNames_NormalPremultipliedAlpha=1]=`ShaderNames_NormalPremultipliedAlpha`,e[e.ShaderNames_NormalMaskedPremultipliedAlpha=2]=`ShaderNames_NormalMaskedPremultipliedAlpha`,e[e.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]=`ShaderNames_NomralMaskedInvertedPremultipliedAlpha`,e[e.ShaderNames_AddPremultipliedAlpha=4]=`ShaderNames_AddPremultipliedAlpha`,e[e.ShaderNames_AddMaskedPremultipliedAlpha=5]=`ShaderNames_AddMaskedPremultipliedAlpha`,e[e.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]=`ShaderNames_AddMaskedPremultipliedAlphaInverted`,e[e.ShaderNames_MultPremultipliedAlpha=7]=`ShaderNames_MultPremultipliedAlpha`,e[e.ShaderNames_MultMaskedPremultipliedAlpha=8]=`ShaderNames_MultMaskedPremultipliedAlpha`,e[e.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]=`ShaderNames_MultMaskedPremultipliedAlphaInverted`,e))(yO||{});let bO=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,xO=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}`,SO=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,CO=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,wO=`precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}`,TO=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}`,EO=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}`;var DO;(e=>{e.CubismShaderSet=vO,e.CubismShader_WebGL=gO,e.CubismShaderManager_WebGL=_O,e.ShaderNames=yO})(DO||={});let OO,kO;var AO=class extends mO{getMaskRenderTexture(){if(this._maskTexture&&this._maskTexture.textures!=null)this._maskTexture.frameNo=this._currentFrameNo;else{this._maskRenderTextures!=null&&this._maskRenderTextures.clear(),this._maskRenderTextures=new J,this._maskColorBuffers!=null&&this._maskColorBuffers.clear(),this._maskColorBuffers=new J;let e=this._clippingMaskBufferSize;for(let t=0;t<this._renderTextureCount;t++)this._maskColorBuffers.pushBack(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers.at(t)),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,e,e,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.pushBack(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures.at(t)),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers.at(t),0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,kO),this._maskTexture=new jO(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(e){this.gl=e}constructor(){super(MO)}setupClippingContext(e,t){this._currentFrameNo++;let n=0;for(let t=0;t<this._clippingContextListForMask.getSize();t++){let r=this._clippingContextListForMask.at(t);this.calcClippedDrawTotalBounds(e,r),r._isUsing&&n++}if(n>0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture().at(0),t.preDraw(),this.setupLayoutBounds(n),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount&&(this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=new J(this._renderTextureCount));for(let e=0;e<this._clearedFrameBufferFlags.getSize();e++)this._clearedFrameBufferFlags.set(e,!1);for(let n=0;n<this._clippingContextListForMask.getSize();n++){let r=this._clippingContextListForMask.at(n),i=r._allClippedDrawRect,a=r._layoutBounds,o=.05,s=0,c=0,l=this.getMaskRenderTexture().at(r._bufferIndex);this._currentMaskRenderTexture!=l&&(this._currentMaskRenderTexture=l,t.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._tmpBoundsOnModel.setRect(i),this._tmpBoundsOnModel.expand(i.width*o,i.height*o),s=a.width/this._tmpBoundsOnModel.width,c=a.height/this._tmpBoundsOnModel.height,this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(s,c),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(s,c),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),r._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),r._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());let u=r._clippingIdCount;for(let n=0;n<u;n++){let i=r._clippingIdList[n];e.getDrawableDynamicFlagVertexPositionsDidChange(i)&&(t.setIsCulling(e.getDrawableCulling(i)!=0),this._clearedFrameBufferFlags.at(r._bufferIndex)||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferFlags.set(r._bufferIndex,!0)),t.setClippingContextBufferForMask(r),t.drawMeshWebGL(e,i))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,kO),t.setClippingContextBufferForMask(null),this.gl.viewport(OO[0],OO[1],OO[2],OO[3])}}getColorBuffer(){return this._maskColorBuffers}getClippingMaskCount(){return this._clippingContextListForMask.getSize()}},jO=class{constructor(e,t){this.frameNo=e,this.textures=t}},MO=class extends Mw{constructor(e,t,n){super(t,n),this._owner=e}getClippingManager(){return this._owner}setGl(e){this._owner.setGL(e)}},NO=class{setGlEnable(e,t){t?this.gl.enable(e):this.gl.disable(e)}setGlEnableVertexAttribArray(e,t){t?this.gl.enableVertexAttribArray(e):this.gl.disableVertexAttribArray(e)}save(){if(this.gl==null){Bw(`'gl' is null. WebGLRenderingContext is required.
|
|
992
|
+
Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastElementArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)}restore(){if(this.gl==null){Bw(`'gl' is null. WebGLRenderingContext is required.
|
|
993
|
+
Please call 'CubimRenderer_WebGL.startUp' function.`);return}this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])}setGl(e){this.gl=e}constructor(){this._lastVertexAttribArrayEnabled=[,,,,],this._lastColorMask=[,,,,],this._lastBlending=[,,,,],this._lastViewport=[,,,,]}},PO=class extends kw{initialize(e,t=1){e.isUsingMasking()&&(this._clippingManager=new AO,this._clippingManager.initialize(e,t)),this._sortedDrawableIndexList.resize(e.getDrawableCount(),0),super.initialize(e)}bindTexture(e,t){this._textures.setValue(e,t)}getBindedTextures(){return this._textures}setClippingMaskBufferSize(e){if(!this._model.isUsingMasking())return;let t=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=void 0,this._clippingManager=null,this._clippingManager=new AO,this._clippingManager.setClippingMaskBufferSize(e),this._clippingManager.initialize(this.getModel(),t)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new NO,this.firstDraw=!0,this._textures=new Gw,this._sortedDrawableIndexList=new J,this._bufferData={vertex:WebGLBuffer=null,uv:WebGLBuffer=null,index:WebGLBuffer=null},this._textures.prepareCapacity(32,!0)}release(){this._clippingManager&&=(this._clippingManager.release(),this._clippingManager=void 0,null),this.gl!=null&&(this.gl.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,this.gl.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,this.gl.deleteBuffer(this._bufferData.index),this._bufferData.index=null,this._bufferData=null,this._textures=null)}doDrawModel(){if(this.gl==null){Bw(`'gl' is null. WebGLRenderingContext is required.
|
|
994
|
+
Please call 'CubimRenderer_WebGL.startUp' function.`);return}this._clippingManager!=null&&(this.preDraw(),this.isUsingHighPrecisionMask()?this._clippingManager.setupMatrixForHighPrecision(this.getModel(),!1):this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();let e=this.getModel().getDrawableCount(),t=this.getModel().getDrawableRenderOrders();for(let n=0;n<e;++n){let e=t[n];this._sortedDrawableIndexList.set(e,n)}for(let t=0;t<e;++t){let e=this._sortedDrawableIndexList.at(t);if(!this.getModel().getDrawableDynamicFlagIsVisible(e))continue;let n=this._clippingManager==null?null:this._clippingManager.getClippingContextListForDraw().at(e);if(n!=null&&this.isUsingHighPrecisionMask()){n._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,n.getClippingManager().getMaskRenderTexture().at(n._bufferIndex)),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{let e=n._clippingIdCount;for(let t=0;t<e;t++){let e=n._clippingIdList[t];this._model.getDrawableDynamicFlagVertexPositionsDidChange(e)&&(this.setIsCulling(this._model.getDrawableCulling(e)!=0),this.setClippingContextBufferForMask(n),this.drawMeshWebGL(this._model,e))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,kO),this.setClippingContextBufferForMask(null),this.gl.viewport(OO[0],OO[1],OO[2],OO[3]),this.preDraw()}this.setClippingContextBufferForDraw(n),this.setIsCulling(this.getModel().getDrawableCulling(e)),this.drawMeshWebGL(this._model,e)}}drawMeshWebGL(e,t){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),this.isGeneratingMask()?_O.getInstance().getShader(this.gl).setupShaderProgramForMask(this,e,t):_O.getInstance().getShader(this.gl).setupShaderProgramForDraw(this,e,t);{let n=e.getDrawableVertexIndexCount(t);this.gl.drawElements(this.gl.TRIANGLES,n,this.gl.UNSIGNED_SHORT,0)}this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){_O.deleteInstance()}setRenderState(e,t){kO=e,OO=t}preDraw(){if(this.firstDraw&&=!1,this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(let e=0;e<this._textures.getSize();++e)this.gl.bindTexture(this.gl.TEXTURE_2D,this._textures.getValue(e)),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(e){this._clippingContextBufferForMask=e}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(e){this._clippingContextBufferForDraw=e}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}isGeneratingMask(){return this.getClippingContextBufferForMask()!=null}startUp(e){this.gl=e,this._clippingManager&&this._clippingManager.setGL(e),_O.getInstance().setGlContext(e),this._rendererProfile.setGl(e),this._extension=this.gl.getExtension(`EXT_texture_filter_anisotropic`)||this.gl.getExtension(`WEBKIT_EXT_texture_filter_anisotropic`)||this.gl.getExtension(`MOZ_EXT_texture_filter_anisotropic`)}};kw.staticRelease=()=>{PO.doStaticRelease()};var FO;(e=>{e.CubismClippingContext=MO,e.CubismClippingManager_WebGL=AO,e.CubismRenderTextureResource=jO,e.CubismRenderer_WebGL=PO})(FO||={});let IO=new Tw,LO={CenterX:`centerX`,centerX:`centerX`,center_x:`centerX`,CenterY:`centerY`,centerY:`centerY`,center_y:`centerY`,X:`x`,x:`x`,Y:`y`,y:`y`,Width:`width`,width:`width`,Height:`height`,height:`height`,Top:`top`,top:`top`,Bottom:`bottom`,bottom:`bottom`,Left:`left`,left:`left`,Right:`right`,right:`right`};function RO(e){if(!e.isUsingMasking())return 1;let t=e.getDrawableMaskCounts(),n=e.getDrawableMasks(),r=new Set;for(let i=0;i<e.getDrawableCount();i++){let e=t[i];if(!e||e<=0)continue;let a=Array.from(n[i]??[]).slice(0,e).sort((e,t)=>e-t).join(`,`);r.add(a)}let i=r.size;return i<=36?1:Math.ceil(i/32)}function zO(e){let t=e.getDrawableMaskCounts(),n=e.getDrawableMasks(),r=new Set,i=e.getDrawableCount(),a=0,o=0,s=0,c=0;for(let l=0;l<i;l++){let i=e.getDrawableVertexCount(l),u=t[l]??0;if(c+=i,u<=0)continue;a++,s+=i,o=Math.max(o,u);let d=Array.from(n[l]??[]).slice(0,u).sort((e,t)=>e-t).join(`,`);r.add(d)}return{maskedDrawableCount:a,uniqueMaskSetCount:r.size,maxMasksPerDrawable:o,maskedVertexCount:s,totalVertexCount:c}}function BO(e){if(!e.isUsingMasking())return!1;let t=zO(e),n=t.totalVertexCount>0?t.maskedVertexCount/t.totalVertexCount:0;return t.uniqueMaskSetCount>16||t.maskedDrawableCount>64||t.maxMasksPerDrawable>=3||t.maskedVertexCount>4096||n>=.5&&t.maskedDrawableCount>24}function VO(e,t){return typeof t==`boolean`?t:BO(e)}var HO=class extends sE{constructor(e,t,n){super(),K(this,`settings`),K(this,`options`),K(this,`coreModel`),K(this,`motionManager`),K(this,`parallelMotionManager`),K(this,`lipSync`,!0),K(this,`breath`,sO.create()),K(this,`eyeBlink`),K(this,`renderer`,new PO),K(this,`idManager`),K(this,`idParamAngleX`),K(this,`idParamAngleY`),K(this,`idParamAngleZ`),K(this,`idParamEyeBallX`),K(this,`idParamEyeBallY`),K(this,`idParamBodyAngleX`),K(this,`idParamBreath`),K(this,`idParamMouthForm`),K(this,`pixelsPerUnit`,1),K(this,`modelTransform`,new j),this.coreModel=e,this.settings=t,this.options=Object.assign({},{breathDepth:1,lipSyncGain:1.5,lipSyncWeight:.4},n),this.idManager=pT.getIdManager(),this.idParamAngleX=this.getIdSafe($.ParamAngleX),this.idParamAngleY=this.getIdSafe($.ParamAngleY),this.idParamAngleZ=this.getIdSafe($.ParamAngleZ),this.idParamEyeBallX=this.getIdSafe($.ParamEyeBallX),this.idParamEyeBallY=this.getIdSafe($.ParamEyeBallY),this.idParamBodyAngleX=this.getIdSafe($.ParamBodyAngleX),this.idParamBreath=this.getIdSafe($.ParamBreath),this.idParamMouthForm=this.getIdSafe($.ParamMouthForm),this.motionManager=new GD(this),this.parallelMotionManager=[],this.init()}init(){var e;super.init();let t=this.settings.getEyeBlinkParameters();if(this.options.eyeBlink!==!1&&t.length){let n=new J;for(let e of t)n.pushBack(this.idManager.getId(e));let r=dO.create();(e=r.setParameterIds)==null||e.call(r,n),this.eyeBlink=r}let n=new J;n.pushBack(new cO(this.idParamAngleX,0,15*this.options.breathDepth,6.5345,.5)),n.pushBack(new cO(this.idParamAngleY,0,8*this.options.breathDepth,3.5345,.5)),n.pushBack(new cO(this.idParamAngleZ,0,10*this.options.breathDepth,5.5345,.5)),n.pushBack(new cO(this.idParamBodyAngleX,0,4*this.options.breathDepth,15.5345,.5)),n.pushBack(new cO(this.idParamBreath,0,.5,3.2345,.5)),this.breath.setParameters(n),this.renderer.initialize(this.coreModel,RO(this.coreModel)),this.renderer.useHighPrecisionMask(VO(this.coreModel,this.options.useHighPrecisionMask)),this.renderer.setIsPremultipliedAlpha(!0)}getIdSafe(e){return this.idManager.getId(e??``)}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){let e={},t=this.settings.layout;if(t)for(let[n,r]of Object.entries(t)){let t=LO[n];t&&typeof r==`number`&&(e[t]=r)}return e}setupLayout(){let e=this,t=this.getSize();e.originalWidth=t[0],e.originalHeight=t[1],e.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit;let n=iE(this.localTransform,this.originalWidth,this.originalHeight,this.getLayout());e.width=n.width,e.height=n.height,this.modelTransform.identity().scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(e,t){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(e),this.renderer._clippingManager&&(this.renderer._clippingManager._currentFrameNo=t),_O.getInstance().setGlContext(e)}bindTexture(e,t){this.renderer.bindTexture(e,t)}getHitAreaDefs(){let e=this.settings.json;return aE(this.settings.hitAreas??e.HitAreas??e.hitAreas??e.hit_areas,e=>this.coreModel.getDrawableIndex(this.idManager.getId(e)))}getDrawableIDs(){let e=this.coreModel.getDrawableCount(),t=[];for(let n=0;n<e;n++)t.push(this.coreModel.getDrawableId(n).getString().s);return t}getDrawableIndex(e){return this.coreModel.getDrawableIndex(this.idManager.getId(e))}getDrawableVertices(e){if(typeof e==`string`){let t=e;if(e=this.getDrawableIndex(t),e===-1)throw TypeError(`Unable to find drawable ID: `+t)}let t=this.coreModel.getDrawableVertices(e).slice();for(let e=0;e<t.length;e+=2)t[e]=t[e]*this.pixelsPerUnit+this.originalWidth/2,t[e+1]=-t[e+1]*this.pixelsPerUnit+this.originalHeight/2;return t}updateTransform(e){this.drawingMatrix.copyFrom(this.modelTransform).prepend(this.localTransform).prepend(e)}update(e,t){var n,r,i,a,o;super.update(e,t),e/=1e3,t/=1e3;let s=this.coreModel,c=this.updateMotions(s,t);if(s.saveParameters(),(n=this.motionManager.expressionManager)==null||n.update(s,t),c||(i=(r=this.eyeBlink)?.updateParameters)==null||i.call(r,s,e),this.updateFocus(),this.updateNaturalMovements(e*1e3,t*1e3),this.lipSync&&this.motionManager.currentAudio){let e=this.motionManager.mouthSync()*this.options.lipSyncGain;e**=1.15,e=_T(e,e>0?.1:0,1),this.motionManager.lipSyncIds.forEach(t=>{s.addParameterValueById(this.getIdSafe(t),e,this.options.lipSyncWeight)})}(a=this.physics)==null||a.evaluate(s,e),(o=this.pose)==null||o.updateParameters(s,e),this.emit(`beforeModelUpdate`),s.update(),s.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,this.focusController.x*30),this.coreModel.addParameterValueById(this.idParamAngleY,this.focusController.y*30),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,this.focusController.x*10)}updateFacialEmotion(e){this.coreModel.addParameterValueById(this.idParamMouthForm,e)}updateNaturalMovements(e,t){var n;(n=this.breath)==null||n.updateParameters(this.coreModel,e/1e3)}draw(e){let t=this.drawingMatrix,n=IO.getArray();n[0]=t.a,n[1]=t.b,n[4]=-t.c,n[5]=-t.d,n[12]=t.tx,n[13]=t.ty,this.renderer.setMvpMatrix(IO);let r=e.getParameter(e.FRAMEBUFFER_BINDING),i=e.getParameter(e.CULL_FACE_MODE),a=n[0]*n[5]-n[1]*n[4];e.cullFace(a<0?e.FRONT:e.BACK),this.renderer.setRenderState(r,this.viewport);try{this.renderer.drawModel()}finally{e.cullFace(i)}}extendParallelMotionManager(e){for(;this.parallelMotionManager.length<e;)this.parallelMotionManager.push(new $D(this))}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}},UO=class{},WO;(e=>{e.ICubismModelSetting=UO})(WO||={});var GO=(e=>(e[e.FrequestNode_Groups=0]=`FrequestNode_Groups`,e[e.FrequestNode_Moc=1]=`FrequestNode_Moc`,e[e.FrequestNode_Motions=2]=`FrequestNode_Motions`,e[e.FrequestNode_Expressions=3]=`FrequestNode_Expressions`,e[e.FrequestNode_Textures=4]=`FrequestNode_Textures`,e[e.FrequestNode_Physics=5]=`FrequestNode_Physics`,e[e.FrequestNode_Pose=6]=`FrequestNode_Pose`,e[e.FrequestNode_HitAreas=7]=`FrequestNode_HitAreas`,e))(GO||{}),KO=class extends UO{constructor(e,t){super(),this.version=`Version`,this.fileReferences=`FileReferences`,this.groups=`Groups`,this.layout=`Layout`,this.hitAreas=`HitAreas`,this.moc=`Moc`,this.textures=`Textures`,this.physics=`Physics`,this.pose=`Pose`,this.expressions=`Expressions`,this.motions=`Motions`,this.userData=`UserData`,this.name=`Name`,this.filePath=`File`,this.id=`Id`,this.ids=`Ids`,this.target=`Target`,this.idle=`Idle`,this.tapBody=`TapBody`,this.pinchIn=`PinchIn`,this.pinchOut=`PinchOut`,this.shake=`Shake`,this.flickHead=`FlickHead`,this.parameter=`Parameter`,this.soundPath=`Sound`,this.fadeInTime=`FadeInTime`,this.fadeOutTime=`FadeOutTime`,this.centerX=`CenterX`,this.centerY=`CenterY`,this.x=`X`,this.y=`Y`,this.width=`Width`,this.height=`Height`,this.lipSync=`LipSync`,this.eyeBlink=`EyeBlink`,this.initParameter=`init_param`,this.initPartsVisible=`init_parts_visible`,this.val=`val`,this._json=Zw.create(e,t),this.getJson()&&(this._jsonValue=new J,this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.groups)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.moc)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.motions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.expressions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.textures)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.physics)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.pose)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.hitAreas)))}release(){Zw.delete(this._json),this._jsonValue=null}getJson(){return this._json}getModelFileName(){return this.isExistModelFile()?this._jsonValue.at(1).getRawString():``}getTextureCount(){return this.isExistTextureFiles()?this._jsonValue.at(4).getSize():0}getTextureDirectory(){let e=this._jsonValue.at(4).getValueByIndex(0).getRawString().split(`/`),t=e.length-1,n=``;for(let r=0;r<t;r++)n+=e[r],r<t-1&&(n+=`/`);return n}getTextureFileName(e){return this._jsonValue.at(4).getValueByIndex(e).getRawString()}getHitAreasCount(){return this.isExistHitAreas()?this._jsonValue.at(7).getSize():0}getHitAreaId(e){return pT.getIdManager().getId(this._jsonValue.at(7).getValueByIndex(e).getValueByString(this.id).getRawString())}getHitAreaName(e){return this._jsonValue.at(7).getValueByIndex(e).getValueByString(this.name).getRawString()}getPhysicsFileName(){return this.isExistPhysicsFile()?this._jsonValue.at(5).getRawString():``}getPoseFileName(){return this.isExistPoseFile()?this._jsonValue.at(6).getRawString():``}getExpressionCount(){return this.isExistExpressionFile()?this._jsonValue.at(3).getSize():0}getExpressionName(e){return this._jsonValue.at(3).getValueByIndex(e).getValueByString(this.name).getRawString()}getExpressionFileName(e){return this._jsonValue.at(3).getValueByIndex(e).getValueByString(this.filePath).getRawString()}getMotionGroupCount(){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().getSize():0}getMotionGroupName(e){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().at(e):null}getMotionCount(e){return this.isExistMotionGroupName(e)?this._jsonValue.at(2).getValueByString(e).getSize():0}getMotionFileName(e,t){return this.isExistMotionGroupName(e)?this._jsonValue.at(2).getValueByString(e).getValueByIndex(t).getValueByString(this.filePath).getRawString():``}getMotionSoundFileName(e,t){return this.isExistMotionSoundFile(e,t)?this._jsonValue.at(2).getValueByString(e).getValueByIndex(t).getValueByString(this.soundPath).getRawString():``}getMotionFadeInTimeValue(e,t){return this.isExistMotionFadeIn(e,t)?this._jsonValue.at(2).getValueByString(e).getValueByIndex(t).getValueByString(this.fadeInTime).toFloat():-1}getMotionFadeOutTimeValue(e,t){return this.isExistMotionFadeOut(e,t)?this._jsonValue.at(2).getValueByString(e).getValueByIndex(t).getValueByString(this.fadeOutTime).toFloat():-1}getUserDataFile(){return this.isExistUserDataFile()?this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData).getRawString():``}getLayoutMap(e){let t=this.getJson().getRoot().getValueByString(this.layout).getMap();if(t==null)return!1;let n=!1;for(let r=t.begin();r.notEqual(t.end());r.preIncrement())e.setValue(r.ptr().first,r.ptr().second.toFloat()),n=!0;return n}getEyeBlinkParameterCount(){if(!this.isExistEyeBlinkParameters())return 0;let e=0;for(let t=0;t<this._jsonValue.at(0).getSize();t++){let n=this._jsonValue.at(0).getValueByIndex(t);if(!(n.isNull()||n.isError())&&n.getValueByString(this.name).getRawString()==this.eyeBlink){e=n.getValueByString(this.ids).getVector().getSize();break}}return e}getEyeBlinkParameterId(e){if(!this.isExistEyeBlinkParameters())return null;for(let t=0;t<this._jsonValue.at(0).getSize();t++){let n=this._jsonValue.at(0).getValueByIndex(t);if(!(n.isNull()||n.isError())&&n.getValueByString(this.name).getRawString()==this.eyeBlink)return pT.getIdManager().getId(n.getValueByString(this.ids).getValueByIndex(e).getRawString())}return null}getLipSyncParameterCount(){if(!this.isExistLipSyncParameters())return 0;let e=0;for(let t=0;t<this._jsonValue.at(0).getSize();t++){let n=this._jsonValue.at(0).getValueByIndex(t);if(!(n.isNull()||n.isError())&&n.getValueByString(this.name).getRawString()==this.lipSync){e=n.getValueByString(this.ids).getVector().getSize();break}}return e}getLipSyncParameterId(e){if(!this.isExistLipSyncParameters())return null;for(let t=0;t<this._jsonValue.at(0).getSize();t++){let n=this._jsonValue.at(0).getValueByIndex(t);if(!(n.isNull()||n.isError())&&n.getValueByString(this.name).getRawString()==this.lipSync)return pT.getIdManager().getId(n.getValueByString(this.ids).getValueByIndex(e).getRawString())}return null}isExistModelFile(){let e=this._jsonValue.at(1);return!e.isNull()&&!e.isError()}isExistTextureFiles(){let e=this._jsonValue.at(4);return!e.isNull()&&!e.isError()}isExistHitAreas(){let e=this._jsonValue.at(7);return!e.isNull()&&!e.isError()}isExistPhysicsFile(){let e=this._jsonValue.at(5);return!e.isNull()&&!e.isError()}isExistPoseFile(){let e=this._jsonValue.at(6);return!e.isNull()&&!e.isError()}isExistExpressionFile(){let e=this._jsonValue.at(3);return!e.isNull()&&!e.isError()}isExistMotionGroups(){let e=this._jsonValue.at(2);return!e.isNull()&&!e.isError()}isExistMotionGroupName(e){let t=this._jsonValue.at(2).getValueByString(e);return!t.isNull()&&!t.isError()}isExistMotionSoundFile(e,t){let n=this._jsonValue.at(2).getValueByString(e).getValueByIndex(t).getValueByString(this.soundPath);return!n.isNull()&&!n.isError()}isExistMotionFadeIn(e,t){let n=this._jsonValue.at(2).getValueByString(e).getValueByIndex(t).getValueByString(this.fadeInTime);return!n.isNull()&&!n.isError()}isExistMotionFadeOut(e,t){let n=this._jsonValue.at(2).getValueByString(e).getValueByIndex(t).getValueByString(this.fadeOutTime);return!n.isNull()&&!n.isError()}isExistUserDataFile(){let e=this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData);return!e.isNull()&&!e.isError()}isExistEyeBlinkParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let e=0;e<this._jsonValue.at(0).getSize();++e)if(this._jsonValue.at(0).getValueByIndex(e).getValueByString(this.name).getRawString()==this.eyeBlink)return!0;return!1}isExistLipSyncParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let e=0;e<this._jsonValue.at(0).getSize();++e)if(this._jsonValue.at(0).getValueByIndex(e).getValueByString(this.name).getRawString()==this.lipSync)return!0;return!1}},qO;(e=>{e.CubismModelSettingJson=KO,e.FrequestNode=GO})(qO||={});let JO=[$.ParamEyeLOpen,$.ParamEyeROpen];var YO=class e extends kT{constructor(t){if(super(t),K(this,`moc`),K(this,`textures`),K(this,`layout`),K(this,`hitAreas`),K(this,`expressions`),K(this,`motions`),!e.isValidJSON(t))throw TypeError(`Invalid JSON.`);let n=new TextEncoder().encode(JSON.stringify(t)).buffer;Object.assign(this,new KO(n,n.byteLength)),this.moc=t.FileReferences.Moc,this.textures=[...t.FileReferences.Textures],this.pose=t.FileReferences.Pose,this.physics=t.FileReferences.Physics,this.expressions=t.FileReferences.Expressions?.filter(e=>!!e&&typeof e.File==`string`),this.motions=t.FileReferences.Motions??t.Motions,this.layout=t.Layout,this.hitAreas=t.HitAreas;let r=this.getFileStem(this.moc);this.setModelName(r,this.name)}static isValidJSON(e){if(!e||typeof e!=`object`)return!1;let t=e.FileReferences;if(!t||typeof t!=`object`||typeof t.Moc!=`string`)return!1;let n=t.Textures;if(!Array.isArray(n)||n.length===0||!n.every(e=>typeof e==`string`))return!1;let r=t.Expressions,i=e=>!!e&&typeof e.File==`string`;return!(r!==void 0&&(!Array.isArray(r)||r.some(e=>!i(e))))}replaceFiles(e){if(super.replaceFiles(e),this.motions)for(let[t,n]of Object.entries(this.motions))for(let r=0;r<n.length;r++){let i=n[r];i?.File&&(i.File=e(i.File,`motions.${t}[${r}].File`),i.Sound&&=e(i.Sound,`motions.${t}[${r}].Sound`))}if(this.expressions)for(let t=0;t<this.expressions.length;t++){let n=this.expressions[t];n?.File&&(n.File=e(n.File,`expressions[${t}].File`))}}getEyeBlinkParameters(){let e=[],t=this.getEyeBlinkParameterCount?.call(this)??0;if(t>0)for(let n=0;n<t;n++){let t=this.getEyeBlinkParameterId?.call(this,n);t?.getString&&e.push(t.getString().s)}else{let t=!1,n=this.json.Groups;if(Array.isArray(n)){for(let r of n)if(r?.Name===`EyeBlink`&&(t=!0,Array.isArray(r.Ids)))for(let t of r.Ids)typeof t==`string`?e.push(t):t?.Id&&e.push(t.Id)}if(t)return e}return e.length?e:[...JO]}getLipSyncParameters(){let e=[],t=this.getLipSyncParameterCount?.call(this)??0;if(t>0)for(let n=0;n<t;n++){let t=this.getLipSyncParameterId?.call(this,n);t?.getString&&e.push(t.getString().s)}else if(Array.isArray(this.json.Groups)){let t=this.json.Groups;for(let n of t)if(!(n?.Name!==`LipSync`||!Array.isArray(n.Ids)))for(let t of n.Ids)typeof t==`string`?e.push(t):t?.Id&&e.push(t.Id)}return e}};xT(YO,[KO]);let XO,ZO=20,QO=16;function $O(e={}){e.memorySizeMB!=null&&(QO=e.memorySizeMB)}function ek(){return pT.isStarted()?Promise.resolve():(XO??=new Promise((e,t)=>{function n(){try{tk(),e()}catch(e){if(ZO--,ZO<0){t(Error(`Failed to start up Cubism framework.`,{cause:e}));return}X.log(`Cubism`,`Startup failed, retrying 10ms later...`),setTimeout(n,10)}}n()}),XO)}function tk(e,t){let n=mw({logFunction:console.log,loggingLevel:mT.LogLevel_Verbose},e),r=t??QO;pT.startUp(n),pT.initialize(vT(r))}let nk=.5,rk=`FadeInTime`,ik=`Link`;var ak=class e{static create(t,n){let r=Zw.create(t,n);if(!r)return null;let i=new e,a=r.getRoot();a.getValueByString(rk).isNull()||(i._fadeTimeSeconds=a.getValueByString(rk).toFloat(nk),i._fadeTimeSeconds<0&&(i._fadeTimeSeconds=nk));let o=a.getValueByString(`Groups`),s=o.getSize();for(let e=0;e<s;++e){let t=o.getValueByIndex(e),n=t.getSize(),r=0;for(let e=0;e<n;++e){let n=t.getValueByIndex(e),a=new ok;if(a.partId=pT.getIdManager().getId(n.getValueByString(`Id`).getRawString()),!n.getValueByString(ik).isNull()){let e=n.getValueByString(ik),t=e.getSize();for(let n=0;n<t;++n){let t=new ok;t.partId=pT.getIdManager().getId(e.getValueByIndex(n).getString()),a.link.pushBack(t)}}i._partGroups.pushBack(a.clone()),++r}i._partGroupCounts.pushBack(r)}return Zw.delete(r),i}static delete(e){}updateParameters(e,t){e!=this._lastModel&&this.reset(e),this._lastModel=e,t<0&&(t=0);let n=0;for(let r=0;r<this._partGroupCounts.getSize();r++){let i=this._partGroupCounts.at(r);this.doFade(e,t,n,i),n+=i}this.copyPartOpacities(e)}reset(e){let t=0;for(let n=0;n<this._partGroupCounts.getSize();++n){let r=this._partGroupCounts.at(n);for(let n=t;n<t+r;++n){this._partGroups.at(n).initialize(e);let r=this._partGroups.at(n).partIndex,i=this._partGroups.at(n).parameterIndex;if(!(r<0)){e.setPartOpacityByIndex(r,+(n==t)),e.setParameterValueByIndex(i,+(n==t));for(let t=0;t<this._partGroups.at(n).link.getSize();++t)this._partGroups.at(n).link.at(t).initialize(e)}}t+=r}}copyPartOpacities(e){for(let t=0;t<this._partGroups.getSize();++t){let n=this._partGroups.at(t);if(n.link.getSize()==0)continue;let r=this._partGroups.at(t).partIndex,i=e.getPartOpacityByIndex(r);for(let t=0;t<n.link.getSize();++t){let r=n.link.at(t).partIndex;r<0||e.setPartOpacityByIndex(r,i)}}}doFade(e,t,n,r){let i=-1,a=1,o=.5,s=.15;for(let o=n;o<n+r;++o){let n=this._partGroups.at(o).partIndex,r=this._partGroups.at(o).parameterIndex;if(e.getParameterValueByIndex(r)>.001){if(i>=0)break;if(i=o,this._fadeTimeSeconds==0){a=1;continue}a=e.getPartOpacityByIndex(n),a+=t/this._fadeTimeSeconds,a>1&&(a=1)}}i<0&&(i=0,a=1);for(let t=n;t<n+r;++t){let n=this._partGroups.at(t).partIndex;if(i==t)e.setPartOpacityByIndex(n,a);else{let t=e.getPartOpacityByIndex(n),r;r=a<o?a*(o-1)/o+1:(1-a)*o/(1-o),(1-r)*(1-a)>s&&(r=1-s/(1-a)),t>r&&(t=r),e.setPartOpacityByIndex(n,t)}}}constructor(){this._fadeTimeSeconds=nk,this._lastModel=null,this._partGroups=new J,this._partGroupCounts=new J}},ok=class e{constructor(e){if(this.parameterIndex=0,this.partIndex=0,this.link=new J,e!=null){this.partId=e.partId;for(let t=e.link.begin();t.notEqual(e.link.end());t.preIncrement())this.link.pushBack(t.ptr().clone())}}assignment(e){this.partId=e.partId;for(let t=e.link.begin();t.notEqual(e.link.end());t.preIncrement())this.link.pushBack(t.ptr().clone());return this}initialize(e){this.parameterIndex=e.getParameterIndex(this.partId),this.partIndex=e.getPartIndex(this.partId),e.setParameterValueByIndex(this.parameterIndex,1)}clone(){let t=new e;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new J;for(let e=this.link.begin();e.notEqual(this.link.end());e.increment())t.link.pushBack(e.ptr().clone());return t}},sk;(e=>{e.CubismPose=ak,e.PartData=ok})(sk||={});var ck=class{constructor(e=!1,t=!1){this.isOverridden=e,this.isParameterRepeated=t}},lk=class{constructor(e=!1,t=new jw){this.isOverridden=e,this.color=t}get isOverwritten(){return this.isOverridden}},uk=class{constructor(e=!1,t=new jw){this.isOverridden=e,this.color=t}get isOverwritten(){return this.isOverridden}},dk=class{constructor(e=!1,t=!1){this.isOverridden=e,this.isCulling=t}get isOverwritten(){return this.isOverridden}},fk=class{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return this._model==null?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){let e=this._model.parameters.count,t=this._savedParameters.getSize();for(let n=0;n<e;++n)n<t?this._savedParameters.set(n,this._parameterValues[n]):this._savedParameters.pushBack(this._parameterValues[n])}getMultiplyColor(e){return this.getOverrideFlagForModelMultiplyColors()||this.getOverrideFlagForDrawableMultiplyColors(e)?this._userMultiplyColors.at(e).color:this.getDrawableMultiplyColor(e)}getScreenColor(e){return this.getOverrideFlagForModelScreenColors()||this.getOverrideFlagForDrawableScreenColors(e)?this._userScreenColors.at(e).color:this.getDrawableScreenColor(e)}setMultiplyColorByTextureColor(e,t){this.setMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setMultiplyColorByRGBA(e,t,n,r,i=1){this._userMultiplyColors.at(e).color.r=t,this._userMultiplyColors.at(e).color.g=n,this._userMultiplyColors.at(e).color.b=r,this._userMultiplyColors.at(e).color.a=i}setScreenColorByTextureColor(e,t){this.setScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setScreenColorByRGBA(e,t,n,r,i=1){this._userScreenColors.at(e).color.r=t,this._userScreenColors.at(e).color.g=n,this._userScreenColors.at(e).color.b=r,this._userScreenColors.at(e).color.a=i}getPartMultiplyColor(e){return this._userPartMultiplyColors.at(e).color}getPartScreenColor(e){return this._userPartScreenColors.at(e).color}setPartColor(e,t,n,r,i,a,o){if(a.at(e).color.r=t,a.at(e).color.g=n,a.at(e).color.b=r,a.at(e).color.a=i,a.at(e).isOverridden)for(let a=0;a<this._partChildDrawables.at(e).getSize();++a){let s=this._partChildDrawables.at(e).at(a);o.at(s).color.r=t,o.at(s).color.g=n,o.at(s).color.b=r,o.at(s).color.a=i}}setPartMultiplyColorByTextureColor(e,t){this.setPartMultiplyColorByRGBA(e,t.r,t.g,t.b,t.a)}setPartMultiplyColorByRGBA(e,t,n,r,i){this.setPartColor(e,t,n,r,i,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(e,t){this.setPartScreenColorByRGBA(e,t.r,t.g,t.b,t.a)}setPartScreenColorByRGBA(e,t,n,r,i){this.setPartColor(e,t,n,r,i,this._userPartScreenColors,this._userScreenColors)}getOverrideFlagForModelParameterRepeat(){return this._isOverriddenParameterRepeat}setOverrideFlagForModelParameterRepeat(e){this._isOverriddenParameterRepeat=e}getOverrideFlagForParameterRepeat(e){return this._userParameterRepeatDataList.at(e).isOverridden}setOverrideFlagForParameterRepeat(e,t){this._userParameterRepeatDataList.at(e).isOverridden=t}getRepeatFlagForParameterRepeat(e){return this._userParameterRepeatDataList.at(e).isParameterRepeated}setRepeatFlagForParameterRepeat(e,t){this._userParameterRepeatDataList.at(e).isParameterRepeated=t}getOverwriteFlagForModelMultiplyColors(){return Y(`getOverwriteFlagForModelMultiplyColors() is a deprecated function. Please use getOverrideFlagForModelMultiplyColors().`),this.getOverrideFlagForModelMultiplyColors()}getOverrideFlagForModelMultiplyColors(){return this._isOverriddenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return Y(`getOverwriteFlagForModelScreenColors() is a deprecated function. Please use getOverrideFlagForModelScreenColors().`),this.getOverrideFlagForModelScreenColors()}getOverrideFlagForModelScreenColors(){return this._isOverriddenModelScreenColors}setOverwriteFlagForModelMultiplyColors(e){Y(`setOverwriteFlagForModelMultiplyColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelMultiplyColors(value: boolean).`),this.setOverrideFlagForModelMultiplyColors(e)}setOverrideFlagForModelMultiplyColors(e){this._isOverriddenModelMultiplyColors=e}setOverwriteFlagForModelScreenColors(e){Y(`setOverwriteFlagForModelScreenColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelScreenColors(value: boolean).`),this.setOverrideFlagForModelScreenColors(e)}setOverrideFlagForModelScreenColors(e){this._isOverriddenModelScreenColors=e}getOverwriteFlagForDrawableMultiplyColors(e){return Y(`getOverwriteFlagForDrawableMultiplyColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableMultiplyColors(drawableindex: number).`),this.getOverrideFlagForDrawableMultiplyColors(e)}getOverrideFlagForDrawableMultiplyColors(e){return this._userMultiplyColors.at(e).isOverridden}getOverwriteFlagForDrawableScreenColors(e){return Y(`getOverwriteFlagForDrawableScreenColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableScreenColors(drawableindex: number).`),this.getOverrideFlagForDrawableScreenColors(e)}getOverrideFlagForDrawableScreenColors(e){return this._userScreenColors.at(e).isOverridden}setOverwriteFlagForDrawableMultiplyColors(e,t){Y(`setOverwriteFlagForDrawableMultiplyColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableMultiplyColors(drawableindex: number, value: boolean).`),this.setOverrideFlagForDrawableMultiplyColors(e,t)}setOverrideFlagForDrawableMultiplyColors(e,t){this._userMultiplyColors.at(e).isOverridden=t}setOverwriteFlagForDrawableScreenColors(e,t){Y(`setOverwriteFlagForDrawableScreenColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableScreenColors(drawableindex: number, value: boolean).`),this.setOverrideFlagForDrawableScreenColors(e,t)}setOverrideFlagForDrawableScreenColors(e,t){this._userScreenColors.at(e).isOverridden=t}getOverwriteColorForPartMultiplyColors(e){return Y(`getOverwriteColorForPartMultiplyColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartMultiplyColors(partIndex: number).`),this.getOverrideColorForPartMultiplyColors(e)}getOverrideColorForPartMultiplyColors(e){return this._userPartMultiplyColors.at(e).isOverridden}getOverwriteColorForPartScreenColors(e){return Y(`getOverwriteColorForPartScreenColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartScreenColors(partIndex: number).`),this.getOverrideColorForPartScreenColors(e)}getOverrideColorForPartScreenColors(e){return this._userPartScreenColors.at(e).isOverridden}setOverwriteColorForPartColors(e,t,n,r){Y(`setOverwriteColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>) is a deprecated function. Please use setOverrideColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>).`),this.setOverrideColorForPartColors(e,t,n,r)}setOverrideColorForPartColors(e,t,n,r){n.at(e).isOverridden=t;for(let i=0;i<this._partChildDrawables.at(e).getSize();++i){let a=this._partChildDrawables.at(e).at(i);r.at(a).isOverridden=t,t&&(r.at(a).color.r=n.at(e).color.r,r.at(a).color.g=n.at(e).color.g,r.at(a).color.b=n.at(e).color.b,r.at(a).color.a=n.at(e).color.a)}}setOverwriteColorForPartMultiplyColors(e,t){Y(`setOverwriteColorForPartMultiplyColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartMultiplyColors(partIndex: number, value: boolean).`),this.setOverrideColorForPartMultiplyColors(e,t)}setOverrideColorForPartMultiplyColors(e,t){this._userPartMultiplyColors.at(e).isOverridden=t,this.setOverrideColorForPartColors(e,t,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(e,t){Y(`setOverwriteColorForPartScreenColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartScreenColors(partIndex: number, value: boolean).`),this.setOverrideColorForPartScreenColors(e,t)}setOverrideColorForPartScreenColors(e,t){this._userPartScreenColors.at(e).isOverridden=t,this.setOverrideColorForPartColors(e,t,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(e){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForDrawableCullings(e))return this._userCullings.at(e).isCulling;let t=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(t[e])}setDrawableCulling(e,t){this._userCullings.at(e).isCulling=t}getOverwriteFlagForModelCullings(){return Y(`getOverwriteFlagForModelCullings() is a deprecated function. Please use getOverrideFlagForModelCullings().`),this.getOverrideFlagForModelCullings()}getOverrideFlagForModelCullings(){return this._isOverriddenCullings}setOverwriteFlagForModelCullings(e){Y(`setOverwriteFlagForModelCullings(isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForModelCullings(isOverriddenCullings: boolean).`),this.setOverrideFlagForModelCullings(e)}setOverrideFlagForModelCullings(e){this._isOverriddenCullings=e}getOverwriteFlagForDrawableCullings(e){return Y(`getOverwriteFlagForDrawableCullings(drawableIndex: number) is a deprecated function. Please use getOverrideFlagForDrawableCullings(drawableIndex: number).`),this.getOverrideFlagForDrawableCullings(e)}getOverrideFlagForDrawableCullings(e){return this._userCullings.at(e).isOverridden}setOverwriteFlagForDrawableCullings(e,t){Y(`setOverwriteFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean).`),this.setOverrideFlagForDrawableCullings(e,t)}setOverrideFlagForDrawableCullings(e,t){this._userCullings.at(e).isOverridden=t}getModelOapcity(){return this._modelOpacity}setModelOapcity(e){this._modelOpacity=e}getModel(){return this._model}getPartIndex(e){let t,n=this._model.parts.count;for(t=0;t<n;++t)if(e==this._partIds.at(t))return t;return this._notExistPartId.isExist(e)?this._notExistPartId.getValue(e):(t=n+this._notExistPartId.getSize(),this._notExistPartId.setValue(e,t),this._notExistPartOpacities.appendKey(t),t)}getPartId(e){let t=this._model.parts.ids[e];return pT.getIdManager().getId(t)}getPartCount(){return this._model.parts.count}getPartParentPartIndices(){return this._model.parts.parentIndices}setPartOpacityByIndex(e,t){if(this._notExistPartOpacities.isExist(e)){this._notExistPartOpacities.setValue(e,t);return}Lw(0<=e&&e<this.getPartCount()),this._partOpacities[e]=t}setPartOpacityById(e,t){let n=this.getPartIndex(e);n<0||this.setPartOpacityByIndex(n,t)}getPartOpacityByIndex(e){return this._notExistPartOpacities.isExist(e)?this._notExistPartOpacities.getValue(e):(Lw(0<=e&&e<this.getPartCount()),this._partOpacities[e])}getPartOpacityById(e){let t=this.getPartIndex(e);return t<0?0:this.getPartOpacityByIndex(t)}getParameterIndex(e){let t,n=this._model.parameters.count;for(t=0;t<n;++t)if(e==this._parameterIds.at(t))return t;return this._notExistParameterId.isExist(e)?this._notExistParameterId.getValue(e):(t=this._model.parameters.count+this._notExistParameterId.getSize(),this._notExistParameterId.setValue(e,t),this._notExistParameterValues.appendKey(t),t)}getParameterCount(){return this._model.parameters.count}getParameterType(e){return this._model.parameters.types[e]}getParameterMaximumValue(e){return this._model.parameters.maximumValues[e]}getParameterMinimumValue(e){return this._model.parameters.minimumValues[e]}getParameterDefaultValue(e){return this._model.parameters.defaultValues[e]}getParameterId(e){return pT.getIdManager().getId(this._model.parameters.ids[e])}getParameterValueByIndex(e){return this._notExistParameterValues.isExist(e)?this._notExistParameterValues.getValue(e):(Lw(0<=e&&e<this.getParameterCount()),this._parameterValues[e])}getParameterValueById(e){let t=this.getParameterIndex(e);return this.getParameterValueByIndex(t)}setParameterValueByIndex(e,t,n=1){if(this._notExistParameterValues.isExist(e)){this._notExistParameterValues.setValue(e,n==1?t:this._notExistParameterValues.getValue(e)*(1-n)+t*n);return}Lw(0<=e&&e<this.getParameterCount()),t=this.isRepeat(e)?this.getParameterRepeatValue(e,t):this.getParameterClampValue(e,t),this._parameterValues[e]=n==1?t:this._parameterValues[e]=this._parameterValues[e]*(1-n)+t*n}setParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.setParameterValueByIndex(r,t,n)}addParameterValueByIndex(e,t,n=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)+t*n)}addParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.addParameterValueByIndex(r,t,n)}isRepeat(e){if(this._notExistParameterValues.isExist(e))return!1;Lw(0<=e&&e<this.getParameterCount());let t;return t=this._isOverriddenParameterRepeat||this._userParameterRepeatDataList.at(e).isOverridden?this._userParameterRepeatDataList.at(e).isParameterRepeated:this._model.parameters.repeats[e]!=0,t}getParameterRepeatValue(e,t){if(this._notExistParameterValues.isExist(e))return t;Lw(0<=e&&e<this.getParameterCount());let n=this._model.parameters.maximumValues[e],r=this._model.parameters.minimumValues[e],i=n-r;if(n<t){let e=Q.mod(t-n,i);t=Number.isNaN(e)?n:r+e}if(t<r){let e=Q.mod(r-t,i);t=Number.isNaN(e)?r:n-e}return t}getParameterClampValue(e,t){if(this._notExistParameterValues.isExist(e))return t;Lw(0<=e&&e<this.getParameterCount());let n=this._model.parameters.maximumValues[e],r=this._model.parameters.minimumValues[e];return Q.clamp(t,r,n)}getParameterRepeats(e){return this._model.parameters.repeats[e]!=0}multiplyParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.multiplyParameterValueByIndex(r,t,n)}multiplyParameterValueByIndex(e,t,n=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)*(1+(t-1)*n))}getDrawableIndex(e){let t=this._model.drawables.count;for(let n=0;n<t;++n)if(this._drawableIds.at(n)==e)return n;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(e){let t=this._model.drawables.ids;return pT.getIdManager().getId(t[e])}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(e){return this.getDrawableTextureIndex(e)}getDrawableTextureIndex(e){return this._model.drawables.textureIndices[e]}getDrawableDynamicFlagVertexPositionsDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(t[e])}getDrawableVertexIndexCount(e){return this._model.drawables.indexCounts[e]}getDrawableVertexCount(e){return this._model.drawables.vertexCounts[e]}getDrawableVertices(e){return this.getDrawableVertexPositions(e)}getDrawableVertexIndices(e){return this._model.drawables.indices[e]}getDrawableVertexPositions(e){return this._model.drawables.vertexPositions[e]}getDrawableVertexUvs(e){return this._model.drawables.vertexUvs[e]}getDrawableOpacity(e){return this._model.drawables.opacities[e]}getDrawableMultiplyColor(e){let t=this._model.drawables.multiplyColors,n=e*4,r=new jw;return r.r=t[n],r.g=t[n+1],r.b=t[n+2],r.a=t[n+3],r}getDrawableScreenColor(e){let t=this._model.drawables.screenColors,n=e*4,r=new jw;return r.r=t[n],r.g=t[n+1],r.b=t[n+2],r.a=t[n+3],r}getDrawableParentPartIndex(e){return this._model.drawables.parentPartIndices[e]}getDrawableBlendMode(e){let t=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(t[e])?Aw.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(t[e])?Aw.CubismBlendMode_Multiplicative:Aw.CubismBlendMode_Normal}getDrawableInvertedMaskBit(e){let t=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(t[e])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let e=0;e<this._model.drawables.count;++e)if(!(this._model.drawables.maskCounts[e]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(t[e])}getDrawableDynamicFlagVisibilityDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(t[e])}getDrawableDynamicFlagOpacityDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(t[e])}getDrawableDynamicFlagRenderOrderDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(t[e])}getDrawableDynamicFlagBlendColorDidChange(e){let t=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(t[e])}loadParameters(){let e=this._model.parameters.count,t=this._savedParameters.getSize();e>t&&(e=t);for(let t=0;t<e;++t)this._parameterValues[t]=this._savedParameters.at(t)}initialize(){Lw(this._model),this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{let e=this._model.parameters.ids,t=this._model.parameters.count;this._parameterIds.prepareCapacity(t),this._userParameterRepeatDataList.prepareCapacity(t);for(let n=0;n<t;++n)this._parameterIds.pushBack(pT.getIdManager().getId(e[n])),this._userParameterRepeatDataList.pushBack(new ck(!1,!1))}let e=this._model.parts.count;{let t=this._model.parts.ids;this._partIds.prepareCapacity(e);for(let n=0;n<e;++n)this._partIds.pushBack(pT.getIdManager().getId(t[n]));this._userPartMultiplyColors.prepareCapacity(e),this._userPartScreenColors.prepareCapacity(e),this._partChildDrawables.prepareCapacity(e)}{let t=this._model.drawables.ids,n=this._model.drawables.count;this._userMultiplyColors.prepareCapacity(n),this._userScreenColors.prepareCapacity(n),this._userCullings.prepareCapacity(n);let r=new dk(!1,!1);for(let t=0;t<e;++t){let e=new jw(1,1,1,1),r=new jw(0,0,0,1),i=new uk(!1,e),a=new uk(!1,r);this._userPartMultiplyColors.pushBack(i),this._userPartScreenColors.pushBack(a),this._partChildDrawables.pushBack(new J),this._partChildDrawables.at(t).prepareCapacity(n)}for(let e=0;e<n;++e){let n=new jw(1,1,1,1),i=new jw(0,0,0,1),a=new lk(!1,n),o=new lk(!1,i);this._drawableIds.pushBack(pT.getIdManager().getId(t[e])),this._userMultiplyColors.pushBack(a),this._userScreenColors.pushBack(o),this._userCullings.pushBack(r);let s=this.getDrawableParentPartIndex(e);s>=0&&this._partChildDrawables.at(s).pushBack(e)}}}constructor(e){this._model=e,this._parameterValues=null,this._parameterMaximumValues=null,this._parameterMinimumValues=null,this._partOpacities=null,this._savedParameters=new J,this._parameterIds=new J,this._drawableIds=new J,this._partIds=new J,this._isOverriddenParameterRepeat=!0,this._isOverriddenModelMultiplyColors=!1,this._isOverriddenModelScreenColors=!1,this._isOverriddenCullings=!1,this._modelOpacity=1,this._userParameterRepeatDataList=new J,this._userMultiplyColors=new J,this._userScreenColors=new J,this._userCullings=new J,this._userPartMultiplyColors=new J,this._userPartScreenColors=new J,this._partChildDrawables=new J,this._notExistPartId=new Gw,this._notExistParameterId=new Gw,this._notExistParameterValues=new Gw,this._notExistPartOpacities=new Gw}release(){this._model.release(),this._model=null}},pk;(e=>{e.CubismModel=fk})(pk||={});var mk=class e{static create(t,n){let r=null;if(n&&!this.hasMocConsistency(t))return Bw(`Inconsistent MOC3.`),r;let i=Live2DCubismCore.Moc.fromArrayBuffer(t);return i&&(r=new e(i),r._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(i,t)),r}static delete(e){e._moc._release(),e._moc=null,e=null}createModel(){let e=null,t=Live2DCubismCore.Model.fromMoc(this._moc);return t&&(e=new fk(t),e.initialize(),++this._modelCount),e}deleteModel(e){e!=null&&(e.release(),e=null,--this._modelCount)}constructor(e){this._moc=e,this._modelCount=0,this._mocVersion=0}release(){Lw(this._modelCount==0),this._moc._release(),this._moc=null}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(e){return Live2DCubismCore.Moc.prototype.hasMocConsistency(e)===1}},hk;(e=>{e.CubismMoc=mk})(hk||={});var gk=(e=>(e[e.CubismPhysicsTargetType_Parameter=0]=`CubismPhysicsTargetType_Parameter`,e))(gk||{}),_k=(e=>(e[e.CubismPhysicsSource_X=0]=`CubismPhysicsSource_X`,e[e.CubismPhysicsSource_Y=1]=`CubismPhysicsSource_Y`,e[e.CubismPhysicsSource_Angle=2]=`CubismPhysicsSource_Angle`,e))(_k||{}),vk=class{constructor(){this.gravity=new Z(0,0),this.wind=new Z(0,0)}},yk=class{},bk=class{},xk=class{constructor(){this.initialPosition=new Z(0,0),this.position=new Z(0,0),this.lastPosition=new Z(0,0),this.lastGravity=new Z(0,0),this.force=new Z(0,0),this.velocity=new Z(0,0)}},Sk=class{constructor(){this.normalizationPosition=new bk,this.normalizationAngle=new bk}},Ck=class{constructor(){this.source=new yk}},wk=class{constructor(){this.destination=new yk,this.translationScale=new Z(0,0)}},Tk=class{constructor(){this.settings=new J,this.inputs=new J,this.outputs=new J,this.particles=new J,this.gravity=new Z(0,0),this.wind=new Z(0,0),this.fps=0}},Ek;(e=>{e.CubismPhysicsInput=Ck,e.CubismPhysicsNormalization=bk,e.CubismPhysicsOutput=wk,e.CubismPhysicsParameter=yk,e.CubismPhysicsParticle=xk,e.CubismPhysicsRig=Tk,e.CubismPhysicsSource=_k,e.CubismPhysicsSubRig=Sk,e.CubismPhysicsTargetType=gk,e.PhysicsJsonEffectiveForces=vk})(Ek||={});let Dk=`Position`,Ok=`Angle`,kk=`Type`,Ak=`Meta`,jk=`EffectiveForces`,Mk=`Gravity`,Nk=`Wind`,Pk=`PhysicsSettings`,Fk=`Normalization`,Ik=`Minimum`,Lk=`Maximum`,Rk=`Default`,zk=`Reflect`,Bk=`Weight`,Vk=`Input`,Hk=`Output`,Uk=`Vertices`;var Wk=class{constructor(e,t){this._json=Zw.create(e,t)}release(){Zw.delete(this._json)}getGravity(){let e=new Z(0,0);return e.x=this._json.getRoot().getValueByString(Ak).getValueByString(jk).getValueByString(Mk).getValueByString(`X`).toFloat(),e.y=this._json.getRoot().getValueByString(Ak).getValueByString(jk).getValueByString(Mk).getValueByString(`Y`).toFloat(),e}getWind(){let e=new Z(0,0);return e.x=this._json.getRoot().getValueByString(Ak).getValueByString(jk).getValueByString(Nk).getValueByString(`X`).toFloat(),e.y=this._json.getRoot().getValueByString(Ak).getValueByString(jk).getValueByString(Nk).getValueByString(`Y`).toFloat(),e}getFps(){return this._json.getRoot().getValueByString(Ak).getValueByString(`Fps`).toFloat(0)}getSubRigCount(){return this._json.getRoot().getValueByString(Ak).getValueByString(`PhysicsSettingCount`).toInt()}getTotalInputCount(){return this._json.getRoot().getValueByString(Ak).getValueByString(`TotalInputCount`).toInt()}getTotalOutputCount(){return this._json.getRoot().getValueByString(Ak).getValueByString(`TotalOutputCount`).toInt()}getVertexCount(){return this._json.getRoot().getValueByString(Ak).getValueByString(`VertexCount`).toInt()}getNormalizationPositionMinimumValue(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Fk).getValueByString(Dk).getValueByString(Ik).toFloat()}getNormalizationPositionMaximumValue(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Fk).getValueByString(Dk).getValueByString(Lk).toFloat()}getNormalizationPositionDefaultValue(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Fk).getValueByString(Dk).getValueByString(Rk).toFloat()}getNormalizationAngleMinimumValue(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Fk).getValueByString(Ok).getValueByString(Ik).toFloat()}getNormalizationAngleMaximumValue(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Fk).getValueByString(Ok).getValueByString(Lk).toFloat()}getNormalizationAngleDefaultValue(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Fk).getValueByString(Ok).getValueByString(Rk).toFloat()}getInputCount(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Vk).getVector().getSize()}getInputWeight(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Vk).getValueByIndex(t).getValueByString(Bk).toFloat()}getInputReflect(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Vk).getValueByIndex(t).getValueByString(zk).toBoolean()}getInputType(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Vk).getValueByIndex(t).getValueByString(kk).getRawString()}getInputSourceId(e,t){return pT.getIdManager().getId(this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Vk).getValueByIndex(t).getValueByString(`Source`).getValueByString(`Id`).getRawString())}getOutputCount(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Hk).getVector().getSize()}getOutputVertexIndex(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Hk).getValueByIndex(t).getValueByString(`VertexIndex`).toInt()}getOutputAngleScale(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Hk).getValueByIndex(t).getValueByString(`Scale`).toFloat()}getOutputWeight(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Hk).getValueByIndex(t).getValueByString(Bk).toFloat()}getOutputDestinationId(e,t){return pT.getIdManager().getId(this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Hk).getValueByIndex(t).getValueByString(`Destination`).getValueByString(`Id`).getRawString())}getOutputType(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Hk).getValueByIndex(t).getValueByString(kk).getRawString()}getOutputReflect(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Hk).getValueByIndex(t).getValueByString(zk).toBoolean()}getParticleCount(e){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Uk).getVector().getSize()}getParticleMobility(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Uk).getValueByIndex(t).getValueByString(`Mobility`).toFloat()}getParticleDelay(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Uk).getValueByIndex(t).getValueByString(`Delay`).toFloat()}getParticleAcceleration(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Uk).getValueByIndex(t).getValueByString(`Acceleration`).toFloat()}getParticleRadius(e,t){return this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Uk).getValueByIndex(t).getValueByString(`Radius`).toFloat()}getParticlePosition(e,t){let n=new Z(0,0);return n.x=this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Uk).getValueByIndex(t).getValueByString(Dk).getValueByString(`X`).toFloat(),n.y=this._json.getRoot().getValueByString(Pk).getValueByIndex(e).getValueByString(Uk).getValueByIndex(t).getValueByString(Dk).getValueByString(`Y`).toFloat(),n}},Gk;(e=>{e.CubismPhysicsJson=Wk})(Gk||={});let Kk=`Angle`,qk=.001;var Jk=class e{static create(t,n){let r=new e;return r.parse(t,n),r._physicsRig.gravity.y=0,r}static delete(e){e!=null&&(e.release(),e=null)}parse(e,t){this._physicsRig=new Tk;let n=new Wk(e,t);this._physicsRig.gravity=n.getGravity(),this._physicsRig.wind=n.getWind(),this._physicsRig.subRigCount=n.getSubRigCount(),this._physicsRig.fps=n.getFps(),this._physicsRig.settings.updateSize(this._physicsRig.subRigCount,Sk,!0),this._physicsRig.inputs.updateSize(n.getTotalInputCount(),Ck,!0),this._physicsRig.outputs.updateSize(n.getTotalOutputCount(),wk,!0),this._physicsRig.particles.updateSize(n.getVertexCount(),xk,!0),this._currentRigOutputs.clear(),this._previousRigOutputs.clear();let r=0,i=0,a=0;for(let e=0;e<this._physicsRig.settings.getSize();++e){this._physicsRig.settings.at(e).normalizationPosition.minimum=n.getNormalizationPositionMinimumValue(e),this._physicsRig.settings.at(e).normalizationPosition.maximum=n.getNormalizationPositionMaximumValue(e),this._physicsRig.settings.at(e).normalizationPosition.defalut=n.getNormalizationPositionDefaultValue(e),this._physicsRig.settings.at(e).normalizationAngle.minimum=n.getNormalizationAngleMinimumValue(e),this._physicsRig.settings.at(e).normalizationAngle.maximum=n.getNormalizationAngleMaximumValue(e),this._physicsRig.settings.at(e).normalizationAngle.defalut=n.getNormalizationAngleDefaultValue(e),this._physicsRig.settings.at(e).inputCount=n.getInputCount(e),this._physicsRig.settings.at(e).baseInputIndex=r;for(let t=0;t<this._physicsRig.settings.at(e).inputCount;++t)this._physicsRig.inputs.at(r+t).sourceParameterIndex=-1,this._physicsRig.inputs.at(r+t).weight=n.getInputWeight(e,t),this._physicsRig.inputs.at(r+t).reflect=n.getInputReflect(e,t),n.getInputType(e,t)==`X`?(this._physicsRig.inputs.at(r+t).type=_k.CubismPhysicsSource_X,this._physicsRig.inputs.at(r+t).getNormalizedParameterValue=Qk):n.getInputType(e,t)==`Y`?(this._physicsRig.inputs.at(r+t).type=_k.CubismPhysicsSource_Y,this._physicsRig.inputs.at(r+t).getNormalizedParameterValue=$k):n.getInputType(e,t)==Kk&&(this._physicsRig.inputs.at(r+t).type=_k.CubismPhysicsSource_Angle,this._physicsRig.inputs.at(r+t).getNormalizedParameterValue=eA),this._physicsRig.inputs.at(r+t).source.targetType=gk.CubismPhysicsTargetType_Parameter,this._physicsRig.inputs.at(r+t).source.id=n.getInputSourceId(e,t);r+=this._physicsRig.settings.at(e).inputCount,this._physicsRig.settings.at(e).outputCount=n.getOutputCount(e),this._physicsRig.settings.at(e).baseOutputIndex=i;let t=new Xk;t.outputs.resize(this._physicsRig.settings.at(e).outputCount);let o=new Xk;o.outputs.resize(this._physicsRig.settings.at(e).outputCount);for(let r=0;r<this._physicsRig.settings.at(e).outputCount;++r)t.outputs.set(r,0),o.outputs.set(r,0),this._physicsRig.outputs.at(i+r).destinationParameterIndex=-1,this._physicsRig.outputs.at(i+r).vertexIndex=n.getOutputVertexIndex(e,r),this._physicsRig.outputs.at(i+r).angleScale=n.getOutputAngleScale(e,r),this._physicsRig.outputs.at(i+r).weight=n.getOutputWeight(e,r),this._physicsRig.outputs.at(i+r).destination.targetType=gk.CubismPhysicsTargetType_Parameter,this._physicsRig.outputs.at(i+r).destination.id=n.getOutputDestinationId(e,r),n.getOutputType(e,r)==`X`?(this._physicsRig.outputs.at(i+r).type=_k.CubismPhysicsSource_X,this._physicsRig.outputs.at(i+r).getValue=tA,this._physicsRig.outputs.at(i+r).getScale=oA):n.getOutputType(e,r)==`Y`?(this._physicsRig.outputs.at(i+r).type=_k.CubismPhysicsSource_Y,this._physicsRig.outputs.at(i+r).getValue=nA,this._physicsRig.outputs.at(i+r).getScale=sA):n.getOutputType(e,r)==Kk&&(this._physicsRig.outputs.at(i+r).type=_k.CubismPhysicsSource_Angle,this._physicsRig.outputs.at(i+r).getValue=rA,this._physicsRig.outputs.at(i+r).getScale=cA),this._physicsRig.outputs.at(i+r).reflect=n.getOutputReflect(e,r);this._currentRigOutputs.pushBack(t),this._previousRigOutputs.pushBack(o),i+=this._physicsRig.settings.at(e).outputCount,this._physicsRig.settings.at(e).particleCount=n.getParticleCount(e),this._physicsRig.settings.at(e).baseParticleIndex=a;for(let t=0;t<this._physicsRig.settings.at(e).particleCount;++t)this._physicsRig.particles.at(a+t).mobility=n.getParticleMobility(e,t),this._physicsRig.particles.at(a+t).delay=n.getParticleDelay(e,t),this._physicsRig.particles.at(a+t).acceleration=n.getParticleAcceleration(e,t),this._physicsRig.particles.at(a+t).radius=n.getParticleRadius(e,t),this._physicsRig.particles.at(a+t).position=n.getParticlePosition(e,t);a+=this._physicsRig.settings.at(e).particleCount}this.initialize(),n.release(),n=void 0,n=null}stabilization(e){let t,n,r,i,a=new Z,o,s,c,l,u=e.getModel().parameters.values,d=e.getModel().parameters.maximumValues,f=e.getModel().parameters.minimumValues,p=e.getModel().parameters.defaultValues;(this._parameterCaches?.length??0)<e.getParameterCount()&&(this._parameterCaches=new Float32Array(e.getParameterCount())),(this._parameterInputCaches?.length??0)<e.getParameterCount()&&(this._parameterInputCaches=new Float32Array(e.getParameterCount()));for(let t=0;t<e.getParameterCount();++t)this._parameterCaches[t]=u[t],this._parameterInputCaches[t]=u[t];for(let m=0;m<this._physicsRig.subRigCount;++m){t={angle:0},a.x=0,a.y=0,o=this._physicsRig.settings.at(m),s=this._physicsRig.inputs.get(o.baseInputIndex),c=this._physicsRig.outputs.get(o.baseOutputIndex),l=this._physicsRig.particles.get(o.baseParticleIndex);for(let r=0;r<o.inputCount;++r)n=s[r].weight/100,s[r].sourceParameterIndex==-1&&(s[r].sourceParameterIndex=e.getParameterIndex(s[r].source.id)),s[r].getNormalizedParameterValue(a,t,u[s[r].sourceParameterIndex],f[s[r].sourceParameterIndex],d[s[r].sourceParameterIndex],p[s[r].sourceParameterIndex],o.normalizationPosition,o.normalizationAngle,s[r].reflect,n),this._parameterCaches[s[r].sourceParameterIndex]=u[s[r].sourceParameterIndex];r=Q.degreesToRadian(-t.angle),a.x=a.x*Q.cos(r)-a.y*Q.sin(r),a.y=a.x*Q.sin(r)+a.y*Q.cos(r),uA(l,o.particleCount,a,t.angle,this._options.wind,qk*o.normalizationPosition.maximum);for(let t=0;t<o.outputCount;++t){let n=c[t].vertexIndex;if(c[t].destinationParameterIndex==-1&&(c[t].destinationParameterIndex=e.getParameterIndex(c[t].destination.id)),n<1||n>=o.particleCount)continue;let r=new Z;r=l[n].position.substract(l[n-1].position),i=c[t].getValue(r,l,n,c[t].reflect,this._options.gravity),this._currentRigOutputs.at(m).outputs.set(t,i),this._previousRigOutputs.at(m).outputs.set(t,i);let a=c[t].destinationParameterIndex,s=!Float32Array.prototype.slice&&`subarray`in Float32Array.prototype?JSON.parse(JSON.stringify(u.subarray(a))):u.slice(a);dA(s,f[a],d[a],i,c[t]);for(let e=a,t=0;e<this._parameterCaches.length;e++,t++)u[e]=this._parameterCaches[e]=s[t]}}}evaluate(e,t){let n,r,i,a,o=new Z,s,c,l,u;if(0>=t)return;let d=e.getModel().parameters.values,f=e.getModel().parameters.maximumValues,p=e.getModel().parameters.minimumValues,m=e.getModel().parameters.defaultValues,h;if(this._currentRemainTime+=t,this._currentRemainTime>5&&(this._currentRemainTime=0),(this._parameterCaches?.length??0)<e.getParameterCount()&&(this._parameterCaches=new Float32Array(e.getParameterCount())),(this._parameterInputCaches?.length??0)<e.getParameterCount()){this._parameterInputCaches=new Float32Array(e.getParameterCount());for(let t=0;t<e.getParameterCount();++t)this._parameterInputCaches[t]=d[t]}for(h=this._physicsRig.fps>0?1/this._physicsRig.fps:t;this._currentRemainTime>=h;){for(let e=0;e<this._physicsRig.subRigCount;++e){s=this._physicsRig.settings.at(e),l=this._physicsRig.outputs.get(s.baseOutputIndex);for(let t=0;t<s.outputCount;++t)this._previousRigOutputs.at(e).outputs.set(t,this._currentRigOutputs.at(e).outputs.at(t))}let t=h/this._currentRemainTime;for(let n=0;n<e.getParameterCount();++n)this._parameterCaches[n]=this._parameterInputCaches[n]*(1-t)+d[n]*t,this._parameterInputCaches[n]=this._parameterCaches[n];for(let t=0;t<this._physicsRig.subRigCount;++t){n={angle:0},o.x=0,o.y=0,s=this._physicsRig.settings.at(t),c=this._physicsRig.inputs.get(s.baseInputIndex),l=this._physicsRig.outputs.get(s.baseOutputIndex),u=this._physicsRig.particles.get(s.baseParticleIndex);for(let t=0;t<s.inputCount;++t)r=c[t].weight/100,c[t].sourceParameterIndex==-1&&(c[t].sourceParameterIndex=e.getParameterIndex(c[t].source.id)),c[t].getNormalizedParameterValue(o,n,this._parameterCaches[c[t].sourceParameterIndex],p[c[t].sourceParameterIndex],f[c[t].sourceParameterIndex],m[c[t].sourceParameterIndex],s.normalizationPosition,s.normalizationAngle,c[t].reflect,r);i=Q.degreesToRadian(-n.angle),o.x=o.x*Q.cos(i)-o.y*Q.sin(i),o.y=o.x*Q.sin(i)+o.y*Q.cos(i),lA(u,s.particleCount,o,n.angle,this._options.wind,qk*s.normalizationPosition.maximum,h,5);for(let n=0;n<s.outputCount;++n){let r=l[n].vertexIndex;if(l[n].destinationParameterIndex==-1&&(l[n].destinationParameterIndex=e.getParameterIndex(l[n].destination.id)),r<1||r>=s.particleCount)continue;let i=new Z;i.x=u[r].position.x-u[r-1].position.x,i.y=u[r].position.y-u[r-1].position.y,a=l[n].getValue(i,u,r,l[n].reflect,this._options.gravity),this._currentRigOutputs.at(t).outputs.set(n,a);let o=l[n].destinationParameterIndex,c=!Float32Array.prototype.slice&&`subarray`in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(o))):this._parameterCaches.slice(o);dA(c,p[o],f[o],a,l[n]);for(let e=o,t=0;e<this._parameterCaches.length;e++,t++)this._parameterCaches[e]=c[t]}}this._currentRemainTime-=h}let g=this._currentRemainTime/h;this.interpolate(e,g)}interpolate(e,t){let n,r,i=e.getModel().parameters.values,a=e.getModel().parameters.maximumValues,o=e.getModel().parameters.minimumValues;for(let e=0;e<this._physicsRig.subRigCount;++e){r=this._physicsRig.settings.at(e),n=this._physicsRig.outputs.get(r.baseOutputIndex);for(let s=0;s<r.outputCount;++s){if(n[s].destinationParameterIndex==-1)continue;let r=n[s].destinationParameterIndex,c=!Float32Array.prototype.slice&&`subarray`in Float32Array.prototype?JSON.parse(JSON.stringify(i.subarray(r))):i.slice(r);dA(c,o[r],a[r],this._previousRigOutputs.at(e).outputs.at(s)*(1-t)+this._currentRigOutputs.at(e).outputs.at(s)*t,n[s]);for(let e=r,t=0;e<i.length;e++,t++)i[e]=c[t]}}}setOptions(e){this._options=e}getOption(){return this._options}constructor(){this._physicsRig=null,this._options=new Yk,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=new J,this._previousRigOutputs=new J,this._currentRemainTime=0,this._parameterCaches=null,this._parameterInputCaches=null}release(){this._physicsRig=void 0,this._physicsRig=null}initialize(){let e,t,n;for(let r=0;r<this._physicsRig.subRigCount;++r){t=this._physicsRig.settings.at(r),e=this._physicsRig.particles.get(t.baseParticleIndex),e[0].initialPosition=new Z(0,0),e[0].lastPosition=new Z(e[0].initialPosition.x,e[0].initialPosition.y),e[0].lastGravity=new Z(0,-1),e[0].lastGravity.y*=-1,e[0].velocity=new Z(0,0),e[0].force=new Z(0,0);for(let r=1;r<t.particleCount;++r)n=new Z(0,0),n.y=e[r].radius,e[r].initialPosition=new Z(e[r-1].initialPosition.x+n.x,e[r-1].initialPosition.y+n.y),e[r].position=new Z(e[r].initialPosition.x,e[r].initialPosition.y),e[r].lastPosition=new Z(e[r].initialPosition.x,e[r].initialPosition.y),e[r].lastGravity=new Z(0,-1),e[r].lastGravity.y*=-1,e[r].velocity=new Z(0,0),e[r].force=new Z(0,0)}}},Yk=class{constructor(){this.gravity=new Z(0,0),this.wind=new Z(0,0)}},Xk=class{constructor(){this.outputs=new J(0)}};function Zk(e){let t=0;return e>0?t=1:e<0&&(t=-1),t}function Qk(e,t,n,r,i,a,o,s,c,l){e.x+=fA(n,r,i,a,o.minimum,o.maximum,o.defalut,c)*l}function $k(e,t,n,r,i,a,o,s,c,l){e.y+=fA(n,r,i,a,o.minimum,o.maximum,o.defalut,c)*l}function eA(e,t,n,r,i,a,o,s,c,l){t.angle+=fA(n,r,i,a,s.minimum,s.maximum,s.defalut,c)*l}function tA(e,t,n,r,i){let a=e.x;return r&&(a*=-1),a}function nA(e,t,n,r,i){let a=e.y;return r&&(a*=-1),a}function rA(e,t,n,r,i){let a;return i=n>=2?t[n-1].position.substract(t[n-2].position):i.multiplyByScaler(-1),a=Q.directionToRadian(i,e),r&&(a*=-1),a}function iA(e,t){let n=Q.max(e,t),r=Q.min(e,t);return Q.abs(n-r)}function aA(e,t){return Q.min(e,t)+iA(e,t)/2}function oA(e,t){return JSON.parse(JSON.stringify(e.x))}function sA(e,t){return JSON.parse(JSON.stringify(e.y))}function cA(e,t){return JSON.parse(JSON.stringify(t))}function lA(e,t,n,r,i,a,o,s){let c,l,u=new Z(0,0),d=new Z(0,0),f=new Z(0,0),p=new Z(0,0);e[0].position=new Z(n.x,n.y);let m=Q.degreesToRadian(r),h=Q.radianToDirection(m);h.normalize();for(let n=1;n<t;++n)e[n].force=h.multiplyByScaler(e[n].acceleration).add(i),e[n].lastPosition=new Z(e[n].position.x,e[n].position.y),c=e[n].delay*o*30,u=e[n].position.substract(e[n-1].position),l=Q.directionToRadian(e[n].lastGravity,h)/s,u.x=Q.cos(l)*u.x-u.y*Q.sin(l),u.y=Q.sin(l)*u.x+u.y*Q.cos(l),e[n].position=e[n-1].position.add(u),d=e[n].velocity.multiplyByScaler(c),f=e[n].force.multiplyByScaler(c).multiplyByScaler(c),e[n].position=e[n].position.add(d).add(f),p=e[n].position.substract(e[n-1].position),p.normalize(),e[n].position=e[n-1].position.add(p.multiplyByScaler(e[n].radius)),Q.abs(e[n].position.x)<a&&(e[n].position.x=0),c!=0&&(e[n].velocity=e[n].position.substract(e[n].lastPosition),e[n].velocity=e[n].velocity.divisionByScalar(c),e[n].velocity=e[n].velocity.multiplyByScaler(e[n].mobility)),e[n].force=new Z(0,0),e[n].lastGravity=new Z(h.x,h.y)}function uA(e,t,n,r,i,a){let o=new Z(0,0);e[0].position=new Z(n.x,n.y);let s=Q.degreesToRadian(r),c=Q.radianToDirection(s);c.normalize();for(let n=1;n<t;++n)e[n].force=c.multiplyByScaler(e[n].acceleration).add(i),e[n].lastPosition=new Z(e[n].position.x,e[n].position.y),e[n].velocity=new Z(0,0),o=e[n].force,o.normalize(),o=o.multiplyByScaler(e[n].radius),e[n].position=e[n-1].position.add(o),Q.abs(e[n].position.x)<a&&(e[n].position.x=0),e[n].force=new Z(0,0),e[n].lastGravity=new Z(c.x,c.y)}function dA(e,t,n,r,i){let a;a=r*i.getScale(i.translationScale,i.angleScale),a<t?(a<i.valueBelowMinimum&&(i.valueBelowMinimum=a),a=t):a>n&&(a>i.valueExceededMaximum&&(i.valueExceededMaximum=a),a=n);let o=i.weight/100;o>=1||(a=e[0]*(1-o)+a*o),e[0]=a}function fA(e,t,n,r,i,a,o,s){let c=0,l=Q.max(n,t);l<e&&(e=l);let u=Q.min(n,t);u>e&&(e=u);let d=Q.min(i,a),f=Q.max(i,a),p=o,m=aA(u,l),h=e-m;switch(Zk(h)){case 1:{let e=f-p,t=l-m;t!=0&&(c=e/t*h,c+=p);break}case-1:{let e=d-p,t=u-m;t!=0&&(c=e/t*h,c+=p);break}case 0:c=p;break}return s?c:c*-1}var pA;(e=>{e.CubismPhysics=Jk,e.Options=Yk})(pA||={}),ME.registerRuntime({version:4,ready:ek,test(e){return e instanceof YO||YO.isValidJSON(e)},isValidMoc(e){if(e.byteLength<4)return!1;let t=new Int8Array(e,0,4);return String.fromCharCode(...t)===`MOC3`},createModelSettings(e){return new YO(e)},createCoreModel(e,t){let n=mk.create(e,!!t?.checkMocConsistency);try{let e=n.createModel();return e.__moc=n,e}catch(e){try{n.release()}catch(e){X.warn(`CubismFactory`,`Failed to release moc after core model creation failed.`,e)}throw e}},createInternalModel(e,t,n){let r=new HO(e,t,n),i=e;return i.__moc&&(r.__moc=i.__moc,delete i.__moc,r.once(`destroy`,mA)),r},createPhysics(e,t){if(!(t instanceof ArrayBuffer))throw TypeError(`Cubism physics data must be an ArrayBuffer.`);return Jk.create(t,t.byteLength)},createPose(e,t){if(!(t instanceof ArrayBuffer))throw TypeError(`Cubism pose data must be an ArrayBuffer.`);return ak.create(t,t.byteLength)}});function mA(){var e;(e=this.__moc)==null||e.release()}return e.Application=Fx,e.Live2DModel=ZE,e.Live2DPlugin=KE,e.Point=je,e.configureCubismSDK=$O,e.extensions=h,e})({});
|
|
995
|
+
//# sourceMappingURL=live2d-vendor.js.map
|