pixijs-input-devices 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const i={AltLeft:"AltLeft",AltRight:"AltRight",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",Backquote:"Backquote",Backslash:"Backslash",Backspace:"Backspace",BracketLeft:"BracketLeft",BracketRight:"BracketRight",CapsLock:"CapsLock",Comma:"Comma",ContextMenu:"ContextMenu",ControlLeft:"ControlLeft",ControlRight:"ControlRight",Delete:"Delete",Digit0:"Digit0",Digit1:"Digit1",Digit2:"Digit2",Digit3:"Digit3",Digit4:"Digit4",Digit5:"Digit5",Digit6:"Digit6",Digit7:"Digit7",Digit8:"Digit8",Digit9:"Digit9",End:"End",Enter:"Enter",Equal:"Equal",Escape:"Escape",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F2:"F2",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F3:"F3",F30:"F30",F31:"F31",F32:"F32",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",Home:"Home",IntlBackslash:"IntlBackslash",IntlRo:"IntlRo",IntlYen:"IntlYen",KeyA:"KeyA",KeyB:"KeyB",KeyC:"KeyC",KeyD:"KeyD",KeyE:"KeyE",KeyF:"KeyF",KeyG:"KeyG",KeyH:"KeyH",KeyI:"KeyI",KeyJ:"KeyJ",KeyK:"KeyK",KeyL:"KeyL",KeyM:"KeyM",KeyN:"KeyN",KeyO:"KeyO",KeyP:"KeyP",KeyQ:"KeyQ",KeyR:"KeyR",KeyS:"KeyS",KeyT:"KeyT",KeyU:"KeyU",KeyV:"KeyV",KeyW:"KeyW",KeyX:"KeyX",KeyY:"KeyY",KeyZ:"KeyZ",Lang1:"Lang1",Lang2:"Lang2",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",MetaLeft:"MetaLeft",MetaRight:"MetaRight",Minus:"Minus",NumLock:"NumLock",Numpad0:"Numpad0",Numpad1:"Numpad1",Numpad2:"Numpad2",Numpad3:"Numpad3",Numpad4:"Numpad4",Numpad5:"Numpad5",Numpad6:"Numpad6",Numpad7:"Numpad7",Numpad8:"Numpad8",Numpad9:"Numpad9",NumpadAdd:"NumpadAdd",NumpadComma:"NumpadComma",NumpadDecimal:"NumpadDecimal",NumpadDivide:"NumpadDivide",NumpadMultiply:"NumpadMultiply",NumpadSubtract:"NumpadSubtract",OSLeft:"OSLeft",Pause:"Pause",Period:"Period",Quote:"Quote",ScrollLock:"ScrollLock",Semicolon:"Semicolon",ShiftLeft:"ShiftLeft",ShiftRight:"ShiftRight",Slash:"Slash",Space:"Space",Tab:"Tab",VolumeDown:"VolumeDown",VolumeMute:"VolumeMute",VolumeUp:"VolumeUp",WakeUp:"WakeUp"};let l=class EventEmitter{constructor(){this._listeners={}}hasListener(i){return void 0!==this._listeners[i]}emit(i,l){var p;null===(p=this._listeners[i])||void 0===p||p.forEach((i=>i(l)))}on(i,l,p){var m,_;if(this._listeners[i]||(this._listeners[i]=[]),null==p?void 0:p.once){const onceFn=p=>{l(p),this.off(i,onceFn)};null===(m=this._listeners[i])||void 0===m||m.push(onceFn)}else null===(_=this._listeners[i])||void 0===_||_.push(l)}off(i,l){var p,m;this._listeners[i]=void 0===l||null===(p=this._listeners[i])||void 0===p?void 0:p.filter((i=>i!==l)),0===(null===(m=this._listeners[i])||void 0===m?void 0:m.length)&&(this._listeners[i]=void 0)}};function __awaiter(i,l,p,m){return new(p||(p=Promise))((function(_,y){function fulfilled(i){try{step(m.next(i))}catch(i){y(i)}}function rejected(i){try{step(m.throw(i))}catch(i){y(i)}}function step(i){i.done?_(i.value):function adopt(i){return i instanceof p?i:new p((function(l){l(i)}))}(i.value).then(fulfilled,rejected)}step((m=m.apply(i,l||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const p=/ф|и|с|в|у|а|п|р|ш|о|л|д|ь|т|щ|з|й|к|ы|е|г|м|ц|ч|н|я|ё|х|ъ|б|ю|э|ж|и/i,m=/[a-z]/i,_=["fr","mg","lu"],y=["ab","ba","be","bg","ch","kk","ky","mk","mn","ru","sr","tg","tt","uk","uz"],x=["de","cs","sk","sl","hu","hr","bs","ro","sq","me","lt","lv","et"];let v,T;function inferKeyboardLayoutFromLang(i=function getLang(){var i;const l=navigator;return(null===(i=l.languages)||void 0===i?void 0:i.length)?l.languages[0]:l.userLanguage||l.language||l.browserLanguage}()){const l=(i||"").toLowerCase(),p=l.split("-")[0];return _.includes(p)||l.startsWith("nl-be")?"AZERTY":y.includes(p)?"JCUKEN":x.includes(p)||l.startsWith("sr-latn")?"QWERTZ":"QWERTY"}const S=new Set(["AZERTY","JCUKEN","QWERTY","QWERTZ"]);function getLayoutKeyLabel(i,l){var p,m;if(void 0===T){const i={ArrowLeft:"⬅",ArrowRight:"➡",ArrowUp:"⬆",ArrowDown:"⬇",AltLeft:"Left Alt",AltRight:"Right Alt",Backquote:"`",Backslash:"\\",Backspace:"Backspace",BracketLeft:"[",BracketRight:"]",CapsLock:"CapsLock",Comma:",",ContextMenu:"Context Menu",ControlLeft:"Left Ctrl",ControlRight:"Right Ctrl",Delete:"Delete",Digit0:"0",Digit1:"1",Digit2:"2",Digit3:"3",Digit4:"4",Digit5:"5",Digit6:"6",Digit7:"7",Digit8:"8",Digit9:"9",End:"End",Enter:"Enter",Equal:"=",Escape:"Esc",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",Home:"Home",IntlBackslash:"\\",IntlRo:"Ro",IntlYen:"¥",KeyA:"A",KeyB:"B",KeyC:"C",KeyD:"D",KeyE:"E",KeyF:"F",KeyG:"G",KeyH:"H",KeyI:"I",KeyJ:"J",KeyK:"K",KeyL:"L",KeyM:"M",KeyN:"N",KeyO:"O",KeyP:"P",KeyQ:"Q",KeyR:"R",KeyS:"S",KeyT:"T",KeyU:"U",KeyV:"V",KeyW:"W",KeyX:"X",KeyY:"Y",KeyZ:"Z",Lang1:"Language 1",Lang2:"Language 2",MediaTrackNext:"Next Track",MediaTrackPrevious:"Previous Track",MetaLeft:"Left "+getMetaKeyLabel(),MetaRight:"Right "+getMetaKeyLabel(),Minus:"-",NumLock:"Num Lock",Numpad0:"Num0",Numpad1:"Num1",Numpad2:"Num2",Numpad3:"Num3",Numpad4:"Num4",Numpad5:"Num5",Numpad6:"Num6",Numpad7:"Num7",Numpad8:"Num8",Numpad9:"Num9",NumpadAdd:"+",NumpadComma:",",NumpadDecimal:".",NumpadDivide:"/",NumpadMultiply:"*",NumpadSubtract:"-",OSLeft:"OS Left",Pause:"Pause",Period:".",Quote:"'",ScrollLock:"Scroll Lock",Semicolon:";",ShiftLeft:"Left Shift",ShiftRight:"Right Shift",Slash:"/",Space:"Space",Tab:"Tab",VolumeDown:"Volume Down",VolumeMute:"Volume Mute",VolumeUp:"Volume Up",WakeUp:"Wake Up"};T={AZERTY:{KeyA:"Q",KeyQ:"A",KeyW:"Z",KeyZ:"W",Backquote:"²",BracketLeft:"«",BracketRight:"»"},JCUKEN:{KeyA:"Ф",KeyB:"И",KeyC:"С",KeyD:"В",KeyE:"У",KeyF:"А",KeyG:"П",KeyH:"Р",KeyI:"Ш",KeyJ:"О",KeyK:"Л",KeyL:"Д",KeyM:"Ь",KeyN:"Т",KeyO:"Щ",KeyP:"З",KeyQ:"Й",KeyR:"К",KeyS:"Ы",KeyT:"Е",KeyU:"Г",KeyV:"М",KeyW:"Ц",KeyX:"Ч",KeyY:"Н",KeyZ:"Я",Backquote:"Ё",BracketLeft:"х",BracketRight:"ъ",Comma:"Б",Period:"Ю",Quote:"Э",Semicolon:"Ж",Slash:"И"},QWERTY:i,QWERTZ:{KeyY:"Z",KeyZ:"Y",BracketLeft:"ü",BracketRight:"ö",Slash:"-"}}}return null!==(m=null!==(p=T[l][i])&&void 0!==p?p:T.QWERTY[i])&&void 0!==m?m:i}function getMetaKeyLabel(){var i,l,p,m;const _=navigator,y=null!==(l=null===(i=_.platform)||void 0===i?void 0:i.toLowerCase())&&void 0!==l?l:"",x=null!==(m=null===(p=_.userAgent)||void 0===p?void 0:p.toLowerCase())&&void 0!==m?m:"";return y.includes("mac")?"⌘":y.includes("win")||y.includes("linux")?"⊞":x.includes("android")?"Search":x.includes("iphone")||x.includes("ipad")?"⌘":"⊞"}class KeyboardDeviceInstance{static configureDefaultBinds(i){KeyboardDeviceInstance.global.configureBinds(i)}constructor(){this.type="keyboard",this.id="keyboard",this.meta={},this.lastInteraction=performance.now(),this.detected=!1,this.options={emitEvents:!0,detectLayoutOnKeypress:!0,binds:{NavigateBack:["Escape","Backspace"],NavigateDown:["ArrowDown","KeyS"],NavigateLeft:["ArrowLeft","KeyA"],NavigateRight:["ArrowRight","KeyD"],NavigateActivate:["Enter","Space"],NavigateUp:["ArrowUp","KeyW"]},repeatableBinds:["NavigateDown","NavigateLeft","NavigateRight","NavigateUp"]},this.key=Object.keys(i).reduce(((i,l)=>(i[l]=!1,i)),{}),this._emitter=new l,this._bindDownEmitter=new l,this._bindUpEmitter=new l,this._deferredKeydown=[],this._deferredKeyup=[],this._bindIndex=new Map,this._bindsDownCurr=new Set,this._bindsDownPrev=new Set,this._layout=inferKeyboardLayoutFromLang(),this._layoutSource="lang",this._rebuildBindIndex(),function requestKeyboardLayout(){return __awaiter(this,void 0,void 0,(function*(){const i=navigator;if(i.keyboard&&i.keyboard.getLayoutMap)try{const l=yield i.keyboard.getLayoutMap();v=l;const p=l.get("KeyQ"),m=l.get("KeyA"),_=l.get("KeyZ");if("a"===p&&"w"===_&&"q"===m)return"AZERTY";if("q"===p&&"y"===_&&"a"===m)return"QWERTZ";if("q"===p&&"z"===_&&"a"===m)return"QWERTY";if("й"===p&&"я"===_&&"ф"===m)return"JCUKEN"}catch(i){}}))}().then((i=>{void 0!==i&&(this._layoutSource="browser",this._layout=i,this.options.detectLayoutOnKeypress=!1,this._emitter.emit("layoutdetected",{layoutSource:"browser",layout:i,device:this}))})),this._configureEventListeners()}get layout(){return this._layout}set layout(i){this._layoutSource="manual",this._layout=i,this.options.detectLayoutOnKeypress=!1}get layoutSource(){return this._layoutSource}bindDown(i){return void 0!==this.options.binds[i]&&this.pressedAny(this.options.binds[i])}bindPressed(i){return this._bindsDownCurr.has(i)&&!this._bindsDownPrev.has(i)}bindReleased(i){return!this._bindsDownCurr.has(i)&&this._bindsDownPrev.has(i)}pressedAny(i){for(let l=0;l<i.length;l++)if(this.key[i[l]])return!0;return!1}pressedAll(i){for(let l=0;l<i.length;l++)if(!this.key[i[l]])return!1;return!0}configureBinds(i){this.options.binds=Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex()}exportBinds(){const i={};for(const l in this.options.binds){const p=this.options.binds[l];p&&(i[l]=[...p])}return i}importBinds(i,l="replace"){this.options.binds="replace"===l?Object.assign({},i):Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex(),this._emitter.emit("bindschanged",{device:this})}playHaptic(){}on(i,l,p){return this._emitter.on(i,l,p),this}off(i,l){return this._emitter.off(i,l),this}onBindDown(i,l,p){return this._bindDownEmitter.on(i,l,p),this}offBindDown(i,l){return this._bindDownEmitter.off(i,l),this}onBindUp(i,l,p){return this._bindUpEmitter.on(i,l,p),this}offBindUp(i,l){return this._bindUpEmitter.off(i,l),this}onBind(i,l,p){return this.onBindUp(i,l,p)}offBind(i,l){return this.offBindDown(i,l).offBindUp(i,l)}getKeyLabel(i,l){var p;return l?getLayoutKeyLabel(i,l):null!==(p=function getNavigatorKeyLabel(i){const l=null==v?void 0:v.get(i);return void 0===l?void 0:function _toLocaleTitleCase(i){return i.split(/\s+/).map((i=>i.charAt(0).toLocaleUpperCase()+i.slice(1))).join(" ")}(l)}(i))&&void 0!==p?p:getLayoutKeyLabel(i,null!=l?l:this._layout)}update(i){this._deferredKeydown.length>0&&(this._deferredKeydown.forEach((i=>this._processDeferredKeydownEvent(i))),this._deferredKeydown.length=0),this.options.emitEvents&&this._deferredKeyup.length>0&&(this._deferredKeyup.forEach((i=>this._emitDeferredKeyupEvent(i))),this._deferredKeyup.length=0,this.lastInteraction=i);const l=this._bindsDownPrev;this._bindsDownPrev=this._bindsDownCurr,this._bindsDownCurr=l,this._bindsDownCurr.clear();for(const[i,l]of this._bindIndex)if(this.key[i])for(let i=0;i<l.length;i++)this._bindsDownCurr.add(l[i])}clear(){for(const l of Object.keys(i))this.key[l]=!1}_configureEventListeners(){const i=this.key,l=this._deferredKeydown,p=this._deferredKeyup;window.addEventListener("keydown",(p=>{i[p.code]=!0,l.push(p),this.lastInteraction=performance.now()}),{passive:!0,capture:!0}),window.addEventListener("keyup",(l=>{i[l.code]=!1,p.push(l),this.lastInteraction=performance.now()}),{passive:!0,capture:!0})}_processDeferredKeydownEvent(i){const l=i.code;if(!i.repeat){if(this.options.detectLayoutOnKeypress&&"lang"===this._layoutSource){const l=function detectKeyboardLayoutFromKeydown(i){const l=i.key.toLowerCase(),_=i.code;return p.test(l)?(S.delete("AZERTY"),S.delete("QWERTY"),S.delete("QWERTZ")):"Backquote"===_&&"²"===l||"BracketLeft"===_&&"«"===l||"BracketRight"===_&&"»"===l||"KeyA"===_&&"q"===l||"KeyQ"===_&&"a"===l||"KeyW"===_&&"z"===l||"KeyZ"===_&&"w"===l?(S.delete("JCUKEN"),S.delete("QWERTY"),S.delete("QWERTZ")):"BracketLeft"===_&&"ü"===l||"BracketRight"===_&&"ö"===l||"KeyY"===_&&"z"===l||"KeyZ"===_&&"y"===l||"Slash"===_&&"-"===l?(S.delete("AZERTY"),S.delete("JCUKEN"),S.delete("QWERTY")):"BracketLeft"===_&&"["===l||"BracketRight"===_&&"]"===l||"KeyZ"===_&&"z"===l?(S.delete("AZERTY"),S.delete("JCUKEN"),S.delete("QWERTZ")):"KeyQ"===_&&"q"===l||"KeyW"===_&&"w"===l?(S.delete("AZERTY"),S.delete("JCUKEN")):"KeyY"===_&&"y"===l?(S.delete("QWERTZ"),S.delete("JCUKEN")):m.test(l)&&S.delete("JCUKEN"),1===S.size?[...S][0]:void 0}(i);void 0!==l&&(this._layout=l,this._layoutSource="keypress",this.options.detectLayoutOnKeypress=!1,this._emitter.emit("layoutdetected",{layout:l,layoutSource:"keypress",device:this}))}this.options.emitEvents&&this._emitter.hasListener(l)&&this._emitter.emit(l,{device:this,keyCode:l,keyLabel:this.getKeyLabel(l),event:i})}if(this.options.emitEvents){const p=this._bindIndex.get(l);if(p){const m=this.getKeyLabel(l);for(let _=0;_<p.length;_++){const y=p[_];if(i.repeat&&!this.options.repeatableBinds.includes(y))continue;const x={device:this,keyCode:l,keyLabel:m,event:i,name:y,repeat:i.repeat,value:1,pressed:!0};this._bindDownEmitter.emit(y,x),this._emitter.emit("binddown",x)}}}}_emitDeferredKeyupEvent(i){const l=i.code,p=this._bindIndex.get(l);if(p){const m=this.getKeyLabel(l);for(let _=0;_<p.length;_++){const y=p[_],x={device:this,keyCode:l,keyLabel:m,event:i,name:y,repeat:i.repeat,value:0,pressed:!1};this._bindUpEmitter.emit(y,x),this._emitter.emit("bindup",x)}}}_rebuildBindIndex(){this._bindIndex.clear();for(const i in this.options.binds){const l=this.options.binds[i];if(l)for(const p of l){let l=this._bindIndex.get(p);l||(l=[],this._bindIndex.set(p,l)),l.push(i)}}}}KeyboardDeviceInstance.global=new KeyboardDeviceInstance;const P=KeyboardDeviceInstance.global,C=0,E=1,A=2,k=3,B=["LeftStickLeft","LeftStickRight","LeftStickUp","LeftStickDown","RightStickLeft","RightStickRight","RightStickUp","RightStickDown"],F={Face1:0,Face2:1,Face3:2,Face4:3,LeftShoulder:4,RightShoulder:5,LeftTrigger:6,RightTrigger:7,Back:8,Start:9,LeftStickClick:10,RightStickClick:11,DpadUp:12,DpadDown:13,DpadLeft:14,DpadRight:15},R=["Face1","Face2","Face3","Face4","LeftShoulder","RightShoulder","LeftTrigger","RightTrigger","Back","Start","LeftStickClick","RightStickClick","DpadUp","DpadDown","DpadLeft","DpadRight"];const I=2e3;class GamepadHapticManager{constructor(i){var l,p,m;this.activeEffects=[],this.state={rumble:0,buzz:0,leftTrigger:0,rightTrigger:0,expires:0},this.gamepad=i,this.hapticEvent="vibrationActuator"in i?(null===(m=null===(p=null===(l=i.vibrationActuator)||void 0===l?void 0:l.effects)||void 0===p?void 0:p.includes)||void 0===m?void 0:m.call(p,"trigger-rumble"))?"trigger-rumble":"dual-rumble":void 0}play(i,l){var p;const m=Math.max(0,null!==(p=i.startDelay)&&void 0!==p?p:0),_=performance.now()+m;this.activeEffects.push(Object.assign(Object.assign({},i),{start:_,end:_+Math.max(i.duration,0),startDelay:void 0})),this.intensity!==l&&(this.intensity=Math.max(0,Math.min(1,l))),m||0!==this.activeEffects.length||this.update()}reset(){var i,l;this.activeEffects.length=0,this.state.rumble=0,this.state.buzz=0,this.state.leftTrigger=0,this.state.rightTrigger=0,this.gamepad.vibrationActuator?(this.gamepad.vibrationActuator.playEffect("dual-rumble",{duration:1,strongMagnitude:0,weakMagnitude:0,leftTrigger:0,rightTrigger:0}),this.gamepad.vibrationActuator.reset()):this.gamepad.hapticActuators&&(null===(l=null===(i=this.gamepad.hapticActuators[0])||void 0===i?void 0:i.pulse)||void 0===l||l.call(i,0,100))}update(){var i,l;const p=performance.now();let m=0,_=0,y=0,x=0,v=0,T=!1;for(let i=0;i<this.activeEffects.length;i++){const l=this.activeEffects[i];l.end<=p?T=!0:l.start>p||("trigger-rumble"===this.hapticEvent&&(l.leftTrigger&&l.leftTrigger>y&&(y=l.leftTrigger),l.rightTrigger&&l.rightTrigger>x&&(x=l.rightTrigger)),l.rumble&&l.rumble>m&&(m=l.rumble),l.buzz&&l.buzz>_&&(_=l.buzz),l.end-p>v&&(v=l.end-p))}if(T){let i=0;for(let l=0;l<this.activeEffects.length;l++)this.activeEffects[l].end>=p&&(this.activeEffects[i++]=this.activeEffects[l]);this.activeEffects.length=i}if(this.state.rumble!==m||this.state.buzz!==_||this.state.leftTrigger!==y||this.state.rightTrigger!==x||this.state.expires<=p&&m+_+y+x>0)if(this.state.rumble=m,this.state.buzz=_,this.state.leftTrigger=y,this.state.rightTrigger=x,void 0!==this.hapticEvent)this.state.expires=p+I,this.gamepad.vibrationActuator.playEffect(this.hapticEvent,{duration:I,strongMagnitude:m*this.intensity,weakMagnitude:_*this.intensity,leftTrigger:y*this.intensity,rightTrigger:x*this.intensity});else if(this.gamepad.hapticActuators){const y=Math.min(v,I),x=Math.max(m,_)*this.intensity;this.state.expires=p+v,null===(l=null===(i=this.gamepad.hapticActuators[0])||void 0===i?void 0:i.pulse)||void 0===l||l.call(i,x,y)}}}const D={clearInputOnBackground:!0,requireDocumentFocus:!0,supressHapticsInactivityPeriodMs:0};class GamepadDevice{static configureDefaultBinds(i){this.defaultOptions.binds=Object.assign(Object.assign({},this.defaultOptions.binds),i)}constructor(i){var p;this.source=i,this.type="gamepad",this.meta={},this.lastInteraction=performance.now(),this.options=JSON.parse(JSON.stringify(GamepadDevice.defaultOptions)),this.leftJoystick={x:0,y:0},this.rightJoystick={x:0,y:0},this.button=[...R,...B].reduce(((i,l)=>(i[l]=!1,i)),{}),this.leftTrigger=0,this.rightTrigger=0,this.leftShoulder=0,this.rightShoulder=0,this._emitter=new l,this._bindDownEmitter=new l,this._bindUpEmitter=new l,this._debounces=new Map,this._bindIndex=new Map,this._bindsDownCurr=new Set,this._bindsDownPrev=new Set,this.id="gamepad"+i.index,this.layout=null!==(p=function detectLayout(i){const l=(i||"").toLowerCase();return/(amazon|luna|1949)/.test(l)?"amazon_luna":/(logitech|046d|c216|logicool|^46d)/.test(l)?"logitech_g":/(joy-?con.*l|057e.*2006)/.test(l)?"nintendo_joycon_l":/(joy-?con.*r|057e.*2007)/.test(l)?"nintendo_joycon_r":/(wiiu?|0305|0306|0337)/.test(l)?"nintendo_wiiu":/(switch.*pro|nintendo|switch|057e|0300)/.test(l)?"nintendo_switch_pro":/(nvidia.*shield|nvidia|shield|0955)/.test(l)?"nvidia_shield":/(playstation.*5|dualsense|0df2|0ce6)/.test(l)?"playstation_5":/(playstation|sony|dualshock|054c|09cc|0ba0|0810)/.test(l)?"playstation_4":/(steam.*controller|steam|28de|1102|1142)/.test(l)?"steam_controller":/(xbox.*series|0b00|0b12)/.test(l)?"xbox_series":/(xbox.*360|0202|0283|0285|0288|0289|028e|028f|0291|0719)/.test(l)?"xbox_360":/(xbox|xinput|045e)/.test(l)?"xbox_one":void 0}(null==i?void 0:i.id))&&void 0!==p?p:"unknown",this._haptics=new GamepadHapticManager(i),this.supportsTriggerRumble="trigger-rumble"===this._haptics.hapticEvent,this._rebuildBindIndex()}bindDown(i){return void 0!==this.options.binds[i]&&this.pressedAny(this.options.binds[i])}bindPressed(i){return this._bindsDownCurr.has(i)&&!this._bindsDownPrev.has(i)}bindReleased(i){return!this._bindsDownCurr.has(i)&&this._bindsDownPrev.has(i)}pressedAny(i){for(let l=0;l<i.length;l++)if(this.button[i[l]])return!0;return!1}pressedAll(i){for(let l=0;l<i.length;l++)if(!this.button[i[l]])return!1;return!0}configureBinds(i){this.options.binds=Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex()}exportBinds(){const i={};for(const l in this.options.binds){const p=this.options.binds[l];p&&(i[l]=[...p])}return i}importBinds(i,l="replace"){this.options.binds="replace"===l?Object.assign({},i):Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex(),this._emitter.emit("bindschanged",{device:this})}on(i,l,p){return this._emitter.on(i,l,p),this}off(i,l){return this._emitter.off(i,l),this}onBindDown(i,l,p){return this._bindDownEmitter.on(i,l,p),this}offBindDown(i,l){return this._bindDownEmitter.off(i,l),this}onBindUp(i,l,p){return this._bindUpEmitter.on(i,l,p),this}offBindUp(i,l){return this._bindUpEmitter.off(i,l),this}onBind(i,l,p){return this.onBindUp(i,l,p)}offBind(i,l){return this.offBindDown(i,l).offBindUp(i,l)}playHaptic(...i){this.options.vibration.enabled&&(D.supressHapticsInactivityPeriodMs>0&&performance.now()-this.lastInteraction>D.supressHapticsInactivityPeriodMs||i.forEach((i=>this._haptics.play(i,this.options.vibration.intensity))))}stopHaptics(){this._haptics.reset()}update(i,l){this.source=i,this._poll(i,l),this._haptics.update(),this._snapshotBindState()}clear(){this.button=[...B,...R].reduce(((i,l)=>(i[l]=!1,i)),{}),this._haptics.reset()}_poll(i,l){var p,m,_,y,x,v,T;const S=this.options.joystick;for(let p=0;p<4;p++){const m=_scale(i.axes[p],S.deadzone),_=B[2*p+(m>0?1:0)];if(Math.abs(m)<S.pressThreshold){if(this.button[_]){if(this.options.emitEvents){const i=this._bindIndex.get(_);if(i)for(let l=0;l<i.length;l++){const y=i[l],x={device:this,type:"axis",axis:p,axisCode:_,name:y,pressed:!1,value:m};this._bindUpEmitter.emit(y,x),this._emitter.emit("bindup",x)}}}else this._debounces.delete(_);this.button[_]=!1}else{const i=S.autoRepeatDelayMs[+this.button[_]];if(this._debounce(_,i)&&this.button[_])continue;if(this.button[_]=!0,this.lastInteraction=l,this.options.emitEvents){this._emitter.hasListener(_)&&this._emitter.emit(_,{device:this,axis:p,axisCode:_,pressed:!0,value:m});const i=this._bindIndex.get(_);if(i)for(let l=0;l<i.length;l++){const y=i[l],x={device:this,type:"axis",axis:p,axisCode:_,name:y,pressed:!0,value:m};this._bindDownEmitter.emit(y,x),this._emitter.emit("binddown",x)}}}}for(let y=0;y<16;y++){let x=y;const v=R[x];if(this.button[v]===(null===(p=i.buttons[y])||void 0===p?void 0:p.pressed))continue;this.lastInteraction=l;const T=null!==(_=null===(m=i.buttons[y])||void 0===m?void 0:m.pressed)&&void 0!==_&&_;if(this.button[v]=T,this.options.emitEvents){T&&this._emitter.hasListener(v)&&this._emitter.emit(v,{device:this,button:x,buttonCode:v,pressed:!0,value:1});const i=this._bindIndex.get(v);if(i)for(let l=0;l<i.length;l++){const p=i[l],m={device:this,type:"button",button:x,buttonCode:v,name:p,pressed:T,value:T?1:0};(T?this._bindDownEmitter:this._bindUpEmitter).emit(p,m),this._emitter.emit(T?"binddown":"bindup",m)}}}const P=this.options.trigger.deadzone;this.leftTrigger=_scale(i.buttons[F.LeftTrigger].value,P),this.rightTrigger=_scale(i.buttons[F.RightTrigger].value,P),this.leftShoulder=_scale(i.buttons[F.LeftShoulder].value,P),this.rightShoulder=_scale(i.buttons[F.RightShoulder].value,P);const I=S.deadzone;this.leftJoystick.x=_scale(null!==(y=i.axes[C])&&void 0!==y?y:0,I),this.leftJoystick.y=_scale(null!==(x=i.axes[E])&&void 0!==x?x:0,I),this.rightJoystick.x=_scale(null!==(v=i.axes[A])&&void 0!==v?v:0,I),this.rightJoystick.y=_scale(null!==(T=i.axes[k])&&void 0!==T?T:0,I)}_debounce(i,l){var p;const m=Date.now();return(null!==(p=this._debounces.get(i))&&void 0!==p?p:0)>m||(this._debounces.set(i,m+l),!1)}_snapshotBindState(){const i=this._bindsDownPrev;this._bindsDownPrev=this._bindsDownCurr,this._bindsDownCurr=i,this._bindsDownCurr.clear();for(const[i,l]of this._bindIndex)if(this.button[i])for(let i=0;i<l.length;i++)this._bindsDownCurr.add(l[i])}_rebuildBindIndex(){this._bindIndex.clear();for(const i in this.options.binds){const l=this.options.binds[i];if(l)for(const p of l){let l=this._bindIndex.get(p);l||(l=[],this._bindIndex.set(p,l)),l.push(i)}}}}function _scale(i,l){const p=(Math.abs(i)-l[0])/(l[1]-l[0]);return p>=0&&p<=1?Math.sign(i)*p:p>1?1*Math.sign(i):0}GamepadDevice.defaultOptions={emitEvents:!0,joystick:{deadzone:[0,1],pressThreshold:.5,autoRepeatDelayMs:[400,100]},trigger:{deadzone:[0,1]},vibration:{enabled:!0,intensity:1},binds:{NavigateActivate:["Face1"],NavigateBack:["Face2"],NavigateUp:["DpadUp","LeftStickUp"],NavigateLeft:["DpadLeft","LeftStickLeft"],NavigateDown:["DpadDown","LeftStickDown"],NavigateRight:["DpadRight","LeftStickRight"]}};class InputDeviceManager{constructor(){this.hasMouseLikePointer=window.matchMedia("(pointer: fine) and (hover: hover)").matches,this.isTouchCapable=("ontouchstart"in window||window.TouchEvent)&&navigator.maxTouchPoints>0,this.isMobile=(()=>{let i=!1;return(l=>{(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(l)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s)|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(|\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(|\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg(g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v)|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v)|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|)|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(l.substr(0,4)))&&(i=!0)})(navigator.userAgent||navigator.vendor),i})(),this.keyboard=P,this.options=D,this._devices=[],this._gamepads=[],this._gamepadIdx=new Map,this._custom=[],this._emitter=new l,this._bindDownEmitter=new l,this._bindUpEmitter=new l,this._hasFocus=!1,this._lastInteractionWatermark=0,!this.isMobile&&this.hasMouseLikePointer?this.add(this.keyboard):window.addEventListener("keydown",(()=>this.add(this.keyboard)),{once:!0}),window.addEventListener("gamepadconnected",(i=>{const l=new GamepadDevice(i.gamepad);this.add(l)})),window.addEventListener("gamepaddisconnected",(i=>{const l=this._gamepadIdx.get(i.gamepad.index);l&&this.remove(l)}))}get devices(){return this._devices}get gamepads(){return this._gamepads}get custom(){return this._custom}get lastInteractedDevice(){return this._lastInteractedDevice}on(i,l){return this._emitter.on(i,l),this}off(i,l){return this._emitter.off(i,l),this}onBindDown(i,l,p){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindDownEmitter.on(i,l,p))),this}onBindUp(i,l,p){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindUpEmitter.on(i,l,p))),this}onBindDownUp(i,l,p){return this.onBindDown(i,l,p).onBindUp(i,l,p)}offBindDown(i,l){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindDownEmitter.off(i,l))),this}offBindUp(i,l){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindUpEmitter.off(i,l))),this}offBindDownUp(i,l){return this.offBindDown(i,l).offBindUp(i,l)}exportBinds(){const i={};for(const l of this._gamepads)i[l.id]=l.exportBinds();return{keyboard:this.keyboard.exportBinds(),gamepads:i}}importBinds(i,l="replace"){this.keyboard.importBinds(i.keyboard,l);for(const p of this._gamepads){const m=i.gamepads[p.id];m&&p.importBinds(m,l)}}emitBindDown(i,l,p=1){return this._bindDownEmitter.emit(i,{name:i,device:l,pressed:!0,value:p}),this}emitBindUp(i,l){return this._bindUpEmitter.emit(i,{name:i,device:l,pressed:!1,value:0}),this}emitBindDownUp(i,l){this.emitBindDown(i,l).emitBindUp(i,l)}add(i){-1===this._devices.indexOf(i)&&(this._devices.push(i),"keyboard"===i.type?(i.detected=!0,i.on("binddown",(i=>this._bindDownEmitter.emit(i.name,i))).on("bindup",(i=>this._bindUpEmitter.emit(i.name,i)))):i instanceof GamepadDevice?(this._gamepadIdx.set(i.source.index,i),this._gamepads.push(i),i.on("binddown",(i=>this._bindDownEmitter.emit(i.name,i))).on("bindup",(i=>this._bindUpEmitter.emit(i.name,i)))):this._custom.push(i),this._emitter.emit("deviceadded",{device:i}))}remove(i){if("keyboard"===i.type)i.detected=!1;else if(i instanceof GamepadDevice){this._gamepadIdx.delete(i.source.index);const l=this._gamepads.indexOf(i);-1!==l&&this._gamepads.splice(l,1)}else{const l=this._custom.indexOf(i);-1!==l&&this._custom.splice(l,1)}const l=this._devices.indexOf(i);-1!==l&&(this._devices.splice(l,1),this._emitter.emit("deviceremoved",{device:i}))}update(){if(this.options.requireDocumentFocus&&!document.hasFocus())return this._hasFocus&&this.options.clearInputOnBackground&&this.devices.forEach((i=>{var l;return null===(l=i.clear)||void 0===l?void 0:l.call(i)})),this._hasFocus=!1,this._devices;this._hasFocus=!0;const i=performance.now();this.keyboard.detected&&this.keyboard.update(i),this._gamepads.length>0&&this._pollGamepads(i);for(const l of this._custom)l.update(i);return this._updateLastInteracted(),this._devices}_updateLastInteracted(){if(0===this._devices.length)return;let i,l=0;for(const i of this._devices)i.lastInteraction>l&&(l=i.lastInteraction);if(!(l<=this._lastInteractionWatermark&&void 0!==this._lastInteractedDevice)){if(this._lastInteractionWatermark=l,1===this._devices.length)i=this._devices[0];else for(const l of this._devices)(void 0===i||l.lastInteraction>i.lastInteraction)&&(i=l);i!==this._lastInteractedDevice&&this._emitter.emit("lastdevicechanged",{device:i}),this._lastInteractedDevice=i}}_pollGamepads(i){var l;if(null!=navigator.getGamepads)for(const p of navigator.getGamepads())null!=p&&(null===(l=this._gamepadIdx.get(p.index))||void 0===l||l.update(p,i))}}InputDeviceManager.global=new InputDeviceManager;const L=InputDeviceManager.global;let U=new WeakMap;function invalidateNavigatablesCache(i){void 0!==i?U.delete(i):U=new WeakMap}function getAllNavigatables(i,l){if(void 0!==l)return _collectNavigatables(i,l);const p=U.get(i);if(void 0!==p)return p;const m=_collectNavigatables(i,[]);return U.set(i,m),m}function _collectNavigatables(i,l){var p;for(const m of null!==(p=i.children)&&void 0!==p?p:[])m.navigatable?l.push(m):_collectNavigatables(m,l);return l}function getFirstNavigatable(i,l){return function chooseFirstNavigatableInDirection(i,l={}){var p,m,_;const{currentFocus:y,direction:x,spatial:v}=l,T=i.filter((i=>i.navigatable&&null!=i.parent&&isVisible(i))),S=T.find((i=>i===y));if(void 0===S)return T.sort(((i,l)=>l.navigationPriority-i.navigationPriority)),T[0];if(void 0===x&&S)return S;const P=null!=S?S:T[Math.floor(Math.random()*T.length)];if(void 0===S)return null!==(p=i[0])&&void 0!==p?p:P;const C=S.getGlobalPosition();let E=T.filter((i=>i!==S)).map((i=>{const{x:l,y:p}=i.getGlobalPosition();return{element:i,x:l,y:p}}));const{minimumDistance:A,directionAxisWeight:k}=v;switch(x){case"NavigateUp":E=E.filter((i=>i.y<C.y-A));break;case"NavigateLeft":E=E.filter((i=>i.x<C.x-A));break;case"NavigateRight":E=E.filter((i=>i.x>C.x+A));break;case"NavigateDown":E=E.filter((i=>i.y>C.y+A));break;default:return S}const B=E.map((i=>{const l="NavigateLeft"===x||"NavigateRight"===x,p=l?1/k:1,m=l?1:1/k,_=(C.x-i.x)*p,y=(C.y-i.y)*m;return Object.assign(Object.assign({},i),{score:_*_+y*y})})).sort(((i,l)=>i.score-l.score));return null!==(_=null===(m=B[0])||void 0===m?void 0:m.element)&&void 0!==_?_:P}(getAllNavigatables(i),l)}function isChildOf(i,l){for(;null!=i;){if(i===l)return!0;i=i.parent}return!1}function isVisible(i){for(;null!=i;){if(!i.visible)return!1;i=i.parent}return!0}const G=Object.freeze({Activate:"NavigateActivate",Back:"NavigateBack",Down:"NavigateDown",Left:"NavigateLeft",Right:"NavigateRight",Up:"NavigateUp"});var O=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(O||{});const normalizeExtension=i=>{if("function"==typeof i||"object"==typeof i&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={..."object"!=typeof i.extension?{type:i.extension}:i.extension,ref:i}}if("object"!=typeof i)throw new Error("Invalid extension type");return"string"==typeof(i={...i}).type&&(i.type=[i.type]),i},normalizeExtensionPriority=(i,l)=>normalizeExtension(i).priority??l,z={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(normalizeExtension).forEach((i=>{i.type.forEach((l=>this._removeHandlers[l]?.(i)))})),this},add(...i){return i.map(normalizeExtension).forEach((i=>{i.type.forEach((l=>{const p=this._addHandlers,m=this._queue;p[l]?p[l]?.(i):(m[l]=m[l]||[],m[l]?.push(i))}))})),this},handle(i,l,p){const m=this._addHandlers,_=this._removeHandlers;if(m[i]||_[i])throw new Error(`Extension type ${i} already has a handler`);m[i]=l,_[i]=p;const y=this._queue;return y[i]&&(y[i]?.forEach((i=>l(i))),delete y[i]),this},handleByMap(i,l){return this.handle(i,(i=>{i.name&&(l[i.name]=i.ref)}),(i=>{i.name&&delete l[i.name]}))},handleByNamedList(i,l,p=-1){return this.handle(i,(i=>{l.findIndex((l=>l.name===i.name))>=0||(l.push({name:i.name,value:i.ref}),l.sort(((i,l)=>normalizeExtensionPriority(l.value,p)-normalizeExtensionPriority(i.value,p))))}),(i=>{const p=l.findIndex((l=>l.name===i.name));-1!==p&&l.splice(p,1)}))},handleByList(i,l,p=-1){return this.handle(i,(i=>{l.includes(i.ref)||(l.push(i.ref),l.sort(((i,l)=>normalizeExtensionPriority(l,p)-normalizeExtensionPriority(i,p))))}),(i=>{const p=l.indexOf(i.ref);-1!==p&&l.splice(p,1)}))}},W={extension:{type:O.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then((function(){return ar}))}},K={extension:{type:O.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:async()=>{await Promise.resolve().then((function(){return hr}))}};class ObservablePoint{constructor(i,l,p){this._x=l||0,this._y=p||0,this._observer=i}clone(i){return new ObservablePoint(i??this._observer,this._x,this._y)}set(i=0,l=i){return this._x===i&&this._y===l||(this._x=i,this._y=l,this._observer._onUpdate(this)),this}copyFrom(i){return this._x===i.x&&this._y===i.y||(this._x=i.x,this._y=i.y,this._observer._onUpdate(this)),this}copyTo(i){return i.set(this._x,this._y),i}equals(i){return i.x===this._x&&i.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(i){this._x!==i&&(this._x=i,this._observer._onUpdate(this))}get y(){return this._y}set y(i){this._y!==i&&(this._y=i,this._observer._onUpdate(this))}}function getDefaultExportFromCjs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Y={exports:{}};!function(i){var l=Object.prototype.hasOwnProperty,p="~";function Events(){}function EE(i,l,p){this.fn=i,this.context=l,this.once=p||!1}function addListener(i,l,m,_,y){if("function"!=typeof m)throw new TypeError("The listener must be a function");var x=new EE(m,_||i,y),v=p?p+l:l;return i._events[v]?i._events[v].fn?i._events[v]=[i._events[v],x]:i._events[v].push(x):(i._events[v]=x,i._eventsCount++),i}function clearEvent(i,l){0==--i._eventsCount?i._events=new Events:delete i._events[l]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),(new Events).__proto__||(p=!1)),EventEmitter.prototype.eventNames=function eventNames(){var i,m,_=[];if(0===this._eventsCount)return _;for(m in i=this._events)l.call(i,m)&&_.push(p?m.slice(1):m);return Object.getOwnPropertySymbols?_.concat(Object.getOwnPropertySymbols(i)):_},EventEmitter.prototype.listeners=function listeners(i){var l=p?p+i:i,m=this._events[l];if(!m)return[];if(m.fn)return[m.fn];for(var _=0,y=m.length,x=new Array(y);_<y;_++)x[_]=m[_].fn;return x},EventEmitter.prototype.listenerCount=function listenerCount(i){var l=p?p+i:i,m=this._events[l];return m?m.fn?1:m.length:0},EventEmitter.prototype.emit=function emit(i,l,m,_,y,x){var v=p?p+i:i;if(!this._events[v])return!1;var T,S,P=this._events[v],C=arguments.length;if(P.fn){switch(P.once&&this.removeListener(i,P.fn,void 0,!0),C){case 1:return P.fn.call(P.context),!0;case 2:return P.fn.call(P.context,l),!0;case 3:return P.fn.call(P.context,l,m),!0;case 4:return P.fn.call(P.context,l,m,_),!0;case 5:return P.fn.call(P.context,l,m,_,y),!0;case 6:return P.fn.call(P.context,l,m,_,y,x),!0}for(S=1,T=new Array(C-1);S<C;S++)T[S-1]=arguments[S];P.fn.apply(P.context,T)}else{var E,A=P.length;for(S=0;S<A;S++)switch(P[S].once&&this.removeListener(i,P[S].fn,void 0,!0),C){case 1:P[S].fn.call(P[S].context);break;case 2:P[S].fn.call(P[S].context,l);break;case 3:P[S].fn.call(P[S].context,l,m);break;case 4:P[S].fn.call(P[S].context,l,m,_);break;default:if(!T)for(E=1,T=new Array(C-1);E<C;E++)T[E-1]=arguments[E];P[S].fn.apply(P[S].context,T)}}return!0},EventEmitter.prototype.on=function on(i,l,p){return addListener(this,i,l,p,!1)},EventEmitter.prototype.once=function once(i,l,p){return addListener(this,i,l,p,!0)},EventEmitter.prototype.removeListener=function removeListener(i,l,m,_){var y=p?p+i:i;if(!this._events[y])return this;if(!l)return clearEvent(this,y),this;var x=this._events[y];if(x.fn)x.fn!==l||_&&!x.once||m&&x.context!==m||clearEvent(this,y);else{for(var v=0,T=[],S=x.length;v<S;v++)(x[v].fn!==l||_&&!x[v].once||m&&x[v].context!==m)&&T.push(x[v]);T.length?this._events[y]=1===T.length?T[0]:T:clearEvent(this,y)}return this},EventEmitter.prototype.removeAllListeners=function removeAllListeners(i){var l;return i?(l=p?p+i:i,this._events[l]&&clearEvent(this,l)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=p,EventEmitter.EventEmitter=EventEmitter,i.exports=EventEmitter}(Y);var V=getDefaultExportFromCjs(Y.exports);const X=2*Math.PI,j=180/Math.PI,q=Math.PI/180;class Point{constructor(i=0,l=0){this.x=0,this.y=0,this.x=i,this.y=l}clone(){return new Point(this.x,this.y)}copyFrom(i){return this.set(i.x,i.y),this}copyTo(i){return i.set(this.x,this.y),i}equals(i){return i.x===this.x&&i.y===this.y}set(i=0,l=i){return this.x=i,this.y=l,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Z.x=0,Z.y=0,Z}}const Z=new Point;class Matrix{constructor(i=1,l=0,p=0,m=1,_=0,y=0){this.array=null,this.a=i,this.b=l,this.c=p,this.d=m,this.tx=_,this.ty=y}fromArray(i){this.a=i[0],this.b=i[1],this.c=i[3],this.d=i[4],this.tx=i[2],this.ty=i[5]}set(i,l,p,m,_,y){return this.a=i,this.b=l,this.c=p,this.d=m,this.tx=_,this.ty=y,this}toArray(i,l){this.array||(this.array=new Float32Array(9));const p=l||this.array;return i?(p[0]=this.a,p[1]=this.b,p[2]=0,p[3]=this.c,p[4]=this.d,p[5]=0,p[6]=this.tx,p[7]=this.ty,p[8]=1):(p[0]=this.a,p[1]=this.c,p[2]=this.tx,p[3]=this.b,p[4]=this.d,p[5]=this.ty,p[6]=0,p[7]=0,p[8]=1),p}apply(i,l){l=l||new Point;const p=i.x,m=i.y;return l.x=this.a*p+this.c*m+this.tx,l.y=this.b*p+this.d*m+this.ty,l}applyInverse(i,l){l=l||new Point;const p=this.a,m=this.b,_=this.c,y=this.d,x=this.tx,v=this.ty,T=1/(p*y+_*-m),S=i.x,P=i.y;return l.x=y*T*S+-_*T*P+(v*_-x*y)*T,l.y=p*T*P+-m*T*S+(-v*p+x*m)*T,l}translate(i,l){return this.tx+=i,this.ty+=l,this}scale(i,l){return this.a*=i,this.d*=l,this.c*=i,this.b*=l,this.tx*=i,this.ty*=l,this}rotate(i){const l=Math.cos(i),p=Math.sin(i),m=this.a,_=this.c,y=this.tx;return this.a=m*l-this.b*p,this.b=m*p+this.b*l,this.c=_*l-this.d*p,this.d=_*p+this.d*l,this.tx=y*l-this.ty*p,this.ty=y*p+this.ty*l,this}append(i){const l=this.a,p=this.b,m=this.c,_=this.d;return this.a=i.a*l+i.b*m,this.b=i.a*p+i.b*_,this.c=i.c*l+i.d*m,this.d=i.c*p+i.d*_,this.tx=i.tx*l+i.ty*m+this.tx,this.ty=i.tx*p+i.ty*_+this.ty,this}appendFrom(i,l){const p=i.a,m=i.b,_=i.c,y=i.d,x=i.tx,v=i.ty,T=l.a,S=l.b,P=l.c,C=l.d;return this.a=p*T+m*P,this.b=p*S+m*C,this.c=_*T+y*P,this.d=_*S+y*C,this.tx=x*T+v*P+l.tx,this.ty=x*S+v*C+l.ty,this}setTransform(i,l,p,m,_,y,x,v,T){return this.a=Math.cos(x+T)*_,this.b=Math.sin(x+T)*_,this.c=-Math.sin(x-v)*y,this.d=Math.cos(x-v)*y,this.tx=i-(p*this.a+m*this.c),this.ty=l-(p*this.b+m*this.d),this}prepend(i){const l=this.tx;if(1!==i.a||0!==i.b||0!==i.c||1!==i.d){const l=this.a,p=this.c;this.a=l*i.a+this.b*i.c,this.b=l*i.b+this.b*i.d,this.c=p*i.a+this.d*i.c,this.d=p*i.b+this.d*i.d}return this.tx=l*i.a+this.ty*i.c+i.tx,this.ty=l*i.b+this.ty*i.d+i.ty,this}decompose(i){const l=this.a,p=this.b,m=this.c,_=this.d,y=i.pivot,x=-Math.atan2(-m,_),v=Math.atan2(p,l),T=Math.abs(x+v);return T<1e-5||Math.abs(X-T)<1e-5?(i.rotation=v,i.skew.x=i.skew.y=0):(i.rotation=0,i.skew.x=x,i.skew.y=v),i.scale.x=Math.sqrt(l*l+p*p),i.scale.y=Math.sqrt(m*m+_*_),i.position.x=this.tx+(y.x*l+y.y*m),i.position.y=this.ty+(y.x*p+y.y*_),i}invert(){const i=this.a,l=this.b,p=this.c,m=this.d,_=this.tx,y=i*m-l*p;return this.a=m/y,this.b=-l/y,this.c=-p/y,this.d=i/y,this.tx=(p*this.ty-m*_)/y,this.ty=-(i*this.ty-l*_)/y,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const i=new Matrix;return i.a=this.a,i.b=this.b,i.c=this.c,i.d=this.d,i.tx=this.tx,i.ty=this.ty,i}copyTo(i){return i.a=this.a,i.b=this.b,i.c=this.c,i.d=this.d,i.tx=this.tx,i.ty=this.ty,i}copyFrom(i){return this.a=i.a,this.b=i.b,this.c=i.c,this.d=i.d,this.tx=i.tx,this.ty=i.ty,this}equals(i){return i.a===this.a&&i.b===this.b&&i.c===this.c&&i.d===this.d&&i.tx===this.tx&&i.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 J.identity()}static get shared(){return Q.identity()}}const Q=new Matrix,J=new Matrix,tt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],et=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],it=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],st=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],rt=[],nt=[],ot=Math.sign;!function init(){for(let i=0;i<16;i++){const l=[];rt.push(l);for(let p=0;p<16;p++){const m=ot(tt[i]*tt[p]+it[i]*et[p]),_=ot(et[i]*tt[p]+st[i]*et[p]),y=ot(tt[i]*it[p]+it[i]*st[p]),x=ot(et[i]*it[p]+st[i]*st[p]);for(let i=0;i<16;i++)if(tt[i]===m&&et[i]===_&&it[i]===y&&st[i]===x){l.push(i);break}}}for(let i=0;i<16;i++){const l=new Matrix;l.set(tt[i],et[i],it[i],st[i],0,0),nt.push(l)}}();const at={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:i=>tt[i],uY:i=>et[i],vX:i=>it[i],vY:i=>st[i],inv:i=>8&i?15&i:7&-i,add:(i,l)=>rt[i][l],sub:(i,l)=>rt[i][at.inv(l)],rotate180:i=>4^i,isVertical:i=>2==(3&i),byDirection:(i,l)=>2*Math.abs(i)<=Math.abs(l)?l>=0?at.S:at.N:2*Math.abs(l)<=Math.abs(i)?i>0?at.E:at.W:l>0?i>0?at.SE:at.SW:i>0?at.NE:at.NW,matrixAppendRotationInv:(i,l,p=0,m=0)=>{const _=nt[at.inv(l)];_.tx=p,_.ty=m,i.append(_)}},ht=[new Point,new Point,new Point,new Point];class Rectangle{constructor(i=0,l=0,p=0,m=0){this.type="rectangle",this.x=Number(i),this.y=Number(l),this.width=Number(p),this.height=Number(m)}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 Rectangle(0,0,0,0)}clone(){return new Rectangle(this.x,this.y,this.width,this.height)}copyFromBounds(i){return this.x=i.minX,this.y=i.minY,this.width=i.maxX-i.minX,this.height=i.maxY-i.minY,this}copyFrom(i){return this.x=i.x,this.y=i.y,this.width=i.width,this.height=i.height,this}copyTo(i){return i.copyFrom(this),i}contains(i,l){return!(this.width<=0||this.height<=0)&&(i>=this.x&&i<this.x+this.width&&l>=this.y&&l<this.y+this.height)}strokeContains(i,l,p){const{width:m,height:_}=this;if(m<=0||_<=0)return!1;const y=this.x,x=this.y;return i>=y-p/2&&i<=y+m+p/2&&l>=x-p/2&&l<=x+_+p/2&&!(i>y+p/2&&i<y+m-p/2&&l>x+p/2&&l<x+_-p/2)}intersects(i,l){if(!l){const l=this.x<i.x?i.x:this.x;if((this.right>i.right?i.right:this.right)<=l)return!1;const p=this.y<i.y?i.y:this.y;return(this.bottom>i.bottom?i.bottom:this.bottom)>p}const p=this.left,m=this.right,_=this.top,y=this.bottom;if(m<=p||y<=_)return!1;const x=ht[0].set(i.left,i.top),v=ht[1].set(i.left,i.bottom),T=ht[2].set(i.right,i.top),S=ht[3].set(i.right,i.bottom);if(T.x<=x.x||v.y<=x.y)return!1;const P=Math.sign(l.a*l.d-l.b*l.c);if(0===P)return!1;if(l.apply(x,x),l.apply(v,v),l.apply(T,T),l.apply(S,S),Math.max(x.x,v.x,T.x,S.x)<=p||Math.min(x.x,v.x,T.x,S.x)>=m||Math.max(x.y,v.y,T.y,S.y)<=_||Math.min(x.y,v.y,T.y,S.y)>=y)return!1;const C=P*(v.y-x.y),E=P*(x.x-v.x),A=C*p+E*_,k=C*m+E*_,B=C*p+E*y,F=C*m+E*y;if(Math.max(A,k,B,F)<=C*x.x+E*x.y||Math.min(A,k,B,F)>=C*S.x+E*S.y)return!1;const R=P*(x.y-T.y),I=P*(T.x-x.x),D=R*p+I*_,L=R*m+I*_,U=R*p+I*y,G=R*m+I*y;return!(Math.max(D,L,U,G)<=R*x.x+I*x.y||Math.min(D,L,U,G)>=R*S.x+I*S.y)}pad(i=0,l=i){return this.x-=i,this.y-=l,this.width+=2*i,this.height+=2*l,this}fit(i){const l=Math.max(this.x,i.x),p=Math.min(this.x+this.width,i.x+i.width),m=Math.max(this.y,i.y),_=Math.min(this.y+this.height,i.y+i.height);return this.x=l,this.width=Math.max(p-l,0),this.y=m,this.height=Math.max(_-m,0),this}ceil(i=1,l=.001){const p=Math.ceil((this.x+this.width-l)*i)/i,m=Math.ceil((this.y+this.height-l)*i)/i;return this.x=Math.floor((this.x+l)*i)/i,this.y=Math.floor((this.y+l)*i)/i,this.width=p-this.x,this.height=m-this.y,this}enlarge(i){const l=Math.min(this.x,i.x),p=Math.max(this.x+this.width,i.x+i.width),m=Math.min(this.y,i.y),_=Math.max(this.y+this.height,i.y+i.height);return this.x=l,this.width=p-l,this.y=m,this.height=_-m,this}getBounds(i){return(i=i||new Rectangle).copyFrom(this),i}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const lt={default:-1};function uid(i="default"){return void 0===lt[i]&&(lt[i]=-1),++lt[i]}const dt={},ut="8.0.0";function deprecation(i,l,p=3){if(dt[l])return;let m=(new Error).stack;void 0===m?console.warn("PixiJS Deprecation Warning: ",`${l}\nDeprecated since v${i}`):(m=m.split("\n").splice(p).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${l}\nDeprecated since v${i}`),console.warn(m),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${l}\nDeprecated since v${i}`),console.warn(m))),dt[l]=!0}const NOOP=()=>{};function nextPow2(i){return i+=0===i?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,(i|=i>>>16)+1}function isPow2(i){return!(i&i-1||!i)}const ct=Object.create(null);const pt=class _TextureStyle extends V{constructor(i={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,i={..._TextureStyle.defaultOptions,...i},this.addressMode=i.addressMode,this.addressModeU=i.addressModeU??this.addressModeU,this.addressModeV=i.addressModeV??this.addressModeV,this.addressModeW=i.addressModeW??this.addressModeW,this.scaleMode=i.scaleMode,this.magFilter=i.magFilter??this.magFilter,this.minFilter=i.minFilter??this.minFilter,this.mipmapFilter=i.mipmapFilter??this.mipmapFilter,this.lodMinClamp=i.lodMinClamp,this.lodMaxClamp=i.lodMaxClamp,this.compare=i.compare,this.maxAnisotropy=i.maxAnisotropy??1}set addressMode(i){this.addressModeU=i,this.addressModeV=i,this.addressModeW=i}get addressMode(){return this.addressModeU}set wrapMode(i){deprecation(ut,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=i}get wrapMode(){return this.addressMode}set scaleMode(i){this.magFilter=i,this.minFilter=i,this.mipmapFilter=i}get scaleMode(){return this.magFilter}set maxAnisotropy(i){this._maxAnisotropy=Math.min(i,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const i=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=function createResourceIdFromString(i){const l=ct[i];return void 0===l&&(ct[i]=uid("resource")),l}(i),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};pt.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ft=pt;const mt=class _TextureSource extends V{constructor(i={}){super(),this.options=i,this.uid=uid("textureSource"),this._resourceType="textureSource",this._resourceId=uid("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.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,i={..._TextureSource.defaultOptions,...i},this.label=i.label??"",this.resource=i.resource,this.autoGarbageCollect=i.autoGarbageCollect,this._resolution=i.resolution,i.width?this.pixelWidth=i.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,i.height?this.pixelHeight=i.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=i.format,this.dimension=i.dimensions,this.mipLevelCount=i.mipLevelCount,this.autoGenerateMipmaps=i.autoGenerateMipmaps,this.sampleCount=i.sampleCount,this.antialias=i.antialias,this.alphaMode=i.alphaMode,this.style=new ft(function definedProps(i){const l={};for(const p in i)void 0!==i[p]&&(l[p]=i[p]);return l}(i)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(i){this.style!==i&&(this._style?.off("change",this._onStyleChange,this),this._style=i,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(i){this._style.addressMode=i}get repeatMode(){return this._style.addressMode}set repeatMode(i){this._style.addressMode=i}get magFilter(){return this._style.magFilter}set magFilter(i){this._style.magFilter=i}get minFilter(){return this._style.minFilter}set minFilter(i){this._style.minFilter=i}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(i){this._style.mipmapFilter=i}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(i){this._style.lodMinClamp=i}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(i){this._style.lodMaxClamp=i}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const i=this._resolution;if(this.resize(this.resourceWidth/i,this.resourceHeight/i))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=uid("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:i}=this;return i.naturalWidth||i.videoWidth||i.displayWidth||i.width}get resourceHeight(){const{resource:i}=this;return i.naturalHeight||i.videoHeight||i.displayHeight||i.height}get resolution(){return this._resolution}set resolution(i){this._resolution!==i&&(this._resolution=i,this.width=this.pixelWidth/i,this.height=this.pixelHeight/i)}resize(i,l,p){p=p||this._resolution,i=i||this.width,l=l||this.height;const m=Math.round(i*p),_=Math.round(l*p);return this.width=m/p,this.height=_/p,this._resolution=p,(this.pixelWidth!==m||this.pixelHeight!==_)&&(this._refreshPOT(),this.pixelWidth=m,this.pixelHeight=_,this.emit("resize",this),this._resourceId=uid("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(i){this._style.wrapMode=i}get wrapMode(){return this._style.wrapMode}set scaleMode(i){this._style.scaleMode=i}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=isPow2(this.pixelWidth)&&isPow2(this.pixelHeight)}static test(i){throw new Error("Unimplemented")}};mt.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let gt=mt;class BufferImageSource extends gt{constructor(i){const l=i.resource||new Float32Array(i.width*i.height*4);let p=i.format;p||(p=l instanceof Float32Array?"rgba32float":l instanceof Int32Array||l instanceof Uint32Array?"rgba32uint":l instanceof Int16Array||l instanceof Uint16Array?"rgba16uint":(Int8Array,"bgra8unorm")),super({...i,resource:l,format:p}),this.uploadMethodId="buffer"}static test(i){return i instanceof Int8Array||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int16Array||i instanceof Uint16Array||i instanceof Int32Array||i instanceof Uint32Array||i instanceof Float32Array}}BufferImageSource.extension=O.TextureSource;const _t=new Matrix;class TextureMatrix{constructor(i,l){this.mapCoord=new Matrix,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===l?i.width<10?0:.5:l,this.isSimple=!1,this.texture=i}get texture(){return this._texture}set texture(i){this.texture!==i&&(this._texture?.removeListener("update",this.update,this),this._texture=i,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(i,l){void 0===l&&(l=i);const p=this.mapCoord;for(let m=0;m<i.length;m+=2){const _=i[m],y=i[m+1];l[m]=_*p.a+y*p.c+p.tx,l[m+1]=_*p.b+y*p.d+p.ty}return l}update(){const i=this._texture;this._updateID++;const l=i.uvs;this.mapCoord.set(l.x1-l.x0,l.y1-l.y0,l.x3-l.x0,l.y3-l.y0,l.x0,l.y0);const p=i.orig,m=i.trim;m&&(_t.set(p.width/m.width,0,0,p.height/m.height,-m.x/m.width,-m.y/m.height),this.mapCoord.append(_t));const _=i.source,y=this.uClampFrame,x=this.clampMargin/_._resolution,v=this.clampOffset/_._resolution;return y[0]=(i.frame.x+x+v)/_.width,y[1]=(i.frame.y+x+v)/_.height,y[2]=(i.frame.x+i.frame.width-x+v)/_.width,y[3]=(i.frame.y+i.frame.height-x+v)/_.height,this.uClampOffset[0]=this.clampOffset/_.pixelWidth,this.uClampOffset[1]=this.clampOffset/_.pixelHeight,this.isSimple=i.frame.width===_.width&&i.frame.height===_.height&&0===i.rotate,!0}}class Texture extends V{constructor({source:i,label:l,frame:p,orig:m,trim:_,defaultAnchor:y,defaultBorders:x,rotate:v,dynamic:T}={}){if(super(),this.uid=uid("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Rectangle,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=l,this.source=i?.source??new gt,this.noFrame=!p,p)this.frame.copyFrom(p);else{const{width:i,height:l}=this._source;this.frame.width=i,this.frame.height=l}this.orig=m||this.frame,this.trim=_,this.rotate=v??0,this.defaultAnchor=y,this.defaultBorders=x,this.destroyed=!1,this.dynamic=T||!1,this.updateUvs()}set source(i){this._source&&this._source.off("resize",this.update,this),this._source=i,i.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new TextureMatrix(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:i,frame:l}=this,{width:p,height:m}=this._source,_=l.x/p,y=l.y/m,x=l.width/p,v=l.height/m;let T=this.rotate;if(T){const l=x/2,p=v/2,m=_+l,S=y+p;T=at.add(T,at.NW),i.x0=m+l*at.uX(T),i.y0=S+p*at.uY(T),T=at.add(T,2),i.x1=m+l*at.uX(T),i.y1=S+p*at.uY(T),T=at.add(T,2),i.x2=m+l*at.uX(T),i.y2=S+p*at.uY(T),T=at.add(T,2),i.x3=m+l*at.uX(T),i.y3=S+p*at.uY(T)}else i.x0=_,i.y0=y,i.x1=_+x,i.y1=y,i.x2=_+x,i.y2=y+v,i.x3=_,i.y3=y+v}destroy(i=!1){this._source&&i&&(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 deprecation(ut,"Texture.baseTexture is now Texture.source"),this._source}}function updateQuadBounds(i,l,p,m){const{width:_,height:y}=p.orig,x=p.trim;if(x){const p=x.width,v=x.height;i.minX=x.x-l._x*_-m,i.maxX=i.minX+p,i.minY=x.y-l._y*y-m,i.maxY=i.minY+v}else i.minX=-l._x*_-m,i.maxX=i.minX+_,i.minY=-l._y*y-m,i.maxY=i.minY+y}Texture.EMPTY=new Texture({label:"EMPTY",source:new gt({label:"EMPTY"})}),Texture.EMPTY.destroy=NOOP,Texture.WHITE=new Texture({source:new BufferImageSource({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),Texture.WHITE.destroy=NOOP;const yt=new Matrix;class Bounds{constructor(i=1/0,l=1/0,p=-1/0,m=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=yt,this.minX=i,this.minY=l,this.maxX=p,this.maxY=m}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Rectangle);const i=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(i.x=0,i.y=0,i.width=0,i.height=0):i.copyFromBounds(this),i}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=yt,this}set(i,l,p,m){this.minX=i,this.minY=l,this.maxX=p,this.maxY=m}addFrame(i,l,p,m,_){_||(_=this.matrix);const y=_.a,x=_.b,v=_.c,T=_.d,S=_.tx,P=_.ty;let C=this.minX,E=this.minY,A=this.maxX,k=this.maxY,B=y*i+v*l+S,F=x*i+T*l+P;B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),B=y*p+v*l+S,F=x*p+T*l+P,B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),B=y*i+v*m+S,F=x*i+T*m+P,B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),B=y*p+v*m+S,F=x*p+T*m+P,B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),this.minX=C,this.minY=E,this.maxX=A,this.maxY=k}addRect(i,l){this.addFrame(i.x,i.y,i.x+i.width,i.y+i.height,l)}addBounds(i,l){this.addFrame(i.minX,i.minY,i.maxX,i.maxY,l)}addBoundsMask(i){this.minX=this.minX>i.minX?this.minX:i.minX,this.minY=this.minY>i.minY?this.minY:i.minY,this.maxX=this.maxX<i.maxX?this.maxX:i.maxX,this.maxY=this.maxY<i.maxY?this.maxY:i.maxY}applyMatrix(i){const l=this.minX,p=this.minY,m=this.maxX,_=this.maxY,{a:y,b:x,c:v,d:T,tx:S,ty:P}=i;let C=y*l+v*p+S,E=x*l+T*p+P;this.minX=C,this.minY=E,this.maxX=C,this.maxY=E,C=y*m+v*p+S,E=x*m+T*p+P,this.minX=C<this.minX?C:this.minX,this.minY=E<this.minY?E:this.minY,this.maxX=C>this.maxX?C:this.maxX,this.maxY=E>this.maxY?E:this.maxY,C=y*l+v*_+S,E=x*l+T*_+P,this.minX=C<this.minX?C:this.minX,this.minY=E<this.minY?E:this.minY,this.maxX=C>this.maxX?C:this.maxX,this.maxY=E>this.maxY?E:this.maxY,C=y*m+v*_+S,E=x*m+T*_+P,this.minX=C<this.minX?C:this.minX,this.minY=E<this.minY?E:this.minY,this.maxX=C>this.maxX?C:this.maxX,this.maxY=E>this.maxY?E:this.maxY}fit(i){return this.minX<i.left&&(this.minX=i.left),this.maxX>i.right&&(this.maxX=i.right),this.minY<i.top&&(this.minY=i.top),this.maxY>i.bottom&&(this.maxY=i.bottom),this}fitBounds(i,l,p,m){return this.minX<i&&(this.minX=i),this.maxX>l&&(this.maxX=l),this.minY<p&&(this.minY=p),this.maxY>m&&(this.maxY=m),this}pad(i,l=i){return this.minX-=i,this.maxX+=i,this.minY-=l,this.maxY+=l,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 Bounds(this.minX,this.minY,this.maxX,this.maxY)}scale(i,l=i){return this.minX*=i,this.minY*=l,this.maxX*=i,this.maxY*=l,this}get x(){return this.minX}set x(i){const l=this.maxX-this.minX;this.minX=i,this.maxX=i+l}get y(){return this.minY}set y(i){const l=this.maxY-this.minY;this.minY=i,this.maxY=i+l}get width(){return this.maxX-this.minX}set width(i){this.maxX=this.minX+i}get height(){return this.maxY-this.minY}set height(i){this.maxY=this.minY+i}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(i,l,p,m){let _=this.minX,y=this.minY,x=this.maxX,v=this.maxY;m||(m=this.matrix);const T=m.a,S=m.b,P=m.c,C=m.d,E=m.tx,A=m.ty;for(let m=l;m<p;m+=2){const l=i[m],p=i[m+1],k=T*l+P*p+E,B=S*l+C*p+A;_=k<_?k:_,y=B<y?B:y,x=k>x?k:x,v=B>v?B:v}this.minX=_,this.minY=y,this.maxX=x,this.maxY=v}containsPoint(i,l){return this.minX<=i&&this.minY<=l&&this.maxX>=i&&this.maxY>=l}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}var xt={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(i){return"string"==typeof i?i.length>0:"number"==typeof i},n=function(i,l,p){return void 0===l&&(l=0),void 0===p&&(p=Math.pow(10,l)),Math.round(p*i)/p+0},e=function(i,l,p){return void 0===l&&(l=0),void 0===p&&(p=1),i>p?p:i>l?i:l},u=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},a=function(i){return{r:e(i.r,0,255),g:e(i.g,0,255),b:e(i.b,0,255),a:e(i.a)}},o=function(i){return{r:n(i.r),g:n(i.g),b:n(i.b),a:n(i.a,3)}},vt=/^#([0-9a-f]{3,8})$/i,s=function(i){var l=i.toString(16);return l.length<2?"0"+l:l},h=function(i){var l=i.r,p=i.g,m=i.b,_=i.a,y=Math.max(l,p,m),x=y-Math.min(l,p,m),v=x?y===l?(p-m)/x:y===p?2+(m-l)/x:4+(l-p)/x:0;return{h:60*(v<0?v+6:v),s:y?x/y*100:0,v:y/255*100,a:_}},b=function(i){var l=i.h,p=i.s,m=i.v,_=i.a;l=l/360*6,p/=100,m/=100;var y=Math.floor(l),x=m*(1-p),v=m*(1-(l-y)*p),T=m*(1-(1-l+y)*p),S=y%6;return{r:255*[m,v,x,x,T,m][S],g:255*[T,m,m,v,x,x][S],b:255*[x,x,T,m,m,v][S],a:_}},g=function(i){return{h:u(i.h),s:e(i.s,0,100),l:e(i.l,0,100),a:e(i.a)}},d=function(i){return{h:n(i.h),s:n(i.s),l:n(i.l),a:n(i.a,3)}},f=function(i){return b((p=(l=i).s,{h:l.h,s:(p*=((m=l.l)<50?m:100-m)/100)>0?2*p/(m+p)*100:0,v:m+p,a:l.a}));var l,p,m},c=function(i){return{h:(l=h(i)).h,s:(_=(200-(p=l.s))*(m=l.v)/100)>0&&_<200?p*m/100/(_<=100?_:200-_)*100:0,l:_/2,a:l.a};var l,p,m,_},bt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Tt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,St=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pt={string:[[function(i){var l=vt.exec(i);return l?(i=l[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:4===i.length?n(parseInt(i[3]+i[3],16)/255,2):1}:6===i.length||8===i.length?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:8===i.length?n(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var l=Tt.exec(i)||St.exec(i);return l?l[2]!==l[4]||l[4]!==l[6]?null:a({r:Number(l[1])/(l[2]?100/255:1),g:Number(l[3])/(l[4]?100/255:1),b:Number(l[5])/(l[6]?100/255:1),a:void 0===l[7]?1:Number(l[7])/(l[8]?100:1)}):null},"rgb"],[function(i){var l=bt.exec(i)||wt.exec(i);if(!l)return null;var p,m,_=g({h:(p=l[1],m=l[2],void 0===m&&(m="deg"),Number(p)*(xt[m]||1)),s:Number(l[3]),l:Number(l[4]),a:void 0===l[5]?1:Number(l[5])/(l[6]?100:1)});return f(_)},"hsl"]],object:[[function(i){var l=i.r,p=i.g,m=i.b,_=i.a,y=void 0===_?1:_;return t(l)&&t(p)&&t(m)?a({r:Number(l),g:Number(p),b:Number(m),a:Number(y)}):null},"rgb"],[function(i){var l=i.h,p=i.s,m=i.l,_=i.a,y=void 0===_?1:_;if(!t(l)||!t(p)||!t(m))return null;var x=g({h:Number(l),s:Number(p),l:Number(m),a:Number(y)});return f(x)},"hsl"],[function(i){var l=i.h,p=i.s,m=i.v,_=i.a,y=void 0===_?1:_;if(!t(l)||!t(p)||!t(m))return null;var x=function(i){return{h:u(i.h),s:e(i.s,0,100),v:e(i.v,0,100),a:e(i.a)}}({h:Number(l),s:Number(p),v:Number(m),a:Number(y)});return b(x)},"hsv"]]},N=function(i,l){for(var p=0;p<l.length;p++){var m=l[p][0](i);if(m)return[m,l[p][1]]}return[null,void 0]},M=function(i,l){var p=c(i);return{h:p.h,s:e(p.s+100*l,0,100),l:p.l,a:p.a}},H=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},$=function(i,l){var p=c(i);return{h:p.h,s:p.s,l:e(p.l+100*l,0,100),a:p.a}},Mt=function(){function r(i){this.parsed=function(i){return"string"==typeof i?N(i.trim(),Pt.string):"object"==typeof i&&null!==i?N(i,Pt.object):[null,void 0]}(i)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return l=(i=o(this.rgba)).r,p=i.g,m=i.b,y=(_=i.a)<1?s(n(255*_)):"","#"+s(l)+s(p)+s(m)+y;var i,l,p,m,_,y},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return l=(i=o(this.rgba)).r,p=i.g,m=i.b,(_=i.a)<1?"rgba("+l+", "+p+", "+m+", "+_+")":"rgb("+l+", "+p+", "+m+")";var i,l,p,m,_},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return l=(i=d(c(this.rgba))).h,p=i.s,m=i.l,(_=i.a)<1?"hsla("+l+", "+p+"%, "+m+"%, "+_+")":"hsl("+l+", "+p+"%, "+m+"%)";var i,l,p,m,_},r.prototype.toHsv=function(){return i=h(this.rgba),{h:n(i.h),s:n(i.s),v:n(i.v),a:n(i.a,3)};var i},r.prototype.invert=function(){return w({r:255-(i=this.rgba).r,g:255-i.g,b:255-i.b,a:i.a});var i},r.prototype.saturate=function(i){return void 0===i&&(i=.1),w(M(this.rgba,i))},r.prototype.desaturate=function(i){return void 0===i&&(i=.1),w(M(this.rgba,-i))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(i){return void 0===i&&(i=.1),w($(this.rgba,i))},r.prototype.darken=function(i){return void 0===i&&(i=.1),w($(this.rgba,-i))},r.prototype.rotate=function(i){return void 0===i&&(i=15),this.hue(this.hue()+i)},r.prototype.alpha=function(i){return"number"==typeof i?w({r:(l=this.rgba).r,g:l.g,b:l.b,a:i}):n(this.rgba.a,3);var l},r.prototype.hue=function(i){var l=c(this.rgba);return"number"==typeof i?w({h:i,s:l.s,l:l.l,a:l.a}):n(l.h)},r.prototype.isEqual=function(i){return this.toHex()===w(i).toHex()},r}(),w=function(i){return i instanceof Mt?i:new Mt(i)},Ct=[];!function(i){i.forEach((function(i){Ct.indexOf(i)<0&&(i(Mt,Pt),Ct.push(i))}))}([function namesPlugin(i,l){var p={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"},m={};for(var _ in p)m[p[_]]=_;var y={};i.prototype.toName=function(l){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var _,x,v=m[this.toHex()];if(v)return v;if(null==l?void 0:l.closest){var T=this.toRgb(),S=1/0,P="black";if(!y.length)for(var C in p)y[C]=new i(p[C]).toRgb();for(var E in p){var A=(_=T,x=y[E],Math.pow(_.r-x.r,2)+Math.pow(_.g-x.g,2)+Math.pow(_.b-x.b,2));A<S&&(S=A,P=E)}return P}},l.string.push([function(l){var m=l.toLowerCase(),_="transparent"===m?"#0000":p[m];return _?new i(_).toRgb():null},"name"])}]);const Et=class _Color{constructor(i=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=i}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(i){return this.value=i,this}set value(i){if(i instanceof _Color)this._value=this._cloneSource(i._value),this._int=i._int,this._components.set(i._components);else{if(null===i)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,i)||(this._value=this._cloneSource(i),this._normalize(this._value))}}get value(){return this._value}_cloneSource(i){return"string"==typeof i||"number"==typeof i||i instanceof Number||null===i?i:Array.isArray(i)||ArrayBuffer.isView(i)?i.slice(0):"object"==typeof i&&null!==i?{...i}:i}_isSourceEqual(i,l){const p=typeof i;if(p!==typeof l)return!1;if("number"===p||"string"===p||i instanceof Number)return i===l;if(Array.isArray(i)&&Array.isArray(l)||ArrayBuffer.isView(i)&&ArrayBuffer.isView(l))return i.length===l.length&&i.every(((i,p)=>i===l[p]));if(null!==i&&null!==l){const p=Object.keys(i),m=Object.keys(l);return p.length===m.length&&p.every((p=>i[p]===l[p]))}return i===l}toRgba(){const[i,l,p,m]=this._components;return{r:i,g:l,b:p,a:m}}toRgb(){const[i,l,p]=this._components;return{r:i,g:l,b:p}}toRgbaString(){const[i,l,p]=this.toUint8RgbArray();return`rgba(${i},${l},${p},${this.alpha})`}toUint8RgbArray(i){const[l,p,m]=this._components;return this._arrayRgb||(this._arrayRgb=[]),(i=i||this._arrayRgb)[0]=Math.round(255*l),i[1]=Math.round(255*p),i[2]=Math.round(255*m),i}toArray(i){this._arrayRgba||(this._arrayRgba=[]),i=i||this._arrayRgba;const[l,p,m,_]=this._components;return i[0]=l,i[1]=p,i[2]=m,i[3]=_,i}toRgbArray(i){this._arrayRgb||(this._arrayRgb=[]),i=i||this._arrayRgb;const[l,p,m]=this._components;return i[0]=l,i[1]=p,i[2]=m,i}toNumber(){return this._int}toBgrNumber(){const[i,l,p]=this.toUint8RgbArray();return(p<<16)+(l<<8)+i}toLittleEndianNumber(){const i=this._int;return(i>>16)+(65280&i)+((255&i)<<16)}multiply(i){const[l,p,m,_]=_Color._temp.setValue(i)._components;return this._components[0]*=l,this._components[1]*=p,this._components[2]*=m,this._components[3]*=_,this._refreshInt(),this._value=null,this}premultiply(i,l=!0){return l&&(this._components[0]*=i,this._components[1]*=i,this._components[2]*=i),this._components[3]=i,this._refreshInt(),this._value=null,this}toPremultiplied(i,l=!0){if(1===i)return(255<<24)+this._int;if(0===i)return l?0:this._int;let p=this._int>>16&255,m=this._int>>8&255,_=255&this._int;return l&&(p=p*i+.5|0,m=m*i+.5|0,_=_*i+.5|0),(255*i<<24)+(p<<16)+(m<<8)+_}toHex(){const i=this._int.toString(16);return`#${"000000".substring(0,6-i.length)+i}`}toHexa(){const i=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-i.length)+i}setAlpha(i){return this._components[3]=this._clamp(i),this}_normalize(i){let l,p,m,_;if(("number"==typeof i||i instanceof Number)&&i>=0&&i<=16777215){l=(i>>16&255)/255,p=(i>>8&255)/255,m=(255&i)/255,_=1}else if((Array.isArray(i)||i instanceof Float32Array)&&i.length>=3&&i.length<=4)i=this._clamp(i),[l,p,m,_=1]=i;else if((i instanceof Uint8Array||i instanceof Uint8ClampedArray)&&i.length>=3&&i.length<=4)i=this._clamp(i,0,255),[l,p,m,_=255]=i,l/=255,p/=255,m/=255,_/=255;else if("string"==typeof i||"object"==typeof i){if("string"==typeof i){const l=_Color.HEX_PATTERN.exec(i);l&&(i=`#${l[2]}`)}const y=w(i);y.isValid()&&(({r:l,g:p,b:m,a:_}=y.rgba),l/=255,p/=255,m/=255)}if(void 0===l)throw new Error(`Unable to convert color ${i}`);this._components[0]=l,this._components[1]=p,this._components[2]=m,this._components[3]=_,this._refreshInt()}_refreshInt(){this._clamp(this._components);const[i,l,p]=this._components;this._int=(255*i<<16)+(255*l<<8)+(255*p|0)}_clamp(i,l=0,p=1){return"number"==typeof i?Math.min(Math.max(i,l),p):(i.forEach(((m,_)=>{i[_]=Math.min(Math.max(m,l),p)})),i)}static isColorLike(i){return"number"==typeof i||"string"==typeof i||i instanceof Number||i instanceof _Color||Array.isArray(i)||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Float32Array||void 0!==i.r&&void 0!==i.g&&void 0!==i.b||void 0!==i.r&&void 0!==i.g&&void 0!==i.b&&void 0!==i.a||void 0!==i.h&&void 0!==i.s&&void 0!==i.l||void 0!==i.h&&void 0!==i.s&&void 0!==i.l&&void 0!==i.a||void 0!==i.h&&void 0!==i.s&&void 0!==i.v||void 0!==i.h&&void 0!==i.s&&void 0!==i.v&&void 0!==i.a}};Et.shared=new Et,Et._temp=new Et,Et.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let At=Et;class Pool{constructor(i,l){this._pool=[],this._count=0,this._index=0,this._classType=i,l&&this.prepopulate(l)}prepopulate(i){for(let l=0;l<i;l++)this._pool[this._index++]=new this._classType;this._count+=i}get(i){let l;return l=this._index>0?this._pool[--this._index]:new this._classType,l.init?.(i),l}return(i){i.reset?.(),this._pool[this._index++]=i}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}const kt=new class PoolGroupClass{constructor(){this._poolsByClass=new Map}prepopulate(i,l){this.getPool(i).prepopulate(l)}get(i,l){return this.getPool(i).get(l)}return(i){this.getPool(i.constructor).return(i)}getPool(i){return this._poolsByClass.has(i)||this._poolsByClass.set(i,new Pool(i)),this._poolsByClass.get(i)}stats(){const i={};return this._poolsByClass.forEach((l=>{const p=i[l._classType.name]?l._classType.name+l._classType.ID:l._classType.name;i[p]={free:l.totalFree,used:l.totalUsed,size:l.totalSize}})),i}};function removeItems(i,l,p){const m=i.length;let _;if(l>=m||0===p)return;const y=m-(p=l+p>m?m-l:p);for(_=l;_<y;++_)i[_]=i[_+p];i.length=y}const Bt={allowChildren:!0,removeChildren(i=0,l){const p=l??this.children.length,m=p-i,_=[];if(m>0&&m<=p){for(let l=p-1;l>=i;l--){const i=this.children[l];i&&(_.push(i),i.parent=null)}removeItems(this.children,i,p);const l=this.renderGroup||this.parentRenderGroup;l&&l.removeChildren(_);for(let i=0;i<_.length;++i)this.emit("childRemoved",_[i],this,i),_[i].emit("removed",this);return _}if(0===m&&0===this.children.length)return _;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const l=this.getChildAt(i);return this.removeChild(l)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,l){if(l<0||l>=this.children.length)throw new Error(`The index ${l} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,l)},getChildIndex(i){const l=this.children.indexOf(i);if(-1===l)throw new Error("The supplied Container must be a child of the caller");return l},addChildAt(i,l){this.allowChildren||deprecation(ut,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:p}=this;if(l<0||l>p.length)throw new Error(`${i}addChildAt: The index ${l} supplied is out of bounds ${p.length}`);if(i.parent){const p=i.parent.children.indexOf(i);if(i.parent===this&&p===l)return i;-1!==p&&i.parent.children.splice(p,1)}l===p.length?p.push(i):p.splice(l,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const m=this.renderGroup||this.parentRenderGroup;return m&&m.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,l),i.emit("added",this),i},swapChildren(i,l){if(i===l)return;const p=this.getChildIndex(i),m=this.getChildIndex(l);this.children[p]=l,this.children[m]=i;const _=this.renderGroup||this.parentRenderGroup;_&&(_.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...i){return 1===i.length?this.reparentChildAt(i[0],this.children.length):(i.forEach((i=>this.reparentChildAt(i,this.children.length))),i[0])},reparentChildAt(i,l){if(i.parent===this)return this.setChildIndex(i,l),i;const p=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,l);const m=this.worldTransform.clone();return m.invert(),p.prepend(m),i.setFromMatrix(p),i}};class FilterEffect{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let i=0;i<this.filters.length;i++)this.filters[i].destroy();this.filters=null,this.filterArea=null}}const Ft=new class MaskEffectManagerClass{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach((i=>{this.add({test:i.test,maskClass:i})})))}add(i){this._tests.push(i)}getMaskEffect(i){this._initialized||this.init();for(let l=0;l<this._tests.length;l++){const p=this._tests[l];if(p.test(i))return kt.get(p.maskClass,i)}return i}returnMaskEffect(i){kt.return(i)}};z.handleByList(O.MaskEffect,Ft._effectClasses);const Rt={_maskEffect:null,_filterEffect:null,effects:[],addEffect(i){if(-1!==this.effects.indexOf(i))return;this.effects.push(i),this.effects.sort(((i,l)=>i.priority-l.priority));const l=this.renderGroup||this.parentRenderGroup;l&&(l.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const l=this.effects.indexOf(i);-1!==l&&(this.effects.splice(l,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const l=this._maskEffect;l?.mask!==i&&(l&&(this.removeEffect(l),Ft.returnMaskEffect(l),this._maskEffect=null),null!=i&&(this._maskEffect=Ft.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},set filters(i){!Array.isArray(i)&&i&&(i=[i]);const l=this._filterEffect||(this._filterEffect=new FilterEffect),p=i?.length>0,m=p!==l.filters?.length>0;i=Array.isArray(i)?i.slice(0):i,l.filters=Object.freeze(i),m&&(p?this.addEffect(l):(this.removeEffect(l),l.filters=i??null))},get filters(){return this._filterEffect?.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new FilterEffect),this._filterEffect.filterArea=i},get filterArea(){return this._filterEffect?.filterArea}},It={label:null,get name(){return deprecation(ut,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){deprecation(ut,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,l=!1){return this.getChildByLabel(i,l)},getChildByLabel(i,l=!1){const p=this.children;for(let l=0;l<p.length;l++){const m=p[l];if(m.label===i||i instanceof RegExp&&i.test(m.label))return m}if(l)for(let l=0;l<p.length;l++){const m=p[l].getChildByLabel(i,!0);if(m)return m}return null},getChildrenByLabel(i,l=!1,p=[]){const m=this.children;for(let l=0;l<m.length;l++){const _=m[l];(_.label===i||i instanceof RegExp&&i.test(_.label))&&p.push(_)}if(l)for(let l=0;l<m.length;l++)m[l].getChildrenByLabel(i,!0,p);return p}},Dt=new Pool(Matrix),Lt=new Pool(Bounds);function getGlobalBounds(i,l,p){let m,_;return p.clear(),i.parent?l?m=i.parent.worldTransform:(_=Dt.get().identity(),m=updateTransformBackwards(i,_)):m=Matrix.IDENTITY,_getGlobalBounds(i,p,m,l),_&&Dt.return(_),p.isValid||p.set(0,0,0,0),p}function _getGlobalBounds(i,l,p,m){if(!i.visible||!i.measurable)return;let _;m?_=i.worldTransform:(i.updateLocalTransform(),_=Dt.get(),_.appendFrom(i.localTransform,p));const y=l,x=!!i.effects.length;if(x&&(l=Lt.get().clear()),i.boundsArea)l.addRect(i.boundsArea,_);else{i.addBounds&&(l.matrix=_,i.addBounds(l));for(let p=0;p<i.children.length;p++)_getGlobalBounds(i.children[p],l,_,m)}if(x){for(let p=0;p<i.effects.length;p++)i.effects[p].addBounds?.(l);y.addBounds(l,Matrix.IDENTITY),Lt.return(l)}m||Dt.return(_)}function updateTransformBackwards(i,l){const p=i.parent;return p&&(updateTransformBackwards(p,l),p.updateLocalTransform(),l.append(p.localTransform)),l}let Ut=0;const Gt=500;function warn(...i){Ut!==Gt&&(Ut++,Ut===Gt?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}function getLocalBounds(i,l,p){return l.clear(),p||(p=Matrix.IDENTITY),_getLocalBounds(i,l,p,i,!0),l.isValid||l.set(0,0,0,0),l}function _getLocalBounds(i,l,p,m,_){let y;if(_)y=Dt.get(),y=p.copyTo(y);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const l=i.localTransform;y=Dt.get(),y.appendFrom(l,p)}const x=l,v=!!i.effects.length;if(v&&(l=Lt.get().clear()),i.boundsArea)l.addRect(i.boundsArea,y);else{i.renderPipeId&&(l.matrix=y,i.addBounds(l));const p=i.children;for(let i=0;i<p.length;i++)_getLocalBounds(p[i],l,y,m,!1)}if(v){for(let p=0;p<i.effects.length;p++)i.effects[p].addLocalBounds?.(l,m);x.addBounds(l,Matrix.IDENTITY),Lt.return(l)}Dt.return(y)}function checkChildrenDidChange(i,l){const p=i.children;for(let i=0;i<p.length;i++){const m=p[i],_=m.uid,y=(65535&m._didViewChangeTick)<<16|65535&m._didContainerChangeTick,x=l.index;l.data[x]===_&&l.data[x+1]===y||(l.data[l.index]=_,l.data[l.index+1]=y,l.didChange=!0),l.index=x+2,m.children.length&&checkChildrenDidChange(m,l)}return l.didChange}const Ot=new Matrix,zt={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,l){const p=Math.sign(this.scale.x)||1;this.scale.x=0!==l?i/l*p:p},_setHeight(i,l){const p=Math.sign(this.scale.y)||1;this.scale.y=0!==l?i/l*p:p},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Bounds});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),checkChildrenDidChange(this,i),i.didChange&&getLocalBounds(this,i.localBounds,Ot),i.localBounds},getBounds(i,l){return getGlobalBounds(this,i,l||new Bounds)}},Nt={_onRender:null,set onRender(i){const l=this.renderGroup||this.parentRenderGroup;if(!i)return this._onRender&&l?.removeOnRender(this),void(this._onRender=null);this._onRender||l?.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},Ht={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,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(sortChildren))}};function sortChildren(i,l){return i._zIndex-l._zIndex}const Wt={getGlobalPosition(i=new Point,l=!1){return this.parent?this.parent.toGlobal(this._position,i,l):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,l,p=!1){if(!p){this.updateLocalTransform();const p=updateTransformBackwards(this,new Matrix);return p.append(this.localTransform),p.apply(i,l)}return this.worldTransform.apply(i,l)},toLocal(i,l,p,m){if(l&&(i=l.toGlobal(i,p,m)),!m){this.updateLocalTransform();const l=updateTransformBackwards(this,new Matrix);return l.append(this.localTransform),l.applyInverse(i,p)}return this.worldTransform.applyInverse(i,p)}};let Kt=0;class InstructionSet{constructor(){this.uid=uid("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.tick=0}reset(){this.instructionSize=0,this.tick=Kt++}add(i){this.instructions[this.instructionSize++]=i}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class RenderGroup{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new Matrix,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new InstructionSet,this._onRenderContainers=[]}init(i){this.root=i,i._onRender&&this.addOnRender(i),i.didChange=!0;const l=i.children;for(let i=0;i<l.length;i++)this.addChild(l[i])}reset(){this.renderGroupChildren.length=0;for(const i in this.childrenToUpdate){const l=this.childrenToUpdate[i];l.list.fill(null),l.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}get localTransform(){return this.root.localTransform}addRenderGroupChild(i){i.renderGroupParent&&i.renderGroupParent._removeRenderGroupChild(i),i.renderGroupParent=this,this.renderGroupChildren.push(i)}_removeRenderGroupChild(i){const l=this.renderGroupChildren.indexOf(i);l>-1&&this.renderGroupChildren.splice(l,1),i.renderGroupParent=null}addChild(i){if(this.structureDidChange=!0,i.parentRenderGroup=this,i.updateTick=-1,i.parent===this.root?i.relativeRenderGroupDepth=1:i.relativeRenderGroupDepth=i.parent.relativeRenderGroupDepth+1,i.didChange=!0,this.onChildUpdate(i),i.renderGroup)return void this.addRenderGroupChild(i.renderGroup);i._onRender&&this.addOnRender(i);const l=i.children;for(let i=0;i<l.length;i++)this.addChild(l[i])}removeChild(i){if(this.structureDidChange=!0,i._onRender&&(i.renderGroup||this.removeOnRender(i)),i.parentRenderGroup=null,i.renderGroup)return void this._removeRenderGroupChild(i.renderGroup);const l=i.children;for(let i=0;i<l.length;i++)this.removeChild(l[i])}removeChildren(i){for(let l=0;l<i.length;l++)this.removeChild(i[l])}onChildUpdate(i){let l=this.childrenToUpdate[i.relativeRenderGroupDepth];l||(l=this.childrenToUpdate[i.relativeRenderGroupDepth]={index:0,list:[]}),l.list[l.index++]=i}updateRenderable(i){i.globalDisplayStatus<7||(i.didViewUpdate=!1,this.instructionSet.renderPipes[i.renderPipeId].updateRenderable(i))}onChildViewUpdate(i){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=i}get isRenderable(){return 7===this.root.localDisplayStatus&&this.worldAlpha>0}addOnRender(i){this._onRenderContainers.push(i)}removeOnRender(i){this._onRenderContainers.splice(this._onRenderContainers.indexOf(i),1)}runOnRender(){for(let i=0;i<this._onRenderContainers.length;i++)this._onRenderContainers[i]._onRender()}destroy(){this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(i=[]){const l=this.root.children;for(let p=0;p<l.length;p++)this._getChildren(l[p],i);return i}_getChildren(i,l=[]){if(l.push(i),i.renderGroup)return l;const p=i.children;for(let i=0;i<p.length;i++)this._getChildren(p[i],l);return l}}const Yt=new ObservablePoint(null),Vt=new ObservablePoint(null),$t=new ObservablePoint(null,1,1);class Container extends V{constructor(i={}){super(),this.uid=uid("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.updateTick=-1,this.localTransform=new Matrix,this.relativeGroupTransform=new Matrix,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ObservablePoint(this,0,0),this._scale=$t,this._pivot=Vt,this._skew=Yt,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=[],function assignWithIgnore(i,l,p={}){for(const m in l)p[m]||void 0===l[m]||(i[m]=l[m])}(this,i,{children:!0,parent:!0,effects:!0}),i.children?.forEach((i=>this.addChild(i))),i.parent?.addChild(this)}static mixin(i){Object.defineProperties(Container.prototype,Object.getOwnPropertyDescriptors(i))}set _didChangeId(i){this._didViewChangeTick=i>>12&4095,this._didContainerChangeTick=4095&i}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...i){if(this.allowChildren||deprecation(ut,"addChild: Only Containers will be allowed to add children in v8.0.0"),i.length>1){for(let l=0;l<i.length;l++)this.addChild(i[l]);return i[0]}const l=i[0];if(l.parent===this)return this.children.splice(this.children.indexOf(l),1),this.children.push(l),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),l;l.parent&&l.parent.removeChild(l),this.children.push(l),this.sortableChildren&&(this.sortDirty=!0),l.parent=this,l.didChange=!0,l.didViewUpdate=!1,l._updateFlags=15;const p=this.renderGroup||this.parentRenderGroup;return p&&p.addChild(l),this.emit("childAdded",l,this,this.children.length-1),l.emit("added",this),this._didViewChangeTick++,0!==l._zIndex&&l.depthOfChildModified(),l}removeChild(...i){if(i.length>1){for(let l=0;l<i.length;l++)this.removeChild(i[l]);return i[0]}const l=i[0],p=this.children.indexOf(l);return p>-1&&(this._didViewChangeTick++,this.children.splice(p,1),this.renderGroup?this.renderGroup.removeChild(l):this.parentRenderGroup&&this.parentRenderGroup.removeChild(l),l.parent=null,this.emit("childRemoved",l,this,p),l.emit("removed",this)),l}_onUpdate(i){i&&i===this._skew&&this._updateSkew(),this._didContainerChangeTick++,this.didChange||(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(i){!!this.renderGroup!==i&&(i?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const i=this.parentRenderGroup;i?.removeChild(this),this.renderGroup=kt.get(RenderGroup,this),this.groupTransform=Matrix.IDENTITY,i?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const i=this.parentRenderGroup;i?.removeChild(this),kt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,i?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new Matrix),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(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get position(){return this._position}set position(i){this._position.copyFrom(i)}get rotation(){return this._rotation}set rotation(i){this._rotation!==i&&(this._rotation=i,this._onUpdate(this._skew))}get angle(){return this.rotation*j}set angle(i){this.rotation=i*q}get pivot(){return this._pivot===Vt&&(this._pivot=new ObservablePoint(this,0,0)),this._pivot}set pivot(i){this._pivot===Vt&&(this._pivot=new ObservablePoint(this,0,0)),"number"==typeof i?this._pivot.set(i):this._pivot.copyFrom(i)}get skew(){return this._skew===Yt&&(this._skew=new ObservablePoint(this,0,0)),this._skew}set skew(i){this._skew===Yt&&(this._skew=new ObservablePoint(this,0,0)),this._skew.copyFrom(i)}get scale(){return this._scale===$t&&(this._scale=new ObservablePoint(this,1,1)),this._scale}set scale(i){this._scale===$t&&(this._scale=new ObservablePoint(this,0,0)),"number"==typeof i?this._scale.set(i):this._scale.copyFrom(i)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(i){const l=this.getLocalBounds().width;this._setWidth(i,l)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(i){const l=this.getLocalBounds().height;this._setHeight(i,l)}getSize(i){i||(i={});const l=this.getLocalBounds();return i.width=Math.abs(this.scale.x*l.width),i.height=Math.abs(this.scale.y*l.height),i}setSize(i,l){const p=this.getLocalBounds();"object"==typeof i?(l=i.height??i.width,i=i.width):l??(l=i),void 0!==i&&this._setWidth(i,p.width),void 0!==l&&this._setHeight(l,p.height)}_updateSkew(){const i=this._rotation,l=this._skew;this._cx=Math.cos(i+l._y),this._sx=Math.sin(i+l._y),this._cy=-Math.sin(i-l._x),this._sy=Math.cos(i-l._x)}updateTransform(i){return this.position.set("number"==typeof i.x?i.x:this.position.x,"number"==typeof i.y?i.y:this.position.y),this.scale.set("number"==typeof i.scaleX?i.scaleX||1:this.scale.x,"number"==typeof i.scaleY?i.scaleY||1:this.scale.y),this.rotation="number"==typeof i.rotation?i.rotation:this.rotation,this.skew.set("number"==typeof i.skewX?i.skewX:this.skew.x,"number"==typeof i.skewY?i.skewY:this.skew.y),this.pivot.set("number"==typeof i.pivotX?i.pivotX:this.pivot.x,"number"==typeof i.pivotY?i.pivotY:this.pivot.y),this}setFromMatrix(i){i.decompose(this)}updateLocalTransform(){const i=this._didContainerChangeTick;if(this._didLocalTransformChangeId===i)return;this._didLocalTransformChangeId=i;const l=this.localTransform,p=this._scale,m=this._pivot,_=this._position,y=p._x,x=p._y,v=m._x,T=m._y;l.a=this._cx*y,l.b=this._sx*y,l.c=this._cy*x,l.d=this._sy*x,l.tx=_._x-(v*l.a+T*l.c),l.ty=_._y-(v*l.b+T*l.d)}set alpha(i){i!==this.localAlpha&&(this.localAlpha=i,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(i){const l=At.shared.setValue(i??16777215).toBgrNumber();l!==this.localColor&&(this.localColor=l,this._updateFlags|=1,this._onUpdate())}get tint(){const i=this.localColor;return((255&i)<<16)+(65280&i)+(i>>16&255)}set blendMode(i){this.localBlendMode!==i&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=i,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(i){const l=i?2:0;(2&this.localDisplayStatus)!==l&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(i){const l=i?0:4;(4&this.localDisplayStatus)!==l&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(i){const l=i?1:0;(1&this.localDisplayStatus)!==l&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&this.groupAlpha>0}destroy(i=!1){if(this.destroyed)return;this.destroyed=!0;const l=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._skew=null,this.emit("destroyed",this),this.removeAllListeners();if("boolean"==typeof i?i:i?.children)for(let p=0;p<l.length;++p)l[p].destroy(i);this.renderGroup?.destroy(),this.renderGroup=null}}Container.mixin(Bt),Container.mixin(Wt),Container.mixin(Nt),Container.mixin(zt),Container.mixin(Rt),Container.mixin(It),Container.mixin(Ht),Container.mixin({cullArea:null,cullable:!1,cullableChildren:!0});class ViewContainer extends Container{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new Bounds(0,1,0,0),this._boundsDirty=!0}_updateBounds(){}get roundPixels(){return!!this._roundPixels}set roundPixels(i){this._roundPixels=i?1:0}containsPoint(i){const l=this.bounds,{x:p,y:m}=i;return p>=l.minX&&p<=l.maxX&&m>=l.minY&&m<=l.maxY}destroy(i){super.destroy(i),this._bounds=null}}class Sprite extends ViewContainer{constructor(i=Texture.EMPTY){i instanceof Texture&&(i={texture:i});const{texture:l=Texture.EMPTY,anchor:p,roundPixels:m,width:_,height:y,...x}=i;super({label:"Sprite",...x}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new ObservablePoint({_onUpdate:()=>{this.onViewUpdate()}}),p?this.anchor=p:l.defaultAnchor&&(this.anchor=l.defaultAnchor),this.texture=l,this.allowChildren=!1,this.roundPixels=m??!1,void 0!==_&&(this.width=_),void 0!==y&&(this.height=y)}static from(i,l=!1){return new Sprite(i instanceof Texture?i:Texture.from(i,l))}set texture(i){i||(i=Texture.EMPTY);const l=this._texture;l!==i&&(l&&l.dynamic&&l.off("update",this.onViewUpdate,this),i.dynamic&&i.on("update",this.onViewUpdate,this),this._texture=i,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 bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(i){const l=this.sourceBounds;return i.x>=l.maxX&&i.x<=l.minX&&i.y>=l.maxY&&i.y<=l.minY}addBounds(i){const l=this._texture.trim?this.sourceBounds:this.bounds;i.addFrame(l.minX,l.minY,l.maxX,l.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const i=this.renderGroup||this.parentRenderGroup;i&&i.onChildViewUpdate(this)}_updateBounds(){updateQuadBounds(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const i=this._anchor,l=this._texture,p=this._sourceBounds,{width:m,height:_}=l.orig;p.maxX=-i._x*m,p.minX=p.maxX+m,p.maxY=-i._y*_,p.minY=p.maxY+_}destroy(i=!1){super.destroy(i);if("boolean"==typeof i?i:i?.texture){const l="boolean"==typeof i?i:i?.textureSource;this._texture.destroy(l)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(i){"number"==typeof i?this._anchor.set(i):this._anchor.copyFrom(i)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(i){this._setWidth(i,this._texture.orig.width),this._width=i}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(i){this._setHeight(i,this._texture.orig.height),this._height=i}getSize(i){return i||(i={}),i.width=Math.abs(this.scale.x)*this._texture.orig.width,i.height=Math.abs(this.scale.y)*this._texture.orig.height,i}setSize(i,l){"object"==typeof i?(l=i.height??i.width,i=i.width):l??(l=i),void 0!==i&&this._setWidth(i,this._texture.orig.width),void 0!==l&&this._setHeight(l,this._texture.orig.height)}}const Xt=new Bounds;function addMaskBounds(i,l,p){const m=Xt;i.measurable=!0,getGlobalBounds(i,p,m),l.addBoundsMask(m),i.measurable=!1}function addMaskLocalBounds(i,l,p){const m=Lt.get();i.measurable=!0;const _=Dt.get().identity();getLocalBounds(i,m,getMatrixRelativeToParent(i,p,_)),i.measurable=!1,l.addBoundsMask(m),Dt.return(_),Lt.return(m)}function getMatrixRelativeToParent(i,l,p){return i?(i!==l&&(getMatrixRelativeToParent(i.parent,l,p),i.updateLocalTransform(),p.append(i.localTransform)),p):(warn("Mask bounds, renderable is not inside the root container"),p)}class AlphaMask{constructor(i){this.priority=0,this.pipe="alphaMask",i?.mask&&this.init(i.mask)}init(i){this.mask=i,this.renderMaskToTexture=!(i instanceof Sprite),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(i,l){addMaskBounds(this.mask,i,l)}addLocalBounds(i,l){addMaskLocalBounds(this.mask,i,l)}containsPoint(i,l){return l(this.mask,i)}destroy(){this.reset()}static test(i){return i instanceof Sprite}}AlphaMask.extension=O.MaskEffect;class ColorMask{constructor(i){this.priority=0,this.pipe="colorMask",i?.mask&&this.init(i.mask)}init(i){this.mask=i}destroy(){}static test(i){return"number"==typeof i}}ColorMask.extension=O.MaskEffect;class StencilMask{constructor(i){this.priority=0,this.pipe="stencilMask",i?.mask&&this.init(i.mask)}init(i){this.mask=i,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(i,l){addMaskBounds(this.mask,i,l)}addLocalBounds(i,l){addMaskLocalBounds(this.mask,i,l)}containsPoint(i,l){return l(this.mask,i)}destroy(){this.reset()}static test(i){return i instanceof Container}}StencilMask.extension=O.MaskEffect;let jt={createCanvas:(i,l)=>{const p=document.createElement("canvas");return p.width=i,p.height=l,p},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,l)=>fetch(i,l),parseXML:i=>(new DOMParser).parseFromString(i,"text/xml")};const qt={get:()=>jt,set(i){jt=i}};class CanvasSource extends gt{constructor(i){i.resource||(i.resource=qt.get().createCanvas()),i.width||(i.width=i.resource.width,i.autoDensity||(i.width/=i.resolution)),i.height||(i.height=i.resource.height,i.autoDensity||(i.height/=i.resolution)),super(i),this.uploadMethodId="image",this.autoDensity=i.autoDensity;const l=i.resource;this.pixelWidth===l.width&&this.pixelWidth===l.height||this.resizeCanvas(),this.transparent=!!i.transparent}resizeCanvas(){this.autoDensity&&(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(i=this.width,l=this.height,p=this._resolution){const m=super.resize(i,l,p);return m&&this.resizeCanvas(),m}static test(i){return globalThis.HTMLCanvasElement&&i instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&i instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}CanvasSource.extension=O.TextureSource;class ImageSource extends gt{constructor(i){if(i.resource&&globalThis.HTMLImageElement&&i.resource instanceof HTMLImageElement){const l=qt.get().createCanvas(i.resource.width,i.resource.height);l.getContext("2d").drawImage(i.resource,0,0,i.resource.width,i.resource.height),i.resource=l,warn("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(i),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(i){return globalThis.HTMLImageElement&&i instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&i instanceof ImageBitmap||globalThis.VideoFrame&&i instanceof VideoFrame}}ImageSource.extension=O.TextureSource;var Zt=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(Zt||{});class TickerListener{constructor(i,l=null,p=0,m=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=i,this._context=l,this.priority=p,this._once=m}match(i,l=null){return this._fn===i&&this._context===l}emit(i){this._fn&&(this._context?this._fn.call(this._context,i):this._fn(i));const l=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),l}connect(i){this.previous=i,i.next&&(i.next.previous=this),this.next=i.next,i.next=this}destroy(i=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const l=this.next;return this.next=i?null:l,this.previous=null,l}}const Qt=class _Ticker{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 TickerListener(null,null,1/0),this.deltaMS=1/_Ticker.targetFPMS,this.elapsedMS=1/_Ticker.targetFPMS,this._tick=i=>{this._requestId=null,this.started&&(this.update(i),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(i,l,p=Zt.NORMAL){return this._addListener(new TickerListener(i,l,p))}addOnce(i,l,p=Zt.NORMAL){return this._addListener(new TickerListener(i,l,p,!0))}_addListener(i){let l=this._head.next,p=this._head;if(l){for(;l;){if(i.priority>l.priority){i.connect(p);break}p=l,l=l.next}i.previous||i.connect(p)}else i.connect(p);return this._startIfPossible(),this}remove(i,l){let p=this._head.next;for(;p;)p=p.match(i,l)?p.destroy():p.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let i=0,l=this._head;for(;l=l.next;)i++;return i}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let i=this._head.next;for(;i;)i=i.destroy(!0);this._head.destroy(),this._head=null}}update(i=performance.now()){let l;if(i>this.lastTime){if(l=this.elapsedMS=i-this.lastTime,l>this._maxElapsedMS&&(l=this._maxElapsedMS),l*=this.speed,this._minElapsedMS){const l=i-this._lastFrame|0;if(l<this._minElapsedMS)return;this._lastFrame=i-l%this._minElapsedMS}this.deltaMS=l,this.deltaTime=this.deltaMS*_Ticker.targetFPMS;const p=this._head;let m=p.next;for(;m;)m=m.emit(this);p.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=i}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(i){const l=Math.min(this.maxFPS,i),p=Math.min(Math.max(0,l)/1e3,_Ticker.targetFPMS);this._maxElapsedMS=1/p}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(i){if(0===i)this._minElapsedMS=0;else{const l=Math.max(this.minFPS,i);this._minElapsedMS=1/(l/1e3)}}static get shared(){if(!_Ticker._shared){const i=_Ticker._shared=new _Ticker;i.autoStart=!0,i._protected=!0}return _Ticker._shared}static get system(){if(!_Ticker._system){const i=_Ticker._system=new _Ticker;i.autoStart=!0,i._protected=!0}return _Ticker._system}};Qt.targetFPMS=.06;let Jt,te=Qt;const ee=class _VideoSource extends gt{constructor(i){super(i),this.isReady=!1,this.uploadMethodId="video",i={..._VideoSource.defaultOptions,...i},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=i.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==i.autoPlay,this.alphaMode=i.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),!1!==i.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const i=te.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-i)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const i=this.resource,l=this.options;return(i.readyState===i.HAVE_ENOUGH_DATA||i.readyState===i.HAVE_FUTURE_DATA)&&i.width&&i.height&&(i.complete=!0),i.addEventListener("play",this._onPlayStart),i.addEventListener("pause",this._onPlayStop),i.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(l.preload||i.addEventListener("canplay",this._onCanPlay),i.addEventListener("canplaythrough",this._onCanPlayThrough),i.addEventListener("error",this._onError,!0)),this.alphaMode=await async function detectVideoAlphaMode(){return Jt??(Jt=(async()=>{const i=document.createElement("canvas").getContext("webgl");if(!i)return"premultiply-alpha-on-upload";const l=await new Promise((i=>{const l=document.createElement("video");l.onloadeddata=()=>i(l),l.onerror=()=>i(null),l.autoplay=!1,l.crossOrigin="anonymous",l.preload="auto",l.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",l.load()}));if(!l)return"premultiply-alpha-on-upload";const p=i.createTexture();i.bindTexture(i.TEXTURE_2D,p);const m=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,m),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,p,0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,l);const _=new Uint8Array(4);return i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,_),i.deleteFramebuffer(m),i.deleteTexture(p),i.getExtension("WEBGL_lose_context")?.loseContext(),_[0]<=_[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Jt}(),this._load=new Promise(((p,m)=>{this.isValid?p(this):(this._resolve=p,this._reject=m,void 0!==l.preloadTimeoutMs&&(this._preloadTimeout=setTimeout((()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${l.preloadTimeoutMs}ms`))}))),i.load())})),this._load}_onError(i){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",i),this._reject&&(this._reject(i),this._reject=null,this._resolve=null)}_isSourcePlaying(){const i=this.resource;return!i.paused&&!i.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const i=this.resource;this.isValid&&(this.isReady=!0,this.resize(i.videoWidth,i.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const i=this.resource;i&&(i.removeEventListener("play",this._onPlayStart),i.removeEventListener("pause",this._onPlayStop),i.removeEventListener("seeked",this._onSeeked),i.removeEventListener("canplay",this._onCanPlay),i.removeEventListener("canplaythrough",this._onCanPlayThrough),i.removeEventListener("error",this._onError,!0),i.pause(),i.src="",i.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(i){i!==this._autoUpdate&&(this._autoUpdate=i,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(i){i!==this._updateFPS&&(this._updateFPS=i,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(te.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(te.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(te.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(i){return globalThis.HTMLVideoElement&&i instanceof HTMLVideoElement}};ee.extension=O.TextureSource,ee.defaultOptions={...gt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},ee.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ie=ee;const convertToList=(i,l,p=!1)=>(Array.isArray(i)||(i=[i]),l?i.map((i=>"string"==typeof i||p?l(i):i)):i);const se=new class CacheClass{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(i){return this._cache.has(i)}get(i){const l=this._cache.get(i);return l||warn(`[Assets] Asset id ${i} was not found in the Cache`),l}set(i,l){const p=convertToList(i);let m;for(let i=0;i<this.parsers.length;i++){const _=this.parsers[i];if(_.test(l)){m=_.getCacheableAssets(p,l);break}}const _=new Map(Object.entries(m||{}));m||p.forEach((i=>{_.set(i,l)}));const y=[..._.keys()],x={cacheKeys:y,keys:p};p.forEach((i=>{this._cacheMap.set(i,x)})),y.forEach((i=>{const p=m?m[i]:l;this._cache.has(i)&&this._cache.get(i)!==p&&warn("[Cache] already has key:",i),this._cache.set(i,_.get(i))}))}remove(i){if(!this._cacheMap.has(i))return void warn(`[Assets] Asset id ${i} was not found in the Cache`);const l=this._cacheMap.get(i);l.cacheKeys.forEach((i=>{this._cache.delete(i)})),l.keys.forEach((i=>{this._cacheMap.delete(i)}))}get parsers(){return this._parsers}},re=[];function textureSourceFrom(i={}){const l=i&&i.resource,p=l?i.resource:i,m=l?i:{resource:i};for(let i=0;i<re.length;i++){const l=re[i];if(l.test(p))return new l(m)}throw new Error(`Could not find a source type for resource: ${m.resource}`)}z.handleByList(O.TextureSource,re),Texture.from=function textureFrom(i,l=!1){return"string"==typeof i?se.get(i):i instanceof gt?new Texture({source:i}):function resourceToTexture(i={},l=!1){const p=i&&i.resource,m=p?i.resource:i,_=p?i:{resource:i};if(!l&&se.has(m))return se.get(m);const y=new Texture({source:textureSourceFrom(_)});return y.on("destroy",(()=>{se.has(m)&&se.remove(m)})),l||se.set(m,y),y}(i,l)},gt.from=textureSourceFrom,z.add(AlphaMask,ColorMask,StencilMask,ie,ImageSource,CanvasSource,BufferImageSource);var ne=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(ne||{});function assertPath(i){if("string"!=typeof i)throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function removeUrlParams(i){return i.split("?")[0].split("#")[0]}const oe={toPosix:i=>function replaceAll(i,l,p){return i.replace(new RegExp(function escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(l),"g"),p)}(i,"\\","/"),isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl:i=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i),isBlobUrl:i=>i.startsWith("blob:"),hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){assertPath(i),i=this.toPosix(i);const l=/^file:\/\/\//.exec(i);if(l)return l[0];const p=/^[^/:]+:\/{0,2}/.exec(i);return p?p[0]:""},toAbsolute(i,l,p){if(assertPath(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const m=removeUrlParams(this.toPosix(l??qt.get().getBaseUrl())),_=removeUrlParams(this.toPosix(p??this.rootname(m)));if((i=this.toPosix(i)).startsWith("/"))return oe.join(_,i.slice(1));return this.isAbsolute(i)?i:this.join(m,i)},normalize(i){if(assertPath(i),0===i.length)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;let l="";const p=(i=this.toPosix(i)).startsWith("/");this.hasProtocol(i)&&(l=this.rootname(i),i=i.slice(l.length));const m=i.endsWith("/");return i=function normalizeStringPosix(i,l){let p="",m=0,_=-1,y=0,x=-1;for(let l=0;l<=i.length;++l){if(l<i.length)x=i.charCodeAt(l);else{if(47===x)break;x=47}if(47===x){if(_===l-1||1===y);else if(_!==l-1&&2===y){if(p.length<2||2!==m||46!==p.charCodeAt(p.length-1)||46!==p.charCodeAt(p.length-2))if(p.length>2){const i=p.lastIndexOf("/");if(i!==p.length-1){-1===i?(p="",m=0):(p=p.slice(0,i),m=p.length-1-p.lastIndexOf("/")),_=l,y=0;continue}}else if(2===p.length||1===p.length){p="",m=0,_=l,y=0;continue}}else p.length>0?p+=`/${i.slice(_+1,l)}`:p=i.slice(_+1,l),m=l-_-1;_=l,y=0}else 46===x&&-1!==y?++y:y=-1}return p}(i),i.length>0&&m&&(i+="/"),p?`/${i}`:l+i},isAbsolute(i){return assertPath(i),i=this.toPosix(i),!!this.hasProtocol(i)||i.startsWith("/")},join(...i){if(0===i.length)return".";let l;for(let p=0;p<i.length;++p){const m=i[p];if(assertPath(m),m.length>0)if(void 0===l)l=m;else{const _=i[p-1]??"";this.joinExtensions.includes(this.extname(_).toLowerCase())?l+=`/../${m}`:l+=`/${m}`}}return void 0===l?".":this.normalize(l)},dirname(i){if(assertPath(i),0===i.length)return".";let l=(i=this.toPosix(i)).charCodeAt(0);const p=47===l;let m=-1,_=!0;const y=this.getProtocol(i),x=i;for(let p=(i=i.slice(y.length)).length-1;p>=1;--p)if(l=i.charCodeAt(p),47===l){if(!_){m=p;break}}else _=!1;return-1===m?p?"/":this.isUrl(x)?y+i:y:p&&1===m?"//":y+i.slice(0,m)},rootname(i){assertPath(i);let l="";if(l=(i=this.toPosix(i)).startsWith("/")?"/":this.getProtocol(i),this.isUrl(i)){const p=i.indexOf("/",l.length);l=-1!==p?i.slice(0,p):i,l.endsWith("/")||(l+="/")}return l},basename(i,l){assertPath(i),l&&assertPath(l),i=removeUrlParams(this.toPosix(i));let p,m=0,_=-1,y=!0;if(void 0!==l&&l.length>0&&l.length<=i.length){if(l.length===i.length&&l===i)return"";let x=l.length-1,v=-1;for(p=i.length-1;p>=0;--p){const T=i.charCodeAt(p);if(47===T){if(!y){m=p+1;break}}else-1===v&&(y=!1,v=p+1),x>=0&&(T===l.charCodeAt(x)?-1==--x&&(_=p):(x=-1,_=v))}return m===_?_=v:-1===_&&(_=i.length),i.slice(m,_)}for(p=i.length-1;p>=0;--p)if(47===i.charCodeAt(p)){if(!y){m=p+1;break}}else-1===_&&(y=!1,_=p+1);return-1===_?"":i.slice(m,_)},extname(i){assertPath(i);let l=-1,p=0,m=-1,_=!0,y=0;for(let x=(i=removeUrlParams(this.toPosix(i))).length-1;x>=0;--x){const v=i.charCodeAt(x);if(47!==v)-1===m&&(_=!1,m=x+1),46===v?-1===l?l=x:1!==y&&(y=1):-1!==l&&(y=-1);else if(!_){p=x+1;break}}return-1===l||-1===m||0===y||1===y&&l===m-1&&l===p+1?"":i.slice(l,m)},parse(i){assertPath(i);const l={root:"",dir:"",base:"",ext:"",name:""};if(0===i.length)return l;let p=(i=removeUrlParams(this.toPosix(i))).charCodeAt(0);const m=this.isAbsolute(i);let _;l.root=this.rootname(i),_=m||this.hasProtocol(i)?1:0;let y=-1,x=0,v=-1,T=!0,S=i.length-1,P=0;for(;S>=_;--S)if(p=i.charCodeAt(S),47!==p)-1===v&&(T=!1,v=S+1),46===p?-1===y?y=S:1!==P&&(P=1):-1!==y&&(P=-1);else if(!T){x=S+1;break}return-1===y||-1===v||0===P||1===P&&y===v-1&&y===x+1?-1!==v&&(l.base=l.name=0===x&&m?i.slice(1,v):i.slice(x,v)):(0===x&&m?(l.name=i.slice(1,y),l.base=i.slice(1,v)):(l.name=i.slice(x,y),l.base=i.slice(x,v)),l.ext=i.slice(y,v)),l.dir=this.dirname(i),l},sep:"/",delimiter:":",joinExtensions:[".html"]};function processX(i,l,p,m,_){const y=l[p];for(let x=0;x<y.length;x++){const v=y[x];p<l.length-1?processX(i.replace(m[p],v),l,p+1,m,_):_.push(i.replace(m[p],v))}}function createStringVariations(i){const l=i.match(/\{(.*?)\}/g),p=[];if(l){const m=[];l.forEach((i=>{const l=i.substring(1,i.length-1).split(",");m.push(l)})),processX(i,m,0,l,p)}else p.push(i);return p}const isSingleItem=i=>!Array.isArray(i);class Resolver{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(i,l)=>`${i}${this._bundleIdConnector}${l}`,extractAssetIdFromBundle:(i,l)=>l.replace(`${i}${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(i){if(this._bundleIdConnector=i.connector??this._bundleIdConnector,this._createBundleAssetId=i.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=i.extractAssetIdFromBundle??this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...i){i.forEach((i=>{this._preferredOrder.push(i),i.priority||(i.priority=Object.keys(i.params))})),this._resolverHash={}}set basePath(i){this._basePath=i}get basePath(){return this._basePath}set rootPath(i){this._rootPath=i}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(i){if("string"==typeof i)this._defaultSearchParams=i;else{const l=i;this._defaultSearchParams=Object.keys(l).map((i=>`${encodeURIComponent(i)}=${encodeURIComponent(l[i])}`)).join("&")}}getAlias(i){const{alias:l,src:p}=i,m=convertToList(l||p,(i=>"string"==typeof i?i:Array.isArray(i)?i.map((i=>i?.src??i)):i?.src?i.src:i),!0);return m}addManifest(i){this._manifest&&warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=i,i.bundles.forEach((i=>{this.addBundle(i.name,i.assets)}))}addBundle(i,l){const p=[];let m=l;Array.isArray(l)||(m=Object.entries(l).map((([i,l])=>"string"==typeof l||Array.isArray(l)?{alias:i,src:l}:{alias:i,...l}))),m.forEach((l=>{const m=l.src,_=l.alias;let y;if("string"==typeof _){const l=this._createBundleAssetId(i,_);p.push(l),y=[_,l]}else{const l=_.map((l=>this._createBundleAssetId(i,l)));p.push(...l),y=[..._,...l]}this.add({...l,alias:y,src:m})})),this._bundles[i]=p}add(i){const l=[];let p;Array.isArray(i)?l.push(...i):l.push(i),p=i=>{this.hasKey(i)&&warn(`[Resolver] already has key: ${i} overwriting`)};convertToList(l).forEach((i=>{const{src:l}=i;let{data:m,format:_,loadParser:y}=i;const x=convertToList(l).map((i=>"string"==typeof i?createStringVariations(i):Array.isArray(i)?i:[i])),v=this.getAlias(i);Array.isArray(v)?v.forEach(p):p(v);const T=[];x.forEach((i=>{i.forEach((i=>{let l={};if("object"!=typeof i){l.src=i;for(let p=0;p<this._parsers.length;p++){const m=this._parsers[p];if(m.test(i)){l=m.parse(i);break}}}else m=i.data??m,_=i.format??_,y=i.loadParser??y,l={...l,...i};if(!v)throw new Error(`[Resolver] alias is undefined for this asset: ${l.src}`);l=this._buildResolvedAsset(l,{aliases:v,data:m,format:_,loadParser:y}),T.push(l)}))})),v.forEach((i=>{this._assetMap[i]=T}))}))}resolveBundle(i){const l=isSingleItem(i);i=convertToList(i);const p={};return i.forEach((i=>{const l=this._bundles[i];if(l){const m=this.resolve(l),_={};for(const l in m){const p=m[l];_[this._extractAssetIdFromBundle(i,l)]=p}p[i]=_}})),l?p[i[0]]:p}resolveUrl(i){const l=this.resolve(i);if("string"!=typeof i){const i={};for(const p in l)i[p]=l[p].src;return i}return l.src}resolve(i){const l=isSingleItem(i);i=convertToList(i);const p={};return i.forEach((i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let l=this._assetMap[i];const p=this._getPreferredOrder(l);p?.priority.forEach((i=>{p.params[i].forEach((p=>{const m=l.filter((l=>!!l[i]&&l[i]===p));m.length&&(l=m)}))})),this._resolverHash[i]=l[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});p[i]=this._resolverHash[i]})),l?p[i[0]]:p}hasKey(i){return!!this._assetMap[i]}hasBundle(i){return!!this._bundles[i]}_getPreferredOrder(i){for(let l=0;l<i.length;l++){const l=i[0],p=this._preferredOrder.find((i=>i.params.format.includes(l.format)));if(p)return p}return this._preferredOrder[0]}_appendDefaultSearchParams(i){if(!this._defaultSearchParams)return i;return`${i}${/\?/.test(i)?"&":"?"}${this._defaultSearchParams}`}_buildResolvedAsset(i,l){const{aliases:p,data:m,loadParser:_,format:y}=l;return(this._basePath||this._rootPath)&&(i.src=oe.toAbsolute(i.src,this._basePath,this._rootPath)),i.alias=p??i.alias??[i.src],i.src=this._appendDefaultSearchParams(i.src),i.data={...m||{},...i.data},i.loadParser=_??i.loadParser,i.format=y??i.format??function getUrlExtension(i){return i.split(".").pop().split("?").shift().split("#").shift()}(i.src),i}}Resolver.RETINA_PREFIX=/@([0-9\.]+)x/;const copySearchParams=(i,l)=>{const p=l.split("?")[1];return p&&(i+=`?${p}`),i},ae=class _Spritesheet{constructor(i,l){this.linkedSheets=[],this._texture=i instanceof Texture?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=l;const p=parseFloat(l.meta.scale);p?(this.resolution=p,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise((i=>{this._callback=i,this._batchIndex=0,this._frameKeys.length<=_Spritesheet.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()}))}_processFrames(i){let l=i;const p=_Spritesheet.BATCH_SIZE;for(;l-i<p&&l<this._frameKeys.length;){const i=this._frameKeys[l],p=this._frames[i],m=p.frame;if(m){let l=null,_=null;const y=!1!==p.trimmed&&p.sourceSize?p.sourceSize:p.frame,x=new Rectangle(0,0,Math.floor(y.w)/this.resolution,Math.floor(y.h)/this.resolution);l=p.rotated?new Rectangle(Math.floor(m.x)/this.resolution,Math.floor(m.y)/this.resolution,Math.floor(m.h)/this.resolution,Math.floor(m.w)/this.resolution):new Rectangle(Math.floor(m.x)/this.resolution,Math.floor(m.y)/this.resolution,Math.floor(m.w)/this.resolution,Math.floor(m.h)/this.resolution),!1!==p.trimmed&&p.spriteSourceSize&&(_=new Rectangle(Math.floor(p.spriteSourceSize.x)/this.resolution,Math.floor(p.spriteSourceSize.y)/this.resolution,Math.floor(m.w)/this.resolution,Math.floor(m.h)/this.resolution)),this.textures[i]=new Texture({source:this.textureSource,frame:l,orig:x,trim:_,rotate:p.rotated?2:0,defaultAnchor:p.anchor,defaultBorders:p.borders,label:i.toString()})}l++}}_processAnimations(){const i=this.data.animations||{};for(const l in i){this.animations[l]=[];for(let p=0;p<i[l].length;p++){const m=i[l][p];this.animations[l].push(this.textures[m])}}}_parseComplete(){const i=this._callback;this._callback=null,this._batchIndex=0,i.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*_Spritesheet.BATCH_SIZE),this._batchIndex++,setTimeout((()=>{this._batchIndex*_Spritesheet.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())}),0)}destroy(i=!1){for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,i&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ae.BATCH_SIZE=1e3;let he=ae;const le=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function getCacheableAssets(i,l,p){const m={};if(i.forEach((i=>{m[i]=l})),Object.keys(l.textures).forEach((i=>{m[i]=l.textures[i]})),!p){const p=oe.dirname(i[0]);l.linkedSheets.forEach(((i,_)=>{const y=getCacheableAssets([`${p}/${l.data.meta.related_multi_packs[_]}`],i,!0);Object.assign(m,y)}))}return m}const de={extension:O.Asset,cache:{test:i=>i instanceof he,getCacheableAssets:(i,l)=>getCacheableAssets(i,l,!1)},resolver:{extension:{type:O.ResolveParser,name:"resolveSpritesheet"},test:i=>{const l=i.split("?")[0].split("."),p=l.pop(),m=l.pop();return"json"===p&&le.includes(m)},parse:i=>{const l=i.split(".");return{resolution:parseFloat(Resolver.RETINA_PREFIX.exec(i)?.[1]??"1"),format:l[l.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:O.LoadParser,priority:ne.Normal,name:"spritesheetLoader"},testParse:async(i,l)=>".json"===oe.extname(l.src).toLowerCase()&&!!i.frames,async parse(i,l,p){const{texture:m,imageFilename:_}=l?.data??{};let y,x=oe.dirname(l.src);if(x&&x.lastIndexOf("/")!==x.length-1&&(x+="/"),m instanceof Texture)y=m;else{const m=copySearchParams(x+(_??i.meta.image),l.src);y=(await p.load([m]))[m]}const v=new he(y.source,i);await v.parse();const T=i?.meta?.related_multi_packs;if(Array.isArray(T)){const i=[];for(const m of T){if("string"!=typeof m)continue;let _=x+m;l.data?.ignoreMultiPack||(_=copySearchParams(_,l.src),i.push(p.load({src:_,data:{ignoreMultiPack:!0}})))}const m=await Promise.all(i);v.linkedSheets=m,m.forEach((i=>{i.linkedSheets=[v].concat(v.linkedSheets.filter((l=>l!==i)))}))}return v},async unload(i,l,p){await p.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};z.add(de);class FederatedEvent{constructor(i){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=FederatedEvent.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Point,this.page=new Point,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=i}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(i,l,p){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(i,l,p,m,_){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var ue=/iPhone/i,ce=/iPod/i,pe=/iPad/i,fe=/\biOS-universal(?:.+)Mac\b/i,me=/\bAndroid(?:.+)Mobile\b/i,ge=/Android/i,_e=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ye=/Silk/i,xe=/Windows Phone/i,ve=/\bWindows(?:.+)ARM\b/i,be=/BlackBerry/i,we=/BB10/i,Te=/Opera Mini/i,Se=/\b(CriOS|Chrome)(?:.+)Mobile/i,Pe=/Mobile(?:.+)Firefox\b/i,isAppleTabletOnIos13=function(i){return void 0!==i&&"MacIntel"===i.platform&&"number"==typeof i.maxTouchPoints&&i.maxTouchPoints>1&&"undefined"==typeof MSStream};function isMobile$1(i){var l={userAgent:"",platform:"",maxTouchPoints:0};i||"undefined"==typeof navigator?"string"==typeof i?l.userAgent=i:i&&i.userAgent&&(l={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0}):l={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var p=l.userAgent,m=p.split("[FBAN");void 0!==m[1]&&(p=m[0]),void 0!==(m=p.split("Twitter"))[1]&&(p=m[0]);var _=function createMatch(i){return function(l){return l.test(i)}}(p),y={apple:{phone:_(ue)&&!_(xe),ipod:_(ce),tablet:!_(ue)&&(_(pe)||isAppleTabletOnIos13(l))&&!_(xe),universal:_(fe),device:(_(ue)||_(ce)||_(pe)||_(fe)||isAppleTabletOnIos13(l))&&!_(xe)},amazon:{phone:_(_e),tablet:!_(_e)&&_(ye),device:_(_e)||_(ye)},android:{phone:!_(xe)&&_(_e)||!_(xe)&&_(me),tablet:!_(xe)&&!_(_e)&&!_(me)&&(_(ye)||_(ge)),device:!_(xe)&&(_(_e)||_(ye)||_(me)||_(ge))||_(/\bokhttp\b/i)},windows:{phone:_(xe),tablet:_(ve),device:_(xe)||_(ve)},other:{blackberry:_(be),blackberry10:_(we),opera:_(Te),firefox:_(Pe),chrome:_(Se),device:_(be)||_(we)||_(Te)||_(Pe)||_(Se)},any:!1,phone:!1,tablet:!1};return y.any=y.apple.device||y.android.device||y.windows.device||y.other.device,y.phone=y.apple.phone||y.android.phone||y.windows.phone,y.tablet=y.apple.tablet||y.android.tablet||y.windows.tablet,y}const Me=(isMobile$1.default??isMobile$1)(globalThis.navigator);class AccessibilitySystem{constructor(i,l=Me){this._mobileInfo=l,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(l.tablet||l.phone)&&this._createTouchHook();const p=document.createElement("div");p.style.width="100px",p.style.height="100px",p.style.position="absolute",p.style.top="0px",p.style.left="0px",p.style.zIndex=2..toString(),this._div=p,this._renderer=i,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const i=document.createElement("button");i.style.width="1px",i.style.height="1px",i.style.position="absolute",i.style.top="-1000px",i.style.left="-1000px",i.style.zIndex=2..toString(),i.style.backgroundColor="#FF0000",i.title="select to enable accessibility for this content",i.addEventListener("focus",(()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()})),document.body.appendChild(i),this._hookDiv=i}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),this._renderer.view.canvas.parentNode?.appendChild(this._div))}_deactivate(){this._isActive&&!this._isMobileAccessibility&&(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),this._div.parentNode?.removeChild(this._div))}_updateAccessibleObjects(i){if(!i.visible||!i.accessibleChildren)return;i.accessible&&i.isInteractive()&&(i._accessibleActive||this._addChild(i),i._renderId=this._renderId);const l=i.children;if(l)for(let i=0;i<l.length;i++)this._updateAccessibleObjects(l[i])}init(i){this.debug=i?.debug??this.debug,this._renderer.runners.postrender.remove(this)}postrender(){const i=performance.now();if(this._mobileInfo.android.device&&i<this._androidUpdateCount)return;if(this._androidUpdateCount=i+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas)return;this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered);const{x:l,y:p,width:m,height:_}=this._renderer.view.canvas.getBoundingClientRect(),{width:y,height:x,resolution:v}=this._renderer,T=m/y*v,S=_/x*v;let P=this._div;P.style.left=`${l}px`,P.style.top=`${p}px`,P.style.width=`${y}px`,P.style.height=`${x}px`;for(let i=0;i<this._children.length;i++){const l=this._children[i];if(l._renderId!==this._renderId)l._accessibleActive=!1,removeItems(this._children,i,1),this._div.removeChild(l._accessibleDiv),this._pool.push(l._accessibleDiv),l._accessibleDiv=null,i--;else{P=l._accessibleDiv;let i=l.hitArea;const p=l.worldTransform;l.hitArea?(P.style.left=(p.tx+i.x*p.a)*T+"px",P.style.top=(p.ty+i.y*p.d)*S+"px",P.style.width=i.width*p.a*T+"px",P.style.height=i.height*p.d*S+"px"):(i=l.getBounds().rectangle,this._capHitArea(i),P.style.left=i.x*T+"px",P.style.top=i.y*S+"px",P.style.width=i.width*T+"px",P.style.height=i.height*S+"px",P.title!==l.accessibleTitle&&null!==l.accessibleTitle&&(P.title=l.accessibleTitle||""),P.getAttribute("aria-label")!==l.accessibleHint&&null!==l.accessibleHint&&P.setAttribute("aria-label",l.accessibleHint||"")),l.accessibleTitle===P.title&&l.tabIndex===P.tabIndex||(P.title=l.accessibleTitle||"",P.tabIndex=l.tabIndex,this.debug&&this._updateDebugHTML(P))}}this._renderId++}_updateDebugHTML(i){i.innerHTML=`type: ${i.type}</br> title : ${i.title}</br> tabIndex: ${i.tabIndex}`}_capHitArea(i){i.x<0&&(i.width+=i.x,i.x=0),i.y<0&&(i.height+=i.y,i.y=0);const{width:l,height:p}=this._renderer;i.x+i.width>l&&(i.width=l-i.x),i.y+i.height>p&&(i.height=p-i.y)}_addChild(i){let l=this._pool.pop();l||(l=document.createElement("button"),l.style.width="100px",l.style.height="100px",l.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",l.style.position="absolute",l.style.zIndex=2..toString(),l.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?l.setAttribute("aria-live","off"):l.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?l.setAttribute("aria-relevant","additions"):l.setAttribute("aria-relevant","text"),l.addEventListener("click",this._onClick.bind(this)),l.addEventListener("focus",this._onFocus.bind(this)),l.addEventListener("focusout",this._onFocusOut.bind(this))),l.style.pointerEvents=i.accessiblePointerEvents,l.type=i.accessibleType,i.accessibleTitle&&null!==i.accessibleTitle?l.title=i.accessibleTitle:i.accessibleHint&&null!==i.accessibleHint||(l.title=`container ${i.tabIndex}`),i.accessibleHint&&null!==i.accessibleHint&&l.setAttribute("aria-label",i.accessibleHint),this.debug&&this._updateDebugHTML(l),i._accessibleActive=!0,i._accessibleDiv=l,l.container=i,this._children.push(i),this._div.appendChild(i._accessibleDiv),i._accessibleDiv.tabIndex=i.tabIndex}_dispatchEvent(i,l){const{container:p}=i.target,m=this._renderer.events.rootBoundary,_=Object.assign(new FederatedEvent(m),{target:p});m.rootTarget=this._renderer.lastObjectRendered,l.forEach((i=>m.dispatchEvent(_,i)))}_onClick(i){this._dispatchEvent(i,["click","pointertap","tap"])}_onFocus(i){i.target.getAttribute("aria-live")||i.target.setAttribute("aria-live","assertive"),this._dispatchEvent(i,["mouseover"])}_onFocusOut(i){i.target.getAttribute("aria-live")||i.target.setAttribute("aria-live","polite"),this._dispatchEvent(i,["mouseout"])}_onKeyDown(i){9===i.keyCode&&this._activate()}_onMouseMove(i){0===i.movementX&&0===i.movementY||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}AccessibilitySystem.extension={type:[O.WebGLSystem,O.WebGPUSystem],name:"accessibility"};const Ce=Object.create(null),Ee=Object.create(null);function createIdFromString(i,l){let p=Ee[i];return void 0===p&&(void 0===Ce[l]&&(Ce[l]=1),Ee[i]=p=Ce[l]++),p}let Ae,ke;function getTestContext(){if(!Ae||Ae?.isContextLost()){const i=qt.get().createCanvas();Ae=i.getContext("webgl",{})}return Ae}function getMaxFragmentPrecision(){if(!ke){ke="mediump";const i=getTestContext();if(i&&i.getShaderPrecisionFormat){const l=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT);ke=l.precision?"highp":"mediump"}}return ke}const Be={},Fe={};const Re={stripVersion:function stripVersion(i,l){return l?i.replace("#version 300 es",""):i},ensurePrecision:function ensurePrecision(i,l,p){const m=p?l.maxSupportedFragmentPrecision:l.maxSupportedVertexPrecision;if("precision"!==i.substring(0,9)){let _=p?l.requestedFragmentPrecision:l.requestedVertexPrecision;return"highp"===_&&"highp"!==m&&(_="mediump"),`precision ${_} float;\n${i}`}return"highp"!==m&&"precision highp"===i.substring(0,15)?i.replace("precision highp","precision mediump"):i},addProgramDefines:function addProgramDefines(i,l,p){return l?i:p?`\n \n #ifdef GL_ES // This checks if it is WebGL1\n #define in varying\n #define finalColor gl_FragColor\n #define texture texture2D\n #endif\n ${i=i.replace("out vec4 finalColor;","")}\n `:`\n \n #ifdef GL_ES // This checks if it is WebGL1\n #define in attribute\n #define out varying\n #endif\n ${i}\n `},setProgramName:function setProgramName(i,{name:l="pixi-program"},p=!0){l=l.replace(/\s+/g,"-");const m=p?Be:Fe;return m[l+=p?"-fragment":"-vertex"]?(m[l]++,l+=`-${m[l]}`):m[l]=1,-1!==i.indexOf("#define SHADER_NAME")?i:`${`#define SHADER_NAME ${l}`}\n${i}`},insertVersion:function insertVersion(i,l){return l?`#version 300 es\n${i}`:i}},Ie=Object.create(null),De=class _GlProgram{constructor(i){const l=-1!==(i={..._GlProgram.defaultOptions,...i}).fragment.indexOf("#version 300 es"),p={stripVersion:l,ensurePrecision:{requestedFragmentPrecision:i.preferredFragmentPrecision,requestedVertexPrecision:i.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:getMaxFragmentPrecision()},setProgramName:{name:i.name},addProgramDefines:l,insertVersion:l};let m=i.fragment,_=i.vertex;Object.keys(Re).forEach((i=>{const l=p[i];m=Re[i](m,l,!0),_=Re[i](_,l,!1)})),this.fragment=m,this.vertex=_,this._key=createIdFromString(`${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}static from(i){const l=`${i.vertex}:${i.fragment}`;return Ie[l]||(Ie[l]=new _GlProgram(i)),Ie[l]}};De.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Le=De;const Ue={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 getAttributeInfoFromFormat(i){return Ue[i]??Ue.float32}const Ge={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",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function extractStructAndGroups(i){const l=/@group\((\d+)\)/,p=/@binding\((\d+)\)/,m=/var(<[^>]+>)? (\w+)/,_=/:\s*(\w+)/,y=/(\w+)\s*:\s*([\w\<\>]+)/g,x=/struct\s+(\w+)/,v=i.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g)?.map((i=>({group:parseInt(i.match(l)[1],10),binding:parseInt(i.match(p)[1],10),name:i.match(m)[2],isUniform:"<uniform>"===i.match(m)[1],type:i.match(_)[1]})));if(!v)return{groups:[],structs:[]};const T=i.match(/struct\s+(\w+)\s*{([^}]+)}/g)?.map((i=>{const l=i.match(x)[1],p=i.match(y).reduce(((i,l)=>{const[p,m]=l.split(":");return i[p.trim()]=m.trim(),i}),{});return p?{name:l,members:p}:null})).filter((({name:i})=>v.some((l=>l.type===i))))??[];return{groups:v,structs:T}}var Oe=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Oe||{});const ze=Object.create(null);class GpuProgram{constructor(i){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:l,vertex:p,layout:m,gpuLayout:_,name:y}=i;if(this.name=y,this.fragment=l,this.vertex=p,l.source===p.source){const i=extractStructAndGroups(l.source);this.structsAndGroups=i}else{const i=extractStructAndGroups(p.source),m=extractStructAndGroups(l.source);this.structsAndGroups=function removeStructAndGroupDuplicates(i,l){const p=new Set,m=new Set;return{structs:[...i.structs,...l.structs].filter((i=>!p.has(i.name)&&(p.add(i.name),!0))),groups:[...i.groups,...l.groups].filter((i=>{const l=`${i.name}-${i.binding}`;return!m.has(l)&&(m.add(l),!0)}))}}(i,m)}this.layout=m??function generateLayoutHash({groups:i}){const l=[];for(let p=0;p<i.length;p++){const m=i[p];l[m.group]||(l[m.group]={}),l[m.group][m.name]=m.binding}return l}(this.structsAndGroups),this.gpuLayout=_??function generateGpuLayoutGroups({groups:i}){const l=[];for(let p=0;p<i.length;p++){const m=i[p];l[m.group]||(l[m.group]=[]),m.isUniform?l[m.group].push({binding:m.binding,visibility:Oe.VERTEX|Oe.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===m.type?l[m.group].push({binding:m.binding,visibility:Oe.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===m.type&&l[m.group].push({binding:m.binding,visibility:Oe.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return l}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===this.layout[0]?.globalUniforms),this.autoAssignLocalUniforms=!(void 0===this.layout[1]?.localUniforms),this._generateProgramKey()}_generateProgramKey(){const{vertex:i,fragment:l}=this,p=i.source+l.source+i.entryPoint+l.entryPoint;this._layoutKey=createIdFromString(p,"program")}get attributeData(){return this._attributeData??(this._attributeData=function extractAttributesFromGpuProgram({source:i,entryPoint:l}){const p={},m=i.indexOf(`fn ${l}`);if(-1!==m){const l=i.indexOf("->",m);if(-1!==l){const _=i.substring(m,l),y=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let x;for(;null!==(x=y.exec(_));){const i=Ge[x[3]]??"float32";p[x[2]]={location:parseInt(x[1],10),format:i,stride:getAttributeInfoFromFormat(i).stride,offset:0,instance:!1,start:0}}}}return p}(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(i){const l=`${i.vertex.source}:${i.fragment.source}:${i.fragment.entryPoint}:${i.vertex.entryPoint}`;return ze[l]||(ze[l]=new GpuProgram(i)),ze[l]}}const Ne=["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>"],He=Ne.reduce(((i,l)=>(i[l]=!0,i)),{});function getDefaultUniformValue(i,l){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*l);case"vec3<f32>":return new Float32Array(3*l);case"vec4<f32>":return new Float32Array(4*l);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const We=class _UniformGroup{constructor(i,l){this._touched=0,this.uid=uid("uniform"),this._resourceType="uniformGroup",this._resourceId=uid("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,l={..._UniformGroup.defaultOptions,...l},this.uniformStructures=i;const p={};for(const l in i){const m=i[l];if(m.name=l,m.size=m.size??1,!He[m.type])throw new Error(`Uniform type ${m.type} is not supported. Supported uniform types are: ${Ne.join(", ")}`);m.value??(m.value=getDefaultUniformValue(m.type,m.size)),p[l]=m.value}this.uniforms=p,this._dirtyId=1,this.ubo=l.ubo,this.isStatic=l.isStatic,this._signature=createIdFromString(Object.keys(p).map((l=>`${l}-${i[l].type}`)).join("-"),"uniform-group")}update(){this._dirtyId++}};We.defaultOptions={ubo:!1,isStatic:!1};let Ke=We;class BindGroup{constructor(i){this.resources=Object.create(null),this._dirty=!0;let l=0;for(const p in i){const m=i[p];this.setResource(m,l++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const i=[];let l=0;for(const p in this.resources)i[l++]=this.resources[p]._resourceId;this._key=i.join("|")}setResource(i,l){const p=this.resources[l];i!==p&&(p&&i.off?.("change",this.onResourceChange,this),i.on?.("change",this.onResourceChange,this),this.resources[l]=i,this._dirty=!0)}getResource(i){return this.resources[i]}_touch(i){const l=this.resources;for(const p in l)l[p]._touched=i}destroy(){const i=this.resources;for(const l in i){const p=i[l];p.off?.("change",this.onResourceChange,this)}this.resources=null}onResourceChange(i){if(this._dirty=!0,i.destroyed){const l=this.resources;for(const p in l)l[p]===i&&(l[p]=null)}else this._updateKey()}}var Ye=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(Ye||{});class Shader extends V{constructor(i){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:l,glProgram:p,groups:m,resources:_,compatibleRenderers:y,groupMap:x}=i;this.gpuProgram=l,this.glProgram=p,void 0===y&&(y=0,l&&(y|=Ye.WEBGPU),p&&(y|=Ye.WEBGL)),this.compatibleRenderers=y;const v={};if(_||m||(_={}),_&&m)throw new Error("[Shader] Cannot have both resources and groups");if(!l&&m&&!x)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!l&&m&&x)for(const i in x)for(const l in x[i]){const p=x[i][l];v[p]={group:i,binding:l,name:p}}else if(l&&m&&!x){const i=l.structsAndGroups.groups;x={},i.forEach((i=>{x[i.group]=x[i.group]||{},x[i.group][i.binding]=i.name,v[i.name]=i}))}else if(_){if(m={},x={},l){l.structsAndGroups.groups.forEach((i=>{x[i.group]=x[i.group]||{},x[i.group][i.binding]=i.name,v[i.name]=i}))}let i=0;for(const l in _)v[l]||(m[99]||(m[99]=new BindGroup,this._ownedBindGroups.push(m[99])),v[l]={group:99,binding:i,name:l},x[99]=x[99]||{},x[99][i]=l,i++);for(const i in _){const l=i;let p=_[i];p.source||p._resourceType||(p=new Ke(p));const y=v[l];y&&(m[y.group]||(m[y.group]=new BindGroup,this._ownedBindGroups.push(m[y.group])),m[y.group].setResource(p,y.binding))}}this.groups=m,this._uniformBindMap=x,this.resources=this._buildResourceAccessor(m,v)}addResource(i,l,p){var m,_;(m=this._uniformBindMap)[l]||(m[l]={}),(_=this._uniformBindMap[l])[p]||(_[p]=i),this.groups[l]||(this.groups[l]=new BindGroup,this._ownedBindGroups.push(this.groups[l]))}_buildResourceAccessor(i,l){const p={};for(const m in l){const _=l[m];Object.defineProperty(p,_.name,{get:()=>i[_.group].getResource(_.binding),set(l){i[_.group].setResource(l,_.binding)}})}return p}destroy(i=!1){this.emit("destroy",this),i&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach((i=>{i.destroy()})),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(i){const{gpu:l,gl:p,...m}=i;let _,y;return l&&(_=GpuProgram.from(l)),p&&(y=Le.from(p)),new Shader({gpuProgram:_,glProgram:y,...m})}}const Ve={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},$e=class _State{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(i){!!(1&this.data)!==i&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(i){!!(2&this.data)!==i&&(this.data^=2)}set cullMode(i){"none"!==i?(this.culling=!0,this.clockwiseFrontFace="front"===i):this.culling=!1}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(i){!!(4&this.data)!==i&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(i){!!(8&this.data)!==i&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(i){!!(32&this.data)!==i&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(i){!!(16&this.data)!==i&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(i){this.blend="none"!==i,this._blendMode=i,this._blendModeId=Ve[i]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(i){this.offsets=!!i,this._polygonOffset=i}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const i=new _State;return i.depthTest=!1,i.blend=!0,i}};$e.default2d=$e.for2d();let Xe=$e;var je={exports:{}};function earcut(i,l,p){p=p||2;var m,_,y,x,v,T,S,P=l&&l.length,C=P?l[0]*p:i.length,E=linkedList(i,0,C,p,!0),A=[];if(!E||E.next===E.prev)return A;if(P&&(E=function eliminateHoles(i,l,p,m){var _,y,x,v=[];for(_=0,y=l.length;_<y;_++)(x=linkedList(i,l[_]*m,_<y-1?l[_+1]*m:i.length,m,!1))===x.next&&(x.steiner=!0),v.push(getLeftmost(x));for(v.sort(compareX),_=0;_<v.length;_++)p=eliminateHole(v[_],p);return p}(i,l,E,p)),i.length>80*p){m=y=i[0],_=x=i[1];for(var k=p;k<C;k+=p)(v=i[k])<m&&(m=v),(T=i[k+1])<_&&(_=T),v>y&&(y=v),T>x&&(x=T);S=0!==(S=Math.max(y-m,x-_))?32767/S:0}return earcutLinked(E,A,p,m,_,S,0),A}function linkedList(i,l,p,m,_){var y,x;if(_===signedArea(i,l,p,m)>0)for(y=l;y<p;y+=m)x=insertNode(y,i[y],i[y+1],x);else for(y=p-m;y>=l;y-=m)x=insertNode(y,i[y],i[y+1],x);return x&&equals(x,x.next)&&(removeNode(x),x=x.next),x}function filterPoints(i,l){if(!i)return i;l||(l=i);var p,m=i;do{if(p=!1,m.steiner||!equals(m,m.next)&&0!==area(m.prev,m,m.next))m=m.next;else{if(removeNode(m),(m=l=m.prev)===m.next)break;p=!0}}while(p||m!==l);return l}function earcutLinked(i,l,p,m,_,y,x){if(i){!x&&y&&function indexCurve(i,l,p,m){var _=i;do{0===_.z&&(_.z=zOrder(_.x,_.y,l,p,m)),_.prevZ=_.prev,_.nextZ=_.next,_=_.next}while(_!==i);_.prevZ.nextZ=null,_.prevZ=null,function sortLinked(i){var l,p,m,_,y,x,v,T,S=1;do{for(p=i,i=null,y=null,x=0;p;){for(x++,m=p,v=0,l=0;l<S&&(v++,m=m.nextZ);l++);for(T=S;v>0||T>0&&m;)0!==v&&(0===T||!m||p.z<=m.z)?(_=p,p=p.nextZ,v--):(_=m,m=m.nextZ,T--),y?y.nextZ=_:i=_,_.prevZ=y,y=_;p=m}y.nextZ=null,S*=2}while(x>1);return i}(_)}(i,m,_,y);for(var v,T,S=i;i.prev!==i.next;)if(v=i.prev,T=i.next,y?isEarHashed(i,m,_,y):isEar(i))l.push(v.i/p|0),l.push(i.i/p|0),l.push(T.i/p|0),removeNode(i),i=T.next,S=T.next;else if((i=T)===S){x?1===x?earcutLinked(i=cureLocalIntersections(filterPoints(i),l,p),l,p,m,_,y,2):2===x&&splitEarcut(i,l,p,m,_,y):earcutLinked(filterPoints(i),l,p,m,_,y,1);break}}}function isEar(i){var l=i.prev,p=i,m=i.next;if(area(l,p,m)>=0)return!1;for(var _=l.x,y=p.x,x=m.x,v=l.y,T=p.y,S=m.y,P=_<y?_<x?_:x:y<x?y:x,C=v<T?v<S?v:S:T<S?T:S,E=_>y?_>x?_:x:y>x?y:x,A=v>T?v>S?v:S:T>S?T:S,k=m.next;k!==l;){if(k.x>=P&&k.x<=E&&k.y>=C&&k.y<=A&&pointInTriangle(_,v,y,T,x,S,k.x,k.y)&&area(k.prev,k,k.next)>=0)return!1;k=k.next}return!0}function isEarHashed(i,l,p,m){var _=i.prev,y=i,x=i.next;if(area(_,y,x)>=0)return!1;for(var v=_.x,T=y.x,S=x.x,P=_.y,C=y.y,E=x.y,A=v<T?v<S?v:S:T<S?T:S,k=P<C?P<E?P:E:C<E?C:E,B=v>T?v>S?v:S:T>S?T:S,F=P>C?P>E?P:E:C>E?C:E,R=zOrder(A,k,l,p,m),I=zOrder(B,F,l,p,m),D=i.prevZ,L=i.nextZ;D&&D.z>=R&&L&&L.z<=I;){if(D.x>=A&&D.x<=B&&D.y>=k&&D.y<=F&&D!==_&&D!==x&&pointInTriangle(v,P,T,C,S,E,D.x,D.y)&&area(D.prev,D,D.next)>=0)return!1;if(D=D.prevZ,L.x>=A&&L.x<=B&&L.y>=k&&L.y<=F&&L!==_&&L!==x&&pointInTriangle(v,P,T,C,S,E,L.x,L.y)&&area(L.prev,L,L.next)>=0)return!1;L=L.nextZ}for(;D&&D.z>=R;){if(D.x>=A&&D.x<=B&&D.y>=k&&D.y<=F&&D!==_&&D!==x&&pointInTriangle(v,P,T,C,S,E,D.x,D.y)&&area(D.prev,D,D.next)>=0)return!1;D=D.prevZ}for(;L&&L.z<=I;){if(L.x>=A&&L.x<=B&&L.y>=k&&L.y<=F&&L!==_&&L!==x&&pointInTriangle(v,P,T,C,S,E,L.x,L.y)&&area(L.prev,L,L.next)>=0)return!1;L=L.nextZ}return!0}function cureLocalIntersections(i,l,p){var m=i;do{var _=m.prev,y=m.next.next;!equals(_,y)&&intersects(_,m,m.next,y)&&locallyInside(_,y)&&locallyInside(y,_)&&(l.push(_.i/p|0),l.push(m.i/p|0),l.push(y.i/p|0),removeNode(m),removeNode(m.next),m=i=y),m=m.next}while(m!==i);return filterPoints(m)}function splitEarcut(i,l,p,m,_,y){var x=i;do{for(var v=x.next.next;v!==x.prev;){if(x.i!==v.i&&isValidDiagonal(x,v)){var T=splitPolygon(x,v);return x=filterPoints(x,x.next),T=filterPoints(T,T.next),earcutLinked(x,l,p,m,_,y,0),void earcutLinked(T,l,p,m,_,y,0)}v=v.next}x=x.next}while(x!==i)}function compareX(i,l){return i.x-l.x}function eliminateHole(i,l){var p=function findHoleBridge(i,l){var p,m=l,_=i.x,y=i.y,x=-1/0;do{if(y<=m.y&&y>=m.next.y&&m.next.y!==m.y){var v=m.x+(y-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(v<=_&&v>x&&(x=v,p=m.x<m.next.x?m:m.next,v===_))return p}m=m.next}while(m!==l);if(!p)return null;var T,S=p,P=p.x,C=p.y,E=1/0;m=p;do{_>=m.x&&m.x>=P&&_!==m.x&&pointInTriangle(y<C?_:x,y,P,C,y<C?x:_,y,m.x,m.y)&&(T=Math.abs(y-m.y)/(_-m.x),locallyInside(m,i)&&(T<E||T===E&&(m.x>p.x||m.x===p.x&§orContainsSector(p,m)))&&(p=m,E=T)),m=m.next}while(m!==S);return p}(i,l);if(!p)return l;var m=splitPolygon(p,i);return filterPoints(m,m.next),filterPoints(p,p.next)}function sectorContainsSector(i,l){return area(i.prev,i,l.prev)<0&&area(l.next,i,i.next)<0}function zOrder(i,l,p,m,_){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-p)*_|0)|i<<8))|i<<4))|i<<2))|i<<1))|(l=1431655765&((l=858993459&((l=252645135&((l=16711935&((l=(l-m)*_|0)|l<<8))|l<<4))|l<<2))|l<<1))<<1}function getLeftmost(i){var l=i,p=i;do{(l.x<p.x||l.x===p.x&&l.y<p.y)&&(p=l),l=l.next}while(l!==i);return p}function pointInTriangle(i,l,p,m,_,y,x,v){return(_-x)*(l-v)>=(i-x)*(y-v)&&(i-x)*(m-v)>=(p-x)*(l-v)&&(p-x)*(y-v)>=(_-x)*(m-v)}function isValidDiagonal(i,l){return i.next.i!==l.i&&i.prev.i!==l.i&&!function intersectsPolygon(i,l){var p=i;do{if(p.i!==i.i&&p.next.i!==i.i&&p.i!==l.i&&p.next.i!==l.i&&intersects(p,p.next,i,l))return!0;p=p.next}while(p!==i);return!1}(i,l)&&(locallyInside(i,l)&&locallyInside(l,i)&&function middleInside(i,l){var p=i,m=!1,_=(i.x+l.x)/2,y=(i.y+l.y)/2;do{p.y>y!=p.next.y>y&&p.next.y!==p.y&&_<(p.next.x-p.x)*(y-p.y)/(p.next.y-p.y)+p.x&&(m=!m),p=p.next}while(p!==i);return m}(i,l)&&(area(i.prev,i,l.prev)||area(i,l.prev,l))||equals(i,l)&&area(i.prev,i,i.next)>0&&area(l.prev,l,l.next)>0)}function area(i,l,p){return(l.y-i.y)*(p.x-l.x)-(l.x-i.x)*(p.y-l.y)}function equals(i,l){return i.x===l.x&&i.y===l.y}function intersects(i,l,p,m){var _=sign(area(i,l,p)),y=sign(area(i,l,m)),x=sign(area(p,m,i)),v=sign(area(p,m,l));return _!==y&&x!==v||(!(0!==_||!onSegment(i,p,l))||(!(0!==y||!onSegment(i,m,l))||(!(0!==x||!onSegment(p,i,m))||!(0!==v||!onSegment(p,l,m)))))}function onSegment(i,l,p){return l.x<=Math.max(i.x,p.x)&&l.x>=Math.min(i.x,p.x)&&l.y<=Math.max(i.y,p.y)&&l.y>=Math.min(i.y,p.y)}function sign(i){return i>0?1:i<0?-1:0}function locallyInside(i,l){return area(i.prev,i,i.next)<0?area(i,l,i.next)>=0&&area(i,i.prev,l)>=0:area(i,l,i.prev)<0||area(i,i.next,l)<0}function splitPolygon(i,l){var p=new Node(i.i,i.x,i.y),m=new Node(l.i,l.x,l.y),_=i.next,y=l.prev;return i.next=l,l.prev=i,p.next=_,_.prev=p,m.next=p,p.prev=m,y.next=m,m.prev=y,m}function insertNode(i,l,p,m){var _=new Node(i,l,p);return m?(_.next=m.next,_.prev=m,m.next.prev=_,m.next=_):(_.prev=_,_.next=_),_}function removeNode(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Node(i,l,p){this.i=i,this.x=l,this.y=p,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(i,l,p,m){for(var _=0,y=l,x=p-m;y<p;y+=m)_+=(i[x]-i[y])*(i[y+1]+i[x+1]),x=y;return _}je.exports=earcut,je.exports.default=earcut,earcut.deviation=function(i,l,p,m){var _=l&&l.length,y=_?l[0]*p:i.length,x=Math.abs(signedArea(i,0,y,p));if(_)for(var v=0,T=l.length;v<T;v++){var S=l[v]*p,P=v<T-1?l[v+1]*p:i.length;x-=Math.abs(signedArea(i,S,P,p))}var C=0;for(v=0;v<m.length;v+=3){var E=m[v]*p,A=m[v+1]*p,k=m[v+2]*p;C+=Math.abs((i[E]-i[k])*(i[A+1]-i[E+1])-(i[E]-i[A])*(i[k+1]-i[E+1]))}return 0===x&&0===C?0:Math.abs((C-x)/x)},earcut.flatten=function(i){for(var l=i[0][0].length,p={vertices:[],holes:[],dimensions:l},m=0,_=0;_<i.length;_++){for(var y=0;y<i[_].length;y++)for(var x=0;x<l;x++)p.vertices.push(i[_][y][x]);_>0&&(m+=i[_-1].length,p.holes.push(m))}return p};var qe=getDefaultExportFromCjs(je.exports);class ResizePlugin{static init(i){Object.defineProperty(this,"resizeTo",{set(i){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=i,i&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame((()=>this.resize())))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;let i,l;if(this._cancelResize(),this._resizeTo===globalThis.window)i=globalThis.innerWidth,l=globalThis.innerHeight;else{const{clientWidth:p,clientHeight:m}=this._resizeTo;i=p,l=m}this.renderer.resize(i,l),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=i.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}ResizePlugin.extension=O.Application;class TickerPlugin{static init(i){i=Object.assign({autoStart:!0,sharedTicker:!1},i),Object.defineProperty(this,"ticker",{set(i){this._ticker&&this._ticker.remove(this.render,this),this._ticker=i,i&&i.add(this.render,this,Zt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=i.sharedTicker?te.shared:new te,i.autoStart&&this.start()}static destroy(){if(this._ticker){const i=this._ticker;this.ticker=null,i.destroy()}}}TickerPlugin.extension=O.Application;class AbstractBitmapFont extends V{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 deprecation(ut,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return deprecation(ut,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return deprecation(ut,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return deprecation(ut,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return deprecation(ut,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(i=!1){this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)this.chars[i].texture?.destroy();this.chars=null,i&&(this.pages.forEach((i=>i.texture.destroy(!0))),this.pages=null)}}const Ze=class _FillGradient{constructor(i,l,p,m){this.uid=uid("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=i,this.y0=l,this.x1=p,this.y1=m}addColorStop(i,l){return this.gradientStops.push({offset:i,color:At.shared.setValue(l).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const i=_FillGradient.defaultTextureSize,{gradientStops:l}=this,p=qt.get().createCanvas();p.width=i,p.height=i;const m=p.getContext("2d"),_=m.createLinearGradient(0,0,_FillGradient.defaultTextureSize,1);for(let i=0;i<l.length;i++){const p=l[i];_.addColorStop(p.offset,p.color)}m.fillStyle=_,m.fillRect(0,0,i,i),this.texture=new Texture({source:new ImageSource({resource:p,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:y,y0:x,x1:v,y1:T}=this,S=new Matrix,P=v-y,C=T-x,E=Math.sqrt(P*P+C*C),A=Math.atan2(C,P);S.translate(-y,-x),S.scale(1/i,1/i),S.rotate(-A),S.scale(256/E,1),this.transform=S,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;const i=this.gradientStops.map((i=>`${i.offset}-${i.color}`)).join("-"),l=this.texture.uid,p=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${i}-${l}-${p}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Ze.defaultTextureSize=256;let Qe=Ze;const Je={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class FillPattern{constructor(i,l){this.uid=uid("fillPattern"),this.transform=new Matrix,this._styleKey=null,this.texture=i,this.transform.scale(1/i.frame.width,1/i.frame.height),l&&(i.source.style.addressModeU=Je[l].addressModeU,i.source.style.addressModeV=Je[l].addressModeV)}setTransform(i){const l=this.texture;this.transform.copyFrom(i),this.transform.invert(),this.transform.scale(1/l.frame.width,1/l.frame.height),this._styleKey=null}get styleKey(){return this._styleKey||(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`),this._styleKey}}var ti=function parse(i){var l=[];return i.replace(ii,(function(i,p,m){var _=p.toLowerCase();for(m=function parseValues(i){var l=i.match(si);return l?l.map(Number):[]}(m),"m"==_&&m.length>2&&(l.push([p].concat(m.splice(0,2))),_="l",p="m"==p?"l":"L");;){if(m.length==ei[_])return m.unshift(p),l.push(m);if(m.length<ei[_])throw new Error("malformed path data");l.push([p].concat(m.splice(0,ei[_])))}})),l},ei={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},ii=/([astvzqmhlc])([^astvzqmhlc]*)/gi;var si=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;var ri=getDefaultExportFromCjs(ti);class Circle{constructor(i=0,l=0,p=0){this.type="circle",this.x=i,this.y=l,this.radius=p}clone(){return new Circle(this.x,this.y,this.radius)}contains(i,l){if(this.radius<=0)return!1;const p=this.radius*this.radius;let m=this.x-i,_=this.y-l;return m*=m,_*=_,m+_<=p}strokeContains(i,l,p){if(0===this.radius)return!1;const m=this.x-i,_=this.y-l,y=this.radius,x=p/2,v=Math.sqrt(m*m+_*_);return v<y+x&&v>y-x}getBounds(i){return(i=i||new Rectangle).x=this.x-this.radius,i.y=this.y-this.radius,i.width=2*this.radius,i.height=2*this.radius,i}copyFrom(i){return this.x=i.x,this.y=i.y,this.radius=i.radius,this}copyTo(i){return i.copyFrom(this),i}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Ellipse{constructor(i=0,l=0,p=0,m=0){this.type="ellipse",this.x=i,this.y=l,this.halfWidth=p,this.halfHeight=m}clone(){return new Ellipse(this.x,this.y,this.halfWidth,this.halfHeight)}contains(i,l){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let p=(i-this.x)/this.halfWidth,m=(l-this.y)/this.halfHeight;return p*=p,m*=m,p+m<=1}strokeContains(i,l,p){const{halfWidth:m,halfHeight:_}=this;if(m<=0||_<=0)return!1;const y=p/2,x=m-y,v=_-y,T=m+y,S=_+y,P=i-this.x,C=l-this.y;return P*P/(x*x)+C*C/(v*v)>1&&P*P/(T*T)+C*C/(S*S)<=1}getBounds(i){return(i=i||new Rectangle).x=this.x-this.halfWidth,i.y=this.y-this.halfHeight,i.width=2*this.halfWidth,i.height=2*this.halfHeight,i}copyFrom(i){return this.x=i.x,this.y=i.y,this.halfWidth=i.halfWidth,this.halfHeight=i.halfHeight,this}copyTo(i){return i.copyFrom(this),i}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function squaredDistanceToLineSegment(i,l,p,m,_,y){const x=_-p,v=y-m,T=x*x+v*v;let S,P,C=-1;0!==T&&(C=((i-p)*x+(l-m)*v)/T),C<0?(S=p,P=m):C>1?(S=_,P=y):(S=p+C*x,P=m+C*v);const E=i-S,A=l-P;return E*E+A*A}class Polygon{constructor(...i){this.type="polygon";let l=Array.isArray(i[0])?i[0]:i;if("number"!=typeof l[0]){const i=[];for(let p=0,m=l.length;p<m;p++)i.push(l[p].x,l[p].y);l=i}this.points=l,this.closePath=!0}clone(){const i=this.points.slice(),l=new Polygon(i);return l.closePath=this.closePath,l}contains(i,l){let p=!1;const m=this.points.length/2;for(let _=0,y=m-1;_<m;y=_++){const m=this.points[2*_],x=this.points[2*_+1],v=this.points[2*y],T=this.points[2*y+1];x>l!=T>l&&i<(l-x)/(T-x)*(v-m)+m&&(p=!p)}return p}strokeContains(i,l,p){const m=p/2,_=m*m,{points:y}=this,x=y.length-(this.closePath?0:2);for(let p=0;p<x;p+=2){if(squaredDistanceToLineSegment(i,l,y[p],y[p+1],y[(p+2)%y.length],y[(p+3)%y.length])<=_)return!0}return!1}getBounds(i){i=i||new Rectangle;const l=this.points;let p=1/0,m=-1/0,_=1/0,y=-1/0;for(let i=0,x=l.length;i<x;i+=2){const x=l[i],v=l[i+1];p=x<p?x:p,m=x>m?x:m,_=v<_?v:_,y=v>y?v:y}return i.x=p,i.width=m-p,i.y=_,i.height=y-_,i}copyFrom(i){return this.points=i.points.slice(),this.closePath=i.closePath,this}copyTo(i){return i.copyFrom(this),i}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce(((i,l)=>`${i}, ${l}`),"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const isCornerWithinStroke=(i,l,p,m,_,y)=>{const x=i-p,v=l-m,T=Math.sqrt(x*x+v*v);return T>=_-y&&T<=_+y};class RoundedRectangle{constructor(i=0,l=0,p=0,m=0,_=20){this.type="roundedRectangle",this.x=i,this.y=l,this.width=p,this.height=m,this.radius=_}getBounds(i){return(i=i||new Rectangle).x=this.x,i.y=this.y,i.width=this.width,i.height=this.height,i}clone(){return new RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)}copyFrom(i){return this.x=i.x,this.y=i.y,this.width=i.width,this.height=i.height,this}copyTo(i){return i.copyFrom(this),i}contains(i,l){if(this.width<=0||this.height<=0)return!1;if(i>=this.x&&i<=this.x+this.width&&l>=this.y&&l<=this.y+this.height){const p=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(l>=this.y+p&&l<=this.y+this.height-p||i>=this.x+p&&i<=this.x+this.width-p)return!0;let m=i-(this.x+p),_=l-(this.y+p);const y=p*p;if(m*m+_*_<=y)return!0;if(m=i-(this.x+this.width-p),m*m+_*_<=y)return!0;if(_=l-(this.y+this.height-p),m*m+_*_<=y)return!0;if(m=i-(this.x+p),m*m+_*_<=y)return!0}return!1}strokeContains(i,l,p){const{x:m,y:_,width:y,height:x,radius:v}=this,T=p/2,S=m+v,P=_+v,C=m+y,E=_+x;return(i>=m-T&&i<=m+T||i>=C-T&&i<=C+T)&&l>=P&&l<=P+(x-2*v)||((l>=_-T&&l<=_+T||l>=E-T&&l<=E+T)&&i>=S&&i<=S+(y-2*v)||(i<S&&l<P&&isCornerWithinStroke(i,l,S,P,v,T)||i>C-v&&l<P&&isCornerWithinStroke(i,l,C-v,P,v,T)||i>C-v&&l>E-v&&isCornerWithinStroke(i,l,C-v,E-v,v,T)||i<S&&l>E-v&&isCornerWithinStroke(i,l,S,E-v,v,T)))}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const ni=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function generateIfTestSrc(i){let l="";for(let p=0;p<i;++p)p>0&&(l+="\nelse "),p<i-1&&(l+=`if(test == ${p}.0){}`);return l}let oi=null;function getMaxTexturesPerBatch(){if(oi)return oi;const i=getTestContext();return oi=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),oi=function checkMaxIfStatementsInShader(i,l){if(0===i)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const p=l.createShader(l.FRAGMENT_SHADER);try{for(;;){const m=ni.replace(/%forloop%/gi,generateIfTestSrc(i));if(l.shaderSource(p,m),l.compileShader(p),l.getShaderParameter(p,l.COMPILE_STATUS))break;i=i/2|0}}finally{l.deleteShader(p)}return i}(oi,i),i.getExtension("WEBGL_lose_context")?.loseContext(),oi}const ai={};function getTextureBatchBindGroup(i,l){let p=2166136261;for(let m=0;m<l;m++)p^=i[m].uid,p=Math.imul(p,16777619),p>>>=0;return ai[p]||function generateTextureBatchBindGroup(i,l,p){const m={};let _=0;hi||(hi=getMaxTexturesPerBatch());for(let p=0;p<hi;p++){const y=p<l?i[p]:Texture.EMPTY.source;m[_++]=y.source,m[_++]=y.style}const y=new BindGroup(m);return ai[p]=y,y}(i,l,p)}let hi=0;class ViewableBuffer{constructor(i){"number"==typeof i?this.rawBinaryData=new ArrayBuffer(i):i instanceof Uint8Array?this.rawBinaryData=i.buffer:this.rawBinaryData=i,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(i){return this[`${i}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(i){switch(i){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${i} isn't a valid view type`)}}}function fastCopy(i,l){const p=i.byteLength/8|0,m=new Float64Array(i,0,p);new Float64Array(l,0,p).set(m);const _=i.byteLength-8*p;if(_>0){const m=new Uint8Array(i,8*p,_);new Uint8Array(l,8*p,_).set(m)}}const li={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};function getAdjustedBlendModeBlend(i,l){return"no-premultiply-alpha"===l.alphaMode&&li[i]||i}class BatchTextureArray{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let i=0;i<this.count;i++){const l=this.textures[i];this.textures[i]=null,this.ids[l.uid]=null}this.count=0}}class Batch{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new BatchTextureArray,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const di=[];let ui=0;function getBatchFromPool(){return ui>0?di[--ui]:new Batch}function returnBatchToPool(i){di[ui++]=i}let ci=0;const pi=class _Batcher{constructor(i={}){this.uid=uid("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],_Batcher.defaultOptions.maxTextures=_Batcher.defaultOptions.maxTextures??getMaxTexturesPerBatch(),i={..._Batcher.defaultOptions,...i};const{maxTextures:l,attributesInitialSize:p,indicesInitialSize:m}=i;this.attributeBuffer=new ViewableBuffer(4*p),this.indexBuffer=new Uint16Array(m),this.maxTextures=l}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let i=0;i<this.batchIndex;i++)returnBatchToPool(this.batches[i]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(i){this._elements[this.elementSize++]=i,i._indexStart=this.indexSize,i._attributeStart=this.attributeSize,i._batcher=this,this.indexSize+=i.indexSize,this.attributeSize+=i.attributeSize*this.vertexSize}checkAndUpdateTexture(i,l){const p=i._batch.textures.ids[l._source.uid];return!(!p&&0!==p)&&(i._textureId=p,i.texture=l,!0)}updateElement(i){this.dirty=!0;const l=this.attributeBuffer;i.packAsQuad?this.packQuadAttributes(i,l.float32View,l.uint32View,i._attributeStart,i._textureId):this.packAttributes(i,l.float32View,l.uint32View,i._attributeStart,i._textureId)}break(i){const l=this._elements;if(!l[this.elementStart])return;let p=getBatchFromPool(),m=p.textures;m.clear();const _=l[this.elementStart];let y=getAdjustedBlendModeBlend(_.blendMode,_.texture._source);4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const x=this.attributeBuffer.float32View,v=this.attributeBuffer.uint32View,T=this.indexBuffer;let S=this._batchIndexSize,P=this._batchIndexStart,C="startBatch";const E=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){const A=l[_];l[_]=null;const k=A.texture._source,B=getAdjustedBlendModeBlend(A.blendMode,k),F=y!==B;k._batchTick!==ci||F?(k._batchTick=ci,(m.count>=E||F)&&(this._finishBatch(p,P,S-P,m,y,i,C),C="renderBatch",P=S,y=B,p=getBatchFromPool(),m=p.textures,m.clear(),++ci),A._textureId=k._textureBindLocation=m.count,m.ids[k.uid]=m.count,m.textures[m.count++]=k,A._batch=p,S+=A.indexSize,A.packAsQuad?(this.packQuadAttributes(A,x,v,A._attributeStart,A._textureId),this.packQuadIndex(T,A._indexStart,A._attributeStart/this.vertexSize)):(this.packAttributes(A,x,v,A._attributeStart,A._textureId),this.packIndex(A,T,A._indexStart,A._attributeStart/this.vertexSize))):(A._textureId=k._textureBindLocation,S+=A.indexSize,A.packAsQuad?(this.packQuadAttributes(A,x,v,A._attributeStart,A._textureId),this.packQuadIndex(T,A._indexStart,A._attributeStart/this.vertexSize)):(this.packAttributes(A,x,v,A._attributeStart,A._textureId),this.packIndex(A,T,A._indexStart,A._attributeStart/this.vertexSize)),A._batch=p)}m.count>0&&(this._finishBatch(p,P,S-P,m,y,i,C),P=S,++ci),this.elementStart=this.elementSize,this._batchIndexStart=P,this._batchIndexSize=S}_finishBatch(i,l,p,m,_,y,x){i.gpuBindGroup=null,i.bindGroup=null,i.action=x,i.batcher=this,i.textures=m,i.blendMode=_,i.start=l,i.size=p,++ci,this.batches[this.batchIndex++]=i,y.add(i)}finish(i){this.break(i)}ensureAttributeBuffer(i){4*i<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*i)}ensureIndexBuffer(i){i<=this.indexBuffer.length||this._resizeIndexBuffer(i)}_resizeAttributeBuffer(i){const l=Math.max(i,2*this.attributeBuffer.size),p=new ViewableBuffer(l);fastCopy(this.attributeBuffer.rawBinaryData,p.rawBinaryData),this.attributeBuffer=p}_resizeIndexBuffer(i){const l=this.indexBuffer;let p=Math.max(i,1.5*l.length);p+=p%2;const m=p>65535?new Uint32Array(p):new Uint16Array(p);if(m.BYTES_PER_ELEMENT!==l.BYTES_PER_ELEMENT)for(let i=0;i<l.length;i++)m[i]=l[i];else fastCopy(l.buffer,m.buffer);this.indexBuffer=m}packQuadIndex(i,l,p){i[l]=p+0,i[l+1]=p+1,i[l+2]=p+2,i[l+3]=p+0,i[l+4]=p+2,i[l+5]=p+3}packIndex(i,l,p,m){const _=i.indices,y=i.indexSize,x=i.indexOffset,v=i.attributeOffset;for(let i=0;i<y;i++)l[p++]=m+_[i+x]-v}destroy(){for(let i=0;i<this.batches.length;i++)returnBatchToPool(this.batches[i]);this.batches=null;for(let i=0;i<this._elements.length;i++)this._elements[i]._batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};pi.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let fi=pi;var mi=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(mi||{});class Buffer extends V{constructor(i){let{data:l,size:p}=i;const{usage:m,label:_,shrinkToFit:y}=i;super(),this.uid=uid("buffer"),this._resourceType="buffer",this._resourceId=uid("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,l instanceof Array&&(l=new Float32Array(l)),this._data=l,p=p??l?.byteLength;const x=!!l;this.descriptor={size:p,usage:m,mappedAtCreation:x,label:_},this.shrinkToFit=y??!0}get data(){return this._data}set data(i){this.setDataWithSize(i,i.length,!0)}get static(){return!!(this.descriptor.usage&mi.STATIC)}set static(i){i?this.descriptor.usage|=mi.STATIC:this.descriptor.usage&=~mi.STATIC}setDataWithSize(i,l,p){if(this._updateID++,this._updateSize=l*i.BYTES_PER_ELEMENT,this._data===i)return void(p&&this.emit("update",this));const m=this._data;this._data=i,m.length===i.length||!this.shrinkToFit&&i.byteLength<m.byteLength?p&&this.emit("update",this):(this.descriptor.size=i.byteLength,this._resourceId=uid("resource"),this.emit("change",this))}update(i){this._updateSize=i??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function ensureIsBuffer(i,l){if(!(i instanceof Buffer)){let p=l?mi.INDEX:mi.VERTEX;i instanceof Array&&(l?(i=new Uint32Array(i),p=mi.INDEX|mi.COPY_DST):(i=new Float32Array(i),p=mi.VERTEX|mi.COPY_DST)),i=new Buffer({data:i,label:l?"index-mesh-buffer":"vertex-mesh-buffer",usage:p})}return i}function ensureIsAttribute(i){return(i instanceof Buffer||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=ensureIsBuffer(i.buffer,!1),i}class Geometry extends V{constructor(i){const{attributes:l,indexBuffer:p,topology:m}=i;super(),this.uid=uid("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Bounds,this._boundsDirty=!0,this.attributes=l,this.buffers=[],this.instanceCount=i.instanceCount||1;for(const i in l){const p=l[i]=ensureIsAttribute(l[i]);-1===this.buffers.indexOf(p.buffer)&&(this.buffers.push(p.buffer),p.buffer.on("update",this.onBufferUpdate,this),p.buffer.on("change",this.onBufferUpdate,this))}p&&(this.indexBuffer=ensureIsBuffer(p,!0),this.buffers.push(this.indexBuffer)),this.topology=m||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(i){return this.attributes[i]}getIndex(){return this.indexBuffer}getBuffer(i){return this.getAttribute(i).buffer}getSize(){for(const i in this.attributes){const l=this.attributes[i];return l.buffer.data.length/(l.stride/4||l.size)}return 0}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function getGeometryBounds(i,l,p){const m=i.getAttribute(l);if(!m)return p.minX=0,p.minY=0,p.maxX=0,p.maxY=0,p;const _=m.buffer.data;let y=1/0,x=1/0,v=-1/0,T=-1/0;const S=_.BYTES_PER_ELEMENT,P=(m.offset||0)/S,C=(m.stride||8)/S;for(let i=P;i<_.length;i+=C){const l=_[i],p=_[i+1];l>v&&(v=l),p>T&&(T=p),l<y&&(y=l),p<x&&(x=p)}return p.minX=y,p.minY=x,p.maxX=v,p.maxY=T,p}(this,"aPosition",this._bounds)):this._bounds}destroy(i=!1){this.emit("destroy",this),this.removeAllListeners(),i&&this.buffers.forEach((i=>i.destroy())),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const gi=new Float32Array(1),_i=new Uint32Array(1);class BatchGeometry extends Geometry{constructor(){const i=new Buffer({data:gi,label:"attribute-batch-buffer",usage:mi.VERTEX|mi.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:i,format:"float32x2",stride:24,offset:0},aUV:{buffer:i,format:"float32x2",stride:24,offset:8},aColor:{buffer:i,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:i,format:"uint16x2",stride:24,offset:20}},indexBuffer:new Buffer({data:_i,label:"index-batch-buffer",usage:mi.INDEX|mi.COPY_DST,shrinkToFit:!1})})}}function addBits(i,l,p){if(i)for(const m in i){const _=l[m.toLocaleLowerCase()];if(_){let l=i[m];"header"===m&&(l=l.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),p&&_.push(`//----${p}----//`),_.push(l)}else warn(`${m} placement hook does not exist in shader`)}}const yi=/\{\{(.*?)\}\}/g;function compileHooks(i){const l={};return(i.match(yi)?.map((i=>i.replace(/[{()}]/g,"")))??[]).forEach((i=>{l[i]=[]})),l}function extractInputs(i,l){let p;const m=/@in\s+([^;]+);/g;for(;null!==(p=m.exec(i));)l.push(p[1])}function compileInputs(i,l,p=!1){const m=[];extractInputs(l,m),i.forEach((i=>{i.header&&extractInputs(i.header,m)}));const _=m;p&&_.sort();const y=_.map(((i,l)=>` @location(${l}) ${i},`)).join("\n");let x=l.replace(/@in\s+[^;]+;\s*/g,"");return x=x.replace("{{in}}",`\n${y}\n`),x}function extractOutputs(i,l){let p;const m=/@out\s+([^;]+);/g;for(;null!==(p=m.exec(i));)l.push(p[1])}function injectBits(i,l){let p=i;for(const i in l){const m=l[i];p=m.join("\n").length?p.replace(`{{${i}}}`,`//-----${i} START-----//\n${m.join("\n")}\n//----${i} FINISH----//`):p.replace(`{{${i}}}`,"")}return p}const xi=Object.create(null),vi=new Map;let bi=0;function compileHighShader({template:i,bits:l}){const p=generateCacheId(i,l);if(xi[p])return xi[p];const{vertex:m,fragment:_}=function compileInputsAndOutputs(i,l){const p=l.map((i=>i.vertex)).filter((i=>!!i)),m=l.map((i=>i.fragment)).filter((i=>!!i));let _=compileInputs(p,i.vertex,!0);_=function compileOutputs(i,l){const p=[];extractOutputs(l,p),i.forEach((i=>{i.header&&extractOutputs(i.header,p)}));let m=0;const _=p.sort().map((i=>i.indexOf("builtin")>-1?i:`@location(${m++}) ${i}`)).join(",\n"),y=p.sort().map((i=>` var ${function stripVariable(i){return i.replace(/@.*?\s+/g,"")}(i)};`)).join("\n"),x=`return VSOutput(\n ${p.sort().map((i=>` ${function extractVariableName(i){const l=/\b(\w+)\s*:/g.exec(i);return l?l[1]:""}(i)}`)).join(",\n")});`;let v=l.replace(/@out\s+[^;]+;\s*/g,"");return v=v.replace("{{struct}}",`\n${_}\n`),v=v.replace("{{start}}",`\n${y}\n`),v=v.replace("{{return}}",`\n${x}\n`),v}(p,_);const y=compileInputs(m,i.fragment,!0);return{vertex:_,fragment:y}}(i,l);return xi[p]=compileBits(m,_,l),xi[p]}function compileHighShaderGl({template:i,bits:l}){const p=generateCacheId(i,l);return xi[p]||(xi[p]=compileBits(i.vertex,i.fragment,l)),xi[p]}function generateCacheId(i,l){return l.map((i=>(vi.has(i)||vi.set(i,bi++),vi.get(i)))).sort(((i,l)=>i-l)).join("-")+i.vertex+i.fragment}function compileBits(i,l,p){const m=compileHooks(i),_=compileHooks(l);return p.forEach((i=>{addBits(i.vertex,m,i.name),addBits(i.fragment,_,i.name)})),{vertex:injectBits(i,m),fragment:injectBits(l,_)}}const wi={name:"global-uniforms-bit",vertex:{header:"\n struct GlobalUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uWorldTransformMatrix:mat3x3<f32>,\n uWorldColorAlpha: vec4<f32>,\n uResolution: vec2<f32>,\n }\n\n @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;\n "}},Ti={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}};function compileHighShaderGpuProgram({bits:i,name:l}){const p=compileHighShader({template:{fragment:"\n @in vUV : vec2<f32>;\n @in vColor : vec4<f32>;\n \n {{header}}\n\n @fragment\n fn main(\n {{in}}\n ) -> @location(0) vec4<f32> {\n \n {{start}}\n\n var outColor:vec4<f32>;\n \n {{main}}\n \n var finalColor:vec4<f32> = outColor * vColor;\n\n {{end}}\n\n return finalColor;\n };\n",vertex:"\n @in aPosition: vec2<f32>;\n @in aUV: vec2<f32>;\n\n @out @builtin(position) vPosition: vec4<f32>;\n @out vUV : vec2<f32>;\n @out vColor : vec4<f32>;\n\n {{header}}\n\n struct VSOutput {\n {{struct}}\n };\n\n @vertex\n fn main( {{in}} ) -> VSOutput {\n\n var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;\n var modelMatrix = mat3x3<f32>(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n var position = aPosition;\n var uv = aUV;\n\n {{start}}\n \n vColor = vec4<f32>(1., 1., 1., 1.);\n\n {{main}}\n\n vUV = uv;\n\n var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);\n \n vColor *= globalUniforms.uWorldColorAlpha;\n\n {{end}}\n\n {{return}}\n };\n"},bits:[wi,...i]});return GpuProgram.from({name:l,vertex:{source:p.vertex,entryPoint:"main"},fragment:{source:p.fragment,entryPoint:"main"}})}function compileHighShaderGlProgram({bits:i,name:l}){return new Le({name:l,...compileHighShaderGl({template:{vertex:"\n in vec2 aPosition;\n in vec2 aUV;\n\n out vec4 vColor;\n out vec2 vUV;\n\n {{header}}\n\n void main(void){\n\n mat3 worldTransformMatrix = uWorldTransformMatrix;\n mat3 modelMatrix = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n vec2 position = aPosition;\n vec2 uv = aUV;\n \n {{start}}\n \n vColor = vec4(1.);\n \n {{main}}\n \n vUV = uv;\n \n mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= uWorldColorAlpha;\n\n {{end}}\n }\n",fragment:"\n \n in vec4 vColor;\n in vec2 vUV;\n\n out vec4 finalColor;\n\n {{header}}\n\n void main(void) {\n \n {{start}}\n\n vec4 outColor;\n \n {{main}}\n \n finalColor = outColor * vColor;\n \n {{end}}\n }\n"},bits:[Ti,...i]})})}const Si={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},Pi={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},Mi={};function generateBindingSrc(i){const l=[];if(1===i)l.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),l.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let p=0;for(let m=0;m<i;m++)l.push(`@group(1) @binding(${p++}) var textureSource${m+1}: texture_2d<f32>;`),l.push(`@group(1) @binding(${p++}) var textureSampler${m+1}: sampler;`)}return l.join("\n")}function generateSampleSrc(i){const l=[];if(1===i)l.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{l.push("switch vTextureId {");for(let p=0;p<i;p++)p===i-1?l.push(" default:{"):l.push(` case ${p}:{`),l.push(` outColor = textureSampleGrad(textureSource${p+1}, textureSampler${p+1}, vUV, uvDx, uvDy);`),l.push(" break;}");l.push("}")}return l.join("\n")}function generateTextureBatchBit(i){return Mi[i]||(Mi[i]={name:"texture-batch-bit",vertex:{header:"\n @in aTextureIdAndRound: vec2<u32>;\n @out @interpolate(flat) vTextureId : u32;\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1)\n {\n vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:`\n @in @interpolate(flat) vTextureId: u32;\n\n ${generateBindingSrc(i)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${generateSampleSrc(i)}\n `}}),Mi[i]}const Ci={};function generateSampleGlSrc(i){const l=[];for(let p=0;p<i;p++)p>0&&l.push("else"),p<i-1&&l.push(`if(vTextureId < ${p}.5)`),l.push("{"),l.push(`\toutColor = texture(uTextures[${p}], vUV);`),l.push("}");return l.join("\n")}function generateTextureBatchBitGl(i){return Ci[i]||(Ci[i]={name:"texture-batch-bit",vertex:{header:"\n in vec2 aTextureIdAndRound;\n out float vTextureId;\n\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:`\n in float vTextureId;\n\n uniform sampler2D uTextures[${i}];\n\n `,main:`\n\n ${generateSampleGlSrc(i)}\n `}}),Ci[i]}const Ei={name:"round-pixels-bit",vertex:{header:"\n fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32> \n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},Ai={name:"round-pixels-bit",vertex:{header:" \n vec2 roundPixels(vec2 position, vec2 targetSize)\n { \n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},ki={};function getBatchSamplersUniformGroup(i){let l=ki[i];if(l)return l;const p=new Int32Array(i);for(let l=0;l<i;l++)p[l]=l;return l=ki[i]=new Ke({uTextures:{value:p,type:"i32",size:i}},{isStatic:!0}),l}class DefaultShader extends Shader{constructor(i){super({glProgram:compileHighShaderGlProgram({name:"batch",bits:[Pi,generateTextureBatchBitGl(i),Ai]}),gpuProgram:compileHighShaderGpuProgram({name:"batch",bits:[Si,generateTextureBatchBit(i),Ei]}),resources:{batchSamplers:getBatchSamplersUniformGroup(i)}})}}let Bi=null;const Fi=class _DefaultBatcher extends fi{constructor(){super(...arguments),this.geometry=new BatchGeometry,this.shader=Bi||(Bi=new DefaultShader(this.maxTextures)),this.name=_DefaultBatcher.extension.name,this.vertexSize=6}packAttributes(i,l,p,m,_){const y=_<<16|65535&i.roundPixels,x=i.transform,v=x.a,T=x.b,S=x.c,P=x.d,C=x.tx,E=x.ty,{positions:A,uvs:k}=i,B=i.color,F=i.attributeOffset,R=F+i.attributeSize;for(let i=F;i<R;i++){const _=2*i,x=A[_],F=A[_+1];l[m++]=v*x+S*F+C,l[m++]=P*F+T*x+E,l[m++]=k[_],l[m++]=k[_+1],p[m++]=B,p[m++]=y}}packQuadAttributes(i,l,p,m,_){const y=i.texture,x=i.transform,v=x.a,T=x.b,S=x.c,P=x.d,C=x.tx,E=x.ty,A=i.bounds,k=A.maxX,B=A.minX,F=A.maxY,R=A.minY,I=y.uvs,D=i.color,L=_<<16|65535&i.roundPixels;l[m+0]=v*B+S*R+C,l[m+1]=P*R+T*B+E,l[m+2]=I.x0,l[m+3]=I.y0,p[m+4]=D,p[m+5]=L,l[m+6]=v*k+S*R+C,l[m+7]=P*R+T*k+E,l[m+8]=I.x1,l[m+9]=I.y1,p[m+10]=D,p[m+11]=L,l[m+12]=v*k+S*F+C,l[m+13]=P*F+T*k+E,l[m+14]=I.x2,l[m+15]=I.y2,p[m+16]=D,p[m+17]=L,l[m+18]=v*B+S*F+C,l[m+19]=P*F+T*B+E,l[m+20]=I.x3,l[m+21]=I.y3,p[m+22]=D,p[m+23]=L}};Fi.extension={type:[O.Batcher],name:"default"};let Ri=Fi;function transformVertices(i,l,p,m,_){const y=l.a,x=l.b,v=l.c,T=l.d,S=l.tx,P=l.ty;p=p||0,m=m||2,_=_||i.length/m-p;let C=p*m;for(let l=0;l<_;l++){const l=i[C],p=i[C+1];i[C]=y*l+v*p+S,i[C+1]=x*l+T*p+P,C+=m}}const Ii=new Matrix;class BatchableGraphics{constructor(){this.packAsQuad=!1,this.batcherName="default",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.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const i=this.baseColor,l=i>>16|65280&i|(255&i)<<16,p=this.renderable;return p?function multiplyHexColors(i,l){return 16777215!==i&&l?16777215!==l&&i?((i>>16&255)*(l>>16&255)/255<<16)+((i>>8&255)*(l>>8&255)/255<<8)+(255&i)*(255&l)/255:i:l}(l,p.groupColor)+(this.alpha*p.groupAlpha*255<<24):l+(255*this.alpha<<24)}get transform(){return this.renderable?.groupTransform||Ii}copyTo(i){i.indexOffset=this.indexOffset,i.indexSize=this.indexSize,i.attributeOffset=this.attributeOffset,i.attributeSize=this.attributeSize,i.baseColor=this.baseColor,i.alpha=this.alpha,i.texture=this.texture,i.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const Di={extension:{type:O.ShapeBuilder,name:"circle"},build(i,l){let p,m,_,y,x,v;if("circle"===i.type){const l=i;p=l.x,m=l.y,x=v=l.radius,_=y=0}else if("ellipse"===i.type){const l=i;p=l.x,m=l.y,x=l.halfWidth,v=l.halfHeight,_=y=0}else{const l=i,T=l.width/2,S=l.height/2;p=l.x+T,m=l.y+S,x=v=Math.max(0,Math.min(l.radius,Math.min(T,S))),_=T-x,y=S-v}if(!(x>=0&&v>=0&&_>=0&&y>=0))return l;const T=Math.ceil(2.3*Math.sqrt(x+v)),S=8*T+(_?4:0)+(y?4:0);if(0===S)return l;if(0===T)return l[0]=l[6]=p+_,l[1]=l[3]=m+y,l[2]=l[4]=p-_,l[5]=l[7]=m-y,l;let P=0,C=4*T+(_?2:0)+2,E=C,A=S,k=_+x,B=y,F=p+k,R=p-k,I=m+B;if(l[P++]=F,l[P++]=I,l[--C]=I,l[--C]=R,y){const i=m-B;l[E++]=R,l[E++]=i,l[--A]=i,l[--A]=F}for(let i=1;i<T;i++){const S=Math.PI/2*(i/T),k=_+Math.cos(S)*x,B=y+Math.sin(S)*v,F=p+k,R=p-k,I=m+B,D=m-B;l[P++]=F,l[P++]=I,l[--C]=I,l[--C]=R,l[E++]=R,l[E++]=D,l[--A]=D,l[--A]=F}k=_,B=y+v,F=p+k,R=p-k,I=m+B;const D=m-B;return l[P++]=F,l[P++]=I,l[--A]=D,l[--A]=F,_&&(l[P++]=R,l[P++]=I,l[--A]=D,l[--A]=R),l},triangulate(i,l,p,m,_,y){if(0===i.length)return;let x=0,v=0;for(let l=0;l<i.length;l+=2)x+=i[l],v+=i[l+1];x/=i.length/2,v/=i.length/2;let T=m;l[T*p]=x,l[T*p+1]=v;const S=T++;for(let m=0;m<i.length;m+=2)l[T*p]=i[m],l[T*p+1]=i[m+1],m>0&&(_[y++]=T,_[y++]=S,_[y++]=T-1),T++;_[y++]=S+1,_[y++]=S,_[y++]=T-1}},Li={...Di,extension:{...Di.extension,name:"ellipse"}},Ui={...Di,extension:{...Di.extension,name:"roundedRectangle"}},Gi=1e-4,Oi=1e-4;function square(i,l,p,m,_,y,x,v){let T,S;x?(T=m,S=-p):(T=-m,S=p);const P=i-p*_+T,C=l-m*_+S,E=i+p*y+T,A=l+m*y+S;return v.push(P,C),v.push(E,A),2}function round(i,l,p,m,_,y,x,v){const T=p-i,S=m-l;let P=Math.atan2(T,S),C=Math.atan2(_-i,y-l);v&&P<C?P+=2*Math.PI:!v&&P>C&&(C+=2*Math.PI);let E=P;const A=C-P,k=Math.abs(A),B=Math.sqrt(T*T+S*S),F=1+(15*k*Math.sqrt(B)/Math.PI|0),R=A/F;if(E+=R,v){x.push(i,l),x.push(p,m);for(let p=1,m=E;p<F;p++,m+=R)x.push(i,l),x.push(i+Math.sin(m)*B,l+Math.cos(m)*B);x.push(i,l),x.push(_,y)}else{x.push(p,m),x.push(i,l);for(let p=1,m=E;p<F;p++,m+=R)x.push(i+Math.sin(m)*B,l+Math.cos(m)*B),x.push(i,l);x.push(_,y),x.push(i,l)}return 2*F}function triangulateWithHoles(i,l,p,m,_,y,x){const v=qe(i,l,2);if(!v)return;for(let i=0;i<v.length;i+=3)y[x++]=v[i]+_,y[x++]=v[i+1]+_,y[x++]=v[i+2]+_;let T=_*m;for(let l=0;l<i.length;l+=2)p[T]=i[l],p[T+1]=i[l+1],T+=m}const zi=[],Ni={extension:{type:O.ShapeBuilder,name:"polygon"},build(i,l){for(let p=0;p<i.points.length;p++)l[p]=i.points[p];return l},triangulate(i,l,p,m,_,y){triangulateWithHoles(i,zi,l,p,m,_,y)}},Hi={extension:{type:O.ShapeBuilder,name:"rectangle"},build(i,l){const p=i,m=p.x,_=p.y,y=p.width,x=p.height;return y>=0&&x>=0?(l[0]=m,l[1]=_,l[2]=m+y,l[3]=_,l[4]=m+y,l[5]=_+x,l[6]=m,l[7]=_+x,l):l},triangulate(i,l,p,m,_,y){let x=0;l[(m*=p)+x]=i[0],l[m+x+1]=i[1],x+=p,l[m+x]=i[2],l[m+x+1]=i[3],x+=p,l[m+x]=i[6],l[m+x+1]=i[7],x+=p,l[m+x]=i[4],l[m+x+1]=i[5],x+=p;const v=m/p;_[y++]=v,_[y++]=v+1,_[y++]=v+2,_[y++]=v+1,_[y++]=v+3,_[y++]=v+2}},Wi={extension:{type:O.ShapeBuilder,name:"triangle"},build:(i,l)=>(l[0]=i.x,l[1]=i.y,l[2]=i.x2,l[3]=i.y2,l[4]=i.x3,l[5]=i.y3,l),triangulate(i,l,p,m,_,y){let x=0;l[(m*=p)+x]=i[0],l[m+x+1]=i[1],x+=p,l[m+x]=i[2],l[m+x+1]=i[3],x+=p,l[m+x]=i[4],l[m+x+1]=i[5];const v=m/p;_[y++]=v,_[y++]=v+1,_[y++]=v+2}},Ki={};z.handleByMap(O.ShapeBuilder,Ki),z.add(Hi,Ni,Wi,Di,Li,Ui);const Yi=new Rectangle;function addTextureToGeometryData(i,l,p){const{vertices:m,uvs:_,indices:y}=p,x=y.length,v=m.length/2,T=[],S=Ki.rectangle,P=Yi,C=i.image;P.x=i.dx,P.y=i.dy,P.width=i.dw,P.height=i.dh;const E=i.transform;S.build(P,T),E&&transformVertices(T,E),S.triangulate(T,m,2,v,y,x);const A=C.uvs;_.push(A.x0,A.y0,A.x1,A.y1,A.x3,A.y3,A.x2,A.y2);const k=kt.get(BatchableGraphics);k.indexOffset=x,k.indexSize=y.length-x,k.attributeOffset=v,k.attributeSize=m.length/2-v,k.baseColor=i.style,k.alpha=i.alpha,k.texture=C,k.geometryData=p,l.push(k)}function addShapePathToGeometryData(i,l,p,m,_,y){const{vertices:x,uvs:v,indices:T}=y,S=i.shapePrimitives.length-1;i.shapePrimitives.forEach((({shape:i,transform:P},C)=>{const E=T.length,A=x.length/2,k=[],B=Ki[i.type];if(B.build(i,k),P&&transformVertices(k,P),m){const p=i.closePath??!0;!function buildLine(i,l,p,m,_,y,x,v,T){const S=Gi;if(0===i.length)return;const P=l;let C=P.alignment;if(.5!==l.alignment){let l=function getOrientationOfPoints(i){const l=i.length;if(l<6)return 1;let p=0;for(let m=0,_=i[l-2],y=i[l-1];m<l;m+=2){const l=i[m],x=i[m+1];p+=(l-_)*(x+y),_=l,y=x}return p<0?-1:1}(i);C=(C-.5)*l+.5}const E=new Point(i[0],i[1]),A=new Point(i[i.length-2],i[i.length-1]),k=m,B=Math.abs(E.x-A.x)<S&&Math.abs(E.y-A.y)<S;if(k){i=i.slice(),B&&(i.pop(),i.pop(),A.set(i[i.length-2],i[i.length-1]));const l=.5*(E.x+A.x),p=.5*(A.y+E.y);i.unshift(l,p),i.push(l,p)}const F=_,R=i.length/2;let I=i.length;const D=F.length/2,L=P.width/2,U=L*L,G=P.miterLimit*P.miterLimit;let O=i[0],z=i[1],W=i[2],K=i[3],Y=0,V=0,X=-(z-K),j=O-W,q=0,Z=0,Q=Math.sqrt(X*X+j*j);X/=Q,j/=Q,X*=L,j*=L;const J=2*(1-C),tt=2*C;k||("round"===P.cap?I+=round(O-X*(J-tt)*.5,z-j*(J-tt)*.5,O-X*J,z-j*J,O+X*tt,z+j*tt,F,!0)+2:"square"===P.cap&&(I+=square(O,z,X,j,J,tt,!0,F))),F.push(O-X*J,z-j*J),F.push(O+X*tt,z+j*tt);for(let l=1;l<R-1;++l){O=i[2*(l-1)],z=i[2*(l-1)+1],W=i[2*l],K=i[2*l+1],Y=i[2*(l+1)],V=i[2*(l+1)+1],X=-(z-K),j=O-W,Q=Math.sqrt(X*X+j*j),X/=Q,j/=Q,X*=L,j*=L,q=-(K-V),Z=W-Y,Q=Math.sqrt(q*q+Z*Z),q/=Q,Z/=Q,q*=L,Z*=L;const p=W-O,m=z-K,_=W-Y,y=V-K,x=p*_+m*y,v=m*_-y*p,T=v<0;if(Math.abs(v)<.001*Math.abs(x)){F.push(W-X*J,K-j*J),F.push(W+X*tt,K+j*tt),x>=0&&("round"===P.join?I+=round(W,K,W-X*J,K-j*J,W-q*J,K-Z*J,F,!1)+4:I+=2,F.push(W-q*tt,K-Z*tt),F.push(W+q*J,K+Z*J));continue}const S=(-X+O)*(-j+K)-(-X+W)*(-j+z),C=(-q+Y)*(-Z+K)-(-q+W)*(-Z+V),E=(p*C-_*S)/v,A=(y*S-m*C)/v,k=(E-W)*(E-W)+(A-K)*(A-K),B=W+(E-W)*J,R=K+(A-K)*J,D=W-(E-W)*tt,et=K-(A-K)*tt,it=T?J:tt;k<=Math.min(p*p+m*m,_*_+y*y)+it*it*U?"bevel"===P.join||k/U>G?(T?(F.push(B,R),F.push(W+X*tt,K+j*tt),F.push(B,R),F.push(W+q*tt,K+Z*tt)):(F.push(W-X*J,K-j*J),F.push(D,et),F.push(W-q*J,K-Z*J),F.push(D,et)),I+=2):"round"===P.join?T?(F.push(B,R),F.push(W+X*tt,K+j*tt),I+=round(W,K,W+X*tt,K+j*tt,W+q*tt,K+Z*tt,F,!0)+4,F.push(B,R),F.push(W+q*tt,K+Z*tt)):(F.push(W-X*J,K-j*J),F.push(D,et),I+=round(W,K,W-X*J,K-j*J,W-q*J,K-Z*J,F,!1)+4,F.push(W-q*J,K-Z*J),F.push(D,et)):(F.push(B,R),F.push(D,et)):(F.push(W-X*J,K-j*J),F.push(W+X*tt,K+j*tt),"round"===P.join?I+=T?round(W,K,W+X*tt,K+j*tt,W+q*tt,K+Z*tt,F,!0)+2:round(W,K,W-X*J,K-j*J,W-q*J,K-Z*J,F,!1)+2:"miter"===P.join&&k/U<=G&&(T?(F.push(D,et),F.push(D,et)):(F.push(B,R),F.push(B,R)),I+=2),F.push(W-q*J,K-Z*J),F.push(W+q*tt,K+Z*tt),I+=2)}O=i[2*(R-2)],z=i[2*(R-2)+1],W=i[2*(R-1)],K=i[2*(R-1)+1],X=-(z-K),j=O-W,Q=Math.sqrt(X*X+j*j),X/=Q,j/=Q,X*=L,j*=L,F.push(W-X*J,K-j*J),F.push(W+X*tt,K+j*tt),k||("round"===P.cap?I+=round(W-X*(J-tt)*.5,K-j*(J-tt)*.5,W-X*J,K-j*J,W+X*tt,K+j*tt,F,!1)+2:"square"===P.cap&&(I+=square(W,K,X,j,J,tt,!1,F)));const et=Oi*Oi;for(let i=D;i<I+D-2;++i)O=F[2*i],z=F[2*i+1],W=F[2*(i+1)],K=F[2*(i+1)+1],Y=F[2*(i+2)],V=F[2*(i+2)+1],Math.abs(O*(K-V)+W*(V-z)+Y*(z-K))<et||v.push(i,i+1,i+2)}(k,l,0,p,x,0,0,T)}else if(p&&S===C){0!==S&&console.warn("[Pixi Graphics] only the last shape have be cut out");const i=[],l=k.slice(),m=function getHoleArrays(i){if(!i)return[];const l=i.shapePrimitives,p=[];for(let i=0;i<l.length;i++){const m=l[i].shape,_=[];Ki[m.type].build(m,_),p.push(_)}return p}(p.shapePath);m.forEach((p=>{i.push(l.length/2),l.push(...p)})),triangulateWithHoles(l,i,x,2,A,T,E)}else B.triangulate(k,x,2,A,T,E);const F=v.length/2,R=l.texture;if(R!==Texture.WHITE){const i=l.matrix;i&&(P&&i.append(P.clone().invert()),function buildUvs(i,l,p,m,_,y,x,v=null){let T=0;p*=l,_*=y;const S=v.a,P=v.b,C=v.c,E=v.d,A=v.tx,k=v.ty;for(;T<x;){const x=i[p],v=i[p+1];m[_]=S*x+C*v+A,m[_+1]=P*x+E*v+k,_+=y,p+=l,T++}}(x,2,A,v,F,2,x.length/2-A,i))}else!function buildSimpleUvs(i,l,p,m){let _=0;for(l*=p;_<m;)i[l]=0,i[l+1]=0,l+=p,_++}(v,F,2,x.length/2-A);const I=kt.get(BatchableGraphics);I.indexOffset=E,I.indexSize=T.length-E,I.attributeOffset=A,I.attributeSize=x.length/2-A,I.baseColor=l.color,I.alpha=l.alpha,I.texture=R,I.geometryData=y,_.push(I)}))}class GpuGraphicsContext{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class GraphicsContextRenderData{constructor(){this.batcher=new Ri,this.instructions=new InstructionSet}init(){this.instructions.reset()}get geometry(){return deprecation("8.3.4","GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const Vi=class _GraphicsContextSystem{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(i){_GraphicsContextSystem.defaultOptions.bezierSmoothness=i?.bezierSmoothness??_GraphicsContextSystem.defaultOptions.bezierSmoothness}getContextRenderData(i){return this._graphicsDataContextHash[i.uid]||this._initContextRenderData(i)}updateGpuContext(i){let l=this._gpuContextHash[i.uid]||this._initContext(i);if(i.dirty){l?this._cleanGraphicsContextData(i):l=this._initContext(i),function buildContextBatches(i,l){const{geometryData:p,batches:m}=l;m.length=0,p.indices.length=0,p.vertices.length=0,p.uvs.length=0;for(let l=0;l<i.instructions.length;l++){const _=i.instructions[l];if("texture"===_.action)addTextureToGeometryData(_.data,m,p);else if("fill"===_.action||"stroke"===_.action){const i="stroke"===_.action,l=_.data.path.shapePath,y=_.data.style,x=_.data.hole;i&&x&&addShapePathToGeometryData(x.shapePath,y,null,!0,m,p),addShapePathToGeometryData(l,y,x,i,m,p)}}}(i,l);const p=i.batchMode;i.customShader||"no-batch"===p?l.isBatchable=!1:"auto"===p&&(l.isBatchable=l.geometryData.vertices.length<400),i.dirty=!1}return l}getGpuContext(i){return this._gpuContextHash[i.uid]||this._initContext(i)}_initContextRenderData(i){const l=kt.get(GraphicsContextRenderData),{batches:p,geometryData:m}=this._gpuContextHash[i.uid],_=m.vertices.length,y=m.indices.length;for(let i=0;i<p.length;i++)p[i].applyTransform=!1;const x=l.batcher;x.ensureAttributeBuffer(_),x.ensureIndexBuffer(y),x.begin();for(let i=0;i<p.length;i++){const l=p[i];x.add(l)}x.finish(l.instructions);const v=x.geometry;v.indexBuffer.setDataWithSize(x.indexBuffer,x.indexSize,!0),v.buffers[0].setDataWithSize(x.attributeBuffer.float32View,x.attributeSize,!0);const T=x.batches;for(let i=0;i<T.length;i++){const l=T[i];l.bindGroup=getTextureBatchBindGroup(l.textures.textures,l.textures.count)}return this._graphicsDataContextHash[i.uid]=l,l}_initContext(i){const l=new GpuGraphicsContext;return l.context=i,this._gpuContextHash[i.uid]=l,i.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[i.uid]}onGraphicsContextDestroy(i){this._cleanGraphicsContextData(i),i.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[i.uid]=null}_cleanGraphicsContextData(i){const l=this._gpuContextHash[i.uid];l.isBatchable||this._graphicsDataContextHash[i.uid]&&(kt.return(this.getContextRenderData(i)),this._graphicsDataContextHash[i.uid]=null),l.batches&&l.batches.forEach((i=>{kt.return(i)}))}destroy(){for(const i in this._gpuContextHash)this._gpuContextHash[i]&&this.onGraphicsContextDestroy(this._gpuContextHash[i].context)}};Vi.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"graphicsContext"},Vi.defaultOptions={bezierSmoothness:.5};let $i=Vi;const Xi=8,ji=1.1920929e-7,qi=1;function buildAdaptiveBezier(i,l,p,m,_,y,x,v,T,S){const P=Math.min(.99,Math.max(0,S??$i.defaultOptions.bezierSmoothness));let C=(qi-P)/1;return C*=C,function begin$1(i,l,p,m,_,y,x,v,T,S){recursive$1(i,l,p,m,_,y,x,v,T,S,0),T.push(x,v)}(l,p,m,_,y,x,v,T,i,C),i}function recursive$1(i,l,p,m,_,y,x,v,T,S,P){if(P>Xi)return;const C=(i+p)/2,E=(l+m)/2,A=(p+_)/2,k=(m+y)/2,B=(_+x)/2,F=(y+v)/2,R=(C+A)/2,I=(E+k)/2,D=(A+B)/2,L=(k+F)/2,U=(R+D)/2,G=(I+L)/2;if(P>0){let P=x-i,C=v-l;const E=Math.abs((p-x)*C-(m-v)*P),A=Math.abs((_-x)*C-(y-v)*P);if(E>ji&&A>ji){if((E+A)*(E+A)<=S*(P*P+C*C))return void T.push(U,G)}else if(E>ji){if(E*E<=S*(P*P+C*C))return void T.push(U,G)}else if(A>ji){if(A*A<=S*(P*P+C*C))return void T.push(U,G)}else if(P=U-(i+x)/2,C=G-(l+v)/2,P*P+C*C<=S)return void T.push(U,G)}recursive$1(i,l,C,E,R,I,U,G,T,S,P+1),recursive$1(U,G,D,L,B,F,x,v,T,S,P+1)}const Zi=8,Qi=1.1920929e-7;function buildAdaptiveQuadratic(i,l,p,m,_,y,x,v){let T=(1-Math.min(.99,Math.max(0,v??$i.defaultOptions.bezierSmoothness)))/1;return T*=T,function begin(i,l,p,m,_,y,x,v){recursive(x,i,l,p,m,_,y,v,0),x.push(_,y)}(l,p,m,_,y,x,i,T),i}function recursive(i,l,p,m,_,y,x,v,T){if(T>Zi)return;const S=(l+m)/2,P=(p+_)/2,C=(m+y)/2,E=(_+x)/2,A=(S+C)/2,k=(P+E)/2;let B=y-l,F=x-p;const R=Math.abs((m-y)*F-(_-x)*B);if(R>Qi){if(R*R<=v*(B*B+F*F))return void i.push(A,k)}else if(B=A-(l+y)/2,F=k-(p+x)/2,B*B+F*F<=v)return void i.push(A,k);recursive(i,l,p,S,P,A,k,v,T+1),recursive(i,A,k,C,E,y,x,v,T+1)}function buildArc(i,l,p,m,_,y,x,v){let T=Math.abs(_-y);(!x&&_>y||x&&y>_)&&(T=2*Math.PI-T),v=v||Math.max(6,Math.floor(6*Math.pow(m,1/3)*(T/Math.PI)));let S=T/(v=Math.max(v,3)),P=_;S*=x?-1:1;for(let _=0;_<v+1;_++){const _=l+Math.cos(P)*m,y=p+Math.sin(P)*m;i.push(_,y),P+=S}}const Ji=2*Math.PI,ts={centerX:0,centerY:0,ang1:0,ang2:0},mapToEllipse=({x:i,y:l},p,m,_,y,x,v,T)=>{const S=_*(i*=p)-y*(l*=m),P=y*i+_*l;return T.x=S+x,T.y=P+v,T};function approxUnitArc(i,l){const p=-1.5707963267948966===l?-.551915024494:4/3*Math.tan(l/4),m=1.5707963267948966===l?.551915024494:p,_=Math.cos(i),y=Math.sin(i),x=Math.cos(i+l),v=Math.sin(i+l);return[{x:_-y*m,y:y+_*m},{x:x+v*m,y:v-x*m},{x:x,y:v}]}const vectorAngle=(i,l,p,m)=>{let _=i*p+l*m;return _>1&&(_=1),_<-1&&(_=-1),(i*m-l*p<0?-1:1)*Math.acos(_)};function buildArcToSvg(i,l,p,m,_,y,x,v=0,T=0,S=0){if(0===y||0===x)return;const P=Math.sin(v*Ji/360),C=Math.cos(v*Ji/360),E=C*(l-m)/2+P*(p-_)/2,A=-P*(l-m)/2+C*(p-_)/2;if(0===E&&0===A)return;y=Math.abs(y),x=Math.abs(x);const k=Math.pow(E,2)/Math.pow(y,2)+Math.pow(A,2)/Math.pow(x,2);k>1&&(y*=Math.sqrt(k),x*=Math.sqrt(k)),((i,l,p,m,_,y,x,v,T,S,P,C,E)=>{const A=Math.pow(_,2),k=Math.pow(y,2),B=Math.pow(P,2),F=Math.pow(C,2);let R=A*k-A*F-k*B;R<0&&(R=0),R/=A*F+k*B,R=Math.sqrt(R)*(x===v?-1:1);const I=R*_/y*C,D=R*-y/_*P,L=S*I-T*D+(i+p)/2,U=T*I+S*D+(l+m)/2,G=(P-I)/_,O=(C-D)/y,z=(-P-I)/_,W=(-C-D)/y,K=vectorAngle(1,0,G,O);let Y=vectorAngle(G,O,z,W);0===v&&Y>0&&(Y-=Ji),1===v&&Y<0&&(Y+=Ji),E.centerX=L,E.centerY=U,E.ang1=K,E.ang2=Y})(l,p,m,_,y,x,T,S,P,C,E,A,ts);let{ang1:B,ang2:F}=ts;const{centerX:R,centerY:I}=ts;let D=Math.abs(F)/(Ji/4);Math.abs(1-D)<1e-7&&(D=1);const L=Math.max(Math.ceil(D),1);F/=L;let U=i[i.length-2],G=i[i.length-1];const O={x:0,y:0};for(let l=0;l<L;l++){const l=approxUnitArc(B,F),{x:p,y:m}=mapToEllipse(l[0],y,x,C,P,R,I,O),{x:_,y:v}=mapToEllipse(l[1],y,x,C,P,R,I,O),{x:T,y:S}=mapToEllipse(l[2],y,x,C,P,R,I,O);buildAdaptiveBezier(i,U,G,p,m,_,v,T,S),U=T,G=S,B+=F}}const es=new Rectangle;class ShapePath{constructor(i){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Bounds,this._graphicsPath2D=i}moveTo(i,l){return this.startPoly(i,l),this}lineTo(i,l){this._ensurePoly();const p=this._currentPoly.points,m=p[p.length-2],_=p[p.length-1];return m===i&&_===l||p.push(i,l),this}arc(i,l,p,m,_,y){this._ensurePoly(!1);return buildArc(this._currentPoly.points,i,l,p,m,_,y),this}arcTo(i,l,p,m,_){this._ensurePoly();return function buildArcTo(i,l,p,m,_,y){const x=i[i.length-2],v=i[i.length-1]-p,T=x-l,S=_-p,P=m-l,C=Math.abs(v*P-T*S);if(C<1e-8||0===y)return void(i[i.length-2]===l&&i[i.length-1]===p||i.push(l,p));const E=v*v+T*T,A=S*S+P*P,k=v*S+T*P,B=y*Math.sqrt(E)/C,F=y*Math.sqrt(A)/C,R=B*k/E,I=F*k/A,D=B*P+F*T,L=B*S+F*v,U=T*(F+R),G=v*(F+R),O=P*(B+I),z=S*(B+I);buildArc(i,D+l,L+p,y,Math.atan2(G-L,U-D),Math.atan2(z-L,O-D),T*S>P*v)}(this._currentPoly.points,i,l,p,m,_),this}arcToSvg(i,l,p,m,_,y,x){return buildArcToSvg(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,y,x,i,l,p,m,_),this}bezierCurveTo(i,l,p,m,_,y,x){this._ensurePoly();const v=this._currentPoly;return buildAdaptiveBezier(this._currentPoly.points,v.lastX,v.lastY,i,l,p,m,_,y,x),this}quadraticCurveTo(i,l,p,m,_){this._ensurePoly();const y=this._currentPoly;return buildAdaptiveQuadratic(this._currentPoly.points,y.lastX,y.lastY,i,l,p,m,_),this}closePath(){return this.endPoly(!0),this}addPath(i,l){this.endPoly(),l&&!l.isIdentity()&&(i=i.clone(!0)).transform(l);for(let l=0;l<i.instructions.length;l++){const p=i.instructions[l];this[p.action](...p.data)}return this}finish(i=!1){this.endPoly(i)}rect(i,l,p,m,_){return this.drawShape(new Rectangle(i,l,p,m),_),this}circle(i,l,p,m){return this.drawShape(new Circle(i,l,p),m),this}poly(i,l,p){const m=new Polygon(i);return m.closePath=l,this.drawShape(m,p),this}regularPoly(i,l,p,m,_=0,y){m=Math.max(0|m,3);const x=-1*Math.PI/2+_,v=2*Math.PI/m,T=[];for(let _=0;_<m;_++){const m=_*v+x;T.push(i+p*Math.cos(m),l+p*Math.sin(m))}return this.poly(T,!0,y),this}roundPoly(i,l,p,m,_,y=0,x){if(m=Math.max(0|m,3),_<=0)return this.regularPoly(i,l,p,m,y);const v=p*Math.sin(Math.PI/m)-.001;_=Math.min(_,v);const T=-1*Math.PI/2+y,S=2*Math.PI/m,P=(m-2)*Math.PI/m/2;for(let y=0;y<m;y++){const m=y*S+T,v=i+p*Math.cos(m),C=l+p*Math.sin(m),E=m+Math.PI+P,A=m-Math.PI-P,k=v+_*Math.cos(E),B=C+_*Math.sin(E),F=v+_*Math.cos(A),R=C+_*Math.sin(A);0===y?this.moveTo(k,B):this.lineTo(k,B),this.quadraticCurveTo(v,C,F,R,x)}return this.closePath()}roundShape(i,l,p=!1,m){return i.length<3?this:(p?function roundedShapeQuadraticCurve(i,l,p,m){const distance=(i,l)=>Math.sqrt((i.x-l.x)**2+(i.y-l.y)**2),pointLerp=(i,l,p)=>({x:i.x+(l.x-i.x)*p,y:i.y+(l.y-i.y)*p}),_=l.length;for(let y=0;y<_;y++){const x=l[(y+1)%_],v=x.radius??p;if(v<=0){0===y?i.moveTo(x.x,x.y):i.lineTo(x.x,x.y);continue}const T=l[y],S=l[(y+2)%_],P=distance(T,x);let C;C=P<1e-4?x:pointLerp(x,T,Math.min(P/2,v)/P);const E=distance(S,x);let A;A=E<1e-4?x:pointLerp(x,S,Math.min(E/2,v)/E),0===y?i.moveTo(C.x,C.y):i.lineTo(C.x,C.y),i.quadraticCurveTo(x.x,x.y,A.x,A.y,m)}}(this,i,l,m):function roundedShapeArc(i,l,p){const vecFrom=(i,l)=>{const p=l.x-i.x,m=l.y-i.y,_=Math.sqrt(p*p+m*m);return{len:_,nx:p/_,ny:m/_}},sharpCorner=(l,p)=>{0===l?i.moveTo(p.x,p.y):i.lineTo(p.x,p.y)};let m=l[l.length-1];for(let _=0;_<l.length;_++){const y=l[_%l.length],x=y.radius??p;if(x<=0){sharpCorner(_,y),m=y;continue}const v=l[(_+1)%l.length],T=vecFrom(y,m),S=vecFrom(y,v);if(T.len<1e-4||S.len<1e-4){sharpCorner(_,y),m=y;continue}let P=Math.asin(T.nx*S.ny-T.ny*S.nx),C=1,E=!1;T.nx*S.nx-T.ny*-S.ny<0?P<0?P=Math.PI+P:(P=Math.PI-P,C=-1,E=!0):P>0&&(C=-1,E=!0);const A=P/2;let k,B=Math.abs(Math.cos(A)*x/Math.sin(A));B>Math.min(T.len/2,S.len/2)?(B=Math.min(T.len/2,S.len/2),k=Math.abs(B*Math.sin(A)/Math.cos(A))):k=x;const F=y.x+S.nx*B+-S.ny*k*C,R=y.y+S.ny*B+S.nx*k*C,I=Math.atan2(T.ny,T.nx)+Math.PI/2*C,D=Math.atan2(S.ny,S.nx)-Math.PI/2*C;0===_&&i.moveTo(F+Math.cos(I)*k,R+Math.sin(I)*k),i.arc(F,R,k,I,D,E),m=y}}(this,i,l),this.closePath())}filletRect(i,l,p,m,_){if(0===_)return this.rect(i,l,p,m);const y=Math.min(p,m)/2,x=Math.min(y,Math.max(-y,_)),v=i+p,T=l+m,S=x<0?-x:0,P=Math.abs(x);return this.moveTo(i,l+P).arcTo(i+S,l+S,i+P,l,P).lineTo(v-P,l).arcTo(v-S,l+S,v,l+P,P).lineTo(v,T-P).arcTo(v-S,T-S,i+p-P,T,P).lineTo(i+P,T).arcTo(i+S,T-S,i,T-P,P).closePath()}chamferRect(i,l,p,m,_,y){if(_<=0)return this.rect(i,l,p,m);const x=Math.min(_,Math.min(p,m)/2),v=i+p,T=l+m,S=[i+x,l,v-x,l,v,l+x,v,T-x,v-x,T,i+x,T,i,T-x,i,l+x];for(let i=S.length-1;i>=2;i-=2)S[i]===S[i-2]&&S[i-1]===S[i-3]&&S.splice(i-1,2);return this.poly(S,!0,y)}ellipse(i,l,p,m,_){return this.drawShape(new Ellipse(i,l,p,m),_),this}roundRect(i,l,p,m,_,y){return this.drawShape(new RoundedRectangle(i,l,p,m,_),y),this}drawShape(i,l){return this.endPoly(),this.shapePrimitives.push({shape:i,transform:l}),this}startPoly(i,l){let p=this._currentPoly;return p&&this.endPoly(),p=new Polygon,p.points.push(i,l),this._currentPoly=p,this}endPoly(i=!1){const l=this._currentPoly;return l&&l.points.length>2&&(l.closePath=i,this.shapePrimitives.push({shape:l})),this._currentPoly=null,this}_ensurePoly(i=!0){if(!this._currentPoly&&(this._currentPoly=new Polygon,i)){const i=this.shapePrimitives[this.shapePrimitives.length-1];if(i){let l=i.shape.x,p=i.shape.y;if(i.transform&&!i.transform.isIdentity()){const m=i.transform,_=l;l=m.a*l+m.c*p+m.tx,p=m.b*_+m.d*p+m.ty}this._currentPoly.points.push(l,p)}else this._currentPoly.points.push(0,0)}}buildPath(){const i=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let l=0;l<i.instructions.length;l++){const p=i.instructions[l];this[p.action](...p.data)}this.finish()}get bounds(){const i=this._bounds;i.clear();const l=this.shapePrimitives;for(let p=0;p<l.length;p++){const m=l[p],_=m.shape.getBounds(es);m.transform?i.addRect(_,m.transform):i.addRect(_)}return i}}class GraphicsPath{constructor(i){this.instructions=[],this.uid=uid("graphicsPath"),this._dirty=!0,"string"==typeof i?function SVGToGraphicsPath(i,l){const p=ri(i),m=[];let _=null,y=0,x=0;for(let i=0;i<p.length;i++){const v=p[i],T=v[0],S=v;switch(T){case"M":y=S[1],x=S[2],l.moveTo(y,x);break;case"m":y+=S[1],x+=S[2],l.moveTo(y,x);break;case"H":y=S[1],l.lineTo(y,x);break;case"h":y+=S[1],l.lineTo(y,x);break;case"V":x=S[1],l.lineTo(y,x);break;case"v":x+=S[1],l.lineTo(y,x);break;case"L":y=S[1],x=S[2],l.lineTo(y,x);break;case"l":y+=S[1],x+=S[2],l.lineTo(y,x);break;case"C":y=S[5],x=S[6],l.bezierCurveTo(S[1],S[2],S[3],S[4],y,x);break;case"c":l.bezierCurveTo(y+S[1],x+S[2],y+S[3],x+S[4],y+S[5],x+S[6]),y+=S[5],x+=S[6];break;case"S":y=S[3],x=S[4],l.bezierCurveToShort(S[1],S[2],y,x);break;case"s":l.bezierCurveToShort(y+S[1],x+S[2],y+S[3],x+S[4]),y+=S[3],x+=S[4];break;case"Q":y=S[3],x=S[4],l.quadraticCurveTo(S[1],S[2],y,x);break;case"q":l.quadraticCurveTo(y+S[1],x+S[2],y+S[3],x+S[4]),y+=S[3],x+=S[4];break;case"T":y=S[1],x=S[2],l.quadraticCurveToShort(y,x);break;case"t":y+=S[1],x+=S[2],l.quadraticCurveToShort(y,x);break;case"A":y=S[6],x=S[7],l.arcToSvg(S[1],S[2],S[3],S[4],S[5],y,x);break;case"a":y+=S[6],x+=S[7],l.arcToSvg(S[1],S[2],S[3],S[4],S[5],y,x);break;case"Z":case"z":l.closePath(),m.length>0&&(_=m.pop(),_?(y=_.startX,x=_.startY):(y=0,x=0)),_=null;break;default:warn(`Unknown SVG path command: ${T}`)}"Z"!==T&&"z"!==T&&null===_&&(_={startX:y,startY:x},m.push(_))}return l}(i,this):this.instructions=i?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new ShapePath(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(i,l){return i=i.clone(),this.instructions.push({action:"addPath",data:[i,l]}),this._dirty=!0,this}arc(...i){return this.instructions.push({action:"arc",data:i}),this._dirty=!0,this}arcTo(...i){return this.instructions.push({action:"arcTo",data:i}),this._dirty=!0,this}arcToSvg(...i){return this.instructions.push({action:"arcToSvg",data:i}),this._dirty=!0,this}bezierCurveTo(...i){return this.instructions.push({action:"bezierCurveTo",data:i}),this._dirty=!0,this}bezierCurveToShort(i,l,p,m,_){const y=this.instructions[this.instructions.length-1],x=this.getLastPoint(Point.shared);let v=0,T=0;if(y&&"bezierCurveTo"===y.action){v=y.data[2],T=y.data[3];const i=x.x,l=x.y;v=i+(i-v),T=l+(l-T)}else v=x.x,T=x.y;return this.instructions.push({action:"bezierCurveTo",data:[v,T,i,l,p,m,_]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...i){return this.instructions.push({action:"ellipse",data:i}),this._dirty=!0,this}lineTo(...i){return this.instructions.push({action:"lineTo",data:i}),this._dirty=!0,this}moveTo(...i){return this.instructions.push({action:"moveTo",data:i}),this}quadraticCurveTo(...i){return this.instructions.push({action:"quadraticCurveTo",data:i}),this._dirty=!0,this}quadraticCurveToShort(i,l,p){const m=this.instructions[this.instructions.length-1],_=this.getLastPoint(Point.shared);let y=0,x=0;if(m&&"quadraticCurveTo"===m.action){y=m.data[0],x=m.data[1];const i=_.x,l=_.y;y=i+(i-y),x=l+(l-x)}else y=_.x,x=_.y;return this.instructions.push({action:"quadraticCurveTo",data:[y,x,i,l,p]}),this._dirty=!0,this}rect(i,l,p,m,_){return this.instructions.push({action:"rect",data:[i,l,p,m,_]}),this._dirty=!0,this}circle(i,l,p,m){return this.instructions.push({action:"circle",data:[i,l,p,m]}),this._dirty=!0,this}roundRect(...i){return this.instructions.push({action:"roundRect",data:i}),this._dirty=!0,this}poly(...i){return this.instructions.push({action:"poly",data:i}),this._dirty=!0,this}regularPoly(...i){return this.instructions.push({action:"regularPoly",data:i}),this._dirty=!0,this}roundPoly(...i){return this.instructions.push({action:"roundPoly",data:i}),this._dirty=!0,this}roundShape(...i){return this.instructions.push({action:"roundShape",data:i}),this._dirty=!0,this}filletRect(...i){return this.instructions.push({action:"filletRect",data:i}),this._dirty=!0,this}chamferRect(...i){return this.instructions.push({action:"chamferRect",data:i}),this._dirty=!0,this}star(i,l,p,m,_,y,x){_=_||m/2;const v=-1*Math.PI/2+y,T=2*p,S=2*Math.PI/T,P=[];for(let p=0;p<T;p++){const y=p%2?_:m,x=p*S+v;P.push(i+y*Math.cos(x),l+y*Math.sin(x))}return this.poly(P,!0,x),this}clone(i=!1){const l=new GraphicsPath;if(i)for(let i=0;i<this.instructions.length;i++){const p=this.instructions[i];l.instructions.push({action:p.action,data:p.data.slice()})}else l.instructions=this.instructions.slice();return l}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(i){if(i.isIdentity())return this;const l=i.a,p=i.b,m=i.c,_=i.d,y=i.tx,x=i.ty;let v=0,T=0,S=0,P=0,C=0,E=0,A=0,k=0;for(let B=0;B<this.instructions.length;B++){const F=this.instructions[B],R=F.data;switch(F.action){case"moveTo":case"lineTo":v=R[0],T=R[1],R[0]=l*v+m*T+y,R[1]=p*v+_*T+x;break;case"bezierCurveTo":S=R[0],P=R[1],C=R[2],E=R[3],v=R[4],T=R[5],R[0]=l*S+m*P+y,R[1]=p*S+_*P+x,R[2]=l*C+m*E+y,R[3]=p*C+_*E+x,R[4]=l*v+m*T+y,R[5]=p*v+_*T+x;break;case"quadraticCurveTo":S=R[0],P=R[1],v=R[2],T=R[3],R[0]=l*S+m*P+y,R[1]=p*S+_*P+x,R[2]=l*v+m*T+y,R[3]=p*v+_*T+x;break;case"arcToSvg":v=R[5],T=R[6],A=R[0],k=R[1],R[0]=l*A+m*k,R[1]=p*A+_*k,R[5]=l*v+m*T+y,R[6]=p*v+_*T+x;break;case"circle":R[4]=adjustTransform(R[3],i);break;case"rect":R[4]=adjustTransform(R[4],i);break;case"ellipse":R[8]=adjustTransform(R[8],i);break;case"roundRect":R[5]=adjustTransform(R[5],i);break;case"addPath":R[0].transform(i);break;case"poly":R[2]=adjustTransform(R[2],i);break;default:warn("unknown transform action",F.action)}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(i){let l=this.instructions.length-1,p=this.instructions[l];if(!p)return i.x=0,i.y=0,i;for(;"closePath"===p.action;){if(l--,l<0)return i.x=0,i.y=0,i;p=this.instructions[l]}switch(p.action){case"moveTo":case"lineTo":i.x=p.data[0],i.y=p.data[1];break;case"quadraticCurveTo":i.x=p.data[2],i.y=p.data[3];break;case"bezierCurveTo":i.x=p.data[4],i.y=p.data[5];break;case"arc":case"arcToSvg":i.x=p.data[5],i.y=p.data[6];break;case"addPath":p.data[0].getLastPoint(i)}return i}}function adjustTransform(i,l){return i?i.prepend(l):l.clone()}function SVGParser(i,l){if("string"==typeof i){const l=document.createElement("div");l.innerHTML=i.trim(),i=l.querySelector("svg")}return renderChildren(i,{context:l,path:new GraphicsPath},null,null),l}function renderChildren(i,l,p,m){const _=i.children,{fillStyle:y,strokeStyle:x}=function parseStyle(i){const l=i.getAttribute("style"),p={},m={};let _=!1,y=!1;if(l){const i=l.split(";");for(let l=0;l<i.length;l++){const x=i[l],[v,T]=x.split(":");switch(v){case"stroke":"none"!==T&&(p.color=At.shared.setValue(T).toNumber(),y=!0);break;case"stroke-width":p.width=Number(T);break;case"fill":"none"!==T&&(_=!0,m.color=At.shared.setValue(T).toNumber());break;case"fill-opacity":m.alpha=Number(T);break;case"stroke-opacity":p.alpha=Number(T);break;case"opacity":m.alpha=Number(T),p.alpha=Number(T)}}}else{const l=i.getAttribute("stroke");l&&"none"!==l&&(y=!0,p.color=At.shared.setValue(l).toNumber(),p.width=parseFloatAttribute(i,"stroke-width",1));const x=i.getAttribute("fill");x&&"none"!==x&&(_=!0,m.color=At.shared.setValue(x).toNumber())}return{strokeStyle:y?p:null,fillStyle:_?m:null}}(i);let v,T,S,P,C,E,A,k,B,F,R,I,D,L,U,G,O;switch(y&&p?p={...p,...y}:y&&(p=y),x&&m?m={...m,...x}:x&&(m=x),l.context.fillStyle=p,l.context.strokeStyle=m,i.nodeName.toLowerCase()){case"path":L=i.getAttribute("d"),U=new GraphicsPath(L),l.context.path(U),p&&l.context.fill(),m&&l.context.stroke();break;case"circle":A=parseFloatAttribute(i,"cx",0),k=parseFloatAttribute(i,"cy",0),B=parseFloatAttribute(i,"r",0),l.context.ellipse(A,k,B,B),p&&l.context.fill(),m&&l.context.stroke();break;case"rect":v=parseFloatAttribute(i,"x",0),T=parseFloatAttribute(i,"y",0),G=parseFloatAttribute(i,"width",0),O=parseFloatAttribute(i,"height",0),F=parseFloatAttribute(i,"rx",0),R=parseFloatAttribute(i,"ry",0),F||R?l.context.roundRect(v,T,G,O,F||R):l.context.rect(v,T,G,O),p&&l.context.fill(),m&&l.context.stroke();break;case"ellipse":A=parseFloatAttribute(i,"cx",0),k=parseFloatAttribute(i,"cy",0),F=parseFloatAttribute(i,"rx",0),R=parseFloatAttribute(i,"ry",0),l.context.beginPath(),l.context.ellipse(A,k,F,R),p&&l.context.fill(),m&&l.context.stroke();break;case"line":S=parseFloatAttribute(i,"x1",0),P=parseFloatAttribute(i,"y1",0),C=parseFloatAttribute(i,"x2",0),E=parseFloatAttribute(i,"y2",0),l.context.beginPath(),l.context.moveTo(S,P),l.context.lineTo(C,E),m&&l.context.stroke();break;case"polygon":D=i.getAttribute("points"),I=D.match(/\d+/g).map((i=>parseInt(i,10))),l.context.poly(I,!0),p&&l.context.fill(),m&&l.context.stroke();break;case"polyline":D=i.getAttribute("points"),I=D.match(/\d+/g).map((i=>parseInt(i,10))),l.context.poly(I,!1),m&&l.context.stroke();break;case"g":case"svg":break;default:console.info(`[SVG parser] <${i.nodeName}> elements unsupported`)}for(let i=0;i<_.length;i++)renderChildren(_[i],l,p,m)}function parseFloatAttribute(i,l,p){const m=i.getAttribute(l);return m?Number(m):p}function isFillPattern(i){return i instanceof FillPattern}function isFillGradient(i){return i instanceof Qe}function handleFillPattern(i,l,p){return i.fill=l,i.color=16777215,i.texture=l.texture,i.matrix=l.transform,{...p,...i}}function handleFillGradient(i,l,p){return l.buildLinearGradient(),i.fill=l,i.color=16777215,i.texture=l.texture,i.matrix=l.transform,{...p,...i}}function toFillStyle(i,l){if(null==i)return null;const p={},m=i;return function isColorLike(i){return At.isColorLike(i)}(i)?function handleColorLike(i,l,p){const m=At.shared.setValue(l??0);return i.color=m.toNumber(),i.alpha=1===m.alpha?p.alpha:m.alpha,i.texture=Texture.WHITE,{...p,...i}}(p,i,l):isFillPattern(i)?handleFillPattern(p,i,l):isFillGradient(i)?handleFillGradient(p,i,l):m.fill&&isFillPattern(m.fill)?handleFillPattern(m,m.fill,l):m.fill&&isFillGradient(m.fill)?handleFillGradient(m,m.fill,l):function handleFillObject(i,l){const p={...l,...i};if(p.texture){if(p.texture!==Texture.WHITE){const i=p.matrix?.invert()||new Matrix;i.translate(p.texture.frame.x,p.texture.frame.y),i.scale(1/p.texture.source.width,1/p.texture.source.height),p.matrix=i}const i=p.texture.source.style;"clamp-to-edge"===i.addressMode&&(i.addressMode="repeat",i.update())}const m=At.shared.setValue(p.color);return p.alpha*=m.alpha,p.color=m.toNumber(),p.matrix=p.matrix?p.matrix.clone():null,p}(m,l)}function toStrokeStyle(i,l){const{width:p,alignment:m,miterLimit:_,cap:y,join:x,...v}=l,T=toFillStyle(i,v);return T?{width:p,alignment:m,miterLimit:_,cap:y,join:x,...T}:null}const is=new Point,ss=new Matrix,rs=class _GraphicsContext extends V{constructor(){super(...arguments),this.uid=uid("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new GraphicsPath,this._transform=new Matrix,this._fillStyle={..._GraphicsContext.defaultFillStyle},this._strokeStyle={..._GraphicsContext.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Bounds,this._boundsDirty=!0}clone(){const i=new _GraphicsContext;return i.batchMode=this.batchMode,i.instructions=this.instructions.slice(),i._activePath=this._activePath.clone(),i._transform=this._transform.clone(),i._fillStyle={...this._fillStyle},i._strokeStyle={...this._strokeStyle},i._stateStack=this._stateStack.slice(),i._bounds=this._bounds.clone(),i._boundsDirty=!0,i}get fillStyle(){return this._fillStyle}set fillStyle(i){this._fillStyle=toFillStyle(i,_GraphicsContext.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(i){this._strokeStyle=toStrokeStyle(i,_GraphicsContext.defaultStrokeStyle)}setFillStyle(i){return this._fillStyle=toFillStyle(i,_GraphicsContext.defaultFillStyle),this}setStrokeStyle(i){return this._strokeStyle=toFillStyle(i,_GraphicsContext.defaultStrokeStyle),this}texture(i,l,p,m,_,y){return this.instructions.push({action:"texture",data:{image:i,dx:p||0,dy:m||0,dw:_||i.frame.width,dh:y||i.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:l?At.shared.setValue(l).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new GraphicsPath,this}fill(i,l){let p;const m=this.instructions[this.instructions.length-1];return p=0===this._tick&&m&&"stroke"===m.action?m.data.path:this._activePath.clone(),p?(null!=i&&(void 0!==l&&"number"==typeof i&&(deprecation(ut,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),i={color:i,alpha:l}),this._fillStyle=toFillStyle(i,_GraphicsContext.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:p}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:i,y:l}=this._activePath.getLastPoint(Point.shared);this._activePath.clear(),this._activePath.moveTo(i,l)}stroke(i){let l;const p=this.instructions[this.instructions.length-1];return l=0===this._tick&&p&&"fill"===p.action?p.data.path:this._activePath.clone(),l?(null!=i&&(this._strokeStyle=toStrokeStyle(i,_GraphicsContext.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:l}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let i=0;i<2;i++){const l=this.instructions[this.instructions.length-1-i],p=this._activePath.clone();if(l&&("stroke"===l.action||"fill"===l.action)){if(!l.data.hole){l.data.hole=p;break}l.data.hole.addPath(p)}}return this._initNextPathLocation(),this}arc(i,l,p,m,_,y){this._tick++;const x=this._transform;return this._activePath.arc(x.a*i+x.c*l+x.tx,x.b*i+x.d*l+x.ty,p,m,_,y),this}arcTo(i,l,p,m,_){this._tick++;const y=this._transform;return this._activePath.arcTo(y.a*i+y.c*l+y.tx,y.b*i+y.d*l+y.ty,y.a*p+y.c*m+y.tx,y.b*p+y.d*m+y.ty,_),this}arcToSvg(i,l,p,m,_,y,x){this._tick++;const v=this._transform;return this._activePath.arcToSvg(i,l,p,m,_,v.a*y+v.c*x+v.tx,v.b*y+v.d*x+v.ty),this}bezierCurveTo(i,l,p,m,_,y,x){this._tick++;const v=this._transform;return this._activePath.bezierCurveTo(v.a*i+v.c*l+v.tx,v.b*i+v.d*l+v.ty,v.a*p+v.c*m+v.tx,v.b*p+v.d*m+v.ty,v.a*_+v.c*y+v.tx,v.b*_+v.d*y+v.ty,x),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(i,l,p,m){return this._tick++,this._activePath.ellipse(i,l,p,m,this._transform.clone()),this}circle(i,l,p){return this._tick++,this._activePath.circle(i,l,p,this._transform.clone()),this}path(i){return this._tick++,this._activePath.addPath(i,this._transform.clone()),this}lineTo(i,l){this._tick++;const p=this._transform;return this._activePath.lineTo(p.a*i+p.c*l+p.tx,p.b*i+p.d*l+p.ty),this}moveTo(i,l){this._tick++;const p=this._transform,m=this._activePath.instructions,_=p.a*i+p.c*l+p.tx,y=p.b*i+p.d*l+p.ty;return 1===m.length&&"moveTo"===m[0].action?(m[0].data[0]=_,m[0].data[1]=y,this):(this._activePath.moveTo(_,y),this)}quadraticCurveTo(i,l,p,m,_){this._tick++;const y=this._transform;return this._activePath.quadraticCurveTo(y.a*i+y.c*l+y.tx,y.b*i+y.d*l+y.ty,y.a*p+y.c*m+y.tx,y.b*p+y.d*m+y.ty,_),this}rect(i,l,p,m){return this._tick++,this._activePath.rect(i,l,p,m,this._transform.clone()),this}roundRect(i,l,p,m,_){return this._tick++,this._activePath.roundRect(i,l,p,m,_,this._transform.clone()),this}poly(i,l){return this._tick++,this._activePath.poly(i,l,this._transform.clone()),this}regularPoly(i,l,p,m,_=0,y){return this._tick++,this._activePath.regularPoly(i,l,p,m,_,y),this}roundPoly(i,l,p,m,_,y){return this._tick++,this._activePath.roundPoly(i,l,p,m,_,y),this}roundShape(i,l,p,m){return this._tick++,this._activePath.roundShape(i,l,p,m),this}filletRect(i,l,p,m,_){return this._tick++,this._activePath.filletRect(i,l,p,m,_),this}chamferRect(i,l,p,m,_,y){return this._tick++,this._activePath.chamferRect(i,l,p,m,_,y),this}star(i,l,p,m,_=0,y=0){return this._tick++,this._activePath.star(i,l,p,m,_,y,this._transform.clone()),this}svg(i){return this._tick++,SVGParser(i,this),this}restore(){const i=this._stateStack.pop();return i&&(this._transform=i.transform,this._fillStyle=i.fillStyle,this._strokeStyle=i.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(i){return this._transform.rotate(i),this}scale(i,l=i){return this._transform.scale(i,l),this}setTransform(i,l,p,m,_,y){return i instanceof Matrix?(this._transform.set(i.a,i.b,i.c,i.d,i.tx,i.ty),this):(this._transform.set(i,l,p,m,_,y),this)}transform(i,l,p,m,_,y){return i instanceof Matrix?(this._transform.append(i),this):(ss.set(i,l,p,m,_,y),this._transform.append(ss),this)}translate(i,l=i){return this._transform.translate(i,l),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const i=this._bounds;i.clear();for(let l=0;l<this.instructions.length;l++){const p=this.instructions[l],m=p.action;if("fill"===m){const l=p.data;i.addBounds(l.path.bounds)}else if("texture"===m){const l=p.data;i.addFrame(l.dx,l.dy,l.dx+l.dw,l.dy+l.dh,l.transform)}if("stroke"===m){const l=p.data,m=l.style.width/2,_=l.path.bounds;i.addFrame(_.minX-m,_.minY-m,_.maxX+m,_.maxY+m)}}return i}containsPoint(i){if(!this.bounds.containsPoint(i.x,i.y))return!1;const l=this.instructions;let p=!1;for(let m=0;m<l.length;m++){const _=l[m],y=_.data,x=y.path;if(!_.action||!x)continue;const v=y.style,T=x.shapePath.shapePrimitives;for(let l=0;l<T.length;l++){const m=T[l].shape;if(!v||!m)continue;const x=T[l].transform,S=x?x.applyInverse(i,is):i;p="fill"===_.action?m.contains(S.x,S.y):m.strokeContains(S.x,S.y,v.width);const P=y.hole;if(P){const i=P.shapePath?.shapePrimitives;if(i)for(let l=0;l<i.length;l++)i[l].shape.contains(S.x,S.y)&&(p=!1)}if(p)return!0}}return p}destroy(i=!1){this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners();if("boolean"==typeof i?i:i?.texture){const l="boolean"==typeof i?i:i?.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(l),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(l)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};rs.defaultFillStyle={color:16777215,alpha:1,texture:Texture.WHITE,matrix:null,fill:null},rs.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Texture.WHITE,matrix:null,fill:null};let ns=rs;const os=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function generateTextStyleKey(i){const l=[];let p=0;for(let m=0;m<os.length;m++){const _=`_${os[m]}`;l[p++]=i[_]}return p=addFillStyleKey(i._fill,l,p),p=function addStokeStyleKey(i,l,p){return i?(p=addFillStyleKey(i,l,p),l[p++]=i.width,l[p++]=i.alignment,l[p++]=i.cap,l[p++]=i.join,l[p++]=i.miterLimit,p):p}(i._stroke,l,p),p=function addDropShadowKey(i,l,p){return i?(l[p++]=i.alpha,l[p++]=i.angle,l[p++]=i.blur,l[p++]=i.distance,l[p++]=At.shared.setValue(i.color).toNumber(),p):p}(i.dropShadow,l,p),l.join("-")}function addFillStyleKey(i,l,p){return i?(l[p++]=i.color,l[p++]=i.alpha,l[p++]=i.fill?.styleKey,p):p}const as=class _TextStyle extends V{constructor(i={}){super(),function convertV7Tov8Style(i){const l=i;if("boolean"==typeof l.dropShadow&&l.dropShadow){const p=hs.defaultDropShadow;i.dropShadow={alpha:l.dropShadowAlpha??p.alpha,angle:l.dropShadowAngle??p.angle,blur:l.dropShadowBlur??p.blur,color:l.dropShadowColor??p.color,distance:l.dropShadowDistance??p.distance}}if(void 0!==l.strokeThickness){deprecation(ut,"strokeThickness is now a part of stroke");const p=l.stroke;let m={};if(At.isColorLike(p))m.color=p;else if(p instanceof Qe||p instanceof FillPattern)m.fill=p;else{if(!Object.hasOwnProperty.call(p,"color")&&!Object.hasOwnProperty.call(p,"fill"))throw new Error("Invalid stroke value.");m=p}i.stroke={...m,width:l.strokeThickness}}if(Array.isArray(l.fillGradientStops)){let p;deprecation(ut,"gradient fill is now a fill pattern: `new FillGradient(...)`"),null==i.fontSize?i.fontSize=hs.defaultTextStyle.fontSize:p="string"==typeof i.fontSize?parseInt(i.fontSize,10):i.fontSize;const m=new Qe(0,0,0,1.7*p),_=l.fillGradientStops.map((i=>At.shared.setValue(i).toNumber()));_.forEach(((i,l)=>{const p=l/(_.length-1);m.addColorStop(p,i)})),i.fill={fill:m}}}(i);const l={..._TextStyle.defaultTextStyle,...i};for(const i in l){this[i]=l[i]}this.update()}get align(){return this._align}set align(i){this._align=i,this.update()}get breakWords(){return this._breakWords}set breakWords(i){this._breakWords=i,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(i){this._dropShadow=null!==i&&"object"==typeof i?this._createProxy({..._TextStyle.defaultDropShadow,...i}):i?this._createProxy({..._TextStyle.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(i){this._fontFamily=i,this.update()}get fontSize(){return this._fontSize}set fontSize(i){this._fontSize="string"==typeof i?parseInt(i,10):i,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(i){this._fontStyle=i,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(i){this._fontVariant=i,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(i){this._fontWeight=i,this.update()}get leading(){return this._leading}set leading(i){this._leading=i,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(i){this._letterSpacing=i,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(i){this._lineHeight=i,this.update()}get padding(){return this._padding}set padding(i){this._padding=i,this.update()}get trim(){return this._trim}set trim(i){this._trim=i,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(i){this._textBaseline=i,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(i){this._whiteSpace=i,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(i){this._wordWrap=i,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(i){this._wordWrapWidth=i,this.update()}get fill(){return this._originalFill}set fill(i){i!==this._originalFill&&(this._originalFill=i,this._isFillStyle(i)&&(this._originalFill=this._createProxy({...ns.defaultFillStyle,...i},(()=>{this._fill=toFillStyle({...this._originalFill},ns.defaultFillStyle)}))),this._fill=toFillStyle(0===i?"black":i,ns.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(i){i!==this._originalStroke&&(this._originalStroke=i,this._isFillStyle(i)&&(this._originalStroke=this._createProxy({...ns.defaultStrokeStyle,...i},(()=>{this._stroke=toStrokeStyle({...this._originalStroke},ns.defaultStrokeStyle)}))),this._stroke=toStrokeStyle(i,ns.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=generateTextStyleKey(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const i=_TextStyle.defaultTextStyle;for(const l in i)this[l]=i[l]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new _TextStyle({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,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,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(i=!1){this.removeAllListeners();if("boolean"==typeof i?i:i?.texture){const l="boolean"==typeof i?i:i?.textureSource;this._fill?.texture&&this._fill.texture.destroy(l),this._originalFill?.texture&&this._originalFill.texture.destroy(l),this._stroke?.texture&&this._stroke.texture.destroy(l),this._originalStroke?.texture&&this._originalStroke.texture.destroy(l)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(i,l){return new Proxy(i,{set:(i,p,m)=>(i[p]=m,l?.(p,m),this.update(),!0)})}_isFillStyle(i){return null!==(i??null)&&!(At.isColorLike(i)||i instanceof Qe||i instanceof FillPattern)}};as.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},as.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};let hs=as;const ls=new class CanvasPoolClass{constructor(i){this._canvasPool=Object.create(null),this.canvasOptions=i||{},this.enableFullScreen=!1}_createCanvasAndContext(i,l){const p=qt.get().createCanvas();p.width=i,p.height=l;const m=p.getContext("2d");return{canvas:p,context:m}}getOptimalCanvasAndContext(i,l,p=1){i=Math.ceil(i*p-1e-6),l=Math.ceil(l*p-1e-6);const m=((i=nextPow2(i))<<17)+((l=nextPow2(l))<<1);this._canvasPool[m]||(this._canvasPool[m]=[]);let _=this._canvasPool[m].pop();return _||(_=this._createCanvasAndContext(i,l)),_}returnCanvasAndContext(i){const l=i.canvas,{width:p,height:m}=l,_=(p<<17)+(m<<1);this._canvasPool[_].push(i)}clear(){this._canvasPool={}}},ds=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function fontStringFromTextStyle(i){const l="number"==typeof i.fontSize?`${i.fontSize}px`:i.fontSize;let p=i.fontFamily;Array.isArray(i.fontFamily)||(p=i.fontFamily.split(","));for(let i=p.length-1;i>=0;i--){let l=p[i].trim();/([\"\'])[^\'\"]+\1/.test(l)||ds.includes(l)||(l=`"${l}"`),p[i]=l}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${l} ${p.join(",")}`}const us={willReadFrequently:!0},cs=class _CanvasTextMetrics{static get experimentalLetterSpacingSupported(){let i=_CanvasTextMetrics._experimentalLetterSpacingSupported;if(void 0!==i){const l=qt.get().getCanvasRenderingContext2D().prototype;i=_CanvasTextMetrics._experimentalLetterSpacingSupported="letterSpacing"in l||"textLetterSpacing"in l}return i}constructor(i,l,p,m,_,y,x,v,T){this.text=i,this.style=l,this.width=p,this.height=m,this.lines=_,this.lineWidths=y,this.lineHeight=x,this.maxLineWidth=v,this.fontProperties=T}static measureText(i=" ",l,p=_CanvasTextMetrics._canvas,m=l.wordWrap){const _=`${i}:${l.styleKey}`;if(_CanvasTextMetrics._measurementCache[_])return _CanvasTextMetrics._measurementCache[_];const y=fontStringFromTextStyle(l),x=_CanvasTextMetrics.measureFont(y);0===x.fontSize&&(x.fontSize=l.fontSize,x.ascent=l.fontSize);const v=_CanvasTextMetrics.__context;v.font=y;const T=(m?_CanvasTextMetrics._wordWrap(i,l,p):i).split(/(?:\r\n|\r|\n)/),S=new Array(T.length);let P=0;for(let i=0;i<T.length;i++){const p=_CanvasTextMetrics._measureText(T[i],l.letterSpacing,v);S[i]=p,P=Math.max(P,p)}const C=l._stroke?.width||0;let E=P+C;l.dropShadow&&(E+=l.dropShadow.distance);const A=l.lineHeight||x.fontSize;let k=Math.max(A,x.fontSize+C)+(T.length-1)*(A+l.leading);l.dropShadow&&(k+=l.dropShadow.distance);return new _CanvasTextMetrics(i,l,E,k,T,S,A+l.leading,P,x)}static _measureText(i,l,p){let m=!1;_CanvasTextMetrics.experimentalLetterSpacingSupported&&(_CanvasTextMetrics.experimentalLetterSpacing?(p.letterSpacing=`${l}px`,p.textLetterSpacing=`${l}px`,m=!0):(p.letterSpacing="0px",p.textLetterSpacing="0px"));let _=p.measureText(i).width;return _>0&&(m?_-=l:_+=(_CanvasTextMetrics.graphemeSegmenter(i).length-1)*l),_}static _wordWrap(i,l,p=_CanvasTextMetrics._canvas){const m=p.getContext("2d",us);let _=0,y="",x="";const v=Object.create(null),{letterSpacing:T,whiteSpace:S}=l,P=_CanvasTextMetrics._collapseSpaces(S),C=_CanvasTextMetrics._collapseNewlines(S);let E=!P;const A=l.wordWrapWidth+T,k=_CanvasTextMetrics._tokenize(i);for(let i=0;i<k.length;i++){let p=k[i];if(_CanvasTextMetrics._isNewline(p)){if(!C){x+=_CanvasTextMetrics._addLine(y),E=!P,y="",_=0;continue}p=" "}if(P){const i=_CanvasTextMetrics.isBreakingSpace(p),l=_CanvasTextMetrics.isBreakingSpace(y[y.length-1]);if(i&&l)continue}const S=_CanvasTextMetrics._getFromCache(p,T,v,m);if(S>A)if(""!==y&&(x+=_CanvasTextMetrics._addLine(y),y="",_=0),_CanvasTextMetrics.canBreakWords(p,l.breakWords)){const i=_CanvasTextMetrics.wordWrapSplit(p);for(let S=0;S<i.length;S++){let P=i[S],C=P,k=1;for(;i[S+k];){const m=i[S+k];if(_CanvasTextMetrics.canBreakChars(C,m,p,S,l.breakWords))break;P+=m,C=m,k++}S+=k-1;const B=_CanvasTextMetrics._getFromCache(P,T,v,m);B+_>A&&(x+=_CanvasTextMetrics._addLine(y),E=!1,y="",_=0),y+=P,_+=B}}else{y.length>0&&(x+=_CanvasTextMetrics._addLine(y),y="",_=0);const l=i===k.length-1;x+=_CanvasTextMetrics._addLine(p,!l),E=!1,y="",_=0}else S+_>A&&(E=!1,x+=_CanvasTextMetrics._addLine(y),y="",_=0),(y.length>0||!_CanvasTextMetrics.isBreakingSpace(p)||E)&&(y+=p,_+=S)}return x+=_CanvasTextMetrics._addLine(y,!1),x}static _addLine(i,l=!0){return i=_CanvasTextMetrics._trimRight(i),i=l?`${i}\n`:i}static _getFromCache(i,l,p,m){let _=p[i];return"number"!=typeof _&&(_=_CanvasTextMetrics._measureText(i,l,m)+l,p[i]=_),_}static _collapseSpaces(i){return"normal"===i||"pre-line"===i}static _collapseNewlines(i){return"normal"===i}static _trimRight(i){if("string"!=typeof i)return"";for(let l=i.length-1;l>=0;l--){const p=i[l];if(!_CanvasTextMetrics.isBreakingSpace(p))break;i=i.slice(0,-1)}return i}static _isNewline(i){return"string"==typeof i&&_CanvasTextMetrics._newlines.includes(i.charCodeAt(0))}static isBreakingSpace(i,l){return"string"==typeof i&&_CanvasTextMetrics._breakingSpaces.includes(i.charCodeAt(0))}static _tokenize(i){const l=[];let p="";if("string"!=typeof i)return l;for(let m=0;m<i.length;m++){const _=i[m],y=i[m+1];_CanvasTextMetrics.isBreakingSpace(_,y)||_CanvasTextMetrics._isNewline(_)?(""!==p&&(l.push(p),p=""),l.push(_)):p+=_}return""!==p&&l.push(p),l}static canBreakWords(i,l){return l}static canBreakChars(i,l,p,m,_){return!0}static wordWrapSplit(i){return _CanvasTextMetrics.graphemeSegmenter(i)}static measureFont(i){if(_CanvasTextMetrics._fonts[i])return _CanvasTextMetrics._fonts[i];const l=_CanvasTextMetrics._context;l.font=i;const p=l.measureText(_CanvasTextMetrics.METRICS_STRING+_CanvasTextMetrics.BASELINE_SYMBOL),m={ascent:p.actualBoundingBoxAscent,descent:p.actualBoundingBoxDescent,fontSize:p.actualBoundingBoxAscent+p.actualBoundingBoxDescent};return _CanvasTextMetrics._fonts[i]=m,m}static clearMetrics(i=""){i?delete _CanvasTextMetrics._fonts[i]:_CanvasTextMetrics._fonts={}}static get _canvas(){if(!_CanvasTextMetrics.__canvas){let i;try{const l=new OffscreenCanvas(0,0),p=l.getContext("2d",us);if(p?.measureText)return _CanvasTextMetrics.__canvas=l,l;i=qt.get().createCanvas()}catch(l){i=qt.get().createCanvas()}i.width=i.height=10,_CanvasTextMetrics.__canvas=i}return _CanvasTextMetrics.__canvas}static get _context(){return _CanvasTextMetrics.__context||(_CanvasTextMetrics.__context=_CanvasTextMetrics._canvas.getContext("2d",us)),_CanvasTextMetrics.__context}};cs.METRICS_STRING="|ÉqÅ",cs.BASELINE_SYMBOL="M",cs.BASELINE_MULTIPLIER=1.4,cs.HEIGHT_MULTIPLIER=2,cs.graphemeSegmenter=(()=>{if("function"==typeof Intl?.Segmenter){const i=new Intl.Segmenter;return l=>[...i.segment(l)].map((i=>i.segment))}return i=>[...i]})(),cs.experimentalLetterSpacing=!1,cs._fonts={},cs._newlines=[10,13],cs._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],cs._measurementCache={};let ps=cs;function getCanvasFillStyle(i,l){if(i.texture===Texture.WHITE&&!i.fill)return At.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(!i.fill){const p=l.createPattern(i.texture.source.resource,"repeat"),m=i.matrix.copyTo(Matrix.shared);return m.scale(i.texture.frame.width,i.texture.frame.height),p.setTransform(m),p}if(i.fill instanceof FillPattern){const p=i.fill,m=l.createPattern(p.texture.source.resource,"repeat"),_=p.transform.copyTo(Matrix.shared);return _.scale(p.texture.frame.width,p.texture.frame.height),m.setTransform(_),m}if(i.fill instanceof Qe){const p=i.fill;if("linear"===p.type){const i=l.createLinearGradient(p.x0,p.y0,p.x1,p.y1);return p.gradientStops.forEach((l=>{i.addColorStop(l.offset,At.shared.setValue(l.color).toHex())})),i}}return warn("FillStyle not recognised",i),"red"}function resolveCharacters(i){if(""===i)return[];"string"==typeof i&&(i=[i]);const l=[];for(let p=0,m=i.length;p<m;p++){const m=i[p];if(Array.isArray(m)){if(2!==m.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${m.length}.`);if(0===m[0].length||0===m[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");const i=m[0].charCodeAt(0),p=m[1].charCodeAt(0);if(p<i)throw new Error("[BitmapFont]: Invalid character range.");for(let m=i,_=p;m<=_;m++)l.push(String.fromCharCode(m))}else l.push(...Array.from(m))}if(0===l.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return l}const fs=class _DynamicBitmapFont extends AbstractBitmapFont{constructor(i){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const l={..._DynamicBitmapFont.defaultOptions,...i};this._textureSize=l.textureSize,this._mipmap=l.mipmap;const p=l.style.clone();l.overrideFill&&(p._fill.color=16777215,p._fill.alpha=1,p._fill.texture=Texture.WHITE,p._fill.fill=null),this.applyFillAsTint=l.overrideFill;const m=p.fontSize;p.fontSize=this.baseMeasurementFontSize;const _=fontStringFromTextStyle(p);l.overrideSize?p._stroke&&(p._stroke.width*=this.baseRenderedFontSize/m):p.fontSize=this.baseRenderedFontSize=m,this._style=p,this._skipKerning=l.skipKerning??!1,this.resolution=l.resolution??1,this._padding=l.padding??4,this.fontMetrics=ps.measureFont(_),this.lineHeight=p.lineHeight||this.fontMetrics.fontSize||p.fontSize}ensureCharacters(i){const l=resolveCharacters(i).filter((i=>!this._currentChars.includes(i))).filter(((i,l,p)=>p.indexOf(i)===l));if(!l.length)return;let p;this._currentChars=[...this._currentChars,...l],p=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:m,context:_}=p.canvasAndContext,y=p.texture.source;const x=this._style;let v=this._currentX,T=this._currentY;const S=this.baseRenderedFontSize/this.baseMeasurementFontSize,P=this._padding*S,C="italic"===x.fontStyle?2:1;let E=0,A=!1;for(let i=0;i<l.length;i++){const p=l[i],k=ps.measureText(p,x,m,!1);k.lineHeight=k.height;const B=C*k.width*S,F=B+2*P,R=k.height*S+2*P;if(A=!1,"\n"!==p&&"\r"!==p&&"\t"!==p&&" "!==p&&(A=!0,E=Math.ceil(Math.max(R,E))),v+F>this._textureSize&&(T+=E,E=R,v=0,T+E>this._textureSize)){y.update();const i=this._nextPage();m=i.canvasAndContext.canvas,_=i.canvasAndContext.context,y=i.texture.source,T=0}const I=B/S-(x.dropShadow?.distance??0)-(x._stroke?.width??0);if(this.chars[p]={id:p.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:I,kerning:{}},A){this._drawGlyph(_,k,v+P,T+P,S,x);const i=y.width*S,l=y.height*S,m=new Rectangle(v/i*y.width,T/l*y.height,F/i*y.width,R/l*y.height);this.chars[p].texture=new Texture({source:y,frame:m}),v+=Math.ceil(F)}}y.update(),this._currentX=v,this._currentY=T,this._skipKerning&&this._applyKerning(l,_)}get pageTextures(){return deprecation(ut,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(i,l){const p=this._measureCache;for(let m=0;m<i.length;m++){const _=i[m];for(let i=0;i<this._currentChars.length;i++){const m=this._currentChars[i];let y=p[_];y||(y=p[_]=l.measureText(_).width);let x=p[m];x||(x=p[m]=l.measureText(m).width);let v=l.measureText(_+m).width,T=v-(y+x);T&&(this.chars[_].kerning[m]=T),v=l.measureText(_+m).width,T=v-(y+x),T&&(this.chars[m].kerning[_]=T)}}}_nextPage(){this._currentPageIndex++;const i=this.resolution,l=ls.getOptimalCanvasAndContext(this._textureSize,this._textureSize,i);this._setupContext(l.context,this._style,i);const p=i*(this.baseRenderedFontSize/this.baseMeasurementFontSize),m={canvasAndContext:l,texture:new Texture({source:new ImageSource({resource:l.canvas,resolution:p,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})})};return this.pages[this._currentPageIndex]=m,m}_setupContext(i,l,p){l.fontSize=this.baseRenderedFontSize,i.scale(p,p),i.font=fontStringFromTextStyle(l),l.fontSize=this.baseMeasurementFontSize,i.textBaseline=l.textBaseline;const m=l._stroke,_=m?.width??0;if(m&&(i.lineWidth=_,i.lineJoin=m.join,i.miterLimit=m.miterLimit,i.strokeStyle=getCanvasFillStyle(m,i)),l._fill&&(i.fillStyle=getCanvasFillStyle(l._fill,i)),l.dropShadow){const m=l.dropShadow,_=At.shared.setValue(m.color).toArray(),y=m.blur*p,x=m.distance*p;i.shadowColor=`rgba(${255*_[0]},${255*_[1]},${255*_[2]},${m.alpha})`,i.shadowBlur=y,i.shadowOffsetX=Math.cos(m.angle)*x,i.shadowOffsetY=Math.sin(m.angle)*x}else i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0}_drawGlyph(i,l,p,m,_,y){const x=l.text,v=l.fontProperties,T=y._stroke,S=(T?.width??0)*_,P=p+S/2,C=m-S/2,E=v.descent*_,A=l.lineHeight*_;y.stroke&&S&&i.strokeText(x,P,C+A-E),y._fill&&i.fillText(x,P,C+A-E)}destroy(){super.destroy();for(let i=0;i<this.pages.length;i++){const{canvasAndContext:l,texture:p}=this.pages[i];l.canvas.width=l.canvas.width,ls.returnCanvasAndContext(l),p.destroy(!0)}this.pages=null}};fs.defaultOptions={textureSize:512,style:new hs,mipmap:!0};let ms=fs;function getBitmapTextLayout(i,l,p,m){const _={width:0,height:0,offsetY:0,scale:l.fontSize/p.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};_.offsetY=p.baseLineOffset;let y=_.lines[0],x=null,v=!0;const T={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},nextWord=i=>{const l=y.width;for(let p=0;p<T.index;p++){const m=i.positions[p];y.chars.push(i.chars[p]),y.charPositions.push(m+l)}y.width+=i.width,v=!1,T.width=0,T.index=0,T.chars.length=0},nextLine=()=>{let i=y.chars.length-1;if(m){let l=y.chars[i];for(;" "===l;)y.width-=p.chars[l].xAdvance,l=y.chars[--i]}_.width=Math.max(_.width,y.width),y={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},v=!0,_.lines.push(y),_.height+=p.lineHeight},S=p.baseMeasurementFontSize/l.fontSize,P=l.letterSpacing*S,C=l.wordWrapWidth*S;for(let m=0;m<i.length+1;m++){let _;const S=m===i.length;S||(_=i[m]);const E=p.chars[_]||p.chars[" "];if(/(?:\s)/.test(_)||"\r"===_||"\n"===_||S){if(!v&&l.wordWrap&&y.width+T.width-P>C?(nextLine(),nextWord(T),S||y.charPositions.push(0)):(T.start=y.width,nextWord(T),S||y.charPositions.push(0)),"\r"===_||"\n"===_)0!==y.width&&nextLine();else if(!S){const i=E.xAdvance+(E.kerning[x]||0)+P;y.width+=i,y.spaceWidth=i,y.spacesIndex.push(y.charPositions.length),y.chars.push(_)}}else{const i=E.kerning[x]||0,l=E.xAdvance+i+P;T.positions[T.index++]=T.width+i,T.chars.push(_),T.width+=l}x=_}return nextLine(),"center"===l.align?function alignCenter(i){for(let l=0;l<i.lines.length;l++){const p=i.lines[l],m=i.width/2-p.width/2;for(let i=0;i<p.charPositions.length;i++)p.charPositions[i]+=m}}(_):"right"===l.align?function alignRight(i){for(let l=0;l<i.lines.length;l++){const p=i.lines[l],m=i.width-p.width;for(let i=0;i<p.charPositions.length;i++)p.charPositions[i]+=m}}(_):"justify"===l.align&&function alignJustify(i){const l=i.width;for(let p=0;p<i.lines.length;p++){const m=i.lines[p];let _=0,y=m.spacesIndex[_++],x=0;const v=m.spacesIndex.length,T=(l-m.width)/v;for(let i=0;i<m.charPositions.length;i++)i===y&&(y=m.spacesIndex[_++],x+=T),m.charPositions[i]+=x}}(_),_}let gs=0;const _s=new class BitmapFontManagerClass{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}}getFont(i,l){let p=`${l.fontFamily}-bitmap`,m=!0;if(l._fill.fill&&!l._stroke)p+=l._fill.fill.styleKey,m=!1;else if(l._stroke||l.dropShadow){let i=l.styleKey;i=i.substring(0,i.lastIndexOf("-")),p=`${i}-bitmap`,m=!1}if(!se.has(p)){const i=new ms({style:l,overrideFill:m,overrideSize:!0,...this.defaultOptions});gs++,gs>50&&warn("BitmapText",`You have dynamically created ${gs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),i.once("destroy",(()=>{gs--,se.remove(p)})),se.set(p,i)}const _=se.get(p);return _.ensureCharacters?.(i),_}getLayout(i,l,p=!0){const m=this.getFont(i,l);return getBitmapTextLayout([...i],l,m,p)}measureText(i,l,p=!0){return this.getLayout(i,l,p)}install(...i){let l=i[0];"string"==typeof l&&(l={name:l,style:i[1],chars:i[2]?.chars,resolution:i[2]?.resolution,padding:i[2]?.padding,skipKerning:i[2]?.skipKerning},deprecation(ut,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const p=l?.name;if(!p)throw new Error("[BitmapFontManager] Property `name` is required.");l={...this.defaultOptions,...l};const m=l.style,_=m instanceof hs?m:new hs(m),y=null!==_._fill.fill&&void 0!==_._fill.fill,x=new ms({style:_,overrideFill:y,skipKerning:l.skipKerning,padding:l.padding,resolution:l.resolution,overrideSize:!1}),v=resolveCharacters(l.chars);return x.ensureCharacters(v.join("")),se.set(`${p}-bitmap`,x),x.once("destroy",(()=>se.remove(`${p}-bitmap`))),x}uninstall(i){const l=`${i}-bitmap`,p=se.get(l);p&&(se.remove(l),p.destroy())}};const ys=new class EventsTickerClass{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(i){this.removeTickerListener(),this.events=i,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(i){this._pauseUpdate=i}addTickerListener(){!this._tickerAdded&&this.domElement&&(te.system.add(this._tickerUpdate,this,Zt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(te.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const i=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===i.pointerType||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,pointerId:i.pointerId}))}_tickerUpdate(i){this._deltaTime+=i.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}};class FederatedMouseEvent extends FederatedEvent{constructor(){super(...arguments),this.client=new Point,this.movement=new Point,this.offset=new Point,this.global=new Point,this.screen=new Point}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(i,l,p){return i.worldTransform.applyInverse(p||this.global,l)}getModifierState(i){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(i)}initMouseEvent(i,l,p,m,_,y,x,v,T,S,P,C,E,A,k){throw new Error("Method not implemented.")}}class FederatedPointerEvent extends FederatedMouseEvent{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class FederatedWheelEvent extends FederatedMouseEvent{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}FederatedWheelEvent.DOM_DELTA_PIXEL=0,FederatedWheelEvent.DOM_DELTA_LINE=1,FederatedWheelEvent.DOM_DELTA_PAGE=2;const xs=new Point,vs=new Point;class EventBoundary{constructor(i){this.dispatch=new V,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=i,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(i,l){this.mappingTable[i]||(this.mappingTable[i]=[]),this.mappingTable[i].push({fn:l,priority:0}),this.mappingTable[i].sort(((i,l)=>i.priority-l.priority))}dispatchEvent(i,l){i.propagationStopped=!1,i.propagationImmediatelyStopped=!1,this.propagate(i,l),this.dispatch.emit(l||i.type,i)}mapEvent(i){if(!this.rootTarget)return;const l=this.mappingTable[i.type];if(l)for(let p=0,m=l.length;p<m;p++)l[p].fn(i);else warn(`[EventBoundary]: Event mapping not defined for ${i.type}`)}hitTest(i,l){ys.pauseUpdate=!0;const p=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,xs.set(i,l),this.hitTestFn,this.hitPruneFn);return p&&p[0]}propagate(i,l){if(!i.target)return;const p=i.composedPath();i.eventPhase=i.CAPTURING_PHASE;for(let m=0,_=p.length-1;m<_;m++)if(i.currentTarget=p[m],this.notifyTarget(i,l),i.propagationStopped||i.propagationImmediatelyStopped)return;if(i.eventPhase=i.AT_TARGET,i.currentTarget=i.target,this.notifyTarget(i,l),!i.propagationStopped&&!i.propagationImmediatelyStopped){i.eventPhase=i.BUBBLING_PHASE;for(let m=p.length-2;m>=0;m--)if(i.currentTarget=p[m],this.notifyTarget(i,l),i.propagationStopped||i.propagationImmediatelyStopped)return}}all(i,l,p=this._allInteractiveElements){if(0===p.length)return;i.eventPhase=i.BUBBLING_PHASE;const m=Array.isArray(l)?l:[l];for(let l=p.length-1;l>=0;l--)m.forEach((m=>{i.currentTarget=p[l],this.notifyTarget(i,m)}))}propagationPath(i){const l=[i];for(let p=0;p<2048&&i!==this.rootTarget&&i.parent;p++){if(!i.parent)throw new Error("Cannot find propagation path to disconnected target");l.push(i.parent),i=i.parent}return l.reverse(),l}hitTestMoveRecursive(i,l,p,m,_,y=!1){let x=!1;if(this._interactivePrune(i))return null;if("dynamic"!==i.eventMode&&"dynamic"!==l||(ys.pauseUpdate=!1),i.interactiveChildren&&i.children){const v=i.children;for(let T=v.length-1;T>=0;T--){const S=v[T],P=this.hitTestMoveRecursive(S,this._isInteractive(l)?l:S.eventMode,p,m,_,y||_(i,p));if(P){if(P.length>0&&!P[P.length-1].parent)continue;const l=i.isInteractive();(P.length>0||l)&&(l&&this._allInteractiveElements.push(i),P.push(i)),0===this._hitElements.length&&(this._hitElements=P),x=!0}}}const v=this._isInteractive(l),T=i.isInteractive();return T&&T&&this._allInteractiveElements.push(i),y||this._hitElements.length>0?null:x?this._hitElements:v&&!_(i,p)&&m(i,p)?T?[i]:[]:null}hitTestRecursive(i,l,p,m,_){if(this._interactivePrune(i)||_(i,p))return null;if("dynamic"!==i.eventMode&&"dynamic"!==l||(ys.pauseUpdate=!1),i.interactiveChildren&&i.children){const y=i.children,x=p;for(let p=y.length-1;p>=0;p--){const v=y[p],T=this.hitTestRecursive(v,this._isInteractive(l)?l:v.eventMode,x,m,_);if(T){if(T.length>0&&!T[T.length-1].parent)continue;const l=i.isInteractive();return(T.length>0||l)&&T.push(i),T}}}const y=this._isInteractive(l),x=i.isInteractive();return y&&m(i,p)?x?[i]:[]:null}_isInteractive(i){return"static"===i||"dynamic"===i}_interactivePrune(i){return!(i&&i.visible&&i.renderable&&i.includeInBuild&&i.measurable)||("none"===i.eventMode||"passive"===i.eventMode&&!i.interactiveChildren)}hitPruneFn(i,l){if(i.hitArea&&(i.worldTransform.applyInverse(l,vs),!i.hitArea.contains(vs.x,vs.y)))return!0;if(i.effects&&i.effects.length)for(let p=0;p<i.effects.length;p++){const m=i.effects[p];if(m.containsPoint){if(!m.containsPoint(l,this.hitTestFn))return!0}}return!1}hitTestFn(i,l){return!!i.hitArea||!!i?.containsPoint&&(i.worldTransform.applyInverse(l,vs),i.containsPoint(vs))}notifyTarget(i,l){if(!i.currentTarget.isInteractive())return;const p=`on${l=l??i.type}`;i.currentTarget[p]?.(i);const m=i.eventPhase===i.CAPTURING_PHASE||i.eventPhase===i.AT_TARGET?`${l}capture`:l;this._notifyListeners(i,m),i.eventPhase===i.AT_TARGET&&this._notifyListeners(i,l)}mapPointerDown(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.createPointerEvent(i);if(this.dispatchEvent(l,"pointerdown"),"touch"===l.pointerType)this.dispatchEvent(l,"touchstart");else if("mouse"===l.pointerType||"pen"===l.pointerType){const i=2===l.button;this.dispatchEvent(l,i?"rightdown":"mousedown")}this.trackingData(i.pointerId).pressTargetsByButton[i.button]=l.composedPath(),this.freeEvent(l)}mapPointerMove(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const l=this.createPointerEvent(i);this._isPointerMoveEvent=!1;const p="mouse"===l.pointerType||"pen"===l.pointerType,m=this.trackingData(i.pointerId),_=this.findMountedTarget(m.overTargets);if(m.overTargets?.length>0&&_!==l.target){const m="mousemove"===i.type?"mouseout":"pointerout",y=this.createPointerEvent(i,m,_);if(this.dispatchEvent(y,"pointerout"),p&&this.dispatchEvent(y,"mouseout"),!l.composedPath().includes(_)){const m=this.createPointerEvent(i,"pointerleave",_);for(m.eventPhase=m.AT_TARGET;m.target&&!l.composedPath().includes(m.target);)m.currentTarget=m.target,this.notifyTarget(m),p&&this.notifyTarget(m,"mouseleave"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(y)}if(_!==l.target){const m="mousemove"===i.type?"mouseover":"pointerover",y=this.clonePointerEvent(l,m);this.dispatchEvent(y,"pointerover"),p&&this.dispatchEvent(y,"mouseover");let x=_?.parent;for(;x&&x!==this.rootTarget.parent&&x!==l.target;)x=x.parent;if(!x||x===this.rootTarget.parent){const i=this.clonePointerEvent(l,"pointerenter");for(i.eventPhase=i.AT_TARGET;i.target&&i.target!==_&&i.target!==this.rootTarget.parent;)i.currentTarget=i.target,this.notifyTarget(i),p&&this.notifyTarget(i,"mouseenter"),i.target=i.target.parent;this.freeEvent(i)}this.freeEvent(y)}const y=[],x=this.enableGlobalMoveEvents??!0;this.moveOnAll?y.push("pointermove"):this.dispatchEvent(l,"pointermove"),x&&y.push("globalpointermove"),"touch"===l.pointerType&&(this.moveOnAll?y.splice(1,0,"touchmove"):this.dispatchEvent(l,"touchmove"),x&&y.push("globaltouchmove")),p&&(this.moveOnAll?y.splice(1,0,"mousemove"):this.dispatchEvent(l,"mousemove"),x&&y.push("globalmousemove"),this.cursor=l.target?.cursor),y.length>0&&this.all(l,y),this._allInteractiveElements.length=0,this._hitElements.length=0,m.overTargets=l.composedPath(),this.freeEvent(l)}mapPointerOver(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.trackingData(i.pointerId),p=this.createPointerEvent(i),m="mouse"===p.pointerType||"pen"===p.pointerType;this.dispatchEvent(p,"pointerover"),m&&this.dispatchEvent(p,"mouseover"),"mouse"===p.pointerType&&(this.cursor=p.target?.cursor);const _=this.clonePointerEvent(p,"pointerenter");for(_.eventPhase=_.AT_TARGET;_.target&&_.target!==this.rootTarget.parent;)_.currentTarget=_.target,this.notifyTarget(_),m&&this.notifyTarget(_,"mouseenter"),_.target=_.target.parent;l.overTargets=p.composedPath(),this.freeEvent(p),this.freeEvent(_)}mapPointerOut(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.trackingData(i.pointerId);if(l.overTargets){const p="mouse"===i.pointerType||"pen"===i.pointerType,m=this.findMountedTarget(l.overTargets),_=this.createPointerEvent(i,"pointerout",m);this.dispatchEvent(_),p&&this.dispatchEvent(_,"mouseout");const y=this.createPointerEvent(i,"pointerleave",m);for(y.eventPhase=y.AT_TARGET;y.target&&y.target!==this.rootTarget.parent;)y.currentTarget=y.target,this.notifyTarget(y),p&&this.notifyTarget(y,"mouseleave"),y.target=y.target.parent;l.overTargets=null,this.freeEvent(_),this.freeEvent(y)}this.cursor=null}mapPointerUp(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=performance.now(),p=this.createPointerEvent(i);if(this.dispatchEvent(p,"pointerup"),"touch"===p.pointerType)this.dispatchEvent(p,"touchend");else if("mouse"===p.pointerType||"pen"===p.pointerType){const i=2===p.button;this.dispatchEvent(p,i?"rightup":"mouseup")}const m=this.trackingData(i.pointerId),_=this.findMountedTarget(m.pressTargetsByButton[i.button]);let y=_;if(_&&!p.composedPath().includes(_)){let l=_;for(;l&&!p.composedPath().includes(l);){if(p.currentTarget=l,this.notifyTarget(p,"pointerupoutside"),"touch"===p.pointerType)this.notifyTarget(p,"touchendoutside");else if("mouse"===p.pointerType||"pen"===p.pointerType){const i=2===p.button;this.notifyTarget(p,i?"rightupoutside":"mouseupoutside")}l=l.parent}delete m.pressTargetsByButton[i.button],y=l}if(y){const _=this.clonePointerEvent(p,"click");_.target=y,_.path=null,m.clicksByButton[i.button]||(m.clicksByButton[i.button]={clickCount:0,target:_.target,timeStamp:l});const x=m.clicksByButton[i.button];if(x.target===_.target&&l-x.timeStamp<200?++x.clickCount:x.clickCount=1,x.target=_.target,x.timeStamp=l,_.detail=x.clickCount,"mouse"===_.pointerType){const i=2===_.button;this.dispatchEvent(_,i?"rightclick":"click")}else"touch"===_.pointerType&&this.dispatchEvent(_,"tap");this.dispatchEvent(_,"pointertap"),this.freeEvent(_)}this.freeEvent(p)}mapPointerUpOutside(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.trackingData(i.pointerId),p=this.findMountedTarget(l.pressTargetsByButton[i.button]),m=this.createPointerEvent(i);if(p){let _=p;for(;_;)m.currentTarget=_,this.notifyTarget(m,"pointerupoutside"),"touch"===m.pointerType?this.notifyTarget(m,"touchendoutside"):"mouse"!==m.pointerType&&"pen"!==m.pointerType||this.notifyTarget(m,2===m.button?"rightupoutside":"mouseupoutside"),_=_.parent;delete l.pressTargetsByButton[i.button]}this.freeEvent(m)}mapWheel(i){if(!(i instanceof FederatedWheelEvent))return void warn("EventBoundary cannot map a non-wheel event as a wheel event");const l=this.createWheelEvent(i);this.dispatchEvent(l),this.freeEvent(l)}findMountedTarget(i){if(!i)return null;let l=i[0];for(let p=1;p<i.length&&i[p].parent===l;p++)l=i[p];return l}createPointerEvent(i,l,p){const m=this.allocateEvent(FederatedPointerEvent);return this.copyPointerData(i,m),this.copyMouseData(i,m),this.copyData(i,m),m.nativeEvent=i.nativeEvent,m.originalEvent=i,m.target=p??this.hitTest(m.global.x,m.global.y)??this._hitElements[0],"string"==typeof l&&(m.type=l),m}createWheelEvent(i){const l=this.allocateEvent(FederatedWheelEvent);return this.copyWheelData(i,l),this.copyMouseData(i,l),this.copyData(i,l),l.nativeEvent=i.nativeEvent,l.originalEvent=i,l.target=this.hitTest(l.global.x,l.global.y),l}clonePointerEvent(i,l){const p=this.allocateEvent(FederatedPointerEvent);return p.nativeEvent=i.nativeEvent,p.originalEvent=i.originalEvent,this.copyPointerData(i,p),this.copyMouseData(i,p),this.copyData(i,p),p.target=i.target,p.path=i.composedPath().slice(),p.type=l??p.type,p}copyWheelData(i,l){l.deltaMode=i.deltaMode,l.deltaX=i.deltaX,l.deltaY=i.deltaY,l.deltaZ=i.deltaZ}copyPointerData(i,l){i instanceof FederatedPointerEvent&&l instanceof FederatedPointerEvent&&(l.pointerId=i.pointerId,l.width=i.width,l.height=i.height,l.isPrimary=i.isPrimary,l.pointerType=i.pointerType,l.pressure=i.pressure,l.tangentialPressure=i.tangentialPressure,l.tiltX=i.tiltX,l.tiltY=i.tiltY,l.twist=i.twist)}copyMouseData(i,l){i instanceof FederatedMouseEvent&&l instanceof FederatedMouseEvent&&(l.altKey=i.altKey,l.button=i.button,l.buttons=i.buttons,l.client.copyFrom(i.client),l.ctrlKey=i.ctrlKey,l.metaKey=i.metaKey,l.movement.copyFrom(i.movement),l.screen.copyFrom(i.screen),l.shiftKey=i.shiftKey,l.global.copyFrom(i.global))}copyData(i,l){l.isTrusted=i.isTrusted,l.srcElement=i.srcElement,l.timeStamp=performance.now(),l.type=i.type,l.detail=i.detail,l.view=i.view,l.which=i.which,l.layer.copyFrom(i.layer),l.page.copyFrom(i.page)}trackingData(i){return this.mappingState.trackingData[i]||(this.mappingState.trackingData[i]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[i]}allocateEvent(i){this.eventPool.has(i)||this.eventPool.set(i,[]);const l=this.eventPool.get(i).pop()||new i(this);return l.eventPhase=l.NONE,l.currentTarget=null,l.path=null,l.target=null,l}freeEvent(i){if(i.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const l=i.constructor;this.eventPool.has(l)||this.eventPool.set(l,[]),this.eventPool.get(l).push(i)}_notifyListeners(i,l){const p=i.currentTarget._events[l];if(p)if("fn"in p)p.once&&i.currentTarget.removeListener(l,p.fn,void 0,!0),p.fn.call(p.context,i);else for(let m=0,_=p.length;m<_&&!i.propagationImmediatelyStopped;m++)p[m].once&&i.currentTarget.removeListener(l,p[m].fn,void 0,!0),p[m].fn.call(p[m].context,i)}}const bs={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ws=class _EventSystem{constructor(i){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=i,this.rootBoundary=new EventBoundary(null),ys.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new FederatedPointerEvent(null),this._rootWheelEvent=new FederatedWheelEvent(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({..._EventSystem.defaultEventFeatures},{set:(i,l,p)=>("globalMove"===l&&(this.rootBoundary.enableGlobalMoveEvents=p),i[l]=p,!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(i){const{canvas:l,resolution:p}=this.renderer;this.setTargetElement(l),this.resolution=p,_EventSystem._defaultEventMode=i.eventMode??"passive",Object.assign(this.features,i.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(i){this.resolution=i}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(i){i=i||"default";let l=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(l=!1),this._currentCursor===i)return;this._currentCursor=i;const p=this.cursorStyles[i];if(p)switch(typeof p){case"string":l&&(this.domElement.style.cursor=p);break;case"function":p(i);break;case"object":l&&Object.assign(this.domElement.style,p)}else l&&"string"==typeof i&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,i)&&(this.domElement.style.cursor=i)}get pointer(){return this._rootPointerEvent}_onPointerDown(i){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const l=this._normalizeToPointerData(i);if(this.autoPreventDefault&&l[0].isNormalized){(i.cancelable||!("cancelable"in i))&&i.preventDefault()}for(let i=0,p=l.length;i<p;i++){const p=l[i],m=this._bootstrapEvent(this._rootPointerEvent,p);this.rootBoundary.mapEvent(m)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(i){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ys.pointerMoved();const l=this._normalizeToPointerData(i);for(let i=0,p=l.length;i<p;i++){const p=this._bootstrapEvent(this._rootPointerEvent,l[i]);this.rootBoundary.mapEvent(p)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(i){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let l=i.target;i.composedPath&&i.composedPath().length>0&&(l=i.composedPath()[0]);const p=l!==this.domElement?"outside":"",m=this._normalizeToPointerData(i);for(let i=0,l=m.length;i<l;i++){const l=this._bootstrapEvent(this._rootPointerEvent,m[i]);l.type+=p,this.rootBoundary.mapEvent(l)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(i){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const l=this._normalizeToPointerData(i);for(let i=0,p=l.length;i<p;i++){const p=this._bootstrapEvent(this._rootPointerEvent,l[i]);this.rootBoundary.mapEvent(p)}this.setCursor(this.rootBoundary.cursor)}onWheel(i){if(!this.features.wheel)return;const l=this.normalizeWheelEvent(i);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(l)}setTargetElement(i){this._removeEvents(),this.domElement=i,ys.domElement=i,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;ys.addTickerListener();const i=this.domElement.style;i&&(globalThis.navigator.msPointerEnabled?(i.msContentZooming="none",i.msTouchAction="none"):this.supportsPointerEvents&&(i.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;ys.removeTickerListener();const i=this.domElement.style;i&&(globalThis.navigator.msPointerEnabled?(i.msContentZooming="",i.msTouchAction=""):this.supportsPointerEvents&&(i.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(i,l,p){const m=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},_=1/this.resolution;i.x=(l-m.left)*(this.domElement.width/m.width)*_,i.y=(p-m.top)*(this.domElement.height/m.height)*_}_normalizeToPointerData(i){const l=[];if(this.supportsTouchEvents&&i instanceof TouchEvent)for(let p=0,m=i.changedTouches.length;p<m;p++){const m=i.changedTouches[p];void 0===m.button&&(m.button=0),void 0===m.buttons&&(m.buttons=1),void 0===m.isPrimary&&(m.isPrimary=1===i.touches.length&&"touchstart"===i.type),void 0===m.width&&(m.width=m.radiusX||1),void 0===m.height&&(m.height=m.radiusY||1),void 0===m.tiltX&&(m.tiltX=0),void 0===m.tiltY&&(m.tiltY=0),void 0===m.pointerType&&(m.pointerType="touch"),void 0===m.pointerId&&(m.pointerId=m.identifier||0),void 0===m.pressure&&(m.pressure=m.force||.5),void 0===m.twist&&(m.twist=0),void 0===m.tangentialPressure&&(m.tangentialPressure=0),void 0===m.layerX&&(m.layerX=m.offsetX=m.clientX),void 0===m.layerY&&(m.layerY=m.offsetY=m.clientY),m.isNormalized=!0,m.type=i.type,l.push(m)}else if(globalThis.MouseEvent&&(!(i instanceof MouseEvent)||this.supportsPointerEvents&&i instanceof globalThis.PointerEvent))l.push(i);else{const p=i;void 0===p.isPrimary&&(p.isPrimary=!0),void 0===p.width&&(p.width=1),void 0===p.height&&(p.height=1),void 0===p.tiltX&&(p.tiltX=0),void 0===p.tiltY&&(p.tiltY=0),void 0===p.pointerType&&(p.pointerType="mouse"),void 0===p.pointerId&&(p.pointerId=1),void 0===p.pressure&&(p.pressure=.5),void 0===p.twist&&(p.twist=0),void 0===p.tangentialPressure&&(p.tangentialPressure=0),p.isNormalized=!0,l.push(p)}return l}normalizeWheelEvent(i){const l=this._rootWheelEvent;return this._transferMouseData(l,i),l.deltaX=i.deltaX,l.deltaY=i.deltaY,l.deltaZ=i.deltaZ,l.deltaMode=i.deltaMode,this.mapPositionToPoint(l.screen,i.clientX,i.clientY),l.global.copyFrom(l.screen),l.offset.copyFrom(l.screen),l.nativeEvent=i,l.type=i.type,l}_bootstrapEvent(i,l){return i.originalEvent=null,i.nativeEvent=l,i.pointerId=l.pointerId,i.width=l.width,i.height=l.height,i.isPrimary=l.isPrimary,i.pointerType=l.pointerType,i.pressure=l.pressure,i.tangentialPressure=l.tangentialPressure,i.tiltX=l.tiltX,i.tiltY=l.tiltY,i.twist=l.twist,this._transferMouseData(i,l),this.mapPositionToPoint(i.screen,l.clientX,l.clientY),i.global.copyFrom(i.screen),i.offset.copyFrom(i.screen),i.isTrusted=l.isTrusted,"pointerleave"===i.type&&(i.type="pointerout"),i.type.startsWith("mouse")&&(i.type=i.type.replace("mouse","pointer")),i.type.startsWith("touch")&&(i.type=bs[i.type]||i.type),i}_transferMouseData(i,l){i.isTrusted=l.isTrusted,i.srcElement=l.srcElement,i.timeStamp=performance.now(),i.type=l.type,i.altKey=l.altKey,i.button=l.button,i.buttons=l.buttons,i.client.x=l.clientX,i.client.y=l.clientY,i.ctrlKey=l.ctrlKey,i.metaKey=l.metaKey,i.movement.x=l.movementX,i.movement.y=l.movementY,i.page.x=l.pageX,i.page.y=l.pageY,i.relatedTarget=null,i.shiftKey=l.shiftKey}};ws.extension={name:"events",type:[O.WebGLSystem,O.CanvasSystem,O.WebGPUSystem],priority:-1},ws.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ts=ws;const Ss={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"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(i){this.eventMode=i?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ts.defaultEventMode},set eventMode(i){this._internalEventMode=i},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(i,l,p){const m="boolean"==typeof p&&p||"object"==typeof p&&p.capture,_="object"==typeof p?p.signal:void 0,y="object"==typeof p&&!0===p.once,x="function"==typeof l?void 0:l;i=m?`${i}capture`:i;const v="function"==typeof l?l:l.handleEvent,T=this;_&&_.addEventListener("abort",(()=>{T.off(i,v,x)})),y?T.once(i,v,x):T.on(i,v,x)},removeEventListener(i,l,p){const m="function"==typeof l?void 0:l;i="boolean"==typeof p&&p||"object"==typeof p&&p.capture?`${i}capture`:i,l="function"==typeof l?l:l.handleEvent,this.off(i,l,m)},dispatchEvent(i){if(!(i instanceof FederatedEvent))throw new Error("Container cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};let Ps=0;const Ms=new class TexturePoolClass{constructor(i){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=i||{},this.enableFullScreen=!1}createTexture(i,l,p){const m=new gt({...this.textureOptions,width:i,height:l,resolution:1,antialias:p,autoGarbageCollect:!0});return new Texture({source:m,label:"texturePool_"+Ps++})}getOptimalTexture(i,l,p=1,m){let _=Math.ceil(i*p-1e-6),y=Math.ceil(l*p-1e-6);_=nextPow2(_),y=nextPow2(y);const x=(_<<17)+(y<<1)+(m?1:0);this._texturePool[x]||(this._texturePool[x]=[]);let v=this._texturePool[x].pop();return v||(v=this.createTexture(_,y,m)),v.source._resolution=p,v.source.width=_/p,v.source.height=y/p,v.source.pixelWidth=_,v.source.pixelHeight=y,v.frame.x=0,v.frame.y=0,v.frame.width=i,v.frame.height=l,v.updateUvs(),this._poolKeyHash[v.uid]=x,v}getSameSizeTexture(i,l=!1){const p=i.source;return this.getOptimalTexture(i.width,i.height,p._resolution,l)}returnTexture(i){const l=this._poolKeyHash[i.uid];this._texturePool[l].push(i)}clear(i){if(i=!1!==i)for(const i in this._texturePool){const l=this._texturePool[i];if(l)for(let i=0;i<l.length;i++)l[i].destroy(!0)}this._texturePool={}}};class FilterPipe{constructor(i){this._renderer=i}push(i,l,p){this._renderer.renderPipes.batch.break(p),p.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:l,filterEffect:i})}pop(i,l,p){this._renderer.renderPipes.batch.break(p),p.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(i){"pushFilter"===i.action?this._renderer.filter.push(i):"popFilter"===i.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}FilterPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"filter"};const Cs=new Matrix;function getFastGlobalBounds(i,l){return l.clear(),_getGlobalBoundsRecursive(i,l),l.isValid||l.set(0,0,0,0),i.renderGroup?l.applyMatrix(i.renderGroup.localTransform):l.applyMatrix(i.parentRenderGroup.worldTransform),l}function _getGlobalBoundsRecursive(i,l){if(7!==i.localDisplayStatus||!i.measurable)return;const p=!!i.effects.length;let m=l;if((i.renderGroup||p)&&(m=Lt.get().clear()),i.boundsArea)l.addRect(i.boundsArea,i.worldTransform);else{if(i.renderPipeId){const l=i.bounds;m.addFrame(l.minX,l.minY,l.maxX,l.maxY,i.groupTransform)}const l=i.children;for(let i=0;i<l.length;i++)_getGlobalBoundsRecursive(l[i],m)}if(p){let p=!1;for(let l=0;l<i.effects.length;l++)i.effects[l].addBounds&&(p||(p=!0,m.applyMatrix(i.parentRenderGroup.worldTransform)),i.effects[l].addBounds(m,!0));p&&(m.applyMatrix(i.parentRenderGroup.worldTransform.copyTo(Cs).invert()),l.addBounds(m,i.relativeGroupTransform)),l.addBounds(m),Lt.return(m)}else i.renderGroup&&(l.addBounds(m,i.relativeGroupTransform),Lt.return(m))}const Es=new Geometry({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class FilterSystem{constructor(i){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Ke({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 BindGroup({}),this.renderer=i}get activeBackTexture(){return this._activeFilterData?.backTexture}push(i){const l=this.renderer,p=i.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const m=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,0===p.length)return void(m.skip=!0);const _=m.bounds;i.renderables?function getGlobalRenderableBounds(i,l){l.clear();const p=l.matrix;for(let p=0;p<i.length;p++){const m=i[p];m.globalDisplayStatus<7||(l.matrix=m.worldTransform,m.addBounds(l))}return l.matrix=p,l}(i.renderables,_):i.filterEffect.filterArea?(_.clear(),_.addRect(i.filterEffect.filterArea),_.applyMatrix(i.container.worldTransform)):getFastGlobalBounds(i.container,_);const y=l.renderTarget.renderTarget.colorTexture.source;let x=1/0,v=0,T=!0,S=!1,P=!1;for(let i=0;i<p.length;i++){const m=p[i];x=Math.min(x,"inherit"===m.resolution?y._resolution:m.resolution),v+=m.padding,"off"===m.antialias?T=!1:"inherit"===m.antialias&&T&&(T=y.antialias);if(!!!(m.compatibleRenderers&l.type)){P=!1;break}if(m.blendRequired&&!(l.backBuffer?.useBackBuffer??1)){warn("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),P=!1;break}P=m.enabled||P,S=S||m.blendRequired}if(!P)return void(m.skip=!0);const C=l.renderTarget.rootViewPort;_.scale(x).fitBounds(0,C.width,0,C.height).ceil().scale(1/x).pad(0|v),_.isPositive?(m.skip=!1,m.bounds=_,m.blendRequired=S,m.container=i.container,m.filterEffect=i.filterEffect,m.previousRenderSurface=l.renderTarget.renderSurface,m.inputTexture=Ms.getOptimalTexture(_.width,_.height,x,T),l.renderTarget.bind(m.inputTexture,!0),l.globalUniforms.push({offset:_})):m.skip=!0}pop(){const i=this.renderer;this._filterStackIndex--;const l=this._filterStack[this._filterStackIndex];if(l.skip)return;this._activeFilterData=l;const p=l.inputTexture,m=l.bounds;let _=Texture.EMPTY;if(i.renderTarget.finishRenderPass(),l.blendRequired){const p=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,y=i.renderTarget.getRenderTarget(l.previousRenderSurface);_=this.getBackTexture(y,m,p)}l.backTexture=_;const y=l.filterEffect.filters;if(this._globalFilterBindGroup.setResource(p.source.style,2),this._globalFilterBindGroup.setResource(_.source,3),i.globalUniforms.pop(),1===y.length)y[0].apply(this,p,l.previousRenderSurface,!1),Ms.returnTexture(p);else{let i=l.inputTexture,p=Ms.getOptimalTexture(m.width,m.height,i.source._resolution,!1),_=0;for(_=0;_<y.length-1;++_){y[_].apply(this,i,p,!0);const l=i;i=p,p=l}y[_].apply(this,i,l.previousRenderSurface,!1),Ms.returnTexture(i),Ms.returnTexture(p)}l.blendRequired&&Ms.returnTexture(_)}getBackTexture(i,l,p){const m=i.colorTexture.source._resolution,_=Ms.getOptimalTexture(l.width,l.height,m,!1);let y=l.minX,x=l.minY;p&&(y-=p.minX,x-=p.minY),y=Math.floor(y*m),x=Math.floor(x*m);const v=Math.ceil(l.width*m),T=Math.ceil(l.height*m);return this.renderer.renderTarget.copyToTexture(i,_,{x:y,y:x},{width:v,height:T},{x:0,y:0}),_}applyFilter(i,l,p,m){const _=this.renderer,y=this._filterStack[this._filterStackIndex],x=y.bounds,v=Point.shared,T=y.previousRenderSurface===p;let S=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,P=this._filterStackIndex-1;for(;P>0&&this._filterStack[P].skip;)--P;P>0&&(S=this._filterStack[P].inputTexture.source._resolution);const C=this._filterGlobalUniforms,E=C.uniforms,A=E.uOutputFrame,k=E.uInputSize,B=E.uInputPixel,F=E.uInputClamp,R=E.uGlobalFrame,I=E.uOutputTexture;if(T){let i=this._filterStackIndex;for(;i>0;){i--;const l=this._filterStack[this._filterStackIndex-1];if(!l.skip){v.x=l.bounds.minX,v.y=l.bounds.minY;break}}A[0]=x.minX-v.x,A[1]=x.minY-v.y}else A[0]=0,A[1]=0;A[2]=l.frame.width,A[3]=l.frame.height,k[0]=l.source.width,k[1]=l.source.height,k[2]=1/k[0],k[3]=1/k[1],B[0]=l.source.pixelWidth,B[1]=l.source.pixelHeight,B[2]=1/B[0],B[3]=1/B[1],F[0]=.5*B[2],F[1]=.5*B[3],F[2]=l.frame.width*k[2]-.5*B[2],F[3]=l.frame.height*k[3]-.5*B[3];const D=this.renderer.renderTarget.rootRenderTarget.colorTexture;R[0]=v.x*S,R[1]=v.y*S,R[2]=D.source.width*S,R[3]=D.source.height*S;const L=this.renderer.renderTarget.getRenderTarget(p);if(_.renderTarget.bind(p,!!m),p instanceof Texture?(I[0]=p.frame.width,I[1]=p.frame.height):(I[0]=L.width,I[1]=L.height),I[2]=L.isRoot?-1:1,C.update(),_.renderPipes.uniformBatch){const i=_.renderPipes.uniformBatch.getUboResource(C);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(C,0);this._globalFilterBindGroup.setResource(l.source,1),this._globalFilterBindGroup.setResource(l.source.style,2),i.groups[0]=this._globalFilterBindGroup,_.encoder.draw({geometry:Es,shader:i,state:i._state,topology:"triangle-list"}),_.type===Ye.WEBGL&&_.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new Bounds,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(i,l){const p=this._activeFilterData,m=i.set(p.inputTexture._source.width,0,0,p.inputTexture._source.height,p.bounds.minX,p.bounds.minY),_=l.worldTransform.copyTo(Matrix.shared);return _.invert(),m.prepend(_),m.scale(1/l.texture.frame.width,1/l.texture.frame.height),m.translate(l.anchor.x,l.anchor.y),m}}FilterSystem.extension={type:[O.WebGLSystem,O.WebGPUSystem],name:"filter"};class Graphics extends ViewContainer{constructor(i){i instanceof ns&&(i={context:i});const{context:l,roundPixels:p,...m}=i||{};super({label:"Graphics",...m}),this.renderPipeId="graphics",this._context=l||(this._ownedContext=new ns),this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=p??!1}set context(i){i!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=i,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(i){i.addBounds(this._context.bounds)}containsPoint(i){return this._context.containsPoint(i)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const i=this.renderGroup||this.parentRenderGroup;i&&i.onChildViewUpdate(this)}destroy(i){this._ownedContext&&!i?this._ownedContext.destroy(i):!0!==i&&!0!==i?.context||this._context.destroy(i),this._ownedContext=null,this._context=null,super.destroy(i)}_callContextMethod(i,l){return this.context[i](...l),this}setFillStyle(...i){return this._callContextMethod("setFillStyle",i)}setStrokeStyle(...i){return this._callContextMethod("setStrokeStyle",i)}fill(...i){return this._callContextMethod("fill",i)}stroke(...i){return this._callContextMethod("stroke",i)}texture(...i){return this._callContextMethod("texture",i)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...i){return this._callContextMethod("arc",i)}arcTo(...i){return this._callContextMethod("arcTo",i)}arcToSvg(...i){return this._callContextMethod("arcToSvg",i)}bezierCurveTo(...i){return this._callContextMethod("bezierCurveTo",i)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...i){return this._callContextMethod("ellipse",i)}circle(...i){return this._callContextMethod("circle",i)}path(...i){return this._callContextMethod("path",i)}lineTo(...i){return this._callContextMethod("lineTo",i)}moveTo(...i){return this._callContextMethod("moveTo",i)}quadraticCurveTo(...i){return this._callContextMethod("quadraticCurveTo",i)}rect(...i){return this._callContextMethod("rect",i)}roundRect(...i){return this._callContextMethod("roundRect",i)}poly(...i){return this._callContextMethod("poly",i)}regularPoly(...i){return this._callContextMethod("regularPoly",i)}roundPoly(...i){return this._callContextMethod("roundPoly",i)}roundShape(...i){return this._callContextMethod("roundShape",i)}filletRect(...i){return this._callContextMethod("filletRect",i)}chamferRect(...i){return this._callContextMethod("chamferRect",i)}star(...i){return this._callContextMethod("star",i)}svg(...i){return this._callContextMethod("svg",i)}restore(...i){return this._callContextMethod("restore",i)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...i){return this._callContextMethod("rotate",i)}scaleTransform(...i){return this._callContextMethod("scale",i)}setTransform(...i){return this._callContextMethod("setTransform",i)}transform(...i){return this._callContextMethod("transform",i)}translateTransform(...i){return this._callContextMethod("translate",i)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(i){this._context.fillStyle=i}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(i){this._context.strokeStyle=i}clone(i=!1){if(i)return new Graphics(this._context.clone());this._ownedContext=null;return new Graphics(this._context)}lineStyle(i,l,p){deprecation(ut,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const m={};return i&&(m.width=i),l&&(m.color=l),p&&(m.alpha=p),this.context.strokeStyle=m,this}beginFill(i,l){deprecation(ut,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const p={};return i&&(p.color=i),l&&(p.alpha=l),this.context.fillStyle=p,this}endFill(){deprecation(ut,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const i=this.context.strokeStyle;return i.width===ns.defaultStrokeStyle.width&&i.color===ns.defaultStrokeStyle.color&&i.alpha===ns.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...i){return deprecation(ut,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",i)}drawEllipse(...i){return deprecation(ut,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",i)}drawPolygon(...i){return deprecation(ut,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",i)}drawRect(...i){return deprecation(ut,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",i)}drawRoundedRect(...i){return deprecation(ut,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",i)}drawStar(...i){return deprecation(ut,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",i)}}const As=class _MeshGeometry extends Geometry{constructor(...i){let l=i[0]??{};l instanceof Float32Array&&(deprecation(ut,"use new MeshGeometry({ positions, uvs, indices }) instead"),l={positions:l,uvs:i[1],indices:i[2]}),l={..._MeshGeometry.defaultOptions,...l};const p=l.positions||new Float32Array([0,0,1,0,1,1,0,1]),m=l.uvs||new Float32Array([0,0,1,0,1,1,0,1]),_=l.indices||new Uint32Array([0,1,2,0,2,3]),y=l.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new Buffer({data:p,label:"attribute-mesh-positions",shrinkToFit:y,usage:mi.VERTEX|mi.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new Buffer({data:m,label:"attribute-mesh-uvs",shrinkToFit:y,usage:mi.VERTEX|mi.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new Buffer({data:_,label:"index-mesh-buffer",shrinkToFit:y,usage:mi.INDEX|mi.COPY_DST}),topology:l.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(i){this.attributes.aPosition.buffer.data=i}get uvs(){return this.attributes.aUV.buffer.data}set uvs(i){this.attributes.aUV.buffer.data=i}get indices(){return this.indexBuffer.data}set indices(i){this.indexBuffer.data=i}};As.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ks=As;function textStyleToCSS(i){const l=i._stroke,p=i._fill,m=[`div { ${[`color: ${At.shared.setValue(p.color).toHex()}`,`font-size: ${i.fontSize}px`,`font-family: ${i.fontFamily}`,`font-weight: ${i.fontWeight}`,`font-style: ${i.fontStyle}`,`font-variant: ${i.fontVariant}`,`letter-spacing: ${i.letterSpacing}px`,`text-align: ${i.align}`,`padding: ${i.padding}px`,`white-space: ${"pre"===i.whiteSpace&&i.wordWrap?"pre-wrap":i.whiteSpace}`,...i.lineHeight?[`line-height: ${i.lineHeight}px`]:[],...i.wordWrap?["word-wrap: "+(i.breakWords?"break-all":"break-word"),`max-width: ${i.wordWrapWidth}px`]:[],...l?[strokeToCSS(l)]:[],...i.dropShadow?[dropShadowToCSS(i.dropShadow)]:[],...i.cssOverrides].join(";")} }`];return function tagStyleToCSS(i,l){for(const p in i){const m=i[p],_=[];for(const i in m)Fs[i]?_.push(Fs[i](m[i])):Bs[i]&&_.push(Bs[i].replace("{{VALUE}}",m[i]));l.push(`${p} { ${_.join(";")} }`)}}(i.tagStyles,m),m.join(" ")}function dropShadowToCSS(i){const l=At.shared.setValue(i.color).setAlpha(i.alpha).toHexa(),p=`${Math.round(Math.cos(i.angle)*i.distance)}px ${Math.round(Math.sin(i.angle)*i.distance)}px`;return i.blur>0?`text-shadow: ${p} ${i.blur}px ${l}`:`text-shadow: ${p} ${l}`}function strokeToCSS(i){return[`-webkit-text-stroke-width: ${i.width}px`,`-webkit-text-stroke-color: ${At.shared.setValue(i.color).toHex()}`,`text-stroke-width: ${i.width}px`,`text-stroke-color: ${At.shared.setValue(i.color).toHex()}`,"paint-order: stroke"].join(";")}const Bs={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Fs={fill:i=>`color: ${At.shared.setValue(i).toHex()}`,breakWords:i=>"word-wrap: "+(i?"break-all":"break-word"),stroke:strokeToCSS,dropShadow:dropShadowToCSS};class HTMLTextStyle extends hs{constructor(i={}){super(i),this._cssOverrides=[],this.cssOverrides??(this.cssOverrides=i.cssOverrides),this.tagStyles=i.tagStyles??{}}set cssOverrides(i){this._cssOverrides=i instanceof Array?i:[i],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=generateTextStyleKey(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new HTMLTextStyle({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?{...this.dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=textStyleToCSS(this)),this._cssStyle}addOverride(...i){const l=i.filter((i=>!this.cssOverrides.includes(i)));l.length>0&&(this.cssOverrides.push(...l),this.update())}removeOverride(...i){const l=i.filter((i=>this.cssOverrides.includes(i)));l.length>0&&(this.cssOverrides=this.cssOverrides.filter((i=>!l.includes(i))),this.update())}set fill(i){"string"!=typeof i&&"number"!=typeof i&&warn("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=i}set stroke(i){i&&"string"!=typeof i&&"number"!=typeof i&&warn("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=i}}const Rs="http://www.w3.org/2000/svg",Is="http://www.w3.org/1999/xhtml";class HTMLTextRenderData{constructor(){this.svgRoot=document.createElementNS(Rs,"svg"),this.foreignObject=document.createElementNS(Rs,"foreignObject"),this.domElement=document.createElementNS(Is,"div"),this.styleElement=document.createElementNS(Is,"style"),this.image=new Image;const{foreignObject:i,svgRoot:l,styleElement:p,domElement:m}=this;i.setAttribute("width","10000"),i.setAttribute("height","10000"),i.style.overflow="hidden",l.appendChild(i),i.appendChild(p),i.appendChild(m)}}let Ds;const Ls={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}};Ls.vertex,Ls.vertex.header.replace("group(1)","group(2)");const Us={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}};class BatchableSprite{constructor(){this.batcherName="default",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}}function color32BitToUniform(i,l,p){const m=(i>>24&255)/255;l[p++]=(255&i)/255*m,l[p++]=(i>>8&255)/255*m,l[p++]=(i>>16&255)/255*m,l[p++]=m}class GraphicsPipe{constructor(i,l){this.state=Xe.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=i,this._adaptor=l,this._adaptor.init()}validateRenderable(i){const l=i.context,p=!!this._graphicsBatchesHash[i.uid],m=this.renderer.graphicsContext.updateGpuContext(l);return!(!m.isBatchable&&p===m.isBatchable)}addRenderable(i,l){const p=this.renderer.graphicsContext.updateGpuContext(i.context);i._didGraphicsUpdate&&(i._didGraphicsUpdate=!1,this._rebuild(i)),p.isBatchable?this._addToBatcher(i,l):(this.renderer.renderPipes.batch.break(l),l.add(i))}updateRenderable(i){const l=this._graphicsBatchesHash[i.uid];if(l)for(let i=0;i<l.length;i++){const p=l[i];p._batcher.updateElement(p)}}destroyRenderable(i){this._graphicsBatchesHash[i.uid]&&this._removeBatchForRenderable(i.uid),i.off("destroyed",this._destroyRenderableBound)}execute(i){if(!i.isRenderable)return;const l=this.renderer,p=i.context;if(!l.graphicsContext.getGpuContext(p).batches.length)return;const m=p.customShader||this._adaptor.shader;this.state.blendMode=i.groupBlendMode;const _=m.resources.localUniforms.uniforms;_.uTransformMatrix=i.groupTransform,_.uRound=l._roundPixels|i._roundPixels,color32BitToUniform(i.groupColorAlpha,_.uColor,0),this._adaptor.execute(this,i)}_rebuild(i){const l=!!this._graphicsBatchesHash[i.uid],p=this.renderer.graphicsContext.updateGpuContext(i.context);l&&this._removeBatchForRenderable(i.uid),p.isBatchable&&this._initBatchesForRenderable(i),i.batched=p.isBatchable}_addToBatcher(i,l){const p=this.renderer.renderPipes.batch,m=this._getBatchesForRenderable(i);for(let i=0;i<m.length;i++){const _=m[i];p.addToBatch(_,l)}}_getBatchesForRenderable(i){return this._graphicsBatchesHash[i.uid]||this._initBatchesForRenderable(i)}_initBatchesForRenderable(i){const l=i.context,p=this.renderer.graphicsContext.getGpuContext(l),m=this.renderer._roundPixels|i._roundPixels,_=p.batches.map((l=>{const p=kt.get(BatchableGraphics);return l.copyTo(p),p.renderable=i,p.roundPixels=m,p}));return void 0===this._graphicsBatchesHash[i.uid]&&i.on("destroyed",this._destroyRenderableBound),this._graphicsBatchesHash[i.uid]=_,_}_removeBatchForRenderable(i){this._graphicsBatchesHash[i].forEach((i=>{kt.return(i)})),this._graphicsBatchesHash[i]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const i in this._graphicsBatchesHash)this._removeBatchForRenderable(i);this._graphicsBatchesHash=null}}GraphicsPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"graphics"};const Gs=class _PlaneGeometry extends ks{constructor(...i){super({});let l=i[0]??{};"number"==typeof l&&(deprecation(ut,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),l={width:l,height:i[1],verticesX:i[2],verticesY:i[3]}),this.build(l)}build(i){i={..._PlaneGeometry.defaultOptions,...i},this.verticesX=this.verticesX??i.verticesX,this.verticesY=this.verticesY??i.verticesY,this.width=this.width??i.width,this.height=this.height??i.height;const l=this.verticesX*this.verticesY,p=[],m=[],_=[],y=this.verticesX-1,x=this.verticesY-1,v=this.width/y,T=this.height/x;for(let i=0;i<l;i++){const l=i%this.verticesX,_=i/this.verticesX|0;p.push(l*v,_*T),m.push(l/y,_/x)}const S=y*x;for(let i=0;i<S;i++){const l=i%y,p=i/y|0,m=p*this.verticesX+l,x=p*this.verticesX+l+1,v=(p+1)*this.verticesX+l,T=(p+1)*this.verticesX+l+1;_.push(m,x,v,x,T,v)}this.buffers[0].data=new Float32Array(p),this.buffers[1].data=new Float32Array(m),this.indexBuffer.data=new Uint32Array(_),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Gs.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Os=Gs;class BatchableMesh{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get uvs(){const i=this.geometry.getBuffer("aUV"),l=i.data;let p=l;const m=this.texture.textureMatrix;return m.isSimple||(p=this._transformedUvs,this._textureMatrixUpdateId===m._updateID&&this._uvUpdateId===i._updateID||((!p||p.length<l.length)&&(p=this._transformedUvs=new Float32Array(l.length)),this._textureMatrixUpdateId=m._updateID,this._uvUpdateId=i._updateID,m.multiplyUvs(l,p))),p}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class MeshPipe{constructor(i,l){this.localUniforms=new Ke({uTransformMatrix:{value:new Matrix,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new BindGroup({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=i,this._adaptor=l,this._adaptor.init()}validateRenderable(i){const l=this._getMeshData(i),p=l.batched,m=i.batched;if(l.batched=m,p!==m)return!0;if(m){const p=i._geometry;if(p.indices.length!==l.indexSize||p.positions.length!==l.vertexSize)return l.indexSize=p.indices.length,l.vertexSize=p.positions.length,!0;const m=this._getBatchableMesh(i),_=i.texture;if(m.texture._source!==_._source&&m.texture._source!==_._source)return!m._batcher.checkAndUpdateTexture(m,_)}return!1}addRenderable(i,l){const p=this.renderer.renderPipes.batch,{batched:m}=this._getMeshData(i);if(m){const m=this._getBatchableMesh(i);m.texture=i._texture,m.geometry=i._geometry,p.addToBatch(m,l)}else p.break(l),l.add(i)}updateRenderable(i){if(i.batched){const l=this._gpuBatchableMeshHash[i.uid];l.texture=i._texture,l.geometry=i._geometry,l._batcher.updateElement(l)}}destroyRenderable(i){this._meshDataHash[i.uid]=null;const l=this._gpuBatchableMeshHash[i.uid];l&&(kt.return(l),this._gpuBatchableMeshHash[i.uid]=null),i.off("destroyed",this._destroyRenderableBound)}execute(i){if(!i.isRenderable)return;i.state.blendMode=getAdjustedBlendModeBlend(i.groupBlendMode,i.texture._source);const l=this.localUniforms;l.uniforms.uTransformMatrix=i.groupTransform,l.uniforms.uRound=this.renderer._roundPixels|i._roundPixels,l.update(),color32BitToUniform(i.groupColorAlpha,l.uniforms.uColor,0),this._adaptor.execute(this,i)}_getMeshData(i){return this._meshDataHash[i.uid]||this._initMeshData(i)}_initMeshData(i){return this._meshDataHash[i.uid]={batched:i.batched,indexSize:i._geometry.indices?.length,vertexSize:i._geometry.positions?.length},i.on("destroyed",this._destroyRenderableBound),this._meshDataHash[i.uid]}_getBatchableMesh(i){return this._gpuBatchableMeshHash[i.uid]||this._initBatchableMesh(i)}_initBatchableMesh(i){const l=kt.get(BatchableMesh);return l.renderable=i,l.texture=i._texture,l.transform=i.groupTransform,l.roundPixels=this.renderer._roundPixels|i._roundPixels,this._gpuBatchableMeshHash[i.uid]=l,l}destroy(){for(const i in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[i]&&kt.return(this._gpuBatchableMeshHash[i]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}MeshPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"mesh"};const zs=class _NineSliceGeometry extends Os{constructor(i={}){super({width:(i={..._NineSliceGeometry.defaultOptions,...i}).width,height:i.height,verticesX:4,verticesY:4}),this.update(i)}update(i){this.width=i.width??this.width,this.height=i.height??this.height,this._originalWidth=i.originalWidth??this._originalWidth,this._originalHeight=i.originalHeight??this._originalHeight,this._leftWidth=i.leftWidth??this._leftWidth,this._rightWidth=i.rightWidth??this._rightWidth,this._topHeight=i.topHeight??this._topHeight,this._bottomHeight=i.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const i=this.positions,l=this._leftWidth+this._rightWidth,p=this.width>l?1:this.width/l,m=this._topHeight+this._bottomHeight,_=this.height>m?1:this.height/m,y=Math.min(p,_);i[9]=i[11]=i[13]=i[15]=this._topHeight*y,i[17]=i[19]=i[21]=i[23]=this.height-this._bottomHeight*y,i[25]=i[27]=i[29]=i[31]=this.height,i[2]=i[10]=i[18]=i[26]=this._leftWidth*y,i[4]=i[12]=i[20]=i[28]=this.width-this._rightWidth*y,i[6]=i[14]=i[22]=i[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const i=this.uvs;i[0]=i[8]=i[16]=i[24]=0,i[1]=i[3]=i[5]=i[7]=0,i[6]=i[14]=i[22]=i[30]=1,i[25]=i[27]=i[29]=i[31]=1;const l=1/this._originalWidth,p=1/this._originalHeight;i[2]=i[10]=i[18]=i[26]=l*this._leftWidth,i[9]=i[11]=i[13]=i[15]=p*this._topHeight,i[4]=i[12]=i[20]=i[28]=1-l*this._rightWidth,i[17]=i[19]=i[21]=i[23]=1-p*this._bottomHeight,this.getBuffer("aUV").update()}};zs.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Ns=zs;class NineSliceSpritePipe{constructor(i){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i}addRenderable(i,l){const p=this._getGpuSprite(i);i._didSpriteUpdate&&this._updateBatchableSprite(i,p),this._renderer.renderPipes.batch.addToBatch(p,l)}updateRenderable(i){const l=this._gpuSpriteHash[i.uid];i._didSpriteUpdate&&this._updateBatchableSprite(i,l),l._batcher.updateElement(l)}validateRenderable(i){const l=i._texture,p=this._getGpuSprite(i);return p.texture._source!==l._source&&!p._batcher.checkAndUpdateTexture(p,l)}destroyRenderable(i){const l=this._gpuSpriteHash[i.uid];kt.return(l.geometry),kt.return(l),this._gpuSpriteHash[i.uid]=null,i.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(i,l){i._didSpriteUpdate=!1,l.geometry.update(i),l.texture=i._texture}_getGpuSprite(i){return this._gpuSpriteHash[i.uid]||this._initGPUSprite(i)}_initGPUSprite(i){const l=kt.get(BatchableMesh);return l.geometry=kt.get(Ns),l.renderable=i,l.transform=i.groupTransform,l.texture=i._texture,l.roundPixels=this._renderer._roundPixels|i._roundPixels,i._didSpriteUpdate=!0,this._gpuSpriteHash[i.uid]=l,i.on("destroyed",this._destroyRenderableBound),l}destroy(){for(const i in this._gpuSpriteHash){this._gpuSpriteHash[i].geometry.destroy()}this._gpuSpriteHash=null,this._renderer=null}}NineSliceSpritePipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"nineSliceSprite"};const Hs={name:"tiling-bit",vertex:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n "},fragment:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n } \n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n "}},Ws={name:"tiling-bit",vertex:{header:"\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n \n ",main:"\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n ",main:"\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n \n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n \n "}};let Ks,Ys;class TilingSpriteShader extends Shader{constructor(){Ks??(Ks=compileHighShaderGpuProgram({name:"tiling-sprite-shader",bits:[Ls,Hs,Ei]})),Ys??(Ys=compileHighShaderGlProgram({name:"tiling-sprite-shader",bits:[Us,Ws,Ai]}));const i=new Ke({uMapCoord:{value:new Matrix,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new Matrix,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Ys,gpuProgram:Ks,resources:{localUniforms:new Ke({uTransformMatrix:{value:new Matrix,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:i,uTexture:Texture.EMPTY.source,uSampler:Texture.EMPTY.source.style}})}updateUniforms(i,l,p,m,_,y){const x=this.resources.tilingUniforms,v=y.width,T=y.height,S=y.textureMatrix,P=x.uniforms.uTextureTransform;P.set(p.a*v/i,p.b*v/l,p.c*T/i,p.d*T/l,p.tx/i,p.ty/l),P.invert(),x.uniforms.uMapCoord=S.mapCoord,x.uniforms.uClampFrame=S.uClampFrame,x.uniforms.uClampOffset=S.uClampOffset,x.uniforms.uTextureTransform=P,x.uniforms.uSizeAnchor[0]=i,x.uniforms.uSizeAnchor[1]=l,x.uniforms.uSizeAnchor[2]=m,x.uniforms.uSizeAnchor[3]=_,y&&(this.resources.uTexture=y.source,this.resources.uSampler=y.source.style)}}const Vs=new class QuadGeometry extends ks{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}};class TilingSpritePipe{constructor(i){this._state=Xe.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i}validateRenderable(i){const l=this._getTilingSpriteData(i),p=l.canBatch;this._updateCanBatch(i);const m=l.canBatch;if(m&&m===p){const{batchableMesh:p}=l;if(p&&p.texture._source!==i.texture._source)return!p._batcher.checkAndUpdateTexture(p,i.texture)}return p!==m}addRenderable(i,l){const p=this._renderer.renderPipes.batch;this._updateCanBatch(i);const m=this._getTilingSpriteData(i),{geometry:_,canBatch:y}=m;if(y){m.batchableMesh||(m.batchableMesh=new BatchableMesh);const y=m.batchableMesh;i._didTilingSpriteUpdate&&(i._didTilingSpriteUpdate=!1,this._updateBatchableMesh(i),y.geometry=_,y.renderable=i,y.transform=i.groupTransform,y.texture=i._texture),y.roundPixels=this._renderer._roundPixels|i._roundPixels,p.addToBatch(y,l)}else p.break(l),m.shader||(m.shader=new TilingSpriteShader),this.updateRenderable(i),l.add(i)}execute(i){const{shader:l}=this._tilingSpriteDataHash[i.uid];l.groups[0]=this._renderer.globalUniforms.bindGroup;const p=l.resources.localUniforms.uniforms;p.uTransformMatrix=i.groupTransform,p.uRound=this._renderer._roundPixels|i._roundPixels,color32BitToUniform(i.groupColorAlpha,p.uColor,0),this._state.blendMode=getAdjustedBlendModeBlend(i.groupBlendMode,i.texture._source),this._renderer.encoder.draw({geometry:Vs,shader:l,state:this._state})}updateRenderable(i){const l=this._getTilingSpriteData(i),{canBatch:p}=l;if(p){const{batchableMesh:p}=l;i._didTilingSpriteUpdate&&this._updateBatchableMesh(i),p._batcher.updateElement(p)}else if(i._didTilingSpriteUpdate){const{shader:p}=l;p.updateUniforms(i.width,i.height,i._tileTransform.matrix,i.anchor.x,i.anchor.y,i.texture)}i._didTilingSpriteUpdate=!1}destroyRenderable(i){const l=this._getTilingSpriteData(i);l.batchableMesh=null,l.shader?.destroy(),this._tilingSpriteDataHash[i.uid]=null,i.off("destroyed",this._destroyRenderableBound)}_getTilingSpriteData(i){return this._tilingSpriteDataHash[i.uid]||this._initTilingSpriteData(i)}_initTilingSpriteData(i){const l=new ks({indices:Vs.indices,positions:Vs.positions.slice(),uvs:Vs.uvs.slice()});return this._tilingSpriteDataHash[i.uid]={canBatch:!0,renderable:i,geometry:l},i.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[i.uid]}_updateBatchableMesh(i){const l=this._getTilingSpriteData(i),{geometry:p}=l,m=i.texture.source.style;"repeat"!==m.addressMode&&(m.addressMode="repeat",m.update()),function setUvs(i,l){const p=i.texture,m=p.frame.width,_=p.frame.height;let y=0,x=0;i._applyAnchorToTexture&&(y=i.anchor.x,x=i.anchor.y),l[0]=l[6]=-y,l[2]=l[4]=1-y,l[1]=l[3]=-x,l[5]=l[7]=1-x;const v=Matrix.shared;v.copyFrom(i._tileTransform.matrix),v.tx/=i.width,v.ty/=i.height,v.invert(),v.scale(i.width/m,i.height/_),function applyMatrix(i,l,p,m){let _=0;const y=i.length/l,x=m.a,v=m.b,T=m.c,S=m.d,P=m.tx,C=m.ty;for(p*=l;_<y;){const m=i[p],y=i[p+1];i[p]=x*m+T*y+P,i[p+1]=v*m+S*y+C,p+=l,_++}}(l,2,0,v)}(i,p.uvs),function setPositions(i,l){const p=i.anchor.x,m=i.anchor.y;l[0]=-p*i.width,l[1]=-m*i.height,l[2]=(1-p)*i.width,l[3]=-m*i.height,l[4]=(1-p)*i.width,l[5]=(1-m)*i.height,l[6]=-p*i.width,l[7]=(1-m)*i.height}(i,p.positions)}destroy(){for(const i in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[i].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(i){const l=this._getTilingSpriteData(i),p=i.texture;let m=!0;return this._renderer.type===Ye.WEBGL&&(m=this._renderer.context.supports.nonPowOf2wrapping),l.canBatch=p.textureMatrix.isSimple&&(m||p.source.isPowerOfTwo),l.canBatch}}TilingSpritePipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"tilingSprite"};const $s={name:"local-uniform-msdf-bit",vertex:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32,\n uRound:f32,\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:" \n outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));\n "}},Xs={name:"local-uniform-msdf-bit",vertex:{header:"\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix *= uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:"\n uniform float uDistance;\n ",main:" \n outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));\n "}},js={name:"msdf-bit",fragment:{header:"\n fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {\n \n // MSDF\n var median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n \n // SDF\n median = min(median, msdfColor.a);\n\n var screenPxDistance = distance * (median - 0.5);\n var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));\n var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);\n var coverage: f32 = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n \n }\n "}},qs={name:"msdf-bit",fragment:{header:"\n float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {\n \n // MSDF\n float median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n \n // SDF\n median = min(median, msdfColor.a);\n \n float screenPxDistance = distance * (median - 0.5);\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n \n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));\n float gamma = mix(1.0, 1.0 / 2.2, luma);\n float coverage = pow(shapeColor.a * alpha, gamma); \n \n return coverage;\n }\n "}};let Zs,Qs;class SdfShader extends Shader{constructor(){const i=new Ke({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new Matrix,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),l=getMaxTexturesPerBatch();Zs??(Zs=compileHighShaderGpuProgram({name:"sdf-shader",bits:[Si,generateTextureBatchBit(l),$s,js,Ei]})),Qs??(Qs=compileHighShaderGlProgram({name:"sdf-shader",bits:[Pi,generateTextureBatchBitGl(l),Xs,qs,Ai]})),super({glProgram:Qs,gpuProgram:Zs,resources:{localUniforms:i,batchSamplers:getBatchSamplersUniformGroup(l)}})}}class BitmapTextPipe{constructor(i){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i}validateRenderable(i){const l=this._getGpuBitmapText(i);return i._didTextUpdate&&(i._didTextUpdate=!1,this._updateContext(i,l)),this._renderer.renderPipes.graphics.validateRenderable(l)}addRenderable(i,l){const p=this._getGpuBitmapText(i);syncWithProxy(i,p),i._didTextUpdate&&(i._didTextUpdate=!1,this._updateContext(i,p)),this._renderer.renderPipes.graphics.addRenderable(p,l),p.context.customShader&&this._updateDistanceField(i)}destroyRenderable(i){i.off("destroyed",this._destroyRenderableBound),this._destroyRenderableByUid(i.uid)}_destroyRenderableByUid(i){const l=this._gpuBitmapText[i].context;l.customShader&&(kt.return(l.customShader),l.customShader=null),kt.return(this._gpuBitmapText[i]),this._gpuBitmapText[i]=null}updateRenderable(i){const l=this._getGpuBitmapText(i);syncWithProxy(i,l),this._renderer.renderPipes.graphics.updateRenderable(l),l.context.customShader&&this._updateDistanceField(i)}_updateContext(i,l){const{context:p}=l,m=_s.getFont(i.text,i._style);p.clear(),"none"!==m.distanceField.type&&(p.customShader||(p.customShader=kt.get(SdfShader)));const _=Array.from(i.text),y=i._style;let x=m.baseLineOffset;const v=getBitmapTextLayout(_,y,m,!0);let T=0;const S=y.padding,P=v.scale;let C=v.width,E=v.height+v.offsetY;y._stroke&&(C+=y._stroke.width/P,E+=y._stroke.width/P),p.translate(-i._anchor._x*C-S,-i._anchor._y*E-S).scale(P,P);const A=m.applyFillAsTint?y._fill.color:16777215;for(let i=0;i<v.lines.length;i++){const l=v.lines[i];for(let i=0;i<l.charPositions.length;i++){const y=_[T++],v=m.chars[y];v?.texture&&p.texture(v.texture,A||"black",Math.round(l.charPositions[i]+v.xOffset),Math.round(x+v.yOffset))}x+=m.lineHeight}}_getGpuBitmapText(i){return this._gpuBitmapText[i.uid]||this.initGpuText(i)}initGpuText(i){const l=kt.get(Graphics);return this._gpuBitmapText[i.uid]=l,this._updateContext(i,l),i.on("destroyed",this._destroyRenderableBound),this._gpuBitmapText[i.uid]}_updateDistanceField(i){const l=this._getGpuBitmapText(i).context,p=i._style.fontFamily,m=se.get(`${p}-bitmap`),{a:_,b:y,c:x,d:v}=i.groupTransform,T=Math.sqrt(_*_+y*y),S=Math.sqrt(x*x+v*v),P=(Math.abs(T)+Math.abs(S))/2,C=m.baseRenderedFontSize/i._style.fontSize,E=P*m.distanceField.range*(1/C);l.customShader.resources.localUniforms.uniforms.uDistance=E}destroy(){for(const i in this._gpuBitmapText)this._destroyRenderableByUid(i);this._gpuBitmapText=null,this._renderer=null}}function syncWithProxy(i,l){l.groupTransform=i.groupTransform,l.groupColorAlpha=i.groupColorAlpha,l.groupColor=i.groupColor,l.groupBlendMode=i.groupBlendMode,l.globalDisplayStatus=i.globalDisplayStatus,l.groupTransform=i.groupTransform,l.localDisplayStatus=i.localDisplayStatus,l.groupAlpha=i.groupAlpha,l._roundPixels=i._roundPixels}BitmapTextPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"bitmapText"};class HTMLTextPipe{constructor(i){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const i in this._gpuText){const l=this._gpuText[i];if(!l)continue;const p=l.batchableSprite.renderable;p._autoResolution&&(p._resolution=this._renderer.resolution,p.onViewUpdate())}}validateRenderable(i){const l=this._getGpuText(i),p=i._getKey();return l.textureNeedsUploading?(l.textureNeedsUploading=!1,!0):l.currentKey!==p}addRenderable(i,l){const p=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),this._renderer.renderPipes.batch.addToBatch(p,l)}updateRenderable(i){const l=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),l._batcher.updateElement(l)}destroyRenderable(i){i.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(i.uid)}_destroyRenderableById(i){const l=this._gpuText[i];this._renderer.htmlText.decreaseReferenceCount(l.currentKey),kt.return(l.batchableSprite),this._gpuText[i]=null}_updateText(i){const l=i._getKey(),p=this._getGpuText(i),m=p.batchableSprite;p.currentKey!==l&&this._updateGpuText(i).catch((i=>{console.error(i)})),i._didTextUpdate=!1;const _=i._style.padding;updateQuadBounds(m.bounds,i._anchor,m.texture,_)}async _updateGpuText(i){i._didTextUpdate=!1;const l=this._getGpuText(i);if(l.generatingTexture)return;const p=i._getKey();this._renderer.htmlText.decreaseReferenceCount(l.currentKey),l.generatingTexture=!0,l.currentKey=p;const m=i.resolution??this._renderer.resolution,_=await this._renderer.htmlText.getManagedTexture(i.text,m,i._style,i._getKey()),y=l.batchableSprite;y.texture=l.texture=_,l.generatingTexture=!1,l.textureNeedsUploading=!0,i.onViewUpdate();const x=i._style.padding;updateQuadBounds(y.bounds,i._anchor,y.texture,x)}_getGpuText(i){return this._gpuText[i.uid]||this.initGpuText(i)}initGpuText(i){const l={texture:Texture.EMPTY,currentKey:"--",batchableSprite:kt.get(BatchableSprite),textureNeedsUploading:!1,generatingTexture:!1},p=l.batchableSprite;return p.renderable=i,p.transform=i.groupTransform,p.texture=Texture.EMPTY,p.bounds={minX:0,maxX:1,minY:0,maxY:0},p.roundPixels=this._renderer._roundPixels|i._roundPixels,i._resolution=i._autoResolution?this._renderer.resolution:i.resolution,this._gpuText[i.uid]=l,i.on("destroyed",this._destroyRenderableBound),l}destroy(){for(const i in this._gpuText)this._destroyRenderableById(i);this._gpuText=null,this._renderer=null}}HTMLTextPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"htmlText"};const Js=new Bounds;function getPo2TextureFromSource(i,l,p,m){const _=Js;_.minX=0,_.minY=0,_.maxX=i.width/m|0,_.maxY=i.height/m|0;const y=Ms.getOptimalTexture(_.width,_.height,m,!1);return y.source.uploadMethodId="image",y.source.resource=i,y.source.alphaMode="premultiply-alpha-on-upload",y.frame.width=l/m,y.frame.height=p/m,y.source.emit("update",y.source),y.updateUvs(),y}async function loadFontCSS(i,l){const p=await async function loadFontAsBase64(i){const l=await qt.get().fetch(i),p=await l.blob(),m=new FileReader;return await new Promise(((i,l)=>{m.onloadend=()=>i(m.result),m.onerror=l,m.readAsDataURL(p)}))}(l);return`@font-face {\n font-family: "${i.fontFamily}";\n src: url('${p}');\n font-weight: ${i.fontWeight};\n font-style: ${i.fontStyle};\n }`}const tr=new Map;class HTMLTextSystem{constructor(i){this._activeTextures={},this._renderer=i,this._createCanvas=i.type===Ye.WEBGPU}getTexture(i){return this._buildTexturePromise(i.text,i.resolution,i.style)}getManagedTexture(i,l,p,m){if(this._activeTextures[m])return this._increaseReferenceCount(m),this._activeTextures[m].promise;const _=this._buildTexturePromise(i,l,p).then((i=>(this._activeTextures[m].texture=i,i)));return this._activeTextures[m]={texture:null,promise:_,usageCount:1},_}async _buildTexturePromise(i,l,p){const m=kt.get(HTMLTextRenderData),_=function extractFontFamilies(i,l){const p=l.fontFamily,m=[],_={},y=i.match(/font-family:([^;"\s]+)/g);function addFontFamily(i){_[i]||(m.push(i),_[i]=!0)}if(Array.isArray(p))for(let i=0;i<p.length;i++)addFontFamily(p[i]);else addFontFamily(p);y&&y.forEach((i=>{addFontFamily(i.split(":")[1].trim())}));for(const i in l.tagStyles)addFontFamily(l.tagStyles[i].fontFamily);return m}(i,p),y=await async function getFontCss(i,l,p){const m=i.filter((i=>se.has(`${i}-and-url`))).map(((i,m)=>{if(!tr.has(i)){const{url:_}=se.get(`${i}-and-url`);0===m?tr.set(i,loadFontCSS({fontWeight:l.fontWeight,fontStyle:l.fontStyle,fontFamily:i},_)):tr.set(i,loadFontCSS({fontWeight:p.fontWeight,fontStyle:p.fontStyle,fontFamily:i},_))}return tr.get(i)}));return(await Promise.all(m)).join("\n")}(_,p,HTMLTextStyle.defaultTextStyle),x=function measureHtmlText(i,l,p,m){m=m||Ds||(Ds=new HTMLTextRenderData);const{domElement:_,styleElement:y,svgRoot:x}=m;_.innerHTML=`<style>${l.cssStyle};</style><div style='padding:0'>${i}</div>`,_.setAttribute("style","transform-origin: top left; display: inline-block"),p&&(y.textContent=p),document.body.appendChild(x);const v=_.getBoundingClientRect();x.remove();const T=ps.measureFont(l.fontStyle).descent,S=2*l.padding;return{width:v.width-S,height:v.height+T-S}}(i,p,y,m),v=Math.ceil(Math.ceil(Math.max(1,x.width)+2*p.padding)*l),T=Math.ceil(Math.ceil(Math.max(1,x.height)+2*p.padding)*l),S=m.image;S.width=2+(0|v),S.height=2+(0|T);const P=function getSVGUrl(i,l,p,m,_){const{domElement:y,styleElement:x,svgRoot:v}=_;y.innerHTML=`<style>${l.cssStyle}</style><div style='padding:0;'>${i}</div>`,y.setAttribute("style",`transform: scale(${p});transform-origin: top left; display: inline-block`),x.textContent=m;const{width:T,height:S}=_.image;return v.setAttribute("width",T.toString()),v.setAttribute("height",S.toString()),(new XMLSerializer).serializeToString(v)}(i,p,l,y,m);await function loadSVGImage(i,l,p){return new Promise((async m=>{p&&await new Promise((i=>setTimeout(i,100))),i.onload=()=>{m()},i.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(l)}`,i.crossOrigin="anonymous"}))}(S,P,function isSafari(){const{userAgent:i}=qt.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(i)}()&&_.length>0);let C=S;this._createCanvas&&(C=function getTemporaryCanvasFromImage(i,l){const p=ls.getOptimalCanvasAndContext(i.width,i.height,l),{context:m}=p;return m.clearRect(0,0,i.width,i.height),m.drawImage(i,0,0),ls.returnCanvasAndContext(p),p.canvas}(S,l));const E=getPo2TextureFromSource(C,S.width-2,S.height-2,l);return this._createCanvas&&this._renderer.texture.initSource(E.source),kt.return(m),E}_increaseReferenceCount(i){this._activeTextures[i].usageCount++}decreaseReferenceCount(i){const l=this._activeTextures[i];l&&(l.usageCount--,0===l.usageCount&&(l.texture?this._cleanUp(l):l.promise.then((i=>{l.texture=i,this._cleanUp(l)})).catch((()=>{warn("HTMLTextSystem: Failed to clean texture")})),this._activeTextures[i]=null))}_cleanUp(i){Ms.returnTexture(i.texture),i.texture.source.resource=null,i.texture.source.uploadMethodId="unknown"}getReferenceCount(i){return this._activeTextures[i].usageCount}destroy(){this._activeTextures=null}}HTMLTextSystem.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"htmlText"},HTMLTextSystem.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class CanvasTextPipe{constructor(i){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const i in this._gpuText){const l=this._gpuText[i];if(!l)continue;const p=l.batchableSprite.renderable;p._autoResolution&&(p._resolution=this._renderer.resolution,p.onViewUpdate())}}validateRenderable(i){const l=this._getGpuText(i),p=i._getKey();if(l.currentKey!==p){const{width:p,height:m}=this._renderer.canvasText.getTextureSize(i.text,i.resolution,i._style);return 1!==this._renderer.canvasText.getReferenceCount(l.currentKey)||p!==l.texture._source.width||m!==l.texture._source.height}return!1}addRenderable(i,l){const p=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),this._renderer.renderPipes.batch.addToBatch(p,l)}updateRenderable(i){const l=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),l._batcher.updateElement(l)}destroyRenderable(i){i.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(i.uid)}_destroyRenderableById(i){const l=this._gpuText[i];this._renderer.canvasText.decreaseReferenceCount(l.currentKey),kt.return(l.batchableSprite),this._gpuText[i]=null}_updateText(i){const l=i._getKey(),p=this._getGpuText(i),m=p.batchableSprite;p.currentKey!==l&&this._updateGpuText(i),i._didTextUpdate=!1;const _=i._style.padding;updateQuadBounds(m.bounds,i._anchor,m.texture,_)}_updateGpuText(i){const l=this._getGpuText(i),p=l.batchableSprite;l.texture&&this._renderer.canvasText.decreaseReferenceCount(l.currentKey),l.texture=p.texture=this._renderer.canvasText.getManagedTexture(i),l.currentKey=i._getKey(),p.texture=l.texture}_getGpuText(i){return this._gpuText[i.uid]||this.initGpuText(i)}initGpuText(i){const l={texture:null,currentKey:"--",batchableSprite:kt.get(BatchableSprite)};return l.batchableSprite.renderable=i,l.batchableSprite.transform=i.groupTransform,l.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},l.batchableSprite.roundPixels=this._renderer._roundPixels|i._roundPixels,this._gpuText[i.uid]=l,i._resolution=i._autoResolution?this._renderer.resolution:i.resolution,this._updateText(i),i.on("destroyed",this._destroyRenderableBound),l}destroy(){for(const i in this._gpuText)this._destroyRenderableById(i);this._gpuText=null,this._renderer=null}}function checkRow(i,l,p){for(let m=0,_=4*p*l;m<l;++m,_+=4)if(0!==i[_+3])return!1;return!0}function checkColumn(i,l,p,m,_){const y=4*l;for(let l=m,x=m*y+4*p;l<=_;++l,x+=y)if(0!==i[x+3])return!1;return!0}CanvasTextPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"text"};class CanvasTextSystem{constructor(i){this._activeTextures={},this._renderer=i}getTextureSize(i,l,p){const m=ps.measureText(i||" ",p);let _=Math.ceil(Math.ceil(Math.max(1,m.width)+2*p.padding)*l),y=Math.ceil(Math.ceil(Math.max(1,m.height)+2*p.padding)*l);return _=Math.ceil(_-1e-6),y=Math.ceil(y-1e-6),_=nextPow2(_),y=nextPow2(y),{width:_,height:y}}getTexture(i,l,p,m){"string"==typeof i&&(deprecation("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),i={text:i,style:p,resolution:l}),i.style instanceof hs||(i.style=new hs(i.style));const{texture:_,canvasAndContext:y}=this.createTextureAndCanvas(i);return this._renderer.texture.initSource(_._source),ls.returnCanvasAndContext(y),_}createTextureAndCanvas(i){const{text:l,style:p}=i,m=i.resolution??this._renderer.resolution,_=ps.measureText(l||" ",p),y=Math.ceil(Math.ceil(Math.max(1,_.width)+2*p.padding)*m),x=Math.ceil(Math.ceil(Math.max(1,_.height)+2*p.padding)*m),v=ls.getOptimalCanvasAndContext(y,x),{canvas:T}=v;this.renderTextToCanvas(l,p,m,v);const S=getPo2TextureFromSource(T,y,x,m);if(p.trim){const i=function getCanvasBoundingBox(i,l=1){const{width:p,height:m}=i,_=i.getContext("2d",{willReadFrequently:!0});if(null===_)throw new TypeError("Failed to get canvas 2D context");const y=_.getImageData(0,0,p,m).data;let x=0,v=0,T=p-1,S=m-1;for(;v<m&&checkRow(y,p,v);)++v;if(v===m)return Rectangle.EMPTY;for(;checkRow(y,p,S);)--S;for(;checkColumn(y,p,x,v,S);)++x;for(;checkColumn(y,p,T,v,S);)--T;return++T,++S,new Rectangle(x/l,v/l,(T-x)/l,(S-v)/l)}(T,m);S.frame.copyFrom(i),S.updateUvs()}return{texture:S,canvasAndContext:v}}getManagedTexture(i){i._resolution=i._autoResolution?this._renderer.resolution:i.resolution;const l=i._getKey();if(this._activeTextures[l])return this._increaseReferenceCount(l),this._activeTextures[l].texture;const{texture:p,canvasAndContext:m}=this.createTextureAndCanvas(i);return this._activeTextures[l]={canvasAndContext:m,texture:p,usageCount:1},p}_increaseReferenceCount(i){this._activeTextures[i].usageCount++}decreaseReferenceCount(i){const l=this._activeTextures[i];if(l.usageCount--,0===l.usageCount){ls.returnCanvasAndContext(l.canvasAndContext),Ms.returnTexture(l.texture);const p=l.texture.source;p.resource=null,p.uploadMethodId="unknown",p.alphaMode="no-premultiply-alpha",this._activeTextures[i]=null}}getReferenceCount(i){return this._activeTextures[i].usageCount}renderTextToCanvas(i,l,p,m){const{canvas:_,context:y}=m,x=fontStringFromTextStyle(l),v=ps.measureText(i||" ",l),T=v.lines,S=v.lineHeight,P=v.lineWidths,C=v.maxLineWidth,E=v.fontProperties,A=_.height;y.resetTransform(),y.scale(p,p);const k=2*l.padding;if(y.clearRect(0,0,v.width+4+k,v.height+4+k),l._stroke?.width){const i=l._stroke;y.lineWidth=i.width,y.miterLimit=i.miterLimit,y.lineJoin=i.join,y.lineCap=i.cap}let B,F;y.font=x;const R=l.dropShadow?2:1;for(let i=0;i<R;++i){const _=l.dropShadow&&0===i,x=_?Math.ceil(Math.max(1,A)+2*l.padding):0,v=x*p;if(_){y.fillStyle="black",y.strokeStyle="black";const i=l.dropShadow,m=i.color,_=i.alpha;y.shadowColor=At.shared.setValue(m).setAlpha(_).toRgbaString();const x=i.blur*p,T=i.distance*p;y.shadowBlur=x,y.shadowOffsetX=Math.cos(i.angle)*T,y.shadowOffsetY=Math.sin(i.angle)*T+v}else y.globalAlpha=l._fill?.alpha??1,y.fillStyle=l._fill?getCanvasFillStyle(l._fill,y):null,l._stroke?.width&&(y.strokeStyle=getCanvasFillStyle(l._stroke,y)),y.shadowColor="black";let k=(S-E.fontSize)/2;S-E.fontSize<0&&(k=0);const R=l._stroke?.width??0;for(let i=0;i<T.length;i++)B=R/2,F=R/2+i*S+E.ascent+k,"right"===l.align?B+=C-P[i]:"center"===l.align&&(B+=(C-P[i])/2),l._stroke?.width&&this._drawLetterSpacing(T[i],l,m,B+l.padding,F+l.padding-x,!0),void 0!==l._fill&&this._drawLetterSpacing(T[i],l,m,B+l.padding,F+l.padding-x)}}_drawLetterSpacing(i,l,p,m,_,y=!1){const{context:x}=p,v=l.letterSpacing;let T=!1;if(ps.experimentalLetterSpacingSupported&&(ps.experimentalLetterSpacing?(x.letterSpacing=`${v}px`,x.textLetterSpacing=`${v}px`,T=!0):(x.letterSpacing="0px",x.textLetterSpacing="0px")),0===v||T)return void(y?x.strokeText(i,m,_):x.fillText(i,m,_));let S=m;const P=ps.graphemeSegmenter(i);let C=x.measureText(i).width,E=0;for(let i=0;i<P.length;++i){const l=P[i];y?x.strokeText(l,S,_):x.fillText(l,S,_);let p="";for(let l=i+1;l<P.length;++l)p+=P[l];E=x.measureText(p).width,S+=C-E+v,C=E}}destroy(){this._activeTextures=null}}CanvasTextSystem.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"canvasText"},z.add(W,K);const er=new FederatedPointerEvent(null),ir=new Point;function emitPointerEvent(i,l,p){if(null==i?void 0:i.destroyed)return;const m=i.getGlobalPosition(ir,!1);for(const _ of p)i.emit(_,toPointerEvent(l,_,m))}function toPointerEvent(i,l,p){const m="custom"===i.type?i.id:i.type,_="pointerup"===l?0:1;return er.type=l,er.pointerType=m,er.pointerId=-1,er.button=0,er.buttons=_,er.isPrimary=!0,er.client.copyFrom(p),er.global.copyFrom(p),er}const sr={[G.Activate]:"activate",[G.Back]:"back",[G.Down]:"down",[G.Left]:"left",[G.Right]:"right",[G.Up]:"up"};class NavigationManager{constructor(){this.options={spatial:{minimumDistance:10,directionAxisWeight:2.5},events:{focus:["pointerenter","pointerover"],blur:["pointerleave","pointerout"],press:["pointerdown"],release:["pointerup","pointertap"]}},this.paused=!1,this.focusSource="pointer",this._responders=[]}get active(){return null!=this._rootContainer&&!this.paused}get focusTarget(){var i;const l=this.responders.find((i=>{var l;return!(null===(l=i.focusTarget)||void 0===l?void 0:l.destroyed)}));return null!==(i=null==l?void 0:l.focusTarget)&&void 0!==i?i:this._rootFocused}set focusTarget(i){this.setFocus(i,void 0)}get firstResponder(){return this._responders[0]}get responders(){return this._responders}configureWithRoot(i){this.enable(i)}invalidateNavCache(){const i=this.getStageContainer();i?invalidateNavigatablesCache(i):invalidateNavigatablesCache()}enable(i){this.active&&this.disable(),this._rootContainer=i,invalidateNavigatablesCache(i);const handler=i=>this._handleNavigateBindEvent(i),l=[G.Left,G.Down,G.Right,G.Up,G.Activate,G.Back];return L.onBindDownUp(l,handler),this._clearBinds=()=>L.offBindDownUp(l,handler),this}pushResponder(i){var l,p,m;const _=i;if(this._responders.includes(_))throw new Error("Responder already in stack.");const y=this.firstResponder;this._responders.unshift(_),invalidateNavigatablesCache(),null===(l=null==y?void 0:y.resignedAsFirstResponder)||void 0===l||l.call(y),this._clearFocusTargetIfRemoved(),null===(p=_.becameFirstResponder)||void 0===p||p.call(_),(null===(m=_.autoFocus)||void 0===m||m)&&this.autoFocus()}popResponder(){var i,l,p,m,_;const y=this.focusTarget,x=this._responders.shift();x&&(x.focusTarget=void 0),invalidateNavigatablesCache();const v=this.focusTarget;return null===(i=null==x?void 0:x.resignedAsFirstResponder)||void 0===i||i.call(x),this._clearFocusTargetIfRemoved(),this.firstResponder&&(null===(p=(l=this.firstResponder).becameFirstResponder)||void 0===p||p.call(l)),y!==v&&(null!==(_=null===(m=this.firstResponder)||void 0===m?void 0:m.autoFocus)&&void 0!==_?_:!v)&&this.autoFocus(),x}setTopMostResponder(i){var l,p,m;const _=i,y=this.firstResponder;if(y===_)return;const x=this._responders.indexOf(_);-1!==x&&this._responders.splice(x,1),this._responders.unshift(_),null===(l=null==y?void 0:y.resignedAsFirstResponder)||void 0===l||l.call(y),this._clearFocusTargetIfRemoved(),null===(p=_.becameFirstResponder)||void 0===p||p.call(_),(null===(m=_.autoFocus)||void 0===m||m)&&this.autoFocus()}removeResponder(i,l=!1){var p,m,_,y,x;const v=i,T=this._responders.indexOf(v);if(-1===T)return;const S=this.focusTarget,P=this.firstResponder;let C;if(l){const i=this._responders.splice(0,T+1);C=i[i.length-1];for(const l of i)l.focusTarget=void 0}else C=this._responders.splice(T,1)[0],C.focusTarget=void 0;const E=this.focusTarget;return P!==this.firstResponder&&(null===(p=null==P?void 0:P.resignedAsFirstResponder)||void 0===p||p.call(P),this._clearFocusTargetIfRemoved(),null===(_=null===(m=this.firstResponder)||void 0===m?void 0:m.becameFirstResponder)||void 0===_||_.call(m)),S!==E&&(null!==(x=null===(y=this.firstResponder)||void 0===y?void 0:y.autoFocus)&&void 0!==x?x:!E)&&this.autoFocus(),C}autoFocus(){if(!rr.active)return;const i=this.getStageContainer();if(!i)return;const l=getFirstNavigatable(i);void 0!==l&&l!==this.focusTarget&&this.setFocus(l,this.device)}getStageContainer(){var i;return null!==(i=this.responders.find(isContainer))&&void 0!==i?i:this._rootContainer}disable(){invalidateNavigatablesCache(),this._clearNavigateBindsHandler(),this._rootContainer=void 0,this._rootFocused=void 0}setFocus(i,l){l?(this.focusSource="device",this.device=l):(this.focusSource="pointer",this.device=void 0);const p=this.focusTarget;if(p==i)return;const m=this.getStageContainer();m&&(i&&!i.navigatable||i&&!isChildOf(i,m)||(this.firstResponder?this.firstResponder.focusTarget=i:this._rootFocused=i,p&&this._blur(p,!1),i&&this._focus(i)))}_clearNavigateBindsHandler(){var i;null===(i=this._clearBinds)||void 0===i||i.call(this),this._clearBinds=void 0}_handleNavigateBindEvent(i){if(!this.active)return;const l=i.name,p=i.device;if(this.device=p,this.focusSource="device",this._responders.some((l=>{var p;return null===(p=l.handledNavigateEvent)||void 0===p?void 0:p.call(l,i)})))return;this._clearFocusTargetIfRemoved();const m=this.focusTarget;if(void 0===m)return void(i.pressed||this.autoFocus());const _=sr[l],y=m.navigationLinks[_];if(null==y?void 0:y.navigatable)i.pressed&&this.setFocus(y,p);else switch(l){case G.Activate:return void(i.pressed?this._press(m):this._release(m));case G.Back:if(i.pressed)return;return void this._blur(m);default:{if(!i.pressed)return;const p=getFirstNavigatable(this.getStageContainer(),{direction:l,currentFocus:m,spatial:this.options.spatial});p&&p!==m&&this.setFocus(p,i.device)}}}_focus(i){this.device&&"device"===this.focusSource&&emitPointerEvent(i,this.device,this.options.events.focus)}_press(i){this.device&&"device"===this.focusSource&&emitPointerEvent(i,this.device,this.options.events.press)}_release(i){this.device&&"device"===this.focusSource&&emitPointerEvent(i,this.device,this.options.events.release)}_blur(i,l=!0){this.device&&"device"===this.focusSource&&(emitPointerEvent(i,this.device,this.options.events.blur),l&&this.setFocus(void 0,void 0))}_clearFocusTargetIfRemoved(i){if(null!=i||(i=this.getStageContainer()),!i)return;const l=this.focusTarget;l&&!isChildOf(l,i)&&this._blur(l)}}function isContainer(i){return"children"in i}NavigationManager.global=new NavigationManager;const rr=NavigationManager.global;let nr=!1;const or=new Set(["pointerdown","pointerup","pointertap"]);z.add(AccessibilitySystem),Container.mixin({accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1}),z.add(ResizePlugin),z.add(TickerPlugin),z.add(Ts),Container.mixin(Ss),z.add(GraphicsPipe),z.add($i),z.add(MeshPipe),z.add(CanvasTextSystem),z.add(CanvasTextPipe),z.add(BitmapTextPipe),z.add(HTMLTextSystem),z.add(HTMLTextPipe),z.add(TilingSpritePipe),z.add(NineSliceSpritePipe),z.add(FilterSystem),z.add(FilterPipe);var ar=Object.freeze({__proto__:null}),hr=Object.freeze({__proto__:null});exports.Button=F,exports.GamepadDevice=GamepadDevice,exports.InputDevice=L,exports.KeyCode=i,exports.KeyboardDevice=P,exports.KeyboardDeviceInstance=KeyboardDeviceInstance,exports.Navigate=G,exports.UINavigation=rr,exports.getAllNavigatables=getAllNavigatables,exports.getFirstNavigatable=getFirstNavigatable,exports.invalidateNavigatablesCache=invalidateNavigatablesCache,exports.isChildOf=isChildOf,exports.isVisible=isVisible,exports.registerPixiJSNavigationMixin=function registerPixiJSNavigationMixin(i){if(nr)return;nr=!0;const l=i.prototype,p=new WeakMap;l.navigationMode="auto",l.navigationPriority=0,Object.defineProperty(l,"navigatable",{get:function(){if(this.destroyed)return!1;switch(this.navigationMode){case"always":return!0;case"none":return!1;default:return this.isInteractive()&&this.eventNames().some((i=>or.has(i)))}},configurable:!0,enumerable:!1}),Object.defineProperty(l,"navigationLinks",{get:function(){let i=p.get(this);return null==i&&(i=this.navigationLinks={}),i},set:function(i){p.set(this,i),this.on("destroyed",(()=>p.delete(this)))},configurable:!0,enumerable:!1})};
|
|
1
|
+
"use strict";const i={AltLeft:"AltLeft",AltRight:"AltRight",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",Backquote:"Backquote",Backslash:"Backslash",Backspace:"Backspace",BracketLeft:"BracketLeft",BracketRight:"BracketRight",CapsLock:"CapsLock",Comma:"Comma",ContextMenu:"ContextMenu",ControlLeft:"ControlLeft",ControlRight:"ControlRight",Delete:"Delete",Digit0:"Digit0",Digit1:"Digit1",Digit2:"Digit2",Digit3:"Digit3",Digit4:"Digit4",Digit5:"Digit5",Digit6:"Digit6",Digit7:"Digit7",Digit8:"Digit8",Digit9:"Digit9",End:"End",Enter:"Enter",Equal:"Equal",Escape:"Escape",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F2:"F2",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F3:"F3",F30:"F30",F31:"F31",F32:"F32",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",Home:"Home",IntlBackslash:"IntlBackslash",IntlRo:"IntlRo",IntlYen:"IntlYen",KeyA:"KeyA",KeyB:"KeyB",KeyC:"KeyC",KeyD:"KeyD",KeyE:"KeyE",KeyF:"KeyF",KeyG:"KeyG",KeyH:"KeyH",KeyI:"KeyI",KeyJ:"KeyJ",KeyK:"KeyK",KeyL:"KeyL",KeyM:"KeyM",KeyN:"KeyN",KeyO:"KeyO",KeyP:"KeyP",KeyQ:"KeyQ",KeyR:"KeyR",KeyS:"KeyS",KeyT:"KeyT",KeyU:"KeyU",KeyV:"KeyV",KeyW:"KeyW",KeyX:"KeyX",KeyY:"KeyY",KeyZ:"KeyZ",Lang1:"Lang1",Lang2:"Lang2",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",MetaLeft:"MetaLeft",MetaRight:"MetaRight",Minus:"Minus",NumLock:"NumLock",Numpad0:"Numpad0",Numpad1:"Numpad1",Numpad2:"Numpad2",Numpad3:"Numpad3",Numpad4:"Numpad4",Numpad5:"Numpad5",Numpad6:"Numpad6",Numpad7:"Numpad7",Numpad8:"Numpad8",Numpad9:"Numpad9",NumpadAdd:"NumpadAdd",NumpadComma:"NumpadComma",NumpadDecimal:"NumpadDecimal",NumpadDivide:"NumpadDivide",NumpadMultiply:"NumpadMultiply",NumpadSubtract:"NumpadSubtract",OSLeft:"OSLeft",Pause:"Pause",Period:"Period",Quote:"Quote",ScrollLock:"ScrollLock",Semicolon:"Semicolon",ShiftLeft:"ShiftLeft",ShiftRight:"ShiftRight",Slash:"Slash",Space:"Space",Tab:"Tab",VolumeDown:"VolumeDown",VolumeMute:"VolumeMute",VolumeUp:"VolumeUp",WakeUp:"WakeUp"};let l=class EventEmitter{constructor(){this._listeners={}}hasListener(i){return void 0!==this._listeners[i]}emit(i,l){var p;null===(p=this._listeners[i])||void 0===p||p.forEach((i=>i(l)))}on(i,l,p){var m,_;if(this._listeners[i]||(this._listeners[i]=[]),null==p?void 0:p.once){const onceFn=p=>{l(p),this.off(i,onceFn)};null===(m=this._listeners[i])||void 0===m||m.push(onceFn)}else null===(_=this._listeners[i])||void 0===_||_.push(l)}off(i,l){var p,m;this._listeners[i]=void 0===l||null===(p=this._listeners[i])||void 0===p?void 0:p.filter((i=>i!==l)),0===(null===(m=this._listeners[i])||void 0===m?void 0:m.length)&&(this._listeners[i]=void 0)}};function __awaiter(i,l,p,m){return new(p||(p=Promise))((function(_,y){function fulfilled(i){try{step(m.next(i))}catch(i){y(i)}}function rejected(i){try{step(m.throw(i))}catch(i){y(i)}}function step(i){i.done?_(i.value):function adopt(i){return i instanceof p?i:new p((function(l){l(i)}))}(i.value).then(fulfilled,rejected)}step((m=m.apply(i,l||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const p=/ф|и|с|в|у|а|п|р|ш|о|л|д|ь|т|щ|з|й|к|ы|е|г|м|ц|ч|н|я|ё|х|ъ|б|ю|э|ж|и/i,m=/[a-z]/i,_=["fr","mg","lu"],y=["ab","ba","be","bg","ch","kk","ky","mk","mn","ru","sr","tg","tt","uk","uz"],x=["de","cs","sk","sl","hu","hr","bs","ro","sq","me","lt","lv","et"];let v,T;function inferKeyboardLayoutFromLang(i=function getLang(){var i;const l=navigator;return(null===(i=l.languages)||void 0===i?void 0:i.length)?l.languages[0]:l.userLanguage||l.language||l.browserLanguage}()){const l=(i||"").toLowerCase(),p=l.split("-")[0];return _.includes(p)||l.startsWith("nl-be")?"AZERTY":y.includes(p)?"JCUKEN":x.includes(p)||l.startsWith("sr-latn")?"QWERTZ":"QWERTY"}const S=new Set(["AZERTY","JCUKEN","QWERTY","QWERTZ"]);function getLayoutKeyLabel(i,l){var p,m;if(void 0===T){const i={ArrowLeft:"⬅",ArrowRight:"➡",ArrowUp:"⬆",ArrowDown:"⬇",AltLeft:"Left Alt",AltRight:"Right Alt",Backquote:"`",Backslash:"\\",Backspace:"Backspace",BracketLeft:"[",BracketRight:"]",CapsLock:"CapsLock",Comma:",",ContextMenu:"Context Menu",ControlLeft:"Left Ctrl",ControlRight:"Right Ctrl",Delete:"Delete",Digit0:"0",Digit1:"1",Digit2:"2",Digit3:"3",Digit4:"4",Digit5:"5",Digit6:"6",Digit7:"7",Digit8:"8",Digit9:"9",End:"End",Enter:"Enter",Equal:"=",Escape:"Esc",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",Home:"Home",IntlBackslash:"\\",IntlRo:"Ro",IntlYen:"¥",KeyA:"A",KeyB:"B",KeyC:"C",KeyD:"D",KeyE:"E",KeyF:"F",KeyG:"G",KeyH:"H",KeyI:"I",KeyJ:"J",KeyK:"K",KeyL:"L",KeyM:"M",KeyN:"N",KeyO:"O",KeyP:"P",KeyQ:"Q",KeyR:"R",KeyS:"S",KeyT:"T",KeyU:"U",KeyV:"V",KeyW:"W",KeyX:"X",KeyY:"Y",KeyZ:"Z",Lang1:"Language 1",Lang2:"Language 2",MediaTrackNext:"Next Track",MediaTrackPrevious:"Previous Track",MetaLeft:"Left "+getMetaKeyLabel(),MetaRight:"Right "+getMetaKeyLabel(),Minus:"-",NumLock:"Num Lock",Numpad0:"Num0",Numpad1:"Num1",Numpad2:"Num2",Numpad3:"Num3",Numpad4:"Num4",Numpad5:"Num5",Numpad6:"Num6",Numpad7:"Num7",Numpad8:"Num8",Numpad9:"Num9",NumpadAdd:"+",NumpadComma:",",NumpadDecimal:".",NumpadDivide:"/",NumpadMultiply:"*",NumpadSubtract:"-",OSLeft:"OS Left",Pause:"Pause",Period:".",Quote:"'",ScrollLock:"Scroll Lock",Semicolon:";",ShiftLeft:"Left Shift",ShiftRight:"Right Shift",Slash:"/",Space:"Space",Tab:"Tab",VolumeDown:"Volume Down",VolumeMute:"Volume Mute",VolumeUp:"Volume Up",WakeUp:"Wake Up"};T={AZERTY:{KeyA:"Q",KeyQ:"A",KeyW:"Z",KeyZ:"W",Backquote:"²",BracketLeft:"«",BracketRight:"»"},JCUKEN:{KeyA:"Ф",KeyB:"И",KeyC:"С",KeyD:"В",KeyE:"У",KeyF:"А",KeyG:"П",KeyH:"Р",KeyI:"Ш",KeyJ:"О",KeyK:"Л",KeyL:"Д",KeyM:"Ь",KeyN:"Т",KeyO:"Щ",KeyP:"З",KeyQ:"Й",KeyR:"К",KeyS:"Ы",KeyT:"Е",KeyU:"Г",KeyV:"М",KeyW:"Ц",KeyX:"Ч",KeyY:"Н",KeyZ:"Я",Backquote:"Ё",BracketLeft:"х",BracketRight:"ъ",Comma:"Б",Period:"Ю",Quote:"Э",Semicolon:"Ж",Slash:"И"},QWERTY:i,QWERTZ:{KeyY:"Z",KeyZ:"Y",BracketLeft:"ü",BracketRight:"ö",Slash:"-"}}}return null!==(m=null!==(p=T[l][i])&&void 0!==p?p:T.QWERTY[i])&&void 0!==m?m:i}function getMetaKeyLabel(){var i,l,p,m;const _=navigator,y=null!==(l=null===(i=_.platform)||void 0===i?void 0:i.toLowerCase())&&void 0!==l?l:"",x=null!==(m=null===(p=_.userAgent)||void 0===p?void 0:p.toLowerCase())&&void 0!==m?m:"";return y.includes("mac")?"⌘":y.includes("win")||y.includes("linux")?"⊞":x.includes("android")?"Search":x.includes("iphone")||x.includes("ipad")?"⌘":"⊞"}class KeyboardDeviceInstance{static configureDefaultBinds(i){KeyboardDeviceInstance.global.configureBinds(i)}constructor(){this.type="keyboard",this.id="keyboard",this.meta={},this.lastInteraction=performance.now(),this.detected=!1,this.options={emitEvents:!0,detectLayoutOnKeypress:!0,binds:{NavigateBack:["Escape","Backspace"],NavigateDown:["ArrowDown","KeyS"],NavigateLeft:["ArrowLeft","KeyA"],NavigateRight:["ArrowRight","KeyD"],NavigateActivate:["Enter","Space"],NavigateUp:["ArrowUp","KeyW"]},repeatableBinds:["NavigateDown","NavigateLeft","NavigateRight","NavigateUp"]},this.key=Object.keys(i).reduce(((i,l)=>(i[l]=!1,i)),{}),this._emitter=new l,this._bindDownEmitter=new l,this._bindUpEmitter=new l,this._deferredKeydown=[],this._deferredKeyup=[],this._bindIndex=new Map,this._bindsDownCurr=new Set,this._bindsDownPrev=new Set,this._layout=inferKeyboardLayoutFromLang(),this._layoutSource="lang",this._rebuildBindIndex(),function requestKeyboardLayout(){return __awaiter(this,void 0,void 0,(function*(){const i=navigator;if(i.keyboard&&i.keyboard.getLayoutMap)try{const l=yield i.keyboard.getLayoutMap();v=l;const p=l.get("KeyQ"),m=l.get("KeyA"),_=l.get("KeyZ");if("a"===p&&"w"===_&&"q"===m)return"AZERTY";if("q"===p&&"y"===_&&"a"===m)return"QWERTZ";if("q"===p&&"z"===_&&"a"===m)return"QWERTY";if("й"===p&&"я"===_&&"ф"===m)return"JCUKEN"}catch(i){}}))}().then((i=>{void 0!==i&&(this._layoutSource="browser",this._layout=i,this.options.detectLayoutOnKeypress=!1,this._emitter.emit("layoutdetected",{layoutSource:"browser",layout:i,device:this}))})),this._configureEventListeners()}get layout(){return this._layout}set layout(i){this._layoutSource="manual",this._layout=i,this.options.detectLayoutOnKeypress=!1}get layoutSource(){return this._layoutSource}bindDown(i){return void 0!==this.options.binds[i]&&this.pressedAny(this.options.binds[i])}bindPressed(i){return this._bindsDownCurr.has(i)&&!this._bindsDownPrev.has(i)}bindReleased(i){return!this._bindsDownCurr.has(i)&&this._bindsDownPrev.has(i)}pressedAny(i){for(let l=0;l<i.length;l++)if(this.key[i[l]])return!0;return!1}pressedAll(i){for(let l=0;l<i.length;l++)if(!this.key[i[l]])return!1;return!0}configureBinds(i){this.options.binds=Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex()}exportBinds(){const i={};for(const l in this.options.binds){const p=this.options.binds[l];p&&(i[l]=[...p])}return i}importBinds(i,l="replace"){this.options.binds="replace"===l?Object.assign({},i):Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex(),this._emitter.emit("bindschanged",{device:this})}playHaptic(){}on(i,l,p){return this._emitter.on(i,l,p),this}off(i,l){return this._emitter.off(i,l),this}onBindDown(i,l,p){return this._bindDownEmitter.on(i,l,p),this}offBindDown(i,l){return this._bindDownEmitter.off(i,l),this}onBindUp(i,l,p){return this._bindUpEmitter.on(i,l,p),this}offBindUp(i,l){return this._bindUpEmitter.off(i,l),this}onBind(i,l,p){return this.onBindUp(i,l,p)}offBind(i,l){return this.offBindDown(i,l).offBindUp(i,l)}getKeyLabel(i,l){var p;return l?getLayoutKeyLabel(i,l):null!==(p=function getNavigatorKeyLabel(i){const l=null==v?void 0:v.get(i);return void 0===l?void 0:function _toLocaleTitleCase(i){return i.split(/\s+/).map((i=>i.charAt(0).toLocaleUpperCase()+i.slice(1))).join(" ")}(l)}(i))&&void 0!==p?p:getLayoutKeyLabel(i,null!=l?l:this._layout)}update(i){this._deferredKeydown.length>0&&(this._deferredKeydown.forEach((i=>this._processDeferredKeydownEvent(i))),this._deferredKeydown.length=0),this.options.emitEvents&&this._deferredKeyup.length>0&&(this._deferredKeyup.forEach((i=>this._emitDeferredKeyupEvent(i))),this._deferredKeyup.length=0,this.lastInteraction=i);const l=this._bindsDownPrev;this._bindsDownPrev=this._bindsDownCurr,this._bindsDownCurr=l,this._bindsDownCurr.clear();for(const[i,l]of this._bindIndex)if(this.key[i])for(let i=0;i<l.length;i++)this._bindsDownCurr.add(l[i])}clear(){for(const l of Object.keys(i))this.key[l]=!1}_configureEventListeners(){const i=this.key,l=this._deferredKeydown,p=this._deferredKeyup;window.addEventListener("keydown",(p=>{i[p.code]=!0,l.push(p),this.lastInteraction=performance.now()}),{passive:!0,capture:!0}),window.addEventListener("keyup",(l=>{i[l.code]=!1,p.push(l),this.lastInteraction=performance.now()}),{passive:!0,capture:!0})}_processDeferredKeydownEvent(i){const l=i.code;if(!i.repeat){if(this.options.detectLayoutOnKeypress&&"lang"===this._layoutSource){const l=function detectKeyboardLayoutFromKeydown(i){const l=i.key.toLowerCase(),_=i.code;return p.test(l)?(S.delete("AZERTY"),S.delete("QWERTY"),S.delete("QWERTZ")):"Backquote"===_&&"²"===l||"BracketLeft"===_&&"«"===l||"BracketRight"===_&&"»"===l||"KeyA"===_&&"q"===l||"KeyQ"===_&&"a"===l||"KeyW"===_&&"z"===l||"KeyZ"===_&&"w"===l?(S.delete("JCUKEN"),S.delete("QWERTY"),S.delete("QWERTZ")):"BracketLeft"===_&&"ü"===l||"BracketRight"===_&&"ö"===l||"KeyY"===_&&"z"===l||"KeyZ"===_&&"y"===l||"Slash"===_&&"-"===l?(S.delete("AZERTY"),S.delete("JCUKEN"),S.delete("QWERTY")):"BracketLeft"===_&&"["===l||"BracketRight"===_&&"]"===l||"KeyZ"===_&&"z"===l?(S.delete("AZERTY"),S.delete("JCUKEN"),S.delete("QWERTZ")):"KeyQ"===_&&"q"===l||"KeyW"===_&&"w"===l?(S.delete("AZERTY"),S.delete("JCUKEN")):"KeyY"===_&&"y"===l?(S.delete("QWERTZ"),S.delete("JCUKEN")):m.test(l)&&S.delete("JCUKEN"),1===S.size?[...S][0]:void 0}(i);void 0!==l&&(this._layout=l,this._layoutSource="keypress",this.options.detectLayoutOnKeypress=!1,this._emitter.emit("layoutdetected",{layout:l,layoutSource:"keypress",device:this}))}this.options.emitEvents&&this._emitter.hasListener(l)&&this._emitter.emit(l,{device:this,keyCode:l,keyLabel:this.getKeyLabel(l),event:i})}if(this.options.emitEvents){const p=this._bindIndex.get(l);if(p){const m=this.getKeyLabel(l);for(let _=0;_<p.length;_++){const y=p[_];if(i.repeat&&!this.options.repeatableBinds.includes(y))continue;const x={device:this,keyCode:l,keyLabel:m,event:i,name:y,repeat:i.repeat,value:1,pressed:!0};this._bindDownEmitter.emit(y,x),this._emitter.emit("binddown",x)}}}}_emitDeferredKeyupEvent(i){const l=i.code,p=this._bindIndex.get(l);if(p){const m=this.getKeyLabel(l);for(let _=0;_<p.length;_++){const y=p[_],x={device:this,keyCode:l,keyLabel:m,event:i,name:y,repeat:i.repeat,value:0,pressed:!1};this._bindUpEmitter.emit(y,x),this._emitter.emit("bindup",x)}}}_rebuildBindIndex(){this._bindIndex.clear();for(const i in this.options.binds){const l=this.options.binds[i];if(l)for(const p of l){let l=this._bindIndex.get(p);l||(l=[],this._bindIndex.set(p,l)),l.push(i)}}}}KeyboardDeviceInstance.global=new KeyboardDeviceInstance;const P=KeyboardDeviceInstance.global,C=0,E=1,A=2,k=3,B=["LeftStickLeft","LeftStickRight","LeftStickUp","LeftStickDown","RightStickLeft","RightStickRight","RightStickUp","RightStickDown"],F={Face1:0,Face2:1,Face3:2,Face4:3,LeftShoulder:4,RightShoulder:5,LeftTrigger:6,RightTrigger:7,Back:8,Start:9,LeftStickClick:10,RightStickClick:11,DpadUp:12,DpadDown:13,DpadLeft:14,DpadRight:15},R=["Face1","Face2","Face3","Face4","LeftShoulder","RightShoulder","LeftTrigger","RightTrigger","Back","Start","LeftStickClick","RightStickClick","DpadUp","DpadDown","DpadLeft","DpadRight"];const I=2e3;class GamepadHapticManager{constructor(i){var l,p,m;this.activeEffects=[],this.state={rumble:0,buzz:0,leftTrigger:0,rightTrigger:0,expires:0},this.gamepad=i,this.hapticEvent="vibrationActuator"in i?(null===(m=null===(p=null===(l=i.vibrationActuator)||void 0===l?void 0:l.effects)||void 0===p?void 0:p.includes)||void 0===m?void 0:m.call(p,"trigger-rumble"))?"trigger-rumble":"dual-rumble":void 0}play(i,l){var p;const m=Math.max(0,null!==(p=i.startDelay)&&void 0!==p?p:0),_=performance.now()+m;this.activeEffects.push(Object.assign(Object.assign({},i),{start:_,end:_+Math.max(i.duration,0),startDelay:void 0})),this.intensity!==l&&(this.intensity=Math.max(0,Math.min(1,l))),m||0!==this.activeEffects.length||this.update()}reset(){var i,l;this.activeEffects.length=0,this.state.rumble=0,this.state.buzz=0,this.state.leftTrigger=0,this.state.rightTrigger=0,this.gamepad.vibrationActuator?(this.gamepad.vibrationActuator.playEffect("dual-rumble",{duration:1,strongMagnitude:0,weakMagnitude:0,leftTrigger:0,rightTrigger:0}),this.gamepad.vibrationActuator.reset()):this.gamepad.hapticActuators&&(null===(l=null===(i=this.gamepad.hapticActuators[0])||void 0===i?void 0:i.pulse)||void 0===l||l.call(i,0,100))}update(){var i,l;const p=performance.now();let m=0,_=0,y=0,x=0,v=0,T=!1;for(let i=0;i<this.activeEffects.length;i++){const l=this.activeEffects[i];l.end<=p?T=!0:l.start>p||("trigger-rumble"===this.hapticEvent&&(l.leftTrigger&&l.leftTrigger>y&&(y=l.leftTrigger),l.rightTrigger&&l.rightTrigger>x&&(x=l.rightTrigger)),l.rumble&&l.rumble>m&&(m=l.rumble),l.buzz&&l.buzz>_&&(_=l.buzz),l.end-p>v&&(v=l.end-p))}if(T){let i=0;for(let l=0;l<this.activeEffects.length;l++)this.activeEffects[l].end>=p&&(this.activeEffects[i++]=this.activeEffects[l]);this.activeEffects.length=i}if(this.state.rumble!==m||this.state.buzz!==_||this.state.leftTrigger!==y||this.state.rightTrigger!==x||this.state.expires<=p&&m+_+y+x>0)if(this.state.rumble=m,this.state.buzz=_,this.state.leftTrigger=y,this.state.rightTrigger=x,void 0!==this.hapticEvent)this.state.expires=p+I,this.gamepad.vibrationActuator.playEffect(this.hapticEvent,{duration:I,strongMagnitude:m*this.intensity,weakMagnitude:_*this.intensity,leftTrigger:y*this.intensity,rightTrigger:x*this.intensity});else if(this.gamepad.hapticActuators){const y=Math.min(v,I),x=Math.max(m,_)*this.intensity;this.state.expires=p+v,null===(l=null===(i=this.gamepad.hapticActuators[0])||void 0===i?void 0:i.pulse)||void 0===l||l.call(i,x,y)}}}const D={clearInputOnBackground:!0,requireDocumentFocus:!0,supressHapticsInactivityPeriodMs:0};class GamepadDevice{static configureDefaultBinds(i){this.defaultOptions.binds=Object.assign(Object.assign({},this.defaultOptions.binds),i)}constructor(i){var p;this.source=i,this.type="gamepad",this.meta={},this.lastInteraction=performance.now(),this.options=JSON.parse(JSON.stringify(GamepadDevice.defaultOptions)),this.leftJoystick={x:0,y:0},this.rightJoystick={x:0,y:0},this.button=[...R,...B].reduce(((i,l)=>(i[l]=!1,i)),{}),this.leftTrigger=0,this.rightTrigger=0,this.leftShoulder=0,this.rightShoulder=0,this._emitter=new l,this._bindDownEmitter=new l,this._bindUpEmitter=new l,this._debounces=new Map,this._bindIndex=new Map,this._bindsDownCurr=new Set,this._bindsDownPrev=new Set,this.id="gamepad"+i.index,this.layout=null!==(p=function detectLayout(i){const l=(i||"").toLowerCase();return/(amazon|luna|1949)/.test(l)?"amazon_luna":/(logitech|046d|c216|logicool|^46d)/.test(l)?"logitech_g":/(joy-?con.*l|057e.*2006)/.test(l)?"nintendo_joycon_l":/(joy-?con.*r|057e.*2007)/.test(l)?"nintendo_joycon_r":/(wiiu?|0305|0306|0337)/.test(l)?"nintendo_wiiu":/(switch.*pro|nintendo|switch|057e|0300)/.test(l)?"nintendo_switch_pro":/(nvidia.*shield|nvidia|shield|0955)/.test(l)?"nvidia_shield":/(playstation.*5|dualsense|0df2|0ce6)/.test(l)?"playstation_5":/(playstation|sony|dualshock|054c|09cc|0ba0|0810)/.test(l)?"playstation_4":/(steam.*controller|steam|28de|1102|1142)/.test(l)?"steam_controller":/(xbox.*series|0b00|0b12)/.test(l)?"xbox_series":/(xbox.*360|0202|0283|0285|0288|0289|028e|028f|0291|0719)/.test(l)?"xbox_360":/(xbox|xinput|045e)/.test(l)?"xbox_one":void 0}(null==i?void 0:i.id))&&void 0!==p?p:"unknown",this._haptics=new GamepadHapticManager(i),this.supportsTriggerRumble="trigger-rumble"===this._haptics.hapticEvent,this._rebuildBindIndex()}bindDown(i){return void 0!==this.options.binds[i]&&this.pressedAny(this.options.binds[i])}bindPressed(i){return this._bindsDownCurr.has(i)&&!this._bindsDownPrev.has(i)}bindReleased(i){return!this._bindsDownCurr.has(i)&&this._bindsDownPrev.has(i)}pressedAny(i){for(let l=0;l<i.length;l++)if(this.button[i[l]])return!0;return!1}pressedAll(i){for(let l=0;l<i.length;l++)if(!this.button[i[l]])return!1;return!0}configureBinds(i){this.options.binds=Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex()}exportBinds(){const i={};for(const l in this.options.binds){const p=this.options.binds[l];p&&(i[l]=[...p])}return i}importBinds(i,l="replace"){this.options.binds="replace"===l?Object.assign({},i):Object.assign(Object.assign({},this.options.binds),i),this._rebuildBindIndex(),this._emitter.emit("bindschanged",{device:this})}on(i,l,p){return this._emitter.on(i,l,p),this}off(i,l){return this._emitter.off(i,l),this}onBindDown(i,l,p){return this._bindDownEmitter.on(i,l,p),this}offBindDown(i,l){return this._bindDownEmitter.off(i,l),this}onBindUp(i,l,p){return this._bindUpEmitter.on(i,l,p),this}offBindUp(i,l){return this._bindUpEmitter.off(i,l),this}onBind(i,l,p){return this.onBindUp(i,l,p)}offBind(i,l){return this.offBindDown(i,l).offBindUp(i,l)}playHaptic(...i){this.options.vibration.enabled&&(D.supressHapticsInactivityPeriodMs>0&&performance.now()-this.lastInteraction>D.supressHapticsInactivityPeriodMs||i.forEach((i=>this._haptics.play(i,this.options.vibration.intensity))))}stopHaptics(){this._haptics.reset()}update(i,l){this.source=i,this._poll(i,l),this._haptics.update(),this._snapshotBindState()}clear(){this.button=[...B,...R].reduce(((i,l)=>(i[l]=!1,i)),{}),this._haptics.reset()}_poll(i,l){var p,m,_,y,x,v,T;const S=this.options.joystick;for(let p=0;p<4;p++){const m=_scale(i.axes[p],S.deadzone),_=B[2*p],y=B[2*p+1],x=m>0?y:_,v=m>0?_:y;if(Math.abs(m)<S.pressThreshold)for(const i of[_,y]){if(this.button[i]){if(this.options.emitEvents){const l=this._bindIndex.get(i);if(l)for(let _=0;_<l.length;_++){const y=l[_],x={device:this,type:"axis",axis:p,axisCode:i,name:y,pressed:!1,value:m};this._bindUpEmitter.emit(y,x),this._emitter.emit("bindup",x)}}this.button[i]=!1}this._debounces.delete(i)}else{const i=S.autoRepeatDelayMs[+this.button[x]];if(this._debounce(x,i)&&this.button[x])continue;if(this.button[x]=!0,this.button[v]=!1,this.lastInteraction=l,this.options.emitEvents){this._emitter.hasListener(x)&&this._emitter.emit(x,{device:this,axis:p,axisCode:x,pressed:!0,value:m});const i=this._bindIndex.get(x);if(i)for(let l=0;l<i.length;l++){const _=i[l],y={device:this,type:"axis",axis:p,axisCode:x,name:_,pressed:!0,value:m};this._bindDownEmitter.emit(_,y),this._emitter.emit("binddown",y)}}}}for(let y=0;y<16;y++){let x=y;const v=R[x];if(this.button[v]===(null===(p=i.buttons[y])||void 0===p?void 0:p.pressed))continue;this.lastInteraction=l;const T=null!==(_=null===(m=i.buttons[y])||void 0===m?void 0:m.pressed)&&void 0!==_&&_;if(this.button[v]=T,this.options.emitEvents){T&&this._emitter.hasListener(v)&&this._emitter.emit(v,{device:this,button:x,buttonCode:v,pressed:!0,value:1});const i=this._bindIndex.get(v);if(i)for(let l=0;l<i.length;l++){const p=i[l],m={device:this,type:"button",button:x,buttonCode:v,name:p,pressed:T,value:T?1:0};(T?this._bindDownEmitter:this._bindUpEmitter).emit(p,m),this._emitter.emit(T?"binddown":"bindup",m)}}}const P=this.options.trigger.deadzone;this.leftTrigger=_scale(i.buttons[F.LeftTrigger].value,P),this.rightTrigger=_scale(i.buttons[F.RightTrigger].value,P),this.leftShoulder=_scale(i.buttons[F.LeftShoulder].value,P),this.rightShoulder=_scale(i.buttons[F.RightShoulder].value,P);const I=S.deadzone;this.leftJoystick.x=_scale(null!==(y=i.axes[C])&&void 0!==y?y:0,I),this.leftJoystick.y=_scale(null!==(x=i.axes[E])&&void 0!==x?x:0,I),this.rightJoystick.x=_scale(null!==(v=i.axes[A])&&void 0!==v?v:0,I),this.rightJoystick.y=_scale(null!==(T=i.axes[k])&&void 0!==T?T:0,I)}_debounce(i,l){var p;const m=Date.now();return(null!==(p=this._debounces.get(i))&&void 0!==p?p:0)>m||(this._debounces.set(i,m+l),!1)}_snapshotBindState(){const i=this._bindsDownPrev;this._bindsDownPrev=this._bindsDownCurr,this._bindsDownCurr=i,this._bindsDownCurr.clear();for(const[i,l]of this._bindIndex)if(this.button[i])for(let i=0;i<l.length;i++)this._bindsDownCurr.add(l[i])}_rebuildBindIndex(){this._bindIndex.clear();for(const i in this.options.binds){const l=this.options.binds[i];if(l)for(const p of l){let l=this._bindIndex.get(p);l||(l=[],this._bindIndex.set(p,l)),l.push(i)}}}}function _scale(i,l){const p=(Math.abs(i)-l[0])/(l[1]-l[0]);return p>=0&&p<=1?Math.sign(i)*p:p>1?1*Math.sign(i):0}GamepadDevice.defaultOptions={emitEvents:!0,joystick:{deadzone:[0,1],pressThreshold:.5,autoRepeatDelayMs:[400,100]},trigger:{deadzone:[0,1]},vibration:{enabled:!0,intensity:1},binds:{NavigateActivate:["Face1"],NavigateBack:["Face2"],NavigateUp:["DpadUp","LeftStickUp"],NavigateLeft:["DpadLeft","LeftStickLeft"],NavigateDown:["DpadDown","LeftStickDown"],NavigateRight:["DpadRight","LeftStickRight"]}};class InputDeviceManager{constructor(){this.hasMouseLikePointer=window.matchMedia("(pointer: fine) and (hover: hover)").matches,this.isTouchCapable=("ontouchstart"in window||window.TouchEvent)&&navigator.maxTouchPoints>0,this.isMobile=(()=>{let i=!1;return(l=>{(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(l)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s)|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(|\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(|\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg(g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v)|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v)|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|)|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(l.substr(0,4)))&&(i=!0)})(navigator.userAgent||navigator.vendor),i})(),this.keyboard=P,this.options=D,this._devices=[],this._gamepads=[],this._gamepadIdx=new Map,this._custom=[],this._emitter=new l,this._bindDownEmitter=new l,this._bindUpEmitter=new l,this._hasFocus=!1,this._lastInteractionWatermark=0,!this.isMobile&&this.hasMouseLikePointer?this.add(this.keyboard):window.addEventListener("keydown",(()=>this.add(this.keyboard)),{once:!0}),window.addEventListener("gamepadconnected",(i=>{const l=new GamepadDevice(i.gamepad);this.add(l)})),window.addEventListener("gamepaddisconnected",(i=>{const l=this._gamepadIdx.get(i.gamepad.index);l&&this.remove(l)}))}get devices(){return this._devices}get gamepads(){return this._gamepads}get custom(){return this._custom}get lastInteractedDevice(){return this._lastInteractedDevice}on(i,l){return this._emitter.on(i,l),this}off(i,l){return this._emitter.off(i,l),this}onBindDown(i,l,p){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindDownEmitter.on(i,l,p))),this}onBindUp(i,l,p){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindUpEmitter.on(i,l,p))),this}onBindDownUp(i,l,p){return this.onBindDown(i,l,p).onBindUp(i,l,p)}offBindDown(i,l){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindDownEmitter.off(i,l))),this}offBindUp(i,l){return(i=Array.isArray(i)?i:[i]).forEach((i=>this._bindUpEmitter.off(i,l))),this}offBindDownUp(i,l){return this.offBindDown(i,l).offBindUp(i,l)}exportBinds(){const i={};for(const l of this._gamepads)i[l.id]=l.exportBinds();return{keyboard:this.keyboard.exportBinds(),gamepads:i}}importBinds(i,l="replace"){this.keyboard.importBinds(i.keyboard,l);for(const p of this._gamepads){const m=i.gamepads[p.id];m&&p.importBinds(m,l)}}emitBindDown(i,l,p=1){return this._bindDownEmitter.emit(i,{name:i,device:l,pressed:!0,value:p}),this}emitBindUp(i,l){return this._bindUpEmitter.emit(i,{name:i,device:l,pressed:!1,value:0}),this}emitBindDownUp(i,l){this.emitBindDown(i,l).emitBindUp(i,l)}add(i){-1===this._devices.indexOf(i)&&(this._devices.push(i),"keyboard"===i.type?(i.detected=!0,i.on("binddown",(i=>this._bindDownEmitter.emit(i.name,i))).on("bindup",(i=>this._bindUpEmitter.emit(i.name,i)))):i instanceof GamepadDevice?(this._gamepadIdx.set(i.source.index,i),this._gamepads.push(i),i.on("binddown",(i=>this._bindDownEmitter.emit(i.name,i))).on("bindup",(i=>this._bindUpEmitter.emit(i.name,i)))):this._custom.push(i),this._emitter.emit("deviceadded",{device:i}))}remove(i){if("keyboard"===i.type)i.detected=!1;else if(i instanceof GamepadDevice){this._gamepadIdx.delete(i.source.index);const l=this._gamepads.indexOf(i);-1!==l&&this._gamepads.splice(l,1)}else{const l=this._custom.indexOf(i);-1!==l&&this._custom.splice(l,1)}const l=this._devices.indexOf(i);-1!==l&&(this._devices.splice(l,1),this._emitter.emit("deviceremoved",{device:i}))}update(){if(this.options.requireDocumentFocus&&!document.hasFocus())return this._hasFocus&&this.options.clearInputOnBackground&&this.devices.forEach((i=>{var l;return null===(l=i.clear)||void 0===l?void 0:l.call(i)})),this._hasFocus=!1,this._devices;this._hasFocus=!0;const i=performance.now();this.keyboard.detected&&this.keyboard.update(i),this._gamepads.length>0&&this._pollGamepads(i);for(const l of this._custom)l.update(i);return this._updateLastInteracted(),this._devices}_updateLastInteracted(){if(0===this._devices.length)return;let i,l=0;for(const i of this._devices)i.lastInteraction>l&&(l=i.lastInteraction);if(!(l<=this._lastInteractionWatermark&&void 0!==this._lastInteractedDevice)){if(this._lastInteractionWatermark=l,1===this._devices.length)i=this._devices[0];else for(const l of this._devices)(void 0===i||l.lastInteraction>i.lastInteraction)&&(i=l);i!==this._lastInteractedDevice&&this._emitter.emit("lastdevicechanged",{device:i}),this._lastInteractedDevice=i}}_pollGamepads(i){var l;if(null!=navigator.getGamepads)for(const p of navigator.getGamepads())null!=p&&(null===(l=this._gamepadIdx.get(p.index))||void 0===l||l.update(p,i))}}InputDeviceManager.global=new InputDeviceManager;const L=InputDeviceManager.global;let U=new WeakMap;function invalidateNavigatablesCache(i){void 0!==i?U.delete(i):U=new WeakMap}function getAllNavigatables(i,l){if(void 0!==l)return _collectNavigatables(i,l);const p=U.get(i);if(void 0!==p)return p;const m=_collectNavigatables(i,[]);return U.set(i,m),m}function _collectNavigatables(i,l){var p;for(const m of null!==(p=i.children)&&void 0!==p?p:[])m.navigatable?l.push(m):_collectNavigatables(m,l);return l}function getFirstNavigatable(i,l){return function chooseFirstNavigatableInDirection(i,l={}){var p,m,_;const{currentFocus:y,direction:x,spatial:v}=l,T=i.filter((i=>i.navigatable&&null!=i.parent&&isVisible(i))),S=T.find((i=>i===y));if(void 0===S)return T.sort(((i,l)=>l.navigationPriority-i.navigationPriority)),T[0];if(void 0===x&&S)return S;const P=null!=S?S:T[Math.floor(Math.random()*T.length)];if(void 0===S)return null!==(p=i[0])&&void 0!==p?p:P;const C=S.getGlobalPosition();let E=T.filter((i=>i!==S)).map((i=>{const{x:l,y:p}=i.getGlobalPosition();return{element:i,x:l,y:p}}));const{minimumDistance:A,directionAxisWeight:k}=v;switch(x){case"NavigateUp":E=E.filter((i=>i.y<C.y-A));break;case"NavigateLeft":E=E.filter((i=>i.x<C.x-A));break;case"NavigateRight":E=E.filter((i=>i.x>C.x+A));break;case"NavigateDown":E=E.filter((i=>i.y>C.y+A));break;default:return S}const B=E.map((i=>{const l="NavigateLeft"===x||"NavigateRight"===x,p=l?1/k:1,m=l?1:1/k,_=(C.x-i.x)*p,y=(C.y-i.y)*m;return Object.assign(Object.assign({},i),{score:_*_+y*y})})).sort(((i,l)=>i.score-l.score));return null!==(_=null===(m=B[0])||void 0===m?void 0:m.element)&&void 0!==_?_:P}(getAllNavigatables(i),l)}function isChildOf(i,l){for(;null!=i;){if(i===l)return!0;i=i.parent}return!1}function isVisible(i){for(;null!=i;){if(!i.visible)return!1;i=i.parent}return!0}const G=Object.freeze({Activate:"NavigateActivate",Back:"NavigateBack",Down:"NavigateDown",Left:"NavigateLeft",Right:"NavigateRight",Up:"NavigateUp"});var O=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(O||{});const normalizeExtension=i=>{if("function"==typeof i||"object"==typeof i&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={..."object"!=typeof i.extension?{type:i.extension}:i.extension,ref:i}}if("object"!=typeof i)throw new Error("Invalid extension type");return"string"==typeof(i={...i}).type&&(i.type=[i.type]),i},normalizeExtensionPriority=(i,l)=>normalizeExtension(i).priority??l,z={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(normalizeExtension).forEach((i=>{i.type.forEach((l=>this._removeHandlers[l]?.(i)))})),this},add(...i){return i.map(normalizeExtension).forEach((i=>{i.type.forEach((l=>{const p=this._addHandlers,m=this._queue;p[l]?p[l]?.(i):(m[l]=m[l]||[],m[l]?.push(i))}))})),this},handle(i,l,p){const m=this._addHandlers,_=this._removeHandlers;if(m[i]||_[i])throw new Error(`Extension type ${i} already has a handler`);m[i]=l,_[i]=p;const y=this._queue;return y[i]&&(y[i]?.forEach((i=>l(i))),delete y[i]),this},handleByMap(i,l){return this.handle(i,(i=>{i.name&&(l[i.name]=i.ref)}),(i=>{i.name&&delete l[i.name]}))},handleByNamedList(i,l,p=-1){return this.handle(i,(i=>{l.findIndex((l=>l.name===i.name))>=0||(l.push({name:i.name,value:i.ref}),l.sort(((i,l)=>normalizeExtensionPriority(l.value,p)-normalizeExtensionPriority(i.value,p))))}),(i=>{const p=l.findIndex((l=>l.name===i.name));-1!==p&&l.splice(p,1)}))},handleByList(i,l,p=-1){return this.handle(i,(i=>{l.includes(i.ref)||(l.push(i.ref),l.sort(((i,l)=>normalizeExtensionPriority(l,p)-normalizeExtensionPriority(i,p))))}),(i=>{const p=l.indexOf(i.ref);-1!==p&&l.splice(p,1)}))}},W={extension:{type:O.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then((function(){return ar}))}},K={extension:{type:O.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:async()=>{await Promise.resolve().then((function(){return hr}))}};class ObservablePoint{constructor(i,l,p){this._x=l||0,this._y=p||0,this._observer=i}clone(i){return new ObservablePoint(i??this._observer,this._x,this._y)}set(i=0,l=i){return this._x===i&&this._y===l||(this._x=i,this._y=l,this._observer._onUpdate(this)),this}copyFrom(i){return this._x===i.x&&this._y===i.y||(this._x=i.x,this._y=i.y,this._observer._onUpdate(this)),this}copyTo(i){return i.set(this._x,this._y),i}equals(i){return i.x===this._x&&i.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(i){this._x!==i&&(this._x=i,this._observer._onUpdate(this))}get y(){return this._y}set y(i){this._y!==i&&(this._y=i,this._observer._onUpdate(this))}}function getDefaultExportFromCjs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Y={exports:{}};!function(i){var l=Object.prototype.hasOwnProperty,p="~";function Events(){}function EE(i,l,p){this.fn=i,this.context=l,this.once=p||!1}function addListener(i,l,m,_,y){if("function"!=typeof m)throw new TypeError("The listener must be a function");var x=new EE(m,_||i,y),v=p?p+l:l;return i._events[v]?i._events[v].fn?i._events[v]=[i._events[v],x]:i._events[v].push(x):(i._events[v]=x,i._eventsCount++),i}function clearEvent(i,l){0==--i._eventsCount?i._events=new Events:delete i._events[l]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),(new Events).__proto__||(p=!1)),EventEmitter.prototype.eventNames=function eventNames(){var i,m,_=[];if(0===this._eventsCount)return _;for(m in i=this._events)l.call(i,m)&&_.push(p?m.slice(1):m);return Object.getOwnPropertySymbols?_.concat(Object.getOwnPropertySymbols(i)):_},EventEmitter.prototype.listeners=function listeners(i){var l=p?p+i:i,m=this._events[l];if(!m)return[];if(m.fn)return[m.fn];for(var _=0,y=m.length,x=new Array(y);_<y;_++)x[_]=m[_].fn;return x},EventEmitter.prototype.listenerCount=function listenerCount(i){var l=p?p+i:i,m=this._events[l];return m?m.fn?1:m.length:0},EventEmitter.prototype.emit=function emit(i,l,m,_,y,x){var v=p?p+i:i;if(!this._events[v])return!1;var T,S,P=this._events[v],C=arguments.length;if(P.fn){switch(P.once&&this.removeListener(i,P.fn,void 0,!0),C){case 1:return P.fn.call(P.context),!0;case 2:return P.fn.call(P.context,l),!0;case 3:return P.fn.call(P.context,l,m),!0;case 4:return P.fn.call(P.context,l,m,_),!0;case 5:return P.fn.call(P.context,l,m,_,y),!0;case 6:return P.fn.call(P.context,l,m,_,y,x),!0}for(S=1,T=new Array(C-1);S<C;S++)T[S-1]=arguments[S];P.fn.apply(P.context,T)}else{var E,A=P.length;for(S=0;S<A;S++)switch(P[S].once&&this.removeListener(i,P[S].fn,void 0,!0),C){case 1:P[S].fn.call(P[S].context);break;case 2:P[S].fn.call(P[S].context,l);break;case 3:P[S].fn.call(P[S].context,l,m);break;case 4:P[S].fn.call(P[S].context,l,m,_);break;default:if(!T)for(E=1,T=new Array(C-1);E<C;E++)T[E-1]=arguments[E];P[S].fn.apply(P[S].context,T)}}return!0},EventEmitter.prototype.on=function on(i,l,p){return addListener(this,i,l,p,!1)},EventEmitter.prototype.once=function once(i,l,p){return addListener(this,i,l,p,!0)},EventEmitter.prototype.removeListener=function removeListener(i,l,m,_){var y=p?p+i:i;if(!this._events[y])return this;if(!l)return clearEvent(this,y),this;var x=this._events[y];if(x.fn)x.fn!==l||_&&!x.once||m&&x.context!==m||clearEvent(this,y);else{for(var v=0,T=[],S=x.length;v<S;v++)(x[v].fn!==l||_&&!x[v].once||m&&x[v].context!==m)&&T.push(x[v]);T.length?this._events[y]=1===T.length?T[0]:T:clearEvent(this,y)}return this},EventEmitter.prototype.removeAllListeners=function removeAllListeners(i){var l;return i?(l=p?p+i:i,this._events[l]&&clearEvent(this,l)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=p,EventEmitter.EventEmitter=EventEmitter,i.exports=EventEmitter}(Y);var V=getDefaultExportFromCjs(Y.exports);const X=2*Math.PI,j=180/Math.PI,q=Math.PI/180;class Point{constructor(i=0,l=0){this.x=0,this.y=0,this.x=i,this.y=l}clone(){return new Point(this.x,this.y)}copyFrom(i){return this.set(i.x,i.y),this}copyTo(i){return i.set(this.x,this.y),i}equals(i){return i.x===this.x&&i.y===this.y}set(i=0,l=i){return this.x=i,this.y=l,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Z.x=0,Z.y=0,Z}}const Z=new Point;class Matrix{constructor(i=1,l=0,p=0,m=1,_=0,y=0){this.array=null,this.a=i,this.b=l,this.c=p,this.d=m,this.tx=_,this.ty=y}fromArray(i){this.a=i[0],this.b=i[1],this.c=i[3],this.d=i[4],this.tx=i[2],this.ty=i[5]}set(i,l,p,m,_,y){return this.a=i,this.b=l,this.c=p,this.d=m,this.tx=_,this.ty=y,this}toArray(i,l){this.array||(this.array=new Float32Array(9));const p=l||this.array;return i?(p[0]=this.a,p[1]=this.b,p[2]=0,p[3]=this.c,p[4]=this.d,p[5]=0,p[6]=this.tx,p[7]=this.ty,p[8]=1):(p[0]=this.a,p[1]=this.c,p[2]=this.tx,p[3]=this.b,p[4]=this.d,p[5]=this.ty,p[6]=0,p[7]=0,p[8]=1),p}apply(i,l){l=l||new Point;const p=i.x,m=i.y;return l.x=this.a*p+this.c*m+this.tx,l.y=this.b*p+this.d*m+this.ty,l}applyInverse(i,l){l=l||new Point;const p=this.a,m=this.b,_=this.c,y=this.d,x=this.tx,v=this.ty,T=1/(p*y+_*-m),S=i.x,P=i.y;return l.x=y*T*S+-_*T*P+(v*_-x*y)*T,l.y=p*T*P+-m*T*S+(-v*p+x*m)*T,l}translate(i,l){return this.tx+=i,this.ty+=l,this}scale(i,l){return this.a*=i,this.d*=l,this.c*=i,this.b*=l,this.tx*=i,this.ty*=l,this}rotate(i){const l=Math.cos(i),p=Math.sin(i),m=this.a,_=this.c,y=this.tx;return this.a=m*l-this.b*p,this.b=m*p+this.b*l,this.c=_*l-this.d*p,this.d=_*p+this.d*l,this.tx=y*l-this.ty*p,this.ty=y*p+this.ty*l,this}append(i){const l=this.a,p=this.b,m=this.c,_=this.d;return this.a=i.a*l+i.b*m,this.b=i.a*p+i.b*_,this.c=i.c*l+i.d*m,this.d=i.c*p+i.d*_,this.tx=i.tx*l+i.ty*m+this.tx,this.ty=i.tx*p+i.ty*_+this.ty,this}appendFrom(i,l){const p=i.a,m=i.b,_=i.c,y=i.d,x=i.tx,v=i.ty,T=l.a,S=l.b,P=l.c,C=l.d;return this.a=p*T+m*P,this.b=p*S+m*C,this.c=_*T+y*P,this.d=_*S+y*C,this.tx=x*T+v*P+l.tx,this.ty=x*S+v*C+l.ty,this}setTransform(i,l,p,m,_,y,x,v,T){return this.a=Math.cos(x+T)*_,this.b=Math.sin(x+T)*_,this.c=-Math.sin(x-v)*y,this.d=Math.cos(x-v)*y,this.tx=i-(p*this.a+m*this.c),this.ty=l-(p*this.b+m*this.d),this}prepend(i){const l=this.tx;if(1!==i.a||0!==i.b||0!==i.c||1!==i.d){const l=this.a,p=this.c;this.a=l*i.a+this.b*i.c,this.b=l*i.b+this.b*i.d,this.c=p*i.a+this.d*i.c,this.d=p*i.b+this.d*i.d}return this.tx=l*i.a+this.ty*i.c+i.tx,this.ty=l*i.b+this.ty*i.d+i.ty,this}decompose(i){const l=this.a,p=this.b,m=this.c,_=this.d,y=i.pivot,x=-Math.atan2(-m,_),v=Math.atan2(p,l),T=Math.abs(x+v);return T<1e-5||Math.abs(X-T)<1e-5?(i.rotation=v,i.skew.x=i.skew.y=0):(i.rotation=0,i.skew.x=x,i.skew.y=v),i.scale.x=Math.sqrt(l*l+p*p),i.scale.y=Math.sqrt(m*m+_*_),i.position.x=this.tx+(y.x*l+y.y*m),i.position.y=this.ty+(y.x*p+y.y*_),i}invert(){const i=this.a,l=this.b,p=this.c,m=this.d,_=this.tx,y=i*m-l*p;return this.a=m/y,this.b=-l/y,this.c=-p/y,this.d=i/y,this.tx=(p*this.ty-m*_)/y,this.ty=-(i*this.ty-l*_)/y,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const i=new Matrix;return i.a=this.a,i.b=this.b,i.c=this.c,i.d=this.d,i.tx=this.tx,i.ty=this.ty,i}copyTo(i){return i.a=this.a,i.b=this.b,i.c=this.c,i.d=this.d,i.tx=this.tx,i.ty=this.ty,i}copyFrom(i){return this.a=i.a,this.b=i.b,this.c=i.c,this.d=i.d,this.tx=i.tx,this.ty=i.ty,this}equals(i){return i.a===this.a&&i.b===this.b&&i.c===this.c&&i.d===this.d&&i.tx===this.tx&&i.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 J.identity()}static get shared(){return Q.identity()}}const Q=new Matrix,J=new Matrix,tt=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],et=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],it=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],st=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],rt=[],nt=[],ot=Math.sign;!function init(){for(let i=0;i<16;i++){const l=[];rt.push(l);for(let p=0;p<16;p++){const m=ot(tt[i]*tt[p]+it[i]*et[p]),_=ot(et[i]*tt[p]+st[i]*et[p]),y=ot(tt[i]*it[p]+it[i]*st[p]),x=ot(et[i]*it[p]+st[i]*st[p]);for(let i=0;i<16;i++)if(tt[i]===m&&et[i]===_&&it[i]===y&&st[i]===x){l.push(i);break}}}for(let i=0;i<16;i++){const l=new Matrix;l.set(tt[i],et[i],it[i],st[i],0,0),nt.push(l)}}();const at={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:i=>tt[i],uY:i=>et[i],vX:i=>it[i],vY:i=>st[i],inv:i=>8&i?15&i:7&-i,add:(i,l)=>rt[i][l],sub:(i,l)=>rt[i][at.inv(l)],rotate180:i=>4^i,isVertical:i=>2==(3&i),byDirection:(i,l)=>2*Math.abs(i)<=Math.abs(l)?l>=0?at.S:at.N:2*Math.abs(l)<=Math.abs(i)?i>0?at.E:at.W:l>0?i>0?at.SE:at.SW:i>0?at.NE:at.NW,matrixAppendRotationInv:(i,l,p=0,m=0)=>{const _=nt[at.inv(l)];_.tx=p,_.ty=m,i.append(_)}},ht=[new Point,new Point,new Point,new Point];class Rectangle{constructor(i=0,l=0,p=0,m=0){this.type="rectangle",this.x=Number(i),this.y=Number(l),this.width=Number(p),this.height=Number(m)}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 Rectangle(0,0,0,0)}clone(){return new Rectangle(this.x,this.y,this.width,this.height)}copyFromBounds(i){return this.x=i.minX,this.y=i.minY,this.width=i.maxX-i.minX,this.height=i.maxY-i.minY,this}copyFrom(i){return this.x=i.x,this.y=i.y,this.width=i.width,this.height=i.height,this}copyTo(i){return i.copyFrom(this),i}contains(i,l){return!(this.width<=0||this.height<=0)&&(i>=this.x&&i<this.x+this.width&&l>=this.y&&l<this.y+this.height)}strokeContains(i,l,p){const{width:m,height:_}=this;if(m<=0||_<=0)return!1;const y=this.x,x=this.y;return i>=y-p/2&&i<=y+m+p/2&&l>=x-p/2&&l<=x+_+p/2&&!(i>y+p/2&&i<y+m-p/2&&l>x+p/2&&l<x+_-p/2)}intersects(i,l){if(!l){const l=this.x<i.x?i.x:this.x;if((this.right>i.right?i.right:this.right)<=l)return!1;const p=this.y<i.y?i.y:this.y;return(this.bottom>i.bottom?i.bottom:this.bottom)>p}const p=this.left,m=this.right,_=this.top,y=this.bottom;if(m<=p||y<=_)return!1;const x=ht[0].set(i.left,i.top),v=ht[1].set(i.left,i.bottom),T=ht[2].set(i.right,i.top),S=ht[3].set(i.right,i.bottom);if(T.x<=x.x||v.y<=x.y)return!1;const P=Math.sign(l.a*l.d-l.b*l.c);if(0===P)return!1;if(l.apply(x,x),l.apply(v,v),l.apply(T,T),l.apply(S,S),Math.max(x.x,v.x,T.x,S.x)<=p||Math.min(x.x,v.x,T.x,S.x)>=m||Math.max(x.y,v.y,T.y,S.y)<=_||Math.min(x.y,v.y,T.y,S.y)>=y)return!1;const C=P*(v.y-x.y),E=P*(x.x-v.x),A=C*p+E*_,k=C*m+E*_,B=C*p+E*y,F=C*m+E*y;if(Math.max(A,k,B,F)<=C*x.x+E*x.y||Math.min(A,k,B,F)>=C*S.x+E*S.y)return!1;const R=P*(x.y-T.y),I=P*(T.x-x.x),D=R*p+I*_,L=R*m+I*_,U=R*p+I*y,G=R*m+I*y;return!(Math.max(D,L,U,G)<=R*x.x+I*x.y||Math.min(D,L,U,G)>=R*S.x+I*S.y)}pad(i=0,l=i){return this.x-=i,this.y-=l,this.width+=2*i,this.height+=2*l,this}fit(i){const l=Math.max(this.x,i.x),p=Math.min(this.x+this.width,i.x+i.width),m=Math.max(this.y,i.y),_=Math.min(this.y+this.height,i.y+i.height);return this.x=l,this.width=Math.max(p-l,0),this.y=m,this.height=Math.max(_-m,0),this}ceil(i=1,l=.001){const p=Math.ceil((this.x+this.width-l)*i)/i,m=Math.ceil((this.y+this.height-l)*i)/i;return this.x=Math.floor((this.x+l)*i)/i,this.y=Math.floor((this.y+l)*i)/i,this.width=p-this.x,this.height=m-this.y,this}enlarge(i){const l=Math.min(this.x,i.x),p=Math.max(this.x+this.width,i.x+i.width),m=Math.min(this.y,i.y),_=Math.max(this.y+this.height,i.y+i.height);return this.x=l,this.width=p-l,this.y=m,this.height=_-m,this}getBounds(i){return(i=i||new Rectangle).copyFrom(this),i}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const lt={default:-1};function uid(i="default"){return void 0===lt[i]&&(lt[i]=-1),++lt[i]}const dt={},ut="8.0.0";function deprecation(i,l,p=3){if(dt[l])return;let m=(new Error).stack;void 0===m?console.warn("PixiJS Deprecation Warning: ",`${l}\nDeprecated since v${i}`):(m=m.split("\n").splice(p).join("\n"),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${l}\nDeprecated since v${i}`),console.warn(m),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${l}\nDeprecated since v${i}`),console.warn(m))),dt[l]=!0}const NOOP=()=>{};function nextPow2(i){return i+=0===i?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,(i|=i>>>16)+1}function isPow2(i){return!(i&i-1||!i)}const ct=Object.create(null);const pt=class _TextureStyle extends V{constructor(i={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,i={..._TextureStyle.defaultOptions,...i},this.addressMode=i.addressMode,this.addressModeU=i.addressModeU??this.addressModeU,this.addressModeV=i.addressModeV??this.addressModeV,this.addressModeW=i.addressModeW??this.addressModeW,this.scaleMode=i.scaleMode,this.magFilter=i.magFilter??this.magFilter,this.minFilter=i.minFilter??this.minFilter,this.mipmapFilter=i.mipmapFilter??this.mipmapFilter,this.lodMinClamp=i.lodMinClamp,this.lodMaxClamp=i.lodMaxClamp,this.compare=i.compare,this.maxAnisotropy=i.maxAnisotropy??1}set addressMode(i){this.addressModeU=i,this.addressModeV=i,this.addressModeW=i}get addressMode(){return this.addressModeU}set wrapMode(i){deprecation(ut,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=i}get wrapMode(){return this.addressMode}set scaleMode(i){this.magFilter=i,this.minFilter=i,this.mipmapFilter=i}get scaleMode(){return this.magFilter}set maxAnisotropy(i){this._maxAnisotropy=Math.min(i,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const i=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=function createResourceIdFromString(i){const l=ct[i];return void 0===l&&(ct[i]=uid("resource")),l}(i),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};pt.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ft=pt;const mt=class _TextureSource extends V{constructor(i={}){super(),this.options=i,this.uid=uid("textureSource"),this._resourceType="textureSource",this._resourceId=uid("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.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,i={..._TextureSource.defaultOptions,...i},this.label=i.label??"",this.resource=i.resource,this.autoGarbageCollect=i.autoGarbageCollect,this._resolution=i.resolution,i.width?this.pixelWidth=i.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,i.height?this.pixelHeight=i.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=i.format,this.dimension=i.dimensions,this.mipLevelCount=i.mipLevelCount,this.autoGenerateMipmaps=i.autoGenerateMipmaps,this.sampleCount=i.sampleCount,this.antialias=i.antialias,this.alphaMode=i.alphaMode,this.style=new ft(function definedProps(i){const l={};for(const p in i)void 0!==i[p]&&(l[p]=i[p]);return l}(i)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(i){this.style!==i&&(this._style?.off("change",this._onStyleChange,this),this._style=i,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(i){this._style.addressMode=i}get repeatMode(){return this._style.addressMode}set repeatMode(i){this._style.addressMode=i}get magFilter(){return this._style.magFilter}set magFilter(i){this._style.magFilter=i}get minFilter(){return this._style.minFilter}set minFilter(i){this._style.minFilter=i}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(i){this._style.mipmapFilter=i}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(i){this._style.lodMinClamp=i}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(i){this._style.lodMaxClamp=i}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const i=this._resolution;if(this.resize(this.resourceWidth/i,this.resourceHeight/i))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=uid("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:i}=this;return i.naturalWidth||i.videoWidth||i.displayWidth||i.width}get resourceHeight(){const{resource:i}=this;return i.naturalHeight||i.videoHeight||i.displayHeight||i.height}get resolution(){return this._resolution}set resolution(i){this._resolution!==i&&(this._resolution=i,this.width=this.pixelWidth/i,this.height=this.pixelHeight/i)}resize(i,l,p){p=p||this._resolution,i=i||this.width,l=l||this.height;const m=Math.round(i*p),_=Math.round(l*p);return this.width=m/p,this.height=_/p,this._resolution=p,(this.pixelWidth!==m||this.pixelHeight!==_)&&(this._refreshPOT(),this.pixelWidth=m,this.pixelHeight=_,this.emit("resize",this),this._resourceId=uid("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(i){this._style.wrapMode=i}get wrapMode(){return this._style.wrapMode}set scaleMode(i){this._style.scaleMode=i}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=isPow2(this.pixelWidth)&&isPow2(this.pixelHeight)}static test(i){throw new Error("Unimplemented")}};mt.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let gt=mt;class BufferImageSource extends gt{constructor(i){const l=i.resource||new Float32Array(i.width*i.height*4);let p=i.format;p||(p=l instanceof Float32Array?"rgba32float":l instanceof Int32Array||l instanceof Uint32Array?"rgba32uint":l instanceof Int16Array||l instanceof Uint16Array?"rgba16uint":(Int8Array,"bgra8unorm")),super({...i,resource:l,format:p}),this.uploadMethodId="buffer"}static test(i){return i instanceof Int8Array||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int16Array||i instanceof Uint16Array||i instanceof Int32Array||i instanceof Uint32Array||i instanceof Float32Array}}BufferImageSource.extension=O.TextureSource;const _t=new Matrix;class TextureMatrix{constructor(i,l){this.mapCoord=new Matrix,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===l?i.width<10?0:.5:l,this.isSimple=!1,this.texture=i}get texture(){return this._texture}set texture(i){this.texture!==i&&(this._texture?.removeListener("update",this.update,this),this._texture=i,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(i,l){void 0===l&&(l=i);const p=this.mapCoord;for(let m=0;m<i.length;m+=2){const _=i[m],y=i[m+1];l[m]=_*p.a+y*p.c+p.tx,l[m+1]=_*p.b+y*p.d+p.ty}return l}update(){const i=this._texture;this._updateID++;const l=i.uvs;this.mapCoord.set(l.x1-l.x0,l.y1-l.y0,l.x3-l.x0,l.y3-l.y0,l.x0,l.y0);const p=i.orig,m=i.trim;m&&(_t.set(p.width/m.width,0,0,p.height/m.height,-m.x/m.width,-m.y/m.height),this.mapCoord.append(_t));const _=i.source,y=this.uClampFrame,x=this.clampMargin/_._resolution,v=this.clampOffset/_._resolution;return y[0]=(i.frame.x+x+v)/_.width,y[1]=(i.frame.y+x+v)/_.height,y[2]=(i.frame.x+i.frame.width-x+v)/_.width,y[3]=(i.frame.y+i.frame.height-x+v)/_.height,this.uClampOffset[0]=this.clampOffset/_.pixelWidth,this.uClampOffset[1]=this.clampOffset/_.pixelHeight,this.isSimple=i.frame.width===_.width&&i.frame.height===_.height&&0===i.rotate,!0}}class Texture extends V{constructor({source:i,label:l,frame:p,orig:m,trim:_,defaultAnchor:y,defaultBorders:x,rotate:v,dynamic:T}={}){if(super(),this.uid=uid("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Rectangle,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=l,this.source=i?.source??new gt,this.noFrame=!p,p)this.frame.copyFrom(p);else{const{width:i,height:l}=this._source;this.frame.width=i,this.frame.height=l}this.orig=m||this.frame,this.trim=_,this.rotate=v??0,this.defaultAnchor=y,this.defaultBorders=x,this.destroyed=!1,this.dynamic=T||!1,this.updateUvs()}set source(i){this._source&&this._source.off("resize",this.update,this),this._source=i,i.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new TextureMatrix(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:i,frame:l}=this,{width:p,height:m}=this._source,_=l.x/p,y=l.y/m,x=l.width/p,v=l.height/m;let T=this.rotate;if(T){const l=x/2,p=v/2,m=_+l,S=y+p;T=at.add(T,at.NW),i.x0=m+l*at.uX(T),i.y0=S+p*at.uY(T),T=at.add(T,2),i.x1=m+l*at.uX(T),i.y1=S+p*at.uY(T),T=at.add(T,2),i.x2=m+l*at.uX(T),i.y2=S+p*at.uY(T),T=at.add(T,2),i.x3=m+l*at.uX(T),i.y3=S+p*at.uY(T)}else i.x0=_,i.y0=y,i.x1=_+x,i.y1=y,i.x2=_+x,i.y2=y+v,i.x3=_,i.y3=y+v}destroy(i=!1){this._source&&i&&(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 deprecation(ut,"Texture.baseTexture is now Texture.source"),this._source}}function updateQuadBounds(i,l,p,m){const{width:_,height:y}=p.orig,x=p.trim;if(x){const p=x.width,v=x.height;i.minX=x.x-l._x*_-m,i.maxX=i.minX+p,i.minY=x.y-l._y*y-m,i.maxY=i.minY+v}else i.minX=-l._x*_-m,i.maxX=i.minX+_,i.minY=-l._y*y-m,i.maxY=i.minY+y}Texture.EMPTY=new Texture({label:"EMPTY",source:new gt({label:"EMPTY"})}),Texture.EMPTY.destroy=NOOP,Texture.WHITE=new Texture({source:new BufferImageSource({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),Texture.WHITE.destroy=NOOP;const yt=new Matrix;class Bounds{constructor(i=1/0,l=1/0,p=-1/0,m=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=yt,this.minX=i,this.minY=l,this.maxX=p,this.maxY=m}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Rectangle);const i=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(i.x=0,i.y=0,i.width=0,i.height=0):i.copyFromBounds(this),i}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=yt,this}set(i,l,p,m){this.minX=i,this.minY=l,this.maxX=p,this.maxY=m}addFrame(i,l,p,m,_){_||(_=this.matrix);const y=_.a,x=_.b,v=_.c,T=_.d,S=_.tx,P=_.ty;let C=this.minX,E=this.minY,A=this.maxX,k=this.maxY,B=y*i+v*l+S,F=x*i+T*l+P;B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),B=y*p+v*l+S,F=x*p+T*l+P,B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),B=y*i+v*m+S,F=x*i+T*m+P,B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),B=y*p+v*m+S,F=x*p+T*m+P,B<C&&(C=B),F<E&&(E=F),B>A&&(A=B),F>k&&(k=F),this.minX=C,this.minY=E,this.maxX=A,this.maxY=k}addRect(i,l){this.addFrame(i.x,i.y,i.x+i.width,i.y+i.height,l)}addBounds(i,l){this.addFrame(i.minX,i.minY,i.maxX,i.maxY,l)}addBoundsMask(i){this.minX=this.minX>i.minX?this.minX:i.minX,this.minY=this.minY>i.minY?this.minY:i.minY,this.maxX=this.maxX<i.maxX?this.maxX:i.maxX,this.maxY=this.maxY<i.maxY?this.maxY:i.maxY}applyMatrix(i){const l=this.minX,p=this.minY,m=this.maxX,_=this.maxY,{a:y,b:x,c:v,d:T,tx:S,ty:P}=i;let C=y*l+v*p+S,E=x*l+T*p+P;this.minX=C,this.minY=E,this.maxX=C,this.maxY=E,C=y*m+v*p+S,E=x*m+T*p+P,this.minX=C<this.minX?C:this.minX,this.minY=E<this.minY?E:this.minY,this.maxX=C>this.maxX?C:this.maxX,this.maxY=E>this.maxY?E:this.maxY,C=y*l+v*_+S,E=x*l+T*_+P,this.minX=C<this.minX?C:this.minX,this.minY=E<this.minY?E:this.minY,this.maxX=C>this.maxX?C:this.maxX,this.maxY=E>this.maxY?E:this.maxY,C=y*m+v*_+S,E=x*m+T*_+P,this.minX=C<this.minX?C:this.minX,this.minY=E<this.minY?E:this.minY,this.maxX=C>this.maxX?C:this.maxX,this.maxY=E>this.maxY?E:this.maxY}fit(i){return this.minX<i.left&&(this.minX=i.left),this.maxX>i.right&&(this.maxX=i.right),this.minY<i.top&&(this.minY=i.top),this.maxY>i.bottom&&(this.maxY=i.bottom),this}fitBounds(i,l,p,m){return this.minX<i&&(this.minX=i),this.maxX>l&&(this.maxX=l),this.minY<p&&(this.minY=p),this.maxY>m&&(this.maxY=m),this}pad(i,l=i){return this.minX-=i,this.maxX+=i,this.minY-=l,this.maxY+=l,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 Bounds(this.minX,this.minY,this.maxX,this.maxY)}scale(i,l=i){return this.minX*=i,this.minY*=l,this.maxX*=i,this.maxY*=l,this}get x(){return this.minX}set x(i){const l=this.maxX-this.minX;this.minX=i,this.maxX=i+l}get y(){return this.minY}set y(i){const l=this.maxY-this.minY;this.minY=i,this.maxY=i+l}get width(){return this.maxX-this.minX}set width(i){this.maxX=this.minX+i}get height(){return this.maxY-this.minY}set height(i){this.maxY=this.minY+i}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(i,l,p,m){let _=this.minX,y=this.minY,x=this.maxX,v=this.maxY;m||(m=this.matrix);const T=m.a,S=m.b,P=m.c,C=m.d,E=m.tx,A=m.ty;for(let m=l;m<p;m+=2){const l=i[m],p=i[m+1],k=T*l+P*p+E,B=S*l+C*p+A;_=k<_?k:_,y=B<y?B:y,x=k>x?k:x,v=B>v?B:v}this.minX=_,this.minY=y,this.maxX=x,this.maxY=v}containsPoint(i,l){return this.minX<=i&&this.minY<=l&&this.maxX>=i&&this.maxY>=l}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}var xt={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(i){return"string"==typeof i?i.length>0:"number"==typeof i},n=function(i,l,p){return void 0===l&&(l=0),void 0===p&&(p=Math.pow(10,l)),Math.round(p*i)/p+0},e=function(i,l,p){return void 0===l&&(l=0),void 0===p&&(p=1),i>p?p:i>l?i:l},u=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},a=function(i){return{r:e(i.r,0,255),g:e(i.g,0,255),b:e(i.b,0,255),a:e(i.a)}},o=function(i){return{r:n(i.r),g:n(i.g),b:n(i.b),a:n(i.a,3)}},vt=/^#([0-9a-f]{3,8})$/i,s=function(i){var l=i.toString(16);return l.length<2?"0"+l:l},h=function(i){var l=i.r,p=i.g,m=i.b,_=i.a,y=Math.max(l,p,m),x=y-Math.min(l,p,m),v=x?y===l?(p-m)/x:y===p?2+(m-l)/x:4+(l-p)/x:0;return{h:60*(v<0?v+6:v),s:y?x/y*100:0,v:y/255*100,a:_}},b=function(i){var l=i.h,p=i.s,m=i.v,_=i.a;l=l/360*6,p/=100,m/=100;var y=Math.floor(l),x=m*(1-p),v=m*(1-(l-y)*p),T=m*(1-(1-l+y)*p),S=y%6;return{r:255*[m,v,x,x,T,m][S],g:255*[T,m,m,v,x,x][S],b:255*[x,x,T,m,m,v][S],a:_}},g=function(i){return{h:u(i.h),s:e(i.s,0,100),l:e(i.l,0,100),a:e(i.a)}},d=function(i){return{h:n(i.h),s:n(i.s),l:n(i.l),a:n(i.a,3)}},f=function(i){return b((p=(l=i).s,{h:l.h,s:(p*=((m=l.l)<50?m:100-m)/100)>0?2*p/(m+p)*100:0,v:m+p,a:l.a}));var l,p,m},c=function(i){return{h:(l=h(i)).h,s:(_=(200-(p=l.s))*(m=l.v)/100)>0&&_<200?p*m/100/(_<=100?_:200-_)*100:0,l:_/2,a:l.a};var l,p,m,_},bt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Tt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,St=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Pt={string:[[function(i){var l=vt.exec(i);return l?(i=l[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:4===i.length?n(parseInt(i[3]+i[3],16)/255,2):1}:6===i.length||8===i.length?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:8===i.length?n(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var l=Tt.exec(i)||St.exec(i);return l?l[2]!==l[4]||l[4]!==l[6]?null:a({r:Number(l[1])/(l[2]?100/255:1),g:Number(l[3])/(l[4]?100/255:1),b:Number(l[5])/(l[6]?100/255:1),a:void 0===l[7]?1:Number(l[7])/(l[8]?100:1)}):null},"rgb"],[function(i){var l=bt.exec(i)||wt.exec(i);if(!l)return null;var p,m,_=g({h:(p=l[1],m=l[2],void 0===m&&(m="deg"),Number(p)*(xt[m]||1)),s:Number(l[3]),l:Number(l[4]),a:void 0===l[5]?1:Number(l[5])/(l[6]?100:1)});return f(_)},"hsl"]],object:[[function(i){var l=i.r,p=i.g,m=i.b,_=i.a,y=void 0===_?1:_;return t(l)&&t(p)&&t(m)?a({r:Number(l),g:Number(p),b:Number(m),a:Number(y)}):null},"rgb"],[function(i){var l=i.h,p=i.s,m=i.l,_=i.a,y=void 0===_?1:_;if(!t(l)||!t(p)||!t(m))return null;var x=g({h:Number(l),s:Number(p),l:Number(m),a:Number(y)});return f(x)},"hsl"],[function(i){var l=i.h,p=i.s,m=i.v,_=i.a,y=void 0===_?1:_;if(!t(l)||!t(p)||!t(m))return null;var x=function(i){return{h:u(i.h),s:e(i.s,0,100),v:e(i.v,0,100),a:e(i.a)}}({h:Number(l),s:Number(p),v:Number(m),a:Number(y)});return b(x)},"hsv"]]},N=function(i,l){for(var p=0;p<l.length;p++){var m=l[p][0](i);if(m)return[m,l[p][1]]}return[null,void 0]},M=function(i,l){var p=c(i);return{h:p.h,s:e(p.s+100*l,0,100),l:p.l,a:p.a}},H=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},$=function(i,l){var p=c(i);return{h:p.h,s:p.s,l:e(p.l+100*l,0,100),a:p.a}},Mt=function(){function r(i){this.parsed=function(i){return"string"==typeof i?N(i.trim(),Pt.string):"object"==typeof i&&null!==i?N(i,Pt.object):[null,void 0]}(i)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return l=(i=o(this.rgba)).r,p=i.g,m=i.b,y=(_=i.a)<1?s(n(255*_)):"","#"+s(l)+s(p)+s(m)+y;var i,l,p,m,_,y},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return l=(i=o(this.rgba)).r,p=i.g,m=i.b,(_=i.a)<1?"rgba("+l+", "+p+", "+m+", "+_+")":"rgb("+l+", "+p+", "+m+")";var i,l,p,m,_},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return l=(i=d(c(this.rgba))).h,p=i.s,m=i.l,(_=i.a)<1?"hsla("+l+", "+p+"%, "+m+"%, "+_+")":"hsl("+l+", "+p+"%, "+m+"%)";var i,l,p,m,_},r.prototype.toHsv=function(){return i=h(this.rgba),{h:n(i.h),s:n(i.s),v:n(i.v),a:n(i.a,3)};var i},r.prototype.invert=function(){return w({r:255-(i=this.rgba).r,g:255-i.g,b:255-i.b,a:i.a});var i},r.prototype.saturate=function(i){return void 0===i&&(i=.1),w(M(this.rgba,i))},r.prototype.desaturate=function(i){return void 0===i&&(i=.1),w(M(this.rgba,-i))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(i){return void 0===i&&(i=.1),w($(this.rgba,i))},r.prototype.darken=function(i){return void 0===i&&(i=.1),w($(this.rgba,-i))},r.prototype.rotate=function(i){return void 0===i&&(i=15),this.hue(this.hue()+i)},r.prototype.alpha=function(i){return"number"==typeof i?w({r:(l=this.rgba).r,g:l.g,b:l.b,a:i}):n(this.rgba.a,3);var l},r.prototype.hue=function(i){var l=c(this.rgba);return"number"==typeof i?w({h:i,s:l.s,l:l.l,a:l.a}):n(l.h)},r.prototype.isEqual=function(i){return this.toHex()===w(i).toHex()},r}(),w=function(i){return i instanceof Mt?i:new Mt(i)},Ct=[];!function(i){i.forEach((function(i){Ct.indexOf(i)<0&&(i(Mt,Pt),Ct.push(i))}))}([function namesPlugin(i,l){var p={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"},m={};for(var _ in p)m[p[_]]=_;var y={};i.prototype.toName=function(l){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var _,x,v=m[this.toHex()];if(v)return v;if(null==l?void 0:l.closest){var T=this.toRgb(),S=1/0,P="black";if(!y.length)for(var C in p)y[C]=new i(p[C]).toRgb();for(var E in p){var A=(_=T,x=y[E],Math.pow(_.r-x.r,2)+Math.pow(_.g-x.g,2)+Math.pow(_.b-x.b,2));A<S&&(S=A,P=E)}return P}},l.string.push([function(l){var m=l.toLowerCase(),_="transparent"===m?"#0000":p[m];return _?new i(_).toRgb():null},"name"])}]);const Et=class _Color{constructor(i=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=i}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(i){return this.value=i,this}set value(i){if(i instanceof _Color)this._value=this._cloneSource(i._value),this._int=i._int,this._components.set(i._components);else{if(null===i)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,i)||(this._value=this._cloneSource(i),this._normalize(this._value))}}get value(){return this._value}_cloneSource(i){return"string"==typeof i||"number"==typeof i||i instanceof Number||null===i?i:Array.isArray(i)||ArrayBuffer.isView(i)?i.slice(0):"object"==typeof i&&null!==i?{...i}:i}_isSourceEqual(i,l){const p=typeof i;if(p!==typeof l)return!1;if("number"===p||"string"===p||i instanceof Number)return i===l;if(Array.isArray(i)&&Array.isArray(l)||ArrayBuffer.isView(i)&&ArrayBuffer.isView(l))return i.length===l.length&&i.every(((i,p)=>i===l[p]));if(null!==i&&null!==l){const p=Object.keys(i),m=Object.keys(l);return p.length===m.length&&p.every((p=>i[p]===l[p]))}return i===l}toRgba(){const[i,l,p,m]=this._components;return{r:i,g:l,b:p,a:m}}toRgb(){const[i,l,p]=this._components;return{r:i,g:l,b:p}}toRgbaString(){const[i,l,p]=this.toUint8RgbArray();return`rgba(${i},${l},${p},${this.alpha})`}toUint8RgbArray(i){const[l,p,m]=this._components;return this._arrayRgb||(this._arrayRgb=[]),(i=i||this._arrayRgb)[0]=Math.round(255*l),i[1]=Math.round(255*p),i[2]=Math.round(255*m),i}toArray(i){this._arrayRgba||(this._arrayRgba=[]),i=i||this._arrayRgba;const[l,p,m,_]=this._components;return i[0]=l,i[1]=p,i[2]=m,i[3]=_,i}toRgbArray(i){this._arrayRgb||(this._arrayRgb=[]),i=i||this._arrayRgb;const[l,p,m]=this._components;return i[0]=l,i[1]=p,i[2]=m,i}toNumber(){return this._int}toBgrNumber(){const[i,l,p]=this.toUint8RgbArray();return(p<<16)+(l<<8)+i}toLittleEndianNumber(){const i=this._int;return(i>>16)+(65280&i)+((255&i)<<16)}multiply(i){const[l,p,m,_]=_Color._temp.setValue(i)._components;return this._components[0]*=l,this._components[1]*=p,this._components[2]*=m,this._components[3]*=_,this._refreshInt(),this._value=null,this}premultiply(i,l=!0){return l&&(this._components[0]*=i,this._components[1]*=i,this._components[2]*=i),this._components[3]=i,this._refreshInt(),this._value=null,this}toPremultiplied(i,l=!0){if(1===i)return(255<<24)+this._int;if(0===i)return l?0:this._int;let p=this._int>>16&255,m=this._int>>8&255,_=255&this._int;return l&&(p=p*i+.5|0,m=m*i+.5|0,_=_*i+.5|0),(255*i<<24)+(p<<16)+(m<<8)+_}toHex(){const i=this._int.toString(16);return`#${"000000".substring(0,6-i.length)+i}`}toHexa(){const i=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-i.length)+i}setAlpha(i){return this._components[3]=this._clamp(i),this}_normalize(i){let l,p,m,_;if(("number"==typeof i||i instanceof Number)&&i>=0&&i<=16777215){l=(i>>16&255)/255,p=(i>>8&255)/255,m=(255&i)/255,_=1}else if((Array.isArray(i)||i instanceof Float32Array)&&i.length>=3&&i.length<=4)i=this._clamp(i),[l,p,m,_=1]=i;else if((i instanceof Uint8Array||i instanceof Uint8ClampedArray)&&i.length>=3&&i.length<=4)i=this._clamp(i,0,255),[l,p,m,_=255]=i,l/=255,p/=255,m/=255,_/=255;else if("string"==typeof i||"object"==typeof i){if("string"==typeof i){const l=_Color.HEX_PATTERN.exec(i);l&&(i=`#${l[2]}`)}const y=w(i);y.isValid()&&(({r:l,g:p,b:m,a:_}=y.rgba),l/=255,p/=255,m/=255)}if(void 0===l)throw new Error(`Unable to convert color ${i}`);this._components[0]=l,this._components[1]=p,this._components[2]=m,this._components[3]=_,this._refreshInt()}_refreshInt(){this._clamp(this._components);const[i,l,p]=this._components;this._int=(255*i<<16)+(255*l<<8)+(255*p|0)}_clamp(i,l=0,p=1){return"number"==typeof i?Math.min(Math.max(i,l),p):(i.forEach(((m,_)=>{i[_]=Math.min(Math.max(m,l),p)})),i)}static isColorLike(i){return"number"==typeof i||"string"==typeof i||i instanceof Number||i instanceof _Color||Array.isArray(i)||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Float32Array||void 0!==i.r&&void 0!==i.g&&void 0!==i.b||void 0!==i.r&&void 0!==i.g&&void 0!==i.b&&void 0!==i.a||void 0!==i.h&&void 0!==i.s&&void 0!==i.l||void 0!==i.h&&void 0!==i.s&&void 0!==i.l&&void 0!==i.a||void 0!==i.h&&void 0!==i.s&&void 0!==i.v||void 0!==i.h&&void 0!==i.s&&void 0!==i.v&&void 0!==i.a}};Et.shared=new Et,Et._temp=new Et,Et.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let At=Et;class Pool{constructor(i,l){this._pool=[],this._count=0,this._index=0,this._classType=i,l&&this.prepopulate(l)}prepopulate(i){for(let l=0;l<i;l++)this._pool[this._index++]=new this._classType;this._count+=i}get(i){let l;return l=this._index>0?this._pool[--this._index]:new this._classType,l.init?.(i),l}return(i){i.reset?.(),this._pool[this._index++]=i}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}const kt=new class PoolGroupClass{constructor(){this._poolsByClass=new Map}prepopulate(i,l){this.getPool(i).prepopulate(l)}get(i,l){return this.getPool(i).get(l)}return(i){this.getPool(i.constructor).return(i)}getPool(i){return this._poolsByClass.has(i)||this._poolsByClass.set(i,new Pool(i)),this._poolsByClass.get(i)}stats(){const i={};return this._poolsByClass.forEach((l=>{const p=i[l._classType.name]?l._classType.name+l._classType.ID:l._classType.name;i[p]={free:l.totalFree,used:l.totalUsed,size:l.totalSize}})),i}};function removeItems(i,l,p){const m=i.length;let _;if(l>=m||0===p)return;const y=m-(p=l+p>m?m-l:p);for(_=l;_<y;++_)i[_]=i[_+p];i.length=y}const Bt={allowChildren:!0,removeChildren(i=0,l){const p=l??this.children.length,m=p-i,_=[];if(m>0&&m<=p){for(let l=p-1;l>=i;l--){const i=this.children[l];i&&(_.push(i),i.parent=null)}removeItems(this.children,i,p);const l=this.renderGroup||this.parentRenderGroup;l&&l.removeChildren(_);for(let i=0;i<_.length;++i)this.emit("childRemoved",_[i],this,i),_[i].emit("removed",this);return _}if(0===m&&0===this.children.length)return _;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const l=this.getChildAt(i);return this.removeChild(l)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,l){if(l<0||l>=this.children.length)throw new Error(`The index ${l} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,l)},getChildIndex(i){const l=this.children.indexOf(i);if(-1===l)throw new Error("The supplied Container must be a child of the caller");return l},addChildAt(i,l){this.allowChildren||deprecation(ut,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:p}=this;if(l<0||l>p.length)throw new Error(`${i}addChildAt: The index ${l} supplied is out of bounds ${p.length}`);if(i.parent){const p=i.parent.children.indexOf(i);if(i.parent===this&&p===l)return i;-1!==p&&i.parent.children.splice(p,1)}l===p.length?p.push(i):p.splice(l,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const m=this.renderGroup||this.parentRenderGroup;return m&&m.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,l),i.emit("added",this),i},swapChildren(i,l){if(i===l)return;const p=this.getChildIndex(i),m=this.getChildIndex(l);this.children[p]=l,this.children[m]=i;const _=this.renderGroup||this.parentRenderGroup;_&&(_.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...i){return 1===i.length?this.reparentChildAt(i[0],this.children.length):(i.forEach((i=>this.reparentChildAt(i,this.children.length))),i[0])},reparentChildAt(i,l){if(i.parent===this)return this.setChildIndex(i,l),i;const p=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,l);const m=this.worldTransform.clone();return m.invert(),p.prepend(m),i.setFromMatrix(p),i}};class FilterEffect{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let i=0;i<this.filters.length;i++)this.filters[i].destroy();this.filters=null,this.filterArea=null}}const Ft=new class MaskEffectManagerClass{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach((i=>{this.add({test:i.test,maskClass:i})})))}add(i){this._tests.push(i)}getMaskEffect(i){this._initialized||this.init();for(let l=0;l<this._tests.length;l++){const p=this._tests[l];if(p.test(i))return kt.get(p.maskClass,i)}return i}returnMaskEffect(i){kt.return(i)}};z.handleByList(O.MaskEffect,Ft._effectClasses);const Rt={_maskEffect:null,_filterEffect:null,effects:[],addEffect(i){if(-1!==this.effects.indexOf(i))return;this.effects.push(i),this.effects.sort(((i,l)=>i.priority-l.priority));const l=this.renderGroup||this.parentRenderGroup;l&&(l.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const l=this.effects.indexOf(i);-1!==l&&(this.effects.splice(l,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const l=this._maskEffect;l?.mask!==i&&(l&&(this.removeEffect(l),Ft.returnMaskEffect(l),this._maskEffect=null),null!=i&&(this._maskEffect=Ft.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},set filters(i){!Array.isArray(i)&&i&&(i=[i]);const l=this._filterEffect||(this._filterEffect=new FilterEffect),p=i?.length>0,m=p!==l.filters?.length>0;i=Array.isArray(i)?i.slice(0):i,l.filters=Object.freeze(i),m&&(p?this.addEffect(l):(this.removeEffect(l),l.filters=i??null))},get filters(){return this._filterEffect?.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new FilterEffect),this._filterEffect.filterArea=i},get filterArea(){return this._filterEffect?.filterArea}},It={label:null,get name(){return deprecation(ut,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){deprecation(ut,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,l=!1){return this.getChildByLabel(i,l)},getChildByLabel(i,l=!1){const p=this.children;for(let l=0;l<p.length;l++){const m=p[l];if(m.label===i||i instanceof RegExp&&i.test(m.label))return m}if(l)for(let l=0;l<p.length;l++){const m=p[l].getChildByLabel(i,!0);if(m)return m}return null},getChildrenByLabel(i,l=!1,p=[]){const m=this.children;for(let l=0;l<m.length;l++){const _=m[l];(_.label===i||i instanceof RegExp&&i.test(_.label))&&p.push(_)}if(l)for(let l=0;l<m.length;l++)m[l].getChildrenByLabel(i,!0,p);return p}},Dt=new Pool(Matrix),Lt=new Pool(Bounds);function getGlobalBounds(i,l,p){let m,_;return p.clear(),i.parent?l?m=i.parent.worldTransform:(_=Dt.get().identity(),m=updateTransformBackwards(i,_)):m=Matrix.IDENTITY,_getGlobalBounds(i,p,m,l),_&&Dt.return(_),p.isValid||p.set(0,0,0,0),p}function _getGlobalBounds(i,l,p,m){if(!i.visible||!i.measurable)return;let _;m?_=i.worldTransform:(i.updateLocalTransform(),_=Dt.get(),_.appendFrom(i.localTransform,p));const y=l,x=!!i.effects.length;if(x&&(l=Lt.get().clear()),i.boundsArea)l.addRect(i.boundsArea,_);else{i.addBounds&&(l.matrix=_,i.addBounds(l));for(let p=0;p<i.children.length;p++)_getGlobalBounds(i.children[p],l,_,m)}if(x){for(let p=0;p<i.effects.length;p++)i.effects[p].addBounds?.(l);y.addBounds(l,Matrix.IDENTITY),Lt.return(l)}m||Dt.return(_)}function updateTransformBackwards(i,l){const p=i.parent;return p&&(updateTransformBackwards(p,l),p.updateLocalTransform(),l.append(p.localTransform)),l}let Ut=0;const Gt=500;function warn(...i){Ut!==Gt&&(Ut++,Ut===Gt?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}function getLocalBounds(i,l,p){return l.clear(),p||(p=Matrix.IDENTITY),_getLocalBounds(i,l,p,i,!0),l.isValid||l.set(0,0,0,0),l}function _getLocalBounds(i,l,p,m,_){let y;if(_)y=Dt.get(),y=p.copyTo(y);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const l=i.localTransform;y=Dt.get(),y.appendFrom(l,p)}const x=l,v=!!i.effects.length;if(v&&(l=Lt.get().clear()),i.boundsArea)l.addRect(i.boundsArea,y);else{i.renderPipeId&&(l.matrix=y,i.addBounds(l));const p=i.children;for(let i=0;i<p.length;i++)_getLocalBounds(p[i],l,y,m,!1)}if(v){for(let p=0;p<i.effects.length;p++)i.effects[p].addLocalBounds?.(l,m);x.addBounds(l,Matrix.IDENTITY),Lt.return(l)}Dt.return(y)}function checkChildrenDidChange(i,l){const p=i.children;for(let i=0;i<p.length;i++){const m=p[i],_=m.uid,y=(65535&m._didViewChangeTick)<<16|65535&m._didContainerChangeTick,x=l.index;l.data[x]===_&&l.data[x+1]===y||(l.data[l.index]=_,l.data[l.index+1]=y,l.didChange=!0),l.index=x+2,m.children.length&&checkChildrenDidChange(m,l)}return l.didChange}const Ot=new Matrix,zt={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,l){const p=Math.sign(this.scale.x)||1;this.scale.x=0!==l?i/l*p:p},_setHeight(i,l){const p=Math.sign(this.scale.y)||1;this.scale.y=0!==l?i/l*p:p},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Bounds});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),checkChildrenDidChange(this,i),i.didChange&&getLocalBounds(this,i.localBounds,Ot),i.localBounds},getBounds(i,l){return getGlobalBounds(this,i,l||new Bounds)}},Nt={_onRender:null,set onRender(i){const l=this.renderGroup||this.parentRenderGroup;if(!i)return this._onRender&&l?.removeOnRender(this),void(this._onRender=null);this._onRender||l?.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},Ht={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,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(sortChildren))}};function sortChildren(i,l){return i._zIndex-l._zIndex}const Wt={getGlobalPosition(i=new Point,l=!1){return this.parent?this.parent.toGlobal(this._position,i,l):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,l,p=!1){if(!p){this.updateLocalTransform();const p=updateTransformBackwards(this,new Matrix);return p.append(this.localTransform),p.apply(i,l)}return this.worldTransform.apply(i,l)},toLocal(i,l,p,m){if(l&&(i=l.toGlobal(i,p,m)),!m){this.updateLocalTransform();const l=updateTransformBackwards(this,new Matrix);return l.append(this.localTransform),l.applyInverse(i,p)}return this.worldTransform.applyInverse(i,p)}};let Kt=0;class InstructionSet{constructor(){this.uid=uid("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.tick=0}reset(){this.instructionSize=0,this.tick=Kt++}add(i){this.instructions[this.instructionSize++]=i}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class RenderGroup{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new Matrix,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new InstructionSet,this._onRenderContainers=[]}init(i){this.root=i,i._onRender&&this.addOnRender(i),i.didChange=!0;const l=i.children;for(let i=0;i<l.length;i++)this.addChild(l[i])}reset(){this.renderGroupChildren.length=0;for(const i in this.childrenToUpdate){const l=this.childrenToUpdate[i];l.list.fill(null),l.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}get localTransform(){return this.root.localTransform}addRenderGroupChild(i){i.renderGroupParent&&i.renderGroupParent._removeRenderGroupChild(i),i.renderGroupParent=this,this.renderGroupChildren.push(i)}_removeRenderGroupChild(i){const l=this.renderGroupChildren.indexOf(i);l>-1&&this.renderGroupChildren.splice(l,1),i.renderGroupParent=null}addChild(i){if(this.structureDidChange=!0,i.parentRenderGroup=this,i.updateTick=-1,i.parent===this.root?i.relativeRenderGroupDepth=1:i.relativeRenderGroupDepth=i.parent.relativeRenderGroupDepth+1,i.didChange=!0,this.onChildUpdate(i),i.renderGroup)return void this.addRenderGroupChild(i.renderGroup);i._onRender&&this.addOnRender(i);const l=i.children;for(let i=0;i<l.length;i++)this.addChild(l[i])}removeChild(i){if(this.structureDidChange=!0,i._onRender&&(i.renderGroup||this.removeOnRender(i)),i.parentRenderGroup=null,i.renderGroup)return void this._removeRenderGroupChild(i.renderGroup);const l=i.children;for(let i=0;i<l.length;i++)this.removeChild(l[i])}removeChildren(i){for(let l=0;l<i.length;l++)this.removeChild(i[l])}onChildUpdate(i){let l=this.childrenToUpdate[i.relativeRenderGroupDepth];l||(l=this.childrenToUpdate[i.relativeRenderGroupDepth]={index:0,list:[]}),l.list[l.index++]=i}updateRenderable(i){i.globalDisplayStatus<7||(i.didViewUpdate=!1,this.instructionSet.renderPipes[i.renderPipeId].updateRenderable(i))}onChildViewUpdate(i){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=i}get isRenderable(){return 7===this.root.localDisplayStatus&&this.worldAlpha>0}addOnRender(i){this._onRenderContainers.push(i)}removeOnRender(i){this._onRenderContainers.splice(this._onRenderContainers.indexOf(i),1)}runOnRender(){for(let i=0;i<this._onRenderContainers.length;i++)this._onRenderContainers[i]._onRender()}destroy(){this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(i=[]){const l=this.root.children;for(let p=0;p<l.length;p++)this._getChildren(l[p],i);return i}_getChildren(i,l=[]){if(l.push(i),i.renderGroup)return l;const p=i.children;for(let i=0;i<p.length;i++)this._getChildren(p[i],l);return l}}const Yt=new ObservablePoint(null),Vt=new ObservablePoint(null),$t=new ObservablePoint(null,1,1);class Container extends V{constructor(i={}){super(),this.uid=uid("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.updateTick=-1,this.localTransform=new Matrix,this.relativeGroupTransform=new Matrix,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ObservablePoint(this,0,0),this._scale=$t,this._pivot=Vt,this._skew=Yt,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=[],function assignWithIgnore(i,l,p={}){for(const m in l)p[m]||void 0===l[m]||(i[m]=l[m])}(this,i,{children:!0,parent:!0,effects:!0}),i.children?.forEach((i=>this.addChild(i))),i.parent?.addChild(this)}static mixin(i){Object.defineProperties(Container.prototype,Object.getOwnPropertyDescriptors(i))}set _didChangeId(i){this._didViewChangeTick=i>>12&4095,this._didContainerChangeTick=4095&i}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...i){if(this.allowChildren||deprecation(ut,"addChild: Only Containers will be allowed to add children in v8.0.0"),i.length>1){for(let l=0;l<i.length;l++)this.addChild(i[l]);return i[0]}const l=i[0];if(l.parent===this)return this.children.splice(this.children.indexOf(l),1),this.children.push(l),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),l;l.parent&&l.parent.removeChild(l),this.children.push(l),this.sortableChildren&&(this.sortDirty=!0),l.parent=this,l.didChange=!0,l.didViewUpdate=!1,l._updateFlags=15;const p=this.renderGroup||this.parentRenderGroup;return p&&p.addChild(l),this.emit("childAdded",l,this,this.children.length-1),l.emit("added",this),this._didViewChangeTick++,0!==l._zIndex&&l.depthOfChildModified(),l}removeChild(...i){if(i.length>1){for(let l=0;l<i.length;l++)this.removeChild(i[l]);return i[0]}const l=i[0],p=this.children.indexOf(l);return p>-1&&(this._didViewChangeTick++,this.children.splice(p,1),this.renderGroup?this.renderGroup.removeChild(l):this.parentRenderGroup&&this.parentRenderGroup.removeChild(l),l.parent=null,this.emit("childRemoved",l,this,p),l.emit("removed",this)),l}_onUpdate(i){i&&i===this._skew&&this._updateSkew(),this._didContainerChangeTick++,this.didChange||(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(i){!!this.renderGroup!==i&&(i?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const i=this.parentRenderGroup;i?.removeChild(this),this.renderGroup=kt.get(RenderGroup,this),this.groupTransform=Matrix.IDENTITY,i?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const i=this.parentRenderGroup;i?.removeChild(this),kt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,i?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new Matrix),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(i){this._position.x=i}get y(){return this._position.y}set y(i){this._position.y=i}get position(){return this._position}set position(i){this._position.copyFrom(i)}get rotation(){return this._rotation}set rotation(i){this._rotation!==i&&(this._rotation=i,this._onUpdate(this._skew))}get angle(){return this.rotation*j}set angle(i){this.rotation=i*q}get pivot(){return this._pivot===Vt&&(this._pivot=new ObservablePoint(this,0,0)),this._pivot}set pivot(i){this._pivot===Vt&&(this._pivot=new ObservablePoint(this,0,0)),"number"==typeof i?this._pivot.set(i):this._pivot.copyFrom(i)}get skew(){return this._skew===Yt&&(this._skew=new ObservablePoint(this,0,0)),this._skew}set skew(i){this._skew===Yt&&(this._skew=new ObservablePoint(this,0,0)),this._skew.copyFrom(i)}get scale(){return this._scale===$t&&(this._scale=new ObservablePoint(this,1,1)),this._scale}set scale(i){this._scale===$t&&(this._scale=new ObservablePoint(this,0,0)),"number"==typeof i?this._scale.set(i):this._scale.copyFrom(i)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(i){const l=this.getLocalBounds().width;this._setWidth(i,l)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(i){const l=this.getLocalBounds().height;this._setHeight(i,l)}getSize(i){i||(i={});const l=this.getLocalBounds();return i.width=Math.abs(this.scale.x*l.width),i.height=Math.abs(this.scale.y*l.height),i}setSize(i,l){const p=this.getLocalBounds();"object"==typeof i?(l=i.height??i.width,i=i.width):l??(l=i),void 0!==i&&this._setWidth(i,p.width),void 0!==l&&this._setHeight(l,p.height)}_updateSkew(){const i=this._rotation,l=this._skew;this._cx=Math.cos(i+l._y),this._sx=Math.sin(i+l._y),this._cy=-Math.sin(i-l._x),this._sy=Math.cos(i-l._x)}updateTransform(i){return this.position.set("number"==typeof i.x?i.x:this.position.x,"number"==typeof i.y?i.y:this.position.y),this.scale.set("number"==typeof i.scaleX?i.scaleX||1:this.scale.x,"number"==typeof i.scaleY?i.scaleY||1:this.scale.y),this.rotation="number"==typeof i.rotation?i.rotation:this.rotation,this.skew.set("number"==typeof i.skewX?i.skewX:this.skew.x,"number"==typeof i.skewY?i.skewY:this.skew.y),this.pivot.set("number"==typeof i.pivotX?i.pivotX:this.pivot.x,"number"==typeof i.pivotY?i.pivotY:this.pivot.y),this}setFromMatrix(i){i.decompose(this)}updateLocalTransform(){const i=this._didContainerChangeTick;if(this._didLocalTransformChangeId===i)return;this._didLocalTransformChangeId=i;const l=this.localTransform,p=this._scale,m=this._pivot,_=this._position,y=p._x,x=p._y,v=m._x,T=m._y;l.a=this._cx*y,l.b=this._sx*y,l.c=this._cy*x,l.d=this._sy*x,l.tx=_._x-(v*l.a+T*l.c),l.ty=_._y-(v*l.b+T*l.d)}set alpha(i){i!==this.localAlpha&&(this.localAlpha=i,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(i){const l=At.shared.setValue(i??16777215).toBgrNumber();l!==this.localColor&&(this.localColor=l,this._updateFlags|=1,this._onUpdate())}get tint(){const i=this.localColor;return((255&i)<<16)+(65280&i)+(i>>16&255)}set blendMode(i){this.localBlendMode!==i&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=i,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(i){const l=i?2:0;(2&this.localDisplayStatus)!==l&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(i){const l=i?0:4;(4&this.localDisplayStatus)!==l&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(i){const l=i?1:0;(1&this.localDisplayStatus)!==l&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&this.groupAlpha>0}destroy(i=!1){if(this.destroyed)return;this.destroyed=!0;const l=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._skew=null,this.emit("destroyed",this),this.removeAllListeners();if("boolean"==typeof i?i:i?.children)for(let p=0;p<l.length;++p)l[p].destroy(i);this.renderGroup?.destroy(),this.renderGroup=null}}Container.mixin(Bt),Container.mixin(Wt),Container.mixin(Nt),Container.mixin(zt),Container.mixin(Rt),Container.mixin(It),Container.mixin(Ht),Container.mixin({cullArea:null,cullable:!1,cullableChildren:!0});class ViewContainer extends Container{constructor(){super(...arguments),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=0,this._lastInstructionTick=-1,this._bounds=new Bounds(0,1,0,0),this._boundsDirty=!0}_updateBounds(){}get roundPixels(){return!!this._roundPixels}set roundPixels(i){this._roundPixels=i?1:0}containsPoint(i){const l=this.bounds,{x:p,y:m}=i;return p>=l.minX&&p<=l.maxX&&m>=l.minY&&m<=l.maxY}destroy(i){super.destroy(i),this._bounds=null}}class Sprite extends ViewContainer{constructor(i=Texture.EMPTY){i instanceof Texture&&(i={texture:i});const{texture:l=Texture.EMPTY,anchor:p,roundPixels:m,width:_,height:y,...x}=i;super({label:"Sprite",...x}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new ObservablePoint({_onUpdate:()=>{this.onViewUpdate()}}),p?this.anchor=p:l.defaultAnchor&&(this.anchor=l.defaultAnchor),this.texture=l,this.allowChildren=!1,this.roundPixels=m??!1,void 0!==_&&(this.width=_),void 0!==y&&(this.height=y)}static from(i,l=!1){return new Sprite(i instanceof Texture?i:Texture.from(i,l))}set texture(i){i||(i=Texture.EMPTY);const l=this._texture;l!==i&&(l&&l.dynamic&&l.off("update",this.onViewUpdate,this),i.dynamic&&i.on("update",this.onViewUpdate,this),this._texture=i,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 bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(i){const l=this.sourceBounds;return i.x>=l.maxX&&i.x<=l.minX&&i.y>=l.maxY&&i.y<=l.minY}addBounds(i){const l=this._texture.trim?this.sourceBounds:this.bounds;i.addFrame(l.minX,l.minY,l.maxX,l.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const i=this.renderGroup||this.parentRenderGroup;i&&i.onChildViewUpdate(this)}_updateBounds(){updateQuadBounds(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const i=this._anchor,l=this._texture,p=this._sourceBounds,{width:m,height:_}=l.orig;p.maxX=-i._x*m,p.minX=p.maxX+m,p.maxY=-i._y*_,p.minY=p.maxY+_}destroy(i=!1){super.destroy(i);if("boolean"==typeof i?i:i?.texture){const l="boolean"==typeof i?i:i?.textureSource;this._texture.destroy(l)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(i){"number"==typeof i?this._anchor.set(i):this._anchor.copyFrom(i)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(i){this._setWidth(i,this._texture.orig.width),this._width=i}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(i){this._setHeight(i,this._texture.orig.height),this._height=i}getSize(i){return i||(i={}),i.width=Math.abs(this.scale.x)*this._texture.orig.width,i.height=Math.abs(this.scale.y)*this._texture.orig.height,i}setSize(i,l){"object"==typeof i?(l=i.height??i.width,i=i.width):l??(l=i),void 0!==i&&this._setWidth(i,this._texture.orig.width),void 0!==l&&this._setHeight(l,this._texture.orig.height)}}const Xt=new Bounds;function addMaskBounds(i,l,p){const m=Xt;i.measurable=!0,getGlobalBounds(i,p,m),l.addBoundsMask(m),i.measurable=!1}function addMaskLocalBounds(i,l,p){const m=Lt.get();i.measurable=!0;const _=Dt.get().identity();getLocalBounds(i,m,getMatrixRelativeToParent(i,p,_)),i.measurable=!1,l.addBoundsMask(m),Dt.return(_),Lt.return(m)}function getMatrixRelativeToParent(i,l,p){return i?(i!==l&&(getMatrixRelativeToParent(i.parent,l,p),i.updateLocalTransform(),p.append(i.localTransform)),p):(warn("Mask bounds, renderable is not inside the root container"),p)}class AlphaMask{constructor(i){this.priority=0,this.pipe="alphaMask",i?.mask&&this.init(i.mask)}init(i){this.mask=i,this.renderMaskToTexture=!(i instanceof Sprite),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(i,l){addMaskBounds(this.mask,i,l)}addLocalBounds(i,l){addMaskLocalBounds(this.mask,i,l)}containsPoint(i,l){return l(this.mask,i)}destroy(){this.reset()}static test(i){return i instanceof Sprite}}AlphaMask.extension=O.MaskEffect;class ColorMask{constructor(i){this.priority=0,this.pipe="colorMask",i?.mask&&this.init(i.mask)}init(i){this.mask=i}destroy(){}static test(i){return"number"==typeof i}}ColorMask.extension=O.MaskEffect;class StencilMask{constructor(i){this.priority=0,this.pipe="stencilMask",i?.mask&&this.init(i.mask)}init(i){this.mask=i,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(i,l){addMaskBounds(this.mask,i,l)}addLocalBounds(i,l){addMaskLocalBounds(this.mask,i,l)}containsPoint(i,l){return l(this.mask,i)}destroy(){this.reset()}static test(i){return i instanceof Container}}StencilMask.extension=O.MaskEffect;let jt={createCanvas:(i,l)=>{const p=document.createElement("canvas");return p.width=i,p.height=l,p},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,l)=>fetch(i,l),parseXML:i=>(new DOMParser).parseFromString(i,"text/xml")};const qt={get:()=>jt,set(i){jt=i}};class CanvasSource extends gt{constructor(i){i.resource||(i.resource=qt.get().createCanvas()),i.width||(i.width=i.resource.width,i.autoDensity||(i.width/=i.resolution)),i.height||(i.height=i.resource.height,i.autoDensity||(i.height/=i.resolution)),super(i),this.uploadMethodId="image",this.autoDensity=i.autoDensity;const l=i.resource;this.pixelWidth===l.width&&this.pixelWidth===l.height||this.resizeCanvas(),this.transparent=!!i.transparent}resizeCanvas(){this.autoDensity&&(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(i=this.width,l=this.height,p=this._resolution){const m=super.resize(i,l,p);return m&&this.resizeCanvas(),m}static test(i){return globalThis.HTMLCanvasElement&&i instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&i instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}CanvasSource.extension=O.TextureSource;class ImageSource extends gt{constructor(i){if(i.resource&&globalThis.HTMLImageElement&&i.resource instanceof HTMLImageElement){const l=qt.get().createCanvas(i.resource.width,i.resource.height);l.getContext("2d").drawImage(i.resource,0,0,i.resource.width,i.resource.height),i.resource=l,warn("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(i),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(i){return globalThis.HTMLImageElement&&i instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&i instanceof ImageBitmap||globalThis.VideoFrame&&i instanceof VideoFrame}}ImageSource.extension=O.TextureSource;var Zt=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(Zt||{});class TickerListener{constructor(i,l=null,p=0,m=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=i,this._context=l,this.priority=p,this._once=m}match(i,l=null){return this._fn===i&&this._context===l}emit(i){this._fn&&(this._context?this._fn.call(this._context,i):this._fn(i));const l=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),l}connect(i){this.previous=i,i.next&&(i.next.previous=this),this.next=i.next,i.next=this}destroy(i=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const l=this.next;return this.next=i?null:l,this.previous=null,l}}const Qt=class _Ticker{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 TickerListener(null,null,1/0),this.deltaMS=1/_Ticker.targetFPMS,this.elapsedMS=1/_Ticker.targetFPMS,this._tick=i=>{this._requestId=null,this.started&&(this.update(i),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(i,l,p=Zt.NORMAL){return this._addListener(new TickerListener(i,l,p))}addOnce(i,l,p=Zt.NORMAL){return this._addListener(new TickerListener(i,l,p,!0))}_addListener(i){let l=this._head.next,p=this._head;if(l){for(;l;){if(i.priority>l.priority){i.connect(p);break}p=l,l=l.next}i.previous||i.connect(p)}else i.connect(p);return this._startIfPossible(),this}remove(i,l){let p=this._head.next;for(;p;)p=p.match(i,l)?p.destroy():p.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let i=0,l=this._head;for(;l=l.next;)i++;return i}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let i=this._head.next;for(;i;)i=i.destroy(!0);this._head.destroy(),this._head=null}}update(i=performance.now()){let l;if(i>this.lastTime){if(l=this.elapsedMS=i-this.lastTime,l>this._maxElapsedMS&&(l=this._maxElapsedMS),l*=this.speed,this._minElapsedMS){const l=i-this._lastFrame|0;if(l<this._minElapsedMS)return;this._lastFrame=i-l%this._minElapsedMS}this.deltaMS=l,this.deltaTime=this.deltaMS*_Ticker.targetFPMS;const p=this._head;let m=p.next;for(;m;)m=m.emit(this);p.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=i}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(i){const l=Math.min(this.maxFPS,i),p=Math.min(Math.max(0,l)/1e3,_Ticker.targetFPMS);this._maxElapsedMS=1/p}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(i){if(0===i)this._minElapsedMS=0;else{const l=Math.max(this.minFPS,i);this._minElapsedMS=1/(l/1e3)}}static get shared(){if(!_Ticker._shared){const i=_Ticker._shared=new _Ticker;i.autoStart=!0,i._protected=!0}return _Ticker._shared}static get system(){if(!_Ticker._system){const i=_Ticker._system=new _Ticker;i.autoStart=!0,i._protected=!0}return _Ticker._system}};Qt.targetFPMS=.06;let Jt,te=Qt;const ee=class _VideoSource extends gt{constructor(i){super(i),this.isReady=!1,this.uploadMethodId="video",i={..._VideoSource.defaultOptions,...i},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=i.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==i.autoPlay,this.alphaMode=i.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),!1!==i.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const i=te.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-i)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const i=this.resource,l=this.options;return(i.readyState===i.HAVE_ENOUGH_DATA||i.readyState===i.HAVE_FUTURE_DATA)&&i.width&&i.height&&(i.complete=!0),i.addEventListener("play",this._onPlayStart),i.addEventListener("pause",this._onPlayStop),i.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(l.preload||i.addEventListener("canplay",this._onCanPlay),i.addEventListener("canplaythrough",this._onCanPlayThrough),i.addEventListener("error",this._onError,!0)),this.alphaMode=await async function detectVideoAlphaMode(){return Jt??(Jt=(async()=>{const i=document.createElement("canvas").getContext("webgl");if(!i)return"premultiply-alpha-on-upload";const l=await new Promise((i=>{const l=document.createElement("video");l.onloadeddata=()=>i(l),l.onerror=()=>i(null),l.autoplay=!1,l.crossOrigin="anonymous",l.preload="auto",l.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",l.load()}));if(!l)return"premultiply-alpha-on-upload";const p=i.createTexture();i.bindTexture(i.TEXTURE_2D,p);const m=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,m),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,p,0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,l);const _=new Uint8Array(4);return i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,_),i.deleteFramebuffer(m),i.deleteTexture(p),i.getExtension("WEBGL_lose_context")?.loseContext(),_[0]<=_[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Jt}(),this._load=new Promise(((p,m)=>{this.isValid?p(this):(this._resolve=p,this._reject=m,void 0!==l.preloadTimeoutMs&&(this._preloadTimeout=setTimeout((()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${l.preloadTimeoutMs}ms`))}))),i.load())})),this._load}_onError(i){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",i),this._reject&&(this._reject(i),this._reject=null,this._resolve=null)}_isSourcePlaying(){const i=this.resource;return!i.paused&&!i.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const i=this.resource;this.isValid&&(this.isReady=!0,this.resize(i.videoWidth,i.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const i=this.resource;i&&(i.removeEventListener("play",this._onPlayStart),i.removeEventListener("pause",this._onPlayStop),i.removeEventListener("seeked",this._onSeeked),i.removeEventListener("canplay",this._onCanPlay),i.removeEventListener("canplaythrough",this._onCanPlayThrough),i.removeEventListener("error",this._onError,!0),i.pause(),i.src="",i.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(i){i!==this._autoUpdate&&(this._autoUpdate=i,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(i){i!==this._updateFPS&&(this._updateFPS=i,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(te.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(te.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(te.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(i){return globalThis.HTMLVideoElement&&i instanceof HTMLVideoElement}};ee.extension=O.TextureSource,ee.defaultOptions={...gt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},ee.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let ie=ee;const convertToList=(i,l,p=!1)=>(Array.isArray(i)||(i=[i]),l?i.map((i=>"string"==typeof i||p?l(i):i)):i);const se=new class CacheClass{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(i){return this._cache.has(i)}get(i){const l=this._cache.get(i);return l||warn(`[Assets] Asset id ${i} was not found in the Cache`),l}set(i,l){const p=convertToList(i);let m;for(let i=0;i<this.parsers.length;i++){const _=this.parsers[i];if(_.test(l)){m=_.getCacheableAssets(p,l);break}}const _=new Map(Object.entries(m||{}));m||p.forEach((i=>{_.set(i,l)}));const y=[..._.keys()],x={cacheKeys:y,keys:p};p.forEach((i=>{this._cacheMap.set(i,x)})),y.forEach((i=>{const p=m?m[i]:l;this._cache.has(i)&&this._cache.get(i)!==p&&warn("[Cache] already has key:",i),this._cache.set(i,_.get(i))}))}remove(i){if(!this._cacheMap.has(i))return void warn(`[Assets] Asset id ${i} was not found in the Cache`);const l=this._cacheMap.get(i);l.cacheKeys.forEach((i=>{this._cache.delete(i)})),l.keys.forEach((i=>{this._cacheMap.delete(i)}))}get parsers(){return this._parsers}},re=[];function textureSourceFrom(i={}){const l=i&&i.resource,p=l?i.resource:i,m=l?i:{resource:i};for(let i=0;i<re.length;i++){const l=re[i];if(l.test(p))return new l(m)}throw new Error(`Could not find a source type for resource: ${m.resource}`)}z.handleByList(O.TextureSource,re),Texture.from=function textureFrom(i,l=!1){return"string"==typeof i?se.get(i):i instanceof gt?new Texture({source:i}):function resourceToTexture(i={},l=!1){const p=i&&i.resource,m=p?i.resource:i,_=p?i:{resource:i};if(!l&&se.has(m))return se.get(m);const y=new Texture({source:textureSourceFrom(_)});return y.on("destroy",(()=>{se.has(m)&&se.remove(m)})),l||se.set(m,y),y}(i,l)},gt.from=textureSourceFrom,z.add(AlphaMask,ColorMask,StencilMask,ie,ImageSource,CanvasSource,BufferImageSource);var ne=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(ne||{});function assertPath(i){if("string"!=typeof i)throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function removeUrlParams(i){return i.split("?")[0].split("#")[0]}const oe={toPosix:i=>function replaceAll(i,l,p){return i.replace(new RegExp(function escapeRegExp(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(l),"g"),p)}(i,"\\","/"),isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl:i=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i),isBlobUrl:i=>i.startsWith("blob:"),hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){assertPath(i),i=this.toPosix(i);const l=/^file:\/\/\//.exec(i);if(l)return l[0];const p=/^[^/:]+:\/{0,2}/.exec(i);return p?p[0]:""},toAbsolute(i,l,p){if(assertPath(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const m=removeUrlParams(this.toPosix(l??qt.get().getBaseUrl())),_=removeUrlParams(this.toPosix(p??this.rootname(m)));if((i=this.toPosix(i)).startsWith("/"))return oe.join(_,i.slice(1));return this.isAbsolute(i)?i:this.join(m,i)},normalize(i){if(assertPath(i),0===i.length)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;let l="";const p=(i=this.toPosix(i)).startsWith("/");this.hasProtocol(i)&&(l=this.rootname(i),i=i.slice(l.length));const m=i.endsWith("/");return i=function normalizeStringPosix(i,l){let p="",m=0,_=-1,y=0,x=-1;for(let l=0;l<=i.length;++l){if(l<i.length)x=i.charCodeAt(l);else{if(47===x)break;x=47}if(47===x){if(_===l-1||1===y);else if(_!==l-1&&2===y){if(p.length<2||2!==m||46!==p.charCodeAt(p.length-1)||46!==p.charCodeAt(p.length-2))if(p.length>2){const i=p.lastIndexOf("/");if(i!==p.length-1){-1===i?(p="",m=0):(p=p.slice(0,i),m=p.length-1-p.lastIndexOf("/")),_=l,y=0;continue}}else if(2===p.length||1===p.length){p="",m=0,_=l,y=0;continue}}else p.length>0?p+=`/${i.slice(_+1,l)}`:p=i.slice(_+1,l),m=l-_-1;_=l,y=0}else 46===x&&-1!==y?++y:y=-1}return p}(i),i.length>0&&m&&(i+="/"),p?`/${i}`:l+i},isAbsolute(i){return assertPath(i),i=this.toPosix(i),!!this.hasProtocol(i)||i.startsWith("/")},join(...i){if(0===i.length)return".";let l;for(let p=0;p<i.length;++p){const m=i[p];if(assertPath(m),m.length>0)if(void 0===l)l=m;else{const _=i[p-1]??"";this.joinExtensions.includes(this.extname(_).toLowerCase())?l+=`/../${m}`:l+=`/${m}`}}return void 0===l?".":this.normalize(l)},dirname(i){if(assertPath(i),0===i.length)return".";let l=(i=this.toPosix(i)).charCodeAt(0);const p=47===l;let m=-1,_=!0;const y=this.getProtocol(i),x=i;for(let p=(i=i.slice(y.length)).length-1;p>=1;--p)if(l=i.charCodeAt(p),47===l){if(!_){m=p;break}}else _=!1;return-1===m?p?"/":this.isUrl(x)?y+i:y:p&&1===m?"//":y+i.slice(0,m)},rootname(i){assertPath(i);let l="";if(l=(i=this.toPosix(i)).startsWith("/")?"/":this.getProtocol(i),this.isUrl(i)){const p=i.indexOf("/",l.length);l=-1!==p?i.slice(0,p):i,l.endsWith("/")||(l+="/")}return l},basename(i,l){assertPath(i),l&&assertPath(l),i=removeUrlParams(this.toPosix(i));let p,m=0,_=-1,y=!0;if(void 0!==l&&l.length>0&&l.length<=i.length){if(l.length===i.length&&l===i)return"";let x=l.length-1,v=-1;for(p=i.length-1;p>=0;--p){const T=i.charCodeAt(p);if(47===T){if(!y){m=p+1;break}}else-1===v&&(y=!1,v=p+1),x>=0&&(T===l.charCodeAt(x)?-1==--x&&(_=p):(x=-1,_=v))}return m===_?_=v:-1===_&&(_=i.length),i.slice(m,_)}for(p=i.length-1;p>=0;--p)if(47===i.charCodeAt(p)){if(!y){m=p+1;break}}else-1===_&&(y=!1,_=p+1);return-1===_?"":i.slice(m,_)},extname(i){assertPath(i);let l=-1,p=0,m=-1,_=!0,y=0;for(let x=(i=removeUrlParams(this.toPosix(i))).length-1;x>=0;--x){const v=i.charCodeAt(x);if(47!==v)-1===m&&(_=!1,m=x+1),46===v?-1===l?l=x:1!==y&&(y=1):-1!==l&&(y=-1);else if(!_){p=x+1;break}}return-1===l||-1===m||0===y||1===y&&l===m-1&&l===p+1?"":i.slice(l,m)},parse(i){assertPath(i);const l={root:"",dir:"",base:"",ext:"",name:""};if(0===i.length)return l;let p=(i=removeUrlParams(this.toPosix(i))).charCodeAt(0);const m=this.isAbsolute(i);let _;l.root=this.rootname(i),_=m||this.hasProtocol(i)?1:0;let y=-1,x=0,v=-1,T=!0,S=i.length-1,P=0;for(;S>=_;--S)if(p=i.charCodeAt(S),47!==p)-1===v&&(T=!1,v=S+1),46===p?-1===y?y=S:1!==P&&(P=1):-1!==y&&(P=-1);else if(!T){x=S+1;break}return-1===y||-1===v||0===P||1===P&&y===v-1&&y===x+1?-1!==v&&(l.base=l.name=0===x&&m?i.slice(1,v):i.slice(x,v)):(0===x&&m?(l.name=i.slice(1,y),l.base=i.slice(1,v)):(l.name=i.slice(x,y),l.base=i.slice(x,v)),l.ext=i.slice(y,v)),l.dir=this.dirname(i),l},sep:"/",delimiter:":",joinExtensions:[".html"]};function processX(i,l,p,m,_){const y=l[p];for(let x=0;x<y.length;x++){const v=y[x];p<l.length-1?processX(i.replace(m[p],v),l,p+1,m,_):_.push(i.replace(m[p],v))}}function createStringVariations(i){const l=i.match(/\{(.*?)\}/g),p=[];if(l){const m=[];l.forEach((i=>{const l=i.substring(1,i.length-1).split(",");m.push(l)})),processX(i,m,0,l,p)}else p.push(i);return p}const isSingleItem=i=>!Array.isArray(i);class Resolver{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(i,l)=>`${i}${this._bundleIdConnector}${l}`,extractAssetIdFromBundle:(i,l)=>l.replace(`${i}${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(i){if(this._bundleIdConnector=i.connector??this._bundleIdConnector,this._createBundleAssetId=i.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=i.extractAssetIdFromBundle??this._extractAssetIdFromBundle,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...i){i.forEach((i=>{this._preferredOrder.push(i),i.priority||(i.priority=Object.keys(i.params))})),this._resolverHash={}}set basePath(i){this._basePath=i}get basePath(){return this._basePath}set rootPath(i){this._rootPath=i}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(i){if("string"==typeof i)this._defaultSearchParams=i;else{const l=i;this._defaultSearchParams=Object.keys(l).map((i=>`${encodeURIComponent(i)}=${encodeURIComponent(l[i])}`)).join("&")}}getAlias(i){const{alias:l,src:p}=i,m=convertToList(l||p,(i=>"string"==typeof i?i:Array.isArray(i)?i.map((i=>i?.src??i)):i?.src?i.src:i),!0);return m}addManifest(i){this._manifest&&warn("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=i,i.bundles.forEach((i=>{this.addBundle(i.name,i.assets)}))}addBundle(i,l){const p=[];let m=l;Array.isArray(l)||(m=Object.entries(l).map((([i,l])=>"string"==typeof l||Array.isArray(l)?{alias:i,src:l}:{alias:i,...l}))),m.forEach((l=>{const m=l.src,_=l.alias;let y;if("string"==typeof _){const l=this._createBundleAssetId(i,_);p.push(l),y=[_,l]}else{const l=_.map((l=>this._createBundleAssetId(i,l)));p.push(...l),y=[..._,...l]}this.add({...l,alias:y,src:m})})),this._bundles[i]=p}add(i){const l=[];let p;Array.isArray(i)?l.push(...i):l.push(i),p=i=>{this.hasKey(i)&&warn(`[Resolver] already has key: ${i} overwriting`)};convertToList(l).forEach((i=>{const{src:l}=i;let{data:m,format:_,loadParser:y}=i;const x=convertToList(l).map((i=>"string"==typeof i?createStringVariations(i):Array.isArray(i)?i:[i])),v=this.getAlias(i);Array.isArray(v)?v.forEach(p):p(v);const T=[];x.forEach((i=>{i.forEach((i=>{let l={};if("object"!=typeof i){l.src=i;for(let p=0;p<this._parsers.length;p++){const m=this._parsers[p];if(m.test(i)){l=m.parse(i);break}}}else m=i.data??m,_=i.format??_,y=i.loadParser??y,l={...l,...i};if(!v)throw new Error(`[Resolver] alias is undefined for this asset: ${l.src}`);l=this._buildResolvedAsset(l,{aliases:v,data:m,format:_,loadParser:y}),T.push(l)}))})),v.forEach((i=>{this._assetMap[i]=T}))}))}resolveBundle(i){const l=isSingleItem(i);i=convertToList(i);const p={};return i.forEach((i=>{const l=this._bundles[i];if(l){const m=this.resolve(l),_={};for(const l in m){const p=m[l];_[this._extractAssetIdFromBundle(i,l)]=p}p[i]=_}})),l?p[i[0]]:p}resolveUrl(i){const l=this.resolve(i);if("string"!=typeof i){const i={};for(const p in l)i[p]=l[p].src;return i}return l.src}resolve(i){const l=isSingleItem(i);i=convertToList(i);const p={};return i.forEach((i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let l=this._assetMap[i];const p=this._getPreferredOrder(l);p?.priority.forEach((i=>{p.params[i].forEach((p=>{const m=l.filter((l=>!!l[i]&&l[i]===p));m.length&&(l=m)}))})),this._resolverHash[i]=l[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});p[i]=this._resolverHash[i]})),l?p[i[0]]:p}hasKey(i){return!!this._assetMap[i]}hasBundle(i){return!!this._bundles[i]}_getPreferredOrder(i){for(let l=0;l<i.length;l++){const l=i[0],p=this._preferredOrder.find((i=>i.params.format.includes(l.format)));if(p)return p}return this._preferredOrder[0]}_appendDefaultSearchParams(i){if(!this._defaultSearchParams)return i;return`${i}${/\?/.test(i)?"&":"?"}${this._defaultSearchParams}`}_buildResolvedAsset(i,l){const{aliases:p,data:m,loadParser:_,format:y}=l;return(this._basePath||this._rootPath)&&(i.src=oe.toAbsolute(i.src,this._basePath,this._rootPath)),i.alias=p??i.alias??[i.src],i.src=this._appendDefaultSearchParams(i.src),i.data={...m||{},...i.data},i.loadParser=_??i.loadParser,i.format=y??i.format??function getUrlExtension(i){return i.split(".").pop().split("?").shift().split("#").shift()}(i.src),i}}Resolver.RETINA_PREFIX=/@([0-9\.]+)x/;const copySearchParams=(i,l)=>{const p=l.split("?")[1];return p&&(i+=`?${p}`),i},ae=class _Spritesheet{constructor(i,l){this.linkedSheets=[],this._texture=i instanceof Texture?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=l;const p=parseFloat(l.meta.scale);p?(this.resolution=p,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise((i=>{this._callback=i,this._batchIndex=0,this._frameKeys.length<=_Spritesheet.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()}))}_processFrames(i){let l=i;const p=_Spritesheet.BATCH_SIZE;for(;l-i<p&&l<this._frameKeys.length;){const i=this._frameKeys[l],p=this._frames[i],m=p.frame;if(m){let l=null,_=null;const y=!1!==p.trimmed&&p.sourceSize?p.sourceSize:p.frame,x=new Rectangle(0,0,Math.floor(y.w)/this.resolution,Math.floor(y.h)/this.resolution);l=p.rotated?new Rectangle(Math.floor(m.x)/this.resolution,Math.floor(m.y)/this.resolution,Math.floor(m.h)/this.resolution,Math.floor(m.w)/this.resolution):new Rectangle(Math.floor(m.x)/this.resolution,Math.floor(m.y)/this.resolution,Math.floor(m.w)/this.resolution,Math.floor(m.h)/this.resolution),!1!==p.trimmed&&p.spriteSourceSize&&(_=new Rectangle(Math.floor(p.spriteSourceSize.x)/this.resolution,Math.floor(p.spriteSourceSize.y)/this.resolution,Math.floor(m.w)/this.resolution,Math.floor(m.h)/this.resolution)),this.textures[i]=new Texture({source:this.textureSource,frame:l,orig:x,trim:_,rotate:p.rotated?2:0,defaultAnchor:p.anchor,defaultBorders:p.borders,label:i.toString()})}l++}}_processAnimations(){const i=this.data.animations||{};for(const l in i){this.animations[l]=[];for(let p=0;p<i[l].length;p++){const m=i[l][p];this.animations[l].push(this.textures[m])}}}_parseComplete(){const i=this._callback;this._callback=null,this._batchIndex=0,i.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*_Spritesheet.BATCH_SIZE),this._batchIndex++,setTimeout((()=>{this._batchIndex*_Spritesheet.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())}),0)}destroy(i=!1){for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,i&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ae.BATCH_SIZE=1e3;let he=ae;const le=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function getCacheableAssets(i,l,p){const m={};if(i.forEach((i=>{m[i]=l})),Object.keys(l.textures).forEach((i=>{m[i]=l.textures[i]})),!p){const p=oe.dirname(i[0]);l.linkedSheets.forEach(((i,_)=>{const y=getCacheableAssets([`${p}/${l.data.meta.related_multi_packs[_]}`],i,!0);Object.assign(m,y)}))}return m}const de={extension:O.Asset,cache:{test:i=>i instanceof he,getCacheableAssets:(i,l)=>getCacheableAssets(i,l,!1)},resolver:{extension:{type:O.ResolveParser,name:"resolveSpritesheet"},test:i=>{const l=i.split("?")[0].split("."),p=l.pop(),m=l.pop();return"json"===p&&le.includes(m)},parse:i=>{const l=i.split(".");return{resolution:parseFloat(Resolver.RETINA_PREFIX.exec(i)?.[1]??"1"),format:l[l.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:O.LoadParser,priority:ne.Normal,name:"spritesheetLoader"},testParse:async(i,l)=>".json"===oe.extname(l.src).toLowerCase()&&!!i.frames,async parse(i,l,p){const{texture:m,imageFilename:_}=l?.data??{};let y,x=oe.dirname(l.src);if(x&&x.lastIndexOf("/")!==x.length-1&&(x+="/"),m instanceof Texture)y=m;else{const m=copySearchParams(x+(_??i.meta.image),l.src);y=(await p.load([m]))[m]}const v=new he(y.source,i);await v.parse();const T=i?.meta?.related_multi_packs;if(Array.isArray(T)){const i=[];for(const m of T){if("string"!=typeof m)continue;let _=x+m;l.data?.ignoreMultiPack||(_=copySearchParams(_,l.src),i.push(p.load({src:_,data:{ignoreMultiPack:!0}})))}const m=await Promise.all(i);v.linkedSheets=m,m.forEach((i=>{i.linkedSheets=[v].concat(v.linkedSheets.filter((l=>l!==i)))}))}return v},async unload(i,l,p){await p.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};z.add(de);class FederatedEvent{constructor(i){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=FederatedEvent.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Point,this.page=new Point,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=i}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(i,l,p){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(i,l,p,m,_){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var ue=/iPhone/i,ce=/iPod/i,pe=/iPad/i,fe=/\biOS-universal(?:.+)Mac\b/i,me=/\bAndroid(?:.+)Mobile\b/i,ge=/Android/i,_e=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,ye=/Silk/i,xe=/Windows Phone/i,ve=/\bWindows(?:.+)ARM\b/i,be=/BlackBerry/i,we=/BB10/i,Te=/Opera Mini/i,Se=/\b(CriOS|Chrome)(?:.+)Mobile/i,Pe=/Mobile(?:.+)Firefox\b/i,isAppleTabletOnIos13=function(i){return void 0!==i&&"MacIntel"===i.platform&&"number"==typeof i.maxTouchPoints&&i.maxTouchPoints>1&&"undefined"==typeof MSStream};function isMobile$1(i){var l={userAgent:"",platform:"",maxTouchPoints:0};i||"undefined"==typeof navigator?"string"==typeof i?l.userAgent=i:i&&i.userAgent&&(l={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0}):l={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var p=l.userAgent,m=p.split("[FBAN");void 0!==m[1]&&(p=m[0]),void 0!==(m=p.split("Twitter"))[1]&&(p=m[0]);var _=function createMatch(i){return function(l){return l.test(i)}}(p),y={apple:{phone:_(ue)&&!_(xe),ipod:_(ce),tablet:!_(ue)&&(_(pe)||isAppleTabletOnIos13(l))&&!_(xe),universal:_(fe),device:(_(ue)||_(ce)||_(pe)||_(fe)||isAppleTabletOnIos13(l))&&!_(xe)},amazon:{phone:_(_e),tablet:!_(_e)&&_(ye),device:_(_e)||_(ye)},android:{phone:!_(xe)&&_(_e)||!_(xe)&&_(me),tablet:!_(xe)&&!_(_e)&&!_(me)&&(_(ye)||_(ge)),device:!_(xe)&&(_(_e)||_(ye)||_(me)||_(ge))||_(/\bokhttp\b/i)},windows:{phone:_(xe),tablet:_(ve),device:_(xe)||_(ve)},other:{blackberry:_(be),blackberry10:_(we),opera:_(Te),firefox:_(Pe),chrome:_(Se),device:_(be)||_(we)||_(Te)||_(Pe)||_(Se)},any:!1,phone:!1,tablet:!1};return y.any=y.apple.device||y.android.device||y.windows.device||y.other.device,y.phone=y.apple.phone||y.android.phone||y.windows.phone,y.tablet=y.apple.tablet||y.android.tablet||y.windows.tablet,y}const Me=(isMobile$1.default??isMobile$1)(globalThis.navigator);class AccessibilitySystem{constructor(i,l=Me){this._mobileInfo=l,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(l.tablet||l.phone)&&this._createTouchHook();const p=document.createElement("div");p.style.width="100px",p.style.height="100px",p.style.position="absolute",p.style.top="0px",p.style.left="0px",p.style.zIndex=2..toString(),this._div=p,this._renderer=i,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const i=document.createElement("button");i.style.width="1px",i.style.height="1px",i.style.position="absolute",i.style.top="-1000px",i.style.left="-1000px",i.style.zIndex=2..toString(),i.style.backgroundColor="#FF0000",i.title="select to enable accessibility for this content",i.addEventListener("focus",(()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()})),document.body.appendChild(i),this._hookDiv=i}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),this._renderer.view.canvas.parentNode?.appendChild(this._div))}_deactivate(){this._isActive&&!this._isMobileAccessibility&&(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),this._div.parentNode?.removeChild(this._div))}_updateAccessibleObjects(i){if(!i.visible||!i.accessibleChildren)return;i.accessible&&i.isInteractive()&&(i._accessibleActive||this._addChild(i),i._renderId=this._renderId);const l=i.children;if(l)for(let i=0;i<l.length;i++)this._updateAccessibleObjects(l[i])}init(i){this.debug=i?.debug??this.debug,this._renderer.runners.postrender.remove(this)}postrender(){const i=performance.now();if(this._mobileInfo.android.device&&i<this._androidUpdateCount)return;if(this._androidUpdateCount=i+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas)return;this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered);const{x:l,y:p,width:m,height:_}=this._renderer.view.canvas.getBoundingClientRect(),{width:y,height:x,resolution:v}=this._renderer,T=m/y*v,S=_/x*v;let P=this._div;P.style.left=`${l}px`,P.style.top=`${p}px`,P.style.width=`${y}px`,P.style.height=`${x}px`;for(let i=0;i<this._children.length;i++){const l=this._children[i];if(l._renderId!==this._renderId)l._accessibleActive=!1,removeItems(this._children,i,1),this._div.removeChild(l._accessibleDiv),this._pool.push(l._accessibleDiv),l._accessibleDiv=null,i--;else{P=l._accessibleDiv;let i=l.hitArea;const p=l.worldTransform;l.hitArea?(P.style.left=(p.tx+i.x*p.a)*T+"px",P.style.top=(p.ty+i.y*p.d)*S+"px",P.style.width=i.width*p.a*T+"px",P.style.height=i.height*p.d*S+"px"):(i=l.getBounds().rectangle,this._capHitArea(i),P.style.left=i.x*T+"px",P.style.top=i.y*S+"px",P.style.width=i.width*T+"px",P.style.height=i.height*S+"px",P.title!==l.accessibleTitle&&null!==l.accessibleTitle&&(P.title=l.accessibleTitle||""),P.getAttribute("aria-label")!==l.accessibleHint&&null!==l.accessibleHint&&P.setAttribute("aria-label",l.accessibleHint||"")),l.accessibleTitle===P.title&&l.tabIndex===P.tabIndex||(P.title=l.accessibleTitle||"",P.tabIndex=l.tabIndex,this.debug&&this._updateDebugHTML(P))}}this._renderId++}_updateDebugHTML(i){i.innerHTML=`type: ${i.type}</br> title : ${i.title}</br> tabIndex: ${i.tabIndex}`}_capHitArea(i){i.x<0&&(i.width+=i.x,i.x=0),i.y<0&&(i.height+=i.y,i.y=0);const{width:l,height:p}=this._renderer;i.x+i.width>l&&(i.width=l-i.x),i.y+i.height>p&&(i.height=p-i.y)}_addChild(i){let l=this._pool.pop();l||(l=document.createElement("button"),l.style.width="100px",l.style.height="100px",l.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",l.style.position="absolute",l.style.zIndex=2..toString(),l.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?l.setAttribute("aria-live","off"):l.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?l.setAttribute("aria-relevant","additions"):l.setAttribute("aria-relevant","text"),l.addEventListener("click",this._onClick.bind(this)),l.addEventListener("focus",this._onFocus.bind(this)),l.addEventListener("focusout",this._onFocusOut.bind(this))),l.style.pointerEvents=i.accessiblePointerEvents,l.type=i.accessibleType,i.accessibleTitle&&null!==i.accessibleTitle?l.title=i.accessibleTitle:i.accessibleHint&&null!==i.accessibleHint||(l.title=`container ${i.tabIndex}`),i.accessibleHint&&null!==i.accessibleHint&&l.setAttribute("aria-label",i.accessibleHint),this.debug&&this._updateDebugHTML(l),i._accessibleActive=!0,i._accessibleDiv=l,l.container=i,this._children.push(i),this._div.appendChild(i._accessibleDiv),i._accessibleDiv.tabIndex=i.tabIndex}_dispatchEvent(i,l){const{container:p}=i.target,m=this._renderer.events.rootBoundary,_=Object.assign(new FederatedEvent(m),{target:p});m.rootTarget=this._renderer.lastObjectRendered,l.forEach((i=>m.dispatchEvent(_,i)))}_onClick(i){this._dispatchEvent(i,["click","pointertap","tap"])}_onFocus(i){i.target.getAttribute("aria-live")||i.target.setAttribute("aria-live","assertive"),this._dispatchEvent(i,["mouseover"])}_onFocusOut(i){i.target.getAttribute("aria-live")||i.target.setAttribute("aria-live","polite"),this._dispatchEvent(i,["mouseout"])}_onKeyDown(i){9===i.keyCode&&this._activate()}_onMouseMove(i){0===i.movementX&&0===i.movementY||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}AccessibilitySystem.extension={type:[O.WebGLSystem,O.WebGPUSystem],name:"accessibility"};const Ce=Object.create(null),Ee=Object.create(null);function createIdFromString(i,l){let p=Ee[i];return void 0===p&&(void 0===Ce[l]&&(Ce[l]=1),Ee[i]=p=Ce[l]++),p}let Ae,ke;function getTestContext(){if(!Ae||Ae?.isContextLost()){const i=qt.get().createCanvas();Ae=i.getContext("webgl",{})}return Ae}function getMaxFragmentPrecision(){if(!ke){ke="mediump";const i=getTestContext();if(i&&i.getShaderPrecisionFormat){const l=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT);ke=l.precision?"highp":"mediump"}}return ke}const Be={},Fe={};const Re={stripVersion:function stripVersion(i,l){return l?i.replace("#version 300 es",""):i},ensurePrecision:function ensurePrecision(i,l,p){const m=p?l.maxSupportedFragmentPrecision:l.maxSupportedVertexPrecision;if("precision"!==i.substring(0,9)){let _=p?l.requestedFragmentPrecision:l.requestedVertexPrecision;return"highp"===_&&"highp"!==m&&(_="mediump"),`precision ${_} float;\n${i}`}return"highp"!==m&&"precision highp"===i.substring(0,15)?i.replace("precision highp","precision mediump"):i},addProgramDefines:function addProgramDefines(i,l,p){return l?i:p?`\n \n #ifdef GL_ES // This checks if it is WebGL1\n #define in varying\n #define finalColor gl_FragColor\n #define texture texture2D\n #endif\n ${i=i.replace("out vec4 finalColor;","")}\n `:`\n \n #ifdef GL_ES // This checks if it is WebGL1\n #define in attribute\n #define out varying\n #endif\n ${i}\n `},setProgramName:function setProgramName(i,{name:l="pixi-program"},p=!0){l=l.replace(/\s+/g,"-");const m=p?Be:Fe;return m[l+=p?"-fragment":"-vertex"]?(m[l]++,l+=`-${m[l]}`):m[l]=1,-1!==i.indexOf("#define SHADER_NAME")?i:`${`#define SHADER_NAME ${l}`}\n${i}`},insertVersion:function insertVersion(i,l){return l?`#version 300 es\n${i}`:i}},Ie=Object.create(null),De=class _GlProgram{constructor(i){const l=-1!==(i={..._GlProgram.defaultOptions,...i}).fragment.indexOf("#version 300 es"),p={stripVersion:l,ensurePrecision:{requestedFragmentPrecision:i.preferredFragmentPrecision,requestedVertexPrecision:i.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:getMaxFragmentPrecision()},setProgramName:{name:i.name},addProgramDefines:l,insertVersion:l};let m=i.fragment,_=i.vertex;Object.keys(Re).forEach((i=>{const l=p[i];m=Re[i](m,l,!0),_=Re[i](_,l,!1)})),this.fragment=m,this.vertex=_,this._key=createIdFromString(`${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}static from(i){const l=`${i.vertex}:${i.fragment}`;return Ie[l]||(Ie[l]=new _GlProgram(i)),Ie[l]}};De.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Le=De;const Ue={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 getAttributeInfoFromFormat(i){return Ue[i]??Ue.float32}const Ge={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",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"};function extractStructAndGroups(i){const l=/@group\((\d+)\)/,p=/@binding\((\d+)\)/,m=/var(<[^>]+>)? (\w+)/,_=/:\s*(\w+)/,y=/(\w+)\s*:\s*([\w\<\>]+)/g,x=/struct\s+(\w+)/,v=i.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g)?.map((i=>({group:parseInt(i.match(l)[1],10),binding:parseInt(i.match(p)[1],10),name:i.match(m)[2],isUniform:"<uniform>"===i.match(m)[1],type:i.match(_)[1]})));if(!v)return{groups:[],structs:[]};const T=i.match(/struct\s+(\w+)\s*{([^}]+)}/g)?.map((i=>{const l=i.match(x)[1],p=i.match(y).reduce(((i,l)=>{const[p,m]=l.split(":");return i[p.trim()]=m.trim(),i}),{});return p?{name:l,members:p}:null})).filter((({name:i})=>v.some((l=>l.type===i))))??[];return{groups:v,structs:T}}var Oe=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Oe||{});const ze=Object.create(null);class GpuProgram{constructor(i){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:l,vertex:p,layout:m,gpuLayout:_,name:y}=i;if(this.name=y,this.fragment=l,this.vertex=p,l.source===p.source){const i=extractStructAndGroups(l.source);this.structsAndGroups=i}else{const i=extractStructAndGroups(p.source),m=extractStructAndGroups(l.source);this.structsAndGroups=function removeStructAndGroupDuplicates(i,l){const p=new Set,m=new Set;return{structs:[...i.structs,...l.structs].filter((i=>!p.has(i.name)&&(p.add(i.name),!0))),groups:[...i.groups,...l.groups].filter((i=>{const l=`${i.name}-${i.binding}`;return!m.has(l)&&(m.add(l),!0)}))}}(i,m)}this.layout=m??function generateLayoutHash({groups:i}){const l=[];for(let p=0;p<i.length;p++){const m=i[p];l[m.group]||(l[m.group]={}),l[m.group][m.name]=m.binding}return l}(this.structsAndGroups),this.gpuLayout=_??function generateGpuLayoutGroups({groups:i}){const l=[];for(let p=0;p<i.length;p++){const m=i[p];l[m.group]||(l[m.group]=[]),m.isUniform?l[m.group].push({binding:m.binding,visibility:Oe.VERTEX|Oe.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===m.type?l[m.group].push({binding:m.binding,visibility:Oe.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===m.type&&l[m.group].push({binding:m.binding,visibility:Oe.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return l}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===this.layout[0]?.globalUniforms),this.autoAssignLocalUniforms=!(void 0===this.layout[1]?.localUniforms),this._generateProgramKey()}_generateProgramKey(){const{vertex:i,fragment:l}=this,p=i.source+l.source+i.entryPoint+l.entryPoint;this._layoutKey=createIdFromString(p,"program")}get attributeData(){return this._attributeData??(this._attributeData=function extractAttributesFromGpuProgram({source:i,entryPoint:l}){const p={},m=i.indexOf(`fn ${l}`);if(-1!==m){const l=i.indexOf("->",m);if(-1!==l){const _=i.substring(m,l),y=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let x;for(;null!==(x=y.exec(_));){const i=Ge[x[3]]??"float32";p[x[2]]={location:parseInt(x[1],10),format:i,stride:getAttributeInfoFromFormat(i).stride,offset:0,instance:!1,start:0}}}}return p}(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(i){const l=`${i.vertex.source}:${i.fragment.source}:${i.fragment.entryPoint}:${i.vertex.entryPoint}`;return ze[l]||(ze[l]=new GpuProgram(i)),ze[l]}}const Ne=["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>"],He=Ne.reduce(((i,l)=>(i[l]=!0,i)),{});function getDefaultUniformValue(i,l){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*l);case"vec3<f32>":return new Float32Array(3*l);case"vec4<f32>":return new Float32Array(4*l);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const We=class _UniformGroup{constructor(i,l){this._touched=0,this.uid=uid("uniform"),this._resourceType="uniformGroup",this._resourceId=uid("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,l={..._UniformGroup.defaultOptions,...l},this.uniformStructures=i;const p={};for(const l in i){const m=i[l];if(m.name=l,m.size=m.size??1,!He[m.type])throw new Error(`Uniform type ${m.type} is not supported. Supported uniform types are: ${Ne.join(", ")}`);m.value??(m.value=getDefaultUniformValue(m.type,m.size)),p[l]=m.value}this.uniforms=p,this._dirtyId=1,this.ubo=l.ubo,this.isStatic=l.isStatic,this._signature=createIdFromString(Object.keys(p).map((l=>`${l}-${i[l].type}`)).join("-"),"uniform-group")}update(){this._dirtyId++}};We.defaultOptions={ubo:!1,isStatic:!1};let Ke=We;class BindGroup{constructor(i){this.resources=Object.create(null),this._dirty=!0;let l=0;for(const p in i){const m=i[p];this.setResource(m,l++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const i=[];let l=0;for(const p in this.resources)i[l++]=this.resources[p]._resourceId;this._key=i.join("|")}setResource(i,l){const p=this.resources[l];i!==p&&(p&&i.off?.("change",this.onResourceChange,this),i.on?.("change",this.onResourceChange,this),this.resources[l]=i,this._dirty=!0)}getResource(i){return this.resources[i]}_touch(i){const l=this.resources;for(const p in l)l[p]._touched=i}destroy(){const i=this.resources;for(const l in i){const p=i[l];p.off?.("change",this.onResourceChange,this)}this.resources=null}onResourceChange(i){if(this._dirty=!0,i.destroyed){const l=this.resources;for(const p in l)l[p]===i&&(l[p]=null)}else this._updateKey()}}var Ye=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(Ye||{});class Shader extends V{constructor(i){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:l,glProgram:p,groups:m,resources:_,compatibleRenderers:y,groupMap:x}=i;this.gpuProgram=l,this.glProgram=p,void 0===y&&(y=0,l&&(y|=Ye.WEBGPU),p&&(y|=Ye.WEBGL)),this.compatibleRenderers=y;const v={};if(_||m||(_={}),_&&m)throw new Error("[Shader] Cannot have both resources and groups");if(!l&&m&&!x)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!l&&m&&x)for(const i in x)for(const l in x[i]){const p=x[i][l];v[p]={group:i,binding:l,name:p}}else if(l&&m&&!x){const i=l.structsAndGroups.groups;x={},i.forEach((i=>{x[i.group]=x[i.group]||{},x[i.group][i.binding]=i.name,v[i.name]=i}))}else if(_){if(m={},x={},l){l.structsAndGroups.groups.forEach((i=>{x[i.group]=x[i.group]||{},x[i.group][i.binding]=i.name,v[i.name]=i}))}let i=0;for(const l in _)v[l]||(m[99]||(m[99]=new BindGroup,this._ownedBindGroups.push(m[99])),v[l]={group:99,binding:i,name:l},x[99]=x[99]||{},x[99][i]=l,i++);for(const i in _){const l=i;let p=_[i];p.source||p._resourceType||(p=new Ke(p));const y=v[l];y&&(m[y.group]||(m[y.group]=new BindGroup,this._ownedBindGroups.push(m[y.group])),m[y.group].setResource(p,y.binding))}}this.groups=m,this._uniformBindMap=x,this.resources=this._buildResourceAccessor(m,v)}addResource(i,l,p){var m,_;(m=this._uniformBindMap)[l]||(m[l]={}),(_=this._uniformBindMap[l])[p]||(_[p]=i),this.groups[l]||(this.groups[l]=new BindGroup,this._ownedBindGroups.push(this.groups[l]))}_buildResourceAccessor(i,l){const p={};for(const m in l){const _=l[m];Object.defineProperty(p,_.name,{get:()=>i[_.group].getResource(_.binding),set(l){i[_.group].setResource(l,_.binding)}})}return p}destroy(i=!1){this.emit("destroy",this),i&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach((i=>{i.destroy()})),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(i){const{gpu:l,gl:p,...m}=i;let _,y;return l&&(_=GpuProgram.from(l)),p&&(y=Le.from(p)),new Shader({gpuProgram:_,glProgram:y,...m})}}const Ve={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},$e=class _State{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(i){!!(1&this.data)!==i&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(i){!!(2&this.data)!==i&&(this.data^=2)}set cullMode(i){"none"!==i?(this.culling=!0,this.clockwiseFrontFace="front"===i):this.culling=!1}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(i){!!(4&this.data)!==i&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(i){!!(8&this.data)!==i&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(i){!!(32&this.data)!==i&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(i){!!(16&this.data)!==i&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(i){this.blend="none"!==i,this._blendMode=i,this._blendModeId=Ve[i]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(i){this.offsets=!!i,this._polygonOffset=i}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const i=new _State;return i.depthTest=!1,i.blend=!0,i}};$e.default2d=$e.for2d();let Xe=$e;var je={exports:{}};function earcut(i,l,p){p=p||2;var m,_,y,x,v,T,S,P=l&&l.length,C=P?l[0]*p:i.length,E=linkedList(i,0,C,p,!0),A=[];if(!E||E.next===E.prev)return A;if(P&&(E=function eliminateHoles(i,l,p,m){var _,y,x,v=[];for(_=0,y=l.length;_<y;_++)(x=linkedList(i,l[_]*m,_<y-1?l[_+1]*m:i.length,m,!1))===x.next&&(x.steiner=!0),v.push(getLeftmost(x));for(v.sort(compareX),_=0;_<v.length;_++)p=eliminateHole(v[_],p);return p}(i,l,E,p)),i.length>80*p){m=y=i[0],_=x=i[1];for(var k=p;k<C;k+=p)(v=i[k])<m&&(m=v),(T=i[k+1])<_&&(_=T),v>y&&(y=v),T>x&&(x=T);S=0!==(S=Math.max(y-m,x-_))?32767/S:0}return earcutLinked(E,A,p,m,_,S,0),A}function linkedList(i,l,p,m,_){var y,x;if(_===signedArea(i,l,p,m)>0)for(y=l;y<p;y+=m)x=insertNode(y,i[y],i[y+1],x);else for(y=p-m;y>=l;y-=m)x=insertNode(y,i[y],i[y+1],x);return x&&equals(x,x.next)&&(removeNode(x),x=x.next),x}function filterPoints(i,l){if(!i)return i;l||(l=i);var p,m=i;do{if(p=!1,m.steiner||!equals(m,m.next)&&0!==area(m.prev,m,m.next))m=m.next;else{if(removeNode(m),(m=l=m.prev)===m.next)break;p=!0}}while(p||m!==l);return l}function earcutLinked(i,l,p,m,_,y,x){if(i){!x&&y&&function indexCurve(i,l,p,m){var _=i;do{0===_.z&&(_.z=zOrder(_.x,_.y,l,p,m)),_.prevZ=_.prev,_.nextZ=_.next,_=_.next}while(_!==i);_.prevZ.nextZ=null,_.prevZ=null,function sortLinked(i){var l,p,m,_,y,x,v,T,S=1;do{for(p=i,i=null,y=null,x=0;p;){for(x++,m=p,v=0,l=0;l<S&&(v++,m=m.nextZ);l++);for(T=S;v>0||T>0&&m;)0!==v&&(0===T||!m||p.z<=m.z)?(_=p,p=p.nextZ,v--):(_=m,m=m.nextZ,T--),y?y.nextZ=_:i=_,_.prevZ=y,y=_;p=m}y.nextZ=null,S*=2}while(x>1);return i}(_)}(i,m,_,y);for(var v,T,S=i;i.prev!==i.next;)if(v=i.prev,T=i.next,y?isEarHashed(i,m,_,y):isEar(i))l.push(v.i/p|0),l.push(i.i/p|0),l.push(T.i/p|0),removeNode(i),i=T.next,S=T.next;else if((i=T)===S){x?1===x?earcutLinked(i=cureLocalIntersections(filterPoints(i),l,p),l,p,m,_,y,2):2===x&&splitEarcut(i,l,p,m,_,y):earcutLinked(filterPoints(i),l,p,m,_,y,1);break}}}function isEar(i){var l=i.prev,p=i,m=i.next;if(area(l,p,m)>=0)return!1;for(var _=l.x,y=p.x,x=m.x,v=l.y,T=p.y,S=m.y,P=_<y?_<x?_:x:y<x?y:x,C=v<T?v<S?v:S:T<S?T:S,E=_>y?_>x?_:x:y>x?y:x,A=v>T?v>S?v:S:T>S?T:S,k=m.next;k!==l;){if(k.x>=P&&k.x<=E&&k.y>=C&&k.y<=A&&pointInTriangle(_,v,y,T,x,S,k.x,k.y)&&area(k.prev,k,k.next)>=0)return!1;k=k.next}return!0}function isEarHashed(i,l,p,m){var _=i.prev,y=i,x=i.next;if(area(_,y,x)>=0)return!1;for(var v=_.x,T=y.x,S=x.x,P=_.y,C=y.y,E=x.y,A=v<T?v<S?v:S:T<S?T:S,k=P<C?P<E?P:E:C<E?C:E,B=v>T?v>S?v:S:T>S?T:S,F=P>C?P>E?P:E:C>E?C:E,R=zOrder(A,k,l,p,m),I=zOrder(B,F,l,p,m),D=i.prevZ,L=i.nextZ;D&&D.z>=R&&L&&L.z<=I;){if(D.x>=A&&D.x<=B&&D.y>=k&&D.y<=F&&D!==_&&D!==x&&pointInTriangle(v,P,T,C,S,E,D.x,D.y)&&area(D.prev,D,D.next)>=0)return!1;if(D=D.prevZ,L.x>=A&&L.x<=B&&L.y>=k&&L.y<=F&&L!==_&&L!==x&&pointInTriangle(v,P,T,C,S,E,L.x,L.y)&&area(L.prev,L,L.next)>=0)return!1;L=L.nextZ}for(;D&&D.z>=R;){if(D.x>=A&&D.x<=B&&D.y>=k&&D.y<=F&&D!==_&&D!==x&&pointInTriangle(v,P,T,C,S,E,D.x,D.y)&&area(D.prev,D,D.next)>=0)return!1;D=D.prevZ}for(;L&&L.z<=I;){if(L.x>=A&&L.x<=B&&L.y>=k&&L.y<=F&&L!==_&&L!==x&&pointInTriangle(v,P,T,C,S,E,L.x,L.y)&&area(L.prev,L,L.next)>=0)return!1;L=L.nextZ}return!0}function cureLocalIntersections(i,l,p){var m=i;do{var _=m.prev,y=m.next.next;!equals(_,y)&&intersects(_,m,m.next,y)&&locallyInside(_,y)&&locallyInside(y,_)&&(l.push(_.i/p|0),l.push(m.i/p|0),l.push(y.i/p|0),removeNode(m),removeNode(m.next),m=i=y),m=m.next}while(m!==i);return filterPoints(m)}function splitEarcut(i,l,p,m,_,y){var x=i;do{for(var v=x.next.next;v!==x.prev;){if(x.i!==v.i&&isValidDiagonal(x,v)){var T=splitPolygon(x,v);return x=filterPoints(x,x.next),T=filterPoints(T,T.next),earcutLinked(x,l,p,m,_,y,0),void earcutLinked(T,l,p,m,_,y,0)}v=v.next}x=x.next}while(x!==i)}function compareX(i,l){return i.x-l.x}function eliminateHole(i,l){var p=function findHoleBridge(i,l){var p,m=l,_=i.x,y=i.y,x=-1/0;do{if(y<=m.y&&y>=m.next.y&&m.next.y!==m.y){var v=m.x+(y-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(v<=_&&v>x&&(x=v,p=m.x<m.next.x?m:m.next,v===_))return p}m=m.next}while(m!==l);if(!p)return null;var T,S=p,P=p.x,C=p.y,E=1/0;m=p;do{_>=m.x&&m.x>=P&&_!==m.x&&pointInTriangle(y<C?_:x,y,P,C,y<C?x:_,y,m.x,m.y)&&(T=Math.abs(y-m.y)/(_-m.x),locallyInside(m,i)&&(T<E||T===E&&(m.x>p.x||m.x===p.x&§orContainsSector(p,m)))&&(p=m,E=T)),m=m.next}while(m!==S);return p}(i,l);if(!p)return l;var m=splitPolygon(p,i);return filterPoints(m,m.next),filterPoints(p,p.next)}function sectorContainsSector(i,l){return area(i.prev,i,l.prev)<0&&area(l.next,i,i.next)<0}function zOrder(i,l,p,m,_){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-p)*_|0)|i<<8))|i<<4))|i<<2))|i<<1))|(l=1431655765&((l=858993459&((l=252645135&((l=16711935&((l=(l-m)*_|0)|l<<8))|l<<4))|l<<2))|l<<1))<<1}function getLeftmost(i){var l=i,p=i;do{(l.x<p.x||l.x===p.x&&l.y<p.y)&&(p=l),l=l.next}while(l!==i);return p}function pointInTriangle(i,l,p,m,_,y,x,v){return(_-x)*(l-v)>=(i-x)*(y-v)&&(i-x)*(m-v)>=(p-x)*(l-v)&&(p-x)*(y-v)>=(_-x)*(m-v)}function isValidDiagonal(i,l){return i.next.i!==l.i&&i.prev.i!==l.i&&!function intersectsPolygon(i,l){var p=i;do{if(p.i!==i.i&&p.next.i!==i.i&&p.i!==l.i&&p.next.i!==l.i&&intersects(p,p.next,i,l))return!0;p=p.next}while(p!==i);return!1}(i,l)&&(locallyInside(i,l)&&locallyInside(l,i)&&function middleInside(i,l){var p=i,m=!1,_=(i.x+l.x)/2,y=(i.y+l.y)/2;do{p.y>y!=p.next.y>y&&p.next.y!==p.y&&_<(p.next.x-p.x)*(y-p.y)/(p.next.y-p.y)+p.x&&(m=!m),p=p.next}while(p!==i);return m}(i,l)&&(area(i.prev,i,l.prev)||area(i,l.prev,l))||equals(i,l)&&area(i.prev,i,i.next)>0&&area(l.prev,l,l.next)>0)}function area(i,l,p){return(l.y-i.y)*(p.x-l.x)-(l.x-i.x)*(p.y-l.y)}function equals(i,l){return i.x===l.x&&i.y===l.y}function intersects(i,l,p,m){var _=sign(area(i,l,p)),y=sign(area(i,l,m)),x=sign(area(p,m,i)),v=sign(area(p,m,l));return _!==y&&x!==v||(!(0!==_||!onSegment(i,p,l))||(!(0!==y||!onSegment(i,m,l))||(!(0!==x||!onSegment(p,i,m))||!(0!==v||!onSegment(p,l,m)))))}function onSegment(i,l,p){return l.x<=Math.max(i.x,p.x)&&l.x>=Math.min(i.x,p.x)&&l.y<=Math.max(i.y,p.y)&&l.y>=Math.min(i.y,p.y)}function sign(i){return i>0?1:i<0?-1:0}function locallyInside(i,l){return area(i.prev,i,i.next)<0?area(i,l,i.next)>=0&&area(i,i.prev,l)>=0:area(i,l,i.prev)<0||area(i,i.next,l)<0}function splitPolygon(i,l){var p=new Node(i.i,i.x,i.y),m=new Node(l.i,l.x,l.y),_=i.next,y=l.prev;return i.next=l,l.prev=i,p.next=_,_.prev=p,m.next=p,p.prev=m,y.next=m,m.prev=y,m}function insertNode(i,l,p,m){var _=new Node(i,l,p);return m?(_.next=m.next,_.prev=m,m.next.prev=_,m.next=_):(_.prev=_,_.next=_),_}function removeNode(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Node(i,l,p){this.i=i,this.x=l,this.y=p,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(i,l,p,m){for(var _=0,y=l,x=p-m;y<p;y+=m)_+=(i[x]-i[y])*(i[y+1]+i[x+1]),x=y;return _}je.exports=earcut,je.exports.default=earcut,earcut.deviation=function(i,l,p,m){var _=l&&l.length,y=_?l[0]*p:i.length,x=Math.abs(signedArea(i,0,y,p));if(_)for(var v=0,T=l.length;v<T;v++){var S=l[v]*p,P=v<T-1?l[v+1]*p:i.length;x-=Math.abs(signedArea(i,S,P,p))}var C=0;for(v=0;v<m.length;v+=3){var E=m[v]*p,A=m[v+1]*p,k=m[v+2]*p;C+=Math.abs((i[E]-i[k])*(i[A+1]-i[E+1])-(i[E]-i[A])*(i[k+1]-i[E+1]))}return 0===x&&0===C?0:Math.abs((C-x)/x)},earcut.flatten=function(i){for(var l=i[0][0].length,p={vertices:[],holes:[],dimensions:l},m=0,_=0;_<i.length;_++){for(var y=0;y<i[_].length;y++)for(var x=0;x<l;x++)p.vertices.push(i[_][y][x]);_>0&&(m+=i[_-1].length,p.holes.push(m))}return p};var qe=getDefaultExportFromCjs(je.exports);class ResizePlugin{static init(i){Object.defineProperty(this,"resizeTo",{set(i){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=i,i&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame((()=>this.resize())))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;let i,l;if(this._cancelResize(),this._resizeTo===globalThis.window)i=globalThis.innerWidth,l=globalThis.innerHeight;else{const{clientWidth:p,clientHeight:m}=this._resizeTo;i=p,l=m}this.renderer.resize(i,l),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=i.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}ResizePlugin.extension=O.Application;class TickerPlugin{static init(i){i=Object.assign({autoStart:!0,sharedTicker:!1},i),Object.defineProperty(this,"ticker",{set(i){this._ticker&&this._ticker.remove(this.render,this),this._ticker=i,i&&i.add(this.render,this,Zt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=i.sharedTicker?te.shared:new te,i.autoStart&&this.start()}static destroy(){if(this._ticker){const i=this._ticker;this.ticker=null,i.destroy()}}}TickerPlugin.extension=O.Application;class AbstractBitmapFont extends V{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 deprecation(ut,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return deprecation(ut,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return deprecation(ut,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return deprecation(ut,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return deprecation(ut,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(i=!1){this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)this.chars[i].texture?.destroy();this.chars=null,i&&(this.pages.forEach((i=>i.texture.destroy(!0))),this.pages=null)}}const Ze=class _FillGradient{constructor(i,l,p,m){this.uid=uid("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=i,this.y0=l,this.x1=p,this.y1=m}addColorStop(i,l){return this.gradientStops.push({offset:i,color:At.shared.setValue(l).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const i=_FillGradient.defaultTextureSize,{gradientStops:l}=this,p=qt.get().createCanvas();p.width=i,p.height=i;const m=p.getContext("2d"),_=m.createLinearGradient(0,0,_FillGradient.defaultTextureSize,1);for(let i=0;i<l.length;i++){const p=l[i];_.addColorStop(p.offset,p.color)}m.fillStyle=_,m.fillRect(0,0,i,i),this.texture=new Texture({source:new ImageSource({resource:p,addressModeU:"clamp-to-edge",addressModeV:"repeat"})});const{x0:y,y0:x,x1:v,y1:T}=this,S=new Matrix,P=v-y,C=T-x,E=Math.sqrt(P*P+C*C),A=Math.atan2(C,P);S.translate(-y,-x),S.scale(1/i,1/i),S.rotate(-A),S.scale(256/E,1),this.transform=S,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;const i=this.gradientStops.map((i=>`${i.offset}-${i.color}`)).join("-"),l=this.texture.uid,p=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${i}-${l}-${p}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Ze.defaultTextureSize=256;let Qe=Ze;const Je={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class FillPattern{constructor(i,l){this.uid=uid("fillPattern"),this.transform=new Matrix,this._styleKey=null,this.texture=i,this.transform.scale(1/i.frame.width,1/i.frame.height),l&&(i.source.style.addressModeU=Je[l].addressModeU,i.source.style.addressModeV=Je[l].addressModeV)}setTransform(i){const l=this.texture;this.transform.copyFrom(i),this.transform.invert(),this.transform.scale(1/l.frame.width,1/l.frame.height),this._styleKey=null}get styleKey(){return this._styleKey||(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`),this._styleKey}}var ti=function parse(i){var l=[];return i.replace(ii,(function(i,p,m){var _=p.toLowerCase();for(m=function parseValues(i){var l=i.match(si);return l?l.map(Number):[]}(m),"m"==_&&m.length>2&&(l.push([p].concat(m.splice(0,2))),_="l",p="m"==p?"l":"L");;){if(m.length==ei[_])return m.unshift(p),l.push(m);if(m.length<ei[_])throw new Error("malformed path data");l.push([p].concat(m.splice(0,ei[_])))}})),l},ei={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},ii=/([astvzqmhlc])([^astvzqmhlc]*)/gi;var si=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;var ri=getDefaultExportFromCjs(ti);class Circle{constructor(i=0,l=0,p=0){this.type="circle",this.x=i,this.y=l,this.radius=p}clone(){return new Circle(this.x,this.y,this.radius)}contains(i,l){if(this.radius<=0)return!1;const p=this.radius*this.radius;let m=this.x-i,_=this.y-l;return m*=m,_*=_,m+_<=p}strokeContains(i,l,p){if(0===this.radius)return!1;const m=this.x-i,_=this.y-l,y=this.radius,x=p/2,v=Math.sqrt(m*m+_*_);return v<y+x&&v>y-x}getBounds(i){return(i=i||new Rectangle).x=this.x-this.radius,i.y=this.y-this.radius,i.width=2*this.radius,i.height=2*this.radius,i}copyFrom(i){return this.x=i.x,this.y=i.y,this.radius=i.radius,this}copyTo(i){return i.copyFrom(this),i}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Ellipse{constructor(i=0,l=0,p=0,m=0){this.type="ellipse",this.x=i,this.y=l,this.halfWidth=p,this.halfHeight=m}clone(){return new Ellipse(this.x,this.y,this.halfWidth,this.halfHeight)}contains(i,l){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let p=(i-this.x)/this.halfWidth,m=(l-this.y)/this.halfHeight;return p*=p,m*=m,p+m<=1}strokeContains(i,l,p){const{halfWidth:m,halfHeight:_}=this;if(m<=0||_<=0)return!1;const y=p/2,x=m-y,v=_-y,T=m+y,S=_+y,P=i-this.x,C=l-this.y;return P*P/(x*x)+C*C/(v*v)>1&&P*P/(T*T)+C*C/(S*S)<=1}getBounds(i){return(i=i||new Rectangle).x=this.x-this.halfWidth,i.y=this.y-this.halfHeight,i.width=2*this.halfWidth,i.height=2*this.halfHeight,i}copyFrom(i){return this.x=i.x,this.y=i.y,this.halfWidth=i.halfWidth,this.halfHeight=i.halfHeight,this}copyTo(i){return i.copyFrom(this),i}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function squaredDistanceToLineSegment(i,l,p,m,_,y){const x=_-p,v=y-m,T=x*x+v*v;let S,P,C=-1;0!==T&&(C=((i-p)*x+(l-m)*v)/T),C<0?(S=p,P=m):C>1?(S=_,P=y):(S=p+C*x,P=m+C*v);const E=i-S,A=l-P;return E*E+A*A}class Polygon{constructor(...i){this.type="polygon";let l=Array.isArray(i[0])?i[0]:i;if("number"!=typeof l[0]){const i=[];for(let p=0,m=l.length;p<m;p++)i.push(l[p].x,l[p].y);l=i}this.points=l,this.closePath=!0}clone(){const i=this.points.slice(),l=new Polygon(i);return l.closePath=this.closePath,l}contains(i,l){let p=!1;const m=this.points.length/2;for(let _=0,y=m-1;_<m;y=_++){const m=this.points[2*_],x=this.points[2*_+1],v=this.points[2*y],T=this.points[2*y+1];x>l!=T>l&&i<(l-x)/(T-x)*(v-m)+m&&(p=!p)}return p}strokeContains(i,l,p){const m=p/2,_=m*m,{points:y}=this,x=y.length-(this.closePath?0:2);for(let p=0;p<x;p+=2){if(squaredDistanceToLineSegment(i,l,y[p],y[p+1],y[(p+2)%y.length],y[(p+3)%y.length])<=_)return!0}return!1}getBounds(i){i=i||new Rectangle;const l=this.points;let p=1/0,m=-1/0,_=1/0,y=-1/0;for(let i=0,x=l.length;i<x;i+=2){const x=l[i],v=l[i+1];p=x<p?x:p,m=x>m?x:m,_=v<_?v:_,y=v>y?v:y}return i.x=p,i.width=m-p,i.y=_,i.height=y-_,i}copyFrom(i){return this.points=i.points.slice(),this.closePath=i.closePath,this}copyTo(i){return i.copyFrom(this),i}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce(((i,l)=>`${i}, ${l}`),"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const isCornerWithinStroke=(i,l,p,m,_,y)=>{const x=i-p,v=l-m,T=Math.sqrt(x*x+v*v);return T>=_-y&&T<=_+y};class RoundedRectangle{constructor(i=0,l=0,p=0,m=0,_=20){this.type="roundedRectangle",this.x=i,this.y=l,this.width=p,this.height=m,this.radius=_}getBounds(i){return(i=i||new Rectangle).x=this.x,i.y=this.y,i.width=this.width,i.height=this.height,i}clone(){return new RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)}copyFrom(i){return this.x=i.x,this.y=i.y,this.width=i.width,this.height=i.height,this}copyTo(i){return i.copyFrom(this),i}contains(i,l){if(this.width<=0||this.height<=0)return!1;if(i>=this.x&&i<=this.x+this.width&&l>=this.y&&l<=this.y+this.height){const p=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(l>=this.y+p&&l<=this.y+this.height-p||i>=this.x+p&&i<=this.x+this.width-p)return!0;let m=i-(this.x+p),_=l-(this.y+p);const y=p*p;if(m*m+_*_<=y)return!0;if(m=i-(this.x+this.width-p),m*m+_*_<=y)return!0;if(_=l-(this.y+this.height-p),m*m+_*_<=y)return!0;if(m=i-(this.x+p),m*m+_*_<=y)return!0}return!1}strokeContains(i,l,p){const{x:m,y:_,width:y,height:x,radius:v}=this,T=p/2,S=m+v,P=_+v,C=m+y,E=_+x;return(i>=m-T&&i<=m+T||i>=C-T&&i<=C+T)&&l>=P&&l<=P+(x-2*v)||((l>=_-T&&l<=_+T||l>=E-T&&l<=E+T)&&i>=S&&i<=S+(y-2*v)||(i<S&&l<P&&isCornerWithinStroke(i,l,S,P,v,T)||i>C-v&&l<P&&isCornerWithinStroke(i,l,C-v,P,v,T)||i>C-v&&l>E-v&&isCornerWithinStroke(i,l,C-v,E-v,v,T)||i<S&&l>E-v&&isCornerWithinStroke(i,l,S,E-v,v,T)))}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const ni=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");function generateIfTestSrc(i){let l="";for(let p=0;p<i;++p)p>0&&(l+="\nelse "),p<i-1&&(l+=`if(test == ${p}.0){}`);return l}let oi=null;function getMaxTexturesPerBatch(){if(oi)return oi;const i=getTestContext();return oi=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),oi=function checkMaxIfStatementsInShader(i,l){if(0===i)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const p=l.createShader(l.FRAGMENT_SHADER);try{for(;;){const m=ni.replace(/%forloop%/gi,generateIfTestSrc(i));if(l.shaderSource(p,m),l.compileShader(p),l.getShaderParameter(p,l.COMPILE_STATUS))break;i=i/2|0}}finally{l.deleteShader(p)}return i}(oi,i),i.getExtension("WEBGL_lose_context")?.loseContext(),oi}const ai={};function getTextureBatchBindGroup(i,l){let p=2166136261;for(let m=0;m<l;m++)p^=i[m].uid,p=Math.imul(p,16777619),p>>>=0;return ai[p]||function generateTextureBatchBindGroup(i,l,p){const m={};let _=0;hi||(hi=getMaxTexturesPerBatch());for(let p=0;p<hi;p++){const y=p<l?i[p]:Texture.EMPTY.source;m[_++]=y.source,m[_++]=y.style}const y=new BindGroup(m);return ai[p]=y,y}(i,l,p)}let hi=0;class ViewableBuffer{constructor(i){"number"==typeof i?this.rawBinaryData=new ArrayBuffer(i):i instanceof Uint8Array?this.rawBinaryData=i.buffer:this.rawBinaryData=i,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(i){return this[`${i}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(i){switch(i){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${i} isn't a valid view type`)}}}function fastCopy(i,l){const p=i.byteLength/8|0,m=new Float64Array(i,0,p);new Float64Array(l,0,p).set(m);const _=i.byteLength-8*p;if(_>0){const m=new Uint8Array(i,8*p,_);new Uint8Array(l,8*p,_).set(m)}}const li={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};function getAdjustedBlendModeBlend(i,l){return"no-premultiply-alpha"===l.alphaMode&&li[i]||i}class BatchTextureArray{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let i=0;i<this.count;i++){const l=this.textures[i];this.textures[i]=null,this.ids[l.uid]=null}this.count=0}}class Batch{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new BatchTextureArray,this.blendMode="normal",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const di=[];let ui=0;function getBatchFromPool(){return ui>0?di[--ui]:new Batch}function returnBatchToPool(i){di[ui++]=i}let ci=0;const pi=class _Batcher{constructor(i={}){this.uid=uid("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],_Batcher.defaultOptions.maxTextures=_Batcher.defaultOptions.maxTextures??getMaxTexturesPerBatch(),i={..._Batcher.defaultOptions,...i};const{maxTextures:l,attributesInitialSize:p,indicesInitialSize:m}=i;this.attributeBuffer=new ViewableBuffer(4*p),this.indexBuffer=new Uint16Array(m),this.maxTextures=l}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let i=0;i<this.batchIndex;i++)returnBatchToPool(this.batches[i]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(i){this._elements[this.elementSize++]=i,i._indexStart=this.indexSize,i._attributeStart=this.attributeSize,i._batcher=this,this.indexSize+=i.indexSize,this.attributeSize+=i.attributeSize*this.vertexSize}checkAndUpdateTexture(i,l){const p=i._batch.textures.ids[l._source.uid];return!(!p&&0!==p)&&(i._textureId=p,i.texture=l,!0)}updateElement(i){this.dirty=!0;const l=this.attributeBuffer;i.packAsQuad?this.packQuadAttributes(i,l.float32View,l.uint32View,i._attributeStart,i._textureId):this.packAttributes(i,l.float32View,l.uint32View,i._attributeStart,i._textureId)}break(i){const l=this._elements;if(!l[this.elementStart])return;let p=getBatchFromPool(),m=p.textures;m.clear();const _=l[this.elementStart];let y=getAdjustedBlendModeBlend(_.blendMode,_.texture._source);4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const x=this.attributeBuffer.float32View,v=this.attributeBuffer.uint32View,T=this.indexBuffer;let S=this._batchIndexSize,P=this._batchIndexStart,C="startBatch";const E=this.maxTextures;for(let _=this.elementStart;_<this.elementSize;++_){const A=l[_];l[_]=null;const k=A.texture._source,B=getAdjustedBlendModeBlend(A.blendMode,k),F=y!==B;k._batchTick!==ci||F?(k._batchTick=ci,(m.count>=E||F)&&(this._finishBatch(p,P,S-P,m,y,i,C),C="renderBatch",P=S,y=B,p=getBatchFromPool(),m=p.textures,m.clear(),++ci),A._textureId=k._textureBindLocation=m.count,m.ids[k.uid]=m.count,m.textures[m.count++]=k,A._batch=p,S+=A.indexSize,A.packAsQuad?(this.packQuadAttributes(A,x,v,A._attributeStart,A._textureId),this.packQuadIndex(T,A._indexStart,A._attributeStart/this.vertexSize)):(this.packAttributes(A,x,v,A._attributeStart,A._textureId),this.packIndex(A,T,A._indexStart,A._attributeStart/this.vertexSize))):(A._textureId=k._textureBindLocation,S+=A.indexSize,A.packAsQuad?(this.packQuadAttributes(A,x,v,A._attributeStart,A._textureId),this.packQuadIndex(T,A._indexStart,A._attributeStart/this.vertexSize)):(this.packAttributes(A,x,v,A._attributeStart,A._textureId),this.packIndex(A,T,A._indexStart,A._attributeStart/this.vertexSize)),A._batch=p)}m.count>0&&(this._finishBatch(p,P,S-P,m,y,i,C),P=S,++ci),this.elementStart=this.elementSize,this._batchIndexStart=P,this._batchIndexSize=S}_finishBatch(i,l,p,m,_,y,x){i.gpuBindGroup=null,i.bindGroup=null,i.action=x,i.batcher=this,i.textures=m,i.blendMode=_,i.start=l,i.size=p,++ci,this.batches[this.batchIndex++]=i,y.add(i)}finish(i){this.break(i)}ensureAttributeBuffer(i){4*i<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*i)}ensureIndexBuffer(i){i<=this.indexBuffer.length||this._resizeIndexBuffer(i)}_resizeAttributeBuffer(i){const l=Math.max(i,2*this.attributeBuffer.size),p=new ViewableBuffer(l);fastCopy(this.attributeBuffer.rawBinaryData,p.rawBinaryData),this.attributeBuffer=p}_resizeIndexBuffer(i){const l=this.indexBuffer;let p=Math.max(i,1.5*l.length);p+=p%2;const m=p>65535?new Uint32Array(p):new Uint16Array(p);if(m.BYTES_PER_ELEMENT!==l.BYTES_PER_ELEMENT)for(let i=0;i<l.length;i++)m[i]=l[i];else fastCopy(l.buffer,m.buffer);this.indexBuffer=m}packQuadIndex(i,l,p){i[l]=p+0,i[l+1]=p+1,i[l+2]=p+2,i[l+3]=p+0,i[l+4]=p+2,i[l+5]=p+3}packIndex(i,l,p,m){const _=i.indices,y=i.indexSize,x=i.indexOffset,v=i.attributeOffset;for(let i=0;i<y;i++)l[p++]=m+_[i+x]-v}destroy(){for(let i=0;i<this.batches.length;i++)returnBatchToPool(this.batches[i]);this.batches=null;for(let i=0;i<this._elements.length;i++)this._elements[i]._batch=null;this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}};pi.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let fi=pi;var mi=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(mi||{});class Buffer extends V{constructor(i){let{data:l,size:p}=i;const{usage:m,label:_,shrinkToFit:y}=i;super(),this.uid=uid("buffer"),this._resourceType="buffer",this._resourceId=uid("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,l instanceof Array&&(l=new Float32Array(l)),this._data=l,p=p??l?.byteLength;const x=!!l;this.descriptor={size:p,usage:m,mappedAtCreation:x,label:_},this.shrinkToFit=y??!0}get data(){return this._data}set data(i){this.setDataWithSize(i,i.length,!0)}get static(){return!!(this.descriptor.usage&mi.STATIC)}set static(i){i?this.descriptor.usage|=mi.STATIC:this.descriptor.usage&=~mi.STATIC}setDataWithSize(i,l,p){if(this._updateID++,this._updateSize=l*i.BYTES_PER_ELEMENT,this._data===i)return void(p&&this.emit("update",this));const m=this._data;this._data=i,m.length===i.length||!this.shrinkToFit&&i.byteLength<m.byteLength?p&&this.emit("update",this):(this.descriptor.size=i.byteLength,this._resourceId=uid("resource"),this.emit("change",this))}update(i){this._updateSize=i??this._updateSize,this._updateID++,this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function ensureIsBuffer(i,l){if(!(i instanceof Buffer)){let p=l?mi.INDEX:mi.VERTEX;i instanceof Array&&(l?(i=new Uint32Array(i),p=mi.INDEX|mi.COPY_DST):(i=new Float32Array(i),p=mi.VERTEX|mi.COPY_DST)),i=new Buffer({data:i,label:l?"index-mesh-buffer":"vertex-mesh-buffer",usage:p})}return i}function ensureIsAttribute(i){return(i instanceof Buffer||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=ensureIsBuffer(i.buffer,!1),i}class Geometry extends V{constructor(i){const{attributes:l,indexBuffer:p,topology:m}=i;super(),this.uid=uid("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Bounds,this._boundsDirty=!0,this.attributes=l,this.buffers=[],this.instanceCount=i.instanceCount||1;for(const i in l){const p=l[i]=ensureIsAttribute(l[i]);-1===this.buffers.indexOf(p.buffer)&&(this.buffers.push(p.buffer),p.buffer.on("update",this.onBufferUpdate,this),p.buffer.on("change",this.onBufferUpdate,this))}p&&(this.indexBuffer=ensureIsBuffer(p,!0),this.buffers.push(this.indexBuffer)),this.topology=m||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(i){return this.attributes[i]}getIndex(){return this.indexBuffer}getBuffer(i){return this.getAttribute(i).buffer}getSize(){for(const i in this.attributes){const l=this.attributes[i];return l.buffer.data.length/(l.stride/4||l.size)}return 0}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function getGeometryBounds(i,l,p){const m=i.getAttribute(l);if(!m)return p.minX=0,p.minY=0,p.maxX=0,p.maxY=0,p;const _=m.buffer.data;let y=1/0,x=1/0,v=-1/0,T=-1/0;const S=_.BYTES_PER_ELEMENT,P=(m.offset||0)/S,C=(m.stride||8)/S;for(let i=P;i<_.length;i+=C){const l=_[i],p=_[i+1];l>v&&(v=l),p>T&&(T=p),l<y&&(y=l),p<x&&(x=p)}return p.minX=y,p.minY=x,p.maxX=v,p.maxY=T,p}(this,"aPosition",this._bounds)):this._bounds}destroy(i=!1){this.emit("destroy",this),this.removeAllListeners(),i&&this.buffers.forEach((i=>i.destroy())),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const gi=new Float32Array(1),_i=new Uint32Array(1);class BatchGeometry extends Geometry{constructor(){const i=new Buffer({data:gi,label:"attribute-batch-buffer",usage:mi.VERTEX|mi.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:i,format:"float32x2",stride:24,offset:0},aUV:{buffer:i,format:"float32x2",stride:24,offset:8},aColor:{buffer:i,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:i,format:"uint16x2",stride:24,offset:20}},indexBuffer:new Buffer({data:_i,label:"index-batch-buffer",usage:mi.INDEX|mi.COPY_DST,shrinkToFit:!1})})}}function addBits(i,l,p){if(i)for(const m in i){const _=l[m.toLocaleLowerCase()];if(_){let l=i[m];"header"===m&&(l=l.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),p&&_.push(`//----${p}----//`),_.push(l)}else warn(`${m} placement hook does not exist in shader`)}}const yi=/\{\{(.*?)\}\}/g;function compileHooks(i){const l={};return(i.match(yi)?.map((i=>i.replace(/[{()}]/g,"")))??[]).forEach((i=>{l[i]=[]})),l}function extractInputs(i,l){let p;const m=/@in\s+([^;]+);/g;for(;null!==(p=m.exec(i));)l.push(p[1])}function compileInputs(i,l,p=!1){const m=[];extractInputs(l,m),i.forEach((i=>{i.header&&extractInputs(i.header,m)}));const _=m;p&&_.sort();const y=_.map(((i,l)=>` @location(${l}) ${i},`)).join("\n");let x=l.replace(/@in\s+[^;]+;\s*/g,"");return x=x.replace("{{in}}",`\n${y}\n`),x}function extractOutputs(i,l){let p;const m=/@out\s+([^;]+);/g;for(;null!==(p=m.exec(i));)l.push(p[1])}function injectBits(i,l){let p=i;for(const i in l){const m=l[i];p=m.join("\n").length?p.replace(`{{${i}}}`,`//-----${i} START-----//\n${m.join("\n")}\n//----${i} FINISH----//`):p.replace(`{{${i}}}`,"")}return p}const xi=Object.create(null),vi=new Map;let bi=0;function compileHighShader({template:i,bits:l}){const p=generateCacheId(i,l);if(xi[p])return xi[p];const{vertex:m,fragment:_}=function compileInputsAndOutputs(i,l){const p=l.map((i=>i.vertex)).filter((i=>!!i)),m=l.map((i=>i.fragment)).filter((i=>!!i));let _=compileInputs(p,i.vertex,!0);_=function compileOutputs(i,l){const p=[];extractOutputs(l,p),i.forEach((i=>{i.header&&extractOutputs(i.header,p)}));let m=0;const _=p.sort().map((i=>i.indexOf("builtin")>-1?i:`@location(${m++}) ${i}`)).join(",\n"),y=p.sort().map((i=>` var ${function stripVariable(i){return i.replace(/@.*?\s+/g,"")}(i)};`)).join("\n"),x=`return VSOutput(\n ${p.sort().map((i=>` ${function extractVariableName(i){const l=/\b(\w+)\s*:/g.exec(i);return l?l[1]:""}(i)}`)).join(",\n")});`;let v=l.replace(/@out\s+[^;]+;\s*/g,"");return v=v.replace("{{struct}}",`\n${_}\n`),v=v.replace("{{start}}",`\n${y}\n`),v=v.replace("{{return}}",`\n${x}\n`),v}(p,_);const y=compileInputs(m,i.fragment,!0);return{vertex:_,fragment:y}}(i,l);return xi[p]=compileBits(m,_,l),xi[p]}function compileHighShaderGl({template:i,bits:l}){const p=generateCacheId(i,l);return xi[p]||(xi[p]=compileBits(i.vertex,i.fragment,l)),xi[p]}function generateCacheId(i,l){return l.map((i=>(vi.has(i)||vi.set(i,bi++),vi.get(i)))).sort(((i,l)=>i-l)).join("-")+i.vertex+i.fragment}function compileBits(i,l,p){const m=compileHooks(i),_=compileHooks(l);return p.forEach((i=>{addBits(i.vertex,m,i.name),addBits(i.fragment,_,i.name)})),{vertex:injectBits(i,m),fragment:injectBits(l,_)}}const wi={name:"global-uniforms-bit",vertex:{header:"\n struct GlobalUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uWorldTransformMatrix:mat3x3<f32>,\n uWorldColorAlpha: vec4<f32>,\n uResolution: vec2<f32>,\n }\n\n @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;\n "}},Ti={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}};function compileHighShaderGpuProgram({bits:i,name:l}){const p=compileHighShader({template:{fragment:"\n @in vUV : vec2<f32>;\n @in vColor : vec4<f32>;\n \n {{header}}\n\n @fragment\n fn main(\n {{in}}\n ) -> @location(0) vec4<f32> {\n \n {{start}}\n\n var outColor:vec4<f32>;\n \n {{main}}\n \n var finalColor:vec4<f32> = outColor * vColor;\n\n {{end}}\n\n return finalColor;\n };\n",vertex:"\n @in aPosition: vec2<f32>;\n @in aUV: vec2<f32>;\n\n @out @builtin(position) vPosition: vec4<f32>;\n @out vUV : vec2<f32>;\n @out vColor : vec4<f32>;\n\n {{header}}\n\n struct VSOutput {\n {{struct}}\n };\n\n @vertex\n fn main( {{in}} ) -> VSOutput {\n\n var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;\n var modelMatrix = mat3x3<f32>(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n var position = aPosition;\n var uv = aUV;\n\n {{start}}\n \n vColor = vec4<f32>(1., 1., 1., 1.);\n\n {{main}}\n\n vUV = uv;\n\n var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);\n \n vColor *= globalUniforms.uWorldColorAlpha;\n\n {{end}}\n\n {{return}}\n };\n"},bits:[wi,...i]});return GpuProgram.from({name:l,vertex:{source:p.vertex,entryPoint:"main"},fragment:{source:p.fragment,entryPoint:"main"}})}function compileHighShaderGlProgram({bits:i,name:l}){return new Le({name:l,...compileHighShaderGl({template:{vertex:"\n in vec2 aPosition;\n in vec2 aUV;\n\n out vec4 vColor;\n out vec2 vUV;\n\n {{header}}\n\n void main(void){\n\n mat3 worldTransformMatrix = uWorldTransformMatrix;\n mat3 modelMatrix = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n vec2 position = aPosition;\n vec2 uv = aUV;\n \n {{start}}\n \n vColor = vec4(1.);\n \n {{main}}\n \n vUV = uv;\n \n mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= uWorldColorAlpha;\n\n {{end}}\n }\n",fragment:"\n \n in vec4 vColor;\n in vec2 vUV;\n\n out vec4 finalColor;\n\n {{header}}\n\n void main(void) {\n \n {{start}}\n\n vec4 outColor;\n \n {{main}}\n \n finalColor = outColor * vColor;\n \n {{end}}\n }\n"},bits:[Ti,...i]})})}const Si={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},Pi={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},Mi={};function generateBindingSrc(i){const l=[];if(1===i)l.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),l.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let p=0;for(let m=0;m<i;m++)l.push(`@group(1) @binding(${p++}) var textureSource${m+1}: texture_2d<f32>;`),l.push(`@group(1) @binding(${p++}) var textureSampler${m+1}: sampler;`)}return l.join("\n")}function generateSampleSrc(i){const l=[];if(1===i)l.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{l.push("switch vTextureId {");for(let p=0;p<i;p++)p===i-1?l.push(" default:{"):l.push(` case ${p}:{`),l.push(` outColor = textureSampleGrad(textureSource${p+1}, textureSampler${p+1}, vUV, uvDx, uvDy);`),l.push(" break;}");l.push("}")}return l.join("\n")}function generateTextureBatchBit(i){return Mi[i]||(Mi[i]={name:"texture-batch-bit",vertex:{header:"\n @in aTextureIdAndRound: vec2<u32>;\n @out @interpolate(flat) vTextureId : u32;\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1)\n {\n vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:`\n @in @interpolate(flat) vTextureId: u32;\n\n ${generateBindingSrc(i)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${generateSampleSrc(i)}\n `}}),Mi[i]}const Ci={};function generateSampleGlSrc(i){const l=[];for(let p=0;p<i;p++)p>0&&l.push("else"),p<i-1&&l.push(`if(vTextureId < ${p}.5)`),l.push("{"),l.push(`\toutColor = texture(uTextures[${p}], vUV);`),l.push("}");return l.join("\n")}function generateTextureBatchBitGl(i){return Ci[i]||(Ci[i]={name:"texture-batch-bit",vertex:{header:"\n in vec2 aTextureIdAndRound;\n out float vTextureId;\n\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:`\n in float vTextureId;\n\n uniform sampler2D uTextures[${i}];\n\n `,main:`\n\n ${generateSampleGlSrc(i)}\n `}}),Ci[i]}const Ei={name:"round-pixels-bit",vertex:{header:"\n fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32> \n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},Ai={name:"round-pixels-bit",vertex:{header:" \n vec2 roundPixels(vec2 position, vec2 targetSize)\n { \n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},ki={};function getBatchSamplersUniformGroup(i){let l=ki[i];if(l)return l;const p=new Int32Array(i);for(let l=0;l<i;l++)p[l]=l;return l=ki[i]=new Ke({uTextures:{value:p,type:"i32",size:i}},{isStatic:!0}),l}class DefaultShader extends Shader{constructor(i){super({glProgram:compileHighShaderGlProgram({name:"batch",bits:[Pi,generateTextureBatchBitGl(i),Ai]}),gpuProgram:compileHighShaderGpuProgram({name:"batch",bits:[Si,generateTextureBatchBit(i),Ei]}),resources:{batchSamplers:getBatchSamplersUniformGroup(i)}})}}let Bi=null;const Fi=class _DefaultBatcher extends fi{constructor(){super(...arguments),this.geometry=new BatchGeometry,this.shader=Bi||(Bi=new DefaultShader(this.maxTextures)),this.name=_DefaultBatcher.extension.name,this.vertexSize=6}packAttributes(i,l,p,m,_){const y=_<<16|65535&i.roundPixels,x=i.transform,v=x.a,T=x.b,S=x.c,P=x.d,C=x.tx,E=x.ty,{positions:A,uvs:k}=i,B=i.color,F=i.attributeOffset,R=F+i.attributeSize;for(let i=F;i<R;i++){const _=2*i,x=A[_],F=A[_+1];l[m++]=v*x+S*F+C,l[m++]=P*F+T*x+E,l[m++]=k[_],l[m++]=k[_+1],p[m++]=B,p[m++]=y}}packQuadAttributes(i,l,p,m,_){const y=i.texture,x=i.transform,v=x.a,T=x.b,S=x.c,P=x.d,C=x.tx,E=x.ty,A=i.bounds,k=A.maxX,B=A.minX,F=A.maxY,R=A.minY,I=y.uvs,D=i.color,L=_<<16|65535&i.roundPixels;l[m+0]=v*B+S*R+C,l[m+1]=P*R+T*B+E,l[m+2]=I.x0,l[m+3]=I.y0,p[m+4]=D,p[m+5]=L,l[m+6]=v*k+S*R+C,l[m+7]=P*R+T*k+E,l[m+8]=I.x1,l[m+9]=I.y1,p[m+10]=D,p[m+11]=L,l[m+12]=v*k+S*F+C,l[m+13]=P*F+T*k+E,l[m+14]=I.x2,l[m+15]=I.y2,p[m+16]=D,p[m+17]=L,l[m+18]=v*B+S*F+C,l[m+19]=P*F+T*B+E,l[m+20]=I.x3,l[m+21]=I.y3,p[m+22]=D,p[m+23]=L}};Fi.extension={type:[O.Batcher],name:"default"};let Ri=Fi;function transformVertices(i,l,p,m,_){const y=l.a,x=l.b,v=l.c,T=l.d,S=l.tx,P=l.ty;p=p||0,m=m||2,_=_||i.length/m-p;let C=p*m;for(let l=0;l<_;l++){const l=i[C],p=i[C+1];i[C]=y*l+v*p+S,i[C+1]=x*l+T*p+P,C+=m}}const Ii=new Matrix;class BatchableGraphics{constructor(){this.packAsQuad=!1,this.batcherName="default",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.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const i=this.baseColor,l=i>>16|65280&i|(255&i)<<16,p=this.renderable;return p?function multiplyHexColors(i,l){return 16777215!==i&&l?16777215!==l&&i?((i>>16&255)*(l>>16&255)/255<<16)+((i>>8&255)*(l>>8&255)/255<<8)+(255&i)*(255&l)/255:i:l}(l,p.groupColor)+(this.alpha*p.groupAlpha*255<<24):l+(255*this.alpha<<24)}get transform(){return this.renderable?.groupTransform||Ii}copyTo(i){i.indexOffset=this.indexOffset,i.indexSize=this.indexSize,i.attributeOffset=this.attributeOffset,i.attributeSize=this.attributeSize,i.baseColor=this.baseColor,i.alpha=this.alpha,i.texture=this.texture,i.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const Di={extension:{type:O.ShapeBuilder,name:"circle"},build(i,l){let p,m,_,y,x,v;if("circle"===i.type){const l=i;p=l.x,m=l.y,x=v=l.radius,_=y=0}else if("ellipse"===i.type){const l=i;p=l.x,m=l.y,x=l.halfWidth,v=l.halfHeight,_=y=0}else{const l=i,T=l.width/2,S=l.height/2;p=l.x+T,m=l.y+S,x=v=Math.max(0,Math.min(l.radius,Math.min(T,S))),_=T-x,y=S-v}if(!(x>=0&&v>=0&&_>=0&&y>=0))return l;const T=Math.ceil(2.3*Math.sqrt(x+v)),S=8*T+(_?4:0)+(y?4:0);if(0===S)return l;if(0===T)return l[0]=l[6]=p+_,l[1]=l[3]=m+y,l[2]=l[4]=p-_,l[5]=l[7]=m-y,l;let P=0,C=4*T+(_?2:0)+2,E=C,A=S,k=_+x,B=y,F=p+k,R=p-k,I=m+B;if(l[P++]=F,l[P++]=I,l[--C]=I,l[--C]=R,y){const i=m-B;l[E++]=R,l[E++]=i,l[--A]=i,l[--A]=F}for(let i=1;i<T;i++){const S=Math.PI/2*(i/T),k=_+Math.cos(S)*x,B=y+Math.sin(S)*v,F=p+k,R=p-k,I=m+B,D=m-B;l[P++]=F,l[P++]=I,l[--C]=I,l[--C]=R,l[E++]=R,l[E++]=D,l[--A]=D,l[--A]=F}k=_,B=y+v,F=p+k,R=p-k,I=m+B;const D=m-B;return l[P++]=F,l[P++]=I,l[--A]=D,l[--A]=F,_&&(l[P++]=R,l[P++]=I,l[--A]=D,l[--A]=R),l},triangulate(i,l,p,m,_,y){if(0===i.length)return;let x=0,v=0;for(let l=0;l<i.length;l+=2)x+=i[l],v+=i[l+1];x/=i.length/2,v/=i.length/2;let T=m;l[T*p]=x,l[T*p+1]=v;const S=T++;for(let m=0;m<i.length;m+=2)l[T*p]=i[m],l[T*p+1]=i[m+1],m>0&&(_[y++]=T,_[y++]=S,_[y++]=T-1),T++;_[y++]=S+1,_[y++]=S,_[y++]=T-1}},Li={...Di,extension:{...Di.extension,name:"ellipse"}},Ui={...Di,extension:{...Di.extension,name:"roundedRectangle"}},Gi=1e-4,Oi=1e-4;function square(i,l,p,m,_,y,x,v){let T,S;x?(T=m,S=-p):(T=-m,S=p);const P=i-p*_+T,C=l-m*_+S,E=i+p*y+T,A=l+m*y+S;return v.push(P,C),v.push(E,A),2}function round(i,l,p,m,_,y,x,v){const T=p-i,S=m-l;let P=Math.atan2(T,S),C=Math.atan2(_-i,y-l);v&&P<C?P+=2*Math.PI:!v&&P>C&&(C+=2*Math.PI);let E=P;const A=C-P,k=Math.abs(A),B=Math.sqrt(T*T+S*S),F=1+(15*k*Math.sqrt(B)/Math.PI|0),R=A/F;if(E+=R,v){x.push(i,l),x.push(p,m);for(let p=1,m=E;p<F;p++,m+=R)x.push(i,l),x.push(i+Math.sin(m)*B,l+Math.cos(m)*B);x.push(i,l),x.push(_,y)}else{x.push(p,m),x.push(i,l);for(let p=1,m=E;p<F;p++,m+=R)x.push(i+Math.sin(m)*B,l+Math.cos(m)*B),x.push(i,l);x.push(_,y),x.push(i,l)}return 2*F}function triangulateWithHoles(i,l,p,m,_,y,x){const v=qe(i,l,2);if(!v)return;for(let i=0;i<v.length;i+=3)y[x++]=v[i]+_,y[x++]=v[i+1]+_,y[x++]=v[i+2]+_;let T=_*m;for(let l=0;l<i.length;l+=2)p[T]=i[l],p[T+1]=i[l+1],T+=m}const zi=[],Ni={extension:{type:O.ShapeBuilder,name:"polygon"},build(i,l){for(let p=0;p<i.points.length;p++)l[p]=i.points[p];return l},triangulate(i,l,p,m,_,y){triangulateWithHoles(i,zi,l,p,m,_,y)}},Hi={extension:{type:O.ShapeBuilder,name:"rectangle"},build(i,l){const p=i,m=p.x,_=p.y,y=p.width,x=p.height;return y>=0&&x>=0?(l[0]=m,l[1]=_,l[2]=m+y,l[3]=_,l[4]=m+y,l[5]=_+x,l[6]=m,l[7]=_+x,l):l},triangulate(i,l,p,m,_,y){let x=0;l[(m*=p)+x]=i[0],l[m+x+1]=i[1],x+=p,l[m+x]=i[2],l[m+x+1]=i[3],x+=p,l[m+x]=i[6],l[m+x+1]=i[7],x+=p,l[m+x]=i[4],l[m+x+1]=i[5],x+=p;const v=m/p;_[y++]=v,_[y++]=v+1,_[y++]=v+2,_[y++]=v+1,_[y++]=v+3,_[y++]=v+2}},Wi={extension:{type:O.ShapeBuilder,name:"triangle"},build:(i,l)=>(l[0]=i.x,l[1]=i.y,l[2]=i.x2,l[3]=i.y2,l[4]=i.x3,l[5]=i.y3,l),triangulate(i,l,p,m,_,y){let x=0;l[(m*=p)+x]=i[0],l[m+x+1]=i[1],x+=p,l[m+x]=i[2],l[m+x+1]=i[3],x+=p,l[m+x]=i[4],l[m+x+1]=i[5];const v=m/p;_[y++]=v,_[y++]=v+1,_[y++]=v+2}},Ki={};z.handleByMap(O.ShapeBuilder,Ki),z.add(Hi,Ni,Wi,Di,Li,Ui);const Yi=new Rectangle;function addTextureToGeometryData(i,l,p){const{vertices:m,uvs:_,indices:y}=p,x=y.length,v=m.length/2,T=[],S=Ki.rectangle,P=Yi,C=i.image;P.x=i.dx,P.y=i.dy,P.width=i.dw,P.height=i.dh;const E=i.transform;S.build(P,T),E&&transformVertices(T,E),S.triangulate(T,m,2,v,y,x);const A=C.uvs;_.push(A.x0,A.y0,A.x1,A.y1,A.x3,A.y3,A.x2,A.y2);const k=kt.get(BatchableGraphics);k.indexOffset=x,k.indexSize=y.length-x,k.attributeOffset=v,k.attributeSize=m.length/2-v,k.baseColor=i.style,k.alpha=i.alpha,k.texture=C,k.geometryData=p,l.push(k)}function addShapePathToGeometryData(i,l,p,m,_,y){const{vertices:x,uvs:v,indices:T}=y,S=i.shapePrimitives.length-1;i.shapePrimitives.forEach((({shape:i,transform:P},C)=>{const E=T.length,A=x.length/2,k=[],B=Ki[i.type];if(B.build(i,k),P&&transformVertices(k,P),m){const p=i.closePath??!0;!function buildLine(i,l,p,m,_,y,x,v,T){const S=Gi;if(0===i.length)return;const P=l;let C=P.alignment;if(.5!==l.alignment){let l=function getOrientationOfPoints(i){const l=i.length;if(l<6)return 1;let p=0;for(let m=0,_=i[l-2],y=i[l-1];m<l;m+=2){const l=i[m],x=i[m+1];p+=(l-_)*(x+y),_=l,y=x}return p<0?-1:1}(i);C=(C-.5)*l+.5}const E=new Point(i[0],i[1]),A=new Point(i[i.length-2],i[i.length-1]),k=m,B=Math.abs(E.x-A.x)<S&&Math.abs(E.y-A.y)<S;if(k){i=i.slice(),B&&(i.pop(),i.pop(),A.set(i[i.length-2],i[i.length-1]));const l=.5*(E.x+A.x),p=.5*(A.y+E.y);i.unshift(l,p),i.push(l,p)}const F=_,R=i.length/2;let I=i.length;const D=F.length/2,L=P.width/2,U=L*L,G=P.miterLimit*P.miterLimit;let O=i[0],z=i[1],W=i[2],K=i[3],Y=0,V=0,X=-(z-K),j=O-W,q=0,Z=0,Q=Math.sqrt(X*X+j*j);X/=Q,j/=Q,X*=L,j*=L;const J=2*(1-C),tt=2*C;k||("round"===P.cap?I+=round(O-X*(J-tt)*.5,z-j*(J-tt)*.5,O-X*J,z-j*J,O+X*tt,z+j*tt,F,!0)+2:"square"===P.cap&&(I+=square(O,z,X,j,J,tt,!0,F))),F.push(O-X*J,z-j*J),F.push(O+X*tt,z+j*tt);for(let l=1;l<R-1;++l){O=i[2*(l-1)],z=i[2*(l-1)+1],W=i[2*l],K=i[2*l+1],Y=i[2*(l+1)],V=i[2*(l+1)+1],X=-(z-K),j=O-W,Q=Math.sqrt(X*X+j*j),X/=Q,j/=Q,X*=L,j*=L,q=-(K-V),Z=W-Y,Q=Math.sqrt(q*q+Z*Z),q/=Q,Z/=Q,q*=L,Z*=L;const p=W-O,m=z-K,_=W-Y,y=V-K,x=p*_+m*y,v=m*_-y*p,T=v<0;if(Math.abs(v)<.001*Math.abs(x)){F.push(W-X*J,K-j*J),F.push(W+X*tt,K+j*tt),x>=0&&("round"===P.join?I+=round(W,K,W-X*J,K-j*J,W-q*J,K-Z*J,F,!1)+4:I+=2,F.push(W-q*tt,K-Z*tt),F.push(W+q*J,K+Z*J));continue}const S=(-X+O)*(-j+K)-(-X+W)*(-j+z),C=(-q+Y)*(-Z+K)-(-q+W)*(-Z+V),E=(p*C-_*S)/v,A=(y*S-m*C)/v,k=(E-W)*(E-W)+(A-K)*(A-K),B=W+(E-W)*J,R=K+(A-K)*J,D=W-(E-W)*tt,et=K-(A-K)*tt,it=T?J:tt;k<=Math.min(p*p+m*m,_*_+y*y)+it*it*U?"bevel"===P.join||k/U>G?(T?(F.push(B,R),F.push(W+X*tt,K+j*tt),F.push(B,R),F.push(W+q*tt,K+Z*tt)):(F.push(W-X*J,K-j*J),F.push(D,et),F.push(W-q*J,K-Z*J),F.push(D,et)),I+=2):"round"===P.join?T?(F.push(B,R),F.push(W+X*tt,K+j*tt),I+=round(W,K,W+X*tt,K+j*tt,W+q*tt,K+Z*tt,F,!0)+4,F.push(B,R),F.push(W+q*tt,K+Z*tt)):(F.push(W-X*J,K-j*J),F.push(D,et),I+=round(W,K,W-X*J,K-j*J,W-q*J,K-Z*J,F,!1)+4,F.push(W-q*J,K-Z*J),F.push(D,et)):(F.push(B,R),F.push(D,et)):(F.push(W-X*J,K-j*J),F.push(W+X*tt,K+j*tt),"round"===P.join?I+=T?round(W,K,W+X*tt,K+j*tt,W+q*tt,K+Z*tt,F,!0)+2:round(W,K,W-X*J,K-j*J,W-q*J,K-Z*J,F,!1)+2:"miter"===P.join&&k/U<=G&&(T?(F.push(D,et),F.push(D,et)):(F.push(B,R),F.push(B,R)),I+=2),F.push(W-q*J,K-Z*J),F.push(W+q*tt,K+Z*tt),I+=2)}O=i[2*(R-2)],z=i[2*(R-2)+1],W=i[2*(R-1)],K=i[2*(R-1)+1],X=-(z-K),j=O-W,Q=Math.sqrt(X*X+j*j),X/=Q,j/=Q,X*=L,j*=L,F.push(W-X*J,K-j*J),F.push(W+X*tt,K+j*tt),k||("round"===P.cap?I+=round(W-X*(J-tt)*.5,K-j*(J-tt)*.5,W-X*J,K-j*J,W+X*tt,K+j*tt,F,!1)+2:"square"===P.cap&&(I+=square(W,K,X,j,J,tt,!1,F)));const et=Oi*Oi;for(let i=D;i<I+D-2;++i)O=F[2*i],z=F[2*i+1],W=F[2*(i+1)],K=F[2*(i+1)+1],Y=F[2*(i+2)],V=F[2*(i+2)+1],Math.abs(O*(K-V)+W*(V-z)+Y*(z-K))<et||v.push(i,i+1,i+2)}(k,l,0,p,x,0,0,T)}else if(p&&S===C){0!==S&&console.warn("[Pixi Graphics] only the last shape have be cut out");const i=[],l=k.slice(),m=function getHoleArrays(i){if(!i)return[];const l=i.shapePrimitives,p=[];for(let i=0;i<l.length;i++){const m=l[i].shape,_=[];Ki[m.type].build(m,_),p.push(_)}return p}(p.shapePath);m.forEach((p=>{i.push(l.length/2),l.push(...p)})),triangulateWithHoles(l,i,x,2,A,T,E)}else B.triangulate(k,x,2,A,T,E);const F=v.length/2,R=l.texture;if(R!==Texture.WHITE){const i=l.matrix;i&&(P&&i.append(P.clone().invert()),function buildUvs(i,l,p,m,_,y,x,v=null){let T=0;p*=l,_*=y;const S=v.a,P=v.b,C=v.c,E=v.d,A=v.tx,k=v.ty;for(;T<x;){const x=i[p],v=i[p+1];m[_]=S*x+C*v+A,m[_+1]=P*x+E*v+k,_+=y,p+=l,T++}}(x,2,A,v,F,2,x.length/2-A,i))}else!function buildSimpleUvs(i,l,p,m){let _=0;for(l*=p;_<m;)i[l]=0,i[l+1]=0,l+=p,_++}(v,F,2,x.length/2-A);const I=kt.get(BatchableGraphics);I.indexOffset=E,I.indexSize=T.length-E,I.attributeOffset=A,I.attributeSize=x.length/2-A,I.baseColor=l.color,I.alpha=l.alpha,I.texture=R,I.geometryData=y,_.push(I)}))}class GpuGraphicsContext{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class GraphicsContextRenderData{constructor(){this.batcher=new Ri,this.instructions=new InstructionSet}init(){this.instructions.reset()}get geometry(){return deprecation("8.3.4","GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}}const Vi=class _GraphicsContextSystem{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(i){_GraphicsContextSystem.defaultOptions.bezierSmoothness=i?.bezierSmoothness??_GraphicsContextSystem.defaultOptions.bezierSmoothness}getContextRenderData(i){return this._graphicsDataContextHash[i.uid]||this._initContextRenderData(i)}updateGpuContext(i){let l=this._gpuContextHash[i.uid]||this._initContext(i);if(i.dirty){l?this._cleanGraphicsContextData(i):l=this._initContext(i),function buildContextBatches(i,l){const{geometryData:p,batches:m}=l;m.length=0,p.indices.length=0,p.vertices.length=0,p.uvs.length=0;for(let l=0;l<i.instructions.length;l++){const _=i.instructions[l];if("texture"===_.action)addTextureToGeometryData(_.data,m,p);else if("fill"===_.action||"stroke"===_.action){const i="stroke"===_.action,l=_.data.path.shapePath,y=_.data.style,x=_.data.hole;i&&x&&addShapePathToGeometryData(x.shapePath,y,null,!0,m,p),addShapePathToGeometryData(l,y,x,i,m,p)}}}(i,l);const p=i.batchMode;i.customShader||"no-batch"===p?l.isBatchable=!1:"auto"===p&&(l.isBatchable=l.geometryData.vertices.length<400),i.dirty=!1}return l}getGpuContext(i){return this._gpuContextHash[i.uid]||this._initContext(i)}_initContextRenderData(i){const l=kt.get(GraphicsContextRenderData),{batches:p,geometryData:m}=this._gpuContextHash[i.uid],_=m.vertices.length,y=m.indices.length;for(let i=0;i<p.length;i++)p[i].applyTransform=!1;const x=l.batcher;x.ensureAttributeBuffer(_),x.ensureIndexBuffer(y),x.begin();for(let i=0;i<p.length;i++){const l=p[i];x.add(l)}x.finish(l.instructions);const v=x.geometry;v.indexBuffer.setDataWithSize(x.indexBuffer,x.indexSize,!0),v.buffers[0].setDataWithSize(x.attributeBuffer.float32View,x.attributeSize,!0);const T=x.batches;for(let i=0;i<T.length;i++){const l=T[i];l.bindGroup=getTextureBatchBindGroup(l.textures.textures,l.textures.count)}return this._graphicsDataContextHash[i.uid]=l,l}_initContext(i){const l=new GpuGraphicsContext;return l.context=i,this._gpuContextHash[i.uid]=l,i.on("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[i.uid]}onGraphicsContextDestroy(i){this._cleanGraphicsContextData(i),i.off("destroy",this.onGraphicsContextDestroy,this),this._gpuContextHash[i.uid]=null}_cleanGraphicsContextData(i){const l=this._gpuContextHash[i.uid];l.isBatchable||this._graphicsDataContextHash[i.uid]&&(kt.return(this.getContextRenderData(i)),this._graphicsDataContextHash[i.uid]=null),l.batches&&l.batches.forEach((i=>{kt.return(i)}))}destroy(){for(const i in this._gpuContextHash)this._gpuContextHash[i]&&this.onGraphicsContextDestroy(this._gpuContextHash[i].context)}};Vi.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"graphicsContext"},Vi.defaultOptions={bezierSmoothness:.5};let $i=Vi;const Xi=8,ji=1.1920929e-7,qi=1;function buildAdaptiveBezier(i,l,p,m,_,y,x,v,T,S){const P=Math.min(.99,Math.max(0,S??$i.defaultOptions.bezierSmoothness));let C=(qi-P)/1;return C*=C,function begin$1(i,l,p,m,_,y,x,v,T,S){recursive$1(i,l,p,m,_,y,x,v,T,S,0),T.push(x,v)}(l,p,m,_,y,x,v,T,i,C),i}function recursive$1(i,l,p,m,_,y,x,v,T,S,P){if(P>Xi)return;const C=(i+p)/2,E=(l+m)/2,A=(p+_)/2,k=(m+y)/2,B=(_+x)/2,F=(y+v)/2,R=(C+A)/2,I=(E+k)/2,D=(A+B)/2,L=(k+F)/2,U=(R+D)/2,G=(I+L)/2;if(P>0){let P=x-i,C=v-l;const E=Math.abs((p-x)*C-(m-v)*P),A=Math.abs((_-x)*C-(y-v)*P);if(E>ji&&A>ji){if((E+A)*(E+A)<=S*(P*P+C*C))return void T.push(U,G)}else if(E>ji){if(E*E<=S*(P*P+C*C))return void T.push(U,G)}else if(A>ji){if(A*A<=S*(P*P+C*C))return void T.push(U,G)}else if(P=U-(i+x)/2,C=G-(l+v)/2,P*P+C*C<=S)return void T.push(U,G)}recursive$1(i,l,C,E,R,I,U,G,T,S,P+1),recursive$1(U,G,D,L,B,F,x,v,T,S,P+1)}const Zi=8,Qi=1.1920929e-7;function buildAdaptiveQuadratic(i,l,p,m,_,y,x,v){let T=(1-Math.min(.99,Math.max(0,v??$i.defaultOptions.bezierSmoothness)))/1;return T*=T,function begin(i,l,p,m,_,y,x,v){recursive(x,i,l,p,m,_,y,v,0),x.push(_,y)}(l,p,m,_,y,x,i,T),i}function recursive(i,l,p,m,_,y,x,v,T){if(T>Zi)return;const S=(l+m)/2,P=(p+_)/2,C=(m+y)/2,E=(_+x)/2,A=(S+C)/2,k=(P+E)/2;let B=y-l,F=x-p;const R=Math.abs((m-y)*F-(_-x)*B);if(R>Qi){if(R*R<=v*(B*B+F*F))return void i.push(A,k)}else if(B=A-(l+y)/2,F=k-(p+x)/2,B*B+F*F<=v)return void i.push(A,k);recursive(i,l,p,S,P,A,k,v,T+1),recursive(i,A,k,C,E,y,x,v,T+1)}function buildArc(i,l,p,m,_,y,x,v){let T=Math.abs(_-y);(!x&&_>y||x&&y>_)&&(T=2*Math.PI-T),v=v||Math.max(6,Math.floor(6*Math.pow(m,1/3)*(T/Math.PI)));let S=T/(v=Math.max(v,3)),P=_;S*=x?-1:1;for(let _=0;_<v+1;_++){const _=l+Math.cos(P)*m,y=p+Math.sin(P)*m;i.push(_,y),P+=S}}const Ji=2*Math.PI,ts={centerX:0,centerY:0,ang1:0,ang2:0},mapToEllipse=({x:i,y:l},p,m,_,y,x,v,T)=>{const S=_*(i*=p)-y*(l*=m),P=y*i+_*l;return T.x=S+x,T.y=P+v,T};function approxUnitArc(i,l){const p=-1.5707963267948966===l?-.551915024494:4/3*Math.tan(l/4),m=1.5707963267948966===l?.551915024494:p,_=Math.cos(i),y=Math.sin(i),x=Math.cos(i+l),v=Math.sin(i+l);return[{x:_-y*m,y:y+_*m},{x:x+v*m,y:v-x*m},{x:x,y:v}]}const vectorAngle=(i,l,p,m)=>{let _=i*p+l*m;return _>1&&(_=1),_<-1&&(_=-1),(i*m-l*p<0?-1:1)*Math.acos(_)};function buildArcToSvg(i,l,p,m,_,y,x,v=0,T=0,S=0){if(0===y||0===x)return;const P=Math.sin(v*Ji/360),C=Math.cos(v*Ji/360),E=C*(l-m)/2+P*(p-_)/2,A=-P*(l-m)/2+C*(p-_)/2;if(0===E&&0===A)return;y=Math.abs(y),x=Math.abs(x);const k=Math.pow(E,2)/Math.pow(y,2)+Math.pow(A,2)/Math.pow(x,2);k>1&&(y*=Math.sqrt(k),x*=Math.sqrt(k)),((i,l,p,m,_,y,x,v,T,S,P,C,E)=>{const A=Math.pow(_,2),k=Math.pow(y,2),B=Math.pow(P,2),F=Math.pow(C,2);let R=A*k-A*F-k*B;R<0&&(R=0),R/=A*F+k*B,R=Math.sqrt(R)*(x===v?-1:1);const I=R*_/y*C,D=R*-y/_*P,L=S*I-T*D+(i+p)/2,U=T*I+S*D+(l+m)/2,G=(P-I)/_,O=(C-D)/y,z=(-P-I)/_,W=(-C-D)/y,K=vectorAngle(1,0,G,O);let Y=vectorAngle(G,O,z,W);0===v&&Y>0&&(Y-=Ji),1===v&&Y<0&&(Y+=Ji),E.centerX=L,E.centerY=U,E.ang1=K,E.ang2=Y})(l,p,m,_,y,x,T,S,P,C,E,A,ts);let{ang1:B,ang2:F}=ts;const{centerX:R,centerY:I}=ts;let D=Math.abs(F)/(Ji/4);Math.abs(1-D)<1e-7&&(D=1);const L=Math.max(Math.ceil(D),1);F/=L;let U=i[i.length-2],G=i[i.length-1];const O={x:0,y:0};for(let l=0;l<L;l++){const l=approxUnitArc(B,F),{x:p,y:m}=mapToEllipse(l[0],y,x,C,P,R,I,O),{x:_,y:v}=mapToEllipse(l[1],y,x,C,P,R,I,O),{x:T,y:S}=mapToEllipse(l[2],y,x,C,P,R,I,O);buildAdaptiveBezier(i,U,G,p,m,_,v,T,S),U=T,G=S,B+=F}}const es=new Rectangle;class ShapePath{constructor(i){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Bounds,this._graphicsPath2D=i}moveTo(i,l){return this.startPoly(i,l),this}lineTo(i,l){this._ensurePoly();const p=this._currentPoly.points,m=p[p.length-2],_=p[p.length-1];return m===i&&_===l||p.push(i,l),this}arc(i,l,p,m,_,y){this._ensurePoly(!1);return buildArc(this._currentPoly.points,i,l,p,m,_,y),this}arcTo(i,l,p,m,_){this._ensurePoly();return function buildArcTo(i,l,p,m,_,y){const x=i[i.length-2],v=i[i.length-1]-p,T=x-l,S=_-p,P=m-l,C=Math.abs(v*P-T*S);if(C<1e-8||0===y)return void(i[i.length-2]===l&&i[i.length-1]===p||i.push(l,p));const E=v*v+T*T,A=S*S+P*P,k=v*S+T*P,B=y*Math.sqrt(E)/C,F=y*Math.sqrt(A)/C,R=B*k/E,I=F*k/A,D=B*P+F*T,L=B*S+F*v,U=T*(F+R),G=v*(F+R),O=P*(B+I),z=S*(B+I);buildArc(i,D+l,L+p,y,Math.atan2(G-L,U-D),Math.atan2(z-L,O-D),T*S>P*v)}(this._currentPoly.points,i,l,p,m,_),this}arcToSvg(i,l,p,m,_,y,x){return buildArcToSvg(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,y,x,i,l,p,m,_),this}bezierCurveTo(i,l,p,m,_,y,x){this._ensurePoly();const v=this._currentPoly;return buildAdaptiveBezier(this._currentPoly.points,v.lastX,v.lastY,i,l,p,m,_,y,x),this}quadraticCurveTo(i,l,p,m,_){this._ensurePoly();const y=this._currentPoly;return buildAdaptiveQuadratic(this._currentPoly.points,y.lastX,y.lastY,i,l,p,m,_),this}closePath(){return this.endPoly(!0),this}addPath(i,l){this.endPoly(),l&&!l.isIdentity()&&(i=i.clone(!0)).transform(l);for(let l=0;l<i.instructions.length;l++){const p=i.instructions[l];this[p.action](...p.data)}return this}finish(i=!1){this.endPoly(i)}rect(i,l,p,m,_){return this.drawShape(new Rectangle(i,l,p,m),_),this}circle(i,l,p,m){return this.drawShape(new Circle(i,l,p),m),this}poly(i,l,p){const m=new Polygon(i);return m.closePath=l,this.drawShape(m,p),this}regularPoly(i,l,p,m,_=0,y){m=Math.max(0|m,3);const x=-1*Math.PI/2+_,v=2*Math.PI/m,T=[];for(let _=0;_<m;_++){const m=_*v+x;T.push(i+p*Math.cos(m),l+p*Math.sin(m))}return this.poly(T,!0,y),this}roundPoly(i,l,p,m,_,y=0,x){if(m=Math.max(0|m,3),_<=0)return this.regularPoly(i,l,p,m,y);const v=p*Math.sin(Math.PI/m)-.001;_=Math.min(_,v);const T=-1*Math.PI/2+y,S=2*Math.PI/m,P=(m-2)*Math.PI/m/2;for(let y=0;y<m;y++){const m=y*S+T,v=i+p*Math.cos(m),C=l+p*Math.sin(m),E=m+Math.PI+P,A=m-Math.PI-P,k=v+_*Math.cos(E),B=C+_*Math.sin(E),F=v+_*Math.cos(A),R=C+_*Math.sin(A);0===y?this.moveTo(k,B):this.lineTo(k,B),this.quadraticCurveTo(v,C,F,R,x)}return this.closePath()}roundShape(i,l,p=!1,m){return i.length<3?this:(p?function roundedShapeQuadraticCurve(i,l,p,m){const distance=(i,l)=>Math.sqrt((i.x-l.x)**2+(i.y-l.y)**2),pointLerp=(i,l,p)=>({x:i.x+(l.x-i.x)*p,y:i.y+(l.y-i.y)*p}),_=l.length;for(let y=0;y<_;y++){const x=l[(y+1)%_],v=x.radius??p;if(v<=0){0===y?i.moveTo(x.x,x.y):i.lineTo(x.x,x.y);continue}const T=l[y],S=l[(y+2)%_],P=distance(T,x);let C;C=P<1e-4?x:pointLerp(x,T,Math.min(P/2,v)/P);const E=distance(S,x);let A;A=E<1e-4?x:pointLerp(x,S,Math.min(E/2,v)/E),0===y?i.moveTo(C.x,C.y):i.lineTo(C.x,C.y),i.quadraticCurveTo(x.x,x.y,A.x,A.y,m)}}(this,i,l,m):function roundedShapeArc(i,l,p){const vecFrom=(i,l)=>{const p=l.x-i.x,m=l.y-i.y,_=Math.sqrt(p*p+m*m);return{len:_,nx:p/_,ny:m/_}},sharpCorner=(l,p)=>{0===l?i.moveTo(p.x,p.y):i.lineTo(p.x,p.y)};let m=l[l.length-1];for(let _=0;_<l.length;_++){const y=l[_%l.length],x=y.radius??p;if(x<=0){sharpCorner(_,y),m=y;continue}const v=l[(_+1)%l.length],T=vecFrom(y,m),S=vecFrom(y,v);if(T.len<1e-4||S.len<1e-4){sharpCorner(_,y),m=y;continue}let P=Math.asin(T.nx*S.ny-T.ny*S.nx),C=1,E=!1;T.nx*S.nx-T.ny*-S.ny<0?P<0?P=Math.PI+P:(P=Math.PI-P,C=-1,E=!0):P>0&&(C=-1,E=!0);const A=P/2;let k,B=Math.abs(Math.cos(A)*x/Math.sin(A));B>Math.min(T.len/2,S.len/2)?(B=Math.min(T.len/2,S.len/2),k=Math.abs(B*Math.sin(A)/Math.cos(A))):k=x;const F=y.x+S.nx*B+-S.ny*k*C,R=y.y+S.ny*B+S.nx*k*C,I=Math.atan2(T.ny,T.nx)+Math.PI/2*C,D=Math.atan2(S.ny,S.nx)-Math.PI/2*C;0===_&&i.moveTo(F+Math.cos(I)*k,R+Math.sin(I)*k),i.arc(F,R,k,I,D,E),m=y}}(this,i,l),this.closePath())}filletRect(i,l,p,m,_){if(0===_)return this.rect(i,l,p,m);const y=Math.min(p,m)/2,x=Math.min(y,Math.max(-y,_)),v=i+p,T=l+m,S=x<0?-x:0,P=Math.abs(x);return this.moveTo(i,l+P).arcTo(i+S,l+S,i+P,l,P).lineTo(v-P,l).arcTo(v-S,l+S,v,l+P,P).lineTo(v,T-P).arcTo(v-S,T-S,i+p-P,T,P).lineTo(i+P,T).arcTo(i+S,T-S,i,T-P,P).closePath()}chamferRect(i,l,p,m,_,y){if(_<=0)return this.rect(i,l,p,m);const x=Math.min(_,Math.min(p,m)/2),v=i+p,T=l+m,S=[i+x,l,v-x,l,v,l+x,v,T-x,v-x,T,i+x,T,i,T-x,i,l+x];for(let i=S.length-1;i>=2;i-=2)S[i]===S[i-2]&&S[i-1]===S[i-3]&&S.splice(i-1,2);return this.poly(S,!0,y)}ellipse(i,l,p,m,_){return this.drawShape(new Ellipse(i,l,p,m),_),this}roundRect(i,l,p,m,_,y){return this.drawShape(new RoundedRectangle(i,l,p,m,_),y),this}drawShape(i,l){return this.endPoly(),this.shapePrimitives.push({shape:i,transform:l}),this}startPoly(i,l){let p=this._currentPoly;return p&&this.endPoly(),p=new Polygon,p.points.push(i,l),this._currentPoly=p,this}endPoly(i=!1){const l=this._currentPoly;return l&&l.points.length>2&&(l.closePath=i,this.shapePrimitives.push({shape:l})),this._currentPoly=null,this}_ensurePoly(i=!0){if(!this._currentPoly&&(this._currentPoly=new Polygon,i)){const i=this.shapePrimitives[this.shapePrimitives.length-1];if(i){let l=i.shape.x,p=i.shape.y;if(i.transform&&!i.transform.isIdentity()){const m=i.transform,_=l;l=m.a*l+m.c*p+m.tx,p=m.b*_+m.d*p+m.ty}this._currentPoly.points.push(l,p)}else this._currentPoly.points.push(0,0)}}buildPath(){const i=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let l=0;l<i.instructions.length;l++){const p=i.instructions[l];this[p.action](...p.data)}this.finish()}get bounds(){const i=this._bounds;i.clear();const l=this.shapePrimitives;for(let p=0;p<l.length;p++){const m=l[p],_=m.shape.getBounds(es);m.transform?i.addRect(_,m.transform):i.addRect(_)}return i}}class GraphicsPath{constructor(i){this.instructions=[],this.uid=uid("graphicsPath"),this._dirty=!0,"string"==typeof i?function SVGToGraphicsPath(i,l){const p=ri(i),m=[];let _=null,y=0,x=0;for(let i=0;i<p.length;i++){const v=p[i],T=v[0],S=v;switch(T){case"M":y=S[1],x=S[2],l.moveTo(y,x);break;case"m":y+=S[1],x+=S[2],l.moveTo(y,x);break;case"H":y=S[1],l.lineTo(y,x);break;case"h":y+=S[1],l.lineTo(y,x);break;case"V":x=S[1],l.lineTo(y,x);break;case"v":x+=S[1],l.lineTo(y,x);break;case"L":y=S[1],x=S[2],l.lineTo(y,x);break;case"l":y+=S[1],x+=S[2],l.lineTo(y,x);break;case"C":y=S[5],x=S[6],l.bezierCurveTo(S[1],S[2],S[3],S[4],y,x);break;case"c":l.bezierCurveTo(y+S[1],x+S[2],y+S[3],x+S[4],y+S[5],x+S[6]),y+=S[5],x+=S[6];break;case"S":y=S[3],x=S[4],l.bezierCurveToShort(S[1],S[2],y,x);break;case"s":l.bezierCurveToShort(y+S[1],x+S[2],y+S[3],x+S[4]),y+=S[3],x+=S[4];break;case"Q":y=S[3],x=S[4],l.quadraticCurveTo(S[1],S[2],y,x);break;case"q":l.quadraticCurveTo(y+S[1],x+S[2],y+S[3],x+S[4]),y+=S[3],x+=S[4];break;case"T":y=S[1],x=S[2],l.quadraticCurveToShort(y,x);break;case"t":y+=S[1],x+=S[2],l.quadraticCurveToShort(y,x);break;case"A":y=S[6],x=S[7],l.arcToSvg(S[1],S[2],S[3],S[4],S[5],y,x);break;case"a":y+=S[6],x+=S[7],l.arcToSvg(S[1],S[2],S[3],S[4],S[5],y,x);break;case"Z":case"z":l.closePath(),m.length>0&&(_=m.pop(),_?(y=_.startX,x=_.startY):(y=0,x=0)),_=null;break;default:warn(`Unknown SVG path command: ${T}`)}"Z"!==T&&"z"!==T&&null===_&&(_={startX:y,startY:x},m.push(_))}return l}(i,this):this.instructions=i?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new ShapePath(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(i,l){return i=i.clone(),this.instructions.push({action:"addPath",data:[i,l]}),this._dirty=!0,this}arc(...i){return this.instructions.push({action:"arc",data:i}),this._dirty=!0,this}arcTo(...i){return this.instructions.push({action:"arcTo",data:i}),this._dirty=!0,this}arcToSvg(...i){return this.instructions.push({action:"arcToSvg",data:i}),this._dirty=!0,this}bezierCurveTo(...i){return this.instructions.push({action:"bezierCurveTo",data:i}),this._dirty=!0,this}bezierCurveToShort(i,l,p,m,_){const y=this.instructions[this.instructions.length-1],x=this.getLastPoint(Point.shared);let v=0,T=0;if(y&&"bezierCurveTo"===y.action){v=y.data[2],T=y.data[3];const i=x.x,l=x.y;v=i+(i-v),T=l+(l-T)}else v=x.x,T=x.y;return this.instructions.push({action:"bezierCurveTo",data:[v,T,i,l,p,m,_]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...i){return this.instructions.push({action:"ellipse",data:i}),this._dirty=!0,this}lineTo(...i){return this.instructions.push({action:"lineTo",data:i}),this._dirty=!0,this}moveTo(...i){return this.instructions.push({action:"moveTo",data:i}),this}quadraticCurveTo(...i){return this.instructions.push({action:"quadraticCurveTo",data:i}),this._dirty=!0,this}quadraticCurveToShort(i,l,p){const m=this.instructions[this.instructions.length-1],_=this.getLastPoint(Point.shared);let y=0,x=0;if(m&&"quadraticCurveTo"===m.action){y=m.data[0],x=m.data[1];const i=_.x,l=_.y;y=i+(i-y),x=l+(l-x)}else y=_.x,x=_.y;return this.instructions.push({action:"quadraticCurveTo",data:[y,x,i,l,p]}),this._dirty=!0,this}rect(i,l,p,m,_){return this.instructions.push({action:"rect",data:[i,l,p,m,_]}),this._dirty=!0,this}circle(i,l,p,m){return this.instructions.push({action:"circle",data:[i,l,p,m]}),this._dirty=!0,this}roundRect(...i){return this.instructions.push({action:"roundRect",data:i}),this._dirty=!0,this}poly(...i){return this.instructions.push({action:"poly",data:i}),this._dirty=!0,this}regularPoly(...i){return this.instructions.push({action:"regularPoly",data:i}),this._dirty=!0,this}roundPoly(...i){return this.instructions.push({action:"roundPoly",data:i}),this._dirty=!0,this}roundShape(...i){return this.instructions.push({action:"roundShape",data:i}),this._dirty=!0,this}filletRect(...i){return this.instructions.push({action:"filletRect",data:i}),this._dirty=!0,this}chamferRect(...i){return this.instructions.push({action:"chamferRect",data:i}),this._dirty=!0,this}star(i,l,p,m,_,y,x){_=_||m/2;const v=-1*Math.PI/2+y,T=2*p,S=2*Math.PI/T,P=[];for(let p=0;p<T;p++){const y=p%2?_:m,x=p*S+v;P.push(i+y*Math.cos(x),l+y*Math.sin(x))}return this.poly(P,!0,x),this}clone(i=!1){const l=new GraphicsPath;if(i)for(let i=0;i<this.instructions.length;i++){const p=this.instructions[i];l.instructions.push({action:p.action,data:p.data.slice()})}else l.instructions=this.instructions.slice();return l}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(i){if(i.isIdentity())return this;const l=i.a,p=i.b,m=i.c,_=i.d,y=i.tx,x=i.ty;let v=0,T=0,S=0,P=0,C=0,E=0,A=0,k=0;for(let B=0;B<this.instructions.length;B++){const F=this.instructions[B],R=F.data;switch(F.action){case"moveTo":case"lineTo":v=R[0],T=R[1],R[0]=l*v+m*T+y,R[1]=p*v+_*T+x;break;case"bezierCurveTo":S=R[0],P=R[1],C=R[2],E=R[3],v=R[4],T=R[5],R[0]=l*S+m*P+y,R[1]=p*S+_*P+x,R[2]=l*C+m*E+y,R[3]=p*C+_*E+x,R[4]=l*v+m*T+y,R[5]=p*v+_*T+x;break;case"quadraticCurveTo":S=R[0],P=R[1],v=R[2],T=R[3],R[0]=l*S+m*P+y,R[1]=p*S+_*P+x,R[2]=l*v+m*T+y,R[3]=p*v+_*T+x;break;case"arcToSvg":v=R[5],T=R[6],A=R[0],k=R[1],R[0]=l*A+m*k,R[1]=p*A+_*k,R[5]=l*v+m*T+y,R[6]=p*v+_*T+x;break;case"circle":R[4]=adjustTransform(R[3],i);break;case"rect":R[4]=adjustTransform(R[4],i);break;case"ellipse":R[8]=adjustTransform(R[8],i);break;case"roundRect":R[5]=adjustTransform(R[5],i);break;case"addPath":R[0].transform(i);break;case"poly":R[2]=adjustTransform(R[2],i);break;default:warn("unknown transform action",F.action)}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(i){let l=this.instructions.length-1,p=this.instructions[l];if(!p)return i.x=0,i.y=0,i;for(;"closePath"===p.action;){if(l--,l<0)return i.x=0,i.y=0,i;p=this.instructions[l]}switch(p.action){case"moveTo":case"lineTo":i.x=p.data[0],i.y=p.data[1];break;case"quadraticCurveTo":i.x=p.data[2],i.y=p.data[3];break;case"bezierCurveTo":i.x=p.data[4],i.y=p.data[5];break;case"arc":case"arcToSvg":i.x=p.data[5],i.y=p.data[6];break;case"addPath":p.data[0].getLastPoint(i)}return i}}function adjustTransform(i,l){return i?i.prepend(l):l.clone()}function SVGParser(i,l){if("string"==typeof i){const l=document.createElement("div");l.innerHTML=i.trim(),i=l.querySelector("svg")}return renderChildren(i,{context:l,path:new GraphicsPath},null,null),l}function renderChildren(i,l,p,m){const _=i.children,{fillStyle:y,strokeStyle:x}=function parseStyle(i){const l=i.getAttribute("style"),p={},m={};let _=!1,y=!1;if(l){const i=l.split(";");for(let l=0;l<i.length;l++){const x=i[l],[v,T]=x.split(":");switch(v){case"stroke":"none"!==T&&(p.color=At.shared.setValue(T).toNumber(),y=!0);break;case"stroke-width":p.width=Number(T);break;case"fill":"none"!==T&&(_=!0,m.color=At.shared.setValue(T).toNumber());break;case"fill-opacity":m.alpha=Number(T);break;case"stroke-opacity":p.alpha=Number(T);break;case"opacity":m.alpha=Number(T),p.alpha=Number(T)}}}else{const l=i.getAttribute("stroke");l&&"none"!==l&&(y=!0,p.color=At.shared.setValue(l).toNumber(),p.width=parseFloatAttribute(i,"stroke-width",1));const x=i.getAttribute("fill");x&&"none"!==x&&(_=!0,m.color=At.shared.setValue(x).toNumber())}return{strokeStyle:y?p:null,fillStyle:_?m:null}}(i);let v,T,S,P,C,E,A,k,B,F,R,I,D,L,U,G,O;switch(y&&p?p={...p,...y}:y&&(p=y),x&&m?m={...m,...x}:x&&(m=x),l.context.fillStyle=p,l.context.strokeStyle=m,i.nodeName.toLowerCase()){case"path":L=i.getAttribute("d"),U=new GraphicsPath(L),l.context.path(U),p&&l.context.fill(),m&&l.context.stroke();break;case"circle":A=parseFloatAttribute(i,"cx",0),k=parseFloatAttribute(i,"cy",0),B=parseFloatAttribute(i,"r",0),l.context.ellipse(A,k,B,B),p&&l.context.fill(),m&&l.context.stroke();break;case"rect":v=parseFloatAttribute(i,"x",0),T=parseFloatAttribute(i,"y",0),G=parseFloatAttribute(i,"width",0),O=parseFloatAttribute(i,"height",0),F=parseFloatAttribute(i,"rx",0),R=parseFloatAttribute(i,"ry",0),F||R?l.context.roundRect(v,T,G,O,F||R):l.context.rect(v,T,G,O),p&&l.context.fill(),m&&l.context.stroke();break;case"ellipse":A=parseFloatAttribute(i,"cx",0),k=parseFloatAttribute(i,"cy",0),F=parseFloatAttribute(i,"rx",0),R=parseFloatAttribute(i,"ry",0),l.context.beginPath(),l.context.ellipse(A,k,F,R),p&&l.context.fill(),m&&l.context.stroke();break;case"line":S=parseFloatAttribute(i,"x1",0),P=parseFloatAttribute(i,"y1",0),C=parseFloatAttribute(i,"x2",0),E=parseFloatAttribute(i,"y2",0),l.context.beginPath(),l.context.moveTo(S,P),l.context.lineTo(C,E),m&&l.context.stroke();break;case"polygon":D=i.getAttribute("points"),I=D.match(/\d+/g).map((i=>parseInt(i,10))),l.context.poly(I,!0),p&&l.context.fill(),m&&l.context.stroke();break;case"polyline":D=i.getAttribute("points"),I=D.match(/\d+/g).map((i=>parseInt(i,10))),l.context.poly(I,!1),m&&l.context.stroke();break;case"g":case"svg":break;default:console.info(`[SVG parser] <${i.nodeName}> elements unsupported`)}for(let i=0;i<_.length;i++)renderChildren(_[i],l,p,m)}function parseFloatAttribute(i,l,p){const m=i.getAttribute(l);return m?Number(m):p}function isFillPattern(i){return i instanceof FillPattern}function isFillGradient(i){return i instanceof Qe}function handleFillPattern(i,l,p){return i.fill=l,i.color=16777215,i.texture=l.texture,i.matrix=l.transform,{...p,...i}}function handleFillGradient(i,l,p){return l.buildLinearGradient(),i.fill=l,i.color=16777215,i.texture=l.texture,i.matrix=l.transform,{...p,...i}}function toFillStyle(i,l){if(null==i)return null;const p={},m=i;return function isColorLike(i){return At.isColorLike(i)}(i)?function handleColorLike(i,l,p){const m=At.shared.setValue(l??0);return i.color=m.toNumber(),i.alpha=1===m.alpha?p.alpha:m.alpha,i.texture=Texture.WHITE,{...p,...i}}(p,i,l):isFillPattern(i)?handleFillPattern(p,i,l):isFillGradient(i)?handleFillGradient(p,i,l):m.fill&&isFillPattern(m.fill)?handleFillPattern(m,m.fill,l):m.fill&&isFillGradient(m.fill)?handleFillGradient(m,m.fill,l):function handleFillObject(i,l){const p={...l,...i};if(p.texture){if(p.texture!==Texture.WHITE){const i=p.matrix?.invert()||new Matrix;i.translate(p.texture.frame.x,p.texture.frame.y),i.scale(1/p.texture.source.width,1/p.texture.source.height),p.matrix=i}const i=p.texture.source.style;"clamp-to-edge"===i.addressMode&&(i.addressMode="repeat",i.update())}const m=At.shared.setValue(p.color);return p.alpha*=m.alpha,p.color=m.toNumber(),p.matrix=p.matrix?p.matrix.clone():null,p}(m,l)}function toStrokeStyle(i,l){const{width:p,alignment:m,miterLimit:_,cap:y,join:x,...v}=l,T=toFillStyle(i,v);return T?{width:p,alignment:m,miterLimit:_,cap:y,join:x,...T}:null}const is=new Point,ss=new Matrix,rs=class _GraphicsContext extends V{constructor(){super(...arguments),this.uid=uid("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new GraphicsPath,this._transform=new Matrix,this._fillStyle={..._GraphicsContext.defaultFillStyle},this._strokeStyle={..._GraphicsContext.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Bounds,this._boundsDirty=!0}clone(){const i=new _GraphicsContext;return i.batchMode=this.batchMode,i.instructions=this.instructions.slice(),i._activePath=this._activePath.clone(),i._transform=this._transform.clone(),i._fillStyle={...this._fillStyle},i._strokeStyle={...this._strokeStyle},i._stateStack=this._stateStack.slice(),i._bounds=this._bounds.clone(),i._boundsDirty=!0,i}get fillStyle(){return this._fillStyle}set fillStyle(i){this._fillStyle=toFillStyle(i,_GraphicsContext.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(i){this._strokeStyle=toStrokeStyle(i,_GraphicsContext.defaultStrokeStyle)}setFillStyle(i){return this._fillStyle=toFillStyle(i,_GraphicsContext.defaultFillStyle),this}setStrokeStyle(i){return this._strokeStyle=toFillStyle(i,_GraphicsContext.defaultStrokeStyle),this}texture(i,l,p,m,_,y){return this.instructions.push({action:"texture",data:{image:i,dx:p||0,dy:m||0,dw:_||i.frame.width,dh:y||i.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:l?At.shared.setValue(l).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new GraphicsPath,this}fill(i,l){let p;const m=this.instructions[this.instructions.length-1];return p=0===this._tick&&m&&"stroke"===m.action?m.data.path:this._activePath.clone(),p?(null!=i&&(void 0!==l&&"number"==typeof i&&(deprecation(ut,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),i={color:i,alpha:l}),this._fillStyle=toFillStyle(i,_GraphicsContext.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:p}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:i,y:l}=this._activePath.getLastPoint(Point.shared);this._activePath.clear(),this._activePath.moveTo(i,l)}stroke(i){let l;const p=this.instructions[this.instructions.length-1];return l=0===this._tick&&p&&"fill"===p.action?p.data.path:this._activePath.clone(),l?(null!=i&&(this._strokeStyle=toStrokeStyle(i,_GraphicsContext.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:l}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let i=0;i<2;i++){const l=this.instructions[this.instructions.length-1-i],p=this._activePath.clone();if(l&&("stroke"===l.action||"fill"===l.action)){if(!l.data.hole){l.data.hole=p;break}l.data.hole.addPath(p)}}return this._initNextPathLocation(),this}arc(i,l,p,m,_,y){this._tick++;const x=this._transform;return this._activePath.arc(x.a*i+x.c*l+x.tx,x.b*i+x.d*l+x.ty,p,m,_,y),this}arcTo(i,l,p,m,_){this._tick++;const y=this._transform;return this._activePath.arcTo(y.a*i+y.c*l+y.tx,y.b*i+y.d*l+y.ty,y.a*p+y.c*m+y.tx,y.b*p+y.d*m+y.ty,_),this}arcToSvg(i,l,p,m,_,y,x){this._tick++;const v=this._transform;return this._activePath.arcToSvg(i,l,p,m,_,v.a*y+v.c*x+v.tx,v.b*y+v.d*x+v.ty),this}bezierCurveTo(i,l,p,m,_,y,x){this._tick++;const v=this._transform;return this._activePath.bezierCurveTo(v.a*i+v.c*l+v.tx,v.b*i+v.d*l+v.ty,v.a*p+v.c*m+v.tx,v.b*p+v.d*m+v.ty,v.a*_+v.c*y+v.tx,v.b*_+v.d*y+v.ty,x),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(i,l,p,m){return this._tick++,this._activePath.ellipse(i,l,p,m,this._transform.clone()),this}circle(i,l,p){return this._tick++,this._activePath.circle(i,l,p,this._transform.clone()),this}path(i){return this._tick++,this._activePath.addPath(i,this._transform.clone()),this}lineTo(i,l){this._tick++;const p=this._transform;return this._activePath.lineTo(p.a*i+p.c*l+p.tx,p.b*i+p.d*l+p.ty),this}moveTo(i,l){this._tick++;const p=this._transform,m=this._activePath.instructions,_=p.a*i+p.c*l+p.tx,y=p.b*i+p.d*l+p.ty;return 1===m.length&&"moveTo"===m[0].action?(m[0].data[0]=_,m[0].data[1]=y,this):(this._activePath.moveTo(_,y),this)}quadraticCurveTo(i,l,p,m,_){this._tick++;const y=this._transform;return this._activePath.quadraticCurveTo(y.a*i+y.c*l+y.tx,y.b*i+y.d*l+y.ty,y.a*p+y.c*m+y.tx,y.b*p+y.d*m+y.ty,_),this}rect(i,l,p,m){return this._tick++,this._activePath.rect(i,l,p,m,this._transform.clone()),this}roundRect(i,l,p,m,_){return this._tick++,this._activePath.roundRect(i,l,p,m,_,this._transform.clone()),this}poly(i,l){return this._tick++,this._activePath.poly(i,l,this._transform.clone()),this}regularPoly(i,l,p,m,_=0,y){return this._tick++,this._activePath.regularPoly(i,l,p,m,_,y),this}roundPoly(i,l,p,m,_,y){return this._tick++,this._activePath.roundPoly(i,l,p,m,_,y),this}roundShape(i,l,p,m){return this._tick++,this._activePath.roundShape(i,l,p,m),this}filletRect(i,l,p,m,_){return this._tick++,this._activePath.filletRect(i,l,p,m,_),this}chamferRect(i,l,p,m,_,y){return this._tick++,this._activePath.chamferRect(i,l,p,m,_,y),this}star(i,l,p,m,_=0,y=0){return this._tick++,this._activePath.star(i,l,p,m,_,y,this._transform.clone()),this}svg(i){return this._tick++,SVGParser(i,this),this}restore(){const i=this._stateStack.pop();return i&&(this._transform=i.transform,this._fillStyle=i.fillStyle,this._strokeStyle=i.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(i){return this._transform.rotate(i),this}scale(i,l=i){return this._transform.scale(i,l),this}setTransform(i,l,p,m,_,y){return i instanceof Matrix?(this._transform.set(i.a,i.b,i.c,i.d,i.tx,i.ty),this):(this._transform.set(i,l,p,m,_,y),this)}transform(i,l,p,m,_,y){return i instanceof Matrix?(this._transform.append(i),this):(ss.set(i,l,p,m,_,y),this._transform.append(ss),this)}translate(i,l=i){return this._transform.translate(i,l),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this.dirty||(this.emit("update",this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;const i=this._bounds;i.clear();for(let l=0;l<this.instructions.length;l++){const p=this.instructions[l],m=p.action;if("fill"===m){const l=p.data;i.addBounds(l.path.bounds)}else if("texture"===m){const l=p.data;i.addFrame(l.dx,l.dy,l.dx+l.dw,l.dy+l.dh,l.transform)}if("stroke"===m){const l=p.data,m=l.style.width/2,_=l.path.bounds;i.addFrame(_.minX-m,_.minY-m,_.maxX+m,_.maxY+m)}}return i}containsPoint(i){if(!this.bounds.containsPoint(i.x,i.y))return!1;const l=this.instructions;let p=!1;for(let m=0;m<l.length;m++){const _=l[m],y=_.data,x=y.path;if(!_.action||!x)continue;const v=y.style,T=x.shapePath.shapePrimitives;for(let l=0;l<T.length;l++){const m=T[l].shape;if(!v||!m)continue;const x=T[l].transform,S=x?x.applyInverse(i,is):i;p="fill"===_.action?m.contains(S.x,S.y):m.strokeContains(S.x,S.y,v.width);const P=y.hole;if(P){const i=P.shapePath?.shapePrimitives;if(i)for(let l=0;l<i.length;l++)i[l].shape.contains(S.x,S.y)&&(p=!1)}if(p)return!0}}return p}destroy(i=!1){this._stateStack.length=0,this._transform=null,this.emit("destroy",this),this.removeAllListeners();if("boolean"==typeof i?i:i?.texture){const l="boolean"==typeof i?i:i?.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(l),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(l)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};rs.defaultFillStyle={color:16777215,alpha:1,texture:Texture.WHITE,matrix:null,fill:null},rs.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Texture.WHITE,matrix:null,fill:null};let ns=rs;const os=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function generateTextStyleKey(i){const l=[];let p=0;for(let m=0;m<os.length;m++){const _=`_${os[m]}`;l[p++]=i[_]}return p=addFillStyleKey(i._fill,l,p),p=function addStokeStyleKey(i,l,p){return i?(p=addFillStyleKey(i,l,p),l[p++]=i.width,l[p++]=i.alignment,l[p++]=i.cap,l[p++]=i.join,l[p++]=i.miterLimit,p):p}(i._stroke,l,p),p=function addDropShadowKey(i,l,p){return i?(l[p++]=i.alpha,l[p++]=i.angle,l[p++]=i.blur,l[p++]=i.distance,l[p++]=At.shared.setValue(i.color).toNumber(),p):p}(i.dropShadow,l,p),l.join("-")}function addFillStyleKey(i,l,p){return i?(l[p++]=i.color,l[p++]=i.alpha,l[p++]=i.fill?.styleKey,p):p}const as=class _TextStyle extends V{constructor(i={}){super(),function convertV7Tov8Style(i){const l=i;if("boolean"==typeof l.dropShadow&&l.dropShadow){const p=hs.defaultDropShadow;i.dropShadow={alpha:l.dropShadowAlpha??p.alpha,angle:l.dropShadowAngle??p.angle,blur:l.dropShadowBlur??p.blur,color:l.dropShadowColor??p.color,distance:l.dropShadowDistance??p.distance}}if(void 0!==l.strokeThickness){deprecation(ut,"strokeThickness is now a part of stroke");const p=l.stroke;let m={};if(At.isColorLike(p))m.color=p;else if(p instanceof Qe||p instanceof FillPattern)m.fill=p;else{if(!Object.hasOwnProperty.call(p,"color")&&!Object.hasOwnProperty.call(p,"fill"))throw new Error("Invalid stroke value.");m=p}i.stroke={...m,width:l.strokeThickness}}if(Array.isArray(l.fillGradientStops)){let p;deprecation(ut,"gradient fill is now a fill pattern: `new FillGradient(...)`"),null==i.fontSize?i.fontSize=hs.defaultTextStyle.fontSize:p="string"==typeof i.fontSize?parseInt(i.fontSize,10):i.fontSize;const m=new Qe(0,0,0,1.7*p),_=l.fillGradientStops.map((i=>At.shared.setValue(i).toNumber()));_.forEach(((i,l)=>{const p=l/(_.length-1);m.addColorStop(p,i)})),i.fill={fill:m}}}(i);const l={..._TextStyle.defaultTextStyle,...i};for(const i in l){this[i]=l[i]}this.update()}get align(){return this._align}set align(i){this._align=i,this.update()}get breakWords(){return this._breakWords}set breakWords(i){this._breakWords=i,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(i){this._dropShadow=null!==i&&"object"==typeof i?this._createProxy({..._TextStyle.defaultDropShadow,...i}):i?this._createProxy({..._TextStyle.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(i){this._fontFamily=i,this.update()}get fontSize(){return this._fontSize}set fontSize(i){this._fontSize="string"==typeof i?parseInt(i,10):i,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(i){this._fontStyle=i,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(i){this._fontVariant=i,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(i){this._fontWeight=i,this.update()}get leading(){return this._leading}set leading(i){this._leading=i,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(i){this._letterSpacing=i,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(i){this._lineHeight=i,this.update()}get padding(){return this._padding}set padding(i){this._padding=i,this.update()}get trim(){return this._trim}set trim(i){this._trim=i,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(i){this._textBaseline=i,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(i){this._whiteSpace=i,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(i){this._wordWrap=i,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(i){this._wordWrapWidth=i,this.update()}get fill(){return this._originalFill}set fill(i){i!==this._originalFill&&(this._originalFill=i,this._isFillStyle(i)&&(this._originalFill=this._createProxy({...ns.defaultFillStyle,...i},(()=>{this._fill=toFillStyle({...this._originalFill},ns.defaultFillStyle)}))),this._fill=toFillStyle(0===i?"black":i,ns.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(i){i!==this._originalStroke&&(this._originalStroke=i,this._isFillStyle(i)&&(this._originalStroke=this._createProxy({...ns.defaultStrokeStyle,...i},(()=>{this._stroke=toStrokeStyle({...this._originalStroke},ns.defaultStrokeStyle)}))),this._stroke=toStrokeStyle(i,ns.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=generateTextStyleKey(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const i=_TextStyle.defaultTextStyle;for(const l in i)this[l]=i[l]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new _TextStyle({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,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,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(i=!1){this.removeAllListeners();if("boolean"==typeof i?i:i?.texture){const l="boolean"==typeof i?i:i?.textureSource;this._fill?.texture&&this._fill.texture.destroy(l),this._originalFill?.texture&&this._originalFill.texture.destroy(l),this._stroke?.texture&&this._stroke.texture.destroy(l),this._originalStroke?.texture&&this._originalStroke.texture.destroy(l)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(i,l){return new Proxy(i,{set:(i,p,m)=>(i[p]=m,l?.(p,m),this.update(),!0)})}_isFillStyle(i){return null!==(i??null)&&!(At.isColorLike(i)||i instanceof Qe||i instanceof FillPattern)}};as.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},as.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};let hs=as;const ls=new class CanvasPoolClass{constructor(i){this._canvasPool=Object.create(null),this.canvasOptions=i||{},this.enableFullScreen=!1}_createCanvasAndContext(i,l){const p=qt.get().createCanvas();p.width=i,p.height=l;const m=p.getContext("2d");return{canvas:p,context:m}}getOptimalCanvasAndContext(i,l,p=1){i=Math.ceil(i*p-1e-6),l=Math.ceil(l*p-1e-6);const m=((i=nextPow2(i))<<17)+((l=nextPow2(l))<<1);this._canvasPool[m]||(this._canvasPool[m]=[]);let _=this._canvasPool[m].pop();return _||(_=this._createCanvasAndContext(i,l)),_}returnCanvasAndContext(i){const l=i.canvas,{width:p,height:m}=l,_=(p<<17)+(m<<1);this._canvasPool[_].push(i)}clear(){this._canvasPool={}}},ds=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function fontStringFromTextStyle(i){const l="number"==typeof i.fontSize?`${i.fontSize}px`:i.fontSize;let p=i.fontFamily;Array.isArray(i.fontFamily)||(p=i.fontFamily.split(","));for(let i=p.length-1;i>=0;i--){let l=p[i].trim();/([\"\'])[^\'\"]+\1/.test(l)||ds.includes(l)||(l=`"${l}"`),p[i]=l}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${l} ${p.join(",")}`}const us={willReadFrequently:!0},cs=class _CanvasTextMetrics{static get experimentalLetterSpacingSupported(){let i=_CanvasTextMetrics._experimentalLetterSpacingSupported;if(void 0!==i){const l=qt.get().getCanvasRenderingContext2D().prototype;i=_CanvasTextMetrics._experimentalLetterSpacingSupported="letterSpacing"in l||"textLetterSpacing"in l}return i}constructor(i,l,p,m,_,y,x,v,T){this.text=i,this.style=l,this.width=p,this.height=m,this.lines=_,this.lineWidths=y,this.lineHeight=x,this.maxLineWidth=v,this.fontProperties=T}static measureText(i=" ",l,p=_CanvasTextMetrics._canvas,m=l.wordWrap){const _=`${i}:${l.styleKey}`;if(_CanvasTextMetrics._measurementCache[_])return _CanvasTextMetrics._measurementCache[_];const y=fontStringFromTextStyle(l),x=_CanvasTextMetrics.measureFont(y);0===x.fontSize&&(x.fontSize=l.fontSize,x.ascent=l.fontSize);const v=_CanvasTextMetrics.__context;v.font=y;const T=(m?_CanvasTextMetrics._wordWrap(i,l,p):i).split(/(?:\r\n|\r|\n)/),S=new Array(T.length);let P=0;for(let i=0;i<T.length;i++){const p=_CanvasTextMetrics._measureText(T[i],l.letterSpacing,v);S[i]=p,P=Math.max(P,p)}const C=l._stroke?.width||0;let E=P+C;l.dropShadow&&(E+=l.dropShadow.distance);const A=l.lineHeight||x.fontSize;let k=Math.max(A,x.fontSize+C)+(T.length-1)*(A+l.leading);l.dropShadow&&(k+=l.dropShadow.distance);return new _CanvasTextMetrics(i,l,E,k,T,S,A+l.leading,P,x)}static _measureText(i,l,p){let m=!1;_CanvasTextMetrics.experimentalLetterSpacingSupported&&(_CanvasTextMetrics.experimentalLetterSpacing?(p.letterSpacing=`${l}px`,p.textLetterSpacing=`${l}px`,m=!0):(p.letterSpacing="0px",p.textLetterSpacing="0px"));let _=p.measureText(i).width;return _>0&&(m?_-=l:_+=(_CanvasTextMetrics.graphemeSegmenter(i).length-1)*l),_}static _wordWrap(i,l,p=_CanvasTextMetrics._canvas){const m=p.getContext("2d",us);let _=0,y="",x="";const v=Object.create(null),{letterSpacing:T,whiteSpace:S}=l,P=_CanvasTextMetrics._collapseSpaces(S),C=_CanvasTextMetrics._collapseNewlines(S);let E=!P;const A=l.wordWrapWidth+T,k=_CanvasTextMetrics._tokenize(i);for(let i=0;i<k.length;i++){let p=k[i];if(_CanvasTextMetrics._isNewline(p)){if(!C){x+=_CanvasTextMetrics._addLine(y),E=!P,y="",_=0;continue}p=" "}if(P){const i=_CanvasTextMetrics.isBreakingSpace(p),l=_CanvasTextMetrics.isBreakingSpace(y[y.length-1]);if(i&&l)continue}const S=_CanvasTextMetrics._getFromCache(p,T,v,m);if(S>A)if(""!==y&&(x+=_CanvasTextMetrics._addLine(y),y="",_=0),_CanvasTextMetrics.canBreakWords(p,l.breakWords)){const i=_CanvasTextMetrics.wordWrapSplit(p);for(let S=0;S<i.length;S++){let P=i[S],C=P,k=1;for(;i[S+k];){const m=i[S+k];if(_CanvasTextMetrics.canBreakChars(C,m,p,S,l.breakWords))break;P+=m,C=m,k++}S+=k-1;const B=_CanvasTextMetrics._getFromCache(P,T,v,m);B+_>A&&(x+=_CanvasTextMetrics._addLine(y),E=!1,y="",_=0),y+=P,_+=B}}else{y.length>0&&(x+=_CanvasTextMetrics._addLine(y),y="",_=0);const l=i===k.length-1;x+=_CanvasTextMetrics._addLine(p,!l),E=!1,y="",_=0}else S+_>A&&(E=!1,x+=_CanvasTextMetrics._addLine(y),y="",_=0),(y.length>0||!_CanvasTextMetrics.isBreakingSpace(p)||E)&&(y+=p,_+=S)}return x+=_CanvasTextMetrics._addLine(y,!1),x}static _addLine(i,l=!0){return i=_CanvasTextMetrics._trimRight(i),i=l?`${i}\n`:i}static _getFromCache(i,l,p,m){let _=p[i];return"number"!=typeof _&&(_=_CanvasTextMetrics._measureText(i,l,m)+l,p[i]=_),_}static _collapseSpaces(i){return"normal"===i||"pre-line"===i}static _collapseNewlines(i){return"normal"===i}static _trimRight(i){if("string"!=typeof i)return"";for(let l=i.length-1;l>=0;l--){const p=i[l];if(!_CanvasTextMetrics.isBreakingSpace(p))break;i=i.slice(0,-1)}return i}static _isNewline(i){return"string"==typeof i&&_CanvasTextMetrics._newlines.includes(i.charCodeAt(0))}static isBreakingSpace(i,l){return"string"==typeof i&&_CanvasTextMetrics._breakingSpaces.includes(i.charCodeAt(0))}static _tokenize(i){const l=[];let p="";if("string"!=typeof i)return l;for(let m=0;m<i.length;m++){const _=i[m],y=i[m+1];_CanvasTextMetrics.isBreakingSpace(_,y)||_CanvasTextMetrics._isNewline(_)?(""!==p&&(l.push(p),p=""),l.push(_)):p+=_}return""!==p&&l.push(p),l}static canBreakWords(i,l){return l}static canBreakChars(i,l,p,m,_){return!0}static wordWrapSplit(i){return _CanvasTextMetrics.graphemeSegmenter(i)}static measureFont(i){if(_CanvasTextMetrics._fonts[i])return _CanvasTextMetrics._fonts[i];const l=_CanvasTextMetrics._context;l.font=i;const p=l.measureText(_CanvasTextMetrics.METRICS_STRING+_CanvasTextMetrics.BASELINE_SYMBOL),m={ascent:p.actualBoundingBoxAscent,descent:p.actualBoundingBoxDescent,fontSize:p.actualBoundingBoxAscent+p.actualBoundingBoxDescent};return _CanvasTextMetrics._fonts[i]=m,m}static clearMetrics(i=""){i?delete _CanvasTextMetrics._fonts[i]:_CanvasTextMetrics._fonts={}}static get _canvas(){if(!_CanvasTextMetrics.__canvas){let i;try{const l=new OffscreenCanvas(0,0),p=l.getContext("2d",us);if(p?.measureText)return _CanvasTextMetrics.__canvas=l,l;i=qt.get().createCanvas()}catch(l){i=qt.get().createCanvas()}i.width=i.height=10,_CanvasTextMetrics.__canvas=i}return _CanvasTextMetrics.__canvas}static get _context(){return _CanvasTextMetrics.__context||(_CanvasTextMetrics.__context=_CanvasTextMetrics._canvas.getContext("2d",us)),_CanvasTextMetrics.__context}};cs.METRICS_STRING="|ÉqÅ",cs.BASELINE_SYMBOL="M",cs.BASELINE_MULTIPLIER=1.4,cs.HEIGHT_MULTIPLIER=2,cs.graphemeSegmenter=(()=>{if("function"==typeof Intl?.Segmenter){const i=new Intl.Segmenter;return l=>[...i.segment(l)].map((i=>i.segment))}return i=>[...i]})(),cs.experimentalLetterSpacing=!1,cs._fonts={},cs._newlines=[10,13],cs._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],cs._measurementCache={};let ps=cs;function getCanvasFillStyle(i,l){if(i.texture===Texture.WHITE&&!i.fill)return At.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(!i.fill){const p=l.createPattern(i.texture.source.resource,"repeat"),m=i.matrix.copyTo(Matrix.shared);return m.scale(i.texture.frame.width,i.texture.frame.height),p.setTransform(m),p}if(i.fill instanceof FillPattern){const p=i.fill,m=l.createPattern(p.texture.source.resource,"repeat"),_=p.transform.copyTo(Matrix.shared);return _.scale(p.texture.frame.width,p.texture.frame.height),m.setTransform(_),m}if(i.fill instanceof Qe){const p=i.fill;if("linear"===p.type){const i=l.createLinearGradient(p.x0,p.y0,p.x1,p.y1);return p.gradientStops.forEach((l=>{i.addColorStop(l.offset,At.shared.setValue(l.color).toHex())})),i}}return warn("FillStyle not recognised",i),"red"}function resolveCharacters(i){if(""===i)return[];"string"==typeof i&&(i=[i]);const l=[];for(let p=0,m=i.length;p<m;p++){const m=i[p];if(Array.isArray(m)){if(2!==m.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${m.length}.`);if(0===m[0].length||0===m[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");const i=m[0].charCodeAt(0),p=m[1].charCodeAt(0);if(p<i)throw new Error("[BitmapFont]: Invalid character range.");for(let m=i,_=p;m<=_;m++)l.push(String.fromCharCode(m))}else l.push(...Array.from(m))}if(0===l.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return l}const fs=class _DynamicBitmapFont extends AbstractBitmapFont{constructor(i){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const l={..._DynamicBitmapFont.defaultOptions,...i};this._textureSize=l.textureSize,this._mipmap=l.mipmap;const p=l.style.clone();l.overrideFill&&(p._fill.color=16777215,p._fill.alpha=1,p._fill.texture=Texture.WHITE,p._fill.fill=null),this.applyFillAsTint=l.overrideFill;const m=p.fontSize;p.fontSize=this.baseMeasurementFontSize;const _=fontStringFromTextStyle(p);l.overrideSize?p._stroke&&(p._stroke.width*=this.baseRenderedFontSize/m):p.fontSize=this.baseRenderedFontSize=m,this._style=p,this._skipKerning=l.skipKerning??!1,this.resolution=l.resolution??1,this._padding=l.padding??4,this.fontMetrics=ps.measureFont(_),this.lineHeight=p.lineHeight||this.fontMetrics.fontSize||p.fontSize}ensureCharacters(i){const l=resolveCharacters(i).filter((i=>!this._currentChars.includes(i))).filter(((i,l,p)=>p.indexOf(i)===l));if(!l.length)return;let p;this._currentChars=[...this._currentChars,...l],p=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:m,context:_}=p.canvasAndContext,y=p.texture.source;const x=this._style;let v=this._currentX,T=this._currentY;const S=this.baseRenderedFontSize/this.baseMeasurementFontSize,P=this._padding*S,C="italic"===x.fontStyle?2:1;let E=0,A=!1;for(let i=0;i<l.length;i++){const p=l[i],k=ps.measureText(p,x,m,!1);k.lineHeight=k.height;const B=C*k.width*S,F=B+2*P,R=k.height*S+2*P;if(A=!1,"\n"!==p&&"\r"!==p&&"\t"!==p&&" "!==p&&(A=!0,E=Math.ceil(Math.max(R,E))),v+F>this._textureSize&&(T+=E,E=R,v=0,T+E>this._textureSize)){y.update();const i=this._nextPage();m=i.canvasAndContext.canvas,_=i.canvasAndContext.context,y=i.texture.source,T=0}const I=B/S-(x.dropShadow?.distance??0)-(x._stroke?.width??0);if(this.chars[p]={id:p.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:I,kerning:{}},A){this._drawGlyph(_,k,v+P,T+P,S,x);const i=y.width*S,l=y.height*S,m=new Rectangle(v/i*y.width,T/l*y.height,F/i*y.width,R/l*y.height);this.chars[p].texture=new Texture({source:y,frame:m}),v+=Math.ceil(F)}}y.update(),this._currentX=v,this._currentY=T,this._skipKerning&&this._applyKerning(l,_)}get pageTextures(){return deprecation(ut,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(i,l){const p=this._measureCache;for(let m=0;m<i.length;m++){const _=i[m];for(let i=0;i<this._currentChars.length;i++){const m=this._currentChars[i];let y=p[_];y||(y=p[_]=l.measureText(_).width);let x=p[m];x||(x=p[m]=l.measureText(m).width);let v=l.measureText(_+m).width,T=v-(y+x);T&&(this.chars[_].kerning[m]=T),v=l.measureText(_+m).width,T=v-(y+x),T&&(this.chars[m].kerning[_]=T)}}}_nextPage(){this._currentPageIndex++;const i=this.resolution,l=ls.getOptimalCanvasAndContext(this._textureSize,this._textureSize,i);this._setupContext(l.context,this._style,i);const p=i*(this.baseRenderedFontSize/this.baseMeasurementFontSize),m={canvasAndContext:l,texture:new Texture({source:new ImageSource({resource:l.canvas,resolution:p,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})})};return this.pages[this._currentPageIndex]=m,m}_setupContext(i,l,p){l.fontSize=this.baseRenderedFontSize,i.scale(p,p),i.font=fontStringFromTextStyle(l),l.fontSize=this.baseMeasurementFontSize,i.textBaseline=l.textBaseline;const m=l._stroke,_=m?.width??0;if(m&&(i.lineWidth=_,i.lineJoin=m.join,i.miterLimit=m.miterLimit,i.strokeStyle=getCanvasFillStyle(m,i)),l._fill&&(i.fillStyle=getCanvasFillStyle(l._fill,i)),l.dropShadow){const m=l.dropShadow,_=At.shared.setValue(m.color).toArray(),y=m.blur*p,x=m.distance*p;i.shadowColor=`rgba(${255*_[0]},${255*_[1]},${255*_[2]},${m.alpha})`,i.shadowBlur=y,i.shadowOffsetX=Math.cos(m.angle)*x,i.shadowOffsetY=Math.sin(m.angle)*x}else i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0}_drawGlyph(i,l,p,m,_,y){const x=l.text,v=l.fontProperties,T=y._stroke,S=(T?.width??0)*_,P=p+S/2,C=m-S/2,E=v.descent*_,A=l.lineHeight*_;y.stroke&&S&&i.strokeText(x,P,C+A-E),y._fill&&i.fillText(x,P,C+A-E)}destroy(){super.destroy();for(let i=0;i<this.pages.length;i++){const{canvasAndContext:l,texture:p}=this.pages[i];l.canvas.width=l.canvas.width,ls.returnCanvasAndContext(l),p.destroy(!0)}this.pages=null}};fs.defaultOptions={textureSize:512,style:new hs,mipmap:!0};let ms=fs;function getBitmapTextLayout(i,l,p,m){const _={width:0,height:0,offsetY:0,scale:l.fontSize/p.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};_.offsetY=p.baseLineOffset;let y=_.lines[0],x=null,v=!0;const T={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},nextWord=i=>{const l=y.width;for(let p=0;p<T.index;p++){const m=i.positions[p];y.chars.push(i.chars[p]),y.charPositions.push(m+l)}y.width+=i.width,v=!1,T.width=0,T.index=0,T.chars.length=0},nextLine=()=>{let i=y.chars.length-1;if(m){let l=y.chars[i];for(;" "===l;)y.width-=p.chars[l].xAdvance,l=y.chars[--i]}_.width=Math.max(_.width,y.width),y={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},v=!0,_.lines.push(y),_.height+=p.lineHeight},S=p.baseMeasurementFontSize/l.fontSize,P=l.letterSpacing*S,C=l.wordWrapWidth*S;for(let m=0;m<i.length+1;m++){let _;const S=m===i.length;S||(_=i[m]);const E=p.chars[_]||p.chars[" "];if(/(?:\s)/.test(_)||"\r"===_||"\n"===_||S){if(!v&&l.wordWrap&&y.width+T.width-P>C?(nextLine(),nextWord(T),S||y.charPositions.push(0)):(T.start=y.width,nextWord(T),S||y.charPositions.push(0)),"\r"===_||"\n"===_)0!==y.width&&nextLine();else if(!S){const i=E.xAdvance+(E.kerning[x]||0)+P;y.width+=i,y.spaceWidth=i,y.spacesIndex.push(y.charPositions.length),y.chars.push(_)}}else{const i=E.kerning[x]||0,l=E.xAdvance+i+P;T.positions[T.index++]=T.width+i,T.chars.push(_),T.width+=l}x=_}return nextLine(),"center"===l.align?function alignCenter(i){for(let l=0;l<i.lines.length;l++){const p=i.lines[l],m=i.width/2-p.width/2;for(let i=0;i<p.charPositions.length;i++)p.charPositions[i]+=m}}(_):"right"===l.align?function alignRight(i){for(let l=0;l<i.lines.length;l++){const p=i.lines[l],m=i.width-p.width;for(let i=0;i<p.charPositions.length;i++)p.charPositions[i]+=m}}(_):"justify"===l.align&&function alignJustify(i){const l=i.width;for(let p=0;p<i.lines.length;p++){const m=i.lines[p];let _=0,y=m.spacesIndex[_++],x=0;const v=m.spacesIndex.length,T=(l-m.width)/v;for(let i=0;i<m.charPositions.length;i++)i===y&&(y=m.spacesIndex[_++],x+=T),m.charPositions[i]+=x}}(_),_}let gs=0;const _s=new class BitmapFontManagerClass{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}}getFont(i,l){let p=`${l.fontFamily}-bitmap`,m=!0;if(l._fill.fill&&!l._stroke)p+=l._fill.fill.styleKey,m=!1;else if(l._stroke||l.dropShadow){let i=l.styleKey;i=i.substring(0,i.lastIndexOf("-")),p=`${i}-bitmap`,m=!1}if(!se.has(p)){const i=new ms({style:l,overrideFill:m,overrideSize:!0,...this.defaultOptions});gs++,gs>50&&warn("BitmapText",`You have dynamically created ${gs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),i.once("destroy",(()=>{gs--,se.remove(p)})),se.set(p,i)}const _=se.get(p);return _.ensureCharacters?.(i),_}getLayout(i,l,p=!0){const m=this.getFont(i,l);return getBitmapTextLayout([...i],l,m,p)}measureText(i,l,p=!0){return this.getLayout(i,l,p)}install(...i){let l=i[0];"string"==typeof l&&(l={name:l,style:i[1],chars:i[2]?.chars,resolution:i[2]?.resolution,padding:i[2]?.padding,skipKerning:i[2]?.skipKerning},deprecation(ut,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const p=l?.name;if(!p)throw new Error("[BitmapFontManager] Property `name` is required.");l={...this.defaultOptions,...l};const m=l.style,_=m instanceof hs?m:new hs(m),y=null!==_._fill.fill&&void 0!==_._fill.fill,x=new ms({style:_,overrideFill:y,skipKerning:l.skipKerning,padding:l.padding,resolution:l.resolution,overrideSize:!1}),v=resolveCharacters(l.chars);return x.ensureCharacters(v.join("")),se.set(`${p}-bitmap`,x),x.once("destroy",(()=>se.remove(`${p}-bitmap`))),x}uninstall(i){const l=`${i}-bitmap`,p=se.get(l);p&&(se.remove(l),p.destroy())}};const ys=new class EventsTickerClass{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(i){this.removeTickerListener(),this.events=i,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(i){this._pauseUpdate=i}addTickerListener(){!this._tickerAdded&&this.domElement&&(te.system.add(this._tickerUpdate,this,Zt.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(te.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const i=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===i.pointerType||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,pointerId:i.pointerId}))}_tickerUpdate(i){this._deltaTime+=i.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}};class FederatedMouseEvent extends FederatedEvent{constructor(){super(...arguments),this.client=new Point,this.movement=new Point,this.offset=new Point,this.global=new Point,this.screen=new Point}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(i,l,p){return i.worldTransform.applyInverse(p||this.global,l)}getModifierState(i){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(i)}initMouseEvent(i,l,p,m,_,y,x,v,T,S,P,C,E,A,k){throw new Error("Method not implemented.")}}class FederatedPointerEvent extends FederatedMouseEvent{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class FederatedWheelEvent extends FederatedMouseEvent{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}FederatedWheelEvent.DOM_DELTA_PIXEL=0,FederatedWheelEvent.DOM_DELTA_LINE=1,FederatedWheelEvent.DOM_DELTA_PAGE=2;const xs=new Point,vs=new Point;class EventBoundary{constructor(i){this.dispatch=new V,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=i,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(i,l){this.mappingTable[i]||(this.mappingTable[i]=[]),this.mappingTable[i].push({fn:l,priority:0}),this.mappingTable[i].sort(((i,l)=>i.priority-l.priority))}dispatchEvent(i,l){i.propagationStopped=!1,i.propagationImmediatelyStopped=!1,this.propagate(i,l),this.dispatch.emit(l||i.type,i)}mapEvent(i){if(!this.rootTarget)return;const l=this.mappingTable[i.type];if(l)for(let p=0,m=l.length;p<m;p++)l[p].fn(i);else warn(`[EventBoundary]: Event mapping not defined for ${i.type}`)}hitTest(i,l){ys.pauseUpdate=!0;const p=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,xs.set(i,l),this.hitTestFn,this.hitPruneFn);return p&&p[0]}propagate(i,l){if(!i.target)return;const p=i.composedPath();i.eventPhase=i.CAPTURING_PHASE;for(let m=0,_=p.length-1;m<_;m++)if(i.currentTarget=p[m],this.notifyTarget(i,l),i.propagationStopped||i.propagationImmediatelyStopped)return;if(i.eventPhase=i.AT_TARGET,i.currentTarget=i.target,this.notifyTarget(i,l),!i.propagationStopped&&!i.propagationImmediatelyStopped){i.eventPhase=i.BUBBLING_PHASE;for(let m=p.length-2;m>=0;m--)if(i.currentTarget=p[m],this.notifyTarget(i,l),i.propagationStopped||i.propagationImmediatelyStopped)return}}all(i,l,p=this._allInteractiveElements){if(0===p.length)return;i.eventPhase=i.BUBBLING_PHASE;const m=Array.isArray(l)?l:[l];for(let l=p.length-1;l>=0;l--)m.forEach((m=>{i.currentTarget=p[l],this.notifyTarget(i,m)}))}propagationPath(i){const l=[i];for(let p=0;p<2048&&i!==this.rootTarget&&i.parent;p++){if(!i.parent)throw new Error("Cannot find propagation path to disconnected target");l.push(i.parent),i=i.parent}return l.reverse(),l}hitTestMoveRecursive(i,l,p,m,_,y=!1){let x=!1;if(this._interactivePrune(i))return null;if("dynamic"!==i.eventMode&&"dynamic"!==l||(ys.pauseUpdate=!1),i.interactiveChildren&&i.children){const v=i.children;for(let T=v.length-1;T>=0;T--){const S=v[T],P=this.hitTestMoveRecursive(S,this._isInteractive(l)?l:S.eventMode,p,m,_,y||_(i,p));if(P){if(P.length>0&&!P[P.length-1].parent)continue;const l=i.isInteractive();(P.length>0||l)&&(l&&this._allInteractiveElements.push(i),P.push(i)),0===this._hitElements.length&&(this._hitElements=P),x=!0}}}const v=this._isInteractive(l),T=i.isInteractive();return T&&T&&this._allInteractiveElements.push(i),y||this._hitElements.length>0?null:x?this._hitElements:v&&!_(i,p)&&m(i,p)?T?[i]:[]:null}hitTestRecursive(i,l,p,m,_){if(this._interactivePrune(i)||_(i,p))return null;if("dynamic"!==i.eventMode&&"dynamic"!==l||(ys.pauseUpdate=!1),i.interactiveChildren&&i.children){const y=i.children,x=p;for(let p=y.length-1;p>=0;p--){const v=y[p],T=this.hitTestRecursive(v,this._isInteractive(l)?l:v.eventMode,x,m,_);if(T){if(T.length>0&&!T[T.length-1].parent)continue;const l=i.isInteractive();return(T.length>0||l)&&T.push(i),T}}}const y=this._isInteractive(l),x=i.isInteractive();return y&&m(i,p)?x?[i]:[]:null}_isInteractive(i){return"static"===i||"dynamic"===i}_interactivePrune(i){return!(i&&i.visible&&i.renderable&&i.includeInBuild&&i.measurable)||("none"===i.eventMode||"passive"===i.eventMode&&!i.interactiveChildren)}hitPruneFn(i,l){if(i.hitArea&&(i.worldTransform.applyInverse(l,vs),!i.hitArea.contains(vs.x,vs.y)))return!0;if(i.effects&&i.effects.length)for(let p=0;p<i.effects.length;p++){const m=i.effects[p];if(m.containsPoint){if(!m.containsPoint(l,this.hitTestFn))return!0}}return!1}hitTestFn(i,l){return!!i.hitArea||!!i?.containsPoint&&(i.worldTransform.applyInverse(l,vs),i.containsPoint(vs))}notifyTarget(i,l){if(!i.currentTarget.isInteractive())return;const p=`on${l=l??i.type}`;i.currentTarget[p]?.(i);const m=i.eventPhase===i.CAPTURING_PHASE||i.eventPhase===i.AT_TARGET?`${l}capture`:l;this._notifyListeners(i,m),i.eventPhase===i.AT_TARGET&&this._notifyListeners(i,l)}mapPointerDown(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.createPointerEvent(i);if(this.dispatchEvent(l,"pointerdown"),"touch"===l.pointerType)this.dispatchEvent(l,"touchstart");else if("mouse"===l.pointerType||"pen"===l.pointerType){const i=2===l.button;this.dispatchEvent(l,i?"rightdown":"mousedown")}this.trackingData(i.pointerId).pressTargetsByButton[i.button]=l.composedPath(),this.freeEvent(l)}mapPointerMove(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const l=this.createPointerEvent(i);this._isPointerMoveEvent=!1;const p="mouse"===l.pointerType||"pen"===l.pointerType,m=this.trackingData(i.pointerId),_=this.findMountedTarget(m.overTargets);if(m.overTargets?.length>0&&_!==l.target){const m="mousemove"===i.type?"mouseout":"pointerout",y=this.createPointerEvent(i,m,_);if(this.dispatchEvent(y,"pointerout"),p&&this.dispatchEvent(y,"mouseout"),!l.composedPath().includes(_)){const m=this.createPointerEvent(i,"pointerleave",_);for(m.eventPhase=m.AT_TARGET;m.target&&!l.composedPath().includes(m.target);)m.currentTarget=m.target,this.notifyTarget(m),p&&this.notifyTarget(m,"mouseleave"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(y)}if(_!==l.target){const m="mousemove"===i.type?"mouseover":"pointerover",y=this.clonePointerEvent(l,m);this.dispatchEvent(y,"pointerover"),p&&this.dispatchEvent(y,"mouseover");let x=_?.parent;for(;x&&x!==this.rootTarget.parent&&x!==l.target;)x=x.parent;if(!x||x===this.rootTarget.parent){const i=this.clonePointerEvent(l,"pointerenter");for(i.eventPhase=i.AT_TARGET;i.target&&i.target!==_&&i.target!==this.rootTarget.parent;)i.currentTarget=i.target,this.notifyTarget(i),p&&this.notifyTarget(i,"mouseenter"),i.target=i.target.parent;this.freeEvent(i)}this.freeEvent(y)}const y=[],x=this.enableGlobalMoveEvents??!0;this.moveOnAll?y.push("pointermove"):this.dispatchEvent(l,"pointermove"),x&&y.push("globalpointermove"),"touch"===l.pointerType&&(this.moveOnAll?y.splice(1,0,"touchmove"):this.dispatchEvent(l,"touchmove"),x&&y.push("globaltouchmove")),p&&(this.moveOnAll?y.splice(1,0,"mousemove"):this.dispatchEvent(l,"mousemove"),x&&y.push("globalmousemove"),this.cursor=l.target?.cursor),y.length>0&&this.all(l,y),this._allInteractiveElements.length=0,this._hitElements.length=0,m.overTargets=l.composedPath(),this.freeEvent(l)}mapPointerOver(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.trackingData(i.pointerId),p=this.createPointerEvent(i),m="mouse"===p.pointerType||"pen"===p.pointerType;this.dispatchEvent(p,"pointerover"),m&&this.dispatchEvent(p,"mouseover"),"mouse"===p.pointerType&&(this.cursor=p.target?.cursor);const _=this.clonePointerEvent(p,"pointerenter");for(_.eventPhase=_.AT_TARGET;_.target&&_.target!==this.rootTarget.parent;)_.currentTarget=_.target,this.notifyTarget(_),m&&this.notifyTarget(_,"mouseenter"),_.target=_.target.parent;l.overTargets=p.composedPath(),this.freeEvent(p),this.freeEvent(_)}mapPointerOut(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.trackingData(i.pointerId);if(l.overTargets){const p="mouse"===i.pointerType||"pen"===i.pointerType,m=this.findMountedTarget(l.overTargets),_=this.createPointerEvent(i,"pointerout",m);this.dispatchEvent(_),p&&this.dispatchEvent(_,"mouseout");const y=this.createPointerEvent(i,"pointerleave",m);for(y.eventPhase=y.AT_TARGET;y.target&&y.target!==this.rootTarget.parent;)y.currentTarget=y.target,this.notifyTarget(y),p&&this.notifyTarget(y,"mouseleave"),y.target=y.target.parent;l.overTargets=null,this.freeEvent(_),this.freeEvent(y)}this.cursor=null}mapPointerUp(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=performance.now(),p=this.createPointerEvent(i);if(this.dispatchEvent(p,"pointerup"),"touch"===p.pointerType)this.dispatchEvent(p,"touchend");else if("mouse"===p.pointerType||"pen"===p.pointerType){const i=2===p.button;this.dispatchEvent(p,i?"rightup":"mouseup")}const m=this.trackingData(i.pointerId),_=this.findMountedTarget(m.pressTargetsByButton[i.button]);let y=_;if(_&&!p.composedPath().includes(_)){let l=_;for(;l&&!p.composedPath().includes(l);){if(p.currentTarget=l,this.notifyTarget(p,"pointerupoutside"),"touch"===p.pointerType)this.notifyTarget(p,"touchendoutside");else if("mouse"===p.pointerType||"pen"===p.pointerType){const i=2===p.button;this.notifyTarget(p,i?"rightupoutside":"mouseupoutside")}l=l.parent}delete m.pressTargetsByButton[i.button],y=l}if(y){const _=this.clonePointerEvent(p,"click");_.target=y,_.path=null,m.clicksByButton[i.button]||(m.clicksByButton[i.button]={clickCount:0,target:_.target,timeStamp:l});const x=m.clicksByButton[i.button];if(x.target===_.target&&l-x.timeStamp<200?++x.clickCount:x.clickCount=1,x.target=_.target,x.timeStamp=l,_.detail=x.clickCount,"mouse"===_.pointerType){const i=2===_.button;this.dispatchEvent(_,i?"rightclick":"click")}else"touch"===_.pointerType&&this.dispatchEvent(_,"tap");this.dispatchEvent(_,"pointertap"),this.freeEvent(_)}this.freeEvent(p)}mapPointerUpOutside(i){if(!(i instanceof FederatedPointerEvent))return void warn("EventBoundary cannot map a non-pointer event as a pointer event");const l=this.trackingData(i.pointerId),p=this.findMountedTarget(l.pressTargetsByButton[i.button]),m=this.createPointerEvent(i);if(p){let _=p;for(;_;)m.currentTarget=_,this.notifyTarget(m,"pointerupoutside"),"touch"===m.pointerType?this.notifyTarget(m,"touchendoutside"):"mouse"!==m.pointerType&&"pen"!==m.pointerType||this.notifyTarget(m,2===m.button?"rightupoutside":"mouseupoutside"),_=_.parent;delete l.pressTargetsByButton[i.button]}this.freeEvent(m)}mapWheel(i){if(!(i instanceof FederatedWheelEvent))return void warn("EventBoundary cannot map a non-wheel event as a wheel event");const l=this.createWheelEvent(i);this.dispatchEvent(l),this.freeEvent(l)}findMountedTarget(i){if(!i)return null;let l=i[0];for(let p=1;p<i.length&&i[p].parent===l;p++)l=i[p];return l}createPointerEvent(i,l,p){const m=this.allocateEvent(FederatedPointerEvent);return this.copyPointerData(i,m),this.copyMouseData(i,m),this.copyData(i,m),m.nativeEvent=i.nativeEvent,m.originalEvent=i,m.target=p??this.hitTest(m.global.x,m.global.y)??this._hitElements[0],"string"==typeof l&&(m.type=l),m}createWheelEvent(i){const l=this.allocateEvent(FederatedWheelEvent);return this.copyWheelData(i,l),this.copyMouseData(i,l),this.copyData(i,l),l.nativeEvent=i.nativeEvent,l.originalEvent=i,l.target=this.hitTest(l.global.x,l.global.y),l}clonePointerEvent(i,l){const p=this.allocateEvent(FederatedPointerEvent);return p.nativeEvent=i.nativeEvent,p.originalEvent=i.originalEvent,this.copyPointerData(i,p),this.copyMouseData(i,p),this.copyData(i,p),p.target=i.target,p.path=i.composedPath().slice(),p.type=l??p.type,p}copyWheelData(i,l){l.deltaMode=i.deltaMode,l.deltaX=i.deltaX,l.deltaY=i.deltaY,l.deltaZ=i.deltaZ}copyPointerData(i,l){i instanceof FederatedPointerEvent&&l instanceof FederatedPointerEvent&&(l.pointerId=i.pointerId,l.width=i.width,l.height=i.height,l.isPrimary=i.isPrimary,l.pointerType=i.pointerType,l.pressure=i.pressure,l.tangentialPressure=i.tangentialPressure,l.tiltX=i.tiltX,l.tiltY=i.tiltY,l.twist=i.twist)}copyMouseData(i,l){i instanceof FederatedMouseEvent&&l instanceof FederatedMouseEvent&&(l.altKey=i.altKey,l.button=i.button,l.buttons=i.buttons,l.client.copyFrom(i.client),l.ctrlKey=i.ctrlKey,l.metaKey=i.metaKey,l.movement.copyFrom(i.movement),l.screen.copyFrom(i.screen),l.shiftKey=i.shiftKey,l.global.copyFrom(i.global))}copyData(i,l){l.isTrusted=i.isTrusted,l.srcElement=i.srcElement,l.timeStamp=performance.now(),l.type=i.type,l.detail=i.detail,l.view=i.view,l.which=i.which,l.layer.copyFrom(i.layer),l.page.copyFrom(i.page)}trackingData(i){return this.mappingState.trackingData[i]||(this.mappingState.trackingData[i]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[i]}allocateEvent(i){this.eventPool.has(i)||this.eventPool.set(i,[]);const l=this.eventPool.get(i).pop()||new i(this);return l.eventPhase=l.NONE,l.currentTarget=null,l.path=null,l.target=null,l}freeEvent(i){if(i.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const l=i.constructor;this.eventPool.has(l)||this.eventPool.set(l,[]),this.eventPool.get(l).push(i)}_notifyListeners(i,l){const p=i.currentTarget._events[l];if(p)if("fn"in p)p.once&&i.currentTarget.removeListener(l,p.fn,void 0,!0),p.fn.call(p.context,i);else for(let m=0,_=p.length;m<_&&!i.propagationImmediatelyStopped;m++)p[m].once&&i.currentTarget.removeListener(l,p[m].fn,void 0,!0),p[m].fn.call(p[m].context,i)}}const bs={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},ws=class _EventSystem{constructor(i){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=i,this.rootBoundary=new EventBoundary(null),ys.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new FederatedPointerEvent(null),this._rootWheelEvent=new FederatedWheelEvent(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({..._EventSystem.defaultEventFeatures},{set:(i,l,p)=>("globalMove"===l&&(this.rootBoundary.enableGlobalMoveEvents=p),i[l]=p,!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(i){const{canvas:l,resolution:p}=this.renderer;this.setTargetElement(l),this.resolution=p,_EventSystem._defaultEventMode=i.eventMode??"passive",Object.assign(this.features,i.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(i){this.resolution=i}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(i){i=i||"default";let l=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(l=!1),this._currentCursor===i)return;this._currentCursor=i;const p=this.cursorStyles[i];if(p)switch(typeof p){case"string":l&&(this.domElement.style.cursor=p);break;case"function":p(i);break;case"object":l&&Object.assign(this.domElement.style,p)}else l&&"string"==typeof i&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,i)&&(this.domElement.style.cursor=i)}get pointer(){return this._rootPointerEvent}_onPointerDown(i){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const l=this._normalizeToPointerData(i);if(this.autoPreventDefault&&l[0].isNormalized){(i.cancelable||!("cancelable"in i))&&i.preventDefault()}for(let i=0,p=l.length;i<p;i++){const p=l[i],m=this._bootstrapEvent(this._rootPointerEvent,p);this.rootBoundary.mapEvent(m)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(i){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ys.pointerMoved();const l=this._normalizeToPointerData(i);for(let i=0,p=l.length;i<p;i++){const p=this._bootstrapEvent(this._rootPointerEvent,l[i]);this.rootBoundary.mapEvent(p)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(i){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let l=i.target;i.composedPath&&i.composedPath().length>0&&(l=i.composedPath()[0]);const p=l!==this.domElement?"outside":"",m=this._normalizeToPointerData(i);for(let i=0,l=m.length;i<l;i++){const l=this._bootstrapEvent(this._rootPointerEvent,m[i]);l.type+=p,this.rootBoundary.mapEvent(l)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(i){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const l=this._normalizeToPointerData(i);for(let i=0,p=l.length;i<p;i++){const p=this._bootstrapEvent(this._rootPointerEvent,l[i]);this.rootBoundary.mapEvent(p)}this.setCursor(this.rootBoundary.cursor)}onWheel(i){if(!this.features.wheel)return;const l=this.normalizeWheelEvent(i);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(l)}setTargetElement(i){this._removeEvents(),this.domElement=i,ys.domElement=i,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;ys.addTickerListener();const i=this.domElement.style;i&&(globalThis.navigator.msPointerEnabled?(i.msContentZooming="none",i.msTouchAction="none"):this.supportsPointerEvents&&(i.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;ys.removeTickerListener();const i=this.domElement.style;i&&(globalThis.navigator.msPointerEnabled?(i.msContentZooming="",i.msTouchAction=""):this.supportsPointerEvents&&(i.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(i,l,p){const m=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},_=1/this.resolution;i.x=(l-m.left)*(this.domElement.width/m.width)*_,i.y=(p-m.top)*(this.domElement.height/m.height)*_}_normalizeToPointerData(i){const l=[];if(this.supportsTouchEvents&&i instanceof TouchEvent)for(let p=0,m=i.changedTouches.length;p<m;p++){const m=i.changedTouches[p];void 0===m.button&&(m.button=0),void 0===m.buttons&&(m.buttons=1),void 0===m.isPrimary&&(m.isPrimary=1===i.touches.length&&"touchstart"===i.type),void 0===m.width&&(m.width=m.radiusX||1),void 0===m.height&&(m.height=m.radiusY||1),void 0===m.tiltX&&(m.tiltX=0),void 0===m.tiltY&&(m.tiltY=0),void 0===m.pointerType&&(m.pointerType="touch"),void 0===m.pointerId&&(m.pointerId=m.identifier||0),void 0===m.pressure&&(m.pressure=m.force||.5),void 0===m.twist&&(m.twist=0),void 0===m.tangentialPressure&&(m.tangentialPressure=0),void 0===m.layerX&&(m.layerX=m.offsetX=m.clientX),void 0===m.layerY&&(m.layerY=m.offsetY=m.clientY),m.isNormalized=!0,m.type=i.type,l.push(m)}else if(globalThis.MouseEvent&&(!(i instanceof MouseEvent)||this.supportsPointerEvents&&i instanceof globalThis.PointerEvent))l.push(i);else{const p=i;void 0===p.isPrimary&&(p.isPrimary=!0),void 0===p.width&&(p.width=1),void 0===p.height&&(p.height=1),void 0===p.tiltX&&(p.tiltX=0),void 0===p.tiltY&&(p.tiltY=0),void 0===p.pointerType&&(p.pointerType="mouse"),void 0===p.pointerId&&(p.pointerId=1),void 0===p.pressure&&(p.pressure=.5),void 0===p.twist&&(p.twist=0),void 0===p.tangentialPressure&&(p.tangentialPressure=0),p.isNormalized=!0,l.push(p)}return l}normalizeWheelEvent(i){const l=this._rootWheelEvent;return this._transferMouseData(l,i),l.deltaX=i.deltaX,l.deltaY=i.deltaY,l.deltaZ=i.deltaZ,l.deltaMode=i.deltaMode,this.mapPositionToPoint(l.screen,i.clientX,i.clientY),l.global.copyFrom(l.screen),l.offset.copyFrom(l.screen),l.nativeEvent=i,l.type=i.type,l}_bootstrapEvent(i,l){return i.originalEvent=null,i.nativeEvent=l,i.pointerId=l.pointerId,i.width=l.width,i.height=l.height,i.isPrimary=l.isPrimary,i.pointerType=l.pointerType,i.pressure=l.pressure,i.tangentialPressure=l.tangentialPressure,i.tiltX=l.tiltX,i.tiltY=l.tiltY,i.twist=l.twist,this._transferMouseData(i,l),this.mapPositionToPoint(i.screen,l.clientX,l.clientY),i.global.copyFrom(i.screen),i.offset.copyFrom(i.screen),i.isTrusted=l.isTrusted,"pointerleave"===i.type&&(i.type="pointerout"),i.type.startsWith("mouse")&&(i.type=i.type.replace("mouse","pointer")),i.type.startsWith("touch")&&(i.type=bs[i.type]||i.type),i}_transferMouseData(i,l){i.isTrusted=l.isTrusted,i.srcElement=l.srcElement,i.timeStamp=performance.now(),i.type=l.type,i.altKey=l.altKey,i.button=l.button,i.buttons=l.buttons,i.client.x=l.clientX,i.client.y=l.clientY,i.ctrlKey=l.ctrlKey,i.metaKey=l.metaKey,i.movement.x=l.movementX,i.movement.y=l.movementY,i.page.x=l.pageX,i.page.y=l.pageY,i.relatedTarget=null,i.shiftKey=l.shiftKey}};ws.extension={name:"events",type:[O.WebGLSystem,O.CanvasSystem,O.WebGPUSystem],priority:-1},ws.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ts=ws;const Ss={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"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(i){this.eventMode=i?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ts.defaultEventMode},set eventMode(i){this._internalEventMode=i},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(i,l,p){const m="boolean"==typeof p&&p||"object"==typeof p&&p.capture,_="object"==typeof p?p.signal:void 0,y="object"==typeof p&&!0===p.once,x="function"==typeof l?void 0:l;i=m?`${i}capture`:i;const v="function"==typeof l?l:l.handleEvent,T=this;_&&_.addEventListener("abort",(()=>{T.off(i,v,x)})),y?T.once(i,v,x):T.on(i,v,x)},removeEventListener(i,l,p){const m="function"==typeof l?void 0:l;i="boolean"==typeof p&&p||"object"==typeof p&&p.capture?`${i}capture`:i,l="function"==typeof l?l:l.handleEvent,this.off(i,l,m)},dispatchEvent(i){if(!(i instanceof FederatedEvent))throw new Error("Container cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};let Ps=0;const Ms=new class TexturePoolClass{constructor(i){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=i||{},this.enableFullScreen=!1}createTexture(i,l,p){const m=new gt({...this.textureOptions,width:i,height:l,resolution:1,antialias:p,autoGarbageCollect:!0});return new Texture({source:m,label:"texturePool_"+Ps++})}getOptimalTexture(i,l,p=1,m){let _=Math.ceil(i*p-1e-6),y=Math.ceil(l*p-1e-6);_=nextPow2(_),y=nextPow2(y);const x=(_<<17)+(y<<1)+(m?1:0);this._texturePool[x]||(this._texturePool[x]=[]);let v=this._texturePool[x].pop();return v||(v=this.createTexture(_,y,m)),v.source._resolution=p,v.source.width=_/p,v.source.height=y/p,v.source.pixelWidth=_,v.source.pixelHeight=y,v.frame.x=0,v.frame.y=0,v.frame.width=i,v.frame.height=l,v.updateUvs(),this._poolKeyHash[v.uid]=x,v}getSameSizeTexture(i,l=!1){const p=i.source;return this.getOptimalTexture(i.width,i.height,p._resolution,l)}returnTexture(i){const l=this._poolKeyHash[i.uid];this._texturePool[l].push(i)}clear(i){if(i=!1!==i)for(const i in this._texturePool){const l=this._texturePool[i];if(l)for(let i=0;i<l.length;i++)l[i].destroy(!0)}this._texturePool={}}};class FilterPipe{constructor(i){this._renderer=i}push(i,l,p){this._renderer.renderPipes.batch.break(p),p.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:l,filterEffect:i})}pop(i,l,p){this._renderer.renderPipes.batch.break(p),p.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(i){"pushFilter"===i.action?this._renderer.filter.push(i):"popFilter"===i.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}FilterPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"filter"};const Cs=new Matrix;function getFastGlobalBounds(i,l){return l.clear(),_getGlobalBoundsRecursive(i,l),l.isValid||l.set(0,0,0,0),i.renderGroup?l.applyMatrix(i.renderGroup.localTransform):l.applyMatrix(i.parentRenderGroup.worldTransform),l}function _getGlobalBoundsRecursive(i,l){if(7!==i.localDisplayStatus||!i.measurable)return;const p=!!i.effects.length;let m=l;if((i.renderGroup||p)&&(m=Lt.get().clear()),i.boundsArea)l.addRect(i.boundsArea,i.worldTransform);else{if(i.renderPipeId){const l=i.bounds;m.addFrame(l.minX,l.minY,l.maxX,l.maxY,i.groupTransform)}const l=i.children;for(let i=0;i<l.length;i++)_getGlobalBoundsRecursive(l[i],m)}if(p){let p=!1;for(let l=0;l<i.effects.length;l++)i.effects[l].addBounds&&(p||(p=!0,m.applyMatrix(i.parentRenderGroup.worldTransform)),i.effects[l].addBounds(m,!0));p&&(m.applyMatrix(i.parentRenderGroup.worldTransform.copyTo(Cs).invert()),l.addBounds(m,i.relativeGroupTransform)),l.addBounds(m),Lt.return(m)}else i.renderGroup&&(l.addBounds(m,i.relativeGroupTransform),Lt.return(m))}const Es=new Geometry({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class FilterSystem{constructor(i){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Ke({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 BindGroup({}),this.renderer=i}get activeBackTexture(){return this._activeFilterData?.backTexture}push(i){const l=this.renderer,p=i.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const m=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,0===p.length)return void(m.skip=!0);const _=m.bounds;i.renderables?function getGlobalRenderableBounds(i,l){l.clear();const p=l.matrix;for(let p=0;p<i.length;p++){const m=i[p];m.globalDisplayStatus<7||(l.matrix=m.worldTransform,m.addBounds(l))}return l.matrix=p,l}(i.renderables,_):i.filterEffect.filterArea?(_.clear(),_.addRect(i.filterEffect.filterArea),_.applyMatrix(i.container.worldTransform)):getFastGlobalBounds(i.container,_);const y=l.renderTarget.renderTarget.colorTexture.source;let x=1/0,v=0,T=!0,S=!1,P=!1;for(let i=0;i<p.length;i++){const m=p[i];x=Math.min(x,"inherit"===m.resolution?y._resolution:m.resolution),v+=m.padding,"off"===m.antialias?T=!1:"inherit"===m.antialias&&T&&(T=y.antialias);if(!!!(m.compatibleRenderers&l.type)){P=!1;break}if(m.blendRequired&&!(l.backBuffer?.useBackBuffer??1)){warn("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),P=!1;break}P=m.enabled||P,S=S||m.blendRequired}if(!P)return void(m.skip=!0);const C=l.renderTarget.rootViewPort;_.scale(x).fitBounds(0,C.width,0,C.height).ceil().scale(1/x).pad(0|v),_.isPositive?(m.skip=!1,m.bounds=_,m.blendRequired=S,m.container=i.container,m.filterEffect=i.filterEffect,m.previousRenderSurface=l.renderTarget.renderSurface,m.inputTexture=Ms.getOptimalTexture(_.width,_.height,x,T),l.renderTarget.bind(m.inputTexture,!0),l.globalUniforms.push({offset:_})):m.skip=!0}pop(){const i=this.renderer;this._filterStackIndex--;const l=this._filterStack[this._filterStackIndex];if(l.skip)return;this._activeFilterData=l;const p=l.inputTexture,m=l.bounds;let _=Texture.EMPTY;if(i.renderTarget.finishRenderPass(),l.blendRequired){const p=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,y=i.renderTarget.getRenderTarget(l.previousRenderSurface);_=this.getBackTexture(y,m,p)}l.backTexture=_;const y=l.filterEffect.filters;if(this._globalFilterBindGroup.setResource(p.source.style,2),this._globalFilterBindGroup.setResource(_.source,3),i.globalUniforms.pop(),1===y.length)y[0].apply(this,p,l.previousRenderSurface,!1),Ms.returnTexture(p);else{let i=l.inputTexture,p=Ms.getOptimalTexture(m.width,m.height,i.source._resolution,!1),_=0;for(_=0;_<y.length-1;++_){y[_].apply(this,i,p,!0);const l=i;i=p,p=l}y[_].apply(this,i,l.previousRenderSurface,!1),Ms.returnTexture(i),Ms.returnTexture(p)}l.blendRequired&&Ms.returnTexture(_)}getBackTexture(i,l,p){const m=i.colorTexture.source._resolution,_=Ms.getOptimalTexture(l.width,l.height,m,!1);let y=l.minX,x=l.minY;p&&(y-=p.minX,x-=p.minY),y=Math.floor(y*m),x=Math.floor(x*m);const v=Math.ceil(l.width*m),T=Math.ceil(l.height*m);return this.renderer.renderTarget.copyToTexture(i,_,{x:y,y:x},{width:v,height:T},{x:0,y:0}),_}applyFilter(i,l,p,m){const _=this.renderer,y=this._filterStack[this._filterStackIndex],x=y.bounds,v=Point.shared,T=y.previousRenderSurface===p;let S=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,P=this._filterStackIndex-1;for(;P>0&&this._filterStack[P].skip;)--P;P>0&&(S=this._filterStack[P].inputTexture.source._resolution);const C=this._filterGlobalUniforms,E=C.uniforms,A=E.uOutputFrame,k=E.uInputSize,B=E.uInputPixel,F=E.uInputClamp,R=E.uGlobalFrame,I=E.uOutputTexture;if(T){let i=this._filterStackIndex;for(;i>0;){i--;const l=this._filterStack[this._filterStackIndex-1];if(!l.skip){v.x=l.bounds.minX,v.y=l.bounds.minY;break}}A[0]=x.minX-v.x,A[1]=x.minY-v.y}else A[0]=0,A[1]=0;A[2]=l.frame.width,A[3]=l.frame.height,k[0]=l.source.width,k[1]=l.source.height,k[2]=1/k[0],k[3]=1/k[1],B[0]=l.source.pixelWidth,B[1]=l.source.pixelHeight,B[2]=1/B[0],B[3]=1/B[1],F[0]=.5*B[2],F[1]=.5*B[3],F[2]=l.frame.width*k[2]-.5*B[2],F[3]=l.frame.height*k[3]-.5*B[3];const D=this.renderer.renderTarget.rootRenderTarget.colorTexture;R[0]=v.x*S,R[1]=v.y*S,R[2]=D.source.width*S,R[3]=D.source.height*S;const L=this.renderer.renderTarget.getRenderTarget(p);if(_.renderTarget.bind(p,!!m),p instanceof Texture?(I[0]=p.frame.width,I[1]=p.frame.height):(I[0]=L.width,I[1]=L.height),I[2]=L.isRoot?-1:1,C.update(),_.renderPipes.uniformBatch){const i=_.renderPipes.uniformBatch.getUboResource(C);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(C,0);this._globalFilterBindGroup.setResource(l.source,1),this._globalFilterBindGroup.setResource(l.source.style,2),i.groups[0]=this._globalFilterBindGroup,_.encoder.draw({geometry:Es,shader:i,state:i._state,topology:"triangle-list"}),_.type===Ye.WEBGL&&_.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new Bounds,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(i,l){const p=this._activeFilterData,m=i.set(p.inputTexture._source.width,0,0,p.inputTexture._source.height,p.bounds.minX,p.bounds.minY),_=l.worldTransform.copyTo(Matrix.shared);return _.invert(),m.prepend(_),m.scale(1/l.texture.frame.width,1/l.texture.frame.height),m.translate(l.anchor.x,l.anchor.y),m}}FilterSystem.extension={type:[O.WebGLSystem,O.WebGPUSystem],name:"filter"};class Graphics extends ViewContainer{constructor(i){i instanceof ns&&(i={context:i});const{context:l,roundPixels:p,...m}=i||{};super({label:"Graphics",...m}),this.renderPipeId="graphics",this._context=l||(this._ownedContext=new ns),this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=p??!1}set context(i){i!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=i,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(i){i.addBounds(this._context.bounds)}containsPoint(i){return this._context.containsPoint(i)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const i=this.renderGroup||this.parentRenderGroup;i&&i.onChildViewUpdate(this)}destroy(i){this._ownedContext&&!i?this._ownedContext.destroy(i):!0!==i&&!0!==i?.context||this._context.destroy(i),this._ownedContext=null,this._context=null,super.destroy(i)}_callContextMethod(i,l){return this.context[i](...l),this}setFillStyle(...i){return this._callContextMethod("setFillStyle",i)}setStrokeStyle(...i){return this._callContextMethod("setStrokeStyle",i)}fill(...i){return this._callContextMethod("fill",i)}stroke(...i){return this._callContextMethod("stroke",i)}texture(...i){return this._callContextMethod("texture",i)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...i){return this._callContextMethod("arc",i)}arcTo(...i){return this._callContextMethod("arcTo",i)}arcToSvg(...i){return this._callContextMethod("arcToSvg",i)}bezierCurveTo(...i){return this._callContextMethod("bezierCurveTo",i)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...i){return this._callContextMethod("ellipse",i)}circle(...i){return this._callContextMethod("circle",i)}path(...i){return this._callContextMethod("path",i)}lineTo(...i){return this._callContextMethod("lineTo",i)}moveTo(...i){return this._callContextMethod("moveTo",i)}quadraticCurveTo(...i){return this._callContextMethod("quadraticCurveTo",i)}rect(...i){return this._callContextMethod("rect",i)}roundRect(...i){return this._callContextMethod("roundRect",i)}poly(...i){return this._callContextMethod("poly",i)}regularPoly(...i){return this._callContextMethod("regularPoly",i)}roundPoly(...i){return this._callContextMethod("roundPoly",i)}roundShape(...i){return this._callContextMethod("roundShape",i)}filletRect(...i){return this._callContextMethod("filletRect",i)}chamferRect(...i){return this._callContextMethod("chamferRect",i)}star(...i){return this._callContextMethod("star",i)}svg(...i){return this._callContextMethod("svg",i)}restore(...i){return this._callContextMethod("restore",i)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...i){return this._callContextMethod("rotate",i)}scaleTransform(...i){return this._callContextMethod("scale",i)}setTransform(...i){return this._callContextMethod("setTransform",i)}transform(...i){return this._callContextMethod("transform",i)}translateTransform(...i){return this._callContextMethod("translate",i)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(i){this._context.fillStyle=i}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(i){this._context.strokeStyle=i}clone(i=!1){if(i)return new Graphics(this._context.clone());this._ownedContext=null;return new Graphics(this._context)}lineStyle(i,l,p){deprecation(ut,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const m={};return i&&(m.width=i),l&&(m.color=l),p&&(m.alpha=p),this.context.strokeStyle=m,this}beginFill(i,l){deprecation(ut,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const p={};return i&&(p.color=i),l&&(p.alpha=l),this.context.fillStyle=p,this}endFill(){deprecation(ut,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const i=this.context.strokeStyle;return i.width===ns.defaultStrokeStyle.width&&i.color===ns.defaultStrokeStyle.color&&i.alpha===ns.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...i){return deprecation(ut,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",i)}drawEllipse(...i){return deprecation(ut,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",i)}drawPolygon(...i){return deprecation(ut,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",i)}drawRect(...i){return deprecation(ut,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",i)}drawRoundedRect(...i){return deprecation(ut,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",i)}drawStar(...i){return deprecation(ut,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",i)}}const As=class _MeshGeometry extends Geometry{constructor(...i){let l=i[0]??{};l instanceof Float32Array&&(deprecation(ut,"use new MeshGeometry({ positions, uvs, indices }) instead"),l={positions:l,uvs:i[1],indices:i[2]}),l={..._MeshGeometry.defaultOptions,...l};const p=l.positions||new Float32Array([0,0,1,0,1,1,0,1]),m=l.uvs||new Float32Array([0,0,1,0,1,1,0,1]),_=l.indices||new Uint32Array([0,1,2,0,2,3]),y=l.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new Buffer({data:p,label:"attribute-mesh-positions",shrinkToFit:y,usage:mi.VERTEX|mi.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new Buffer({data:m,label:"attribute-mesh-uvs",shrinkToFit:y,usage:mi.VERTEX|mi.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new Buffer({data:_,label:"index-mesh-buffer",shrinkToFit:y,usage:mi.INDEX|mi.COPY_DST}),topology:l.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(i){this.attributes.aPosition.buffer.data=i}get uvs(){return this.attributes.aUV.buffer.data}set uvs(i){this.attributes.aUV.buffer.data=i}get indices(){return this.indexBuffer.data}set indices(i){this.indexBuffer.data=i}};As.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ks=As;function textStyleToCSS(i){const l=i._stroke,p=i._fill,m=[`div { ${[`color: ${At.shared.setValue(p.color).toHex()}`,`font-size: ${i.fontSize}px`,`font-family: ${i.fontFamily}`,`font-weight: ${i.fontWeight}`,`font-style: ${i.fontStyle}`,`font-variant: ${i.fontVariant}`,`letter-spacing: ${i.letterSpacing}px`,`text-align: ${i.align}`,`padding: ${i.padding}px`,`white-space: ${"pre"===i.whiteSpace&&i.wordWrap?"pre-wrap":i.whiteSpace}`,...i.lineHeight?[`line-height: ${i.lineHeight}px`]:[],...i.wordWrap?["word-wrap: "+(i.breakWords?"break-all":"break-word"),`max-width: ${i.wordWrapWidth}px`]:[],...l?[strokeToCSS(l)]:[],...i.dropShadow?[dropShadowToCSS(i.dropShadow)]:[],...i.cssOverrides].join(";")} }`];return function tagStyleToCSS(i,l){for(const p in i){const m=i[p],_=[];for(const i in m)Fs[i]?_.push(Fs[i](m[i])):Bs[i]&&_.push(Bs[i].replace("{{VALUE}}",m[i]));l.push(`${p} { ${_.join(";")} }`)}}(i.tagStyles,m),m.join(" ")}function dropShadowToCSS(i){const l=At.shared.setValue(i.color).setAlpha(i.alpha).toHexa(),p=`${Math.round(Math.cos(i.angle)*i.distance)}px ${Math.round(Math.sin(i.angle)*i.distance)}px`;return i.blur>0?`text-shadow: ${p} ${i.blur}px ${l}`:`text-shadow: ${p} ${l}`}function strokeToCSS(i){return[`-webkit-text-stroke-width: ${i.width}px`,`-webkit-text-stroke-color: ${At.shared.setValue(i.color).toHex()}`,`text-stroke-width: ${i.width}px`,`text-stroke-color: ${At.shared.setValue(i.color).toHex()}`,"paint-order: stroke"].join(";")}const Bs={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Fs={fill:i=>`color: ${At.shared.setValue(i).toHex()}`,breakWords:i=>"word-wrap: "+(i?"break-all":"break-word"),stroke:strokeToCSS,dropShadow:dropShadowToCSS};class HTMLTextStyle extends hs{constructor(i={}){super(i),this._cssOverrides=[],this.cssOverrides??(this.cssOverrides=i.cssOverrides),this.tagStyles=i.tagStyles??{}}set cssOverrides(i){this._cssOverrides=i instanceof Array?i:[i],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=generateTextStyleKey(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new HTMLTextStyle({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?{...this.dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=textStyleToCSS(this)),this._cssStyle}addOverride(...i){const l=i.filter((i=>!this.cssOverrides.includes(i)));l.length>0&&(this.cssOverrides.push(...l),this.update())}removeOverride(...i){const l=i.filter((i=>this.cssOverrides.includes(i)));l.length>0&&(this.cssOverrides=this.cssOverrides.filter((i=>!l.includes(i))),this.update())}set fill(i){"string"!=typeof i&&"number"!=typeof i&&warn("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=i}set stroke(i){i&&"string"!=typeof i&&"number"!=typeof i&&warn("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=i}}const Rs="http://www.w3.org/2000/svg",Is="http://www.w3.org/1999/xhtml";class HTMLTextRenderData{constructor(){this.svgRoot=document.createElementNS(Rs,"svg"),this.foreignObject=document.createElementNS(Rs,"foreignObject"),this.domElement=document.createElementNS(Is,"div"),this.styleElement=document.createElementNS(Is,"style"),this.image=new Image;const{foreignObject:i,svgRoot:l,styleElement:p,domElement:m}=this;i.setAttribute("width","10000"),i.setAttribute("height","10000"),i.style.overflow="hidden",l.appendChild(i),i.appendChild(p),i.appendChild(m)}}let Ds;const Ls={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}};Ls.vertex,Ls.vertex.header.replace("group(1)","group(2)");const Us={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}};class BatchableSprite{constructor(){this.batcherName="default",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}}function color32BitToUniform(i,l,p){const m=(i>>24&255)/255;l[p++]=(255&i)/255*m,l[p++]=(i>>8&255)/255*m,l[p++]=(i>>16&255)/255*m,l[p++]=m}class GraphicsPipe{constructor(i,l){this.state=Xe.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=i,this._adaptor=l,this._adaptor.init()}validateRenderable(i){const l=i.context,p=!!this._graphicsBatchesHash[i.uid],m=this.renderer.graphicsContext.updateGpuContext(l);return!(!m.isBatchable&&p===m.isBatchable)}addRenderable(i,l){const p=this.renderer.graphicsContext.updateGpuContext(i.context);i._didGraphicsUpdate&&(i._didGraphicsUpdate=!1,this._rebuild(i)),p.isBatchable?this._addToBatcher(i,l):(this.renderer.renderPipes.batch.break(l),l.add(i))}updateRenderable(i){const l=this._graphicsBatchesHash[i.uid];if(l)for(let i=0;i<l.length;i++){const p=l[i];p._batcher.updateElement(p)}}destroyRenderable(i){this._graphicsBatchesHash[i.uid]&&this._removeBatchForRenderable(i.uid),i.off("destroyed",this._destroyRenderableBound)}execute(i){if(!i.isRenderable)return;const l=this.renderer,p=i.context;if(!l.graphicsContext.getGpuContext(p).batches.length)return;const m=p.customShader||this._adaptor.shader;this.state.blendMode=i.groupBlendMode;const _=m.resources.localUniforms.uniforms;_.uTransformMatrix=i.groupTransform,_.uRound=l._roundPixels|i._roundPixels,color32BitToUniform(i.groupColorAlpha,_.uColor,0),this._adaptor.execute(this,i)}_rebuild(i){const l=!!this._graphicsBatchesHash[i.uid],p=this.renderer.graphicsContext.updateGpuContext(i.context);l&&this._removeBatchForRenderable(i.uid),p.isBatchable&&this._initBatchesForRenderable(i),i.batched=p.isBatchable}_addToBatcher(i,l){const p=this.renderer.renderPipes.batch,m=this._getBatchesForRenderable(i);for(let i=0;i<m.length;i++){const _=m[i];p.addToBatch(_,l)}}_getBatchesForRenderable(i){return this._graphicsBatchesHash[i.uid]||this._initBatchesForRenderable(i)}_initBatchesForRenderable(i){const l=i.context,p=this.renderer.graphicsContext.getGpuContext(l),m=this.renderer._roundPixels|i._roundPixels,_=p.batches.map((l=>{const p=kt.get(BatchableGraphics);return l.copyTo(p),p.renderable=i,p.roundPixels=m,p}));return void 0===this._graphicsBatchesHash[i.uid]&&i.on("destroyed",this._destroyRenderableBound),this._graphicsBatchesHash[i.uid]=_,_}_removeBatchForRenderable(i){this._graphicsBatchesHash[i].forEach((i=>{kt.return(i)})),this._graphicsBatchesHash[i]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const i in this._graphicsBatchesHash)this._removeBatchForRenderable(i);this._graphicsBatchesHash=null}}GraphicsPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"graphics"};const Gs=class _PlaneGeometry extends ks{constructor(...i){super({});let l=i[0]??{};"number"==typeof l&&(deprecation(ut,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),l={width:l,height:i[1],verticesX:i[2],verticesY:i[3]}),this.build(l)}build(i){i={..._PlaneGeometry.defaultOptions,...i},this.verticesX=this.verticesX??i.verticesX,this.verticesY=this.verticesY??i.verticesY,this.width=this.width??i.width,this.height=this.height??i.height;const l=this.verticesX*this.verticesY,p=[],m=[],_=[],y=this.verticesX-1,x=this.verticesY-1,v=this.width/y,T=this.height/x;for(let i=0;i<l;i++){const l=i%this.verticesX,_=i/this.verticesX|0;p.push(l*v,_*T),m.push(l/y,_/x)}const S=y*x;for(let i=0;i<S;i++){const l=i%y,p=i/y|0,m=p*this.verticesX+l,x=p*this.verticesX+l+1,v=(p+1)*this.verticesX+l,T=(p+1)*this.verticesX+l+1;_.push(m,x,v,x,T,v)}this.buffers[0].data=new Float32Array(p),this.buffers[1].data=new Float32Array(m),this.indexBuffer.data=new Uint32Array(_),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Gs.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Os=Gs;class BatchableMesh{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get uvs(){const i=this.geometry.getBuffer("aUV"),l=i.data;let p=l;const m=this.texture.textureMatrix;return m.isSimple||(p=this._transformedUvs,this._textureMatrixUpdateId===m._updateID&&this._uvUpdateId===i._updateID||((!p||p.length<l.length)&&(p=this._transformedUvs=new Float32Array(l.length)),this._textureMatrixUpdateId=m._updateID,this._uvUpdateId=i._updateID,m.multiplyUvs(l,p))),p}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class MeshPipe{constructor(i,l){this.localUniforms=new Ke({uTransformMatrix:{value:new Matrix,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new BindGroup({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=i,this._adaptor=l,this._adaptor.init()}validateRenderable(i){const l=this._getMeshData(i),p=l.batched,m=i.batched;if(l.batched=m,p!==m)return!0;if(m){const p=i._geometry;if(p.indices.length!==l.indexSize||p.positions.length!==l.vertexSize)return l.indexSize=p.indices.length,l.vertexSize=p.positions.length,!0;const m=this._getBatchableMesh(i),_=i.texture;if(m.texture._source!==_._source&&m.texture._source!==_._source)return!m._batcher.checkAndUpdateTexture(m,_)}return!1}addRenderable(i,l){const p=this.renderer.renderPipes.batch,{batched:m}=this._getMeshData(i);if(m){const m=this._getBatchableMesh(i);m.texture=i._texture,m.geometry=i._geometry,p.addToBatch(m,l)}else p.break(l),l.add(i)}updateRenderable(i){if(i.batched){const l=this._gpuBatchableMeshHash[i.uid];l.texture=i._texture,l.geometry=i._geometry,l._batcher.updateElement(l)}}destroyRenderable(i){this._meshDataHash[i.uid]=null;const l=this._gpuBatchableMeshHash[i.uid];l&&(kt.return(l),this._gpuBatchableMeshHash[i.uid]=null),i.off("destroyed",this._destroyRenderableBound)}execute(i){if(!i.isRenderable)return;i.state.blendMode=getAdjustedBlendModeBlend(i.groupBlendMode,i.texture._source);const l=this.localUniforms;l.uniforms.uTransformMatrix=i.groupTransform,l.uniforms.uRound=this.renderer._roundPixels|i._roundPixels,l.update(),color32BitToUniform(i.groupColorAlpha,l.uniforms.uColor,0),this._adaptor.execute(this,i)}_getMeshData(i){return this._meshDataHash[i.uid]||this._initMeshData(i)}_initMeshData(i){return this._meshDataHash[i.uid]={batched:i.batched,indexSize:i._geometry.indices?.length,vertexSize:i._geometry.positions?.length},i.on("destroyed",this._destroyRenderableBound),this._meshDataHash[i.uid]}_getBatchableMesh(i){return this._gpuBatchableMeshHash[i.uid]||this._initBatchableMesh(i)}_initBatchableMesh(i){const l=kt.get(BatchableMesh);return l.renderable=i,l.texture=i._texture,l.transform=i.groupTransform,l.roundPixels=this.renderer._roundPixels|i._roundPixels,this._gpuBatchableMeshHash[i.uid]=l,l}destroy(){for(const i in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[i]&&kt.return(this._gpuBatchableMeshHash[i]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}MeshPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"mesh"};const zs=class _NineSliceGeometry extends Os{constructor(i={}){super({width:(i={..._NineSliceGeometry.defaultOptions,...i}).width,height:i.height,verticesX:4,verticesY:4}),this.update(i)}update(i){this.width=i.width??this.width,this.height=i.height??this.height,this._originalWidth=i.originalWidth??this._originalWidth,this._originalHeight=i.originalHeight??this._originalHeight,this._leftWidth=i.leftWidth??this._leftWidth,this._rightWidth=i.rightWidth??this._rightWidth,this._topHeight=i.topHeight??this._topHeight,this._bottomHeight=i.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const i=this.positions,l=this._leftWidth+this._rightWidth,p=this.width>l?1:this.width/l,m=this._topHeight+this._bottomHeight,_=this.height>m?1:this.height/m,y=Math.min(p,_);i[9]=i[11]=i[13]=i[15]=this._topHeight*y,i[17]=i[19]=i[21]=i[23]=this.height-this._bottomHeight*y,i[25]=i[27]=i[29]=i[31]=this.height,i[2]=i[10]=i[18]=i[26]=this._leftWidth*y,i[4]=i[12]=i[20]=i[28]=this.width-this._rightWidth*y,i[6]=i[14]=i[22]=i[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const i=this.uvs;i[0]=i[8]=i[16]=i[24]=0,i[1]=i[3]=i[5]=i[7]=0,i[6]=i[14]=i[22]=i[30]=1,i[25]=i[27]=i[29]=i[31]=1;const l=1/this._originalWidth,p=1/this._originalHeight;i[2]=i[10]=i[18]=i[26]=l*this._leftWidth,i[9]=i[11]=i[13]=i[15]=p*this._topHeight,i[4]=i[12]=i[20]=i[28]=1-l*this._rightWidth,i[17]=i[19]=i[21]=i[23]=1-p*this._bottomHeight,this.getBuffer("aUV").update()}};zs.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Ns=zs;class NineSliceSpritePipe{constructor(i){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i}addRenderable(i,l){const p=this._getGpuSprite(i);i._didSpriteUpdate&&this._updateBatchableSprite(i,p),this._renderer.renderPipes.batch.addToBatch(p,l)}updateRenderable(i){const l=this._gpuSpriteHash[i.uid];i._didSpriteUpdate&&this._updateBatchableSprite(i,l),l._batcher.updateElement(l)}validateRenderable(i){const l=i._texture,p=this._getGpuSprite(i);return p.texture._source!==l._source&&!p._batcher.checkAndUpdateTexture(p,l)}destroyRenderable(i){const l=this._gpuSpriteHash[i.uid];kt.return(l.geometry),kt.return(l),this._gpuSpriteHash[i.uid]=null,i.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(i,l){i._didSpriteUpdate=!1,l.geometry.update(i),l.texture=i._texture}_getGpuSprite(i){return this._gpuSpriteHash[i.uid]||this._initGPUSprite(i)}_initGPUSprite(i){const l=kt.get(BatchableMesh);return l.geometry=kt.get(Ns),l.renderable=i,l.transform=i.groupTransform,l.texture=i._texture,l.roundPixels=this._renderer._roundPixels|i._roundPixels,i._didSpriteUpdate=!0,this._gpuSpriteHash[i.uid]=l,i.on("destroyed",this._destroyRenderableBound),l}destroy(){for(const i in this._gpuSpriteHash){this._gpuSpriteHash[i].geometry.destroy()}this._gpuSpriteHash=null,this._renderer=null}}NineSliceSpritePipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"nineSliceSprite"};const Hs={name:"tiling-bit",vertex:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n "},fragment:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n } \n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n "}},Ws={name:"tiling-bit",vertex:{header:"\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n \n ",main:"\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n ",main:"\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n \n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n \n "}};let Ks,Ys;class TilingSpriteShader extends Shader{constructor(){Ks??(Ks=compileHighShaderGpuProgram({name:"tiling-sprite-shader",bits:[Ls,Hs,Ei]})),Ys??(Ys=compileHighShaderGlProgram({name:"tiling-sprite-shader",bits:[Us,Ws,Ai]}));const i=new Ke({uMapCoord:{value:new Matrix,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new Matrix,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Ys,gpuProgram:Ks,resources:{localUniforms:new Ke({uTransformMatrix:{value:new Matrix,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:i,uTexture:Texture.EMPTY.source,uSampler:Texture.EMPTY.source.style}})}updateUniforms(i,l,p,m,_,y){const x=this.resources.tilingUniforms,v=y.width,T=y.height,S=y.textureMatrix,P=x.uniforms.uTextureTransform;P.set(p.a*v/i,p.b*v/l,p.c*T/i,p.d*T/l,p.tx/i,p.ty/l),P.invert(),x.uniforms.uMapCoord=S.mapCoord,x.uniforms.uClampFrame=S.uClampFrame,x.uniforms.uClampOffset=S.uClampOffset,x.uniforms.uTextureTransform=P,x.uniforms.uSizeAnchor[0]=i,x.uniforms.uSizeAnchor[1]=l,x.uniforms.uSizeAnchor[2]=m,x.uniforms.uSizeAnchor[3]=_,y&&(this.resources.uTexture=y.source,this.resources.uSampler=y.source.style)}}const Vs=new class QuadGeometry extends ks{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}};class TilingSpritePipe{constructor(i){this._state=Xe.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i}validateRenderable(i){const l=this._getTilingSpriteData(i),p=l.canBatch;this._updateCanBatch(i);const m=l.canBatch;if(m&&m===p){const{batchableMesh:p}=l;if(p&&p.texture._source!==i.texture._source)return!p._batcher.checkAndUpdateTexture(p,i.texture)}return p!==m}addRenderable(i,l){const p=this._renderer.renderPipes.batch;this._updateCanBatch(i);const m=this._getTilingSpriteData(i),{geometry:_,canBatch:y}=m;if(y){m.batchableMesh||(m.batchableMesh=new BatchableMesh);const y=m.batchableMesh;i._didTilingSpriteUpdate&&(i._didTilingSpriteUpdate=!1,this._updateBatchableMesh(i),y.geometry=_,y.renderable=i,y.transform=i.groupTransform,y.texture=i._texture),y.roundPixels=this._renderer._roundPixels|i._roundPixels,p.addToBatch(y,l)}else p.break(l),m.shader||(m.shader=new TilingSpriteShader),this.updateRenderable(i),l.add(i)}execute(i){const{shader:l}=this._tilingSpriteDataHash[i.uid];l.groups[0]=this._renderer.globalUniforms.bindGroup;const p=l.resources.localUniforms.uniforms;p.uTransformMatrix=i.groupTransform,p.uRound=this._renderer._roundPixels|i._roundPixels,color32BitToUniform(i.groupColorAlpha,p.uColor,0),this._state.blendMode=getAdjustedBlendModeBlend(i.groupBlendMode,i.texture._source),this._renderer.encoder.draw({geometry:Vs,shader:l,state:this._state})}updateRenderable(i){const l=this._getTilingSpriteData(i),{canBatch:p}=l;if(p){const{batchableMesh:p}=l;i._didTilingSpriteUpdate&&this._updateBatchableMesh(i),p._batcher.updateElement(p)}else if(i._didTilingSpriteUpdate){const{shader:p}=l;p.updateUniforms(i.width,i.height,i._tileTransform.matrix,i.anchor.x,i.anchor.y,i.texture)}i._didTilingSpriteUpdate=!1}destroyRenderable(i){const l=this._getTilingSpriteData(i);l.batchableMesh=null,l.shader?.destroy(),this._tilingSpriteDataHash[i.uid]=null,i.off("destroyed",this._destroyRenderableBound)}_getTilingSpriteData(i){return this._tilingSpriteDataHash[i.uid]||this._initTilingSpriteData(i)}_initTilingSpriteData(i){const l=new ks({indices:Vs.indices,positions:Vs.positions.slice(),uvs:Vs.uvs.slice()});return this._tilingSpriteDataHash[i.uid]={canBatch:!0,renderable:i,geometry:l},i.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[i.uid]}_updateBatchableMesh(i){const l=this._getTilingSpriteData(i),{geometry:p}=l,m=i.texture.source.style;"repeat"!==m.addressMode&&(m.addressMode="repeat",m.update()),function setUvs(i,l){const p=i.texture,m=p.frame.width,_=p.frame.height;let y=0,x=0;i._applyAnchorToTexture&&(y=i.anchor.x,x=i.anchor.y),l[0]=l[6]=-y,l[2]=l[4]=1-y,l[1]=l[3]=-x,l[5]=l[7]=1-x;const v=Matrix.shared;v.copyFrom(i._tileTransform.matrix),v.tx/=i.width,v.ty/=i.height,v.invert(),v.scale(i.width/m,i.height/_),function applyMatrix(i,l,p,m){let _=0;const y=i.length/l,x=m.a,v=m.b,T=m.c,S=m.d,P=m.tx,C=m.ty;for(p*=l;_<y;){const m=i[p],y=i[p+1];i[p]=x*m+T*y+P,i[p+1]=v*m+S*y+C,p+=l,_++}}(l,2,0,v)}(i,p.uvs),function setPositions(i,l){const p=i.anchor.x,m=i.anchor.y;l[0]=-p*i.width,l[1]=-m*i.height,l[2]=(1-p)*i.width,l[3]=-m*i.height,l[4]=(1-p)*i.width,l[5]=(1-m)*i.height,l[6]=-p*i.width,l[7]=(1-m)*i.height}(i,p.positions)}destroy(){for(const i in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[i].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(i){const l=this._getTilingSpriteData(i),p=i.texture;let m=!0;return this._renderer.type===Ye.WEBGL&&(m=this._renderer.context.supports.nonPowOf2wrapping),l.canBatch=p.textureMatrix.isSimple&&(m||p.source.isPowerOfTwo),l.canBatch}}TilingSpritePipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"tilingSprite"};const $s={name:"local-uniform-msdf-bit",vertex:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32,\n uRound:f32,\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:" \n outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));\n "}},Xs={name:"local-uniform-msdf-bit",vertex:{header:"\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix *= uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:"\n uniform float uDistance;\n ",main:" \n outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));\n "}},js={name:"msdf-bit",fragment:{header:"\n fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {\n \n // MSDF\n var median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n \n // SDF\n median = min(median, msdfColor.a);\n\n var screenPxDistance = distance * (median - 0.5);\n var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));\n var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);\n var coverage: f32 = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n \n }\n "}},qs={name:"msdf-bit",fragment:{header:"\n float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {\n \n // MSDF\n float median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n \n // SDF\n median = min(median, msdfColor.a);\n \n float screenPxDistance = distance * (median - 0.5);\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n \n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));\n float gamma = mix(1.0, 1.0 / 2.2, luma);\n float coverage = pow(shapeColor.a * alpha, gamma); \n \n return coverage;\n }\n "}};let Zs,Qs;class SdfShader extends Shader{constructor(){const i=new Ke({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new Matrix,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),l=getMaxTexturesPerBatch();Zs??(Zs=compileHighShaderGpuProgram({name:"sdf-shader",bits:[Si,generateTextureBatchBit(l),$s,js,Ei]})),Qs??(Qs=compileHighShaderGlProgram({name:"sdf-shader",bits:[Pi,generateTextureBatchBitGl(l),Xs,qs,Ai]})),super({glProgram:Qs,gpuProgram:Zs,resources:{localUniforms:i,batchSamplers:getBatchSamplersUniformGroup(l)}})}}class BitmapTextPipe{constructor(i){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i}validateRenderable(i){const l=this._getGpuBitmapText(i);return i._didTextUpdate&&(i._didTextUpdate=!1,this._updateContext(i,l)),this._renderer.renderPipes.graphics.validateRenderable(l)}addRenderable(i,l){const p=this._getGpuBitmapText(i);syncWithProxy(i,p),i._didTextUpdate&&(i._didTextUpdate=!1,this._updateContext(i,p)),this._renderer.renderPipes.graphics.addRenderable(p,l),p.context.customShader&&this._updateDistanceField(i)}destroyRenderable(i){i.off("destroyed",this._destroyRenderableBound),this._destroyRenderableByUid(i.uid)}_destroyRenderableByUid(i){const l=this._gpuBitmapText[i].context;l.customShader&&(kt.return(l.customShader),l.customShader=null),kt.return(this._gpuBitmapText[i]),this._gpuBitmapText[i]=null}updateRenderable(i){const l=this._getGpuBitmapText(i);syncWithProxy(i,l),this._renderer.renderPipes.graphics.updateRenderable(l),l.context.customShader&&this._updateDistanceField(i)}_updateContext(i,l){const{context:p}=l,m=_s.getFont(i.text,i._style);p.clear(),"none"!==m.distanceField.type&&(p.customShader||(p.customShader=kt.get(SdfShader)));const _=Array.from(i.text),y=i._style;let x=m.baseLineOffset;const v=getBitmapTextLayout(_,y,m,!0);let T=0;const S=y.padding,P=v.scale;let C=v.width,E=v.height+v.offsetY;y._stroke&&(C+=y._stroke.width/P,E+=y._stroke.width/P),p.translate(-i._anchor._x*C-S,-i._anchor._y*E-S).scale(P,P);const A=m.applyFillAsTint?y._fill.color:16777215;for(let i=0;i<v.lines.length;i++){const l=v.lines[i];for(let i=0;i<l.charPositions.length;i++){const y=_[T++],v=m.chars[y];v?.texture&&p.texture(v.texture,A||"black",Math.round(l.charPositions[i]+v.xOffset),Math.round(x+v.yOffset))}x+=m.lineHeight}}_getGpuBitmapText(i){return this._gpuBitmapText[i.uid]||this.initGpuText(i)}initGpuText(i){const l=kt.get(Graphics);return this._gpuBitmapText[i.uid]=l,this._updateContext(i,l),i.on("destroyed",this._destroyRenderableBound),this._gpuBitmapText[i.uid]}_updateDistanceField(i){const l=this._getGpuBitmapText(i).context,p=i._style.fontFamily,m=se.get(`${p}-bitmap`),{a:_,b:y,c:x,d:v}=i.groupTransform,T=Math.sqrt(_*_+y*y),S=Math.sqrt(x*x+v*v),P=(Math.abs(T)+Math.abs(S))/2,C=m.baseRenderedFontSize/i._style.fontSize,E=P*m.distanceField.range*(1/C);l.customShader.resources.localUniforms.uniforms.uDistance=E}destroy(){for(const i in this._gpuBitmapText)this._destroyRenderableByUid(i);this._gpuBitmapText=null,this._renderer=null}}function syncWithProxy(i,l){l.groupTransform=i.groupTransform,l.groupColorAlpha=i.groupColorAlpha,l.groupColor=i.groupColor,l.groupBlendMode=i.groupBlendMode,l.globalDisplayStatus=i.globalDisplayStatus,l.groupTransform=i.groupTransform,l.localDisplayStatus=i.localDisplayStatus,l.groupAlpha=i.groupAlpha,l._roundPixels=i._roundPixels}BitmapTextPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"bitmapText"};class HTMLTextPipe{constructor(i){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const i in this._gpuText){const l=this._gpuText[i];if(!l)continue;const p=l.batchableSprite.renderable;p._autoResolution&&(p._resolution=this._renderer.resolution,p.onViewUpdate())}}validateRenderable(i){const l=this._getGpuText(i),p=i._getKey();return l.textureNeedsUploading?(l.textureNeedsUploading=!1,!0):l.currentKey!==p}addRenderable(i,l){const p=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),this._renderer.renderPipes.batch.addToBatch(p,l)}updateRenderable(i){const l=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),l._batcher.updateElement(l)}destroyRenderable(i){i.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(i.uid)}_destroyRenderableById(i){const l=this._gpuText[i];this._renderer.htmlText.decreaseReferenceCount(l.currentKey),kt.return(l.batchableSprite),this._gpuText[i]=null}_updateText(i){const l=i._getKey(),p=this._getGpuText(i),m=p.batchableSprite;p.currentKey!==l&&this._updateGpuText(i).catch((i=>{console.error(i)})),i._didTextUpdate=!1;const _=i._style.padding;updateQuadBounds(m.bounds,i._anchor,m.texture,_)}async _updateGpuText(i){i._didTextUpdate=!1;const l=this._getGpuText(i);if(l.generatingTexture)return;const p=i._getKey();this._renderer.htmlText.decreaseReferenceCount(l.currentKey),l.generatingTexture=!0,l.currentKey=p;const m=i.resolution??this._renderer.resolution,_=await this._renderer.htmlText.getManagedTexture(i.text,m,i._style,i._getKey()),y=l.batchableSprite;y.texture=l.texture=_,l.generatingTexture=!1,l.textureNeedsUploading=!0,i.onViewUpdate();const x=i._style.padding;updateQuadBounds(y.bounds,i._anchor,y.texture,x)}_getGpuText(i){return this._gpuText[i.uid]||this.initGpuText(i)}initGpuText(i){const l={texture:Texture.EMPTY,currentKey:"--",batchableSprite:kt.get(BatchableSprite),textureNeedsUploading:!1,generatingTexture:!1},p=l.batchableSprite;return p.renderable=i,p.transform=i.groupTransform,p.texture=Texture.EMPTY,p.bounds={minX:0,maxX:1,minY:0,maxY:0},p.roundPixels=this._renderer._roundPixels|i._roundPixels,i._resolution=i._autoResolution?this._renderer.resolution:i.resolution,this._gpuText[i.uid]=l,i.on("destroyed",this._destroyRenderableBound),l}destroy(){for(const i in this._gpuText)this._destroyRenderableById(i);this._gpuText=null,this._renderer=null}}HTMLTextPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"htmlText"};const Js=new Bounds;function getPo2TextureFromSource(i,l,p,m){const _=Js;_.minX=0,_.minY=0,_.maxX=i.width/m|0,_.maxY=i.height/m|0;const y=Ms.getOptimalTexture(_.width,_.height,m,!1);return y.source.uploadMethodId="image",y.source.resource=i,y.source.alphaMode="premultiply-alpha-on-upload",y.frame.width=l/m,y.frame.height=p/m,y.source.emit("update",y.source),y.updateUvs(),y}async function loadFontCSS(i,l){const p=await async function loadFontAsBase64(i){const l=await qt.get().fetch(i),p=await l.blob(),m=new FileReader;return await new Promise(((i,l)=>{m.onloadend=()=>i(m.result),m.onerror=l,m.readAsDataURL(p)}))}(l);return`@font-face {\n font-family: "${i.fontFamily}";\n src: url('${p}');\n font-weight: ${i.fontWeight};\n font-style: ${i.fontStyle};\n }`}const tr=new Map;class HTMLTextSystem{constructor(i){this._activeTextures={},this._renderer=i,this._createCanvas=i.type===Ye.WEBGPU}getTexture(i){return this._buildTexturePromise(i.text,i.resolution,i.style)}getManagedTexture(i,l,p,m){if(this._activeTextures[m])return this._increaseReferenceCount(m),this._activeTextures[m].promise;const _=this._buildTexturePromise(i,l,p).then((i=>(this._activeTextures[m].texture=i,i)));return this._activeTextures[m]={texture:null,promise:_,usageCount:1},_}async _buildTexturePromise(i,l,p){const m=kt.get(HTMLTextRenderData),_=function extractFontFamilies(i,l){const p=l.fontFamily,m=[],_={},y=i.match(/font-family:([^;"\s]+)/g);function addFontFamily(i){_[i]||(m.push(i),_[i]=!0)}if(Array.isArray(p))for(let i=0;i<p.length;i++)addFontFamily(p[i]);else addFontFamily(p);y&&y.forEach((i=>{addFontFamily(i.split(":")[1].trim())}));for(const i in l.tagStyles)addFontFamily(l.tagStyles[i].fontFamily);return m}(i,p),y=await async function getFontCss(i,l,p){const m=i.filter((i=>se.has(`${i}-and-url`))).map(((i,m)=>{if(!tr.has(i)){const{url:_}=se.get(`${i}-and-url`);0===m?tr.set(i,loadFontCSS({fontWeight:l.fontWeight,fontStyle:l.fontStyle,fontFamily:i},_)):tr.set(i,loadFontCSS({fontWeight:p.fontWeight,fontStyle:p.fontStyle,fontFamily:i},_))}return tr.get(i)}));return(await Promise.all(m)).join("\n")}(_,p,HTMLTextStyle.defaultTextStyle),x=function measureHtmlText(i,l,p,m){m=m||Ds||(Ds=new HTMLTextRenderData);const{domElement:_,styleElement:y,svgRoot:x}=m;_.innerHTML=`<style>${l.cssStyle};</style><div style='padding:0'>${i}</div>`,_.setAttribute("style","transform-origin: top left; display: inline-block"),p&&(y.textContent=p),document.body.appendChild(x);const v=_.getBoundingClientRect();x.remove();const T=ps.measureFont(l.fontStyle).descent,S=2*l.padding;return{width:v.width-S,height:v.height+T-S}}(i,p,y,m),v=Math.ceil(Math.ceil(Math.max(1,x.width)+2*p.padding)*l),T=Math.ceil(Math.ceil(Math.max(1,x.height)+2*p.padding)*l),S=m.image;S.width=2+(0|v),S.height=2+(0|T);const P=function getSVGUrl(i,l,p,m,_){const{domElement:y,styleElement:x,svgRoot:v}=_;y.innerHTML=`<style>${l.cssStyle}</style><div style='padding:0;'>${i}</div>`,y.setAttribute("style",`transform: scale(${p});transform-origin: top left; display: inline-block`),x.textContent=m;const{width:T,height:S}=_.image;return v.setAttribute("width",T.toString()),v.setAttribute("height",S.toString()),(new XMLSerializer).serializeToString(v)}(i,p,l,y,m);await function loadSVGImage(i,l,p){return new Promise((async m=>{p&&await new Promise((i=>setTimeout(i,100))),i.onload=()=>{m()},i.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(l)}`,i.crossOrigin="anonymous"}))}(S,P,function isSafari(){const{userAgent:i}=qt.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(i)}()&&_.length>0);let C=S;this._createCanvas&&(C=function getTemporaryCanvasFromImage(i,l){const p=ls.getOptimalCanvasAndContext(i.width,i.height,l),{context:m}=p;return m.clearRect(0,0,i.width,i.height),m.drawImage(i,0,0),ls.returnCanvasAndContext(p),p.canvas}(S,l));const E=getPo2TextureFromSource(C,S.width-2,S.height-2,l);return this._createCanvas&&this._renderer.texture.initSource(E.source),kt.return(m),E}_increaseReferenceCount(i){this._activeTextures[i].usageCount++}decreaseReferenceCount(i){const l=this._activeTextures[i];l&&(l.usageCount--,0===l.usageCount&&(l.texture?this._cleanUp(l):l.promise.then((i=>{l.texture=i,this._cleanUp(l)})).catch((()=>{warn("HTMLTextSystem: Failed to clean texture")})),this._activeTextures[i]=null))}_cleanUp(i){Ms.returnTexture(i.texture),i.texture.source.resource=null,i.texture.source.uploadMethodId="unknown"}getReferenceCount(i){return this._activeTextures[i].usageCount}destroy(){this._activeTextures=null}}HTMLTextSystem.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"htmlText"},HTMLTextSystem.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class CanvasTextPipe{constructor(i){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=i,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(const i in this._gpuText){const l=this._gpuText[i];if(!l)continue;const p=l.batchableSprite.renderable;p._autoResolution&&(p._resolution=this._renderer.resolution,p.onViewUpdate())}}validateRenderable(i){const l=this._getGpuText(i),p=i._getKey();if(l.currentKey!==p){const{width:p,height:m}=this._renderer.canvasText.getTextureSize(i.text,i.resolution,i._style);return 1!==this._renderer.canvasText.getReferenceCount(l.currentKey)||p!==l.texture._source.width||m!==l.texture._source.height}return!1}addRenderable(i,l){const p=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),this._renderer.renderPipes.batch.addToBatch(p,l)}updateRenderable(i){const l=this._getGpuText(i).batchableSprite;i._didTextUpdate&&this._updateText(i),l._batcher.updateElement(l)}destroyRenderable(i){i.off("destroyed",this._destroyRenderableBound),this._destroyRenderableById(i.uid)}_destroyRenderableById(i){const l=this._gpuText[i];this._renderer.canvasText.decreaseReferenceCount(l.currentKey),kt.return(l.batchableSprite),this._gpuText[i]=null}_updateText(i){const l=i._getKey(),p=this._getGpuText(i),m=p.batchableSprite;p.currentKey!==l&&this._updateGpuText(i),i._didTextUpdate=!1;const _=i._style.padding;updateQuadBounds(m.bounds,i._anchor,m.texture,_)}_updateGpuText(i){const l=this._getGpuText(i),p=l.batchableSprite;l.texture&&this._renderer.canvasText.decreaseReferenceCount(l.currentKey),l.texture=p.texture=this._renderer.canvasText.getManagedTexture(i),l.currentKey=i._getKey(),p.texture=l.texture}_getGpuText(i){return this._gpuText[i.uid]||this.initGpuText(i)}initGpuText(i){const l={texture:null,currentKey:"--",batchableSprite:kt.get(BatchableSprite)};return l.batchableSprite.renderable=i,l.batchableSprite.transform=i.groupTransform,l.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},l.batchableSprite.roundPixels=this._renderer._roundPixels|i._roundPixels,this._gpuText[i.uid]=l,i._resolution=i._autoResolution?this._renderer.resolution:i.resolution,this._updateText(i),i.on("destroyed",this._destroyRenderableBound),l}destroy(){for(const i in this._gpuText)this._destroyRenderableById(i);this._gpuText=null,this._renderer=null}}function checkRow(i,l,p){for(let m=0,_=4*p*l;m<l;++m,_+=4)if(0!==i[_+3])return!1;return!0}function checkColumn(i,l,p,m,_){const y=4*l;for(let l=m,x=m*y+4*p;l<=_;++l,x+=y)if(0!==i[x+3])return!1;return!0}CanvasTextPipe.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"text"};class CanvasTextSystem{constructor(i){this._activeTextures={},this._renderer=i}getTextureSize(i,l,p){const m=ps.measureText(i||" ",p);let _=Math.ceil(Math.ceil(Math.max(1,m.width)+2*p.padding)*l),y=Math.ceil(Math.ceil(Math.max(1,m.height)+2*p.padding)*l);return _=Math.ceil(_-1e-6),y=Math.ceil(y-1e-6),_=nextPow2(_),y=nextPow2(y),{width:_,height:y}}getTexture(i,l,p,m){"string"==typeof i&&(deprecation("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),i={text:i,style:p,resolution:l}),i.style instanceof hs||(i.style=new hs(i.style));const{texture:_,canvasAndContext:y}=this.createTextureAndCanvas(i);return this._renderer.texture.initSource(_._source),ls.returnCanvasAndContext(y),_}createTextureAndCanvas(i){const{text:l,style:p}=i,m=i.resolution??this._renderer.resolution,_=ps.measureText(l||" ",p),y=Math.ceil(Math.ceil(Math.max(1,_.width)+2*p.padding)*m),x=Math.ceil(Math.ceil(Math.max(1,_.height)+2*p.padding)*m),v=ls.getOptimalCanvasAndContext(y,x),{canvas:T}=v;this.renderTextToCanvas(l,p,m,v);const S=getPo2TextureFromSource(T,y,x,m);if(p.trim){const i=function getCanvasBoundingBox(i,l=1){const{width:p,height:m}=i,_=i.getContext("2d",{willReadFrequently:!0});if(null===_)throw new TypeError("Failed to get canvas 2D context");const y=_.getImageData(0,0,p,m).data;let x=0,v=0,T=p-1,S=m-1;for(;v<m&&checkRow(y,p,v);)++v;if(v===m)return Rectangle.EMPTY;for(;checkRow(y,p,S);)--S;for(;checkColumn(y,p,x,v,S);)++x;for(;checkColumn(y,p,T,v,S);)--T;return++T,++S,new Rectangle(x/l,v/l,(T-x)/l,(S-v)/l)}(T,m);S.frame.copyFrom(i),S.updateUvs()}return{texture:S,canvasAndContext:v}}getManagedTexture(i){i._resolution=i._autoResolution?this._renderer.resolution:i.resolution;const l=i._getKey();if(this._activeTextures[l])return this._increaseReferenceCount(l),this._activeTextures[l].texture;const{texture:p,canvasAndContext:m}=this.createTextureAndCanvas(i);return this._activeTextures[l]={canvasAndContext:m,texture:p,usageCount:1},p}_increaseReferenceCount(i){this._activeTextures[i].usageCount++}decreaseReferenceCount(i){const l=this._activeTextures[i];if(l.usageCount--,0===l.usageCount){ls.returnCanvasAndContext(l.canvasAndContext),Ms.returnTexture(l.texture);const p=l.texture.source;p.resource=null,p.uploadMethodId="unknown",p.alphaMode="no-premultiply-alpha",this._activeTextures[i]=null}}getReferenceCount(i){return this._activeTextures[i].usageCount}renderTextToCanvas(i,l,p,m){const{canvas:_,context:y}=m,x=fontStringFromTextStyle(l),v=ps.measureText(i||" ",l),T=v.lines,S=v.lineHeight,P=v.lineWidths,C=v.maxLineWidth,E=v.fontProperties,A=_.height;y.resetTransform(),y.scale(p,p);const k=2*l.padding;if(y.clearRect(0,0,v.width+4+k,v.height+4+k),l._stroke?.width){const i=l._stroke;y.lineWidth=i.width,y.miterLimit=i.miterLimit,y.lineJoin=i.join,y.lineCap=i.cap}let B,F;y.font=x;const R=l.dropShadow?2:1;for(let i=0;i<R;++i){const _=l.dropShadow&&0===i,x=_?Math.ceil(Math.max(1,A)+2*l.padding):0,v=x*p;if(_){y.fillStyle="black",y.strokeStyle="black";const i=l.dropShadow,m=i.color,_=i.alpha;y.shadowColor=At.shared.setValue(m).setAlpha(_).toRgbaString();const x=i.blur*p,T=i.distance*p;y.shadowBlur=x,y.shadowOffsetX=Math.cos(i.angle)*T,y.shadowOffsetY=Math.sin(i.angle)*T+v}else y.globalAlpha=l._fill?.alpha??1,y.fillStyle=l._fill?getCanvasFillStyle(l._fill,y):null,l._stroke?.width&&(y.strokeStyle=getCanvasFillStyle(l._stroke,y)),y.shadowColor="black";let k=(S-E.fontSize)/2;S-E.fontSize<0&&(k=0);const R=l._stroke?.width??0;for(let i=0;i<T.length;i++)B=R/2,F=R/2+i*S+E.ascent+k,"right"===l.align?B+=C-P[i]:"center"===l.align&&(B+=(C-P[i])/2),l._stroke?.width&&this._drawLetterSpacing(T[i],l,m,B+l.padding,F+l.padding-x,!0),void 0!==l._fill&&this._drawLetterSpacing(T[i],l,m,B+l.padding,F+l.padding-x)}}_drawLetterSpacing(i,l,p,m,_,y=!1){const{context:x}=p,v=l.letterSpacing;let T=!1;if(ps.experimentalLetterSpacingSupported&&(ps.experimentalLetterSpacing?(x.letterSpacing=`${v}px`,x.textLetterSpacing=`${v}px`,T=!0):(x.letterSpacing="0px",x.textLetterSpacing="0px")),0===v||T)return void(y?x.strokeText(i,m,_):x.fillText(i,m,_));let S=m;const P=ps.graphemeSegmenter(i);let C=x.measureText(i).width,E=0;for(let i=0;i<P.length;++i){const l=P[i];y?x.strokeText(l,S,_):x.fillText(l,S,_);let p="";for(let l=i+1;l<P.length;++l)p+=P[l];E=x.measureText(p).width,S+=C-E+v,C=E}}destroy(){this._activeTextures=null}}CanvasTextSystem.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"canvasText"},z.add(W,K);const er=new FederatedPointerEvent(null),ir=new Point;function emitPointerEvent(i,l,p){if(null==i?void 0:i.destroyed)return;const m=i.getGlobalPosition(ir,!1);for(const _ of p)i.emit(_,toPointerEvent(l,_,m))}function toPointerEvent(i,l,p){const m="custom"===i.type?i.id:i.type,_="pointerup"===l?0:1;return er.type=l,er.pointerType=m,er.pointerId=-1,er.button=0,er.buttons=_,er.isPrimary=!0,er.client.copyFrom(p),er.global.copyFrom(p),er}const sr={[G.Activate]:"activate",[G.Back]:"back",[G.Down]:"down",[G.Left]:"left",[G.Right]:"right",[G.Up]:"up"};class NavigationManager{constructor(){this.options={spatial:{minimumDistance:10,directionAxisWeight:2.5},events:{focus:["pointerenter","pointerover"],blur:["pointerleave","pointerout"],press:["pointerdown"],release:["pointerup","pointertap"]}},this.paused=!1,this.focusSource="pointer",this._responders=[]}get active(){return null!=this._rootContainer&&!this.paused}get focusTarget(){var i;const l=this.responders.find((i=>{var l;return!(null===(l=i.focusTarget)||void 0===l?void 0:l.destroyed)}));return null!==(i=null==l?void 0:l.focusTarget)&&void 0!==i?i:this._rootFocused}set focusTarget(i){this.setFocus(i,void 0)}get firstResponder(){return this._responders[0]}get responders(){return this._responders}configureWithRoot(i){this.enable(i)}invalidateNavCache(){const i=this.getStageContainer();i?invalidateNavigatablesCache(i):invalidateNavigatablesCache()}enable(i){this.active&&this.disable(),this._rootContainer=i,invalidateNavigatablesCache(i);const handler=i=>this._handleNavigateBindEvent(i),l=[G.Left,G.Down,G.Right,G.Up,G.Activate,G.Back];return L.onBindDownUp(l,handler),this._clearBinds=()=>L.offBindDownUp(l,handler),this}pushResponder(i){var l,p,m;const _=i;if(this._responders.includes(_))throw new Error("Responder already in stack.");const y=this.firstResponder;this._responders.unshift(_),invalidateNavigatablesCache(),null===(l=null==y?void 0:y.resignedAsFirstResponder)||void 0===l||l.call(y),this._clearFocusTargetIfRemoved(),null===(p=_.becameFirstResponder)||void 0===p||p.call(_),(null===(m=_.autoFocus)||void 0===m||m)&&this.autoFocus()}popResponder(){var i,l,p,m,_;const y=this.focusTarget,x=this._responders.shift();x&&(x.focusTarget=void 0),invalidateNavigatablesCache();const v=this.focusTarget;return null===(i=null==x?void 0:x.resignedAsFirstResponder)||void 0===i||i.call(x),this._clearFocusTargetIfRemoved(),this.firstResponder&&(null===(p=(l=this.firstResponder).becameFirstResponder)||void 0===p||p.call(l)),y!==v&&(null!==(_=null===(m=this.firstResponder)||void 0===m?void 0:m.autoFocus)&&void 0!==_?_:!v)&&this.autoFocus(),x}setTopMostResponder(i){var l,p,m;const _=i,y=this.firstResponder;if(y===_)return;const x=this._responders.indexOf(_);-1!==x&&this._responders.splice(x,1),this._responders.unshift(_),null===(l=null==y?void 0:y.resignedAsFirstResponder)||void 0===l||l.call(y),this._clearFocusTargetIfRemoved(),null===(p=_.becameFirstResponder)||void 0===p||p.call(_),(null===(m=_.autoFocus)||void 0===m||m)&&this.autoFocus()}removeResponder(i,l=!1){var p,m,_,y,x;const v=i,T=this._responders.indexOf(v);if(-1===T)return;const S=this.focusTarget,P=this.firstResponder;let C;if(l){const i=this._responders.splice(0,T+1);C=i[i.length-1];for(const l of i)l.focusTarget=void 0}else C=this._responders.splice(T,1)[0],C.focusTarget=void 0;const E=this.focusTarget;return P!==this.firstResponder&&(null===(p=null==P?void 0:P.resignedAsFirstResponder)||void 0===p||p.call(P),this._clearFocusTargetIfRemoved(),null===(_=null===(m=this.firstResponder)||void 0===m?void 0:m.becameFirstResponder)||void 0===_||_.call(m)),S!==E&&(null!==(x=null===(y=this.firstResponder)||void 0===y?void 0:y.autoFocus)&&void 0!==x?x:!E)&&this.autoFocus(),C}autoFocus(){if(!rr.active)return;const i=this.getStageContainer();if(!i)return;const l=getFirstNavigatable(i);void 0!==l&&l!==this.focusTarget&&this.setFocus(l,this.device)}getStageContainer(){var i;return null!==(i=this.responders.find(isContainer))&&void 0!==i?i:this._rootContainer}disable(){invalidateNavigatablesCache(),this._clearNavigateBindsHandler(),this._rootContainer=void 0,this._rootFocused=void 0}setFocus(i,l){l?(this.focusSource="device",this.device=l):(this.focusSource="pointer",this.device=void 0);const p=this.focusTarget;if(p==i)return;const m=this.getStageContainer();m&&(i&&!i.navigatable||i&&!isChildOf(i,m)||(this.firstResponder?this.firstResponder.focusTarget=i:this._rootFocused=i,p&&this._blur(p,!1),i&&this._focus(i)))}_clearNavigateBindsHandler(){var i;null===(i=this._clearBinds)||void 0===i||i.call(this),this._clearBinds=void 0}_handleNavigateBindEvent(i){if(!this.active)return;const l=i.name,p=i.device;if(this.device=p,this.focusSource="device",this._responders.some((l=>{var p;return null===(p=l.handledNavigateEvent)||void 0===p?void 0:p.call(l,i)})))return;this._clearFocusTargetIfRemoved();const m=this.focusTarget;if(void 0===m)return void(i.pressed||this.autoFocus());const _=sr[l],y=m.navigationLinks[_];if(null==y?void 0:y.navigatable)i.pressed&&this.setFocus(y,p);else switch(l){case G.Activate:return void(i.pressed?this._press(m):this._release(m));case G.Back:if(i.pressed)return;return void this._blur(m);default:{if(!i.pressed)return;const p=getFirstNavigatable(this.getStageContainer(),{direction:l,currentFocus:m,spatial:this.options.spatial});p&&p!==m&&this.setFocus(p,i.device)}}}_focus(i){this.device&&"device"===this.focusSource&&emitPointerEvent(i,this.device,this.options.events.focus)}_press(i){this.device&&"device"===this.focusSource&&emitPointerEvent(i,this.device,this.options.events.press)}_release(i){this.device&&"device"===this.focusSource&&emitPointerEvent(i,this.device,this.options.events.release)}_blur(i,l=!0){this.device&&"device"===this.focusSource&&(emitPointerEvent(i,this.device,this.options.events.blur),l&&this.setFocus(void 0,void 0))}_clearFocusTargetIfRemoved(i){if(null!=i||(i=this.getStageContainer()),!i)return;const l=this.focusTarget;l&&!isChildOf(l,i)&&this._blur(l)}}function isContainer(i){return"children"in i}NavigationManager.global=new NavigationManager;const rr=NavigationManager.global;let nr=!1;const or=new Set(["pointerdown","pointerup","pointertap"]);z.add(AccessibilitySystem),Container.mixin({accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1}),z.add(ResizePlugin),z.add(TickerPlugin),z.add(Ts),Container.mixin(Ss),z.add(GraphicsPipe),z.add($i),z.add(MeshPipe),z.add(CanvasTextSystem),z.add(CanvasTextPipe),z.add(BitmapTextPipe),z.add(HTMLTextSystem),z.add(HTMLTextPipe),z.add(TilingSpritePipe),z.add(NineSliceSpritePipe),z.add(FilterSystem),z.add(FilterPipe);var ar=Object.freeze({__proto__:null}),hr=Object.freeze({__proto__:null});exports.Button=F,exports.GamepadDevice=GamepadDevice,exports.InputDevice=L,exports.KeyCode=i,exports.KeyboardDevice=P,exports.KeyboardDeviceInstance=KeyboardDeviceInstance,exports.Navigate=G,exports.UINavigation=rr,exports.getAllNavigatables=getAllNavigatables,exports.getFirstNavigatable=getFirstNavigatable,exports.invalidateNavigatablesCache=invalidateNavigatablesCache,exports.isChildOf=isChildOf,exports.isVisible=isVisible,exports.registerPixiJSNavigationMixin=function registerPixiJSNavigationMixin(i){if(nr)return;nr=!0;const l=i.prototype,p=new WeakMap;l.navigationMode="auto",l.navigationPriority=0,Object.defineProperty(l,"navigatable",{get:function(){if(this.destroyed)return!1;switch(this.navigationMode){case"always":return!0;case"none":return!1;default:return this.isInteractive()&&this.eventNames().some((i=>or.has(i)))}},configurable:!0,enumerable:!1}),Object.defineProperty(l,"navigationLinks",{get:function(){let i=p.get(this);return null==i&&(i=this.navigationLinks={}),i},set:function(i){p.set(this,i),this.on("destroyed",(()=>p.delete(this)))},configurable:!0,enumerable:!1})};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|