diff --git a/demos/head-turn/README.md b/demos/head-turn/README.md index e9f789f..9cc94f4 100644 --- a/demos/head-turn/README.md +++ b/demos/head-turn/README.md @@ -12,10 +12,10 @@ Every build and runtime dependency is installed from the public npm registry (`h | Package | Version | Role | | --- | --- | --- | -| `@rig-c/parts` | `1.71.0` | Slices per-part depth sheets from `depth.jpg`, promotes `face` (`head`) and `topwear` (`chest`) to `13×16` depth-sampled surface grids (`360` triangles each), and emits the 2.5D `turn`, `tilt`, and `body_turn` animations and `yaw` / `pitch` / `body_yaw_dial` sliders | +| `@rig-c/parts` | `1.71.1` | Slices per-part depth sheets from `depth.jpg`, promotes `face` (`head`) and `topwear` (`chest`) to `13×16` depth-sampled surface grids (`360` triangles each), and emits the 2.5D `turn`, `tilt`, and `body_turn` animations and `yaw` / `pitch` / `body_yaw_dial` sliders | | `@rig-c/pose` | `1.4.0` | Cleans and retargets the 4-way sign-test pose sequence (`pose#455`, 25 frames at 24 fps) onto the rig's `yaw`, `pitch`, and `body_yaw_dial` sliders as the `"clip"` animation | | `rig-c` | `2.79.0` | Gates (`--profile rig-play`) and compiles `rig.json` + `motion.json` into `skeleton.model.json`, `skeleton.json`, `skeleton.atlas`, and polygon-packed `skeleton.png`, and provides `readModel` in the browser | -| `@rig-c/play` | `1.20.0` | Loads `skeleton.model.json` + `skeleton.png` (`loadModel`) and steps the runtime pose and animation mixer (`RigPlayer`) | +| `@rig-c/play` | `1.21.0` | Loads `skeleton.model.json` + `skeleton.png` (`loadModel`) and steps the runtime pose and animation mixer (`RigPlayer`) | | `@rig-c/pixi` | `0.1.5` | Renders the posed `RigPlayer` frame onto a PixiJS v8 `Container` (`PixiRig`) | | `pixi.js` | `8.22.0` | Hardware-accelerated `WebGLRenderer` host | @@ -26,7 +26,7 @@ Every build and runtime dependency is installed from the public npm registry (`h 1. **Source art and confirmed depth atlas** - Painting: [`bundle/look.png`](./bundle/look.png) - Confirmed depth atlas: [`bundle/depth.jpg`](./bundle/depth.jpg) (`1284×1289`, SHA-256 `c814960c7e40dd1d5573a5e6d6e5d97eefeb309d015dea924359dc87f8e998a0`, white = near, `zScale = 109.86819166092819`) -2. **2.5D head and body turn configuration (`@rig-c/parts@1.71.0`)** +2. **2.5D head and body turn configuration (`@rig-c/parts@1.71.1`)** - `config.turn`: - `pivot: 55`, `counter: 0.1`, `grid: [13, 16]` - Head roles: `face: "surface"` (`face_surface` under `faceshift`), `hair_back: "rear"`, `hairpin: "rear"` (`rear_shift`), and facial/hair features (`ear_r`, `ear_l`, `nose`, `mouth`, `eyewhite_r`, `eyewhite_l`, `iris_r`, `iris_l`, `lash_r`, `lash_l`, `brow_l`, `brow_r`, `hair_front`) as `"unit"` @@ -64,15 +64,17 @@ Every build and runtime dependency is installed from the public npm registry (`h ```bash mkdir -p build-env && cd build-env npm init -y - npm install --no-save \ - @rig-c/parts@1.71.0 \ + PLAYWRIGHT_SKIP_BROWSER_GC=1 npm install --no-save \ + @rig-c/parts@1.71.1 \ @rig-c/pose@1.4.0 \ - @rig-c/play@1.20.0 \ + @rig-c/play@1.21.0 \ @rig-c/pixi@0.1.5 \ rig-c@2.79.0 \ pixi.js@8.22.0 ``` -2. **Run `@rig-c/parts` (`rigStage`) on the cut parts + depth sheets cropped from `depth.jpg`**: +2. **Reassemble the approved source layers using `@rig-c/parts@1.71.1` with the turn roles in the assemble config**: + - Do not reuse PNGs assembled by an older version: moving head parts must keep their own fringe and seam colours. + - Then run `@rig-c/parts` (`rigStage`) on the cut parts + depth sheets cropped from `depth.jpg`: - Configure `config.turn` (head) and `config.turn.body` (torso `topwear` + `collar_back`) with `pivot: 55`, `counter: 0.1`, `grid: [13, 16]`, and `zScale: 109.86819166092819`. - Emit `rig-out/rig.json`, `rig-out/motion.json`, `rig-out/images/`, `rig-out/depth_sheets.json`, and `rig-out/mesh_report.json`. 3. **Clean and retarget the 4-way sign-test pose clip with `@rig-c/pose`**: @@ -111,3 +113,13 @@ Every build and runtime dependency is installed from the public npm registry (`h bun run build bun run verify ``` + +## Page physics environment + +Immediately after creating its `PixiRig`, the page calls: + +```js +rig.environment({ wind: [0, 0], gravity: [0, 1] }); +``` + +This environment belongs to that player and persists across pointer/clip changes and seeks. Wind is zero; gravity uses the runtime axes (x right, y down). Authored physics response strengths remain in the rig. No global runtime default is changed. diff --git a/demos/head-turn/bundle-manifest.json b/demos/head-turn/bundle-manifest.json index 0476e0f..8873463 100644 --- a/demos/head-turn/bundle-manifest.json +++ b/demos/head-turn/bundle-manifest.json @@ -1,11 +1,11 @@ { "schema": 1, - "sha256": "6c9f3e6fba334c10362f51585e6f02a2c642772505b4a4b64c63b337216ec1d8", + "sha256": "3f5a0b5f4b9dc3e2ea1231a937726afa00963f81e2a5d8d2a6194684d8600087", "files": [ { "path": "README.md", - "bytes": 1365, - "sha256": "47b488ebb86e81c1641648d75b7c4a8f78fa5a07b2ee38d88a335ca46bc26d69" + "bytes": 1575, + "sha256": "93ad01c5d59c89d52a57937ef75f81b8cc602167365f90f0b533b826844199c0" }, { "path": "THIRD_PARTY_LICENSES.txt", @@ -14,8 +14,8 @@ }, { "path": "app.js", - "bytes": 21243, - "sha256": "ca7920c05519a456309e4d6b9d32b460922c8b785ab4e0a2275c9f1924c03604" + "bytes": 21387, + "sha256": "27ba309caece2ce337ede3164c3143c42019260aa99db5d724c87e2256ace192" }, { "path": "depth.jpg", @@ -34,8 +34,8 @@ }, { "path": "runtime.js", - "bytes": 861880, - "sha256": "ed316db7c4cbac929f2ae901b7bd5694dc8a4b889c647d3b6f55e4f80733f1e1" + "bytes": 900848, + "sha256": "84228edc7a9efee1d5b9d486a9ebfe0988c2feaa82fafc076d58769201fc7595" }, { "path": "skeleton.atlas", @@ -44,18 +44,18 @@ }, { "path": "skeleton.json", - "bytes": 688778, - "sha256": "d03cbfbf7ee004e2eb2bd6715eb9d6a96b6a6084b766dec311b25692b37b50f2" + "bytes": 689886, + "sha256": "a683ce9de7e570e2572c9ba7b79920b405ff2e4f7b40b46efd2bfa5ad301dfbd" }, { "path": "skeleton.model.json", - "bytes": 1177764, - "sha256": "eca8add48a7353ac23e5a4d12556635ff14b74555882ffe58f18276e309723b5" + "bytes": 1182610, + "sha256": "ce6ef0bdc4376acb96746c7260d242dedf47e15a6d81d4508a1e7729b8ba6e64" }, { "path": "skeleton.png", - "bytes": 1792596, - "sha256": "53f36ff9e0b7a3a21dc8032d810a15de9c97720a1176159a12b46578c4e1d419" + "bytes": 1793991, + "sha256": "45b52e2a93561cadfe60f9b2f27aa3f9877be7ee209659028fe66e3e3a0d36ba" } ] } diff --git a/demos/head-turn/bundle/README.md b/demos/head-turn/bundle/README.md index 71f71bb..ca39d20 100644 --- a/demos/head-turn/bundle/README.md +++ b/demos/head-turn/bundle/README.md @@ -2,10 +2,12 @@ This directory holds the compiled runtime assets for [`/demos/head-turn/`](../): -- `skeleton.model.json`, `skeleton.json`, `skeleton.atlas`, `skeleton.png` — compiled 2.5D head and body turn rig produced by `@rig-c/parts@1.71.0`, `@rig-c/pose@1.4.0`, and `rig-c@2.79.0` (`--profile rig-play --pack --page-edges free --pack-shape polygon`). -- `runtime.js` — browser ESM bundle of the published runtime packages (`@rig-c/play@1.20.0`, `@rig-c/pixi@0.1.5`, `rig-c@2.79.0`, `pixi.js@8.22.0`). +- `skeleton.model.json`, `skeleton.json`, `skeleton.atlas`, `skeleton.png` — compiled 2.5D head and body turn rig produced by `@rig-c/parts@1.71.1`, `@rig-c/pose@1.4.0`, and `rig-c@2.79.0` (`--profile rig-play --pack --page-edges free --pack-shape polygon`). +- `runtime.js` — browser ESM bundle of the published runtime packages (`@rig-c/play@1.21.0`, `@rig-c/pixi@0.1.5`, `rig-c@2.79.0`, `pixi.js@8.22.0`). - `app.js`, `index.html` — consumer page driving `pointer` mode (critically damped spring on `yaw_dial`, `pitch_dial`, `body_yaw_dial`, `gaze_x_dial`, `gaze_y_dial`) and `clip` mode (`@rig-c/pose` 4-way sign-test clip played by `@rig-c/play` and rendered on WebGL via `@rig-c/pixi`). - `look.png`, `depth.jpg` — the source character painting and confirmed grayscale depth atlas (`1284×1289`, SHA-256 `c814960c7e40dd1d5573a5e6d6e5d97eefeb309d015dea924359dc87f8e998a0`). - `THIRD_PARTY_LICENSES.txt` — third-party licence notices. See [`../README.md`](../README.md), [`../bundle-manifest.json`](../bundle-manifest.json), and [`../package-manifest.json`](../package-manifest.json) for full package provenance (`name@version` + npm tarball `sha512` integrity) and step-by-step rebuild instructions. + +The page sets its own player environment: `rig.environment({ wind: [0, 0], gravity: [0, 1] })`. Reassemble the approved source layers with turn roles before rig generation; do not reuse legacy assembled PNGs. diff --git a/demos/head-turn/bundle/app.js b/demos/head-turn/bundle/app.js index 008c71d..37afe5f 100644 --- a/demos/head-turn/bundle/app.js +++ b/demos/head-turn/bundle/app.js @@ -320,6 +320,8 @@ async function main() { const stage = new Container(); const rig = new PixiRig(assets, { ticker: null, autoUpdate: false }); + // This page owns its physics environment; authored response strengths stay in the rig. + rig.environment({ wind: [0, 0], gravity: [0, 1] }); stage.addChild(rig); // Measure neutral bounds at setup/idle to frame the bust cleanly in the viewport. diff --git a/demos/head-turn/bundle/runtime.js b/demos/head-turn/bundle/runtime.js index f5ff5f8..ef42796 100644 --- a/demos/head-turn/bundle/runtime.js +++ b/demos/head-turn/bundle/runtime.js @@ -1,7 +1,7 @@ -var YM=Object.create;var{getPrototypeOf:VM,defineProperty:fm,getOwnPropertyNames:HM}=Object;var mm=Object.prototype.hasOwnProperty;function zM(e){return this[e]}var qM,KM,JM=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var r=t?qM??=new WeakMap:KM??=new WeakMap,i=r.get(e);if(i)return i}n=e!=null?YM(VM(e)):{};let o=t||!e||!e.__esModule||!mm.call(e,"default")?fm(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of HM(e))if(!mm.call(o,a))fm(o,a,{get:zM.bind(e,a),enumerable:!0})}if(s)r.set(e,o);return o};var ZM=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var w=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(s){n=[s]}if(n)throw n[0];return t};var E,cc=(e)=>{if(typeof e==="function"||typeof e==="object"&&e.extension){if(!e.extension)throw Error("Extension class must have an extension object");e={...typeof e.extension!=="object"?{type:e.extension}:e.extension,ref:e}}if(typeof e==="object")e={...e};else throw Error("Invalid extension type");if(typeof e.type==="string")e.type=[e.type];return e},lo=(e,t)=>cc(e).priority??t,Z;var W=w(()=>{E=((e)=>(e.Application="application",e.WebGLPipes="webgl-pipes",e.WebGLPipesAdaptor="webgl-pipes-adaptor",e.WebGLSystem="webgl-system",e.WebGLLoader="webgl-loader",e.WebGPUPipes="webgpu-pipes",e.WebGPUPipesAdaptor="webgpu-pipes-adaptor",e.WebGPUSystem="webgpu-system",e.WebGPULoader="webgpu-loader",e.CanvasSystem="canvas-system",e.CanvasPipesAdaptor="canvas-pipes-adaptor",e.CanvasPipes="canvas-pipes",e.CanvasLoader="canvas-loader",e.Asset="asset",e.LoadParser="load-parser",e.ResolveParser="resolve-parser",e.CacheParser="cache-parser",e.DetectionParser="detection-parser",e.MaskEffect="mask-effect",e.BlendMode="blend-mode",e.TextureSource="texture-source",e.TextureUploaderWebGL="texture-uploader-webgl",e.TextureUploaderWebGPU="texture-uploader-webgpu",e.Environment="environment",e.ShapeBuilder="shape-builder",e.Batcher="batcher",e))(E||{}),Z={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(cc).forEach((t)=>{t.type.forEach((n)=>this._removeHandlers[n]?.(t))}),this},add(...e){return e.map(cc).forEach((t)=>{t.type.forEach((n)=>{let s=this._addHandlers,r=this._queue;if(!s[n])r[n]=r[n]||[],r[n]?.push(t);else s[n]?.(t)})}),this},handle(e,t,n){let s=this._addHandlers,r=this._removeHandlers;if(s[e]||r[e])throw Error(`Extension type ${e} already has a handler`);s[e]=t,r[e]=n;let i=this._queue;if(i[e])i[e]?.forEach((o)=>t(o)),delete i[e];return this},handleByMap(e,t){return this.handle(e,(n)=>{if(n.name)t[n.name]=n.ref},(n)=>{if(n.name)delete t[n.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,(s)=>{if(t.findIndex((i)=>i.name===s.name)>=0)return;t.push({name:s.name,value:s.ref}),t.sort((i,o)=>lo(o.value,n)-lo(i.value,n))},(s)=>{let r=t.findIndex((i)=>i.name===s.name);if(r!==-1)t.splice(r,1)})},handleByList(e,t,n=-1){return this.handle(e,(s)=>{if(t.includes(s.ref))return;t.push(s.ref),t.sort((r,i)=>lo(i,n)-lo(r,n))},(s)=>{let r=t.indexOf(s.ref);if(r!==-1)t.splice(r,1)})},mixin(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}}});var gm=ZM(function(JO,uc){var QM=Object.prototype.hasOwnProperty,dt="~";function Ir(){}if(Object.create){if(Ir.prototype=Object.create(null),!new Ir().__proto__)dt=!1}function eT(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function pm(e,t,n,s,r){if(typeof n!=="function")throw TypeError("The listener must be a function");var i=new eT(n,s||e,r),o=dt?dt+t:t;if(!e._events[o])e._events[o]=i,e._eventsCount++;else if(!e._events[o].fn)e._events[o].push(i);else e._events[o]=[e._events[o],i];return e}function co(e,t){if(--e._eventsCount===0)e._events=new Ir;else delete e._events[t]}function it(){this._events=new Ir,this._eventsCount=0}it.prototype.eventNames=function(){var t=[],n,s;if(this._eventsCount===0)return t;for(s in n=this._events)if(QM.call(n,s))t.push(dt?s.slice(1):s);if(Object.getOwnPropertySymbols)return t.concat(Object.getOwnPropertySymbols(n));return t};it.prototype.listeners=function(t){var n=dt?dt+t:t,s=this._events[n];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,i=s.length,o=Array(i);r{ym=JM(gm(),1),de=ym.default});var tT,hn=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},Je=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},Rt=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},Mm=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},xm=function(e){return{r:Rt(e.r,0,255),g:Rt(e.g,0,255),b:Rt(e.b,0,255),a:Rt(e.a)}},hc=function(e){return{r:Je(e.r),g:Je(e.g),b:Je(e.b),a:Je(e.a,3)}},nT,uo=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},Tm=function(e){var{r:t,g:n,b:s,a:r}=e,i=Math.max(t,n,s),o=i-Math.min(t,n,s),a=o?i===t?(n-s)/o:i===n?2+(s-t)/o:4+(t-n)/o:0;return{h:60*(a<0?a+6:a),s:i?o/i*100:0,v:i/255*100,a:r}},Cm=function(e){var{h:t,s:n,v:s,a:r}=e;t=t/360*6,n/=100,s/=100;var i=Math.floor(t),o=s*(1-n),a=s*(1-(t-i)*n),l=s*(1-(1-t+i)*n),u=i%6;return{r:255*[s,a,o,o,l,s][u],g:255*[l,s,s,a,o,o][u],b:255*[o,o,l,s,s,a][u],a:r}},bm=function(e){return{h:Mm(e.h),s:Rt(e.s,0,100),l:Rt(e.l,0,100),a:Rt(e.a)}},vm=function(e){return{h:Je(e.h),s:Je(e.s),l:Je(e.l),a:Je(e.a,3)}},_m=function(e){return Cm((n=(t=e).s,{h:t.h,s:(n*=((s=t.l)<50?s:100-s)/100)>0?2*n/(s+n)*100:0,v:s+n,a:t.a}));var t,n,s},Br=function(e){return{h:(t=Tm(e)).h,s:(r=(200-(n=t.s))*(s=t.v)/100)>0&&r<200?n*s/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,n,s,r},sT,rT,iT,oT,mc,Sm=function(e,t){for(var n=0;n{tT={grad:0.9,turn:360,rad:360/(2*Math.PI)},nT=/^#([0-9a-f]{3,8})$/i,sT=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rT=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,iT=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oT=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,mc={string:[[function(e){var t=nT.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?Je(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?Je(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=iT.exec(e)||oT.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:xm({r:Number(t[1])/(t[2]?0.39215686274509803:1),g:Number(t[3])/(t[4]?0.39215686274509803:1),b:Number(t[5])/(t[6]?0.39215686274509803:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=sT.exec(e)||rT.exec(e);if(!t)return null;var n,s,r=bm({h:(n=t[1],s=t[2],s===void 0&&(s="deg"),Number(n)*(tT[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return _m(r)},"hsl"]],object:[[function(e){var{r:t,g:n,b:s,a:r}=e,i=r===void 0?1:r;return hn(t)&&hn(n)&&hn(s)?xm({r:Number(t),g:Number(n),b:Number(s),a:Number(i)}):null},"rgb"],[function(e){var{h:t,s:n,l:s,a:r}=e,i=r===void 0?1:r;if(!hn(t)||!hn(n)||!hn(s))return null;var o=bm({h:Number(t),s:Number(n),l:Number(s),a:Number(i)});return _m(o)},"hsl"],[function(e){var{h:t,s:n,v:s,a:r}=e,i=r===void 0?1:r;if(!hn(t)||!hn(n)||!hn(s))return null;var o=function(a){return{h:Mm(a.h),s:Rt(a.s,0,100),v:Rt(a.v,0,100),a:Rt(a.a)}}({h:Number(t),s:Number(n),v:Number(s),a:Number(i)});return Cm(o)},"hsv"]]},pc=function(){function e(t){this.parsed=aT(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return Je(fc(this.rgba),2)},e.prototype.isDark=function(){return fc(this.rgba)<0.5},e.prototype.isLight=function(){return fc(this.rgba)>=0.5},e.prototype.toHex=function(){return t=hc(this.rgba),n=t.r,s=t.g,r=t.b,o=(i=t.a)<1?uo(Je(255*i)):"","#"+uo(n)+uo(s)+uo(r)+o;var t,n,s,r,i,o},e.prototype.toRgb=function(){return hc(this.rgba)},e.prototype.toRgbString=function(){return t=hc(this.rgba),n=t.r,s=t.g,r=t.b,(i=t.a)<1?"rgba("+n+", "+s+", "+r+", "+i+")":"rgb("+n+", "+s+", "+r+")";var t,n,s,r,i},e.prototype.toHsl=function(){return vm(Br(this.rgba))},e.prototype.toHslString=function(){return t=vm(Br(this.rgba)),n=t.h,s=t.s,r=t.l,(i=t.a)<1?"hsla("+n+", "+s+"%, "+r+"%, "+i+")":"hsl("+n+", "+s+"%, "+r+"%)";var t,n,s,r,i},e.prototype.toHsv=function(){return t=Tm(this.rgba),{h:Je(t.h),s:Je(t.s),v:Je(t.v),a:Je(t.a,3)};var t},e.prototype.invert=function(){return Xt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=0.1),Xt(dc(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=0.1),Xt(dc(this.rgba,-t))},e.prototype.grayscale=function(){return Xt(dc(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=0.1),Xt(km(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=0.1),Xt(km(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?Xt({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):Je(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=Br(this.rgba);return typeof t=="number"?Xt({h:t,s:n.s,l:n.l,a:n.a}):Je(n.h)},e.prototype.isEqual=function(t){return this.toHex()===Xt(t).toHex()},e}(),wm=[]});function gc(e,t){var n={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var r in n)s[n[r]]=r;var i={};e.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,u=s[this.toHex()];if(u)return u;if(o==null?void 0:o.closest){var c=this.toRgb(),h=1/0,d="black";if(!i.length)for(var f in n)i[f]=new e(n[f]).toRgb();for(var m in n){var p=(a=c,l=i[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));pi===n[o])}else if(t!==null&&n!==null){let i=Object.keys(t),o=Object.keys(n);if(i.length!==o.length)return!1;return i.every((a)=>t[a]===n[a])}return t===n}toRgba(){let[t,n,s,r]=this._components;return{r:t,g:n,b:s,a:r}}toRgb(){let[t,n,s]=this._components;return{r:t,g:n,b:s}}toRgbaString(){let[t,n,s]=this.toUint8RgbArray();return`rgba(${t},${n},${s},${this.alpha})`}toUint8RgbArray(t){let[n,s,r]=this._components;if(!this._arrayRgb)this._arrayRgb=[];return t||(t=this._arrayRgb),t[0]=Math.round(n*255),t[1]=Math.round(s*255),t[2]=Math.round(r*255),t}toArray(t){if(!this._arrayRgba)this._arrayRgba=[];t||(t=this._arrayRgba);let[n,s,r,i]=this._components;return t[0]=n,t[1]=s,t[2]=r,t[3]=i,t}toRgbArray(t){if(!this._arrayRgb)this._arrayRgb=[];t||(t=this._arrayRgb);let[n,s,r]=this._components;return t[0]=n,t[1]=s,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){let[t,n,s]=this.toUint8RgbArray();return(s<<16)+(n<<8)+t}toLittleEndianNumber(){let t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){let[n,s,r,i]=e._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=s,this._components[2]*=r,this._components[3]*=i,this._refreshInt(),this._value=null,this}premultiply(t,n=!0){if(n)this._components[0]*=t,this._components[1]*=t,this._components[2]*=t;return this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,n=!0){if(t===1)return-16777216+this._int;if(t===0)return n?0:this._int;let s=this._int>>16&255,r=this._int>>8&255,i=this._int&255;if(n)s=s*t+0.5|0,r=r*t+0.5|0,i=i*t+0.5|0;return(t*255<<24)+(s<<16)+(r<<8)+i}toHex(){let t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){let n=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-n.length)+n}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let n,s,r,i;if((typeof t==="number"||t instanceof Number)&&t>=0&&t<=16777215){let o=t;n=(o>>16&255)/255,s=(o>>8&255)/255,r=(o&255)/255,i=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,s,r,i=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,s,r,i=255]=t,n/=255,s/=255,r/=255,i/=255;else if(typeof t==="string"||typeof t==="object"){if(typeof t==="string"){let a=e.HEX_PATTERN.exec(t);if(a)t=`#${a[2]}`}let o=Xt(t);if(o.isValid())({r:n,g:s,b:r,a:i}=o.rgba),n/=255,s/=255,r/=255}if(n!==void 0)this._components[0]=n,this._components[1]=s,this._components[2]=r,this._components[3]=i,this._refreshInt();else throw Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[t,n,s]=this._components;this._int=(t*255<<16)+(n*255<<8)+(s*255|0)}_clamp(t,n=0,s=1){if(typeof t==="number")return Math.min(Math.max(t,n),s);return t.forEach((r,i)=>{t[i]=Math.min(Math.max(r,n),s)}),t}static isColorLike(t){return typeof t==="number"||typeof t==="string"||t instanceof Number||t instanceof e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}},he;var Pt=w(()=>{Em();Am([gc]);Es.shared=new Es;Es._temp=new Es;Es.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;he=Es});var Rm;var Pm=w(()=>{Rm={cullArea:null,cullable:!1,cullableChildren:!0}});var $m,Om,Im;var yc=w(()=>{$m=Math.PI*2,Om=180/Math.PI,Im=Math.PI/180});class ie{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new ie(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return xc.x=0,xc.y=0,xc}}var xc;var jt=w(()=>{xc=new ie});class U{constructor(e=1,t=0,n=0,s=1,r=0,i=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=s,this.tx=r,this.ty=i}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,n,s,r,i){return this.a=e,this.b=t,this.c=n,this.d=s,this.tx=r,this.ty=i,this}toArray(e,t){if(!this.array)this.array=new Float32Array(9);let n=t||this.array;if(e)n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1;else n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1;return n}apply(e,t){t=t||new ie;let{x:n,y:s}=e;return t.x=this.a*n+this.c*s+this.tx,t.y=this.b*n+this.d*s+this.ty,t}applyInverse(e,t){t=t||new ie;let n=this.a,s=this.b,r=this.c,i=this.d,o=this.tx,a=this.ty,l=1/(n*i+r*-s),{x:u,y:c}=e;return t.x=i*l*u+-r*l*c+(a*r-o*i)*l,t.y=n*l*c+-s*l*u+(-a*n+o*s)*l,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),s=this.a,r=this.c,i=this.tx;return this.a=s*t-this.b*n,this.b=s*n+this.b*t,this.c=r*t-this.d*n,this.d=r*n+this.d*t,this.tx=i*t-this.ty*n,this.ty=i*n+this.ty*t,this}append(e){let t=this.a,n=this.b,s=this.c,r=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*n+e.b*r,this.c=e.c*t+e.d*s,this.d=e.c*n+e.d*r,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*n+e.ty*r+this.ty,this}appendFrom(e,t){let{a:n,b:s,c:r,d:i,tx:o,ty:a}=e,{a:l,b:u,c,d:h}=t;return this.a=n*l+s*c,this.b=n*u+s*h,this.c=r*l+i*c,this.d=r*u+i*h,this.tx=o*l+a*c+t.tx,this.ty=o*u+a*h+t.ty,this}setTransform(e,t,n,s,r,i,o,a,l){return this.a=Math.cos(o+l)*r,this.b=Math.sin(o+l)*r,this.c=-Math.sin(o-a)*i,this.d=Math.cos(o-a)*i,this.tx=e-(n*this.a+s*this.c),this.ty=t-(n*this.b+s*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let n=this.a,s=this.c;this.a=n*e.a+this.b*e.c,this.b=n*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,n=this.b,s=this.c,r=this.d,i=e.pivot,o=-Math.atan2(-s,r),a=Math.atan2(n,t),l=Math.abs(o+a),u=Math.sqrt(t*t+n*n);if(l<0.00001||Math.abs($m-l)<0.00001)e.rotation=a,e.skew.x=e.skew.y=0;else if(Math.abs(Math.PI-l)<0.00001)e.rotation=a-Math.PI,e.skew.x=e.skew.y=0,u=-u;else e.rotation=0,e.skew.x=o,e.skew.y=a;return e.scale.x=u,e.scale.y=Math.sqrt(s*s+r*r),e.position.x=this.tx+(i.x*t+i.y*s),e.position.y=this.ty+(i.x*n+i.y*r),e}invert(){let e=this.a,t=this.b,n=this.c,s=this.d,r=this.tx,i=e*s-t*n;return this.a=s/i,this.b=-t/i,this.c=-n/i,this.d=e/i,this.tx=(n*this.ty-s*r)/i,this.ty=-(e*this.ty-t*r)/i,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let e=new U;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return uT.identity()}static get shared(){return cT.identity()}}var cT,uT;var me=w(()=>{yc();jt();cT=new U,uT=new U});class Ze{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(e){return new Ze(e??this._observer,this._x,this._y)}set(e=0,t=e){if(this._x!==e||this._y!==t)this._x=e,this._y=t,this._observer._onUpdate(this);return this}copyFrom(e){if(this._x!==e.x||this._y!==e.y)this._x=e.x,this._y=e.y,this._observer._onUpdate(this);return this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){if(this._x!==e)this._x=e,this._observer._onUpdate(this)}get y(){return this._y}set y(e){if(this._y!==e)this._y=e,this._observer._onUpdate(this)}}var bc=()=>{};function ee(e="default"){if(vc[e]===void 0)vc[e]=-1;return++vc[e]}var vc;var qe=w(()=>{vc={default:-1}});var Bm,ae="8.0.0",Dm="8.3.4",$t="8.21.0",Fm="8.22.0",Rs,X=(e,t,n=3)=>{if(Rs.quiet||Bm.has(t))return;let s=Error().stack,r=`${t} -Deprecated since v${e}`,i=typeof console.groupCollapsed==="function"&&!Rs.noColor;if(typeof s>"u")console.warn("PixiJS Deprecation Warning: ",r);else if(s=s.split(` +var dT=Object.create;var{getPrototypeOf:fT,defineProperty:Am,getOwnPropertyNames:mT}=Object;var Em=Object.prototype.hasOwnProperty;function pT(e){return this[e]}var gT,yT,xT=(e,t,n)=>{var s=e!=null&&typeof e==="object";if(s){var r=t?gT??=new WeakMap:yT??=new WeakMap,i=r.get(e);if(i)return i}n=e!=null?dT(fT(e)):{};let o=t||!e||!e.__esModule||!Em.call(e,"default")?Am(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of mT(e))if(!Em.call(o,a))Am(o,a,{get:pT.bind(e,a),enumerable:!0})}if(s)r.set(e,o);return o};var bT=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var M=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(s){n=[s]}if(n)throw n[0];return t};var D,xc=(e)=>{if(typeof e==="function"||typeof e==="object"&&e.extension){if(!e.extension)throw Error("Extension class must have an extension object");e={...typeof e.extension!=="object"?{type:e.extension}:e.extension,ref:e}}if(typeof e==="object")e={...e};else throw Error("Invalid extension type");if(typeof e.type==="string")e.type=[e.type];return e},po=(e,t)=>xc(e).priority??t,ne;var z=M(()=>{D=((e)=>(e.Application="application",e.WebGLPipes="webgl-pipes",e.WebGLPipesAdaptor="webgl-pipes-adaptor",e.WebGLSystem="webgl-system",e.WebGLLoader="webgl-loader",e.WebGPUPipes="webgpu-pipes",e.WebGPUPipesAdaptor="webgpu-pipes-adaptor",e.WebGPUSystem="webgpu-system",e.WebGPULoader="webgpu-loader",e.CanvasSystem="canvas-system",e.CanvasPipesAdaptor="canvas-pipes-adaptor",e.CanvasPipes="canvas-pipes",e.CanvasLoader="canvas-loader",e.Asset="asset",e.LoadParser="load-parser",e.ResolveParser="resolve-parser",e.CacheParser="cache-parser",e.DetectionParser="detection-parser",e.MaskEffect="mask-effect",e.BlendMode="blend-mode",e.TextureSource="texture-source",e.TextureUploaderWebGL="texture-uploader-webgl",e.TextureUploaderWebGPU="texture-uploader-webgpu",e.Environment="environment",e.ShapeBuilder="shape-builder",e.Batcher="batcher",e))(D||{}),ne={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...e){return e.map(xc).forEach((t)=>{t.type.forEach((n)=>this._removeHandlers[n]?.(t))}),this},add(...e){return e.map(xc).forEach((t)=>{t.type.forEach((n)=>{let s=this._addHandlers,r=this._queue;if(!s[n])r[n]=r[n]||[],r[n]?.push(t);else s[n]?.(t)})}),this},handle(e,t,n){let s=this._addHandlers,r=this._removeHandlers;if(s[e]||r[e])throw Error(`Extension type ${e} already has a handler`);s[e]=t,r[e]=n;let i=this._queue;if(i[e])i[e]?.forEach((o)=>t(o)),delete i[e];return this},handleByMap(e,t){return this.handle(e,(n)=>{if(n.name)t[n.name]=n.ref},(n)=>{if(n.name)delete t[n.name]})},handleByNamedList(e,t,n=-1){return this.handle(e,(s)=>{if(t.findIndex((i)=>i.name===s.name)>=0)return;t.push({name:s.name,value:s.ref}),t.sort((i,o)=>po(o.value,n)-po(i.value,n))},(s)=>{let r=t.findIndex((i)=>i.name===s.name);if(r!==-1)t.splice(r,1)})},handleByList(e,t,n=-1){return this.handle(e,(s)=>{if(t.includes(s.ref))return;t.push(s.ref),t.sort((r,i)=>po(i,n)-po(r,n))},(s)=>{let r=t.indexOf(s.ref);if(r!==-1)t.splice(r,1)})},mixin(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}}});var Rm=bT(function(wI,bc){var vT=Object.prototype.hasOwnProperty,gt="~";function Vr(){}if(Object.create){if(Vr.prototype=Object.create(null),!new Vr().__proto__)gt=!1}function _T(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function Pm(e,t,n,s,r){if(typeof n!=="function")throw TypeError("The listener must be a function");var i=new _T(n,s||e,r),o=gt?gt+t:t;if(!e._events[o])e._events[o]=i,e._eventsCount++;else if(!e._events[o].fn)e._events[o].push(i);else e._events[o]=[e._events[o],i];return e}function go(e,t){if(--e._eventsCount===0)e._events=new Vr;else delete e._events[t]}function ut(){this._events=new Vr,this._eventsCount=0}ut.prototype.eventNames=function(){var t=[],n,s;if(this._eventsCount===0)return t;for(s in n=this._events)if(vT.call(n,s))t.push(gt?s.slice(1):s);if(Object.getOwnPropertySymbols)return t.concat(Object.getOwnPropertySymbols(n));return t};ut.prototype.listeners=function(t){var n=gt?gt+t:t,s=this._events[n];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,i=s.length,o=Array(i);r{$m=xT(Rm(),1),ke=$m.default});var ST,yn=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},et=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},Gt=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},Lm=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},Om=function(e){return{r:Gt(e.r,0,255),g:Gt(e.g,0,255),b:Gt(e.b,0,255),a:Gt(e.a)}},vc=function(e){return{r:et(e.r),g:et(e.g),b:et(e.b),a:et(e.a,3)}},wT,yo=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},Um=function(e){var{r:t,g:n,b:s,a:r}=e,i=Math.max(t,n,s),o=i-Math.min(t,n,s),a=o?i===t?(n-s)/o:i===n?2+(s-t)/o:4+(t-n)/o:0;return{h:60*(a<0?a+6:a),s:i?o/i*100:0,v:i/255*100,a:r}},Wm=function(e){var{h:t,s:n,v:s,a:r}=e;t=t/360*6,n/=100,s/=100;var i=Math.floor(t),o=s*(1-n),a=s*(1-(t-i)*n),l=s*(1-(1-t+i)*n),u=i%6;return{r:255*[s,a,o,o,l,s][u],g:255*[l,s,s,a,o,o][u],b:255*[o,o,l,s,s,a][u],a:r}},Im=function(e){return{h:Lm(e.h),s:Gt(e.s,0,100),l:Gt(e.l,0,100),a:Gt(e.a)}},Bm=function(e){return{h:et(e.h),s:et(e.s),l:et(e.l),a:et(e.a,3)}},Fm=function(e){return Wm((n=(t=e).s,{h:t.h,s:(n*=((s=t.l)<50?s:100-s)/100)>0?2*n/(s+n)*100:0,v:s+n,a:t.a}));var t,n,s},jr=function(e){return{h:(t=Um(e)).h,s:(r=(200-(n=t.s))*(s=t.v)/100)>0&&r<200?n*s/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,n,s,r},kT,MT,TT,CT,wc,Dm=function(e,t){for(var n=0;n{ST={grad:0.9,turn:360,rad:360/(2*Math.PI)},wT=/^#([0-9a-f]{3,8})$/i,kT=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,MT=/^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,CT=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wc={string:[[function(e){var t=wT.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?et(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?et(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=TT.exec(e)||CT.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:Om({r:Number(t[1])/(t[2]?0.39215686274509803:1),g:Number(t[3])/(t[4]?0.39215686274509803:1),b:Number(t[5])/(t[6]?0.39215686274509803:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=kT.exec(e)||MT.exec(e);if(!t)return null;var n,s,r=Im({h:(n=t[1],s=t[2],s===void 0&&(s="deg"),Number(n)*(ST[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Fm(r)},"hsl"]],object:[[function(e){var{r:t,g:n,b:s,a:r}=e,i=r===void 0?1:r;return yn(t)&&yn(n)&&yn(s)?Om({r:Number(t),g:Number(n),b:Number(s),a:Number(i)}):null},"rgb"],[function(e){var{h:t,s:n,l:s,a:r}=e,i=r===void 0?1:r;if(!yn(t)||!yn(n)||!yn(s))return null;var o=Im({h:Number(t),s:Number(n),l:Number(s),a:Number(i)});return Fm(o)},"hsl"],[function(e){var{h:t,s:n,v:s,a:r}=e,i=r===void 0?1:r;if(!yn(t)||!yn(n)||!yn(s))return null;var o=function(a){return{h:Lm(a.h),s:Gt(a.s,0,100),v:Gt(a.v,0,100),a:Gt(a.a)}}({h:Number(t),s:Number(n),v:Number(s),a:Number(i)});return Wm(o)},"hsv"]]},kc=function(){function e(t){this.parsed=AT(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return et(Sc(this.rgba),2)},e.prototype.isDark=function(){return Sc(this.rgba)<0.5},e.prototype.isLight=function(){return Sc(this.rgba)>=0.5},e.prototype.toHex=function(){return t=vc(this.rgba),n=t.r,s=t.g,r=t.b,o=(i=t.a)<1?yo(et(255*i)):"","#"+yo(n)+yo(s)+yo(r)+o;var t,n,s,r,i,o},e.prototype.toRgb=function(){return vc(this.rgba)},e.prototype.toRgbString=function(){return t=vc(this.rgba),n=t.r,s=t.g,r=t.b,(i=t.a)<1?"rgba("+n+", "+s+", "+r+", "+i+")":"rgb("+n+", "+s+", "+r+")";var t,n,s,r,i},e.prototype.toHsl=function(){return Bm(jr(this.rgba))},e.prototype.toHslString=function(){return t=Bm(jr(this.rgba)),n=t.h,s=t.s,r=t.l,(i=t.a)<1?"hsla("+n+", "+s+"%, "+r+"%, "+i+")":"hsl("+n+", "+s+"%, "+r+"%)";var t,n,s,r,i},e.prototype.toHsv=function(){return t=Um(this.rgba),{h:et(t.h),s:et(t.s),v:et(t.v),a:et(t.a,3)};var t},e.prototype.invert=function(){return qt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=0.1),qt(_c(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=0.1),qt(_c(this.rgba,-t))},e.prototype.grayscale=function(){return qt(_c(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=0.1),qt(Nm(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=0.1),qt(Nm(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?qt({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):et(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=jr(this.rgba);return typeof t=="number"?qt({h:t,s:n.s,l:n.l,a:n.a}):et(n.h)},e.prototype.isEqual=function(t){return this.toHex()===qt(t).toHex()},e}(),Gm=[]});function Mc(e,t){var n={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var r in n)s[n[r]]=r;var i={};e.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,u=s[this.toHex()];if(u)return u;if(o==null?void 0:o.closest){var c=this.toRgb(),h=1/0,d="black";if(!i.length)for(var f in n)i[f]=new e(n[f]).toRgb();for(var m in n){var p=(a=c,l=i[m],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));pi===n[o])}else if(t!==null&&n!==null){let i=Object.keys(t),o=Object.keys(n);if(i.length!==o.length)return!1;return i.every((a)=>t[a]===n[a])}return t===n}toRgba(){let[t,n,s,r]=this._components;return{r:t,g:n,b:s,a:r}}toRgb(){let[t,n,s]=this._components;return{r:t,g:n,b:s}}toRgbaString(){let[t,n,s]=this.toUint8RgbArray();return`rgba(${t},${n},${s},${this.alpha})`}toUint8RgbArray(t){let[n,s,r]=this._components;if(!this._arrayRgb)this._arrayRgb=[];return t||(t=this._arrayRgb),t[0]=Math.round(n*255),t[1]=Math.round(s*255),t[2]=Math.round(r*255),t}toArray(t){if(!this._arrayRgba)this._arrayRgba=[];t||(t=this._arrayRgba);let[n,s,r,i]=this._components;return t[0]=n,t[1]=s,t[2]=r,t[3]=i,t}toRgbArray(t){if(!this._arrayRgb)this._arrayRgb=[];t||(t=this._arrayRgb);let[n,s,r]=this._components;return t[0]=n,t[1]=s,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){let[t,n,s]=this.toUint8RgbArray();return(s<<16)+(n<<8)+t}toLittleEndianNumber(){let t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){let[n,s,r,i]=e._temp.setValue(t)._components;return this._components[0]*=n,this._components[1]*=s,this._components[2]*=r,this._components[3]*=i,this._refreshInt(),this._value=null,this}premultiply(t,n=!0){if(n)this._components[0]*=t,this._components[1]*=t,this._components[2]*=t;return this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,n=!0){if(t===1)return-16777216+this._int;if(t===0)return n?0:this._int;let s=this._int>>16&255,r=this._int>>8&255,i=this._int&255;if(n)s=s*t+0.5|0,r=r*t+0.5|0,i=i*t+0.5|0;return(t*255<<24)+(s<<16)+(r<<8)+i}toHex(){let t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){let n=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-n.length)+n}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let n,s,r,i;if((typeof t==="number"||t instanceof Number)&&t>=0&&t<=16777215){let o=t;n=(o>>16&255)/255,s=(o>>8&255)/255,r=(o&255)/255,i=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[n,s,r,i=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[n,s,r,i=255]=t,n/=255,s/=255,r/=255,i/=255;else if(typeof t==="string"||typeof t==="object"){if(typeof t==="string"){let a=e.HEX_PATTERN.exec(t);if(a)t=`#${a[2]}`}let o=qt(t);if(o.isValid())({r:n,g:s,b:r,a:i}=o.rgba),n/=255,s/=255,r/=255}if(n!==void 0)this._components[0]=n,this._components[1]=s,this._components[2]=r,this._components[3]=i,this._refreshInt();else throw Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);let[t,n,s]=this._components;this._int=(t*255<<16)+(n*255<<8)+(s*255|0)}_clamp(t,n=0,s=1){if(typeof t==="number")return Math.min(Math.max(t,n),s);return t.forEach((r,i)=>{t[i]=Math.min(Math.max(r,n),s)}),t}static isColorLike(t){return typeof t==="number"||typeof t==="string"||t instanceof Number||t instanceof e||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}},we;var Lt=M(()=>{Vm();Xm([Mc]);Ns.shared=new Ns;Ns._temp=new Ns;Ns.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;we=Ns});var jm;var Ym=M(()=>{jm={cullArea:null,cullable:!1,cullableChildren:!0}});var Hm,zm,qm;var Tc=M(()=>{Hm=Math.PI*2,zm=180/Math.PI,qm=Math.PI/180});class ue{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new ue(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Cc.x=0,Cc.y=0,Cc}}var Cc;var Kt=M(()=>{Cc=new ue});class j{constructor(e=1,t=0,n=0,s=1,r=0,i=0){this.array=null,this.a=e,this.b=t,this.c=n,this.d=s,this.tx=r,this.ty=i}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,n,s,r,i){return this.a=e,this.b=t,this.c=n,this.d=s,this.tx=r,this.ty=i,this}toArray(e,t){if(!this.array)this.array=new Float32Array(9);let n=t||this.array;if(e)n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1;else n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1;return n}apply(e,t){t=t||new ue;let{x:n,y:s}=e;return t.x=this.a*n+this.c*s+this.tx,t.y=this.b*n+this.d*s+this.ty,t}applyInverse(e,t){t=t||new ue;let n=this.a,s=this.b,r=this.c,i=this.d,o=this.tx,a=this.ty,l=1/(n*i+r*-s),{x:u,y:c}=e;return t.x=i*l*u+-r*l*c+(a*r-o*i)*l,t.y=n*l*c+-s*l*u+(-a*n+o*s)*l,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),s=this.a,r=this.c,i=this.tx;return this.a=s*t-this.b*n,this.b=s*n+this.b*t,this.c=r*t-this.d*n,this.d=r*n+this.d*t,this.tx=i*t-this.ty*n,this.ty=i*n+this.ty*t,this}append(e){let t=this.a,n=this.b,s=this.c,r=this.d;return this.a=e.a*t+e.b*s,this.b=e.a*n+e.b*r,this.c=e.c*t+e.d*s,this.d=e.c*n+e.d*r,this.tx=e.tx*t+e.ty*s+this.tx,this.ty=e.tx*n+e.ty*r+this.ty,this}appendFrom(e,t){let{a:n,b:s,c:r,d:i,tx:o,ty:a}=e,{a:l,b:u,c,d:h}=t;return this.a=n*l+s*c,this.b=n*u+s*h,this.c=r*l+i*c,this.d=r*u+i*h,this.tx=o*l+a*c+t.tx,this.ty=o*u+a*h+t.ty,this}setTransform(e,t,n,s,r,i,o,a,l){return this.a=Math.cos(o+l)*r,this.b=Math.sin(o+l)*r,this.c=-Math.sin(o-a)*i,this.d=Math.cos(o-a)*i,this.tx=e-(n*this.a+s*this.c),this.ty=t-(n*this.b+s*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let n=this.a,s=this.c;this.a=n*e.a+this.b*e.c,this.b=n*e.b+this.b*e.d,this.c=s*e.a+this.d*e.c,this.d=s*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){let t=this.a,n=this.b,s=this.c,r=this.d,i=e.pivot,o=-Math.atan2(-s,r),a=Math.atan2(n,t),l=Math.abs(o+a),u=Math.sqrt(t*t+n*n);if(l<0.00001||Math.abs(Hm-l)<0.00001)e.rotation=a,e.skew.x=e.skew.y=0;else if(Math.abs(Math.PI-l)<0.00001)e.rotation=a-Math.PI,e.skew.x=e.skew.y=0,u=-u;else e.rotation=0,e.skew.x=o,e.skew.y=a;return e.scale.x=u,e.scale.y=Math.sqrt(s*s+r*r),e.position.x=this.tx+(i.x*t+i.y*s),e.position.y=this.ty+(i.x*n+i.y*r),e}invert(){let e=this.a,t=this.b,n=this.c,s=this.d,r=this.tx,i=e*s-t*n;return this.a=s/i,this.b=-t/i,this.c=-n/i,this.d=e/i,this.tx=(n*this.ty-s*r)/i,this.ty=-(e*this.ty-t*r)/i,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){let e=new j;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return RT.identity()}static get shared(){return PT.identity()}}var PT,RT;var Ce=M(()=>{Tc();Kt();PT=new j,RT=new j});class tt{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}clone(e){return new tt(e??this._observer,this._x,this._y)}set(e=0,t=e){if(this._x!==e||this._y!==t)this._x=e,this._y=t,this._observer._onUpdate(this);return this}copyFrom(e){if(this._x!==e.x||this._y!==e.y)this._x=e.x,this._y=e.y,this._observer._onUpdate(this);return this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){if(this._x!==e)this._x=e,this._observer._onUpdate(this)}get y(){return this._y}set y(e){if(this._y!==e)this._y=e,this._observer._onUpdate(this)}}var Ac=()=>{};function ie(e="default"){if(Ec[e]===void 0)Ec[e]=-1;return++Ec[e]}var Ec;var Ze=M(()=>{Ec={default:-1}});var Km,be="8.0.0",Jm="8.3.4",Ut="8.21.0",Zm="8.22.0",Gs,q=(e,t,n=3)=>{if(Gs.quiet||Km.has(t))return;let s=Error().stack,r=`${t} +Deprecated since v${e}`,i=typeof console.groupCollapsed==="function"&&!Gs.noColor;if(typeof s>"u")console.warn("PixiJS Deprecation Warning: ",r);else if(s=s.split(` `).splice(n).join(` -`),i)console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(s),console.groupEnd();else console.warn("PixiJS Deprecation Warning: ",r),console.warn(s);Bm.add(t)};var Re=w(()=>{Bm=new Set,Rs={quiet:!1,noColor:!1};Object.defineProperties(X,{quiet:{get:()=>Rs.quiet,set:(e)=>{Rs.quiet=e},enumerable:!0,configurable:!1},noColor:{get:()=>Rs.noColor,set:(e)=>{Rs.noColor=e},enumerable:!0,configurable:!1}})});function V(...e){if(_c===Nm)return;if(_c++,_c===Nm)console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS.");else console.warn("PixiJS Warning: ",...e)}var _c=0,Nm=500;var Pe=()=>{};var Ot;var Hn=w(()=>{Ot={_registeredResources:new Set,register(e){this._registeredResources.add(e)},unregister(e){this._registeredResources.delete(e)},release(){this._registeredResources.forEach((e)=>e.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(e){return this._registeredResources.has(e)},reset(){this._registeredResources.clear()}}});class Sc{constructor(e,t){if(this._pool=[],this._count=0,this._index=0,this._classType=e,t)this.prepopulate(t)}prepopulate(e){for(let t=0;t0)t=this._pool[--this._index];else t=new this._classType,this._count++;return t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e{};class Lm{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){if(!this._poolsByClass.has(e))this._poolsByClass.set(e,new Sc(e));return this._poolsByClass.get(e)}stats(){let e={};return this._poolsByClass.forEach((t)=>{let n=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[n]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach((e)=>e.clear()),this._poolsByClass.clear()}}var Ce;var dn=w(()=>{Hn();Gm();Ce=new Lm;Ot.register(Ce)});var Um;var Wm=w(()=>{Re();Um={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(e){if(typeof e==="boolean"&&e===!1)this.disableRenderGroup();else this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(e===!0?{}:e)},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(e){X("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(e)}}});function ho(e,t,n){let s=e.length,r;if(t>=s||n===0)return;n=t+n>s?s-t:n;let i=s-n;for(r=t;r{};var Xm;var jm=w(()=>{kc();Re();Xm={allowChildren:!0,removeChildren(e=0,t){let n=t??this.children.length,s=n-e,r=[];if(s>0&&s<=n){for(let o=n-1;o>=e;o--){let a=this.children[o];if(!a)continue;r.push(a),a.parent=null}ho(this.children,e,n);let i=this.renderGroup||this.parentRenderGroup;if(i)i.removeChildren(r);for(let o=0;o0)this._didViewChangeTick++;return r}else if(s===0&&this.children.length===0)return r;throw RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(e){let t=this.getChildAt(e);return this.removeChild(t)},getChildAt(e){if(e<0||e>=this.children.length)throw Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]},setChildIndex(e,t){if(t<0||t>=this.children.length)throw Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(e),this.addChildAt(e,t)},getChildIndex(e){let t=this.children.indexOf(e);if(t===-1)throw Error("The supplied Container must be a child of the caller");return t},addChildAt(e,t){if(!this.allowChildren)X(ae,"addChildAt: Only Containers will be allowed to add children in v8.0.0");let{children:n}=this;if(t<0||t>n.length)throw Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${n.length}`);let s=e.parent===this;if(e.parent){let i=e.parent.children.indexOf(e);if(s){if(i===t)return e;e.parent.children.splice(i,1)}else e.removeFromParent()}if(t===n.length)n.push(e);else n.splice(t,0,e);let r=this.renderGroup||this.parentRenderGroup;if(this.sortableChildren)this.sortDirty=!0;if(s){if(r)r.structureDidChange=!0;return e}if(e.parent=this,e.didChange=!0,e._updateFlags=15,r)r.addChild(e);return this.emit("childAdded",e,this,t),e.emit("added",this),e},swapChildren(e,t){if(e===t)return;let n=this.getChildIndex(e),s=this.getChildIndex(t);this.children[n]=t,this.children[s]=e;let r=this.renderGroup||this.parentRenderGroup;if(r)r.structureDidChange=!0;this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...e){if(e.length===1)return this.reparentChildAt(e[0],this.children.length);return e.forEach((t)=>this.reparentChildAt(t,this.children.length)),e[0]},reparentChildAt(e,t){if(e.parent===this)return this.setChildIndex(e,t),e;let n=e.worldTransform.clone();e.removeFromParent(),this.addChildAt(e,t);let s=this.worldTransform.clone();return s.invert(),n.prepend(s),e.setFromMatrix(n),e},replaceChild(e,t){e.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(e)),t.setFromMatrix(e.localTransform),t.updateLocalTransform(),this.removeChild(e)}}});var Ym;var Vm=w(()=>{Ym={collectRenderables(e,t,n){if(this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild)return;if(this.sortableChildren)this.sortChildren();if(this.isSimple)this.collectRenderablesSimple(e,t,n);else if(this.renderGroup)t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,e);else this.collectRenderablesWithEffects(e,t,n)},collectRenderablesSimple(e,t,n){let s=this.children,r=s.length;for(let i=0;i=0;r--){let i=this.effects[r];s[i.pipe].pop(i,this,e)}}}});class kn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e{};class Hm{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){if(this._initialized)return;this._initialized=!0,this._effectClasses.forEach((e)=>{this.add({test:e.test,maskClass:e})})}add(e){this._tests.push(e)}getMaskEffect(e){if(!this._initialized)this.init();for(let t=0;t{W();dn();mo=new Hm;Z.handleByList(E.MaskEffect,mo._effectClasses)});var qm;var Km=w(()=>{fo();zm();qm={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){let e=this.renderGroup||this.parentRenderGroup;if(e)e.structureDidChange=!0},addEffect(e){if(this.effects.indexOf(e)!==-1)return;this.effects.push(e),this.effects.sort((n,s)=>n.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple()},removeEffect(e){let t=this.effects.indexOf(e);if(t===-1)return;this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple()},set mask(e){let t=this._maskEffect;if(t?.mask===e)return;if(t)this.removeEffect(t),mo.returnMaskEffect(t),this._maskEffect=null;if(e===null||e===void 0)return;this._maskEffect=mo.getMaskEffect(e),this.addEffect(this._maskEffect)},get mask(){return this._maskEffect?.mask},setMask(e){if(this._maskOptions={...this._maskOptions,...e},e.mask)this.mask=e.mask;this._markStructureAsChanged()},set filters(e){if(!Array.isArray(e)&&e)e=[e];let t=this._filterEffect||(this._filterEffect=new kn);e=e;let n=e?.length>0,s=t.filters?.length>0,r=n!==s;if(e=Array.isArray(e)?e.slice(0):e,t.filters=Object.freeze(e),r)if(n)this.addEffect(t);else this.removeEffect(t),t.filters=e??null},get filters(){return this._filterEffect?.filters},set filterArea(e){this._filterEffect||(this._filterEffect=new kn),this._filterEffect.filterArea=e},get filterArea(){return this._filterEffect?.filterArea}}});var Jm;var Zm=w(()=>{Re();Jm={label:null,get name(){return X(ae,"Container.name property has been removed, use Container.label instead"),this.label},set name(e){X(ae,"Container.name property has been removed, use Container.label instead"),this.label=e},getChildByName(e,t=!1){return this.getChildByLabel(e,t)},getChildByLabel(e,t=!1){let n=this.children;for(let s=0;s=this.x&&e=this.y&&t=c&&e<=h&&t>=d&&t<=f&&!(e>m&&ey&&te.right?e.right:this.right)<=M)return!1;let T=this.ye.bottom?e.bottom:this.bottom)>T}let n=this.left,s=this.right,r=this.top,i=this.bottom;if(s<=n||i<=r)return!1;let o=po[0].set(e.left,e.top),a=po[1].set(e.left,e.bottom),l=po[2].set(e.right,e.top),u=po[3].set(e.right,e.bottom);if(l.x<=o.x||a.y<=o.y)return!1;let c=Math.sign(t.a*t.d-t.b*t.c);if(c===0)return!1;if(t.apply(o,o),t.apply(a,a),t.apply(l,l),t.apply(u,u),Math.max(o.x,a.x,l.x,u.x)<=n||Math.min(o.x,a.x,l.x,u.x)>=s||Math.max(o.y,a.y,l.y,u.y)<=r||Math.min(o.y,a.y,l.y,u.y)>=i)return!1;let h=c*(a.y-o.y),d=c*(o.x-a.x),f=h*n+d*r,m=h*s+d*r,p=h*n+d*i,y=h*s+d*i;if(Math.max(f,m,p,y)<=h*o.x+d*o.y||Math.min(f,m,p,y)>=h*u.x+d*u.y)return!1;let g=c*(o.y-l.y),x=c*(l.x-o.x),b=g*n+x*r,v=g*s+x*r,_=g*n+x*i,S=g*s+x*i;if(Math.max(b,v,_,S)<=g*o.x+x*o.y||Math.min(b,v,_,S)>=g*u.x+x*u.y)return!1;return!0}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){let t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),s=Math.max(this.y,e.y),r=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(n-t,0),this.y=s,this.height=Math.max(r-s,0),this}ceil(e=1,t=0.001){let n=Math.ceil((this.x+this.width-t)*e)/e,s=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=n-this.x,this.height=s-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){let t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),s=Math.min(this.y,e.y),r=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=n-t,this.y=s,this.height=r-s,this}getBounds(e){return e||(e=new Q),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;let{x:t,y:n}=e,s=e.x+e.width,r=e.y+e.height;return t>=this.x&&t=this.y&&n=this.x&&s<=this.x+this.width&&r>=this.y&&r<=this.y+this.height}set(e,t,n,s){return this.x=e,this.y=t,this.width=n,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}var po;var et=w(()=>{jt();po=[new ie,new ie,new ie,new ie]});class fe{constructor(e=1/0,t=1/0,n=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Qm,this.minX=e,this.minY=t,this.maxX=n,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){if(!this._rectangle)this._rectangle=new Q;let e=this._rectangle;if(this.minX>this.maxX||this.minY>this.maxY)e.x=0,e.y=0,e.width=0,e.height=0;else e.copyFromBounds(this);return e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Qm,this}set(e,t,n,s){this.minX=e,this.minY=t,this.maxX=n,this.maxY=s}addFrame(e,t,n,s,r){r||(r=this.matrix);let i=r.a,o=r.b,a=r.c,l=r.d,u=r.tx,c=r.ty,h=this.minX,d=this.minY,f=this.maxX,m=this.maxY,p=i*e+a*t+u,y=o*e+l*t+c;if(pf)f=p;if(y>m)m=y;if(p=i*n+a*t+u,y=o*n+l*t+c,pf)f=p;if(y>m)m=y;if(p=i*e+a*s+u,y=o*e+l*s+c,pf)f=p;if(y>m)m=y;if(p=i*n+a*s+u,y=o*n+l*s+c,pf)f=p;if(y>m)m=y;this.minX=h,this.minY=d,this.maxX=f,this.maxY=m}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxXthis.maxX?h:this.maxX,this.maxY=d>this.maxY?d:this.maxY,h=i*t+a*r+u,d=o*t+l*r+c,this.minX=hthis.maxX?h:this.maxX,this.maxY=d>this.maxY?d:this.maxY,h=i*s+a*r+u,d=o*s+l*r+c,this.minX=hthis.maxX?h:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(e){if(this.minXe.right)this.maxX=e.right;if(this.minYe.bottom)this.maxY=e.bottom;return this}fitBounds(e,t,n,s){if(this.minXt)this.maxX=t;if(this.minYs)this.maxY=s;return this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new fe(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){let t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){let t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,t,n,s){let r=this.minX,i=this.minY,o=this.maxX,a=this.maxY;s||(s=this.matrix);let l=s.a,u=s.b,c=s.c,h=s.d,d=s.tx,f=s.ty;for(let m=t;mo?g:o,a=x>a?x:a}this.minX=r,this.minY=i,this.maxX=o,this.maxY=a}containsPoint(e,t){if(this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t)return!0;return!1}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var Qm;var ft=w(()=>{me();et();Qm=new U});var Ye,_t;var zn=w(()=>{me();dn();ft();Ye=Ce.getPool(U),_t=Ce.getPool(fe)});var hT,ep;var tp=w(()=>{me();ft();zn();hT=new U,ep={getFastGlobalBounds(e,t){if(t||(t=new fe),t.clear(),this._getGlobalBoundsRecursive(!!e,t,this.parentRenderLayer),!t.isValid)t.set(0,0,0,0);let n=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(n.worldTransform),t},_getGlobalBoundsRecursive(e,t,n){let s=t;if(e&&this.parentRenderLayer&&this.parentRenderLayer!==n)return;if(this.localDisplayStatus!==7||!this.measurable)return;let r=!!this.effects.length;if(this.renderGroup||r)s=_t.get().clear();if(this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){let o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}let i=this.children;for(let o=0;o{me();zn()});function yo(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;let n=e>>16&255,s=e>>8&255,r=e&255,i=t>>16&255,o=t>>8&255,a=t&255,l=n*i/255|0,u=s*o/255|0,c=r*a/255|0;return(l<<16)+(u<<8)+c}var wc=()=>{};function $s(e,t){if(e===sp)return t;if(t===sp)return e;return yo(e,t)}var sp=16777215;var Mc=w(()=>{wc()});function Fr(e){return((e&255)<<16)+(e&65280)+(e>>16&255)}var rp;var ip=w(()=>{me();Dr();zn();Mc();rp={getGlobalAlpha(e){if(e){if(this.renderGroup)return this.renderGroup.worldAlpha;if(this.parentRenderGroup)return this.parentRenderGroup.worldAlpha*this.alpha;return this.alpha}let t=this.alpha,n=this.parent;while(n)t*=n.alpha,n=n.parent;return t},getGlobalTransform(e=new U,t){if(t)return e.copyFrom(this.worldTransform);this.updateLocalTransform();let n=go(this,Ye.get().identity());return e.appendFrom(this.localTransform,n),Ye.return(n),e},getGlobalTint(e){if(e){if(this.renderGroup)return Fr(this.renderGroup.worldColor);if(this.parentRenderGroup)return Fr($s(this.localColor,this.parentRenderGroup.worldColor));return this.tint}let t=this.localColor,n=this.parent;while(n)t=$s(t,n.localColor),n=n.parent;return Fr(t)}}});function Os(e,t,n){if(t.clear(),n||(n=U.IDENTITY),op(e,t,n,e,!0),!t.isValid)t.set(0,0,0,0);return t}function op(e,t,n,s,r){let i;if(!r){if(!e.visible||!e.measurable)return;e.updateLocalTransform();let l=e.localTransform;i=Ye.get(),i.appendFrom(l,n)}else i=Ye.get(),i=n.copyTo(i);let o=t,a=!!e.effects.length;if(a)t=_t.get().clear();if(e.boundsArea)t.addRect(e.boundsArea,i);else{if(e.renderPipeId)t.matrix=i,t.addBounds(e.bounds);let l=e.children;for(let u=0;u{me();zn()});function Tc(e,t){let n=e.children;for(let s=0;s{};var dT,lp;var cp=w(()=>{me();ft();Dr();xo();ap();dT=new U,lp={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(e,t){let n=Math.sign(this.scale.x)||1;if(t!==0)this.scale.x=e/t*n;else this.scale.x=n},_setHeight(e,t){let n=Math.sign(this.scale.y)||1;if(t!==0)this.scale.y=e/t*n;else this.scale.y=n},getLocalBounds(){if(!this._localBoundsCacheData)this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new fe};let e=this._localBoundsCacheData;if(e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick)e.didChange=!0,e.data[0]=this._didViewChangeTick;if(Tc(this,e),e.didChange)Os(this,e.localBounds,dT);return e.localBounds},getBounds(e,t){return Ps(this,e,t||new fe)}}});var up;var hp=w(()=>{up={_onRender:null,set onRender(e){let t=this.renderGroup||this.parentRenderGroup;if(!e){if(this._onRender)t?.removeOnRender(this);this._onRender=null;return}if(!this._onRender)t?.addOnRender(this);this._onRender=e},get onRender(){return this._onRender}}});function fT(e,t){return e._zIndex-t._zIndex}var dp;var fp=w(()=>{dp={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(e){if(this._zIndex===e)return;this._zIndex=e,this.depthOfChildModified()},depthOfChildModified(){if(this.parent)this.parent.sortableChildren=!0,this.parent.sortDirty=!0;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0},sortChildren(){if(!this.sortDirty)return;this.sortDirty=!1,this.children.sort(fT)}}});var mp;var pp=w(()=>{jt();zn();mp={getGlobalPosition(e=new ie,t=!1){if(this.parent)this.parent.toGlobal(this._position,e,t);else e.x=this._position.x,e.y=this._position.y;return e},toGlobal(e,t,n=!1){let s=this.getGlobalTransform(Ye.get(),n);return t=s.apply(e,t),Ye.return(s),t},toLocal(e,t,n,s){if(t)e=t.toGlobal(e,n,s);let r=this.getGlobalTransform(Ye.get(),s);return n=r.applyInverse(e,n),Ye.return(r),n}}});class qn{constructor(){this.uid=ee("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){if(this.renderPipes)for(let e in this.renderPipes)this.renderPipes[e].destroyInstructionSet?.(this);this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}var bo=w(()=>{qe()});function Is(e){return e+=e===0?1:0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function fn(e){return!(e&e-1)&&!!e}var vo=()=>{};function _o(e){let t={};for(let n in e)if(e[n]!==void 0)t[n]=e[n];return t}var Cc=()=>{};function mT(e){let t=gp[e];if(t===void 0)gp[e]=ee("resource");return t}var gp,yp,Bs;var Ac=w(()=>{Ke();qe();Re();gp=Object.create(null);yp=class e extends de{constructor(t={}){super();this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,t={...e.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){X(ae,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){if(this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1)this.scaleMode="linear"}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){let t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=mT(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};yp.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};Bs=yp});function pT(e){if(e.viewDimension)return e.viewDimension;if(e.depth)return"3d";return e.arrayLayerCount>1?"2d-array":"2d"}function gT(e,t,n){if(e.depth!==void 0&&typeof e.depth!=="number")throw Error(`[TextureSource] depth is a 3D texture's depth in texels, but got ${e.depth}. For a depth buffer, use the depth option of a RenderTarget or the renderer.`);if(e.depth&&e.arrayLayerCount>1)throw Error("[TextureSource] depth and arrayLayerCount can't be combined: use depth for a 3D texture or arrayLayerCount for a 2D array.");if(e.depth&&t!=="3d")throw Error(`[TextureSource] depth makes a 3D texture, but viewDimension is '${t}'. Use arrayLayerCount for layered textures.`);if(t==="3d"&&e.arrayLayerCount>1)throw Error("[TextureSource] a 3D texture takes depth, not arrayLayerCount.");if(e.dimensions&&e.dimensions!==n)throw Error(`[TextureSource] dimensions '${e.dimensions}' doesn't match viewDimension '${t}'. Leave dimensions out; it is derived from the view.`);else if(e.dimensions)X(Fm,"TextureSource dimensions is derived from viewDimension and depth; leave it out.");if(n==="3d"&&e.antialias)throw Error("[TextureSource] a 3D texture can't be antialiased: WebGPU has no multisampled 3D textures.")}var xp,le;var gt=w(()=>{Ke();vo();Cc();qe();Re();Ac();xp=class e extends de{constructor(t={}){super();this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ee("textureSource"),this._resourceType="textureSource",this._resourceId=ee("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.depth=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this.storage=!1,this._batchTick=-1,this._textureBindLocation=-1;let n=t;t={...e.defaultOptions,...t};let s=pT(t),r=s==="3d"||s==="1d"?s:"2d";if(gT(n,s,r),this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width)this.pixelWidth=t.width*this._resolution;else this.pixelWidth=this.resource?this.resourceWidth??1:1;if(t.height)this.pixelHeight=t.height*this._resolution;else this.pixelHeight=this.resource?this.resourceHeight??1:1;this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=r,this.viewDimension=s,this.arrayLayerCount=t.arrayLayerCount,this.depth=r==="3d"?t.depth??1:1,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=r==="3d"?!1:t.antialias,this.transient=t.transient??!1,this.storage=t.storage??!1,this.alphaMode=t.alphaMode,this.style=new Bs(_o(t)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get depthOrArrayLayers(){return this.dimension==="3d"?this.depth:this.arrayLayerCount||1}get source(){return this}get style(){return this._style}set style(t){if(this.style===t)return;this._ownsStyle=!1,this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange()}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){let t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){if(this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style){if(this._ownsStyle)this._style.destroy();this._style=null}this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=ee("resource"),this.emit("change",this),this.emit("unload",this);for(let t in this._gpuData)this._gpuData[t]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){let{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){let{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){if(this._resolution===t)return;this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t}resize(t,n,s){s||(s=this._resolution),t||(t=this.width),n||(n=this.height);let r=Math.round(t*s),i=Math.round(n*s);if(this.width=r/s,this.height=i/s,this._resolution=s,this.pixelWidth===r&&this.pixelHeight===i)return!1;return this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=i,this.emit("resize",this),this._resourceId=ee("resource"),this.emit("change",this),!0}updateMipmaps(){if(this.autoGenerateMipmaps&&this.mipLevelCount>1)this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=fn(this.pixelWidth)&&fn(this.pixelHeight)}static test(t){throw Error("Unimplemented")}};xp.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};le=xp});function yT(){for(let e=0;e<16;e++){let t=[];Ec.push(t);for(let n=0;n<16;n++){let s=So(Kn[e]*Kn[n]+Zn[e]*Jn[n]),r=So(Jn[e]*Kn[n]+Qn[e]*Jn[n]),i=So(Kn[e]*Zn[n]+Zn[e]*Qn[n]),o=So(Jn[e]*Zn[n]+Qn[e]*Qn[n]);for(let a=0;a<16;a++)if(Kn[a]===s&&Jn[a]===r&&Zn[a]===i&&Qn[a]===o){t.push(a);break}}}for(let e=0;e<16;e++){let t=new U;t.set(Kn[e],Jn[e],Zn[e],Qn[e],0,0),bp.push(t)}}var Kn,Jn,Zn,Qn,Ec,bp,So,se;var Rc=w(()=>{me();Kn=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Jn=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Zn=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Qn=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ec=[],bp=[],So=Math.sign;yT();se={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:(e)=>Kn[e],uY:(e)=>Jn[e],vX:(e)=>Zn[e],vY:(e)=>Qn[e],inv:(e)=>{if(e&8)return e&15;return-e&7},add:(e,t)=>Ec[e][t],sub:(e,t)=>Ec[e][se.inv(t)],rotate180:(e)=>e^4,isVertical:(e)=>(e&3)===2,byDirection:(e,t)=>{if(Math.abs(e)*2<=Math.abs(t)){if(t>=0)return se.S;return se.N}else if(Math.abs(t)*2<=Math.abs(e)){if(e>0)return se.E;return se.W}else if(t>0){if(e>0)return se.SE;return se.SW}else if(e>0)return se.NE;return se.NW},matrixAppendRotationInv:(e,t,n=0,s=0,r=0,i=0)=>{let o=bp[se.inv(t)],{a,b:l,c:u,d:c}=o,h=n-Math.min(0,a*r,u*i,a*r+u*i),d=s-Math.min(0,l*r,c*i,l*r+c*i),{a:f,b:m,c:p,d:y}=e;e.a=a*f+l*p,e.b=a*m+l*y,e.c=u*f+c*p,e.d=u*m+c*y,e.tx=h*f+d*p+e.tx,e.ty=h*m+d*y+e.ty},transformRectCoords:(e,t,n,s)=>{let{x:r,y:i,width:o,height:a}=e,{x:l,y:u,width:c,height:h}=t;if(n===se.E)return s.set(r+l,i+u,o,a),s;else if(n===se.S)return s.set(c-i-a+l,r+u,a,o);else if(n===se.W)return s.set(c-r-o+l,h-i-a+u,o,a);else if(n===se.N)return s.set(i+l,h-r-o+u,a,o);return s.set(r+l,i+u,o,a)}}});var Pc=()=>{};var vp=()=>{};function Nr(e){return e.endsWith("int")}var $c=()=>{};var Ds;var Oc=w(()=>{W();$c();gt();Ds=class Ds extends le{constructor(e){let t=e.depth??e.arrayLayerCount??1,n=e.resource||new Float32Array(e.width*e.height*t*4),s=e.format;if(!s)if(n instanceof Float32Array)s="rgba32float";else if(n instanceof Int32Array)s="rgba32uint";else if(n instanceof Uint32Array)s="rgba32uint";else if(n instanceof Int16Array)s="rgba16uint";else if(n instanceof Uint16Array)s="rgba16uint";else if(n instanceof Int8Array)s="bgra8unorm";else s="bgra8unorm";let r=Nr(s)||t>1;super({...r&&{alphaMode:"no-premultiply-alpha"},...e,resource:n,format:s});this.uploadMethodId="buffer",this._updateStart=0,this._updateEnd=1/0}update(e=0,t=1/0){if((e>0||t<1/0)&&this.depthOrArrayLayers>1)throw Error("[BufferImageSource] a 3D texture or 2D array uploads whole: call update() with no range.");this._updateStart=e,this._updateEnd=t,super.update(),this._updateStart=0,this._updateEnd=1/0}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}};Ds.extension=E.TextureSource});class Gr{constructor(e,t){if(this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof t>"u")this.clampMargin=e.width<10?0:0.5;else this.clampMargin=t;this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){if(this._texture!==e)this._texture?.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this);this.update()}destroy(){this._texture?.removeListener("update",this.update,this),this._texture=null}multiplyUvs(e,t){if(t===void 0)t=e;let n=this.mapCoord;for(let s=0;s{me();_p=new U});var j;var De=w(()=>{Ke();Rc();et();qe();Re();vp();Oc();gt();Ic();j=class j extends de{constructor({source:e,label:t,frame:n,orig:s,trim:r,defaultAnchor:i,defaultBorders:o,rotate:a,dynamic:l}={}){super();if(this.uid=ee("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Q,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new le,this.noFrame=!n,n)this.frame.copyFrom(n);else{let{width:u,height:c}=this._source;this.frame.width=u,this.frame.height=c}this.orig=s||this.frame,this.trim=r,this.rotate=a??0,this.defaultAnchor=i,this.defaultBorders=o,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(e){if(this._source)this._source.off("resize",this.update,this);this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){if(!this._textureMatrix)this._textureMatrix=new Gr(this);return this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){let{uvs:e,frame:t}=this,{width:n,height:s}=this._source,r=t.x/n,i=t.y/s,o=t.width/n,a=t.height/s,l=this.rotate;if(l){let u=o/2,c=a/2,h=r+u,d=i+c;l=se.add(l,se.NW),e.x0=h+u*se.uX(l),e.y0=d+c*se.uY(l),l=se.add(l,2),e.x1=h+u*se.uX(l),e.y1=d+c*se.uY(l),l=se.add(l,2),e.x2=h+u*se.uX(l),e.y2=d+c*se.uY(l),l=se.add(l,2),e.x3=h+u*se.uX(l),e.y3=d+c*se.uY(l)}else e.x0=r,e.y0=i,e.x1=r+o,e.y1=i,e.x2=r+o,e.y2=i+a,e.x3=r,e.y3=i+a}destroy(e=!1){if(this._source){if(this._source.off("resize",this.update,this),e)this._source.destroy(),this._source=null}this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){if(this.noFrame)this.frame.width=this._source.width,this.frame.height=this._source.height;this.updateUvs(),this.emit("update",this)}get baseTexture(){return X(ae,"Texture.baseTexture is now Texture.source"),this._source}};j.EMPTY=new j({label:"EMPTY",source:new le({label:"EMPTY"})});j.EMPTY.destroy=Pc;j.WHITE=new j({source:new Ds({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});j.WHITE.destroy=Pc});class Lr{constructor(){this._screenSizes=new Map,this._widths=[],this._heights=[]}get size(){return this._screenSizes.size}set(e,t,n){let s=this._screenSizes.get(e);if(s&&s.pixelWidth===t&&s.pixelHeight===n)return!1;return this._screenSizes.set(e,{pixelWidth:t,pixelHeight:n}),this._update(),!0}remove(e){if(!this._screenSizes.delete(e))return!1;return this._update(),!0}getFittingWidth(e){return this._getFittingAxis(e,this._widths)}getFittingHeight(e){return this._getFittingAxis(e,this._heights)}hasWidth(e){return this._widths.includes(e)}hasHeight(e){return this._heights.includes(e)}_getFittingAxis(e,t){for(let n=0;n=e)return s}return}_update(){this._widths=[...this._screenSizes.values()].map((e)=>e.pixelWidth).filter((e,t,n)=>n.indexOf(e)===t).sort((e,t)=>e-t),this._heights=[...this._screenSizes.values()].map((e)=>e.pixelHeight).filter((e,t,n)=>n.indexOf(e)===t).sort((e,t)=>e-t)}}var Bc=()=>{};function ST(e){let t=Sp[e];if(t!==void 0)return t;return Sp[e]=_T++}function kT(e,t,n,s,r,i){return(e<<17)+(t<<2)+((s?1:0)<<1)+(n?1:0)+(i==="nearest"?1:0)*bT+ST(r)*vT}class kp{constructor(e){this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new Lr,this._enableFullScreen=!1,this.textureOptions=e||{}}get textureStyle(){if(X($t,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),!this._textureStyle)this._textureStyle=new Bs(this.textureOptions);return this._textureStyle}set textureStyle(e){X($t,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle=e}get enableFullScreen(){return X($t,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){X($t,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen=e}createTexture(...e){let t=e[0];if(typeof t==="number")X($t,"TexturePool.createTexture params are now an options object. See params: { width, height, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],antialias:e[2]??!1,autoGenerateMipmaps:e[3]??!1};let n=t.format??this.textureOptions.format??le.defaultOptions.format,s=t.scaleMode??this.textureOptions.scaleMode??Bs.defaultOptions.scaleMode,r=new le({...this.textureOptions,width:t.width,height:t.height,resolution:1,antialias:t.antialias??!1,autoGarbageCollect:!1,autoGenerateMipmaps:t.autoGenerateMipmaps??!1,format:n,scaleMode:s});return new j({source:r,label:`texturePool_${xT++}`})}getOptimalTexture(...e){let t=e[0];if(typeof t==="number")X($t,"TexturePool.getOptimalTexture params are now an options object. See params: { width, height, resolution, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],resolution:e[2]??1,antialias:e[3]??!1,autoGenerateMipmaps:e[4]??!1};let n=t.width,s=t.height,r=t.resolution??1,i=t.antialias??!1,o=t.autoGenerateMipmaps??!1,a=t.format??this.textureOptions.format??le.defaultOptions.format,l=t.scaleMode??this.textureOptions.scaleMode??Bs.defaultOptions.scaleMode,{width:u,height:c}=this.getOptimalSize(n,s,r);if(u>Dc||c>Dc)V(`TexturePool: ${u}x${c} is larger than the ${Dc}px pool key limit, textures of this size may be pooled together`);let h=kT(u,c,i,o,a,l),d=this._buckets.get(h);if(!d)d=[],this._buckets.set(h,d);let f=d.pop();if(!f)f=this.createTexture({width:u,height:c,antialias:i,autoGenerateMipmaps:o,format:a,scaleMode:l}),this._poolStyle[f.uid]=f.source.style;return f.source._resolution=r,f.source.width=u/r,f.source.height=c/r,f.source.pixelWidth=u,f.source.pixelHeight=c,f.frame.x=0,f.frame.y=0,f.frame.width=n,f.frame.height=s,f.updateUvs(),this._poolKey[f.uid]=h,f}getOptimalSize(e,t,n=1){let s=Math.ceil(e*n-0.000001),r=Math.ceil(t*n-0.000001),i=Is(s),o=this._screens.getFittingWidth(s),a=Is(r),l=this._screens.getFittingHeight(r);return{width:o!==void 0?Math.min(o,i):i,height:l!==void 0?Math.min(l,a):a}}getSameSizeTexture(e,t=!1){let n=e.source;return this.getOptimalTexture({width:e.width,height:e.height,resolution:n._resolution,antialias:t})}returnTexture(e,t=!1){let n=e.uid,s=this._poolKey[n];if(s===void 0){V("TexturePool: returnTexture was passed a texture that did not come from this pool, ignoring it");return}let r=this._poolStyle[n];if(t&&e.source.style!==r)e.source.style=r;let i=this._buckets.get(s);if(!i){delete this._poolKey[n],delete this._poolStyle[n],e.destroy(!0);return}i.push(e)}setScreenSize(e,t,n){if(!this._screens.set(e,t,n))return;this._pruneScreenTextures()}removeScreen(e){if(!this._screens.remove(e))return;this._pruneScreenTextures()}_pruneScreenTextures(){for(let[e,t]of this._buckets){let n=e>>>0,s=n>>>17,r=n>>>2&32767;if((fn(s)||this._screens.hasWidth(s))&&(fn(r)||this._screens.hasHeight(r)))continue;this._dropTextures(t,!0),this._buckets.delete(e)}}_dropTextures(e,t){for(let n=0;n{vo();Re();Pe();Hn();gt();De();Ac();Bc();Sp=Object.create(null);Ue=new kp;Ot.register(Ue)});class Fs{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new U,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new qn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){if(this.root=e,e._onRender)this.addOnRender(e);e.didChange=!0;let t=e.children;for(let n=0;n-1)this.renderGroupChildren.splice(t,1);e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root)e.relativeRenderGroupDepth=1;else e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1;if(e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}if(e._onRender)this.addOnRender(e);let t=e.children;for(let n=0;n0}addOnRender(e){if(this._onRenderContainers.indexOf(e)===-1)this._onRenderContainers.push(e)}removeOnRender(e){let t=this._onRenderContainers.indexOf(e);if(t!==-1)this._onRenderContainers.splice(t,1)}runOnRender(e){for(let t=0;t{me();bo();es()});function wp(e,t,n={}){for(let s in t)if(!n[s]&&t[s]!==void 0)e[s]=t[s]}var Mp=()=>{};var Nc,ko,Gc,wo,Ns=1,Ur=2,ts=4,Fe;var nn=w(()=>{Ke();Pt();Pm();W();me();yc();bc();qe();Re();Pe();dn();Wm();jm();Vm();Km();Zm();tp();ip();cp();hp();fp();pp();Fc();Mp();Nc=new Ze(null),ko=new Ze(null),Gc=new Ze(null,1,1),wo=new Ze(null);Fe=class Fe extends de{constructor(e={}){super();this.uid=ee("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new U,this.relativeGroupTransform=new U,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Ze(this,0,0),this._scale=Gc,this._pivot=ko,this._origin=wo,this._skew=Nc,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=[],wp(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach((t)=>this.addChild(t)),e.parent?.addChild(this)}static mixin(e){X("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),Z.mixin(Fe,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(!this.allowChildren)X(ae,"addChild: Only Containers will be allowed to add children in v8.0.0");if(e.length>1){for(let s=0;s1){for(let s=0;s-1){if(this._didViewChangeTick++,this.children.splice(n,1),this.renderGroup)this.renderGroup.removeChild(t);else if(this.parentRenderGroup)this.parentRenderGroup.removeChild(t);if(t.parentRenderLayer)t.parentRenderLayer.detach(t);t.parent=null,this.emit("childRemoved",t,this,n),t.emit("removed",this)}return t}_onUpdate(e){if(e){if(e===this._skew)this._updateSkew()}if(this._didContainerChangeTick++,this.didChange)return;if(this.didChange=!0,this.parentRenderGroup)this.parentRenderGroup.onChildUpdate(this)}set isRenderGroup(e){if(!!this.renderGroup===e)return;if(e)this.enableRenderGroup();else this.disableRenderGroup()}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Ce.get(Fs,this),this.groupTransform=U.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),Ce.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){if(this._worldTransform||(this._worldTransform=new U),this.renderGroup)this._worldTransform.copyFrom(this.renderGroup.worldTransform);else if(this.parentRenderGroup)this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform);return this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){if(this._rotation!==e)this._rotation=e,this._onUpdate(this._skew)}get angle(){return this.rotation*Om}set angle(e){this.rotation=e*Im}get pivot(){if(this._pivot===ko)this._pivot=new Ze(this,0,0);return this._pivot}set pivot(e){if(this._pivot===ko){if(this._pivot=new Ze(this,0,0),this._origin!==wo)V("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")}typeof e==="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){if(this._skew===Nc)this._skew=new Ze(this,0,0);return this._skew}set skew(e){if(this._skew===Nc)this._skew=new Ze(this,0,0);this._skew.copyFrom(e)}get scale(){if(this._scale===Gc)this._scale=new Ze(this,1,1);return this._scale}set scale(e){if(this._scale===Gc)this._scale=new Ze(this,0,0);if(typeof e==="string")e=parseFloat(e);typeof e==="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){if(this._origin===wo)this._origin=new Ze(this,0,0);return this._origin}set origin(e){if(this._origin===wo){if(this._origin=new Ze(this,0,0),this._pivot!==ko)V("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")}typeof e==="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){let t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){let t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){if(!e)e={};let t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){let n=this.getLocalBounds();if(typeof e==="object")t=e.height??e.width,e=e.width;else t??(t=e);e!==void 0&&this._setWidth(e,n.width),t!==void 0&&this._setHeight(t,n.height)}_updateSkew(){let e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x==="number"?e.x:this.position.x,typeof e.y==="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX==="number"?e.scaleX:this.scale.x,typeof e.scaleY==="number"?e.scaleY:this.scale.y),this.rotation=typeof e.rotation==="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX==="number"?e.skewX:this.skew.x,typeof e.skewY==="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX==="number"?e.pivotX:this.pivot.x,typeof e.pivotY==="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX==="number"?e.originX:this.origin.x,typeof e.originY==="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;let t=this.localTransform,n=this._scale,s=this._pivot,r=this._origin,i=this._position,{_x:o,_y:a}=n,{_x:l,_y:u}=s,c=-r._x,h=-r._y;t.a=this._cx*o,t.b=this._sx*o,t.c=this._cy*a,t.d=this._sy*a,t.tx=i._x-(l*t.a+u*t.c)+(c*t.a+h*t.c)-c,t.ty=i._y-(l*t.b+u*t.d)+(c*t.b+h*t.d)-h}set alpha(e){if(e===this.localAlpha)return;this.localAlpha=e,this._updateFlags|=Ns,this._onUpdate()}get alpha(){return this.localAlpha}set tint(e){let n=he.shared.setValue(e??16777215).toBgrNumber();if(n===this.localColor)return;this.localColor=n,this._updateFlags|=Ns,this._onUpdate()}get tint(){return Fr(this.localColor)}set blendMode(e){if(this.localBlendMode===e)return;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._updateFlags|=Ur,this.localBlendMode=e,this._onUpdate()}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;if((this.localDisplayStatus&2)===t)return;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._updateFlags|=ts,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e)}get culled(){return!(this.localDisplayStatus&4)}set culled(e){let t=e?0:4;if((this.localDisplayStatus&4)===t)return;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._updateFlags|=ts,this.localDisplayStatus^=4,this._onUpdate()}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=e?1:0;if((this.localDisplayStatus&1)===t)return;if(this._updateFlags|=ts,this.localDisplayStatus^=1,this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._onUpdate()}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length)t=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof e==="boolean"?e:e?.children)&&t)for(let s=0;s{wn=((e)=>(e[e.INTERACTION=50]="INTERACTION",e[e.HIGH=25]="HIGH",e[e.NORMAL=0]="NORMAL",e[e.LOW=-25]="LOW",e[e.UTILITY=-50]="UTILITY",e))(wn||{})});class Wr{constructor(e,t=null,n=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=n,this._once=s}match(e,t=null){return this._fn===e&&this._context===t}emit(e){if(this._fn)if(this._context)this._fn.call(this._context,e);else this._fn(e);let t=this.next;if(this._once)this.destroy(!0);if(this._destroyed)this.next=null;return t}connect(e){if(this.previous=e,e.next)e.next.previous=this;this.next=e.next,e.next=this}destroy(e=!1){if(this._destroyed=!0,this._fn=null,this._context=null,this.previous)this.previous.next=this.next;if(this.next)this.next.previous=this.previous;let t=this.next;return this.next=e?null:t,this.previous=null,t}}var Tp=()=>{};var Cp=class e{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Wr(null,null,1/0),this.deltaMS=1/e.targetFPMS,this.elapsedMS=1/e.targetFPMS,this._tick=(t)=>{if(this._requestId=null,this.started){if(this.update(t),this.started&&this._requestId===null&&this._head.next)this._requestId=requestAnimationFrame(this._tick)}}}_requestIfNeeded(){if(this._requestId===null&&this._head.next)this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick)}_cancelIfNeeded(){if(this._requestId!==null)cancelAnimationFrame(this._requestId),this._requestId=null}_startIfPossible(){if(this.started)this._requestIfNeeded();else if(this.autoStart)this.start()}add(t,n,s=wn.NORMAL){return this._addListener(new Wr(t,n,s))}addOnce(t,n,s=wn.NORMAL){return this._addListener(new Wr(t,n,s,!0))}_addListener(t){let n=this._head.next,s=this._head;if(!n)t.connect(s);else{while(n){if(t.priority>n.priority){t.connect(s);break}s=n,n=n.next}if(!t.previous)t.connect(s)}return this._startIfPossible(),this}remove(t,n){let s=this._head.next;while(s)if(s.match(t,n))s=s.destroy();else s=s.next;if(!this._head.next)this._cancelIfNeeded();return this}get count(){if(!this._head)return 0;let t=0,n=this._head;while(n=n.next)t++;return t}start(){if(!this.started)this.started=!0,this._requestIfNeeded()}stop(){if(this.started)this.started=!1,this._cancelIfNeeded()}destroy(){if(!this._protected){this.stop();let t=this._head.next;while(t)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS)n=this._maxElapsedMS;if(n*=this.speed,this._minElapsedMS){let i=t-this._lastFrame|0;if(ithis.maxFPS)this.maxFPS=t}get maxFPS(){if(this._minElapsedMS)return Math.round(1000/this._minElapsedMS);return 0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{if(t{Mo();Tp();Cp.targetFPMS=0.06;tt=Cp});class Xr{constructor(e){if(this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let t=this._canvas.getBoundingClientRect(),n=this._canvas.width,s=this._canvas.height,r=t.width/n*this._renderer.resolution,i=t.height/s*this._renderer.resolution,{left:o,top:a}=t,l=`translate(${o}px, ${a}px) scale(${r}, ${i})`;if(l!==this._lastTransform)this._domElement.style.transform=l,this._lastTransform=l},this._domElement=e.domElement,this._renderer=e.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)return;this._canvas=this._renderer.canvas,this._attachObserver()}get canvas(){return this._canvas}ensureAttached(){if(!this._domElement.parentNode&&this._canvas.parentNode)this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation()}_attachObserver(){if("ResizeObserver"in globalThis){if(this._observer)this._observer.disconnect(),this._observer=null;this._observer=new ResizeObserver((e)=>{for(let t of e){if(t.target!==this._canvas)continue;let n=this.canvas.width,s=this.canvas.height,r=t.contentRect.width/n*this._renderer.resolution,i=t.contentRect.height/s*this._renderer.resolution;if(this._lastScaleX!==r||this._lastScaleY!==i)this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=i}}),this._observer.observe(this._canvas)}else if(!this._tickerAttached)tt.shared.add(this.updateTranslation,this,wn.HIGH)}destroy(){if(this._observer)this._observer.disconnect(),this._observer=null;else if(this._tickerAttached)tt.shared.remove(this.updateTranslation);this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}var Lc=w(()=>{Mo();Gs()});class Mn{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Mn.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ie,this.page=new ie,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){if(this.manager&&(!this.path||this.path[this.path.length-1]!==this.target))this.path=this.target?this.manager.propagationPath(this.target):[];return this.path}initEvent(e,t,n){throw Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,n,s,r){throw Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){if(this.nativeEvent instanceof Event&&this.nativeEvent.cancelable)this.nativeEvent.preventDefault();this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var To=w(()=>{jt()});function wT(e){return function(t){return t.test(e)}}function jr(e){var t={userAgent:"",platform:"",maxTouchPoints:0};if(!e&&typeof navigator<"u")t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};else if(typeof e==="string")t.userAgent=e;else if(e&&e.userAgent)t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0};var n=t.userAgent,s=n.split("[FBAN");if(typeof s[1]<"u")n=s[0];if(s=n.split("Twitter"),typeof s[1]<"u")n=s[0];var r=wT(n),i={apple:{phone:r(Uc)&&!r(mn),ipod:r(Ap),tablet:!r(Uc)&&(r(Ep)||Np(t))&&!r(mn),universal:r(Rp),device:(r(Uc)||r(Ap)||r(Ep)||r(Rp)||Np(t))&&!r(mn)},amazon:{phone:r(Ls),tablet:!r(Ls)&&r(Co),device:r(Ls)||r(Co)},android:{phone:!r(mn)&&r(Ls)||!r(mn)&&r(Wc),tablet:!r(mn)&&!r(Ls)&&!r(Wc)&&(r(Co)||r(Pp)),device:!r(mn)&&(r(Ls)||r(Co)||r(Wc)||r(Pp))||r(/\bokhttp\b/i)},windows:{phone:r(mn),tablet:r($p),device:r(mn)||r($p)},other:{blackberry:r(Op),blackberry10:r(Ip),opera:r(Bp),firefox:r(Fp),chrome:r(Dp),device:r(Op)||r(Ip)||r(Bp)||r(Fp)||r(Dp)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var Uc,Ap,Ep,Rp,Wc,Pp,Ls,Co,mn,$p,Op,Ip,Bp,Dp,Fp,Np=function(e){return typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints==="number"&&e.maxTouchPoints>1&&typeof MSStream>"u"};var Xc=w(()=>{Uc=/iPhone/i,Ap=/iPod/i,Ep=/iPad/i,Rp=/\biOS-universal(?:.+)Mac\b/i,Wc=/\bAndroid(?:.+)Mobile\b/i,Pp=/Android/i,Ls=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Co=/Silk/i,mn=/Windows Phone/i,$p=/\bWindows(?:.+)ARM\b/i,Op=/BlackBerry/i,Ip=/BB10/i,Bp=/Opera Mini/i,Dp=/\b(CriOS|Chrome)(?:.+)Mobile/i,Fp=/Mobile(?:.+)Firefox\b/i});var Gp=w(()=>{Xc();Xc()});var MT,Lp;var Up=w(()=>{Gp();MT=jr.default??jr,Lp=MT(globalThis.navigator)});var TT=9,Wp=100,CT=0,AT=0,Xp=2,jp=1,ET=-1000,RT=-1000,PT=2,jc=class e{constructor(t,n=Lp){if(this._mobileInfo=n,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,n.tablet||n.phone)this._createTouchHook();this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let t=document.createElement("button");t.style.width=`${jp}px`,t.style.height=`${jp}px`,t.style.position="absolute",t.style.top=`${ET}px`,t.style.left=`${RT}px`,t.style.zIndex=PT.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){if(!this._hookDiv)return;document.body.removeChild(this._hookDiv),this._hookDiv=null}_activate(){if(this._isActive)return;if(this._isActive=!0,!this._div)this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${CT}px`,this._div.style.left=`${AT}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=Xp.toString(),this._canvasObserver=new Xr({domElement:this._div,renderer:this._renderer});if(this._deactivateOnMouseMove)globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);let t=this._renderer.view.canvas;if(!t.parentNode){let n=new MutationObserver(()=>{if(t.parentNode)n.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup()});n.observe(document.body,{childList:!0,subtree:!0})}else this._canvasObserver.ensureAttached(),this._initAccessibilitySetup()}_initAccessibilitySetup(){if(this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered)this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!this._isActive||this._isMobileAccessibility)return;this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._renderer.runners.postrender.remove(this);for(let t of this._children){if(t._accessibleDiv?.parentNode)t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null;t._accessibleActive=!1}for(let t in this._pools)this._pools[t].forEach((s)=>{if(s.parentNode)s.parentNode.removeChild(s)}),delete this._pools[t];if(this._div?.parentNode)this._div.parentNode.removeChild(this._div);this._pools={},this._children=[]}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;if(t.accessible){if(!t._accessibleActive)this._addChild(t);t._renderId=this._renderId}let n=t.children;if(n)for(let s=0;s=0;s--){let r=this._children[s];if(!n.has(s)){if(r._accessibleDiv&&r._accessibleDiv.parentNode)r._accessibleDiv.parentNode.removeChild(r._accessibleDiv),this._getPool(r.accessibleType).push(r._accessibleDiv),r._accessibleDiv=null;r._accessibleActive=!1,ho(this._children,s,1)}}if(this._renderer.renderingToScreen)this._canvasObserver.ensureAttached();for(let s=0;s title : ${t.title}
tabIndex: ${t.tabIndex}`}_capHitArea(t){if(t.x<0)t.width+=t.x,t.x=0;if(t.y<0)t.height+=t.y,t.y=0;let{width:n,height:s}=this._renderer;if(t.x+t.width>n)t.width=n-t.x;if(t.y+t.height>s)t.height=s-t.y}_addChild(t){let s=this._getPool(t.accessibleType).pop();if(s)s.innerHTML="",s.removeAttribute("title"),s.removeAttribute("aria-label"),s.tabIndex=0;else{if(t.accessibleType==="button"){if(s=document.createElement("button"),!this.debug)s.style.color="transparent"}else s=document.createElement(t.accessibleType),s.style.cssText=` +`),i)console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(s),console.groupEnd();else console.warn("PixiJS Deprecation Warning: ",r),console.warn(s);Km.add(t)};var Ie=M(()=>{Km=new Set,Gs={quiet:!1,noColor:!1};Object.defineProperties(q,{quiet:{get:()=>Gs.quiet,set:(e)=>{Gs.quiet=e},enumerable:!0,configurable:!1},noColor:{get:()=>Gs.noColor,set:(e)=>{Gs.noColor=e},enumerable:!0,configurable:!1}})});function te(...e){if(Pc===Qm)return;if(Pc++,Pc===Qm)console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS.");else console.warn("PixiJS Warning: ",...e)}var Pc=0,Qm=500;var Be=()=>{};var Wt;var ss=M(()=>{Wt={_registeredResources:new Set,register(e){this._registeredResources.add(e)},unregister(e){this._registeredResources.delete(e)},release(){this._registeredResources.forEach((e)=>e.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(e){return this._registeredResources.has(e)},reset(){this._registeredResources.clear()}}});class Rc{constructor(e,t){if(this._pool=[],this._count=0,this._index=0,this._classType=e,t)this.prepopulate(t)}prepopulate(e){for(let t=0;t0)t=this._pool[--this._index];else t=new this._classType,this._count++;return t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e{};class tp{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){if(!this._poolsByClass.has(e))this._poolsByClass.set(e,new Rc(e));return this._poolsByClass.get(e)}stats(){let e={};return this._poolsByClass.forEach((t)=>{let n=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[n]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach((e)=>e.clear()),this._poolsByClass.clear()}}var Re;var xn=M(()=>{ss();ep();Re=new tp;Wt.register(Re)});var np;var sp=M(()=>{Ie();np={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(e){if(typeof e==="boolean"&&e===!1)this.disableRenderGroup();else this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(e===!0?{}:e)},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(e){q("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(e)}}});function xo(e,t,n){let s=e.length,r;if(t>=s||n===0)return;n=t+n>s?s-t:n;let i=s-n;for(r=t;r{};var rp;var ip=M(()=>{$c();Ie();rp={allowChildren:!0,removeChildren(e=0,t){let n=t??this.children.length,s=n-e,r=[];if(s>0&&s<=n){for(let o=n-1;o>=e;o--){let a=this.children[o];if(!a)continue;r.push(a),a.parent=null}xo(this.children,e,n);let i=this.renderGroup||this.parentRenderGroup;if(i)i.removeChildren(r);for(let o=0;o0)this._didViewChangeTick++;return r}else if(s===0&&this.children.length===0)return r;throw RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(e){let t=this.getChildAt(e);return this.removeChild(t)},getChildAt(e){if(e<0||e>=this.children.length)throw Error(`getChildAt: Index (${e}) does not exist.`);return this.children[e]},setChildIndex(e,t){if(t<0||t>=this.children.length)throw Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(e),this.addChildAt(e,t)},getChildIndex(e){let t=this.children.indexOf(e);if(t===-1)throw Error("The supplied Container must be a child of the caller");return t},addChildAt(e,t){if(!this.allowChildren)q(be,"addChildAt: Only Containers will be allowed to add children in v8.0.0");let{children:n}=this;if(t<0||t>n.length)throw Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${n.length}`);let s=e.parent===this;if(e.parent){let i=e.parent.children.indexOf(e);if(s){if(i===t)return e;e.parent.children.splice(i,1)}else e.removeFromParent()}if(t===n.length)n.push(e);else n.splice(t,0,e);let r=this.renderGroup||this.parentRenderGroup;if(this.sortableChildren)this.sortDirty=!0;if(s){if(r)r.structureDidChange=!0;return e}if(e.parent=this,e.didChange=!0,e._updateFlags=15,r)r.addChild(e);return this.emit("childAdded",e,this,t),e.emit("added",this),e},swapChildren(e,t){if(e===t)return;let n=this.getChildIndex(e),s=this.getChildIndex(t);this.children[n]=t,this.children[s]=e;let r=this.renderGroup||this.parentRenderGroup;if(r)r.structureDidChange=!0;this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...e){if(e.length===1)return this.reparentChildAt(e[0],this.children.length);return e.forEach((t)=>this.reparentChildAt(t,this.children.length)),e[0]},reparentChildAt(e,t){if(e.parent===this)return this.setChildIndex(e,t),e;let n=e.worldTransform.clone();e.removeFromParent(),this.addChildAt(e,t);let s=this.worldTransform.clone();return s.invert(),n.prepend(s),e.setFromMatrix(n),e},replaceChild(e,t){e.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(e)),t.setFromMatrix(e.localTransform),t.updateLocalTransform(),this.removeChild(e)}}});var op;var ap=M(()=>{op={collectRenderables(e,t,n){if(this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild)return;if(this.sortableChildren)this.sortChildren();if(this.isSimple)this.collectRenderablesSimple(e,t,n);else if(this.renderGroup)t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,e);else this.collectRenderablesWithEffects(e,t,n)},collectRenderablesSimple(e,t,n){let s=this.children,r=s.length;for(let i=0;i=0;r--){let i=this.effects[r];s[i.pipe].pop(i,this,e)}}}});class Pn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e{};class lp{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){if(this._initialized)return;this._initialized=!0,this._effectClasses.forEach((e)=>{this.add({test:e.test,maskClass:e})})}add(e){this._tests.push(e)}getMaskEffect(e){if(!this._initialized)this.init();for(let t=0;t{z();xn();vo=new lp;ne.handleByList(D.MaskEffect,vo._effectClasses)});var up;var hp=M(()=>{bo();cp();up={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){let e=this.renderGroup||this.parentRenderGroup;if(e)e.structureDidChange=!0},addEffect(e){if(this.effects.indexOf(e)!==-1)return;this.effects.push(e),this.effects.sort((n,s)=>n.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple()},removeEffect(e){let t=this.effects.indexOf(e);if(t===-1)return;this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple()},set mask(e){let t=this._maskEffect;if(t?.mask===e)return;if(t)this.removeEffect(t),vo.returnMaskEffect(t),this._maskEffect=null;if(e===null||e===void 0)return;this._maskEffect=vo.getMaskEffect(e),this.addEffect(this._maskEffect)},get mask(){return this._maskEffect?.mask},setMask(e){if(this._maskOptions={...this._maskOptions,...e},e.mask)this.mask=e.mask;this._markStructureAsChanged()},set filters(e){if(!Array.isArray(e)&&e)e=[e];let t=this._filterEffect||(this._filterEffect=new Pn);e=e;let n=e?.length>0,s=t.filters?.length>0,r=n!==s;if(e=Array.isArray(e)?e.slice(0):e,t.filters=Object.freeze(e),r)if(n)this.addEffect(t);else this.removeEffect(t),t.filters=e??null},get filters(){return this._filterEffect?.filters},set filterArea(e){this._filterEffect||(this._filterEffect=new Pn),this._filterEffect.filterArea=e},get filterArea(){return this._filterEffect?.filterArea}}});var dp;var fp=M(()=>{Ie();dp={label:null,get name(){return q(be,"Container.name property has been removed, use Container.label instead"),this.label},set name(e){q(be,"Container.name property has been removed, use Container.label instead"),this.label=e},getChildByName(e,t=!1){return this.getChildByLabel(e,t)},getChildByLabel(e,t=!1){let n=this.children;for(let s=0;s=this.x&&e=this.y&&t=c&&e<=h&&t>=d&&t<=f&&!(e>m&&ey&&te.right?e.right:this.right)<=k)return!1;let T=this.ye.bottom?e.bottom:this.bottom)>T}let n=this.left,s=this.right,r=this.top,i=this.bottom;if(s<=n||i<=r)return!1;let o=_o[0].set(e.left,e.top),a=_o[1].set(e.left,e.bottom),l=_o[2].set(e.right,e.top),u=_o[3].set(e.right,e.bottom);if(l.x<=o.x||a.y<=o.y)return!1;let c=Math.sign(t.a*t.d-t.b*t.c);if(c===0)return!1;if(t.apply(o,o),t.apply(a,a),t.apply(l,l),t.apply(u,u),Math.max(o.x,a.x,l.x,u.x)<=n||Math.min(o.x,a.x,l.x,u.x)>=s||Math.max(o.y,a.y,l.y,u.y)<=r||Math.min(o.y,a.y,l.y,u.y)>=i)return!1;let h=c*(a.y-o.y),d=c*(o.x-a.x),f=h*n+d*r,m=h*s+d*r,p=h*n+d*i,y=h*s+d*i;if(Math.max(f,m,p,y)<=h*o.x+d*o.y||Math.min(f,m,p,y)>=h*u.x+d*u.y)return!1;let g=c*(o.y-l.y),x=c*(l.x-o.x),b=g*n+x*r,v=g*s+x*r,_=g*n+x*i,S=g*s+x*i;if(Math.max(b,v,_,S)<=g*o.x+x*o.y||Math.min(b,v,_,S)>=g*u.x+x*u.y)return!1;return!0}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){let t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),s=Math.max(this.y,e.y),r=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(n-t,0),this.y=s,this.height=Math.max(r-s,0),this}ceil(e=1,t=0.001){let n=Math.ceil((this.x+this.width-t)*e)/e,s=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=n-this.x,this.height=s-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){let t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),s=Math.min(this.y,e.y),r=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=n-t,this.y=s,this.height=r-s,this}getBounds(e){return e||(e=new se),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;let{x:t,y:n}=e,s=e.x+e.width,r=e.y+e.height;return t>=this.x&&t=this.y&&n=this.x&&s<=this.x+this.width&&r>=this.y&&r<=this.y+this.height}set(e,t,n,s){return this.x=e,this.y=t,this.width=n,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}var _o;var st=M(()=>{Kt();_o=[new ue,new ue,new ue,new ue]});class Me{constructor(e=1/0,t=1/0,n=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=mp,this.minX=e,this.minY=t,this.maxX=n,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){if(!this._rectangle)this._rectangle=new se;let e=this._rectangle;if(this.minX>this.maxX||this.minY>this.maxY)e.x=0,e.y=0,e.width=0,e.height=0;else e.copyFromBounds(this);return e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=mp,this}set(e,t,n,s){this.minX=e,this.minY=t,this.maxX=n,this.maxY=s}addFrame(e,t,n,s,r){r||(r=this.matrix);let i=r.a,o=r.b,a=r.c,l=r.d,u=r.tx,c=r.ty,h=this.minX,d=this.minY,f=this.maxX,m=this.maxY,p=i*e+a*t+u,y=o*e+l*t+c;if(pf)f=p;if(y>m)m=y;if(p=i*n+a*t+u,y=o*n+l*t+c,pf)f=p;if(y>m)m=y;if(p=i*e+a*s+u,y=o*e+l*s+c,pf)f=p;if(y>m)m=y;if(p=i*n+a*s+u,y=o*n+l*s+c,pf)f=p;if(y>m)m=y;this.minX=h,this.minY=d,this.maxX=f,this.maxY=m}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxXthis.maxX?h:this.maxX,this.maxY=d>this.maxY?d:this.maxY,h=i*t+a*r+u,d=o*t+l*r+c,this.minX=hthis.maxX?h:this.maxX,this.maxY=d>this.maxY?d:this.maxY,h=i*s+a*r+u,d=o*s+l*r+c,this.minX=hthis.maxX?h:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(e){if(this.minXe.right)this.maxX=e.right;if(this.minYe.bottom)this.maxY=e.bottom;return this}fitBounds(e,t,n,s){if(this.minXt)this.maxX=t;if(this.minYs)this.maxY=s;return this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Me(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){let t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){let t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,t,n,s){let r=this.minX,i=this.minY,o=this.maxX,a=this.maxY;s||(s=this.matrix);let l=s.a,u=s.b,c=s.c,h=s.d,d=s.tx,f=s.ty;for(let m=t;mo?g:o,a=x>a?x:a}this.minX=r,this.minY=i,this.maxX=o,this.maxY=a}containsPoint(e,t){if(this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t)return!0;return!1}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var mp;var yt=M(()=>{Ce();st();mp=new j});var He,At;var rs=M(()=>{Ce();xn();yt();He=Re.getPool(j),At=Re.getPool(Me)});var $T,pp;var gp=M(()=>{Ce();yt();rs();$T=new j,pp={getFastGlobalBounds(e,t){if(t||(t=new Me),t.clear(),this._getGlobalBoundsRecursive(!!e,t,this.parentRenderLayer),!t.isValid)t.set(0,0,0,0);let n=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(n.worldTransform),t},_getGlobalBoundsRecursive(e,t,n){let s=t;if(e&&this.parentRenderLayer&&this.parentRenderLayer!==n)return;if(this.localDisplayStatus!==7||!this.measurable)return;let r=!!this.effects.length;if(this.renderGroup||r)s=At.get().clear();if(this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){let o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}let i=this.children;for(let o=0;o{Ce();rs()});function wo(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;let n=e>>16&255,s=e>>8&255,r=e&255,i=t>>16&255,o=t>>8&255,a=t&255,l=n*i/255|0,u=s*o/255|0,c=r*a/255|0;return(l<<16)+(u<<8)+c}var Oc=()=>{};function Us(e,t){if(e===xp)return t;if(t===xp)return e;return wo(e,t)}var xp=16777215;var Ic=M(()=>{Oc()});function Hr(e){return((e&255)<<16)+(e&65280)+(e>>16&255)}var bp;var vp=M(()=>{Ce();Yr();rs();Ic();bp={getGlobalAlpha(e){if(e){if(this.renderGroup)return this.renderGroup.worldAlpha;if(this.parentRenderGroup)return this.parentRenderGroup.worldAlpha*this.alpha;return this.alpha}let t=this.alpha,n=this.parent;while(n)t*=n.alpha,n=n.parent;return t},getGlobalTransform(e=new j,t){if(t)return e.copyFrom(this.worldTransform);this.updateLocalTransform();let n=So(this,He.get().identity());return e.appendFrom(this.localTransform,n),He.return(n),e},getGlobalTint(e){if(e){if(this.renderGroup)return Hr(this.renderGroup.worldColor);if(this.parentRenderGroup)return Hr(Us(this.localColor,this.parentRenderGroup.worldColor));return this.tint}let t=this.localColor,n=this.parent;while(n)t=Us(t,n.localColor),n=n.parent;return Hr(t)}}});function Ws(e,t,n){if(t.clear(),n||(n=j.IDENTITY),_p(e,t,n,e,!0),!t.isValid)t.set(0,0,0,0);return t}function _p(e,t,n,s,r){let i;if(!r){if(!e.visible||!e.measurable)return;e.updateLocalTransform();let l=e.localTransform;i=He.get(),i.appendFrom(l,n)}else i=He.get(),i=n.copyTo(i);let o=t,a=!!e.effects.length;if(a)t=At.get().clear();if(e.boundsArea)t.addRect(e.boundsArea,i);else{if(e.renderPipeId)t.matrix=i,t.addBounds(e.bounds);let l=e.children;for(let u=0;u{Ce();rs()});function Bc(e,t){let n=e.children;for(let s=0;s{};var OT,wp;var kp=M(()=>{Ce();yt();Yr();ko();Sp();OT=new j,wp={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(e,t){let n=Math.sign(this.scale.x)||1;if(t!==0)this.scale.x=e/t*n;else this.scale.x=n},_setHeight(e,t){let n=Math.sign(this.scale.y)||1;if(t!==0)this.scale.y=e/t*n;else this.scale.y=n},getLocalBounds(){if(!this._localBoundsCacheData)this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Me};let e=this._localBoundsCacheData;if(e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick)e.didChange=!0,e.data[0]=this._didViewChangeTick;if(Bc(this,e),e.didChange)Ws(this,e.localBounds,OT);return e.localBounds},getBounds(e,t){return Ls(this,e,t||new Me)}}});var Mp;var Tp=M(()=>{Mp={_onRender:null,set onRender(e){let t=this.renderGroup||this.parentRenderGroup;if(!e){if(this._onRender)t?.removeOnRender(this);this._onRender=null;return}if(!this._onRender)t?.addOnRender(this);this._onRender=e},get onRender(){return this._onRender}}});function IT(e,t){return e._zIndex-t._zIndex}var Cp;var Ap=M(()=>{Cp={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(e){if(this._zIndex===e)return;this._zIndex=e,this.depthOfChildModified()},depthOfChildModified(){if(this.parent)this.parent.sortableChildren=!0,this.parent.sortDirty=!0;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0},sortChildren(){if(!this.sortDirty)return;this.sortDirty=!1,this.children.sort(IT)}}});var Ep;var Pp=M(()=>{Kt();rs();Ep={getGlobalPosition(e=new ue,t=!1){if(this.parent)this.parent.toGlobal(this._position,e,t);else e.x=this._position.x,e.y=this._position.y;return e},toGlobal(e,t,n=!1){let s=this.getGlobalTransform(He.get(),n);return t=s.apply(e,t),He.return(s),t},toLocal(e,t,n,s){if(t)e=t.toGlobal(e,n,s);let r=this.getGlobalTransform(He.get(),s);return n=r.applyInverse(e,n),He.return(r),n}}});class is{constructor(){this.uid=ie("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){if(this.renderPipes)for(let e in this.renderPipes)this.renderPipes[e].destroyInstructionSet?.(this);this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}var Mo=M(()=>{Ze()});function Xs(e){return e+=e===0?1:0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function bn(e){return!(e&e-1)&&!!e}var To=()=>{};function Co(e){let t={};for(let n in e)if(e[n]!==void 0)t[n]=e[n];return t}var Fc=()=>{};function BT(e){let t=Rp[e];if(t===void 0)Rp[e]=ie("resource");return t}var Rp,$p,Vs;var Dc=M(()=>{Qe();Ze();Ie();Rp=Object.create(null);$p=class e extends ke{constructor(t={}){super();this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,t={...e.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){q(be,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){if(this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1)this.scaleMode="linear"}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){let t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=BT(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};$p.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};Vs=$p});function FT(e){if(e.viewDimension)return e.viewDimension;if(e.depth)return"3d";return e.arrayLayerCount>1?"2d-array":"2d"}function DT(e,t,n){if(e.depth!==void 0&&typeof e.depth!=="number")throw Error(`[TextureSource] depth is a 3D texture's depth in texels, but got ${e.depth}. For a depth buffer, use the depth option of a RenderTarget or the renderer.`);if(e.depth&&e.arrayLayerCount>1)throw Error("[TextureSource] depth and arrayLayerCount can't be combined: use depth for a 3D texture or arrayLayerCount for a 2D array.");if(e.depth&&t!=="3d")throw Error(`[TextureSource] depth makes a 3D texture, but viewDimension is '${t}'. Use arrayLayerCount for layered textures.`);if(t==="3d"&&e.arrayLayerCount>1)throw Error("[TextureSource] a 3D texture takes depth, not arrayLayerCount.");if(e.dimensions&&e.dimensions!==n)throw Error(`[TextureSource] dimensions '${e.dimensions}' doesn't match viewDimension '${t}'. Leave dimensions out; it is derived from the view.`);else if(e.dimensions)q(Zm,"TextureSource dimensions is derived from viewDimension and depth; leave it out.");if(n==="3d"&&e.antialias)throw Error("[TextureSource] a 3D texture can't be antialiased: WebGPU has no multisampled 3D textures.")}var Op,ve;var St=M(()=>{Qe();To();Fc();Ze();Ie();Dc();Op=class e extends ke{constructor(t={}){super();this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ie("textureSource"),this._resourceType="textureSource",this._resourceId=ie("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.depth=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this.storage=!1,this._batchTick=-1,this._textureBindLocation=-1;let n=t;t={...e.defaultOptions,...t};let s=FT(t),r=s==="3d"||s==="1d"?s:"2d";if(DT(n,s,r),this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width)this.pixelWidth=t.width*this._resolution;else this.pixelWidth=this.resource?this.resourceWidth??1:1;if(t.height)this.pixelHeight=t.height*this._resolution;else this.pixelHeight=this.resource?this.resourceHeight??1:1;this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=r,this.viewDimension=s,this.arrayLayerCount=t.arrayLayerCount,this.depth=r==="3d"?t.depth??1:1,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=r==="3d"?!1:t.antialias,this.transient=t.transient??!1,this.storage=t.storage??!1,this.alphaMode=t.alphaMode,this.style=new Vs(Co(t)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get depthOrArrayLayers(){return this.dimension==="3d"?this.depth:this.arrayLayerCount||1}get source(){return this}get style(){return this._style}set style(t){if(this.style===t)return;this._ownsStyle=!1,this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange()}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){let t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){if(this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style){if(this._ownsStyle)this._style.destroy();this._style=null}this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=ie("resource"),this.emit("change",this),this.emit("unload",this);for(let t in this._gpuData)this._gpuData[t]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){let{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){let{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){if(this._resolution===t)return;this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t}resize(t,n,s){s||(s=this._resolution),t||(t=this.width),n||(n=this.height);let r=Math.round(t*s),i=Math.round(n*s);if(this.width=r/s,this.height=i/s,this._resolution=s,this.pixelWidth===r&&this.pixelHeight===i)return!1;return this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=i,this.emit("resize",this),this._resourceId=ie("resource"),this.emit("change",this),!0}updateMipmaps(){if(this.autoGenerateMipmaps&&this.mipLevelCount>1)this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=bn(this.pixelWidth)&&bn(this.pixelHeight)}static test(t){throw Error("Unimplemented")}};Op.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};ve=Op});function NT(){for(let e=0;e<16;e++){let t=[];Nc.push(t);for(let n=0;n<16;n++){let s=Ao(os[e]*os[n]+ls[e]*as[n]),r=Ao(as[e]*os[n]+cs[e]*as[n]),i=Ao(os[e]*ls[n]+ls[e]*cs[n]),o=Ao(as[e]*ls[n]+cs[e]*cs[n]);for(let a=0;a<16;a++)if(os[a]===s&&as[a]===r&&ls[a]===i&&cs[a]===o){t.push(a);break}}}for(let e=0;e<16;e++){let t=new j;t.set(os[e],as[e],ls[e],cs[e],0,0),Ip.push(t)}}var os,as,ls,cs,Nc,Ip,Ao,ce;var Gc=M(()=>{Ce();os=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],as=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],ls=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],cs=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Nc=[],Ip=[],Ao=Math.sign;NT();ce={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:(e)=>os[e],uY:(e)=>as[e],vX:(e)=>ls[e],vY:(e)=>cs[e],inv:(e)=>{if(e&8)return e&15;return-e&7},add:(e,t)=>Nc[e][t],sub:(e,t)=>Nc[e][ce.inv(t)],rotate180:(e)=>e^4,isVertical:(e)=>(e&3)===2,byDirection:(e,t)=>{if(Math.abs(e)*2<=Math.abs(t)){if(t>=0)return ce.S;return ce.N}else if(Math.abs(t)*2<=Math.abs(e)){if(e>0)return ce.E;return ce.W}else if(t>0){if(e>0)return ce.SE;return ce.SW}else if(e>0)return ce.NE;return ce.NW},matrixAppendRotationInv:(e,t,n=0,s=0,r=0,i=0)=>{let o=Ip[ce.inv(t)],{a,b:l,c:u,d:c}=o,h=n-Math.min(0,a*r,u*i,a*r+u*i),d=s-Math.min(0,l*r,c*i,l*r+c*i),{a:f,b:m,c:p,d:y}=e;e.a=a*f+l*p,e.b=a*m+l*y,e.c=u*f+c*p,e.d=u*m+c*y,e.tx=h*f+d*p+e.tx,e.ty=h*m+d*y+e.ty},transformRectCoords:(e,t,n,s)=>{let{x:r,y:i,width:o,height:a}=e,{x:l,y:u,width:c,height:h}=t;if(n===ce.E)return s.set(r+l,i+u,o,a),s;else if(n===ce.S)return s.set(c-i-a+l,r+u,a,o);else if(n===ce.W)return s.set(c-r-o+l,h-i-a+u,o,a);else if(n===ce.N)return s.set(i+l,h-r-o+u,a,o);return s.set(r+l,i+u,o,a)}}});var Lc=()=>{};var Bp=()=>{};function zr(e){return e.endsWith("int")}var Uc=()=>{};var js;var Wc=M(()=>{z();Uc();St();js=class js extends ve{constructor(e){let t=e.depth??e.arrayLayerCount??1,n=e.resource||new Float32Array(e.width*e.height*t*4),s=e.format;if(!s)if(n instanceof Float32Array)s="rgba32float";else if(n instanceof Int32Array)s="rgba32uint";else if(n instanceof Uint32Array)s="rgba32uint";else if(n instanceof Int16Array)s="rgba16uint";else if(n instanceof Uint16Array)s="rgba16uint";else if(n instanceof Int8Array)s="bgra8unorm";else s="bgra8unorm";let r=zr(s)||t>1;super({...r&&{alphaMode:"no-premultiply-alpha"},...e,resource:n,format:s});this.uploadMethodId="buffer",this._updateStart=0,this._updateEnd=1/0}update(e=0,t=1/0){if((e>0||t<1/0)&&this.depthOrArrayLayers>1)throw Error("[BufferImageSource] a 3D texture or 2D array uploads whole: call update() with no range.");this._updateStart=e,this._updateEnd=t,super.update(),this._updateStart=0,this._updateEnd=1/0}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}};js.extension=D.TextureSource});class qr{constructor(e,t){if(this.mapCoord=new j,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof t>"u")this.clampMargin=e.width<10?0:0.5;else this.clampMargin=t;this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){if(this._texture!==e)this._texture?.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this);this.update()}destroy(){this._texture?.removeListener("update",this.update,this),this._texture=null}multiplyUvs(e,t){if(t===void 0)t=e;let n=this.mapCoord;for(let s=0;s{Ce();Fp=new j});var K;var Ne=M(()=>{Qe();Gc();st();Ze();Ie();Bp();Wc();St();Xc();K=class K extends ke{constructor({source:e,label:t,frame:n,orig:s,trim:r,defaultAnchor:i,defaultBorders:o,rotate:a,dynamic:l}={}){super();if(this.uid=ie("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new se,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new ve,this.noFrame=!n,n)this.frame.copyFrom(n);else{let{width:u,height:c}=this._source;this.frame.width=u,this.frame.height=c}this.orig=s||this.frame,this.trim=r,this.rotate=a??0,this.defaultAnchor=i,this.defaultBorders=o,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(e){if(this._source)this._source.off("resize",this.update,this);this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){if(!this._textureMatrix)this._textureMatrix=new qr(this);return this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){let{uvs:e,frame:t}=this,{width:n,height:s}=this._source,r=t.x/n,i=t.y/s,o=t.width/n,a=t.height/s,l=this.rotate;if(l){let u=o/2,c=a/2,h=r+u,d=i+c;l=ce.add(l,ce.NW),e.x0=h+u*ce.uX(l),e.y0=d+c*ce.uY(l),l=ce.add(l,2),e.x1=h+u*ce.uX(l),e.y1=d+c*ce.uY(l),l=ce.add(l,2),e.x2=h+u*ce.uX(l),e.y2=d+c*ce.uY(l),l=ce.add(l,2),e.x3=h+u*ce.uX(l),e.y3=d+c*ce.uY(l)}else e.x0=r,e.y0=i,e.x1=r+o,e.y1=i,e.x2=r+o,e.y2=i+a,e.x3=r,e.y3=i+a}destroy(e=!1){if(this._source){if(this._source.off("resize",this.update,this),e)this._source.destroy(),this._source=null}this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){if(this.noFrame)this.frame.width=this._source.width,this.frame.height=this._source.height;this.updateUvs(),this.emit("update",this)}get baseTexture(){return q(be,"Texture.baseTexture is now Texture.source"),this._source}};K.EMPTY=new K({label:"EMPTY",source:new ve({label:"EMPTY"})});K.EMPTY.destroy=Lc;K.WHITE=new K({source:new js({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});K.WHITE.destroy=Lc});class Kr{constructor(){this._screenSizes=new Map,this._widths=[],this._heights=[]}get size(){return this._screenSizes.size}set(e,t,n){let s=this._screenSizes.get(e);if(s&&s.pixelWidth===t&&s.pixelHeight===n)return!1;return this._screenSizes.set(e,{pixelWidth:t,pixelHeight:n}),this._update(),!0}remove(e){if(!this._screenSizes.delete(e))return!1;return this._update(),!0}getFittingWidth(e){return this._getFittingAxis(e,this._widths)}getFittingHeight(e){return this._getFittingAxis(e,this._heights)}hasWidth(e){return this._widths.includes(e)}hasHeight(e){return this._heights.includes(e)}_getFittingAxis(e,t){for(let n=0;n=e)return s}return}_update(){this._widths=[...this._screenSizes.values()].map((e)=>e.pixelWidth).filter((e,t,n)=>n.indexOf(e)===t).sort((e,t)=>e-t),this._heights=[...this._screenSizes.values()].map((e)=>e.pixelHeight).filter((e,t,n)=>n.indexOf(e)===t).sort((e,t)=>e-t)}}var Vc=()=>{};function XT(e){let t=Dp[e];if(t!==void 0)return t;return Dp[e]=WT++}function VT(e,t,n,s,r,i){return(e<<17)+(t<<2)+((s?1:0)<<1)+(n?1:0)+(i==="nearest"?1:0)*LT+XT(r)*UT}class Np{constructor(e){this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new Kr,this._enableFullScreen=!1,this.textureOptions=e||{}}get textureStyle(){if(q(Ut,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),!this._textureStyle)this._textureStyle=new Vs(this.textureOptions);return this._textureStyle}set textureStyle(e){q(Ut,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle=e}get enableFullScreen(){return q(Ut,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){q(Ut,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen=e}createTexture(...e){let t=e[0];if(typeof t==="number")q(Ut,"TexturePool.createTexture params are now an options object. See params: { width, height, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],antialias:e[2]??!1,autoGenerateMipmaps:e[3]??!1};let n=t.format??this.textureOptions.format??ve.defaultOptions.format,s=t.scaleMode??this.textureOptions.scaleMode??Vs.defaultOptions.scaleMode,r=new ve({...this.textureOptions,width:t.width,height:t.height,resolution:1,antialias:t.antialias??!1,autoGarbageCollect:!1,autoGenerateMipmaps:t.autoGenerateMipmaps??!1,format:n,scaleMode:s});return new K({source:r,label:`texturePool_${GT++}`})}getOptimalTexture(...e){let t=e[0];if(typeof t==="number")q(Ut,"TexturePool.getOptimalTexture params are now an options object. See params: { width, height, resolution, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],resolution:e[2]??1,antialias:e[3]??!1,autoGenerateMipmaps:e[4]??!1};let n=t.width,s=t.height,r=t.resolution??1,i=t.antialias??!1,o=t.autoGenerateMipmaps??!1,a=t.format??this.textureOptions.format??ve.defaultOptions.format,l=t.scaleMode??this.textureOptions.scaleMode??Vs.defaultOptions.scaleMode,{width:u,height:c}=this.getOptimalSize(n,s,r);if(u>jc||c>jc)te(`TexturePool: ${u}x${c} is larger than the ${jc}px pool key limit, textures of this size may be pooled together`);let h=VT(u,c,i,o,a,l),d=this._buckets.get(h);if(!d)d=[],this._buckets.set(h,d);let f=d.pop();if(!f)f=this.createTexture({width:u,height:c,antialias:i,autoGenerateMipmaps:o,format:a,scaleMode:l}),this._poolStyle[f.uid]=f.source.style;return f.source._resolution=r,f.source.width=u/r,f.source.height=c/r,f.source.pixelWidth=u,f.source.pixelHeight=c,f.frame.x=0,f.frame.y=0,f.frame.width=n,f.frame.height=s,f.updateUvs(),this._poolKey[f.uid]=h,f}getOptimalSize(e,t,n=1){let s=Math.ceil(e*n-0.000001),r=Math.ceil(t*n-0.000001),i=Xs(s),o=this._screens.getFittingWidth(s),a=Xs(r),l=this._screens.getFittingHeight(r);return{width:o!==void 0?Math.min(o,i):i,height:l!==void 0?Math.min(l,a):a}}getSameSizeTexture(e,t=!1){let n=e.source;return this.getOptimalTexture({width:e.width,height:e.height,resolution:n._resolution,antialias:t})}returnTexture(e,t=!1){let n=e.uid,s=this._poolKey[n];if(s===void 0){te("TexturePool: returnTexture was passed a texture that did not come from this pool, ignoring it");return}let r=this._poolStyle[n];if(t&&e.source.style!==r)e.source.style=r;let i=this._buckets.get(s);if(!i){delete this._poolKey[n],delete this._poolStyle[n],e.destroy(!0);return}i.push(e)}setScreenSize(e,t,n){if(!this._screens.set(e,t,n))return;this._pruneScreenTextures()}removeScreen(e){if(!this._screens.remove(e))return;this._pruneScreenTextures()}_pruneScreenTextures(){for(let[e,t]of this._buckets){let n=e>>>0,s=n>>>17,r=n>>>2&32767;if((bn(s)||this._screens.hasWidth(s))&&(bn(r)||this._screens.hasHeight(r)))continue;this._dropTextures(t,!0),this._buckets.delete(e)}}_dropTextures(e,t){for(let n=0;n{To();Ie();Be();ss();St();Ne();Dc();Vc();Dp=Object.create(null);Xe=new Np;Wt.register(Xe)});class Ys{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new j,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new is,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){if(this.root=e,e._onRender)this.addOnRender(e);e.didChange=!0;let t=e.children;for(let n=0;n-1)this.renderGroupChildren.splice(t,1);e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root)e.relativeRenderGroupDepth=1;else e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1;if(e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}if(e._onRender)this.addOnRender(e);let t=e.children;for(let n=0;n0}addOnRender(e){if(this._onRenderContainers.indexOf(e)===-1)this._onRenderContainers.push(e)}removeOnRender(e){let t=this._onRenderContainers.indexOf(e);if(t!==-1)this._onRenderContainers.splice(t,1)}runOnRender(e){for(let t=0;t{Ce();Mo();us()});function Gp(e,t,n={}){for(let s in t)if(!n[s]&&t[s]!==void 0)e[s]=t[s]}var Lp=()=>{};var Hc,Eo,zc,Po,Hs=1,Jr=2,hs=4,Ge;var un=M(()=>{Qe();Lt();Ym();z();Ce();Tc();Ac();Ze();Ie();Be();xn();sp();ip();ap();hp();fp();gp();vp();kp();Tp();Ap();Pp();Yc();Lp();Hc=new tt(null),Eo=new tt(null),zc=new tt(null,1,1),Po=new tt(null);Ge=class Ge extends ke{constructor(e={}){super();this.uid=ie("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new j,this.relativeGroupTransform=new j,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new tt(this,0,0),this._scale=zc,this._pivot=Eo,this._origin=Po,this._skew=Hc,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=[],Gp(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach((t)=>this.addChild(t)),e.parent?.addChild(this)}static mixin(e){q("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),ne.mixin(Ge,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(!this.allowChildren)q(be,"addChild: Only Containers will be allowed to add children in v8.0.0");if(e.length>1){for(let s=0;s1){for(let s=0;s-1){if(this._didViewChangeTick++,this.children.splice(n,1),this.renderGroup)this.renderGroup.removeChild(t);else if(this.parentRenderGroup)this.parentRenderGroup.removeChild(t);if(t.parentRenderLayer)t.parentRenderLayer.detach(t);t.parent=null,this.emit("childRemoved",t,this,n),t.emit("removed",this)}return t}_onUpdate(e){if(e){if(e===this._skew)this._updateSkew()}if(this._didContainerChangeTick++,this.didChange)return;if(this.didChange=!0,this.parentRenderGroup)this.parentRenderGroup.onChildUpdate(this)}set isRenderGroup(e){if(!!this.renderGroup===e)return;if(e)this.enableRenderGroup();else this.disableRenderGroup()}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Re.get(Ys,this),this.groupTransform=j.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e?.removeChild(this),Re.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){if(this._worldTransform||(this._worldTransform=new j),this.renderGroup)this._worldTransform.copyFrom(this.renderGroup.worldTransform);else if(this.parentRenderGroup)this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform);return this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){if(this._rotation!==e)this._rotation=e,this._onUpdate(this._skew)}get angle(){return this.rotation*zm}set angle(e){this.rotation=e*qm}get pivot(){if(this._pivot===Eo)this._pivot=new tt(this,0,0);return this._pivot}set pivot(e){if(this._pivot===Eo){if(this._pivot=new tt(this,0,0),this._origin!==Po)te("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")}typeof e==="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){if(this._skew===Hc)this._skew=new tt(this,0,0);return this._skew}set skew(e){if(this._skew===Hc)this._skew=new tt(this,0,0);this._skew.copyFrom(e)}get scale(){if(this._scale===zc)this._scale=new tt(this,1,1);return this._scale}set scale(e){if(this._scale===zc)this._scale=new tt(this,0,0);if(typeof e==="string")e=parseFloat(e);typeof e==="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){if(this._origin===Po)this._origin=new tt(this,0,0);return this._origin}set origin(e){if(this._origin===Po){if(this._origin=new tt(this,0,0),this._pivot!==Eo)te("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")}typeof e==="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){let t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){let t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){if(!e)e={};let t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){let n=this.getLocalBounds();if(typeof e==="object")t=e.height??e.width,e=e.width;else t??(t=e);e!==void 0&&this._setWidth(e,n.width),t!==void 0&&this._setHeight(t,n.height)}_updateSkew(){let e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x==="number"?e.x:this.position.x,typeof e.y==="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX==="number"?e.scaleX:this.scale.x,typeof e.scaleY==="number"?e.scaleY:this.scale.y),this.rotation=typeof e.rotation==="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX==="number"?e.skewX:this.skew.x,typeof e.skewY==="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX==="number"?e.pivotX:this.pivot.x,typeof e.pivotY==="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX==="number"?e.originX:this.origin.x,typeof e.originY==="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;let t=this.localTransform,n=this._scale,s=this._pivot,r=this._origin,i=this._position,{_x:o,_y:a}=n,{_x:l,_y:u}=s,c=-r._x,h=-r._y;t.a=this._cx*o,t.b=this._sx*o,t.c=this._cy*a,t.d=this._sy*a,t.tx=i._x-(l*t.a+u*t.c)+(c*t.a+h*t.c)-c,t.ty=i._y-(l*t.b+u*t.d)+(c*t.b+h*t.d)-h}set alpha(e){if(e===this.localAlpha)return;this.localAlpha=e,this._updateFlags|=Hs,this._onUpdate()}get alpha(){return this.localAlpha}set tint(e){let n=we.shared.setValue(e??16777215).toBgrNumber();if(n===this.localColor)return;this.localColor=n,this._updateFlags|=Hs,this._onUpdate()}get tint(){return Hr(this.localColor)}set blendMode(e){if(this.localBlendMode===e)return;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._updateFlags|=Jr,this.localBlendMode=e,this._onUpdate()}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;if((this.localDisplayStatus&2)===t)return;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._updateFlags|=hs,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e)}get culled(){return!(this.localDisplayStatus&4)}set culled(e){let t=e?0:4;if((this.localDisplayStatus&4)===t)return;if(this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._updateFlags|=hs,this.localDisplayStatus^=4,this._onUpdate()}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=e?1:0;if((this.localDisplayStatus&1)===t)return;if(this._updateFlags|=hs,this.localDisplayStatus^=1,this.parentRenderGroup)this.parentRenderGroup.structureDidChange=!0;this._onUpdate()}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length)t=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof e==="boolean"?e:e?.children)&&t)for(let s=0;s{Rn=((e)=>(e[e.INTERACTION=50]="INTERACTION",e[e.HIGH=25]="HIGH",e[e.NORMAL=0]="NORMAL",e[e.LOW=-25]="LOW",e[e.UTILITY=-50]="UTILITY",e))(Rn||{})});class Zr{constructor(e,t=null,n=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=n,this._once=s}match(e,t=null){return this._fn===e&&this._context===t}emit(e){if(this._fn)if(this._context)this._fn.call(this._context,e);else this._fn(e);let t=this.next;if(this._once)this.destroy(!0);if(this._destroyed)this.next=null;return t}connect(e){if(this.previous=e,e.next)e.next.previous=this;this.next=e.next,e.next=this}destroy(e=!1){if(this._destroyed=!0,this._fn=null,this._context=null,this.previous)this.previous.next=this.next;if(this.next)this.next.previous=this.previous;let t=this.next;return this.next=e?null:t,this.previous=null,t}}var Up=()=>{};var Wp=class e{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Zr(null,null,1/0),this.deltaMS=1/e.targetFPMS,this.elapsedMS=1/e.targetFPMS,this._tick=(t)=>{if(this._requestId=null,this.started){if(this.update(t),this.started&&this._requestId===null&&this._head.next)this._requestId=requestAnimationFrame(this._tick)}}}_requestIfNeeded(){if(this._requestId===null&&this._head.next)this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick)}_cancelIfNeeded(){if(this._requestId!==null)cancelAnimationFrame(this._requestId),this._requestId=null}_startIfPossible(){if(this.started)this._requestIfNeeded();else if(this.autoStart)this.start()}add(t,n,s=Rn.NORMAL){return this._addListener(new Zr(t,n,s))}addOnce(t,n,s=Rn.NORMAL){return this._addListener(new Zr(t,n,s,!0))}_addListener(t){let n=this._head.next,s=this._head;if(!n)t.connect(s);else{while(n){if(t.priority>n.priority){t.connect(s);break}s=n,n=n.next}if(!t.previous)t.connect(s)}return this._startIfPossible(),this}remove(t,n){let s=this._head.next;while(s)if(s.match(t,n))s=s.destroy();else s=s.next;if(!this._head.next)this._cancelIfNeeded();return this}get count(){if(!this._head)return 0;let t=0,n=this._head;while(n=n.next)t++;return t}start(){if(!this.started)this.started=!0,this._requestIfNeeded()}stop(){if(this.started)this.started=!1,this._cancelIfNeeded()}destroy(){if(!this._protected){this.stop();let t=this._head.next;while(t)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS)n=this._maxElapsedMS;if(n*=this.speed,this._minElapsedMS){let i=t-this._lastFrame|0;if(ithis.maxFPS)this.maxFPS=t}get maxFPS(){if(this._minElapsedMS)return Math.round(1000/this._minElapsedMS);return 0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{if(t{Ro();Up();Wp.targetFPMS=0.06;rt=Wp});class Qr{constructor(e){if(this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;let t=this._canvas.getBoundingClientRect(),n=this._canvas.width,s=this._canvas.height,r=t.width/n*this._renderer.resolution,i=t.height/s*this._renderer.resolution,{left:o,top:a}=t,l=`translate(${o}px, ${a}px) scale(${r}, ${i})`;if(l!==this._lastTransform)this._domElement.style.transform=l,this._lastTransform=l},this._domElement=e.domElement,this._renderer=e.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)return;this._canvas=this._renderer.canvas,this._attachObserver()}get canvas(){return this._canvas}ensureAttached(){if(!this._domElement.parentNode&&this._canvas.parentNode)this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation()}_attachObserver(){if("ResizeObserver"in globalThis){if(this._observer)this._observer.disconnect(),this._observer=null;this._observer=new ResizeObserver((e)=>{for(let t of e){if(t.target!==this._canvas)continue;let n=this.canvas.width,s=this.canvas.height,r=t.contentRect.width/n*this._renderer.resolution,i=t.contentRect.height/s*this._renderer.resolution;if(this._lastScaleX!==r||this._lastScaleY!==i)this.updateTranslation(),this._lastScaleX=r,this._lastScaleY=i}}),this._observer.observe(this._canvas)}else if(!this._tickerAttached)rt.shared.add(this.updateTranslation,this,Rn.HIGH)}destroy(){if(this._observer)this._observer.disconnect(),this._observer=null;else if(this._tickerAttached)rt.shared.remove(this.updateTranslation);this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}var qc=M(()=>{Ro();zs()});class $n{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=$n.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ue,this.page=new ue,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){if(this.manager&&(!this.path||this.path[this.path.length-1]!==this.target))this.path=this.target?this.manager.propagationPath(this.target):[];return this.path}initEvent(e,t,n){throw Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,n,s,r){throw Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){if(this.nativeEvent instanceof Event&&this.nativeEvent.cancelable)this.nativeEvent.preventDefault();this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var $o=M(()=>{Kt()});function jT(e){return function(t){return t.test(e)}}function ei(e){var t={userAgent:"",platform:"",maxTouchPoints:0};if(!e&&typeof navigator<"u")t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};else if(typeof e==="string")t.userAgent=e;else if(e&&e.userAgent)t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0};var n=t.userAgent,s=n.split("[FBAN");if(typeof s[1]<"u")n=s[0];if(s=n.split("Twitter"),typeof s[1]<"u")n=s[0];var r=jT(n),i={apple:{phone:r(Kc)&&!r(vn),ipod:r(Xp),tablet:!r(Kc)&&(r(Vp)||Qp(t))&&!r(vn),universal:r(jp),device:(r(Kc)||r(Xp)||r(Vp)||r(jp)||Qp(t))&&!r(vn)},amazon:{phone:r(qs),tablet:!r(qs)&&r(Oo),device:r(qs)||r(Oo)},android:{phone:!r(vn)&&r(qs)||!r(vn)&&r(Jc),tablet:!r(vn)&&!r(qs)&&!r(Jc)&&(r(Oo)||r(Yp)),device:!r(vn)&&(r(qs)||r(Oo)||r(Jc)||r(Yp))||r(/\bokhttp\b/i)},windows:{phone:r(vn),tablet:r(Hp),device:r(vn)||r(Hp)},other:{blackberry:r(zp),blackberry10:r(qp),opera:r(Kp),firefox:r(Zp),chrome:r(Jp),device:r(zp)||r(qp)||r(Kp)||r(Zp)||r(Jp)},any:!1,phone:!1,tablet:!1};return i.any=i.apple.device||i.android.device||i.windows.device||i.other.device,i.phone=i.apple.phone||i.android.phone||i.windows.phone,i.tablet=i.apple.tablet||i.android.tablet||i.windows.tablet,i}var Kc,Xp,Vp,jp,Jc,Yp,qs,Oo,vn,Hp,zp,qp,Kp,Jp,Zp,Qp=function(e){return typeof e<"u"&&e.platform==="MacIntel"&&typeof e.maxTouchPoints==="number"&&e.maxTouchPoints>1&&typeof MSStream>"u"};var Zc=M(()=>{Kc=/iPhone/i,Xp=/iPod/i,Vp=/iPad/i,jp=/\biOS-universal(?:.+)Mac\b/i,Jc=/\bAndroid(?:.+)Mobile\b/i,Yp=/Android/i,qs=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Oo=/Silk/i,vn=/Windows Phone/i,Hp=/\bWindows(?:.+)ARM\b/i,zp=/BlackBerry/i,qp=/BB10/i,Kp=/Opera Mini/i,Jp=/\b(CriOS|Chrome)(?:.+)Mobile/i,Zp=/Mobile(?:.+)Firefox\b/i});var eg=M(()=>{Zc();Zc()});var YT,tg;var ng=M(()=>{eg();YT=ei.default??ei,tg=YT(globalThis.navigator)});var HT=9,sg=100,zT=0,qT=0,rg=2,ig=1,KT=-1000,JT=-1000,ZT=2,Qc=class e{constructor(t,n=tg){if(this._mobileInfo=n,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,n.tablet||n.phone)this._createTouchHook();this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){let t=document.createElement("button");t.style.width=`${ig}px`,t.style.height=`${ig}px`,t.style.position="absolute",t.style.top=`${KT}px`,t.style.left=`${JT}px`,t.style.zIndex=ZT.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){if(!this._hookDiv)return;document.body.removeChild(this._hookDiv),this._hookDiv=null}_activate(){if(this._isActive)return;if(this._isActive=!0,!this._div)this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${zT}px`,this._div.style.left=`${qT}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=rg.toString(),this._canvasObserver=new Qr({domElement:this._div,renderer:this._renderer});if(this._deactivateOnMouseMove)globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);let t=this._renderer.view.canvas;if(!t.parentNode){let n=new MutationObserver(()=>{if(t.parentNode)n.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup()});n.observe(document.body,{childList:!0,subtree:!0})}else this._canvasObserver.ensureAttached(),this._initAccessibilitySetup()}_initAccessibilitySetup(){if(this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered)this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!this._isActive||this._isMobileAccessibility)return;this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._renderer.runners.postrender.remove(this);for(let t of this._children){if(t._accessibleDiv?.parentNode)t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null;t._accessibleActive=!1}for(let t in this._pools)this._pools[t].forEach((s)=>{if(s.parentNode)s.parentNode.removeChild(s)}),delete this._pools[t];if(this._div?.parentNode)this._div.parentNode.removeChild(this._div);this._pools={},this._children=[]}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;if(t.accessible){if(!t._accessibleActive)this._addChild(t);t._renderId=this._renderId}let n=t.children;if(n)for(let s=0;s=0;s--){let r=this._children[s];if(!n.has(s)){if(r._accessibleDiv&&r._accessibleDiv.parentNode)r._accessibleDiv.parentNode.removeChild(r._accessibleDiv),this._getPool(r.accessibleType).push(r._accessibleDiv),r._accessibleDiv=null;r._accessibleActive=!1,xo(this._children,s,1)}}if(this._renderer.renderingToScreen)this._canvasObserver.ensureAttached();for(let s=0;s title : ${t.title}
tabIndex: ${t.tabIndex}`}_capHitArea(t){if(t.x<0)t.width+=t.x,t.x=0;if(t.y<0)t.height+=t.y,t.y=0;let{width:n,height:s}=this._renderer;if(t.x+t.width>n)t.width=n-t.x;if(t.y+t.height>s)t.height=s-t.y}_addChild(t){let s=this._getPool(t.accessibleType).pop();if(s)s.innerHTML="",s.removeAttribute("title"),s.removeAttribute("aria-label"),s.tabIndex=0;else{if(t.accessibleType==="button"){if(s=document.createElement("button"),!this.debug)s.style.color="transparent"}else s=document.createElement(t.accessibleType),s.style.cssText=` color: transparent; pointer-events: none; padding: 0; @@ -14,7 +14,7 @@ Deprecated since v${e}`,i=typeof console.groupCollapsed==="function"&&!Rs.noColo -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; - `;if(s.style.width=`${Wp}px`,s.style.height=`${Wp}px`,s.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",s.style.position="absolute",s.style.zIndex=Xp.toString(),s.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome"))s.setAttribute("aria-live","off");else s.setAttribute("aria-live","polite");if(navigator.userAgent.match(/rv:.*Gecko\//))s.setAttribute("aria-relevant","additions");else s.setAttribute("aria-relevant","text");s.addEventListener("click",this._onClick.bind(this)),s.addEventListener("focus",this._onFocus.bind(this)),s.addEventListener("focusout",this._onFocusOut.bind(this))}if(s.style.pointerEvents=t.accessiblePointerEvents,s.type=t.accessibleType,t.accessibleText)s.innerText=t.accessibleText;if(t.accessibleTitle&&t.accessibleTitle!==null)s.title=t.accessibleTitle;else if(!t.accessibleHint||t.accessibleHint===null)s.title=`container ${t.tabIndex}`;if(t.accessibleHint&&t.accessibleHint!==null)s.setAttribute("aria-label",t.accessibleHint);if(t.interactive)s.tabIndex=t.tabIndex;else s.tabIndex=0;if(this.debug)this._updateDebugHTML(s);t._accessibleActive=!0,t._accessibleDiv=s,s.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,n){let{container:s}=t.target,r=this._renderer.events.rootBoundary,i=Object.assign(new Mn(r),{target:s});r.rootTarget=this._renderer.lastObjectRendered,n.forEach((o)=>r.dispatchEvent(i,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){if(!t.target.getAttribute("aria-live"))t.target.setAttribute("aria-live","assertive");this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){if(!t.target.getAttribute("aria-live"))t.target.setAttribute("aria-live","polite");this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){if(t.keyCode!==TT||!this._activateOnTab)return;this._activate()}_onMouseMove(t){if(t.movementX===0&&t.movementY===0)return;this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){if(t)this._activate();else this._deactivate()}_getPool(t){if(!this._pools[t])this._pools[t]=[];return this._pools[t]}},Yp;var Vp=w(()=>{Lc();To();W();Up();kc();jc.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"accessibility"};jc.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};Yp=jc});var Hp;var zp=w(()=>{Hp={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}});var qp=w(()=>{W();nn();Vp();zp();Z.add(Yp);Z.mixin(Fe,Hp)});class Ao{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new Xr({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){if(!this._attachedDomElements.includes(e))this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){let e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t{W();Lc();Ao.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"dom"}});var ns;var Eo=w(()=>{ft();nn();ns=class ns extends Fe{constructor(e){super(e);this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new fe(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){if(!this._boundsDirty)return this._bounds;return this.updateBounds(),this._boundsDirty=!1,this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){let t=this.bounds,{x:n,y:s}=e;return n>=t.minX&&n<=t.maxX&&s>=t.minY&&s<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;if(e)e.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,n){let{renderPipes:s}=t;s.blendMode.pushBlendMode(this,this.groupBlendMode,e);let i=s[this.renderPipeId];if(i?.addRenderable)i.addRenderable(this,e);this.didViewUpdate=!1;let o=this.children,a=o.length;for(let l=0;l{W();Kp();Z.add(Ao)});class Zp{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){if(this._tickerAdded||!this.domElement)return;tt.system.add(this._tickerUpdate,this,wn.INTERACTION),this._tickerAdded=!0}removeTickerListener(){if(!this._tickerAdded)return;tt.system.remove(this._tickerUpdate,this),this._tickerAdded=!1}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}let e=this.events._rootPointerEvent;if(this.events.supportsTouchEvents&&e.pointerType==="touch")return;globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){if(this._deltaTime+=e.deltaTime,this._deltaTime{Mo();Gs();Yt=new Zp});var Tn;var Ro=w(()=>{jt();To();Tn=class Tn extends Mn{constructor(){super(...arguments);this.client=new ie,this.movement=new ie,this.offset=new ie,this.global=new ie,this.screen=new ie}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,n){return e.worldTransform.applyInverse(n||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,n,s,r,i,o,a,l,u,c,h,d,f,m){throw Error("Method not implemented.")}}});var ot;var Vc=w(()=>{Ro();ot=class ot extends Tn{constructor(){super(...arguments);this.width=0,this.height=0,this.isPrimary=!1,this.persistentDeviceId=0}getCoalescedEvents(){if(this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove")return[this];return[]}getPredictedEvents(){throw Error("getPredictedEvents is not supported!")}}});var pn;var Hc=w(()=>{Ro();pn=class pn extends Tn{constructor(){super(...arguments);this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};pn.DOM_DELTA_PIXEL=0;pn.DOM_DELTA_LINE=1;pn.DOM_DELTA_PAGE=2});class zc{constructor(e){this.dispatch=new de,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mapContextMenu=this.mapContextMenu.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),this.addEventMapping("contextmenu",this.mapContextMenu)}addEventMapping(e,t){if(!this.mappingTable[e])this.mappingTable[e]=[];this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((n,s)=>n.priority-s.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;let t=this.mappingTable[e.type];if(t)for(let n=0,s=t.length;n=0;s--)if(e.currentTarget=n[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}all(e,t,n=this._allInteractiveElements){if(n.length===0)return;e.eventPhase=e.BUBBLING_PHASE;let s=Array.isArray(t)?t:[t];for(let r=n.length-1;r>=0;r--)s.forEach((i)=>{e.currentTarget=n[r],this.notifyTarget(e,i)})}propagationPath(e){let t=[e];for(let n=0;n<$T&&(e!==this.rootTarget&&e.parent);n++){if(!e.parent)throw Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,n,s,r,i=!1){let o=!1;if(this._interactivePrune(e))return null;if(e.eventMode==="dynamic"||t==="dynamic")Yt.pauseUpdate=!1;if(e.interactiveChildren&&e.children){let u=e.children;for(let c=u.length-1;c>=0;c--){let h=u[c],d=this.hitTestMoveRecursive(h,this._isInteractive(t)?t:h.eventMode,n,s,r,i||r(e,n));if(d){if(d.length>0&&!d[d.length-1].parent)continue;let f=e.isInteractive();if(d.length>0||f){if(f)this._allInteractiveElements.push(e);d.push(e)}if(this._hitElements.length===0)this._hitElements=d;o=!0}}}let a=this._isInteractive(t),l=e.isInteractive();if(l&&l)this._allInteractiveElements.push(e);if(i||this._hitElements.length>0)return null;if(o)return this._hitElements;if(a&&(!r(e,n)&&s(e,n)))return l?[e]:[];return null}hitTestRecursive(e,t,n,s,r){if(this._interactivePrune(e)||r(e,n))return null;if(e.eventMode==="dynamic"||t==="dynamic")Yt.pauseUpdate=!1;if(e.interactiveChildren&&e.children){let a=e.children,l=n;for(let u=a.length-1;u>=0;u--){let c=a[u],h=this.hitTestRecursive(c,this._isInteractive(t)?t:c.eventMode,l,s,r);if(h){if(h.length>0&&!h[h.length-1].parent)continue;let d=e.isInteractive();if(h.length>0||d)h.push(e);return h}}}let i=this._isInteractive(t),o=e.isInteractive();if(i&&s(e,n))return o?[e]:[];return null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){if(!e||!e.visible||!e.renderable||!e.measurable)return!0;if(e.eventMode==="none")return!0;if(e.eventMode==="passive"&&!e.interactiveChildren)return!0;return!1}hitPruneFn(e,t){if(e.hitArea){if(e.worldTransform.applyInverse(t,Yr),!e.hitArea.contains(Yr.x,Yr.y))return!0}if(e.effects&&e.effects.length)for(let n=0;n0&&r!==t.target){let a=e.type==="mousemove"?"mouseout":"pointerout",l=this.createPointerEvent(e,a,r);if(this.dispatchEvent(l,"pointerout"),n)this.dispatchEvent(l,"mouseout");if(!t.composedPath().includes(r)){let u=this.createPointerEvent(e,"pointerleave",r);u.eventPhase=u.AT_TARGET;while(u.target&&!t.composedPath().includes(u.target)){if(u.currentTarget=u.target,this.notifyTarget(u),n)this.notifyTarget(u,"mouseleave");u.target=u.target.parent}this.freeEvent(u)}this.freeEvent(l)}if(r!==t.target){let a=e.type==="mousemove"?"mouseover":"pointerover",l=this.clonePointerEvent(t,a);if(this.dispatchEvent(l,"pointerover"),n)this.dispatchEvent(l,"mouseover");let u=r?.parent;while(u&&u!==this.rootTarget.parent){if(u===t.target)break;u=u.parent}if(!u||u===this.rootTarget.parent){let h=this.clonePointerEvent(t,"pointerenter");h.eventPhase=h.AT_TARGET;while(h.target&&h.target!==r&&h.target!==this.rootTarget.parent){if(h.currentTarget=h.target,this.notifyTarget(h),n)this.notifyTarget(h,"mouseenter");h.target=h.target.parent}this.freeEvent(h)}this.freeEvent(l)}let i=[],o=this.enableGlobalMoveEvents??!0;if(this.moveOnAll?i.push("pointermove"):this.dispatchEvent(t,"pointermove"),o&&i.push("globalpointermove"),t.pointerType==="touch")this.moveOnAll?i.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),o&&i.push("globaltouchmove");if(n)this.moveOnAll?i.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),o&&i.push("globalmousemove"),this.cursor=t.target?.cursor;if(i.length>0)this.all(t,i);this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof ot)){V("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId),n=this.createPointerEvent(e),s=n.pointerType==="mouse"||n.pointerType==="pen";if(this.dispatchEvent(n,"pointerover"),s)this.dispatchEvent(n,"mouseover");if(n.pointerType==="mouse")this.cursor=n.target?.cursor;let r=this.clonePointerEvent(n,"pointerenter");r.eventPhase=r.AT_TARGET;while(r.target&&r.target!==this.rootTarget.parent){if(r.currentTarget=r.target,this.notifyTarget(r),s)this.notifyTarget(r,"mouseenter");r.target=r.target.parent}t.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(r)}mapPointerOut(e){if(!(e instanceof ot)){V("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId);if(t.overTargets){let n=e.pointerType==="mouse"||e.pointerType==="pen",s=this.findMountedTarget(t.overTargets),r=this.createPointerEvent(e,"pointerout",s);if(this.dispatchEvent(r),n)this.dispatchEvent(r,"mouseout");let i=this.createPointerEvent(e,"pointerleave",s);i.eventPhase=i.AT_TARGET;while(i.target&&i.target!==this.rootTarget.parent){if(i.currentTarget=i.target,this.notifyTarget(i),n)this.notifyTarget(i,"mouseleave");i.target=i.target.parent}t.overTargets=null,this.freeEvent(r),this.freeEvent(i)}this.cursor=null}mapPointerUp(e){if(!(e instanceof ot)){V("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=performance.now(),n=this.createPointerEvent(e);if(this.dispatchEvent(n,"pointerup"),n.pointerType==="touch")this.dispatchEvent(n,"touchend");else if(n.pointerType==="mouse"||n.pointerType==="pen"){let o=n.button===2;this.dispatchEvent(n,o?"rightup":"mouseup")}let s=this.trackingData(e.pointerId),r=this.findMountedTarget(s.pressTargetsByButton[e.button]),i=r;if(r&&!n.composedPath().includes(r)){let o=r;while(o&&!n.composedPath().includes(o)){if(n.currentTarget=o,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch")this.notifyTarget(n,"touchendoutside");else if(n.pointerType==="mouse"||n.pointerType==="pen"){let a=n.button===2;this.notifyTarget(n,a?"rightupoutside":"mouseupoutside")}o=o.parent}delete s.pressTargetsByButton[e.button],i=o}if(i){let o=this.clonePointerEvent(n,"click");if(o.target=i,o.path=null,!s.clicksByButton[e.button])s.clicksByButton[e.button]={clickCount:0,target:o.target,timeStamp:t};let a=s.clicksByButton[e.button];if(a.target===o.target&&t-a.timeStamp<200)++a.clickCount;else a.clickCount=1;if(a.target=o.target,a.timeStamp=t,o.detail=a.clickCount,o.pointerType==="mouse"){let l=o.button===2;this.dispatchEvent(o,l?"rightclick":"click")}else if(o.pointerType==="touch")this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(n)}mapPointerUpOutside(e){if(!(e instanceof ot)){V("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId),n=this.findMountedTarget(t.pressTargetsByButton[e.button]),s=this.createPointerEvent(e);if(n){let r=n;while(r){if(s.currentTarget=r,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen")this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside");r=r.parent}delete t.pressTargetsByButton[e.button]}this.freeEvent(s)}mapWheel(e){if(!(e instanceof pn)){V("EventBoundary cannot map a non-wheel event as a wheel event");return}let t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}mapContextMenu(e){if(!(e instanceof ot)){V("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.createPointerEvent(e);this.dispatchEvent(t,"contextmenu"),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let n=1;n{Ke();jt();Pe();Yc();Ro();Vc();Hc();OT=new ie,Yr=new ie});var IT=1,BT,qc=class e{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new zc(null),Yt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new ot(null),this._rootWheelEvent=new pn(null),this._rootContextMenuEvent=new ot(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...e.defaultEventFeatures},{set:(n,s,r)=>{if(s==="globalMove")this.rootBoundary.enableGlobalMoveEvents=r;return n[s]=r,!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._onContextMenu=this._onContextMenu.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){let{canvas:n,resolution:s}=this.renderer;this.setTargetElement(n),this.resolution=s,e._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){Yt.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let n=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas)n=!1;if(this._currentCursor===t)return;this._currentCursor=t;let s=this.cursorStyles[t];if(s)switch(typeof s){case"string":if(n)this.domElement.style.cursor=s;break;case"function":s(t);break;case"object":if(n)Object.assign(this.domElement.style,s);break}else if(n&&typeof t==="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t))this.domElement.style.cursor=t}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let n=this._normalizeToPointerData(t);if(this.autoPreventDefault&&n[0].isNormalized){if(t.cancelable||!("cancelable"in t))t.preventDefault()}for(let s=0,r=n.length;s0)n=t.composedPath()[0];let s=n!==this.domElement?"outside":"",r=this._normalizeToPointerData(t);for(let i=0,o=r.length;i"u")i.button=0;if(typeof i.buttons>"u")i.buttons=1;if(typeof i.isPrimary>"u")i.isPrimary=t.touches.length===1&&t.type==="touchstart";if(typeof i.width>"u")i.width=i.radiusX||1;if(typeof i.height>"u")i.height=i.radiusY||1;if(typeof i.tiltX>"u")i.tiltX=0;if(typeof i.tiltY>"u")i.tiltY=0;if(typeof i.pointerType>"u")i.pointerType="touch";if(typeof i.pointerId>"u")i.pointerId=i.identifier||0;if(typeof i.pressure>"u")i.pressure=i.force||0.5;if(typeof i.twist>"u")i.twist=0;if(typeof i.tangentialPressure>"u")i.tangentialPressure=0;if(typeof i.layerX>"u")i.layerX=i.offsetX=i.clientX;if(typeof i.layerY>"u")i.layerY=i.offsetY=i.clientY;i.isNormalized=!0,i.type=t.type,i.altKey??(i.altKey=t.altKey),i.ctrlKey??(i.ctrlKey=t.ctrlKey),i.metaKey??(i.metaKey=t.metaKey),i.shiftKey??(i.shiftKey=t.shiftKey),n.push(i)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){let s=t;if(typeof s.isPrimary>"u")s.isPrimary=!0;if(typeof s.width>"u")s.width=1;if(typeof s.height>"u")s.height=1;if(typeof s.tiltX>"u")s.tiltX=0;if(typeof s.tiltY>"u")s.tiltY=0;if(typeof s.pointerType>"u")s.pointerType="mouse";if(typeof s.pointerId>"u")s.pointerId=IT;if(typeof s.pressure>"u")s.pressure=0.5;if(typeof s.twist>"u")s.twist=0;if(typeof s.tangentialPressure>"u")s.tangentialPressure=0;s.isNormalized=!0,n.push(s)}else n.push(t);return n}normalizeWheelEvent(t){let n=this._rootWheelEvent;return this._transferMouseData(n,t),n.deltaX=t.deltaX,n.deltaY=t.deltaY,n.deltaZ=t.deltaZ,n.deltaMode=t.deltaMode,this.mapPositionToPoint(n.screen,t.clientX,t.clientY),n.global.copyFrom(n.screen),n.offset.copyFrom(n.screen),n.nativeEvent=t,n.type=t.type,n}_bootstrapEvent(t,n){if(t.originalEvent=null,t.nativeEvent=n,t.pointerId=n.pointerId,t.width=n.width,t.height=n.height,t.isPrimary=n.isPrimary,t.pointerType=n.pointerType,t.pressure=n.pressure,t.tangentialPressure=n.tangentialPressure,t.tiltX=n.tiltX,t.tiltY=n.tiltY,t.twist=n.twist,this._transferMouseData(t,n),this.mapPositionToPoint(t.screen,n.clientX,n.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=n.isTrusted,t.type==="pointerleave")t.type="pointerout";if(t.type.startsWith("mouse"))t.type=t.type.replace("mouse","pointer");if(t.type.startsWith("touch"))t.type=BT[t.type]||t.type;return t}_transferMouseData(t,n){t.isTrusted=n.isTrusted,t.srcElement=n.srcElement,t.timeStamp=performance.now(),t.type=n.type,t.altKey=n.altKey,t.button=n.button,t.buttons=n.buttons,t.client.x=n.clientX,t.client.y=n.clientY,t.ctrlKey=n.ctrlKey,t.metaKey=n.metaKey,t.movement.x=n.movementX,t.movement.y=n.movementY,t.page.x=n.pageX,t.page.y=n.pageY,t.relatedTarget=null,t.shiftKey=n.shiftKey}},Po;var Kc=w(()=>{W();Qp();Yc();Vc();Hc();BT={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};qc.extension={name:"events",type:[E.WebGLSystem,E.CanvasSystem,E.WebGPUSystem],priority:-1};qc.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};Po=qc});var eg;var tg=w(()=>{Kc();To();eg={onclick:null,oncontextmenu:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(e){this.eventMode=e?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Po.defaultEventMode},set eventMode(e){this._internalEventMode=e},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(e,t,n){let s=typeof n==="boolean"&&n||typeof n==="object"&&n.capture,r=typeof n==="object"?n.signal:void 0,i=typeof n==="object"?n.once===!0:!1,o=typeof t==="function"?void 0:t;e=s?`${e}capture`:e;let a=typeof t==="function"?t:t.handleEvent,l=this;if(r)r.addEventListener("abort",()=>{l.off(e,a,o)});if(i)l.once(e,a,o);else l.on(e,a,o)},removeEventListener(e,t,n){let s=typeof n==="boolean"&&n||typeof n==="object"&&n.capture,r=typeof t==="function"?void 0:t;e=s?`${e}capture`:e,t=typeof t==="function"?t:t.handleEvent,this.off(e,t,r)},dispatchEvent(e){if(!(e instanceof Mn))throw Error("Container cannot propagate events outside of the Federated Events API");return e.defaultPrevented=!1,e.path=null,e.target=this,e.manager.dispatchEvent(e),!e.defaultPrevented}}});var ng=w(()=>{W();nn();Kc();tg();Z.add(Po);Z.mixin(Fe,eg)});var Jc;var sg=w(()=>{Jc=((e)=>(e[e.Low=0]="Low",e[e.Normal=1]="Normal",e[e.High=2]="High",e))(Jc||{})});var rg;var ig=w(()=>{rg={createCanvas:(e,t)=>{let n=document.createElement("canvas");return n.width=e,n.height=t,n},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(e,t)=>fetch(e,t),parseXML:(e)=>new DOMParser().parseFromString(e,"text/xml")}});var og,ne;var nt=w(()=>{ig();og=rg,ne={get(){return og},set(e){og=e}}});function Vt(e){if(typeof e!=="string")throw TypeError(`Path must be a string. Received ${JSON.stringify(e)}`)}function Vr(e){return e.split("?")[0].split("#")[0]}function DT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function FT(e,t,n){return e.replace(new RegExp(DT(t),"g"),n)}function NT(e,t){let n="",s=0,r=-1,i=0,o=-1;for(let a=0;a<=e.length;++a){if(a2){let l=n.lastIndexOf("/");if(l!==n.length-1){if(l===-1)n="",s=0;else n=n.slice(0,l),s=n.length-1-n.lastIndexOf("/");r=a,i=0;continue}}else if(n.length===2||n.length===1){n="",s=0,r=a,i=0;continue}}if(t){if(n.length>0)n+="/..";else n="..";s=2}}else{if(n.length>0)n+=`/${e.slice(r+1,a)}`;else n=e.slice(r+1,a);s=a-r-1}r=a,i=0}else if(o===46&&i!==-1)++i;else i=-1}return n}var ss;var Zc=w(()=>{nt();ss={toPosix(e){return FT(e,"\\","/")},isUrl(e){return/^https?:/.test(this.toPosix(e))},isDataUrl(e){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(e)},isBlobUrl(e){return e.startsWith("blob:")},hasProtocol(e){return/^[^/:]+:/.test(this.toPosix(e))},getProtocol(e){Vt(e),e=this.toPosix(e);let t=/^file:\/\/\//.exec(e);if(t)return t[0];let n=/^[^/:]+:\/{0,2}/.exec(e);if(n)return n[0];return""},toAbsolute(e,t,n){if(Vt(e),this.isDataUrl(e)||this.isBlobUrl(e))return e;let s=Vr(this.toPosix(t??ne.get().getBaseUrl())),r=Vr(this.toPosix(n??this.rootname(s)));if(e=this.toPosix(e),e.startsWith("/"))return ss.join(r,e.slice(1));return this.isAbsolute(e)?e:this.join(s,e)},normalize(e){if(Vt(e),e.length===0)return".";if(this.isDataUrl(e)||this.isBlobUrl(e))return e;e=this.toPosix(e);let t="",n=e.startsWith("/");if(this.hasProtocol(e))t=this.rootname(e),e=e.slice(t.length);let s=e.endsWith("/");if(e=NT(e,!1),e.length>0&&s)e+="/";if(n)return`/${e}`;return t+e},isAbsolute(e){if(Vt(e),e=this.toPosix(e),this.hasProtocol(e))return!0;return e.startsWith("/")},join(...e){if(e.length===0)return".";let t;for(let n=0;n0)if(t===void 0)t=s;else{let r=e[n-1]??"";if(this.joinExtensions.includes(this.extname(r).toLowerCase()))t+=`/../${s}`;else t+=`/${s}`}}if(t===void 0)return".";return this.normalize(t)},dirname(e){if(Vt(e),e.length===0)return".";e=this.toPosix(e);let t=e.charCodeAt(0),n=t===47,s=-1,r=!0,i=this.getProtocol(e),o=e;e=e.slice(i.length);for(let a=e.length-1;a>=1;--a)if(t=e.charCodeAt(a),t===47){if(!r){s=a;break}}else r=!1;if(s===-1)return n?"/":this.isUrl(o)?i+e:i;if(n&&s===1)return"//";return i+e.slice(0,s)},rootname(e){Vt(e),e=this.toPosix(e);let t="";if(e.startsWith("/"))t="/";else t=this.getProtocol(e);if(this.isUrl(e)){let n=e.indexOf("/",t.length);if(n!==-1)t=e.slice(0,n);else t=e;if(!t.endsWith("/"))t+="/"}return t},basename(e,t){if(Vt(e),t)Vt(t);e=Vr(this.toPosix(e));let n=0,s=-1,r=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let o=t.length-1,a=-1;for(i=e.length-1;i>=0;--i){let l=e.charCodeAt(i);if(l===47){if(!r){n=i+1;break}}else{if(a===-1)r=!1,a=i+1;if(o>=0)if(l===t.charCodeAt(o)){if(--o===-1)s=i}else o=-1,s=a}}if(n===s)s=a;else if(s===-1)s=e.length;return e.slice(n,s)}for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!r){n=i+1;break}}else if(s===-1)r=!1,s=i+1;if(s===-1)return"";return e.slice(n,s)},extname(e){Vt(e),e=Vr(this.toPosix(e));let t=-1,n=0,s=-1,r=!0,i=0;for(let o=e.length-1;o>=0;--o){let a=e.charCodeAt(o);if(a===47){if(!r){n=o+1;break}continue}if(s===-1)r=!1,s=o+1;if(a===46){if(t===-1)t=o;else if(i!==1)i=1}else if(t!==-1)i=-1}if(t===-1||s===-1||i===0||i===1&&t===s-1&&t===n+1)return"";return e.slice(t,s)},parse(e){Vt(e);let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;e=Vr(this.toPosix(e));let n=e.charCodeAt(0),s=this.isAbsolute(e),r,i="";if(t.root=this.rootname(e),s||this.hasProtocol(e))r=1;else r=0;let o=-1,a=0,l=-1,u=!0,c=e.length-1,h=0;for(;c>=r;--c){if(n=e.charCodeAt(c),n===47){if(!u){a=c+1;break}continue}if(l===-1)u=!1,l=c+1;if(n===46){if(o===-1)o=c;else if(h!==1)h=1}else if(o!==-1)h=-1}if(o===-1||l===-1||h===0||h===1&&o===l-1&&o===a+1){if(l!==-1)if(a===0&&s)t.base=t.name=e.slice(1,l);else t.base=t.name=e.slice(a,l)}else{if(a===0&&s)t.name=e.slice(1,o),t.base=e.slice(1,l);else t.name=e.slice(a,o),t.base=e.slice(a,l);t.ext=e.slice(o,l)}if(t.dir=this.dirname(e),i)t.dir=i+t.dir;return t},sep:"/",delimiter:":",joinExtensions:[".html"]}});var Cn=(e,t,n=!1)=>{if(!Array.isArray(e))e=[e];if(!t)return e;return e.map((s)=>{if(typeof s==="string"||n)return t(s);return s})};var Qc=()=>{};function ag(e,t,n,s,r){let i=t[n];for(let o=0;o{let o=i.substring(1,i.length-1).split(",");r.push(o)}),ag(e,r,0,n,s)}else s.push(e);return s}var cg=()=>{};var eu=(e)=>!Array.isArray(e);var ug=()=>{};class $o{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach((t)=>{if(this._preferredOrder.push(t),!t.priority)t.priority=Object.keys(t.params)}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e==="string")this._defaultSearchParams=e;else{let t=e;this._defaultSearchParams=Object.keys(t).map((n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t[n])}`).join("&")}}getAlias(e){let{alias:t,src:n}=e;return Cn(t||n,(r)=>{if(typeof r==="string")return r;if(Array.isArray(r))return r.map((i)=>i?.src??i);if(r?.src)return r.src;return r},!0)}removeAlias(e,t){if(!this._assetMap[e])return;if(t&&t!==this._resolverHash[e])return;delete this._resolverHash[e],delete this._assetMap[e]}addManifest(e){if(this._manifest)V("[Resolver] Manifest already exists, this will be overwritten");this._manifest=e,e.bundles.forEach((t)=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){let n=[],s=t;if(!Array.isArray(t))s=Object.entries(t).map(([r,i])=>{if(typeof i==="string"||Array.isArray(i))return{alias:r,src:i};return{alias:r,...i}});s.forEach((r)=>{let{src:i,alias:o}=r,a;if(typeof o==="string"){let l=this._createBundleAssetId(e,o);n.push(l),a=[o,l]}else{let l=o.map((u)=>this._createBundleAssetId(e,u));n.push(...l),a=[...o,...l]}this.add({...r,...{alias:a,src:i}})}),this._bundles[e]=n}add(e){let t=[];if(Array.isArray(e))t.push(...e);else t.push(e);let n;n=(r)=>{if(this.hasKey(r))V(`[Resolver] already has key: ${r} overwriting`)},Cn(t).forEach((r)=>{let{src:i}=r,{data:o,format:a,loadParser:l,parser:u}=r,c=Cn(i).map((m)=>{if(typeof m==="string")return lg(m);return Array.isArray(m)?m:[m]}),h=this.getAlias(r);Array.isArray(h)?h.forEach(n):n(h);let d=[],f=(m)=>{let p=this._parsers.find((y)=>y.test(m));return{src:m,...p?.parse(m)}};c.forEach((m)=>{m.forEach((p)=>{let y={};if(typeof p!=="object")y=f(p);else{if(o=p.data??o,a=p.format??a,p.loadParser||p.parser)l=p.loadParser??l,u=p.parser??u;y={...f(p.src),...p}}if(!h)throw Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this._buildResolvedAsset(y,{aliases:h,data:o,format:a,loadParser:l,parser:u,progressSize:r.progressSize}),d.push(y)})}),h.forEach((m)=>{this._assetMap[m]=d})})}resolveBundle(e){let t=eu(e);e=Cn(e);let n={};return e.forEach((s)=>{let r=this._bundles[s];if(r){let i=this.resolve(r),o={};for(let a in i){let l=i[a];o[this._extractAssetIdFromBundle(s,a)]=l}n[s]=o}}),t?n[e[0]]:n}resolveUrl(e){let t=this.resolve(e);if(typeof e!=="string"){let n={};for(let s in t)n[s]=t[s].src;return n}return t.src}resolve(e){let t=eu(e);e=Cn(e);let n={};return e.forEach((s)=>{if(!this._resolverHash[s])if(this._assetMap[s]){let r=this._assetMap[s],i=this._getPreferredOrder(r);i?.priority.forEach((o)=>{i.params[o].forEach((a)=>{let l=r.filter((u)=>{if(u[o])return u[o]===a;return!1});if(l.length)r=l})}),this._resolverHash[s]=r[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});n[s]=this._resolverHash[s]}),t?n[e[0]]:n}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;tr.params.format.includes(n.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;let t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){let{aliases:n,data:s,loadParser:r,parser:i,format:o,progressSize:a}=t;if(this._basePath||this._rootPath)e.src=ss.toAbsolute(e.src,this._basePath,this._rootPath);if(e.alias=n??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=r??e.loadParser,e.parser=i??e.parser,e.format=o??e.format??GT(e.src),a!==void 0)e.progressSize=a;return e}}function GT(e){return e.split(".").pop().split("?").shift().split("#").shift()}var hg=w(()=>{Pe();Zc();Qc();cg();ug();$o.RETINA_PREFIX=/@([0-9\.]+)x/});var tu=(e,t)=>{let n=t.split("?")[1];if(n)e+=`?${n}`;return e};var dg=()=>{};var fg=class e{constructor(t,n){this.linkedSheets=[];let s=t;if(t?.source instanceof le)s={texture:t,data:n};let{texture:r,data:i,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=r instanceof j?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=i;let a=parseFloat(i.meta.scale);if(a)this.resolution=a,r.source.resolution=this.resolution;else this.resolution=r.source._resolution;this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise((t)=>{if(this._callback=t,this._batchIndex=0,this._frameKeys.length<=e.BATCH_SIZE)this._processFrames(0),this._processAnimations(),this._parseComplete();else this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,n=!1){let s=t,r=n?1/0:e.BATCH_SIZE;while(s-t{if(this._batchIndex*e.BATCH_SIZE{et();gt();De();fg.BATCH_SIZE=1000;nu=fg});function pg(e,t,n){let s={};if(e.forEach((r)=>{s[r]=t}),Object.keys(t.textures).forEach((r)=>{s[`${t.cachePrefix}${r}`]=t.textures[r]}),!n){let r=ss.dirname(e[0]);t.linkedSheets.forEach((i,o)=>{let a=pg([`${r}/${t.data.meta.related_multi_packs[o]}`],i,!0);Object.assign(s,a)})}return s}var LT,gg;var yg=w(()=>{sg();hg();dg();W();De();Zc();mg();LT=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];gg={extension:E.Asset,cache:{test:(e)=>e instanceof nu,getCacheableAssets:(e,t)=>pg(e,t,!1)},resolver:{extension:{type:E.ResolveParser,name:"resolveSpritesheet"},test:(e)=>{let n=e.split("?")[0].split("."),s=n.pop(),r=n.pop();return s==="json"&<.includes(r)},parse:(e)=>{let t=e.split(".");return{resolution:parseFloat($o.RETINA_PREFIX.exec(e)?.[1]??"1"),format:t[t.length-2],src:e}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:E.LoadParser,priority:Jc.Normal,name:"spritesheetLoader"},async testParse(e,t){return ss.extname(t.src).toLowerCase()===".json"&&!!e.frames},async parse(e,t,n){let{texture:s,imageFilename:r,textureOptions:i,cachePrefix:o}=t?.data??{},a=ss.dirname(t.src);if(a&&a.lastIndexOf("/")!==a.length-1)a+="/";let l;if(s instanceof j)l=s;else{let h=tu(a+(r??e.meta.image),t.src);l=(await n.load([{src:h,data:i}]))[h]}let u=new nu({texture:l.source,data:e,cachePrefix:o});await u.parse();let c=e?.meta?.related_multi_packs;if(Array.isArray(c)){let h=[];for(let f of c){if(typeof f!=="string")continue;let m=a+f;if(t.data?.ignoreMultiPack)continue;m=tu(m,t.src),h.push(n.load({src:m,data:{textureOptions:i,ignoreMultiPack:!0}}))}let d=await Promise.all(h);u.linkedSheets=d,d.forEach((f)=>{f.linkedSheets=[u].concat(u.linkedSheets.filter((m)=>m!==f))})}return u},async unload(e,t,n){await n.unload(e.textureSource._sourceOrigin),e.destroy(!1)}}}});var Oo=w(()=>{W();yg();Z.add(gg)});function xg(e,t,n){let{width:s,height:r}=n.orig,i=n.trim;if(i){let{width:o,height:a}=i;e.minX=i.x-t._x*s,e.maxX=e.minX+o,e.minY=i.y-t._y*r,e.maxY=e.minY+a}else e.minX=-t._x*s,e.maxX=e.minX+s,e.minY=-t._y*r,e.maxY=e.minY+r}var bg=()=>{};var Ht;var Io=w(()=>{bc();De();bg();Re();Eo();Ht=class Ht extends ns{constructor(e=j.EMPTY){if(e instanceof j)e={texture:e};let{texture:t=j.EMPTY,anchor:n,roundPixels:s,width:r,height:i,...o}=e;super({label:"Sprite",...o});if(this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Ze({_onUpdate:()=>{this.onViewUpdate()}}),n)this.anchor=n;else if(t.defaultAnchor)this.anchor=t.defaultAnchor;if(this.texture=t,this.allowChildren=!1,this.roundPixels=s??!1,r!==void 0)this.width=r;if(i!==void 0)this.height=i}static from(e,t=!1){if(e instanceof j)return new Ht(e);return new Ht(j.from(e,t))}set texture(e){e||(e=j.EMPTY);let t=this._texture;if(t===e)return;if(t&&t.dynamic)t.off("update",this.onViewUpdate,this);if(e.dynamic)e.on("update",this.onViewUpdate,this);if(this._texture=e,this._width)this._setWidth(this._width,this._texture.orig.width);if(this._height)this._setHeight(this._height,this._texture.orig.height);this.onViewUpdate()}get texture(){return this._texture}get visualBounds(){return xg(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return X("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){let e=this._anchor,t=this._texture,n=this._bounds,{width:s,height:r}=t.orig;n.minX=-e._x*s,n.maxX=n.minX+s,n.minY=-e._y*r,n.maxY=n.minY+r}destroy(e=!1){if(super.destroy(e),typeof e==="boolean"?e:e?.texture){let n=typeof e==="boolean"?e:e?.textureSource;this._texture.destroy(n)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e==="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){if(typeof e==="object")t=e.height??e.width,e=e.width;else t??(t=e);e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}});function Bo(e,t,n){let s=UT;e.measurable=!0,Ps(e,n,s),t.addBoundsMask(s),e.measurable=!1}var UT;var su=w(()=>{ft();Dr();UT=new fe});function Do(e,t,n){let s=_t.get();e.measurable=!0;let r=Ye.get().identity(),i=vg(e,n,r);Os(e,s,i),e.measurable=!1,t.addBoundsMask(s),Ye.return(r),_t.return(s)}function vg(e,t,n){if(!e)return V("Mask bounds, renderable is not inside the root container"),n;if(e!==t)vg(e.parent,t,n),e.updateLocalTransform(),n.append(e.localTransform);return n}var ru=w(()=>{xo();zn();Pe()});class Fo{constructor(e){if(this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e?.mask)this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof Ht),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){if(this.mask===null)return;this.mask.measurable=!0,this.mask=null}addBounds(e,t){if(!this.inverse)Bo(this.mask,e,t)}addLocalBounds(e,t){Do(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof Ht}}var _g=w(()=>{W();Io();su();ru();Fo.extension=E.MaskEffect});class No{constructor(e){if(this.priority=0,this.pipe="colorMask",e?.mask)this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e==="number"}}var Sg=w(()=>{W();No.extension=E.MaskEffect});class Go{constructor(e){if(this.priority=0,this.pipe="stencilMask",e?.mask)this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){if(this.mask===null)return;this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(e,t){Bo(this.mask,e,t)}addLocalBounds(e,t){Do(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof Fe}}var kg=w(()=>{W();nn();su();ru();Go.extension=E.MaskEffect});var St;var Hr=w(()=>{nt();W();gt();St=class St extends le{constructor(e){if(!e.resource)e.resource=ne.get().createCanvas();if(!e.width){if(e.width=e.resource.width,!e.autoDensity)e.width/=e.resolution}if(!e.height){if(e.height=e.resource.height,!e.autoDensity)e.height/=e.resolution}super(e);this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.transparent}resizeCanvas(){if(this.autoDensity&&"style"in this.resource)this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`;if(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight}resize(e=this.width,t=this.height,n=this._resolution){let s=super.resize(e,t,n);if(s)this.resizeCanvas();return s}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}};St.extension=E.TextureSource});var sn;var Lo=w(()=>{W();gt();sn=class sn extends le{constructor(e){super(e);this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}};sn.extension=E.TextureSource});async function wg(){return iu??(iu=(async()=>{let t=ne.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";let n=await new Promise((o)=>{let a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!n)return"premultiply-alpha-on-upload";let s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);let r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n);let i=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,i),t.deleteFramebuffer(r),t.deleteTexture(s),t.getExtension("WEBGL_lose_context")?.loseContext(),i[0]<=i[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),iu}var iu;var Mg=w(()=>{nt()});var Uo,Tg;var Cg=w(()=>{W();Gs();Mg();gt();Uo=class e extends le{constructor(t){super(t);if(this.isReady=!1,this.uploadMethodId="video",t={...e.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1)this.load()}updateFrame(){if(this.destroyed)return;if(this._updateFPS){let t=tt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}if(!this._updateFPS||this._msToNextUpdate<=0)this._msToNextUpdate=this._updateFPS?Math.floor(1000/this._updateFPS):0;if(this.isValid)this.update()}_videoFrameRequestCallback(){if(this.updateFrame(),this.destroyed)this._videoFrameRequestCallbackHandle=null;else this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;let t=this.resource,n=this.options;if((t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height)t.complete=!0;if(t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),!this._isSourceReady()){if(!n.preload)t.addEventListener("canplay",this._onCanPlay);t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)}else this._mediaReady();if(!this.isValid)t.addEventListener("loadedmetadata",this._onLoadedMetadata);return this.alphaMode=await wg(),this._load=new Promise((s,r)=>{if(this.isValid)s(this);else{if(this._resolve=s,this._reject=r,n.preloadTimeoutMs!==void 0)this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${n.preloadTimeoutMs}ms`))});t.load()}}),this._load}_onError(t){if(this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject)this._reject(t),this._reject=null,this._resolve=null}_isSourcePlaying(){let t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){if(this._autoUpdate&&!this._isSourcePlaying())this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0}_onLoadedMetadata(){if(!this.isValid)return;this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){if(this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout)clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0;this._mediaReady()}_mediaReady(){let t=this.resource;if(this.isValid)this.isReady=!0,this.resize(t.videoWidth,t.videoHeight);if(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid)this._resolve(this),this._resolve=null,this._reject=null;if(this._isSourcePlaying())this._onPlayStart();else if(this.autoPlay)this.resource.play()}destroy(){this._configureAutoUpdate();let t=this.resource;if(t)t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load();super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){if(t!==this._autoUpdate)this._autoUpdate=t,this._configureAutoUpdate()}get updateFPS(){return this._updateFPS}set updateFPS(t){if(t!==this._updateFPS)this._updateFPS=t,this._configureAutoUpdate()}_configureAutoUpdate(){if(this._autoUpdate&&this._isSourcePlaying())if(!this._updateFPS&&this.resource.requestVideoFrameCallback){if(this._isConnectedToTicker)tt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0;if(this._videoFrameRequestCallbackHandle===null)this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}else{if(this._videoFrameRequestCallbackHandle!==null)this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null;if(!this._isConnectedToTicker)tt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0}else{if(this._videoFrameRequestCallbackHandle!==null)this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null;if(this._isConnectedToTicker)tt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0}}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Uo.extension=E.TextureSource;Uo.defaultOptions={...le.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Uo.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};Tg=Uo});class Ag{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){let t=this._cache.get(e);if(!t)V(`[Assets] Asset id ${e} was not found in the Cache`);return t}set(e,t){let n=Cn(e),s;for(let a=0;a{r.set(a,t)});let i=[...r.keys()],o={cacheKeys:i,keys:n};n.forEach((a)=>{this._cacheMap.set(a,o)}),i.forEach((a)=>{let l=s?s[a]:t;if(this._cache.has(a)&&this._cache.get(a)!==l)V("[Cache] already has key:",a);this._cache.set(a,r.get(a))})}remove(e){if(!this._cacheMap.has(e)){V(`[Assets] Asset id ${e} was not found in the Cache`);return}let t=this._cacheMap.get(e);t.cacheKeys.forEach((s)=>{this._cache.delete(s)}),t.keys.forEach((s)=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}var rs;var Eg=w(()=>{Pe();Qc();rs=new Ag});function Rg(e={}){let t=e&&e.resource,n=t?e.resource:e,s=t?e:{resource:e};for(let r=0;r{if(rs.has(s))rs.remove(s)}),!t)rs.set(s,i);return i}function $g(e,t=!1){if(typeof e==="string")return rs.get(e);else if(e instanceof le)return new j({source:e});return Pg(e,t)}var ou;var au=w(()=>{Eg();W();gt();De();ou=[];Z.handleByList(E.TextureSource,ou);j.from=$g;le.from=Rg});var Wo=w(()=>{W();_g();Sg();kg();Oc();Hr();Lo();Cg();au();Z.add(Fo,No,Go,Tg,sn,St,Ds)});function Og(e){let t=ne.get().createCanvas(6,1),n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,6,1),t}function Ig(){if(Us!==void 0)return Us;try{let e=Og("#ff00ff"),t=Og("#ffff00"),s=ne.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(e,0,0),s.drawImage(t,2,0);let r=s.getImageData(2,0,1,1);if(!r)Us=!1;else{let i=r.data;Us=i[0]===255&&i[1]===0&&i[2]===0}}catch(e){Us=!1}return Us}var Us;var Bg=w(()=>{nt()});var Ae;var Dg=w(()=>{Pt();nt();Rc();Bg();Ae={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Ig(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:(e)=>{let t=e.source,n=t?.resource;if(!n)return null;let s=t.alphaMode==="premultiplied-alpha",r=t.resourceWidth??t.pixelWidth,i=t.resourceHeight??t.pixelHeight,o=r!==t.pixelWidth||i!==t.pixelHeight;if(s){if(n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas){if(!o)return n}let a=Ae._unpremultipliedCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){let a=Ae._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;let l=ne.get().createCanvas(t.pixelWidth,t.pixelHeight),u=l.getContext("2d"),c=u.createImageData(t.pixelWidth,t.pixelHeight),h=c.data,d=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(t.format==="bgra8unorm")for(let f=0;f0){let f=255/d;c[h]=Math.min(255,c[h]*f+0.5),c[h+1]=Math.min(255,c[h+1]*f+0.5),c[h+2]=Math.min(255,c[h+2]*f+0.5)}}return l.putImageData(u,0,0),Ae._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){let a=Ae._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;let l=ne.get().createCanvas(t.pixelWidth,t.pixelHeight),u=l.getContext("2d");return l.width=t.pixelWidth,l.height=t.pixelHeight,u.drawImage(n,0,0),Ae._canvasSourceCache.set(t,{canvas:l,resourceId:t._resourceId}),l}return n},getTintedCanvas:(e,t)=>{let n=e.texture,s=he.shared.setValue(t).toHex(),r=n.tintCache||(n.tintCache={}),i=r[s],o=n.source._resourceId;if(i?.tintId===o)return i;let a=i&&"getContext"in i?i:ne.get().createCanvas();if(Ae.tintMethod(n,t,a),a.tintId=o,Ae.convertTintToImage&&a.toDataURL!==void 0){let l=ne.get().createImage();l.src=a.toDataURL(),l.tintId=o,r[s]=l}else r[s]=a;return r[s]},getTintedPattern:(e,t)=>{let n=he.shared.setValue(t).toHex(),s=e.patternCache||(e.patternCache={}),r=e.source._resourceId,i=s[n];if(i?.tintId===r)return i;if(!Ae.canvas)Ae.canvas=ne.get().createCanvas();return Ae.tintMethod(e,t,Ae.canvas),i=Ae.canvas.getContext("2d").createPattern(Ae.canvas,"repeat"),i.tintId=r,s[n]=i,i},applyPatternTransform:(e,t,n=!0)=>{if(!t)return;let s=e;if(!s.setTransform)return;let r=globalThis.DOMMatrix;if(!r)return;let i=new r([t.a,t.b,t.c,t.d,t.tx,t.ty]);s.setTransform(n?i.inverse():i)},tintWithMultiply:(e,t,n)=>{let s=n.getContext("2d"),r=e.frame.clone(),i=e.source._resolution??e.source.resolution??1,o=e.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;let a=se.isVertical(o),l=a?r.height:r.width,u=a?r.width:r.height;if(n.width=Math.ceil(l),n.height=Math.ceil(u),s.save(),t!==16777215)s.fillStyle=he.shared.setValue(t).toHex(),s.fillRect(0,0,l,u),s.globalCompositeOperation="multiply";let c=Ae.getCanvasSource(e);if(!c){s.restore();return}if(o)Ae._applyInverseRotation(s,o,r.width,r.height);if(s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),t!==16777215)s.globalCompositeOperation="destination-atop",s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height);s.restore()},tintWithOverlay:(e,t,n)=>{let s=n.getContext("2d"),r=e.frame.clone(),i=e.source._resolution??e.source.resolution??1,o=e.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;let a=se.isVertical(o),l=a?r.height:r.width,u=a?r.width:r.height;n.width=Math.ceil(l),n.height=Math.ceil(u),s.save(),s.globalCompositeOperation="copy",s.fillStyle=he.shared.setValue(t).toHex(),s.fillRect(0,0,l,u),s.globalCompositeOperation="destination-atop";let c=Ae.getCanvasSource(e);if(!c){s.restore();return}if(o)Ae._applyInverseRotation(s,o,r.width,r.height);s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore()},tintWithPerPixel:(e,t,n)=>{let s=n.getContext("2d"),r=e.frame.clone(),i=e.source._resolution??e.source.resolution??1,o=e.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;let a=se.isVertical(o),l=a?r.height:r.width,u=a?r.width:r.height;n.width=Math.ceil(l),n.height=Math.ceil(u),s.save(),s.globalCompositeOperation="copy";let c=Ae.getCanvasSource(e);if(!c){s.restore();return}if(o)Ae._applyInverseRotation(s,o,r.width,r.height);s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore();let h=t>>16&255,d=t>>8&255,f=t&255,m=s.getImageData(0,0,l,u),p=m.data;for(let y=0;y{let r=se.inv(t),i=se.uX(r),o=se.uY(r),a=se.vX(r),l=se.vY(r),u=-Math.min(0,i*n,a*s,i*n+a*s),c=-Math.min(0,o*n,l*s,o*n+l*s);e.transform(i,o,a,l,u,c)}};Ae.tintMethod=Ae.canUseMultiply?Ae.tintWithMultiply:Ae.tintWithPerPixel});function Fg(e,t){return(e<<17)+(t<<2)}class Ng{constructor(e){this._buckets=new Map,this._screens=new Lr,this._enableFullScreen=!1,this.canvasOptions=e||{}}get enableFullScreen(){return X($t,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){X($t,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen=e}_createCanvasAndContext(e,t){let n=ne.get().createCanvas();n.width=e,n.height=t;let s=n.getContext("2d");return{canvas:n,context:s}}getOptimalCanvasAndContext(e,t,n=1){let{width:s,height:r}=this.getOptimalSize(e,t,n);if(s>lu||r>lu)V(`CanvasPool: ${s}x${r} is larger than the ${lu}px pool key limit, canvases of this size may be pooled together`);let i=Fg(s,r),o=this._buckets.get(i);if(!o)o=[],this._buckets.set(i,o);let a=o.pop();if(!a)a=this._createCanvasAndContext(s,r);return a}getOptimalSize(e,t,n=1){let s=Math.ceil(e*n-0.000001),r=Math.ceil(t*n-0.000001),i=Is(s),o=this._screens.getFittingWidth(s),a=Is(r),l=this._screens.getFittingHeight(r);return{width:o!==void 0?Math.min(o,i):i,height:l!==void 0?Math.min(l,a):a}}returnCanvasAndContext(e){let t=e.canvas,{width:n,height:s}=t,r=this._buckets.get(Fg(n,s));if(!r)return;e.context.resetTransform(),e.context.clearRect(0,0,n,s),r.push(e)}setScreenSize(e,t,n){if(!this._screens.set(e,t,n))return;this._pruneScreenCanvases()}removeScreen(e){if(!this._screens.remove(e))return;this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(let[e]of this._buckets){let t=e>>>17,n=e>>>2&32767;if((fn(t)||this._screens.hasWidth(t))&&(fn(n)||this._screens.hasHeight(n)))continue;this._buckets.delete(e)}}}var lu=32767,Ws;var cu=w(()=>{nt();vo();Re();Pe();Hn();Bc();Ws=new Ng;Ot.register(Ws)});function Xo(e){let t=e.length;if(t<6)return 1;let n=0;for(let s=0,r=e[t-2],i=e[t-1];s{};function Gg(e,t,n,s,r,i){let o=e-n,a=t-s,l=r-n,u=i-s,c=o*l+a*u,h=l*l+u*u,d=-1;if(h!==0)d=c/h;let f,m;if(d<0)f=n,m=s;else if(d>1)f=r,m=i;else f=n+d*l,m=s+d*u;let p=e-f,y=t-m;return p*p+y*y}var Lg=()=>{};function hu(e,t,n,s,r,i,o,a){let l=o-n,u=a-s,c=r-n,h=i-s,d=e-n,f=t-s,m=l*l+u*u,p=l*c+u*h,y=l*d+u*f,g=c*c+h*h,x=c*d+h*f,b=1/(m*g-p*p),v=(g*y-p*x)*b,_=(m*x-p*y)*b;return v>=0&&_>=0&&v+_<1}var Ug=()=>{};class jo{constructor(e=0,t=0,n=0){this.type="circle",this.x=e,this.y=t,this.radius=n}clone(){return new jo(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;let n=this.radius*this.radius,s=this.x-e,r=this.y-t;return s*=s,r*=r,s+r<=n}strokeContains(e,t,n,s=0.5){if(this.radius===0)return!1;let r=this.x-e,i=this.y-t,o=this.radius,a=(1-s)*n,l=Math.sqrt(r*r+i*i);return l<=o+a&&l>o-(n-a)}getBounds(e){return e||(e=new Q),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}var Wg=w(()=>{et()});class Yo{constructor(e=0,t=0,n=0,s=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=n,this.halfHeight=s}clone(){return new Yo(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let n=(e-this.x)/this.halfWidth,s=(t-this.y)/this.halfHeight;return n*=n,s*=s,n+s<=1}strokeContains(e,t,n,s=0.5){let{halfWidth:r,halfHeight:i}=this;if(r<=0||i<=0)return!1;let o=n*(1-s),a=n-o,l=r-a,u=i-a,c=r+o,h=i+o,d=e-this.x,f=t-this.y;if(d*d/(c*c)+f*f/(h*h)>1)return!1;if(l<=0||u<=0)return!0;return d*d/(l*l)+f*f/(u*u)>1}getBounds(e){return e||(e=new Q),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}var Xg=w(()=>{et()});class Xs{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!=="number"){let n=[];for(let s=0,r=t.length;st!==u>t&&e<(l-o)*((t-a)/(u-a))+o)n=!n}return n}strokeContains(e,t,n,s=0.5){let{points:r}=this,i=s===0.5?s:(s-0.5)*Xo(r)+0.5,o=n*i,a=n-o,l=o*o,u=a*a,c=r.length-(this.closePath?0:2);for(let h=0;hs?l:s,r=ui?u:i}return e.x=n,e.width=s-n,e.y=r,e.height=i-r,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return X("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return X("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}var WT,XT;var jg=w(()=>{Re();uu();Lg();et()});class Ho{constructor(e=0,t=0,n=0,s=0,r=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=n,this.height=s,this.radius=r}getBounds(e){return e||(e=new Q),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new Ho(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width){if(t>=this.y&&t<=this.y+this.height){let n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+n&&t<=this.y+this.height-n||e>=this.x+n&&e<=this.x+this.width-n)return!0;let s=e-(this.x+n),r=t-(this.y+n),i=n*n;if(s*s+r*r<=i)return!0;if(s=e-(this.x+this.width-n),s*s+r*r<=i)return!0;if(r=t-(this.y+this.height-n),s*s+r*r<=i)return!0;if(s=e-(this.x+n),s*s+r*r<=i)return!0}}return!1}strokeContains(e,t,n,s=0.5){let{x:r,y:i,width:o,height:a,radius:l}=this,u=n*(1-s),c=n-u,h=r+l,d=i+l,f=o-l*2,m=a-l*2,p=r+o,y=i+a;if((e>=r-u&&e<=r+c||e>=p-c&&e<=p+u)&&t>=d&&t<=d+m)return!0;if((t>=i-u&&t<=i+c||t>=y-c&&t<=y+u)&&e>=h&&e<=h+f)return!0;return ep-l&&tp-l&&t>y-l&&Vo(e,t,p-l,y-l,l,c,u)||ey-l&&Vo(e,t,h,y-l,l,c,u)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}var Vo=(e,t,n,s,r,i,o)=>{let a=e-n,l=t-s,u=Math.sqrt(a*a+l*l);return u>=r-i&&u<=r+o};var Yg=w(()=>{et()});function zo(e,t){t.clear();let n=t.matrix;for(let s=0;s{me();Vg=new U});function Hg(e,t,n,s,r=!1,i){let o=jT;o.minX=0,o.minY=0,o.maxX=e.width/s|0,o.maxY=e.height/s|0;let a=Ue.getOptimalTexture({width:o.width,height:o.height,resolution:s,autoGenerateMipmaps:r,scaleMode:i});return a.source.uploadMethodId="image",a.source.resource=e,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=t/s,a.frame.height=n/s,a.source.emit("update",a.source),a.updateUvs(),a}var jT;var zg=w(()=>{es();ft();jT=new fe});function qg(e){return typeof e.getCanvasFilterString==="function"}class Kg{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new fe,this.cssFilterString=""}}class qo{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let t=this._pushFilterFrame(),n=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=n,t.container=e.container,t.cssFilterString="",n.every((a)=>!a.enabled)){t.skip=!0;return}let s=[],r=1;for(let a of n){if(!a.enabled)continue;if(!qg(a)){this._warnUnsupportedFilter(a);continue}let l=a.getCanvasFilterString();if(l===null){this._warnUnsupportedFilter(a);continue}if(l)s.push(l)}if(s.length===0&&r===1){t.skip=!0;return}t.cssFilterString=s.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let i=this.renderer.canvasContext.activeContext,o=i.filter||"none";if(this._savedStates.push({filter:o,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){let a=this.renderer.canvasContext.activeResolution||1;i.save(),i.setTransform(1,0,0,1,0,0),i.beginPath(),i.rect(t.bounds.x*a,t.bounds.y*a,t.bounds.width*a,t.bounds.height*a),i.clip()}else t.useClip=!1;if(r!==1)this._alphaMultiplier*=r;if(t.cssFilterString)i.filter=o!=="none"?`${o} ${t.cssFilterString}`:t.cssFilterString}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let n=this.renderer.canvasContext.activeContext;if(e.useClip)n.restore();else n.filter=t.filter;this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every((y)=>!y.enabled))return e;let n=[],s=1;for(let y of t){if(!y.enabled)continue;if(!qg(y)){this._warnUnsupportedFilter(y);continue}let g=y.getCanvasFilterString();if(g===null){this._warnUnsupportedFilter(y);continue}if(g)n.push(g)}if(n.length===0&&s===1)return e;let r=Ae.getCanvasSource(e);if(!r)return e;let i=e.frame,o=e.source._resolution??e.source.resolution??1,{width:a,height:l}=i,u=Ws.getOptimalCanvasAndContext(a,l,o),{canvas:c,context:h}=u;if(h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,c.width,c.height),n.length)h.filter=n.join(" ");if(s!==1)h.globalAlpha=s;let d=i.x*o,f=i.y*o,m=a*o,p=l*o;return h.drawImage(r,d,f,m,p,0,0,m,p),h.filter="none",h.globalAlpha=1,Hg(c,a,l,o)}_calculateFilterArea(e,t){if(e.renderables)zo(e.renderables,t);else if(e.filterEffect.filterArea)t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform);else e.container.getFastGlobalBounds(!0,t);if(e.container){let s=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;if(s)t.applyMatrix(s)}}_warnUnsupportedFilter(e){let t=e?.constructor?.name||"Filter";if(this._warnedFilterTypes.has(t))return;this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`)}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];if(!e)e=this._filterStack[this._filterStackIndex]=new Kg;return this._filterStackIndex++,e}_popFilterFrame(){if(this._filterStackIndex<=0)return this._filterStack[0];return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}var Jg=w(()=>{W();Dg();cu();ft();du();zg();qo.extension={type:[E.CanvasSystem],name:"filter"}});class Ko{constructor(e){this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){if(e.action==="pushFilter")this._renderer.filter.push(e);else if(e.action==="popFilter")this._renderer.filter.pop()}destroy(){this._renderer=null}}var Zg=w(()=>{W();Ko.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"filter"}});function An(e,t){let n=Qg[e];if(n===void 0){if(fu[t]===void 0)fu[t]=1;Qg[e]=n=fu[t]++}return n}var fu,Qg;var zr=w(()=>{fu=Object.create(null),Qg=Object.create(null)});function Zo(){if(!Jo||Jo?.isContextLost())Jo=ne.get().createCanvas().getContext("webgl",{});return Jo}var Jo;var mu=w(()=>{nt()});function ey(){if(!Qo){Qo="mediump";let e=Zo();if(e){if(e.getShaderPrecisionFormat)Qo=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision?"highp":"mediump"}}return Qo}var Qo;var ty=w(()=>{mu()});function ny(e,t,n){if(t)return e;if(n)return e=e.replace("out vec4 finalColor;",""),` + `;if(s.style.width=`${sg}px`,s.style.height=`${sg}px`,s.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",s.style.position="absolute",s.style.zIndex=rg.toString(),s.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome"))s.setAttribute("aria-live","off");else s.setAttribute("aria-live","polite");if(navigator.userAgent.match(/rv:.*Gecko\//))s.setAttribute("aria-relevant","additions");else s.setAttribute("aria-relevant","text");s.addEventListener("click",this._onClick.bind(this)),s.addEventListener("focus",this._onFocus.bind(this)),s.addEventListener("focusout",this._onFocusOut.bind(this))}if(s.style.pointerEvents=t.accessiblePointerEvents,s.type=t.accessibleType,t.accessibleText)s.innerText=t.accessibleText;if(t.accessibleTitle&&t.accessibleTitle!==null)s.title=t.accessibleTitle;else if(!t.accessibleHint||t.accessibleHint===null)s.title=`container ${t.tabIndex}`;if(t.accessibleHint&&t.accessibleHint!==null)s.setAttribute("aria-label",t.accessibleHint);if(t.interactive)s.tabIndex=t.tabIndex;else s.tabIndex=0;if(this.debug)this._updateDebugHTML(s);t._accessibleActive=!0,t._accessibleDiv=s,s.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,n){let{container:s}=t.target,r=this._renderer.events.rootBoundary,i=Object.assign(new $n(r),{target:s});r.rootTarget=this._renderer.lastObjectRendered,n.forEach((o)=>r.dispatchEvent(i,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){if(!t.target.getAttribute("aria-live"))t.target.setAttribute("aria-live","assertive");this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){if(!t.target.getAttribute("aria-live"))t.target.setAttribute("aria-live","polite");this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){if(t.keyCode!==HT||!this._activateOnTab)return;this._activate()}_onMouseMove(t){if(t.movementX===0&&t.movementY===0)return;this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){if(t)this._activate();else this._deactivate()}_getPool(t){if(!this._pools[t])this._pools[t]=[];return this._pools[t]}},og;var ag=M(()=>{qc();$o();z();ng();$c();Qc.extension={type:[D.WebGLSystem,D.WebGPUSystem],name:"accessibility"};Qc.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};og=Qc});var lg;var cg=M(()=>{lg={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}});var ug=M(()=>{z();un();ag();cg();ne.add(og);ne.mixin(Ge,lg)});class Io{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new Qr({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){if(!this._attachedDomElements.includes(e))this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){let e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t{z();qc();Io.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"dom"}});var ds;var Bo=M(()=>{yt();un();ds=class ds extends Ge{constructor(e){super(e);this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new Me(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){if(!this._boundsDirty)return this._bounds;return this.updateBounds(),this._boundsDirty=!1,this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){let t=this.bounds,{x:n,y:s}=e;return n>=t.minX&&n<=t.maxX&&s>=t.minY&&s<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;if(e)e.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,n){let{renderPipes:s}=t;s.blendMode.pushBlendMode(this,this.groupBlendMode,e);let i=s[this.renderPipeId];if(i?.addRenderable)i.addRenderable(this,e);this.didViewUpdate=!1;let o=this.children,a=o.length;for(let l=0;l{z();hg();ne.add(Io)});class fg{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){if(this._tickerAdded||!this.domElement)return;rt.system.add(this._tickerUpdate,this,Rn.INTERACTION),this._tickerAdded=!0}removeTickerListener(){if(!this._tickerAdded)return;rt.system.remove(this._tickerUpdate,this),this._tickerAdded=!1}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}let e=this.events._rootPointerEvent;if(this.events.supportsTouchEvents&&e.pointerType==="touch")return;globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){if(this._deltaTime+=e.deltaTime,this._deltaTime{Ro();zs();Jt=new fg});var On;var Fo=M(()=>{Kt();$o();On=class On extends $n{constructor(){super(...arguments);this.client=new ue,this.movement=new ue,this.offset=new ue,this.global=new ue,this.screen=new ue}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,n){return e.worldTransform.applyInverse(n||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,n,s,r,i,o,a,l,u,c,h,d,f,m){throw Error("Method not implemented.")}}});var ht;var tu=M(()=>{Fo();ht=class ht extends On{constructor(){super(...arguments);this.width=0,this.height=0,this.isPrimary=!1,this.persistentDeviceId=0}getCoalescedEvents(){if(this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove")return[this];return[]}getPredictedEvents(){throw Error("getPredictedEvents is not supported!")}}});var _n;var nu=M(()=>{Fo();_n=class _n extends On{constructor(){super(...arguments);this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};_n.DOM_DELTA_PIXEL=0;_n.DOM_DELTA_LINE=1;_n.DOM_DELTA_PAGE=2});class su{constructor(e){this.dispatch=new ke,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mapContextMenu=this.mapContextMenu.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),this.addEventMapping("contextmenu",this.mapContextMenu)}addEventMapping(e,t){if(!this.mappingTable[e])this.mappingTable[e]=[];this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((n,s)=>n.priority-s.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;let t=this.mappingTable[e.type];if(t)for(let n=0,s=t.length;n=0;s--)if(e.currentTarget=n[s],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}all(e,t,n=this._allInteractiveElements){if(n.length===0)return;e.eventPhase=e.BUBBLING_PHASE;let s=Array.isArray(t)?t:[t];for(let r=n.length-1;r>=0;r--)s.forEach((i)=>{e.currentTarget=n[r],this.notifyTarget(e,i)})}propagationPath(e){let t=[e];for(let n=0;n=0;c--){let h=u[c],d=this.hitTestMoveRecursive(h,this._isInteractive(t)?t:h.eventMode,n,s,r,i||r(e,n));if(d){if(d.length>0&&!d[d.length-1].parent)continue;let f=e.isInteractive();if(d.length>0||f){if(f)this._allInteractiveElements.push(e);d.push(e)}if(this._hitElements.length===0)this._hitElements=d;o=!0}}}let a=this._isInteractive(t),l=e.isInteractive();if(l&&l)this._allInteractiveElements.push(e);if(i||this._hitElements.length>0)return null;if(o)return this._hitElements;if(a&&(!r(e,n)&&s(e,n)))return l?[e]:[];return null}hitTestRecursive(e,t,n,s,r){if(this._interactivePrune(e)||r(e,n))return null;if(e.eventMode==="dynamic"||t==="dynamic")Jt.pauseUpdate=!1;if(e.interactiveChildren&&e.children){let a=e.children,l=n;for(let u=a.length-1;u>=0;u--){let c=a[u],h=this.hitTestRecursive(c,this._isInteractive(t)?t:c.eventMode,l,s,r);if(h){if(h.length>0&&!h[h.length-1].parent)continue;let d=e.isInteractive();if(h.length>0||d)h.push(e);return h}}}let i=this._isInteractive(t),o=e.isInteractive();if(i&&s(e,n))return o?[e]:[];return null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){if(!e||!e.visible||!e.renderable||!e.measurable)return!0;if(e.eventMode==="none")return!0;if(e.eventMode==="passive"&&!e.interactiveChildren)return!0;return!1}hitPruneFn(e,t){if(e.hitArea){if(e.worldTransform.applyInverse(t,ti),!e.hitArea.contains(ti.x,ti.y))return!0}if(e.effects&&e.effects.length)for(let n=0;n0&&r!==t.target){let a=e.type==="mousemove"?"mouseout":"pointerout",l=this.createPointerEvent(e,a,r);if(this.dispatchEvent(l,"pointerout"),n)this.dispatchEvent(l,"mouseout");if(!t.composedPath().includes(r)){let u=this.createPointerEvent(e,"pointerleave",r);u.eventPhase=u.AT_TARGET;while(u.target&&!t.composedPath().includes(u.target)){if(u.currentTarget=u.target,this.notifyTarget(u),n)this.notifyTarget(u,"mouseleave");u.target=u.target.parent}this.freeEvent(u)}this.freeEvent(l)}if(r!==t.target){let a=e.type==="mousemove"?"mouseover":"pointerover",l=this.clonePointerEvent(t,a);if(this.dispatchEvent(l,"pointerover"),n)this.dispatchEvent(l,"mouseover");let u=r?.parent;while(u&&u!==this.rootTarget.parent){if(u===t.target)break;u=u.parent}if(!u||u===this.rootTarget.parent){let h=this.clonePointerEvent(t,"pointerenter");h.eventPhase=h.AT_TARGET;while(h.target&&h.target!==r&&h.target!==this.rootTarget.parent){if(h.currentTarget=h.target,this.notifyTarget(h),n)this.notifyTarget(h,"mouseenter");h.target=h.target.parent}this.freeEvent(h)}this.freeEvent(l)}let i=[],o=this.enableGlobalMoveEvents??!0;if(this.moveOnAll?i.push("pointermove"):this.dispatchEvent(t,"pointermove"),o&&i.push("globalpointermove"),t.pointerType==="touch")this.moveOnAll?i.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),o&&i.push("globaltouchmove");if(n)this.moveOnAll?i.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),o&&i.push("globalmousemove"),this.cursor=t.target?.cursor;if(i.length>0)this.all(t,i);this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof ht)){te("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId),n=this.createPointerEvent(e),s=n.pointerType==="mouse"||n.pointerType==="pen";if(this.dispatchEvent(n,"pointerover"),s)this.dispatchEvent(n,"mouseover");if(n.pointerType==="mouse")this.cursor=n.target?.cursor;let r=this.clonePointerEvent(n,"pointerenter");r.eventPhase=r.AT_TARGET;while(r.target&&r.target!==this.rootTarget.parent){if(r.currentTarget=r.target,this.notifyTarget(r),s)this.notifyTarget(r,"mouseenter");r.target=r.target.parent}t.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(r)}mapPointerOut(e){if(!(e instanceof ht)){te("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId);if(t.overTargets){let n=e.pointerType==="mouse"||e.pointerType==="pen",s=this.findMountedTarget(t.overTargets),r=this.createPointerEvent(e,"pointerout",s);if(this.dispatchEvent(r),n)this.dispatchEvent(r,"mouseout");let i=this.createPointerEvent(e,"pointerleave",s);i.eventPhase=i.AT_TARGET;while(i.target&&i.target!==this.rootTarget.parent){if(i.currentTarget=i.target,this.notifyTarget(i),n)this.notifyTarget(i,"mouseleave");i.target=i.target.parent}t.overTargets=null,this.freeEvent(r),this.freeEvent(i)}this.cursor=null}mapPointerUp(e){if(!(e instanceof ht)){te("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=performance.now(),n=this.createPointerEvent(e);if(this.dispatchEvent(n,"pointerup"),n.pointerType==="touch")this.dispatchEvent(n,"touchend");else if(n.pointerType==="mouse"||n.pointerType==="pen"){let o=n.button===2;this.dispatchEvent(n,o?"rightup":"mouseup")}let s=this.trackingData(e.pointerId),r=this.findMountedTarget(s.pressTargetsByButton[e.button]),i=r;if(r&&!n.composedPath().includes(r)){let o=r;while(o&&!n.composedPath().includes(o)){if(n.currentTarget=o,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch")this.notifyTarget(n,"touchendoutside");else if(n.pointerType==="mouse"||n.pointerType==="pen"){let a=n.button===2;this.notifyTarget(n,a?"rightupoutside":"mouseupoutside")}o=o.parent}delete s.pressTargetsByButton[e.button],i=o}if(i){let o=this.clonePointerEvent(n,"click");if(o.target=i,o.path=null,!s.clicksByButton[e.button])s.clicksByButton[e.button]={clickCount:0,target:o.target,timeStamp:t};let a=s.clicksByButton[e.button];if(a.target===o.target&&t-a.timeStamp<200)++a.clickCount;else a.clickCount=1;if(a.target=o.target,a.timeStamp=t,o.detail=a.clickCount,o.pointerType==="mouse"){let l=o.button===2;this.dispatchEvent(o,l?"rightclick":"click")}else if(o.pointerType==="touch")this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(n)}mapPointerUpOutside(e){if(!(e instanceof ht)){te("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.trackingData(e.pointerId),n=this.findMountedTarget(t.pressTargetsByButton[e.button]),s=this.createPointerEvent(e);if(n){let r=n;while(r){if(s.currentTarget=r,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen")this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside");r=r.parent}delete t.pressTargetsByButton[e.button]}this.freeEvent(s)}mapWheel(e){if(!(e instanceof _n)){te("EventBoundary cannot map a non-wheel event as a wheel event");return}let t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}mapContextMenu(e){if(!(e instanceof ht)){te("EventBoundary cannot map a non-pointer event as a pointer event");return}let t=this.createPointerEvent(e);this.dispatchEvent(t,"contextmenu"),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let n=1;n{Qe();Kt();Be();eu();Fo();tu();nu();eC=new ue,ti=new ue});var tC=1,nC,ru=class e{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new su(null),Jt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new ht(null),this._rootWheelEvent=new _n(null),this._rootContextMenuEvent=new ht(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...e.defaultEventFeatures},{set:(n,s,r)=>{if(s==="globalMove")this.rootBoundary.enableGlobalMoveEvents=r;return n[s]=r,!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._onContextMenu=this._onContextMenu.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){let{canvas:n,resolution:s}=this.renderer;this.setTargetElement(n),this.resolution=s,e._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){Jt.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let n=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas)n=!1;if(this._currentCursor===t)return;this._currentCursor=t;let s=this.cursorStyles[t];if(s)switch(typeof s){case"string":if(n)this.domElement.style.cursor=s;break;case"function":s(t);break;case"object":if(n)Object.assign(this.domElement.style,s);break}else if(n&&typeof t==="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t))this.domElement.style.cursor=t}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let n=this._normalizeToPointerData(t);if(this.autoPreventDefault&&n[0].isNormalized){if(t.cancelable||!("cancelable"in t))t.preventDefault()}for(let s=0,r=n.length;s0)n=t.composedPath()[0];let s=n!==this.domElement?"outside":"",r=this._normalizeToPointerData(t);for(let i=0,o=r.length;i"u")i.button=0;if(typeof i.buttons>"u")i.buttons=1;if(typeof i.isPrimary>"u")i.isPrimary=t.touches.length===1&&t.type==="touchstart";if(typeof i.width>"u")i.width=i.radiusX||1;if(typeof i.height>"u")i.height=i.radiusY||1;if(typeof i.tiltX>"u")i.tiltX=0;if(typeof i.tiltY>"u")i.tiltY=0;if(typeof i.pointerType>"u")i.pointerType="touch";if(typeof i.pointerId>"u")i.pointerId=i.identifier||0;if(typeof i.pressure>"u")i.pressure=i.force||0.5;if(typeof i.twist>"u")i.twist=0;if(typeof i.tangentialPressure>"u")i.tangentialPressure=0;if(typeof i.layerX>"u")i.layerX=i.offsetX=i.clientX;if(typeof i.layerY>"u")i.layerY=i.offsetY=i.clientY;i.isNormalized=!0,i.type=t.type,i.altKey??(i.altKey=t.altKey),i.ctrlKey??(i.ctrlKey=t.ctrlKey),i.metaKey??(i.metaKey=t.metaKey),i.shiftKey??(i.shiftKey=t.shiftKey),n.push(i)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){let s=t;if(typeof s.isPrimary>"u")s.isPrimary=!0;if(typeof s.width>"u")s.width=1;if(typeof s.height>"u")s.height=1;if(typeof s.tiltX>"u")s.tiltX=0;if(typeof s.tiltY>"u")s.tiltY=0;if(typeof s.pointerType>"u")s.pointerType="mouse";if(typeof s.pointerId>"u")s.pointerId=tC;if(typeof s.pressure>"u")s.pressure=0.5;if(typeof s.twist>"u")s.twist=0;if(typeof s.tangentialPressure>"u")s.tangentialPressure=0;s.isNormalized=!0,n.push(s)}else n.push(t);return n}normalizeWheelEvent(t){let n=this._rootWheelEvent;return this._transferMouseData(n,t),n.deltaX=t.deltaX,n.deltaY=t.deltaY,n.deltaZ=t.deltaZ,n.deltaMode=t.deltaMode,this.mapPositionToPoint(n.screen,t.clientX,t.clientY),n.global.copyFrom(n.screen),n.offset.copyFrom(n.screen),n.nativeEvent=t,n.type=t.type,n}_bootstrapEvent(t,n){if(t.originalEvent=null,t.nativeEvent=n,t.pointerId=n.pointerId,t.width=n.width,t.height=n.height,t.isPrimary=n.isPrimary,t.pointerType=n.pointerType,t.pressure=n.pressure,t.tangentialPressure=n.tangentialPressure,t.tiltX=n.tiltX,t.tiltY=n.tiltY,t.twist=n.twist,this._transferMouseData(t,n),this.mapPositionToPoint(t.screen,n.clientX,n.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=n.isTrusted,t.type==="pointerleave")t.type="pointerout";if(t.type.startsWith("mouse"))t.type=t.type.replace("mouse","pointer");if(t.type.startsWith("touch"))t.type=nC[t.type]||t.type;return t}_transferMouseData(t,n){t.isTrusted=n.isTrusted,t.srcElement=n.srcElement,t.timeStamp=performance.now(),t.type=n.type,t.altKey=n.altKey,t.button=n.button,t.buttons=n.buttons,t.client.x=n.clientX,t.client.y=n.clientY,t.ctrlKey=n.ctrlKey,t.metaKey=n.metaKey,t.movement.x=n.movementX,t.movement.y=n.movementY,t.page.x=n.pageX,t.page.y=n.pageY,t.relatedTarget=null,t.shiftKey=n.shiftKey}},Do;var iu=M(()=>{z();mg();eu();tu();nu();nC={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};ru.extension={name:"events",type:[D.WebGLSystem,D.CanvasSystem,D.WebGPUSystem],priority:-1};ru.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};Do=ru});var pg;var gg=M(()=>{iu();$o();pg={onclick:null,oncontextmenu:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(e){this.eventMode=e?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Do.defaultEventMode},set eventMode(e){this._internalEventMode=e},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(e,t,n){let s=typeof n==="boolean"&&n||typeof n==="object"&&n.capture,r=typeof n==="object"?n.signal:void 0,i=typeof n==="object"?n.once===!0:!1,o=typeof t==="function"?void 0:t;e=s?`${e}capture`:e;let a=typeof t==="function"?t:t.handleEvent,l=this;if(r)r.addEventListener("abort",()=>{l.off(e,a,o)});if(i)l.once(e,a,o);else l.on(e,a,o)},removeEventListener(e,t,n){let s=typeof n==="boolean"&&n||typeof n==="object"&&n.capture,r=typeof t==="function"?void 0:t;e=s?`${e}capture`:e,t=typeof t==="function"?t:t.handleEvent,this.off(e,t,r)},dispatchEvent(e){if(!(e instanceof $n))throw Error("Container cannot propagate events outside of the Federated Events API");return e.defaultPrevented=!1,e.path=null,e.target=this,e.manager.dispatchEvent(e),!e.defaultPrevented}}});var yg=M(()=>{z();un();iu();gg();ne.add(Do);ne.mixin(Ge,pg)});var ou;var xg=M(()=>{ou=((e)=>(e[e.Low=0]="Low",e[e.Normal=1]="Normal",e[e.High=2]="High",e))(ou||{})});var bg;var vg=M(()=>{bg={createCanvas:(e,t)=>{let n=document.createElement("canvas");return n.width=e,n.height=t,n},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(e,t)=>fetch(e,t),parseXML:(e)=>new DOMParser().parseFromString(e,"text/xml")}});var _g,le;var it=M(()=>{vg();_g=bg,le={get(){return _g},set(e){_g=e}}});function Zt(e){if(typeof e!=="string")throw TypeError(`Path must be a string. Received ${JSON.stringify(e)}`)}function ni(e){return e.split("?")[0].split("#")[0]}function sC(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rC(e,t,n){return e.replace(new RegExp(sC(t),"g"),n)}function iC(e,t){let n="",s=0,r=-1,i=0,o=-1;for(let a=0;a<=e.length;++a){if(a2){let l=n.lastIndexOf("/");if(l!==n.length-1){if(l===-1)n="",s=0;else n=n.slice(0,l),s=n.length-1-n.lastIndexOf("/");r=a,i=0;continue}}else if(n.length===2||n.length===1){n="",s=0,r=a,i=0;continue}}if(t){if(n.length>0)n+="/..";else n="..";s=2}}else{if(n.length>0)n+=`/${e.slice(r+1,a)}`;else n=e.slice(r+1,a);s=a-r-1}r=a,i=0}else if(o===46&&i!==-1)++i;else i=-1}return n}var fs;var au=M(()=>{it();fs={toPosix(e){return rC(e,"\\","/")},isUrl(e){return/^https?:/.test(this.toPosix(e))},isDataUrl(e){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(e)},isBlobUrl(e){return e.startsWith("blob:")},hasProtocol(e){return/^[^/:]+:/.test(this.toPosix(e))},getProtocol(e){Zt(e),e=this.toPosix(e);let t=/^file:\/\/\//.exec(e);if(t)return t[0];let n=/^[^/:]+:\/{0,2}/.exec(e);if(n)return n[0];return""},toAbsolute(e,t,n){if(Zt(e),this.isDataUrl(e)||this.isBlobUrl(e))return e;let s=ni(this.toPosix(t??le.get().getBaseUrl())),r=ni(this.toPosix(n??this.rootname(s)));if(e=this.toPosix(e),e.startsWith("/"))return fs.join(r,e.slice(1));return this.isAbsolute(e)?e:this.join(s,e)},normalize(e){if(Zt(e),e.length===0)return".";if(this.isDataUrl(e)||this.isBlobUrl(e))return e;e=this.toPosix(e);let t="",n=e.startsWith("/");if(this.hasProtocol(e))t=this.rootname(e),e=e.slice(t.length);let s=e.endsWith("/");if(e=iC(e,!1),e.length>0&&s)e+="/";if(n)return`/${e}`;return t+e},isAbsolute(e){if(Zt(e),e=this.toPosix(e),this.hasProtocol(e))return!0;return e.startsWith("/")},join(...e){if(e.length===0)return".";let t;for(let n=0;n0)if(t===void 0)t=s;else{let r=e[n-1]??"";if(this.joinExtensions.includes(this.extname(r).toLowerCase()))t+=`/../${s}`;else t+=`/${s}`}}if(t===void 0)return".";return this.normalize(t)},dirname(e){if(Zt(e),e.length===0)return".";e=this.toPosix(e);let t=e.charCodeAt(0),n=t===47,s=-1,r=!0,i=this.getProtocol(e),o=e;e=e.slice(i.length);for(let a=e.length-1;a>=1;--a)if(t=e.charCodeAt(a),t===47){if(!r){s=a;break}}else r=!1;if(s===-1)return n?"/":this.isUrl(o)?i+e:i;if(n&&s===1)return"//";return i+e.slice(0,s)},rootname(e){Zt(e),e=this.toPosix(e);let t="";if(e.startsWith("/"))t="/";else t=this.getProtocol(e);if(this.isUrl(e)){let n=e.indexOf("/",t.length);if(n!==-1)t=e.slice(0,n);else t=e;if(!t.endsWith("/"))t+="/"}return t},basename(e,t){if(Zt(e),t)Zt(t);e=ni(this.toPosix(e));let n=0,s=-1,r=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let o=t.length-1,a=-1;for(i=e.length-1;i>=0;--i){let l=e.charCodeAt(i);if(l===47){if(!r){n=i+1;break}}else{if(a===-1)r=!1,a=i+1;if(o>=0)if(l===t.charCodeAt(o)){if(--o===-1)s=i}else o=-1,s=a}}if(n===s)s=a;else if(s===-1)s=e.length;return e.slice(n,s)}for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!r){n=i+1;break}}else if(s===-1)r=!1,s=i+1;if(s===-1)return"";return e.slice(n,s)},extname(e){Zt(e),e=ni(this.toPosix(e));let t=-1,n=0,s=-1,r=!0,i=0;for(let o=e.length-1;o>=0;--o){let a=e.charCodeAt(o);if(a===47){if(!r){n=o+1;break}continue}if(s===-1)r=!1,s=o+1;if(a===46){if(t===-1)t=o;else if(i!==1)i=1}else if(t!==-1)i=-1}if(t===-1||s===-1||i===0||i===1&&t===s-1&&t===n+1)return"";return e.slice(t,s)},parse(e){Zt(e);let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;e=ni(this.toPosix(e));let n=e.charCodeAt(0),s=this.isAbsolute(e),r,i="";if(t.root=this.rootname(e),s||this.hasProtocol(e))r=1;else r=0;let o=-1,a=0,l=-1,u=!0,c=e.length-1,h=0;for(;c>=r;--c){if(n=e.charCodeAt(c),n===47){if(!u){a=c+1;break}continue}if(l===-1)u=!1,l=c+1;if(n===46){if(o===-1)o=c;else if(h!==1)h=1}else if(o!==-1)h=-1}if(o===-1||l===-1||h===0||h===1&&o===l-1&&o===a+1){if(l!==-1)if(a===0&&s)t.base=t.name=e.slice(1,l);else t.base=t.name=e.slice(a,l)}else{if(a===0&&s)t.name=e.slice(1,o),t.base=e.slice(1,l);else t.name=e.slice(a,o),t.base=e.slice(a,l);t.ext=e.slice(o,l)}if(t.dir=this.dirname(e),i)t.dir=i+t.dir;return t},sep:"/",delimiter:":",joinExtensions:[".html"]}});var In=(e,t,n=!1)=>{if(!Array.isArray(e))e=[e];if(!t)return e;return e.map((s)=>{if(typeof s==="string"||n)return t(s);return s})};var lu=()=>{};function Sg(e,t,n,s,r){let i=t[n];for(let o=0;o{let o=i.substring(1,i.length-1).split(",");r.push(o)}),Sg(e,r,0,n,s)}else s.push(e);return s}var kg=()=>{};var cu=(e)=>!Array.isArray(e);var Mg=()=>{};class No{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach((t)=>{if(this._preferredOrder.push(t),!t.priority)t.priority=Object.keys(t.params)}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e==="string")this._defaultSearchParams=e;else{let t=e;this._defaultSearchParams=Object.keys(t).map((n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t[n])}`).join("&")}}getAlias(e){let{alias:t,src:n}=e;return In(t||n,(r)=>{if(typeof r==="string")return r;if(Array.isArray(r))return r.map((i)=>i?.src??i);if(r?.src)return r.src;return r},!0)}removeAlias(e,t){if(!this._assetMap[e])return;if(t&&t!==this._resolverHash[e])return;delete this._resolverHash[e],delete this._assetMap[e]}addManifest(e){if(this._manifest)te("[Resolver] Manifest already exists, this will be overwritten");this._manifest=e,e.bundles.forEach((t)=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){let n=[],s=t;if(!Array.isArray(t))s=Object.entries(t).map(([r,i])=>{if(typeof i==="string"||Array.isArray(i))return{alias:r,src:i};return{alias:r,...i}});s.forEach((r)=>{let{src:i,alias:o}=r,a;if(typeof o==="string"){let l=this._createBundleAssetId(e,o);n.push(l),a=[o,l]}else{let l=o.map((u)=>this._createBundleAssetId(e,u));n.push(...l),a=[...o,...l]}this.add({...r,...{alias:a,src:i}})}),this._bundles[e]=n}add(e){let t=[];if(Array.isArray(e))t.push(...e);else t.push(e);let n;n=(r)=>{if(this.hasKey(r))te(`[Resolver] already has key: ${r} overwriting`)},In(t).forEach((r)=>{let{src:i}=r,{data:o,format:a,loadParser:l,parser:u}=r,c=In(i).map((m)=>{if(typeof m==="string")return wg(m);return Array.isArray(m)?m:[m]}),h=this.getAlias(r);Array.isArray(h)?h.forEach(n):n(h);let d=[],f=(m)=>{let p=this._parsers.find((y)=>y.test(m));return{src:m,...p?.parse(m)}};c.forEach((m)=>{m.forEach((p)=>{let y={};if(typeof p!=="object")y=f(p);else{if(o=p.data??o,a=p.format??a,p.loadParser||p.parser)l=p.loadParser??l,u=p.parser??u;y={...f(p.src),...p}}if(!h)throw Error(`[Resolver] alias is undefined for this asset: ${y.src}`);y=this._buildResolvedAsset(y,{aliases:h,data:o,format:a,loadParser:l,parser:u,progressSize:r.progressSize}),d.push(y)})}),h.forEach((m)=>{this._assetMap[m]=d})})}resolveBundle(e){let t=cu(e);e=In(e);let n={};return e.forEach((s)=>{let r=this._bundles[s];if(r){let i=this.resolve(r),o={};for(let a in i){let l=i[a];o[this._extractAssetIdFromBundle(s,a)]=l}n[s]=o}}),t?n[e[0]]:n}resolveUrl(e){let t=this.resolve(e);if(typeof e!=="string"){let n={};for(let s in t)n[s]=t[s].src;return n}return t.src}resolve(e){let t=cu(e);e=In(e);let n={};return e.forEach((s)=>{if(!this._resolverHash[s])if(this._assetMap[s]){let r=this._assetMap[s],i=this._getPreferredOrder(r);i?.priority.forEach((o)=>{i.params[o].forEach((a)=>{let l=r.filter((u)=>{if(u[o])return u[o]===a;return!1});if(l.length)r=l})}),this._resolverHash[s]=r[0]}else this._resolverHash[s]=this._buildResolvedAsset({alias:[s],src:s},{});n[s]=this._resolverHash[s]}),t?n[e[0]]:n}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;tr.params.format.includes(n.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;let t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){let{aliases:n,data:s,loadParser:r,parser:i,format:o,progressSize:a}=t;if(this._basePath||this._rootPath)e.src=fs.toAbsolute(e.src,this._basePath,this._rootPath);if(e.alias=n??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...s||{},...e.data},e.loadParser=r??e.loadParser,e.parser=i??e.parser,e.format=o??e.format??oC(e.src),a!==void 0)e.progressSize=a;return e}}function oC(e){return e.split(".").pop().split("?").shift().split("#").shift()}var Tg=M(()=>{Be();au();lu();kg();Mg();No.RETINA_PREFIX=/@([0-9\.]+)x/});var uu=(e,t)=>{let n=t.split("?")[1];if(n)e+=`?${n}`;return e};var Cg=()=>{};var Ag=class e{constructor(t,n){this.linkedSheets=[];let s=t;if(t?.source instanceof ve)s={texture:t,data:n};let{texture:r,data:i,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=r instanceof K?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=i;let a=parseFloat(i.meta.scale);if(a)this.resolution=a,r.source.resolution=this.resolution;else this.resolution=r.source._resolution;this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise((t)=>{if(this._callback=t,this._batchIndex=0,this._frameKeys.length<=e.BATCH_SIZE)this._processFrames(0),this._processAnimations(),this._parseComplete();else this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,n=!1){let s=t,r=n?1/0:e.BATCH_SIZE;while(s-t{if(this._batchIndex*e.BATCH_SIZE{st();St();Ne();Ag.BATCH_SIZE=1000;hu=Ag});function Pg(e,t,n){let s={};if(e.forEach((r)=>{s[r]=t}),Object.keys(t.textures).forEach((r)=>{s[`${t.cachePrefix}${r}`]=t.textures[r]}),!n){let r=fs.dirname(e[0]);t.linkedSheets.forEach((i,o)=>{let a=Pg([`${r}/${t.data.meta.related_multi_packs[o]}`],i,!0);Object.assign(s,a)})}return s}var aC,Rg;var $g=M(()=>{xg();Tg();Cg();z();Ne();au();Eg();aC=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];Rg={extension:D.Asset,cache:{test:(e)=>e instanceof hu,getCacheableAssets:(e,t)=>Pg(e,t,!1)},resolver:{extension:{type:D.ResolveParser,name:"resolveSpritesheet"},test:(e)=>{let n=e.split("?")[0].split("."),s=n.pop(),r=n.pop();return s==="json"&&aC.includes(r)},parse:(e)=>{let t=e.split(".");return{resolution:parseFloat(No.RETINA_PREFIX.exec(e)?.[1]??"1"),format:t[t.length-2],src:e}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:D.LoadParser,priority:ou.Normal,name:"spritesheetLoader"},async testParse(e,t){return fs.extname(t.src).toLowerCase()===".json"&&!!e.frames},async parse(e,t,n){let{texture:s,imageFilename:r,textureOptions:i,cachePrefix:o}=t?.data??{},a=fs.dirname(t.src);if(a&&a.lastIndexOf("/")!==a.length-1)a+="/";let l;if(s instanceof K)l=s;else{let h=uu(a+(r??e.meta.image),t.src);l=(await n.load([{src:h,data:i}]))[h]}let u=new hu({texture:l.source,data:e,cachePrefix:o});await u.parse();let c=e?.meta?.related_multi_packs;if(Array.isArray(c)){let h=[];for(let f of c){if(typeof f!=="string")continue;let m=a+f;if(t.data?.ignoreMultiPack)continue;m=uu(m,t.src),h.push(n.load({src:m,data:{textureOptions:i,ignoreMultiPack:!0}}))}let d=await Promise.all(h);u.linkedSheets=d,d.forEach((f)=>{f.linkedSheets=[u].concat(u.linkedSheets.filter((m)=>m!==f))})}return u},async unload(e,t,n){await n.unload(e.textureSource._sourceOrigin),e.destroy(!1)}}}});var Go=M(()=>{z();$g();ne.add(Rg)});function Og(e,t,n){let{width:s,height:r}=n.orig,i=n.trim;if(i){let{width:o,height:a}=i;e.minX=i.x-t._x*s,e.maxX=e.minX+o,e.minY=i.y-t._y*r,e.maxY=e.minY+a}else e.minX=-t._x*s,e.maxX=e.minX+s,e.minY=-t._y*r,e.maxY=e.minY+r}var Ig=()=>{};var Qt;var Lo=M(()=>{Ac();Ne();Ig();Ie();Bo();Qt=class Qt extends ds{constructor(e=K.EMPTY){if(e instanceof K)e={texture:e};let{texture:t=K.EMPTY,anchor:n,roundPixels:s,width:r,height:i,...o}=e;super({label:"Sprite",...o});if(this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new tt({_onUpdate:()=>{this.onViewUpdate()}}),n)this.anchor=n;else if(t.defaultAnchor)this.anchor=t.defaultAnchor;if(this.texture=t,this.allowChildren=!1,this.roundPixels=s??!1,r!==void 0)this.width=r;if(i!==void 0)this.height=i}static from(e,t=!1){if(e instanceof K)return new Qt(e);return new Qt(K.from(e,t))}set texture(e){e||(e=K.EMPTY);let t=this._texture;if(t===e)return;if(t&&t.dynamic)t.off("update",this.onViewUpdate,this);if(e.dynamic)e.on("update",this.onViewUpdate,this);if(this._texture=e,this._width)this._setWidth(this._width,this._texture.orig.width);if(this._height)this._setHeight(this._height,this._texture.orig.height);this.onViewUpdate()}get texture(){return this._texture}get visualBounds(){return Og(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return q("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){let e=this._anchor,t=this._texture,n=this._bounds,{width:s,height:r}=t.orig;n.minX=-e._x*s,n.maxX=n.minX+s,n.minY=-e._y*r,n.maxY=n.minY+r}destroy(e=!1){if(super.destroy(e),typeof e==="boolean"?e:e?.texture){let n=typeof e==="boolean"?e:e?.textureSource;this._texture.destroy(n)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e==="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){if(typeof e==="object")t=e.height??e.width,e=e.width;else t??(t=e);e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}});function Uo(e,t,n){let s=lC;e.measurable=!0,Ls(e,n,s),t.addBoundsMask(s),e.measurable=!1}var lC;var du=M(()=>{yt();Yr();lC=new Me});function Wo(e,t,n){let s=At.get();e.measurable=!0;let r=He.get().identity(),i=Bg(e,n,r);Ws(e,s,i),e.measurable=!1,t.addBoundsMask(s),He.return(r),At.return(s)}function Bg(e,t,n){if(!e)return te("Mask bounds, renderable is not inside the root container"),n;if(e!==t)Bg(e.parent,t,n),e.updateLocalTransform(),n.append(e.localTransform);return n}var fu=M(()=>{ko();rs();Be()});class Xo{constructor(e){if(this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e?.mask)this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof Qt),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){if(this.mask===null)return;this.mask.measurable=!0,this.mask=null}addBounds(e,t){if(!this.inverse)Uo(this.mask,e,t)}addLocalBounds(e,t){Wo(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof Qt}}var Fg=M(()=>{z();Lo();du();fu();Xo.extension=D.MaskEffect});class Vo{constructor(e){if(this.priority=0,this.pipe="colorMask",e?.mask)this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e==="number"}}var Dg=M(()=>{z();Vo.extension=D.MaskEffect});class jo{constructor(e){if(this.priority=0,this.pipe="stencilMask",e?.mask)this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){if(this.mask===null)return;this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(e,t){Uo(this.mask,e,t)}addLocalBounds(e,t){Wo(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof Ge}}var Ng=M(()=>{z();un();du();fu();jo.extension=D.MaskEffect});var Et;var si=M(()=>{it();z();St();Et=class Et extends ve{constructor(e){if(!e.resource)e.resource=le.get().createCanvas();if(!e.width){if(e.width=e.resource.width,!e.autoDensity)e.width/=e.resolution}if(!e.height){if(e.height=e.resource.height,!e.autoDensity)e.height/=e.resolution}super(e);this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.transparent}resizeCanvas(){if(this.autoDensity&&"style"in this.resource)this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`;if(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight}resize(e=this.width,t=this.height,n=this._resolution){let s=super.resize(e,t,n);if(s)this.resizeCanvas();return s}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}};Et.extension=D.TextureSource});var hn;var Yo=M(()=>{z();St();hn=class hn extends ve{constructor(e){super(e);this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}};hn.extension=D.TextureSource});async function Gg(){return mu??(mu=(async()=>{let t=le.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";let n=await new Promise((o)=>{let a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!n)return"premultiply-alpha-on-upload";let s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);let r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n);let i=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,i),t.deleteFramebuffer(r),t.deleteTexture(s),t.getExtension("WEBGL_lose_context")?.loseContext(),i[0]<=i[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),mu}var mu;var Lg=M(()=>{it()});var Ho,Ug;var Wg=M(()=>{z();zs();Lg();St();Ho=class e extends ve{constructor(t){super(t);if(this.isReady=!1,this.uploadMethodId="video",t={...e.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1)this.load()}updateFrame(){if(this.destroyed)return;if(this._updateFPS){let t=rt.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}if(!this._updateFPS||this._msToNextUpdate<=0)this._msToNextUpdate=this._updateFPS?Math.floor(1000/this._updateFPS):0;if(this.isValid)this.update()}_videoFrameRequestCallback(){if(this.updateFrame(),this.destroyed)this._videoFrameRequestCallbackHandle=null;else this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;let t=this.resource,n=this.options;if((t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height)t.complete=!0;if(t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),!this._isSourceReady()){if(!n.preload)t.addEventListener("canplay",this._onCanPlay);t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)}else this._mediaReady();if(!this.isValid)t.addEventListener("loadedmetadata",this._onLoadedMetadata);return this.alphaMode=await Gg(),this._load=new Promise((s,r)=>{if(this.isValid)s(this);else{if(this._resolve=s,this._reject=r,n.preloadTimeoutMs!==void 0)this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${n.preloadTimeoutMs}ms`))});t.load()}}),this._load}_onError(t){if(this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject)this._reject(t),this._reject=null,this._resolve=null}_isSourcePlaying(){let t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){if(this._autoUpdate&&!this._isSourcePlaying())this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0}_onLoadedMetadata(){if(!this.isValid)return;this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){if(this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout)clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0;this._mediaReady()}_mediaReady(){let t=this.resource;if(this.isValid)this.isReady=!0,this.resize(t.videoWidth,t.videoHeight);if(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid)this._resolve(this),this._resolve=null,this._reject=null;if(this._isSourcePlaying())this._onPlayStart();else if(this.autoPlay)this.resource.play()}destroy(){this._configureAutoUpdate();let t=this.resource;if(t)t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load();super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){if(t!==this._autoUpdate)this._autoUpdate=t,this._configureAutoUpdate()}get updateFPS(){return this._updateFPS}set updateFPS(t){if(t!==this._updateFPS)this._updateFPS=t,this._configureAutoUpdate()}_configureAutoUpdate(){if(this._autoUpdate&&this._isSourcePlaying())if(!this._updateFPS&&this.resource.requestVideoFrameCallback){if(this._isConnectedToTicker)rt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0;if(this._videoFrameRequestCallbackHandle===null)this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}else{if(this._videoFrameRequestCallbackHandle!==null)this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null;if(!this._isConnectedToTicker)rt.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0}else{if(this._videoFrameRequestCallbackHandle!==null)this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null;if(this._isConnectedToTicker)rt.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0}}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ho.extension=D.TextureSource;Ho.defaultOptions={...ve.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ho.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};Ug=Ho});class Xg{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){let t=this._cache.get(e);if(!t)te(`[Assets] Asset id ${e} was not found in the Cache`);return t}set(e,t){let n=In(e),s;for(let a=0;a{r.set(a,t)});let i=[...r.keys()],o={cacheKeys:i,keys:n};n.forEach((a)=>{this._cacheMap.set(a,o)}),i.forEach((a)=>{let l=s?s[a]:t;if(this._cache.has(a)&&this._cache.get(a)!==l)te("[Cache] already has key:",a);this._cache.set(a,r.get(a))})}remove(e){if(!this._cacheMap.has(e)){te(`[Assets] Asset id ${e} was not found in the Cache`);return}let t=this._cacheMap.get(e);t.cacheKeys.forEach((s)=>{this._cache.delete(s)}),t.keys.forEach((s)=>{this._cacheMap.delete(s)})}get parsers(){return this._parsers}}var ms;var Vg=M(()=>{Be();lu();ms=new Xg});function jg(e={}){let t=e&&e.resource,n=t?e.resource:e,s=t?e:{resource:e};for(let r=0;r{if(ms.has(s))ms.remove(s)}),!t)ms.set(s,i);return i}function Hg(e,t=!1){if(typeof e==="string")return ms.get(e);else if(e instanceof ve)return new K({source:e});return Yg(e,t)}var pu;var gu=M(()=>{Vg();z();St();Ne();pu=[];ne.handleByList(D.TextureSource,pu);K.from=Hg;ve.from=jg});var zo=M(()=>{z();Fg();Dg();Ng();Wc();si();Yo();Wg();gu();ne.add(Xo,Vo,jo,Ug,hn,Et,js)});function zg(e){let t=le.get().createCanvas(6,1),n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,6,1),t}function qg(){if(Ks!==void 0)return Ks;try{let e=zg("#ff00ff"),t=zg("#ffff00"),s=le.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(e,0,0),s.drawImage(t,2,0);let r=s.getImageData(2,0,1,1);if(!r)Ks=!1;else{let i=r.data;Ks=i[0]===255&&i[1]===0&&i[2]===0}}catch(e){Ks=!1}return Ks}var Ks;var Kg=M(()=>{it()});var $e;var Jg=M(()=>{Lt();it();Gc();Kg();$e={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:qg(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:(e)=>{let t=e.source,n=t?.resource;if(!n)return null;let s=t.alphaMode==="premultiplied-alpha",r=t.resourceWidth??t.pixelWidth,i=t.resourceHeight??t.pixelHeight,o=r!==t.pixelWidth||i!==t.pixelHeight;if(s){if(n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas){if(!o)return n}let a=$e._unpremultipliedCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){let a=$e._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;let l=le.get().createCanvas(t.pixelWidth,t.pixelHeight),u=l.getContext("2d"),c=u.createImageData(t.pixelWidth,t.pixelHeight),h=c.data,d=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(t.format==="bgra8unorm")for(let f=0;f0){let f=255/d;c[h]=Math.min(255,c[h]*f+0.5),c[h+1]=Math.min(255,c[h+1]*f+0.5),c[h+2]=Math.min(255,c[h+2]*f+0.5)}}return l.putImageData(u,0,0),$e._unpremultipliedCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(o){let a=$e._canvasSourceCache.get(t);if(a?.resourceId===t._resourceId)return a.canvas;let l=le.get().createCanvas(t.pixelWidth,t.pixelHeight),u=l.getContext("2d");return l.width=t.pixelWidth,l.height=t.pixelHeight,u.drawImage(n,0,0),$e._canvasSourceCache.set(t,{canvas:l,resourceId:t._resourceId}),l}return n},getTintedCanvas:(e,t)=>{let n=e.texture,s=we.shared.setValue(t).toHex(),r=n.tintCache||(n.tintCache={}),i=r[s],o=n.source._resourceId;if(i?.tintId===o)return i;let a=i&&"getContext"in i?i:le.get().createCanvas();if($e.tintMethod(n,t,a),a.tintId=o,$e.convertTintToImage&&a.toDataURL!==void 0){let l=le.get().createImage();l.src=a.toDataURL(),l.tintId=o,r[s]=l}else r[s]=a;return r[s]},getTintedPattern:(e,t)=>{let n=we.shared.setValue(t).toHex(),s=e.patternCache||(e.patternCache={}),r=e.source._resourceId,i=s[n];if(i?.tintId===r)return i;if(!$e.canvas)$e.canvas=le.get().createCanvas();return $e.tintMethod(e,t,$e.canvas),i=$e.canvas.getContext("2d").createPattern($e.canvas,"repeat"),i.tintId=r,s[n]=i,i},applyPatternTransform:(e,t,n=!0)=>{if(!t)return;let s=e;if(!s.setTransform)return;let r=globalThis.DOMMatrix;if(!r)return;let i=new r([t.a,t.b,t.c,t.d,t.tx,t.ty]);s.setTransform(n?i.inverse():i)},tintWithMultiply:(e,t,n)=>{let s=n.getContext("2d"),r=e.frame.clone(),i=e.source._resolution??e.source.resolution??1,o=e.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;let a=ce.isVertical(o),l=a?r.height:r.width,u=a?r.width:r.height;if(n.width=Math.ceil(l),n.height=Math.ceil(u),s.save(),t!==16777215)s.fillStyle=we.shared.setValue(t).toHex(),s.fillRect(0,0,l,u),s.globalCompositeOperation="multiply";let c=$e.getCanvasSource(e);if(!c){s.restore();return}if(o)$e._applyInverseRotation(s,o,r.width,r.height);if(s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),t!==16777215)s.globalCompositeOperation="destination-atop",s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height);s.restore()},tintWithOverlay:(e,t,n)=>{let s=n.getContext("2d"),r=e.frame.clone(),i=e.source._resolution??e.source.resolution??1,o=e.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;let a=ce.isVertical(o),l=a?r.height:r.width,u=a?r.width:r.height;n.width=Math.ceil(l),n.height=Math.ceil(u),s.save(),s.globalCompositeOperation="copy",s.fillStyle=we.shared.setValue(t).toHex(),s.fillRect(0,0,l,u),s.globalCompositeOperation="destination-atop";let c=$e.getCanvasSource(e);if(!c){s.restore();return}if(o)$e._applyInverseRotation(s,o,r.width,r.height);s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore()},tintWithPerPixel:(e,t,n)=>{let s=n.getContext("2d"),r=e.frame.clone(),i=e.source._resolution??e.source.resolution??1,o=e.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;let a=ce.isVertical(o),l=a?r.height:r.width,u=a?r.width:r.height;n.width=Math.ceil(l),n.height=Math.ceil(u),s.save(),s.globalCompositeOperation="copy";let c=$e.getCanvasSource(e);if(!c){s.restore();return}if(o)$e._applyInverseRotation(s,o,r.width,r.height);s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore();let h=t>>16&255,d=t>>8&255,f=t&255,m=s.getImageData(0,0,l,u),p=m.data;for(let y=0;y{let r=ce.inv(t),i=ce.uX(r),o=ce.uY(r),a=ce.vX(r),l=ce.vY(r),u=-Math.min(0,i*n,a*s,i*n+a*s),c=-Math.min(0,o*n,l*s,o*n+l*s);e.transform(i,o,a,l,u,c)}};$e.tintMethod=$e.canUseMultiply?$e.tintWithMultiply:$e.tintWithPerPixel});function Zg(e,t){return(e<<17)+(t<<2)}class Qg{constructor(e){this._buckets=new Map,this._screens=new Kr,this._enableFullScreen=!1,this.canvasOptions=e||{}}get enableFullScreen(){return q(Ut,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){q(Ut,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen=e}_createCanvasAndContext(e,t){let n=le.get().createCanvas();n.width=e,n.height=t;let s=n.getContext("2d");return{canvas:n,context:s}}getOptimalCanvasAndContext(e,t,n=1){let{width:s,height:r}=this.getOptimalSize(e,t,n);if(s>yu||r>yu)te(`CanvasPool: ${s}x${r} is larger than the ${yu}px pool key limit, canvases of this size may be pooled together`);let i=Zg(s,r),o=this._buckets.get(i);if(!o)o=[],this._buckets.set(i,o);let a=o.pop();if(!a)a=this._createCanvasAndContext(s,r);return a}getOptimalSize(e,t,n=1){let s=Math.ceil(e*n-0.000001),r=Math.ceil(t*n-0.000001),i=Xs(s),o=this._screens.getFittingWidth(s),a=Xs(r),l=this._screens.getFittingHeight(r);return{width:o!==void 0?Math.min(o,i):i,height:l!==void 0?Math.min(l,a):a}}returnCanvasAndContext(e){let t=e.canvas,{width:n,height:s}=t,r=this._buckets.get(Zg(n,s));if(!r)return;e.context.resetTransform(),e.context.clearRect(0,0,n,s),r.push(e)}setScreenSize(e,t,n){if(!this._screens.set(e,t,n))return;this._pruneScreenCanvases()}removeScreen(e){if(!this._screens.remove(e))return;this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(let[e]of this._buckets){let t=e>>>17,n=e>>>2&32767;if((bn(t)||this._screens.hasWidth(t))&&(bn(n)||this._screens.hasHeight(n)))continue;this._buckets.delete(e)}}}var yu=32767,Js;var xu=M(()=>{it();To();Ie();Be();ss();Vc();Js=new Qg;Wt.register(Js)});function qo(e){let t=e.length;if(t<6)return 1;let n=0;for(let s=0,r=e[t-2],i=e[t-1];s{};function ey(e,t,n,s,r,i){let o=e-n,a=t-s,l=r-n,u=i-s,c=o*l+a*u,h=l*l+u*u,d=-1;if(h!==0)d=c/h;let f,m;if(d<0)f=n,m=s;else if(d>1)f=r,m=i;else f=n+d*l,m=s+d*u;let p=e-f,y=t-m;return p*p+y*y}var ty=()=>{};function vu(e,t,n,s,r,i,o,a){let l=o-n,u=a-s,c=r-n,h=i-s,d=e-n,f=t-s,m=l*l+u*u,p=l*c+u*h,y=l*d+u*f,g=c*c+h*h,x=c*d+h*f,b=1/(m*g-p*p),v=(g*y-p*x)*b,_=(m*x-p*y)*b;return v>=0&&_>=0&&v+_<1}var ny=()=>{};class Ko{constructor(e=0,t=0,n=0){this.type="circle",this.x=e,this.y=t,this.radius=n}clone(){return new Ko(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;let n=this.radius*this.radius,s=this.x-e,r=this.y-t;return s*=s,r*=r,s+r<=n}strokeContains(e,t,n,s=0.5){if(this.radius===0)return!1;let r=this.x-e,i=this.y-t,o=this.radius,a=(1-s)*n,l=Math.sqrt(r*r+i*i);return l<=o+a&&l>o-(n-a)}getBounds(e){return e||(e=new se),e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}var sy=M(()=>{st()});class Jo{constructor(e=0,t=0,n=0,s=0){this.type="ellipse",this.x=e,this.y=t,this.halfWidth=n,this.halfHeight=s}clone(){return new Jo(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let n=(e-this.x)/this.halfWidth,s=(t-this.y)/this.halfHeight;return n*=n,s*=s,n+s<=1}strokeContains(e,t,n,s=0.5){let{halfWidth:r,halfHeight:i}=this;if(r<=0||i<=0)return!1;let o=n*(1-s),a=n-o,l=r-a,u=i-a,c=r+o,h=i+o,d=e-this.x,f=t-this.y;if(d*d/(c*c)+f*f/(h*h)>1)return!1;if(l<=0||u<=0)return!0;return d*d/(l*l)+f*f/(u*u)>1}getBounds(e){return e||(e=new se),e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}var ry=M(()=>{st()});class Zs{constructor(...e){this.type="polygon";let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!=="number"){let n=[];for(let s=0,r=t.length;st!==u>t&&e<(l-o)*((t-a)/(u-a))+o)n=!n}return n}strokeContains(e,t,n,s=0.5){let{points:r}=this,i=s===0.5?s:(s-0.5)*qo(r)+0.5,o=n*i,a=n-o,l=o*o,u=a*a,c=r.length-(this.closePath?0:2);for(let h=0;hs?l:s,r=ui?u:i}return e.x=n,e.width=s-n,e.y=r,e.height=i-r,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return q("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return q("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}var cC,uC;var iy=M(()=>{Ie();bu();ty();st()});class Qo{constructor(e=0,t=0,n=0,s=0,r=20){this.type="roundedRectangle",this.x=e,this.y=t,this.width=n,this.height=s,this.radius=r}getBounds(e){return e||(e=new se),e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new Qo(this.x,this.y,this.width,this.height,this.radius)}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width){if(t>=this.y&&t<=this.y+this.height){let n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+n&&t<=this.y+this.height-n||e>=this.x+n&&e<=this.x+this.width-n)return!0;let s=e-(this.x+n),r=t-(this.y+n),i=n*n;if(s*s+r*r<=i)return!0;if(s=e-(this.x+this.width-n),s*s+r*r<=i)return!0;if(r=t-(this.y+this.height-n),s*s+r*r<=i)return!0;if(s=e-(this.x+n),s*s+r*r<=i)return!0}}return!1}strokeContains(e,t,n,s=0.5){let{x:r,y:i,width:o,height:a,radius:l}=this,u=n*(1-s),c=n-u,h=r+l,d=i+l,f=o-l*2,m=a-l*2,p=r+o,y=i+a;if((e>=r-u&&e<=r+c||e>=p-c&&e<=p+u)&&t>=d&&t<=d+m)return!0;if((t>=i-u&&t<=i+c||t>=y-c&&t<=y+u)&&e>=h&&e<=h+f)return!0;return ep-l&&tp-l&&t>y-l&&Zo(e,t,p-l,y-l,l,c,u)||ey-l&&Zo(e,t,h,y-l,l,c,u)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}var Zo=(e,t,n,s,r,i,o)=>{let a=e-n,l=t-s,u=Math.sqrt(a*a+l*l);return u>=r-i&&u<=r+o};var oy=M(()=>{st()});function ea(e,t){t.clear();let n=t.matrix;for(let s=0;s{Ce();ay=new j});function ly(e,t,n,s,r=!1,i){let o=hC;o.minX=0,o.minY=0,o.maxX=e.width/s|0,o.maxY=e.height/s|0;let a=Xe.getOptimalTexture({width:o.width,height:o.height,resolution:s,autoGenerateMipmaps:r,scaleMode:i});return a.source.uploadMethodId="image",a.source.resource=e,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=t/s,a.frame.height=n/s,a.source.emit("update",a.source),a.updateUvs(),a}var hC;var cy=M(()=>{us();yt();hC=new Me});function uy(e){return typeof e.getCanvasFilterString==="function"}class hy{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new Me,this.cssFilterString=""}}class ta{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){let t=this._pushFilterFrame(),n=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=n,t.container=e.container,t.cssFilterString="",n.every((a)=>!a.enabled)){t.skip=!0;return}let s=[],r=1;for(let a of n){if(!a.enabled)continue;if(!uy(a)){this._warnUnsupportedFilter(a);continue}let l=a.getCanvasFilterString();if(l===null){this._warnUnsupportedFilter(a);continue}if(l)s.push(l)}if(s.length===0&&r===1){t.skip=!0;return}t.cssFilterString=s.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;let i=this.renderer.canvasContext.activeContext,o=i.filter||"none";if(this._savedStates.push({filter:o,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){let a=this.renderer.canvasContext.activeResolution||1;i.save(),i.setTransform(1,0,0,1,0,0),i.beginPath(),i.rect(t.bounds.x*a,t.bounds.y*a,t.bounds.width*a,t.bounds.height*a),i.clip()}else t.useClip=!1;if(r!==1)this._alphaMultiplier*=r;if(t.cssFilterString)i.filter=o!=="none"?`${o} ${t.cssFilterString}`:t.cssFilterString}pop(){let e=this._popFilterFrame();if(e.skip)return;let t=this._savedStates.pop();if(!t)return;let n=this.renderer.canvasContext.activeContext;if(e.useClip)n.restore();else n.filter=t.filter;this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every((y)=>!y.enabled))return e;let n=[],s=1;for(let y of t){if(!y.enabled)continue;if(!uy(y)){this._warnUnsupportedFilter(y);continue}let g=y.getCanvasFilterString();if(g===null){this._warnUnsupportedFilter(y);continue}if(g)n.push(g)}if(n.length===0&&s===1)return e;let r=$e.getCanvasSource(e);if(!r)return e;let i=e.frame,o=e.source._resolution??e.source.resolution??1,{width:a,height:l}=i,u=Js.getOptimalCanvasAndContext(a,l,o),{canvas:c,context:h}=u;if(h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,c.width,c.height),n.length)h.filter=n.join(" ");if(s!==1)h.globalAlpha=s;let d=i.x*o,f=i.y*o,m=a*o,p=l*o;return h.drawImage(r,d,f,m,p,0,0,m,p),h.filter="none",h.globalAlpha=1,ly(c,a,l,o)}_calculateFilterArea(e,t){if(e.renderables)ea(e.renderables,t);else if(e.filterEffect.filterArea)t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform);else e.container.getFastGlobalBounds(!0,t);if(e.container){let s=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;if(s)t.applyMatrix(s)}}_warnUnsupportedFilter(e){let t=e?.constructor?.name||"Filter";if(this._warnedFilterTypes.has(t))return;this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`)}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];if(!e)e=this._filterStack[this._filterStackIndex]=new hy;return this._filterStackIndex++,e}_popFilterFrame(){if(this._filterStackIndex<=0)return this._filterStack[0];return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}var dy=M(()=>{z();Jg();xu();yt();_u();cy();ta.extension={type:[D.CanvasSystem],name:"filter"}});class na{constructor(e){this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){if(e.action==="pushFilter")this._renderer.filter.push(e);else if(e.action==="popFilter")this._renderer.filter.pop()}destroy(){this._renderer=null}}var fy=M(()=>{z();na.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"filter"}});function Bn(e,t){let n=my[e];if(n===void 0){if(Su[t]===void 0)Su[t]=1;my[e]=n=Su[t]++}return n}var Su,my;var ri=M(()=>{Su=Object.create(null),my=Object.create(null)});function ra(){if(!sa||sa?.isContextLost())sa=le.get().createCanvas().getContext("webgl",{});return sa}var sa;var wu=M(()=>{it()});function py(){if(!ia){ia="mediump";let e=ra();if(e){if(e.getShaderPrecisionFormat)ia=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision?"highp":"mediump"}}return ia}var ia;var gy=M(()=>{wu()});function yy(e,t,n){if(t)return e;if(n)return e=e.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying @@ -29,11 +29,11 @@ Deprecated since v${e}`,i=typeof console.groupCollapsed==="function"&&!Rs.noColo #define out varying #endif ${e} - `}var sy=()=>{};function ry(e,t,n){let s=n?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(e.substring(0,9)!=="precision"){let i=n?t.requestedFragmentPrecision:t.requestedVertexPrecision;if(i==="highp"&&s!=="highp")i="mediump";e=`precision ${i} float; -${e}`}else if(s!=="highp"&&e.substring(0,15)==="precision highp")e=e.replace("precision highp","precision mediump");let r=t.maxSupportedFragmentPrecision==="highp"?"highp":"mediump";return zT(e,r)}function zT(e,t){let n=new Set,s="";for(let[,r]of e.matchAll(VT))n.add(r);for(let[,r]of e.matchAll(YT)){if(n.has(r))continue;n.add(r),s+=`precision ${HT[r]??t} ${r}; -`}return s+e}var YT,VT,HT;var iy=w(()=>{YT=/\buniform\s+([iu]?sampler\w+)/g,VT=/\bprecision\s+\w+\s+([iu]?sampler\w+)\s*;/g,HT={sampler2D:"lowp",samplerCube:"lowp"}});function oy(e,t){if(!t)return e;return`#version 300 es -${e}`}var ay=()=>{};function ly(e,{name:t="pixi-program"},n=!0){t=t.replace(/\s+/g,"-"),t+=n?"-fragment":"-vertex";let s=n?qT:KT;if(s[t])s[t]++,t+=`-${s[t]}`;else s[t]=1;if(e.indexOf("#define SHADER_NAME")!==-1)return e;return`${`#define SHADER_NAME ${t}`} -${e}`}var qT,KT;var cy=w(()=>{qT={},KT={}});function uy(e,t){if(!t)return e;return e.replace("#version 300 es","")}var hy=()=>{};var pu,qr,dy=class e{constructor(t){t={...e.defaultOptions,...t};let n=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:n,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ey()},setProgramName:{name:t.name},addProgramDefines:n,insertVersion:n},r=t.fragment,i=t.vertex;Object.keys(pu).forEach((o)=>{let a=s[o];r=pu[o](r,a,!0),i=pu[o](i,a,!1)}),this.fragment=r,this.vertex=i,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=An(`${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,qr[this._cacheKey]=null}static from(t){let n=`${t.vertex}:${t.fragment}`;if(!qr[n])qr[n]=new e(t),qr[n]._cacheKey=n;return qr[n]}},yt;var En=w(()=>{zr();ty();sy();iy();ay();cy();hy();pu={stripVersion:uy,ensurePrecision:ry,addProgramDefines:ny,setProgramName:ly,insertVersion:oy},qr=Object.create(null);dy.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};yt=dy});function gn(e){return fy[e]??fy.float32}var fy;var Kr=w(()=>{fy={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 py(e,t){let n;while((n=my.exec(e))!==null){let s=JT[n[3]]??"float32";t[n[2]]={location:parseInt(n[1],10),format:s,stride:gn(s).stride,offset:0,instance:!1,start:0}}my.lastIndex=0}function ZT(e){return e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function gy({source:e,entryPoint:t}){let n={},s=ZT(e),r=s.indexOf(`fn ${t}(`);if(r===-1)return n;let i=s.indexOf("->",r);if(i===-1)return n;let o=s.substring(r,i);if(py(o,n),Object.keys(n).length===0){let a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){let l=a[1],u=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),c=s.match(u);if(c)py(c[1],n)}}return n}var JT,my;var yy=w(()=>{Kr();JT={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"},my=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g});function ea(e){let t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,i=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,u=e.match(t)?.map((h)=>{let d=h.match(r),f=d?.[1]??"",m;if(f==="")m="uniform";else if(f.startsWith("{let d=h.match(l)[1],f=h.match(a).reduce((m,p)=>{let[y,g]=p.split(":");return m[y.trim()]=g.trim(),m},{});if(!f)return null;return{name:d,members:f}}).filter(({name:h})=>u.some((d)=>d.type===h||d.type.includes(`<${h}>`)))??[];return{groups:u,structs:c}}var xy=()=>{};var We;var by=w(()=>{We=((e)=>(e[e.VERTEX=1]="VERTEX",e[e.FRAGMENT=2]="FRAGMENT",e[e.COMPUTE=4]="COMPUTE",e))(We||{})});function ta(e){if(e.endsWith(""))return"uint";if(e.endsWith(""))return"sint";return"float"}function vy({groups:e}){let t=[];for(let n=0;n{by()});function Sy({groups:e}){let t=[];for(let n=0;n{};function wy(e,t){let n=new Set,s=new Set,r=[...e.structs,...t.structs].filter((o)=>{if(n.has(o.name))return!1;return n.add(o.name),!0}),i=[...e.groups,...t.groups].filter((o)=>{let a=`${o.name}-${o.binding}`;if(s.has(a))return!1;return s.add(a),!0});return{structs:r,groups:i}}var My=()=>{};class xt{constructor(e){this._layoutKey=0,this._attributeLocationsKey=0;let{fragment:t,vertex:n,layout:s,gpuLayout:r,name:i}=e;if(this.name=i,this.fragment=t,this.vertex=n,t.source===n.source){let o=ea(t.source);this.structsAndGroups=o}else{let o=ea(n.source),a=ea(t.source);this.structsAndGroups=wy(o,a)}this.layout=s??Sy(this.structsAndGroups),this.gpuLayout=r??vy(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){let{vertex:e,fragment:t}=this,n=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=An(n,"program")}get attributeData(){return this._attributeData??(this._attributeData=gy(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Jr[this._cacheKey]=null}static from(e){let t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;if(!Jr[t])Jr[t]=new xt(e),Jr[t]._cacheKey=t;return Jr[t]}}var Jr;var is=w(()=>{zr();yy();xy();_y();ky();My();Jr=Object.create(null)});class kt{constructor(e){this.resources=Object.create(null),this._resourceKeysValue=null,this._dirty=!0;let t=0;for(let n in e){let s=e[n];this.setResource(s,t++)}}get _resourceKeys(){return this._resourceKeysValue??(this._resourceKeysValue=Object.keys(this.resources).map(Number)),this._resourceKeysValue}get _key(){if(this._dirty){this._dirty=!1;let e=[],t=0;for(let n in this.resources)e[t++]=this.resources[n]?this.resources[n]._resourceId:-1;this._keyValue=e.join("|")}return this._keyValue}setResource(e,t){let n=this.resources[t];if(e===n)return;if(n)n.off?.("change",this.onResourceChange,this);if(e.on?.("change",this.onResourceChange,this),n===void 0)this._resourceKeysValue=null;this.resources[t]=e,this._dirty=!0}getResource(e){return this.resources[e]}_touch(e){let t=this.resources,n=this._resourceKeys;for(let s=0;s{Pe()});var at;var Rn=w(()=>{at=((e)=>(e[e.WEBGL=1]="WEBGL",e[e.WEBGPU=2]="WEBGPU",e[e.CANVAS=4]="CANVAS",e[e.BOTH=3]="BOTH",e))(at||{})});class Zr{constructor(e){this.data={...e};let t=Object.keys(e).sort().map((n)=>`${n}:${e[n]}`).join("|");this.id=An(t,"shader-overrides")}static from(e){if(e instanceof Zr)return e;return new Zr(e)}}var Ty=w(()=>{zr()});var gu,Cy;var Ay=w(()=>{gu=["f32","i32","u32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4","vec2","vec3","vec4"],Cy=gu.reduce((e,t)=>(e[t]=!0,e),{})});function Ey(e,t){switch(e){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var Ry=()=>{};var Py,Ve;var zt=w(()=>{Ke();qe();zr();Ay();Ry();Py=class e extends de{constructor(t,n){super();this.uid=ee("uniform"),this._resourceType="uniformGroup",this._resourceId=ee("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,n={...e.defaultOptions,...n},this.uniformStructures=t;let s={};for(let r in t){let i=t[r];if(i.name=r,i.size=i.size??1,!Cy[i.type]){let o=i.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){let[,a,l]=o;throw Error(`Uniform type ${i.type} is not supported. Use type: '${a}', size: ${l} instead.`)}throw Error(`Uniform type ${i.type} is not supported. Supported uniform types are: ${gu.join(", ")}`)}i.value??(i.value=Ey(i.type,i.size)),s[r]=i.value}this.uniforms=s,this._dirtyId=1,this.ubo=n.ubo,this.isStatic=n.isStatic,this._signature=An(Object.keys(s).map((r)=>`${r}-${t[r].type}`).join("-"),"uniform-group")}get buffer(){return this._buffer}set buffer(t){if(this._buffer===t)return;this._buffer?.off("change",this.onBufferChange,this),this._buffer=t,t?.on("change",this.onBufferChange,this)}get _gcLastUsed(){return this._buffer?._gcLastUsed??-1}set _gcLastUsed(t){if(this._buffer)this._buffer._gcLastUsed=t}onBufferChange(){this._resourceId=ee("resource"),this.emit("change",this)}update(){this._dirtyId++}};Py.defaultOptions={ubo:!1,isStatic:!1};Ve=Py});var It;var Ys=w(()=>{Ke();qe();Pe();En();js();is();Rn();Ty();zt();It=class It extends de{constructor(e){super();this.uid=ee("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:n,groups:s,resources:r,compatibleRenderers:i,groupMap:o,overrides:a}=e;if(this._overrides=a?Zr.from(a):null,this.gpuProgram=t,this.glProgram=n,i===void 0){if(i=0,t)i|=at.WEBGPU;if(n)i|=at.WEBGL}this.compatibleRenderers=i;let l={};if(o)for(let u in o)for(let c in o[u]){let h=o[u][c];l[h]={group:u,binding:c,name:h}}if(!r&&!s)r={};if(r&&s)throw Error("[Shader] Cannot have both resources and groups");else if(!t&&s&&!o)throw Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");else if(t&&s&&!o){let u=t.structsAndGroups.groups;o={},u.forEach((c)=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c})}else if(r){if(s={},o||(o={}),t)t.structsAndGroups.groups.forEach((h)=>{o[h.group]=o[h.group]||{},o[h.group][h.binding]=h.name,l[h.name]=h});let u=0;for(let c in r){if(l[c])continue;if(t&&!n)V(`[Shader] the resource '${c}' matches no binding in the WGSL source — is the name correct?`);if(!s[99])s[99]=new kt,this._ownedBindGroups.push(s[99]);l[c]={group:99,binding:u,name:c},o[99]=o[99]||{},o[99][u]=c,u++}for(let c in r){let h=c,d=r[c];if(!d.source&&!d._resourceType)d=new Ve(d);let f=l[h];if(f){if(!s[f.group])s[f.group]=new kt,this._ownedBindGroups.push(s[f.group]);s[f.group].setResource(d,f.binding)}}}this.groups=s,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(s,l)}addResource(e,t,n){var s,r;if((s=this._uniformBindMap)[t]||(s[t]={}),(r=this._uniformBindMap[t])[n]||(r[n]=e),!this.groups[t])this.groups[t]=new kt,this._ownedBindGroups.push(this.groups[t])}_buildResourceAccessor(e,t){let n={};for(let s in t){let r=t[s];Object.defineProperty(n,r.name,{get(){return e[r.group].getResource(r.binding)},set(i){e[r.group].setResource(i,r.binding)}})}return n}destroy(e=!1){if(this._destroyed)return;if(this._destroyed=!0,this.emit("destroy",this),e)this.gpuProgram?.destroy(),this.glProgram?.destroy();this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach((t)=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null,this._overrides=null}static from(e){let{gpu:t,gl:n,...s}=e,r,i;if(t)r=xt.from(t);if(n)i=yt.from(n);return new It({gpuProgram:r,glProgram:i,...s})}}});var QT,wu,yu,xu,bu,vu,_u,Su,ku=class e{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<{QT={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},wu={BLEND:0,OFFSET:1,CULLING:2,DEPTH_TEST:3,WINDING:4,DEPTH_MASK:5},{BLEND:yu,OFFSET:xu,CULLING:bu,DEPTH_TEST:vu,WINDING:_u,DEPTH_MASK:Su}=wu;ku.default2d=ku.for2d();lt=ku});var $y,Vs;var na=w(()=>{En();is();Ys();yn();$y=class e extends It{constructor(t){t={...e.defaultOptions,...t};super(t);if(this.enabled=!0,this._state=lt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias==="boolean")this.antialias=t.antialias?"on":"off";else this.antialias=t.antialias;if(this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired)this.addResource("uBackTexture",0,3)}apply(t,n,s,r){t.applyFilter(this,n,s,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){let{gpu:n,gl:s,...r}=t,i,o;if(n)i=xt.from(n);if(s)o=yt.from(s);return new e({gpuProgram:i,glProgram:o,...r})}};$y.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};Vs=$y});var sa=`in vec2 aPosition; + `}var xy=()=>{};function by(e,t,n){let s=n?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(e.substring(0,9)!=="precision"){let i=n?t.requestedFragmentPrecision:t.requestedVertexPrecision;if(i==="highp"&&s!=="highp")i="mediump";e=`precision ${i} float; +${e}`}else if(s!=="highp"&&e.substring(0,15)==="precision highp")e=e.replace("precision highp","precision mediump");let r=t.maxSupportedFragmentPrecision==="highp"?"highp":"mediump";return pC(e,r)}function pC(e,t){let n=new Set,s="";for(let[,r]of e.matchAll(fC))n.add(r);for(let[,r]of e.matchAll(dC)){if(n.has(r))continue;n.add(r),s+=`precision ${mC[r]??t} ${r}; +`}return s+e}var dC,fC,mC;var vy=M(()=>{dC=/\buniform\s+([iu]?sampler\w+)/g,fC=/\bprecision\s+\w+\s+([iu]?sampler\w+)\s*;/g,mC={sampler2D:"lowp",samplerCube:"lowp"}});function _y(e,t){if(!t)return e;return`#version 300 es +${e}`}var Sy=()=>{};function wy(e,{name:t="pixi-program"},n=!0){t=t.replace(/\s+/g,"-"),t+=n?"-fragment":"-vertex";let s=n?gC:yC;if(s[t])s[t]++,t+=`-${s[t]}`;else s[t]=1;if(e.indexOf("#define SHADER_NAME")!==-1)return e;return`${`#define SHADER_NAME ${t}`} +${e}`}var gC,yC;var ky=M(()=>{gC={},yC={}});function My(e,t){if(!t)return e;return e.replace("#version 300 es","")}var Ty=()=>{};var ku,ii,Cy=class e{constructor(t){t={...e.defaultOptions,...t};let n=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:n,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:py()},setProgramName:{name:t.name},addProgramDefines:n,insertVersion:n},r=t.fragment,i=t.vertex;Object.keys(ku).forEach((o)=>{let a=s[o];r=ku[o](r,a,!0),i=ku[o](i,a,!1)}),this.fragment=r,this.vertex=i,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Bn(`${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,ii[this._cacheKey]=null}static from(t){let n=`${t.vertex}:${t.fragment}`;if(!ii[n])ii[n]=new e(t),ii[n]._cacheKey=n;return ii[n]}},wt;var Fn=M(()=>{ri();gy();xy();vy();Sy();ky();Ty();ku={stripVersion:My,ensurePrecision:by,addProgramDefines:yy,setProgramName:wy,insertVersion:_y},ii=Object.create(null);Cy.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};wt=Cy});function Sn(e){return Ay[e]??Ay.float32}var Ay;var oi=M(()=>{Ay={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 Py(e,t){let n;while((n=Ey.exec(e))!==null){let s=xC[n[3]]??"float32";t[n[2]]={location:parseInt(n[1],10),format:s,stride:Sn(s).stride,offset:0,instance:!1,start:0}}Ey.lastIndex=0}function bC(e){return e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Ry({source:e,entryPoint:t}){let n={},s=bC(e),r=s.indexOf(`fn ${t}(`);if(r===-1)return n;let i=s.indexOf("->",r);if(i===-1)return n;let o=s.substring(r,i);if(Py(o,n),Object.keys(n).length===0){let a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){let l=a[1],u=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),c=s.match(u);if(c)Py(c[1],n)}}return n}var xC,Ey;var $y=M(()=>{oi();xC={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"},Ey=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g});function oa(e){let t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,n=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,i=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,u=e.match(t)?.map((h)=>{let d=h.match(r),f=d?.[1]??"",m;if(f==="")m="uniform";else if(f.startsWith("{let d=h.match(l)[1],f=h.match(a).reduce((m,p)=>{let[y,g]=p.split(":");return m[y.trim()]=g.trim(),m},{});if(!f)return null;return{name:d,members:f}}).filter(({name:h})=>u.some((d)=>d.type===h||d.type.includes(`<${h}>`)))??[];return{groups:u,structs:c}}var Oy=()=>{};var Ve;var Iy=M(()=>{Ve=((e)=>(e[e.VERTEX=1]="VERTEX",e[e.FRAGMENT=2]="FRAGMENT",e[e.COMPUTE=4]="COMPUTE",e))(Ve||{})});function aa(e){if(e.endsWith(""))return"uint";if(e.endsWith(""))return"sint";return"float"}function By({groups:e}){let t=[];for(let n=0;n{Iy()});function Dy({groups:e}){let t=[];for(let n=0;n{};function Gy(e,t){let n=new Set,s=new Set,r=[...e.structs,...t.structs].filter((o)=>{if(n.has(o.name))return!1;return n.add(o.name),!0}),i=[...e.groups,...t.groups].filter((o)=>{let a=`${o.name}-${o.binding}`;if(s.has(a))return!1;return s.add(a),!0});return{structs:r,groups:i}}var Ly=()=>{};class kt{constructor(e){this._layoutKey=0,this._attributeLocationsKey=0;let{fragment:t,vertex:n,layout:s,gpuLayout:r,name:i}=e;if(this.name=i,this.fragment=t,this.vertex=n,t.source===n.source){let o=oa(t.source);this.structsAndGroups=o}else{let o=oa(n.source),a=oa(t.source);this.structsAndGroups=Gy(o,a)}this.layout=s??Dy(this.structsAndGroups),this.gpuLayout=r??By(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){let{vertex:e,fragment:t}=this,n=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=Bn(n,"program")}get attributeData(){return this._attributeData??(this._attributeData=Ry(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,ai[this._cacheKey]=null}static from(e){let t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;if(!ai[t])ai[t]=new kt(e),ai[t]._cacheKey=t;return ai[t]}}var ai;var ps=M(()=>{ri();$y();Oy();Fy();Ny();Ly();ai=Object.create(null)});class Pt{constructor(e){this.resources=Object.create(null),this._resourceKeysValue=null,this._dirty=!0;let t=0;for(let n in e){let s=e[n];this.setResource(s,t++)}}get _resourceKeys(){return this._resourceKeysValue??(this._resourceKeysValue=Object.keys(this.resources).map(Number)),this._resourceKeysValue}get _key(){if(this._dirty){this._dirty=!1;let e=[],t=0;for(let n in this.resources)e[t++]=this.resources[n]?this.resources[n]._resourceId:-1;this._keyValue=e.join("|")}return this._keyValue}setResource(e,t){let n=this.resources[t];if(e===n)return;if(n)n.off?.("change",this.onResourceChange,this);if(e.on?.("change",this.onResourceChange,this),n===void 0)this._resourceKeysValue=null;this.resources[t]=e,this._dirty=!0}getResource(e){return this.resources[e]}_touch(e){let t=this.resources,n=this._resourceKeys;for(let s=0;s{Be()});var dt;var Dn=M(()=>{dt=((e)=>(e[e.WEBGL=1]="WEBGL",e[e.WEBGPU=2]="WEBGPU",e[e.CANVAS=4]="CANVAS",e[e.BOTH=3]="BOTH",e))(dt||{})});class li{constructor(e){this.data={...e};let t=Object.keys(e).sort().map((n)=>`${n}:${e[n]}`).join("|");this.id=Bn(t,"shader-overrides")}static from(e){if(e instanceof li)return e;return new li(e)}}var Uy=M(()=>{ri()});var Mu,Wy;var Xy=M(()=>{Mu=["f32","i32","u32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4","vec2","vec3","vec4"],Wy=Mu.reduce((e,t)=>(e[t]=!0,e),{})});function Vy(e,t){switch(e){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var jy=()=>{};var Yy,ze;var en=M(()=>{Qe();Ze();ri();Xy();jy();Yy=class e extends ke{constructor(t,n){super();this.uid=ie("uniform"),this._resourceType="uniformGroup",this._resourceId=ie("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,n={...e.defaultOptions,...n},this.uniformStructures=t;let s={};for(let r in t){let i=t[r];if(i.name=r,i.size=i.size??1,!Wy[i.type]){let o=i.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){let[,a,l]=o;throw Error(`Uniform type ${i.type} is not supported. Use type: '${a}', size: ${l} instead.`)}throw Error(`Uniform type ${i.type} is not supported. Supported uniform types are: ${Mu.join(", ")}`)}i.value??(i.value=Vy(i.type,i.size)),s[r]=i.value}this.uniforms=s,this._dirtyId=1,this.ubo=n.ubo,this.isStatic=n.isStatic,this._signature=Bn(Object.keys(s).map((r)=>`${r}-${t[r].type}`).join("-"),"uniform-group")}get buffer(){return this._buffer}set buffer(t){if(this._buffer===t)return;this._buffer?.off("change",this.onBufferChange,this),this._buffer=t,t?.on("change",this.onBufferChange,this)}get _gcLastUsed(){return this._buffer?._gcLastUsed??-1}set _gcLastUsed(t){if(this._buffer)this._buffer._gcLastUsed=t}onBufferChange(){this._resourceId=ie("resource"),this.emit("change",this)}update(){this._dirtyId++}};Yy.defaultOptions={ubo:!1,isStatic:!1};ze=Yy});var Xt;var er=M(()=>{Qe();Ze();Be();Fn();Qs();ps();Dn();Uy();en();Xt=class Xt extends ke{constructor(e){super();this.uid=ie("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:n,groups:s,resources:r,compatibleRenderers:i,groupMap:o,overrides:a}=e;if(this._overrides=a?li.from(a):null,this.gpuProgram=t,this.glProgram=n,i===void 0){if(i=0,t)i|=dt.WEBGPU;if(n)i|=dt.WEBGL}this.compatibleRenderers=i;let l={};if(o)for(let u in o)for(let c in o[u]){let h=o[u][c];l[h]={group:u,binding:c,name:h}}if(!r&&!s)r={};if(r&&s)throw Error("[Shader] Cannot have both resources and groups");else if(!t&&s&&!o)throw Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");else if(t&&s&&!o){let u=t.structsAndGroups.groups;o={},u.forEach((c)=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c})}else if(r){if(s={},o||(o={}),t)t.structsAndGroups.groups.forEach((h)=>{o[h.group]=o[h.group]||{},o[h.group][h.binding]=h.name,l[h.name]=h});let u=0;for(let c in r){if(l[c])continue;if(t&&!n)te(`[Shader] the resource '${c}' matches no binding in the WGSL source — is the name correct?`);if(!s[99])s[99]=new Pt,this._ownedBindGroups.push(s[99]);l[c]={group:99,binding:u,name:c},o[99]=o[99]||{},o[99][u]=c,u++}for(let c in r){let h=c,d=r[c];if(!d.source&&!d._resourceType)d=new ze(d);let f=l[h];if(f){if(!s[f.group])s[f.group]=new Pt,this._ownedBindGroups.push(s[f.group]);s[f.group].setResource(d,f.binding)}}}this.groups=s,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(s,l)}addResource(e,t,n){var s,r;if((s=this._uniformBindMap)[t]||(s[t]={}),(r=this._uniformBindMap[t])[n]||(r[n]=e),!this.groups[t])this.groups[t]=new Pt,this._ownedBindGroups.push(this.groups[t])}_buildResourceAccessor(e,t){let n={};for(let s in t){let r=t[s];Object.defineProperty(n,r.name,{get(){return e[r.group].getResource(r.binding)},set(i){e[r.group].setResource(i,r.binding)}})}return n}destroy(e=!1){if(this._destroyed)return;if(this._destroyed=!0,this.emit("destroy",this),e)this.gpuProgram?.destroy(),this.glProgram?.destroy();this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach((t)=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null,this._overrides=null}static from(e){let{gpu:t,gl:n,...s}=e,r,i;if(t)r=kt.from(t);if(n)i=wt.from(n);return new Xt({gpuProgram:r,glProgram:i,...s})}}});var vC,Ou,Tu,Cu,Au,Eu,Pu,Ru,$u=class e{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<{vC={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},Ou={BLEND:0,OFFSET:1,CULLING:2,DEPTH_TEST:3,WINDING:4,DEPTH_MASK:5},{BLEND:Tu,OFFSET:Cu,CULLING:Au,DEPTH_TEST:Eu,WINDING:Pu,DEPTH_MASK:Ru}=Ou;$u.default2d=$u.for2d();ft=$u});var Hy,tr;var la=M(()=>{Fn();ps();er();wn();Hy=class e extends Xt{constructor(t){t={...e.defaultOptions,...t};super(t);if(this.enabled=!0,this._state=ft.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias==="boolean")this.antialias=t.antialias?"on":"off";else this.antialias=t.antialias;if(this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired)this.addResource("uBackTexture",0,3)}apply(t,n,s,r){t.applyFilter(this,n,s,r)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){let{gpu:n,gl:s,...r}=t,i,o;if(n)i=kt.from(n);if(s)o=wt.from(s);return new e({gpuProgram:i,glProgram:o,...r})}};Hy.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};tr=Hy});var ca=`in vec2 aPosition; out vec2 vTextureCoord; uniform vec4 uInputSize; @@ -60,13 +60,13 @@ void main(void) gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } -`;var Mu=()=>{};var Oy=`in vec2 vTextureCoord; +`;var Iu=()=>{};var zy=`in vec2 vTextureCoord; out vec4 finalColor; uniform sampler2D uTexture; void main() { finalColor = texture(uTexture, vTextureCoord); } -`;var Iy=()=>{};var Tu=`struct GlobalFilterUniforms { +`;var qy=()=>{};var Bu=`struct GlobalFilterUniforms { uInputSize: vec4, uInputPixel: vec4, uInputClamp: vec4, @@ -115,26 +115,26 @@ fn mainFragment( ) -> @location(0) vec4 { return textureSample(uTexture, uSampler, uv); } -`;var By=()=>{};var Cu;var Dy=w(()=>{En();is();na();Mu();Iy();By();Cu=class Cu extends Vs{constructor(){let e=xt.from({vertex:{source:Tu,entryPoint:"mainVertex"},fragment:{source:Tu,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=yt.from({vertex:sa,fragment:Oy,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}});var ce;var os=w(()=>{ce=((e)=>(e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE",e[e.STATIC=1024]="STATIC",e))(ce||{})});var ct;var Hs=w(()=>{Ke();qe();os();ct=class ct extends de{constructor(e){let{data:t,size:n}=e,{usage:s,label:r,shrinkToFit:i}=e;super();if(this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ee("buffer"),this._resourceType="buffer",this._resourceId=ee("resource"),this._updateID=1,this._updateOffset=0,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array)t=new Float32Array(t);this._data=t,n??(n=t?.byteLength);let o=!!t;this.descriptor={size:n,usage:s,mappedAtCreation:o,label:r},this.shrinkToFit=i??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){if(!this._dataInt32)this._dataInt32=new Int32Array(this.data.buffer);return this._dataInt32}get static(){return!!(this.descriptor.usage&ce.STATIC)}set static(e){if(e)this.descriptor.usage|=ce.STATIC;else this.descriptor.usage&=~ce.STATIC}setDataWithSize(e,t,n){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._updateOffset=0,this._data===e){if(n)this.emit("update",this);return}let s=this._data;if(this._data=e,this._dataInt32=null,!s||s.length!==e.length){if(!this.shrinkToFit&&s&&e.byteLength{Hs();os()});function Ny(e,t,n){let s=e.getAttribute(t);if(!s)return n.minX=0,n.minY=0,n.maxX=0,n.maxY=0,n;let r=s.buffer.data,i=1/0,o=1/0,a=-1/0,l=-1/0,u=r.BYTES_PER_ELEMENT,c=(s.offset||0)/u,h=(s.stride||8)/u;for(let d=c;da)a=f;if(m>l)l=m;if(f{};function eC(e){if(e instanceof ct||Array.isArray(e)||e.BYTES_PER_ELEMENT)e={buffer:e};return e.buffer=Au(e.buffer,!1),e}var qt;var zs=w(()=>{Ke();ft();qe();Re();Hs();Fy();Gy();qt=class qt extends de{constructor(e={}){super();this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ee("geometry"),this._layoutKey=0,this.instanceCount=1,this.indexCount=0,this._bounds=new fe,this._boundsDirty=!0,this._vertexCount=0,this._vertexCountDirty=!0;let{attributes:t,indexBuffer:n,topology:s}=e;if(this.buffers=[],this.attributes={},t)for(let r in t)this.addAttribute(r,t[r]);if(this.instanceCount=e.instanceCount??1,this.indexCount=e.indexCount??0,n)this.addIndex(n);this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this._vertexCountDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}get vertexCount(){if(!this._vertexCountDirty)return this._vertexCount;this._vertexCountDirty=!1;let e=this.attributes;for(let t in e){let n=e[t];if(n.instance)continue;let s=n.buffer;return this._vertexCount=s.data.length/(n.stride/4||n.size),this._vertexCount}return this._vertexCount=0,0}getSize(){return X("8.20.0","Geometry.getSize is deprecated, please use Geometry.vertexCount instead."),this.vertexCount}addAttribute(e,t){let n=eC(t);if(this.buffers.indexOf(n.buffer)===-1)this.buffers.push(n.buffer),n.buffer.on("update",this.onBufferUpdate,this),n.buffer.on("change",this.onBufferUpdate,this);this.attributes[e]=n,this._vertexCountDirty=!0}addIndex(e){this.indexBuffer=Au(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){if(!this._boundsDirty)return this._bounds;return this._boundsDirty=!1,Ny(this,"aPosition",this._bounds)}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){this.emit("destroy",this);for(let t of this.buffers)if(t.off("update",this.onBufferUpdate,this),t.off("change",this.onBufferUpdate,this),e)t.destroy();this.unload(),this.removeAllListeners(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}});class Ly{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new fe,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class ra{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Ve({uInputSize:{value:new Float32Array(4),type:"vec4"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new kt({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,n=e.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=n,s.container=e.container,s.outputRenderSurface=t.renderTarget.renderSurface;let r=t.renderTarget.renderTarget.colorTexture.source,{resolution:i,antialias:o}=r;if(n.every((u)=>!u.enabled)){s.skip=!0;return}let a=s.bounds;if(this._calculateFilterArea(e,a),this._calculateFilterBounds(s,t.renderTarget.rootViewPort,o,i,1),s.skip)return;let l=this._getPreviousFilterData();this._setupFilterTextures(s,a,t,l)}generateFilteredTexture({texture:e,filters:t}){if(t.every((u)=>!u.enabled))return e;let n=this._pushFilterData();this._activeFilterData=n,n.skip=!1,n.filters=t;let s=e.source,{resolution:r,antialias:i}=s,o=n.bounds;if(o.clear(),o.addRect(e.frame),this._calculateFilterBounds(n,o.rectangle,i,r,0),n.skip)return this._popFilterData(),e;n.outputRenderSurface=Ue.getOptimalTexture({width:o.width,height:o.height,resolution:n.resolution,antialias:n.antialias}),n.backTexture=j.EMPTY,n.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(n,!0);let l=n.outputRenderSurface;return l.source.alphaMode="premultiplied-alpha",this._popFilterData(),l}pop(){let e=this.renderer,t=this._popFilterData();if(t.skip)return;if(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired)Ue.returnTexture(t.backTexture);Ue.returnTexture(t.inputTexture)}getBackTexture(e,t,n){let s=e.colorTexture.source._resolution,r=Ue.getOptimalTexture({width:t.width,height:t.height,resolution:s}),{minX:i,minY:o}=t;if(n)i-=n.minX,o-=n.minY;i=Math.floor(i*s),o=Math.floor(o*s);let a=Math.ceil(t.width*s),l=Math.ceil(t.height*s);return this.renderer.renderTarget.copyToTexture(e,r,{x:i,y:o},{width:a,height:l},{x:0,y:0}),r}applyFilter(e,t,n,s){let r=this.renderer,i=this._activeFilterData,a=i.outputRenderSurface===n,l=this._findClosestFilterData(),u=l?l.inputTexture.source._resolution:r.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=0,h=0;if(a&&l)c=l.bounds.minX,h=l.bounds.minY;this._updateFilterUniforms(t,n,i,c,h,u,a,s);let d=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,t,r)}calculateSpriteMatrix(e,t){let n=this._activeFilterData,s=e.set(n.inputTexture._source.width,0,0,n.inputTexture._source.height,n.bounds.minX,n.bounds.minY),r=t.worldTransform.copyTo(U.shared),i=t.renderGroup||t.parentRenderGroup;if(i&&i.cacheToLocalTransform)r.prepend(i.cacheToLocalTransform);return r.invert(),s.prepend(r),s.scale(1/t.texture.orig.width,1/t.texture.orig.height),s.translate(t.anchor.x,t.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Cu),this._passthroughFilter}_setupBindGroupsAndRender(e,t,n){if(n.renderPipes.uniformBatch){let s=n.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);if(this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:tC,shader:e,state:e._state,topology:"triangle-list"}),n.type===at.WEBGL)n.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,n,s){if(e.backTexture=j.EMPTY,e.inputTexture=Ue.getOptimalTexture({width:t.width,height:t.height,resolution:e.resolution,antialias:e.antialias}),e.blendRequired){n.renderTarget.finishRenderPass();let r=n.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(r,t,s?.bounds)}n.renderTarget.bind({target:e.inputTexture,clear:!0}),n.globalUniforms.push({offset:t})}_updateFilterUniforms(e,t,n,s,r,i,o,a){let l=this._filterGlobalUniforms.uniforms,{uOutputFrame:u,uInputSize:c,uInputPixel:h,uInputClamp:d,uGlobalFrame:f,uOutputTexture:m}=l;if(o)u[0]=n.bounds.minX-s,u[1]=n.bounds.minY-r;else u[0]=0,u[1]=0;u[2]=e.frame.width,u[3]=e.frame.height,c[0]=e.source.width,c[1]=e.source.height,c[2]=1/c[0],c[3]=1/c[1],h[0]=e.source.pixelWidth,h[1]=e.source.pixelHeight,h[2]=1/h[0],h[3]=1/h[1],d[0]=0.5*h[2],d[1]=0.5*h[3],d[2]=e.frame.width*c[2]-0.5*h[2],d[3]=e.frame.height*c[3]-0.5*h[3];let p=this.renderer.renderTarget.rootRenderTarget.colorTexture;if(f[0]=s*i,f[1]=r*i,f[2]=p.source.width*i,f[3]=p.source.height*i,t instanceof j)t.source.resource=null;let y=this.renderer.renderTarget.getRenderTarget(t);if(this.renderer.renderTarget.bind({target:t,clear:!!a}),t instanceof j)m[0]=t.frame.width,m[1]=t.frame.height;else m[0]=y.width,m[1]=y.height;m[2]=y.isRoot?-1:1,this._filterGlobalUniforms.update()}_findClosestFilterData(){for(let e=this._filterStackIndex-1;e>=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_calculateFilterArea(e,t){if(e.renderables)zo(e.renderables,t);else if(e.filterEffect.filterArea)t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform);else e.container.getFastGlobalBounds(!0,t);if(e.container){let s=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;if(s)t.applyMatrix(s)}}_applyFiltersToTexture(e,t){let{inputTexture:n,bounds:s,filters:r,firstEnabledIndex:i,lastEnabledIndex:o}=e;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),i===o)r[i].apply(this,n,e.outputRenderSurface,t);else{let a=e.inputTexture,l=Ue.getOptimalTexture({width:s.width,height:s.height,resolution:a.source._resolution}),u=l;for(let c=i;c=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];if(!e)e=this._filterStack[this._filterStackIndex]=new Ly;return this._filterStackIndex++,e}}var tC;var Uy=w(()=>{W();Dy();me();js();zs();zt();De();es();Rn();ft();du();Pe();tC=new qt({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])});ra.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"filter"}});var Eu=w(()=>{W();Jg();Zg();Uy();Z.add(ra,qo);Z.add(Ko)});var Wy=w(()=>{qp();Jp();ng();Oo();Wo();Eu()});var jy=w(()=>{Oo();Wo();Eu()});async function Vy(e){if(e)return;for(let t=0;t{W();Ru=[];Z.handleByNamedList(E.Environment,Ru)});function ia(){if(typeof Qr==="boolean")return Qr;try{Qr=Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(e){Qr=!1}return Qr}var Qr;var Pu=()=>{};function ua(e,t,n=2){let s=t&&t.length,r=s?t[0]*n:e.length;if(ni.size)ni.clear();let i=Jy(e,0,r,n,!0),o=[];if(!i||i.next===i.prev)return o;let a=0,l=0,u=0;if(s)i=oC(e,t,i,n);if(e.length>80*n){a=e[0],l=e[1];let c=a,h=l;for(let d=n;dc)c=f;if(m>h)h=m}u=Math.max(c-a,h-l),u=u!==0?32767/u:0}return Ou(i,o,a,l,u),o}function Jy(e,t,n,s,r){let i=null;if(r===bC(e,t,n,s)>0)for(let o=t;o=t;o-=s)i=Ky(o/s|0,e[o],e[o+1],i);if(i&&si(i,i.next))ii(i),i=i.next;return i}function ls(e,t=e){let n=t===e,s=e,r;do if(r=!1,s!==s.next&&(ni.size===0||!ni.has(s))&&(si(s,s.next)||He(s.prev,s,s.next)===0)){if(n||s===t)t=s.prev;$u=!0,ii(s),s=s.prev,r=!0}else if(n||s!==t)s=s.next,r=!n;while(r||s!==t);return t}function Ou(e,t,n,s,r){if(r)fC(e,n,s,r);let i=e,o=!1;while(e.prev!==e.next){let a=e.prev,l=e.next;if(He(a,e,l)<0&&(r?sC(e,n,s,r):nC(e))){t.push(a.i,e.i,l.i),ii(e),e=l,i=l;continue}if(e=l,e===i){if($u=!1,e=ls(e),$u){i=e;continue}if(!o){e=rC(e,t),i=e,o=!0;continue}iC(e,t,n,s,r);break}}}function nC(e){let t=e.prev,n=e,s=e.next,r=t.x,i=n.x,o=s.x,a=t.y,l=n.y,u=s.y,c=Math.min(r,i,o),h=Math.min(a,l,u),d=Math.max(r,i,o),f=Math.max(a,l,u),m=s.next;while(m!==t){if(m.x>=c&&m.x<=d&&m.y>=h&&m.y<=f&&!(r===m.x&&a===m.y)&&ca(r,a,i,l,o,u,m.x,m.y)&&He(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function sC(e,t,n,s){let r=e.prev,i=e,o=e.next,a=r.x,l=i.x,u=o.x,c=r.y,h=i.y,d=o.y,f=Math.min(a,l,u),m=Math.min(c,h,d),p=Math.max(a,l,u),y=Math.max(c,h,d),g=Fu(f,m,t,n,s),x=Fu(p,y,t,n,s),b=e.prevZ;while(b&&b.z>=g){if(b.x>=f&&b.x<=p&&b.y>=m&&b.y<=y&&b!==o&&!(a===b.x&&c===b.y)&&ca(a,c,l,h,u,d,b.x,b.y)&&He(b.prev,b,b.next)>=0)return!1;b=b.prevZ}let v=e.nextZ;while(v&&v.z<=x){if(v.x>=f&&v.x<=p&&v.y>=m&&v.y<=y&&v!==o&&!(a===v.x&&c===v.y)&&ca(a,c,l,h,u,d,v.x,v.y)&&He(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function rC(e,t){let n=e,s=!1;do{let r=n.prev,i=n.next.next;if(ex(r,n,n.next,i,!1)&&ri(r,i)&&ri(i,r))t.push(r.i,n.i,i.i),ii(n),ii(n.next),n=e=i,s=!0;n=n.next}while(n!==e);return s?ls(n):n}function iC(e,t,n,s,r){let i=e;do{let o=i.next.next;while(o!==i.prev){if(i.i!==o.i&&gC(i,o)){let a=tx(i,o);i=ls(i,i.next),a=ls(a,a.next),Ou(i,t,n,s,r),Ou(a,t,n,s,r);return}o=o.next}i=i.next}while(i!==e)}function oC(e,t,n,s){let r=[];for(let i=0,o=t.length;io)o=c.x;if(c.ya)a=c.y;n=c}while(++lXe[n+2])Xe[n+2]=t.x;if(t.y>Xe[n+3])Xe[n+3]=t.y}function zy(e){let t=Du[e];while(t.prev.next!==t)t=t.next;return Du[e]=t,t}function qy(e){let t=Bu[e];while(t.prev.next!==t)t=t.next;return Bu[e]=t,t}function hC(e,t){let n=t,{x:s,y:r}=e,i=-1/0,o;if(si(e,n))return n;for(let d=0,f=0;dXe[f+3]||Xe[f]>s||Xe[f+2]<=i)continue;let m=zy(d);n=qy(d);do{if(n.prev.next===n){if(si(e,n.next))return n.next;else if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){let p=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(p<=s&&p>i){if(i=p,o=n.xs||Xe[f+3]c)continue;let m=zy(d);n=qy(d);do{if(n.prev.next===n&&s>=n.x&&n.x>=a&&s!==n.x&&ca(rs)&&(po.x||n.x===o.x&&dC(o,n))))o=n,h=p}n=n.next}while(n!==m)}return o}function dC(e,t){return He(e.prev,e,t.prev)<0&&He(t.next,e,e.next)<0}function fC(e,t,n,s){let r=e,i=0;do r.z=Fu(r.x,r.y,t,n,s),wt[i++]=r,r=r.next;while(r!==e);mC(i);let o=null;for(let a=0;a=0&&wt[r].z>s)wt[r+1]=wt[r],r--;wt[r+1]=n}return}if(as.length>>i&255]++;let o=0;for(let a=0;a<256;a++){let l=ti[a];ti[a]=o,o+=l}for(let a=0;a>>i&255]++;s[u]=t[a],r[u]=l}}function Fu(e,t,n,s,r){return e=(e-n)*r|0,t=(t-s)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function pC(e){let t=e,n=e;do{if(t.x=(e-o)*(i-a)&&(e-o)*(s-a)>=(n-o)*(t-a)&&(n-o)*(i-a)>=(r-o)*(s-a)}function gC(e,t){let n=si(e,t)&&He(e.prev,e,e.next)>0&&He(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||ri(e,t)&&ri(t,e)&&(He(e.prev,e,t.prev)!==0||He(e,t.prev,t)!==0))&&!yC(e,t)&&(n||xC(e,t))}function He(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function si(e,t){return e.x===t.x&&e.y===t.y}function ex(e,t,n,s,r=!0){let i=He(e,t,n),o=He(e,t,s),a=He(n,s,e),l=He(n,s,t);if((i>0&&o<0||i<0&&o>0)&&(a>0&&l<0||a<0&&l>0))return!0;if(!r)return!1;if(i===0&&aa(e,n,t))return!0;if(o===0&&aa(e,s,t))return!0;if(a===0&&aa(n,e,s))return!0;if(l===0&&aa(n,t,s))return!0;return!1}function aa(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function yC(e,t){let n=Math.min(e.x,t.x),s=Math.max(e.x,t.x),r=Math.min(e.y,t.y),i=Math.max(e.y,t.y),o=e;do{let a=o.next;if(o.x>s&&a.x>s||o.xi&&a.y>i||o.y=0&&He(e,e.prev,t)>=0:He(e,t,e.prev)<0||He(e,e.next,t)<0}function xC(e,t){let n=e,s=!1,r=(e.x+t.x)/2,i=(e.y+t.y)/2;do{let o=n.next;if(n.y>i!==o.y>i&&r<(o.x-n.x)*(i-n.y)/(o.y-n.y)+n.x)s=!s;n=o}while(n!==e);return s}function tx(e,t){let n=Nu(e.i,e.x,e.y),s=Nu(t.i,t.x,t.y),r=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,s.next=n,n.prev=s,i.next=s,s.prev=i,s}function Ky(e,t,n,s){let r=Nu(e,t,n);if(!s)r.prev=r,r.next=r;else r.next=s.next,r.prev=s,s.next.prev=r,s.next=r;return r}function ii(e){if(e.next.prev=e.prev,e.prev.next=e.next,e.prevZ)e.prevZ.nextZ=e.nextZ;if(e.nextZ)e.nextZ.prevZ=e.prevZ;if(Iu)uC(e.prev,e.next)}function Nu(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function bC(e,t,n,s){let r=0;for(let i=t,o=n-s;i{ni=new Set;Xe=new Float64Array(0),Bu=[],Du=[];wt=[],qs=[],as=new Uint32Array(0),ei=new Uint32Array(0),ti=new Uint32Array(256)});var sx;var rx=w(()=>{nx();Ke();sx=ua.default||ua});var mt;var oi=w(()=>{mt=((e)=>(e[e.NONE=0]="NONE",e[e.COLOR=16384]="COLOR",e[e.STENCIL=1024]="STENCIL",e[e.DEPTH=256]="DEPTH",e[e.COLOR_DEPTH=16640]="COLOR_DEPTH",e[e.COLOR_STENCIL=17408]="COLOR_STENCIL",e[e.DEPTH_STENCIL=1280]="DEPTH_STENCIL",e[e.ALL=17664]="ALL",e))(mt||{})});class ai{constructor(e){this.items=[],this._name=e}emit(e,t,n,s,r,i,o,a){let{name:l,items:u}=this;for(let c=0,h=u.length;c{};var vC,ix,ox;var ax=w(()=>{Pt();Hy();nn();Pu();qe();Re();Hn();oi();Gu();Ke();vC=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],ix=class e extends de{constructor(t){super();this.tick=0,this.uid=ee("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;let n=[...vC,...this.config.runners??[]];this._addRunners(...n),this._unsafeEvalCheck()}async init(t={}){let n=t.skipExtensionImports===!0?!0:t.manageImports===!1;if(await Vy(n),!n&&this.config.loaders)await Promise.all(this.config.loaders.map((s)=>s.value.load()));this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(let s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...e.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s{this.runners[n]=new ai(n)})}_addSystems(t){let n;for(n in t){let s=t[n];this._addSystem(s.value,s.name)}}_addSystem(t,n){let s=new t(this);if(this[n])throw Error(`Whoops! The name "${n}" is already in use`);this[n]=s,this._systemsHash[n]=s;for(let r in this.runners)this.runners[r].add(s);return this}_addPipes(t,n){let s=n.reduce((r,i)=>(r[i.name]=i.value,r),{});t.forEach((r)=>{let{value:i,name:o}=r,a=s[o];this.renderPipes[o]=new i(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){if(this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),t===!0||typeof t==="object"&&t.releaseGlobalResources)Ot.release();Object.values(this.runners).forEach((n)=>{n.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ia())throw Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};ix.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};ox=ix});var Ks="8.22.0";var Lu=w(()=>{Ke()});class lx{static init(){globalThis.__PIXI_APP_INIT__?.(this,Ks)}static destroy(){}}class ha{constructor(e){this._renderer=e}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Ks)}destroy(){this._renderer=null}}var cx=w(()=>{W();Lu();lx.extension=E.Application;ha.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"initHook",priority:-10}});function ux(e){let t=[];return e.replace(_C,(n,s,r)=>{let i=s.toLowerCase(),o=s,a=kC(r);if(i==="m"&&a.length>2)t.push([o,...a.splice(0,2)]),i="l",o=o==="m"?"l":"L";while(!0){if(a.length===Uu[i])return t.push([o,...a]),"";if(a.length{Uu={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},_C=/([astvzqmhlc])([^astvzqmhlc]*)/gi,SC=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi});function dx(e,t){let n=ux(e),s=[],r=null,i=0,o=0;for(let a=0;a0)if(r=s.pop(),r)i=r.startX,o=r.startY;else i=0,o=0;r=null;break;default:V(`Unknown SVG path command: ${u}`)}if(u!=="Z"&&u!=="z"){if(r===null)r={startX:i,startY:o},s.push(r)}}return t}var fx=w(()=>{hx();Pe()});function px(e,t,n){let s=2166136261;for(let r=0;r>>=0;return mx[s]||wC(e,t,s,n)}function wC(e,t,n,s){let r={},i=0;for(let a=0;a{js();De();mx={}});class da{constructor(e){if(typeof e==="number")this.rawBinaryData=new ArrayBuffer(e);else if(e instanceof Uint8Array)this.rawBinaryData=e.buffer;else this.rawBinaryData=e;this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){if(!this._int8View)this._int8View=new Int8Array(this.rawBinaryData);return this._int8View}get uint8View(){if(!this._uint8View)this._uint8View=new Uint8Array(this.rawBinaryData);return this._uint8View}get int16View(){if(!this._int16View)this._int16View=new Int16Array(this.rawBinaryData);return this._int16View}get int32View(){if(!this._int32View)this._int32View=new Int32Array(this.rawBinaryData);return this._int32View}get float64View(){if(!this._float64Array)this._float64Array=new Float64Array(this.rawBinaryData);return this._float64Array}get bigUint64View(){if(!this._bigUint64Array)this._bigUint64Array=new BigUint64Array(this.rawBinaryData);return this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw Error(`${e} isn't a valid view type`)}}}var yx=()=>{};function Wu(e,t,n,s){if(n??(n=0),s??(s=Math.min(e.byteLength-n,t.byteLength)),!(n&7)&&!(s&7)){let r=s/8;new Float64Array(t,0,r).set(new Float64Array(e,n,r))}else if(!(n&3)&&!(s&3)){let r=s/4;new Float32Array(t,0,r).set(new Float32Array(e,n,r))}else new Uint8Array(t).set(new Uint8Array(e,n,s))}var xx=()=>{};var bx,je;var Js=w(()=>{bx={normal:"normal-npm",add:"add-npm",screen:"screen-npm"},je=((e)=>(e[e.DISABLED=0]="DISABLED",e[e.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",e[e.MASK_ACTIVE=2]="MASK_ACTIVE",e[e.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",e[e.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",e[e.NONE=5]="NONE",e))(je||{})});function li(e,t){if(t.alphaMode==="no-premultiply-alpha")return bx[e]||e;return e}var Xu=w(()=>{Js()});function TC(e){let t="";for(let n=0;n0)t+=` -else `;if(n{MC=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` -`)});function vx(){if(Zs)return Zs;let e=Zo();return Zs=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),Zs=fa(Zs,e),e.getExtension("WEBGL_lose_context")?.loseContext(),Zs}var Zs=null;var _x=w(()=>{mu();ju()});class Yu{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e{};class Mx{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Yu,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}function kx(){return ma>0?ui[--ma]:new Mx}function wx(e){e.elements=null,ui[ma++]=e}var ui,ma=0,ci=0,Tx=class e{constructor(t){if(this.uid=ee("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...e.defaultOptions,...t},!t.maxTextures)X("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=vx();let{maxTextures:n,attributesInitialSize:s,indicesInitialSize:r}=t;this.attributeBuffer=new da(s*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=n}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size)this._resizeAttributeBuffer(this.attributeSize*4);if(this.indexSize>this.indexBuffer.length)this._resizeIndexBuffer(this.indexSize);let l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,c=this.indexBuffer,h=this._batchIndexSize,d=this._batchIndexStart,f="startBatch",m=[],p=this.maxTextures;for(let y=this.elementStart;y=p||_)this._finishBatch(s,d,h-d,r,o,a,t,f,m),f="renderBatch",d=h,o=v,a=g.topology,s=kx(),r=s.textures,r.clear(),m=[],++ci;if(g._textureId=b._textureBindLocation=r.count,r.ids[b.uid]=r.count,r.textures[r.count++]=b,g._batch=s,m.push(g),h+=g.indexSize,g.packAsQuad)this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize);else this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize)}if(r.count>0)this._finishBatch(s,d,h-d,r,o,a,t,f,m),d=h,++ci;this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=h}_finishBatch(t,n,s,r,i,o,a,l,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=r,t.blendMode=i,t.topology=o,t.start=n,t.size=s,t.elements=u,++ci,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){if(t*4<=this.attributeBuffer.size)return;this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){if(t<=this.indexBuffer.length)return;this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){let n=Math.max(t,this.attributeBuffer.size*2),s=new da(n);Wu(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){let n=this.indexBuffer,s=Math.max(t,n.length*1.5);s+=s%2;let r=s>65535?new Uint32Array(s):new Uint16Array(s);if(r.BYTES_PER_ELEMENT!==n.BYTES_PER_ELEMENT)for(let i=0;i{qe();yx();Re();Hn();xx();Xu();_x();Sx();ui=[];Ot.register({clear:()=>{if(ui.length>0){for(let e of ui)if(e)e.destroy()}ui.length=0,ma=0}});Tx.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};Cx=Tx});var CC,AC,Vu;var Ex=w(()=>{Hs();os();zs();CC=new Float32Array(1),AC=new Uint32Array(1);Vu=class Vu extends qt{constructor(){let t=new ct({data:CC,label:"attribute-batch-buffer",usage:ce.VERTEX|ce.COPY_DST,shrinkToFit:!1}),n=new ct({data:AC,label:"index-batch-buffer",usage:ce.INDEX|ce.COPY_DST,shrinkToFit:!1}),s=24;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:n})}}});function Hu(e,t,n){if(e)for(let s in e){let r=s.toLocaleLowerCase(),i=t[r];if(i){let o=e[s];if(s==="header")o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"");if(n)i.push(`//----${n}----//`);i.push(o)}else V(`${s} placement hook does not exist in shader`)}}var Rx=w(()=>{Pe()});function zu(e){let t={};return(e.match(EC)?.map((s)=>s.replace(/[{()}]/g,""))??[]).forEach((s)=>{t[s]=[]}),t}var EC;var Px=w(()=>{EC=/\{\{(.*?)\}\}/g});function $x(e,t){let n,s=/@in\s+([^;]+);/g;while((n=s.exec(e))!==null)t.push(n[1])}function qu(e,t,n=!1){let s=[];$x(t,s),e.forEach((a)=>{if(a.header)$x(a.header,s)});let r=s;if(n)r.sort();let i=r.map((a,l)=>` @location(${l}) ${a},`).join(` +`;var Ky=()=>{};var Fu;var Jy=M(()=>{Fn();ps();la();Iu();qy();Ky();Fu=class Fu extends tr{constructor(){let e=kt.from({vertex:{source:Bu,entryPoint:"mainVertex"},fragment:{source:Bu,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=wt.from({vertex:ca,fragment:zy,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}});var _e;var gs=M(()=>{_e=((e)=>(e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE",e[e.STATIC=1024]="STATIC",e))(_e||{})});var mt;var nr=M(()=>{Qe();Ze();gs();mt=class mt extends ke{constructor(e){let{data:t,size:n}=e,{usage:s,label:r,shrinkToFit:i}=e;super();if(this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ie("buffer"),this._resourceType="buffer",this._resourceId=ie("resource"),this._updateID=1,this._updateOffset=0,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array)t=new Float32Array(t);this._data=t,n??(n=t?.byteLength);let o=!!t;this.descriptor={size:n,usage:s,mappedAtCreation:o,label:r},this.shrinkToFit=i??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){if(!this._dataInt32)this._dataInt32=new Int32Array(this.data.buffer);return this._dataInt32}get static(){return!!(this.descriptor.usage&_e.STATIC)}set static(e){if(e)this.descriptor.usage|=_e.STATIC;else this.descriptor.usage&=~_e.STATIC}setDataWithSize(e,t,n){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._updateOffset=0,this._data===e){if(n)this.emit("update",this);return}let s=this._data;if(this._data=e,this._dataInt32=null,!s||s.length!==e.length){if(!this.shrinkToFit&&s&&e.byteLength{nr();gs()});function Qy(e,t,n){let s=e.getAttribute(t);if(!s)return n.minX=0,n.minY=0,n.maxX=0,n.maxY=0,n;let r=s.buffer.data,i=1/0,o=1/0,a=-1/0,l=-1/0,u=r.BYTES_PER_ELEMENT,c=(s.offset||0)/u,h=(s.stride||8)/u;for(let d=c;da)a=f;if(m>l)l=m;if(f{};function _C(e){if(e instanceof mt||Array.isArray(e)||e.BYTES_PER_ELEMENT)e={buffer:e};return e.buffer=Du(e.buffer,!1),e}var tn;var sr=M(()=>{Qe();yt();Ze();Ie();nr();Zy();ex();tn=class tn extends ke{constructor(e={}){super();this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ie("geometry"),this._layoutKey=0,this.instanceCount=1,this.indexCount=0,this._bounds=new Me,this._boundsDirty=!0,this._vertexCount=0,this._vertexCountDirty=!0;let{attributes:t,indexBuffer:n,topology:s}=e;if(this.buffers=[],this.attributes={},t)for(let r in t)this.addAttribute(r,t[r]);if(this.instanceCount=e.instanceCount??1,this.indexCount=e.indexCount??0,n)this.addIndex(n);this.topology=s||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this._vertexCountDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}get vertexCount(){if(!this._vertexCountDirty)return this._vertexCount;this._vertexCountDirty=!1;let e=this.attributes;for(let t in e){let n=e[t];if(n.instance)continue;let s=n.buffer;return this._vertexCount=s.data.length/(n.stride/4||n.size),this._vertexCount}return this._vertexCount=0,0}getSize(){return q("8.20.0","Geometry.getSize is deprecated, please use Geometry.vertexCount instead."),this.vertexCount}addAttribute(e,t){let n=_C(t);if(this.buffers.indexOf(n.buffer)===-1)this.buffers.push(n.buffer),n.buffer.on("update",this.onBufferUpdate,this),n.buffer.on("change",this.onBufferUpdate,this);this.attributes[e]=n,this._vertexCountDirty=!0}addIndex(e){this.indexBuffer=Du(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){if(!this._boundsDirty)return this._bounds;return this._boundsDirty=!1,Qy(this,"aPosition",this._bounds)}unload(){this.emit("unload",this);for(let e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){this.emit("destroy",this);for(let t of this.buffers)if(t.off("update",this.onBufferUpdate,this),t.off("change",this.onBufferUpdate,this),e)t.destroy();this.unload(),this.removeAllListeners(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}});class tx{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new Me,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class ua{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new ze({uInputSize:{value:new Float32Array(4),type:"vec4"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new Pt({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,n=e.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=n,s.container=e.container,s.outputRenderSurface=t.renderTarget.renderSurface;let r=t.renderTarget.renderTarget.colorTexture.source,{resolution:i,antialias:o}=r;if(n.every((u)=>!u.enabled)){s.skip=!0;return}let a=s.bounds;if(this._calculateFilterArea(e,a),this._calculateFilterBounds(s,t.renderTarget.rootViewPort,o,i,1),s.skip)return;let l=this._getPreviousFilterData();this._setupFilterTextures(s,a,t,l)}generateFilteredTexture({texture:e,filters:t}){if(t.every((u)=>!u.enabled))return e;let n=this._pushFilterData();this._activeFilterData=n,n.skip=!1,n.filters=t;let s=e.source,{resolution:r,antialias:i}=s,o=n.bounds;if(o.clear(),o.addRect(e.frame),this._calculateFilterBounds(n,o.rectangle,i,r,0),n.skip)return this._popFilterData(),e;n.outputRenderSurface=Xe.getOptimalTexture({width:o.width,height:o.height,resolution:n.resolution,antialias:n.antialias}),n.backTexture=K.EMPTY,n.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(n,!0);let l=n.outputRenderSurface;return l.source.alphaMode="premultiplied-alpha",this._popFilterData(),l}pop(){let e=this.renderer,t=this._popFilterData();if(t.skip)return;if(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired)Xe.returnTexture(t.backTexture);Xe.returnTexture(t.inputTexture)}getBackTexture(e,t,n){let s=e.colorTexture.source._resolution,r=Xe.getOptimalTexture({width:t.width,height:t.height,resolution:s}),{minX:i,minY:o}=t;if(n)i-=n.minX,o-=n.minY;i=Math.floor(i*s),o=Math.floor(o*s);let a=Math.ceil(t.width*s),l=Math.ceil(t.height*s);return this.renderer.renderTarget.copyToTexture(e,r,{x:i,y:o},{width:a,height:l},{x:0,y:0}),r}applyFilter(e,t,n,s){let r=this.renderer,i=this._activeFilterData,a=i.outputRenderSurface===n,l=this._findClosestFilterData(),u=l?l.inputTexture.source._resolution:r.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=0,h=0;if(a&&l)c=l.bounds.minX,h=l.bounds.minY;this._updateFilterUniforms(t,n,i,c,h,u,a,s);let d=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,t,r)}calculateSpriteMatrix(e,t){let n=this._activeFilterData,s=e.set(n.inputTexture._source.width,0,0,n.inputTexture._source.height,n.bounds.minX,n.bounds.minY),r=t.worldTransform.copyTo(j.shared),i=t.renderGroup||t.parentRenderGroup;if(i&&i.cacheToLocalTransform)r.prepend(i.cacheToLocalTransform);return r.invert(),s.prepend(r),s.scale(1/t.texture.orig.width,1/t.texture.orig.height),s.translate(t.anchor.x,t.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Fu),this._passthroughFilter}_setupBindGroupsAndRender(e,t,n){if(n.renderPipes.uniformBatch){let s=n.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);if(this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:SC,shader:e,state:e._state,topology:"triangle-list"}),n.type===dt.WEBGL)n.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,n,s){if(e.backTexture=K.EMPTY,e.inputTexture=Xe.getOptimalTexture({width:t.width,height:t.height,resolution:e.resolution,antialias:e.antialias}),e.blendRequired){n.renderTarget.finishRenderPass();let r=n.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(r,t,s?.bounds)}n.renderTarget.bind({target:e.inputTexture,clear:!0}),n.globalUniforms.push({offset:t})}_updateFilterUniforms(e,t,n,s,r,i,o,a){let l=this._filterGlobalUniforms.uniforms,{uOutputFrame:u,uInputSize:c,uInputPixel:h,uInputClamp:d,uGlobalFrame:f,uOutputTexture:m}=l;if(o)u[0]=n.bounds.minX-s,u[1]=n.bounds.minY-r;else u[0]=0,u[1]=0;u[2]=e.frame.width,u[3]=e.frame.height,c[0]=e.source.width,c[1]=e.source.height,c[2]=1/c[0],c[3]=1/c[1],h[0]=e.source.pixelWidth,h[1]=e.source.pixelHeight,h[2]=1/h[0],h[3]=1/h[1],d[0]=0.5*h[2],d[1]=0.5*h[3],d[2]=e.frame.width*c[2]-0.5*h[2],d[3]=e.frame.height*c[3]-0.5*h[3];let p=this.renderer.renderTarget.rootRenderTarget.colorTexture;if(f[0]=s*i,f[1]=r*i,f[2]=p.source.width*i,f[3]=p.source.height*i,t instanceof K)t.source.resource=null;let y=this.renderer.renderTarget.getRenderTarget(t);if(this.renderer.renderTarget.bind({target:t,clear:!!a}),t instanceof K)m[0]=t.frame.width,m[1]=t.frame.height;else m[0]=y.width,m[1]=y.height;m[2]=y.isRoot?-1:1,this._filterGlobalUniforms.update()}_findClosestFilterData(){for(let e=this._filterStackIndex-1;e>=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_calculateFilterArea(e,t){if(e.renderables)ea(e.renderables,t);else if(e.filterEffect.filterArea)t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform);else e.container.getFastGlobalBounds(!0,t);if(e.container){let s=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;if(s)t.applyMatrix(s)}}_applyFiltersToTexture(e,t){let{inputTexture:n,bounds:s,filters:r,firstEnabledIndex:i,lastEnabledIndex:o}=e;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),i===o)r[i].apply(this,n,e.outputRenderSurface,t);else{let a=e.inputTexture,l=Xe.getOptimalTexture({width:s.width,height:s.height,resolution:a.source._resolution}),u=l;for(let c=i;c=0;e--){let t=this._filterStack[e];if(!t.skip)return t}return null}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];if(!e)e=this._filterStack[this._filterStackIndex]=new tx;return this._filterStackIndex++,e}}var SC;var nx=M(()=>{z();Jy();Ce();Qs();sr();en();Ne();us();Dn();yt();_u();Be();SC=new tn({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])});ua.extension={type:[D.WebGLSystem,D.WebGPUSystem],name:"filter"}});var Nu=M(()=>{z();dy();fy();nx();ne.add(ua,ta);ne.add(na)});var sx=M(()=>{ug();dg();yg();Go();zo();Nu()});var ix=M(()=>{Go();zo();Nu()});async function ax(e){if(e)return;for(let t=0;t{z();Gu=[];ne.handleByNamedList(D.Environment,Gu)});function ha(){if(typeof ci==="boolean")return ci;try{ci=Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(e){ci=!1}return ci}var ci;var Lu=()=>{};function ga(e,t,n=2){let s=t&&t.length,r=s?t[0]*n:e.length;if(di.size)di.clear();let i=dx(e,0,r,n,!0),o=[];if(!i||i.next===i.prev)return o;let a=0,l=0,u=0;if(s)i=CC(e,t,i,n);if(e.length>80*n){a=e[0],l=e[1];let c=a,h=l;for(let d=n;dc)c=f;if(m>h)h=m}u=Math.max(c-a,h-l),u=u!==0?32767/u:0}return Wu(i,o,a,l,u),o}function dx(e,t,n,s,r){let i=null;if(r===LC(e,t,n,s)>0)for(let o=t;o=t;o-=s)i=hx(o/s|0,e[o],e[o+1],i);if(i&&fi(i,i.next))pi(i),i=i.next;return i}function xs(e,t=e){let n=t===e,s=e,r;do if(r=!1,s!==s.next&&(di.size===0||!di.has(s))&&(fi(s,s.next)||qe(s.prev,s,s.next)===0)){if(n||s===t)t=s.prev;Uu=!0,pi(s),s=s.prev,r=!0}else if(n||s!==t)s=s.next,r=!n;while(r||s!==t);return t}function Wu(e,t,n,s,r){if(r)IC(e,n,s,r);let i=e,o=!1;while(e.prev!==e.next){let a=e.prev,l=e.next;if(qe(a,e,l)<0&&(r?kC(e,n,s,r):wC(e))){t.push(a.i,e.i,l.i),pi(e),e=l,i=l;continue}if(e=l,e===i){if(Uu=!1,e=xs(e),Uu){i=e;continue}if(!o){e=MC(e,t),i=e,o=!0;continue}TC(e,t,n,s,r);break}}}function wC(e){let t=e.prev,n=e,s=e.next,r=t.x,i=n.x,o=s.x,a=t.y,l=n.y,u=s.y,c=Math.min(r,i,o),h=Math.min(a,l,u),d=Math.max(r,i,o),f=Math.max(a,l,u),m=s.next;while(m!==t){if(m.x>=c&&m.x<=d&&m.y>=h&&m.y<=f&&!(r===m.x&&a===m.y)&&pa(r,a,i,l,o,u,m.x,m.y)&&qe(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function kC(e,t,n,s){let r=e.prev,i=e,o=e.next,a=r.x,l=i.x,u=o.x,c=r.y,h=i.y,d=o.y,f=Math.min(a,l,u),m=Math.min(c,h,d),p=Math.max(a,l,u),y=Math.max(c,h,d),g=Yu(f,m,t,n,s),x=Yu(p,y,t,n,s),b=e.prevZ;while(b&&b.z>=g){if(b.x>=f&&b.x<=p&&b.y>=m&&b.y<=y&&b!==o&&!(a===b.x&&c===b.y)&&pa(a,c,l,h,u,d,b.x,b.y)&&qe(b.prev,b,b.next)>=0)return!1;b=b.prevZ}let v=e.nextZ;while(v&&v.z<=x){if(v.x>=f&&v.x<=p&&v.y>=m&&v.y<=y&&v!==o&&!(a===v.x&&c===v.y)&&pa(a,c,l,h,u,d,v.x,v.y)&&qe(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function MC(e,t){let n=e,s=!1;do{let r=n.prev,i=n.next.next;if(px(r,n,n.next,i,!1)&&mi(r,i)&&mi(i,r))t.push(r.i,n.i,i.i),pi(n),pi(n.next),n=e=i,s=!0;n=n.next}while(n!==e);return s?xs(n):n}function TC(e,t,n,s,r){let i=e;do{let o=i.next.next;while(o!==i.prev){if(i.i!==o.i&&DC(i,o)){let a=gx(i,o);i=xs(i,i.next),a=xs(a,a.next),Wu(i,t,n,s,r),Wu(a,t,n,s,r);return}o=o.next}i=i.next}while(i!==e)}function CC(e,t,n,s){let r=[];for(let i=0,o=t.length;io)o=c.x;if(c.ya)a=c.y;n=c}while(++lje[n+2])je[n+2]=t.x;if(t.y>je[n+3])je[n+3]=t.y}function cx(e){let t=ju[e];while(t.prev.next!==t)t=t.next;return ju[e]=t,t}function ux(e){let t=Vu[e];while(t.prev.next!==t)t=t.next;return Vu[e]=t,t}function $C(e,t){let n=t,{x:s,y:r}=e,i=-1/0,o;if(fi(e,n))return n;for(let d=0,f=0;dje[f+3]||je[f]>s||je[f+2]<=i)continue;let m=cx(d);n=ux(d);do{if(n.prev.next===n){if(fi(e,n.next))return n.next;else if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){let p=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(p<=s&&p>i){if(i=p,o=n.xs||je[f+3]c)continue;let m=cx(d);n=ux(d);do{if(n.prev.next===n&&s>=n.x&&n.x>=a&&s!==n.x&&pa(rs)&&(po.x||n.x===o.x&&OC(o,n))))o=n,h=p}n=n.next}while(n!==m)}return o}function OC(e,t){return qe(e.prev,e,t.prev)<0&&qe(t.next,e,e.next)<0}function IC(e,t,n,s){let r=e,i=0;do r.z=Yu(r.x,r.y,t,n,s),Rt[i++]=r,r=r.next;while(r!==e);BC(i);let o=null;for(let a=0;a=0&&Rt[r].z>s)Rt[r+1]=Rt[r],r--;Rt[r+1]=n}return}if(ys.length>>i&255]++;let o=0;for(let a=0;a<256;a++){let l=hi[a];hi[a]=o,o+=l}for(let a=0;a>>i&255]++;s[u]=t[a],r[u]=l}}function Yu(e,t,n,s,r){return e=(e-n)*r|0,t=(t-s)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function FC(e){let t=e,n=e;do{if(t.x=(e-o)*(i-a)&&(e-o)*(s-a)>=(n-o)*(t-a)&&(n-o)*(i-a)>=(r-o)*(s-a)}function DC(e,t){let n=fi(e,t)&&qe(e.prev,e,e.next)>0&&qe(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||mi(e,t)&&mi(t,e)&&(qe(e.prev,e,t.prev)!==0||qe(e,t.prev,t)!==0))&&!NC(e,t)&&(n||GC(e,t))}function qe(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function fi(e,t){return e.x===t.x&&e.y===t.y}function px(e,t,n,s,r=!0){let i=qe(e,t,n),o=qe(e,t,s),a=qe(n,s,e),l=qe(n,s,t);if((i>0&&o<0||i<0&&o>0)&&(a>0&&l<0||a<0&&l>0))return!0;if(!r)return!1;if(i===0&&fa(e,n,t))return!0;if(o===0&&fa(e,s,t))return!0;if(a===0&&fa(n,e,s))return!0;if(l===0&&fa(n,t,s))return!0;return!1}function fa(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function NC(e,t){let n=Math.min(e.x,t.x),s=Math.max(e.x,t.x),r=Math.min(e.y,t.y),i=Math.max(e.y,t.y),o=e;do{let a=o.next;if(o.x>s&&a.x>s||o.xi&&a.y>i||o.y=0&&qe(e,e.prev,t)>=0:qe(e,t,e.prev)<0||qe(e,e.next,t)<0}function GC(e,t){let n=e,s=!1,r=(e.x+t.x)/2,i=(e.y+t.y)/2;do{let o=n.next;if(n.y>i!==o.y>i&&r<(o.x-n.x)*(i-n.y)/(o.y-n.y)+n.x)s=!s;n=o}while(n!==e);return s}function gx(e,t){let n=Hu(e.i,e.x,e.y),s=Hu(t.i,t.x,t.y),r=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,s.next=n,n.prev=s,i.next=s,s.prev=i,s}function hx(e,t,n,s){let r=Hu(e,t,n);if(!s)r.prev=r,r.next=r;else r.next=s.next,r.prev=s,s.next.prev=r,s.next=r;return r}function pi(e){if(e.next.prev=e.prev,e.prev.next=e.next,e.prevZ)e.prevZ.nextZ=e.nextZ;if(e.nextZ)e.nextZ.prevZ=e.prevZ;if(Xu)RC(e.prev,e.next)}function Hu(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function LC(e,t,n,s){let r=0;for(let i=t,o=n-s;i{di=new Set;je=new Float64Array(0),Vu=[],ju=[];Rt=[],rr=[],ys=new Uint32Array(0),ui=new Uint32Array(0),hi=new Uint32Array(256)});var xx;var bx=M(()=>{yx();Qe();xx=ga.default||ga});var xt;var gi=M(()=>{xt=((e)=>(e[e.NONE=0]="NONE",e[e.COLOR=16384]="COLOR",e[e.STENCIL=1024]="STENCIL",e[e.DEPTH=256]="DEPTH",e[e.COLOR_DEPTH=16640]="COLOR_DEPTH",e[e.COLOR_STENCIL=17408]="COLOR_STENCIL",e[e.DEPTH_STENCIL=1280]="DEPTH_STENCIL",e[e.ALL=17664]="ALL",e))(xt||{})});class yi{constructor(e){this.items=[],this._name=e}emit(e,t,n,s,r,i,o,a){let{name:l,items:u}=this;for(let c=0,h=u.length;c{};var UC,vx,_x;var Sx=M(()=>{Lt();lx();un();Lu();Ze();Ie();ss();gi();zu();Qe();UC=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],vx=class e extends ke{constructor(t){super();this.tick=0,this.uid=ie("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;let n=[...UC,...this.config.runners??[]];this._addRunners(...n),this._unsafeEvalCheck()}async init(t={}){let n=t.skipExtensionImports===!0?!0:t.manageImports===!1;if(await ax(n),!n&&this.config.loaders)await Promise.all(this.config.loaders.map((s)=>s.value.load()));this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(let s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...e.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s{this.runners[n]=new yi(n)})}_addSystems(t){let n;for(n in t){let s=t[n];this._addSystem(s.value,s.name)}}_addSystem(t,n){let s=new t(this);if(this[n])throw Error(`Whoops! The name "${n}" is already in use`);this[n]=s,this._systemsHash[n]=s;for(let r in this.runners)this.runners[r].add(s);return this}_addPipes(t,n){let s=n.reduce((r,i)=>(r[i.name]=i.value,r),{});t.forEach((r)=>{let{value:i,name:o}=r,a=s[o];this.renderPipes[o]=new i(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){if(this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),t===!0||typeof t==="object"&&t.releaseGlobalResources)Wt.release();Object.values(this.runners).forEach((n)=>{n.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ha())throw Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};vx.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};_x=vx});var ir="8.22.0";var qu=M(()=>{Qe()});class wx{static init(){globalThis.__PIXI_APP_INIT__?.(this,ir)}static destroy(){}}class ya{constructor(e){this._renderer=e}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,ir)}destroy(){this._renderer=null}}var kx=M(()=>{z();qu();wx.extension=D.Application;ya.extension={type:[D.WebGLSystem,D.WebGPUSystem],name:"initHook",priority:-10}});function Mx(e){let t=[];return e.replace(WC,(n,s,r)=>{let i=s.toLowerCase(),o=s,a=VC(r);if(i==="m"&&a.length>2)t.push([o,...a.splice(0,2)]),i="l",o=o==="m"?"l":"L";while(!0){if(a.length===Ku[i])return t.push([o,...a]),"";if(a.length{Ku={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},WC=/([astvzqmhlc])([^astvzqmhlc]*)/gi,XC=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi});function Cx(e,t){let n=Mx(e),s=[],r=null,i=0,o=0;for(let a=0;a0)if(r=s.pop(),r)i=r.startX,o=r.startY;else i=0,o=0;r=null;break;default:te(`Unknown SVG path command: ${u}`)}if(u!=="Z"&&u!=="z"){if(r===null)r={startX:i,startY:o},s.push(r)}}return t}var Ax=M(()=>{Tx();Be()});function Px(e,t,n){let s=2166136261;for(let r=0;r>>=0;return Ex[s]||jC(e,t,s,n)}function jC(e,t,n,s){let r={},i=0;for(let a=0;a{Qs();Ne();Ex={}});class xa{constructor(e){if(typeof e==="number")this.rawBinaryData=new ArrayBuffer(e);else if(e instanceof Uint8Array)this.rawBinaryData=e.buffer;else this.rawBinaryData=e;this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){if(!this._int8View)this._int8View=new Int8Array(this.rawBinaryData);return this._int8View}get uint8View(){if(!this._uint8View)this._uint8View=new Uint8Array(this.rawBinaryData);return this._uint8View}get int16View(){if(!this._int16View)this._int16View=new Int16Array(this.rawBinaryData);return this._int16View}get int32View(){if(!this._int32View)this._int32View=new Int32Array(this.rawBinaryData);return this._int32View}get float64View(){if(!this._float64Array)this._float64Array=new Float64Array(this.rawBinaryData);return this._float64Array}get bigUint64View(){if(!this._bigUint64Array)this._bigUint64Array=new BigUint64Array(this.rawBinaryData);return this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(e){switch(e){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw Error(`${e} isn't a valid view type`)}}}var $x=()=>{};function Ju(e,t,n,s){if(n??(n=0),s??(s=Math.min(e.byteLength-n,t.byteLength)),!(n&7)&&!(s&7)){let r=s/8;new Float64Array(t,0,r).set(new Float64Array(e,n,r))}else if(!(n&3)&&!(s&3)){let r=s/4;new Float32Array(t,0,r).set(new Float32Array(e,n,r))}else new Uint8Array(t).set(new Uint8Array(e,n,s))}var Ox=()=>{};var Ix,Ye;var or=M(()=>{Ix={normal:"normal-npm",add:"add-npm",screen:"screen-npm"},Ye=((e)=>(e[e.DISABLED=0]="DISABLED",e[e.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",e[e.MASK_ACTIVE=2]="MASK_ACTIVE",e[e.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",e[e.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",e[e.NONE=5]="NONE",e))(Ye||{})});function xi(e,t){if(t.alphaMode==="no-premultiply-alpha")return Ix[e]||e;return e}var Zu=M(()=>{or()});function HC(e){let t="";for(let n=0;n0)t+=` +else `;if(n{YC=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` +`)});function Bx(){if(ar)return ar;let e=ra();return ar=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),ar=ba(ar,e),e.getExtension("WEBGL_lose_context")?.loseContext(),ar}var ar=null;var Fx=M(()=>{wu();Qu()});class eh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e{};class Lx{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new eh,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}function Nx(){return va>0?vi[--va]:new Lx}function Gx(e){e.elements=null,vi[va++]=e}var vi,va=0,bi=0,Ux=class e{constructor(t){if(this.uid=ie("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...e.defaultOptions,...t},!t.maxTextures)q("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Bx();let{maxTextures:n,attributesInitialSize:s,indicesInitialSize:r}=t;this.attributeBuffer=new xa(s*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=n}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size)this._resizeAttributeBuffer(this.attributeSize*4);if(this.indexSize>this.indexBuffer.length)this._resizeIndexBuffer(this.indexSize);let l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,c=this.indexBuffer,h=this._batchIndexSize,d=this._batchIndexStart,f="startBatch",m=[],p=this.maxTextures;for(let y=this.elementStart;y=p||_)this._finishBatch(s,d,h-d,r,o,a,t,f,m),f="renderBatch",d=h,o=v,a=g.topology,s=Nx(),r=s.textures,r.clear(),m=[],++bi;if(g._textureId=b._textureBindLocation=r.count,r.ids[b.uid]=r.count,r.textures[r.count++]=b,g._batch=s,m.push(g),h+=g.indexSize,g.packAsQuad)this.packQuadAttributes(g,l,u,g._attributeStart,g._textureId),this.packQuadIndex(c,g._indexStart,g._attributeStart/this.vertexSize);else this.packAttributes(g,l,u,g._attributeStart,g._textureId),this.packIndex(g,c,g._indexStart,g._attributeStart/this.vertexSize)}if(r.count>0)this._finishBatch(s,d,h-d,r,o,a,t,f,m),d=h,++bi;this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=h}_finishBatch(t,n,s,r,i,o,a,l,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=r,t.blendMode=i,t.topology=o,t.start=n,t.size=s,t.elements=u,++bi,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){if(t*4<=this.attributeBuffer.size)return;this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){if(t<=this.indexBuffer.length)return;this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){let n=Math.max(t,this.attributeBuffer.size*2),s=new xa(n);Ju(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){let n=this.indexBuffer,s=Math.max(t,n.length*1.5);s+=s%2;let r=s>65535?new Uint32Array(s):new Uint16Array(s);if(r.BYTES_PER_ELEMENT!==n.BYTES_PER_ELEMENT)for(let i=0;i{Ze();$x();Ie();ss();Ox();Zu();Fx();Dx();vi=[];Wt.register({clear:()=>{if(vi.length>0){for(let e of vi)if(e)e.destroy()}vi.length=0,va=0}});Ux.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};Wx=Ux});var zC,qC,th;var Vx=M(()=>{nr();gs();sr();zC=new Float32Array(1),qC=new Uint32Array(1);th=class th extends tn{constructor(){let t=new mt({data:zC,label:"attribute-batch-buffer",usage:_e.VERTEX|_e.COPY_DST,shrinkToFit:!1}),n=new mt({data:qC,label:"index-batch-buffer",usage:_e.INDEX|_e.COPY_DST,shrinkToFit:!1}),s=24;super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:n})}}});function nh(e,t,n){if(e)for(let s in e){let r=s.toLocaleLowerCase(),i=t[r];if(i){let o=e[s];if(s==="header")o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"");if(n)i.push(`//----${n}----//`);i.push(o)}else te(`${s} placement hook does not exist in shader`)}}var jx=M(()=>{Be()});function sh(e){let t={};return(e.match(KC)?.map((s)=>s.replace(/[{()}]/g,""))??[]).forEach((s)=>{t[s]=[]}),t}var KC;var Yx=M(()=>{KC=/\{\{(.*?)\}\}/g});function Hx(e,t){let n,s=/@in\s+([^;]+);/g;while((n=s.exec(e))!==null)t.push(n[1])}function rh(e,t,n=!1){let s=[];Hx(t,s),e.forEach((a)=>{if(a.header)Hx(a.header,s)});let r=s;if(n)r.sort();let i=r.map((a,l)=>` @location(${l}) ${a},`).join(` `),o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` ${i} -`),o}var Ox=()=>{};function Ix(e,t){let n,s=/@out\s+([^;]+);/g;while((n=s.exec(e))!==null)t.push(n[1])}function RC(e){let n=/\b(\w+)\s*:/g.exec(e);return n?n[1]:""}function PC(e){let t=/@.*?\s+/g;return e.replace(t,"")}function Bx(e,t){let n=[];Ix(t,n),e.forEach((l)=>{if(l.header)Ix(l.header,n)});let s=0,r=n.sort().map((l)=>{if(l.indexOf("builtin")>-1)return l;return`@location(${s++}) ${l}`}).join(`, -`),i=n.sort().map((l)=>` var ${PC(l)};`).join(` +`),o}var zx=()=>{};function qx(e,t){let n,s=/@out\s+([^;]+);/g;while((n=s.exec(e))!==null)t.push(n[1])}function JC(e){let n=/\b(\w+)\s*:/g.exec(e);return n?n[1]:""}function ZC(e){let t=/@.*?\s+/g;return e.replace(t,"")}function Kx(e,t){let n=[];qx(t,n),e.forEach((l)=>{if(l.header)qx(l.header,n)});let s=0,r=n.sort().map((l)=>{if(l.indexOf("builtin")>-1)return l;return`@location(${s++}) ${l}`}).join(`, +`),i=n.sort().map((l)=>` var ${ZC(l)};`).join(` `),o=`return VSOutput( - ${n.sort().map((l)=>` ${RC(l)}`).join(`, + ${n.sort().map((l)=>` ${JC(l)}`).join(`, `)});`,a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` ${r} `),a=a.replace("{{start}}",` ${i} `),a=a.replace("{{return}}",` ${o} -`),a}var Dx=()=>{};function Ku(e,t){let n=e;for(let s in t){let r=t[s];if(r.join(` +`),a}var Jx=()=>{};function ih(e,t){let n=e;for(let s in t){let r=t[s];if(r.join(` `).length)n=n.replace(`{{${s}}}`,`//-----${s} START-----// ${r.join(` `)} -//----${s} FINISH----//`);else n=n.replace(`{{${s}}}`,"")}return n}var Fx=()=>{};function Nx({template:e,bits:t}){let n=Lx(e,t);if(Pn[n])return Pn[n];let{vertex:s,fragment:r}=OC(e,t);return Pn[n]=Ux(s,r,t),Pn[n]}function Gx({template:e,bits:t}){let n=Lx(e,t);if(Pn[n])return Pn[n];return Pn[n]=Ux(e.vertex,e.fragment,t),Pn[n]}function OC(e,t){let n=t.map((o)=>o.vertex).filter((o)=>!!o),s=t.map((o)=>o.fragment).filter((o)=>!!o),r=qu(n,e.vertex,!0);r=Bx(n,r);let i=qu(s,e.fragment,!0);return{vertex:r,fragment:i}}function Lx(e,t){return t.map((n)=>{if(!Ju.has(n))Ju.set(n,$C++);return Ju.get(n)}).sort((n,s)=>n-s).join("-")+e.vertex+e.fragment}function Ux(e,t,n){let s=zu(e),r=zu(t);return n.forEach((i)=>{Hu(i.vertex,s,i.name),Hu(i.fragment,r,i.name)}),{vertex:Ku(e,s),fragment:Ku(t,r)}}var Pn,Ju,$C=0;var Wx=w(()=>{Rx();Px();Ox();Dx();Fx();Pn=Object.create(null),Ju=new Map});var Xx=` +//----${s} FINISH----//`);else n=n.replace(`{{${s}}}`,"")}return n}var Zx=()=>{};function Qx({template:e,bits:t}){let n=t0(e,t);if(Nn[n])return Nn[n];let{vertex:s,fragment:r}=eA(e,t);return Nn[n]=n0(s,r,t),Nn[n]}function e0({template:e,bits:t}){let n=t0(e,t);if(Nn[n])return Nn[n];return Nn[n]=n0(e.vertex,e.fragment,t),Nn[n]}function eA(e,t){let n=t.map((o)=>o.vertex).filter((o)=>!!o),s=t.map((o)=>o.fragment).filter((o)=>!!o),r=rh(n,e.vertex,!0);r=Kx(n,r);let i=rh(s,e.fragment,!0);return{vertex:r,fragment:i}}function t0(e,t){return t.map((n)=>{if(!oh.has(n))oh.set(n,QC++);return oh.get(n)}).sort((n,s)=>n-s).join("-")+e.vertex+e.fragment}function n0(e,t,n){let s=sh(e),r=sh(t);return n.forEach((i)=>{nh(i.vertex,s,i.name),nh(i.fragment,r,i.name)}),{vertex:ih(e,s),fragment:ih(t,r)}}var Nn,oh,QC=0;var s0=M(()=>{jx();Yx();zx();Jx();Zx();Nn=Object.create(null),oh=new Map});var r0=` @in aPosition: vec2; @in aUV: vec2; @@ -178,7 +178,7 @@ ${r.join(` {{return}} }; -`,jx=` +`,i0=` @in vUV : vec2; @in vColor : vec4; @@ -201,7 +201,7 @@ ${r.join(` return finalColor; }; -`,Yx=` +`,o0=` in vec2 aPosition; in vec2 aUV; @@ -237,7 +237,7 @@ ${r.join(` {{end}} } -`,Vx=` +`,a0=` in vec4 vColor; in vec2 vUV; @@ -258,7 +258,7 @@ ${r.join(` {{end}} } -`;var Hx=()=>{};var zx,qx;var Kx=w(()=>{zx={name:"global-uniforms-bit",vertex:{header:` +`;var l0=()=>{};var c0,u0;var h0=M(()=>{c0={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, @@ -267,22 +267,22 @@ ${r.join(` } @group(0) @binding(0) var globalUniforms : GlobalUniforms; - `}},qx={name:"global-uniforms-bit",vertex:{header:` + `}},u0={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; - `}}});function Jx({bits:e,name:t}){let n=Nx({template:{fragment:jx,vertex:Xx},bits:[zx,...e]});return xt.from({name:t,vertex:{source:n.vertex,entryPoint:"main"},fragment:{source:n.fragment,entryPoint:"main"}})}function Qs({bits:e,name:t}){return new yt({name:t,...Gx({template:{vertex:Yx,fragment:Vx},bits:[qx,...e]})})}var pa=w(()=>{En();is();Wx();Hx();Kx()});var Zx,ga;var Zu=w(()=>{Zx={name:"color-bit",vertex:{header:` + `}}});function d0({bits:e,name:t}){let n=Qx({template:{fragment:i0,vertex:r0},bits:[c0,...e]});return kt.from({name:t,vertex:{source:n.vertex,entryPoint:"main"},fragment:{source:n.fragment,entryPoint:"main"}})}function lr({bits:e,name:t}){return new wt({name:t,...e0({template:{vertex:o0,fragment:a0},bits:[u0,...e]})})}var _a=M(()=>{Fn();ps();s0();l0();h0()});var f0,Sa;var ah=M(()=>{f0={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); - `}},ga={name:"color-bit",vertex:{header:` + `}},Sa={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); - `}}});function IC(e){let t=[];if(e===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let n=0;for(let s=0;s;`),t.push(`@group(1) @binding(${n++}) var textureSampler${s+1}: sampler;`)}return t.join(` -`)}function BC(e){let t=[];if(e===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let n=0;n;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let n=0;for(let s=0;s;`),t.push(`@group(1) @binding(${n++}) var textureSampler${s+1}: sampler;`)}return t.join(` +`)}function nA(e){let t=[];if(e===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let n=0;n; @out @interpolate(flat) vTextureId : u32; `,main:` @@ -295,14 +295,14 @@ ${r.join(` `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; - ${IC(e)} + ${tA(e)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); - ${BC(e)} - `}};return Qu[e]}function DC(e){let t=[];for(let n=0;n0)t.push("else");if(n0)t.push("else");if(n{Qu={};eh={}});var eb,er;var xa=w(()=>{eb={name:"round-pixels-bit",vertex:{header:` + ${sA(e)} + `}};return ch[e]}var lh,ch;var uh=M(()=>{lh={};ch={}});var p0,cr;var ka=M(()=>{p0={name:"round-pixels-bit",vertex:{header:` fn roundPixels(position: vec2, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } - `}},er={name:"round-pixels-bit",vertex:{header:` + `}},cr={name:"round-pixels-bit",vertex:{header:` vec2 roundPixels(vec2 position, vec2 targetSize) { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } - `}}});function ba(e){let t=tb[e];if(t)return t;let n=new Int32Array(e);for(let s=0;s{zt();tb={}});var va;var nb=w(()=>{pa();Zu();th();xa();nh();Ys();va=class va extends It{constructor(e){let t=Qs({name:"batch",bits:[ga,ya(e),er]}),n=Jx({name:"batch",bits:[Zx,Qx(e),eb]});super({glProgram:t,gpuProgram:n,resources:{batchSamplers:ba(e)}});this.maxTextures=e}}});var hi=null,sb,di;var sh=w(()=>{W();Ax();Ex();nb();sb=class e extends Cx{constructor(t){super(t);this.geometry=new Vu,this.name=e.extension.name,this.vertexSize=6,hi??(hi=new va(t.maxTextures)),this.shader=hi}packAttributes(t,n,s,r,i){let o=i<<16|t.roundPixels&65535,a=t.transform,{a:l,b:u,c,d:h,tx:d,ty:f}=a,{positions:m,uvs:p}=t,{color:y,attributeOffset:g}=t,x=g+t.attributeSize;for(let b=g;bt&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}var $n=()=>{};function rb(e,t,n,s,r,i,o,a=null){let l=0;n*=t,r*=i;let{a:u,b:c,c:h,d,tx:f,ty:m}=a;while(l{};function rh(e,t,n,s,r){let{a:i,b:o,c:a,d:l,tx:u,ty:c}=t;n||(n=0),s||(s=2),r||(r=e.length/s-n);let h=n*s;for(let d=0;d{};class tr{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){if(this.renderable&&this.applyTransform)return this.renderable.groupBlendMode;return"normal"}get color(){let e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,n=this.renderable;if(n)return yo(t,n.groupColor)+(this.alpha*n.groupAlpha*255<<24);return t+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||FC}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}var FC;var ih=w(()=>{me();wc();FC=new U});var nr,lb,cb;var ub=w(()=>{W();nr={extension:{type:E.ShapeBuilder,name:"circle"},build(e,t){let n,s,r,i,o,a;if(e.type==="circle"){let v=e;if(o=a=v.radius,o<=0)return!1;n=v.x,s=v.y,r=i=0}else if(e.type==="ellipse"){let v=e;if(o=v.halfWidth,a=v.halfHeight,o<=0||a<=0)return!1;n=v.x,s=v.y,r=i=0}else{let v=e,_=v.width/2,S=v.height/2;n=v.x+_,s=v.y+S,o=a=Math.max(0,Math.min(v.radius,Math.min(_,S))),r=_-o,i=S-a}if(r<0||i<0)return!1;let l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(r?4:0)+(i?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=n+r,t[1]=t[3]=s+i,t[2]=t[4]=n-r,t[5]=t[7]=s-i,!0;let c=0,h=l*4+(r?2:0)+2,d=h,f=u,m=r+o,p=i,y=n+m,g=n-m,x=s+p;if(t[c++]=y,t[c++]=x,t[--h]=x,t[--h]=g,i){let v=s-p;t[d++]=g,t[d++]=v,t[--f]=v,t[--f]=y}for(let v=1;v0)r[i++]=l,r[i++]=u,r[i++]=l-1;l++}r[i++]=u+1,r[i++]=u,r[i++]=l-1}},lb={...nr,extension:{...nr.extension,name:"ellipse"}},cb={...nr,extension:{...nr.extension,name:"roundedRectangle"}}});var _a=0.0001,oh=0.0001;var ah=()=>{};function hb(e,t,n,s,r,i,o,a){let l=e-n*r,u=t-s*r,c=e+n*i,h=t+s*i,d,f;if(o)d=s,f=-n;else d=-s,f=n;let m=l+d,p=u+f,y=c+d,g=h+f;return a.push(m,p),a.push(y,g),2}function cs(e,t,n,s,r,i,o,a){let l=n-e,u=s-t,c=Math.atan2(l,u),h=Math.atan2(r-e,i-t);if(a&&ch)h+=Math.PI*2;let d=c,f=h-c,m=Math.abs(f),p=Math.sqrt(l*l+u*u),y=(15*m*Math.sqrt(p)/Math.PI>>0)+1,g=f/y;if(d+=g,a){o.push(e,t),o.push(n,s);for(let x=1,b=d;x=0){if(a.join==="round")p+=cs(S,M,S-A*B,M-O*B,S-R*B,M-P*B,f,!1)+4;else p+=2;f.push(S-R*C,M-P*C),f.push(S+R*B,M+P*B)}continue}let pe=(-A+v)*(-O+M)-(-A+S)*(-O+_),Ie=(-R+k)*(-P+M)-(-R+S)*(-P+T),Le=(G*Ie-q*pe)/J,Me=(L*pe-z*Ie)/J,ue=(Le-S)*(Le-S)+(Me-M)*(Me-M),re=S+(Le-S)*B,ge=M+(Me-M)*B,xe=S-(Le-S)*C,Te=M-(Me-M)*C,Be=Math.min(G*G+z*z,q*q+L*L),te=H?B:C,be=Be+te*te*x;if(ue<=be)if(a.join==="bevel"||ue/x>b){if(H)f.push(re,ge),f.push(S+A*C,M+O*C),f.push(re,ge),f.push(S+R*C,M+P*C);else f.push(S-A*B,M-O*B),f.push(xe,Te),f.push(S-R*B,M-P*B),f.push(xe,Te);p+=2}else if(a.join==="round")if(H)f.push(re,ge),f.push(S+A*C,M+O*C),p+=cs(S,M,S+A*C,M+O*C,S+R*C,M+P*C,f,!0)+4,f.push(re,ge),f.push(S+R*C,M+P*C);else f.push(S-A*B,M-O*B),f.push(xe,Te),p+=cs(S,M,S-A*B,M-O*B,S-R*B,M-P*B,f,!1)+4,f.push(S-R*B,M-P*B),f.push(xe,Te);else f.push(re,ge),f.push(xe,Te);else{if(f.push(S-A*B,M-O*B),f.push(S+A*C,M+O*C),a.join==="round")if(H)p+=cs(S,M,S+A*C,M+O*C,S+R*C,M+P*C,f,!0)+2;else p+=cs(S,M,S-A*B,M-O*B,S-R*B,M-P*B,f,!1)+2;else if(a.join==="miter"&&ue/x<=b){if(H)f.push(xe,Te),f.push(xe,Te);else f.push(re,ge),f.push(re,ge);p+=2}f.push(S-R*B,M-P*B),f.push(S+R*C,M+P*C),p+=2}}if(v=e[(m-2)*2],_=e[(m-2)*2+1],S=e[(m-1)*2],M=e[(m-1)*2+1],A=-(_-M),O=v-S,I=Math.sqrt(A*A+O*O),A/=I,O/=I,A*=g,O*=g,f.push(S-A*B,M-O*B),f.push(S+A*C,M+O*C),!h){if(a.cap==="round")p+=cs(S-A*(B-C)*0.5,M-O*(B-C)*0.5,S-A*B,M-O*B,S+A*C,M+O*C,f,!1)+2;else if(a.cap==="square")p+=hb(S,M,A,O,B,C,!1,f)}let D=oh*oh;for(let N=y;N{uu();jt();ah()});function mb(e,t,n,s){let r=_a;if(e.length===0)return;let i=e[0],o=e[1],a=e[e.length-2],l=e[e.length-1],u=t||Math.abs(i-a){ah()});function Sa(e,t,n,s,r,i,o){let a=sx(e,t,2);if(!a)return;for(let u=0;u{rx()});var NC,gb;var yb=w(()=>{W();lh();NC=[],gb={extension:{type:E.ShapeBuilder,name:"polygon"},build(e,t){for(let n=0;n{W();xb={extension:{type:E.ShapeBuilder,name:"rectangle"},build(e,t){let n=e,{x:s,y:r,width:i,height:o}=n;if(!(i>0&&o>0))return!1;return t[0]=s,t[1]=r,t[2]=s+i,t[3]=r,t[4]=s+i,t[5]=r+o,t[6]=s,t[7]=r+o,!0},triangulate(e,t,n,s,r,i){let o=0;s*=n,t[s+o]=e[0],t[s+o+1]=e[1],o+=n,t[s+o]=e[2],t[s+o+1]=e[3],o+=n,t[s+o]=e[6],t[s+o+1]=e[7],o+=n,t[s+o]=e[4],t[s+o+1]=e[5],o+=n;let a=s/n;r[i++]=a,r[i++]=a+1,r[i++]=a+2,r[i++]=a+1,r[i++]=a+3,r[i++]=a+2}}});var vb;var _b=w(()=>{W();vb={extension:{type:E.ShapeBuilder,name:"triangle"},build(e,t){return t[0]=e.x,t[1]=e.y,t[2]=e.x2,t[3]=e.y2,t[4]=e.x3,t[5]=e.y3,!0},triangulate(e,t,n,s,r,i){let o=0;s*=n,t[s+o]=e[0],t[s+o+1]=e[1],o+=n,t[s+o]=e[2],t[s+o+1]=e[3],o+=n,t[s+o]=e[4],t[s+o+1]=e[5];let a=s/n;r[i++]=a,r[i++]=a+1,r[i++]=a+2}}});function kb(e,t){for(let n=0;n{this.addColorStop(r.offset,r.color)})}addColorStop(t,n){return this.colorStops.push({offset:t,color:he.shared.setValue(n).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:n}=this.start,{x:s,y:r}=this.end,i=s-t,o=r-n,a=i<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(i<0){let y=t;t=s,s=y,i*=-1}if(o<0){let y=n;n=r,r=y,o*=-1}}let l=this.colorStops.length?this.colorStops:Sb,u=this._textureSize,{canvas:c,context:h}=wb(u,1),d=!a?h.createLinearGradient(0,0,this._textureSize,0):h.createLinearGradient(this._textureSize,0,0,0);kb(d,l),h.fillStyle=d,h.fillRect(0,0,u,1),this.texture=new j({source:new sn({resource:c,addressMode:this._wrapMode})});let f=Math.sqrt(i*i+o*o),m=Math.atan2(o,i),p=new U;if(p.scale(f/u,1),p.rotate(m),p.translate(t,n),this.textureSpace==="local")p.scale(u,u);this.transform=p}buildGradient(){if(!this.texture)this._tick++;if(this.type==="linear")this.buildLinearGradient();else this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;let t=this.colorStops.length?this.colorStops:Sb,n=this._textureSize,{canvas:s,context:r}=wb(n,n),{x:i,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,h=a-c,d=l-c,f=n/(c*2),m=(i-h)*f,p=(o-d)*f,y=r.createRadialGradient(m,p,u*f,(a-h)*f,(l-d)*f,c*f);kb(y,t),r.fillStyle=t[t.length-1].color,r.fillRect(0,0,n,n),r.fillStyle=y,r.translate(m,p),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-m,-p),r.fillRect(0,0,n,n),this.texture=new j({source:new sn({resource:s,addressMode:this._wrapMode})});let g=new U;if(this.textureSpace==="local")g.scale(2*c,2*c);else g.scale(1/f,1/f);g.translate(h,d),this.transform=g}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}},On;var ka=w(()=>{Pt();nt();me();Lo();De();qe();Re();Cc();Sb=[{offset:0,color:"white"},{offset:1,color:"black"}];ch.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};ch.defaultRadialOptions={center:{x:0.5,y:0.5},innerRadius:0,outerRadius:0.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};On=ch});function Mb(e,t,n,s){let r=t.matrix?e.copyFrom(t.matrix).invert():e.identity();if(t.textureSpace==="local"){let o=n.getBounds(UC);if(t.width)o.pad(t.width);let{x:a,y:l}=o,u=1/o.width,c=1/o.height,h=-a*u,d=-l*c,{a:f,b:m,c:p,d:y}=r;r.a*=u,r.b*=u,r.c*=c,r.d*=c,r.tx=h*f+d*p+r.tx,r.ty=h*m+d*y+r.ty}else if(t.texture.rotate){let{uvs:o,orig:a}=t.texture;r.scale(1/a.width,1/a.height),r.prepend(WC.set(o.x1-o.x0,o.y1-o.y0,o.x3-o.x0,o.y3-o.y0,o.x0,o.y0))}else r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height);let i=t.texture.source.style;if(!(t.fill instanceof On)&&i.addressMode==="clamp-to-edge")i.addressMode="repeat",i.update();if(s)r.append(LC.copyFrom(s).invert());return r}var LC,UC,WC;var Tb=w(()=>{me();et();ka();LC=new U,UC=new Q,WC=new U});function Ab(e,t){let{geometryData:n,batches:s}=t;s.length=0,n.indices.length=0,n.vertices.length=0,n.uvs.length=0;for(let r=0;r{let h=[],d=wa[l.type];if(!d.build(l,h))return;let f=a.length,m=i.length/2,p="triangle-list";if(u)rh(h,u);if(!n)if(c){let b=[],v=h.slice();VC(c).forEach((S)=>{b.push(v.length/2),v.push(...S)}),Sa(v,b,i,2,m,a,f)}else d.triangulate(h,i,2,m,a,f);else{let b=l.closePath??!0,v=t;if(!v.pixelLine)db(h,v,!1,b,i,a);else mb(h,b,i,a),p="line-list"}let y=o.length/2,g=t.texture;if(g!==j.WHITE){let b=Mb(jC,t,l,u);rb(i,2,m,o,y,2,i.length/2-m,b)}else ib(o,y,2,i.length/2-m);let x=Ce.get(tr);x.indexOffset=f,x.indexSize=a.length-f,x.attributeOffset=m,x.attributeSize=i.length/2-m,x.baseColor=t.color,x.alpha=t.alpha,x.texture=g,x.geometryData=r,x.topology=p,s.push(x)})}function VC(e){let t=[];for(let n=0;n{W();me();et();ob();ab();De();dn();ih();ub();fb();pb();yb();bb();_b();Tb();lh();wa={};Z.handleByMap(E.ShapeBuilder,wa);Z.add(xb,gb,vb,nr,lb,cb);XC=new Q,jC=new U});class Rb{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){if(this.batches)this.batches.forEach((e)=>{Ce.return(e)});if(this.graphicsData)Ce.return(this.graphicsData);this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Pb{constructor(){this.instructions=new qn}init(e){let t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new di({maxTextures:t}),this.instructions.reset()}get geometry(){return X(Dm,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}var uh=class e{constructor(t){this._renderer=t,this._managedContexts=new pt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){let n=!!t._gpuData[this._renderer.uid],s=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!n){if(n)s.reset();Ab(t,s);let r=t.batchMode;if(t.customShader||r==="no-batch")s.isBatchable=!1;else if(r==="auto")s.isBatchable=s.geometryData.vertices.length<400;else s.isBatchable=!0;t.dirty=!1}return s}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){let n=Ce.get(Pb,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:r,geometryData:i}=s;s.graphicsData=n;let o=i.vertices.length,a=i.indices.length;for(let h=0;h{W();gx();sh();bo();$n();Re();dn();Eb();uh.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"graphicsContext"};uh.defaultOptions={bezierSmoothness:0.5};sr=uh});function Ca(e,t,n,s,r,i,o,a,l,u){let h=Math.min(0.99,Math.max(0,u??sr.defaultOptions.bezierSmoothness)),d=(zC-h)/1;return d*=d,qC(t,n,s,r,i,o,a,l,e,d),e}function qC(e,t,n,s,r,i,o,a,l,u){dh(e,t,n,s,r,i,o,a,l,u,0),l.push(o,a)}function dh(e,t,n,s,r,i,o,a,l,u,c){if(c>HC)return;let h=Math.PI,d=(e+n)/2,f=(t+s)/2,m=(n+r)/2,p=(s+i)/2,y=(r+o)/2,g=(i+a)/2,x=(d+m)/2,b=(f+p)/2,v=(m+y)/2,_=(p+g)/2,S=(x+v)/2,M=(b+_)/2;if(c>0){let k=o-e,T=a-t,A=Math.abs((n-o)*T-(s-a)*k),O=Math.abs((r-o)*T-(i-a)*k),R,P;if(A>Ta&&O>Ta){if((A+O)*(A+O)<=u*(k*k+T*T)){if(rr=h)R=2*h-R;if(P>=h)P=2*h-P;if(R+Pus){l.push(n,s);return}if(P>us){l.push(r,i);return}}}}else if(A>Ta){if(A*A<=u*(k*k+T*T)){if(rr=h)R=2*h-R;if(Rus){l.push(n,s);return}}}}else if(O>Ta){if(O*O<=u*(k*k+T*T)){if(rr=h)R=2*h-R;if(Rus){l.push(r,i);return}}}}else if(k=S-(e+o)/2,T=M-(t+a)/2,k*k+T*T<=u){l.push(S,M);return}}dh(e,t,d,f,x,b,S,M,l,u,c+1),dh(S,M,v,_,y,g,o,a,l,u,c+1)}var HC=8,Ta=0.00000011920929,zC=1,hh=0.01,rr=0,us=0;var fh=w(()=>{Ma()});function Ob(e,t,n,s,r,i,o,a){let u=Math.min(0.99,Math.max(0,a??sr.defaultOptions.bezierSmoothness)),c=(ZC-u)/1;return c*=c,eA(t,n,s,r,i,o,e,c),e}function eA(e,t,n,s,r,i,o,a){mh(o,e,t,n,s,r,i,a,0),o.push(r,i)}function mh(e,t,n,s,r,i,o,a,l){if(l>KC)return;let u=Math.PI,c=(t+s)/2,h=(n+r)/2,d=(s+i)/2,f=(r+o)/2,m=(c+d)/2,p=(h+f)/2,y=i-t,g=o-n,x=Math.abs((s-i)*g-(r-o)*y);if(x>JC){if(x*x<=a*(y*y+g*g)){if($b=u)b=2*u-b;if(b<$b){e.push(m,p);return}}}else if(y=m-(t+i)/2,g=p-(n+o)/2,y*y+g*g<=a){e.push(m,p);return}mh(e,t,n,c,h,m,p,a,l+1),mh(e,m,p,d,f,i,o,a,l+1)}var KC=8,JC=0.00000011920929,ZC=1,QC=0.01,$b=0;var Ib=w(()=>{Ma()});function Aa(e,t,n,s,r,i,o,a){let l=Math.abs(r-i);if(!o&&r>i)l=2*Math.PI-l;else if(o&&i>r)l=2*Math.PI-l;a||(a=Math.max(6,Math.floor(6*Math.pow(s,0.3333333333333333)*(l/Math.PI)))),a=Math.max(a,3);let u=l/a,c=r;u*=o?-1:1;for(let h=0;h{};function Bb(e,t,n,s,r,i){let o=e[e.length-2],l=e[e.length-1]-n,u=o-t,c=r-n,h=s-t,d=Math.abs(l*h-u*c);if(d<0.00000001||i===0){if(e[e.length-2]!==t||e[e.length-1]!==n)e.push(t,n);return}let f=l*l+u*u,m=c*c+h*h,p=l*c+u*h,y=i*Math.sqrt(f)/d,g=i*Math.sqrt(m)/d,x=y*p/f,b=g*p/m,v=y*h+g*u,_=y*c+g*l,S=u*(g+x),M=l*(g+x),k=h*(y+b),T=c*(y+b),A=Math.atan2(M-_,S-v),O=Math.atan2(T-_,k-v);Aa(e,v+t,_+n,i,A,O,u*c>h*l)}var Db=w(()=>{ph()});function tA(e,t){let n=t===-1.5707963267948966?-0.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?0.551915024494:n,r=Math.cos(e),i=Math.sin(e),o=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-i*s,y:i+r*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}function Nb(e,t,n,s,r,i,o,a=0,l=0,u=0){if(i===0||o===0)return;let c=Math.sin(a*fi/360),h=Math.cos(a*fi/360),d=h*(t-s)/2+c*(n-r)/2,f=-c*(t-s)/2+h*(n-r)/2;if(d===0&&f===0)return;i=Math.abs(i),o=Math.abs(o);let m=Math.pow(d,2)/Math.pow(i,2)+Math.pow(f,2)/Math.pow(o,2);if(m>1)i*=Math.sqrt(m),o*=Math.sqrt(m);nA(t,n,s,r,i,o,l,u,c,h,d,f,gh);let{ang1:p,ang2:y}=gh,{centerX:g,centerY:x}=gh,b=Math.abs(y)/(fi/4);if(Math.abs(1-b)<0.0000001)b=1;let v=Math.max(Math.ceil(b),1);y/=v;let _=e[e.length-2],S=e[e.length-1],M={x:0,y:0};for(let k=0;k{e*=n,t*=s;let u=r*e-i*t,c=i*e+r*t;return l.x=u+o,l.y=c+a,l},Fb=(e,t,n,s)=>{let r=e*s-t*n<0?-1:1,i=e*n+t*s;if(i>1)i=1;if(i<-1)i=-1;return r*Math.acos(i)},nA=(e,t,n,s,r,i,o,a,l,u,c,h,d)=>{let f=Math.pow(r,2),m=Math.pow(i,2),p=Math.pow(c,2),y=Math.pow(h,2),g=f*m-f*y-m*p;if(g<0)g=0;g/=f*y+m*p,g=Math.sqrt(g)*(o===a?-1:1);let x=g*r/i*h,b=g*-i/r*c,v=u*x-l*b+(e+n)/2,_=l*x+u*b+(t+s)/2,S=(c-x)/r,M=(h-b)/i,k=(-c-x)/r,T=(-h-b)/i,A=Fb(1,0,S,M),O=Fb(S,M,k,T);if(a===0&&O>0)O-=fi;if(a===1&&O<0)O+=fi;d.centerX=v,d.centerY=_,d.ang1=A,d.ang2=O};var Gb=w(()=>{fh();fi=Math.PI*2,gh={centerX:0,centerY:0,ang1:0,ang2:0}});function Lb(e,t,n){let s=(o,a)=>{let l=a.x-o.x,u=a.y-o.y,c=Math.sqrt(l*l+u*u),h=l/c,d=u/c;return{len:c,nx:h,ny:d}},r=(o,a)=>{if(o===0)e.moveTo(a.x,a.y);else e.lineTo(a.x,a.y)},i=t[t.length-1];for(let o=0;o0)f=-1,m=!0;let p=d/2,y,g=Math.abs(Math.cos(p)*l/Math.sin(p));if(g>Math.min(c.len/2,h.len/2))g=Math.min(c.len/2,h.len/2),y=Math.abs(g*Math.sin(p)/Math.cos(p));else y=l;let x=a.x+h.nx*g+-h.ny*y*f,b=a.y+h.ny*g+h.nx*y*f,v=Math.atan2(c.ny,c.nx)+Math.PI/2*f,_=Math.atan2(h.ny,h.nx)-Math.PI/2*f;if(o===0)e.moveTo(x+Math.cos(v)*y,b+Math.sin(v)*y);e.arc(x,b,y,v,_,m),i=a}}function Ub(e,t,n,s){let r=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),i=(a,l,u)=>({x:a.x+(l.x-a.x)*u,y:a.y+(l.y-a.y)*u}),o=t.length;for(let a=0;a{};class xh{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new fe,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();let n=this._currentPoly.points,s=n[n.length-2],r=n[n.length-1];if(s!==e||r!==t)n.push(e,t);return this}arc(e,t,n,s,r,i){this._ensurePoly(!1);let o=this._currentPoly.points;return Aa(o,e,t,n,s,r,i),this}arcTo(e,t,n,s,r){this._ensurePoly();let i=this._currentPoly.points;return Bb(i,e,t,n,s,r),this}arcToSvg(e,t,n,s,r,i,o){let a=this._currentPoly.points;return Nb(a,this._currentPoly.lastX,this._currentPoly.lastY,i,o,e,t,n,s,r),this}bezierCurveTo(e,t,n,s,r,i,o){this._ensurePoly();let a=this._currentPoly;return Ca(this._currentPoly.points,a.lastX,a.lastY,e,t,n,s,r,i,o),this}quadraticCurveTo(e,t,n,s,r){this._ensurePoly();let i=this._currentPoly;return Ob(this._currentPoly.points,i.lastX,i.lastY,e,t,n,s,r),this}closePath(){return this.endPoly(!0),this}addPath(e,t){if(this.endPoly(),t&&!t.isIdentity())e=e.clone(!0),e.transform(t);let n=this.shapePrimitives,s=n.length;for(let r=0;r1){let r=null;for(let i=s;i=2;c-=2)if(u[c]===u[c-2]&&u[c-1]===u[c-3])u.splice(c-1,2);return this.poly(u,!0,i)}ellipse(e,t,n,s,r){return this.drawShape(new Yo(e,t,n,s),r),this}roundRect(e,t,n,s,r,i){return this.drawShape(new Ho(e,t,n,s,r),i),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let n=this._currentPoly;if(n)this.endPoly();return n=new Xs,n.points.push(e,t),this._currentPoly=n,this}endPoly(e=!1){let t=this._currentPoly;if(t&&t.points.length>2)t.closePath=e,this.shapePrimitives.push({shape:t});return this._currentPoly=null,this}_ensurePoly(e=!0){if(this._currentPoly)return;if(this._currentPoly=new Xs,e){let t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let n=t.shape.x,s=t.shape.y;if(t.transform&&!t.transform.isIdentity()){let r=t.transform,i=n;n=r.a*n+r.c*s+r.tx,s=r.b*i+r.d*s+r.ty}this._currentPoly.points.push(n,s)}else this._currentPoly.points.push(0,0)}}buildPath(){let e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t{Wg();Xg();jg();et();Yg();ft();fh();Ib();ph();Db();Gb();Wb();sA=new Q});class Bt{constructor(e,t=!1){if(this.instructions=[],this.uid=ee("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e==="string")dx(e,this);else this.instructions=e?.slice()??[]}get shapePath(){if(!this._shapePath)this._shapePath=new xh(this);if(this._dirty)this._dirty=!1,this._shapePath.buildPath();return this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,n,s,r){let i=this.instructions[this.instructions.length-1],o=this.getLastPoint(ie.shared),a=0,l=0;if(!i||i.action!=="bezierCurveTo")a=o.x,l=o.y;else{a=i.data[2],l=i.data[3];let{x:u,y:c}=o;a=u+(u-a),l=c+(c-l)}return this.instructions.push({action:"bezierCurveTo",data:[a,l,e,t,n,s,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,n){let s=this.instructions[this.instructions.length-1],r=this.getLastPoint(ie.shared),i=0,o=0;if(!s||s.action!=="quadraticCurveTo")i=r.x,o=r.y;else{i=s.data[0],o=s.data[1];let{x:a,y:l}=r;i=a+(a-i),o=l+(l-o)}return this.instructions.push({action:"quadraticCurveTo",data:[i,o,e,t,n]}),this._dirty=!0,this}rect(e,t,n,s,r){return this.instructions.push({action:"rect",data:[e,t,n,s,r]}),this._dirty=!0,this}circle(e,t,n,s){return this.instructions.push({action:"circle",data:[e,t,n,s]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,n,s,r,i,o){r||(r=s/2);let a=-1*Math.PI/2+i,l=n*2,u=Math.PI*2/l,c=[];for(let h=0;h{jt();qe();Pe();fx();Xb()});function ze(e,t,n){let s=e.getAttribute(t);return s?Number(s):n}var bh=()=>{};function jb(e,t){let n=e.querySelectorAll("defs");for(let s=0;s{Pt();ka();bh()});function vh(e){let t=e.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}var zb=()=>{};function _h(e,t){let n=e.getAttribute("style"),s={},r={},i={strokeStyle:s,fillStyle:r,useFill:!1,useStroke:!1};for(let o in qb){let a=e.getAttribute(o);if(a)Kb(t,i,o,a.trim())}if(n){let o=n.split(";");for(let a=0;a{Pt();zb();qb={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}}});function Zb(e){if(e.length<=2)return!0;let t=e.map((a)=>a.area).sort((a,l)=>l-a),[n,s]=t,r=t[t.length-1],i=n/s,o=s/r;if(i>3&&o<2)return!1;return!0}var Qb=()=>{};function e0(e){return e.split(/(?=[Mm])/).filter((s)=>s.trim().length>0)}function t0(e){let t=e.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;let n=t.map(Number),s=[],r=[];for(let c=0;c{Ea()});function s0(e,t){if(typeof e==="string"){let o=document.createElement("div");o.innerHTML=e.trim(),e=o.querySelector("svg")}let n={context:t,defs:{},path:new Bt};jb(e,n);let s=e.children,{fillStyle:r,strokeStyle:i}=_h(e,n);for(let o=0;o1;if(O&&R){let I=A.map((B)=>({path:B,area:t0(B)}));if(I.sort((B,C)=>C.area-B.area),A.length>3||!Zb(I))for(let B=0;BparseInt(T,10)),t.context.poly(b,!0),n)t.context.fill(n);if(s)t.context.stroke(s);break;case"polyline":if(v=e.getAttribute("points"),b=v.match(/-?\d+/g).map((T)=>parseInt(T,10)),t.context.poly(b,!1),s)t.context.stroke(s);break;case"g":case"svg":break;default:{V(`[SVG parser] <${e.nodeName}> elements unsupported`);break}}if(a)n=null;for(let T=0;T{Pe();Ea();Hb();bh();Jb();Qb();n0()});function oA(e){return e.texture!==void 0}class kh{constructor(e,t){this.uid=ee("fillPattern"),this._tick=0,this.transform=new U;let n=oA(e)?e:{texture:e,repetition:t};this.texture=n.texture,this.textureSpace=n.textureSpace??"global";let s=n.repetition;if(s)this.texture.source.style.addressModeU=o0[s].addressModeU,this.texture.source.style.addressModeV=o0[s].addressModeV}setTransform(e){if(e){if(this.transform.equals(e))return;this.transform.copyFrom(e)}else{if(this.transform.isIdentity())return;this.transform.identity()}this._tick++}get texture(){return this._texture}set texture(e){if(this._texture===e)return;this._texture=e,this._tick++}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var o0;var a0=w(()=>{me();qe();o0={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"}}});function aA(e){return he.isColorLike(e)}function l0(e){return e instanceof kh}function c0(e){return e instanceof On}function lA(e){return e instanceof j}function cA(e,t,n){let s=he.shared.setValue(t??0);return e.color=s.toNumber(),e.alpha=s.alpha===1?n.alpha:s.alpha,e.texture=j.WHITE,{...n,...e}}function uA(e,t,n){return e.texture=t,{...n,...e}}function u0(e,t,n){return e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,e.textureSpace=t.textureSpace,{...n,...e}}function h0(e,t,n){return t.buildGradient(),e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,e.textureSpace=t.textureSpace,{...n,...e}}function hA(e,t){let n={...t,...e},s=he.shared.setValue(n.color);return n.alpha*=s.alpha,n.color=s.toNumber(),n}function or(e,t){if(e===void 0||e===null)return null;let n={},s=e;if(aA(e))return cA(n,e,t);else if(lA(e))return uA(n,e,t);else if(l0(e))return u0(n,e,t);else if(c0(e))return h0(n,e,t);else if(s.fill&&l0(s.fill))return u0(s,s.fill,t);else if(s.fill&&c0(s.fill))return h0(s,s.fill,t);return hA(s,t)}function wh(e,t){let{width:n,alignment:s,miterLimit:r,cap:i,join:o,pixelLine:a,...l}=t,u=or(e,l);if(!u)return null;return{width:n,alignment:s,miterLimit:r,cap:i,join:o,pixelLine:a,...u}}var d0=w(()=>{Pt();De();ka();a0()});function f0(e,t){let n=1,s=e.shapePath.shapePrimitives;for(let r=0;r1)A=1;let O=Math.sqrt((1-A)*0.5);if(O<0.000001)continue;let R=Math.min(1/O,t);if(R>n)n=R}}return n}var m0=()=>{};var dA,p0,Mh,ar;var g0=w(()=>{Ke();Pt();me();jt();De();qe();Re();ft();Ea();i0();d0();m0();dA=new ie,p0=new U,Mh=class e extends de{constructor(){super(...arguments);this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ee("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Bt,this._transform=new U,this._fillStyle={...e.defaultFillStyle},this._strokeStyle={...e.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new fe,this._boundsDirty=!0}clone(){let t=new e;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=or(t,e.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=wh(t,e.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=or(t,e.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=or(t,e.defaultStrokeStyle),this}texture(t,n,s,r,i,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:r||0,dw:i||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:n||n===0?he.shared.setValue(n).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Bt,this}fill(t,n){let s,r=this.instructions[this.instructions.length-1];if(this._tick===0&&r?.action==="stroke")s=r.data.path;else s=this._activePath.clone();if(!s)return this;if(t!=null){if(n!==void 0&&typeof t==="number")X(ae,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:n};this._fillStyle=or(t,e.defaultFillStyle)}return this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this}_initNextPathLocation(){let{x:t,y:n}=this._activePath.getLastPoint(ie.shared);this._activePath.clear(),this._activePath.moveTo(t,n)}stroke(t){let n,s=this.instructions[this.instructions.length-1];if(this._tick===0&&s?.action==="fill")n=s.data.path;else n=this._activePath.clone();if(!n)return this;if(t!=null)this._strokeStyle=wh(t,e.defaultStrokeStyle);return this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this}cut(){for(let t=0;t<2;t++){let n=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(n){if(n.action==="stroke"||n.action==="fill")if(n.data.hole)n.data.hole.addPath(s);else{n.data.hole=s;break}}}return this._initNextPathLocation(),this}arc(t,n,s,r,i,o){this._tick++;let a=this._transform;return this._activePath.arc(a.a*t+a.c*n+a.tx,a.b*t+a.d*n+a.ty,s,r,i,o),this}arcTo(t,n,s,r,i){this._tick++;let o=this._transform;return this._activePath.arcTo(o.a*t+o.c*n+o.tx,o.b*t+o.d*n+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,i),this}arcToSvg(t,n,s,r,i,o,a){this._tick++;let l=this._transform;return this._activePath.arcToSvg(t,n,s,r,i,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,n,s,r,i,o,a){this._tick++;let l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*n+l.tx,l.b*t+l.d*n+l.ty,l.a*s+l.c*r+l.tx,l.b*s+l.d*r+l.ty,l.a*i+l.c*o+l.tx,l.b*i+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,n,s,r){return this._tick++,this._activePath.ellipse(t,n,s,r,this._transform.clone()),this}circle(t,n,s){return this._tick++,this._activePath.circle(t,n,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,n){this._tick++;let s=this._transform;return this._activePath.lineTo(s.a*t+s.c*n+s.tx,s.b*t+s.d*n+s.ty),this}moveTo(t,n){this._tick++;let s=this._transform,r=this._activePath.instructions,i=s.a*t+s.c*n+s.tx,o=s.b*t+s.d*n+s.ty;if(r.length===1&&r[0].action==="moveTo")return r[0].data[0]=i,r[0].data[1]=o,this;return this._activePath.moveTo(i,o),this}quadraticCurveTo(t,n,s,r,i){this._tick++;let o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*n+o.tx,o.b*t+o.d*n+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,i),this}rect(t,n,s,r){return this._tick++,this._activePath.rect(t,n,s,r,this._transform.clone()),this}roundRect(t,n,s,r,i){return this._tick++,this._activePath.roundRect(t,n,s,r,i,this._transform.clone()),this}poly(t,n){return this._tick++,this._activePath.poly(t,n,this._transform.clone()),this}regularPoly(t,n,s,r,i=0,o){return this._tick++,this._activePath.regularPoly(t,n,s,r,i,o),this}roundPoly(t,n,s,r,i,o){return this._tick++,this._activePath.roundPoly(t,n,s,r,i,o),this}roundShape(t,n,s,r){return this._tick++,this._activePath.roundShape(t,n,s,r),this}filletRect(t,n,s,r,i){return this._tick++,this._activePath.filletRect(t,n,s,r,i),this}chamferRect(t,n,s,r,i,o){return this._tick++,this._activePath.chamferRect(t,n,s,r,i,o),this}star(t,n,s,r,i=0,o=0){return this._tick++,this._activePath.star(t,n,s,r,i,o,this._transform.clone()),this}svg(t){return this._tick++,s0(t,this),this}restore(){let t=this._stateStack.pop();if(t)this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle;return 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(t){return this._transform.rotate(t),this}scale(t,n=t){return this._transform.scale(t,n),this}setTransform(t,n,s,r,i,o){if(t instanceof U)return this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this;return this._transform.set(t,n,s,r,i,o),this}transform(t,n,s,r,i,o){if(t instanceof U)return this._transform.append(t),this;return p0.set(t,n,s,r,i,o),this._transform.append(p0),this}translate(t,n=t){return this._transform.translate(t,n),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;let t=this._bounds;t.clear();for(let n=0;n{en();g0={}});var Ta;var y0=M(()=>{_a();ah();uh();ka();hh();er();Ta=class Ta extends Xt{constructor(e){let t=lr({name:"batch",bits:[Sa,wa(e),cr]}),n=d0({name:"batch",bits:[f0,m0(e),p0]});super({glProgram:t,gpuProgram:n,resources:{batchSamplers:Ma(e)}});this.maxTextures=e}}});var _i=null,x0,Si;var dh=M(()=>{z();Xx();Vx();y0();x0=class e extends Wx{constructor(t){super(t);this.geometry=new th,this.name=e.extension.name,this.vertexSize=6,_i??(_i=new Ta(t.maxTextures)),this.shader=_i}packAttributes(t,n,s,r,i){let o=i<<16|t.roundPixels&65535,a=t.transform,{a:l,b:u,c,d:h,tx:d,ty:f}=a,{positions:m,uvs:p}=t,{color:y,attributeOffset:g}=t,x=g+t.attributeSize;for(let b=g;bt&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}var Gn=()=>{};function b0(e,t,n,s,r,i,o,a=null){let l=0;n*=t,r*=i;let{a:u,b:c,c:h,d,tx:f,ty:m}=a;while(l{};function fh(e,t,n,s,r){let{a:i,b:o,c:a,d:l,tx:u,ty:c}=t;n||(n=0),s||(s=2),r||(r=e.length/s-n);let h=n*s;for(let d=0;d{};class ur{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){if(this.renderable&&this.applyTransform)return this.renderable.groupBlendMode;return"normal"}get color(){let e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,n=this.renderable;if(n)return wo(t,n.groupColor)+(this.alpha*n.groupAlpha*255<<24);return t+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||rA}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}var rA;var mh=M(()=>{Ce();Oc();rA=new j});var hr,w0,k0;var M0=M(()=>{z();hr={extension:{type:D.ShapeBuilder,name:"circle"},build(e,t){let n,s,r,i,o,a;if(e.type==="circle"){let v=e;if(o=a=v.radius,o<=0)return!1;n=v.x,s=v.y,r=i=0}else if(e.type==="ellipse"){let v=e;if(o=v.halfWidth,a=v.halfHeight,o<=0||a<=0)return!1;n=v.x,s=v.y,r=i=0}else{let v=e,_=v.width/2,S=v.height/2;n=v.x+_,s=v.y+S,o=a=Math.max(0,Math.min(v.radius,Math.min(_,S))),r=_-o,i=S-a}if(r<0||i<0)return!1;let l=Math.ceil(2.3*Math.sqrt(o+a)),u=l*8+(r?4:0)+(i?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=n+r,t[1]=t[3]=s+i,t[2]=t[4]=n-r,t[5]=t[7]=s-i,!0;let c=0,h=l*4+(r?2:0)+2,d=h,f=u,m=r+o,p=i,y=n+m,g=n-m,x=s+p;if(t[c++]=y,t[c++]=x,t[--h]=x,t[--h]=g,i){let v=s-p;t[d++]=g,t[d++]=v,t[--f]=v,t[--f]=y}for(let v=1;v0)r[i++]=l,r[i++]=u,r[i++]=l-1;l++}r[i++]=u+1,r[i++]=u,r[i++]=l-1}},w0={...hr,extension:{...hr.extension,name:"ellipse"}},k0={...hr,extension:{...hr.extension,name:"roundedRectangle"}}});var Ca=0.0001,ph=0.0001;var gh=()=>{};function T0(e,t,n,s,r,i,o,a){let l=e-n*r,u=t-s*r,c=e+n*i,h=t+s*i,d,f;if(o)d=s,f=-n;else d=-s,f=n;let m=l+d,p=u+f,y=c+d,g=h+f;return a.push(m,p),a.push(y,g),2}function bs(e,t,n,s,r,i,o,a){let l=n-e,u=s-t,c=Math.atan2(l,u),h=Math.atan2(r-e,i-t);if(a&&ch)h+=Math.PI*2;let d=c,f=h-c,m=Math.abs(f),p=Math.sqrt(l*l+u*u),y=(15*m*Math.sqrt(p)/Math.PI>>0)+1,g=f/y;if(d+=g,a){o.push(e,t),o.push(n,s);for(let x=1,b=d;x=0){if(a.join==="round")p+=bs(S,k,S-A*I,k-C*I,S-E*I,k-P*I,f,!1)+4;else p+=2;f.push(S-E*R,k-P*R),f.push(S+E*I,k+P*I)}continue}let H=(-A+v)*(-C+k)-(-A+S)*(-C+_),Z=(-E+w)*(-P+k)-(-E+S)*(-P+T),V=(U*Z-ee*H)/F,Q=(W*H-J*Z)/F,he=(V-S)*(V-S)+(Q-k)*(Q-k),re=S+(V-S)*I,Ae=k+(Q-k)*I,ae=S-(V-S)*R,Pe=k-(Q-k)*R,De=Math.min(U*U+J*J,ee*ee+W*W),oe=G?I:R,Ee=De+oe*oe*x;if(he<=Ee)if(a.join==="bevel"||he/x>b){if(G)f.push(re,Ae),f.push(S+A*R,k+C*R),f.push(re,Ae),f.push(S+E*R,k+P*R);else f.push(S-A*I,k-C*I),f.push(ae,Pe),f.push(S-E*I,k-P*I),f.push(ae,Pe);p+=2}else if(a.join==="round")if(G)f.push(re,Ae),f.push(S+A*R,k+C*R),p+=bs(S,k,S+A*R,k+C*R,S+E*R,k+P*R,f,!0)+4,f.push(re,Ae),f.push(S+E*R,k+P*R);else f.push(S-A*I,k-C*I),f.push(ae,Pe),p+=bs(S,k,S-A*I,k-C*I,S-E*I,k-P*I,f,!1)+4,f.push(S-E*I,k-P*I),f.push(ae,Pe);else f.push(re,Ae),f.push(ae,Pe);else{if(f.push(S-A*I,k-C*I),f.push(S+A*R,k+C*R),a.join==="round")if(G)p+=bs(S,k,S+A*R,k+C*R,S+E*R,k+P*R,f,!0)+2;else p+=bs(S,k,S-A*I,k-C*I,S-E*I,k-P*I,f,!1)+2;else if(a.join==="miter"&&he/x<=b){if(G)f.push(ae,Pe),f.push(ae,Pe);else f.push(re,Ae),f.push(re,Ae);p+=2}f.push(S-E*I,k-P*I),f.push(S+E*R,k+P*R),p+=2}}if(v=e[(m-2)*2],_=e[(m-2)*2+1],S=e[(m-1)*2],k=e[(m-1)*2+1],A=-(_-k),C=v-S,O=Math.sqrt(A*A+C*C),A/=O,C/=O,A*=g,C*=g,f.push(S-A*I,k-C*I),f.push(S+A*R,k+C*R),!h){if(a.cap==="round")p+=bs(S-A*(I-R)*0.5,k-C*(I-R)*0.5,S-A*I,k-C*I,S+A*R,k+C*R,f,!1)+2;else if(a.cap==="square")p+=T0(S,k,A,C,I,R,!1,f)}let N=ph*ph;for(let L=y;L{bu();Kt();gh()});function E0(e,t,n,s){let r=Ca;if(e.length===0)return;let i=e[0],o=e[1],a=e[e.length-2],l=e[e.length-1],u=t||Math.abs(i-a){gh()});function Aa(e,t,n,s,r,i,o){let a=xx(e,t,2);if(!a)return;for(let u=0;u{bx()});var iA,R0;var $0=M(()=>{z();yh();iA=[],R0={extension:{type:D.ShapeBuilder,name:"polygon"},build(e,t){for(let n=0;n{z();O0={extension:{type:D.ShapeBuilder,name:"rectangle"},build(e,t){let n=e,{x:s,y:r,width:i,height:o}=n;if(!(i>0&&o>0))return!1;return t[0]=s,t[1]=r,t[2]=s+i,t[3]=r,t[4]=s+i,t[5]=r+o,t[6]=s,t[7]=r+o,!0},triangulate(e,t,n,s,r,i){let o=0;s*=n,t[s+o]=e[0],t[s+o+1]=e[1],o+=n,t[s+o]=e[2],t[s+o+1]=e[3],o+=n,t[s+o]=e[6],t[s+o+1]=e[7],o+=n,t[s+o]=e[4],t[s+o+1]=e[5],o+=n;let a=s/n;r[i++]=a,r[i++]=a+1,r[i++]=a+2,r[i++]=a+1,r[i++]=a+3,r[i++]=a+2}}});var B0;var F0=M(()=>{z();B0={extension:{type:D.ShapeBuilder,name:"triangle"},build(e,t){return t[0]=e.x,t[1]=e.y,t[2]=e.x2,t[3]=e.y2,t[4]=e.x3,t[5]=e.y3,!0},triangulate(e,t,n,s,r,i){let o=0;s*=n,t[s+o]=e[0],t[s+o+1]=e[1],o+=n,t[s+o]=e[2],t[s+o+1]=e[3],o+=n,t[s+o]=e[4],t[s+o+1]=e[5];let a=s/n;r[i++]=a,r[i++]=a+1,r[i++]=a+2}}});function N0(e,t){for(let n=0;n{this.addColorStop(r.offset,r.color)})}addColorStop(t,n){return this.colorStops.push({offset:t,color:we.shared.setValue(n).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:n}=this.start,{x:s,y:r}=this.end,i=s-t,o=r-n,a=i<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(i<0){let y=t;t=s,s=y,i*=-1}if(o<0){let y=n;n=r,r=y,o*=-1}}let l=this.colorStops.length?this.colorStops:D0,u=this._textureSize,{canvas:c,context:h}=G0(u,1),d=!a?h.createLinearGradient(0,0,this._textureSize,0):h.createLinearGradient(this._textureSize,0,0,0);N0(d,l),h.fillStyle=d,h.fillRect(0,0,u,1),this.texture=new K({source:new hn({resource:c,addressMode:this._wrapMode})});let f=Math.sqrt(i*i+o*o),m=Math.atan2(o,i),p=new j;if(p.scale(f/u,1),p.rotate(m),p.translate(t,n),this.textureSpace==="local")p.scale(u,u);this.transform=p}buildGradient(){if(!this.texture)this._tick++;if(this.type==="linear")this.buildLinearGradient();else this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;let t=this.colorStops.length?this.colorStops:D0,n=this._textureSize,{canvas:s,context:r}=G0(n,n),{x:i,y:o}=this.center,{x:a,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,h=a-c,d=l-c,f=n/(c*2),m=(i-h)*f,p=(o-d)*f,y=r.createRadialGradient(m,p,u*f,(a-h)*f,(l-d)*f,c*f);N0(y,t),r.fillStyle=t[t.length-1].color,r.fillRect(0,0,n,n),r.fillStyle=y,r.translate(m,p),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-m,-p),r.fillRect(0,0,n,n),this.texture=new K({source:new hn({resource:s,addressMode:this._wrapMode})});let g=new j;if(this.textureSpace==="local")g.scale(2*c,2*c);else g.scale(1/f,1/f);g.translate(h,d),this.transform=g}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}},Ln;var Ea=M(()=>{Lt();it();Ce();Yo();Ne();Ze();Ie();Fc();D0=[{offset:0,color:"white"},{offset:1,color:"black"}];xh.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};xh.defaultRadialOptions={center:{x:0.5,y:0.5},innerRadius:0,outerRadius:0.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};Ln=xh});function L0(e,t,n,s){let r=t.matrix?e.copyFrom(t.matrix).invert():e.identity();if(t.textureSpace==="local"){let o=n.getBounds(lA);if(t.width)o.pad(t.width);let{x:a,y:l}=o,u=1/o.width,c=1/o.height,h=-a*u,d=-l*c,{a:f,b:m,c:p,d:y}=r;r.a*=u,r.b*=u,r.c*=c,r.d*=c,r.tx=h*f+d*p+r.tx,r.ty=h*m+d*y+r.ty}else if(t.texture.rotate){let{uvs:o,orig:a}=t.texture;r.scale(1/a.width,1/a.height),r.prepend(cA.set(o.x1-o.x0,o.y1-o.y0,o.x3-o.x0,o.y3-o.y0,o.x0,o.y0))}else r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height);let i=t.texture.source.style;if(!(t.fill instanceof Ln)&&i.addressMode==="clamp-to-edge")i.addressMode="repeat",i.update();if(s)r.append(aA.copyFrom(s).invert());return r}var aA,lA,cA;var U0=M(()=>{Ce();st();Ea();aA=new j,lA=new se,cA=new j});function X0(e,t){let{geometryData:n,batches:s}=t;s.length=0,n.indices.length=0,n.vertices.length=0,n.uvs.length=0;for(let r=0;r{let h=[],d=Pa[l.type];if(!d.build(l,h))return;let f=a.length,m=i.length/2,p="triangle-list";if(u)fh(h,u);if(!n)if(c){let b=[],v=h.slice();fA(c).forEach((S)=>{b.push(v.length/2),v.push(...S)}),Aa(v,b,i,2,m,a,f)}else d.triangulate(h,i,2,m,a,f);else{let b=l.closePath??!0,v=t;if(!v.pixelLine)C0(h,v,!1,b,i,a);else E0(h,b,i,a),p="line-list"}let y=o.length/2,g=t.texture;if(g!==K.WHITE){let b=L0(hA,t,l,u);b0(i,2,m,o,y,2,i.length/2-m,b)}else v0(o,y,2,i.length/2-m);let x=Re.get(ur);x.indexOffset=f,x.indexSize=a.length-f,x.attributeOffset=m,x.attributeSize=i.length/2-m,x.baseColor=t.color,x.alpha=t.alpha,x.texture=g,x.geometryData=r,x.topology=p,s.push(x)})}function fA(e){let t=[];for(let n=0;n{z();Ce();st();_0();S0();Ne();xn();mh();M0();A0();P0();$0();I0();F0();U0();yh();Pa={};ne.handleByMap(D.ShapeBuilder,Pa);ne.add(O0,R0,B0,hr,w0,k0);uA=new se,hA=new j});class j0{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){if(this.batches)this.batches.forEach((e)=>{Re.return(e)});if(this.graphicsData)Re.return(this.graphicsData);this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Y0{constructor(){this.instructions=new is}init(e){let t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new Si({maxTextures:t}),this.instructions.reset()}get geometry(){return q(Jm,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}var bh=class e{constructor(t){this._renderer=t,this._managedContexts=new bt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){let n=!!t._gpuData[this._renderer.uid],s=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!n){if(n)s.reset();X0(t,s);let r=t.batchMode;if(t.customShader||r==="no-batch")s.isBatchable=!1;else if(r==="auto")s.isBatchable=s.geometryData.vertices.length<400;else s.isBatchable=!0;t.dirty=!1}return s}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){let n=Re.get(Y0,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:r,geometryData:i}=s;s.graphicsData=n;let o=i.vertices.length,a=i.indices.length;for(let h=0;h{z();Rx();dh();Mo();Gn();Ie();xn();V0();bh.extension={type:[D.WebGLSystem,D.WebGPUSystem],name:"graphicsContext"};bh.defaultOptions={bezierSmoothness:0.5};dr=bh});function Oa(e,t,n,s,r,i,o,a,l,u){let h=Math.min(0.99,Math.max(0,u??dr.defaultOptions.bezierSmoothness)),d=(pA-h)/1;return d*=d,gA(t,n,s,r,i,o,a,l,e,d),e}function gA(e,t,n,s,r,i,o,a,l,u){_h(e,t,n,s,r,i,o,a,l,u,0),l.push(o,a)}function _h(e,t,n,s,r,i,o,a,l,u,c){if(c>mA)return;let h=Math.PI,d=(e+n)/2,f=(t+s)/2,m=(n+r)/2,p=(s+i)/2,y=(r+o)/2,g=(i+a)/2,x=(d+m)/2,b=(f+p)/2,v=(m+y)/2,_=(p+g)/2,S=(x+v)/2,k=(b+_)/2;if(c>0){let w=o-e,T=a-t,A=Math.abs((n-o)*T-(s-a)*w),C=Math.abs((r-o)*T-(i-a)*w),E,P;if(A>$a&&C>$a){if((A+C)*(A+C)<=u*(w*w+T*T)){if(fr=h)E=2*h-E;if(P>=h)P=2*h-P;if(E+Pvs){l.push(n,s);return}if(P>vs){l.push(r,i);return}}}}else if(A>$a){if(A*A<=u*(w*w+T*T)){if(fr=h)E=2*h-E;if(Evs){l.push(n,s);return}}}}else if(C>$a){if(C*C<=u*(w*w+T*T)){if(fr=h)E=2*h-E;if(Evs){l.push(r,i);return}}}}else if(w=S-(e+o)/2,T=k-(t+a)/2,w*w+T*T<=u){l.push(S,k);return}}_h(e,t,d,f,x,b,S,k,l,u,c+1),_h(S,k,v,_,y,g,o,a,l,u,c+1)}var mA=8,$a=0.00000011920929,pA=1,vh=0.01,fr=0,vs=0;var Sh=M(()=>{Ra()});function z0(e,t,n,s,r,i,o,a){let u=Math.min(0.99,Math.max(0,a??dr.defaultOptions.bezierSmoothness)),c=(bA-u)/1;return c*=c,_A(t,n,s,r,i,o,e,c),e}function _A(e,t,n,s,r,i,o,a){wh(o,e,t,n,s,r,i,a,0),o.push(r,i)}function wh(e,t,n,s,r,i,o,a,l){if(l>yA)return;let u=Math.PI,c=(t+s)/2,h=(n+r)/2,d=(s+i)/2,f=(r+o)/2,m=(c+d)/2,p=(h+f)/2,y=i-t,g=o-n,x=Math.abs((s-i)*g-(r-o)*y);if(x>xA){if(x*x<=a*(y*y+g*g)){if(H0=u)b=2*u-b;if(b{Ra()});function Ia(e,t,n,s,r,i,o,a){let l=Math.abs(r-i);if(!o&&r>i)l=2*Math.PI-l;else if(o&&i>r)l=2*Math.PI-l;a||(a=Math.max(6,Math.floor(6*Math.pow(s,0.3333333333333333)*(l/Math.PI)))),a=Math.max(a,3);let u=l/a,c=r;u*=o?-1:1;for(let h=0;h{};function K0(e,t,n,s,r,i){let o=e[e.length-2],l=e[e.length-1]-n,u=o-t,c=r-n,h=s-t,d=Math.abs(l*h-u*c);if(d<0.00000001||i===0){if(e[e.length-2]!==t||e[e.length-1]!==n)e.push(t,n);return}let f=l*l+u*u,m=c*c+h*h,p=l*c+u*h,y=i*Math.sqrt(f)/d,g=i*Math.sqrt(m)/d,x=y*p/f,b=g*p/m,v=y*h+g*u,_=y*c+g*l,S=u*(g+x),k=l*(g+x),w=h*(y+b),T=c*(y+b),A=Math.atan2(k-_,S-v),C=Math.atan2(T-_,w-v);Ia(e,v+t,_+n,i,A,C,u*c>h*l)}var J0=M(()=>{kh()});function SA(e,t){let n=t===-1.5707963267948966?-0.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?0.551915024494:n,r=Math.cos(e),i=Math.sin(e),o=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-i*s,y:i+r*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}function Q0(e,t,n,s,r,i,o,a=0,l=0,u=0){if(i===0||o===0)return;let c=Math.sin(a*wi/360),h=Math.cos(a*wi/360),d=h*(t-s)/2+c*(n-r)/2,f=-c*(t-s)/2+h*(n-r)/2;if(d===0&&f===0)return;i=Math.abs(i),o=Math.abs(o);let m=Math.pow(d,2)/Math.pow(i,2)+Math.pow(f,2)/Math.pow(o,2);if(m>1)i*=Math.sqrt(m),o*=Math.sqrt(m);wA(t,n,s,r,i,o,l,u,c,h,d,f,Mh);let{ang1:p,ang2:y}=Mh,{centerX:g,centerY:x}=Mh,b=Math.abs(y)/(wi/4);if(Math.abs(1-b)<0.0000001)b=1;let v=Math.max(Math.ceil(b),1);y/=v;let _=e[e.length-2],S=e[e.length-1],k={x:0,y:0};for(let w=0;w{e*=n,t*=s;let u=r*e-i*t,c=i*e+r*t;return l.x=u+o,l.y=c+a,l},Z0=(e,t,n,s)=>{let r=e*s-t*n<0?-1:1,i=e*n+t*s;if(i>1)i=1;if(i<-1)i=-1;return r*Math.acos(i)},wA=(e,t,n,s,r,i,o,a,l,u,c,h,d)=>{let f=Math.pow(r,2),m=Math.pow(i,2),p=Math.pow(c,2),y=Math.pow(h,2),g=f*m-f*y-m*p;if(g<0)g=0;g/=f*y+m*p,g=Math.sqrt(g)*(o===a?-1:1);let x=g*r/i*h,b=g*-i/r*c,v=u*x-l*b+(e+n)/2,_=l*x+u*b+(t+s)/2,S=(c-x)/r,k=(h-b)/i,w=(-c-x)/r,T=(-h-b)/i,A=Z0(1,0,S,k),C=Z0(S,k,w,T);if(a===0&&C>0)C-=wi;if(a===1&&C<0)C+=wi;d.centerX=v,d.centerY=_,d.ang1=A,d.ang2=C};var eb=M(()=>{Sh();wi=Math.PI*2,Mh={centerX:0,centerY:0,ang1:0,ang2:0}});function tb(e,t,n){let s=(o,a)=>{let l=a.x-o.x,u=a.y-o.y,c=Math.sqrt(l*l+u*u),h=l/c,d=u/c;return{len:c,nx:h,ny:d}},r=(o,a)=>{if(o===0)e.moveTo(a.x,a.y);else e.lineTo(a.x,a.y)},i=t[t.length-1];for(let o=0;o0)f=-1,m=!0;let p=d/2,y,g=Math.abs(Math.cos(p)*l/Math.sin(p));if(g>Math.min(c.len/2,h.len/2))g=Math.min(c.len/2,h.len/2),y=Math.abs(g*Math.sin(p)/Math.cos(p));else y=l;let x=a.x+h.nx*g+-h.ny*y*f,b=a.y+h.ny*g+h.nx*y*f,v=Math.atan2(c.ny,c.nx)+Math.PI/2*f,_=Math.atan2(h.ny,h.nx)-Math.PI/2*f;if(o===0)e.moveTo(x+Math.cos(v)*y,b+Math.sin(v)*y);e.arc(x,b,y,v,_,m),i=a}}function nb(e,t,n,s){let r=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),i=(a,l,u)=>({x:a.x+(l.x-a.x)*u,y:a.y+(l.y-a.y)*u}),o=t.length;for(let a=0;a{};class Ch{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Me,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();let n=this._currentPoly.points,s=n[n.length-2],r=n[n.length-1];if(s!==e||r!==t)n.push(e,t);return this}arc(e,t,n,s,r,i){this._ensurePoly(!1);let o=this._currentPoly.points;return Ia(o,e,t,n,s,r,i),this}arcTo(e,t,n,s,r){this._ensurePoly();let i=this._currentPoly.points;return K0(i,e,t,n,s,r),this}arcToSvg(e,t,n,s,r,i,o){let a=this._currentPoly.points;return Q0(a,this._currentPoly.lastX,this._currentPoly.lastY,i,o,e,t,n,s,r),this}bezierCurveTo(e,t,n,s,r,i,o){this._ensurePoly();let a=this._currentPoly;return Oa(this._currentPoly.points,a.lastX,a.lastY,e,t,n,s,r,i,o),this}quadraticCurveTo(e,t,n,s,r){this._ensurePoly();let i=this._currentPoly;return z0(this._currentPoly.points,i.lastX,i.lastY,e,t,n,s,r),this}closePath(){return this.endPoly(!0),this}addPath(e,t){if(this.endPoly(),t&&!t.isIdentity())e=e.clone(!0),e.transform(t);let n=this.shapePrimitives,s=n.length;for(let r=0;r1){let r=null;for(let i=s;i=2;c-=2)if(u[c]===u[c-2]&&u[c-1]===u[c-3])u.splice(c-1,2);return this.poly(u,!0,i)}ellipse(e,t,n,s,r){return this.drawShape(new Jo(e,t,n,s),r),this}roundRect(e,t,n,s,r,i){return this.drawShape(new Qo(e,t,n,s,r),i),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let n=this._currentPoly;if(n)this.endPoly();return n=new Zs,n.points.push(e,t),this._currentPoly=n,this}endPoly(e=!1){let t=this._currentPoly;if(t&&t.points.length>2)t.closePath=e,this.shapePrimitives.push({shape:t});return this._currentPoly=null,this}_ensurePoly(e=!0){if(this._currentPoly)return;if(this._currentPoly=new Zs,e){let t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let n=t.shape.x,s=t.shape.y;if(t.transform&&!t.transform.isIdentity()){let r=t.transform,i=n;n=r.a*n+r.c*s+r.tx,s=r.b*i+r.d*s+r.ty}this._currentPoly.points.push(n,s)}else this._currentPoly.points.push(0,0)}}buildPath(){let e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t{sy();ry();iy();st();oy();yt();Sh();q0();kh();J0();eb();sb();kA=new se});class Vt{constructor(e,t=!1){if(this.instructions=[],this.uid=ie("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e==="string")Cx(e,this);else this.instructions=e?.slice()??[]}get shapePath(){if(!this._shapePath)this._shapePath=new Ch(this);if(this._dirty)this._dirty=!1,this._shapePath.buildPath();return this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,n,s,r){let i=this.instructions[this.instructions.length-1],o=this.getLastPoint(ue.shared),a=0,l=0;if(!i||i.action!=="bezierCurveTo")a=o.x,l=o.y;else{a=i.data[2],l=i.data[3];let{x:u,y:c}=o;a=u+(u-a),l=c+(c-l)}return this.instructions.push({action:"bezierCurveTo",data:[a,l,e,t,n,s,r]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,n){let s=this.instructions[this.instructions.length-1],r=this.getLastPoint(ue.shared),i=0,o=0;if(!s||s.action!=="quadraticCurveTo")i=r.x,o=r.y;else{i=s.data[0],o=s.data[1];let{x:a,y:l}=r;i=a+(a-i),o=l+(l-o)}return this.instructions.push({action:"quadraticCurveTo",data:[i,o,e,t,n]}),this._dirty=!0,this}rect(e,t,n,s,r){return this.instructions.push({action:"rect",data:[e,t,n,s,r]}),this._dirty=!0,this}circle(e,t,n,s){return this.instructions.push({action:"circle",data:[e,t,n,s]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,n,s,r,i,o){r||(r=s/2);let a=-1*Math.PI/2+i,l=n*2,u=Math.PI*2/l,c=[];for(let h=0;h{Kt();Ze();Be();Ax();rb()});function Ke(e,t,n){let s=e.getAttribute(t);return s?Number(s):n}var Ah=()=>{};function ib(e,t){let n=e.querySelectorAll("defs");for(let s=0;s{Lt();Ea();Ah()});function Eh(e){let t=e.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}var cb=()=>{};function Ph(e,t){let n=e.getAttribute("style"),s={},r={},i={strokeStyle:s,fillStyle:r,useFill:!1,useStroke:!1};for(let o in ub){let a=e.getAttribute(o);if(a)hb(t,i,o,a.trim())}if(n){let o=n.split(";");for(let a=0;a{Lt();cb();ub={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}}});function fb(e){if(e.length<=2)return!0;let t=e.map((a)=>a.area).sort((a,l)=>l-a),[n,s]=t,r=t[t.length-1],i=n/s,o=s/r;if(i>3&&o<2)return!1;return!0}var mb=()=>{};function pb(e){return e.split(/(?=[Mm])/).filter((s)=>s.trim().length>0)}function gb(e){let t=e.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;let n=t.map(Number),s=[],r=[];for(let c=0;c{Ba()});function xb(e,t){if(typeof e==="string"){let o=document.createElement("div");o.innerHTML=e.trim(),e=o.querySelector("svg")}let n={context:t,defs:{},path:new Vt};ib(e,n);let s=e.children,{fillStyle:r,strokeStyle:i}=Ph(e,n);for(let o=0;o1;if(C&&E){let O=A.map((I)=>({path:I,area:gb(I)}));if(O.sort((I,R)=>R.area-I.area),A.length>3||!fb(O))for(let I=0;IparseInt(T,10)),t.context.poly(b,!0),n)t.context.fill(n);if(s)t.context.stroke(s);break;case"polyline":if(v=e.getAttribute("points"),b=v.match(/-?\d+/g).map((T)=>parseInt(T,10)),t.context.poly(b,!1),s)t.context.stroke(s);break;case"g":case"svg":break;default:{te(`[SVG parser] <${e.nodeName}> elements unsupported`);break}}if(a)n=null;for(let T=0;T{Be();Ba();lb();Ah();db();mb();yb()});function CA(e){return e.texture!==void 0}class $h{constructor(e,t){this.uid=ie("fillPattern"),this._tick=0,this.transform=new j;let n=CA(e)?e:{texture:e,repetition:t};this.texture=n.texture,this.textureSpace=n.textureSpace??"global";let s=n.repetition;if(s)this.texture.source.style.addressModeU=_b[s].addressModeU,this.texture.source.style.addressModeV=_b[s].addressModeV}setTransform(e){if(e){if(this.transform.equals(e))return;this.transform.copyFrom(e)}else{if(this.transform.isIdentity())return;this.transform.identity()}this._tick++}get texture(){return this._texture}set texture(e){if(this._texture===e)return;this._texture=e,this._tick++}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var _b;var Sb=M(()=>{Ce();Ze();_b={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"}}});function AA(e){return we.isColorLike(e)}function wb(e){return e instanceof $h}function kb(e){return e instanceof Ln}function EA(e){return e instanceof K}function PA(e,t,n){let s=we.shared.setValue(t??0);return e.color=s.toNumber(),e.alpha=s.alpha===1?n.alpha:s.alpha,e.texture=K.WHITE,{...n,...e}}function RA(e,t,n){return e.texture=t,{...n,...e}}function Mb(e,t,n){return e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,e.textureSpace=t.textureSpace,{...n,...e}}function Tb(e,t,n){return t.buildGradient(),e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,e.textureSpace=t.textureSpace,{...n,...e}}function $A(e,t){let n={...t,...e},s=we.shared.setValue(n.color);return n.alpha*=s.alpha,n.color=s.toNumber(),n}function pr(e,t){if(e===void 0||e===null)return null;let n={},s=e;if(AA(e))return PA(n,e,t);else if(EA(e))return RA(n,e,t);else if(wb(e))return Mb(n,e,t);else if(kb(e))return Tb(n,e,t);else if(s.fill&&wb(s.fill))return Mb(s,s.fill,t);else if(s.fill&&kb(s.fill))return Tb(s,s.fill,t);return $A(s,t)}function Oh(e,t){let{width:n,alignment:s,miterLimit:r,cap:i,join:o,pixelLine:a,...l}=t,u=pr(e,l);if(!u)return null;return{width:n,alignment:s,miterLimit:r,cap:i,join:o,pixelLine:a,...u}}var Cb=M(()=>{Lt();Ne();Ea();Sb()});function Ab(e,t){let n=1,s=e.shapePath.shapePrimitives;for(let r=0;r1)A=1;let C=Math.sqrt((1-A)*0.5);if(C<0.000001)continue;let E=Math.min(1/C,t);if(E>n)n=E}}return n}var Eb=()=>{};var OA,Pb,Ih,gr;var Rb=M(()=>{Qe();Lt();Ce();Kt();Ne();Ze();Ie();yt();Ba();vb();Cb();Eb();OA=new ue,Pb=new j,Ih=class e extends ke{constructor(){super(...arguments);this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ie("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new Vt,this._transform=new j,this._fillStyle={...e.defaultFillStyle},this._strokeStyle={...e.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Me,this._boundsDirty=!0}clone(){let t=new e;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=pr(t,e.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Oh(t,e.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=pr(t,e.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=pr(t,e.defaultStrokeStyle),this}texture(t,n,s,r,i,o){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:r||0,dw:i||t.frame.width,dh:o||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:n||n===0?we.shared.setValue(n).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new Vt,this}fill(t,n){let s,r=this.instructions[this.instructions.length-1];if(this._tick===0&&r?.action==="stroke")s=r.data.path;else s=this._activePath.clone();if(!s)return this;if(t!=null){if(n!==void 0&&typeof t==="number")q(be,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:n};this._fillStyle=pr(t,e.defaultFillStyle)}return this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this}_initNextPathLocation(){let{x:t,y:n}=this._activePath.getLastPoint(ue.shared);this._activePath.clear(),this._activePath.moveTo(t,n)}stroke(t){let n,s=this.instructions[this.instructions.length-1];if(this._tick===0&&s?.action==="fill")n=s.data.path;else n=this._activePath.clone();if(!n)return this;if(t!=null)this._strokeStyle=Oh(t,e.defaultStrokeStyle);return this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this}cut(){for(let t=0;t<2;t++){let n=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(n){if(n.action==="stroke"||n.action==="fill")if(n.data.hole)n.data.hole.addPath(s);else{n.data.hole=s;break}}}return this._initNextPathLocation(),this}arc(t,n,s,r,i,o){this._tick++;let a=this._transform;return this._activePath.arc(a.a*t+a.c*n+a.tx,a.b*t+a.d*n+a.ty,s,r,i,o),this}arcTo(t,n,s,r,i){this._tick++;let o=this._transform;return this._activePath.arcTo(o.a*t+o.c*n+o.tx,o.b*t+o.d*n+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,i),this}arcToSvg(t,n,s,r,i,o,a){this._tick++;let l=this._transform;return this._activePath.arcToSvg(t,n,s,r,i,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(t,n,s,r,i,o,a){this._tick++;let l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*n+l.tx,l.b*t+l.d*n+l.ty,l.a*s+l.c*r+l.tx,l.b*s+l.d*r+l.ty,l.a*i+l.c*o+l.tx,l.b*i+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,n,s,r){return this._tick++,this._activePath.ellipse(t,n,s,r,this._transform.clone()),this}circle(t,n,s){return this._tick++,this._activePath.circle(t,n,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,n){this._tick++;let s=this._transform;return this._activePath.lineTo(s.a*t+s.c*n+s.tx,s.b*t+s.d*n+s.ty),this}moveTo(t,n){this._tick++;let s=this._transform,r=this._activePath.instructions,i=s.a*t+s.c*n+s.tx,o=s.b*t+s.d*n+s.ty;if(r.length===1&&r[0].action==="moveTo")return r[0].data[0]=i,r[0].data[1]=o,this;return this._activePath.moveTo(i,o),this}quadraticCurveTo(t,n,s,r,i){this._tick++;let o=this._transform;return this._activePath.quadraticCurveTo(o.a*t+o.c*n+o.tx,o.b*t+o.d*n+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,i),this}rect(t,n,s,r){return this._tick++,this._activePath.rect(t,n,s,r,this._transform.clone()),this}roundRect(t,n,s,r,i){return this._tick++,this._activePath.roundRect(t,n,s,r,i,this._transform.clone()),this}poly(t,n){return this._tick++,this._activePath.poly(t,n,this._transform.clone()),this}regularPoly(t,n,s,r,i=0,o){return this._tick++,this._activePath.regularPoly(t,n,s,r,i,o),this}roundPoly(t,n,s,r,i,o){return this._tick++,this._activePath.roundPoly(t,n,s,r,i,o),this}roundShape(t,n,s,r){return this._tick++,this._activePath.roundShape(t,n,s,r),this}filletRect(t,n,s,r,i){return this._tick++,this._activePath.filletRect(t,n,s,r,i),this}chamferRect(t,n,s,r,i,o){return this._tick++,this._activePath.chamferRect(t,n,s,r,i,o),this}star(t,n,s,r,i=0,o=0){return this._tick++,this._activePath.star(t,n,s,r,i,o,this._transform.clone()),this}svg(t){return this._tick++,xb(t,this),this}restore(){let t=this._stateStack.pop();if(t)this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle;return 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(t){return this._transform.rotate(t),this}scale(t,n=t){return this._transform.scale(t,n),this}setTransform(t,n,s,r,i,o){if(t instanceof j)return this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this;return this._transform.set(t,n,s,r,i,o),this}transform(t,n,s,r,i,o){if(t instanceof j)return this._transform.append(t),this;return Pb.set(t,n,s,r,i,o),this._transform.append(Pb),this}translate(t,n=t){return this._transform.translate(t,n),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;let t=this._bounds;t.clear();for(let n=0;n{};var v0=`in vec2 aPosition; +`;var Ib=()=>{};var Bb=`in vec2 aPosition; out vec2 vTextureCoord; out vec2 vMaskCoord; @@ -408,7 +408,7 @@ void main(void) vTextureCoord = filterTextureCoord(aPosition); vMaskCoord = getFilterCoord(aPosition); } -`;var _0=()=>{};var Ch=`struct GlobalFilterUniforms { +`;var Fb=()=>{};var Fh=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, @@ -512,7 +512,7 @@ fn mainFragment( return source * a; } -`;var S0=()=>{};var Ah;var k0=w(()=>{me();En();is();zt();De();Ic();Pe();na();b0();_0();S0();Ah=class Ah extends Vs{constructor(e){let{sprite:t,...n}=e,s=new Gr(t.texture),r=new Ve({uFilterMatrix:{value:new U,type:"mat3x3"},uMaskClamp:{value:s.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"},uChannel:{value:e.channel==="alpha"?1:0,type:"f32"}}),i=xt.from({vertex:{source:Ch,entryPoint:"mainVertex"},fragment:{source:Ch,entryPoint:"mainFragment"}}),o=yt.from({vertex:v0,fragment:x0,name:"mask-filter"});super({...n,gpuProgram:i,glProgram:o,clipToViewport:!1,resources:{filterUniforms:r,uMaskTexture:t.texture.source}});this.sprite=t,this._textureMatrix=s}setSprite(e){this.sprite=e;let t=this._getSafeTexture();this._textureMatrix.texture=t,this.resources.uMaskTexture=t.source}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(e){this.resources.filterUniforms.uniforms.uChannel=e==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(e,t,n,s){let r=this._getSafeTexture();this._textureMatrix.texture=r,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=r.source,e.applyFilter(this,t,n,s)}_getSafeTexture(){let e=this.sprite.texture;if(e.destroyed||!e.source||e.source.destroyed)return V("[MaskFilter] The mask texture was destroyed while the mask is still in use. Remove the mask before destroying its texture."),j.EMPTY;return e}destroy(e=!1){this._textureMatrix.destroy(),super.destroy(e)}}});class w0{constructor(){this.isBatchable=!1}reset(){if(this.isBatchable=!1,this.context=null,this.graphicsData)this.graphicsData.destroy(),this.graphicsData=null}destroy(){this.reset()}}class M0{constructor(){this.instructions=new qn}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}var Eh=class e{constructor(t){this._renderer=t,this._managedContexts=new pt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){let n=t._gpuData,s=!!n[this._renderer.uid],r=n[this._renderer.uid]||this._initContext(t);if(t.dirty||!s){if(s)r.reset();r.isBatchable=!1,t.dirty=!1}return r}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){let n=new M0,s=this.getGpuContext(t);return s.graphicsData=n,n.init(),n}_initContext(t){let n=new w0;return n.context=t,t._gpuData[this._renderer.uid]=n,this._managedContexts.add(t),n}destroy(){this._managedContexts.destroy(),this._renderer=null}},T0;var C0=w(()=>{W();bo();$n();Eh.extension={type:[E.CanvasSystem],name:"graphicsContext"};Eh.defaultOptions={bezierSmoothness:0.5};T0=Eh});class Pa{constructor(e,t){this.state=lt.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new pt({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,t){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){if(!e.isRenderable)return;this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}var A0=w(()=>{W();yn();$n();Pa.extension={type:[E.CanvasPipes],name:"graphics"}});function lr(e,t,n){let s=(e>>24&255)/255;t[n++]=(e&255)/255*s,t[n++]=(e>>8&255)/255*s,t[n++]=(e>>16&255)/255*s,t[n++]=s}var $a=()=>{};class E0{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach((e)=>{Ce.return(e)}),this.batches.length=0}}class Oa{constructor(e,t){this.state=lt.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new pt({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){let t=e.context,n=!!e._gpuData,r=this.renderer.graphicsContext.updateGpuContext(t);if(r.isBatchable||n!==r.isBatchable)return!0;return!1}addRenderable(e,t){let s=this.renderer.graphicsContext.updateGpuContext(e.context);if(e.didViewUpdate||!e._gpuData[this.renderer.uid])this._rebuild(e);if(s.isBatchable)this._addToBatcher(e,t);else this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){let n=this._getGpuDataForRenderable(e).batches;for(let s=0;s{let a=Ce.get(tr);return o.copyTo(a),a.renderable=e,a.roundPixels=i,a})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}var R0=w(()=>{W();yn();$n();dn();$a();ih();Oa.extension={type:[E.WebGLPipes,E.WebGPUPipes],name:"graphics"}});var P0=w(()=>{W();C0();A0();Ma();R0();Z.add(Pa);Z.add(Oa);Z.add(T0);Z.add(sr)});var hs;var $0=w(()=>{Re();Eo();g0();P0();hs=class hs extends ns{constructor(e){if(e instanceof ar)e={context:e};let{context:t,roundPixels:n,...s}=e||{};super({label:"Graphics",...s});if(this.renderPipeId="graphics",!t)this.context=this._ownedContext=new ar,this.context.autoGarbageCollect=this.autoGarbageCollect;else this.context=t;this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=n??!1}set context(e){if(e===this._context)return;if(this._context)this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this);this._context=e,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate()}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(e){return this._context.containsPoint(e)}destroy(e){if(this._ownedContext&&!e)this._ownedContext.destroy(e);else if(e===!0||e?.context===!0)this._context.destroy(e);this._context?.off("update",this.onViewUpdate,this),this._context?.off("unload",this.unload,this),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){if(e)return new hs(this._context.clone());return this._ownedContext=null,new hs(this._context)}lineStyle(e,t,n){X(ae,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");let s={};return e&&(s.width=e),t&&(s.color=t),n&&(s.alpha=n),this.context.strokeStyle=s,this}beginFill(e,t){X(ae,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");let n={};if(e!==void 0)n.color=e;if(t!==void 0)n.alpha=t;return this.context.fillStyle=n,this}endFill(){X(ae,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();let e=this.context.strokeStyle;if(e.width!==ar.defaultStrokeStyle.width||e.color!==ar.defaultStrokeStyle.color||e.alpha!==ar.defaultStrokeStyle.alpha)this.context.stroke();return this}drawCircle(...e){return X(ae,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return X(ae,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return X(ae,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return X(ae,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return X(ae,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return X(ae,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}});var $h,dY,Da;var Oh=w(()=>{$h={name:"local-uniform-bit",vertex:{header:` +`;var Db=()=>{};var Dh;var Nb=M(()=>{Ce();Fn();ps();en();Ne();Xc();Be();la();Ib();Fb();Db();Dh=class Dh extends tr{constructor(e){let{sprite:t,...n}=e,s=new qr(t.texture),r=new ze({uFilterMatrix:{value:new j,type:"mat3x3"},uMaskClamp:{value:s.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"},uChannel:{value:e.channel==="alpha"?1:0,type:"f32"}}),i=kt.from({vertex:{source:Fh,entryPoint:"mainVertex"},fragment:{source:Fh,entryPoint:"mainFragment"}}),o=wt.from({vertex:Bb,fragment:Ob,name:"mask-filter"});super({...n,gpuProgram:i,glProgram:o,clipToViewport:!1,resources:{filterUniforms:r,uMaskTexture:t.texture.source}});this.sprite=t,this._textureMatrix=s}setSprite(e){this.sprite=e;let t=this._getSafeTexture();this._textureMatrix.texture=t,this.resources.uMaskTexture=t.source}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(e){this.resources.filterUniforms.uniforms.uChannel=e==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(e,t,n,s){let r=this._getSafeTexture();this._textureMatrix.texture=r,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=r.source,e.applyFilter(this,t,n,s)}_getSafeTexture(){let e=this.sprite.texture;if(e.destroyed||!e.source||e.source.destroyed)return te("[MaskFilter] The mask texture was destroyed while the mask is still in use. Remove the mask before destroying its texture."),K.EMPTY;return e}destroy(e=!1){this._textureMatrix.destroy(),super.destroy(e)}}});class Gb{constructor(){this.isBatchable=!1}reset(){if(this.isBatchable=!1,this.context=null,this.graphicsData)this.graphicsData.destroy(),this.graphicsData=null}destroy(){this.reset()}}class Lb{constructor(){this.instructions=new is}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}var Nh=class e{constructor(t){this._renderer=t,this._managedContexts=new bt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){let n=t._gpuData,s=!!n[this._renderer.uid],r=n[this._renderer.uid]||this._initContext(t);if(t.dirty||!s){if(s)r.reset();r.isBatchable=!1,t.dirty=!1}return r}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){let n=new Lb,s=this.getGpuContext(t);return s.graphicsData=n,n.init(),n}_initContext(t){let n=new Gb;return n.context=t,t._gpuData[this._renderer.uid]=n,this._managedContexts.add(t),n}destroy(){this._managedContexts.destroy(),this._renderer=null}},Ub;var Wb=M(()=>{z();Mo();Gn();Nh.extension={type:[D.CanvasSystem],name:"graphicsContext"};Nh.defaultOptions={bezierSmoothness:0.5};Ub=Nh});class Da{constructor(e,t){this.state=ft.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new bt({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){return!1}addRenderable(e,t){this._managedGraphics.add(e),this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){}execute(e){if(!e.isRenderable)return;this._adaptor.execute(this,e)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}var Xb=M(()=>{z();wn();Gn();Da.extension={type:[D.CanvasPipes],name:"graphics"}});function yr(e,t,n){let s=(e>>24&255)/255;t[n++]=(e&255)/255*s,t[n++]=(e>>8&255)/255*s,t[n++]=(e>>16&255)/255*s,t[n++]=s}var Na=()=>{};class Vb{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach((e)=>{Re.return(e)}),this.batches.length=0}}class Ga{constructor(e,t){this.state=ft.for2d(),this.renderer=e,this._adaptor=t,this.renderer.runners.contextChange.add(this),this._managedGraphics=new bt({renderer:e,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(e){let t=e.context,n=!!e._gpuData,r=this.renderer.graphicsContext.updateGpuContext(t);if(r.isBatchable||n!==r.isBatchable)return!0;return!1}addRenderable(e,t){let s=this.renderer.graphicsContext.updateGpuContext(e.context);if(e.didViewUpdate||!e._gpuData[this.renderer.uid])this._rebuild(e);if(s.isBatchable)this._addToBatcher(e,t);else this.renderer.renderPipes.batch.break(t),t.add(e)}updateRenderable(e){let n=this._getGpuDataForRenderable(e).batches;for(let s=0;s{let a=Re.get(ur);return o.copyTo(a),a.renderable=e,a.roundPixels=i,a})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}var jb=M(()=>{z();wn();Gn();xn();Na();mh();Ga.extension={type:[D.WebGLPipes,D.WebGPUPipes],name:"graphics"}});var Yb=M(()=>{z();Wb();Xb();Ra();jb();ne.add(Da);ne.add(Ga);ne.add(Ub);ne.add(dr)});var _s;var Hb=M(()=>{Ie();Bo();Rb();Yb();_s=class _s extends ds{constructor(e){if(e instanceof gr)e={context:e};let{context:t,roundPixels:n,...s}=e||{};super({label:"Graphics",...s});if(this.renderPipeId="graphics",!t)this.context=this._ownedContext=new gr,this.context.autoGarbageCollect=this.autoGarbageCollect;else this.context=t;this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=n??!1}set context(e){if(e===this._context)return;if(this._context)this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this);this._context=e,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate()}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(e){return this._context.containsPoint(e)}destroy(e){if(this._ownedContext&&!e)this._ownedContext.destroy(e);else if(e===!0||e?.context===!0)this._context.destroy(e);this._context?.off("update",this.onViewUpdate,this),this._context?.off("unload",this.unload,this),this._ownedContext=null,this._context=null,super.destroy(e)}_onTouch(e){this._gcLastUsed=e,this._context._gcLastUsed=e}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod("setFillStyle",e)}setStrokeStyle(...e){return this._callContextMethod("setStrokeStyle",e)}fill(...e){return this._callContextMethod("fill",e)}stroke(...e){return this._callContextMethod("stroke",e)}texture(...e){return this._callContextMethod("texture",e)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...e){return this._callContextMethod("arc",e)}arcTo(...e){return this._callContextMethod("arcTo",e)}arcToSvg(...e){return this._callContextMethod("arcToSvg",e)}bezierCurveTo(...e){return this._callContextMethod("bezierCurveTo",e)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...e){return this._callContextMethod("ellipse",e)}circle(...e){return this._callContextMethod("circle",e)}path(...e){return this._callContextMethod("path",e)}lineTo(...e){return this._callContextMethod("lineTo",e)}moveTo(...e){return this._callContextMethod("moveTo",e)}quadraticCurveTo(...e){return this._callContextMethod("quadraticCurveTo",e)}rect(...e){return this._callContextMethod("rect",e)}roundRect(...e){return this._callContextMethod("roundRect",e)}poly(...e){return this._callContextMethod("poly",e)}regularPoly(...e){return this._callContextMethod("regularPoly",e)}roundPoly(...e){return this._callContextMethod("roundPoly",e)}roundShape(...e){return this._callContextMethod("roundShape",e)}filletRect(...e){return this._callContextMethod("filletRect",e)}chamferRect(...e){return this._callContextMethod("chamferRect",e)}star(...e){return this._callContextMethod("star",e)}svg(...e){return this._callContextMethod("svg",e)}restore(...e){return this._callContextMethod("restore",e)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...e){return this._callContextMethod("rotate",e)}scaleTransform(...e){return this._callContextMethod("scale",e)}setTransform(...e){return this._callContextMethod("setTransform",e)}transform(...e){return this._callContextMethod("transform",e)}translateTransform(...e){return this._callContextMethod("translate",e)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(e=!1){if(e)return new _s(this._context.clone());return this._ownedContext=null,new _s(this._context)}lineStyle(e,t,n){q(be,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");let s={};return e&&(s.width=e),t&&(s.color=t),n&&(s.alpha=n),this.context.strokeStyle=s,this}beginFill(e,t){q(be,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");let n={};if(e!==void 0)n.color=e;if(t!==void 0)n.alpha=t;return this.context.fillStyle=n,this}endFill(){q(be,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();let e=this.context.strokeStyle;if(e.width!==gr.defaultStrokeStyle.width||e.color!==gr.defaultStrokeStyle.color||e.alpha!==gr.defaultStrokeStyle.alpha)this.context.stroke();return this}drawCircle(...e){return q(be,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",e)}drawEllipse(...e){return q(be,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",e)}drawPolygon(...e){return q(be,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",e)}drawRect(...e){return q(be,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",e)}drawRoundedRect(...e){return q(be,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",e)}drawStar(...e){return q(be,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",e)}}});var Uh,Nj,Wa;var Wh=M(()=>{Uh={name:"local-uniform-bit",vertex:{header:` struct LocalUniforms { uTransformMatrix:mat3x3, @@ -529,7 +529,7 @@ fn mainFragment( { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } - `}},dY={...$h,vertex:{...$h.vertex,header:$h.vertex.header.replace("group(1)","group(2)")}},Da={name:"local-uniform-bit",vertex:{header:` + `}},Nj={...Uh,vertex:{...Uh.vertex,header:Uh.vertex.header.replace("group(1)","group(2)")}},Wa={name:"local-uniform-bit",vertex:{header:` uniform mat3 uTransformMatrix; uniform vec4 uColor; @@ -542,7 +542,7 @@ fn mainFragment( { gl_Position.xy = roundPixels(gl_Position.xy, uResolution); } - `}}});class pi{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}var Ih=()=>{};function I0(){let{userAgent:e}=ne.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}var B0=w(()=>{nt()});class Fa{constructor(){this._tempState=lt.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,n){let s=e.renderer,r=this._didUploadHash[n.uid];if(s.shader.bind(n,r),!r)this._didUploadHash[n.uid]=!0;s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(t,n.glProgram)}execute(e,t){let n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);let s=t.textures.textures;for(let r=0;r{W();yn();Fa.extension={type:[E.WebGLPipesAdaptor],name:"batch"}});var Bh=class e{constructor(t,n){this.state=lt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=n,this._adaptor.init?.(this)}static getBatcher(t,n){return new this._availableBatchers[t]({maxTextures:n})}buildStart(t){let n=this._batchersByInstructionSet[t.uid];if(!n)n=this._batchersByInstructionSet[t.uid]=Object.create(null),n.default||(n.default=new di({maxTextures:this.renderer.limits.maxBatchableTextures}));this._activeBatches=n,this._activeBatch=this._activeBatches.default;for(let s in this._activeBatches)this._activeBatches[s].begin()}addToBatch(t,n){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(n);let s=this._activeBatches[t.batcherName];if(!s)s=this._activeBatches[t.batcherName]=e.getBatcher(t.batcherName,this.renderer.limits.maxBatchableTextures),s.begin();this._activeBatch=s}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);let n=this._activeBatches;for(let s in n){let r=n[s],i=r.geometry;i.indexBuffer.setDataWithSize(r.indexBuffer,r.indexSize,!0),i.buffers[0].setDataWithSize(r.attributeBuffer.float32View,r.attributeSize,!1)}}upload(t){let n=this._batchersByInstructionSet[t.uid];for(let s in n){let r=n[s],i=r.geometry;if(r.dirty)r.dirty=!1,i.buffers[0].update(r.attributeSize*4)}}execute(t){if(t.action==="startBatch"){let n=t.batcher,{geometry:s,shader:r}=n;this._adaptor.start(this,s,r)}this._adaptor.execute(this,t)}destroyInstructionSet(t){let n=this._batchersByInstructionSet[t.uid];if(!n)return;for(let s in n)n[s].destroy();if(delete this._batchersByInstructionSet[t.uid],this._activeBatches===n)this._activeBatches=Object.create(null),this._activeBatch=null}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(let t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}},Dh;var F0=w(()=>{W();yn();sh();Bh.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"batch"};Bh._availableBatchers=Object.create(null);Dh=Bh;Z.handleByMap(E.Batcher,Dh._availableBatchers);Z.add(di)});var N0;var G0=w(()=>{N0={name:"texture-bit",vertex:{header:` + `}}});class Mi{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}var Xh=()=>{};function qb(){let{userAgent:e}=le.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}var Kb=M(()=>{it()});class Xa{constructor(){this._tempState=ft.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,n){let s=e.renderer,r=this._didUploadHash[n.uid];if(s.shader.bind(n,r),!r)this._didUploadHash[n.uid]=!0;s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(t,n.glProgram)}execute(e,t){let n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);let s=t.textures.textures;for(let r=0;r{z();wn();Xa.extension={type:[D.WebGLPipesAdaptor],name:"batch"}});var Vh=class e{constructor(t,n){this.state=ft.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=n,this._adaptor.init?.(this)}static getBatcher(t,n){return new this._availableBatchers[t]({maxTextures:n})}buildStart(t){let n=this._batchersByInstructionSet[t.uid];if(!n)n=this._batchersByInstructionSet[t.uid]=Object.create(null),n.default||(n.default=new Si({maxTextures:this.renderer.limits.maxBatchableTextures}));this._activeBatches=n,this._activeBatch=this._activeBatches.default;for(let s in this._activeBatches)this._activeBatches[s].begin()}addToBatch(t,n){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(n);let s=this._activeBatches[t.batcherName];if(!s)s=this._activeBatches[t.batcherName]=e.getBatcher(t.batcherName,this.renderer.limits.maxBatchableTextures),s.begin();this._activeBatch=s}this._activeBatch.add(t)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);let n=this._activeBatches;for(let s in n){let r=n[s],i=r.geometry;i.indexBuffer.setDataWithSize(r.indexBuffer,r.indexSize,!0),i.buffers[0].setDataWithSize(r.attributeBuffer.float32View,r.attributeSize,!1)}}upload(t){let n=this._batchersByInstructionSet[t.uid];for(let s in n){let r=n[s],i=r.geometry;if(r.dirty)r.dirty=!1,i.buffers[0].update(r.attributeSize*4)}}execute(t){if(t.action==="startBatch"){let n=t.batcher,{geometry:s,shader:r}=n;this._adaptor.start(this,s,r)}this._adaptor.execute(this,t)}destroyInstructionSet(t){let n=this._batchersByInstructionSet[t.uid];if(!n)return;for(let s in n)n[s].destroy();if(delete this._batchersByInstructionSet[t.uid],this._activeBatches===n)this._activeBatches=Object.create(null),this._activeBatch=null}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(let t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}},jh;var Zb=M(()=>{z();wn();dh();Vh.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"batch"};Vh._availableBatchers=Object.create(null);jh=Vh;ne.handleByMap(D.Batcher,jh._availableBatchers);ne.add(Si)});var Qb;var ev=M(()=>{Qb={name:"texture-bit",vertex:{header:` uniform mat3 uTextureMatrix; `,main:` uv = (uTextureMatrix * vec3(uv, 1.0)).xy; @@ -552,9 +552,9 @@ fn mainFragment( `,main:` outColor = texture(uTexture, vUV); - `}}});class Na{constructor(e){this._activeMaskStage=[],this._usedEffects=[],this._renderer=e,e.runners.postrender.add(this)}push(e,t,n){let s=this._renderer;if(s.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??"red",e.renderMaskToTexture){let r=e.mask;r.includeInBuild=!0,r.collectRenderables(n,s,null),r.includeInBuild=!1}s.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){let t=this._renderer,n=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){let s=Ce.get(L0);if(s.inverse=e.inverse,s.channel=e.mask.channel,n){e.mask.mask.measurable=!0;let r=Ps(e.mask.mask,!0,fA);e.mask.mask.measurable=!1,r.ceil();let i=t.renderTarget.renderTarget.colorTexture.source,o=Ue.getOptimalTexture({width:r.width,height:r.height,resolution:i._resolution,antialias:i.antialias});t.renderTarget.push({target:o,clear:!0}),t.globalUniforms.push({offset:r,worldColor:4294967295});let a=s.sprite;a.texture=o,a.worldTransform.tx=r.minX,a.worldTransform.ty=r.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer,filterTexture:o})}else s.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){let s=this._activeMaskStage[this._activeMaskStage.length-1];if(n){if(t.type===at.WEBGL)t.renderTarget.finishRenderPass();t.renderTarget.pop(),t.globalUniforms.pop()}t.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();let s=this._activeMaskStage.pop();if(n)Ue.returnTexture(s.filterTexture);this._usedEffects.push(s.filterEffect)}}postrender(){let e=this._usedEffects;for(let t=0;t{W();fo();k0();ft();Dr();Io();dn();De();es();Rn();fA=new fe;L0=class L0 extends kn{constructor(){super();this._placeholderSprite=new Ht(j.EMPTY),this.filters=[new Ah({sprite:this._placeholderSprite,inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].setSprite(e)}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}reset(){this._placeholderSprite.texture=j.EMPTY,this.sprite=this._placeholderSprite}};Na.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"alphaMask"}});class Ga{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];if(i!==this._currentColor)this._currentColor=i,n.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1});this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];if(i!==this._currentColor)this._currentColor=i,n.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1})}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}var W0=w(()=>{W();Ga.extension={type:[E.WebGLPipes,E.WebGPUPipes],name:"colorMask"}});class La{constructor(e){this._maskHash=new WeakMap,this._renderer=e}push(e,t,n){let s=e,r=this._renderer;r.renderPipes.batch.break(n),r.renderPipes.blendMode.setBlendMode(s.mask,"none",n),n.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let i=s.mask;if(i.includeInBuild=!0,!this._maskHash.has(s))this._maskHash.set(s,{instructionsStart:0,instructionsLength:0});let o=this._maskHash.get(s);o.instructionsStart=n.instructionSize,i.collectRenderables(n,r,null),i.includeInBuild=!1,r.renderPipes.batch.break(n),n.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let a=n.instructionSize-o.instructionsStart-1;o.instructionsLength=a}pop(e,t,n){let s=e,r=this._renderer;r.renderPipes.batch.break(n),r.renderPipes.blendMode.setBlendMode(s.mask,"none",n),n.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});let i=this._maskHash.get(e);for(let o=0;o{W();oi();Js();La.extension={type:[E.WebGLPipes,E.WebGPUPipes],name:"stencilMask"}});class Ua{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){if(!e.isRenderable)return;e.render(this._renderer)}destroy(){this._renderer=null}}var j0=w(()=>{W();Ua.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"customRender"}});function gi(e,t){let n=e.instructionSet,s=n.instructions;for(let r=0;r{};class Wa{constructor(e){this._renderer=e}addRenderGroup(e,t){if(e.isCachedAsTexture)this._addRenderableCacheAsTexture(e,t);else this._addRenderableDirect(e,t)}execute(e){if(!e.isRenderable)return;if(e.isCachedAsTexture)this._executeCacheAsTexture(e);else this._executeDirect(e)}destroy(){this._renderer=null}_addRenderableDirect(e,t){if(this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup)Ce.return(e._batchableRenderGroup),e._batchableRenderGroup=null;t.add(e)}_addRenderableCacheAsTexture(e,t){let n=e._batchableRenderGroup??(e._batchableRenderGroup=Ce.get(pi));n.renderable=e.root,n.transform=e.root.relativeGroupTransform,n.texture=e.texture,n.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(n,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;let t=new U().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push({target:e.texture,clear:!0,frame:e.texture.frame}),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),gi(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),gi(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}var Y0=w(()=>{W();me();dn();Ih();Fh();Wa.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"renderGroup"}});class Xa{constructor(e){this._renderer=e}addRenderable(e,t){let n=this._getGpuSprite(e);if(e.didViewUpdate)this._updateBatchableSprite(e,n);this._renderer.renderPipes.batch.addToBatch(n,t)}updateRenderable(e){let t=this._getGpuSprite(e);if(e.didViewUpdate)this._updateBatchableSprite(e,t);t._batcher.updateElement(t)}validateRenderable(e){let t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=new pi;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}var V0=w(()=>{W();Ih();Xa.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"sprite"}});class ja{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,n){this._blendModeStack.push(t),this.setBlendMode(e,t,n)}popBlendMode(e){this._blendModeStack.pop();let t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,n){let s=e instanceof Fs;if(this._activeBlendMode===t){if(this._isAdvanced&&e&&!s)this._renderableList?.push(e);return}if(this._isAdvanced)this._endAdvancedBlendMode(n);if(this._activeBlendMode=t,!e)return;if(this._isAdvanced=!!yi[t],this._isAdvanced)this._beginAdvancedBlendMode(e,n)}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);let n=this._activeBlendMode;if(!yi[n]){V(`Unable to assign BlendMode: '${n}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let s=this._ensureFilterEffect(n),r=e instanceof Fs,i={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:r?null:[e],container:r?e.root:null,canBundle:!1};this._renderableList=i.renderables,t.add(i)}_ensureFilterEffect(e){let t=this._filterHash[e];if(!t)t=this._filterHash[e]=new kn,t.filters=[new yi[e]];return t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){if(!this._isAdvanced)return;this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(let e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}var yi;var H0=w(()=>{W();fo();Fc();Pe();yi={};Z.handle(E.BlendMode,(e)=>{if(!e.name)throw Error("BlendMode extension must have a name property");yi[e.name]=e.ref},(e)=>{delete yi[e.name]});ja.extension={type:[E.WebGLPipes,E.WebGPUPipes,E.CanvasPipes],name:"blendMode"}});function xi(e,t){t||(t=0);for(let n=t;n{};function Gh(e,t=!1){pA(e);let n=e.childrenToUpdate,s=e.updateTick++;for(let r in n){let i=Number(r),o=n[r],{list:a,index:l}=o;for(let u=0;u1?1:n,e.worldAlpha=n,e.worldColorAlpha=e.worldColor+((n*255|0)<<24)}function K0(e,t,n){if(t===e.updateTick)return;e.updateTick=t,e.didChange=!1;let s=e.localTransform;e.updateLocalTransform();let r=e.parent;if(r&&!r.renderGroup){if(n|=e._updateFlags,e.relativeGroupTransform.appendFrom(s,r.relativeGroupTransform),n&z0)q0(e,r,n)}else if(n=e._updateFlags,e.relativeGroupTransform.copyFrom(s),n&z0)q0(e,mA,n);if(!e.renderGroup){let i=e.children,o=i.length;for(let u=0;u1?1:s,e.groupAlpha=s,e.groupColorAlpha=e.groupColor+((s*255|0)<<24)}if(n&Ur)e.groupBlendMode=e.localBlendMode==="inherit"?t.groupBlendMode:e.localBlendMode;if(n&ts)e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus;e._updateFlags=0}var mA,z0;var J0=w(()=>{nn();Nh();Mc();mA=new Fe,z0=ts|Ns|Ur});function Z0(e,t){let{list:n}=e.childrenRenderablesToUpdate,s=!1;for(let r=0;r{};class Ya{constructor(e){this._renderer=e}render({container:e,transform:t}){let n=e.parent,s=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;let r=this._renderer,i=gA;if(t)i.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t);let o=r.renderPipes;if(this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),r.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),gi(e.renderGroup,o),o.uniformBatch)o.uniformBatch.renderEnd();if(t)e.renderGroup.localTransform.copyFrom(i);e.parent=n,e.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let n=e.renderGroupChildren.length-1;n>=0;n--)this._updateCachedRenderGroups(e.renderGroupChildren[n],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){let n=e.root.getLocalBounds(),s=this._renderer,r=e.textureOptions.resolution||s.view.resolution,i=e.textureOptions.antialias??s.view.antialias,o=e.textureOptions.scaleMode??"linear",a=e.texture;if(n.ceil(),e.texture)Ue.returnTexture(e.texture);let l=Ue.getOptimalTexture({width:n.width,height:n.height,resolution:r,antialias:i,scaleMode:o});if(e.texture=l,e._textureBounds||(e._textureBounds=new fe),e._textureBounds.copyFrom(n),a!==e.texture){if(e.renderGroupParent)e.renderGroupParent.structureDidChange=!0}}}else if(e.texture)Ue.returnTexture(e.texture),e.texture=null}_updateRenderGroups(e){let t=this._renderer,n=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=n,!e.structureDidChange)Z0(e,n);else xi(e.childrenRenderablesToUpdate.list,0);if(Gh(e),e.structureDidChange)e.structureDidChange=!1,this._buildInstructions(e,t);else this._updateRenderables(e);if(e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),e.isCachedAsTexture&&!e.textureNeedsUpdate)return;for(let s=0;s{W();me();es();ft();Nh();Fh();J0();Q0();gA=new U;Ya.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"renderGroup"}});var Lh=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new he(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...e.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){if(he.shared.setValue(t).alpha<1&&this._backgroundColor.alpha===1)V("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application.");this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}},tv;var nv=w(()=>{Pt();W();Pe();Lh.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"background",priority:0};Lh.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};tv=Lh});var Uh,Wh=class e{constructor(t){this._renderer=t}_normalizeOptions(t,n={}){if(t instanceof Fe||t instanceof j)return{target:t,...n};return{...n,...t}}async image(t){let n=ne.get().createImage();return n.src=await this.base64(t),n}async base64(t){t=this._normalizeOptions(t,e.defaultImageOptions);let{format:n,quality:s}=t,r=this.canvas(t);if(r.toBlob!==void 0)return new Promise((i,o)=>{r.toBlob((a)=>{if(!a){o(Error("ICanvas.toBlob failed!"));return}let l=new FileReader;l.onload=()=>i(l.result),l.onerror=o,l.readAsDataURL(a)},Uh[n],s)});if(r.toDataURL!==void 0)return r.toDataURL(Uh[n],s);if(r.convertToBlob!==void 0){let i=await r.convertToBlob({type:Uh[n],quality:s});return new Promise((o,a)=>{let l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(i)})}throw Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);let n=t.target,s=this._renderer;if(n instanceof j)return s.texture.generateCanvas(n);let r=s.textureGenerator.generateTexture(t),i=s.texture.generateCanvas(r);return r.destroy(!0),i}pixels(t){t=this._normalizeOptions(t);let n=t.target,s=this._renderer,r=n instanceof j?n:s.textureGenerator.generateTexture(t),i=s.texture.getPixels(r);if(n instanceof Fe)r.destroy(!0);return i}texture(t){if(t=this._normalizeOptions(t),t.target instanceof j)return t.target;return this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);let n=this.canvas(t),s=document.createElement("a");s.download=t.filename??"image.png",s.href=n.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){let n=t.width??200;t=this._normalizeOptions(t);let s=this.canvas(t),r=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);let i=["font-size: 1px;",`padding: ${n}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",i)}destroy(){this._renderer=null}},sv;var rv=w(()=>{nt();W();nn();De();Uh={png:"image/png",jpg:"image/jpeg",webp:"image/webp"};Wh.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"extract"};Wh.defaultImageOptions={format:"png",quality:1};sv=Wh});var Va;var iv=w(()=>{gt();De();Va=class Va extends j{static create(e){let{dynamic:t,textureOptions:n,...s}=e;return new Va({...n,source:new le(s),dynamic:t??!1})}resize(e,t,n){return this.source.resize(e,t,n),this}}});class Ha{constructor(e){this._renderer=e}generateTexture(e){if(e instanceof Fe)e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0};let t=e.resolution||this._renderer.resolution,n=e.antialias||this._renderer.view.antialias,s=e.target,r=e.clearColor;if(r)r=Array.isArray(r)&&r.length===4?r:he.shared.setValue(r).toArray();else r=bA;let i=e.frame?.copyTo(yA)||Os(s,xA).rectangle,o=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};i.width=Math.max(i.width,1/t)|0,i.height=Math.max(i.height,1/t)|0;let a=Va.create({...e.textureSourceOptions,width:i.width,height:i.height,resolution:t,antialias:n,textureOptions:o}),l=U.shared.translate(-i.x,-i.y);return this._renderer.render({container:s,transform:l,target:a,clearColor:r}),a.source.updateMipmaps(),a}destroy(){this._renderer=null}}var yA,xA,bA;var ov=w(()=>{Pt();W();me();et();ft();xo();nn();iv();yA=new Q,xA=new fe,bA=[0,0,0,0];Ha.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"textureGenerator"}});function av(e){let t=!1;for(let s in e)if(e[s]==null){t=!0;break}if(!t)return e;let n=Object.create(null);for(let s in e){let r=e[s];if(r)n[s]=r}return n}function lv(e){let t=0;for(let n=0;n{};var Xh=class e{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._running=!1,this._renderer=t}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){if(this.enabled===t)return;if(t)this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(let n of this._managedCollections){let{context:s,collection:r,type:i}=n;if(i==="hash")s[r]=av(s[r]);else s[r]=lv(s[r])}},this._frequency);else this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){if(!this._ready||!this.enabled)return;this.run(),this._ready=!1}_updateInstructionGCTick(t,n){t.instructionSet.gcTick=n,t.gcTick=n;for(let s of t.renderGroupChildren)this._updateInstructionGCTick(s,n)}addCollection(t,n,s){this._managedCollections.push({context:t,collection:n,type:s})}addResource(t,n){if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,t._onTouch?.(this.now);return}let s=this._managedResources.length;t._gcData={index:s,type:n},t._gcLastUsed=this.now,t._onTouch?.(this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){let n=t._gcData;if(!n)return;let s=n.index,r=this._managedResources.length-1;if(this._running)this._managedResources[s]=null;else{if(s!==r){let i=this._managedResources[r];this._managedResources[s]=i,i._gcData.index=s}this._managedResources.length--}t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,n,s,r=0){this._managedResourceHashes.push({context:t,hash:n,type:s,priority:r}),this._managedResourceHashes.sort((i,o)=>i.priority-o.priority)}run(){if(this._running)return;let t=performance.now(),n=this._managedResourceHashes,s=this._managedResources;this._running=!0;try{for(let i of n)this.runOnHash(i,t);let r=s.length;for(let i=0;i{t?.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}},uv;var hv=w(()=>{W();cv();Xh.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"gc",priority:0};Xh.defaultOptions={gcActive:!0,gcMaxUnusedTime:60000,gcFrequency:30000};uv=Xh});class za{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e"},uWorldTransformMatrix:{value:new U,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}var dv=w(()=>{W();me();jt();$a();js();Rn();zt();za.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"globalUniforms"}});class qa{constructor(){this._tasks=[],this._offset=0}init(){tt.system.add(this._update,this)}repeat(e,t,n=!0){let s=vA++,r=0;if(n)this._offset+=1000,r=this._offset;return this._tasks.push({func:e,duration:t,start:performance.now(),offset:r,last:performance.now(),repeat:!0,id:s}),s}cancel(e){for(let t=0;t=n.duration){let s=e-n.start;n.func(s),n.last=e}}}destroy(){tt.system.remove(this._update,this),this._tasks.length=0}}var vA=1;var fv=w(()=>{W();Gs();qa.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"scheduler",priority:0}});function pv(e){if(mv)return;if(ne.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){let t=[`%c %c %c %c %c PixiJS %c v${Ks} (${e}) http://www.pixijs.com/ + `}}});class Va{constructor(e){this._activeMaskStage=[],this._usedEffects=[],this._renderer=e,e.runners.postrender.add(this)}push(e,t,n){let s=this._renderer;if(s.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??"red",e.renderMaskToTexture){let r=e.mask;r.includeInBuild=!0,r.collectRenderables(n,s,null),r.includeInBuild=!1}s.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){let t=this._renderer,n=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){let s=Re.get(tv);if(s.inverse=e.inverse,s.channel=e.mask.channel,n){e.mask.mask.measurable=!0;let r=Ls(e.mask.mask,!0,IA);e.mask.mask.measurable=!1,r.ceil();let i=t.renderTarget.renderTarget.colorTexture.source,o=Xe.getOptimalTexture({width:r.width,height:r.height,resolution:i._resolution,antialias:i.antialias});t.renderTarget.push({target:o,clear:!0}),t.globalUniforms.push({offset:r,worldColor:4294967295});let a=s.sprite;a.texture=o,a.worldTransform.tx=r.minX,a.worldTransform.ty=r.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer,filterTexture:o})}else s.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){let s=this._activeMaskStage[this._activeMaskStage.length-1];if(n){if(t.type===dt.WEBGL)t.renderTarget.finishRenderPass();t.renderTarget.pop(),t.globalUniforms.pop()}t.filter.push({renderPipeId:"filter",action:"pushFilter",container:s.maskedContainer,filterEffect:s.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();let s=this._activeMaskStage.pop();if(n)Xe.returnTexture(s.filterTexture);this._usedEffects.push(s.filterEffect)}}postrender(){let e=this._usedEffects;for(let t=0;t{z();bo();Nb();yt();Yr();Lo();xn();Ne();us();Dn();IA=new Me;tv=class tv extends Pn{constructor(){super();this._placeholderSprite=new Qt(K.EMPTY),this.filters=[new Dh({sprite:this._placeholderSprite,inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].setSprite(e)}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}reset(){this._placeholderSprite.texture=K.EMPTY,this.sprite=this._placeholderSprite}};Va.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"alphaMask"}});class ja{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];if(i!==this._currentColor)this._currentColor=i,n.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1});this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];if(i!==this._currentColor)this._currentColor=i,n.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1})}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}var sv=M(()=>{z();ja.extension={type:[D.WebGLPipes,D.WebGPUPipes],name:"colorMask"}});class Ya{constructor(e){this._maskHash=new WeakMap,this._renderer=e}push(e,t,n){let s=e,r=this._renderer;r.renderPipes.batch.break(n),r.renderPipes.blendMode.setBlendMode(s.mask,"none",n),n.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let i=s.mask;if(i.includeInBuild=!0,!this._maskHash.has(s))this._maskHash.set(s,{instructionsStart:0,instructionsLength:0});let o=this._maskHash.get(s);o.instructionsStart=n.instructionSize,i.collectRenderables(n,r,null),i.includeInBuild=!1,r.renderPipes.batch.break(n),n.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let a=n.instructionSize-o.instructionsStart-1;o.instructionsLength=a}pop(e,t,n){let s=e,r=this._renderer;r.renderPipes.batch.break(n),r.renderPipes.blendMode.setBlendMode(s.mask,"none",n),n.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});let i=this._maskHash.get(e);for(let o=0;o{z();gi();or();Ya.extension={type:[D.WebGLPipes,D.WebGPUPipes],name:"stencilMask"}});class Ha{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){if(!e.isRenderable)return;e.render(this._renderer)}destroy(){this._renderer=null}}var iv=M(()=>{z();Ha.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"customRender"}});function Ti(e,t){let n=e.instructionSet,s=n.instructions;for(let r=0;r{};class za{constructor(e){this._renderer=e}addRenderGroup(e,t){if(e.isCachedAsTexture)this._addRenderableCacheAsTexture(e,t);else this._addRenderableDirect(e,t)}execute(e){if(!e.isRenderable)return;if(e.isCachedAsTexture)this._executeCacheAsTexture(e);else this._executeDirect(e)}destroy(){this._renderer=null}_addRenderableDirect(e,t){if(this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup)Re.return(e._batchableRenderGroup),e._batchableRenderGroup=null;t.add(e)}_addRenderableCacheAsTexture(e,t){let n=e._batchableRenderGroup??(e._batchableRenderGroup=Re.get(Mi));n.renderable=e.root,n.transform=e.root.relativeGroupTransform,n.texture=e.texture,n.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(n,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;let t=new j().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push({target:e.texture,clear:!0,frame:e.texture.frame}),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),Ti(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),Ti(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}var ov=M(()=>{z();Ce();xn();Xh();Yh();za.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"renderGroup"}});class qa{constructor(e){this._renderer=e}addRenderable(e,t){let n=this._getGpuSprite(e);if(e.didViewUpdate)this._updateBatchableSprite(e,n);this._renderer.renderPipes.batch.addToBatch(n,t)}updateRenderable(e){let t=this._getGpuSprite(e);if(e.didViewUpdate)this._updateBatchableSprite(e,t);t._batcher.updateElement(t)}validateRenderable(e){let t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=new Mi;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}var av=M(()=>{z();Xh();qa.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"sprite"}});class Ka{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,n){this._blendModeStack.push(t),this.setBlendMode(e,t,n)}popBlendMode(e){this._blendModeStack.pop();let t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,n){let s=e instanceof Ys;if(this._activeBlendMode===t){if(this._isAdvanced&&e&&!s)this._renderableList?.push(e);return}if(this._isAdvanced)this._endAdvancedBlendMode(n);if(this._activeBlendMode=t,!e)return;if(this._isAdvanced=!!Ci[t],this._isAdvanced)this._beginAdvancedBlendMode(e,n)}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);let n=this._activeBlendMode;if(!Ci[n]){te(`Unable to assign BlendMode: '${n}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let s=this._ensureFilterEffect(n),r=e instanceof Ys,i={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:r?null:[e],container:r?e.root:null,canBundle:!1};this._renderableList=i.renderables,t.add(i)}_ensureFilterEffect(e){let t=this._filterHash[e];if(!t)t=this._filterHash[e]=new Pn,t.filters=[new Ci[e]];return t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){if(!this._isAdvanced)return;this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(let e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}var Ci;var lv=M(()=>{z();bo();Yc();Be();Ci={};ne.handle(D.BlendMode,(e)=>{if(!e.name)throw Error("BlendMode extension must have a name property");Ci[e.name]=e.ref},(e)=>{delete Ci[e.name]});Ka.extension={type:[D.WebGLPipes,D.WebGPUPipes,D.CanvasPipes],name:"blendMode"}});function Ai(e,t){t||(t=0);for(let n=t;n{};function zh(e,t=!1){FA(e);let n=e.childrenToUpdate,s=e.updateTick++;for(let r in n){let i=Number(r),o=n[r],{list:a,index:l}=o;for(let u=0;u1?1:n,e.worldAlpha=n,e.worldColorAlpha=e.worldColor+((n*255|0)<<24)}function hv(e,t,n){if(t===e.updateTick)return;e.updateTick=t,e.didChange=!1;let s=e.localTransform;e.updateLocalTransform();let r=e.parent;if(r&&!r.renderGroup){if(n|=e._updateFlags,e.relativeGroupTransform.appendFrom(s,r.relativeGroupTransform),n&cv)uv(e,r,n)}else if(n=e._updateFlags,e.relativeGroupTransform.copyFrom(s),n&cv)uv(e,BA,n);if(!e.renderGroup){let i=e.children,o=i.length;for(let u=0;u1?1:s,e.groupAlpha=s,e.groupColorAlpha=e.groupColor+((s*255|0)<<24)}if(n&Jr)e.groupBlendMode=e.localBlendMode==="inherit"?t.groupBlendMode:e.localBlendMode;if(n&hs)e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus;e._updateFlags=0}var BA,cv;var dv=M(()=>{un();Hh();Ic();BA=new Ge,cv=hs|Hs|Jr});function fv(e,t){let{list:n}=e.childrenRenderablesToUpdate,s=!1;for(let r=0;r{};class Ja{constructor(e){this._renderer=e}render({container:e,transform:t}){let n=e.parent,s=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;let r=this._renderer,i=DA;if(t)i.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t);let o=r.renderPipes;if(this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),r.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),Ti(e.renderGroup,o),o.uniformBatch)o.uniformBatch.renderEnd();if(t)e.renderGroup.localTransform.copyFrom(i);e.parent=n,e.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let n=e.renderGroupChildren.length-1;n>=0;n--)this._updateCachedRenderGroups(e.renderGroupChildren[n],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){let n=e.root.getLocalBounds(),s=this._renderer,r=e.textureOptions.resolution||s.view.resolution,i=e.textureOptions.antialias??s.view.antialias,o=e.textureOptions.scaleMode??"linear",a=e.texture;if(n.ceil(),e.texture)Xe.returnTexture(e.texture);let l=Xe.getOptimalTexture({width:n.width,height:n.height,resolution:r,antialias:i,scaleMode:o});if(e.texture=l,e._textureBounds||(e._textureBounds=new Me),e._textureBounds.copyFrom(n),a!==e.texture){if(e.renderGroupParent)e.renderGroupParent.structureDidChange=!0}}}else if(e.texture)Xe.returnTexture(e.texture),e.texture=null}_updateRenderGroups(e){let t=this._renderer,n=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=n,!e.structureDidChange)fv(e,n);else Ai(e.childrenRenderablesToUpdate.list,0);if(zh(e),e.structureDidChange)e.structureDidChange=!1,this._buildInstructions(e,t);else this._updateRenderables(e);if(e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),e.isCachedAsTexture&&!e.textureNeedsUpdate)return;for(let s=0;s{z();Ce();us();yt();Hh();Yh();dv();mv();DA=new j;Ja.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"renderGroup"}});var qh=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new we(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...e.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){if(we.shared.setValue(t).alpha<1&&this._backgroundColor.alpha===1)te("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application.");this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}},gv;var yv=M(()=>{Lt();z();Be();qh.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"background",priority:0};qh.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};gv=qh});var Kh,Jh=class e{constructor(t){this._renderer=t}_normalizeOptions(t,n={}){if(t instanceof Ge||t instanceof K)return{target:t,...n};return{...n,...t}}async image(t){let n=le.get().createImage();return n.src=await this.base64(t),n}async base64(t){t=this._normalizeOptions(t,e.defaultImageOptions);let{format:n,quality:s}=t,r=this.canvas(t);if(r.toBlob!==void 0)return new Promise((i,o)=>{r.toBlob((a)=>{if(!a){o(Error("ICanvas.toBlob failed!"));return}let l=new FileReader;l.onload=()=>i(l.result),l.onerror=o,l.readAsDataURL(a)},Kh[n],s)});if(r.toDataURL!==void 0)return r.toDataURL(Kh[n],s);if(r.convertToBlob!==void 0){let i=await r.convertToBlob({type:Kh[n],quality:s});return new Promise((o,a)=>{let l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(i)})}throw Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);let n=t.target,s=this._renderer;if(n instanceof K)return s.texture.generateCanvas(n);let r=s.textureGenerator.generateTexture(t),i=s.texture.generateCanvas(r);return r.destroy(!0),i}pixels(t){t=this._normalizeOptions(t);let n=t.target,s=this._renderer,r=n instanceof K?n:s.textureGenerator.generateTexture(t),i=s.texture.getPixels(r);if(n instanceof Ge)r.destroy(!0);return i}texture(t){if(t=this._normalizeOptions(t),t.target instanceof K)return t.target;return this._renderer.textureGenerator.generateTexture(t)}download(t){t=this._normalizeOptions(t);let n=this.canvas(t),s=document.createElement("a");s.download=t.filename??"image.png",s.href=n.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(t){let n=t.width??200;t=this._normalizeOptions(t);let s=this.canvas(t),r=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);let i=["font-size: 1px;",`padding: ${n}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",i)}destroy(){this._renderer=null}},xv;var bv=M(()=>{it();z();un();Ne();Kh={png:"image/png",jpg:"image/jpeg",webp:"image/webp"};Jh.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"extract"};Jh.defaultImageOptions={format:"png",quality:1};xv=Jh});var Za;var vv=M(()=>{St();Ne();Za=class Za extends K{static create(e){let{dynamic:t,textureOptions:n,...s}=e;return new Za({...n,source:new ve(s),dynamic:t??!1})}resize(e,t,n){return this.source.resize(e,t,n),this}}});class Qa{constructor(e){this._renderer=e}generateTexture(e){if(e instanceof Ge)e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0};let t=e.resolution||this._renderer.resolution,n=e.antialias||this._renderer.view.antialias,s=e.target,r=e.clearColor;if(r)r=Array.isArray(r)&&r.length===4?r:we.shared.setValue(r).toArray();else r=LA;let i=e.frame?.copyTo(NA)||Ws(s,GA).rectangle,o=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};i.width=Math.max(i.width,1/t)|0,i.height=Math.max(i.height,1/t)|0;let a=Za.create({...e.textureSourceOptions,width:i.width,height:i.height,resolution:t,antialias:n,textureOptions:o}),l=j.shared.translate(-i.x,-i.y);return this._renderer.render({container:s,transform:l,target:a,clearColor:r}),a.source.updateMipmaps(),a}destroy(){this._renderer=null}}var NA,GA,LA;var _v=M(()=>{Lt();z();Ce();st();yt();ko();un();vv();NA=new se,GA=new Me,LA=[0,0,0,0];Qa.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"textureGenerator"}});function Sv(e){let t=!1;for(let s in e)if(e[s]==null){t=!0;break}if(!t)return e;let n=Object.create(null);for(let s in e){let r=e[s];if(r)n[s]=r}return n}function wv(e){let t=0;for(let n=0;n{};var Zh=class e{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._running=!1,this._renderer=t}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){if(this.enabled===t)return;if(t)this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(let n of this._managedCollections){let{context:s,collection:r,type:i}=n;if(i==="hash")s[r]=Sv(s[r]);else s[r]=wv(s[r])}},this._frequency);else this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){if(!this._ready||!this.enabled)return;this.run(),this._ready=!1}_updateInstructionGCTick(t,n){t.instructionSet.gcTick=n,t.gcTick=n;for(let s of t.renderGroupChildren)this._updateInstructionGCTick(s,n)}addCollection(t,n,s){this._managedCollections.push({context:t,collection:n,type:s})}addResource(t,n){if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,t._onTouch?.(this.now);return}let s=this._managedResources.length;t._gcData={index:s,type:n},t._gcLastUsed=this.now,t._onTouch?.(this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){let n=t._gcData;if(!n)return;let s=n.index,r=this._managedResources.length-1;if(this._running)this._managedResources[s]=null;else{if(s!==r){let i=this._managedResources[r];this._managedResources[s]=i,i._gcData.index=s}this._managedResources.length--}t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,n,s,r=0){this._managedResourceHashes.push({context:t,hash:n,type:s,priority:r}),this._managedResourceHashes.sort((i,o)=>i.priority-o.priority)}run(){if(this._running)return;let t=performance.now(),n=this._managedResourceHashes,s=this._managedResources;this._running=!0;try{for(let i of n)this.runOnHash(i,t);let r=s.length;for(let i=0;i{t?.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}},Mv;var Tv=M(()=>{z();kv();Zh.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"gc",priority:0};Zh.defaultOptions={gcActive:!0,gcMaxUnusedTime:60000,gcFrequency:30000};Mv=Zh});class el{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e"},uWorldTransformMatrix:{value:new j,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}var Cv=M(()=>{z();Ce();Kt();Na();Qs();Dn();en();el.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"globalUniforms"}});class tl{constructor(){this._tasks=[],this._offset=0}init(){rt.system.add(this._update,this)}repeat(e,t,n=!0){let s=UA++,r=0;if(n)this._offset+=1000,r=this._offset;return this._tasks.push({func:e,duration:t,start:performance.now(),offset:r,last:performance.now(),repeat:!0,id:s}),s}cancel(e){for(let t=0;t=n.duration){let s=e-n.start;n.func(s),n.last=e}}}destroy(){rt.system.remove(this._update,this),this._tasks.length=0}}var UA=1;var Av=M(()=>{z();zs();tl.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"scheduler",priority:0}});function Pv(e){if(Ev)return;if(le.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){let t=[`%c %c %c %c %c PixiJS %c v${ir} (${e}) http://www.pixijs.com/ -`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else if(globalThis.console)globalThis.console.log(`PixiJS ${Ks} - ${e} - http://www.pixijs.com/`);mv=!0}var mv=!1;var gv=w(()=>{nt();Lu()});class bi{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;if(this._renderer.type===at.WEBGL)t+=` ${this._renderer.context.webGLVersion}`;pv(t)}}}var yv=w(()=>{W();gv();Rn();bi.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"hello",priority:-2};bi.defaultOptions={hello:!1}});var jh=class e{constructor(t){this._renderer=t}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return X("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(t){X("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=t}addManagedHash(t,n){X("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,n,"hash")}addManagedArray(t,n){X("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,n,"array")}addRenderable(t){X("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(t,"renderable")}run(){X("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}},xv;var bv=w(()=>{W();Re();jh.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"renderableGC",priority:0};jh.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:60000,renderableGCFrequency:30000};xv=jh});var Yh=class e{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){X("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1000*60}set maxIdle(t){X("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=t/60*1000}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1000)}set checkCountMax(t){X("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(t){X("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){if(t.textureGCActive!==e.defaultOptions.textureGCActive)this.active=t.textureGCActive;if(t.textureGCMaxIdle!==e.defaultOptions.textureGCMaxIdle)this.maxIdle=t.textureGCMaxIdle;if(t.textureGCCheckCountMax!==e.defaultOptions.textureGCCheckCountMax)this.checkCountMax=t.textureGCCheckCountMax}run(){X("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}},vv;var _v=w(()=>{W();Re();Yh.extension={type:[E.WebGLSystem,E.WebGPUSystem],name:"textureGC"};Yh.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};vv=Yh});var Sv,cr;var Vh=w(()=>{Ke();qe();gt();De();Sv=class e extends de{constructor(t={}){super();this.uid=ee("renderTarget"),this.colorAttachments=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,this._depth=!1,this._stencil=!1,this._colorTextures=null;let n="colorAttachments"in t?t:this._normalizeOptions(t);if(this.isRoot=n.isRoot??!1,this.label=n.label,this.colorAttachments=n.colorAttachments,this.depthStencilAttachment=n.depthStencilAttachment,this.depthStencilAttachment){let s=this.depthStencilAttachment.texture.format;this._depth||(this._depth=s.includes("depth")),this._stencil||(this._stencil=s.includes("stencil"))}if(this.colorAttachments.length===0&&!this.depthStencilAttachment)throw Error("[RenderTarget] no color textures or depth textures were provided. Provide a depthStencilTexture or set depth/stencil to true when using colorTextures: 0.");if(this.colorAttachments.length>0){let s=this.colorTexture;this.resize(s.width,s.height,s._resolution)}if(this.sizeSource)this.sizeSource.on("resize",this.onSourceResize,this)}_normalizeOptions(t){let n={...e.defaultOptions,...t},s=[],r;if(typeof n.colorTextures==="number"){if(n.colorTextures>0){this._managedColorTextures=!0;for(let o=0;o{s.push({texture:o.source,loadOp:"clear",storeOp:"store"})});let i=n.depthStencilTexture===!0;if(this._depth=!!(n.depth||i),this._stencil=!!(n.stencil||i),n.depthStencilTexture instanceof j||n.depthStencilTexture instanceof le){if(n.isRoot)throw Error("[RenderTarget] cannot attach a depth-stencil texture to the screen — the canvas owns its own depth/stencil buffers. Render to a texture target instead.");r={texture:n.depthStencilTexture.source}}else if(i&&!n.isRoot||(n.stencil||n.depth)&&s.length===0)r=this._createDepthStencilTexture(n.width,n.height,n.resolution);return{colorAttachments:s,depthStencilAttachment:r,isRoot:n.isRoot,label:n.label}}get size(){let t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.sizeSource.width}get height(){return this.sizeSource.height}get pixelWidth(){return this.sizeSource.pixelWidth}get pixelHeight(){return this.sizeSource.pixelHeight}get resolution(){return this.sizeSource._resolution}get colorTextures(){return this._colorTextures||(this._colorTextures=this.colorAttachments.map((t)=>t.texture)),this._colorTextures}get depthStencilTexture(){return this.depthStencilAttachment?.texture??null}get depth(){return this._depth}get stencil(){return this._stencil}get colorTexture(){return this.colorAttachments[0]?.texture}get sizeSource(){return this.colorAttachments[0]?.texture??this.depthStencilAttachment?.texture}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this._createDepthStencilTexture(this.sizeSource.width,this.sizeSource.height,this.sizeSource._resolution),this._depth=!0,this._stencil=!0}resize(t,n,s=this.resolution,r=!1){if(this.dirtyId++,this.colorAttachments.forEach((i,o)=>{if(r&&o===0)return;i.texture.resize(t,n,s)}),this.depthStencilAttachment){if(r&&this.colorAttachments.length===0)return;this.depthStencilAttachment.texture.resize(t,n,s)}}destroy(){if(!this.colorAttachments&&!this.depthStencilAttachment)return;if(this.emit("destroy",this),this.sizeSource.off("resize",this.onSourceResize,this),this._managedColorTextures)this.colorAttachments.forEach((t)=>{t.texture.destroy()});if(this.depthStencilAttachment)this.depthStencilAttachment.texture.destroy(),delete this.depthStencilAttachment;this.colorAttachments=null,this._colorTextures=null,this.removeAllListeners()}_createDepthStencilTexture(t,n,s){return this.depthStencilAttachment??(this.depthStencilAttachment={texture:new le({width:t,height:n,resolution:s,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1})}),this.depthStencilAttachment}};Sv.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};cr=Sv});function Ka(e,t){if(!ur.has(e)){let n=new j({source:new St({resource:e,...t})}),s=()=>{if(ur.get(e)===n)ur.delete(e)};n.once("destroy",s),n.source.once("destroy",s),ur.set(e,n)}return ur.get(e)}var ur;var Hh=w(()=>{Hn();Hr();De();ur=new Map;Ot.register(ur)});var zh=class e{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}constructor(t){this._renderer=t}init(t){if(t={...e.defaultOptions,...t},t.view)X(ae,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view;this.screen=new Q(0,0,t.width,t.height),this.canvas=t.canvas||ne.get().createCanvas(),this.antialias=!!t.antialias;let{depth:n,...s}=t;this.texture=Ka(this.canvas,s),this.renderTarget=new cr({colorTextures:[this.texture],depth:!!n,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.texture.source.on("resize",this._updateScreenSize,this),this.resolution=t.resolution,this._updateScreenSize()}resize(t,n,s){this.texture.source.resize(t,n,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){if((typeof t==="boolean"?t:!!t?.removeView)&&this.canvas.parentNode)this.canvas.parentNode.removeChild(this.canvas);this.texture.source.off("resize",this._updateScreenSize,this),Ue.removeScreen(this._renderer.uid),Ws.removeScreen(this._renderer.uid),this.texture.destroy()}_updateScreenSize(){let{pixelWidth:t,pixelHeight:n}=this.texture.source,s=this._renderer.uid;Ue.setScreenSize(s,t,n),Ws.setScreenSize(s,t,n)}},kv;var wv=w(()=>{nt();W();et();Re();Vh();cu();es();Hh();zh.extension={type:[E.WebGLSystem,E.WebGPUSystem,E.CanvasSystem],name:"view",priority:0};zh.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};kv=zh});var Mv,Tv;var Cv=w(()=>{j0();Y0();ev();V0();cx();F0();U0();W0();X0();nv();H0();rv();ov();hv();dv();fv();yv();bv();_v();wv();Mv=[tv,za,bi,kv,Ya,uv,vv,Ha,sv,ha,xv,qa],Tv=[ja,Dh,Xa,Wa,Na,La,Ga,Ua]});function Av(e,t,n,s,r,i){let o=i?1:-1;return e.identity(),e.a=1/s*2,e.d=o*(1/r*2),e.tx=-1-t*e.a,e.ty=-o-n*e.d,e}var Ev=()=>{};function Rv(e){if(e.colorAttachments.length===0)return!1;let t=e.colorTexture.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var Pv=()=>{};class qh{constructor(e){this.rootViewPort=new Q,this.viewport=new Q,this.onRenderTargetChange=new ai("onRenderTargetChange"),this.projectionMatrix=new U,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._bindState={target:null,frame:void 0,mipLevel:0,layer:0,flipY:!1},this._bindFrame=new Q,this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}get renderSurface(){return this._bindState.target}get mipLevel(){return this._bindState.mipLevel}get layer(){return this._bindState.layer}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart(e){this._renderTargetStack.length=0,this.push(e),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Rv(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,n,s,r=0,i=0,o){let a;if("target"in e)a=e;else X("8.20.0","RenderTargetSystem.bind: positional arguments are deprecated, please use an options object instead: bind({ target, clear, clearColor, frame, mipLevel, layer, flipY })"),a={target:e,clear:t,clearColor:n,frame:s,mipLevel:r,layer:i,flipY:o};let l=a.target;t=a.clear??!0,n=a.clearColor,r=(a.mipLevel??0)|0,i=(a.layer??0)|0,o=a.flipY,s=a.frame;let u=this.getRenderTarget(l),c=this.renderTarget!==u||!!u.flipY!==!!o;this.renderTarget=u;let h=this.getGpuRenderTarget(u);if(u.pixelWidth!==h.width||u.pixelHeight!==h.height)this.adaptor.resizeGpuRenderTarget(u),h.width=u.pixelWidth,h.height=u.pixelHeight;let d=u.colorAttachments[0]?.texture||u.depthStencilAttachment?.texture,f=this.viewport,m=d.dimension==="3d"?Math.max(d.depth>>r,1):d.depthOrArrayLayers;if(i<0||i>=m)throw Error(`[RenderTargetSystem] layer ${i} is out of bounds (layer count=${m}).`);let p=this._bindState;p.target=l,p.frame=s?this._bindFrame.copyFrom(s):void 0,p.mipLevel=r,p.layer=i,p.flipY=o;let y=Math.max(d.pixelWidth>>r,1),g=Math.max(d.pixelHeight>>r,1);if(!s&&l instanceof j)s=l.frame;if(s){let x=d._resolution,b=1<{if(e!==t)this._releaseRenderTarget(t,e);else e.off("destroy",this._onRenderTargetDestroy,this)}),this._renderSurfaceToRenderTargetHash.clear();for(let e of Object.values(this._gpuRenderTargetHash))if(e)this.adaptor.destroyGpuRenderTarget(e);this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;if(St.test(e))e=Ka(e).source;if(e instanceof cr)t=e,e.once("destroy",this._onRenderTargetDestroy,this);else if(e instanceof le){let n=e.format;if(t=n.includes("depth")||n.includes("stencil")?new cr({colorTextures:0,depthStencilTexture:e}):new cr({colorTextures:[e]}),e.source instanceof St)t.isRoot=!0;e.once("destroy",this._onRenderSurfaceDestroy,this)}return this._renderSurfaceToRenderTargetHash.set(e,t),t}_onRenderSurfaceDestroy(e){let t=this._renderSurfaceToRenderTargetHash.get(e);if(t)this._releaseRenderTarget(e,t)}_onRenderTargetDestroy(e){this._renderSurfaceToRenderTargetHash.delete(e),this._releaseGpuRenderTarget(e)}_releaseRenderTarget(e,t){t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e),e.off("destroy",this._onRenderSurfaceDestroy,this),this._releaseGpuRenderTarget(t)}_releaseGpuRenderTarget(e){let t=this._gpuRenderTargetHash[e.uid];if(t)this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(t)}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this._bindState.target=null}}var $v=w(()=>{me();et();Re();Pe();oi();Ev();Rn();Gu();Hr();gt();De();Hh();Pv();Vh()});var vi;var Ov=w(()=>{vi=((e)=>(e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e))(vi||{})});class Kh{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}var Iv=()=>{};class Ja{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new pt({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){let{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){let{_gl:n}=this;if(this._boundBufferBases[t]!==e)this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,n.bindBufferBase(n.UNIFORM_BUFFER,t,e.buffer)}nextBindBase(e){if(this._bindCallId++,this._minBaseLocation=0,e){if(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1)this._nextBindBaseIndex=1}}freeLocationForBufferBase(e){let t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;let n=0,s=this._nextBindBaseIndex;while(n<2){if(s>=this._maxBindings)s=this._minBaseLocation,n++;let r=this._boundBufferBases[s];if(r&&r._lastBindCallId===this._bindCallId){s++;continue}break}if(t=s,this._nextBindBaseIndex=s+1,n>=2)return-1;return e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t}getLastBindBaseLocation(e){let t=e._lastBindBaseLocation;if(this._boundBufferBases[t]===e)return t;return-1}bindBufferRange(e,t,n,s){let{_gl:r}=this;n||(n=0),t||(t=0),this._boundBufferBases[t]=null,r.bindBufferRange(r.UNIFORM_BUFFER,t||0,e.buffer,n*256,s||256)}updateBuffer(e){let{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);let s=e.data,r=e.descriptor.usage&ce.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;if(s)if(n.byteLength>=s.byteLength)t.bufferSubData(n.type,e._updateOffset,s,e._updateOffset/s.BYTES_PER_ELEMENT,(e._updateSize||s.byteLength)/s.BYTES_PER_ELEMENT);else n.byteLength=s.byteLength,t.bufferData(n.type,s,r);else n.byteLength=e.descriptor.size,t.bufferData(n.type,n.byteLength,r);return n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){let n=e._gpuData[this._renderer.uid];if(!n)return;if(!t)this._gl.deleteBuffer(n.buffer)}createGLBuffer(e){let{_gl:t}=this,n=vi.ARRAY_BUFFER;if(e.descriptor.usage&ce.INDEX)n=vi.ELEMENT_ARRAY_BUFFER;else if(e.descriptor.usage&ce.UNIFORM)n=vi.UNIFORM_BUFFER;let s=new Kh(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}var Bv=w(()=>{W();$n();os();Ov();Iv();Ja.extension={type:[E.WebGLSystem],name:"buffer"}});var Jh=class e{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){t={...e.defaultOptions,...t};let n=this.multiView=t.multiView;if(t.context&&n)V("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),n=!1;if(n)this.canvas=ne.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height);else this.canvas=this._renderer.view.canvas;if(t.context)this.initFromContext(t.context);else{let s=this._renderer.background.alpha<1,r=t.premultipliedAlpha??!0,i=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:s,premultipliedAlpha:r,antialias:i,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView){if(t!==this.canvas)V("multiView is disabled, but targetCanvas is not the main canvas");return}let{canvas:n}=this;if(n.width{if(this.gl.isContextLost())this.extensions.loseContext?.restoreContext()},0)}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){let t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){let n=t.getContextAttributes();if(n&&!n.stencil)V("Provided WebGL context does not have a stencil buffer, masks may not render correctly");let s=this.supports,r=this.webGLVersion===2,i=this.extensions;if(s.uint32Indices=r||!!i.uint32ElementIndex,s.uniformBufferObject=r,s.vertexArrayObject=r||!!i.vertexArrayObject,s.srgbTextures=r||!!i.srgb,s.nonPowOf2wrapping=r,s.nonPowOf2mipmaps=r,s.msaa=r,!s.uint32Indices)V("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}},Dv;var Fv=w(()=>{nt();W();Pe();Jh.extension={type:[E.WebGLSystem],name:"context"};Jh.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};Dv=Jh});function Nv(e,t){for(let n in e.attributes){let s=e.attributes[n],r=t[n];if(r)s.format??(s.format=r.format),s.offset??(s.offset=r.offset),s.instance??(s.instance=r.instance);else if(!s.format)V(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}_A(e)}function _A(e){let{buffers:t,attributes:n}=e,s={},r={};for(let i in t){let o=t[i];s[o.uid]=0,r[o.uid]=0}for(let i in n){let o=n[i];s[o.buffer.uid]+=gn(o.format).stride}for(let i in n){let o=n[i];o.stride??(o.stride=s[o.buffer.uid]),o.start??(o.start=r[o.buffer.uid]),r[o.buffer.uid]+=gn(o.format).stride}}var Gv=w(()=>{Pe();Kr()});var Za,In,oe;var _i=w(()=>{Za=((e)=>(e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e))(Za||{}),In=((e)=>(e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e))(In||{}),oe=((e)=>(e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT",e))(oe||{})});function Uv(e){return Lv[e]??Lv.float32}var Lv;var Wv=w(()=>{_i();Lv={uint8x2:oe.UNSIGNED_BYTE,uint8x4:oe.UNSIGNED_BYTE,sint8x2:oe.BYTE,sint8x4:oe.BYTE,unorm8x2:oe.UNSIGNED_BYTE,unorm8x4:oe.UNSIGNED_BYTE,snorm8x2:oe.BYTE,snorm8x4:oe.BYTE,uint16x2:oe.UNSIGNED_SHORT,uint16x4:oe.UNSIGNED_SHORT,sint16x2:oe.SHORT,sint16x4:oe.SHORT,unorm16x2:oe.UNSIGNED_SHORT,unorm16x4:oe.UNSIGNED_SHORT,snorm16x2:oe.SHORT,snorm16x4:oe.SHORT,float16x2:oe.HALF_FLOAT,float16x4:oe.HALF_FLOAT,float32:oe.FLOAT,float32x2:oe.FLOAT,float32x3:oe.FLOAT,float32x4:oe.FLOAT,uint32:oe.UNSIGNED_INT,uint32x2:oe.UNSIGNED_INT,uint32x3:oe.UNSIGNED_INT,uint32x4:oe.UNSIGNED_INT,sint32:oe.INT,sint32x2:oe.INT,sint32x3:oe.INT,sint32x4:oe.INT}});class Xv{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class Qa{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new pt({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);let t=this._renderer.context.extensions.vertexArrayObject;if(t)e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=(s)=>t.bindVertexArrayOES(s),e.deleteVertexArray=(s)=>t.deleteVertexArrayOES(s);let n=this._renderer.context.extensions.vertexAttribDivisorANGLE;if(n)e.drawArraysInstanced=(s,r,i,o)=>{n.drawArraysInstancedANGLE(s,r,i,o)},e.drawElementsInstanced=(s,r,i,o,a)=>{n.drawElementsInstancedANGLE(s,r,i,o,a)},e.vertexAttribDivisor=(s,r)=>n.vertexAttribDivisorANGLE(s,r);this._activeGeometry=null,this._activeVao=null}bind(e,t){let n=this.gl;this._activeGeometry=e;let s=this.getVao(e,t);if(this._activeVao!==s)this._activeVao=s,n.bindVertexArray(s);this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n{W();$n();Kr();Gv();Wv();SA={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};Qa.extension={type:[E.WebGLSystem],name:"geometry"}});var kA,Zh=class e{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){let{useBackBuffer:n,antialias:s}={...e.defaultOptions,...t};if(this.useBackBuffer=n,this._antialias=s,!this._renderer.context.supports.msaa)V("antialiasing, is not supported on when using the back buffer"),this._antialias=!1;this._state=lt.for2d();let r=new yt({vertex:` +`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else if(globalThis.console)globalThis.console.log(`PixiJS ${ir} - ${e} - http://www.pixijs.com/`);Ev=!0}var Ev=!1;var Rv=M(()=>{it();qu()});class Ei{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;if(this._renderer.type===dt.WEBGL)t+=` ${this._renderer.context.webGLVersion}`;Pv(t)}}}var $v=M(()=>{z();Rv();Dn();Ei.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"hello",priority:-2};Ei.defaultOptions={hello:!1}});var Qh=class e{constructor(t){this._renderer=t}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return q("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(t){q("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=t}addManagedHash(t,n){q("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,n,"hash")}addManagedArray(t,n){q("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(t,n,"array")}addRenderable(t){q("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(t,"renderable")}run(){q("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}},Ov;var Iv=M(()=>{z();Ie();Qh.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"renderableGC",priority:0};Qh.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:60000,renderableGCFrequency:30000};Ov=Qh});var ed=class e{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){q("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1000*60}set maxIdle(t){q("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=t/60*1000}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1000)}set checkCountMax(t){q("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(t){q("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){if(t.textureGCActive!==e.defaultOptions.textureGCActive)this.active=t.textureGCActive;if(t.textureGCMaxIdle!==e.defaultOptions.textureGCMaxIdle)this.maxIdle=t.textureGCMaxIdle;if(t.textureGCCheckCountMax!==e.defaultOptions.textureGCCheckCountMax)this.checkCountMax=t.textureGCCheckCountMax}run(){q("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}},Bv;var Fv=M(()=>{z();Ie();ed.extension={type:[D.WebGLSystem,D.WebGPUSystem],name:"textureGC"};ed.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};Bv=ed});var Dv,xr;var td=M(()=>{Qe();Ze();St();Ne();Dv=class e extends ke{constructor(t={}){super();this.uid=ie("renderTarget"),this.colorAttachments=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,this._depth=!1,this._stencil=!1,this._colorTextures=null;let n="colorAttachments"in t?t:this._normalizeOptions(t);if(this.isRoot=n.isRoot??!1,this.label=n.label,this.colorAttachments=n.colorAttachments,this.depthStencilAttachment=n.depthStencilAttachment,this.depthStencilAttachment){let s=this.depthStencilAttachment.texture.format;this._depth||(this._depth=s.includes("depth")),this._stencil||(this._stencil=s.includes("stencil"))}if(this.colorAttachments.length===0&&!this.depthStencilAttachment)throw Error("[RenderTarget] no color textures or depth textures were provided. Provide a depthStencilTexture or set depth/stencil to true when using colorTextures: 0.");if(this.colorAttachments.length>0){let s=this.colorTexture;this.resize(s.width,s.height,s._resolution)}if(this.sizeSource)this.sizeSource.on("resize",this.onSourceResize,this)}_normalizeOptions(t){let n={...e.defaultOptions,...t},s=[],r;if(typeof n.colorTextures==="number"){if(n.colorTextures>0){this._managedColorTextures=!0;for(let o=0;o{s.push({texture:o.source,loadOp:"clear",storeOp:"store"})});let i=n.depthStencilTexture===!0;if(this._depth=!!(n.depth||i),this._stencil=!!(n.stencil||i),n.depthStencilTexture instanceof K||n.depthStencilTexture instanceof ve){if(n.isRoot)throw Error("[RenderTarget] cannot attach a depth-stencil texture to the screen — the canvas owns its own depth/stencil buffers. Render to a texture target instead.");r={texture:n.depthStencilTexture.source}}else if(i&&!n.isRoot||(n.stencil||n.depth)&&s.length===0)r=this._createDepthStencilTexture(n.width,n.height,n.resolution);return{colorAttachments:s,depthStencilAttachment:r,isRoot:n.isRoot,label:n.label}}get size(){let t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.sizeSource.width}get height(){return this.sizeSource.height}get pixelWidth(){return this.sizeSource.pixelWidth}get pixelHeight(){return this.sizeSource.pixelHeight}get resolution(){return this.sizeSource._resolution}get colorTextures(){return this._colorTextures||(this._colorTextures=this.colorAttachments.map((t)=>t.texture)),this._colorTextures}get depthStencilTexture(){return this.depthStencilAttachment?.texture??null}get depth(){return this._depth}get stencil(){return this._stencil}get colorTexture(){return this.colorAttachments[0]?.texture}get sizeSource(){return this.colorAttachments[0]?.texture??this.depthStencilAttachment?.texture}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this._createDepthStencilTexture(this.sizeSource.width,this.sizeSource.height,this.sizeSource._resolution),this._depth=!0,this._stencil=!0}resize(t,n,s=this.resolution,r=!1){if(this.dirtyId++,this.colorAttachments.forEach((i,o)=>{if(r&&o===0)return;i.texture.resize(t,n,s)}),this.depthStencilAttachment){if(r&&this.colorAttachments.length===0)return;this.depthStencilAttachment.texture.resize(t,n,s)}}destroy(){if(!this.colorAttachments&&!this.depthStencilAttachment)return;if(this.emit("destroy",this),this.sizeSource.off("resize",this.onSourceResize,this),this._managedColorTextures)this.colorAttachments.forEach((t)=>{t.texture.destroy()});if(this.depthStencilAttachment)this.depthStencilAttachment.texture.destroy(),delete this.depthStencilAttachment;this.colorAttachments=null,this._colorTextures=null,this.removeAllListeners()}_createDepthStencilTexture(t,n,s){return this.depthStencilAttachment??(this.depthStencilAttachment={texture:new ve({width:t,height:n,resolution:s,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1})}),this.depthStencilAttachment}};Dv.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};xr=Dv});function nl(e,t){if(!br.has(e)){let n=new K({source:new Et({resource:e,...t})}),s=()=>{if(br.get(e)===n)br.delete(e)};n.once("destroy",s),n.source.once("destroy",s),br.set(e,n)}return br.get(e)}var br;var nd=M(()=>{ss();si();Ne();br=new Map;Wt.register(br)});var sd=class e{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}constructor(t){this._renderer=t}init(t){if(t={...e.defaultOptions,...t},t.view)q(be,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view;this.screen=new se(0,0,t.width,t.height),this.canvas=t.canvas||le.get().createCanvas(),this.antialias=!!t.antialias;let{depth:n,...s}=t;this.texture=nl(this.canvas,s),this.renderTarget=new xr({colorTextures:[this.texture],depth:!!n,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.texture.source.on("resize",this._updateScreenSize,this),this.resolution=t.resolution,this._updateScreenSize()}resize(t,n,s){this.texture.source.resize(t,n,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){if((typeof t==="boolean"?t:!!t?.removeView)&&this.canvas.parentNode)this.canvas.parentNode.removeChild(this.canvas);this.texture.source.off("resize",this._updateScreenSize,this),Xe.removeScreen(this._renderer.uid),Js.removeScreen(this._renderer.uid),this.texture.destroy()}_updateScreenSize(){let{pixelWidth:t,pixelHeight:n}=this.texture.source,s=this._renderer.uid;Xe.setScreenSize(s,t,n),Js.setScreenSize(s,t,n)}},Nv;var Gv=M(()=>{it();z();st();Ie();td();xu();us();nd();sd.extension={type:[D.WebGLSystem,D.WebGPUSystem,D.CanvasSystem],name:"view",priority:0};sd.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};Nv=sd});var Lv,Uv;var Wv=M(()=>{iv();ov();pv();av();kx();Zb();nv();sv();rv();yv();lv();bv();_v();Tv();Cv();Av();$v();Iv();Fv();Gv();Lv=[gv,el,Ei,Nv,Ja,Mv,Bv,Qa,xv,ya,Ov,tl],Uv=[Ka,jh,qa,za,Va,Ya,ja,Ha]});function Xv(e,t,n,s,r,i){let o=i?1:-1;return e.identity(),e.a=1/s*2,e.d=o*(1/r*2),e.tx=-1-t*e.a,e.ty=-o-n*e.d,e}var Vv=()=>{};function jv(e){if(e.colorAttachments.length===0)return!1;let t=e.colorTexture.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var Yv=()=>{};class rd{constructor(e){this.rootViewPort=new se,this.viewport=new se,this.onRenderTargetChange=new yi("onRenderTargetChange"),this.projectionMatrix=new j,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._bindState={target:null,frame:void 0,mipLevel:0,layer:0,flipY:!1},this._bindFrame=new se,this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}get renderSurface(){return this._bindState.target}get mipLevel(){return this._bindState.mipLevel}get layer(){return this._bindState.layer}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart(e){this._renderTargetStack.length=0,this.push(e),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=jv(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,n,s,r=0,i=0,o){let a;if("target"in e)a=e;else q("8.20.0","RenderTargetSystem.bind: positional arguments are deprecated, please use an options object instead: bind({ target, clear, clearColor, frame, mipLevel, layer, flipY })"),a={target:e,clear:t,clearColor:n,frame:s,mipLevel:r,layer:i,flipY:o};let l=a.target;t=a.clear??!0,n=a.clearColor,r=(a.mipLevel??0)|0,i=(a.layer??0)|0,o=a.flipY,s=a.frame;let u=this.getRenderTarget(l),c=this.renderTarget!==u||!!u.flipY!==!!o;this.renderTarget=u;let h=this.getGpuRenderTarget(u);if(u.pixelWidth!==h.width||u.pixelHeight!==h.height)this.adaptor.resizeGpuRenderTarget(u),h.width=u.pixelWidth,h.height=u.pixelHeight;let d=u.colorAttachments[0]?.texture||u.depthStencilAttachment?.texture,f=this.viewport,m=d.dimension==="3d"?Math.max(d.depth>>r,1):d.depthOrArrayLayers;if(i<0||i>=m)throw Error(`[RenderTargetSystem] layer ${i} is out of bounds (layer count=${m}).`);let p=this._bindState;p.target=l,p.frame=s?this._bindFrame.copyFrom(s):void 0,p.mipLevel=r,p.layer=i,p.flipY=o;let y=Math.max(d.pixelWidth>>r,1),g=Math.max(d.pixelHeight>>r,1);if(!s&&l instanceof K)s=l.frame;if(s){let x=d._resolution,b=1<{if(e!==t)this._releaseRenderTarget(t,e);else e.off("destroy",this._onRenderTargetDestroy,this)}),this._renderSurfaceToRenderTargetHash.clear();for(let e of Object.values(this._gpuRenderTargetHash))if(e)this.adaptor.destroyGpuRenderTarget(e);this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;if(Et.test(e))e=nl(e).source;if(e instanceof xr)t=e,e.once("destroy",this._onRenderTargetDestroy,this);else if(e instanceof ve){let n=e.format;if(t=n.includes("depth")||n.includes("stencil")?new xr({colorTextures:0,depthStencilTexture:e}):new xr({colorTextures:[e]}),e.source instanceof Et)t.isRoot=!0;e.once("destroy",this._onRenderSurfaceDestroy,this)}return this._renderSurfaceToRenderTargetHash.set(e,t),t}_onRenderSurfaceDestroy(e){let t=this._renderSurfaceToRenderTargetHash.get(e);if(t)this._releaseRenderTarget(e,t)}_onRenderTargetDestroy(e){this._renderSurfaceToRenderTargetHash.delete(e),this._releaseGpuRenderTarget(e)}_releaseRenderTarget(e,t){t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e),e.off("destroy",this._onRenderSurfaceDestroy,this),this._releaseGpuRenderTarget(t)}_releaseGpuRenderTarget(e){let t=this._gpuRenderTargetHash[e.uid];if(t)this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(t)}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this._bindState.target=null}}var Hv=M(()=>{Ce();st();Ie();Be();gi();Vv();Dn();zu();si();St();Ne();nd();Yv();td()});var Pi;var zv=M(()=>{Pi=((e)=>(e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e))(Pi||{})});class id{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}var qv=()=>{};class sl{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new bt({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){let{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){let{_gl:n}=this;if(this._boundBufferBases[t]!==e)this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,n.bindBufferBase(n.UNIFORM_BUFFER,t,e.buffer)}nextBindBase(e){if(this._bindCallId++,this._minBaseLocation=0,e){if(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1)this._nextBindBaseIndex=1}}freeLocationForBufferBase(e){let t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;let n=0,s=this._nextBindBaseIndex;while(n<2){if(s>=this._maxBindings)s=this._minBaseLocation,n++;let r=this._boundBufferBases[s];if(r&&r._lastBindCallId===this._bindCallId){s++;continue}break}if(t=s,this._nextBindBaseIndex=s+1,n>=2)return-1;return e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t}getLastBindBaseLocation(e){let t=e._lastBindBaseLocation;if(this._boundBufferBases[t]===e)return t;return-1}bindBufferRange(e,t,n,s){let{_gl:r}=this;n||(n=0),t||(t=0),this._boundBufferBases[t]=null,r.bindBufferRange(r.UNIFORM_BUFFER,t||0,e.buffer,n*256,s||256)}updateBuffer(e){let{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);let s=e.data,r=e.descriptor.usage&_e.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;if(s)if(n.byteLength>=s.byteLength)t.bufferSubData(n.type,e._updateOffset,s,e._updateOffset/s.BYTES_PER_ELEMENT,(e._updateSize||s.byteLength)/s.BYTES_PER_ELEMENT);else n.byteLength=s.byteLength,t.bufferData(n.type,s,r);else n.byteLength=e.descriptor.size,t.bufferData(n.type,n.byteLength,r);return n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){let n=e._gpuData[this._renderer.uid];if(!n)return;if(!t)this._gl.deleteBuffer(n.buffer)}createGLBuffer(e){let{_gl:t}=this,n=Pi.ARRAY_BUFFER;if(e.descriptor.usage&_e.INDEX)n=Pi.ELEMENT_ARRAY_BUFFER;else if(e.descriptor.usage&_e.UNIFORM)n=Pi.UNIFORM_BUFFER;let s=new id(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}var Kv=M(()=>{z();Gn();gs();zv();qv();sl.extension={type:[D.WebGLSystem],name:"buffer"}});var od=class e{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){t={...e.defaultOptions,...t};let n=this.multiView=t.multiView;if(t.context&&n)te("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),n=!1;if(n)this.canvas=le.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height);else this.canvas=this._renderer.view.canvas;if(t.context)this.initFromContext(t.context);else{let s=this._renderer.background.alpha<1,r=t.premultipliedAlpha??!0,i=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:s,premultipliedAlpha:r,antialias:i,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView){if(t!==this.canvas)te("multiView is disabled, but targetCanvas is not the main canvas");return}let{canvas:n}=this;if(n.width{if(this.gl.isContextLost())this.extensions.loseContext?.restoreContext()},0)}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){let t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){let n=t.getContextAttributes();if(n&&!n.stencil)te("Provided WebGL context does not have a stencil buffer, masks may not render correctly");let s=this.supports,r=this.webGLVersion===2,i=this.extensions;if(s.uint32Indices=r||!!i.uint32ElementIndex,s.uniformBufferObject=r,s.vertexArrayObject=r||!!i.vertexArrayObject,s.srgbTextures=r||!!i.srgb,s.nonPowOf2wrapping=r,s.nonPowOf2mipmaps=r,s.msaa=r,!s.uint32Indices)te("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}},Jv;var Zv=M(()=>{it();z();Be();od.extension={type:[D.WebGLSystem],name:"context"};od.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};Jv=od});function Qv(e,t){for(let n in e.attributes){let s=e.attributes[n],r=t[n];if(r)s.format??(s.format=r.format),s.offset??(s.offset=r.offset),s.instance??(s.instance=r.instance);else if(!s.format)te(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}WA(e)}function WA(e){let{buffers:t,attributes:n}=e,s={},r={};for(let i in t){let o=t[i];s[o.uid]=0,r[o.uid]=0}for(let i in n){let o=n[i];s[o.buffer.uid]+=Sn(o.format).stride}for(let i in n){let o=n[i];o.stride??(o.stride=s[o.buffer.uid]),o.start??(o.start=r[o.buffer.uid]),r[o.buffer.uid]+=Sn(o.format).stride}}var e_=M(()=>{Be();oi()});var rl,Un,fe;var Ri=M(()=>{rl=((e)=>(e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e))(rl||{}),Un=((e)=>(e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e))(Un||{}),fe=((e)=>(e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT",e))(fe||{})});function n_(e){return t_[e]??t_.float32}var t_;var s_=M(()=>{Ri();t_={uint8x2:fe.UNSIGNED_BYTE,uint8x4:fe.UNSIGNED_BYTE,sint8x2:fe.BYTE,sint8x4:fe.BYTE,unorm8x2:fe.UNSIGNED_BYTE,unorm8x4:fe.UNSIGNED_BYTE,snorm8x2:fe.BYTE,snorm8x4:fe.BYTE,uint16x2:fe.UNSIGNED_SHORT,uint16x4:fe.UNSIGNED_SHORT,sint16x2:fe.SHORT,sint16x4:fe.SHORT,unorm16x2:fe.UNSIGNED_SHORT,unorm16x4:fe.UNSIGNED_SHORT,snorm16x2:fe.SHORT,snorm16x4:fe.SHORT,float16x2:fe.HALF_FLOAT,float16x4:fe.HALF_FLOAT,float32:fe.FLOAT,float32x2:fe.FLOAT,float32x3:fe.FLOAT,float32x4:fe.FLOAT,uint32:fe.UNSIGNED_INT,uint32x2:fe.UNSIGNED_INT,uint32x3:fe.UNSIGNED_INT,uint32x4:fe.UNSIGNED_INT,sint32:fe.INT,sint32x2:fe.INT,sint32x3:fe.INT,sint32x4:fe.INT}});class r_{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class il{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new bt({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);let t=this._renderer.context.extensions.vertexArrayObject;if(t)e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=(s)=>t.bindVertexArrayOES(s),e.deleteVertexArray=(s)=>t.deleteVertexArrayOES(s);let n=this._renderer.context.extensions.vertexAttribDivisorANGLE;if(n)e.drawArraysInstanced=(s,r,i,o)=>{n.drawArraysInstancedANGLE(s,r,i,o)},e.drawElementsInstanced=(s,r,i,o,a)=>{n.drawElementsInstancedANGLE(s,r,i,o,a)},e.vertexAttribDivisor=(s,r)=>n.vertexAttribDivisorANGLE(s,r);this._activeGeometry=null,this._activeVao=null}bind(e,t){let n=this.gl;this._activeGeometry=e;let s=this.getVao(e,t);if(this._activeVao!==s)this._activeVao=s,n.bindVertexArray(s);this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n{z();Gn();oi();e_();s_();XA={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};il.extension={type:[D.WebGLSystem],name:"geometry"}});var VA,ad=class e{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){let{useBackBuffer:n,antialias:s}={...e.defaultOptions,...t};if(this.useBackBuffer=n,this._antialias=s,!this._renderer.context.supports.msaa)te("antialiasing, is not supported on when using the back buffer"),this._antialias=!1;this._state=ft.for2d();let r=new wt({vertex:` attribute vec2 aPosition; out vec2 vUv; @@ -573,7 +573,7 @@ fn mainFragment( void main() { finalColor = texture(uTexture, vUv); - }`,name:"big-triangle"});this._bigTriangleShader=new It({glProgram:r,resources:{uTexture:j.WHITE.source}})}renderStart(t){let n=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!n.isRoot,this._useBackBufferThisRender){let s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let t=this._renderer;if(t.renderTarget.finishRenderPass(),!this._useBackBufferThisRender)return;t.renderTarget.bind({target:this._targetTexture,clear:!1}),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:kA,shader:this._bigTriangleShader,state:this._state})}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new j({source:new le({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){if(this._backBufferTexture)this._backBufferTexture.destroy(),this._backBufferTexture=null}},Yv;var Vv=w(()=>{W();Pe();zs();Ys();yn();gt();De();En();kA=new qt({attributes:{aPosition:[-1,-1,3,-1,-1,3]}});Zh.extension={type:[E.WebGLSystem],name:"backBuffer",priority:1};Zh.defaultOptions={useBackBuffer:!1};Yv=Zh});class el{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){if(this._colorMaskCache===e)return;this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1))}}var Hv=w(()=>{W();el.extension={type:[E.WebGLSystem],name:"colorMask"}});class tl{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){let t=this._renderer,{geometry:n,shader:s,state:r,skipSync:i,topology:o,size:a,start:l,instanceCount:u}=e;if(t.shader.bind(s,i),t.geometry.bind(n,t.shader._activeProgram),r)t.state.set(r);t.geometry.draw(o,a,l,u??n.instanceCount)}destroy(){this._renderer=null}}var zv=w(()=>{W();tl.extension={type:[E.WebGLSystem],name:"encoder"}});class nl{constructor(e){this._renderer=e}contextChange(){let e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=fa(this.maxTextures,e);let t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}var qv=w(()=>{W();ju();nl.extension={type:[E.WebGLSystem],name:"limits"}});class Qh{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[],this.stencilMode=je.DISABLED,this.stencilReference=0,this.maskStackIndex=0}}var Kv=w(()=>{Js()});var Bn;var Jv=w(()=>{Js();Bn=[];Bn[je.NONE]=void 0;Bn[je.DISABLED]={stencilWriteMask:0,stencilReadMask:0};Bn[je.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};Bn[je.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};Bn[je.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};Bn[je.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}}});class sl{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:je.NONE},this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this._activeGpuRenderTarget=null,this.resetState()}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderer.renderTarget.getGpuRenderTarget(e);this._activeGpuRenderTarget=t,this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=je.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){let n=this._activeGpuRenderTarget??(this._activeGpuRenderTarget=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget)),s=this._gl,r=Bn[e],i=this._stencilCache;if(n.stencilMode=e,n.stencilReference=t,e===je.DISABLED){if(this._stencilCache.enabled)this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST);return}if(!this._stencilCache.enabled)this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST);if(e!==i.stencilMode||i.stencilReference!==t)i.stencilMode=e,i.stencilReference=t,s.stencilFunc(this._comparisonFuncMapping[r.stencilBack.compare],t,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[r.stencilBack.passOp])}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._gl=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}}var Zv=w(()=>{W();Jv();Js();sl.extension={type:[E.WebGLSystem],name:"stencil"}});class ed{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!ia())throw Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(e){let t=this.getUniformGroupData(e);e.buffer||(e.buffer=new ct({data:new Float32Array(t.layout.size/4),usage:ce.UNIFORM|ce.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){let t=e._signature,n=this._syncFunctionHash[t];if(!n){let s=Object.keys(e.uniformStructures).map((o)=>e.uniformStructures[o]),r=this._adaptor.createUboElements(s),i=this._generateUboSync(r.uboElements);n=this._syncFunctionHash[t]={layout:r,syncFunction:i}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,n){let s=this.getUniformGroupData(e);e.buffer||(e.buffer=new ct({data:new Float32Array(s.layout.size/4),usage:ce.UNIFORM|ce.COPY_DST}));let r=null;if(!t)t=e.buffer.data,r=e.buffer.dataInt32;return n||(n=0),s.syncFunction(e.uniforms,t,r,n),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;let t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}var Qv=w(()=>{Pu();Hs();os()});function e_(e){let t=e.map((i)=>({data:i,offset:0,size:0})),n=16,s=0,r=0;for(let i=0;i1)s=Math.max(s,16)*o.data.size;let a=s===12?16:s;o.size=s;let l=r%16;if(l>0&&16-l{td={f32:4,i32:4,"vec2":8,"vec3":12,"vec4":16,"vec2":8,"vec3":12,"vec4":16,u32:4,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64}});var Dn;var sd=w(()=>{Dn=[{type:"mat3x3",test:(e)=>e.value.a!==void 0,ubo:` + }`,name:"big-triangle"});this._bigTriangleShader=new Xt({glProgram:r,resources:{uTexture:K.WHITE.source}})}renderStart(t){let n=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!n.isRoot,this._useBackBufferThisRender){let s=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=s.colorTexture,t.target=this._getBackBufferTexture(s.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let t=this._renderer;if(t.renderTarget.finishRenderPass(),!this._useBackBufferThisRender)return;t.renderTarget.bind({target:this._targetTexture,clear:!1}),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:VA,shader:this._bigTriangleShader,state:this._state})}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new K({source:new ve({width:t.width,height:t.height,resolution:t._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(t.width,t.height,t._resolution),this._backBufferTexture}destroy(){if(this._backBufferTexture)this._backBufferTexture.destroy(),this._backBufferTexture=null}},o_;var a_=M(()=>{z();Be();sr();er();wn();St();Ne();Fn();VA=new tn({attributes:{aPosition:[-1,-1,3,-1,-1,3]}});ad.extension={type:[D.WebGLSystem],name:"backBuffer",priority:1};ad.defaultOptions={useBackBuffer:!1};o_=ad});class ol{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){if(this._colorMaskCache===e)return;this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1))}}var l_=M(()=>{z();ol.extension={type:[D.WebGLSystem],name:"colorMask"}});class al{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){let t=this._renderer,{geometry:n,shader:s,state:r,skipSync:i,topology:o,size:a,start:l,instanceCount:u}=e;if(t.shader.bind(s,i),t.geometry.bind(n,t.shader._activeProgram),r)t.state.set(r);t.geometry.draw(o,a,l,u??n.instanceCount)}destroy(){this._renderer=null}}var c_=M(()=>{z();al.extension={type:[D.WebGLSystem],name:"encoder"}});class ll{constructor(e){this._renderer=e}contextChange(){let e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=ba(this.maxTextures,e);let t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}var u_=M(()=>{z();Qu();ll.extension={type:[D.WebGLSystem],name:"limits"}});class ld{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[],this.stencilMode=Ye.DISABLED,this.stencilReference=0,this.maskStackIndex=0}}var h_=M(()=>{or()});var Wn;var d_=M(()=>{or();Wn=[];Wn[Ye.NONE]=void 0;Wn[Ye.DISABLED]={stencilWriteMask:0,stencilReadMask:0};Wn[Ye.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}};Wn[Ye.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}};Wn[Ye.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}};Wn[Ye.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}}});class cl{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Ye.NONE},this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this._activeGpuRenderTarget=null,this.resetState()}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderer.renderTarget.getGpuRenderTarget(e);this._activeGpuRenderTarget=t,this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Ye.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){let n=this._activeGpuRenderTarget??(this._activeGpuRenderTarget=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget)),s=this._gl,r=Wn[e],i=this._stencilCache;if(n.stencilMode=e,n.stencilReference=t,e===Ye.DISABLED){if(this._stencilCache.enabled)this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST);return}if(!this._stencilCache.enabled)this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST);if(e!==i.stencilMode||i.stencilReference!==t)i.stencilMode=e,i.stencilReference=t,s.stencilFunc(this._comparisonFuncMapping[r.stencilBack.compare],t,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[r.stencilBack.passOp])}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._gl=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}}var f_=M(()=>{z();d_();or();cl.extension={type:[D.WebGLSystem],name:"stencil"}});class cd{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!ha())throw Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(e){let t=this.getUniformGroupData(e);e.buffer||(e.buffer=new mt({data:new Float32Array(t.layout.size/4),usage:_e.UNIFORM|_e.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){let t=e._signature,n=this._syncFunctionHash[t];if(!n){let s=Object.keys(e.uniformStructures).map((o)=>e.uniformStructures[o]),r=this._adaptor.createUboElements(s),i=this._generateUboSync(r.uboElements);n=this._syncFunctionHash[t]={layout:r,syncFunction:i}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,n){let s=this.getUniformGroupData(e);e.buffer||(e.buffer=new mt({data:new Float32Array(s.layout.size/4),usage:_e.UNIFORM|_e.COPY_DST}));let r=null;if(!t)t=e.buffer.data,r=e.buffer.dataInt32;return n||(n=0),s.syncFunction(e.uniforms,t,r,n),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;let t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}var m_=M(()=>{Lu();nr();gs()});function p_(e){let t=e.map((i)=>({data:i,offset:0,size:0})),n=16,s=0,r=0;for(let i=0;i1)s=Math.max(s,16)*o.data.size;let a=s===12?16:s;o.size=s;let l=r%16;if(l>0&&16-l{ud={f32:4,i32:4,"vec2":8,"vec3":12,"vec4":16,"vec2":8,"vec3":12,"vec4":16,u32:4,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64}});var Xn;var dd=M(()=>{Xn=[{type:"mat3x3",test:(e)=>e.value.a!==void 0,ubo:` var matrix = uv[name].toArray(true); data[offset] = matrix[0]; data[offset + 1] = matrix[1]; @@ -644,23 +644,23 @@ fn mainFragment( cv[2] = v.blue; gl.uniform3f(ud[name].location, v.red, v.green, v.blue); } - `}]});function t_(e,t,n){let s=[` + `}]});function g_(e,t,n){let s=[` var v = null; var v2 = null; var t = 0; var index = 0; var name = null; var arrayOffset = null; - `],r=0;for(let o=0;o1)c=a.offset/4,s.push(n(a,c-r));else{let h=t[a.data.type];c=a.offset/4,s.push(` + `],r=0;for(let o=0;o1)c=a.offset/4,s.push(n(a,c-r));else{let h=t[a.data.type];c=a.offset/4,s.push(` v = uv.${l}; offset += ${c-r}; ${h}; `)}r=c}let i=s.join(` -`);return Function("uv","data","dataInt32","offset",i)}var n_=w(()=>{sd()});function hr(e,t){return` +`);return Function("uv","data","dataInt32","offset",i)}var y_=M(()=>{dd()});function vr(e,t){return` for (let i = 0; i < ${e*t}; i++) { data[offset + (((i / ${e})|0) * 4) + (i % ${e})] = v[i]; } - `}var rd,b8;var s_=w(()=>{rd={f32:` + `}var fd,j8;var x_=M(()=>{fd={f32:` data[offset] = v;`,i32:` dataInt32[offset] = v;`,u32:` dataInt32[offset] = v;`,"vec2":` @@ -706,12 +706,12 @@ fn mainFragment( data[offset + 10] = v[8];`,"mat4x4":` for (let i = 0; i < 16; i++) { data[offset + i] = v[i]; - }`,"mat3x2":hr(3,2),"mat4x2":hr(4,2),"mat2x3":hr(2,3),"mat4x3":hr(4,3),"mat2x4":hr(2,4),"mat3x4":hr(3,4)},b8={...rd,"mat2x2":` + }`,"mat3x2":vr(3,2),"mat4x2":vr(4,2),"mat2x3":vr(2,3),"mat4x3":vr(4,3),"mat2x4":vr(2,4),"mat3x4":vr(3,4)},j8={...fd,"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3]; - `}});function r_(e,t){let n=Math.max(td[e.data.type]/16,1),s=e.data.value.length/e.data.size,r=(4-s%4)%4,i=e.data.type.indexOf("i32")>=0?"dataInt32":"data";return` + `}});function b_(e,t){let n=Math.max(ud[e.data.type]/16,1),s=e.data.value.length/e.data.size,r=(4-s%4)%4,i=e.data.type.indexOf("i32")>=0?"dataInt32":"data";return` v = uv.${e.data.name}; offset += ${t}; @@ -727,7 +727,7 @@ fn mainFragment( } ${r!==0?`arrayOffset += ${r};`:""} } - `}var i_=w(()=>{nd()});function o_(e){return t_(e,rd,r_)}var a_=w(()=>{n_();s_();i_()});var rl;var l_=w(()=>{W();Qv();nd();a_();rl=class rl extends ed{constructor(){super({createUboElements:e_,generateUboSync:o_})}};rl.extension={type:[E.WebGLSystem],name:"ubo"}});class id{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Q,this._boundFramebuffer=void 0}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Q,this._boundFramebuffer=void 0;let e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},(n,s)=>e.COLOR_ATTACHMENT0+s)}copyToTexture(e,t,n,s,r){let i=this._renderTargetSystem,o=this._renderer,a=i.getGpuRenderTarget(e),l=o.gl;return this.finishRenderPass(e),l.bindFramebuffer(l.FRAMEBUFFER,a.resolveTargetFramebuffer),this._boundFramebuffer=a.resolveTargetFramebuffer,o.texture.bind(t,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,r.x,r.y,n.x,n.y,s.width,s.height),t}copyDepthTexture(e,t,n,s,r){let i=this._renderTargetSystem,o=this._renderer.gl;this.finishRenderPass(e);let a=i.getRenderTarget(t),l=i.getGpuRenderTarget(e),u=i.getGpuRenderTarget(a);o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.bindFramebuffer(o.DRAW_FRAMEBUFFER,u.framebuffer),this._boundFramebuffer=void 0,o.blitFramebuffer(n.x,n.y,n.x+s.width,n.y+s.height,r.x,r.y,r.x+s.width,r.y+s.height,o.DEPTH_BUFFER_BIT,o.NEAREST)}startRenderPass(e,t=!0,n,s,r=0,i=0){let a=this._renderTargetSystem.getGpuRenderTarget(e);if(i!==0&&this._renderer.context.webGLVersion<2)throw Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(r>0){if(a.msaa)throw Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}e.colorAttachments.forEach((h)=>{this._renderer.texture.unbind(h.texture)});let l=this._renderer.gl;if(this.bindFramebuffer(a.framebuffer),!e.isRoot&&e.colorAttachments.length>0&&(a._attachedMipLevel!==r||a._attachedLayer!==i))e.colorAttachments.forEach((h,d)=>{let f=h.texture,m=this._renderer.texture.getGlSource(f);if(m.target===l.TEXTURE_2D){if(i!==0)throw Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,l.TEXTURE_2D,m.texture,r)}else if(m.target===l.TEXTURE_2D_ARRAY||m.target===l.TEXTURE_3D)l.framebufferTextureLayer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,m.texture,r,i);else if(m.target===l.TEXTURE_CUBE_MAP){if(i<0||i>5)throw Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,l.TEXTURE_CUBE_MAP_POSITIVE_X+i,m.texture,r)}else throw Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),a._attachedMipLevel=r,a._attachedLayer=i;if(a.framebuffer){if(e.depthStencilAttachment)this._attachDepthStencilTexture(e,r,i);else if(!a.depthStencilRenderBuffer&&(e.stencil||e.depth))this._initStencil(a)}if(e.colorAttachments.length>1)this._setDrawBuffers(e,l);let u=s.y;if(e.isRoot)u=e.pixelHeight-s.height-s.y;let c=this._viewPortCache;if(c.x!==s.x||c.y!==u||c.width!==s.width||c.height!==s.height)c.x=s.x,c.y=u,c.width=s.width,c.height=s.height,l.viewport(s.x,u,s.width,s.height);this.clear(e,t,n)}finishRenderPass(e){let n=this._renderTargetSystem.getGpuRenderTarget(e);if(!n.msaa||e.colorAttachments.length===0)return;let s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,n.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,n.framebuffer),s.blitFramebuffer(0,0,n.width,n.height,0,0,n.width,n.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer),this._boundFramebuffer=n.framebuffer}initGpuRenderTarget(e){let n=this._renderer.gl,s=new Qh;s._attachedMipLevel=0,s._attachedLayer=0;let r=e.colorTexture;if(r instanceof St)return this._renderer.context.ensureCanvasSize(r.resource),s.framebuffer=null,s;if(s.width=e.pixelWidth,s.height=e.pixelHeight,e.colorAttachments.length===0)this._initDepth(e,s);else this._initColor(e,s);if(e.depthStencilAttachment)this._attachDepthStencilTexture(e,0,0);return n.bindFramebuffer(n.FRAMEBUFFER,null),this._boundFramebuffer=null,s}destroyGpuRenderTarget(e){let t=this._renderer.gl;if(e.framebuffer)t.deleteFramebuffer(e.framebuffer),e.framebuffer=null;if(e.resolveTargetFramebuffer)t.deleteFramebuffer(e.resolveTargetFramebuffer),e.resolveTargetFramebuffer=null;if(e.depthStencilRenderBuffer)t.deleteRenderbuffer(e.depthStencilRenderBuffer),e.depthStencilRenderBuffer=null;e.msaaRenderBuffer.forEach((n)=>{t.deleteRenderbuffer(n)}),e.msaaRenderBuffer.length=0}clear(e,t,n,s,r=0,i=0){if(!t)return;if(i!==0)throw Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");let o=this._renderTargetSystem;if(typeof t==="boolean")t=t?mt.ALL:mt.NONE;if(e.colorAttachments.length===0){if(t&=~mt.COLOR,!t)return}let a=this._renderer.gl,l=!!(t&mt.DEPTH)&&!this._renderer.state.depthMaskEnabled;if(t&mt.COLOR){n??(n=o.defaultClearColor);let u=this._clearColorCache,c=n;if(u[0]!==c[0]||u[1]!==c[1]||u[2]!==c[2]||u[3]!==c[3])u[0]=c[0],u[1]=c[1],u[2]=c[2],u[3]=c[3],a.clearColor(c[0],c[1],c[2],c[3])}if(l)a.depthMask(!0);if(a.clear(t),l)a.depthMask(!1)}resizeGpuRenderTarget(e){if(e.isRoot)return;let t=this._renderTargetSystem.getGpuRenderTarget(e);if(t.width=e.pixelWidth,t.height=e.pixelHeight,e.colorAttachments.length>0)this._resizeColor(e,t);if(t.depthStencilRenderBuffer)this._resizeStencil(t);this._boundFramebuffer=void 0}_initColor(e,t){let n=this._renderer,s=n.gl,r=s.createFramebuffer();if(t.resolveTargetFramebuffer=r,s.bindFramebuffer(s.FRAMEBUFFER,r),e.colorAttachments.forEach((o,a)=>{let l=o.texture;if(l.antialias)if(n.context.supports.msaa)t.msaa=!0;else V("[RenderTexture] Antialiasing on textures is not supported in WebGL1");n.texture.bindSource(l,0);let u=n.texture.getGlSource(l),c=u.texture;if(u.target===s.TEXTURE_2D)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,s.TEXTURE_2D,c,0);else if(u.target===s.TEXTURE_2D_ARRAY||u.target===s.TEXTURE_3D)s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,c,0,0);else if(u.target===s.TEXTURE_CUBE_MAP)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,s.TEXTURE_CUBE_MAP_POSITIVE_X,c,0);else throw Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),t.msaa){let o=s.createFramebuffer();t.framebuffer=o,s.bindFramebuffer(s.FRAMEBUFFER,o),e.colorAttachments.forEach((a,l)=>{let u=s.createRenderbuffer();t.msaaRenderBuffer[l]=u})}else t.framebuffer=r;this._resizeColor(e,t)}_initDepth(e,t){let n=this._renderer;if(n.context.webGLVersion<2)throw Error("[RenderTargetSystem] Depth-only render targets require WebGL2.");let s=n.gl,r=s.createFramebuffer();t.resolveTargetFramebuffer=r,t.framebuffer=r,s.bindFramebuffer(s.FRAMEBUFFER,r),s.drawBuffers([s.NONE]),s.readBuffer(s.NONE)}_resizeColor(e,t){let n=e.colorAttachments[0].texture;if(t._attachedMipLevel=0,t._attachedLayer=0,e.colorAttachments.forEach((s,r)=>{if(r===0)return;s.texture.resize(n.width,n.height,n._resolution)}),t.msaa){let s=this._renderer,r=s.gl,i=t.framebuffer;r.bindFramebuffer(r.FRAMEBUFFER,i),e.colorAttachments.forEach((o,a)=>{let l=o.texture;s.texture.bindSource(l,0);let c=s.texture.getGlSource(l).internalFormat,h=t.msaaRenderBuffer[a];r.bindRenderbuffer(r.RENDERBUFFER,h),r.renderbufferStorageMultisample(r.RENDERBUFFER,4,c,l.pixelWidth,l.pixelHeight),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,r.RENDERBUFFER,h)})}}_attachDepthStencilTexture(e,t,n){let s=this._renderer,r=s.gl,i=e.depthStencilAttachment.texture,o=s.texture.getGlSource(i),a=o.texture,l=i.format,u;if(l==="depth24plus-stencil8"||l==="depth32float-stencil8")u=r.DEPTH_STENCIL_ATTACHMENT;else if(l==="stencil8")u=r.STENCIL_ATTACHMENT;else u=r.DEPTH_ATTACHMENT;if(o.target===r.TEXTURE_2D)r.framebufferTexture2D(r.FRAMEBUFFER,u,r.TEXTURE_2D,a,t);else if(o.target===r.TEXTURE_2D_ARRAY||o.target===r.TEXTURE_3D)r.framebufferTextureLayer(r.FRAMEBUFFER,u,a,t,n);else if(o.target===r.TEXTURE_CUBE_MAP)r.framebufferTexture2D(r.FRAMEBUFFER,u,r.TEXTURE_CUBE_MAP_POSITIVE_X+n,a,t)}_initStencil(e){if(e.framebuffer===null)return;let t=this._renderer.gl,n=t.createRenderbuffer();e.depthStencilRenderBuffer=n,t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,n),this._resizeStencil(e)}_resizeStencil(e){let t=this._renderer.gl;if(t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa)t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height);else t.renderbufferStorage(t.RENDERBUFFER,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}prerender(e){if(e.colorAttachments.length===0)return;let t=e.colorAttachments[0].texture.resource;if(this._renderer.context.multiView&&St.test(t))this._renderer.context.ensureCanvasSize(t)}postrender(e){if(!this._renderer.context.multiView||e.colorAttachments.length===0)return;let t=e.colorAttachments[0].texture;if(St.test(t.resource)){let n=this._renderer.context.canvas,s=t;s.context2D.drawImage(n,0,s.pixelHeight-n.height)}}_setDrawBuffers(e,t){let n=e.colorAttachments.length,s=this._drawBuffersCache[n];if(this._renderer.context.webGLVersion===1){let r=this._renderer.context.extensions.drawBuffers;if(!r)V("[RenderTexture] This WebGL1 context does not support rendering to multiple targets");else r.drawBuffersWEBGL(s)}else t.drawBuffers(s)}resetState(){this._boundFramebuffer=void 0,this._viewPortCache=new Q,this._clearColorCache=[0,0,0,0]}bindFramebuffer(e){if(this._boundFramebuffer===e)return;this._boundFramebuffer=e,this._renderer.gl.bindFramebuffer(this._renderer.gl.FRAMEBUFFER,e)}}var c_=w(()=>{et();Pe();Hr();oi();Kv()});var il;var u_=w(()=>{W();$v();c_();il=class il extends qh{constructor(e){super(e);this.adaptor=new id,this.adaptor.init(e,this)}resetState(){this.adaptor.resetState()}};il.extension={type:[E.WebGLSystem],name:"renderTarget"}});var Si;var od=w(()=>{Ke();qe();Si=class Si extends de{constructor({buffer:e,offset:t,size:n}){super();this.uid=ee("buffer"),this._resourceType="bufferResource",this._resourceId=ee("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=n,this.buffer.on("change",this.onBufferChange,this)}get _gcLastUsed(){return this.buffer?._gcLastUsed??-1}set _gcLastUsed(e){if(this.buffer)this.buffer._gcLastUsed=e}onBufferChange(){this._resourceId=ee("resource"),this.emit("change",this)}destroy(e=!1){if(this.destroyed=!0,e)this.buffer.destroy();this.emit("change",this),this.buffer=null,this.removeAllListeners()}}});var ad;var h_=w(()=>{Ke();qe();ad=class ad extends de{constructor(e,t){super();this._resourceType="textureView",this._resourceId=ee("resource"),this.source=e,this.viewDescriptor=t,this._onChange=this._onChange.bind(this),this._onDestroy=this._onDestroy.bind(this),this.source.on("change",this._onChange),this.source.on("destroy",this._onDestroy)}_onChange(){this.emit("change",this)}_onDestroy(){this.destroy()}get destroyed(){return this.source.destroyed}destroy(){if(this.source)this.source.off("change",this._onChange),this.source.off("destroy",this._onDestroy);this.emit("destroy",this),this.removeAllListeners()}}});function d_(e,t){let n=[],s=[` + `}var v_=M(()=>{hd()});function __(e){return g_(e,fd,b_)}var S_=M(()=>{y_();x_();v_()});var ul;var w_=M(()=>{z();m_();hd();S_();ul=class ul extends cd{constructor(){super({createUboElements:p_,generateUboSync:__})}};ul.extension={type:[D.WebGLSystem],name:"ubo"}});class md{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new se,this._boundFramebuffer=void 0}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new se,this._boundFramebuffer=void 0;let e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},(n,s)=>e.COLOR_ATTACHMENT0+s)}copyToTexture(e,t,n,s,r){let i=this._renderTargetSystem,o=this._renderer,a=i.getGpuRenderTarget(e),l=o.gl;return this.finishRenderPass(e),l.bindFramebuffer(l.FRAMEBUFFER,a.resolveTargetFramebuffer),this._boundFramebuffer=a.resolveTargetFramebuffer,o.texture.bind(t,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,r.x,r.y,n.x,n.y,s.width,s.height),t}copyDepthTexture(e,t,n,s,r){let i=this._renderTargetSystem,o=this._renderer.gl;this.finishRenderPass(e);let a=i.getRenderTarget(t),l=i.getGpuRenderTarget(e),u=i.getGpuRenderTarget(a);o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.bindFramebuffer(o.DRAW_FRAMEBUFFER,u.framebuffer),this._boundFramebuffer=void 0,o.blitFramebuffer(n.x,n.y,n.x+s.width,n.y+s.height,r.x,r.y,r.x+s.width,r.y+s.height,o.DEPTH_BUFFER_BIT,o.NEAREST)}startRenderPass(e,t=!0,n,s,r=0,i=0){let a=this._renderTargetSystem.getGpuRenderTarget(e);if(i!==0&&this._renderer.context.webGLVersion<2)throw Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(r>0){if(a.msaa)throw Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}e.colorAttachments.forEach((h)=>{this._renderer.texture.unbind(h.texture)});let l=this._renderer.gl;if(this.bindFramebuffer(a.framebuffer),!e.isRoot&&e.colorAttachments.length>0&&(a._attachedMipLevel!==r||a._attachedLayer!==i))e.colorAttachments.forEach((h,d)=>{let f=h.texture,m=this._renderer.texture.getGlSource(f);if(m.target===l.TEXTURE_2D){if(i!==0)throw Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,l.TEXTURE_2D,m.texture,r)}else if(m.target===l.TEXTURE_2D_ARRAY||m.target===l.TEXTURE_3D)l.framebufferTextureLayer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,m.texture,r,i);else if(m.target===l.TEXTURE_CUBE_MAP){if(i<0||i>5)throw Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+d,l.TEXTURE_CUBE_MAP_POSITIVE_X+i,m.texture,r)}else throw Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),a._attachedMipLevel=r,a._attachedLayer=i;if(a.framebuffer){if(e.depthStencilAttachment)this._attachDepthStencilTexture(e,r,i);else if(!a.depthStencilRenderBuffer&&(e.stencil||e.depth))this._initStencil(a)}if(e.colorAttachments.length>1)this._setDrawBuffers(e,l);let u=s.y;if(e.isRoot)u=e.pixelHeight-s.height-s.y;let c=this._viewPortCache;if(c.x!==s.x||c.y!==u||c.width!==s.width||c.height!==s.height)c.x=s.x,c.y=u,c.width=s.width,c.height=s.height,l.viewport(s.x,u,s.width,s.height);this.clear(e,t,n)}finishRenderPass(e){let n=this._renderTargetSystem.getGpuRenderTarget(e);if(!n.msaa||e.colorAttachments.length===0)return;let s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,n.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,n.framebuffer),s.blitFramebuffer(0,0,n.width,n.height,0,0,n.width,n.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer),this._boundFramebuffer=n.framebuffer}initGpuRenderTarget(e){let n=this._renderer.gl,s=new ld;s._attachedMipLevel=0,s._attachedLayer=0;let r=e.colorTexture;if(r instanceof Et)return this._renderer.context.ensureCanvasSize(r.resource),s.framebuffer=null,s;if(s.width=e.pixelWidth,s.height=e.pixelHeight,e.colorAttachments.length===0)this._initDepth(e,s);else this._initColor(e,s);if(e.depthStencilAttachment)this._attachDepthStencilTexture(e,0,0);return n.bindFramebuffer(n.FRAMEBUFFER,null),this._boundFramebuffer=null,s}destroyGpuRenderTarget(e){let t=this._renderer.gl;if(e.framebuffer)t.deleteFramebuffer(e.framebuffer),e.framebuffer=null;if(e.resolveTargetFramebuffer)t.deleteFramebuffer(e.resolveTargetFramebuffer),e.resolveTargetFramebuffer=null;if(e.depthStencilRenderBuffer)t.deleteRenderbuffer(e.depthStencilRenderBuffer),e.depthStencilRenderBuffer=null;e.msaaRenderBuffer.forEach((n)=>{t.deleteRenderbuffer(n)}),e.msaaRenderBuffer.length=0}clear(e,t,n,s,r=0,i=0){if(!t)return;if(i!==0)throw Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");let o=this._renderTargetSystem;if(typeof t==="boolean")t=t?xt.ALL:xt.NONE;if(e.colorAttachments.length===0){if(t&=~xt.COLOR,!t)return}let a=this._renderer.gl,l=!!(t&xt.DEPTH)&&!this._renderer.state.depthMaskEnabled;if(t&xt.COLOR){n??(n=o.defaultClearColor);let u=this._clearColorCache,c=n;if(u[0]!==c[0]||u[1]!==c[1]||u[2]!==c[2]||u[3]!==c[3])u[0]=c[0],u[1]=c[1],u[2]=c[2],u[3]=c[3],a.clearColor(c[0],c[1],c[2],c[3])}if(l)a.depthMask(!0);if(a.clear(t),l)a.depthMask(!1)}resizeGpuRenderTarget(e){if(e.isRoot)return;let t=this._renderTargetSystem.getGpuRenderTarget(e);if(t.width=e.pixelWidth,t.height=e.pixelHeight,e.colorAttachments.length>0)this._resizeColor(e,t);if(t.depthStencilRenderBuffer)this._resizeStencil(t);this._boundFramebuffer=void 0}_initColor(e,t){let n=this._renderer,s=n.gl,r=s.createFramebuffer();if(t.resolveTargetFramebuffer=r,s.bindFramebuffer(s.FRAMEBUFFER,r),e.colorAttachments.forEach((o,a)=>{let l=o.texture;if(l.antialias)if(n.context.supports.msaa)t.msaa=!0;else te("[RenderTexture] Antialiasing on textures is not supported in WebGL1");n.texture.bindSource(l,0);let u=n.texture.getGlSource(l),c=u.texture;if(u.target===s.TEXTURE_2D)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,s.TEXTURE_2D,c,0);else if(u.target===s.TEXTURE_2D_ARRAY||u.target===s.TEXTURE_3D)s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,c,0,0);else if(u.target===s.TEXTURE_CUBE_MAP)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+a,s.TEXTURE_CUBE_MAP_POSITIVE_X,c,0);else throw Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),t.msaa){let o=s.createFramebuffer();t.framebuffer=o,s.bindFramebuffer(s.FRAMEBUFFER,o),e.colorAttachments.forEach((a,l)=>{let u=s.createRenderbuffer();t.msaaRenderBuffer[l]=u})}else t.framebuffer=r;this._resizeColor(e,t)}_initDepth(e,t){let n=this._renderer;if(n.context.webGLVersion<2)throw Error("[RenderTargetSystem] Depth-only render targets require WebGL2.");let s=n.gl,r=s.createFramebuffer();t.resolveTargetFramebuffer=r,t.framebuffer=r,s.bindFramebuffer(s.FRAMEBUFFER,r),s.drawBuffers([s.NONE]),s.readBuffer(s.NONE)}_resizeColor(e,t){let n=e.colorAttachments[0].texture;if(t._attachedMipLevel=0,t._attachedLayer=0,e.colorAttachments.forEach((s,r)=>{if(r===0)return;s.texture.resize(n.width,n.height,n._resolution)}),t.msaa){let s=this._renderer,r=s.gl,i=t.framebuffer;r.bindFramebuffer(r.FRAMEBUFFER,i),e.colorAttachments.forEach((o,a)=>{let l=o.texture;s.texture.bindSource(l,0);let c=s.texture.getGlSource(l).internalFormat,h=t.msaaRenderBuffer[a];r.bindRenderbuffer(r.RENDERBUFFER,h),r.renderbufferStorageMultisample(r.RENDERBUFFER,4,c,l.pixelWidth,l.pixelHeight),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+a,r.RENDERBUFFER,h)})}}_attachDepthStencilTexture(e,t,n){let s=this._renderer,r=s.gl,i=e.depthStencilAttachment.texture,o=s.texture.getGlSource(i),a=o.texture,l=i.format,u;if(l==="depth24plus-stencil8"||l==="depth32float-stencil8")u=r.DEPTH_STENCIL_ATTACHMENT;else if(l==="stencil8")u=r.STENCIL_ATTACHMENT;else u=r.DEPTH_ATTACHMENT;if(o.target===r.TEXTURE_2D)r.framebufferTexture2D(r.FRAMEBUFFER,u,r.TEXTURE_2D,a,t);else if(o.target===r.TEXTURE_2D_ARRAY||o.target===r.TEXTURE_3D)r.framebufferTextureLayer(r.FRAMEBUFFER,u,a,t,n);else if(o.target===r.TEXTURE_CUBE_MAP)r.framebufferTexture2D(r.FRAMEBUFFER,u,r.TEXTURE_CUBE_MAP_POSITIVE_X+n,a,t)}_initStencil(e){if(e.framebuffer===null)return;let t=this._renderer.gl,n=t.createRenderbuffer();e.depthStencilRenderBuffer=n,t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,n),this._resizeStencil(e)}_resizeStencil(e){let t=this._renderer.gl;if(t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa)t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height);else t.renderbufferStorage(t.RENDERBUFFER,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}prerender(e){if(e.colorAttachments.length===0)return;let t=e.colorAttachments[0].texture.resource;if(this._renderer.context.multiView&&Et.test(t))this._renderer.context.ensureCanvasSize(t)}postrender(e){if(!this._renderer.context.multiView||e.colorAttachments.length===0)return;let t=e.colorAttachments[0].texture;if(Et.test(t.resource)){let n=this._renderer.context.canvas,s=t;s.context2D.drawImage(n,0,s.pixelHeight-n.height)}}_setDrawBuffers(e,t){let n=e.colorAttachments.length,s=this._drawBuffersCache[n];if(this._renderer.context.webGLVersion===1){let r=this._renderer.context.extensions.drawBuffers;if(!r)te("[RenderTexture] This WebGL1 context does not support rendering to multiple targets");else r.drawBuffersWEBGL(s)}else t.drawBuffers(s)}resetState(){this._boundFramebuffer=void 0,this._viewPortCache=new se,this._clearColorCache=[0,0,0,0]}bindFramebuffer(e){if(this._boundFramebuffer===e)return;this._boundFramebuffer=e,this._renderer.gl.bindFramebuffer(this._renderer.gl.FRAMEBUFFER,e)}}var k_=M(()=>{st();Be();si();gi();h_()});var hl;var M_=M(()=>{z();Hv();k_();hl=class hl extends rd{constructor(e){super(e);this.adaptor=new md,this.adaptor.init(e,this)}resetState(){this.adaptor.resetState()}};hl.extension={type:[D.WebGLSystem],name:"renderTarget"}});var $i;var pd=M(()=>{Qe();Ze();$i=class $i extends ke{constructor({buffer:e,offset:t,size:n}){super();this.uid=ie("buffer"),this._resourceType="bufferResource",this._resourceId=ie("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=n,this.buffer.on("change",this.onBufferChange,this)}get _gcLastUsed(){return this.buffer?._gcLastUsed??-1}set _gcLastUsed(e){if(this.buffer)this.buffer._gcLastUsed=e}onBufferChange(){this._resourceId=ie("resource"),this.emit("change",this)}destroy(e=!1){if(this.destroyed=!0,e)this.buffer.destroy();this.emit("change",this),this.buffer=null,this.removeAllListeners()}}});var gd;var T_=M(()=>{Qe();Ze();gd=class gd extends ke{constructor(e,t){super();this._resourceType="textureView",this._resourceId=ie("resource"),this.source=e,this.viewDescriptor=t,this._onChange=this._onChange.bind(this),this._onDestroy=this._onDestroy.bind(this),this.source.on("change",this._onChange),this.source.on("destroy",this._onDestroy)}_onChange(){this.emit("change",this)}_onDestroy(){this.destroy()}get destroyed(){return this.source.destroyed}destroy(){if(this.source)this.source.off("change",this._onChange),this.source.off("destroy",this._onDestroy);this.emit("destroy",this),this.removeAllListeners()}}});function C_(e,t){let n=[],s=[` var g = s.groups; var sS = r.shader; var p = s.glProgram; @@ -735,7 +735,7 @@ fn mainFragment( var resources; `],r=!1,i=0,o=t._getProgramData(e.glProgram);for(let l in e.groups){let u=e.groups[l];n.push(` resources = g[${l}].resources; - `);for(let c in u.resources){let h=u.resources[c];if(h instanceof Ve)if(h.ubo){let d=e._uniformBindMap[l][Number(c)];n.push(` + `);for(let c in u.resources){let h=u.resources[c];if(h instanceof ze)if(h.ubo){let d=e._uniformBindMap[l][Number(c)];n.push(` sS.bindUniformBlock( resources[${c}], '${d}', @@ -743,21 +743,21 @@ fn mainFragment( ); `)}else n.push(` ugS.updateUniformGroup(resources[${c}], p, sD); - `);else if(h instanceof Si){let d=e._uniformBindMap[l][Number(c)];n.push(` + `);else if(h instanceof $i){let d=e._uniformBindMap[l][Number(c)];n.push(` sS.bindUniformBlock( resources[${c}], '${d}', ${e.glProgram._uniformBlockData[d].index} ); - `)}else if(h instanceof le||h instanceof ad){let d=e._uniformBindMap[l][c],f=o.uniformData[d];if(f){if(!r)r=!0,s.push(` + `)}else if(h instanceof ve||h instanceof gd){let d=e._uniformBindMap[l][c],f=o.uniformData[d];if(f){if(!r)r=!0,s.push(` var tS = r.texture; `);t._gl.uniform1i(f.location,i),n.push(` tS.bind(resources[${c}], ${i}); `),i++}}}}let a=[...s,...n].join(` -`);return Function("r","s","sD",a)}var f_=w(()=>{od();zt();gt();h_()});class ld{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}var m_=()=>{};function cd(e,t,n){let s=e.createShader(t);return e.shaderSource(s,n),e.compileShader(s),s}var p_=()=>{};function ud(e){let t=Array(e);for(let n=0;n{};function dd(e,t){if(!al){let n=Object.keys(g_);al={};for(let s=0;s{g_={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_2D_SHADOW:"sampler2DShadow",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_CUBE_SHADOW:"samplerCubeShadow",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray",SAMPLER_2D_ARRAY_SHADOW:"sampler2DArrayShadow",SAMPLER_3D:"sampler3D",INT_SAMPLER_3D:"sampler3D",UNSIGNED_INT_SAMPLER_3D:"sampler3D"},wA={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"}});function x_(e,t,n=!1){let s={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let o=0;oo>a?1:-1);for(let o=0;o{Kr();fd()});function v_(e,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};let n={},s=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS);for(let r=0;r{};function S_(e,t){let n={},s=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r{hd();fd()});function w_(e,t){let n=e.getShaderSource(t);if(n===null){console.error("PixiJS Error: Could not retrieve shader source (WebGL context may be lost).");return}let s=n.split(` +`);return Function("r","s","sD",a)}var A_=M(()=>{pd();en();St();T_()});class yd{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}var E_=()=>{};function xd(e,t,n){let s=e.createShader(t);return e.shaderSource(s,n),e.compileShader(s),s}var P_=()=>{};function bd(e){let t=Array(e);for(let n=0;n{};function _d(e,t){if(!fl){let n=Object.keys(R_);fl={};for(let s=0;s{R_={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_2D_SHADOW:"sampler2DShadow",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_CUBE_SHADOW:"samplerCubeShadow",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray",SAMPLER_2D_ARRAY_SHADOW:"sampler2DArrayShadow",SAMPLER_3D:"sampler3D",INT_SAMPLER_3D:"sampler3D",UNSIGNED_INT_SAMPLER_3D:"sampler3D"},jA={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"}});function O_(e,t,n=!1){let s={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let o=0;oo>a?1:-1);for(let o=0;o{oi();Sd()});function B_(e,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};let n={},s=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS);for(let r=0;r{};function D_(e,t){let n={},s=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r{vd();Sd()});function G_(e,t){let n=e.getShaderSource(t);if(n===null){console.error("PixiJS Error: Could not retrieve shader source (WebGL context may be lost).");return}let s=n.split(` `).map((c,h)=>`${h}: ${c}`),r=e.getShaderInfoLog(t)??"",i=r.split(` `),o={},a=i.map((c)=>parseFloat(c.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter((c)=>{if(c&&!o[c])return o[c]=!0,!0;return!1}),l=[""];a.forEach((c)=>{s[c-1]=`%c${s[c-1]}%c`,l.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});let u=s.join(` -`);l[0]=u,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...l),console.groupEnd()}function M_(e,t,n,s){if(!e.getProgramParameter(t,e.LINK_STATUS)){if(!e.getShaderParameter(n,e.COMPILE_STATUS))w_(e,n);if(!e.getShaderParameter(s,e.COMPILE_STATUS))w_(e,s);if(console.error("PixiJS Error: Could not initialize shader."),e.getProgramInfoLog(t)!=="")console.warn("PixiJS Warning: gl.getProgramInfoLog()",e.getProgramInfoLog(t))}}var T_=()=>{};function C_(e,t){let n=cd(e,e.VERTEX_SHADER,t.vertex),s=cd(e,e.FRAGMENT_SHADER,t.fragment),r=e.createProgram();e.attachShader(r,n),e.attachShader(r,s);let i=t.transformFeedbackVaryings;if(i)if(typeof e.transformFeedbackVaryings!=="function")V("TransformFeedback is not supported but TransformFeedbackVaryings are given.");else e.transformFeedbackVaryings(r,i.names,i.bufferMode==="separate"?e.SEPARATE_ATTRIBS:e.INTERLEAVED_ATTRIBS);if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))M_(e,r,n,s);t._attributeData=x_(r,e,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=S_(r,e),t._uniformBlockData=v_(r,e),e.deleteShader(n),e.deleteShader(s);let o={};for(let l in t._uniformData){let u=t._uniformData[l];o[l]={location:e.getUniformLocation(r,l),value:ol(u.type,u.size)}}return new ld(r,o)}var A_=w(()=>{Pe();m_();p_();hd();b_();__();k_();T_()});class cl{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(e,t){if(this._setProgram(e.glProgram),t)return;ll.textureCount=0,ll.blockIndex=0;let n=this._shaderSyncFunctions[e.glProgram._key];if(!n)n=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this);this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),n(this._renderer,e,ll)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,ll)}bindUniformBlock(e,t,n=0){let s=this._renderer.buffer,r=this._getProgramData(this._activeProgram),i=e._bufferResource;if(!i)this._renderer.ubo.updateUniformGroup(e);let o=e.buffer,a=s.updateBuffer(o),l=s.freeLocationForBufferBase(a);if(i){let{offset:c,size:h}=e;if(c===0&&h===o.data.byteLength)s.bindBufferBase(a,l);else s.bindBufferRange(a,l,c)}else if(s.getLastBindBaseLocation(a)!==l)s.bindBufferBase(a,l);let u=this._activeProgram._uniformBlockData[t].index;if(r.uniformBlockBindings[n]===l)return;r.uniformBlockBindings[n]=l,this._renderer.gl.uniformBlockBinding(r.program,u,l)}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;let t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){let t=e._key;return this._programDataHash[t]=C_(this._gl,e),this._programDataHash[t]}destroy(){for(let e of Object.keys(this._programDataHash))this._programDataHash[e].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(e,t){return d_(e,t)}resetState(){this._activeProgram=null}}var ll;var E_=w(()=>{W();f_();A_();ll={textureCount:0,blockIndex:0};cl.extension={type:[E.WebGLSystem],name:"shader"}});var R_,P_;var $_=w(()=>{R_={f32:`if (cv !== v) { +`);l[0]=u,console.error(r),console.groupCollapsed("click to view full shader code"),console.warn(...l),console.groupEnd()}function L_(e,t,n,s){if(!e.getProgramParameter(t,e.LINK_STATUS)){if(!e.getShaderParameter(n,e.COMPILE_STATUS))G_(e,n);if(!e.getShaderParameter(s,e.COMPILE_STATUS))G_(e,s);if(console.error("PixiJS Error: Could not initialize shader."),e.getProgramInfoLog(t)!=="")console.warn("PixiJS Warning: gl.getProgramInfoLog()",e.getProgramInfoLog(t))}}var U_=()=>{};function W_(e,t){let n=xd(e,e.VERTEX_SHADER,t.vertex),s=xd(e,e.FRAGMENT_SHADER,t.fragment),r=e.createProgram();e.attachShader(r,n),e.attachShader(r,s);let i=t.transformFeedbackVaryings;if(i)if(typeof e.transformFeedbackVaryings!=="function")te("TransformFeedback is not supported but TransformFeedbackVaryings are given.");else e.transformFeedbackVaryings(r,i.names,i.bufferMode==="separate"?e.SEPARATE_ATTRIBS:e.INTERLEAVED_ATTRIBS);if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))L_(e,r,n,s);t._attributeData=O_(r,e,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=D_(r,e),t._uniformBlockData=B_(r,e),e.deleteShader(n),e.deleteShader(s);let o={};for(let l in t._uniformData){let u=t._uniformData[l];o[l]={location:e.getUniformLocation(r,l),value:dl(u.type,u.size)}}return new yd(r,o)}var X_=M(()=>{Be();E_();P_();vd();I_();F_();N_();U_()});class pl{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(e,t){if(this._setProgram(e.glProgram),t)return;ml.textureCount=0,ml.blockIndex=0;let n=this._shaderSyncFunctions[e.glProgram._key];if(!n)n=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this);this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),n(this._renderer,e,ml)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,ml)}bindUniformBlock(e,t,n=0){let s=this._renderer.buffer,r=this._getProgramData(this._activeProgram),i=e._bufferResource;if(!i)this._renderer.ubo.updateUniformGroup(e);let o=e.buffer,a=s.updateBuffer(o),l=s.freeLocationForBufferBase(a);if(i){let{offset:c,size:h}=e;if(c===0&&h===o.data.byteLength)s.bindBufferBase(a,l);else s.bindBufferRange(a,l,c)}else if(s.getLastBindBaseLocation(a)!==l)s.bindBufferBase(a,l);let u=this._activeProgram._uniformBlockData[t].index;if(r.uniformBlockBindings[n]===l)return;r.uniformBlockBindings[n]=l,this._renderer.gl.uniformBlockBinding(r.program,u,l)}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;let t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){let t=e._key;return this._programDataHash[t]=W_(this._gl,e),this._programDataHash[t]}destroy(){for(let e of Object.keys(this._programDataHash))this._programDataHash[e].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(e,t){return C_(e,t)}resetState(){this._activeProgram=null}}var ml;var V_=M(()=>{z();A_();X_();ml={textureCount:0,blockIndex:0};pl.extension={type:[D.WebGLSystem],name:"shader"}});var j_,Y_;var H_=M(()=>{j_={f32:`if (cv !== v) { cu.value = v; gl.uniform1f(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { @@ -829,25 +829,25 @@ fn mainFragment( cv[2] = v[2]; cv[3] = v[3]; gl.uniform4i(location, v[0], v[1], v[2], v[3]); - }`,"mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);"},P_={f32:"gl.uniform1fv(location, v);","vec2":"gl.uniform2fv(location, v);","vec3":"gl.uniform3fv(location, v);","vec4":"gl.uniform4fv(location, v);","mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);"}});function O_(e,t){let n=[` + }`,"mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);"},Y_={f32:"gl.uniform1fv(location, v);","vec2":"gl.uniform2fv(location, v);","vec3":"gl.uniform3fv(location, v);","vec4":"gl.uniform4fv(location, v);","mat2x2":"gl.uniformMatrix2fv(location, false, v);","mat3x3":"gl.uniformMatrix3fv(location, false, v);","mat4x4":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2":"gl.uniform2iv(location, v);","vec3":"gl.uniform3iv(location, v);","vec4":"gl.uniform4iv(location, v);"}});function z_(e,t){let n=[` var v = null; var cv = null; var cu = null; var t = 0; var gl = renderer.gl; var name = null; - `];for(let s in e.uniforms){if(!t[s]){if(e.uniforms[s]instanceof Ve)if(e.uniforms[s].ubo)n.push(` + `];for(let s in e.uniforms){if(!t[s]){if(e.uniforms[s]instanceof ze)if(e.uniforms[s].ubo)n.push(` renderer.shader.bindUniformBlock(uv.${s}, "${s}"); `);else n.push(` renderer.shader.updateUniformGroup(uv.${s}); - `);else if(e.uniforms[s]instanceof Si)n.push(` + `);else if(e.uniforms[s]instanceof $i)n.push(` renderer.shader.bindBufferResource(uv.${s}, "${s}"); - `);continue}let r=e.uniformStructures[s],i=!1;for(let o=0;o{od();zt();sd();$_()});class ul{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,n){let s=this._renderer.shader._getProgramData(t);if(!e.isStatic||e._dirtyId!==s.uniformDirtyGroups[e.uid])s.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(s.uniformData,e.uniforms,this._renderer,n)}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){let n=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),s=this._getSignature(e,t._uniformData,"u");if(!this._cache[s])this._cache[s]=this._generateUniformsSync(e,t._uniformData);return n[t._key]=this._cache[s],n[t._key]}_generateUniformsSync(e,t){return O_(e,t)}_getSignature(e,t,n){let s=e.uniforms,r=[`${n}-`];for(let i in s)if(r.push(i),t[i])r.push(t[i].type);return r.join("-")}destroy(){this._renderer=null,this._cache=null}}var B_=w(()=>{W();I_();ul.extension={type:[E.WebGLSystem],name:"uniformGroup"}});function D_(e){let t={};if(t.normal=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t.add=[e.ONE,e.ONE],t.multiply=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.screen=[e.ONE,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[e.SRC_ALPHA,e.ONE,e.ONE,e.ONE],t["screen-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.erase=[e.ZERO,e.ONE_MINUS_SRC_ALPHA],!(e instanceof ne.get().getWebGLRenderingContext()))t.min=[e.ONE,e.ONE,e.ONE,e.ONE,e.MIN,e.MIN],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,e.MAX,e.MAX];else{let s=e.getExtension("EXT_blend_minmax");if(s)t.min=[e.ONE,e.ONE,e.ONE,e.ONE,s.MIN_EXT,s.MIN_EXT],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,s.MAX_EXT,s.MAX_EXT]}return t}var F_=w(()=>{nt()});var MA,TA,CA,AA,EA,N_,G_=class e{constructor(t){this._invertFrontFace=!1,this._renderer=t,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[MA]=this.setBlend,this.map[TA]=this.setOffset,this.map[CA]=this.setCullFace,this.map[AA]=this.setDepthTest,this.map[EA]=this.setFrontFace,this.map[N_]=this.setDepthMask,this.checks=[],this.defaultState=lt.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){if(this._invertFrontFace=this._renderer.renderTarget.isFrontFaceInverted(t,t.flipY),this._cullFace)this.setFrontFace(this._frontFace);else this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=D_(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let n=this.stateId^t.data,s=0;while(n){if(n&1)this.map[s].call(this,!!(t.data&1<>=1,s++}this.stateId=t.data}for(let n=0;n{W();yn();F_();({BLEND:MA,OFFSET:TA,CULLING:CA,DEPTH_TEST:AA,WINDING:EA,DEPTH_MASK:N_}=wu);G_.extension={type:[E.WebGLSystem],name:"state"};L_=G_});class md{constructor(e){this.target=In.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=oe.UNSIGNED_BYTE,this.internalFormat=Za.RGBA,this.format=Za.RGBA,this.samplerType=0}destroy(){}}var W_=w(()=>{_i()});function X_(e,t,n,s,r){if(e=Math.max(0,e),t=Math.min(t,n*s),e>=t)return 0;let i=Math.floor(e/n),o=e-i*n,a=Math.floor(t/n),l=t-a*n;if(i===a)return r[0].set(o,i,l-o,1),1;let u=0,c=i;if(o>0)r[u++].set(o,i,n-o,1),c++;if(a>c)r[u++].set(0,c,n,a-c);if(l>0)r[u++].set(0,a,l,1);return u}var j_=()=>{};var Y_,V_;var H_=w(()=>{et();j_();_i();Y_=[new Q,new Q,new Q],V_={id:"buffer",upload(e,t,n,s,r,i=!1){let o=r||t.target,a=e.resource;if(o===In.TEXTURE_3D||o===In.TEXTURE_2D_ARRAY){if(i||t.width!==e.width||t.height!==e.height)n.texImage3D(o,0,t.internalFormat,e.width,e.height,e.depthOrArrayLayers,0,t.format,t.type,a);else n.texSubImage3D(o,0,0,0,0,e.width,e.height,e.depthOrArrayLayers,t.format,t.type,a);t.width=e.width,t.height=e.height;return}let l=e.width*e.height,u=i||t.width!==e.width||t.height!==e.height,c=e._updateStart>0||e._updateEnd{RA={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},z_={id:"compressed",upload(e,t,n,s,r,i){let o=r??t.target;n.pixelStorei(n.UNPACK_ALIGNMENT,4);let{pixelWidth:a,pixelHeight:l}=e,u=!!RA[e.format];for(let c=0;c>1,1),l=Math.max(l>>1,1)}}}});function J_(e){return{id:"cube",upload(t,n,s,r){let i=t.faces;for(let o=0;o{_i();K_=["right","left","top","bottom","front","back"]});function PA(e,t,n,s,r,i,o,a,l,u){if(!u){if(l)e.texImage2D(t,0,n.internalFormat,s,r,0,n.format,n.type,null);e.texSubImage2D(t,0,0,0,i,o,n.format,n.type,a);return}if(!l){e.texSubImage2D(t,0,0,0,n.format,n.type,a);return}e.texImage2D(t,0,n.internalFormat,s,r,0,n.format,n.type,a)}function $A(e,t,n,s,r,i,o,a,l,u){if(!u){if(l)e.texImage2D(t,0,n.internalFormat,s,r,0,n.format,n.type,null);e.texSubImage2D(t,0,0,0,n.format,n.type,a);return}if(!l){e.texSubImage2D(t,0,0,0,n.format,n.type,a);return}e.texImage2D(t,0,n.internalFormat,n.format,n.type,a)}var hl;var pd=w(()=>{hl={id:"image",upload(e,t,n,s,r,i=!1){let o=r||t.target,{pixelWidth:a,pixelHeight:l,resourceWidth:u,resourceHeight:c}=e,h=s===2,d=i||t.width!==a||t.height!==l,f=u>=a&&c>=l,m=e.resource;(h?PA:$A)(n,o,t,a,l,u,c,m,d,f),t.width=a,t.height=l}}});var OA,Q_;var eS=w(()=>{B0();pd();OA=I0(),Q_={id:"video",upload(e,t,n,s,r,i=OA){if(!e.isValid){let o=r??t.target;n.texImage2D(o,0,t.internalFormat,1,1,0,t.format,t.type,null);return}hl.upload(e,t,n,s,r,i)}}});var gd,tS,dl,nS;var sS=w(()=>{gd={linear:9729,nearest:9728},tS={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},dl={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},nS={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519}});function yd(e,t,n,s,r,i,o,a){let l=i;if(!a||e.addressModeU!=="repeat"||e.addressModeV!=="repeat"||e.addressModeW!=="repeat"){let u=dl[o?"clamp-to-edge":e.addressModeU],c=dl[o?"clamp-to-edge":e.addressModeV],h=dl[o?"clamp-to-edge":e.addressModeW];if(t[r](l,t.TEXTURE_WRAP_S,u),t[r](l,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R)t[r](l,t.TEXTURE_WRAP_R,h)}if(!a||e.magFilter!=="linear")t[r](l,t.TEXTURE_MAG_FILTER,gd[e.magFilter]);if(n){if(!a||e.mipmapFilter!=="linear"){let u=tS[e.minFilter][e.mipmapFilter];t[r](l,t.TEXTURE_MIN_FILTER,u)}}else t[r](l,t.TEXTURE_MIN_FILTER,gd[e.minFilter]);if(s&&e.maxAnisotropy>1){let u=Math.min(e.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[r](l,s.TEXTURE_MAX_ANISOTROPY_EXT,u)}if(e.compare)t[r](l,t.TEXTURE_COMPARE_FUNC,nS[e.compare]),t[r](l,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE);else if(!a)t[r](l,t.TEXTURE_COMPARE_MODE,t.NONE)}var rS=w(()=>{sS()});function iS(e){return{r8unorm:e.RED,r8snorm:e.RED,r8uint:e.RED_INTEGER,r8sint:e.RED_INTEGER,r16uint:e.RED_INTEGER,r16sint:e.RED_INTEGER,r16float:e.RED,rg8unorm:e.RG,rg8snorm:e.RG,rg8uint:e.RG_INTEGER,rg8sint:e.RG_INTEGER,r32uint:e.RED_INTEGER,r32sint:e.RED_INTEGER,r32float:e.RED,rg16uint:e.RG_INTEGER,rg16sint:e.RG_INTEGER,rg16float:e.RG,rgba8unorm:e.RGBA,"rgba8unorm-srgb":e.RGBA,rgba8snorm:e.RGBA,rgba8uint:e.RGBA_INTEGER,rgba8sint:e.RGBA_INTEGER,bgra8unorm:e.RGBA,"bgra8unorm-srgb":e.RGBA,rgb9e5ufloat:e.RGB,rgb10a2unorm:e.RGBA,rg11b10ufloat:e.RGB,rg32uint:e.RG_INTEGER,rg32sint:e.RG_INTEGER,rg32float:e.RG,rgba16uint:e.RGBA_INTEGER,rgba16sint:e.RGBA_INTEGER,rgba16float:e.RGBA,rgba32uint:e.RGBA_INTEGER,rgba32sint:e.RGBA_INTEGER,rgba32float:e.RGBA,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT,depth24plus:e.DEPTH_COMPONENT,"depth24plus-stencil8":e.DEPTH_STENCIL,depth32float:e.DEPTH_COMPONENT,"depth32float-stencil8":e.DEPTH_STENCIL}}var oS=()=>{};function aS(e,t){let n={},s=e.RGBA;if(!(e instanceof ne.get().getWebGLRenderingContext()))n={"rgba8unorm-srgb":e.SRGB8_ALPHA8,"bgra8unorm-srgb":e.SRGB8_ALPHA8},s=e.RGBA8;else if(t.srgb)n={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT};return{r8unorm:e.R8,r8snorm:e.R8_SNORM,r8uint:e.R8UI,r8sint:e.R8I,r16uint:e.R16UI,r16sint:e.R16I,r16float:e.R16F,rg8unorm:e.RG8,rg8snorm:e.RG8_SNORM,rg8uint:e.RG8UI,rg8sint:e.RG8I,r32uint:e.R32UI,r32sint:e.R32I,r32float:e.R32F,rg16uint:e.RG16UI,rg16sint:e.RG16I,rg16float:e.RG16F,rgba8unorm:e.RGBA,...n,rgba8snorm:e.RGBA8_SNORM,rgba8uint:e.RGBA8UI,rgba8sint:e.RGBA8I,bgra8unorm:s,rgb9e5ufloat:e.RGB9_E5,rgb10a2unorm:e.RGB10_A2,rg11b10ufloat:e.R11F_G11F_B10F,rg32uint:e.RG32UI,rg32sint:e.RG32I,rg32float:e.RG32F,rgba16uint:e.RGBA16UI,rgba16sint:e.RGBA16I,rgba16float:e.RGBA16F,rgba32uint:e.RGBA32UI,rgba32sint:e.RGBA32I,rgba32float:e.RGBA32F,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT16,depth24plus:e.DEPTH_COMPONENT24,"depth24plus-stencil8":e.DEPTH24_STENCIL8,depth32float:e.DEPTH_COMPONENT32F,"depth32float-stencil8":e.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}var lS=w(()=>{nt()});function cS(e){return{r8unorm:e.UNSIGNED_BYTE,r8snorm:e.BYTE,r8uint:e.UNSIGNED_BYTE,r8sint:e.BYTE,r16uint:e.UNSIGNED_SHORT,r16sint:e.SHORT,r16float:e.HALF_FLOAT,rg8unorm:e.UNSIGNED_BYTE,rg8snorm:e.BYTE,rg8uint:e.UNSIGNED_BYTE,rg8sint:e.BYTE,r32uint:e.UNSIGNED_INT,r32sint:e.INT,r32float:e.FLOAT,rg16uint:e.UNSIGNED_SHORT,rg16sint:e.SHORT,rg16float:e.HALF_FLOAT,rgba8unorm:e.UNSIGNED_BYTE,"rgba8unorm-srgb":e.UNSIGNED_BYTE,rgba8snorm:e.BYTE,rgba8uint:e.UNSIGNED_BYTE,rgba8sint:e.BYTE,bgra8unorm:e.UNSIGNED_BYTE,"bgra8unorm-srgb":e.UNSIGNED_BYTE,rgb9e5ufloat:e.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:e.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:e.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:e.UNSIGNED_INT,rg32sint:e.INT,rg32float:e.FLOAT,rgba16uint:e.UNSIGNED_SHORT,rgba16sint:e.SHORT,rgba16float:e.HALF_FLOAT,rgba32uint:e.UNSIGNED_INT,rgba32sint:e.INT,rgba32float:e.FLOAT,stencil8:e.UNSIGNED_BYTE,depth16unorm:e.UNSIGNED_SHORT,depth24plus:e.UNSIGNED_INT,"depth24plus-stencil8":e.UNSIGNED_INT_24_8,depth32float:e.FLOAT,"depth32float-stencil8":e.FLOAT_32_UNSIGNED_INT_24_8_REV}}var uS=()=>{};function hS(e){return{"2d":e.TEXTURE_2D,cube:e.TEXTURE_CUBE_MAP,"1d":null,"3d":e?.TEXTURE_3D||null,"2d-array":e?.TEXTURE_2D_ARRAY||null,"cube-array":e?.TEXTURE_CUBE_MAP_ARRAY||null}}var dS=()=>{};var IA=4,xd=class e{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._integerUnits=0,this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new pt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});let n={image:hl,buffer:V_,video:Q_,compressed:z_,...e.uploadExtensions};this._uploads={...n,cube:J_(n)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){if(this._gl=t,!this._mapFormatToInternalFormat)this._mapFormatToInternalFormat=aS(t,this._renderer.context.extensions),this._mapFormatToType=cS(t),this._mapFormatToFormat=iS(t),this._mapViewDimensionToGlTarget=hS(t);this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let n=0;n<16;n++)this.bind(j.EMPTY,n)}initSource(t){this.bind(t)}bind(t,n=0){let s=t.source;if(t){if(this.bindSource(s,n),this._useSeparateSamplers)this._bindSampler(s.style,n)}else if(this.bindSource(null,n),this._useSeparateSamplers)this._bindSampler(null,n)}bindSource(t,n=0){let s=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[n]!==t){this._setBoundTexture(n,t),this._activateLocation(n),t||(t=j.EMPTY.source);let r=this.getGlSource(t);s.bindTexture(r.target,r.texture)}}unbindIntegerTextures(t){if(t>=32)return;let n=this._integerUnits>>>t<31)return;if(!n||n.viewDimension!=="2d")return;if(Nr(n.format))this._integerUnits|=1<1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",r.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,n)}onSourceUnload(t,n=!1){let s=t._gpuData[this._renderer.uid];if(!s)return;if(!n)this.unbind(t),this._gl.deleteTexture(s.texture);t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceUpdate(t){let n=this._gl,s=this.getGlSource(t);n.bindTexture(s.target,s.texture),this._setBoundTexture(this._activeTextureLocation,t);let r=t.alphaMode==="premultiply-alpha-on-upload"&&!Nr(t.format)&&s.target!==n.TEXTURE_3D&&s.target!==n.TEXTURE_2D_ARRAY;if(this._premultiplyAlpha!==r)this._premultiplyAlpha=r,n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r);if(this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,s,n,this._renderer.context.webGLVersion);else if(s.target===n.TEXTURE_2D)this._initEmptyTexture2D(s,t);else if(s.target===n.TEXTURE_2D_ARRAY||s.target===n.TEXTURE_3D)this._initEmptyTexture3D(s,t);else if(s.target===n.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(s,t);else throw Error("[GlTextureSystem] Unsupported texture target for empty allocation.");if(this._applyMipRange(s,t),t.autoGenerateMipmaps&&t.mipLevelCount>1)this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,n=!0){if(n)this.bindSource(t,0);let s=this.getGlSource(t);this._gl.generateMipmap(s.target)}_initEmptyTexture2D(t,n){let s=this._gl;s.texImage2D(s.TEXTURE_2D,0,t.internalFormat,n.pixelWidth,n.pixelHeight,0,t.format,t.type,null);let r=Math.max(n.pixelWidth>>1,1),i=Math.max(n.pixelHeight>>1,1);for(let o=1;o>1,1),i=Math.max(i>>1,1)}_initEmptyTexture3D(t,n){let s=this._gl,r=t.target===s.TEXTURE_3D,{pixelWidth:i,pixelHeight:o,depthOrArrayLayers:a}=n;for(let l=0;l>1,1),o=Math.max(o>>1,1),r)a=Math.max(a>>1,1)}_initEmptyTextureCube(t,n){let s=this._gl,r=6;for(let a=0;a<6;a++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,t.internalFormat,n.pixelWidth,n.pixelHeight,0,t.format,t.type,null);let i=Math.max(n.pixelWidth>>1,1),o=Math.max(n.pixelHeight>>1,1);for(let a=1;a>1,1),o=Math.max(o>>1,1)}}_applyMipRange(t,n){if(this._renderer.context.webGLVersion!==2)return;if(n.mipLevelCount<=1)return;let s=this._gl,r=Math.max((n.mipLevelCount|0)-1,0);s.texParameteri(t.target,s.TEXTURE_BASE_LEVEL,0),s.texParameteri(t.target,s.TEXTURE_MAX_LEVEL,r)}_initSampler(t){let n=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,yd(t,n,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){let{pixels:n,width:s,height:r}=this.getPixels(t),i=ne.get().createCanvas();i.width=s,i.height=r;let o=i.getContext("2d");if(o){let a=o.createImageData(s,r);a.data.set(n),o.putImageData(a,0,0)}return i}getPixels(t){let n=t.source.resolution,s=t.frame,r=Math.max(Math.round(s.width*n),1),i=Math.max(Math.round(s.height*n),1),o=new Uint8Array(IA*r*i),a=this._renderer,l=a.renderTarget.getRenderTarget(t),u=a.renderTarget.getGpuRenderTarget(l),c=a.gl;return a.renderTarget.adaptor.bindFramebuffer(u.resolveTargetFramebuffer),c.readPixels(Math.round(s.x*n),Math.round(s.y*n),r,i,c.RGBA,c.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:r,height:i}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){let t=this._renderer.limits.maxTextures;this._activeTextureLocation=-1,this._boundTextures.fill(null),this._integerUnits=t>=32?-1:(1<{nt();W();$n();De();$c();W_();H_();q_();Z_();pd();eS();rS();oS();lS();uS();dS();xd.extension={type:[E.WebGLSystem],name:"texture"};xd.uploadExtensions=Object.create(null);bd=xd;Z.handleByMap(E.TextureUploaderWebGL,bd.uploadExtensions)});class fl{contextChange(e){let t=new Ve({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new U,type:"mat3x3"},uRound:{value:0,type:"f32"}}),n=e.limits.maxBatchableTextures,s=Qs({name:"graphics",bits:[ga,ya(n),Da,er]});this.shader=new It({glProgram:s,resources:{localUniforms:t,batchSamplers:ba(n)}})}execute(e,t){let n=t.context,s=n.customShader||this.shader,r=e.renderer,i=r.graphicsContext,{batcher:o,instructions:a}=i.getContextRenderData(n);s.groups[0]=r.globalUniforms.bindGroup,r.state.set(e.state),r.shader.bind(s),r.geometry.bind(o.geometry,s.glProgram);let l=a.instructions;for(let u=0;u{W();me();pa();Zu();th();Oh();xa();nh();Ys();zt();fl.extension={type:[E.WebGLPipesAdaptor],name:"graphics"}});class ml{init(){let e=Qs({name:"mesh",bits:[Da,N0,er]});this._shader=new It({glProgram:e,resources:{uTexture:j.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3",value:new U}}}})}execute(e,t){let n=e.renderer,s=t._shader;if(!s){s=this._shader;let r=t.texture,i=r.source;s.resources.uTexture=i,s.resources.uSampler=i.style,s.resources.textureUniforms.uniforms.uTextureMatrix=r.textureMatrix.mapCoord}else if(!s.glProgram){V("Mesh shader has no glProgram",t.shader);return}s.groups[100]=n.globalUniforms.bindGroup,s.groups[101]=e.localUniformsBindGroup,n.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}var pS=w(()=>{W();me();pa();Oh();xa();G0();Ys();De();Pe();ml.extension={type:[E.WebGLPipesAdaptor],name:"mesh"}});var BA,DA,FA,gS,yS,xS,bS,vd;var vS=w(()=>{W();mS();pS();D0();ax();Cv();Rn();Bv();Fv();jv();Vv();Hv();zv();qv();Zv();l_();u_();E_();B_();U_();fS();BA=[...Mv,rl,Yv,Dv,nl,Ja,bd,il,Qa,ul,cl,tl,L_,sl,el],DA=[...Tv],FA=[Fa,ml,fl],gS=[],yS=[],xS=[],bS=[];Z.handleByNamedList(E.WebGLSystem,gS);Z.handleByNamedList(E.WebGLPipes,yS);Z.handleByNamedList(E.WebGLPipesAdaptor,xS);Z.handleByNamedList(E.WebGLLoader,bS);Z.add(...BA,...DA,...FA);vd=class vd extends ox{constructor(){let e={name:"webgl",type:at.WEBGL,systems:gS,renderPipes:yS,renderPipeAdaptors:xS,loaders:bS};super(e)}}});W();var Xy={extension:{type:E.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(() => (Wy(),{}))}};W();var Yy={extension:{type:E.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(() => (jy(),{}))}};W();Wo();Oo();Pt();En();is();zt();na();Mu();var y0=` +`))}var q_=M(()=>{pd();en();dd();H_()});class gl{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,n){let s=this._renderer.shader._getProgramData(t);if(!e.isStatic||e._dirtyId!==s.uniformDirtyGroups[e.uid])s.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(s.uniformData,e.uniforms,this._renderer,n)}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){let n=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),s=this._getSignature(e,t._uniformData,"u");if(!this._cache[s])this._cache[s]=this._generateUniformsSync(e,t._uniformData);return n[t._key]=this._cache[s],n[t._key]}_generateUniformsSync(e,t){return z_(e,t)}_getSignature(e,t,n){let s=e.uniforms,r=[`${n}-`];for(let i in s)if(r.push(i),t[i])r.push(t[i].type);return r.join("-")}destroy(){this._renderer=null,this._cache=null}}var K_=M(()=>{z();q_();gl.extension={type:[D.WebGLSystem],name:"uniformGroup"}});function J_(e){let t={};if(t.normal=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t.add=[e.ONE,e.ONE],t.multiply=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.screen=[e.ONE,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[e.SRC_ALPHA,e.ONE,e.ONE,e.ONE],t["screen-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.erase=[e.ZERO,e.ONE_MINUS_SRC_ALPHA],!(e instanceof le.get().getWebGLRenderingContext()))t.min=[e.ONE,e.ONE,e.ONE,e.ONE,e.MIN,e.MIN],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,e.MAX,e.MAX];else{let s=e.getExtension("EXT_blend_minmax");if(s)t.min=[e.ONE,e.ONE,e.ONE,e.ONE,s.MIN_EXT,s.MIN_EXT],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,s.MAX_EXT,s.MAX_EXT]}return t}var Z_=M(()=>{it()});var YA,HA,zA,qA,KA,Q_,eS=class e{constructor(t){this._invertFrontFace=!1,this._renderer=t,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[YA]=this.setBlend,this.map[HA]=this.setOffset,this.map[zA]=this.setCullFace,this.map[qA]=this.setDepthTest,this.map[KA]=this.setFrontFace,this.map[Q_]=this.setDepthMask,this.checks=[],this.defaultState=ft.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){if(this._invertFrontFace=this._renderer.renderTarget.isFrontFaceInverted(t,t.flipY),this._cullFace)this.setFrontFace(this._frontFace);else this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=J_(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let n=this.stateId^t.data,s=0;while(n){if(n&1)this.map[s].call(this,!!(t.data&1<>=1,s++}this.stateId=t.data}for(let n=0;n{z();wn();Z_();({BLEND:YA,OFFSET:HA,CULLING:zA,DEPTH_TEST:qA,WINDING:KA,DEPTH_MASK:Q_}=Ou);eS.extension={type:[D.WebGLSystem],name:"state"};tS=eS});class wd{constructor(e){this.target=Un.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=fe.UNSIGNED_BYTE,this.internalFormat=rl.RGBA,this.format=rl.RGBA,this.samplerType=0}destroy(){}}var sS=M(()=>{Ri()});function rS(e,t,n,s,r){if(e=Math.max(0,e),t=Math.min(t,n*s),e>=t)return 0;let i=Math.floor(e/n),o=e-i*n,a=Math.floor(t/n),l=t-a*n;if(i===a)return r[0].set(o,i,l-o,1),1;let u=0,c=i;if(o>0)r[u++].set(o,i,n-o,1),c++;if(a>c)r[u++].set(0,c,n,a-c);if(l>0)r[u++].set(0,a,l,1);return u}var iS=()=>{};var oS,aS;var lS=M(()=>{st();iS();Ri();oS=[new se,new se,new se],aS={id:"buffer",upload(e,t,n,s,r,i=!1){let o=r||t.target,a=e.resource;if(o===Un.TEXTURE_3D||o===Un.TEXTURE_2D_ARRAY){if(i||t.width!==e.width||t.height!==e.height)n.texImage3D(o,0,t.internalFormat,e.width,e.height,e.depthOrArrayLayers,0,t.format,t.type,a);else n.texSubImage3D(o,0,0,0,0,e.width,e.height,e.depthOrArrayLayers,t.format,t.type,a);t.width=e.width,t.height=e.height;return}let l=e.width*e.height,u=i||t.width!==e.width||t.height!==e.height,c=e._updateStart>0||e._updateEnd{JA={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},cS={id:"compressed",upload(e,t,n,s,r,i){let o=r??t.target;n.pixelStorei(n.UNPACK_ALIGNMENT,4);let{pixelWidth:a,pixelHeight:l}=e,u=!!JA[e.format];for(let c=0;c>1,1),l=Math.max(l>>1,1)}}}});function dS(e){return{id:"cube",upload(t,n,s,r){let i=t.faces;for(let o=0;o{Ri();hS=["right","left","top","bottom","front","back"]});function ZA(e,t,n,s,r,i,o,a,l,u){if(!u){if(l)e.texImage2D(t,0,n.internalFormat,s,r,0,n.format,n.type,null);e.texSubImage2D(t,0,0,0,i,o,n.format,n.type,a);return}if(!l){e.texSubImage2D(t,0,0,0,n.format,n.type,a);return}e.texImage2D(t,0,n.internalFormat,s,r,0,n.format,n.type,a)}function QA(e,t,n,s,r,i,o,a,l,u){if(!u){if(l)e.texImage2D(t,0,n.internalFormat,s,r,0,n.format,n.type,null);e.texSubImage2D(t,0,0,0,n.format,n.type,a);return}if(!l){e.texSubImage2D(t,0,0,0,n.format,n.type,a);return}e.texImage2D(t,0,n.internalFormat,n.format,n.type,a)}var yl;var kd=M(()=>{yl={id:"image",upload(e,t,n,s,r,i=!1){let o=r||t.target,{pixelWidth:a,pixelHeight:l,resourceWidth:u,resourceHeight:c}=e,h=s===2,d=i||t.width!==a||t.height!==l,f=u>=a&&c>=l,m=e.resource;(h?ZA:QA)(n,o,t,a,l,u,c,m,d,f),t.width=a,t.height=l}}});var eE,mS;var pS=M(()=>{Kb();kd();eE=qb(),mS={id:"video",upload(e,t,n,s,r,i=eE){if(!e.isValid){let o=r??t.target;n.texImage2D(o,0,t.internalFormat,1,1,0,t.format,t.type,null);return}yl.upload(e,t,n,s,r,i)}}});var Md,gS,xl,yS;var xS=M(()=>{Md={linear:9729,nearest:9728},gS={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},xl={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},yS={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519}});function Td(e,t,n,s,r,i,o,a){let l=i;if(!a||e.addressModeU!=="repeat"||e.addressModeV!=="repeat"||e.addressModeW!=="repeat"){let u=xl[o?"clamp-to-edge":e.addressModeU],c=xl[o?"clamp-to-edge":e.addressModeV],h=xl[o?"clamp-to-edge":e.addressModeW];if(t[r](l,t.TEXTURE_WRAP_S,u),t[r](l,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R)t[r](l,t.TEXTURE_WRAP_R,h)}if(!a||e.magFilter!=="linear")t[r](l,t.TEXTURE_MAG_FILTER,Md[e.magFilter]);if(n){if(!a||e.mipmapFilter!=="linear"){let u=gS[e.minFilter][e.mipmapFilter];t[r](l,t.TEXTURE_MIN_FILTER,u)}}else t[r](l,t.TEXTURE_MIN_FILTER,Md[e.minFilter]);if(s&&e.maxAnisotropy>1){let u=Math.min(e.maxAnisotropy,t.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[r](l,s.TEXTURE_MAX_ANISOTROPY_EXT,u)}if(e.compare)t[r](l,t.TEXTURE_COMPARE_FUNC,yS[e.compare]),t[r](l,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE);else if(!a)t[r](l,t.TEXTURE_COMPARE_MODE,t.NONE)}var bS=M(()=>{xS()});function vS(e){return{r8unorm:e.RED,r8snorm:e.RED,r8uint:e.RED_INTEGER,r8sint:e.RED_INTEGER,r16uint:e.RED_INTEGER,r16sint:e.RED_INTEGER,r16float:e.RED,rg8unorm:e.RG,rg8snorm:e.RG,rg8uint:e.RG_INTEGER,rg8sint:e.RG_INTEGER,r32uint:e.RED_INTEGER,r32sint:e.RED_INTEGER,r32float:e.RED,rg16uint:e.RG_INTEGER,rg16sint:e.RG_INTEGER,rg16float:e.RG,rgba8unorm:e.RGBA,"rgba8unorm-srgb":e.RGBA,rgba8snorm:e.RGBA,rgba8uint:e.RGBA_INTEGER,rgba8sint:e.RGBA_INTEGER,bgra8unorm:e.RGBA,"bgra8unorm-srgb":e.RGBA,rgb9e5ufloat:e.RGB,rgb10a2unorm:e.RGBA,rg11b10ufloat:e.RGB,rg32uint:e.RG_INTEGER,rg32sint:e.RG_INTEGER,rg32float:e.RG,rgba16uint:e.RGBA_INTEGER,rgba16sint:e.RGBA_INTEGER,rgba16float:e.RGBA,rgba32uint:e.RGBA_INTEGER,rgba32sint:e.RGBA_INTEGER,rgba32float:e.RGBA,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT,depth24plus:e.DEPTH_COMPONENT,"depth24plus-stencil8":e.DEPTH_STENCIL,depth32float:e.DEPTH_COMPONENT,"depth32float-stencil8":e.DEPTH_STENCIL}}var _S=()=>{};function SS(e,t){let n={},s=e.RGBA;if(!(e instanceof le.get().getWebGLRenderingContext()))n={"rgba8unorm-srgb":e.SRGB8_ALPHA8,"bgra8unorm-srgb":e.SRGB8_ALPHA8},s=e.RGBA8;else if(t.srgb)n={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT};return{r8unorm:e.R8,r8snorm:e.R8_SNORM,r8uint:e.R8UI,r8sint:e.R8I,r16uint:e.R16UI,r16sint:e.R16I,r16float:e.R16F,rg8unorm:e.RG8,rg8snorm:e.RG8_SNORM,rg8uint:e.RG8UI,rg8sint:e.RG8I,r32uint:e.R32UI,r32sint:e.R32I,r32float:e.R32F,rg16uint:e.RG16UI,rg16sint:e.RG16I,rg16float:e.RG16F,rgba8unorm:e.RGBA,...n,rgba8snorm:e.RGBA8_SNORM,rgba8uint:e.RGBA8UI,rgba8sint:e.RGBA8I,bgra8unorm:s,rgb9e5ufloat:e.RGB9_E5,rgb10a2unorm:e.RGB10_A2,rg11b10ufloat:e.R11F_G11F_B10F,rg32uint:e.RG32UI,rg32sint:e.RG32I,rg32float:e.RG32F,rgba16uint:e.RGBA16UI,rgba16sint:e.RGBA16I,rgba16float:e.RGBA16F,rgba32uint:e.RGBA32UI,rgba32sint:e.RGBA32I,rgba32float:e.RGBA32F,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT16,depth24plus:e.DEPTH_COMPONENT24,"depth24plus-stencil8":e.DEPTH24_STENCIL8,depth32float:e.DEPTH_COMPONENT32F,"depth32float-stencil8":e.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}var wS=M(()=>{it()});function kS(e){return{r8unorm:e.UNSIGNED_BYTE,r8snorm:e.BYTE,r8uint:e.UNSIGNED_BYTE,r8sint:e.BYTE,r16uint:e.UNSIGNED_SHORT,r16sint:e.SHORT,r16float:e.HALF_FLOAT,rg8unorm:e.UNSIGNED_BYTE,rg8snorm:e.BYTE,rg8uint:e.UNSIGNED_BYTE,rg8sint:e.BYTE,r32uint:e.UNSIGNED_INT,r32sint:e.INT,r32float:e.FLOAT,rg16uint:e.UNSIGNED_SHORT,rg16sint:e.SHORT,rg16float:e.HALF_FLOAT,rgba8unorm:e.UNSIGNED_BYTE,"rgba8unorm-srgb":e.UNSIGNED_BYTE,rgba8snorm:e.BYTE,rgba8uint:e.UNSIGNED_BYTE,rgba8sint:e.BYTE,bgra8unorm:e.UNSIGNED_BYTE,"bgra8unorm-srgb":e.UNSIGNED_BYTE,rgb9e5ufloat:e.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:e.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:e.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:e.UNSIGNED_INT,rg32sint:e.INT,rg32float:e.FLOAT,rgba16uint:e.UNSIGNED_SHORT,rgba16sint:e.SHORT,rgba16float:e.HALF_FLOAT,rgba32uint:e.UNSIGNED_INT,rgba32sint:e.INT,rgba32float:e.FLOAT,stencil8:e.UNSIGNED_BYTE,depth16unorm:e.UNSIGNED_SHORT,depth24plus:e.UNSIGNED_INT,"depth24plus-stencil8":e.UNSIGNED_INT_24_8,depth32float:e.FLOAT,"depth32float-stencil8":e.FLOAT_32_UNSIGNED_INT_24_8_REV}}var MS=()=>{};function TS(e){return{"2d":e.TEXTURE_2D,cube:e.TEXTURE_CUBE_MAP,"1d":null,"3d":e?.TEXTURE_3D||null,"2d-array":e?.TEXTURE_2D_ARRAY||null,"cube-array":e?.TEXTURE_CUBE_MAP_ARRAY||null}}var CS=()=>{};var tE=4,Cd=class e{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._integerUnits=0,this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new bt({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});let n={image:yl,buffer:aS,video:mS,compressed:cS,...e.uploadExtensions};this._uploads={...n,cube:dS(n)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){if(this._gl=t,!this._mapFormatToInternalFormat)this._mapFormatToInternalFormat=SS(t,this._renderer.context.extensions),this._mapFormatToType=kS(t),this._mapFormatToFormat=vS(t),this._mapViewDimensionToGlTarget=TS(t);this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let n=0;n<16;n++)this.bind(K.EMPTY,n)}initSource(t){this.bind(t)}bind(t,n=0){let s=t.source;if(t){if(this.bindSource(s,n),this._useSeparateSamplers)this._bindSampler(s.style,n)}else if(this.bindSource(null,n),this._useSeparateSamplers)this._bindSampler(null,n)}bindSource(t,n=0){let s=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[n]!==t){this._setBoundTexture(n,t),this._activateLocation(n),t||(t=K.EMPTY.source);let r=this.getGlSource(t);s.bindTexture(r.target,r.texture)}}unbindIntegerTextures(t){if(t>=32)return;let n=this._integerUnits>>>t<31)return;if(!n||n.viewDimension!=="2d")return;if(zr(n.format))this._integerUnits|=1<1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",r.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,n)}onSourceUnload(t,n=!1){let s=t._gpuData[this._renderer.uid];if(!s)return;if(!n)this.unbind(t),this._gl.deleteTexture(s.texture);t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceUpdate(t){let n=this._gl,s=this.getGlSource(t);n.bindTexture(s.target,s.texture),this._setBoundTexture(this._activeTextureLocation,t);let r=t.alphaMode==="premultiply-alpha-on-upload"&&!zr(t.format)&&s.target!==n.TEXTURE_3D&&s.target!==n.TEXTURE_2D_ARRAY;if(this._premultiplyAlpha!==r)this._premultiplyAlpha=r,n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r);if(this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,s,n,this._renderer.context.webGLVersion);else if(s.target===n.TEXTURE_2D)this._initEmptyTexture2D(s,t);else if(s.target===n.TEXTURE_2D_ARRAY||s.target===n.TEXTURE_3D)this._initEmptyTexture3D(s,t);else if(s.target===n.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(s,t);else throw Error("[GlTextureSystem] Unsupported texture target for empty allocation.");if(this._applyMipRange(s,t),t.autoGenerateMipmaps&&t.mipLevelCount>1)this.onUpdateMipmaps(t,!1)}onUpdateMipmaps(t,n=!0){if(n)this.bindSource(t,0);let s=this.getGlSource(t);this._gl.generateMipmap(s.target)}_initEmptyTexture2D(t,n){let s=this._gl;s.texImage2D(s.TEXTURE_2D,0,t.internalFormat,n.pixelWidth,n.pixelHeight,0,t.format,t.type,null);let r=Math.max(n.pixelWidth>>1,1),i=Math.max(n.pixelHeight>>1,1);for(let o=1;o>1,1),i=Math.max(i>>1,1)}_initEmptyTexture3D(t,n){let s=this._gl,r=t.target===s.TEXTURE_3D,{pixelWidth:i,pixelHeight:o,depthOrArrayLayers:a}=n;for(let l=0;l>1,1),o=Math.max(o>>1,1),r)a=Math.max(a>>1,1)}_initEmptyTextureCube(t,n){let s=this._gl,r=6;for(let a=0;a<6;a++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,t.internalFormat,n.pixelWidth,n.pixelHeight,0,t.format,t.type,null);let i=Math.max(n.pixelWidth>>1,1),o=Math.max(n.pixelHeight>>1,1);for(let a=1;a>1,1),o=Math.max(o>>1,1)}}_applyMipRange(t,n){if(this._renderer.context.webGLVersion!==2)return;if(n.mipLevelCount<=1)return;let s=this._gl,r=Math.max((n.mipLevelCount|0)-1,0);s.texParameteri(t.target,s.TEXTURE_BASE_LEVEL,0),s.texParameteri(t.target,s.TEXTURE_MAX_LEVEL,r)}_initSampler(t){let n=this._gl,s=this._gl.createSampler();return this._glSamplers[t._resourceId]=s,Td(t,n,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",s,!1,!0),this._glSamplers[t._resourceId]}_getGlSampler(t){return this._glSamplers[t._resourceId]||this._initSampler(t)}getGlSource(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){let{pixels:n,width:s,height:r}=this.getPixels(t),i=le.get().createCanvas();i.width=s,i.height=r;let o=i.getContext("2d");if(o){let a=o.createImageData(s,r);a.data.set(n),o.putImageData(a,0,0)}return i}getPixels(t){let n=t.source.resolution,s=t.frame,r=Math.max(Math.round(s.width*n),1),i=Math.max(Math.round(s.height*n),1),o=new Uint8Array(tE*r*i),a=this._renderer,l=a.renderTarget.getRenderTarget(t),u=a.renderTarget.getGpuRenderTarget(l),c=a.gl;return a.renderTarget.adaptor.bindFramebuffer(u.resolveTargetFramebuffer),c.readPixels(Math.round(s.x*n),Math.round(s.y*n),r,i,c.RGBA,c.UNSIGNED_BYTE,o),{pixels:new Uint8ClampedArray(o.buffer),width:r,height:i}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){let t=this._renderer.limits.maxTextures;this._activeTextureLocation=-1,this._boundTextures.fill(null),this._integerUnits=t>=32?-1:(1<{it();z();Gn();Ne();Uc();sS();lS();uS();fS();kd();pS();bS();_S();wS();MS();CS();Cd.extension={type:[D.WebGLSystem],name:"texture"};Cd.uploadExtensions=Object.create(null);Ad=Cd;ne.handleByMap(D.TextureUploaderWebGL,Ad.uploadExtensions)});class bl{contextChange(e){let t=new ze({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new j,type:"mat3x3"},uRound:{value:0,type:"f32"}}),n=e.limits.maxBatchableTextures,s=lr({name:"graphics",bits:[Sa,wa(n),Wa,cr]});this.shader=new Xt({glProgram:s,resources:{localUniforms:t,batchSamplers:Ma(n)}})}execute(e,t){let n=t.context,s=n.customShader||this.shader,r=e.renderer,i=r.graphicsContext,{batcher:o,instructions:a}=i.getContextRenderData(n);s.groups[0]=r.globalUniforms.bindGroup,r.state.set(e.state),r.shader.bind(s),r.geometry.bind(o.geometry,s.glProgram);let l=a.instructions;for(let u=0;u{z();Ce();_a();ah();uh();Wh();ka();hh();er();en();bl.extension={type:[D.WebGLPipesAdaptor],name:"graphics"}});class vl{init(){let e=lr({name:"mesh",bits:[Wa,Qb,cr]});this._shader=new Xt({glProgram:e,resources:{uTexture:K.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3",value:new j}}}})}execute(e,t){let n=e.renderer,s=t._shader;if(!s){s=this._shader;let r=t.texture,i=r.source;s.resources.uTexture=i,s.resources.uSampler=i.style,s.resources.textureUniforms.uniforms.uTextureMatrix=r.textureMatrix.mapCoord}else if(!s.glProgram){te("Mesh shader has no glProgram",t.shader);return}s.groups[100]=n.globalUniforms.bindGroup,s.groups[101]=e.localUniformsBindGroup,n.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}var PS=M(()=>{z();Ce();_a();Wh();ka();ev();er();Ne();Be();vl.extension={type:[D.WebGLPipesAdaptor],name:"mesh"}});var nE,sE,rE,RS,$S,OS,IS,Ed;var BS=M(()=>{z();ES();PS();Jb();Sx();Wv();Dn();Kv();Zv();i_();a_();l_();c_();u_();f_();w_();M_();V_();K_();nS();AS();nE=[...Lv,ul,o_,Jv,ll,sl,Ad,hl,il,gl,pl,al,tS,cl,ol],sE=[...Uv],rE=[Xa,vl,bl],RS=[],$S=[],OS=[],IS=[];ne.handleByNamedList(D.WebGLSystem,RS);ne.handleByNamedList(D.WebGLPipes,$S);ne.handleByNamedList(D.WebGLPipesAdaptor,OS);ne.handleByNamedList(D.WebGLLoader,IS);ne.add(...nE,...sE,...rE);Ed=class Ed extends _x{constructor(){let e={name:"webgl",type:dt.WEBGL,systems:RS,renderPipes:$S,renderPipeAdaptors:OS,loaders:IS};super(e)}}});z();var rx={extension:{type:D.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(() => (sx(),{}))}};z();var ox={extension:{type:D.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(() => (ix(),{}))}};z();zo();Go();Lt();Fn();ps();en();la();Iu();var $b=` in vec2 vTextureCoord; in vec4 vColor; @@ -911,7 +911,7 @@ void main() finalColor = vec4(rgb, result.a); } -`;var Th=`struct GlobalFilterUniforms { +`;var Bh=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, @@ -1019,7 +1019,7 @@ fn mainFragment( rgb.b *= result.a; return vec4(rgb, result.a); -}`;class Ra extends Vs{constructor(e={}){let t=new Ve({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),n=xt.from({vertex:{source:Th,entryPoint:"mainVertex"},fragment:{source:Th,entryPoint:"mainFragment"}}),s=yt.from({vertex:sa,fragment:y0,name:"color-matrix-filter"});super({...e,gpuProgram:n,glProgram:s,resources:{colorMatrixUniforms:t}});this.alpha=1}_loadMatrix(e,t=!1){if(t){let n=[...e];this._multiply(n,this.matrix,e),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=n}else this.resources.colorMatrixUniforms.uniforms.uColorMatrix=e;this.resources.colorMatrixUniforms.update()}_multiply(e,t,n){return e[0]=t[0]*n[0]+t[1]*n[5]+t[2]*n[10]+t[3]*n[15],e[1]=t[0]*n[1]+t[1]*n[6]+t[2]*n[11]+t[3]*n[16],e[2]=t[0]*n[2]+t[1]*n[7]+t[2]*n[12]+t[3]*n[17],e[3]=t[0]*n[3]+t[1]*n[8]+t[2]*n[13]+t[3]*n[18],e[4]=t[0]*n[4]+t[1]*n[9]+t[2]*n[14]+t[3]*n[19]+t[4],e[5]=t[5]*n[0]+t[6]*n[5]+t[7]*n[10]+t[8]*n[15],e[6]=t[5]*n[1]+t[6]*n[6]+t[7]*n[11]+t[8]*n[16],e[7]=t[5]*n[2]+t[6]*n[7]+t[7]*n[12]+t[8]*n[17],e[8]=t[5]*n[3]+t[6]*n[8]+t[7]*n[13]+t[8]*n[18],e[9]=t[5]*n[4]+t[6]*n[9]+t[7]*n[14]+t[8]*n[19]+t[9],e[10]=t[10]*n[0]+t[11]*n[5]+t[12]*n[10]+t[13]*n[15],e[11]=t[10]*n[1]+t[11]*n[6]+t[12]*n[11]+t[13]*n[16],e[12]=t[10]*n[2]+t[11]*n[7]+t[12]*n[12]+t[13]*n[17],e[13]=t[10]*n[3]+t[11]*n[8]+t[12]*n[13]+t[13]*n[18],e[14]=t[10]*n[4]+t[11]*n[9]+t[12]*n[14]+t[13]*n[19]+t[14],e[15]=t[15]*n[0]+t[16]*n[5]+t[17]*n[10]+t[18]*n[15],e[16]=t[15]*n[1]+t[16]*n[6]+t[17]*n[11]+t[18]*n[16],e[17]=t[15]*n[2]+t[16]*n[7]+t[17]*n[12]+t[18]*n[17],e[18]=t[15]*n[3]+t[16]*n[8]+t[17]*n[13]+t[18]*n[18],e[19]=t[15]*n[4]+t[16]*n[9]+t[17]*n[14]+t[18]*n[19]+t[19],e}brightness(e,t){let n=[e,0,0,0,0,0,e,0,0,0,0,0,e,0,0,0,0,0,1,0];this._loadMatrix(n,t)}tint(e,t){let[n,s,r]=he.shared.setValue(e).toArray(),i=[n,0,0,0,0,0,s,0,0,0,0,0,r,0,0,0,0,0,1,0];this._loadMatrix(i,t)}greyscale(e,t){let n=[e,e,e,0,0,e,e,e,0,0,e,e,e,0,0,0,0,0,1,0];this._loadMatrix(n,t)}grayscale(e,t){this.greyscale(e,t)}blackAndWhite(e){let t=[0.3,0.6,0.1,0,0,0.3,0.6,0.1,0,0,0.3,0.6,0.1,0,0,0,0,0,1,0];this._loadMatrix(t,e)}hue(e,t){e=(e||0)/180*Math.PI;let n=Math.cos(e),s=Math.sin(e),r=Math.sqrt,i=0.3333333333333333,o=r(i),a=n+(1-n)*i,l=i*(1-n)-o*s,u=i*(1-n)+o*s,c=i*(1-n)+o*s,h=n+i*(1-n),d=i*(1-n)-o*s,f=i*(1-n)-o*s,m=i*(1-n)+o*s,p=n+i*(1-n),y=[a,l,u,0,0,c,h,d,0,0,f,m,p,0,0,0,0,0,1,0];this._loadMatrix(y,t)}contrast(e,t){let n=(e||0)+1,s=-0.5*(n-1),r=[n,0,0,0,s,0,n,0,0,s,0,0,n,0,s,0,0,0,1,0];this._loadMatrix(r,t)}saturate(e=0,t){let n=e*2/3+1,s=(n-1)*-0.5,r=[n,s,s,0,0,s,n,s,0,0,s,s,n,0,0,0,0,0,1,0];this._loadMatrix(r,t)}desaturate(){this.saturate(-1)}negative(e){let t=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(t,e)}sepia(e){let t=[0.393,0.7689999,0.18899999,0,0,0.349,0.6859999,0.16799999,0,0,0.272,0.5339999,0.13099999,0,0,0,0,0,1,0];this._loadMatrix(t,e)}technicolor(e){let t=[1.9125277891456083,-0.8545344976951645,-0.09155508482755585,0,0.046249425232852304,-0.3087833385928097,1.7658908555458428,-0.10601743074722245,0,-0.2758903984886823,-0.231103377548616,-0.7501899197440212,1.847597816108189,0,0.12137623870388682,0,0,0,1,0];this._loadMatrix(t,e)}polaroid(e){let t=[1.438,-0.062,-0.062,0,0,-0.122,1.378,-0.122,0,0,-0.016,-0.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(t,e)}toBGR(e){let t=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(t,e)}kodachrome(e){let t=[1.1285582396593525,-0.3967382283601348,-0.03992559172921793,0,0.24991995145868634,-0.16404339962244616,1.0835251566291304,-0.05498805115633132,0,0.09698983488904393,-0.16786010706155763,-0.5603416277695248,1.6014850761964943,0,0.13972481597886063,0,0,0,1,0];this._loadMatrix(t,e)}browni(e){let t=[0.5997023498159715,0.34553243048391263,-0.2708298674538042,0,0.1860075629647401,-0.037703249837783157,0.8609577587992641,0.15059552388459913,0,-0.14497417640467167,0.24113635128153335,-0.07441037908422492,0.44972182064877153,0,-0.029655197167024642,0,0,0,1,0];this._loadMatrix(t,e)}vintage(e){let t=[0.6279345635605994,0.3202183420819367,-0.03965408211312453,0,0.037848179746251466,0.02578397704808868,0.6441188644374771,0.03259127616149294,0,0.029265996770472907,0.0466055556782719,-0.0851232987247891,0.5241648018700465,0,0.020232119953863904,0,0,0,1,0];this._loadMatrix(t,e)}colorTone(e,t,n,s,r){e||(e=0.2),t||(t=0.15),n||(n=16770432),s||(s=3375104);let i=he.shared,[o,a,l]=i.setValue(n).toArray(),[u,c,h]=i.setValue(s).toArray(),d=[0.3,0.59,0.11,0,0,o,a,l,e,0,u,c,h,t,0,o-u,a-c,l-h,0,0];this._loadMatrix(d,r)}night(e,t){e||(e=0.1);let n=[e*-2,-e,0,0,0,-e,0,e,0,0,0,e,e*2,0,0,0,0,0,1,0];this._loadMatrix(n,t)}predator(e,t){let n=[11.224130630493164*e,-4.794486999511719*e,-2.8746118545532227*e,0*e,0.40342438220977783*e,-3.6330697536468506*e,9.193157196044922*e,-2.951810836791992*e,0*e,-1.316135048866272*e,-3.2184197902679443*e,-4.2375030517578125*e,7.476448059082031*e,0*e,0.8044459223747253*e,0,0,0,1,0];this._loadMatrix(n,t)}lsd(e){let t=[2,-0.4,0.5,0,0,-0.5,2,-0.4,0,0,-0.4,-0.5,3,0,0,0,0,0,1,0];this._loadMatrix(t,e)}reset(){let e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(e,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(e){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=e}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(e){this.resources.colorMatrixUniforms.uniforms.uAlpha=e}}Ug();zs();yn();De();Re();Eo();Hs();os();zs();Re();var O0=class e extends qt{constructor(...t){let n=t[0]??{};if(n instanceof Float32Array)X(ae,"use new MeshGeometry({ positions, uvs, indices }) instead"),n={positions:n,uvs:t[1],indices:t[2]};n={...e.defaultOptions,...n};let s=n.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=n.uvs;if(!r)if(n.positions)r=new Float32Array(s.length);else r=new Float32Array([0,0,1,0,1,1,0,1]);let i=n.indices||new Uint32Array([0,1,2,0,2,3]),o=n.shrinkBuffersToFit,a=new ct({data:s,label:"attribute-mesh-positions",shrinkToFit:o,usage:ce.VERTEX|ce.COPY_DST}),l=new ct({data:r,label:"attribute-mesh-uvs",shrinkToFit:o,usage:ce.VERTEX|ce.COPY_DST}),u=new ct({data:i,label:"index-mesh-buffer",shrinkToFit:o,usage:ce.INDEX|ce.COPY_DST});super({attributes:{aPosition:{buffer:a,format:"float32x2",stride:8,offset:0},aUV:{buffer:l,format:"float32x2",stride:8,offset:0}},indexBuffer:u,topology:n.topology});this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};O0.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};var mi=O0;W();W();me();js();zt();Xu();$a();class Rh{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(e){this._topology=e}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(e){if(this.texture===e)return;this.texture=e,this._textureMatrixUpdateId=-1}get uvs(){let t=this.geometry.getBuffer("aUV"),n=t.data,s=n,r=this.texture.textureMatrix;if(!r.isSimple){if(s=this._transformedUvs,this._textureMatrixUpdateId!==r._updateID||this._uvUpdateId!==t._updateID){if(!s||s.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new kt({0:this.localUniforms}),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){let t=this._getMeshData(e),n=t.batched,s=e.batched;if(t.batched=s,n!==s)return!0;else if(s){let r=e._geometry;if(r.indices.length!==t.indexSize||r.positions.length!==t.vertexSize)return t.indexSize=r.indices.length,t.vertexSize=r.positions.length,!0;let i=this._getBatchableMesh(e);if(i.texture.uid!==e._texture.uid)i._textureMatrixUpdateId=-1;return!i._batcher.checkAndUpdateTexture(i,e._texture)}return!1}addRenderable(e,t){let n=this.renderer.renderPipes.batch,s=this._getMeshData(e);if(e.didViewUpdate)s.indexSize=e._geometry.indices?.length,s.vertexSize=e._geometry.positions?.length;if(s.batched){let r=this._getBatchableMesh(e);r.setTexture(e._texture),r.geometry=e._geometry,n.addToBatch(r,t)}else n.break(t),t.add(e)}updateRenderable(e){if(e.batched){let t=this._getBatchableMesh(e);t.setTexture(e._texture),t.geometry=e._geometry,t._batcher.updateElement(t)}}execute(e){if(!e.isRenderable)return;if(e.state.blend)e.state.blendMode=li(e.groupBlendMode,e.texture._source);let t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),lr(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){var t,n;return(t=e._gpuData)[n=this.renderer.uid]||(t[n]=new Ph),e._gpuData[this.renderer.uid].meshData||this._initMeshData(e)}_initMeshData(e){return e._gpuData[this.renderer.uid].meshData={batched:e.batched,indexSize:0,vertexSize:0},e._gpuData[this.renderer.uid].meshData}_getBatchableMesh(e){var t,n;return(t=e._gpuData)[n=this.renderer.uid]||(t[n]=new Ph),e._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(e)}_initBatchableMesh(e){let t=new Rh;return t.renderable=e,t.setTexture(e._texture),t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,e._gpuData[this.renderer.uid].batchableMesh=t,t}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Ia.extension={type:[E.WebGLPipes,E.WebGPUPipes],name:"mesh"};Z.add(Ia);class Ba extends ns{constructor(...e){let t=e[0];if(t instanceof qt){if(X(ae,"Mesh: use new Mesh({ geometry, shader }) instead"),t={geometry:t,shader:e[1]},e[3])X(ae,"Mesh: drawMode argument has been removed, use geometry.topology instead"),t.geometry.topology=e[3]}let{geometry:n,shader:s,texture:r,roundPixels:i,state:o,...a}=t;super({label:"Mesh",...a});this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=r??s?.texture??j.WHITE,this.state=o??lt.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=i??!1}get material(){return X(ae,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(e){if(this._shader===e)return;this._shader=e,this.onViewUpdate()}get shader(){return this._shader}set geometry(e){if(this._geometry===e)return;this._geometry?.off("update",this.onViewUpdate,this),e.on("update",this.onViewUpdate,this),this._geometry=e,this.onViewUpdate()}get geometry(){return this._geometry}set texture(e){e||(e=j.EMPTY);let t=this._texture;if(t===e)return;if(t&&t.dynamic)t.off("update",this.onViewUpdate,this);if(e.dynamic)e.on("update",this.onViewUpdate,this);if(this.shader)this.shader.texture=e;this._texture=e,this.onViewUpdate()}get texture(){return this._texture}get batched(){if(this._shader)return!1;if((this.state.data&12)!==0)return!1;if(this._geometry instanceof mi){if(this._geometry.batchMode==="auto")return this._geometry.positions.length/2<=100;return this._geometry.batchMode==="batch"}return!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(e){let{x:t,y:n}=e;if(!this.bounds.containsPoint(t,n))return!1;let s=this.geometry.getBuffer("aPosition").data,r=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){let i=this.geometry.getIndex().data,o=i.length;for(let a=0;a+2t.name===e.skin)}function pl(e){if(e.skin==="all")return e.skins;let t=e.skin===null?void 0:e.skins.find((s)=>s.name===e.skin),n=e.skin==="default"?void 0:e.skins.find((s)=>s.name==="default");return[t,n].filter((s)=>s!==void 0)}function ki(e,t,n){if(e.skin==="all")return e.skins.filter((r)=>r.attachments[t]?.[n]!==void 0).map((r)=>r.name);let s=pl(e).find((r)=>r.attachments[t]?.[n]!==void 0);return s===void 0?[]:[s.name]}function _S(e,t,n){return Sd(e).some((s)=>s.constraints[t].includes(n))}var SS=["hold","once","loop","pingpong","onceReverse","loopReverse","pingpongReverse"];var dr=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),ds=(e)=>typeof e==="number"&&Number.isFinite(e);function NA(e){return e.weighted?2*e.bindings.reduce((t,n)=>t+n.length,0):e.xy.length}function kS(e,t,n){let s=-1/0;e.forEach((r,i)=>{if(!dr(r))return;let o=r.time;if(!ds(o)||o<0)n.push(`${t}[${i}]: time is ${JSON.stringify(o)}, not a finite time at or after 0`);else if(o<=s)n.push(`${t}[${i}]: time ${o} is not after the key before it — the writer refuses key times that do not strictly increase`);if(ds(o))s=Math.max(s,o)})}function GA(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];kS(e,t,s);let r=NA(n),i=[];return e.forEach((o,a)=>{let l=`${t}[${a}]`;if(!dr(o)){s.push(`${l} is not an object`);return}for(let m of Object.keys(o))if(!["time","offset","vertices","curve"].includes(m))s.push(`${l}: field "${m}" is not one a deform key carries; it carries [time, offset, vertices, curve]`);let u=o.vertices,c=[];if(u!==void 0)if(!Array.isArray(u)||u.length===0||!u.every(ds))s.push(`${l}: vertices is not a non-empty list of finite numbers (omit it for the setup geometry)`);else c=u;let h=0;if(o.offset!==void 0)if(u===void 0)s.push(`${l}: offset ${JSON.stringify(o.offset)} with no vertices — a key with no run is the setup geometry, and the writer states no start for it`);else if(typeof o.offset!=="number"||!Number.isInteger(o.offset)||o.offset<0)s.push(`${l}: offset is ${JSON.stringify(o.offset)}, not a whole index at or after 0`);else h=o.offset;if(h+c.length>r)s.push(`${l}: the run starts at ${h} and is ${c.length} long, past the ${r} numbers of the attachment's deform array`);let d="linear";if(o.curve!==void 0)if(a===e.length-1)s.push(`${l}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(o.curve==="stepped")d="stepped";else if(Array.isArray(o.curve)&&o.curve.length===4&&o.curve.every(ds))d=o.curve;else s.push(`${l}: curve is ${JSON.stringify(o.curve)}, not "stepped" nor 4 finite numbers (a deform key's curve is one channel)`);let f=ds(o.time)?o.time:0;i.push({time:Math.fround(f),stated:f,curve:d,offset:h,vertices:c})}),i}function LA(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];kS(e,t,s);let r=[];return e.forEach((i,o)=>{let a=`${t}[${o}]`;if(!dr(i)){s.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(!["time","mode","index","delay"].includes(h))s.push(`${a}: field "${h}" is not one a sequence key carries; it carries [time, mode, index, delay]`);let l="hold";if(i.mode!==void 0){let h=SS.find((d)=>d===i.mode);if(h===void 0)s.push(`${a}: mode is ${JSON.stringify(i.mode)}, none of ${SS.join(", ")}`);else l=h}let u=0;if(i.index!==void 0)if(typeof i.index!=="number"||!Number.isInteger(i.index)||i.index<0||i.index>=n)s.push(`${a}: index is ${JSON.stringify(i.index)}, not a frame of the series' ${n} — the writer refuses an index past the last frame`);else u=i.index;let c=r.length===0?0:r[r.length-1].delay;if(i.delay!==void 0)if(!ds(i.delay)||i.delay<0)s.push(`${a}: delay is ${JSON.stringify(i.delay)}, not a finite number of seconds at or above 0`);else c=Math.fround(i.delay);r.push({time:Math.fround(ds(i.time)?i.time:0),mode:l,index:u,delay:c})}),r}function wS(e,t,n,s){let r=[],i=`${t}.attachments`;if(!Array.isArray(e))return s.push(`${i} is not a list`),r;return e.forEach((o,a)=>{let l=`${i}[${a}]`;if(!dr(o)||typeof o.name!=="string"){s.push(`${l} names no skin`);return}let u=n.find((c)=>c.name===o.name);if(u===void 0)s.push(`${l}: "${o.name}" is not a skin of this document`);if(!Array.isArray(o.slots)){s.push(`${l}: slots is not a list`);return}o.slots.forEach((c,h)=>{let d=`${l}.slots[${h}]`;if(!dr(c)||typeof c.name!=="string"){s.push(`${d} names no slot`);return}if(!Array.isArray(c.attachments)){s.push(`${d}: attachments is not a list`);return}let f=c.name;c.attachments.forEach((m,p)=>{let y=`${d}.attachments[${p}]`;if(!dr(m)||typeof m.name!=="string"){s.push(`${y} names no attachment`);return}for(let v of Object.keys(m))if(!["name","deform","sequence"].includes(v))s.push(`${y}: field "${v}" is not one this reader knows; it reads [name, deform, sequence]`);let g=u?.attachments[f]?.[m.name],x=`${y} "${o.name}/${f}/${m.name}"`;if(u!==void 0&&g===void 0)s.push(`${x}: skin "${u.name}" files no attachment "${m.name}" under slot "${f}"`);let b={skin:o.name,slot:f,attachment:m.name,deform:null,sequence:null};if(m.deform!==void 0&&g!==void 0){let v=g.geometry;if(v===void 0||v.kind!=="mesh"&&v.kind!=="clipping"&&v.kind!=="boundingbox"&&v.kind!=="path")s.push(`${x}: a deform keys the vertices of a mesh, bounding box, clipping or path attachment, and this one is a ${g.kind}`);else b.deform=GA(m.deform,`${x}.deform`,v.vertices,s)}if(m.sequence!==void 0&&g!==void 0){let v=g.sequenceCount;if(v===void 0)s.push(`${x}: a sequence timeline steps a series, and this ${g.kind} carries no sequence`);else b.sequence=LA(m.sequence,`${x}.sequence`,v,s)}if(m.deform===void 0&&m.sequence===void 0)s.push(`${x}: carries neither a deform nor a sequence timeline`);r.push(b)})})}),r}function wd(e,t){if(!e.weighted)return{weighted:!1,xy:[...t]};let n=0;return{weighted:!0,bindings:e.bindings.map((s)=>s.map((r)=>{let i=Math.fround(r.x)+t[n],o=Math.fround(r.y)+t[n+1];return n+=2,{...r,x:i,y:o}}))}}var MS=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function TS(e,t,n,s){let r=`${t}.drawOrder`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=new Map(n.map((l,u)=>[l.name,u])),o=[],a=-1/0;return e.forEach((l,u)=>{let c=`${r}[${u}]`;if(!MS(l)){s.push(`${c} is not an object`);return}for(let f of Object.keys(l))if(f!=="time"&&f!=="offsets")s.push(`${c}: field "${f}" is not one a draw-order key carries; it carries [time, offsets]`);let h=l.time;if(typeof h!=="number"||!Number.isFinite(h)||h<0)s.push(`${c}: time is ${JSON.stringify(h)}, not a finite time at or after 0`);else if(h<=a)s.push(`${c}: time ${h} is not after the key before it — the writer refuses key times that do not strictly increase`);if(typeof h==="number"&&Number.isFinite(h))a=Math.max(a,h);let d=[];if(l.offsets!==void 0)if(!Array.isArray(l.offsets))s.push(`${c}: offsets is not a list`);else{let f=new Map;l.offsets.forEach((m,p)=>{let y=`${c}.offsets[${p}]`;if(!MS(m)||typeof m.slot!=="string"){s.push(`${y} names no slot`);return}let g=i.get(m.slot);if(g===void 0){s.push(`${y}: "${m.slot}" is not a slot of this document`);return}if(typeof m.offset!=="number"||!Number.isInteger(m.offset)){s.push(`${y}: slot "${m.slot}" offset is ${JSON.stringify(m.offset)}, not a whole number`);return}if(d.some((b)=>b.slot===g))s.push(`${y}: slot "${m.slot}" is moved twice in one key`);let x=g+m.offset;if(x<0||x>=n.length)s.push(`${y}: slot "${m.slot}" is at ${g} and offset ${m.offset} lands at ${x}, outside the ${n.length} slots`);else if(f.has(x))s.push(`${y}: slot "${m.slot}" lands at ${x}, where slot "${f.get(x)}" lands too — two moves on one place leave a slot out of the runtime's order`);else f.set(x,m.slot);d.push({slot:g,offset:m.offset})})}o.push({time:Math.fround(typeof h==="number"&&Number.isFinite(h)?h:0),moves:d})}),o}var ES=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),CS=["name","int","float","string","audio","volume","balance"],AS=["time","name","int","float","string","volume","balance"];function RS(e,t,n){let s={};if(e.int!==void 0)if(typeof e.int!=="number"||!Number.isInteger(e.int))n.push(`${t}: int is ${JSON.stringify(e.int)}, not a whole number`);else s.int=e.int;if(e.float!==void 0)if(typeof e.float!=="number"||!Number.isFinite(e.float))n.push(`${t}: float is ${JSON.stringify(e.float)}, not a finite number`);else s.float=e.float;if(e.string!==void 0)if(typeof e.string!=="string")n.push(`${t}: string is ${JSON.stringify(e.string)}, not a string`);else s.string=e.string;for(let r of["volume","balance"])if(e[r]!==void 0)if(typeof e[r]!=="number"||!Number.isFinite(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])}, not a finite number`);else s[r]=e[r];return s}function PS(e,t){let n=new Map;if(!Array.isArray(e))return t.push("events is not a list"),n;return e.forEach((s,r)=>{let i=`events[${r}]`;if(!ES(s)||typeof s.name!=="string"||s.name===""){t.push(`${i} names no event`);return}for(let a of Object.keys(s))if(!CS.includes(a))t.push(`${i} "${s.name}": field "${a}" is not one this reader knows; it reads [${CS.join(", ")}]`);if(s.audio!==void 0&&typeof s.audio!=="string")t.push(`${i} "${s.name}": audio is ${JSON.stringify(s.audio)}, not a string`);if(n.has(s.name))t.push(`${i}: event "${s.name}" is declared twice`);let o=RS(s,`${i} "${s.name}"`,t);n.set(s.name,{audio:typeof s.audio==="string"?s.audio:"",volume:o.volume??0,balance:o.balance??0,name:s.name,int:o.int??0,float:o.float??0,string:o.string??""})}),n}function $S(e,t,n,s){let r=`${t}.events`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=[],o=-1/0;return e.forEach((a,l)=>{let u=`${r}[${l}]`;if(!ES(a)){s.push(`${u} is not an object`);return}for(let f of Object.keys(a))if(!AS.includes(f))s.push(`${u}: field "${f}" is not one an event key carries; it carries [${AS.join(", ")}]`);let c=a.time;if(typeof c!=="number"||!Number.isFinite(c)||c<0)s.push(`${u}: time is ${JSON.stringify(c)}, not a finite time at or after 0`);else if(c0?n.reverse():n;return t.flippedWinding===!0?s.reverse():s}function XA(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(r*(e[1]-n[1])-i*(e[0]-n[0]))/(a*r-o*i);return[n[0]+l*o,n[1]+l*a]}function Cd(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(o*(e[1]-n[1])-a*(e[0]-n[0]))/(a*r-o*i);return[e[0]+l*r,e[1]+l*i]}function DS(e,t,n){let s=n.fromClipEdge===!0?XA:Cd,r=[...e],i=!1;for(let o=0;o0;o++){let a=t[o],l=t[(o+1)%t.length],u=(h)=>(l[0]-a[0])*(h[1]-a[1])-(l[1]-a[1])*(h[0]-a[0])<0,c=[];for(let h=0;h[t[2*P],t[2*P+1]]),p=f.map((P)=>[o(s[2*P]),o(s[2*P+1])]),{points:y,cut:g}=DS(m,i,r);for(let P=1;P+1r.uvByDivision===!0?P/T:P*A,R=a.length/2;if(!g&&r.insideRotated!==!0){m.forEach(([P,I],F)=>{a.push(o(P),o(I)),l.push(p[F][0],p[F][1])});for(let P=1;P+1GS(r,i,o,a,n)){let r=[],i=[],o=[],a=null;for(let c of e){if(c.kind==="clip"){if(a!==null&&a.end===c.slot)a=null;if(c.active&&a===null){let h=c.inverse?"it is inverse":gl(c.polygon);if(h!==null)i.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${h}`);let d={polygon:c.polygon,inverse:c.inverse,convex:c.convex},f=yl(d);if(f.kind==="refused")o.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${f.why}`);a={end:c.end,shape:d}}continue}if(c.kind==="draw"&&a!==null){let h=s(a.shape,c.vertices,c.triangles,c.uvs);if(h!==null)r.push([c.slot,c.attachment,h.clipped?1:0,h.vertices.map(t),h.uvs.map(t),h.triangles])}if(a!==null&&a.end===c.slot)a=null}let l=o.length===0?null:`${o.join("; ")} — the runtime's coverage of a polygon that is not simple is its own triangulation's, measured not to be the polygon's area (src/core/clipping.ts)`,u=l===null?r:null;if(i.length>0)return{rows:null,why:`${i.join("; ")} — the runtime decomposes such a polygon into convex pieces of its own choosing, or clips the outside of an inverse one, and neither was reproduced from the dump (src/core/clipping.ts)`,drawn:u,drawnWhy:l};return{rows:r,why:null,drawn:u,drawnWhy:l}}function jA(e){let t=[];for(let n=0;n+10&&i<0||r<0&&i>0)&&(o>0&&a<0||o<0&&a>0))return!0;let l=(u,c,h)=>Math.min(u[0],c[0])<=h[0]&&h[0]<=Math.max(u[0],c[0])&&Math.min(u[1],c[1])<=h[1]&&h[1]<=Math.max(u[1],c[1]);return r===0&&l(n,s,e)||i===0&&l(n,s,t)||o===0&&l(e,t,n)||a===0&&l(e,t,s)}function VA(e){let t=e.length;for(let n=0;n0)return`edges ${n} and ${(n+1)%t} fold back over each other at vertex ${(n+1)%t}`;for(let o=n+2;o3;){n=!1;for(let s=0;ss[0]-r[0]||s[1]-r[1]),n=(s)=>{let r=[];for(let i of s){while(r.length>=2&&Mt(r[r.length-2],r[r.length-1],i)<=0)r.pop();r.push(i)}return r.pop(),r};return[...n(t),...n([...t].reverse())]}function zA(e){let t=e.flat();return BS(t)<0?[...e].reverse():[...e]}function qA(e){let t=e.length,n=e.map((a,l)=>l),s=[],r=(a,l,u,c)=>Mt(l,u,a)>=0&&Mt(u,c,a)>=0&&Mt(c,l,a)>=0;while(n.length>3){let a=!1;for(let l=0;ld!==u&&d!==c&&d!==h&&r(e[d],e[u],e[c],e[h])))continue;s.push([u,c,h]),n.splice(l,1),a=!0;break}if(!a)throw Error(`convexPieces: no ear left among vertices [${n.join(", ")}] of a polygon the caller held simple — a defect in src/core/clipping.ts`)}s.push([...n]);let i=s.map((a)=>[...a]),o=(a)=>a.every((l,u)=>Mt(e[a[(u+a.length-1)%a.length]],e[l],e[a[(u+1)%a.length]])>0);for(let a=!0;a;){a=!1;e:for(let l=0;la.map((l)=>e[l]))}function yl(e){let t=jA(e.polygon);if(t.length<3)return{kind:"refused",why:`it has ${t.length} vertex(es)`};let n=[];for(let o=0;o0){let o=t.filter((a,l)=>{let u=t[(l+1)%t.length];return a[0]!==u[0]||a[1]!==u[1]});if(!e.inverse&&o.length===t.length-n.length&&o.length>=3&&gl(o.flat())===null)return{kind:"convex",polygon:e.polygon};return{kind:"refused",why:`vertices ${n.join(", ")} are the same point`}}let s=VA(t);if(s!==null)return{kind:"refused",why:s};let r=HA(t);if(Mt(r[0],r[1],r[2])===0&&r.length===3)return{kind:"refused",why:"every vertex lies on one line"};if(e.inverse)return{kind:"inverse",hull:OS(r)};if(gl(e.polygon)===null)return{kind:"convex",polygon:e.polygon};if(e.convex)return{kind:"convex",polygon:OS(r).flat()};let i=qA(zA(r));return i.length===1?{kind:"convex",polygon:i[0].flat()}:{kind:"pieces",pieces:i}}function IS(e,t,n){let s=(o)=>(n[0]-t[0])*(o[1]-t[1])-(n[1]-t[1])*(o[0]-t[0])<0,r=[],i=!1;for(let o=0;oTd(p.flat(),{})):null,m=o.kind==="inverse"?Td(o.hull.flat(),{}):[];for(let p=0;p+2[t[2*R],t[2*R+1]]),x=y.map((R)=>[a(s[2*R]),a(s[2*R+1])]),b=[];if(f!==null)for(let R of f)b.push(DS(g,R,{}));else{let R=[...g],P=!1;for(let I=0;I0;I++){let F=m[I],B=m[(I+1)%m.length],C=IS(R,B,F);b.push({points:C.cut||P?C.points:[...g],cut:C.cut||P});let D=IS(R,F,B);P||=D.cut,R=D.points}d=!0}let[v,_,S]=g,M=_[1]-S[1],k=S[0]-_[0],T=v[0]-S[0],A=S[1]-v[1],O=1/(M*T+k*(v[1]-S[1]));for(let[R,{points:P,cut:I}]of b.entries()){if(d||=I,R===i.dropRegion)continue;if(P.length<3)continue;let F=l.length/2;if(!I)g.forEach(([B,C],D)=>{l.push(a(B),a(C)),u.push(x[D][0],x[D][1])});else for(let[B,C]of P){let D=(M*(B-S[0])+k*(C-S[1]))*O,N=(A*(B-S[0])+T*(C-S[1]))*O,G=1-D-N;l.push(a(B),a(C)),u.push(a(x[0][0]*D+x[1][0]*N+x[2][0]*G),a(x[0][1]*D+x[1][1]*N+x[2][1]*G))}for(let B=1;B+1e;function JA(e,t){let{width:n,height:s}=e,r=e.scaleX??1,i=e.scaleY??1,o=e.atlas,a=n/o.originalWidth*r,l=s/o.originalHeight*i,u=-n/2*r+o.offsetX*a,c=-s/2*i+o.offsetY*l,h=u+o.width*a,d=c+o.height*l,f=(e.rotation??0)*KA,m=Math.cos(f),p=Math.sin(f),y=e.x??0,g=e.y??0,x=[];for(let[b,v]of[[u,c],[u,d],[h,d],[h,c]]){let _=b*m+y-v*p,S=v*m+g+b*p;x.push(t.a*_+t.b*S+t.worldX,t.c*_+t.d*S+t.worldY)}return x}var Ed=new WeakMap;function US(e,t){let n=[],s=new Map;for(let o of e.bindings)for(let a of o)if(!s.has(a.bone))s.set(a.bone,n.length),n.push(a.bone);let r=n.length,i=e.bindings.map((o)=>o.map((a)=>{let l=s.get(a.bone);return{bone:t===void 0?l:t(l,r),x:a.x,y:a.y,fx:Math.fround(a.x),fy:Math.fround(a.y),weight:Math.fround(a.weight)}}));return{bones:n,bindings:i}}function WS(e){let t=Ed.get(e);if(t===void 0)t=US(e),Ed.set(e,t);return t}function XS(e,t){let n=Array(e.length);for(let s=0;stypeof e==="object"&&e!==null&&!Array.isArray(e),fs=(e)=>typeof e==="number"&&Number.isFinite(e),Ad=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function tE(e,t,n){if(!Mi(e)){n.push(`${t} is ${JSON.stringify(e)}, not an atlas rectangle`);return}let s=n.length;for(let r of Object.keys(e))if(!Ad.includes(r))n.push(`${t}: field "${r}" is not one this reader knows; it reads [${Ad.join(", ")}]`);for(let r of Ad)if(!fs(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])??"absent"}, not a finite number`);return n.length===s?e:void 0}function nE(e,t,n,s){if(!Mi(e)||typeof e.weighted!=="boolean"){s.push(`${t} is not { weighted: false, xy } or { weighted: true, bindings }`);return}let r=s.length;if(!e.weighted){let a=e.xy;if(!Array.isArray(a)||a.length%2!==0||!a.every(fs))s.push(`${t}.xy is not an even-length list of finite numbers`);return s.length===r?{weighted:!1,xy:a}:void 0}let i=e.bindings;if(!Array.isArray(i)){s.push(`${t}.bindings is not a list`);return}if(i.forEach((a,l)=>{if(!Array.isArray(a)||a.length===0){s.push(`${t}.bindings[${l}] is not a non-empty list of bindings`);return}a.forEach((u,c)=>{let h=`${t}.bindings[${l}][${c}]`;if(!Mi(u)){s.push(`${h} is not an object`);return}if(typeof u.bone!=="string"||!n.has(u.bone))s.push(`${h}: bone ${JSON.stringify(u.bone)} is not a bone of this document`);for(let d of["x","y","weight"])if(!fs(u[d]))s.push(`${h}: ${d} is ${JSON.stringify(u[d])??"absent"}, not a finite number`)})}),s.length!==r)return;let o={weighted:!0,bindings:i};return Ed.set(o,US(o)),o}function jS(e,t,n,s,r,i){let o=i.length;switch(t){case"region":{for(let d of["x","y","rotation","scaleX","scaleY"])if(e[d]!==void 0&&!fs(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])}, not a finite number`);for(let d of["width","height"])if(!fs(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])??"absent"}, not a finite number`);let a=e.atlas!==void 0,l=e.sequence!==void 0,u,c;if(a===l)i.push(`${n}: the region carries ${a?"both an atlas rectangle and a sequence":"neither an atlas rectangle nor a sequence"}; the writer states exactly one of the two, and a sequence holds a rectangle per frame (issue #935)`);else if(a)u=e.atlas===null?null:Mi(e.atlas)?e.atlas:void 0;else{let d=e.sequence;if(!Mi(d))i.push(`${n}.sequence is not an object`);else{let f=d.count,m=d.setup??0;if(typeof f!=="number"||!Number.isInteger(f)||f<1)i.push(`${n}.sequence: count is ${JSON.stringify(f)}, not a whole number of at least 1`);else if(typeof m!=="number"||!Number.isInteger(m)||m<0||m>=f)i.push(`${n}.sequence: setup is ${JSON.stringify(d.setup)}, not a frame of the ${f}`);if(!Array.isArray(d.atlas)||d.atlas.length!==f)i.push(`${n}.sequence: atlas is not a list of ${JSON.stringify(f)} rectangle(s), one per frame`);else{let p=d.atlas.map((y,g)=>tE(y,`${n}.sequence.atlas[${g}]`,i));if(typeof m==="number"&&Number.isInteger(m)&&m>=0&&my!==void 0))c=p}}}if(i.length!==o||u===void 0)return;let h=(d)=>e[d]===void 0?{}:{[d]:e[d]};return{kind:"region",region:{...h("x"),...h("y"),...h("rotation"),...h("scaleX"),...h("scaleY"),width:e.width,height:e.height,atlas:u,...c===void 0?{}:{frames:c}}}}case"linkedmesh":{for(let a of["skin","slot","source"])if(typeof e[a]!=="string"||e[a]==="")i.push(`${n}: ${a} is ${JSON.stringify(e[a])??"absent"}, not a non-empty string`);if(typeof e.slot==="string"&&!r.has(e.slot))i.push(`${n}: slot "${e.slot}" is not a slot of this document`);if(i.length!==o)return;return{kind:"linkedmesh",skin:e.skin,slot:e.slot,source:e.source}}case"mesh":case"clipping":case"boundingbox":case"path":{let a=nE(e.vertices,`${n}.vertices`,s,i);if(t==="clipping"&&e.end!==void 0&&(typeof e.end!=="string"||!r.has(e.end)))i.push(`${n}: end is ${JSON.stringify(e.end)}, not a slot of this document`);if(t==="clipping"){for(let u of["inverse","convex"])if(e[u]!==void 0&&typeof e[u]!=="boolean")i.push(`${n}: ${u} is ${JSON.stringify(e[u])}, not a boolean`)}let l=t==="mesh"&&a!==void 0?sE(e,a,n,i):void 0;if(a===void 0||i.length!==o)return;if(t==="mesh")return l===void 0?void 0:{kind:t,vertices:a,...l};if(t==="clipping")return{kind:t,end:typeof e.end==="string"?e.end:null,vertices:a,inverse:e.inverse===!0,convex:e.convex===!0};if(t==="boundingbox")return{kind:t,vertices:a};return rE(e,a,n,i)}}}function sE(e,t,n,s){let r=s.length,i=t.weighted?t.bindings.length:t.xy.length/2,{uvs:o,triangles:a}=e;if(!Array.isArray(o)||!o.every(fs)||o.length!==2*i)s.push(`${n}.uvs is not ${2*i} finite numbers, one pair per vertex`);if(!Array.isArray(a)||a.length%3!==0||!a.every((u)=>Number.isInteger(u)&&u>=0&&u=0&&l<=i))s.push(`${n}.hull is ${JSON.stringify(l)}, not a whole number of vertices from 0 to ${i}`);return s.length===r?{uvs:o,triangles:a,...l===void 0?{}:{hull:l}}:void 0}function rE(e,t,n,s){let r=s.length;for(let a of["closed","constantSpeed"])if(e[a]!==void 0&&typeof e[a]!=="boolean")s.push(`${n}: ${a} is ${JSON.stringify(e[a])}, not a boolean`);let i=t.weighted?t.bindings.length:t.xy.length/2;if(e.vertexCount!==i)s.push(`${n}: vertexCount is ${JSON.stringify(e.vertexCount)??"absent"}, and the vertices hold ${i} point(s)`);else if(i%3!==0||i<(e.closed===!0?3:6))s.push(`${n}: vertexCount is ${i}, not a multiple of 3 of at least ${e.closed===!0?3:6} — the curve walk reads knots and handles in threes`);let o=e.lengths;if(!Array.isArray(o)||!o.every(fs))s.push(`${n}: lengths is not a list of finite numbers`);else if(o.length!==i/3)s.push(`${n}: lengths has ${o.length} entry(ies) where the vertices make ${i/3}`);if(s.length!==r)return;return{kind:"path",vertices:t,closed:e.closed===!0,constantSpeed:e.constantSpeed!==!1,lengths:o}}function vl(e,t){for(let n=0;nb.geometry.kind==="clipping"),f=new Map;for(let b of e){let v=t.get(b.bone);if(v===void 0)throw Error(`slot "${b.slot}": bone "${b.bone}" has no world transform`);let{geometry:_,deform:S}=b,M=(k)=>S===void 0?a(k,v,t):r.vertices===void 0||r.deformedVertices!==void 0?l(k,S,v,t):a(wd(k,S),v,t,LS);if(_.kind==="region"){let k=b.frame===void 0?_.region.atlas:_.region.frames?.[b.frame]??_.region.atlas;if(k===null){h.push(`slot "${b.slot}" shows region "${b.name}" (skin "${b.skin}", placeholder "${b.placeholder}")`);continue}let T=o(k===_.region.atlas?_.region:{..._.region,atlas:k},v);if(u.push([b.slot,b.name,"region",vl(T,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:bl,uvs:xl})}else if(_.kind==="mesh"){let k=M(_.vertices);if(u.push([b.slot,b.name,"mesh",vl(k,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:k,triangles:_.triangles,uvs:_.uvs})}else if(_.kind==="linkedmesh"){let k=n(_.skin,_.slot,_.source);if(typeof k==="string")throw Error(`slot "${b.slot}": ${k} (readModel refuses it first)`);let T=M(k);u.push([b.slot,b.name,"mesh",vl(T,s)]);let A=i?.meshOf(_.skin,_.slot,_.source);if(i!==void 0&&A===void 0)throw Error(`slot "${b.slot}": the linked mesh's source "${_.source}" carries no triangles (readModel refuses it first)`);if(d&&A!==void 0)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:A.triangles,uvs:A.uvs})}else if(_.kind==="clipping"){let k=M(_.vertices);c.push([b.slot,b.name,_.end,vl(k,s)]),f.set(b.slot,{slot:b.slot,kind:"clip",attachment:b.name,active:i?.active.has(b.bone)??!1,end:_.end,polygon:k,inverse:_.inverse,convex:_.convex})}}let m=h.length===0?null:`${h.join("; ")} — the model states the build had no atlas rectangle for it (atlas: null), and its corners read the trim and original size; a trim of 0 is not assumed`,p=null,y=i===void 0?"the draw order was not given":m,g=null,x=y;if(i!==void 0&&m===null&&!d)p=[],y=null,g=[],x=null;else if(i!==void 0&&m===null){let b=i.order.map((_)=>f.get(_)??{slot:_,kind:"none"}),v=NS(b,s,i.clip,i.through);p=v.rows,y=v.why,g=v.drawn,x=v.drawnWhy}return{attachments:m===null?u:null,attachmentsWhy:m,clips:c,clipped:p,clippedWhy:y,drawnClipped:g,drawnClippedWhy:x}}var Z9=rn/180;var iE=["fixed","percent"],oE=["length","fixed","percent","proportional"],aE=["tangent","chain","chainScale"],YS=["bones","slot","positionMode","spacingMode","rotateMode","rotation","position","spacing","mixRotate","mixX","mixY","skin"],Sl=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Pd(e,t,n,s,r,i){let o=e[t];if(o===void 0)return s;let a=typeof o==="string"&&o.length>0?o[0].toLowerCase()+o.slice(1):"",l=n.find((u)=>u===a);if(l===void 0)return i.push(`${r}: ${t} is ${JSON.stringify(o)}, none of ${n.join(", ")} (first letter in either case)`),s;return l}function Fn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function VS(e,t,n,s,r,i){let o=i.length;for(let d of Object.keys(e)){if(d==="kind"||d==="name"||d==="declaredIn")continue;if(!YS.includes(d))i.push(`${n}: field "${d}" is not one this reader knows; it reads [${YS.join(", ")}]`)}let a=[];if(!Array.isArray(e.bones)||e.bones.length===0)i.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`);else e.bones.forEach((d,f)=>typeof d==="string"&&s.has(d)?a.push(d):i.push(`${n}: bones[${f}] ${JSON.stringify(d)} is not a bone of this document`));let l=typeof e.slot==="string"?e.slot:"",u=r.get(l);if(u===void 0)i.push(`${n}: slot is ${JSON.stringify(e.slot)}, not a slot of this document`);if(e.skin!==void 0&&typeof e.skin!=="boolean")i.push(`${n}: skin is ${JSON.stringify(e.skin)}, not a boolean`);let c=Fn(e,"mixX",1,n,i),h={kind:"path",name:t,bones:a,slot:l,slotBone:u??"",positionMode:Pd(e,"positionMode",iE,"percent",n,i),spacingMode:Pd(e,"spacingMode",oE,"length",n,i),rotateMode:Pd(e,"rotateMode",aE,"tangent",n,i),offsetRotation:Fn(e,"rotation",0,n,i),position:Fn(e,"position",0,n,i),spacing:Fn(e,"spacing",0,n,i),mixRotate:Fn(e,"mixRotate",1,n,i),mixX:c,mixY:Fn(e,"mixY",c,n,i),skin:e.skin===!0,listedBySkin:!1,path:null,unresolved:null,slotDeps:[]};return i.length===o?h:void 0}var $d={position:["value"],spacing:["value"],mix:["mixRotate","mixX","mixY"]};function lE(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function HS(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.path[${o}]`;if(!Sl(i)||typeof i.name!=="string"){s.push(`${a} names no constraint`);return}if(!n.has(i.name))s.push(`${a}: "${i.name}" is not a path constraint of this document`);let l={name:i.name};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!Sl(u)||typeof u.name!=="string"||!(u.name in $d)){s.push(`${h}: ${Sl(u)?JSON.stringify(u.name):"it"} is not a path timeline; they are ${Object.keys($d).join(", ")}`);return}let d=u.name;if(l[d]!==void 0)s.push(`${h}: "${d}" is keyed twice on path constraint "${i.name}"`);let f=$d[d],m=u.keys;if(!Array.isArray(m)||m.length===0){s.push(`${h}: keys is not a non-empty list`);return}let p=-1/0,y=[];m.forEach((g,x)=>{let b=`${h}.keys[${x}]`;if(!Sl(g)){s.push(`${b} is not an object`);return}for(let S of Object.keys(g))if(S!=="time"&&S!=="curve"&&!f.includes(S))s.push(`${b}: field "${S}" is not one this reader knows; it reads [time, ${f.join(", ")}, curve]`);let v=g.time;if(typeof v!=="number"||!Number.isFinite(v)||v<0){s.push(`${b}: time is ${JSON.stringify(v)}, not a finite time at or after 0`);return}if(v<=p)s.push(`${b}: time ${v} is not after the key before it — the writer refuses key times that do not strictly increase`);p=Math.max(p,v);let _=f.map((S)=>{if(S==="mixY"&&g.mixY===void 0)return Fn(g,"mixX",1,b,s);return Fn(g,S,d==="mix"?1:0,b,s)});y.push({time:Math.fround(v),values:_.map(Math.fround),stated:{time:v,values:_},curve:lE(g,f.length,x===m.length-1,b,s)})}),l[d]=y}),r.push(l)}),r}var nK=rn/180,zS=["bone","scaleY","x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix","inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],cE=["x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix"],uE=["inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],qS=["none","uniform","volume"];var JS=["inertia","strength","damping","mass","wind","gravity","mix"],KS=[...JS,"reset"],Od="*",hE={x:0,y:0,rotate:0,scaleX:0,shearX:0,limit:5000,fps:60,inertia:0.5,strength:100,damping:0.85,mass:1,wind:0,gravity:0,mix:1};function ZS(e,t,n,s,r,i){let o=i.length;for(let c of Object.keys(e)){if(c==="kind"||c==="name"||c==="declaredIn")continue;if(!zS.includes(c))i.push(`${n}: field "${c}" is not one this reader knows; it reads [${zS.join(", ")}]`)}if(typeof e.bone!=="string"||!s.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);for(let c of cE){let h=e[c];if(h!==void 0&&(typeof h!=="number"||!Number.isFinite(h)))i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a finite number`)}for(let c of uE){let h=e[c];if(h!==void 0&&typeof h!=="boolean")i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a boolean`)}let a="None";if(e.scaleY!==void 0){let c=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"";if(!qS.includes(c))i.push(`${n}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${qS.join(", ")}`);else a=c==="uniform"?"Uniform":c==="volume"?"Volume":"None"}if(i.length!==o)return;let l=(c)=>typeof e[c]==="number"?e[c]:hE[c],u={};for(let c of JS)u[c]=e[`${c}Global`]===!0;return{kind:"physics",name:t,bone:e.bone,skin:e.skin===!0,listedBySkin:!1,x:l("x"),y:l("y"),rotate:l("rotate"),scaleX:l("scaleX"),shearX:l("shearX"),limit:l("limit"),step:1/l("fps"),referenceScale:r,inertia:l("inertia"),strength:l("strength"),damping:l("damping"),massInverse:1/l("mass"),wind:l("wind"),gravity:l("gravity"),mix:l("mix"),global:u,scaleYMode:a}}var Ti=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function QS(e){if(!Array.isArray(e))return 0;let t=0;for(let n of e)if(typeof n==="object"&&n!==null&&Array.isArray(n.timelines))t+=n.timelines.length;return t}function ek(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.physics[${o}]`;if(!Ti(i)||typeof i.name!=="string"){s.push(`${a} names no physics constraint`);return}let l=i.name;if(l!==Od&&!n.has(l))s.push(`${a}: "${l}" is not a physics constraint of this document (nor "${Od}", the timeline naming none)`);if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}let u=new Set;i.timelines.forEach((c,h)=>{let d=`${a}.timelines[${h}]`,f=Ti(c)?KS.find((g)=>g===c.name):void 0;if(!Ti(c)||f===void 0){s.push(`${d}: ${JSON.stringify(Ti(c)?c.name:c)} is not a physics timeline; one keys ${KS.join(", ")}`);return}if(u.has(f))s.push(`${d}: "${f}" is keyed twice on "${l}"`);u.add(f);let m=[],p=c.keys;if(!Array.isArray(p)||p.length===0){s.push(`${d} "${f}": keys is not a non-empty list`);return}let y=-1/0;p.forEach((g,x)=>{let b=`${d} "${f}".keys[${x}]`;if(!Ti(g)){s.push(`${b} is not an object`);return}let v=f==="reset"?["time"]:["time","value","curve"];for(let k of Object.keys(g))if(!v.includes(k))s.push(`${b}: field "${k}" is not one this reader knows; it reads [${v.join(", ")}]`);let _=g.time;if(typeof _!=="number"||!Number.isFinite(_)||_<0){s.push(`${b}: time is ${JSON.stringify(_)}, not a finite time at or after 0`);return}if(_<=y)s.push(`${b}: time ${_} is not after the key before it — the writer refuses key times that do not strictly increase`);if(y=Math.max(y,_),f==="reset"){m.push({time:Math.fround(_),values:[],stated:{time:_,values:[]},curve:"stepped"});return}let S=f==="mix"?1:0;if(g.value!==void 0)if(typeof g.value!=="number"||!Number.isFinite(g.value))s.push(`${b}: value is ${JSON.stringify(g.value)}, not a finite number`);else S=g.value;let M="linear";if(g.curve!==void 0)if(x===p.length-1)s.push(`${b}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(g.curve==="stepped")M="stepped";else if(Array.isArray(g.curve)&&g.curve.length===4&&g.curve.every((k)=>typeof k==="number"&&Number.isFinite(k)))M=g.curve;else s.push(`${b}: curve is ${JSON.stringify(g.curve)}, not "stepped" nor four finite numbers`);m.push({time:Math.fround(_),values:[Math.fround(S)],stated:{time:_,values:[S]},curve:M})}),r.push({name:l,kind:f,keys:m})})}),r}var dE=Object.freeze({wind:Object.freeze([1,0]),gravity:Object.freeze([0,1])});var fE=rn*2,iK=1/fE;var tk=["animation","additive","loop","mix","bone","property","from","to","scale","max","local","time","skin"],kl=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function nk(e,t,n,s,r,i){let o=i.length;for(let y of Object.keys(e)){if(y==="kind"||y==="name"||y==="declaredIn")continue;if(!tk.includes(y))i.push(`${n}: field "${y}" is not one this reader knows; it reads [${tk.join(", ")}]`)}let a=(y,g)=>{let x=e[y];if(x===void 0)return g;if(typeof x!=="number"||!Number.isFinite(x))return i.push(`${n}: ${y} is ${JSON.stringify(x)}, not a finite number`),g;return x},l=(y)=>{let g=e[y];if(g===void 0)return!1;if(typeof g!=="boolean")return i.push(`${n}: ${y} is ${JSON.stringify(g)}, not a boolean`),!1;return g},u=r.find((y)=>y.name===e.animation);if(u===void 0)i.push(`${n}: a slider's animation is ${JSON.stringify(e.animation)}, not an animation of this document`);let c=new Map(s.map((y)=>[y.name,y])),h=null;if(e.bone!==void 0)if(typeof e.bone!=="string"||!c.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);else h=e.bone;let d="rotate";if(e.property!==void 0){let y=Nn.find((g)=>g===e.property);if(y===void 0)i.push(`${n}: property is ${JSON.stringify(e.property)}, none of ${Nn.join(", ")}`);else d=y}a("max",0);let f=l("loop"),m=new Map;for(let y of u?.timelines.bones??[]){let g=c.get(y.name);if(g!==void 0)m.set(g.name,g)}let p={kind:"slider",name:t,animation:u?.name??"",timelines:u?.timelines??{declared:0,duration:0,bones:[],slots:[],later:[],attachments:[],drawOrder:[],events:[]},physics:[],setup:m,additive:l("additive"),loop:f,mix:a("mix",1),time:a("time",0),bone:h,property:d,from:a("from",0),to:a("to",0),scale:a("scale",1),local:l("local"),skin:l("skin"),listedBySkin:!1};return i.length===o?p:void 0}function sk(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.slider[${o}]`;if(!kl(i)||typeof i.name!=="string"){s.push(`${a} names no slider`);return}if(!n.some((u)=>u.kind==="slider"&&u.name===i.name))s.push(`${a}: "${i.name}" is not a slider of this document`);let l={name:i.name,time:null,mix:null};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!kl(u)||u.name!=="time"&&u.name!=="mix"){s.push(`${h}: ${JSON.stringify(kl(u)?u.name:u)} is not a slider timeline; a slider keys time and mix`);return}let d=u.name;if(l[d]!==null)s.push(`${h}: "${d}" is keyed twice on slider "${i.name}"`);l[d]=pE(u.keys,`${h} "${d}"`,s)}),r.push(l)}),r}function pE(e,t,n){let s=[];if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),s;let r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!kl(i)){n.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(h!=="time"&&h!=="value"&&h!=="curve")n.push(`${a}: field "${h}" is not one this reader knows; it reads [time, value, curve]`);let l=i.time;if(typeof l!=="number"||!Number.isFinite(l)||l<0){n.push(`${a}: time is ${JSON.stringify(l)}, not a finite time at or after 0`);return}if(l<=r)n.push(`${a}: time ${l} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l);let u=1;if(i.value!==void 0)if(typeof i.value!=="number"||!Number.isFinite(i.value))n.push(`${a}: value is ${JSON.stringify(i.value)}, not a finite number`);else u=i.value;let c="linear";if(i.curve!==void 0)if(o===e.length-1)n.push(`${a}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(i.curve==="stepped")c="stepped";else if(Array.isArray(i.curve)&&i.curve.length===4&&i.curve.every((h)=>typeof h==="number"&&Number.isFinite(h)))c=i.curve;else n.push(`${a}: curve is ${JSON.stringify(i.curve)}, not "stepped" nor 4 finite numbers`);s.push({time:Math.fround(l),values:[Math.fround(u)],stated:{time:l,values:[u]},curve:c})}),s}var IK=180/rn,BK=rn/180;var Nn=["rotate","x","y","scaleX","scaleY","shearY"],rk={rotate:"mixRotate",x:"mixX",y:"mixY",scaleX:"mixScaleX",scaleY:"mixScaleY",shearY:"mixShearY"},gE={rotate:"rotation",x:"x",y:"y",scaleX:"scaleX",scaleY:"scaleY",shearY:"shearY"},ik=["none","uniform","volume"],yE={ik:["bones","target","scaleY","mix","softness","bendPositive","compress","stretch","skin"],transform:["bones","source","properties","localSource","localTarget","additive","clamp","rotation","x","y","scaleX","scaleY","shearY","mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY","skin"]},Gn=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function wl(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function an(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function Jt(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="boolean")return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a boolean`),n;return i}function xE(e,t,n,s){if(!Array.isArray(e.bones)||e.bones.length===0)return s.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`),[];let r=[];return e.bones.forEach((i,o)=>{if(typeof i!=="string"||!t.has(i))s.push(`${n}: bones[${o}] ${JSON.stringify(i)} is not a bone of this document`);else r.push(i)}),r}function ok(e,t,n,s,r){let i=e[t];if(typeof i!=="string"||!n.has(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a bone of this document`),"";return i}function Bd(e,t,n,s,r){if(e[rk[t]]!==void 0)return an(e,rk[t],0,s,r);if(t==="y")return n.has("x")?Bd(e,"x",n,s,r):0;if(t==="scaleY")return n.has("scaleX")?Bd(e,"scaleX",n,s,r):0;return n.has(t)?1:0}function ck(e,t,n,s,r,i,o){let a=o.length,l={...e};delete l.kind,delete l.name,delete l.declaredIn,wl(l,yE[t],s,o);let u=xE(e,r,s,o),c=Jt(e,"skin",!1,s,o);if(t==="ik"){let g=ok(e,"target",r,s,o);if(u.length>2)o.push(`${s}: an ik constraint names ${u.length} bones; the format takes one or two`);if(u.length>=1&&i.get(u[0])===void 0)o.push(`${s}: its first bone "${u[0]}" is the root; spine-core throws posing an ik constraint on a bone with no parent`);if(u.length===2&&i.get(u[1])!==u[0])o.push(`${s}: "${u[1]}" is not a child of "${u[0]}"; a two-bone ik needs the second bone directly under the first`);let x="none";if(e.scaleY!==void 0){let v=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"",_=ik.find((S)=>S===v);if(_===void 0)o.push(`${s}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${ik.join(", ")}`);else x=_}let b={kind:t,name:n,bones:u,target:g,scaleY:x,skin:c,listedBySkin:!1,mix:an(e,"mix",1,s,o),softness:an(e,"softness",0,s,o),bendPositive:Jt(e,"bendPositive",!0,s,o),compress:Jt(e,"compress",!1,s,o),stretch:Jt(e,"stretch",!1,s,o)};return o.length===a?b:void 0}let h=ok(e,"source",r,s,o),d=[],f=new Set;if(e.properties!==void 0&&!Gn(e.properties))o.push(`${s}: properties is not an object`);else if(Gn(e.properties))for(let[g,x]of Object.entries(e.properties)){let b=`${s}.properties.${g}`,v=Nn.find((S)=>S===g);if(v===void 0){o.push(`${b}: "${g}" is none of ${Nn.join(", ")}`);continue}if(!Gn(x)){o.push(`${b} is not an object`);continue}wl(x,["offset","to"],b,o);let _=[];if(!Gn(x.to))o.push(`${b}: to is not an object`);else for(let[S,M]of Object.entries(x.to)){let k=`${b}.to.${S}`,T=Nn.find((A)=>A===S);if(T===void 0){o.push(`${k}: "${S}" is none of ${Nn.join(", ")}`);continue}if(!Gn(M)){o.push(`${k} is not an object`);continue}wl(M,["offset","scale","max"],k,o),_.push({property:T,offset:an(M,"offset",0,k,o),scale:an(M,"scale",1,k,o),max:an(M,"max",1,k,o)}),f.add(T)}d.push({property:v,offset:an(x,"offset",0,b,o),to:_})}let m={},p={};for(let g of Nn)m[g]=an(e,gE[g],0,s,o),p[g]=Bd(e,g,f,s,o);let y={kind:t,name:n,bones:u,source:h,properties:d,skin:c,listedBySkin:!1,offsets:m,mixes:p,localSource:Jt(e,"localSource",!1,s,o),localTarget:Jt(e,"localTarget",!1,s,o),additive:Jt(e,"additive",!1,s,o),clamp:Jt(e,"clamp",!1,s,o)};return o.length===a?y:void 0}var ak=["mix","softness"],lk=["mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY"];function bE(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function uk(e,t,n,s){let r={ik:[],transform:[],path:[],physics:0,slider:[]};if(!Gn(e))return r;r.path=HS(e.path,t,new Set(n.filter((i)=>i.kind==="path").map((i)=>i.name)),s),r.physics=QS(e.physics),r.physicsKeyed=ek(e.physics,t,new Set(n.filter((i)=>i.kind==="physics").map((i)=>i.name)),s),r.slider=sk(e.slider,t,n,s);for(let i of["ik","transform"]){let o=e[i];if(!Array.isArray(o))continue;o.forEach((a,l)=>{let u=`${t}.constraints.${i}[${l}]`;if(!Gn(a)||typeof a.name!=="string"){s.push(`${u} names no constraint`);return}if(!n.some((p)=>p.kind===i&&p.name===a.name))s.push(`${u}: "${a.name}" is not a ${i} constraint of this document`);let c=a.keys;if(!Array.isArray(c)||c.length===0){s.push(`${u}: keys is not a non-empty list`);return}let h=i==="ik"?ak:lk,d=i==="ik"?["time",...ak,"bendPositive","compress","stretch","curve"]:["time",...lk,"curve"],f=-1/0,m=[];if(c.forEach((p,y)=>{let g=`${u}.keys[${y}]`;if(!Gn(p)){s.push(`${g} is not an object`);return}wl(p,d,g,s);let x=p.time;if(typeof x!=="number"||!Number.isFinite(x)||x<0){s.push(`${g}: time is ${JSON.stringify(x)}, not a finite time at or after 0`);return}if(x<=f)s.push(`${g}: time ${x} is not after the key before it — the writer refuses key times that do not strictly increase`);f=Math.max(f,x);let b=h.map((v)=>{if(i==="transform"&&v==="mixY"&&p.mixY===void 0)return an(p,"mixX",1,g,s);return an(p,v,v==="softness"?0:1,g,s)});m.push({time:Math.fround(x),values:b.map(Math.fround),stated:{time:x,values:b},curve:bE(p,h.length,y===c.length-1,g,s),flags:{bendPositive:Jt(p,"bendPositive",!0,g,s),compress:Jt(p,"compress",!1,g,s),stretch:Jt(p,"stretch",!1,g,s)}})}),i==="ik")r.ik.push({name:a.name,keys:m});else r.transform.push({name:a.name,keys:m})})}return r}var mk={rotate:["value"],translate:["x","y"],translatex:["value"],translatey:["value"],scale:["x","y"],scalex:["value"],scaley:["value"],shear:["x","y"],shearx:["value"],sheary:["value"]},TE=[...Object.keys(mk),"inherit"],Gd={rgba:{fields:[["color",8]],channels:["r","g","b","a"]},rgb:{fields:[["color",6]],channels:["r","g","b"]},alpha:{fields:[],channels:["a"]},rgba2:{fields:[["light",8],["dark",6]],channels:["r","g","b","a","r2","g2","b2"]},rgb2:{fields:[["light",6],["dark",6]],channels:["r","g","b","r2","g2","b2"]}},CE=["attachment",...Object.keys(Gd)];var mr=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),AE=(e,t)=>typeof e==="string"&&e.length===t&&/^[0-9a-fA-F]+$/.test(e);function pk(e,t,n){let s=e.time;if(typeof s!=="number"||!Number.isFinite(s)||s<0)return n.push(`${t}: time is ${JSON.stringify(s)}, not a finite time at or after 0`),null;return s}function gk(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),[];let s=[],r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!mr(i)){n.push(`${a} is not an object`);return}let l=pk(i,a,n);if(l===null)return;if(l<=r)n.push(`${a}: time ${i.time} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l),s.push({raw:i,at:a,time:l})}),s}function Ci(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this timeline's keys carry; they carry [${t.join(", ")}]`)}function yk(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function EE(e,t,n,s){let r=gk(t,n,s);return r.map(({raw:i,at:o,time:a},l)=>{if(e==="inherit"){Ci(i,["time","inherit"],o,s);let h=typeof i.inherit==="string"?Ld(i.inherit):null;if(h===null)s.push(`${o}: inherit is ${JSON.stringify(i.inherit)}, which folds to no inherit mode`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",mode:h??"normal"}}let u=mk[e];Ci(i,["time",...u,"curve"],o,s);let c=u.map((h)=>{let d=i[h];if(typeof d!=="number"||!Number.isFinite(d))return s.push(`${o}: ${h} is ${JSON.stringify(d)}, not a finite number — the writer states every channel on every key`),0;return d});return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:yk(i,u.length,l===r.length-1,o,s)}})}function RE(e,t){let n=[];for(let s=0;s{if(e==="attachment"){if(Ci(i,["time","name"],o,s),i.name!==null&&(typeof i.name!=="string"||i.name===""))s.push(`${o}: name is ${JSON.stringify(i.name)}, not a placeholder name or null`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",name:typeof i.name==="string"?i.name:null}}let u=Gd[e],c=[];if(e==="alpha"){Ci(i,["time","value","curve"],o,s);let h=i.value;if(typeof h!=="number"||!Number.isFinite(h))s.push(`${o}: value is ${JSON.stringify(h)}, not a finite number`);else c=[h]}else{Ci(i,["time",...u.fields.map(([h])=>h),"curve"],o,s);for(let[h,d]of u.fields){let f=i[h];if(!AE(f,d))s.push(`${o}: ${h} is ${JSON.stringify(f)}, not ${d} hex digits — the one spelling the writer gives a ${e} key's ${h}`);else c.push(...RE(f,h==="dark"||d===6?3:4))}}if(c.length!==u.channels.length)c=u.channels.map(()=>0);return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:yk(i,u.channels.length,l===r.length-1,o,s)}})}function $E(e,t,n){let s=[],r=0,i=(a,l)=>{if(r++,!Array.isArray(a)){n.push(`${l} is not a list of keys`);return}a.forEach((u,c)=>{if(!mr(u))n.push(`${l}[${c}] is not an object`);else{let h=pk(u,`${l}[${c}]`,n);if(h!==null)s.push(Math.fround(h))}})},o=(a,l,u)=>{if(!Array.isArray(a)){n.push(`${l} is not a list`);return}a.forEach((c,h)=>mr(c)?u(c,`${l}[${h}]`):n.push(`${l}[${h}] is not an object`))};if(!mr(e))n.push(`${t} is not an object`);else{for(let a of["ik","transform"])o(e[a],`${t}.${a}`,(l,u)=>i(l.keys,`${u}.keys`));for(let a of["path","physics","slider"])o(e[a],`${t}.${a}`,(l,u)=>o(l.timelines,`${u}.timelines`,(c,h)=>i(c.keys,`${h}.keys`)))}return{timelines:r,times:s}}function xk(e,t,n,s,r,i){let o=typeof e.duration==="number"&&Number.isFinite(e.duration)?e.duration:0;if(typeof e.duration!=="number"||!Number.isFinite(e.duration))r.push(`${t}: duration is ${JSON.stringify(e.duration)}, not a finite number`);let a=new Map(s.map((x)=>[x.name,x])),l=[],u=(x,b,v,_)=>{let S=e[x],M=[];if(!Array.isArray(S))return r.push(`${t}: ${x} is not a list`),M;return S.forEach((k,T)=>{let A=`${t}.${x}[${T}]`;if(!mr(k)||typeof k.name!=="string"){r.push(`${A} names no target`);return}let O=`${A} "${k.name}"`,R=v(k.name);if(R!==null)r.push(`${O}: ${R}`);if(!Array.isArray(k.timelines)){r.push(`${O}: timelines is not a list`);return}let P=k.name,I={name:P,timelines:[]};k.timelines.forEach((F,B)=>{let C=`${O}.timelines[${B}]`;if(!mr(F)||typeof F.name!=="string"){r.push(`${C} names no timeline`);return}let D=b.find((G)=>G===F.name);if(D===void 0){r.push(`${C}: "${F.name}" is not a ${x==="bones"?"bone":"slot"} timeline this core reads; it reads [${b.join(", ")}]`);return}if(I.timelines.some((G)=>G.kind===D))r.push(`${C}: "${D}" is keyed twice on ${P} — the writer merges one property's tracks into one`);let N=_(D,F.keys,`${C} "${D}"`,P);for(let G of N)l.push(G.time);I.timelines.push({kind:D,keys:N})}),M.push(I)}),M},c=u("bones",TE,(x)=>n.has(x)?null:`"${x}" is not a bone of this document`,(x,b,v)=>EE(x,b,v,r)),h=u("slots",CE,(x)=>a.has(x)?null:`"${x}" is not a slot of this document`,(x,b,v,_)=>{if((x==="rgba2"||x==="rgb2")&&a.get(_)?.dark===void 0)r.push(`${v}: slot "${_}" states no dark colour, and a ${x} timeline on such a slot makes the runtime throw while it is applied — the writer refuses it`);return PE(x,b,v,r)}),d=[],f=$E(e.constraints,`${t}.constraints`,r);if(l.push(...f.times),f.timelines>0)d.push(["constraints",f.timelines]);let m=wS(e.attachments,t,i.skins,r),p=TS(e.drawOrder,t,s,r),y=$S(e.events,t,i.events,r);for(let x of m)for(let b of[...x.deform??[],...x.sequence??[]])l.push(b.time);for(let x of[...p,...y])l.push(x.time);let g=m.reduce((x,b)=>x+(b.deform===null?0:1)+(b.sequence===null?0:1),0);if(g>0)d.push(["attachments",g]);if(p.length>0)d.push(["drawOrder",1]);if(y.length>0)d.push(["events",1]);return{declared:o,duration:l.length===0?0:Math.max(...l),bones:c,slots:h,later:d,attachments:m,drawOrder:p,events:y}}var ms="rigc-compiled/3",Xd="rigc-compiled/2",jd="rigc-compiled/1",Ak=[ms,Xd,jd];class st extends Error{}var Ek=["referenceScale","stage","bones","slots","skins","constraints","events","animations","editorOrder","images","pageGrids","droppedStates","absentParts","meshBones","meshes","physics","deformTransforms","trackDerivations","rig","pages","spine"],Rk=Ek.filter((e)=>e!=="stage"&&e!=="editorOrder"),IE=Rk.filter((e)=>e!=="pages"),Pk=["name","width","height","pma","scale","regions"],BE=Pk.filter((e)=>e!=="pma"&&e!=="scale"),_k=["x","y","width","height"],Sk=["slot","attachment"],kk=["name","x","y","width","height","offsetX","offsetY","originalWidth","originalHeight","degrees","index"],DE=["name","parent","length","x","y","rotation","scaleX","scaleY","shearX","shearY","inheritMode","skinRequired","editor"],FE=["length","x","y","rotation","scaleX","scaleY","shearX","shearY"],NE=["name","bone","setup","color","dark","blend"],GE=["name","bones","constraints","attachments"],wk={mesh:["kind","name","path","color","uvs","triangles","vertices","hull","edges","width","height","sequence"],boundingbox:["kind","name","vertexCount","vertices","editorColor"],clipping:["kind","name","end","convex","inverse","vertexCount","vertices","editorColor"],path:["kind","name","closed","constantSpeed","vertexCount","vertices","lengths","editorColor"],region:["kind","name","path","x","y","rotation","scaleX","scaleY","width","height","color","sequence","atlas"],linkedmesh:["kind","name","path","source","skin","slot","timelines","width","height","color","sequence"]},LE=new Set(["region","mesh","linkedmesh"]),$k=/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/,Yd=["Normal","Additive","Multiply","Screen"];function UE(e){let t=`${e.slice(0,1).toUpperCase()}${e.slice(1)}`;return Yd.includes(t)?t:null}var pr=["ik","transform","path","physics","slider"],Ok=["normal","onlyTranslation","noRotationOrReflection","noScale","noScaleOrReflection"],Mk=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function WE(e,t,n){if(!Array.isArray(e))return t.push(`pages is ${JSON.stringify(e)??"absent"}, not a list of pages`),[];let s=[];return e.forEach((r,i)=>{let o=`pages[${i}]`;if(!Ne(r)){t.push(`${o} is not an object`);return}let a=t.length,l=typeof r.name==="string"?`${o} "${r.name}"`:o;if(Dt(r,n?Pk:BE,l,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)??"absent"}, not a non-empty string`);for(let c of["width","height"]){let h=r[c];if(typeof h!=="number"||!Number.isFinite(h)||h<=0)t.push(`${l}: ${c} is ${JSON.stringify(h)??"absent"}, not a positive finite number — a page UV divides by it`)}if(n){if(typeof r.pma!=="boolean")t.push(`${l}: pma is ${JSON.stringify(r.pma)??"absent"}, not true or false — whether the page's texels are premultiplied`);if(r.scale!==null&&(typeof r.scale!=="number"||!Number.isFinite(r.scale)))t.push(`${l}: scale is ${JSON.stringify(r.scale)??"absent"}, not a finite number or null — the number the page's scale: line states, null where it has none`)}let u=[];if(!Array.isArray(r.regions))t.push(`${l}: regions is not a list`);else if(r.regions.length===0)t.push(`${l}: regions is an empty list — a page holds at least one region; the atlas text cannot state a page with none (its block would end before a region line, which A07_ATLAS_TEXT_SHAPE refuses), so no build writes one`);else r.regions.forEach((c,h)=>{let d=`${l}.regions[${h}]`;if(!Ne(c)){t.push(`${d} is not an object`);return}let f=typeof c.name==="string"?`${d} "${c.name}"`:d;if(Dt(c,kk,f,t),typeof c.name!=="string"||c.name==="")t.push(`${d}: name is ${JSON.stringify(c.name)??"absent"}, not a non-empty string`);for(let m of kk){if(m==="name")continue;let p=c[m];if(typeof p!=="number"||!Number.isFinite(p))t.push(`${f}: ${m} is ${JSON.stringify(p)??"absent"}, not a finite number`)}u.push(c)});if(t.length===a)s.push(n?{name:r.name,width:r.width,height:r.height,pma:r.pma,scale:r.scale,regions:u}:{name:r.name,width:r.width,height:r.height,regions:u})}),s}function XE(e,t){if(e===void 0)return"";if(!Ne(e))return t.push(`spine is ${JSON.stringify(e)}, not { "sha256": "<64 lowercase hex digits>" }`),"";for(let s of Object.keys(e))if(s!=="sha256")t.push(`spine: field "${s}" is not one this reader knows; it reads [sha256]`);let n=e.sha256;if(typeof n!=="string"||!/^[0-9a-f]{64}$/.test(n))return t.push(`spine.sha256 is ${JSON.stringify(n)??"absent"}, not 64 lowercase hex digits — the SHA-256 of the skeleton.json written beside the document`),"";return n}function jE(e,t){if(e===null)return null;if(!Ne(e))return t.push(`stage is ${JSON.stringify(e)??"absent"}, not null or { x, y, width, height } — the setup-pose box the Spine header declares`),null;let n=t.length;Dt(e,[..._k,"box"],"stage",t);for(let i of _k){let o=e[i];if(typeof o!=="number"||!Number.isFinite(o))t.push(`stage: ${i} is ${JSON.stringify(o)??"absent"}, not a finite number`)}let s=e.box;if(s!==void 0)if(!Ne(s))t.push(`stage.box is ${JSON.stringify(s)}, not { slot, attachment }`);else{Dt(s,Sk,"stage.box",t);for(let i of Sk)if(typeof s[i]!=="string"||s[i]==="")t.push(`stage.box: ${i} is ${JSON.stringify(s[i])??"absent"}, not a non-empty string`)}if(t.length!==n)return null;let r={x:e.x,y:e.y,width:e.width,height:e.height};if(Ne(s))r.box={slot:s.slot,attachment:s.attachment};return r}function YE(e,t,n,s){let r={skins:[],animations:[]};if(!Ne(e))return s.push(`editorOrder is ${JSON.stringify(e)??"absent"}, not { skins, animations }`),r;Dt(e,["skins","animations"],"editorOrder",s);let i=(l,u)=>{if(!Array.isArray(l)||l.some((c)=>typeof c!=="string"))return s.push(`${u} is ${JSON.stringify(l)??"absent"}, not a list of names`),null;return l},o=(l,u,c,h)=>{let d=new Set;for(let m of l){if(d.has(m))return void s.push(`${c} lists ${h} "${m}" twice`);if(d.add(m),!u.includes(m))return void s.push(`${c} lists ${h} "${m}", which the document does not hold`)}let f=u.find((m)=>!d.has(m));if(f!==void 0)s.push(`${c} leaves out ${h} "${f}"`)};if(!Array.isArray(e.skins))s.push(`editorOrder.skins is ${JSON.stringify(e.skins)??"absent"}, not a list`);else e.skins.forEach((l,u)=>{let c=`editorOrder.skins[${u}]`;if(!Ne(l)||typeof l.name!=="string")return void s.push(`${c} is not { name, slots }`);Dt(l,["name","slots"],c,s);let h=i(l.slots,`${c}.slots`),d=t.find((f)=>f.name===l.name);if(h!==null&&d!==void 0)o(h,Object.keys(d.attachments),`${c}.slots`,"slot key");r.skins.push({name:l.name,slots:h??[]})}),o(r.skins.map((l)=>l.name),t.map((l)=>l.name),"editorOrder.skins","skin");let a=i(e.animations,"editorOrder.animations");if(a!==null)o(a,n.map((l)=>l.name),"editorOrder.animations","animation"),r.animations=a;return r}var Ne=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Ld(e){let t=e.length===0?e:e[0].toLowerCase()+e.slice(1);return Ok.find((n)=>n===t)??null}function Dt(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function VE(e,t){if(!Array.isArray(e))return t.push("bones is not a list"),[];let n=[],s=new Set;return e.forEach((r,i)=>{let o=`bones[${i}]`;if(!Ne(r)){t.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(Dt(r,DE,a,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);else if(s.has(r.name))t.push(`${a}: the name is declared twice`);if(r.parent!==void 0){if(typeof r.parent!=="string")t.push(`${a}: parent is ${JSON.stringify(r.parent)}, not a bone name`);else if(!s.has(r.parent))t.push(`${a}: parent "${r.parent}" is not declared before it; bones are parents first`)}for(let l of FE){let u=r[l];if(u!==void 0&&(typeof u!=="number"||!Number.isFinite(u)))t.push(`${a}: ${l} is ${JSON.stringify(u)}, not a finite number`)}if(r.inheritMode!==void 0){if(typeof r.inheritMode!=="string"||Ld(r.inheritMode)===null)t.push(`${a}: inheritMode is ${JSON.stringify(r.inheritMode)}, which folds to none of ${Ok.join(", ")}`)}if(r.skinRequired!==void 0&&typeof r.skinRequired!=="boolean")t.push(`${a}: skinRequired is ${JSON.stringify(r.skinRequired)}, not a boolean`);if(r.editor!==void 0)if(!Ne(r.editor))t.push(`${a}: editor is not an object`);else{Dt(r.editor,["color","icon"],`${a}.editor`,t);for(let l of["color","icon"])if(r.editor[l]!==void 0&&typeof r.editor[l]!=="string")t.push(`${a}.editor: ${l} is not a string`)}if(typeof r.name==="string"&&r.name!=="")s.add(r.name);n.push(r)}),n}function HE(e,t,n){if(!Array.isArray(e))return n.push("slots is not a list"),[];let s=[];return e.forEach((r,i)=>{let o=`slots[${i}]`;if(!Ne(r)){n.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(Dt(r,NE,a,n),typeof r.name!=="string"||r.name==="")n.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);if(typeof r.bone!=="string")n.push(`${a}: bone is ${JSON.stringify(r.bone)}, not a bone name`);else if(!t.has(r.bone))n.push(`${a}: bone "${r.bone}" is not a bone of this document`);if(r.setup!==null&&typeof r.setup!=="string")n.push(`${a}: setup is ${JSON.stringify(r.setup)}, not a placeholder name or null`);for(let l of["color","dark","blend"])if(r[l]!==void 0&&typeof r[l]!=="string")n.push(`${a}: ${l} is ${JSON.stringify(r[l])}, not a string`);for(let l of["color","dark"]){let u=r[l];if(typeof u==="string"&&!$k.test(u))n.push(`${a}: ${l} is ${JSON.stringify(u)}, not six or eight hex digits (rrggbb or rrggbbaa) — the only spellings whose reading was measured to be a colour`)}if(typeof r.blend==="string"&&UE(r.blend)===null)n.push(`${a}: blend is ${JSON.stringify(r.blend)}, which the runtime reads as no mode — one of ${Yd.join(", ")}, first letter in either case, is the only spelling measured to be one`);s.push(r)}),s}function zE(e,t,n,s,r){let i={};for(let[o,a]of Object.entries(e)){let l=`${s}.attachments["${o}"]`;if(!n.has(o))r.push(`${l}: "${o}" is not a slot of this document`);if(!Ne(a)){r.push(`${l} is not an object`);continue}let u={};for(let[c,h]of Object.entries(a)){let d=`${l}["${c}"]`;if(!Ne(h)){r.push(`${d} is not an object`);continue}let f=Object.keys(wk),m=f.find((g)=>g===h.kind);if(m===void 0){r.push(`${d}: kind is ${JSON.stringify(h.kind)}, none of ${f.join(", ")}`);continue}Dt(h,wk[m],d,r);let p={kind:m};for(let g of["name","path"]){let x=h[g];if(x===void 0)continue;if(typeof x!=="string"||x==="")r.push(`${d}: ${g} is ${JSON.stringify(x)}, not a non-empty string`);else p[g]=x}if(m==="region"&&h.atlas!==void 0){let g=qE(h.atlas,`${d}.atlas`,r);if(g!==void 0)p.atlas=g}let y=jS(h,m,d,t,n,r);if(y!==void 0)p.geometry=y;if(Ne(h.sequence)){let g=h.sequence.count;if(typeof g==="number"&&Number.isInteger(g)&&g>=1)p.sequenceCount=g;else if(m!=="region")r.push(`${d}.sequence: count is ${JSON.stringify(g)}, not a whole number of at least 1`);let x=h.sequence.setup??0;if(typeof x==="number"&&Number.isInteger(x)&&x>=0&&(typeof g!=="number"||x{let a=`skins[${o}]`;if(!Ne(i)){s.push(`${a} is not an object`);return}let l=typeof i.name==="string"?`${a} "${i.name}"`:a;if(Dt(i,GE,l,s),typeof i.name!=="string"||i.name==="")s.push(`${a}: name is ${JSON.stringify(i.name)}, not a non-empty string`);let u=[];if(!Array.isArray(i.bones))s.push(`${l}: bones is not a list`);else i.bones.forEach((d,f)=>{if(typeof d!=="string")s.push(`${l}: bones[${f}] is not a bone name`);else if(!t.has(d))s.push(`${l}: bones[${f}] "${d}" is not a bone of this document`);else u.push(d)});let c=Object.fromEntries(pr.map((d)=>[d,[]]));if(!Ne(i.constraints))s.push(`${l}: constraints is not an object`);else for(let[d,f]of Object.entries(i.constraints)){let m=pr.find((p)=>p===d);if(m===void 0)s.push(`${l}.constraints: "${d}" is not a constraint kind; a skin lists ${pr.join(", ")}`);else if(!Array.isArray(f)||f.some((p)=>typeof p!=="string"))s.push(`${l}.constraints.${d} is not a list of constraint names`);else c[m]=f}let h={};if(!Ne(i.attachments))s.push(`${l}: attachments is not an object`);else h=zE(i.attachments,t,n,l,s);r.push({name:typeof i.name==="string"?i.name:"",bones:u,constraints:c,attachments:h})}),r}function JE(e,t,n,s,r,i){let o=new Set(n.map((l)=>l.name));if(!Array.isArray(e))return i.push("animations is not a list"),[];let a=[];return e.forEach((l,u)=>{let c=`animations[${u}]`;if(!Ne(l)){i.push(`${c} is not an object`);return}if(typeof l.name!=="string"||l.name==="")i.push(`${c}: name is ${JSON.stringify(l.name)}, not a non-empty string`);let h=typeof l.name==="string"?`${c} "${l.name}"`:c,d=[];if(!Array.isArray(l.slots))i.push(`${h}: slots is not a list`);else l.slots.forEach((p,y)=>{if(!Ne(p)||typeof p.name!=="string")i.push(`${h}: slots[${y}] names no slot`);else if(!o.has(p.name))i.push(`${h}: slots[${y}] "${p.name}" is not a slot of this document`);else d.push(p.name)});let f=[],m=(p)=>Array.isArray(p)?p.filter(Ne):[];for(let p of m(l.attachments))for(let y of m(p.slots))for(let g of m(y.attachments))if(g.deform!==void 0)f.push(`${String(p.name)}/${String(y.name)}/${String(g.name)}`);a.push({name:typeof l.name==="string"?l.name:"",slots:d,timelines:xk(l,h,t,n,i,{skins:s,events:r}),constraints:{ik:[],transform:[],path:[],physics:0,slider:[]},deforms:f})}),a}function ZE(e,t,n,s,r,i){let o=new Set(n.map((c)=>c.name)),a=new Map(s.map((c)=>[c.name,c.bone])),l=new Map(n.map((c)=>[c.name,c.parent]));if(!Array.isArray(e))return i.push("constraints is not a list"),[];let u=[];return e.forEach((c,h)=>{let d=`constraints[${h}]`;if(!Ne(c)){i.push(`${d} is not an object`);return}let f=pr.find((y)=>y===c.kind);if(f===void 0)i.push(`${d}: kind is ${JSON.stringify(c.kind)}, none of ${pr.join(", ")}`);if(typeof c.name!=="string"||c.name==="")i.push(`${d}: name is ${JSON.stringify(c.name)}, not a non-empty string`);if(c.declaredIn!=="rig"&&c.declaredIn!=="motion")i.push(`${d}: declaredIn is ${JSON.stringify(c.declaredIn)}, not "rig" or "motion"`);let m=`${d} "${String(c.name)}"`,p;if(typeof c.name==="string"){if(f==="ik"||f==="transform")p=ck(c,f,c.name,m,o,l,i);else if(f==="path")p=VS(c,c.name,m,o,a,i);else if(f==="physics")p=ZS(c,c.name,m,o,r,i);else if(f==="slider")p=nk(c,c.name,m,n,t,i)}if(f!==void 0&&typeof c.name==="string")u.push({kind:f,name:c.name,...f==="slider"&&typeof c.animation==="string"?{animation:c.animation}:{},...p!==void 0?{record:p}:{}})}),u}function Ik(e,t="the model document"){let n;try{n=JSON.parse(e)}catch(_){throw new st(`${t}: not JSON — ${_.message}`)}if(!Ne(n))throw new st(`${t}: not a JSON object`);if(typeof n.spec!=="string"||!Ak.includes(n.spec))throw new st(`${t}: spec is ${JSON.stringify(n.spec)}, not "${ms}" (or "${Xd}", read without its stage, editor order and page flags, or "${jd}", read without its pages too)`);let s=n.spec,r=s===ms?Ek:s===Xd?Rk:IE,i=[];for(let _ of r)if(!(_ in n))i.push(`section "${_}" is missing`);for(let _ of Object.keys(n))if(_!=="spec"&&!r.includes(_))i.push(`section "${_}" is not one a ${s} document has`);let o=s!==jd&&"pages"in n?WE(n.pages,i,s===ms):null,a=s===ms&&"stage"in n?jE(n.stage,i):null,l=typeof n.referenceScale==="number"&&Number.isFinite(n.referenceScale)?n.referenceScale:NaN;if("referenceScale"in n&&Number.isNaN(l))i.push(`referenceScale is ${JSON.stringify(n.referenceScale)}, not a finite number — wind and gravity act over it`);let u=XE(n.spine,i),c=VE(n.bones,i),h=new Set(c.map((_)=>_.name)),d=HE(n.slots,h,i),f=new Set(d.map((_)=>_.name)),m=KE(n.skins,h,f,i);i.push(...eR(m));let p=PS(n.events,i),y=JE(n.animations,h,d,m,p,i),g=ZE(n.constraints,y,c,d,l,i);for(let _ of m)for(let S of pr)for(let M of _.constraints[S])if(!g.some((k)=>k.kind===S&&k.name===M))i.push(`skin "${_.name}".constraints.${S}: "${M}" is not a ${S} constraint of this document — the runtime refuses the file ("Couldn't find … constraint ${M} for skin ${_.name}.")`);if(Array.isArray(n.animations))n.animations.forEach((_,S)=>{if(Ne(_)&&y[S]!==void 0)y[S].constraints=uk(_.constraints,`animations[${S}] "${y[S].name}"`,g,i)});for(let _ of g){let S=_.record;if(S?.kind==="slider")S.physics=y.find((M)=>M.name===S.animation)?.constraints.physicsKeyed??[]}let x=s===ms&&"editorOrder"in n?YE(n.editorOrder,m,y,i):null;if(i.length>0)throw new st(`${t}: ${i.length} problem(s): ${i.join("; ")}`);let v={spec:s,skin:_d,referenceScale:l,bones:c,slots:d,skins:m,constraints:g,animations:y,spine:{sha256:u},pages:o,stated:x===null?null:{stage:a,editorOrder:x}};return QE(v),v}function QE(e){for(let t of e.constraints)if(t.record!==void 0)t.record.listedBySkin=_S(e,t.kind,t.name);for(let t of e.constraints){let n=t.record;if(n?.kind!=="path")continue;n.path=null,n.unresolved=null;let s=e.slots.find((a)=>a.name===n.slot),r=fr(e,s),i=s.setup===null?[]:ki(e,s.name,s.setup).flatMap((a)=>{let l=e.skins.find((u)=>u.name===a)?.attachments[s.name]?.[s.setup]?.geometry;return l===void 0?[]:[{skin:a,g:JSON.stringify(l)}]});if(i.length>1&&i.some((a)=>a.g!==i[0].g))n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${i.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&"conflict"in r)n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${r.conflict.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&r.record.geometry?.kind==="path"){let a=r.record.geometry;n.path={vertices:a.vertices,closed:a.closed,constantSpeed:a.constantSpeed,lengths:a.lengths}}let o=[];for(let a of pl(e))for(let l of Object.values(a.attachments[n.slot]??{})){let u=l.geometry;if(u?.kind!=="path")continue;for(let c of u.vertices.weighted?u.vertices.bindings.flatMap((h)=>h.map((d)=>d.bone)):[n.slotBone])if(!o.includes(c))o.push(c)}n.slotDeps=o}}function eR(e){let t=[];return e.forEach((n,s)=>{for(let[r,i]of Object.entries(n.attachments))for(let[o,a]of Object.entries(i)){let l=a.geometry;if(l?.kind!=="linkedmesh")continue;let u=Bk(e,l.skin,l.slot,l.source);if(u!==null)t.push(`skins[${s}] "${n.name}".attachments["${r}"]["${o}"]: ${u}`)}}),t}function Bk(e,t,n,s){let r=e.find((o)=>o.name===t);if(r===void 0)return`the linked mesh's skin "${t}" is not a skin of this document`;let i=r.attachments[n]?.[s];if(i===void 0)return`the linked mesh's source "${s}" is not in skin "${t}" slot "${n}"`;if(i.kind!=="mesh")return`the linked mesh's source "${s}" in skin "${t}" slot "${n}" is a ${i.kind}, not a mesh`;return null}function Vd(e){if(!Number.isFinite(e))return null;return e===0?0:e}var Tk=new WeakMap;function on(e){let t=Tk.get(e);if(t!==void 0)return t;let n=tR(e);return Tk.set(e,n),n}function tR(e){let t=new Set(Sd(e).flatMap((r)=>r.bones)),n=new Map(e.bones.map((r)=>[r.name,r.parent])),s=new Set;for(let r of t)for(let i=r;i!==void 0&&!s.has(i);i=n.get(i))s.add(i);return new Set(e.bones.filter((r)=>r.skinRequired!==!0||s.has(r.name)).map((r)=>r.name))}function Md(e){let t=e.record.name??e.placeholder;return{name:t,path:LE.has(e.record.kind)?e.record.path??t:null}}var Ck=new WeakMap;function fr(e,t,n=t.setup){if(n===null)return null;let s=Ck.get(e);if(s===void 0)s=new Map,Ck.set(e,s);let r=s.get(t.name);if(r===void 0)r=new Map,s.set(t.name,r);if(r.has(n))return r.get(n);let i=nR(e,t.name,n);return r.set(n,i),i}function nR(e,t,n){if(e.skin!==_d){for(let o of pl(e)){let a=o.attachments[t]?.[n];if(a!==void 0)return{skin:o.name,placeholder:n,record:a}}return null}let s=[];for(let o of e.skins){let a=o.attachments[t]?.[n];if(a!==void 0)s.push({skin:o.name,placeholder:n,record:a})}if(s.length===0)return null;let r=s.map((o)=>({skin:o.skin,...Md(o)}));return r.every((o)=>o.name===r[0].name&&o.path===r[0].path)?s[0]:{conflict:r.map((o)=>({skin:o.skin,shown:o.name,path:o.path}))}}function Ud(e,t,n={}){let s=on(e);return{order:t,active:s,meshOf:(r,i,o)=>{let a=e.skins.find((l)=>l.name===r)?.attachments[i]?.[o]?.geometry;return a?.kind==="mesh"?{uvs:a.uvs,triangles:a.triangles}:void 0},...n.clip===void 0?{}:{clip:n.clip},...n.through===void 0?{}:{through:n.through}}}function Wd(e){return(t,n,s)=>{let r=e.skins.find((i)=>i.name===t)?.attachments[n]?.[s]?.geometry;return r?.kind==="mesh"?r.vertices:Bk(e.skins,t,n,s)??`the linked mesh's source "${s}" carries no vertices`}}function oR(e,t){if(e===null)throw new st(`the raw pose computed a non-finite ${t}`);return e}var aR=(e)=>e;function lR(e,t,n){return n.keep?e===null?Number.NaN:e:oR(e,t)}var cR=()=>null;function Dk(e,t){return e.bones.map((n)=>{let s=t.get(n.name);if(s===void 0)throw new st(`bone "${n.name}" has no world transform`);return{name:n.name,a:s.a,b:s.b,c:s.c,d:s.d,worldX:s.worldX,worldY:s.worldY}})}function uR(e,t,n,s,r,i){let o=Ud(e,s,r),a=_l(t,n,Wd(e),i.keep?aR:Vd,{region:r.region,vertices:r.vertices,deformedVertices:r.deformedVertices},i.loop&&i.live!==!0&&r.through===void 0?{...o,through:cR}:o);if(a.attachments===null)throw new st(`the raw pose leaves the attachments out: ${a.attachmentsWhy}`);if(a.drawnClipped===null)throw new st(`the raw pose leaves the clipped triangles out: ${a.drawnClippedWhy}`);return{rows:a.attachments,clips:a.clips,drawnClipped:a.drawnClipped}}function Fk(e,t,n,s,r,i,o={}){let{rows:a}=uR(e,t,n,s,r,i),l=[],u=0;for(let c of t){let h=c.geometry;if(h.kind!=="region"&&h.kind!=="mesh"&&h.kind!=="linkedmesh")continue;let d=a[u++];if(d===void 0||d[0]!==c.slot)throw new st(`slot "${c.slot}": the attachment rows are not in the shown records' order`);let f=d[3],m=i.keep&&hR(f)?f:f.map((p)=>lR(p,`vertex of slot "${c.slot}"`,i));l.push({slot:c.slot,attachment:d[1],vertices:o.vertices===void 0?m:o.vertices(m,c.slot)})}return l}function hR(e){for(let t of e)if(t===null)return!1;return!0}function dR(e){return{setup:(t,n,s,r,i,o,a)=>({animationTime:0,bones:Dk(t,n),slots:s,drawn:Fk(t,i,n,r,o,a,e)}),step:(t,n,s,r)=>{let i=Fk(t,n.shown,n.world,n.drawOrder,s,r,e);return{animationTime:n.animationTime,bones:Dk(t,n.world),slots:n.slots,drawn:i}}}}var $7=dR({});var Gi=new WeakMap;function n1(e){if("order"in e)return e;e.generation;let t=Gi.get(e);if(!t)throw Error("LIVE_FRAME_SOURCE: renderer needs a liveFrame() borrowed from a player");return t}var Hd=100,vR=0.001;function s1(e,t){let n=document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.width=`${Hd}px`,n.style.height=`${Hd}px`,n.style.visibility="hidden",n.style.pointerEvents="none",e.appendChild(n);let s=0,r=0;try{let l=n.getBoundingClientRect();s=l.width,r=l.height}finally{n.remove()}let i=Math.max(s,r)/Hd;if(!(i>0))return t;let a=(typeof devicePixelRatio==="number"?devicePixelRatio:1)*i;if(t>0&&Math.abs(a-t)e*zl,rotationOnlyFrame:!1};function o1(e,t,n,s,r,i=Gf){let o=(e+t)*i,a=(e+90+n)*i;return[Math.cos(o)*s,Math.cos(a)*r,Math.sin(o)*s,Math.sin(a)*r]}function hf(e,t,n,s,r,i){let o=e.radiansPerDegree;if(e.rotationOnlyFrame&&r===1&&i===1&&n===0&&s===0){let a=Math.cos(t*o),l=Math.sin(t*o);return[a,-l,l,a]}return o1(t,n,s,r,i,o)}function zd(e,t){return[e[0]*t[0]+e[1]*t[2],e[0]*t[1]+e[1]*t[3],e[2]*t[0]+e[3]*t[2],e[2]*t[1]+e[3]*t[3]]}function a1(e,t,n=Gf){let s=t*n,r=Math.cos(s),i=Math.sin(s),o=e[0]*r+e[1]*i,a=e[2]*r+e[3]*i,l=1/Math.sqrt(o*o+a*a);return[o*l,a*l]}function l1(e,t,n,s=i1){let r=n.rotation??0,i=n.shearX??0,o=n.shearY??0,a=n.scaleX??1,l=n.scaleY??1,u=s.radiansPerDegree,c=[t.a,t.b,t.c,t.d];switch(e){case"normal":return zd(c,hf(s,r,i,o,a,l));case"onlyTranslation":return hf(s,r,i,o,a,l);case"noRotationOrReflection":{let h=c[0]*c[0]+c[2]*c[2],d,f;if(h>r1){let y=Math.abs(c[0]*c[3]-c[1]*c[2])/h;d=[c[0],-c[2]*y,c[2],c[0]*y],f=r-s.degreesOf(Math.atan2(c[2],c[0]))}else d=[0,-c[1],0,c[3]],f=r-90+s.degreesOf(Math.atan2(c[3],c[1]));let m=(f+i)*u,p=(f+o+90)*u;return zd(d,[Math.cos(m)*a,Math.cos(p)*l,Math.sin(m)*a,Math.sin(p)*l])}case"noScale":case"noScaleOrReflection":{let[h,d]=a1(c,r,u),f=e==="noScale"&&c[0]*c[3]-c[1]*c[2]<0?-1:1,m=[h,-d*f,d,h*f];return zd(m,o1(0,i,o,a,l,u))}}}function _R(e){let t=e.inheritMode;if(t===void 0)return"normal";let n=t.length===0?t:t[0].toLowerCase()+t.slice(1);if(n==="normal"||n==="onlyTranslation"||n==="noRotationOrReflection"||n==="noScale"||n==="noScaleOrReflection")return n;throw Error(`bone "${e.name}": inheritMode ${JSON.stringify(t)} is no mode (readModel refuses it first)`)}function Li(e,t=null,n=l1,s=i1){let r=new Map;for(let i of e){if(t!==null&&!t.has(i.name)){r.set(i.name,{a:0,b:0,c:0,d:0,worldX:0,worldY:0});continue}let o=i.x??0,a=i.y??0;if(i.parent===void 0){let[f,m,p,y]=hf(s,i.rotation??0,i.shearX??0,i.shearY??0,i.scaleX??1,i.scaleY??1);r.set(i.name,{a:f,b:m,c:p,d:y,worldX:o,worldY:a});continue}let l=r.get(i.parent);if(l===void 0)throw Error(`bone "${i.name}": parent "${i.parent}" is not posed before it`);let[u,c,h,d]=n(_R(i),l,i,s);r.set(i.name,{a:u,b:c,c:h,d,worldX:l.a*o+l.b*a+l.worldX,worldY:l.c*o+l.d*a+l.worldY})}return r}var _s="all",Nk="default";function c1(e){if(e.skin===null)return[];return e.skin===_s?e.skins:e.skins.filter((t)=>t.name===e.skin)}function Lf(e){if(e.skin===_s)return e.skins;let t=e.skin===null?void 0:e.skins.find((s)=>s.name===e.skin),n=e.skin===Nk?void 0:e.skins.find((s)=>s.name===Nk);return[t,n].filter((s)=>s!==void 0)}function Uf(e,t,n){if(e.skin===_s)return e.skins.filter((r)=>r.attachments[t]?.[n]!==void 0).map((r)=>r.name);let s=Lf(e).find((r)=>r.attachments[t]?.[n]!==void 0);return s===void 0?[]:[s.name]}var ec=(e,t,n)=>n.has(t.bone);function SR(e,t,n){return c1(e).some((s)=>s.constraints[t].includes(n))}var u1=0.99999999,Gk=["hold","once","loop","pingpong","onceReverse","loopReverse","pingpongReverse"],kR=0.00001,wr=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),vs=(e)=>typeof e==="number"&&Number.isFinite(e);function h1(e){return e.weighted?2*e.bindings.reduce((t,n)=>t+n.length,0):e.xy.length}function d1(e,t,n){let s=-1/0;e.forEach((r,i)=>{if(!wr(r))return;let o=r.time;if(!vs(o)||o<0)n.push(`${t}[${i}]: time is ${JSON.stringify(o)}, not a finite time at or after 0`);else if(o<=s)n.push(`${t}[${i}]: time ${o} is not after the key before it — the writer refuses key times that do not strictly increase`);if(vs(o))s=Math.max(s,o)})}function wR(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];d1(e,t,s);let r=h1(n),i=[];return e.forEach((o,a)=>{let l=`${t}[${a}]`;if(!wr(o)){s.push(`${l} is not an object`);return}for(let m of Object.keys(o))if(!["time","offset","vertices","curve"].includes(m))s.push(`${l}: field "${m}" is not one a deform key carries; it carries [time, offset, vertices, curve]`);let u=o.vertices,c=[];if(u!==void 0)if(!Array.isArray(u)||u.length===0||!u.every(vs))s.push(`${l}: vertices is not a non-empty list of finite numbers (omit it for the setup geometry)`);else c=u;let h=0;if(o.offset!==void 0)if(u===void 0)s.push(`${l}: offset ${JSON.stringify(o.offset)} with no vertices — a key with no run is the setup geometry, and the writer states no start for it`);else if(typeof o.offset!=="number"||!Number.isInteger(o.offset)||o.offset<0)s.push(`${l}: offset is ${JSON.stringify(o.offset)}, not a whole index at or after 0`);else h=o.offset;if(h+c.length>r)s.push(`${l}: the run starts at ${h} and is ${c.length} long, past the ${r} numbers of the attachment's deform array`);let d="linear";if(o.curve!==void 0)if(a===e.length-1)s.push(`${l}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(o.curve==="stepped")d="stepped";else if(Array.isArray(o.curve)&&o.curve.length===4&&o.curve.every(vs))d=o.curve;else s.push(`${l}: curve is ${JSON.stringify(o.curve)}, not "stepped" nor 4 finite numbers (a deform key's curve is one channel)`);let f=vs(o.time)?o.time:0;i.push({time:Math.fround(f),stated:f,curve:d,offset:h,vertices:c})}),i}function MR(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];d1(e,t,s);let r=[];return e.forEach((i,o)=>{let a=`${t}[${o}]`;if(!wr(i)){s.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(!["time","mode","index","delay"].includes(h))s.push(`${a}: field "${h}" is not one a sequence key carries; it carries [time, mode, index, delay]`);let l="hold";if(i.mode!==void 0){let h=Gk.find((d)=>d===i.mode);if(h===void 0)s.push(`${a}: mode is ${JSON.stringify(i.mode)}, none of ${Gk.join(", ")}`);else l=h}let u=0;if(i.index!==void 0)if(typeof i.index!=="number"||!Number.isInteger(i.index)||i.index<0||i.index>=n)s.push(`${a}: index is ${JSON.stringify(i.index)}, not a frame of the series' ${n} — the writer refuses an index past the last frame`);else u=i.index;let c=r.length===0?0:r[r.length-1].delay;if(i.delay!==void 0)if(!vs(i.delay)||i.delay<0)s.push(`${a}: delay is ${JSON.stringify(i.delay)}, not a finite number of seconds at or above 0`);else c=Math.fround(i.delay);r.push({time:Math.fround(vs(i.time)?i.time:0),mode:l,index:u,delay:c})}),r}function TR(e,t,n,s){let r=[],i=`${t}.attachments`;if(!Array.isArray(e))return s.push(`${i} is not a list`),r;return e.forEach((o,a)=>{let l=`${i}[${a}]`;if(!wr(o)||typeof o.name!=="string"){s.push(`${l} names no skin`);return}let u=n.find((c)=>c.name===o.name);if(u===void 0)s.push(`${l}: "${o.name}" is not a skin of this document`);if(!Array.isArray(o.slots)){s.push(`${l}: slots is not a list`);return}o.slots.forEach((c,h)=>{let d=`${l}.slots[${h}]`;if(!wr(c)||typeof c.name!=="string"){s.push(`${d} names no slot`);return}if(!Array.isArray(c.attachments)){s.push(`${d}: attachments is not a list`);return}let f=c.name;c.attachments.forEach((m,p)=>{let y=`${d}.attachments[${p}]`;if(!wr(m)||typeof m.name!=="string"){s.push(`${y} names no attachment`);return}for(let v of Object.keys(m))if(!["name","deform","sequence"].includes(v))s.push(`${y}: field "${v}" is not one this reader knows; it reads [name, deform, sequence]`);let g=u?.attachments[f]?.[m.name],x=`${y} "${o.name}/${f}/${m.name}"`;if(u!==void 0&&g===void 0)s.push(`${x}: skin "${u.name}" files no attachment "${m.name}" under slot "${f}"`);let b={skin:o.name,slot:f,attachment:m.name,deform:null,sequence:null};if(m.deform!==void 0&&g!==void 0){let v=g.geometry;if(v===void 0||v.kind!=="mesh"&&v.kind!=="clipping"&&v.kind!=="boundingbox"&&v.kind!=="path")s.push(`${x}: a deform keys the vertices of a mesh, bounding box, clipping or path attachment, and this one is a ${g.kind}`);else b.deform=wR(m.deform,`${x}.deform`,v.vertices,s)}if(m.sequence!==void 0&&g!==void 0){let v=g.sequenceCount;if(v===void 0)s.push(`${x}: a sequence timeline steps a series, and this ${g.kind} carries no sequence`);else b.sequence=MR(m.sequence,`${x}.sequence`,v,s)}if(m.deform===void 0&&m.sequence===void 0)s.push(`${x}: carries neither a deform nor a sequence timeline`);r.push(b)})})}),r}function df(e,t){let n=kr(e);return t.vertices.forEach((s,r)=>{let i=t.offset+r;n[i]=e.weighted?Math.fround(s):Math.fround(n[i]+Math.fround(s))}),n}function kr(e){return e.weighted?Array(h1(e)).fill(0):e.xy.map((t)=>Math.fround(t))}function CR(e,t,n){if(e.curve==="stepped")return 0;if(e.curve==="linear")return(n-e.time)/(t.time-e.time);let s=e.curve,r=sc(e.stated,0,s[0],s[1],s[2],s[3],t.stated,u1),i=[e.time,0,...r,t.time,1],o=2;while(ou+(a[c]-u)*l)}function AR(e,t,n,s,r){let i=kr(e),o=t??i;if(!r&&s===1)return[...n];if(r&&s===1&&t===null)return[...n];return o.map((a,l)=>r?a+(n[l]-i[l])*s:a+(n[l]-a)*s)}function f1(e,t){if(!e.weighted)return{weighted:!1,xy:[...t]};let n=0;return{weighted:!0,bindings:e.bindings.map((s)=>s.map((r)=>{let i=Math.fround(r.x)+t[n],o=Math.fround(r.y)+t[n+1];return n+=2,{...r,x:i,y:o}}))}}function ER(e,t,n){let s=rt(e,n);if(s<0)return null;let r=e[s],i=r.index;if(r.mode!=="hold"&&r.delay>0)i+=Math.floor((n-r.time)/r.delay+kR);let o=r.mode.endsWith("Reverse"),a=o?r.mode.slice(0,-7):r.mode,l;if(a==="hold"||a==="once")l=Math.min(i,t-1);else if(a==="loop")l=i%t;else{let u=2*(t-1);if(l=u===0?0:i%u,l>=t)l=u-l}return o?t-1-l:l}function Xf(e,t){let n=t.record.geometry;if(n?.kind==="linkedmesh")return t.record.timelines===!0?`${n.skin}/${n.slot}/${n.source}`:null;return`${t.skin}/${e}/${t.placeholder}`}var RR=(e)=>`${e.skin}/${e.slot}/${e.attachment}`,Lk=new WeakMap;function Uk(e,t,n,s){let r=t(e,{...n,setup:s});if(r===null||"conflict"in r||r.record.geometry===void 0)return null;let i=r.record.geometry,o=i.kind==="linkedmesh"?e.skins.find((l)=>l.name===i.skin)?.attachments[i.slot]?.[i.source]:r.record,a=o?.geometry;return Object.freeze({entry:Object.freeze({slot:n.name,bone:n.bone,name:Ki(r).name,placeholder:r.placeholder,skin:r.skin,geometry:i}),identity:Xf(n.name,r),vertices:a!==void 0&&a.kind!=="region"&&a.kind!=="linkedmesh"?a.vertices:null,count:o?.sequenceCount,fillers:Object.freeze(Uf(e,n.name,r.placeholder).map((l)=>`"${l}"`))})}function Wk(e,t,n,s){if(s===null)return null;if(t!==vn)return Uk(e,t,n,s);let r=Lk.get(e);if(r===void 0)Lk.set(e,r=new Map);let i=r.get(n.name);if(i===void 0)r.set(n.name,i=new Map);if(i.has(s))return i.get(s);let o=Uk(e,t,n,s);return i.set(s,o),o}var Xk=new WeakMap,jk=new WeakMap;function PR(e,t){let n=Xk.get(e);if(n===void 0){let s=new Map;for(let r of e){let i=RR(r),o=s.get(i);if(o===void 0)s.set(i,[r]);else o.push(r)}Xk.set(e,n=s)}return n.get(t)}function $R(e,t){let n=jk.get(e);if(n===void 0){let s=new Map;for(let r of e)for(let i of r.timelines){if(i.kind!=="attachment"||i.keys===void 0)continue;let o=s.get(r.name);if(o===void 0)s.set(r.name,[i.keys]);else o.push(i.keys)}jk.set(e,n=s)}return n.get(t)}function Yk(e,t,n,s,r,i,o,a){if(e===null||e.identity===null)return t;let l=PR(n,e.identity);if(l===void 0)return t;if(t??={deform:null,frame:null,seen:[]},!t.seen.includes(e.identity))t.seen.push(e.identity);for(let u of l){if(u.deform!==null&&e.vertices!==null){let c=i(e.vertices,u.deform,s);if(c!==null)t.deform=r===null?c:o(e.vertices,t.deform,c,r.alpha,r.additive)}if(u.sequence!==null&&e.count!==void 0){let c=a(u.sequence,e.count,s);if(c!==null)t.frame=c}}return t}function m1(e,t,n,s,r,i={},o){let a=i.deform??Wf,l=i.deformBlend??AR,u=i.sequence??ER,c=[],h=[],d=At(e),f=i.slotTimelines??ec;for(let m of e.slots){let p=f(e,m,d),y=n.get(m.name)??null,g=p?o?.get(m.name):void 0,x=g===void 0||g.deform===null&&g.seen.length===0?null:{deform:g.deform,frame:null,seen:[...g.seen]},b=Wk(e,t,m,y);if(s!==null&&p)x=Yk(b,x,s.timelines.attachments,s.t,null,a,l,u);if(p)for(let _ of r){let S=$R(_.timelines.slots,m.name);if(S!==void 0)for(let M of S){let k=rt(M,_.at);if(k<0)continue;let T=M[k].name??null;if(T!==y){if(x!==null)x.deform=null,x.frame=null;y=T,b=Wk(e,t,m,y)}}x=Yk(b,x,_.timelines.attachments,_.at,_,a,l,u)}if(b===null)continue;let v=x===null||x.deform===null&&x.frame===null?b.entry:{...b.entry};if(c.push(v),x!==null&&x.seen.length>0&&b.fillers.length>1){h.push(`slot "${m.name}" shows placeholder "${b.entry.placeholder}", which skins ${b.fillers.join(", ")} fill, and ${x.seen.map((_)=>`"${_}"`).join(", ")} key(s) it — which record --skin all shows, and so whether the timeline moves it, is the Spine file's skin order, not the model's`);continue}if(x!==null){if(x.deform!==null)v.deform=x.deform;if(x.frame!==null)v.frame=x.frame}}return{shown:c,why:h}}var Vk=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function OR(e,t,n,s){let r=`${t}.drawOrder`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=new Map(n.map((l,u)=>[l.name,u])),o=[],a=-1/0;return e.forEach((l,u)=>{let c=`${r}[${u}]`;if(!Vk(l)){s.push(`${c} is not an object`);return}for(let f of Object.keys(l))if(f!=="time"&&f!=="offsets")s.push(`${c}: field "${f}" is not one a draw-order key carries; it carries [time, offsets]`);let h=l.time;if(typeof h!=="number"||!Number.isFinite(h)||h<0)s.push(`${c}: time is ${JSON.stringify(h)}, not a finite time at or after 0`);else if(h<=a)s.push(`${c}: time ${h} is not after the key before it — the writer refuses key times that do not strictly increase`);if(typeof h==="number"&&Number.isFinite(h))a=Math.max(a,h);let d=[];if(l.offsets!==void 0)if(!Array.isArray(l.offsets))s.push(`${c}: offsets is not a list`);else{let f=new Map;l.offsets.forEach((m,p)=>{let y=`${c}.offsets[${p}]`;if(!Vk(m)||typeof m.slot!=="string"){s.push(`${y} names no slot`);return}let g=i.get(m.slot);if(g===void 0){s.push(`${y}: "${m.slot}" is not a slot of this document`);return}if(typeof m.offset!=="number"||!Number.isInteger(m.offset)){s.push(`${y}: slot "${m.slot}" offset is ${JSON.stringify(m.offset)}, not a whole number`);return}if(d.some((b)=>b.slot===g))s.push(`${y}: slot "${m.slot}" is moved twice in one key`);let x=g+m.offset;if(x<0||x>=n.length)s.push(`${y}: slot "${m.slot}" is at ${g} and offset ${m.offset} lands at ${x}, outside the ${n.length} slots`);else if(f.has(x))s.push(`${y}: slot "${m.slot}" lands at ${x}, where slot "${f.get(x)}" lands too — two moves on one place leave a slot out of the runtime's order`);else f.set(x,m.slot);d.push({slot:g,offset:m.offset})})}o.push({time:Math.fround(typeof h==="number"&&Number.isFinite(h)?h:0),moves:d})}),o}function IR(e,t){let n=Array(e).fill(-1);for(let o of t)n[o.slot+o.offset]=o.slot;let s=new Set(t.map((o)=>o.slot)),r=Array.from({length:e},(o,a)=>a).filter((o)=>!s.has(o)),i=0;for(let o=0;otypeof e==="object"&&e!==null&&!Array.isArray(e),Hk=["name","int","float","string","audio","volume","balance"],zk=["time","name","int","float","string","volume","balance"];function y1(e,t,n){let s={};if(e.int!==void 0)if(typeof e.int!=="number"||!Number.isInteger(e.int))n.push(`${t}: int is ${JSON.stringify(e.int)}, not a whole number`);else s.int=e.int;if(e.float!==void 0)if(typeof e.float!=="number"||!Number.isFinite(e.float))n.push(`${t}: float is ${JSON.stringify(e.float)}, not a finite number`);else s.float=e.float;if(e.string!==void 0)if(typeof e.string!=="string")n.push(`${t}: string is ${JSON.stringify(e.string)}, not a string`);else s.string=e.string;for(let r of["volume","balance"])if(e[r]!==void 0)if(typeof e[r]!=="number"||!Number.isFinite(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])}, not a finite number`);else s[r]=e[r];return s}function BR(e,t){let n=new Map;if(!Array.isArray(e))return t.push("events is not a list"),n;return e.forEach((s,r)=>{let i=`events[${r}]`;if(!g1(s)||typeof s.name!=="string"||s.name===""){t.push(`${i} names no event`);return}for(let a of Object.keys(s))if(!Hk.includes(a))t.push(`${i} "${s.name}": field "${a}" is not one this reader knows; it reads [${Hk.join(", ")}]`);if(s.audio!==void 0&&typeof s.audio!=="string")t.push(`${i} "${s.name}": audio is ${JSON.stringify(s.audio)}, not a string`);if(n.has(s.name))t.push(`${i}: event "${s.name}" is declared twice`);let o=y1(s,`${i} "${s.name}"`,t);n.set(s.name,{audio:typeof s.audio==="string"?s.audio:"",volume:o.volume??0,balance:o.balance??0,name:s.name,int:o.int??0,float:o.float??0,string:o.string??""})}),n}function DR(e,t,n,s){let r=`${t}.events`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=[],o=-1/0;return e.forEach((a,l)=>{let u=`${r}[${l}]`;if(!g1(a)){s.push(`${u} is not an object`);return}for(let f of Object.keys(a))if(!zk.includes(f))s.push(`${u}: field "${f}" is not one an event key carries; it carries [${zk.join(", ")}]`);let c=a.time;if(typeof c!=="number"||!Number.isFinite(c)||c<0)s.push(`${u}: time is ${JSON.stringify(c)}, not a finite time at or after 0`);else if(c[o.name,s(o.time),o.int,s(o.float),o.string];if(r)return[...e.filter((o)=>o.time>t),...e.filter((o)=>o.time<=n)].map(i);return e.filter((o)=>o.time>t&&o.time<=n).map(i)}function x1(e){let t=0,n=e.length/2;for(let s=0;s0?n.reverse():n;return t.flippedWinding===!0?s.reverse():s}function FR(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(r*(e[1]-n[1])-i*(e[0]-n[0]))/(a*r-o*i);return[n[0]+l*o,n[1]+l*a]}function pf(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(o*(e[1]-n[1])-a*(e[0]-n[0]))/(a*r-o*i);return[e[0]+l*r,e[1]+l*i]}function b1(e,t,n){let s=n.fromClipEdge===!0?FR:pf,r=[...e],i=!1;for(let o=0;o0;o++){let a=t[o],l=t[(o+1)%t.length],u=(h)=>(l[0]-a[0])*(h[1]-a[1])-(l[1]-a[1])*(h[0]-a[0])<0,c=[];for(let h=0;h[t[2*P],t[2*P+1]]),p=f.map((P)=>[o(s[2*P]),o(s[2*P+1])]),{points:y,cut:g}=b1(m,i,r);for(let P=1;P+1r.uvByDivision===!0?P/T:P*A,R=a.length/2;if(!g&&r.insideRotated!==!0){m.forEach(([P,I],F)=>{a.push(o(P),o(I)),l.push(p[F][0],p[F][1])});for(let P=1;P+1S1(r,i,o,a,n)){let r=[],i=[],o=[],a=null;for(let c of e){if(c.kind==="clip"){if(a!==null&&a.end===c.slot)a=null;if(c.active&&a===null){let h=c.inverse?"it is inverse":ff(c.polygon);if(h!==null)i.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${h}`);let d={polygon:c.polygon,inverse:c.inverse,convex:c.convex},f=gf(d);if(f.kind==="refused")o.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${f.why}`);a={end:c.end,shape:d}}continue}if(c.kind==="draw"&&a!==null){let h=s(a.shape,c.vertices,c.triangles,c.uvs);if(h!==null)r.push([c.slot,c.attachment,h.clipped?1:0,h.vertices.map(t),h.uvs.map(t),h.triangles])}if(a!==null&&a.end===c.slot)a=null}let l=o.length===0?null:`${o.join("; ")} — the runtime's coverage of a polygon that is not simple is its own triangulation's, measured not to be the polygon's area (src/core/clipping.ts)`,u=l===null?r:null;if(i.length>0)return{rows:null,why:`${i.join("; ")} — the runtime decomposes such a polygon into convex pieces of its own choosing, or clips the outside of an inverse one, and neither was reproduced from the dump (src/core/clipping.ts)`,drawn:u,drawnWhy:l};return{rows:r,why:null,drawn:u,drawnWhy:l}}function GR(e){let t=[];for(let n=0;n+10&&i<0||r<0&&i>0)&&(o>0&&a<0||o<0&&a>0))return!0;let l=(u,c,h)=>Math.min(u[0],c[0])<=h[0]&&h[0]<=Math.max(u[0],c[0])&&Math.min(u[1],c[1])<=h[1]&&h[1]<=Math.max(u[1],c[1]);return r===0&&l(n,s,e)||i===0&&l(n,s,t)||o===0&&l(e,t,n)||a===0&&l(e,t,s)}function UR(e){let t=e.length;for(let n=0;n0)return`edges ${n} and ${(n+1)%t} fold back over each other at vertex ${(n+1)%t}`;for(let o=n+2;o3;){n=!1;for(let s=0;ss[0]-r[0]||s[1]-r[1]),n=(s)=>{let r=[];for(let i of s){while(r.length>=2&&Tt(r[r.length-2],r[r.length-1],i)<=0)r.pop();r.push(i)}return r.pop(),r};return[...n(t),...n([...t].reverse())]}function XR(e){let t=e.flat();return x1(t)<0?[...e].reverse():[...e]}function jR(e){let t=e.length,n=e.map((a,l)=>l),s=[],r=(a,l,u,c)=>Tt(l,u,a)>=0&&Tt(u,c,a)>=0&&Tt(c,l,a)>=0;while(n.length>3){let a=!1;for(let l=0;ld!==u&&d!==c&&d!==h&&r(e[d],e[u],e[c],e[h])))continue;s.push([u,c,h]),n.splice(l,1),a=!0;break}if(!a)throw Error(`convexPieces: no ear left among vertices [${n.join(", ")}] of a polygon the caller held simple — a defect in src/core/clipping.ts`)}s.push([...n]);let i=s.map((a)=>[...a]),o=(a)=>a.every((l,u)=>Tt(e[a[(u+a.length-1)%a.length]],e[l],e[a[(u+1)%a.length]])>0);for(let a=!0;a;){a=!1;e:for(let l=0;la.map((l)=>e[l]))}function gf(e){let t=GR(e.polygon);if(t.length<3)return{kind:"refused",why:`it has ${t.length} vertex(es)`};let n=[];for(let o=0;o0){let o=t.filter((a,l)=>{let u=t[(l+1)%t.length];return a[0]!==u[0]||a[1]!==u[1]});if(!e.inverse&&o.length===t.length-n.length&&o.length>=3&&ff(o.flat())===null)return{kind:"convex",polygon:e.polygon};return{kind:"refused",why:`vertices ${n.join(", ")} are the same point`}}let s=UR(t);if(s!==null)return{kind:"refused",why:s};let r=WR(t);if(Tt(r[0],r[1],r[2])===0&&r.length===3)return{kind:"refused",why:"every vertex lies on one line"};if(e.inverse)return{kind:"inverse",hull:qk(r)};if(ff(e.polygon)===null)return{kind:"convex",polygon:e.polygon};if(e.convex)return{kind:"convex",polygon:qk(r).flat()};let i=jR(XR(r));return i.length===1?{kind:"convex",polygon:i[0].flat()}:{kind:"pieces",pieces:i}}function Kk(e,t,n){let s=(o)=>(n[0]-t[0])*(o[1]-t[1])-(n[1]-t[1])*(o[0]-t[0])<0,r=[],i=!1;for(let o=0;omf(p.flat(),{})):null,m=o.kind==="inverse"?mf(o.hull.flat(),{}):[];for(let p=0;p+2[t[2*R],t[2*R+1]]),x=y.map((R)=>[a(s[2*R]),a(s[2*R+1])]),b=[];if(f!==null)for(let R of f)b.push(b1(g,R,{}));else{let R=[...g],P=!1;for(let I=0;I0;I++){let F=m[I],B=m[(I+1)%m.length],C=Kk(R,B,F);b.push({points:C.cut||P?C.points:[...g],cut:C.cut||P});let D=Kk(R,F,B);P||=D.cut,R=D.points}d=!0}let[v,_,S]=g,M=_[1]-S[1],k=S[0]-_[0],T=v[0]-S[0],A=S[1]-v[1],O=1/(M*T+k*(v[1]-S[1]));for(let[R,{points:P,cut:I}]of b.entries()){if(d||=I,R===i.dropRegion)continue;if(P.length<3)continue;let F=l.length/2;if(!I)g.forEach(([B,C],D)=>{l.push(a(B),a(C)),u.push(x[D][0],x[D][1])});else for(let[B,C]of P){let D=(M*(B-S[0])+k*(C-S[1]))*O,N=(A*(B-S[0])+T*(C-S[1]))*O,G=1-D-N;l.push(a(B),a(C)),u.push(a(x[0][0]*D+x[1][0]*N+x[2][0]*G),a(x[0][1]*D+x[1][1]*N+x[2][1]*G))}for(let B=1;B+1e;function HR(e,t){let{width:n,height:s}=e,r=e.scaleX??1,i=e.scaleY??1,o=e.atlas,a=n/o.originalWidth*r,l=s/o.originalHeight*i,u=-n/2*r+o.offsetX*a,c=-s/2*i+o.offsetY*l,h=u+o.width*a,d=c+o.height*l,f=(e.rotation??0)*YR,m=Math.cos(f),p=Math.sin(f),y=e.x??0,g=e.y??0,x=[];for(let[b,v]of[[u,c],[u,d],[h,d],[h,c]]){let _=b*m+y-v*p,S=v*m+g+b*p;x.push(t.a*_+t.b*S+t.worldX,t.c*_+t.d*S+t.worldY)}return x}var yf=new WeakMap;function w1(e,t){let n=[],s=new Map;for(let i of e.bindings)for(let o of i)if(!s.has(o.bone))s.set(o.bone,n.length),n.push(o.bone);n.length;let r=e.bindings.map((i)=>i.map((o)=>({bone:s.get(o.bone),x:o.x,y:o.y,fx:Math.fround(o.x),fy:Math.fround(o.y),weight:Math.fround(o.weight)})));return{bones:n,bindings:r}}function M1(e){let t=yf.get(e);if(t===void 0)t=w1(e),yf.set(e,t);return t}function T1(e,t){let n=Array(e.length);for(let s=0;stypeof e==="object"&&e!==null&&!Array.isArray(e),Ss=(e)=>typeof e==="number"&&Number.isFinite(e),qd=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function JR(e,t,n){if(!Ui(e)){n.push(`${t} is ${JSON.stringify(e)}, not an atlas rectangle`);return}let s=n.length;for(let r of Object.keys(e))if(!qd.includes(r))n.push(`${t}: field "${r}" is not one this reader knows; it reads [${qd.join(", ")}]`);for(let r of qd)if(!Ss(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])??"absent"}, not a finite number`);return n.length===s?e:void 0}function ZR(e,t,n,s){if(!Ui(e)||typeof e.weighted!=="boolean"){s.push(`${t} is not { weighted: false, xy } or { weighted: true, bindings }`);return}let r=s.length;if(!e.weighted){let a=e.xy;if(!Array.isArray(a)||a.length%2!==0||!a.every(Ss))s.push(`${t}.xy is not an even-length list of finite numbers`);return s.length===r?{weighted:!1,xy:a}:void 0}let i=e.bindings;if(!Array.isArray(i)){s.push(`${t}.bindings is not a list`);return}if(i.forEach((a,l)=>{if(!Array.isArray(a)||a.length===0){s.push(`${t}.bindings[${l}] is not a non-empty list of bindings`);return}a.forEach((u,c)=>{let h=`${t}.bindings[${l}][${c}]`;if(!Ui(u)){s.push(`${h} is not an object`);return}if(typeof u.bone!=="string"||!n.has(u.bone))s.push(`${h}: bone ${JSON.stringify(u.bone)} is not a bone of this document`);for(let d of["x","y","weight"])if(!Ss(u[d]))s.push(`${h}: ${d} is ${JSON.stringify(u[d])??"absent"}, not a finite number`)})}),s.length!==r)return;let o={weighted:!0,bindings:i};return yf.set(o,w1(o)),o}function QR(e,t,n,s,r,i){let o=i.length;switch(t){case"region":{for(let d of["x","y","rotation","scaleX","scaleY"])if(e[d]!==void 0&&!Ss(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])}, not a finite number`);for(let d of["width","height"])if(!Ss(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])??"absent"}, not a finite number`);let a=e.atlas!==void 0,l=e.sequence!==void 0,u,c;if(a===l)i.push(`${n}: the region carries ${a?"both an atlas rectangle and a sequence":"neither an atlas rectangle nor a sequence"}; the writer states exactly one of the two, and a sequence holds a rectangle per frame (issue #935)`);else if(a)u=e.atlas===null?null:Ui(e.atlas)?e.atlas:void 0;else{let d=e.sequence;if(!Ui(d))i.push(`${n}.sequence is not an object`);else{let f=d.count,m=d.setup??0;if(typeof f!=="number"||!Number.isInteger(f)||f<1)i.push(`${n}.sequence: count is ${JSON.stringify(f)}, not a whole number of at least 1`);else if(typeof m!=="number"||!Number.isInteger(m)||m<0||m>=f)i.push(`${n}.sequence: setup is ${JSON.stringify(d.setup)}, not a frame of the ${f}`);if(!Array.isArray(d.atlas)||d.atlas.length!==f)i.push(`${n}.sequence: atlas is not a list of ${JSON.stringify(f)} rectangle(s), one per frame`);else{let p=d.atlas.map((y,g)=>JR(y,`${n}.sequence.atlas[${g}]`,i));if(typeof m==="number"&&Number.isInteger(m)&&m>=0&&my!==void 0))c=p}}}if(i.length!==o||u===void 0)return;let h=(d)=>e[d]===void 0?{}:{[d]:e[d]};return{kind:"region",region:{...h("x"),...h("y"),...h("rotation"),...h("scaleX"),...h("scaleY"),width:e.width,height:e.height,atlas:u,...c===void 0?{}:{frames:c}}}}case"linkedmesh":{for(let a of["skin","slot","source"])if(typeof e[a]!=="string"||e[a]==="")i.push(`${n}: ${a} is ${JSON.stringify(e[a])??"absent"}, not a non-empty string`);if(typeof e.slot==="string"&&!r.has(e.slot))i.push(`${n}: slot "${e.slot}" is not a slot of this document`);if(i.length!==o)return;return{kind:"linkedmesh",skin:e.skin,slot:e.slot,source:e.source}}case"mesh":case"clipping":case"boundingbox":case"path":{let a=ZR(e.vertices,`${n}.vertices`,s,i);if(t==="clipping"&&e.end!==void 0&&(typeof e.end!=="string"||!r.has(e.end)))i.push(`${n}: end is ${JSON.stringify(e.end)}, not a slot of this document`);if(t==="clipping"){for(let u of["inverse","convex"])if(e[u]!==void 0&&typeof e[u]!=="boolean")i.push(`${n}: ${u} is ${JSON.stringify(e[u])}, not a boolean`)}let l=t==="mesh"&&a!==void 0?eP(e,a,n,i):void 0;if(a===void 0||i.length!==o)return;if(t==="mesh")return l===void 0?void 0:{kind:t,vertices:a,...l};if(t==="clipping")return{kind:t,end:typeof e.end==="string"?e.end:null,vertices:a,inverse:e.inverse===!0,convex:e.convex===!0};if(t==="boundingbox")return{kind:t,vertices:a};return tP(e,a,n,i)}}}function eP(e,t,n,s){let r=s.length,i=t.weighted?t.bindings.length:t.xy.length/2,{uvs:o,triangles:a}=e;if(!Array.isArray(o)||!o.every(Ss)||o.length!==2*i)s.push(`${n}.uvs is not ${2*i} finite numbers, one pair per vertex`);if(!Array.isArray(a)||a.length%3!==0||!a.every((u)=>Number.isInteger(u)&&u>=0&&u=0&&l<=i))s.push(`${n}.hull is ${JSON.stringify(l)}, not a whole number of vertices from 0 to ${i}`);return s.length===r?{uvs:o,triangles:a,...l===void 0?{}:{hull:l}}:void 0}function tP(e,t,n,s){let r=s.length;for(let a of["closed","constantSpeed"])if(e[a]!==void 0&&typeof e[a]!=="boolean")s.push(`${n}: ${a} is ${JSON.stringify(e[a])}, not a boolean`);let i=t.weighted?t.bindings.length:t.xy.length/2;if(e.vertexCount!==i)s.push(`${n}: vertexCount is ${JSON.stringify(e.vertexCount)??"absent"}, and the vertices hold ${i} point(s)`);else if(i%3!==0||i<(e.closed===!0?3:6))s.push(`${n}: vertexCount is ${i}, not a multiple of 3 of at least ${e.closed===!0?3:6} — the curve walk reads knots and handles in threes`);let o=e.lengths;if(!Array.isArray(o)||!o.every(Ss))s.push(`${n}: lengths is not a list of finite numbers`);else if(o.length!==i/3)s.push(`${n}: lengths has ${o.length} entry(ies) where the vertices make ${i/3}`);if(s.length!==r)return;return{kind:"path",vertices:t,closed:e.closed===!0,constantSpeed:e.constantSpeed!==!1,lengths:o}}function Ml(e,t){for(let n=0;nb.geometry.kind==="clipping"),f=new Map;for(let b of e){let v=t.get(b.bone);if(v===void 0)throw Error(`slot "${b.slot}": bone "${b.bone}" has no world transform`);let{geometry:_,deform:S}=b,M=(k)=>S===void 0?a(k,v,t):r.vertices===void 0||r.deformedVertices!==void 0?l(k,S,v,t):a(f1(k,S),v,t,k1);if(_.kind==="region"){let k=b.frame===void 0?_.region.atlas:_.region.frames?.[b.frame]??_.region.atlas;if(k===null){h.push(`slot "${b.slot}" shows region "${b.name}" (skin "${b.skin}", placeholder "${b.placeholder}")`);continue}let T=o(k===_.region.atlas?_.region:{..._.region,atlas:k},v);if(u.push([b.slot,b.name,"region",Ml(T,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:Yf,uvs:_1})}else if(_.kind==="mesh"){let k=M(_.vertices);if(u.push([b.slot,b.name,"mesh",Ml(k,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:k,triangles:_.triangles,uvs:_.uvs})}else if(_.kind==="linkedmesh"){let k=n(_.skin,_.slot,_.source);if(typeof k==="string")throw Error(`slot "${b.slot}": ${k} (readModel refuses it first)`);let T=M(k);u.push([b.slot,b.name,"mesh",Ml(T,s)]);let A=i?.meshOf(_.skin,_.slot,_.source);if(i!==void 0&&A===void 0)throw Error(`slot "${b.slot}": the linked mesh's source "${_.source}" carries no triangles (readModel refuses it first)`);if(d&&A!==void 0)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:A.triangles,uvs:A.uvs})}else if(_.kind==="clipping"){let k=M(_.vertices);c.push([b.slot,b.name,_.end,Ml(k,s)]),f.set(b.slot,{slot:b.slot,kind:"clip",attachment:b.name,active:i?.active.has(b.bone)??!1,end:_.end,polygon:k,inverse:_.inverse,convex:_.convex})}}let m=h.length===0?null:`${h.join("; ")} — the model states the build had no atlas rectangle for it (atlas: null), and its corners read the trim and original size; a trim of 0 is not assumed`,p=null,y=i===void 0?"the draw order was not given":m,g=null,x=y;if(i!==void 0&&m===null&&!d)p=[],y=null,g=[],x=null;else if(i!==void 0&&m===null){let b=i.order.map((_)=>f.get(_)??{slot:_,kind:"none"}),v=NR(b,s,i.clip,i.through);p=v.rows,y=v.why,g=v.drawn,x=v.drawnWhy}return{attachments:m===null?u:null,attachmentsWhy:m,clips:c,clipped:p,clippedWhy:y,drawnClipped:g,drawnClippedWhy:x}}var Zk=_e/180;function nP(e,t){let n=[],s=0,r=e[0],i=e[1];for(let o=0,a=2;otypeof e==="object"&&e!==null&&!Array.isArray(e);function Jd(e,t,n,s,r,i){let o=e[t];if(o===void 0)return s;let a=typeof o==="string"&&o.length>0?o[0].toLowerCase()+o.slice(1):"",l=n.find((u)=>u===a);if(l===void 0)return i.push(`${r}: ${t} is ${JSON.stringify(o)}, none of ${n.join(", ")} (first letter in either case)`),s;return l}function Wn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function oP(e,t,n,s,r,i){let o=i.length;for(let d of Object.keys(e)){if(d==="kind"||d==="name"||d==="declaredIn")continue;if(!Qk.includes(d))i.push(`${n}: field "${d}" is not one this reader knows; it reads [${Qk.join(", ")}]`)}let a=[];if(!Array.isArray(e.bones)||e.bones.length===0)i.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`);else e.bones.forEach((d,f)=>typeof d==="string"&&s.has(d)?a.push(d):i.push(`${n}: bones[${f}] ${JSON.stringify(d)} is not a bone of this document`));let l=typeof e.slot==="string"?e.slot:"",u=r.get(l);if(u===void 0)i.push(`${n}: slot is ${JSON.stringify(e.slot)}, not a slot of this document`);if(e.skin!==void 0&&typeof e.skin!=="boolean")i.push(`${n}: skin is ${JSON.stringify(e.skin)}, not a boolean`);let c=Wn(e,"mixX",1,n,i),h={kind:"path",name:t,bones:a,slot:l,slotBone:u??"",positionMode:Jd(e,"positionMode",sP,"percent",n,i),spacingMode:Jd(e,"spacingMode",rP,"length",n,i),rotateMode:Jd(e,"rotateMode",iP,"tangent",n,i),offsetRotation:Wn(e,"rotation",0,n,i),position:Wn(e,"position",0,n,i),spacing:Wn(e,"spacing",0,n,i),mixRotate:Wn(e,"mixRotate",1,n,i),mixX:c,mixY:Wn(e,"mixY",c,n,i),skin:e.skin===!0,listedBySkin:!1,path:null,unresolved:null,slotDeps:[]};return i.length===o?h:void 0}var Zd={position:["value"],spacing:["value"],mix:["mixRotate","mixX","mixY"]};function aP(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function lP(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.path[${o}]`;if(!Tl(i)||typeof i.name!=="string"){s.push(`${a} names no constraint`);return}if(!n.has(i.name))s.push(`${a}: "${i.name}" is not a path constraint of this document`);let l={name:i.name};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!Tl(u)||typeof u.name!=="string"||!(u.name in Zd)){s.push(`${h}: ${Tl(u)?JSON.stringify(u.name):"it"} is not a path timeline; they are ${Object.keys(Zd).join(", ")}`);return}let d=u.name;if(l[d]!==void 0)s.push(`${h}: "${d}" is keyed twice on path constraint "${i.name}"`);let f=Zd[d],m=u.keys;if(!Array.isArray(m)||m.length===0){s.push(`${h}: keys is not a non-empty list`);return}let p=-1/0,y=[];m.forEach((g,x)=>{let b=`${h}.keys[${x}]`;if(!Tl(g)){s.push(`${b} is not an object`);return}for(let S of Object.keys(g))if(S!=="time"&&S!=="curve"&&!f.includes(S))s.push(`${b}: field "${S}" is not one this reader knows; it reads [time, ${f.join(", ")}, curve]`);let v=g.time;if(typeof v!=="number"||!Number.isFinite(v)||v<0){s.push(`${b}: time is ${JSON.stringify(v)}, not a finite time at or after 0`);return}if(v<=p)s.push(`${b}: time ${v} is not after the key before it — the writer refuses key times that do not strictly increase`);p=Math.max(p,v);let _=f.map((S)=>{if(S==="mixY"&&g.mixY===void 0)return Wn(g,"mixX",1,b,s);return Wn(g,S,d==="mix"?1:0,b,s)});y.push({time:Math.fround(v),values:_.map(Math.fround),stated:{time:v,values:_},curve:aP(g,f.length,x===m.length-1,b,s)})}),l[d]=y}),r.push(l)}),r}function cP(e,t,n){return C1(n.vertices,e.world.get(t.slotBone),e.world,n.exact===!0?k1:Math.fround)}function ew(e,t,n,s,r,i,o){let a=Math.atan2(r-n,s-t);i[o]=t+e*Math.cos(a),i[o+1]=n+e*Math.sin(a),i[o+2]=a}function tw(e,t,n,s,r,i,o){let a=Math.atan2(r-n,s-t);i[o]=s+e*Math.cos(a),i[o+1]=r+e*Math.sin(a),i[o+2]=a}function nw(e,t,n,s,r,i,o,a,l,u,c,h){if(Number.isNaN(e)){u[c]=t,u[c+1]=n,u[c+2]=Math.atan2(r-n,s-t);return}let d=e*e,f=d*e,m=1-e,p=m*m,y=p*m,g=m*e,x=g*3,b=m*x,v=x*e,_=t*y+s*b+i*v+a*f,S=n*y+r*b+o*v+l*f;if(u[c]=_,u[c+1]=S,h)if(e<0.001)u[c+2]=Math.atan2(r-n,s-t);else u[c+2]=Math.atan2(S-(n*p+r*g*2+o*d),_-(t*p+s*g*2+i*d))}function uP(e,t,n,s,r){let i=s.length,o=cP(e,t,n),a=o.length/2,l=(R)=>[o[2*R],o[2*R+1]],u=Array(i*3+2).fill(0),c=n.closed,h=t.position;if(!n.constantSpeed){let R=n.lengths,P=a/3-(c?1:2),I=R[P];if(t.positionMode==="percent")h*=I;let F=t.spacingMode==="percent"?I:t.spacingMode==="proportional"?I/i:1,B=0;for(let C=0,D=0;CI){let[ue,re]=l(a-3),[ge,xe]=l(a-2);tw(G-I,ue,re,ge,xe,u,D);continue}for(;;B++){let ue=R[B];if(G>ue)continue;if(B===0)G/=ue;else{let re=R[B-1];G=(G-re)/(ue-re)}break}let z=3*B+1,q=(ue)=>l((z+ue)%a),[L,K]=q(0),[J,H]=q(1),[pe,Ie]=q(2),[Le,Me]=q(3);nw(G,L,K,J,H,pe,Ie,Le,Me,u,D,r||C>0&&N===0)}return u}let d=[];if(c){for(let R=1;R0?m[m.length-1]:0;if(t.positionMode==="percent")h*=p;let y=t.spacingMode==="percent"?p:t.spacingMode==="proportional"?p/i:1,g=[,,,,,,,,,,].fill(0),x=0,b=-1,v=0,_=0,S=0,M=0,k=0,T=0,A=0,O=0;for(let R=0,P=0,I=0,F=0;Rp){let D=d.length;tw(C-p,d[D-4],d[D-3],d[D-2],d[D-1],u,P);continue}for(;;I++){let D=m[I];if(C>D)continue;if(I===0)C/=D;else{let N=m[I-1];C=(C-N)/(D-N)}break}if(I!==b){b=I;let D=I*6;v=d[D],_=d[D+1],S=d[D+2],M=d[D+3],k=d[D+4],T=d[D+5],A=d[D+6],O=d[D+7];let N=(v-S*2+k)*0.03,G=(_-M*2+T)*0.03,z=((S-k)*3-v+A)*0.006,q=((M-T)*3-_+O)*0.006,L=N*2+z,K=G*2+q,J=(S-v)*0.3+N+z*0.16666667,H=(M-_)*0.3+G+q*0.16666667;x=Math.sqrt(J*J+H*H),g[0]=x;for(let pe=1;pe<8;pe++)J+=L,H+=K,L+=z,K+=q,x+=Math.sqrt(J*J+H*H),g[pe]=x;J+=L,H+=K,x+=Math.sqrt(J*J+H*H),g[8]=x,J+=L+z,H+=K+q,x+=Math.sqrt(J*J+H*H),g[9]=x,F=0}C*=x;for(;;F++){let D=g[F];if(C>D)continue;if(F===0)C/=D;else{let N=g[F-1];C=F+(C-N)/(D-N)}break}nw(C*0.1,v,_,S,M,k,T,A,O,u,P,r||R>0&&B===0)}return u}function hP(e,t,n){let s=t.path,r={changed:[],inWorld:[]};if(s===null)return r;let{mixRotate:i,mixX:o,mixY:a}=t;if(i===0&&o===0&&a===0)return r;let l=t.rotateMode==="tangent",u=t.rotateMode==="chainScale",c=t.bones.map((M)=>e.bones[e.index.get(M)]),h=c.length,d=l?h:h+1,f=Array(d).fill(0),m=u?Array(h).fill(0):[],p=t.spacing,y=(M)=>e.world.get(M.name);if(t.spacingMode==="percent"){if(u)for(let M=0;M0){M=d/M*p;for(let k=1;k0?Zk:-Zk}let S=[];for(let M=0,k=3;M=Kd){let B=(Math.sqrt(P*P+I*I)/F-1)*i+1;A.a*=B,A.c*=B}}if(x=O,b=R,i>0){let{a:F,b:B,c:C,d:D}=A,N;if(l)N=g[k-1];else if(f[M+1]===0)N=g[k+2];else N=Math.atan2(I,P);if(N-=Math.atan2(C,F),_){let q=Math.cos(N),L=Math.sin(N),K=T.length??0;x+=(K*(q*F-L*C)-P)*i,b+=(K*(L*F+q*C)-I)*i}else N+=v;if(N>_e)N-=_e*2;else if(N<-_e)N+=_e*2;N*=i;let G=Math.cos(N),z=Math.sin(N);A.a=G*F-z*C,A.b=G*B-z*D,A.c=z*F+G*C,A.d=z*B+G*D}e.world.set(T.name,A),S.push(T.name)}return{changed:S,inWorld:[...S]}}function E1(e,t,n,s){let r=new Map(e.map((h)=>[h.name,h.parent])),i=new Map;for(let h of e)if(h.parent!==void 0)i.set(h.parent,[...i.get(h.parent)??[],h.name]);let o=new Map(e.map((h)=>[h.name,!t.has(h.name)])),a=new Map,l=(h,d)=>{if(o.get(h))return;let f=r.get(h);if(f!==void 0)l(f,d);o.set(h,!0),a.set(h,{at:d,when:"before"})},u=(h)=>{for(let d of h){if(!t.has(d))continue;if(o.get(d))u(i.get(d)??[]);o.set(d,!1)}},c=new Map;return n.forEach((h,d)=>{if(s.has(d))return;let f;if(h.kind==="slider"){u(h.timelines.bones.map((m)=>m.name));return}if(h.kind==="ik"){if(f=h.bones,l(h.target,d),l(h.bones[0],d),h.bones.length>1)l(h.bones[h.bones.length-1],d);if(u(i.get(h.bones[0])??[]),h.bones.length>1)o.set(h.bones[h.bones.length-1],!0)}else{if(f=h.kind==="physics"?[h.bone]:h.bones,h.kind==="transform")l(h.source,d);else if(h.kind==="path")for(let m of h.slotDeps)l(m,d);for(let m of f)l(m,d);if(h.kind==="path")c.set(d,a.get(h.slotBone)??null);for(let m of f)u(i.get(m)??[]);for(let m of f)o.set(m,!0)}for(let m of f)a.set(m,{at:d,when:"after"})}),c}var dP=_e/180,sw=["bone","scaleY","x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix","inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],fP=["x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix"],mP=["inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],rw=["none","uniform","volume"],R1=["inertia","strength","damping","mass","wind","gravity","mix"],iw=[...R1,"reset"],Wi="*",pP={x:0,y:0,rotate:0,scaleX:0,shearX:0,limit:5000,fps:60,inertia:0.5,strength:100,damping:0.85,mass:1,wind:0,gravity:0,mix:1};function gP(e,t,n,s,r,i){let o=i.length;for(let c of Object.keys(e)){if(c==="kind"||c==="name"||c==="declaredIn")continue;if(!sw.includes(c))i.push(`${n}: field "${c}" is not one this reader knows; it reads [${sw.join(", ")}]`)}if(typeof e.bone!=="string"||!s.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);for(let c of fP){let h=e[c];if(h!==void 0&&(typeof h!=="number"||!Number.isFinite(h)))i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a finite number`)}for(let c of mP){let h=e[c];if(h!==void 0&&typeof h!=="boolean")i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a boolean`)}let a="None";if(e.scaleY!==void 0){let c=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"";if(!rw.includes(c))i.push(`${n}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${rw.join(", ")}`);else a=c==="uniform"?"Uniform":c==="volume"?"Volume":"None"}if(i.length!==o)return;let l=(c)=>typeof e[c]==="number"?e[c]:pP[c],u={};for(let c of R1)u[c]=e[`${c}Global`]===!0;return{kind:"physics",name:t,bone:e.bone,skin:e.skin===!0,listedBySkin:!1,x:l("x"),y:l("y"),rotate:l("rotate"),scaleX:l("scaleX"),shearX:l("shearX"),limit:l("limit"),step:1/l("fps"),referenceScale:r,inertia:l("inertia"),strength:l("strength"),damping:l("damping"),massInverse:1/l("mass"),wind:l("wind"),gravity:l("gravity"),mix:l("mix"),global:u,scaleYMode:a}}function xf(e,t){return(!e.skin||e.listedBySkin)&&t.has(e.bone)}var Ai=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function yP(e){if(!Array.isArray(e))return 0;let t=0;for(let n of e)if(typeof n==="object"&&n!==null&&Array.isArray(n.timelines))t+=n.timelines.length;return t}function xP(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.physics[${o}]`;if(!Ai(i)||typeof i.name!=="string"){s.push(`${a} names no physics constraint`);return}let l=i.name;if(l!==Wi&&!n.has(l))s.push(`${a}: "${l}" is not a physics constraint of this document (nor "${Wi}", the timeline naming none)`);if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}let u=new Set;i.timelines.forEach((c,h)=>{let d=`${a}.timelines[${h}]`,f=Ai(c)?iw.find((g)=>g===c.name):void 0;if(!Ai(c)||f===void 0){s.push(`${d}: ${JSON.stringify(Ai(c)?c.name:c)} is not a physics timeline; one keys ${iw.join(", ")}`);return}if(u.has(f))s.push(`${d}: "${f}" is keyed twice on "${l}"`);u.add(f);let m=[],p=c.keys;if(!Array.isArray(p)||p.length===0){s.push(`${d} "${f}": keys is not a non-empty list`);return}let y=-1/0;p.forEach((g,x)=>{let b=`${d} "${f}".keys[${x}]`;if(!Ai(g)){s.push(`${b} is not an object`);return}let v=f==="reset"?["time"]:["time","value","curve"];for(let k of Object.keys(g))if(!v.includes(k))s.push(`${b}: field "${k}" is not one this reader knows; it reads [${v.join(", ")}]`);let _=g.time;if(typeof _!=="number"||!Number.isFinite(_)||_<0){s.push(`${b}: time is ${JSON.stringify(_)}, not a finite time at or after 0`);return}if(_<=y)s.push(`${b}: time ${_} is not after the key before it — the writer refuses key times that do not strictly increase`);if(y=Math.max(y,_),f==="reset"){m.push({time:Math.fround(_),values:[],stated:{time:_,values:[]},curve:"stepped"});return}let S=f==="mix"?1:0;if(g.value!==void 0)if(typeof g.value!=="number"||!Number.isFinite(g.value))s.push(`${b}: value is ${JSON.stringify(g.value)}, not a finite number`);else S=g.value;let M="linear";if(g.curve!==void 0)if(x===p.length-1)s.push(`${b}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(g.curve==="stepped")M="stepped";else if(Array.isArray(g.curve)&&g.curve.length===4&&g.curve.every((k)=>typeof k==="number"&&Number.isFinite(k)))M=g.curve;else s.push(`${b}: curve is ${JSON.stringify(g.curve)}, not "stepped" nor four finite numbers`);m.push({time:Math.fround(_),values:[Math.fround(S)],stated:{time:_,values:[S]},curve:M})}),r.push({name:l,kind:f,keys:m})})}),r}function Vf(e,t,n){return e.filter((s)=>n(s)&&(t==="reset"||s.global[t]))}function bP(e,t,n,s,r,i={},o=!1){let a=i.search??rt,l=i.channel??ws,u=new Map(e.map((d)=>[d.name,d])),c=new Map(e.map((d)=>[d.name,{...d}])),h=new Set;for(let d of t){let f=d.name===Wi?Vf([...c.values()],d.kind,r):[c.get(d.name)].filter((p)=>r(p));if(d.kind==="reset"){if(vP(d.keys,s,n,o))for(let p of f)h.add(p.name);continue}let m=a(d.keys,n);for(let p of f){let y=u.get(p.name);if(d.kind==="mass"){let g=1/y.massInverse;p.massInverse=m<0?y.massInverse:1/(g+(l(d.keys,m,0,n)-g))}else p[d.kind]=m<0?y[d.kind]:y[d.kind]+(l(d.keys,m,0,n)-y[d.kind])}}return{records:c,reset:h}}function vP(e,t,n,s=!1){return s?e.some((r)=>r.time>t||r.time<=n):e.some((r)=>t0,y:e.y>0,rotateOrShearX:e.rotate>0||e.shearX>0,scaleX:e.scaleX>0}}function TP(e,t,n,s){let r=e.mix;if(r===0)return!1;let i=qf(s,e.name),{x:o,y:a,rotateOrShearX:l,scaleX:u}=MP(e),c=n;if(s.phase==="reset")Hf(i,s.time);let h=Math.max(s.time-i.lastTime,0),d=Math.max(0,1-i.remaining/e.step);i.remaining+=h,i.lastTime=s.time;let{worldX:f,worldY:m}=t,p=s.env??zf,y=0;if(i.pending)i.pending=!1,i.ux=f,i.uy=m;else{let g=i.remaining,{inertia:x,step:b,referenceScale:v}=e,_=-1,S=e.limit*h,M=S;if(o||a){if(o){let k=(i.ux-f)*x;i.xOffset+=k>S?S:k<-S?-S:k,i.ux=f}if(a){let k=(i.uy-m)*x;i.yOffset+=k>M?M:k<-M?-M:k,i.uy=m}if(g>=b){_=Math.pow(e.damping,60*b);let k=e.massInverse*b,T=e.strength,A=e.wind*v,O=e.gravity*v,R=A*p.wind[0]+O*p.gravity[0],P=A*p.wind[1]+O*p.gravity[1],{xOffset:I,yOffset:F}=i;do{if(o)i.xVelocity+=(R-i.xOffset*T)*k,i.xOffset+=i.xVelocity*b,i.xVelocity*=_;if(a)i.yVelocity-=(P+i.yOffset*T)*k,i.yOffset+=i.yVelocity*b,i.yVelocity*=_;g-=b}while(g>=b);i.xLag=i.xOffset-I,i.yLag=i.yOffset-F}if(y=Math.max(0,1-g/b),o)t.worldX+=(i.xOffset-i.xLag*y)*r*e.x;if(a)t.worldY+=(i.yOffset-i.yLag*y)*r*e.y}if(l||u){let k=Math.atan2(t.c,t.a),T=0,A=0,O=0,R=i.cx-t.worldX,P=i.cy-t.worldY;if(R>S)R=S;else if(R<-S)R=-S;if(P>M)P=M;else if(P<-M)P=-M;if(l){O=(e.rotate+e.shearX)*r;let I=i.rotateLag*d,F=Math.atan2(P+i.ty,R+i.tx)-k-(i.rotateOffset-I)*O;if(i.rotateOffset+=(F-Math.ceil(F*wP-0.5)*P1)*x,F=(i.rotateOffset-I)*O+k,T=Math.cos(F),A=Math.sin(F),u){if(F=c*Math.sqrt(t.a*t.a+t.c*t.c),F>0)i.scaleOffset+=(R*T+P*A)*x/F}}else{T=Math.cos(k),A=Math.sin(k);let I=c*Math.sqrt(t.a*t.a+t.c*t.c)-i.scaleLag*d;if(I>0)i.scaleOffset+=(R*T+P*A)*x/I}if(g=i.remaining,g>=b){if(_===-1)_=Math.pow(e.damping,60*b);let I=e.massInverse*b,F=e.strength,B=e.wind*p.wind[0]+e.gravity*p.gravity[0],C=e.wind*p.wind[1]+e.gravity*p.gravity[1],D=c/v,{rotateOffset:N,scaleOffset:G}=i;for(;;){if(g-=b,u)i.scaleVelocity+=(B*T-C*A-i.scaleOffset*F)*I,i.scaleOffset+=i.scaleVelocity*b,i.scaleVelocity*=_;if(l){if(i.rotateVelocity-=((B*A+C*T)*D+i.rotateOffset*F)*I,i.rotateOffset+=i.rotateVelocity*b,i.rotateVelocity*=_,g0){let _=0;if(e.rotate>0)_=g*e.rotate,x=Math.sin(_),b=Math.cos(_),v=t.b,t.b=b*v-x*t.d,t.d=x*v+b*t.d;_+=g*e.shearX,x=Math.sin(_),b=Math.cos(_),v=t.a,t.a=b*v-x*t.c,t.c=x*v+b*t.c}else g*=e.rotate,x=Math.sin(g),b=Math.cos(g),v=t.a,t.a=b*v-x*t.c,t.c=x*v+b*t.c,v=t.b,t.b=b*v-x*t.d,t.d=x*v+b*t.d}if(u){let g=1+(i.scaleOffset-i.scaleLag*y)*r*e.scaleX;if(t.a*=g,t.c*=g,e.scaleYMode==="Uniform")t.b*=g,t.d*=g;else if(e.scaleYMode==="Volume"){let x=Math.abs(g),b=x>=0.7?1/x:4-3.67347*x;t.b*=b,t.d*=b}}return i.tx=c*t.a,i.ty=c*t.c,!0}function CP(e,t,n,s,r,i){let o=e.filter((l)=>l.kind==="physics"),a=bP(o,t,n,r.last,(l)=>xf(l,s),{},r.loop===!0&&n[l.name,l])),r.keyedNow=new Set(t.flatMap((l)=>l.kind==="reset"?[]:(l.name===Wi?Vf(o,l.kind,(u)=>xf(u,s)).map((u)=>u.name):[l.name]).map((u)=>`${u}/${l.kind==="mass"?"massInverse":l.kind}`)));for(let l of a.reset)Hf(qf(r,l),i);return e.map((l)=>l.kind==="physics"?a.records.get(l.name):l)}function Kf(e){return{phase:"reset",time:0,states:new Map,last:-1,...e?{step:e}:{}}}function $1(e){let t=a$(e,At(e));return t.length===0?null:`${t.map((n)=>`path constraint "${n.constraint}" reads slot bone "${n.bone}" from the previous pose`).join("; ")} — under the step the previous pose is the previous step's, which the stepped walk does not carry`}var ow=["animation","additive","loop","mix","bone","property","from","to","scale","max","local","time","skin"],Ll=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function AP(e,t,n,s,r,i){let o=i.length;for(let y of Object.keys(e)){if(y==="kind"||y==="name"||y==="declaredIn")continue;if(!ow.includes(y))i.push(`${n}: field "${y}" is not one this reader knows; it reads [${ow.join(", ")}]`)}let a=(y,g)=>{let x=e[y];if(x===void 0)return g;if(typeof x!=="number"||!Number.isFinite(x))return i.push(`${n}: ${y} is ${JSON.stringify(x)}, not a finite number`),g;return x},l=(y)=>{let g=e[y];if(g===void 0)return!1;if(typeof g!=="boolean")return i.push(`${n}: ${y} is ${JSON.stringify(g)}, not a boolean`),!1;return g},u=r.find((y)=>y.name===e.animation);if(u===void 0)i.push(`${n}: a slider's animation is ${JSON.stringify(e.animation)}, not an animation of this document`);let c=new Map(s.map((y)=>[y.name,y])),h=null;if(e.bone!==void 0)if(typeof e.bone!=="string"||!c.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);else h=e.bone;let d="rotate";if(e.property!==void 0){let y=Ct.find((g)=>g===e.property);if(y===void 0)i.push(`${n}: property is ${JSON.stringify(e.property)}, none of ${Ct.join(", ")}`);else d=y}a("max",0);let f=l("loop"),m=new Map;for(let y of u?.timelines.bones??[]){let g=c.get(y.name);if(g!==void 0)m.set(g.name,g)}let p={kind:"slider",name:t,animation:u?.name??"",timelines:u?.timelines??{declared:0,duration:0,bones:[],slots:[],later:[],attachments:[],drawOrder:[],events:[]},physics:[],setup:m,additive:l("additive"),loop:f,mix:a("mix",1),time:a("time",0),bone:h,property:d,from:a("from",0),to:a("to",0),scale:a("scale",1),local:l("local"),skin:l("skin"),listedBySkin:!1};return i.length===o?p:void 0}function EP(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.slider[${o}]`;if(!Ll(i)||typeof i.name!=="string"){s.push(`${a} names no slider`);return}if(!n.some((u)=>u.kind==="slider"&&u.name===i.name))s.push(`${a}: "${i.name}" is not a slider of this document`);let l={name:i.name,time:null,mix:null};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!Ll(u)||u.name!=="time"&&u.name!=="mix"){s.push(`${h}: ${JSON.stringify(Ll(u)?u.name:u)} is not a slider timeline; a slider keys time and mix`);return}let d=u.name;if(l[d]!==null)s.push(`${h}: "${d}" is keyed twice on slider "${i.name}"`);l[d]=RP(u.keys,`${h} "${d}"`,s)}),r.push(l)}),r}function RP(e,t,n){let s=[];if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),s;let r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!Ll(i)){n.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(h!=="time"&&h!=="value"&&h!=="curve")n.push(`${a}: field "${h}" is not one this reader knows; it reads [time, value, curve]`);let l=i.time;if(typeof l!=="number"||!Number.isFinite(l)||l<0){n.push(`${a}: time is ${JSON.stringify(l)}, not a finite time at or after 0`);return}if(l<=r)n.push(`${a}: time ${l} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l);let u=1;if(i.value!==void 0)if(typeof i.value!=="number"||!Number.isFinite(i.value))n.push(`${a}: value is ${JSON.stringify(i.value)}, not a finite number`);else u=i.value;let c="linear";if(i.curve!==void 0)if(o===e.length-1)n.push(`${a}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(i.curve==="stepped")c="stepped";else if(Array.isArray(i.curve)&&i.curve.length===4&&i.curve.every((h)=>typeof h==="number"&&Number.isFinite(h)))c=i.curve;else n.push(`${a}: curve is ${JSON.stringify(i.curve)}, not "stepped" nor 4 finite numbers`);s.push({time:Math.fround(l),values:[Math.fround(u)],stated:{time:l,values:[u]},curve:c})}),s}function PP(e,t,n,s={}){let r=t.find((l)=>l.name===e.name);if(r===void 0)return e;let i=s.search??rt,o=s.channel??ws,a=(l,u)=>{if(l===null)return u;let c=i(l,n);return c<0?u:u+(o(l,c,0,n)-u)*1};return{...e,time:a(r.time,e.time),mix:a(r.mix,e.mix)}}function $P(e,t){if(t.bone===null)return t.time;let n=F1(e,{source:t.bone,localSource:t.local,offsets:OP},t.property),s=t.to+(n-t.from)*t.scale,r=t.timelines.duration;if(t.loop&&r===0)return 0;return t.loop?r+s%r:Math.max(0,s)}var OP={rotate:0,x:0,y:0,scaleX:0,scaleY:0,shearY:0};function O1(e,t){let n=rt(e,t);if(n<0)return null;return e[n].values.map((s,r)=>ws(e,n,r,t))}function IP(e,t,n,s){if(t.mix===0)return[];let r=$P(e,t),i=t.timelines.duration,o=t.loop&&i!==0?r%i:r;n?.push({name:t.name,timelines:t.timelines,at:o,alpha:t.mix,additive:t.additive,time:r});let a=t.mix;if(s!==void 0&&e.rules.sliderWritesPhysics)FP(t,o,a,s);let l=[];for(let u of t.timelines.bones){let c=e.index.get(u.name),h=t.setup.get(u.name);if(c===void 0||h===void 0)continue;let d=e.bones[c],f=!1;for(let m of u.timelines){if(m.kind==="inherit"){let x=rt(m.keys,o);if(x<0)continue;d.inheritMode=m.keys[x].mode,f=!0;continue}let p=O1(m.keys,o);if(p===null)continue;f=!0;let y=(x,b)=>{let v=d[x]??0;d[x]=t.additive?v+p[b]*a:v+((h[x]??0)+p[b]-v)*a},g=(x,b)=>{let v=d[x]??1,_=h[x]??1;if(t.additive){d[x]=e.rules.sliderAdditiveScaleProduct?v+(p[b]*_-_)*a:v+(p[b]-1)*_*a;return}let S=_*p[b];if(a===1&&e.rules.sliderScaleMixOneIsTarget){d[x]=S;return}let M=Math.abs(v)*Math.sign(S);d[x]=M+(S-M)*a};switch(m.kind){case"rotate":y("rotation",0);break;case"translate":y("x",0),y("y",1);break;case"translatex":y("x",0);break;case"translatey":y("y",0);break;case"shear":y("shearX",0),y("shearY",1);break;case"shearx":y("shearX",0);break;case"sheary":y("shearY",0);break;case"scale":g("scaleX",0),g("scaleY",1);break;case"scalex":g("scaleX",0);break;case"scaley":g("scaleY",0);break}}if(f||e.rules.sliderReposesKeyedBones&&u.timelines.length>0)l.push(u.name)}return l}function BP(e,t,n,s){let r=new Map(e.flatMap((a)=>a.kind==="physics"?[[a.name,a]]:[])),i=new Map(r),o=new Map;if(!s.sliderPhysicsLastsOnePass){for(let[a,l]of n.carried??new Map){let u=i.get(a);if(u===void 0)continue;let c={...u},h={};for(let[d,f]of Object.entries(l)){if(n.keyedNow?.has(`${a}/${d}`))continue;c[d]=f,h[d]=f}i.set(a,c),o.set(a,h)}n.carried=o}return{records:i,setup:n.setupRecords??r,active:(a)=>xf(a,t),rules:s,ctx:n,written:o}}var DP=new Set(["wind","gravity"]);function FP(e,t,n,s){let r=s.rules;for(let i of e.physics){let o=s.records.get(i.name),a=i.name===Wi?Vf([...s.records.values()],i.kind,s.active):o!==void 0&&s.active(o)?[o]:[];if(i.kind==="reset"){if(!r.sliderPhysicsResetIsDead&&i.keys.some((h)=>h.time<=t))for(let h of a)Hf(qf(s.ctx,h.name),s.ctx.time);continue}let l=rt(i.keys,t);if(l<0)continue;let u=ws(i.keys,l,0,t),c=e.additive&&(DP.has(i.kind)||!r.sliderPhysicsAddsWindGravityOnly);for(let h of a){let d=r.sliderPhysicsFromCurrent?h:s.setup.get(h.name),f={...h},m;if(i.kind==="mass")if(m="massInverse",r.sliderPhysicsBlendsMass){let p=1/d.massInverse;f.massInverse=1/(c?1/h.massInverse+u*n:p+(u-p)*n)}else f.massInverse=c?h.massInverse+1/u*n:d.massInverse+(1/u-d.massInverse)*n;else m=i.kind,f[m]=c?h[m]+u*n:d[m]+(u-d[m])*n;if(s.records.set(h.name,f),!r.sliderPhysicsLastsOnePass)s.written.set(h.name,{...s.written.get(h.name),[m]:f[m]})}}}var Cl=(e)=>e<0?0:e>1?1:e,NP={rgba:[0,1,2,3],rgb:[0,1,2],alpha:[3],rgba2:[0,1,2,3,4,5,6],rgb2:[0,1,2,4,5,6]};function I1(e,t,n){for(let s of n)for(let r of s.timelines.slots){if(r.name!==e)continue;for(let i of r.timelines){if(i.kind==="attachment"){let a=rt(i.keys,s.at);if(a>=0)t.placeholder=i.keys[a].name??null;continue}let o=O1(i.keys,s.at);if(o===null)continue;NP[i.kind].forEach((a,l)=>{if(a<4)t.light[a]=s.alpha===1?Cl(o[l]):Cl(t.light[a]+(o[l]-t.light[a])*s.alpha);else if(t.dark!==null)t.dark[a-4]=s.alpha===1?Cl(o[l]):Cl(t.dark[a-4]+(o[l]-t.dark[a-4])*s.alpha)})}}}function GP(e){let t=[];for(let n of e.constraints){if(n.kind!=="slider")continue;let s=e.animations.find((c)=>c.name===n.animation);if(s===void 0)continue;let r=s.constraints,i=r.slider.reduce((c,h)=>c+(h.time===null?0:1)+(h.mix===null?0:1),0),o=r.path.reduce((c,h)=>c+[h.position,h.spacing,h.mix].filter((d)=>d!==void 0).length,0),a=[r.ik.length>0?"ik":null,r.transform.length>0?"transform":null,o>0?"path":null,i>0?"slider":null].filter((c)=>c!==null);if(a.length>0)t.push(`slider "${n.name}" applies animation "${n.animation}", which keys ${a.join(", ")} constraint timelines — a slider writing a later constraint's pose is not posed by this cut`);let l=e.constraints.flatMap((c)=>c.record?.kind==="path"?[c.record.slot]:[]),u=s.timelines.attachments.filter((c)=>c.deform!==null&&l.includes(c.slot)&&e.skins.find((h)=>h.name===c.skin)?.attachments[c.slot]?.[c.attachment]?.geometry?.kind==="path");if(u.length>0)t.push(`slider "${n.name}" applies animation "${n.animation}", which deforms walked path attachment(s) ${u.map((c)=>`"${c.skin}/${c.slot}/${c.attachment}"`).join(", ")} — a slider's deform of a curve a path constraint walks is not posed by this cut`)}return t.length===0?null:t.join("; ")}var Ut=180/_e,Ei=_e/180,aw=["ik","transform","path","physics","slider"],Ct=["rotate","x","y","scaleX","scaleY","shearY"],lw={rotate:"mixRotate",x:"mixX",y:"mixY",scaleX:"mixScaleX",scaleY:"mixScaleY",shearY:"mixShearY"},LP={rotate:"rotation",x:"x",y:"y",scaleX:"scaleX",scaleY:"scaleY",shearY:"shearY"},cw=["none","uniform","volume"],UP={ik:["bones","target","scaleY","mix","softness","bendPositive","compress","stretch","skin"],transform:["bones","source","properties","localSource","localTarget","additive","clamp","rotation","x","y","scaleX","scaleY","shearY","mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY","skin"]},Xn=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Ul(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function ln(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function Zt(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="boolean")return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a boolean`),n;return i}function WP(e,t,n,s){if(!Array.isArray(e.bones)||e.bones.length===0)return s.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`),[];let r=[];return e.bones.forEach((i,o)=>{if(typeof i!=="string"||!t.has(i))s.push(`${n}: bones[${o}] ${JSON.stringify(i)} is not a bone of this document`);else r.push(i)}),r}function uw(e,t,n,s,r){let i=e[t];if(typeof i!=="string"||!n.has(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a bone of this document`),"";return i}function bf(e,t,n,s,r){if(e[lw[t]]!==void 0)return ln(e,lw[t],0,s,r);if(t==="y")return n.has("x")?bf(e,"x",n,s,r):0;if(t==="scaleY")return n.has("scaleX")?bf(e,"scaleX",n,s,r):0;return n.has(t)?1:0}function XP(e,t,n,s,r,i,o){let a=o.length,l={...e};delete l.kind,delete l.name,delete l.declaredIn,Ul(l,UP[t],s,o);let u=WP(e,r,s,o),c=Zt(e,"skin",!1,s,o);if(t==="ik"){let g=uw(e,"target",r,s,o);if(u.length>2)o.push(`${s}: an ik constraint names ${u.length} bones; the format takes one or two`);if(u.length>=1&&i.get(u[0])===void 0)o.push(`${s}: its first bone "${u[0]}" is the root; spine-core throws posing an ik constraint on a bone with no parent`);if(u.length===2&&i.get(u[1])!==u[0])o.push(`${s}: "${u[1]}" is not a child of "${u[0]}"; a two-bone ik needs the second bone directly under the first`);let x="none";if(e.scaleY!==void 0){let v=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"",_=cw.find((S)=>S===v);if(_===void 0)o.push(`${s}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${cw.join(", ")}`);else x=_}let b={kind:t,name:n,bones:u,target:g,scaleY:x,skin:c,listedBySkin:!1,mix:ln(e,"mix",1,s,o),softness:ln(e,"softness",0,s,o),bendPositive:Zt(e,"bendPositive",!0,s,o),compress:Zt(e,"compress",!1,s,o),stretch:Zt(e,"stretch",!1,s,o)};return o.length===a?b:void 0}let h=uw(e,"source",r,s,o),d=[],f=new Set;if(e.properties!==void 0&&!Xn(e.properties))o.push(`${s}: properties is not an object`);else if(Xn(e.properties))for(let[g,x]of Object.entries(e.properties)){let b=`${s}.properties.${g}`,v=Ct.find((S)=>S===g);if(v===void 0){o.push(`${b}: "${g}" is none of ${Ct.join(", ")}`);continue}if(!Xn(x)){o.push(`${b} is not an object`);continue}Ul(x,["offset","to"],b,o);let _=[];if(!Xn(x.to))o.push(`${b}: to is not an object`);else for(let[S,M]of Object.entries(x.to)){let k=`${b}.to.${S}`,T=Ct.find((A)=>A===S);if(T===void 0){o.push(`${k}: "${S}" is none of ${Ct.join(", ")}`);continue}if(!Xn(M)){o.push(`${k} is not an object`);continue}Ul(M,["offset","scale","max"],k,o),_.push({property:T,offset:ln(M,"offset",0,k,o),scale:ln(M,"scale",1,k,o),max:ln(M,"max",1,k,o)}),f.add(T)}d.push({property:v,offset:ln(x,"offset",0,b,o),to:_})}let m={},p={};for(let g of Ct)m[g]=ln(e,LP[g],0,s,o),p[g]=bf(e,g,f,s,o);let y={kind:t,name:n,bones:u,source:h,properties:d,skin:c,listedBySkin:!1,offsets:m,mixes:p,localSource:Zt(e,"localSource",!1,s,o),localTarget:Zt(e,"localTarget",!1,s,o),additive:Zt(e,"additive",!1,s,o),clamp:Zt(e,"clamp",!1,s,o)};return o.length===a?y:void 0}var hw=["mix","softness"],dw=["mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY"];function jP(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function YP(e,t,n,s){let r={ik:[],transform:[],path:[],physics:0,slider:[]};if(!Xn(e))return r;r.path=lP(e.path,t,new Set(n.filter((i)=>i.kind==="path").map((i)=>i.name)),s),r.physics=yP(e.physics),r.physicsKeyed=xP(e.physics,t,new Set(n.filter((i)=>i.kind==="physics").map((i)=>i.name)),s),r.slider=EP(e.slider,t,n,s);for(let i of["ik","transform"]){let o=e[i];if(!Array.isArray(o))continue;o.forEach((a,l)=>{let u=`${t}.constraints.${i}[${l}]`;if(!Xn(a)||typeof a.name!=="string"){s.push(`${u} names no constraint`);return}if(!n.some((p)=>p.kind===i&&p.name===a.name))s.push(`${u}: "${a.name}" is not a ${i} constraint of this document`);let c=a.keys;if(!Array.isArray(c)||c.length===0){s.push(`${u}: keys is not a non-empty list`);return}let h=i==="ik"?hw:dw,d=i==="ik"?["time",...hw,"bendPositive","compress","stretch","curve"]:["time",...dw,"curve"],f=-1/0,m=[];if(c.forEach((p,y)=>{let g=`${u}.keys[${y}]`;if(!Xn(p)){s.push(`${g} is not an object`);return}Ul(p,d,g,s);let x=p.time;if(typeof x!=="number"||!Number.isFinite(x)||x<0){s.push(`${g}: time is ${JSON.stringify(x)}, not a finite time at or after 0`);return}if(x<=f)s.push(`${g}: time ${x} is not after the key before it — the writer refuses key times that do not strictly increase`);f=Math.max(f,x);let b=h.map((v)=>{if(i==="transform"&&v==="mixY"&&p.mixY===void 0)return ln(p,"mixX",1,g,s);return ln(p,v,v==="softness"?0:1,g,s)});m.push({time:Math.fround(x),values:b.map(Math.fround),stated:{time:x,values:b},curve:jP(p,h.length,y===c.length-1,g,s),flags:{bendPositive:Zt(p,"bendPositive",!0,g,s),compress:Zt(p,"compress",!1,g,s),stretch:Zt(p,"stretch",!1,g,s)}})}),i==="ik")r.ik.push({name:a.name,keys:m});else r.transform.push({name:a.name,keys:m})})}return r}function fw(e,t,n,s={}){let r=s.search??rt,i=s.channel??ws;return e.map((o)=>{if(t===null||o.kind==="physics")return o;if(o.kind==="slider")return PP(o,t.slider,n,s);if(o.kind==="path"){let c=t.path.find((d)=>d.name===o.name);if(c===void 0)return o;let h={...o};for(let[d,f]of[["position",["position"]],["spacing",["spacing"]],["mix",["mixRotate","mixX","mixY"]]]){let m=c[d];if(m===void 0)continue;let p=r(m,n);if(p<0)continue;f.forEach((y,g)=>h[y]=o[y]+(i(m,p,g,n)-o[y])*1)}return h}if(o.kind==="ik"){let c=t.ik.find((d)=>d.name===o.name);if(c===void 0)return o;let h=r(c.keys,n);if(h<0)return o;return{...o,mix:o.mix+(i(c.keys,h,0,n)-o.mix)*1,softness:o.softness+(i(c.keys,h,1,n)-o.softness)*1,...c.keys[h].flags}}let a=t.transform.find((c)=>c.name===o.name);if(a===void 0)return o;let l=r(a.keys,n);if(l<0)return o;let u={};return Ct.forEach((c,h)=>u[c]=o.mixes[c]+(i(a.keys,l,h,n)-o.mixes[c])*1),{...o,mixes:u}})}function vf(e){return e>180?e-360:e<=-180?e+360:e}var VP={a:1,b:0,c:0,d:1,worldX:0,worldY:0};function Xi(e){let t=e.inheritMode;if(t===void 0||t.length===0)return"normal";let n=t[0].toLowerCase()+t.slice(1);return n==="onlyTranslation"||n==="noRotationOrReflection"||n==="noScale"||n==="noScaleOrReflection"?n:"normal"}var Yn={ikCollapsedDet:0.00001,ikXAxisFloor:0.00001,readBackCollapsed:!0,offsetNegatedAtZeroDet:!0,inactiveHoldsItsWorld:!0,transformIgnoresBoneActivity:!0,ikOverInactiveFresh:!0,refuseHistoryLeak:!0,readBackReflectedShear:!0,readBackConformalInverse:!0,readBackNoScaleFrame:!0,additiveShearRightAngle:!0,ikZeroScaleSignPositive:!0,ikStretchMinLength:0.00001,ikTwoBoneNearChild:0.00001,sliderReposesKeyedBones:!0,sliderAdditiveScaleProduct:!0,sliderScaleMixOneIsTarget:!0,sliderWritesPhysics:!0,sliderPhysicsFromCurrent:!0,sliderPhysicsAddsWindGravityOnly:!0,sliderPhysicsBlendsMass:!0,sliderPhysicsLastsOnePass:!0,sliderPhysicsResetIsDead:!0};function ji(e){return e===void 0?Yn:{...Yn,...e}}function B1(e,t){return e/(t<0.7?0.25+t*0.642857:t)}function ks(e,t){return e.bones[e.index.get(t)]}function Jf(e,t){return t.parent===void 0?VP:e.world.get(t.parent)}function HP(e,t){if(!e.active.has(t.name)){if(!e.rules.inactiveHoldsItsWorld)e.world.set(t.name,{a:0,b:0,c:0,d:0,worldX:0,worldY:0});return}if(t.parent===void 0){e.world.set(t.name,Li([t]).get(t.name));return}let n=e.world.get(t.parent),[s,r,i,o]=l1(Xi(t),n,t),a=t.x??0,l=t.y??0;e.world.set(t.name,{a:s,b:r,c:i,d:o,worldX:n.a*a+n.b*l+n.worldX,worldY:n.c*a+n.d*l+n.worldY})}function zP(e,t,n,s=Yn){let r=e.parent===void 0?"normal":Xi(e),i=1/(t.a*t.d-t.b*t.c),o=n.worldX-t.worldX,a=n.worldY-t.worldY;if(e.x=o*(t.d*i)-a*(t.b*i),e.y=a*(t.a*i)-o*(t.c*i),e.shearX=0,r==="noScale"||r==="noScaleOrReflection"){let d=t.a*t.d-t.b*t.c,f=r==="noScale"&&d<0?-1:1;if(!s.readBackNoScaleFrame){let x=Math.sqrt(n.a*n.a+n.c*n.c),[b,v]=[n.a/x,n.c/x];Al(e,x,0,b*n.b+v*n.d,(b*n.d-v*n.b)*f,s),e.rotation=Math.atan2((v*t.a-b*t.c)/d,(b*t.d-v*t.b)/d)*Ut;return}let m=d<0?-1:1,p=Math.atan2((t.a*n.c-t.c*n.a)*m,(t.d*n.a-t.b*n.c)*m)*Ut,[y,g]=a1([t.a,t.b,t.c,t.d],p);Al(e,y*n.a+g*n.c,(y*n.c-g*n.a)*f,y*n.b+g*n.d,(y*n.d-g*n.b)*f,s,"shearX"),e.rotation=p;return}let l,u,c,h;if(r==="onlyTranslation")[l,u,c,h]=[n.a,n.b,n.c,n.d];else if(r==="noRotationOrReflection"){if(s.readBackConformalInverse){let d=1/(t.a*t.a+t.c*t.c),f=1/Math.abs(t.a*t.d-t.b*t.c);[l,u,c,h]=[(t.a*n.a+t.c*n.c)*d,(t.a*n.b+t.c*n.d)*d,(t.a*n.c-t.c*n.a)*f,(t.a*n.d-t.c*n.b)*f]}else{let d=Math.abs(t.a*t.d-t.b*t.c)/(t.a*t.a+t.c*t.c),[f,m,p,y]=[t.a,-t.c*d,t.c,t.a*d],g=f*y-m*p;[l,u,c,h]=[(y*n.a-m*n.c)/g,(y*n.b-m*n.d)/g,(f*n.c-p*n.a)/g,(f*n.d-p*n.b)/g]}Al(e,l,c,u,h,s),e.rotation=(e.rotation??0)+Math.atan2(t.c,t.a)*Ut;return}else{let[d,f,m,p]=[t.d*i,t.b*i,t.c*i,t.a*i];[l,u,c,h]=[d*n.a-f*n.c,d*n.b-f*n.d,p*n.c-m*n.a,p*n.d-m*n.b]}Al(e,l,c,u,h,s)}function Al(e,t,n,s,r,i,o="rotation"){let a=Math.sqrt(t*t+n*n),l=Math.sqrt(s*s+r*r);if(i.readBackCollapsed?!(a>0.0001):a<=0.0001){e.scaleX=0,e.scaleY=l,e.shearY=0,e.rotation=!i.readBackCollapsed||l>0.00001?Math.atan2(r,s)*Ut-90:0;return}let u=Math.atan2(n,t)*Ut,c=t*r-s*n,h=Math.atan2(r,s)*Ut;if(o==="rotation")e.rotation=u;else e.shearX=u;e.scaleX=a,e.scaleY=c<0?-l:l;let d=o==="rotation"?u:0,f=90;if(c<0)if(i.readBackReflectedShear)f=-90;else h+=180;let m=h-(d+f);m=m>180?m-360:m<-180?m+360:m,e.shearY=!i.readBackCollapsed||l>0.00001?m:0}function D1(e,t,n=null){let s=ks(e,t.bones[0]),r=n??Jf(e,s),i=e.world.get(s.name),o=e.world.get(t.target),a=Xi(s),[l,u,c,h]=[r.a,r.b,r.c,r.d],d=0,f,m;if(a==="noRotationOrReflection"){let b=Math.abs(l*h-u*c)/Math.max(e.rules.ikXAxisFloor,l*l+c*c);u=-c*b,h=l*b,d=Math.atan2(c,l)*Ut;let v=l*h-u*c,_=o.worldX-r.worldX,S=o.worldY-r.worldY;[f,m]=Math.abs(v)<=e.rules.ikCollapsedDet?[0,0]:[(_*h-S*u)/v-(s.x??0),(S*l-_*c)/v-(s.y??0)]}else if(a==="onlyTranslation")f=o.worldX-i.worldX,m=o.worldY-i.worldY;else{let b=l*h-u*c,v=o.worldX-r.worldX,_=o.worldY-r.worldY;[f,m]=Math.abs(b)<=e.rules.ikCollapsedDet?[0,0]:[(v*h-_*u)/b-(s.x??0),(_*l-v*c)/b-(s.y??0)]}let p=s.rotation??0,y=s.scaleX??1,g=-(s.shearX??0)-p+d+Math.atan2(m,f)*Ut;if(y<0)g+=180;s.rotation=p+vf(g)*t.mix;let x=(s.length??0)*y;if((t.compress||t.stretch)&&x>e.rules.ikStretchMinLength){let b=o.worldX-i.worldX,v=o.worldY-i.worldY,_=a==="noScale"||a==="noScaleOrReflection"?Math.sqrt(b*b+v*v):Math.sqrt(f*f+m*m);if(t.compress&&_x){let S=(_/x-1)*t.mix+1;if(s.scaleX=y*S,t.scaleY==="uniform")s.scaleY=(s.scaleY??1)*S;else if(t.scaleY==="volume")s.scaleY=B1(s.scaleY??1,S)}}return[s.name]}function qP(e,t,n=null){let s=ks(e,t.bones[0]),r=ks(e,t.bones[1]);if(Xi(s)!=="normal"||Xi(r)!=="normal")return[];let i=n??Jf(e,s),o=e.world.get(s.name),a=e.world.get(t.target),l=i.a*i.d-i.b*i.c,u=Math.abs(l)<=e.rules.ikCollapsedDet?0:1/l,c=(L,K)=>{let J=L-i.worldX,H=K-i.worldY;return[(J*i.d-H*i.b)*u,(H*i.a-J*i.c)*u]},h=s.x??0,d=s.y??0,f=s.scaleX??1,m=s.scaleY??1,p=r.scaleX??1,y=f,g=m,x=r.x??0,b=r.y??0,v=Math.abs(Math.abs(f)-Math.abs(m))<=0.00001;if(!v||t.stretch)b=0;let[_,S]=c(o.a*x+o.b*b+o.worldX,o.c*x+o.d*b+o.worldY),M=_-h,k=S-d,T=Math.sqrt(M*M+k*k),A=(r.length??0)*Math.abs(p);if(T0){let H=Math.min(1,J/(L*2))-1,pe=(J-L*(1-H*H))/K;O-=pe*O,R-=pe*R,P=O*O+R*R}}let F,B;if(v){A*=Math.abs(f);let L=(P-T*T-A*A)/(2*T*A);if(L<-1)L=-1,B=Math.PI*I;else if(L>1){if(L=1,B=0,t.stretch){let H=(Math.sqrt(P)/(T+A)-1)*t.mix+1;if(y*=H,t.scaleY==="uniform")g*=H;else if(t.scaleY==="volume")g=B1(g,H)}}else B=Math.acos(L)*I;let K=T+A*L,J=A*Math.sin(B);F=Math.atan2(R*K-O*J,O*K+R*J)}else{let L=Math.abs(f)*A,K=Math.abs(m)*A,J=L*L,H=K*K,pe=H-J,Ie=-2*H*T,Le=H*T*T+J*P-J*H,Me=Ie*Ie-4*pe*Le,ue=!1;if(F=0,B=0,Me>=0){let re=Math.sqrt(Me);if(Ie<0)re=-re;re=-(Ie+re)*0.5;let ge=re/pe,xe=Le/re,Te=Math.abs(ge)=0){let te=Math.sqrt(Be)*I;F=Math.atan2(R,O)-Math.atan2(te,Te),B=Math.atan2(te/Math.abs(m),(Te-T)/Math.abs(f)),ue=!0}}if(!ue){let re={angle:_e,x:T-L,y:0,dist:(T-L)*(T-L)},ge={angle:0,x:T+L,y:0,dist:(T+L)*(T+L)},xe=-L*T/(J-H);if(xe>=-1&&xe<=1){let Be=Math.acos(xe),te=L*Math.cos(Be)+T,be=K*Math.sin(Be),ye=te*te+be*be;if(yege.dist)ge={angle:Be,x:te,y:be,dist:ye}}let Te=P<=(re.dist+ge.dist)*0.5?re:ge;F=Math.atan2(R,O)-Math.atan2(Te.y*I,Te.x),B=Te.angle*I}}let C=e.rules.ikZeroScaleSignPositive?(f<0?-1:1)*(m<0?-1:1):Math.sign(f)*Math.sign(m),D=Math.atan2(b,x),N=s.rotation??0,G=(F-C*D)*Ut+(f<0?180:0)-N;s.rotation=N+vf(G)*t.mix,s.scaleX=y,s.scaleY=g;let z=((B+C*D)*Ut-(r.shearX??0))*C+(p<0?180:0),q=r.rotation??0;return r.y=b,r.rotation=q+vf(z-q)*t.mix,[s.name]}function F1(e,t,n){let s=ks(e,t.source),r=t.offsets;if(t.localSource)switch(n){case"rotate":return(s.rotation??0)+r.rotate;case"x":return(s.x??0)+r.x;case"y":return(s.y??0)+r.y;case"scaleX":return(s.scaleX??1)+r.scaleX;case"scaleY":return(s.scaleY??1)+r.scaleY;case"shearY":return(s.shearY??0)+r.shearY}let i=e.world.get(t.source);switch(n){case"rotate":{let o=i.a*i.d-i.b*i.c,a=Math.atan2(i.c,i.a)*Ut+((e.rules.offsetNegatedAtZeroDet?o>0:o>=0)?r.rotate:-r.rotate);if(a<0)a+=360;return a}case"x":return i.a*r.x+i.b*r.y+i.worldX;case"y":return i.c*r.x+i.d*r.y+i.worldY;case"scaleX":return Math.sqrt(i.a*i.a+i.c*i.c)+r.scaleX;case"scaleY":return Math.sqrt(i.b*i.b+i.d*i.d)+r.scaleY;case"shearY":return(Math.atan2(i.d,i.b)-Math.atan2(i.c,i.a))*Ut-90+r.shearY}}function KP(e,t,n,s,r,i){switch(t){case"rotate":{let o=r?n*Ei:n*Ei-Math.atan2(e.c,e.a);if(o>_e)o-=2*_e;else if(o<-_e)o+=2*_e;o*=s;let a=Math.cos(o),l=Math.sin(o),[u,c]=[e.a,e.b];e.a=a*u-l*e.c,e.b=a*c-l*e.d,e.c=l*u+a*e.c,e.d=l*c+a*e.d;return}case"x":e.worldX=r?e.worldX+n*s:e.worldX+(n-e.worldX)*s;return;case"y":e.worldY=r?e.worldY+n*s:e.worldY+(n-e.worldY)*s;return;case"scaleX":case"scaleY":{let[o,a]=t==="scaleX"?["a","c"]:["b","d"],l=Math.sqrt(e[o]*e[o]+e[a]*e[a]);if(l===0)return;let u=r?1+(n-1)*s:1+(n-l)*s/l;e[o]*=u,e[a]*=u;return}case"shearY":{let o=Math.atan2(e.d,e.b),a=Math.atan2(e.c,e.a),l=r&&!i.additiveShearRightAngle?n*Ei:(n+90)*Ei-(r?90*Ei:o-a);if(!r)l=l>_e?l-2*_e:l<-_e?l+2*_e:l;let u=o+l*s,c=Math.sqrt(e.b*e.b+e.d*e.d);e.b=Math.cos(u)*c,e.d=Math.sin(u)*c;return}}}var JP={rotate:"rotation",x:"x",y:"y",scaleX:"scaleX",scaleY:"scaleY",shearY:"shearY"};function ZP(e,t,n,s,r){let i=JP[t],o=t==="scaleX"||t==="scaleY",a=e[i]??(o?1:0);if(!r)e[i]=a+(n-a)*s;else e[i]=o?a*(1+(n-1)*s):a+n*s}function QP(e,t){let n=[],s=[];for(let r of t.bones){let i=ks(e,r),o={...e.world.get(r)},a=!1;for(let l of t.properties){let u=F1(e,t,l.property)-l.offset;for(let c of l.to){let h=t.mixes[c.property];if(h===0)continue;let d=u*c.scale+c.offset;if(t.clamp){let f=Math.min(c.offset,c.max),m=Math.max(c.offset,c.max);d=dm?m:d}if(a=!0,t.localTarget)ZP(i,c.property,d,h,t.additive);else KP(o,c.property,d,h,t.additive,e.rules)}}if(!a)continue;if(n.push(r),!t.localTarget)e.world.set(r,o),s.push(r)}return{changed:n,inWorld:s}}function Zf(e,t){return N1(t,e.active,e.rules)}function N1(e,t,n=Yn){if(e.skin&&!e.listedBySkin)return"skin";return(e.kind==="path"?[e.slotBone]:e.kind==="ik"?n.ikOverInactiveFresh?[e.target]:[...e.bones,e.target]:e.kind==="transform"?n.transformIgnoresBoneActivity?[e.source]:[...e.bones,e.source]:e.kind==="slider"?e.bone===null?[]:[e.bone]:[e.bone]).every((r)=>t.has(r))?null:"inactive bone"}function G1(e,t,n,s){let r=new Map(e.map((h)=>[h.name,h.parent])),i=new Map;for(let h of e)if(h.parent!==void 0)i.set(h.parent,[...i.get(h.parent)??[],h.name]);let o=new Map(e.map((h)=>[h.name,!t.has(h.name)])),a=new Set,l=(h)=>{if(o.get(h))return;let d=r.get(h);if(d!==void 0)l(d);o.set(h,!0),a.add(h)},u=(h)=>{for(let d of h){if(!t.has(d))continue;if(o.get(d))u(i.get(d)??[]);o.set(d,!1)}},c=new Map;return n.forEach((h,d)=>{if(s.has(d))return;if(h.kind==="slider"){u(h.timelines.bones.map((m)=>m.name));return}if(h.kind==="ik"){if(l(h.target),l(h.bones[0]),h.bones.length>1)l(h.bones[h.bones.length-1]);if(h.bones.some((m)=>!t.has(m))){let m=r.get(h.bones[0]);c.set(d,m===void 0||a.has(m))}if(u(i.get(h.bones[0])??[]),h.bones.length>1)o.set(h.bones[h.bones.length-1],!0);return}let f=h.kind==="physics"?[h.bone]:h.bones;if(h.kind==="transform")l(h.source);else if(h.kind==="path")for(let m of h.slotDeps)l(m);for(let m of f)l(m);for(let m of f)u(i.get(m)??[]);for(let m of f)o.set(m,!0)}),c}function e$(e,t,n,s){if(!e.rules.ikOverInactiveFresh||s.get(n)!==!1)return null;return{a:0,b:0,c:0,d:0,worldX:0,worldY:0}}function ql(e,t,n,s,r=null,i,o,a,l=Yn){if(s.length===0&&a===void 0){if(o!==void 0&&!l.sliderPhysicsLastsOnePass)o.carried=new Map;return new Map(t)}let u={bones:e.map((y)=>({...y})),index:r$(e,n),world:new Map(t),active:n,rules:l},c=new Set;s.forEach((y,g)=>{if(Zf(u,y)!==null)c.add(g)});let h=s.some((y)=>y.kind==="path")?mw(n$,u,s,c,()=>E1(e,n,s,c)):new Map,d=s.some((y)=>y.kind==="ik"&&y.bones.some((g)=>!n.has(g)))?mw(s$,u,s,c,()=>G1(e,n,s,c)):new Map,f=new Map,m=o===void 0?void 0:BP(s,n,o,l),p=(y,g)=>{for(let[x,b]of h)if(b!==null&&b.at===y&&b.when===g&&!(x===y&&g==="before"))f.set(x,{...u.world.get(s[x].slotBone)})};for(let y=0;y0)o$(u,x,b);p(y,"after")}return u.world}function t$(e){switch(e.kind){case"slider":return[e.kind,e.timelines.bones];case"ik":return[e.kind,e.target,e.bones];case"physics":return[e.kind,e.bone];case"transform":return[e.kind,e.source,e.bones];case"path":return[e.kind,e.bones,e.slotDeps,e.slotBone]}}var n$=new WeakMap,s$=new WeakMap;function mw(e,t,n,s,r){let i=n.map(t$),o=[...s],a=e.get(t.index);if(a!==void 0&&a.shapes.length===i.length&&i.every((u,c)=>u.length===a.shapes[c].length&&u.every((h,d)=>h===a.shapes[c][d]))&&a.skipped.length===o.length&&o.every((u,c)=>u===a.skipped[c]))return a.plan;let l=r();return e.set(t.index,{shapes:i,skipped:o,plan:l}),l}var pw=new WeakMap;function r$(e,t){let n=pw.get(t);if(n!==void 0&&n.names.length===e.length&&e.every((r,i)=>r.name===n.names[i]&&r.parent===n.parents[i]))return n.index;let s=new Map(e.map((r,i)=>[r.name,i]));return pw.set(t,{names:e.map((r)=>r.name),parents:e.map((r)=>r.parent),index:s}),s}var gw=new WeakMap;function i$(e){let t=gw.get(e.index);if(t!==void 0)return t;let n=e.bones.map(()=>[]);for(let s=0;su-c);for(let u of l){let c=e.bones[u];if(c.parent!==void 0&&r.has(c.parent)&&(!e.rules.inactiveHoldsItsWorld||e.active.has(c.parent)||s.includes(c.parent)))r.add(c.name);if(r.has(c.name)&&!i.includes(c.name))HP(e,c)}}function a$(e,t){let n=e.constraints.flatMap((o)=>o.record===void 0?[]:[o.record]);if(!n.some((o)=>o.kind==="path"))return[];let s={bones:[...e.bones],index:new Map(e.bones.map((o,a)=>[o.name,a])),active:t,rules:Yn},r=new Set;n.forEach((o,a)=>{if(Zf(s,o)!==null)r.add(a)});let i=[];for(let[o,a]of E1(e.bones,t,n,r)){let l=n[o];if(a===null&&l.offsetRotation!==0)i.push({constraint:l.name,bone:l.slotBone})}return i}function L1(e){let t=[],n=e.constraints.flatMap((s)=>s.record?.kind==="path"?[s.record]:[]);for(let s of e.animations){for(let r of n)if(s.timelines.slots.some((i)=>i.name===r.slot&&i.timelines.some((o)=>o.kind==="attachment")))t.push(`animation "${s.name}" keys the attachment of slot "${r.slot}", which path constraint "${r.name}" walks — a switch of the walked curve is not measured`);for(let r of s.deforms){let[i,o,a]=r.split("/"),l=e.skins.find((c)=>c.name===i)?.attachments[o]?.[a]?.geometry,u=Uf(e,o,a).map((c)=>`"${c}"`);if(l?.kind==="path"&&u.length>1)t.push(`animation "${s.name}" deforms path attachment "${a}" (skin "${i}", slot "${o}"), a placeholder skins ${u.join(", ")} fill — which of them --skin all walks, and so whether the deform moves it, is the Spine file's skin order, not the model's`)}}return t.length===0?null:t.join("; ")}function tc(e,t=Yn){let n=e.constraints.flatMap((o)=>o.record?.kind==="path"&&o.record.unresolved!==null?[o.record.unresolved]:[]);if(n.length>0)return n.join("; ");let s=e.constraints.filter((o)=>!aw.includes(o.kind));if(s.length===0)return GP(e)??(t.refuseHistoryLeak?l$(e):null);let r=[...new Set(e.constraints.map((o)=>o.kind))],i=[...new Set(s.map((o)=>o.kind))];return`the document declares ${r.map((o)=>`${o} ×${e.constraints.filter((a)=>a.kind===o).length}`).join(", ")}, and ${i.join(", ")} constraints are not admitted (item 5; ${aw.join(", ")} are): the oracle applies them`}function l$(e){return c$(e).refusal}function c$(e){let t=e.constraints.flatMap((p)=>p.record===void 0?[]:[p.record]),n=At(e);if(e.bones.every((p)=>n.has(p.name)))return{refusal:null,tainted:new Map};let s=new Map(e.bones.map((p)=>[p.name,p.parent])),r=new Set;for(let p of e.bones)if(!n.has(p.name)||p.parent!==void 0&&r.has(p.parent))r.add(p.name);let i=(p)=>e.bones.filter((y)=>{for(let g=y.name;g!==void 0;g=s.get(g))if(g===p)return!0;return!1}).map((y)=>y.name),o={bones:[...e.bones],index:new Map(e.bones.map((p,y)=>[p.name,y])),active:n,rules:Yn},a=new Set;t.forEach((p,y)=>{if(Zf(o,p)!==null)a.add(y)});let l=G1(e.bones,n,t,a),u=new Map,c=new Map,h=(p)=>`${p.kind} constraint "${p.name}" writes into inactive bone "${p.inactive}"`,d=()=>{let p=new Map(u);for(let[y,g]of c)if(!p.has(y))p.set(y,g);return p},f=(p,y,g)=>{for(let x of y)if(!p.has(x))p.set(x,g)},m=(p)=>`${p.kind} constraint "${p.name}"`;for(let p=0;pk.name):y.bones,x=y.kind==="transform"&&y.localSource||y.kind==="slider"&&y.local,b=y.kind==="ik"?[y.target]:y.kind==="transform"?[y.source]:y.kind==="path"?[y.slotBone,...y.slotDeps]:y.kind==="slider"?y.bone===null?[]:[y.bone]:[],v=x?c:u,_=b.find((k)=>v.has(k));if(_!==void 0){let k=g.find((A)=>!r.has(A)),T=v.get(_);if(k!==void 0)return{refusal:`${m(y)} moves posed bone "${k}" and reads ${x?"the local values":"the world transform"} of bone "${_}", a bone whose value depends on the runtime's previous pass (${h(T)}) — the runtime's own sample-after-sample and fresh-skeleton readings disagree there, so there is no one value to pose`,tainted:d()};f(u,g.flatMap(i),T),f(c,g,T)}let S=g.find((k)=>!n.has(k));if(S===void 0||y.kind==="physics"||y.kind==="slider")continue;let M={kind:y.kind,name:y.name,inactive:S};if(y.kind==="ik"){if(l.get(p)!==!1)continue;if(f(c,y.bones,M),y.bones.length>1)f(u,i(y.bones[1]),M)}else if(y.kind==="transform"&&y.localTarget)f(c,g,M);else f(u,g.flatMap(i),M),f(c,g,M)}return{refusal:null,tainted:d()}}var U1={rotate:["value"],translate:["x","y"],translatex:["value"],translatey:["value"],scale:["x","y"],scalex:["value"],scaley:["value"],shear:["x","y"],shearx:["value"],sheary:["value"]},u$=[...Object.keys(U1),"inherit"],nc={rgba:{fields:[["color",8]],channels:["r","g","b","a"]},rgb:{fields:[["color",6]],channels:["r","g","b"]},alpha:{fields:[],channels:["a"]},rgba2:{fields:[["light",8],["dark",6]],channels:["r","g","b","a","r2","g2","b2"]},rgb2:{fields:[["light",6],["dark",6]],channels:["r","g","b","r2","g2","b2"]}},h$=["attachment",...Object.keys(nc)],Mr=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),d$=(e,t)=>typeof e==="string"&&e.length===t&&/^[0-9a-fA-F]+$/.test(e);function W1(e,t,n){let s=e.time;if(typeof s!=="number"||!Number.isFinite(s)||s<0)return n.push(`${t}: time is ${JSON.stringify(s)}, not a finite time at or after 0`),null;return s}function X1(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),[];let s=[],r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!Mr(i)){n.push(`${a} is not an object`);return}let l=W1(i,a,n);if(l===null)return;if(l<=r)n.push(`${a}: time ${i.time} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l),s.push({raw:i,at:a,time:l})}),s}function Bi(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this timeline's keys carry; they carry [${t.join(", ")}]`)}function j1(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function f$(e,t,n,s){let r=X1(t,n,s);return r.map(({raw:i,at:o,time:a},l)=>{if(e==="inherit"){Bi(i,["time","inherit"],o,s);let h=typeof i.inherit==="string"?Qf(i.inherit):null;if(h===null)s.push(`${o}: inherit is ${JSON.stringify(i.inherit)}, which folds to no inherit mode`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",mode:h??"normal"}}let u=U1[e];Bi(i,["time",...u,"curve"],o,s);let c=u.map((h)=>{let d=i[h];if(typeof d!=="number"||!Number.isFinite(d))return s.push(`${o}: ${h} is ${JSON.stringify(d)}, not a finite number — the writer states every channel on every key`),0;return d});return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:j1(i,u.length,l===r.length-1,o,s)}})}function m$(e,t){let n=[];for(let s=0;s{if(e==="attachment"){if(Bi(i,["time","name"],o,s),i.name!==null&&(typeof i.name!=="string"||i.name===""))s.push(`${o}: name is ${JSON.stringify(i.name)}, not a placeholder name or null`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",name:typeof i.name==="string"?i.name:null}}let u=nc[e],c=[];if(e==="alpha"){Bi(i,["time","value","curve"],o,s);let h=i.value;if(typeof h!=="number"||!Number.isFinite(h))s.push(`${o}: value is ${JSON.stringify(h)}, not a finite number`);else c=[h]}else{Bi(i,["time",...u.fields.map(([h])=>h),"curve"],o,s);for(let[h,d]of u.fields){let f=i[h];if(!d$(f,d))s.push(`${o}: ${h} is ${JSON.stringify(f)}, not ${d} hex digits — the one spelling the writer gives a ${e} key's ${h}`);else c.push(...m$(f,h==="dark"||d===6?3:4))}}if(c.length!==u.channels.length)c=u.channels.map(()=>0);return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:j1(i,u.channels.length,l===r.length-1,o,s)}})}function g$(e,t,n){let s=[],r=0,i=(a,l)=>{if(r++,!Array.isArray(a)){n.push(`${l} is not a list of keys`);return}a.forEach((u,c)=>{if(!Mr(u))n.push(`${l}[${c}] is not an object`);else{let h=W1(u,`${l}[${c}]`,n);if(h!==null)s.push(Math.fround(h))}})},o=(a,l,u)=>{if(!Array.isArray(a)){n.push(`${l} is not a list`);return}a.forEach((c,h)=>Mr(c)?u(c,`${l}[${h}]`):n.push(`${l}[${h}] is not an object`))};if(!Mr(e))n.push(`${t} is not an object`);else{for(let a of["ik","transform"])o(e[a],`${t}.${a}`,(l,u)=>i(l.keys,`${u}.keys`));for(let a of["path","physics","slider"])o(e[a],`${t}.${a}`,(l,u)=>o(l.timelines,`${u}.timelines`,(c,h)=>i(c.keys,`${h}.keys`)))}return{timelines:r,times:s}}function y$(e,t,n,s,r,i){let o=typeof e.duration==="number"&&Number.isFinite(e.duration)?e.duration:0;if(typeof e.duration!=="number"||!Number.isFinite(e.duration))r.push(`${t}: duration is ${JSON.stringify(e.duration)}, not a finite number`);let a=new Map(s.map((x)=>[x.name,x])),l=[],u=(x,b,v,_)=>{let S=e[x],M=[];if(!Array.isArray(S))return r.push(`${t}: ${x} is not a list`),M;return S.forEach((k,T)=>{let A=`${t}.${x}[${T}]`;if(!Mr(k)||typeof k.name!=="string"){r.push(`${A} names no target`);return}let O=`${A} "${k.name}"`,R=v(k.name);if(R!==null)r.push(`${O}: ${R}`);if(!Array.isArray(k.timelines)){r.push(`${O}: timelines is not a list`);return}let P=k.name,I={name:P,timelines:[]};k.timelines.forEach((F,B)=>{let C=`${O}.timelines[${B}]`;if(!Mr(F)||typeof F.name!=="string"){r.push(`${C} names no timeline`);return}let D=b.find((G)=>G===F.name);if(D===void 0){r.push(`${C}: "${F.name}" is not a ${x==="bones"?"bone":"slot"} timeline this core reads; it reads [${b.join(", ")}]`);return}if(I.timelines.some((G)=>G.kind===D))r.push(`${C}: "${D}" is keyed twice on ${P} — the writer merges one property's tracks into one`);let N=_(D,F.keys,`${C} "${D}"`,P);for(let G of N)l.push(G.time);I.timelines.push({kind:D,keys:N})}),M.push(I)}),M},c=u("bones",u$,(x)=>n.has(x)?null:`"${x}" is not a bone of this document`,(x,b,v)=>f$(x,b,v,r)),h=u("slots",h$,(x)=>a.has(x)?null:`"${x}" is not a slot of this document`,(x,b,v,_)=>{if((x==="rgba2"||x==="rgb2")&&a.get(_)?.dark===void 0)r.push(`${v}: slot "${_}" states no dark colour, and a ${x} timeline on such a slot makes the runtime throw while it is applied — the writer refuses it`);return p$(x,b,v,r)}),d=[],f=g$(e.constraints,`${t}.constraints`,r);if(l.push(...f.times),f.timelines>0)d.push(["constraints",f.timelines]);let m=TR(e.attachments,t,i.skins,r),p=OR(e.drawOrder,t,s,r),y=DR(e.events,t,i.events,r);for(let x of m)for(let b of[...x.deform??[],...x.sequence??[]])l.push(b.time);for(let x of[...p,...y])l.push(x.time);let g=m.reduce((x,b)=>x+(b.deform===null?0:1)+(b.sequence===null?0:1),0);if(g>0)d.push(["attachments",g]);if(p.length>0)d.push(["drawOrder",1]);if(y.length>0)d.push(["events",1]);return{declared:o,duration:l.length===0?0:Math.max(...l),bones:c,slots:h,later:d,attachments:m,drawOrder:p,events:y}}var x$=0.16666667,Y1=10;function sc(e,t,n,s,r,i,o,a){let l=(d,f,m,p)=>{let y=(d-2*f+m)*0.03,g=((f-m)*3-d+p)*0.006,x=(f-d)*0.3+y+g*x$,b=y*2+g,v=d,_=[];for(let S=1;Sr(e,s,o,t))}function H1(e,t,n){let s=(n.search??rt)(e,t);return s<0?null:e[s]}var xw=new WeakMap;function b$(e){let t=xw.get(e);if(t===void 0)t=new Map(e.bones.map((n)=>[n.name,n])),xw.set(e,t);return t}function v$(e,t,n,s={}){let r=b$(t);return e.bones.map((i)=>{let o=r.get(i.name);if(o===void 0)return i;let a={...i};for(let l of o.timelines){if(l.kind==="inherit"){let d=H1(l.keys,n,s);if(d===null)if(i.inheritMode===void 0)delete a.inheritMode;else a.inheritMode=i.inheritMode;else a.inheritMode=d.mode;continue}let u=V1(l.keys,n,s),c=(d,f)=>{a[d]=(i[d]??0)+(u===null?0:u[f])},h=(d,f)=>{a[d]=(i[d]??1)*(u===null?1:u[f])};switch(l.kind){case"rotate":c("rotation",0);break;case"translate":c("x",0),c("y",1);break;case"translatex":c("x",0);break;case"translatey":c("y",0);break;case"shear":c("shearX",0),c("shearY",1);break;case"shearx":c("shearX",0);break;case"sheary":c("shearY",0);break;case"scale":h("scaleX",0),h("scaleY",1);break;case"scalex":h("scaleX",0);break;case"scaley":h("scaleY",0);break}}return a})}var _$={rotation:0,x:0,y:0,scaleX:1,scaleY:1,shearX:0,shearY:0};class z1{constructor(e,t,n){this.bones=e,this.index=t,this.setup=n}read(e){return this.bones[this.index][e]??_$[e]}write(e,t){if(typeof t!=="number"||!Number.isFinite(t))throw new Y(`the adjustment wrote bone "${this.setup.name}" ${e} = ${String(t)}, not a finite number`);if(this.bones[this.index]===this.setup)this.bones[this.index]={...this.setup};this.bones[this.index][e]=t}get rotation(){return this.read("rotation")}set rotation(e){this.write("rotation",e)}get x(){return this.read("x")}set x(e){this.write("x",e)}get y(){return this.read("y")}set y(e){this.write("y",e)}get scaleX(){return this.read("scaleX")}set scaleX(e){this.write("scaleX",e)}get scaleY(){return this.read("scaleY")}set scaleY(e){this.write("scaleY",e)}get shearX(){return this.read("shearX")}set shearX(e){this.write("shearX",e)}get shearY(){return this.read("shearY")}set shearY(e){this.write("shearY",e)}}function q1(e,t,n,s){let r=new Map,i=e.bones.map((o)=>o.name);n({names:i,bone(o){let a=r.get(o);if(a===void 0){let l=i.indexOf(o);if(l<0)throw new Y(`the adjustment asked for bone ${JSON.stringify(o)}, which is not one of this document's bones`);a=new z1(t,l,e.bones[l]),r.set(o,a)}return a}},s)}var bw=(e)=>e<0?0:e>1?1:e;function S$(e,t,n,s={},r=[],i){let o=tm(e),a=s.colour??o,l=new Map(t.slots.map((u)=>[u.name,u]));return K1(e,s,r,i,(u,c)=>{let h=u.setup,d=u.color===void 0?rc:a(u.color),f=[d[0],d[1],d[2],d[3]],m=u.dark===void 0?null:o(u.dark),p=m===null?null:[m[0],m[1],m[2]];for(let y of c?l.get(u.name)?.timelines??[]:[]){if(y.kind==="attachment"){let b=H1(y.keys,n,s);h=b===null?u.setup:b.name??null;continue}let g=V1(y.keys,n,s);nc[y.kind].channels.forEach((b,v)=>{let _={r:0,g:1,b:2,a:3,r2:4,g2:5,b2:6}[b];if(_<4)f[_]=g===null?d[_]:bw(g[v]);else if(p!==null&&m!==null)p[_-4]=g===null?m[_-4]:bw(g[v])})}return{placeholder:h,light:f,dark:p}})}function K1(e,t,n,s,r){let i=t.shown??vn,o=t.blend??nm,a=t.round??qi,l=[],u=[],c=At(e),h=t.slotTimelines??ec;for(let d of e.slots){let f=h(e,d,c),m=r(d,f),p=m.placeholder,{light:y,dark:g}=m;s?.set(d.name,p);let x={placeholder:p,light:y,dark:g};if(f)I1(d.name,x,n);p=x.placeholder;let b=p===null?null:i(e,{...d,setup:p});if(b!==null&&"conflict"in b){u.push(`slot "${d.name}" shows placeholder "${p}", filled by skins ${b.conflict.map((_)=>`"${_.skin}" (shows ${JSON.stringify(_.shown)})`).join(", ")}`);continue}let v=b===null?null:Ki(b);l.push([d.name,v===null?null:v.name,a(y[0]),a(y[1]),a(y[2]),a(y[3]),g===null?null:[a(g[0]),a(g[1]),a(g[2])],v===null?null:v.path,o(d)])}return{rows:l,conflicts:u}}function k$(e,t,n,s,r,i,o){return w$(e,t,n,s,r,i,o).world}function w$(e,t,n,s,r,i,o){let a=s.stage;if(a!==void 0)a.begin("timeline");let l=v$(e,t,n,s);if(a!==void 0)a.end("timeline");if(r!==void 0&&o!==void 0)return J1(e,l,s,()=>vw(e,fw(Vi(e),r,n),t,n,s),r.physicsKeyed??[],n,i,o);let u=At(e);if(o?.adjustment!==void 0){if(a!==void 0)a.begin("timeline");if(q1(e,l,o.adjustment.callback,o.adjustment.context),a!==void 0)a.end("timeline")}if(a!==void 0)a.begin("world");let c=(s.evaluate??Li)(l,u);if(a!==void 0)a.end("world");let h=c;if(r!==void 0){if(a!==void 0)a.begin("constraints");let d=Vi(e),f=vw(e,fw(d,r,n),t,n,s),m=d.some((p)=>p.kind==="path")?ql(e.bones,(s.evaluate??Li)(e.bones,u),u,s.constraints?s.constraints(d):d,null,void 0,void 0,void 0,ji(s.solver)):null;if(h=ql(l,c,u,s.constraints?s.constraints(f):f,m,i,void 0,void 0,ji(s.solver)),a!==void 0)a.end("constraints")}for(let d of l)if(h.get(d.name)===void 0)throw new Y(`the evaluator returned no transform for bone "${d.name}"`);return{bones:l,world:h,active:u,round:s.round??qi}}function J1(e,t,n,s,r,i,o,a){let l=n.stage,u=At(e);if(a.adjustment!==void 0){if(l!==void 0)l.begin("timeline");if(q1(e,t,a.adjustment.callback,a.adjustment.context),l!==void 0)l.end("timeline")}if(l!==void 0)l.begin("world");let c=(n.evaluate??Li)(t,u);if(l!==void 0)l.end("world"),l.begin("constraints");let h=CP(s(),r,i,u,a.ctx,a.before),d=ql(t,c,u,n.constraints?n.constraints(h):h,null,o,a.ctx,void 0,ji(n.solver));if(l!==void 0)l.end("constraints");for(let f of t)if(d.get(f.name)===void 0)throw new Y(`the evaluator returned no transform for bone "${f.name}"`);return{bones:t,world:d,active:u,round:n.round??qi}}function M$(e,t,n,s,r){return J1(e,t,n,()=>Vi(e),[],0,s,r).world}function vw(e,t,n,s,r){if(n.attachments.every((i)=>i.deform===null))return t;return t.map((i)=>{if(i.kind!=="path"||i.path===null)return i;let o=e.slots.find((h)=>h.name===i.slot),a=o===void 0?null:(r.shown??vn)(e,o);if(a===null||"conflict"in a)return i;let l=Xf(i.slot,a),u=n.attachments.find((h)=>h.deform!==null&&`${h.skin}/${h.slot}/${h.attachment}`===l);if(u===void 0||u.deform===null)return i;let c=(r.deform??Wf)(i.path.vertices,u.deform,s);return c===null?i:{...i,path:{...i.path,vertices:f1(i.path.vertices,c),exact:!0}}})}var _r="rigc-compiled/3",_f="rigc-compiled/2",Sf="rigc-compiled/1",Z1=[_r,_f,Sf];class Y extends Error{}var Q1=["referenceScale","stage","bones","slots","skins","constraints","events","animations","editorOrder","images","pageGrids","droppedStates","absentParts","meshBones","meshes","physics","deformTransforms","trackDerivations","rig","pages","spine"],eM=Q1.filter((e)=>e!=="stage"&&e!=="editorOrder"),T$=eM.filter((e)=>e!=="pages"),tM=["name","width","height","pma","scale","regions"],C$=tM.filter((e)=>e!=="pma"&&e!=="scale"),_w=["x","y","width","height"],Sw=["slot","attachment"],kw=["name","x","y","width","height","offsetX","offsetY","originalWidth","originalHeight","degrees","index"],A$=["name","parent","length","x","y","rotation","scaleX","scaleY","shearX","shearY","inheritMode","skinRequired","editor"],E$=["length","x","y","rotation","scaleX","scaleY","shearX","shearY"],R$=["name","bone","setup","color","dark","blend"],P$=["name","bones","constraints","attachments"],ww={mesh:["kind","name","path","color","uvs","triangles","vertices","hull","edges","width","height","sequence"],boundingbox:["kind","name","vertexCount","vertices","editorColor"],clipping:["kind","name","end","convex","inverse","vertexCount","vertices","editorColor"],path:["kind","name","closed","constantSpeed","vertexCount","vertices","lengths","editorColor"],region:["kind","name","path","x","y","rotation","scaleX","scaleY","width","height","color","sequence","atlas"],linkedmesh:["kind","name","path","source","skin","slot","timelines","width","height","color","sequence"]},nM=new Set(["region","mesh","linkedmesh"]),sM=/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/,rM=["Normal","Additive","Multiply","Screen"];function iM(e){let t=`${e.slice(0,1).toUpperCase()}${e.slice(1)}`;return rM.includes(t)?t:null}var Tr=["ik","transform","path","physics","slider"],oM=["normal","onlyTranslation","noRotationOrReflection","noScale","noScaleOrReflection"],Mw=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function $$(e,t,n){if(!Array.isArray(e))return t.push(`pages is ${JSON.stringify(e)??"absent"}, not a list of pages`),[];let s=[];return e.forEach((r,i)=>{let o=`pages[${i}]`;if(!Ge(r)){t.push(`${o} is not an object`);return}let a=t.length,l=typeof r.name==="string"?`${o} "${r.name}"`:o;if(Wt(r,n?tM:C$,l,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)??"absent"}, not a non-empty string`);for(let c of["width","height"]){let h=r[c];if(typeof h!=="number"||!Number.isFinite(h)||h<=0)t.push(`${l}: ${c} is ${JSON.stringify(h)??"absent"}, not a positive finite number — a page UV divides by it`)}if(n){if(typeof r.pma!=="boolean")t.push(`${l}: pma is ${JSON.stringify(r.pma)??"absent"}, not true or false — whether the page's texels are premultiplied`);if(r.scale!==null&&(typeof r.scale!=="number"||!Number.isFinite(r.scale)))t.push(`${l}: scale is ${JSON.stringify(r.scale)??"absent"}, not a finite number or null — the number the page's scale: line states, null where it has none`)}let u=[];if(!Array.isArray(r.regions))t.push(`${l}: regions is not a list`);else if(r.regions.length===0)t.push(`${l}: regions is an empty list — a page holds at least one region; the atlas text cannot state a page with none (its block would end before a region line, which A07_ATLAS_TEXT_SHAPE refuses), so no build writes one`);else r.regions.forEach((c,h)=>{let d=`${l}.regions[${h}]`;if(!Ge(c)){t.push(`${d} is not an object`);return}let f=typeof c.name==="string"?`${d} "${c.name}"`:d;if(Wt(c,kw,f,t),typeof c.name!=="string"||c.name==="")t.push(`${d}: name is ${JSON.stringify(c.name)??"absent"}, not a non-empty string`);for(let m of kw){if(m==="name")continue;let p=c[m];if(typeof p!=="number"||!Number.isFinite(p))t.push(`${f}: ${m} is ${JSON.stringify(p)??"absent"}, not a finite number`)}u.push(c)});if(t.length===a)s.push(n?{name:r.name,width:r.width,height:r.height,pma:r.pma,scale:r.scale,regions:u}:{name:r.name,width:r.width,height:r.height,regions:u})}),s}function O$(e,t){if(e===void 0)return"";if(!Ge(e))return t.push(`spine is ${JSON.stringify(e)}, not { "sha256": "<64 lowercase hex digits>" }`),"";for(let s of Object.keys(e))if(s!=="sha256")t.push(`spine: field "${s}" is not one this reader knows; it reads [sha256]`);let n=e.sha256;if(typeof n!=="string"||!/^[0-9a-f]{64}$/.test(n))return t.push(`spine.sha256 is ${JSON.stringify(n)??"absent"}, not 64 lowercase hex digits — the SHA-256 of the skeleton.json written beside the document`),"";return n}function I$(e,t){if(e===null)return null;if(!Ge(e))return t.push(`stage is ${JSON.stringify(e)??"absent"}, not null or { x, y, width, height } — the setup-pose box the Spine header declares`),null;let n=t.length;Wt(e,[..._w,"box"],"stage",t);for(let i of _w){let o=e[i];if(typeof o!=="number"||!Number.isFinite(o))t.push(`stage: ${i} is ${JSON.stringify(o)??"absent"}, not a finite number`)}let s=e.box;if(s!==void 0)if(!Ge(s))t.push(`stage.box is ${JSON.stringify(s)}, not { slot, attachment }`);else{Wt(s,Sw,"stage.box",t);for(let i of Sw)if(typeof s[i]!=="string"||s[i]==="")t.push(`stage.box: ${i} is ${JSON.stringify(s[i])??"absent"}, not a non-empty string`)}if(t.length!==n)return null;let r={x:e.x,y:e.y,width:e.width,height:e.height};if(Ge(s))r.box={slot:s.slot,attachment:s.attachment};return r}function B$(e,t,n,s){let r={skins:[],animations:[]};if(!Ge(e))return s.push(`editorOrder is ${JSON.stringify(e)??"absent"}, not { skins, animations }`),r;Wt(e,["skins","animations"],"editorOrder",s);let i=(l,u)=>{if(!Array.isArray(l)||l.some((c)=>typeof c!=="string"))return s.push(`${u} is ${JSON.stringify(l)??"absent"}, not a list of names`),null;return l},o=(l,u,c,h)=>{let d=new Set;for(let m of l){if(d.has(m))return void s.push(`${c} lists ${h} "${m}" twice`);if(d.add(m),!u.includes(m))return void s.push(`${c} lists ${h} "${m}", which the document does not hold`)}let f=u.find((m)=>!d.has(m));if(f!==void 0)s.push(`${c} leaves out ${h} "${f}"`)};if(!Array.isArray(e.skins))s.push(`editorOrder.skins is ${JSON.stringify(e.skins)??"absent"}, not a list`);else e.skins.forEach((l,u)=>{let c=`editorOrder.skins[${u}]`;if(!Ge(l)||typeof l.name!=="string")return void s.push(`${c} is not { name, slots }`);Wt(l,["name","slots"],c,s);let h=i(l.slots,`${c}.slots`),d=t.find((f)=>f.name===l.name);if(h!==null&&d!==void 0)o(h,Object.keys(d.attachments),`${c}.slots`,"slot key");r.skins.push({name:l.name,slots:h??[]})}),o(r.skins.map((l)=>l.name),t.map((l)=>l.name),"editorOrder.skins","skin");let a=i(e.animations,"editorOrder.animations");if(a!==null)o(a,n.map((l)=>l.name),"editorOrder.animations","animation"),r.animations=a;return r}var Ge=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Qf(e){let t=e.length===0?e:e[0].toLowerCase()+e.slice(1);return oM.find((n)=>n===t)??null}function Wt(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function D$(e,t){if(!Array.isArray(e))return t.push("bones is not a list"),[];let n=[],s=new Set;return e.forEach((r,i)=>{let o=`bones[${i}]`;if(!Ge(r)){t.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(Wt(r,A$,a,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);else if(s.has(r.name))t.push(`${a}: the name is declared twice`);if(r.parent!==void 0){if(typeof r.parent!=="string")t.push(`${a}: parent is ${JSON.stringify(r.parent)}, not a bone name`);else if(!s.has(r.parent))t.push(`${a}: parent "${r.parent}" is not declared before it; bones are parents first`)}for(let l of E$){let u=r[l];if(u!==void 0&&(typeof u!=="number"||!Number.isFinite(u)))t.push(`${a}: ${l} is ${JSON.stringify(u)}, not a finite number`)}if(r.inheritMode!==void 0){if(typeof r.inheritMode!=="string"||Qf(r.inheritMode)===null)t.push(`${a}: inheritMode is ${JSON.stringify(r.inheritMode)}, which folds to none of ${oM.join(", ")}`)}if(r.skinRequired!==void 0&&typeof r.skinRequired!=="boolean")t.push(`${a}: skinRequired is ${JSON.stringify(r.skinRequired)}, not a boolean`);if(r.editor!==void 0)if(!Ge(r.editor))t.push(`${a}: editor is not an object`);else{Wt(r.editor,["color","icon"],`${a}.editor`,t);for(let l of["color","icon"])if(r.editor[l]!==void 0&&typeof r.editor[l]!=="string")t.push(`${a}.editor: ${l} is not a string`)}if(typeof r.name==="string"&&r.name!=="")s.add(r.name);n.push(r)}),n}function F$(e,t,n){if(!Array.isArray(e))return n.push("slots is not a list"),[];let s=[];return e.forEach((r,i)=>{let o=`slots[${i}]`;if(!Ge(r)){n.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(Wt(r,R$,a,n),typeof r.name!=="string"||r.name==="")n.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);if(typeof r.bone!=="string")n.push(`${a}: bone is ${JSON.stringify(r.bone)}, not a bone name`);else if(!t.has(r.bone))n.push(`${a}: bone "${r.bone}" is not a bone of this document`);if(r.setup!==null&&typeof r.setup!=="string")n.push(`${a}: setup is ${JSON.stringify(r.setup)}, not a placeholder name or null`);for(let l of["color","dark","blend"])if(r[l]!==void 0&&typeof r[l]!=="string")n.push(`${a}: ${l} is ${JSON.stringify(r[l])}, not a string`);for(let l of["color","dark"]){let u=r[l];if(typeof u==="string"&&!sM.test(u))n.push(`${a}: ${l} is ${JSON.stringify(u)}, not six or eight hex digits (rrggbb or rrggbbaa) — the only spellings whose reading was measured to be a colour`)}if(typeof r.blend==="string"&&iM(r.blend)===null)n.push(`${a}: blend is ${JSON.stringify(r.blend)}, which the runtime reads as no mode — one of ${rM.join(", ")}, first letter in either case, is the only spelling measured to be one`);s.push(r)}),s}function N$(e,t,n,s,r){let i={};for(let[o,a]of Object.entries(e)){let l=`${s}.attachments["${o}"]`;if(!n.has(o))r.push(`${l}: "${o}" is not a slot of this document`);if(!Ge(a)){r.push(`${l} is not an object`);continue}let u={};for(let[c,h]of Object.entries(a)){let d=`${l}["${c}"]`;if(!Ge(h)){r.push(`${d} is not an object`);continue}let f=Object.keys(ww),m=f.find((g)=>g===h.kind);if(m===void 0){r.push(`${d}: kind is ${JSON.stringify(h.kind)}, none of ${f.join(", ")}`);continue}Wt(h,ww[m],d,r);let p={kind:m};for(let g of["name","path"]){let x=h[g];if(x===void 0)continue;if(typeof x!=="string"||x==="")r.push(`${d}: ${g} is ${JSON.stringify(x)}, not a non-empty string`);else p[g]=x}if(m==="region"&&h.atlas!==void 0){let g=G$(h.atlas,`${d}.atlas`,r);if(g!==void 0)p.atlas=g}let y=QR(h,m,d,t,n,r);if(y!==void 0)p.geometry=y;if(Ge(h.sequence)){let g=h.sequence.count;if(typeof g==="number"&&Number.isInteger(g)&&g>=1)p.sequenceCount=g;else if(m!=="region")r.push(`${d}.sequence: count is ${JSON.stringify(g)}, not a whole number of at least 1`);let x=h.sequence.setup??0;if(typeof x==="number"&&Number.isInteger(x)&&x>=0&&(typeof g!=="number"||x{let a=`skins[${o}]`;if(!Ge(i)){s.push(`${a} is not an object`);return}let l=typeof i.name==="string"?`${a} "${i.name}"`:a;if(Wt(i,P$,l,s),typeof i.name!=="string"||i.name==="")s.push(`${a}: name is ${JSON.stringify(i.name)}, not a non-empty string`);let u=[];if(!Array.isArray(i.bones))s.push(`${l}: bones is not a list`);else i.bones.forEach((d,f)=>{if(typeof d!=="string")s.push(`${l}: bones[${f}] is not a bone name`);else if(!t.has(d))s.push(`${l}: bones[${f}] "${d}" is not a bone of this document`);else u.push(d)});let c=Object.fromEntries(Tr.map((d)=>[d,[]]));if(!Ge(i.constraints))s.push(`${l}: constraints is not an object`);else for(let[d,f]of Object.entries(i.constraints)){let m=Tr.find((p)=>p===d);if(m===void 0)s.push(`${l}.constraints: "${d}" is not a constraint kind; a skin lists ${Tr.join(", ")}`);else if(!Array.isArray(f)||f.some((p)=>typeof p!=="string"))s.push(`${l}.constraints.${d} is not a list of constraint names`);else c[m]=f}let h={};if(!Ge(i.attachments))s.push(`${l}: attachments is not an object`);else h=N$(i.attachments,t,n,l,s);r.push({name:typeof i.name==="string"?i.name:"",bones:u,constraints:c,attachments:h})}),r}function U$(e,t,n,s,r,i){let o=new Set(n.map((l)=>l.name));if(!Array.isArray(e))return i.push("animations is not a list"),[];let a=[];return e.forEach((l,u)=>{let c=`animations[${u}]`;if(!Ge(l)){i.push(`${c} is not an object`);return}if(typeof l.name!=="string"||l.name==="")i.push(`${c}: name is ${JSON.stringify(l.name)}, not a non-empty string`);let h=typeof l.name==="string"?`${c} "${l.name}"`:c,d=[];if(!Array.isArray(l.slots))i.push(`${h}: slots is not a list`);else l.slots.forEach((p,y)=>{if(!Ge(p)||typeof p.name!=="string")i.push(`${h}: slots[${y}] names no slot`);else if(!o.has(p.name))i.push(`${h}: slots[${y}] "${p.name}" is not a slot of this document`);else d.push(p.name)});let f=[],m=(p)=>Array.isArray(p)?p.filter(Ge):[];for(let p of m(l.attachments))for(let y of m(p.slots))for(let g of m(y.attachments))if(g.deform!==void 0)f.push(`${String(p.name)}/${String(y.name)}/${String(g.name)}`);a.push({name:typeof l.name==="string"?l.name:"",slots:d,timelines:y$(l,h,t,n,i,{skins:s,events:r}),constraints:{ik:[],transform:[],path:[],physics:0,slider:[]},deforms:f})}),a}function W$(e,t,n,s,r,i){let o=new Set(n.map((c)=>c.name)),a=new Map(s.map((c)=>[c.name,c.bone])),l=new Map(n.map((c)=>[c.name,c.parent]));if(!Array.isArray(e))return i.push("constraints is not a list"),[];let u=[];return e.forEach((c,h)=>{let d=`constraints[${h}]`;if(!Ge(c)){i.push(`${d} is not an object`);return}let f=Tr.find((y)=>y===c.kind);if(f===void 0)i.push(`${d}: kind is ${JSON.stringify(c.kind)}, none of ${Tr.join(", ")}`);if(typeof c.name!=="string"||c.name==="")i.push(`${d}: name is ${JSON.stringify(c.name)}, not a non-empty string`);if(c.declaredIn!=="rig"&&c.declaredIn!=="motion")i.push(`${d}: declaredIn is ${JSON.stringify(c.declaredIn)}, not "rig" or "motion"`);let m=`${d} "${String(c.name)}"`,p;if(typeof c.name==="string"){if(f==="ik"||f==="transform")p=XP(c,f,c.name,m,o,l,i);else if(f==="path")p=oP(c,c.name,m,o,a,i);else if(f==="physics")p=gP(c,c.name,m,o,r,i);else if(f==="slider")p=AP(c,c.name,m,n,t,i)}if(f!==void 0&&typeof c.name==="string")u.push({kind:f,name:c.name,...f==="slider"&&typeof c.animation==="string"?{animation:c.animation}:{},...p!==void 0?{record:p}:{}})}),u}function X$(e,t="the model document"){let n;try{n=JSON.parse(e)}catch(_){throw new Y(`${t}: not JSON — ${_.message}`)}if(!Ge(n))throw new Y(`${t}: not a JSON object`);if(typeof n.spec!=="string"||!Z1.includes(n.spec))throw new Y(`${t}: spec is ${JSON.stringify(n.spec)}, not "${_r}" (or "${_f}", read without its stage, editor order and page flags, or "${Sf}", read without its pages too)`);let s=n.spec,r=s===_r?Q1:s===_f?eM:T$,i=[];for(let _ of r)if(!(_ in n))i.push(`section "${_}" is missing`);for(let _ of Object.keys(n))if(_!=="spec"&&!r.includes(_))i.push(`section "${_}" is not one a ${s} document has`);let o=s!==Sf&&"pages"in n?$$(n.pages,i,s===_r):null,a=s===_r&&"stage"in n?I$(n.stage,i):null,l=typeof n.referenceScale==="number"&&Number.isFinite(n.referenceScale)?n.referenceScale:NaN;if("referenceScale"in n&&Number.isNaN(l))i.push(`referenceScale is ${JSON.stringify(n.referenceScale)}, not a finite number — wind and gravity act over it`);let u=O$(n.spine,i),c=D$(n.bones,i),h=new Set(c.map((_)=>_.name)),d=F$(n.slots,h,i),f=new Set(d.map((_)=>_.name)),m=L$(n.skins,h,f,i);i.push(...j$(m));let p=BR(n.events,i),y=U$(n.animations,h,d,m,p,i),g=W$(n.constraints,y,c,d,l,i);for(let _ of m)for(let S of Tr)for(let M of _.constraints[S])if(!g.some((k)=>k.kind===S&&k.name===M))i.push(`skin "${_.name}".constraints.${S}: "${M}" is not a ${S} constraint of this document — the runtime refuses the file ("Couldn't find … constraint ${M} for skin ${_.name}.")`);if(Array.isArray(n.animations))n.animations.forEach((_,S)=>{if(Ge(_)&&y[S]!==void 0)y[S].constraints=YP(_.constraints,`animations[${S}] "${y[S].name}"`,g,i)});for(let _ of g){let S=_.record;if(S?.kind==="slider")S.physics=y.find((M)=>M.name===S.animation)?.constraints.physicsKeyed??[]}let x=s===_r&&"editorOrder"in n?B$(n.editorOrder,m,y,i):null;if(i.length>0)throw new Y(`${t}: ${i.length} problem(s): ${i.join("; ")}`);let v={spec:s,skin:_s,referenceScale:l,bones:c,slots:d,skins:m,constraints:g,animations:y,spine:{sha256:u},pages:o,stated:x===null?null:{stage:a,editorOrder:x}};return em(v),v}function kf(e,t){if(t!==_s&&!e.skins.some((s)=>s.name===t))throw new Y(`--skin ${JSON.stringify(t)}: no such skin; this document declares [${e.skins.map((s)=>s.name).join(", ")||"none"}] (or pass ${_s})`);let n={...e,skin:t,constraints:e.constraints.map((s)=>s.record===void 0?s:{...s,record:{...s.record}})};return em(n),n}function Tw(e){let t={...e,skin:null,constraints:e.constraints.map((n)=>n.record===void 0?n:{...n,record:{...n.record}})};return em(t),t}function em(e){for(let t of e.constraints)if(t.record!==void 0)t.record.listedBySkin=SR(e,t.kind,t.name);for(let t of e.constraints){let n=t.record;if(n?.kind!=="path")continue;n.path=null,n.unresolved=null;let s=e.slots.find((a)=>a.name===n.slot),r=vn(e,s),i=s.setup===null?[]:Uf(e,s.name,s.setup).flatMap((a)=>{let l=e.skins.find((u)=>u.name===a)?.attachments[s.name]?.[s.setup]?.geometry;return l===void 0?[]:[{skin:a,g:JSON.stringify(l)}]});if(i.length>1&&i.some((a)=>a.g!==i[0].g))n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${i.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&"conflict"in r)n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${r.conflict.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&r.record.geometry?.kind==="path"){let a=r.record.geometry;n.path={vertices:a.vertices,closed:a.closed,constantSpeed:a.constantSpeed,lengths:a.lengths}}let o=[];for(let a of Lf(e))for(let l of Object.values(a.attachments[n.slot]??{})){let u=l.geometry;if(u?.kind!=="path")continue;for(let c of u.vertices.weighted?u.vertices.bindings.flatMap((h)=>h.map((d)=>d.bone)):[n.slotBone])if(!o.includes(c))o.push(c)}n.slotDeps=o}}function j$(e){let t=[];return e.forEach((n,s)=>{for(let[r,i]of Object.entries(n.attachments))for(let[o,a]of Object.entries(i)){let l=a.geometry;if(l?.kind!=="linkedmesh")continue;let u=aM(e,l.skin,l.slot,l.source);if(u!==null)t.push(`skins[${s}] "${n.name}".attachments["${r}"]["${o}"]: ${u}`)}}),t}function aM(e,t,n,s){let r=e.find((o)=>o.name===t);if(r===void 0)return`the linked mesh's skin "${t}" is not a skin of this document`;let i=r.attachments[n]?.[s];if(i===void 0)return`the linked mesh's source "${s}" is not in skin "${t}" slot "${n}"`;if(i.kind!=="mesh")return`the linked mesh's source "${s}" in skin "${t}" slot "${n}" is a ${i.kind}, not a mesh`;return null}function qi(e){if(!Number.isFinite(e))return null;let t=Math.round(e*1e6)/1e6;return t===0?0:t}function Yi(e){if(!Number.isFinite(e))return null;return e===0?0:e}function Vi(e){return e.constraints.flatMap((t)=>t.record===void 0?[]:[t.record])}var Y$=[],V$=["setup.bones","setup.slots","setup.drawOrder","setup.attachments","setup.clips","setup.clipped"],Cw=new WeakMap;function At(e){let t=Cw.get(e);if(t!==void 0)return t;let n=H$(e);return Cw.set(e,n),n}function H$(e){let t=new Set(c1(e).flatMap((r)=>r.bones)),n=new Map(e.bones.map((r)=>[r.name,r.parent])),s=new Set;for(let r of t)for(let i=r;i!==void 0&&!s.has(i);i=n.get(i))s.add(i);return new Set(e.bones.filter((r)=>r.skinRequired!==!0||s.has(r.name)).map((r)=>r.name))}function Hi(e){let t=(n)=>Number.parseInt(e.slice(2*n,2*n+2),16)/255;return[t(0),t(1),t(2),e.length===8?t(3):1]}var Aw=new WeakMap;function tm(e){let t=Aw.get(e);if(t===void 0)t=new Map,Aw.set(e,t);let n=t;return(s)=>{let r=n.get(s);if(r===void 0)r=Hi(s),n.set(s,r);return r}}var rc=[1,1,1,1];function nm(e){if(e.blend===void 0)return"Normal";let t=iM(e.blend);if(t===null)throw new Y(`slot "${e.name}": blend ${JSON.stringify(e.blend)} is no mode the runtime reads`);return t}function Ki(e){let t=e.record.name??e.placeholder;return{name:t,path:nM.has(e.record.kind)?e.record.path??t:null}}var Ew=new WeakMap;function vn(e,t,n=t.setup){if(n===null)return null;let s=Ew.get(e);if(s===void 0)s=new Map,Ew.set(e,s);let r=s.get(t.name);if(r===void 0)r=new Map,s.set(t.name,r);if(r.has(n))return r.get(n);let i=z$(e,t.name,n);return r.set(n,i),i}function z$(e,t,n){if(e.skin!==_s){for(let o of Lf(e)){let a=o.attachments[t]?.[n];if(a!==void 0)return{skin:o.name,placeholder:n,record:a}}return null}let s=[];for(let o of e.skins){let a=o.attachments[t]?.[n];if(a!==void 0)s.push({skin:o.name,placeholder:n,record:a})}if(s.length===0)return null;let r=s.map((o)=>({skin:o.skin,...Ki(o)}));return r.every((o)=>o.name===r[0].name&&o.path===r[0].path)?s[0]:{conflict:r.map((o)=>({skin:o.skin,shown:o.name,path:o.path}))}}function sm(e,t={},n){let s=t.evaluate??Li,r=t.shown??vn,i=t.colour??Hi,o=t.blend??nm,a=t.round??qi,l=tc(e,ji(t.solver)),u=null,c=null,h=[];if(l===null){let I=At(e),F=Vi(e);c=ql(e.bones,s(e.bones,I),I,t.constraints?t.constraints(F):F,null,h,n,void 0,ji(t.solver));let B=c;u=e.bones.map((C)=>{let D=B.get(C.name);if(D===void 0)throw new Y(`the evaluator returned no transform for bone "${C.name}"`);return[C.name,a(D.worldX),a(D.worldY),a(D.a),a(D.b),a(D.c),a(D.d),I.has(C.name)?1:0,C.parent??null]})}let d=[],f=[],m=At(e),p=t.slotTimelines??ec;for(let I of e.slots){let F={placeholder:I.setup,light:I.color===void 0?[1,1,1,1]:[...i(I.color)],dark:I.dark===void 0?null:Hi(I.dark).slice(0,3)};if(p(e,I,m))I1(I.name,F,h);let B={...I,setup:F.placeholder},C=F.placeholder===null?null:r(e,B);if(C!==null&&"conflict"in C){d.push(`slot "${I.name}" placeholder "${F.placeholder}" is filled by skins ${C.conflict.map((K)=>`"${K.skin}" (shows ${JSON.stringify(K.shown)}, path ${JSON.stringify(K.path)})`).join(", ")}`);continue}let D=C===null?null:Ki(C),[N,G,z,q]=F.light,L=F.dark;f.push([I.name,D===null?null:D.name,a(N),a(G),a(z),a(q),L===null?null:[a(L[0]),a(L[1]),a(L[2])],D===null?null:D.path,o(I)])}let y=(l===null?null:K$(e))??(d.length===0?null:`${d.join("; ")} — under --skin all the LAST of them in the Spine file's skin order wins, and that order is the emitter's (default first, the rest in the editor's order), not the model's; the per-skin dumps (--skin ) judge it`),g=y===null?f:null,x=[l===null?null:`setup.bones is absent (${l}), and every vertex goes through a bone's world matrix`,y===null?null:"setup.slots is absent, so what a slot shows is not posed"].filter((I)=>I!==null),b=l===null?null:q$(e,"drawOrder"),v=null;if(b===null){let I=e.slots.map((F,B)=>B);for(let F of h)I=(t.drawOrder??p1)(e.slots.length,F.timelines.drawOrder,F.at)??I;v=I.map((F)=>e.slots[F].name)}let _=null,S=null,M=x.length===0?null:x.join("; "),k=M,T=null,A=M??b,O=null;if(M===null&&c!==null&&v!==null){let I=c,F=new Map(e.slots.map((z)=>[z.name,z.setup])),B=m1(e,r,F,null,h,t),C=new Map(v.map((z,q)=>[z,q])),D=[...B.shown].sort((z,q)=>(C.get(z.slot)??0)-(C.get(q.slot)??0));O=B.why.length===0?D:null;let N=A1(D,I,rm(e),a,{region:t.region,vertices:t.vertices},lM(e,v,t)),G=B.why.length===0?null:`${B.why.join("; ")}`;_=G===null?N.attachments:null,k=G??N.attachmentsWhy,S=G===null?N.clips:null,M=G,T=G===null?N.clipped:null,A=G??N.clippedWhy}let R={"setup.bones":l,"setup.slots":y,"setup.drawOrder":b,"setup.attachments":k,"setup.clips":M,"setup.clipped":A},P=Y$.map(([I,F])=>[I,F]);for(let I of V$)if(R[I]!==null)P.push([I,R[I]]);return{setup:{bones:u,slots:g,drawOrder:v,attachments:_,clips:S,clipped:T},absent:P,world:c,shown:O}}function lM(e,t,n={}){let s=At(e);return{order:t,active:s,meshOf:(r,i,o)=>{let a=e.skins.find((l)=>l.name===r)?.attachments[i]?.[o]?.geometry;return a?.kind==="mesh"?{uvs:a.uvs,triangles:a.triangles}:void 0},...n.clip===void 0?{}:{clip:n.clip},...n.through===void 0?{}:{through:n.through}}}function rm(e){return(t,n,s)=>{let r=e.skins.find((i)=>i.name===t)?.attachments[n]?.[s]?.geometry;return r?.kind==="mesh"?r.vertices:aM(e.skins,t,n,s)??`the linked mesh's source "${s}" carries no vertices`}}function q$(e,t){let n=e.constraints.flatMap((s)=>{if(s.kind!=="slider")return[];let r=e.animations.find((i)=>i.name===s.animation);return r!==void 0&&r.timelines[t].length>0?[`slider "${s.name}" applies animation "${s.animation}", which keys the draw order`]:[]});return n.length===0?null:`${n.join("; ")} — a slider's time is read off the bones, which are absent`}function K$(e){let t=e.constraints.flatMap((n)=>{if(n.kind!=="slider")return[];let s=e.animations.find((r)=>r.name===n.animation)?.slots??[];return s.length===0?[]:[`slider "${n.name}" applies animation "${n.animation}", which keys slot(s) ${s.map((r)=>`"${r}"`).join(", ")}`]});return t.length===0?null:`${t.join("; ")} — the oracle's setup applies sliders, and a slider poses the slots its animation keys at a time read off the bones, which are absent`}function cM(e,t){let n=new Map(t.map((s,r)=>[s,r]));return[...e].sort((s,r)=>(n.get(s.slot)??0)-(n.get(r.slot)??0))}function wf(e,t){if(e===null)throw new Y(`the raw pose computed a non-finite ${t}`);return e}var Di={loop:!1,keep:!1},uM=(e)=>e,Kl=(e)=>({round:e.keep?uM:Yi});function J$(e,t,n){return n.keep?e===null?Number.NaN:e:wf(e,t)}var Z$=()=>null;function Mf(e,t){let n=At(e);return e.bones.map((s)=>{let r=t.get(s.name);if(r===void 0)throw new Y(`bone "${s.name}" has no world transform`);return{name:s.name,parent:s.parent??null,active:n.has(s.name),a:r.a,b:r.b,c:r.c,d:r.d,worldX:r.worldX,worldY:r.worldY,rotationX:Math.atan2(r.c,r.a)*zl,rotationY:Math.atan2(r.d,r.b)*zl,scaleX:Math.sqrt(r.a*r.a+r.c*r.c),scaleY:Math.sqrt(r.b*r.b+r.d*r.d)}})}function Q$(e,t,n,s,r,i){let o=lM(e,s,r),a=A1(t,n,rm(e),i.keep?uM:Yi,{region:r.region,vertices:r.vertices,deformedVertices:r.deformedVertices},i.loop&&i.live!==!0&&r.through===void 0?{...o,through:Z$}:o);if(a.attachments===null)throw new Y(`the raw pose leaves the attachments out: ${a.attachmentsWhy}`);if(a.drawnClipped===null)throw new Y(`the raw pose leaves the clipped triangles out: ${a.drawnClippedWhy}`);return{rows:a.attachments,clips:a.clips,drawnClipped:a.drawnClipped}}function El(e,t,n){return e2(e)?e:e.map((s)=>J$(s,t,n))}function e2(e){for(let t of e)if(t===null)return!1;return!0}function Tf(e,t,n,s,r,i=Di){let o=r.stage;if(o!==void 0)o.begin("geometry");let a=Q$(e,t,n,s,r,i);if(o!==void 0)o.end("geometry"),o.begin("readout");let l=a.rows,u=[],c=tm(e),h=0;for(let m of t){let p=m.geometry;if(p.kind!=="region"&&p.kind!=="mesh"&&p.kind!=="linkedmesh")continue;let y=l[h++];if(y===void 0||y[0]!==m.slot)throw new Y(`slot "${m.slot}": the attachment rows are not in the shown records' order`);let g=e.skins.find((k)=>k.name===m.skin)?.attachments[m.slot]?.[m.placeholder],x=g?.color===void 0?rc:c(g.color),b=[x[0],x[1],x[2],x[3]],v,_,S=null;if(p.kind==="region")v=_1,_=Yf;else{let k=p.kind==="mesh"?p:e.skins.find((T)=>T.name===p.skin)?.attachments[p.slot]?.[p.source]?.geometry;if(k===void 0||k.kind!=="mesh")throw new Y(`slot "${m.slot}": the linked mesh's source carries no mesh`);({uvs:v,triangles:_}=(r.meshArrays??VR)(k)),S=k.hull??null}let M=m.frame??g?.sequenceSetup??0;u.push({slot:m.slot,attachment:y[1],kind:y[2],vertices:El(y[3],`vertex of slot "${m.slot}"`,i),uvs:v,triangles:_,hull:S,sequenceIndex:M,colour:b})}let d=a.clips.map((m)=>[m[0],m[1],m[2],El(m[3],`clip vertex of slot "${m[0]}"`,i)]),f=a.drawnClipped.map((m)=>[m[0],m[1],m[2],El(m[3],`clipped vertex of slot "${m[0]}"`,i),El(m[4],`clipped uv of slot "${m[0]}"`,i),m[5]]);if(o!==void 0)o.end("readout");return{drawn:u,clips:d,clipped:f}}function jn(e,t={}){return t2(e,t,Di)}function t2(e,t,n){let{world:s,shown:r,slots:i,drawOrder:o}=n2(e,t,n),a=Tf(e,r,s,o,t,n);return{trackTime:0,animationTime:0,bones:Mf(e,s),slots:i,drawOrder:o,...a,events:[],shown:cM(r,o)}}function n2(e,t,n){let s=sm(e,{...t,...Kl(n)},Kf(t.physicsStep)),r=s.absent.filter(([l])=>l!=="setup.clipped");if(r.length>0)throw new Y(`the raw setup pose leaves ${r.map(([l,u])=>`${l} out (${u})`).join("; ")}`);let{setup:i,world:o,shown:a}=s;if(o===null||a===null||i.slots===null||i.drawOrder===null)throw new Y("the raw setup pose was not posed");return{world:o,shown:a,slots:i.slots,drawOrder:i.drawOrder}}var s2=0.0000000009313225746154785;function Ln(e){return e+e*s2}function hM(e,t){return(n)=>{let s=e(n);if(typeof s!=="number"||!Number.isFinite(s)||s<0)throw new Y(`${t} clock moved the physics by ${String(s)} for a step of ${n}, not a finite time at or above 0`);return s}}function dM(e,t,n){if(typeof t!=="object"||t===null||Array.isArray(t))throw new Y(`${n} setEnvironment was given ${t===null?"null":Array.isArray(t)?"an array":typeof t}, not an object { wind?: [x, y], gravity?: [x, y] }`);let s=t;for(let l of Object.keys(s))if(l!=="wind"&&l!=="gravity")throw new Y(`${n} setEnvironment names "${l}", which is not one of [wind, gravity]`);let r=(l)=>{let u=s[l];if(u===void 0)return;if(!Array.isArray(u)||u.length!==2||u.some((c)=>typeof c!=="number"||!Number.isFinite(c)))throw new Y(`${n} setEnvironment's ${l} is ${JSON.stringify(u)}, not a pair of finite numbers [x, y] (x to the right, y down)`);return Object.freeze([u[0],u[1]])},i=r("wind"),o=r("gravity"),a=e.env??zf;e.env=Object.freeze({wind:i??a.wind,gravity:o??a.gravity})}function fM(e){return e.env??zf}function mM(e,t,n,s){for(let[r,i]of[["x",t],["y",n]])if(typeof i!=="number"||!Number.isFinite(i))throw new Y(`${s} physicsTranslate's ${r} is ${String(i)}, not a finite distance in the skeleton's world`);SP(e,t,n)}function pM(e,t,n,s,r){for(let[i,o]of[["x",t],["y",n],["degrees",s]])if(typeof o!=="number"||!Number.isFinite(o))throw new Y(`${r} physicsRotate's ${i} is ${String(o)}, not a finite number`);kP(e,t,n,s)}function r2(e,t){return t===0?0:e%t}var Cf={setup:(e,t,n,s,r,i,o)=>({trackTime:0,animationTime:0,bones:Mf(e,t),slots:n,drawOrder:s,...Tf(e,r,t,s,i,o),events:[],shown:cM(r,s)}),step:(e,t,n,s)=>{let r=Tf(e,t.shown,t.world,t.drawOrder,n,s),i=n.stage;if(i!==void 0)i.begin("readout");let o=t.events(),a={trackTime:t.trackTime,animationTime:t.animationTime,bones:Mf(e,t.world),slots:t.slots,drawOrder:t.drawOrder,...r,events:o,shown:t.shown};if(i!==void 0)i.end("readout");return a}};function i2(e,t){let n=e.animations.find((s)=>s.name===t);if(n===void 0)throw new Y(`animation "${t}" is not one of this document's [${e.animations.map((s)=>s.name).join(", ")}]`);return n}function o2(e,t,n,s,r,i,o,a){let l=tc(e)??L1(e)??$1(e);if(l!==null)throw new Y(`the raw walk leaves the bones out: ${l}`);let u=Kf(n.physicsStep);if(a?.(u),r.loop&&r.wrapResets!==!1)u.loop=!0;let c={doc:e,anim:t,duration:t.timelines.duration,mode:r,plant:n,raw:{...n,...Kl(r)},resolve:n.shown??vn,shape:i,ctx:u,adjust:o,trackTime:0,last:-1};if(s==="setup"){let h=sm(e,{...n,...Kl(r)},u),d=h.absent.filter(([f])=>f!=="setup.clipped");if(d.length>0)throw new Y(`the raw walk's reset pose leaves ${d.map(([f,m])=>`${f} out (${m})`).join("; ")}`);if(h.world===null||h.shown===null||h.setup.slots===null||h.setup.drawOrder===null)throw new Y("the raw walk's reset pose was not posed");return u.phase="update",{track:c,first:i.setup(e,h.world,h.setup.slots,h.setup.drawOrder,h.shown,n,r)}}return{track:c,first:gM(c,0,!0)}}function gM(e,t,n=!1){let{doc:s,anim:r,duration:i,mode:o,plant:a,raw:l,resolve:u,shape:c,ctx:h,adjust:d}=e;e.trackTime+=t;let{trackTime:f,last:m}=e,p=o.loop?(o.time??r2)(f,i,f-t):fk$(s,r.timelines,p,l,r.constraints,_,{ctx:h,before:y,adjustment:b}),slots:(_,S)=>S$(s,r.timelines,p,l,_,S),drawOrder:r.timelines.drawOrder,at:p,sample:{timelines:r.timelines,t:p},events:()=>o.loop&&o.live!==!0?[]:o.loop?g(x,m,p,Yi,p0)throw new Y(`the raw walk leaves the slots out: ${m.conflicts.join("; ")}`);let p=t.drawOrder??p1,g=p(e.slots.length,u.drawOrder,u.at)??e.slots.map((M,k)=>k);for(let M of h)g=p(e.slots.length,M.timelines.drawOrder,M.at)??g;let x=g.map((M)=>e.slots[M].name);if(c!==void 0)c.end("readout"),c.begin("timeline");let b=m1(e,n,f,u.sample,h,t,u.mixed);if(c!==void 0)c.end("timeline");if(b.why.length>0)throw new Y(`the raw walk leaves the attachments out: ${b.why.join("; ")}`);if(c!==void 0)c.begin("readout");let v=new Map(x.map((M,k)=>[M,k])),_=[...b.shown].sort((M,k)=>(v.get(M.slot)??0)-(v.get(k.slot)??0));if(c!==void 0)c.end("readout");let S=()=>u.events().map((M)=>[M[0],wf(M[1],"event time"),M[2],wf(M[3],"event float"),M[4]]);return s.step(e,{trackTime:a,animationTime:l,world:d,slots:m.rows,drawOrder:x,shown:_,events:S},t,r)}function a2(e,t){let n=tc(e)??L1(e)??$1(e);if(n!==null)throw new Y(`the raw walk leaves the bones out: ${n}`);let s=Kf(t.physicsStep),r={...t,...Kl(Di)},i=t.shown??vn;return{ctx:s,raw:r,setupPose:()=>{let o=sm(e,r,s),a=o.absent.filter(([l])=>l!=="setup.clipped");if(a.length>0)throw new Y(`the raw walk's reset pose leaves ${a.map(([l,u])=>`${l} out (${u})`).join("; ")}`);if(o.world===null||o.shown===null||o.setup.slots===null||o.setup.drawOrder===null)throw new Y("the raw walk's reset pose was not posed");return s.phase="update",Cf.setup(e,o.world,o.setup.slots,o.setup.drawOrder,o.shown,t,Di)},step:(o,a,l,u)=>yM(e,t,i,Cf,Di,s,o,a,l,u)}}function l2(e,t,n,s,r,i,o){return o2(e,i2(e,t),n,s,r,Cf,i,o)}function c2(e,t){return gM(e,t)}var Qd=["strength","damping","inertia","wind","gravity","mix"],u2=(e)=>({strength:e.strength,damping:e.damping,inertia:e.inertia,wind:e.wind,gravity:e.gravity,mix:e.mix});class im{constructor(e){this.doc=e,this.overrides=new Map,this.evaluated=new Map}named(e){let t=this.doc.constraints.find((n)=>n.name===e);if(t===void 0)throw new Y(`physics parameters: no constraint "${String(e)}"; this document declares [${this.doc.constraints.map((n)=>n.name).join(", ")}]`);if(t.kind!=="physics")throw new Y(`physics parameters: constraint "${e}" is ${t.kind}, not physics`)}set(e,t){if(this.named(e),typeof t!=="object"||t===null||Array.isArray(t))throw new Y(`physics parameters: constraint "${e}" patch is ${String(t)}, not an object of finite fields [${Qd.join(", ")}]`);let n={};for(let s of Reflect.ownKeys(t)){if(typeof s!=="string"||!Qd.includes(s))throw new Y(`physics parameters: constraint "${e}" field "${String(s)}" is unknown; expected [${Qd.join(", ")}]`);let r=s,i=t[r];if(typeof i!=="number"||!Number.isFinite(i))throw new Y(`physics parameters: constraint "${e}" field "${r}" is ${String(i)}, not a finite number`);n[r]=i}if(Reflect.ownKeys(n).length>0)this.overrides.set(e,{...this.overrides.get(e),...n})}read(e){this.named(e);let t=this.overrides.get(e),n=this.evaluated.get(e);return{override:t===void 0?null:{...t},effective:n===void 0?null:{...n}}}clear(e){this.named(e),this.overrides.delete(e)}apply(e){let t=this.overrides.get(e.name),n=t===void 0?e:{...e,...t};return this.evaluated.set(e.name,u2(n)),n}}var h2={loop:!1,keep:!1},d2={loop:!0,keep:!1,live:!0};function Ri(e,t,n,s={}){if(typeof n!=="object"||n===null||typeof n.loop!=="boolean")throw new Y(`the live track's options.loop is ${JSON.stringify(n?.loop)}, not true or false`);if(n.reset!=="animation"&&n.reset!=="setup")throw new Y(`the live track's options.reset is ${JSON.stringify(n.reset)}, not "animation" or "setup"`);if(n.adjust!==void 0&&typeof n.adjust!=="function")throw new Y(`the live track's options.adjust is ${typeof n.adjust}, not a function`);if(n.clock!==void 0&&typeof n.clock!=="function")throw new Y(`the live track's options.clock is ${typeof n.clock}, not a function`);let r=n.loop?d2:h2,i=n.clock===void 0?void 0:hM(n.clock,"the live track's"),o=new im(e),{track:a,first:l}=l2(e,t,s,n.reset,i===void 0?r:{...r,clock:(u)=>i(u)},n.adjust,(u)=>{u.parameters=o});return new xM(a,l,o)}class xM{constructor(e,t,n){this.parameters=n,this.steps=0,this.refused=null,this.track=e,this.first=t,this.latest=t.animationTime}get trackTime(){return this.track.trackTime}get animationTime(){return this.latest}get duration(){return this.track.duration}get environment(){return fM(this.track.ctx)}setEnvironment(e){this.live("setEnvironment"),dM(this.track.ctx,e,"the live track's")}setPhysicsParameters(e,t){this.live("setPhysicsParameters"),this.parameters.set(e,t)}readPhysicsParameters(e){return this.parameters.read(e)}clearPhysicsParameters(e){this.live("clearPhysicsParameters"),this.parameters.clear(e)}physicsTranslate(e,t){this.live("physicsTranslate"),mM(this.track.ctx,e,t,"the live track's")}physicsRotate(e,t,n){this.live("physicsRotate"),pM(this.track.ctx,e,t,n,"the live track's")}live(e){if(this.refused!==null)throw new Y(`the live track was refused at step ${this.refused}, after its time and physics had moved; open the track again (${e} not made)`)}step(e){let t=this.steps+1;if(this.refused!==null)throw new Y(`the live track was refused at step ${this.refused}, after its time and physics had moved; open the track again`);if(typeof e!=="number"||!Number.isFinite(e)||e<0)throw new Y(`the live track's step ${t} is ${String(e)}, not a finite time at or above 0`);try{let n=c2(this.track,e);return this.steps=t,this.latest=n.animationTime,n}catch(n){throw this.refused=`${t} (${n instanceof Error?n.message:String(n)})`,n}}}var ps=0,$e=1,xn=2,Rw=3,Rl=4,Pw={name:null,duration:0,timelines:[],ids:new Set};function ef(e){return e.type==="deform"||e.type==="bone"&&e.kind!=="inherit"}var f2={rotate:["rotate"],translate:["x","y"],translatex:["x"],translatey:["y"],scale:["scaleX","scaleY"],scalex:["scaleX"],scaley:["scaleY"],shear:["shearX","shearY"],shearx:["shearX"],sheary:["shearY"],inherit:["inherit"]},m2={rgba:["rgb","alpha"],rgb:["rgb"],alpha:["alpha"],rgba2:["rgb","alpha","rgb2"],rgb2:["rgb","rgb2"]};function p2(e,t){let n=e.animations.find((u)=>u.name===t);if(n===void 0)throw new Y(`animation "${t}" is not one of this document's [${e.animations.map((u)=>u.name).join(", ")}]`);let{timelines:s,constraints:r}=n,i=[];for(let[u,c]of[["ik",r.ik.length],["transform",r.transform.length],["path",r.path.length],["physics",r.physics+(r.physicsKeyed?.length??0)],["slider",r.slider.length]])if(c>0)i.push(`${u} constraint timelines`);if(s.attachments.some((u)=>u.sequence!==null))i.push("a sequence timeline");if(s.drawOrder.length>0)i.push("the draw order");for(let u of s.attachments){if(u.deform===null)continue;if(e.skins.find((h)=>h.name===u.skin)?.attachments[u.slot]?.[u.attachment]?.geometry?.kind==="path")i.push(`a deform of path attachment "${u.skin}/${u.slot}/${u.attachment}"`)}if(i.length>0)throw new Y(`animation "${t}" keys ${i.join(", ")}, which the live tracks do not mix — they mix bone, slot colour, attachment and deform timelines, and fire events (issue #1336)`);let o=new Map(e.bones.map((u,c)=>[u.name,c])),a=new Map(e.slots.map((u,c)=>[u.name,c])),l=[];for(let u of s.slots){let c=a.get(u.name);for(let h of u.timelines)if(h.kind==="attachment")l.push({type:"attachment",slot:c,keys:h.keys,ids:[`attachment|${u.name}`],instant:!0});else l.push({type:"colour",slot:c,kind:h.kind,keys:h.keys,ids:m2[h.kind].map((d)=>`${d}|${u.name}`),instant:!1})}for(let u of s.bones){let c=o.get(u.name);for(let h of u.timelines)l.push({type:"bone",bone:c,kind:h.kind,keys:h.keys,ids:f2[h.kind].map((d)=>`${d}|${u.name}`),instant:h.kind==="inherit"})}for(let u of s.attachments){if(u.deform===null)continue;let c=`${u.skin}/${u.slot}/${u.attachment}`;l.push({type:"deform",identity:c,timeline:u,ids:[`deform|${u.slot}|${c}`],instant:!1})}if(s.events.length>0)l.push({type:"events",keys:s.events,ids:["event"],instant:!0});return{name:t,duration:s.duration,timelines:l,ids:new Set(l.flatMap((u)=>u.ids))}}function $w(e,t){return{anim:e,loop:t,previous:null,next:null,mixingFrom:null,mixingTo:null,delay:0,trackTime:0,trackLast:-1,nextTrackLast:-1,trackEnd:Number.MAX_VALUE,animationLast:-1,nextAnimationLast:-1,mixTime:0,mixDuration:0,totalAlpha:0,alpha:1,additive:!1,keepHold:!1,timelineMode:[],timelineHoldMix:[],timelinesRotation:[]}}function Af(e){if(!e.loop)return Math.min(e.trackTime+0,e.anim.duration);let t=e.anim.duration;if(t===0)return 0;return e.trackTime%t+0}function g2(e){let t=e.anim.duration;if(t!==0){if(e.loop)return t*(1+(e.trackTime/t|0));if(e.trackTimee>0?1:e<0?-1:0,$i=(e)=>e<0?0:e>1?1:e,y2=[0,0,0],x2=0,Ow=1,Iw=2;class bM{constructor(e,t){this.doc=e,this.plant=t,this.events=[],this.resolved=new Map,this.bones=[...e.bones],this.active=At(e);let n=tm(e);this.stated=n;let s=t.colour??n,r=t.slotTimelines??ec;this.live=e.slots.map((i)=>r(e,i,this.active)),this.slots=e.slots.map((i)=>{let o=i.dark===void 0?null:n(i.dark),a=i.color===void 0?rc:s(i.color);return{placeholder:i.setup,light:[a[0],a[1],a[2],a[3]],dark:o===null?null:[o[0],o[1],o[2]],deform:null,seen:[],attachmentState:x2}})}bone(e){let t=this.bones[e];if(!this.active.has(t.name))return null;if(t===this.doc.bones[e])this.bones[e]={...t};return this.bones[e]}slotLive(e){return this.live[e]}resolve(e,t){if(t===null)return{key:null,vertex:!1,timeline:null,vertices:null};let n=this.doc.slots[e],s=`${e}\x00${t}`,r=this.resolved.get(s);if(r!==void 0)return r;let i=(this.plant.shown??vn)(this.doc,{...n,setup:t}),o;if(i===null)o={key:null,vertex:!1,timeline:null,vertices:null};else if("conflict"in i)o={key:`conflict\x00${t}`,vertex:!1,timeline:null,vertices:null};else o=b2(this.doc,n,i);return this.resolved.set(s,o),o}setAttachment(e,t){let n=this.slots[e],s=this.resolve(e,n.placeholder),r=this.resolve(e,t);if(n.placeholder=t,s.key===r.key)return;if(!r.vertex||!s.vertex||r.timeline!==s.timeline)n.deform=null}}function b2(e,t,n){let s=n.record.geometry,r=`${n.skin}\x00${n.placeholder}`;if(s===void 0||s.kind==="region")return{key:r,vertex:!1,timeline:null,vertices:null};if(s.kind==="linkedmesh"){let i=e.skins.find((a)=>a.name===s.skin)?.attachments[s.slot]?.[s.source]?.geometry,o=i!==void 0&&i.kind!=="region"&&i.kind!=="linkedmesh"?i.vertices:null;return{key:r,vertex:!0,timeline:n.record.timelines===!0?`${s.skin}/${s.slot}/${s.source}`:`${n.skin}/${t.name}/${n.placeholder}`,vertices:o}}return{key:r,vertex:!0,timeline:`${n.skin}/${t.name}/${n.placeholder}`,vertices:s.vertices}}class vM{constructor(e,t){this.doc=e,this.plant=t,this.tracks=[],this.animationsChanged=!1,this.propertyIds=new Map,this.anims=new Map}animation(e){let t=this.anims.get(e);if(t===void 0)t=p2(this.doc,e),this.anims.set(e,t);return t}changed(){this.animationsChanged=!0}expandToIndex(e){while(this.tracks.length<=e)this.tracks.push(null);return this.tracks[e]}clearNext(e){e.next=null}setTrack(e,t){let n=this.expandToIndex(e);if(this.tracks[e]=t,t.previous=null,n!==null)n.next=null,t.mixingFrom=n,n.mixingTo=t,t.mixTime=0,n.timelinesRotation.length=0;this.changed()}setAnimation(e,t,n){let s=this.expandToIndex(e);if(s!==null)if(s.nextTrackLast===-1&&s.anim===t)this.tracks[e]=s.mixingFrom,this.changed(),this.clearNext(s),s=s.mixingFrom;else this.clearNext(s);let r=$w(t,n);return this.setTrack(e,r),r}addAnimation(e,t,n,s){let r=this.expandToIndex(e);if(r!==null)while(r.next!==null)r=r.next;let i=$w(t,n);if(r===null){if(this.setTrack(e,i),s<0)s=0}else if(r.next=i,i.previous=r,s<=0)s=Math.max(s+this.complete(r)-i.mixDuration,0);return i.delay=s,i}setMixDuration(e,t,n){if(e.mixDuration=t,n<=0)n=e.previous===null?0:Math.max(n+this.complete(e.previous)-t,0);e.delay=n}complete(e){return this.plant.queueDelayNow===!0?e.trackTime:g2(e)}mixOf(e){let t;if(e.mixDuration===0)t=1;else if(t=e.mixTime/e.mixDuration,t>=1)t=1;return this.plant.mixReversed===!0?1-t:t}alphaOf(e){if(this.plant.alphaIgnored===!0)return 1;return this.plant.alphaInverted===!0?1-e.alpha:e.alpha}additiveOf(e){return e.additive&&this.plant.additiveAsReplace!==!0}holdsAdditive(e){return e!==null&&this.additiveOf(e)&&this.plant.additiveHeld!==!0}update(e){let t=this.tracks;for(let n=0,s=t.length;n0){if(r.delay-=i,r.delay>0)continue;i=-r.delay,r.delay=0}let o=r.next;if(o!==null){let a=r.trackLast-o.delay;if(a>=0){o.delay=0,o.trackTime+=a+e,r.trackTime+=i,this.setTrack(n,o);while(o.mixingFrom!==null)o.mixTime+=e,o=o.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&r.mixingFrom===null){t[n]=null,this.changed(),this.clearNext(r);continue}if(r.mixingFrom!==null&&this.updateMixingFrom(r,e)){let a=r.mixingFrom;if(r.mixingFrom=null,a!==null)a.mixingTo=null;this.changed()}r.trackTime+=i}}updateMixingFrom(e,t){let n=e.mixingFrom;if(n===null)return!0;let s=this.updateMixingFrom(n,t);if(n.animationLast=n.nextAnimationLast,n.trackLast=n.nextTrackLast,e.nextTrackLast!==-1&&e.mixTime>=e.mixDuration){if(n.totalAlpha===0||e.mixDuration===0){if(e.mixingFrom=n.mixingFrom,n.mixingFrom!==null)n.mixingFrom.mixingTo=e;if(n.totalAlpha===0)for(let r=e;r.mixingTo!==null;r=r.mixingTo)r.keepHold=!0;this.changed()}return s}return n.trackTime+=t,e.mixTime+=t,!1}apply(e){if(this.animationsChanged)this.computeModes();let t=0,n=this.tracks;for(let s=0,r=n.length;s0)continue;let o=this.alphaOf(i);if(i.mixingFrom!==null)o*=this.applyMixingFrom(i,e,s);else if(i.trackTime>=i.trackEnd&&i.next===null)o=0;let a=i.animationLast,l=Af(i),u=i.anim.timelines,c=u.length;if(s===0&&o===1)for(let h of u)if(h.type==="attachment")this.applyAttachment(e,h,l,$e,!0);else this.applyTimeline(e,h,a,l,!0,1,$e,!1,!1);else{let h=i.timelineMode,d=this.plant.attachmentsBelowHalfAlpha===!0?o>=0.5:o>=0,f=this.additiveOf(i),m=f&&this.plant.additiveRotateRemembered!==!0,p=!m&&i.timelinesRotation.length!==c<<1;if(p)i.timelinesRotation.length=c<<1;u.forEach((y,g)=>{let x=this.fromOf(h[g]&Rw,s);if(!m&&y.type==="bone"&&y.kind==="rotate")this.applyRotate(e,y,l,o,x,i.timelinesRotation,g<<1,p);else if(y.type==="attachment")if(f&&this.plant.additiveAttachmentsDirect===!0)this.applyAttachmentDirect(e,y,l,x,!1);else this.applyAttachment(e,y,l,x,d);else this.applyTimeline(e,y,a,l,!0,o,x,!1,f)})}if(s===0)t=l;i.nextAnimationLast=l,i.nextTrackLast=i.trackTime}return e.slots.forEach((s,r)=>{if(s.attachmentState===Ow)e.setAttachment(r,this.doc.slots[r].setup)}),t}fromOf(e,t){return this.plant.higherTracksFromSetup===!0&&t>0&&e===ps?$e:e}applyMixingFrom(e,t,n){let s=e.mixingFrom,r=s.mixingFrom!==null?this.applyMixingFrom(s,t,n):1,i=this.mixOf(e),o=this.alphaOf(s)*r,a=1-i*(this.plant.holdIgnoresEntryAlpha===!0?1:this.alphaOf(e)),l=o*(1-i),u=a>0?l/a:o,c=s.anim.timelines,h=c.length,{timelineMode:d,timelineHoldMix:f}=s,m=this.additiveOf(s),p=m&&this.plant.additiveRotateRemembered!==!0,y=!p&&s.timelinesRotation.length!==h<<1;if(y)s.timelinesRotation.length=h<<1;let g=s.animationLast,x=Af(s),b=this.plant.eventsUntilHalfMix===!0&&i<0.5;return s.totalAlpha=0,c.forEach((v,_)=>{let S=d[_],M=this.fromOf(S&Rw,n),k;if((S&Rl)!==0&&this.plant.holdFaded!==!0){let T=f[_];k=T===null||T===void 0?u:u*(1-this.mixOf(T))}else k=l;if(s.totalAlpha+=k,!p&&v.type==="bone"&&v.kind==="rotate")this.applyRotate(t,v,x,k,M,s.timelinesRotation,_<<1,y);else if(v.type==="attachment")if(m&&this.plant.additiveAttachmentsDirect===!0)this.applyAttachmentDirect(t,v,x,M,!0);else this.applyAttachment(t,v,x,M,!1);else this.applyTimeline(t,v,g,x,b,k,M,!0,m)}),s.nextAnimationLast=x,s.nextTrackLast=s.trackTime,i}computeModes(){this.animationsChanged=!1,this.tracks.forEach((e,t)=>{if(e===null)return;let n=e;while(n.mixingFrom!==null)n=n.mixingFrom;do this.computeHold(n,t),n=n.mixingTo;while(n!==null)}),this.propertyIds.clear()}computeHold(e,t){let n=e.anim.timelines,s=e.timelineMode;s.length=n.length;let r=e.timelineHoldMix;r.length=0;let i=e.mixingTo,o=this.holdsAdditive(e),a=this.holdsAdditive(i);n.forEach((l,u)=>{let c=this.propertyFrom(t,l.ids);if(o&&ef(l)){s[u]=c;return}let h;if(i===null||l.instant||a&&ef(l)||!Dw(i.anim,l.ids))h=c;else{h=c|Rl;for(let d=i.mixingTo;d!==null;d=d.mixingTo)if(this.holdsAdditive(d)&&ef(l)||!Dw(d.anim,l.ids)){if(d.mixDuration>0)r[u]=d;break}}if(e.keepHold)h=h&~Rl|(s[u]??0)&Rl;s[u]=h})}propertyFrom(e,t){let n=this.propertyIds,s=$e;for(let r=0,i=t.length;rs(e,n,i,t))}applyTimeline(e,t,n,s,r,i,o,a,l){switch(t.type){case"bone":return this.applyBone(e,t,s,i,o,a,l);case"colour":return this.applyColour(e,t,s,i,o);case"deform":return this.applyDeform(e,t,s,i,o,l);case"events":if(r)e.events.push(...jf(t.keys,n,s,Yi,s{if(l.inheritMode===void 0)delete a.inheritMode;else a.inheritMode=l.inheritMode};if(i){if(r!==ps)f();return}let m=(this.plant.search??rt)(t.keys,n);if(m<0){if(r!==ps)f()}else a.inheritMode=t.keys[m].mode;return}let u=this.values(t.keys,n),c=(f,m)=>{let p=l[f]??0,y=a[f]??0;a[f]=u===null?Bw(r,s,y,p):r===$e?p+u[m]*s:y+(o?u[m]:u[m]+p-y)*s},h=(f,m)=>{let p=l[f]??0,y=l[m]??0;if(u===null){if(r===$e)a[f]=p,a[m]=y;else if(r===xn)a[f]=(a[f]??0)+(p-(a[f]??0))*s,a[m]=(a[m]??0)+(y-(a[m]??0))*s;return}if(r===$e)a[f]=p+u[0]*s,a[m]=y+u[1]*s;else if(o)a[f]=(a[f]??0)+u[0]*s,a[m]=(a[m]??0)+u[1]*s;else a[f]=(a[f]??0)+(p+u[0]-(a[f]??0))*s,a[m]=(a[m]??0)+(y+u[1]-(a[m]??0))*s},d=(f,m)=>{let p=l[f]??1,y=a[f]??1;a[f]=u===null?Bw(r,s,y,p):tf(u[m]*p,s,r,i,o,y,p)};switch(t.kind){case"rotate":c("rotation",0);break;case"translate":h("x","y");break;case"translatex":c("x",0);break;case"translatey":c("y",0);break;case"shear":h("shearX","shearY");break;case"shearx":c("shearX",0);break;case"sheary":c("shearY",0);break;case"scale":if(u===null){let f=l.scaleX??1,m=l.scaleY??1;if(r===$e)a.scaleX=f,a.scaleY=m;else if(r===xn)a.scaleX=(a.scaleX??1)+(f-(a.scaleX??1))*s,a.scaleY=(a.scaleY??1)+(m-(a.scaleY??1))*s}else a.scaleX=tf(u[0]*(l.scaleX??1),s,r,i,o,a.scaleX??1,l.scaleX??1),a.scaleY=tf(u[1]*(l.scaleY??1),s,r,i,o,a.scaleY??1,l.scaleY??1);break;case"scalex":d("scaleX",0);break;case"scaley":d("scaleY",0);break}}applyRotate(e,t,n,s,r,i,o,a){if(a)i[o]=0;if(s===1){this.applyBone(e,t,n,1,r,!1,!1);return}let l=e.bone(t.bone);if(l===null)return;let u=this.doc.bones[t.bone].rotation??0,c=this.values(t.keys,n),h,d;if(c===null){if(r===$e){l.rotation=u;return}if(r===ps)return;h=l.rotation??0,d=u}else h=r===$e?u:l.rotation??0,d=u+c[0];let f,m=d-h;if(m-=Math.ceil(m/360-0.5)*360,m===0)f=i[o];else{let p,y;if(a)p=0,y=m;else p=i[o],y=i[o+1]??Number.NaN;let g=p-p%360;f=m+g;let x=m>=0,b=p>=0;if(Math.abs(y)<=90&&Pi(y)!==Pi(m))if(Math.abs(p-g)>180)f+=360*Pi(p),b=x;else if(g!==0)f-=360*Pi(p);else b=x;if(b!==x)f+=360*Pi(p);i[o]=f}i[o+1]=m,l.rotation=h+f*s}applyAttachment(e,t,n,s,r){if(!e.slotLive(t.slot))return;let i=e.slots[t.slot];if(!r&&i.attachmentState===Iw)return;let o=(this.plant.search??rt)(t.keys,n),a=o<0,l=null;if(!a)l=t.keys[o].name??null,a=!r&&l===null;if(a){if(s===ps)return;l=this.doc.slots[t.slot].setup}if(e.setAttachment(t.slot,l),r)i.attachmentState=Iw;else if(!a)i.attachmentState=Ow}applyAttachmentDirect(e,t,n,s,r){if(!e.slotLive(t.slot))return;let i=(this.plant.search??rt)(t.keys,n);if(r||i<0){if(s!==ps)e.setAttachment(t.slot,this.doc.slots[t.slot].setup)}else e.setAttachment(t.slot,t.keys[i].name??null)}applyColour(e,t,n,s,r){if(!e.slotLive(t.slot))return;let i=this.doc.slots[t.slot],o=e.slots[t.slot],{light:a,dark:l}=o,u=i.color===void 0?rc:(this.plant.colour??e.stated)(i.color),c=i.dark===void 0?y2:e.stated(i.dark),h=()=>{for(let m=0;m<4;m++)a[m]=$i(a[m])},d=this.values(t.keys,n),f=nc[t.kind].channels.length;switch(t.kind){case"rgba":{if(d===null){if(r===$e)for(let m=0;m<4;m++)a[m]=u[m];else if(r===xn){for(let m=0;m<4;m++)a[m]+=(u[m]-a[m])*s;h()}return}if(s===1)for(let m=0;m<4;m++)a[m]=d[m];else if(r===$e)for(let m=0;m<4;m++)a[m]=u[m]+(d[m]-u[m])*s;else for(let m=0;m<4;m++)a[m]+=(d[m]-a[m])*s;h();return}case"rgb":{if(d===null){if(r===$e)for(let p=0;p<3;p++)a[p]=u[p];else if(r===xn)for(let p=0;p<3;p++)a[p]+=(u[p]-a[p])*s;return}let m=[d[0],d[1],d[2]];if(s!==1)for(let p=0;p<3;p++)m[p]=r===$e?u[p]+(m[p]-u[p])*s:a[p]+(m[p]-a[p])*s;for(let p=0;p<3;p++)a[p]=$i(m[p]);return}case"alpha":{if(d===null){if(r===$e)a[3]=u[3];else if(r===xn)a[3]+=(u[3]-a[3])*s;return}let m=d[0];if(s!==1)m=r===$e?u[3]+(m-u[3])*s:a[3]+(m-a[3])*s;a[3]=$i(m);return}case"rgba2":case"rgb2":{if(l===null)return;let m=t.kind==="rgba2",p=m?4:3;if(d===null){if(r===$e){for(let x=0;x{if(!e.slotLive(l))return;let u=e.resolve(l,a.placeholder);if(!u.vertex||u.timeline!==t.identity||u.vertices===null)return;let c=u.vertices;if(!a.seen.includes(t.identity))a.seen.push(t.identity);let h=(this.plant.deform??Wf)(c,o,n),d=r;if(a.deform===null)d=$e;if(h===null){if(d===$e)a.deform=null;else if(d===xn){if(s===1){a.deform=null;return}let m=a.deform;if(!c.weighted){let p=kr(c);a.deform=m.map((y,g)=>y+(p[g]-y)*s)}else{let p=1-s;a.deform=m.map((y)=>y*p)}}return}let f=d===$e;if(s===1)if(i&&!f){let m=a.deform;if(!c.weighted){let p=kr(c);a.deform=m.map((y,g)=>y+(h[g]-p[g]))}else a.deform=m.map((p,y)=>p+h[y])}else a.deform=[...h];else if(f)if(!c.weighted){let m=kr(c);a.deform=h.map((p,y)=>m[y]+(p-m[y])*s)}else a.deform=h.map((m)=>m*s);else if(i){let m=a.deform;if(!c.weighted){let p=kr(c);a.deform=m.map((y,g)=>y+(h[g]-p[g])*s)}else a.deform=m.map((p,y)=>p+h[y]*s)}else{let m=a.deform;a.deform=m.map((p,y)=>p+(h[y]-p)*s)}})}}function Bw(e,t,n,s){if(e===$e)return s;if(e===xn)return n+(s-n)*t;return n}function tf(e,t,n,s,r,i,o){if(t===1&&!r)return e;let a=n===$e?o:i;if(r)return a+(e-o)*t;if(s)return a+(Math.abs(e)*Math.sign(a)-a)*t;return a=Math.abs(a)*Math.sign(e),a+(e-a)*t}function Dw(e,t){for(let n of t)if(e.ids.has(n))return!0;return!1}function gr(e,t){if(typeof e!=="number"||!Number.isInteger(e)||e<0)throw new Y(`the live tracks' ${t} names track ${String(e)}, not a whole number at or above 0`);return e}function Pl(e,t,n){if(typeof e!=="number"||!Number.isFinite(e)||e<0)throw new Y(`the live tracks' ${n} ${t} is ${String(e)}, not a finite time at or above 0`);return e}function Fw(e,t){if(typeof e!=="object"||e===null||typeof e.loop!=="boolean")throw new Y(`the live tracks' ${t} options.loop is ${JSON.stringify(e?.loop)}, not true or false`);return e.loop}function _M(e,t,n){if(typeof e!=="number"||!Number.isFinite(e)||e<0||e>1)throw new Y(`the live tracks' ${n} ${t} is ${typeof e==="number"?String(e):JSON.stringify(e)}, not a number from 0 to 1`);return e}function Nw(e,t){let n=e.alpha===void 0?1:_M(e.alpha,"options.alpha",t),s=e.additive;if(s!==void 0&&typeof s!=="boolean")throw new Y(`the live tracks' ${t} options.additive is ${JSON.stringify(s)}, not true or false — an entry adds or it does not`);return{alpha:n,additive:s===!0}}function Gw(e,t){if(typeof e!=="number"||!Number.isFinite(e))throw new Y(`the live tracks' ${t} delay is ${String(e)}, not a finite number`);return e}function nf(e,t,n={}){if(typeof t!=="object"||t===null||t.reset!=="animation"&&t.reset!=="setup")throw new Y(`the live tracks' options.reset is ${JSON.stringify(t?.reset)}, not "animation" or "setup"`);if(t.adjust!==void 0&&typeof t.adjust!=="function")throw new Y(`the live tracks' options.adjust is ${typeof t.adjust}, not a function`);if(t.clock!==void 0&&typeof t.clock!=="function")throw new Y(`the live tracks' options.clock is ${typeof t.clock}, not a function`);let s=t.clock===void 0?void 0:hM(t.clock,"the live tracks'");return new SM(e,t.reset,t.adjust,s,n,a2(e,n))}class SM{constructor(e,t,n,s,r,i){this.doc=e,this.reset=t,this.adjust=n,this.clock=s,this.plant=r,this.path=i,this.started=!1,this.steps=0,this.time=0,this.refused=null,this.mixer=new vM(e,r),this.parameters=new im(e),this.path.ctx.parameters=this.parameters}get trackTime(){return this.time}get environment(){return fM(this.path.ctx)}setEnvironment(e){this.live("setEnvironment"),dM(this.path.ctx,e,"the live tracks'")}setPhysicsParameters(e,t){this.live("setPhysicsParameters"),this.parameters.set(e,t)}readPhysicsParameters(e){return this.parameters.read(e)}clearPhysicsParameters(e){this.live("clearPhysicsParameters"),this.parameters.clear(e)}physicsTranslate(e,t){this.live("physicsTranslate"),mM(this.path.ctx,e,t,"the live tracks'")}physicsRotate(e,t,n){this.live("physicsRotate"),pM(this.path.ctx,e,t,n,"the live tracks'")}live(e){if(this.refused!==null)throw new Y(`the live tracks were refused at ${this.refused}, after their entries and physics had moved; open them again (${e} not made)`)}setAnimation(e,t,n){this.live("setAnimation");let s=gr(e,"setAnimation"),r=Fw(n,"setAnimation"),i=Pl(n.mixDuration,"mixDuration","setAnimation"),o=Nw(n,"setAnimation"),a=this.mixer.setAnimation(s,this.mixer.animation(t),r);a.mixDuration=i,a.alpha=o.alpha,a.additive=o.additive}setEmptyAnimation(e,t){this.live("setEmptyAnimation");let n=gr(e,"setEmptyAnimation"),s=Pl(t,"mixDuration","setEmptyAnimation"),r=this.mixer.setAnimation(n,Pw,!1);r.mixDuration=s,r.trackEnd=s}addAnimation(e,t,n){this.live("addAnimation");let s=gr(e,"addAnimation"),r=Fw(n,"addAnimation"),i=Pl(n.mixDuration,"mixDuration","addAnimation"),o=Gw(n.delay,"addAnimation"),a=Nw(n,"addAnimation"),l=this.mixer.addAnimation(s,this.mixer.animation(t),r,o);this.mixer.setMixDuration(l,i,o),l.alpha=a.alpha,l.additive=a.additive}addEmptyAnimation(e,t,n){this.live("addEmptyAnimation");let s=gr(e,"addEmptyAnimation"),r=Pl(t,"mixDuration","addEmptyAnimation"),i=Gw(n,"addEmptyAnimation"),o=this.mixer.addAnimation(s,Pw,!1,i);if(i<=0)o.delay=Math.max(o.delay+o.mixDuration-r,0);o.mixDuration=r,o.trackEnd=r}setAlpha(e,t){this.live("setAlpha");let n=gr(e,"setAlpha"),s=_M(t,"alpha","setAlpha"),r=this.mixer.tracks[n]??null;if(r===null)throw new Y(`the live tracks' setAlpha names track ${n}, which plays nothing — there is no entry to weigh`);r.alpha=s}current(e){let t=this.mixer.tracks[gr(e,"current")]??null;if(t===null)return null;return{animation:t.anim.name,loop:t.loop,trackTime:t.trackTime,animationTime:Af(t),duration:t.anim.duration,alpha:t.alpha,additive:t.additive}}start(){if(this.live("start"),this.started)throw new Y("the live tracks were started already; pose 0 is posed once");return this.started=!0,this.guard("start",()=>{if(this.reset==="setup")return this.path.setupPose();return this.pose(0,!0)})}step(e){let t=this.steps+1;if(this.live(`step ${t}`),!this.started)throw new Y(`the live tracks' step ${t} comes before start(), which poses pose 0`);if(typeof e!=="number"||!Number.isFinite(e)||e<0)throw new Y(`the live tracks' step ${t} is ${String(e)}, not a finite time at or above 0`);return this.guard(`step ${t}`,()=>{this.time+=e;let n=this.plant.stage;if(n!==void 0)n.begin("timeline");if(this.mixer.update(e),n!==void 0)n.end("timeline");let s=this.pose(e,!1);return this.steps=t,s})}guard(e,t){try{return t()}catch(n){throw this.refused=`${e} (${n instanceof Error?n.message:String(n)})`,n}}pose(e,t){let{doc:n,path:s}=this,r=s.ctx,i=r.time;r.time+=this.clock===void 0?e:this.clock(e);let o=this.plant.stage;if(o!==void 0)o.begin("timeline");let a=new bM(n,this.plant),l=this.mixer.apply(a),u=this.mixer.tracks[0]??null,c=this.adjust===void 0?void 0:{callback:this.adjust,context:{trackTime:u?.trackTime??null,animation:u?.anim.name??null,globalTime:this.time}},h=new Map(n.slots.map((d,f)=>[d.name,{deform:a.slots[f].deform,seen:a.slots[f].seen}]));if(o!==void 0)o.end("timeline");return s.step(t,this.time,l,{world:(d)=>M$(n,a.bones,s.raw,d,{ctx:r,before:i,adjustment:c}),slots:(d,f)=>K1(n,s.raw,d,f,(m,p)=>{let y=a.slots[n.slots.indexOf(m)];return{placeholder:y.placeholder,light:y.light,dark:y.dark}}),drawOrder:[],at:0,sample:null,mixed:h,events:()=>a.events})}}function v2(e){let t=new Map;for(let n of e){let s={name:n.name,width:n.width,height:n.height};for(let r of n.regions)if(!t.has(r.name))t.set(r.name,{page:s,region:r})}return(n)=>t.get(n)??null}function _2(e,t,n={}){let s=e.degrees===90||n.turned270===!0&&e.degrees===270,r=e.x/t.width,i=e.y/t.height,o=(e.x+(s?e.height:e.width))/t.width,a=(e.y+(s?e.width:e.height))/t.height,l;if(s)l=n.rotationFlipped===!0?[r,i,o,i,o,a,r,a]:[o,a,r,a,r,i,o,i];else l=[r,a,r,i,o,i,o,a];return l.map(Math.fround)}function S2(e,t,n,s={}){let r=s.trimDropped===!0,i=r?0:e.offsetX,o=r?0:e.offsetY,a=r?e.width:e.originalWidth,l=r?e.height:e.originalHeight,{width:u,height:c}=t,h=s.artAsFloat32===!0?n.map(Math.fround):n,d=e.x/u,f=e.y/c,m=[];switch(e.degrees){case 90:{d-=(l-o-e.height)/u,f-=(a-i-e.width)/c;let p=l/u,y=a/c;for(let g=0;g+1typeof e==="object"&&e!==null&&!Array.isArray(e),Lw=(e,t)=>typeof e==="number"&&Number.isInteger(e)&&e>=t;function M2(e){let t=new Map,n=[];if((yr(e)&&Array.isArray(e.skins)?e.skins:[]).forEach((r,i)=>{if(!yr(r)||typeof r.name!=="string"||!yr(r.attachments))return;for(let[o,a]of Object.entries(r.attachments)){if(!yr(a))continue;for(let[l,u]of Object.entries(a)){if(!yr(u)||u.sequence===void 0)continue;let c=`skins[${i}] "${r.name}".attachments["${o}"]["${l}"].sequence`,h=u.sequence;if(!yr(h)){n.push(`${c} is not an object`);continue}let d=n.length;if(!Lw(h.count,1))n.push(`${c}: count is ${JSON.stringify(h.count)??"absent"}, not a whole number of at least 1`);for(let p of["start","digits","setup"])if(h[p]!==void 0&&!Lw(h[p],0))n.push(`${c}: ${p} is ${JSON.stringify(h[p])}, not a whole number of at least 0`);if(n.length!==d)continue;let f=h.count,m=h.setup??0;if(m>=f){n.push(`${c}: setup is ${m}, and a ${f}-frame series has frames 0 to ${f-1}`);continue}t.set(`${r.name}/${o}/${l}`,{count:f,start:h.start??1,digits:h.digits??0,setup:m})}}}),n.length>0)throw new Y(`the model document's sequences: ${n.join("; ")}`);return t}function T2(e,t,n,s){let r=new Map(t.map((a)=>[a.slot,a])),i=[],o=[];for(let a of n){let l=r.get(a);if(l===void 0)continue;let u=l.geometry;if(u.kind!=="region"&&u.kind!=="mesh"&&u.kind!=="linkedmesh")continue;let c=e.skins.find((g)=>g.name===l.skin)?.attachments[l.slot]?.[l.placeholder];if(c===void 0)throw new Y(`slot "${l.slot}": skin "${l.skin}" files no record under placeholder "${l.placeholder}" (readModel refuses it first)`);let h=c.path??l.name,d=s.sequences.get(`${l.skin}/${l.slot}/${l.placeholder}`);if(u.kind==="linkedmesh"&&d!==void 0&&l.frame!==void 0){let g=e.skins.find((x)=>x.name===u.skin)?.attachments[u.slot]?.[u.source]?.sequenceCount;if(g!==d.count){o.push(`slot "${l.slot}" shows linked mesh "${l.name}", whose own ${d.count}-frame series a sequence timeline steps over its source's ${g??"unstated"} frame(s)`);continue}}let f=d===void 0?null:l.frame??d.setup,m=d===void 0||f===null?h:w2(h,d,f),p=s.lookup(m);if(p===null)throw new Y(`slot "${l.slot}" shows "${l.name}", which draws atlas region "${m}"${f===null?"":` (frame ${f} of its series over "${h}")`}, and the atlas has no region of that name — spine-core refuses to load the pair ("Region not found in atlas")`);let y=null;if(u.kind==="mesh")y=u.uvs;else if(u.kind==="linkedmesh"){let g=e.skins.find((x)=>x.name===u.skin)?.attachments[u.slot]?.[u.source]?.geometry;if(g?.kind!=="mesh")throw new Y(`slot "${l.slot}": the linked mesh's source "${u.source}" carries no uvs (readModel refuses it first)`);y=g.uvs}i.push({slot:l.slot,name:l.name,kind:u.kind,region:m,frame:f,found:p,art:y})}if(o.length>0)return{drawn:null,why:`${o.join("; ")} — which of the two counts the runtime steps it over was not measured`};return{drawn:i,why:null}}function C2(e,t){let n=new Map;for(let s of e){let r=t.get(s.name);if(!r)throw Error(`Missing page image: ${s.name}`);for(let i of s.regions)n.set(i.name,{page:s,region:i,image:r})}return n}function A2(e,t,n){let s=om(t,t.image);wM(e,t,t.image,s,n)}var kM=new Set;function Ef(e){if(!kM.delete(e))return;URL.revokeObjectURL(e)}var Uw=new WeakMap;function Jl(e,t){if(!t)return e;let n=Uw.get(e);if(n)return n;let{naturalWidth:s,naturalHeight:r}=e;if(!(s>0)||!(r>0))return e;let i=E2(e,s,r);return Uw.set(e,i),i}function E2(e,t,n){let s=document.createElement("canvas");s.width=t,s.height=n;let r=s.getContext("2d");if(!r)return e;r.drawImage(e,0,0);let i;try{i=r.getImageData(0,0,t,n)}catch{return e}let o=i.data;for(let a=0;a0?t.width:s,o=t.height>0?t.height:r,a=e.degrees===90,l=a?e.height:e.width,u=a?e.width:e.height;if(!t.pma&&!a&&e.x===0&&e.y===0&&l===i&&u===o)return{passThrough:!0,sx:0,sy:0,sw:s,sh:r,cw:s,ch:r};let c=s/i,h=r/o,d=Math.round(e.x*c),f=Math.round(e.y*h),m=Math.max(1,Math.round((e.x+l)*c)-d),p=Math.max(1,Math.round((e.y+u)*h)-f);return{passThrough:!1,sx:d,sy:f,sw:m,sh:p,cw:a?p:m,ch:a?m:p}}function P2(e,t){let n=t.get(e.page.name);if(!n)return e.region.width*e.region.height;let s=om(e,n);return s.cw*s.ch}async function $2(e,t,n){let{region:s,page:r}=e,i=t.get(r.name);if(!i)throw Error(`Missing page image: ${r.name}`);let{width:o,height:a}=s,l=om(e,i);if(l.passThrough)return{url:i.src,width:o,height:a};let u=document.createElement("canvas");if(wM(u,e,i,l),n==="data")return{url:u.toDataURL("image/png"),width:o,height:a};let c=await new Promise((d,f)=>{u.toBlob((m)=>m?d(m):f(Error("toBlob failed")),"image/png")}),h=URL.createObjectURL(c);return kM.add(h),{url:h,width:o,height:a}}function wM(e,t,n,s,r){e.width=r===void 0?s.cw:Math.min(s.cw,Math.max(1,Math.ceil(t.region.width*r))),e.height=r===void 0?s.ch:Math.min(s.ch,Math.max(1,Math.ceil(t.region.height*r)));let i=e.getContext("2d");if(!i)throw Error("2d context unavailable");if(r!==void 0)i.imageSmoothingQuality="high",i.scale(e.width/s.cw,e.height/s.ch);if(t.region.degrees===90)i.translate(s.cw,0),i.rotate(Math.PI/2);let o=Jl(n,t.page.pma===!0);i.drawImage(o,s.sx,s.sy,s.sw,s.sh,0,0,s.sw,s.sh)}async function O2(e,t,n={}){let s=n.encoding??"blob";if(s!=="blob"&&s!=="data")throw Error(`encoding must be 'blob' or 'data', got ${String(n.encoding)}`);let r=e.flatMap((h)=>h.regions.map((d)=>({region:d,page:h}))),i=Array(r.length),o=-1,a,l=[],u=0;for(let h=0;h0&&u+f>R2)if(await Promise.race(l.map((p)=>p.promise)),l=l.filter((p)=>!p.done),o!==-1)break;if(o!==-1)break;u+=f;let m={done:!1,promise:Promise.resolve()};m.promise=(async()=>{try{i[h]=await $2(d,t,s)}catch(p){if(o===-1||hh.promise)),o!==-1){for(let h of i)if(h)Ef(h.url);throw a}let c=new Map;for(let h=0;h"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Pt({0:this.localUniforms}),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){let t=this._getMeshData(e),n=t.batched,s=e.batched;if(t.batched=s,n!==s)return!0;else if(s){let r=e._geometry;if(r.indices.length!==t.indexSize||r.positions.length!==t.vertexSize)return t.indexSize=r.indices.length,t.vertexSize=r.positions.length,!0;let i=this._getBatchableMesh(e);if(i.texture.uid!==e._texture.uid)i._textureMatrixUpdateId=-1;return!i._batcher.checkAndUpdateTexture(i,e._texture)}return!1}addRenderable(e,t){let n=this.renderer.renderPipes.batch,s=this._getMeshData(e);if(e.didViewUpdate)s.indexSize=e._geometry.indices?.length,s.vertexSize=e._geometry.positions?.length;if(s.batched){let r=this._getBatchableMesh(e);r.setTexture(e._texture),r.geometry=e._geometry,n.addToBatch(r,t)}else n.break(t),t.add(e)}updateRenderable(e){if(e.batched){let t=this._getBatchableMesh(e);t.setTexture(e._texture),t.geometry=e._geometry,t._batcher.updateElement(t)}}execute(e){if(!e.isRenderable)return;if(e.state.blend)e.state.blendMode=xi(e.groupBlendMode,e.texture._source);let t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),yr(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){var t,n;return(t=e._gpuData)[n=this.renderer.uid]||(t[n]=new Lh),e._gpuData[this.renderer.uid].meshData||this._initMeshData(e)}_initMeshData(e){return e._gpuData[this.renderer.uid].meshData={batched:e.batched,indexSize:0,vertexSize:0},e._gpuData[this.renderer.uid].meshData}_getBatchableMesh(e){var t,n;return(t=e._gpuData)[n=this.renderer.uid]||(t[n]=new Lh),e._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(e)}_initBatchableMesh(e){let t=new Gh;return t.renderable=e,t.setTexture(e._texture),t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,e._gpuData[this.renderer.uid].batchableMesh=t,t}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}La.extension={type:[D.WebGLPipes,D.WebGPUPipes],name:"mesh"};ne.add(La);class Ua extends ds{constructor(...e){let t=e[0];if(t instanceof tn){if(q(be,"Mesh: use new Mesh({ geometry, shader }) instead"),t={geometry:t,shader:e[1]},e[3])q(be,"Mesh: drawMode argument has been removed, use geometry.topology instead"),t.geometry.topology=e[3]}let{geometry:n,shader:s,texture:r,roundPixels:i,state:o,...a}=t;super({label:"Mesh",...a});this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=r??s?.texture??K.WHITE,this.state=o??ft.for2d(),this._geometry=n,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=i??!1}get material(){return q(be,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(e){if(this._shader===e)return;this._shader=e,this.onViewUpdate()}get shader(){return this._shader}set geometry(e){if(this._geometry===e)return;this._geometry?.off("update",this.onViewUpdate,this),e.on("update",this.onViewUpdate,this),this._geometry=e,this.onViewUpdate()}get geometry(){return this._geometry}set texture(e){e||(e=K.EMPTY);let t=this._texture;if(t===e)return;if(t&&t.dynamic)t.off("update",this.onViewUpdate,this);if(e.dynamic)e.on("update",this.onViewUpdate,this);if(this.shader)this.shader.texture=e;this._texture=e,this.onViewUpdate()}get texture(){return this._texture}get batched(){if(this._shader)return!1;if((this.state.data&12)!==0)return!1;if(this._geometry instanceof ki){if(this._geometry.batchMode==="auto")return this._geometry.positions.length/2<=100;return this._geometry.batchMode==="batch"}return!1}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(e){let{x:t,y:n}=e;if(!this.bounds.containsPoint(t,n))return!1;let s=this.geometry.getBuffer("aPosition").data,r=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){let i=this.geometry.getIndex().data,o=i.length;for(let a=0;a+2t.name===e.skin)}function _l(e){if(e.skin==="all")return e.skins;let t=e.skin===null?void 0:e.skins.find((s)=>s.name===e.skin),n=e.skin==="default"?void 0:e.skins.find((s)=>s.name==="default");return[t,n].filter((s)=>s!==void 0)}function Oi(e,t,n){if(e.skin==="all")return e.skins.filter((r)=>r.attachments[t]?.[n]!==void 0).map((r)=>r.name);let s=_l(e).find((r)=>r.attachments[t]?.[n]!==void 0);return s===void 0?[]:[s.name]}function FS(e,t,n){return Rd(e).some((s)=>s.constraints[t].includes(n))}var DS=["hold","once","loop","pingpong","onceReverse","loopReverse","pingpongReverse"];var _r=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Ss=(e)=>typeof e==="number"&&Number.isFinite(e);function iE(e){return e.weighted?2*e.bindings.reduce((t,n)=>t+n.length,0):e.xy.length}function NS(e,t,n){let s=-1/0;e.forEach((r,i)=>{if(!_r(r))return;let o=r.time;if(!Ss(o)||o<0)n.push(`${t}[${i}]: time is ${JSON.stringify(o)}, not a finite time at or after 0`);else if(o<=s)n.push(`${t}[${i}]: time ${o} is not after the key before it — the writer refuses key times that do not strictly increase`);if(Ss(o))s=Math.max(s,o)})}function oE(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];NS(e,t,s);let r=iE(n),i=[];return e.forEach((o,a)=>{let l=`${t}[${a}]`;if(!_r(o)){s.push(`${l} is not an object`);return}for(let m of Object.keys(o))if(!["time","offset","vertices","curve"].includes(m))s.push(`${l}: field "${m}" is not one a deform key carries; it carries [time, offset, vertices, curve]`);let u=o.vertices,c=[];if(u!==void 0)if(!Array.isArray(u)||u.length===0||!u.every(Ss))s.push(`${l}: vertices is not a non-empty list of finite numbers (omit it for the setup geometry)`);else c=u;let h=0;if(o.offset!==void 0)if(u===void 0)s.push(`${l}: offset ${JSON.stringify(o.offset)} with no vertices — a key with no run is the setup geometry, and the writer states no start for it`);else if(typeof o.offset!=="number"||!Number.isInteger(o.offset)||o.offset<0)s.push(`${l}: offset is ${JSON.stringify(o.offset)}, not a whole index at or after 0`);else h=o.offset;if(h+c.length>r)s.push(`${l}: the run starts at ${h} and is ${c.length} long, past the ${r} numbers of the attachment's deform array`);let d="linear";if(o.curve!==void 0)if(a===e.length-1)s.push(`${l}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(o.curve==="stepped")d="stepped";else if(Array.isArray(o.curve)&&o.curve.length===4&&o.curve.every(Ss))d=o.curve;else s.push(`${l}: curve is ${JSON.stringify(o.curve)}, not "stepped" nor 4 finite numbers (a deform key's curve is one channel)`);let f=Ss(o.time)?o.time:0;i.push({time:Math.fround(f),stated:f,curve:d,offset:h,vertices:c})}),i}function aE(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];NS(e,t,s);let r=[];return e.forEach((i,o)=>{let a=`${t}[${o}]`;if(!_r(i)){s.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(!["time","mode","index","delay"].includes(h))s.push(`${a}: field "${h}" is not one a sequence key carries; it carries [time, mode, index, delay]`);let l="hold";if(i.mode!==void 0){let h=DS.find((d)=>d===i.mode);if(h===void 0)s.push(`${a}: mode is ${JSON.stringify(i.mode)}, none of ${DS.join(", ")}`);else l=h}let u=0;if(i.index!==void 0)if(typeof i.index!=="number"||!Number.isInteger(i.index)||i.index<0||i.index>=n)s.push(`${a}: index is ${JSON.stringify(i.index)}, not a frame of the series' ${n} — the writer refuses an index past the last frame`);else u=i.index;let c=r.length===0?0:r[r.length-1].delay;if(i.delay!==void 0)if(!Ss(i.delay)||i.delay<0)s.push(`${a}: delay is ${JSON.stringify(i.delay)}, not a finite number of seconds at or above 0`);else c=Math.fround(i.delay);r.push({time:Math.fround(Ss(i.time)?i.time:0),mode:l,index:u,delay:c})}),r}function GS(e,t,n,s){let r=[],i=`${t}.attachments`;if(!Array.isArray(e))return s.push(`${i} is not a list`),r;return e.forEach((o,a)=>{let l=`${i}[${a}]`;if(!_r(o)||typeof o.name!=="string"){s.push(`${l} names no skin`);return}let u=n.find((c)=>c.name===o.name);if(u===void 0)s.push(`${l}: "${o.name}" is not a skin of this document`);if(!Array.isArray(o.slots)){s.push(`${l}: slots is not a list`);return}o.slots.forEach((c,h)=>{let d=`${l}.slots[${h}]`;if(!_r(c)||typeof c.name!=="string"){s.push(`${d} names no slot`);return}if(!Array.isArray(c.attachments)){s.push(`${d}: attachments is not a list`);return}let f=c.name;c.attachments.forEach((m,p)=>{let y=`${d}.attachments[${p}]`;if(!_r(m)||typeof m.name!=="string"){s.push(`${y} names no attachment`);return}for(let v of Object.keys(m))if(!["name","deform","sequence"].includes(v))s.push(`${y}: field "${v}" is not one this reader knows; it reads [name, deform, sequence]`);let g=u?.attachments[f]?.[m.name],x=`${y} "${o.name}/${f}/${m.name}"`;if(u!==void 0&&g===void 0)s.push(`${x}: skin "${u.name}" files no attachment "${m.name}" under slot "${f}"`);let b={skin:o.name,slot:f,attachment:m.name,deform:null,sequence:null};if(m.deform!==void 0&&g!==void 0){let v=g.geometry;if(v===void 0||v.kind!=="mesh"&&v.kind!=="clipping"&&v.kind!=="boundingbox"&&v.kind!=="path")s.push(`${x}: a deform keys the vertices of a mesh, bounding box, clipping or path attachment, and this one is a ${g.kind}`);else b.deform=oE(m.deform,`${x}.deform`,v.vertices,s)}if(m.sequence!==void 0&&g!==void 0){let v=g.sequenceCount;if(v===void 0)s.push(`${x}: a sequence timeline steps a series, and this ${g.kind} carries no sequence`);else b.sequence=aE(m.sequence,`${x}.sequence`,v,s)}if(m.deform===void 0&&m.sequence===void 0)s.push(`${x}: carries neither a deform nor a sequence timeline`);r.push(b)})})}),r}function Od(e,t){if(!e.weighted)return{weighted:!1,xy:[...t]};let n=0;return{weighted:!0,bindings:e.bindings.map((s)=>s.map((r)=>{let i=Math.fround(r.x)+t[n],o=Math.fround(r.y)+t[n+1];return n+=2,{...r,x:i,y:o}}))}}var LS=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function US(e,t,n,s){let r=`${t}.drawOrder`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=new Map(n.map((l,u)=>[l.name,u])),o=[],a=-1/0;return e.forEach((l,u)=>{let c=`${r}[${u}]`;if(!LS(l)){s.push(`${c} is not an object`);return}for(let f of Object.keys(l))if(f!=="time"&&f!=="offsets")s.push(`${c}: field "${f}" is not one a draw-order key carries; it carries [time, offsets]`);let h=l.time;if(typeof h!=="number"||!Number.isFinite(h)||h<0)s.push(`${c}: time is ${JSON.stringify(h)}, not a finite time at or after 0`);else if(h<=a)s.push(`${c}: time ${h} is not after the key before it — the writer refuses key times that do not strictly increase`);if(typeof h==="number"&&Number.isFinite(h))a=Math.max(a,h);let d=[];if(l.offsets!==void 0)if(!Array.isArray(l.offsets))s.push(`${c}: offsets is not a list`);else{let f=new Map;l.offsets.forEach((m,p)=>{let y=`${c}.offsets[${p}]`;if(!LS(m)||typeof m.slot!=="string"){s.push(`${y} names no slot`);return}let g=i.get(m.slot);if(g===void 0){s.push(`${y}: "${m.slot}" is not a slot of this document`);return}if(typeof m.offset!=="number"||!Number.isInteger(m.offset)){s.push(`${y}: slot "${m.slot}" offset is ${JSON.stringify(m.offset)}, not a whole number`);return}if(d.some((b)=>b.slot===g))s.push(`${y}: slot "${m.slot}" is moved twice in one key`);let x=g+m.offset;if(x<0||x>=n.length)s.push(`${y}: slot "${m.slot}" is at ${g} and offset ${m.offset} lands at ${x}, outside the ${n.length} slots`);else if(f.has(x))s.push(`${y}: slot "${m.slot}" lands at ${x}, where slot "${f.get(x)}" lands too — two moves on one place leave a slot out of the runtime's order`);else f.set(x,m.slot);d.push({slot:g,offset:m.offset})})}o.push({time:Math.fround(typeof h==="number"&&Number.isFinite(h)?h:0),moves:d})}),o}var VS=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),WS=["name","int","float","string","audio","volume","balance"],XS=["time","name","int","float","string","volume","balance"];function jS(e,t,n){let s={};if(e.int!==void 0)if(typeof e.int!=="number"||!Number.isInteger(e.int))n.push(`${t}: int is ${JSON.stringify(e.int)}, not a whole number`);else s.int=e.int;if(e.float!==void 0)if(typeof e.float!=="number"||!Number.isFinite(e.float))n.push(`${t}: float is ${JSON.stringify(e.float)}, not a finite number`);else s.float=e.float;if(e.string!==void 0)if(typeof e.string!=="string")n.push(`${t}: string is ${JSON.stringify(e.string)}, not a string`);else s.string=e.string;for(let r of["volume","balance"])if(e[r]!==void 0)if(typeof e[r]!=="number"||!Number.isFinite(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])}, not a finite number`);else s[r]=e[r];return s}function YS(e,t){let n=new Map;if(!Array.isArray(e))return t.push("events is not a list"),n;return e.forEach((s,r)=>{let i=`events[${r}]`;if(!VS(s)||typeof s.name!=="string"||s.name===""){t.push(`${i} names no event`);return}for(let a of Object.keys(s))if(!WS.includes(a))t.push(`${i} "${s.name}": field "${a}" is not one this reader knows; it reads [${WS.join(", ")}]`);if(s.audio!==void 0&&typeof s.audio!=="string")t.push(`${i} "${s.name}": audio is ${JSON.stringify(s.audio)}, not a string`);if(n.has(s.name))t.push(`${i}: event "${s.name}" is declared twice`);let o=jS(s,`${i} "${s.name}"`,t);n.set(s.name,{audio:typeof s.audio==="string"?s.audio:"",volume:o.volume??0,balance:o.balance??0,name:s.name,int:o.int??0,float:o.float??0,string:o.string??""})}),n}function HS(e,t,n,s){let r=`${t}.events`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=[],o=-1/0;return e.forEach((a,l)=>{let u=`${r}[${l}]`;if(!VS(a)){s.push(`${u} is not an object`);return}for(let f of Object.keys(a))if(!XS.includes(f))s.push(`${u}: field "${f}" is not one an event key carries; it carries [${XS.join(", ")}]`);let c=a.time;if(typeof c!=="number"||!Number.isFinite(c)||c<0)s.push(`${u}: time is ${JSON.stringify(c)}, not a finite time at or after 0`);else if(c0?n.reverse():n;return t.flippedWinding===!0?s.reverse():s}function uE(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(r*(e[1]-n[1])-i*(e[0]-n[0]))/(a*r-o*i);return[n[0]+l*o,n[1]+l*a]}function Fd(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(o*(e[1]-n[1])-a*(e[0]-n[0]))/(a*r-o*i);return[e[0]+l*r,e[1]+l*i]}function JS(e,t,n){let s=n.fromClipEdge===!0?uE:Fd,r=[...e],i=!1;for(let o=0;o0;o++){let a=t[o],l=t[(o+1)%t.length],u=(h)=>(l[0]-a[0])*(h[1]-a[1])-(l[1]-a[1])*(h[0]-a[0])<0,c=[];for(let h=0;h[t[2*P],t[2*P+1]]),p=f.map((P)=>[o(s[2*P]),o(s[2*P+1])]),{points:y,cut:g}=JS(m,i,r);for(let P=1;P+1r.uvByDivision===!0?P/T:P*A,E=a.length/2;if(!g&&r.insideRotated!==!0){m.forEach(([P,O],B)=>{a.push(o(P),o(O)),l.push(p[B][0],p[B][1])});for(let P=1;P+1ew(r,i,o,a,n)){let r=[],i=[],o=[],a=null;for(let c of e){if(c.kind==="clip"){if(a!==null&&a.end===c.slot)a=null;if(c.active&&a===null){let h=c.inverse?"it is inverse":Sl(c.polygon);if(h!==null)i.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${h}`);let d={polygon:c.polygon,inverse:c.inverse,convex:c.convex},f=wl(d);if(f.kind==="refused")o.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${f.why}`);a={end:c.end,shape:d}}continue}if(c.kind==="draw"&&a!==null){let h=s(a.shape,c.vertices,c.triangles,c.uvs);if(h!==null)r.push([c.slot,c.attachment,h.clipped?1:0,h.vertices.map(t),h.uvs.map(t),h.triangles])}if(a!==null&&a.end===c.slot)a=null}let l=o.length===0?null:`${o.join("; ")} — the runtime's coverage of a polygon that is not simple is its own triangulation's, measured not to be the polygon's area (src/core/clipping.ts)`,u=l===null?r:null;if(i.length>0)return{rows:null,why:`${i.join("; ")} — the runtime decomposes such a polygon into convex pieces of its own choosing, or clips the outside of an inverse one, and neither was reproduced from the dump (src/core/clipping.ts)`,drawn:u,drawnWhy:l};return{rows:r,why:null,drawn:u,drawnWhy:l}}function hE(e){let t=[];for(let n=0;n+10&&i<0||r<0&&i>0)&&(o>0&&a<0||o<0&&a>0))return!0;let l=(u,c,h)=>Math.min(u[0],c[0])<=h[0]&&h[0]<=Math.max(u[0],c[0])&&Math.min(u[1],c[1])<=h[1]&&h[1]<=Math.max(u[1],c[1]);return r===0&&l(n,s,e)||i===0&&l(n,s,t)||o===0&&l(e,t,n)||a===0&&l(e,t,s)}function fE(e){let t=e.length;for(let n=0;n0)return`edges ${n} and ${(n+1)%t} fold back over each other at vertex ${(n+1)%t}`;for(let o=n+2;o3;){n=!1;for(let s=0;ss[0]-r[0]||s[1]-r[1]),n=(s)=>{let r=[];for(let i of s){while(r.length>=2&&$t(r[r.length-2],r[r.length-1],i)<=0)r.pop();r.push(i)}return r.pop(),r};return[...n(t),...n([...t].reverse())]}function pE(e){let t=e.flat();return KS(t)<0?[...e].reverse():[...e]}function gE(e){let t=e.length,n=e.map((a,l)=>l),s=[],r=(a,l,u,c)=>$t(l,u,a)>=0&&$t(u,c,a)>=0&&$t(c,l,a)>=0;while(n.length>3){let a=!1;for(let l=0;ld!==u&&d!==c&&d!==h&&r(e[d],e[u],e[c],e[h])))continue;s.push([u,c,h]),n.splice(l,1),a=!0;break}if(!a)throw Error(`convexPieces: no ear left among vertices [${n.join(", ")}] of a polygon the caller held simple — a defect in src/core/clipping.ts`)}s.push([...n]);let i=s.map((a)=>[...a]),o=(a)=>a.every((l,u)=>$t(e[a[(u+a.length-1)%a.length]],e[l],e[a[(u+1)%a.length]])>0);for(let a=!0;a;){a=!1;e:for(let l=0;la.map((l)=>e[l]))}function wl(e){let t=hE(e.polygon);if(t.length<3)return{kind:"refused",why:`it has ${t.length} vertex(es)`};let n=[];for(let o=0;o0){let o=t.filter((a,l)=>{let u=t[(l+1)%t.length];return a[0]!==u[0]||a[1]!==u[1]});if(!e.inverse&&o.length===t.length-n.length&&o.length>=3&&Sl(o.flat())===null)return{kind:"convex",polygon:e.polygon};return{kind:"refused",why:`vertices ${n.join(", ")} are the same point`}}let s=fE(t);if(s!==null)return{kind:"refused",why:s};let r=mE(t);if($t(r[0],r[1],r[2])===0&&r.length===3)return{kind:"refused",why:"every vertex lies on one line"};if(e.inverse)return{kind:"inverse",hull:zS(r)};if(Sl(e.polygon)===null)return{kind:"convex",polygon:e.polygon};if(e.convex)return{kind:"convex",polygon:zS(r).flat()};let i=gE(pE(r));return i.length===1?{kind:"convex",polygon:i[0].flat()}:{kind:"pieces",pieces:i}}function qS(e,t,n){let s=(o)=>(n[0]-t[0])*(o[1]-t[1])-(n[1]-t[1])*(o[0]-t[0])<0,r=[],i=!1;for(let o=0;oBd(p.flat(),{})):null,m=o.kind==="inverse"?Bd(o.hull.flat(),{}):[];for(let p=0;p+2[t[2*E],t[2*E+1]]),x=y.map((E)=>[a(s[2*E]),a(s[2*E+1])]),b=[];if(f!==null)for(let E of f)b.push(JS(g,E,{}));else{let E=[...g],P=!1;for(let O=0;O0;O++){let B=m[O],I=m[(O+1)%m.length],R=qS(E,I,B);b.push({points:R.cut||P?R.points:[...g],cut:R.cut||P});let N=qS(E,B,I);P||=N.cut,E=N.points}d=!0}let[v,_,S]=g,k=_[1]-S[1],w=S[0]-_[0],T=v[0]-S[0],A=S[1]-v[1],C=1/(k*T+w*(v[1]-S[1]));for(let[E,{points:P,cut:O}]of b.entries()){if(d||=O,E===i.dropRegion)continue;if(P.length<3)continue;let B=l.length/2;if(!O)g.forEach(([I,R],N)=>{l.push(a(I),a(R)),u.push(x[N][0],x[N][1])});else for(let[I,R]of P){let N=(k*(I-S[0])+w*(R-S[1]))*C,L=(A*(I-S[0])+T*(R-S[1]))*C,U=1-N-L;l.push(a(I),a(R)),u.push(a(x[0][0]*N+x[1][0]*L+x[2][0]*U),a(x[0][1]*N+x[1][1]*L+x[2][1]*U))}for(let I=1;I+1e;function xE(e,t){let{width:n,height:s}=e,r=e.scaleX??1,i=e.scaleY??1,o=e.atlas,a=n/o.originalWidth*r,l=s/o.originalHeight*i,u=-n/2*r+o.offsetX*a,c=-s/2*i+o.offsetY*l,h=u+o.width*a,d=c+o.height*l,f=(e.rotation??0)*yE,m=Math.cos(f),p=Math.sin(f),y=e.x??0,g=e.y??0,x=[];for(let[b,v]of[[u,c],[u,d],[h,d],[h,c]]){let _=b*m+y-v*p,S=v*m+g+b*p;x.push(t.a*_+t.b*S+t.worldX,t.c*_+t.d*S+t.worldY)}return x}var Nd=new WeakMap;function nw(e,t){let n=[],s=new Map;for(let o of e.bindings)for(let a of o)if(!s.has(a.bone))s.set(a.bone,n.length),n.push(a.bone);let r=n.length,i=e.bindings.map((o)=>o.map((a)=>{let l=s.get(a.bone);return{bone:t===void 0?l:t(l,r),x:a.x,y:a.y,fx:Math.fround(a.x),fy:Math.fround(a.y),weight:Math.fround(a.weight)}}));return{bones:n,bindings:i}}function sw(e){let t=Nd.get(e);if(t===void 0)t=nw(e),Nd.set(e,t);return t}function rw(e,t){let n=Array(e.length);for(let s=0;stypeof e==="object"&&e!==null&&!Array.isArray(e),ws=(e)=>typeof e==="number"&&Number.isFinite(e),Dd=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function SE(e,t,n){if(!Bi(e)){n.push(`${t} is ${JSON.stringify(e)}, not an atlas rectangle`);return}let s=n.length;for(let r of Object.keys(e))if(!Dd.includes(r))n.push(`${t}: field "${r}" is not one this reader knows; it reads [${Dd.join(", ")}]`);for(let r of Dd)if(!ws(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])??"absent"}, not a finite number`);return n.length===s?e:void 0}function wE(e,t,n,s){if(!Bi(e)||typeof e.weighted!=="boolean"){s.push(`${t} is not { weighted: false, xy } or { weighted: true, bindings }`);return}let r=s.length;if(!e.weighted){let a=e.xy;if(!Array.isArray(a)||a.length%2!==0||!a.every(ws))s.push(`${t}.xy is not an even-length list of finite numbers`);return s.length===r?{weighted:!1,xy:a}:void 0}let i=e.bindings;if(!Array.isArray(i)){s.push(`${t}.bindings is not a list`);return}if(i.forEach((a,l)=>{if(!Array.isArray(a)||a.length===0){s.push(`${t}.bindings[${l}] is not a non-empty list of bindings`);return}a.forEach((u,c)=>{let h=`${t}.bindings[${l}][${c}]`;if(!Bi(u)){s.push(`${h} is not an object`);return}if(typeof u.bone!=="string"||!n.has(u.bone))s.push(`${h}: bone ${JSON.stringify(u.bone)} is not a bone of this document`);for(let d of["x","y","weight"])if(!ws(u[d]))s.push(`${h}: ${d} is ${JSON.stringify(u[d])??"absent"}, not a finite number`)})}),s.length!==r)return;let o={weighted:!0,bindings:i};return Nd.set(o,nw(o)),o}function iw(e,t,n,s,r,i){let o=i.length;switch(t){case"region":{for(let d of["x","y","rotation","scaleX","scaleY"])if(e[d]!==void 0&&!ws(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])}, not a finite number`);for(let d of["width","height"])if(!ws(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])??"absent"}, not a finite number`);let a=e.atlas!==void 0,l=e.sequence!==void 0,u,c;if(a===l)i.push(`${n}: the region carries ${a?"both an atlas rectangle and a sequence":"neither an atlas rectangle nor a sequence"}; the writer states exactly one of the two, and a sequence holds a rectangle per frame (issue #935)`);else if(a)u=e.atlas===null?null:Bi(e.atlas)?e.atlas:void 0;else{let d=e.sequence;if(!Bi(d))i.push(`${n}.sequence is not an object`);else{let f=d.count,m=d.setup??0;if(typeof f!=="number"||!Number.isInteger(f)||f<1)i.push(`${n}.sequence: count is ${JSON.stringify(f)}, not a whole number of at least 1`);else if(typeof m!=="number"||!Number.isInteger(m)||m<0||m>=f)i.push(`${n}.sequence: setup is ${JSON.stringify(d.setup)}, not a frame of the ${f}`);if(!Array.isArray(d.atlas)||d.atlas.length!==f)i.push(`${n}.sequence: atlas is not a list of ${JSON.stringify(f)} rectangle(s), one per frame`);else{let p=d.atlas.map((y,g)=>SE(y,`${n}.sequence.atlas[${g}]`,i));if(typeof m==="number"&&Number.isInteger(m)&&m>=0&&my!==void 0))c=p}}}if(i.length!==o||u===void 0)return;let h=(d)=>e[d]===void 0?{}:{[d]:e[d]};return{kind:"region",region:{...h("x"),...h("y"),...h("rotation"),...h("scaleX"),...h("scaleY"),width:e.width,height:e.height,atlas:u,...c===void 0?{}:{frames:c}}}}case"linkedmesh":{for(let a of["skin","slot","source"])if(typeof e[a]!=="string"||e[a]==="")i.push(`${n}: ${a} is ${JSON.stringify(e[a])??"absent"}, not a non-empty string`);if(typeof e.slot==="string"&&!r.has(e.slot))i.push(`${n}: slot "${e.slot}" is not a slot of this document`);if(i.length!==o)return;return{kind:"linkedmesh",skin:e.skin,slot:e.slot,source:e.source}}case"mesh":case"clipping":case"boundingbox":case"path":{let a=wE(e.vertices,`${n}.vertices`,s,i);if(t==="clipping"&&e.end!==void 0&&(typeof e.end!=="string"||!r.has(e.end)))i.push(`${n}: end is ${JSON.stringify(e.end)}, not a slot of this document`);if(t==="clipping"){for(let u of["inverse","convex"])if(e[u]!==void 0&&typeof e[u]!=="boolean")i.push(`${n}: ${u} is ${JSON.stringify(e[u])}, not a boolean`)}let l=t==="mesh"&&a!==void 0?kE(e,a,n,i):void 0;if(a===void 0||i.length!==o)return;if(t==="mesh")return l===void 0?void 0:{kind:t,vertices:a,...l};if(t==="clipping")return{kind:t,end:typeof e.end==="string"?e.end:null,vertices:a,inverse:e.inverse===!0,convex:e.convex===!0};if(t==="boundingbox")return{kind:t,vertices:a};return ME(e,a,n,i)}}}function kE(e,t,n,s){let r=s.length,i=t.weighted?t.bindings.length:t.xy.length/2,{uvs:o,triangles:a}=e;if(!Array.isArray(o)||!o.every(ws)||o.length!==2*i)s.push(`${n}.uvs is not ${2*i} finite numbers, one pair per vertex`);if(!Array.isArray(a)||a.length%3!==0||!a.every((u)=>Number.isInteger(u)&&u>=0&&u=0&&l<=i))s.push(`${n}.hull is ${JSON.stringify(l)}, not a whole number of vertices from 0 to ${i}`);return s.length===r?{uvs:o,triangles:a,...l===void 0?{}:{hull:l}}:void 0}function ME(e,t,n,s){let r=s.length;for(let a of["closed","constantSpeed"])if(e[a]!==void 0&&typeof e[a]!=="boolean")s.push(`${n}: ${a} is ${JSON.stringify(e[a])}, not a boolean`);let i=t.weighted?t.bindings.length:t.xy.length/2;if(e.vertexCount!==i)s.push(`${n}: vertexCount is ${JSON.stringify(e.vertexCount)??"absent"}, and the vertices hold ${i} point(s)`);else if(i%3!==0||i<(e.closed===!0?3:6))s.push(`${n}: vertexCount is ${i}, not a multiple of 3 of at least ${e.closed===!0?3:6} — the curve walk reads knots and handles in threes`);let o=e.lengths;if(!Array.isArray(o)||!o.every(ws))s.push(`${n}: lengths is not a list of finite numbers`);else if(o.length!==i/3)s.push(`${n}: lengths has ${o.length} entry(ies) where the vertices make ${i/3}`);if(s.length!==r)return;return{kind:"path",vertices:t,closed:e.closed===!0,constantSpeed:e.constantSpeed!==!1,lengths:o}}function Tl(e,t){for(let n=0;nb.geometry.kind==="clipping"),f=new Map;for(let b of e){let v=t.get(b.bone);if(v===void 0)throw Error(`slot "${b.slot}": bone "${b.bone}" has no world transform`);let{geometry:_,deform:S}=b,k=(w)=>S===void 0?a(w,v,t):r.vertices===void 0||r.deformedVertices!==void 0?l(w,S,v,t):a(Od(w,S),v,t,tw);if(_.kind==="region"){let w=b.frame===void 0?_.region.atlas:_.region.frames?.[b.frame]??_.region.atlas;if(w===null){h.push(`slot "${b.slot}" shows region "${b.name}" (skin "${b.skin}", placeholder "${b.placeholder}")`);continue}let T=o(w===_.region.atlas?_.region:{..._.region,atlas:w},v);if(u.push([b.slot,b.name,"region",Tl(T,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:Ml,uvs:kl})}else if(_.kind==="mesh"){let w=k(_.vertices);if(u.push([b.slot,b.name,"mesh",Tl(w,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:w,triangles:_.triangles,uvs:_.uvs})}else if(_.kind==="linkedmesh"){let w=n(_.skin,_.slot,_.source);if(typeof w==="string")throw Error(`slot "${b.slot}": ${w} (readModel refuses it first)`);let T=k(w);u.push([b.slot,b.name,"mesh",Tl(T,s)]);let A=i?.meshOf(_.skin,_.slot,_.source);if(i!==void 0&&A===void 0)throw Error(`slot "${b.slot}": the linked mesh's source "${_.source}" carries no triangles (readModel refuses it first)`);if(d&&A!==void 0)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:A.triangles,uvs:A.uvs})}else if(_.kind==="clipping"){let w=k(_.vertices);c.push([b.slot,b.name,_.end,Tl(w,s)]),f.set(b.slot,{slot:b.slot,kind:"clip",attachment:b.name,active:i?.active.has(b.bone)??!1,end:_.end,polygon:w,inverse:_.inverse,convex:_.convex})}}let m=h.length===0?null:`${h.join("; ")} — the model states the build had no atlas rectangle for it (atlas: null), and its corners read the trim and original size; a trim of 0 is not assumed`,p=null,y=i===void 0?"the draw order was not given":m,g=null,x=y;if(i!==void 0&&m===null&&!d)p=[],y=null,g=[],x=null;else if(i!==void 0&&m===null){let b=i.order.map((_)=>f.get(_)??{slot:_,kind:"none"}),v=QS(b,s,i.clip,i.through);p=v.rows,y=v.why,g=v.drawn,x=v.drawnWhy}return{attachments:m===null?u:null,attachmentsWhy:m,clips:c,clipped:p,clippedWhy:y,drawnClipped:g,drawnClippedWhy:x}}var kK=dn/180;var TE=["fixed","percent"],CE=["length","fixed","percent","proportional"],AE=["tangent","chain","chainScale"],ow=["bones","slot","positionMode","spacingMode","rotateMode","rotation","position","spacing","mixRotate","mixX","mixY","skin"],Al=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Ld(e,t,n,s,r,i){let o=e[t];if(o===void 0)return s;let a=typeof o==="string"&&o.length>0?o[0].toLowerCase()+o.slice(1):"",l=n.find((u)=>u===a);if(l===void 0)return i.push(`${r}: ${t} is ${JSON.stringify(o)}, none of ${n.join(", ")} (first letter in either case)`),s;return l}function Vn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function aw(e,t,n,s,r,i){let o=i.length;for(let d of Object.keys(e)){if(d==="kind"||d==="name"||d==="declaredIn")continue;if(!ow.includes(d))i.push(`${n}: field "${d}" is not one this reader knows; it reads [${ow.join(", ")}]`)}let a=[];if(!Array.isArray(e.bones)||e.bones.length===0)i.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`);else e.bones.forEach((d,f)=>typeof d==="string"&&s.has(d)?a.push(d):i.push(`${n}: bones[${f}] ${JSON.stringify(d)} is not a bone of this document`));let l=typeof e.slot==="string"?e.slot:"",u=r.get(l);if(u===void 0)i.push(`${n}: slot is ${JSON.stringify(e.slot)}, not a slot of this document`);if(e.skin!==void 0&&typeof e.skin!=="boolean")i.push(`${n}: skin is ${JSON.stringify(e.skin)}, not a boolean`);let c=Vn(e,"mixX",1,n,i),h={kind:"path",name:t,bones:a,slot:l,slotBone:u??"",positionMode:Ld(e,"positionMode",TE,"percent",n,i),spacingMode:Ld(e,"spacingMode",CE,"length",n,i),rotateMode:Ld(e,"rotateMode",AE,"tangent",n,i),offsetRotation:Vn(e,"rotation",0,n,i),position:Vn(e,"position",0,n,i),spacing:Vn(e,"spacing",0,n,i),mixRotate:Vn(e,"mixRotate",1,n,i),mixX:c,mixY:Vn(e,"mixY",c,n,i),skin:e.skin===!0,listedBySkin:!1,path:null,unresolved:null,slotDeps:[]};return i.length===o?h:void 0}var Ud={position:["value"],spacing:["value"],mix:["mixRotate","mixX","mixY"]};function EE(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function lw(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.path[${o}]`;if(!Al(i)||typeof i.name!=="string"){s.push(`${a} names no constraint`);return}if(!n.has(i.name))s.push(`${a}: "${i.name}" is not a path constraint of this document`);let l={name:i.name};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!Al(u)||typeof u.name!=="string"||!(u.name in Ud)){s.push(`${h}: ${Al(u)?JSON.stringify(u.name):"it"} is not a path timeline; they are ${Object.keys(Ud).join(", ")}`);return}let d=u.name;if(l[d]!==void 0)s.push(`${h}: "${d}" is keyed twice on path constraint "${i.name}"`);let f=Ud[d],m=u.keys;if(!Array.isArray(m)||m.length===0){s.push(`${h}: keys is not a non-empty list`);return}let p=-1/0,y=[];m.forEach((g,x)=>{let b=`${h}.keys[${x}]`;if(!Al(g)){s.push(`${b} is not an object`);return}for(let S of Object.keys(g))if(S!=="time"&&S!=="curve"&&!f.includes(S))s.push(`${b}: field "${S}" is not one this reader knows; it reads [time, ${f.join(", ")}, curve]`);let v=g.time;if(typeof v!=="number"||!Number.isFinite(v)||v<0){s.push(`${b}: time is ${JSON.stringify(v)}, not a finite time at or after 0`);return}if(v<=p)s.push(`${b}: time ${v} is not after the key before it — the writer refuses key times that do not strictly increase`);p=Math.max(p,v);let _=f.map((S)=>{if(S==="mixY"&&g.mixY===void 0)return Vn(g,"mixX",1,b,s);return Vn(g,S,d==="mix"?1:0,b,s)});y.push({time:Math.fround(v),values:_.map(Math.fround),stated:{time:v,values:_},curve:EE(g,f.length,x===m.length-1,b,s)})}),l[d]=y}),r.push(l)}),r}var AK=dn/180,cw=["bone","scaleY","x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix","inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],PE=["x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix"],RE=["inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],uw=["none","uniform","volume"];var dw=["inertia","strength","damping","mass","wind","gravity","mix"],hw=[...dw,"reset"],Wd="*",$E={x:0,y:0,rotate:0,scaleX:0,shearX:0,limit:5000,fps:60,inertia:0.5,strength:100,damping:0.85,mass:1,wind:0,gravity:0,mix:1};function fw(e,t,n,s,r,i){let o=i.length;for(let c of Object.keys(e)){if(c==="kind"||c==="name"||c==="declaredIn")continue;if(!cw.includes(c))i.push(`${n}: field "${c}" is not one this reader knows; it reads [${cw.join(", ")}]`)}if(typeof e.bone!=="string"||!s.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);for(let c of PE){let h=e[c];if(h!==void 0&&(typeof h!=="number"||!Number.isFinite(h)))i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a finite number`)}for(let c of RE){let h=e[c];if(h!==void 0&&typeof h!=="boolean")i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a boolean`)}let a="None";if(e.scaleY!==void 0){let c=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"";if(!uw.includes(c))i.push(`${n}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${uw.join(", ")}`);else a=c==="uniform"?"Uniform":c==="volume"?"Volume":"None"}if(i.length!==o)return;let l=(c)=>typeof e[c]==="number"?e[c]:$E[c],u={};for(let c of dw)u[c]=e[`${c}Global`]===!0;return{kind:"physics",name:t,bone:e.bone,skin:e.skin===!0,listedBySkin:!1,x:l("x"),y:l("y"),rotate:l("rotate"),scaleX:l("scaleX"),shearX:l("shearX"),limit:l("limit"),step:1/l("fps"),referenceScale:r,inertia:l("inertia"),strength:l("strength"),damping:l("damping"),massInverse:1/l("mass"),wind:l("wind"),gravity:l("gravity"),mix:l("mix"),global:u,scaleYMode:a}}var Fi=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function mw(e){if(!Array.isArray(e))return 0;let t=0;for(let n of e)if(typeof n==="object"&&n!==null&&Array.isArray(n.timelines))t+=n.timelines.length;return t}function pw(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.physics[${o}]`;if(!Fi(i)||typeof i.name!=="string"){s.push(`${a} names no physics constraint`);return}let l=i.name;if(l!==Wd&&!n.has(l))s.push(`${a}: "${l}" is not a physics constraint of this document (nor "${Wd}", the timeline naming none)`);if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}let u=new Set;i.timelines.forEach((c,h)=>{let d=`${a}.timelines[${h}]`,f=Fi(c)?hw.find((g)=>g===c.name):void 0;if(!Fi(c)||f===void 0){s.push(`${d}: ${JSON.stringify(Fi(c)?c.name:c)} is not a physics timeline; one keys ${hw.join(", ")}`);return}if(u.has(f))s.push(`${d}: "${f}" is keyed twice on "${l}"`);u.add(f);let m=[],p=c.keys;if(!Array.isArray(p)||p.length===0){s.push(`${d} "${f}": keys is not a non-empty list`);return}let y=-1/0;p.forEach((g,x)=>{let b=`${d} "${f}".keys[${x}]`;if(!Fi(g)){s.push(`${b} is not an object`);return}let v=f==="reset"?["time"]:["time","value","curve"];for(let w of Object.keys(g))if(!v.includes(w))s.push(`${b}: field "${w}" is not one this reader knows; it reads [${v.join(", ")}]`);let _=g.time;if(typeof _!=="number"||!Number.isFinite(_)||_<0){s.push(`${b}: time is ${JSON.stringify(_)}, not a finite time at or after 0`);return}if(_<=y)s.push(`${b}: time ${_} is not after the key before it — the writer refuses key times that do not strictly increase`);if(y=Math.max(y,_),f==="reset"){m.push({time:Math.fround(_),values:[],stated:{time:_,values:[]},curve:"stepped"});return}let S=f==="mix"?1:0;if(g.value!==void 0)if(typeof g.value!=="number"||!Number.isFinite(g.value))s.push(`${b}: value is ${JSON.stringify(g.value)}, not a finite number`);else S=g.value;let k="linear";if(g.curve!==void 0)if(x===p.length-1)s.push(`${b}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(g.curve==="stepped")k="stepped";else if(Array.isArray(g.curve)&&g.curve.length===4&&g.curve.every((w)=>typeof w==="number"&&Number.isFinite(w)))k=g.curve;else s.push(`${b}: curve is ${JSON.stringify(g.curve)}, not "stepped" nor four finite numbers`);m.push({time:Math.fround(_),values:[Math.fround(S)],stated:{time:_,values:[S]},curve:k})}),r.push({name:l,kind:f,keys:m})})}),r}var OE=Object.freeze({wind:Object.freeze([1,0]),gravity:Object.freeze([0,1])});var IE=dn*2,RK=1/IE;var gw=["animation","additive","loop","mix","bone","property","from","to","scale","max","local","time","skin"],El=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function yw(e,t,n,s,r,i){let o=i.length;for(let y of Object.keys(e)){if(y==="kind"||y==="name"||y==="declaredIn")continue;if(!gw.includes(y))i.push(`${n}: field "${y}" is not one this reader knows; it reads [${gw.join(", ")}]`)}let a=(y,g)=>{let x=e[y];if(x===void 0)return g;if(typeof x!=="number"||!Number.isFinite(x))return i.push(`${n}: ${y} is ${JSON.stringify(x)}, not a finite number`),g;return x},l=(y)=>{let g=e[y];if(g===void 0)return!1;if(typeof g!=="boolean")return i.push(`${n}: ${y} is ${JSON.stringify(g)}, not a boolean`),!1;return g},u=r.find((y)=>y.name===e.animation);if(u===void 0)i.push(`${n}: a slider's animation is ${JSON.stringify(e.animation)}, not an animation of this document`);let c=new Map(s.map((y)=>[y.name,y])),h=null;if(e.bone!==void 0)if(typeof e.bone!=="string"||!c.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);else h=e.bone;let d="rotate";if(e.property!==void 0){let y=jn.find((g)=>g===e.property);if(y===void 0)i.push(`${n}: property is ${JSON.stringify(e.property)}, none of ${jn.join(", ")}`);else d=y}a("max",0);let f=l("loop"),m=new Map;for(let y of u?.timelines.bones??[]){let g=c.get(y.name);if(g!==void 0)m.set(g.name,g)}let p={kind:"slider",name:t,animation:u?.name??"",timelines:u?.timelines??{declared:0,duration:0,bones:[],slots:[],later:[],attachments:[],drawOrder:[],events:[]},physics:[],setup:m,additive:l("additive"),loop:f,mix:a("mix",1),time:a("time",0),bone:h,property:d,from:a("from",0),to:a("to",0),scale:a("scale",1),local:l("local"),skin:l("skin"),listedBySkin:!1};return i.length===o?p:void 0}function xw(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.slider[${o}]`;if(!El(i)||typeof i.name!=="string"){s.push(`${a} names no slider`);return}if(!n.some((u)=>u.kind==="slider"&&u.name===i.name))s.push(`${a}: "${i.name}" is not a slider of this document`);let l={name:i.name,time:null,mix:null};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!El(u)||u.name!=="time"&&u.name!=="mix"){s.push(`${h}: ${JSON.stringify(El(u)?u.name:u)} is not a slider timeline; a slider keys time and mix`);return}let d=u.name;if(l[d]!==null)s.push(`${h}: "${d}" is keyed twice on slider "${i.name}"`);l[d]=FE(u.keys,`${h} "${d}"`,s)}),r.push(l)}),r}function FE(e,t,n){let s=[];if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),s;let r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!El(i)){n.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(h!=="time"&&h!=="value"&&h!=="curve")n.push(`${a}: field "${h}" is not one this reader knows; it reads [time, value, curve]`);let l=i.time;if(typeof l!=="number"||!Number.isFinite(l)||l<0){n.push(`${a}: time is ${JSON.stringify(l)}, not a finite time at or after 0`);return}if(l<=r)n.push(`${a}: time ${l} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l);let u=1;if(i.value!==void 0)if(typeof i.value!=="number"||!Number.isFinite(i.value))n.push(`${a}: value is ${JSON.stringify(i.value)}, not a finite number`);else u=i.value;let c="linear";if(i.curve!==void 0)if(o===e.length-1)n.push(`${a}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(i.curve==="stepped")c="stepped";else if(Array.isArray(i.curve)&&i.curve.length===4&&i.curve.every((h)=>typeof h==="number"&&Number.isFinite(h)))c=i.curve;else n.push(`${a}: curve is ${JSON.stringify(i.curve)}, not "stepped" nor 4 finite numbers`);s.push({time:Math.fround(l),values:[Math.fround(u)],stated:{time:l,values:[u]},curve:c})}),s}var o7=180/dn,a7=dn/180;var jn=["rotate","x","y","scaleX","scaleY","shearY"],bw={rotate:"mixRotate",x:"mixX",y:"mixY",scaleX:"mixScaleX",scaleY:"mixScaleY",shearY:"mixShearY"},DE={rotate:"rotation",x:"x",y:"y",scaleX:"scaleX",scaleY:"scaleY",shearY:"shearY"},vw=["none","uniform","volume"],NE={ik:["bones","target","scaleY","mix","softness","bendPositive","compress","stretch","skin"],transform:["bones","source","properties","localSource","localTarget","additive","clamp","rotation","x","y","scaleX","scaleY","shearY","mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY","skin"]},Yn=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Pl(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function mn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function sn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="boolean")return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a boolean`),n;return i}function GE(e,t,n,s){if(!Array.isArray(e.bones)||e.bones.length===0)return s.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`),[];let r=[];return e.bones.forEach((i,o)=>{if(typeof i!=="string"||!t.has(i))s.push(`${n}: bones[${o}] ${JSON.stringify(i)} is not a bone of this document`);else r.push(i)}),r}function _w(e,t,n,s,r){let i=e[t];if(typeof i!=="string"||!n.has(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a bone of this document`),"";return i}function Vd(e,t,n,s,r){if(e[bw[t]]!==void 0)return mn(e,bw[t],0,s,r);if(t==="y")return n.has("x")?Vd(e,"x",n,s,r):0;if(t==="scaleY")return n.has("scaleX")?Vd(e,"scaleX",n,s,r):0;return n.has(t)?1:0}function kw(e,t,n,s,r,i,o){let a=o.length,l={...e};delete l.kind,delete l.name,delete l.declaredIn,Pl(l,NE[t],s,o);let u=GE(e,r,s,o),c=sn(e,"skin",!1,s,o);if(t==="ik"){let g=_w(e,"target",r,s,o);if(u.length>2)o.push(`${s}: an ik constraint names ${u.length} bones; the format takes one or two`);if(u.length>=1&&i.get(u[0])===void 0)o.push(`${s}: its first bone "${u[0]}" is the root; spine-core throws posing an ik constraint on a bone with no parent`);if(u.length===2&&i.get(u[1])!==u[0])o.push(`${s}: "${u[1]}" is not a child of "${u[0]}"; a two-bone ik needs the second bone directly under the first`);let x="none";if(e.scaleY!==void 0){let v=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"",_=vw.find((S)=>S===v);if(_===void 0)o.push(`${s}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${vw.join(", ")}`);else x=_}let b={kind:t,name:n,bones:u,target:g,scaleY:x,skin:c,listedBySkin:!1,mix:mn(e,"mix",1,s,o),softness:mn(e,"softness",0,s,o),bendPositive:sn(e,"bendPositive",!0,s,o),compress:sn(e,"compress",!1,s,o),stretch:sn(e,"stretch",!1,s,o)};return o.length===a?b:void 0}let h=_w(e,"source",r,s,o),d=[],f=new Set;if(e.properties!==void 0&&!Yn(e.properties))o.push(`${s}: properties is not an object`);else if(Yn(e.properties))for(let[g,x]of Object.entries(e.properties)){let b=`${s}.properties.${g}`,v=jn.find((S)=>S===g);if(v===void 0){o.push(`${b}: "${g}" is none of ${jn.join(", ")}`);continue}if(!Yn(x)){o.push(`${b} is not an object`);continue}Pl(x,["offset","to"],b,o);let _=[];if(!Yn(x.to))o.push(`${b}: to is not an object`);else for(let[S,k]of Object.entries(x.to)){let w=`${b}.to.${S}`,T=jn.find((A)=>A===S);if(T===void 0){o.push(`${w}: "${S}" is none of ${jn.join(", ")}`);continue}if(!Yn(k)){o.push(`${w} is not an object`);continue}Pl(k,["offset","scale","max"],w,o),_.push({property:T,offset:mn(k,"offset",0,w,o),scale:mn(k,"scale",1,w,o),max:mn(k,"max",1,w,o)}),f.add(T)}d.push({property:v,offset:mn(x,"offset",0,b,o),to:_})}let m={},p={};for(let g of jn)m[g]=mn(e,DE[g],0,s,o),p[g]=Vd(e,g,f,s,o);let y={kind:t,name:n,bones:u,source:h,properties:d,skin:c,listedBySkin:!1,offsets:m,mixes:p,localSource:sn(e,"localSource",!1,s,o),localTarget:sn(e,"localTarget",!1,s,o),additive:sn(e,"additive",!1,s,o),clamp:sn(e,"clamp",!1,s,o)};return o.length===a?y:void 0}var Sw=["mix","softness"],ww=["mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY"];function LE(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function Mw(e,t,n,s){let r={ik:[],transform:[],path:[],physics:0,slider:[]};if(!Yn(e))return r;r.path=lw(e.path,t,new Set(n.filter((i)=>i.kind==="path").map((i)=>i.name)),s),r.physics=mw(e.physics),r.physicsKeyed=pw(e.physics,t,new Set(n.filter((i)=>i.kind==="physics").map((i)=>i.name)),s),r.slider=xw(e.slider,t,n,s);for(let i of["ik","transform"]){let o=e[i];if(!Array.isArray(o))continue;o.forEach((a,l)=>{let u=`${t}.constraints.${i}[${l}]`;if(!Yn(a)||typeof a.name!=="string"){s.push(`${u} names no constraint`);return}if(!n.some((p)=>p.kind===i&&p.name===a.name))s.push(`${u}: "${a.name}" is not a ${i} constraint of this document`);let c=a.keys;if(!Array.isArray(c)||c.length===0){s.push(`${u}: keys is not a non-empty list`);return}let h=i==="ik"?Sw:ww,d=i==="ik"?["time",...Sw,"bendPositive","compress","stretch","curve"]:["time",...ww,"curve"],f=-1/0,m=[];if(c.forEach((p,y)=>{let g=`${u}.keys[${y}]`;if(!Yn(p)){s.push(`${g} is not an object`);return}Pl(p,d,g,s);let x=p.time;if(typeof x!=="number"||!Number.isFinite(x)||x<0){s.push(`${g}: time is ${JSON.stringify(x)}, not a finite time at or after 0`);return}if(x<=f)s.push(`${g}: time ${x} is not after the key before it — the writer refuses key times that do not strictly increase`);f=Math.max(f,x);let b=h.map((v)=>{if(i==="transform"&&v==="mixY"&&p.mixY===void 0)return mn(p,"mixX",1,g,s);return mn(p,v,v==="softness"?0:1,g,s)});m.push({time:Math.fround(x),values:b.map(Math.fround),stated:{time:x,values:b},curve:LE(p,h.length,y===c.length-1,g,s),flags:{bendPositive:sn(p,"bendPositive",!0,g,s),compress:sn(p,"compress",!1,g,s),stretch:sn(p,"stretch",!1,g,s)}})}),i==="ik")r.ik.push({name:a.name,keys:m});else r.transform.push({name:a.name,keys:m})})}return r}var Ew={rotate:["value"],translate:["x","y"],translatex:["value"],translatey:["value"],scale:["x","y"],scalex:["value"],scaley:["value"],shear:["x","y"],shearx:["value"],sheary:["value"]},HE=[...Object.keys(Ew),"inherit"],zd={rgba:{fields:[["color",8]],channels:["r","g","b","a"]},rgb:{fields:[["color",6]],channels:["r","g","b"]},alpha:{fields:[],channels:["a"]},rgba2:{fields:[["light",8],["dark",6]],channels:["r","g","b","a","r2","g2","b2"]},rgb2:{fields:[["light",6],["dark",6]],channels:["r","g","b","r2","g2","b2"]}},zE=["attachment",...Object.keys(zd)];var wr=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),qE=(e,t)=>typeof e==="string"&&e.length===t&&/^[0-9a-fA-F]+$/.test(e);function Pw(e,t,n){let s=e.time;if(typeof s!=="number"||!Number.isFinite(s)||s<0)return n.push(`${t}: time is ${JSON.stringify(s)}, not a finite time at or after 0`),null;return s}function Rw(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),[];let s=[],r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!wr(i)){n.push(`${a} is not an object`);return}let l=Pw(i,a,n);if(l===null)return;if(l<=r)n.push(`${a}: time ${i.time} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l),s.push({raw:i,at:a,time:l})}),s}function Di(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this timeline's keys carry; they carry [${t.join(", ")}]`)}function $w(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function KE(e,t,n,s){let r=Rw(t,n,s);return r.map(({raw:i,at:o,time:a},l)=>{if(e==="inherit"){Di(i,["time","inherit"],o,s);let h=typeof i.inherit==="string"?qd(i.inherit):null;if(h===null)s.push(`${o}: inherit is ${JSON.stringify(i.inherit)}, which folds to no inherit mode`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",mode:h??"normal"}}let u=Ew[e];Di(i,["time",...u,"curve"],o,s);let c=u.map((h)=>{let d=i[h];if(typeof d!=="number"||!Number.isFinite(d))return s.push(`${o}: ${h} is ${JSON.stringify(d)}, not a finite number — the writer states every channel on every key`),0;return d});return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:$w(i,u.length,l===r.length-1,o,s)}})}function JE(e,t){let n=[];for(let s=0;s{if(e==="attachment"){if(Di(i,["time","name"],o,s),i.name!==null&&(typeof i.name!=="string"||i.name===""))s.push(`${o}: name is ${JSON.stringify(i.name)}, not a placeholder name or null`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",name:typeof i.name==="string"?i.name:null}}let u=zd[e],c=[];if(e==="alpha"){Di(i,["time","value","curve"],o,s);let h=i.value;if(typeof h!=="number"||!Number.isFinite(h))s.push(`${o}: value is ${JSON.stringify(h)}, not a finite number`);else c=[h]}else{Di(i,["time",...u.fields.map(([h])=>h),"curve"],o,s);for(let[h,d]of u.fields){let f=i[h];if(!qE(f,d))s.push(`${o}: ${h} is ${JSON.stringify(f)}, not ${d} hex digits — the one spelling the writer gives a ${e} key's ${h}`);else c.push(...JE(f,h==="dark"||d===6?3:4))}}if(c.length!==u.channels.length)c=u.channels.map(()=>0);return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:$w(i,u.channels.length,l===r.length-1,o,s)}})}function QE(e,t,n){let s=[],r=0,i=(a,l)=>{if(r++,!Array.isArray(a)){n.push(`${l} is not a list of keys`);return}a.forEach((u,c)=>{if(!wr(u))n.push(`${l}[${c}] is not an object`);else{let h=Pw(u,`${l}[${c}]`,n);if(h!==null)s.push(Math.fround(h))}})},o=(a,l,u)=>{if(!Array.isArray(a)){n.push(`${l} is not a list`);return}a.forEach((c,h)=>wr(c)?u(c,`${l}[${h}]`):n.push(`${l}[${h}] is not an object`))};if(!wr(e))n.push(`${t} is not an object`);else{for(let a of["ik","transform"])o(e[a],`${t}.${a}`,(l,u)=>i(l.keys,`${u}.keys`));for(let a of["path","physics","slider"])o(e[a],`${t}.${a}`,(l,u)=>o(l.timelines,`${u}.timelines`,(c,h)=>i(c.keys,`${h}.keys`)))}return{timelines:r,times:s}}function Ow(e,t,n,s,r,i){let o=typeof e.duration==="number"&&Number.isFinite(e.duration)?e.duration:0;if(typeof e.duration!=="number"||!Number.isFinite(e.duration))r.push(`${t}: duration is ${JSON.stringify(e.duration)}, not a finite number`);let a=new Map(s.map((x)=>[x.name,x])),l=[],u=(x,b,v,_)=>{let S=e[x],k=[];if(!Array.isArray(S))return r.push(`${t}: ${x} is not a list`),k;return S.forEach((w,T)=>{let A=`${t}.${x}[${T}]`;if(!wr(w)||typeof w.name!=="string"){r.push(`${A} names no target`);return}let C=`${A} "${w.name}"`,E=v(w.name);if(E!==null)r.push(`${C}: ${E}`);if(!Array.isArray(w.timelines)){r.push(`${C}: timelines is not a list`);return}let P=w.name,O={name:P,timelines:[]};w.timelines.forEach((B,I)=>{let R=`${C}.timelines[${I}]`;if(!wr(B)||typeof B.name!=="string"){r.push(`${R} names no timeline`);return}let N=b.find((U)=>U===B.name);if(N===void 0){r.push(`${R}: "${B.name}" is not a ${x==="bones"?"bone":"slot"} timeline this core reads; it reads [${b.join(", ")}]`);return}if(O.timelines.some((U)=>U.kind===N))r.push(`${R}: "${N}" is keyed twice on ${P} — the writer merges one property's tracks into one`);let L=_(N,B.keys,`${R} "${N}"`,P);for(let U of L)l.push(U.time);O.timelines.push({kind:N,keys:L})}),k.push(O)}),k},c=u("bones",HE,(x)=>n.has(x)?null:`"${x}" is not a bone of this document`,(x,b,v)=>KE(x,b,v,r)),h=u("slots",zE,(x)=>a.has(x)?null:`"${x}" is not a slot of this document`,(x,b,v,_)=>{if((x==="rgba2"||x==="rgb2")&&a.get(_)?.dark===void 0)r.push(`${v}: slot "${_}" states no dark colour, and a ${x} timeline on such a slot makes the runtime throw while it is applied — the writer refuses it`);return ZE(x,b,v,r)}),d=[],f=QE(e.constraints,`${t}.constraints`,r);if(l.push(...f.times),f.timelines>0)d.push(["constraints",f.timelines]);let m=GS(e.attachments,t,i.skins,r),p=US(e.drawOrder,t,s,r),y=HS(e.events,t,i.events,r);for(let x of m)for(let b of[...x.deform??[],...x.sequence??[]])l.push(b.time);for(let x of[...p,...y])l.push(x.time);let g=m.reduce((x,b)=>x+(b.deform===null?0:1)+(b.sequence===null?0:1),0);if(g>0)d.push(["attachments",g]);if(p.length>0)d.push(["drawOrder",1]);if(y.length>0)d.push(["events",1]);return{declared:o,duration:l.length===0?0:Math.max(...l),bones:c,slots:h,later:d,attachments:m,drawOrder:p,events:y}}var ks="rigc-compiled/3",Zd="rigc-compiled/2",Qd="rigc-compiled/1",Xw=[ks,Zd,Qd];class ot extends Error{}var Vw=["referenceScale","stage","bones","slots","skins","constraints","events","animations","editorOrder","images","pageGrids","droppedStates","absentParts","meshBones","meshes","physics","deformTransforms","trackDerivations","rig","pages","spine"],jw=Vw.filter((e)=>e!=="stage"&&e!=="editorOrder"),tP=jw.filter((e)=>e!=="pages"),Yw=["name","width","height","pma","scale","regions"],nP=Yw.filter((e)=>e!=="pma"&&e!=="scale"),Fw=["x","y","width","height"],Dw=["slot","attachment"],Nw=["name","x","y","width","height","offsetX","offsetY","originalWidth","originalHeight","degrees","index"],sP=["name","parent","length","x","y","rotation","scaleX","scaleY","shearX","shearY","inheritMode","skinRequired","editor"],rP=["length","x","y","rotation","scaleX","scaleY","shearX","shearY"],iP=["name","bone","setup","color","dark","blend"],oP=["name","bones","constraints","attachments"],Gw={mesh:["kind","name","path","color","uvs","triangles","vertices","hull","edges","width","height","sequence"],boundingbox:["kind","name","vertexCount","vertices","editorColor"],clipping:["kind","name","end","convex","inverse","vertexCount","vertices","editorColor"],path:["kind","name","closed","constantSpeed","vertexCount","vertices","lengths","editorColor"],region:["kind","name","path","x","y","rotation","scaleX","scaleY","width","height","color","sequence","atlas"],linkedmesh:["kind","name","path","source","skin","slot","timelines","width","height","color","sequence"]},aP=new Set(["region","mesh","linkedmesh"]),Hw=/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/,ef=["Normal","Additive","Multiply","Screen"];function lP(e){let t=`${e.slice(0,1).toUpperCase()}${e.slice(1)}`;return ef.includes(t)?t:null}var kr=["ik","transform","path","physics","slider"],zw=["normal","onlyTranslation","noRotationOrReflection","noScale","noScaleOrReflection"],Lw=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function cP(e,t,n){if(!Array.isArray(e))return t.push(`pages is ${JSON.stringify(e)??"absent"}, not a list of pages`),[];let s=[];return e.forEach((r,i)=>{let o=`pages[${i}]`;if(!Le(r)){t.push(`${o} is not an object`);return}let a=t.length,l=typeof r.name==="string"?`${o} "${r.name}"`:o;if(jt(r,n?Yw:nP,l,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)??"absent"}, not a non-empty string`);for(let c of["width","height"]){let h=r[c];if(typeof h!=="number"||!Number.isFinite(h)||h<=0)t.push(`${l}: ${c} is ${JSON.stringify(h)??"absent"}, not a positive finite number — a page UV divides by it`)}if(n){if(typeof r.pma!=="boolean")t.push(`${l}: pma is ${JSON.stringify(r.pma)??"absent"}, not true or false — whether the page's texels are premultiplied`);if(r.scale!==null&&(typeof r.scale!=="number"||!Number.isFinite(r.scale)))t.push(`${l}: scale is ${JSON.stringify(r.scale)??"absent"}, not a finite number or null — the number the page's scale: line states, null where it has none`)}let u=[];if(!Array.isArray(r.regions))t.push(`${l}: regions is not a list`);else if(r.regions.length===0)t.push(`${l}: regions is an empty list — a page holds at least one region; the atlas text cannot state a page with none (its block would end before a region line, which A07_ATLAS_TEXT_SHAPE refuses), so no build writes one`);else r.regions.forEach((c,h)=>{let d=`${l}.regions[${h}]`;if(!Le(c)){t.push(`${d} is not an object`);return}let f=typeof c.name==="string"?`${d} "${c.name}"`:d;if(jt(c,Nw,f,t),typeof c.name!=="string"||c.name==="")t.push(`${d}: name is ${JSON.stringify(c.name)??"absent"}, not a non-empty string`);for(let m of Nw){if(m==="name")continue;let p=c[m];if(typeof p!=="number"||!Number.isFinite(p))t.push(`${f}: ${m} is ${JSON.stringify(p)??"absent"}, not a finite number`)}u.push(c)});if(t.length===a)s.push(n?{name:r.name,width:r.width,height:r.height,pma:r.pma,scale:r.scale,regions:u}:{name:r.name,width:r.width,height:r.height,regions:u})}),s}function uP(e,t){if(e===void 0)return"";if(!Le(e))return t.push(`spine is ${JSON.stringify(e)}, not { "sha256": "<64 lowercase hex digits>" }`),"";for(let s of Object.keys(e))if(s!=="sha256")t.push(`spine: field "${s}" is not one this reader knows; it reads [sha256]`);let n=e.sha256;if(typeof n!=="string"||!/^[0-9a-f]{64}$/.test(n))return t.push(`spine.sha256 is ${JSON.stringify(n)??"absent"}, not 64 lowercase hex digits — the SHA-256 of the skeleton.json written beside the document`),"";return n}function hP(e,t){if(e===null)return null;if(!Le(e))return t.push(`stage is ${JSON.stringify(e)??"absent"}, not null or { x, y, width, height } — the setup-pose box the Spine header declares`),null;let n=t.length;jt(e,[...Fw,"box"],"stage",t);for(let i of Fw){let o=e[i];if(typeof o!=="number"||!Number.isFinite(o))t.push(`stage: ${i} is ${JSON.stringify(o)??"absent"}, not a finite number`)}let s=e.box;if(s!==void 0)if(!Le(s))t.push(`stage.box is ${JSON.stringify(s)}, not { slot, attachment }`);else{jt(s,Dw,"stage.box",t);for(let i of Dw)if(typeof s[i]!=="string"||s[i]==="")t.push(`stage.box: ${i} is ${JSON.stringify(s[i])??"absent"}, not a non-empty string`)}if(t.length!==n)return null;let r={x:e.x,y:e.y,width:e.width,height:e.height};if(Le(s))r.box={slot:s.slot,attachment:s.attachment};return r}function dP(e,t,n,s){let r={skins:[],animations:[]};if(!Le(e))return s.push(`editorOrder is ${JSON.stringify(e)??"absent"}, not { skins, animations }`),r;jt(e,["skins","animations"],"editorOrder",s);let i=(l,u)=>{if(!Array.isArray(l)||l.some((c)=>typeof c!=="string"))return s.push(`${u} is ${JSON.stringify(l)??"absent"}, not a list of names`),null;return l},o=(l,u,c,h)=>{let d=new Set;for(let m of l){if(d.has(m))return void s.push(`${c} lists ${h} "${m}" twice`);if(d.add(m),!u.includes(m))return void s.push(`${c} lists ${h} "${m}", which the document does not hold`)}let f=u.find((m)=>!d.has(m));if(f!==void 0)s.push(`${c} leaves out ${h} "${f}"`)};if(!Array.isArray(e.skins))s.push(`editorOrder.skins is ${JSON.stringify(e.skins)??"absent"}, not a list`);else e.skins.forEach((l,u)=>{let c=`editorOrder.skins[${u}]`;if(!Le(l)||typeof l.name!=="string")return void s.push(`${c} is not { name, slots }`);jt(l,["name","slots"],c,s);let h=i(l.slots,`${c}.slots`),d=t.find((f)=>f.name===l.name);if(h!==null&&d!==void 0)o(h,Object.keys(d.attachments),`${c}.slots`,"slot key");r.skins.push({name:l.name,slots:h??[]})}),o(r.skins.map((l)=>l.name),t.map((l)=>l.name),"editorOrder.skins","skin");let a=i(e.animations,"editorOrder.animations");if(a!==null)o(a,n.map((l)=>l.name),"editorOrder.animations","animation"),r.animations=a;return r}var Le=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function qd(e){let t=e.length===0?e:e[0].toLowerCase()+e.slice(1);return zw.find((n)=>n===t)??null}function jt(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function fP(e,t){if(!Array.isArray(e))return t.push("bones is not a list"),[];let n=[],s=new Set;return e.forEach((r,i)=>{let o=`bones[${i}]`;if(!Le(r)){t.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(jt(r,sP,a,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);else if(s.has(r.name))t.push(`${a}: the name is declared twice`);if(r.parent!==void 0){if(typeof r.parent!=="string")t.push(`${a}: parent is ${JSON.stringify(r.parent)}, not a bone name`);else if(!s.has(r.parent))t.push(`${a}: parent "${r.parent}" is not declared before it; bones are parents first`)}for(let l of rP){let u=r[l];if(u!==void 0&&(typeof u!=="number"||!Number.isFinite(u)))t.push(`${a}: ${l} is ${JSON.stringify(u)}, not a finite number`)}if(r.inheritMode!==void 0){if(typeof r.inheritMode!=="string"||qd(r.inheritMode)===null)t.push(`${a}: inheritMode is ${JSON.stringify(r.inheritMode)}, which folds to none of ${zw.join(", ")}`)}if(r.skinRequired!==void 0&&typeof r.skinRequired!=="boolean")t.push(`${a}: skinRequired is ${JSON.stringify(r.skinRequired)}, not a boolean`);if(r.editor!==void 0)if(!Le(r.editor))t.push(`${a}: editor is not an object`);else{jt(r.editor,["color","icon"],`${a}.editor`,t);for(let l of["color","icon"])if(r.editor[l]!==void 0&&typeof r.editor[l]!=="string")t.push(`${a}.editor: ${l} is not a string`)}if(typeof r.name==="string"&&r.name!=="")s.add(r.name);n.push(r)}),n}function mP(e,t,n){if(!Array.isArray(e))return n.push("slots is not a list"),[];let s=[];return e.forEach((r,i)=>{let o=`slots[${i}]`;if(!Le(r)){n.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(jt(r,iP,a,n),typeof r.name!=="string"||r.name==="")n.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);if(typeof r.bone!=="string")n.push(`${a}: bone is ${JSON.stringify(r.bone)}, not a bone name`);else if(!t.has(r.bone))n.push(`${a}: bone "${r.bone}" is not a bone of this document`);if(r.setup!==null&&typeof r.setup!=="string")n.push(`${a}: setup is ${JSON.stringify(r.setup)}, not a placeholder name or null`);for(let l of["color","dark","blend"])if(r[l]!==void 0&&typeof r[l]!=="string")n.push(`${a}: ${l} is ${JSON.stringify(r[l])}, not a string`);for(let l of["color","dark"]){let u=r[l];if(typeof u==="string"&&!Hw.test(u))n.push(`${a}: ${l} is ${JSON.stringify(u)}, not six or eight hex digits (rrggbb or rrggbbaa) — the only spellings whose reading was measured to be a colour`)}if(typeof r.blend==="string"&&lP(r.blend)===null)n.push(`${a}: blend is ${JSON.stringify(r.blend)}, which the runtime reads as no mode — one of ${ef.join(", ")}, first letter in either case, is the only spelling measured to be one`);s.push(r)}),s}function pP(e,t,n,s,r){let i={};for(let[o,a]of Object.entries(e)){let l=`${s}.attachments["${o}"]`;if(!n.has(o))r.push(`${l}: "${o}" is not a slot of this document`);if(!Le(a)){r.push(`${l} is not an object`);continue}let u={};for(let[c,h]of Object.entries(a)){let d=`${l}["${c}"]`;if(!Le(h)){r.push(`${d} is not an object`);continue}let f=Object.keys(Gw),m=f.find((g)=>g===h.kind);if(m===void 0){r.push(`${d}: kind is ${JSON.stringify(h.kind)}, none of ${f.join(", ")}`);continue}jt(h,Gw[m],d,r);let p={kind:m};for(let g of["name","path"]){let x=h[g];if(x===void 0)continue;if(typeof x!=="string"||x==="")r.push(`${d}: ${g} is ${JSON.stringify(x)}, not a non-empty string`);else p[g]=x}if(m==="region"&&h.atlas!==void 0){let g=gP(h.atlas,`${d}.atlas`,r);if(g!==void 0)p.atlas=g}let y=iw(h,m,d,t,n,r);if(y!==void 0)p.geometry=y;if(Le(h.sequence)){let g=h.sequence.count;if(typeof g==="number"&&Number.isInteger(g)&&g>=1)p.sequenceCount=g;else if(m!=="region")r.push(`${d}.sequence: count is ${JSON.stringify(g)}, not a whole number of at least 1`);let x=h.sequence.setup??0;if(typeof x==="number"&&Number.isInteger(x)&&x>=0&&(typeof g!=="number"||x{let a=`skins[${o}]`;if(!Le(i)){s.push(`${a} is not an object`);return}let l=typeof i.name==="string"?`${a} "${i.name}"`:a;if(jt(i,oP,l,s),typeof i.name!=="string"||i.name==="")s.push(`${a}: name is ${JSON.stringify(i.name)}, not a non-empty string`);let u=[];if(!Array.isArray(i.bones))s.push(`${l}: bones is not a list`);else i.bones.forEach((d,f)=>{if(typeof d!=="string")s.push(`${l}: bones[${f}] is not a bone name`);else if(!t.has(d))s.push(`${l}: bones[${f}] "${d}" is not a bone of this document`);else u.push(d)});let c=Object.fromEntries(kr.map((d)=>[d,[]]));if(!Le(i.constraints))s.push(`${l}: constraints is not an object`);else for(let[d,f]of Object.entries(i.constraints)){let m=kr.find((p)=>p===d);if(m===void 0)s.push(`${l}.constraints: "${d}" is not a constraint kind; a skin lists ${kr.join(", ")}`);else if(!Array.isArray(f)||f.some((p)=>typeof p!=="string"))s.push(`${l}.constraints.${d} is not a list of constraint names`);else c[m]=f}let h={};if(!Le(i.attachments))s.push(`${l}: attachments is not an object`);else h=pP(i.attachments,t,n,l,s);r.push({name:typeof i.name==="string"?i.name:"",bones:u,constraints:c,attachments:h})}),r}function xP(e,t,n,s,r,i){let o=new Set(n.map((l)=>l.name));if(!Array.isArray(e))return i.push("animations is not a list"),[];let a=[];return e.forEach((l,u)=>{let c=`animations[${u}]`;if(!Le(l)){i.push(`${c} is not an object`);return}if(typeof l.name!=="string"||l.name==="")i.push(`${c}: name is ${JSON.stringify(l.name)}, not a non-empty string`);let h=typeof l.name==="string"?`${c} "${l.name}"`:c,d=[];if(!Array.isArray(l.slots))i.push(`${h}: slots is not a list`);else l.slots.forEach((p,y)=>{if(!Le(p)||typeof p.name!=="string")i.push(`${h}: slots[${y}] names no slot`);else if(!o.has(p.name))i.push(`${h}: slots[${y}] "${p.name}" is not a slot of this document`);else d.push(p.name)});let f=[],m=(p)=>Array.isArray(p)?p.filter(Le):[];for(let p of m(l.attachments))for(let y of m(p.slots))for(let g of m(y.attachments))if(g.deform!==void 0)f.push(`${String(p.name)}/${String(y.name)}/${String(g.name)}`);a.push({name:typeof l.name==="string"?l.name:"",slots:d,timelines:Ow(l,h,t,n,i,{skins:s,events:r}),constraints:{ik:[],transform:[],path:[],physics:0,slider:[]},deforms:f})}),a}function bP(e,t,n,s,r,i){let o=new Set(n.map((c)=>c.name)),a=new Map(s.map((c)=>[c.name,c.bone])),l=new Map(n.map((c)=>[c.name,c.parent]));if(!Array.isArray(e))return i.push("constraints is not a list"),[];let u=[];return e.forEach((c,h)=>{let d=`constraints[${h}]`;if(!Le(c)){i.push(`${d} is not an object`);return}let f=kr.find((y)=>y===c.kind);if(f===void 0)i.push(`${d}: kind is ${JSON.stringify(c.kind)}, none of ${kr.join(", ")}`);if(typeof c.name!=="string"||c.name==="")i.push(`${d}: name is ${JSON.stringify(c.name)}, not a non-empty string`);if(c.declaredIn!=="rig"&&c.declaredIn!=="motion")i.push(`${d}: declaredIn is ${JSON.stringify(c.declaredIn)}, not "rig" or "motion"`);let m=`${d} "${String(c.name)}"`,p;if(typeof c.name==="string"){if(f==="ik"||f==="transform")p=kw(c,f,c.name,m,o,l,i);else if(f==="path")p=aw(c,c.name,m,o,a,i);else if(f==="physics")p=fw(c,c.name,m,o,r,i);else if(f==="slider")p=yw(c,c.name,m,n,t,i)}if(f!==void 0&&typeof c.name==="string")u.push({kind:f,name:c.name,...f==="slider"&&typeof c.animation==="string"?{animation:c.animation}:{},...p!==void 0?{record:p}:{}})}),u}function qw(e,t="the model document"){let n;try{n=JSON.parse(e)}catch(_){throw new ot(`${t}: not JSON — ${_.message}`)}if(!Le(n))throw new ot(`${t}: not a JSON object`);if(typeof n.spec!=="string"||!Xw.includes(n.spec))throw new ot(`${t}: spec is ${JSON.stringify(n.spec)}, not "${ks}" (or "${Zd}", read without its stage, editor order and page flags, or "${Qd}", read without its pages too)`);let s=n.spec,r=s===ks?Vw:s===Zd?jw:tP,i=[];for(let _ of r)if(!(_ in n))i.push(`section "${_}" is missing`);for(let _ of Object.keys(n))if(_!=="spec"&&!r.includes(_))i.push(`section "${_}" is not one a ${s} document has`);let o=s!==Qd&&"pages"in n?cP(n.pages,i,s===ks):null,a=s===ks&&"stage"in n?hP(n.stage,i):null,l=typeof n.referenceScale==="number"&&Number.isFinite(n.referenceScale)?n.referenceScale:NaN;if("referenceScale"in n&&Number.isNaN(l))i.push(`referenceScale is ${JSON.stringify(n.referenceScale)}, not a finite number — wind and gravity act over it`);let u=uP(n.spine,i),c=fP(n.bones,i),h=new Set(c.map((_)=>_.name)),d=mP(n.slots,h,i),f=new Set(d.map((_)=>_.name)),m=yP(n.skins,h,f,i);i.push(..._P(m));let p=YS(n.events,i),y=xP(n.animations,h,d,m,p,i),g=bP(n.constraints,y,c,d,l,i);for(let _ of m)for(let S of kr)for(let k of _.constraints[S])if(!g.some((w)=>w.kind===S&&w.name===k))i.push(`skin "${_.name}".constraints.${S}: "${k}" is not a ${S} constraint of this document — the runtime refuses the file ("Couldn't find … constraint ${k} for skin ${_.name}.")`);if(Array.isArray(n.animations))n.animations.forEach((_,S)=>{if(Le(_)&&y[S]!==void 0)y[S].constraints=Mw(_.constraints,`animations[${S}] "${y[S].name}"`,g,i)});for(let _ of g){let S=_.record;if(S?.kind==="slider")S.physics=y.find((k)=>k.name===S.animation)?.constraints.physicsKeyed??[]}let x=s===ks&&"editorOrder"in n?dP(n.editorOrder,m,y,i):null;if(i.length>0)throw new ot(`${t}: ${i.length} problem(s): ${i.join("; ")}`);let v={spec:s,skin:Pd,referenceScale:l,bones:c,slots:d,skins:m,constraints:g,animations:y,spine:{sha256:u},pages:o,stated:x===null?null:{stage:a,editorOrder:x}};return vP(v),v}function vP(e){for(let t of e.constraints)if(t.record!==void 0)t.record.listedBySkin=FS(e,t.kind,t.name);for(let t of e.constraints){let n=t.record;if(n?.kind!=="path")continue;n.path=null,n.unresolved=null;let s=e.slots.find((a)=>a.name===n.slot),r=Sr(e,s),i=s.setup===null?[]:Oi(e,s.name,s.setup).flatMap((a)=>{let l=e.skins.find((u)=>u.name===a)?.attachments[s.name]?.[s.setup]?.geometry;return l===void 0?[]:[{skin:a,g:JSON.stringify(l)}]});if(i.length>1&&i.some((a)=>a.g!==i[0].g))n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${i.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&"conflict"in r)n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${r.conflict.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&r.record.geometry?.kind==="path"){let a=r.record.geometry;n.path={vertices:a.vertices,closed:a.closed,constantSpeed:a.constantSpeed,lengths:a.lengths}}let o=[];for(let a of _l(e))for(let l of Object.values(a.attachments[n.slot]??{})){let u=l.geometry;if(u?.kind!=="path")continue;for(let c of u.vertices.weighted?u.vertices.bindings.flatMap((h)=>h.map((d)=>d.bone)):[n.slotBone])if(!o.includes(c))o.push(c)}n.slotDeps=o}}function _P(e){let t=[];return e.forEach((n,s)=>{for(let[r,i]of Object.entries(n.attachments))for(let[o,a]of Object.entries(i)){let l=a.geometry;if(l?.kind!=="linkedmesh")continue;let u=Kw(e,l.skin,l.slot,l.source);if(u!==null)t.push(`skins[${s}] "${n.name}".attachments["${r}"]["${o}"]: ${u}`)}}),t}function Kw(e,t,n,s){let r=e.find((o)=>o.name===t);if(r===void 0)return`the linked mesh's skin "${t}" is not a skin of this document`;let i=r.attachments[n]?.[s];if(i===void 0)return`the linked mesh's source "${s}" is not in skin "${t}" slot "${n}"`;if(i.kind!=="mesh")return`the linked mesh's source "${s}" in skin "${t}" slot "${n}" is a ${i.kind}, not a mesh`;return null}function tf(e){if(!Number.isFinite(e))return null;return e===0?0:e}var Uw=new WeakMap;function fn(e){let t=Uw.get(e);if(t!==void 0)return t;let n=SP(e);return Uw.set(e,n),n}function SP(e){let t=new Set(Rd(e).flatMap((r)=>r.bones)),n=new Map(e.bones.map((r)=>[r.name,r.parent])),s=new Set;for(let r of t)for(let i=r;i!==void 0&&!s.has(i);i=n.get(i))s.add(i);return new Set(e.bones.filter((r)=>r.skinRequired!==!0||s.has(r.name)).map((r)=>r.name))}function Id(e){let t=e.record.name??e.placeholder;return{name:t,path:aP.has(e.record.kind)?e.record.path??t:null}}var Ww=new WeakMap;function Sr(e,t,n=t.setup){if(n===null)return null;let s=Ww.get(e);if(s===void 0)s=new Map,Ww.set(e,s);let r=s.get(t.name);if(r===void 0)r=new Map,s.set(t.name,r);if(r.has(n))return r.get(n);let i=wP(e,t.name,n);return r.set(n,i),i}function wP(e,t,n){if(e.skin!==Pd){for(let o of _l(e)){let a=o.attachments[t]?.[n];if(a!==void 0)return{skin:o.name,placeholder:n,record:a}}return null}let s=[];for(let o of e.skins){let a=o.attachments[t]?.[n];if(a!==void 0)s.push({skin:o.name,placeholder:n,record:a})}if(s.length===0)return null;let r=s.map((o)=>({skin:o.skin,...Id(o)}));return r.every((o)=>o.name===r[0].name&&o.path===r[0].path)?s[0]:{conflict:r.map((o)=>({skin:o.skin,shown:o.name,path:o.path}))}}function Kd(e,t,n={}){let s=fn(e);return{order:t,active:s,meshOf:(r,i,o)=>{let a=e.skins.find((l)=>l.name===r)?.attachments[i]?.[o]?.geometry;return a?.kind==="mesh"?{uvs:a.uvs,triangles:a.triangles}:void 0},...n.clip===void 0?{}:{clip:n.clip},...n.through===void 0?{}:{through:n.through}}}function Jd(e){return(t,n,s)=>{let r=e.skins.find((i)=>i.name===t)?.attachments[n]?.[s]?.geometry;return r?.kind==="mesh"?r.vertices:Kw(e.skins,t,n,s)??`the linked mesh's source "${s}" carries no vertices`}}function CP(e,t){if(e===null)throw new ot(`the raw pose computed a non-finite ${t}`);return e}var AP=(e)=>e;function EP(e,t,n){return n.keep?e===null?Number.NaN:e:CP(e,t)}var PP=()=>null;function Jw(e,t){return e.bones.map((n)=>{let s=t.get(n.name);if(s===void 0)throw new ot(`bone "${n.name}" has no world transform`);return{name:n.name,a:s.a,b:s.b,c:s.c,d:s.d,worldX:s.worldX,worldY:s.worldY}})}function RP(e,t,n,s,r,i){let o=Kd(e,s,r),a=Cl(t,n,Jd(e),i.keep?AP:tf,{region:r.region,vertices:r.vertices,deformedVertices:r.deformedVertices},i.loop&&i.live!==!0&&r.through===void 0?{...o,through:PP}:o);if(a.attachments===null)throw new ot(`the raw pose leaves the attachments out: ${a.attachmentsWhy}`);if(a.drawnClipped===null)throw new ot(`the raw pose leaves the clipped triangles out: ${a.drawnClippedWhy}`);return{rows:a.attachments,clips:a.clips,drawnClipped:a.drawnClipped}}function Zw(e,t,n,s,r,i,o={}){let{rows:a}=RP(e,t,n,s,r,i),l=[],u=0;for(let c of t){let h=c.geometry;if(h.kind!=="region"&&h.kind!=="mesh"&&h.kind!=="linkedmesh")continue;let d=a[u++];if(d===void 0||d[0]!==c.slot)throw new ot(`slot "${c.slot}": the attachment rows are not in the shown records' order`);let f=d[3],m=i.keep&&$P(f)?f:f.map((p)=>EP(p,`vertex of slot "${c.slot}"`,i));l.push({slot:c.slot,attachment:d[1],vertices:o.vertices===void 0?m:o.vertices(m,c.slot)})}return l}function $P(e){for(let t of e)if(t===null)return!1;return!0}function OP(e){return{setup:(t,n,s,r,i,o,a)=>({animationTime:0,bones:Jw(t,n),slots:s,drawn:Zw(t,i,n,r,o,a,e)}),step:(t,n,s,r)=>{let i=Zw(t,n.shown,n.world,n.drawOrder,s,r,e);return{animationTime:n.animationTime,bones:Jw(t,n.world),slots:n.slots,drawn:i}}}}var rJ=OP({});var Hi=new WeakMap;function _1(e){if("order"in e)return e;e.generation;let t=Hi.get(e);if(!t)throw Error("LIVE_FRAME_SOURCE: renderer needs a liveFrame() borrowed from a player");return t}var nf=100,UP=0.001;function S1(e,t){let n=document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.width=`${nf}px`,n.style.height=`${nf}px`,n.style.visibility="hidden",n.style.pointerEvents="none",e.appendChild(n);let s=0,r=0;try{let l=n.getBoundingClientRect();s=l.width,r=l.height}finally{n.remove()}let i=Math.max(s,r)/nf;if(!(i>0))return t;let a=(typeof devicePixelRatio==="number"?devicePixelRatio:1)*i;if(t>0&&Math.abs(a-t)e*rc,rotationOnlyFrame:!1};function M1(e,t,n,s,r,i=Jf){let o=(e+t)*i,a=(e+90+n)*i;return[Math.cos(o)*s,Math.cos(a)*r,Math.sin(o)*s,Math.sin(a)*r]}function _f(e,t,n,s,r,i){let o=e.radiansPerDegree;if(e.rotationOnlyFrame&&r===1&&i===1&&n===0&&s===0){let a=Math.cos(t*o),l=Math.sin(t*o);return[a,-l,l,a]}return M1(t,n,s,r,i,o)}function sf(e,t){return[e[0]*t[0]+e[1]*t[2],e[0]*t[1]+e[1]*t[3],e[2]*t[0]+e[3]*t[2],e[2]*t[1]+e[3]*t[3]]}function T1(e,t,n=Jf){let s=t*n,r=Math.cos(s),i=Math.sin(s),o=e[0]*r+e[1]*i,a=e[2]*r+e[3]*i,l=1/Math.sqrt(o*o+a*a);return[o*l,a*l]}function C1(e,t,n,s=k1){let r=n.rotation??0,i=n.shearX??0,o=n.shearY??0,a=n.scaleX??1,l=n.scaleY??1,u=s.radiansPerDegree,c=[t.a,t.b,t.c,t.d];switch(e){case"normal":return sf(c,_f(s,r,i,o,a,l));case"onlyTranslation":return _f(s,r,i,o,a,l);case"noRotationOrReflection":{let h=c[0]*c[0]+c[2]*c[2],d,f;if(h>w1){let y=Math.abs(c[0]*c[3]-c[1]*c[2])/h;d=[c[0],-c[2]*y,c[2],c[0]*y],f=r-s.degreesOf(Math.atan2(c[2],c[0]))}else d=[0,-c[1],0,c[3]],f=r-90+s.degreesOf(Math.atan2(c[3],c[1]));let m=(f+i)*u,p=(f+o+90)*u;return sf(d,[Math.cos(m)*a,Math.cos(p)*l,Math.sin(m)*a,Math.sin(p)*l])}case"noScale":case"noScaleOrReflection":{let[h,d]=T1(c,r,u),f=e==="noScale"&&c[0]*c[3]-c[1]*c[2]<0?-1:1,m=[h,-d*f,d,h*f];return sf(m,M1(0,i,o,a,l,u))}}}function WP(e){let t=e.inheritMode;if(t===void 0)return"normal";let n=t.length===0?t:t[0].toLowerCase()+t.slice(1);if(n==="normal"||n==="onlyTranslation"||n==="noRotationOrReflection"||n==="noScale"||n==="noScaleOrReflection")return n;throw Error(`bone "${e.name}": inheritMode ${JSON.stringify(t)} is no mode (readModel refuses it first)`)}function zi(e,t=null,n=C1,s=k1){let r=new Map;for(let i of e){if(t!==null&&!t.has(i.name)){r.set(i.name,{a:0,b:0,c:0,d:0,worldX:0,worldY:0});continue}let o=i.x??0,a=i.y??0;if(i.parent===void 0){let[f,m,p,y]=_f(s,i.rotation??0,i.shearX??0,i.shearY??0,i.scaleX??1,i.scaleY??1);r.set(i.name,{a:f,b:m,c:p,d:y,worldX:o,worldY:a});continue}let l=r.get(i.parent);if(l===void 0)throw Error(`bone "${i.name}": parent "${i.parent}" is not posed before it`);let[u,c,h,d]=n(WP(i),l,i,s);r.set(i.name,{a:u,b:c,c:h,d,worldX:l.a*o+l.b*a+l.worldX,worldY:l.c*o+l.d*a+l.worldY})}return r}var Ps="all",Qw="default";function A1(e){if(e.skin===null)return[];return e.skin===Ps?e.skins:e.skins.filter((t)=>t.name===e.skin)}function Zf(e){if(e.skin===Ps)return e.skins;let t=e.skin===null?void 0:e.skins.find((s)=>s.name===e.skin),n=e.skin===Qw?void 0:e.skins.find((s)=>s.name===Qw);return[t,n].filter((s)=>s!==void 0)}function Qf(e,t,n){if(e.skin===Ps)return e.skins.filter((r)=>r.attachments[t]?.[n]!==void 0).map((r)=>r.name);let s=Zf(e).find((r)=>r.attachments[t]?.[n]!==void 0);return s===void 0?[]:[s.name]}var hc=(e,t,n)=>n.has(t.bone);function XP(e,t,n){return A1(e).some((s)=>s.constraints[t].includes(n))}var E1=0.99999999,ek=["hold","once","loop","pingpong","onceReverse","loopReverse","pingpongReverse"],VP=0.00001,Ir=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),Es=(e)=>typeof e==="number"&&Number.isFinite(e);function P1(e){return e.weighted?2*e.bindings.reduce((t,n)=>t+n.length,0):e.xy.length}function R1(e,t,n){let s=-1/0;e.forEach((r,i)=>{if(!Ir(r))return;let o=r.time;if(!Es(o)||o<0)n.push(`${t}[${i}]: time is ${JSON.stringify(o)}, not a finite time at or after 0`);else if(o<=s)n.push(`${t}[${i}]: time ${o} is not after the key before it — the writer refuses key times that do not strictly increase`);if(Es(o))s=Math.max(s,o)})}function jP(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];R1(e,t,s);let r=P1(n),i=[];return e.forEach((o,a)=>{let l=`${t}[${a}]`;if(!Ir(o)){s.push(`${l} is not an object`);return}for(let m of Object.keys(o))if(!["time","offset","vertices","curve"].includes(m))s.push(`${l}: field "${m}" is not one a deform key carries; it carries [time, offset, vertices, curve]`);let u=o.vertices,c=[];if(u!==void 0)if(!Array.isArray(u)||u.length===0||!u.every(Es))s.push(`${l}: vertices is not a non-empty list of finite numbers (omit it for the setup geometry)`);else c=u;let h=0;if(o.offset!==void 0)if(u===void 0)s.push(`${l}: offset ${JSON.stringify(o.offset)} with no vertices — a key with no run is the setup geometry, and the writer states no start for it`);else if(typeof o.offset!=="number"||!Number.isInteger(o.offset)||o.offset<0)s.push(`${l}: offset is ${JSON.stringify(o.offset)}, not a whole index at or after 0`);else h=o.offset;if(h+c.length>r)s.push(`${l}: the run starts at ${h} and is ${c.length} long, past the ${r} numbers of the attachment's deform array`);let d="linear";if(o.curve!==void 0)if(a===e.length-1)s.push(`${l}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(o.curve==="stepped")d="stepped";else if(Array.isArray(o.curve)&&o.curve.length===4&&o.curve.every(Es))d=o.curve;else s.push(`${l}: curve is ${JSON.stringify(o.curve)}, not "stepped" nor 4 finite numbers (a deform key's curve is one channel)`);let f=Es(o.time)?o.time:0;i.push({time:Math.fround(f),stated:f,curve:d,offset:h,vertices:c})}),i}function YP(e,t,n,s){if(!Array.isArray(e)||e.length===0)return s.push(`${t}: keys is not a non-empty list`),[];R1(e,t,s);let r=[];return e.forEach((i,o)=>{let a=`${t}[${o}]`;if(!Ir(i)){s.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(!["time","mode","index","delay"].includes(h))s.push(`${a}: field "${h}" is not one a sequence key carries; it carries [time, mode, index, delay]`);let l="hold";if(i.mode!==void 0){let h=ek.find((d)=>d===i.mode);if(h===void 0)s.push(`${a}: mode is ${JSON.stringify(i.mode)}, none of ${ek.join(", ")}`);else l=h}let u=0;if(i.index!==void 0)if(typeof i.index!=="number"||!Number.isInteger(i.index)||i.index<0||i.index>=n)s.push(`${a}: index is ${JSON.stringify(i.index)}, not a frame of the series' ${n} — the writer refuses an index past the last frame`);else u=i.index;let c=r.length===0?0:r[r.length-1].delay;if(i.delay!==void 0)if(!Es(i.delay)||i.delay<0)s.push(`${a}: delay is ${JSON.stringify(i.delay)}, not a finite number of seconds at or above 0`);else c=Math.fround(i.delay);r.push({time:Math.fround(Es(i.time)?i.time:0),mode:l,index:u,delay:c})}),r}function HP(e,t,n,s){let r=[],i=`${t}.attachments`;if(!Array.isArray(e))return s.push(`${i} is not a list`),r;return e.forEach((o,a)=>{let l=`${i}[${a}]`;if(!Ir(o)||typeof o.name!=="string"){s.push(`${l} names no skin`);return}let u=n.find((c)=>c.name===o.name);if(u===void 0)s.push(`${l}: "${o.name}" is not a skin of this document`);if(!Array.isArray(o.slots)){s.push(`${l}: slots is not a list`);return}o.slots.forEach((c,h)=>{let d=`${l}.slots[${h}]`;if(!Ir(c)||typeof c.name!=="string"){s.push(`${d} names no slot`);return}if(!Array.isArray(c.attachments)){s.push(`${d}: attachments is not a list`);return}let f=c.name;c.attachments.forEach((m,p)=>{let y=`${d}.attachments[${p}]`;if(!Ir(m)||typeof m.name!=="string"){s.push(`${y} names no attachment`);return}for(let v of Object.keys(m))if(!["name","deform","sequence"].includes(v))s.push(`${y}: field "${v}" is not one this reader knows; it reads [name, deform, sequence]`);let g=u?.attachments[f]?.[m.name],x=`${y} "${o.name}/${f}/${m.name}"`;if(u!==void 0&&g===void 0)s.push(`${x}: skin "${u.name}" files no attachment "${m.name}" under slot "${f}"`);let b={skin:o.name,slot:f,attachment:m.name,deform:null,sequence:null};if(m.deform!==void 0&&g!==void 0){let v=g.geometry;if(v===void 0||v.kind!=="mesh"&&v.kind!=="clipping"&&v.kind!=="boundingbox"&&v.kind!=="path")s.push(`${x}: a deform keys the vertices of a mesh, bounding box, clipping or path attachment, and this one is a ${g.kind}`);else b.deform=jP(m.deform,`${x}.deform`,v.vertices,s)}if(m.sequence!==void 0&&g!==void 0){let v=g.sequenceCount;if(v===void 0)s.push(`${x}: a sequence timeline steps a series, and this ${g.kind} carries no sequence`);else b.sequence=YP(m.sequence,`${x}.sequence`,v,s)}if(m.deform===void 0&&m.sequence===void 0)s.push(`${x}: carries neither a deform nor a sequence timeline`);r.push(b)})})}),r}function Sf(e,t){let n=Pr(e);return t.vertices.forEach((s,r)=>{let i=t.offset+r;n[i]=e.weighted?Math.fround(s):Math.fround(n[i]+Math.fround(s))}),n}function Pr(e){return e.weighted?Array(P1(e)).fill(0):e.xy.map((t)=>Math.fround(t))}function zP(e,t,n){if(e.curve==="stepped")return 0;if(e.curve==="linear")return(n-e.time)/(t.time-e.time);let s=e.curve,r=mc(e.stated,0,s[0],s[1],s[2],s[3],t.stated,E1),i=[e.time,0,...r,t.time,1],o=2;while(ou+(a[c]-u)*l)}function qP(e,t,n,s,r){let i=Pr(e),o=t??i;if(!r&&s===1)return[...n];if(r&&s===1&&t===null)return[...n];return o.map((a,l)=>r?a+(n[l]-i[l])*s:a+(n[l]-a)*s)}function $1(e,t){if(!e.weighted)return{weighted:!1,xy:[...t]};let n=0;return{weighted:!0,bindings:e.bindings.map((s)=>s.map((r)=>{let i=Math.fround(r.x)+t[n],o=Math.fround(r.y)+t[n+1];return n+=2,{...r,x:i,y:o}}))}}function KP(e,t,n){let s=ct(e,n);if(s<0)return null;let r=e[s],i=r.index;if(r.mode!=="hold"&&r.delay>0)i+=Math.floor((n-r.time)/r.delay+VP);let o=r.mode.endsWith("Reverse"),a=o?r.mode.slice(0,-7):r.mode,l;if(a==="hold"||a==="once")l=Math.min(i,t-1);else if(a==="loop")l=i%t;else{let u=2*(t-1);if(l=u===0?0:i%u,l>=t)l=u-l}return o?t-1-l:l}function tm(e,t){let n=t.record.geometry;if(n?.kind==="linkedmesh")return t.record.timelines===!0?`${n.skin}/${n.slot}/${n.source}`:null;return`${t.skin}/${e}/${t.placeholder}`}var JP=(e)=>`${e.skin}/${e.slot}/${e.attachment}`,tk=new WeakMap;function nk(e,t,n,s){let r=t(e,{...n,setup:s});if(r===null||"conflict"in r||r.record.geometry===void 0)return null;let i=r.record.geometry,o=i.kind==="linkedmesh"?e.skins.find((l)=>l.name===i.skin)?.attachments[i.slot]?.[i.source]:r.record,a=o?.geometry;return Object.freeze({entry:Object.freeze({slot:n.name,bone:n.bone,name:ro(r).name,placeholder:r.placeholder,skin:r.skin,geometry:i}),identity:tm(n.name,r),vertices:a!==void 0&&a.kind!=="region"&&a.kind!=="linkedmesh"?a.vertices:null,count:o?.sequenceCount,fillers:Object.freeze(Qf(e,n.name,r.placeholder).map((l)=>`"${l}"`))})}function sk(e,t,n,s){if(s===null)return null;if(t!==Mn)return nk(e,t,n,s);let r=tk.get(e);if(r===void 0)tk.set(e,r=new Map);let i=r.get(n.name);if(i===void 0)r.set(n.name,i=new Map);if(i.has(s))return i.get(s);let o=nk(e,t,n,s);return i.set(s,o),o}var rk=new WeakMap,ik=new WeakMap;function ZP(e,t){let n=rk.get(e);if(n===void 0){let s=new Map;for(let r of e){let i=JP(r),o=s.get(i);if(o===void 0)s.set(i,[r]);else o.push(r)}rk.set(e,n=s)}return n.get(t)}function QP(e,t){let n=ik.get(e);if(n===void 0){let s=new Map;for(let r of e)for(let i of r.timelines){if(i.kind!=="attachment"||i.keys===void 0)continue;let o=s.get(r.name);if(o===void 0)s.set(r.name,[i.keys]);else o.push(i.keys)}ik.set(e,n=s)}return n.get(t)}function ok(e,t,n,s,r,i,o,a){if(e===null||e.identity===null)return t;let l=ZP(n,e.identity);if(l===void 0)return t;if(t??={deform:null,frame:null,seen:[]},!t.seen.includes(e.identity))t.seen.push(e.identity);for(let u of l){if(u.deform!==null&&e.vertices!==null){let c=i(e.vertices,u.deform,s);if(c!==null)t.deform=r===null?c:o(e.vertices,t.deform,c,r.alpha,r.additive)}if(u.sequence!==null&&e.count!==void 0){let c=a(u.sequence,e.count,s);if(c!==null)t.frame=c}}return t}function O1(e,t,n,s,r,i={},o){let a=i.deform??em,l=i.deformBlend??qP,u=i.sequence??KP,c=[],h=[],d=Dt(e),f=i.slotTimelines??hc;for(let m of e.slots){let p=f(e,m,d),y=n.get(m.name)??null,g=p?o?.get(m.name):void 0,x=g===void 0||g.deform===null&&g.seen.length===0?null:{deform:g.deform,frame:null,seen:[...g.seen]},b=sk(e,t,m,y);if(s!==null&&p)x=ok(b,x,s.timelines.attachments,s.t,null,a,l,u);if(p)for(let _ of r){let S=QP(_.timelines.slots,m.name);if(S!==void 0)for(let k of S){let w=ct(k,_.at);if(w<0)continue;let T=k[w].name??null;if(T!==y){if(x!==null)x.deform=null,x.frame=null;y=T,b=sk(e,t,m,y)}}x=ok(b,x,_.timelines.attachments,_.at,_,a,l,u)}if(b===null)continue;let v=x===null||x.deform===null&&x.frame===null?b.entry:{...b.entry};if(c.push(v),x!==null&&x.seen.length>0&&b.fillers.length>1){h.push(`slot "${m.name}" shows placeholder "${b.entry.placeholder}", which skins ${b.fillers.join(", ")} fill, and ${x.seen.map((_)=>`"${_}"`).join(", ")} key(s) it — which record --skin all shows, and so whether the timeline moves it, is the Spine file's skin order, not the model's`);continue}if(x!==null){if(x.deform!==null)v.deform=x.deform;if(x.frame!==null)v.frame=x.frame}}return{shown:c,why:h}}var ak=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function eR(e,t,n,s){let r=`${t}.drawOrder`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=new Map(n.map((l,u)=>[l.name,u])),o=[],a=-1/0;return e.forEach((l,u)=>{let c=`${r}[${u}]`;if(!ak(l)){s.push(`${c} is not an object`);return}for(let f of Object.keys(l))if(f!=="time"&&f!=="offsets")s.push(`${c}: field "${f}" is not one a draw-order key carries; it carries [time, offsets]`);let h=l.time;if(typeof h!=="number"||!Number.isFinite(h)||h<0)s.push(`${c}: time is ${JSON.stringify(h)}, not a finite time at or after 0`);else if(h<=a)s.push(`${c}: time ${h} is not after the key before it — the writer refuses key times that do not strictly increase`);if(typeof h==="number"&&Number.isFinite(h))a=Math.max(a,h);let d=[];if(l.offsets!==void 0)if(!Array.isArray(l.offsets))s.push(`${c}: offsets is not a list`);else{let f=new Map;l.offsets.forEach((m,p)=>{let y=`${c}.offsets[${p}]`;if(!ak(m)||typeof m.slot!=="string"){s.push(`${y} names no slot`);return}let g=i.get(m.slot);if(g===void 0){s.push(`${y}: "${m.slot}" is not a slot of this document`);return}if(typeof m.offset!=="number"||!Number.isInteger(m.offset)){s.push(`${y}: slot "${m.slot}" offset is ${JSON.stringify(m.offset)}, not a whole number`);return}if(d.some((b)=>b.slot===g))s.push(`${y}: slot "${m.slot}" is moved twice in one key`);let x=g+m.offset;if(x<0||x>=n.length)s.push(`${y}: slot "${m.slot}" is at ${g} and offset ${m.offset} lands at ${x}, outside the ${n.length} slots`);else if(f.has(x))s.push(`${y}: slot "${m.slot}" lands at ${x}, where slot "${f.get(x)}" lands too — two moves on one place leave a slot out of the runtime's order`);else f.set(x,m.slot);d.push({slot:g,offset:m.offset})})}o.push({time:Math.fround(typeof h==="number"&&Number.isFinite(h)?h:0),moves:d})}),o}function tR(e,t){let n=Array(e).fill(-1);for(let o of t)n[o.slot+o.offset]=o.slot;let s=new Set(t.map((o)=>o.slot)),r=Array.from({length:e},(o,a)=>a).filter((o)=>!s.has(o)),i=0;for(let o=0;otypeof e==="object"&&e!==null&&!Array.isArray(e),lk=["name","int","float","string","audio","volume","balance"],ck=["time","name","int","float","string","volume","balance"];function F1(e,t,n){let s={};if(e.int!==void 0)if(typeof e.int!=="number"||!Number.isInteger(e.int))n.push(`${t}: int is ${JSON.stringify(e.int)}, not a whole number`);else s.int=e.int;if(e.float!==void 0)if(typeof e.float!=="number"||!Number.isFinite(e.float))n.push(`${t}: float is ${JSON.stringify(e.float)}, not a finite number`);else s.float=e.float;if(e.string!==void 0)if(typeof e.string!=="string")n.push(`${t}: string is ${JSON.stringify(e.string)}, not a string`);else s.string=e.string;for(let r of["volume","balance"])if(e[r]!==void 0)if(typeof e[r]!=="number"||!Number.isFinite(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])}, not a finite number`);else s[r]=e[r];return s}function nR(e,t){let n=new Map;if(!Array.isArray(e))return t.push("events is not a list"),n;return e.forEach((s,r)=>{let i=`events[${r}]`;if(!B1(s)||typeof s.name!=="string"||s.name===""){t.push(`${i} names no event`);return}for(let a of Object.keys(s))if(!lk.includes(a))t.push(`${i} "${s.name}": field "${a}" is not one this reader knows; it reads [${lk.join(", ")}]`);if(s.audio!==void 0&&typeof s.audio!=="string")t.push(`${i} "${s.name}": audio is ${JSON.stringify(s.audio)}, not a string`);if(n.has(s.name))t.push(`${i}: event "${s.name}" is declared twice`);let o=F1(s,`${i} "${s.name}"`,t);n.set(s.name,{audio:typeof s.audio==="string"?s.audio:"",volume:o.volume??0,balance:o.balance??0,name:s.name,int:o.int??0,float:o.float??0,string:o.string??""})}),n}function sR(e,t,n,s){let r=`${t}.events`;if(!Array.isArray(e))return s.push(`${r} is not a list`),[];let i=[],o=-1/0;return e.forEach((a,l)=>{let u=`${r}[${l}]`;if(!B1(a)){s.push(`${u} is not an object`);return}for(let f of Object.keys(a))if(!ck.includes(f))s.push(`${u}: field "${f}" is not one an event key carries; it carries [${ck.join(", ")}]`);let c=a.time;if(typeof c!=="number"||!Number.isFinite(c)||c<0)s.push(`${u}: time is ${JSON.stringify(c)}, not a finite time at or after 0`);else if(c[o.name,s(o.time),o.int,s(o.float),o.string];if(r)return[...e.filter((o)=>o.time>t),...e.filter((o)=>o.time<=n)].map(i);return e.filter((o)=>o.time>t&&o.time<=n).map(i)}function D1(e){let t=0,n=e.length/2;for(let s=0;s0?n.reverse():n;return t.flippedWinding===!0?s.reverse():s}function rR(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(r*(e[1]-n[1])-i*(e[0]-n[0]))/(a*r-o*i);return[n[0]+l*o,n[1]+l*a]}function Mf(e,t,n,s){let r=t[0]-e[0],i=t[1]-e[1],o=s[0]-n[0],a=s[1]-n[1],l=(o*(e[1]-n[1])-a*(e[0]-n[0]))/(a*r-o*i);return[e[0]+l*r,e[1]+l*i]}function N1(e,t,n){let s=n.fromClipEdge===!0?rR:Mf,r=[...e],i=!1;for(let o=0;o0;o++){let a=t[o],l=t[(o+1)%t.length],u=(h)=>(l[0]-a[0])*(h[1]-a[1])-(l[1]-a[1])*(h[0]-a[0])<0,c=[];for(let h=0;h[t[2*P],t[2*P+1]]),p=f.map((P)=>[o(s[2*P]),o(s[2*P+1])]),{points:y,cut:g}=N1(m,i,r);for(let P=1;P+1r.uvByDivision===!0?P/T:P*A,E=a.length/2;if(!g&&r.insideRotated!==!0){m.forEach(([P,O],B)=>{a.push(o(P),o(O)),l.push(p[B][0],p[B][1])});for(let P=1;P+1U1(r,i,o,a,n)){let r=[],i=[],o=[],a=null;for(let c of e){if(c.kind==="clip"){if(a!==null&&a.end===c.slot)a=null;if(c.active&&a===null){let h=c.inverse?"it is inverse":wf(c.polygon);if(h!==null)i.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${h}`);let d={polygon:c.polygon,inverse:c.inverse,convex:c.convex},f=Tf(d);if(f.kind==="refused")o.push(`slot "${c.slot}" starts clip "${c.attachment}", and ${f.why}`);a={end:c.end,shape:d}}continue}if(c.kind==="draw"&&a!==null){let h=s(a.shape,c.vertices,c.triangles,c.uvs);if(h!==null)r.push([c.slot,c.attachment,h.clipped?1:0,h.vertices.map(t),h.uvs.map(t),h.triangles])}if(a!==null&&a.end===c.slot)a=null}let l=o.length===0?null:`${o.join("; ")} — the runtime's coverage of a polygon that is not simple is its own triangulation's, measured not to be the polygon's area (src/core/clipping.ts)`,u=l===null?r:null;if(i.length>0)return{rows:null,why:`${i.join("; ")} — the runtime decomposes such a polygon into convex pieces of its own choosing, or clips the outside of an inverse one, and neither was reproduced from the dump (src/core/clipping.ts)`,drawn:u,drawnWhy:l};return{rows:r,why:null,drawn:u,drawnWhy:l}}function oR(e){let t=[];for(let n=0;n+10&&i<0||r<0&&i>0)&&(o>0&&a<0||o<0&&a>0))return!0;let l=(u,c,h)=>Math.min(u[0],c[0])<=h[0]&&h[0]<=Math.max(u[0],c[0])&&Math.min(u[1],c[1])<=h[1]&&h[1]<=Math.max(u[1],c[1]);return r===0&&l(n,s,e)||i===0&&l(n,s,t)||o===0&&l(e,t,n)||a===0&&l(e,t,s)}function lR(e){let t=e.length;for(let n=0;n0)return`edges ${n} and ${(n+1)%t} fold back over each other at vertex ${(n+1)%t}`;for(let o=n+2;o3;){n=!1;for(let s=0;ss[0]-r[0]||s[1]-r[1]),n=(s)=>{let r=[];for(let i of s){while(r.length>=2&&Ft(r[r.length-2],r[r.length-1],i)<=0)r.pop();r.push(i)}return r.pop(),r};return[...n(t),...n([...t].reverse())]}function uR(e){let t=e.flat();return D1(t)<0?[...e].reverse():[...e]}function hR(e){let t=e.length,n=e.map((a,l)=>l),s=[],r=(a,l,u,c)=>Ft(l,u,a)>=0&&Ft(u,c,a)>=0&&Ft(c,l,a)>=0;while(n.length>3){let a=!1;for(let l=0;ld!==u&&d!==c&&d!==h&&r(e[d],e[u],e[c],e[h])))continue;s.push([u,c,h]),n.splice(l,1),a=!0;break}if(!a)throw Error(`convexPieces: no ear left among vertices [${n.join(", ")}] of a polygon the caller held simple — a defect in src/core/clipping.ts`)}s.push([...n]);let i=s.map((a)=>[...a]),o=(a)=>a.every((l,u)=>Ft(e[a[(u+a.length-1)%a.length]],e[l],e[a[(u+1)%a.length]])>0);for(let a=!0;a;){a=!1;e:for(let l=0;la.map((l)=>e[l]))}function Tf(e){let t=oR(e.polygon);if(t.length<3)return{kind:"refused",why:`it has ${t.length} vertex(es)`};let n=[];for(let o=0;o0){let o=t.filter((a,l)=>{let u=t[(l+1)%t.length];return a[0]!==u[0]||a[1]!==u[1]});if(!e.inverse&&o.length===t.length-n.length&&o.length>=3&&wf(o.flat())===null)return{kind:"convex",polygon:e.polygon};return{kind:"refused",why:`vertices ${n.join(", ")} are the same point`}}let s=lR(t);if(s!==null)return{kind:"refused",why:s};let r=cR(t);if(Ft(r[0],r[1],r[2])===0&&r.length===3)return{kind:"refused",why:"every vertex lies on one line"};if(e.inverse)return{kind:"inverse",hull:uk(r)};if(wf(e.polygon)===null)return{kind:"convex",polygon:e.polygon};if(e.convex)return{kind:"convex",polygon:uk(r).flat()};let i=hR(uR(r));return i.length===1?{kind:"convex",polygon:i[0].flat()}:{kind:"pieces",pieces:i}}function hk(e,t,n){let s=(o)=>(n[0]-t[0])*(o[1]-t[1])-(n[1]-t[1])*(o[0]-t[0])<0,r=[],i=!1;for(let o=0;okf(p.flat(),{})):null,m=o.kind==="inverse"?kf(o.hull.flat(),{}):[];for(let p=0;p+2[t[2*E],t[2*E+1]]),x=y.map((E)=>[a(s[2*E]),a(s[2*E+1])]),b=[];if(f!==null)for(let E of f)b.push(N1(g,E,{}));else{let E=[...g],P=!1;for(let O=0;O0;O++){let B=m[O],I=m[(O+1)%m.length],R=hk(E,I,B);b.push({points:R.cut||P?R.points:[...g],cut:R.cut||P});let N=hk(E,B,I);P||=N.cut,E=N.points}d=!0}let[v,_,S]=g,k=_[1]-S[1],w=S[0]-_[0],T=v[0]-S[0],A=S[1]-v[1],C=1/(k*T+w*(v[1]-S[1]));for(let[E,{points:P,cut:O}]of b.entries()){if(d||=O,E===i.dropRegion)continue;if(P.length<3)continue;let B=l.length/2;if(!O)g.forEach(([I,R],N)=>{l.push(a(I),a(R)),u.push(x[N][0],x[N][1])});else for(let[I,R]of P){let N=(k*(I-S[0])+w*(R-S[1]))*C,L=(A*(I-S[0])+T*(R-S[1]))*C,U=1-N-L;l.push(a(I),a(R)),u.push(a(x[0][0]*N+x[1][0]*L+x[2][0]*U),a(x[0][1]*N+x[1][1]*L+x[2][1]*U))}for(let I=1;I+1e;function mR(e,t){let{width:n,height:s}=e,r=e.scaleX??1,i=e.scaleY??1,o=e.atlas,a=n/o.originalWidth*r,l=s/o.originalHeight*i,u=-n/2*r+o.offsetX*a,c=-s/2*i+o.offsetY*l,h=u+o.width*a,d=c+o.height*l,f=(e.rotation??0)*dR,m=Math.cos(f),p=Math.sin(f),y=e.x??0,g=e.y??0,x=[];for(let[b,v]of[[u,c],[u,d],[h,d],[h,c]]){let _=b*m+y-v*p,S=v*m+g+b*p;x.push(t.a*_+t.b*S+t.worldX,t.c*_+t.d*S+t.worldY)}return x}var Cf=new WeakMap;function X1(e,t){let n=[],s=new Map;for(let i of e.bindings)for(let o of i)if(!s.has(o.bone))s.set(o.bone,n.length),n.push(o.bone);n.length;let r=e.bindings.map((i)=>i.map((o)=>({bone:s.get(o.bone),x:o.x,y:o.y,fx:Math.fround(o.x),fy:Math.fround(o.y),weight:Math.fround(o.weight)})));return{bones:n,bindings:r}}function V1(e){let t=Cf.get(e);if(t===void 0)t=X1(e),Cf.set(e,t);return t}function j1(e,t){let n=Array(e.length);for(let s=0;stypeof e==="object"&&e!==null&&!Array.isArray(e),Rs=(e)=>typeof e==="number"&&Number.isFinite(e),rf=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function xR(e,t,n){if(!qi(e)){n.push(`${t} is ${JSON.stringify(e)}, not an atlas rectangle`);return}let s=n.length;for(let r of Object.keys(e))if(!rf.includes(r))n.push(`${t}: field "${r}" is not one this reader knows; it reads [${rf.join(", ")}]`);for(let r of rf)if(!Rs(e[r]))n.push(`${t}: ${r} is ${JSON.stringify(e[r])??"absent"}, not a finite number`);return n.length===s?e:void 0}function bR(e,t,n,s){if(!qi(e)||typeof e.weighted!=="boolean"){s.push(`${t} is not { weighted: false, xy } or { weighted: true, bindings }`);return}let r=s.length;if(!e.weighted){let a=e.xy;if(!Array.isArray(a)||a.length%2!==0||!a.every(Rs))s.push(`${t}.xy is not an even-length list of finite numbers`);return s.length===r?{weighted:!1,xy:a}:void 0}let i=e.bindings;if(!Array.isArray(i)){s.push(`${t}.bindings is not a list`);return}if(i.forEach((a,l)=>{if(!Array.isArray(a)||a.length===0){s.push(`${t}.bindings[${l}] is not a non-empty list of bindings`);return}a.forEach((u,c)=>{let h=`${t}.bindings[${l}][${c}]`;if(!qi(u)){s.push(`${h} is not an object`);return}if(typeof u.bone!=="string"||!n.has(u.bone))s.push(`${h}: bone ${JSON.stringify(u.bone)} is not a bone of this document`);for(let d of["x","y","weight"])if(!Rs(u[d]))s.push(`${h}: ${d} is ${JSON.stringify(u[d])??"absent"}, not a finite number`)})}),s.length!==r)return;let o={weighted:!0,bindings:i};return Cf.set(o,X1(o)),o}function vR(e,t,n,s,r,i){let o=i.length;switch(t){case"region":{for(let d of["x","y","rotation","scaleX","scaleY"])if(e[d]!==void 0&&!Rs(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])}, not a finite number`);for(let d of["width","height"])if(!Rs(e[d]))i.push(`${n}: ${d} is ${JSON.stringify(e[d])??"absent"}, not a finite number`);let a=e.atlas!==void 0,l=e.sequence!==void 0,u,c;if(a===l)i.push(`${n}: the region carries ${a?"both an atlas rectangle and a sequence":"neither an atlas rectangle nor a sequence"}; the writer states exactly one of the two, and a sequence holds a rectangle per frame (issue #935)`);else if(a)u=e.atlas===null?null:qi(e.atlas)?e.atlas:void 0;else{let d=e.sequence;if(!qi(d))i.push(`${n}.sequence is not an object`);else{let f=d.count,m=d.setup??0;if(typeof f!=="number"||!Number.isInteger(f)||f<1)i.push(`${n}.sequence: count is ${JSON.stringify(f)}, not a whole number of at least 1`);else if(typeof m!=="number"||!Number.isInteger(m)||m<0||m>=f)i.push(`${n}.sequence: setup is ${JSON.stringify(d.setup)}, not a frame of the ${f}`);if(!Array.isArray(d.atlas)||d.atlas.length!==f)i.push(`${n}.sequence: atlas is not a list of ${JSON.stringify(f)} rectangle(s), one per frame`);else{let p=d.atlas.map((y,g)=>xR(y,`${n}.sequence.atlas[${g}]`,i));if(typeof m==="number"&&Number.isInteger(m)&&m>=0&&my!==void 0))c=p}}}if(i.length!==o||u===void 0)return;let h=(d)=>e[d]===void 0?{}:{[d]:e[d]};return{kind:"region",region:{...h("x"),...h("y"),...h("rotation"),...h("scaleX"),...h("scaleY"),width:e.width,height:e.height,atlas:u,...c===void 0?{}:{frames:c}}}}case"linkedmesh":{for(let a of["skin","slot","source"])if(typeof e[a]!=="string"||e[a]==="")i.push(`${n}: ${a} is ${JSON.stringify(e[a])??"absent"}, not a non-empty string`);if(typeof e.slot==="string"&&!r.has(e.slot))i.push(`${n}: slot "${e.slot}" is not a slot of this document`);if(i.length!==o)return;return{kind:"linkedmesh",skin:e.skin,slot:e.slot,source:e.source}}case"mesh":case"clipping":case"boundingbox":case"path":{let a=bR(e.vertices,`${n}.vertices`,s,i);if(t==="clipping"&&e.end!==void 0&&(typeof e.end!=="string"||!r.has(e.end)))i.push(`${n}: end is ${JSON.stringify(e.end)}, not a slot of this document`);if(t==="clipping"){for(let u of["inverse","convex"])if(e[u]!==void 0&&typeof e[u]!=="boolean")i.push(`${n}: ${u} is ${JSON.stringify(e[u])}, not a boolean`)}let l=t==="mesh"&&a!==void 0?_R(e,a,n,i):void 0;if(a===void 0||i.length!==o)return;if(t==="mesh")return l===void 0?void 0:{kind:t,vertices:a,...l};if(t==="clipping")return{kind:t,end:typeof e.end==="string"?e.end:null,vertices:a,inverse:e.inverse===!0,convex:e.convex===!0};if(t==="boundingbox")return{kind:t,vertices:a};return SR(e,a,n,i)}}}function _R(e,t,n,s){let r=s.length,i=t.weighted?t.bindings.length:t.xy.length/2,{uvs:o,triangles:a}=e;if(!Array.isArray(o)||!o.every(Rs)||o.length!==2*i)s.push(`${n}.uvs is not ${2*i} finite numbers, one pair per vertex`);if(!Array.isArray(a)||a.length%3!==0||!a.every((u)=>Number.isInteger(u)&&u>=0&&u=0&&l<=i))s.push(`${n}.hull is ${JSON.stringify(l)}, not a whole number of vertices from 0 to ${i}`);return s.length===r?{uvs:o,triangles:a,...l===void 0?{}:{hull:l}}:void 0}function SR(e,t,n,s){let r=s.length;for(let a of["closed","constantSpeed"])if(e[a]!==void 0&&typeof e[a]!=="boolean")s.push(`${n}: ${a} is ${JSON.stringify(e[a])}, not a boolean`);let i=t.weighted?t.bindings.length:t.xy.length/2;if(e.vertexCount!==i)s.push(`${n}: vertexCount is ${JSON.stringify(e.vertexCount)??"absent"}, and the vertices hold ${i} point(s)`);else if(i%3!==0||i<(e.closed===!0?3:6))s.push(`${n}: vertexCount is ${i}, not a multiple of 3 of at least ${e.closed===!0?3:6} — the curve walk reads knots and handles in threes`);let o=e.lengths;if(!Array.isArray(o)||!o.every(Rs))s.push(`${n}: lengths is not a list of finite numbers`);else if(o.length!==i/3)s.push(`${n}: lengths has ${o.length} entry(ies) where the vertices make ${i/3}`);if(s.length!==r)return;return{kind:"path",vertices:t,closed:e.closed===!0,constantSpeed:e.constantSpeed!==!1,lengths:o}}function Rl(e,t){for(let n=0;nb.geometry.kind==="clipping"),f=new Map;for(let b of e){let v=t.get(b.bone);if(v===void 0)throw Error(`slot "${b.slot}": bone "${b.bone}" has no world transform`);let{geometry:_,deform:S}=b,k=(w)=>S===void 0?a(w,v,t):r.vertices===void 0||r.deformedVertices!==void 0?l(w,S,v,t):a($1(w,S),v,t,W1);if(_.kind==="region"){let w=b.frame===void 0?_.region.atlas:_.region.frames?.[b.frame]??_.region.atlas;if(w===null){h.push(`slot "${b.slot}" shows region "${b.name}" (skin "${b.skin}", placeholder "${b.placeholder}")`);continue}let T=o(w===_.region.atlas?_.region:{..._.region,atlas:w},v);if(u.push([b.slot,b.name,"region",Rl(T,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:sm,uvs:L1})}else if(_.kind==="mesh"){let w=k(_.vertices);if(u.push([b.slot,b.name,"mesh",Rl(w,s)]),d)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:w,triangles:_.triangles,uvs:_.uvs})}else if(_.kind==="linkedmesh"){let w=n(_.skin,_.slot,_.source);if(typeof w==="string")throw Error(`slot "${b.slot}": ${w} (readModel refuses it first)`);let T=k(w);u.push([b.slot,b.name,"mesh",Rl(T,s)]);let A=i?.meshOf(_.skin,_.slot,_.source);if(i!==void 0&&A===void 0)throw Error(`slot "${b.slot}": the linked mesh's source "${_.source}" carries no triangles (readModel refuses it first)`);if(d&&A!==void 0)f.set(b.slot,{slot:b.slot,kind:"draw",attachment:b.name,vertices:T,triangles:A.triangles,uvs:A.uvs})}else if(_.kind==="clipping"){let w=k(_.vertices);c.push([b.slot,b.name,_.end,Rl(w,s)]),f.set(b.slot,{slot:b.slot,kind:"clip",attachment:b.name,active:i?.active.has(b.bone)??!1,end:_.end,polygon:w,inverse:_.inverse,convex:_.convex})}}let m=h.length===0?null:`${h.join("; ")} — the model states the build had no atlas rectangle for it (atlas: null), and its corners read the trim and original size; a trim of 0 is not assumed`,p=null,y=i===void 0?"the draw order was not given":m,g=null,x=y;if(i!==void 0&&m===null&&!d)p=[],y=null,g=[],x=null;else if(i!==void 0&&m===null){let b=i.order.map((_)=>f.get(_)??{slot:_,kind:"none"}),v=iR(b,s,i.clip,i.through);p=v.rows,y=v.why,g=v.drawn,x=v.drawnWhy}return{attachments:m===null?u:null,attachmentsWhy:m,clips:c,clipped:p,clippedWhy:y,drawnClipped:g,drawnClippedWhy:x}}var fk=Te/180;function wR(e,t){let n=[],s=0,r=e[0],i=e[1];for(let o=0,a=2;otypeof e==="object"&&e!==null&&!Array.isArray(e);function af(e,t,n,s,r,i){let o=e[t];if(o===void 0)return s;let a=typeof o==="string"&&o.length>0?o[0].toLowerCase()+o.slice(1):"",l=n.find((u)=>u===a);if(l===void 0)return i.push(`${r}: ${t} is ${JSON.stringify(o)}, none of ${n.join(", ")} (first letter in either case)`),s;return l}function qn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function CR(e,t,n,s,r,i){let o=i.length;for(let d of Object.keys(e)){if(d==="kind"||d==="name"||d==="declaredIn")continue;if(!mk.includes(d))i.push(`${n}: field "${d}" is not one this reader knows; it reads [${mk.join(", ")}]`)}let a=[];if(!Array.isArray(e.bones)||e.bones.length===0)i.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`);else e.bones.forEach((d,f)=>typeof d==="string"&&s.has(d)?a.push(d):i.push(`${n}: bones[${f}] ${JSON.stringify(d)} is not a bone of this document`));let l=typeof e.slot==="string"?e.slot:"",u=r.get(l);if(u===void 0)i.push(`${n}: slot is ${JSON.stringify(e.slot)}, not a slot of this document`);if(e.skin!==void 0&&typeof e.skin!=="boolean")i.push(`${n}: skin is ${JSON.stringify(e.skin)}, not a boolean`);let c=qn(e,"mixX",1,n,i),h={kind:"path",name:t,bones:a,slot:l,slotBone:u??"",positionMode:af(e,"positionMode",kR,"percent",n,i),spacingMode:af(e,"spacingMode",MR,"length",n,i),rotateMode:af(e,"rotateMode",TR,"tangent",n,i),offsetRotation:qn(e,"rotation",0,n,i),position:qn(e,"position",0,n,i),spacing:qn(e,"spacing",0,n,i),mixRotate:qn(e,"mixRotate",1,n,i),mixX:c,mixY:qn(e,"mixY",c,n,i),skin:e.skin===!0,listedBySkin:!1,path:null,unresolved:null,slotDeps:[]};return i.length===o?h:void 0}var lf={position:["value"],spacing:["value"],mix:["mixRotate","mixX","mixY"]};function AR(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function ER(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.path[${o}]`;if(!$l(i)||typeof i.name!=="string"){s.push(`${a} names no constraint`);return}if(!n.has(i.name))s.push(`${a}: "${i.name}" is not a path constraint of this document`);let l={name:i.name};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!$l(u)||typeof u.name!=="string"||!(u.name in lf)){s.push(`${h}: ${$l(u)?JSON.stringify(u.name):"it"} is not a path timeline; they are ${Object.keys(lf).join(", ")}`);return}let d=u.name;if(l[d]!==void 0)s.push(`${h}: "${d}" is keyed twice on path constraint "${i.name}"`);let f=lf[d],m=u.keys;if(!Array.isArray(m)||m.length===0){s.push(`${h}: keys is not a non-empty list`);return}let p=-1/0,y=[];m.forEach((g,x)=>{let b=`${h}.keys[${x}]`;if(!$l(g)){s.push(`${b} is not an object`);return}for(let S of Object.keys(g))if(S!=="time"&&S!=="curve"&&!f.includes(S))s.push(`${b}: field "${S}" is not one this reader knows; it reads [time, ${f.join(", ")}, curve]`);let v=g.time;if(typeof v!=="number"||!Number.isFinite(v)||v<0){s.push(`${b}: time is ${JSON.stringify(v)}, not a finite time at or after 0`);return}if(v<=p)s.push(`${b}: time ${v} is not after the key before it — the writer refuses key times that do not strictly increase`);p=Math.max(p,v);let _=f.map((S)=>{if(S==="mixY"&&g.mixY===void 0)return qn(g,"mixX",1,b,s);return qn(g,S,d==="mix"?1:0,b,s)});y.push({time:Math.fround(v),values:_.map(Math.fround),stated:{time:v,values:_},curve:AR(g,f.length,x===m.length-1,b,s)})}),l[d]=y}),r.push(l)}),r}function PR(e,t,n){return Y1(n.vertices,e.world.get(t.slotBone),e.world,n.exact===!0?W1:Math.fround)}function pk(e,t,n,s,r,i,o){let a=Math.atan2(r-n,s-t);i[o]=t+e*Math.cos(a),i[o+1]=n+e*Math.sin(a),i[o+2]=a}function gk(e,t,n,s,r,i,o){let a=Math.atan2(r-n,s-t);i[o]=s+e*Math.cos(a),i[o+1]=r+e*Math.sin(a),i[o+2]=a}function yk(e,t,n,s,r,i,o,a,l,u,c,h){if(Number.isNaN(e)){u[c]=t,u[c+1]=n,u[c+2]=Math.atan2(r-n,s-t);return}let d=e*e,f=d*e,m=1-e,p=m*m,y=p*m,g=m*e,x=g*3,b=m*x,v=x*e,_=t*y+s*b+i*v+a*f,S=n*y+r*b+o*v+l*f;if(u[c]=_,u[c+1]=S,h)if(e<0.001)u[c+2]=Math.atan2(r-n,s-t);else u[c+2]=Math.atan2(S-(n*p+r*g*2+o*d),_-(t*p+s*g*2+i*d))}function RR(e,t,n,s,r){let i=s.length,o=PR(e,t,n),a=o.length/2,l=(E)=>[o[2*E],o[2*E+1]],u=Array(i*3+2).fill(0),c=n.closed,h=t.position;if(!n.constantSpeed){let E=n.lengths,P=a/3-(c?1:2),O=E[P];if(t.positionMode==="percent")h*=O;let B=t.spacingMode==="percent"?O:t.spacingMode==="proportional"?O/i:1,I=0;for(let R=0,N=0;RO){let[he,re]=l(a-3),[Ae,ae]=l(a-2);gk(U-O,he,re,Ae,ae,u,N);continue}for(;;I++){let he=E[I];if(U>he)continue;if(I===0)U/=he;else{let re=E[I-1];U=(U-re)/(he-re)}break}let J=3*I+1,ee=(he)=>l((J+he)%a),[W,X]=ee(0),[F,G]=ee(1),[H,Z]=ee(2),[V,Q]=ee(3);yk(U,W,X,F,G,H,Z,V,Q,u,N,r||R>0&&L===0)}return u}let d=[];if(c){for(let E=1;E0?m[m.length-1]:0;if(t.positionMode==="percent")h*=p;let y=t.spacingMode==="percent"?p:t.spacingMode==="proportional"?p/i:1,g=[,,,,,,,,,,].fill(0),x=0,b=-1,v=0,_=0,S=0,k=0,w=0,T=0,A=0,C=0;for(let E=0,P=0,O=0,B=0;Ep){let N=d.length;gk(R-p,d[N-4],d[N-3],d[N-2],d[N-1],u,P);continue}for(;;O++){let N=m[O];if(R>N)continue;if(O===0)R/=N;else{let L=m[O-1];R=(R-L)/(N-L)}break}if(O!==b){b=O;let N=O*6;v=d[N],_=d[N+1],S=d[N+2],k=d[N+3],w=d[N+4],T=d[N+5],A=d[N+6],C=d[N+7];let L=(v-S*2+w)*0.03,U=(_-k*2+T)*0.03,J=((S-w)*3-v+A)*0.006,ee=((k-T)*3-_+C)*0.006,W=L*2+J,X=U*2+ee,F=(S-v)*0.3+L+J*0.16666667,G=(k-_)*0.3+U+ee*0.16666667;x=Math.sqrt(F*F+G*G),g[0]=x;for(let H=1;H<8;H++)F+=W,G+=X,W+=J,X+=ee,x+=Math.sqrt(F*F+G*G),g[H]=x;F+=W,G+=X,x+=Math.sqrt(F*F+G*G),g[8]=x,F+=W+J,G+=X+ee,x+=Math.sqrt(F*F+G*G),g[9]=x,B=0}R*=x;for(;;B++){let N=g[B];if(R>N)continue;if(B===0)R/=N;else{let L=g[B-1];R=B+(R-L)/(N-L)}break}yk(R*0.1,v,_,S,k,w,T,A,C,u,P,r||E>0&&I===0)}return u}function $R(e,t,n){let s=t.path,r={changed:[],inWorld:[]};if(s===null)return r;let{mixRotate:i,mixX:o,mixY:a}=t;if(i===0&&o===0&&a===0)return r;let l=t.rotateMode==="tangent",u=t.rotateMode==="chainScale",c=t.bones.map((k)=>e.bones[e.index.get(k)]),h=c.length,d=l?h:h+1,f=Array(d).fill(0),m=u?Array(h).fill(0):[],p=t.spacing,y=(k)=>e.world.get(k.name);if(t.spacingMode==="percent"){if(u)for(let k=0;k0){k=d/k*p;for(let w=1;w0?fk:-fk}let S=[];for(let k=0,w=3;k=of){let I=(Math.sqrt(P*P+O*O)/B-1)*i+1;A.a*=I,A.c*=I}}if(x=C,b=E,i>0){let{a:B,b:I,c:R,d:N}=A,L;if(l)L=g[w-1];else if(f[k+1]===0)L=g[w+2];else L=Math.atan2(O,P);if(L-=Math.atan2(R,B),_){let ee=Math.cos(L),W=Math.sin(L),X=T.length??0;x+=(X*(ee*B-W*R)-P)*i,b+=(X*(W*B+ee*R)-O)*i}else L+=v;if(L>Te)L-=Te*2;else if(L<-Te)L+=Te*2;L*=i;let U=Math.cos(L),J=Math.sin(L);A.a=U*B-J*R,A.b=U*I-J*N,A.c=J*B+U*R,A.d=J*I+U*N}e.world.set(T.name,A),S.push(T.name)}return{changed:S,inWorld:[...S]}}function rm(e,t,n,s){let r=new Map(e.map((h)=>[h.name,h.parent])),i=new Map;for(let h of e)if(h.parent!==void 0)i.set(h.parent,[...i.get(h.parent)??[],h.name]);let o=new Map(e.map((h)=>[h.name,!t.has(h.name)])),a=new Map,l=(h,d)=>{if(o.get(h))return;let f=r.get(h);if(f!==void 0)l(f,d);o.set(h,!0),a.set(h,{at:d,when:"before"})},u=(h)=>{for(let d of h){if(!t.has(d))continue;if(o.get(d))u(i.get(d)??[]);o.set(d,!1)}},c=new Map;return n.forEach((h,d)=>{if(s.has(d))return;let f;if(h.kind==="slider"){u(h.timelines.bones.map((m)=>m.name));return}if(h.kind==="ik"){if(f=h.bones,l(h.target,d),l(h.bones[0],d),h.bones.length>1)l(h.bones[h.bones.length-1],d);if(u(i.get(h.bones[0])??[]),h.bones.length>1)o.set(h.bones[h.bones.length-1],!0)}else{if(f=h.kind==="physics"?[h.bone]:h.bones,h.kind==="transform")l(h.source,d);else if(h.kind==="path")for(let m of h.slotDeps)l(m,d);for(let m of f)l(m,d);if(h.kind==="path")c.set(d,a.get(h.slotBone)??null);for(let m of f)u(i.get(m)??[]);for(let m of f)o.set(m,!0)}for(let m of f)a.set(m,{at:d,when:"after"})}),c}var OR=Te/180,xk=["bone","scaleY","x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix","inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],IR=["x","y","rotate","scaleX","shearX","limit","fps","inertia","strength","damping","mass","wind","gravity","mix"],BR=["inertiaGlobal","strengthGlobal","dampingGlobal","massGlobal","windGlobal","gravityGlobal","mixGlobal","skin"],bk=["none","uniform","volume"],z1=["inertia","strength","damping","mass","wind","gravity","mix"],vk=[...z1,"reset"],Ki="*",FR={x:0,y:0,rotate:0,scaleX:0,shearX:0,limit:5000,fps:60,inertia:0.5,strength:100,damping:0.85,mass:1,wind:0,gravity:0,mix:1};function DR(e,t,n,s,r,i){let o=i.length;for(let c of Object.keys(e)){if(c==="kind"||c==="name"||c==="declaredIn")continue;if(!xk.includes(c))i.push(`${n}: field "${c}" is not one this reader knows; it reads [${xk.join(", ")}]`)}if(typeof e.bone!=="string"||!s.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);for(let c of IR){let h=e[c];if(h!==void 0&&(typeof h!=="number"||!Number.isFinite(h)))i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a finite number`)}for(let c of BR){let h=e[c];if(h!==void 0&&typeof h!=="boolean")i.push(`${n}: ${c} is ${JSON.stringify(h)}, not a boolean`)}let a="None";if(e.scaleY!==void 0){let c=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"";if(!bk.includes(c))i.push(`${n}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${bk.join(", ")}`);else a=c==="uniform"?"Uniform":c==="volume"?"Volume":"None"}if(i.length!==o)return;let l=(c)=>typeof e[c]==="number"?e[c]:FR[c],u={};for(let c of z1)u[c]=e[`${c}Global`]===!0;return{kind:"physics",name:t,bone:e.bone,skin:e.skin===!0,listedBySkin:!1,x:l("x"),y:l("y"),rotate:l("rotate"),scaleX:l("scaleX"),shearX:l("shearX"),limit:l("limit"),step:1/l("fps"),referenceScale:r,inertia:l("inertia"),strength:l("strength"),damping:l("damping"),massInverse:1/l("mass"),wind:l("wind"),gravity:l("gravity"),mix:l("mix"),global:u,scaleYMode:a}}function Af(e,t){return(!e.skin||e.listedBySkin)&&t.has(e.bone)}var Ni=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function NR(e){if(!Array.isArray(e))return 0;let t=0;for(let n of e)if(typeof n==="object"&&n!==null&&Array.isArray(n.timelines))t+=n.timelines.length;return t}function GR(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.physics[${o}]`;if(!Ni(i)||typeof i.name!=="string"){s.push(`${a} names no physics constraint`);return}let l=i.name;if(l!==Ki&&!n.has(l))s.push(`${a}: "${l}" is not a physics constraint of this document (nor "${Ki}", the timeline naming none)`);if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}let u=new Set;i.timelines.forEach((c,h)=>{let d=`${a}.timelines[${h}]`,f=Ni(c)?vk.find((g)=>g===c.name):void 0;if(!Ni(c)||f===void 0){s.push(`${d}: ${JSON.stringify(Ni(c)?c.name:c)} is not a physics timeline; one keys ${vk.join(", ")}`);return}if(u.has(f))s.push(`${d}: "${f}" is keyed twice on "${l}"`);u.add(f);let m=[],p=c.keys;if(!Array.isArray(p)||p.length===0){s.push(`${d} "${f}": keys is not a non-empty list`);return}let y=-1/0;p.forEach((g,x)=>{let b=`${d} "${f}".keys[${x}]`;if(!Ni(g)){s.push(`${b} is not an object`);return}let v=f==="reset"?["time"]:["time","value","curve"];for(let w of Object.keys(g))if(!v.includes(w))s.push(`${b}: field "${w}" is not one this reader knows; it reads [${v.join(", ")}]`);let _=g.time;if(typeof _!=="number"||!Number.isFinite(_)||_<0){s.push(`${b}: time is ${JSON.stringify(_)}, not a finite time at or after 0`);return}if(_<=y)s.push(`${b}: time ${_} is not after the key before it — the writer refuses key times that do not strictly increase`);if(y=Math.max(y,_),f==="reset"){m.push({time:Math.fround(_),values:[],stated:{time:_,values:[]},curve:"stepped"});return}let S=f==="mix"?1:0;if(g.value!==void 0)if(typeof g.value!=="number"||!Number.isFinite(g.value))s.push(`${b}: value is ${JSON.stringify(g.value)}, not a finite number`);else S=g.value;let k="linear";if(g.curve!==void 0)if(x===p.length-1)s.push(`${b}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(g.curve==="stepped")k="stepped";else if(Array.isArray(g.curve)&&g.curve.length===4&&g.curve.every((w)=>typeof w==="number"&&Number.isFinite(w)))k=g.curve;else s.push(`${b}: curve is ${JSON.stringify(g.curve)}, not "stepped" nor four finite numbers`);m.push({time:Math.fround(_),values:[Math.fround(S)],stated:{time:_,values:[S]},curve:k})}),r.push({name:l,kind:f,keys:m})})}),r}function im(e,t,n){return e.filter((s)=>n(s)&&(t==="reset"||s.global[t]))}function LR(e,t,n,s,r,i={},o=!1){let a=i.search??ct,l=i.channel??Os,u=new Map(e.map((d)=>[d.name,d])),c=new Map(e.map((d)=>[d.name,{...d}])),h=new Set;for(let d of t){let f=d.name===Ki?im([...c.values()],d.kind,r):[c.get(d.name)].filter((p)=>r(p));if(d.kind==="reset"){if(UR(d.keys,s,n,o))for(let p of f)h.add(p.name);continue}let m=a(d.keys,n);for(let p of f){let y=u.get(p.name);if(d.kind==="mass"){let g=1/y.massInverse;p.massInverse=m<0?y.massInverse:1/(g+(l(d.keys,m,0,n)-g))}else p[d.kind]=m<0?y[d.kind]:y[d.kind]+(l(d.keys,m,0,n)-y[d.kind])}}return{records:c,reset:h}}function UR(e,t,n,s=!1){return s?e.some((r)=>r.time>t||r.time<=n):e.some((r)=>t0,y:e.y>0,rotateOrShearX:e.rotate>0||e.shearX>0,scaleX:e.scaleX>0}}function HR(e,t,n,s){let r=e.mix;if(r===0)return!1;let i=lm(s,e.name),{x:o,y:a,rotateOrShearX:l,scaleX:u}=YR(e),c=n;if(s.phase==="reset")om(i,s.time);let h=Math.max(s.time-i.lastTime,0),d=Math.max(0,1-i.remaining/e.step);i.remaining+=h,i.lastTime=s.time;let{worldX:f,worldY:m}=t,p=s.env??am,y=0;if(i.pending)i.pending=!1,i.ux=f,i.uy=m;else{let g=i.remaining,{inertia:x,step:b,referenceScale:v}=e,_=-1,S=e.limit*h,k=S;if(o||a){if(o){let w=(i.ux-f)*x;i.xOffset+=w>S?S:w<-S?-S:w,i.ux=f}if(a){let w=(i.uy-m)*x;i.yOffset+=w>k?k:w<-k?-k:w,i.uy=m}if(g>=b){_=Math.pow(e.damping,60*b);let w=e.massInverse*b,T=e.strength,A=e.wind*v,C=e.gravity*v,E=A*p.wind[0]+C*p.gravity[0],P=A*p.wind[1]+C*p.gravity[1],{xOffset:O,yOffset:B}=i;do{if(o)i.xVelocity+=(E-i.xOffset*T)*w,i.xOffset+=i.xVelocity*b,i.xVelocity*=_;if(a)i.yVelocity-=(P+i.yOffset*T)*w,i.yOffset+=i.yVelocity*b,i.yVelocity*=_;g-=b}while(g>=b);i.xLag=i.xOffset-O,i.yLag=i.yOffset-B}if(y=Math.max(0,1-g/b),o)t.worldX+=(i.xOffset-i.xLag*y)*r*e.x;if(a)t.worldY+=(i.yOffset-i.yLag*y)*r*e.y}if(l||u){let w=Math.atan2(t.c,t.a),T=0,A=0,C=0,E=i.cx-t.worldX,P=i.cy-t.worldY;if(E>S)E=S;else if(E<-S)E=-S;if(P>k)P=k;else if(P<-k)P=-k;if(l){C=(e.rotate+e.shearX)*r;let O=i.rotateLag*d,B=Math.atan2(P+i.ty,E+i.tx)-w-(i.rotateOffset-O)*C;if(i.rotateOffset+=(B-Math.ceil(B*jR-0.5)*q1)*x,B=(i.rotateOffset-O)*C+w,T=Math.cos(B),A=Math.sin(B),u){if(B=c*Math.sqrt(t.a*t.a+t.c*t.c),B>0)i.scaleOffset+=(E*T+P*A)*x/B}}else{T=Math.cos(w),A=Math.sin(w);let O=c*Math.sqrt(t.a*t.a+t.c*t.c)-i.scaleLag*d;if(O>0)i.scaleOffset+=(E*T+P*A)*x/O}if(g=i.remaining,g>=b){if(_===-1)_=Math.pow(e.damping,60*b);let O=e.massInverse*b,B=e.strength,I=e.wind*p.wind[0]+e.gravity*p.gravity[0],R=e.wind*p.wind[1]+e.gravity*p.gravity[1],N=c/v,{rotateOffset:L,scaleOffset:U}=i;for(;;){if(g-=b,u)i.scaleVelocity+=(I*T-R*A-i.scaleOffset*B)*O,i.scaleOffset+=i.scaleVelocity*b,i.scaleVelocity*=_;if(l){if(i.rotateVelocity-=((I*A+R*T)*N+i.rotateOffset*B)*O,i.rotateOffset+=i.rotateVelocity*b,i.rotateVelocity*=_,g0){let _=0;if(e.rotate>0)_=g*e.rotate,x=Math.sin(_),b=Math.cos(_),v=t.b,t.b=b*v-x*t.d,t.d=x*v+b*t.d;_+=g*e.shearX,x=Math.sin(_),b=Math.cos(_),v=t.a,t.a=b*v-x*t.c,t.c=x*v+b*t.c}else g*=e.rotate,x=Math.sin(g),b=Math.cos(g),v=t.a,t.a=b*v-x*t.c,t.c=x*v+b*t.c,v=t.b,t.b=b*v-x*t.d,t.d=x*v+b*t.d}if(u){let g=1+(i.scaleOffset-i.scaleLag*y)*r*e.scaleX;if(t.a*=g,t.c*=g,e.scaleYMode==="Uniform")t.b*=g,t.d*=g;else if(e.scaleYMode==="Volume"){let x=Math.abs(g),b=x>=0.7?1/x:4-3.67347*x;t.b*=b,t.d*=b}}return i.tx=c*t.a,i.ty=c*t.c,!0}function zR(e,t,n,s,r,i){let o=e.filter((l)=>l.kind==="physics"),a=LR(o,t,n,r.last,(l)=>Af(l,s),{},r.loop===!0&&n[l.name,l])),r.keyedNow=new Set(t.flatMap((l)=>l.kind==="reset"?[]:(l.name===Ki?im(o,l.kind,(u)=>Af(u,s)).map((u)=>u.name):[l.name]).map((u)=>`${u}/${l.kind==="mass"?"massInverse":l.kind}`)));for(let l of a.reset)om(lm(r,l),i);return e.map((l)=>l.kind==="physics"?a.records.get(l.name):l)}function cm(e){return{phase:"reset",time:0,states:new Map,last:-1,...e?{step:e}:{}}}function um(e){let t=A2(e,Dt(e));return t.length===0?null:`${t.map((n)=>`path constraint "${n.constraint}" reads slot bone "${n.bone}" from the previous pose`).join("; ")} — under the step the previous pose is the previous step's, which the stepped walk does not carry`}var _k=["animation","additive","loop","mix","bone","property","from","to","scale","max","local","time","skin"],Yl=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function qR(e,t,n,s,r,i){let o=i.length;for(let y of Object.keys(e)){if(y==="kind"||y==="name"||y==="declaredIn")continue;if(!_k.includes(y))i.push(`${n}: field "${y}" is not one this reader knows; it reads [${_k.join(", ")}]`)}let a=(y,g)=>{let x=e[y];if(x===void 0)return g;if(typeof x!=="number"||!Number.isFinite(x))return i.push(`${n}: ${y} is ${JSON.stringify(x)}, not a finite number`),g;return x},l=(y)=>{let g=e[y];if(g===void 0)return!1;if(typeof g!=="boolean")return i.push(`${n}: ${y} is ${JSON.stringify(g)}, not a boolean`),!1;return g},u=r.find((y)=>y.name===e.animation);if(u===void 0)i.push(`${n}: a slider's animation is ${JSON.stringify(e.animation)}, not an animation of this document`);let c=new Map(s.map((y)=>[y.name,y])),h=null;if(e.bone!==void 0)if(typeof e.bone!=="string"||!c.has(e.bone))i.push(`${n}: bone is ${JSON.stringify(e.bone)}, not a bone of this document`);else h=e.bone;let d="rotate";if(e.property!==void 0){let y=Ct.find((g)=>g===e.property);if(y===void 0)i.push(`${n}: property is ${JSON.stringify(e.property)}, none of ${Ct.join(", ")}`);else d=y}a("max",0);let f=l("loop"),m=new Map;for(let y of u?.timelines.bones??[]){let g=c.get(y.name);if(g!==void 0)m.set(g.name,g)}let p={kind:"slider",name:t,animation:u?.name??"",timelines:u?.timelines??{declared:0,duration:0,bones:[],slots:[],later:[],attachments:[],drawOrder:[],events:[]},physics:[],setup:m,additive:l("additive"),loop:f,mix:a("mix",1),time:a("time",0),bone:h,property:d,from:a("from",0),to:a("to",0),scale:a("scale",1),local:l("local"),skin:l("skin"),listedBySkin:!1};return i.length===o?p:void 0}function KR(e,t,n,s){let r=[];if(!Array.isArray(e))return r;return e.forEach((i,o)=>{let a=`${t}.constraints.slider[${o}]`;if(!Yl(i)||typeof i.name!=="string"){s.push(`${a} names no slider`);return}if(!n.some((u)=>u.kind==="slider"&&u.name===i.name))s.push(`${a}: "${i.name}" is not a slider of this document`);let l={name:i.name,time:null,mix:null};if(!Array.isArray(i.timelines)){s.push(`${a}: timelines is not a list`);return}i.timelines.forEach((u,c)=>{let h=`${a}.timelines[${c}]`;if(!Yl(u)||u.name!=="time"&&u.name!=="mix"){s.push(`${h}: ${JSON.stringify(Yl(u)?u.name:u)} is not a slider timeline; a slider keys time and mix`);return}let d=u.name;if(l[d]!==null)s.push(`${h}: "${d}" is keyed twice on slider "${i.name}"`);l[d]=JR(u.keys,`${h} "${d}"`,s)}),r.push(l)}),r}function JR(e,t,n){let s=[];if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),s;let r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!Yl(i)){n.push(`${a} is not an object`);return}for(let h of Object.keys(i))if(h!=="time"&&h!=="value"&&h!=="curve")n.push(`${a}: field "${h}" is not one this reader knows; it reads [time, value, curve]`);let l=i.time;if(typeof l!=="number"||!Number.isFinite(l)||l<0){n.push(`${a}: time is ${JSON.stringify(l)}, not a finite time at or after 0`);return}if(l<=r)n.push(`${a}: time ${l} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l);let u=1;if(i.value!==void 0)if(typeof i.value!=="number"||!Number.isFinite(i.value))n.push(`${a}: value is ${JSON.stringify(i.value)}, not a finite number`);else u=i.value;let c="linear";if(i.curve!==void 0)if(o===e.length-1)n.push(`${a}: the last key carries a curve, which eases to no key — the writer refuses it`);else if(i.curve==="stepped")c="stepped";else if(Array.isArray(i.curve)&&i.curve.length===4&&i.curve.every((h)=>typeof h==="number"&&Number.isFinite(h)))c=i.curve;else n.push(`${a}: curve is ${JSON.stringify(i.curve)}, not "stepped" nor 4 finite numbers`);s.push({time:Math.fround(l),values:[Math.fround(u)],stated:{time:l,values:[u]},curve:c})}),s}function ZR(e,t,n,s={}){let r=t.find((l)=>l.name===e.name);if(r===void 0)return e;let i=s.search??ct,o=s.channel??Os,a=(l,u)=>{if(l===null)return u;let c=i(l,n);return c<0?u:u+(o(l,c,0,n)-u)*1};return{...e,time:a(r.time,e.time),mix:a(r.mix,e.mix)}}function QR(e,t){if(t.bone===null)return t.time;let n=eM(e,{source:t.bone,localSource:t.local,offsets:e2},t.property),s=t.to+(n-t.from)*t.scale,r=t.timelines.duration;if(t.loop&&r===0)return 0;return t.loop?r+s%r:Math.max(0,s)}var e2={rotate:0,x:0,y:0,scaleX:0,scaleY:0,shearY:0};function K1(e,t){let n=ct(e,t);if(n<0)return null;return e[n].values.map((s,r)=>Os(e,n,r,t))}function t2(e,t,n,s){if(t.mix===0)return[];let r=QR(e,t),i=t.timelines.duration,o=t.loop&&i!==0?r%i:r;n?.push({name:t.name,timelines:t.timelines,at:o,alpha:t.mix,additive:t.additive,time:r});let a=t.mix;if(s!==void 0&&e.rules.sliderWritesPhysics)r2(t,o,a,s);let l=[];for(let u of t.timelines.bones){let c=e.index.get(u.name),h=t.setup.get(u.name);if(c===void 0||h===void 0)continue;let d=e.bones[c],f=!1;for(let m of u.timelines){if(m.kind==="inherit"){let x=ct(m.keys,o);if(x<0)continue;d.inheritMode=m.keys[x].mode,f=!0;continue}let p=K1(m.keys,o);if(p===null)continue;f=!0;let y=(x,b)=>{let v=d[x]??0;d[x]=t.additive?v+p[b]*a:v+((h[x]??0)+p[b]-v)*a},g=(x,b)=>{let v=d[x]??1,_=h[x]??1;if(t.additive){d[x]=e.rules.sliderAdditiveScaleProduct?v+(p[b]*_-_)*a:v+(p[b]-1)*_*a;return}let S=_*p[b];if(a===1&&e.rules.sliderScaleMixOneIsTarget){d[x]=S;return}let k=Math.abs(v)*Math.sign(S);d[x]=k+(S-k)*a};switch(m.kind){case"rotate":y("rotation",0);break;case"translate":y("x",0),y("y",1);break;case"translatex":y("x",0);break;case"translatey":y("y",0);break;case"shear":y("shearX",0),y("shearY",1);break;case"shearx":y("shearX",0);break;case"sheary":y("shearY",0);break;case"scale":g("scaleX",0),g("scaleY",1);break;case"scalex":g("scaleX",0);break;case"scaley":g("scaleY",0);break}}if(f||e.rules.sliderReposesKeyedBones&&u.timelines.length>0)l.push(u.name)}return l}function n2(e,t,n,s){let r=new Map(e.flatMap((a)=>a.kind==="physics"?[[a.name,a]]:[])),i=new Map(r),o=new Map;if(!s.sliderPhysicsLastsOnePass){for(let[a,l]of n.carried??new Map){let u=i.get(a);if(u===void 0)continue;let c={...u},h={};for(let[d,f]of Object.entries(l)){if(n.keyedNow?.has(`${a}/${d}`))continue;c[d]=f,h[d]=f}i.set(a,c),o.set(a,h)}n.carried=o}return{records:i,setup:n.setupRecords??r,active:(a)=>Af(a,t),rules:s,ctx:n,written:o}}var s2=new Set(["wind","gravity"]);function r2(e,t,n,s){let r=s.rules;for(let i of e.physics){let o=s.records.get(i.name),a=i.name===Ki?im([...s.records.values()],i.kind,s.active):o!==void 0&&s.active(o)?[o]:[];if(i.kind==="reset"){if(!r.sliderPhysicsResetIsDead&&i.keys.some((h)=>h.time<=t))for(let h of a)om(lm(s.ctx,h.name),s.ctx.time);continue}let l=ct(i.keys,t);if(l<0)continue;let u=Os(i.keys,l,0,t),c=e.additive&&(s2.has(i.kind)||!r.sliderPhysicsAddsWindGravityOnly);for(let h of a){let d=r.sliderPhysicsFromCurrent?h:s.setup.get(h.name),f={...h},m;if(i.kind==="mass")if(m="massInverse",r.sliderPhysicsBlendsMass){let p=1/d.massInverse;f.massInverse=1/(c?1/h.massInverse+u*n:p+(u-p)*n)}else f.massInverse=c?h.massInverse+1/u*n:d.massInverse+(1/u-d.massInverse)*n;else m=i.kind,f[m]=c?h[m]+u*n:d[m]+(u-d[m])*n;if(s.records.set(h.name,f),!r.sliderPhysicsLastsOnePass)s.written.set(h.name,{...s.written.get(h.name),[m]:f[m]})}}}var Ol=(e)=>e<0?0:e>1?1:e,i2={rgba:[0,1,2,3],rgb:[0,1,2],alpha:[3],rgba2:[0,1,2,3,4,5,6],rgb2:[0,1,2,4,5,6]};function J1(e,t,n){for(let s of n)for(let r of s.timelines.slots){if(r.name!==e)continue;for(let i of r.timelines){if(i.kind==="attachment"){let a=ct(i.keys,s.at);if(a>=0)t.placeholder=i.keys[a].name??null;continue}let o=K1(i.keys,s.at);if(o===null)continue;i2[i.kind].forEach((a,l)=>{if(a<4)t.light[a]=s.alpha===1?Ol(o[l]):Ol(t.light[a]+(o[l]-t.light[a])*s.alpha);else if(t.dark!==null)t.dark[a-4]=s.alpha===1?Ol(o[l]):Ol(t.dark[a-4]+(o[l]-t.dark[a-4])*s.alpha)})}}}function o2(e){let t=[];for(let n of e.constraints){if(n.kind!=="slider")continue;let s=e.animations.find((c)=>c.name===n.animation);if(s===void 0)continue;let r=s.constraints,i=r.slider.reduce((c,h)=>c+(h.time===null?0:1)+(h.mix===null?0:1),0),o=r.path.reduce((c,h)=>c+[h.position,h.spacing,h.mix].filter((d)=>d!==void 0).length,0),a=[r.ik.length>0?"ik":null,r.transform.length>0?"transform":null,o>0?"path":null,i>0?"slider":null].filter((c)=>c!==null);if(a.length>0)t.push(`slider "${n.name}" applies animation "${n.animation}", which keys ${a.join(", ")} constraint timelines — a slider writing a later constraint's pose is not posed by this cut`);let l=e.constraints.flatMap((c)=>c.record?.kind==="path"?[c.record.slot]:[]),u=s.timelines.attachments.filter((c)=>c.deform!==null&&l.includes(c.slot)&&e.skins.find((h)=>h.name===c.skin)?.attachments[c.slot]?.[c.attachment]?.geometry?.kind==="path");if(u.length>0)t.push(`slider "${n.name}" applies animation "${n.animation}", which deforms walked path attachment(s) ${u.map((c)=>`"${c.skin}/${c.slot}/${c.attachment}"`).join(", ")} — a slider's deform of a curve a path constraint walks is not posed by this cut`)}return t.length===0?null:t.join("; ")}var Ht=180/Te,Gi=Te/180,Sk=["ik","transform","path","physics","slider"],Ct=["rotate","x","y","scaleX","scaleY","shearY"],wk={rotate:"mixRotate",x:"mixX",y:"mixY",scaleX:"mixScaleX",scaleY:"mixScaleY",shearY:"mixShearY"},a2={rotate:"rotation",x:"x",y:"y",scaleX:"scaleX",scaleY:"scaleY",shearY:"shearY"},kk=["none","uniform","volume"],l2={ik:["bones","target","scaleY","mix","softness","bendPositive","compress","stretch","skin"],transform:["bones","source","properties","localSource","localTarget","additive","clamp","rotation","x","y","scaleX","scaleY","shearY","mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY","skin"]},Kn=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function Hl(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function pn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="number"||!Number.isFinite(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a finite number`),n;return i}function rn(e,t,n,s,r){let i=e[t];if(i===void 0)return n;if(typeof i!=="boolean")return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a boolean`),n;return i}function c2(e,t,n,s){if(!Array.isArray(e.bones)||e.bones.length===0)return s.push(`${n}: bones is ${JSON.stringify(e.bones)}, not a non-empty list of bone names`),[];let r=[];return e.bones.forEach((i,o)=>{if(typeof i!=="string"||!t.has(i))s.push(`${n}: bones[${o}] ${JSON.stringify(i)} is not a bone of this document`);else r.push(i)}),r}function Mk(e,t,n,s,r){let i=e[t];if(typeof i!=="string"||!n.has(i))return r.push(`${s}: ${t} is ${JSON.stringify(i)}, not a bone of this document`),"";return i}function Ef(e,t,n,s,r){if(e[wk[t]]!==void 0)return pn(e,wk[t],0,s,r);if(t==="y")return n.has("x")?Ef(e,"x",n,s,r):0;if(t==="scaleY")return n.has("scaleX")?Ef(e,"scaleX",n,s,r):0;return n.has(t)?1:0}function u2(e,t,n,s,r,i,o){let a=o.length,l={...e};delete l.kind,delete l.name,delete l.declaredIn,Hl(l,l2[t],s,o);let u=c2(e,r,s,o),c=rn(e,"skin",!1,s,o);if(t==="ik"){let g=Mk(e,"target",r,s,o);if(u.length>2)o.push(`${s}: an ik constraint names ${u.length} bones; the format takes one or two`);if(u.length>=1&&i.get(u[0])===void 0)o.push(`${s}: its first bone "${u[0]}" is the root; spine-core throws posing an ik constraint on a bone with no parent`);if(u.length===2&&i.get(u[1])!==u[0])o.push(`${s}: "${u[1]}" is not a child of "${u[0]}"; a two-bone ik needs the second bone directly under the first`);let x="none";if(e.scaleY!==void 0){let v=typeof e.scaleY==="string"&&e.scaleY.length>0?e.scaleY[0].toLowerCase()+e.scaleY.slice(1):"",_=kk.find((S)=>S===v);if(_===void 0)o.push(`${s}: scaleY is ${JSON.stringify(e.scaleY)}, none of ${kk.join(", ")}`);else x=_}let b={kind:t,name:n,bones:u,target:g,scaleY:x,skin:c,listedBySkin:!1,mix:pn(e,"mix",1,s,o),softness:pn(e,"softness",0,s,o),bendPositive:rn(e,"bendPositive",!0,s,o),compress:rn(e,"compress",!1,s,o),stretch:rn(e,"stretch",!1,s,o)};return o.length===a?b:void 0}let h=Mk(e,"source",r,s,o),d=[],f=new Set;if(e.properties!==void 0&&!Kn(e.properties))o.push(`${s}: properties is not an object`);else if(Kn(e.properties))for(let[g,x]of Object.entries(e.properties)){let b=`${s}.properties.${g}`,v=Ct.find((S)=>S===g);if(v===void 0){o.push(`${b}: "${g}" is none of ${Ct.join(", ")}`);continue}if(!Kn(x)){o.push(`${b} is not an object`);continue}Hl(x,["offset","to"],b,o);let _=[];if(!Kn(x.to))o.push(`${b}: to is not an object`);else for(let[S,k]of Object.entries(x.to)){let w=`${b}.to.${S}`,T=Ct.find((A)=>A===S);if(T===void 0){o.push(`${w}: "${S}" is none of ${Ct.join(", ")}`);continue}if(!Kn(k)){o.push(`${w} is not an object`);continue}Hl(k,["offset","scale","max"],w,o),_.push({property:T,offset:pn(k,"offset",0,w,o),scale:pn(k,"scale",1,w,o),max:pn(k,"max",1,w,o)}),f.add(T)}d.push({property:v,offset:pn(x,"offset",0,b,o),to:_})}let m={},p={};for(let g of Ct)m[g]=pn(e,a2[g],0,s,o),p[g]=Ef(e,g,f,s,o);let y={kind:t,name:n,bones:u,source:h,properties:d,skin:c,listedBySkin:!1,offsets:m,mixes:p,localSource:rn(e,"localSource",!1,s,o),localTarget:rn(e,"localTarget",!1,s,o),additive:rn(e,"additive",!1,s,o),clamp:rn(e,"clamp",!1,s,o)};return o.length===a?y:void 0}var Tk=["mix","softness"],Ck=["mixRotate","mixX","mixY","mixScaleX","mixScaleY","mixShearY"];function h2(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function d2(e,t,n,s){let r={ik:[],transform:[],path:[],physics:0,slider:[]};if(!Kn(e))return r;r.path=ER(e.path,t,new Set(n.filter((i)=>i.kind==="path").map((i)=>i.name)),s),r.physics=NR(e.physics),r.physicsKeyed=GR(e.physics,t,new Set(n.filter((i)=>i.kind==="physics").map((i)=>i.name)),s),r.slider=KR(e.slider,t,n,s);for(let i of["ik","transform"]){let o=e[i];if(!Array.isArray(o))continue;o.forEach((a,l)=>{let u=`${t}.constraints.${i}[${l}]`;if(!Kn(a)||typeof a.name!=="string"){s.push(`${u} names no constraint`);return}if(!n.some((p)=>p.kind===i&&p.name===a.name))s.push(`${u}: "${a.name}" is not a ${i} constraint of this document`);let c=a.keys;if(!Array.isArray(c)||c.length===0){s.push(`${u}: keys is not a non-empty list`);return}let h=i==="ik"?Tk:Ck,d=i==="ik"?["time",...Tk,"bendPositive","compress","stretch","curve"]:["time",...Ck,"curve"],f=-1/0,m=[];if(c.forEach((p,y)=>{let g=`${u}.keys[${y}]`;if(!Kn(p)){s.push(`${g} is not an object`);return}Hl(p,d,g,s);let x=p.time;if(typeof x!=="number"||!Number.isFinite(x)||x<0){s.push(`${g}: time is ${JSON.stringify(x)}, not a finite time at or after 0`);return}if(x<=f)s.push(`${g}: time ${x} is not after the key before it — the writer refuses key times that do not strictly increase`);f=Math.max(f,x);let b=h.map((v)=>{if(i==="transform"&&v==="mixY"&&p.mixY===void 0)return pn(p,"mixX",1,g,s);return pn(p,v,v==="softness"?0:1,g,s)});m.push({time:Math.fround(x),values:b.map(Math.fround),stated:{time:x,values:b},curve:h2(p,h.length,y===c.length-1,g,s),flags:{bendPositive:rn(p,"bendPositive",!0,g,s),compress:rn(p,"compress",!1,g,s),stretch:rn(p,"stretch",!1,g,s)}})}),i==="ik")r.ik.push({name:a.name,keys:m});else r.transform.push({name:a.name,keys:m})})}return r}function Ak(e,t,n,s={}){let r=s.search??ct,i=s.channel??Os;return e.map((o)=>{if(t===null||o.kind==="physics")return o;if(o.kind==="slider")return ZR(o,t.slider,n,s);if(o.kind==="path"){let c=t.path.find((d)=>d.name===o.name);if(c===void 0)return o;let h={...o};for(let[d,f]of[["position",["position"]],["spacing",["spacing"]],["mix",["mixRotate","mixX","mixY"]]]){let m=c[d];if(m===void 0)continue;let p=r(m,n);if(p<0)continue;f.forEach((y,g)=>h[y]=o[y]+(i(m,p,g,n)-o[y])*1)}return h}if(o.kind==="ik"){let c=t.ik.find((d)=>d.name===o.name);if(c===void 0)return o;let h=r(c.keys,n);if(h<0)return o;return{...o,mix:o.mix+(i(c.keys,h,0,n)-o.mix)*1,softness:o.softness+(i(c.keys,h,1,n)-o.softness)*1,...c.keys[h].flags}}let a=t.transform.find((c)=>c.name===o.name);if(a===void 0)return o;let l=r(a.keys,n);if(l<0)return o;let u={};return Ct.forEach((c,h)=>u[c]=o.mixes[c]+(i(a.keys,l,h,n)-o.mixes[c])*1),{...o,mixes:u}})}function Pf(e){return e>180?e-360:e<=-180?e+360:e}var f2={a:1,b:0,c:0,d:1,worldX:0,worldY:0};function Ji(e){let t=e.inheritMode;if(t===void 0||t.length===0)return"normal";let n=t[0].toLowerCase()+t.slice(1);return n==="onlyTranslation"||n==="noRotationOrReflection"||n==="noScale"||n==="noScaleOrReflection"?n:"normal"}var es={ikCollapsedDet:0.00001,ikXAxisFloor:0.00001,readBackCollapsed:!0,offsetNegatedAtZeroDet:!0,inactiveHoldsItsWorld:!0,transformIgnoresBoneActivity:!0,ikOverInactiveFresh:!0,refuseHistoryLeak:!0,readBackReflectedShear:!0,readBackConformalInverse:!0,readBackNoScaleFrame:!0,additiveShearRightAngle:!0,ikZeroScaleSignPositive:!0,ikStretchMinLength:0.00001,ikTwoBoneNearChild:0.00001,sliderReposesKeyedBones:!0,sliderAdditiveScaleProduct:!0,sliderScaleMixOneIsTarget:!0,sliderWritesPhysics:!0,sliderPhysicsFromCurrent:!0,sliderPhysicsAddsWindGravityOnly:!0,sliderPhysicsBlendsMass:!0,sliderPhysicsLastsOnePass:!0,sliderPhysicsResetIsDead:!0};function Zi(e){return e===void 0?es:{...es,...e}}function Z1(e,t){return e/(t<0.7?0.25+t*0.642857:t)}function $s(e,t){return e.bones[e.index.get(t)]}function hm(e,t){return t.parent===void 0?f2:e.world.get(t.parent)}function m2(e,t){if(!e.active.has(t.name)){if(!e.rules.inactiveHoldsItsWorld)e.world.set(t.name,{a:0,b:0,c:0,d:0,worldX:0,worldY:0});return}if(t.parent===void 0){e.world.set(t.name,zi([t]).get(t.name));return}let n=e.world.get(t.parent),[s,r,i,o]=C1(Ji(t),n,t),a=t.x??0,l=t.y??0;e.world.set(t.name,{a:s,b:r,c:i,d:o,worldX:n.a*a+n.b*l+n.worldX,worldY:n.c*a+n.d*l+n.worldY})}function p2(e,t,n,s=es){let r=e.parent===void 0?"normal":Ji(e),i=1/(t.a*t.d-t.b*t.c),o=n.worldX-t.worldX,a=n.worldY-t.worldY;if(e.x=o*(t.d*i)-a*(t.b*i),e.y=a*(t.a*i)-o*(t.c*i),e.shearX=0,r==="noScale"||r==="noScaleOrReflection"){let d=t.a*t.d-t.b*t.c,f=r==="noScale"&&d<0?-1:1;if(!s.readBackNoScaleFrame){let x=Math.sqrt(n.a*n.a+n.c*n.c),[b,v]=[n.a/x,n.c/x];Il(e,x,0,b*n.b+v*n.d,(b*n.d-v*n.b)*f,s),e.rotation=Math.atan2((v*t.a-b*t.c)/d,(b*t.d-v*t.b)/d)*Ht;return}let m=d<0?-1:1,p=Math.atan2((t.a*n.c-t.c*n.a)*m,(t.d*n.a-t.b*n.c)*m)*Ht,[y,g]=T1([t.a,t.b,t.c,t.d],p);Il(e,y*n.a+g*n.c,(y*n.c-g*n.a)*f,y*n.b+g*n.d,(y*n.d-g*n.b)*f,s,"shearX"),e.rotation=p;return}let l,u,c,h;if(r==="onlyTranslation")[l,u,c,h]=[n.a,n.b,n.c,n.d];else if(r==="noRotationOrReflection"){if(s.readBackConformalInverse){let d=1/(t.a*t.a+t.c*t.c),f=1/Math.abs(t.a*t.d-t.b*t.c);[l,u,c,h]=[(t.a*n.a+t.c*n.c)*d,(t.a*n.b+t.c*n.d)*d,(t.a*n.c-t.c*n.a)*f,(t.a*n.d-t.c*n.b)*f]}else{let d=Math.abs(t.a*t.d-t.b*t.c)/(t.a*t.a+t.c*t.c),[f,m,p,y]=[t.a,-t.c*d,t.c,t.a*d],g=f*y-m*p;[l,u,c,h]=[(y*n.a-m*n.c)/g,(y*n.b-m*n.d)/g,(f*n.c-p*n.a)/g,(f*n.d-p*n.b)/g]}Il(e,l,c,u,h,s),e.rotation=(e.rotation??0)+Math.atan2(t.c,t.a)*Ht;return}else{let[d,f,m,p]=[t.d*i,t.b*i,t.c*i,t.a*i];[l,u,c,h]=[d*n.a-f*n.c,d*n.b-f*n.d,p*n.c-m*n.a,p*n.d-m*n.b]}Il(e,l,c,u,h,s)}function Il(e,t,n,s,r,i,o="rotation"){let a=Math.sqrt(t*t+n*n),l=Math.sqrt(s*s+r*r);if(i.readBackCollapsed?!(a>0.0001):a<=0.0001){e.scaleX=0,e.scaleY=l,e.shearY=0,e.rotation=!i.readBackCollapsed||l>0.00001?Math.atan2(r,s)*Ht-90:0;return}let u=Math.atan2(n,t)*Ht,c=t*r-s*n,h=Math.atan2(r,s)*Ht;if(o==="rotation")e.rotation=u;else e.shearX=u;e.scaleX=a,e.scaleY=c<0?-l:l;let d=o==="rotation"?u:0,f=90;if(c<0)if(i.readBackReflectedShear)f=-90;else h+=180;let m=h-(d+f);m=m>180?m-360:m<-180?m+360:m,e.shearY=!i.readBackCollapsed||l>0.00001?m:0}function Q1(e,t,n=null){let s=$s(e,t.bones[0]),r=n??hm(e,s),i=e.world.get(s.name),o=e.world.get(t.target),a=Ji(s),[l,u,c,h]=[r.a,r.b,r.c,r.d],d=0,f,m;if(a==="noRotationOrReflection"){let b=Math.abs(l*h-u*c)/Math.max(e.rules.ikXAxisFloor,l*l+c*c);u=-c*b,h=l*b,d=Math.atan2(c,l)*Ht;let v=l*h-u*c,_=o.worldX-r.worldX,S=o.worldY-r.worldY;[f,m]=Math.abs(v)<=e.rules.ikCollapsedDet?[0,0]:[(_*h-S*u)/v-(s.x??0),(S*l-_*c)/v-(s.y??0)]}else if(a==="onlyTranslation")f=o.worldX-i.worldX,m=o.worldY-i.worldY;else{let b=l*h-u*c,v=o.worldX-r.worldX,_=o.worldY-r.worldY;[f,m]=Math.abs(b)<=e.rules.ikCollapsedDet?[0,0]:[(v*h-_*u)/b-(s.x??0),(_*l-v*c)/b-(s.y??0)]}let p=s.rotation??0,y=s.scaleX??1,g=-(s.shearX??0)-p+d+Math.atan2(m,f)*Ht;if(y<0)g+=180;s.rotation=p+Pf(g)*t.mix;let x=(s.length??0)*y;if((t.compress||t.stretch)&&x>e.rules.ikStretchMinLength){let b=o.worldX-i.worldX,v=o.worldY-i.worldY,_=a==="noScale"||a==="noScaleOrReflection"?Math.sqrt(b*b+v*v):Math.sqrt(f*f+m*m);if(t.compress&&_x){let S=(_/x-1)*t.mix+1;if(s.scaleX=y*S,t.scaleY==="uniform")s.scaleY=(s.scaleY??1)*S;else if(t.scaleY==="volume")s.scaleY=Z1(s.scaleY??1,S)}}return[s.name]}function g2(e,t,n=null){let s=$s(e,t.bones[0]),r=$s(e,t.bones[1]);if(Ji(s)!=="normal"||Ji(r)!=="normal")return[];let i=n??hm(e,s),o=e.world.get(s.name),a=e.world.get(t.target),l=i.a*i.d-i.b*i.c,u=Math.abs(l)<=e.rules.ikCollapsedDet?0:1/l,c=(W,X)=>{let F=W-i.worldX,G=X-i.worldY;return[(F*i.d-G*i.b)*u,(G*i.a-F*i.c)*u]},h=s.x??0,d=s.y??0,f=s.scaleX??1,m=s.scaleY??1,p=r.scaleX??1,y=f,g=m,x=r.x??0,b=r.y??0,v=Math.abs(Math.abs(f)-Math.abs(m))<=0.00001;if(!v||t.stretch)b=0;let[_,S]=c(o.a*x+o.b*b+o.worldX,o.c*x+o.d*b+o.worldY),k=_-h,w=S-d,T=Math.sqrt(k*k+w*w),A=(r.length??0)*Math.abs(p);if(T0){let G=Math.min(1,F/(W*2))-1,H=(F-W*(1-G*G))/X;C-=H*C,E-=H*E,P=C*C+E*E}}let B,I;if(v){A*=Math.abs(f);let W=(P-T*T-A*A)/(2*T*A);if(W<-1)W=-1,I=Math.PI*O;else if(W>1){if(W=1,I=0,t.stretch){let G=(Math.sqrt(P)/(T+A)-1)*t.mix+1;if(y*=G,t.scaleY==="uniform")g*=G;else if(t.scaleY==="volume")g=Z1(g,G)}}else I=Math.acos(W)*O;let X=T+A*W,F=A*Math.sin(I);B=Math.atan2(E*X-C*F,C*X+E*F)}else{let W=Math.abs(f)*A,X=Math.abs(m)*A,F=W*W,G=X*X,H=G-F,Z=-2*G*T,V=G*T*T+F*P-F*G,Q=Z*Z-4*H*V,he=!1;if(B=0,I=0,Q>=0){let re=Math.sqrt(Q);if(Z<0)re=-re;re=-(Z+re)*0.5;let Ae=re/H,ae=V/re,Pe=Math.abs(Ae)=0){let oe=Math.sqrt(De)*O;B=Math.atan2(E,C)-Math.atan2(oe,Pe),I=Math.atan2(oe/Math.abs(m),(Pe-T)/Math.abs(f)),he=!0}}if(!he){let re={angle:Te,x:T-W,y:0,dist:(T-W)*(T-W)},Ae={angle:0,x:T+W,y:0,dist:(T+W)*(T+W)},ae=-W*T/(F-G);if(ae>=-1&&ae<=1){let De=Math.acos(ae),oe=W*Math.cos(De)+T,Ee=X*Math.sin(De),xe=oe*oe+Ee*Ee;if(xeAe.dist)Ae={angle:De,x:oe,y:Ee,dist:xe}}let Pe=P<=(re.dist+Ae.dist)*0.5?re:Ae;B=Math.atan2(E,C)-Math.atan2(Pe.y*O,Pe.x),I=Pe.angle*O}}let R=e.rules.ikZeroScaleSignPositive?(f<0?-1:1)*(m<0?-1:1):Math.sign(f)*Math.sign(m),N=Math.atan2(b,x),L=s.rotation??0,U=(B-R*N)*Ht+(f<0?180:0)-L;s.rotation=L+Pf(U)*t.mix,s.scaleX=y,s.scaleY=g;let J=((I+R*N)*Ht-(r.shearX??0))*R+(p<0?180:0),ee=r.rotation??0;return r.y=b,r.rotation=ee+Pf(J-ee)*t.mix,[s.name]}function eM(e,t,n){let s=$s(e,t.source),r=t.offsets;if(t.localSource)switch(n){case"rotate":return(s.rotation??0)+r.rotate;case"x":return(s.x??0)+r.x;case"y":return(s.y??0)+r.y;case"scaleX":return(s.scaleX??1)+r.scaleX;case"scaleY":return(s.scaleY??1)+r.scaleY;case"shearY":return(s.shearY??0)+r.shearY}let i=e.world.get(t.source);switch(n){case"rotate":{let o=i.a*i.d-i.b*i.c,a=Math.atan2(i.c,i.a)*Ht+((e.rules.offsetNegatedAtZeroDet?o>0:o>=0)?r.rotate:-r.rotate);if(a<0)a+=360;return a}case"x":return i.a*r.x+i.b*r.y+i.worldX;case"y":return i.c*r.x+i.d*r.y+i.worldY;case"scaleX":return Math.sqrt(i.a*i.a+i.c*i.c)+r.scaleX;case"scaleY":return Math.sqrt(i.b*i.b+i.d*i.d)+r.scaleY;case"shearY":return(Math.atan2(i.d,i.b)-Math.atan2(i.c,i.a))*Ht-90+r.shearY}}function y2(e,t,n,s,r,i){switch(t){case"rotate":{let o=r?n*Gi:n*Gi-Math.atan2(e.c,e.a);if(o>Te)o-=2*Te;else if(o<-Te)o+=2*Te;o*=s;let a=Math.cos(o),l=Math.sin(o),[u,c]=[e.a,e.b];e.a=a*u-l*e.c,e.b=a*c-l*e.d,e.c=l*u+a*e.c,e.d=l*c+a*e.d;return}case"x":e.worldX=r?e.worldX+n*s:e.worldX+(n-e.worldX)*s;return;case"y":e.worldY=r?e.worldY+n*s:e.worldY+(n-e.worldY)*s;return;case"scaleX":case"scaleY":{let[o,a]=t==="scaleX"?["a","c"]:["b","d"],l=Math.sqrt(e[o]*e[o]+e[a]*e[a]);if(l===0)return;let u=r?1+(n-1)*s:1+(n-l)*s/l;e[o]*=u,e[a]*=u;return}case"shearY":{let o=Math.atan2(e.d,e.b),a=Math.atan2(e.c,e.a),l=r&&!i.additiveShearRightAngle?n*Gi:(n+90)*Gi-(r?90*Gi:o-a);if(!r)l=l>Te?l-2*Te:l<-Te?l+2*Te:l;let u=o+l*s,c=Math.sqrt(e.b*e.b+e.d*e.d);e.b=Math.cos(u)*c,e.d=Math.sin(u)*c;return}}}var x2={rotate:"rotation",x:"x",y:"y",scaleX:"scaleX",scaleY:"scaleY",shearY:"shearY"};function b2(e,t,n,s,r){let i=x2[t],o=t==="scaleX"||t==="scaleY",a=e[i]??(o?1:0);if(!r)e[i]=a+(n-a)*s;else e[i]=o?a*(1+(n-1)*s):a+n*s}function v2(e,t){let n=[],s=[];for(let r of t.bones){let i=$s(e,r),o={...e.world.get(r)},a=!1;for(let l of t.properties){let u=eM(e,t,l.property)-l.offset;for(let c of l.to){let h=t.mixes[c.property];if(h===0)continue;let d=u*c.scale+c.offset;if(t.clamp){let f=Math.min(c.offset,c.max),m=Math.max(c.offset,c.max);d=dm?m:d}if(a=!0,t.localTarget)b2(i,c.property,d,h,t.additive);else y2(o,c.property,d,h,t.additive,e.rules)}}if(!a)continue;if(n.push(r),!t.localTarget)e.world.set(r,o),s.push(r)}return{changed:n,inWorld:s}}function dm(e,t){return Rf(t,e.active,e.rules)}function Rf(e,t,n=es){if(e.skin&&!e.listedBySkin)return"skin";return(e.kind==="path"?[e.slotBone]:e.kind==="ik"?n.ikOverInactiveFresh?[e.target]:[...e.bones,e.target]:e.kind==="transform"?n.transformIgnoresBoneActivity?[e.source]:[...e.bones,e.source]:e.kind==="slider"?e.bone===null?[]:[e.bone]:[e.bone]).every((r)=>t.has(r))?null:"inactive bone"}function tM(e,t,n,s){let r=new Map(e.map((h)=>[h.name,h.parent])),i=new Map;for(let h of e)if(h.parent!==void 0)i.set(h.parent,[...i.get(h.parent)??[],h.name]);let o=new Map(e.map((h)=>[h.name,!t.has(h.name)])),a=new Set,l=(h)=>{if(o.get(h))return;let d=r.get(h);if(d!==void 0)l(d);o.set(h,!0),a.add(h)},u=(h)=>{for(let d of h){if(!t.has(d))continue;if(o.get(d))u(i.get(d)??[]);o.set(d,!1)}},c=new Map;return n.forEach((h,d)=>{if(s.has(d))return;if(h.kind==="slider"){u(h.timelines.bones.map((m)=>m.name));return}if(h.kind==="ik"){if(l(h.target),l(h.bones[0]),h.bones.length>1)l(h.bones[h.bones.length-1]);if(h.bones.some((m)=>!t.has(m))){let m=r.get(h.bones[0]);c.set(d,m===void 0||a.has(m))}if(u(i.get(h.bones[0])??[]),h.bones.length>1)o.set(h.bones[h.bones.length-1],!0);return}let f=h.kind==="physics"?[h.bone]:h.bones;if(h.kind==="transform")l(h.source);else if(h.kind==="path")for(let m of h.slotDeps)l(m);for(let m of f)l(m);for(let m of f)u(i.get(m)??[]);for(let m of f)o.set(m,!0)}),c}function _2(e,t,n,s){if(!e.rules.ikOverInactiveFresh||s.get(n)!==!1)return null;return{a:0,b:0,c:0,d:0,worldX:0,worldY:0}}function ic(e,t,n,s,r=null,i,o,a,l=es){if(s.length===0&&a===void 0){if(o!==void 0&&!l.sliderPhysicsLastsOnePass)o.carried=new Map;return new Map(t)}let u={bones:e.map((y)=>({...y})),index:M2(e,n),world:new Map(t),active:n,rules:l},c=new Set;s.forEach((y,g)=>{if(dm(u,y)!==null)c.add(g)});let h=s.some((y)=>y.kind==="path")?Ek(w2,u,s,c,()=>rm(e,n,s,c)):new Map,d=s.some((y)=>y.kind==="ik"&&y.bones.some((g)=>!n.has(g)))?Ek(k2,u,s,c,()=>tM(e,n,s,c)):new Map,f=new Map,m=o===void 0?void 0:n2(s,n,o,l),p=(y,g)=>{for(let[x,b]of h)if(b!==null&&b.at===y&&b.when===g&&!(x===y&&g==="before"))f.set(x,{...u.world.get(s[x].slotBone)})};for(let y=0;y0)C2(u,x,b);p(y,"after")}return u.world}function S2(e){switch(e.kind){case"slider":return[e.kind,e.timelines.bones];case"ik":return[e.kind,e.target,e.bones];case"physics":return[e.kind,e.bone];case"transform":return[e.kind,e.source,e.bones];case"path":return[e.kind,e.bones,e.slotDeps,e.slotBone]}}var w2=new WeakMap,k2=new WeakMap;function Ek(e,t,n,s,r){let i=n.map(S2),o=[...s],a=e.get(t.index);if(a!==void 0&&a.shapes.length===i.length&&i.every((u,c)=>u.length===a.shapes[c].length&&u.every((h,d)=>h===a.shapes[c][d]))&&a.skipped.length===o.length&&o.every((u,c)=>u===a.skipped[c]))return a.plan;let l=r();return e.set(t.index,{shapes:i,skipped:o,plan:l}),l}var Pk=new WeakMap;function M2(e,t){let n=Pk.get(t);if(n!==void 0&&n.names.length===e.length&&e.every((r,i)=>r.name===n.names[i]&&r.parent===n.parents[i]))return n.index;let s=new Map(e.map((r,i)=>[r.name,i]));return Pk.set(t,{names:e.map((r)=>r.name),parents:e.map((r)=>r.parent),index:s}),s}var Rk=new WeakMap;function T2(e){let t=Rk.get(e.index);if(t!==void 0)return t;let n=e.bones.map(()=>[]);for(let s=0;su-c);for(let u of l){let c=e.bones[u];if(c.parent!==void 0&&r.has(c.parent)&&(!e.rules.inactiveHoldsItsWorld||e.active.has(c.parent)||s.includes(c.parent)))r.add(c.name);if(r.has(c.name)&&!i.includes(c.name))m2(e,c)}}function A2(e,t){let n=e.constraints.flatMap((o)=>o.record===void 0?[]:[o.record]);if(!n.some((o)=>o.kind==="path"))return[];let s={bones:[...e.bones],index:new Map(e.bones.map((o,a)=>[o.name,a])),active:t,rules:es},r=new Set;n.forEach((o,a)=>{if(dm(s,o)!==null)r.add(a)});let i=[];for(let[o,a]of rm(e.bones,t,n,r)){let l=n[o];if(a===null&&l.offsetRotation!==0)i.push({constraint:l.name,bone:l.slotBone})}return i}function fm(e){let t=[],n=e.constraints.flatMap((s)=>s.record?.kind==="path"?[s.record]:[]);for(let s of e.animations){for(let r of n)if(s.timelines.slots.some((i)=>i.name===r.slot&&i.timelines.some((o)=>o.kind==="attachment")))t.push(`animation "${s.name}" keys the attachment of slot "${r.slot}", which path constraint "${r.name}" walks — a switch of the walked curve is not measured`);for(let r of s.deforms){let[i,o,a]=r.split("/"),l=e.skins.find((c)=>c.name===i)?.attachments[o]?.[a]?.geometry,u=Qf(e,o,a).map((c)=>`"${c}"`);if(l?.kind==="path"&&u.length>1)t.push(`animation "${s.name}" deforms path attachment "${a}" (skin "${i}", slot "${o}"), a placeholder skins ${u.join(", ")} fill — which of them --skin all walks, and so whether the deform moves it, is the Spine file's skin order, not the model's`)}}return t.length===0?null:t.join("; ")}function dc(e,t=es){let n=e.constraints.flatMap((o)=>o.record?.kind==="path"&&o.record.unresolved!==null?[o.record.unresolved]:[]);if(n.length>0)return n.join("; ");let s=e.constraints.filter((o)=>!Sk.includes(o.kind));if(s.length===0)return o2(e)??(t.refuseHistoryLeak?E2(e):null);let r=[...new Set(e.constraints.map((o)=>o.kind))],i=[...new Set(s.map((o)=>o.kind))];return`the document declares ${r.map((o)=>`${o} ×${e.constraints.filter((a)=>a.kind===o).length}`).join(", ")}, and ${i.join(", ")} constraints are not admitted (item 5; ${Sk.join(", ")} are): the oracle applies them`}function E2(e){return P2(e).refusal}function P2(e){let t=e.constraints.flatMap((p)=>p.record===void 0?[]:[p.record]),n=Dt(e);if(e.bones.every((p)=>n.has(p.name)))return{refusal:null,tainted:new Map};let s=new Map(e.bones.map((p)=>[p.name,p.parent])),r=new Set;for(let p of e.bones)if(!n.has(p.name)||p.parent!==void 0&&r.has(p.parent))r.add(p.name);let i=(p)=>e.bones.filter((y)=>{for(let g=y.name;g!==void 0;g=s.get(g))if(g===p)return!0;return!1}).map((y)=>y.name),o={bones:[...e.bones],index:new Map(e.bones.map((p,y)=>[p.name,y])),active:n,rules:es},a=new Set;t.forEach((p,y)=>{if(dm(o,p)!==null)a.add(y)});let l=tM(e.bones,n,t,a),u=new Map,c=new Map,h=(p)=>`${p.kind} constraint "${p.name}" writes into inactive bone "${p.inactive}"`,d=()=>{let p=new Map(u);for(let[y,g]of c)if(!p.has(y))p.set(y,g);return p},f=(p,y,g)=>{for(let x of y)if(!p.has(x))p.set(x,g)},m=(p)=>`${p.kind} constraint "${p.name}"`;for(let p=0;pw.name):y.bones,x=y.kind==="transform"&&y.localSource||y.kind==="slider"&&y.local,b=y.kind==="ik"?[y.target]:y.kind==="transform"?[y.source]:y.kind==="path"?[y.slotBone,...y.slotDeps]:y.kind==="slider"?y.bone===null?[]:[y.bone]:[],v=x?c:u,_=b.find((w)=>v.has(w));if(_!==void 0){let w=g.find((A)=>!r.has(A)),T=v.get(_);if(w!==void 0)return{refusal:`${m(y)} moves posed bone "${w}" and reads ${x?"the local values":"the world transform"} of bone "${_}", a bone whose value depends on the runtime's previous pass (${h(T)}) — the runtime's own sample-after-sample and fresh-skeleton readings disagree there, so there is no one value to pose`,tainted:d()};f(u,g.flatMap(i),T),f(c,g,T)}let S=g.find((w)=>!n.has(w));if(S===void 0||y.kind==="physics"||y.kind==="slider")continue;let k={kind:y.kind,name:y.name,inactive:S};if(y.kind==="ik"){if(l.get(p)!==!1)continue;if(f(c,y.bones,k),y.bones.length>1)f(u,i(y.bones[1]),k)}else if(y.kind==="transform"&&y.localTarget)f(c,g,k);else f(u,g.flatMap(i),k),f(c,g,k)}return{refusal:null,tainted:d()}}var nM={rotate:["value"],translate:["x","y"],translatex:["value"],translatey:["value"],scale:["x","y"],scalex:["value"],scaley:["value"],shear:["x","y"],shearx:["value"],sheary:["value"]},R2=[...Object.keys(nM),"inherit"],fc={rgba:{fields:[["color",8]],channels:["r","g","b","a"]},rgb:{fields:[["color",6]],channels:["r","g","b"]},alpha:{fields:[],channels:["a"]},rgba2:{fields:[["light",8],["dark",6]],channels:["r","g","b","a","r2","g2","b2"]},rgb2:{fields:[["light",6],["dark",6]],channels:["r","g","b","r2","g2","b2"]}},$2=["attachment",...Object.keys(fc)],Br=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e),O2=(e,t)=>typeof e==="string"&&e.length===t&&/^[0-9a-fA-F]+$/.test(e);function sM(e,t,n){let s=e.time;if(typeof s!=="number"||!Number.isFinite(s)||s<0)return n.push(`${t}: time is ${JSON.stringify(s)}, not a finite time at or after 0`),null;return s}function rM(e,t,n){if(!Array.isArray(e)||e.length===0)return n.push(`${t}: keys is not a non-empty list`),[];let s=[],r=-1/0;return e.forEach((i,o)=>{let a=`${t}.keys[${o}]`;if(!Br(i)){n.push(`${a} is not an object`);return}let l=sM(i,a,n);if(l===null)return;if(l<=r)n.push(`${a}: time ${i.time} is not after the key before it — the writer refuses key times that do not strictly increase`);r=Math.max(r,l),s.push({raw:i,at:a,time:l})}),s}function ji(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this timeline's keys carry; they carry [${t.join(", ")}]`)}function iM(e,t,n,s,r){let i=e.curve;if(i===void 0)return"linear";if(n)return r.push(`${s}: the last key carries a curve, which eases to no key — the writer refuses it`),"linear";if(i==="stepped")return"stepped";if(!Array.isArray(i)||i.length!==t*4||!i.every((o)=>typeof o==="number"&&Number.isFinite(o)))return r.push(`${s}: curve is ${JSON.stringify(i)}, not "stepped" nor ${t*4} finite numbers (four per channel)`),"linear";return i}function I2(e,t,n,s){let r=rM(t,n,s);return r.map(({raw:i,at:o,time:a},l)=>{if(e==="inherit"){ji(i,["time","inherit"],o,s);let h=typeof i.inherit==="string"?mm(i.inherit):null;if(h===null)s.push(`${o}: inherit is ${JSON.stringify(i.inherit)}, which folds to no inherit mode`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",mode:h??"normal"}}let u=nM[e];ji(i,["time",...u,"curve"],o,s);let c=u.map((h)=>{let d=i[h];if(typeof d!=="number"||!Number.isFinite(d))return s.push(`${o}: ${h} is ${JSON.stringify(d)}, not a finite number — the writer states every channel on every key`),0;return d});return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:iM(i,u.length,l===r.length-1,o,s)}})}function B2(e,t){let n=[];for(let s=0;s{if(e==="attachment"){if(ji(i,["time","name"],o,s),i.name!==null&&(typeof i.name!=="string"||i.name===""))s.push(`${o}: name is ${JSON.stringify(i.name)}, not a placeholder name or null`);return{time:Math.fround(a),values:[],stated:{time:a,values:[]},curve:"stepped",name:typeof i.name==="string"?i.name:null}}let u=fc[e],c=[];if(e==="alpha"){ji(i,["time","value","curve"],o,s);let h=i.value;if(typeof h!=="number"||!Number.isFinite(h))s.push(`${o}: value is ${JSON.stringify(h)}, not a finite number`);else c=[h]}else{ji(i,["time",...u.fields.map(([h])=>h),"curve"],o,s);for(let[h,d]of u.fields){let f=i[h];if(!O2(f,d))s.push(`${o}: ${h} is ${JSON.stringify(f)}, not ${d} hex digits — the one spelling the writer gives a ${e} key's ${h}`);else c.push(...B2(f,h==="dark"||d===6?3:4))}}if(c.length!==u.channels.length)c=u.channels.map(()=>0);return{time:Math.fround(a),values:c.map(Math.fround),stated:{time:a,values:c},curve:iM(i,u.channels.length,l===r.length-1,o,s)}})}function D2(e,t,n){let s=[],r=0,i=(a,l)=>{if(r++,!Array.isArray(a)){n.push(`${l} is not a list of keys`);return}a.forEach((u,c)=>{if(!Br(u))n.push(`${l}[${c}] is not an object`);else{let h=sM(u,`${l}[${c}]`,n);if(h!==null)s.push(Math.fround(h))}})},o=(a,l,u)=>{if(!Array.isArray(a)){n.push(`${l} is not a list`);return}a.forEach((c,h)=>Br(c)?u(c,`${l}[${h}]`):n.push(`${l}[${h}] is not an object`))};if(!Br(e))n.push(`${t} is not an object`);else{for(let a of["ik","transform"])o(e[a],`${t}.${a}`,(l,u)=>i(l.keys,`${u}.keys`));for(let a of["path","physics","slider"])o(e[a],`${t}.${a}`,(l,u)=>o(l.timelines,`${u}.timelines`,(c,h)=>i(c.keys,`${h}.keys`)))}return{timelines:r,times:s}}function N2(e,t,n,s,r,i){let o=typeof e.duration==="number"&&Number.isFinite(e.duration)?e.duration:0;if(typeof e.duration!=="number"||!Number.isFinite(e.duration))r.push(`${t}: duration is ${JSON.stringify(e.duration)}, not a finite number`);let a=new Map(s.map((x)=>[x.name,x])),l=[],u=(x,b,v,_)=>{let S=e[x],k=[];if(!Array.isArray(S))return r.push(`${t}: ${x} is not a list`),k;return S.forEach((w,T)=>{let A=`${t}.${x}[${T}]`;if(!Br(w)||typeof w.name!=="string"){r.push(`${A} names no target`);return}let C=`${A} "${w.name}"`,E=v(w.name);if(E!==null)r.push(`${C}: ${E}`);if(!Array.isArray(w.timelines)){r.push(`${C}: timelines is not a list`);return}let P=w.name,O={name:P,timelines:[]};w.timelines.forEach((B,I)=>{let R=`${C}.timelines[${I}]`;if(!Br(B)||typeof B.name!=="string"){r.push(`${R} names no timeline`);return}let N=b.find((U)=>U===B.name);if(N===void 0){r.push(`${R}: "${B.name}" is not a ${x==="bones"?"bone":"slot"} timeline this core reads; it reads [${b.join(", ")}]`);return}if(O.timelines.some((U)=>U.kind===N))r.push(`${R}: "${N}" is keyed twice on ${P} — the writer merges one property's tracks into one`);let L=_(N,B.keys,`${R} "${N}"`,P);for(let U of L)l.push(U.time);O.timelines.push({kind:N,keys:L})}),k.push(O)}),k},c=u("bones",R2,(x)=>n.has(x)?null:`"${x}" is not a bone of this document`,(x,b,v)=>I2(x,b,v,r)),h=u("slots",$2,(x)=>a.has(x)?null:`"${x}" is not a slot of this document`,(x,b,v,_)=>{if((x==="rgba2"||x==="rgb2")&&a.get(_)?.dark===void 0)r.push(`${v}: slot "${_}" states no dark colour, and a ${x} timeline on such a slot makes the runtime throw while it is applied — the writer refuses it`);return F2(x,b,v,r)}),d=[],f=D2(e.constraints,`${t}.constraints`,r);if(l.push(...f.times),f.timelines>0)d.push(["constraints",f.timelines]);let m=HP(e.attachments,t,i.skins,r),p=eR(e.drawOrder,t,s,r),y=sR(e.events,t,i.events,r);for(let x of m)for(let b of[...x.deform??[],...x.sequence??[]])l.push(b.time);for(let x of[...p,...y])l.push(x.time);let g=m.reduce((x,b)=>x+(b.deform===null?0:1)+(b.sequence===null?0:1),0);if(g>0)d.push(["attachments",g]);if(p.length>0)d.push(["drawOrder",1]);if(y.length>0)d.push(["events",1]);return{declared:o,duration:l.length===0?0:Math.max(...l),bones:c,slots:h,later:d,attachments:m,drawOrder:p,events:y}}var G2=0.16666667,oM=10;function mc(e,t,n,s,r,i,o,a){let l=(d,f,m,p)=>{let y=(d-2*f+m)*0.03,g=((f-m)*3-d+p)*0.006,x=(f-d)*0.3+y+g*G2,b=y*2+g,v=d,_=[];for(let S=1;Sr(e,s,o,t))}function lM(e,t,n){let s=(n.search??ct)(e,t);return s<0?null:e[s]}var Ok=new WeakMap;function L2(e){let t=Ok.get(e);if(t===void 0)t=new Map(e.bones.map((n)=>[n.name,n])),Ok.set(e,t);return t}function U2(e,t,n,s={}){let r=L2(t);return e.bones.map((i)=>{let o=r.get(i.name);if(o===void 0)return i;let a={...i};for(let l of o.timelines){if(l.kind==="inherit"){let d=lM(l.keys,n,s);if(d===null)if(i.inheritMode===void 0)delete a.inheritMode;else a.inheritMode=i.inheritMode;else a.inheritMode=d.mode;continue}let u=aM(l.keys,n,s),c=(d,f)=>{a[d]=(i[d]??0)+(u===null?0:u[f])},h=(d,f)=>{a[d]=(i[d]??1)*(u===null?1:u[f])};switch(l.kind){case"rotate":c("rotation",0);break;case"translate":c("x",0),c("y",1);break;case"translatex":c("x",0);break;case"translatey":c("y",0);break;case"shear":c("shearX",0),c("shearY",1);break;case"shearx":c("shearX",0);break;case"sheary":c("shearY",0);break;case"scale":h("scaleX",0),h("scaleY",1);break;case"scalex":h("scaleX",0);break;case"scaley":h("scaleY",0);break}}return a})}var W2={rotation:0,x:0,y:0,scaleX:1,scaleY:1,shearX:0,shearY:0};class cM{constructor(e,t,n){this.bones=e,this.index=t,this.setup=n}read(e){return this.bones[this.index][e]??W2[e]}write(e,t){if(typeof t!=="number"||!Number.isFinite(t))throw new Y(`the adjustment wrote bone "${this.setup.name}" ${e} = ${String(t)}, not a finite number`);if(this.bones[this.index]===this.setup)this.bones[this.index]={...this.setup};this.bones[this.index][e]=t}get rotation(){return this.read("rotation")}set rotation(e){this.write("rotation",e)}get x(){return this.read("x")}set x(e){this.write("x",e)}get y(){return this.read("y")}set y(e){this.write("y",e)}get scaleX(){return this.read("scaleX")}set scaleX(e){this.write("scaleX",e)}get scaleY(){return this.read("scaleY")}set scaleY(e){this.write("scaleY",e)}get shearX(){return this.read("shearX")}set shearX(e){this.write("shearX",e)}get shearY(){return this.read("shearY")}set shearY(e){this.write("shearY",e)}}function uM(e,t,n,s){let r=new Map,i=e.bones.map((o)=>o.name);n({names:i,bone(o){let a=r.get(o);if(a===void 0){let l=i.indexOf(o);if(l<0)throw new Y(`the adjustment asked for bone ${JSON.stringify(o)}, which is not one of this document's bones`);a=new cM(t,l,e.bones[l]),r.set(o,a)}return a}},s)}var Ik=(e)=>e<0?0:e>1?1:e;function X2(e,t,n,s={},r=[],i){let o=gm(e),a=s.colour??o,l=new Map(t.slots.map((u)=>[u.name,u]));return hM(e,s,r,i,(u,c)=>{let h=u.setup,d=u.color===void 0?pc:a(u.color),f=[d[0],d[1],d[2],d[3]],m=u.dark===void 0?null:o(u.dark),p=m===null?null:[m[0],m[1],m[2]];for(let y of c?l.get(u.name)?.timelines??[]:[]){if(y.kind==="attachment"){let b=lM(y.keys,n,s);h=b===null?u.setup:b.name??null;continue}let g=aM(y.keys,n,s);fc[y.kind].channels.forEach((b,v)=>{let _={r:0,g:1,b:2,a:3,r2:4,g2:5,b2:6}[b];if(_<4)f[_]=g===null?d[_]:Ik(g[v]);else if(p!==null&&m!==null)p[_-4]=g===null?m[_-4]:Ik(g[v])})}return{placeholder:h,light:f,dark:p}})}function hM(e,t,n,s,r){let i=t.shown??Mn,o=t.blend??ym,a=t.round??so,l=[],u=[],c=Dt(e),h=t.slotTimelines??hc;for(let d of e.slots){let f=h(e,d,c),m=r(d,f),p=m.placeholder,{light:y,dark:g}=m;s?.set(d.name,p);let x={placeholder:p,light:y,dark:g};if(f)J1(d.name,x,n);p=x.placeholder;let b=p===null?null:i(e,{...d,setup:p});if(b!==null&&"conflict"in b){u.push(`slot "${d.name}" shows placeholder "${p}", filled by skins ${b.conflict.map((_)=>`"${_.skin}" (shows ${JSON.stringify(_.shown)})`).join(", ")}`);continue}let v=b===null?null:ro(b);l.push([d.name,v===null?null:v.name,a(y[0]),a(y[1]),a(y[2]),a(y[3]),g===null?null:[a(g[0]),a(g[1]),a(g[2])],v===null?null:v.path,o(d)])}return{rows:l,conflicts:u}}function V2(e,t,n,s,r,i,o){return j2(e,t,n,s,r,i,o).world}function j2(e,t,n,s,r,i,o){let a=s.stage;if(a!==void 0)a.begin("timeline");let l=U2(e,t,n,s);if(a!==void 0)a.end("timeline");if(r!==void 0&&o!==void 0)return dM(e,l,s,()=>Bk(e,Ak(eo(e),r,n),t,n,s),r.physicsKeyed??[],n,i,o);let u=Dt(e);if(o?.adjustment!==void 0){if(a!==void 0)a.begin("timeline");if(uM(e,l,o.adjustment.callback,o.adjustment.context),a!==void 0)a.end("timeline")}if(a!==void 0)a.begin("world");let c=(s.evaluate??zi)(l,u);if(a!==void 0)a.end("world");let h=c;if(r!==void 0){if(a!==void 0)a.begin("constraints");let d=eo(e),f=Bk(e,Ak(d,r,n),t,n,s),m=d.some((p)=>p.kind==="path")?ic(e.bones,(s.evaluate??zi)(e.bones,u),u,s.constraints?s.constraints(d):d,null,void 0,void 0,void 0,Zi(s.solver)):null;if(h=ic(l,c,u,s.constraints?s.constraints(f):f,m,i,void 0,void 0,Zi(s.solver)),a!==void 0)a.end("constraints")}for(let d of l)if(h.get(d.name)===void 0)throw new Y(`the evaluator returned no transform for bone "${d.name}"`);return{bones:l,world:h,active:u,round:s.round??so}}function dM(e,t,n,s,r,i,o,a){let l=n.stage,u=Dt(e);if(a.adjustment!==void 0){if(l!==void 0)l.begin("timeline");if(uM(e,t,a.adjustment.callback,a.adjustment.context),l!==void 0)l.end("timeline")}if(l!==void 0)l.begin("world");let c=(n.evaluate??zi)(t,u);if(l!==void 0)l.end("world"),l.begin("constraints");let h=zR(s(),r,i,u,a.ctx,a.before),d=ic(t,c,u,n.constraints?n.constraints(h):h,null,o,a.ctx,void 0,Zi(n.solver));if(l!==void 0)l.end("constraints");for(let f of t)if(d.get(f.name)===void 0)throw new Y(`the evaluator returned no transform for bone "${f.name}"`);return{bones:t,world:d,active:u,round:n.round??so}}function Y2(e,t,n,s,r){return dM(e,t,n,()=>eo(e),[],0,s,r).world}function Bk(e,t,n,s,r){if(n.attachments.every((i)=>i.deform===null))return t;return t.map((i)=>{if(i.kind!=="path"||i.path===null)return i;let o=e.slots.find((h)=>h.name===i.slot),a=o===void 0?null:(r.shown??Mn)(e,o);if(a===null||"conflict"in a)return i;let l=tm(i.slot,a),u=n.attachments.find((h)=>h.deform!==null&&`${h.skin}/${h.slot}/${h.attachment}`===l);if(u===void 0||u.deform===null)return i;let c=(r.deform??em)(i.path.vertices,u.deform,s);return c===null?i:{...i,path:{...i.path,vertices:$1(i.path.vertices,c),exact:!0}}})}var Er="rigc-compiled/3",$f="rigc-compiled/2",Of="rigc-compiled/1",fM=[Er,$f,Of];class Y extends Error{}var mM=["referenceScale","stage","bones","slots","skins","constraints","events","animations","editorOrder","images","pageGrids","droppedStates","absentParts","meshBones","meshes","physics","deformTransforms","trackDerivations","rig","pages","spine"],pM=mM.filter((e)=>e!=="stage"&&e!=="editorOrder"),H2=pM.filter((e)=>e!=="pages"),gM=["name","width","height","pma","scale","regions"],z2=gM.filter((e)=>e!=="pma"&&e!=="scale"),Fk=["x","y","width","height"],Dk=["slot","attachment"],Nk=["name","x","y","width","height","offsetX","offsetY","originalWidth","originalHeight","degrees","index"],q2=["name","parent","length","x","y","rotation","scaleX","scaleY","shearX","shearY","inheritMode","skinRequired","editor"],K2=["length","x","y","rotation","scaleX","scaleY","shearX","shearY"],J2=["name","bone","setup","color","dark","blend"],Z2=["name","bones","constraints","attachments"],Gk={mesh:["kind","name","path","color","uvs","triangles","vertices","hull","edges","width","height","sequence"],boundingbox:["kind","name","vertexCount","vertices","editorColor"],clipping:["kind","name","end","convex","inverse","vertexCount","vertices","editorColor"],path:["kind","name","closed","constantSpeed","vertexCount","vertices","lengths","editorColor"],region:["kind","name","path","x","y","rotation","scaleX","scaleY","width","height","color","sequence","atlas"],linkedmesh:["kind","name","path","source","skin","slot","timelines","width","height","color","sequence"]},yM=new Set(["region","mesh","linkedmesh"]),xM=/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/,bM=["Normal","Additive","Multiply","Screen"];function vM(e){let t=`${e.slice(0,1).toUpperCase()}${e.slice(1)}`;return bM.includes(t)?t:null}var Fr=["ik","transform","path","physics","slider"],_M=["normal","onlyTranslation","noRotationOrReflection","noScale","noScaleOrReflection"],Lk=["width","height","offsetX","offsetY","originalWidth","originalHeight"];function Q2(e,t,n){if(!Array.isArray(e))return t.push(`pages is ${JSON.stringify(e)??"absent"}, not a list of pages`),[];let s=[];return e.forEach((r,i)=>{let o=`pages[${i}]`;if(!We(r)){t.push(`${o} is not an object`);return}let a=t.length,l=typeof r.name==="string"?`${o} "${r.name}"`:o;if(zt(r,n?gM:z2,l,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)??"absent"}, not a non-empty string`);for(let c of["width","height"]){let h=r[c];if(typeof h!=="number"||!Number.isFinite(h)||h<=0)t.push(`${l}: ${c} is ${JSON.stringify(h)??"absent"}, not a positive finite number — a page UV divides by it`)}if(n){if(typeof r.pma!=="boolean")t.push(`${l}: pma is ${JSON.stringify(r.pma)??"absent"}, not true or false — whether the page's texels are premultiplied`);if(r.scale!==null&&(typeof r.scale!=="number"||!Number.isFinite(r.scale)))t.push(`${l}: scale is ${JSON.stringify(r.scale)??"absent"}, not a finite number or null — the number the page's scale: line states, null where it has none`)}let u=[];if(!Array.isArray(r.regions))t.push(`${l}: regions is not a list`);else if(r.regions.length===0)t.push(`${l}: regions is an empty list — a page holds at least one region; the atlas text cannot state a page with none (its block would end before a region line, which A07_ATLAS_TEXT_SHAPE refuses), so no build writes one`);else r.regions.forEach((c,h)=>{let d=`${l}.regions[${h}]`;if(!We(c)){t.push(`${d} is not an object`);return}let f=typeof c.name==="string"?`${d} "${c.name}"`:d;if(zt(c,Nk,f,t),typeof c.name!=="string"||c.name==="")t.push(`${d}: name is ${JSON.stringify(c.name)??"absent"}, not a non-empty string`);for(let m of Nk){if(m==="name")continue;let p=c[m];if(typeof p!=="number"||!Number.isFinite(p))t.push(`${f}: ${m} is ${JSON.stringify(p)??"absent"}, not a finite number`)}u.push(c)});if(t.length===a)s.push(n?{name:r.name,width:r.width,height:r.height,pma:r.pma,scale:r.scale,regions:u}:{name:r.name,width:r.width,height:r.height,regions:u})}),s}function e$(e,t){if(e===void 0)return"";if(!We(e))return t.push(`spine is ${JSON.stringify(e)}, not { "sha256": "<64 lowercase hex digits>" }`),"";for(let s of Object.keys(e))if(s!=="sha256")t.push(`spine: field "${s}" is not one this reader knows; it reads [sha256]`);let n=e.sha256;if(typeof n!=="string"||!/^[0-9a-f]{64}$/.test(n))return t.push(`spine.sha256 is ${JSON.stringify(n)??"absent"}, not 64 lowercase hex digits — the SHA-256 of the skeleton.json written beside the document`),"";return n}function t$(e,t){if(e===null)return null;if(!We(e))return t.push(`stage is ${JSON.stringify(e)??"absent"}, not null or { x, y, width, height } — the setup-pose box the Spine header declares`),null;let n=t.length;zt(e,[...Fk,"box"],"stage",t);for(let i of Fk){let o=e[i];if(typeof o!=="number"||!Number.isFinite(o))t.push(`stage: ${i} is ${JSON.stringify(o)??"absent"}, not a finite number`)}let s=e.box;if(s!==void 0)if(!We(s))t.push(`stage.box is ${JSON.stringify(s)}, not { slot, attachment }`);else{zt(s,Dk,"stage.box",t);for(let i of Dk)if(typeof s[i]!=="string"||s[i]==="")t.push(`stage.box: ${i} is ${JSON.stringify(s[i])??"absent"}, not a non-empty string`)}if(t.length!==n)return null;let r={x:e.x,y:e.y,width:e.width,height:e.height};if(We(s))r.box={slot:s.slot,attachment:s.attachment};return r}function n$(e,t,n,s){let r={skins:[],animations:[]};if(!We(e))return s.push(`editorOrder is ${JSON.stringify(e)??"absent"}, not { skins, animations }`),r;zt(e,["skins","animations"],"editorOrder",s);let i=(l,u)=>{if(!Array.isArray(l)||l.some((c)=>typeof c!=="string"))return s.push(`${u} is ${JSON.stringify(l)??"absent"}, not a list of names`),null;return l},o=(l,u,c,h)=>{let d=new Set;for(let m of l){if(d.has(m))return void s.push(`${c} lists ${h} "${m}" twice`);if(d.add(m),!u.includes(m))return void s.push(`${c} lists ${h} "${m}", which the document does not hold`)}let f=u.find((m)=>!d.has(m));if(f!==void 0)s.push(`${c} leaves out ${h} "${f}"`)};if(!Array.isArray(e.skins))s.push(`editorOrder.skins is ${JSON.stringify(e.skins)??"absent"}, not a list`);else e.skins.forEach((l,u)=>{let c=`editorOrder.skins[${u}]`;if(!We(l)||typeof l.name!=="string")return void s.push(`${c} is not { name, slots }`);zt(l,["name","slots"],c,s);let h=i(l.slots,`${c}.slots`),d=t.find((f)=>f.name===l.name);if(h!==null&&d!==void 0)o(h,Object.keys(d.attachments),`${c}.slots`,"slot key");r.skins.push({name:l.name,slots:h??[]})}),o(r.skins.map((l)=>l.name),t.map((l)=>l.name),"editorOrder.skins","skin");let a=i(e.animations,"editorOrder.animations");if(a!==null)o(a,n.map((l)=>l.name),"editorOrder.animations","animation"),r.animations=a;return r}var We=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);function mm(e){let t=e.length===0?e:e[0].toLowerCase()+e.slice(1);return _M.find((n)=>n===t)??null}function zt(e,t,n,s){for(let r of Object.keys(e))if(!t.includes(r))s.push(`${n}: field "${r}" is not one this reader knows; it reads [${t.join(", ")}]`)}function s$(e,t){if(!Array.isArray(e))return t.push("bones is not a list"),[];let n=[],s=new Set;return e.forEach((r,i)=>{let o=`bones[${i}]`;if(!We(r)){t.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(zt(r,q2,a,t),typeof r.name!=="string"||r.name==="")t.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);else if(s.has(r.name))t.push(`${a}: the name is declared twice`);if(r.parent!==void 0){if(typeof r.parent!=="string")t.push(`${a}: parent is ${JSON.stringify(r.parent)}, not a bone name`);else if(!s.has(r.parent))t.push(`${a}: parent "${r.parent}" is not declared before it; bones are parents first`)}for(let l of K2){let u=r[l];if(u!==void 0&&(typeof u!=="number"||!Number.isFinite(u)))t.push(`${a}: ${l} is ${JSON.stringify(u)}, not a finite number`)}if(r.inheritMode!==void 0){if(typeof r.inheritMode!=="string"||mm(r.inheritMode)===null)t.push(`${a}: inheritMode is ${JSON.stringify(r.inheritMode)}, which folds to none of ${_M.join(", ")}`)}if(r.skinRequired!==void 0&&typeof r.skinRequired!=="boolean")t.push(`${a}: skinRequired is ${JSON.stringify(r.skinRequired)}, not a boolean`);if(r.editor!==void 0)if(!We(r.editor))t.push(`${a}: editor is not an object`);else{zt(r.editor,["color","icon"],`${a}.editor`,t);for(let l of["color","icon"])if(r.editor[l]!==void 0&&typeof r.editor[l]!=="string")t.push(`${a}.editor: ${l} is not a string`)}if(typeof r.name==="string"&&r.name!=="")s.add(r.name);n.push(r)}),n}function r$(e,t,n){if(!Array.isArray(e))return n.push("slots is not a list"),[];let s=[];return e.forEach((r,i)=>{let o=`slots[${i}]`;if(!We(r)){n.push(`${o} is not an object`);return}let a=typeof r.name==="string"?`${o} "${r.name}"`:o;if(zt(r,J2,a,n),typeof r.name!=="string"||r.name==="")n.push(`${o}: name is ${JSON.stringify(r.name)}, not a non-empty string`);if(typeof r.bone!=="string")n.push(`${a}: bone is ${JSON.stringify(r.bone)}, not a bone name`);else if(!t.has(r.bone))n.push(`${a}: bone "${r.bone}" is not a bone of this document`);if(r.setup!==null&&typeof r.setup!=="string")n.push(`${a}: setup is ${JSON.stringify(r.setup)}, not a placeholder name or null`);for(let l of["color","dark","blend"])if(r[l]!==void 0&&typeof r[l]!=="string")n.push(`${a}: ${l} is ${JSON.stringify(r[l])}, not a string`);for(let l of["color","dark"]){let u=r[l];if(typeof u==="string"&&!xM.test(u))n.push(`${a}: ${l} is ${JSON.stringify(u)}, not six or eight hex digits (rrggbb or rrggbbaa) — the only spellings whose reading was measured to be a colour`)}if(typeof r.blend==="string"&&vM(r.blend)===null)n.push(`${a}: blend is ${JSON.stringify(r.blend)}, which the runtime reads as no mode — one of ${bM.join(", ")}, first letter in either case, is the only spelling measured to be one`);s.push(r)}),s}function i$(e,t,n,s,r){let i={};for(let[o,a]of Object.entries(e)){let l=`${s}.attachments["${o}"]`;if(!n.has(o))r.push(`${l}: "${o}" is not a slot of this document`);if(!We(a)){r.push(`${l} is not an object`);continue}let u={};for(let[c,h]of Object.entries(a)){let d=`${l}["${c}"]`;if(!We(h)){r.push(`${d} is not an object`);continue}let f=Object.keys(Gk),m=f.find((g)=>g===h.kind);if(m===void 0){r.push(`${d}: kind is ${JSON.stringify(h.kind)}, none of ${f.join(", ")}`);continue}zt(h,Gk[m],d,r);let p={kind:m};for(let g of["name","path"]){let x=h[g];if(x===void 0)continue;if(typeof x!=="string"||x==="")r.push(`${d}: ${g} is ${JSON.stringify(x)}, not a non-empty string`);else p[g]=x}if(m==="region"&&h.atlas!==void 0){let g=o$(h.atlas,`${d}.atlas`,r);if(g!==void 0)p.atlas=g}let y=vR(h,m,d,t,n,r);if(y!==void 0)p.geometry=y;if(We(h.sequence)){let g=h.sequence.count;if(typeof g==="number"&&Number.isInteger(g)&&g>=1)p.sequenceCount=g;else if(m!=="region")r.push(`${d}.sequence: count is ${JSON.stringify(g)}, not a whole number of at least 1`);let x=h.sequence.setup??0;if(typeof x==="number"&&Number.isInteger(x)&&x>=0&&(typeof g!=="number"||x{let a=`skins[${o}]`;if(!We(i)){s.push(`${a} is not an object`);return}let l=typeof i.name==="string"?`${a} "${i.name}"`:a;if(zt(i,Z2,l,s),typeof i.name!=="string"||i.name==="")s.push(`${a}: name is ${JSON.stringify(i.name)}, not a non-empty string`);let u=[];if(!Array.isArray(i.bones))s.push(`${l}: bones is not a list`);else i.bones.forEach((d,f)=>{if(typeof d!=="string")s.push(`${l}: bones[${f}] is not a bone name`);else if(!t.has(d))s.push(`${l}: bones[${f}] "${d}" is not a bone of this document`);else u.push(d)});let c=Object.fromEntries(Fr.map((d)=>[d,[]]));if(!We(i.constraints))s.push(`${l}: constraints is not an object`);else for(let[d,f]of Object.entries(i.constraints)){let m=Fr.find((p)=>p===d);if(m===void 0)s.push(`${l}.constraints: "${d}" is not a constraint kind; a skin lists ${Fr.join(", ")}`);else if(!Array.isArray(f)||f.some((p)=>typeof p!=="string"))s.push(`${l}.constraints.${d} is not a list of constraint names`);else c[m]=f}let h={};if(!We(i.attachments))s.push(`${l}: attachments is not an object`);else h=i$(i.attachments,t,n,l,s);r.push({name:typeof i.name==="string"?i.name:"",bones:u,constraints:c,attachments:h})}),r}function l$(e,t,n,s,r,i){let o=new Set(n.map((l)=>l.name));if(!Array.isArray(e))return i.push("animations is not a list"),[];let a=[];return e.forEach((l,u)=>{let c=`animations[${u}]`;if(!We(l)){i.push(`${c} is not an object`);return}if(typeof l.name!=="string"||l.name==="")i.push(`${c}: name is ${JSON.stringify(l.name)}, not a non-empty string`);let h=typeof l.name==="string"?`${c} "${l.name}"`:c,d=[];if(!Array.isArray(l.slots))i.push(`${h}: slots is not a list`);else l.slots.forEach((p,y)=>{if(!We(p)||typeof p.name!=="string")i.push(`${h}: slots[${y}] names no slot`);else if(!o.has(p.name))i.push(`${h}: slots[${y}] "${p.name}" is not a slot of this document`);else d.push(p.name)});let f=[],m=(p)=>Array.isArray(p)?p.filter(We):[];for(let p of m(l.attachments))for(let y of m(p.slots))for(let g of m(y.attachments))if(g.deform!==void 0)f.push(`${String(p.name)}/${String(y.name)}/${String(g.name)}`);a.push({name:typeof l.name==="string"?l.name:"",slots:d,timelines:N2(l,h,t,n,i,{skins:s,events:r}),constraints:{ik:[],transform:[],path:[],physics:0,slider:[]},deforms:f})}),a}function c$(e,t,n,s,r,i){let o=new Set(n.map((c)=>c.name)),a=new Map(s.map((c)=>[c.name,c.bone])),l=new Map(n.map((c)=>[c.name,c.parent]));if(!Array.isArray(e))return i.push("constraints is not a list"),[];let u=[];return e.forEach((c,h)=>{let d=`constraints[${h}]`;if(!We(c)){i.push(`${d} is not an object`);return}let f=Fr.find((y)=>y===c.kind);if(f===void 0)i.push(`${d}: kind is ${JSON.stringify(c.kind)}, none of ${Fr.join(", ")}`);if(typeof c.name!=="string"||c.name==="")i.push(`${d}: name is ${JSON.stringify(c.name)}, not a non-empty string`);if(c.declaredIn!=="rig"&&c.declaredIn!=="motion")i.push(`${d}: declaredIn is ${JSON.stringify(c.declaredIn)}, not "rig" or "motion"`);let m=`${d} "${String(c.name)}"`,p;if(typeof c.name==="string"){if(f==="ik"||f==="transform")p=u2(c,f,c.name,m,o,l,i);else if(f==="path")p=CR(c,c.name,m,o,a,i);else if(f==="physics")p=DR(c,c.name,m,o,r,i);else if(f==="slider")p=qR(c,c.name,m,n,t,i)}if(f!==void 0&&typeof c.name==="string")u.push({kind:f,name:c.name,...f==="slider"&&typeof c.animation==="string"?{animation:c.animation}:{},...p!==void 0?{record:p}:{}})}),u}function u$(e,t="the model document"){let n;try{n=JSON.parse(e)}catch(_){throw new Y(`${t}: not JSON — ${_.message}`)}if(!We(n))throw new Y(`${t}: not a JSON object`);if(typeof n.spec!=="string"||!fM.includes(n.spec))throw new Y(`${t}: spec is ${JSON.stringify(n.spec)}, not "${Er}" (or "${$f}", read without its stage, editor order and page flags, or "${Of}", read without its pages too)`);let s=n.spec,r=s===Er?mM:s===$f?pM:H2,i=[];for(let _ of r)if(!(_ in n))i.push(`section "${_}" is missing`);for(let _ of Object.keys(n))if(_!=="spec"&&!r.includes(_))i.push(`section "${_}" is not one a ${s} document has`);let o=s!==Of&&"pages"in n?Q2(n.pages,i,s===Er):null,a=s===Er&&"stage"in n?t$(n.stage,i):null,l=typeof n.referenceScale==="number"&&Number.isFinite(n.referenceScale)?n.referenceScale:NaN;if("referenceScale"in n&&Number.isNaN(l))i.push(`referenceScale is ${JSON.stringify(n.referenceScale)}, not a finite number — wind and gravity act over it`);let u=e$(n.spine,i),c=s$(n.bones,i),h=new Set(c.map((_)=>_.name)),d=r$(n.slots,h,i),f=new Set(d.map((_)=>_.name)),m=a$(n.skins,h,f,i);i.push(...h$(m));let p=nR(n.events,i),y=l$(n.animations,h,d,m,p,i),g=c$(n.constraints,y,c,d,l,i);for(let _ of m)for(let S of Fr)for(let k of _.constraints[S])if(!g.some((w)=>w.kind===S&&w.name===k))i.push(`skin "${_.name}".constraints.${S}: "${k}" is not a ${S} constraint of this document — the runtime refuses the file ("Couldn't find … constraint ${k} for skin ${_.name}.")`);if(Array.isArray(n.animations))n.animations.forEach((_,S)=>{if(We(_)&&y[S]!==void 0)y[S].constraints=d2(_.constraints,`animations[${S}] "${y[S].name}"`,g,i)});for(let _ of g){let S=_.record;if(S?.kind==="slider")S.physics=y.find((k)=>k.name===S.animation)?.constraints.physicsKeyed??[]}let x=s===Er&&"editorOrder"in n?n$(n.editorOrder,m,y,i):null;if(i.length>0)throw new Y(`${t}: ${i.length} problem(s): ${i.join("; ")}`);let v={spec:s,skin:Ps,referenceScale:l,bones:c,slots:d,skins:m,constraints:g,animations:y,spine:{sha256:u},pages:o,stated:x===null?null:{stage:a,editorOrder:x}};return pm(v),v}function If(e,t){if(t!==Ps&&!e.skins.some((s)=>s.name===t))throw new Y(`--skin ${JSON.stringify(t)}: no such skin; this document declares [${e.skins.map((s)=>s.name).join(", ")||"none"}] (or pass ${Ps})`);let n={...e,skin:t,constraints:e.constraints.map((s)=>s.record===void 0?s:{...s,record:{...s.record}})};return pm(n),n}function Uk(e){let t={...e,skin:null,constraints:e.constraints.map((n)=>n.record===void 0?n:{...n,record:{...n.record}})};return pm(t),t}function pm(e){for(let t of e.constraints)if(t.record!==void 0)t.record.listedBySkin=XP(e,t.kind,t.name);for(let t of e.constraints){let n=t.record;if(n?.kind!=="path")continue;n.path=null,n.unresolved=null;let s=e.slots.find((a)=>a.name===n.slot),r=Mn(e,s),i=s.setup===null?[]:Qf(e,s.name,s.setup).flatMap((a)=>{let l=e.skins.find((u)=>u.name===a)?.attachments[s.name]?.[s.setup]?.geometry;return l===void 0?[]:[{skin:a,g:JSON.stringify(l)}]});if(i.length>1&&i.some((a)=>a.g!==i[0].g))n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${i.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&"conflict"in r)n.unresolved=`path constraint "${n.name}" walks slot "${n.slot}", whose placeholder "${s.setup}" skins ${r.conflict.map((a)=>`"${a.skin}"`).join(", ")} fill differently — which one --skin all shows is the Spine file's skin order, not the model's; the per-skin dumps (--skin ) judge it`;else if(r!==null&&r.record.geometry?.kind==="path"){let a=r.record.geometry;n.path={vertices:a.vertices,closed:a.closed,constantSpeed:a.constantSpeed,lengths:a.lengths}}let o=[];for(let a of Zf(e))for(let l of Object.values(a.attachments[n.slot]??{})){let u=l.geometry;if(u?.kind!=="path")continue;for(let c of u.vertices.weighted?u.vertices.bindings.flatMap((h)=>h.map((d)=>d.bone)):[n.slotBone])if(!o.includes(c))o.push(c)}n.slotDeps=o}}function h$(e){let t=[];return e.forEach((n,s)=>{for(let[r,i]of Object.entries(n.attachments))for(let[o,a]of Object.entries(i)){let l=a.geometry;if(l?.kind!=="linkedmesh")continue;let u=SM(e,l.skin,l.slot,l.source);if(u!==null)t.push(`skins[${s}] "${n.name}".attachments["${r}"]["${o}"]: ${u}`)}}),t}function SM(e,t,n,s){let r=e.find((o)=>o.name===t);if(r===void 0)return`the linked mesh's skin "${t}" is not a skin of this document`;let i=r.attachments[n]?.[s];if(i===void 0)return`the linked mesh's source "${s}" is not in skin "${t}" slot "${n}"`;if(i.kind!=="mesh")return`the linked mesh's source "${s}" in skin "${t}" slot "${n}" is a ${i.kind}, not a mesh`;return null}function so(e){if(!Number.isFinite(e))return null;let t=Math.round(e*1e6)/1e6;return t===0?0:t}function Qi(e){if(!Number.isFinite(e))return null;return e===0?0:e}function eo(e){return e.constraints.flatMap((t)=>t.record===void 0?[]:[t.record])}var d$=[],f$=["setup.bones","setup.slots","setup.drawOrder","setup.attachments","setup.clips","setup.clipped"],Wk=new WeakMap;function Dt(e){let t=Wk.get(e);if(t!==void 0)return t;let n=m$(e);return Wk.set(e,n),n}function m$(e){let t=new Set(A1(e).flatMap((r)=>r.bones)),n=new Map(e.bones.map((r)=>[r.name,r.parent])),s=new Set;for(let r of t)for(let i=r;i!==void 0&&!s.has(i);i=n.get(i))s.add(i);return new Set(e.bones.filter((r)=>r.skinRequired!==!0||s.has(r.name)).map((r)=>r.name))}function to(e){let t=(n)=>Number.parseInt(e.slice(2*n,2*n+2),16)/255;return[t(0),t(1),t(2),e.length===8?t(3):1]}var Xk=new WeakMap;function gm(e){let t=Xk.get(e);if(t===void 0)t=new Map,Xk.set(e,t);let n=t;return(s)=>{let r=n.get(s);if(r===void 0)r=to(s),n.set(s,r);return r}}var pc=[1,1,1,1];function ym(e){if(e.blend===void 0)return"Normal";let t=vM(e.blend);if(t===null)throw new Y(`slot "${e.name}": blend ${JSON.stringify(e.blend)} is no mode the runtime reads`);return t}function ro(e){let t=e.record.name??e.placeholder;return{name:t,path:yM.has(e.record.kind)?e.record.path??t:null}}var Vk=new WeakMap;function Mn(e,t,n=t.setup){if(n===null)return null;let s=Vk.get(e);if(s===void 0)s=new Map,Vk.set(e,s);let r=s.get(t.name);if(r===void 0)r=new Map,s.set(t.name,r);if(r.has(n))return r.get(n);let i=p$(e,t.name,n);return r.set(n,i),i}function p$(e,t,n){if(e.skin!==Ps){for(let o of Zf(e)){let a=o.attachments[t]?.[n];if(a!==void 0)return{skin:o.name,placeholder:n,record:a}}return null}let s=[];for(let o of e.skins){let a=o.attachments[t]?.[n];if(a!==void 0)s.push({skin:o.name,placeholder:n,record:a})}if(s.length===0)return null;let r=s.map((o)=>({skin:o.skin,...ro(o)}));return r.every((o)=>o.name===r[0].name&&o.path===r[0].path)?s[0]:{conflict:r.map((o)=>({skin:o.skin,shown:o.name,path:o.path}))}}function xm(e,t={},n){let s=t.evaluate??zi,r=t.shown??Mn,i=t.colour??to,o=t.blend??ym,a=t.round??so,l=dc(e,Zi(t.solver)),u=null,c=null,h=[];if(l===null){let O=Dt(e),B=eo(e);c=ic(e.bones,s(e.bones,O),O,t.constraints?t.constraints(B):B,null,h,n,void 0,Zi(t.solver));let I=c;u=e.bones.map((R)=>{let N=I.get(R.name);if(N===void 0)throw new Y(`the evaluator returned no transform for bone "${R.name}"`);return[R.name,a(N.worldX),a(N.worldY),a(N.a),a(N.b),a(N.c),a(N.d),O.has(R.name)?1:0,R.parent??null]})}let d=[],f=[],m=Dt(e),p=t.slotTimelines??hc;for(let O of e.slots){let B={placeholder:O.setup,light:O.color===void 0?[1,1,1,1]:[...i(O.color)],dark:O.dark===void 0?null:to(O.dark).slice(0,3)};if(p(e,O,m))J1(O.name,B,h);let I={...O,setup:B.placeholder},R=B.placeholder===null?null:r(e,I);if(R!==null&&"conflict"in R){d.push(`slot "${O.name}" placeholder "${B.placeholder}" is filled by skins ${R.conflict.map((X)=>`"${X.skin}" (shows ${JSON.stringify(X.shown)}, path ${JSON.stringify(X.path)})`).join(", ")}`);continue}let N=R===null?null:ro(R),[L,U,J,ee]=B.light,W=B.dark;f.push([O.name,N===null?null:N.name,a(L),a(U),a(J),a(ee),W===null?null:[a(W[0]),a(W[1]),a(W[2])],N===null?null:N.path,o(O)])}let y=(l===null?null:y$(e))??(d.length===0?null:`${d.join("; ")} — under --skin all the LAST of them in the Spine file's skin order wins, and that order is the emitter's (default first, the rest in the editor's order), not the model's; the per-skin dumps (--skin ) judge it`),g=y===null?f:null,x=[l===null?null:`setup.bones is absent (${l}), and every vertex goes through a bone's world matrix`,y===null?null:"setup.slots is absent, so what a slot shows is not posed"].filter((O)=>O!==null),b=l===null?null:g$(e,"drawOrder"),v=null;if(b===null){let O=e.slots.map((B,I)=>I);for(let B of h)O=(t.drawOrder??I1)(e.slots.length,B.timelines.drawOrder,B.at)??O;v=O.map((B)=>e.slots[B].name)}let _=null,S=null,k=x.length===0?null:x.join("; "),w=k,T=null,A=k??b,C=null;if(k===null&&c!==null&&v!==null){let O=c,B=new Map(e.slots.map((J)=>[J.name,J.setup])),I=O1(e,r,B,null,h,t),R=new Map(v.map((J,ee)=>[J,ee])),N=[...I.shown].sort((J,ee)=>(R.get(J.slot)??0)-(R.get(ee.slot)??0));C=I.why.length===0?N:null;let L=H1(N,O,bm(e),a,{region:t.region,vertices:t.vertices},wM(e,v,t)),U=I.why.length===0?null:`${I.why.join("; ")}`;_=U===null?L.attachments:null,w=U??L.attachmentsWhy,S=U===null?L.clips:null,k=U,T=U===null?L.clipped:null,A=U??L.clippedWhy}let E={"setup.bones":l,"setup.slots":y,"setup.drawOrder":b,"setup.attachments":w,"setup.clips":k,"setup.clipped":A},P=d$.map(([O,B])=>[O,B]);for(let O of f$)if(E[O]!==null)P.push([O,E[O]]);return{setup:{bones:u,slots:g,drawOrder:v,attachments:_,clips:S,clipped:T},absent:P,world:c,shown:C}}function wM(e,t,n={}){let s=Dt(e);return{order:t,active:s,meshOf:(r,i,o)=>{let a=e.skins.find((l)=>l.name===r)?.attachments[i]?.[o]?.geometry;return a?.kind==="mesh"?{uvs:a.uvs,triangles:a.triangles}:void 0},...n.clip===void 0?{}:{clip:n.clip},...n.through===void 0?{}:{through:n.through}}}function bm(e){return(t,n,s)=>{let r=e.skins.find((i)=>i.name===t)?.attachments[n]?.[s]?.geometry;return r?.kind==="mesh"?r.vertices:SM(e.skins,t,n,s)??`the linked mesh's source "${s}" carries no vertices`}}function g$(e,t){let n=e.constraints.flatMap((s)=>{if(s.kind!=="slider")return[];let r=e.animations.find((i)=>i.name===s.animation);return r!==void 0&&r.timelines[t].length>0?[`slider "${s.name}" applies animation "${s.animation}", which keys the draw order`]:[]});return n.length===0?null:`${n.join("; ")} — a slider's time is read off the bones, which are absent`}function y$(e){let t=e.constraints.flatMap((n)=>{if(n.kind!=="slider")return[];let s=e.animations.find((r)=>r.name===n.animation)?.slots??[];return s.length===0?[]:[`slider "${n.name}" applies animation "${n.animation}", which keys slot(s) ${s.map((r)=>`"${r}"`).join(", ")}`]});return t.length===0?null:`${t.join("; ")} — the oracle's setup applies sliders, and a slider poses the slots its animation keys at a time read off the bones, which are absent`}function kM(e,t){let n=new Map(t.map((s,r)=>[s,r]));return[...e].sort((s,r)=>(n.get(s.slot)??0)-(n.get(r.slot)??0))}function Bf(e,t){if(e===null)throw new Y(`the raw pose computed a non-finite ${t}`);return e}var Yi={loop:!1,keep:!1},MM=(e)=>e,oc=(e)=>({round:e.keep?MM:Qi});function x$(e,t,n){return n.keep?e===null?Number.NaN:e:Bf(e,t)}var b$=()=>null;function Ff(e,t){let n=Dt(e);return e.bones.map((s)=>{let r=t.get(s.name);if(r===void 0)throw new Y(`bone "${s.name}" has no world transform`);return{name:s.name,parent:s.parent??null,active:n.has(s.name),a:r.a,b:r.b,c:r.c,d:r.d,worldX:r.worldX,worldY:r.worldY,rotationX:Math.atan2(r.c,r.a)*rc,rotationY:Math.atan2(r.d,r.b)*rc,scaleX:Math.sqrt(r.a*r.a+r.c*r.c),scaleY:Math.sqrt(r.b*r.b+r.d*r.d)}})}function v$(e,t,n,s,r,i){let o=wM(e,s,r),a=H1(t,n,bm(e),i.keep?MM:Qi,{region:r.region,vertices:r.vertices,deformedVertices:r.deformedVertices},i.loop&&i.live!==!0&&r.through===void 0?{...o,through:b$}:o);if(a.attachments===null)throw new Y(`the raw pose leaves the attachments out: ${a.attachmentsWhy}`);if(a.drawnClipped===null)throw new Y(`the raw pose leaves the clipped triangles out: ${a.drawnClippedWhy}`);return{rows:a.attachments,clips:a.clips,drawnClipped:a.drawnClipped}}function Bl(e,t,n){return _$(e)?e:e.map((s)=>x$(s,t,n))}function _$(e){for(let t of e)if(t===null)return!1;return!0}function Df(e,t,n,s,r,i=Yi){let o=r.stage;if(o!==void 0)o.begin("geometry");let a=v$(e,t,n,s,r,i);if(o!==void 0)o.end("geometry"),o.begin("readout");let l=a.rows,u=[],c=gm(e),h=0;for(let m of t){let p=m.geometry;if(p.kind!=="region"&&p.kind!=="mesh"&&p.kind!=="linkedmesh")continue;let y=l[h++];if(y===void 0||y[0]!==m.slot)throw new Y(`slot "${m.slot}": the attachment rows are not in the shown records' order`);let g=e.skins.find((w)=>w.name===m.skin)?.attachments[m.slot]?.[m.placeholder],x=g?.color===void 0?pc:c(g.color),b=[x[0],x[1],x[2],x[3]],v,_,S=null;if(p.kind==="region")v=L1,_=sm;else{let w=p.kind==="mesh"?p:e.skins.find((T)=>T.name===p.skin)?.attachments[p.slot]?.[p.source]?.geometry;if(w===void 0||w.kind!=="mesh")throw new Y(`slot "${m.slot}": the linked mesh's source carries no mesh`);({uvs:v,triangles:_}=(r.meshArrays??fR)(w)),S=w.hull??null}let k=m.frame??g?.sequenceSetup??0;u.push({slot:m.slot,attachment:y[1],kind:y[2],vertices:Bl(y[3],`vertex of slot "${m.slot}"`,i),uvs:v,triangles:_,hull:S,sequenceIndex:k,colour:b})}let d=a.clips.map((m)=>[m[0],m[1],m[2],Bl(m[3],`clip vertex of slot "${m[0]}"`,i)]),f=a.drawnClipped.map((m)=>[m[0],m[1],m[2],Bl(m[3],`clipped vertex of slot "${m[0]}"`,i),Bl(m[4],`clipped uv of slot "${m[0]}"`,i),m[5]]);if(o!==void 0)o.end("readout");return{drawn:u,clips:d,clipped:f}}function Jn(e,t={}){return S$(e,t,Yi)}function S$(e,t,n){let{world:s,shown:r,slots:i,drawOrder:o}=w$(e,t,n),a=Df(e,r,s,o,t,n);return{trackTime:0,animationTime:0,bones:Ff(e,s),slots:i,drawOrder:o,...a,events:[],shown:kM(r,o)}}function w$(e,t,n){let s=xm(e,{...t,...oc(n)},cm(t.physicsStep)),r=s.absent.filter(([l])=>l!=="setup.clipped");if(r.length>0)throw new Y(`the raw setup pose leaves ${r.map(([l,u])=>`${l} out (${u})`).join("; ")}`);let{setup:i,world:o,shown:a}=s;if(o===null||a===null||i.slots===null||i.drawOrder===null)throw new Y("the raw setup pose was not posed");return{world:o,shown:a,slots:i.slots,drawOrder:i.drawOrder}}var k$=0.0000000009313225746154785;function Hn(e){return e+e*k$}function TM(e,t){return(n)=>{let s=e(n);if(typeof s!=="number"||!Number.isFinite(s)||s<0)throw new Y(`${t} clock moved the physics by ${String(s)} for a step of ${n}, not a finite time at or above 0`);return s}}function CM(e,t,n){if(typeof t!=="object"||t===null||Array.isArray(t))throw new Y(`${n} setEnvironment was given ${t===null?"null":Array.isArray(t)?"an array":typeof t}, not an object { wind?: [x, y], gravity?: [x, y] }`);let s=t;for(let l of Object.keys(s))if(l!=="wind"&&l!=="gravity")throw new Y(`${n} setEnvironment names "${l}", which is not one of [wind, gravity]`);let r=(l)=>{let u=s[l];if(u===void 0)return;if(!Array.isArray(u)||u.length!==2||u.some((c)=>typeof c!=="number"||!Number.isFinite(c)))throw new Y(`${n} setEnvironment's ${l} is ${JSON.stringify(u)}, not a pair of finite numbers [x, y] (x to the right, y down)`);return Object.freeze([u[0],u[1]])},i=r("wind"),o=r("gravity"),a=e.env??am;e.env=Object.freeze({wind:i??a.wind,gravity:o??a.gravity})}function AM(e){return e.env??am}function ac(e,t,n){if(t===void 0)return;if(!Array.isArray(t))throw new Y(`${n} physics movement scope is ${String(t)}, not an array of physics constraint names`);let s=new Set;for(let r of t){if(typeof r!=="string")throw new Y(`${n} physics movement scope name ${String(r)} is not a string`);let i=e.constraints.find((o)=>o.kind==="physics"&&o.name===r)??e.constraints.find((o)=>o.name===r);if(i===void 0)throw new Y(`${n} physics movement scope: no constraint "${r}"; this document declares [${e.constraints.map((o)=>o.name).join(", ")}]`);if(i.kind!=="physics")throw new Y(`${n} physics movement scope: constraint "${r}" is ${i.kind}, not physics`);s.add(r)}return s}function EM(e,t,n,s,r){for(let[i,o]of[["x",t],["y",n]])if(typeof o!=="number"||!Number.isFinite(o))throw new Y(`${s} physicsTranslate's ${i} is ${String(o)}, not a finite distance in the skeleton's world`);XR(e,t,n,r)}function PM(e,t,n,s,r,i){for(let[o,a]of[["x",t],["y",n],["degrees",s]])if(typeof a!=="number"||!Number.isFinite(a))throw new Y(`${r} physicsRotate's ${o} is ${String(a)}, not a finite number`);VR(e,t,n,s,i)}function M$(e,t){return t===0?0:e%t}var Nf={setup:(e,t,n,s,r,i,o)=>({trackTime:0,animationTime:0,bones:Ff(e,t),slots:n,drawOrder:s,...Df(e,r,t,s,i,o),events:[],shown:kM(r,s)}),step:(e,t,n,s)=>{let r=Df(e,t.shown,t.world,t.drawOrder,n,s),i=n.stage;if(i!==void 0)i.begin("readout");let o=t.events(),a={trackTime:t.trackTime,animationTime:t.animationTime,bones:Ff(e,t.world),slots:t.slots,drawOrder:t.drawOrder,...r,events:o,shown:t.shown};if(i!==void 0)i.end("readout");return a}};function T$(e,t){let n=e.animations.find((s)=>s.name===t);if(n===void 0)throw new Y(`animation "${t}" is not one of this document's [${e.animations.map((s)=>s.name).join(", ")}]`);return n}function C$(e,t,n,s,r,i,o,a){let l=dc(e)??fm(e)??um(e);if(l!==null)throw new Y(`the raw walk leaves the bones out: ${l}`);let u=cm(n.physicsStep);if(a?.(u),r.loop&&r.wrapResets!==!1)u.loop=!0;let c={doc:e,anim:t,duration:t.timelines.duration,mode:r,plant:n,raw:{...n,...oc(r)},resolve:n.shown??Mn,shape:i,ctx:u,adjust:o,trackTime:0,last:-1};if(s==="setup"){let h=xm(e,{...n,...oc(r)},u),d=h.absent.filter(([f])=>f!=="setup.clipped");if(d.length>0)throw new Y(`the raw walk's reset pose leaves ${d.map(([f,m])=>`${f} out (${m})`).join("; ")}`);if(h.world===null||h.shown===null||h.setup.slots===null||h.setup.drawOrder===null)throw new Y("the raw walk's reset pose was not posed");return u.phase="update",{track:c,first:i.setup(e,h.world,h.setup.slots,h.setup.drawOrder,h.shown,n,r)}}return{track:c,first:RM(c,0,!0)}}function RM(e,t,n=!1){let{doc:s,anim:r,duration:i,mode:o,plant:a,raw:l,resolve:u,shape:c,ctx:h,adjust:d}=e;e.trackTime+=t;let{trackTime:f,last:m}=e,p=o.loop?(o.time??M$)(f,i,f-t):fV2(s,r.timelines,p,l,r.constraints,_,{ctx:h,before:y,adjustment:b}),slots:(_,S)=>X2(s,r.timelines,p,l,_,S),drawOrder:r.timelines.drawOrder,at:p,sample:{timelines:r.timelines,t:p},events:()=>o.loop&&o.live!==!0?[]:o.loop?g(x,m,p,Qi,p0)throw new Y(`the raw walk leaves the slots out: ${m.conflicts.join("; ")}`);let p=t.drawOrder??I1,g=p(e.slots.length,u.drawOrder,u.at)??e.slots.map((k,w)=>w);for(let k of h)g=p(e.slots.length,k.timelines.drawOrder,k.at)??g;let x=g.map((k)=>e.slots[k].name);if(c!==void 0)c.end("readout"),c.begin("timeline");let b=O1(e,n,f,u.sample,h,t,u.mixed);if(c!==void 0)c.end("timeline");if(b.why.length>0)throw new Y(`the raw walk leaves the attachments out: ${b.why.join("; ")}`);if(c!==void 0)c.begin("readout");let v=new Map(x.map((k,w)=>[k,w])),_=[...b.shown].sort((k,w)=>(v.get(k.slot)??0)-(v.get(w.slot)??0));if(c!==void 0)c.end("readout");let S=()=>u.events().map((k)=>[k[0],Bf(k[1],"event time"),k[2],Bf(k[3],"event float"),k[4]]);return s.step(e,{trackTime:a,animationTime:l,world:d,slots:m.rows,drawOrder:x,shown:_,events:S},t,r)}function A$(e,t){let n=dc(e)??fm(e)??um(e);if(n!==null)throw new Y(`the raw walk leaves the bones out: ${n}`);let s=cm(t.physicsStep),r={...t,...oc(Yi)},i=t.shown??Mn;return{ctx:s,raw:r,setupPose:()=>{let o=xm(e,r,s),a=o.absent.filter(([l])=>l!=="setup.clipped");if(a.length>0)throw new Y(`the raw walk's reset pose leaves ${a.map(([l,u])=>`${l} out (${u})`).join("; ")}`);if(o.world===null||o.shown===null||o.setup.slots===null||o.setup.drawOrder===null)throw new Y("the raw walk's reset pose was not posed");return s.phase="update",Nf.setup(e,o.world,o.setup.slots,o.setup.drawOrder,o.shown,t,Yi)},step:(o,a,l,u)=>$M(e,t,i,Nf,Yi,s,o,a,l,u)}}function E$(e,t,n,s,r,i,o){return C$(e,T$(e,t),n,s,r,Nf,i,o)}function P$(e,t){return RM(e,t)}var cf=["strength","damping","inertia","wind","gravity","mix"],R$=(e)=>({strength:e.strength,damping:e.damping,inertia:e.inertia,wind:e.wind,gravity:e.gravity,mix:e.mix});class vm{constructor(e){this.doc=e,this.overrides=new Map,this.evaluated=new Map}named(e){let t=this.doc.constraints.find((n)=>n.name===e);if(t===void 0)throw new Y(`physics parameters: no constraint "${String(e)}"; this document declares [${this.doc.constraints.map((n)=>n.name).join(", ")}]`);if(t.kind!=="physics")throw new Y(`physics parameters: constraint "${e}" is ${t.kind}, not physics`)}set(e,t){if(this.named(e),typeof t!=="object"||t===null||Array.isArray(t))throw new Y(`physics parameters: constraint "${e}" patch is ${String(t)}, not an object of finite fields [${cf.join(", ")}]`);let n={};for(let s of Reflect.ownKeys(t)){if(typeof s!=="string"||!cf.includes(s))throw new Y(`physics parameters: constraint "${e}" field "${String(s)}" is unknown; expected [${cf.join(", ")}]`);let r=s,i=t[r];if(typeof i!=="number"||!Number.isFinite(i))throw new Y(`physics parameters: constraint "${e}" field "${r}" is ${String(i)}, not a finite number`);n[r]=i}if(Reflect.ownKeys(n).length>0)this.overrides.set(e,{...this.overrides.get(e),...n})}read(e){this.named(e);let t=this.overrides.get(e),n=this.evaluated.get(e);return{override:t===void 0?null:{...t},effective:n===void 0?null:{...n}}}clear(e){this.named(e),this.overrides.delete(e)}apply(e){let t=this.overrides.get(e.name),n=t===void 0?e:{...e,...t};return this.evaluated.set(e.name,R$(n)),n}}var $$={loop:!1,keep:!1},O$={loop:!0,keep:!1,live:!0};function Li(e,t,n,s={}){if(typeof n!=="object"||n===null||typeof n.loop!=="boolean")throw new Y(`the live track's options.loop is ${JSON.stringify(n?.loop)}, not true or false`);if(n.reset!=="animation"&&n.reset!=="setup")throw new Y(`the live track's options.reset is ${JSON.stringify(n.reset)}, not "animation" or "setup"`);if(n.adjust!==void 0&&typeof n.adjust!=="function")throw new Y(`the live track's options.adjust is ${typeof n.adjust}, not a function`);if(n.clock!==void 0&&typeof n.clock!=="function")throw new Y(`the live track's options.clock is ${typeof n.clock}, not a function`);let r=n.loop?O$:$$,i=n.clock===void 0?void 0:TM(n.clock,"the live track's"),o=new vm(e),{track:a,first:l}=E$(e,t,s,n.reset,i===void 0?r:{...r,clock:(u)=>i(u)},n.adjust,(u)=>{u.parameters=o});return new OM(a,l,o)}class OM{constructor(e,t,n){this.parameters=n,this.steps=0,this.refused=null,this.track=e,this.first=t,this.latest=t.animationTime}get trackTime(){return this.track.trackTime}get animationTime(){return this.latest}get duration(){return this.track.duration}get environment(){return AM(this.track.ctx)}setEnvironment(e){this.live("setEnvironment"),CM(this.track.ctx,e,"the live track's")}setPhysicsParameters(e,t){this.live("setPhysicsParameters"),this.parameters.set(e,t)}readPhysicsParameters(e){return this.parameters.read(e)}clearPhysicsParameters(e){this.live("clearPhysicsParameters"),this.parameters.clear(e)}physicsTranslate(e,t,n){this.live("physicsTranslate"),EM(this.track.ctx,e,t,"the live track's",ac(this.track.doc,n,"the live track's"))}physicsRotate(e,t,n,s){this.live("physicsRotate"),PM(this.track.ctx,e,t,n,"the live track's",ac(this.track.doc,s,"the live track's"))}live(e){if(this.refused!==null)throw new Y(`the live track was refused at step ${this.refused}, after its time and physics had moved; open the track again (${e} not made)`)}step(e){let t=this.steps+1;if(this.refused!==null)throw new Y(`the live track was refused at step ${this.refused}, after its time and physics had moved; open the track again`);if(typeof e!=="number"||!Number.isFinite(e)||e<0)throw new Y(`the live track's step ${t} is ${String(e)}, not a finite time at or above 0`);try{let n=P$(this.track,e);return this.steps=t,this.latest=n.animationTime,n}catch(n){throw this.refused=`${t} (${n instanceof Error?n.message:String(n)})`,n}}}var Ms=0,Fe=1,kn=2,jk=3,Fl=4,Yk={name:null,duration:0,timelines:[],ids:new Set};function uf(e){return e.type==="deform"||e.type==="bone"&&e.kind!=="inherit"}var I$={rotate:["rotate"],translate:["x","y"],translatex:["x"],translatey:["y"],scale:["scaleX","scaleY"],scalex:["scaleX"],scaley:["scaleY"],shear:["shearX","shearY"],shearx:["shearX"],sheary:["shearY"],inherit:["inherit"]},B$={rgba:["rgb","alpha"],rgb:["rgb"],alpha:["alpha"],rgba2:["rgb","alpha","rgb2"],rgb2:["rgb","rgb2"]};function F$(e,t){let n=e.animations.find((u)=>u.name===t);if(n===void 0)throw new Y(`animation "${t}" is not one of this document's [${e.animations.map((u)=>u.name).join(", ")}]`);let{timelines:s,constraints:r}=n,i=[];for(let[u,c]of[["ik",r.ik.length],["transform",r.transform.length],["path",r.path.length],["physics",r.physics+(r.physicsKeyed?.length??0)],["slider",r.slider.length]])if(c>0)i.push(`${u} constraint timelines`);if(s.attachments.some((u)=>u.sequence!==null))i.push("a sequence timeline");if(s.drawOrder.length>0)i.push("the draw order");for(let u of s.attachments){if(u.deform===null)continue;if(e.skins.find((h)=>h.name===u.skin)?.attachments[u.slot]?.[u.attachment]?.geometry?.kind==="path")i.push(`a deform of path attachment "${u.skin}/${u.slot}/${u.attachment}"`)}if(i.length>0)throw new Y(`animation "${t}" keys ${i.join(", ")}, which the live tracks do not mix — they mix bone, slot colour, attachment and deform timelines, and fire events (issue #1336)`);let o=new Map(e.bones.map((u,c)=>[u.name,c])),a=new Map(e.slots.map((u,c)=>[u.name,c])),l=[];for(let u of s.slots){let c=a.get(u.name);for(let h of u.timelines)if(h.kind==="attachment")l.push({type:"attachment",slot:c,keys:h.keys,ids:[`attachment|${u.name}`],instant:!0});else l.push({type:"colour",slot:c,kind:h.kind,keys:h.keys,ids:B$[h.kind].map((d)=>`${d}|${u.name}`),instant:!1})}for(let u of s.bones){let c=o.get(u.name);for(let h of u.timelines)l.push({type:"bone",bone:c,kind:h.kind,keys:h.keys,ids:I$[h.kind].map((d)=>`${d}|${u.name}`),instant:h.kind==="inherit"})}for(let u of s.attachments){if(u.deform===null)continue;let c=`${u.skin}/${u.slot}/${u.attachment}`;l.push({type:"deform",identity:c,timeline:u,ids:[`deform|${u.slot}|${c}`],instant:!1})}if(s.events.length>0)l.push({type:"events",keys:s.events,ids:["event"],instant:!0});return{name:t,duration:s.duration,timelines:l,ids:new Set(l.flatMap((u)=>u.ids))}}function Hk(e,t){return{anim:e,loop:t,previous:null,next:null,mixingFrom:null,mixingTo:null,delay:0,trackTime:0,trackLast:-1,nextTrackLast:-1,trackEnd:Number.MAX_VALUE,animationLast:-1,nextAnimationLast:-1,mixTime:0,mixDuration:0,totalAlpha:0,alpha:1,additive:!1,keepHold:!1,timelineMode:[],timelineHoldMix:[],timelinesRotation:[]}}function Gf(e){if(!e.loop)return Math.min(e.trackTime+0,e.anim.duration);let t=e.anim.duration;if(t===0)return 0;return e.trackTime%t+0}function D$(e){let t=e.anim.duration;if(t!==0){if(e.loop)return t*(1+(e.trackTime/t|0));if(e.trackTimee>0?1:e<0?-1:0,Wi=(e)=>e<0?0:e>1?1:e,N$=[0,0,0],G$=0,zk=1,qk=2;class IM{constructor(e,t){this.doc=e,this.plant=t,this.events=[],this.resolved=new Map,this.bones=[...e.bones],this.active=Dt(e);let n=gm(e);this.stated=n;let s=t.colour??n,r=t.slotTimelines??hc;this.live=e.slots.map((i)=>r(e,i,this.active)),this.slots=e.slots.map((i)=>{let o=i.dark===void 0?null:n(i.dark),a=i.color===void 0?pc:s(i.color);return{placeholder:i.setup,light:[a[0],a[1],a[2],a[3]],dark:o===null?null:[o[0],o[1],o[2]],deform:null,seen:[],attachmentState:G$}})}bone(e){let t=this.bones[e];if(!this.active.has(t.name))return null;if(t===this.doc.bones[e])this.bones[e]={...t};return this.bones[e]}slotLive(e){return this.live[e]}resolve(e,t){if(t===null)return{key:null,vertex:!1,timeline:null,vertices:null};let n=this.doc.slots[e],s=`${e}\x00${t}`,r=this.resolved.get(s);if(r!==void 0)return r;let i=(this.plant.shown??Mn)(this.doc,{...n,setup:t}),o;if(i===null)o={key:null,vertex:!1,timeline:null,vertices:null};else if("conflict"in i)o={key:`conflict\x00${t}`,vertex:!1,timeline:null,vertices:null};else o=L$(this.doc,n,i);return this.resolved.set(s,o),o}setAttachment(e,t){let n=this.slots[e],s=this.resolve(e,n.placeholder),r=this.resolve(e,t);if(n.placeholder=t,s.key===r.key)return;if(!r.vertex||!s.vertex||r.timeline!==s.timeline)n.deform=null}}function L$(e,t,n){let s=n.record.geometry,r=`${n.skin}\x00${n.placeholder}`;if(s===void 0||s.kind==="region")return{key:r,vertex:!1,timeline:null,vertices:null};if(s.kind==="linkedmesh"){let i=e.skins.find((a)=>a.name===s.skin)?.attachments[s.slot]?.[s.source]?.geometry,o=i!==void 0&&i.kind!=="region"&&i.kind!=="linkedmesh"?i.vertices:null;return{key:r,vertex:!0,timeline:n.record.timelines===!0?`${s.skin}/${s.slot}/${s.source}`:`${n.skin}/${t.name}/${n.placeholder}`,vertices:o}}return{key:r,vertex:!0,timeline:`${n.skin}/${t.name}/${n.placeholder}`,vertices:s.vertices}}class BM{constructor(e,t){this.doc=e,this.plant=t,this.tracks=[],this.animationsChanged=!1,this.propertyIds=new Map,this.anims=new Map}animation(e){let t=this.anims.get(e);if(t===void 0)t=F$(this.doc,e),this.anims.set(e,t);return t}changed(){this.animationsChanged=!0}expandToIndex(e){while(this.tracks.length<=e)this.tracks.push(null);return this.tracks[e]}clearNext(e){e.next=null}setTrack(e,t){let n=this.expandToIndex(e);if(this.tracks[e]=t,t.previous=null,n!==null)n.next=null,t.mixingFrom=n,n.mixingTo=t,t.mixTime=0,n.timelinesRotation.length=0;this.changed()}setAnimation(e,t,n){let s=this.expandToIndex(e);if(s!==null)if(s.nextTrackLast===-1&&s.anim===t)this.tracks[e]=s.mixingFrom,this.changed(),this.clearNext(s),s=s.mixingFrom;else this.clearNext(s);let r=Hk(t,n);return this.setTrack(e,r),r}addAnimation(e,t,n,s){let r=this.expandToIndex(e);if(r!==null)while(r.next!==null)r=r.next;let i=Hk(t,n);if(r===null){if(this.setTrack(e,i),s<0)s=0}else if(r.next=i,i.previous=r,s<=0)s=Math.max(s+this.complete(r)-i.mixDuration,0);return i.delay=s,i}setMixDuration(e,t,n){if(e.mixDuration=t,n<=0)n=e.previous===null?0:Math.max(n+this.complete(e.previous)-t,0);e.delay=n}complete(e){return this.plant.queueDelayNow===!0?e.trackTime:D$(e)}mixOf(e){let t;if(e.mixDuration===0)t=1;else if(t=e.mixTime/e.mixDuration,t>=1)t=1;return this.plant.mixReversed===!0?1-t:t}alphaOf(e){if(this.plant.alphaIgnored===!0)return 1;return this.plant.alphaInverted===!0?1-e.alpha:e.alpha}additiveOf(e){return e.additive&&this.plant.additiveAsReplace!==!0}holdsAdditive(e){return e!==null&&this.additiveOf(e)&&this.plant.additiveHeld!==!0}update(e){let t=this.tracks;for(let n=0,s=t.length;n0){if(r.delay-=i,r.delay>0)continue;i=-r.delay,r.delay=0}let o=r.next;if(o!==null){let a=r.trackLast-o.delay;if(a>=0){o.delay=0,o.trackTime+=a+e,r.trackTime+=i,this.setTrack(n,o);while(o.mixingFrom!==null)o.mixTime+=e,o=o.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&r.mixingFrom===null){t[n]=null,this.changed(),this.clearNext(r);continue}if(r.mixingFrom!==null&&this.updateMixingFrom(r,e)){let a=r.mixingFrom;if(r.mixingFrom=null,a!==null)a.mixingTo=null;this.changed()}r.trackTime+=i}}updateMixingFrom(e,t){let n=e.mixingFrom;if(n===null)return!0;let s=this.updateMixingFrom(n,t);if(n.animationLast=n.nextAnimationLast,n.trackLast=n.nextTrackLast,e.nextTrackLast!==-1&&e.mixTime>=e.mixDuration){if(n.totalAlpha===0||e.mixDuration===0){if(e.mixingFrom=n.mixingFrom,n.mixingFrom!==null)n.mixingFrom.mixingTo=e;if(n.totalAlpha===0)for(let r=e;r.mixingTo!==null;r=r.mixingTo)r.keepHold=!0;this.changed()}return s}return n.trackTime+=t,e.mixTime+=t,!1}apply(e){if(this.animationsChanged)this.computeModes();let t=0,n=this.tracks;for(let s=0,r=n.length;s0)continue;let o=this.alphaOf(i);if(i.mixingFrom!==null)o*=this.applyMixingFrom(i,e,s);else if(i.trackTime>=i.trackEnd&&i.next===null)o=0;let a=i.animationLast,l=Gf(i),u=i.anim.timelines,c=u.length;if(s===0&&o===1)for(let h of u)if(h.type==="attachment")this.applyAttachment(e,h,l,Fe,!0);else this.applyTimeline(e,h,a,l,!0,1,Fe,!1,!1);else{let h=i.timelineMode,d=this.plant.attachmentsBelowHalfAlpha===!0?o>=0.5:o>=0,f=this.additiveOf(i),m=f&&this.plant.additiveRotateRemembered!==!0,p=!m&&i.timelinesRotation.length!==c<<1;if(p)i.timelinesRotation.length=c<<1;u.forEach((y,g)=>{let x=this.fromOf(h[g]&jk,s);if(!m&&y.type==="bone"&&y.kind==="rotate")this.applyRotate(e,y,l,o,x,i.timelinesRotation,g<<1,p);else if(y.type==="attachment")if(f&&this.plant.additiveAttachmentsDirect===!0)this.applyAttachmentDirect(e,y,l,x,!1);else this.applyAttachment(e,y,l,x,d);else this.applyTimeline(e,y,a,l,!0,o,x,!1,f)})}if(s===0)t=l;i.nextAnimationLast=l,i.nextTrackLast=i.trackTime}return e.slots.forEach((s,r)=>{if(s.attachmentState===zk)e.setAttachment(r,this.doc.slots[r].setup)}),t}fromOf(e,t){return this.plant.higherTracksFromSetup===!0&&t>0&&e===Ms?Fe:e}applyMixingFrom(e,t,n){let s=e.mixingFrom,r=s.mixingFrom!==null?this.applyMixingFrom(s,t,n):1,i=this.mixOf(e),o=this.alphaOf(s)*r,a=1-i*(this.plant.holdIgnoresEntryAlpha===!0?1:this.alphaOf(e)),l=o*(1-i),u=a>0?l/a:o,c=s.anim.timelines,h=c.length,{timelineMode:d,timelineHoldMix:f}=s,m=this.additiveOf(s),p=m&&this.plant.additiveRotateRemembered!==!0,y=!p&&s.timelinesRotation.length!==h<<1;if(y)s.timelinesRotation.length=h<<1;let g=s.animationLast,x=Gf(s),b=this.plant.eventsUntilHalfMix===!0&&i<0.5;return s.totalAlpha=0,c.forEach((v,_)=>{let S=d[_],k=this.fromOf(S&jk,n),w;if((S&Fl)!==0&&this.plant.holdFaded!==!0){let T=f[_];w=T===null||T===void 0?u:u*(1-this.mixOf(T))}else w=l;if(s.totalAlpha+=w,!p&&v.type==="bone"&&v.kind==="rotate")this.applyRotate(t,v,x,w,k,s.timelinesRotation,_<<1,y);else if(v.type==="attachment")if(m&&this.plant.additiveAttachmentsDirect===!0)this.applyAttachmentDirect(t,v,x,k,!0);else this.applyAttachment(t,v,x,k,!1);else this.applyTimeline(t,v,g,x,b,w,k,!0,m)}),s.nextAnimationLast=x,s.nextTrackLast=s.trackTime,i}computeModes(){this.animationsChanged=!1,this.tracks.forEach((e,t)=>{if(e===null)return;let n=e;while(n.mixingFrom!==null)n=n.mixingFrom;do this.computeHold(n,t),n=n.mixingTo;while(n!==null)}),this.propertyIds.clear()}computeHold(e,t){let n=e.anim.timelines,s=e.timelineMode;s.length=n.length;let r=e.timelineHoldMix;r.length=0;let i=e.mixingTo,o=this.holdsAdditive(e),a=this.holdsAdditive(i);n.forEach((l,u)=>{let c=this.propertyFrom(t,l.ids);if(o&&uf(l)){s[u]=c;return}let h;if(i===null||l.instant||a&&uf(l)||!Jk(i.anim,l.ids))h=c;else{h=c|Fl;for(let d=i.mixingTo;d!==null;d=d.mixingTo)if(this.holdsAdditive(d)&&uf(l)||!Jk(d.anim,l.ids)){if(d.mixDuration>0)r[u]=d;break}}if(e.keepHold)h=h&~Fl|(s[u]??0)&Fl;s[u]=h})}propertyFrom(e,t){let n=this.propertyIds,s=Fe;for(let r=0,i=t.length;rs(e,n,i,t))}applyTimeline(e,t,n,s,r,i,o,a,l){switch(t.type){case"bone":return this.applyBone(e,t,s,i,o,a,l);case"colour":return this.applyColour(e,t,s,i,o);case"deform":return this.applyDeform(e,t,s,i,o,l);case"events":if(r)e.events.push(...nm(t.keys,n,s,Qi,s{if(l.inheritMode===void 0)delete a.inheritMode;else a.inheritMode=l.inheritMode};if(i){if(r!==Ms)f();return}let m=(this.plant.search??ct)(t.keys,n);if(m<0){if(r!==Ms)f()}else a.inheritMode=t.keys[m].mode;return}let u=this.values(t.keys,n),c=(f,m)=>{let p=l[f]??0,y=a[f]??0;a[f]=u===null?Kk(r,s,y,p):r===Fe?p+u[m]*s:y+(o?u[m]:u[m]+p-y)*s},h=(f,m)=>{let p=l[f]??0,y=l[m]??0;if(u===null){if(r===Fe)a[f]=p,a[m]=y;else if(r===kn)a[f]=(a[f]??0)+(p-(a[f]??0))*s,a[m]=(a[m]??0)+(y-(a[m]??0))*s;return}if(r===Fe)a[f]=p+u[0]*s,a[m]=y+u[1]*s;else if(o)a[f]=(a[f]??0)+u[0]*s,a[m]=(a[m]??0)+u[1]*s;else a[f]=(a[f]??0)+(p+u[0]-(a[f]??0))*s,a[m]=(a[m]??0)+(y+u[1]-(a[m]??0))*s},d=(f,m)=>{let p=l[f]??1,y=a[f]??1;a[f]=u===null?Kk(r,s,y,p):hf(u[m]*p,s,r,i,o,y,p)};switch(t.kind){case"rotate":c("rotation",0);break;case"translate":h("x","y");break;case"translatex":c("x",0);break;case"translatey":c("y",0);break;case"shear":h("shearX","shearY");break;case"shearx":c("shearX",0);break;case"sheary":c("shearY",0);break;case"scale":if(u===null){let f=l.scaleX??1,m=l.scaleY??1;if(r===Fe)a.scaleX=f,a.scaleY=m;else if(r===kn)a.scaleX=(a.scaleX??1)+(f-(a.scaleX??1))*s,a.scaleY=(a.scaleY??1)+(m-(a.scaleY??1))*s}else a.scaleX=hf(u[0]*(l.scaleX??1),s,r,i,o,a.scaleX??1,l.scaleX??1),a.scaleY=hf(u[1]*(l.scaleY??1),s,r,i,o,a.scaleY??1,l.scaleY??1);break;case"scalex":d("scaleX",0);break;case"scaley":d("scaleY",0);break}}applyRotate(e,t,n,s,r,i,o,a){if(a)i[o]=0;if(s===1){this.applyBone(e,t,n,1,r,!1,!1);return}let l=e.bone(t.bone);if(l===null)return;let u=this.doc.bones[t.bone].rotation??0,c=this.values(t.keys,n),h,d;if(c===null){if(r===Fe){l.rotation=u;return}if(r===Ms)return;h=l.rotation??0,d=u}else h=r===Fe?u:l.rotation??0,d=u+c[0];let f,m=d-h;if(m-=Math.ceil(m/360-0.5)*360,m===0)f=i[o];else{let p,y;if(a)p=0,y=m;else p=i[o],y=i[o+1]??Number.NaN;let g=p-p%360;f=m+g;let x=m>=0,b=p>=0;if(Math.abs(y)<=90&&Ui(y)!==Ui(m))if(Math.abs(p-g)>180)f+=360*Ui(p),b=x;else if(g!==0)f-=360*Ui(p);else b=x;if(b!==x)f+=360*Ui(p);i[o]=f}i[o+1]=m,l.rotation=h+f*s}applyAttachment(e,t,n,s,r){if(!e.slotLive(t.slot))return;let i=e.slots[t.slot];if(!r&&i.attachmentState===qk)return;let o=(this.plant.search??ct)(t.keys,n),a=o<0,l=null;if(!a)l=t.keys[o].name??null,a=!r&&l===null;if(a){if(s===Ms)return;l=this.doc.slots[t.slot].setup}if(e.setAttachment(t.slot,l),r)i.attachmentState=qk;else if(!a)i.attachmentState=zk}applyAttachmentDirect(e,t,n,s,r){if(!e.slotLive(t.slot))return;let i=(this.plant.search??ct)(t.keys,n);if(r||i<0){if(s!==Ms)e.setAttachment(t.slot,this.doc.slots[t.slot].setup)}else e.setAttachment(t.slot,t.keys[i].name??null)}applyColour(e,t,n,s,r){if(!e.slotLive(t.slot))return;let i=this.doc.slots[t.slot],o=e.slots[t.slot],{light:a,dark:l}=o,u=i.color===void 0?pc:(this.plant.colour??e.stated)(i.color),c=i.dark===void 0?N$:e.stated(i.dark),h=()=>{for(let m=0;m<4;m++)a[m]=Wi(a[m])},d=this.values(t.keys,n),f=fc[t.kind].channels.length;switch(t.kind){case"rgba":{if(d===null){if(r===Fe)for(let m=0;m<4;m++)a[m]=u[m];else if(r===kn){for(let m=0;m<4;m++)a[m]+=(u[m]-a[m])*s;h()}return}if(s===1)for(let m=0;m<4;m++)a[m]=d[m];else if(r===Fe)for(let m=0;m<4;m++)a[m]=u[m]+(d[m]-u[m])*s;else for(let m=0;m<4;m++)a[m]+=(d[m]-a[m])*s;h();return}case"rgb":{if(d===null){if(r===Fe)for(let p=0;p<3;p++)a[p]=u[p];else if(r===kn)for(let p=0;p<3;p++)a[p]+=(u[p]-a[p])*s;return}let m=[d[0],d[1],d[2]];if(s!==1)for(let p=0;p<3;p++)m[p]=r===Fe?u[p]+(m[p]-u[p])*s:a[p]+(m[p]-a[p])*s;for(let p=0;p<3;p++)a[p]=Wi(m[p]);return}case"alpha":{if(d===null){if(r===Fe)a[3]=u[3];else if(r===kn)a[3]+=(u[3]-a[3])*s;return}let m=d[0];if(s!==1)m=r===Fe?u[3]+(m-u[3])*s:a[3]+(m-a[3])*s;a[3]=Wi(m);return}case"rgba2":case"rgb2":{if(l===null)return;let m=t.kind==="rgba2",p=m?4:3;if(d===null){if(r===Fe){for(let x=0;x{if(!e.slotLive(l))return;let u=e.resolve(l,a.placeholder);if(!u.vertex||u.timeline!==t.identity||u.vertices===null)return;let c=u.vertices;if(!a.seen.includes(t.identity))a.seen.push(t.identity);let h=(this.plant.deform??em)(c,o,n),d=r;if(a.deform===null)d=Fe;if(h===null){if(d===Fe)a.deform=null;else if(d===kn){if(s===1){a.deform=null;return}let m=a.deform;if(!c.weighted){let p=Pr(c);a.deform=m.map((y,g)=>y+(p[g]-y)*s)}else{let p=1-s;a.deform=m.map((y)=>y*p)}}return}let f=d===Fe;if(s===1)if(i&&!f){let m=a.deform;if(!c.weighted){let p=Pr(c);a.deform=m.map((y,g)=>y+(h[g]-p[g]))}else a.deform=m.map((p,y)=>p+h[y])}else a.deform=[...h];else if(f)if(!c.weighted){let m=Pr(c);a.deform=h.map((p,y)=>m[y]+(p-m[y])*s)}else a.deform=h.map((m)=>m*s);else if(i){let m=a.deform;if(!c.weighted){let p=Pr(c);a.deform=m.map((y,g)=>y+(h[g]-p[g])*s)}else a.deform=m.map((p,y)=>p+h[y]*s)}else{let m=a.deform;a.deform=m.map((p,y)=>p+(h[y]-p)*s)}})}}function Kk(e,t,n,s){if(e===Fe)return s;if(e===kn)return n+(s-n)*t;return n}function hf(e,t,n,s,r,i,o){if(t===1&&!r)return e;let a=n===Fe?o:i;if(r)return a+(e-o)*t;if(s)return a+(Math.abs(e)*Math.sign(a)-a)*t;return a=Math.abs(a)*Math.sign(e),a+(e-a)*t}function Jk(e,t){for(let n of t)if(e.ids.has(n))return!0;return!1}function Mr(e,t){if(typeof e!=="number"||!Number.isInteger(e)||e<0)throw new Y(`the live tracks' ${t} names track ${String(e)}, not a whole number at or above 0`);return e}function Dl(e,t,n){if(typeof e!=="number"||!Number.isFinite(e)||e<0)throw new Y(`the live tracks' ${n} ${t} is ${String(e)}, not a finite time at or above 0`);return e}function Zk(e,t){if(typeof e!=="object"||e===null||typeof e.loop!=="boolean")throw new Y(`the live tracks' ${t} options.loop is ${JSON.stringify(e?.loop)}, not true or false`);return e.loop}function FM(e,t,n){if(typeof e!=="number"||!Number.isFinite(e)||e<0||e>1)throw new Y(`the live tracks' ${n} ${t} is ${typeof e==="number"?String(e):JSON.stringify(e)}, not a number from 0 to 1`);return e}function Qk(e,t){let n=e.alpha===void 0?1:FM(e.alpha,"options.alpha",t),s=e.additive;if(s!==void 0&&typeof s!=="boolean")throw new Y(`the live tracks' ${t} options.additive is ${JSON.stringify(s)}, not true or false — an entry adds or it does not`);return{alpha:n,additive:s===!0}}function e1(e,t){if(typeof e!=="number"||!Number.isFinite(e))throw new Y(`the live tracks' ${t} delay is ${String(e)}, not a finite number`);return e}function df(e,t,n={}){if(typeof t!=="object"||t===null||t.reset!=="animation"&&t.reset!=="setup")throw new Y(`the live tracks' options.reset is ${JSON.stringify(t?.reset)}, not "animation" or "setup"`);if(t.adjust!==void 0&&typeof t.adjust!=="function")throw new Y(`the live tracks' options.adjust is ${typeof t.adjust}, not a function`);if(t.clock!==void 0&&typeof t.clock!=="function")throw new Y(`the live tracks' options.clock is ${typeof t.clock}, not a function`);let s=t.clock===void 0?void 0:TM(t.clock,"the live tracks'");return new DM(e,t.reset,t.adjust,s,n,A$(e,n))}class DM{constructor(e,t,n,s,r,i){this.doc=e,this.reset=t,this.adjust=n,this.clock=s,this.plant=r,this.path=i,this.started=!1,this.steps=0,this.time=0,this.refused=null,this.mixer=new BM(e,r),this.parameters=new vm(e),this.path.ctx.parameters=this.parameters}get trackTime(){return this.time}get environment(){return AM(this.path.ctx)}setEnvironment(e){this.live("setEnvironment"),CM(this.path.ctx,e,"the live tracks'")}setPhysicsParameters(e,t){this.live("setPhysicsParameters"),this.parameters.set(e,t)}readPhysicsParameters(e){return this.parameters.read(e)}clearPhysicsParameters(e){this.live("clearPhysicsParameters"),this.parameters.clear(e)}physicsTranslate(e,t,n){this.live("physicsTranslate"),EM(this.path.ctx,e,t,"the live tracks'",ac(this.doc,n,"the live tracks'"))}physicsRotate(e,t,n,s){this.live("physicsRotate"),PM(this.path.ctx,e,t,n,"the live tracks'",ac(this.doc,s,"the live tracks'"))}live(e){if(this.refused!==null)throw new Y(`the live tracks were refused at ${this.refused}, after their entries and physics had moved; open them again (${e} not made)`)}setAnimation(e,t,n){this.live("setAnimation");let s=Mr(e,"setAnimation"),r=Zk(n,"setAnimation"),i=Dl(n.mixDuration,"mixDuration","setAnimation"),o=Qk(n,"setAnimation"),a=this.mixer.setAnimation(s,this.mixer.animation(t),r);a.mixDuration=i,a.alpha=o.alpha,a.additive=o.additive}setEmptyAnimation(e,t){this.live("setEmptyAnimation");let n=Mr(e,"setEmptyAnimation"),s=Dl(t,"mixDuration","setEmptyAnimation"),r=this.mixer.setAnimation(n,Yk,!1);r.mixDuration=s,r.trackEnd=s}addAnimation(e,t,n){this.live("addAnimation");let s=Mr(e,"addAnimation"),r=Zk(n,"addAnimation"),i=Dl(n.mixDuration,"mixDuration","addAnimation"),o=e1(n.delay,"addAnimation"),a=Qk(n,"addAnimation"),l=this.mixer.addAnimation(s,this.mixer.animation(t),r,o);this.mixer.setMixDuration(l,i,o),l.alpha=a.alpha,l.additive=a.additive}addEmptyAnimation(e,t,n){this.live("addEmptyAnimation");let s=Mr(e,"addEmptyAnimation"),r=Dl(t,"mixDuration","addEmptyAnimation"),i=e1(n,"addEmptyAnimation"),o=this.mixer.addAnimation(s,Yk,!1,i);if(i<=0)o.delay=Math.max(o.delay+o.mixDuration-r,0);o.mixDuration=r,o.trackEnd=r}setAlpha(e,t){this.live("setAlpha");let n=Mr(e,"setAlpha"),s=FM(t,"alpha","setAlpha"),r=this.mixer.tracks[n]??null;if(r===null)throw new Y(`the live tracks' setAlpha names track ${n}, which plays nothing — there is no entry to weigh`);r.alpha=s}current(e){let t=this.mixer.tracks[Mr(e,"current")]??null;if(t===null)return null;return{animation:t.anim.name,loop:t.loop,trackTime:t.trackTime,animationTime:Gf(t),duration:t.anim.duration,alpha:t.alpha,additive:t.additive}}start(){if(this.live("start"),this.started)throw new Y("the live tracks were started already; pose 0 is posed once");return this.started=!0,this.guard("start",()=>{if(this.reset==="setup")return this.path.setupPose();return this.pose(0,!0)})}step(e){let t=this.steps+1;if(this.live(`step ${t}`),!this.started)throw new Y(`the live tracks' step ${t} comes before start(), which poses pose 0`);if(typeof e!=="number"||!Number.isFinite(e)||e<0)throw new Y(`the live tracks' step ${t} is ${String(e)}, not a finite time at or above 0`);return this.guard(`step ${t}`,()=>{this.time+=e;let n=this.plant.stage;if(n!==void 0)n.begin("timeline");if(this.mixer.update(e),n!==void 0)n.end("timeline");let s=this.pose(e,!1);return this.steps=t,s})}guard(e,t){try{return t()}catch(n){throw this.refused=`${e} (${n instanceof Error?n.message:String(n)})`,n}}pose(e,t){let{doc:n,path:s}=this,r=s.ctx,i=r.time;r.time+=this.clock===void 0?e:this.clock(e);let o=this.plant.stage;if(o!==void 0)o.begin("timeline");let a=new IM(n,this.plant),l=this.mixer.apply(a),u=this.mixer.tracks[0]??null,c=this.adjust===void 0?void 0:{callback:this.adjust,context:{trackTime:u?.trackTime??null,animation:u?.anim.name??null,globalTime:this.time}},h=new Map(n.slots.map((d,f)=>[d.name,{deform:a.slots[f].deform,seen:a.slots[f].seen}]));if(o!==void 0)o.end("timeline");return s.step(t,this.time,l,{world:(d)=>Y2(n,a.bones,s.raw,d,{ctx:r,before:i,adjustment:c}),slots:(d,f)=>hM(n,s.raw,d,f,(m,p)=>{let y=a.slots[n.slots.indexOf(m)];return{placeholder:y.placeholder,light:y.light,dark:y.dark}}),drawOrder:[],at:0,sample:null,mixed:h,events:()=>a.events})}}function U$(e){let t=new Map;for(let n of e){let s={name:n.name,width:n.width,height:n.height};for(let r of n.regions)if(!t.has(r.name))t.set(r.name,{page:s,region:r})}return(n)=>t.get(n)??null}function W$(e,t,n={}){let s=e.degrees===90||n.turned270===!0&&e.degrees===270,r=e.x/t.width,i=e.y/t.height,o=(e.x+(s?e.height:e.width))/t.width,a=(e.y+(s?e.width:e.height))/t.height,l;if(s)l=n.rotationFlipped===!0?[r,i,o,i,o,a,r,a]:[o,a,r,a,r,i,o,i];else l=[r,a,r,i,o,i,o,a];return l.map(Math.fround)}function X$(e,t,n,s={}){let r=s.trimDropped===!0,i=r?0:e.offsetX,o=r?0:e.offsetY,a=r?e.width:e.originalWidth,l=r?e.height:e.originalHeight,{width:u,height:c}=t,h=s.artAsFloat32===!0?n.map(Math.fround):n,d=e.x/u,f=e.y/c,m=[];switch(e.degrees){case 90:{d-=(l-o-e.height)/u,f-=(a-i-e.width)/c;let p=l/u,y=a/c;for(let g=0;g+1typeof e==="object"&&e!==null&&!Array.isArray(e),t1=(e,t)=>typeof e==="number"&&Number.isInteger(e)&&e>=t;function Y$(e){let t=new Map,n=[];if((Tr(e)&&Array.isArray(e.skins)?e.skins:[]).forEach((r,i)=>{if(!Tr(r)||typeof r.name!=="string"||!Tr(r.attachments))return;for(let[o,a]of Object.entries(r.attachments)){if(!Tr(a))continue;for(let[l,u]of Object.entries(a)){if(!Tr(u)||u.sequence===void 0)continue;let c=`skins[${i}] "${r.name}".attachments["${o}"]["${l}"].sequence`,h=u.sequence;if(!Tr(h)){n.push(`${c} is not an object`);continue}let d=n.length;if(!t1(h.count,1))n.push(`${c}: count is ${JSON.stringify(h.count)??"absent"}, not a whole number of at least 1`);for(let p of["start","digits","setup"])if(h[p]!==void 0&&!t1(h[p],0))n.push(`${c}: ${p} is ${JSON.stringify(h[p])}, not a whole number of at least 0`);if(n.length!==d)continue;let f=h.count,m=h.setup??0;if(m>=f){n.push(`${c}: setup is ${m}, and a ${f}-frame series has frames 0 to ${f-1}`);continue}t.set(`${r.name}/${o}/${l}`,{count:f,start:h.start??1,digits:h.digits??0,setup:m})}}}),n.length>0)throw new Y(`the model document's sequences: ${n.join("; ")}`);return t}function H$(e,t,n,s){let r=new Map(t.map((a)=>[a.slot,a])),i=[],o=[];for(let a of n){let l=r.get(a);if(l===void 0)continue;let u=l.geometry;if(u.kind!=="region"&&u.kind!=="mesh"&&u.kind!=="linkedmesh")continue;let c=e.skins.find((g)=>g.name===l.skin)?.attachments[l.slot]?.[l.placeholder];if(c===void 0)throw new Y(`slot "${l.slot}": skin "${l.skin}" files no record under placeholder "${l.placeholder}" (readModel refuses it first)`);let h=c.path??l.name,d=s.sequences.get(`${l.skin}/${l.slot}/${l.placeholder}`);if(u.kind==="linkedmesh"&&d!==void 0&&l.frame!==void 0){let g=e.skins.find((x)=>x.name===u.skin)?.attachments[u.slot]?.[u.source]?.sequenceCount;if(g!==d.count){o.push(`slot "${l.slot}" shows linked mesh "${l.name}", whose own ${d.count}-frame series a sequence timeline steps over its source's ${g??"unstated"} frame(s)`);continue}}let f=d===void 0?null:l.frame??d.setup,m=d===void 0||f===null?h:j$(h,d,f),p=s.lookup(m);if(p===null)throw new Y(`slot "${l.slot}" shows "${l.name}", which draws atlas region "${m}"${f===null?"":` (frame ${f} of its series over "${h}")`}, and the atlas has no region of that name — spine-core refuses to load the pair ("Region not found in atlas")`);let y=null;if(u.kind==="mesh")y=u.uvs;else if(u.kind==="linkedmesh"){let g=e.skins.find((x)=>x.name===u.skin)?.attachments[u.slot]?.[u.source]?.geometry;if(g?.kind!=="mesh")throw new Y(`slot "${l.slot}": the linked mesh's source "${u.source}" carries no uvs (readModel refuses it first)`);y=g.uvs}i.push({slot:l.slot,name:l.name,kind:u.kind,region:m,frame:f,found:p,art:y})}if(o.length>0)return{drawn:null,why:`${o.join("; ")} — which of the two counts the runtime steps it over was not measured`};return{drawn:i,why:null}}function z$(e,t){let n=new Map;for(let s of e){let r=t.get(s.name);if(!r)throw Error(`Missing page image: ${s.name}`);for(let i of s.regions)n.set(i.name,{page:s,region:i,image:r})}return n}function q$(e,t,n){let s=_m(t,t.image);GM(e,t,t.image,s,n)}var NM=new Set;function Lf(e){if(!NM.delete(e))return;URL.revokeObjectURL(e)}var n1=new WeakMap;function lc(e,t){if(!t)return e;let n=n1.get(e);if(n)return n;let{naturalWidth:s,naturalHeight:r}=e;if(!(s>0)||!(r>0))return e;let i=K$(e,s,r);return n1.set(e,i),i}function K$(e,t,n){let s=document.createElement("canvas");s.width=t,s.height=n;let r=s.getContext("2d");if(!r)return e;r.drawImage(e,0,0);let i;try{i=r.getImageData(0,0,t,n)}catch{return e}let o=i.data;for(let a=0;a0?t.width:s,o=t.height>0?t.height:r,a=e.degrees===90,l=a?e.height:e.width,u=a?e.width:e.height;if(!t.pma&&!a&&e.x===0&&e.y===0&&l===i&&u===o)return{passThrough:!0,sx:0,sy:0,sw:s,sh:r,cw:s,ch:r};let c=s/i,h=r/o,d=Math.round(e.x*c),f=Math.round(e.y*h),m=Math.max(1,Math.round((e.x+l)*c)-d),p=Math.max(1,Math.round((e.y+u)*h)-f);return{passThrough:!1,sx:d,sy:f,sw:m,sh:p,cw:a?p:m,ch:a?m:p}}function Z$(e,t){let n=t.get(e.page.name);if(!n)return e.region.width*e.region.height;let s=_m(e,n);return s.cw*s.ch}async function Q$(e,t,n){let{region:s,page:r}=e,i=t.get(r.name);if(!i)throw Error(`Missing page image: ${r.name}`);let{width:o,height:a}=s,l=_m(e,i);if(l.passThrough)return{url:i.src,width:o,height:a};let u=document.createElement("canvas");if(GM(u,e,i,l),n==="data")return{url:u.toDataURL("image/png"),width:o,height:a};let c=await new Promise((d,f)=>{u.toBlob((m)=>m?d(m):f(Error("toBlob failed")),"image/png")}),h=URL.createObjectURL(c);return NM.add(h),{url:h,width:o,height:a}}function GM(e,t,n,s,r){e.width=r===void 0?s.cw:Math.min(s.cw,Math.max(1,Math.ceil(t.region.width*r))),e.height=r===void 0?s.ch:Math.min(s.ch,Math.max(1,Math.ceil(t.region.height*r)));let i=e.getContext("2d");if(!i)throw Error("2d context unavailable");if(r!==void 0)i.imageSmoothingQuality="high",i.scale(e.width/s.cw,e.height/s.ch);if(t.region.degrees===90)i.translate(s.cw,0),i.rotate(Math.PI/2);let o=lc(n,t.page.pma===!0);i.drawImage(o,s.sx,s.sy,s.sw,s.sh,0,0,s.sw,s.sh)}async function eO(e,t,n={}){let s=n.encoding??"blob";if(s!=="blob"&&s!=="data")throw Error(`encoding must be 'blob' or 'data', got ${String(n.encoding)}`);let r=e.flatMap((h)=>h.regions.map((d)=>({region:d,page:h}))),i=Array(r.length),o=-1,a,l=[],u=0;for(let h=0;h0&&u+f>J$)if(await Promise.race(l.map((p)=>p.promise)),l=l.filter((p)=>!p.done),o!==-1)break;if(o!==-1)break;u+=f;let m={done:!1,promise:Promise.resolve()};m.promise=(async()=>{try{i[h]=await Q$(d,t,s)}catch(p){if(o===-1||hh.promise)),o!==-1){for(let h of i)if(h)Lf(h.url);throw a}let c=new Map;for(let h=0;h{this.markLost()});let t=this.link(N2,G2);this.meshProgram=t,e.useProgram(t);let n=e.getUniformLocation(t,"uResolution"),s=e.getUniformLocation(t,"uOrigin");if(!n||!s)throw Error("mesh program uniforms not found");this.uResolution=n,this.uOrigin=s,e.uniform1i(e.getUniformLocation(t,"uTex"),0),this.meshPos=e.getAttribLocation(t,"aPos"),this.meshUV=e.getAttribLocation(t,"aUV");let r=this.link(D2,F2);this.frameProgram=r,e.useProgram(r);let i=e.getUniformLocation(r,"uResolution"),o=e.getUniformLocation(r,"uOrigin");if(!i||!o)throw Error("frame program uniforms not found");this.frameResolution=i,this.frameOrigin=o,e.uniform1i(e.getUniformLocation(r,"uTex"),0),this.framePos=e.getAttribLocation(r,"aPos"),this.frameUV=e.getAttribLocation(r,"aUV"),this.frameColor=e.getAttribLocation(r,"aColor"),this.frameDark=e.getAttribLocation(r,"aDark"),e.bindBuffer(e.ARRAY_BUFFER,e.createBuffer()),e.enable(e.BLEND),e.enable(e.SCISSOR_TEST),e.clearColor(0,0,0,0),e.activeTexture(e.TEXTURE0),this.maxSize=Math.min(e.getParameter(e.MAX_RENDERBUFFER_SIZE)||4096,8192)}flush(e){let t=this.gl;if(this.lost||t.isContextLost())return!1;let n=Math.max(512,this.canvas.width);for(let y of e)n=Math.max(n,y.width+Qe*2);if(n>this.maxSize)return!1;let s=e.map((y,g)=>g).sort((y,g)=>e[g].height-e[y].height),r=this.packX=Array(e.length),i=this.packY=Array(e.length),o=Qe,a=Qe,l=0,u=Qe;for(let y of s){let g=e[y];if(o+g.width+Qe>n)a+=l+Qe,o=Qe,l=0;if(r[y]=o,i[y]=a,o+=g.width+Qe,g.height>l)l=g.height;if(a+g.height+Qe>u)u=a+g.height+Qe}if(u>this.maxSize)return!1;if(n>this.canvas.width||u>this.canvas.height)this.canvas.width=Math.min(this.maxSize,Math.ceil(n/Un)*Un),this.canvas.height=Math.min(this.maxSize,Math.ceil(Math.max(u,this.canvas.height)/Un)*Un);let c=this.canvas.height;this.bindMesh();let h=0;for(let y of e)h+=y.triangles.length*4;if(this.vertexData.lengththis.maxSize||s>this.maxSize)return!1;if(n>this.canvas.width||s>this.canvas.height)this.canvas.width=Math.min(this.maxSize,Math.ceil(Math.max(n,this.canvas.width)/Un)*Un),this.canvas.height=Math.min(this.maxSize,Math.ceil(Math.max(s,this.canvas.height)/Un)*Un);let r=this.canvas.width,i=this.canvas.height;t.viewport(0,0,r,i),this.bindFrame(e.stride),t.uniform2f(this.frameResolution,r,i),t.uniform2f(this.frameOrigin,Qe,Qe);let o=0;for(let c of e.runs)o=Math.max(o,c.first+c.count);if(o>0)t.bufferData(t.ARRAY_BUFFER,e.data.subarray(0,o*e.stride),t.DYNAMIC_DRAW);t.scissor(Qe,i-Qe-e.height,e.width,e.height),t.clear(t.COLOR_BUFFER_BIT);let a=null,l=null;for(let c of e.runs){if(c.page!==a)t.bindTexture(t.TEXTURE_2D,this.textureFor(c.page,c.pma)),a=c.page;if(c.blend!==l){let[h,d]=B2[c.blend];t.blendFuncSeparate(h,d,t.ONE,d),l=c.blend}t.drawArrays(t.TRIANGLES,c.first,c.count)}if(t.isContextLost())return this.markLost(),!1;let u=e.canvas.getContext("2d");if(!u)return!0;if(u.setTransform(1,0,0,1,0,0),u.globalAlpha=1,u.globalCompositeOperation="source-over",u.clearRect(0,0,e.canvas.width,e.canvas.height),e.width>0&&e.height>0)u.drawImage(this.canvas,Qe,Qe,e.width,e.height,0,0,e.width,e.height);return!0}bindMesh(){let e=this.gl;if(this.bound!=="mesh")e.useProgram(this.meshProgram),this.disableAttributes(),e.enableVertexAttribArray(this.meshPos),e.enableVertexAttribArray(this.meshUV),e.vertexAttribPointer(this.meshPos,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(this.meshUV,2,e.FLOAT,!1,16,8),this.bound="mesh";e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}bindFrame(e){let t=this.gl;t.useProgram(this.frameProgram),this.disableAttributes();let n=e*4;if(t.enableVertexAttribArray(this.framePos),t.enableVertexAttribArray(this.frameUV),t.enableVertexAttribArray(this.frameColor),t.vertexAttribPointer(this.framePos,2,t.FLOAT,!1,n,0),t.vertexAttribPointer(this.frameUV,2,t.FLOAT,!1,n,8),t.vertexAttribPointer(this.frameColor,4,t.FLOAT,!1,n,16),e===11)t.enableVertexAttribArray(this.frameDark),t.vertexAttribPointer(this.frameDark,3,t.FLOAT,!1,n,32);else t.vertexAttrib3f(this.frameDark,0,0,0);this.bound="frame"}disableAttributes(){let e=this.gl;for(let t of[this.meshPos,this.meshUV,this.framePos,this.frameUV,this.frameColor,this.frameDark])if(t>=0)e.disableVertexAttribArray(t)}link(e,t){let n=this.gl,s=n.createProgram();if(!s)throw Error("createProgram failed");if(n.attachShader(s,this.compile(n.VERTEX_SHADER,e)),n.attachShader(s,this.compile(n.FRAGMENT_SHADER,t)),n.linkProgram(s),!n.getProgramParameter(s,n.LINK_STATUS))throw Error(`program link failed: ${n.getProgramInfoLog(s)}`);return s}retain(e){let t=this.textures.get(e);if(t)t.users++;else this.textures.set(e,{texture:null,users:1,pma:!1})}release(e){let t=this.textures.get(e);if(!t)return;if(--t.users>0)return;if(this.textures.delete(e),!t.texture)return;if(!this.lost&&!this.gl.isContextLost())this.gl.deleteTexture(t.texture);this.liveTextureCount--}markLost(){this.lost=!0,this.textures=new WeakMap,this.liveTextureCount=0}compile(e,t){let n=this.gl,s=n.createShader(e);if(!s)throw Error("createShader failed");if(n.shaderSource(s,t),n.compileShader(s),!n.getShaderParameter(s,n.COMPILE_STATUS))throw Error(`shader compile failed: ${n.getShaderInfoLog(s)}`);return s}textureFor(e,t){let n=this.textures.get(e);if(n?.texture){if(n.pma===t)return n.texture;this.gl.deleteTexture(n.texture),n.texture=null,this.liveTextureCount--}let s=this.gl,r=s.createTexture();if(!r)throw Error("createTexture failed");if(s.bindTexture(s.TEXTURE_2D,r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t?0:1),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),!n)n={texture:null,users:0,pma:t},this.textures.set(e,n);return n.pma=t,n.texture=r,this.liveTextureCount++,r}}var xr;function Cr(){if(xr===void 0)try{xr=new MM}catch{xr=null}return xr&&!xr.lost?xr:null}function TM(e=typeof navigator==="object"?navigator.userAgent:""){return/AppleWebKit/.test(e)&&/Linux|X11/.test(e)&&!/Android|Chrome|Chromium|CriOS|Edg/.test(e)?"triangle":"page"}var gs=new Float32Array(8),sf="http://www.w3.org/2000/svg",L2=0,U2=4,W2=new Float64Array(6);function X2(e,t,n,s,r,i,o){let a=W2;a[0]=e,a[1]=t,a[2]=n,a[3]=s,a[4]=r,a[5]=i;let l=(n-e)*(i-t)-(r-e)*(s-t);if(o===0||l===0)return a;let u=l>0?1:-1,c=Math.hypot(n-e,s-t),h=(s-t)/c*u,d=-(n-e)/c*u;c=Math.hypot(r-n,i-s);let f=(i-s)/c*u,m=-(r-n)/c*u;c=Math.hypot(e-r,t-i);let p=(t-i)/c*u,y=-(e-r)/c*u;return rf(a,0,p,y,h,d,o),rf(a,2,h,d,f,m,o),rf(a,4,f,m,p,y,o),a}function rf(e,t,n,s,r,i,o){let a=o/(1+n*r+s*i),l=(n+r)*a,u=(s+i)*a,c=Math.hypot(l,u),h=U2*o;if(c>h)l*=h/c,u*=h/c;e[t]+=l,e[t+1]+=u}function $l(e){return`${Oi(e)}px`}function Oi(e){return Math.round(e*1000)/1000}var Xw=1e9;function j2(e){if(!Number.isFinite(e))return 0;return 2**(Math.max(-149,Math.floor(Math.log2(Math.abs(e)))-23)-1)}function jw(e,t,n,s){if(e===t)return!0;if(s===0)return!1;let r=j2(n),i=Math.abs(e-t);return i<0.5&&i<=r}var Y2={Normal:"",Additive:"plus-lighter",Multiply:"multiply",Screen:"screen"};class CM{constructor(e,t,n=new Map,s=new Map){this.root=e,this.regionImages=t,this.pages=n,this.atlasRegions=s}clipping=!0;clipCount=0;rigidRasterCount=0;clipSkipCount=0;clipWriteCount=0;meshCount=0;meshReuseCount=0;canvasReallocCount=0;triangleCount=0;triangleExpand=0.5;meshSourceRect=TM();pixelRatio=typeof devicePixelRatio==="number"?devicePixelRatio:1;meshBackend="webgl";meshBackendActive="webgl";views=new Map;frameNumber=0;pendingJobs=[];pendingViews=[];glPages=null;scratchVertices=new Float32Array(256);tintDefs=null;clipActive=null;clipsSeen=new Set;clipInverse=!1;clipOnRoot=!1;clipPolygon=new Float64Array(0);clipPolygonLength=0;rootClipSaved=null;rootClipWritten="";get meshBackingPixels(){let e=0;for(let t of this.views.values())if(t.kind==="canvas")e+=t.canvasW*t.canvasH;return e}syncPixelRatio(){return this.pixelRatio=s1(this.root,this.pixelRatio),this.pixelRatio}render(e){let t=n1(e);this.clipCount=0,this.rigidRasterCount=0,this.clipSkipCount=0,this.clipWriteCount=0,this.meshCount=0,this.meshReuseCount=0,this.canvasReallocCount=0,this.triangleCount=0,this.clipActive=null,this.clipInverse=!1,this.clipOnRoot=!1,this.clipsSeen.clear();let n=++this.frameNumber,s=this.meshBackend==="webgl"?Cr():null;this.meshBackendActive=s?"webgl":"canvas2d";let r=t.order,i=r.length>0?r[0].clip:void 0;if(i&&!i.inverse&&this.clipping&&i.polygon.length>=6){let o=!0;for(let a=1,l=r.length;a0&&g<1?1.25**Math.ceil(Math.log(g)/Math.log(1.25)):1;if(s.regionName!==e.region||t&&s.regionRatio!==x)if(s.regionName=e.region,s.regionRatio=x,t)A2(s.el,t,x<1?x:void 0),s.el.style.width=`${h}px`,s.el.style.height=`${d}px`,this.rigidRasterCount++;else{let b=s.el;b.src=this.regionImages.get(e.region).url,b.width=h,b.height=d}return this.setTransform(s,`matrix(${f},${m},${p},${y},${a},${l})`),this.applyClip(s,f,m,p,y,a,l,h,d),this.applyCommon(s,e),s}renderMesh(e){let t=e.sequence,n=this.pages.get(e.page);if(!n)return null;let{pma:s,vertices:r}=e,i=r.length;if(this.scratchVertices.lengthu)u=T;if(Ac)c=A}let h=1;a=Math.floor(a)-h,l=Math.floor(l)-h;let d=Math.ceil(u)+h-a,f=Math.ceil(c)+h-l;if(d<=0||f<=0)return null;let m=this.view(e.slot,"canvas"),p=m.el,y=this.pixelRatio,{uvs:g,triangles:x}=e,b=m.meshUvs!==g||m.meshTriangles!==x||m.meshPage!==n||m.meshSequenceIndex!==t||m.meshExpand!==this.triangleExpand||m.meshSourceRect!==this.meshSourceRect||m.meshVertexCount!==i||m.meshBackendDrawn!==this.meshBackendActive,v=Math.max(1,Math.round(d*y)),_=Math.max(1,Math.round(f*y)),S=m.meshRatio!==y;if(v>m.canvasW||_>m.canvasH||S){let T=S?0:m.canvasW,A=S?0:m.canvasH;m.canvasW=Math.ceil(Math.max(v*1.25,T)/32)*32,m.canvasH=Math.ceil(Math.max(_*1.25,A)/32)*32,m.meshRatio=y,p.width=m.canvasW,p.height=m.canvasH,p.style.width=`${m.canvasW/y}px`,p.style.height=`${m.canvasH/y}px`,this.canvasReallocCount++,b=!0}if(m.meshVertices.length0?"L":"M"}${Oi(x)} ${Oi(b)}`;else m+=`${p>0?",":""}${$l(x)} ${$l(b)}`}this.setClipPath(e,f?`${m}Z')`:`${m})`)}setClipPath(e,t){if(e.clipPath===t)return;e.clipPath=t,e.el.style.clipPath=t,this.clipWriteCount++}rootClipPath(){let e=this.clipPolygon,t="polygon(";for(let n=0,s=this.clipPolygonLength;n0)t+=",";t+=`${$l(e[n])} ${$l(e[n+1])}`}return`${t})`}writeRootClip(e){if(this.rootClipSaved===null)this.rootClipSaved=this.root.style.clipPath;if(this.rootClipWritten===e)return;this.rootClipWritten=e,this.root.style.clipPath=e,this.clipWriteCount++}releaseRootClip(){if(this.rootClipSaved===null)return;this.root.style.clipPath=this.rootClipSaved,this.rootClipSaved=null,this.rootClipWritten="",this.clipWriteCount++}setTransform(e,t){if(e.transform!==t)e.transform=t,e.el.style.transform=t}applyCommon(e,t){let{z:n,tint:s}=t;if(e.zIndex!==n)e.zIndex=n,e.el.style.zIndex=String(n);let r=s[3];if(e.opacity!==r)e.opacity=r,e.el.style.opacity=r===1?"":String(r);let i=s[0],o=s[1],a=s[2];if(e.tintR!==i||e.tintG!==o||e.tintB!==a)if(e.tintR=i,e.tintG=o,e.tintB=a,i===1&&o===1&&a===1)e.el.style.filter="";else this.tintMatrixFor(e).setAttribute("values",`${i} 0 0 0 0 0 ${o} 0 0 0 0 0 ${a} 0 0 0 0 0 1 0`),e.el.style.filter=`url(#${e.tintId})`;let l=t.blend;if(e.blendMode!==l)e.blendMode=l,e.el.style.mixBlendMode=Y2[l];if(!e.visible)e.visible=!0,e.el.style.display=""}tintMatrixFor(e){if(e.tintMatrix)return e.tintMatrix;if(!this.tintDefs){let s=document.createElementNS(sf,"svg");s.setAttribute("width","0"),s.setAttribute("height","0"),s.style.position="absolute",this.root.appendChild(s),this.tintDefs=s}let t=document.createElementNS(sf,"filter");e.tintId=`rig-play-tint-${L2++}`,t.setAttribute("id",e.tintId),t.setAttribute("color-interpolation-filters","sRGB");let n=document.createElementNS(sf,"feColorMatrix");return n.setAttribute("in","SourceGraphic"),n.setAttribute("type","matrix"),t.appendChild(n),this.tintDefs.appendChild(t),e.tintMatrix=n,n}view(e,t){let n=this.views.get(e);if(n&&n.kind!==t)n.el.remove(),n.tintMatrix?.parentElement?.remove(),n=void 0;if(!n){let s=t==="image"?document.createElement("img"):document.createElement("canvas");if(s instanceof HTMLImageElement)s.draggable=!1;s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transformOrigin="0 0",s.style.pointerEvents="none",s.style.userSelect="none",s.style.display="none",n={kind:t,el:s,regionName:"",regionRatio:-1,visible:!1,zIndex:-1,opacity:1,blendMode:"Normal",transform:"",clipPath:"",tintR:1,tintG:1,tintB:1,tintId:"",tintMatrix:null,canvasW:0,canvasH:0,meshRatio:-1,meshUvs:null,meshTriangles:null,meshPage:null,meshSequenceIndex:-1,meshExpand:-1,meshSourceRect:"",meshVertexCount:-1,meshBackendDrawn:"",meshVertices:new Float64Array(0),meshOriginX:0,meshOriginY:0,drawnIn:0},this.views.set(e,n),this.root.appendChild(s)}return n}hide(e){if(e.visible)e.visible=!1,e.el.style.display="none";this.setClipPath(e,"")}}function AM(e,t,n,s,r,i,o,a,l,u,c,h,d,f,m,p){let y=X2(r,i,l,u,d,f,n),g=y[0],x=y[1],b=y[2],v=y[3],_=y[4],S=y[5];e.beginPath(),e.moveTo(g,x),e.lineTo(b,v),e.lineTo(_,S),e.closePath();let M=l-r,k=u-i,T=d-r,A=f-i,O=c-o,R=h-a,P=m-o,I=p-a,F=O*I-P*R;if(F===0)return;F=1/F;let B=(I*M-R*T)*F,C=(I*k-R*A)*F,D=(O*T-P*M)*F,N=(O*A-P*k)*F,G=r-B*o-D*a,z=i-C*o-N*a;if(s==="page"){e.save(),e.transform(B,C,D,N,G,z),e.clip(),e.drawImage(t,0,0),e.restore();return}let q=Math.min(o,c,m),L=Math.max(o,c,m),K=Math.min(a,h,p),J=Math.max(a,h,p),H=B*N-C*D;if(H!==0){let ue=1/H,re=N*ue,ge=-D*ue,xe=-C*ue,Te=B*ue,Be=g-r,te=x-i,be=o+re*Be+ge*te,ye=a+xe*Be+Te*te;q=Math.min(q,be),L=Math.max(L,be),K=Math.min(K,ye),J=Math.max(J,ye),Be=b-l,te=v-u,be=c+re*Be+ge*te,ye=h+xe*Be+Te*te,q=Math.min(q,be),L=Math.max(L,be),K=Math.min(K,ye),J=Math.max(J,ye),Be=_-d,te=S-f,be=m+re*Be+ge*te,ye=p+xe*Be+Te*te,q=Math.min(q,be),L=Math.max(L,be),K=Math.min(K,ye),J=Math.max(J,ye)}let pe=Math.max(0,Math.floor(q-1)),Ie=Math.max(0,Math.floor(K-1)),Le=Math.min(t.width,Math.ceil(L+1))-pe,Me=Math.min(t.height,Math.ceil(J+1))-Ie;if(!(Le>0)||!(Me>0))return;e.save(),e.transform(B,C,D,N,G,z),e.clip(),e.drawImage(t,pe,Ie,Le,Me,pe,Ie,Le,Me),e.restore()}var V2={Normal:0,Additive:1,Multiply:2,Screen:3},H2={Normal:"source-over",Additive:"lighter",Multiply:"multiply",Screen:"screen"},br=16;class Rf{constructor(e,t){this.root=e,this.pages=t;let n=document.createElement("canvas");n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.transformOrigin="0 0",n.style.pointerEvents="none",n.style.userSelect="none",n.width=0,n.height=0,this.canvas=n,this.ctx=n.getContext("2d"),e.appendChild(n)}pixelRatio=typeof devicePixelRatio==="number"?devicePixelRatio:1;clipping=!0;viewport=null;backend="webgl";meshSourceRect=TM();backendActive="webgl";canvas;drawCalls=0;blendFlushes=0;trianglesDrawn=0;framesReused=0;blits=0;canvasReallocCount=0;clipCount=0;clipSkipCount=0;ctx;left=0;top=0;right=0;bottom=0;hasRect=!1;backingW=0;backingH=0;backingRatio=-1;data=new Float32Array(4096);runs=[];glPages=new Set;sig=new Float64Array(256);sigLength=-1;sigRefs=[];nextSig=new Float64Array(256);nextRefs=[];syncPixelRatio(){return this.pixelRatio=s1(this.root,this.pixelRatio),this.pixelRatio}reserve(e){this.growTo(e.x,-(e.y+e.height),e.x+e.width,-e.y)}render(e){let t=n1(e);this.drawCalls=0,this.blendFlushes=0,this.trianglesDrawn=0,this.framesReused=0,this.blits=0,this.canvasReallocCount=0,this.clipCount=0,this.clipSkipCount=0;let n=this.backend==="webgl"?Cr():null;this.backendActive=n?"webgl":"canvas2d";let s=t.order,r=this.viewport;if(r)this.setRect(Math.floor(r.x),Math.floor(-(r.y+r.height)),Math.ceil(r.x+r.width),Math.ceil(-r.y));else{let i=1/0,o=1/0,a=-1/0,l=-1/0;for(let u=0;ua)a=f;if(ml)l=m}}if(i<=a&&o<=l)this.growTo(i,o,a,l)}if(this.sizeBacking(),!this.signatureChanged(s)){this.framesReused=1,this.countClips(s);return}if(this.backingW===0||this.backingH===0)return;if(n){if(this.buildVertices(s),n.flushFrame({canvas:this.canvas,width:this.backingW,height:this.backingH,data:this.data,stride:this.stride,runs:this.runs})){this.blits=1;return}this.backendActive="canvas2d",this.sigLength=-1}this.draw2d(s)}dispose(){if(this.canvas.remove(),this.glPages.size){let e=Cr();if(e)for(let t of this.glPages)e.release(t);this.glPages.clear()}this.sigLength=-1}growTo(e,t,n,s){if(this.hasRect&&e>=this.left&&t>=this.top&&n<=this.right&&s<=this.bottom)return;if(!this.hasRect){this.setRect(Math.floor(e)-br,Math.floor(t)-br,Math.ceil(n)+br,Math.ceil(s)+br);return}let r=Math.max(br,Math.round((this.right-this.left)/4)),i=Math.max(br,Math.round((this.bottom-this.top)/4));this.setRect(ethis.right?Math.ceil(n)+r:this.right,s>this.bottom?Math.ceil(s)+i:this.bottom)}setRect(e,t,n,s){if(this.hasRect&&e===this.left&&t===this.top&&n===this.right&&s===this.bottom)return;this.left=e,this.top=t,this.right=Math.max(e,n),this.bottom=Math.max(t,s),this.hasRect=!0,this.canvas.style.transform=`translate(${e}px,${t}px)`}sizeBacking(){let e=this.pixelRatio,t=this.hasRect?Math.max(0,Math.ceil((this.right-this.left)*e)):0,n=this.hasRect?Math.max(0,Math.ceil((this.bottom-this.top)*e)):0;if(t===this.backingW&&n===this.backingH&&e===this.backingRatio)return;this.backingW=t,this.backingH=n,this.backingRatio=e,this.canvas.width=t,this.canvas.height=n,this.canvas.style.width=`${t/e}px`,this.canvas.style.height=`${n/e}px`,this.canvasReallocCount++,this.sigLength=-1}signatureChanged(e){let t=0,n=this.nextRefs;n.length=0;let s=this.nextSig,r=(a)=>{if(t+a>s.length){let l=new Float64Array(Math.max(s.length*2,t+a));l.set(s.subarray(0,t)),s=l,this.nextSig=l}};r(9),s[t++]=this.meshSourceRect==="triangle"?1:0,s[t++]=this.left,s[t++]=this.top,s[t++]=this.backingW,s[t++]=this.backingH,s[t++]=this.backingRatio,s[t++]=this.backendActive==="webgl"?1:0,s[t++]=this.clipping?1:0,s[t++]=e.length;let i;for(let a=0;a=6)this.clipCount++;else this.clipSkipCount++}}stride=8;piecesOf(e,t){let n=e.kind==="region"?e.corners:e.vertices,s=e.kind==="region"?Yf:e.triangles,r=e.clip;if(!r)return{vertices:n,uvs:e.uvs,triangles:s};let i=t.get(r);if(i===void 0)if(i=this.clipping&&r.polygon.length>=6,t.set(r,i),i)this.clipCount++;else this.clipSkipCount++;if(!i)return{vertices:n,uvs:e.uvs,triangles:s};let o=S1({polygon:r.polygon,inverse:r.inverse,convex:r.convex},n,s,e.uvs);if(o===null)return t.set(r,!1),this.clipCount--,this.clipSkipCount++,{vertices:n,uvs:e.uvs,triangles:s};return o.clipped?o:{vertices:n,uvs:e.uvs,triangles:s}}buildVertices(e){let t=!1;for(let h=0;h(u-r)*s,a=(u)=>(-u-i)*s,l=null;for(let u=0;uO&&I>R)t.drawImage(f,O,R,P-O,I-R,O,R,P-O,I-R);t.setTransform(1,0,0,1,0,0)}this.trianglesDrawn+=2;continue}for(let b=0;b+2c.name)),i=new Set(n.bones.map((c)=>c.name)),o=new Map;for(let c of n.skins)for(let[h,d]of Object.entries(c.attachments)){let f=o.get(h);if(!f)f=new Set,o.set(h,f);for(let m of Object.keys(d))f.add(m)}let a=[];if(Array.isArray(s.sets))for(let c=0;c{let r=new Image;if(t!==void 0)r.crossOrigin=t;r.onload=()=>n(r),r.onerror=()=>s(Error(`Failed to load page image: ${e}`)),r.src=e})}function Q2(e){return e.split(/[?#]/,1)[0].toLowerCase()}function eO(e,t){let n;try{n=X$(e,t)}catch(s){if(s instanceof Y)throw new Y(`${s.message} — build it with \`rigc build\``);throw s}if(n.pages===null)throw new Y(`${t}: a ${n.spec} document does not state where each region sits on its page — build it with \`rigc build\``);return{spec:n.spec,doc:n,parsed:JSON.parse(e)}}async function tO(e){let{modelUrl:t,crossOrigin:n}=e,s=Q2(t);if(s.endsWith(".skel")||s.endsWith(".json")&&!s.endsWith(".model.json"))throw new Y(`${t} is a Spine export; this player reads a compiled model document (${Z1[0]}, skeleton.model.json) — build it with \`rigc build\``);let r=e.regions??"blob";if(r!=="atlas"&&r!=="blob"&&r!=="data"&&r!=="none")throw Error(`regions must be 'atlas', 'blob', 'data' or 'none', got ${String(e.regions)}`);let i=e.fetch??globalThis.fetch.bind(globalThis),o=e.resolvePage??EM,a=eO(await RM(i,t),t),l=a.doc.pages??[],u=new Map;await Promise.all(l.map(async(f)=>{u.set(f.name,await Z2(o(f.name,t),n))}));let c=await K2(i,t,e.setsUrl,a.doc),h=r==="none"||r==="atlas"?new Map:await O2(l,u,{encoding:r}),d=!1;return{spec:a.spec,animations:a.doc.animations.map((f)=>({name:f.name,duration:f.timelines.duration})),skins:a.doc.skins.map((f)=>f.name),sets:c,stage:J2(a.doc),regions:r,regionImages:h,atlasRegions:r==="atlas"?C2(l,u):new Map,pageImages:u,document:a,dispose(){if(d)return;d=!0,I2(h)}}}var ic=0,Ji=1,PM=2,Lt=2*(Y1+1);function Sr(e,t){let n=e.length,s=new Float64Array(n),r=new Float64Array(n*t),i=new Uint8Array(n),o=new Float64Array(n*t*Lt);for(let a=0;a=n)continue;let c=e[a+1];for(let h=0;h=0&&r[i]>s)i--;while(i+1=e.keys)return o;let a=e.kinds[t];if(a===Ji)return o;if(a===ic){let f=e.times[t];return o+(s-f)/(e.times[t+1]-f)*(i[(t+1)*r+n]-o)}let l=e.polylines,u=(t*r+n)*Lt,c=2;while(c({time:n.time,values:[0],curve:"linear",stated:{time:n.stated,values:[0]}})),1);for(let n=0;n[C.name,D])),l=(C)=>{let D=a.get(C);if(D===void 0)throw new Gt(`bone "${C}" is not a bone of this document (readModel refuses it first)`);return D},u=At(e),c=new Int32Array(o),h=new Uint8Array(o),d=new Uint8Array(o),f=new Float64Array(o),m=new Float64Array(o*cn);if(e.bones.forEach((C,D)=>{if(c[D]=C.parent===void 0?-1:l(C.parent),c[D]>=D)throw new Gt(`bone "${C.name}" is listed before its parent (readModel refuses it first)`);let N=C.inheritMode===void 0?"normal":Qf(C.inheritMode);if(N===null)throw new Gt(`bone "${C.name}": inheritMode ${JSON.stringify(C.inheritMode)} is no mode (readModel refuses it first)`);h[D]=oO[N],d[D]=u.has(C.name)?1:0,f[D]=C.length??0;let G=D*cn;m[G+bn]=C.x??0,m[G+Qt]=C.y??0,m[G+bt]=C.rotation??0,m[G+en]=C.scaleX??1,m[G+Nt]=C.scaleY??1,m[G+bs]=C.shearX??0,m[G+Ar]=C.shearY??0}),n.setupNudge!==void 0)m[l(n.setupNudge.bone)*cn+n.setupNudge.field]+=n.setupNudge.delta;let p=e.bones.map(()=>[]);for(let C=0;C=0;D=c[D])p[D].push(C);let y=new Int32Array(o+1),g=[];for(let C=0;C!u.has(z)))s.note("inactive-constrained-bone",`${C.kind} constraint "${C.name}" names bone(s) ${C.bones.filter((z)=>!u.has(z)).map((z)=>`"${z}"`).join(", ")}, which the view leaves inactive — what the oracle writes there depends on the pass before`);let G=x.length;if(C.kind==="ik")x.push(dO(C,G,D,N,l));else{if(C.localSource||C.localTarget)s.note("local-transform",`transform constraint "${C.name}" ${[C.localSource?"reads local values (localSource)":"",C.localTarget?"writes local values (localTarget)":""].filter((q)=>q!=="").join(" and ")}`);if(C.additive)s.note("additive-transform",`transform constraint "${C.name}" is additive`);let z=fO(C,G,D,N,l);if(D)for(let q=0;q=0&&(L===Ql||L===am))s.note("noscale-world-target",`transform constraint "${C.name}" moves bone "${C.bones[q]}" in world space, and its local values are read back in a noScale mode`)}x.push(z)}}let b=[],v=0,_=0,S=rm(e),M=n.attachmentSkin===void 0?e:kf(e,n.attachmentSkin),k=e.slots.map(()=>new Map),T=(C,D,N)=>{let G=k[C],z=G.get(D);if(z===void 0)z=A(C,D),G.set(D,z);if(z.missing!==null)s.note(z.missing[0],z.missing[1],N);return z.index},A=(C,D)=>{let N=e.slots[C],G=D===null?null:vn(M,N,D);if(G===null)return{index:-1,missing:null};if("conflict"in G)return{index:-1,missing:["skin-conflict",`slot "${N.name}" placeholder "${D}" is filled by skins that disagree`]};let z=Ki(G),q=G.record.geometry,L={timeline:Xf(N.name,G),deformOffset:_,slot:C,name:z.name,skin:G.skin,placeholder:G.placeholder,path:nM.has(G.record.kind)?z.path:null,bone:l(N.bone),offset:v},K=null,J=null;if(q?.kind==="clipping")J=["clipping",`slot "${N.name}" shows clipping attachment "${z.name}"`];else if(q?.kind==="region"){let H=q.region;if(H.atlas===null)J=["null-atlas-region",`slot "${N.name}" shows region "${z.name}", whose atlas rectangle the model states as null`];else{let{width:pe,height:Ie}=H,Le=H.scaleX??1,Me=H.scaleY??1,ue=H.atlas,re=pe/ue.originalWidth*Le,ge=Ie/ue.originalHeight*Me,xe=-pe/2*Le+ue.offsetX*re,Te=-Ie/2*Me+ue.offsetY*ge,Be=xe+ue.width*re,te=Te+ue.height*ge,be=(H.rotation??0)*vt,ye=Math.cos(be),ht=Math.sin(be),Vn=H.x??0,Cs=H.y??0,As=new Float64Array(8),Rr=[xe,Te,xe,te,Be,te,Be,Te];for(let un=0;un<8;un+=2){let Et=Rr[un],_n=Rr[un+1];As[un]=Et*ye+Vn-_n*ht,As[un+1]=_n*ye+Cs+Et*ht}K=Bf(L,Pf,As,8)}}else if(q?.kind==="mesh"||q?.kind==="linkedmesh"){let H=q.kind==="mesh"?q.vertices:S(q.skin,q.slot,q.source);if(typeof H==="string")throw new Gt(`slot "${N.name}": ${H} (readModel refuses it first)`);K=hO(L,H,l,n.bindingIndex,o)}if(K===null)K=Bf(L,$M,new Float64Array(0),0);return b.push(K),v+=K.count,_+=K.deformCount,{index:b.length-1,missing:J}},O=e.slots.map((C,D)=>{let N=l(C.bone),G=C.color===void 0?[1,1,1,1]:Hi(C.color);return{name:C.name,bone:N,live:u.has(C.bone),setupAttachment:T(D,C.setup,null),light:Float64Array.from(G),dark:C.dark===void 0?null:Float64Array.from(Hi(C.dark).slice(0,3)),blend:nm(C)}}),R=new Map(e.slots.map((C,D)=>[C.name,D])),P=new Map,I=[],F=0;for(let C of e.animations){let D=mO(C,s,r,a,R,O,x,e,(G,z)=>T(G,z,C.name)),N=s.byAnimation.get(C.name);if(N!==void 0&&N.length>0)I.push({animation:C.name,missing:N});else P.set(C.name,D),F=Math.max(F,D.cursors)}if(s.model.length>0)throw new zi(s.model);let B=e.animations.map((C)=>C.name);return{omitDeform:n.omitDeform===!0,deformAfterWeights:n.deformAfterWeights===!0,deformCount:_,eventWrapOffByOne:n.eventWrapOffByOne===!0,restoreEventsFromStart:n.restoreEventsFromStart===!0,doc:e,boneNames:e.bones.map((C)=>C.name),parents:c,modes:h,active:d,lengths:f,setup:m,subtreeStart:y,subtrees:Int32Array.from(g),slots:O,attachments:b,vertexCount:v,constraints:x,animations:P,refused:I,cursors:F,scratch:n.scratchByBones===!0?Math.max(1,o):Math.max(1,o,...x.map((C)=>C.bones.length)),animation(C){let D=P.get(C);if(D!==void 0)return D;let N=I.find((G)=>G.animation===C);if(N!==void 0)throw new zi(N.missing);throw new Gt(`animation ${JSON.stringify(C)} is not one of this document's [${B.join(", ")}]`)}}}var zw=new Int32Array(0),jl=new Float64Array(0);function Bf(e,t,n,s){return{...e,draw:t,local:n,count:s,deformCount:t===Fi?s:0,bindingCounts:zw,bindingBones:zw,bindingX:jl,bindingY:jl,bindingWeights:jl}}function hO(e,t,n,s,r){if(!t.weighted){let c=t.xy.length-t.xy.length%2,h=new Float64Array(c);for(let d=0;de.offsets[f])),mixes:Float64Array.from(Ct.map((f)=>e.mixes[f])),clamp:e.clamp}}function mO(e,t,n,s,r,i,o,a,l){let{timelines:u,name:c}=e,h=0,d=u.attachments.filter((v)=>v.deform!==null),f=u.attachments.filter((v)=>v.sequence!==null);if(f.length>0)t.note("sequence-timeline",`${f.length} sequence timeline(s): ${f.slice(0,3).map((v)=>`${v.skin}/${v.slot}/${v.attachment}`).join(", ")}${f.length>3?", …":""}`,c);if(u.drawOrder.length>0)t.note("draw-order-timeline",`${u.drawOrder.length} draw-order key(s)`,c);let m=(v)=>new Map(v.map((_)=>[_.name,_])),p=[];for(let v of m(u.bones).values()){let _=s.get(v.name);if(_===void 0)continue;for(let S of v.timelines){if(S.kind==="inherit"){t.note("inherit-timeline",`bone "${v.name}" keys its inherit mode`,c);continue}let M=cO[S.kind];p.push({bone:_,curve:Sr(S.keys,M.length),cursor:h++,fields:Int32Array.from(M.map((k)=>k[0])),multiply:Uint8Array.from(M.map((k)=>k[1]))})}}let y=[],g=[...m(u.slots).values()].flatMap((v)=>{let _=r.get(v.name);return _===void 0?[]:[{si:_,target:v}]}).sort((v,_)=>v.si-_.si);for(let{si:v,target:_}of g){if(!i[v].live)continue;for(let S of _.timelines)if(S.kind==="attachment"){let M=Int32Array.from(S.keys.map((k)=>l(v,k.name??null)));y.push({slot:v,curve:Sr(S.keys,0),cursor:h++,attachments:M,channels:null})}else if(S.kind==="rgba2"||S.kind==="rgb2")t.note("dark-colour-timeline",`slot "${_.name}" keys an ${S.kind} timeline`,c);else{let M=uO[S.kind];y.push({slot:v,curve:Sr(S.keys,M.length),cursor:h++,attachments:null,channels:Int32Array.from(M)})}}let x=o.map(()=>null);for(let v of o)if(v.kind==="ik"){let _=e.constraints.ik.find((S)=>S.name===v.name);if(_===void 0)continue;x[v.index]={constraint:v.index,curve:Sr(_.keys,2),cursor:h++,flags:Uint8Array.from(_.keys.map((S)=>FM(S.flags.bendPositive,S.flags.compress,S.flags.stretch)))}}else{let _=e.constraints.transform.find((S)=>S.name===v.name);if(_===void 0)continue;x[v.index]={constraint:v.index,curve:Sr(_.keys,Ct.length),cursor:h++,flags:null}}let b=d.map((v)=>{let _=a.skins.find((k)=>k.name===v.skin)?.attachments[v.slot]?.[v.attachment]?.geometry;if(_===void 0||_.kind==="region"||_.kind==="linkedmesh")throw new Gt(`deform "${v.skin}/${v.slot}/${v.attachment}" has no vertex geometry (readModel refuses it first)`);let S=v.deform,M=S.map((k)=>df(_.vertices,k));return{identity:`${v.skin}/${v.slot}/${v.attachment}`,cursor:h++,curve:nO(S),count:M[0].length,held:Float64Array.from(M.flat())}});return{name:c,duration:u.duration,deforms:b,bones:p,slots:y,constraints:x,cursors:h,events:u.events.length,eventKeys:Object.freeze(n?[]:u.events.map((v)=>Object.freeze({name:v.name,time:v.time,int:v.int,float:v.float,string:v.string,volume:v.volume??0,balance:v.balance??0})))}}var Ft=zl,Bl=2*_e,Yl=0,Vl=1,Hl=2,Ni=3,Df=4;function of(e){return e>180?e-360:e<=-180?e+360:e}function qw(e,t){return e/(t<0.7?0.25+t*0.642857:t)}var pO=(e)=>e<0?0:e>1?1:e;class NM{constructor(e){this.trackTime=0,this.time=0,this.fired=[],this.eventTime=-1,this.current=null,this.w=new Float64Array(ut),this.model=e;let t=e.boneNames.length,n=e.slots.length,s=e.constraints.length;this.locals=new Float64Array(t*cn),this.world=new Float64Array(t*ut),this.light=new Float64Array(n*4),this.shown=new Int32Array(n),this.vertices=new Float64Array(e.vertexCount),this.deform=new Float64Array(e.deformCount),this.deformed=new Uint8Array(e.attachments.length),this.cursors=new Int32Array(Math.max(1,e.cursors)).fill(-1),this.ikMix=new Float64Array(s),this.ikSoftness=new Float64Array(s),this.ikFlags=new Uint8Array(s),this.mixes=new Float64Array(s*6),this.changed=new Int32Array(e.scratch),this.inWorld=new Int32Array(e.scratch),this.changedMark=new Uint8Array(t),this.inWorldMark=new Uint8Array(t),this.below=new Uint8Array(t),this.visit=new Uint8Array(t)}get events(){return this.fired}setAnimation(e){this.current=this.model.animation(e),this.cursors.fill(-1),this.trackTime=0,this.time=0,this.eventTime=-1,this.fired.length=0}restore(e,t,n){if(!Number.isFinite(t))throw new Gt(`restore: track time ${t} is not finite`);if(!Number.isFinite(n))throw new Gt(`restore: animation time ${n} is not finite`);if(this.setAnimation(e),this.trackTime=t,!this.model.restoreEventsFromStart)this.eventTime=n;this.apply(n)}setupPose(){this.current=null,this.time=0,this.eventTime=-1,this.fired.length=0,this.locals.set(this.model.setup),this.hierarchy(),this.constraintValues(null,0),this.solveConstraints(),this.slotValues(null,0),this.deformValues(null,0)}apply(e){let t=this.current;if(t===null)throw new Gt("apply: no animation is set (setAnimation first)");if(!Number.isFinite(e))throw new Gt(`apply: the time ${e} is not finite`);this.collectEvents(t,e),this.time=e,this.boneTimelines(t,e),this.hierarchy(),this.constraintValues(t,e),this.solveConstraints(),this.slotValues(t,e),this.deformValues(t,e)}step(e){let t=this.current;if(t===null)throw new Gt("step: no animation is set (setAnimation first)");this.trackTime+=e,this.apply(t.duration===0?0:this.trackTime%t.duration)}collectEvents(e,t){let n=this.eventTime,s=tn)this.fired[i++]=r[o]}for(let o=0;o0:a.time>n))this.fired[i++]=a}this.fired.length=i,this.eventTime=t}boneTimelines(e,t){let n=this.locals,s=this.model.setup;n.set(s);let r=e.bones;for(let i=0;ir1){let D=Math.abs(y*b-g*x)/S;M=y,k=-x*D,T=x,A=y*D,O=u-Math.atan2(x,y)*Ft}else M=0,k=-g,T=0,A=b,O=u-90+Math.atan2(b,g)*Ft;let R=(O+d)*vt,P=(O+f+90)*vt,I=Math.cos(R)*c,F=Math.cos(P)*h,B=Math.sin(R)*c,C=Math.sin(P)*h;s[r+Oe]=M*I+k*B,s[r+we]=M*F+k*C,s[r+Ee]=T*I+A*B,s[r+ve]=T*F+A*C;break}default:{let S=u*vt,M=Math.cos(S),k=Math.sin(S),T=y*M+g*k,A=x*M+b*k,O=1/Math.sqrt(T*T+A*A),R=T*O,P=A*O,I=n.modes[e]===Ql&&y*b-g*x<0?-1:1,F=R,B=-P*I,C=P,D=R*I,N=(0+d)*vt,G=(90+f)*vt,z=Math.cos(N)*c,q=Math.cos(G)*h,L=Math.sin(N)*c,K=Math.sin(G)*h;s[r+Oe]=F*z+B*L,s[r+we]=F*q+B*K,s[r+Ee]=C*z+D*L,s[r+ve]=C*q+D*K}}s[r+Se]=y*a+g*l+v,s[r+ke]=x*a+b*l+_}constraintValues(e,t){let n=this.model.constraints;for(let s=0;s=0)h=l[c+Oe],d=l[c+we],f=l[c+Ee],m=l[c+ve],p=l[c+Se],y=l[c+ke];let g=e*ut,x=t*ut,b=e*cn,v=o.modes[e],_=0,S,M;if(v===Xl){let R=Math.abs(h*m-d*f)/Math.max(0.00001,h*h+f*f);d=-f*R,m=h*R,_=Math.atan2(f,h)*Ft;let P=h*m-d*f,I=l[x+Se]-p,F=l[x+ke]-y;if(Math.abs(P)<=0.00001)S=0,M=0;else S=(I*m-F*d)/P-a[b+bn],M=(F*h-I*f)/P-a[b+Qt]}else if(v===Wl)S=l[x+Se]-l[g+Se],M=l[x+ke]-l[g+ke];else{let R=h*m-d*f,P=l[x+Se]-p,I=l[x+ke]-y;if(Math.abs(R)<=0.00001)S=0,M=0;else S=(P*m-I*d)/R-a[b+bn],M=(I*h-P*f)/R-a[b+Qt]}let k=a[b+bt],T=a[b+en],A=-a[b+bs]-k+_+Math.atan2(M,S)*Ft;if(T<0)A+=180;a[b+bt]=k+of(A)*n;let O=o.lengths[e]*T;if((s||r)&&O>0.00001){let R=l[x+Se]-l[g+Se],P=l[x+ke]-l[g+ke],I=v===Ql||v===am?Math.sqrt(R*R+P*P):Math.sqrt(S*S+M*M);if(s&&IO){let F=(I/O-1)*n+1;if(a[b+en]=T*F,i===$f)a[b+Nt]=a[b+Nt]*F;else if(i===Of)a[b+Nt]=qw(a[b+Nt],F)}}}solveTwo(e,t,n,s){let r=this.model,i=this.locals,o=this.world,a=e.bones[0],l=e.bones[1];if(r.modes[a]!==Ii||r.modes[l]!==Ii)return!1;let u=(s&If)!==0,c=r.parents[a]*ut,h=a*ut,d=e.target*ut,f=a*cn,m=l*cn,p=o[c+Oe],y=o[c+we],g=o[c+Ee],x=o[c+ve],b=o[c+Se],v=o[c+ke],_=p*x-y*g,S=Math.abs(_)<=0.00001?0:1/_,M=i[f+bn],k=i[f+Qt],T=i[f+en],A=i[f+Nt],O=i[m+en],R=T,P=A,I=i[m+bn],F=i[m+Qt],B=Math.abs(Math.abs(T)-Math.abs(A))<=0.00001;if(!B||u)F=0;let C=o[h+Oe]*I+o[h+we]*F+o[h+Se]-b,D=o[h+Ee]*I+o[h+ve]*F+o[h+ke]-v,N=(C*x-D*y)*S,G=(D*p-C*g)*S,z=N-M,q=G-k,L=Math.sqrt(z*z+q*q),K=r.lengths[l]*Math.abs(O);if(L<0.00001)return this.solveOne(a,e.target,t,!1,u,0),i[m+bt]=0,i[m+Qt]=F,!0;C=o[d+Se]-b,D=o[d+ke]-v;let J=(C*x-D*y)*S,H=(D*p-C*g)*S;J-=M,H-=k;let pe=J*J+H*H,Ie=(s&OM)!==0?1:-1;if(n!==0){let te=n*(Math.abs(T)*(Math.abs(O)+1)*0.5),be=Math.sqrt(pe),ye=be-L-K*Math.abs(T)+te;if(ye>0){let ht=Math.min(1,ye/(te*2))-1,Vn=(ye-te*(1-ht*ht))/be;J-=Vn*J,H-=Vn*H,pe=J*J+H*H}}let Le,Me;if(B){K*=Math.abs(T);let te=(pe-L*L-K*K)/(2*L*K);if(te<-1)te=-1,Me=Math.PI*Ie;else if(te>1){if(te=1,Me=0,u){let ht=(Math.sqrt(pe)/(L+K)-1)*t+1;if(R*=ht,e.scaleY===$f)P*=ht;else if(e.scaleY===Of)P=qw(P,ht)}}else Me=Math.acos(te)*Ie;let be=L+K*te,ye=K*Math.sin(Me);Le=Math.atan2(H*be-J*ye,J*be+H*ye)}else{let te=Math.abs(T)*K,be=Math.abs(A)*K,ye=te*te,ht=be*be,Vn=ht-ye,Cs=-2*ht*L,As=ht*L*L+ye*pe-ye*ht,Rr=Cs*Cs-4*Vn*As,un=!1;if(Le=0,Me=0,Rr>=0){let Et=Math.sqrt(Rr);if(Cs<0)Et=-Et;Et=-(Cs+Et)*0.5;let _n=Et/Vn,Pr=As/Et,Sn=Math.abs(_n)=0){let Or=Math.sqrt($r)*Ie;Le=Math.atan2(H,J)-Math.atan2(Or,Sn),Me=Math.atan2(Or/Math.abs(A),(Sn-L)/Math.abs(T)),un=!0}}if(!un){let Et=_e,_n=L-te,Pr=0,Sn=(L-te)*(L-te),$r=0,Or=L+te,dm=0,ac=(L+te)*(L+te),lc=-te*L/(ye-ht);if(lc>=-1&&lc<=1){let ro=Math.acos(lc),io=te*Math.cos(ro)+L,oo=be*Math.sin(ro),ao=io*io+oo*oo;if(aoac)$r=ro,Or=io,dm=oo,ac=ao}if(pe<=(Sn+ac)*0.5)Le=Math.atan2(H,J)-Math.atan2(Pr*Ie,_n),Me=Et*Ie;else Le=Math.atan2(H,J)-Math.atan2(dm*Ie,Or),Me=$r*Ie}}let ue=(T<0?-1:1)*(A<0?-1:1),re=Math.atan2(F,I),ge=i[f+bt],xe=(Le-ue*re)*Ft+(T<0?180:0)-ge;i[f+bt]=ge+of(xe)*t,i[f+en]=R,i[f+Nt]=P;let Te=((Me+ue*re)*Ft-i[m+bs])*ue+(O<0?180:0),Be=i[m+bt];return i[m+Qt]=F,i[m+bt]=Be+of(Te-Be)*t,!0}solveTransform(e,t){let n=this.world,s=this.w,r=this.mixes,i=t*6,o=0;for(let a=0;ax?x:y}c=!0,gO(s,m,y,p)}}if(!c)continue;n[u+Oe]=s[Oe],n[u+we]=s[we],n[u+Ee]=s[Ee],n[u+ve]=s[ve],n[u+Se]=s[Se],n[u+ke]=s[ke],this.changed[o]=l,this.inWorld[o]=l,o++}if(o>0)this.repose(o,o)}sourceValue(e,t){let n=this.world,s=e.source*ut,r=e.offsets,i=n[s+Oe],o=n[s+we],a=n[s+Ee],l=n[s+ve];switch(t){case Yl:{let u=i*l-o*a,c=Math.atan2(a,i)*Ft+(u>0?r[Yl]:-r[Yl]);if(c<0)c+=360;return c}case Vl:return i*r[Vl]+o*r[Hl]+n[s+Se];case Hl:return a*r[Vl]+l*r[Hl]+n[s+ke];case Ni:return Math.sqrt(i*i+a*a)+r[Ni];case Df:return Math.sqrt(o*o+l*l)+r[Df];default:return(Math.atan2(l,o)-Math.atan2(a,i))*Ft-90+r[5]}}repose(e,t){let n=this.model,s=this.changed,r=this.changedMark,i=this.inWorldMark,o=this.below;for(let h=0;h=0&&s[r]===1&&(n[r]===1||this.changedMark[r]===1))s[e]=1;if(s[e]===1&&this.inWorldMark[e]===0)this.poseBone(e,!1)}localFromWorld(e){let t=this.model,n=this.world,s=this.locals,r=e*ut,i=e*cn,o=t.parents[e],a=o<0?Ii:t.modes[e],l=1,u=0,c=0,h=1,d=0,f=0;if(o>=0){let T=o*ut;l=n[T+Oe],u=n[T+we],c=n[T+Ee],h=n[T+ve],d=n[T+Se],f=n[T+ke]}let m=1/(l*h-u*c),p=n[r+Se]-d,y=n[r+ke]-f;s[i+bn]=p*(h*m)-y*(u*m),s[i+Qt]=y*(l*m)-p*(c*m),s[i+bs]=0;let g=n[r+Oe],x=n[r+we],b=n[r+Ee],v=n[r+ve];if(a===Wl){this.decompose(i,g,b,x,v);return}if(a===Xl){let T=1/(l*l+c*c),A=1/Math.abs(l*h-u*c);this.decompose(i,(l*g+c*b)*T,(l*b-c*g)*A,(l*x+c*v)*T,(l*v-c*x)*A),s[i+bt]=s[i+bt]+Math.atan2(c,l)*Ft;return}let _=h*m,S=u*m,M=c*m,k=l*m;this.decompose(i,_*g-S*b,k*b-M*g,_*x-S*v,k*v-M*x)}decompose(e,t,n,s,r){let i=this.locals,o=Math.sqrt(t*t+n*n),a=Math.sqrt(s*s+r*r);if(!(o>0.0001)){i[e+en]=0,i[e+Nt]=a,i[e+Ar]=0,i[e+bt]=a>0.00001?Math.atan2(r,s)*Ft-90:0;return}let l=Math.atan2(n,t)*Ft,u=t*r-s*n,c=Math.atan2(r,s)*Ft;i[e+bt]=l,i[e+en]=o,i[e+Nt]=u<0?-a:a;let h=u<0?-90:90,d=c-(l+h);d=d>180?d-360:d<-180?d+360:d,i[e+Ar]=a>0.00001?d:0}slotValues(e,t){let n=this.model.slots,s=this.light;for(let i=0;i_e)r-=Bl;else if(r<-_e)r+=Bl;r*=s;let i=Math.cos(r),o=Math.sin(r),a=e[Oe],l=e[we];e[Oe]=i*a-o*e[Ee],e[we]=i*l-o*e[ve],e[Ee]=o*a+i*e[Ee],e[ve]=o*l+i*e[ve];return}case Vl:e[Se]=e[Se]+(n-e[Se])*s;return;case Hl:e[ke]=e[ke]+(n-e[ke])*s;return;case Ni:case Df:{let r=t===Ni?Oe:we,i=t===Ni?Ee:ve,o=Math.sqrt(e[r]*e[r]+e[i]*e[i]);if(o===0)return;let a=1+(n-o)*s/o;e[r]*=a,e[i]*=a;return}default:{let r=Math.atan2(e[ve],e[we]),i=Math.atan2(e[Ee],e[Oe]),o=(n+90)*vt-(r-i);o=o>_e?o-Bl:o<-_e?o+Bl:o;let a=r+o*s,l=Math.sqrt(e[we]*e[we]+e[ve]*e[ve]);e[we]=Math.cos(a)*l,e[ve]=Math.sin(a)*l}}}function Kw(e,t){if(e.pages===null)throw new Y(`a ${e.spec} document does not state where each region sits on its page; build it with \`rigc build\``);let n=new Map(e.pages.map((i)=>[i.name,i])),s=new Map,r=new Map;for(let i=0;il.length===r.length&&l.every((u,c)=>u===r[c]));if(a===void 0)a=o?r:Object.freeze([...r]),s.lists.push(a),s.byRef.set(a,a);if(o)s.byRef.set(r,a);return a}function vO(e){let t=new Map;for(let n=0;n!0){let s=new Map;if(e.clips.length===0)return s;let r=new Map;for(let a=0;a!0){let{drawn:r,why:i}=T2(e.doc,t.shown,t.drawOrder,e.uv);if(r===null)throw new Y(`the page UVs are not posed: ${i}`);let o=null,a=null,l=null,u=t.clips.length===0?null:kO(t,e.active,s),[c,h,d,f]=n,m=[];for(let p=0;pe[t+r]});return Object.freeze(s)}function wO(e,t){let n=t(),s=e.generation,r=new WeakMap,i=()=>{if(t()!==n)throw Error(`LIVE_FRAME_STALE: borrowed generation ${s} was invalidated; call liveFrame() again`)},o=(u)=>{let c=r.get(u);if(c)return c;let h=new Proxy(Array.isArray(u)?[]:{},{get(d,f){if(i(),f==="buffer"||f==="set"||f==="fill"||f==="copyWithin"||f==="reverse"||f==="sort")throw Error(`LIVE_FRAME_READONLY: ${String(f)} does not expose the live backing store`);let m=Reflect.get(u,f,u);if(typeof m==="function"){if(ArrayBuffer.isView(u)&&f!==Symbol.iterator)throw Error(`LIVE_FRAME_READONLY: ${String(f)} is not part of the indexed live buffer interface`);return(...p)=>{i();let y=Reflect.apply(m,Array.isArray(u)?h:u,p);return y!==null&&typeof y==="object"?o(y):y}}return m!==null&&typeof m==="object"?o(m):m},set(){throw i(),Error("LIVE_FRAME_READONLY: live frame values cannot be assigned")},defineProperty(){throw i(),Error("LIVE_FRAME_READONLY: live frame values cannot be redefined")},deleteProperty(){throw i(),Error("LIVE_FRAME_READONLY: live frame values cannot be deleted")},preventExtensions(){throw i(),Error("LIVE_FRAME_READONLY: live frame objects cannot be reconfigured")},setPrototypeOf(){throw i(),Error("LIVE_FRAME_READONLY: live frame prototypes cannot be changed")},has(d,f){return i(),Reflect.has(u,f)},ownKeys(){return i(),Reflect.ownKeys(u)},getOwnPropertyDescriptor(d,f){if(i(),f==="length"&&Array.isArray(u))return{value:u.length,writable:!0,configurable:!1,enumerable:!1};let m=Reflect.getOwnPropertyDescriptor(u,f);return m?{configurable:!0,enumerable:m.enumerable,get:()=>Reflect.get(h,f)}:void 0}});return r.set(u,h),h},a=o(e),l=Gi.get(e);if(l)Gi.set(a,l);return a}class GM{model;pose;renderFrame={order:[]};live;order;tint;templates;colours;revision=0;previousColor=new Float64Array(4).fill(Number.NaN);drawn=0;epoch=0;constructor(e,t){this.model=t??DM(e.doc),this.pose=new NM(this.model),this.order=new Int32Array(this.model.slots.length),this.tint=new Float64Array(this.model.slots.length*4);let n=[],s=[];this.templates=this.model.attachments.map((i,o)=>{let a=i;if(a.skin===void 0||a.placeholder===void 0)throw Error(`RUNTIME_DRAW_IDENTITY: attachment ${o} on slot "${this.model.slots[i.slot].name}" needs resolved skin and placeholder from rig-c/runtime`);let l=this.model.slots[i.slot],u={...e.doc,slots:e.doc.slots.map((m,p)=>({...m,setup:p===i.slot?a.placeholder:null}))},c=jn(u),h=c.drawn.find((m)=>m.slot===l.name),d=Ff(e,c).order.find((m)=>m.slot===l.name)??null,f=h?.colour??[1,1,1,1];if(n.push(f),d){let m=Jw(this.pose.vertices,i.offset,i.count);if(d.kind==="region")d.corners=m;else d.vertices=m;d.tint=Jw(this.tint,i.slot*4,4)}return s.push(Object.freeze({slot:l.name,slotIndex:i.slot,attachment:i.name,skin:a.skin,placeholder:a.placeholder,kind:d?.kind??"none",region:d?.kind==="region"?d.region:null,page:d?.page??null,pma:d?.pma??!1,blend:l.blend,offset:i.offset,count:i.count,uvs:Object.freeze(d?.uvs??[]),triangles:Object.freeze(d?.kind==="mesh"?d.triangles:[]),dark:d?.dark?Object.freeze(d.dark):null,clip:null})),d}),this.colours=n;let r=this;this.live=Object.freeze({get generation(){return r.epoch},get count(){return r.drawn},drawOrder:this.order,vertices:this.pose.vertices,tint:this.tint,attachments:Object.freeze(s)}),Gi.set(this.live,this.renderFrame)}update(e,t,n,s=!0){if(s)this.pose.computeVertices();let r=!1;for(let o=0;o<4;o++){if(!Object.is(this.previousColor[o],t[o]))r=!0;this.previousColor[o]=t[o]}if(r)this.revision++;let i=0;for(let o=0;o{let r={...s,tint:s.tint.slice()};return s.kind==="region"?{...r,kind:"region",region:s.region,corners:s.corners.slice(),page:s.page,pma:s.pma,uvs:s.uvs}:{...r,kind:"mesh",vertices:s.vertices.slice(),page:s.page,pma:s.pma,uvs:s.uvs,triangles:s.triangles,sequence:s.sequence}})}}}function MO(e,t,n){let s=0;for(let c of e.order)s+=(c.kind==="region"?c.corners:c.vertices).length;let r=new Float64Array(s),i=new Float64Array(n.size*4),o=new Int32Array(e.order.length),a=0,l=e.order.map((c,h)=>{let d=c.kind==="region"?c.corners:c.vertices,f=n.get(c.slot);if(f===void 0)throw Error(`LIVE_FRAME_SLOT: drawn slot "${c.slot}" has no setup index`);r.set(d,a),i.set(c.tint,f*4),o[h]=h;let m=t.get(c.slot);if(!m)throw Error(`LIVE_FRAME_IDENTITY: drawn slot "${c.slot}" has no coherent identity`);let p={slot:c.slot,slotIndex:f,attachment:m.attachment,skin:m.skin,placeholder:null,kind:c.kind,region:c.kind==="region"?c.region:null,page:c.page,pma:c.pma,blend:c.blend,offset:a,count:d.length,uvs:c.uvs,triangles:c.kind==="mesh"?c.triangles:[],dark:c.dark??null,clip:c.clip??null};return a+=d.length,p}),u={generation:e.generation??0,count:l.length,drawOrder:o,vertices:r,tint:i,attachments:l};return Gi.set(u,e),u}var af=Object.freeze({wind:Object.freeze([1,0]),gravity:Object.freeze([0,1])});function Dl(e,t){let n=t?.ease;if(n===void 0)return 0;if(typeof n!=="number"||!Number.isFinite(n)||n<0)throw Error(`${e}: options.ease must be a finite number of seconds at or above 0, got ${typeof n==="number"?String(n):JSON.stringify(n)}`);return n}function TO(e){return Math.min(Math.max(e.elapsed/e.duration,0),1)}function CO(e){return e*e*(3-2*e)}function Fl(e,t){if(t===void 0)return;if(t===null||typeof t!=="object")throw Error(`${e}: options must be an object like { physics: 'carry' }, got ${JSON.stringify(t)}`);let n=t.physics;if(n===void 0||n==="carry"||n==="reset")return n;throw Error(`${e}: options.physics must be 'carry' or 'reset', got ${JSON.stringify(n)}`)}function lf(e,t){let n=new Set;if(e!==null){for(let[s,r]of e)if(t?.get(s)!==r)n.add(s)}if(t!==null){for(let[s,r]of t)if(e?.get(s)!==r)n.add(s)}return n}function Zw(e){return"first"in e?e.track.ctx:e.path.ctx}function AO(e){let t=new Set(e);return(n)=>t.has(n)}function lm(e,t){if(t.hides.includes(e))return!0;if(e.endsWith("_still")&&!(e in t.slots)){let n=e.slice(0,-6);if(n in t.slots||t.hides.includes(n))return!0}return!1}function EO(e,t){let n=new Set;for(let s of e.slots)if(s.name in t.slots||lm(s.name,t))n.add(s.name);return n}function Nf(e){let t=(e%360+360)%360;if(t>180)t-=360;return t}function cf(e,t){let n=new Set(e.bones.map((o)=>o.name)),s=(o)=>o!==void 0&&o.endsWith("_d")&&n.has(o.slice(0,-2))?o.slice(0,-2):o,r=e.bones.map((o)=>({...o,parent:s(o.parent)})),i=new Map;for(let o=0;oh.name===r[o].name);if(u===void 0)throw Error(`drawn bone ${JSON.stringify(r[o].name)} was not posed`);let c=Nf(a-Nf(Math.atan2(u.c,u.a)*180/Math.PI));r[o]={...r[o],rotation:c},i.set(r[o].name,c)}return i}function RO(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=e.filter((n)=>n.drawn!==void 0);return{name:e.map((n)=>n.name).join("+"),slots:Object.assign({},...e.map((n)=>n.slots)),hides:e.flatMap((n)=>n.hides),...t.length===0?{}:{drawn:Object.assign({},...t.map((n)=>n.drawn))}}}function uf(e,t,n){let s=new Set(Object.keys(n.slots)),r=e.slots.flatMap((b)=>{let v=n.slots[b.name];return v!==void 0?[{...b,setup:v}]:[]}),i=new Map(t.bones.map((b)=>[b.name,{a:b.a,b:b.b,c:b.c,d:b.d,worldX:b.worldX,worldY:b.worldY}])),o=r.length>0?jn({...e,slots:r,constraints:[]},{evaluate:()=>i,constraints:()=>[]}):null,a=new Map,l=new Map,u=new Map,c=new Map;if(o!==null){for(let b of o.slots)a.set(b[0],b);for(let b of o.shown)l.set(b.slot,b);for(let b of o.drawn)u.set(b.slot,b);for(let b of o.clips)c.set(b[0],b)}let h=new Map(t.shown.map((b)=>[b.slot,b])),d=new Map(t.drawn.map((b)=>[b.slot,b])),f=new Map(t.clips.map((b)=>[b[0],b])),m=(b)=>lm(b,n),p=t.slots.map((b)=>{let v=b[0];if(m(v))return[v,null,b[2],b[3],b[4],b[5],b[6],null,b[8]];let _=a.get(v);if(_!==void 0)return[v,_[1],b[2],b[3],b[4],b[5],b[6],_[7],b[8]];return b}),y=[],g=[],x=[];for(let b of t.drawOrder){if(m(b))continue;if(s.has(b)){let v=l.get(b);if(v!==void 0)y.push(v);let _=u.get(b);if(_!==void 0)g.push(_);let S=c.get(b);if(S!==void 0)x.push(S)}else{let v=h.get(b);if(v!==void 0)y.push(v);let _=d.get(b);if(_!==void 0)g.push(_);let S=f.get(b);if(S!==void 0)x.push(S)}}return{...t,slots:p,shown:y,drawn:g,clips:x}}var PO=4096,Qw=8,$O=1024;function e1(e){let t=new Map;for(let[n,s]of e.states)t.set(n,{...s});return{phase:e.phase,time:e.time,last:e.last,loop:e.loop,env:e.env,states:t}}function t1(e,t){if(e.phase=t.phase,e.time=t.time,e.last=t.last,t.loop===void 0)delete e.loop;else e.loop=t.loop;if(t.env===void 0)delete e.env;else e.env=t.env;e.states.clear();for(let[n,s]of t.states)e.states.set(n,{...s})}function Nl(e){if("first"in e){let s=e;return{kind:"track",steps:s.steps,latest:s.latest,refused:s.refused,trackTime:s.track.trackTime,last:s.track.last,ctx:e1(s.track.ctx)}}let t=e,n=t.mixer.tracks[0]??null;return{kind:"tracks",started:t.started,steps:t.steps,time:t.time,refused:t.refused,animationsChanged:t.mixer.animationsChanged,propertyIds:new Map(t.mixer.propertyIds),entry:n===null?null:{delay:n.delay,trackTime:n.trackTime,trackLast:n.trackLast,nextTrackLast:n.nextTrackLast,trackEnd:n.trackEnd,animationLast:n.animationLast,nextAnimationLast:n.nextAnimationLast,mixTime:n.mixTime,mixDuration:n.mixDuration,totalAlpha:n.totalAlpha,alpha:n.alpha,additive:n.additive,keepHold:n.keepHold,timelineMode:[...n.timelineMode],timelineHoldMix:[...n.timelineHoldMix],timelinesRotation:[...n.timelinesRotation]},ctx:e1(t.path.ctx)}}function Gl(e,t){if(t.kind==="track"){let r=e;r.steps=t.steps,r.latest=t.latest,r.refused=t.refused,r.track.trackTime=t.trackTime,r.track.last=t.last,t1(r.track.ctx,t.ctx);return}let n=e;n.started=t.started,n.steps=t.steps,n.time=t.time,n.refused=t.refused,n.mixer.animationsChanged=t.animationsChanged,n.mixer.propertyIds.clear();for(let[r,i]of t.propertyIds)n.mixer.propertyIds.set(r,i);let s=n.mixer.tracks[0]??null;if(s!==null&&t.entry!==null)s.delay=t.entry.delay,s.trackTime=t.entry.trackTime,s.trackLast=t.entry.trackLast,s.nextTrackLast=t.entry.nextTrackLast,s.trackEnd=t.entry.trackEnd,s.animationLast=t.entry.animationLast,s.nextAnimationLast=t.entry.nextAnimationLast,s.mixTime=t.entry.mixTime,s.mixDuration=t.entry.mixDuration,s.totalAlpha=t.entry.totalAlpha,s.alpha=t.entry.alpha,s.additive=t.entry.additive,s.keepHold=t.entry.keepHold,s.timelineMode=[...t.entry.timelineMode],s.timelineHoldMix=[...t.entry.timelineHoldMix],s.timelinesRotation=[...t.entry.timelinesRotation];t1(n.path.ctx,t.ctx)}class cm{get renderer(){return this.active}timeScale=1;color=[1,1,1,1];active;root;assets;meshBackend;view;source;read;skinName;seekStep;env=null;track=null;tracks=null;animation=null;loop=!0;trackCount=0;trackMode;beyondBase=!1;paused=!1;pose=null;rawPose=null;setup=null;seekCache=null;poseGeneration=0;runtimeModel=null;runtimeFrames=null;runtimeReadback=null;runtimeCompletionClock={trackTime:0};poserLabel="oracle: not selected";oracleOnly;liveChecks;liveDisposed=!1;cachedIdentity=null;cachedIdentityGen=-1;setList;setsByName;activeList=[];activeSet=null;touchedSets=new Map;drawnPose=null;carryPlant=!1;easing=null;lastStep=0;easePlant=null;adjustFn=null;physicsPatches=new Map;heldParameters=null;slotFilter=null;draws=()=>!0;adjustHook=(e,t)=>{if(this.easing!==null)this.applyEase(this.easing,e);else if(this.drawnPose!==null)for(let[n,s]of this.drawnPose)e.bone(n).rotation=s;if(this.adjustFn!==null)this.adjustFn(e,t)};listeners={event:new Set,complete:new Set};constructor(e,t,n={}){let s=t.document;if(this.read=s,n.poser!==void 0&&n.poser!=="auto"&&n.poser!=="oracle")throw Error(`poser must be auto or oracle, got ${String(n.poser)}`);if(this.oracleOnly=n.poser==="oracle",this.liveChecks=n.liveFrameChecks??!1,this.skinName=n.skin,this.view=n.skin===void 0?Tw(s.doc):kf(s.doc,n.skin),this.source=Kw(this.view,s.parsed),this.seekStep=n.seekStep??0.016666666666666666,this.trackMode=n.tracks===!0,!(this.seekStep>0))throw Error(`seekStep must be a positive number of seconds, got ${String(n.seekStep)}`);if(this.root=e,this.assets=t,this.setList=t.sets??[],this.setsByName=new Map(this.setList.map((r)=>[r.name,r])),this.meshBackend=n.meshBackend,this.adjustFn=n.adjust??null,n.slots!==void 0&&n.slots!==null)this.slots=n.slots;this.poseGeneration=0,this.cachedIdentity=null,this.active=this.create(n.mode??"dom"),this.selectRuntime()}get mode(){return this.active instanceof Rf?"canvas":"dom"}set mode(e){if(e!=="dom"&&e!=="canvas")throw Error(`mode must be 'dom' or 'canvas', got ${String(e)}`);if(e===this.mode)return;let t=this.active,n=this.create(e);n.pixelRatio=t.pixelRatio,n.clipping=t.clipping,t.dispose(),this.active=n,this.draw()}create(e){if(e==="canvas"){let n=new Rf(this.root,this.assets.pageImages);if(this.assets.stage)n.reserve(this.assets.stage);return n}if(e!=="dom")throw Error(`mode must be 'dom' or 'canvas', got ${String(e)}`);if(this.assets.regions==="none")throw Error("these assets were loaded with regions: 'none' (no region bitmaps, for the canvas mode only); the DOM mode needs a load with regions 'atlas', 'blob' or 'data'");let t=new CM(this.root,this.assets.regionImages,this.assets.pageImages,this.assets.atlasRegions);if(this.meshBackend)t.meshBackend=this.meshBackend;return t}get current(){return this.tracks!==null?this.tracks.current(0)?.animation??null:this.animation}get time(){return this.runtimeFrames?.pose.trackTime??this.tracks?.trackTime??this.track?.trackTime??0}play(e,t={}){let n=t.track??0,s=t.loop??!0,r=t.mix??0,i=t.alpha??1,o=t.additive??!1;this.paused=!1,this.clearSeekCache();let a=n===0&&r===0&&i===1&&!o;if(!a)this.beyondBase=!0;if(this.tracks===null&&a&&!this.trackMode){if(this.tryRuntimePlay(e,s))return;this.oracle("animation not supported by the runtime"),this.animation=e,this.loop=s,this.track=Ri(this.view,e,{loop:s,reset:"animation",adjust:this.adjustHook,clock:Ln}),this.setRawPose(this.initializeSingle(this.track)),this.applyEnvironment(this.track);return}let l=this.compose();if(l.setAnimation(n,e,{loop:s,mixDuration:r,alpha:i,additive:o}),this.trackCount=Math.max(this.trackCount,n+1),n===0)this.animation=e,this.loop=s;this.setRawPose(l.step(0))}queue(e,t={}){let n=t.track??0;this.beyondBase=!0,this.clearSeekCache();let s=this.compose();s.addAnimation(n,e,{loop:t.loop??!0,mixDuration:t.mix??0,delay:t.delay??0,alpha:t.alpha??1,additive:t.additive??!1}),this.trackCount=Math.max(this.trackCount,n+1),this.setRawPose(s.step(0))}clear(e=0,t={}){this.beyondBase=!0,this.clearSeekCache();let n=this.compose();n.setEmptyAnimation(e,t.mix??0),this.trackCount=Math.max(this.trackCount,e+1),this.setRawPose(n.step(0))}queueClear(e=0,t={}){this.beyondBase=!0,this.clearSeekCache();let n=this.compose();n.addEmptyAnimation(e,t.mix??0,t.delay??0),this.trackCount=Math.max(this.trackCount,e+1),this.setRawPose(n.step(0))}setAlpha(e,t){this.beyondBase=!0,this.clearSeekCache();let n=this.compose();n.setAlpha(e,t),this.setRawPose(n.step(0))}entry(e=0){if(this.runtimeFrames!==null){if(e!==0||this.animation===null)return null;let n=this.runtimeFrames.pose;return{animation:this.animation,loop:this.loop,trackTime:n.trackTime,animationTime:n.time,duration:this.runtimeFrames.model.animation(this.animation).duration,alpha:1,additive:!1}}if(this.tracks!==null){let n=this.tracks.current(e);return n===null?null:{animation:n.animation,loop:n.loop,trackTime:n.trackTime,animationTime:n.animationTime,duration:n.duration,alpha:n.alpha,additive:n.additive}}let t=this.track;if(e!==0||t===null)return null;return{animation:this.animation,loop:this.loop,trackTime:t.trackTime,animationTime:t.animationTime,duration:t.duration,alpha:1,additive:!1}}get composed(){return this.tracks!==null}compose(){if(this.oracle("track composition"),this.tracks!==null)return this.tracks;this.clearSeekCache();let e=nf(this.view,{reset:"animation",adjust:this.adjustHook,clock:Ln}),t=this.track,n=t?.trackTime??0;if(t!==null&&this.animation!==null)e.setAnimation(0,this.animation,{loop:this.loop,mixDuration:0}),this.trackCount=1;if(this.tracks=e,this.track=null,this.setRawPose(e.start()),this.applyPhysicsParameters(e),this.applyEnvironment(e),n>0)this.stepTo(n);return e}setRawPose(e){this.rawPose=e,this.heldParameters=null;let t=this.shownSet();this.pose=t===null?e:uf(this.view,e,t),this.poseGeneration++,this.cachedIdentity=null}setPhysicsParameters(e,t){let n=this.requirePhysicsTrack("setPhysicsParameters",e);n.setPhysicsParameters(e,t);let s=n.readPhysicsParameters(e).override;if(s!==null)this.physicsPatches.set(e,s);this.clearSeekCache()}readPhysicsParameters(e){let t=this.requirePhysicsTrack("readPhysicsParameters",e).readPhysicsParameters(e);if(this.heldParameters===null)return t;let n=this.heldParameters.get(e)?.effective??null;return{override:t.override,effective:n===null?null:{...n}}}clearPhysicsParameters(e){this.requirePhysicsTrack("clearPhysicsParameters",e).clearPhysicsParameters(e),this.physicsPatches.delete(e),this.clearSeekCache()}requirePhysicsTrack(e,t){let n=this.stepper();if(n===null)throw Error(`${e}(${JSON.stringify(t)}) before play: no live track`);return n}readParameters(e){return new Map(this.view.constraints.filter((t)=>t.kind==="physics").map((t)=>[t.name,e.readPhysicsParameters(t.name)]))}applyPhysicsParameters(e){for(let[t,n]of this.physicsPatches)e.setPhysicsParameters(t,n)}initializeSingle(e){return this.applyPhysicsParameters(e),e.first}environment(e){if(e===null)this.env=null,this.clearSeekCache(),this.stepper()?.setEnvironment(af);else if(e!==void 0){this.clearSeekCache();let t=this.stepper();if(t)t.setEnvironment(e),this.env=t.environment;else{let n=this.env??af;this.env={wind:e.wind??n.wind,gravity:e.gravity??n.gravity}}}return this.stepper()?.environment??this.env??af}moved(e){if(this.runtimeFrames!==null&&Number.isFinite(e.x??0)&&Number.isFinite(e.y??0)&&Number.isFinite(e.rotation??0))return;let t=this.stepper();if(!t)return;let n=e.x??0,s=e.y??0;if(n!==0||s!==0)t.physicsTranslate(n,s);if(e.rotation)t.physicsRotate(0,0,e.rotation)}pause(){this.paused=!0}resume(){this.paused=!1}seek(e){if(this.animation===null)throw Error("seek before play: no animation is open");if(!(e>=0)||!Number.isFinite(e))throw Error(`seek time must be a finite time at or above 0, got ${String(e)}`);if(this.beyondBase)throw Error("seek is defined for a single animation on track 0; after a mix, another track, a queue or a clear the player cannot replay to a time — step it forward with frame/advance instead");if(this.runtimeFrames!==null){let l=Math.floor(e/this.seekStep),u=0;for(let h=0;h0)u+=c;this.runtimeFrames.pose.trackTime=u,this.applyRuntimeTime();return}this.easing=null;let t=this.ensureSeekCache(),n=this.tracks??this.track,s=t.exact.get(e);if(s!==void 0){Gl(n,s.state),this.rawPose=s.rawPose,this.pose=s.pose,this.heldParameters=s.parameters,this.poseGeneration++,this.cachedIdentity=null;return}let r=Math.floor(e/this.seekStep);while(t.frontierSteps0)this.rawPose=n.step(a),i=this.readParameters(n);if(this.rawPose!==null)this.setRawPose(this.rawPose);if(this.heldParameters=i,this.rawPose!==null&&this.pose!==null){if(t.exact.size>=$O){let l=t.exact.keys().next().value;if(l!==void 0)t.exact.delete(l)}t.exact.set(e,{state:Nl(n),rawPose:this.rawPose,pose:this.pose,parameters:i})}}clearSeekCache(){this.seekCache=null}ensureSeekCache(){let e=this.tracks!==null?"tracks":"track";if(this.seekCache!==null&&this.seekCache.mode===e)return this.seekCache;if(this.tracks===null&&this.track===null)this.reopen();let t,n;if(e==="tracks"){let r=nf(this.view,{reset:"animation",adjust:this.adjustHook,clock:Ln});r.setAnimation(0,this.animation,{loop:this.loop,mixDuration:0}),n=r.start(),this.applyPhysicsParameters(r),this.applyEnvironment(r),t=r}else{let r=Ri(this.view,this.animation,{loop:this.loop,reset:"animation",adjust:this.adjustHook,clock:Ln});n=this.initializeSingle(r),this.applyEnvironment(r),t=r}let s=new Map;return s.set(0,{state:Nl(t),rawPose:n,parameters:this.readParameters(t)}),this.seekCache={mode:e,frontier:t,frontierSteps:0,grid:s,exact:new Map},this.seekCache}reopen(){if(this.tracks!==null){let e=nf(this.view,{reset:"animation",adjust:this.adjustHook,clock:Ln});e.setAnimation(0,this.animation,{loop:this.loop,mixDuration:0}),this.trackCount=1,this.tracks=e,this.setRawPose(e.start()),this.applyPhysicsParameters(e),this.applyEnvironment(e);return}this.track=Ri(this.view,this.animation,{loop:this.loop,reset:"animation",adjust:this.adjustHook,clock:Ln}),this.setRawPose(this.initializeSingle(this.track)),this.applyEnvironment(this.track)}stepper(){return this.oracle("oracle track operation"),this.tracks??this.track}applyEnvironment(e){if(this.env!==null)e.setEnvironment(this.env)}stepTo(e){let t=this.tracks??this.track,n=Math.floor(e/this.seekStep);for(let r=0;r0)this.rawPose=t.step(s);if(this.rawPose!==null)this.setRawPose(this.rawPose)}on(e,t){let n=this.listeners[e];return n.add(t),()=>n.delete(t)}frame(e){this.advance(e),this.draw()}advance(e){if(this.runtimeFrames!==null){let o=e*this.timeScale;if(this.paused||!(o>0))return;if(!Number.isFinite(o))throw Error(`advance step must be finite, got ${String(o)}`);let a=this.runtimeFrames.pose.trackTime,l=this.runtimeFrames.model.animations.get(this.animation).duration;this.runtimeFrames.pose.trackTime+=o,this.lastStep=o,this.applyRuntimeTime();let u=this.runtimeCompletionClock;if(this.listeners.event.size>0){let c=this.runtimeFrames.pose.events.slice();for(let h of c){let d={name:h.name,time:h.time,int:h.int,float:h.float,string:h.string,track:0};for(let f of this.listeners.event)f(d)}}if(this.listeners.complete.size>0){let c=u.trackTime;if(this.loop?l===0||Math.floor(c/l)>Math.floor(a/l):a=l){let d={animation:this.animation,track:0};for(let f of this.listeners.complete)f(d)}}return}if(this.pose===null)return;let t=e*this.timeScale;if(this.paused||!(t>0))return;if(this.lastStep=t,this.easing!==null)this.advanceEase(this.easing,t);let n=this.tracks;if(n!==null){let o=[];for(let l=0;le.name)}setSet(e,t){if(this.setList.length===0)throw Error(`cannot setSet(${JSON.stringify(e)}): this model has no sets.json`);let n=Fl("setSet",t),s=Dl("setSet",t);this.activate(e===null?[]:[this.namedSet(e)],n,s)}setSets(e,t){if(this.setList.length===0)throw Error(`cannot setSets(${JSON.stringify(e)}): this model has no sets.json`);let n=Fl("setSets",t),s=Dl("setSets",t),r=e.map((i)=>this.namedSet(i));for(let i=0;ii!==r),n,s)}namedSet(e){let t=this.setsByName.get(e);if(t===void 0)throw Error(`no set named ${JSON.stringify(e)} in sets.json (available: ${this.setList.map((n)=>n.name).join(", ")})`);return t}reposeDrawn(){let e=this.tracks??this.track;if(e!==null&&this.pose!==null){this.setRawPose(e.step(0));return}this.setRawPose(this.drawnSetup())}drawnSetup(){let e=this.setup??(this.setup=jn(this.view));if(this.drawnPose===null)return e;return jn({...this.view,bones:this.view.bones.map((t)=>{let n=this.drawnPose?.get(t.name);return n===void 0?t:{...t,rotation:n}})})}touched(e){let t=this.touchedSets.get(e.name);if(t===void 0)t=EO(this.view,e),this.touchedSets.set(e.name,t);return t}handOverPhysics(e,t){let n=this.tracks??this.track;if(n===null||this.pose===null||this.rawPose===null)return;if(e.size===0)return;let s=new Map(this.view.bones.map((m)=>[m.name,m.parent])),r=(m)=>{for(let p=m;p!==void 0;p=s.get(p))if(e.has(p))return p;return},i=Zw(n),o=[];for(let m of this.view.constraints){if(m.kind!=="physics")continue;let p=m.record?.bone,y=p===void 0?void 0:r(p);if(y===void 0)continue;let g=i.states.get(m.name);if(g===void 0||g.pending)continue;o.push({name:m.name,anchor:y})}if(o.length===0)return;if(t==="reset"){for(let{name:m}of o){let p=i.states.get(m);p.remaining=0,p.lastTime=i.time,p.pending=!0,p.xOffset=p.xLag=p.xVelocity=0,p.yOffset=p.yLag=p.yVelocity=0,p.rotateOffset=p.rotateLag=p.rotateVelocity=0,p.scaleOffset=p.scaleLag=p.scaleVelocity=0}return}let a=new Set(o.map((m)=>m.anchor)),l=(m)=>{let p=new Map;for(let y of m.bones)if(a.has(y.name))p.set(y.name,y);return p},u=l(this.rawPose),c=Nl(n),h=l(n.step(0));Gl(n,c);let d=new Map;for(let m of a){let p=u.get(m),y=h.get(m);if(p===void 0||y===void 0)continue;if(this.carryPlant){d.set(m,[1,0,0,1,0,0]);continue}let g=p.a*p.d-p.b*p.c;if(!Number.isFinite(g)||g===0)continue;let x=p.d/g,b=-p.b/g,v=-p.c/g,_=p.a/g,S=y.a*x+y.b*v,M=y.a*b+y.b*_,k=y.c*x+y.d*v,T=y.c*b+y.d*_;d.set(m,[S,M,k,T,y.worldX-(S*p.worldX+M*p.worldY),y.worldY-(k*p.worldX+T*p.worldY)])}let f=Zw(n).states;for(let{name:m,anchor:p}of o){let y=d.get(p),g=f.get(m);if(y===void 0||g===void 0)continue;let[x,b,v,_,S,M]=y,k=g.ux;g.ux=x*k+b*g.uy+S,g.uy=v*k+_*g.uy+M;let T=g.cx;g.cx=x*T+b*g.cy+S,g.cy=v*T+_*g.cy+M;let A=g.tx;g.tx=x*A+b*g.ty,g.ty=v*A+_*g.ty}}shownSet(){let e=this.easing;return e===null||e.swapped?this.activeSet:e.fromSet}easedLocal(e,t,n,s){let r=t??s,i=n??s,o=TO(e),a=this.easePlant==="overshoot"?o<1?1.2*o:1:CO(o);return r+Nf(i-r)*a}applyEase(e,t){for(let n of e.bones.keys())e.clip.set(n,t.bone(n).rotation);if(this.drawnPose!==null){for(let[n,s]of this.drawnPose)if(!e.bones.has(n))t.bone(n).rotation=s}for(let[n,{from:s,to:r}]of e.bones)t.bone(n).rotation=this.easedLocal(e,s,r,e.clip.get(n))}startEase(e,t,n,s){if((this.tracks??this.track)===null||this.pose===null)return!1;let i=this.drawnPose,o=n===void 0?null:cf(this.view,n),a=this.easing,l=lf(i,o);if(a!==null)for(let h of a.bones.keys())l.add(h);let u=new Map;for(let h of l){let d=o?.get(h)??null,f,m=a?.bones.get(h);if(a!==null&&m!==void 0)f=a.elapsed>0?this.easedLocal(a,m.from,m.to,a.clip.get(h)):m.from;else f=i?.get(h)??null;if(f===d)continue;u.set(h,{from:f,to:d})}if(u.size===0)return!1;let c={duration:e,elapsed:0,bones:u,clip:new Map,fromSet:t,swapped:!1,physics:s};if(this.easePlant==="swap-at-0"||this.swapsNow(0,this.lastStep/e))c.swapped=!0;if(this.easing=c,this.drawnPose=o,s==="reset")this.handOverPhysics(new Set(u.keys()),"reset");return this.reposeDrawn(),!0}swapsNow(e,t){if(e>=0.5)return!0;return t>e&&0.5-e=e.duration)this.easing=null;else if(!e.swapped&&this.swapsNow(e.elapsed/e.duration,(e.elapsed+t)/e.duration))e.swapped=!0;if(e.physics==="carry")this.handOverPhysics(new Set(e.bones.keys()),"carry")}activate(e,t,n=0){this.oracle("attachment sets");for(let l=0;le.includes(l)),this.activeSet=RO(this.activeList),this.clearSeekCache();let i=this.activeSet?.drawn;if(n>0&&this.startEase(n,r,i,t))return;let o=this.easing;if(o!==null){this.easing=null;let l=this.drawnPose;this.drawnPose=i===void 0?null:cf(this.view,i);let u=lf(l,this.drawnPose);for(let c of o.bones.keys())u.add(c);if(t!==void 0)this.handOverPhysics(u,t);this.reposeDrawn();return}if(i!==s&&!(i===void 0&&s===void 0)){let l=this.drawnPose;if(this.drawnPose=i===void 0?null:cf(this.view,i),t!==void 0)this.handOverPhysics(lf(l,this.drawnPose),t);this.reposeDrawn();return}let a=this.rawPose??(this.setup??(this.setup=jn(this.view)));this.rawPose=a,this.pose=this.activeSet===null?a:uf(this.view,a,this.activeSet),this.poseGeneration++,this.cachedIdentity=null}get slots(){return this.slotFilter}set slots(e){if(e===null){this.slotFilter=null,this.draws=()=>!0,this.poseGeneration++,this.cachedIdentity=null;return}if(typeof e==="function"){this.slotFilter=e,this.draws=e,this.poseGeneration++,this.cachedIdentity=null;return}if(!Array.isArray(e))throw Error(`slots must be an array of slot names, a function, or null, got ${typeof e}`);let t=new Set(this.read.doc.slots.map((r)=>r.name)),n=e.filter((r)=>!t.has(r));if(n.length>0)throw Error(`no slot named ${n.map((r)=>JSON.stringify(r)).join(", ")} in this document (slots: ${[...t].join(", ")})`);let s=new Set(e);this.slotFilter=[...e],this.draws=(r)=>s.has(r),this.poseGeneration++,this.cachedIdentity=null}get adjust(){return this.adjustFn}set adjust(e){if(e!==null&&typeof e!=="function")throw Error(`adjust must be a function or null, got ${typeof e}`);this.oracle("local adjustment"),this.adjustFn=e,this.clearSeekCache(),this.repose()}repose(){if(this.runtimeFrames!==null){this.applyRuntimeTime();return}this.clearSeekCache();let e=this.tracks??this.track;if(e===null||this.pose===null)return;this.setRawPose(e.step(0))}bone(e){let t=this.posed();for(let n of t.bones){if(n.name!==e)continue;return{name:e,active:n.active,x:n.worldX,y:n.worldY,a:n.a,b:n.b,c:n.c,d:n.d,rotationX:n.rotationX,rotationY:n.rotationY,scaleX:n.scaleX,scaleY:n.scaleY}}throw Error(`no bone named ${JSON.stringify(e)} in this document (bones: ${t.bones.map((n)=>n.name).join(", ")})`)}bounds(){let e=this.runtimeFrames!==null?this.posedFrame():this.pose===null?Ff(this.source,this.posed(),this.color,this.draws):this.posedFrame(),t=1/0,n=1/0,s=-1/0,r=-1/0;for(let i of e.order){let o=i.kind==="region"?i.corners:i.vertices,a=-1/0,l=-1/0,u=1/0,c=1/0;if(i.clip&&!i.clip.inverse){let h=i.clip.polygon;a=1/0,l=1/0,u=-1/0,c=-1/0;for(let d=0;du)u=h[d];if(h[d+1]c)c=h[d+1]}}for(let h=0;hs)s=d;if(fr)r=f}}if(t===1/0)return null;return{x:t,y:n,width:s-t,height:r-n}}posed(){if(this.runtimeFrames!==null&&this.animation!==null){if(this.runtimeReadback===null){let e=Ri(this.view,this.animation,{loop:this.loop,reset:"animation",clock:Ln});this.runtimeReadback=this.time>0?e.step(this.time):e.first}return this.runtimeReadback}if(this.pose!==null)return this.pose;if(this.setup===null)this.setup=jn(this.view);return this.activeSet===null?this.setup:uf(this.view,this.setup,this.activeSet)}get poser(){return this.runtimeFrames!==null?"runtime":this.poserLabel==="runtime"?"oracle: no runtime animation is active":this.poserLabel}selectRuntime(){if(this.runtimeModel=null,this.oracleOnly){this.poserLabel="oracle: explicitly selected";return}try{this.runtimeModel=DM(this.view),this.poserLabel=this.trackMode?"oracle: track composition":this.adjustFn!==null?"oracle: local adjustment":"runtime"}catch(e){if(!(e instanceof zi))throw e;this.poserLabel=`oracle: ${e.message}`}}tryRuntimePlay(e,t){if(this.runtimeModel===null)return!1;let n=this.trackMode?"track composition":this.adjustFn!==null?"local adjustment":this.activeSet!==null?"attachment sets":this.easing!==null?"set easing":this.env!==null?"environment configuration":null;if(n!==null)return this.poserLabel=`oracle: ${n}`,!1;if(!this.runtimeModel.animations.has(e)){let r=this.runtimeModel.refused.find((i)=>i.animation===e);if(r)this.poserLabel=`oracle: ${new zi(r.missing).message}`;return!1}let s=this.runtimeFrames??new GM(this.source,this.runtimeModel);return s.pose.setAnimation(e),s.pose.apply(0),this.runtimeFrames=s,this.runtimeCompletionClock={trackTime:0},this.animation=e,this.loop=t,this.track=null,this.tracks=null,this.pose=null,this.rawPose=null,this.poserLabel="runtime",this.poseGeneration++,this.cachedIdentity=null,this.runtimeReadback=null,s.update(this.poseGeneration,this.color,this.draws),!0}applyRuntimeTime(){let e=this.runtimeFrames,t=e.model.animations.get(this.animation).duration,n=e.pose.trackTime;this.runtimeCompletionClock.trackTime=n,e.pose.apply(t===0?0:this.loop?n%t:Math.min(n,t)),this.poseGeneration++,this.cachedIdentity=null,this.runtimeReadback=null,e.update(this.poseGeneration,this.color,this.draws)}oracle(e){if(this.runtimeFrames===null||this.animation===null)return;let t=this.runtimeFrames.pose.trackTime,n=this.poseGeneration;if(this.runtimeFrames=null,this.runtimeReadback=null,this.poserLabel==="runtime")this.poserLabel=`oracle: ${e}`;if(this.track=Ri(this.view,this.animation,{loop:this.loop,reset:"animation",adjust:this.adjustHook,clock:Ln}),this.setRawPose(this.track.first),t>0)this.setRawPose(this.track.step(t));this.poseGeneration=n,this.applyEnvironment(this.track)}liveFrame(){if(this.liveDisposed)throw Error("LIVE_FRAME_DISPOSED: cannot borrow a frame after dispose");let e;if(this.runtimeFrames!==null)this.runtimeFrames.update(this.poseGeneration,this.color,this.draws,!1),e=this.runtimeFrames.live;else{let t=new Map(this.slotIdentity().slots.map((n)=>[n.slot,n]));e=MO(this.posedFrame(),t,this.source.slotIndex)}return this.liveChecks?this.checkedFrame(e):e}checkedFrame(e){let t=this.poseGeneration,n=this.runtimeFrames,s=n?.revision;return wO(e,()=>this.poseGeneration===t&&(n===null||n.revision===s)?t:-1)}get generation(){return this.poseGeneration}posedFrame(e){let t=e===void 0?this.draws:e===null?()=>!0:typeof e==="function"?e:AO(e);if(this.runtimeFrames!==null)this.runtimeFrames.update(this.poseGeneration,this.color,this.draws,!1);let n=this.runtimeFrames!==null?this.runtimeFrames.snapshot(t):this.pose===null?{order:[]}:Ff(this.source,this.pose,this.color,t);return Object.defineProperty(n,"generation",{value:this.poseGeneration,enumerable:!1,configurable:!0}),n}slotIdentity(){if(this.cachedIdentity!==null&&this.cachedIdentityGen===this.poseGeneration)return this.cachedIdentity;let e=this.setup??(this.setup=jn(this.view)),t=this.posed(),n=this.runtimeFrames!==null?t:this.rawPose??e,s=new Map(t.shown.map((u)=>[u.slot,u])),r=new Set(e.shown.map((u)=>u.slot)),i=new Map(n.slots.map((u)=>[u[0],u])),o=[],a=this.shownSet();for(let u=0;u{if(s===null)return;let i=this.view.animations.find((l)=>l.name===s);if(i===void 0)return;let o=i.timelines.slots.find((l)=>l.name===e);if(o===void 0)return;let a;for(let l of o.timelines){if(l.kind!=="attachment")continue;let u=null;for(let c of l.keys)if(c.time<=r)u=c;else break;if(u!==null)a=u.name===null||u.name===void 0}return a};if(this.tracks!==null){let s=!1;for(let r=0;r0)for(let[s,r,i,o,a]of e.events){let l={name:s,time:r,int:i,float:o,string:a,track:0};for(let u of this.listeners.event)u(l)}if(this.listeners.complete.size>0){let{duration:s,trackTime:r}=n,i=s>0?Math.floor(r/s):1/0,o=s>0?Math.floor(t/s):-1/0;if(this.loop?i>0&&i>o:t=s){let a={animation:this.animation,track:0};for(let l of this.listeners.complete)l(a)}}}dispatch(e,t,n){let s=[];for(let i=0;ii!==null&&o!==null&&i.animation===o.animation&&i.loop===o.loop&&o.trackTime>=i.trackTime;if(this.listeners.event.size>0&&e.events.length>0){let i=[],o=0;for(let c=0;cp.name===h.animation)?.timelines.events??[];if(m.length>0){let p=r(d,h)?d.animationTime:-1;f=jf(m,p,h.animationTime,void 0,h.animationTime0)for(let i=0;i0?Math.floor(o.trackTime/l):1/0,c=l>0?Math.floor(a.trackTime/l):-1/0;if(!(o.loop?u>0&&u>c:a.trackTime=l))continue;let d={animation:o.animation,track:i};for(let f of this.listeners.complete)f(d)}}}var Ts=Object.freeze([]),LM=new WeakSet,UM=new WeakSet,OO=["slot","slotIndex","attachment","skin","placeholder","kind","region","page","pma","blend","offset","count"];function jM(e){if(UM.has(e))return!0;if(!Object.isFrozen(e))return!1;let t=Object.getOwnPropertyDescriptors(e);if(!OO.every((n)=>{let s=t[n];return s&&"value"in s&&(s.value===null||!["object","function"].includes(typeof s.value))}))return!1;return UM.add(e),!0}function Ms(e,t,n,s){if(e&&typeof e==="object"&&LM.has(e))return;if(!e||typeof e!=="object"||!Number.isInteger(e.length)||e.length<0)throw Error(`${t}: live ${s===void 0?n:`slot "${s}" ${n}`} needs an indexed buffer with nonnegative integer length`);let r=Object.getOwnPropertyDescriptor(e,"length");if(r&&"value"in r&&!r.writable&&!r.configurable&&Object.isFrozen(e))LM.add(e)}var so=class{constructor(e){this.count=e}count;source=Ts;offset=0};function to(e){return e instanceof so?e.source:e}function no(e){return e instanceof so?e.offset:0}function Er(e){return e instanceof so?e.count:e?e.length:-1}var IO=class{constructor(e="PixiRenderer"){this.owner=e}owner;order=[];rows=[];validated=new WeakSet;read(e){e.generation;let{drawOrder:t,vertices:n,tint:s,attachments:r,count:i}=e,o=this.owner;if(Ms(t,o,"drawOrder"),Ms(n,o,"vertices"),Ms(s,o,"tint"),!Number.isInteger(i)||i<0||i>t.length)throw Error(`${o}: live frame count=${i} needs an integer in 0..${t.length}`);for(let a=0;an.length||c.slotIndex*4+4>s.length)throw Error(`${o}: live slot "${c.slot}" has invalid vertex span ${c.offset}+${c.count} or tint slotIndex=${c.slotIndex}`);let h=this.rows[a];if(!h||h.slot.kind!==c.kind||h.points.count!==c.count){let f=new so(c.count),m=new so(4),p={slot:c.slot,blend:c.blend,tint:m,page:c.page??"",pma:c.pma,uvs:Ts};h={slot:c.kind==="region"?{...p,kind:"region",region:c.region??"",corners:f}:{...p,kind:"mesh",vertices:f,triangles:Ts},points:f,tint:m},this.rows[a]=h}h.points.source=n,h.points.offset=c.offset,h.tint.source=s,h.tint.offset=c.slotIndex*4;let d=h.slot;if(d.slot=c.slot,d.blend=c.blend,d.page=c.page??"",d.pma=c.pma,d.uvs=c.uvs,d.dark=c.dark??void 0,d.clip=c.clip??void 0,d.kind==="region")d.region=c.region??"";else d.triangles=c.triangles;this.order[a]=d}return this.order.length=i,this.order}release(){for(let e of this.rows)if(e.points.source=Ts,e.tint.source=Ts,e.slot.uvs=Ts,e.slot.dark=void 0,e.slot.clip=void 0,e.slot.kind==="mesh")e.slot.triangles=Ts}};function BO(e){return JSON.stringify([e.slotIndex,e.slot,e.skin,e.placeholder,e.attachment,e.kind,e.page,e.region])}function DO(e){let t={slot:e.slot,z:e.slotIndex,blend:e.blend,tint:[1,1,1,1]};return e.kind==="region"?{...t,kind:"region",region:e.region??"",corners:[],page:e.page??"",pma:e.pma,uvs:Array.from(e.uvs)}:{...t,kind:"mesh",page:e.page??"",pma:e.pma,vertices:[],uvs:Array.from(e.uvs),triangles:Array.from(e.triangles),sequence:0}}function WM(e,t){if(ArrayBuffer.isView(t)&&t instanceof Float64Array)e.set(t);else for(let n=0;n=Math.max(64,e.attachments.length*2))this.checkedTemplates.clear();this.checkedTemplates.set(d,c)}if(jM(u))this.immutable.add(u),this.templates.set(u,c)}let h=this.rows[l];if(!h)h={template:c,offset:u.offset,count:u.count,tintOffset:u.slotIndex*4},this.rows[l]=h;if(h.template=c,h.offset=u.offset,h.count=u.count,h.tintOffset=u.slotIndex*4,u.dark===null)h.dark=void 0;else{let d=h.darkBuffer??=[];d.length=u.dark.length;for(let f=0;f=1)return 1;return e}var NO={Normal:"normal",Additive:"add",Multiply:"multiply",Screen:"screen"};function GO(e,t,n){let s=tn(e[t]),r=tn(e[t+1]),i=tn(e[t+2]),o=tn(e[t+3]),a=tn(n[0]),l=tn(n[1]),u=tn(n[2]);return[s-a,0,0,0,a,0,r-l,0,0,l,0,0,i-u,0,u,0,0,0,o,0]}function LO(e){let t=0,n=e.length/2;for(let s=0;s=Math.min(e,n)-0.000000001&&r<=Math.max(e,n)+0.000000001&&i>=Math.min(t,s)-0.000000001&&i<=Math.max(t,s)+0.000000001}function UO(e,t,n,s,r,i,o,a){let l=eo(r,i,o,a,e,t),u=eo(r,i,o,a,n,s),c=eo(e,t,n,s,r,i),h=eo(e,t,n,s,o,a);if((l>0.000000001&&u<-0.000000001||l<-0.000000001&&u>0.000000001)&&(c>0.000000001&&h<-0.000000001||c<-0.000000001&&h>0.000000001))return!0;if(Math.abs(l)<=0.000000001&&oc(r,i,o,a,e,t))return!0;if(Math.abs(u)<=0.000000001&&oc(r,i,o,a,n,s))return!0;if(Math.abs(c)<=0.000000001&&oc(e,t,n,s,r,i))return!0;if(Math.abs(h)<=0.000000001&&oc(e,t,n,s,o,a))return!0;return!1}function Zi(e,t,n,s,r,i=!1){let o=i||Array.isArray(e)?Er(e):-1;if(o!==t)throw Error(`PixiRenderer: slot "${s}" on page "${r}" has invalid ${n} length ${o<0?"non-array":o} (expected ${t})`);let a=to(e),l=no(e);for(let u=0;u= ${t})`);let a=to(e),l=no(e);for(let u=0;u= 6)`);let r=e.polygon;for(let l=0;l 0)`);if(e.convex){let l=o>0?1:-1;for(let u=0;u>>0;if(n===0)this.slotCounts.clear();let s=e.length,r=this.preparedPool,i=this.slotCounts;for(let c=0;c0?h.slot:"",f=i.get(d);if(!f)f={generation:n,count:0},i.set(d,f);else if(f.generation!==n)f.generation=n,f.count=0;let m=f.count++,p=m===0?d:`${d}\x00${m}`,y=r[c];if(!y)y={kind:"region",poolKey:p,slot:h,texture:j.EMPTY,blendMode:"normal",color:16777215,alpha:1,darkMatrix:null,clipPlan:null},r[c]=y;this.prepareSlot(h,p,y,t)}let o=!1;for(let c=0;c0?r[0].slot.clip:void 0,l=a!==void 0;if(l){for(let c=1;cs)this.root.removeChildAt(this.root.children.length-1);let u=0;for(let c=0;c0)t.filters=[];if(t.tint!==n.color)t.tint=n.color;if(t.alpha!==n.alpha)t.alpha=n.alpha;if(t.blendMode!==n.blendMode)t.blendMode=n.blendMode}}prepareSlot(e,t,n,s){if(!e||typeof e!=="object")throw Error("PixiRenderer: encountered invalid slot entry in frame.order (expected PosedSlot object)");let r=typeof e.slot==="string"&&e.slot.length>0?e.slot:"",i=typeof e.page==="string"&&e.page.length>0?e.page:"";if(e.kind!=="region"&&e.kind!=="mesh")throw Error(`PixiRenderer: slot "${r}" on page "${i}" has unsupported kind "${String(e.kind)}" (expected "region" or "mesh")`);let o=NO[e.blend];if(o===void 0)throw Error(`PixiRenderer: slot "${r}" on page "${i}" has unsupported blend mode "${String(e.blend)}" (expected Normal, Additive, Multiply, or Screen)`);if(typeof e.pma!=="boolean")throw Error(`PixiRenderer: slot "${r}" on page "${i}" has invalid pma=${String(e.pma)} (expected boolean)`);let a=this.validatedPages.get(e.page);if(!a){let k=this.assets.pageImages.get(e.page);if(!k)throw Error(`PixiRenderer: slot "${r}" references page "${i}", which is missing from assets.pageImages (expected HTMLImageElement for "${i}")`);let T=k.naturalWidth||k.width,A=k.naturalHeight||k.height;if(!Number.isFinite(T)||!Number.isFinite(A)||T<=0||A<=0)throw Error(`PixiRenderer: slot "${r}" page "${i}" has invalid image dimensions ${String(T)}x${String(A)} (expected positive decoded dimensions)`);a={pageImage:k,pw:T,ph:A},this.validatedPages.set(e.page,a)}let{pageImage:l,pw:u,ph:c}=a,h=!s||this.liveFrameChecks;if(h)Zi(e.tint,4,"tint",r,i,s);let d=to(e.tint),f=no(e.tint),m=null;if(e.dark!==void 0){if(h)Zi(e.dark,3,"dark",r,i,s);m=GO(d,f,e.dark)}let p=null;if(e.clip!==void 0){let k=this.validatedClips.get(e.clip);if(!k)k=XO(e.clip,r,i,s),this.validatedClips.set(e.clip,k);p=k}let y=Math.round(tn(d[f+0])*255),g=Math.round(tn(d[f+1])*255),x=Math.round(tn(d[f+2])*255),b=y<<16|g<<8|x,v=tn(d[f+3]);if(e.kind==="region"){if(h)Zi(e.corners,8,"corners",r,i,s);let k=this.regionPool.get(t),T;if(!this.alwaysReuploadGeometry&&k&&k.uvsRef===e.uvs&&k.page===e.page&&k.pma===e.pma&&k.texture!==null&&!k.texture.destroyed)this.sourceFor(l,e.pma),T=k.texture;else Zi(e.uvs,8,"uvs",r,i,s),T=this.regionTextureFor(l,u,c,e);n.kind="region",n.poolKey=t,n.slot=e,n.texture=T,n.blendMode=o,n.color=b,n.alpha=v,n.darkMatrix=m,n.clipPlan=p;return}if(h)WO(e.vertices,6,"vertices",r,i,s);let _=this.meshPool.get(t),S=!this.alwaysReuploadGeometry&&_!==void 0&&_.positions.length===Er(e.vertices);if(!S||_.uvsRef!==e.uvs)Zi(e.uvs,Er(e.vertices),"uvs",r,i,s);if(!S||_.trianglesRef!==e.triangles){if(!s&&!Array.isArray(e.triangles)||e.triangles.length<3||e.triangles.length%3!==0)throw Error(`PixiRenderer: slot "${r}" on page "${i}" has invalid triangles length ${Array.isArray(e.triangles)?e.triangles.length:"non-array"} (expected multiple of 3 >= 3)`);let k=Er(e.vertices)/2;for(let T=0;T=k)throw Error(`PixiRenderer: slot "${r}" on page "${i}" has out-of-range triangle index triangles[${T}]=${String(A)} (expected integer in 0..${k-1})`)}}if(!s&&(typeof e.sequence!=="number"||!Number.isInteger(e.sequence)))throw Error(`PixiRenderer: slot "${r}" on page "${i}" has invalid sequence=${String(e.sequence)} (expected integer)`);let M;if(!this.alwaysReuploadGeometry&&_&&_.page===e.page&&_.pma===e.pma&&_.texture!==null&&!_.texture.destroyed)this.sourceFor(l,e.pma),M=_.texture;else M=this.pageTextureFor(l,e.page,e.pma);n.kind="mesh",n.poolKey=t,n.slot=e,n.texture=M,n.blendMode=o,n.color=b,n.alpha=v,n.darkMatrix=m,n.clipPlan=p}sourceFor(e,t){let n=t?"premultiplied-alpha":"premultiply-alpha-on-upload",s=Qi.get(e);if(!s||s.source.destroyed){let r=new sn({resource:e,alphaMode:n,scaleMode:"linear",addressMode:"clamp-to-edge",autoGenerateMipmaps:!1});s={source:r,pma:t,holders:new Set},Qi.set(e,s),hm.add(r)}else if(s.pma!==t)s.pma=t,s.source.alphaMode=n,s.source.update();if(!this.retainedPages.has(e))this.retainedPages.add(e),s.holders.add(this);return s.source}pageTextureFor(e,t,n){let s=`${t}\x00${n?"1":"0"}`,r=this.pageTextures.get(s);if(r)return this.sourceFor(e,n),r;let i=this.sourceFor(e,n);return r=new j({source:i}),this.pageTextures.set(s,r),r}regionTextureFor(e,t,n,s){let r=s.uvs[0],i=s.uvs[1],o=s.uvs[2],a=s.uvs[3],l=s.uvs[4],u=s.uvs[5],c=s.uvs[6],h=s.uvs[7],d=`${s.page}\x00${s.pma?"1":"0"}\x00${r},${i},${o},${a},${l},${u},${c},${h}`,f=this.regionTextures.get(d);if(f)return this.sourceFor(e,s.pma),f;let m=this.sourceFor(e,s.pma),p=Math.min(r,o,l,c),y=Math.max(r,o,l,c),g=Math.min(i,a,u,h),x=Math.max(i,a,u,h),b=Math.max(1,(y-p)*t),v=Math.max(1,(x-g)*n),_=new Q(p*t,g*n,b,v),S=Math.abs(o-l)this.player.posedFrame();rigDestroyed=!1;constructor(e,t={}){super();if(!e||typeof e!=="object"||!e.document||typeof e.document!=="object"||!(e.pageImages instanceof Map))throw Error("PixiRig: invalid assets argument (expected ModelAssets with document and pageImages Map)");let n=t.timescale??t.timeScale;if(n!==void 0&&(typeof n!=="number"||!Number.isFinite(n)||n<0))throw Error(`PixiRig: invalid timescale=${String(n)} (expected finite number >= 0)`);if(t.renderGroup!==void 0&&typeof t.renderGroup!=="boolean")throw Error(`PixiRig: invalid renderGroup=${String(t.renderGroup)} (expected boolean)`);this.assets=e;let s=document.createElement("div"),r=e.regions==="none"?"canvas":"dom";if(this.player=new cm(s,e,{mode:r,skin:t.skin,slots:t.slots,liveFrameChecks:t.liveFrameChecks,poser:t.poser}),n!==void 0)this.player.timeScale=n;if(this.renderer=new YO(this,e),this.renderer.liveFrameChecks=t.liveFrameChecks??!1,t.renderGroup===!0)this.renderer.useRenderGroup=!0;this.ticker=t.ticker===void 0?tt.shared:t.ticker,this.autoUpdate=t.autoUpdate??this.ticker!==null;let i=this.player.posedFrame();if(this.lastDrawnFrame=i,this.renderer.render(i),this.autoUpdate&&this.ticker)this.attachTicker()}onTick=(e)=>{if(this.rigDestroyed)return;this.advance(e.deltaMS/1000)};ensureActive(e){if(this.rigDestroyed)throw Error(`PixiRig: cannot call ${e}() on a destroyed PixiRig`)}attachTicker(){if(this.tickerAttached||!this.ticker||this.rigDestroyed)return;this.ticker.add(this.onTick),this.tickerAttached=!0}detachTicker(){if(!this.tickerAttached||!this.ticker)return;this.ticker.remove(this.onTick),this.tickerAttached=!1}play(e,t={}){if(this.ensureActive("play"),typeof e!=="string"||e.length===0)throw Error(`PixiRig: invalid animation name ${String(e)} in play(name) (expected non-empty string)`);if(this.player.play(e,t),this.drawCurrent(),this.autoUpdate&&this.ticker)this.attachTicker()}advance(e){if(this.ensureActive("advance"),typeof e!=="number"||!Number.isFinite(e)||e<0)throw Error(`PixiRig: invalid dt=${String(e)} in advance(dt) (expected finite number >= 0)`);this.player.advance(e),this.drawCurrent()}seek(e){if(this.ensureActive("seek"),typeof e!=="number"||!Number.isFinite(e))throw Error(`PixiRig: invalid time=${String(e)} in seek(time) (expected finite number)`);this.player.seek(e),this.drawCurrent()}draw(){this.ensureActive("draw");let e=this.player.posedFrame();return this.lastDrawnFrame=e,this.renderer.render(e),e}renderFrame(e){if(this.ensureActive("renderFrame"),"order"in e){this.renderer.render(e),this.lastDrawnFrame=e;return}if(e.generation!==this.player.generation)throw Error(`PixiRig: live frame generation ${e.generation} needs current player generation ${this.player.generation}`);if(this.player.poser!=="runtime"){this.renderFrame(this.player.posedFrame());return}this.renderer.render(e),this.retainedRuntimeFrame.capture(e,this.snapshotSeed),this.lastDrawnFrame=null}drawCurrent(){this.renderFrame(this.player.poser==="runtime"?this.player.liveFrame():this.player.posedFrame())}drawnFrame(){return this.ensureActive("drawnFrame"),this.lastDrawnFrame??=this.retainedRuntimeFrame.snapshot()}posedFrame(e){if(this.ensureActive("posedFrame"),e===void 0)return this.player.posedFrame();return this.player.posedFrame(e)}bone(e){if(this.ensureActive("bone"),typeof e!=="string"||e.length===0)throw Error(`PixiRig: invalid bone name ${String(e)} in bone(name) (expected non-empty string)`);return this.player.bone(e)}bounds(){return this.ensureActive("bounds"),this.player.bounds()}get time(){return this.player.time}get current(){return this.player.current}get timescale(){return this.player.timeScale}set timescale(e){if(this.ensureActive("timescale"),typeof e!=="number"||!Number.isFinite(e)||e<0)throw Error(`PixiRig: invalid timescale=${String(e)} (expected finite number >= 0)`);this.player.timeScale=e}get timeScale(){return this.player.timeScale}set timeScale(e){this.timescale=e}get skin(){return this.player.skin}set skin(e){this.ensureActive("skin"),this.player.skin=e,this.drawCurrent()}get slots(){return this.player.slots}set slots(e){this.ensureActive("slots"),this.player.slots=e,this.drawCurrent()}get color(){return this.player.color}set color(e){this.ensureActive("color"),this.player.color=e,this.drawCurrent()}get adjust(){return this.player.adjust}set adjust(e){this.ensureActive("adjust"),this.player.adjust=e,this.drawCurrent()}get composed(){return this.ensureActive("composed"),this.player.composed}repose(){this.ensureActive("repose"),this.player.repose(),this.drawCurrent()}pause(){this.ensureActive("pause"),this.player.pause()}resume(){this.ensureActive("resume"),this.player.resume()}queue(e,t){this.ensureActive("queue"),this.player.queue(e,t)}clear(e,t){this.ensureActive("clear"),this.player.clear(e,t),this.drawCurrent()}queueClear(e,t){this.ensureActive("queueClear"),this.player.queueClear(e,t)}setAlpha(e,t){this.ensureActive("setAlpha"),this.player.setAlpha(e,t),this.drawCurrent()}entry(e){return this.ensureActive("entry"),this.player.entry(e)}environment(e){this.ensureActive("environment");let t=this.player.environment(e);return this.drawCurrent(),t}moved(e){this.ensureActive("moved"),this.player.moved(e)}onRigEvent(e,t){if(this.ensureActive("onRigEvent"),e==="event")return this.player.on("event",t);return this.player.on("complete",t)}resourceCounts(){return this.renderer.resourceCounts()}destroy(e){if(this.rigDestroyed)return;this.rigDestroyed=!0,this.detachTicker(),this.renderer.dispose(),this.player.dispose(),super.destroy(e)}};function HO(e,t){let n=t.getGlobalTransform(new U,!1),s=n.apply({x:e[0],y:-e[1]}),r=n.apply({x:e[2],y:-e[3]}),i=n.apply({x:e[4],y:-e[5]}),o=n.apply({x:e[6],y:-e[7]});return[s.x,s.y,r.x,r.y,i.x,i.y,o.x,o.y]}function zO(e,t,n=!1){let s=t.getGlobalTransform(new U,!1),r=Array(e.length);for(let i=0;i{this.markLost()});let t=this.link(iO,oO);this.meshProgram=t,e.useProgram(t);let n=e.getUniformLocation(t,"uResolution"),s=e.getUniformLocation(t,"uOrigin");if(!n||!s)throw Error("mesh program uniforms not found");this.uResolution=n,this.uOrigin=s,e.uniform1i(e.getUniformLocation(t,"uTex"),0),this.meshPos=e.getAttribLocation(t,"aPos"),this.meshUV=e.getAttribLocation(t,"aUV");let r=this.link(sO,rO);this.frameProgram=r,e.useProgram(r);let i=e.getUniformLocation(r,"uResolution"),o=e.getUniformLocation(r,"uOrigin");if(!i||!o)throw Error("frame program uniforms not found");this.frameResolution=i,this.frameOrigin=o,e.uniform1i(e.getUniformLocation(r,"uTex"),0),this.framePos=e.getAttribLocation(r,"aPos"),this.frameUV=e.getAttribLocation(r,"aUV"),this.frameColor=e.getAttribLocation(r,"aColor"),this.frameDark=e.getAttribLocation(r,"aDark"),e.bindBuffer(e.ARRAY_BUFFER,e.createBuffer()),e.enable(e.BLEND),e.enable(e.SCISSOR_TEST),e.clearColor(0,0,0,0),e.activeTexture(e.TEXTURE0),this.maxSize=Math.min(e.getParameter(e.MAX_RENDERBUFFER_SIZE)||4096,8192)}flush(e){let t=this.gl;if(this.lost||t.isContextLost())return!1;let n=Math.max(512,this.canvas.width);for(let y of e)n=Math.max(n,y.width+nt*2);if(n>this.maxSize)return!1;let s=e.map((y,g)=>g).sort((y,g)=>e[g].height-e[y].height),r=this.packX=Array(e.length),i=this.packY=Array(e.length),o=nt,a=nt,l=0,u=nt;for(let y of s){let g=e[y];if(o+g.width+nt>n)a+=l+nt,o=nt,l=0;if(r[y]=o,i[y]=a,o+=g.width+nt,g.height>l)l=g.height;if(a+g.height+nt>u)u=a+g.height+nt}if(u>this.maxSize)return!1;if(n>this.canvas.width||u>this.canvas.height)this.canvas.width=Math.min(this.maxSize,Math.ceil(n/zn)*zn),this.canvas.height=Math.min(this.maxSize,Math.ceil(Math.max(u,this.canvas.height)/zn)*zn);let c=this.canvas.height;this.bindMesh();let h=0;for(let y of e)h+=y.triangles.length*4;if(this.vertexData.lengththis.maxSize||s>this.maxSize)return!1;if(n>this.canvas.width||s>this.canvas.height)this.canvas.width=Math.min(this.maxSize,Math.ceil(Math.max(n,this.canvas.width)/zn)*zn),this.canvas.height=Math.min(this.maxSize,Math.ceil(Math.max(s,this.canvas.height)/zn)*zn);let r=this.canvas.width,i=this.canvas.height;t.viewport(0,0,r,i),this.bindFrame(e.stride),t.uniform2f(this.frameResolution,r,i),t.uniform2f(this.frameOrigin,nt,nt);let o=0;for(let c of e.runs)o=Math.max(o,c.first+c.count);if(o>0)t.bufferData(t.ARRAY_BUFFER,e.data.subarray(0,o*e.stride),t.DYNAMIC_DRAW);t.scissor(nt,i-nt-e.height,e.width,e.height),t.clear(t.COLOR_BUFFER_BIT);let a=null,l=null;for(let c of e.runs){if(c.page!==a)t.bindTexture(t.TEXTURE_2D,this.textureFor(c.page,c.pma)),a=c.page;if(c.blend!==l){let[h,d]=nO[c.blend];t.blendFuncSeparate(h,d,t.ONE,d),l=c.blend}t.drawArrays(t.TRIANGLES,c.first,c.count)}if(t.isContextLost())return this.markLost(),!1;let u=e.canvas.getContext("2d");if(!u)return!0;if(u.setTransform(1,0,0,1,0,0),u.globalAlpha=1,u.globalCompositeOperation="source-over",u.clearRect(0,0,e.canvas.width,e.canvas.height),e.width>0&&e.height>0)u.drawImage(this.canvas,nt,nt,e.width,e.height,0,0,e.width,e.height);return!0}bindMesh(){let e=this.gl;if(this.bound!=="mesh")e.useProgram(this.meshProgram),this.disableAttributes(),e.enableVertexAttribArray(this.meshPos),e.enableVertexAttribArray(this.meshUV),e.vertexAttribPointer(this.meshPos,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(this.meshUV,2,e.FLOAT,!1,16,8),this.bound="mesh";e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}bindFrame(e){let t=this.gl;t.useProgram(this.frameProgram),this.disableAttributes();let n=e*4;if(t.enableVertexAttribArray(this.framePos),t.enableVertexAttribArray(this.frameUV),t.enableVertexAttribArray(this.frameColor),t.vertexAttribPointer(this.framePos,2,t.FLOAT,!1,n,0),t.vertexAttribPointer(this.frameUV,2,t.FLOAT,!1,n,8),t.vertexAttribPointer(this.frameColor,4,t.FLOAT,!1,n,16),e===11)t.enableVertexAttribArray(this.frameDark),t.vertexAttribPointer(this.frameDark,3,t.FLOAT,!1,n,32);else t.vertexAttrib3f(this.frameDark,0,0,0);this.bound="frame"}disableAttributes(){let e=this.gl;for(let t of[this.meshPos,this.meshUV,this.framePos,this.frameUV,this.frameColor,this.frameDark])if(t>=0)e.disableVertexAttribArray(t)}link(e,t){let n=this.gl,s=n.createProgram();if(!s)throw Error("createProgram failed");if(n.attachShader(s,this.compile(n.VERTEX_SHADER,e)),n.attachShader(s,this.compile(n.FRAGMENT_SHADER,t)),n.linkProgram(s),!n.getProgramParameter(s,n.LINK_STATUS))throw Error(`program link failed: ${n.getProgramInfoLog(s)}`);return s}retain(e){let t=this.textures.get(e);if(t)t.users++;else this.textures.set(e,{texture:null,users:1,pma:!1})}release(e){let t=this.textures.get(e);if(!t)return;if(--t.users>0)return;if(this.textures.delete(e),!t.texture)return;if(!this.lost&&!this.gl.isContextLost())this.gl.deleteTexture(t.texture);this.liveTextureCount--}markLost(){this.lost=!0,this.textures=new WeakMap,this.liveTextureCount=0}compile(e,t){let n=this.gl,s=n.createShader(e);if(!s)throw Error("createShader failed");if(n.shaderSource(s,t),n.compileShader(s),!n.getShaderParameter(s,n.COMPILE_STATUS))throw Error(`shader compile failed: ${n.getShaderInfoLog(s)}`);return s}textureFor(e,t){let n=this.textures.get(e);if(n?.texture){if(n.pma===t)return n.texture;this.gl.deleteTexture(n.texture),n.texture=null,this.liveTextureCount--}let s=this.gl,r=s.createTexture();if(!r)throw Error("createTexture failed");if(s.bindTexture(s.TEXTURE_2D,r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t?0:1),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),!n)n={texture:null,users:0,pma:t},this.textures.set(e,n);return n.pma=t,n.texture=r,this.liveTextureCount++,r}}var Cr;function Dr(){if(Cr===void 0)try{Cr=new LM}catch{Cr=null}return Cr&&!Cr.lost?Cr:null}function UM(e=typeof navigator==="object"?navigator.userAgent:""){return/AppleWebKit/.test(e)&&/Linux|X11/.test(e)&&!/Android|Chrome|Chromium|CriOS|Edg/.test(e)?"triangle":"page"}var Ts=new Float32Array(8),ff="http://www.w3.org/2000/svg",aO=0,lO=4,cO=new Float64Array(6);function uO(e,t,n,s,r,i,o){let a=cO;a[0]=e,a[1]=t,a[2]=n,a[3]=s,a[4]=r,a[5]=i;let l=(n-e)*(i-t)-(r-e)*(s-t);if(o===0||l===0)return a;let u=l>0?1:-1,c=Math.hypot(n-e,s-t),h=(s-t)/c*u,d=-(n-e)/c*u;c=Math.hypot(r-n,i-s);let f=(i-s)/c*u,m=-(r-n)/c*u;c=Math.hypot(e-r,t-i);let p=(t-i)/c*u,y=-(e-r)/c*u;return mf(a,0,p,y,h,d,o),mf(a,2,h,d,f,m,o),mf(a,4,f,m,p,y,o),a}function mf(e,t,n,s,r,i,o){let a=o/(1+n*r+s*i),l=(n+r)*a,u=(s+i)*a,c=Math.hypot(l,u),h=lO*o;if(c>h)l*=h/c,u*=h/c;e[t]+=l,e[t+1]+=u}function Nl(e){return`${Xi(e)}px`}function Xi(e){return Math.round(e*1000)/1000}var r1=1e9;function hO(e){if(!Number.isFinite(e))return 0;return 2**(Math.max(-149,Math.floor(Math.log2(Math.abs(e)))-23)-1)}function i1(e,t,n,s){if(e===t)return!0;if(s===0)return!1;let r=hO(n),i=Math.abs(e-t);return i<0.5&&i<=r}var dO={Normal:"",Additive:"plus-lighter",Multiply:"multiply",Screen:"screen"};class WM{constructor(e,t,n=new Map,s=new Map){this.root=e,this.regionImages=t,this.pages=n,this.atlasRegions=s}clipping=!0;clipCount=0;rigidRasterCount=0;clipSkipCount=0;clipWriteCount=0;meshCount=0;meshReuseCount=0;canvasReallocCount=0;triangleCount=0;triangleExpand=0.5;meshSourceRect=UM();pixelRatio=typeof devicePixelRatio==="number"?devicePixelRatio:1;meshBackend="webgl";meshBackendActive="webgl";views=new Map;frameNumber=0;pendingJobs=[];pendingViews=[];glPages=null;scratchVertices=new Float32Array(256);tintDefs=null;clipActive=null;clipsSeen=new Set;clipInverse=!1;clipOnRoot=!1;clipPolygon=new Float64Array(0);clipPolygonLength=0;rootClipSaved=null;rootClipWritten="";get meshBackingPixels(){let e=0;for(let t of this.views.values())if(t.kind==="canvas")e+=t.canvasW*t.canvasH;return e}syncPixelRatio(){return this.pixelRatio=S1(this.root,this.pixelRatio),this.pixelRatio}render(e){let t=_1(e);this.clipCount=0,this.rigidRasterCount=0,this.clipSkipCount=0,this.clipWriteCount=0,this.meshCount=0,this.meshReuseCount=0,this.canvasReallocCount=0,this.triangleCount=0,this.clipActive=null,this.clipInverse=!1,this.clipOnRoot=!1,this.clipsSeen.clear();let n=++this.frameNumber,s=this.meshBackend==="webgl"?Dr():null;this.meshBackendActive=s?"webgl":"canvas2d";let r=t.order,i=r.length>0?r[0].clip:void 0;if(i&&!i.inverse&&this.clipping&&i.polygon.length>=6){let o=!0;for(let a=1,l=r.length;a0&&g<1?1.25**Math.ceil(Math.log(g)/Math.log(1.25)):1;if(s.regionName!==e.region||t&&s.regionRatio!==x)if(s.regionName=e.region,s.regionRatio=x,t)q$(s.el,t,x<1?x:void 0),s.el.style.width=`${h}px`,s.el.style.height=`${d}px`,this.rigidRasterCount++;else{let b=s.el;b.src=this.regionImages.get(e.region).url,b.width=h,b.height=d}return this.setTransform(s,`matrix(${f},${m},${p},${y},${a},${l})`),this.applyClip(s,f,m,p,y,a,l,h,d),this.applyCommon(s,e),s}renderMesh(e){let t=e.sequence,n=this.pages.get(e.page);if(!n)return null;let{pma:s,vertices:r}=e,i=r.length;if(this.scratchVertices.lengthu)u=T;if(Ac)c=A}let h=1;a=Math.floor(a)-h,l=Math.floor(l)-h;let d=Math.ceil(u)+h-a,f=Math.ceil(c)+h-l;if(d<=0||f<=0)return null;let m=this.view(e.slot,"canvas"),p=m.el,y=this.pixelRatio,{uvs:g,triangles:x}=e,b=m.meshUvs!==g||m.meshTriangles!==x||m.meshPage!==n||m.meshSequenceIndex!==t||m.meshExpand!==this.triangleExpand||m.meshSourceRect!==this.meshSourceRect||m.meshVertexCount!==i||m.meshBackendDrawn!==this.meshBackendActive,v=Math.max(1,Math.round(d*y)),_=Math.max(1,Math.round(f*y)),S=m.meshRatio!==y;if(v>m.canvasW||_>m.canvasH||S){let T=S?0:m.canvasW,A=S?0:m.canvasH;m.canvasW=Math.ceil(Math.max(v*1.25,T)/32)*32,m.canvasH=Math.ceil(Math.max(_*1.25,A)/32)*32,m.meshRatio=y,p.width=m.canvasW,p.height=m.canvasH,p.style.width=`${m.canvasW/y}px`,p.style.height=`${m.canvasH/y}px`,this.canvasReallocCount++,b=!0}if(m.meshVertices.length0?"L":"M"}${Xi(x)} ${Xi(b)}`;else m+=`${p>0?",":""}${Nl(x)} ${Nl(b)}`}this.setClipPath(e,f?`${m}Z')`:`${m})`)}setClipPath(e,t){if(e.clipPath===t)return;e.clipPath=t,e.el.style.clipPath=t,this.clipWriteCount++}rootClipPath(){let e=this.clipPolygon,t="polygon(";for(let n=0,s=this.clipPolygonLength;n0)t+=",";t+=`${Nl(e[n])} ${Nl(e[n+1])}`}return`${t})`}writeRootClip(e){if(this.rootClipSaved===null)this.rootClipSaved=this.root.style.clipPath;if(this.rootClipWritten===e)return;this.rootClipWritten=e,this.root.style.clipPath=e,this.clipWriteCount++}releaseRootClip(){if(this.rootClipSaved===null)return;this.root.style.clipPath=this.rootClipSaved,this.rootClipSaved=null,this.rootClipWritten="",this.clipWriteCount++}setTransform(e,t){if(e.transform!==t)e.transform=t,e.el.style.transform=t}applyCommon(e,t){let{z:n,tint:s}=t;if(e.zIndex!==n)e.zIndex=n,e.el.style.zIndex=String(n);let r=s[3];if(e.opacity!==r)e.opacity=r,e.el.style.opacity=r===1?"":String(r);let i=s[0],o=s[1],a=s[2];if(e.tintR!==i||e.tintG!==o||e.tintB!==a)if(e.tintR=i,e.tintG=o,e.tintB=a,i===1&&o===1&&a===1)e.el.style.filter="";else this.tintMatrixFor(e).setAttribute("values",`${i} 0 0 0 0 0 ${o} 0 0 0 0 0 ${a} 0 0 0 0 0 1 0`),e.el.style.filter=`url(#${e.tintId})`;let l=t.blend;if(e.blendMode!==l)e.blendMode=l,e.el.style.mixBlendMode=dO[l];if(!e.visible)e.visible=!0,e.el.style.display=""}tintMatrixFor(e){if(e.tintMatrix)return e.tintMatrix;if(!this.tintDefs){let s=document.createElementNS(ff,"svg");s.setAttribute("width","0"),s.setAttribute("height","0"),s.style.position="absolute",this.root.appendChild(s),this.tintDefs=s}let t=document.createElementNS(ff,"filter");e.tintId=`rig-play-tint-${aO++}`,t.setAttribute("id",e.tintId),t.setAttribute("color-interpolation-filters","sRGB");let n=document.createElementNS(ff,"feColorMatrix");return n.setAttribute("in","SourceGraphic"),n.setAttribute("type","matrix"),t.appendChild(n),this.tintDefs.appendChild(t),e.tintMatrix=n,n}view(e,t){let n=this.views.get(e);if(n&&n.kind!==t)n.el.remove(),n.tintMatrix?.parentElement?.remove(),n=void 0;if(!n){let s=t==="image"?document.createElement("img"):document.createElement("canvas");if(s instanceof HTMLImageElement)s.draggable=!1;s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transformOrigin="0 0",s.style.pointerEvents="none",s.style.userSelect="none",s.style.display="none",n={kind:t,el:s,regionName:"",regionRatio:-1,visible:!1,zIndex:-1,opacity:1,blendMode:"Normal",transform:"",clipPath:"",tintR:1,tintG:1,tintB:1,tintId:"",tintMatrix:null,canvasW:0,canvasH:0,meshRatio:-1,meshUvs:null,meshTriangles:null,meshPage:null,meshSequenceIndex:-1,meshExpand:-1,meshSourceRect:"",meshVertexCount:-1,meshBackendDrawn:"",meshVertices:new Float64Array(0),meshOriginX:0,meshOriginY:0,drawnIn:0},this.views.set(e,n),this.root.appendChild(s)}return n}hide(e){if(e.visible)e.visible=!1,e.el.style.display="none";this.setClipPath(e,"")}}function XM(e,t,n,s,r,i,o,a,l,u,c,h,d,f,m,p){let y=uO(r,i,l,u,d,f,n),g=y[0],x=y[1],b=y[2],v=y[3],_=y[4],S=y[5];e.beginPath(),e.moveTo(g,x),e.lineTo(b,v),e.lineTo(_,S),e.closePath();let k=l-r,w=u-i,T=d-r,A=f-i,C=c-o,E=h-a,P=m-o,O=p-a,B=C*O-P*E;if(B===0)return;B=1/B;let I=(O*k-E*T)*B,R=(O*w-E*A)*B,N=(C*T-P*k)*B,L=(C*A-P*w)*B,U=r-I*o-N*a,J=i-R*o-L*a;if(s==="page"){e.save(),e.transform(I,R,N,L,U,J),e.clip(),e.drawImage(t,0,0),e.restore();return}let ee=Math.min(o,c,m),W=Math.max(o,c,m),X=Math.min(a,h,p),F=Math.max(a,h,p),G=I*L-R*N;if(G!==0){let he=1/G,re=L*he,Ae=-N*he,ae=-R*he,Pe=I*he,De=g-r,oe=x-i,Ee=o+re*De+Ae*oe,xe=a+ae*De+Pe*oe;ee=Math.min(ee,Ee),W=Math.max(W,Ee),X=Math.min(X,xe),F=Math.max(F,xe),De=b-l,oe=v-u,Ee=c+re*De+Ae*oe,xe=h+ae*De+Pe*oe,ee=Math.min(ee,Ee),W=Math.max(W,Ee),X=Math.min(X,xe),F=Math.max(F,xe),De=_-d,oe=S-f,Ee=m+re*De+Ae*oe,xe=p+ae*De+Pe*oe,ee=Math.min(ee,Ee),W=Math.max(W,Ee),X=Math.min(X,xe),F=Math.max(F,xe)}let H=Math.max(0,Math.floor(ee-1)),Z=Math.max(0,Math.floor(X-1)),V=Math.min(t.width,Math.ceil(W+1))-H,Q=Math.min(t.height,Math.ceil(F+1))-Z;if(!(V>0)||!(Q>0))return;e.save(),e.transform(I,R,N,L,U,J),e.clip(),e.drawImage(t,H,Z,V,Q,H,Z,V,Q),e.restore()}var fO={Normal:0,Additive:1,Multiply:2,Screen:3},mO={Normal:"source-over",Additive:"lighter",Multiply:"multiply",Screen:"screen"},Ar=16;class Uf{constructor(e,t){this.root=e,this.pages=t;let n=document.createElement("canvas");n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.transformOrigin="0 0",n.style.pointerEvents="none",n.style.userSelect="none",n.width=0,n.height=0,this.canvas=n,this.ctx=n.getContext("2d"),e.appendChild(n)}pixelRatio=typeof devicePixelRatio==="number"?devicePixelRatio:1;clipping=!0;viewport=null;backend="webgl";meshSourceRect=UM();backendActive="webgl";canvas;drawCalls=0;blendFlushes=0;trianglesDrawn=0;framesReused=0;blits=0;canvasReallocCount=0;clipCount=0;clipSkipCount=0;ctx;left=0;top=0;right=0;bottom=0;hasRect=!1;backingW=0;backingH=0;backingRatio=-1;data=new Float32Array(4096);runs=[];glPages=new Set;sig=new Float64Array(256);sigLength=-1;sigRefs=[];nextSig=new Float64Array(256);nextRefs=[];syncPixelRatio(){return this.pixelRatio=S1(this.root,this.pixelRatio),this.pixelRatio}reserve(e){this.growTo(e.x,-(e.y+e.height),e.x+e.width,-e.y)}render(e){let t=_1(e);this.drawCalls=0,this.blendFlushes=0,this.trianglesDrawn=0,this.framesReused=0,this.blits=0,this.canvasReallocCount=0,this.clipCount=0,this.clipSkipCount=0;let n=this.backend==="webgl"?Dr():null;this.backendActive=n?"webgl":"canvas2d";let s=t.order,r=this.viewport;if(r)this.setRect(Math.floor(r.x),Math.floor(-(r.y+r.height)),Math.ceil(r.x+r.width),Math.ceil(-r.y));else{let i=1/0,o=1/0,a=-1/0,l=-1/0;for(let u=0;ua)a=f;if(ml)l=m}}if(i<=a&&o<=l)this.growTo(i,o,a,l)}if(this.sizeBacking(),!this.signatureChanged(s)){this.framesReused=1,this.countClips(s);return}if(this.backingW===0||this.backingH===0)return;if(n){if(this.buildVertices(s),n.flushFrame({canvas:this.canvas,width:this.backingW,height:this.backingH,data:this.data,stride:this.stride,runs:this.runs})){this.blits=1;return}this.backendActive="canvas2d",this.sigLength=-1}this.draw2d(s)}dispose(){if(this.canvas.remove(),this.glPages.size){let e=Dr();if(e)for(let t of this.glPages)e.release(t);this.glPages.clear()}this.sigLength=-1}growTo(e,t,n,s){if(this.hasRect&&e>=this.left&&t>=this.top&&n<=this.right&&s<=this.bottom)return;if(!this.hasRect){this.setRect(Math.floor(e)-Ar,Math.floor(t)-Ar,Math.ceil(n)+Ar,Math.ceil(s)+Ar);return}let r=Math.max(Ar,Math.round((this.right-this.left)/4)),i=Math.max(Ar,Math.round((this.bottom-this.top)/4));this.setRect(ethis.right?Math.ceil(n)+r:this.right,s>this.bottom?Math.ceil(s)+i:this.bottom)}setRect(e,t,n,s){if(this.hasRect&&e===this.left&&t===this.top&&n===this.right&&s===this.bottom)return;this.left=e,this.top=t,this.right=Math.max(e,n),this.bottom=Math.max(t,s),this.hasRect=!0,this.canvas.style.transform=`translate(${e}px,${t}px)`}sizeBacking(){let e=this.pixelRatio,t=this.hasRect?Math.max(0,Math.ceil((this.right-this.left)*e)):0,n=this.hasRect?Math.max(0,Math.ceil((this.bottom-this.top)*e)):0;if(t===this.backingW&&n===this.backingH&&e===this.backingRatio)return;this.backingW=t,this.backingH=n,this.backingRatio=e,this.canvas.width=t,this.canvas.height=n,this.canvas.style.width=`${t/e}px`,this.canvas.style.height=`${n/e}px`,this.canvasReallocCount++,this.sigLength=-1}signatureChanged(e){let t=0,n=this.nextRefs;n.length=0;let s=this.nextSig,r=(a)=>{if(t+a>s.length){let l=new Float64Array(Math.max(s.length*2,t+a));l.set(s.subarray(0,t)),s=l,this.nextSig=l}};r(9),s[t++]=this.meshSourceRect==="triangle"?1:0,s[t++]=this.left,s[t++]=this.top,s[t++]=this.backingW,s[t++]=this.backingH,s[t++]=this.backingRatio,s[t++]=this.backendActive==="webgl"?1:0,s[t++]=this.clipping?1:0,s[t++]=e.length;let i;for(let a=0;a=6)this.clipCount++;else this.clipSkipCount++}}stride=8;piecesOf(e,t){let n=e.kind==="region"?e.corners:e.vertices,s=e.kind==="region"?sm:e.triangles,r=e.clip;if(!r)return{vertices:n,uvs:e.uvs,triangles:s};let i=t.get(r);if(i===void 0)if(i=this.clipping&&r.polygon.length>=6,t.set(r,i),i)this.clipCount++;else this.clipSkipCount++;if(!i)return{vertices:n,uvs:e.uvs,triangles:s};let o=U1({polygon:r.polygon,inverse:r.inverse,convex:r.convex},n,s,e.uvs);if(o===null)return t.set(r,!1),this.clipCount--,this.clipSkipCount++,{vertices:n,uvs:e.uvs,triangles:s};return o.clipped?o:{vertices:n,uvs:e.uvs,triangles:s}}buildVertices(e){let t=!1;for(let h=0;h(u-r)*s,a=(u)=>(-u-i)*s,l=null;for(let u=0;uC&&O>E)t.drawImage(f,C,E,P-C,O-E,C,E,P-C,O-E);t.setTransform(1,0,0,1,0,0)}this.trianglesDrawn+=2;continue}for(let b=0;b+2c.name)),i=new Set(n.bones.map((c)=>c.name)),o=new Map;for(let c of n.skins)for(let[h,d]of Object.entries(c.attachments)){let f=o.get(h);if(!f)f=new Set,o.set(h,f);for(let m of Object.keys(d))f.add(m)}let a=[];if(Array.isArray(s.sets))for(let c=0;c{let r=new Image;if(t!==void 0)r.crossOrigin=t;r.onload=()=>n(r),r.onerror=()=>s(Error(`Failed to load page image: ${e}`)),r.src=e})}function vO(e){return e.split(/[?#]/,1)[0].toLowerCase()}function _O(e,t){let n;try{n=u$(e,t)}catch(s){if(s instanceof Y)throw new Y(`${s.message} — build it with \`rigc build\``);throw s}if(n.pages===null)throw new Y(`${t}: a ${n.spec} document does not state where each region sits on its page — build it with \`rigc build\``);return{spec:n.spec,doc:n,parsed:JSON.parse(e)}}async function SO(e){let{modelUrl:t,crossOrigin:n}=e,s=vO(t);if(s.endsWith(".skel")||s.endsWith(".json")&&!s.endsWith(".model.json"))throw new Y(`${t} is a Spine export; this player reads a compiled model document (${fM[0]}, skeleton.model.json) — build it with \`rigc build\``);let r=e.regions??"blob";if(r!=="atlas"&&r!=="blob"&&r!=="data"&&r!=="none")throw Error(`regions must be 'atlas', 'blob', 'data' or 'none', got ${String(e.regions)}`);let i=e.fetch??globalThis.fetch.bind(globalThis),o=e.resolvePage??VM,a=_O(await jM(i,t),t),l=a.doc.pages??[],u=new Map;await Promise.all(l.map(async(f)=>{u.set(f.name,await bO(o(f.name,t),n))}));let c=await yO(i,t,e.setsUrl,a.doc),h=r==="none"||r==="atlas"?new Map:await eO(l,u,{encoding:r}),d=!1;return{spec:a.spec,animations:a.doc.animations.map((f)=>({name:f.name,duration:f.timelines.duration})),skins:a.doc.skins.map((f)=>f.name),sets:c,stage:xO(a.doc),regions:r,regionImages:h,atlasRegions:r==="atlas"?z$(l,u):new Map,pageImages:u,document:a,dispose(){if(d)return;d=!0,tO(h)}}}var gc=0,Gr=1,YM=2,Yt=2*(oM+1);function Ot(e,t){let n=e.length,s=new Float64Array(n),r=new Float64Array(n*t),i=new Uint8Array(n),o=new Float64Array(n*t*Yt);for(let a=0;a=n)continue;let h=e[a+1],d=l.stated,{stated:f,values:m}=h;for(let p=0;p=0&&r[i]>s)i--;while(i+1=e.keys)return o;let a=e.kinds[t];if(a===Gr)return o;if(a===gc){let f=e.times[t];return o+(s-f)/(e.times[t+1]-f)*(i[(t+1)*r+n]-o)}let l=e.polylines,u=(t*r+n)*Yt,c=2;while(c({time:n.time,values:[0],curve:"linear",stated:{time:n.stated,values:[0]}})),1);for(let n=0;n[F.name,G])),l=(F)=>{let G=a.get(F);if(G===void 0)throw new Ue(`bone "${F}" is not a bone of this document (readModel refuses it first)`);return G},u=new Map(e.slots.map((F,G)=>[F.name,G])),c=(F)=>{let G=u.get(F);if(G===void 0)throw new Ue(`slot "${F}" is not a slot of this document (readModel refuses it first)`);return G},h=Dt(e),d=new Int32Array(o),f=new Uint8Array(o),m=new Uint8Array(o),p=new Float64Array(o),y=new Float64Array(o*Mt);if(e.bones.forEach((F,G)=>{if(d[G]=F.parent===void 0?-1:l(F.parent),d[G]>=G)throw new Ue(`bone "${F.name}" is listed before its parent (readModel refuses it first)`);let H=F.inheritMode===void 0?"normal":mm(F.inheritMode);if(H===null)throw new Ue(`bone "${F.name}": inheritMode ${JSON.stringify(F.inheritMode)} is no mode (readModel refuses it first)`);f[G]=TO[H],m[G]=h.has(F.name)?1:0,p[G]=F.length??0;let Z=G*Mt;y[Z+on]=F.x??0,y[Z+It]=F.y??0,y[Z+lt]=F.rotation??0,y[Z+Bt]=F.scaleX??1,y[Z+Tt]=F.scaleY??1,y[Z+Zn]=F.shearX??0,y[Z+Qn]=F.shearY??0}),n.setupNudge!==void 0)y[l(n.setupNudge.bone)*Mt+n.setupNudge.field]+=n.setupNudge.delta;let g=e.bones.map(()=>[]);for(let F=0;F=0;G=d[G])g[G].push(F);let x=new Int32Array(o+1),b=[];for(let F=0;F{if(Rf(F,h)!==null)S.add(G)});let k=_.some((F)=>F.kind==="path")?rm(e.bones,h,_,S):new Map;for(let F of _){let G=Rf(F,h)===null,H=Int32Array.from((F.kind==="physics"?[F.bone]:F.kind==="slider"?F.timelines.bones.filter((V)=>V.timelines.length>0).map((V)=>V.name):F.bones).map(l)),Z=v.length;if(F.kind==="physics"){v.push({kind:"physics",name:F.name,index:Z,applied:G,bones:H,setup:F});continue}if(F.kind==="slider"){v.push({kind:"slider",name:F.name,index:Z,applied:G,bones:H,setup:F,bone:F.bone===null?-1:l(F.bone),property:Ct.indexOf(F.property),animation:null});continue}if(G&&F.bones.some((V)=>!h.has(V)))s.note("inactive-constrained-bone",`${F.kind} constraint "${F.name}" names bone(s) ${F.bones.filter((V)=>!h.has(V)).map((V)=>`"${V}"`).join(", ")}, which the view leaves inactive — what the oracle writes there depends on the pass before`);if(F.kind==="ik")v.push(IO(F,Z,G,H,l));else if(F.kind==="path")v.push(BO(F,Z,G,H,l,c,k.get(Z)??null));else{let V=!F.localTarget&&H.some((he)=>d[he]>=0&&(f[he]===Rr||f[he]===uc)),Q=FO(F,Z,G&&!(n.omitLocalTransform&&(F.localSource||F.localTarget))&&!(n.omitNoScaleWorldTransform&&V)&&!(n.omitAdditiveTransform&&F.additive),H,l);v.push(Q)}}let w=e.skins.some((F)=>Object.values(F.attachments).some((G)=>Object.values(G).some((H)=>H.geometry?.kind==="clipping"))),T=[],A=0,C=0,E=bm(e),P=n.attachmentSkin===void 0?e:If(e,n.attachmentSkin),O=e.slots.map(()=>new Map),B=(F,G,H)=>{let Z=O[F],V=Z.get(G);if(V===void 0)V=I(F,G),Z.set(G,V);if(V.missing!==null)s.note(V.missing[0],V.missing[1],H);return V.index},I=(F,G)=>{let H=e.slots[F],Z=G===null?null:Mn(P,H,G);if(Z===null)return{index:-1,missing:null};if("conflict"in Z)return{index:-1,missing:["skin-conflict",`slot "${H.name}" placeholder "${G}" is filled by skins that disagree`]};let V=ro(Z),Q=Z.record.geometry,he={timeline:tm(H.name,Z),deformOffset:C,slot:F,name:V.name,skin:Z.skin,placeholder:Z.placeholder,path:yM.has(Z.record.kind)?V.path:null,bone:l(H.bone),offset:A},re=null,Ae=null;if(Q?.kind==="clipping")re={...zf(he,Q.vertices,l,n.bindingIndex,o),clip:{end:Q.end,inverse:Q.inverse,convex:Q.convex}};else if(Q?.kind==="region"){let ae=Q.region;if(ae.atlas===null)Ae=["null-atlas-region",`slot "${H.name}" shows region "${V.name}", whose atlas rectangle the model states as null`];else{let{width:Pe,height:De}=ae,oe=ae.scaleX??1,Ee=ae.scaleY??1,xe=ae.atlas,pt=Pe/xe.originalWidth*oe,Tn=De/xe.originalHeight*Ee,Cn=-Pe/2*oe+xe.offsetX*pt,Fs=-De/2*Ee+xe.offsetY*Tn,Ur=Cn+xe.width*pt,Wr=Fs+xe.height*Tn,Nt=(ae.rotation??0)*Je,An=Math.cos(Nt),En=Math.sin(Nt),ln=ae.x??0,ts=ae.y??0,gn=new Float64Array(8),Xr=[Cn,Fs,Cn,Wr,Ur,Wr,Ur,Fs];for(let cn=0;cn<8;cn+=2){let Ds=Xr[cn],ns=Xr[cn+1];gn[cn]=Ds*An+ln-ns*En,gn[cn+1]=ns*An+ts+Ds*En}re=Hf(he,Wf,gn,8)}}else if(Q?.kind==="mesh"||Q?.kind==="linkedmesh"){let ae=Q.kind==="mesh"?Q.vertices:E(Q.skin,Q.slot,Q.source);if(typeof ae==="string")throw new Ue(`slot "${H.name}": ${ae} (readModel refuses it first)`);re=zf(he,ae,l,n.bindingIndex,o)}else if(Q?.kind==="path")re=OO(he,Q.vertices,l,n.bindingIndex,o);if(re===null)re=Hf(he,Sm,new Float64Array(0),0);if(w){if(Q?.kind==="region")re={...re,clipTopology:{triangles:new Int32Array([0,1,2,2,3,0]),uvs:new Float64Array([0,1,0,0,1,0,1,1])}};else if(Q?.kind==="mesh"||Q?.kind==="linkedmesh"){let ae=Q.kind==="mesh"?Q:e.skins.find((Pe)=>Pe.name===Q.skin)?.attachments[Q.slot]?.[Q.source]?.geometry;if(ae?.kind!=="mesh")throw new Ue("clipping topology: linked source is not a mesh (readModel refuses it first)");re={...re,clipTopology:{triangles:Int32Array.from(ae.triangles),uvs:Float64Array.from(ae.uvs)}}}}return T.push(re),A+=re.count,C+=re.deformCount,{index:T.length-1,missing:Ae}},R=e.slots.map((F,G)=>{let H=l(F.bone),Z=F.color===void 0?[1,1,1,1]:to(F.color);return{name:F.name,bone:H,live:h.has(F.bone),setupAttachment:B(G,F.setup,null),light:Float64Array.from(Z),dark:F.dark===void 0?null:Float64Array.from(to(F.dark).slice(0,3)),blend:ym(F)}}),N=!1,L=0,U=0;for(let F of v){if(F.kind!=="path")continue;N=!0,F.attachment=F.setup.path===null?-1:R[F.slot].setupAttachment;let G=F.rotateMode===wm?F.bones.length:F.bones.length+1;if(G>L)L=G;if(F.attachment>=0){let H=T[F.attachment];if(F.pathVertices=H.bindingCounts.length>0?H.bindingCounts.length*2:H.local.length,F.pathVertices>U)U=F.pathVertices}}let J=new Map,ee=[],W=0;for(let F of e.animations){let G=DO(F,s,r,a,u,R,v,e,(Z,V)=>B(Z,V,F.name)),H=s.byAnimation.get(F.name);if(H!==void 0&&H.length>0)ee.push({animation:F.name,missing:H});else J.set(F.name,G),W=Math.max(W,G.cursors)}for(let F of v)if(F.kind==="slider"){let G=J.get(F.setup.animation);if(G!==void 0)F.animation=G;else for(let H of s.byAnimation.get(F.setup.animation)??[])s.note(H.feature,`slider "${F.name}" applies refused animation "${F.setup.animation}": ${H.detail}`)}if(s.model.length>0)throw new no(s.model);let X=e.animations.map((F)=>F.name);return{omitPhysics:n.omitPhysics===!0,sliderAsTrack:n.sliderAsTrack===!0,omitDeform:n.omitDeform===!0,deformAfterWeights:n.deformAfterWeights===!0,omitPath:n.omitPath===!0,ignorePhysicsScope:n.ignorePhysicsScope===!0,omitDrawOrder:n.omitDrawOrder===!0,omitDarkColour:n.omitDarkColour===!0,hasPath:N,maxPathSpaces:L,maxPathVertices:U,deformCount:C,eventWrapOffByOne:n.eventWrapOffByOne===!0,restoreEventsFromStart:n.restoreEventsFromStart===!0,doc:e,boneNames:e.bones.map((F)=>F.name),parents:d,modes:f,active:m,lengths:p,setup:y,subtreeStart:x,subtrees:Int32Array.from(b),slots:R,attachments:T,vertexCount:A,constraints:v,animations:J,refused:ee,cursors:W,scratch:n.scratchByBones===!0?Math.max(1,o):Math.max(1,o,...v.map((F)=>F.bones.length)),animation(F){let G=J.get(F);if(G!==void 0)return G;let H=ee.find((Z)=>Z.animation===F);if(H!==void 0)throw new no(H.missing);throw new Ue(`animation ${JSON.stringify(F)} is not one of this document's [${X.join(", ")}]`)}}}var u1=new Int32Array(0),Zl=new Float64Array(0);function Hf(e,t,n,s){return{...e,draw:t,local:n,count:s,deformCount:t===$r?s:0,bindingCounts:u1,bindingBones:u1,bindingX:Zl,bindingY:Zl,bindingWeights:Zl}}function zf(e,t,n,s,r){if(!t.weighted){let c=t.xy.length-t.xy.length%2,h=new Float64Array(c);for(let d=0;de.offsets[f])),mixes:Float64Array.from(Ct.map((f)=>e.mixes[f])),clamp:e.clamp,localSource:e.localSource,localTarget:e.localTarget,additive:e.additive}}function DO(e,t,n,s,r,i,o,a,l){let{timelines:u,name:c}=e,h=0,d=u.attachments.filter((C)=>C.deform!==null),f=u.attachments.filter((C)=>C.sequence!==null);if(f.length>0)t.note("sequence-timeline",`${f.length} sequence timeline(s): ${f.slice(0,3).map((C)=>`${C.skin}/${C.slot}/${C.attachment}`).join(", ")}${f.length>3?", …":""}`,c);let m=null;if(u.drawOrder.length>0){let C=i.length,E=new Int32Array(u.drawOrder.length*C).fill(-1),P=new Uint8Array(C);for(let O=0;Onew Map(C.map((E)=>[E.name,E])),y=[],g=new Map,x=(C,E)=>{let P=g.get(C);if(P!==void 0)return P;let O=[];g.set(C,O);let B=s.get(C.name);if(B===void 0)return O;for(let I of C.timelines){if(I.kind==="inherit"){if(!E)t.note("inherit-timeline",`bone "${C.name}" keys its inherit mode`,c);else for(let N of o)if(N.kind==="slider"&&N.setup.animation===c)t.note("inherit-timeline",`slider "${N.name}" applies animation "${c}" whose bone "${C.name}" keys its inherit mode`);continue}let R=RO[I.kind];O.push({bone:B,curve:Ot(I.keys,R.length),cursor:h++,fields:Int32Array.from(R.map((N)=>N[0])),multiply:Uint8Array.from(R.map((N)=>N[1]))})}return O};for(let C of p(u.bones).values())y.push(...x(C,!1));let b=o.some((C)=>C.kind==="slider"&&C.setup.animation===c)?u.bones.flatMap((C)=>x(C,!0)):[],v=[],_=[...p(u.slots).values()].flatMap((C)=>{let E=r.get(C.name);return E===void 0?[]:[{si:E,target:C}]}).sort((C,E)=>C.si-E.si);for(let{si:C,target:E}of _){if(!i[C].live)continue;for(let P of E.timelines)if(P.kind==="attachment"){let O=Int32Array.from(P.keys.map((B)=>l(C,B.name??null)));v.push({slot:C,curve:Ot(P.keys,0),cursor:h++,attachments:O,channels:null})}else{let O=$O[P.kind];v.push({slot:C,curve:Ot(P.keys,O.length),cursor:h++,attachments:null,channels:Int32Array.from(O)})}}let S=o.map(()=>null);for(let C of o)if(C.kind==="ik"){let E=e.constraints.ik.find((P)=>P.name===C.name);if(E===void 0)continue;S[C.index]={constraint:C.index,curve:Ot(E.keys,2),cursor:h++,flags:Uint8Array.from(E.keys.map((P)=>eT(P.flags.bendPositive,P.flags.compress,P.flags.stretch)))}}else if(C.kind==="transform"){let E=e.constraints.transform.find((P)=>P.name===C.name);if(E===void 0)continue;S[C.index]={constraint:C.index,curve:Ot(E.keys,Ct.length),cursor:h++,flags:null}}let k=o.map((C)=>{if(C.kind!=="slider")return null;let E=e.constraints.slider.find((P)=>P.name===C.name);if(E===void 0)return null;return{time:E.time===null?null:Ot(E.time,1),mix:E.mix===null?null:Ot(E.mix,1),timeCursor:h++,mixCursor:h++}}),w=o.map((C)=>{if(C.kind!=="path")return null;let E=e.constraints.path.find((P)=>P.name===C.name);if(E===void 0)return null;return{position:E.position===void 0?null:Ot(E.position,1),spacing:E.spacing===void 0?null:Ot(E.spacing,1),mix:E.mix===void 0?null:Ot(E.mix,3),positionCursor:h++,spacingCursor:h++,mixCursor:h++}}),T=(e.constraints.physicsKeyed??[]).map((C)=>({kind:C.kind,cursor:h++,curve:Ot(C.keys,C.kind==="reset"?0:1),targets:Int32Array.from(o.filter((E)=>E.kind==="physics"&&E.applied&&(C.name==="*"?C.kind==="reset"||E.setup.global[C.kind]:E.name===C.name)).map((E)=>E.index))})),A=d.map((C)=>{let E=a.skins.find((B)=>B.name===C.skin)?.attachments[C.slot]?.[C.attachment]?.geometry;if(E===void 0||E.kind==="region"||E.kind==="linkedmesh")throw new Ue(`deform "${C.skin}/${C.slot}/${C.attachment}" has no vertex geometry (readModel refuses it first)`);let P=C.deform,O=P.map((B)=>Sf(E.vertices,B));return{identity:`${C.skin}/${C.slot}/${C.attachment}`,cursor:h++,curve:wO(P),count:O[0].length,held:Float64Array.from(O.flat())}});return{name:c,duration:u.duration,physics:T,sliders:k,paths:w,deforms:A,bones:y,sliderBones:b,slots:v,drawOrder:m,constraints:S,cursors:h,events:u.events.length,eventKeys:Object.freeze(n?[]:u.events.map((C)=>Object.freeze({name:C.name,time:C.time,int:C.int,float:C.float,string:C.string,volume:C.volume??0,balance:C.balance??0})))}}class tT{constructor(e,t){this.vertexCount=0,this.triangleCount=0,this.clipped=!1;let n=e*Math.max(3,t*(t+3));if(!Number.isSafeInteger(n)||n<0)throw Error("runtime clip: output capacity is not a safe non-negative integer");this.vertices=new Float32Array(n*2),this.uvs=new Float32Array(n*2),this.triangles=new Int32Array(n*3),this.sources=new Int32Array(n)}}class nT{constructor(e){this.maxPolygonVertices=e,this.nativeRows=!1,this.tri=new Float64Array(6),this.uv=new Float64Array(6),this.regionsCount=0,this.inverse=!1,this.cut=!1,this.n=0;let t=Math.max(3,e);this.points=new Float64Array(t*2),this.ring=new Int32Array(t),this.work=new Int32Array(t),this.sorted=new Int32Array(t),this.hull=new Int32Array(t*2),this.pieces=new Int32Array(t*t),this.sizes=new Int32Array(t),this.merged=new Int32Array(t*2),this.regions=new Float64Array(t*t*2),this.regionSizes=new Int32Array(t),this.a=new Float64Array((t*2+16)*2),this.b=new Float64Array(this.a.length),this.outside=new Float64Array(this.a.length)}cross(e,t,n){let s=this.points;return(s[t*2]-s[e*2])*(s[n*2+1]-s[e*2+1])-(s[t*2+1]-s[e*2+1])*(s[n*2]-s[e*2])}area(e,t){let n=this.points,s=0;for(let r=0;r0&&i<0||r<0&&i>0)&&(o>0&&a<0||o<0&&a>0))return!0;return r===0&&this.on(n,s,e)||i===0&&this.on(n,s,t)||o===0&&this.on(e,t,n)||a===0&&this.on(e,t,s)}region(e,t,n,s=0){let r=this.points,i=0;for(let a=0;a0?t-1-a:a)]*2;this.regions[o+a*2]=r[l],this.regions[o+a*2+1]=r[l+1]}this.regionSizes[n]=t}makeHull(e){let t=this.sorted,n=this.points,s=this.hull;for(let o=0;o0){let u=t[l-1];if(n[u*2]=2&&this.cross(s[r-2],s[r-1],a)<=0)r--;s[r++]=a}r--;let i=r;for(let o=e-1;o>=0;o--){let a=t[o];while(r>=i+2&&this.cross(s[r-2],s[r-1],a)<=0)r--;s[r++]=a}return r-1}plan(e,t){this.nativeRows=!1;let n=this.n,s=this.points,r=this.ring,i=0,o=0;for(let h=0;h0){if(!e&&o===n-i&&o>=3&&this.convex(this.work,o))return this.regionsCount=1,this.inverse=!1,this.region(r,n,0),!1;throw Error("runtime clip: polygon has repeated vertices unsupported by clipShapeOf")}for(let h=0;h0)throw Error("runtime clip: neighbouring polygon edges fold back");for(let m=h+2;m3;){h=!1;for(let d=0;d3){let h=!1;for(let d=0;d=0&&this.cross(m,p,b)>=0&&this.cross(p,f,b)>=0){y=!0;break}}if(y)continue;let g=c*this.maxPolygonVertices;this.pieces[g]=f,this.pieces[g+1]=m,this.pieces[g+2]=p,this.sizes[c++]=3,this.work.copyWithin(d,d+1,u),u--,h=!0;break}if(!h)throw Error("runtime clip: no ear left in a polygon held simple")}for(let h=0;h<3;h++)this.pieces[c*this.maxPolygonVertices+h]=this.work[h];this.sizes[c++]=3;for(let h=!0;h;){h=!1;e:for(let d=0;d1}prepare(e,t,n,s,r){if(this.n=n/2,!Number.isInteger(this.n)||this.n<3||this.n>this.maxPolygonVertices)throw Error("runtime clip: polygon vertex count exceeds its load-time capacity");for(let a=0;ao.length)throw Error("runtime clip: scratch polygon exceeds its load-time capacity");o[a*2]=d+v*x,o[a*2+1]=f+v*b,a++}if(g){if(a*2+2>o.length)throw Error("runtime clip: scratch polygon exceeds its load-time capacity");o[a*2]=m,o[a*2+1]=p,a++}}return a}emit(e,t,n,s,r){if(t<3)return;if((r.vertexCount+t)*2>r.vertices.length||r.triangleCount+t-2>r.sources.length)throw Error("runtime clip: output exceeds its load-time capacity");let i=this.tri,o=this.uv,a=r.vertexCount,l=i[3]-i[5],u=i[4]-i[2],c=i[0]-i[4],h=i[5]-i[1],d=1/(l*c+u*(i[1]-i[5]));for(let f=0;f0;f++){let m=d+f*2,p=d+(f+1)%h*2;u=this.half(a,u,this.regions[m],this.regions[m+1],this.regions[p],this.regions[p+1],l),c||=this.cut;let y=a;a=l,l=y}r.clipped||=c,this.emit(a,u,c,i/3,r)}else{let o=this.a,a=this.b,l=3,u=!1;for(let h=0;h<6;h++)o[h]=this.tri[h];let c=this.regionSizes[0];for(let h=0;h0;h++){let d=h*2,f=(h+1)%c*2,m=this.regions[d],p=this.regions[d+1],y=this.regions[f],g=this.regions[f+1],x=this.half(o,l,y,g,m,p,this.outside),b=this.cut||u;this.emit(this.outside,x,b,i/3,r),l=this.half(o,l,m,p,y,g,a),u||=this.cut;let v=o;o=a,a=v}}}}}class sT{constructor(e){this.model=e,this.nativeRows=!0,this.clipCount=0,this.drawCount=0;let t=[],n=[],s=new Int32Array(e.slots.length),r=3;for(let i of e.attachments){let o=i.clipTopology?.triangles??null,a=i.clipTopology?.uvs??null;if(i.clip!==void 0)r=Math.max(r,i.count/2);if(t.push(o),n.push(a),o!==null)s[i.slot]=Math.max(s[i.slot],o.length/3)}this.triangles=t,this.uvs=n,this.clipper=new nT(r),this.clipSlots=new Int32Array(e.slots.length),this.drawSlots=new Int32Array(e.slots.length),this.outputs=Array.from(s,(i)=>new tT(i,r))}frame(e,t=!1){if(e.model!==this.model)throw Error("runtime clip draw: pose differs from the prepared model");this.clipCount=0,this.drawCount=0,this.nativeRows=!0;let n=!1,s=null;for(let r=0;r0,c=e.y>0,h=e.rotate>0||e.shearX>0,d=e.scaleX>0,f=r;if(o)Ql(t,i);let m=Math.max(i-t.lastTime,0),p=Math.max(0,1-t.remaining/e.step);t.remaining+=m,t.lastTime=i;let y=n[s+4],g=n[s+5],x=0;if(t.pending)t.pending=!1,t.ux=y,t.uy=g;else{let b=t.remaining,{inertia:v,step:_,referenceScale:S}=e,k=-1,w=e.limit*m,T=w;if(u||c){if(u){let A=(t.ux-y)*v;t.xOffset+=A>w?w:A<-w?-w:A,t.ux=y}if(c){let A=(t.uy-g)*v;t.yOffset+=A>T?T:A<-T?-T:A,t.uy=g}if(b>=_){k=Math.pow(e.damping,60*_);let A=e.massInverse*_,C=e.strength,E=e.wind*S,P=e.gravity*S,O=E*a[0]+P*a[2],B=E*a[1]+P*a[3],{xOffset:I,yOffset:R}=t;do{if(u)t.xVelocity+=(O-t.xOffset*C)*A,t.xOffset+=t.xVelocity*_,t.xVelocity*=k;if(c)t.yVelocity-=(B+t.yOffset*C)*A,t.yOffset+=t.yVelocity*_,t.yVelocity*=k;b-=_}while(b>=_);t.xLag=t.xOffset-I,t.yLag=t.yOffset-R}if(x=Math.max(0,1-b/_),u)n[s+4]+=(t.xOffset-t.xLag*x)*l*e.x;if(c)n[s+5]+=(t.yOffset-t.yLag*x)*l*e.y}if(h||d){let A=Math.atan2(n[s+2],n[s+0]),C=0,E=0,P=0,O=t.cx-n[s+4],B=t.cy-n[s+5];if(O>w)O=w;else if(O<-w)O=-w;if(B>T)B=T;else if(B<-T)B=-T;if(h){P=(e.rotate+e.shearX)*l;let I=t.rotateLag*p,R=Math.atan2(B+t.ty,O+t.tx)-A-(t.rotateOffset-I)*P;if(t.rotateOffset+=(R-Math.ceil(R*NO-0.5)*rT)*v,R=(t.rotateOffset-I)*P+A,C=Math.cos(R),E=Math.sin(R),d){if(R=f*Math.sqrt(n[s+0]*n[s+0]+n[s+2]*n[s+2]),R>0)t.scaleOffset+=(O*C+B*E)*v/R}}else{C=Math.cos(A),E=Math.sin(A);let I=f*Math.sqrt(n[s+0]*n[s+0]+n[s+2]*n[s+2])-t.scaleLag*p;if(I>0)t.scaleOffset+=(O*C+B*E)*v/I}if(b=t.remaining,b>=_){if(k===-1)k=Math.pow(e.damping,60*_);let I=e.massInverse*_,R=e.strength,N=e.wind*a[0]+e.gravity*a[2],L=e.wind*a[1]+e.gravity*a[3],U=f/S,{rotateOffset:J,scaleOffset:ee}=t;for(;;){if(b-=_,d)t.scaleVelocity+=(N*C-L*E-t.scaleOffset*R)*I,t.scaleOffset+=t.scaleVelocity*_,t.scaleVelocity*=k;if(h){if(t.rotateVelocity-=((N*E+L*C)*U+t.rotateOffset*R)*I,t.rotateOffset+=t.rotateVelocity*_,t.rotateVelocity*=k,b<_)break;let W=t.rotateOffset*P+A;C=Math.cos(W),E=Math.sin(W)}else if(b<_)break}t.rotateLag=t.rotateOffset-J,t.scaleLag=t.scaleOffset-ee}x=Math.max(0,1-b/_)}t.remaining=b}if(t.cx=n[s+4],t.cy=n[s+5],h){let b=(t.rotateOffset-t.rotateLag*x)*l,v=0,_=0,S=0;if(e.shearX>0){let k=0;if(e.rotate>0)k=b*e.rotate,v=Math.sin(k),_=Math.cos(k),S=n[s+1],n[s+1]=_*S-v*n[s+3],n[s+3]=v*S+_*n[s+3];k+=b*e.shearX,v=Math.sin(k),_=Math.cos(k),S=n[s+0],n[s+0]=_*S-v*n[s+2],n[s+2]=v*S+_*n[s+2]}else b*=e.rotate,v=Math.sin(b),_=Math.cos(b),S=n[s+0],n[s+0]=_*S-v*n[s+2],n[s+2]=v*S+_*n[s+2],S=n[s+1],n[s+1]=_*S-v*n[s+3],n[s+3]=v*S+_*n[s+3]}if(d){let b=1+(t.scaleOffset-t.scaleLag*x)*l*e.scaleX;if(n[s+0]*=b,n[s+2]*=b,e.scaleYMode==="Uniform")n[s+1]*=b,n[s+3]*=b;else if(e.scaleYMode==="Volume"){let v=Math.abs(b),_=v>=0.7?1/v:4-3.67347*v;n[s+1]*=_,n[s+3]*=_}}return t.tx=f*n[s+0],t.ty=f*n[s+2],!0}var _t=rc,Or=2*Te,pf=0.00001,ec=0,tc=1,nc=2,Nr=3,sc=4,h1=new Int32Array([lt,on,It,Bt,Tt,Qn]);function gf(e){return e>180?e-360:e<=-180?e+360:e}function d1(e,t){return e/(t<0.7?0.25+t*0.642857:t)}var Ll=(e)=>e<0?0:e>1?1:e;class iT{constructor(e,t={}){this.trackTime=0,this.time=0,this.fired=[],this.eventTime=-1,this.current=null,this.pathSegmentEnds=new Float64Array(10),this.w=new Float64Array(Oe),this.physicsTime=0,this.physicsLast=-1,this.physicsPhase="none",this.physicsReady=!1,this.environment=new Float64Array([1,0,0,1]),this.model=e,this.clipping=e.attachments.some((a)=>a.clip!==void 0)?new sT(e):null,this.clock=t.clock,this.hasPhysics=e.constraints.some((a)=>a.kind==="physics"),this.physicsStates=e.constraints.map(()=>GO()),this.physicsRecords=e.constraints.map((a)=>a.kind==="physics"?{...a.setup}:null),this.sliderTime=new Float64Array(e.constraints.length),this.sliderMix=new Float64Array(e.constraints.length),this.sliderAt=new Float64Array(e.constraints.length);let n=e.boneNames.length,s=e.slots.length,r=e.constraints.length;this.physicsScope=new Uint8Array(r),this.locals=new Float64Array(n*Mt),this.world=new Float64Array(n*Oe),this.light=new Float64Array(s*4),this.dark=new Float64Array(s*3),this.shown=new Int32Array(s),this.drawOrder=new Int32Array(s);for(let a=0;a0?i*3+2:0),this.pathWorldPts=new Float64Array(o),this.pathChain=new Float64Array(o>0?o+4:0),this.pathCurveEnds=new Float64Array(o>0?Math.ceil(o/6)+1:0),this.changed=new Int32Array(e.scratch),this.inWorld=new Int32Array(e.scratch),this.changedMark=new Uint8Array(n),this.inWorldMark=new Uint8Array(n),this.below=new Uint8Array(n),this.visit=new Uint8Array(n)}get events(){return this.fired}setAnimation(e){this.current=this.model.animation(e),this.physicsTime=0,this.physicsLast=-1,this.physicsReady=!1;for(let t=0;tn)this.fired[i++]=r[o]}for(let o=0;o0:a.time>n))this.fired[i++]=a}this.fired.length=i,this.eventTime=t}boneTimelines(e,t){let n=this.locals,s=this.model.setup;n.set(s);let r=e.bones;for(let i=0;iw1){let N=Math.abs(y*b-g*x)/S;k=y,w=-x*N,T=x,A=y*N,C=u-Math.atan2(x,y)*_t}else k=0,w=-g,T=0,A=b,C=u-90+Math.atan2(b,g)*_t;let E=(C+d)*Je,P=(C+f+90)*Je,O=Math.cos(E)*c,B=Math.cos(P)*h,I=Math.sin(E)*c,R=Math.sin(P)*h;s[r+ge]=k*O+w*I,s[r+Se]=k*B+w*R,s[r+de]=T*O+A*I,s[r+ye]=T*B+A*R;break}default:{let S=u*Je,k=Math.cos(S),w=Math.sin(S),T=y*k+g*w,A=x*k+b*w,C=1/Math.sqrt(T*T+A*A),E=T*C,P=A*C,O=n.modes[e]===Rr&&y*b-g*x<0?-1:1,B=E,I=-P*O,R=P,N=E*O,L=(0+d)*Je,U=(90+f)*Je,J=Math.cos(L)*c,ee=Math.cos(U)*h,W=Math.sin(L)*c,X=Math.sin(U)*h;s[r+ge]=B*J+I*W,s[r+Se]=B*ee+I*X,s[r+de]=R*J+N*W,s[r+ye]=R*ee+N*X}}s[r+me]=y*a+g*l+v,s[r+pe]=x*a+b*l+_}constraintValues(e,t){let n=this.model.constraints;for(let s=0;s=0)l+=(at(a.time,c,0,t)-l)*1}if(a.mix!==null){let c=vt(a.mix,this.cursors,a.mixCursor,t);if(c>=0)u+=(at(a.mix,c,0,t)-u)*1}}this.sliderTime[s]=l,this.sliderMix[s]=u}else if(r.kind==="path"){let a=e===null?null:e.paths[s],{position:l,spacing:u,mixRotate:c,mixX:h,mixY:d}=r;if(a!==null){if(a.position!==null){let m=vt(a.position,this.cursors,a.positionCursor,t);if(m>=0)l=r.position+(at(a.position,m,0,t)-r.position)*1}if(a.spacing!==null){let m=vt(a.spacing,this.cursors,a.spacingCursor,t);if(m>=0)u=r.spacing+(at(a.spacing,m,0,t)-r.spacing)*1}if(a.mix!==null){let m=vt(a.mix,this.cursors,a.mixCursor,t);if(m>=0)c=r.mixRotate+(at(a.mix,m,0,t)-r.mixRotate)*1,h=r.mixX+(at(a.mix,m,1,t)-r.mixX)*1,d=r.mixY+(at(a.mix,m,2,t)-r.mixY)*1}}let f=s*5;this.pathValues[f]=l,this.pathValues[f+1]=u,this.pathValues[f+2]=c,this.pathValues[f+3]=h,this.pathValues[f+4]=d}}}solveConstraints(){let e=this.model.constraints,t=this.model.hasPath;for(let n=0;n0?1:-1}}resetPhysics(e="animation"){this.physicsTime=0,this.physicsLast=-1;for(let t=0;to.name).join(", ")}]`);if(i.kind!=="physics")throw new Ue(`physics movement scope: constraint "${r}" is ${i.kind}, not physics`);t[i.index]=1}return this.model.ignorePhysicsScope?null:t}physicsTranslate(e,t,n){let s=this.checkPhysicsScope(n);if(!Number.isFinite(e)||!Number.isFinite(t))throw new Ue("physicsTranslate: x and y must be finite");for(let r=0;rh||f<=t:f>h&&f<=t)c=!0}if(c)for(let d=0;d=0){let u=e.bone,c=u*Oe,h=u*Mt,d;if(r.local){let f=e.property===0?lt:e.property===1?on:e.property===2?It:e.property===3?Bt:e.property===4?Tt:Qn;d=this.locals[h+f]+0}else{let f=this.world,m=f[c],p=f[c+2],y=f[c+1],g=f[c+3];switch(e.property){case 0:if(d=Math.atan2(p,m)*_t+(m*g-y*p>0?0:-0),d<0)d+=360;break;case 1:d=m*0+y*0+f[c+me];break;case 2:d=p*0+g*0+f[c+pe];break;case 3:d=Math.sqrt(m*m+p*p)+0;break;case 4:d=Math.sqrt(y*y+g*g)+0;break;default:d=(Math.atan2(g,y)-Math.atan2(p,m))*_t-90+0}}s=r.to+(d-r.from)*r.scale,s=r.loop?i.duration===0?0:i.duration+s%i.duration:Math.max(0,s)}let o=this.model.sliderAsTrack?this.time:r.loop&&i.duration!==0?s%i.duration:s;if(this.sliderAt[t]=o,this.physicsPhase!=="none")this.physicsTimelines(i.physics,o,n,r.additive,!1);let a=this.locals,l=this.model.setup;for(let u=0;u0)this.repose(e.bones.length,0)}solvePath(e,t){if(e.attachment<0||this.model.omitPath)return;let n=t*5,s=this.pathValues[n],r=this.pathValues[n+1],i=this.pathValues[n+2],o=this.pathValues[n+3],a=this.pathValues[n+4];if(i===0&&o===0&&a===0)return;let l=e.rotateMode===wm,u=e.rotateMode===JM,c=e.bones,h=c.length,d=l?h:h+1,f=this.pathSpaces,m=this.pathLengths,p=this.world,y=this.model.lengths;if(f[0]=0,e.spacingMode===Kl){if(u)for(let S=0;S0){S=d/S*r;for(let k=1;k0}else S=e.slotEventAt>=0&&this.pathSlotSign[t]>0;v*=S?Je:-Je}for(let S=0,k=3;S=pf){let J=(Math.sqrt(N*N+L*L)/U-1)*i+1;A*=J,E*=J}}if(x=I,b=R,i>0){let U=A,J=C,ee=E,W=P,X;if(l)X=g[k-1];else if(f[S+1]===0)X=g[k+2];else X=Math.atan2(L,N);if(X-=Math.atan2(ee,U),_){let H=Math.cos(X),Z=Math.sin(X),V=y[w];x+=(V*(H*U-Z*ee)-N)*i,b+=(V*(Z*U+H*ee)-L)*i}else X+=v;if(X>Te)X-=Or;else if(X<-Te)X+=Or;X*=i;let F=Math.cos(X),G=Math.sin(X);A=F*U-G*ee,C=F*J-G*W,E=G*U+F*ee,P=G*J+F*W}p[T+ge]=A,p[T+Se]=C,p[T+de]=E,p[T+ye]=P,p[T+me]=O,p[T+pe]=B,this.changed[S]=w,this.inWorld[S]=w}if(h>0)this.repose(h,h)}computePathWorld(e){let t=this.model.attachments[e.attachment],n=this.world,s=this.pathWorldPts,r=this.deformed[e.attachment]!==0;if(t.bindingCounts.length===0){let d=e.slotBone*Oe,f=n[d+ge],m=n[d+Se],p=n[d+de],y=n[d+ye],g=n[d+me],x=n[d+pe],b=r?this.deform:t.local,v=r?t.deformOffset:0;for(let _=0;_R){let V=2*(o-3),Q=2*(o-2);m1(W-R,r[V],r[V+1],r[Q],r[Q+1],l,J);continue}for(;;L++){let V=B[L];if(W>V)continue;if(L===0)W/=V;else{let Q=B[L-1];W=(W-Q)/(V-Q)}break}let X=3*L+1,F=X%o*2,G=(X+1)%o*2,H=(X+2)%o*2,Z=(X+3)%o*2;p1(W,r[F],r[F+1],r[G],r[G+1],r[H],r[H+1],r[Z],r[Z+1],l,J,s||U>0&&ee===0)}return}let h=this.pathChain,d=0;if(c){for(let B=2;B0?m[f-1]:0;if(e.positionMode===Yf)t*=x;let b=e.spacingMode===Kl?x:e.spacingMode===Jl?x/n:1,v=this.pathSegmentEnds;for(let B=0;B<10;B++)v[B]=0;let _=0,S=-1,k=0,w=0,T=0,A=0,C=0,E=0,P=0,O=0;for(let B=0,I=0,R=0,N=0;Bx){m1(U-x,h[d-4],h[d-3],h[d-2],h[d-1],l,I);continue}for(;;R++){let J=m[R];if(U>J)continue;if(R===0)U/=J;else{let ee=m[R-1];U=(U-ee)/(J-ee)}break}if(R!==S){S=R;let J=R*6;k=h[J],w=h[J+1],T=h[J+2],A=h[J+3],C=h[J+4],E=h[J+5],P=h[J+6],O=h[J+7];let ee=(k-T*2+C)*0.03,W=(w-A*2+E)*0.03,X=((T-C)*3-k+P)*0.006,F=((A-E)*3-w+O)*0.006,G=ee*2+X,H=W*2+F,Z=(T-k)*0.3+ee+X*0.16666667,V=(A-w)*0.3+W+F*0.16666667;_=Math.sqrt(Z*Z+V*V),v[0]=_;for(let Q=1;Q<8;Q++)Z+=G,V+=H,G+=X,H+=F,_+=Math.sqrt(Z*Z+V*V),v[Q]=_;Z+=G,V+=H,_+=Math.sqrt(Z*Z+V*V),v[8]=_,Z+=G+X,V+=H+F,_+=Math.sqrt(Z*Z+V*V),v[9]=_,N=0}U*=_;for(;;N++){let J=v[N];if(U>J)continue;if(N===0)U/=J;else{let ee=v[N-1];U=N+(U-ee)/(J-ee)}break}p1(U*0.1,k,w,T,A,C,E,P,O,l,I,s||B>0&&L===0)}}sliderAttachments(){for(let e=0;e=0){let l=this.drawOrder.length,u=r.drawOrder.orders,c=a*l;for(let h=0;h=0)this.deformed[c]=0;this.shown[l.slot]=c}else{let c=l.channels,h=this.model.slots[l.slot],d=l.slot*4,f=l.slot*3;for(let m=0;m=0)h=l[c+ge],d=l[c+Se],f=l[c+de],m=l[c+ye],p=l[c+me],y=l[c+pe];let g=e*Oe,x=t*Oe,b=e*Mt,v=o.modes[e],_=0,S,k;if(v===ql){let E=Math.abs(h*m-d*f)/Math.max(0.00001,h*h+f*f);d=-f*E,m=h*E,_=Math.atan2(f,h)*_t;let P=h*m-d*f,O=l[x+me]-p,B=l[x+pe]-y;if(Math.abs(P)<=0.00001)S=0,k=0;else S=(O*m-B*d)/P-a[b+on],k=(B*h-O*f)/P-a[b+It]}else if(v===zl)S=l[x+me]-l[g+me],k=l[x+pe]-l[g+pe];else{let E=h*m-d*f,P=l[x+me]-p,O=l[x+pe]-y;if(Math.abs(E)<=0.00001)S=0,k=0;else S=(P*m-O*d)/E-a[b+on],k=(O*h-P*f)/E-a[b+It]}let w=a[b+lt],T=a[b+Bt],A=-a[b+Zn]-w+_+Math.atan2(k,S)*_t;if(T<0)A+=180;a[b+lt]=w+gf(A)*n;let C=o.lengths[e]*T;if((s||r)&&C>0.00001){let E=l[x+me]-l[g+me],P=l[x+pe]-l[g+pe],O=v===Rr||v===uc?Math.sqrt(E*E+P*P):Math.sqrt(S*S+k*k);if(s&&OC){let B=(O/C-1)*n+1;if(a[b+Bt]=T*B,i===Xf)a[b+Tt]=a[b+Tt]*B;else if(i===Vf)a[b+Tt]=d1(a[b+Tt],B)}}}solveTwo(e,t,n,s){let r=this.model,i=this.locals,o=this.world,a=e.bones[0],l=e.bones[1];if(r.modes[a]!==Vi||r.modes[l]!==Vi)return!1;let u=(s&jf)!==0,c=r.parents[a]*Oe,h=a*Oe,d=e.target*Oe,f=a*Mt,m=l*Mt,p=o[c+ge],y=o[c+Se],g=o[c+de],x=o[c+ye],b=o[c+me],v=o[c+pe],_=p*x-y*g,S=Math.abs(_)<=0.00001?0:1/_,k=i[f+on],w=i[f+It],T=i[f+Bt],A=i[f+Tt],C=i[m+Bt],E=T,P=A,O=i[m+on],B=i[m+It],I=Math.abs(Math.abs(T)-Math.abs(A))<=0.00001;if(!I||u)B=0;let R=o[h+ge]*O+o[h+Se]*B+o[h+me]-b,N=o[h+de]*O+o[h+ye]*B+o[h+pe]-v,L=(R*x-N*y)*S,U=(N*p-R*g)*S,J=L-k,ee=U-w,W=Math.sqrt(J*J+ee*ee),X=r.lengths[l]*Math.abs(C);if(W<0.00001)return this.solveOne(a,e.target,t,!1,u,0),i[m+lt]=0,i[m+It]=B,!0;R=o[d+me]-b,N=o[d+pe]-v;let F=(R*x-N*y)*S,G=(N*p-R*g)*S;F-=k,G-=w;let H=F*F+G*G,Z=(s&HM)!==0?1:-1;if(n!==0){let oe=n*(Math.abs(T)*(Math.abs(C)+1)*0.5),Ee=Math.sqrt(H),xe=Ee-W-X*Math.abs(T)+oe;if(xe>0){let pt=Math.min(1,xe/(oe*2))-1,Tn=(xe-oe*(1-pt*pt))/Ee;F-=Tn*F,G-=Tn*G,H=F*F+G*G}}let V,Q;if(I){X*=Math.abs(T);let oe=(H-W*W-X*X)/(2*W*X);if(oe<-1)oe=-1,Q=Math.PI*Z;else if(oe>1){if(oe=1,Q=0,u){let pt=(Math.sqrt(H)/(W+X)-1)*t+1;if(E*=pt,e.scaleY===Xf)P*=pt;else if(e.scaleY===Vf)P=d1(P,pt)}}else Q=Math.acos(oe)*Z;let Ee=W+X*oe,xe=X*Math.sin(Q);V=Math.atan2(G*Ee-F*xe,F*Ee+G*xe)}else{let oe=Math.abs(T)*X,Ee=Math.abs(A)*X,xe=oe*oe,pt=Ee*Ee,Tn=pt-xe,Cn=-2*pt*W,Fs=pt*W*W+xe*H-xe*pt,Ur=Cn*Cn-4*Tn*Fs,Wr=!1;if(V=0,Q=0,Ur>=0){let Nt=Math.sqrt(Ur);if(Cn<0)Nt=-Nt;Nt=-(Cn+Nt)*0.5;let An=Nt/Tn,En=Fs/Nt,ln=Math.abs(An)=0){let gn=Math.sqrt(ts)*Z;V=Math.atan2(G,F)-Math.atan2(gn,ln),Q=Math.atan2(gn/Math.abs(A),(ln-W)/Math.abs(T)),Wr=!0}}if(!Wr){let Nt=Te,An=W-oe,En=0,ln=(W-oe)*(W-oe),ts=0,gn=W+oe,Xr=0,cn=(W+oe)*(W+oe),Ds=-oe*W/(xe-pt);if(Ds>=-1&&Ds<=1){let ns=Math.acos(Ds),ho=oe*Math.cos(ns)+W,fo=Ee*Math.sin(ns),mo=ho*ho+fo*fo;if(mocn)ts=ns,gn=ho,Xr=fo,cn=mo}if(H<=(ln+cn)*0.5)V=Math.atan2(G,F)-Math.atan2(En*Z,An),Q=Nt*Z;else V=Math.atan2(G,F)-Math.atan2(Xr*Z,gn),Q=ts*Z}}let he=(T<0?-1:1)*(A<0?-1:1),re=Math.atan2(B,O),Ae=i[f+lt],ae=(V-he*re)*_t+(T<0?180:0)-Ae;i[f+lt]=Ae+gf(ae)*t,i[f+Bt]=E,i[f+Tt]=P;let Pe=((Q+he*re)*_t-i[m+Zn])*he+(C<0?180:0),De=i[m+lt];return i[m+It]=B,i[m+lt]=De+gf(Pe-De)*t,!0}solveTransform(e,t){let n=this.world,s=this.w,r=this.mixes,i=t*6,o=0;for(let a=0;ax?x:y}if(c=!0,e.localTarget){let g=l*Mt+h1[m],x=this.locals[g];this.locals[g]=e.additive?m===Nr||m===sc?x*(1+(y-1)*p):x+y*p:x+(y-x)*p}else UO(s,m,y,p,e.additive)}}if(!c)continue;if(!e.localTarget)n[u+ge]=s[ge],n[u+Se]=s[Se],n[u+de]=s[de],n[u+ye]=s[ye],n[u+me]=s[me],n[u+pe]=s[pe];this.changed[o]=l,this.inWorld[o]=l,o++}if(o>0)this.repose(o,e.localTarget?0:o)}sourceValue(e,t){if(e.localSource)return this.locals[e.source*Mt+h1[t]]+e.offsets[t];let n=this.world,s=e.source*Oe,r=e.offsets,i=n[s+ge],o=n[s+Se],a=n[s+de],l=n[s+ye];switch(t){case ec:{let u=i*l-o*a,c=Math.atan2(a,i)*_t+(u>0?r[ec]:-r[ec]);if(c<0)c+=360;return c}case tc:return i*r[tc]+o*r[nc]+n[s+me];case nc:return a*r[tc]+l*r[nc]+n[s+pe];case Nr:return Math.sqrt(i*i+a*a)+r[Nr];case sc:return Math.sqrt(o*o+l*l)+r[sc];default:return(Math.atan2(l,o)-Math.atan2(a,i))*_t-90+r[5]}}repose(e,t){let n=this.model,s=this.changed,r=this.changedMark,i=this.inWorldMark,o=this.below;for(let h=0;h=0&&s[r]===1&&(n[r]===1||this.changedMark[r]===1))s[e]=1;if(s[e]===1&&this.inWorldMark[e]===0)this.poseBone(e,!1)}localFromWorld(e){let t=this.model,n=this.world,s=this.locals,r=e*Oe,i=e*Mt,o=t.parents[e],a=o<0?Vi:t.modes[e],l=1,u=0,c=0,h=1,d=0,f=0;if(o>=0){let T=o*Oe;l=n[T+ge],u=n[T+Se],c=n[T+de],h=n[T+ye],d=n[T+me],f=n[T+pe]}let m=1/(l*h-u*c),p=n[r+me]-d,y=n[r+pe]-f;s[i+on]=p*(h*m)-y*(u*m),s[i+It]=y*(l*m)-p*(c*m),s[i+Zn]=0;let g=n[r+ge],x=n[r+Se],b=n[r+de],v=n[r+ye];if(a===Rr||a===uc){let T=l*h-u*c,A=a===Rr&&T<0?-1:1,C=T<0?-1:1,E=Math.atan2((l*b-c*g)*C,(h*g-u*b)*C)*_t,P=E*Je,O=Math.cos(P),B=Math.sin(P),I=l*O+u*B,R=c*O+h*B,N=1/Math.sqrt(I*I+R*R);I*=N,R*=N,this.decompose(i,I*g+R*b,(I*b-R*g)*A,I*x+R*v,(I*v-R*x)*A,!0),s[i+lt]=E;return}if(a===zl){this.decompose(i,g,b,x,v);return}if(a===ql){let T=1/(l*l+c*c),A=1/Math.abs(l*h-u*c);this.decompose(i,(l*g+c*b)*T,(l*b-c*g)*A,(l*x+c*v)*T,(l*v-c*x)*A),s[i+lt]=s[i+lt]+Math.atan2(c,l)*_t;return}let _=h*m,S=u*m,k=c*m,w=l*m;this.decompose(i,_*g-S*b,w*b-k*g,_*x-S*v,w*v-k*x)}decompose(e,t,n,s,r,i=!1){let o=this.locals,a=Math.sqrt(t*t+n*n),l=Math.sqrt(s*s+r*r);if(!(a>0.0001)){o[e+Bt]=0,o[e+Tt]=l,o[e+Qn]=0,o[e+lt]=l>0.00001?Math.atan2(r,s)*_t-90:0;return}let u=Math.atan2(n,t)*_t,c=t*r-s*n,h=Math.atan2(r,s)*_t;o[e+(i?Zn:lt)]=u,o[e+Bt]=a,o[e+Tt]=c<0?-l:l;let d=c<0?-90:90,f=h-((i?0:u)+d);f=f>180?f-360:f<-180?f+360:f,o[e+Qn]=l>0.00001?f:0}slotValues(e,t){let n=this.model.slots,s=this.light,r=this.dark;for(let o=0;o=0){let a=n.length,l=e.drawOrder.orders,u=o*a;for(let c=0;cTe)i-=Or;else if(i<-Te)i+=Or;i*=s;let o=Math.cos(i),a=Math.sin(i),l=e[ge],u=e[Se];e[ge]=o*l-a*e[de],e[Se]=o*u-a*e[ye],e[de]=a*l+o*e[de],e[ye]=a*u+o*e[ye];return}case tc:e[me]=r?e[me]+n*s:e[me]+(n-e[me])*s;return;case nc:e[pe]=r?e[pe]+n*s:e[pe]+(n-e[pe])*s;return;case Nr:case sc:{let i=t===Nr?ge:Se,o=t===Nr?de:ye,a=Math.sqrt(e[i]*e[i]+e[o]*e[o]);if(a===0)return;let l=r?1+(n-1)*s:1+(n-a)*s/a;e[i]*=l,e[o]*=l;return}default:{let i=Math.atan2(e[ye],e[Se]),o=Math.atan2(e[de],e[ge]),a=(n+90)*Je-(r?90*Je:i-o);if(!r)a=a>Te?a-Or:a<-Te?a+Or:a;let l=i+a*s,u=Math.sqrt(e[Se]*e[Se]+e[ye]*e[ye]);e[Se]=Math.cos(l)*u,e[ye]=Math.sin(l)*u}}}function f1(e,t,n,s,r,i,o){let a=Math.atan2(r-n,s-t);i[o]=t+e*Math.cos(a),i[o+1]=n+e*Math.sin(a),i[o+2]=a}function m1(e,t,n,s,r,i,o){let a=Math.atan2(r-n,s-t);i[o]=s+e*Math.cos(a),i[o+1]=r+e*Math.sin(a),i[o+2]=a}function p1(e,t,n,s,r,i,o,a,l,u,c,h){if(Number.isNaN(e)){u[c]=t,u[c+1]=n,u[c+2]=Math.atan2(r-n,s-t);return}let d=e*e,f=d*e,m=1-e,p=m*m,y=p*m,g=m*e,x=g*3,b=m*x,v=x*e,_=t*y+s*b+i*v+a*f,S=n*y+r*b+o*v+l*f;if(u[c]=_,u[c+1]=S,h)if(e<0.001)u[c+2]=Math.atan2(r-n,s-t);else u[c+2]=Math.atan2(S-(n*p+r*g*2+o*d),_-(t*p+s*g*2+i*d))}function g1(e,t){if(e.pages===null)throw new Y(`a ${e.spec} document does not state where each region sits on its page; build it with \`rigc build\``);let n=new Map(e.pages.map((i)=>[i.name,i])),s=new Map,r=new Map;for(let i=0;il.length===r.length&&l.every((u,c)=>u===r[c]));if(a===void 0)a=o?r:Object.freeze([...r]),s.lists.push(a),s.byRef.set(a,a);if(o)s.byRef.set(r,a);return a}function jO(e){let t=new Map;for(let n=0;n!0){let s=new Map;if(e.clips.length===0)return s;let r=new Map;for(let a=0;a!0){let{drawn:r,why:i}=H$(e.doc,t.shown,t.drawOrder,e.uv);if(r===null)throw new Y(`the page UVs are not posed: ${i}`);let o=null,a=null,l=null,u=t.clips.length===0?null:zO(t,e.active,s),[c,h,d,f]=n,m=[];for(let p=0;pe[t+r]});return Object.freeze(s)}function qO(e,t){let n=t(),s=e.generation,r=new WeakMap,i=()=>{if(t()!==n)throw Error(`LIVE_FRAME_STALE: borrowed generation ${s} was invalidated; call liveFrame() again`)},o=(u)=>{let c=r.get(u);if(c)return c;let h=new Proxy(Array.isArray(u)?[]:{},{get(d,f){if(i(),f==="buffer"||f==="set"||f==="fill"||f==="copyWithin"||f==="reverse"||f==="sort")throw Error(`LIVE_FRAME_READONLY: ${String(f)} does not expose the live backing store`);let m=Reflect.get(u,f,u);if(typeof m==="function"){if(ArrayBuffer.isView(u)&&f!==Symbol.iterator)throw Error(`LIVE_FRAME_READONLY: ${String(f)} is not part of the indexed live buffer interface`);return(...p)=>{i();let y=Reflect.apply(m,Array.isArray(u)?h:u,p);return y!==null&&typeof y==="object"?o(y):y}}return m!==null&&typeof m==="object"?o(m):m},set(){throw i(),Error("LIVE_FRAME_READONLY: live frame values cannot be assigned")},defineProperty(){throw i(),Error("LIVE_FRAME_READONLY: live frame values cannot be redefined")},deleteProperty(){throw i(),Error("LIVE_FRAME_READONLY: live frame values cannot be deleted")},preventExtensions(){throw i(),Error("LIVE_FRAME_READONLY: live frame objects cannot be reconfigured")},setPrototypeOf(){throw i(),Error("LIVE_FRAME_READONLY: live frame prototypes cannot be changed")},has(d,f){return i(),Reflect.has(u,f)},ownKeys(){return i(),Reflect.ownKeys(u)},getOwnPropertyDescriptor(d,f){if(i(),f==="length"&&Array.isArray(u))return{value:u.length,writable:!0,configurable:!1,enumerable:!1};let m=Reflect.getOwnPropertyDescriptor(u,f);return m?{configurable:!0,enumerable:m.enumerable,get:()=>Reflect.get(h,f)}:void 0}});return r.set(u,h),h},a=o(e),l=Hi.get(e);if(l)Hi.set(a,l);return a}function KO(e,t){return Object.defineProperty(e,"clip",{get:()=>t?.clip??null}),e}class oT{model;pose;renderFrame={order:[]};live;order;tint;templates;clips;colours;revision=0;previousColor=new Float64Array(4).fill(Number.NaN);drawn=0;epoch=0;constructor(e,t){this.model=t??QM(e.doc),this.pose=new iT(this.model),this.order=new Int32Array(this.model.slots.length),this.tint=new Float64Array(this.model.slots.length*4);let n=[],s=[];this.clips=this.model.attachments.map((i)=>i.clip===void 0?null:{polygon:Ul(this.pose.vertices,i.offset,i.count),inverse:i.clip.inverse,convex:i.clip.convex}),this.templates=this.model.attachments.map((i,o)=>{let a=i;if(a.skin===void 0||a.placeholder===void 0)throw Error(`RUNTIME_DRAW_IDENTITY: attachment ${o} on slot "${this.model.slots[i.slot].name}" needs resolved skin and placeholder from rig-c/runtime`);let l=this.model.slots[i.slot],u={...e.doc,slots:e.doc.slots.map((p,y)=>({...p,setup:y===i.slot?a.placeholder:null}))},c=Jn(u),h=c.drawn.find((p)=>p.slot===l.name),d=qf(e,c).order.find((p)=>p.slot===l.name)??null,f=h?.colour??[1,1,1,1];if(n.push(f),d){let p=Ul(this.pose.vertices,i.offset,i.count);if(d.kind==="region")d.corners=p;else d.vertices=p;if(d.tint=Ul(this.tint,i.slot*4,4),l.dark!==null)d.dark=Ul(this.pose.dark,i.slot*3,3)}let m={slot:l.name,slotIndex:i.slot,attachment:i.name,skin:a.skin,placeholder:a.placeholder,kind:d?.kind??"none",region:d?.kind==="region"?d.region:null,page:d?.page??null,pma:d?.pma??!1,blend:l.blend,offset:i.offset,count:i.count,uvs:Object.freeze(d?.uvs??[]),triangles:Object.freeze(d?.kind==="mesh"?d.triangles:[]),dark:d?.dark??null,clip:null};return s.push(Object.freeze(this.pose.clipping===null?m:KO(m,d))),d}),this.colours=n;let r=this;this.live=Object.freeze({get generation(){return r.epoch},get count(){return r.drawn},drawOrder:this.order,vertices:this.pose.vertices,tint:this.tint,attachments:Object.freeze(s)}),Hi.set(this.live,this.renderFrame)}update(e,t,n,s=!0){if(s)this.pose.computeVertices();let r=!1;for(let l=0;l<4;l++){if(!Object.is(this.previousColor[l],t[l]))r=!0;this.previousColor[l]=t[l]}if(r)this.revision++;let i=0,o=null,a=null;for(let l=0;l{let d=c.kind==="region"?c.corners:c.vertices,f=n.get(c.slot);if(f===void 0)throw Error(`LIVE_FRAME_SLOT: drawn slot "${c.slot}" has no setup index`);r.set(d,a),i.set(c.tint,f*4),o[h]=h;let m=t.get(c.slot);if(!m)throw Error(`LIVE_FRAME_IDENTITY: drawn slot "${c.slot}" has no coherent identity`);let p={slot:c.slot,slotIndex:f,attachment:m.attachment,skin:m.skin,placeholder:null,kind:c.kind,region:c.kind==="region"?c.region:null,page:c.page,pma:c.pma,blend:c.blend,offset:a,count:d.length,uvs:c.uvs,triangles:c.kind==="mesh"?c.triangles:[],dark:c.dark??null,clip:c.clip??null};return a+=d.length,p}),u={generation:e.generation??0,count:l.length,drawOrder:o,vertices:r,tint:i,attachments:l};return Hi.set(u,e),u}var yf=Object.freeze({wind:Object.freeze([1,0]),gravity:Object.freeze([0,1])});function Wl(e,t){let n=t?.ease;if(n===void 0)return 0;if(typeof n!=="number"||!Number.isFinite(n)||n<0)throw Error(`${e}: options.ease must be a finite number of seconds at or above 0, got ${typeof n==="number"?String(n):JSON.stringify(n)}`);return n}function ZO(e){return Math.min(Math.max(e.elapsed/e.duration,0),1)}function QO(e){return e*e*(3-2*e)}function Xl(e,t){if(t===void 0)return;if(t===null||typeof t!=="object")throw Error(`${e}: options must be an object like { physics: 'carry' }, got ${JSON.stringify(t)}`);let n=t.physics;if(n===void 0||n==="carry"||n==="reset")return n;throw Error(`${e}: options.physics must be 'carry' or 'reset', got ${JSON.stringify(n)}`)}function xf(e,t){let n=new Set;if(e!==null){for(let[s,r]of e)if(t?.get(s)!==r)n.add(s)}if(t!==null){for(let[s,r]of t)if(e?.get(s)!==r)n.add(s)}return n}function y1(e){return"first"in e?e.track.ctx:e.path.ctx}function eI(e){let t=new Set(e);return(n)=>t.has(n)}function km(e,t){if(t.hides.includes(e))return!0;if(e.endsWith("_still")&&!(e in t.slots)){let n=e.slice(0,-6);if(n in t.slots||t.hides.includes(n))return!0}return!1}function tI(e,t){let n=new Set;for(let s of e.slots)if(s.name in t.slots||km(s.name,t))n.add(s.name);return n}function Kf(e){let t=(e%360+360)%360;if(t>180)t-=360;return t}function bf(e,t){let n=new Set(e.bones.map((o)=>o.name)),s=(o)=>o!==void 0&&o.endsWith("_d")&&n.has(o.slice(0,-2))?o.slice(0,-2):o,r=e.bones.map((o)=>({...o,parent:s(o.parent)})),i=new Map;for(let o=0;oh.name===r[o].name);if(u===void 0)throw Error(`drawn bone ${JSON.stringify(r[o].name)} was not posed`);let c=Kf(a-Kf(Math.atan2(u.c,u.a)*180/Math.PI));r[o]={...r[o],rotation:c},i.set(r[o].name,c)}return i}function nI(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=e.filter((n)=>n.drawn!==void 0);return{name:e.map((n)=>n.name).join("+"),slots:Object.assign({},...e.map((n)=>n.slots)),hides:e.flatMap((n)=>n.hides),...t.length===0?{}:{drawn:Object.assign({},...t.map((n)=>n.drawn))}}}function vf(e,t,n){let s=new Set(Object.keys(n.slots)),r=e.slots.flatMap((b)=>{let v=n.slots[b.name];return v!==void 0?[{...b,setup:v}]:[]}),i=new Map(t.bones.map((b)=>[b.name,{a:b.a,b:b.b,c:b.c,d:b.d,worldX:b.worldX,worldY:b.worldY}])),o=r.length>0?Jn({...e,slots:r,constraints:[]},{evaluate:()=>i,constraints:()=>[]}):null,a=new Map,l=new Map,u=new Map,c=new Map;if(o!==null){for(let b of o.slots)a.set(b[0],b);for(let b of o.shown)l.set(b.slot,b);for(let b of o.drawn)u.set(b.slot,b);for(let b of o.clips)c.set(b[0],b)}let h=new Map(t.shown.map((b)=>[b.slot,b])),d=new Map(t.drawn.map((b)=>[b.slot,b])),f=new Map(t.clips.map((b)=>[b[0],b])),m=(b)=>km(b,n),p=t.slots.map((b)=>{let v=b[0];if(m(v))return[v,null,b[2],b[3],b[4],b[5],b[6],null,b[8]];let _=a.get(v);if(_!==void 0)return[v,_[1],b[2],b[3],b[4],b[5],b[6],_[7],b[8]];return b}),y=[],g=[],x=[];for(let b of t.drawOrder){if(m(b))continue;if(s.has(b)){let v=l.get(b);if(v!==void 0)y.push(v);let _=u.get(b);if(_!==void 0)g.push(_);let S=c.get(b);if(S!==void 0)x.push(S)}else{let v=h.get(b);if(v!==void 0)y.push(v);let _=d.get(b);if(_!==void 0)g.push(_);let S=f.get(b);if(S!==void 0)x.push(S)}}return{...t,slots:p,shown:y,drawn:g,clips:x}}var sI=4096,x1=8,rI=1024;function b1(e){let t=new Map;for(let[n,s]of e.states)t.set(n,{...s});return{phase:e.phase,time:e.time,last:e.last,loop:e.loop,env:e.env,states:t}}function v1(e,t){if(e.phase=t.phase,e.time=t.time,e.last=t.last,t.loop===void 0)delete e.loop;else e.loop=t.loop;if(t.env===void 0)delete e.env;else e.env=t.env;e.states.clear();for(let[n,s]of t.states)e.states.set(n,{...s})}function Vl(e){if("first"in e){let s=e;return{kind:"track",steps:s.steps,latest:s.latest,refused:s.refused,trackTime:s.track.trackTime,last:s.track.last,ctx:b1(s.track.ctx)}}let t=e,n=t.mixer.tracks[0]??null;return{kind:"tracks",started:t.started,steps:t.steps,time:t.time,refused:t.refused,animationsChanged:t.mixer.animationsChanged,propertyIds:new Map(t.mixer.propertyIds),entry:n===null?null:{delay:n.delay,trackTime:n.trackTime,trackLast:n.trackLast,nextTrackLast:n.nextTrackLast,trackEnd:n.trackEnd,animationLast:n.animationLast,nextAnimationLast:n.nextAnimationLast,mixTime:n.mixTime,mixDuration:n.mixDuration,totalAlpha:n.totalAlpha,alpha:n.alpha,additive:n.additive,keepHold:n.keepHold,timelineMode:[...n.timelineMode],timelineHoldMix:[...n.timelineHoldMix],timelinesRotation:[...n.timelinesRotation]},ctx:b1(t.path.ctx)}}function jl(e,t){if(t.kind==="track"){let r=e;r.steps=t.steps,r.latest=t.latest,r.refused=t.refused,r.track.trackTime=t.trackTime,r.track.last=t.last,v1(r.track.ctx,t.ctx);return}let n=e;n.started=t.started,n.steps=t.steps,n.time=t.time,n.refused=t.refused,n.mixer.animationsChanged=t.animationsChanged,n.mixer.propertyIds.clear();for(let[r,i]of t.propertyIds)n.mixer.propertyIds.set(r,i);let s=n.mixer.tracks[0]??null;if(s!==null&&t.entry!==null)s.delay=t.entry.delay,s.trackTime=t.entry.trackTime,s.trackLast=t.entry.trackLast,s.nextTrackLast=t.entry.nextTrackLast,s.trackEnd=t.entry.trackEnd,s.animationLast=t.entry.animationLast,s.nextAnimationLast=t.entry.nextAnimationLast,s.mixTime=t.entry.mixTime,s.mixDuration=t.entry.mixDuration,s.totalAlpha=t.entry.totalAlpha,s.alpha=t.entry.alpha,s.additive=t.entry.additive,s.keepHold=t.entry.keepHold,s.timelineMode=[...t.entry.timelineMode],s.timelineHoldMix=[...t.entry.timelineHoldMix],s.timelinesRotation=[...t.entry.timelinesRotation];v1(n.path.ctx,t.ctx)}class Mm{get renderer(){return this.active}timeScale=1;color=[1,1,1,1];active;root;assets;meshBackend;view;source;read;skinName;seekStep;env=null;track=null;tracks=null;animation=null;loop=!0;trackCount=0;trackMode;beyondBase=!1;paused=!1;pose=null;rawPose=null;setup=null;seekCache=null;poseGeneration=0;runtimeModel=null;runtimeFrames=null;runtimeReadback=null;runtimeCompletionClock={trackTime:0};poserLabel="oracle: not selected";oracleOnly;liveChecks;liveDisposed=!1;cachedIdentity=null;cachedIdentityGen=-1;setList;setsByName;activeList=[];activeSet=null;touchedSets=new Map;drawnPose=null;carryPlant=!1;easing=null;lastStep=0;easePlant=null;adjustFn=null;physicsPatches=new Map;heldParameters=null;slotFilter=null;draws=()=>!0;adjustHook=(e,t)=>{if(this.easing!==null)this.applyEase(this.easing,e);else if(this.drawnPose!==null)for(let[n,s]of this.drawnPose)e.bone(n).rotation=s;if(this.adjustFn!==null)this.adjustFn(e,t)};listeners={event:new Set,complete:new Set};constructor(e,t,n={}){let s=t.document;if(this.read=s,n.poser!==void 0&&n.poser!=="auto"&&n.poser!=="oracle")throw Error(`poser must be auto or oracle, got ${String(n.poser)}`);if(this.oracleOnly=n.poser==="oracle",this.liveChecks=n.liveFrameChecks??!1,this.skinName=n.skin,this.view=n.skin===void 0?Uk(s.doc):If(s.doc,n.skin),this.source=g1(this.view,s.parsed),this.seekStep=n.seekStep??0.016666666666666666,this.trackMode=n.tracks===!0,!(this.seekStep>0))throw Error(`seekStep must be a positive number of seconds, got ${String(n.seekStep)}`);if(this.root=e,this.assets=t,this.setList=t.sets??[],this.setsByName=new Map(this.setList.map((r)=>[r.name,r])),this.meshBackend=n.meshBackend,this.adjustFn=n.adjust??null,n.slots!==void 0&&n.slots!==null)this.slots=n.slots;this.poseGeneration=0,this.cachedIdentity=null,this.active=this.create(n.mode??"dom"),this.selectRuntime()}get mode(){return this.active instanceof Uf?"canvas":"dom"}set mode(e){if(e!=="dom"&&e!=="canvas")throw Error(`mode must be 'dom' or 'canvas', got ${String(e)}`);if(e===this.mode)return;let t=this.active,n=this.create(e);n.pixelRatio=t.pixelRatio,n.clipping=t.clipping,t.dispose(),this.active=n,this.draw()}create(e){if(e==="canvas"){let n=new Uf(this.root,this.assets.pageImages);if(this.assets.stage)n.reserve(this.assets.stage);return n}if(e!=="dom")throw Error(`mode must be 'dom' or 'canvas', got ${String(e)}`);if(this.assets.regions==="none")throw Error("these assets were loaded with regions: 'none' (no region bitmaps, for the canvas mode only); the DOM mode needs a load with regions 'atlas', 'blob' or 'data'");let t=new WM(this.root,this.assets.regionImages,this.assets.pageImages,this.assets.atlasRegions);if(this.meshBackend)t.meshBackend=this.meshBackend;return t}get current(){return this.tracks!==null?this.tracks.current(0)?.animation??null:this.animation}get time(){return this.runtimeFrames?.pose.trackTime??this.tracks?.trackTime??this.track?.trackTime??0}play(e,t={}){let n=t.track??0,s=t.loop??!0,r=t.mix??0,i=t.alpha??1,o=t.additive??!1;this.paused=!1,this.clearSeekCache();let a=n===0&&r===0&&i===1&&!o;if(!a)this.beyondBase=!0;if(this.tracks===null&&a&&!this.trackMode){if(this.tryRuntimePlay(e,s))return;this.oracle("animation not supported by the runtime"),this.animation=e,this.loop=s,this.track=Li(this.view,e,{loop:s,reset:"animation",adjust:this.adjustHook,clock:Hn}),this.setRawPose(this.initializeSingle(this.track)),this.applyEnvironment(this.track);return}let l=this.compose();if(l.setAnimation(n,e,{loop:s,mixDuration:r,alpha:i,additive:o}),this.trackCount=Math.max(this.trackCount,n+1),n===0)this.animation=e,this.loop=s;this.setRawPose(l.step(0))}queue(e,t={}){let n=t.track??0;this.beyondBase=!0,this.clearSeekCache();let s=this.compose();s.addAnimation(n,e,{loop:t.loop??!0,mixDuration:t.mix??0,delay:t.delay??0,alpha:t.alpha??1,additive:t.additive??!1}),this.trackCount=Math.max(this.trackCount,n+1),this.setRawPose(s.step(0))}clear(e=0,t={}){this.beyondBase=!0,this.clearSeekCache();let n=this.compose();n.setEmptyAnimation(e,t.mix??0),this.trackCount=Math.max(this.trackCount,e+1),this.setRawPose(n.step(0))}queueClear(e=0,t={}){this.beyondBase=!0,this.clearSeekCache();let n=this.compose();n.addEmptyAnimation(e,t.mix??0,t.delay??0),this.trackCount=Math.max(this.trackCount,e+1),this.setRawPose(n.step(0))}setAlpha(e,t){this.beyondBase=!0,this.clearSeekCache();let n=this.compose();n.setAlpha(e,t),this.setRawPose(n.step(0))}entry(e=0){if(this.runtimeFrames!==null){if(e!==0||this.animation===null)return null;let n=this.runtimeFrames.pose;return{animation:this.animation,loop:this.loop,trackTime:n.trackTime,animationTime:n.time,duration:this.runtimeFrames.model.animation(this.animation).duration,alpha:1,additive:!1}}if(this.tracks!==null){let n=this.tracks.current(e);return n===null?null:{animation:n.animation,loop:n.loop,trackTime:n.trackTime,animationTime:n.animationTime,duration:n.duration,alpha:n.alpha,additive:n.additive}}let t=this.track;if(e!==0||t===null)return null;return{animation:this.animation,loop:this.loop,trackTime:t.trackTime,animationTime:t.animationTime,duration:t.duration,alpha:1,additive:!1}}get composed(){return this.tracks!==null}compose(){if(this.oracle("track composition"),this.tracks!==null)return this.tracks;this.clearSeekCache();let e=df(this.view,{reset:"animation",adjust:this.adjustHook,clock:Hn}),t=this.track,n=t?.trackTime??0;if(t!==null&&this.animation!==null)e.setAnimation(0,this.animation,{loop:this.loop,mixDuration:0}),this.trackCount=1;if(this.tracks=e,this.track=null,this.setRawPose(e.start()),this.applyPhysicsParameters(e),this.applyEnvironment(e),n>0)this.stepTo(n);return e}setRawPose(e){this.rawPose=e,this.heldParameters=null;let t=this.shownSet();this.pose=t===null?e:vf(this.view,e,t),this.poseGeneration++,this.cachedIdentity=null}setPhysicsParameters(e,t){let n=this.requirePhysicsTrack("setPhysicsParameters",e);n.setPhysicsParameters(e,t);let s=n.readPhysicsParameters(e).override;if(s!==null)this.physicsPatches.set(e,s);this.clearSeekCache()}readPhysicsParameters(e){let t=this.requirePhysicsTrack("readPhysicsParameters",e).readPhysicsParameters(e);if(this.heldParameters===null)return t;let n=this.heldParameters.get(e)?.effective??null;return{override:t.override,effective:n===null?null:{...n}}}clearPhysicsParameters(e){this.requirePhysicsTrack("clearPhysicsParameters",e).clearPhysicsParameters(e),this.physicsPatches.delete(e),this.clearSeekCache()}requirePhysicsTrack(e,t){let n=this.stepper();if(n===null)throw Error(`${e}(${JSON.stringify(t)}) before play: no live track`);return n}readParameters(e){return new Map(this.view.constraints.filter((t)=>t.kind==="physics").map((t)=>[t.name,e.readPhysicsParameters(t.name)]))}applyPhysicsParameters(e){for(let[t,n]of this.physicsPatches)e.setPhysicsParameters(t,n)}initializeSingle(e){return this.applyPhysicsParameters(e),e.first}environment(e){if(e===null)this.env=null,this.clearSeekCache(),this.stepper()?.setEnvironment(yf);else if(e!==void 0){this.clearSeekCache();let t=this.stepper();if(t)t.setEnvironment(e),this.env=t.environment;else{let n=this.env??yf;this.env={wind:e.wind??n.wind,gravity:e.gravity??n.gravity}}}return this.stepper()?.environment??this.env??yf}moved(e){if(this.runtimeFrames!==null&&Number.isFinite(e.x??0)&&Number.isFinite(e.y??0)&&Number.isFinite(e.rotation??0))return;let t=this.stepper();if(!t)return;let n=e.x??0,s=e.y??0;if(n!==0||s!==0)t.physicsTranslate(n,s);if(e.rotation)t.physicsRotate(0,0,e.rotation)}physicsMoved(e,t){let n=(f,m,p)=>{if(f===null||typeof f!=="object"||Array.isArray(f))throw Error(`physicsMoved: ${p} must be an object`);for(let y of Reflect.ownKeys(f))if(typeof y!=="string"||!m.includes(y))throw Error(`physicsMoved: unknown ${p} field ${String(y)}`);return f},s=(f,m)=>{if(typeof f!=="number"||!Number.isFinite(f))throw Error(`physicsMoved: ${m} must be a finite number, got ${String(f)}`);return f},r=n(e,["bone","subtree","constraints"],"scope"),i=Object.keys(r);if(i.length!==1)throw Error("physicsMoved: scope must name exactly one of bone, subtree, constraints");let o=i[0],a;if(o==="constraints"){if(!Array.isArray(r.constraints))throw Error("physicsMoved: constraints must be an array of exact physics names");a=[];for(let f of r.constraints){if(typeof f!=="string")throw Error(`physicsMoved: constraint name ${String(f)} must be a string`);let m=this.view.constraints.find((p)=>p.kind==="physics"&&p.name===f)??this.view.constraints.find((p)=>p.name===f);if(m===void 0)throw Error(`physicsMoved: no constraint ${JSON.stringify(f)}`);if(m.kind!=="physics")throw Error(`physicsMoved: constraint ${JSON.stringify(f)} is ${m.kind}, not physics`);if(!a.includes(f))a.push(f)}}else{let f=r[o];if(typeof f!=="string"||!this.view.bones.some((y)=>y.name===f))throw Error(`physicsMoved: no bone ${JSON.stringify(f)}`);let m=new Map(this.view.bones.map((y)=>[y.name,y.parent])),p=(y)=>{if(o==="bone")return y===f;for(let g=y;g!==void 0;g=m.get(g))if(g===f)return!0;return!1};a=this.view.constraints.filter((y)=>y.kind==="physics"&&p(y.record?.bone)).map((y)=>y.name)}let l=n(t,["translation","rotation"],"motion");if(Object.keys(l).length!==1)throw Error("physicsMoved: motion must name exactly one of translation, rotation");let u,c,h;if("translation"in l){let f=n(l.translation,["x","y"],"translation");u=s(f.x,"translation.x"),c=s(f.y,"translation.y")}else{let f=n(l.rotation,["degrees","pivot"],"rotation");if(h=s(f.degrees,"rotation.degrees"),!Array.isArray(f.pivot)||f.pivot.length!==2)throw Error("physicsMoved: rotation.pivot must be two finite world coordinates");u=s(f.pivot[0],"rotation.pivot[0]"),c=s(f.pivot[1],"rotation.pivot[1]")}if(a.length===0||(h===void 0?u===0&&c===0:h===0))return;let d=this.stepper();if(d===null)return;if(h===void 0)d.physicsTranslate(u,c,a);else d.physicsRotate(u,c,h,a);this.clearSeekCache()}pause(){this.paused=!0}resume(){this.paused=!1}seek(e){if(this.animation===null)throw Error("seek before play: no animation is open");if(!(e>=0)||!Number.isFinite(e))throw Error(`seek time must be a finite time at or above 0, got ${String(e)}`);if(this.beyondBase)throw Error("seek is defined for a single animation on track 0; after a mix, another track, a queue or a clear the player cannot replay to a time — step it forward with frame/advance instead");if(this.runtimeFrames!==null){let l=Math.floor(e/this.seekStep),u=0;for(let h=0;h0)u+=c;this.runtimeFrames.pose.trackTime=u,this.applyRuntimeTime();return}this.easing=null;let t=this.ensureSeekCache(),n=this.tracks??this.track,s=t.exact.get(e);if(s!==void 0){jl(n,s.state),this.rawPose=s.rawPose,this.pose=s.pose,this.heldParameters=s.parameters,this.poseGeneration++,this.cachedIdentity=null;return}let r=Math.floor(e/this.seekStep);while(t.frontierSteps0)this.rawPose=n.step(a),i=this.readParameters(n);if(this.rawPose!==null)this.setRawPose(this.rawPose);if(this.heldParameters=i,this.rawPose!==null&&this.pose!==null){if(t.exact.size>=rI){let l=t.exact.keys().next().value;if(l!==void 0)t.exact.delete(l)}t.exact.set(e,{state:Vl(n),rawPose:this.rawPose,pose:this.pose,parameters:i})}}clearSeekCache(){this.seekCache=null}ensureSeekCache(){let e=this.tracks!==null?"tracks":"track";if(this.seekCache!==null&&this.seekCache.mode===e)return this.seekCache;if(this.tracks===null&&this.track===null)this.reopen();let t,n;if(e==="tracks"){let r=df(this.view,{reset:"animation",adjust:this.adjustHook,clock:Hn});r.setAnimation(0,this.animation,{loop:this.loop,mixDuration:0}),n=r.start(),this.applyPhysicsParameters(r),this.applyEnvironment(r),t=r}else{let r=Li(this.view,this.animation,{loop:this.loop,reset:"animation",adjust:this.adjustHook,clock:Hn});n=this.initializeSingle(r),this.applyEnvironment(r),t=r}let s=new Map;return s.set(0,{state:Vl(t),rawPose:n,parameters:this.readParameters(t)}),this.seekCache={mode:e,frontier:t,frontierSteps:0,grid:s,exact:new Map},this.seekCache}reopen(){if(this.tracks!==null){let e=df(this.view,{reset:"animation",adjust:this.adjustHook,clock:Hn});e.setAnimation(0,this.animation,{loop:this.loop,mixDuration:0}),this.trackCount=1,this.tracks=e,this.setRawPose(e.start()),this.applyPhysicsParameters(e),this.applyEnvironment(e);return}this.track=Li(this.view,this.animation,{loop:this.loop,reset:"animation",adjust:this.adjustHook,clock:Hn}),this.setRawPose(this.initializeSingle(this.track)),this.applyEnvironment(this.track)}stepper(){return this.oracle("oracle track operation"),this.tracks??this.track}applyEnvironment(e){if(this.env!==null)e.setEnvironment(this.env)}stepTo(e){let t=this.tracks??this.track,n=Math.floor(e/this.seekStep);for(let r=0;r0)this.rawPose=t.step(s);if(this.rawPose!==null)this.setRawPose(this.rawPose)}on(e,t){let n=this.listeners[e];return n.add(t),()=>n.delete(t)}frame(e){this.advance(e),this.draw()}advance(e){if(this.runtimeFrames!==null){let o=e*this.timeScale;if(this.paused||!(o>0))return;if(!Number.isFinite(o))throw Error(`advance step must be finite, got ${String(o)}`);let a=this.runtimeFrames.pose.trackTime,l=this.runtimeFrames.model.animations.get(this.animation).duration;this.runtimeFrames.pose.trackTime+=o,this.lastStep=o,this.applyRuntimeTime();let u=this.runtimeCompletionClock;if(this.listeners.event.size>0){let c=this.runtimeFrames.pose.events.slice();for(let h of c){let d={name:h.name,time:h.time,int:h.int,float:h.float,string:h.string,track:0};for(let f of this.listeners.event)f(d)}}if(this.listeners.complete.size>0){let c=u.trackTime;if(this.loop?l===0||Math.floor(c/l)>Math.floor(a/l):a=l){let d={animation:this.animation,track:0};for(let f of this.listeners.complete)f(d)}}return}if(this.pose===null)return;let t=e*this.timeScale;if(this.paused||!(t>0))return;if(this.lastStep=t,this.easing!==null)this.advanceEase(this.easing,t);let n=this.tracks;if(n!==null){let o=[];for(let l=0;le.name)}setSet(e,t){if(this.setList.length===0)throw Error(`cannot setSet(${JSON.stringify(e)}): this model has no sets.json`);let n=Xl("setSet",t),s=Wl("setSet",t);this.activate(e===null?[]:[this.namedSet(e)],n,s)}setSets(e,t){if(this.setList.length===0)throw Error(`cannot setSets(${JSON.stringify(e)}): this model has no sets.json`);let n=Xl("setSets",t),s=Wl("setSets",t),r=e.map((i)=>this.namedSet(i));for(let i=0;ii!==r),n,s)}namedSet(e){let t=this.setsByName.get(e);if(t===void 0)throw Error(`no set named ${JSON.stringify(e)} in sets.json (available: ${this.setList.map((n)=>n.name).join(", ")})`);return t}reposeDrawn(){let e=this.tracks??this.track;if(e!==null&&this.pose!==null){this.setRawPose(e.step(0));return}this.setRawPose(this.drawnSetup())}drawnSetup(){let e=this.setup??(this.setup=Jn(this.view));if(this.drawnPose===null)return e;return Jn({...this.view,bones:this.view.bones.map((t)=>{let n=this.drawnPose?.get(t.name);return n===void 0?t:{...t,rotation:n}})})}touched(e){let t=this.touchedSets.get(e.name);if(t===void 0)t=tI(this.view,e),this.touchedSets.set(e.name,t);return t}handOverPhysics(e,t){let n=this.tracks??this.track;if(n===null||this.pose===null||this.rawPose===null)return;if(e.size===0)return;let s=new Map(this.view.bones.map((m)=>[m.name,m.parent])),r=(m)=>{for(let p=m;p!==void 0;p=s.get(p))if(e.has(p))return p;return},i=y1(n),o=[];for(let m of this.view.constraints){if(m.kind!=="physics")continue;let p=m.record?.bone,y=p===void 0?void 0:r(p);if(y===void 0)continue;let g=i.states.get(m.name);if(g===void 0||g.pending)continue;o.push({name:m.name,anchor:y})}if(o.length===0)return;if(t==="reset"){for(let{name:m}of o){let p=i.states.get(m);p.remaining=0,p.lastTime=i.time,p.pending=!0,p.xOffset=p.xLag=p.xVelocity=0,p.yOffset=p.yLag=p.yVelocity=0,p.rotateOffset=p.rotateLag=p.rotateVelocity=0,p.scaleOffset=p.scaleLag=p.scaleVelocity=0}return}let a=new Set(o.map((m)=>m.anchor)),l=(m)=>{let p=new Map;for(let y of m.bones)if(a.has(y.name))p.set(y.name,y);return p},u=l(this.rawPose),c=Vl(n),h=l(n.step(0));jl(n,c);let d=new Map;for(let m of a){let p=u.get(m),y=h.get(m);if(p===void 0||y===void 0)continue;if(this.carryPlant){d.set(m,[1,0,0,1,0,0]);continue}let g=p.a*p.d-p.b*p.c;if(!Number.isFinite(g)||g===0)continue;let x=p.d/g,b=-p.b/g,v=-p.c/g,_=p.a/g,S=y.a*x+y.b*v,k=y.a*b+y.b*_,w=y.c*x+y.d*v,T=y.c*b+y.d*_;d.set(m,[S,k,w,T,y.worldX-(S*p.worldX+k*p.worldY),y.worldY-(w*p.worldX+T*p.worldY)])}let f=y1(n).states;for(let{name:m,anchor:p}of o){let y=d.get(p),g=f.get(m);if(y===void 0||g===void 0)continue;let[x,b,v,_,S,k]=y,w=g.ux;g.ux=x*w+b*g.uy+S,g.uy=v*w+_*g.uy+k;let T=g.cx;g.cx=x*T+b*g.cy+S,g.cy=v*T+_*g.cy+k;let A=g.tx;g.tx=x*A+b*g.ty,g.ty=v*A+_*g.ty}}shownSet(){let e=this.easing;return e===null||e.swapped?this.activeSet:e.fromSet}easedLocal(e,t,n,s){let r=t??s,i=n??s,o=ZO(e),a=this.easePlant==="overshoot"?o<1?1.2*o:1:QO(o);return r+Kf(i-r)*a}applyEase(e,t){for(let n of e.bones.keys())e.clip.set(n,t.bone(n).rotation);if(this.drawnPose!==null){for(let[n,s]of this.drawnPose)if(!e.bones.has(n))t.bone(n).rotation=s}for(let[n,{from:s,to:r}]of e.bones)t.bone(n).rotation=this.easedLocal(e,s,r,e.clip.get(n))}startEase(e,t,n,s){if((this.tracks??this.track)===null||this.pose===null)return!1;let i=this.drawnPose,o=n===void 0?null:bf(this.view,n),a=this.easing,l=xf(i,o);if(a!==null)for(let h of a.bones.keys())l.add(h);let u=new Map;for(let h of l){let d=o?.get(h)??null,f,m=a?.bones.get(h);if(a!==null&&m!==void 0)f=a.elapsed>0?this.easedLocal(a,m.from,m.to,a.clip.get(h)):m.from;else f=i?.get(h)??null;if(f===d)continue;u.set(h,{from:f,to:d})}if(u.size===0)return!1;let c={duration:e,elapsed:0,bones:u,clip:new Map,fromSet:t,swapped:!1,physics:s};if(this.easePlant==="swap-at-0"||this.swapsNow(0,this.lastStep/e))c.swapped=!0;if(this.easing=c,this.drawnPose=o,s==="reset")this.handOverPhysics(new Set(u.keys()),"reset");return this.reposeDrawn(),!0}swapsNow(e,t){if(e>=0.5)return!0;return t>e&&0.5-e=e.duration)this.easing=null;else if(!e.swapped&&this.swapsNow(e.elapsed/e.duration,(e.elapsed+t)/e.duration))e.swapped=!0;if(e.physics==="carry")this.handOverPhysics(new Set(e.bones.keys()),"carry")}activate(e,t,n=0){this.oracle("attachment sets");for(let l=0;le.includes(l)),this.activeSet=nI(this.activeList),this.clearSeekCache();let i=this.activeSet?.drawn;if(n>0&&this.startEase(n,r,i,t))return;let o=this.easing;if(o!==null){this.easing=null;let l=this.drawnPose;this.drawnPose=i===void 0?null:bf(this.view,i);let u=xf(l,this.drawnPose);for(let c of o.bones.keys())u.add(c);if(t!==void 0)this.handOverPhysics(u,t);this.reposeDrawn();return}if(i!==s&&!(i===void 0&&s===void 0)){let l=this.drawnPose;if(this.drawnPose=i===void 0?null:bf(this.view,i),t!==void 0)this.handOverPhysics(xf(l,this.drawnPose),t);this.reposeDrawn();return}let a=this.rawPose??(this.setup??(this.setup=Jn(this.view)));this.rawPose=a,this.pose=this.activeSet===null?a:vf(this.view,a,this.activeSet),this.poseGeneration++,this.cachedIdentity=null}get slots(){return this.slotFilter}set slots(e){if(e===null){this.slotFilter=null,this.draws=()=>!0,this.poseGeneration++,this.cachedIdentity=null;return}if(typeof e==="function"){this.slotFilter=e,this.draws=e,this.poseGeneration++,this.cachedIdentity=null;return}if(!Array.isArray(e))throw Error(`slots must be an array of slot names, a function, or null, got ${typeof e}`);let t=new Set(this.read.doc.slots.map((r)=>r.name)),n=e.filter((r)=>!t.has(r));if(n.length>0)throw Error(`no slot named ${n.map((r)=>JSON.stringify(r)).join(", ")} in this document (slots: ${[...t].join(", ")})`);let s=new Set(e);this.slotFilter=[...e],this.draws=(r)=>s.has(r),this.poseGeneration++,this.cachedIdentity=null}get adjust(){return this.adjustFn}set adjust(e){if(e!==null&&typeof e!=="function")throw Error(`adjust must be a function or null, got ${typeof e}`);this.oracle("local adjustment"),this.adjustFn=e,this.clearSeekCache(),this.repose()}repose(){if(this.runtimeFrames!==null){this.applyRuntimeTime();return}this.clearSeekCache();let e=this.tracks??this.track;if(e===null||this.pose===null)return;this.setRawPose(e.step(0))}bone(e){let t=this.posed();for(let n of t.bones){if(n.name!==e)continue;return{name:e,active:n.active,x:n.worldX,y:n.worldY,a:n.a,b:n.b,c:n.c,d:n.d,rotationX:n.rotationX,rotationY:n.rotationY,scaleX:n.scaleX,scaleY:n.scaleY}}throw Error(`no bone named ${JSON.stringify(e)} in this document (bones: ${t.bones.map((n)=>n.name).join(", ")})`)}bounds(){let e=this.runtimeFrames!==null?this.posedFrame():this.pose===null?qf(this.source,this.posed(),this.color,this.draws):this.posedFrame(),t=1/0,n=1/0,s=-1/0,r=-1/0;for(let i of e.order){let o=i.kind==="region"?i.corners:i.vertices,a=-1/0,l=-1/0,u=1/0,c=1/0;if(i.clip&&!i.clip.inverse){let h=i.clip.polygon;a=1/0,l=1/0,u=-1/0,c=-1/0;for(let d=0;du)u=h[d];if(h[d+1]c)c=h[d+1]}}for(let h=0;hs)s=d;if(fr)r=f}}if(t===1/0)return null;return{x:t,y:n,width:s-t,height:r-n}}posed(){if(this.runtimeFrames!==null&&this.animation!==null){if(this.runtimeReadback===null){let e=Li(this.view,this.animation,{loop:this.loop,reset:"animation",clock:Hn});this.runtimeReadback=this.time>0?e.step(this.time):e.first}return this.runtimeReadback}if(this.pose!==null)return this.pose;if(this.setup===null)this.setup=Jn(this.view);return this.activeSet===null?this.setup:vf(this.view,this.setup,this.activeSet)}get poser(){return this.runtimeFrames!==null?"runtime":this.poserLabel==="runtime"?"oracle: no runtime animation is active":this.poserLabel}selectRuntime(){if(this.runtimeModel=null,this.oracleOnly){this.poserLabel="oracle: explicitly selected";return}let e=this.view.constraints.find((t)=>t.kind==="physics");if(e){this.poserLabel=`oracle: physics constraint "${e.name}" requires player clock, seek and movement integration`;return}try{this.runtimeModel=QM(this.view),this.poserLabel=this.trackMode?"oracle: track composition":this.adjustFn!==null?"oracle: local adjustment":"runtime"}catch(t){if(!(t instanceof no))throw t;this.poserLabel=`oracle: ${t.message}`}}tryRuntimePlay(e,t){if(this.runtimeModel===null)return!1;let n=this.trackMode?"track composition":this.adjustFn!==null?"local adjustment":this.activeSet!==null?"attachment sets":this.easing!==null?"set easing":this.env!==null?"environment configuration":null;if(n!==null)return this.poserLabel=`oracle: ${n}`,!1;if(!this.runtimeModel.animations.has(e)){let r=this.runtimeModel.refused.find((i)=>i.animation===e);if(r)this.poserLabel=`oracle: ${new no(r.missing).message}`;return!1}let s=this.runtimeFrames??new oT(this.source,this.runtimeModel);return s.pose.setAnimation(e),s.pose.apply(0),this.runtimeFrames=s,this.runtimeCompletionClock={trackTime:0},this.animation=e,this.loop=t,this.track=null,this.tracks=null,this.pose=null,this.rawPose=null,this.poserLabel="runtime",this.poseGeneration++,this.cachedIdentity=null,this.runtimeReadback=null,s.update(this.poseGeneration,this.color,this.draws),!0}applyRuntimeTime(){let e=this.runtimeFrames,t=e.model.animations.get(this.animation).duration,n=e.pose.trackTime;this.runtimeCompletionClock.trackTime=n,e.pose.apply(t===0?0:this.loop?n%t:Math.min(n,t)),this.poseGeneration++,this.cachedIdentity=null,this.runtimeReadback=null,e.update(this.poseGeneration,this.color,this.draws)}oracle(e){if(this.runtimeFrames===null||this.animation===null)return;let t=this.runtimeFrames.pose.trackTime,n=this.poseGeneration;if(this.runtimeFrames=null,this.runtimeReadback=null,this.poserLabel==="runtime")this.poserLabel=`oracle: ${e}`;if(this.track=Li(this.view,this.animation,{loop:this.loop,reset:"animation",adjust:this.adjustHook,clock:Hn}),this.setRawPose(this.track.first),t>0)this.setRawPose(this.track.step(t));this.poseGeneration=n,this.applyEnvironment(this.track)}liveFrame(){if(this.liveDisposed)throw Error("LIVE_FRAME_DISPOSED: cannot borrow a frame after dispose");let e;if(this.runtimeFrames!==null)this.runtimeFrames.update(this.poseGeneration,this.color,this.draws,!1),e=this.runtimeFrames.live;else{let t=new Map(this.slotIdentity().slots.map((n)=>[n.slot,n]));e=JO(this.posedFrame(),t,this.source.slotIndex)}return this.liveChecks?this.checkedFrame(e):e}checkedFrame(e){let t=this.poseGeneration,n=this.runtimeFrames,s=n?.revision;return qO(e,()=>this.poseGeneration===t&&(n===null||n.revision===s)?t:-1)}get generation(){return this.poseGeneration}posedFrame(e){let t=e===void 0?this.draws:e===null?()=>!0:typeof e==="function"?e:eI(e);if(this.runtimeFrames!==null)this.runtimeFrames.update(this.poseGeneration,this.color,this.draws,!1);let n=this.runtimeFrames!==null?this.runtimeFrames.snapshot(t):this.pose===null?{order:[]}:qf(this.source,this.pose,this.color,t);return Object.defineProperty(n,"generation",{value:this.poseGeneration,enumerable:!1,configurable:!0}),n}slotIdentity(){if(this.cachedIdentity!==null&&this.cachedIdentityGen===this.poseGeneration)return this.cachedIdentity;let e=this.setup??(this.setup=Jn(this.view)),t=this.posed(),n=this.runtimeFrames!==null?t:this.rawPose??e,s=new Map(t.shown.map((u)=>[u.slot,u])),r=new Set(e.shown.map((u)=>u.slot)),i=new Map(n.slots.map((u)=>[u[0],u])),o=[],a=this.shownSet();for(let u=0;u{if(s===null)return;let i=this.view.animations.find((l)=>l.name===s);if(i===void 0)return;let o=i.timelines.slots.find((l)=>l.name===e);if(o===void 0)return;let a;for(let l of o.timelines){if(l.kind!=="attachment")continue;let u=null;for(let c of l.keys)if(c.time<=r)u=c;else break;if(u!==null)a=u.name===null||u.name===void 0}return a};if(this.tracks!==null){let s=!1;for(let r=0;r0)for(let[s,r,i,o,a]of e.events){let l={name:s,time:r,int:i,float:o,string:a,track:0};for(let u of this.listeners.event)u(l)}if(this.listeners.complete.size>0){let{duration:s,trackTime:r}=n,i=s>0?Math.floor(r/s):1/0,o=s>0?Math.floor(t/s):-1/0;if(this.loop?i>0&&i>o:t=s){let a={animation:this.animation,track:0};for(let l of this.listeners.complete)l(a)}}}dispatch(e,t,n){let s=[];for(let i=0;ii!==null&&o!==null&&i.animation===o.animation&&i.loop===o.loop&&o.trackTime>=i.trackTime;if(this.listeners.event.size>0&&e.events.length>0){let i=[],o=0;for(let c=0;cp.name===h.animation)?.timelines.events??[];if(m.length>0){let p=r(d,h)?d.animationTime:-1;f=nm(m,p,h.animationTime,void 0,h.animationTime0)for(let i=0;i0?Math.floor(o.trackTime/l):1/0,c=l>0?Math.floor(a.trackTime/l):-1/0;if(!(o.loop?u>0&&u>c:a.trackTime=l))continue;let d={animation:o.animation,track:i};for(let f of this.listeners.complete)f(d)}}}var Bs=Object.freeze([]),aT=new WeakSet,lT=new WeakSet,iI=["slot","slotIndex","attachment","skin","placeholder","kind","region","page","pma","blend","offset","count"];function hT(e){if(lT.has(e))return!0;if(!Object.isFrozen(e))return!1;let t=Object.getOwnPropertyDescriptors(e);if(!iI.every((n)=>{let s=t[n];return s&&"value"in s&&(s.value===null||!["object","function"].includes(typeof s.value))}))return!1;return lT.add(e),!0}function Is(e,t,n,s){if(e&&typeof e==="object"&&aT.has(e))return;if(!e||typeof e!=="object"||!Number.isInteger(e.length)||e.length<0)throw Error(`${t}: live ${s===void 0?n:`slot "${s}" ${n}`} needs an indexed buffer with nonnegative integer length`);let r=Object.getOwnPropertyDescriptor(e,"length");if(r&&"value"in r&&!r.writable&&!r.configurable&&Object.isFrozen(e))aT.add(e)}var uo=class{constructor(e){this.count=e}count;source=Bs;offset=0};function lo(e){return e instanceof uo?e.source:e}function co(e){return e instanceof uo?e.offset:0}function Lr(e){return e instanceof uo?e.count:e?e.length:-1}var oI=class{constructor(e="PixiRenderer"){this.owner=e}owner;order=[];rows=[];validated=new WeakSet;read(e){e.generation;let{drawOrder:t,vertices:n,tint:s,attachments:r,count:i}=e,o=this.owner;if(Is(t,o,"drawOrder"),Is(n,o,"vertices"),Is(s,o,"tint"),!Number.isInteger(i)||i<0||i>t.length)throw Error(`${o}: live frame count=${i} needs an integer in 0..${t.length}`);for(let a=0;an.length||c.slotIndex*4+4>s.length)throw Error(`${o}: live slot "${c.slot}" has invalid vertex span ${c.offset}+${c.count} or tint slotIndex=${c.slotIndex}`);let h=this.rows[a];if(!h||h.slot.kind!==c.kind||h.points.count!==c.count){let f=new uo(c.count),m=new uo(4),p={slot:c.slot,blend:c.blend,tint:m,page:c.page??"",pma:c.pma,uvs:Bs};h={slot:c.kind==="region"?{...p,kind:"region",region:c.region??"",corners:f}:{...p,kind:"mesh",vertices:f,triangles:Bs},points:f,tint:m},this.rows[a]=h}h.points.source=n,h.points.offset=c.offset,h.tint.source=s,h.tint.offset=c.slotIndex*4;let d=h.slot;if(d.slot=c.slot,d.blend=c.blend,d.page=c.page??"",d.pma=c.pma,d.uvs=c.uvs,d.dark=c.dark??void 0,d.clip=c.clip??void 0,d.kind==="region")d.region=c.region??"";else d.triangles=c.triangles;this.order[a]=d}return this.order.length=i,this.order}release(){for(let e of this.rows)if(e.points.source=Bs,e.tint.source=Bs,e.slot.uvs=Bs,e.slot.dark=void 0,e.slot.clip=void 0,e.slot.kind==="mesh")e.slot.triangles=Bs}};function aI(e){return JSON.stringify([e.slotIndex,e.slot,e.skin,e.placeholder,e.attachment,e.kind,e.page,e.region])}function lI(e){let t={slot:e.slot,z:e.slotIndex,blend:e.blend,tint:[1,1,1,1]};return e.kind==="region"?{...t,kind:"region",region:e.region??"",corners:[],page:e.page??"",pma:e.pma,uvs:Array.from(e.uvs)}:{...t,kind:"mesh",page:e.page??"",pma:e.pma,vertices:[],uvs:Array.from(e.uvs),triangles:Array.from(e.triangles),sequence:0}}function cT(e,t){if(ArrayBuffer.isView(t)&&t instanceof Float64Array)e.set(t);else for(let n=0;n=Math.max(64,e.attachments.length*2))this.checkedTemplates.clear();this.checkedTemplates.set(d,c)}if(hT(u))this.immutable.add(u),this.templates.set(u,c)}let h=this.rows[l];if(!h)h={template:c,offset:u.offset,count:u.count,tintOffset:u.slotIndex*4},this.rows[l]=h;if(h.template=c,h.offset=u.offset,h.count=u.count,h.tintOffset=u.slotIndex*4,u.dark===null)h.dark=void 0;else{let d=h.darkBuffer??=[];d.length=u.dark.length;for(let f=0;f=1)return 1;return e}var uI={Normal:"normal",Additive:"add",Multiply:"multiply",Screen:"screen"};function hI(e,t,n){let s=an(e[t]),r=an(e[t+1]),i=an(e[t+2]),o=an(e[t+3]),a=an(n[0]),l=an(n[1]),u=an(n[2]);return[s-a,0,0,0,a,0,r-l,0,0,l,0,0,i-u,0,u,0,0,0,o,0]}function dI(e){let t=0,n=e.length/2;for(let s=0;s=Math.min(e,n)-0.000000001&&r<=Math.max(e,n)+0.000000001&&i>=Math.min(t,s)-0.000000001&&i<=Math.max(t,s)+0.000000001}function fI(e,t,n,s,r,i,o,a){let l=ao(r,i,o,a,e,t),u=ao(r,i,o,a,n,s),c=ao(e,t,n,s,r,i),h=ao(e,t,n,s,o,a);if((l>0.000000001&&u<-0.000000001||l<-0.000000001&&u>0.000000001)&&(c>0.000000001&&h<-0.000000001||c<-0.000000001&&h>0.000000001))return!0;if(Math.abs(l)<=0.000000001&&yc(r,i,o,a,e,t))return!0;if(Math.abs(u)<=0.000000001&&yc(r,i,o,a,n,s))return!0;if(Math.abs(c)<=0.000000001&&yc(e,t,n,s,r,i))return!0;if(Math.abs(h)<=0.000000001&&yc(e,t,n,s,o,a))return!0;return!1}function io(e,t,n,s,r,i=!1){let o=i||Array.isArray(e)?Lr(e):-1;if(o!==t)throw Error(`PixiRenderer: slot "${s}" on page "${r}" has invalid ${n} length ${o<0?"non-array":o} (expected ${t})`);let a=lo(e),l=co(e);for(let u=0;u= ${t})`);let a=lo(e),l=co(e);for(let u=0;u= 6)`);let r=e.polygon;for(let l=0;l 0)`);if(e.convex){let l=o>0?1:-1;for(let u=0;u>>0;if(n===0)this.slotCounts.clear();let s=e.length,r=this.preparedPool,i=this.slotCounts;for(let c=0;c0?h.slot:"",f=i.get(d);if(!f)f={generation:n,count:0},i.set(d,f);else if(f.generation!==n)f.generation=n,f.count=0;let m=f.count++,p=m===0?d:`${d}\x00${m}`,y=r[c];if(!y)y={kind:"region",poolKey:p,slot:h,texture:K.EMPTY,blendMode:"normal",color:16777215,alpha:1,darkMatrix:null,clipPlan:null},r[c]=y;this.prepareSlot(h,p,y,t)}let o=!1;for(let c=0;c0?r[0].slot.clip:void 0,l=a!==void 0;if(l){for(let c=1;cs)this.root.removeChildAt(this.root.children.length-1);let u=0;for(let c=0;c0)t.filters=[];if(t.tint!==n.color)t.tint=n.color;if(t.alpha!==n.alpha)t.alpha=n.alpha;if(t.blendMode!==n.blendMode)t.blendMode=n.blendMode}}prepareSlot(e,t,n,s){if(!e||typeof e!=="object")throw Error("PixiRenderer: encountered invalid slot entry in frame.order (expected PosedSlot object)");let r=typeof e.slot==="string"&&e.slot.length>0?e.slot:"",i=typeof e.page==="string"&&e.page.length>0?e.page:"";if(e.kind!=="region"&&e.kind!=="mesh")throw Error(`PixiRenderer: slot "${r}" on page "${i}" has unsupported kind "${String(e.kind)}" (expected "region" or "mesh")`);let o=uI[e.blend];if(o===void 0)throw Error(`PixiRenderer: slot "${r}" on page "${i}" has unsupported blend mode "${String(e.blend)}" (expected Normal, Additive, Multiply, or Screen)`);if(typeof e.pma!=="boolean")throw Error(`PixiRenderer: slot "${r}" on page "${i}" has invalid pma=${String(e.pma)} (expected boolean)`);let a=this.validatedPages.get(e.page);if(!a){let w=this.assets.pageImages.get(e.page);if(!w)throw Error(`PixiRenderer: slot "${r}" references page "${i}", which is missing from assets.pageImages (expected HTMLImageElement for "${i}")`);let T=w.naturalWidth||w.width,A=w.naturalHeight||w.height;if(!Number.isFinite(T)||!Number.isFinite(A)||T<=0||A<=0)throw Error(`PixiRenderer: slot "${r}" page "${i}" has invalid image dimensions ${String(T)}x${String(A)} (expected positive decoded dimensions)`);a={pageImage:w,pw:T,ph:A},this.validatedPages.set(e.page,a)}let{pageImage:l,pw:u,ph:c}=a,h=!s||this.liveFrameChecks;if(h)io(e.tint,4,"tint",r,i,s);let d=lo(e.tint),f=co(e.tint),m=null;if(e.dark!==void 0){if(h)io(e.dark,3,"dark",r,i,s);m=hI(d,f,e.dark)}let p=null;if(e.clip!==void 0){let w=this.validatedClips.get(e.clip);if(!w)w=pI(e.clip,r,i,s),this.validatedClips.set(e.clip,w);p=w}let y=Math.round(an(d[f+0])*255),g=Math.round(an(d[f+1])*255),x=Math.round(an(d[f+2])*255),b=y<<16|g<<8|x,v=an(d[f+3]);if(e.kind==="region"){if(h)io(e.corners,8,"corners",r,i,s);let w=this.regionPool.get(t),T;if(!this.alwaysReuploadGeometry&&w&&w.uvsRef===e.uvs&&w.page===e.page&&w.pma===e.pma&&w.texture!==null&&!w.texture.destroyed)this.sourceFor(l,e.pma),T=w.texture;else io(e.uvs,8,"uvs",r,i,s),T=this.regionTextureFor(l,u,c,e);n.kind="region",n.poolKey=t,n.slot=e,n.texture=T,n.blendMode=o,n.color=b,n.alpha=v,n.darkMatrix=m,n.clipPlan=p;return}if(h)mI(e.vertices,6,"vertices",r,i,s);let _=this.meshPool.get(t),S=!this.alwaysReuploadGeometry&&_!==void 0&&_.positions.length===Lr(e.vertices);if(!S||_.uvsRef!==e.uvs)io(e.uvs,Lr(e.vertices),"uvs",r,i,s);if(!S||_.trianglesRef!==e.triangles){if(!s&&!Array.isArray(e.triangles)||e.triangles.length<3||e.triangles.length%3!==0)throw Error(`PixiRenderer: slot "${r}" on page "${i}" has invalid triangles length ${Array.isArray(e.triangles)?e.triangles.length:"non-array"} (expected multiple of 3 >= 3)`);let w=Lr(e.vertices)/2;for(let T=0;T=w)throw Error(`PixiRenderer: slot "${r}" on page "${i}" has out-of-range triangle index triangles[${T}]=${String(A)} (expected integer in 0..${w-1})`)}}if(!s&&(typeof e.sequence!=="number"||!Number.isInteger(e.sequence)))throw Error(`PixiRenderer: slot "${r}" on page "${i}" has invalid sequence=${String(e.sequence)} (expected integer)`);let k;if(!this.alwaysReuploadGeometry&&_&&_.page===e.page&&_.pma===e.pma&&_.texture!==null&&!_.texture.destroyed)this.sourceFor(l,e.pma),k=_.texture;else k=this.pageTextureFor(l,e.page,e.pma);n.kind="mesh",n.poolKey=t,n.slot=e,n.texture=k,n.blendMode=o,n.color=b,n.alpha=v,n.darkMatrix=m,n.clipPlan=p}sourceFor(e,t){let n=t?"premultiplied-alpha":"premultiply-alpha-on-upload",s=oo.get(e);if(!s||s.source.destroyed){let r=new hn({resource:e,alphaMode:n,scaleMode:"linear",addressMode:"clamp-to-edge",autoGenerateMipmaps:!1});s={source:r,pma:t,holders:new Set},oo.set(e,s),Cm.add(r)}else if(s.pma!==t)s.pma=t,s.source.alphaMode=n,s.source.update();if(!this.retainedPages.has(e))this.retainedPages.add(e),s.holders.add(this);return s.source}pageTextureFor(e,t,n){let s=`${t}\x00${n?"1":"0"}`,r=this.pageTextures.get(s);if(r)return this.sourceFor(e,n),r;let i=this.sourceFor(e,n);return r=new K({source:i}),this.pageTextures.set(s,r),r}regionTextureFor(e,t,n,s){let r=s.uvs[0],i=s.uvs[1],o=s.uvs[2],a=s.uvs[3],l=s.uvs[4],u=s.uvs[5],c=s.uvs[6],h=s.uvs[7],d=`${s.page}\x00${s.pma?"1":"0"}\x00${r},${i},${o},${a},${l},${u},${c},${h}`,f=this.regionTextures.get(d);if(f)return this.sourceFor(e,s.pma),f;let m=this.sourceFor(e,s.pma),p=Math.min(r,o,l,c),y=Math.max(r,o,l,c),g=Math.min(i,a,u,h),x=Math.max(i,a,u,h),b=Math.max(1,(y-p)*t),v=Math.max(1,(x-g)*n),_=new se(p*t,g*n,b,v),S=Math.abs(o-l)this.player.posedFrame();rigDestroyed=!1;constructor(e,t={}){super();if(!e||typeof e!=="object"||!e.document||typeof e.document!=="object"||!(e.pageImages instanceof Map))throw Error("PixiRig: invalid assets argument (expected ModelAssets with document and pageImages Map)");let n=t.timescale??t.timeScale;if(n!==void 0&&(typeof n!=="number"||!Number.isFinite(n)||n<0))throw Error(`PixiRig: invalid timescale=${String(n)} (expected finite number >= 0)`);if(t.renderGroup!==void 0&&typeof t.renderGroup!=="boolean")throw Error(`PixiRig: invalid renderGroup=${String(t.renderGroup)} (expected boolean)`);this.assets=e;let s=document.createElement("div"),r=e.regions==="none"?"canvas":"dom";if(this.player=new Mm(s,e,{mode:r,skin:t.skin,slots:t.slots,liveFrameChecks:t.liveFrameChecks,poser:t.poser}),n!==void 0)this.player.timeScale=n;if(this.renderer=new yI(this,e),this.renderer.liveFrameChecks=t.liveFrameChecks??!1,t.renderGroup===!0)this.renderer.useRenderGroup=!0;this.ticker=t.ticker===void 0?rt.shared:t.ticker,this.autoUpdate=t.autoUpdate??this.ticker!==null;let i=this.player.posedFrame();if(this.lastDrawnFrame=i,this.renderer.render(i),this.autoUpdate&&this.ticker)this.attachTicker()}onTick=(e)=>{if(this.rigDestroyed)return;this.advance(e.deltaMS/1000)};ensureActive(e){if(this.rigDestroyed)throw Error(`PixiRig: cannot call ${e}() on a destroyed PixiRig`)}attachTicker(){if(this.tickerAttached||!this.ticker||this.rigDestroyed)return;this.ticker.add(this.onTick),this.tickerAttached=!0}detachTicker(){if(!this.tickerAttached||!this.ticker)return;this.ticker.remove(this.onTick),this.tickerAttached=!1}play(e,t={}){if(this.ensureActive("play"),typeof e!=="string"||e.length===0)throw Error(`PixiRig: invalid animation name ${String(e)} in play(name) (expected non-empty string)`);if(this.player.play(e,t),this.drawCurrent(),this.autoUpdate&&this.ticker)this.attachTicker()}advance(e){if(this.ensureActive("advance"),typeof e!=="number"||!Number.isFinite(e)||e<0)throw Error(`PixiRig: invalid dt=${String(e)} in advance(dt) (expected finite number >= 0)`);this.player.advance(e),this.drawCurrent()}seek(e){if(this.ensureActive("seek"),typeof e!=="number"||!Number.isFinite(e))throw Error(`PixiRig: invalid time=${String(e)} in seek(time) (expected finite number)`);this.player.seek(e),this.drawCurrent()}draw(){this.ensureActive("draw");let e=this.player.posedFrame();return this.lastDrawnFrame=e,this.renderer.render(e),e}renderFrame(e){if(this.ensureActive("renderFrame"),"order"in e){this.renderer.render(e),this.lastDrawnFrame=e;return}if(e.generation!==this.player.generation)throw Error(`PixiRig: live frame generation ${e.generation} needs current player generation ${this.player.generation}`);if(this.player.poser!=="runtime"){this.renderFrame(this.player.posedFrame());return}this.renderer.render(e),this.retainedRuntimeFrame.capture(e,this.snapshotSeed),this.lastDrawnFrame=null}drawCurrent(){this.renderFrame(this.player.poser==="runtime"?this.player.liveFrame():this.player.posedFrame())}drawnFrame(){return this.ensureActive("drawnFrame"),this.lastDrawnFrame??=this.retainedRuntimeFrame.snapshot()}posedFrame(e){if(this.ensureActive("posedFrame"),e===void 0)return this.player.posedFrame();return this.player.posedFrame(e)}bone(e){if(this.ensureActive("bone"),typeof e!=="string"||e.length===0)throw Error(`PixiRig: invalid bone name ${String(e)} in bone(name) (expected non-empty string)`);return this.player.bone(e)}bounds(){return this.ensureActive("bounds"),this.player.bounds()}get time(){return this.player.time}get current(){return this.player.current}get timescale(){return this.player.timeScale}set timescale(e){if(this.ensureActive("timescale"),typeof e!=="number"||!Number.isFinite(e)||e<0)throw Error(`PixiRig: invalid timescale=${String(e)} (expected finite number >= 0)`);this.player.timeScale=e}get timeScale(){return this.player.timeScale}set timeScale(e){this.timescale=e}get skin(){return this.player.skin}set skin(e){this.ensureActive("skin"),this.player.skin=e,this.drawCurrent()}get slots(){return this.player.slots}set slots(e){this.ensureActive("slots"),this.player.slots=e,this.drawCurrent()}get color(){return this.player.color}set color(e){this.ensureActive("color"),this.player.color=e,this.drawCurrent()}get adjust(){return this.player.adjust}set adjust(e){this.ensureActive("adjust"),this.player.adjust=e,this.drawCurrent()}get composed(){return this.ensureActive("composed"),this.player.composed}repose(){this.ensureActive("repose"),this.player.repose(),this.drawCurrent()}pause(){this.ensureActive("pause"),this.player.pause()}resume(){this.ensureActive("resume"),this.player.resume()}queue(e,t){this.ensureActive("queue"),this.player.queue(e,t)}clear(e,t){this.ensureActive("clear"),this.player.clear(e,t),this.drawCurrent()}queueClear(e,t){this.ensureActive("queueClear"),this.player.queueClear(e,t)}setAlpha(e,t){this.ensureActive("setAlpha"),this.player.setAlpha(e,t),this.drawCurrent()}entry(e){return this.ensureActive("entry"),this.player.entry(e)}environment(e){this.ensureActive("environment");let t=this.player.environment(e);return this.drawCurrent(),t}moved(e){this.ensureActive("moved"),this.player.moved(e)}onRigEvent(e,t){if(this.ensureActive("onRigEvent"),e==="event")return this.player.on("event",t);return this.player.on("complete",t)}resourceCounts(){return this.renderer.resourceCounts()}destroy(e){if(this.rigDestroyed)return;this.rigDestroyed=!0,this.detachTicker(),this.renderer.dispose(),this.player.dispose(),super.destroy(e)}};function bI(e,t){let n=t.getGlobalTransform(new j,!1),s=n.apply({x:e[0],y:-e[1]}),r=n.apply({x:e[2],y:-e[3]}),i=n.apply({x:e[4],y:-e[5]}),o=n.apply({x:e[6],y:-e[7]});return[s.x,s.y,r.x,r.y,i.x,i.y,o.x,o.y]}function vI(e,t,n=!1){let s=t.getGlobalTransform(new j,!1),r=Array(e.length);for(let i=0;i { fs.readFileSync(path.join(ROOT_DIR, HEAD_TURN_PACKAGE_MANIFEST_REL), 'utf-8'), ) as { packages: Array<{ name: string; version: string; integrity: string }> }; const byName = new Map(pkgManifest.packages.map((p) => [p.name, p])); - expect(byName.get('@rig-c/parts')?.version).toBe('1.71.0'); + expect(byName.get('@rig-c/parts')?.version).toBe('1.71.1'); expect(byName.get('@rig-c/pose')?.version).toBe('1.4.0'); - expect(byName.get('@rig-c/play')?.version).toBe('1.20.0'); + expect(byName.get('@rig-c/play')?.version).toBe('1.21.0'); expect(byName.get('@rig-c/pixi')?.version).toBe('0.1.5'); expect(byName.get('rig-c')?.version).toBe('2.79.0'); expect(byName.get('pixi.js')?.version).toBe('8.22.0'); diff --git a/src/head-turn.ts b/src/head-turn.ts index 2bcce7c..cce46e7 100644 --- a/src/head-turn.ts +++ b/src/head-turn.ts @@ -13,8 +13,8 @@ export const HEAD_TURN_PAGE_README_REL = 'demos/head-turn/README.md'; export const HEAD_TURN_APP_REL = 'demos/head-turn/bundle/app.js'; export const HEAD_TURN_README_REL = 'demos/head-turn/bundle/README.md'; -// Approved eleven-file published-stack bundle inventory (@rig-c/parts 1.71.0, @rig-c/pose 1.4.0, @rig-c/play 1.20.0, @rig-c/pixi 0.1.5, rig-c 2.79.0, pixi.js 8.22.0). -export const HEAD_TURN_BUNDLE_SHA256 = '6c9f3e6fba334c10362f51585e6f02a2c642772505b4a4b64c63b337216ec1d8'; +// Approved eleven-file published-stack bundle inventory (@rig-c/parts 1.71.1, @rig-c/pose 1.4.0, @rig-c/play 1.21.0, @rig-c/pixi 0.1.5, rig-c 2.79.0, pixi.js 8.22.0). +export const HEAD_TURN_BUNDLE_SHA256 = '3f5a0b5f4b9dc3e2ea1231a937726afa00963f81e2a5d8d2a6194684d8600087'; // Preserved ten-file GPU displacement prototype inventory at demos/head-turn/prototype/. export const HEAD_TURN_PROTOTYPE_SHA256 = 'fb7bc15b188ed8f29a931067df44a4c3cdb61ba3f114c706722eee73c8a6c2fc';