const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-BytxDfn1.js","assets/webworkerAll-J8ccMaq4.js","assets/colorToUniform-DmtBy-2V.js","assets/WebGPURenderer-CtyVoQqf.js","assets/SharedSystems-DVK37F7d.js","assets/WebGLRenderer-BVO0qznQ.js"])))=>i.map(i=>d[i]); (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();class Wn{constructor(){this.listeners=new Map}on(t,e){this.listeners.has(t)||this.listeners.set(t,new Set);const i=this.listeners.get(t);return i.add(e),()=>{i.delete(e),i.size===0&&this.listeners.delete(t)}}emit(t,e){const i=this.listeners.get(t);if(i)for(const r of i)r(e)}}const _r="timeplot.app-state.v1";function Ns(s){return Object.fromEntries(Object.entries(s).map(([t,e])=>[t,{...e}]))}function Us(s){return Object.fromEntries(Object.entries(s).map(([t,e])=>[t,{...e}]))}function Yn(s){return{type:s.type,preset:s.preset,sampleRateHz:s.sampleRateHz,amplitude:s.amplitude,noise:s.noise,replayRate:s.replayRate,dataFileName:s.dataFileName,wsUrl:s.wsUrl,wsReconnectMs:s.wsReconnectMs}}function Xn(s){return{plot:{showGrid:s.plot.showGrid,showPoints:s.plot.showPoints,windowDurationMs:s.plot.windowDurationMs,maxPoints:s.plot.maxPoints},time:{speed:s.time.speed},panels:Ns(s.panels),graphs:Us(s.graphs),sources:Object.fromEntries(Object.entries(s.sources).map(([t,e])=>[t,Yn(e)]))}}function jn(s,t){return!t||typeof t!="object"?s:{...s,time:t.time?{...s.time,speed:t.time.speed??s.time.speed,paused:!1}:s.time,plot:t.plot?{...s.plot,...t.plot,valueRange:s.plot.valueRange,hoveredPoint:null,tooltip:{...s.plot.tooltip}}:s.plot,panels:t.panels?Ns(Object.fromEntries(Object.entries(s.panels).map(([i,r])=>[i,{...r,...t.panels[i]??{}}]))):s.panels,graphs:t.graphs?Us(Object.fromEntries(Object.entries(s.graphs).map(([i,r])=>[i,{...r,...t.graphs[i]??{}}]))):s.graphs,sources:t.sources?Object.fromEntries(Object.entries(s.sources).map(([i,r])=>{const n=t.sources[i]??{},o=n.type??r.type;return[i,{...r,...n,type:o,dataset:[],datasetPointCount:0,datasetDurationMs:0,loadError:o==="csv-replay"&&n.dataFileName?`Reload ${n.dataFileName} to restore replay data`:"",wsStatus:"idle",wsStatusDetail:""}]})):s.sources}}function qn(){if(typeof localStorage>"u")return null;try{const s=localStorage.getItem(_r);return s?JSON.parse(s):null}catch(s){return console.warn("[timeplot] failed to load persisted state",s),null}}function Zn(s){if(!(typeof localStorage>"u"))try{localStorage.setItem(_r,JSON.stringify(Xn(s)))}catch(t){console.warn("[timeplot] failed to persist state",t)}}function br(){return{app:{title:"TimePlot",renderer:"pending"},time:{realNowMs:Date.now(),realElapsedMs:0,plotTimeMs:0,speed:1,paused:!1},plot:{showGrid:!0,showPoints:!0,windowDurationMs:2e4,maxPoints:1600,valueRange:{min:-1.6,max:1.6},hoveredPoint:null,tooltip:{visible:!1,x:0,y:0,point:null}},sources:{signalA:{id:"signal-a",label:"Signal A",type:"synthetic-wave",preset:"telemetry",sampleRateHz:60,amplitude:1,noise:.08,replayRate:1,dataset:[],dataFileName:"",datasetPointCount:0,datasetDurationMs:0,loadError:"",wsUrl:"ws://localhost:8080",wsReconnectMs:2e3,wsStatus:"idle",wsStatusDetail:""},signalB:{id:"signal-b",label:"Signal B",type:"synthetic-wave",preset:"chirp",sampleRateHz:48,amplitude:.8,noise:.04,replayRate:1,dataset:[],dataFileName:"",datasetPointCount:0,datasetDurationMs:0,loadError:"",wsUrl:"ws://localhost:8080",wsReconnectMs:2e3,wsStatus:"idle",wsStatusDetail:""}},graphs:{primary:{sourceKey:"signalA",transform:"raw",title:"Primary signal"},secondary:{sourceKey:"signalB",transform:"delta",title:"Secondary signal"}},panels:{status:{title:"Status",visible:!0},source:{title:"Data Source",visible:!0},config:{title:"Config",visible:!0},help:{title:"Help",visible:!1}}}}class Kn{constructor(t=br()){this.state=jn(t,qn()),this.listeners=new Set}getState(){return this.state}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}setState(t){const e=typeof t=="function"?t(this.state):t;this.state=e,Zn(this.state);for(const i of this.listeners)i(this.state)}patch(t){this.setState(e=>({...e,...t,time:t.time?{...e.time,...t.time}:e.time,plot:t.plot?{...e.plot,...t.plot,valueRange:t.plot.valueRange?{...e.plot.valueRange,...t.plot.valueRange}:e.plot.valueRange,tooltip:t.plot.tooltip?{...e.plot.tooltip,...t.plot.tooltip}:e.plot.tooltip}:e.plot,sources:t.sources?Object.fromEntries(Object.entries({...e.sources,...t.sources}).map(([i,r])=>[i,{...e.sources[i],...r}])):e.sources,graphs:t.graphs?Us(Object.fromEntries(Object.entries({...e.graphs,...t.graphs}).map(([i,r])=>[i,{...e.graphs[i],...r}]))):e.graphs,panels:t.panels?Ns({...e.panels,...t.panels}):e.panels}))}}class Qn{constructor(t){this.store=t,this.lastFrameTime=performance.now()}tick(t=performance.now()){const e=t-this.lastFrameTime;return this.lastFrameTime=t,this.store.setState(i=>{const r=i.time.realElapsedMs+e,n=i.time.paused?0:e*i.time.speed;return{...i,time:{...i.time,realNowMs:Date.now(),realElapsedMs:r,plotTimeMs:Math.max(0,i.time.plotTimeMs+n)}}}),e}togglePause(){this.store.setState(t=>({...t,time:{...t.time,paused:!t.time.paused}}))}setPaused(t){this.store.setState(e=>({...e,time:{...e.time,paused:t}}))}setSpeed(t){const e=Math.max(.1,Math.min(12,t));this.store.setState(i=>({...i,time:{...i.time,speed:e}}))}reset(){this.store.setState(t=>({...t,time:{...t.time,realElapsedMs:0,plotTimeMs:0},plot:{...t.plot,hoveredPoint:null,tooltip:{...t.plot.tooltip,visible:!1,point:null}}})),this.lastFrameTime=performance.now()}}class ni{constructor(t=1600){this.maxPoints=t,this.points=[]}addPoint(t){this.points.push(t),this.points.length>this.maxPoints&&this.points.splice(0,this.points.length-this.maxPoints)}clear(){this.points=[]}getVisiblePoints(t,e){const i=t-e;return this.points.filter(r=>r.timeMs>=i&&r.timeMs<=t)}}const Jn="modulepreload",to=function(s){return"/"+s},oi={},Ne=function(t,e,i){let r=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));r=Promise.allSettled(e.map(h=>{if(h=to(h),h in oi)return;oi[h]=!0;const l=h.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${c}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":Jn,l||(u.as="script"),u.crossOrigin="",u.href=h,a&&u.setAttribute("nonce",a),document.head.appendChild(u),l)return new Promise((p,d)=>{u.addEventListener("load",p),u.addEventListener("error",()=>d(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&n(a.reason);return t().catch(n)})};var L=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(L||{});const ys=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},ve=(s,t)=>ys(s).priority??t,rt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(ys).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(ys).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,r=this._queue;i[e]?(o=i[e])==null||o.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var o;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((o=n[s])==null||o.forEach(a=>t(a)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,o)=>ve(o.value,e)-ve(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>ve(n,e)-ve(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})},mixin(s,...t){for(const e of t)Object.defineProperties(s.prototype,Object.getOwnPropertyDescriptors(e))}},eo={extension:{type:L.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Ne(()=>import("./browserAll-BytxDfn1.js"),__vite__mapDeps([0,1,2]))}},so={extension:{type:L.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Ne(()=>import("./webworkerAll-J8ccMaq4.js"),__vite__mapDeps([1,2]))}};class q{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new q(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.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(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function wr(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Sr={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function n(h,l,c,u,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new r(c,u||h,p),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],d]:h._events[m].push(d):(h._events[m]=d,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new i:delete h._events[l]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)t.call(c,u)&&l.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},a.prototype.listeners=function(l){var c=e?e+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var p=0,d=u.length,m=new Array(d);pkt[s],uY:s=>Et[s],vX:s=>Rt[s],vY:s=>It[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>_s[s][t],sub:(s,t)=>_s[s][z.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?z.S:z.N:Math.abs(t)*2<=Math.abs(s)?s>0?z.E:z.W:t>0?s>0?z.SE:z.SW:s>0?z.NE:z.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=vr[z.inv(t)];r.tx=e,r.ty=i,s.append(r)},transformRectCoords:(s,t,e,i)=>{const{x:r,y:n,width:o,height:a}=s,{x:h,y:l,width:c,height:u}=t;return e===z.E?(i.set(r+h,n+l,o,a),i):e===z.S?i.set(c-n-a+h,r+l,a,o):e===z.W?i.set(c-r-o+h,u-n-a+l,o,a):e===z.N?i.set(n+h,u-r-o+l,a,o):i.set(r+h,n+l,o,a)}},Me=[new Z,new Z,new Z,new Z];class W{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new W(0,0,0,0)}clone(){return new W(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&e=u&&t<=p&&e>=d&&e<=m&&!(t>g&&tx&&et.right?t.right:this.right)<=R)return!1;const P=this.yt.bottom?t.bottom:this.bottom)>P}const i=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=i||o<=n)return!1;const a=Me[0].set(t.left,t.top),h=Me[1].set(t.left,t.bottom),l=Me[2].set(t.right,t.top),c=Me[3].set(t.right,t.bottom);if(l.x<=a.x||h.y<=a.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(a,a),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(a.x,h.x,l.x,c.x)<=i||Math.min(a.x,h.x,l.x,c.x)>=r||Math.max(a.y,h.y,l.y,c.y)<=n||Math.min(a.y,h.y,l.y,c.y)>=o))return!1;const p=u*(h.y-a.y),d=u*(a.x-h.x),m=p*i+d*n,g=p*r+d*n,f=p*i+d*o,x=p*r+d*o;if(Math.max(m,g,f,x)<=p*a.x+d*a.y||Math.min(m,g,f,x)>=p*c.x+d*c.y)return!1;const y=u*(a.y-l.y),_=u*(l.x-a.x),b=y*i+_*n,v=y*r+_*n,S=y*i+_*o,w=y*r+_*o;return!(Math.max(b,v,S,w)<=y*a.x+_*a.y||Math.min(b,v,S,w)>=y*c.x+_*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=r-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t||(t=new W),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,r=t.x+t.width,n=t.y+t.height;return e>=this.x&&e=this.y&&i=this.x&&r=this.y&&n{if($t.quiet||ai.has(t))return;let i=new Error().stack;const r=`${t} Deprecated since v${s}`,n=typeof console.groupCollapsed=="function"&&!$t.noColor;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",r):(i=i.split(` `).splice(e).join(` `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(i))),ai.add(t)};Object.defineProperties(F,{quiet:{get:()=>$t.quiet,set:s=>{$t.quiet=s},enumerable:!0,configurable:!1},noColor:{get:()=>$t.noColor,set:s=>{$t.noColor=s},enumerable:!0,configurable:!1}});const Pr=()=>{};function Vt(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function hi(s){return!(s&s-1)&&!!s}function Mr(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const li=Object.create(null);function uo(s){const t=li[s];return t===void 0&&(li[s]=V("resource")),t}const Cr=class Tr extends pt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Tr.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){F(O,"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){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.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=uo(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Cr.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ue=Cr;const Ar=class kr extends pt{constructor(t={}){super(),this.options=t,this.uid=V("textureSource"),this._resourceType="textureSource",this._resourceId=V("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...kr.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Ue(Mr(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.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){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=V("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=V("resource"),this.emit("change",this),!0)}updateMipmaps(){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=hi(this.pixelWidth)&&hi(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Ar.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ht=Ar;class $s extends ht{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}$s.extension=L.TextureSource;const ci=new I;class fo{constructor(t,e){this.mapCoord=new I,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let r=0;rthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new W);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=ui,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const o=n.a,a=n.b,h=n.c,l=n.d,c=n.tx,u=n.ty;let p=this.minX,d=this.minY,m=this.maxX,g=this.maxY,f=o*t+h*e+c,x=a*t+l*e+u;fm&&(m=f),x>g&&(g=x),f=o*i+h*e+c,x=a*i+l*e+u,fm&&(m=f),x>g&&(g=x),f=o*t+h*r+c,x=a*t+l*r+u,fm&&(m=f),x>g&&(g=x),f=o*i+h*r+c,x=a*i+l*r+u,fm&&(m=f),x>g&&(g=x),this.minX=p,this.minY=d,this.maxX=m,this.maxY=g}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?p:this.maxX,this.maxY=d>this.maxY?d:this.maxY,p=o*e+h*n+c,d=a*e+l*n+u,this.minX=pthis.maxX?p:this.maxX,this.maxY=d>this.maxY?d:this.maxY,p=o*r+h*n+c,d=a*r+l*n+u,this.minX=pthis.maxX?p:this.maxX,this.maxY=d>this.maxY?d:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minXe&&(this.maxX=e),this.minYr&&(this.maxY=r),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,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 at(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}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(t,e,i,r){let n=this.minX,o=this.minY,a=this.maxX,h=this.maxY;r||(r=this.matrix);const l=r.a,c=r.b,u=r.c,p=r.d,d=r.tx,m=r.ty;for(let g=e;ga?y:a,h=_>h?_:h}this.minX=n,this.minY=o,this.maxX=a,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var mo={grad:.9,turn:360,rad:360/(2*Math.PI)},mt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},X=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},st=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Er=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},di=function(s){return{r:st(s.r,0,255),g:st(s.g,0,255),b:st(s.b,0,255),a:st(s.a)}},Qe=function(s){return{r:X(s.r),g:X(s.g),b:X(s.b),a:X(s.a,3)}},go=/^#([0-9a-f]{3,8})$/i,Ce=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Rr=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),o=n-Math.min(t,e,i),a=o?n===t?(e-i)/o:n===e?2+(i-t)/o:4+(t-e)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:r}},Ir=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),l=n%6;return{r:255*[i,a,o,o,h,i][l],g:255*[h,i,i,a,o,o][l],b:255*[o,o,h,i,i,a][l],a:r}},fi=function(s){return{h:Er(s.h),s:st(s.s,0,100),l:st(s.l,0,100),a:st(s.a)}},pi=function(s){return{h:X(s.h),s:X(s.s),l:X(s.l),a:X(s.a,3)}},mi=function(s){return Ir((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},he=function(s){return{h:(t=Rr(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},xo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_o=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bs={string:[[function(s){var t=go.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?X(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?X(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=_o.exec(s)||bo.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:di({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(s){var t=xo.exec(s)||yo.exec(s);if(!t)return null;var e,i,r=fi({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(mo[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return mi(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return mt(t)&&mt(e)&&mt(i)?di({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!mt(t)||!mt(e)||!mt(i))return null;var o=fi({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return mi(o)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!mt(t)||!mt(e)||!mt(i))return null;var o=function(a){return{h:Er(a.h),s:st(a.s,0,100),v:st(a.v,0,100),a:st(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Ir(o)},"hsv"]]},gi=function(s,t){for(var e=0;e=.5},s.prototype.toHex=function(){return t=Qe(this.rgba),e=t.r,i=t.g,r=t.b,o=(n=t.a)<1?Ce(X(255*n)):"","#"+Ce(e)+Ce(i)+Ce(r)+o;var t,e,i,r,n,o},s.prototype.toRgb=function(){return Qe(this.rgba)},s.prototype.toRgbString=function(){return t=Qe(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return pi(he(this.rgba))},s.prototype.toHslString=function(){return t=pi(he(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Rr(this.rgba),{h:X(t.h),s:X(t.s),v:X(t.v),a:X(t.a,3)};var t},s.prototype.invert=function(){return ct({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),ct(Je(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),ct(Je(this.rgba,-t))},s.prototype.grayscale=function(){return ct(Je(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),ct(xi(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),ct(xi(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?ct({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):X(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=he(this.rgba);return typeof t=="number"?ct({h:t,s:e.s,l:e.l,a:e.a}):X(e.h)},s.prototype.isEqual=function(t){return this.toHex()===ct(t).toHex()},s}(),ct=function(s){return s instanceof ws?s:new ws(s)},yi=[],So=function(s){s.forEach(function(t){yi.indexOf(t)<0&&(t(ws,bs),yi.push(t))})};function vo(s,t){var e={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"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,h,l=i[this.toHex()];if(l)return l;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,p="black";if(!n.length)for(var d in e)n[d]=new s(e[d]).toRgb();for(var m in e){var g=(a=c,h=n[m],Math.pow(a.r-h.r,2)+Math.pow(a.g-h.g,2)+Math.pow(a.b-h.b,2));gn===e[o]);if(t!==null&&e!==null){const n=Object.keys(t),o=Object.keys(e);return n.length!==o.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=re._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const o=t;e=(o>>16&255)/255,i=(o>>8&255)/255,r=(o&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=re.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=ct(t);o.isValid()&&({r:e,g:i,b:r,a:n}=o.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof re||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}};Wt.shared=new Wt;Wt._temp=new Wt;Wt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=Wt;const Po={cullArea:null,cullable:!1,cullableChildren:!0};let es=0;const _i=500;function Q(...s){es!==_i&&(es++,es===_i?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...s))}const _e={_registeredResources:new Set,register(s){this._registeredResources.add(s)},unregister(s){this._registeredResources.delete(s)},release(){this._registeredResources.forEach(s=>s.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(s){return this._registeredResources.has(s)},reset(){this._registeredResources.clear()}};class Mo{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?e=this._pool[--this._index]:e=new this._classType,(i=e.init)==null||i.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}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 t=0;t{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const it=new Co;_e.register(it);const To={get isCachedAsTexture(){var s;return!!((s=this.renderGroup)!=null&&s.isCachedAsTexture)},cacheAsTexture(s){typeof s=="boolean"&&s===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(s===!0?{}:s))},updateCacheTexture(){var s;(s=this.renderGroup)==null||s.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(s){F("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(s)}};function Ao(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r0&&i<=e){for(let a=e-1;a>=s;a--){const h=this.children[a];h&&(r.push(h),h.parent=null)}Ao(this.children,s,e);const o=this.renderGroup||this.parentRenderGroup;o&&o.removeChildren(r);for(let a=0;a0&&this._didViewChangeTick++,r}else if(i===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(s){const t=this.getChildAt(s);return this.removeChild(t)},getChildAt(s){if(s<0||s>=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||F(O,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s},replaceChild(s,t){s.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(s)),t.setFromMatrix(s.localTransform),t.updateLocalTransform(),this.removeChild(s)}},Eo={collectRenderables(s,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(s,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,s):this.collectRenderablesWithEffects(s,t,e))},collectRenderablesSimple(s,t,e){const i=this.children,r=i.length;for(let n=0;n=0;r--){const n=this.effects[r];i[n.pipe].pop(n,this,s)}}};class bi{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;ee.priority-i.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Ss.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Ss.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},setMask(s){this._maskOptions={...this._maskOptions,...s},s.mask&&(this.mask=s.mask),this._markStructureAsChanged()},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new bi);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new bi),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},Bo={label:null,get name(){return F(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){F(O,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i>16&255,i=s>>8&255,r=s&255,n=t>>16&255,o=t>>8&255,a=t&255,h=e*n/255|0,l=i*o/255|0,c=r*a/255|0;return(h<<16)+(l<<8)+c}const wi=16777215;function Si(s,t){return s===wi?t:t===wi?s:Gr(s,t)}function ze(s){return((s&255)<<16)+(s&65280)+(s>>16&255)}const Lo={getGlobalAlpha(s){if(s)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(s=new I,t){if(t)return s.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Os(this,K.get().identity());return s.appendFrom(this.localTransform,e),K.return(e),s},getGlobalTint(s){if(s)return this.renderGroup?ze(this.renderGroup.worldColor):this.parentRenderGroup?ze(Si(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Si(t,e.localColor),e=e.parent;return ze(t)}};function Lr(s,t,e){return t.clear(),e||(e=I.IDENTITY),Dr(s,t,e,s,!0),t.isValid||t.set(0,0,0,0),t}function Dr(s,t,e,i,r){var h,l;let n;if(r)n=K.get(),n=e.copyTo(n);else{if(!s.visible||!s.measurable)return;s.updateLocalTransform();const c=s.localTransform;n=K.get(),n.appendFrom(c,e)}const o=t,a=!!s.effects.length;if(a&&(t=xt.get().clear()),s.boundsArea)t.addRect(s.boundsArea,n);else{s.renderPipeId&&(t.matrix=n,t.addBounds(s.bounds));const c=s.children;for(let u=0;u-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;ethis.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){F("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),rt.mixin(ft,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||F(O,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r1){for(let r=0;r-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=it.get(Wo,this),this.groupTransform=I.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),it.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new I),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*no}set angle(t){this.rotation=t*oo}get pivot(){return this._pivot===Te&&(this._pivot=new q(this,0,0)),this._pivot}set pivot(t){this._pivot===Te&&(this._pivot=new q(this,0,0),this._origin!==Ae&&Q("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ss&&(this._skew=new q(this,0,0)),this._skew}set skew(t){this._skew===ss&&(this._skew=new q(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===is&&(this._scale=new q(this,1,1)),this._scale}set scale(t){this._scale===is&&(this._scale=new q(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Ae&&(this._origin=new q(this,0,0)),this._origin}set origin(t){this._origin===Ae&&(this._origin=new q(this,0,0),this._pivot!==Te&&Q("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,r=this._pivot,n=this._origin,o=this._position,a=i._x,h=i._y,l=r._x,c=r._y,u=-n._x,p=-n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*h,e.d=this._sy*h,e.tx=o._x-(l*e.a+c*e.c)+(u*e.a+p*e.c)-u,e.ty=o._y-(l*e.b+c*e.d)+(u*e.b+p*e.d)-p}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=vi,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Y.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=vi,this._onUpdate())}get tint(){return ze(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Xo,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=rs,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=rs,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=rs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;if(this.destroyed)return;this.destroyed=!0;let e;if(this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&e)for(let n=0;n=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){var e,i;super.destroy(t),this._bounds=null;for(const r in this._gpuData)(i=(e=this._gpuData[r]).destroy)==null||i.call(e);this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:r}=e;r.blendMode.pushBlendMode(this,this.groupBlendMode,t),r[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const o=this.children,a=o.length;for(let h=0;h{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof D?new de(t):new de(D.from(t,e))}set texture(t){t||(t=D.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return po(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return F("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:r,height:n}=e.orig;i.minX=-t._x*r,i.maxX=i.minX+r,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const jo=new at;function Ur(s,t,e){const i=jo;s.measurable=!0,Br(s,e,i),t.addBoundsMask(i),s.measurable=!1}function $r(s,t,e){const i=xt.get();s.measurable=!0;const r=K.get().identity(),n=Or(s,e,r);Lr(s,i,n),s.measurable=!1,t.addBoundsMask(i),K.return(r),xt.return(i)}function Or(s,t,e){return s?(s!==t&&(Or(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(Q("Mask bounds, renderable is not inside the root container"),e)}class Vr{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof de),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){this.inverse||Ur(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof de}}Vr.extension=L.MaskEffect;class Wr{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Wr.extension=L.MaskEffect;class Yr{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){Ur(this.mask,t,e)}addLocalBounds(t,e){$r(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof ft}}Yr.extension=L.MaskEffect;const qo={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let Pi=qo;const et={get(){return Pi},set(s){Pi=s}};class Xr extends ht{constructor(t){t.resource||(t.resource=et.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Xr.extension=L.TextureSource;class $e extends ht{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}$e.extension=L.TextureSource;var vs=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(vs||{});class ns{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const jr=class tt{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 ns(null,null,1/0),this.deltaMS=1/tt.targetFPMS,this.elapsedMS=1/tt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=vs.NORMAL){return this._addListener(new ns(t,e,i))}addOnce(t,e,i=vs.NORMAL){return this._addListener(new ns(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const n=t-this._lastFrame|0;if(n{var o;const t=et.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const h=document.createElement("video");h.onloadeddata=()=>a(h),h.onerror=()=>a(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,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,e);const n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(o=t.getExtension("WEBGL_lose_context"))==null||o.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),os}const We=class qr extends ht{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...qr.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),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=ke.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Zo(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;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("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(ke.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ke.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ke.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};We.extension=L.TextureSource;We.defaultOptions={...ht.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};We.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ko=We;const zt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class Qo{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||Q(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=zt(t);let r;for(let h=0;h{n.set(h,e)});const o=[...n.keys()],a={cacheKeys:o,keys:i};i.forEach(h=>{this._cacheMap.set(h,a)}),o.forEach(h=>{const l=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&Q("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){Q(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const Ht=new Qo,Ps=[];rt.handleByList(L.TextureSource,Ps);function Zr(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r{Ht.has(i)&&Ht.remove(i)}),t||Ht.set(i,n),n}function ta(s,t=!1){return typeof s=="string"?Ht.get(s):s instanceof ht?new D({source:s}):Jo(s,t)}D.from=ta;ht.from=Zr;rt.add(Vr,Wr,Yr,Ko,$e,Xr,$s);var Kr=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(Kr||{});function nt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function Qt(s){return s.split("?")[0].split("#")[0]}function ea(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sa(s,t,e){return s.replace(new RegExp(ea(t),"g"),e)}function ia(s,t){let e="",i=0,r=-1,n=0,o=-1;for(let a=0;a<=s.length;++a){if(a2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=a,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,a)}`:e=s.slice(r+1,a),i=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const fe={toPosix(s){return sa(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){nt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(nt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=Qt(this.toPosix(t??et.get().getBaseUrl())),r=Qt(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?fe.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(nt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=ia(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return nt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(nt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),o=s;s=s.slice(n.length);for(let a=s.length-1;a>=1;--a)if(t=s.charCodeAt(a),t===47){if(!r){i=a;break}}else r=!1;return i===-1?e?"/":this.isUrl(o)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){nt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){nt(s),t&&nt(t),s=Qt(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let o=t.length-1,a=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(h===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){nt(s),s=Qt(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let o=s.length-1;o>=0;--o){const a=s.charCodeAt(o);if(a===47){if(!r){e=o+1;break}continue}i===-1&&(r=!1,i=o+1),a===46?t===-1?t=o:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){nt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=Qt(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,o=0,a=-1,h=!0,l=s.length-1,c=0;for(;l>=r;--l){if(e=s.charCodeAt(l),e===47){if(!h){o=l+1;break}continue}a===-1&&(h=!1,a=l+1),e===46?n===-1?n=l:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&i?t.base=t.name=s.slice(1,a):t.base=t.name=s.slice(o,a)):(o===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,a)):(t.name=s.slice(o,n),t.base=s.slice(o,a)),t.ext=s.slice(n,a)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Qr(s,t,e,i,r){const n=t[e];for(let o=0;o{const o=n.substring(1,n.length-1).split(",");r.push(o)}),Qr(s,r,0,e,i)}else i.push(s);return i}const Mi=s=>!Array.isArray(s);class Jr{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${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(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}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(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return zt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>(o==null?void 0:o.src)??o):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&Q("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let h;if(typeof a=="string"){const l=this._createBundleAssetId(t,a);i.push(l),h=[a,l]}else{const l=a.map(c=>this._createBundleAssetId(t,c));i.push(...l),h=[...a,...l]}this.add({...n,alias:h,src:o})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&Q(`[Resolver] already has key: ${n} overwriting`)},zt(e).forEach(n=>{const{src:o}=n;let{data:a,format:h,loadParser:l,parser:c}=n;const u=zt(o).map(m=>typeof m=="string"?ra(m):Array.isArray(m)?m:[m]),p=this.getAlias(n);Array.isArray(p)?p.forEach(i):i(p);const d=[];u.forEach(m=>{m.forEach(g=>{let f={};if(typeof g!="object"){f.src=g;for(let x=0;x{this._assetMap[m]=d})})}resolveBundle(t){const e=Mi(t);t=zt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const h in o){const l=o[h];a[this._extractAssetIdFromBundle(r,h)]=l}i[r]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=Mi(t);t=zt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o==null||o.priority.forEach(a=>{o.params[a].forEach(h=>{const l=n.filter(c=>c[a]?c[a]===h:!1);l.length&&(n=l)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(i.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:i,data:r,loadParser:n,parser:o,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=fe.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.parser=o??t.parser,t.format=a??t.format??na(t.src),t}}Jr.RETINA_PREFIX=/@([0-9\.]+)x/;function na(s){return s.split(".").pop().split("?").shift().split("#").shift()}const Ci=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},tn=class ne{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof ht&&(i={texture:t,data:e});const{texture:r,data:n,cachePrefix:o=""}=i;this.cachePrefix=o,this._texture=r instanceof D?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ne.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=ne.BATCH_SIZE;for(;e-t{this._batchIndex*ne.BATCH_SIZE{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[`${t.cachePrefix}${r}`]=t.textures[r]}),!e){const r=fe.dirname(s[0]);t.linkedSheets.forEach((n,o)=>{const a=en([`${r}/${t.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(i,a)})}return i}const aa={extension:L.Asset,cache:{test:s=>s instanceof Ti,getCacheableAssets:(s,t)=>en(s,t,!1)},resolver:{extension:{type:L.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&oa.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=Jr.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:L.LoadParser,priority:Kr.Normal,name:"spritesheetLoader"},async testParse(s,t){return fe.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var u,p;const{texture:i,imageFilename:r,textureOptions:n,cachePrefix:o}=(t==null?void 0:t.data)??{};let a=fe.dirname(t.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let h;if(i instanceof D)h=i;else{const d=Ci(a+(r??s.meta.image),t.src);h=(await e.load([{src:d,data:n}]))[d]}const l=new Ti({texture:h.source,data:s,cachePrefix:o});await l.parse();const c=(u=s==null?void 0:s.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(c)){const d=[];for(const g of c){if(typeof g!="string")continue;let f=a+g;(p=t.data)!=null&&p.ignoreMultiPack||(f=Ci(f,t.src),d.push(e.load({src:f,data:{textureOptions:n,ignoreMultiPack:!0}})))}const m=await Promise.all(d);l.linkedSheets=m,m.forEach(g=>{g.linkedSheets=[l].concat(l.linkedSheets.filter(f=>f!==g))})}return l},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};rt.add(aa);const as=Object.create(null),Ai=Object.create(null);function Ws(s,t){let e=Ai[s];return e===void 0&&(as[t]===void 0&&(as[t]=1),Ai[s]=e=as[t]++),e}let Gt;function sn(){return(!Gt||Gt!=null&&Gt.isContextLost())&&(Gt=et.get().createCanvas().getContext("webgl",{})),Gt}let Ee;function ha(){if(!Ee){Ee="mediump";const s=sn();s&&s.getShaderPrecisionFormat&&(Ee=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Ee}function la(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying #define finalColor gl_FragColor #define texture texture2D #endif ${s} `):` #ifdef GL_ES // This checks if it is WebGL1 #define in attribute #define out varying #endif ${s} `}function ca(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float; ${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function ua(s,t){return t?`#version 300 es ${s}`:s}const da={},fa={};function pa(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?da:fa;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`} ${s}`}function ma(s,t){return t?s.replace("#version 300 es",""):s}const hs={stripVersion:ma,ensurePrecision:ca,addProgramDefines:la,setProgramName:pa,insertVersion:ua},Jt=Object.create(null),rn=class Ms{constructor(t){t={...Ms.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:ha()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(hs).forEach(o=>{const a=i[o];r=hs[o](r,a,!0),n=hs[o](n,a,!1)}),this.fragment=r,this.vertex=n,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Ws(`${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,Jt[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Jt[e]||(Jt[e]=new Ms(t),Jt[e]._cacheKey=e),Jt[e]}};rn.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let nn=rn;const ki={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 ga(s){return ki[s]??ki.float32}const xa={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function ya({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),o=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let a;for(;(a=o.exec(n))!==null;){const h=xa[a[3]]??"float32";e[a[2]]={location:parseInt(a[1],10),format:h,stride:ga(h).stride,offset:0,instance:!1,start:0}}}}return e}function ls(s){var u,p;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(u=s.match(t))==null?void 0:u.map(d=>({group:parseInt(d.match(e)[1],10),binding:parseInt(d.match(i)[1],10),name:d.match(r)[2],isUniform:d.match(r)[1]==="",type:d.match(n)[1]}));if(!l)return{groups:[],structs:[]};const c=((p=s.match(o))==null?void 0:p.map(d=>{const m=d.match(h)[1],g=d.match(a).reduce((f,x)=>{const[y,_]=x.split(":");return f[y.trim()]=_.trim(),f},{});return g?{name:m,members:g}:null}).filter(({name:d})=>l.some(m=>m.type===d)))??[];return{groups:l,structs:c}}var oe=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(oe||{});function _a({groups:s}){const t=[];for(let e=0;ee.has(o.name)?!1:(e.add(o.name),!0)),n=[...s.groups,...t.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return i.has(a)?!1:(i.add(a),!0)});return{structs:r,groups:n}}const te=Object.create(null);class Ye{constructor(t){var a,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:o}=t;if(this.name=o,this.fragment=e,this.vertex=i,e.source===i.source){const l=ls(e.source);this.structsAndGroups=l}else{const l=ls(i.source),c=ls(e.source);this.structsAndGroups=wa(l,c)}this.layout=r??ba(this.structsAndGroups),this.gpuLayout=n??_a(this.structsAndGroups),this.autoAssignGlobalUniforms=((a=this.layout[0])==null?void 0:a.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ws(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=ya(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,te[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return te[e]||(te[e]=new Ye(t),te[e]._cacheKey=e),te[e]}}const on=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4"],Sa=on.reduce((s,t)=>(s[t]=!0,s),{});function va(s,t){switch(s){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}const an=class hn{constructor(t,e){this._touched=0,this.uid=V("uniform"),this._resourceType="uniformGroup",this._resourceId=V("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...hn.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Sa[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,h]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${h} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${on.join(", ")}`)}n.value??(n.value=va(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ws(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};an.defaultOptions={ubo:!1,isStatic:!1};let ln=an;class He{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r==null?void 0:r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Cs=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Cs||{});class Ys extends pt{constructor(t){super(),this.uid=V("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=e,this.glProgram=i,o===void 0&&(o=0,e&&(o|=Cs.WEBGPU),i&&(o|=Cs.WEBGL)),this.compatibleRenderers=o;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&a)for(const l in a)for(const c in a[l]){const u=a[l][c];h[u]={group:l,binding:c,name:u}}else if(e&&r&&!a){const l=e.structsAndGroups.groups;a={},l.forEach(c=>{a[c.group]=a[c.group]||{},a[c.group][c.binding]=c.name,h[c.name]=c})}else if(n){r={},a={},e&&e.structsAndGroups.groups.forEach(u=>{a[u.group]=a[u.group]||{},a[u.group][u.binding]=u.name,h[u.name]=u});let l=0;for(const c in n)h[c]||(r[99]||(r[99]=new He,this._ownedBindGroups.push(r[99])),h[c]={group:99,binding:l,name:c},a[99]=a[99]||{},a[99][l]=c,l++);for(const c in n){const u=c;let p=n[c];!p.source&&!p._resourceType&&(p=new ln(p));const d=h[u];d&&(r[d.group]||(r[d.group]=new He,this._ownedBindGroups.push(r[d.group])),r[d.group].setResource(p,d.binding))}}this.groups=r,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new He,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(o){t[n.group].setResource(o,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,o;return e&&(n=Ye.from(e)),i&&(o=nn.from(i)),new Ys({gpuProgram:n,glProgram:o,...r})}}const Ts=[];rt.handleByNamedList(L.Environment,Ts);async function Pa(s){if(!s)for(let t=0;t80*e){a=s[0],h=s[1];let c=a,u=h;for(let p=e;pc&&(c=d),m>u&&(u=m)}l=Math.max(c-a,u-h),l=l!==0?32767/l:0}return pe(n,o,e,a,h,l,0),o}function cn(s,t,e,i,r){let n;if(r===Ua(s,t,e,i)>0)for(let o=t;o=t;o-=i)n=Ri(o/i|0,s[o],s[o+1],n);return n&&Yt(n,n.next)&&(ge(n),n=n.next),n}function Ft(s,t){if(!s)return s;t||(t=s);let e=s,i;do if(i=!1,!e.steiner&&(Yt(e,e.next)||U(e.prev,e,e.next)===0)){if(ge(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function pe(s,t,e,i,r,n,o){if(!s)return;!o&&n&&Ga(s,i,r,n);let a=s;for(;s.prev!==s.next;){const h=s.prev,l=s.next;if(n?Ta(s,i,r,n):Ca(s)){t.push(h.i,s.i,l.i),ge(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=Aa(Ft(s),t),pe(s,t,e,i,r,n,2)):o===2&&ka(s,t,e,i,r,n):pe(Ft(s),t,e,i,r,n,1);break}}}function Ca(s){const t=s.prev,e=s,i=s.next;if(U(t,e,i)>=0)return!1;const r=t.x,n=e.x,o=i.x,a=t.y,h=e.y,l=i.y,c=Math.min(r,n,o),u=Math.min(a,h,l),p=Math.max(r,n,o),d=Math.max(a,h,l);let m=i.next;for(;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=u&&m.y<=d&&ae(r,a,n,h,o,l,m.x,m.y)&&U(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Ta(s,t,e,i){const r=s.prev,n=s,o=s.next;if(U(r,n,o)>=0)return!1;const a=r.x,h=n.x,l=o.x,c=r.y,u=n.y,p=o.y,d=Math.min(a,h,l),m=Math.min(c,u,p),g=Math.max(a,h,l),f=Math.max(c,u,p),x=As(d,m,t,e,i),y=As(g,f,t,e,i);let _=s.prevZ,b=s.nextZ;for(;_&&_.z>=x&&b&&b.z<=y;){if(_.x>=d&&_.x<=g&&_.y>=m&&_.y<=f&&_!==r&&_!==o&&ae(a,c,h,u,l,p,_.x,_.y)&&U(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=d&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&ae(a,c,h,u,l,p,b.x,b.y)&&U(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=x;){if(_.x>=d&&_.x<=g&&_.y>=m&&_.y<=f&&_!==r&&_!==o&&ae(a,c,h,u,l,p,_.x,_.y)&&U(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=d&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&ae(a,c,h,u,l,p,b.x,b.y)&&U(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Aa(s,t){let e=s;do{const i=e.prev,r=e.next.next;!Yt(i,r)&&dn(i,e,e.next,r)&&me(i,r)&&me(r,i)&&(t.push(i.i,e.i,r.i),ge(e),ge(e.next),e=s=r),e=e.next}while(e!==s);return Ft(e)}function ka(s,t,e,i,r,n){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&za(o,a)){let h=fn(o,a);o=Ft(o,o.next),h=Ft(h,h.next),pe(o,t,e,i,r,n,0),pe(h,t,e,i,r,n,0);return}a=a.next}o=o.next}while(o!==s)}function Ea(s,t,e,i){const r=[];for(let n=0,o=t.length;n=e.next.y&&e.next.y!==e.y){const u=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(u<=i&&u>n&&(n=u,o=e.x=e.x&&e.x>=h&&i!==e.x&&un(ro.x||e.x===o.x&&Fa(o,e)))&&(o=e,c=u)}e=e.next}while(e!==a);return o}function Fa(s,t){return U(s.prev,s,t.prev)<0&&U(t.next,s,s.next)<0}function Ga(s,t,e,i){let r=s;do r.z===0&&(r.z=As(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,La(r)}function La(s){let t,e=1;do{let i=s,r;s=null;let n=null;for(t=0;i;){t++;let o=i,a=0;for(let l=0;l0||h>0&&o;)a!==0&&(h===0||!o||i.z<=o.z)?(r=i,i=i.nextZ,a--):(r=o,o=o.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;i=o}n.nextZ=null,e*=2}while(t>1);return s}function As(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function Da(s){let t=s,e=s;do(t.x=(s-o)*(n-a)&&(s-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(r-o)*(i-a)}function ae(s,t,e,i,r,n,o,a){return!(s===o&&t===a)&&un(s,t,e,i,r,n,o,a)}function za(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!Ha(s,t)&&(me(s,t)&&me(t,s)&&Na(s,t)&&(U(s.prev,s,t.prev)||U(s,t.prev,t))||Yt(s,t)&&U(s.prev,s,s.next)>0&&U(t.prev,t,t.next)>0)}function U(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Yt(s,t){return s.x===t.x&&s.y===t.y}function dn(s,t,e,i){const r=Ie(U(s,t,e)),n=Ie(U(s,t,i)),o=Ie(U(e,i,s)),a=Ie(U(e,i,t));return!!(r!==n&&o!==a||r===0&&Re(s,e,t)||n===0&&Re(s,i,t)||o===0&&Re(e,s,i)||a===0&&Re(e,t,i))}function Re(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Ie(s){return s>0?1:s<0?-1:0}function Ha(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&dn(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function me(s,t){return U(s.prev,s,s.next)<0?U(s,t,s.next)>=0&&U(s,s.prev,t)>=0:U(s,t,s.prev)<0||U(s,s.next,t)<0}function Na(s,t){let e=s,i=!1;const r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function fn(s,t){const e=ks(s.i,s.x,s.y),i=ks(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Ri(s,t,e,i){const r=ks(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ge(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function ks(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ua(s,t,e,i){let r=0;for(let n=t,o=e-i;n(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(pn||{});class Oa{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,o,a,h){const{name:l,items:c}=this;for(let u=0,p=c.length;u{this.runners[e]=new Oa(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,o=r.name,a=i[o];this.renderPipes[o]=new n(this,a?new a:null),this.runners.destroy.add(this.renderPipes[o])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&_e.release(),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ma())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};mn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let xn=mn,Be;function Wa(s){return Be!==void 0||(Be=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??xn.defaultOptions.failIfMajorPerformanceCaveat};try{if(!et.get().getWebGLRenderingContext())return!1;let r=et.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const o=r.getExtension("WEBGL_lose_context");o&&o.loseContext()}return r=null,n}catch{return!1}})()),Be}let Fe;async function Ya(s={}){return Fe!==void 0||(Fe=await(async()=>{const t=et.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Fe}const Ii=["webgl","webgpu","canvas"];async function Xa(s){let t=[];s.preference?(t.push(s.preference),Ii.forEach(n=>{n!==s.preference&&t.push(n)})):t=Ii.slice();let e,i={};for(let n=0;n{const{WebGPURenderer:h}=await import("./WebGPURenderer-CtyVoQqf.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=a,i={...s,...s.webgpu};break}else if(o==="webgl"&&Wa(s.failIfMajorPerformanceCaveat??xn.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:a}=await Ne(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-BVO0qznQ.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=a,i={...s,...s.webgl};break}else if(o==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const yn="8.13.2";class _n{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,yn)}static destroy(){}}_n.extension=L.Application;class ja{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,yn)}destroy(){this._renderer=null}}ja.extension={type:[L.WebGLSystem,L.WebGPUSystem],name:"initHook",priority:-10};const bn=class Es{constructor(...t){this.stage=new ft,t[0]!==void 0&&F(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await Xa(t),Es._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return F(O,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const i=Es._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};bn._plugins=[];let wn=bn;rt.handleByList(L.Application,wn._plugins);rt.add(_n);/** * tiny-lru * * @copyright 2025 Jason Mulligan * @license BSD-3-Clause * @version 11.4.5 */class qa{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(e=>[e,this.get(e)])}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=[];let e=this.first;for(;e!==null;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let r=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(t,e,i=!1,r=this.resetTtl){let n=this.items[t];return i||n!==void 0?(n.value=e,i===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){return t.map(e=>this.get(e))}}function Za(s=1e3,t=0,e=!1){if(isNaN(s)||s<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new qa(s,t,e)}const Ka=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Sn(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Ka.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const cs={willReadFrequently:!0},lt=class T{static get experimentalLetterSpacingSupported(){let t=T._experimentalLetterSpacingSupported;if(t===void 0){const e=et.get().getCanvasRenderingContext2D().prototype;t=T._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,o,a,h,l){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,i=T._canvas,r=e.wordWrap){var y;const n=`${t}-${e.styleKey}-wordWrap-${r}`;if(T._measurementCache.has(n))return T._measurementCache.get(n);const o=Sn(e),a=T.measureFont(o);a.fontSize===0&&(a.fontSize=e.fontSize,a.ascent=e.fontSize);const h=T.__context;h.font=o;const c=(r?T._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(c.length);let p=0;for(let _=0;_0)if(r)o-=e,l-=e;else{const c=(T.graphemeSegmenter(t).length-1)*e;o+=c,l+=c}return Math.max(o,l)}static _wordWrap(t,e,i=T._canvas){const r=i.getContext("2d",cs);let n=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,u=T._collapseSpaces(c),p=T._collapseNewlines(c);let d=!u;const m=e.wordWrapWidth+l,g=T._tokenize(t);for(let f=0;fm)if(o!==""&&(a+=T._addLine(o),o="",n=0),T.canBreakWords(x,e.breakWords)){const _=T.wordWrapSplit(x);for(let b=0;b<_.length;b++){let v=_[b],S=v,w=1;for(;_[b+w];){const k=_[b+w];if(!T.canBreakChars(S,k,x,b,e.breakWords))v+=k;else break;S=k,w++}b+=w-1;const R=T._getFromCache(v,l,h,r);R+n>m&&(a+=T._addLine(o),d=!1,o="",n=0),o+=v,n+=R}}else{o.length>0&&(a+=T._addLine(o),o="",n=0);const _=f===g.length-1;a+=T._addLine(x,!_),d=!1,o="",n=0}else y+n>m&&(d=!1,a+=T._addLine(o),o="",n=0),(o.length>0||!T.isBreakingSpace(x)||d)&&(o+=x,n+=y)}return a+=T._addLine(o,!1),a}static _addLine(t,e=!0){return t=T._trimRight(t),t=e?`${t} `:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=T._measureText(t,e,r)+e,i[t]=n),n}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const i=t[e];if(!T.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:T._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:T._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>{const e=s.segment(t),i=[];let r=0;for(const n of e)i[r++]=n.segment;return i}}return s=>[...s]})();lt.experimentalLetterSpacing=!1;lt._fonts={};lt._newlines=[10,13];lt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];lt._measurementCache=Za(1e3);let Nt=lt;const Bi=[{offset:0,color:"white"},{offset:1,color:"black"}],Xs=class Rs{constructor(...t){this.uid=V("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Qa(t);e={...e.type==="radial"?Rs.defaultRadialOptions:Rs.defaultLinearOptions,...Mr(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Y.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:r}=this.end,n=i-t,o=r-e;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const f=t;t=i,i=f,n*=-1}if(o<0){const f=e;e=r,r=f,o*=-1}}const h=this.colorStops.length?this.colorStops:Bi,l=this._textureSize,{canvas:c,context:u}=Gi(l,1),p=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);Fi(p,h),u.fillStyle=p,u.fillRect(0,0,l,1),this.texture=new D({source:new $e({resource:c,addressMode:this._wrapMode})});const d=Math.sqrt(n*n+o*o),m=Math.atan2(o,n),g=new I;g.scale(d/l,1),g.rotate(m),g.translate(t,e),this.textureSpace==="local"&&g.scale(l,l),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Bi,e=this._textureSize,{canvas:i,context:r}=Gi(e,e),{x:n,y:o}=this.center,{x:a,y:h}=this.outerCenter,l=this.innerRadius,c=this.outerRadius,u=a-c,p=h-c,d=e/(c*2),m=(n-u)*d,g=(o-p)*d,f=r.createRadialGradient(m,g,l*d,(a-u)*d,(h-p)*d,c*d);Fi(f,t),r.fillStyle=t[t.length-1].color,r.fillRect(0,0,e,e),r.fillStyle=f,r.translate(m,g),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-m,-g),r.fillRect(0,0,e,e),this.texture=new D({source:new $e({resource:i,addressMode:this._wrapMode})});const x=new I;x.scale(1/d,1/d),x.translate(u,p),this.textureSpace==="local"&&x.scale(e,e),this.transform=x}destroy(){var t;(t=this.texture)==null||t.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}`}};Xs.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Xs.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let _t=Xs;function Fi(s,t){for(let e=0;e2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==us[n])return r.unshift(i),t.push(r);if(r.length0&&(r=i.pop(),r?(n=r.startX,o=r.startY):(n=0,o=0)),r=null;break;default:Q(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&r===null&&(r={startX:n,startY:o},i.push(r))}return t}class js{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new js(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i,r=.5){if(this.radius===0)return!1;const n=this.x-t,o=this.y-e,a=this.radius,h=(1-r)*i,l=Math.sqrt(n*n+o*o);return l<=a+h&&l>a-(i-h)}getBounds(t){return t||(t=new W),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class qs{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new qs(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i,r=.5){const{halfWidth:n,halfHeight:o}=this;if(n<=0||o<=0)return!1;const a=i*(1-r),h=i-a,l=n-h,c=o-h,u=n+a,p=o+a,d=t-this.x,m=e-this.y,g=d*d/(l*l)+m*m/(c*c),f=d*d/(u*u)+m*m/(p*p);return g>1&&f<=1}getBounds(t){return t||(t=new W),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function oh(s,t,e,i,r,n){const o=s-e,a=t-i,h=r-e,l=n-i,c=o*h+a*l,u=h*h+l*l;let p=-1;u!==0&&(p=c/u);let d,m;p<0?(d=e,m=i):p>1?(d=r,m=n):(d=e+p*h,m=i+p*l);const g=s-d,f=t-m;return g*g+f*f}let ah,hh;class le{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;re!=c>e&&t<(l-a)*((e-h)/(c-h))+a&&(i=!i)}return i}strokeContains(t,e,i,r=.5){const n=i*i,o=n*(1-r),a=n-o,{points:h}=this,l=h.length-(this.closePath?0:2);for(let c=0;cr?l:r,n=co?c:o}return t.x=i,t.width=r-i,t.y=n,t.height=o-n,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return F("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return F("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Ge=(s,t,e,i,r,n,o)=>{const a=s-e,h=t-i,l=Math.sqrt(a*a+h*h);return l>=r-n&&l<=r+o};class Zs{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t||(t=new W),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Zs(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(r*r+n*n<=o||(r=t-(this.x+this.width-i),r*r+n*n<=o)||(n=e-(this.y+this.height-i),r*r+n*n<=o)||(r=t-(this.x+i),r*r+n*n<=o))return!0}return!1}strokeContains(t,e,i,r=.5){const{x:n,y:o,width:a,height:h,radius:l}=this,c=i*(1-r),u=i-c,p=n+l,d=o+l,m=a-l*2,g=h-l*2,f=n+a,x=o+h;return(t>=n-c&&t<=n+u||t>=f-u&&t<=f+c)&&e>=d&&e<=d+g||(e>=o-c&&e<=o+u||e>=x-u&&e<=x+c)&&t>=p&&t<=p+m?!0:tf-l&&ef-l&&e>x-l&&Ge(t,e,f-l,x-l,l,u,c)||tx-l&&Ge(t,e,p,x-l,l,u,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const vn={};function lh(s,t,e){let i=2166136261;for(let r=0;r>>=0;return vn[i]||ch(s,t,i,e)}function ch(s,t,e,i){const r={};let n=0;for(let a=0;a0){const o=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(o)}}const uh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var dh=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",s[s.NONE=5]="NONE",s))(dh||{});function Hi(s,t){return t.alphaMode==="no-premultiply-alpha"&&uh[s]||s}const fh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function ph(s){let t="";for(let e=0;e0&&(t+=` else `),e{if(ce.length>0)for(const s of ce)s&&s.destroy();ce.length=0,Oe=0}});function Ni(){return Oe>0?ce[--Oe]:new yh}function Ui(s){ce[Oe++]=s}let se=0;const Pn=class Mn{constructor(t){this.uid=V("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...Mn.defaultOptions,...t},t.maxTextures||(F("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=gh());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new Di(i*4),this.indexBuffer=new Uint16Array(r),this.maxTextures=e}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),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,l=this.attributeBuffer.uint32View,c=this.indexBuffer;let u=this._batchIndexSize,p=this._batchIndexStart,d="startBatch";const m=this.maxTextures;for(let g=this.elementStart;g=m||b)&&(this._finishBatch(i,p,u-p,r,o,a,t,d),d="renderBatch",p=u,o=_,a=f.topology,i=Ni(),r=i.textures,r.clear(),++se),f._textureId=y._textureBindLocation=r.count,r.ids[y.uid]=r.count,r.textures[r.count++]=y,f._batch=i,u+=f.indexSize,f.packAsQuad?(this.packQuadAttributes(f,h,l,f._attributeStart,f._textureId),this.packQuadIndex(c,f._indexStart,f._attributeStart/this.vertexSize)):(this.packAttributes(f,h,l,f._attributeStart,f._textureId),this.packIndex(f,c,f._indexStart,f._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,p,u-p,r,o,a,t,d),p=u,++se),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=u}_finishBatch(t,e,i,r,n,o,a,h){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=r,t.blendMode=n,t.topology=o,t.start=e,t.size=i,++se,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new Di(e);zi(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(J||{});class xe extends pt{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:o}=t;super(),this.uid=V("buffer"),this._resourceType="buffer",this._resourceId=V("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i??(i=e==null?void 0:e.byteLength);const a=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&J.STATIC)}set static(t){t?this.descriptor.usage|=J.STATIC:this.descriptor.usage&=~J.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,this._dataInt32=null,!r||r.length!==t.length){!this.shrinkToFit&&r&&t.byteLengtha&&(a=d),m>h&&(h=m),de.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const vh=new Float32Array(1),Ph=new Uint32Array(1);class Mh extends Sh{constructor(){const e=new xe({data:vh,label:"attribute-batch-buffer",usage:J.VERTEX|J.COPY_DST,shrinkToFit:!1}),i=new xe({data:Ph,label:"index-batch-buffer",usage:J.INDEX|J.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4}},indexBuffer:i})}}function $i(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let o=s[i];i==="header"&&(o=o.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(o)}else Q(`${i} placement hook does not exist in shader`)}}const Ch=/\{\{(.*?)\}\}/g;function Oi(s){var i;const t={};return(((i=s.match(Ch))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function Vi(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Wi(s,t,e=!1){const i=[];Vi(t,i),s.forEach(a=>{a.header&&Vi(a.header,i)});const r=i;e&&r.sort();const n=r.map((a,h)=>` @location(${h}) ${a},`).join(` `);let o=t.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",` ${n} `),o}function Yi(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Th(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Ah(s){const t=/@.*?\s+/g;return s.replace(t,"")}function kh(s,t){const e=[];Yi(t,e),s.forEach(h=>{h.header&&Yi(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`, `),n=e.sort().map(h=>` var ${Ah(h)};`).join(` `),o=`return VSOutput( ${e.sort().map(h=>` ${Th(h)}`).join(`, `)});`;let a=t.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",` ${r} `),a=a.replace("{{start}}",` ${n} `),a=a.replace("{{return}}",` ${o} `),a}function Xi(s,t){let e=s;for(const i in t){const r=t[i];r.join(` `).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----// ${r.join(` `)} //----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const St=Object.create(null),ds=new Map;let Eh=0;function Rh({template:s,bits:t}){const e=Tn(s,t);if(St[e])return St[e];const{vertex:i,fragment:r}=Bh(s,t);return St[e]=An(i,r,t),St[e]}function Ih({template:s,bits:t}){const e=Tn(s,t);return St[e]||(St[e]=An(s.vertex,s.fragment,t)),St[e]}function Bh(s,t){const e=t.map(o=>o.vertex).filter(o=>!!o),i=t.map(o=>o.fragment).filter(o=>!!o);let r=Wi(e,s.vertex,!0);r=kh(e,r);const n=Wi(i,s.fragment,!0);return{vertex:r,fragment:n}}function Tn(s,t){return t.map(e=>(ds.has(e)||ds.set(e,Eh++),ds.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function An(s,t,e){const i=Oi(s),r=Oi(t);return e.forEach(n=>{$i(n.vertex,i,n.name),$i(n.fragment,r,n.name)}),{vertex:Xi(s,i),fragment:Xi(t,r)}}const Fh=` @in aPosition: vec2; @in aUV: vec2; @out @builtin(position) vPosition: vec4; @out vUV : vec2; @out vColor : vec4; {{header}} struct VSOutput { {{struct}} }; @vertex fn main( {{in}} ) -> VSOutput { var worldTransformMatrix = globalUniforms.uWorldTransformMatrix; var modelMatrix = mat3x3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); var position = aPosition; var uv = aUV; {{start}} vColor = vec4(1., 1., 1., 1.); {{main}} vUV = uv; var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix; vPosition = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= globalUniforms.uWorldColorAlpha; {{end}} {{return}} }; `,Gh=` @in vUV : vec2; @in vColor : vec4; {{header}} @fragment fn main( {{in}} ) -> @location(0) vec4 { {{start}} var outColor:vec4; {{main}} var finalColor:vec4 = outColor * vColor; {{end}} return finalColor; }; `,Lh=` in vec2 aPosition; in vec2 aUV; out vec4 vColor; out vec2 vUV; {{header}} void main(void){ mat3 worldTransformMatrix = uWorldTransformMatrix; mat3 modelMatrix = mat3( 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ); vec2 position = aPosition; vec2 uv = aUV; {{start}} vColor = vec4(1.); {{main}} vUV = uv; mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix; gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); vColor *= uWorldColorAlpha; {{end}} } `,Dh=` in vec4 vColor; in vec2 vUV; out vec4 finalColor; {{header}} void main(void) { {{start}} vec4 outColor; {{main}} finalColor = outColor * vColor; {{end}} } `,zh={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, uWorldColorAlpha: vec4, uResolution: vec2, } @group(0) @binding(0) var globalUniforms : GlobalUniforms; `}},Hh={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; `}};function Nh({bits:s,name:t}){const e=Rh({template:{fragment:Gh,vertex:Fh},bits:[zh,...s]});return Ye.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Uh({bits:s,name:t}){return new nn({name:t,...Ih({template:{vertex:Lh,fragment:Dh},bits:[Hh,...s]})})}const $h={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},Oh={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); `}},fs={};function Vh(s){const t=[];if(s===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` `)}function Wh(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` vTextureId = aTextureIdAndRound.y; `,end:` if(aTextureIdAndRound.x == 1) { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; ${Vh(s)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); ${Wh(s)} `}}),fs[s]}const ps={};function Xh(s){const t=[];for(let e=0;e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } `}},Zh={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; } `}},ji={};function Kh(s){let t=ji[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i>16|t&65280|(t&255)<<16,i=this.renderable;return i?Gr(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||sl}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const ye={extension:{type:L.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,o,a;if(s.type==="circle"){const b=s;if(o=a=b.radius,o<=0)return!1;e=b.x,i=b.y,r=n=0}else if(s.type==="ellipse"){const b=s;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;e=b.x,i=b.y,r=n=0}else{const b=s,v=b.width/2,S=b.height/2;e=b.x+v,i=b.y+S,o=a=Math.max(0,Math.min(b.radius,Math.min(v,S))),r=v-o,n=S-a}if(r<0||n<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=h*8+(r?4:0)+(n?4:0);if(l===0)return!1;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,!0;let c=0,u=h*4+(r?2:0)+2,p=u,d=l,m=r+o,g=n,f=e+m,x=e-m,y=i+g;if(t[c++]=f,t[c++]=y,t[--u]=y,t[--u]=x,n){const b=i-g;t[p++]=x,t[p++]=b,t[--d]=b,t[--d]=f}for(let b=1;b0&&(r[n++]=h,r[n++]=l,r[n++]=h-1),h++;r[n++]=l+1,r[n++]=l,r[n++]=h-1}},il={...ye,extension:{...ye.extension,name:"ellipse"}},rl={...ye,extension:{...ye.extension,name:"roundedRectangle"}},Bn=1e-4,qi=1e-4;function nl(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];iu&&(u+=Math.PI*2);let p=c;const d=u-c,m=Math.abs(d),g=Math.sqrt(h*h+l*l),f=(15*m*Math.sqrt(g)/Math.PI>>0)+1,x=d/f;if(p+=x,a){o.push(s,t),o.push(e,i);for(let y=1,_=p;y=0&&(a.join==="round"?g+=Tt(S,w,S-P*C,w-M*C,S-G*C,w-E*C,d,!1)+4:g+=2,d.push(S-G*A,w-E*A),d.push(S+G*C,w+E*C));continue}const si=(-P+b)*(-M+w)-(-P+S)*(-M+v),ii=(-G+R)*(-E+w)-(-G+S)*(-E+k),we=(wt*ii-qt*si)/be,Se=(Zt*si-jt*ii)/be,qe=(we-S)*(we-S)+(Se-w)*(Se-w),vt=S+(we-S)*C,Pt=w+(Se-w)*C,Mt=S-(we-S)*A,Ct=w-(Se-w)*A,On=Math.min(wt*wt+jt*jt,qt*qt+Zt*Zt),ri=Kt?C:A,Vn=On+ri*ri*y;qe<=Vn?a.join==="bevel"||qe/y>_?(Kt?(d.push(vt,Pt),d.push(S+P*A,w+M*A),d.push(vt,Pt),d.push(S+G*A,w+E*A)):(d.push(S-P*C,w-M*C),d.push(Mt,Ct),d.push(S-G*C,w-E*C),d.push(Mt,Ct)),g+=2):a.join==="round"?Kt?(d.push(vt,Pt),d.push(S+P*A,w+M*A),g+=Tt(S,w,S+P*A,w+M*A,S+G*A,w+E*A,d,!0)+4,d.push(vt,Pt),d.push(S+G*A,w+E*A)):(d.push(S-P*C,w-M*C),d.push(Mt,Ct),g+=Tt(S,w,S-P*C,w-M*C,S-G*C,w-E*C,d,!1)+4,d.push(S-G*C,w-E*C),d.push(Mt,Ct)):(d.push(vt,Pt),d.push(Mt,Ct)):(d.push(S-P*C,w-M*C),d.push(S+P*A,w+M*A),a.join==="round"?Kt?g+=Tt(S,w,S+P*A,w+M*A,S+G*A,w+E*A,d,!0)+2:g+=Tt(S,w,S-P*C,w-M*C,S-G*C,w-E*C,d,!1)+2:a.join==="miter"&&qe/y<=_&&(Kt?(d.push(Mt,Ct),d.push(Mt,Ct)):(d.push(vt,Pt),d.push(vt,Pt)),g+=2),d.push(S-G*C,w-E*C),d.push(S+G*A,w+E*A),g+=2)}b=s[(m-2)*2],v=s[(m-2)*2+1],S=s[(m-1)*2],w=s[(m-1)*2+1],P=-(v-w),M=b-S,N=Math.sqrt(P*P+M*M),P/=N,M/=N,P*=x,M*=x,d.push(S-P*C,w-M*C),d.push(S+P*A,w+M*A),u||(a.cap==="round"?g+=Tt(S-P*(C-A)*.5,w-M*(C-A)*.5,S-P*C,w-M*C,S+P*A,w+M*A,d,!1)+2:a.cap==="square"&&(g+=Zi(S,w,P,M,C,A,!1,d)));const Xt=qi*qi;for(let B=f;B0&&o>0?(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+o,t[6]=i,t[7]=r+o,!0):!1},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[6],t[i+o+1]=s[7],o+=e,t[i+o]=s[4],t[i+o+1]=s[5],o+=e;const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},ul={extension:{type:L.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,!0},triangulate(s,t,e,i,r,n){let o=0;i*=e,t[i+o]=s[0],t[i+o+1]=s[1],o+=e,t[i+o]=s[2],t[i+o+1]=s[3],o+=e,t[i+o]=s[4],t[i+o+1]=s[5];const a=i/e;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},dl=new I,fl=new W;function pl(s,t,e,i){const r=t.matrix?s.copyFrom(t.matrix).invert():s.identity();if(t.textureSpace==="local"){const o=e.getBounds(fl);t.width&&o.pad(t.width);const{x:a,y:h}=o,l=1/o.width,c=1/o.height,u=-a*l,p=-h*c,d=r.a,m=r.b,g=r.c,f=r.d;r.a*=l,r.b*=l,r.c*=c,r.d*=c,r.tx=u*d+p*g+r.tx,r.ty=u*m+p*f+r.ty}else r.translate(t.texture.frame.x,t.texture.frame.y),r.scale(1/t.texture.source.width,1/t.texture.source.height);const n=t.texture.source.style;return!(t.fill instanceof _t)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),i&&r.append(dl.copyFrom(i).invert()),r}const je={};rt.handleByMap(L.ShapeBuilder,je);rt.add(cl,ll,ul,ye,il,rl);const ml=new W,gl=new I;function xl(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r{const u=[],p=je[h.type];if(!p.build(h,u))return;const d=a.length,m=n.length/2;let g="triangle-list";if(l&&Rn(u,l),e){const _=h.closePath??!0,b=t;b.pixelLine?(al(u,_,n,a),g="line-list"):ol(u,b,!1,_,n,a)}else if(c){const _=[],b=u.slice();_l(c).forEach(S=>{_.push(b.length/2),b.push(...S)}),Fn(b,_,n,2,m,a,d)}else p.triangulate(u,n,2,m,a,d);const f=o.length/2,x=t.texture;if(x!==D.WHITE){const _=pl(gl,t,h,l);tl(n,2,m,o,f,2,n.length/2-m,_)}else el(o,f,2,n.length/2-m);const y=it.get(In);y.indexOffset=d,y.indexSize=a.length-d,y.attributeOffset=m,y.attributeSize=n.length/2-m,y.baseColor=t.color,y.alpha=t.alpha,y.texture=x,y.geometryData=r,y.topology=g,i.push(y)})}function _l(s){const t=[];for(let e=0;e{it.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Ks.extension={type:[L.WebGLSystem,L.WebGPUSystem,L.CanvasSystem],name:"graphicsContext"};Ks.defaultOptions={bezierSmoothness:.5};let Gn=Ks;const Sl=8,Le=11920929e-14,vl=1;function Ln(s,t,e,i,r,n,o,a,h,l){const u=Math.min(.99,Math.max(0,l??Gn.defaultOptions.bezierSmoothness));let p=(vl-u)/1;return p*=p,Pl(t,e,i,r,n,o,a,h,s,p),s}function Pl(s,t,e,i,r,n,o,a,h,l){Bs(s,t,e,i,r,n,o,a,h,l,0),h.push(o,a)}function Bs(s,t,e,i,r,n,o,a,h,l,c){if(c>Sl)return;const u=(s+e)/2,p=(t+i)/2,d=(e+r)/2,m=(i+n)/2,g=(r+o)/2,f=(n+a)/2,x=(u+d)/2,y=(p+m)/2,_=(d+g)/2,b=(m+f)/2,v=(x+_)/2,S=(y+b)/2;if(c>0){let w=o-s,R=a-t;const k=Math.abs((e-o)*R-(i-a)*w),P=Math.abs((r-o)*R-(n-a)*w);if(k>Le&&P>Le){if((k+P)*(k+P)<=l*(w*w+R*R)){h.push(v,S);return}}else if(k>Le){if(k*k<=l*(w*w+R*R)){h.push(v,S);return}}else if(P>Le){if(P*P<=l*(w*w+R*R)){h.push(v,S);return}}else if(w=v-(s+o)/2,R=S-(t+a)/2,w*w+R*R<=l){h.push(v,S);return}}Bs(s,t,u,p,x,y,v,S,h,l,c+1),Bs(v,S,_,b,g,f,o,a,h,l,c+1)}const Ml=8,Cl=11920929e-14,Tl=1;function Al(s,t,e,i,r,n,o,a){const l=Math.min(.99,Math.max(0,a??Gn.defaultOptions.bezierSmoothness));let c=(Tl-l)/1;return c*=c,kl(t,e,i,r,n,o,s,c),s}function kl(s,t,e,i,r,n,o,a){Fs(o,s,t,e,i,r,n,a,0),o.push(r,n)}function Fs(s,t,e,i,r,n,o,a,h){if(h>Ml)return;const l=(t+i)/2,c=(e+r)/2,u=(i+n)/2,p=(r+o)/2,d=(l+u)/2,m=(c+p)/2;let g=n-t,f=o-e;const x=Math.abs((i-n)*f-(r-o)*g);if(x>Cl){if(x*x<=a*(g*g+f*f)){s.push(d,m);return}}else if(g=d-(t+n)/2,f=m-(e+o)/2,g*g+f*f<=a){s.push(d,m);return}Fs(s,t,e,l,c,d,m,a,h+1),Fs(s,d,m,u,p,n,o,a,h+1)}function Dn(s,t,e,i,r,n,o,a){let h=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI)))),a=Math.max(a,3);let l=h/a,c=r;l*=o?-1:1;for(let u=0;uu*h)}const ue=Math.PI*2,gs={centerX:0,centerY:0,ang1:0,ang2:0},xs=({x:s,y:t},e,i,r,n,o,a,h)=>{s*=e,t*=i;const l=r*s-n*t,c=n*s+r*t;return h.x=l+o,h.y=c+a,h};function Rl(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),o=Math.cos(s+t),a=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:o+a*i,y:a-o*i},{x:o,y:a}]}const Qi=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Il=(s,t,e,i,r,n,o,a,h,l,c,u,p)=>{const d=Math.pow(r,2),m=Math.pow(n,2),g=Math.pow(c,2),f=Math.pow(u,2);let x=d*m-d*f-m*g;x<0&&(x=0),x/=d*f+m*g,x=Math.sqrt(x)*(o===a?-1:1);const y=x*r/n*u,_=x*-n/r*c,b=l*y-h*_+(s+e)/2,v=h*y+l*_+(t+i)/2,S=(c-y)/r,w=(u-_)/n,R=(-c-y)/r,k=(-u-_)/n,P=Qi(1,0,S,w);let M=Qi(S,w,R,k);a===0&&M>0&&(M-=ue),a===1&&M<0&&(M+=ue),p.centerX=b,p.centerY=v,p.ang1=P,p.ang2=M};function Bl(s,t,e,i,r,n,o,a=0,h=0,l=0){if(n===0||o===0)return;const c=Math.sin(a*ue/360),u=Math.cos(a*ue/360),p=u*(t-i)/2+c*(e-r)/2,d=-c*(t-i)/2+u*(e-r)/2;if(p===0&&d===0)return;n=Math.abs(n),o=Math.abs(o);const m=Math.pow(p,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);m>1&&(n*=Math.sqrt(m),o*=Math.sqrt(m)),Il(t,e,i,r,n,o,h,l,c,u,p,d,gs);let{ang1:g,ang2:f}=gs;const{centerX:x,centerY:y}=gs;let _=Math.abs(f)/(ue/4);Math.abs(1-_)<1e-7&&(_=1);const b=Math.max(Math.ceil(_),1);f/=b;let v=s[s.length-2],S=s[s.length-1];const w={x:0,y:0};for(let R=0;R{const h=a.x-o.x,l=a.y-o.y,c=Math.sqrt(h*h+l*l),u=h/c,p=l/c;return{len:c,nx:u,ny:p}},r=(o,a)=>{o===0?s.moveTo(a.x,a.y):s.lineTo(a.x,a.y)};let n=t[t.length-1];for(let o=0;o0&&(d=-1,m=!0);const g=p/2;let f,x=Math.abs(Math.cos(g)*h/Math.sin(g));x>Math.min(c.len/2,u.len/2)?(x=Math.min(c.len/2,u.len/2),f=Math.abs(x*Math.sin(g)/Math.cos(g))):f=h;const y=a.x+u.nx*x+-u.ny*f*d,_=a.y+u.ny*x+u.nx*f*d,b=Math.atan2(c.ny,c.nx)+Math.PI/2*d,v=Math.atan2(u.ny,u.nx)-Math.PI/2*d;o===0&&s.moveTo(y+Math.cos(b)*f,_+Math.sin(b)*f),s.arc(y,_,f,b,v,m),n=a}}function Gl(s,t,e,i){const r=(a,h)=>Math.sqrt((a.x-h.x)**2+(a.y-h.y)**2),n=(a,h,l)=>({x:a.x+(h.x-a.x)*l,y:a.y+(h.y-a.y)*l}),o=t.length;for(let a=0;a1){let n=null;for(let o=r;o=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(t,e,i,r,n){return this.drawShape(new qs(t,e,i,r),n),this}roundRect(t,e,i,r,n,o){return this.drawShape(new Zs(t,e,i,r,n),o),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new le,i.points.push(t,e),this._currentPoly=i,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new le,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,o=i;i=n.a*i+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty}this._currentPoly.points.push(i,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;ea.area).sort((a,h)=>h-a),[e,i]=t,r=t[t.length-1],n=e/i,o=i/r;return!(n>3&&o<2)}function $l(s){return s.split(/(?=[Mm])/).filter(i=>i.trim().length>0)}function Ol(s){const t=s.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],r=[];for(let c=0;c1;if(M&&G){const N=P.map(C=>({path:C,area:Ol(C)}));if(N.sort((C,A)=>A.area-C.area),P.length>3||!Ul(N))for(let C=0;CparseInt(k,10)),t.context.poly(_,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":b=s.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{Q(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}a&&(e=null);for(let k=0;k{this._fill=Bt({...this._originalFill},ot.defaultFillStyle)})),this._fill=Bt(t===0?"black":t,ot.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ot.defaultStrokeStyle,...t},()=>{this._stroke=Ve({...this._originalStroke},ot.defaultStrokeStyle)})),this._stroke=Ve(t,ot.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const t=Ut.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new Ut({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e(i[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Y.isColorLike(t)||t instanceof _t||t instanceof Xe)}};Js.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Js.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Nn=Js;function Kl(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=Nn.defaultDropShadow;s.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){F(O,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Y.isColorLike(e))i.color=e;else if(e instanceof _t||e instanceof Xe)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(F(O,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&Q("The number of fill colors must match the number of fill gradient stops.");const e=new _t({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),i=t.fillGradientStops.slice(),r=t.fill.map(n=>Y.shared.setValue(n).toNumber());i.forEach((n,o)=>{e.addColorStop(n,r[o])}),s.fill={fill:e}}}class Ql{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=et.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Vt(t),e=Vt(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:r}=e,n=(i<<17)+(r<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,r),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const Gs=new Ql;_e.register(Gs);const hr=1e5;function lr(s,t,e,i=0){if(s.texture===D.WHITE&&!s.fill)return Y.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof Xe){const r=s.fill,n=t.createPattern(r.texture.source.resource,"repeat"),o=r.transform.copyTo(I.shared);return o.scale(r.texture.frame.width,r.texture.frame.height),n.setTransform(o),n}else if(s.fill instanceof _t){const r=s.fill,n=r.type==="linear",o=r.textureSpace==="local";let a=1,h=1;o&&e&&(a=e.width+i,h=e.height+i);let l,c=!1;if(n){const{start:u,end:p}=r;l=t.createLinearGradient(u.x*a,u.y*h,p.x*a,p.y*h),c=Math.abs(p.x-u.x){const g=d+m.offset*u;l.addColorStop(Math.floor(g*hr)/hr,Y.shared.setValue(m.color).toHex())})}}else r.colorStops.forEach(u=>{l.addColorStop(u.offset,Y.shared.setValue(u.color).toHex())});return l}}else{const r=t.createPattern(s.texture.source.resource,"repeat"),n=s.matrix.copyTo(I.shared);return n.scale(s.texture.frame.width,s.texture.frame.height),r.setTransform(n),r}return Q("FillStyle not recognised",s),"red"}class dt extends Vs{constructor(t){t instanceof ot&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ot,this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=i??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new dt(this._context.clone()):(this._ownedContext=null,new dt(this._context))}lineStyle(t,e,i){F(O,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){F(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){F(O,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==ot.defaultStrokeStyle.width||t.color!==ot.defaultStrokeStyle.color||t.alpha!==ot.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return F(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return F(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return F(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return F(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return F(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return F(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class Jl extends Vs{constructor(t,e){const{text:i,resolution:r,style:n,anchor:o,width:a,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new q({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=l??!1,a!==void 0&&(this.width=a),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function tc(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(F(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}let At=null,gt=null;function ec(s,t){At||(At=et.get().createCanvas(256,128),gt=At.getContext("2d",{willReadFrequently:!0}),gt.globalCompositeOperation="copy",gt.globalAlpha=1),(At.width{this.pointer=null,this.lastPointerEventAt=performance.now()}),this.host.addEventListener("pointermove",t=>{const e=this.host.getBoundingClientRect();this.pointer={x:t.clientX-e.left,y:t.clientY-e.top},this.lastPointerEventAt=performance.now()})}resize(){this.bounds={width:this.host.clientWidth,height:this.host.clientHeight}}render(t,e){this.resize(),this.renderFrame(t,e),this.clearHover()}clearHover(){this.crosshair.clear()}getHoverCandidate(){if(!this.pointer||this.screenPoints.length===0)return null;let t=null,e=1/0;for(const i of this.screenPoints){const r=i.x-this.pointer.x,n=i.y-this.pointer.y,o=Math.sqrt(r*r+n*n);othis.hoverRadiusPx?null:{panelId:this.panelId,point:t,x:De(t.x,0,this.bounds.width),y:De(t.y,0,this.bounds.height),pointerX:this.pointer.x,pointerY:this.pointer.y,distance:e,lastPointerEventAt:this.lastPointerEventAt}}hasPointer(){return this.pointer!==null}findNearestScreenPointByTime(t){if(this.screenPoints.length===0)return null;let e=null,i=1/0;for(const r of this.screenPoints){const n=Math.abs(r.timeMs-t);nt;){const e=this.axisLabels.pop();this.axisLabelLayer.removeChild(e),e.destroy()}}renderAxes({padding:t,plotWidth:e,plotHeight:i,minTime:r,maxTime:n,minValue:o,maxValue:a,width:h}){const d=[];this.axes.clear(),this.axes.moveTo(t.left,t.top),this.axes.lineTo(t.left,t.top+i),this.axes.lineTo(t.left+e,t.top+i),this.axes.stroke({color:4082783,width:1,alpha:1});for(let m=0;m<5;m+=1){const g=m/4,f=t.top+g*i,x=r+g*(n-r);this.axes.moveTo(t.left-8,f),this.axes.lineTo(t.left,f),this.axes.stroke({color:5202554,width:1,alpha:1}),d.push({text:Ot(x),x:14,y:f-7,anchorX:0})}for(let m=0;m<5;m+=1){const g=m/4,f=t.left+g*e,x=o+g*(a-o);this.axes.moveTo(f,t.top+i),this.axes.lineTo(f,t.top+i+8),this.axes.stroke({color:5202554,width:1,alpha:1}),d.push({text:Ls(x),x:f,y:t.top+i+10,anchorX:.5})}this.ensureAxisLabelCount(d.length),d.forEach((m,g)=>{const f=this.axisLabels[g];f.text=m.text,f.x=m.x,f.y=m.y,f.anchor.set(m.anchorX,0)}),this.axisTitleText.text="TIME",this.axisTitleText.x=18,this.axisTitleText.y=t.top-18,this.axisTitleText.rotation=0,this.axes.moveTo(t.left+e,t.top+i),this.axes.lineTo(h-14,t.top+i),this.axes.stroke({color:2107957,width:1,alpha:1})}renderReadouts(t,e){if(!this.showReadouts){this.readoutBackground.clear(),this.realTimeText.text="",this.plotTimeText.text="";return}const i=168,r=22,n=6,o=e-i-18,a=14;this.readoutBackground.clear(),this.readoutBackground.rect(o,a,i,r),this.readoutBackground.fill({color:1054237,alpha:1}),this.readoutBackground.stroke({color:3095629,width:1,alpha:1}),this.readoutBackground.rect(o,a+r+n,i,r),this.readoutBackground.fill({color:1054237,alpha:1}),this.readoutBackground.stroke({color:3095629,width:1,alpha:1}),this.realTimeText.text=`REAL ${Un(t.time.realNowMs)}`,this.realTimeText.x=o+10,this.realTimeText.y=a+5,this.plotTimeText.text=`PLOT ${Ot(t.time.plotTimeMs)}`,this.plotTimeText.x=o+10,this.plotTimeText.y=a+r+n+5}renderFrame(t,e){const i=this.bounds.width,r=this.bounds.height,n={top:72,right:28,bottom:46,left:88},o=Math.max(10,i-n.left-n.right),a=Math.max(10,r-n.top-n.bottom),h=t.time.plotTimeMs-t.plot.windowDurationMs,l=Math.max(t.time.plotTimeMs,h+1),{min:c,max:u}=t.plot.valueRange,p=Math.max(.001,u-c);if(this.background.clear(),rc(this.background,0,0,i,r,6,{color:329483,alpha:1},{color:2898765,width:1}),this.grid.clear(),t.plot.showGrid){for(let m=0;m<=6;m+=1){const g=n.left+o*m/6;this.grid.moveTo(g,n.top),this.grid.lineTo(g,n.top+a),this.grid.stroke({color:2176074,width:1,alpha:.85})}for(let m=0;m<=8;m+=1){const g=n.top+a*m/8;this.grid.moveTo(n.left,g),this.grid.lineTo(n.left+o,g),this.grid.stroke({color:2176074,width:1,alpha:.85})}}if(this.renderAxes({padding:n,plotWidth:o,plotHeight:a,minTime:h,maxTime:l,minValue:c,maxValue:u,width:i}),this.line.clear(),this.points.clear(),this.screenPoints=[],e.length>0&&(e.forEach((d,m)=>{const g=n.left+(d.value-c)/p*o,f=n.top+(d.timeMs-h)/(l-h)*a;this.screenPoints.push({...d,x:g,y:f}),m===0?this.line.moveTo(g,f):this.line.lineTo(g,f)}),this.line.stroke({color:this.lineColor,width:2,alpha:.96,cap:"square",join:"miter"}),t.plot.showPoints))for(const d of this.screenPoints)this.points.rect(d.x-2,d.y-2,4,4),this.points.fill({color:this.pointColor,alpha:.92});this.titleText.text=this.panelTitle,this.titleText.x=20,this.titleText.y=14,this.subtitleText.text=this.panelSubtitle??`value → ${t.source.preset} · ${t.source.sampleRateHz} hz · time ↓`,this.subtitleText.x=20,this.subtitleText.y=36,this.renderReadouts(t,i)}destroy(){this.app.destroy(!0,{children:!0})}}class ti{constructor(t={}){this.config={...t},this.running=!1}start(){this.running=!0}stop(){this.running=!1}updateConfig(t){this.config={...this.config,...t}}}function nc(s,t,e){return Math.min(e,Math.max(t,s))}class oc extends ti{constructor(t={}){super({replayRate:1,dataset:[],...t}),this.sourceType="csv-replay",this.nextPointIndex=0}start(t=0){super.start(),this.reset(t)}reset(){this.nextPointIndex=0}updateConfig(t){const e=t.dataset!==this.config.dataset;super.updateConfig(t),e&&this.reset()}update(t){if(!this.running||!Array.isArray(this.config.dataset)||this.config.dataset.length===0)return[];const e=nc(this.config.replayRate??1,.1,8),i=t*e,r=[];for(;this.nextPointIndexi)break;r.push({timeMs:n.timeMs/e,value:n.value,sourceId:this.config.id??"csv-replay"}),this.nextPointIndex+=1}return r}}function ac(s,t,e){return Math.min(e,Math.max(t,s))}function hc(s){const t=Math.sin(s*12.9898)*43758.5453;return t-Math.floor(t)}class lc extends ti{constructor(t={}){super({sampleRateHz:60,preset:"telemetry",amplitude:1,noise:.08,...t}),this.sourceType="synthetic-wave",this.lastEmittedPlotTimeMs=0}start(t=0){super.start(),this.lastEmittedPlotTimeMs=t}stop(){super.stop()}reset(t=0){this.lastEmittedPlotTimeMs=t}sampleValue(t){const e=t/1e3,i=this.config.amplitude,r=this.config.noise,n=(hc(t*.017)-.5)*2*r;switch(this.config.preset){case"chirp":{const o=Math.sin(e*e*1.4);return i*(.7*o+.3*Math.sin(e*7.5))+n}case"burst":{const o=e%6-1.5,a=Math.sin(e*9.5)*Math.exp(-(o**2)*.8);return i*(.45*Math.sin(e*2.1)+a)+n}case"telemetry":default:{const o=Math.sin(e*2.2),a=.35*Math.cos(e*6.4+Math.sin(e*.8)),h=.15*Math.sin(e*.33);return i*(o+a+h)+n}}}update(t){if(!this.running)return[];const e=1e3/ac(this.config.sampleRateHz,1,240);if(tDs(t));if($n(s))return[{value:s,timestampMs:null}];if(typeof s=="string"){const t=s.trim();if(!t)return[];const e=Number(t);if(Number.isFinite(e))return[{value:e,timestampMs:null}];try{return Ds(JSON.parse(t))}catch{return[]}}if(s&&typeof s=="object"){const t=[s.value,s.y,s.signal,s.data].find(i=>Number.isFinite(Number(i)));if(t===void 0)return[];const e=[s.timeMs,s.timestampMs,s.timestamp,s.t].find(i=>Number.isFinite(Number(i)));return[{value:Number(t),timestampMs:e===void 0?null:Number(e)}]}return[]}class uc extends ti{constructor(t={},{onStatusChange:e}={}){super({wsUrl:"ws://localhost:8080",wsReconnectMs:2e3,...t}),this.sourceType="websocket",this.onStatusChange=e,this.socket=null,this.queue=[],this.lastPlotTimeMs=0,this.reconnectTimer=null,this.shouldReconnect=!1,this.firstSourceTimestampMs=null,this.basePlotTimeMs=0}start(t=0){super.start(),this.lastPlotTimeMs=t,this.basePlotTimeMs=t,this.shouldReconnect=!0,this.connect()}stop(){super.stop(),this.shouldReconnect=!1,this.clearReconnectTimer(),this.socket&&(this.socket.close(),this.socket=null),this.setStatus("disconnected","socket closed")}reset(t=0){this.queue=[],this.lastPlotTimeMs=t,this.basePlotTimeMs=t,this.firstSourceTimestampMs=null}updateConfig(t){const e=this.config.wsUrl,i=this.config.wsReconnectMs;super.updateConfig(t),(e!==this.config.wsUrl||i!==this.config.wsReconnectMs)&&this.running&&this.reconnect()}update(t){if(this.lastPlotTimeMs=t,this.queue.length===0)return[];const e=[];for(;this.queue.length>0;){const i=this.queue.shift();let r=t;$n(i.timestampMs)&&(this.firstSourceTimestampMs===null&&(this.firstSourceTimestampMs=i.timestampMs,this.basePlotTimeMs=t),r=this.basePlotTimeMs+(i.timestampMs-this.firstSourceTimestampMs)),e.push({timeMs:r,value:i.value,sourceId:this.config.id??"websocket"})}return e}reconnect(){this.running&&(this.clearReconnectTimer(),this.socket&&(this.socket.close(),this.socket=null),this.connect())}connect(){var e;const t=(e=this.config.wsUrl)==null?void 0:e.trim();if(!t){this.setStatus("idle","enter a websocket url");return}this.clearReconnectTimer(),this.setStatus("connecting",t);try{this.socket=new WebSocket(t)}catch(i){this.setStatus("error",i instanceof Error?i.message:String(i)),this.scheduleReconnect();return}this.socket.addEventListener("open",()=>{this.setStatus("connected",t)}),this.socket.addEventListener("message",i=>{const r=Ds(i.data);r.length!==0&&this.queue.push(...r)}),this.socket.addEventListener("error",()=>{this.setStatus("error","socket error")}),this.socket.addEventListener("close",()=>{this.socket=null,this.running&&(this.setStatus("disconnected","retrying"),this.scheduleReconnect())})}scheduleReconnect(){if(!this.shouldReconnect||!this.running)return;const t=cc(Number(this.config.wsReconnectMs)||2e3,250,3e4);this.clearReconnectTimer(),this.reconnectTimer=window.setTimeout(()=>{this.connect()},t)}clearReconnectTimer(){this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}setStatus(t,e=""){var i;(i=this.onStatusChange)==null||i.call(this,{wsStatus:t,wsStatusDetail:e})}}class dc{constructor(t,e){this.store=t,this.bus=e,this.sources=new Map,this.syncFromState()}syncFromState(){const t=this.store.getState(),e=Object.entries(t.sources),i=new Set(e.map(([r])=>r));for(const[r,n]of e){const o=this.sources.get(r);if(!o){const a=this.createSource(r,n);this.sources.set(r,a),a.start(t.time.plotTimeMs);continue}if(o.sourceType!==n.type){o.stop();const a=this.createSource(r,n);this.sources.set(r,a),a.start(t.time.plotTimeMs);continue}o.updateConfig(n)}for(const[r,n]of this.sources.entries())i.has(r)||(n.stop(),this.sources.delete(r))}createSource(t,e){switch(e.type){case"csv-replay":return new oc(e);case"websocket":return new uc(e,{onStatusChange:i=>{this.store.setState(r=>({...r,sources:{...r.sources,[t]:{...r.sources[t],...i}}}))}});case"synthetic-wave":default:return new lc(e)}}update(t){for(const[e,i]of this.sources.entries()){const r=i.update(t);for(const n of r)this.bus.emit("data:point",{...n,sourceId:e})}}reset(){const t=this.store.getState().time.plotTimeMs;for(const e of this.sources.values())e.reset(t)}}function fc(s){return s.split(/[;,\t]/).map(t=>t.trim())}function zs(s){return s!==""&&Number.isFinite(Number(s))}function pc(s){if(s.length===0)return{hasHeader:!1,headers:[]};const[t]=s,e=t.some(i=>!zs(i));return{hasHeader:e,headers:e?t.map(i=>i.toLowerCase()):[]}}function mc(s){const t=s.find(e=>e.includes("time")||e.includes("timestamp"));return t&&t.includes("sec")&&!t.includes("msec")&&!t.includes("ms")?1e3:1}function gc(s,t){if(s.length===0)return{timeIndex:t>1?0:-1,valueIndex:t>1?1:0};const e=s.findIndex(r=>r.includes("time")||r.includes("timestamp")),i=s.findIndex(r=>r.includes("value")||r.includes("signal")||r.includes("y"));return{timeIndex:e,valueIndex:i>=0?i:s.length>1?1:0}}function xc(s,{sampleRateHz:t=60}={}){var m;const e=s.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).map(fc).filter(g=>g.some(f=>f!==""));if(e.length===0)throw new Error("CSV file is empty");const{hasHeader:i,headers:r}=pc(e),n=i?e.slice(1):e,o=e[0].length,{timeIndex:a,valueIndex:h}=gc(r,o),l=mc(r),c=1e3/Math.max(1,t),u=n.map((g,f)=>{const x=g[h];if(!zs(x))return null;const y=Number(x);return{timeMs:a>=0&&zs(g[a])?Number(g[a])*l:f*c,value:y}}).filter(Boolean).sort((g,f)=>g.timeMs-f.timeMs);if(u.length===0)throw new Error("CSV file did not contain any numeric data points");const p=u[0].timeMs,d=u.map(g=>({timeMs:g.timeMs-p,value:g.value}));return{points:d,metadata:{pointCount:d.length,durationMs:((m=d.at(-1))==null?void 0:m.timeMs)??0}}}function H(s,t,e){const i=document.createElement(s);return t&&(i.className=t),e&&(i.textContent=e),i}function mr(s,t){s.dataset.active=String(t)}function gr(s){return s.tagName==="SELECT"?s.value:s instanceof HTMLInputElement?s.type==="checkbox"?s.checked:s.type==="number"||s.type==="range"?Number(s.value):s.value:s.value}function j(s,t){if(!(!s||document.activeElement===s)){if(s instanceof HTMLInputElement&&s.type==="checkbox"){s.checked=!!t;return}s.value=String(t??"")}}class yc{constructor({root:t,store:e,actions:i}){this.root=t,this.store=e,this.actions=i,this.elements={}}mount(){const t=H("div","timeplot-shell"),e=H("header","timeplot-topbar"),i=H("section","timeplot-viewport"),r=H("div","timeplot-plot-grid"),n=H("section","timeplot-plot-panel"),o=H("section","timeplot-plot-panel"),a=H("div","timeplot-canvas-host"),h=H("div","timeplot-canvas-host"),l=H("aside","timeplot-sidebar"),c=H("div","timeplot-tooltip"),u=H("div","timeplot-tooltip");c.hidden=!0,u.hidden=!0;const p=H("div","timeplot-brand"),d=H("h1","timeplot-title","TimePlot"),m=H("div","timeplot-subtitle","Dual synchronized signal monitor");p.append(d,m);const g=H("div","timeplot-toolbar");return g.append(this.createTransportControls(),this.createPanelToggles()),e.append(p,g),n.append(a,c),o.append(h,u),r.append(n,o),i.append(r),t.append(e,i,l),this.root.replaceChildren(t),this.elements={...this.elements,shell:t,topbar:e,viewport:i,plotGrid:r,primaryPlotPanel:n,secondaryPlotPanel:o,primaryCanvasHost:a,secondaryCanvasHost:h,sidebar:l,primaryTooltip:c,secondaryTooltip:u,title:d,subtitle:m,statusPanel:this.createStatusPanel(),sourcePanel:this.createSourcePanel(),configPanel:this.createConfigPanel(),helpPanel:this.createHelpPanel()},l.append(this.elements.statusPanel,this.elements.sourcePanel,this.elements.configPanel,this.elements.helpPanel),this.elements}createTransportControls(){const t=H("div","control-group"),e=H("button","control-button","Pause"),i=H("button","control-button","Reset"),r=H("span",null,"Speed"),n=document.createElement("input");n.type="range",n.min="0.1",n.max="6",n.step="0.1";const o=H("span",null,"1.0×");return e.addEventListener("click",()=>this.actions.togglePause()),i.addEventListener("click",()=>this.actions.resetScene()),n.addEventListener("input",a=>this.actions.setSpeed(Number(a.target.value))),t.append(e,i,r,n,o),this.elements.pauseButton=e,this.elements.resetButton=i,this.elements.speedInput=n,this.elements.speedValue=o,t}createPanelToggles(){const t=H("div","control-group"),e=["status","source","config","help"];this.elements.panelButtons={};for(const i of e){const r=H("button","panel-toggle",i);r.addEventListener("click",()=>this.actions.togglePanel(i)),this.elements.panelButtons[i]=r,t.append(r)}return t}createStatusPanel(){const t=H("section","panel");return t.innerHTML=`

Status

Renderer
Real time
Real elapsed
Plot time
Playback
Points
`,t}createSourcePanel(){const t=H("section","panel");return t.innerHTML=`

Data Source

Signal A
Signal B
`,t.querySelectorAll("[data-source-field]").forEach(e=>{const i=e.tagName==="SELECT"?"change":"input";e.addEventListener(i,()=>{const r=e.getAttribute("data-source-key"),n=e.getAttribute("data-source-field"),o=gr(e);this.actions.updateSource(r,n,o)})}),t.querySelectorAll("[data-source-file]").forEach(e=>{e.addEventListener("change",async()=>{var n;const i=e.getAttribute("data-source-key"),r=(n=e.files)==null?void 0:n[0];r&&(await this.actions.loadSourceFile(i,r),e.value="")})}),t}createConfigPanel(){const t=H("section","panel");return t.innerHTML=`

Config

Show grid
Show points
Graph routing
`,t.querySelectorAll("[data-plot-field]").forEach(e=>{const i=e instanceof HTMLInputElement&&e.type==="checkbox"?"change":"input";e.addEventListener(i,()=>{const r=e.getAttribute("data-plot-field"),n=gr(e);this.actions.updatePlot(r,n)})}),t.querySelectorAll("[data-graph-field]").forEach(e=>{e.addEventListener("change",()=>{const i=e.getAttribute("data-graph-id"),r=e.getAttribute("data-graph-field");this.actions.updateGraph(i,r,e.value)})}),t}createHelpPanel(){const t=H("section","panel");return t.innerHTML=`

Help

  1. Each signal can be synthetic or file-backed CSV replay.
  2. Each graph can target Signal A or Signal B independently.
  3. Each graph can render raw, delta, or smoothed data.
  4. Hover either trace to inspect the nearest synchronized sample.
  5. Use pause and speed controls to inspect timing behavior.
`,t}sync(t,e){this.elements.title.textContent=t.app.title,this.elements.subtitle.textContent="Dual synchronized signal monitor",this.elements.pauseButton.textContent=t.time.paused?"Resume":"Pause",mr(this.elements.pauseButton,t.time.paused),j(this.elements.speedInput,t.time.speed),this.elements.speedValue.textContent=`${t.time.speed.toFixed(1)}×`;const i=this.elements.statusPanel.querySelectorAll("[data-field]"),r=Object.fromEntries(Array.from(i).map(n=>[n.getAttribute("data-field"),n]));r.renderer.textContent=t.app.renderer,r.realTime.textContent=Un(t.time.realNowMs),r.realElapsed.textContent=Ot(t.time.realElapsedMs),r.plotTime.textContent=Ot(t.time.plotTimeMs),r.playback.textContent=t.time.paused?"Paused":`${t.time.speed.toFixed(1)}×`,r.points.textContent=typeof e=="object"?`${e.primary} / ${e.secondary}`:`${e}`,this.syncSourcePanel(t),this.syncConfigPanel(t),this.syncPanels(t),this.syncTooltip(t)}syncSourcePanel(t){Object.entries(t.sources).forEach(([e,i])=>{j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="type"]`),i.type),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="preset"]`),i.preset),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="sampleRateHz"]`),i.sampleRateHz),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="amplitude"]`),i.amplitude),j(this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="noise"]`),i.noise);const r=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="replayRate"]`);r&&j(r,i.replayRate??1),this.elements.sourcePanel.querySelector(`[data-source-config="${e}"]`).querySelectorAll("[data-source-mode]").forEach(c=>{c.hidden=c.getAttribute("data-source-mode")!==i.type});const o=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-meta]`);o&&(i.type==="csv-replay"?o.innerHTML=i.loadError?`${i.loadError}`:`${i.dataFileName||"No file loaded"}${i.datasetPointCount?` · ${i.datasetPointCount} pts · ${Ot(i.datasetDurationMs||0)}`:""}`:i.type==="websocket"?o.textContent="":o.textContent="Generates data procedurally in-browser");const a=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="wsUrl"]`),h=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-field="wsReconnectMs"]`),l=this.elements.sourcePanel.querySelector(`[data-source-key="${e}"][data-source-ws-meta]`);a&&j(a,i.wsUrl??""),h&&j(h,i.wsReconnectMs??2e3),l&&(l.innerHTML=i.type==="websocket"?`status: ${i.wsStatus||"idle"}${i.wsStatusDetail?` · ${i.wsStatusDetail}`:""}`:"")})}syncConfigPanel(t){j(this.elements.configPanel.querySelector('[data-plot-field="windowDurationMs"]'),t.plot.windowDurationMs),j(this.elements.configPanel.querySelector('[data-plot-field="maxPoints"]'),t.plot.maxPoints),j(this.elements.configPanel.querySelector('[data-plot-field="showGrid"]'),t.plot.showGrid),j(this.elements.configPanel.querySelector('[data-plot-field="showPoints"]'),t.plot.showPoints),j(this.elements.configPanel.querySelector('[data-graph-id="primary"][data-graph-field="sourceKey"]'),t.graphs.primary.sourceKey),j(this.elements.configPanel.querySelector('[data-graph-id="primary"][data-graph-field="transform"]'),t.graphs.primary.transform),j(this.elements.configPanel.querySelector('[data-graph-id="secondary"][data-graph-field="sourceKey"]'),t.graphs.secondary.sourceKey),j(this.elements.configPanel.querySelector('[data-graph-id="secondary"][data-graph-field="transform"]'),t.graphs.secondary.transform)}syncPanels(t){const e={status:this.elements.statusPanel,source:this.elements.sourcePanel,config:this.elements.configPanel,help:this.elements.helpPanel};for(const[i,r]of Object.entries(t.panels))e[i].hidden=!r.visible,mr(this.elements.panelButtons[i],r.visible)}syncTooltip(t){const e=t.plot.tooltip;if(this.elements.primaryTooltip.hidden=!0,this.elements.secondaryTooltip.hidden=!0,!e.visible||!e.point)return;const i=e.panelId==="secondary"?this.elements.secondaryTooltip:this.elements.primaryTooltip;i.hidden=!1,i.style.left=`${e.x}px`,i.style.top=`${e.y}px`,i.innerHTML=`
Hovered sample
Panel${e.panelLabel??"Primary"}
Plot time${Ot(e.point.timeMs)}
Value${Ls(e.point.value)}
Source${e.point.sourceId}
${e.linkedPoint?`
Linked panel${e.linkedPanelLabel??"Linked"}
`:""} ${e.linkedPoint?`
Linked value${Ls(e.linkedPoint.value)}
`:""} `}}function xr(s,t,e){return Math.min(e,Math.max(t,s))}function _c(s){if(s.length<2)return[];const t=[];for(let e=1;ea+h.value,0)/n.length;e.push({...s[i],value:o,sourceId:`${s[i].sourceId}:smooth`})}return e}function wc(s,t){switch(t){case"delta":return _c(s);case"smooth":return bc(s);case"raw":default:return s}}function yr(s){switch(s){case"delta":return"Δvalue / second";case"smooth":return"moving average";case"raw":default:return"raw signal"}}function Sc(s,t){if(s.length===0)return t;let e=1/0,i=-1/0;for(const n of s)e=Math.min(e,n.value),i=Math.max(i,n.value);const r=Math.max(Math.abs(e),Math.abs(i),.1);return{min:-r,max:r}}function vc(s,t){return!s&&!t?null:s&&!t?s:!s&&t?t:s.lastPointerEventAt>=t.lastPointerEventAt?s:t}async function Pc(s){const t=new Wn,e=new Kn(br()),i=new Qn(e),r=new Map(Object.keys(e.getState().sources).map(f=>[f,new ni(e.getState().plot.maxPoints)]));let n;const o=()=>{const f=e.getState();for(const x of Object.keys(f.sources))r.has(x)||r.set(x,new ni(f.plot.maxPoints)),r.get(x).maxPoints=f.plot.maxPoints;for(const x of Array.from(r.keys()))f.sources[x]||r.delete(x)},a=f=>{var x;(x=r.get(f))==null||x.clear()},h=(f,x)=>{const y=f.graphs[x],_=r.get(y.sourceKey),b=_?_.getVisiblePoints(f.time.plotTimeMs,f.plot.windowDurationMs):[],v=wc(b,y.transform);return{graphConfig:y,points:v,range:Sc(v,f.plot.valueRange)}},l={togglePause:()=>i.togglePause(),setSpeed:f=>i.setSpeed(f),resetScene:()=>{i.reset(),r.forEach(f=>f.clear()),n.reset()},togglePanel:f=>{e.setState(x=>({...x,panels:{...x.panels,[f]:{...x.panels[f],visible:!x.panels[f].visible}}}))},updateSource:(f,x,y)=>{e.setState(_=>({..._,sources:{..._.sources,[f]:{..._.sources[f],[x]:y,...x==="type"?{loadError:y==="csv-replay"&&_.sources[f].dataset.length===0?_.sources[f].dataFileName?`Reload ${_.sources[f].dataFileName} to restore replay data`:"Load a CSV file to begin replay":"",wsStatus:y==="websocket"?_.sources[f].wsStatus:"idle",wsStatusDetail:y==="websocket"?_.sources[f].wsStatusDetail:""}:{}}}})),n.syncFromState(),o(),(x==="type"||x==="wsUrl"||x==="wsReconnectMs")&&(a(f),n.reset())},loadSourceFile:async(f,x)=>{var y;try{const b=((y=e.getState().sources[f])==null?void 0:y.sampleRateHz)??60,v=await x.text(),{points:S,metadata:w}=xc(v,{sampleRateHz:b});a(f),e.setState(R=>({...R,sources:{...R.sources,[f]:{...R.sources[f],type:"csv-replay",dataset:S,dataFileName:x.name,datasetPointCount:w.pointCount,datasetDurationMs:w.durationMs,loadError:"",wsStatus:"idle",wsStatusDetail:""}}})),n.syncFromState(),n.reset()}catch(_){e.setState(b=>({...b,sources:{...b.sources,[f]:{...b.sources[f],loadError:_ instanceof Error?_.message:String(_)}}}))}},updatePlot:(f,x)=>{e.setState(y=>({...y,plot:{...y.plot,[f]:x}})),f==="maxPoints"&&(buffer.maxPoints=xr(x,200,4e3),r.forEach(y=>{y.maxPoints=xr(x,200,4e3)}))},updateGraph:(f,x,y)=>{e.setState(_=>({..._,graphs:{..._.graphs,[f]:{..._.graphs[f],[x]:y}}}))}},c=new yc({root:s,store:e,actions:l}),u=c.mount(),p=new pr({host:u.primaryCanvasHost,panelId:"primary",title:"Primary signal",subtitle:null,showReadouts:!0,lineColor:10473983,pointColor:15201023}),d=new pr({host:u.secondaryCanvasHost,panelId:"secondary",title:"Secondary signal",subtitle:null,showReadouts:!1,lineColor:16761963,pointColor:16769456}),m=await p.init();await d.init(),e.patch({app:{...e.getState().app,renderer:m}}),n=new dc(e,t),t.on("data:point",f=>{var x;(x=r.get(f.sourceId))==null||x.addPoint(f)});const g=f=>{if(!(f.target instanceof HTMLInputElement||f.target instanceof HTMLSelectElement)){if(f.code==="Space"){f.preventDefault(),l.togglePause();return}if(f.key==="["){l.setSpeed(e.getState().time.speed-.1);return}if(f.key==="]"){l.setSpeed(e.getState().time.speed+.1);return}f.key.toLowerCase()==="g"&&l.updatePlot("showGrid",!e.getState().plot.showGrid)}};return window.addEventListener("keydown",g),p.app.ticker.add(()=>{i.tick(),n.syncFromState(),o(),n.update(e.getState().time.plotTimeMs);const f=e.getState(),x=h(f,"primary"),y=h(f,"secondary");p.panelTitle=f.graphs.primary.title,p.panelSubtitle=`${f.sources[f.graphs.primary.sourceKey].label} · ${yr(f.graphs.primary.transform)} · time ↓`,d.panelTitle=f.graphs.secondary.title,d.panelSubtitle=`${f.sources[f.graphs.secondary.sourceKey].label} · ${yr(f.graphs.secondary.transform)} · time ↓`;const _={...f,plot:{...f.plot,valueRange:x.range}},b={...f,plot:{...f.plot,valueRange:y.range}};p.render(_,x.points),d.render(b,y.points);const v=p.getHoverCandidate(),S=d.getHoverCandidate(),w=vc(v,S);if(!w){p.clearHover(),d.clearHover(),e.setState(E=>({...E,plot:{...E.plot,hoveredPoint:null,tooltip:{...E.plot.tooltip,visible:!1,point:null,linkedPoint:null}}})),c.sync(e.getState(),{primary:x.points.length,secondary:y.points.length});return}const R=p.findNearestScreenPointByTime(w.point.timeMs),k=d.findNearestScreenPointByTime(w.point.timeMs);p.renderLinkedHover(R),d.renderLinkedHover(k);const P=w.panelId==="secondary"?f.graphs.secondary.title:f.graphs.primary.title,M=w.panelId==="secondary"?R:k,G=w.panelId==="secondary"?f.graphs.primary.title:f.graphs.secondary.title;e.setState(E=>({...E,plot:{...E.plot,hoveredPoint:w.point,tooltip:{...E.plot.tooltip,visible:!0,panelId:w.panelId,panelLabel:P,x:w.x,y:w.y,point:w.point,linkedPoint:M,linkedPanelLabel:G}}})),c.sync(e.getState(),{primary:x.points.length,secondary:y.points.length})}),{destroy(){window.removeEventListener("keydown",g),p.destroy(),d.destroy()}}}const Hs=document.getElementById("app");if(!Hs)throw new Error("App root not found");Pc(Hs).catch(s=>{console.error("Failed to start TimePlot",s),Hs.innerHTML=`

TimePlot failed to start

${String(s)}
`});export{Wo as $,xn as A,J as B,ft as C,et as D,L as E,Nr as F,Ye as G,bi as H,de as I,ga as J,Ma as K,_e as L,I as M,V as N,W as O,Z as P,Oa as Q,Cs as R,dh as S,ke as T,vs as U,Si as V,rs as W,vi as X,Xo as Y,Ue as Z,Y as _,pt as a,Lr as a0,yn as a1,F as a2,O as a3,ja as a4,Sh as a5,mh as a6,Uh as a7,Oh as a8,jh as a9,Zh as aa,Kh as ab,Sn as ac,Nt as ad,$e as ae,lr as af,Nn as ag,Za as ah,Ht as ai,In as aj,Hi as ak,Di as al,dt as am,po as an,fr as ao,Gn as ap,xe as b,He as c,Ws as d,rt as e,zi as f,lh as g,pn as h,Xr as i,ht as j,ln as k,Gs as l,Nh as m,$h as n,Yh as o,qh as p,Ys as q,Ao as r,D as s,nn as t,fo as u,Jh as v,Q as w,it as x,Br as y,at as z};