@annotorious/openseadragon 3.0.0-rc.21 → 3.0.0-rc.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/annotation/pixi/stageRenderer.d.ts +3 -2
- package/dist/annotation/pixi/stageRenderer.d.ts.map +1 -1
- package/dist/annotorious-openseadragon.css +1 -1
- package/dist/annotorious-openseadragon.es.js +2485 -2462
- package/dist/annotorious-openseadragon.es.js.map +1 -1
- package/dist/annotorious-openseadragon.js +34 -34
- package/dist/annotorious-openseadragon.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
(function(Dt,jt){typeof exports=="object"&&typeof module<"u"?jt(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],jt):(Dt=typeof globalThis<"u"?globalThis:Dt||self,jt(Dt.AnnotoriousOSD={},Dt.OpenSeadragon))})(this,function(Dt,jt){"use strict";var CE=Object.defineProperty;var IE=(Dt,jt,hr)=>jt in Dt?CE(Dt,jt,{enumerable:!0,configurable:!0,writable:!0,value:hr}):Dt[jt]=hr;var wl=(Dt,jt,hr)=>(IE(Dt,typeof jt!="symbol"?jt+"":jt,hr),hr);var hr=Object.prototype.hasOwnProperty;function Cr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Cr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(hr.call(r,e)&&++i&&!hr.call(t,e)||!(e in t)||!Cr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var ro=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ro||{});let Es;const Ff=new Uint8Array(16);function Lf(){if(!Es&&(Es=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Es))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Es(Ff)}const $t=[];for(let r=0;r<256;++r)$t.push((r+256).toString(16).slice(1));function Nf(r,t=0){return $t[r[t+0]]+$t[r[t+1]]+$t[r[t+2]]+$t[r[t+3]]+"-"+$t[r[t+4]]+$t[r[t+5]]+"-"+$t[r[t+6]]+$t[r[t+7]]+"-"+$t[r[t+8]]+$t[r[t+9]]+"-"+$t[r[t+10]]+$t[r[t+11]]+$t[r[t+12]]+$t[r[t+13]]+$t[r[t+14]]+$t[r[t+15]]}const Uf=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Rl={randomUUID:Uf};function kf(r,t,e){if(Rl.randomUUID&&!t&&!r)return Rl.randomUUID();r=r||{};const i=r.random||(r.rng||Lf)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return Nf(i)}const Gf=(r,t,e,i)=>({id:kf(),annotation:r.id,created:e||new Date,creator:i,...t}),$f=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},Hf=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Xf=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Cr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Vf=(r,t)=>!Cr(r.target,t.target),zf=(r,t)=>{const e=$f(r,t),i=Hf(r,t),s=Xf(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:Vf(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var cr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r))(cr||{});const Wf=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return zf(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let jf=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const Yf=250,qf=r=>{const t=jf(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>Yf)e.splice(i+1),e.push(p),i=e.length-1;else{const g=e.length-1;e[g]=Wf(e[g],p)}n=m}s=!1};r.observe(o,{origin:cr.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},Kf=(r,t,e,i)=>{const{store:s,selection:n,hover:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const _=l.get(y);_&&_.indexOf(x)>0&&_.splice(_.indexOf(x),1)},p=(y,x,_)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(C=>e.serialize(C)):e.serialize(x),R=_?_ instanceof PointerEvent?_:e.serialize(_):void 0;v(w,R)}else v(x,_)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:_})=>s.getAnnotation(_));x.forEach(_=>{const v=h.find(w=>w.id===_.id);(!v||!Cr(v,_))&&p("updateAnnotation",_,v)}),h=h.map(_=>x.find(({id:w})=>w===_.id)||_)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>s.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const _=s.getAnnotation(x.id);_&&!Cr(_,x)&&p("updateAnnotation",_,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),_=new Set(y.map(({id:v})=>v));h.filter(v=>!_.has(v.id)).forEach(v=>{const w=s.getAnnotation(v.id);w&&!Cr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>_.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>s.getAnnotation(v))]}p("selectionChanged",h)}}),o.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",s.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",s.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",s.getAnnotation(c)),p("mouseEnterAnnotation",s.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>s.getAnnotation(x)))),s.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:_}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(_||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const R=h.find(C=>C.id===v.id)||v;h=h.map(C=>C.id===v.id?w:C),p("updateAnnotation",w,R)})},{origin:cr.LOCAL}),s.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),_=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);_.length>0&&(h=h.map(v=>_.find(R=>R.id===v.id)||v))}},{origin:cr.REMOTE});const g=y=>x=>{const{updated:_}=x;y?(_||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(_||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",g(!0)),t.on("redo",g(!1)),{on:d,off:f,emit:p}},Zf=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Jf=(r,t,e)=>{const{store:i,selection:s}=r,n=g=>{if(e){const{parsed:y,error:x}=e.parse(g);y?i.addAnnotation(y,cr.REMOTE):console.error(x)}else i.addAnnotation(g,cr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=g=>{const y=i.getAnnotation(g);return e&&y?e.serialize(y):y},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var g;const y=(((g=s.selected)==null?void 0:g.map(x=>x.id))||[]).map(x=>i.getAnnotation(x)).filter(Boolean);return e?y.map(e.serialize):y},u=(g,y=!0)=>fetch(g).then(x=>x.json()).then(x=>(f(x,y),x)),d=g=>{if(typeof g=="string"){const y=i.getAnnotation(g);if(i.deleteAnnotation(g),y)return e?e.serialize(y):y}else{const y=e?e.parse(g).parsed:g;if(y)return i.deleteAnnotation(y),g}},f=(g,y=!0)=>{if(e){const{parsed:x,failed:_}=Zf(e)(g);_.length>0&&console.warn(`Discarded ${_.length} invalid annotations`,_),i.bulkAddAnnotation(x,y,cr.REMOTE)}else i.bulkAddAnnotation(g,y,cr.REMOTE)},p=g=>{g?s.setSelected(g):s.clear()},m=g=>{if(e){const y=e.parse(g).parsed,x=e.serialize(i.getAnnotation(y.id));return i.updateAnnotation(y),x}else{const y=i.getAnnotation(g.id);return i.updateAnnotation(g),y}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,undo:t.undo,updateAnnotation:m}},Qf="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let tp=r=>crypto.getRandomValues(new Uint8Array(r)),ep=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},rp=(r,t=21)=>ep(r,t,tp),ip=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Qf[e[r]&63];return t};const sp=()=>({isGuest:!0,id:rp("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),np=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],op=()=>{const r=[...np];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};ip();var ap=Object.defineProperty,lp=(r,t,e)=>t in r?ap(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ml=(r,t,e)=>(lp(r,typeof t!="symbol"?t+"":t,e),e);function At(){}function io(r,t){for(const e in t)r[e]=t[e];return r}function Bl(r){return r()}function Dl(){return Object.create(null)}function Se(r){r.forEach(Bl)}function Nt(r){return typeof r=="function"}function Yt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function hp(r){return Object.keys(r).length===0}function Ol(r,...t){if(r==null){for(const i of t)i(void 0);return At}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Fl(r,t,e){r.$$.on_destroy.push(Ol(t,e))}function cp(r,t,e,i){if(r){const s=Ll(r,t,e,i);return r[0](s)}}function Ll(r,t,e,i){return r[1]&&i?io(e.ctx.slice(),r[1](i(t))):e.ctx}function up(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function dp(r,t,e,i,s,n){if(s){const o=Ll(t,e,i,n);r.p(o,s)}}function fp(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Nl(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Ts(r){return r??""}const pp=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ce(r,t){r.appendChild(t)}function rt(r,t,e){r.insertBefore(t,e||null)}function tt(r){r.parentNode&&r.parentNode.removeChild(r)}function so(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function mt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ul(r){return document.createTextNode(r)}function me(){return Ul(" ")}function Ie(){return Ul("")}function Ot(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function A(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function mp(r){return Array.from(r.childNodes)}function As(r,t,e){r.classList.toggle(t,!!e)}function gp(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Gi;function $i(r){Gi=r}function kl(){if(!Gi)throw new Error("Function called outside component initialization");return Gi}function Hi(r){kl().$$.on_mount.push(r)}function Kr(){const r=kl();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=gp(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ye(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Zr=[],Ss=[];let Jr=[];const Gl=[],yp=Promise.resolve();let no=!1;function _p(){no||(no=!0,yp.then($l))}function oo(r){Jr.push(r)}const ao=new Set;let Qr=0;function $l(){if(Qr!==0)return;const r=Gi;do{try{for(;Qr<Zr.length;){const t=Zr[Qr];Qr++,$i(t),vp(t.$$)}}catch(t){throw Zr.length=0,Qr=0,t}for($i(null),Zr.length=0,Qr=0;Ss.length;)Ss.pop()();for(let t=0;t<Jr.length;t+=1){const e=Jr[t];ao.has(e)||(ao.add(e),e())}Jr.length=0}while(Zr.length);for(;Gl.length;)Gl.pop()();no=!1,ao.clear(),$i(r)}function vp(r){if(r.fragment!==null){r.update(),Se(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(oo)}}function xp(r){const t=[],e=[];Jr.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Jr=t}const Cs=new Set;let Ir;function Pe(){Ir={r:0,c:[],p:Ir}}function Re(){Ir.r||Se(Ir.c),Ir=Ir.p}function ot(r,t){r&&r.i&&(Cs.delete(r),r.i(t))}function pt(r,t,e,i){if(r&&r.o){if(Cs.has(r))return;Cs.add(r),Ir.c.push(()=>{Cs.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ti(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function he(r){r&&r.c()}function ie(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),oo(()=>{const n=r.$$.on_mount.map(Bl).filter(Nt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Se(n),r.$$.on_mount=[]}),s.forEach(oo)}function se(r,t){const e=r.$$;e.fragment!==null&&(xp(e.after_update),Se(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function bp(r,t){r.$$.dirty[0]===-1&&(Zr.push(r),_p(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ce(r,t,e,i,s,n,o=null,a=[-1]){const l=Gi;$i(r);const h=r.$$={fragment:null,ctx:[],props:n,update:At,not_equal:s,bound:Dl(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Dl(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&bp(r,u)),d}):[],h.update(),c=!0,Se(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=mp(t.target);h.fragment&&h.fragment.l(u),u.forEach(tt)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),ie(r,t.target,t.anchor),$l()}$i(l)}class ue{constructor(){Ml(this,"$$"),Ml(this,"$$set")}$destroy(){se(this,1),this.$destroy=At}$on(t,e){if(!Nt(e))return At;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!hp(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const wp="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(wp);var bt=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(bt||{});const lo={},ho=(r,t)=>lo[r]=t,co=r=>lo[r.type].area(r),Ep=(r,t,e)=>lo[r.type].intersects(r,t,e),Is=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Tp={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};ho(bt.ELLIPSE,Tp);const Ap={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};ho(bt.POLYGON,Ap);const Sp={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};ho(bt.RECTANGLE,Sp);const Cp=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,c,u]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,m]=[l,h,c,u].map(parseFloat);return{type:bt.RECTANGLE,geometry:{x:d,y:f,w:p,h:m,bounds:{minX:d,minY:t?f-m:f,maxX:d+p,maxY:t?f:f+m}}}},Ip=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},Hl="http://www.w3.org/2000/svg",Xl=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Pp=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Hl}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Rp=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Hl),i=t.lookupNamespaceURI(null);return e||i?Xl(t).firstChild:Xl(Pp(t)).firstChild},Mp=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:bt.POLYGON,geometry:{points:s,bounds:Is(s)}}},Bp=r=>{const t=Rp(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:bt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},Dp=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return Mp(t);if(t.includes("<ellipse "))return Bp(t);throw"Unsupported SVG shape: "+t},Op=r=>{let t;if(r.type===bt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===bt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`};let Ps;const Fp=new Uint8Array(16);function Lp(){if(!Ps&&(Ps=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ps))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ps(Fp)}const Ht=[];for(let r=0;r<256;++r)Ht.push((r+256).toString(16).slice(1));function Np(r,t=0){return Ht[r[t+0]]+Ht[r[t+1]]+Ht[r[t+2]]+Ht[r[t+3]]+"-"+Ht[r[t+4]]+Ht[r[t+5]]+"-"+Ht[r[t+6]]+Ht[r[t+7]]+"-"+Ht[r[t+8]]+Ht[r[t+9]]+"-"+Ht[r[t+10]]+Ht[r[t+11]]+Ht[r[t+12]]+Ht[r[t+13]]+Ht[r[t+14]]+Ht[r[t+15]]}const Up=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Vl={randomUUID:Up};function zl(r,t,e){if(Vl.randomUUID&&!t&&!r)return Vl.randomUUID();r=r||{};const i=r.random||(r.rng||Lp)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return Np(i)}var Wl=Object.prototype.hasOwnProperty;function Pr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Pr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Wl.call(r,e)&&++i&&!Wl.call(t,e)||!(e in t)||!Pr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function uo(){}function kp(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const ei=[];function fo(r,t=uo){let e;const i=new Set;function s(a){if(kp(r,a)&&(r=a,e)){const l=!ei.length;for(const h of i)h[1](),ei.push(h,r);if(l){for(let h=0;h<ei.length;h+=2)ei[h][0](ei[h+1]);ei.length=0}}}function n(a){s(a(r))}function o(a,l=uo){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||uo),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Gp=r=>{const{subscribe:t,set:e}=fo();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var jl=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(jl||{});const po={selected:[]},$p=(r,t="EDIT")=>{const{subscribe:e,set:i}=fo(po);let s=po;e(u=>s=u);const n=()=>i(po),o=()=>{var u;return((u=s.selected)==null?void 0:u.length)===0},a=u=>{if(s.selected.length===0)return!1;const d=typeof u=="string"?u:u.id;return s.selected.some(f=>f.id===d)},l=(u,d)=>{const f=r.getAnnotation(u);if(f){const p=Hp(f,t);i(p==="EDIT"?{selected:[{id:u,editable:!0}],pointerEvent:d}:p==="SELECT"?{selected:[{id:u}],pointerEvent:d}:{selected:[],pointerEvent:d})}else console.warn("Invalid selection: "+u)},h=(u,d=!0)=>{const f=Array.isArray(u)?u:[u],p=f.map(m=>r.getAnnotation(m)).filter(Boolean);i({selected:p.map(({id:m})=>({id:m,editable:d}))}),p.length!==f.length&&console.warn("Invalid selection",u)},c=u=>{if(s.selected.length===0)return!1;const{selected:d}=s;d.filter(({id:f})=>u.includes(f)).length>0&&i({selected:d.filter(({id:f})=>!u.includes(f))})};return r.observe(({changes:u})=>c((u.deleted||[]).map(d=>d.id))),{clear:n,clickSelect:l,get selected(){return s?[...s.selected]:null},get pointerEvent(){return s?s.pointerEvent:null},isEmpty:o,isSelected:a,setSelected:h,subscribe:e}},Hp=(r,t)=>typeof t=="function"?t(r)||"EDIT":t||"EDIT",Xp=[];for(let r=0;r<256;++r)Xp.push((r+256).toString(16).slice(1));typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Vp=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},zp=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Wp=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Pr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),jp=(r,t)=>!Pr(r.target,t.target),Yl=(r,t)=>{const e=Vp(r,t),i=zp(r,t),s=Wp(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:jp(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Pt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r))(Pt||{});const Yp=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(!r.options.origin||r.options.origin===n))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},qp=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return Yl(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},Kp=r=>r.id!==void 0,Zp=()=>{const r=new Map,t=new Map,e=[],i=(b,T={})=>e.push({onChange:b,options:T}),s=b=>{const T=e.findIndex(I=>I.onChange==b);T>-1&&e.splice(T,1)},n=(b,T)=>{const I={origin:b,changes:{created:T.created||[],updated:T.updated||[],deleted:T.deleted||[]},state:[...r.values()]};e.forEach(O=>{Yp(O,I)&&O.onChange(I)})},o=(b,T=Pt.LOCAL)=>{if(r.get(b.id))throw Error(`Cannot add annotation ${b.id} - exists already`);r.set(b.id,b),b.bodies.forEach(I=>t.set(I.id,b.id)),n(T,{created:[b]})},a=(b,T)=>{const I=typeof b=="string"?T:b,O=typeof b=="string"?b:b.id,M=r.get(O);if(M){const E=Yl(M,I);return O===I.id?r.set(O,I):(r.delete(O),r.set(I.id,I)),M.bodies.forEach(S=>t.delete(S.id)),I.bodies.forEach(S=>t.set(S.id,I.id)),E}else console.warn(`Cannot update annotation ${O} - does not exist`)},l=(b,T=Pt.LOCAL,I=Pt.LOCAL)=>{const O=Kp(T)?I:T,M=a(b,T);M&&n(O,{updated:[M]})},h=(b,T=Pt.LOCAL)=>{const I=b.reduce((O,M)=>{const E=a(M);return E?[...O,E]:O},[]);I.length>0&&n(T,{updated:I})},c=(b,T=Pt.LOCAL)=>{const I=r.get(b.annotation);if(I){const O={...I,bodies:[...I.bodies,b]};r.set(I.id,O),t.set(b.id,O.id),n(T,{updated:[{oldValue:I,newValue:O,bodiesCreated:[b]}]})}else console.warn(`Attempt to add body to missing annotation: ${b.annotation}`)},u=()=>[...r.values()],d=(b=Pt.LOCAL)=>{const T=[...r.values()];r.clear(),t.clear(),n(b,{deleted:T})},f=(b,T=!0,I=Pt.LOCAL)=>{if(T){const O=[...r.values()];r.clear(),t.clear(),b.forEach(M=>{r.set(M.id,M),M.bodies.forEach(E=>t.set(E.id,M.id))}),n(I,{created:b,deleted:O})}else{const O=b.reduce((M,E)=>{const S=r.get(E.id);return S?[...M,S]:M},[]);if(O.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${O.map(M=>M.id).join(", ")}`);b.forEach(M=>{r.set(M.id,M),M.bodies.forEach(E=>t.set(E.id,M.id))}),n(I,{created:b})}},p=b=>{const T=typeof b=="string"?b:b.id,I=r.get(T);if(I)return r.delete(T),I.bodies.forEach(O=>t.delete(O.id)),I;console.warn(`Attempt to delete missing annotation: ${T}`)},m=(b,T=Pt.LOCAL)=>{const I=p(b);I&&n(T,{deleted:[I]})},g=(b,T=Pt.LOCAL)=>{const I=b.reduce((O,M)=>{const E=p(M);return E?[...O,E]:O},[]);I.length>0&&n(T,{deleted:I})},y=(b,T=Pt.LOCAL)=>{const I=r.get(b.annotation);if(I){const O=I.bodies.find(M=>M.id===b.id);if(O){t.delete(O.id);const M={...I,bodies:I.bodies.filter(E=>E.id!==b.id)};r.set(I.id,M),n(T,{updated:[{oldValue:I,newValue:M,bodiesDeleted:[O]}]})}else console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${b.annotation}`)},x=b=>{const T=r.get(b);return T?{...T}:void 0},_=b=>{const T=t.get(b);if(T){const I=x(T).bodies.find(O=>O.id===b);if(I)return I;console.error(`Store integrity error: body ${b} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${b}`)},v=(b,T)=>{if(b.annotation!==T.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const I=r.get(b.annotation);if(I){const O=I.bodies.find(E=>E.id===b.id),M={...I,bodies:I.bodies.map(E=>E.id===O.id?T:E)};return r.set(I.id,M),O.id!==T.id&&(t.delete(O.id),t.set(T.id,M.id)),{oldValue:I,newValue:M,bodiesUpdated:[{oldBody:O,newBody:T}]}}else console.warn(`Attempt to add body to missing annotation ${b.annotation}`)},w=(b,T,I=Pt.LOCAL)=>{const O=v(b,T);O&&n(I,{updated:[O]})},R=(b,T=Pt.LOCAL)=>{const I=b.map(O=>v({id:O.id,annotation:O.annotation},O)).filter(Boolean);n(T,{updated:I})},C=b=>{const T=r.get(b.annotation);if(T){const I={...T,target:{...T.target,...b}};return r.set(T.id,I),{oldValue:T,newValue:I,targetUpdated:{oldTarget:T.target,newTarget:b}}}else console.warn(`Attempt to update target on missing annotation: ${b.annotation}`)};return{addAnnotation:o,addBody:c,all:u,bulkAddAnnotation:f,bulkDeleteAnnotation:g,bulkUpdateAnnotation:h,bulkUpdateBodies:R,bulkUpdateTargets:(b,T=Pt.LOCAL)=>{const I=b.map(O=>C(O)).filter(Boolean);I.length>0&&n(T,{updated:I})},clear:d,deleteAnnotation:m,deleteBody:y,getAnnotation:x,getBody:_,observe:i,unobserve:s,updateAnnotation:l,updateBody:w,updateTarget:(b,T=Pt.LOCAL)=>{const I=C(b);I&&n(T,{updated:[I]})}}},Jp=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let Qp=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const tm=250,em=r=>{const t=Qp(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>tm)e.splice(i+1),e.push(p),i=e.length-1;else{const g=e.length-1;e[g]=qp(e[g],p)}n=m}s=!1};r.observe(o,{origin:Pt.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},rm=()=>{const{subscribe:r,set:t}=fo([]);return{subscribe:r,set:t}},im=(r,t,e,i)=>{const{store:s,selection:n,hover:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,x)=>{l.has(y)?l.get(y).push(x):l.set(y,[x])},f=(y,x)=>{const _=l.get(y);_&&_.indexOf(x)>0&&_.splice(_.indexOf(x),1)},p=(y,x,_)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(v=>{if(e){const w=Array.isArray(x)?x.map(C=>e.serialize(C)):e.serialize(x),R=_?_ instanceof PointerEvent?_:e.serialize(_):void 0;v(w,R)}else v(x,_)})},1)},m=()=>{const{selected:y}=n,x=(y||[]).map(({id:_})=>s.getAnnotation(_));x.forEach(_=>{const v=h.find(w=>w.id===_.id);(!v||!Pr(v,_))&&p("updateAnnotation",_,v)}),h=h.map(_=>x.find(({id:v})=>v===_.id)||_)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:x})=>s.getAnnotation(x));else if(h.length>0&&y.length===0)h.forEach(x=>{const _=s.getAnnotation(x.id);_&&!Pr(_,x)&&p("updateAnnotation",_,x)}),h=[];else{const x=new Set(h.map(v=>v.id)),_=new Set(y.map(({id:v})=>v));h.filter(v=>!_.has(v.id)).forEach(v=>{const w=s.getAnnotation(v.id);w&&!Pr(w,v)&&p("updateAnnotation",w,v)}),h=[...h.filter(v=>_.has(v.id)),...y.filter(({id:v})=>!x.has(v)).map(({id:v})=>s.getAnnotation(v))]}p("selectionChanged",h)}}),o.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",s.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",s.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",s.getAnnotation(c)),p("mouseEnterAnnotation",s.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(x=>s.getAnnotation(x)))),s.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:x,deleted:_}=y.changes;(x||[]).forEach(v=>p("createAnnotation",v)),(_||[]).forEach(v=>p("deleteAnnotation",v)),(y.changes.updated||[]).filter(v=>[...v.bodiesCreated||[],...v.bodiesDeleted||[],...v.bodiesUpdated||[]].length>0).forEach(({oldValue:v,newValue:w})=>{const R=h.find(C=>C.id===v.id)||v;h=h.map(C=>C.id===v.id?w:C),p("updateAnnotation",w,R)})},{origin:Pt.LOCAL}),s.observe(y=>{if(h){const x=new Set(h.map(v=>v.id)),_=(y.changes.updated||[]).filter(({newValue:v})=>x.has(v.id)).map(({newValue:v})=>v);_.length>0&&(h=h.map(v=>_.find(w=>w.id===v.id)||v))}},{origin:Pt.REMOTE});const g=y=>x=>{const{updated:_}=x;y?(_||[]).forEach(v=>p("updateAnnotation",v.oldValue,v.newValue)):(_||[]).forEach(v=>p("updateAnnotation",v.newValue,v.oldValue))};return t.on("undo",g(!0)),t.on("redo",g(!1)),{on:d,off:f,emit:p}},sm=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),nm=(r,t,e)=>{const{store:i,selection:s}=r,n=g=>{if(e){const{parsed:y,error:x}=e.parse(g);y?i.addAnnotation(y,Pt.REMOTE):console.error(x)}else i.addAnnotation(g,Pt.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=g=>{const y=i.getAnnotation(g);return e&&y?e.serialize(y):y},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var g;const y=(((g=s.selected)==null?void 0:g.map(x=>x.id))||[]).map(x=>i.getAnnotation(x)).filter(Boolean);return e?y.map(e.serialize):y},u=(g,y=!0)=>fetch(g).then(x=>x.json()).then(x=>(f(x,y),x)),d=g=>{if(typeof g=="string"){const y=i.getAnnotation(g);if(i.deleteAnnotation(g),y)return e?e.serialize(y):y}else{const y=e?e.parse(g).parsed:g;if(y)return i.deleteAnnotation(y),g}},f=(g,y=!0)=>{if(e){const{parsed:x,failed:_}=sm(e)(g);_.length>0&&console.warn(`Discarded ${_.length} invalid annotations`,_),i.bulkAddAnnotation(x,y,Pt.REMOTE)}else i.bulkAddAnnotation(g,y,Pt.REMOTE)},p=g=>{g?s.setSelected(g):s.clear()},m=g=>{if(e){const y=e.parse(g).parsed,x=e.serialize(i.getAnnotation(y.id));return i.updateAnnotation(y),x}else{const y=i.getAnnotation(g.id);return i.updateAnnotation(g),y}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,undo:t.undo,updateAnnotation:m}},om="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let am=r=>crypto.getRandomValues(new Uint8Array(r)),lm=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},hm=(r,t=21)=>lm(r,t,am),cm=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=om[e[r]&63];return t};const um=()=>({isGuest:!0,id:hm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),dm=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},ql=r=>r?typeof r=="object"?{...r}:r:void 0,fm=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,creator:l,...h}=e;return{id:i||`temp-${dm(e)}`,annotation:t,type:s,purpose:n,value:o,created:a?new Date(a):void 0,creator:ql(l),...h}}),pm=r=>r.map(t=>{var e,i;const s={...t};return delete s.annotation,(e=s.id)!=null&&e.startsWith("temp-")&&delete s.id,{...s,created:(i=s.created)==null?void 0:i.toISOString()}});cm();const mm=(r,t=!1)=>({parse:e=>gm(e,t),serialize:e=>ym(e,r)}),gm=(r,t=!1)=>{const e=r.id||zl(),{creator:i,created:s,modified:n,body:o,...a}=r,l=fm(o,e),h=Array.isArray(r.target)?r.target[0]:r.target,c=Array.isArray(h.selector)?h.selector[0]:h.selector,u=(c==null?void 0:c.type)==="FragmentSelector"?Cp(c,t):(c==null?void 0:c.type)==="SvgSelector"?Dp(c):void 0;return u?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:ql(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:u}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},ym=(r,t)=>{const{selector:e,creator:i,created:s,updated:n,updatedBy:o,...a}=r.target,l=e.type==bt.RECTANGLE?Ip(e.geometry):Op(e),h={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:pm(r.bodies),created:s==null?void 0:s.toISOString(),creator:i,modified:n==null?void 0:n.toISOString(),target:{...a,source:t,selector:l}};return delete h.bodies,"annotation"in h.target&&delete h.target.annotation,h};function Kl(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Zl(r){let t,e;return t=new Xi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Nt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function _m(r){let t,e,i,s,n,o,a,l,h,c,u,d=ti(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=Zl(Kl(r,d,m));const p=m=>pt(f[m],1,1,()=>{f[m]=null});return{c(){t=mt("polygon"),s=me(),n=mt("polygon"),a=me();for(let m=0;m<f.length;m+=1)f[m].c();l=Ie(),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"points",i=r[4].points.map(Jl).join(" ")),A(n,"class","a9s-inner a9s-shape-handle"),A(n,"style",r[1]),A(n,"points",o=r[4].points.map(Ql).join(" "))},m(m,g){rt(m,t,g),rt(m,s,g),rt(m,n,g),rt(m,a,g);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,g);rt(m,l,g),h=!0,c||(u=[Ot(t,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(n,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,g){if(r=m,(!h||g&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!h||g&16&&i!==(i=r[4].points.map(Jl).join(" ")))&&A(t,"points",i),(!h||g&2)&&A(n,"style",r[1]),(!h||g&16&&o!==(o=r[4].points.map(Ql).join(" ")))&&A(n,"points",o),g&536){d=ti(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=Kl(r,d,y);f[y]?(f[y].p(x,g),ot(f[y],1)):(f[y]=Zl(x),f[y].c(),ot(f[y],1),f[y].m(l.parentNode,l))}for(Pe(),y=d.length;y<f.length;y+=1)p(y);Re()}},i(m){if(!h){for(let g=0;g<d.length;g+=1)ot(f[g]);h=!0}},o(m){f=f.filter(Boolean);for(let g=0;g<f.length;g+=1)pt(f[g]);h=!1},d(m){m&&(tt(t),tt(s),tt(n),tt(a),tt(l)),so(f,m),c=!1,Se(u)}}}function vm(r){let t,e;return t=new nh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[_m,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}const Jl=r=>r.join(","),Ql=r=>r.join(",");function xm(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const g=d.geometry;f==="SHAPE"?m=g.points.map(([x,_])=>[x+p[0],_+p[1]]):m=g.points.map(([x,_],v)=>f===`HANDLE-${v}`?[x+p[0],_+p[1]]:[x,_]);const y=Is(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ye.call(this,r,d)}function c(d){Ye.call(this,r,d)}function u(d){Ye.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class bm extends ue{constructor(t){super(),ce(this,t,xm,vm,Yt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const mo=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},ri=[];function wm(r,t=At){let e;const i=new Set;function s(a){if(Yt(r,a)&&(r=a,e)){const l=!ri.length;for(const h of i)h[1](),ri.push(h,r);if(l){for(let h=0;h<ri.length;h+=2)ri[h][0](ri[h+1]);ri.length=0}}}function n(a){s(a(r))}function o(a,l=At){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||At),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Em=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},Tm=(r,t)=>{Em(r,t);const{subscribe:e,set:i}=wm(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},th="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Am(r){let t,e,i,s,n,o;return{c(){t=mt("rect"),A(t,"class",e=Ts(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(t,"x",i=r[0]-r[5]/2),A(t,"y",s=r[1]-r[5]/2),A(t,"width",r[5]),A(t,"height",r[5])},m(a,l){rt(a,t,l),n||(o=Ot(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Ts(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&A(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&A(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&A(t,"y",s),l&32&&A(t,"width",a[5]),l&32&&A(t,"height",a[5])},d(a){a&&tt(t),n=!1,o()}}}function Sm(r){let t,e,i,s,n,o,a,l,h;return{c(){t=mt("g"),e=mt("circle"),s=mt("rect"),A(e,"cx",r[0]),A(e,"cy",r[1]),A(e,"r",i=r[3]/r[2]),A(e,"class","a9s-touch-halo svelte-1sgkh33"),As(e,"touched",r[4]),A(s,"class",n=Ts(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(s,"x",o=r[0]-r[5]/2),A(s,"y",a=r[1]-r[5]/2),A(s,"width",r[5]),A(s,"height",r[5]),A(t,"class","a9s-touch-handle")},m(c,u){rt(c,t,u),Ce(t,e),Ce(t,s),l||(h=[Ot(e,"pointerdown",r[10]),Ot(e,"pointerdown",r[6]),Ot(e,"pointerup",r[7]),Ot(s,"pointerdown",r[9]),Ot(s,"pointerdown",r[6]),Ot(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&A(e,"cx",c[0]),u&2&&A(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&A(e,"r",i),u&16&&As(e,"touched",c[4]),u&256&&n!==(n=Ts(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&A(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&A(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&A(s,"y",a),u&32&&A(s,"width",c[5]),u&32&&A(s,"height",c[5])},d(c){c&&tt(t),l=!1,Se(h)}}}function Cm(r){let t;function e(s,n){return th?Sm:Am}let i=e()(r);return{c(){i.c(),t=Ie()},m(s,n){i.m(s,n),rt(s,t,n)},p(s,[n]){i.p(s,n)},i:At,o:At,d(s){s&&tt(t),i.d(s)}}}function Im(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){Ye.call(this,r,p)}function d(p){Ye.call(this,r,p)}function f(p){Ye.call(this,r,p)}return r.$$set=p=>{e(8,t=io(io({},t),Nl(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Nl(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class Xi extends ue{constructor(t){super(),ce(this,t,Im,Cm,Yt,{x:0,y:1,scale:2,radius:3})}}function Pm(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g,y,x,_,v,w,R,C,b,T,I,O,M,E,S,L,k,G,H,X,D,F,j,nt,Q,V,_t,Tt;return H=new Xi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),H.$on("pointerdown",function(){Nt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),D=new Xi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),D.$on("pointerdown",function(){Nt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new Xi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){Nt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new Xi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){Nt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=mt("rect"),a=me(),l=mt("rect"),f=me(),p=mt("rect"),x=me(),_=mt("rect"),C=me(),b=mt("rect"),M=me(),E=mt("rect"),G=me(),he(H.$$.fragment),X=me(),he(D.$$.fragment),F=me(),he(j.$$.fragment),nt=me(),he(Q.$$.fragment),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"x",i=r[4].x),A(t,"y",s=r[4].y),A(t,"width",n=r[4].w),A(t,"height",o=r[4].h),A(l,"class","a9s-inner a9s-shape-handle"),A(l,"style",r[1]),A(l,"x",h=r[4].x),A(l,"y",c=r[4].y),A(l,"width",u=r[4].w),A(l,"height",d=r[4].h),A(p,"class","a9s-edge-handle a9s-edge-handle-top"),A(p,"x",m=r[4].x),A(p,"y",g=r[4].y),A(p,"height",1),A(p,"width",y=r[4].w),A(_,"class","a9s-edge-handle a9s-edge-handle-right"),A(_,"x",v=r[4].x+r[4].w),A(_,"y",w=r[4].y),A(_,"height",R=r[4].h),A(_,"width",1),A(b,"class","a9s-edge-handle a9s-edge-handle-bottom"),A(b,"x",T=r[4].x),A(b,"y",I=r[4].y+r[4].h),A(b,"height",1),A(b,"width",O=r[4].w),A(E,"class","a9s-edge-handle a9s-edge-handle-left"),A(E,"x",S=r[4].x),A(E,"y",L=r[4].y),A(E,"height",k=r[4].h),A(E,"width",1)},m(N,B){rt(N,t,B),rt(N,a,B),rt(N,l,B),rt(N,f,B),rt(N,p,B),rt(N,x,B),rt(N,_,B),rt(N,C,B),rt(N,b,B),rt(N,M,B),rt(N,E,B),rt(N,G,B),ie(H,N,B),rt(N,X,B),ie(D,N,B),rt(N,F,B),ie(j,N,B),rt(N,nt,B),ie(Q,N,B),V=!0,_t||(Tt=[Ot(t,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(l,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(p,"pointerdown",function(){Nt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Ot(_,"pointerdown",function(){Nt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Ot(b,"pointerdown",function(){Nt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Ot(E,"pointerdown",function(){Nt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(N,B){r=N,(!V||B&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!V||B&16&&i!==(i=r[4].x))&&A(t,"x",i),(!V||B&16&&s!==(s=r[4].y))&&A(t,"y",s),(!V||B&16&&n!==(n=r[4].w))&&A(t,"width",n),(!V||B&16&&o!==(o=r[4].h))&&A(t,"height",o),(!V||B&2)&&A(l,"style",r[1]),(!V||B&16&&h!==(h=r[4].x))&&A(l,"x",h),(!V||B&16&&c!==(c=r[4].y))&&A(l,"y",c),(!V||B&16&&u!==(u=r[4].w))&&A(l,"width",u),(!V||B&16&&d!==(d=r[4].h))&&A(l,"height",d),(!V||B&16&&m!==(m=r[4].x))&&A(p,"x",m),(!V||B&16&&g!==(g=r[4].y))&&A(p,"y",g),(!V||B&16&&y!==(y=r[4].w))&&A(p,"width",y),(!V||B&16&&v!==(v=r[4].x+r[4].w))&&A(_,"x",v),(!V||B&16&&w!==(w=r[4].y))&&A(_,"y",w),(!V||B&16&&R!==(R=r[4].h))&&A(_,"height",R),(!V||B&16&&T!==(T=r[4].x))&&A(b,"x",T),(!V||B&16&&I!==(I=r[4].y+r[4].h))&&A(b,"y",I),(!V||B&16&&O!==(O=r[4].w))&&A(b,"width",O),(!V||B&16&&S!==(S=r[4].x))&&A(E,"x",S),(!V||B&16&&L!==(L=r[4].y))&&A(E,"y",L),(!V||B&16&&k!==(k=r[4].h))&&A(E,"height",k);const xt={};B&16&&(xt.x=r[4].x),B&16&&(xt.y=r[4].y),B&8&&(xt.scale=r[3]),H.$set(xt);const ft={};B&16&&(ft.x=r[4].x+r[4].w),B&16&&(ft.y=r[4].y),B&8&&(ft.scale=r[3]),D.$set(ft);const gt={};B&16&&(gt.x=r[4].x+r[4].w),B&16&&(gt.y=r[4].y+r[4].h),B&8&&(gt.scale=r[3]),j.$set(gt);const yt={};B&16&&(yt.x=r[4].x),B&16&&(yt.y=r[4].y+r[4].h),B&8&&(yt.scale=r[3]),Q.$set(yt)},i(N){V||(ot(H.$$.fragment,N),ot(D.$$.fragment,N),ot(j.$$.fragment,N),ot(Q.$$.fragment,N),V=!0)},o(N){pt(H.$$.fragment,N),pt(D.$$.fragment,N),pt(j.$$.fragment,N),pt(Q.$$.fragment,N),V=!1},d(N){N&&(tt(t),tt(a),tt(l),tt(f),tt(p),tt(x),tt(_),tt(C),tt(b),tt(M),tt(E),tt(G),tt(X),tt(F),tt(nt)),se(H,N),se(D,N),se(j,N),se(Q,N),_t=!1,Se(Tt)}}}function Rm(r){let t,e;return t=new nh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Pm,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function Mm(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[g,y]=[m.minX,m.minY],[x,_]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")g+=v,x+=v,y+=w,_+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{_+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const R=Math.min(g,x),C=Math.min(y,_),b=Math.abs(x-g),T=Math.abs(_-y);return{...d,geometry:{x:R,y:C,w:b,h:T,bounds:{minX:R,minY:C,maxX:R+b,maxY:C+T}}}};function h(d){Ye.call(this,r,d)}function c(d){Ye.call(this,r,d)}function u(d){Ye.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Bm extends ue{constructor(t){super(),ce(this,t,Mm,Rm,Yt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const eh=new Map([[bt.RECTANGLE,Bm],[bt.POLYGON,bm]]),rh=r=>eh.get(r.type),ih=(r,t)=>eh.set(r,t),Dm=r=>({}),sh=r=>({grab:r[0]});function Om(r){let t,e,i,s;const n=r[7].default,o=cp(n,r,r[6],sh);return{c(){t=mt("g"),o&&o.c(),A(t,"class","a9s-annotation selected")},m(a,l){rt(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Ot(t,"pointerup",r[2]),Ot(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&dp(o,n,a,a[6],e?up(n,a[6],l,Dm):fp(a[6]),sh)},i(a){e||(ot(o,a),e=!0)},o(a){pt(o,a),e=!1},d(a){a&&tt(t),o&&o.d(a),i=!1,Se(s)}}}function Fm(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Kr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>g=>{h=m,c=l.elementToImage(g.offsetX,g.offsetY),u=o,g.target.setPointerCapture(g.pointerId),n("grab",g)},f=m=>{if(h){const[g,y]=l.elementToImage(m.offsetX,m.offsetY),x=[g-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class nh extends ue{constructor(t){super(),ce(this,t,Fm,Om,Yt,{shape:3,editor:4,transform:5})}}const Rs=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s}=e;let n="";return i&&(n+=`fill:${i};stroke:${i};`),n+=`fill-opacity:${s||"0.25"};`,n}};function Lm(r,t,e){let i;const s=Kr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Hi(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&(i=Rs(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c})},[n,o,a,l,h,c,u]}class Nm extends ue{constructor(t){super(),ce(this,t,Lm,null,Yt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function Um(r,t,e){const i=Kr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return Hi(()=>{const c=n.closest("svg"),u=[],d=(f,p,m)=>{c==null||c.addEventListener(f,p,m),u.push(()=>c==null?void 0:c.removeEventListener(f,p,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class km extends ue{constructor(t){super(),ce(this,t,Um,null,Yt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function oh(r){let t,e;return{c(){t=mt("rect"),e=mt("rect"),A(t,"class","a9s-outer"),A(t,"x",r[1]),A(t,"y",r[2]),A(t,"width",r[3]),A(t,"height",r[4]),A(e,"class","a9s-inner"),A(e,"x",r[1]),A(e,"y",r[2]),A(e,"width",r[3]),A(e,"height",r[4])},m(i,s){rt(i,t,s),rt(i,e,s)},p(i,s){s&2&&A(t,"x",i[1]),s&4&&A(t,"y",i[2]),s&8&&A(t,"width",i[3]),s&16&&A(t,"height",i[4]),s&2&&A(e,"x",i[1]),s&4&&A(e,"y",i[2]),s&8&&A(e,"width",i[3]),s&16&&A(e,"height",i[4])},d(i){i&&(tt(t),tt(e))}}}function Gm(r){let t,e=r[0]&&oh(r);return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){rt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=oh(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&tt(t),e&&e.d()}}}function $m(r,t,e){const i=Kr();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,c,u,d,f;const p=x=>{const _=x;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(_.offsetX,_.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))},m=x=>{const _=x;l&&(h=o.elementToImage(_.offsetX,_.offsetY),e(1,c=Math.min(h[0],l[0])),e(2,u=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,f=Math.abs(h[1]-l[1])))},g=x=>{const _=x,v=performance.now()-a;if(n==="click"){if(v>300)return;_.stopPropagation(),l?y():(e(0,l=o.elementToImage(_.offsetX,_.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))}else l&&(v>300||d*f>100?(_.stopPropagation(),y()):(e(0,l=void 0),h=void 0))},y=()=>{if(d*f>15){const x={type:bt.RECTANGLE,geometry:{bounds:{minX:c,minY:u,maxX:c+d,maxY:u+f},x:c,y:u,w:d,h:f}};i("create",x)}e(0,l=void 0),h=void 0};return Hi(()=>{s("pointerdown",p),s("pointermove",m),s("pointerup",g,!0)}),r.$$set=x=>{"addEventListener"in x&&e(5,s=x.addEventListener),"drawingMode"in x&&e(6,n=x.drawingMode),"transform"in x&&e(7,o=x.transform)},[l,c,u,d,f,s,n,o]}class Hm extends ue{constructor(t){super(),ce(this,t,$m,Gm,Yt,{addEventListener:5,drawingMode:6,transform:7})}}function go(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function ah(r){let t,e,i,s,n,o=r[2]&&lh(r);return{c(){t=mt("polygon"),i=mt("polygon"),o&&o.c(),n=Ie(),A(t,"class","a9s-outer"),A(t,"points",e=r[16]),A(i,"class","a9s-inner"),A(i,"points",s=r[16])},m(a,l){rt(a,t,l),rt(a,i,l),o&&o.m(a,l),rt(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&A(t,"points",e),l&7&&s!==(s=a[16])&&A(i,"points",s),a[2]?o?o.p(a,l):(o=lh(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(tt(t),tt(i),tt(n)),o&&o.d(a)}}}function lh(r){let t,e,i;return{c(){t=mt("rect"),A(t,"class","a9s-corner-handle"),A(t,"x",e=r[0][0][0]-r[3]/2),A(t,"y",i=r[0][0][1]-r[3]/2),A(t,"height",r[3]),A(t,"width",r[3])},m(s,n){rt(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&A(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&A(t,"y",i),n&8&&A(t,"height",s[3]),n&8&&A(t,"width",s[3])},d(s){s&&tt(t)}}}function Xm(r){let t,e=r[1]&&ah(go(r));return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){rt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(go(i),s):(e=ah(go(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&tt(t),e&&e.d()}}}const Vm=20,zm=1500;function Wm(r,t,e){let i;const s=Kr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c=[],u,d,f=!1;const p=_=>{const v=_,{timeStamp:w,offsetX:R,offsetY:C}=v;if(h={timeStamp:w,offsetX:R,offsetY:C},o==="drag"&&c.length===0){const b=a.elementToImage(v.offsetX,v.offsetY);c.push(b),e(1,u=b)}},m=_=>{const v=_;if(d&&clearTimeout(d),c.length>0){if(e(1,u=a.elementToImage(v.offsetX,v.offsetY)),c.length>2){const w=mo(u,c[0])*l;e(2,f=w<Vm)}v.pointerType==="touch"&&(d=setTimeout(()=>{y()},zm))}},g=_=>{const v=_;if(d&&clearTimeout(d),o==="click"){const w=v.timeStamp-h.timeStamp,R=mo([h.offsetX,h.offsetY],[v.offsetX,v.offsetY]);if(w>300||R>15)return;if(f)x();else if(c.length===0){const C=a.elementToImage(v.offsetX,v.offsetY);c.push(C),e(1,u=C)}else c.push(u)}else{if(c.length===1&&mo(c[0],u)<=4){e(0,c=[]),e(1,u=void 0);return}v.stopImmediatePropagation(),f?x():c.push(u)}},y=()=>{if(!u)return;const _=[...c,u],v={type:bt.POLYGON,geometry:{bounds:Is(_),points:_}};co(v)>4&&(e(0,c=[]),e(1,u=void 0),s("create",v))},x=()=>{const _={type:bt.POLYGON,geometry:{bounds:Is(c),points:[...c]}};e(0,c=[]),e(1,u=void 0),s("create",_)};return Hi(()=>{n("pointerdown",p,!0),n("pointermove",m),n("pointerup",g,!0),n("dblclick",y,!0)}),r.$$set=_=>{"addEventListener"in _&&e(4,n=_.addEventListener),"drawingMode"in _&&e(5,o=_.drawingMode),"transform"in _&&e(6,a=_.transform),"viewportScale"in _&&e(7,l=_.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[c,u,f,i,n,o,a,l]}class jm extends ue{constructor(t){super(),ce(this,t,Wm,Xm,Yt,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const yo=new Map([["rectangle",{tool:Hm}],["polygon",{tool:jm}]]),Ms=()=>[...yo.keys()],Bs=r=>yo.get(r),hh=(r,t,e)=>yo.set(r,{tool:t,opts:e});function Ym(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("ellipse"),s=mt("ellipse"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"cx",r[2]),A(e,"cy",r[3]),A(e,"rx",r[4]),A(e,"ry",r[5]),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"cx",r[2]),A(s,"cy",r[3]),A(s,"rx",r[4]),A(s,"ry",r[5]),A(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),Ce(t,e),Ce(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:At,o:At,d(o){o&&tt(t)}}}function qm(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=n;return r.$$set=u=>{"annotation"in u&&e(0,s=u.annotation),"geom"in u&&e(6,n=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Rs(s,o))},[s,i,a,l,h,c,n,o]}class Km extends ue{constructor(t){super(),ce(this,t,qm,Ym,Yt,{annotation:0,geom:6,style:7})}}function Zm(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("polygon"),s=mt("polygon"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"points",r[2].map(Jm).join(" ")),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"points",r[2].map(Qm).join(" ")),A(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),Ce(t,e),Ce(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:At,o:At,d(o){o&&tt(t)}}}const Jm=r=>r.join(","),Qm=r=>r.join(",");function tg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Rs(s,o))},[s,i,a,n,o]}class eg extends ue{constructor(t){super(),ce(this,t,tg,Zm,Yt,{annotation:0,geom:3,style:4})}}function rg(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("rect"),s=mt("rect"),A(e,"class","a9s-outer"),A(e,"style",i=r[5]?"display:none;":void 0),A(e,"x",r[4]),A(e,"y",r[3]),A(e,"width",r[2]),A(e,"height",r[1]),A(s,"class","a9s-inner"),A(s,"style",r[5]),A(s,"x",r[4]),A(s,"y",r[3]),A(s,"width",r[2]),A(s,"height",r[1]),A(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),Ce(t,e),Ce(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&A(e,"style",i),a&16&&A(e,"x",o[4]),a&8&&A(e,"y",o[3]),a&4&&A(e,"width",o[2]),a&2&&A(e,"height",o[1]),a&32&&A(s,"style",o[5]),a&16&&A(s,"x",o[4]),a&8&&A(s,"y",o[3]),a&4&&A(s,"width",o[2]),a&2&&A(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:At,o:At,d(o){o&&tt(t)}}}function ig(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Rs(l,c)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,c]}class sg extends ue{constructor(t){super(),ce(this,t,ig,rg,Yt,{annotation:0,geom:6,style:7})}}const ng=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),og=250,ag=(r,t)=>{const e=Kr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<og){const{x:n,y:o}=lg(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},lg=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())},{Boolean:ch}=pp;function uh(r,t,e){const i=r.slice();return i[30]=t[e],i}function dh(r,t,e){const i=r.slice();return i[33]=t[e],i}function _o(r){const t=r.slice(),e=t[33].target.selector;return t[36]=e,t}function fh(r){let t=r[33].id,e,i,s=ph(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&8192&&Yt(t,t=n[33].id)?(Pe(),pt(s,1,1,At),Re(),s=ph(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s.d(n)}}}function hg(r){let t,e;return t=new eg({props:{annotation:r[33],geom:r[36].geometry,style:r[1]}}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&8192&&(n.annotation=i[33]),s[0]&8192&&(n.geom=i[36].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function cg(r){let t,e;return t=new sg({props:{annotation:r[33],geom:r[36].geometry,style:r[1]}}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&8192&&(n.annotation=i[33]),s[0]&8192&&(n.geom=i[36].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function ug(r){let t,e;return t=new Km({props:{annotation:r[33],geom:r[36].geometry,style:r[1]}}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&8192&&(n.annotation=i[33]),s[0]&8192&&(n.geom=i[36].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function ph(r){let t,e,i,s;const n=[ug,cg,hg],o=[];function a(l,h){return l[36].type===bt.ELLIPSE?0:l[36].type===bt.RECTANGLE?1:l[36].type===bt.POLYGON?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ie()},m(l,h){~t&&o[t].m(l,h),rt(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Pe(),pt(o[c],1,1,()=>{o[c]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){pt(e),s=!1},d(l){l&&tt(i),~t&&o[t].d(l)}}}function mh(r){let t=!r[7](r[33]),e,i,s=t&&fh(_o(r));return{c(){s&&s.c(),e=Ie()},m(n,o){s&&s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&8320&&(t=!n[7](n[33])),t?s?(s.p(_o(n),o),o[0]&8320&&ot(s,1)):(s=fh(_o(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(Pe(),pt(s,1,1,()=>{s=null}),Re())},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s&&s.d(n)}}}function gh(r){let t,e,i,s;const n=[fg,dg],o=[];function a(l,h){return l[6]?0:l[12]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ie()},m(l,h){~t&&o[t].m(l,h),rt(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Pe(),pt(o[c],1,1,()=>{o[c]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){pt(e),s=!1},d(l){l&&tt(i),~t&&o[t].d(l)}}}function dg(r){let t=r[2],e,i,s=yh(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&4&&Yt(t,t=n[2])?(Pe(),pt(s,1,1,At),Re(),s=yh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s.d(n)}}}function fg(r){let t,e,i=ti(r[6]),s=[];for(let o=0;o<i.length;o+=1)s[o]=vh(uh(r,i,o));const n=o=>pt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ie()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);rt(o,t,a),e=!0},p(o,a){if(a[0]&803922){i=ti(o[6]);let l;for(l=0;l<i.length;l+=1){const h=uh(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=vh(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(Pe(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(ch);for(let a=0;a<s.length;a+=1)pt(s[a]);e=!1},d(o){o&&tt(t),so(s,o)}}}function yh(r){let t,e;return t=new km({props:{target:r[4],tool:r[12],drawingMode:r[11],transform:r[10],viewportScale:r[14]}}),t.$on("create",r[17]),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&16&&(n.target=i[4]),s[0]&4096&&(n.tool=i[12]),s[0]&2048&&(n.drawingMode=i[11]),s[0]&1024&&(n.transform=i[10]),s[0]&16384&&(n.viewportScale=i[14]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function _h(r){let t,e;return t=new Nm({props:{target:r[4],editor:r[19](r[30].target.selector),annotation:r[30],style:r[1],transform:r[10],viewportScale:r[14]}}),t.$on("change",function(){Nt(r[18](r[30]))&&r[18](r[30]).apply(this,arguments)}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&16&&(n.target=r[4]),s[0]&64&&(n.editor=r[19](r[30].target.selector)),s[0]&64&&(n.annotation=r[30]),s[0]&2&&(n.style=r[1]),s[0]&1024&&(n.transform=r[10]),s[0]&16384&&(n.viewportScale=r[14]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function vh(r){let t=r[30].id,e,i,s=_h(r);return{c(){s.c(),e=Ie()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&64&&Yt(t,t=n[30].id)?(Pe(),pt(s,1,1,At),Re(),s=_h(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s.d(n)}}}function pg(r){let t,e,i,s,n,o,a=ti(r[13]),l=[];for(let u=0;u<a.length;u+=1)l[u]=mh(dh(r,a,u));const h=u=>pt(l[u],1,1,()=>{l[u]=null});let c=r[4]&&gh(r);return{c(){t=mt("svg"),e=mt("g");for(let u=0;u<l.length;u+=1)l[u].c();i=mt("g"),c&&c.c(),A(i,"class","drawing"),A(t,"class","a9s-annotationlayer"),As(t,"drawing",r[12])},m(u,d){rt(u,t,d),Ce(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);Ce(t,i),c&&c.m(i,null),r[26](i),r[27](t),s=!0,n||(o=[Ot(t,"pointerup",function(){Nt(r[8])&&r[8].apply(this,arguments)}),Ot(t,"pointerdown",function(){Nt(r[9])&&r[9].apply(this,arguments)})],n=!0)},p(u,d){if(r=u,d[0]&8322){a=ti(r[13]);let f;for(f=0;f<a.length;f+=1){const p=dh(r,a,f);l[f]?(l[f].p(p,d),ot(l[f],1)):(l[f]=mh(p),l[f].c(),ot(l[f],1),l[f].m(e,null))}for(Pe(),f=a.length;f<l.length;f+=1)h(f);Re()}r[4]?c?(c.p(r,d),d[0]&16&&ot(c,1)):(c=gh(r),c.c(),ot(c,1),c.m(i,null)):c&&(Pe(),pt(c,1,1,()=>{c=null}),Re()),(!s||d[0]&4096)&&As(t,"drawing",r[12])},i(u){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(c),s=!0}},o(u){l=l.filter(ch);for(let d=0;d<l.length;d+=1)pt(l[d]);pt(c),s=!1},d(u){u&&tt(t),so(l,u),c&&c.d(),r[26](null),r[27](null),n=!1,Se(o)}}}function mg(r,t,e){let i,s,n,o,a,l,h,c,u,d,f=At,p=()=>(f(),f=Ol(b,X=>e(14,d=X)),b);r.$$.on_destroy.push(()=>f());let{drawingEnabled:m}=t,{image:g}=t,{preferredDrawingMode:y}=t,{state:x}=t,{style:_=void 0}=t,{toolName:v=Ms()[0]}=t,{user:w}=t,R,C,b;Hi(()=>p(e(5,b=Tm(g,C))));const{selection:T,store:I}=x;Fl(r,T,X=>e(25,c=X)),Fl(r,I,X=>e(13,u=X));let O,M;const E=X=>{O&&I.unobserve(O);const D=X.filter(({editable:F})=>F).map(({id:F})=>F);D.length>0?(e(6,M=D.map(F=>I.getAnnotation(F)).filter(Boolean)),O=F=>{const{updated:j}=F.changes;e(6,M=j==null?void 0:j.map(nt=>nt.newValue))},I.observe(O,{annotations:D})):e(6,M=void 0)},S=X=>{const D=zl(),F={id:D,bodies:[],target:{annotation:D,selector:X.detail,creator:w,created:new Date}};I.addAnnotation(F),T.setSelected(F.id)},L=X=>D=>{var F;const{target:j}=X,nt=10*60*1e3,Q=((F=j.creator)==null?void 0:F.id)!==w.id||!j.created||new Date().getTime()-j.created.getTime()>nt;I.updateTarget({...j,selector:D.detail,created:Q?j.created:new Date,updated:Q?new Date:void 0,updatedBy:Q?w:void 0})},k=X=>rh(X);function G(X){Ss[X?"unshift":"push"](()=>{R=X,e(4,R)})}function H(X){Ss[X?"unshift":"push"](()=>{C=X,e(3,C)})}return r.$$set=X=>{"drawingEnabled"in X&&e(0,m=X.drawingEnabled),"image"in X&&e(20,g=X.image),"preferredDrawingMode"in X&&e(21,y=X.preferredDrawingMode),"state"in X&&e(22,x=X.state),"style"in X&&e(1,_=X.style),"toolName"in X&&e(2,v=X.toolName),"user"in X&&e(23,w=X.user)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(12,{tool:i,opts:s}=Bs(v)||{tool:void 0,opts:void 0},i,(e(24,s),e(2,v))),r.$$.dirty[0]&18874368&&e(11,n=(s==null?void 0:s.drawingMode)||y),r.$$.dirty[0]&8&&e(10,o=ng(C)),r.$$.dirty[0]&8&&e(9,{onPointerDown:a,onPointerUp:l}=ag(C,I),a,(e(8,l),e(3,C))),r.$$.dirty[0]&33554432&&e(7,h=X=>c.selected.find(D=>D.id===X.id&&D.editable)),r.$$.dirty[0]&33554432&&E(c.selected)},[m,_,v,C,R,b,M,h,l,a,o,n,i,u,d,T,I,S,L,k,g,y,x,w,s,c,G,H]}class gg extends ue{constructor(t){super(),ce(this,t,mg,pg,Yt,{drawingEnabled:0,image:20,preferredDrawingMode:21,state:22,style:1,toolName:2,user:23},null,[-1,-1])}}function yg(r,t,e,i,s){xh(r,t,e||0,i||r.length-1,s||_g)}function xh(r,t,e,i,s){for(;i>e;){if(i-e>600){var n=i-e+1,o=t-e+1,a=Math.log(n),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(n-l)/n)*(o-n/2<0?-1:1),c=Math.max(e,Math.floor(t-o*l/n+h)),u=Math.min(i,Math.floor(t+(n-o)*l/n+h));xh(r,t,c,u,s)}var d=r[t],f=e,p=i;for(Vi(r,e,t),s(r[i],d)>0&&Vi(r,e,i);f<p;){for(Vi(r,f,p),f++,p--;s(r[f],d)<0;)f++;for(;s(r[p],d)>0;)p--}s(r[e],d)===0?Vi(r,e,p):(p++,Vi(r,p,i)),p<=t&&(e=p+1),t<=p&&(i=p-1)}}function Vi(r,t,e){var i=r[t];r[t]=r[e],r[e]=i}function _g(r,t){return r<t?-1:r>t?1:0}class vg{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Os(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;Os(t,l)&&(e.leaf?i.push(a):xo(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Os(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if(Os(t,o)){if(e.leaf||xo(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=si([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const c=xg(t,i.children,e);if(c!==-1)return i.children.splice(c,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&xo(i,s)?(n.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=si(t.slice(e,i+1)),ii(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=si([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));bh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);bh(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return ii(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=vo(h),u=Eg(t,h)-c;u<o?(o=u,n=c<n?c:n,a=h):u===o&&c<n&&(n=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),Wi(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=si(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,ii(i,this.toBBox),ii(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=si([t,e]),this.data.height=t.height+1,this.data.leaf=!1,ii(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=zi(t,0,a,this.toBBox),h=zi(t,a,i,this.toBBox),c=Tg(l,h),u=vo(l)+vo(h);c<n?(n=c,s=a,o=u<o?u:o):c===n&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:bg,n=t.leaf?this.compareMinY:wg,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=zi(t,0,e,n),a=zi(t,i-e,i,n);let l=Ds(o)+Ds(a);for(let h=e;h<i-e;h++){const c=t.children[h];Wi(o,t.leaf?n(c):c),l+=Ds(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];Wi(a,t.leaf?n(c):c),l+=Ds(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)Wi(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():ii(t[e],this.toBBox)}}function xg(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function ii(r,t){zi(r,0,r.children.length,t,r)}function zi(r,t,e,i,s){s||(s=si(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];Wi(s,r.leaf?i(o):o)}return s}function Wi(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function bg(r,t){return r.minX-t.minX}function wg(r,t){return r.minY-t.minY}function vo(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Ds(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Eg(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Tg(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function xo(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Os(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function si(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function bh(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;yg(r,o,t,e,s),n.push(t,o,o,e)}}const Ag=()=>{const r=new vg,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},n=o=>{const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===bt.RECTANGLE||Ep(h.selector,o,a));if(l.length>0)return l.sort((h,c)=>co(h.selector)-co(c.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.map(h=>{const{minX:c,minY:u,maxX:d,maxY:f}=h.selector.geometry.bounds;return{minX:c,minY:u,maxX:d,maxY:f,target:h}});l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},wh=r=>{const t=Zp(),e=Ag(),i=$p(t,r.pointerSelectAction),s=Gp(t),n=rm();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation))},selection:i,hover:s,viewport:n}},Sg=r=>{const t=wh(r);return{...t,store:Jp(t.store)}},Cg=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Eh=r=>{const t=Cg(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},Th=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Eh(r):e),Ah=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,pointerSelectAction:r.pointerSelectAction||t.pointerSelectAction,theme:r.theme||t.theme}),Sh=navigator.userAgent.indexOf("Mac OS X")!==-1,Ch=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{Sh?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Sh?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},Ig=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Ah(t,{drawingEnabled:!0,drawingMode:"drag",pointerSelectAction:jl.EDIT,theme:"light"}),s=Sg(i),{selection:n,store:o}=s,a=em(o),l=im(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const c=Ch(a);let u=um();Th(e,h,i.theme);const d=new gg({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:u}});d.$on("click",b=>{const{originalEvent:T,annotation:I}=b.detail;I?n.clickSelect(I.id,T):n.isEmpty()||n.clear()});const f=nm(s,a,i.adapter),p=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},m=()=>u,g=(b,T,I)=>hh(b,T,I),y=(b,T)=>ih(b,T),x=b=>{if(!Bs(b))throw`No drawing tool named ${b}`;d.$set({toolName:b})},_=b=>d.$set({drawingEnabled:b}),v=b=>{console.warn("Filter not implemented yet")},w=b=>d.$set({style:b}),R=b=>Th(e,h,b),C=b=>{u=b,d.$set({user:b})};return{...f,destroy:p,getUser:m,listDrawingTools:Ms,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:y,setDrawingEnabled:_,setDrawingTool:x,setFilter:v,setStyle:w,setTheme:R,setUser:C,state:s}};function Me(){}function bo(r,t){for(const e in t)r[e]=t[e];return r}function Ih(r){return r()}function Ph(){return Object.create(null)}function qe(r){r.forEach(Ih)}function qt(r){return typeof r=="function"}function Qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Pg(r){return Object.keys(r).length===0}function Rg(r,...t){if(r==null){for(const i of t)i(void 0);return Me}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function wo(r,t,e){r.$$.on_destroy.push(Rg(t,e))}function Rh(r,t,e,i){if(r){const s=Mh(r,t,e,i);return r[0](s)}}function Mh(r,t,e,i){return r[1]&&i?bo(e.ctx.slice(),r[1](i(t))):e.ctx}function Bh(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Dh(r,t,e,i,s,n){if(s){const o=Mh(t,e,i,n);r.p(o,s)}}function Oh(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Fh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Fs(r){return r??""}const Mg=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ke(r,t){r.appendChild(t)}function ct(r,t,e){r.insertBefore(t,e||null)}function lt(r){r.parentNode&&r.parentNode.removeChild(r)}function Eo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Et(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function To(r){return document.createTextNode(r)}function ge(){return To(" ")}function ur(){return To("")}function Xt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function P(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Bg(r){return Array.from(r.childNodes)}function Dg(r,t){t=""+t,r.data!==t&&(r.data=t)}function Ls(r,t,e){r.classList.toggle(t,!!e)}function Og(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let ji;function Yi(r){ji=r}function Ao(){if(!ji)throw new Error("Function called outside component initialization");return ji}function Ns(r){Ao().$$.on_mount.push(r)}function Fg(r){Ao().$$.on_destroy.push(r)}function Us(){const r=Ao();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Og(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ze(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const ni=[],ks=[];let oi=[];const Lh=[],Lg=Promise.resolve();let So=!1;function Ng(){So||(So=!0,Lg.then(Nh))}function Co(r){oi.push(r)}const Io=new Set;let ai=0;function Nh(){if(ai!==0)return;const r=ji;do{try{for(;ai<ni.length;){const t=ni[ai];ai++,Yi(t),Ug(t.$$)}}catch(t){throw ni.length=0,ai=0,t}for(Yi(null),ni.length=0,ai=0;ks.length;)ks.pop()();for(let t=0;t<oi.length;t+=1){const e=oi[t];Io.has(e)||(Io.add(e),e())}oi.length=0}while(ni.length);for(;Lh.length;)Lh.pop()();So=!1,Io.clear(),Yi(r)}function Ug(r){if(r.fragment!==null){r.update(),qe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Co)}}function kg(r){const t=[],e=[];oi.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),oi=t}const Gs=new Set;let Rr;function Je(){Rr={r:0,c:[],p:Rr}}function Qe(){Rr.r||qe(Rr.c),Rr=Rr.p}function st(r,t){r&&r.i&&(Gs.delete(r),r.i(t))}function ut(r,t,e,i){if(r&&r.o){if(Gs.has(r))return;Gs.add(r),Rr.c.push(()=>{Gs.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function li(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function te(r){r&&r.c()}function Kt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Co(()=>{const n=r.$$.on_mount.map(Ih).filter(qt);r.$$.on_destroy?r.$$.on_destroy.push(...n):qe(n),r.$$.on_mount=[]}),s.forEach(Co)}function Zt(r,t){const e=r.$$;e.fragment!==null&&(kg(e.after_update),qe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Gg(r,t){r.$$.dirty[0]===-1&&(ni.push(r),Ng(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ne(r,t,e,i,s,n,o=null,a=[-1]){const l=ji;Yi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Me,not_equal:s,bound:Ph(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Ph(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Gg(r,u)),d}):[],h.update(),c=!0,qe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Bg(t.target);h.fragment&&h.fragment.l(u),u.forEach(lt)}else h.fragment&&h.fragment.c();t.intro&&st(r.$$.fragment),Kt(r,t.target,t.anchor),Nh()}Yi(l)}class oe{constructor(){wl(this,"$$");wl(this,"$$set")}$destroy(){Zt(this,1),this.$destroy=Me}$on(t,e){if(!qt(e))return Me;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Pg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const $g="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add($g);var Mr=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Mr||{}),Uh=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Uh||{}),Po=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Po||{}),J=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(J||{}),Be=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Be||{}),U=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(U||{}),hi=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(hi||{}),Z=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(Z||{}),z=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(z||{}),tr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(tr||{}),dr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(dr||{}),De=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(De||{}),re=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(re||{}),Oe=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Oe||{}),Ro=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Ro||{}),de=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(de||{}),Ft=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(Ft||{}),Bt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Bt||{}),Fe=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Fe||{});const W={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Mo=/iPhone/i,kh=/iPod/i,Gh=/iPad/i,$h=/\biOS-universal(?:.+)Mac\b/i,Bo=/\bAndroid(?:.+)Mobile\b/i,Hh=/Android/i,ci=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,$s=/Silk/i,er=/Windows Phone/i,Xh=/\bWindows(?:.+)ARM\b/i,Vh=/BlackBerry/i,zh=/BB10/i,Wh=/Opera Mini/i,jh=/\b(CriOS|Chrome)(?:.+)Mobile/i,Yh=/Mobile(?:.+)Firefox\b/i,qh=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Hg(r){return function(t){return t.test(r)}}function Kh(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=Hg(e),n={apple:{phone:s(Mo)&&!s(er),ipod:s(kh),tablet:!s(Mo)&&(s(Gh)||qh(t))&&!s(er),universal:s($h),device:(s(Mo)||s(kh)||s(Gh)||s($h)||qh(t))&&!s(er)},amazon:{phone:s(ci),tablet:!s(ci)&&s($s),device:s(ci)||s($s)},android:{phone:!s(er)&&s(ci)||!s(er)&&s(Bo),tablet:!s(er)&&!s(ci)&&!s(Bo)&&(s($s)||s(Hh)),device:!s(er)&&(s(ci)||s($s)||s(Bo)||s(Hh))||s(/\bokhttp\b/i)},windows:{phone:s(er),tablet:s(Xh),device:s(er)||s(Xh)},other:{blackberry:s(Vh),blackberry10:s(zh),opera:s(Wh),firefox:s(Yh),chrome:s(jh),device:s(Vh)||s(zh)||s(Wh)||s(Yh)||s(jh)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Xg=Kh.default??Kh,rr=Xg(globalThis.navigator);W.RETINA_PREFIX=/@([0-9\.]+)x/,W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Hs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Vg(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var Jh={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var g=this._events[m],y=arguments.length,x,_;if(g.fn){switch(g.once&&this.removeListener(h,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(_=1,x=new Array(y-1);_<y;_++)x[_-1]=arguments[_];g.fn.apply(g.context,x)}else{var v=g.length,w;for(_=0;_<v;_++)switch(g[_].once&&this.removeListener(h,g[_].fn,void 0,!0),y){case 1:g[_].fn.call(g[_].context);break;case 2:g[_].fn.call(g[_].context,c);break;case 3:g[_].fn.call(g[_].context,c,u);break;case 4:g[_].fn.call(g[_].context,c,u,d);break;default:if(!x)for(w=1,x=new Array(y-1);w<y;w++)x[w-1]=arguments[w];g[_].fn.apply(g[_].context,x)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,g=[],y=p.length;m<y;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(Jh);var zg=Jh.exports;const qi=Zh(zg);var Do={exports:{}};Do.exports=Xs,Do.exports.default=Xs;function Xs(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Qh(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=Kg(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return Ki(n,o,e,a,l,f,0),o}function Qh(r,t,e,i,s){var n,o;if(s===Lo(r,t,e,i)>0)for(n=t;n<e;n+=i)o=rc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=rc(n,r[n],r[n+1],o);return o&&Vs(o,o.next)&&(Ji(o),o=o.next),o}function Br(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Vs(e,e.next)||St(e.prev,e,e.next)===0)){if(Ji(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Ki(r,t,e,i,s,n,o){if(r){!o&&n&&ey(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?jg(r,i,s,n):Wg(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Ji(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Yg(Br(r),t,e),Ki(r,t,e,i,s,n,2)):o===2&&qg(r,t,e,i,s,n):Ki(Br(r),t,e,i,s,n,1);break}}}}function Wg(r){var t=r.prev,e=r,i=r.next;if(St(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&ui(s,a,n,l,o,h,p.x,p.y)&&St(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function jg(r,t,e,i){var s=r.prev,n=r,o=r.next;if(St(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,c=s.y,u=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,y=Oo(f,p,t,e,i),x=Oo(m,g,t,e,i),_=r.prevZ,v=r.nextZ;_&&_.z>=y&&v&&v.z<=x;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==s&&_!==o&&ui(a,c,l,u,h,d,_.x,_.y)&&St(_.prev,_,_.next)>=0||(_=_.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==o&&ui(a,c,l,u,h,d,v.x,v.y)&&St(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;_&&_.z>=y;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==s&&_!==o&&ui(a,c,l,u,h,d,_.x,_.y)&&St(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==o&&ui(a,c,l,u,h,d,v.x,v.y)&&St(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Yg(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Vs(s,n)&&tc(s,i,i.next,n)&&Zi(s,n)&&Zi(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Ji(i),Ji(i.next),i=r=n),i=i.next}while(i!==r);return Br(i)}function qg(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&sy(o,a)){var l=ec(o,a);o=Br(o,o.next),l=Br(l,l.next),Ki(o,t,e,i,s,n,0),Ki(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Kg(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=Qh(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(iy(h));for(s.sort(Zg),n=0;n<s.length;n++)e=Jg(s[n],e);return e}function Zg(r,t){return r.x-t.x}function Jg(r,t){var e=Qg(r,t);if(!e)return t;var i=ec(e,r);return Br(i,i.next),Br(e,e.next)}function Qg(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&ui(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Zi(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&ty(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function ty(r,t){return St(r.prev,r,t.prev)<0&&St(t.next,r,r.next)<0}function ey(r,t,e,i){var s=r;do s.z===0&&(s.z=Oo(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,ry(s)}function ry(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function Oo(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function iy(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function ui(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function sy(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!ny(r,t)&&(Zi(r,t)&&Zi(t,r)&&oy(r,t)&&(St(r.prev,r,t.prev)||St(r,t.prev,t))||Vs(r,t)&&St(r.prev,r,r.next)>0&&St(t.prev,t,t.next)>0)}function St(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Vs(r,t){return r.x===t.x&&r.y===t.y}function tc(r,t,e,i){var s=Ws(St(r,t,e)),n=Ws(St(r,t,i)),o=Ws(St(e,i,r)),a=Ws(St(e,i,t));return!!(s!==n&&o!==a||s===0&&zs(r,e,t)||n===0&&zs(r,i,t)||o===0&&zs(e,r,i)||a===0&&zs(e,t,i))}function zs(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Ws(r){return r>0?1:r<0?-1:0}function ny(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&tc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Zi(r,t){return St(r.prev,r,r.next)<0?St(r,t,r.next)>=0&&St(r,r.prev,t)>=0:St(r,t,r.prev)<0||St(r,r.next,t)<0}function oy(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function ec(r,t){var e=new Fo(r.i,r.x,r.y),i=new Fo(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function rc(r,t,e,i){var s=new Fo(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ji(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Fo(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Xs.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Lo(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(Lo(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Lo(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}Xs.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var ay=Do.exports;const ly=Zh(ay);var js={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */js.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Hs=="object"&&Hs;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,m="-",g=/^xn--/,y=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=l-h,w=Math.floor,R=String.fromCharCode,C;function b(D){throw new RangeError(_[D])}function T(D,F){for(var j=D.length,nt=[];j--;)nt[j]=F(D[j]);return nt}function I(D,F){var j=D.split("@"),nt="";j.length>1&&(nt=j[0]+"@",D=j[1]),D=D.replace(x,".");var Q=D.split("."),V=T(Q,F).join(".");return nt+V}function O(D){for(var F=[],j=0,nt=D.length,Q,V;j<nt;)Q=D.charCodeAt(j++),Q>=55296&&Q<=56319&&j<nt?(V=D.charCodeAt(j++),(V&64512)==56320?F.push(((Q&1023)<<10)+(V&1023)+65536):(F.push(Q),j--)):F.push(Q);return F}function M(D){return T(D,function(F){var j="";return F>65535&&(F-=65536,j+=R(F>>>10&1023|55296),F=56320|F&1023),j+=R(F),j}).join("")}function E(D){return D-48<10?D-22:D-65<26?D-65:D-97<26?D-97:l}function S(D,F){return D+22+75*(D<26)-((F!=0)<<5)}function L(D,F,j){var nt=0;for(D=j?w(D/d):D>>1,D+=w(D/F);D>v*c>>1;nt+=l)D=w(D/v);return w(nt+(v+1)*D/(D+u))}function k(D){var F=[],j=D.length,nt,Q=0,V=p,_t=f,Tt,N,B,xt,ft,gt,yt,ze,We;for(Tt=D.lastIndexOf(m),Tt<0&&(Tt=0),N=0;N<Tt;++N)D.charCodeAt(N)>=128&&b("not-basic"),F.push(D.charCodeAt(N));for(B=Tt>0?Tt+1:0;B<j;){for(xt=Q,ft=1,gt=l;B>=j&&b("invalid-input"),yt=E(D.charCodeAt(B++)),(yt>=l||yt>w((a-Q)/ft))&&b("overflow"),Q+=yt*ft,ze=gt<=_t?h:gt>=_t+c?c:gt-_t,!(yt<ze);gt+=l)We=l-ze,ft>w(a/We)&&b("overflow"),ft*=We;nt=F.length+1,_t=L(Q-xt,nt,xt==0),w(Q/nt)>a-V&&b("overflow"),V+=w(Q/nt),Q%=nt,F.splice(Q++,0,V)}return M(F)}function G(D){var F,j,nt,Q,V,_t,Tt,N,B,xt,ft,gt=[],yt,ze,We,ys;for(D=O(D),yt=D.length,F=p,j=0,V=f,_t=0;_t<yt;++_t)ft=D[_t],ft<128&>.push(R(ft));for(nt=Q=gt.length,Q&>.push(m);nt<yt;){for(Tt=a,_t=0;_t<yt;++_t)ft=D[_t],ft>=F&&ft<Tt&&(Tt=ft);for(ze=nt+1,Tt-F>w((a-j)/ze)&&b("overflow"),j+=(Tt-F)*ze,F=Tt,_t=0;_t<yt;++_t)if(ft=D[_t],ft<F&&++j>a&&b("overflow"),ft==F){for(N=j,B=l;xt=B<=V?h:B>=V+c?c:B-V,!(N<xt);B+=l)ys=N-xt,We=l-xt,gt.push(R(S(xt+ys%We,0))),N=w(ys/We);gt.push(R(S(N,0))),V=L(j,ze,nt==Q),j=0,++nt}++j,++F}return gt.join("")}function H(D){return I(D,function(F){return g.test(F)?k(F.slice(4).toLowerCase()):F})}function X(D){return I(D,function(F){return y.test(F)?"xn--"+G(F):F})}if(o={version:"1.4.1",ucs2:{decode:O,encode:M},decode:k,encode:G,toASCII:X,toUnicode:H},i&&s)if(r.exports==i)s.exports=o;else for(C in o)o.hasOwnProperty(C)&&(i[C]=o[C]);else e.punycode=o})(Hs)}(js,js.exports);var hy=js.exports,cy=Error,uy=EvalError,dy=RangeError,fy=ReferenceError,ic=SyntaxError,Qi=TypeError,py=URIError,my=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},sc=typeof Symbol<"u"&&Symbol,gy=my,yy=function(){return typeof sc!="function"||typeof Symbol!="function"||typeof sc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:gy()},No={__proto__:null,foo:{}},_y=Object,vy=function(){return{__proto__:No}.foo===No.foo&&!(No instanceof _y)},xy="Function.prototype.bind called on incompatible ",by=Object.prototype.toString,wy=Math.max,Ey="[object Function]",nc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},Ty=function(t,e){for(var i=[],s=e||0,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},Ay=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},Sy=function(t){var e=this;if(typeof e!="function"||by.apply(e)!==Ey)throw new TypeError(xy+e);for(var i=Ty(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,nc(i,arguments));return Object(c)===c?c:this}return e.apply(t,nc(i,arguments))},o=wy(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+Ay(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},Cy=Sy,Uo=Function.prototype.bind||Cy,Iy=Function.prototype.call,Py=Object.prototype.hasOwnProperty,Ry=Uo,My=Ry.call(Iy,Py),ht,By=cy,Dy=uy,Oy=dy,Fy=fy,di=ic,fi=Qi,Ly=py,oc=Function,ko=function(r){try{return oc('"use strict"; return ('+r+").constructor;")()}catch{}},Dr=Object.getOwnPropertyDescriptor;if(Dr)try{Dr({},"")}catch{Dr=null}var Go=function(){throw new fi},Ny=Dr?function(){try{return arguments.callee,Go}catch{try{return Dr(arguments,"callee").get}catch{return Go}}}():Go,pi=yy(),Uy=vy(),Ut=Object.getPrototypeOf||(Uy?function(r){return r.__proto__}:null),mi={},ky=typeof Uint8Array>"u"||!Ut?ht:Ut(Uint8Array),Or={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?ht:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?ht:ArrayBuffer,"%ArrayIteratorPrototype%":pi&&Ut?Ut([][Symbol.iterator]()):ht,"%AsyncFromSyncIteratorPrototype%":ht,"%AsyncFunction%":mi,"%AsyncGenerator%":mi,"%AsyncGeneratorFunction%":mi,"%AsyncIteratorPrototype%":mi,"%Atomics%":typeof Atomics>"u"?ht:Atomics,"%BigInt%":typeof BigInt>"u"?ht:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?ht:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?ht:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?ht:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":By,"%eval%":eval,"%EvalError%":Dy,"%Float32Array%":typeof Float32Array>"u"?ht:Float32Array,"%Float64Array%":typeof Float64Array>"u"?ht:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?ht:FinalizationRegistry,"%Function%":oc,"%GeneratorFunction%":mi,"%Int8Array%":typeof Int8Array>"u"?ht:Int8Array,"%Int16Array%":typeof Int16Array>"u"?ht:Int16Array,"%Int32Array%":typeof Int32Array>"u"?ht:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":pi&&Ut?Ut(Ut([][Symbol.iterator]())):ht,"%JSON%":typeof JSON=="object"?JSON:ht,"%Map%":typeof Map>"u"?ht:Map,"%MapIteratorPrototype%":typeof Map>"u"||!pi||!Ut?ht:Ut(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?ht:Promise,"%Proxy%":typeof Proxy>"u"?ht:Proxy,"%RangeError%":Oy,"%ReferenceError%":Fy,"%Reflect%":typeof Reflect>"u"?ht:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?ht:Set,"%SetIteratorPrototype%":typeof Set>"u"||!pi||!Ut?ht:Ut(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?ht:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":pi&&Ut?Ut(""[Symbol.iterator]()):ht,"%Symbol%":pi?Symbol:ht,"%SyntaxError%":di,"%ThrowTypeError%":Ny,"%TypedArray%":ky,"%TypeError%":fi,"%Uint8Array%":typeof Uint8Array>"u"?ht:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?ht:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?ht:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?ht:Uint32Array,"%URIError%":Ly,"%WeakMap%":typeof WeakMap>"u"?ht:WeakMap,"%WeakRef%":typeof WeakRef>"u"?ht:WeakRef,"%WeakSet%":typeof WeakSet>"u"?ht:WeakSet};if(Ut)try{null.error}catch(r){var Gy=Ut(Ut(r));Or["%Error.prototype%"]=Gy}var $y=function r(t){var e;if(t==="%AsyncFunction%")e=ko("async function () {}");else if(t==="%GeneratorFunction%")e=ko("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=ko("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&Ut&&(e=Ut(s.prototype))}return Or[t]=e,e},ac={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ts=Uo,Ys=My,Hy=ts.call(Function.call,Array.prototype.concat),Xy=ts.call(Function.apply,Array.prototype.splice),lc=ts.call(Function.call,String.prototype.replace),qs=ts.call(Function.call,String.prototype.slice),Vy=ts.call(Function.call,RegExp.prototype.exec),zy=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Wy=/\\(\\)?/g,jy=function(t){var e=qs(t,0,1),i=qs(t,-1);if(e==="%"&&i!=="%")throw new di("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new di("invalid intrinsic syntax, expected opening `%`");var s=[];return lc(t,zy,function(n,o,a,l){s[s.length]=a?lc(l,Wy,"$1"):o||n}),s},Yy=function(t,e){var i=t,s;if(Ys(ac,i)&&(s=ac[i],i="%"+s[0]+"%"),Ys(Or,i)){var n=Or[i];if(n===mi&&(n=$y(i)),typeof n>"u"&&!e)throw new fi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new di("intrinsic "+t+" does not exist!")},gi=function(t,e){if(typeof t!="string"||t.length===0)throw new fi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new fi('"allowMissing" argument must be a boolean');if(Vy(/^%?[^%]*%?$/,t)===null)throw new di("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=jy(t),s=i.length>0?i[0]:"",n=Yy("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],Xy(i,Hy([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=qs(d,0,1),p=qs(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new di("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",Ys(Or,o))a=Or[o];else if(a!=null){if(!(d in a)){if(!e)throw new fi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Dr&&c+1>=i.length){var m=Dr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=Ys(a,d),a=a[d];u&&!l&&(Or[o]=a)}}return a},hc={exports:{}},$o,cc;function Ho(){if(cc)return $o;cc=1;var r=gi,t=r("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return $o=t,$o}var qy=gi,Ks=qy("%Object.getOwnPropertyDescriptor%",!0);if(Ks)try{Ks([],"length")}catch{Ks=null}var uc=Ks,dc=Ho(),Ky=ic,yi=Qi,fc=uc,Zy=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new yi("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new yi("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new yi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new yi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new yi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new yi("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!fc&&fc(t,e);if(dc)dc(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:i,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=i;else throw new Ky("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Xo=Ho(),pc=function(){return!!Xo};pc.hasArrayLengthDefineBug=function(){if(!Xo)return null;try{return Xo([],"length",{value:1}).length!==1}catch{return!0}};var Jy=pc,Qy=gi,mc=Zy,t0=Jy(),gc=uc,yc=Qi,e0=Qy("%Math.floor%"),r0=function(t,e){if(typeof t!="function")throw new yc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||e0(e)!==e)throw new yc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&gc){var o=gc(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(t0?mc(t,"length",e,!0,!0):mc(t,"length",e)),t};(function(r){var t=Uo,e=gi,i=r0,s=Qi,n=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),a=e("%Reflect.apply%",!0)||t.call(o,n),l=Ho(),h=e("%Math.max%");r.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return i(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(r.exports,"apply",{value:c}):r.exports.apply=c})(hc);var i0=hc.exports,_c=gi,vc=i0,s0=vc(_c("String.prototype.indexOf")),n0=function(t,e){var i=_c(t,!!e);return typeof i=="function"&&s0(t,".prototype.")>-1?vc(i):i};const o0=Vg(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Vo=typeof Map=="function"&&Map.prototype,zo=Object.getOwnPropertyDescriptor&&Vo?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Zs=Vo&&zo&&typeof zo.get=="function"?zo.get:null,xc=Vo&&Map.prototype.forEach,Wo=typeof Set=="function"&&Set.prototype,jo=Object.getOwnPropertyDescriptor&&Wo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Js=Wo&&jo&&typeof jo.get=="function"?jo.get:null,bc=Wo&&Set.prototype.forEach,a0=typeof WeakMap=="function"&&WeakMap.prototype,es=a0?WeakMap.prototype.has:null,l0=typeof WeakSet=="function"&&WeakSet.prototype,rs=l0?WeakSet.prototype.has:null,h0=typeof WeakRef=="function"&&WeakRef.prototype,wc=h0?WeakRef.prototype.deref:null,c0=Boolean.prototype.valueOf,u0=Object.prototype.toString,d0=Function.prototype.toString,f0=String.prototype.match,Yo=String.prototype.slice,fr=String.prototype.replace,p0=String.prototype.toUpperCase,Ec=String.prototype.toLowerCase,Tc=RegExp.prototype.test,Ac=Array.prototype.concat,Le=Array.prototype.join,m0=Array.prototype.slice,Sc=Math.floor,qo=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ko=Object.getOwnPropertySymbols,Zo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,_i=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Jt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===_i||!0)?Symbol.toStringTag:null,Cc=Object.prototype.propertyIsEnumerable,Ic=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Pc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Tc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-Sc(-r):Sc(r);if(i!==r){var s=String(i),n=Yo.call(t,s.length+1);return fr.call(s,e,"$&_")+"."+fr.call(fr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fr.call(t,e,"$&_")}var Jo=o0,Rc=Jo.custom,Mc=Oc(Rc)?Rc:null,g0=function r(t,e,i,s){var n=e||{};if(pr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(pr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=pr(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(pr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(pr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Lc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Pc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Pc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return Qo(t)?"[Array]":"[Object]";var u=O0(n,i);if(typeof s>"u")s=[];else if(Fc(s,t)>=0)return"[Circular]";function d(E,S,L){if(S&&(s=m0.call(s),s.push(S)),L){var k={depth:n.depth};return pr(n,"quoteStyle")&&(k.quoteStyle=n.quoteStyle),r(E,k,i+1,s)}return r(E,n,i+1,s)}if(typeof t=="function"&&!Dc(t)){var f=A0(t),p=Qs(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+Le.call(p,", ")+" }":"")}if(Oc(t)){var m=_i?fr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Zo.call(t);return typeof t=="object"&&!_i?is(m):m}if(M0(t)){for(var g="<"+Ec.call(String(t.nodeName)),y=t.attributes||[],x=0;x<y.length;x++)g+=" "+y[x].name+"="+Bc(y0(y[x].value),"double",n);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+="</"+Ec.call(String(t.nodeName))+">",g}if(Qo(t)){if(t.length===0)return"[]";var _=Qs(t,d);return u&&!D0(_)?"["+ea(_,u)+"]":"[ "+Le.call(_,", ")+" ]"}if(v0(t)){var v=Qs(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Cc.call(t,"cause")?"{ ["+String(t)+"] "+Le.call(Ac.call("[cause]: "+d(t.cause),v),", ")+" }":v.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Le.call(v,", ")+" }"}if(typeof t=="object"&&o){if(Mc&&typeof t[Mc]=="function"&&Jo)return Jo(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(S0(t)){var w=[];return xc&&xc.call(t,function(E,S){w.push(d(S,t,!0)+" => "+d(E,t))}),Nc("Map",Zs.call(t),w,u)}if(P0(t)){var R=[];return bc&&bc.call(t,function(E){R.push(d(E,t))}),Nc("Set",Js.call(t),R,u)}if(C0(t))return ta("WeakMap");if(R0(t))return ta("WeakSet");if(I0(t))return ta("WeakRef");if(b0(t))return is(d(Number(t)));if(E0(t))return is(d(qo.call(t)));if(w0(t))return is(c0.call(t));if(x0(t))return is(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(t===Hs)return"{ [object globalThis] }";if(!_0(t)&&!Dc(t)){var C=Qs(t,d),b=Ic?Ic(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",I=!b&&Jt&&Object(t)===t&&Jt in t?Yo.call(mr(t),8,-1):T?"Object":"",O=b||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",M=O+(I||T?"["+Le.call(Ac.call([],I||[],T||[]),": ")+"] ":"");return C.length===0?M+"{}":u?M+"{"+ea(C,u)+"}":M+"{ "+Le.call(C,", ")+" }"}return String(t)};function Bc(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function y0(r){return fr.call(String(r),/"/g,""")}function Qo(r){return mr(r)==="[object Array]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function _0(r){return mr(r)==="[object Date]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function Dc(r){return mr(r)==="[object RegExp]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function v0(r){return mr(r)==="[object Error]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function x0(r){return mr(r)==="[object String]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function b0(r){return mr(r)==="[object Number]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function w0(r){return mr(r)==="[object Boolean]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function Oc(r){if(_i)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Zo)return!1;try{return Zo.call(r),!0}catch{}return!1}function E0(r){if(!r||typeof r!="object"||!qo)return!1;try{return qo.call(r),!0}catch{}return!1}var T0=Object.prototype.hasOwnProperty||function(r){return r in this};function pr(r,t){return T0.call(r,t)}function mr(r){return u0.call(r)}function A0(r){if(r.name)return r.name;var t=f0.call(d0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Fc(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function S0(r){if(!Zs||!r||typeof r!="object")return!1;try{Zs.call(r);try{Js.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function C0(r){if(!es||!r||typeof r!="object")return!1;try{es.call(r,es);try{rs.call(r,rs)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function I0(r){if(!wc||!r||typeof r!="object")return!1;try{return wc.call(r),!0}catch{}return!1}function P0(r){if(!Js||!r||typeof r!="object")return!1;try{Js.call(r);try{Zs.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function R0(r){if(!rs||!r||typeof r!="object")return!1;try{rs.call(r,rs);try{es.call(r,es)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function M0(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Lc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Lc(Yo.call(r,0,t.maxStringLength),t)+i}var s=fr.call(fr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,B0);return Bc(s,"single",t)}function B0(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+p0.call(t.toString(16))}function is(r){return"Object("+r+")"}function ta(r){return r+" { ? }"}function Nc(r,t,e,i){var s=i?ea(e,i):Le.call(e,", ");return r+" ("+t+") {"+s+"}"}function D0(r){for(var t=0;t<r.length;t++)if(Fc(r[t],`
|
|
1
|
+
(function(Dt,jt){typeof exports=="object"&&typeof module<"u"?jt(exports,require("openseadragon")):typeof define=="function"&&define.amd?define(["exports","openseadragon"],jt):(Dt=typeof globalThis<"u"?globalThis:Dt||self,jt(Dt.AnnotoriousOSD={},Dt.OpenSeadragon))})(this,function(Dt,jt){"use strict";var IE=Object.defineProperty;var CE=(Dt,jt,hr)=>jt in Dt?IE(Dt,jt,{enumerable:!0,configurable:!0,writable:!0,value:hr}):Dt[jt]=hr;var wl=(Dt,jt,hr)=>(CE(Dt,typeof jt!="symbol"?jt+"":jt,hr),hr);var hr=Object.prototype.hasOwnProperty;function Ir(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Ir(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(hr.call(r,e)&&++i&&!hr.call(t,e)||!(e in t)||!Ir(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}var ro=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(ro||{});let Ts;const Ff=new Uint8Array(16);function Lf(){if(!Ts&&(Ts=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ts))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ts(Ff)}const $t=[];for(let r=0;r<256;++r)$t.push((r+256).toString(16).slice(1));function Nf(r,t=0){return $t[r[t+0]]+$t[r[t+1]]+$t[r[t+2]]+$t[r[t+3]]+"-"+$t[r[t+4]]+$t[r[t+5]]+"-"+$t[r[t+6]]+$t[r[t+7]]+"-"+$t[r[t+8]]+$t[r[t+9]]+"-"+$t[r[t+10]]+$t[r[t+11]]+$t[r[t+12]]+$t[r[t+13]]+$t[r[t+14]]+$t[r[t+15]]}const Uf=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Rl={randomUUID:Uf};function kf(r,t,e){if(Rl.randomUUID&&!t&&!r)return Rl.randomUUID();r=r||{};const i=r.random||(r.rng||Lf)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return Nf(i)}const Gf=(r,t,e,i)=>({id:kf(),annotation:r.id,created:e||new Date,creator:i,...t}),$f=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},Hf=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Xf=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Ir(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),Vf=(r,t)=>!Ir(r.target,t.target),zf=(r,t)=>{const e=$f(r,t),i=Hf(r,t),s=Xf(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:Vf(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var cr=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r))(cr||{});const Wf=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return zf(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}};let jf=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const Yf=250,qf=r=>{const t=jf(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>Yf)e.splice(i+1),e.push(p),i=e.length-1;else{const g=e.length-1;e[g]=Wf(e[g],p)}n=m}s=!1};r.observe(o,{origin:cr.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},Kf=(r,t,e,i)=>{const{store:s,selection:n,hover:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},f=(y,v)=>{const _=l.get(y);_&&_.indexOf(v)>0&&_.splice(_.indexOf(v),1)},p=(y,v,_)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const T=Array.isArray(v)?v.map(I=>e.serialize(I)):e.serialize(v),P=_?_ instanceof PointerEvent?_:e.serialize(_):void 0;x(T,P)}else x(v,_)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:_})=>s.getAnnotation(_));v.forEach(_=>{const x=h.find(T=>T.id===_.id);(!x||!Ir(x,_))&&p("updateAnnotation",_,x)}),h=h.map(_=>v.find(({id:T})=>T===_.id)||_)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>s.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const _=s.getAnnotation(v.id);_&&!Ir(_,v)&&p("updateAnnotation",_,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),_=new Set(y.map(({id:x})=>x));h.filter(x=>!_.has(x.id)).forEach(x=>{const T=s.getAnnotation(x.id);T&&!Ir(T,x)&&p("updateAnnotation",T,x)}),h=[...h.filter(x=>_.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>s.getAnnotation(x))]}p("selectionChanged",h)}}),o.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",s.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",s.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",s.getAnnotation(c)),p("mouseEnterAnnotation",s.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(v=>s.getAnnotation(v)))),s.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:v,deleted:_}=y.changes;(v||[]).forEach(x=>p("createAnnotation",x)),(_||[]).forEach(x=>p("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:T})=>{const P=h.find(I=>I.id===x.id)||x;h=h.map(I=>I.id===x.id?T:I),p("updateAnnotation",T,P)})},{origin:cr.LOCAL}),s.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),_=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);_.length>0&&(h=h.map(x=>_.find(P=>P.id===x.id)||x))}},{origin:cr.REMOTE});const g=y=>v=>{const{updated:_}=v;y?(_||[]).forEach(x=>p("updateAnnotation",x.oldValue,x.newValue)):(_||[]).forEach(x=>p("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",g(!0)),t.on("redo",g(!1)),{on:d,off:f,emit:p}},Zf=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),Jf=(r,t,e)=>{const{store:i,selection:s}=r,n=g=>{if(e){const{parsed:y,error:v}=e.parse(g);y?i.addAnnotation(y,cr.REMOTE):console.error(v)}else i.addAnnotation(g,cr.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=g=>{const y=i.getAnnotation(g);return e&&y?e.serialize(y):y},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var g;const y=(((g=s.selected)==null?void 0:g.map(v=>v.id))||[]).map(v=>i.getAnnotation(v)).filter(Boolean);return e?y.map(e.serialize):y},u=(g,y=!0)=>fetch(g).then(v=>v.json()).then(v=>(f(v,y),v)),d=g=>{if(typeof g=="string"){const y=i.getAnnotation(g);if(i.deleteAnnotation(g),y)return e?e.serialize(y):y}else{const y=e?e.parse(g).parsed:g;if(y)return i.deleteAnnotation(y),g}},f=(g,y=!0)=>{if(e){const{parsed:v,failed:_}=Zf(e)(g);_.length>0&&console.warn(`Discarded ${_.length} invalid annotations`,_),i.bulkAddAnnotation(v,y,cr.REMOTE)}else i.bulkAddAnnotation(g,y,cr.REMOTE)},p=g=>{g?s.setSelected(g):s.clear()},m=g=>{if(e){const y=e.parse(g).parsed,v=e.serialize(i.getAnnotation(y.id));return i.updateAnnotation(y),v}else{const y=i.getAnnotation(g.id);return i.updateAnnotation(g),y}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,undo:t.undo,updateAnnotation:m}},Qf="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let tp=r=>crypto.getRandomValues(new Uint8Array(r)),ep=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},rp=(r,t=21)=>ep(r,t,tp),ip=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Qf[e[r]&63];return t};const sp=()=>({isGuest:!0,id:rp("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),np=["#ff7c00","#1ac938","#e8000b","#8b2be2","#9f4800","#f14cc1","#ffc400","#00d7ff","#023eff"],op=()=>{const r=[...np];return{assignRandomColor:()=>{const t=Math.floor(Math.random()*r.length),e=r[t];return r.splice(t,1),e},releaseColor:t=>r.push(t)}};ip();var ap=Object.defineProperty,lp=(r,t,e)=>t in r?ap(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ml=(r,t,e)=>(lp(r,typeof t!="symbol"?t+"":t,e),e);function At(){}function io(r,t){for(const e in t)r[e]=t[e];return r}function Bl(r){return r()}function Dl(){return Object.create(null)}function Se(r){r.forEach(Bl)}function Nt(r){return typeof r=="function"}function Yt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function hp(r){return Object.keys(r).length===0}function Ol(r,...t){if(r==null){for(const i of t)i(void 0);return At}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function Fl(r,t,e){r.$$.on_destroy.push(Ol(t,e))}function cp(r,t,e,i){if(r){const s=Ll(r,t,e,i);return r[0](s)}}function Ll(r,t,e,i){return r[1]&&i?io(e.ctx.slice(),r[1](i(t))):e.ctx}function up(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function dp(r,t,e,i,s,n){if(s){const o=Ll(t,e,i,n);r.p(o,s)}}function fp(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Nl(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function As(r){return r??""}const pp=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ie(r,t){r.appendChild(t)}function rt(r,t,e){r.insertBefore(t,e||null)}function tt(r){r.parentNode&&r.parentNode.removeChild(r)}function so(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function mt(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ul(r){return document.createTextNode(r)}function me(){return Ul(" ")}function Ce(){return Ul("")}function Ot(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function A(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function mp(r){return Array.from(r.childNodes)}function Kr(r,t,e){r.classList.toggle(t,!!e)}function gp(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let $i;function Hi(r){$i=r}function kl(){if(!$i)throw new Error("Function called outside component initialization");return $i}function Xi(r){kl().$$.on_mount.push(r)}function Zr(){const r=kl();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=gp(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ye(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const Jr=[],Ss=[];let Qr=[];const Gl=[],yp=Promise.resolve();let no=!1;function _p(){no||(no=!0,yp.then($l))}function oo(r){Qr.push(r)}const ao=new Set;let ti=0;function $l(){if(ti!==0)return;const r=$i;do{try{for(;ti<Jr.length;){const t=Jr[ti];ti++,Hi(t),vp(t.$$)}}catch(t){throw Jr.length=0,ti=0,t}for(Hi(null),Jr.length=0,ti=0;Ss.length;)Ss.pop()();for(let t=0;t<Qr.length;t+=1){const e=Qr[t];ao.has(e)||(ao.add(e),e())}Qr.length=0}while(Jr.length);for(;Gl.length;)Gl.pop()();no=!1,ao.clear(),Hi(r)}function vp(r){if(r.fragment!==null){r.update(),Se(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(oo)}}function xp(r){const t=[],e=[];Qr.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),Qr=t}const Is=new Set;let Cr;function Pe(){Cr={r:0,c:[],p:Cr}}function Re(){Cr.r||Se(Cr.c),Cr=Cr.p}function ot(r,t){r&&r.i&&(Is.delete(r),r.i(t))}function pt(r,t,e,i){if(r&&r.o){if(Is.has(r))return;Is.add(r),Cr.c.push(()=>{Is.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function ei(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function he(r){r&&r.c()}function ie(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),oo(()=>{const n=r.$$.on_mount.map(Bl).filter(Nt);r.$$.on_destroy?r.$$.on_destroy.push(...n):Se(n),r.$$.on_mount=[]}),s.forEach(oo)}function se(r,t){const e=r.$$;e.fragment!==null&&(xp(e.after_update),Se(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function bp(r,t){r.$$.dirty[0]===-1&&(Jr.push(r),_p(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ce(r,t,e,i,s,n,o=null,a=[-1]){const l=$i;Hi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:At,not_equal:s,bound:Dl(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Dl(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&bp(r,u)),d}):[],h.update(),c=!0,Se(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=mp(t.target);h.fragment&&h.fragment.l(u),u.forEach(tt)}else h.fragment&&h.fragment.c();t.intro&&ot(r.$$.fragment),ie(r,t.target,t.anchor),$l()}Hi(l)}class ue{constructor(){Ml(this,"$$"),Ml(this,"$$set")}$destroy(){se(this,1),this.$destroy=At}$on(t,e){if(!Nt(e))return At;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!hp(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const wp="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(wp);var bt=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(bt||{});const lo={},ho=(r,t)=>lo[r]=t,co=r=>lo[r.type].area(r),Ep=(r,t,e)=>lo[r.type].intersects(r,t,e),Cs=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Tp={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};ho(bt.ELLIPSE,Tp);const Ap={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};ho(bt.POLYGON,Ap);const Sp={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};ho(bt.RECTANGLE,Sp);const Ip=(r,t=!1)=>{const e=typeof r=="string"?r:r.value,i=/^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g,s=[...e.matchAll(i)][0],[n,o,a,l,h,c,u]=s;if(o!=="xywh")throw new Error("Unsupported MediaFragment: "+e);if(a&&a!=="pixel")throw new Error(`Unsupported MediaFragment unit: ${a}`);const[d,f,p,m]=[l,h,c,u].map(parseFloat);return{type:bt.RECTANGLE,geometry:{x:d,y:f,w:p,h:m,bounds:{minX:d,minY:t?f-m:f,maxX:d+p,maxY:t?f:f+m}}}},Cp=r=>{const{x:t,y:e,w:i,h:s}=r;return{type:"FragmentSelector",conformsTo:"http://www.w3.org/TR/media-frags/",value:`xywh=pixel:${t},${e},${i},${s}`}},Hl="http://www.w3.org/2000/svg",Xl=r=>{const t=i=>{Array.from(i.attributes).forEach(s=>{s.name.startsWith("on")&&i.removeAttribute(s.name)})},e=r.getElementsByTagName("script");return Array.from(e).reverse().forEach(i=>i.parentNode.removeChild(i)),Array.from(r.querySelectorAll("*")).forEach(t),r},Pp=r=>{const t=new XMLSerializer().serializeToString(r.documentElement).replace("<svg>",`<svg xmlns="${Hl}">`);return new DOMParser().parseFromString(t,"image/svg+xml").documentElement},Rp=r=>{const t=new DOMParser().parseFromString(r,"image/svg+xml"),e=t.lookupPrefix(Hl),i=t.lookupNamespaceURI(null);return e||i?Xl(t).firstChild:Xl(Pp(t)).firstChild},Mp=r=>{const[t,e,i]=r.match(/(<polygon points=["|'])([^("|')]*)/)||[],s=i.split(" ").map(n=>n.split(",").map(parseFloat));return{type:bt.POLYGON,geometry:{points:s,bounds:Cs(s)}}},Bp=r=>{const t=Rp(r),e=parseFloat(t.getAttribute("cx")),i=parseFloat(t.getAttribute("cy")),s=parseFloat(t.getAttribute("rx")),n=parseFloat(t.getAttribute("ry")),o={minX:e-s,minY:i-n,maxX:e+s,maxY:i+n};return{type:bt.ELLIPSE,geometry:{cx:e,cy:i,rx:s,ry:n,bounds:o}}},Dp=r=>{const t=typeof r=="string"?r:r.value;if(t.includes("<polygon points="))return Mp(t);if(t.includes("<ellipse "))return Bp(t);throw"Unsupported SVG shape: "+t},Op=r=>{let t;if(r.type===bt.POLYGON){const e=r.geometry,{points:i}=e;t=`<svg><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}else if(r.type===bt.ELLIPSE){const e=r.geometry;t=`<svg><ellipse cx="${e.cx}" cy="${e.cy}" rx="${e.rx}" ry="${e.ry}" /></svg>`}if(t)return{type:"SvgSelector",value:t};throw`Unsupported shape type: ${r.type}`};let Ps;const Fp=new Uint8Array(16);function Lp(){if(!Ps&&(Ps=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ps))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ps(Fp)}const Ht=[];for(let r=0;r<256;++r)Ht.push((r+256).toString(16).slice(1));function Np(r,t=0){return Ht[r[t+0]]+Ht[r[t+1]]+Ht[r[t+2]]+Ht[r[t+3]]+"-"+Ht[r[t+4]]+Ht[r[t+5]]+"-"+Ht[r[t+6]]+Ht[r[t+7]]+"-"+Ht[r[t+8]]+Ht[r[t+9]]+"-"+Ht[r[t+10]]+Ht[r[t+11]]+Ht[r[t+12]]+Ht[r[t+13]]+Ht[r[t+14]]+Ht[r[t+15]]}const Up=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Vl={randomUUID:Up};function zl(r,t,e){if(Vl.randomUUID&&!t&&!r)return Vl.randomUUID();r=r||{};const i=r.random||(r.rng||Lp)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return Np(i)}var Wl=Object.prototype.hasOwnProperty;function Pr(r,t){var e,i;if(r===t)return!0;if(r&&t&&(e=r.constructor)===t.constructor){if(e===Date)return r.getTime()===t.getTime();if(e===RegExp)return r.toString()===t.toString();if(e===Array){if((i=r.length)===t.length)for(;i--&&Pr(r[i],t[i]););return i===-1}if(!e||typeof r=="object"){i=0;for(e in r)if(Wl.call(r,e)&&++i&&!Wl.call(t,e)||!(e in t)||!Pr(r[e],t[e]))return!1;return Object.keys(t).length===i}}return r!==r&&t!==t}function uo(){}function kp(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}const ri=[];function fo(r,t=uo){let e;const i=new Set;function s(a){if(kp(r,a)&&(r=a,e)){const l=!ri.length;for(const h of i)h[1](),ri.push(h,r);if(l){for(let h=0;h<ri.length;h+=2)ri[h][0](ri[h+1]);ri.length=0}}}function n(a){s(a(r))}function o(a,l=uo){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||uo),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Gp=r=>{const{subscribe:t,set:e}=fo();let i;return t(s=>i=s),r.observe(({changes:s})=>{if(i){(s.deleted||[]).some(o=>o.id===i)&&e(void 0);const n=(s.updated||[]).find(({oldValue:o})=>o.id===i);n&&e(n.newValue.id)}}),{get current(){return i},subscribe:t,set:e}};var jl=(r=>(r.EDIT="EDIT",r.SELECT="SELECT",r.NONE="NONE",r))(jl||{});const po={selected:[]},$p=(r,t="EDIT")=>{const{subscribe:e,set:i}=fo(po);let s=po;e(u=>s=u);const n=()=>i(po),o=()=>{var u;return((u=s.selected)==null?void 0:u.length)===0},a=u=>{if(s.selected.length===0)return!1;const d=typeof u=="string"?u:u.id;return s.selected.some(f=>f.id===d)},l=(u,d)=>{const f=r.getAnnotation(u);if(f){const p=Hp(f,t);i(p==="EDIT"?{selected:[{id:u,editable:!0}],pointerEvent:d}:p==="SELECT"?{selected:[{id:u}],pointerEvent:d}:{selected:[],pointerEvent:d})}else console.warn("Invalid selection: "+u)},h=(u,d=!0)=>{const f=Array.isArray(u)?u:[u],p=f.map(m=>r.getAnnotation(m)).filter(Boolean);i({selected:p.map(({id:m})=>({id:m,editable:d}))}),p.length!==f.length&&console.warn("Invalid selection",u)},c=u=>{if(s.selected.length===0)return!1;const{selected:d}=s;d.filter(({id:f})=>u.includes(f)).length>0&&i({selected:d.filter(({id:f})=>!u.includes(f))})};return r.observe(({changes:u})=>c((u.deleted||[]).map(d=>d.id))),{clear:n,clickSelect:l,get selected(){return s?[...s.selected]:null},get pointerEvent(){return s?s.pointerEvent:null},isEmpty:o,isSelected:a,setSelected:h,subscribe:e}},Hp=(r,t)=>typeof t=="function"?t(r)||"EDIT":t||"EDIT",Xp=[];for(let r=0;r<256;++r)Xp.push((r+256).toString(16).slice(1));typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Vp=(r,t)=>{const e=new Set(r.bodies.map(i=>i.id));return t.bodies.filter(i=>!e.has(i.id))},zp=(r,t)=>{const e=new Set(t.bodies.map(i=>i.id));return r.bodies.filter(i=>!e.has(i.id))},Wp=(r,t)=>t.bodies.map(e=>{const i=r.bodies.find(s=>s.id===e.id);return{newBody:e,oldBody:i&&!Pr(i,e)?i:void 0}}).filter(({oldBody:e})=>e).map(({oldBody:e,newBody:i})=>({oldBody:e,newBody:i})),jp=(r,t)=>!Pr(r.target,t.target),Yl=(r,t)=>{const e=Vp(r,t),i=zp(r,t),s=Wp(r,t);return{oldValue:r,newValue:t,bodiesCreated:e.length>0?e:void 0,bodiesDeleted:i.length>0?i:void 0,bodiesUpdated:s.length>0?s:void 0,targetUpdated:jp(r,t)?{oldTarget:r.target,newTarget:t.target}:void 0}};var Pt=(r=>(r.LOCAL="LOCAL",r.REMOTE="REMOTE",r))(Pt||{});const Yp=(r,t)=>{var e,i;const{changes:s,origin:n}=t;if(!(!r.options.origin||r.options.origin===n))return!1;if(r.options.ignore){const{ignore:o}=r.options,a=l=>l&&l.length>0;if(!(a(s.created)||a(s.deleted))){const l=(e=s.updated)==null?void 0:e.some(c=>a(c.bodiesCreated)||a(c.bodiesDeleted)||a(c.bodiesUpdated)),h=(i=s.updated)==null?void 0:i.some(c=>c.targetUpdated);if(o==="BODY_ONLY"&&l&&!h||o==="TARGET_ONLY"&&h&&!l)return!1}}if(r.options.annotations){const o=new Set([...(s.created||[]).map(a=>a.id),...(s.deleted||[]).map(a=>a.id),...(s.updated||[]).map(({oldValue:a})=>a.id)]);return!!(Array.isArray(r.options.annotations)?r.options.annotations:[r.options.annotations]).find(a=>o.has(a))}else return!0},qp=(r,t)=>{const e=new Set((r.created||[]).map(u=>u.id)),i=new Set((r.updated||[]).map(({newValue:u})=>u.id)),s=new Set((t.created||[]).map(u=>u.id)),n=new Set((t.deleted||[]).map(u=>u.id)),o=new Set((t.updated||[]).map(({oldValue:u})=>u.id)),a=new Set((t.updated||[]).filter(({oldValue:u})=>e.has(u.id)||i.has(u.id)).map(({oldValue:u})=>u.id)),l=[...(r.created||[]).filter(u=>!n.has(u.id)).map(u=>o.has(u.id)?t.updated.find(({oldValue:d})=>d.id===u.id).newValue:u),...t.created||[]],h=[...(r.deleted||[]).filter(u=>!s.has(u.id)),...(t.deleted||[]).filter(u=>!e.has(u.id))],c=[...(r.updated||[]).filter(({newValue:u})=>!n.has(u.id)).map(u=>{const{oldValue:d,newValue:f}=u;if(o.has(f.id)){const p=t.updated.find(m=>m.oldValue.id===f.id).newValue;return Yl(d,p)}else return u}),...(t.updated||[]).filter(({oldValue:u})=>!a.has(u.id))];return{created:l,deleted:h,updated:c}},Kp=r=>r.id!==void 0,Zp=()=>{const r=new Map,t=new Map,e=[],i=(b,E={})=>e.push({onChange:b,options:E}),s=b=>{const E=e.findIndex(S=>S.onChange==b);E>-1&&e.splice(E,1)},n=(b,E)=>{const S={origin:b,changes:{created:E.created||[],updated:E.updated||[],deleted:E.deleted||[]},state:[...r.values()]};e.forEach(D=>{Yp(D,S)&&D.onChange(S)})},o=(b,E=Pt.LOCAL)=>{if(r.get(b.id))throw Error(`Cannot add annotation ${b.id} - exists already`);r.set(b.id,b),b.bodies.forEach(S=>t.set(S.id,b.id)),n(E,{created:[b]})},a=(b,E)=>{const S=typeof b=="string"?E:b,D=typeof b=="string"?b:b.id,B=r.get(D);if(B){const w=Yl(B,S);return D===S.id?r.set(D,S):(r.delete(D),r.set(S.id,S)),B.bodies.forEach(C=>t.delete(C.id)),S.bodies.forEach(C=>t.set(C.id,S.id)),w}else console.warn(`Cannot update annotation ${D} - does not exist`)},l=(b,E=Pt.LOCAL,S=Pt.LOCAL)=>{const D=Kp(E)?S:E,B=a(b,E);B&&n(D,{updated:[B]})},h=(b,E=Pt.LOCAL)=>{const S=b.reduce((D,B)=>{const w=a(B);return w?[...D,w]:D},[]);S.length>0&&n(E,{updated:S})},c=(b,E=Pt.LOCAL)=>{const S=r.get(b.annotation);if(S){const D={...S,bodies:[...S.bodies,b]};r.set(S.id,D),t.set(b.id,D.id),n(E,{updated:[{oldValue:S,newValue:D,bodiesCreated:[b]}]})}else console.warn(`Attempt to add body to missing annotation: ${b.annotation}`)},u=()=>[...r.values()],d=(b=Pt.LOCAL)=>{const E=[...r.values()];r.clear(),t.clear(),n(b,{deleted:E})},f=(b,E=!0,S=Pt.LOCAL)=>{if(E){const D=[...r.values()];r.clear(),t.clear(),b.forEach(B=>{r.set(B.id,B),B.bodies.forEach(w=>t.set(w.id,B.id))}),n(S,{created:b,deleted:D})}else{const D=b.reduce((B,w)=>{const C=r.get(w.id);return C?[...B,C]:B},[]);if(D.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${D.map(B=>B.id).join(", ")}`);b.forEach(B=>{r.set(B.id,B),B.bodies.forEach(w=>t.set(w.id,B.id))}),n(S,{created:b})}},p=b=>{const E=typeof b=="string"?b:b.id,S=r.get(E);if(S)return r.delete(E),S.bodies.forEach(D=>t.delete(D.id)),S;console.warn(`Attempt to delete missing annotation: ${E}`)},m=(b,E=Pt.LOCAL)=>{const S=p(b);S&&n(E,{deleted:[S]})},g=(b,E=Pt.LOCAL)=>{const S=b.reduce((D,B)=>{const w=p(B);return w?[...D,w]:D},[]);S.length>0&&n(E,{deleted:S})},y=(b,E=Pt.LOCAL)=>{const S=r.get(b.annotation);if(S){const D=S.bodies.find(B=>B.id===b.id);if(D){t.delete(D.id);const B={...S,bodies:S.bodies.filter(w=>w.id!==b.id)};r.set(S.id,B),n(E,{updated:[{oldValue:S,newValue:B,bodiesDeleted:[D]}]})}else console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${b.annotation}`)},v=b=>{const E=r.get(b);return E?{...E}:void 0},_=b=>{const E=t.get(b);if(E){const S=v(E).bodies.find(D=>D.id===b);if(S)return S;console.error(`Store integrity error: body ${b} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${b}`)},x=(b,E)=>{if(b.annotation!==E.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const S=r.get(b.annotation);if(S){const D=S.bodies.find(w=>w.id===b.id),B={...S,bodies:S.bodies.map(w=>w.id===D.id?E:w)};return r.set(S.id,B),D.id!==E.id&&(t.delete(D.id),t.set(E.id,B.id)),{oldValue:S,newValue:B,bodiesUpdated:[{oldBody:D,newBody:E}]}}else console.warn(`Attempt to add body to missing annotation ${b.annotation}`)},T=(b,E,S=Pt.LOCAL)=>{const D=x(b,E);D&&n(S,{updated:[D]})},P=(b,E=Pt.LOCAL)=>{const S=b.map(D=>x({id:D.id,annotation:D.annotation},D)).filter(Boolean);n(E,{updated:S})},I=b=>{const E=r.get(b.annotation);if(E){const S={...E,target:{...E.target,...b}};return r.set(E.id,S),{oldValue:E,newValue:S,targetUpdated:{oldTarget:E.target,newTarget:b}}}else console.warn(`Attempt to update target on missing annotation: ${b.annotation}`)};return{addAnnotation:o,addBody:c,all:u,bulkAddAnnotation:f,bulkDeleteAnnotation:g,bulkUpdateAnnotation:h,bulkUpdateBodies:P,bulkUpdateTargets:(b,E=Pt.LOCAL)=>{const S=b.map(D=>I(D)).filter(Boolean);S.length>0&&n(E,{updated:S})},clear:d,deleteAnnotation:m,deleteBody:y,getAnnotation:v,getBody:_,observe:i,unobserve:s,updateAnnotation:l,updateBody:T,updateTarget:(b,E=Pt.LOCAL)=>{const S=I(b);S&&n(E,{updated:[S]})}}},Jp=r=>({...r,subscribe:t=>{const e=i=>t(i.state);return r.observe(e),t(r.all()),()=>r.unobserve(e)}});let Qp=()=>({emit(r,...t){for(let e=0,i=this.events[r]||[],s=i.length;e<s;e++)i[e](...t)},events:{},on(r,t){var e;return((e=this.events)[r]||(e[r]=[])).push(t),()=>{var i;this.events[r]=(i=this.events[r])==null?void 0:i.filter(s=>t!==s)}}});const tm=250,em=r=>{const t=Qp(),e=[];let i=-1,s=!1,n=0;const o=f=>{if(!s){const{changes:p}=f,m=performance.now();if(m-n>tm)e.splice(i+1),e.push(p),i=e.length-1;else{const g=e.length-1;e[g]=qp(e[g],p)}n=m}s=!1};r.observe(o,{origin:Pt.LOCAL});const a=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f),l=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),h=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({oldValue:p})=>p)),c=f=>f&&f.length>0&&r.bulkUpdateAnnotation(f.map(({newValue:p})=>p)),u=f=>f&&f.length>0&&r.bulkAddAnnotation(f,!1),d=f=>f&&f.length>0&&r.bulkDeleteAnnotation(f);return{canRedo:()=>e.length-1>i,canUndo:()=>i>-1,destroy:()=>r.unobserve(o),on:(f,p)=>t.on(f,p),redo:()=>{if(e.length-1>i){s=!0;const{created:f,updated:p,deleted:m}=e[i+1];l(f),c(p),d(m),t.emit("redo",e[i+1]),i+=1}},undo:()=>{if(i>-1){s=!0;const{created:f,updated:p,deleted:m}=e[i];a(f),h(p),u(m),t.emit("undo",e[i]),i-=1}}}},rm=()=>{const{subscribe:r,set:t}=fo([]);return{subscribe:r,set:t}},im=(r,t,e,i)=>{const{store:s,selection:n,hover:o,viewport:a}=r,l=new Map;let h=[],c,u;const d=(y,v)=>{l.has(y)?l.get(y).push(v):l.set(y,[v])},f=(y,v)=>{const _=l.get(y);_&&_.indexOf(v)>0&&_.splice(_.indexOf(v),1)},p=(y,v,_)=>{l.has(y)&&setTimeout(()=>{l.get(y).forEach(x=>{if(e){const T=Array.isArray(v)?v.map(I=>e.serialize(I)):e.serialize(v),P=_?_ instanceof PointerEvent?_:e.serialize(_):void 0;x(T,P)}else x(v,_)})},1)},m=()=>{const{selected:y}=n,v=(y||[]).map(({id:_})=>s.getAnnotation(_));v.forEach(_=>{const x=h.find(T=>T.id===_.id);(!x||!Pr(x,_))&&p("updateAnnotation",_,x)}),h=h.map(_=>v.find(({id:x})=>x===_.id)||_)};n.subscribe(({selected:y})=>{if(!(h.length===0&&y.length===0)){if(h.length===0&&y.length>0)h=y.map(({id:v})=>s.getAnnotation(v));else if(h.length>0&&y.length===0)h.forEach(v=>{const _=s.getAnnotation(v.id);_&&!Pr(_,v)&&p("updateAnnotation",_,v)}),h=[];else{const v=new Set(h.map(x=>x.id)),_=new Set(y.map(({id:x})=>x));h.filter(x=>!_.has(x.id)).forEach(x=>{const T=s.getAnnotation(x.id);T&&!Pr(T,x)&&p("updateAnnotation",T,x)}),h=[...h.filter(x=>_.has(x.id)),...y.filter(({id:x})=>!v.has(x)).map(({id:x})=>s.getAnnotation(x))]}p("selectionChanged",h)}}),o.subscribe(y=>{!c&&y?p("mouseEnterAnnotation",s.getAnnotation(y)):c&&!y?p("mouseLeaveAnnotation",s.getAnnotation(c)):c&&y&&(p("mouseLeaveAnnotation",s.getAnnotation(c)),p("mouseEnterAnnotation",s.getAnnotation(y))),c=y}),a==null||a.subscribe(y=>p("viewportIntersect",y.map(v=>s.getAnnotation(v)))),s.observe(y=>{i&&(u&&clearTimeout(u),u=setTimeout(m,1e3));const{created:v,deleted:_}=y.changes;(v||[]).forEach(x=>p("createAnnotation",x)),(_||[]).forEach(x=>p("deleteAnnotation",x)),(y.changes.updated||[]).filter(x=>[...x.bodiesCreated||[],...x.bodiesDeleted||[],...x.bodiesUpdated||[]].length>0).forEach(({oldValue:x,newValue:T})=>{const P=h.find(I=>I.id===x.id)||x;h=h.map(I=>I.id===x.id?T:I),p("updateAnnotation",T,P)})},{origin:Pt.LOCAL}),s.observe(y=>{if(h){const v=new Set(h.map(x=>x.id)),_=(y.changes.updated||[]).filter(({newValue:x})=>v.has(x.id)).map(({newValue:x})=>x);_.length>0&&(h=h.map(x=>_.find(T=>T.id===x.id)||x))}},{origin:Pt.REMOTE});const g=y=>v=>{const{updated:_}=v;y?(_||[]).forEach(x=>p("updateAnnotation",x.oldValue,x.newValue)):(_||[]).forEach(x=>p("updateAnnotation",x.newValue,x.oldValue))};return t.on("undo",g(!0)),t.on("redo",g(!1)),{on:d,off:f,emit:p}},sm=r=>t=>t.reduce((e,i)=>{const{parsed:s,error:n}=r.parse(i);return n?{parsed:e.parsed,failed:[...e.failed,i]}:s?{parsed:[...e.parsed,s],failed:e.failed}:{...e}},{parsed:[],failed:[]}),nm=(r,t,e)=>{const{store:i,selection:s}=r,n=g=>{if(e){const{parsed:y,error:v}=e.parse(g);y?i.addAnnotation(y,Pt.REMOTE):console.error(v)}else i.addAnnotation(g,Pt.REMOTE)},o=()=>s.clear(),a=()=>i.clear(),l=g=>{const y=i.getAnnotation(g);return e&&y?e.serialize(y):y},h=()=>e?i.all().map(e.serialize):i.all(),c=()=>{var g;const y=(((g=s.selected)==null?void 0:g.map(v=>v.id))||[]).map(v=>i.getAnnotation(v)).filter(Boolean);return e?y.map(e.serialize):y},u=(g,y=!0)=>fetch(g).then(v=>v.json()).then(v=>(f(v,y),v)),d=g=>{if(typeof g=="string"){const y=i.getAnnotation(g);if(i.deleteAnnotation(g),y)return e?e.serialize(y):y}else{const y=e?e.parse(g).parsed:g;if(y)return i.deleteAnnotation(y),g}},f=(g,y=!0)=>{if(e){const{parsed:v,failed:_}=sm(e)(g);_.length>0&&console.warn(`Discarded ${_.length} invalid annotations`,_),i.bulkAddAnnotation(v,y,Pt.REMOTE)}else i.bulkAddAnnotation(g,y,Pt.REMOTE)},p=g=>{g?s.setSelected(g):s.clear()},m=g=>{if(e){const y=e.parse(g).parsed,v=e.serialize(i.getAnnotation(y.id));return i.updateAnnotation(y),v}else{const y=i.getAnnotation(g.id);return i.updateAnnotation(g),y}};return{addAnnotation:n,cancelSelected:o,canRedo:t.canRedo,canUndo:t.canUndo,clearAnnotations:a,getAnnotationById:l,getAnnotations:h,getSelected:c,loadAnnotations:u,redo:t.redo,removeAnnotation:d,setAnnotations:f,setSelected:p,undo:t.undo,updateAnnotation:m}},om="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let am=r=>crypto.getRandomValues(new Uint8Array(r)),lm=(r,t,e)=>{let i=(2<<Math.log(r.length-1)/Math.LN2)-1,s=-~(1.6*i*t/r.length);return(n=t)=>{let o="";for(;;){let a=e(s),l=s;for(;l--;)if(o+=r[a[l]&i]||"",o.length===n)return o}}},hm=(r,t=21)=>lm(r,t,am),cm=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=om[e[r]&63];return t};const um=()=>({isGuest:!0,id:hm("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),dm=r=>{const t=JSON.stringify(r);let e=0;for(let i=0,s=t.length;i<s;i++){let n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return`${e}`},ql=r=>r?typeof r=="object"?{...r}:r:void 0,fm=(r,t)=>(Array.isArray(r)?r:[r]).map(e=>{const{id:i,type:s,purpose:n,value:o,created:a,creator:l,...h}=e;return{id:i||`temp-${dm(e)}`,annotation:t,type:s,purpose:n,value:o,created:a?new Date(a):void 0,creator:ql(l),...h}}),pm=r=>r.map(t=>{var e,i;const s={...t};return delete s.annotation,(e=s.id)!=null&&e.startsWith("temp-")&&delete s.id,{...s,created:(i=s.created)==null?void 0:i.toISOString()}});cm();const mm=(r,t=!1)=>({parse:e=>gm(e,t),serialize:e=>ym(e,r)}),gm=(r,t=!1)=>{const e=r.id||zl(),{creator:i,created:s,modified:n,body:o,...a}=r,l=fm(o,e),h=Array.isArray(r.target)?r.target[0]:r.target,c=Array.isArray(h.selector)?h.selector[0]:h.selector,u=(c==null?void 0:c.type)==="FragmentSelector"?Ip(c,t):(c==null?void 0:c.type)==="SvgSelector"?Dp(c):void 0;return u?{parsed:{...a,id:e,bodies:l,target:{created:s?new Date(s):void 0,creator:ql(i),updated:n?new Date(n):void 0,...Array.isArray(a.target)?a.target[0]:a.target,annotation:e,selector:u}}}:{error:Error(`Invalid selector: ${JSON.stringify(c)}`)}},ym=(r,t)=>{const{selector:e,creator:i,created:s,updated:n,updatedBy:o,...a}=r.target,l=e.type==bt.RECTANGLE?Cp(e.geometry):Op(e),h={...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:r.id,type:"Annotation",body:pm(r.bodies),created:s==null?void 0:s.toISOString(),creator:i,modified:n==null?void 0:n.toISOString(),target:{...a,source:t,selector:l}};return delete h.bodies,"annotation"in h.target&&delete h.target.annotation,h};function Kl(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function Zl(r){let t,e;return t=new Vi({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){Nt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function _m(r){let t,e,i,s,n,o,a,l,h,c,u,d=ei(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=Zl(Kl(r,d,m));const p=m=>pt(f[m],1,1,()=>{f[m]=null});return{c(){t=mt("polygon"),s=me(),n=mt("polygon"),a=me();for(let m=0;m<f.length;m+=1)f[m].c();l=Ce(),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"points",i=r[4].points.map(Jl).join(" ")),A(n,"class","a9s-inner a9s-shape-handle"),A(n,"style",r[1]),A(n,"points",o=r[4].points.map(Ql).join(" "))},m(m,g){rt(m,t,g),rt(m,s,g),rt(m,n,g),rt(m,a,g);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,g);rt(m,l,g),h=!0,c||(u=[Ot(t,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(n,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,g){if(r=m,(!h||g&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!h||g&16&&i!==(i=r[4].points.map(Jl).join(" ")))&&A(t,"points",i),(!h||g&2)&&A(n,"style",r[1]),(!h||g&16&&o!==(o=r[4].points.map(Ql).join(" ")))&&A(n,"points",o),g&536){d=ei(r[4].points);let y;for(y=0;y<d.length;y+=1){const v=Kl(r,d,y);f[y]?(f[y].p(v,g),ot(f[y],1)):(f[y]=Zl(v),f[y].c(),ot(f[y],1),f[y].m(l.parentNode,l))}for(Pe(),y=d.length;y<f.length;y+=1)p(y);Re()}},i(m){if(!h){for(let g=0;g<d.length;g+=1)ot(f[g]);h=!0}},o(m){f=f.filter(Boolean);for(let g=0;g<f.length;g+=1)pt(f[g]);h=!1},d(m){m&&(tt(t),tt(s),tt(n),tt(a),tt(l)),so(f,m),c=!1,Se(u)}}}function vm(r){let t,e;return t=new nh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[_m,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}const Jl=r=>r.join(","),Ql=r=>r.join(",");function xm(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const g=d.geometry;f==="SHAPE"?m=g.points.map(([v,_])=>[v+p[0],_+p[1]]):m=g.points.map(([v,_],x)=>f===`HANDLE-${x}`?[v+p[0],_+p[1]]:[v,_]);const y=Cs(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ye.call(this,r,d)}function c(d){Ye.call(this,r,d)}function u(d){Ye.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class bm extends ue{constructor(t){super(),ce(this,t,xm,vm,Yt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const mo=(r,t)=>{const e=Math.abs(t[0]-r[0]),i=Math.abs(t[1]-r[1]);return Math.sqrt(Math.pow(e,2)+Math.pow(i,2))},ii=[];function wm(r,t=At){let e;const i=new Set;function s(a){if(Yt(r,a)&&(r=a,e)){const l=!ii.length;for(const h of i)h[1](),ii.push(h,r);if(l){for(let h=0;h<ii.length;h+=2)ii[h][0](ii[h+1]);ii.length=0}}}function n(a){s(a(r))}function o(a,l=At){const h=[a,l];return i.add(h),i.size===1&&(e=t(s,n)||At),a(r),()=>{i.delete(h),i.size===0&&e&&(e(),e=null)}}return{set:s,update:n,subscribe:o}}const Em=(r,t)=>{const{naturalWidth:e,naturalHeight:i}=r;if(!e&&!i){const{width:s,height:n}=r;t.setAttribute("viewBox",`0 0 ${s} ${n}`),r.addEventListener("load",o=>{const a=o.target;t.setAttribute("viewBox",`0 0 ${a.naturalWidth} ${a.naturalHeight}`)})}else t.setAttribute("viewBox",`0 0 ${e} ${i}`)},Tm=(r,t)=>{Em(r,t);const{subscribe:e,set:i}=wm(1);let s;return window.ResizeObserver&&(s=new ResizeObserver(()=>{const n=t.getBoundingClientRect(),{width:o,height:a}=t.viewBox.baseVal,l=Math.max(n.width/o,n.height/a);i(l)}),s.observe(t.parentElement)),{destroy:()=>{s&&s.disconnect()},subscribe:e}},th="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Am(r){let t,e,i,s,n,o;return{c(){t=mt("rect"),A(t,"class",e=As(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(t,"x",i=r[0]-r[5]/2),A(t,"y",s=r[1]-r[5]/2),A(t,"width",r[5]),A(t,"height",r[5])},m(a,l){rt(a,t,l),n||(o=Ot(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=As(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&A(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&A(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&A(t,"y",s),l&32&&A(t,"width",a[5]),l&32&&A(t,"height",a[5])},d(a){a&&tt(t),n=!1,o()}}}function Sm(r){let t,e,i,s,n,o,a,l,h;return{c(){t=mt("g"),e=mt("circle"),s=mt("rect"),A(e,"cx",r[0]),A(e,"cy",r[1]),A(e,"r",i=r[3]/r[2]),A(e,"class","a9s-touch-halo svelte-1sgkh33"),Kr(e,"touched",r[4]),A(s,"class",n=As(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),A(s,"x",o=r[0]-r[5]/2),A(s,"y",a=r[1]-r[5]/2),A(s,"width",r[5]),A(s,"height",r[5]),A(t,"class","a9s-touch-handle")},m(c,u){rt(c,t,u),Ie(t,e),Ie(t,s),l||(h=[Ot(e,"pointerdown",r[10]),Ot(e,"pointerdown",r[6]),Ot(e,"pointerup",r[7]),Ot(s,"pointerdown",r[9]),Ot(s,"pointerdown",r[6]),Ot(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&A(e,"cx",c[0]),u&2&&A(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&A(e,"r",i),u&16&&Kr(e,"touched",c[4]),u&256&&n!==(n=As(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&A(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&A(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&A(s,"y",a),u&32&&A(s,"width",c[5]),u&32&&A(s,"height",c[5])},d(c){c&&tt(t),l=!1,Se(h)}}}function Im(r){let t;function e(s,n){return th?Sm:Am}let i=e()(r);return{c(){i.c(),t=Ce()},m(s,n){i.m(s,n),rt(s,t,n)},p(s,[n]){i.p(s,n)},i:At,o:At,d(s){s&&tt(t),i.d(s)}}}function Cm(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){Ye.call(this,r,p)}function d(p){Ye.call(this,r,p)}function f(p){Ye.call(this,r,p)}return r.$$set=p=>{e(8,t=io(io({},t),Nl(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Nl(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class Vi extends ue{constructor(t){super(),ce(this,t,Cm,Im,Yt,{x:0,y:1,scale:2,radius:3})}}function Pm(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g,y,v,_,x,T,P,I,b,E,S,D,B,w,C,F,k,G,$,nt,R,L,W,Q,J,H,_t,Tt;return $=new Vi({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),$.$on("pointerdown",function(){Nt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),R=new Vi({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),R.$on("pointerdown",function(){Nt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),W=new Vi({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),W.$on("pointerdown",function(){Nt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),J=new Vi({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),J.$on("pointerdown",function(){Nt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=mt("rect"),a=me(),l=mt("rect"),f=me(),p=mt("rect"),v=me(),_=mt("rect"),I=me(),b=mt("rect"),B=me(),w=mt("rect"),G=me(),he($.$$.fragment),nt=me(),he(R.$$.fragment),L=me(),he(W.$$.fragment),Q=me(),he(J.$$.fragment),A(t,"class","a9s-outer"),A(t,"style",e=r[1]?"display:none;":void 0),A(t,"x",i=r[4].x),A(t,"y",s=r[4].y),A(t,"width",n=r[4].w),A(t,"height",o=r[4].h),A(l,"class","a9s-inner a9s-shape-handle"),A(l,"style",r[1]),A(l,"x",h=r[4].x),A(l,"y",c=r[4].y),A(l,"width",u=r[4].w),A(l,"height",d=r[4].h),A(p,"class","a9s-edge-handle a9s-edge-handle-top"),A(p,"x",m=r[4].x),A(p,"y",g=r[4].y),A(p,"height",1),A(p,"width",y=r[4].w),A(_,"class","a9s-edge-handle a9s-edge-handle-right"),A(_,"x",x=r[4].x+r[4].w),A(_,"y",T=r[4].y),A(_,"height",P=r[4].h),A(_,"width",1),A(b,"class","a9s-edge-handle a9s-edge-handle-bottom"),A(b,"x",E=r[4].x),A(b,"y",S=r[4].y+r[4].h),A(b,"height",1),A(b,"width",D=r[4].w),A(w,"class","a9s-edge-handle a9s-edge-handle-left"),A(w,"x",C=r[4].x),A(w,"y",F=r[4].y),A(w,"height",k=r[4].h),A(w,"width",1)},m(N,O){rt(N,t,O),rt(N,a,O),rt(N,l,O),rt(N,f,O),rt(N,p,O),rt(N,v,O),rt(N,_,O),rt(N,I,O),rt(N,b,O),rt(N,B,O),rt(N,w,O),rt(N,G,O),ie($,N,O),rt(N,nt,O),ie(R,N,O),rt(N,L,O),ie(W,N,O),rt(N,Q,O),ie(J,N,O),H=!0,_t||(Tt=[Ot(t,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(l,"pointerdown",function(){Nt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Ot(p,"pointerdown",function(){Nt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Ot(_,"pointerdown",function(){Nt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Ot(b,"pointerdown",function(){Nt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Ot(w,"pointerdown",function(){Nt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(N,O){r=N,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&A(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&A(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&A(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&A(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&A(t,"height",o),(!H||O&2)&&A(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&A(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&A(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&A(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&A(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&A(p,"x",m),(!H||O&16&&g!==(g=r[4].y))&&A(p,"y",g),(!H||O&16&&y!==(y=r[4].w))&&A(p,"width",y),(!H||O&16&&x!==(x=r[4].x+r[4].w))&&A(_,"x",x),(!H||O&16&&T!==(T=r[4].y))&&A(_,"y",T),(!H||O&16&&P!==(P=r[4].h))&&A(_,"height",P),(!H||O&16&&E!==(E=r[4].x))&&A(b,"x",E),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&A(b,"y",S),(!H||O&16&&D!==(D=r[4].w))&&A(b,"width",D),(!H||O&16&&C!==(C=r[4].x))&&A(w,"x",C),(!H||O&16&&F!==(F=r[4].y))&&A(w,"y",F),(!H||O&16&&k!==(k=r[4].h))&&A(w,"height",k);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y),O&8&&(xt.scale=r[3]),$.$set(xt);const ft={};O&16&&(ft.x=r[4].x+r[4].w),O&16&&(ft.y=r[4].y),O&8&&(ft.scale=r[3]),R.$set(ft);const gt={};O&16&&(gt.x=r[4].x+r[4].w),O&16&&(gt.y=r[4].y+r[4].h),O&8&&(gt.scale=r[3]),W.$set(gt);const yt={};O&16&&(yt.x=r[4].x),O&16&&(yt.y=r[4].y+r[4].h),O&8&&(yt.scale=r[3]),J.$set(yt)},i(N){H||(ot($.$$.fragment,N),ot(R.$$.fragment,N),ot(W.$$.fragment,N),ot(J.$$.fragment,N),H=!0)},o(N){pt($.$$.fragment,N),pt(R.$$.fragment,N),pt(W.$$.fragment,N),pt(J.$$.fragment,N),H=!1},d(N){N&&(tt(t),tt(a),tt(l),tt(f),tt(p),tt(v),tt(_),tt(I),tt(b),tt(B),tt(w),tt(G),tt(nt),tt(L),tt(Q)),se($,N),se(R,N),se(W,N),se(J,N),_t=!1,Se(Tt)}}}function Rm(r){let t,e;return t=new nh({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Pm,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function Mm(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[g,y]=[m.minX,m.minY],[v,_]=[m.maxX,m.maxY];const[x,T]=p;if(f==="SHAPE")g+=x,v+=x,y+=T,_+=T;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=T;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{_+=T;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const P=Math.min(g,v),I=Math.min(y,_),b=Math.abs(v-g),E=Math.abs(_-y);return{...d,geometry:{x:P,y:I,w:b,h:E,bounds:{minX:P,minY:I,maxX:P+b,maxY:I+E}}}};function h(d){Ye.call(this,r,d)}function c(d){Ye.call(this,r,d)}function u(d){Ye.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Bm extends ue{constructor(t){super(),ce(this,t,Mm,Rm,Yt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const eh=new Map([[bt.RECTANGLE,Bm],[bt.POLYGON,bm]]),rh=r=>eh.get(r.type),ih=(r,t)=>eh.set(r,t),Dm=r=>({}),sh=r=>({grab:r[0]});function Om(r){let t,e,i,s;const n=r[7].default,o=cp(n,r,r[6],sh);return{c(){t=mt("g"),o&&o.c(),A(t,"class","a9s-annotation selected")},m(a,l){rt(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Ot(t,"pointerup",r[2]),Ot(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&dp(o,n,a,a[6],e?up(n,a[6],l,Dm):fp(a[6]),sh)},i(a){e||(ot(o,a),e=!0)},o(a){pt(o,a),e=!1},d(a){a&&tt(t),o&&o.d(a),i=!1,Se(s)}}}function Fm(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Zr();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>g=>{h=m,c=l.elementToImage(g.offsetX,g.offsetY),u=o,g.target.setPointerCapture(g.pointerId),n("grab",g)},f=m=>{if(h){const[g,y]=l.elementToImage(m.offsetX,m.offsetY),v=[g-c[0],y-c[1]];e(3,o=a(u,h,v)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class nh extends ue{constructor(t){super(),ce(this,t,Fm,Om,Yt,{shape:3,editor:4,transform:5})}}const Rs=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s}=e;let n="";return i&&(n+=`fill:${i};stroke:${i};`),n+=`fill-opacity:${s||"0.25"};`,n}};function Lm(r,t,e){let i;const s=Zr();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Xi(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&(i=Rs(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c})},[n,o,a,l,h,c,u]}class Nm extends ue{constructor(t){super(),ce(this,t,Lm,null,Yt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}function Um(r,t,e){const i=Zr();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewportScale:l}=t,h;return Xi(()=>{const c=n.closest("svg"),u=[],d=(f,p,m)=>{c==null||c.addEventListener(f,p,m),u.push(()=>c==null?void 0:c.removeEventListener(f,p,m))};return e(5,h=new o({target:n,props:{addEventListener:d,drawingMode:s,transform:a,viewportScale:l}})),h.$on("create",f=>i("create",f.detail)),()=>{u.forEach(f=>f()),h.$destroy()}}),r.$$set=c=>{"drawingMode"in c&&e(0,s=c.drawingMode),"target"in c&&e(1,n=c.target),"tool"in c&&e(2,o=c.tool),"transform"in c&&e(3,a=c.transform),"viewportScale"in c&&e(4,l=c.viewportScale)},r.$$.update=()=>{r.$$.dirty&40&&h&&h.$set({transform:a}),r.$$.dirty&48&&h&&h.$set({viewportScale:l})},[s,n,o,a,l,h]}class km extends ue{constructor(t){super(),ce(this,t,Um,null,Yt,{drawingMode:0,target:1,tool:2,transform:3,viewportScale:4})}}function oh(r){let t,e;return{c(){t=mt("rect"),e=mt("rect"),A(t,"class","a9s-outer"),A(t,"x",r[1]),A(t,"y",r[2]),A(t,"width",r[3]),A(t,"height",r[4]),A(e,"class","a9s-inner"),A(e,"x",r[1]),A(e,"y",r[2]),A(e,"width",r[3]),A(e,"height",r[4])},m(i,s){rt(i,t,s),rt(i,e,s)},p(i,s){s&2&&A(t,"x",i[1]),s&4&&A(t,"y",i[2]),s&8&&A(t,"width",i[3]),s&16&&A(t,"height",i[4]),s&2&&A(e,"x",i[1]),s&4&&A(e,"y",i[2]),s&8&&A(e,"width",i[3]),s&16&&A(e,"height",i[4])},d(i){i&&(tt(t),tt(e))}}}function Gm(r){let t,e=r[0]&&oh(r);return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){rt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[0]?e?e.p(i,s):(e=oh(i),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&tt(t),e&&e.d()}}}function $m(r,t,e){const i=Zr();let{addEventListener:s}=t,{drawingMode:n}=t,{transform:o}=t,a,l,h,c,u,d,f;const p=v=>{const _=v;a=performance.now(),n==="drag"&&(e(0,l=o.elementToImage(_.offsetX,_.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))},m=v=>{const _=v;l&&(h=o.elementToImage(_.offsetX,_.offsetY),e(1,c=Math.min(h[0],l[0])),e(2,u=Math.min(h[1],l[1])),e(3,d=Math.abs(h[0]-l[0])),e(4,f=Math.abs(h[1]-l[1])))},g=v=>{const _=v,x=performance.now()-a;if(n==="click"){if(x>300)return;_.stopPropagation(),l?y():(e(0,l=o.elementToImage(_.offsetX,_.offsetY)),h=l,e(1,c=l[0]),e(2,u=l[1]),e(3,d=1),e(4,f=1))}else l&&(x>300||d*f>100?(_.stopPropagation(),y()):(e(0,l=void 0),h=void 0))},y=()=>{if(d*f>15){const v={type:bt.RECTANGLE,geometry:{bounds:{minX:c,minY:u,maxX:c+d,maxY:u+f},x:c,y:u,w:d,h:f}};i("create",v)}e(0,l=void 0),h=void 0};return Xi(()=>{s("pointerdown",p),s("pointermove",m),s("pointerup",g,!0)}),r.$$set=v=>{"addEventListener"in v&&e(5,s=v.addEventListener),"drawingMode"in v&&e(6,n=v.drawingMode),"transform"in v&&e(7,o=v.transform)},[l,c,u,d,f,s,n,o]}class Hm extends ue{constructor(t){super(),ce(this,t,$m,Gm,Yt,{addEventListener:5,drawingMode:6,transform:7})}}function go(r){const t=r.slice(),e=(t[2]?t[0]:[...t[0],t[1]]).map(i=>i.join(",")).join(" ");return t[16]=e,t}function ah(r){let t,e,i,s,n,o=r[2]&&lh(r);return{c(){t=mt("polygon"),i=mt("polygon"),o&&o.c(),n=Ce(),A(t,"class","a9s-outer"),A(t,"points",e=r[16]),A(i,"class","a9s-inner"),A(i,"points",s=r[16])},m(a,l){rt(a,t,l),rt(a,i,l),o&&o.m(a,l),rt(a,n,l)},p(a,l){l&7&&e!==(e=a[16])&&A(t,"points",e),l&7&&s!==(s=a[16])&&A(i,"points",s),a[2]?o?o.p(a,l):(o=lh(a),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},d(a){a&&(tt(t),tt(i),tt(n)),o&&o.d(a)}}}function lh(r){let t,e,i;return{c(){t=mt("rect"),A(t,"class","a9s-corner-handle"),A(t,"x",e=r[0][0][0]-r[3]/2),A(t,"y",i=r[0][0][1]-r[3]/2),A(t,"height",r[3]),A(t,"width",r[3])},m(s,n){rt(s,t,n)},p(s,n){n&9&&e!==(e=s[0][0][0]-s[3]/2)&&A(t,"x",e),n&9&&i!==(i=s[0][0][1]-s[3]/2)&&A(t,"y",i),n&8&&A(t,"height",s[3]),n&8&&A(t,"width",s[3])},d(s){s&&tt(t)}}}function Xm(r){let t,e=r[1]&&ah(go(r));return{c(){t=mt("g"),e&&e.c(),A(t,"class","a9s-annotation a9s-rubberband")},m(i,s){rt(i,t,s),e&&e.m(t,null)},p(i,[s]){i[1]?e?e.p(go(i),s):(e=ah(go(i)),e.c(),e.m(t,null)):e&&(e.d(1),e=null)},i:At,o:At,d(i){i&&tt(t),e&&e.d()}}}const Vm=20,zm=1500;function Wm(r,t,e){let i;const s=Zr();let{addEventListener:n}=t,{drawingMode:o}=t,{transform:a}=t,{viewportScale:l=1}=t,h,c=[],u,d,f=!1;const p=_=>{const x=_,{timeStamp:T,offsetX:P,offsetY:I}=x;if(h={timeStamp:T,offsetX:P,offsetY:I},o==="drag"&&c.length===0){const b=a.elementToImage(x.offsetX,x.offsetY);c.push(b),e(1,u=b)}},m=_=>{const x=_;if(d&&clearTimeout(d),c.length>0){if(e(1,u=a.elementToImage(x.offsetX,x.offsetY)),c.length>2){const T=mo(u,c[0])*l;e(2,f=T<Vm)}x.pointerType==="touch"&&(d=setTimeout(()=>{y()},zm))}},g=_=>{const x=_;if(d&&clearTimeout(d),o==="click"){const T=x.timeStamp-h.timeStamp,P=mo([h.offsetX,h.offsetY],[x.offsetX,x.offsetY]);if(T>300||P>15)return;if(f)v();else if(c.length===0){const I=a.elementToImage(x.offsetX,x.offsetY);c.push(I),e(1,u=I)}else c.push(u)}else{if(c.length===1&&mo(c[0],u)<=4){e(0,c=[]),e(1,u=void 0);return}x.stopImmediatePropagation(),f?v():c.push(u)}},y=()=>{if(!u)return;const _=[...c,u],x={type:bt.POLYGON,geometry:{bounds:Cs(_),points:_}};co(x)>4&&(e(0,c=[]),e(1,u=void 0),s("create",x))},v=()=>{const _={type:bt.POLYGON,geometry:{bounds:Cs(c),points:[...c]}};e(0,c=[]),e(1,u=void 0),s("create",_)};return Xi(()=>{n("pointerdown",p,!0),n("pointermove",m),n("pointerup",g,!0),n("dblclick",y,!0)}),r.$$set=_=>{"addEventListener"in _&&e(4,n=_.addEventListener),"drawingMode"in _&&e(5,o=_.drawingMode),"transform"in _&&e(6,a=_.transform),"viewportScale"in _&&e(7,l=_.viewportScale)},r.$$.update=()=>{r.$$.dirty&128&&e(3,i=10/l)},[c,u,f,i,n,o,a,l]}class jm extends ue{constructor(t){super(),ce(this,t,Wm,Xm,Yt,{addEventListener:4,drawingMode:5,transform:6,viewportScale:7})}}const yo=new Map([["rectangle",{tool:Hm}],["polygon",{tool:jm}]]),Ms=()=>[...yo.keys()],Bs=r=>yo.get(r),hh=(r,t,e)=>yo.set(r,{tool:t,opts:e});function Ym(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("ellipse"),s=mt("ellipse"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"cx",r[2]),A(e,"cy",r[3]),A(e,"rx",r[4]),A(e,"ry",r[5]),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"cx",r[2]),A(s,"cy",r[3]),A(s,"rx",r[4]),A(s,"ry",r[5]),A(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),Ie(t,e),Ie(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:At,o:At,d(o){o&&tt(t)}}}function qm(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{cx:a,cy:l,rx:h,ry:c}=n;return r.$$set=u=>{"annotation"in u&&e(0,s=u.annotation),"geom"in u&&e(6,n=u.geom),"style"in u&&e(7,o=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(1,i=Rs(s,o))},[s,i,a,l,h,c,n,o]}class Km extends ue{constructor(t){super(),ce(this,t,qm,Ym,Yt,{annotation:0,geom:6,style:7})}}function Zm(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("polygon"),s=mt("polygon"),A(e,"class","a9s-outer"),A(e,"style",i=r[1]?"display:none;":void 0),A(e,"points",r[2].map(Jm).join(" ")),A(s,"class","a9s-inner"),A(s,"style",r[1]),A(s,"points",r[2].map(Qm).join(" ")),A(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),Ie(t,e),Ie(t,s)},p(o,[a]){a&2&&i!==(i=o[1]?"display:none;":void 0)&&A(e,"style",i),a&2&&A(s,"style",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:At,o:At,d(o){o&&tt(t)}}}const Jm=r=>r.join(","),Qm=r=>r.join(",");function tg(r,t,e){let i,{annotation:s}=t,{geom:n}=t,{style:o}=t;const{points:a}=n;return r.$$set=l=>{"annotation"in l&&e(0,s=l.annotation),"geom"in l&&e(3,n=l.geom),"style"in l&&e(4,o=l.style)},r.$$.update=()=>{r.$$.dirty&17&&e(1,i=Rs(s,o))},[s,i,a,n,o]}class eg extends ue{constructor(t){super(),ce(this,t,tg,Zm,Yt,{annotation:0,geom:3,style:4})}}function rg(r){let t,e,i,s,n;return{c(){t=mt("g"),e=mt("rect"),s=mt("rect"),A(e,"class","a9s-outer"),A(e,"style",i=r[5]?"display:none;":void 0),A(e,"x",r[4]),A(e,"y",r[3]),A(e,"width",r[2]),A(e,"height",r[1]),A(s,"class","a9s-inner"),A(s,"style",r[5]),A(s,"x",r[4]),A(s,"y",r[3]),A(s,"width",r[2]),A(s,"height",r[1]),A(t,"data-id",n=r[0].id)},m(o,a){rt(o,t,a),Ie(t,e),Ie(t,s)},p(o,[a]){a&32&&i!==(i=o[5]?"display:none;":void 0)&&A(e,"style",i),a&16&&A(e,"x",o[4]),a&8&&A(e,"y",o[3]),a&4&&A(e,"width",o[2]),a&2&&A(e,"height",o[1]),a&32&&A(s,"style",o[5]),a&16&&A(s,"x",o[4]),a&8&&A(s,"y",o[3]),a&4&&A(s,"width",o[2]),a&2&&A(s,"height",o[1]),a&1&&n!==(n=o[0].id)&&A(t,"data-id",n)},i:At,o:At,d(o){o&&tt(t)}}}function ig(r,t,e){let i,s,n,o,a,{annotation:l}=t,{geom:h}=t,{style:c}=t;return r.$$set=u=>{"annotation"in u&&e(0,l=u.annotation),"geom"in u&&e(6,h=u.geom),"style"in u&&e(7,c=u.style)},r.$$.update=()=>{r.$$.dirty&129&&e(5,i=Rs(l,c)),r.$$.dirty&64&&e(4,{x:s,y:n,w:o,h:a}=h,s,(e(3,n),e(6,h)),(e(2,o),e(6,h)),(e(1,a),e(6,h)))},[l,a,o,n,s,i,h,c]}class sg extends ue{constructor(t){super(),ce(this,t,ig,rg,Yt,{annotation:0,geom:6,style:7})}}const ng=r=>({elementToImage:(t,e)=>{const i=r.getBoundingClientRect(),s=r.createSVGPoint();s.x=t+i.x,s.y=e+i.y;const{x:n,y:o}=s.matrixTransform(r.getScreenCTM().inverse());return[n,o]}}),og=250,ag=(r,t)=>{const e=Zr();let i;return{onPointerDown:()=>i=performance.now(),onPointerUp:s=>{if(performance.now()-i<og){const{x:n,y:o}=lg(s,r),a=t.getAt(n,o);a?e("click",{originalEvent:s,annotation:a}):e("click",{originalEvent:s})}}}},lg=(r,t)=>{const e=t.createSVGPoint(),i=t.getBoundingClientRect(),s=r.clientX-i.x,n=r.clientY-i.y,{left:o,top:a}=t.getBoundingClientRect();return e.x=s+o,e.y=n+a,e.matrixTransform(t.getScreenCTM().inverse())},{Boolean:ch}=pp;function uh(r,t,e){const i=r.slice();return i[31]=t[e],i}function dh(r,t,e){const i=r.slice();return i[34]=t[e],i}function _o(r){const t=r.slice(),e=t[34].target.selector;return t[37]=e,t}function fh(r){let t=r[34].id,e,i,s=ph(r);return{c(){s.c(),e=Ce()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&16384&&Yt(t,t=n[34].id)?(Pe(),pt(s,1,1,At),Re(),s=ph(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s.d(n)}}}function hg(r){let t,e;return t=new eg({props:{annotation:r[34],geom:r[37].geometry,style:r[1]}}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&16384&&(n.annotation=i[34]),s[0]&16384&&(n.geom=i[37].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function cg(r){let t,e;return t=new sg({props:{annotation:r[34],geom:r[37].geometry,style:r[1]}}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&16384&&(n.annotation=i[34]),s[0]&16384&&(n.geom=i[37].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function ug(r){let t,e;return t=new Km({props:{annotation:r[34],geom:r[37].geometry,style:r[1]}}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&16384&&(n.annotation=i[34]),s[0]&16384&&(n.geom=i[37].geometry),s[0]&2&&(n.style=i[1]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function ph(r){let t,e,i,s;const n=[ug,cg,hg],o=[];function a(l,h){return l[37].type===bt.ELLIPSE?0:l[37].type===bt.RECTANGLE?1:l[37].type===bt.POLYGON?2:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ce()},m(l,h){~t&&o[t].m(l,h),rt(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Pe(),pt(o[c],1,1,()=>{o[c]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){pt(e),s=!1},d(l){l&&tt(i),~t&&o[t].d(l)}}}function mh(r){let t=!r[8](r[34]),e,i,s=t&&fh(_o(r));return{c(){s&&s.c(),e=Ce()},m(n,o){s&&s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&16640&&(t=!n[8](n[34])),t?s?(s.p(_o(n),o),o[0]&16640&&ot(s,1)):(s=fh(_o(n)),s.c(),ot(s,1),s.m(e.parentNode,e)):s&&(Pe(),pt(s,1,1,()=>{s=null}),Re())},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s&&s.d(n)}}}function gh(r){let t,e,i,s;const n=[fg,dg],o=[];function a(l,h){return l[7]?0:l[13]&&l[0]?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=Ce()},m(l,h){~t&&o[t].m(l,h),rt(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Pe(),pt(o[c],1,1,()=>{o[c]=null}),Re()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),ot(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(ot(e),s=!0)},o(l){pt(e),s=!1},d(l){l&&tt(i),~t&&o[t].d(l)}}}function dg(r){let t=r[2],e,i,s=yh(r);return{c(){s.c(),e=Ce()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&4&&Yt(t,t=n[2])?(Pe(),pt(s,1,1,At),Re(),s=yh(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s.d(n)}}}function fg(r){let t,e,i=ei(r[7]),s=[];for(let o=0;o<i.length;o+=1)s[o]=vh(uh(r,i,o));const n=o=>pt(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=Ce()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);rt(o,t,a),e=!0},p(o,a){if(a[0]&1607842){i=ei(o[7]);let l;for(l=0;l<i.length;l+=1){const h=uh(o,i,l);s[l]?(s[l].p(h,a),ot(s[l],1)):(s[l]=vh(h),s[l].c(),ot(s[l],1),s[l].m(t.parentNode,t))}for(Pe(),l=i.length;l<s.length;l+=1)n(l);Re()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)ot(s[a]);e=!0}},o(o){s=s.filter(ch);for(let a=0;a<s.length;a+=1)pt(s[a]);e=!1},d(o){o&&tt(t),so(s,o)}}}function yh(r){let t,e;return t=new km({props:{target:r[5],tool:r[13],drawingMode:r[12],transform:r[11],viewportScale:r[15]}}),t.$on("create",r[18]),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&8192&&(n.tool=i[13]),s[0]&4096&&(n.drawingMode=i[12]),s[0]&2048&&(n.transform=i[11]),s[0]&32768&&(n.viewportScale=i[15]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function _h(r){let t,e;return t=new Nm({props:{target:r[5],editor:r[20](r[31].target.selector),annotation:r[31],style:r[1],transform:r[11],viewportScale:r[15]}}),t.$on("change",function(){Nt(r[19](r[31]))&&r[19](r[31]).apply(this,arguments)}),{c(){he(t.$$.fragment)},m(i,s){ie(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&128&&(n.editor=r[20](r[31].target.selector)),s[0]&128&&(n.annotation=r[31]),s[0]&2&&(n.style=r[1]),s[0]&2048&&(n.transform=r[11]),s[0]&32768&&(n.viewportScale=r[15]),t.$set(n)},i(i){e||(ot(t.$$.fragment,i),e=!0)},o(i){pt(t.$$.fragment,i),e=!1},d(i){se(t,i)}}}function vh(r){let t=r[31].id,e,i,s=_h(r);return{c(){s.c(),e=Ce()},m(n,o){s.m(n,o),rt(n,e,o),i=!0},p(n,o){o[0]&128&&Yt(t,t=n[31].id)?(Pe(),pt(s,1,1,At),Re(),s=_h(n),s.c(),ot(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(ot(s),i=!0)},o(n){pt(s),i=!1},d(n){n&&tt(e),s.d(n)}}}function pg(r){let t,e,i,s,n,o,a=ei(r[14]),l=[];for(let u=0;u<a.length;u+=1)l[u]=mh(dh(r,a,u));const h=u=>pt(l[u],1,1,()=>{l[u]=null});let c=r[5]&&gh(r);return{c(){t=mt("svg"),e=mt("g");for(let u=0;u<l.length;u+=1)l[u].c();i=mt("g"),c&&c.c(),A(i,"class","drawing"),A(t,"class","a9s-annotationlayer"),Kr(t,"drawing",r[13]),Kr(t,"hidden",!r[3])},m(u,d){rt(u,t,d),Ie(t,e);for(let f=0;f<l.length;f+=1)l[f]&&l[f].m(e,null);Ie(t,i),c&&c.m(i,null),r[27](i),r[28](t),s=!0,n||(o=[Ot(t,"pointerup",function(){Nt(r[9])&&r[9].apply(this,arguments)}),Ot(t,"pointerdown",function(){Nt(r[10])&&r[10].apply(this,arguments)})],n=!0)},p(u,d){if(r=u,d[0]&16642){a=ei(r[14]);let f;for(f=0;f<a.length;f+=1){const p=dh(r,a,f);l[f]?(l[f].p(p,d),ot(l[f],1)):(l[f]=mh(p),l[f].c(),ot(l[f],1),l[f].m(e,null))}for(Pe(),f=a.length;f<l.length;f+=1)h(f);Re()}r[5]?c?(c.p(r,d),d[0]&32&&ot(c,1)):(c=gh(r),c.c(),ot(c,1),c.m(i,null)):c&&(Pe(),pt(c,1,1,()=>{c=null}),Re()),(!s||d[0]&8192)&&Kr(t,"drawing",r[13]),(!s||d[0]&8)&&Kr(t,"hidden",!r[3])},i(u){if(!s){for(let d=0;d<a.length;d+=1)ot(l[d]);ot(c),s=!0}},o(u){l=l.filter(ch);for(let d=0;d<l.length;d+=1)pt(l[d]);pt(c),s=!1},d(u){u&&tt(t),so(l,u),c&&c.d(),r[27](null),r[28](null),n=!1,Se(o)}}}function mg(r,t,e){let i,s,n,o,a,l,h,c,u,d,f=At,p=()=>(f(),f=Ol(E,R=>e(15,d=R)),E);r.$$.on_destroy.push(()=>f());let{drawingEnabled:m}=t,{image:g}=t,{preferredDrawingMode:y}=t,{state:v}=t,{style:_=void 0}=t,{toolName:x=Ms()[0]}=t,{user:T}=t,{visible:P=!0}=t,I,b,E;Xi(()=>p(e(6,E=Tm(g,b))));const{selection:S,store:D}=v;Fl(r,S,R=>e(26,c=R)),Fl(r,D,R=>e(14,u=R));let B,w;const C=R=>{B&&D.unobserve(B);const L=R.filter(({editable:W})=>W).map(({id:W})=>W);L.length>0?(e(7,w=L.map(W=>D.getAnnotation(W)).filter(Boolean)),B=W=>{const{updated:Q}=W.changes;e(7,w=Q==null?void 0:Q.map(J=>J.newValue))},D.observe(B,{annotations:L})):e(7,w=void 0)},F=R=>{const L=zl(),W={id:L,bodies:[],target:{annotation:L,selector:R.detail,creator:T,created:new Date}};D.addAnnotation(W),S.setSelected(W.id)},k=R=>L=>{var W;const{target:Q}=R,J=10*60*1e3,H=((W=Q.creator)==null?void 0:W.id)!==T.id||!Q.created||new Date().getTime()-Q.created.getTime()>J;D.updateTarget({...Q,selector:L.detail,created:H?Q.created:new Date,updated:H?new Date:void 0,updatedBy:H?T:void 0})},G=R=>rh(R);function $(R){Ss[R?"unshift":"push"](()=>{I=R,e(5,I)})}function nt(R){Ss[R?"unshift":"push"](()=>{b=R,e(4,b)})}return r.$$set=R=>{"drawingEnabled"in R&&e(0,m=R.drawingEnabled),"image"in R&&e(21,g=R.image),"preferredDrawingMode"in R&&e(22,y=R.preferredDrawingMode),"state"in R&&e(23,v=R.state),"style"in R&&e(1,_=R.style),"toolName"in R&&e(2,x=R.toolName),"user"in R&&e(24,T=R.user),"visible"in R&&e(3,P=R.visible)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(13,{tool:i,opts:s}=Bs(x)||{tool:void 0,opts:void 0},i,(e(25,s),e(2,x))),r.$$.dirty[0]&37748736&&e(12,n=(s==null?void 0:s.drawingMode)||y),r.$$.dirty[0]&16&&e(11,o=ng(b)),r.$$.dirty[0]&16&&e(10,{onPointerDown:a,onPointerUp:l}=ag(b,D),a,(e(9,l),e(4,b))),r.$$.dirty[0]&67108864&&e(8,h=R=>c.selected.find(L=>L.id===R.id&&L.editable)),r.$$.dirty[0]&67108864&&C(c.selected)},[m,_,x,P,b,I,E,w,h,l,a,o,n,i,u,d,S,D,F,k,G,g,y,v,T,s,c,$,nt]}class gg extends ue{constructor(t){super(),ce(this,t,mg,pg,Yt,{drawingEnabled:0,image:21,preferredDrawingMode:22,state:23,style:1,toolName:2,user:24,visible:3},null,[-1,-1])}}function yg(r,t,e,i,s){xh(r,t,e||0,i||r.length-1,s||_g)}function xh(r,t,e,i,s){for(;i>e;){if(i-e>600){var n=i-e+1,o=t-e+1,a=Math.log(n),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(n-l)/n)*(o-n/2<0?-1:1),c=Math.max(e,Math.floor(t-o*l/n+h)),u=Math.min(i,Math.floor(t+(n-o)*l/n+h));xh(r,t,c,u,s)}var d=r[t],f=e,p=i;for(zi(r,e,t),s(r[i],d)>0&&zi(r,e,i);f<p;){for(zi(r,f,p),f++,p--;s(r[f],d)<0;)f++;for(;s(r[p],d)>0;)p--}s(r[e],d)===0?zi(r,e,p):(p++,zi(r,p,i)),p<=t&&(e=p+1),t<=p&&(i=p-1)}}function zi(r,t,e){var i=r[t];r[t]=r[e],r[e]=i}function _g(r,t){return r<t?-1:r>t?1:0}class vg{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Os(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;Os(t,l)&&(e.leaf?i.push(a):xo(t,l)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Os(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if(Os(t,o)){if(e.leaf||xo(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=ni([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,l,h;for(;i||n.length;){if(i||(i=n.pop(),l=n[n.length-1],a=o.pop(),h=!0),i.leaf){const c=xg(t,i.children,e);if(c!==-1)return i.children.splice(c,1),n.push(i),this._condense(n),this}!h&&!i.leaf&&xo(i,s)?(n.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=ni(t.slice(e,i+1)),si(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=ni([]),a.leaf=!1,a.height=s;const l=Math.ceil(n/o),h=l*Math.ceil(Math.sqrt(o));bh(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);bh(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return si(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=vo(h),u=Eg(t,h)-c;u<o?(o=u,n=c<n?c:n,a=h):u===o&&c<n&&(n=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),ji(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=ni(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,si(i,this.toBBox),si(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=ni([t,e]),this.data.height=t.height+1,this.data.leaf=!1,si(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Wi(t,0,a,this.toBBox),h=Wi(t,a,i,this.toBBox),c=Tg(l,h),u=vo(l)+vo(h);c<n?(n=c,s=a,o=u<o?u:o):c===n&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:bg,n=t.leaf?this.compareMinY:wg,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Wi(t,0,e,n),a=Wi(t,i-e,i,n);let l=Ds(o)+Ds(a);for(let h=e;h<i-e;h++){const c=t.children[h];ji(o,t.leaf?n(c):c),l+=Ds(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];ji(a,t.leaf?n(c):c),l+=Ds(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)ji(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():si(t[e],this.toBBox)}}function xg(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function si(r,t){Wi(r,0,r.children.length,t,r)}function Wi(r,t,e,i,s){s||(s=ni(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];ji(s,r.leaf?i(o):o)}return s}function ji(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function bg(r,t){return r.minX-t.minX}function wg(r,t){return r.minY-t.minY}function vo(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Ds(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Eg(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function Tg(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function xo(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Os(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function ni(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function bh(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;yg(r,o,t,e,s),n.push(t,o,o,e)}}const Ag=()=>{const r=new vg,t=new Map,e=()=>[...t.values()],i=()=>{r.clear(),t.clear()},s=o=>{const{minX:a,minY:l,maxX:h,maxY:c}=o.selector.geometry.bounds,u={minX:a,minY:l,maxX:h,maxY:c,target:o};r.insert(u),t.set(o.annotation,u)},n=o=>{const a=t.get(o.annotation);a&&r.remove(a),t.delete(o.annotation)};return{all:e,clear:i,getAt:(o,a)=>{const l=r.search({minX:o,minY:a,maxX:o,maxY:a}).map(h=>h.target).filter(h=>h.selector.type===bt.RECTANGLE||Ep(h.selector,o,a));if(l.length>0)return l.sort((h,c)=>co(h.selector)-co(c.selector)),l[0]},getIntersecting:(o,a,l,h)=>r.search({minX:o,minY:a,maxX:o+l,maxY:a+h}).map(c=>c.target),insert:s,remove:n,set:(o,a=!0)=>{a&&i();const l=o.map(h=>{const{minX:c,minY:u,maxX:d,maxY:f}=h.selector.geometry.bounds;return{minX:c,minY:u,maxX:d,maxY:f,target:h}});l.forEach(h=>t.set(h.target.annotation,h)),r.load(l)},size:()=>r.all().length,update:(o,a)=>{n(o),s(a)}}},wh=r=>{const t=Zp(),e=Ag(),i=$p(t,r.pointerSelectAction),s=Gp(t),n=rm();return t.observe(({changes:o})=>{e.set((o.created||[]).map(a=>a.target),!1),(o.deleted||[]).forEach(a=>e.remove(a.target)),(o.updated||[]).forEach(({oldValue:a,newValue:l})=>e.update(a.target,l.target))}),{store:{...t,getAt:(o,a)=>{const l=e.getAt(o,a);return l?t.getAnnotation(l.annotation):void 0},getIntersecting:(o,a,l,h)=>e.getIntersecting(o,a,l,h).map(c=>t.getAnnotation(c.annotation))},selection:i,hover:s,viewport:n}},Sg=r=>{const t=wh(r);return{...t,store:Jp(t.store)}},Ig=r=>{let t,e;if(r.nodeName==="CANVAS")t=r,e=t.getContext("2d",{willReadFrequently:!0});else{const s=r;t=document.createElement("canvas"),t.width=s.width,t.height=s.height,e=t.getContext("2d",{willReadFrequently:!0}),e.drawImage(s,0,0,s.width,s.height)}let i=0;for(let s=1;s<10;s++)for(let n=1;n<10;n++){const o=Math.round(n*t.width/10),a=Math.round(s*t.height/10),l=e.getImageData(o,a,1,1).data,h=(.299*l[0]+.587*l[1]+.114*l[2])/255;i+=h}return i/81},Eh=r=>{const t=Ig(r),e=t>.6?"dark":"light";return console.log(`[Annotorious] Image brightness: ${t.toFixed(1)}. Setting ${e} theme.`),e},Th=(r,t,e)=>t.setAttribute("data-theme",e==="auto"?Eh(r):e),Ah=(r,t)=>({...r,drawingEnabled:r.drawingEnabled===void 0?t.drawingEnabled:r.drawingEnabled,drawingMode:r.drawingMode||t.drawingMode,pointerSelectAction:r.pointerSelectAction||t.pointerSelectAction,theme:r.theme||t.theme}),Sh=navigator.userAgent.indexOf("Mac OS X")!==-1,Ih=(r,t)=>{const e=t||document,i=o=>{const a=o;a.key==="z"&&a.ctrlKey?r.undo():a.key==="y"&&a.ctrlKey&&r.redo()},s=o=>{const a=o;a.key==="z"&&a.metaKey&&(a.shiftKey?r.redo():r.undo())},n=()=>{Sh?e.removeEventListener("keydown",s):e.removeEventListener("keydown",i)};return Sh?e.addEventListener("keydown",s):e.addEventListener("keydown",i),{destroy:n}},Cg=(r,t={})=>{if(!r)throw"Missing argument: image";const e=typeof r=="string"?document.getElementById(r):r,i=Ah(t,{drawingEnabled:!0,drawingMode:"drag",pointerSelectAction:jl.EDIT,theme:"light"}),s=Sg(i),{selection:n,store:o}=s,a=em(o),l=im(s,a,i.adapter,i.autoSave),h=document.createElement("DIV");h.style.position="relative",h.style.display="inline-block",e.style.display="block",e.parentNode.insertBefore(h,e),h.appendChild(e);const c=Ih(a);let u=um();Th(e,h,i.theme);const d=new gg({target:h,props:{drawingEnabled:!!i.drawingEnabled,image:e,preferredDrawingMode:i.drawingMode,state:s,style:i.style,user:u}});d.$on("click",E=>{const{originalEvent:S,annotation:D}=E.detail;D?n.clickSelect(D.id,S):n.isEmpty()||n.clear()});const f=nm(s,a,i.adapter),p=()=>{d.$destroy(),h.parentNode.insertBefore(e,h),h.parentNode.removeChild(h),c.destroy(),a.destroy()},m=()=>u,g=(E,S,D)=>hh(E,S,D),y=(E,S)=>ih(E,S),v=E=>{if(!Bs(E))throw`No drawing tool named ${E}`;d.$set({toolName:E})},_=E=>d.$set({drawingEnabled:E}),x=E=>{console.warn("Filter not implemented yet")},T=E=>d.$set({style:E}),P=E=>Th(e,h,E),I=E=>{u=E,d.$set({user:E})},b=E=>d.$set({visible:E});return{...f,destroy:p,getUser:m,listDrawingTools:Ms,on:l.on,off:l.off,registerDrawingTool:g,registerShapeEditor:y,setDrawingEnabled:_,setDrawingTool:v,setFilter:x,setStyle:T,setTheme:P,setUser:I,setVisible:b,state:s}};function Me(){}function bo(r,t){for(const e in t)r[e]=t[e];return r}function Ch(r){return r()}function Ph(){return Object.create(null)}function qe(r){r.forEach(Ch)}function qt(r){return typeof r=="function"}function Qt(r,t){return r!=r?t==t:r!==t||r&&typeof r=="object"||typeof r=="function"}function Pg(r){return Object.keys(r).length===0}function Rg(r,...t){if(r==null){for(const i of t)i(void 0);return Me}const e=r.subscribe(...t);return e.unsubscribe?()=>e.unsubscribe():e}function wo(r,t,e){r.$$.on_destroy.push(Rg(t,e))}function Rh(r,t,e,i){if(r){const s=Mh(r,t,e,i);return r[0](s)}}function Mh(r,t,e,i){return r[1]&&i?bo(e.ctx.slice(),r[1](i(t))):e.ctx}function Bh(r,t,e,i){if(r[2]&&i){const s=r[2](i(e));if(t.dirty===void 0)return s;if(typeof s=="object"){const n=[],o=Math.max(t.dirty.length,s.length);for(let a=0;a<o;a+=1)n[a]=t.dirty[a]|s[a];return n}return t.dirty|s}return t.dirty}function Dh(r,t,e,i,s,n){if(s){const o=Mh(t,e,i,n);r.p(o,s)}}function Oh(r){if(r.ctx.length>32){const t=[],e=r.ctx.length/32;for(let i=0;i<e;i++)t[i]=-1;return t}return-1}function Fh(r){const t={};for(const e in r)e[0]!=="$"&&(t[e]=r[e]);return t}function Fs(r){return r??""}const Mg=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function Ke(r,t){r.appendChild(t)}function ct(r,t,e){r.insertBefore(t,e||null)}function lt(r){r.parentNode&&r.parentNode.removeChild(r)}function Eo(r,t){for(let e=0;e<r.length;e+=1)r[e]&&r[e].d(t)}function Et(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function To(r){return document.createTextNode(r)}function ge(){return To(" ")}function ur(){return To("")}function Xt(r,t,e,i){return r.addEventListener(t,e,i),()=>r.removeEventListener(t,e,i)}function M(r,t,e){e==null?r.removeAttribute(t):r.getAttribute(t)!==e&&r.setAttribute(t,e)}function Bg(r){return Array.from(r.childNodes)}function Dg(r,t){t=""+t,r.data!==t&&(r.data=t)}function Ls(r,t,e){r.classList.toggle(t,!!e)}function Og(r,t,{bubbles:e=!1,cancelable:i=!1}={}){return new CustomEvent(r,{detail:t,bubbles:e,cancelable:i})}let Yi;function qi(r){Yi=r}function Ao(){if(!Yi)throw new Error("Function called outside component initialization");return Yi}function Ns(r){Ao().$$.on_mount.push(r)}function Fg(r){Ao().$$.on_destroy.push(r)}function Us(){const r=Ao();return(t,e,{cancelable:i=!1}={})=>{const s=r.$$.callbacks[t];if(s){const n=Og(t,e,{cancelable:i});return s.slice().forEach(o=>{o.call(r,n)}),!n.defaultPrevented}return!0}}function Ze(r,t){const e=r.$$.callbacks[t.type];e&&e.slice().forEach(i=>i.call(this,t))}const oi=[],ks=[];let ai=[];const Lh=[],Lg=Promise.resolve();let So=!1;function Ng(){So||(So=!0,Lg.then(Nh))}function Io(r){ai.push(r)}const Co=new Set;let li=0;function Nh(){if(li!==0)return;const r=Yi;do{try{for(;li<oi.length;){const t=oi[li];li++,qi(t),Ug(t.$$)}}catch(t){throw oi.length=0,li=0,t}for(qi(null),oi.length=0,li=0;ks.length;)ks.pop()();for(let t=0;t<ai.length;t+=1){const e=ai[t];Co.has(e)||(Co.add(e),e())}ai.length=0}while(oi.length);for(;Lh.length;)Lh.pop()();So=!1,Co.clear(),qi(r)}function Ug(r){if(r.fragment!==null){r.update(),qe(r.before_update);const t=r.dirty;r.dirty=[-1],r.fragment&&r.fragment.p(r.ctx,t),r.after_update.forEach(Io)}}function kg(r){const t=[],e=[];ai.forEach(i=>r.indexOf(i)===-1?t.push(i):e.push(i)),e.forEach(i=>i()),ai=t}const Gs=new Set;let Rr;function Je(){Rr={r:0,c:[],p:Rr}}function Qe(){Rr.r||qe(Rr.c),Rr=Rr.p}function st(r,t){r&&r.i&&(Gs.delete(r),r.i(t))}function ut(r,t,e,i){if(r&&r.o){if(Gs.has(r))return;Gs.add(r),Rr.c.push(()=>{Gs.delete(r),i&&(e&&r.d(1),i())}),r.o(t)}else i&&i()}function hi(r){return(r==null?void 0:r.length)!==void 0?r:Array.from(r)}function te(r){r&&r.c()}function Kt(r,t,e){const{fragment:i,after_update:s}=r.$$;i&&i.m(t,e),Io(()=>{const n=r.$$.on_mount.map(Ch).filter(qt);r.$$.on_destroy?r.$$.on_destroy.push(...n):qe(n),r.$$.on_mount=[]}),s.forEach(Io)}function Zt(r,t){const e=r.$$;e.fragment!==null&&(kg(e.after_update),qe(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Gg(r,t){r.$$.dirty[0]===-1&&(oi.push(r),Ng(),r.$$.dirty.fill(0)),r.$$.dirty[t/31|0]|=1<<t%31}function ne(r,t,e,i,s,n,o=null,a=[-1]){const l=Yi;qi(r);const h=r.$$={fragment:null,ctx:[],props:n,update:Me,not_equal:s,bound:Ph(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:Ph(),dirty:a,skip_bound:!1,root:t.target||l.$$.root};o&&o(h.root);let c=!1;if(h.ctx=e?e(r,t.props||{},(u,d,...f)=>{const p=f.length?f[0]:d;return h.ctx&&s(h.ctx[u],h.ctx[u]=p)&&(!h.skip_bound&&h.bound[u]&&h.bound[u](p),c&&Gg(r,u)),d}):[],h.update(),c=!0,qe(h.before_update),h.fragment=i?i(h.ctx):!1,t.target){if(t.hydrate){const u=Bg(t.target);h.fragment&&h.fragment.l(u),u.forEach(lt)}else h.fragment&&h.fragment.c();t.intro&&st(r.$$.fragment),Kt(r,t.target,t.anchor),Nh()}qi(l)}class oe{constructor(){wl(this,"$$");wl(this,"$$set")}$destroy(){Zt(this,1),this.$destroy=Me}$on(t,e){if(!qt(e))return Me;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(e),()=>{const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}$set(t){this.$$set&&!Pg(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const $g="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add($g);var Mr=(r=>(r[r.WEBGL_LEGACY=0]="WEBGL_LEGACY",r[r.WEBGL=1]="WEBGL",r[r.WEBGL2=2]="WEBGL2",r))(Mr||{}),Uh=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.WEBGL=1]="WEBGL",r[r.CANVAS=2]="CANVAS",r))(Uh||{}),Po=(r=>(r[r.COLOR=16384]="COLOR",r[r.DEPTH=256]="DEPTH",r[r.STENCIL=1024]="STENCIL",r))(Po||{}),Z=(r=>(r[r.NORMAL=0]="NORMAL",r[r.ADD=1]="ADD",r[r.MULTIPLY=2]="MULTIPLY",r[r.SCREEN=3]="SCREEN",r[r.OVERLAY=4]="OVERLAY",r[r.DARKEN=5]="DARKEN",r[r.LIGHTEN=6]="LIGHTEN",r[r.COLOR_DODGE=7]="COLOR_DODGE",r[r.COLOR_BURN=8]="COLOR_BURN",r[r.HARD_LIGHT=9]="HARD_LIGHT",r[r.SOFT_LIGHT=10]="SOFT_LIGHT",r[r.DIFFERENCE=11]="DIFFERENCE",r[r.EXCLUSION=12]="EXCLUSION",r[r.HUE=13]="HUE",r[r.SATURATION=14]="SATURATION",r[r.COLOR=15]="COLOR",r[r.LUMINOSITY=16]="LUMINOSITY",r[r.NORMAL_NPM=17]="NORMAL_NPM",r[r.ADD_NPM=18]="ADD_NPM",r[r.SCREEN_NPM=19]="SCREEN_NPM",r[r.NONE=20]="NONE",r[r.SRC_OVER=0]="SRC_OVER",r[r.SRC_IN=21]="SRC_IN",r[r.SRC_OUT=22]="SRC_OUT",r[r.SRC_ATOP=23]="SRC_ATOP",r[r.DST_OVER=24]="DST_OVER",r[r.DST_IN=25]="DST_IN",r[r.DST_OUT=26]="DST_OUT",r[r.DST_ATOP=27]="DST_ATOP",r[r.ERASE=26]="ERASE",r[r.SUBTRACT=28]="SUBTRACT",r[r.XOR=29]="XOR",r))(Z||{}),Be=(r=>(r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r))(Be||{}),U=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(U||{}),ci=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(ci||{}),K=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(K||{}),V=(r=>(r[r.FLOAT=0]="FLOAT",r[r.INT=1]="INT",r[r.UINT=2]="UINT",r))(V||{}),tr=(r=>(r[r.NEAREST=0]="NEAREST",r[r.LINEAR=1]="LINEAR",r))(tr||{}),dr=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(dr||{}),De=(r=>(r[r.OFF=0]="OFF",r[r.POW2=1]="POW2",r[r.ON=2]="ON",r[r.ON_MANUAL=3]="ON_MANUAL",r))(De||{}),re=(r=>(r[r.NPM=0]="NPM",r[r.UNPACK=1]="UNPACK",r[r.PMA=2]="PMA",r[r.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",r[r.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",r[r.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",r))(re||{}),Oe=(r=>(r[r.NO=0]="NO",r[r.YES=1]="YES",r[r.AUTO=2]="AUTO",r[r.BLEND=0]="BLEND",r[r.CLEAR=1]="CLEAR",r[r.BLIT=2]="BLIT",r))(Oe||{}),Ro=(r=>(r[r.AUTO=0]="AUTO",r[r.MANUAL=1]="MANUAL",r))(Ro||{}),de=(r=>(r.LOW="lowp",r.MEDIUM="mediump",r.HIGH="highp",r))(de||{}),Ft=(r=>(r[r.NONE=0]="NONE",r[r.SCISSOR=1]="SCISSOR",r[r.STENCIL=2]="STENCIL",r[r.SPRITE=3]="SPRITE",r[r.COLOR=4]="COLOR",r))(Ft||{}),Bt=(r=>(r[r.NONE=0]="NONE",r[r.LOW=2]="LOW",r[r.MEDIUM=4]="MEDIUM",r[r.HIGH=8]="HIGH",r))(Bt||{}),Fe=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Fe||{});const z={ADAPTER:{createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")},RESOLUTION:1,CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1};var Mo=/iPhone/i,kh=/iPod/i,Gh=/iPad/i,$h=/\biOS-universal(?:.+)Mac\b/i,Bo=/\bAndroid(?:.+)Mobile\b/i,Hh=/Android/i,ui=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,$s=/Silk/i,er=/Windows Phone/i,Xh=/\bWindows(?:.+)ARM\b/i,Vh=/BlackBerry/i,zh=/BB10/i,Wh=/Opera Mini/i,jh=/\b(CriOS|Chrome)(?:.+)Mobile/i,Yh=/Mobile(?:.+)Firefox\b/i,qh=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function Hg(r){return function(t){return t.test(r)}}function Kh(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]<"u"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]<"u"&&(e=i[0]);var s=Hg(e),n={apple:{phone:s(Mo)&&!s(er),ipod:s(kh),tablet:!s(Mo)&&(s(Gh)||qh(t))&&!s(er),universal:s($h),device:(s(Mo)||s(kh)||s(Gh)||s($h)||qh(t))&&!s(er)},amazon:{phone:s(ui),tablet:!s(ui)&&s($s),device:s(ui)||s($s)},android:{phone:!s(er)&&s(ui)||!s(er)&&s(Bo),tablet:!s(er)&&!s(ui)&&!s(Bo)&&(s($s)||s(Hh)),device:!s(er)&&(s(ui)||s($s)||s(Bo)||s(Hh))||s(/\bokhttp\b/i)},windows:{phone:s(er),tablet:s(Xh),device:s(er)||s(Xh)},other:{blackberry:s(Vh),blackberry10:s(zh),opera:s(Wh),firefox:s(Yh),chrome:s(jh),device:s(Vh)||s(zh)||s(Wh)||s(Yh)||s(jh)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const Xg=Kh.default??Kh,rr=Xg(globalThis.navigator);z.RETINA_PREFIX=/@([0-9\.]+)x/,z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var Hs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Vg(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var Jh={exports:{}};(function(r){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new s(c,u||l,d),p=e?e+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new i:delete l._events[h]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)t.call(c,u)&&h.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=e?e+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=e?e+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var m=e?e+h:h;if(!this._events[m])return!1;var g=this._events[m],y=arguments.length,v,_;if(g.fn){switch(g.once&&this.removeListener(h,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(_=1,v=new Array(y-1);_<y;_++)v[_-1]=arguments[_];g.fn.apply(g.context,v)}else{var x=g.length,T;for(_=0;_<x;_++)switch(g[_].once&&this.removeListener(h,g[_].fn,void 0,!0),y){case 1:g[_].fn.call(g[_].context);break;case 2:g[_].fn.call(g[_].context,c);break;case 3:g[_].fn.call(g[_].context,c,u);break;case 4:g[_].fn.call(g[_].context,c,u,d);break;default:if(!v)for(T=1,v=new Array(y-1);T<y;T++)v[T-1]=arguments[T];g[_].fn.apply(g[_].context,v)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=e?e+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var m=0,g=[],y=p.length;m<y;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=e?e+h:h,this._events[c]&&o(this,c)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,r.exports=a})(Jh);var zg=Jh.exports;const Ki=Zh(zg);var Do={exports:{}};Do.exports=Xs,Do.exports.default=Xs;function Xs(r,t,e){e=e||2;var i=t&&t.length,s=i?t[0]*e:r.length,n=Qh(r,0,s,e,!0),o=[];if(!n||n.next===n.prev)return o;var a,l,h,c,u,d,f;if(i&&(n=Kg(r,t,n,e)),r.length>80*e){a=h=r[0],l=c=r[1];for(var p=e;p<s;p+=e)u=r[p],d=r[p+1],u<a&&(a=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-l),f=f!==0?32767/f:0}return Zi(n,o,e,a,l,f,0),o}function Qh(r,t,e,i,s){var n,o;if(s===Lo(r,t,e,i)>0)for(n=t;n<e;n+=i)o=rc(n,r[n],r[n+1],o);else for(n=e-i;n>=t;n-=i)o=rc(n,r[n],r[n+1],o);return o&&Vs(o,o.next)&&(Qi(o),o=o.next),o}function Br(r,t){if(!r)return r;t||(t=r);var e=r,i;do if(i=!1,!e.steiner&&(Vs(e,e.next)||St(e.prev,e,e.next)===0)){if(Qi(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Zi(r,t,e,i,s,n,o){if(r){!o&&n&&ey(r,i,s,n);for(var a=r,l,h;r.prev!==r.next;){if(l=r.prev,h=r.next,n?jg(r,i,s,n):Wg(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),Qi(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Yg(Br(r),t,e),Zi(r,t,e,i,s,n,2)):o===2&&qg(r,t,e,i,s,n):Zi(Br(r),t,e,i,s,n,1);break}}}}function Wg(r){var t=r.prev,e=r,i=r.next;if(St(t,e,i)>=0)return!1;for(var s=t.x,n=e.x,o=i.x,a=t.y,l=e.y,h=i.y,c=s<n?s<o?s:o:n<o?n:o,u=a<l?a<h?a:h:l<h?l:h,d=s>n?s>o?s:o:n>o?n:o,f=a>l?a>h?a:h:l>h?l:h,p=i.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&di(s,a,n,l,o,h,p.x,p.y)&&St(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function jg(r,t,e,i){var s=r.prev,n=r,o=r.next;if(St(s,n,o)>=0)return!1;for(var a=s.x,l=n.x,h=o.x,c=s.y,u=n.y,d=o.y,f=a<l?a<h?a:h:l<h?l:h,p=c<u?c<d?c:d:u<d?u:d,m=a>l?a>h?a:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,y=Oo(f,p,t,e,i),v=Oo(m,g,t,e,i),_=r.prevZ,x=r.nextZ;_&&_.z>=y&&x&&x.z<=v;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==s&&_!==o&&di(a,c,l,u,h,d,_.x,_.y)&&St(_.prev,_,_.next)>=0||(_=_.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==s&&x!==o&&di(a,c,l,u,h,d,x.x,x.y)&&St(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;_&&_.z>=y;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==s&&_!==o&&di(a,c,l,u,h,d,_.x,_.y)&&St(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=v;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==s&&x!==o&&di(a,c,l,u,h,d,x.x,x.y)&&St(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Yg(r,t,e){var i=r;do{var s=i.prev,n=i.next.next;!Vs(s,n)&&tc(s,i,i.next,n)&&Ji(s,n)&&Ji(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Qi(i),Qi(i.next),i=r=n),i=i.next}while(i!==r);return Br(i)}function qg(r,t,e,i,s,n){var o=r;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&sy(o,a)){var l=ec(o,a);o=Br(o,o.next),l=Br(l,l.next),Zi(o,t,e,i,s,n,0),Zi(l,t,e,i,s,n,0);return}a=a.next}o=o.next}while(o!==r)}function Kg(r,t,e,i){var s=[],n,o,a,l,h;for(n=0,o=t.length;n<o;n++)a=t[n]*i,l=n<o-1?t[n+1]*i:r.length,h=Qh(r,a,l,i,!1),h===h.next&&(h.steiner=!0),s.push(iy(h));for(s.sort(Zg),n=0;n<s.length;n++)e=Jg(s[n],e);return e}function Zg(r,t){return r.x-t.x}function Jg(r,t){var e=Qg(r,t);if(!e)return t;var i=ec(e,r);return Br(i,i.next),Br(e,e.next)}function Qg(r,t){var e=t,i=r.x,s=r.y,n=-1/0,o;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var a=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(a<=i&&a>n&&(n=a,o=e.x<e.next.x?e:e.next,a===i))return o}e=e.next}while(e!==t);if(!o)return null;var l=o,h=o.x,c=o.y,u=1/0,d;e=o;do i>=e.x&&e.x>=h&&i!==e.x&&di(s<c?i:n,s,h,c,s<c?n:i,s,e.x,e.y)&&(d=Math.abs(s-e.y)/(i-e.x),Ji(e,r)&&(d<u||d===u&&(e.x>o.x||e.x===o.x&&ty(o,e)))&&(o=e,u=d)),e=e.next;while(e!==l);return o}function ty(r,t){return St(r.prev,r,t.prev)<0&&St(t.next,r,r.next)<0}function ey(r,t,e,i){var s=r;do s.z===0&&(s.z=Oo(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==r);s.prevZ.nextZ=null,s.prevZ=null,ry(s)}function ry(r){var t,e,i,s,n,o,a,l,h=1;do{for(e=r,r=null,n=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(l=h;a>0||l>0&&i;)a!==0&&(l===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,l--),n?n.nextZ=s:r=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(o>1);return r}function Oo(r,t,e,i,s){return r=(r-e)*s|0,t=(t-i)*s|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function iy(r){var t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function di(r,t,e,i,s,n,o,a){return(s-o)*(t-a)>=(r-o)*(n-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(n-a)>=(s-o)*(i-a)}function sy(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!ny(r,t)&&(Ji(r,t)&&Ji(t,r)&&oy(r,t)&&(St(r.prev,r,t.prev)||St(r,t.prev,t))||Vs(r,t)&&St(r.prev,r,r.next)>0&&St(t.prev,t,t.next)>0)}function St(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Vs(r,t){return r.x===t.x&&r.y===t.y}function tc(r,t,e,i){var s=Ws(St(r,t,e)),n=Ws(St(r,t,i)),o=Ws(St(e,i,r)),a=Ws(St(e,i,t));return!!(s!==n&&o!==a||s===0&&zs(r,e,t)||n===0&&zs(r,i,t)||o===0&&zs(e,r,i)||a===0&&zs(e,t,i))}function zs(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Ws(r){return r>0?1:r<0?-1:0}function ny(r,t){var e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&tc(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Ji(r,t){return St(r.prev,r,r.next)<0?St(r,t,r.next)>=0&&St(r,r.prev,t)>=0:St(r,t,r.prev)<0||St(r,r.next,t)<0}function oy(r,t){var e=r,i=!1,s=(r.x+t.x)/2,n=(r.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function ec(r,t){var e=new Fo(r.i,r.x,r.y),i=new Fo(t.i,t.x,t.y),s=r.next,n=t.prev;return r.next=t,t.prev=r,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function rc(r,t,e,i){var s=new Fo(r,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Qi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Fo(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Xs.deviation=function(r,t,e,i){var s=t&&t.length,n=s?t[0]*e:r.length,o=Math.abs(Lo(r,0,n,e));if(s)for(var a=0,l=t.length;a<l;a++){var h=t[a]*e,c=a<l-1?t[a+1]*e:r.length;o-=Math.abs(Lo(r,h,c,e))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*e,f=i[a+1]*e,p=i[a+2]*e;u+=Math.abs((r[d]-r[p])*(r[f+1]-r[d+1])-(r[d]-r[f])*(r[p+1]-r[d+1]))}return o===0&&u===0?0:Math.abs((u-o)/o)};function Lo(r,t,e,i){for(var s=0,n=t,o=e-i;n<e;n+=i)s+=(r[o]-r[n])*(r[n+1]+r[o+1]),o=n;return s}Xs.flatten=function(r){for(var t=r[0][0].length,e={vertices:[],holes:[],dimensions:t},i=0,s=0;s<r.length;s++){for(var n=0;n<r[s].length;n++)for(var o=0;o<t;o++)e.vertices.push(r[s][n][o]);s>0&&(i+=r[s-1].length,e.holes.push(i))}return e};var ay=Do.exports;const ly=Zh(ay);var js={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */js.exports,function(r,t){(function(e){var i=t&&!t.nodeType&&t,s=r&&!r.nodeType&&r,n=typeof Hs=="object"&&Hs;(n.global===n||n.window===n||n.self===n)&&(e=n);var o,a=2147483647,l=36,h=1,c=26,u=38,d=700,f=72,p=128,m="-",g=/^xn--/,y=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=l-h,T=Math.floor,P=String.fromCharCode,I;function b(R){throw new RangeError(_[R])}function E(R,L){for(var W=R.length,Q=[];W--;)Q[W]=L(R[W]);return Q}function S(R,L){var W=R.split("@"),Q="";W.length>1&&(Q=W[0]+"@",R=W[1]),R=R.replace(v,".");var J=R.split("."),H=E(J,L).join(".");return Q+H}function D(R){for(var L=[],W=0,Q=R.length,J,H;W<Q;)J=R.charCodeAt(W++),J>=55296&&J<=56319&&W<Q?(H=R.charCodeAt(W++),(H&64512)==56320?L.push(((J&1023)<<10)+(H&1023)+65536):(L.push(J),W--)):L.push(J);return L}function B(R){return E(R,function(L){var W="";return L>65535&&(L-=65536,W+=P(L>>>10&1023|55296),L=56320|L&1023),W+=P(L),W}).join("")}function w(R){return R-48<10?R-22:R-65<26?R-65:R-97<26?R-97:l}function C(R,L){return R+22+75*(R<26)-((L!=0)<<5)}function F(R,L,W){var Q=0;for(R=W?T(R/d):R>>1,R+=T(R/L);R>x*c>>1;Q+=l)R=T(R/x);return T(Q+(x+1)*R/(R+u))}function k(R){var L=[],W=R.length,Q,J=0,H=p,_t=f,Tt,N,O,xt,ft,gt,yt,ze,We;for(Tt=R.lastIndexOf(m),Tt<0&&(Tt=0),N=0;N<Tt;++N)R.charCodeAt(N)>=128&&b("not-basic"),L.push(R.charCodeAt(N));for(O=Tt>0?Tt+1:0;O<W;){for(xt=J,ft=1,gt=l;O>=W&&b("invalid-input"),yt=w(R.charCodeAt(O++)),(yt>=l||yt>T((a-J)/ft))&&b("overflow"),J+=yt*ft,ze=gt<=_t?h:gt>=_t+c?c:gt-_t,!(yt<ze);gt+=l)We=l-ze,ft>T(a/We)&&b("overflow"),ft*=We;Q=L.length+1,_t=F(J-xt,Q,xt==0),T(J/Q)>a-H&&b("overflow"),H+=T(J/Q),J%=Q,L.splice(J++,0,H)}return B(L)}function G(R){var L,W,Q,J,H,_t,Tt,N,O,xt,ft,gt=[],yt,ze,We,_s;for(R=D(R),yt=R.length,L=p,W=0,H=f,_t=0;_t<yt;++_t)ft=R[_t],ft<128&>.push(P(ft));for(Q=J=gt.length,J&>.push(m);Q<yt;){for(Tt=a,_t=0;_t<yt;++_t)ft=R[_t],ft>=L&&ft<Tt&&(Tt=ft);for(ze=Q+1,Tt-L>T((a-W)/ze)&&b("overflow"),W+=(Tt-L)*ze,L=Tt,_t=0;_t<yt;++_t)if(ft=R[_t],ft<L&&++W>a&&b("overflow"),ft==L){for(N=W,O=l;xt=O<=H?h:O>=H+c?c:O-H,!(N<xt);O+=l)_s=N-xt,We=l-xt,gt.push(P(C(xt+_s%We,0))),N=T(_s/We);gt.push(P(C(N,0))),H=F(W,ze,Q==J),W=0,++Q}++W,++L}return gt.join("")}function $(R){return S(R,function(L){return g.test(L)?k(L.slice(4).toLowerCase()):L})}function nt(R){return S(R,function(L){return y.test(L)?"xn--"+G(L):L})}if(o={version:"1.4.1",ucs2:{decode:D,encode:B},decode:k,encode:G,toASCII:nt,toUnicode:$},i&&s)if(r.exports==i)s.exports=o;else for(I in o)o.hasOwnProperty(I)&&(i[I]=o[I]);else e.punycode=o})(Hs)}(js,js.exports);var hy=js.exports,cy=Error,uy=EvalError,dy=RangeError,fy=ReferenceError,ic=SyntaxError,ts=TypeError,py=URIError,my=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),i=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;t[e]=s;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var n=Object.getOwnPropertySymbols(t);if(n.length!==1||n[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(t,e);if(o.value!==s||o.enumerable!==!0)return!1}return!0},sc=typeof Symbol<"u"&&Symbol,gy=my,yy=function(){return typeof sc!="function"||typeof Symbol!="function"||typeof sc("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:gy()},No={__proto__:null,foo:{}},_y=Object,vy=function(){return{__proto__:No}.foo===No.foo&&!(No instanceof _y)},xy="Function.prototype.bind called on incompatible ",by=Object.prototype.toString,wy=Math.max,Ey="[object Function]",nc=function(t,e){for(var i=[],s=0;s<t.length;s+=1)i[s]=t[s];for(var n=0;n<e.length;n+=1)i[n+t.length]=e[n];return i},Ty=function(t,e){for(var i=[],s=e||0,n=0;s<t.length;s+=1,n+=1)i[n]=t[s];return i},Ay=function(r,t){for(var e="",i=0;i<r.length;i+=1)e+=r[i],i+1<r.length&&(e+=t);return e},Sy=function(t){var e=this;if(typeof e!="function"||by.apply(e)!==Ey)throw new TypeError(xy+e);for(var i=Ty(arguments,1),s,n=function(){if(this instanceof s){var c=e.apply(this,nc(i,arguments));return Object(c)===c?c:this}return e.apply(t,nc(i,arguments))},o=wy(0,e.length-i.length),a=[],l=0;l<o;l++)a[l]="$"+l;if(s=Function("binder","return function ("+Ay(a,",")+"){ return binder.apply(this,arguments); }")(n),e.prototype){var h=function(){};h.prototype=e.prototype,s.prototype=new h,h.prototype=null}return s},Iy=Sy,Uo=Function.prototype.bind||Iy,Cy=Function.prototype.call,Py=Object.prototype.hasOwnProperty,Ry=Uo,My=Ry.call(Cy,Py),ht,By=cy,Dy=uy,Oy=dy,Fy=fy,fi=ic,pi=ts,Ly=py,oc=Function,ko=function(r){try{return oc('"use strict"; return ('+r+").constructor;")()}catch{}},Dr=Object.getOwnPropertyDescriptor;if(Dr)try{Dr({},"")}catch{Dr=null}var Go=function(){throw new pi},Ny=Dr?function(){try{return arguments.callee,Go}catch{try{return Dr(arguments,"callee").get}catch{return Go}}}():Go,mi=yy(),Uy=vy(),Ut=Object.getPrototypeOf||(Uy?function(r){return r.__proto__}:null),gi={},ky=typeof Uint8Array>"u"||!Ut?ht:Ut(Uint8Array),Or={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?ht:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?ht:ArrayBuffer,"%ArrayIteratorPrototype%":mi&&Ut?Ut([][Symbol.iterator]()):ht,"%AsyncFromSyncIteratorPrototype%":ht,"%AsyncFunction%":gi,"%AsyncGenerator%":gi,"%AsyncGeneratorFunction%":gi,"%AsyncIteratorPrototype%":gi,"%Atomics%":typeof Atomics>"u"?ht:Atomics,"%BigInt%":typeof BigInt>"u"?ht:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?ht:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?ht:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?ht:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":By,"%eval%":eval,"%EvalError%":Dy,"%Float32Array%":typeof Float32Array>"u"?ht:Float32Array,"%Float64Array%":typeof Float64Array>"u"?ht:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?ht:FinalizationRegistry,"%Function%":oc,"%GeneratorFunction%":gi,"%Int8Array%":typeof Int8Array>"u"?ht:Int8Array,"%Int16Array%":typeof Int16Array>"u"?ht:Int16Array,"%Int32Array%":typeof Int32Array>"u"?ht:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":mi&&Ut?Ut(Ut([][Symbol.iterator]())):ht,"%JSON%":typeof JSON=="object"?JSON:ht,"%Map%":typeof Map>"u"?ht:Map,"%MapIteratorPrototype%":typeof Map>"u"||!mi||!Ut?ht:Ut(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?ht:Promise,"%Proxy%":typeof Proxy>"u"?ht:Proxy,"%RangeError%":Oy,"%ReferenceError%":Fy,"%Reflect%":typeof Reflect>"u"?ht:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?ht:Set,"%SetIteratorPrototype%":typeof Set>"u"||!mi||!Ut?ht:Ut(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?ht:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":mi&&Ut?Ut(""[Symbol.iterator]()):ht,"%Symbol%":mi?Symbol:ht,"%SyntaxError%":fi,"%ThrowTypeError%":Ny,"%TypedArray%":ky,"%TypeError%":pi,"%Uint8Array%":typeof Uint8Array>"u"?ht:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?ht:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?ht:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?ht:Uint32Array,"%URIError%":Ly,"%WeakMap%":typeof WeakMap>"u"?ht:WeakMap,"%WeakRef%":typeof WeakRef>"u"?ht:WeakRef,"%WeakSet%":typeof WeakSet>"u"?ht:WeakSet};if(Ut)try{null.error}catch(r){var Gy=Ut(Ut(r));Or["%Error.prototype%"]=Gy}var $y=function r(t){var e;if(t==="%AsyncFunction%")e=ko("async function () {}");else if(t==="%GeneratorFunction%")e=ko("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=ko("async function* () {}");else if(t==="%AsyncGenerator%"){var i=r("%AsyncGeneratorFunction%");i&&(e=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var s=r("%AsyncGenerator%");s&&Ut&&(e=Ut(s.prototype))}return Or[t]=e,e},ac={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},es=Uo,Ys=My,Hy=es.call(Function.call,Array.prototype.concat),Xy=es.call(Function.apply,Array.prototype.splice),lc=es.call(Function.call,String.prototype.replace),qs=es.call(Function.call,String.prototype.slice),Vy=es.call(Function.call,RegExp.prototype.exec),zy=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Wy=/\\(\\)?/g,jy=function(t){var e=qs(t,0,1),i=qs(t,-1);if(e==="%"&&i!=="%")throw new fi("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&e!=="%")throw new fi("invalid intrinsic syntax, expected opening `%`");var s=[];return lc(t,zy,function(n,o,a,l){s[s.length]=a?lc(l,Wy,"$1"):o||n}),s},Yy=function(t,e){var i=t,s;if(Ys(ac,i)&&(s=ac[i],i="%"+s[0]+"%"),Ys(Or,i)){var n=Or[i];if(n===gi&&(n=$y(i)),typeof n>"u"&&!e)throw new pi("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:n}}throw new fi("intrinsic "+t+" does not exist!")},yi=function(t,e){if(typeof t!="string"||t.length===0)throw new pi("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new pi('"allowMissing" argument must be a boolean');if(Vy(/^%?[^%]*%?$/,t)===null)throw new fi("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=jy(t),s=i.length>0?i[0]:"",n=Yy("%"+s+"%",e),o=n.name,a=n.value,l=!1,h=n.alias;h&&(s=h[0],Xy(i,Hy([0,1],h)));for(var c=1,u=!0;c<i.length;c+=1){var d=i[c],f=qs(d,0,1),p=qs(d,-1);if((f==='"'||f==="'"||f==="`"||p==='"'||p==="'"||p==="`")&&f!==p)throw new fi("property names with quotes must have matching quotes");if((d==="constructor"||!u)&&(l=!0),s+="."+d,o="%"+s+"%",Ys(Or,o))a=Or[o];else if(a!=null){if(!(d in a)){if(!e)throw new pi("base intrinsic for "+t+" exists, but the property is not available.");return}if(Dr&&c+1>=i.length){var m=Dr(a,d);u=!!m,u&&"get"in m&&!("originalValue"in m.get)?a=m.get:a=a[d]}else u=Ys(a,d),a=a[d];u&&!l&&(Or[o]=a)}}return a},hc={exports:{}},$o,cc;function Ho(){if(cc)return $o;cc=1;var r=yi,t=r("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return $o=t,$o}var qy=yi,Ks=qy("%Object.getOwnPropertyDescriptor%",!0);if(Ks)try{Ks([],"length")}catch{Ks=null}var uc=Ks,dc=Ho(),Ky=ic,_i=ts,fc=uc,Zy=function(t,e,i){if(!t||typeof t!="object"&&typeof t!="function")throw new _i("`obj` must be an object or a function`");if(typeof e!="string"&&typeof e!="symbol")throw new _i("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new _i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new _i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new _i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new _i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,a=arguments.length>6?arguments[6]:!1,l=!!fc&&fc(t,e);if(dc)dc(t,e,{configurable:o===null&&l?l.configurable:!o,enumerable:s===null&&l?l.enumerable:!s,value:i,writable:n===null&&l?l.writable:!n});else if(a||!s&&!n&&!o)t[e]=i;else throw new Ky("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Xo=Ho(),pc=function(){return!!Xo};pc.hasArrayLengthDefineBug=function(){if(!Xo)return null;try{return Xo([],"length",{value:1}).length!==1}catch{return!0}};var Jy=pc,Qy=yi,mc=Zy,t0=Jy(),gc=uc,yc=ts,e0=Qy("%Math.floor%"),r0=function(t,e){if(typeof t!="function")throw new yc("`fn` is not a function");if(typeof e!="number"||e<0||e>4294967295||e0(e)!==e)throw new yc("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,n=!0;if("length"in t&&gc){var o=gc(t,"length");o&&!o.configurable&&(s=!1),o&&!o.writable&&(n=!1)}return(s||n||!i)&&(t0?mc(t,"length",e,!0,!0):mc(t,"length",e)),t};(function(r){var t=Uo,e=yi,i=r0,s=ts,n=e("%Function.prototype.apply%"),o=e("%Function.prototype.call%"),a=e("%Reflect.apply%",!0)||t.call(o,n),l=Ho(),h=e("%Math.max%");r.exports=function(d){if(typeof d!="function")throw new s("a function is required");var f=a(t,o,arguments);return i(f,1+h(0,d.length-(arguments.length-1)),!0)};var c=function(){return a(t,n,arguments)};l?l(r.exports,"apply",{value:c}):r.exports.apply=c})(hc);var i0=hc.exports,_c=yi,vc=i0,s0=vc(_c("String.prototype.indexOf")),n0=function(t,e){var i=_c(t,!!e);return typeof i=="function"&&s0(t,".prototype.")>-1?vc(i):i};const o0=Vg(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Vo=typeof Map=="function"&&Map.prototype,zo=Object.getOwnPropertyDescriptor&&Vo?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Zs=Vo&&zo&&typeof zo.get=="function"?zo.get:null,xc=Vo&&Map.prototype.forEach,Wo=typeof Set=="function"&&Set.prototype,jo=Object.getOwnPropertyDescriptor&&Wo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Js=Wo&&jo&&typeof jo.get=="function"?jo.get:null,bc=Wo&&Set.prototype.forEach,a0=typeof WeakMap=="function"&&WeakMap.prototype,rs=a0?WeakMap.prototype.has:null,l0=typeof WeakSet=="function"&&WeakSet.prototype,is=l0?WeakSet.prototype.has:null,h0=typeof WeakRef=="function"&&WeakRef.prototype,wc=h0?WeakRef.prototype.deref:null,c0=Boolean.prototype.valueOf,u0=Object.prototype.toString,d0=Function.prototype.toString,f0=String.prototype.match,Yo=String.prototype.slice,fr=String.prototype.replace,p0=String.prototype.toUpperCase,Ec=String.prototype.toLowerCase,Tc=RegExp.prototype.test,Ac=Array.prototype.concat,Le=Array.prototype.join,m0=Array.prototype.slice,Sc=Math.floor,qo=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Ko=Object.getOwnPropertySymbols,Zo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,vi=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Jt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===vi||!0)?Symbol.toStringTag:null,Ic=Object.prototype.propertyIsEnumerable,Cc=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(r){return r.__proto__}:null);function Pc(r,t){if(r===1/0||r===-1/0||r!==r||r&&r>-1e3&&r<1e3||Tc.call(/e/,t))return t;var e=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof r=="number"){var i=r<0?-Sc(-r):Sc(r);if(i!==r){var s=String(i),n=Yo.call(t,s.length+1);return fr.call(s,e,"$&_")+"."+fr.call(fr.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}}return fr.call(t,e,"$&_")}var Jo=o0,Rc=Jo.custom,Mc=Oc(Rc)?Rc:null,g0=function r(t,e,i,s){var n=e||{};if(pr(n,"quoteStyle")&&n.quoteStyle!=="single"&&n.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(pr(n,"maxStringLength")&&(typeof n.maxStringLength=="number"?n.maxStringLength<0&&n.maxStringLength!==1/0:n.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=pr(n,"customInspect")?n.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(pr(n,"indent")&&n.indent!==null&&n.indent!==" "&&!(parseInt(n.indent,10)===n.indent&&n.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(pr(n,"numericSeparator")&&typeof n.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=n.numericSeparator;if(typeof t>"u")return"undefined";if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(typeof t=="string")return Lc(t,n);if(typeof t=="number"){if(t===0)return 1/0/t>0?"0":"-0";var l=String(t);return a?Pc(t,l):l}if(typeof t=="bigint"){var h=String(t)+"n";return a?Pc(t,h):h}var c=typeof n.depth>"u"?5:n.depth;if(typeof i>"u"&&(i=0),i>=c&&c>0&&typeof t=="object")return Qo(t)?"[Array]":"[Object]";var u=O0(n,i);if(typeof s>"u")s=[];else if(Fc(s,t)>=0)return"[Circular]";function d(w,C,F){if(C&&(s=m0.call(s),s.push(C)),F){var k={depth:n.depth};return pr(n,"quoteStyle")&&(k.quoteStyle=n.quoteStyle),r(w,k,i+1,s)}return r(w,n,i+1,s)}if(typeof t=="function"&&!Dc(t)){var f=A0(t),p=Qs(t,d);return"[Function"+(f?": "+f:" (anonymous)")+"]"+(p.length>0?" { "+Le.call(p,", ")+" }":"")}if(Oc(t)){var m=vi?fr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Zo.call(t);return typeof t=="object"&&!vi?ss(m):m}if(M0(t)){for(var g="<"+Ec.call(String(t.nodeName)),y=t.attributes||[],v=0;v<y.length;v++)g+=" "+y[v].name+"="+Bc(y0(y[v].value),"double",n);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+="</"+Ec.call(String(t.nodeName))+">",g}if(Qo(t)){if(t.length===0)return"[]";var _=Qs(t,d);return u&&!D0(_)?"["+ea(_,u)+"]":"[ "+Le.call(_,", ")+" ]"}if(v0(t)){var x=Qs(t,d);return!("cause"in Error.prototype)&&"cause"in t&&!Ic.call(t,"cause")?"{ ["+String(t)+"] "+Le.call(Ac.call("[cause]: "+d(t.cause),x),", ")+" }":x.length===0?"["+String(t)+"]":"{ ["+String(t)+"] "+Le.call(x,", ")+" }"}if(typeof t=="object"&&o){if(Mc&&typeof t[Mc]=="function"&&Jo)return Jo(t,{depth:c-i});if(o!=="symbol"&&typeof t.inspect=="function")return t.inspect()}if(S0(t)){var T=[];return xc&&xc.call(t,function(w,C){T.push(d(C,t,!0)+" => "+d(w,t))}),Nc("Map",Zs.call(t),T,u)}if(P0(t)){var P=[];return bc&&bc.call(t,function(w){P.push(d(w,t))}),Nc("Set",Js.call(t),P,u)}if(I0(t))return ta("WeakMap");if(R0(t))return ta("WeakSet");if(C0(t))return ta("WeakRef");if(b0(t))return ss(d(Number(t)));if(E0(t))return ss(d(qo.call(t)));if(w0(t))return ss(c0.call(t));if(x0(t))return ss(d(String(t)));if(typeof window<"u"&&t===window)return"{ [object Window] }";if(t===Hs)return"{ [object globalThis] }";if(!_0(t)&&!Dc(t)){var I=Qs(t,d),b=Cc?Cc(t)===Object.prototype:t instanceof Object||t.constructor===Object,E=t instanceof Object?"":"null prototype",S=!b&&Jt&&Object(t)===t&&Jt in t?Yo.call(mr(t),8,-1):E?"Object":"",D=b||typeof t.constructor!="function"?"":t.constructor.name?t.constructor.name+" ":"",B=D+(S||E?"["+Le.call(Ac.call([],S||[],E||[]),": ")+"] ":"");return I.length===0?B+"{}":u?B+"{"+ea(I,u)+"}":B+"{ "+Le.call(I,", ")+" }"}return String(t)};function Bc(r,t,e){var i=(e.quoteStyle||t)==="double"?'"':"'";return i+r+i}function y0(r){return fr.call(String(r),/"/g,""")}function Qo(r){return mr(r)==="[object Array]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function _0(r){return mr(r)==="[object Date]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function Dc(r){return mr(r)==="[object RegExp]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function v0(r){return mr(r)==="[object Error]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function x0(r){return mr(r)==="[object String]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function b0(r){return mr(r)==="[object Number]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function w0(r){return mr(r)==="[object Boolean]"&&(!Jt||!(typeof r=="object"&&Jt in r))}function Oc(r){if(vi)return r&&typeof r=="object"&&r instanceof Symbol;if(typeof r=="symbol")return!0;if(!r||typeof r!="object"||!Zo)return!1;try{return Zo.call(r),!0}catch{}return!1}function E0(r){if(!r||typeof r!="object"||!qo)return!1;try{return qo.call(r),!0}catch{}return!1}var T0=Object.prototype.hasOwnProperty||function(r){return r in this};function pr(r,t){return T0.call(r,t)}function mr(r){return u0.call(r)}function A0(r){if(r.name)return r.name;var t=f0.call(d0.call(r),/^function\s*([\w$]+)/);return t?t[1]:null}function Fc(r,t){if(r.indexOf)return r.indexOf(t);for(var e=0,i=r.length;e<i;e++)if(r[e]===t)return e;return-1}function S0(r){if(!Zs||!r||typeof r!="object")return!1;try{Zs.call(r);try{Js.call(r)}catch{return!0}return r instanceof Map}catch{}return!1}function I0(r){if(!rs||!r||typeof r!="object")return!1;try{rs.call(r,rs);try{is.call(r,is)}catch{return!0}return r instanceof WeakMap}catch{}return!1}function C0(r){if(!wc||!r||typeof r!="object")return!1;try{return wc.call(r),!0}catch{}return!1}function P0(r){if(!Js||!r||typeof r!="object")return!1;try{Js.call(r);try{Zs.call(r)}catch{return!0}return r instanceof Set}catch{}return!1}function R0(r){if(!is||!r||typeof r!="object")return!1;try{is.call(r,is);try{rs.call(r,rs)}catch{return!0}return r instanceof WeakSet}catch{}return!1}function M0(r){return!r||typeof r!="object"?!1:typeof HTMLElement<"u"&&r instanceof HTMLElement?!0:typeof r.nodeName=="string"&&typeof r.getAttribute=="function"}function Lc(r,t){if(r.length>t.maxStringLength){var e=r.length-t.maxStringLength,i="... "+e+" more character"+(e>1?"s":"");return Lc(Yo.call(r,0,t.maxStringLength),t)+i}var s=fr.call(fr.call(r,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,B0);return Bc(s,"single",t)}function B0(r){var t=r.charCodeAt(0),e={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return e?"\\"+e:"\\x"+(t<16?"0":"")+p0.call(t.toString(16))}function ss(r){return"Object("+r+")"}function ta(r){return r+" { ? }"}function Nc(r,t,e,i){var s=i?ea(e,i):Le.call(e,", ");return r+" ("+t+") {"+s+"}"}function D0(r){for(var t=0;t<r.length;t++)if(Fc(r[t],`
|
|
2
2
|
`)>=0)return!1;return!0}function O0(r,t){var e;if(r.indent===" ")e=" ";else if(typeof r.indent=="number"&&r.indent>0)e=Le.call(Array(r.indent+1)," ");else return null;return{base:e,prev:Le.call(Array(t+1),e)}}function ea(r,t){if(r.length===0)return"";var e=`
|
|
3
3
|
`+t.prev+t.base;return e+Le.call(r,","+e)+`
|
|
4
|
-
`+t.prev}function Qs(r,t){var e=Qo(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=pr(r,s)?t(r[s],r):""}var n=typeof Ko=="function"?Ko(r):[],o;if(_i){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)pr(r,l)&&(e&&String(Number(l))===l&&l<r.length||_i&&o["$"+l]instanceof Symbol||(Tc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof Ko=="function")for(var h=0;h<n.length;h++)Cc.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var Uc=gi,vi=n0,F0=g0,L0=Qi,tn=Uc("%WeakMap%",!0),en=Uc("%Map%",!0),N0=vi("WeakMap.prototype.get",!0),U0=vi("WeakMap.prototype.set",!0),k0=vi("WeakMap.prototype.has",!0),G0=vi("Map.prototype.get",!0),$0=vi("Map.prototype.set",!0),H0=vi("Map.prototype.has",!0),ra=function(r,t){for(var e=r,i;(i=e.next)!==null;e=i)if(i.key===t)return e.next=i.next,i.next=r.next,r.next=i,i},X0=function(r,t){var e=ra(r,t);return e&&e.value},V0=function(r,t,e){var i=ra(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},z0=function(r,t){return!!ra(r,t)},W0=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new L0("Side channel does not contain "+F0(n))},get:function(n){if(tn&&n&&(typeof n=="object"||typeof n=="function")){if(t)return N0(t,n)}else if(en){if(e)return G0(e,n)}else if(i)return X0(i,n)},has:function(n){if(tn&&n&&(typeof n=="object"||typeof n=="function")){if(t)return k0(t,n)}else if(en){if(e)return H0(e,n)}else if(i)return z0(i,n);return!1},set:function(n,o){tn&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new tn),U0(t,n,o)):en?(e||(e=new en),$0(e,n,o)):(i||(i={key:{},next:null}),V0(i,n,o))}};return s},j0=String.prototype.replace,Y0=/%20/g,ia={RFC1738:"RFC1738",RFC3986:"RFC3986"},sa={default:ia.RFC3986,formatters:{RFC1738:function(r){return j0.call(r,Y0,"+")},RFC3986:function(r){return String(r)}},RFC1738:ia.RFC1738,RFC3986:ia.RFC3986},q0=sa,na=Object.prototype.hasOwnProperty,Fr=Array.isArray,Ne=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),K0=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Fr(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},kc=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},Z0=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Fr(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!na.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Fr(t)&&!Fr(e)&&(s=kc(t,i)),Fr(t)&&Fr(e)?(e.forEach(function(n,o){if(na.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return na.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},J0=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},Q0=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},t_=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;++l){var h=o.charCodeAt(l);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||n===q0.RFC1738&&(h===40||h===41)){a+=o.charAt(l);continue}if(h<128){a=a+Ne[h];continue}if(h<2048){a=a+(Ne[192|h>>6]+Ne[128|h&63]);continue}if(h<55296||h>=57344){a=a+(Ne[224|h>>12]+Ne[128|h>>6&63]+Ne[128|h&63]);continue}l+=1,h=65536+((h&1023)<<10|o.charCodeAt(l)&1023),a+=Ne[240|h>>18]+Ne[128|h>>12&63]+Ne[128|h>>6&63]+Ne[128|h&63]}return a},e_=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return K0(e),t},r_=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},i_=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},s_=function(t,e){return[].concat(t,e)},n_=function(t,e){if(Fr(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},Gc={arrayToObject:kc,assign:J0,combine:s_,compact:e_,decode:Q0,encode:t_,isBuffer:i_,isRegExp:r_,maybeMap:n_,merge:Z0},$c=W0,rn=Gc,ss=sa,o_=Object.prototype.hasOwnProperty,Hc={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Ue=Array.isArray,a_=Array.prototype.push,Xc=function(r,t){a_.apply(r,Ue(t)?t:[t])},l_=Date.prototype.toISOString,Vc=ss.default,Lt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:rn.encode,encodeValuesOnly:!1,format:Vc,formatter:ss.formatters[Vc],indices:!1,serializeDate:function(t){return l_.call(t)},skipNulls:!1,strictNullHandling:!1},h_=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},oa={},c_=function r(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g,y,x){for(var _=t,v=x,w=0,R=!1;(v=v.get(oa))!==void 0&&!R;){var C=v.get(t);if(w+=1,typeof C<"u"){if(C===w)throw new RangeError("Cyclic object value");R=!0}typeof v.get(oa)>"u"&&(w=0)}if(typeof c=="function"?_=c(e,_):_ instanceof Date?_=f(_):i==="comma"&&Ue(_)&&(_=rn.maybeMap(_,function(D){return D instanceof Date?f(D):D})),_===null){if(o)return h&&!g?h(e,Lt.encoder,y,"key",p):e;_=""}if(h_(_)||rn.isBuffer(_)){if(h){var b=g?e:h(e,Lt.encoder,y,"key",p);return[m(b)+"="+m(h(_,Lt.encoder,y,"value",p))]}return[m(e)+"="+m(String(_))]}var T=[];if(typeof _>"u")return T;var I;if(i==="comma"&&Ue(_))g&&h&&(_=rn.maybeMap(_,h)),I=[{value:_.length>0?_.join(",")||null:void 0}];else if(Ue(c))I=c;else{var O=Object.keys(_);I=u?O.sort(u):O}var M=l?e.replace(/\./g,"%2E"):e,E=s&&Ue(_)&&_.length===1?M+"[]":M;if(n&&Ue(_)&&_.length===0)return E+"[]";for(var S=0;S<I.length;++S){var L=I[S],k=typeof L=="object"&&typeof L.value<"u"?L.value:_[L];if(!(a&&k===null)){var G=d&&l?L.replace(/\./g,"%2E"):L,H=Ue(_)?typeof i=="function"?i(E,G):E:E+(d?"."+G:"["+G+"]");x.set(t,w);var X=$c();X.set(oa,x),Xc(T,r(k,H,i,s,n,o,a,l,i==="comma"&&g&&Ue(_)?null:h,c,u,d,f,p,m,g,y,X))}}return T},u_=function(t){if(!t)return Lt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Lt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=ss.default;if(typeof t.format<"u"){if(!o_.call(ss.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=ss.formatters[i],n=Lt.filter;(typeof t.filter=="function"||Ue(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in Hc?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Lt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var a=typeof t.allowDots>"u"?t.encodeDotInKeys===!0?!0:Lt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Lt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Lt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Lt.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Lt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Lt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Lt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Lt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Lt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Lt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Lt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Lt.strictNullHandling}},d_=function(r,t){var e=r,i=u_(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):Ue(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=Hc[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=$c(),c=0;c<s.length;++c){var u=s[c];i.skipNulls&&e[u]===null||Xc(o,c_(e[u],u,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var d=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""},xi=Gc,aa=Object.prototype.hasOwnProperty,f_=Array.isArray,Rt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!0,decoder:xi.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},p_=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},zc=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},m_="utf8=%26%2310003%3B",g_="utf8=%E2%9C%93",y_=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,n),a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===g_?h="utf-8":o[l]===m_&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Rt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Rt.decoder,h,"key"),p=xi.maybeMap(zc(c.slice(d+1),e),function(g){return e.decoder(g,Rt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=p_(p)),c.indexOf("[]=")>-1&&(p=f_(p)?[p]:p);var m=aa.call(i,f);m&&e.duplicates==="combine"?i[f]=xi.combine(i[f],p):(!m||e.duplicates==="last")&&(i[f]=p)}return i},__=function(r,t,e,i){for(var s=i?t:zc(t,e),n=r.length-1;n>=0;--n){var o,a=r[n];if(a==="[]"&&e.parseArrays)o=e.allowEmptyArrays&&s===""?[]:[].concat(s);else{o=e.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=e.decodeDotInKeys?l.replace(/%2E/g,"."):l,c=parseInt(h,10);!e.parseArrays&&h===""?o={0:s}:!isNaN(c)&&a!==h&&String(c)===h&&c>=0&&e.parseArrays&&c<=e.arrayLimit?(o=[],o[c]=s):h!=="__proto__"&&(o[h]=s)}s=o}return s},v_=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,c=[];if(h){if(!i.plainObjects&&aa.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(n))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&aa.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}return l&&c.push("["+n.slice(l.index)+"]"),__(c,e,i,s)}},x_=function(t){if(!t)return Rt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.decodeDotInKeys<"u"&&typeof t.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(t.decoder!==null&&typeof t.decoder<"u"&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?Rt.charset:t.charset,i=typeof t.duplicates>"u"?Rt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Rt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Rt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Rt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Rt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Rt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Rt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Rt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Rt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Rt.decoder,delimiter:typeof t.delimiter=="string"||xi.isRegExp(t.delimiter)?t.delimiter:Rt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Rt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Rt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Rt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Rt.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Rt.strictNullHandling}},b_=function(r,t){var e=x_(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?y_(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=v_(a,i[a],e,typeof r=="string");s=xi.merge(s,l,e)}return e.allowSparse===!0?s:xi.compact(s)},w_=d_,E_=b_,T_=sa,A_={formats:T_,parse:E_,stringify:w_},S_=hy;function ir(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var C_=/^([a-z0-9.+-]+:)/i,I_=/:[0-9]*$/,P_=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,R_=["<",">",'"',"`"," ","\r",`
|
|
5
|
-
`," "],M_=["{","}","|","\\","^","`"].concat(R_),la=["'"].concat(M_),Wc=["%","/","?",";","#"].concat(la),jc=["/","?","#"],B_=255,Yc=/^[+a-z0-9A-Z_-]{0,63}$/,D_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,O_={javascript:!0,"javascript:":!0},ha={javascript:!0,"javascript:":!0},
|
|
4
|
+
`+t.prev}function Qs(r,t){var e=Qo(r),i=[];if(e){i.length=r.length;for(var s=0;s<r.length;s++)i[s]=pr(r,s)?t(r[s],r):""}var n=typeof Ko=="function"?Ko(r):[],o;if(vi){o={};for(var a=0;a<n.length;a++)o["$"+n[a]]=n[a]}for(var l in r)pr(r,l)&&(e&&String(Number(l))===l&&l<r.length||vi&&o["$"+l]instanceof Symbol||(Tc.call(/[^\w$]/,l)?i.push(t(l,r)+": "+t(r[l],r)):i.push(l+": "+t(r[l],r))));if(typeof Ko=="function")for(var h=0;h<n.length;h++)Ic.call(r,n[h])&&i.push("["+t(n[h])+"]: "+t(r[n[h]],r));return i}var Uc=yi,xi=n0,F0=g0,L0=ts,tn=Uc("%WeakMap%",!0),en=Uc("%Map%",!0),N0=xi("WeakMap.prototype.get",!0),U0=xi("WeakMap.prototype.set",!0),k0=xi("WeakMap.prototype.has",!0),G0=xi("Map.prototype.get",!0),$0=xi("Map.prototype.set",!0),H0=xi("Map.prototype.has",!0),ra=function(r,t){for(var e=r,i;(i=e.next)!==null;e=i)if(i.key===t)return e.next=i.next,i.next=r.next,r.next=i,i},X0=function(r,t){var e=ra(r,t);return e&&e.value},V0=function(r,t,e){var i=ra(r,t);i?i.value=e:r.next={key:t,next:r.next,value:e}},z0=function(r,t){return!!ra(r,t)},W0=function(){var t,e,i,s={assert:function(n){if(!s.has(n))throw new L0("Side channel does not contain "+F0(n))},get:function(n){if(tn&&n&&(typeof n=="object"||typeof n=="function")){if(t)return N0(t,n)}else if(en){if(e)return G0(e,n)}else if(i)return X0(i,n)},has:function(n){if(tn&&n&&(typeof n=="object"||typeof n=="function")){if(t)return k0(t,n)}else if(en){if(e)return H0(e,n)}else if(i)return z0(i,n);return!1},set:function(n,o){tn&&n&&(typeof n=="object"||typeof n=="function")?(t||(t=new tn),U0(t,n,o)):en?(e||(e=new en),$0(e,n,o)):(i||(i={key:{},next:null}),V0(i,n,o))}};return s},j0=String.prototype.replace,Y0=/%20/g,ia={RFC1738:"RFC1738",RFC3986:"RFC3986"},sa={default:ia.RFC3986,formatters:{RFC1738:function(r){return j0.call(r,Y0,"+")},RFC3986:function(r){return String(r)}},RFC1738:ia.RFC1738,RFC3986:ia.RFC3986},q0=sa,na=Object.prototype.hasOwnProperty,Fr=Array.isArray,Ne=function(){for(var r=[],t=0;t<256;++t)r.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return r}(),K0=function(t){for(;t.length>1;){var e=t.pop(),i=e.obj[e.prop];if(Fr(i)){for(var s=[],n=0;n<i.length;++n)typeof i[n]<"u"&&s.push(i[n]);e.obj[e.prop]=s}}},kc=function(t,e){for(var i=e&&e.plainObjects?Object.create(null):{},s=0;s<t.length;++s)typeof t[s]<"u"&&(i[s]=t[s]);return i},Z0=function r(t,e,i){if(!e)return t;if(typeof e!="object"){if(Fr(t))t.push(e);else if(t&&typeof t=="object")(i&&(i.plainObjects||i.allowPrototypes)||!na.call(Object.prototype,e))&&(t[e]=!0);else return[t,e];return t}if(!t||typeof t!="object")return[t].concat(e);var s=t;return Fr(t)&&!Fr(e)&&(s=kc(t,i)),Fr(t)&&Fr(e)?(e.forEach(function(n,o){if(na.call(t,o)){var a=t[o];a&&typeof a=="object"&&n&&typeof n=="object"?t[o]=r(a,n,i):t.push(n)}else t[o]=n}),t):Object.keys(e).reduce(function(n,o){var a=e[o];return na.call(n,o)?n[o]=r(n[o],a,i):n[o]=a,n},s)},J0=function(t,e){return Object.keys(e).reduce(function(i,s){return i[s]=e[s],i},t)},Q0=function(r,t,e){var i=r.replace(/\+/g," ");if(e==="iso-8859-1")return i.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(i)}catch{return i}},t_=function(t,e,i,s,n){if(t.length===0)return t;var o=t;if(typeof t=="symbol"?o=Symbol.prototype.toString.call(t):typeof t!="string"&&(o=String(t)),i==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});for(var a="",l=0;l<o.length;++l){var h=o.charCodeAt(l);if(h===45||h===46||h===95||h===126||h>=48&&h<=57||h>=65&&h<=90||h>=97&&h<=122||n===q0.RFC1738&&(h===40||h===41)){a+=o.charAt(l);continue}if(h<128){a=a+Ne[h];continue}if(h<2048){a=a+(Ne[192|h>>6]+Ne[128|h&63]);continue}if(h<55296||h>=57344){a=a+(Ne[224|h>>12]+Ne[128|h>>6&63]+Ne[128|h&63]);continue}l+=1,h=65536+((h&1023)<<10|o.charCodeAt(l)&1023),a+=Ne[240|h>>18]+Ne[128|h>>12&63]+Ne[128|h>>6&63]+Ne[128|h&63]}return a},e_=function(t){for(var e=[{obj:{o:t},prop:"o"}],i=[],s=0;s<e.length;++s)for(var n=e[s],o=n.obj[n.prop],a=Object.keys(o),l=0;l<a.length;++l){var h=a[l],c=o[h];typeof c=="object"&&c!==null&&i.indexOf(c)===-1&&(e.push({obj:o,prop:h}),i.push(c))}return K0(e),t},r_=function(t){return Object.prototype.toString.call(t)==="[object RegExp]"},i_=function(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},s_=function(t,e){return[].concat(t,e)},n_=function(t,e){if(Fr(t)){for(var i=[],s=0;s<t.length;s+=1)i.push(e(t[s]));return i}return e(t)},Gc={arrayToObject:kc,assign:J0,combine:s_,compact:e_,decode:Q0,encode:t_,isBuffer:i_,isRegExp:r_,maybeMap:n_,merge:Z0},$c=W0,rn=Gc,ns=sa,o_=Object.prototype.hasOwnProperty,Hc={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},Ue=Array.isArray,a_=Array.prototype.push,Xc=function(r,t){a_.apply(r,Ue(t)?t:[t])},l_=Date.prototype.toISOString,Vc=ns.default,Lt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:rn.encode,encodeValuesOnly:!1,format:Vc,formatter:ns.formatters[Vc],indices:!1,serializeDate:function(t){return l_.call(t)},skipNulls:!1,strictNullHandling:!1},h_=function(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"},oa={},c_=function r(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g,y,v){for(var _=t,x=v,T=0,P=!1;(x=x.get(oa))!==void 0&&!P;){var I=x.get(t);if(T+=1,typeof I<"u"){if(I===T)throw new RangeError("Cyclic object value");P=!0}typeof x.get(oa)>"u"&&(T=0)}if(typeof c=="function"?_=c(e,_):_ instanceof Date?_=f(_):i==="comma"&&Ue(_)&&(_=rn.maybeMap(_,function(R){return R instanceof Date?f(R):R})),_===null){if(o)return h&&!g?h(e,Lt.encoder,y,"key",p):e;_=""}if(h_(_)||rn.isBuffer(_)){if(h){var b=g?e:h(e,Lt.encoder,y,"key",p);return[m(b)+"="+m(h(_,Lt.encoder,y,"value",p))]}return[m(e)+"="+m(String(_))]}var E=[];if(typeof _>"u")return E;var S;if(i==="comma"&&Ue(_))g&&h&&(_=rn.maybeMap(_,h)),S=[{value:_.length>0?_.join(",")||null:void 0}];else if(Ue(c))S=c;else{var D=Object.keys(_);S=u?D.sort(u):D}var B=l?e.replace(/\./g,"%2E"):e,w=s&&Ue(_)&&_.length===1?B+"[]":B;if(n&&Ue(_)&&_.length===0)return w+"[]";for(var C=0;C<S.length;++C){var F=S[C],k=typeof F=="object"&&typeof F.value<"u"?F.value:_[F];if(!(a&&k===null)){var G=d&&l?F.replace(/\./g,"%2E"):F,$=Ue(_)?typeof i=="function"?i(w,G):w:w+(d?"."+G:"["+G+"]");v.set(t,T);var nt=$c();nt.set(oa,v),Xc(E,r(k,$,i,s,n,o,a,l,i==="comma"&&g&&Ue(_)?null:h,c,u,d,f,p,m,g,y,nt))}}return E},u_=function(t){if(!t)return Lt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");var e=t.charset||Lt.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var i=ns.default;if(typeof t.format<"u"){if(!o_.call(ns.formatters,t.format))throw new TypeError("Unknown format option provided.");i=t.format}var s=ns.formatters[i],n=Lt.filter;(typeof t.filter=="function"||Ue(t.filter))&&(n=t.filter);var o;if(t.arrayFormat in Hc?o=t.arrayFormat:"indices"in t?o=t.indices?"indices":"repeat":o=Lt.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var a=typeof t.allowDots>"u"?t.encodeDotInKeys===!0?!0:Lt.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:Lt.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Lt.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Lt.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?Lt.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:Lt.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:Lt.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:Lt.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:Lt.encodeValuesOnly,filter:n,format:i,formatter:s,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:Lt.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:Lt.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Lt.strictNullHandling}},d_=function(r,t){var e=r,i=u_(t),s,n;typeof i.filter=="function"?(n=i.filter,e=n("",e)):Ue(i.filter)&&(n=i.filter,s=n);var o=[];if(typeof e!="object"||e===null)return"";var a=Hc[i.arrayFormat],l=a==="comma"&&i.commaRoundTrip;s||(s=Object.keys(e)),i.sort&&s.sort(i.sort);for(var h=$c(),c=0;c<s.length;++c){var u=s[c];i.skipNulls&&e[u]===null||Xc(o,c_(e[u],u,a,l,i.allowEmptyArrays,i.strictNullHandling,i.skipNulls,i.encodeDotInKeys,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,h))}var d=o.join(i.delimiter),f=i.addQueryPrefix===!0?"?":"";return i.charsetSentinel&&(i.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""},bi=Gc,aa=Object.prototype.hasOwnProperty,f_=Array.isArray,Rt={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!0,decoder:bi.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},p_=function(r){return r.replace(/&#(\d+);/g,function(t,e){return String.fromCharCode(parseInt(e,10))})},zc=function(r,t){return r&&typeof r=="string"&&t.comma&&r.indexOf(",")>-1?r.split(","):r},m_="utf8=%26%2310003%3B",g_="utf8=%E2%9C%93",y_=function(t,e){var i={__proto__:null},s=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,n=e.parameterLimit===1/0?void 0:e.parameterLimit,o=s.split(e.delimiter,n),a=-1,l,h=e.charset;if(e.charsetSentinel)for(l=0;l<o.length;++l)o[l].indexOf("utf8=")===0&&(o[l]===g_?h="utf-8":o[l]===m_&&(h="iso-8859-1"),a=l,l=o.length);for(l=0;l<o.length;++l)if(l!==a){var c=o[l],u=c.indexOf("]="),d=u===-1?c.indexOf("="):u+1,f,p;d===-1?(f=e.decoder(c,Rt.decoder,h,"key"),p=e.strictNullHandling?null:""):(f=e.decoder(c.slice(0,d),Rt.decoder,h,"key"),p=bi.maybeMap(zc(c.slice(d+1),e),function(g){return e.decoder(g,Rt.decoder,h,"value")})),p&&e.interpretNumericEntities&&h==="iso-8859-1"&&(p=p_(p)),c.indexOf("[]=")>-1&&(p=f_(p)?[p]:p);var m=aa.call(i,f);m&&e.duplicates==="combine"?i[f]=bi.combine(i[f],p):(!m||e.duplicates==="last")&&(i[f]=p)}return i},__=function(r,t,e,i){for(var s=i?t:zc(t,e),n=r.length-1;n>=0;--n){var o,a=r[n];if(a==="[]"&&e.parseArrays)o=e.allowEmptyArrays&&s===""?[]:[].concat(s);else{o=e.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,h=e.decodeDotInKeys?l.replace(/%2E/g,"."):l,c=parseInt(h,10);!e.parseArrays&&h===""?o={0:s}:!isNaN(c)&&a!==h&&String(c)===h&&c>=0&&e.parseArrays&&c<=e.arrayLimit?(o=[],o[c]=s):h!=="__proto__"&&(o[h]=s)}s=o}return s},v_=function(t,e,i,s){if(t){var n=i.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=i.depth>0&&o.exec(n),h=l?n.slice(0,l.index):n,c=[];if(h){if(!i.plainObjects&&aa.call(Object.prototype,h)&&!i.allowPrototypes)return;c.push(h)}for(var u=0;i.depth>0&&(l=a.exec(n))!==null&&u<i.depth;){if(u+=1,!i.plainObjects&&aa.call(Object.prototype,l[1].slice(1,-1))&&!i.allowPrototypes)return;c.push(l[1])}return l&&c.push("["+n.slice(l.index)+"]"),__(c,e,i,s)}},x_=function(t){if(!t)return Rt;if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.decodeDotInKeys<"u"&&typeof t.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(t.decoder!==null&&typeof t.decoder<"u"&&typeof t.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var e=typeof t.charset>"u"?Rt.charset:t.charset,i=typeof t.duplicates>"u"?Rt.duplicates:t.duplicates;if(i!=="combine"&&i!=="first"&&i!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var s=typeof t.allowDots>"u"?t.decodeDotInKeys===!0?!0:Rt.allowDots:!!t.allowDots;return{allowDots:s,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:Rt.allowEmptyArrays,allowPrototypes:typeof t.allowPrototypes=="boolean"?t.allowPrototypes:Rt.allowPrototypes,allowSparse:typeof t.allowSparse=="boolean"?t.allowSparse:Rt.allowSparse,arrayLimit:typeof t.arrayLimit=="number"?t.arrayLimit:Rt.arrayLimit,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:Rt.charsetSentinel,comma:typeof t.comma=="boolean"?t.comma:Rt.comma,decodeDotInKeys:typeof t.decodeDotInKeys=="boolean"?t.decodeDotInKeys:Rt.decodeDotInKeys,decoder:typeof t.decoder=="function"?t.decoder:Rt.decoder,delimiter:typeof t.delimiter=="string"||bi.isRegExp(t.delimiter)?t.delimiter:Rt.delimiter,depth:typeof t.depth=="number"||t.depth===!1?+t.depth:Rt.depth,duplicates:i,ignoreQueryPrefix:t.ignoreQueryPrefix===!0,interpretNumericEntities:typeof t.interpretNumericEntities=="boolean"?t.interpretNumericEntities:Rt.interpretNumericEntities,parameterLimit:typeof t.parameterLimit=="number"?t.parameterLimit:Rt.parameterLimit,parseArrays:t.parseArrays!==!1,plainObjects:typeof t.plainObjects=="boolean"?t.plainObjects:Rt.plainObjects,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:Rt.strictNullHandling}},b_=function(r,t){var e=x_(t);if(r===""||r===null||typeof r>"u")return e.plainObjects?Object.create(null):{};for(var i=typeof r=="string"?y_(r,e):r,s=e.plainObjects?Object.create(null):{},n=Object.keys(i),o=0;o<n.length;++o){var a=n[o],l=v_(a,i[a],e,typeof r=="string");s=bi.merge(s,l,e)}return e.allowSparse===!0?s:bi.compact(s)},w_=d_,E_=b_,T_=sa,A_={formats:T_,parse:E_,stringify:w_},S_=hy;function ir(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var I_=/^([a-z0-9.+-]+:)/i,C_=/:[0-9]*$/,P_=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,R_=["<",">",'"',"`"," ","\r",`
|
|
5
|
+
`," "],M_=["{","}","|","\\","^","`"].concat(R_),la=["'"].concat(M_),Wc=["%","/","?",";","#"].concat(la),jc=["/","?","#"],B_=255,Yc=/^[+a-z0-9A-Z_-]{0,63}$/,D_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,O_={javascript:!0,"javascript:":!0},ha={javascript:!0,"javascript:":!0},wi={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},ca=A_;function F_(r,t,e){if(r&&typeof r=="object"&&r instanceof ir)return r;var i=new ir;return i.parse(r,t,e),i}ir.prototype.parse=function(r,t,e){if(typeof r!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof r);var i=r.indexOf("?"),s=i!==-1&&i<r.indexOf("#")?"?":"#",n=r.split(s),o=/\\/g;n[0]=n[0].replace(o,"/"),r=n.join(s);var a=r;if(a=a.trim(),!e&&r.split("#").length===1){var l=P_.exec(a);if(l)return this.path=a,this.href=a,this.pathname=l[1],l[2]?(this.search=l[2],t?this.query=ca.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var h=I_.exec(a);if(h){h=h[0];var c=h.toLowerCase();this.protocol=c,a=a.substr(h.length)}if(e||h||a.match(/^\/\/[^@/]+@[^@/]+/)){var u=a.substr(0,2)==="//";u&&!(h&&ha[h])&&(a=a.substr(2),this.slashes=!0)}if(!ha[h]&&(u||h&&!wi[h])){for(var d=-1,f=0;f<jc.length;f++){var p=a.indexOf(jc[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var m,g;d===-1?g=a.lastIndexOf("@"):g=a.lastIndexOf("@",d),g!==-1&&(m=a.slice(0,g),a=a.slice(g+1),this.auth=decodeURIComponent(m)),d=-1;for(var f=0;f<Wc.length;f++){var p=a.indexOf(Wc[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var y=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!y)for(var v=this.hostname.split(/\./),f=0,_=v.length;f<_;f++){var x=v[f];if(x&&!x.match(Yc)){for(var T="",P=0,I=x.length;P<I;P++)x.charCodeAt(P)>127?T+="x":T+=x[P];if(!T.match(Yc)){var b=v.slice(0,f),E=v.slice(f+1),S=x.match(D_);S&&(b.push(S[1]),E.unshift(S[2])),E.length&&(a="/"+E.join(".")+a),this.hostname=b.join(".");break}}}this.hostname.length>B_?this.hostname="":this.hostname=this.hostname.toLowerCase(),y||(this.hostname=S_.toASCII(this.hostname));var D=this.port?":"+this.port:"",B=this.hostname||"";this.host=B+D,this.href+=this.host,y&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!O_[c])for(var f=0,_=la.length;f<_;f++){var w=la[f];if(a.indexOf(w)!==-1){var C=encodeURIComponent(w);C===w&&(C=escape(w)),a=a.split(w).join(C)}}var F=a.indexOf("#");F!==-1&&(this.hash=a.substr(F),a=a.slice(0,F));var k=a.indexOf("?");if(k!==-1?(this.search=a.substr(k),this.query=a.substr(k+1),t&&(this.query=ca.parse(this.query)),a=a.slice(0,k)):t&&(this.search="",this.query={}),a&&(this.pathname=a),wi[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var D=this.pathname||"",G=this.search||"";this.path=D+G}return this.href=this.format(),this},ir.prototype.format=function(){var r=this.auth||"";r&&(r=encodeURIComponent(r),r=r.replace(/%3A/i,":"),r+="@");var t=this.protocol||"",e=this.pathname||"",i=this.hash||"",s=!1,n="";this.host?s=r+this.host:this.hostname&&(s=r+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(n=ca.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||wi[t])&&s!==!1?(s="//"+(s||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):s||(s=""),i&&i.charAt(0)!=="#"&&(i="#"+i),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+s+e+o+i},ir.prototype.resolve=function(r){return this.resolveObject(F_(r,!1,!0)).format()},ir.prototype.resolveObject=function(r){if(typeof r=="string"){var t=new ir;t.parse(r,!1,!0),r=t}for(var e=new ir,i=Object.keys(this),s=0;s<i.length;s++){var n=i[s];e[n]=this[n]}if(e.hash=r.hash,r.href==="")return e.href=e.format(),e;if(r.slashes&&!r.protocol){for(var o=Object.keys(r),a=0;a<o.length;a++){var l=o[a];l!=="protocol"&&(e[l]=r[l])}return wi[e.protocol]&&e.hostname&&!e.pathname&&(e.pathname="/",e.path=e.pathname),e.href=e.format(),e}if(r.protocol&&r.protocol!==e.protocol){if(!wi[r.protocol]){for(var h=Object.keys(r),c=0;c<h.length;c++){var u=h[c];e[u]=r[u]}return e.href=e.format(),e}if(e.protocol=r.protocol,!r.host&&!ha[r.protocol]){for(var _=(r.pathname||"").split("/");_.length&&!(r.host=_.shift()););r.host||(r.host=""),r.hostname||(r.hostname=""),_[0]!==""&&_.unshift(""),_.length<2&&_.unshift(""),e.pathname=_.join("/")}else e.pathname=r.pathname;if(e.search=r.search,e.query=r.query,e.host=r.host||"",e.auth=r.auth,e.hostname=r.hostname||r.host,e.port=r.port,e.pathname||e.search){var d=e.pathname||"",f=e.search||"";e.path=d+f}return e.slashes=e.slashes||r.slashes,e.href=e.format(),e}var p=e.pathname&&e.pathname.charAt(0)==="/",m=r.host||r.pathname&&r.pathname.charAt(0)==="/",g=m||p||e.host&&r.pathname,y=g,v=e.pathname&&e.pathname.split("/")||[],_=r.pathname&&r.pathname.split("/")||[],x=e.protocol&&!wi[e.protocol];if(x&&(e.hostname="",e.port=null,e.host&&(v[0]===""?v[0]=e.host:v.unshift(e.host)),e.host="",r.protocol&&(r.hostname=null,r.port=null,r.host&&(_[0]===""?_[0]=r.host:_.unshift(r.host)),r.host=null),g=g&&(_[0]===""||v[0]==="")),m)e.host=r.host||r.host===""?r.host:e.host,e.hostname=r.hostname||r.hostname===""?r.hostname:e.hostname,e.search=r.search,e.query=r.query,v=_;else if(_.length)v||(v=[]),v.pop(),v=v.concat(_),e.search=r.search,e.query=r.query;else if(r.search!=null){if(x){e.host=v.shift(),e.hostname=e.host;var T=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;T&&(e.auth=T.shift(),e.hostname=T.shift(),e.host=e.hostname)}return e.search=r.search,e.query=r.query,(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.href=e.format(),e}if(!v.length)return e.pathname=null,e.search?e.path="/"+e.search:e.path=null,e.href=e.format(),e;for(var P=v.slice(-1)[0],I=(e.host||r.host||v.length>1)&&(P==="."||P==="..")||P==="",b=0,E=v.length;E>=0;E--)P=v[E],P==="."?v.splice(E,1):P===".."?(v.splice(E,1),b++):b&&(v.splice(E,1),b--);if(!g&&!y)for(;b--;b)v.unshift("..");g&&v[0]!==""&&(!v[0]||v[0].charAt(0)!=="/")&&v.unshift(""),I&&v.join("/").substr(-1)!=="/"&&v.push("");var S=v[0]===""||v[0]&&v[0].charAt(0)==="/";if(x){e.hostname=S?"":v.length?v.shift():"",e.host=e.hostname;var T=e.host&&e.host.indexOf("@")>0?e.host.split("@"):!1;T&&(e.auth=T.shift(),e.hostname=T.shift(),e.host=e.hostname)}return g=g||e.host&&v.length,g&&!S&&v.unshift(""),v.length>0?e.pathname=v.join("/"):(e.pathname=null,e.path=null),(e.pathname!==null||e.search!==null)&&(e.path=(e.pathname?e.pathname:"")+(e.search?e.search:"")),e.auth=r.auth||e.auth,e.slashes=e.slashes||r.slashes,e.href=e.format(),e},ir.prototype.parseHost=function(){var r=this.host,t=C_.exec(r);t&&(t=t[0],t!==":"&&(this.port=t.substr(1)),r=r.substr(0,r.length-t.length)),r&&(this.hostname=r)};const qc={};function at(r,t,e=3){if(qc[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
6
6
|
Deprecated since v${r}`):(i=i.split(`
|
|
7
7
|
`).splice(e).join(`
|
|
8
8
|
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
|
|
9
9
|
Deprecated since v${r}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
|
|
10
|
-
Deprecated since v${r}`),console.warn(i))),qc[t]=!0}function ye(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function ns(r){return r.split("?")[0].split("#")[0]}function L_(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N_(r,t,e){return r.replace(new RegExp(L_(t),"g"),e)}function U_(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const kt={toPosix(r){return N_(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){ye(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(ye(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=ns(this.toPosix(t??W.ADAPTER.getBaseUrl())),s=ns(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?kt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(ye(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=U_(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return ye(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(ye(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(ye(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){ye(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){ye(r),t&&ye(t),r=ns(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){ye(r),r=ns(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!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?"":r.slice(t,i)},parse(r){ye(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=ns(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h: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=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let ua;async function k_(){return ua??(ua=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return re.UNPACK;const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return re.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?re.PMA:re.UNPACK})()),ua}let da;function G_(){return typeof da>"u"&&(da=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:W.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!W.ADAPTER.getWebGLRenderingContext())return!1;const e=W.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),da}var $_={grad:.9,turn:360,rad:360/(2*Math.PI)},sr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Gt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},fe=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Kc=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Zc=function(r){return{r:fe(r.r,0,255),g:fe(r.g,0,255),b:fe(r.b,0,255),a:fe(r.a)}},fa=function(r){return{r:Gt(r.r),g:Gt(r.g),b:Gt(r.b),a:Gt(r.a,3)}},H_=/^#([0-9a-f]{3,8})$/i,sn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Jc=function(r){var t=r.r,e=r.g,i=r.b,s=r.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:s}},Qc=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:s}},tu=function(r){return{h:Kc(r.h),s:fe(r.s,0,100),l:fe(r.l,0,100),a:fe(r.a)}},eu=function(r){return{h:Gt(r.h),s:Gt(r.s),l:Gt(r.l),a:Gt(r.a,3)}},ru=function(r){return Qc((e=(t=r).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},os=function(r){return{h:(t=Jc(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},X_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,V_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,z_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,W_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pa={string:[[function(r){var t=H_.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Gt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Gt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=z_.exec(r)||W_.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Zc({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(r){var t=X_.exec(r)||V_.exec(r);if(!t)return null;var e,i,s=tu({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*($_[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ru(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return sr(t)&&sr(e)&&sr(i)?Zc({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!sr(t)||!sr(e)||!sr(i))return null;var o=tu({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return ru(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!sr(t)||!sr(e)||!sr(i))return null;var o=function(a){return{h:Kc(a.h),s:fe(a.s,0,100),v:fe(a.v,0,100),a:fe(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Qc(o)},"hsv"]]},iu=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},j_=function(r){return typeof r=="string"?iu(r.trim(),pa.string):typeof r=="object"&&r!==null?iu(r,pa.object):[null,void 0]},ma=function(r,t){var e=os(r);return{h:e.h,s:fe(e.s+100*t,0,100),l:e.l,a:e.a}},ga=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},su=function(r,t){var e=os(r);return{h:e.h,s:e.s,l:fe(e.l+100*t,0,100),a:e.a}},ya=function(){function r(t){this.parsed=j_(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Gt(ga(this.rgba),2)},r.prototype.isDark=function(){return ga(this.rgba)<.5},r.prototype.isLight=function(){return ga(this.rgba)>=.5},r.prototype.toHex=function(){return t=fa(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?sn(Gt(255*n)):"","#"+sn(e)+sn(i)+sn(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return fa(this.rgba)},r.prototype.toRgbString=function(){return t=fa(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return eu(os(this.rgba))},r.prototype.toHslString=function(){return t=eu(os(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=Jc(this.rgba),{h:Gt(t.h),s:Gt(t.s),v:Gt(t.v),a:Gt(t.a,3)};var t},r.prototype.invert=function(){return ke({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),ke(ma(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),ke(ma(this.rgba,-t))},r.prototype.grayscale=function(){return ke(ma(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),ke(su(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),ke(su(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?ke({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Gt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=os(this.rgba);return typeof t=="number"?ke({h:t,s:e.s,l:e.l,a:e.a}):Gt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===ke(t).toHex()},r}(),ke=function(r){return r instanceof ya?r:new ya(r)},nu=[],Y_=function(r){r.forEach(function(t){nu.indexOf(t)<0&&(t(ya,pa),nu.push(t))})};function q_(r,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 s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var p in e){var m=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<u&&(u=m,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}Y_([q_]);const wi=class Zn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Zn)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}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,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=Zn.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,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,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,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,s=(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,s,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,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Zn.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=ke(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,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((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};wi.shared=new wi,wi.temp=new wi,wi.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let vt=wi;function K_(r){return at("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),vt.shared.setValue(r).toHex()}function Z_(r){return at("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),vt.shared.setValue(r).toNumber()}function J_(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[J.NORMAL_NPM]=J.NORMAL,r[J.ADD_NPM]=J.ADD,r[J.SCREEN_NPM]=J.SCREEN,t[J.NORMAL]=J.NORMAL_NPM,t[J.ADD]=J.ADD_NPM,t[J.SCREEN]=J.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const ou=J_();function au(r,t){return ou[t?1:0][r]}function Q_(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function lu(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}function nn(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function hu(r){return!(r&r-1)&&!!r}function cu(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Ei(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function gr(r){return r===0?0:r<0?-1:1}let tv=0;function Lr(){return++tv}const _a=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};_a.EMPTY=new _a(0,0,0,0);let uu=_a;const du={},Ge=Object.create(null),yr=Object.create(null);class ev{constructor(t,e,i){this._canvas=W.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||W.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function fu(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function pu(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function rv(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&fu(s,t,o);)++o;if(o===e)return uu.EMPTY;for(;fu(s,t,l);)--l;for(;pu(s,t,n,o,l);)++n;for(;pu(s,t,a,o,l);)--a;return++a,++l,new uu(n,o,a,l)}function iv(r){const t=rv(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function sv(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function nr(r,t=1){var i;const e=(i=W.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var $=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))($||{});const va=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},mu=(r,t)=>va(r).priority??t,Y={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(va).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(va).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(o=s[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>mu(n,e)-mu(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class xa{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const nv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
10
|
+
Deprecated since v${r}`),console.warn(i))),qc[t]=!0}function ye(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function os(r){return r.split("?")[0].split("#")[0]}function L_(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N_(r,t,e){return r.replace(new RegExp(L_(t),"g"),e)}function U_(r,t){let e="",i=0,s=-1,n=0,o=-1;for(let a=0;a<=r.length;++a){if(a<r.length)o=r.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||n===1))if(s!==a-1&&n===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),s=a,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=a,n=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(s+1,a)}`:e=r.slice(s+1,a),i=a-s-1;s=a,n=0}else o===46&&n!==-1?++n:n=-1}return e}const kt={toPosix(r){return N_(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){ye(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(ye(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=os(this.toPosix(t??z.ADAPTER.getBaseUrl())),s=os(this.toPosix(e??this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?kt.join(s,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(ye(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=U_(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return ye(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){if(r.length===0)return".";let t;for(let e=0;e<r.length;++e){const i=r[e];if(ye(i),i.length>0)if(t===void 0)t=i;else{const s=r[e-1]??"";this.joinExtensions.includes(this.extname(s).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(r){if(ye(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,s=!0;const n=this.getProtocol(r),o=r;r=r.slice(n.length);for(let a=r.length-1;a>=1;--a)if(t=r.charCodeAt(a),t===47){if(!s){i=a;break}}else s=!1;return i===-1?e?"/":this.isUrl(o)?n+r:n:e&&i===1?"//":n+r.slice(0,i)},rootname(r){ye(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){ye(r),t&&ye(t),r=os(this.toPosix(r));let e=0,i=-1,s=!0,n;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let o=t.length-1,a=-1;for(n=r.length-1;n>=0;--n){const l=r.charCodeAt(n);if(l===47){if(!s){e=n+1;break}}else a===-1&&(s=!1,a=n+1),o>=0&&(l===t.charCodeAt(o)?--o===-1&&(i=n):(o=-1,i=a))}return e===i?i=a:i===-1&&(i=r.length),r.slice(e,i)}for(n=r.length-1;n>=0;--n)if(r.charCodeAt(n)===47){if(!s){e=n+1;break}}else i===-1&&(s=!1,i=n+1);return i===-1?"":r.slice(e,i)},extname(r){ye(r),r=os(this.toPosix(r));let t=-1,e=0,i=-1,s=!0,n=0;for(let o=r.length-1;o>=0;--o){const a=r.charCodeAt(o);if(a===47){if(!s){e=o+1;break}continue}i===-1&&(s=!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?"":r.slice(t,i)},parse(r){ye(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=os(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let s;t.root=this.rootname(r),i||this.hasProtocol(r)?s=1:s=0;let n=-1,o=0,a=-1,l=!0,h=r.length-1,c=0;for(;h>=s;--h){if(e=r.charCodeAt(h),e===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),e===46?n===-1?n=h: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=r.slice(1,a):t.base=t.name=r.slice(o,a)):(o===0&&i?(t.name=r.slice(1,n),t.base=r.slice(1,a)):(t.name=r.slice(o,n),t.base=r.slice(o,a)),t.ext=r.slice(n,a)),t.dir=this.dirname(r),t},sep:"/",delimiter:":",joinExtensions:[".html"]};let ua;async function k_(){return ua??(ua=(async()=>{var n;const r=document.createElement("canvas").getContext("webgl");if(!r)return re.UNPACK;const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return re.UNPACK;const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e);const i=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t);const s=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,s),r.deleteFramebuffer(i),r.deleteTexture(e),(n=r.getExtension("WEBGL_lose_context"))==null||n.loseContext(),s[0]<=s[3]?re.PMA:re.UNPACK})()),ua}let da;function G_(){return typeof da>"u"&&(da=function(){var t;const r={stencil:!0,failIfMajorPerformanceCaveat:z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!z.ADAPTER.getWebGLRenderingContext())return!1;const e=z.ADAPTER.createCanvas();let i=e.getContext("webgl",r)||e.getContext("experimental-webgl",r);const s=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const n=i.getExtension("WEBGL_lose_context");n&&n.loseContext()}return i=null,s}catch{return!1}}()),da}var $_={grad:.9,turn:360,rad:360/(2*Math.PI)},sr=function(r){return typeof r=="string"?r.length>0:typeof r=="number"},Gt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},fe=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Kc=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Zc=function(r){return{r:fe(r.r,0,255),g:fe(r.g,0,255),b:fe(r.b,0,255),a:fe(r.a)}},fa=function(r){return{r:Gt(r.r),g:Gt(r.g),b:Gt(r.b),a:Gt(r.a,3)}},H_=/^#([0-9a-f]{3,8})$/i,sn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},Jc=function(r){var t=r.r,e=r.g,i=r.b,s=r.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:s}},Qc=function(r){var t=r.h,e=r.s,i=r.v,s=r.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),o=i*(1-e),a=i*(1-(t-n)*e),l=i*(1-(1-t+n)*e),h=n%6;return{r:255*[i,a,o,o,l,i][h],g:255*[l,i,i,a,o,o][h],b:255*[o,o,l,i,i,a][h],a:s}},tu=function(r){return{h:Kc(r.h),s:fe(r.s,0,100),l:fe(r.l,0,100),a:fe(r.a)}},eu=function(r){return{h:Gt(r.h),s:Gt(r.s),l:Gt(r.l),a:Gt(r.a,3)}},ru=function(r){return Qc((e=(t=r).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},as=function(r){return{h:(t=Jc(r)).h,s:(s=(200-(e=t.s))*(i=t.v)/100)>0&&s<200?e*i/100/(s<=100?s:200-s)*100:0,l:s/2,a:t.a};var t,e,i,s},X_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,V_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,z_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,W_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pa={string:[[function(r){var t=H_.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Gt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Gt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=z_.exec(r)||W_.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Zc({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(r){var t=X_.exec(r)||V_.exec(r);if(!t)return null;var e,i,s=tu({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*($_[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return ru(s)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,s=r.a,n=s===void 0?1:s;return sr(t)&&sr(e)&&sr(i)?Zc({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,s=r.a,n=s===void 0?1:s;if(!sr(t)||!sr(e)||!sr(i))return null;var o=tu({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return ru(o)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,s=r.a,n=s===void 0?1:s;if(!sr(t)||!sr(e)||!sr(i))return null;var o=function(a){return{h:Kc(a.h),s:fe(a.s,0,100),v:fe(a.v,0,100),a:fe(a.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Qc(o)},"hsv"]]},iu=function(r,t){for(var e=0;e<t.length;e++){var i=t[e][0](r);if(i)return[i,t[e][1]]}return[null,void 0]},j_=function(r){return typeof r=="string"?iu(r.trim(),pa.string):typeof r=="object"&&r!==null?iu(r,pa.object):[null,void 0]},ma=function(r,t){var e=as(r);return{h:e.h,s:fe(e.s+100*t,0,100),l:e.l,a:e.a}},ga=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},su=function(r,t){var e=as(r);return{h:e.h,s:e.s,l:fe(e.l+100*t,0,100),a:e.a}},ya=function(){function r(t){this.parsed=j_(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return this.parsed!==null},r.prototype.brightness=function(){return Gt(ga(this.rgba),2)},r.prototype.isDark=function(){return ga(this.rgba)<.5},r.prototype.isLight=function(){return ga(this.rgba)>=.5},r.prototype.toHex=function(){return t=fa(this.rgba),e=t.r,i=t.g,s=t.b,o=(n=t.a)<1?sn(Gt(255*n)):"","#"+sn(e)+sn(i)+sn(s)+o;var t,e,i,s,n,o},r.prototype.toRgb=function(){return fa(this.rgba)},r.prototype.toRgbString=function(){return t=fa(this.rgba),e=t.r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},r.prototype.toHsl=function(){return eu(as(this.rgba))},r.prototype.toHslString=function(){return t=eu(as(this.rgba)),e=t.h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},r.prototype.toHsv=function(){return t=Jc(this.rgba),{h:Gt(t.h),s:Gt(t.s),v:Gt(t.v),a:Gt(t.a,3)};var t},r.prototype.invert=function(){return ke({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),ke(ma(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),ke(ma(this.rgba,-t))},r.prototype.grayscale=function(){return ke(ma(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),ke(su(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),ke(su(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?ke({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Gt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=as(this.rgba);return typeof t=="number"?ke({h:t,s:e.s,l:e.l,a:e.a}):Gt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===ke(t).toHex()},r}(),ke=function(r){return r instanceof ya?r:new ya(r)},nu=[],Y_=function(r){r.forEach(function(t){nu.indexOf(t)<0&&(t(ya,pa),nu.push(t))})};function q_(r,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 s in e)i[e[s]]=s;var n={};r.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=i[this.toHex()];if(h)return h;if(o!=null&&o.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new r(e[f]).toRgb();for(var p in e){var m=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));m<u&&(u=m,d=p)}return d}},t.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":e[a];return l?new r(l).toRgb():null},"name"])}Y_([q_]);const Ei=class Zn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof Zn)this._value=this.cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set PIXI.Color#value to null");(this._value===null||!this.isSourceEqual(this._value,t))&&(this.normalize(t),this._value=this.cloneSource(t))}}get value(){return this._value}cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((s,n)=>s===e[n]);if(t!==null&&e!==null){const s=Object.keys(t),n=Object.keys(e);return s.length!==n.length?!1:s.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}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,s]=this._components;return t=t??[],t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(s*255),t}toRgbArray(t){t=t??[];const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,t}toNumber(){return this._int}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,s,n]=Zn.temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=s,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,s=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}round(t){const[e,i,s]=this._components;return this._components[0]=Math.round(e*t)/t,this._components[1]=Math.round(i*t)/t,this._components[2]=Math.round(s*t)/t,this.refreshInt(),this._value=null,this}toArray(t){t=t??[];const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}normalize(t){let e,i,s,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,s=(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,s,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,s,n=255]=t,e/=255,i/=255,s/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const a=Zn.HEX_PATTERN.exec(t);a&&(t=`#${a[2]}`)}const o=ke(t);o.isValid()&&({r:e,g:i,b:s,a:n}=o.rgba,e/=255,i/=255,s/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=s,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((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}};Ei.shared=new Ei,Ei.temp=new Ei,Ei.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let vt=Ei;function K_(r){return at("7.2.0","utils.hex2string is deprecated, use Color#toHex instead"),vt.shared.setValue(r).toHex()}function Z_(r){return at("7.2.0","utils.rgb2hex is deprecated, use Color#toNumber instead"),vt.shared.setValue(r).toNumber()}function J_(){const r=[],t=[];for(let i=0;i<32;i++)r[i]=i,t[i]=i;r[Z.NORMAL_NPM]=Z.NORMAL,r[Z.ADD_NPM]=Z.ADD,r[Z.SCREEN_NPM]=Z.SCREEN,t[Z.NORMAL]=Z.NORMAL_NPM,t[Z.ADD]=Z.ADD_NPM,t[Z.SCREEN]=Z.SCREEN_NPM;const e=[];return e.push(t),e.push(r),e}const ou=J_();function au(r,t){return ou[t?1:0][r]}function Q_(r,t=null){const e=r*6;if(t=t||new Uint16Array(e),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,s=0;i<e;i+=6,s+=4)t[i+0]=s+0,t[i+1]=s+1,t[i+2]=s+2,t[i+3]=s+0,t[i+4]=s+2,t[i+5]=s+3;return t}function lu(r){if(r.BYTES_PER_ELEMENT===4)return r instanceof Float32Array?"Float32Array":r instanceof Uint32Array?"Uint32Array":"Int32Array";if(r.BYTES_PER_ELEMENT===2){if(r instanceof Uint16Array)return"Uint16Array"}else if(r.BYTES_PER_ELEMENT===1&&r instanceof Uint8Array)return"Uint8Array";return null}function nn(r){return r+=r===0?1:0,--r,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function hu(r){return!(r&r-1)&&!!r}function cu(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function Ti(r,t,e){const i=r.length;let s;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(s=t;s<n;++s)r[s]=r[s+e];r.length=n}function gr(r){return r===0?0:r<0?-1:1}let tv=0;function Lr(){return++tv}const _a=class{constructor(r,t,e,i){this.left=r,this.top=t,this.right=e,this.bottom=i}get width(){return this.right-this.left}get height(){return this.bottom-this.top}isEmpty(){return this.left===this.right||this.top===this.bottom}};_a.EMPTY=new _a(0,0,0,0);let uu=_a;const du={},Ge=Object.create(null),yr=Object.create(null);class ev{constructor(t,e,i){this._canvas=z.ADAPTER.createCanvas(),this._context=this._canvas.getContext("2d"),this.resolution=i||z.RESOLUTION,this.resize(t,e)}clear(){this._checkDestroyed(),this._context.setTransform(1,0,0,1,0,0),this._context.clearRect(0,0,this._canvas.width,this._canvas.height)}resize(t,e){this._checkDestroyed(),this._canvas.width=Math.round(t*this.resolution),this._canvas.height=Math.round(e*this.resolution)}destroy(){this._context=null,this._canvas=null}get width(){return this._checkDestroyed(),this._canvas.width}set width(t){this._checkDestroyed(),this._canvas.width=Math.round(t)}get height(){return this._checkDestroyed(),this._canvas.height}set height(t){this._checkDestroyed(),this._canvas.height=Math.round(t)}get canvas(){return this._checkDestroyed(),this._canvas}get context(){return this._checkDestroyed(),this._context}_checkDestroyed(){if(this._canvas===null)throw new TypeError("The CanvasRenderTarget has already been destroyed")}}function fu(r,t,e){for(let i=0,s=4*e*t;i<t;++i,s+=4)if(r[s+3]!==0)return!1;return!0}function pu(r,t,e,i,s){const n=4*t;for(let o=i,a=i*n+4*e;o<=s;++o,a+=n)if(r[a+3]!==0)return!1;return!0}function rv(r){const{width:t,height:e}=r,i=r.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const s=i.getImageData(0,0,t,e).data;let n=0,o=0,a=t-1,l=e-1;for(;o<e&&fu(s,t,o);)++o;if(o===e)return uu.EMPTY;for(;fu(s,t,l);)--l;for(;pu(s,t,n,o,l);)++n;for(;pu(s,t,a,o,l);)--a;return++a,++l,new uu(n,o,a,l)}function iv(r){const t=rv(r),{width:e,height:i}=t;let s=null;if(!t.isEmpty()){const n=r.getContext("2d");if(n===null)throw new TypeError("Failed to get canvas 2D context");s=n.getImageData(t.left,t.top,e,i)}return{width:e,height:i,data:s}}function sv(r,t=globalThis.location){if(r.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function nr(r,t=1){var i;const e=(i=z.RETINA_PREFIX)==null?void 0:i.exec(r);return e?parseFloat(e[1]):t}var X=(r=>(r.Renderer="renderer",r.Application="application",r.RendererSystem="renderer-webgl-system",r.RendererPlugin="renderer-webgl-plugin",r.CanvasRendererSystem="renderer-canvas-system",r.CanvasRendererPlugin="renderer-canvas-plugin",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r))(X||{});const va=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){if(!r.extension)throw new Error("Extension class must have an extension object");r={...typeof r.extension!="object"?{type:r.extension}:r.extension,ref:r}}if(typeof r=="object")r={...r};else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},mu=(r,t)=>va(r).priority??t,j={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(va).forEach(t=>{t.type.forEach(e=>{var i,s;return(s=(i=this._removeHandlers)[e])==null?void 0:s.call(i,t)})}),this},add(...r){return r.map(va).forEach(t=>{t.type.forEach(e=>{var n,o;const i=this._addHandlers,s=this._queue;i[e]?(n=i[e])==null||n.call(i,t):(s[e]=s[e]||[],(o=s[e])==null||o.push(t))})}),this},handle(r,t,e){var o;const i=this._addHandlers,s=this._removeHandlers;if(i[r]||s[r])throw new Error(`Extension type ${r} already has a handler`);i[r]=t,s[r]=e;const n=this._queue;return n[r]&&((o=n[r])==null||o.forEach(a=>t(a)),delete n[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((s,n)=>mu(n,e)-mu(s,e)))},i=>{const s=t.indexOf(i.ref);s!==-1&&t.splice(s,1)})}};class xa{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData)}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}const nv=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
11
11
|
`);function ov(r){let t="";for(let e=0;e<r;++e)e>0&&(t+=`
|
|
12
|
-
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function av(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=nv.replace(/%forloop%/gi,ov(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const ba=0,wa=1,Ea=2,Ta=3,Aa=4,Sa=5;class $e{constructor(){this.data=0,this.blendMode=J.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<ba)}set blend(t){!!(this.data&1<<ba)!==t&&(this.data^=1<<ba)}get offsets(){return!!(this.data&1<<wa)}set offsets(t){!!(this.data&1<<wa)!==t&&(this.data^=1<<wa)}get culling(){return!!(this.data&1<<Ea)}set culling(t){!!(this.data&1<<Ea)!==t&&(this.data^=1<<Ea)}get depthTest(){return!!(this.data&1<<Ta)}set depthTest(t){!!(this.data&1<<Ta)!==t&&(this.data^=1<<Ta)}get depthMask(){return!!(this.data&1<<Sa)}set depthMask(t){!!(this.data&1<<Sa)!==t&&(this.data^=1<<Sa)}get clockwiseFrontFace(){return!!(this.data&1<<Aa)}set clockwiseFrontFace(t){!!(this.data&1<<Aa)!==t&&(this.data^=1<<Aa)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==J.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new $e;return t.depthTest=!1,t.blend=!0,t}}$e.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Ca=[];function gu(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=Ca.length-1;i>=0;--i){const s=Ca[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class _e{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][h](t,e,i,s,n,o,a,l);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(_e.prototype,{dispatch:{value:_e.prototype.emit},run:{value:_e.prototype.emit}});class as{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new _e("setRealSize"),this.onUpdate=new _e("update"),this.onError=new _e("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class on extends as{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===re.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const lv={scaleMode:tr.NEAREST,alphaMode:re.NPM},Ia=class Li extends qi{constructor(t=null,e=null){super(),e=Object.assign({},Li.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof as)&&(t=gu(t,p),t.internal=!0),this.resolution=f||W.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=i,this.uid=Lr(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=hu(this.realWidth)&&hu(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete yr[this.cacheId],delete Ge[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Li.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=W.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Lr()}`}n=t._pixiId}let o=yr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new Li(t,e),o.cacheId=n,Li.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new on(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=U.RGBA,a=Z.FLOAT):t instanceof Int32Array?(o=U.RGBA_INTEGER,a=Z.INT):t instanceof Uint32Array?(o=U.RGBA_INTEGER,a=Z.UNSIGNED_INT):t instanceof Int16Array?(o=U.RGBA_INTEGER,a=Z.SHORT):t instanceof Uint16Array?(o=U.RGBA_INTEGER,a=Z.UNSIGNED_SHORT):t instanceof Int8Array?(o=U.RGBA,a=Z.BYTE):(o=U.RGBA,a=Z.UNSIGNED_BYTE),n.internal=!0,new Li(n,Object.assign({},lv,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),yr[e]&&yr[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),yr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=yr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete yr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete yr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Ia.defaultOptions={mipmap:De.POW2,anisotropicLevel:0,scaleMode:tr.LINEAR,wrapMode:dr.CLAMP,alphaMode:re.UNPACK,target:hi.TEXTURE_2D,format:U.RGBA,type:Z.UNSIGNED_BYTE},Ia._globalBatch=0;let et=Ia;class Pa{constructor(){this.texArray=null,this.blend=0,this.type=Be.TRIANGLES,this.start=0,this.size=0,this.data=null}}let hv=0;class Mt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=hv++,this.disposeRunner=new _e("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Fe.ELEMENT_ARRAY_BUFFER:Fe.ARRAY_BUFFER}get index(){return this.type===Fe.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Mt(t)}}class an{constructor(t,e=0,i=!1,s=Z.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new an(t,e,i,s,n)}}const cv={Float32Array,Uint32Array,Int32Array,Uint8Array};function uv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=lu(c);s[u]||(s[u]=new cv[u](n)),o=s[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(n)}const yu={5126:4,5123:2,5121:1};let dv=0;const fv={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class _r{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=dv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new _e("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Mt||(e instanceof Array&&(e=new Float32Array(e)),e=new Mt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,s,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new an(c,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Mt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Mt(t)),t.type=Fe.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Mt;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*yu[n.type]/4),n.buffer=0}for(i.data=uv(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new _r;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Mt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new an(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Fe.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new _r,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new fv[lu(o.buffers[a].data)](s[a]),e.buffers[a]=new Mt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Fe.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*yu[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class _u extends _r{constructor(t=!1){super(),this._buffer=new Mt(null,t,!1),this._indexBuffer=new Mt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,Z.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,Z.FLOAT).addAttribute("aColor",this._buffer,4,!0,Z.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,Z.FLOAT).addIndex(this._indexBuffer)}}const ln=Math.PI*2,pv=180/Math.PI,mv=Math.PI/180;var Vt=(r=>(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(Vt||{});class dt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new dt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}dt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const hn=[new dt,new dt,new dt,new dt];class it{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Vt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new it(0,0,0,0)}clone(){return new it(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const b=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=b)return!1;const T=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>T}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=hn[0].set(t.left,t.top),l=hn[1].set(t.left,t.bottom),h=hn[2].set(t.right,t.top),c=hn[3].set(t.right,t.bottom);if(h.x<=a.x||l.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(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=s||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*i+f*n,m=d*s+f*n,g=d*i+f*o,y=d*s+f*o;if(Math.max(p,m,g,y)<=d*a.x+f*a.y||Math.min(p,m,g,y)>=d*c.x+f*c.y)return!1;const x=u*(a.y-h.y),_=u*(h.x-a.x),v=x*i+_*n,w=x*s+_*n,R=x*i+_*o,C=x*s+_*o;return!(Math.max(v,w,R,C)<=x*a.x+_*a.y||Math.min(v,w,R,C)>=x*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),s=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=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=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=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=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=s,this.height=n-s,this}}it.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class cn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Vt.CIRC}clone(){return new cn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new it(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}cn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class un{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Vt.ELIP}clone(){return new un(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new it(this.x-this.width,this.y-this.height,this.width,this.height)}}un.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Nr{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Vt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Nr(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}Nr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class dn{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Vt.RREC}clone(){return new dn(this.x,this.y,this.width,this.height,this.radius)}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 s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}dn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class wt{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new dt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new dt;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(ln-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new wt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new wt}static get TEMP_MATRIX(){return new wt}}wt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Ur=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],kr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Gr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$r=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ra=[],vu=[],fn=Math.sign;function gv(){for(let r=0;r<16;r++){const t=[];Ra.push(t);for(let e=0;e<16;e++){const i=fn(Ur[r]*Ur[e]+Gr[r]*kr[e]),s=fn(kr[r]*Ur[e]+$r[r]*kr[e]),n=fn(Ur[r]*Gr[e]+Gr[r]*$r[e]),o=fn(kr[r]*Gr[e]+$r[r]*$r[e]);for(let a=0;a<16;a++)if(Ur[a]===i&&kr[a]===s&&Gr[a]===n&&$r[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new wt;t.set(Ur[r],kr[r],Gr[r],$r[r],0,0),vu.push(t)}}gv();const Ct={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>Ur[r],uY:r=>kr[r],vX:r=>Gr[r],vY:r=>$r[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Ra[r][t],sub:(r,t)=>Ra[r][Ct.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?Ct.S:Ct.N:Math.abs(t)*2<=Math.abs(r)?r>0?Ct.E:Ct.W:t>0?r>0?Ct.SE:Ct.SW:r>0?Ct.NE:Ct.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=vu[Ct.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class or{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new or(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}or.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Ma=class{constructor(){this.worldTransform=new wt,this.localTransform=new wt,this.position=new or(this.onChange,this,0,0),this.scale=new or(this.onChange,this,1,1),this.pivot=new or(this.onChange,this,0,0),this.skew=new or(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const e=r.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};Ma.IDENTITY=new Ma;let Ba=Ma;Ba.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var yv=`varying vec2 vTextureCoord;
|
|
12
|
+
else `),e<r-1&&(t+=`if(test == ${e}.0){}`);return t}function av(r,t){if(r===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const i=nv.replace(/%forloop%/gi,ov(r));if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))r=r/2|0;else break}return r}const ba=0,wa=1,Ea=2,Ta=3,Aa=4,Sa=5;class $e{constructor(){this.data=0,this.blendMode=Z.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<ba)}set blend(t){!!(this.data&1<<ba)!==t&&(this.data^=1<<ba)}get offsets(){return!!(this.data&1<<wa)}set offsets(t){!!(this.data&1<<wa)!==t&&(this.data^=1<<wa)}get culling(){return!!(this.data&1<<Ea)}set culling(t){!!(this.data&1<<Ea)!==t&&(this.data^=1<<Ea)}get depthTest(){return!!(this.data&1<<Ta)}set depthTest(t){!!(this.data&1<<Ta)!==t&&(this.data^=1<<Ta)}get depthMask(){return!!(this.data&1<<Sa)}set depthMask(t){!!(this.data&1<<Sa)!==t&&(this.data^=1<<Sa)}get clockwiseFrontFace(){return!!(this.data&1<<Aa)}set clockwiseFrontFace(t){!!(this.data&1<<Aa)!==t&&(this.data^=1<<Aa)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==Z.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new $e;return t.depthTest=!1,t.blend=!0,t}}$e.prototype.toString=function(){return`[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`};const Ia=[];function gu(r,t){if(!r)return null;let e="";if(typeof r=="string"){const i=/\.(\w{3,4})(?:$|\?|#)/i.exec(r);i&&(e=i[1].toLowerCase())}for(let i=Ia.length-1;i>=0;--i){const s=Ia[i];if(s.test&&s.test(r,e))return new s(r,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class _e{constructor(t){this.items=[],this._name=t,this._aliasCount=0}emit(t,e,i,s,n,o,a,l){if(arguments.length>8)throw new Error("max arguments reached");const{name:h,items:c}=this;this._aliasCount++;for(let u=0,d=c.length;u<d;u++)c[u][h](t,e,i,s,n,o,a,l);return c===this.items&&this._aliasCount--,this}ensureNonAliasedItems(){this._aliasCount>0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))}add(t){return t[this._name]&&(this.ensureNonAliasedItems(),this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&(this.ensureNonAliasedItems(),this.items.splice(e,1)),this}contains(t){return this.items.includes(t)}removeAll(){return this.ensureNonAliasedItems(),this.items.length=0,this}destroy(){this.removeAll(),this.items.length=0,this._name=""}get empty(){return this.items.length===0}get name(){return this._name}}Object.defineProperties(_e.prototype,{dispatch:{value:_e.prototype.emit},run:{value:_e.prototype.emit}});class ls{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new _e("setRealSize"),this.onUpdate=new _e("update"),this.onError=new _e("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,i){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class on extends ls{constructor(t,e){const{width:i,height:s}=e||{};if(!i||!s)throw new Error("BufferResource width or height invalid");super(i,s),this.data=t,this.unpackAlignment=e.unpackAlignment??4}upload(t,e,i){const s=t.gl;s.pixelStorei(s.UNPACK_ALIGNMENT,this.unpackAlignment),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===re.UNPACK);const n=e.realWidth,o=e.realHeight;return i.width===n&&i.height===o?s.texSubImage2D(e.target,0,0,0,n,o,e.format,i.type,this.data):(i.width=n,i.height=o,s.texImage2D(e.target,0,i.internalFormat,n,o,0,e.format,i.type,this.data)),!0}dispose(){this.data=null}static test(t){return t===null||t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}const lv={scaleMode:tr.NEAREST,alphaMode:re.NPM},Ca=class Ni extends Ki{constructor(t=null,e=null){super(),e=Object.assign({},Ni.defaultOptions,e);const{alphaMode:i,mipmap:s,anisotropicLevel:n,scaleMode:o,width:a,height:l,wrapMode:h,format:c,type:u,target:d,resolution:f,resourceOptions:p}=e;t&&!(t instanceof ls)&&(t=gu(t,p),t.internal=!0),this.resolution=f||z.RESOLUTION,this.width=Math.round((a||0)*this.resolution)/this.resolution,this.height=Math.round((l||0)*this.resolution)/this.resolution,this._mipmap=s,this.anisotropicLevel=n,this._wrapMode=h,this._scaleMode=o,this.format=c,this.type=u,this.target=d,this.alphaMode=i,this.uid=Lr(),this.touched=0,this.isPowerOfTwo=!1,this._refreshPOT(),this._glTextures={},this.dirtyId=0,this.dirtyStyleId=0,this.cacheId=null,this.valid=a>0&&l>0,this.textureCacheIds=[],this.destroyed=!1,this.resource=null,this._batchEnabled=0,this._batchLocation=0,this.parentTextureArray=null,this.setResource(t)}get realWidth(){return Math.round(this.width*this.resolution)}get realHeight(){return Math.round(this.height*this.resolution)}get mipmap(){return this._mipmap}set mipmap(t){this._mipmap!==t&&(this._mipmap=t,this.dirtyStyleId++)}get scaleMode(){return this._scaleMode}set scaleMode(t){this._scaleMode!==t&&(this._scaleMode=t,this.dirtyStyleId++)}get wrapMode(){return this._wrapMode}set wrapMode(t){this._wrapMode!==t&&(this._wrapMode=t,this.dirtyStyleId++)}setStyle(t,e){let i;return t!==void 0&&t!==this.scaleMode&&(this.scaleMode=t,i=!0),e!==void 0&&e!==this.mipmap&&(this.mipmap=e,i=!0),i&&this.dirtyStyleId++,this}setSize(t,e,i){return i=i||this.resolution,this.setRealSize(t*i,e*i,i)}setRealSize(t,e,i){return this.resolution=i||this.resolution,this.width=Math.round(t)/this.resolution,this.height=Math.round(e)/this.resolution,this._refreshPOT(),this.update(),this}_refreshPOT(){this.isPowerOfTwo=hu(this.realWidth)&&hu(this.realHeight)}setResolution(t){const e=this.resolution;return e===t?this:(this.resolution=t,this.valid&&(this.width=Math.round(this.width*e)/t,this.height=Math.round(this.height*e)/t,this.emit("update",this)),this._refreshPOT(),this)}setResource(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this}update(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))}onError(t){this.emit("error",this,t)}destroy(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete yr[this.cacheId],delete Ge[this.cacheId],this.cacheId=null),this.valid=!1,this.dispose(),Ni.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}dispose(){this.emit("dispose",this)}castToBaseTexture(){return this}static from(t,e,i=z.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Lr()}`}n=t._pixiId}let o=yr[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in BaseTextureCache.`);return o||(o=new Ni(t,e),o.cacheId=n,Ni.addToCache(o,n)),o}static fromBuffer(t,e,i,s){t=t||new Float32Array(e*i*4);const n=new on(t,{width:e,height:i,...s==null?void 0:s.resourceOptions});let o,a;return t instanceof Float32Array?(o=U.RGBA,a=K.FLOAT):t instanceof Int32Array?(o=U.RGBA_INTEGER,a=K.INT):t instanceof Uint32Array?(o=U.RGBA_INTEGER,a=K.UNSIGNED_INT):t instanceof Int16Array?(o=U.RGBA_INTEGER,a=K.SHORT):t instanceof Uint16Array?(o=U.RGBA_INTEGER,a=K.UNSIGNED_SHORT):t instanceof Int8Array?(o=U.RGBA,a=K.BYTE):(o=U.RGBA,a=K.UNSIGNED_BYTE),n.internal=!0,new Ni(n,Object.assign({},lv,{type:a,format:o},s))}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),yr[e]&&yr[e]!==t&&console.warn(`BaseTexture added to the cache with an id [${e}] that already had an entry`),yr[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=yr[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete yr[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)delete yr[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}};Ca.defaultOptions={mipmap:De.POW2,anisotropicLevel:0,scaleMode:tr.LINEAR,wrapMode:dr.CLAMP,alphaMode:re.UNPACK,target:ci.TEXTURE_2D,format:U.RGBA,type:K.UNSIGNED_BYTE},Ca._globalBatch=0;let et=Ca;class Pa{constructor(){this.texArray=null,this.blend=0,this.type=Be.TRIANGLES,this.start=0,this.size=0,this.data=null}}let hv=0;class Mt{constructor(t,e=!0,i=!1){this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=i,this.static=e,this.id=hv++,this.disposeRunner=new _e("disposeBuffer")}update(t){t instanceof Array&&(t=new Float32Array(t)),this.data=t||this.data,this._updateID++}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.data=null}set index(t){this.type=t?Fe.ELEMENT_ARRAY_BUFFER:Fe.ARRAY_BUFFER}get index(){return this.type===Fe.ELEMENT_ARRAY_BUFFER}static from(t){return t instanceof Array&&(t=new Float32Array(t)),new Mt(t)}}class an{constructor(t,e=0,i=!1,s=K.FLOAT,n,o,a,l=1){this.buffer=t,this.size=e,this.normalized=i,this.type=s,this.stride=n,this.start=o,this.instance=a,this.divisor=l}destroy(){this.buffer=null}static from(t,e,i,s,n){return new an(t,e,i,s,n)}}const cv={Float32Array,Uint32Array,Int32Array,Uint8Array};function uv(r,t){let e=0,i=0;const s={};for(let l=0;l<r.length;l++)i+=t[l],e+=r[l].length;const n=new ArrayBuffer(e*4);let o=null,a=0;for(let l=0;l<r.length;l++){const h=t[l],c=r[l],u=lu(c);s[u]||(s[u]=new cv[u](n)),o=s[u];for(let d=0;d<c.length;d++){const f=(d/h|0)*i+a,p=d%h;o[f+p]=c[d]}a+=h}return new Float32Array(n)}const yu={5126:4,5123:2,5121:1};let dv=0;const fv={Float32Array,Uint32Array,Int32Array,Uint8Array,Uint16Array};class _r{constructor(t=[],e={}){this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=dv++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new _e("disposeGeometry"),this.refCount=0}addAttribute(t,e,i=0,s=!1,n,o,a,l=!1){if(!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof Mt||(e instanceof Array&&(e=new Float32Array(e)),e=new Mt(e));const h=t.split("|");if(h.length>1){for(let u=0;u<h.length;u++)this.addAttribute(h[u],e,i,s,n);return this}let c=this.buffers.indexOf(e);return c===-1&&(this.buffers.push(e),c=this.buffers.length-1),this.attributes[t]=new an(c,i,s,n,o,a,l),this.instanced=this.instanced||l,this}getAttribute(t){return this.attributes[t]}getBuffer(t){return this.buffers[this.getAttribute(t).buffer]}addIndex(t){return t instanceof Mt||(t instanceof Array&&(t=new Uint16Array(t)),t=new Mt(t)),t.type=Fe.ELEMENT_ARRAY_BUFFER,this.indexBuffer=t,this.buffers.includes(t)||this.buffers.push(t),this}getIndex(){return this.indexBuffer}interleave(){if(this.buffers.length===1||this.buffers.length===2&&this.indexBuffer)return this;const t=[],e=[],i=new Mt;let s;for(s in this.attributes){const n=this.attributes[s],o=this.buffers[n.buffer];t.push(o.data),e.push(n.size*yu[n.type]/4),n.buffer=0}for(i.data=uv(t,e),s=0;s<this.buffers.length;s++)this.buffers[s]!==this.indexBuffer&&this.buffers[s].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this}getSize(){for(const t in this.attributes){const e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0}dispose(){this.disposeRunner.emit(this,!1)}destroy(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null}clone(){const t=new _r;for(let e=0;e<this.buffers.length;e++)t.buffers[e]=new Mt(this.buffers[e].data.slice(0));for(const e in this.attributes){const i=this.attributes[e];t.attributes[e]=new an(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(t.indexBuffer=t.buffers[this.buffers.indexOf(this.indexBuffer)],t.indexBuffer.type=Fe.ELEMENT_ARRAY_BUFFER),t}static merge(t){const e=new _r,i=[],s=[],n=[];let o;for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)s[l]=s[l]||0,s[l]+=o.buffers[l].data.length,n[l]=0}for(let a=0;a<o.buffers.length;a++)i[a]=new fv[lu(o.buffers[a].data)](s[a]),e.buffers[a]=new Mt(i[a]);for(let a=0;a<t.length;a++){o=t[a];for(let l=0;l<o.buffers.length;l++)i[l].set(o.buffers[l].data,n[l]),n[l]+=o.buffers[l].data.length}if(e.attributes=o.attributes,o.indexBuffer){e.indexBuffer=e.buffers[o.buffers.indexOf(o.indexBuffer)],e.indexBuffer.type=Fe.ELEMENT_ARRAY_BUFFER;let a=0,l=0,h=0,c=0;for(let u=0;u<o.buffers.length;u++)if(o.buffers[u]!==o.indexBuffer){c=u;break}for(const u in o.attributes){const d=o.attributes[u];(d.buffer|0)===c&&(l+=d.size*yu[d.type]/4)}for(let u=0;u<t.length;u++){const d=t[u].indexBuffer.data;for(let f=0;f<d.length;f++)e.indexBuffer.data[f+h]+=a;a+=t[u].buffers[c].data.length/l,h+=d.length}}return e}}class _u extends _r{constructor(t=!1){super(),this._buffer=new Mt(null,t,!1),this._indexBuffer=new Mt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,K.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,K.FLOAT).addAttribute("aColor",this._buffer,4,!0,K.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,K.FLOAT).addIndex(this._indexBuffer)}}const ln=Math.PI*2,pv=180/Math.PI,mv=Math.PI/180;var Vt=(r=>(r[r.POLY=0]="POLY",r[r.RECT=1]="RECT",r[r.CIRC=2]="CIRC",r[r.ELIP=3]="ELIP",r[r.RREC=4]="RREC",r))(Vt||{});class dt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new dt(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}}dt.prototype.toString=function(){return`[@pixi/math:Point x=${this.x} y=${this.y}]`};const hn=[new dt,new dt,new dt,new dt];class it{constructor(t=0,e=0,i=0,s=0){this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s),this.type=Vt.RECT}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}static get EMPTY(){return new it(0,0,0,0)}clone(){return new it(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}intersects(t,e){if(!e){const b=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=b)return!1;const E=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>E}const i=this.left,s=this.right,n=this.top,o=this.bottom;if(s<=i||o<=n)return!1;const a=hn[0].set(t.left,t.top),l=hn[1].set(t.left,t.bottom),h=hn[2].set(t.right,t.top),c=hn[3].set(t.right,t.bottom);if(h.x<=a.x||l.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(l,l),e.apply(h,h),e.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=i||Math.min(a.x,l.x,h.x,c.x)>=s||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*i+f*n,m=d*s+f*n,g=d*i+f*o,y=d*s+f*o;if(Math.max(p,m,g,y)<=d*a.x+f*a.y||Math.min(p,m,g,y)>=d*c.x+f*c.y)return!1;const v=u*(a.y-h.y),_=u*(h.x-a.x),x=v*i+_*n,T=v*s+_*n,P=v*i+_*o,I=v*s+_*o;return!(Math.max(x,T,P,I)<=v*a.x+_*a.y||Math.min(x,T,P,I)>=v*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),s=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=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=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=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=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=s,this.height=n-s,this}}it.prototype.toString=function(){return`[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class cn{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=Vt.CIRC}clone(){return new cn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}getBounds(){return new it(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}}cn.prototype.toString=function(){return`[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`};class un{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=Vt.ELIP}clone(){return new un(this.x,this.y,this.width,this.height)}contains(t,e){if(this.width<=0||this.height<=0)return!1;let i=(t-this.x)/this.width,s=(e-this.y)/this.height;return i*=i,s*=s,i+s<=1}getBounds(){return new it(this.x-this.width,this.y-this.height,this.width,this.height)}}un.prototype.toString=function(){return`[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`};class Nr{constructor(...t){let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let s=0,n=e.length;s<n;s++)i.push(e[s].x,e[s].y);e=i}this.points=e,this.type=Vt.POLY,this.closeStroke=!0}clone(){const t=this.points.slice(),e=new Nr(t);return e.closeStroke=this.closeStroke,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,o=s-1;n<s;o=n++){const a=this.points[n*2],l=this.points[n*2+1],h=this.points[o*2],c=this.points[o*2+1];l>e!=c>e&&t<(h-a)*((e-l)/(c-l))+a&&(i=!i)}return i}}Nr.prototype.toString=function(){return`[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r,t)=>`${r}, ${t}`,"")}]`};class dn{constructor(t=0,e=0,i=0,s=0,n=20){this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n,this.type=Vt.RREC}clone(){return new dn(this.x,this.y,this.width,this.height,this.radius)}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 s=t-(this.x+i),n=e-(this.y+i);const o=i*i;if(s*s+n*n<=o||(s=t-(this.x+this.width-i),s*s+n*n<=o)||(n=e-(this.y+this.height-i),s*s+n*n<=o)||(s=t-(this.x+i),s*s+n*n<=o))return!0}return!1}}dn.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`};class wt{constructor(t=1,e=0,i=0,s=1,n=0,o=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,s,n,o){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=o,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new dt;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new dt;const i=1/(this.a*this.d+this.c*-this.b),s=t.x,n=t.y;return e.x=this.d*i*s+-this.c*i*n+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*n+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,n=this.c,o=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=o*e-this.ty*i,this.ty=o*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}setTransform(t,e,i,s,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,s=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=s*t.a+this.d*t.c,this.d=s*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,o=t.pivot,a=-Math.atan2(-s,n),l=Math.atan2(i,e),h=Math.abs(a+l);return h<1e-5||Math.abs(ln-h)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=a,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(o.x*e+o.y*s),t.position.y=this.ty+(o.x*i+o.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,o=t*s-e*i;return this.a=s/o,this.b=-e/o,this.c=-i/o,this.d=t/o,this.tx=(i*this.ty-s*n)/o,this.ty=-(t*this.ty-e*n)/o,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new wt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}static get IDENTITY(){return new wt}static get TEMP_MATRIX(){return new wt}}wt.prototype.toString=function(){return`[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`};const Ur=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],kr=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Gr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$r=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Ra=[],vu=[],fn=Math.sign;function gv(){for(let r=0;r<16;r++){const t=[];Ra.push(t);for(let e=0;e<16;e++){const i=fn(Ur[r]*Ur[e]+Gr[r]*kr[e]),s=fn(kr[r]*Ur[e]+$r[r]*kr[e]),n=fn(Ur[r]*Gr[e]+Gr[r]*$r[e]),o=fn(kr[r]*Gr[e]+$r[r]*$r[e]);for(let a=0;a<16;a++)if(Ur[a]===i&&kr[a]===s&&Gr[a]===n&&$r[a]===o){t.push(a);break}}}for(let r=0;r<16;r++){const t=new wt;t.set(Ur[r],kr[r],Gr[r],$r[r],0,0),vu.push(t)}}gv();const It={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:r=>Ur[r],uY:r=>kr[r],vX:r=>Gr[r],vY:r=>$r[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Ra[r][t],sub:(r,t)=>Ra[r][It.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?It.S:It.N:Math.abs(t)*2<=Math.abs(r)?r>0?It.E:It.W:t>0?r>0?It.SE:It.SW:r>0?It.NE:It.NW,matrixAppendRotationInv:(r,t,e=0,i=0)=>{const s=vu[It.inv(t)];s.tx=e,s.ty=i,r.append(s)}};class or{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}clone(t=this.cb,e=this.scope){return new or(t,e,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}or.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`};const Ma=class{constructor(){this.worldTransform=new wt,this.localTransform=new wt,this.position=new or(this.onChange,this,0,0),this.scale=new or(this.onChange,this,1,1),this.pivot=new or(this.onChange,this,0,0),this.skew=new or(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const r=this.localTransform;this._localID!==this._currentLocalID&&(r.a=this._cx*this.scale.x,r.b=this._sx*this.scale.x,r.c=this._cy*this.scale.y,r.d=this._sy*this.scale.y,r.tx=this.position.x-(this.pivot.x*r.a+this.pivot.y*r.c),r.ty=this.position.y-(this.pivot.x*r.b+this.pivot.y*r.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(r){const t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==r._worldID){const e=r.worldTransform,i=this.worldTransform;i.a=t.a*e.a+t.b*e.c,i.b=t.a*e.b+t.b*e.d,i.c=t.c*e.a+t.d*e.c,i.d=t.c*e.b+t.d*e.d,i.tx=t.tx*e.a+t.ty*e.c+e.tx,i.ty=t.tx*e.b+t.ty*e.d+e.ty,this._parentID=r._worldID,this._worldID++}}setFromMatrix(r){r.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this.updateSkew())}};Ma.IDENTITY=new Ma;let Ba=Ma;Ba.prototype.toString=function(){return`[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`};var yv=`varying vec2 vTextureCoord;
|
|
13
13
|
|
|
14
14
|
uniform sampler2D uSampler;
|
|
15
15
|
|
|
@@ -26,7 +26,7 @@ void main(void){
|
|
|
26
26
|
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
|
27
27
|
vTextureCoord = aTextureCoord;
|
|
28
28
|
}
|
|
29
|
-
`;function xu(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Da(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function bu(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Da(2*t);case"bvec3":return Da(3*t);case"bvec4":return Da(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const
|
|
29
|
+
`;function xu(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Da(r){const t=new Array(r);for(let e=0;e<t.length;e++)t[e]=!1;return t}function bu(r,t){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Da(2*t);case"bvec3":return Da(3*t);case"bvec4":return Da(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Ai=[{test:r=>r.type==="float"&&r.size===1&&!r.isArray,code:r=>`
|
|
30
30
|
if(uv["${r}"] !== ud["${r}"].value)
|
|
31
31
|
{
|
|
32
32
|
ud["${r}"].value = uv["${r}"]
|
|
@@ -292,18 +292,18 @@ void main(void){
|
|
|
292
292
|
renderer.shader.syncUniformBufferGroup(uv.${s}, '${s}');
|
|
293
293
|
`):e.push(`
|
|
294
294
|
renderer.shader.syncUniformGroup(uv.${s}, syncData);
|
|
295
|
-
`));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<
|
|
295
|
+
`));continue}const o=r.uniforms[s];let a=!1;for(let l=0;l<Ai.length;l++)if(Ai[l].test(n,o)){e.push(Ai[l].code(s,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?vv:xv)[n.type].replace("location",`ud["${s}"].location`);e.push(`
|
|
296
296
|
cu = ud["${s}"];
|
|
297
297
|
cv = cu.value;
|
|
298
298
|
v = uv["${s}"];
|
|
299
299
|
${l};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
|
|
300
|
-
`))}const wu={};let
|
|
300
|
+
`))}const wu={};let Si=wu;function wv(){if(Si===wu||Si!=null&&Si.isContextLost()){const r=z.ADAPTER.createCanvas();let t;z.PREFER_ENV>=Mr.WEBGL2&&(t=r.getContext("webgl2",{})),t||(t=r.getContext("webgl",{})||r.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Si=t}return Si}let pn;function Ev(){if(!pn){pn=de.MEDIUM;const r=wv();if(r&&r.getShaderPrecisionFormat){const t=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT);t&&(pn=t.precision?de.HIGH:de.MEDIUM)}}return pn}function Eu(r,t){const e=r.getShaderSource(t).split(`
|
|
301
301
|
`).map((h,c)=>`${c}: ${h}`),i=r.getShaderInfoLog(t),s=i.split(`
|
|
302
302
|
`),n={},o=s.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!n[h]?(n[h]=!0,!0):!1),a=[""];o.forEach(h=>{e[h-1]=`%c${e[h-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(`
|
|
303
|
-
`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Tv(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Eu(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Eu(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Av={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Tu(r){return Av[r]}let mn=null;const Au={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function Su(r,t){if(!mn){const e=Object.keys(Au);mn={};for(let i=0;i<e.length;++i){const s=e[i];mn[r[s]]=Au[s]}}return mn[t]}function
|
|
304
|
-
${r}`}else if(e!==de.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let
|
|
303
|
+
`);a[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function Tv(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Eu(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Eu(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}const Av={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Tu(r){return Av[r]}let mn=null;const Au={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"};function Su(r,t){if(!mn){const e=Object.keys(Au);mn={};for(let i=0;i<e.length;++i){const s=e[i];mn[r[s]]=Au[s]}}return mn[t]}function Iu(r,t,e){if(r.substring(0,9)!=="precision"){let i=t;return t===de.HIGH&&e!==de.HIGH&&(i=de.MEDIUM),`precision ${i} float;
|
|
304
|
+
${r}`}else if(e!==de.HIGH&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}let hs;function Sv(){if(typeof hs=="boolean")return hs;try{hs=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{hs=!1}return hs}let Iv=0;const gn={},Oa=class Ui{constructor(t,e,i="pixi-shader",s={}){this.extra={},this.id=Iv++,this.vertexSrc=t||Ui.defaultVertexSrc,this.fragmentSrc=e||Ui.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=s,this.vertexSrc.substring(0,8)!=="#version"&&(i=i.replace(/\s+/g,"-"),gn[i]?(gn[i]++,i+=`-${gn[i]}`):gn[i]=1,this.vertexSrc=`#define SHADER_NAME ${i}
|
|
305
305
|
${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${i}
|
|
306
|
-
${this.fragmentSrc}`,this.vertexSrc=
|
|
306
|
+
${this.fragmentSrc}`,this.vertexSrc=Iu(this.vertexSrc,Ui.defaultVertexPrecision,de.HIGH),this.fragmentSrc=Iu(this.fragmentSrc,Ui.defaultFragmentPrecision,Ev())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return _v}static get defaultFragmentSrc(){return yv}static from(t,e,i){const s=t+e;let n=du[s];return n||(du[s]=n=new Ui(t,e,i)),n}};Oa.defaultVertexPrecision=de.HIGH,Oa.defaultFragmentPrecision=rr.apple.device?de.HIGH:de.MEDIUM;let ar=Oa,Cv=0;class ve{constructor(t,e,i){this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=Cv++,this.static=!!e,this.ubo=!!i,t instanceof Mt?(this.buffer=t,this.buffer.type=Fe.UNIFORM_BUFFER,this.autoManage=!1,this.ubo=!0):(this.uniforms=t,this.ubo&&(this.buffer=new Mt(new Float32Array(1)),this.buffer.type=Fe.UNIFORM_BUFFER,this.autoManage=!0))}update(){this.dirtyId++,!this.autoManage&&this.buffer&&this.buffer.update()}add(t,e,i){if(!this.ubo)this.uniforms[t]=new ve(e,i);else throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them")}static from(t,e,i){return new ve(t,e,i)}static uboFrom(t,e){return new ve(t,e??!0,!0)}}class He{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof ve?this.uniformGroup=e:this.uniformGroup=new ve(e):this.uniformGroup=new ve({}),this.disposeRunner=new _e("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const i in e.uniforms){const s=e.uniforms[i];if(s.group===!0&&this.checkUniformExists(t,s))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,i){const s=ar.from(t,e);return new He(s,i)}}class Pv{constructor(t,e){if(this.vertexSrc=t,this.fragTemplate=e,this.programCache={},this.defaultGroupCache={},!e.includes("%count%"))throw new Error('Fragment template must contain "%count%".');if(!e.includes("%forloop%"))throw new Error('Fragment template must contain "%forloop%".')}generateShader(t){if(!this.programCache[t]){const i=new Int32Array(t);for(let n=0;n<t;n++)i[n]=n;this.defaultGroupCache[t]=ve.from({uSamplers:i},!0);let s=this.fragTemplate;s=s.replace(/%count%/gi,`${t}`),s=s.replace(/%forloop%/gi,this.generateSampleSrc(t)),this.programCache[t]=new ar(this.vertexSrc,s)}const e={tint:new Float32Array([1,1,1,1]),translationMatrix:new wt,default:this.defaultGroupCache[t]};return new He(this.programCache[t],e)}generateSampleSrc(t){let e="";e+=`
|
|
307
307
|
`,e+=`
|
|
308
308
|
`;for(let i=0;i<t;i++)i>0&&(e+=`
|
|
309
309
|
else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
|
|
@@ -311,7 +311,7 @@ else `),i<t-1&&(e+=`if(vTextureId < ${i}.5)`),e+=`
|
|
|
311
311
|
color = texture2D(uSamplers[${i}], vTextureCoord);`,e+=`
|
|
312
312
|
}`;return e+=`
|
|
313
313
|
`,e+=`
|
|
314
|
-
`,e}}class Fa{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Rv(){return!rr.apple.device}function Mv(r){let t=!0;const e=
|
|
314
|
+
`,e}}class Fa{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}function Rv(){return!rr.apple.device}function Mv(r){let t=!0;const e=z.ADAPTER.getNavigator();if(rr.tablet||rr.phone){if(rr.apple.device){const i=e.userAgent.match(/OS (\d+)_(\d+)?/);i&&parseInt(i[1],10)<11&&(t=!1)}if(rr.android.device){const i=e.userAgent.match(/Android\s([0-9.]*)/);i&&parseInt(i[1],10)<7&&(t=!1)}}return t?r:4}class yn{constructor(t){this.renderer=t}flush(){}destroy(){this.renderer=null}start(){}stop(){this.flush()}render(t){}}var Bv=`varying vec2 vTextureCoord;
|
|
315
315
|
varying vec4 vColor;
|
|
316
316
|
varying float vTextureId;
|
|
317
317
|
uniform sampler2D uSamplers[%count%];
|
|
@@ -342,7 +342,7 @@ void main(void){
|
|
|
342
342
|
vTextureId = aTextureId;
|
|
343
343
|
vColor = aColor * tint;
|
|
344
344
|
}
|
|
345
|
-
`;const
|
|
345
|
+
`;const cs=class Ae extends yn{constructor(t){super(t),this.setShaderGenerator(),this.geometryClass=_u,this.vertexSize=6,this.state=$e.for2d(),this.size=Ae.defaultBatchSize*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.maxTextures=1,this.renderer.on("prerender",this.onPrerender,this),t.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultMaxTextures(){return this._defaultMaxTextures=this._defaultMaxTextures??Mv(32),this._defaultMaxTextures}static set defaultMaxTextures(t){this._defaultMaxTextures=t}static get canUploadSameBuffer(){return this._canUploadSameBuffer=this._canUploadSameBuffer??Rv(),this._canUploadSameBuffer}static set canUploadSameBuffer(t){this._canUploadSameBuffer=t}get MAX_TEXTURES(){return at("7.1.0","BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"),this.maxTextures}static get defaultVertexSrc(){return Dv}static get defaultFragmentTemplate(){return Bv}setShaderGenerator({vertex:t=Ae.defaultVertexSrc,fragment:e=Ae.defaultFragmentTemplate}={}){this.shaderGenerator=new Pv(t,e)}contextChange(){const t=this.renderer.gl;z.PREFER_ENV===Mr.WEBGL_LEGACY?this.maxTextures=1:(this.maxTextures=Math.min(t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Ae.defaultMaxTextures),this.maxTextures=av(this.maxTextures,t)),this._shader=this.shaderGenerator.generateShader(this.maxTextures);for(let e=0;e<this._packedGeometryPoolSize;e++)this._packedGeometries[e]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:t,_textureArrayPool:e}=Ae,i=this.size/4,s=Math.floor(i/this.maxTextures)+1;for(;t.length<i;)t.push(new Pa);for(;e.length<s;)e.push(new Fa);for(let n=0;n<this.maxTextures;n++)this._tempBoundTextures[n]=null}onPrerender(){this._flushId=0}render(t){t._texture.valid&&(this._vertexCount+t.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=t.vertexData.length/2,this._indexCount+=t.indices.length,this._bufferedTextures[this._bufferSize]=t._texture.baseTexture,this._bufferedElements[this._bufferSize++]=t)}buildTexturesAndDrawCalls(){const{_bufferedTextures:t,maxTextures:e}=this,i=Ae._textureArrayPool,s=this.renderer.batch,n=this._tempBoundTextures,o=this.renderer.textureGC.count;let a=++et._globalBatch,l=0,h=i[0],c=0;s.copyBoundTextures(n,e);for(let u=0;u<this._bufferSize;++u){const d=t[u];t[u]=null,d._batchEnabled!==a&&(h.count>=e&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,u),c=u,h=i[++l],++a),d._batchEnabled=a,d.touched=o,h.elements[h.count++]=d)}h.count>0&&(s.boundArray(h,n,a,e),this.buildDrawCalls(h,c,this._bufferSize),++l,++a);for(let u=0;u<n.length;u++)n[u]=null;et._globalBatch=a}buildDrawCalls(t,e,i){const{_bufferedElements:s,_attributeBuffer:n,_indexBuffer:o,vertexSize:a}=this,l=Ae._drawCallPool;let h=this._dcIndex,c=this._aIndex,u=this._iIndex,d=l[h];d.start=this._iIndex,d.texArray=t;for(let f=e;f<i;++f){const p=s[f],m=p._texture.baseTexture,g=ou[m.alphaMode?1:0][p.blendMode];s[f]=null,e<f&&d.blend!==g&&(d.size=u-d.start,e=f,d=l[++h],d.texArray=t,d.start=u),this.packInterleavedGeometry(p,n,o,c,u),c+=p.vertexData.length/2*a,u+=p.indices.length,d.blend=g}e<i&&(d.size=u-d.start,++h),this._dcIndex=h,this._aIndex=c,this._iIndex=u}bindAndClearTexArray(t){const e=this.renderer.texture;for(let i=0;i<t.count;i++)e.bind(t.elements[i],t.ids[i]),t.elements[i]=null;t.count=0}updateGeometry(){const{_packedGeometries:t,_attributeBuffer:e,_indexBuffer:i}=this;Ae.canUploadSameBuffer?(t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,t[this._flushId]=new this.geometryClass),t[this._flushId]._buffer.update(e.rawBinaryData),t[this._flushId]._indexBuffer.update(i),this.renderer.geometry.bind(t[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const t=this._dcIndex,{gl:e,state:i}=this.renderer,s=Ae._drawCallPool;let n=null;for(let o=0;o<t;o++){const{texArray:a,type:l,size:h,start:c,blend:u}=s[o];n!==a&&(n=a,this.bindAndClearTexArray(a)),this.state.blendMode=u,i.set(this.state),e.drawElements(l,h,e.UNSIGNED_SHORT,c*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.maxTextures),this.renderer.shader.bind(this._shader),Ae.canUploadSameBuffer&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]&&this._packedGeometries[t].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(t){const e=nn(Math.ceil(t/8)),i=cu(e),s=e*8;this._aBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._aBuffers[s];return n||(this._aBuffers[s]=n=new xa(s*this.vertexSize*4)),n}getIndexBuffer(t){const e=nn(Math.ceil(t/12)),i=cu(e),s=e*12;this._iBuffers.length<=i&&(this._iBuffers.length=i+1);let n=this._iBuffers[i];return n||(this._iBuffers[i]=n=new Uint16Array(s)),n}packInterleavedGeometry(t,e,i,s,n){const{uint32View:o,float32View:a}=e,l=s/this.vertexSize,h=t.uvs,c=t.indices,u=t.vertexData,d=t._texture.baseTexture._batchLocation,f=Math.min(t.worldAlpha,1),p=vt.shared.setValue(t._tintRGB).toPremultiplied(f,t._texture.baseTexture.alphaMode>0);for(let m=0;m<u.length;m+=2)a[s++]=u[m],a[s++]=u[m+1],a[s++]=h[m],a[s++]=h[m+1],o[s++]=p,a[s++]=d;for(let m=0;m<c.length;m++)i[n++]=l+c[m]}};cs.defaultBatchSize=4096,cs.extension={name:"batch",type:X.RendererPlugin},cs._drawCallPool=[],cs._textureArrayPool=[];let Hr=cs;j.add(Hr);var Ov=`varying vec2 vTextureCoord;
|
|
346
346
|
|
|
347
347
|
uniform sampler2D uSampler;
|
|
348
348
|
|
|
@@ -375,7 +375,7 @@ void main(void)
|
|
|
375
375
|
gl_Position = filterVertexPosition();
|
|
376
376
|
vTextureCoord = filterTextureCoord();
|
|
377
377
|
}
|
|
378
|
-
`;const La=class _s extends He{constructor(t,e,i){const s=ar.from(t||_s.defaultVertexSrc,e||_s.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=_s.defaultResolution,this.multisample=_s.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new $e}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Fv}static get defaultFragmentSrc(){return Ov}};La.defaultResolution=1,La.defaultMultisample=Bt.NONE;let ee=La;class _n{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new vt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}_n.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},_n.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"background"},Y.add(_n);class Iu{constructor(t){this.renderer=t,this.emptyRenderer=new yn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=n[h],u=c._batchLocation;if(u>=0&&u<s&&e[u]===c){o[h]=u;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}Iu.extension={type:$.RendererSystem,name:"batch"},Y.add(Iu);let Pu=0;class vn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Pu++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Pu++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(W.PREFER_ENV>=Mr.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}vn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},vn.extension={type:$.RendererSystem,name:"context"},Y.add(vn);class Na{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new _e("disposeFramebuffer"),this.multisample=Bt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new et(null,{scaleMode:tr.NEAREST,resolution:1,mipmap:De.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new et(null,{scaleMode:tr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:De.OFF,format:U.DEPTH_COMPONENT,type:Z.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Ru extends et{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Bt.NONE),super(null,t),this.mipmap=De.OFF,this.valid=!0,this._clear=new vt([0,0,0,0]),this.framebuffer=new Na(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class lr extends as{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=sv(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===re.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Mu extends lr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;lr.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??W.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===re.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Ua{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=Ct.add(i,Ct.NW),this.x0=l+o*Ct.uX(i),this.y0=h+a*Ct.uY(i),i=Ct.add(i,2),this.x1=l+o*Ct.uX(i),this.y1=h+a*Ct.uY(i),i=Ct.add(i,2),this.x2=l+o*Ct.uX(i),this.y2=h+a*Ct.uY(i),i=Ct.add(i,2),this.x3=l+o*Ct.uX(i),this.y3=h+a*Ct.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Ua.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Bu=new Ua;function xn(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class q extends qi{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new it(0,0,1,1)),t instanceof q&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Bu,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new dt(o.x,o.y):new dt(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&Ge[e.url]&&q.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,q.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new q(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Bu&&(this._uvs=new Ua),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=W.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof et){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Lr()}`,et.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Lr()}`}n=t._pixiId}let o=Ge[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof et)?(e.resolution||(e.resolution=nr(t)),o=new q(new et(t,e)),o.baseTexture.cacheId=n,et.addToCache(o.baseTexture,n),q.addToCache(o,n)):!o&&t instanceof et&&(o=new q(t),q.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=q.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new q(et.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new et(t,Object.assign({scaleMode:et.defaultOptions.scaleMode,resolution:nr(e)},s)),{resource:o}=n;o instanceof Mu&&(o.url=e);const a=new q(n);return i||(i=e),et.addToCache(a.baseTexture,i),q.addToCache(a,i),i!==e&&(et.addToCache(a.baseTexture,e),q.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ge[e]&&Ge[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Ge[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ge[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ge[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Ge[t.textureCacheIds[e]]===t&&delete Ge[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return q._EMPTY||(q._EMPTY=new q(new et),xn(q._EMPTY),xn(q._EMPTY.baseTexture)),q._EMPTY}static get WHITE(){if(!q._WHITE){const t=W.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),q._WHITE=new q(et.from(t)),xn(q._WHITE),xn(q._WHITE.baseTexture)}return q._WHITE}}class Xr extends q{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Xr(new Ru(t))}}class Du{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Bt.NONE){const s=new Ru(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Xr(s)}getOptimalTexture(t,e,i=1,s=Bt.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=nn(t),e=nn(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Bt.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Du.SCREEN_KEY=-1;class Lv extends _r{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Ou extends _r{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Mt(this.vertices),this.uvBuffer=new Mt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Nv{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Bt.NONE,this.sourceFrame=new it,this.destinationFrame=new it,this.bindingSourceFrame=new it,this.bindingDestinationFrame=new it,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const bn=[new dt,new dt,new dt,new dt],ka=new wt;class Fu{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Du,this.statePool=[],this.quad=new Lv,this.quadUv=new Ou,this.tempRect=new it,this.activeState={},this.globalUniforms=new ve({outputFrame:new it,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new Nv,o=i.renderTexture;let a,l;if(o.current){const g=o.current;a=g.resolution,l=g.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let g=1;g<e.length;g++){const y=e[g];h=Math.min(h,y.resolution||a),c=Math.min(c,y.multisample??l),u=this.useMaxPadding?Math.max(u,y.padding):u+y.padding,d=d&&y.autoFit,f=f||(y.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(ka.copyFrom(i.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Oe.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,Oe.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,Oe.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Oe.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===Oe.CLEAR||e===Oe.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Be.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Be.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(wt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=Bt.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||Bt.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=bn[0],s=bn[1],n=bn[2],o=bn[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),c=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?ka.copyFrom(n):ka.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Fu.extension={type:$.RendererSystem,name:"filter"},Y.add(Fu);class Uv{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Bt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const kv=new it;class Lu{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Na(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new it,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;W.PREFER_ENV===Mr.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,s,n=Po.COLOR|Po.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new Uv(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Bt.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=Bt.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=s.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new Na(s.width,s.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=kv,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new it}destroy(){this.renderer=null}}Lu.extension={type:$.RendererSystem,name:"framebuffer"},Y.add(Lu);const Ga={5126:4,5123:2,5121:1};class Nu{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;W.PREFER_ENV===Mr.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*Ga[d[m].type];for(const m in d){const g=d[m],y=g.size;g.stride===void 0&&(f[g.buffer]===y*Ga[g.type]?g.stride=0:g.stride=f[g.buffer]),g.start===void 0&&(g.start=p[g.buffer],p[g.buffer]+=y*Ga[g.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let m=0;m<u.length;m++){const g=u[m];o.bind(g),i&&g._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,s.bindVertexArray(null),o.unbind(Fe.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(u),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Nu.extension={type:$.RendererSystem,name:"geometry"},Y.add(Nu);const Uu=new wt;class ku{constructor(t,e){this._texture=t,this.mapCoord=new wt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(Uu.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Uu));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var Gv=`varying vec2 vMaskCoord;
|
|
378
|
+
`;const La=class vs extends He{constructor(t,e,i){const s=ar.from(t||vs.defaultVertexSrc,e||vs.defaultFragmentSrc);super(s,i),this.padding=0,this.resolution=vs.defaultResolution,this.multisample=vs.defaultMultisample,this.enabled=!0,this.autoFit=!0,this.state=new $e}apply(t,e,i,s,n){t.applyFilter(this,e,i,s)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return Fv}static get defaultFragmentSrc(){return Ov}};La.defaultResolution=1,La.defaultMultisample=Bt.NONE;let ee=La;class _n{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new vt(0),this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender;const{backgroundColor:e,background:i,backgroundAlpha:s}=t,n=i??e;n!==void 0&&(this.color=n),this.alpha=s}get color(){return this._backgroundColor.value}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get backgroundColor(){return this._backgroundColor}destroy(){}}_n.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0},_n.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"background"},j.add(_n);class Cu{constructor(t){this.renderer=t,this.emptyRenderer=new yn(t),this.currentRenderer=this.emptyRenderer}setObjectRenderer(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())}flush(){this.setObjectRenderer(this.emptyRenderer)}reset(){this.setObjectRenderer(this.emptyRenderer)}copyBoundTextures(t,e){const{boundTextures:i}=this.renderer.texture;for(let s=e-1;s>=0;--s)t[s]=i[s]||null,t[s]&&(t[s]._batchLocation=s)}boundArray(t,e,i,s){const{elements:n,ids:o,count:a}=t;let l=0;for(let h=0;h<a;h++){const c=n[h],u=c._batchLocation;if(u>=0&&u<s&&e[u]===c){o[h]=u;continue}for(;l<s;){const d=e[l];if(d&&d._batchEnabled===i&&d._batchLocation===l){l++;continue}o[h]=l,c._batchLocation=l,e[l]=c;break}}}destroy(){this.renderer=null}}Cu.extension={type:X.RendererSystem,name:"batch"},j.add(Cu);let Pu=0;class vn{constructor(t){this.renderer=t,this.webGLVersion=1,this.extensions={},this.supports={uint32Indices:!1},this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this.renderer.gl=t,this.renderer.CONTEXT_UID=Pu++}init(t){if(t.context)this.initFromContext(t.context);else{const e=this.renderer.background.alpha<1,i=t.premultipliedAlpha;this.preserveDrawingBuffer=t.preserveDrawingBuffer,this.useContextAlpha=t.useContextAlpha,this.powerPreference=t.powerPreference,this.initFromOptions({alpha:e,premultipliedAlpha:i,antialias:t.antialias,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference})}}initFromContext(t){this.gl=t,this.validateContext(t),this.renderer.gl=t,this.renderer.CONTEXT_UID=Pu++,this.renderer.runners.contextChange.emit(t);const e=this.renderer.view;e.addEventListener!==void 0&&(e.addEventListener("webglcontextlost",this.handleContextLost,!1),e.addEventListener("webglcontextrestored",this.handleContextRestored,!1))}initFromOptions(t){const e=this.createContext(this.renderer.view,t);this.initFromContext(e)}createContext(t,e){let i;if(z.PREFER_ENV>=Mr.WEBGL2&&(i=t.getContext("webgl2",e)),i)this.webGLVersion=2;else if(this.webGLVersion=1,i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e),!i)throw new Error("This browser does not support WebGL. Try using the canvas renderer");return this.gl=i,this.getExtensions(),this.gl}getExtensions(){const{gl:t}=this,e={loseContext:t.getExtension("WEBGL_lose_context"),anisotropicFiltering:t.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),s3tc:t.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:t.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:t.getExtension("WEBGL_compressed_texture_etc"),etc1:t.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:t.getExtension("WEBGL_compressed_texture_atc"),astc:t.getExtension("WEBGL_compressed_texture_astc"),bptc:t.getExtension("EXT_texture_compression_bptc")};this.webGLVersion===1?Object.assign(this.extensions,e,{drawBuffers:t.getExtension("WEBGL_draw_buffers"),depthTexture:t.getExtension("WEBGL_depth_texture"),vertexArrayObject:t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:t.getExtension("OES_element_index_uint"),floatTexture:t.getExtension("OES_texture_float"),floatTextureLinear:t.getExtension("OES_texture_float_linear"),textureHalfFloat:t.getExtension("OES_texture_half_float"),textureHalfFloatLinear:t.getExtension("OES_texture_half_float_linear")}):this.webGLVersion===2&&Object.assign(this.extensions,e,{colorBufferFloat:t.getExtension("EXT_color_buffer_float")})}handleContextLost(t){t.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext&&this.extensions.loseContext.restoreContext()},0)}handleContextRestored(){this.renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this.renderer.view;this.renderer=null,t.removeEventListener!==void 0&&(t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored)),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()}postrender(){this.renderer.objectRenderer.renderingToScreen&&this.gl.flush()}validateContext(t){const e=t.getContextAttributes(),i="WebGL2RenderingContext"in globalThis&&t instanceof globalThis.WebGL2RenderingContext;i&&(this.webGLVersion=2),e&&!e.stencil&&console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=i||!!t.getExtension("OES_element_index_uint");this.supports.uint32Indices=s,s||console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly")}}vn.defaultOptions={context:null,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"},vn.extension={type:X.RendererSystem,name:"context"},j.add(vn);class Na{constructor(t,e){if(this.width=Math.round(t),this.height=Math.round(e),!this.width||!this.height)throw new Error("Framebuffer width or height is zero");this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new _e("disposeFramebuffer"),this.multisample=Bt.NONE}get colorTexture(){return this.colorTextures[0]}addColorTexture(t=0,e){return this.colorTextures[t]=e||new et(null,{scaleMode:tr.NEAREST,resolution:1,mipmap:De.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this}addDepthTexture(t){return this.depthTexture=t||new et(null,{scaleMode:tr.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:De.OFF,format:U.DEPTH_COMPONENT,type:K.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this}enableDepth(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this}enableStencil(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this}resize(t,e){if(t=Math.round(t),e=Math.round(e),!t||!e)throw new Error("Framebuffer width and height must not be zero");if(!(t===this.width&&e===this.height)){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(let i=0;i<this.colorTextures.length;i++){const s=this.colorTextures[i],n=s.resolution;s.setSize(t/n,e/n)}if(this.depthTexture){const i=this.depthTexture.resolution;this.depthTexture.setSize(t/i,e/i)}}}dispose(){this.disposeRunner.emit(this,!1)}destroyDepthTexture(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)}}class Ru extends et{constructor(t={}){if(typeof t=="number"){const e=arguments[0],i=arguments[1],s=arguments[2],n=arguments[3];t={width:e,height:i,scaleMode:s,resolution:n}}t.width=t.width??100,t.height=t.height??100,t.multisample??(t.multisample=Bt.NONE),super(null,t),this.mipmap=De.OFF,this.valid=!0,this._clear=new vt([0,0,0,0]),this.framebuffer=new Na(this.realWidth,this.realHeight).addColorTexture(0,this),this.framebuffer.multisample=t.multisample,this.maskStack=[],this.filterStack=[{}]}set clearColor(t){this._clear.setValue(t)}get clearColor(){return this._clear.value}get clear(){return this._clear}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e){this.framebuffer.resize(t*this.resolution,e*this.resolution),this.setRealSize(this.framebuffer.width,this.framebuffer.height)}dispose(){this.framebuffer.dispose(),super.dispose()}destroy(){super.destroy(),this.framebuffer.destroyDepthTexture(),this.framebuffer=null}}class lr extends ls{constructor(t){const e=t,i=e.naturalWidth||e.videoWidth||e.displayWidth||e.width,s=e.naturalHeight||e.videoHeight||e.displayHeight||e.height;super(i,s),this.source=t,this.noSubImage=!1}static crossOrigin(t,e,i){i===void 0&&!e.startsWith("data:")?t.crossOrigin=sv(e):i!==!1&&(t.crossOrigin=typeof i=="string"?i:"anonymous")}upload(t,e,i,s){const n=t.gl,o=e.realWidth,a=e.realHeight;if(s=s||this.source,typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement){if(!s.complete||s.naturalWidth===0)return!1}else if(typeof HTMLVideoElement<"u"&&s instanceof HTMLVideoElement&&s.readyState<=1)return!1;return n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===re.UNPACK),!this.noSubImage&&e.target===n.TEXTURE_2D&&i.width===o&&i.height===a?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.format,i.type,s):(i.width=o,i.height=a,n.texImage2D(e.target,0,i.internalFormat,e.format,i.type,s)),!0}update(){if(this.destroyed)return;const t=this.source,e=t.naturalWidth||t.videoWidth||t.width,i=t.naturalHeight||t.videoHeight||t.height;this.resize(e,i),super.update()}dispose(){this.source=null}}class Mu extends lr{constructor(t,e){if(e=e||{},typeof t=="string"){const i=new Image;lr.crossOrigin(i,t,e.crossorigin),i.src=t,t=i}super(t),!t.complete&&this._width&&this._height&&(this._width=0,this._height=0),this.url=t.src,this._process=null,this.preserveBitmap=!1,this.createBitmap=(e.createBitmap??z.CREATE_IMAGE_BITMAP)&&!!globalThis.createImageBitmap,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.bitmap=null,this._load=null,e.autoLoad!==!1&&this.load()}load(t){return this._load?this._load:(t!==void 0&&(this.createBitmap=t),this._load=new Promise((e,i)=>{const s=this.source;this.url=s.src;const n=()=>{this.destroyed||(s.onload=null,s.onerror=null,this.update(),this._load=null,this.createBitmap?e(this.process()):e(this))};s.complete&&s.src?n():(s.onload=n,s.onerror=o=>{i(o),this.onError.emit(o)})}),this._load)}process(){const t=this.source;if(this._process!==null)return this._process;if(this.bitmap!==null||!globalThis.createImageBitmap)return Promise.resolve(this);const e=globalThis.createImageBitmap,i=!t.crossOrigin||t.crossOrigin==="anonymous";return this._process=fetch(t.src,{mode:i?"cors":"no-cors"}).then(s=>s.blob()).then(s=>e(s,0,0,t.width,t.height,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===re.UNPACK?"premultiply":"none"})).then(s=>this.destroyed?Promise.reject():(this.bitmap=s,this.update(),this._process=null,Promise.resolve(this))),this._process}upload(t,e,i){if(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),!this.createBitmap)return super.upload(t,e,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(super.upload(t,e,i,this.bitmap),!this.preserveBitmap){let s=!0;const n=e._glTextures;for(const o in n){const a=n[o];if(a!==i&&a.dirtyId!==e.dirtyId){s=!1;break}}s&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0}dispose(){this.source.onload=null,this.source.onerror=null,super.dispose(),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null}static test(t){return typeof HTMLImageElement<"u"&&(typeof t=="string"||t instanceof HTMLImageElement)}}class Ua{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const s=e.width,n=e.height;if(i){const o=t.width/2/s,a=t.height/2/n,l=t.x/s+o,h=t.y/n+a;i=It.add(i,It.NW),this.x0=l+o*It.uX(i),this.y0=h+a*It.uY(i),i=It.add(i,2),this.x1=l+o*It.uX(i),this.y1=h+a*It.uY(i),i=It.add(i,2),this.x2=l+o*It.uX(i),this.y2=h+a*It.uY(i),i=It.add(i,2),this.x3=l+o*It.uX(i),this.y3=h+a*It.uY(i)}else this.x0=t.x/s,this.y0=t.y/n,this.x1=(t.x+t.width)/s,this.y1=t.y/n,this.x2=(t.x+t.width)/s,this.y2=(t.y+t.height)/n,this.x3=t.x/s,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}Ua.prototype.toString=function(){return`[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`};const Bu=new Ua;function xn(r){r.destroy=function(){},r.on=function(){},r.once=function(){},r.emit=function(){}}class Y extends Ki{constructor(t,e,i,s,n,o,a){if(super(),this.noFrame=!1,e||(this.noFrame=!0,e=new it(0,0,1,1)),t instanceof Y&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=s,this.valid=!1,this.destroyed=!1,this._uvs=Bu,this.uvMatrix=null,this.orig=i||e,this._rotate=Number(n||0),n===!0)this._rotate=2;else if(this._rotate%2!==0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");this.defaultAnchor=o?new dt(o.x,o.y):new dt(0,0),this.defaultBorders=a,this._updateID=0,this.textureCacheIds=[],t.valid?this.noFrame?t.valid&&this.onBaseTextureUpdated(t):this.frame=e:t.once("loaded",this.onBaseTextureUpdated,this),this.noFrame&&t.on("update",this.onBaseTextureUpdated,this)}update(){this.baseTexture.resource&&this.baseTexture.resource.update()}onBaseTextureUpdated(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)}destroy(t){if(this.baseTexture){if(t){const{resource:e}=this.baseTexture;e!=null&&e.url&&Ge[e.url]&&Y.removeFromCache(e.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,Y.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0,this.emit("destroyed",this),this.removeAllListeners()}clone(){var s;const t=this._frame.clone(),e=this._frame===this.orig?t:this.orig.clone(),i=new Y(this.baseTexture,!this.noFrame&&t,e,(s=this.trim)==null?void 0:s.clone(),this.rotate,this.defaultAnchor,this.defaultBorders);return this.noFrame&&(i._frame=t),i}updateUvs(){this._uvs===Bu&&(this._uvs=new Ua),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++}static from(t,e={},i=z.STRICT_TEXTURE_CACHE){const s=typeof t=="string";let n=null;if(s)n=t;else if(t instanceof et){if(!t.cacheId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t.cacheId=`${a}-${Lr()}`,et.addToCache(t,t.cacheId)}n=t.cacheId}else{if(!t._pixiId){const a=(e==null?void 0:e.pixiIdPrefix)||"pixiid";t._pixiId=`${a}_${Lr()}`}n=t._pixiId}let o=Ge[n];if(s&&i&&!o)throw new Error(`The cacheId "${n}" does not exist in TextureCache.`);return!o&&!(t instanceof et)?(e.resolution||(e.resolution=nr(t)),o=new Y(new et(t,e)),o.baseTexture.cacheId=n,et.addToCache(o.baseTexture,n),Y.addToCache(o,n)):!o&&t instanceof et&&(o=new Y(t),Y.addToCache(o,n)),o}static fromURL(t,e){const i=Object.assign({autoLoad:!1},e==null?void 0:e.resourceOptions),s=Y.from(t,Object.assign({resourceOptions:i},e),!1),n=s.baseTexture.resource;return s.baseTexture.valid?Promise.resolve(s):n.load().then(()=>Promise.resolve(s))}static fromBuffer(t,e,i,s){return new Y(et.fromBuffer(t,e,i,s))}static fromLoader(t,e,i,s){const n=new et(t,Object.assign({scaleMode:et.defaultOptions.scaleMode,resolution:nr(e)},s)),{resource:o}=n;o instanceof Mu&&(o.url=e);const a=new Y(n);return i||(i=e),et.addToCache(a.baseTexture,i),Y.addToCache(a,i),i!==e&&(et.addToCache(a.baseTexture,e),Y.addToCache(a,e)),a.baseTexture.valid?Promise.resolve(a):new Promise(l=>{a.baseTexture.once("loaded",()=>l(a))})}static addToCache(t,e){e&&(t.textureCacheIds.includes(e)||t.textureCacheIds.push(e),Ge[e]&&Ge[e]!==t&&console.warn(`Texture added to the cache with an id [${e}] that already had an entry`),Ge[e]=t)}static removeFromCache(t){if(typeof t=="string"){const e=Ge[t];if(e){const i=e.textureCacheIds.indexOf(t);return i>-1&&e.textureCacheIds.splice(i,1),delete Ge[t],e}}else if(t!=null&&t.textureCacheIds){for(let e=0;e<t.textureCacheIds.length;++e)Ge[t.textureCacheIds[e]]===t&&delete Ge[t.textureCacheIds[e]];return t.textureCacheIds.length=0,t}return null}get resolution(){return this.baseTexture.resolution}get frame(){return this._frame}set frame(t){this._frame=t,this.noFrame=!1;const{x:e,y:i,width:s,height:n}=t,o=e+s>this.baseTexture.width,a=i+n>this.baseTexture.height;if(o||a){const l=o&&a?"and":"or",h=`X: ${e} + ${s} = ${e+s} > ${this.baseTexture.width}`,c=`Y: ${i} + ${n} = ${i+n} > ${this.baseTexture.height}`;throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`)}this.valid=s&&n&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=t),this.valid&&this.updateUvs()}get rotate(){return this._rotate}set rotate(t){this._rotate=t,this.valid&&this.updateUvs()}get width(){return this.orig.width}get height(){return this.orig.height}castToBaseTexture(){return this.baseTexture}static get EMPTY(){return Y._EMPTY||(Y._EMPTY=new Y(new et),xn(Y._EMPTY),xn(Y._EMPTY.baseTexture)),Y._EMPTY}static get WHITE(){if(!Y._WHITE){const t=z.ADAPTER.createCanvas(16,16),e=t.getContext("2d");t.width=16,t.height=16,e.fillStyle="white",e.fillRect(0,0,16,16),Y._WHITE=new Y(et.from(t)),xn(Y._WHITE),xn(Y._WHITE.baseTexture)}return Y._WHITE}}class Xr extends Y{constructor(t,e){super(t,e),this.valid=!0,this.filterFrame=null,this.filterPoolKey=null,this.updateUvs()}get framebuffer(){return this.baseTexture.framebuffer}get multisample(){return this.framebuffer.multisample}set multisample(t){this.framebuffer.multisample=t}resize(t,e,i=!0){const s=this.baseTexture.resolution,n=Math.round(t*s)/s,o=Math.round(e*s)/s;this.valid=n>0&&o>0,this._frame.width=this.orig.width=n,this._frame.height=this.orig.height=o,i&&this.baseTexture.resize(n,o),this.updateUvs()}setResolution(t){const{baseTexture:e}=this;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))}static create(t){return new Xr(new Ru(t))}}class Du{constructor(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}createTexture(t,e,i=Bt.NONE){const s=new Ru(Object.assign({width:t,height:e,resolution:1,multisample:i},this.textureOptions));return new Xr(s)}getOptimalTexture(t,e,i=1,s=Bt.NONE){let n;t=Math.max(Math.ceil(t*i-1e-6),1),e=Math.max(Math.ceil(e*i-1e-6),1),!this.enableFullScreen||t!==this._pixelsWidth||e!==this._pixelsHeight?(t=nn(t),e=nn(e),n=((t&65535)<<16|e&65535)>>>0,s>1&&(n+=s*4294967296)):n=s>1?-s:-1,this.texturePool[n]||(this.texturePool[n]=[]);let o=this.texturePool[n].pop();return o||(o=this.createTexture(t,e,s)),o.filterPoolKey=n,o.setResolution(i),o}getFilterTexture(t,e,i){const s=this.getOptimalTexture(t.width,t.height,e||t.resolution,i||Bt.NONE);return s.filterFrame=t.filterFrame,s}returnTexture(t){const e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)}returnFilterTexture(t){this.returnTexture(t)}clear(t){if(t=t!==!1,t)for(const e in this.texturePool){const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0)}this.texturePool={}}setScreenSize(t){if(!(t.width===this._pixelsWidth&&t.height===this._pixelsHeight)){this.enableFullScreen=t.width>0&&t.height>0;for(const e in this.texturePool){if(!(Number(e)<0))continue;const i=this.texturePool[e];if(i)for(let s=0;s<i.length;s++)i[s].destroy(!0);this.texturePool[e]=[]}this._pixelsWidth=t.width,this._pixelsHeight=t.height}}}Du.SCREEN_KEY=-1;class Lv extends _r{constructor(){super(),this.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2])}}class Ou extends _r{constructor(){super(),this.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.vertexBuffer=new Mt(this.vertices),this.uvBuffer=new Mt(this.uvs),this.addAttribute("aVertexPosition",this.vertexBuffer).addAttribute("aTextureCoord",this.uvBuffer).addIndex([0,1,2,0,2,3])}map(t,e){let i=0,s=0;return this.uvs[0]=i,this.uvs[1]=s,this.uvs[2]=i+e.width/t.width,this.uvs[3]=s,this.uvs[4]=i+e.width/t.width,this.uvs[5]=s+e.height/t.height,this.uvs[6]=i,this.uvs[7]=s+e.height/t.height,i=e.x,s=e.y,this.vertices[0]=i,this.vertices[1]=s,this.vertices[2]=i+e.width,this.vertices[3]=s,this.vertices[4]=i+e.width,this.vertices[5]=s+e.height,this.vertices[6]=i,this.vertices[7]=s+e.height,this.invalidate(),this}invalidate(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this}}class Nv{constructor(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.multisample=Bt.NONE,this.sourceFrame=new it,this.destinationFrame=new it,this.bindingSourceFrame=new it,this.bindingDestinationFrame=new it,this.filters=[],this.transform=null}clear(){this.target=null,this.filters=null,this.renderTexture=null}}const bn=[new dt,new dt,new dt,new dt],ka=new wt;class Fu{constructor(t){this.renderer=t,this.defaultFilterStack=[{}],this.texturePool=new Du,this.statePool=[],this.quad=new Lv,this.quadUv=new Ou,this.tempRect=new it,this.activeState={},this.globalUniforms=new ve({outputFrame:new it,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),this.forceClear=!1,this.useMaxPadding=!1}init(){this.texturePool.setScreenSize(this.renderer.view)}push(t,e){const i=this.renderer,s=this.defaultFilterStack,n=this.statePool.pop()||new Nv,o=i.renderTexture;let a,l;if(o.current){const g=o.current;a=g.resolution,l=g.multisample}else a=i.resolution,l=i.multisample;let h=e[0].resolution||a,c=e[0].multisample??l,u=e[0].padding,d=e[0].autoFit,f=e[0].legacy??!0;for(let g=1;g<e.length;g++){const y=e[g];h=Math.min(h,y.resolution||a),c=Math.min(c,y.multisample??l),u=this.useMaxPadding?Math.max(u,y.padding):u+y.padding,d=d&&y.autoFit,f=f||(y.legacy??!0)}s.length===1&&(this.defaultFilterStack[0].renderTexture=o.current),s.push(n),n.resolution=h,n.multisample=c,n.legacy=f,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(u);const p=this.tempRect.copyFrom(o.sourceFrame);i.projection.transform&&this.transformAABB(ka.copyFrom(i.projection.transform).invert(),p),d?(n.sourceFrame.fit(p),(n.sourceFrame.width<=0||n.sourceFrame.height<=0)&&(n.sourceFrame.width=0,n.sourceFrame.height=0)):n.sourceFrame.intersects(p)||(n.sourceFrame.width=0,n.sourceFrame.height=0),this.roundFrame(n.sourceFrame,o.current?o.current.resolution:i.resolution,o.sourceFrame,o.destinationFrame,i.projection.transform),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,h,c),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;const m=this.tempRect;m.x=0,m.y=0,m.width=n.sourceFrame.width,m.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,n.bindingSourceFrame.copyFrom(o.sourceFrame),n.bindingDestinationFrame.copyFrom(o.destinationFrame),n.transform=i.projection.transform,i.projection.transform=null,o.bind(n.renderTexture,n.sourceFrame,m),i.framebuffer.clear(0,0,0,0)}pop(){const t=this.defaultFilterStack,e=t.pop(),i=e.filters;this.activeState=e;const s=this.globalUniforms.uniforms;s.outputFrame=e.sourceFrame,s.resolution=e.resolution;const n=s.inputSize,o=s.inputPixel,a=s.inputClamp;if(n[0]=e.destinationFrame.width,n[1]=e.destinationFrame.height,n[2]=1/n[0],n[3]=1/n[1],o[0]=Math.round(n[0]*e.resolution),o[1]=Math.round(n[1]*e.resolution),o[2]=1/o[0],o[3]=1/o[1],a[0]=.5*o[2],a[1]=.5*o[3],a[2]=e.sourceFrame.width*n[2]-.5*o[2],a[3]=e.sourceFrame.height*n[3]-.5*o[3],e.legacy){const h=s.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,s.filterClamp=s.inputClamp}this.globalUniforms.update();const l=t[t.length-1];if(this.renderer.framebuffer.blit(),i.length===1)i[0].apply(this,e.renderTexture,l.renderTexture,Oe.BLEND,e),this.returnFilterTexture(e.renderTexture);else{let h=e.renderTexture,c=this.getOptimalFilterTexture(h.width,h.height,e.resolution);c.filterFrame=h.filterFrame;let u=0;for(u=0;u<i.length-1;++u){u===1&&e.multisample>1&&(c=this.getOptimalFilterTexture(h.width,h.height,e.resolution),c.filterFrame=h.filterFrame),i[u].apply(this,h,c,Oe.CLEAR,e);const d=h;h=c,c=d}i[u].apply(this,h,l.renderTexture,Oe.BLEND,e),u>1&&e.multisample>1&&this.returnFilterTexture(e.renderTexture),this.returnFilterTexture(h),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)}bindAndClear(t,e=Oe.CLEAR){const{renderTexture:i,state:s}=this.renderer;if(t===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,t==null?void 0:t.filterFrame){const o=this.tempRect;o.x=0,o.y=0,o.width=t.filterFrame.width,o.height=t.filterFrame.height,i.bind(t,t.filterFrame,o)}else t!==this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?i.bind(t):this.renderer.renderTexture.bind(t,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame);const n=s.stateId&1||this.forceClear;(e===Oe.CLEAR||e===Oe.BLIT&&n)&&this.renderer.framebuffer.clear(0,0,0,0)}applyFilter(t,e,i,s){const n=this.renderer;n.state.set(t.state),this.bindAndClear(i,s),t.uniforms.uSampler=e,t.uniforms.filterGlobals=this.globalUniforms,n.shader.bind(t),t.legacy=!!t.program.attributeData.aTextureCoord,t.legacy?(this.quadUv.map(e._frame,e.filterFrame),n.geometry.bind(this.quadUv),n.geometry.draw(Be.TRIANGLES)):(n.geometry.bind(this.quad),n.geometry.draw(Be.TRIANGLE_STRIP))}calculateSpriteMatrix(t,e){const{sourceFrame:i,destinationFrame:s}=this.activeState,{orig:n}=e._texture,o=t.set(s.width,0,0,s.height,i.x,i.y),a=e.worldTransform.copyTo(wt.TEMP_MATRIX);return a.invert(),o.prepend(a),o.scale(1/n.width,1/n.height),o.translate(e.anchor.x,e.anchor.y),o}destroy(){this.renderer=null,this.texturePool.clear(!1)}getOptimalFilterTexture(t,e,i=1,s=Bt.NONE){return this.texturePool.getOptimalTexture(t,e,i,s)}getFilterTexture(t,e,i){if(typeof t=="number"){const n=t;t=e,e=n}t=t||this.activeState.renderTexture;const s=this.texturePool.getOptimalTexture(t.width,t.height,e||t.resolution,i||Bt.NONE);return s.filterFrame=t.filterFrame,s}returnFilterTexture(t){this.texturePool.returnTexture(t)}emptyPool(){this.texturePool.clear(!0)}resize(){this.texturePool.setScreenSize(this.renderer.view)}transformAABB(t,e){const i=bn[0],s=bn[1],n=bn[2],o=bn[3];i.set(e.left,e.top),s.set(e.left,e.bottom),n.set(e.right,e.top),o.set(e.right,e.bottom),t.apply(i,i),t.apply(s,s),t.apply(n,n),t.apply(o,o);const a=Math.min(i.x,s.x,n.x,o.x),l=Math.min(i.y,s.y,n.y,o.y),h=Math.max(i.x,s.x,n.x,o.x),c=Math.max(i.y,s.y,n.y,o.y);e.x=a,e.y=l,e.width=h-a,e.height=c-l}roundFrame(t,e,i,s,n){if(!(t.width<=0||t.height<=0||i.width<=0||i.height<=0)){if(n){const{a:o,b:a,c:l,d:h}=n;if((Math.abs(a)>1e-4||Math.abs(l)>1e-4)&&(Math.abs(o)>1e-4||Math.abs(h)>1e-4))return}n=n?ka.copyFrom(n):ka.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.transformAABB(n,t),t.ceil(e),this.transformAABB(n.invert(),t)}}}Fu.extension={type:X.RendererSystem,name:"filter"},j.add(Fu);class Uv{constructor(t){this.framebuffer=t,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Bt.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}}const kv=new it;class Lu{constructor(t){this.renderer=t,this.managedFramebuffers=[],this.unknownFramebuffer=new Na(10,10),this.msaaSamples=null}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new it,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){let e=this.renderer.context.extensions.drawBuffers,i=this.renderer.context.extensions.depthTexture;z.PREFER_ENV===Mr.WEBGL_LEGACY&&(e=null,i=null),e?t.drawBuffers=s=>e.drawBuffersWEBGL(s):(this.hasMRT=!1,t.drawBuffers=()=>{}),i||(this.writeDepthTexture=!1)}else this.msaaSamples=t.getInternalformatParameter(t.RENDERBUFFER,t.RGBA8,t.SAMPLES)}bind(t,e,i=0){const{gl:s}=this;if(t){const n=t.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(t);this.current!==t&&(this.current=t,s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer)),n.mipLevel!==i&&(t.dirtyId++,t.dirtyFormat++,n.mipLevel=i),n.dirtyId!==t.dirtyId&&(n.dirtyId=t.dirtyId,n.dirtyFormat!==t.dirtyFormat?(n.dirtyFormat=t.dirtyFormat,n.dirtySize=t.dirtySize,this.updateFramebuffer(t,i)):n.dirtySize!==t.dirtySize&&(n.dirtySize=t.dirtySize,this.resizeFramebuffer(t)));for(let o=0;o<t.colorTextures.length;o++){const a=t.colorTextures[o];this.renderer.texture.unbind(a.parentTextureArray||a)}if(t.depthTexture&&this.renderer.texture.unbind(t.depthTexture),e){const o=e.width>>i,a=e.height>>i,l=o/e.width;this.setViewport(e.x*l,e.y*l,o,a)}else{const o=t.width>>i,a=t.height>>i;this.setViewport(0,0,o,a)}}else this.current&&(this.current=null,s.bindFramebuffer(s.FRAMEBUFFER,null)),e?this.setViewport(e.x,e.y,e.width,e.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)}setViewport(t,e,i,s){const n=this.viewport;t=Math.round(t),e=Math.round(e),i=Math.round(i),s=Math.round(s),(n.width!==i||n.height!==s||n.x!==t||n.y!==e)&&(n.x=t,n.y=e,n.width=i,n.height=s,this.gl.viewport(t,e,i,s))}get size(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}clear(t,e,i,s,n=Po.COLOR|Po.DEPTH){const{gl:o}=this;o.clearColor(t,e,i,s),o.clear(n)}initFramebuffer(t){const{gl:e}=this,i=new Uv(e.createFramebuffer());return i.multisample=this.detectSamples(t.multisample),t.glFramebuffers[this.CONTEXT_UID]=i,this.managedFramebuffers.push(t),t.disposeRunner.add(this),i}resizeFramebuffer(t){const{gl:e}=this,i=t.glFramebuffers[this.CONTEXT_UID];if(i.stencil){e.bindRenderbuffer(e.RENDERBUFFER,i.stencil);let o;this.renderer.context.webGLVersion===1?o=e.DEPTH_STENCIL:t.depth&&t.stencil?o=e.DEPTH24_STENCIL8:t.depth?o=e.DEPTH_COMPONENT24:o=e.STENCIL_INDEX8,i.msaaBuffer?e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height)}const s=t.colorTextures;let n=s.length;e.drawBuffers||(n=Math.min(n,1));for(let o=0;o<n;o++){const a=s[o],l=a.parentTextureArray||a;this.renderer.texture.bind(l,0),o===0&&i.msaaBuffer&&(e.bindRenderbuffer(e.RENDERBUFFER,i.msaaBuffer),e.renderbufferStorageMultisample(e.RENDERBUFFER,i.multisample,l._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height))}t.depthTexture&&this.writeDepthTexture&&this.renderer.texture.bind(t.depthTexture,0)}updateFramebuffer(t,e){const{gl:i}=this,s=t.glFramebuffers[this.CONTEXT_UID],n=t.colorTextures;let o=n.length;i.drawBuffers||(o=Math.min(o,1)),s.multisample>1&&this.canMultisampleFramebuffer(t)?s.msaaBuffer=s.msaaBuffer||i.createRenderbuffer():s.msaaBuffer&&(i.deleteRenderbuffer(s.msaaBuffer),s.msaaBuffer=null,s.blitFramebuffer&&(s.blitFramebuffer.dispose(),s.blitFramebuffer=null));const a=[];for(let l=0;l<o;l++){const h=n[l],c=h.parentTextureArray||h;this.renderer.texture.bind(c,0),l===0&&s.msaaBuffer?(i.bindRenderbuffer(i.RENDERBUFFER,s.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,c._glTextures[this.CONTEXT_UID].internalFormat,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,s.msaaBuffer)):(i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+l,h.target,c._glTextures[this.CONTEXT_UID].texture,e),a.push(i.COLOR_ATTACHMENT0+l))}if(a.length>1&&i.drawBuffers(a),t.depthTexture&&this.writeDepthTexture){const l=t.depthTexture;this.renderer.texture.bind(l,0),i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,l._glTextures[this.CONTEXT_UID].texture,e)}if((t.stencil||t.depth)&&!(t.depthTexture&&this.writeDepthTexture)){s.stencil=s.stencil||i.createRenderbuffer();let l,h;this.renderer.context.webGLVersion===1?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH_STENCIL):t.depth&&t.stencil?(l=i.DEPTH_STENCIL_ATTACHMENT,h=i.DEPTH24_STENCIL8):t.depth?(l=i.DEPTH_ATTACHMENT,h=i.DEPTH_COMPONENT24):(l=i.STENCIL_ATTACHMENT,h=i.STENCIL_INDEX8),i.bindRenderbuffer(i.RENDERBUFFER,s.stencil),s.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,s.multisample,h,t.width,t.height):i.renderbufferStorage(i.RENDERBUFFER,h,t.width,t.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,s.stencil)}else s.stencil&&(i.deleteRenderbuffer(s.stencil),s.stencil=null)}canMultisampleFramebuffer(t){return this.renderer.context.webGLVersion!==1&&t.colorTextures.length<=1&&!t.depthTexture}detectSamples(t){const{msaaSamples:e}=this;let i=Bt.NONE;if(t<=1||e===null)return i;for(let s=0;s<e.length;s++)if(e[s]<=t){i=e[s];break}return i===1&&(i=Bt.NONE),i}blit(t,e,i){const{current:s,renderer:n,gl:o,CONTEXT_UID:a}=this;if(n.context.webGLVersion!==2||!s)return;const l=s.glFramebuffers[a];if(!l)return;if(!t){if(!l.msaaBuffer)return;const c=s.colorTextures[0];if(!c)return;l.blitFramebuffer||(l.blitFramebuffer=new Na(s.width,s.height),l.blitFramebuffer.addColorTexture(0,c)),t=l.blitFramebuffer,t.colorTextures[0]!==c&&(t.colorTextures[0]=c,t.dirtyId++,t.dirtyFormat++),(t.width!==s.width||t.height!==s.height)&&(t.width=s.width,t.height=s.height,t.dirtyId++,t.dirtySize++)}e||(e=kv,e.width=s.width,e.height=s.height),i||(i=e);const h=e.width===i.width&&e.height===i.height;this.bind(t),o.bindFramebuffer(o.READ_FRAMEBUFFER,l.framebuffer),o.blitFramebuffer(e.left,e.top,e.right,e.bottom,i.left,i.top,i.right,i.bottom,o.COLOR_BUFFER_BIT,h?o.NEAREST:o.LINEAR),o.bindFramebuffer(o.READ_FRAMEBUFFER,t.glFramebuffers[this.CONTEXT_UID].framebuffer)}disposeFramebuffer(t,e){const i=t.glFramebuffers[this.CONTEXT_UID],s=this.gl;if(!i)return;delete t.glFramebuffers[this.CONTEXT_UID];const n=this.managedFramebuffers.indexOf(t);n>=0&&this.managedFramebuffers.splice(n,1),t.disposeRunner.remove(this),e||(s.deleteFramebuffer(i.framebuffer),i.msaaBuffer&&s.deleteRenderbuffer(i.msaaBuffer),i.stencil&&s.deleteRenderbuffer(i.stencil)),i.blitFramebuffer&&this.disposeFramebuffer(i.blitFramebuffer,e)}disposeAll(t){const e=this.managedFramebuffers;this.managedFramebuffers=[];for(let i=0;i<e.length;i++)this.disposeFramebuffer(e[i],t)}forceStencil(){const t=this.current;if(!t)return;const e=t.glFramebuffers[this.CONTEXT_UID];if(!e||e.stencil&&t.stencil)return;t.stencil=!0;const i=t.width,s=t.height,n=this.gl,o=e.stencil=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,o);let a,l;this.renderer.context.webGLVersion===1?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH_STENCIL):t.depth?(a=n.DEPTH_STENCIL_ATTACHMENT,l=n.DEPTH24_STENCIL8):(a=n.STENCIL_ATTACHMENT,l=n.STENCIL_INDEX8),e.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,e.multisample,l,i,s):n.renderbufferStorage(n.RENDERBUFFER,l,i,s),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,o)}reset(){this.current=this.unknownFramebuffer,this.viewport=new it}destroy(){this.renderer=null}}Lu.extension={type:X.RendererSystem,name:"framebuffer"},j.add(Lu);const Ga={5126:4,5123:2,5121:1};class Nu{constructor(t){this.renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this.canUseUInt32ElementIndex=!1,this.managedGeometries={}}contextChange(){this.disposeAll(!0);const t=this.gl=this.renderer.gl,e=this.renderer.context;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,e.webGLVersion!==2){let i=this.renderer.context.extensions.vertexArrayObject;z.PREFER_ENV===Mr.WEBGL_LEGACY&&(i=null),i?(t.createVertexArray=()=>i.createVertexArrayOES(),t.bindVertexArray=s=>i.bindVertexArrayOES(s),t.deleteVertexArray=s=>i.deleteVertexArrayOES(s)):(this.hasVao=!1,t.createVertexArray=()=>null,t.bindVertexArray=()=>null,t.deleteVertexArray=()=>null)}if(e.webGLVersion!==2){const i=t.getExtension("ANGLE_instanced_arrays");i?(t.vertexAttribDivisor=(s,n)=>i.vertexAttribDivisorANGLE(s,n),t.drawElementsInstanced=(s,n,o,a,l)=>i.drawElementsInstancedANGLE(s,n,o,a,l),t.drawArraysInstanced=(s,n,o,a)=>i.drawArraysInstancedANGLE(s,n,o,a)):this.hasInstance=!1}this.canUseUInt32ElementIndex=e.webGLVersion===2||!!e.extensions.uint32ElementIndex}bind(t,e){e=e||this.renderer.shader.shader;const{gl:i}=this;let s=t.glVertexArrayObjects[this.CONTEXT_UID],n=!1;s||(this.managedGeometries[t.id]=t,t.disposeRunner.add(this),t.glVertexArrayObjects[this.CONTEXT_UID]=s={},n=!0);const o=s[e.program.id]||this.initGeometryVao(t,e,n);this._activeGeometry=t,this._activeVao!==o&&(this._activeVao=o,this.hasVao?i.bindVertexArray(o):this.activateVao(t,e.program)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this.renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.update(s)}}checkCompatibility(t,e){const i=t.attributes,s=e.attributeData;for(const n in s)if(!i[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(t,e){const i=t.attributes,s=e.attributeData,n=["g",t.id];for(const o in i)s[o]&&n.push(o,s[o].location);return n.join("-")}initGeometryVao(t,e,i=!0){const s=this.gl,n=this.CONTEXT_UID,o=this.renderer.buffer,a=e.program;a.glPrograms[n]||this.renderer.shader.generateProgram(e),this.checkCompatibility(t,a);const l=this.getSignature(t,a),h=t.glVertexArrayObjects[this.CONTEXT_UID];let c=h[l];if(c)return h[a.id]=c,c;const u=t.buffers,d=t.attributes,f={},p={};for(const m in u)f[m]=0,p[m]=0;for(const m in d)!d[m].size&&a.attributeData[m]?d[m].size=a.attributeData[m].size:d[m].size||console.warn(`PIXI Geometry attribute '${m}' size cannot be determined (likely the bound shader does not have the attribute)`),f[d[m].buffer]+=d[m].size*Ga[d[m].type];for(const m in d){const g=d[m],y=g.size;g.stride===void 0&&(f[g.buffer]===y*Ga[g.type]?g.stride=0:g.stride=f[g.buffer]),g.start===void 0&&(g.start=p[g.buffer],p[g.buffer]+=y*Ga[g.type])}c=s.createVertexArray(),s.bindVertexArray(c);for(let m=0;m<u.length;m++){const g=u[m];o.bind(g),i&&g._glBuffers[n].refCount++}return this.activateVao(t,a),h[a.id]=c,h[l]=c,s.bindVertexArray(null),o.unbind(Fe.ARRAY_BUFFER),c}disposeGeometry(t,e){var a;if(!this.managedGeometries[t.id])return;delete this.managedGeometries[t.id];const i=t.glVertexArrayObjects[this.CONTEXT_UID],s=this.gl,n=t.buffers,o=(a=this.renderer)==null?void 0:a.buffer;if(t.disposeRunner.remove(this),!!i){if(o)for(let l=0;l<n.length;l++){const h=n[l]._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(n[l],e))}if(!e){for(const l in i)if(l[0]==="g"){const h=i[l];this._activeVao===h&&this.unbind(),s.deleteVertexArray(h)}}delete t.glVertexArrayObjects[this.CONTEXT_UID]}}disposeAll(t){const e=Object.keys(this.managedGeometries);for(let i=0;i<e.length;i++)this.disposeGeometry(this.managedGeometries[e[i]],t)}activateVao(t,e){const i=this.gl,s=this.CONTEXT_UID,n=this.renderer.buffer,o=t.buffers,a=t.attributes;t.indexBuffer&&n.bind(t.indexBuffer);let l=null;for(const h in a){const c=a[h],u=o[c.buffer],d=u._glBuffers[s];if(e.attributeData[h]){l!==d&&(n.bind(u),l=d);const f=e.attributeData[h].location;if(i.enableVertexAttribArray(f),i.vertexAttribPointer(f,c.size,c.type||i.FLOAT,c.normalized,c.stride,c.start),c.instance)if(this.hasInstance)i.vertexAttribDivisor(f,c.divisor);else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(t,e,i,s){const{gl:n}=this,o=this._activeGeometry;if(o.indexBuffer){const a=o.indexBuffer.data.BYTES_PER_ELEMENT,l=a===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT;a===2||a===4&&this.canUseUInt32ElementIndex?o.instanced?n.drawElementsInstanced(t,e||o.indexBuffer.data.length,l,(i||0)*a,s||1):n.drawElements(t,e||o.indexBuffer.data.length,l,(i||0)*a):console.warn("unsupported index buffer type: uint32")}else o.instanced?n.drawArraysInstanced(t,i,e||o.getSize(),s||1):n.drawArrays(t,i,e||o.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this.renderer=null}}Nu.extension={type:X.RendererSystem,name:"geometry"},j.add(Nu);const Uu=new wt;class ku{constructor(t,e){this._texture=t,this.mapCoord=new wt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e>"u"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],o=t[s+1];e[s]=n*i.a+o*i.c+i.tx,e[s+1]=n*i.b+o*i.d+i.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const i=e._uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const s=e.orig,n=e.trim;n&&(Uu.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Uu));const o=e.baseTexture,a=this.uClampFrame,l=this.clampMargin/o.resolution,h=this.clampOffset;return a[0]=(e._frame.x+l+h)/o.width,a[1]=(e._frame.y+l+h)/o.height,a[2]=(e._frame.x+e._frame.width-l+h)/o.width,a[3]=(e._frame.y+e._frame.height-l+h)/o.height,this.uClampOffset[0]=h/o.realWidth,this.uClampOffset[1]=h/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}var Gv=`varying vec2 vMaskCoord;
|
|
379
379
|
varying vec2 vTextureCoord;
|
|
380
380
|
|
|
381
381
|
uniform sampler2D uSampler;
|
|
@@ -416,7 +416,7 @@ void main(void)
|
|
|
416
416
|
vTextureCoord = aTextureCoord;
|
|
417
417
|
vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
|
|
418
418
|
}
|
|
419
|
-
`;class Hv extends ee{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||$v,e||Gv,i),this.maskSprite=s,this.maskMatrix=new wt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new ku(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class Xv{constructor(t=null){this.type=Ft.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=ee.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Ft.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Gu{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new Xv;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Ft.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Ft.SCISSOR:this.renderer.scissor.push(i);break;case Ft.STENCIL:this.renderer.stencil.push(i);break;case Ft.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Ft.COLOR:this.pushColorMask(i);break}i.type===Ft.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Ft.SCISSOR:this.renderer.scissor.pop(e);break;case Ft.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Ft.SPRITE:this.popSpriteMask(e);break;case Ft.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Ft.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Ft.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Ft.SCISSOR:t.type=Ft.STENCIL:t.type=Ft.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new Hv])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Gu.extension={type:$.RendererSystem,name:"mask"},Y.add(Gu);class $u{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Hu=new wt,Xu=[],Vu=class Jn extends $u{constructor(t){super(t),this.glConst=W.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,Xu.pop()??new it);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Jn.isMatrixRotated(e.worldTransform)||Jn.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Jn.isMatrixRotated(n)||(n=n?Hu.copyFrom(n):Hu.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&Xu.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};Vu.extension={type:$.RendererSystem,name:"scissor"};let Vv=Vu;Y.add(Vv);class zu extends $u{constructor(t){super(t),this.glConst=W.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}zu.extension={type:$.RendererSystem,name:"stencil"},Y.add(zu);class Wu{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return at("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return at("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return at("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Wu.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_plugin"},Y.add(Wu);class ju{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new wt,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}ju.extension={type:$.RendererSystem,name:"projection"},Y.add(ju);const zv=new Ba,Yu=new it;class qu{constructor(t){this.renderer=t,this._tempMatrix=new wt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(Yu))||t.getLocalBounds(Yu,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=Xr.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=zv,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}qu.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"textureGenerator"},Y.add(qu);const Vr=new it,cs=new it;class Ku{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new it,this.destinationFrame=new it,this.viewportFrame=new it}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(Vr.width=t.frame.width,Vr.height=t.frame.height,e=Vr),i||(cs.x=t.frame.x,cs.y=t.frame.y,cs.width=e.width,cs.height=e.height,i=cs),o=n.framebuffer):(a=s.resolution,e||(Vr.width=s._view.screen.width,Vr.height=s._view.screen.height,e=Vr),i||(i=Vr,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=vt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:c,height:u}=this.viewportFrame;l=Math.round(l),h=Math.round(h),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,c,u)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Ku.extension={type:$.RendererSystem,name:"renderTexture"},Y.add(Ku);class Wv{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function jv(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=Su(t,n.type),a={type:o,name:n.name,size:Tu(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function Yv(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Su(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:bu(l,n.size)}}return e}function qv(r,t){var a;const e=xu(r,r.VERTEX_SHADER,t.vertexSrc),i=xu(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Tv(r,s,e,i),t.attributeData=jv(s,r),t.uniformData=Yv(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,c)=>h>c?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(s,l),value:bu(h.type,h.size)}}return new Wv(s,o)}function Kv(r,t,e,i,s){e.buffer.update(s)}const Zv={float:`
|
|
419
|
+
`;class Hv extends ee{constructor(t,e,i){let s=null;typeof t!="string"&&e===void 0&&i===void 0&&(s=t,t=void 0,e=void 0,i=void 0),super(t||$v,e||Gv,i),this.maskSprite=s,this.maskMatrix=new wt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,i,s){const n=this._maskSprite,o=n._texture;o.valid&&(o.uvMatrix||(o.uvMatrix=new ku(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,i,s))}}class Xv{constructor(t=null){this.type=Ft.NONE,this.autoDetect=!0,this.maskObject=t||null,this.pooled=!1,this.isMaskData=!0,this.resolution=null,this.multisample=ee.defaultMultisample,this.enabled=!0,this.colorMask=15,this._filters=null,this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null,this._scissorRectLocal=null,this._colorMask=15,this._target=null}get filter(){return this._filters?this._filters[0]:null}set filter(t){t?this._filters?this._filters[0]=t:this._filters=[t]:this._filters=null}reset(){this.pooled&&(this.maskObject=null,this.type=Ft.NONE,this.autoDetect=!0),this._target=null,this._scissorRectLocal=null}copyCountersOrReset(t){t?(this._stencilCounter=t._stencilCounter,this._scissorCounter=t._scissorCounter,this._scissorRect=t._scissorRect):(this._stencilCounter=0,this._scissorCounter=0,this._scissorRect=null)}}class Gu{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let i=e;if(!i.isMaskData){const n=this.maskDataPool.pop()||new Xv;n.pooled=!0,n.maskObject=e,i=n}const s=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(i.copyCountersOrReset(s),i._colorMask=s?s._colorMask:15,i.autoDetect&&this.detect(i),i._target=t,i.type!==Ft.SPRITE&&this.maskStack.push(i),i.enabled)switch(i.type){case Ft.SCISSOR:this.renderer.scissor.push(i);break;case Ft.STENCIL:this.renderer.stencil.push(i);break;case Ft.SPRITE:i.copyCountersOrReset(null),this.pushSpriteMask(i);break;case Ft.COLOR:this.pushColorMask(i);break}i.type===Ft.SPRITE&&this.maskStack.push(i)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case Ft.SCISSOR:this.renderer.scissor.pop(e);break;case Ft.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case Ft.SPRITE:this.popSpriteMask(e);break;case Ft.COLOR:this.popColorMask(e);break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const i=this.maskStack[this.maskStack.length-1];i.type===Ft.SPRITE&&i._filters&&(i._filters[0].maskSprite=i.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=Ft.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=Ft.SCISSOR:t.type=Ft.STENCIL:t.type=Ft.COLOR}pushSpriteMask(t){const{maskObject:e}=t,i=t._target;let s=t._filters;s||(s=this.alphaMaskPool[this.alphaMaskIndex],s||(s=this.alphaMaskPool[this.alphaMaskIndex]=[new Hv])),s[0].resolution=t.resolution,s[0].multisample=t.multisample,s[0].maskSprite=e;const n=i.filterArea;i.filterArea=e.getBounds(!0),this.renderer.filter.push(i,s),i.filterArea=n,t._filters||this.alphaMaskIndex++}popSpriteMask(t){this.renderer.filter.pop(),t._filters?t._filters[0].maskSprite=null:(this.alphaMaskIndex--,this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite=null)}pushColorMask(t){const e=t._colorMask,i=t._colorMask=e&t.colorMask;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}popColorMask(t){const e=t._colorMask,i=this.maskStack.length>0?this.maskStack[this.maskStack.length-1]._colorMask:15;i!==e&&this.renderer.gl.colorMask((i&1)!==0,(i&2)!==0,(i&4)!==0,(i&8)!==0)}destroy(){this.renderer=null}}Gu.extension={type:X.RendererSystem,name:"mask"},j.add(Gu);class $u{constructor(t){this.renderer=t,this.maskStack=[],this.glConst=0}getStackLength(){return this.maskStack.length}setMaskStack(t){const{gl:e}=this.renderer,i=this.getStackLength();this.maskStack=t;const s=this.getStackLength();s!==i&&(s===0?e.disable(this.glConst):(e.enable(this.glConst),this._useCurrent()))}_useCurrent(){}destroy(){this.renderer=null,this.maskStack=null}}const Hu=new wt,Xu=[],Vu=class Jn extends $u{constructor(t){super(t),this.glConst=z.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._scissorCounter:0}calcScissorRect(t){if(t._scissorRectLocal)return;const e=t._scissorRect,{maskObject:i}=t,{renderer:s}=this,n=s.renderTexture,o=i.getBounds(!0,Xu.pop()??new it);this.roundFrameToPixels(o,n.current?n.current.resolution:s.resolution,n.sourceFrame,n.destinationFrame,s.projection.transform),e&&o.fit(e),t._scissorRectLocal=o}static isMatrixRotated(t){if(!t)return!1;const{a:e,b:i,c:s,d:n}=t;return(Math.abs(i)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(e)>1e-4||Math.abs(n)>1e-4)}testScissor(t){const{maskObject:e}=t;if(!e.isFastRect||!e.isFastRect()||Jn.isMatrixRotated(e.worldTransform)||Jn.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(t);const i=t._scissorRectLocal;return i.width>0&&i.height>0}roundFrameToPixels(t,e,i,s,n){Jn.isMatrixRotated(n)||(n=n?Hu.copyFrom(n):Hu.identity(),n.translate(-i.x,-i.y).scale(s.width/i.width,s.height/i.height).translate(s.x,s.y),this.renderer.filter.transformAABB(n,t),t.fit(s),t.x=Math.round(t.x*e),t.y=Math.round(t.y*e),t.width=Math.round(t.width*e),t.height=Math.round(t.height*e))}push(t){t._scissorRectLocal||this.calcScissorRect(t);const{gl:e}=this.renderer;t._scissorRect||e.enable(e.SCISSOR_TEST),t._scissorCounter++,t._scissorRect=t._scissorRectLocal,this._useCurrent()}pop(t){const{gl:e}=this.renderer;t&&Xu.push(t._scissorRectLocal),this.getStackLength()>0?this._useCurrent():e.disable(e.SCISSOR_TEST)}_useCurrent(){const t=this.maskStack[this.maskStack.length-1]._scissorRect;let e;this.renderer.renderTexture.current?e=t.y:e=this.renderer.height-t.height-t.y,this.renderer.gl.scissor(t.x,e,t.width,t.height)}};Vu.extension={type:X.RendererSystem,name:"scissor"};let Vv=Vu;j.add(Vv);class zu extends $u{constructor(t){super(t),this.glConst=z.ADAPTER.getWebGLRenderingContext().STENCIL_TEST}getStackLength(){const t=this.maskStack[this.maskStack.length-1];return t?t._stencilCounter:0}push(t){const e=t.maskObject,{gl:i}=this.renderer,s=t._stencilCounter;s===0&&(this.renderer.framebuffer.forceStencil(),i.clearStencil(0),i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST)),t._stencilCounter++;const n=t._colorMask;n!==0&&(t._colorMask=0,i.colorMask(!1,!1,!1,!1)),i.stencilFunc(i.EQUAL,s,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.INCR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,n!==0&&(t._colorMask=n,i.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this._useCurrent()}pop(t){const e=this.renderer.gl;if(this.getStackLength()===0)e.disable(e.STENCIL_TEST);else{const i=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null,s=i?i._colorMask:15;s!==0&&(i._colorMask=0,e.colorMask(!1,!1,!1,!1)),e.stencilOp(e.KEEP,e.KEEP,e.DECR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,s!==0&&(i._colorMask=s,e.colorMask((s&1)!==0,(s&2)!==0,(s&4)!==0,(s&8)!==0)),this._useCurrent()}}_useCurrent(){const t=this.renderer.gl;t.stencilFunc(t.EQUAL,this.getStackLength(),4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}}zu.extension={type:X.RendererSystem,name:"stencil"},j.add(zu);class Wu{constructor(t){this.renderer=t,this.plugins={},Object.defineProperties(this.plugins,{extract:{enumerable:!1,get(){return at("7.0.0","renderer.plugins.extract has moved to renderer.extract"),t.extract}},prepare:{enumerable:!1,get(){return at("7.0.0","renderer.plugins.prepare has moved to renderer.prepare"),t.prepare}},interaction:{enumerable:!1,get(){return at("7.0.0","renderer.plugins.interaction has been deprecated, use renderer.events"),t.events}}})}init(){const t=this.rendererPlugins;for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Wu.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_plugin"},j.add(Wu);class ju{constructor(t){this.renderer=t,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new wt,this.transform=null}update(t,e,i,s){this.destinationFrame=t||this.destinationFrame||this.defaultFrame,this.sourceFrame=e||this.sourceFrame||t,this.calculateProjection(this.destinationFrame,this.sourceFrame,i,s),this.transform&&this.projectionMatrix.append(this.transform);const n=this.renderer;n.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,n.globalUniforms.update(),n.shader.shader&&n.shader.syncUniformGroup(n.shader.shader.uniforms.globals)}calculateProjection(t,e,i,s){const n=this.projectionMatrix,o=s?-1:1;n.identity(),n.a=1/e.width*2,n.d=o*(1/e.height*2),n.tx=-1-e.x*n.a,n.ty=-o-e.y*n.d}setTransform(t){}destroy(){this.renderer=null}}ju.extension={type:X.RendererSystem,name:"projection"},j.add(ju);const zv=new Ba,Yu=new it;class qu{constructor(t){this.renderer=t,this._tempMatrix=new wt}generateTexture(t,e){const{region:i,...s}=e||{},n=(i==null?void 0:i.copyTo(Yu))||t.getLocalBounds(Yu,!0),o=s.resolution||this.renderer.resolution;n.width=Math.max(n.width,1/o),n.height=Math.max(n.height,1/o),s.width=n.width,s.height=n.height,s.resolution=o,s.multisample??(s.multisample=this.renderer.multisample);const a=Xr.create(s);this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const l=t.transform;return t.transform=zv,this.renderer.render(t,{renderTexture:a,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=l,a}destroy(){}}qu.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"textureGenerator"},j.add(qu);const Vr=new it,us=new it;class Ku{constructor(t){this.renderer=t,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new it,this.destinationFrame=new it,this.viewportFrame=new it}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}bind(t=null,e,i){const s=this.renderer;this.current=t;let n,o,a;t?(n=t.baseTexture,a=n.resolution,e||(Vr.width=t.frame.width,Vr.height=t.frame.height,e=Vr),i||(us.x=t.frame.x,us.y=t.frame.y,us.width=e.width,us.height=e.height,i=us),o=n.framebuffer):(a=s.resolution,e||(Vr.width=s._view.screen.width,Vr.height=s._view.screen.height,e=Vr),i||(i=Vr,i.width=e.width,i.height=e.height));const l=this.viewportFrame;l.x=i.x*a,l.y=i.y*a,l.width=i.width*a,l.height=i.height*a,t||(l.y=s.view.height-(l.y+l.height)),l.ceil(),this.renderer.framebuffer.bind(o,l),this.renderer.projection.update(i,e,a,!o),t?this.renderer.mask.setMaskStack(n.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(e),this.destinationFrame.copyFrom(i)}clear(t,e){const i=this.current?this.current.baseTexture.clear:this.renderer.background.backgroundColor,s=vt.shared.setValue(t||i);(this.current&&this.current.baseTexture.alphaMode>0||!this.current&&this._rendererPremultipliedAlpha)&&s.premultiply(s.alpha);const n=this.destinationFrame,o=this.current?this.current.baseTexture:this.renderer._view.screen,a=n.width!==o.width||n.height!==o.height;if(a){let{x:l,y:h,width:c,height:u}=this.viewportFrame;l=Math.round(l),h=Math.round(h),c=Math.round(c),u=Math.round(u),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(l,h,c,u)}this.renderer.framebuffer.clear(s.red,s.green,s.blue,s.alpha,e),a&&this.renderer.scissor.pop()}resize(){this.bind(null)}reset(){this.bind(null)}destroy(){this.renderer=null}}Ku.extension={type:X.RendererSystem,name:"renderTexture"},j.add(Ku);class Wv{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function jv(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_ATTRIBUTES);for(let s=0;s<i;s++){const n=t.getActiveAttrib(r,s);if(n.name.startsWith("gl_"))continue;const o=Su(t,n.type),a={type:o,name:n.name,size:Tu(o),location:t.getAttribLocation(r,n.name)};e[n.name]=a}return e}function Yv(r,t){const e={},i=t.getProgramParameter(r,t.ACTIVE_UNIFORMS);for(let s=0;s<i;s++){const n=t.getActiveUniform(r,s),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),l=Su(t,n.type);e[o]={name:o,index:s,type:l,size:n.size,isArray:a,value:bu(l,n.size)}}return e}function qv(r,t){var a;const e=xu(r,r.VERTEX_SHADER,t.vertexSrc),i=xu(r,r.FRAGMENT_SHADER,t.fragmentSrc),s=r.createProgram();r.attachShader(s,e),r.attachShader(s,i);const n=(a=t.extra)==null?void 0:a.transformFeedbackVaryings;if(n&&(typeof r.transformFeedbackVaryings!="function"?console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,n.names,n.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Tv(r,s,e,i),t.attributeData=jv(s,r),t.uniformData=Yv(s,r),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((h,c)=>h>c?1:-1);for(let h=0;h<l.length;h++)t.attributeData[l[h]].location=h,r.bindAttribLocation(s,h,l[h]);r.linkProgram(s)}r.deleteShader(e),r.deleteShader(i);const o={};for(const l in t.uniformData){const h=t.uniformData[l];o[l]={location:r.getUniformLocation(s,l),value:bu(h.type,h.size)}}return new Wv(s,o)}function Kv(r,t,e,i,s){e.buffer.update(s)}const Zv={float:`
|
|
420
420
|
data[offset] = v;
|
|
421
421
|
`,vec2:`
|
|
422
422
|
data[offset] = v[0];
|
|
@@ -462,7 +462,7 @@ void main(void)
|
|
|
462
462
|
var gl = renderer.gl
|
|
463
463
|
var index = 0;
|
|
464
464
|
var data = buffer.data;
|
|
465
|
-
`];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<
|
|
465
|
+
`];for(let o=0;o<i.length;o++){const a=i[o],l=r.uniforms[a.data.name],h=a.data.name;let c=!1;for(let u=0;u<Ai.length;u++){const d=Ai[u];if(d.codeUbo&&d.test(a.data,l)){n.push(`offset = ${a.offset/4};`,Ai[u].codeUbo(a.data.name,l)),c=!0;break}}if(!c)if(a.data.size>1){const u=Tu(a.data.type),d=Math.max(Zu[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(`
|
|
466
466
|
cv = ud.${h}.value;
|
|
467
467
|
v = uv.${h};
|
|
468
468
|
offset = ${a.offset/4};
|
|
@@ -486,7 +486,7 @@ void main(void)
|
|
|
486
486
|
`)}}return n.push(`
|
|
487
487
|
renderer.buffer.update(buffer);
|
|
488
488
|
`),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
|
|
489
|
-
`))}}let e1=0;const wn={textureCount:0,uboCount:0};class Ju{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=e1++}systemCheck(){if(!Sv())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(wn.textureCount=0,wn.uboCount=0,this.syncUniformGroup(t.uniformGroup,wn)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=bv(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,wn,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=t1(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=qv(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}Ju.extension={type:$.RendererSystem,name:"shader"},Y.add(Ju);class En{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}En.defaultOptions={hello:!1},En.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"},Y.add(En);function r1(r,t=[]){return t[J.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.ADD]=[r.ONE,r.ONE],t[J.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.NONE]=[0,0],t[J.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[J.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[J.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[J.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[J.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[J.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[J.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[J.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[J.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[J.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const i1=0,s1=1,n1=2,o1=3,a1=4,l1=5,Qu=class El{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=J.NONE,this._blendEq=!1,this.map=[],this.map[i1]=this.setBlend,this.map[s1]=this.setOffset,this.map[n1]=this.setCullFace,this.map[o1]=this.setDepthTest,this.map[a1]=this.setFrontFace,this.map[l1]=this.setDepthMask,this.checks=[],this.defaultState=new $e,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=r1(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(El.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(El.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};Qu.extension={type:$.RendererSystem,name:"state"};let h1=Qu;Y.add(h1);class c1 extends qi{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new _e(e)})}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 s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const us=class Qn{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Qn.defaultMaxIdle,this.checkCountMax=Qn.defaultCheckCountMax,this.mode=Qn.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Ro.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};us.defaultMode=Ro.AUTO,us.defaultMaxIdle=60*60,us.defaultCheckCountMax=60*10,us.extension={type:$.RendererSystem,name:"textureGC"};let zr=us;Y.add(zr);class $a{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=Z.UNSIGNED_BYTE,this.internalFormat=U.RGBA,this.samplerType=0}}function u1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:z.FLOAT,[r.RGBA]:z.FLOAT,[r.ALPHA]:z.FLOAT,[r.LUMINANCE]:z.FLOAT,[r.LUMINANCE_ALPHA]:z.FLOAT,[r.R8]:z.FLOAT,[r.R8_SNORM]:z.FLOAT,[r.RG8]:z.FLOAT,[r.RG8_SNORM]:z.FLOAT,[r.RGB8]:z.FLOAT,[r.RGB8_SNORM]:z.FLOAT,[r.RGB565]:z.FLOAT,[r.RGBA4]:z.FLOAT,[r.RGB5_A1]:z.FLOAT,[r.RGBA8]:z.FLOAT,[r.RGBA8_SNORM]:z.FLOAT,[r.RGB10_A2]:z.FLOAT,[r.RGB10_A2UI]:z.FLOAT,[r.SRGB8]:z.FLOAT,[r.SRGB8_ALPHA8]:z.FLOAT,[r.R16F]:z.FLOAT,[r.RG16F]:z.FLOAT,[r.RGB16F]:z.FLOAT,[r.RGBA16F]:z.FLOAT,[r.R32F]:z.FLOAT,[r.RG32F]:z.FLOAT,[r.RGB32F]:z.FLOAT,[r.RGBA32F]:z.FLOAT,[r.R11F_G11F_B10F]:z.FLOAT,[r.RGB9_E5]:z.FLOAT,[r.R8I]:z.INT,[r.R8UI]:z.UINT,[r.R16I]:z.INT,[r.R16UI]:z.UINT,[r.R32I]:z.INT,[r.R32UI]:z.UINT,[r.RG8I]:z.INT,[r.RG8UI]:z.UINT,[r.RG16I]:z.INT,[r.RG16UI]:z.UINT,[r.RG32I]:z.INT,[r.RG32UI]:z.UINT,[r.RGB8I]:z.INT,[r.RGB8UI]:z.UINT,[r.RGB16I]:z.INT,[r.RGB16UI]:z.UINT,[r.RGB32I]:z.INT,[r.RGB32UI]:z.UINT,[r.RGBA8I]:z.INT,[r.RGBA8UI]:z.UINT,[r.RGBA16I]:z.INT,[r.RGBA16UI]:z.UINT,[r.RGBA32I]:z.INT,[r.RGBA32UI]:z.UINT,[r.DEPTH_COMPONENT16]:z.FLOAT,[r.DEPTH_COMPONENT24]:z.FLOAT,[r.DEPTH_COMPONENT32F]:z.FLOAT,[r.DEPTH_STENCIL]:z.FLOAT,[r.DEPTH24_STENCIL8]:z.FLOAT,[r.DEPTH32F_STENCIL8]:z.FLOAT}:t={[r.RGB]:z.FLOAT,[r.RGBA]:z.FLOAT,[r.ALPHA]:z.FLOAT,[r.LUMINANCE]:z.FLOAT,[r.LUMINANCE_ALPHA]:z.FLOAT,[r.DEPTH_STENCIL]:z.FLOAT},t}function d1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[Z.UNSIGNED_BYTE]:{[U.RGBA]:r.RGBA8,[U.RGB]:r.RGB8,[U.RG]:r.RG8,[U.RED]:r.R8,[U.RGBA_INTEGER]:r.RGBA8UI,[U.RGB_INTEGER]:r.RGB8UI,[U.RG_INTEGER]:r.RG8UI,[U.RED_INTEGER]:r.R8UI,[U.ALPHA]:r.ALPHA,[U.LUMINANCE]:r.LUMINANCE,[U.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[Z.BYTE]:{[U.RGBA]:r.RGBA8_SNORM,[U.RGB]:r.RGB8_SNORM,[U.RG]:r.RG8_SNORM,[U.RED]:r.R8_SNORM,[U.RGBA_INTEGER]:r.RGBA8I,[U.RGB_INTEGER]:r.RGB8I,[U.RG_INTEGER]:r.RG8I,[U.RED_INTEGER]:r.R8I},[Z.UNSIGNED_SHORT]:{[U.RGBA_INTEGER]:r.RGBA16UI,[U.RGB_INTEGER]:r.RGB16UI,[U.RG_INTEGER]:r.RG16UI,[U.RED_INTEGER]:r.R16UI,[U.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[Z.SHORT]:{[U.RGBA_INTEGER]:r.RGBA16I,[U.RGB_INTEGER]:r.RGB16I,[U.RG_INTEGER]:r.RG16I,[U.RED_INTEGER]:r.R16I},[Z.UNSIGNED_INT]:{[U.RGBA_INTEGER]:r.RGBA32UI,[U.RGB_INTEGER]:r.RGB32UI,[U.RG_INTEGER]:r.RG32UI,[U.RED_INTEGER]:r.R32UI,[U.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[Z.INT]:{[U.RGBA_INTEGER]:r.RGBA32I,[U.RGB_INTEGER]:r.RGB32I,[U.RG_INTEGER]:r.RG32I,[U.RED_INTEGER]:r.R32I},[Z.FLOAT]:{[U.RGBA]:r.RGBA32F,[U.RGB]:r.RGB32F,[U.RG]:r.RG32F,[U.RED]:r.R32F,[U.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[Z.HALF_FLOAT]:{[U.RGBA]:r.RGBA16F,[U.RGB]:r.RGB16F,[U.RG]:r.RG16F,[U.RED]:r.R16F},[Z.UNSIGNED_SHORT_5_6_5]:{[U.RGB]:r.RGB565},[Z.UNSIGNED_SHORT_4_4_4_4]:{[U.RGBA]:r.RGBA4},[Z.UNSIGNED_SHORT_5_5_5_1]:{[U.RGBA]:r.RGB5_A1},[Z.UNSIGNED_INT_2_10_10_10_REV]:{[U.RGBA]:r.RGB10_A2,[U.RGBA_INTEGER]:r.RGB10_A2UI},[Z.UNSIGNED_INT_10F_11F_11F_REV]:{[U.RGB]:r.R11F_G11F_B10F},[Z.UNSIGNED_INT_5_9_9_9_REV]:{[U.RGB]:r.RGB9_E5},[Z.UNSIGNED_INT_24_8]:{[U.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[Z.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[U.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[Z.UNSIGNED_BYTE]:{[U.RGBA]:r.RGBA,[U.RGB]:r.RGB,[U.ALPHA]:r.ALPHA,[U.LUMINANCE]:r.LUMINANCE,[U.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[Z.UNSIGNED_SHORT_5_6_5]:{[U.RGB]:r.RGB},[Z.UNSIGNED_SHORT_4_4_4_4]:{[U.RGBA]:r.RGBA},[Z.UNSIGNED_SHORT_5_5_5_1]:{[U.RGBA]:r.RGBA}},t}class td{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new et,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=d1(t),this.samplerTypes=u1(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new $a(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new $a(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==z.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new $a(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??z.FLOAT,this.webGLVersion===2&&t.type===Z.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==z.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&Ei(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===De.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=dr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==De.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===tr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===tr.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===tr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===tr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}td.extension={type:$.RendererSystem,name:"texture"},Y.add(td);class ed{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}ed.extension={type:$.RendererSystem,name:"transformFeedback"},Y.add(ed);class Tn{constructor(t){this.renderer=t}init(t){this.screen=new it(0,0,t.width,t.height),this.element=t.view||W.ADAPTER.createCanvas(),this.resolution=t.resolution||W.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Tn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Tn.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"},Y.add(Tn),W.PREFER_ENV=Mr.WEBGL2,W.STRICT_TEXTURE_CACHE=!1,W.RENDER_OPTIONS={...vn.defaultOptions,..._n.defaultOptions,...Tn.defaultOptions,...En.defaultOptions},Object.defineProperties(W,{WRAP_MODE:{get(){return et.defaultOptions.wrapMode},set(r){at("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),et.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return et.defaultOptions.scaleMode},set(r){at("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),et.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return et.defaultOptions.mipmap},set(r){at("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),et.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return et.defaultOptions.anisotropicLevel},set(r){at("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),et.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return at("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ee.defaultResolution},set(r){ee.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return at("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ee.defaultMultisample},set(r){ee.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Hr.defaultMaxTextures},set(r){at("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Hr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Hr.defaultBatchSize},set(r){at("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Hr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Hr.canUploadSameBuffer},set(r){at("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Hr.canUploadSameBuffer=r}},GC_MODE:{get(){return zr.defaultMode},set(r){at("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),zr.defaultMode=r}},GC_MAX_IDLE:{get(){return zr.defaultMaxIdle},set(r){at("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),zr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return zr.defaultCheckCountMax},set(r){at("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),zr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return ar.defaultVertexPrecision},set(r){at("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),ar.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return ar.defaultFragmentPrecision},set(r){at("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),ar.defaultFragmentPrecision=r}}});var Wr=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Wr||{});class Ha{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}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 rd=class le{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 Ha(null,null,1/0),this.deltaMS=1/le.targetFPMS,this.elapsedMS=1/le.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=Wr.NORMAL){return this._addListener(new Ha(t,e,i))}addOnce(t,e,i=Wr.NORMAL){return this._addListener(new Ha(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<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*le.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,le.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!le._shared){const t=le._shared=new le;t.autoStart=!0,t._protected=!0}return le._shared}static get system(){if(!le._system){const t=le._system=new le;t.autoStart=!0,t._protected=!0}return le._system}};rd.targetFPMS=.06;let ae=rd;Object.defineProperties(W,{TARGET_FPMS:{get(){return ae.targetFPMS},set(r){at("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),ae.targetFPMS=r}}});class id{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Wr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ae.shared:new ae,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}id.extension=$.Application,Y.add(id);const sd=[];Y.handleByList($.Renderer,sd);function nd(r){for(const t of sd)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var f1=`attribute vec2 aVertexPosition;
|
|
489
|
+
`))}}let e1=0;const wn={textureCount:0,uboCount:0};class Ju{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=e1++}systemCheck(){if(!Sv())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(wn.textureCount=0,wn.uboCount=0,this.syncUniformGroup(t.uniformGroup,wn)),s}setUniforms(t){const e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){const i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=bv(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;const s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,wn,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){const{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=t1(t,this.shader.program.uniformData)),t.autoManage){const l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const o in s)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,i=t.program,s=qv(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}Ju.extension={type:X.RendererSystem,name:"shader"},j.add(Ju);class En{constructor(t){this.renderer=t}run(t){const{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}}En.defaultOptions={hello:!1},En.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"startup"},j.add(En);function r1(r,t=[]){return t[Z.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.ADD]=[r.ONE,r.ONE],t[Z.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.NONE]=[0,0],t[Z.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[Z.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[Z.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[Z.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Z.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[Z.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[Z.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[Z.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[Z.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Z.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}const i1=0,s1=1,n1=2,o1=3,a1=4,l1=5,Qu=class El{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Z.NONE,this._blendEq=!1,this.map=[],this.map[i1]=this.setBlend,this.map[s1]=this.setOffset,this.map[n1]=this.setCullFace,this.map[o1]=this.setDepthTest,this.map[a1]=this.setFrontFace,this.map[l1]=this.setDepthMask,this.checks=[],this.defaultState=new $e,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=r1(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(El.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(El.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;const e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){const i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};Qu.extension={type:X.RendererSystem,name:"state"};let h1=Qu;j.add(h1);class c1 extends Ki{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);const e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(const s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new _e(e)})}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 s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){const i=Object.keys(this._systemsHash);t.items.forEach(s=>{const n=i.find(o=>this._systemsHash[o]===s);s[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}const ds=class Qn{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Qn.defaultMaxIdle,this.checkCountMax=Qn.defaultCheckCountMax,this.mode=Qn.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Ro.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let i=!1;for(let s=0;s<e.length;s++){const n=e[s];n.resource&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[s]=null,i=!0)}if(i){let s=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[s++]=e[n]);e.length=s}}unload(t){const e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};ds.defaultMode=Ro.AUTO,ds.defaultMaxIdle=60*60,ds.defaultCheckCountMax=60*10,ds.extension={type:X.RendererSystem,name:"textureGC"};let zr=ds;j.add(zr);class $a{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=K.UNSIGNED_BYTE,this.internalFormat=U.RGBA,this.samplerType=0}}function u1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:V.FLOAT,[r.RGBA]:V.FLOAT,[r.ALPHA]:V.FLOAT,[r.LUMINANCE]:V.FLOAT,[r.LUMINANCE_ALPHA]:V.FLOAT,[r.R8]:V.FLOAT,[r.R8_SNORM]:V.FLOAT,[r.RG8]:V.FLOAT,[r.RG8_SNORM]:V.FLOAT,[r.RGB8]:V.FLOAT,[r.RGB8_SNORM]:V.FLOAT,[r.RGB565]:V.FLOAT,[r.RGBA4]:V.FLOAT,[r.RGB5_A1]:V.FLOAT,[r.RGBA8]:V.FLOAT,[r.RGBA8_SNORM]:V.FLOAT,[r.RGB10_A2]:V.FLOAT,[r.RGB10_A2UI]:V.FLOAT,[r.SRGB8]:V.FLOAT,[r.SRGB8_ALPHA8]:V.FLOAT,[r.R16F]:V.FLOAT,[r.RG16F]:V.FLOAT,[r.RGB16F]:V.FLOAT,[r.RGBA16F]:V.FLOAT,[r.R32F]:V.FLOAT,[r.RG32F]:V.FLOAT,[r.RGB32F]:V.FLOAT,[r.RGBA32F]:V.FLOAT,[r.R11F_G11F_B10F]:V.FLOAT,[r.RGB9_E5]:V.FLOAT,[r.R8I]:V.INT,[r.R8UI]:V.UINT,[r.R16I]:V.INT,[r.R16UI]:V.UINT,[r.R32I]:V.INT,[r.R32UI]:V.UINT,[r.RG8I]:V.INT,[r.RG8UI]:V.UINT,[r.RG16I]:V.INT,[r.RG16UI]:V.UINT,[r.RG32I]:V.INT,[r.RG32UI]:V.UINT,[r.RGB8I]:V.INT,[r.RGB8UI]:V.UINT,[r.RGB16I]:V.INT,[r.RGB16UI]:V.UINT,[r.RGB32I]:V.INT,[r.RGB32UI]:V.UINT,[r.RGBA8I]:V.INT,[r.RGBA8UI]:V.UINT,[r.RGBA16I]:V.INT,[r.RGBA16UI]:V.UINT,[r.RGBA32I]:V.INT,[r.RGBA32UI]:V.UINT,[r.DEPTH_COMPONENT16]:V.FLOAT,[r.DEPTH_COMPONENT24]:V.FLOAT,[r.DEPTH_COMPONENT32F]:V.FLOAT,[r.DEPTH_STENCIL]:V.FLOAT,[r.DEPTH24_STENCIL8]:V.FLOAT,[r.DEPTH32F_STENCIL8]:V.FLOAT}:t={[r.RGB]:V.FLOAT,[r.RGBA]:V.FLOAT,[r.ALPHA]:V.FLOAT,[r.LUMINANCE]:V.FLOAT,[r.LUMINANCE_ALPHA]:V.FLOAT,[r.DEPTH_STENCIL]:V.FLOAT},t}function d1(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[K.UNSIGNED_BYTE]:{[U.RGBA]:r.RGBA8,[U.RGB]:r.RGB8,[U.RG]:r.RG8,[U.RED]:r.R8,[U.RGBA_INTEGER]:r.RGBA8UI,[U.RGB_INTEGER]:r.RGB8UI,[U.RG_INTEGER]:r.RG8UI,[U.RED_INTEGER]:r.R8UI,[U.ALPHA]:r.ALPHA,[U.LUMINANCE]:r.LUMINANCE,[U.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[K.BYTE]:{[U.RGBA]:r.RGBA8_SNORM,[U.RGB]:r.RGB8_SNORM,[U.RG]:r.RG8_SNORM,[U.RED]:r.R8_SNORM,[U.RGBA_INTEGER]:r.RGBA8I,[U.RGB_INTEGER]:r.RGB8I,[U.RG_INTEGER]:r.RG8I,[U.RED_INTEGER]:r.R8I},[K.UNSIGNED_SHORT]:{[U.RGBA_INTEGER]:r.RGBA16UI,[U.RGB_INTEGER]:r.RGB16UI,[U.RG_INTEGER]:r.RG16UI,[U.RED_INTEGER]:r.R16UI,[U.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[K.SHORT]:{[U.RGBA_INTEGER]:r.RGBA16I,[U.RGB_INTEGER]:r.RGB16I,[U.RG_INTEGER]:r.RG16I,[U.RED_INTEGER]:r.R16I},[K.UNSIGNED_INT]:{[U.RGBA_INTEGER]:r.RGBA32UI,[U.RGB_INTEGER]:r.RGB32UI,[U.RG_INTEGER]:r.RG32UI,[U.RED_INTEGER]:r.R32UI,[U.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[K.INT]:{[U.RGBA_INTEGER]:r.RGBA32I,[U.RGB_INTEGER]:r.RGB32I,[U.RG_INTEGER]:r.RG32I,[U.RED_INTEGER]:r.R32I},[K.FLOAT]:{[U.RGBA]:r.RGBA32F,[U.RGB]:r.RGB32F,[U.RG]:r.RG32F,[U.RED]:r.R32F,[U.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[K.HALF_FLOAT]:{[U.RGBA]:r.RGBA16F,[U.RGB]:r.RGB16F,[U.RG]:r.RG16F,[U.RED]:r.R16F},[K.UNSIGNED_SHORT_5_6_5]:{[U.RGB]:r.RGB565},[K.UNSIGNED_SHORT_4_4_4_4]:{[U.RGBA]:r.RGBA4},[K.UNSIGNED_SHORT_5_5_5_1]:{[U.RGBA]:r.RGB5_A1},[K.UNSIGNED_INT_2_10_10_10_REV]:{[U.RGBA]:r.RGB10_A2,[U.RGBA_INTEGER]:r.RGB10_A2UI},[K.UNSIGNED_INT_10F_11F_11F_REV]:{[U.RGB]:r.R11F_G11F_B10F},[K.UNSIGNED_INT_5_9_9_9_REV]:{[U.RGB]:r.RGB9_E5},[K.UNSIGNED_INT_24_8]:{[U.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[K.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[U.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[K.UNSIGNED_BYTE]:{[U.RGBA]:r.RGBA,[U.RGB]:r.RGB,[U.ALPHA]:r.ALPHA,[U.LUMINANCE]:r.LUMINANCE,[U.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[K.UNSIGNED_SHORT_5_6_5]:{[U.RGB]:r.RGB},[K.UNSIGNED_SHORT_4_4_4_4]:{[U.RGBA]:r.RGBA},[K.UNSIGNED_SHORT_5_5_5_1]:{[U.RGBA]:r.RGBA}},t}class td{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new et,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=d1(t),this.samplerTypes=u1(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};const i=new $a(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new $a(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){const{gl:i}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[s].samplerType!==V.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new $a(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var i;e.internalFormat=((i=this.internalFormats[t.type])==null?void 0:i[t.format])??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??V.FLOAT,this.webGLVersion===2&&t.type===K.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var s;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const i=this.renderer;if(this.initTextureType(t,e),(s=t.resource)==null?void 0:s.upload(i,t,e))e.samplerType!==V.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=i.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const s=this.managedTextures.indexOf(t);s!==-1&&Ti(this.managedTextures,s,1)}}updateTextureStyle(t){var i;const e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===De.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=dr.CLAMP:e.wrapMode=t.wrapMode,(i=t.resource)!=null&&i.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const i=this.gl;if(e.mipmap&&t.mipmap!==De.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===tr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);const s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===tr.LINEAR){const n=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===tr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===tr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}}td.extension={type:X.RendererSystem,name:"texture"},j.add(td);class ed{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:i,CONTEXT_UID:s}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[s]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&n.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}ed.extension={type:X.RendererSystem,name:"transformFeedback"},j.add(ed);class Tn{constructor(t){this.renderer=t}init(t){this.screen=new it(0,0,t.width,t.height),this.element=t.view||z.ADAPTER.createCanvas(),this.resolution=t.resolution||z.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Tn.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Tn.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_view"},j.add(Tn),z.PREFER_ENV=Mr.WEBGL2,z.STRICT_TEXTURE_CACHE=!1,z.RENDER_OPTIONS={...vn.defaultOptions,..._n.defaultOptions,...Tn.defaultOptions,...En.defaultOptions},Object.defineProperties(z,{WRAP_MODE:{get(){return et.defaultOptions.wrapMode},set(r){at("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),et.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return et.defaultOptions.scaleMode},set(r){at("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),et.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return et.defaultOptions.mipmap},set(r){at("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),et.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return et.defaultOptions.anisotropicLevel},set(r){at("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),et.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return at("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ee.defaultResolution},set(r){ee.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return at("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ee.defaultMultisample},set(r){ee.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Hr.defaultMaxTextures},set(r){at("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Hr.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Hr.defaultBatchSize},set(r){at("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Hr.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Hr.canUploadSameBuffer},set(r){at("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Hr.canUploadSameBuffer=r}},GC_MODE:{get(){return zr.defaultMode},set(r){at("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),zr.defaultMode=r}},GC_MAX_IDLE:{get(){return zr.defaultMaxIdle},set(r){at("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),zr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return zr.defaultCheckCountMax},set(r){at("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),zr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return ar.defaultVertexPrecision},set(r){at("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),ar.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return ar.defaultFragmentPrecision},set(r){at("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),ar.defaultFragmentPrecision=r}}});var Wr=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Wr||{});class Ha{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}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 rd=class le{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 Ha(null,null,1/0),this.deltaMS=1/le.targetFPMS,this.elapsedMS=1/le.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=Wr.NORMAL){return this._addListener(new Ha(t,e,i))}addOnce(t,e,i=Wr.NORMAL){return this._addListener(new Ha(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<this._minElapsedMS)return;this._lastFrame=t-n%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*le.targetFPMS;const i=this._head;let s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,le.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!le._shared){const t=le._shared=new le;t.autoStart=!0,t._protected=!0}return le._shared}static get system(){if(!le._system){const t=le._system=new le;t.autoStart=!0,t._protected=!0}return le._system}};rd.targetFPMS=.06;let ae=rd;Object.defineProperties(z,{TARGET_FPMS:{get(){return ae.targetFPMS},set(r){at("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),ae.targetFPMS=r}}});class id{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Wr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?ae.shared:new ae,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}id.extension=X.Application,j.add(id);const sd=[];j.handleByList(X.Renderer,sd);function nd(r){for(const t of sd)if(t.test(r))return new t(r);throw new Error("Unable to auto-detect a suitable renderer.")}var f1=`attribute vec2 aVertexPosition;
|
|
490
490
|
attribute vec2 aTextureCoord;
|
|
491
491
|
|
|
492
492
|
uniform mat3 projectionMatrix;
|
|
@@ -523,7 +523,7 @@ void main(void)
|
|
|
523
523
|
gl_Position = filterVertexPosition();
|
|
524
524
|
vTextureCoord = filterTextureCoord();
|
|
525
525
|
}
|
|
526
|
-
`;const m1=f1,od=p1;class ad{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Bt.HIGH?this.multisample=Bt.HIGH:e>=Bt.MEDIUM?this.multisample=Bt.MEDIUM:e>=Bt.LOW?this.multisample=Bt.LOW:this.multisample=Bt.NONE}destroy(){}}ad.extension={type:$.RendererSystem,name:"_multisample"},Y.add(ad);class g1{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class ld{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new g1(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}ld.extension={type:$.RendererSystem,name:"buffer"},Y.add(ld);class hd{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}hd.extension={type:$.RendererSystem,name:"objectRenderer"},Y.add(hd);const An=class Tl extends c1{constructor(t){super(),this.type=Uh.WEBGL,t=Object.assign({},W.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ve({projectionMatrix:new wt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Tl.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(at("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Tl.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:G_()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return at("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return at("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return at("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return at("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){at("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return at("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){at("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return at("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};An.extension={type:$.Renderer,priority:1},An.__plugins={},An.__systems={};let Xa=An;Y.handleByMap($.RendererPlugin,Xa.__plugins),Y.handleByMap($.RendererSystem,Xa.__systems),Y.add(Xa);class cd extends as{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new et;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof as?this.addResourceAt(t[i],i):this.addResourceAt(gu(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class y1 extends cd{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=hi.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class _1 extends lr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const ud=class vs extends cd{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==vs.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<vs.SIDES;a++)this.items[a].target=hi.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=hi.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=hi.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<vs.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===vs.SIDES}};ud.SIDES=6;let v1=ud;class Si extends lr{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Si.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await W.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===re.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Si._EMPTY=Si._EMPTY??W.ADAPTER.createCanvas(0,0),Si._EMPTY}}const Va=class to extends lr{constructor(t,e){e=e||{},super(W.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},to.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;lr.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${Lr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=to.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&to.SVG_XML.test(t)}};Va.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Va.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let za=Va;class x1 extends lr{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Wa=class Al extends lr{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];lr.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||Al.MIME_TYPES[c]||`video/${c}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,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._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=ae.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;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._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;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._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}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.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(ae.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ae.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ae.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Al.TYPES.includes(e)}};Wa.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Wa.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let dd=Wa;Ca.push(Si,Mu,_1,dd,x1,za,on,v1,y1);class Sn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?it.EMPTY:(t=t||new it(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*e.x+n*e.y+a,c=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=o*e+l*i+c,y=a*e+h*i+u;d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,g=o*s+l*i+c,y=a*s+h*i+u,d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,g=o*e+l*n+c,y=a*e+h*n+u,d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,g=o*s+l*n+c,y=a*s+h*n+u,d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],c=t[l+1];s=h<s?h:s,n=c<n?c:n,o=h>o?h:o,a=c>a?c:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,g=this.maxY;for(let y=i;y<s;y+=2){const x=e[y],_=e[y+1],v=a*x+h*_+u,w=c*_+l*x+d;f=Math.min(f,v-n),m=Math.max(m,v+n),p=Math.min(p,w-o),g=Math.max(g,w+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=g}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class It extends qi{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Ba,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Sn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(It.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new it),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new it),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Sn);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new b1),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*pv}set angle(t){this.transform.rotation=t*mv}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class b1 extends It{constructor(){super(...arguments),this.sortDirty=null}}It.prototype.displayObjectUpdateTransform=It.prototype.updateTransform;const w1=new wt;function E1(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const fd=class Sl extends It{constructor(){super(),this.children=[],this.sortableChildren=Sl.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Ei(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Ei(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Ei(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(E1),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==Sl.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=w1.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==Ft.NONE));if(s&&t.batch.flush(),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};fd.defaultSortableChildren=!1;let xe=fd;xe.prototype.containerUpdateTransform=xe.prototype.updateTransform,Object.defineProperties(W,{SORTABLE_CHILDREN:{get(){return xe.defaultSortableChildren},set(r){at("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),xe.defaultSortableChildren=r}}});const ds=new dt,T1=new Uint16Array([0,1,2,0,2,3]);class Ci extends xe{constructor(t){super(),this._anchor=new or(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new vt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=J.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||q.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=T1,this.pluginName="batch",this.isSprite=!0,this._roundPixels=W.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=gr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=gr(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,g=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,g=c.y-d._y*u.height,m=g+c.height):(p=-d._x*u.width,f=p+u.width,g=-d._y*u.height,m=g+u.height),h[0]=i*p+n*g+a,h[1]=o*g+s*p+l,h[2]=i*f+n*g+a,h[3]=o*g+s*f+l,h[4]=i*f+n*m+a,h[5]=o*m+s*f+l,h[6]=i*p+n*m+a,h[7]=o*m+s*p+l,this._roundPixels){const y=W.RESOLUTION;for(let x=0;x<h.length;++x)h[x]=Math.round(h[x]*y)/y}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty,d=-s._x*i.width,f=d+i.width,p=-s._y*i.height,m=p+i.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*m+c,e[5]=h*m+a*f+u,e[6]=o*d+l*m+c,e[7]=h*m+a*d+u,this._roundPixels){const g=W.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*g)/g}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Sn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new it),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,ds);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return ds.x>=s&&ds.x<s+e&&(n=-i*this.anchor.y,ds.y>=n&&ds.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof q?t:q.from(t,e);return new Ci(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=gr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=gr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||q.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const pd=new wt;It.prototype._cacheAsBitmap=!1,It.prototype._cacheData=null,It.prototype._cacheAsBitmapResolution=null,It.prototype._cacheAsBitmapMultisample=null;class A1{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(It.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(r){r!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(r){r!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(r){if(this._cacheAsBitmap===r)return;this._cacheAsBitmap=r;let t;r?(this._cacheData||(this._cacheData=new A1),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),It.prototype._renderCached=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(r),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(r))},It.prototype._initCachedDisplayObject=function(r){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new it,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=Xr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${Lr()}`;this._cacheData.textureCacheId=h,et.addToCache(l.baseTexture,h),q.addToCache(l,h);const c=this.transform.localTransform.copyTo(pd).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new Ci(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},It.prototype._renderCachedCanvas=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(r),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(r))},It.prototype._initCachedDisplayObjectCanvas=function(r){var c;if((c=this._cacheData)!=null&&c.sprite)return;const t=this.getLocalBounds(new it,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Xr.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Lr()}`;this._cacheData.textureCacheId=a,et.addToCache(o.baseTexture,a),q.addToCache(o,a);const l=pd;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new Ci(o);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)},It.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},It.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},It.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,et.removeFromCache(this._cacheData.textureCacheId),q.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},It.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},It.prototype.name=null,xe.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},It.prototype.getGlobalPosition=function(r=new dt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var S1=`varying vec2 vTextureCoord;
|
|
526
|
+
`;const m1=f1,od=p1;class ad{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{const i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Bt.HIGH?this.multisample=Bt.HIGH:e>=Bt.MEDIUM?this.multisample=Bt.MEDIUM:e>=Bt.LOW?this.multisample=Bt.LOW:this.multisample=Bt.NONE}destroy(){}}ad.extension={type:X.RendererSystem,name:"_multisample"},j.add(ad);class g1{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class ld{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,i){const{gl:s,CONTEXT_UID:n}=this;i=i||0;const o=t._glBuffers[n]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,o.buffer,i*256,256)}update(t){const{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new g1(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}ld.extension={type:X.RendererSystem,name:"buffer"},j.add(ld);class hd{constructor(t){this.renderer=t}render(t,e){const i=this.renderer;let s,n,o,a;if(e&&(s=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=o,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){const l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(n??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}hd.extension={type:X.RendererSystem,name:"objectRenderer"},j.add(hd);const An=class Tl extends c1{constructor(t){super(),this.type=Uh.WEBGL,t=Object.assign({},z.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ve({projectionMatrix:new wt},!0);const e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:Tl.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(at("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=Tl.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t!=null&&t.forceCanvas?!1:G_()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return at("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return at("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return at("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return at("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){at("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return at("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){at("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return at("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};An.extension={type:X.Renderer,priority:1},An.__plugins={},An.__systems={};let Xa=An;j.handleByMap(X.RendererPlugin,Xa.__plugins),j.handleByMap(X.RendererSystem,Xa.__systems),j.add(Xa);class cd extends ls{constructor(t,e){const{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let n=0;n<t;n++){const o=new et;this.items.push(o),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof ls?this.addResourceAt(t[i],i):this.addResourceAt(gu(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;const t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{const{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}}class y1 extends cd{constructor(t,e){const{width:i,height:s}=e||{};let n,o;Array.isArray(t)?(n=t,o=t.length):o=t,super(o,{width:i,height:s}),n&&this.initFromArray(n,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=ci.TEXTURE_2D_ARRAY}upload(t,e,i){const{length:s,itemDirtyIds:n,items:o}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){const h=o[l];n[l]<h.dirtyId&&(n[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}}class _1 extends lr{constructor(t){super(t)}static test(t){const{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}}const ud=class xs extends cd{constructor(t,e){const{width:i,height:s,autoLoad:n,linkBaseTexture:o}=e||{};if(t&&t.length!==xs.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<xs.SIDES;a++)this.items[a].target=ci.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=o!==!1,t&&this.initFromArray(t,e),n!==!1&&this.load()}bind(t){super.bind(t),t.target=ci.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=ci.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){const s=this.itemDirtyIds;for(let n=0;n<xs.SIDES;n++){const o=this.items[n];(s[n]<o.dirtyId||i.dirtyId<e.dirtyId)&&(o.valid&&o.resource?(o.resource.upload(t,o,i),s[n]=o.dirtyId):s[n]<-1&&(t.gl.texImage2D(o.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[n]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===xs.SIDES}};ud.SIDES=6;let v1=ud;class Ii extends lr{constructor(t,e){e=e||{};let i,s,n;typeof t=="string"?(i=Ii.EMPTY,s=t,n=!0):(i=t,s=null,n=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??n,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{const i=await z.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;const s=await i.blob();if(this.destroyed)return;const n=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===re.UNPACK?"premultiply":"none"});if(this.destroyed){n.close();return}this.source=n,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return Ii._EMPTY=Ii._EMPTY??z.ADAPTER.createCanvas(0,0),Ii._EMPTY}}const Va=class to extends lr{constructor(t,e){e=e||{},super(z.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},to.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){const t=new Image;lr.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;const e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,n=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,n=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),n=Math.round(n);const o=this.source;o.width=s,o.height=n,o._pixiId=`canvas_${Lr()}`,o.getContext("2d").drawImage(t,0,0,e,i,0,0,s,n),this._resolve(),this._resolve=null}}static getSize(t){const e=to.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&to.SVG_XML.test(t)}};Va.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Va.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;let za=Va;class x1 extends lr{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}}const Wa=class Al extends lr{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){const i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);const s=t[0].src||t[0];lr.crossOrigin(i,s,e.crossorigin);for(let n=0;n<t.length;++n){const o=document.createElement("source");let{src:a,mime:l}=t[n];if(a=a||t[n],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||Al.MIME_TYPES[c]||`video/${c}`}o.src=a,l&&(o.type=l),i.appendChild(o)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,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._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){const e=ae.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;const t=this.source;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._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){const t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);const e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();const t=this.source;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._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}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.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(ae.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(ae.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(ae.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||Al.TYPES.includes(e)}};Wa.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Wa.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let dd=Wa;Ia.push(Ii,Mu,_1,dd,x1,za,on,v1,y1);class Sn{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?it.EMPTY:(t=t||new it(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:i,b:s,c:n,d:o,tx:a,ty:l}=t,h=i*e.x+n*e.y+a,c=s*e.x+o*e.y+l;this.minX=Math.min(this.minX,h),this.maxX=Math.max(this.maxX,h),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,i=this.minY,s=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,i=a<i?a:i,s=o>s?o:s,n=a>n?a:n,this.minX=e,this.minY=i,this.maxX=s,this.maxY=n}addFrame(t,e,i,s,n){this.addFrameMatrix(t.worldTransform,e,i,s,n)}addFrameMatrix(t,e,i,s,n){const o=t.a,a=t.b,l=t.c,h=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=o*e+l*i+c,y=a*e+h*i+u;d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,g=o*s+l*i+c,y=a*s+h*i+u,d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,g=o*e+l*n+c,y=a*e+h*n+u,d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,g=o*s+l*n+c,y=a*s+h*n+u,d=g<d?g:d,f=y<f?y:f,p=g>p?g:p,m=y>m?y:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}addVertexData(t,e,i){let s=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let l=e;l<i;l+=2){const h=t[l],c=t[l+1];s=h<s?h:s,n=c<n?c:n,o=h>o?h:o,a=c>a?c:a}this.minX=s,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,i,s){this.addVerticesMatrix(t.worldTransform,e,i,s)}addVerticesMatrix(t,e,i,s,n=0,o=n){const a=t.a,l=t.b,h=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,m=this.maxX,g=this.maxY;for(let y=i;y<s;y+=2){const v=e[y],_=e[y+1],x=a*v+h*_+u,T=c*_+l*v+d;f=Math.min(f,x-n),m=Math.max(m,x+n),p=Math.min(p,T-o),g=Math.max(g,T+o)}this.minX=f,this.minY=p,this.maxX=m,this.maxY=g}addBounds(t){const e=this.minX,i=this.minY,s=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<i?t.minY:i,this.maxX=t.maxX>s?t.maxX:s,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const i=t.minX>e.minX?t.minX:e.minX,s=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const i=t.minX>e.x?t.minX:e.x,s=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(i<=n&&s<=o){const a=this.minX,l=this.minY,h=this.maxX,c=this.maxY;this.minX=i<a?i:a,this.minY=s<l?s:l,this.maxX=n>h?n:h,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,i,s,n,o){t-=n,e-=o,i+=n,s+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>i?this.maxX:i,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>s?this.maxY:s}}class Ct extends Ki{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new Ba,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new Sn,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}static mixin(t){const e=Object.keys(t);for(let i=0;i<e.length;++i){const s=e[i];Object.defineProperty(Ct.prototype,s,Object.getOwnPropertyDescriptor(t,s))}}get destroyed(){return this._destroyed}_recursivePostUpdateTransform(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(this._tempDisplayObjectParent.transform)}updateTransform(){this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha}getBounds(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=this._tempDisplayObjectParent,this.updateTransform(),this.parent=null)),this._bounds.updateID!==this._boundsID&&(this.calculateBounds(),this._bounds.updateID=this._boundsID),e||(this._boundsRect||(this._boundsRect=new it),e=this._boundsRect),this._bounds.getRectangle(e)}getLocalBounds(t){t||(this._localBoundsRect||(this._localBoundsRect=new it),t=this._localBoundsRect),this._localBounds||(this._localBounds=new Sn);const e=this.transform,i=this.parent;this.parent=null,this._tempDisplayObjectParent.worldAlpha=(i==null?void 0:i.worldAlpha)??1,this.transform=this._tempDisplayObjectParent.transform;const s=this._bounds,n=this._boundsID;this._bounds=this._localBounds;const o=this.getBounds(!1,t);return this.parent=i,this.transform=e,this._bounds=s,this._bounds.updateID+=this._boundsID-n,o}toGlobal(t,e,i=!1){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)}toLocal(t,e,i,s){return e&&(t=e.toGlobal(t,i,s)),s||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,i)}setParent(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t}removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)}setTransform(t=0,e=0,i=1,s=1,n=0,o=0,a=0,l=0,h=0){return this.position.x=t,this.position.y=e,this.scale.x=i||1,this.scale.y=s||1,this.rotation=n,this.skew.x=o,this.skew.y=a,this.pivot.x=l,this.pivot.y=h,this}destroy(t){this.removeFromParent(),this._destroyed=!0,this.transform=null,this.parent=null,this._bounds=null,this.mask=null,this.cullArea=null,this.filters=null,this.filterArea=null,this.hitArea=null,this.eventMode="auto",this.interactiveChildren=!1,this.emit("destroyed"),this.removeAllListeners()}get _tempDisplayObjectParent(){return this.tempDisplayObjectParent===null&&(this.tempDisplayObjectParent=new b1),this.tempDisplayObjectParent}enableTempParent(){const t=this.parent;return this.parent=this._tempDisplayObjectParent,t}disableTempParent(t){this.parent=t}get x(){return this.position.x}set x(t){this.transform.position.x=t}get y(){return this.position.y}set y(t){this.transform.position.y=t}get worldTransform(){return this.transform.worldTransform}get localTransform(){return this.transform.localTransform}get position(){return this.transform.position}set position(t){this.transform.position.copyFrom(t)}get scale(){return this.transform.scale}set scale(t){this.transform.scale.copyFrom(t)}get pivot(){return this.transform.pivot}set pivot(t){this.transform.pivot.copyFrom(t)}get skew(){return this.transform.skew}set skew(t){this.transform.skew.copyFrom(t)}get rotation(){return this.transform.rotation}set rotation(t){this.transform.rotation=t}get angle(){return this.transform.rotation*pv}set angle(t){this.transform.rotation=t*mv}get zIndex(){return this._zIndex}set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.parent&&(this.parent.sortDirty=!0))}get worldVisible(){let t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}get mask(){return this._mask}set mask(t){if(this._mask!==t){if(this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount--,e._maskRefCount===0&&(e.renderable=!0,e.isMask=!1))}if(this._mask=t,this._mask){const e=this._mask.isMaskData?this._mask.maskObject:this._mask;e&&(e._maskRefCount===0&&(e.renderable=!1,e.isMask=!0),e._maskRefCount++)}}}}class b1 extends Ct{constructor(){super(...arguments),this.sortDirty=null}}Ct.prototype.displayObjectUpdateTransform=Ct.prototype.updateTransform;const w1=new wt;function E1(r,t){return r.zIndex===t.zIndex?r._lastSortedIndex-t._lastSortedIndex:r.zIndex-t.zIndex}const fd=class Sl extends Ct{constructor(){super(),this.children=[],this.sortableChildren=Sl.defaultSortableChildren,this.sortDirty=!1}onChildrenChange(t){}addChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.addChild(t[e]);else{const e=t[0];e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.push(e),this._boundsID++,this.onChildrenChange(this.children.length-1),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this)}return t[0]}addChildAt(t,e){if(e<0||e>this.children.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${this.children.length}`);return t.parent&&t.parent.removeChild(t),t.parent=this,this.sortDirty=!0,t.transform._parentID=-1,this.children.splice(e,0,t),this._boundsID++,this.onChildrenChange(e),t.emit("added",this),this.emit("childAdded",t,this,e),t}swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t,this.onChildrenChange(i<s?i:s)}getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return e}setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);const i=this.getChildIndex(t);Ti(this.children,i,1),this.children.splice(e,0,t),this.onChildrenChange(e)}getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]}removeChild(...t){if(t.length>1)for(let e=0;e<t.length;e++)this.removeChild(t[e]);else{const e=t[0],i=this.children.indexOf(e);if(i===-1)return null;e.parent=null,e.transform._parentID=-1,Ti(this.children,i,1),this._boundsID++,this.onChildrenChange(i),e.emit("removed",this),this.emit("childRemoved",e,this,i)}return t[0]}removeChildAt(t){const e=this.getChildAt(t);return e.parent=null,e.transform._parentID=-1,Ti(this.children,t,1),this._boundsID++,this.onChildrenChange(t),e.emit("removed",this),this.emit("childRemoved",e,this,t),e}removeChildren(t=0,e=this.children.length){const i=t,s=e,n=s-i;let o;if(n>0&&n<=s){o=this.children.splice(i,n);for(let a=0;a<o.length;++a)o[a].parent=null,o[a].transform&&(o[a].transform._parentID=-1);this._boundsID++,this.onChildrenChange(t);for(let a=0;a<o.length;++a)o[a].emit("removed",this),this.emit("childRemoved",o[a],this,a);return o}else if(n===0&&this.children.length===0)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}sortChildren(){let t=!1;for(let e=0,i=this.children.length;e<i;++e){const s=this.children[e];s._lastSortedIndex=e,!t&&s.zIndex!==0&&(t=!0)}t&&this.children.length>1&&this.children.sort(E1),this.sortDirty=!1}updateTransform(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(let t=0,e=this.children.length;t<e;++t){const i=this.children[t];i.visible&&i.updateTransform()}}calculateBounds(){this._bounds.clear(),this._calculateBounds();for(let t=0;t<this.children.length;t++){const e=this.children[t];if(!(!e.visible||!e.renderable))if(e.calculateBounds(),e._mask){const i=e._mask.isMaskData?e._mask.maskObject:e._mask;i?(i.calculateBounds(),this._bounds.addBoundsMask(e._bounds,i._bounds)):this._bounds.addBounds(e._bounds)}else e.filterArea?this._bounds.addBoundsArea(e._bounds,e.filterArea):this._bounds.addBounds(e._bounds)}this._bounds.updateID=this._boundsID}getLocalBounds(t,e=!1){const i=super.getLocalBounds(t);if(!e)for(let s=0,n=this.children.length;s<n;++s){const o=this.children[s];o.visible&&o.updateTransform()}return i}_calculateBounds(){}_renderWithCulling(t){const e=t.renderTexture.sourceFrame;if(!(e.width>0&&e.height>0))return;let i,s;this.cullArea?(i=this.cullArea,s=this.worldTransform):this._render!==Sl.prototype._render&&(i=this.getBounds(!0));const n=t.projection.transform;if(n&&(s?(s=w1.copyFrom(s),s.prepend(n)):s=n),i&&e.intersects(i,s))this._render(t);else if(this.cullArea)return;for(let o=0,a=this.children.length;o<a;++o){const l=this.children[o],h=l.cullable;l.cullable=h||!this.cullArea,l.render(t),l.cullable=h}}render(t){var e;if(!(!this.visible||this.worldAlpha<=0||!this.renderable))if(this._mask||(e=this.filters)!=null&&e.length)this.renderAdvanced(t);else if(this.cullable)this._renderWithCulling(t);else{this._render(t);for(let i=0,s=this.children.length;i<s;++i)this.children[i].render(t)}}renderAdvanced(t){var n,o,a;const e=this.filters,i=this._mask;if(e){this._enabledFilters||(this._enabledFilters=[]),this._enabledFilters.length=0;for(let l=0;l<e.length;l++)e[l].enabled&&this._enabledFilters.push(e[l])}const s=e&&((n=this._enabledFilters)==null?void 0:n.length)||i&&(!i.isMaskData||i.enabled&&(i.autoDetect||i.type!==Ft.NONE));if(s&&t.batch.flush(),e&&((o=this._enabledFilters)!=null&&o.length)&&t.filter.push(this,this._enabledFilters),i&&t.mask.push(this,this._mask),this.cullable)this._renderWithCulling(t);else{this._render(t);for(let l=0,h=this.children.length;l<h;++l)this.children[l].render(t)}s&&t.batch.flush(),i&&t.mask.pop(this),e&&((a=this._enabledFilters)!=null&&a.length)&&t.filter.pop()}_render(t){}destroy(t){super.destroy(),this.sortDirty=!1;const e=typeof t=="boolean"?t:t==null?void 0:t.children,i=this.removeChildren(0,this.children.length);if(e)for(let s=0;s<i.length;++s)i[s].destroy(t)}get width(){return this.scale.x*this.getLocalBounds().width}set width(t){const e=this.getLocalBounds().width;e!==0?this.scale.x=t/e:this.scale.x=1,this._width=t}get height(){return this.scale.y*this.getLocalBounds().height}set height(t){const e=this.getLocalBounds().height;e!==0?this.scale.y=t/e:this.scale.y=1,this._height=t}};fd.defaultSortableChildren=!1;let xe=fd;xe.prototype.containerUpdateTransform=xe.prototype.updateTransform,Object.defineProperties(z,{SORTABLE_CHILDREN:{get(){return xe.defaultSortableChildren},set(r){at("7.1.0","settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"),xe.defaultSortableChildren=r}}});const fs=new dt,T1=new Uint16Array([0,1,2,0,2,3]);class Ci extends xe{constructor(t){super(),this._anchor=new or(this._onAnchorUpdate,this,t?t.defaultAnchor.x:0,t?t.defaultAnchor.y:0),this._texture=null,this._width=0,this._height=0,this._tintColor=new vt(16777215),this._tintRGB=null,this.tint=16777215,this.blendMode=Z.NORMAL,this._cachedTint=16777215,this.uvs=null,this.texture=t||Y.EMPTY,this.vertexData=new Float32Array(8),this.vertexTrimmedData=null,this._transformID=-1,this._textureID=-1,this._transformTrimmedID=-1,this._textureTrimmedID=-1,this.indices=T1,this.pluginName="batch",this.isSprite=!0,this._roundPixels=z.ROUND_PIXELS}_onTextureUpdate(){this._textureID=-1,this._textureTrimmedID=-1,this._cachedTint=16777215,this._width&&(this.scale.x=gr(this.scale.x)*this._width/this._texture.orig.width),this._height&&(this.scale.y=gr(this.scale.y)*this._height/this._texture.orig.height)}_onAnchorUpdate(){this._transformID=-1,this._transformTrimmedID=-1}calculateVertices(){const t=this._texture;if(this._transformID===this.transform._worldID&&this._textureID===t._updateID)return;this._textureID!==t._updateID&&(this.uvs=this._texture._uvs.uvsFloat32),this._transformID=this.transform._worldID,this._textureID=t._updateID;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this.vertexData,c=t.trim,u=t.orig,d=this._anchor;let f=0,p=0,m=0,g=0;if(c?(p=c.x-d._x*u.width,f=p+c.width,g=c.y-d._y*u.height,m=g+c.height):(p=-d._x*u.width,f=p+u.width,g=-d._y*u.height,m=g+u.height),h[0]=i*p+n*g+a,h[1]=o*g+s*p+l,h[2]=i*f+n*g+a,h[3]=o*g+s*f+l,h[4]=i*f+n*m+a,h[5]=o*m+s*f+l,h[6]=i*p+n*m+a,h[7]=o*m+s*p+l,this._roundPixels){const y=z.RESOLUTION;for(let v=0;v<h.length;++v)h[v]=Math.round(h[v]*y)/y}}calculateTrimmedVertices(){if(!this.vertexTrimmedData)this.vertexTrimmedData=new Float32Array(8);else if(this._transformTrimmedID===this.transform._worldID&&this._textureTrimmedID===this._texture._updateID)return;this._transformTrimmedID=this.transform._worldID,this._textureTrimmedID=this._texture._updateID;const t=this._texture,e=this.vertexTrimmedData,i=t.orig,s=this._anchor,n=this.transform.worldTransform,o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty,d=-s._x*i.width,f=d+i.width,p=-s._y*i.height,m=p+i.height;if(e[0]=o*d+l*p+c,e[1]=h*p+a*d+u,e[2]=o*f+l*p+c,e[3]=h*p+a*f+u,e[4]=o*f+l*m+c,e[5]=h*m+a*f+u,e[6]=o*d+l*m+c,e[7]=h*m+a*d+u,this._roundPixels){const g=z.RESOLUTION;for(let y=0;y<e.length;++y)e[y]=Math.round(e[y]*g)/g}}_render(t){this.calculateVertices(),t.batch.setObjectRenderer(t.plugins[this.pluginName]),t.plugins[this.pluginName].render(this)}_calculateBounds(){const t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))}getLocalBounds(t){return this.children.length===0?(this._localBounds||(this._localBounds=new Sn),this._localBounds.minX=this._texture.orig.width*-this._anchor._x,this._localBounds.minY=this._texture.orig.height*-this._anchor._y,this._localBounds.maxX=this._texture.orig.width*(1-this._anchor._x),this._localBounds.maxY=this._texture.orig.height*(1-this._anchor._y),t||(this._localBoundsRect||(this._localBoundsRect=new it),t=this._localBoundsRect),this._localBounds.getRectangle(t)):super.getLocalBounds.call(this,t)}containsPoint(t){this.worldTransform.applyInverse(t,fs);const e=this._texture.orig.width,i=this._texture.orig.height,s=-e*this.anchor.x;let n=0;return fs.x>=s&&fs.x<s+e&&(n=-i*this.anchor.y,fs.y>=n&&fs.y<n+i)}destroy(t){if(super.destroy(t),this._texture.off("update",this._onTextureUpdate,this),this._anchor=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.baseTexture;this._texture.destroy(!!e)}this._texture=null}static from(t,e){const i=t instanceof Y?t:Y.from(t,e);return new Ci(i)}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1,this._transformTrimmedID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){const e=gr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){const e=gr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get anchor(){return this._anchor}set anchor(t){this._anchor.copyFrom(t)}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber()}get tintValue(){return this._tintColor.toNumber()}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture&&this._texture.off("update",this._onTextureUpdate,this),this._texture=t||Y.EMPTY,this._cachedTint=16777215,this._textureID=-1,this._textureTrimmedID=-1,t&&(t.baseTexture.valid?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}const pd=new wt;Ct.prototype._cacheAsBitmap=!1,Ct.prototype._cacheData=null,Ct.prototype._cacheAsBitmapResolution=null,Ct.prototype._cacheAsBitmapMultisample=null;class A1{constructor(){this.textureCacheId=null,this.originalRender=null,this.originalRenderCanvas=null,this.originalCalculateBounds=null,this.originalGetLocalBounds=null,this.originalUpdateTransform=null,this.originalDestroy=null,this.originalMask=null,this.originalFilterArea=null,this.originalContainsPoint=null,this.sprite=null}}Object.defineProperties(Ct.prototype,{cacheAsBitmapResolution:{get(){return this._cacheAsBitmapResolution},set(r){r!==this._cacheAsBitmapResolution&&(this._cacheAsBitmapResolution=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmapMultisample:{get(){return this._cacheAsBitmapMultisample},set(r){r!==this._cacheAsBitmapMultisample&&(this._cacheAsBitmapMultisample=r,this.cacheAsBitmap&&(this.cacheAsBitmap=!1,this.cacheAsBitmap=!0))}},cacheAsBitmap:{get(){return this._cacheAsBitmap},set(r){if(this._cacheAsBitmap===r)return;this._cacheAsBitmap=r;let t;r?(this._cacheData||(this._cacheData=new A1),t=this._cacheData,t.originalRender=this.render,t.originalRenderCanvas=this.renderCanvas,t.originalUpdateTransform=this.updateTransform,t.originalCalculateBounds=this.calculateBounds,t.originalGetLocalBounds=this.getLocalBounds,t.originalDestroy=this.destroy,t.originalContainsPoint=this.containsPoint,t.originalMask=this._mask,t.originalFilterArea=this.filterArea,this.render=this._renderCached,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(t=this._cacheData,t.sprite&&this._destroyCachedDisplayObject(),this.render=t.originalRender,this.renderCanvas=t.originalRenderCanvas,this.calculateBounds=t.originalCalculateBounds,this.getLocalBounds=t.originalGetLocalBounds,this.destroy=t.originalDestroy,this.updateTransform=t.originalUpdateTransform,this.containsPoint=t.originalContainsPoint,this._mask=t.originalMask,this.filterArea=t.originalFilterArea)}}}),Ct.prototype._renderCached=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(r),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._render(r))},Ct.prototype._initCachedDisplayObject=function(r){var d,f;if((d=this._cacheData)!=null&&d.sprite)return;const t=this.alpha;this.alpha=1,r.batch.flush();const e=this.getLocalBounds(new it,!0);if((f=this.filters)!=null&&f.length){const p=this.filters[0].padding;e.pad(p)}const i=this.cacheAsBitmapResolution||r.resolution;e.ceil(i),e.width=Math.max(e.width,1/i),e.height=Math.max(e.height,1/i);const s=r.renderTexture.current,n=r.renderTexture.sourceFrame.clone(),o=r.renderTexture.destinationFrame.clone(),a=r.projection.transform,l=Xr.create({width:e.width,height:e.height,resolution:i,multisample:this.cacheAsBitmapMultisample??r.multisample}),h=`cacheAsBitmap_${Lr()}`;this._cacheData.textureCacheId=h,et.addToCache(l.baseTexture,h),Y.addToCache(l,h);const c=this.transform.localTransform.copyTo(pd).invert().translate(-e.x,-e.y);this.render=this._cacheData.originalRender,r.render(this,{renderTexture:l,clear:!0,transform:c,skipUpdateTransform:!1}),r.framebuffer.blit(),r.projection.transform=a,r.renderTexture.bind(s,n,o),this.render=this._renderCached,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=t;const u=new Ci(l);u.transform.worldTransform=this.transform.worldTransform,u.anchor.x=-(e.x/e.width),u.anchor.y=-(e.y/e.height),u.alpha=t,u._bounds=this._bounds,this._cacheData.sprite=u,this.transform._parentID=-1,this.parent?this.updateTransform():(this.enableTempParent(),this.updateTransform(),this.disableTempParent(null)),this.containsPoint=u.containsPoint.bind(u)},Ct.prototype._renderCachedCanvas=function(r){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(r),this._cacheData.sprite.worldAlpha=this.worldAlpha,this._cacheData.sprite._renderCanvas(r))},Ct.prototype._initCachedDisplayObjectCanvas=function(r){var c;if((c=this._cacheData)!=null&&c.sprite)return;const t=this.getLocalBounds(new it,!0),e=this.alpha;this.alpha=1;const i=r.canvasContext.activeContext,s=r._projTransform,n=this.cacheAsBitmapResolution||r.resolution;t.ceil(n),t.width=Math.max(t.width,1/n),t.height=Math.max(t.height,1/n);const o=Xr.create({width:t.width,height:t.height,resolution:n}),a=`cacheAsBitmap_${Lr()}`;this._cacheData.textureCacheId=a,et.addToCache(o.baseTexture,a),Y.addToCache(o,a);const l=pd;this.transform.localTransform.copyTo(l),l.invert(),l.tx-=t.x,l.ty-=t.y,this.renderCanvas=this._cacheData.originalRenderCanvas,r.render(this,{renderTexture:o,clear:!0,transform:l,skipUpdateTransform:!1}),r.canvasContext.activeContext=i,r._projTransform=s,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.calculateBounds=this._calculateCachedBounds,this.getLocalBounds=this._getCachedLocalBounds,this._mask=null,this.filterArea=null,this.alpha=e;const h=new Ci(o);h.transform.worldTransform=this.transform.worldTransform,h.anchor.x=-(t.x/t.width),h.anchor.y=-(t.y/t.height),h.alpha=e,h._bounds=this._bounds,this._cacheData.sprite=h,this.transform._parentID=-1,this.parent?this.updateTransform():(this.parent=r._tempDisplayObjectParent,this.updateTransform(),this.parent=null),this.containsPoint=h.containsPoint.bind(h)},Ct.prototype._calculateCachedBounds=function(){this._bounds.clear(),this._cacheData.sprite.transform._worldID=this.transform._worldID,this._cacheData.sprite._calculateBounds(),this._bounds.updateID=this._boundsID},Ct.prototype._getCachedLocalBounds=function(){return this._cacheData.sprite.getLocalBounds(null)},Ct.prototype._destroyCachedDisplayObject=function(){this._cacheData.sprite._texture.destroy(!0),this._cacheData.sprite=null,et.removeFromCache(this._cacheData.textureCacheId),Y.removeFromCache(this._cacheData.textureCacheId),this._cacheData.textureCacheId=null},Ct.prototype._cacheAsBitmapDestroy=function(r){this.cacheAsBitmap=!1,this.destroy(r)},Ct.prototype.name=null,xe.prototype.getChildByName=function(r,t){for(let e=0,i=this.children.length;e<i;e++)if(this.children[e].name===r)return this.children[e];if(t)for(let e=0,i=this.children.length;e<i;e++){const s=this.children[e];if(!s.getChildByName)continue;const n=s.getChildByName(r,!0);if(n)return n}return null},Ct.prototype.getGlobalPosition=function(r=new dt,t=!1){return this.parent?this.parent.toGlobal(this.position,r,t):(r.x=this.position.x,r.y=this.position.y),r};var S1=`varying vec2 vTextureCoord;
|
|
527
527
|
|
|
528
528
|
uniform sampler2D uSampler;
|
|
529
529
|
uniform float uAlpha;
|
|
@@ -532,8 +532,8 @@ void main(void)
|
|
|
532
532
|
{
|
|
533
533
|
gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
|
|
534
534
|
}
|
|
535
|
-
`;class
|
|
536
|
-
`);function R1(r){const t=
|
|
535
|
+
`;class I1 extends ee{constructor(t=1){super(m1,S1,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const C1={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},P1=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
|
|
536
|
+
`);function R1(r){const t=C1[r],e=t.length;let i=P1,s="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<r;a++){let l=n.replace("%index%",a.toString());o=a,a>=e&&(o=r-a-1),l=l.replace("%value%",t[o].toString()),s+=l,s+=`
|
|
537
537
|
`}return i=i.replace("%blur%",s),i=i.replace("%size%",r.toString()),i}const M1=`
|
|
538
538
|
attribute vec2 aVertexPosition;
|
|
539
539
|
|
|
@@ -863,8 +863,8 @@ void main()
|
|
|
863
863
|
|
|
864
864
|
gl_FragColor = color;
|
|
865
865
|
}
|
|
866
|
-
`;class H1 extends ee{constructor(t=.5,e=Math.random()){super(od,$1,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const md={AlphaFilter:C1,BlurFilter:D1,BlurFilterPass:ja,ColorMatrixFilter:Ya,DisplacementFilter:N1,FXAAFilter:G1,NoiseFilter:H1};Object.entries(md).forEach(([r,t])=>{Object.defineProperty(md,r,{get(){return at("7.1.0",`filters.${r} has moved to ${r}`),t}})});class X1{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(ae.system.add(this.tickerUpdate,this,Wr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(ae.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const vr=new X1;class fs{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=fs.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new dt,this.page=new dt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class Cn extends fs{constructor(){super(...arguments),this.client=new dt,this.movement=new dt,this.offset=new dt,this.global=new dt,this.screen=new dt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class be extends Cn{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Ii extends Cn{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Ii.DOM_DELTA_PIXEL=0,Ii.DOM_DELTA_LINE=1,Ii.DOM_DELTA_PAGE=2;const V1=2048,z1=new dt,qa=new dt;class W1{constructor(t){this.dispatch=new qi,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){vr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,z1.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<V1&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const c=l[h],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,i,s,n);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,qa),!t.hitArea.contains(qa.x,qa.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,o;e=e??t.type;const i=`on${e}`;(o=(n=t.currentTarget)[i])==null||o.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,n);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof Ii)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(be);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Ii);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(be);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof be&&e instanceof be&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof Cn&&e instanceof Cn&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const j1=1,Y1={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ka=class Cl{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new W1(null),vr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new be(null),this.rootWheelEvent=new Ii(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Cl.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Cl._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,vr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,vr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;vr.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;vr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=j1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Y1[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};Ka.extension={name:"events",type:[$.RendererSystem,$.CanvasRendererSystem]},Ka.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Za=Ka;Y.add(Za);function gd(r){return r==="dynamic"||r==="static"}const q1={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??gd(Za.defaultEventMode)},set interactive(r){at("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Za.defaultEventMode},set eventMode(r){this._internalInteractive=gd(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof fs))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};It.mixin(q1);const K1={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};It.mixin(K1);const Z1=9,In=100,J1=0,Q1=0,yd=2,_d=1,tx=-1e3,ex=-1e3,rx=2;class vd{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(rr.tablet||rr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${In}px`,e.style.height=`${In}px`,e.style.position="absolute",e.style.top=`${J1}px`,e.style.left=`${Q1}px`,e.style.zIndex=yd.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${_d}px`,t.style.height=`${_d}px`,t.style.position="absolute",t.style.top=`${tx}px`,t.style.left=`${ex}px`,t.style.zIndex=rx.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(rr.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,c=n/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,Ei(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*h}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*h}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${In}px`,e.style.height=`${In}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=yd.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new fs(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Z1&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}vd.extension={name:"accessibility",type:[$.RendererPlugin,$.CanvasRendererPlugin]},Y.add(vd);const xd=class Il{constructor(t){this.stage=new xe,t=Object.assign({forceCanvas:!1},t),this.renderer=nd(t),Il._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=Il._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};xd._plugins=[];let ix=xd;Y.handleByList($.Application,ix._plugins);class bd{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}bd.extension=$.Application,Y.add(bd);const wd={loader:$.LoadParser,resolver:$.ResolveParser,cache:$.CacheParser,detection:$.DetectionParser};Y.handle($.Asset,r=>{const t=r.ref;Object.entries(wd).filter(([e])=>!!t[e]).forEach(([e,i])=>Y.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(wd).filter(e=>!!t[e]).forEach(e=>Y.remove(t[e]))});class sx{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Pi(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function xr(r,t){const e=r.split("?")[0],i=kt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const we=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Ja=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Ed(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Ed(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function nx(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Ed(r,s,0,e,i)}else i.push(r);return i}const Pn=r=>!Array.isArray(r);class ox{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||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=we(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof q){const a=e;i.forEach(l=>{a.baseTexture!==q.EMPTY.baseTexture&&et.addToCache(a.baseTexture,l),q.addToCache(a,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const jr=new ox;class ax{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Pn(t),o=we(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=kt.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),s[h.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(u){throw delete this.promiseCache[c],delete s[h.src],new Error(`[Loader.load] Failed to load ${c}.
|
|
867
|
-
${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=we(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=kt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var Ee=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ee||{});const lx=".json",hx="application/json",cx={extension:{type
|
|
866
|
+
`;class H1 extends ee{constructor(t=.5,e=Math.random()){super(od,$1,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}const md={AlphaFilter:I1,BlurFilter:D1,BlurFilterPass:ja,ColorMatrixFilter:Ya,DisplacementFilter:N1,FXAAFilter:G1,NoiseFilter:H1};Object.entries(md).forEach(([r,t])=>{Object.defineProperty(md,r,{get(){return at("7.1.0",`filters.${r} has moved to ${r}`),t}})});class X1{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this.tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){this.tickerAdded||!this.domElement||(ae.system.add(this.tickerUpdate,this,Wr.INTERACTION),this.tickerAdded=!0)}removeTickerListener(){this.tickerAdded&&(ae.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)}pointerMoved(){this._didMove=!0}update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events.rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY}))}tickerUpdate(t){this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.update())}}const vr=new X1;class ps{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=ps.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new dt,this.page=new dt,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(t,e,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(t,e,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}class In extends ps{constructor(){super(...arguments),this.client=new dt,this.movement=new dt,this.offset=new dt,this.global=new dt,this.screen=new dt}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)}getModifierState(t){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(t)}initMouseEvent(t,e,i,s,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class be extends In{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Pi extends In{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}Pi.DOM_DELTA_PIXEL=0,Pi.DOM_DELTA_LINE=1,Pi.DOM_DELTA_PAGE=2;const V1=2048,z1=new dt,qa=new dt;class W1{constructor(t){this.dispatch=new Ki,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((i,s)=>i.priority-s.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else console.warn(`[EventBoundary]: Event mapping not defined for ${t.type}`)}hitTest(t,e){vr.pauseUpdate=!0;const i=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",s=this[i](this.rootTarget,this.rootTarget.eventMode,z1.set(t,e),this.hitTestFn,this.hitPruneFn);return s&&s[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!(t.propagationStopped||t.propagationImmediatelyStopped)){t.eventPhase=t.BUBBLING_PHASE;for(let s=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let n=i.length-1;n>=0;n--)s.forEach(o=>{t.currentTarget=i[n],this.notifyTarget(t,o)})}propagationPath(t){const e=[t];for(let i=0;i<V1&&t!==this.rootTarget;i++){if(!t.parent)throw new Error("Cannot find propagation path to disconnected target");e.push(t.parent),t=t.parent}return e.reverse(),e}hitTestMoveRecursive(t,e,i,s,n,o=!1){let a=!1;if(this._interactivePrune(t))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const c=t.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(e)?e:d.eventMode,i,s,n,o||n(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=t.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(e),h=t.isInteractive();return l&&h&&this._allInteractiveElements.push(t),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(vr.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children;for(let h=l.length-1;h>=0;h--){const c=l[h],u=this.hitTestRecursive(c,this._isInteractive(e)?e:c.eventMode,i,s,n);if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=t.isInteractive();return(u.length>0||d)&&u.push(t),u}}}const o=this._isInteractive(e),a=t.isInteractive();return o&&s(t,i)?a?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!!(!t||t.isMask||!t.visible||!t.renderable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren||t.isMask)}hitPruneFn(t,e){var i;if(t.hitArea&&(t.worldTransform.applyInverse(e,qa),!t.hitArea.contains(qa.x,qa.y)))return!0;if(t._mask){const s=t._mask.isMaskData?t._mask.maskObject:t._mask;if(s&&!((i=s.containsPoint)!=null&&i.call(s,e)))return!0}return!1}hitTestFn(t,e){return t.eventMode==="passive"?!1:t.hitArea?!0:t.containsPoint?t.containsPoint(e):!1}notifyTarget(t,e){var n,o;e=e??t.type;const i=`on${e}`;(o=(n=t.currentTarget)[i])==null||o.call(n,t);const s=t.eventPhase===t.CAPTURING_PHASE||t.eventPhase===t.AT_TARGET?`${e}capture`:e;this.notifyListeners(t,s),t.eventPhase===t.AT_TARGET&&this.notifyListeners(t,e)}mapPointerDown(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),e.pointerType==="touch")this.dispatchEvent(e,"touchstart");else if(e.pointerType==="mouse"||e.pointerType==="pen"){const s=e.button===2;this.dispatchEvent(e,s?"rightdown":"mousedown")}const i=this.trackingData(t.pointerId);i.pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){var l,h;if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i=e.pointerType==="mouse"||e.pointerType==="pen",s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(((l=s.overTargets)==null?void 0:l.length)>0&&n!==e.target){const c=t.type==="mousemove"?"mouseout":"pointerout",u=this.createPointerEvent(t,c,n);if(this.dispatchEvent(u,"pointerout"),i&&this.dispatchEvent(u,"mouseout"),!e.composedPath().includes(n)){const d=this.createPointerEvent(t,"pointerleave",n);for(d.eventPhase=d.AT_TARGET;d.target&&!e.composedPath().includes(d.target);)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseleave"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(u)}if(n!==e.target){const c=t.type==="mousemove"?"mouseover":"pointerover",u=this.clonePointerEvent(e,c);this.dispatchEvent(u,"pointerover"),i&&this.dispatchEvent(u,"mouseover");let d=n==null?void 0:n.parent;for(;d&&d!==this.rootTarget.parent&&d!==e.target;)d=d.parent;if(!d||d===this.rootTarget.parent){const f=this.clonePointerEvent(e,"pointerenter");for(f.eventPhase=f.AT_TARGET;f.target&&f.target!==n&&f.target!==this.rootTarget.parent;)f.currentTarget=f.target,this.notifyTarget(f),i&&this.notifyTarget(f,"mouseenter"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(u)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&o.push("globalpointermove"),e.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(h=e.target)==null?void 0:h.cursor),o.length>0&&this.all(e,o),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){var o;if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const n=this.clonePointerEvent(i,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(t,"pointerleave",s);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let o=n;if(n&&!i.composedPath().includes(n)){let a=n;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete s.pressTargetsByButton[t.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:a.target,timeStamp:e});const l=s.clicksByButton[t.button];if(l.target===a.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=e,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof be)){console.warn("EventBoundary cannot map a non-pointer event as a pointer event");return}const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch"?this.notifyTarget(s,"touchendoutside"):(s.pointerType==="mouse"||s.pointerType==="pen")&&this.notifyTarget(s,s.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof Pi)){console.warn("EventBoundary cannot map a non-wheel event as a wheel event");return}const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;i<t.length&&t[i].parent===e;i++)e=t[i];return e}createPointerEvent(t,e,i){const s=this.allocateEvent(be);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],typeof e=="string"&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(Pi);return this.copyWheelData(t,e),this.copyMouseData(t,e),this.copyData(t,e),e.nativeEvent=t.nativeEvent,e.originalEvent=t,e.target=this.hitTest(e.global.x,e.global.y),e}clonePointerEvent(t,e){const i=this.allocateEvent(be);return i.nativeEvent=t.nativeEvent,i.originalEvent=t.originalEvent,this.copyPointerData(t,i),this.copyMouseData(t,i),this.copyData(t,i),i.target=t.target,i.path=t.composedPath().slice(),i.type=e??i.type,i}copyWheelData(t,e){e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ}copyPointerData(t,e){t instanceof be&&e instanceof be&&(e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist)}copyMouseData(t,e){t instanceof In&&e instanceof In&&(e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.copyFrom(t.client),e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.copyFrom(t.movement),e.screen.copyFrom(t.screen),e.shiftKey=t.shiftKey,e.global.copyFrom(t.global))}copyData(t,e){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.detail=t.detail,e.view=t.view,e.which=t.which,e.layer.copyFrom(t.layer),e.page.copyFrom(t.page)}trackingData(t){return this.mappingState.trackingData[t]||(this.mappingState.trackingData[t]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[t]}allocateEvent(t){this.eventPool.has(t)||this.eventPool.set(t,[]);const e=this.eventPool.get(t).pop()||new t(this);return e.eventPhase=e.NONE,e.currentTarget=null,e.path=null,e.target=null,e}freeEvent(t){if(t.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const e=t.constructor;this.eventPool.has(e)||this.eventPool.set(e,[]),this.eventPool.get(e).push(t)}notifyListeners(t,e){const i=t.currentTarget._events[e];if(i&&t.currentTarget.isInteractive())if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const j1=1,Y1={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ka=class Il{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new W1(null),vr.init(this),this.autoPreventDefault=!0,this.eventsAdded=!1,this.rootPointerEvent=new be(null),this.rootWheelEvent=new Pi(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...Il.defaultEventFeatures},{set:(e,i,s)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=s),e[i]=s,!0)}),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOverOut=this.onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{view:e,resolution:i}=this.renderer;this.setTargetElement(e),this.resolution=i,Il._defaultEventMode=t.eventMode??"auto",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){this.setTargetElement(null),this.renderer=null}setCursor(t){t=t||"default";let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this.currentCursor===t)return;this.currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this.rootPointerEvent}onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,s=e.length;i<s;i++){const n=e[i],o=this.bootstrapEvent(this.rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,vr.pointerMoved();const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onPointerUp(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let e=t.target;t.composedPath&&t.composedPath().length>0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",s=this.normalizeToPointerData(t);for(let n=0,o=s.length;n<o;n++){const a=this.bootstrapEvent(this.rootPointerEvent,s[n]);a.type+=i,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}onPointerOverOut(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this.normalizeToPointerData(t);for(let i=0,s=e.length;i<s;i++){const n=this.bootstrapEvent(this.rootPointerEvent,e[i]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(t){if(!this.features.wheel)return;const e=this.normalizeWheelEvent(t);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(e)}setTargetElement(t){this.removeEvents(),this.domElement=t,vr.domElement=t,this.addEvents()}addEvents(){if(this.eventsAdded||!this.domElement)return;vr.addTickerListener();const t=this.domElement.style;t&&(globalThis.navigator.msPointerEnabled?(t.msContentZooming="none",t.msTouchAction="none"):this.supportsPointerEvents&&(t.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this.onPointerMove,!0),this.domElement.addEventListener("pointerdown",this.onPointerDown,!0),this.domElement.addEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this.onPointerOverOut,!0),globalThis.addEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this.onPointerMove,!0),this.domElement.addEventListener("mousedown",this.onPointerDown,!0),this.domElement.addEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this.onPointerOverOut,!0),globalThis.addEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this.onPointerDown,!0),this.domElement.addEventListener("touchend",this.onPointerUp,!0),this.domElement.addEventListener("touchmove",this.onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.eventsAdded=!0}removeEvents(){if(!this.eventsAdded||!this.domElement)return;vr.removeTickerListener();const t=this.domElement.style;globalThis.navigator.msPointerEnabled?(t.msContentZooming="",t.msTouchAction=""):this.supportsPointerEvents&&(t.touchAction=""),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this.onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this.onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this.onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this.onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this.onPointerMove,!0),this.domElement.removeEventListener("mousedown",this.onPointerDown,!0),this.domElement.removeEventListener("mouseout",this.onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this.onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this.onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this.onPointerDown,!0),this.domElement.removeEventListener("touchend",this.onPointerUp,!0),this.domElement.removeEventListener("touchmove",this.onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this.eventsAdded=!1}mapPositionToPoint(t,e,i){const s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const n=t.changedTouches[i];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=t.touches.length===1&&t.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=t.type,e.push(n)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&(!this.supportsPointerEvents||!(t instanceof globalThis.PointerEvent))){const i=t;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=j1),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,e.push(i)}else e.push(t);return e}normalizeWheelEvent(t){const e=this.rootWheelEvent;return this.transferMouseData(e,t),e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ,e.deltaMode=t.deltaMode,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.nativeEvent=t,e.type=t.type,e}bootstrapEvent(t,e){return t.originalEvent=null,t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.isTrusted=e.isTrusted,t.type==="pointerleave"&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Y1[t.type]||t.type),t}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.relatedTarget=null,t.shiftKey=e.shiftKey}};Ka.extension={name:"events",type:[X.RendererSystem,X.CanvasRendererSystem]},Ka.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Za=Ka;j.add(Za);function gd(r){return r==="dynamic"||r==="static"}const q1={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,_internalInteractive:void 0,get interactive(){return this._internalInteractive??gd(Za.defaultEventMode)},set interactive(r){at("7.2.0","Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."),this._internalInteractive=r,this.eventMode=r?"static":"auto"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Za.defaultEventMode},set eventMode(r){this._internalInteractive=gd(r),this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof e=="object"?e.signal:void 0,n=typeof e=="object"?e.once===!0:!1,o=typeof t=="function"?void 0:t;r=i?`${r}capture`:r;const a=typeof t=="function"?t:t.handleEvent,l=this;s&&s.addEventListener("abort",()=>{l.off(r,a,o)}),n?l.once(r,a,o):l.on(r,a,o)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,s=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,s)},dispatchEvent(r){if(!(r instanceof ps))throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};Ct.mixin(q1);const K1={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,renderId:-1};Ct.mixin(K1);const Z1=9,Cn=100,J1=0,Q1=0,yd=2,_d=1,tx=-1e3,ex=-1e3,rx=2;class vd{constructor(t){this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this.pool=[],this.renderId=0,this.children=[],this.androidUpdateCount=0,this.androidUpdateFrequency=500,this._hookDiv=null,(rr.tablet||rr.phone)&&this.createTouchHook();const e=document.createElement("div");e.style.width=`${Cn}px`,e.style.height=`${Cn}px`,e.style.position="absolute",e.style.top=`${J1}px`,e.style.left=`${Q1}px`,e.style.zIndex=yd.toString(),this.div=e,this.renderer=t,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}createTouchHook(){const t=document.createElement("button");t.style.width=`${_d}px`,t.style.height=`${_d}px`,t.style.position="absolute",t.style.top=`${tx}px`,t.style.left=`${ex}px`,t.style.zIndex=rx.toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this.activate(),this.destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}activate(){var t;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this.renderer.on("postrender",this.update,this),(t=this.renderer.view.parentNode)==null||t.appendChild(this.div))}deactivate(){var t;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this.renderer.off("postrender",this.update),(t=this.div.parentNode)==null||t.removeChild(this.div))}updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&t.isInteractive()&&(t._accessibleActive||this.addChild(t),t.renderId=this.renderId);const e=t.children;if(e)for(let i=0;i<e.length;i++)this.updateAccessibleObjects(e[i])}update(){const t=performance.now();if(rr.android.device&&t<this.androidUpdateCount||(this.androidUpdateCount=t+this.androidUpdateFrequency,!this.renderer.renderingToScreen))return;this.renderer.lastObjectRendered&&this.updateAccessibleObjects(this.renderer.lastObjectRendered);const{x:e,y:i,width:s,height:n}=this.renderer.view.getBoundingClientRect(),{width:o,height:a,resolution:l}=this.renderer,h=s/o*l,c=n/a*l;let u=this.div;u.style.left=`${e}px`,u.style.top=`${i}px`,u.style.width=`${o}px`,u.style.height=`${a}px`;for(let d=0;d<this.children.length;d++){const f=this.children[d];if(f.renderId!==this.renderId)f._accessibleActive=!1,Ti(this.children,d,1),this.div.removeChild(f._accessibleDiv),this.pool.push(f._accessibleDiv),f._accessibleDiv=null,d--;else{u=f._accessibleDiv;let p=f.hitArea;const m=f.worldTransform;f.hitArea?(u.style.left=`${(m.tx+p.x*m.a)*h}px`,u.style.top=`${(m.ty+p.y*m.d)*c}px`,u.style.width=`${p.width*m.a*h}px`,u.style.height=`${p.height*m.d*c}px`):(p=f.getBounds(),this.capHitArea(p),u.style.left=`${p.x*h}px`,u.style.top=`${p.y*c}px`,u.style.width=`${p.width*h}px`,u.style.height=`${p.height*c}px`,u.title!==f.accessibleTitle&&f.accessibleTitle!==null&&(u.title=f.accessibleTitle),u.getAttribute("aria-label")!==f.accessibleHint&&f.accessibleHint!==null&&u.setAttribute("aria-label",f.accessibleHint)),(f.accessibleTitle!==u.title||f.tabIndex!==u.tabIndex)&&(u.title=f.accessibleTitle,u.tabIndex=f.tabIndex,this.debug&&this.updateDebugHTML(u))}}this.renderId++}updateDebugHTML(t){t.innerHTML=`type: ${t.type}</br> title : ${t.title}</br> tabIndex: ${t.tabIndex}`}capHitArea(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0);const{width:e,height:i}=this.renderer;t.x+t.width>e&&(t.width=e-t.x),t.y+t.height>i&&(t.height=i-t.y)}addChild(t){let e=this.pool.pop();e||(e=document.createElement("button"),e.style.width=`${Cn}px`,e.style.height=`${Cn}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=yd.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`displayObject ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),this.debug&&this.updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex}_dispatchEvent(t,e){const{displayObject:i}=t.target,s=this.renderer.events.rootBoundary,n=Object.assign(new ps(s),{target:i});s.rootTarget=this.renderer.lastObjectRendered,e.forEach(o=>s.dispatchEvent(n,o))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode===Z1&&this.activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this.deactivate()}destroy(){this.destroyTouchHook(),this.div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this.pool=null,this.children=null,this.renderer=null}}vd.extension={name:"accessibility",type:[X.RendererPlugin,X.CanvasRendererPlugin]},j.add(vd);const xd=class Cl{constructor(t){this.stage=new xe,t=Object.assign({forceCanvas:!1},t),this.renderer=nd(t),Cl._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render(this.stage)}get view(){var t;return(t=this.renderer)==null?void 0:t.view}get screen(){var t;return(t=this.renderer)==null?void 0:t.screen}destroy(t,e){const i=Cl._plugins.slice(0);i.reverse(),i.forEach(s=>{s.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};xd._plugins=[];let ix=xd;j.handleByList(X.Application,ix._plugins);class bd{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this.cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this.cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this.cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;e=s,i=n}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}bd.extension=X.Application,j.add(bd);const wd={loader:X.LoadParser,resolver:X.ResolveParser,cache:X.CacheParser,detection:X.DetectionParser};j.handle(X.Asset,r=>{const t=r.ref;Object.entries(wd).filter(([e])=>!!t[e]).forEach(([e,i])=>j.add(Object.assign(t[e],{extension:t[e].extension??i})))},r=>{const t=r.ref;Object.keys(wd).filter(e=>!!t[e]).forEach(e=>j.remove(t[e]))});class sx{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;i<e;i++)t.push(this._assetList.pop());await this._loader.load(t),this._isLoading=!1,this._next()}}get active(){return this._isActive}set active(t){this._isActive!==t&&(this._isActive=t,t&&!this._isLoading&&this._next())}}function Ri(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function xr(r,t){const e=r.split("?")[0],i=kt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const we=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r),Ja=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r};function Ed(r,t,e,i,s){const n=t[e];for(let o=0;o<n.length;o++){const a=n[o];e<t.length-1?Ed(r.replace(i[e],a),t,e+1,i,s):s.push(r.replace(i[e],a))}}function nx(r){const t=/\{(.*?)\}/g,e=r.match(t),i=[];if(e){const s=[];e.forEach(n=>{const o=n.substring(1,n.length-1).split(",");s.push(o)}),Ed(r,s,0,e,i)}else i.push(r);return i}const Pn=r=>!Array.isArray(r);class ox{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||console.warn(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=we(t);let s;for(let a=0;a<this.parsers.length;a++){const l=this.parsers[a];if(l.test(e)){s=l.getCacheableAssets(i,e);break}}s||(s={},i.forEach(a=>{s[a]=e}));const n=Object.keys(s),o={cacheKeys:n,keys:i};if(i.forEach(a=>{this._cacheMap.set(a,o)}),n.forEach(a=>{this._cache.has(a)&&this._cache.get(a)!==e&&console.warn("[Cache] already has key:",a),this._cache.set(a,s[a])}),e instanceof Y){const a=e;i.forEach(l=>{a.baseTexture!==Y.EMPTY.baseTexture&&et.addToCache(a.baseTexture,l),Y.addToCache(a,l)})}}remove(t){if(!this._cacheMap.has(t)){console.warn(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const jr=new ox;class ax{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var o,a;let s=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||console.warn(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.load&&((o=h.test)!=null&&o.call(h,t,e,this))){n=h;break}}if(!n)return console.warn(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),null}s=await n.load(t,e,this),i.parser=n;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];h.parse&&h.parse&&await((a=h.testParse)==null?void 0:a.call(h,s,e,this))&&(s=await h.parse(s,e,this)||s,i.parser=h)}return s})(),i}async load(t,e){this._parsersValidated||this._validateParsers();let i=0;const s={},n=Pn(t),o=we(t,h=>({alias:[h],src:h})),a=o.length,l=o.map(async h=>{const c=kt.toAbsolute(h.src);if(!s[h.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,h)),s[h.src]=await this.promiseCache[c].promise,e&&e(++i/a)}catch(u){throw delete this.promiseCache[c],delete s[h.src],new Error(`[Loader.load] Failed to load ${c}.
|
|
867
|
+
${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=we(t,i=>({alias:[i],src:i})).map(async i=>{var o,a;const s=kt.toAbsolute(i.src),n=this.promiseCache[s];if(n){const l=await n.promise;delete this.promiseCache[s],(a=(o=n.parser)==null?void 0:o.unload)==null||a.call(o,l,i,this)}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(t[e.name]&&console.warn(`[Assets] loadParser name conflict "${e.name}"`),{...t,[e.name]:e}),{})}}var Ee=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(Ee||{});const lx=".json",hx="application/json",cx={extension:{type:X.LoadParser,priority:Ee.Low},name:"loadJson",test(r){return Ri(r,hx)||xr(r,lx)},async load(r){return await(await z.ADAPTER.fetch(r)).json()}};j.add(cx);const ux=".txt",dx="text/plain",fx={name:"loadTxt",extension:{type:X.LoadParser,priority:Ee.Low},test(r){return Ri(r,dx)||xr(r,ux)},async load(r){return await(await z.ADAPTER.fetch(r)).text()}};j.add(fx);const px=["normal","bold","100","200","300","400","500","600","700","800","900"],mx=[".ttf",".otf",".woff",".woff2"],gx=["font/ttf","font/otf","font/woff","font/woff2"],yx=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function _x(r){const t=kt.extname(r),e=kt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1));let i=e.length>0;for(const n of e)if(!n.match(yx)){i=!1;break}let s=e.join(" ");return i||(s=`"${s.replace(/[\\"]/g,"\\$&")}"`),s}const vx=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function xx(r){return vx.test(r)?r:encodeURI(r)}const bx={extension:{type:X.LoadParser,priority:Ee.Low},name:"loadWebFont",test(r){return Ri(r,gx)||xr(r,mx)},async load(r,t){var i,s,n;const e=z.ADAPTER.getFontFaceSet();if(e){const o=[],a=((i=t.data)==null?void 0:i.family)??_x(r),l=((n=(s=t.data)==null?void 0:s.weights)==null?void 0:n.filter(c=>px.includes(c)))??["normal"],h=t.data??{};for(let c=0;c<l.length;c++){const u=l[c],d=new FontFace(a,`url(${xx(r)})`,{...h,weight:u});await d.load(),e.add(d),o.push(d)}return o.length===1?o[0]:o}return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"),null},unload(r){(Array.isArray(r)?r:[r]).forEach(t=>z.ADAPTER.getFontFaceSet().delete(t))}};j.add(bx);const wx=`(function() {
|
|
868
868
|
"use strict";
|
|
869
869
|
const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
|
|
870
870
|
async function checkImageBitmap() {
|
|
@@ -881,7 +881,7 @@ ${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=we
|
|
|
881
881
|
self.postMessage(result);
|
|
882
882
|
});
|
|
883
883
|
})();
|
|
884
|
-
`;let
|
|
884
|
+
`;let Mi=null,Qa=class{constructor(){Mi||(Mi=URL.createObjectURL(new Blob([wx],{type:"application/javascript"}))),this.worker=new Worker(Mi)}};Qa.revokeObjectURL=function(){Mi&&(URL.revokeObjectURL(Mi),Mi=null)};const Ex=`(function() {
|
|
885
885
|
"use strict";
|
|
886
886
|
async function loadImageBitmap(url) {
|
|
887
887
|
const response = await fetch(url);
|
|
@@ -907,8 +907,8 @@ ${u}`)}});return await Promise.all(l),n?s[o[0].src]:s}async unload(t){const e=we
|
|
|
907
907
|
}
|
|
908
908
|
};
|
|
909
909
|
})();
|
|
910
|
-
`;let
|
|
911
|
-
Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},we(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=we(h||c).map(y=>typeof y=="string"?nx(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const g=[];p.forEach(y=>{y.forEach(x=>{let _={};if(typeof x!="object"){_.src=x;for(let v=0;v<this._parsers.length;v++){const w=this._parsers[v];if(w.test(x)){_=w.parse(x);break}}}else u=x.data??u,d=x.format??d,f=x.loadParser??f,_={..._,...x};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this.buildResolvedAsset(_,{aliases:m,data:u,format:d,loadParser:f}),g.push(_)})}),m.forEach(y=>{this._assetMap[y]=g})})}resolveBundle(t){const e=Pn(t);t=we(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Pn(t);t=we(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const c=n.filter(u=>u[l]?u[l]===h:!1);c.length&&(n=c)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}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:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=kt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??t.format??kt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Fx{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ox,this.loader=new ax,this.cache=jr,this._backgroundLoader=new sx(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=Pn(t),s=we(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e==null||e(++a/l)},c=o.map(u=>{const d=s[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{n[u]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return jr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=jr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,jr.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=we(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=we(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{jr.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return Rn.config.preferWorkers}set preferWorkers(t){at("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Mn=new Fx;Y.handleByList($.LoadParser,Mn.loader.parsers).handleByList($.ResolveParser,Mn.resolver.parsers).handleByList($.CacheParser,Mn.cache.parsers).handleByList($.DetectionParser,Mn.detections);const Lx={extension:$.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof q),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};Y.add(Lx);async function Cd(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Nx={extension:{type:$.DetectionParser,priority:1},test:async()=>Cd("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};Y.add(Nx);const Ux={extension:{type:$.DetectionParser,priority:0},test:async()=>Cd("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};Y.add(Ux);const Id=["png","jpg","jpeg"],kx={extension:{type:$.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Id],remove:async r=>r.filter(t=>!Id.includes(t))};Y.add(kx);const Gx="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function el(r){return Gx?!1:document.createElement("video").canPlayType(r)!==""}const $x={extension:{type:$.DetectionParser,priority:0},test:async()=>el("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};Y.add($x);const Hx={extension:{type:$.DetectionParser,priority:0},test:async()=>el("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};Y.add(Hx);const Xx={extension:{type:$.DetectionParser,priority:0},test:async()=>el("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};Y.add(Xx);const Vx={extension:$.ResolveParser,test:Rn.test,parse:r=>{var t;return{resolution:parseFloat(((t=W.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:kt.extname(r).slice(1),src:r}}};Y.add(Vx);var zt=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(zt||{});const Bn={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Xe,Bi;function Pd(){Bi={bptc:Xe.getExtension("EXT_texture_compression_bptc"),astc:Xe.getExtension("WEBGL_compressed_texture_astc"),etc:Xe.getExtension("WEBGL_compressed_texture_etc"),s3tc:Xe.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Xe.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Xe.getExtension("WEBGL_compressed_texture_pvrtc")||Xe.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Xe.getExtension("WEBGL_compressed_texture_etc1"),atc:Xe.getExtension("WEBGL_compressed_texture_atc")}}const zx={extension:{type:$.DetectionParser,priority:2},test:async()=>{const r=W.ADAPTER.createCanvas().getContext("webgl");return r?(Xe=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Bi||Pd();const t=[];for(const e in Bi)Bi[e]&&t.push(e);return[...t,...r]},remove:async r=>(Bi||Pd(),r.filter(t=>!(t in Bi)))};Y.add(zx);class Wx extends on{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new xa(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new xa(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Yr extends Wx{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Yr._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Yr._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=Yr._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Bn[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Bn[e];return l}}const rl=4,Dn=124,jx=32,Rd=20,Yx=542327876,On={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},qx={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},Fn={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Kx=1,Zx=2,Jx=4,Qx=64,tb=512,eb=131072,rb=827611204,ib=861165636,sb=894720068,nb=808540228,ob=4,ab={[rb]:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[ib]:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[sb]:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT},lb={70:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:zt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:zt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:zt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:zt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function hb(r){const t=new Uint32Array(r);if(t[0]!==Yx)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Dn/Uint32Array.BYTES_PER_ELEMENT),i=e[On.HEIGHT],s=e[On.WIDTH],n=e[On.MIPMAP_COUNT],o=new Uint32Array(r,On.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,jx/Uint32Array.BYTES_PER_ELEMENT),a=o[Kx];if(a&Jx){const l=o[qx.FOURCC];if(l!==nb){const x=ab[l],_=rl+Dn,v=new Uint8Array(r,_);return[new Yr(v,{format:x,width:s,height:i,levels:n})]}const h=rl+Dn,c=new Uint32Array(t.buffer,h,Rd/Uint32Array.BYTES_PER_ELEMENT),u=c[Fn.DXGI_FORMAT],d=c[Fn.RESOURCE_DIMENSION],f=c[Fn.MISC_FLAG],p=c[Fn.ARRAY_SIZE],m=lb[u];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===ob)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,y=rl+Dn+Rd;if(p===1)g.push(new Uint8Array(r,y));else{const x=Bn[m];let _=0,v=s,w=i;for(let C=0;C<n;C++){const b=Math.max(1,v+3&-4),T=Math.max(1,w+3&-4),I=b*T*x;_+=I,v=v>>>1,w=w>>>1}let R=y;for(let C=0;C<p;C++)g.push(new Uint8Array(r,R,_)),R+=_}return g.map(x=>new Yr(x,{format:m,width:s,height:i,levels:n}))}throw a&Qx?new Error("DDSParser does not support uncompressed texture data."):a&tb?new Error("DDSParser does not supported YUV uncompressed texture data."):a&eb?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&Zx?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Md=[171,75,84,88,32,49,49,187,13,10,26,10],cb=67305985,Te={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},il=64,Bd={[Z.UNSIGNED_BYTE]:1,[Z.UNSIGNED_SHORT]:2,[Z.INT]:4,[Z.UNSIGNED_INT]:4,[Z.FLOAT]:4,[Z.HALF_FLOAT]:8},ub={[U.RGBA]:4,[U.RGB]:3,[U.RG]:2,[U.RED]:1,[U.LUMINANCE]:1,[U.LUMINANCE_ALPHA]:2,[U.ALPHA]:1},db={[Z.UNSIGNED_SHORT_4_4_4_4]:2,[Z.UNSIGNED_SHORT_5_5_5_1]:2,[Z.UNSIGNED_SHORT_5_6_5]:2};function fb(r,t,e=!1){const i=new DataView(t);if(!pb(r,i))return null;const s=i.getUint32(Te.ENDIANNESS,!0)===cb,n=i.getUint32(Te.GL_TYPE,s),o=i.getUint32(Te.GL_FORMAT,s),a=i.getUint32(Te.GL_INTERNAL_FORMAT,s),l=i.getUint32(Te.PIXEL_WIDTH,s),h=i.getUint32(Te.PIXEL_HEIGHT,s)||1,c=i.getUint32(Te.PIXEL_DEPTH,s)||1,u=i.getUint32(Te.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(Te.NUMBER_OF_FACES,s),f=i.getUint32(Te.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(Te.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const m=4,g=4,y=l+3&-4,x=h+3&-4,_=new Array(u);let v=l*h;n===0&&(v=y*x);let w;if(n!==0?Bd[n]?w=Bd[n]*ub[o]:w=db[n]:w=Bn[a],w===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const R=e?gb(i,p,s):null;let C=v*w,b=l,T=h,I=y,O=x,M=il+p;for(let E=0;E<f;E++){const S=i.getUint32(M,s);let L=M+4;for(let k=0;k<u;k++){let G=_[k];G||(G=_[k]=new Array(f)),G[E]={levelID:E,levelWidth:f>1||n!==0?b:I,levelHeight:f>1||n!==0?T:O,levelBuffer:new Uint8Array(t,L,C)},L+=C}M+=S+4,M=M%4!==0?M+4-M%4:M,b=b>>1||1,T=T>>1||1,I=b+m-1&~(m-1),O=T+g-1&~(g-1),C=I*O*w}return n!==0?{uncompressed:_.map(E=>{let S=E[0].levelBuffer,L=!1;return n===Z.FLOAT?S=new Float32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4):n===Z.UNSIGNED_INT?(L=!0,S=new Uint32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)):n===Z.INT&&(L=!0,S=new Int32Array(E[0].levelBuffer.buffer,E[0].levelBuffer.byteOffset,E[0].levelBuffer.byteLength/4)),{resource:new on(S,{width:E[0].levelWidth,height:E[0].levelHeight}),type:n,format:L?mb(o):o}}),kvData:R}:{compressed:_.map(E=>new Yr(null,{format:a,width:l,height:h,levels:f,levelBuffers:E})),kvData:R}}function pb(r,t){for(let e=0;e<Md.length;e++)if(t.getUint8(e)!==Md[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function mb(r){switch(r){case U.RGBA:return U.RGBA_INTEGER;case U.RGB:return U.RGB_INTEGER;case U.RG:return U.RG_INTEGER;case U.RED:return U.RED_INTEGER;default:return r}}function gb(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(il+s,e),o=il+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),c=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,c),s+=4+n+a}return i}const yb={extension:{type:$.LoadParser,priority:Ee.High},name:"loadDDS",test(r){return xr(r,".dds")},async load(r,t,e){const i=await(await W.ADAPTER.fetch(r)).arrayBuffer(),s=hb(i).map(n=>{const o=new et(n,{mipmap:De.OFF,alphaMode:re.NO_PREMULTIPLIED_ALPHA,resolution:nr(r),...t.data});return ps(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};Y.add(yb);const _b={extension:{type:$.LoadParser,priority:Ee.High},name:"loadKTX",test(r){return xr(r,".ktx")},async load(r,t,e){const i=await(await W.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=fb(r,i),a=s??n,l={mipmap:De.OFF,alphaMode:re.NO_PREMULTIPLIED_ALPHA,resolution:nr(r),...t.data},h=a.map(c=>{a===n&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new et(u,l);return d.ktxKeyValueData=o,ps(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};Y.add(_b);const vb=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],xb={extension:$.ResolveParser,test:r=>{const t=kt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(vb.includes(n))return{resolution:parseFloat(((i=W.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=W.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};Y.add(xb);const Ln=new it,bb=4,Dd=class xs{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&xs._flipY(i,s,n),a&&xs._unpremultiplyAlpha(i);const l=new ev(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&xs._flipY(i,s,n),a&&xs._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof Xr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(Ln.width=e.width,Ln.height=e.height,e=Ln)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===U.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else s=i.resolution,e||(e=Ln,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*s),1),u=Math.max(Math.round(e.height*s),1),d=new Uint8Array(bb*c*u);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),c,u,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:c,height:u,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Dd.extension={name:"extract",type:$.RendererSystem};let wb=Dd;Y.add(wb);const Nn={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Vt.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===Vt.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,s=n=0}else{const p=r.shape,m=p.width/2,g=p.height/2;e=p.x+m,i=p.y+g,o=a=Math.max(0,Math.min(p.radius,Math.min(m,g))),s=m-o,n=g-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let c=0,u=l*4+(s?2:0)+2,d=u,f=h;{const p=s+o,m=n,g=e+p,y=e-p,x=i+m;if(t[c++]=g,t[c++]=x,t[--u]=x,t[--u]=y,n){const _=i-m;t[d++]=y,t[d++]=_,t[--f]=_,t[--f]=g}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),g=s+Math.cos(m)*o,y=n+Math.sin(m)*a,x=e+g,_=e-g,v=i+y,w=i-y;t[c++]=x,t[c++]=v,t[--u]=v,t[--u]=_,t[d++]=_,t[d++]=w,t[--f]=w,t[--f]=x}{const p=s,m=n+a,g=e+p,y=e-p,x=i+m,_=i-m;t[c++]=g,t[c++]=x,t[--f]=_,t[--f]=g,s&&(t[c++]=y,t[c++]=x,t[--f]=_,t[--f]=y)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Vt.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function Od(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const Fd={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){Od(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];Od(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=ly(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},Eb={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},Tb={build(r){Nn.build(r)},triangulate(r,t){Nn.triangulate(r,t)}};var pe=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(pe||{}),br=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(br||{});const Di={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,t=20){if(!this.adaptive||!r||isNaN(r))return t;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class Ld{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=s-e,u=i-t,d=Math.abs(l*u-h*c);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=l*l+h*h,p=c*c+u*u,m=l*c+h*u,g=n*Math.sqrt(f)/d,y=n*Math.sqrt(p)/d,x=g*m/f,_=y*m/p,v=g*u+y*h,w=g*c+y*l,R=h*(y+x),C=l*(y+x),b=u*(g+_),T=c*(g+_),I=Math.atan2(C-w,R-v),O=Math.atan2(T-w,b-v);return{cx:v+t,cy:w+e,radius:n,startAngle:I,endAngle:O,anticlockwise:h*c>u*l}}static arc(t,e,i,s,n,o,a,l,h){const c=a-o,u=Di._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/ln)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),g=u-1,y=g%1/g;for(let x=0;x<=g;++x){const _=x+y*x,v=d+o+f*_,w=Math.cos(v),R=-Math.sin(v);h.push((p*w+m*R)*n+i,(p*-R+m*w)*n+s)}}}class Ab{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class sl{static curveLength(t,e,i,s,n,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,m=0,g=0,y=0,x=0,_=0,v=t,w=e;for(let R=1;R<=10;++R)c=R/10,u=c*c,d=u*c,f=1-c,p=f*f,m=p*f,g=m*t+3*p*c*i+3*f*u*n+d*a,y=m*e+3*p*c*s+3*f*u*o+d*l,x=v-g,_=w-y,v=g,w=y,h+=Math.sqrt(x*x+_*_);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=Di._segmentsCount(sl.curveLength(l,h,t,e,i,s,n,o));let u=0,d=0,f=0,p=0,m=0;a.push(l,h);for(let g=1,y=0;g<=c;++g)y=g/c,u=1-y,d=u*u,f=d*u,p=y*y,m=p*y,a.push(f*l+3*d*y*t+3*u*p*i+m*n,f*h+3*d*y*e+3*u*p*s+m*o)}}function Nd(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,c=r+e*n,u=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,m=h+f,g=c+d,y=u+f;return a.push(p,m,g,y),2}function qr(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let c=Math.atan2(l,h),u=Math.atan2(s-r,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(l*l+h*h),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,y=f/g;if(d+=y,a){o.push(r,t,e,i);for(let x=1,_=d;x<g;x++,_+=y)o.push(r,t,r+Math.sin(_)*m,t+Math.cos(_)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let x=1,_=d;x<g;x++,_+=y)o.push(r+Math.sin(_)*m,t+Math.cos(_)*m,r,t);o.push(s,n,r,t)}return g*2}function Sb(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new dt(i[0],i[1]),a=new dt(i[i.length-2],i[i.length-1]),l=e.type!==Vt.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const G=(o.x+a.x)*.5,H=(a.y+o.y)*.5;i.unshift(G,H),i.push(G,H)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=n.width/2,m=p*p,g=n.miterLimit*n.miterLimit;let y=i[0],x=i[1],_=i[2],v=i[3],w=0,R=0,C=-(x-v),b=y-_,T=0,I=0,O=Math.sqrt(C*C+b*b);C/=O,b/=O,C*=p,b*=p;const M=n.alignment,E=(1-M)*2,S=M*2;l||(n.cap===br.ROUND?d+=qr(y-C*(E-S)*.5,x-b*(E-S)*.5,y-C*E,x-b*E,y+C*S,x+b*S,c,!0)+2:n.cap===br.SQUARE&&(d+=Nd(y,x,C,b,E,S,!0,c))),c.push(y-C*E,x-b*E,y+C*S,x+b*S);for(let G=1;G<u-1;++G){y=i[(G-1)*2],x=i[(G-1)*2+1],_=i[G*2],v=i[G*2+1],w=i[(G+1)*2],R=i[(G+1)*2+1],C=-(x-v),b=y-_,O=Math.sqrt(C*C+b*b),C/=O,b/=O,C*=p,b*=p,T=-(v-R),I=_-w,O=Math.sqrt(T*T+I*I),T/=O,I/=O,T*=p,I*=p;const H=_-y,X=x-v,D=_-w,F=R-v,j=H*D+X*F,nt=X*D-F*H,Q=nt<0;if(Math.abs(nt)<.001*Math.abs(j)){c.push(_-C*E,v-b*E,_+C*S,v+b*S),j>=0&&(n.join===pe.ROUND?d+=qr(_,v,_-C*E,v-b*E,_-T*E,v-I*E,c,!1)+4:d+=2,c.push(_-T*S,v-I*S,_+T*E,v+I*E));continue}const V=(-C+y)*(-b+v)-(-C+_)*(-b+x),_t=(-T+w)*(-I+v)-(-T+_)*(-I+R),Tt=(H*_t-D*V)/nt,N=(F*V-X*_t)/nt,B=(Tt-_)*(Tt-_)+(N-v)*(N-v),xt=_+(Tt-_)*E,ft=v+(N-v)*E,gt=_-(Tt-_)*S,yt=v-(N-v)*S,ze=Math.min(H*H+X*X,D*D+F*F),We=Q?E:S,ys=ze+We*We*m,SE=B<=ys;let Kn=n.join;if(Kn===pe.MITER&&B/m>g&&(Kn=pe.BEVEL),SE)switch(Kn){case pe.MITER:{c.push(xt,ft,gt,yt);break}case pe.BEVEL:{Q?c.push(xt,ft,_+C*S,v+b*S,xt,ft,_+T*S,v+I*S):c.push(_-C*E,v-b*E,gt,yt,_-T*E,v-I*E,gt,yt),d+=2;break}case pe.ROUND:{Q?(c.push(xt,ft,_+C*S,v+b*S),d+=qr(_,v,_+C*S,v+b*S,_+T*S,v+I*S,c,!0)+4,c.push(xt,ft,_+T*S,v+I*S)):(c.push(_-C*E,v-b*E,gt,yt),d+=qr(_,v,_-C*E,v-b*E,_-T*E,v-I*E,c,!1)+4,c.push(_-T*E,v-I*E,gt,yt));break}}else{switch(c.push(_-C*E,v-b*E,_+C*S,v+b*S),Kn){case pe.MITER:{Q?c.push(gt,yt,gt,yt):c.push(xt,ft,xt,ft),d+=2;break}case pe.ROUND:{Q?d+=qr(_,v,_+C*S,v+b*S,_+T*S,v+I*S,c,!0)+2:d+=qr(_,v,_-C*E,v-b*E,_-T*E,v-I*E,c,!1)+2;break}}c.push(_-T*E,v-I*E,_+T*S,v+I*S),d+=2}}y=i[(u-2)*2],x=i[(u-2)*2+1],_=i[(u-1)*2],v=i[(u-1)*2+1],C=-(x-v),b=y-_,O=Math.sqrt(C*C+b*b),C/=O,b/=O,C*=p,b*=p,c.push(_-C*E,v-b*E,_+C*S,v+b*S),l||(n.cap===br.ROUND?d+=qr(_-C*(E-S)*.5,v-b*(E-S)*.5,_-C*E,v-b*E,_+C*S,v+b*S,c,!1)+2:n.cap===br.SQUARE&&(d+=Nd(_,v,C,b,E,S,!1,c)));const L=t.indices,k=Di.epsilon*Di.epsilon;for(let G=f;G<d+f-2;++G)y=c[G*2],x=c[G*2+1],_=c[(G+1)*2],v=c[(G+1)*2+1],w=c[(G+2)*2],R=c[(G+2)*2+1],!(Math.abs(y*(v-R)+_*(R-x)+w*(x-v))<k)&&L.push(G,G+1,G+2)}function Cb(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Vt.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let c=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,h)}function Ud(r,t){r.lineStyle.native?Cb(r,t):Sb(r,t)}class nl{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,c=2*s-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),g=2*u*m,y=2*Math.sqrt(f),x=d/m;return(g*p+m*d*(p-y)+(4*f*u-d*d)*Math.log((2*m+x+p)/(x+y)))/(4*g)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=Di._segmentsCount(nl.curveLength(o,a,t,e,i,s));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,c+(e+(s-e)*d-c)*d)}}}const ol={[Vt.POLY]:Fd,[Vt.CIRC]:Nn,[Vt.ELIP]:Nn,[Vt.RECT]:Eb,[Vt.RREC]:Tb},kd=[],Un=[];class kn{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new kn(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Oi=new dt,Gd=class Mf extends _u{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Sn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Un.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),kd.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new kn(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new kn(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Oi):Oi.copyFrom(t),s.shape.contains(Oi.x,Oi.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(Oi.x,Oi.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;ol[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,g=this.points.length/2;p.wrapMode=dr.REPEAT,d===0?this.processFill(h):this.processLine(h);const y=this.points.length/2-g;y!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,g),i=null),i||(i=kd.pop()||new Ab,i.begin(f,m,g),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,g,y,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<Mf.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++et._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),Un.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Un.pop();s||(s=new Pa,s.texArray=new Fa),s.texArray.count=0,s.start=0,s.size=0,s.type=Be.TRIANGLES;let n=0,o=null,a=0,l=!1,h=Be.TRIANGLES,c=0;this.drawCalls.push(s);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?Be.LINES:Be.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=Un.pop(),s||(s=new Pa,s.texArray=new Fa),this.drawCalls.push(s)),s.start=c,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=dr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,c+=d.size,a=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}et._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Fd.triangulate(t,this):ol[t.type].triangulate(t,this)}processLine(t){Ud(t,this);for(let e=0;e<t.holes.length;e++)Ud(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];ol[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=vt.shared.setValue(e).toLittleEndianNumber(),a=vt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let u=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,c=l.height/n.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[i]+o),p=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)f=Math.min(f,Math.floor(t[m]+o)),p=Math.min(p,Math.floor(t[m+1]+o));u-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+u)*h,t[m+1]=(t[m+1]+d)*c}};Gd.BATCHABLE_SIZE=100;let Ib=Gd;class Gn{constructor(){this.color=16777215,this.alpha=1,this.texture=q.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Gn;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=q.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class al extends Gn{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=br.BUTT,this.join=pe.MITER,this.miterLimit=10}clone(){const t=new al;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=br.BUTT,this.join=pe.MITER,this.miterLimit=10}}const ll={},hl=class eo extends xe{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Gn,this._lineStyle=new al,this._matrix=null,this._holeMode=!1,this.state=$e.for2d(),this._geometry=t||new Ib,this._geometry.refCount++,this._transformID=-1,this._tintColor=new vt(16777215),this.blendMode=J.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new eo(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:q.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:br.BUTT,join:pe.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Nr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Nr,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),nl.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),sl.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=Ld.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(l,h,c,u,d,f)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=ln:o&&s<=n&&(s+=ln),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-l);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return Ld.arc(a,l,t,e,i,s,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:q.WHITE,color:t,alpha:e})}normalizeColor(t){const e=vt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:q.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new it(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new dn(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new cn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new un(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Nr(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Vt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:vt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,vt.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!ll[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new wt,default:ve.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;ll[i]=new He(a,o)}e=ll[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,eo._TEMP_POINT),this._geometry.containsPoint(eo._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=vt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=i*f+n*p+a,c[u++]=o*p+s*f+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};hl.curves=Di,hl._TEMP_POINT=new dt;let ms=hl;class Pb{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const cl=new dt,$d=new Nr,Hd=class Bf extends xe{constructor(t,e,i,s=Be.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||$e.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=W.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Be.TRIANGLES&&e.length<Bf.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,c=s.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=W.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new Pb(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,cl);const e=this.geometry.getBuffer("aVertexPosition").data,i=$d.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,c=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[c],i[5]=e[c+1],$d.contains(cl.x,cl.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Hd.BATCHABLE_SIZE=100;let Xd=Hd;class Rb extends _r{constructor(t,e,i){super();const s=new Mt(t),n=new Mt(e,!0),o=new Mt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,Z.FLOAT).addAttribute("aTextureCoord",n,2,!1,Z.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Mb=`varying vec2 vTextureCoord;
|
|
910
|
+
`;let Bi=null;class Td{constructor(){Bi||(Bi=URL.createObjectURL(new Blob([Ex],{type:"application/javascript"}))),this.worker=new Worker(Bi)}}Td.revokeObjectURL=function(){Bi&&(URL.revokeObjectURL(Bi),Bi=null)};let Ad=0,tl;class Tx{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Qa;e.addEventListener("message",i=>{e.terminate(),Qa.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){tl===void 0&&(tl=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<tl&&(this._createdWorkers++,t=new Td().worker,t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((s,n)=>{this.queue.push({id:t,arguments:e,resolve:s,reject:n})});return this.next(),i}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),i=e.id;this.resolveHash[Ad]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ad++,id:i})}}const Sd=new Tx;function ms(r,t,e){r.resource.internal=!0;const i=new Y(r),s=()=>{delete t.promiseCache[e],jr.has(e)&&jr.remove(e)};return i.baseTexture.once("destroyed",()=>{e in t.promiseCache&&(console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."),s())}),i.once("destroyed",()=>{r.destroyed||(console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),s())}),i}const Ax=[".jpeg",".jpg",".png",".webp",".avif"],Sx=["image/jpeg","image/png","image/webp","image/avif"];async function Ix(r){const t=await z.ADAPTER.fetch(r);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const Rn={name:"loadTextures",extension:{type:X.LoadParser,priority:Ee.High},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return Ri(r,Sx)||xr(r,Ax)},async load(r,t,e){var a;const i=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap;let s;i?this.config.preferWorkers&&await Sd.isImageBitmapSupported()?s=await Sd.loadImageBitmap(r):s=await Ix(r):s=await new Promise((l,h)=>{const c=new Image;c.crossOrigin=this.config.crossOrigin,c.src=r,c.complete?l(c):(c.onload=()=>l(c),c.onerror=u=>h(u))});const n={...t.data};n.resolution??(n.resolution=nr(r)),i&&((a=n.resourceOptions)==null?void 0:a.ownsImageBitmap)===void 0&&(n.resourceOptions={...n.resourceOptions},n.resourceOptions.ownsImageBitmap=!0);const o=new et(s,n);return o.resource.src=r,ms(o,e,r)},unload(r){r.destroy(!0)}};j.add(Rn);const Cx=".svg",Px="image/svg+xml",Rx={extension:{type:X.LoadParser,priority:Ee.High},name:"loadSVG",test(r){return Ri(r,Px)||xr(r,Cx)},async testParse(r){return za.test(r)},async parse(r,t,e){var n;const i=new za(r,(n=t==null?void 0:t.data)==null?void 0:n.resourceOptions);await i.load();const s=new et(i,{resolution:nr(r),...t==null?void 0:t.data});return s.resource.src=t.src,ms(s,e,t.src)},async load(r,t){return(await z.ADAPTER.fetch(r)).text()},unload:Rn.unload};j.add(Rx);const Mx=[".mp4",".m4v",".webm",".ogv"],Bx=["video/mp4","video/webm","video/ogg"],Dx={name:"loadVideo",extension:{type:X.LoadParser,priority:Ee.High},config:{defaultAutoPlay:!0,defaultUpdateFPS:0,defaultLoop:!1,defaultMuted:!1,defaultPlaysinline:!0},test(r){return Ri(r,Bx)||xr(r,Mx)},async load(r,t,e){var o;let i;const s=await(await z.ADAPTER.fetch(r)).blob(),n=URL.createObjectURL(s);try{const a={autoPlay:this.config.defaultAutoPlay,updateFPS:this.config.defaultUpdateFPS,loop:this.config.defaultLoop,muted:this.config.defaultMuted,playsinline:this.config.defaultPlaysinline,...(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions,autoLoad:!0},l=new dd(n,a);await l.load();const h=new et(l,{alphaMode:await k_(),resolution:nr(r),...t==null?void 0:t.data});h.resource.src=r,i=ms(h,e,r),i.baseTexture.once("destroyed",()=>{URL.revokeObjectURL(n)})}catch(a){throw URL.revokeObjectURL(n),a}return i},unload(r){r.destroy(!0)}};j.add(Dx);class Ox{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,name:i,src:s,srcs:n}=t;return we(e||i||s||n,o=>typeof o=="string"?o:Array.isArray(o)?o.map(a=>(a==null?void 0:a.src)??(a==null?void 0:a.srcs)??a):o!=null&&o.src||o!=null&&o.srcs?o.src??o.srcs:o,!0)}addManifest(t){this._manifest&&console.warn("[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=[];Array.isArray(e)?e.forEach(s=>{const n=s.src??s.srcs,o=s.alias??s.name;let a;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);i.push(l),a=[o,l]}else{const l=o.map(h=>this._createBundleAssetId(t,h));i.push(...l),a=[...o,...l]}this.add({...s,alias:a,src:n})}):Object.keys(e).forEach(s=>{const n=[s,this._createBundleAssetId(t,s)];if(typeof e[s]=="string")this.add({alias:n,src:e[s]});else if(Array.isArray(e[s]))this.add({alias:n,src:e[s]});else{const o=e[s],a=o.src??o.srcs;this.add({...o,alias:n,src:Array.isArray(a)?a:[a]})}i.push(...n)}),this._bundles[t]=i}add(t,e,i,s,n){const o=[];typeof t=="string"||Array.isArray(t)&&typeof t[0]=="string"?(at("7.2.0",`Assets.add now uses an object instead of individual parameters.
|
|
911
|
+
Please use Assets.add({ alias, src, data, format, loadParser }) instead.`),o.push({alias:t,src:e,data:i,format:s,loadParser:n})):Array.isArray(t)?o.push(...t):o.push(t);let a;a=l=>{this.hasKey(l)&&console.warn(`[Resolver] already has key: ${l} overwriting`)},we(o).forEach(l=>{const{src:h,srcs:c}=l;let{data:u,format:d,loadParser:f}=l;const p=we(h||c).map(y=>typeof y=="string"?nx(y):Array.isArray(y)?y:[y]),m=this.getAlias(l);Array.isArray(m)?m.forEach(a):a(m);const g=[];p.forEach(y=>{y.forEach(v=>{let _={};if(typeof v!="object"){_.src=v;for(let x=0;x<this._parsers.length;x++){const T=this._parsers[x];if(T.test(v)){_=T.parse(v);break}}}else u=v.data??u,d=v.format??d,f=v.loadParser??f,_={..._,...v};if(!m)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this.buildResolvedAsset(_,{aliases:m,data:u,format:d,loadParser:f}),g.push(_)})}),m.forEach(y=>{this._assetMap[y]=g})})}resolveBundle(t){const e=Pn(t);t=we(t);const i={};return t.forEach(s=>{const n=this._bundles[s];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(s,l)]=h}i[s]=a}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const s in e)i[s]=e[s].src;return i}return e.src}resolve(t){const e=Pn(t);t=we(t);const i={};return t.forEach(s=>{if(!this._resolverHash[s])if(this._assetMap[s]){let n=this._assetMap[s];const o=n[0],a=this._getPreferredOrder(n);a==null||a.priority.forEach(l=>{a.params[l].forEach(h=>{const c=n.filter(u=>u[l]?u[l]===h:!1);c.length&&(n=c)})}),this._resolverHash[s]=n[0]??o}else this._resolverHash[s]=this.buildResolvedAsset({alias:[s],src:s},{});i[s]=this._resolverHash[s]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const i=t[0],s=this._preferredOrder.find(n=>n.params.format.includes(i.format));if(s)return s}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:s,loadParser:n,format:o}=e;return(this._basePath||this._rootPath)&&(t.src=kt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.format=o??t.format??kt.extname(t.src).slice(1),t.srcs=t.src,t.name=t.alias,t}}class Fx{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Ox,this.loader=new ax,this.cache=jr,this._backgroundLoader=new sx(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o;if(this._initialized){console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let a=t.manifest;typeof a=="string"&&(a=await this.load(a)),this.resolver.addManifest(a)}const e=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,s=await this._detectFormats({preferredFormats:(o=t.texturePreference)==null?void 0:o.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t,e,i,s,n){this.resolver.add(t,e,i,s,n)}async load(t,e){this._initialized||await this.init();const i=Pn(t),s=we(t).map(a=>{if(typeof a!="string"){const l=this.resolver.getAlias(a);return l.some(h=>!this.resolver.hasKey(h))&&this.add(a),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(a)||this.add({alias:a,src:a}),a}),n=this.resolver.resolve(s),o=await this._mapLoadToResolve(n,e);return i?o[s[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},o=Object.keys(s);let a=0,l=0;const h=()=>{e==null||e(++a/l)},c=o.map(u=>{const d=s[u];return l+=Object.keys(d).length,this._mapLoadToResolve(d,h).then(f=>{n[u]=f})});return await Promise.all(c),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return jr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=jr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=Object.values(t),s=Object.keys(t);this._backgroundLoader.active=!1;const n=await this.loader.load(i,e);this._backgroundLoader.active=!0;const o={};return i.forEach((a,l)=>{const h=n[a.src],c=[a.src];a.alias&&c.push(...a.alias),o[s[l]]=h,jr.set(c,h)}),o}async unload(t){this._initialized||await this.init();const e=we(t).map(s=>typeof s!="string"?s.src:s),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=we(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(s=>this._unloadFromResolved(e[s]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{jr.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,s)=>e.indexOf(i)===s),e}get detections(){return this._detections}get preferWorkers(){return Rn.config.preferWorkers}set preferWorkers(t){at("7.2.0","Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."),this.setPreferences({preferWorkers:t})}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Mn=new Fx;j.handleByList(X.LoadParser,Mn.loader.parsers).handleByList(X.ResolveParser,Mn.resolver.parsers).handleByList(X.CacheParser,Mn.cache.parsers).handleByList(X.DetectionParser,Mn.detections);const Lx={extension:X.CacheParser,test:r=>Array.isArray(r)&&r.every(t=>t instanceof Y),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((s,n)=>{e[i+(n===0?"":n+1)]=s})}),e}};j.add(Lx);async function Id(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const Nx={extension:{type:X.DetectionParser,priority:1},test:async()=>Id("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")};j.add(Nx);const Ux={extension:{type:X.DetectionParser,priority:0},test:async()=>Id("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};j.add(Ux);const Cd=["png","jpg","jpeg"],kx={extension:{type:X.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Cd],remove:async r=>r.filter(t=>!Cd.includes(t))};j.add(kx);const Gx="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function el(r){return Gx?!1:document.createElement("video").canPlayType(r)!==""}const $x={extension:{type:X.DetectionParser,priority:0},test:async()=>el("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")};j.add($x);const Hx={extension:{type:X.DetectionParser,priority:0},test:async()=>el("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")};j.add(Hx);const Xx={extension:{type:X.DetectionParser,priority:0},test:async()=>el("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")};j.add(Xx);const Vx={extension:X.ResolveParser,test:Rn.test,parse:r=>{var t;return{resolution:parseFloat(((t=z.RETINA_PREFIX.exec(r))==null?void 0:t[1])??"1"),format:kt.extname(r).slice(1),src:r}}};j.add(Vx);var zt=(r=>(r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35987]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(zt||{});const Bn={33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,35840:.5,35842:.5,35841:.25,35843:.25,36196:.5,35986:.5,35987:1,34798:1,37808:1,36492:1,36493:1,36494:1,36495:1};let Xe,Di;function Pd(){Di={bptc:Xe.getExtension("EXT_texture_compression_bptc"),astc:Xe.getExtension("WEBGL_compressed_texture_astc"),etc:Xe.getExtension("WEBGL_compressed_texture_etc"),s3tc:Xe.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:Xe.getExtension("WEBGL_compressed_texture_s3tc_srgb"),pvrtc:Xe.getExtension("WEBGL_compressed_texture_pvrtc")||Xe.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:Xe.getExtension("WEBGL_compressed_texture_etc1"),atc:Xe.getExtension("WEBGL_compressed_texture_atc")}}const zx={extension:{type:X.DetectionParser,priority:2},test:async()=>{const r=z.ADAPTER.createCanvas().getContext("webgl");return r?(Xe=r,!0):(console.warn("WebGL not available for compressed textures."),!1)},add:async r=>{Di||Pd();const t=[];for(const e in Di)Di[e]&&t.push(e);return[...t,...r]},remove:async r=>(Di||Pd(),r.filter(t=>!(t in Di)))};j.add(zx);class Wx extends on{constructor(t,e={width:1,height:1,autoLoad:!0}){let i,s;typeof t=="string"?(i=t,s=new Uint8Array):(i=null,s=t),super(s,e),this.origin=i,this.buffer=s?new xa(s):null,this._load=null,this.loaded=!1,this.origin!==null&&e.autoLoad!==!1&&this.load(),this.origin===null&&this.buffer&&(this._load=Promise.resolve(this),this.loaded=!0,this.onBlobLoaded(this.buffer.rawBinaryData))}onBlobLoaded(t){}load(){return this._load?this._load:(this._load=fetch(this.origin).then(t=>t.blob()).then(t=>t.arrayBuffer()).then(t=>(this.data=new Uint32Array(t),this.buffer=new xa(t),this.loaded=!0,this.onBlobLoaded(t),this.update(),this)),this._load)}}class Yr extends Wx{constructor(t,e){super(t,e),this.format=e.format,this.levels=e.levels||1,this._width=e.width,this._height=e.height,this._extension=Yr._formatToExtension(this.format),(e.levelBuffers||this.buffer)&&(this._levelBuffers=e.levelBuffers||Yr._createLevelBuffers(t instanceof Uint8Array?t:this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height))}upload(t,e,i){const s=t.gl;if(!t.context.extensions[this._extension])throw new Error(`${this._extension} textures are not supported on the current machine`);if(!this._levelBuffers)return!1;s.pixelStorei(s.UNPACK_ALIGNMENT,4);for(let n=0,o=this.levels;n<o;n++){const{levelID:a,levelWidth:l,levelHeight:h,levelBuffer:c}=this._levelBuffers[n];s.compressedTexImage2D(s.TEXTURE_2D,a,this.format,l,h,0,c)}return!0}onBlobLoaded(){this._levelBuffers=Yr._createLevelBuffers(this.buffer.uint8View,this.format,this.levels,4,4,this.width,this.height)}static _formatToExtension(t){if(t>=33776&&t<=33779)return"s3tc";if(t>=35916&&t<=35919)return"s3tc_sRGB";if(t>=37488&&t<=37497)return"etc";if(t>=35840&&t<=35843)return"pvrtc";if(t===36196)return"etc1";if(t===35986||t===35987||t===34798)return"atc";if(t>=36492&&t<=36495)return"bptc";if(t===37808)return"astc";throw new Error(`Invalid (compressed) texture format given: ${t}`)}static _createLevelBuffers(t,e,i,s,n,o,a){const l=new Array(i);let h=t.byteOffset,c=o,u=a,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Bn[e];for(let m=0;m<i;m++)l[m]={levelID:m,levelWidth:i>1?c:d,levelHeight:i>1?u:f,levelBuffer:new Uint8Array(t.buffer,h,p)},h+=p,c=c>>1||1,u=u>>1||1,d=c+s-1&~(s-1),f=u+n-1&~(n-1),p=d*f*Bn[e];return l}}const rl=4,Dn=124,jx=32,Rd=20,Yx=542327876,On={SIZE:1,FLAGS:2,HEIGHT:3,WIDTH:4,MIPMAP_COUNT:7,PIXEL_FORMAT:19},qx={SIZE:0,FLAGS:1,FOURCC:2,RGB_BITCOUNT:3,R_BIT_MASK:4,G_BIT_MASK:5,B_BIT_MASK:6,A_BIT_MASK:7},Fn={DXGI_FORMAT:0,RESOURCE_DIMENSION:1,MISC_FLAG:2,ARRAY_SIZE:3,MISC_FLAGS2:4},Kx=1,Zx=2,Jx=4,Qx=64,tb=512,eb=131072,rb=827611204,ib=861165636,sb=894720068,nb=808540228,ob=4,ab={[rb]:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,[ib]:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,[sb]:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT},lb={70:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,71:zt.COMPRESSED_RGBA_S3TC_DXT1_EXT,73:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,74:zt.COMPRESSED_RGBA_S3TC_DXT3_EXT,76:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,77:zt.COMPRESSED_RGBA_S3TC_DXT5_EXT,72:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,75:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,78:zt.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,96:zt.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,95:zt.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,98:zt.COMPRESSED_RGBA_BPTC_UNORM_EXT,99:zt.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT};function hb(r){const t=new Uint32Array(r);if(t[0]!==Yx)throw new Error("Invalid DDS file magic word");const e=new Uint32Array(r,0,Dn/Uint32Array.BYTES_PER_ELEMENT),i=e[On.HEIGHT],s=e[On.WIDTH],n=e[On.MIPMAP_COUNT],o=new Uint32Array(r,On.PIXEL_FORMAT*Uint32Array.BYTES_PER_ELEMENT,jx/Uint32Array.BYTES_PER_ELEMENT),a=o[Kx];if(a&Jx){const l=o[qx.FOURCC];if(l!==nb){const v=ab[l],_=rl+Dn,x=new Uint8Array(r,_);return[new Yr(x,{format:v,width:s,height:i,levels:n})]}const h=rl+Dn,c=new Uint32Array(t.buffer,h,Rd/Uint32Array.BYTES_PER_ELEMENT),u=c[Fn.DXGI_FORMAT],d=c[Fn.RESOURCE_DIMENSION],f=c[Fn.MISC_FLAG],p=c[Fn.ARRAY_SIZE],m=lb[u];if(m===void 0)throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);if(f===ob)throw new Error("DDSParser does not support cubemap textures");if(d===6)throw new Error("DDSParser does not supported 3D texture data");const g=new Array,y=rl+Dn+Rd;if(p===1)g.push(new Uint8Array(r,y));else{const v=Bn[m];let _=0,x=s,T=i;for(let I=0;I<n;I++){const b=Math.max(1,x+3&-4),E=Math.max(1,T+3&-4),S=b*E*v;_+=S,x=x>>>1,T=T>>>1}let P=y;for(let I=0;I<p;I++)g.push(new Uint8Array(r,P,_)),P+=_}return g.map(v=>new Yr(v,{format:m,width:s,height:i,levels:n}))}throw a&Qx?new Error("DDSParser does not support uncompressed texture data."):a&tb?new Error("DDSParser does not supported YUV uncompressed texture data."):a&eb?new Error("DDSParser does not support single-channel (lumninance) texture data!"):a&Zx?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}const Md=[171,75,84,88,32,49,49,187,13,10,26,10],cb=67305985,Te={FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},il=64,Bd={[K.UNSIGNED_BYTE]:1,[K.UNSIGNED_SHORT]:2,[K.INT]:4,[K.UNSIGNED_INT]:4,[K.FLOAT]:4,[K.HALF_FLOAT]:8},ub={[U.RGBA]:4,[U.RGB]:3,[U.RG]:2,[U.RED]:1,[U.LUMINANCE]:1,[U.LUMINANCE_ALPHA]:2,[U.ALPHA]:1},db={[K.UNSIGNED_SHORT_4_4_4_4]:2,[K.UNSIGNED_SHORT_5_5_5_1]:2,[K.UNSIGNED_SHORT_5_6_5]:2};function fb(r,t,e=!1){const i=new DataView(t);if(!pb(r,i))return null;const s=i.getUint32(Te.ENDIANNESS,!0)===cb,n=i.getUint32(Te.GL_TYPE,s),o=i.getUint32(Te.GL_FORMAT,s),a=i.getUint32(Te.GL_INTERNAL_FORMAT,s),l=i.getUint32(Te.PIXEL_WIDTH,s),h=i.getUint32(Te.PIXEL_HEIGHT,s)||1,c=i.getUint32(Te.PIXEL_DEPTH,s)||1,u=i.getUint32(Te.NUMBER_OF_ARRAY_ELEMENTS,s)||1,d=i.getUint32(Te.NUMBER_OF_FACES,s),f=i.getUint32(Te.NUMBER_OF_MIPMAP_LEVELS,s),p=i.getUint32(Te.BYTES_OF_KEY_VALUE_DATA,s);if(h===0||c!==1)throw new Error("Only 2D textures are supported");if(d!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(u!==1)throw new Error("WebGL does not support array textures");const m=4,g=4,y=l+3&-4,v=h+3&-4,_=new Array(u);let x=l*h;n===0&&(x=y*v);let T;if(n!==0?Bd[n]?T=Bd[n]*ub[o]:T=db[n]:T=Bn[a],T===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");const P=e?gb(i,p,s):null;let I=x*T,b=l,E=h,S=y,D=v,B=il+p;for(let w=0;w<f;w++){const C=i.getUint32(B,s);let F=B+4;for(let k=0;k<u;k++){let G=_[k];G||(G=_[k]=new Array(f)),G[w]={levelID:w,levelWidth:f>1||n!==0?b:S,levelHeight:f>1||n!==0?E:D,levelBuffer:new Uint8Array(t,F,I)},F+=I}B+=C+4,B=B%4!==0?B+4-B%4:B,b=b>>1||1,E=E>>1||1,S=b+m-1&~(m-1),D=E+g-1&~(g-1),I=S*D*T}return n!==0?{uncompressed:_.map(w=>{let C=w[0].levelBuffer,F=!1;return n===K.FLOAT?C=new Float32Array(w[0].levelBuffer.buffer,w[0].levelBuffer.byteOffset,w[0].levelBuffer.byteLength/4):n===K.UNSIGNED_INT?(F=!0,C=new Uint32Array(w[0].levelBuffer.buffer,w[0].levelBuffer.byteOffset,w[0].levelBuffer.byteLength/4)):n===K.INT&&(F=!0,C=new Int32Array(w[0].levelBuffer.buffer,w[0].levelBuffer.byteOffset,w[0].levelBuffer.byteLength/4)),{resource:new on(C,{width:w[0].levelWidth,height:w[0].levelHeight}),type:n,format:F?mb(o):o}}),kvData:P}:{compressed:_.map(w=>new Yr(null,{format:a,width:l,height:h,levels:f,levelBuffers:w})),kvData:P}}function pb(r,t){for(let e=0;e<Md.length;e++)if(t.getUint8(e)!==Md[e])return console.error(`${r} is not a valid *.ktx file!`),!1;return!0}function mb(r){switch(r){case U.RGBA:return U.RGBA_INTEGER;case U.RGB:return U.RGB_INTEGER;case U.RG:return U.RG_INTEGER;case U.RED:return U.RED_INTEGER;default:return r}}function gb(r,t,e){const i=new Map;let s=0;for(;s<t;){const n=r.getUint32(il+s,e),o=il+s+4,a=3-(n+3)%4;if(n===0||n>t-s){console.error("KTXLoader: keyAndValueByteSize out of bounds");break}let l=0;for(;l<n&&r.getUint8(o+l)!==0;l++);if(l===-1){console.error("KTXLoader: Failed to find null byte terminating kvData key");break}const h=new TextDecoder().decode(new Uint8Array(r.buffer,o,l)),c=new DataView(r.buffer,o+l+1,n-l-1);i.set(h,c),s+=4+n+a}return i}const yb={extension:{type:X.LoadParser,priority:Ee.High},name:"loadDDS",test(r){return xr(r,".dds")},async load(r,t,e){const i=await(await z.ADAPTER.fetch(r)).arrayBuffer(),s=hb(i).map(n=>{const o=new et(n,{mipmap:De.OFF,alphaMode:re.NO_PREMULTIPLIED_ALPHA,resolution:nr(r),...t.data});return ms(o,e,r)});return s.length===1?s[0]:s},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};j.add(yb);const _b={extension:{type:X.LoadParser,priority:Ee.High},name:"loadKTX",test(r){return xr(r,".ktx")},async load(r,t,e){const i=await(await z.ADAPTER.fetch(r)).arrayBuffer(),{compressed:s,uncompressed:n,kvData:o}=fb(r,i),a=s??n,l={mipmap:De.OFF,alphaMode:re.NO_PREMULTIPLIED_ALPHA,resolution:nr(r),...t.data},h=a.map(c=>{a===n&&Object.assign(l,{type:c.type,format:c.format});const u=c.resource??c,d=new et(u,l);return d.ktxKeyValueData=o,ms(d,e,r)});return h.length===1?h[0]:h},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};j.add(_b);const vb=["s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"],xb={extension:X.ResolveParser,test:r=>{const t=kt.extname(r).slice(1);return["basis","ktx","dds"].includes(t)},parse:r=>{var i,s;const t=r.split("."),e=t.pop();if(["ktx","dds"].includes(e)){const n=t.pop();if(vb.includes(n))return{resolution:parseFloat(((i=z.RETINA_PREFIX.exec(r))==null?void 0:i[1])??"1"),format:n,src:r}}return{resolution:parseFloat(((s=z.RETINA_PREFIX.exec(r))==null?void 0:s[1])??"1"),format:e,src:r}}};j.add(xb);const Ln=new it,bb=4,Dd=class bs{constructor(t){this.renderer=t,this._rendererPremultipliedAlpha=!1}contextChange(){var e;const t=(e=this.renderer)==null?void 0:e.gl.getContextAttributes();this._rendererPremultipliedAlpha=!!(t&&t.alpha&&t.premultipliedAlpha)}async image(t,e,i,s){const n=new Image;return n.src=await this.base64(t,e,i,s),n}async base64(t,e,i,s){const n=this.canvas(t,s);if(n.toBlob!==void 0)return new Promise((o,a)=>{n.toBlob(l=>{if(!l){a(new Error("ICanvas.toBlob failed!"));return}const h=new FileReader;h.onload=()=>o(h.result),h.onerror=a,h.readAsDataURL(l)},e,i)});if(n.toDataURL!==void 0)return n.toDataURL(e,i);if(n.convertToBlob!==void 0){const o=await n.convertToBlob({type:e,quality:i});return new Promise((a,l)=>{const h=new FileReader;h.onload=()=>a(h.result),h.onerror=l,h.readAsDataURL(o)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);o&&bs._flipY(i,s,n),a&&bs._unpremultiplyAlpha(i);const l=new ev(s,n,1),h=new ImageData(new Uint8ClampedArray(i.buffer),s,n);return l.context.putImageData(h,0,0),l.canvas}pixels(t,e){const{pixels:i,width:s,height:n,flipY:o,premultipliedAlpha:a}=this._rawPixels(t,e);return o&&bs._flipY(i,s,n),a&&bs._unpremultiplyAlpha(i),i}_rawPixels(t,e){const i=this.renderer;if(!i)throw new Error("The Extract has already been destroyed");let s,n=!1,o=!1,a,l=!1;t&&(t instanceof Xr?a=t:(a=i.generateTexture(t,{region:e,resolution:i.resolution,multisample:i.multisample}),l=!0,e&&(Ln.width=e.width,Ln.height=e.height,e=Ln)));const h=i.gl;if(a){if(s=a.baseTexture.resolution,e=e??a.frame,n=!1,o=a.baseTexture.alphaMode>0&&a.baseTexture.format===U.RGBA,!l){i.renderTexture.bind(a);const f=a.framebuffer.glFramebuffers[i.CONTEXT_UID];f.blitFramebuffer&&i.framebuffer.bind(f.blitFramebuffer)}}else s=i.resolution,e||(e=Ln,e.width=i.width/s,e.height=i.height/s),n=!0,o=this._rendererPremultipliedAlpha,i.renderTexture.bind();const c=Math.max(Math.round(e.width*s),1),u=Math.max(Math.round(e.height*s),1),d=new Uint8Array(bb*c*u);return h.readPixels(Math.round(e.x*s),Math.round(e.y*s),c,u,h.RGBA,h.UNSIGNED_BYTE,d),l&&(a==null||a.destroy(!0)),{pixels:d,width:c,height:u,flipY:n,premultipliedAlpha:o}}destroy(){this.renderer=null}static _flipY(t,e,i){const s=e<<2,n=i>>1,o=new Uint8Array(s);for(let a=0;a<n;a++){const l=a*s,h=(i-a-1)*s;o.set(t.subarray(l,l+s)),t.copyWithin(l,h,h+s),t.set(o,h)}}static _unpremultiplyAlpha(t){t instanceof Uint8ClampedArray&&(t=new Uint8Array(t.buffer));const e=t.length;for(let i=0;i<e;i+=4){const s=t[i+3];if(s!==0){const n=255.001/s;t[i]=t[i]*n+.5,t[i+1]=t[i+1]*n+.5,t[i+2]=t[i+2]*n+.5}}}};Dd.extension={name:"extract",type:X.RendererSystem};let wb=Dd;j.add(wb);const Nn={build(r){const t=r.points;let e,i,s,n,o,a;if(r.type===Vt.CIRC){const p=r.shape;e=p.x,i=p.y,o=a=p.radius,s=n=0}else if(r.type===Vt.ELIP){const p=r.shape;e=p.x,i=p.y,o=p.width,a=p.height,s=n=0}else{const p=r.shape,m=p.width/2,g=p.height/2;e=p.x+m,i=p.y+g,o=a=Math.max(0,Math.min(p.radius,Math.min(m,g))),s=m-o,n=g-a}if(!(o>=0&&a>=0&&s>=0&&n>=0)){t.length=0;return}const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(s?4:0)+(n?4:0);if(t.length=h,h===0)return;if(l===0){t.length=8,t[0]=t[6]=e+s,t[1]=t[3]=i+n,t[2]=t[4]=e-s,t[5]=t[7]=i-n;return}let c=0,u=l*4+(s?2:0)+2,d=u,f=h;{const p=s+o,m=n,g=e+p,y=e-p,v=i+m;if(t[c++]=g,t[c++]=v,t[--u]=v,t[--u]=y,n){const _=i-m;t[d++]=y,t[d++]=_,t[--f]=_,t[--f]=g}}for(let p=1;p<l;p++){const m=Math.PI/2*(p/l),g=s+Math.cos(m)*o,y=n+Math.sin(m)*a,v=e+g,_=e-g,x=i+y,T=i-y;t[c++]=v,t[c++]=x,t[--u]=x,t[--u]=_,t[d++]=_,t[d++]=T,t[--f]=T,t[--f]=v}{const p=s,m=n+a,g=e+p,y=e-p,v=i+m,_=i-m;t[c++]=g,t[c++]=v,t[--f]=_,t[--f]=g,s&&(t[c++]=y,t[c++]=v,t[--f]=_,t[--f]=y)}},triangulate(r,t){const e=r.points,i=t.points,s=t.indices;if(e.length===0)return;let n=i.length/2;const o=n;let a,l;if(r.type!==Vt.RREC){const c=r.shape;a=c.x,l=c.y}else{const c=r.shape;a=c.x+c.width/2,l=c.y+c.height/2}const h=r.matrix;i.push(r.matrix?h.a*a+h.c*l+h.tx:a,r.matrix?h.b*a+h.d*l+h.ty:l),n++,i.push(e[0],e[1]);for(let c=2;c<e.length;c+=2)i.push(e[c],e[c+1]),s.push(n++,o,n);s.push(o+1,o,n)}};function Od(r,t=!1){const e=r.length;if(e<6)return;let i=0;for(let s=0,n=r[e-2],o=r[e-1];s<e;s+=2){const a=r[s],l=r[s+1];i+=(a-n)*(l+o),n=a,o=l}if(!t&&i>0||t&&i<=0){const s=e/2;for(let n=s+s%2;n<e;n+=2){const o=e-n-2,a=e-n-1,l=n,h=n+1;[r[o],r[l]]=[r[l],r[o]],[r[a],r[h]]=[r[h],r[a]]}}}const Fd={build(r){r.points=r.shape.points.slice()},triangulate(r,t){let e=r.points;const i=r.holes,s=t.points,n=t.indices;if(e.length>=6){Od(e,!1);const o=[];for(let h=0;h<i.length;h++){const c=i[h];Od(c.points,!0),o.push(e.length/2),e=e.concat(c.points)}const a=ly(e,o,2);if(!a)return;const l=s.length/2;for(let h=0;h<a.length;h+=3)n.push(a[h]+l),n.push(a[h+1]+l),n.push(a[h+2]+l);for(let h=0;h<e.length;h++)s.push(e[h])}}},Eb={build(r){const t=r.shape,e=t.x,i=t.y,s=t.width,n=t.height,o=r.points;o.length=0,s>=0&&n>=0&&o.push(e,i,e+s,i,e+s,i+n,e,i+n)},triangulate(r,t){const e=r.points,i=t.points;if(e.length===0)return;const s=i.length/2;i.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),t.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},Tb={build(r){Nn.build(r)},triangulate(r,t){Nn.triangulate(r,t)}};var pe=(r=>(r.MITER="miter",r.BEVEL="bevel",r.ROUND="round",r))(pe||{}),br=(r=>(r.BUTT="butt",r.ROUND="round",r.SQUARE="square",r))(br||{});const Oi={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(r,t=20){if(!this.adaptive||!r||isNaN(r))return t;let e=Math.ceil(r/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}};class Ld{static curveTo(t,e,i,s,n,o){const a=o[o.length-2],l=o[o.length-1]-e,h=a-t,c=s-e,u=i-t,d=Math.abs(l*u-h*c);if(d<1e-8||n===0)return(o[o.length-2]!==t||o[o.length-1]!==e)&&o.push(t,e),null;const f=l*l+h*h,p=c*c+u*u,m=l*c+h*u,g=n*Math.sqrt(f)/d,y=n*Math.sqrt(p)/d,v=g*m/f,_=y*m/p,x=g*u+y*h,T=g*c+y*l,P=h*(y+v),I=l*(y+v),b=u*(g+_),E=c*(g+_),S=Math.atan2(I-T,P-x),D=Math.atan2(E-T,b-x);return{cx:x+t,cy:T+e,radius:n,startAngle:S,endAngle:D,anticlockwise:h*c>u*l}}static arc(t,e,i,s,n,o,a,l,h){const c=a-o,u=Oi._segmentsCount(Math.abs(c)*n,Math.ceil(Math.abs(c)/ln)*40),d=c/(u*2),f=d*2,p=Math.cos(d),m=Math.sin(d),g=u-1,y=g%1/g;for(let v=0;v<=g;++v){const _=v+y*v,x=d+o+f*_,T=Math.cos(x),P=-Math.sin(x);h.push((p*T+m*P)*n+i,(p*-P+m*T)*n+s)}}}class Ab{constructor(){this.reset()}begin(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i}end(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0}}class sl{static curveLength(t,e,i,s,n,o,a,l){let h=0,c=0,u=0,d=0,f=0,p=0,m=0,g=0,y=0,v=0,_=0,x=t,T=e;for(let P=1;P<=10;++P)c=P/10,u=c*c,d=u*c,f=1-c,p=f*f,m=p*f,g=m*t+3*p*c*i+3*f*u*n+d*a,y=m*e+3*p*c*s+3*f*u*o+d*l,v=x-g,_=T-y,x=g,T=y,h+=Math.sqrt(v*v+_*_);return h}static curveTo(t,e,i,s,n,o,a){const l=a[a.length-2],h=a[a.length-1];a.length-=2;const c=Oi._segmentsCount(sl.curveLength(l,h,t,e,i,s,n,o));let u=0,d=0,f=0,p=0,m=0;a.push(l,h);for(let g=1,y=0;g<=c;++g)y=g/c,u=1-y,d=u*u,f=d*u,p=y*y,m=p*y,a.push(f*l+3*d*y*t+3*u*p*i+m*n,f*h+3*d*y*e+3*u*p*s+m*o)}}function Nd(r,t,e,i,s,n,o,a){const l=r-e*s,h=t-i*s,c=r+e*n,u=t+i*n;let d,f;o?(d=i,f=-e):(d=-i,f=e);const p=l+d,m=h+f,g=c+d,y=u+f;return a.push(p,m,g,y),2}function qr(r,t,e,i,s,n,o,a){const l=e-r,h=i-t;let c=Math.atan2(l,h),u=Math.atan2(s-r,n-t);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(l*l+h*h),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,y=f/g;if(d+=y,a){o.push(r,t,e,i);for(let v=1,_=d;v<g;v++,_+=y)o.push(r,t,r+Math.sin(_)*m,t+Math.cos(_)*m);o.push(r,t,s,n)}else{o.push(e,i,r,t);for(let v=1,_=d;v<g;v++,_+=y)o.push(r+Math.sin(_)*m,t+Math.cos(_)*m,r,t);o.push(s,n,r,t)}return g*2}function Sb(r,t){const e=r.shape;let i=r.points||e.points.slice();const s=t.closePointEps;if(i.length===0)return;const n=r.lineStyle,o=new dt(i[0],i[1]),a=new dt(i[i.length-2],i[i.length-1]),l=e.type!==Vt.POLY||e.closeStroke,h=Math.abs(o.x-a.x)<s&&Math.abs(o.y-a.y)<s;if(l){i=i.slice(),h&&(i.pop(),i.pop(),a.set(i[i.length-2],i[i.length-1]));const G=(o.x+a.x)*.5,$=(a.y+o.y)*.5;i.unshift(G,$),i.push(G,$)}const c=t.points,u=i.length/2;let d=i.length;const f=c.length/2,p=n.width/2,m=p*p,g=n.miterLimit*n.miterLimit;let y=i[0],v=i[1],_=i[2],x=i[3],T=0,P=0,I=-(v-x),b=y-_,E=0,S=0,D=Math.sqrt(I*I+b*b);I/=D,b/=D,I*=p,b*=p;const B=n.alignment,w=(1-B)*2,C=B*2;l||(n.cap===br.ROUND?d+=qr(y-I*(w-C)*.5,v-b*(w-C)*.5,y-I*w,v-b*w,y+I*C,v+b*C,c,!0)+2:n.cap===br.SQUARE&&(d+=Nd(y,v,I,b,w,C,!0,c))),c.push(y-I*w,v-b*w,y+I*C,v+b*C);for(let G=1;G<u-1;++G){y=i[(G-1)*2],v=i[(G-1)*2+1],_=i[G*2],x=i[G*2+1],T=i[(G+1)*2],P=i[(G+1)*2+1],I=-(v-x),b=y-_,D=Math.sqrt(I*I+b*b),I/=D,b/=D,I*=p,b*=p,E=-(x-P),S=_-T,D=Math.sqrt(E*E+S*S),E/=D,S/=D,E*=p,S*=p;const $=_-y,nt=v-x,R=_-T,L=P-x,W=$*R+nt*L,Q=nt*R-L*$,J=Q<0;if(Math.abs(Q)<.001*Math.abs(W)){c.push(_-I*w,x-b*w,_+I*C,x+b*C),W>=0&&(n.join===pe.ROUND?d+=qr(_,x,_-I*w,x-b*w,_-E*w,x-S*w,c,!1)+4:d+=2,c.push(_-E*C,x-S*C,_+E*w,x+S*w));continue}const H=(-I+y)*(-b+x)-(-I+_)*(-b+v),_t=(-E+T)*(-S+x)-(-E+_)*(-S+P),Tt=($*_t-R*H)/Q,N=(L*H-nt*_t)/Q,O=(Tt-_)*(Tt-_)+(N-x)*(N-x),xt=_+(Tt-_)*w,ft=x+(N-x)*w,gt=_-(Tt-_)*C,yt=x-(N-x)*C,ze=Math.min($*$+nt*nt,R*R+L*L),We=J?w:C,_s=ze+We*We*m,SE=O<=_s;let Kn=n.join;if(Kn===pe.MITER&&O/m>g&&(Kn=pe.BEVEL),SE)switch(Kn){case pe.MITER:{c.push(xt,ft,gt,yt);break}case pe.BEVEL:{J?c.push(xt,ft,_+I*C,x+b*C,xt,ft,_+E*C,x+S*C):c.push(_-I*w,x-b*w,gt,yt,_-E*w,x-S*w,gt,yt),d+=2;break}case pe.ROUND:{J?(c.push(xt,ft,_+I*C,x+b*C),d+=qr(_,x,_+I*C,x+b*C,_+E*C,x+S*C,c,!0)+4,c.push(xt,ft,_+E*C,x+S*C)):(c.push(_-I*w,x-b*w,gt,yt),d+=qr(_,x,_-I*w,x-b*w,_-E*w,x-S*w,c,!1)+4,c.push(_-E*w,x-S*w,gt,yt));break}}else{switch(c.push(_-I*w,x-b*w,_+I*C,x+b*C),Kn){case pe.MITER:{J?c.push(gt,yt,gt,yt):c.push(xt,ft,xt,ft),d+=2;break}case pe.ROUND:{J?d+=qr(_,x,_+I*C,x+b*C,_+E*C,x+S*C,c,!0)+2:d+=qr(_,x,_-I*w,x-b*w,_-E*w,x-S*w,c,!1)+2;break}}c.push(_-E*w,x-S*w,_+E*C,x+S*C),d+=2}}y=i[(u-2)*2],v=i[(u-2)*2+1],_=i[(u-1)*2],x=i[(u-1)*2+1],I=-(v-x),b=y-_,D=Math.sqrt(I*I+b*b),I/=D,b/=D,I*=p,b*=p,c.push(_-I*w,x-b*w,_+I*C,x+b*C),l||(n.cap===br.ROUND?d+=qr(_-I*(w-C)*.5,x-b*(w-C)*.5,_-I*w,x-b*w,_+I*C,x+b*C,c,!1)+2:n.cap===br.SQUARE&&(d+=Nd(_,x,I,b,w,C,!1,c)));const F=t.indices,k=Oi.epsilon*Oi.epsilon;for(let G=f;G<d+f-2;++G)y=c[G*2],v=c[G*2+1],_=c[(G+1)*2],x=c[(G+1)*2+1],T=c[(G+2)*2],P=c[(G+2)*2+1],!(Math.abs(y*(x-P)+_*(P-v)+T*(v-x))<k)&&F.push(G,G+1,G+2)}function Ib(r,t){let e=0;const i=r.shape,s=r.points||i.points,n=i.type!==Vt.POLY||i.closeStroke;if(s.length===0)return;const o=t.points,a=t.indices,l=s.length/2,h=o.length/2;let c=h;for(o.push(s[0],s[1]),e=1;e<l;e++)o.push(s[e*2],s[e*2+1]),a.push(c,c+1),c++;n&&a.push(c,h)}function Ud(r,t){r.lineStyle.native?Ib(r,t):Sb(r,t)}class nl{static curveLength(t,e,i,s,n,o){const a=t-2*i+n,l=e-2*s+o,h=2*i-2*t,c=2*s-2*e,u=4*(a*a+l*l),d=4*(a*h+l*c),f=h*h+c*c,p=2*Math.sqrt(u+d+f),m=Math.sqrt(u),g=2*u*m,y=2*Math.sqrt(f),v=d/m;return(g*p+m*d*(p-y)+(4*f*u-d*d)*Math.log((2*m+v+p)/(v+y)))/(4*g)}static curveTo(t,e,i,s,n){const o=n[n.length-2],a=n[n.length-1],l=Oi._segmentsCount(nl.curveLength(o,a,t,e,i,s));let h=0,c=0;for(let u=1;u<=l;++u){const d=u/l;h=o+(t-o)*d,c=a+(e-a)*d,n.push(h+(t+(i-t)*d-h)*d,c+(e+(s-e)*d-c)*d)}}}const ol={[Vt.POLY]:Fd,[Vt.CIRC]:Nn,[Vt.ELIP]:Nn,[Vt.RECT]:Eb,[Vt.RREC]:Tb},kd=[],Un=[];class kn{constructor(t,e=null,i=null,s=null){this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=s,this.type=t.type}clone(){return new kn(this.shape,this.fillStyle,this.lineStyle,this.matrix)}destroy(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null}}const Fi=new dt,Gd=class Mf extends _u{constructor(){super(),this.closePointEps=1e-4,this.boundsPadding=0,this.uvsFloat32=null,this.indicesUint16=null,this.batchable=!1,this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.drawCalls=[],this.batchDirty=-1,this.batches=[],this.dirty=0,this.cacheDirty=-1,this.clearDirty=0,this.shapeIndex=0,this._bounds=new Sn,this.boundsDirty=-1}get bounds(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds}invalidate(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(let t=0;t<this.drawCalls.length;t++)this.drawCalls[t].texArray.clear(),Un.push(this.drawCalls[t]);this.drawCalls.length=0;for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e.reset(),kd.push(e)}this.batches.length=0}clear(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this}drawShape(t,e=null,i=null,s=null){const n=new kn(t,e,i,s);return this.graphicsData.push(n),this.dirty++,this}drawHole(t,e=null){if(!this.graphicsData.length)return null;const i=new kn(t,null,null,e),s=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=s.lineStyle,s.holes.push(i),this.dirty++,this}destroy(){super.destroy();for(let t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null}containsPoint(t){const e=this.graphicsData;for(let i=0;i<e.length;++i){const s=e[i];if(s.fillStyle.visible&&s.shape&&(s.matrix?s.matrix.applyInverse(t,Fi):Fi.copyFrom(t),s.shape.contains(Fi.x,Fi.y))){let n=!1;if(s.holes){for(let o=0;o<s.holes.length;o++)if(s.holes[o].shape.contains(Fi.x,Fi.y)){n=!0;break}}if(!n)return!0}}return!1}updateBatches(){if(!this.graphicsData.length){this.batchable=!0;return}if(!this.validateBatching())return;this.cacheDirty=this.dirty;const t=this.uvs,e=this.graphicsData;let i=null,s=null;this.batches.length>0&&(i=this.batches[this.batches.length-1],s=i.style);for(let l=this.shapeIndex;l<e.length;l++){this.shapeIndex++;const h=e[l],c=h.fillStyle,u=h.lineStyle;ol[h.type].build(h),h.matrix&&this.transformPoints(h.points,h.matrix),(c.visible||u.visible)&&this.processHoles(h.holes);for(let d=0;d<2;d++){const f=d===0?c:u;if(!f.visible)continue;const p=f.texture.baseTexture,m=this.indices.length,g=this.points.length/2;p.wrapMode=dr.REPEAT,d===0?this.processFill(h):this.processLine(h);const y=this.points.length/2-g;y!==0&&(i&&!this._compareStyles(s,f)&&(i.end(m,g),i=null),i||(i=kd.pop()||new Ab,i.begin(f,m,g),this.batches.push(i),s=f),this.addUvs(this.points,t,f.texture,g,y,f.matrix))}}const n=this.indices.length,o=this.points.length/2;if(i&&i.end(n,o),this.batches.length===0){this.batchable=!0;return}const a=o>65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&a===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=a?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}_compareStyles(t,e){return!(!t||!e||t.texture.baseTexture!==e.texture.baseTexture||t.color+t.alpha!==e.color+e.alpha||!!t.native!=!!e.native)}validateBatching(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(let t=0,e=this.graphicsData.length;t<e;t++){const i=this.graphicsData[t],s=i.fillStyle,n=i.lineStyle;if(s&&!s.texture.baseTexture.valid||n&&!n.texture.baseTexture.valid)return!1}return!0}packBatches(){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);const t=this.batches;for(let e=0,i=t.length;e<i;e++){const s=t[e];for(let n=0;n<s.size;n++){const o=s.start+n;this.indicesUint16[o]=this.indicesUint16[o]-s.attribStart}}}isBatchable(){if(this.points.length>65535*2)return!1;const t=this.batches;for(let e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<Mf.BATCHABLE_SIZE*2}buildDrawCalls(){let t=++et._globalBatch;for(let u=0;u<this.drawCalls.length;u++)this.drawCalls[u].texArray.clear(),Un.push(this.drawCalls[u]);this.drawCalls.length=0;const e=this.colors,i=this.textureIds;let s=Un.pop();s||(s=new Pa,s.texArray=new Fa),s.texArray.count=0,s.start=0,s.size=0,s.type=Be.TRIANGLES;let n=0,o=null,a=0,l=!1,h=Be.TRIANGLES,c=0;this.drawCalls.push(s);for(let u=0;u<this.batches.length;u++){const d=this.batches[u],f=8,p=d.style,m=p.texture.baseTexture;l!==!!p.native&&(l=!!p.native,h=l?Be.LINES:Be.TRIANGLES,o=null,n=f,t++),o!==m&&(o=m,m._batchEnabled!==t&&(n===f&&(t++,n=0,s.size>0&&(s=Un.pop(),s||(s=new Pa,s.texArray=new Fa),this.drawCalls.push(s)),s.start=c,s.size=0,s.texArray.count=0,s.type=h),m.touched=1,m._batchEnabled=t,m._batchLocation=n,m.wrapMode=dr.REPEAT,s.texArray.elements[s.texArray.count++]=m,n++)),s.size+=d.size,c+=d.size,a=m._batchLocation,this.addColors(e,p.color,p.alpha,d.attribSize,d.attribStart),this.addTextureIds(i,a,d.attribSize,d.attribStart)}et._globalBatch=t,this.packAttributes()}packAttributes(){const t=this.points,e=this.uvs,i=this.colors,s=this.textureIds,n=new ArrayBuffer(t.length*3*4),o=new Float32Array(n),a=new Uint32Array(n);let l=0;for(let h=0;h<t.length/2;h++)o[l++]=t[h*2],o[l++]=t[h*2+1],o[l++]=e[h*2],o[l++]=e[h*2+1],a[l++]=i[h],o[l++]=s[h];this._buffer.update(n),this._indexBuffer.update(this.indicesUint16)}processFill(t){t.holes.length?Fd.triangulate(t,this):ol[t.type].triangulate(t,this)}processLine(t){Ud(t,this);for(let e=0;e<t.holes.length;e++)Ud(t.holes[e],this)}processHoles(t){for(let e=0;e<t.length;e++){const i=t[e];ol[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}}calculateBounds(){const t=this._bounds;t.clear(),t.addVertexData(this.points,0,this.points.length),t.pad(this.boundsPadding,this.boundsPadding)}transformPoints(t,e){for(let i=0;i<t.length/2;i++){const s=t[i*2],n=t[i*2+1];t[i*2]=e.a*s+e.c*n+e.tx,t[i*2+1]=e.b*s+e.d*n+e.ty}}addColors(t,e,i,s,n=0){const o=vt.shared.setValue(e).toLittleEndianNumber(),a=vt.shared.setValue(o).toPremultiplied(i);t.length=Math.max(t.length,n+s);for(let l=0;l<s;l++)t[n+l]=a}addTextureIds(t,e,i,s=0){t.length=Math.max(t.length,s+i);for(let n=0;n<i;n++)t[s+n]=e}addUvs(t,e,i,s,n,o=null){let a=0;const l=e.length,h=i.frame;for(;a<n;){let u=t[(s+a)*2],d=t[(s+a)*2+1];if(o){const f=o.a*u+o.c*d+o.tx;d=o.b*u+o.d*d+o.ty,u=f}a++,e.push(u/h.width,d/h.height)}const c=i.baseTexture;(h.width<c.width||h.height<c.height)&&this.adjustUvs(e,i,l,n)}adjustUvs(t,e,i,s){const n=e.baseTexture,o=1e-6,a=i+s*2,l=e.frame,h=l.width/n.width,c=l.height/n.height;let u=l.x/l.width,d=l.y/l.height,f=Math.floor(t[i]+o),p=Math.floor(t[i+1]+o);for(let m=i+2;m<a;m+=2)f=Math.min(f,Math.floor(t[m]+o)),p=Math.min(p,Math.floor(t[m+1]+o));u-=f,d-=p;for(let m=i;m<a;m+=2)t[m]=(t[m]+u)*h,t[m+1]=(t[m+1]+d)*c}};Gd.BATCHABLE_SIZE=100;let Cb=Gd;class Gn{constructor(){this.color=16777215,this.alpha=1,this.texture=Y.WHITE,this.matrix=null,this.visible=!1,this.reset()}clone(){const t=new Gn;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t}reset(){this.color=16777215,this.alpha=1,this.texture=Y.WHITE,this.matrix=null,this.visible=!1}destroy(){this.texture=null,this.matrix=null}}class al extends Gn{constructor(){super(...arguments),this.width=0,this.alignment=.5,this.native=!1,this.cap=br.BUTT,this.join=pe.MITER,this.miterLimit=10}clone(){const t=new al;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t}reset(){super.reset(),this.color=0,this.alignment=.5,this.width=0,this.native=!1,this.cap=br.BUTT,this.join=pe.MITER,this.miterLimit=10}}const ll={},hl=class eo extends xe{constructor(t=null){super(),this.shader=null,this.pluginName="batch",this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this._fillStyle=new Gn,this._lineStyle=new al,this._matrix=null,this._holeMode=!1,this.state=$e.for2d(),this._geometry=t||new Cb,this._geometry.refCount++,this._transformID=-1,this._tintColor=new vt(16777215),this.blendMode=Z.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new eo(this._geometry)}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(t){this._tintColor.setValue(t)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(t=null,e=0,i,s=.5,n=!1){return typeof t=="number"&&(t={width:t,color:e,alpha:i,alignment:s,native:n}),this.lineTextureStyle(t)}lineTextureStyle(t){const e={width:0,texture:Y.WHITE,color:t!=null&&t.texture?16777215:0,matrix:null,alignment:.5,native:!1,cap:br.BUTT,join:pe.MITER,miterLimit:10};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.width>0&&t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:i},t)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new Nr,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new Nr,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this}lineTo(t,e){this.currentPath||this.moveTo(0,0);const i=this.currentPath.points,s=i[i.length-2],n=i[i.length-1];return(s!==t||n!==e)&&i.push(t,e),this}_initCurve(t=0,e=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[t,e]):this.moveTo(t,e)}quadraticCurveTo(t,e,i,s){this._initCurve();const n=this.currentPath.points;return n.length===0&&this.moveTo(0,0),nl.curveTo(t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,o){return this._initCurve(),sl.curveTo(t,e,i,s,n,o,this.currentPath.points),this}arcTo(t,e,i,s,n){this._initCurve(t,e);const o=this.currentPath.points,a=Ld.curveTo(t,e,i,s,n,o);if(a){const{cx:l,cy:h,radius:c,startAngle:u,endAngle:d,anticlockwise:f}=a;this.arc(l,h,c,u,d,f)}return this}arc(t,e,i,s,n,o=!1){if(s===n)return this;if(!o&&n<=s?n+=ln:o&&s<=n&&(s+=ln),n-s===0)return this;const a=t+Math.cos(s)*i,l=e+Math.sin(s)*i,h=this._geometry.closePointEps;let c=this.currentPath?this.currentPath.points:null;if(c){const u=Math.abs(c[c.length-2]-a),d=Math.abs(c[c.length-1]-l);u<h&&d<h||c.push(a,l)}else this.moveTo(a,l),c=this.currentPath.points;return Ld.arc(a,l,t,e,i,s,n,o,c),this}beginFill(t=0,e){return this.beginTextureFill({texture:Y.WHITE,color:t,alpha:e})}normalizeColor(t){const e=vt.shared.setValue(t.color??0);t.color=e.toNumber(),t.alpha??(t.alpha=e.alpha)}beginTextureFill(t){const e={texture:Y.WHITE,color:16777215,matrix:null};t=Object.assign(e,t),this.normalizeColor(t),this.currentPath&&this.startPoly();const i=t.alpha>0;return i?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:i},t)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(t,e,i,s){return this.drawShape(new it(t,e,i,s))}drawRoundedRect(t,e,i,s,n){return this.drawShape(new dn(t,e,i,s,n))}drawCircle(t,e,i){return this.drawShape(new cn(t,e,i))}drawEllipse(t,e,i,s){return this.drawShape(new un(t,e,i,s))}drawPolygon(...t){let e,i=!0;const s=t[0];s.points?(i=s.closeStroke,e=s.points):Array.isArray(t[0])?e=t[0]:e=t;const n=new Nr(e);return n.closeStroke=i,this.drawShape(n),this}drawShape(t){return this._holeMode?this._geometry.drawHole(t,this._matrix):this._geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this}clear(){return this._geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._boundsID++,this._matrix=null,this._holeMode=!1,this.currentPath=null,this}isFastRect(){const t=this._geometry.graphicsData;return t.length===1&&t[0].shape.type===Vt.RECT&&!t[0].matrix&&!t[0].holes.length&&!(t[0].lineStyle.visible&&t[0].lineStyle.width)}_render(t){this.finishPoly();const e=this._geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))}_populateBatches(){const t=this._geometry,e=this.blendMode,i=t.batches.length;this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.batches.length=i,this.vertexData=new Float32Array(t.points);for(let s=0;s<i;s++){const n=t.batches[s],o=n.style.color,a=new Float32Array(this.vertexData.buffer,n.attribStart*4*2,n.attribSize*2),l=new Float32Array(t.uvsFloat32.buffer,n.attribStart*4*2,n.attribSize*2),h=new Uint16Array(t.indicesUint16.buffer,n.start*2,n.size),c={vertexData:a,blendMode:e,indices:h,uvs:l,_batchRGB:vt.shared.setValue(o).toRgbArray(),_tintRGB:o,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[s]=c}}_renderBatched(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(let e=0,i=this.batches.length;e<i;e++){const s=this.batches[e];s.worldAlpha=this.worldAlpha*s.alpha,t.plugins[this.pluginName].render(s)}}}_renderDirect(t){const e=this._resolveDirectShader(t),i=this._geometry,s=this.worldAlpha,n=e.uniforms,o=i.drawCalls;n.translationMatrix=this.transform.worldTransform,vt.shared.setValue(this._tintColor).premultiply(s).toArray(n.tint),t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(let a=0,l=o.length;a<l;a++)this._renderDrawCallDirect(t,i.drawCalls[a])}_renderDrawCallDirect(t,e){const{texArray:i,type:s,size:n,start:o}=e,a=i.count;for(let l=0;l<a;l++)t.texture.bind(i.elements[l],l);t.geometry.draw(s,n,o)}_resolveDirectShader(t){let e=this.shader;const i=this.pluginName;if(!e){if(!ll[i]){const{maxTextures:s}=t.plugins[i],n=new Int32Array(s);for(let l=0;l<s;l++)n[l]=l;const o={tint:new Float32Array([1,1,1,1]),translationMatrix:new wt,default:ve.from({uSamplers:n},!0)},a=t.plugins[i]._shader.program;ll[i]=new He(a,o)}e=ll[i]}return e}_calculateBounds(){this.finishPoly();const t=this._geometry;if(!t.graphicsData.length)return;const{minX:e,minY:i,maxX:s,maxY:n}=t.bounds;this._bounds.addFrame(this.transform,e,i,s,n)}containsPoint(t){return this.worldTransform.applyInverse(t,eo._TEMP_POINT),this._geometry.containsPoint(eo._TEMP_POINT)}calculateTints(){if(this.batchTint!==this.tint){this.batchTint=this._tintColor.toNumber();for(let t=0;t<this.batches.length;t++){const e=this.batches[t];e._tintRGB=vt.shared.setValue(this._tintColor).multiply(e._batchRGB).toLittleEndianNumber()}}}calculateVertices(){const t=this.transform._worldID;if(this._transformID===t)return;this._transformID=t;const e=this.transform.worldTransform,i=e.a,s=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=this._geometry.points,c=this.vertexData;let u=0;for(let d=0;d<h.length;d+=2){const f=h[d],p=h[d+1];c[u++]=i*f+n*p+a,c[u++]=o*p+s*f+l}}closePath(){const t=this.currentPath;return t&&(t.closeStroke=!0,this.finishPoly()),this}setMatrix(t){return this._matrix=t,this}beginHole(){return this.finishPoly(),this._holeMode=!0,this}endHole(){return this.finishPoly(),this._holeMode=!1,this}destroy(t){this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this._geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,super.destroy(t)}};hl.curves=Oi,hl._TEMP_POINT=new dt;let gs=hl;class Pb{constructor(t,e){this.uvBuffer=t,this.uvMatrix=e,this.data=null,this._bufferUpdateId=-1,this._textureUpdateId=-1,this._updateID=0}update(t){if(!t&&this._bufferUpdateId===this.uvBuffer._updateID&&this._textureUpdateId===this.uvMatrix._updateID)return;this._bufferUpdateId=this.uvBuffer._updateID,this._textureUpdateId=this.uvMatrix._updateID;const e=this.uvBuffer.data;(!this.data||this.data.length!==e.length)&&(this.data=new Float32Array(e.length)),this.uvMatrix.multiplyUvs(e,this.data),this._updateID++}}const cl=new dt,$d=new Nr,Hd=class Bf extends xe{constructor(t,e,i,s=Be.TRIANGLES){super(),this.geometry=t,this.shader=e,this.state=i||$e.for2d(),this.drawMode=s,this.start=0,this.size=0,this.uvs=null,this.indices=null,this.vertexData=new Float32Array(1),this.vertexDirty=-1,this._transformID=-1,this._roundPixels=z.ROUND_PIXELS,this.batchUvs=null}get geometry(){return this._geometry}set geometry(t){this._geometry!==t&&(this._geometry&&(this._geometry.refCount--,this._geometry.refCount===0&&this._geometry.dispose()),this._geometry=t,this._geometry&&this._geometry.refCount++,this.vertexDirty=-1)}get uvBuffer(){return this.geometry.buffers[1]}get verticesBuffer(){return this.geometry.buffers[0]}set material(t){this.shader=t}get material(){return this.shader}set blendMode(t){this.state.blendMode=t}get blendMode(){return this.state.blendMode}set roundPixels(t){this._roundPixels!==t&&(this._transformID=-1),this._roundPixels=t}get roundPixels(){return this._roundPixels}get tint(){return"tint"in this.shader?this.shader.tint:null}set tint(t){this.shader.tint=t}get tintValue(){return this.shader.tintValue}get texture(){return"texture"in this.shader?this.shader.texture:null}set texture(t){this.shader.texture=t}_render(t){const e=this.geometry.buffers[0].data;this.shader.batchable&&this.drawMode===Be.TRIANGLES&&e.length<Bf.BATCHABLE_SIZE*2?this._renderToBatch(t):this._renderDefault(t)}_renderDefault(t){const e=this.shader;e.alpha=this.worldAlpha,e.update&&e.update(),t.batch.flush(),e.uniforms.translationMatrix=this.transform.worldTransform.toArray(!0),t.shader.bind(e),t.state.set(this.state),t.geometry.bind(this.geometry,e),t.geometry.draw(this.drawMode,this.size,this.start,this.geometry.instanceCount)}_renderToBatch(t){const e=this.geometry,i=this.shader;i.uvMatrix&&(i.uvMatrix.update(),this.calculateUvs()),this.calculateVertices(),this.indices=e.indexBuffer.data,this._tintRGB=i._tintRGB,this._texture=i.texture;const s=this.material.pluginName;t.batch.setObjectRenderer(t.plugins[s]),t.plugins[s].render(this)}calculateVertices(){const t=this.geometry.buffers[0],e=t.data,i=t._updateID;if(i===this.vertexDirty&&this._transformID===this.transform._worldID)return;this._transformID=this.transform._worldID,this.vertexData.length!==e.length&&(this.vertexData=new Float32Array(e.length));const s=this.transform.worldTransform,n=s.a,o=s.b,a=s.c,l=s.d,h=s.tx,c=s.ty,u=this.vertexData;for(let d=0;d<u.length/2;d++){const f=e[d*2],p=e[d*2+1];u[d*2]=n*f+a*p+h,u[d*2+1]=o*f+l*p+c}if(this._roundPixels){const d=z.RESOLUTION;for(let f=0;f<u.length;++f)u[f]=Math.round(u[f]*d)/d}this.vertexDirty=i}calculateUvs(){const t=this.geometry.buffers[1],e=this.shader;e.uvMatrix.isSimple?this.uvs=t.data:(this.batchUvs||(this.batchUvs=new Pb(t,e.uvMatrix)),this.batchUvs.update(),this.uvs=this.batchUvs.data)}_calculateBounds(){this.calculateVertices(),this._bounds.addVertexData(this.vertexData,0,this.vertexData.length)}containsPoint(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,cl);const e=this.geometry.getBuffer("aVertexPosition").data,i=$d.points,s=this.geometry.getIndex().data,n=s.length,o=this.drawMode===4?3:1;for(let a=0;a+2<n;a+=o){const l=s[a]*2,h=s[a+1]*2,c=s[a+2]*2;if(i[0]=e[l],i[1]=e[l+1],i[2]=e[h],i[3]=e[h+1],i[4]=e[c],i[5]=e[c+1],$d.contains(cl.x,cl.y))return!0}return!1}destroy(t){super.destroy(t),this._cachedTexture&&(this._cachedTexture.destroy(),this._cachedTexture=null),this.geometry=null,this.shader=null,this.state=null,this.uvs=null,this.indices=null,this.vertexData=null}};Hd.BATCHABLE_SIZE=100;let Xd=Hd;class Rb extends _r{constructor(t,e,i){super();const s=new Mt(t),n=new Mt(e,!0),o=new Mt(i,!0,!0);this.addAttribute("aVertexPosition",s,2,!1,K.FLOAT).addAttribute("aTextureCoord",n,2,!1,K.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}var Mb=`varying vec2 vTextureCoord;
|
|
912
912
|
uniform vec4 uColor;
|
|
913
913
|
|
|
914
914
|
uniform sampler2D uSampler;
|
|
@@ -932,7 +932,7 @@ void main(void)
|
|
|
932
932
|
|
|
933
933
|
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
|
|
934
934
|
}
|
|
935
|
-
`;class Vd extends He{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:wt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||ar.from(Bb,Mb),i),this._colorDirty=!1,this.uvMatrix=new ku(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new vt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;vt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class zd{constructor(t,e,i){this.geometry=new _r,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||
|
|
935
|
+
`;class Vd extends He{constructor(t,e){const i={uSampler:t,alpha:1,uTextureMatrix:wt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(i,e.uniforms),super(e.program||ar.from(Bb,Mb),i),this._colorDirty=!1,this.uvMatrix=new ku(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this._tintColor=new vt(e.tint),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this.tint&&(this._tintColor.setValue(t),this._tintRGB=this._tintColor.toLittleEndianNumber(),this._colorDirty=!0)}get tint(){return this._tintColor.value}get tintValue(){return this._tintColor.toNumber()}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture.alphaMode;vt.shared.setValue(this._tintColor).premultiply(this._alpha,t).toArray(this.uniforms.uColor)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class zd{constructor(t,e,i){this.geometry=new _r,this.indexBuffer=null,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(let s=0;s<t.length;++s){let n=t[s];n={attributeName:n.attributeName,size:n.size,uploadFunction:n.uploadFunction,type:n.type||K.FLOAT,offset:n.offset},e[s]?this.dynamicProperties.push(n):this.staticProperties.push(n)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this._updateID=0,this.initBuffers()}initBuffers(){const t=this.geometry;let e=0;this.indexBuffer=new Mt(Q_(this.size),!0,!0),t.addIndex(this.indexBuffer),this.dynamicStride=0;for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];a.offset=e,e+=a.size,this.dynamicStride+=a.size}const i=new ArrayBuffer(this.size*this.dynamicStride*4*4);this.dynamicData=new Float32Array(i),this.dynamicDataUint32=new Uint32Array(i),this.dynamicBuffer=new Mt(this.dynamicData,!1,!1);let s=0;this.staticStride=0;for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];a.offset=s,s+=a.size,this.staticStride+=a.size}const n=new ArrayBuffer(this.size*this.staticStride*4*4);this.staticData=new Float32Array(n),this.staticDataUint32=new Uint32Array(n),this.staticBuffer=new Mt(this.staticData,!0,!1);for(let o=0;o<this.dynamicProperties.length;++o){const a=this.dynamicProperties[o];t.addAttribute(a.attributeName,this.dynamicBuffer,0,a.type===K.UNSIGNED_BYTE,a.type,this.dynamicStride*4,a.offset*4)}for(let o=0;o<this.staticProperties.length;++o){const a=this.staticProperties[o];t.addAttribute(a.attributeName,this.staticBuffer,0,a.type===K.UNSIGNED_BYTE,a.type,this.staticStride*4,a.offset*4)}}uploadDynamic(t,e,i){for(let s=0;s<this.dynamicProperties.length;s++){const n=this.dynamicProperties[s];n.uploadFunction(t,e,i,n.type===K.UNSIGNED_BYTE?this.dynamicDataUint32:this.dynamicData,this.dynamicStride,n.offset)}this.dynamicBuffer._updateID++}uploadStatic(t,e,i){for(let s=0;s<this.staticProperties.length;s++){const n=this.staticProperties[s];n.uploadFunction(t,e,i,n.type===K.UNSIGNED_BYTE?this.staticDataUint32:this.staticData,this.staticStride,n.offset)}this.staticBuffer._updateID++}destroy(){this.indexBuffer=null,this.dynamicProperties=null,this.dynamicBuffer=null,this.dynamicData=null,this.dynamicDataUint32=null,this.staticProperties=null,this.staticBuffer=null,this.staticData=null,this.staticDataUint32=null,this.geometry.destroy()}}var Db=`varying vec2 vTextureCoord;
|
|
936
936
|
varying vec4 vColor;
|
|
937
937
|
|
|
938
938
|
uniform sampler2D uSampler;
|
|
@@ -965,8 +965,8 @@ void main(void){
|
|
|
965
965
|
vTextureCoord = aTextureCoord;
|
|
966
966
|
vColor = aColor * uColor;
|
|
967
967
|
}
|
|
968
|
-
`;class Wd extends yn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new wt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:
|
|
969
|
-
`:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=K._measureText(t,e,s)+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(!K.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:K._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:K._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(K.isBreakingSpace(n,o)||K.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return K.graphemeSegmenter(t)}static measureFont(t){if(K._fonts[t])return K._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=K._canvas,s=K._context;s.font=t;const n=K.METRICS_STRING+K.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(K.BASELINE_SYMBOL).width);const l=Math.ceil(K.HEIGHT_MULTIPLIER*a);if(a=a*K.BASELINE_MULTIPLIER|0,o===0||l===0)return K._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,K._fonts[t]=e,e}static clearMetrics(t=""){t?delete K._fonts[t]:K._fonts={}}static get _canvas(){var t;if(!K.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Hn))!=null&&t.measureText)return K.__canvas=i,i;e=W.ADAPTER.createCanvas()}catch{e=W.ADAPTER.createCanvas()}e.width=e.height=10,K.__canvas=e}return K.__canvas}static get _context(){return K.__context||(K.__context=K._canvas.getContext("2d",Hn)),K.__context}};Ve.METRICS_STRING="|ÉqÅ",Ve.BASELINE_SYMBOL="M",Ve.BASELINE_MULTIPLIER=1.4,Ve.HEIGHT_MULTIPLIER=2,Ve.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),Ve.experimentalLetterSpacing=!1,Ve._fonts={},Ve._newlines=[10,13],Ve._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let wr=Ve;const Fb=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],jd=class bs{constructor(t){this.styleID=0,this.reset(),dl(this,t,t)}clone(){const t={};return dl(t,this,bs.defaultStyle),new bs(t)}reset(){dl(this,bs.defaultStyle,bs.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=ul(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=ul(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){Lb(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=ul(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Fb.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};jd.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:$n.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Er=jd;function ul(r){const t=vt.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function Lb(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function dl(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const Nb={texture:!0,children:!1,baseTexture:!0},Yd=class Pl extends Ci{constructor(t,e,i){let s=!1;i||(i=W.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=q.from(i);n.orig=new it,n.trim=new it,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Pl.defaultResolution??W.RESOLUTION,this._autoResolution=Pl.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return wr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){at("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),wr.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=wr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let m=0;m<p;++m){const g=e.dropShadow&&m===0,y=g?Math.ceil(Math.max(1,o)+e.padding*2):0,x=y*this._resolution;if(g){i.fillStyle="black",i.strokeStyle="black";const v=e.dropShadowColor,w=e.dropShadowBlur*this._resolution,R=e.dropShadowDistance*this._resolution;i.shadowColor=vt.shared.setValue(v).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=w,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*R,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*R+x}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let _=(l-u.fontSize)/2;l-u.fontSize<0&&(_=0);for(let v=0;v<a.length;v++)d=e.strokeThickness/2,f=e.strokeThickness/2+v*l+u.ascent+_,e.align==="right"?d+=c-h[v]:e.align==="center"&&(d+=(c-h[v])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[v],d+e.padding,f+e.padding-y,!0),e.fill&&this.drawLetterSpacing(a[v],d+e.padding,f+e.padding-y)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(wr.experimentalLetterSpacingSupported&&(wr.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=wr.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+n,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=iv(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,c=s.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(s[0]),u.unshift(0),c.push(s[s.length-1]),u.push(1),t.fillGradientType===$n.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,m=i.lineHeight*f;let g=m;f>0&&p>m&&(g=(m+p)/2);const y=m+d,x=i.lineHeight*(f+1);let _=y;f+1<e.length&&x<y&&(_=(y+x)/2);const v=(_-g)/h;for(let w=0;w<c.length;w++){let R=0;typeof u[w]=="number"?R=u[w]:R=w/c.length;let C=Math.min(1,Math.max(0,g/h+R*v));C=Number(C.toFixed(5)),n.addColorStop(C,c[w])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let m;typeof u[p]=="number"?m=u[p]:m=f/d,n.addColorStop(m,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Nb,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=gr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=gr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof Er?this._style=t:this._style=new Er(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};Yd.defaultAutoResolution=!0;let qd=Yd;class Ub{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function kb(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof q){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function Gb(r,t){if(r.baseTexture instanceof et){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function $b(r,t){if(r._texture&&r._texture instanceof q){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Hb(r,t){return t instanceof qd?(t.updateText(!0),!0):!1}function Xb(r,t){if(t instanceof Er){const e=t.toFontString();return wr.measureFont(e),!0}return!1}function Vb(r,t){if(r instanceof qd){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function zb(r,t){return r instanceof Er?(t.includes(r)||t.push(r),!0):!1}const Kd=class Df{constructor(t){this.limiter=new Ub(Df.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(Vb),this.registerFindHook(zb),this.registerFindHook(kb),this.registerFindHook(Gb),this.registerFindHook($b),this.registerUploadHook(Hb),this.registerUploadHook(Xb)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,ae.system.addOnce(this.tick,this,Wr.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)ae.system.addOnce(this.tick,this,Wr.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof xe)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&ae.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Kd.uploadsPerFrame=4;let fl=Kd;Object.defineProperties(W,{UPLOADS_PER_FRAME:{get(){return fl.uploadsPerFrame},set(r){at("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),fl.uploadsPerFrame=r}}});function Zd(r,t){return t instanceof et?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function Wb(r,t){if(!(t instanceof ms))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&Zd(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function jb(r,t){return r instanceof ms?(t.push(r),!0):!1}class Jd extends fl{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(jb),this.registerUploadHook(Zd),this.registerUploadHook(Wb)}}Jd.extension={name:"prepare",type:$.RendererSystem},Y.add(Jd);var Yb=`#version 300 es
|
|
968
|
+
`;class Wd extends yn{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new wt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:K.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=He.from(Ob,Db,{}),this.state=$e.for2d()}render(t){const e=t.children,i=t._maxSize,s=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>i&&!t.autoResize&&(o=i);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const l=e[0]._texture.baseTexture,h=l.alphaMode>0;this.state.blendMode=au(t.blendMode,h),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=vt.shared.setValue(t.tintRgb).premultiply(t.worldAlpha,h).toArray(this.shader.uniforms.uColor),this.shader.uniforms.uSampler=l,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;f<o;f+=s,p+=1){let m=o-f;m>s&&(m=s),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const g=a[p];g.uploadDynamic(e,f,m);const y=t._bufferUpdateIDs[p]||0;d=d||g._updateID<y,d&&(g._updateID=t._updateID,g.uploadStatic(e,f,m)),n.geometry.bind(g.geometry),c.drawElements(c.TRIANGLES,m*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],i=t._maxSize,s=t._batchSize,n=t._properties;for(let o=0;o<i;o+=s)e.push(new zd(this.properties,n,s));return e}_generateOneMoreBuffer(t){const e=t._batchSize,i=t._properties;return new zd(this.properties,i,e)}uploadVertices(t,e,i,s,n,o){let a=0,l=0,h=0,c=0;for(let u=0;u<i;++u){const d=t[e+u],f=d._texture,p=d.scale.x,m=d.scale.y,g=f.trim,y=f.orig;g?(l=g.x-d.anchor.x*y.width,a=l+g.width,c=g.y-d.anchor.y*y.height,h=c+g.height):(a=y.width*(1-d.anchor.x),l=y.width*-d.anchor.x,h=y.height*(1-d.anchor.y),c=y.height*-d.anchor.y),s[o]=l*p,s[o+1]=c*m,s[o+n]=a*p,s[o+n+1]=c*m,s[o+n*2]=a*p,s[o+n*2+1]=h*m,s[o+n*3]=l*p,s[o+n*3+1]=h*m,o+=n*4}}uploadPosition(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].position;s[o]=l.x,s[o+1]=l.y,s[o+n]=l.x,s[o+n+1]=l.y,s[o+n*2]=l.x,s[o+n*2+1]=l.y,s[o+n*3]=l.x,s[o+n*3+1]=l.y,o+=n*4}}uploadRotation(t,e,i,s,n,o){for(let a=0;a<i;a++){const l=t[e+a].rotation;s[o]=l,s[o+n]=l,s[o+n*2]=l,s[o+n*3]=l,o+=n*4}}uploadUvs(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a]._texture._uvs;l?(s[o]=l.x0,s[o+1]=l.y0,s[o+n]=l.x1,s[o+n+1]=l.y1,s[o+n*2]=l.x2,s[o+n*2+1]=l.y2,s[o+n*3]=l.x3,s[o+n*3+1]=l.y3,o+=n*4):(s[o]=0,s[o+1]=0,s[o+n]=0,s[o+n+1]=0,s[o+n*2]=0,s[o+n*2+1]=0,s[o+n*3]=0,s[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,i,s,n,o){for(let a=0;a<i;++a){const l=t[e+a],h=vt.shared.setValue(l._tintRGB).toPremultiplied(l.alpha,l.texture.baseTexture.alphaMode>0);s[o]=h,s[o+n]=h,s[o+n*2]=h,s[o+n*3]=h,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}Wd.extension={name:"particle",type:X.RendererPlugin},j.add(Wd);var $n=(r=>(r[r.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",r[r.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",r))($n||{});const Hn={willReadFrequently:!0},Ve=class q{static get experimentalLetterSpacingSupported(){let t=q._experimentalLetterSpacingSupported;if(t!==void 0){const e=z.ADAPTER.getCanvasRenderingContext2D().prototype;t=q._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,s,n,o,a,l,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h}static measureText(t,e,i,s=q._canvas){i=i??e.wordWrap;const n=e.toFontString(),o=q.measureFont(n);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const a=s.getContext("2d",Hn);a.font=n;const l=(i?q.wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),h=new Array(l.length);let c=0;for(let p=0;p<l.length;p++){const m=q._measureText(l[p],e.letterSpacing,a);h[p]=m,c=Math.max(c,m)}let u=c+e.strokeThickness;e.dropShadow&&(u+=e.dropShadowDistance);const d=e.lineHeight||o.fontSize+e.strokeThickness;let f=Math.max(d,o.fontSize+e.strokeThickness*2)+e.leading+(l.length-1)*(d+e.leading);return e.dropShadow&&(f+=e.dropShadowDistance),new q(t,e,u,f,l,h,d+e.leading,c,o)}static _measureText(t,e,i){let s=!1;q.experimentalLetterSpacingSupported&&(q.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,s=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));let n=i.measureText(t).width;return n>0&&(s?n-=e:n+=(q.graphemeSegmenter(t).length-1)*e),n}static wordWrap(t,e,i=q._canvas){const s=i.getContext("2d",Hn);let n=0,o="",a="";const l=Object.create(null),{letterSpacing:h,whiteSpace:c}=e,u=q.collapseSpaces(c),d=q.collapseNewlines(c);let f=!u;const p=e.wordWrapWidth+h,m=q.tokenize(t);for(let g=0;g<m.length;g++){let y=m[g];if(q.isNewline(y)){if(!d){a+=q.addLine(o),f=!u,o="",n=0;continue}y=" "}if(u){const _=q.isBreakingSpace(y),x=q.isBreakingSpace(o[o.length-1]);if(_&&x)continue}const v=q.getFromCache(y,h,l,s);if(v>p)if(o!==""&&(a+=q.addLine(o),o="",n=0),q.canBreakWords(y,e.breakWords)){const _=q.wordWrapSplit(y);for(let x=0;x<_.length;x++){let T=_[x],P=T,I=1;for(;_[x+I];){const E=_[x+I];if(!q.canBreakChars(P,E,y,x,e.breakWords))T+=E;else break;P=E,I++}x+=I-1;const b=q.getFromCache(T,h,l,s);b+n>p&&(a+=q.addLine(o),f=!1,o="",n=0),o+=T,n+=b}}else{o.length>0&&(a+=q.addLine(o),o="",n=0);const _=g===m.length-1;a+=q.addLine(y,!_),f=!1,o="",n=0}else v+n>p&&(f=!1,a+=q.addLine(o),o="",n=0),(o.length>0||!q.isBreakingSpace(y)||f)&&(o+=y,n+=v)}return a+=q.addLine(o,!1),a}static addLine(t,e=!0){return t=q.trimRight(t),t=e?`${t}
|
|
969
|
+
`:t,t}static getFromCache(t,e,i,s){let n=i[t];return typeof n!="number"&&(n=q._measureText(t,e,s)+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(!q.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:q._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:q._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let s=0;s<t.length;s++){const n=t[s],o=t[s+1];if(q.isBreakingSpace(n,o)||q.isNewline(n)){i!==""&&(e.push(i),i=""),e.push(n);continue}i+=n}return i!==""&&e.push(i),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(t){return q.graphemeSegmenter(t)}static measureFont(t){if(q._fonts[t])return q._fonts[t];const e={ascent:0,descent:0,fontSize:0},i=q._canvas,s=q._context;s.font=t;const n=q.METRICS_STRING+q.BASELINE_SYMBOL,o=Math.ceil(s.measureText(n).width);let a=Math.ceil(s.measureText(q.BASELINE_SYMBOL).width);const l=Math.ceil(q.HEIGHT_MULTIPLIER*a);if(a=a*q.BASELINE_MULTIPLIER|0,o===0||l===0)return q._fonts[t]=e,e;i.width=o,i.height=l,s.fillStyle="#f00",s.fillRect(0,0,o,l),s.font=t,s.textBaseline="alphabetic",s.fillStyle="#000",s.fillText(n,0,a);const h=s.getImageData(0,0,o,l).data,c=h.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=l;d>a;--d){for(let m=0;m<u;m+=4)if(h[f+m]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,q._fonts[t]=e,e}static clearMetrics(t=""){t?delete q._fonts[t]:q._fonts={}}static get _canvas(){var t;if(!q.__canvas){let e;try{const i=new OffscreenCanvas(0,0);if((t=i.getContext("2d",Hn))!=null&&t.measureText)return q.__canvas=i,i;e=z.ADAPTER.createCanvas()}catch{e=z.ADAPTER.createCanvas()}e.width=e.height=10,q.__canvas=e}return q.__canvas}static get _context(){return q.__context||(q.__context=q._canvas.getContext("2d",Hn)),q.__context}};Ve.METRICS_STRING="|ÉqÅ",Ve.BASELINE_SYMBOL="M",Ve.BASELINE_MULTIPLIER=1.4,Ve.HEIGHT_MULTIPLIER=2,Ve.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>[...r.segment(t)].map(e=>e.segment)}return r=>[...r]})(),Ve.experimentalLetterSpacing=!1,Ve._fonts={},Ve._newlines=[10,13],Ve._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];let wr=Ve;const Fb=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],jd=class ws{constructor(t){this.styleID=0,this.reset(),dl(this,t,t)}clone(){const t={};return dl(t,this,ws.defaultStyle),new ws(t)}reset(){dl(this,ws.defaultStyle,ws.defaultStyle)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.styleID++)}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.styleID++)}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(this._dropShadow=t,this.styleID++)}get dropShadowAlpha(){return this._dropShadowAlpha}set dropShadowAlpha(t){this._dropShadowAlpha!==t&&(this._dropShadowAlpha=t,this.styleID++)}get dropShadowAngle(){return this._dropShadowAngle}set dropShadowAngle(t){this._dropShadowAngle!==t&&(this._dropShadowAngle=t,this.styleID++)}get dropShadowBlur(){return this._dropShadowBlur}set dropShadowBlur(t){this._dropShadowBlur!==t&&(this._dropShadowBlur=t,this.styleID++)}get dropShadowColor(){return this._dropShadowColor}set dropShadowColor(t){const e=ul(t);this._dropShadowColor!==e&&(this._dropShadowColor=e,this.styleID++)}get dropShadowDistance(){return this._dropShadowDistance}set dropShadowDistance(t){this._dropShadowDistance!==t&&(this._dropShadowDistance=t,this.styleID++)}get fill(){return this._fill}set fill(t){const e=ul(t);this._fill!==e&&(this._fill=e,this.styleID++)}get fillGradientType(){return this._fillGradientType}set fillGradientType(t){this._fillGradientType!==t&&(this._fillGradientType=t,this.styleID++)}get fillGradientStops(){return this._fillGradientStops}set fillGradientStops(t){Lb(this._fillGradientStops,t)||(this._fillGradientStops=t,this.styleID++)}get fontFamily(){return this._fontFamily}set fontFamily(t){this.fontFamily!==t&&(this._fontFamily=t,this.styleID++)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.styleID++)}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.styleID++)}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.styleID++)}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.styleID++)}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.styleID++)}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.styleID++)}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.styleID++)}get lineJoin(){return this._lineJoin}set lineJoin(t){this._lineJoin!==t&&(this._lineJoin=t,this.styleID++)}get miterLimit(){return this._miterLimit}set miterLimit(t){this._miterLimit!==t&&(this._miterLimit=t,this.styleID++)}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.styleID++)}get stroke(){return this._stroke}set stroke(t){const e=ul(t);this._stroke!==e&&(this._stroke=e,this.styleID++)}get strokeThickness(){return this._strokeThickness}set strokeThickness(t){this._strokeThickness!==t&&(this._strokeThickness=t,this.styleID++)}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.styleID++)}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.styleID++)}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.styleID++)}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.styleID++)}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.styleID++)}toFontString(){const t=typeof this.fontSize=="number"?`${this.fontSize}px`:this.fontSize;let e=this.fontFamily;Array.isArray(this.fontFamily)||(e=this.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let s=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(s)&&!Fb.includes(s)&&(s=`"${s}"`),e[i]=s}return`${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${t} ${e.join(",")}`}};jd.defaultStyle={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:$n.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Er=jd;function ul(r){const t=vt.shared,e=i=>{const s=t.setValue(i);return s.alpha===1?s.toHex():s.toRgbaString()};return Array.isArray(r)?r.map(e):e(r)}function Lb(r,t){if(!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length)return!1;for(let e=0;e<r.length;++e)if(r[e]!==t[e])return!1;return!0}function dl(r,t,e){for(const i in e)Array.isArray(t[i])?r[i]=t[i].slice():r[i]=t[i]}const Nb={texture:!0,children:!1,baseTexture:!0},Yd=class Pl extends Ci{constructor(t,e,i){let s=!1;i||(i=z.ADAPTER.createCanvas(),s=!0),i.width=3,i.height=3;const n=Y.from(i);n.orig=new it,n.trim=new it,super(n),this._ownCanvas=s,this.canvas=i,this.context=i.getContext("2d",{willReadFrequently:!0}),this._resolution=Pl.defaultResolution??z.RESOLUTION,this._autoResolution=Pl.defaultAutoResolution,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=t,this.style=e,this.localStyleID=-1}static get experimentalLetterSpacing(){return wr.experimentalLetterSpacing}static set experimentalLetterSpacing(t){at("7.1.0","Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"),wr.experimentalLetterSpacing=t}updateText(t){const e=this._style;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;this._font=this._style.toFontString();const i=this.context,s=wr.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),n=s.width,o=s.height,a=s.lines,l=s.lineHeight,h=s.lineWidths,c=s.maxLineWidth,u=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,n)+e.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,o)+e.padding*2)*this._resolution),i.scale(this._resolution,this._resolution),i.clearRect(0,0,this.canvas.width,this.canvas.height),i.font=this._font,i.lineWidth=e.strokeThickness,i.textBaseline=e.textBaseline,i.lineJoin=e.lineJoin,i.miterLimit=e.miterLimit;let d,f;const p=e.dropShadow?2:1;for(let m=0;m<p;++m){const g=e.dropShadow&&m===0,y=g?Math.ceil(Math.max(1,o)+e.padding*2):0,v=y*this._resolution;if(g){i.fillStyle="black",i.strokeStyle="black";const x=e.dropShadowColor,T=e.dropShadowBlur*this._resolution,P=e.dropShadowDistance*this._resolution;i.shadowColor=vt.shared.setValue(x).setAlpha(e.dropShadowAlpha).toRgbaString(),i.shadowBlur=T,i.shadowOffsetX=Math.cos(e.dropShadowAngle)*P,i.shadowOffsetY=Math.sin(e.dropShadowAngle)*P+v}else i.fillStyle=this._generateFillStyle(e,a,s),i.strokeStyle=e.stroke,i.shadowColor="black",i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0;let _=(l-u.fontSize)/2;l-u.fontSize<0&&(_=0);for(let x=0;x<a.length;x++)d=e.strokeThickness/2,f=e.strokeThickness/2+x*l+u.ascent+_,e.align==="right"?d+=c-h[x]:e.align==="center"&&(d+=(c-h[x])/2),e.stroke&&e.strokeThickness&&this.drawLetterSpacing(a[x],d+e.padding,f+e.padding-y,!0),e.fill&&this.drawLetterSpacing(a[x],d+e.padding,f+e.padding-y)}this.updateTexture()}drawLetterSpacing(t,e,i,s=!1){const n=this._style.letterSpacing;let o=!1;if(wr.experimentalLetterSpacingSupported&&(wr.experimentalLetterSpacing?(this.context.letterSpacing=`${n}px`,this.context.textLetterSpacing=`${n}px`,o=!0):(this.context.letterSpacing="0px",this.context.textLetterSpacing="0px")),n===0||o){s?this.context.strokeText(t,e,i):this.context.fillText(t,e,i);return}let a=e;const l=wr.graphemeSegmenter(t);let h=this.context.measureText(t).width,c=0;for(let u=0;u<l.length;++u){const d=l[u];s?this.context.strokeText(d,a,i):this.context.fillText(d,a,i);let f="";for(let p=u+1;p<l.length;++p)f+=l[p];c=this.context.measureText(f).width,a+=h-c+n,h=c}}updateTexture(){const t=this.canvas;if(this._style.trim){const o=iv(t);o.data&&(t.width=o.width,t.height=o.height,this.context.putImageData(o.data,0,0))}const e=this._texture,i=this._style,s=i.trim?0:i.padding,n=e.baseTexture;e.trim.width=e._frame.width=t.width/this._resolution,e.trim.height=e._frame.height=t.height/this._resolution,e.trim.x=-s,e.trim.y=-s,e.orig.width=e._frame.width-s*2,e.orig.height=e._frame.height-s*2,this._onTextureUpdate(),n.setRealSize(t.width,t.height,this._resolution),e.updateUvs(),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}updateTransform(){this.updateText(!0),super.updateTransform()}getBounds(t,e){return this.updateText(!0),this._textureID===-1&&(t=!1),super.getBounds(t,e)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds.call(this,t)}_calculateBounds(){this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_generateFillStyle(t,e,i){const s=t.fill;if(Array.isArray(s)){if(s.length===1)return s[0]}else return s;let n;const o=t.dropShadow?t.dropShadowDistance:0,a=t.padding||0,l=this.canvas.width/this._resolution-o-a*2,h=this.canvas.height/this._resolution-o-a*2,c=s.slice(),u=t.fillGradientStops.slice();if(!u.length){const d=c.length+1;for(let f=1;f<d;++f)u.push(f/d)}if(c.unshift(s[0]),u.unshift(0),c.push(s[s.length-1]),u.push(1),t.fillGradientType===$n.LINEAR_VERTICAL){n=this.context.createLinearGradient(l/2,a,l/2,h+a);const d=i.fontProperties.fontSize+t.strokeThickness;for(let f=0;f<e.length;f++){const p=i.lineHeight*(f-1)+d,m=i.lineHeight*f;let g=m;f>0&&p>m&&(g=(m+p)/2);const y=m+d,v=i.lineHeight*(f+1);let _=y;f+1<e.length&&v<y&&(_=(y+v)/2);const x=(_-g)/h;for(let T=0;T<c.length;T++){let P=0;typeof u[T]=="number"?P=u[T]:P=T/c.length;let I=Math.min(1,Math.max(0,g/h+P*x));I=Number(I.toFixed(5)),n.addColorStop(I,c[T])}}}else{n=this.context.createLinearGradient(a,h/2,l+a,h/2);const d=c.length+1;let f=1;for(let p=0;p<c.length;p++){let m;typeof u[p]=="number"?m=u[p]:m=f/d,n.addColorStop(m,c[p]),f++}}return n}destroy(t){typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Nb,t),super.destroy(t),this._ownCanvas&&(this.canvas.height=this.canvas.width=0),this.context=null,this.canvas=null,this._style=null}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this.updateText(!0);const e=gr(this.scale.x)||1;this.scale.x=e*t/this._texture.orig.width,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this.updateText(!0);const e=gr(this.scale.y)||1;this.scale.y=e*t/this._texture.orig.height,this._height=t}get style(){return this._style}set style(t){t=t||{},t instanceof Er?this._style=t:this._style=new Er(t),this.localStyleID=-1,this.dirty=!0}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}};Yd.defaultAutoResolution=!0;let qd=Yd;class Ub{constructor(t){this.maxItemsPerFrame=t,this.itemsLeft=0}beginFrame(){this.itemsLeft=this.maxItemsPerFrame}allowedToUpload(){return this.itemsLeft-- >0}}function kb(r,t){var i;let e=!1;if((i=r==null?void 0:r._textures)!=null&&i.length){for(let s=0;s<r._textures.length;s++)if(r._textures[s]instanceof Y){const n=r._textures[s].baseTexture;t.includes(n)||(t.push(n),e=!0)}}return e}function Gb(r,t){if(r.baseTexture instanceof et){const e=r.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function $b(r,t){if(r._texture&&r._texture instanceof Y){const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function Hb(r,t){return t instanceof qd?(t.updateText(!0),!0):!1}function Xb(r,t){if(t instanceof Er){const e=t.toFontString();return wr.measureFont(e),!0}return!1}function Vb(r,t){if(r instanceof qd){t.includes(r.style)||t.push(r.style),t.includes(r)||t.push(r);const e=r._texture.baseTexture;return t.includes(e)||t.push(e),!0}return!1}function zb(r,t){return r instanceof Er?(t.includes(r)||t.push(r),!0):!1}const Kd=class Df{constructor(t){this.limiter=new Ub(Df.uploadsPerFrame),this.renderer=t,this.uploadHookHelper=null,this.queue=[],this.addHooks=[],this.uploadHooks=[],this.completes=[],this.ticking=!1,this.delayedTick=()=>{this.queue&&this.prepareItems()},this.registerFindHook(Vb),this.registerFindHook(zb),this.registerFindHook(kb),this.registerFindHook(Gb),this.registerFindHook($b),this.registerUploadHook(Hb),this.registerUploadHook(Xb)}upload(t){return new Promise(e=>{t&&this.add(t),this.queue.length?(this.completes.push(e),this.ticking||(this.ticking=!0,ae.system.addOnce(this.tick,this,Wr.UTILITY))):e()})}tick(){setTimeout(this.delayedTick,0)}prepareItems(){for(this.limiter.beginFrame();this.queue.length&&this.limiter.allowedToUpload();){const t=this.queue[0];let e=!1;if(t&&!t._destroyed){for(let i=0,s=this.uploadHooks.length;i<s;i++)if(this.uploadHooks[i](this.uploadHookHelper,t)){this.queue.shift(),e=!0;break}}e||this.queue.shift()}if(this.queue.length)ae.system.addOnce(this.tick,this,Wr.UTILITY);else{this.ticking=!1;const t=this.completes.slice(0);this.completes.length=0;for(let e=0,i=t.length;e<i;e++)t[e]()}}registerFindHook(t){return t&&this.addHooks.push(t),this}registerUploadHook(t){return t&&this.uploadHooks.push(t),this}add(t){for(let e=0,i=this.addHooks.length;e<i&&!this.addHooks[e](t,this.queue);e++);if(t instanceof xe)for(let e=t.children.length-1;e>=0;e--)this.add(t.children[e]);return this}destroy(){this.ticking&&ae.system.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null,this.limiter=null,this.uploadHookHelper=null}};Kd.uploadsPerFrame=4;let fl=Kd;Object.defineProperties(z,{UPLOADS_PER_FRAME:{get(){return fl.uploadsPerFrame},set(r){at("7.1.0","settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"),fl.uploadsPerFrame=r}}});function Zd(r,t){return t instanceof et?(t._glTextures[r.CONTEXT_UID]||r.texture.bind(t),!0):!1}function Wb(r,t){if(!(t instanceof gs))return!1;const{geometry:e}=t;t.finishPoly(),e.updateBatches();const{batches:i}=e;for(let s=0;s<i.length;s++){const{texture:n}=i[s].style;n&&Zd(r,n.baseTexture)}return e.batchable||r.geometry.bind(e,t._resolveDirectShader(r)),!0}function jb(r,t){return r instanceof gs?(t.push(r),!0):!1}class Jd extends fl{constructor(t){super(t),this.uploadHookHelper=this.renderer,this.registerFindHook(jb),this.registerUploadHook(Zd),this.registerUploadHook(Wb)}}Jd.extension={name:"prepare",type:X.RendererSystem},j.add(Jd);var Yb=`#version 300 es
|
|
970
970
|
#define SHADER_NAME Tiling-Sprite-100
|
|
971
971
|
|
|
972
972
|
precision lowp float;
|
|
@@ -1080,7 +1080,7 @@ void main(void)
|
|
|
1080
1080
|
vec4 texSample = texture2D(uSampler, vTextureCoord);
|
|
1081
1081
|
gl_FragColor = texSample * uColor;
|
|
1082
1082
|
}
|
|
1083
|
-
`;const Xn=new wt;class tf extends yn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Ou,this.state=$e.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=He.from(Qd,Zb,e),this.shader=t.context.webGLVersion>1?He.from(qb,Yb,e):He.from(Qd,Kb,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==dr.CLAMP:l.wrapMode===dr.CLAMP&&(l.wrapMode=dr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,g=t._width,y=t._height;Xn.set(c.a*p/g,c.b*p/y,c.c*m/g,c.d*m/y,c.tx/g,c.ty/y),Xn.invert(),d?Xn.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=Xn.toArray(!0),f.uniforms.uColor=vt.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=au(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}tf.extension={name:"tilingSprite",type:$.RendererPlugin},Y.add(tf);const ef=class ws{constructor(t,e,i){this.linkedSheets=[],(t instanceof et||t instanceof q)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=s instanceof q?s:null,this.baseTexture=s instanceof et?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const l=this.baseTexture.resource;this.resolution=this._updateResolution(o||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=nr(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ws.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=ws.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new it(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new it(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new it(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new it(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new q(this.baseTexture,a,c,l,n.rotated?2:0,n.anchor,n.borders),q.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*ws.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ws.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};ef.BATCH_SIZE=1e3;let rf=ef;const Jb=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function sf(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=kt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,sf([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const Qb={extension:$.Asset,cache:{test:r=>r instanceof rf,getCacheableAssets:(r,t)=>sf(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&Jb.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=W.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:$.LoadParser,priority:Ee.Normal},async testParse(r,t){return kt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var c,u;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=kt.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=Ja(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new rf({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(c=r==null?void 0:r.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let m=o+p;(u=t.data)!=null&&u.ignoreMultiPack||(m=Ja(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);l.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==p))})}return l},unload(r){r.destroy(!0)}}};Y.add(Qb);class Vn{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class zn{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const c=a[h].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[u]=p}i[o].push(l)}const s=new Vn;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class pl{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Vn,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class ml{static test(t){return typeof t=="string"&&t.includes("<font>")?pl.test(W.ADAPTER.parseXML(t)):!1}static parse(t){return pl.parse(W.ADAPTER.parseXML(t))}}const gl=[zn,pl,ml];function tw(r){for(let t=0;t<gl.length;t++)if(gl[t].test(r))return gl[t];return null}function ew(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,c=r.width/i-l-h*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let m=1;m<p;++m)f.push(m/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===$n.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let g=0;g<s.length;g++){const y=n.lineHeight*g;for(let x=0;x<d.length;x++){let _=0;typeof f[x]=="number"?_=f[x]:_=x/d.length;const v=y/u+_*m;let w=Math.max(p,v);w=Math.min(w,1),a.addColorStop(w,d[x]),p=w}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let m=1;for(let g=0;g<d.length;g++){let y;typeof f[g]=="number"?y=f[g]:y=m/p,a.addColorStop(y,d[g]),m++}}return a}function rw(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,c=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=ew(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=vt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Wn(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function nf(r){return Array.from?Array.from(r):r.split("")}function iw(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...nf(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Tr=class je{constructor(t,e,i){var c;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=nr(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let u=0;u<t.page.length;u++){const{id:d,file:f}=t.page[u];h[d]=e instanceof Array?e[u]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=re.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=De.OFF)}for(let u=0;u<t.char.length;u++){const{id:d,page:f}=t.char[u];let{x:p,y:m,width:g,height:y,xoffset:x,yoffset:_,xadvance:v}=t.char[u];p/=l,m/=l,g/=l,y/=l,x/=l,_/=l,v/=l;const w=new it(p+h[f].frame.x/l,m+h[f].frame.y/l,g,y);this.chars[d]={xOffset:x,yOffset:_,xAdvance:v,kerning:{},texture:new q(h[f].baseTexture,w),page:f}}for(let u=0;u<t.kerning.length;u++){let{first:d,second:f,amount:p}=t.kerning[u];d/=l,f/=l,p/=l,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((c=a==null?void 0:a.fieldType)==null?void 0:c.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof Vn)s=t;else{const o=tw(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof q&&(e=[e]);const n=new je(s,e,i);return je.available[n.font]=n,n}static uninstall(t){const e=je.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete je.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},je.defaultOptions,i),c=iw(s),u=e instanceof Er?e:new Er(e),d=a,f=new Vn;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,m=0,g,y,x,_=0;const v=[];for(let R=0;R<c.length;R++){g||(g=W.ADAPTER.createCanvas(),g.width=a,g.height=l,y=g.getContext("2d"),x=new et(g,{resolution:o,...h}),v.push(new q(x)),f.page.push({id:v.length-1,file:""}));const C=c[R],b=wr.measureText(C,u,!1,g),T=b.width,I=Math.ceil(b.height),O=Math.ceil((u.fontStyle==="italic"?2:1)*T);if(m>=l-I*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${C}')`);--R,g=null,y=null,x=null,m=0,p=0,_=0;continue}if(_=Math.max(I+b.fontProperties.descent,_),O*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${C}')`);--R,m+=_*o,m=Math.ceil(m),p=0,_=0;continue}rw(g,y,b,p,m,o,u);const M=Wn(b.text);f.char.push({id:M,page:v.length-1,x:p/o,y:m/o,width:O,height:I,xoffset:0,yoffset:0,xadvance:T-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(O+2*n)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let R=0,C=c.length;R<C;R++){const b=c[R];for(let T=0;T<C;T++){const I=c[T],O=y.measureText(b).width,M=y.measureText(I).width,E=y.measureText(b+I).width-(O+M);E&&f.kerning.push({first:Wn(b),second:Wn(I),amount:E})}}const w=new je(f,v,!0);return je.available[t]!==void 0&&je.uninstall(t),je.available[t]=w,w}};Tr.ALPHA=[["a","z"],["A","Z"]," "],Tr.NUMERIC=[["0","9"]],Tr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Tr.ASCII=[[" ","~"]],Tr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Tr.ALPHANUMERIC},Tr.available={};let Ar=Tr;var sw=`// Pixi texture info\r
|
|
1083
|
+
`;const Xn=new wt;class tf extends yn{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new Ou,this.state=$e.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=He.from(Qd,Zb,e),this.shader=t.context.webGLVersion>1?He.from(qb,Yb,e):He.from(Qd,Kb,e)}render(t){const e=this.renderer,i=this.quad;let s=i.vertices;s[0]=s[6]=t._width*-t.anchor.x,s[1]=s[3]=t._height*-t.anchor.y,s[2]=s[4]=t._width*(1-t.anchor.x),s[5]=s[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;s=i.uvs,s[0]=s[6]=-n,s[1]=s[3]=-o,s[2]=s[4]=1-n,s[5]=s[7]=1-o,i.invalidate();const a=t._texture,l=a.baseTexture,h=l.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=l.isPowerOfTwo&&a.frame.width===l.width&&a.frame.height===l.height;d&&(l._glTextures[e.CONTEXT_UID]?d=l.wrapMode!==dr.CLAMP:l.wrapMode===dr.CLAMP&&(l.wrapMode=dr.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,m=a.height,g=t._width,y=t._height;Xn.set(c.a*p/g,c.b*p/y,c.c*m/g,c.d*m/y,c.tx/g,c.ty/y),Xn.invert(),d?Xn.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=Xn.toArray(!0),f.uniforms.uColor=vt.shared.setValue(t.tint).premultiply(t.worldAlpha,h).toArray(f.uniforms.uColor),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(i),this.state.blendMode=au(t.blendMode,h),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}tf.extension={name:"tilingSprite",type:X.RendererPlugin},j.add(tf);const ef=class Es{constructor(t,e,i){this.linkedSheets=[],(t instanceof et||t instanceof Y)&&(t={texture:t,data:e,resolutionFilename:i});const{texture:s,data:n,resolutionFilename:o=null,cachePrefix:a=""}=t;this.cachePrefix=a,this._texture=s instanceof Y?s:null,this.baseTexture=s instanceof et?s:this._texture.baseTexture,this.textures={},this.animations={},this.data=n;const l=this.baseTexture.resource;this.resolution=this._updateResolution(o||(l?l.url:null)),this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}_updateResolution(t=null){const{scale:e}=this.data.meta;let i=nr(t,null);return i===null&&(i=typeof e=="number"?e:parseFloat(e??"1")),i!==1&&this.baseTexture.setResolution(i),i}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Es.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=Es.BATCH_SIZE;for(;e-t<i&&e<this._frameKeys.length;){const s=this._frameKeys[e],n=this._frames[s],o=n.frame;if(o){let a=null,l=null;const h=n.trimmed!==!1&&n.sourceSize?n.sourceSize:n.frame,c=new it(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);n.rotated?a=new it(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):a=new it(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),n.trimmed!==!1&&n.spriteSourceSize&&(l=new it(Math.floor(n.spriteSourceSize.x)/this.resolution,Math.floor(n.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[s]=new Y(this.baseTexture,a,c,l,n.rotated?2:0,n.anchor,n.borders),Y.addToCache(this.textures[s],this.cachePrefix+s.toString())}e++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];this.animations[e].push(this.textures[s])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Es.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Es.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.baseTexture.destroy()),this._texture=null,this.baseTexture=null,this.linkedSheets=[]}};ef.BATCH_SIZE=1e3;let rf=ef;const Jb=["jpg","png","jpeg","avif","webp","s3tc","s3tc_sRGB","etc","etc1","pvrtc","atc","astc","bptc"];function sf(r,t,e){const i={};if(r.forEach(s=>{i[s]=t}),Object.keys(t.textures).forEach(s=>{i[`${t.cachePrefix}${s}`]=t.textures[s]}),!e){const s=kt.dirname(r[0]);t.linkedSheets.forEach((n,o)=>{Object.assign(i,sf([`${s}/${t.data.meta.related_multi_packs[o]}`],n,!0))})}return i}const Qb={extension:X.Asset,cache:{test:r=>r instanceof rf,getCacheableAssets:(r,t)=>sf(r,t,!1)},resolver:{test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&Jb.includes(i)},parse:r=>{var e;const t=r.split(".");return{resolution:parseFloat(((e=z.RETINA_PREFIX.exec(r))==null?void 0:e[1])??"1"),format:t[t.length-2],src:r}}},loader:{name:"spritesheetLoader",extension:{type:X.LoadParser,priority:Ee.Normal},async testParse(r,t){return kt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var c,u;const{texture:i,imageFilename:s,cachePrefix:n}=(t==null?void 0:t.data)??{};let o=kt.dirname(t.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let a;if(i&&i.baseTexture)a=i;else{const d=Ja(o+(s??r.meta.image),t.src);a=(await e.load([d]))[d]}const l=new rf({texture:a.baseTexture,data:r,resolutionFilename:t.src,cachePrefix:n});await l.parse();const h=(c=r==null?void 0:r.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const d=[];for(const p of h){if(typeof p!="string")continue;let m=o+p;(u=t.data)!=null&&u.ignoreMultiPack||(m=Ja(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);l.linkedSheets=f,f.forEach(p=>{p.linkedSheets=[l].concat(l.linkedSheets.filter(m=>m!==p))})}return l},unload(r){r.destroy(!0)}}};j.add(Qb);class Vn{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class zn{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),l={};for(const h in a){const c=a[h].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;l[u]=p}i[o].push(l)}const s=new Vn;return i.info.forEach(n=>s.info.push({face:n.face,size:parseInt(n.size,10)})),i.common.forEach(n=>s.common.push({lineHeight:parseInt(n.lineHeight,10)})),i.page.forEach(n=>s.page.push({id:parseInt(n.id,10),file:n.file})),i.char.forEach(n=>s.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),i.kerning.forEach(n=>s.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),i.distanceField.forEach(n=>s.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),s}}class pl{static test(t){const e=t;return typeof t!="string"&&"getElementsByTagName"in t&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new Vn,i=t.getElementsByTagName("info"),s=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),l=t.getElementsByTagName("distanceField");for(let h=0;h<i.length;h++)e.info.push({face:i[h].getAttribute("face"),size:parseInt(i[h].getAttribute("size"),10)});for(let h=0;h<s.length;h++)e.common.push({lineHeight:parseInt(s[h].getAttribute("lineHeight"),10)});for(let h=0;h<n.length;h++)e.page.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});for(let h=0;h<o.length;h++){const c=o[h];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xadvance"),10)})}for(let h=0;h<a.length;h++)e.kerning.push({first:parseInt(a[h].getAttribute("first"),10),second:parseInt(a[h].getAttribute("second"),10),amount:parseInt(a[h].getAttribute("amount"),10)});for(let h=0;h<l.length;h++)e.distanceField.push({fieldType:l[h].getAttribute("fieldType"),distanceRange:parseInt(l[h].getAttribute("distanceRange"),10)});return e}}class ml{static test(t){return typeof t=="string"&&t.includes("<font>")?pl.test(z.ADAPTER.parseXML(t)):!1}static parse(t){return pl.parse(z.ADAPTER.parseXML(t))}}const gl=[zn,pl,ml];function tw(r){for(let t=0;t<gl.length;t++)if(gl[t].test(r))return gl[t];return null}function ew(r,t,e,i,s,n){const o=e.fill;if(Array.isArray(o)){if(o.length===1)return o[0]}else return o;let a;const l=e.dropShadow?e.dropShadowDistance:0,h=e.padding||0,c=r.width/i-l-h*2,u=r.height/i-l-h*2,d=o.slice(),f=e.fillGradientStops.slice();if(!f.length){const p=d.length+1;for(let m=1;m<p;++m)f.push(m/p)}if(d.unshift(o[0]),f.unshift(0),d.push(o[o.length-1]),f.push(1),e.fillGradientType===$n.LINEAR_VERTICAL){a=t.createLinearGradient(c/2,h,c/2,u+h);let p=0;const m=(n.fontProperties.fontSize+e.strokeThickness)/u;for(let g=0;g<s.length;g++){const y=n.lineHeight*g;for(let v=0;v<d.length;v++){let _=0;typeof f[v]=="number"?_=f[v]:_=v/d.length;const x=y/u+_*m;let T=Math.max(p,x);T=Math.min(T,1),a.addColorStop(T,d[v]),p=T}}}else{a=t.createLinearGradient(h,u/2,c+h,u/2);const p=d.length+1;let m=1;for(let g=0;g<d.length;g++){let y;typeof f[g]=="number"?y=f[g]:y=m/p,a.addColorStop(y,d[g]),m++}}return a}function rw(r,t,e,i,s,n,o){const a=e.text,l=e.fontProperties;t.translate(i,s),t.scale(n,n);const h=o.strokeThickness/2,c=-(o.strokeThickness/2);if(t.font=o.toFontString(),t.lineWidth=o.strokeThickness,t.textBaseline=o.textBaseline,t.lineJoin=o.lineJoin,t.miterLimit=o.miterLimit,t.fillStyle=ew(r,t,o,n,[a],e),t.strokeStyle=o.stroke,o.dropShadow){const u=o.dropShadowColor,d=o.dropShadowBlur*n,f=o.dropShadowDistance*n;t.shadowColor=vt.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(),t.shadowBlur=d,t.shadowOffsetX=Math.cos(o.dropShadowAngle)*f,t.shadowOffsetY=Math.sin(o.dropShadowAngle)*f}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;o.stroke&&o.strokeThickness&&t.strokeText(a,h,c+e.lineHeight-l.descent),o.fill&&t.fillText(a,h,c+e.lineHeight-l.descent),t.setTransform(1,0,0,1,0,0),t.fillStyle="rgba(0, 0, 0, 0)"}function Wn(r){return r.codePointAt?r.codePointAt(0):r.charCodeAt(0)}function nf(r){return Array.from?Array.from(r):r.split("")}function iw(r){typeof r=="string"&&(r=[r]);const t=[];for(let e=0,i=r.length;e<i;e++){const s=r[e];if(Array.isArray(s)){if(s.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);const n=s[0].charCodeAt(0),o=s[1].charCodeAt(0);if(o<n)throw new Error("[BitmapFont]: Invalid character range.");for(let a=n,l=o;a<=l;a++)t.push(String.fromCharCode(a))}else t.push(...nf(s))}if(t.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return t}const Tr=class je{constructor(t,e,i){var c;const[s]=t.info,[n]=t.common,[o]=t.page,[a]=t.distanceField,l=nr(o.file),h={};this._ownsTextures=i,this.font=s.face,this.size=s.size,this.lineHeight=n.lineHeight/l,this.chars={},this.pageTextures=h;for(let u=0;u<t.page.length;u++){const{id:d,file:f}=t.page[u];h[d]=e instanceof Array?e[u]:e[f],a!=null&&a.fieldType&&a.fieldType!=="none"&&(h[d].baseTexture.alphaMode=re.NO_PREMULTIPLIED_ALPHA,h[d].baseTexture.mipmap=De.OFF)}for(let u=0;u<t.char.length;u++){const{id:d,page:f}=t.char[u];let{x:p,y:m,width:g,height:y,xoffset:v,yoffset:_,xadvance:x}=t.char[u];p/=l,m/=l,g/=l,y/=l,v/=l,_/=l,x/=l;const T=new it(p+h[f].frame.x/l,m+h[f].frame.y/l,g,y);this.chars[d]={xOffset:v,yOffset:_,xAdvance:x,kerning:{},texture:new Y(h[f].baseTexture,T),page:f}}for(let u=0;u<t.kerning.length;u++){let{first:d,second:f,amount:p}=t.kerning[u];d/=l,f/=l,p/=l,this.chars[f]&&(this.chars[f].kerning[d]=p)}this.distanceFieldRange=a==null?void 0:a.distanceRange,this.distanceFieldType=((c=a==null?void 0:a.fieldType)==null?void 0:c.toLowerCase())??"none"}destroy(){for(const t in this.chars)this.chars[t].texture.destroy(),this.chars[t].texture=null;for(const t in this.pageTextures)this._ownsTextures&&this.pageTextures[t].destroy(!0),this.pageTextures[t]=null;this.chars=null,this.pageTextures=null}static install(t,e,i){let s;if(t instanceof Vn)s=t;else{const o=tw(t);if(!o)throw new Error("Unrecognized data format for font.");s=o.parse(t)}e instanceof Y&&(e=[e]);const n=new je(s,e,i);return je.available[n.font]=n,n}static uninstall(t){const e=je.available[t];if(!e)throw new Error(`No font found named '${t}'`);e.destroy(),delete je.available[t]}static from(t,e,i){if(!t)throw new Error("[BitmapFont] Property `name` is required.");const{chars:s,padding:n,resolution:o,textureWidth:a,textureHeight:l,...h}=Object.assign({},je.defaultOptions,i),c=iw(s),u=e instanceof Er?e:new Er(e),d=a,f=new Vn;f.info[0]={face:u.fontFamily,size:u.fontSize},f.common[0]={lineHeight:u.fontSize};let p=0,m=0,g,y,v,_=0;const x=[];for(let P=0;P<c.length;P++){g||(g=z.ADAPTER.createCanvas(),g.width=a,g.height=l,y=g.getContext("2d"),v=new et(g,{resolution:o,...h}),x.push(new Y(v)),f.page.push({id:x.length-1,file:""}));const I=c[P],b=wr.measureText(I,u,!1,g),E=b.width,S=Math.ceil(b.height),D=Math.ceil((u.fontStyle==="italic"?2:1)*E);if(m>=l-S*o){if(m===0)throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${I}')`);--P,g=null,y=null,v=null,m=0,p=0,_=0;continue}if(_=Math.max(S+b.fontProperties.descent,_),D*o+p>=d){if(p===0)throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${I}')`);--P,m+=_*o,m=Math.ceil(m),p=0,_=0;continue}rw(g,y,b,p,m,o,u);const B=Wn(b.text);f.char.push({id:B,page:x.length-1,x:p/o,y:m/o,width:D,height:S,xoffset:0,yoffset:0,xadvance:E-(u.dropShadow?u.dropShadowDistance:0)-(u.stroke?u.strokeThickness:0)}),p+=(D+2*n)*o,p=Math.ceil(p)}if(!(i!=null&&i.skipKerning))for(let P=0,I=c.length;P<I;P++){const b=c[P];for(let E=0;E<I;E++){const S=c[E],D=y.measureText(b).width,B=y.measureText(S).width,w=y.measureText(b+S).width-(D+B);w&&f.kerning.push({first:Wn(b),second:Wn(S),amount:w})}}const T=new je(f,x,!0);return je.available[t]!==void 0&&je.uninstall(t),je.available[t]=T,T}};Tr.ALPHA=[["a","z"],["A","Z"]," "],Tr.NUMERIC=[["0","9"]],Tr.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],Tr.ASCII=[[" ","~"]],Tr.defaultOptions={resolution:1,textureWidth:512,textureHeight:512,padding:4,chars:Tr.ALPHANUMERIC},Tr.available={};let Ar=Tr;var sw=`// Pixi texture info\r
|
|
1084
1084
|
varying vec2 vTextureCoord;\r
|
|
1085
1085
|
uniform sampler2D uSampler;\r
|
|
1086
1086
|
\r
|
|
@@ -1134,15 +1134,15 @@ void main(void)\r
|
|
|
1134
1134
|
\r
|
|
1135
1135
|
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
|
|
1136
1136
|
}\r
|
|
1137
|
-
`;const of=[],af=[],lf=[],ow=class Of extends xe{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Of.styleDefaults,e);if(!Ar.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new vt(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new or(()=>{this.dirty=!0},this,0,0),this._roundPixels=
|
|
1138
|
-
`)||" ",h=nf(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?of:af;let d=null,f=0,p=0,m=0,g=-1,y=0,
|
|
1139
|
-
`){o.push(f),a.push(-1),p=Math.max(p,f),++m,++
|
|
1140
|
-
`&&(/(?:\s)/.test(
|
|
1137
|
+
`;const of=[],af=[],lf=[],ow=class Of extends xe{constructor(t,e={}){super();const{align:i,tint:s,maxWidth:n,letterSpacing:o,fontName:a,fontSize:l}=Object.assign({},Of.styleDefaults,e);if(!Ar.available[a])throw new Error(`Missing BitmapFont "${a}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=i,this._tintColor=new vt(s),this._font=void 0,this._fontName=a,this._fontSize=l,this.text=t,this._maxWidth=n,this._maxLineHeight=0,this._letterSpacing=o,this._anchor=new or(()=>{this.dirty=!0},this,0,0),this._roundPixels=z.ROUND_PIXELS,this.dirty=!0,this._resolution=z.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var D;const t=Ar.available[this._fontName],e=this.fontSize,i=e/t.size,s=new dt,n=[],o=[],a=[],l=this._text.replace(/(?:\r\n|\r)/g,`
|
|
1138
|
+
`)||" ",h=nf(l),c=this._maxWidth*t.size/e,u=t.distanceFieldType==="none"?of:af;let d=null,f=0,p=0,m=0,g=-1,y=0,v=0,_=0,x=0;for(let B=0;B<h.length;B++){const w=h[B],C=Wn(w);if(/(?:\s)/.test(w)&&(g=B,y=f,x++),w==="\r"||w===`
|
|
1139
|
+
`){o.push(f),a.push(-1),p=Math.max(p,f),++m,++v,s.x=0,s.y+=t.lineHeight,d=null,x=0;continue}const F=t.chars[C];if(!F)continue;d&&F.kerning[d]&&(s.x+=F.kerning[d]);const k=lf.pop()||{texture:Y.EMPTY,line:0,charCode:0,prevSpaces:0,position:new dt};k.texture=F.texture,k.line=m,k.charCode=C,k.position.x=Math.round(s.x+F.xOffset+this._letterSpacing/2),k.position.y=Math.round(s.y+F.yOffset),k.prevSpaces=x,n.push(k),f=k.position.x+Math.max(F.xAdvance-F.xOffset,F.texture.orig.width),s.x+=F.xAdvance+this._letterSpacing,_=Math.max(_,F.yOffset+F.texture.height),d=C,g!==-1&&c>0&&s.x>c&&(++v,Ti(n,1+g-v,1+B-g),B=g,g=-1,o.push(y),a.push(n.length>0?n[n.length-1].prevSpaces:0),p=Math.max(p,y),m++,s.x=0,s.y+=t.lineHeight,d=null,x=0)}const T=h[h.length-1];T!=="\r"&&T!==`
|
|
1140
|
+
`&&(/(?:\s)/.test(T)&&(f=y),o.push(f),p=Math.max(p,f),a.push(-1));const P=[];for(let B=0;B<=m;B++){let w=0;this._align==="right"?w=p-o[B]:this._align==="center"?w=(p-o[B])/2:this._align==="justify"&&(w=a[B]<0?0:(p-o[B])/a[B]),P.push(w)}const I=n.length,b={},E=[],S=this._activePagesMeshData;u.push(...S);for(let B=0;B<I;B++){const w=n[B].texture,C=w.baseTexture.uid;if(!b[C]){let F=u.pop();if(!F){const G=new Rb;let $,nt;t.distanceFieldType==="none"?($=new Vd(Y.EMPTY),nt=Z.NORMAL):($=new Vd(Y.EMPTY,{program:ar.from(nw,sw),uniforms:{uFWidth:0}}),nt=Z.NORMAL_NPM);const R=new Xd(G,$);R.blendMode=nt,F={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:R,vertices:null,uvs:null,indices:null}}F.index=0,F.indexCount=0,F.vertexCount=0,F.uvsCount=0,F.total=0;const{_textureCache:k}=this;k[C]=k[C]||new Y(w.baseTexture),F.mesh.texture=k[C],F.mesh.tint=this._tintColor.value,E.push(F),b[C]=F}b[C].total++}for(let B=0;B<S.length;B++)E.includes(S[B])||this.removeChild(S[B].mesh);for(let B=0;B<E.length;B++)E[B].mesh.parent!==this&&this.addChild(E[B].mesh);this._activePagesMeshData=E;for(const B in b){const w=b[B],C=w.total;if(!(((D=w.indices)==null?void 0:D.length)>6*C)||w.vertices.length<Xd.BATCHABLE_SIZE*2)w.vertices=new Float32Array(4*2*C),w.uvs=new Float32Array(4*2*C),w.indices=new Uint16Array(6*C);else{const F=w.total,k=w.vertices;for(let G=F*4*2;G<k.length;G++)k[G]=0}w.mesh.size=6*C}for(let B=0;B<I;B++){const w=n[B];let C=w.position.x+P[w.line]*(this._align==="justify"?w.prevSpaces:1);this._roundPixels&&(C=Math.round(C));const F=C*i,k=w.position.y*i,G=w.texture,$=b[G.baseTexture.uid],nt=G.frame,R=G._uvs,L=$.index++;$.indices[L*6+0]=0+L*4,$.indices[L*6+1]=1+L*4,$.indices[L*6+2]=2+L*4,$.indices[L*6+3]=0+L*4,$.indices[L*6+4]=2+L*4,$.indices[L*6+5]=3+L*4,$.vertices[L*8+0]=F,$.vertices[L*8+1]=k,$.vertices[L*8+2]=F+nt.width*i,$.vertices[L*8+3]=k,$.vertices[L*8+4]=F+nt.width*i,$.vertices[L*8+5]=k+nt.height*i,$.vertices[L*8+6]=F,$.vertices[L*8+7]=k+nt.height*i,$.uvs[L*8+0]=R.x0,$.uvs[L*8+1]=R.y0,$.uvs[L*8+2]=R.x1,$.uvs[L*8+3]=R.y1,$.uvs[L*8+4]=R.x2,$.uvs[L*8+5]=R.y2,$.uvs[L*8+6]=R.x3,$.uvs[L*8+7]=R.y3}this._textWidth=p*i,this._textHeight=(s.y+t.lineHeight)*i;for(const B in b){const w=b[B];if(this.anchor.x!==0||this.anchor.y!==0){let G=0;const $=this._textWidth*this.anchor.x,nt=this._textHeight*this.anchor.y;for(let R=0;R<w.total;R++)w.vertices[G++]-=$,w.vertices[G++]-=nt,w.vertices[G++]-=$,w.vertices[G++]-=nt,w.vertices[G++]-=$,w.vertices[G++]-=nt,w.vertices[G++]-=$,w.vertices[G++]-=nt}this._maxLineHeight=_*i;const C=w.mesh.geometry.getBuffer("aVertexPosition"),F=w.mesh.geometry.getBuffer("aTextureCoord"),k=w.mesh.geometry.getIndex();C.data=w.vertices,F.data=w.uvs,k.data=w.indices,C.update(),F.update(),k.update()}for(let B=0;B<n.length;B++)lf.push(n[B]);this._font=t,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0);const{distanceFieldRange:e,distanceFieldType:i,size:s}=Ar.available[this._fontName];if(i!=="none"){const{a:n,b:o,c:a,d:l}=this.worldTransform,h=Math.sqrt(n*n+o*o),c=Math.sqrt(a*a+l*l),u=(Math.abs(h)+Math.abs(c))/2,d=this.fontSize/s,f=t._view.resolution;for(const p of this._activePagesMeshData)p.mesh.shader.uniforms.uFWidth=u*e*d*f}super._render(t)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const t=Ar.available[this._fontName];if(!t)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==t&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tintColor.value}set tint(t){if(this.tint!==t){this._tintColor.setValue(t);for(let e=0;e<this._activePagesMeshData.length;e++)this._activePagesMeshData[e].mesh.tint=t}}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.dirty=!0)}get fontName(){return this._fontName}set fontName(t){if(!Ar.available[t])throw new Error(`Missing BitmapFont "${t}"`);this._fontName!==t&&(this._fontName=t,this.dirty=!0)}get fontSize(){return this._fontSize??Ar.available[this._fontName].size}set fontSize(t){this._fontSize!==t&&(this._fontSize=t,this.dirty=!0)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get text(){return this._text}set text(t){t=String(t??""),this._text!==t&&(this._text=t,this.dirty=!0)}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth!==t&&(this._maxWidth=t,this.dirty=!0)}get maxLineHeight(){return this.validate(),this._maxLineHeight}get textWidth(){return this.validate(),this._textWidth}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.dirty=!0)}get roundPixels(){return this._roundPixels}set roundPixels(t){t!==this._roundPixels&&(this._roundPixels=t,this.dirty=!0)}get textHeight(){return this.validate(),this._textHeight}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}destroy(t){const{_textureCache:e}=this,i=Ar.available[this._fontName].distanceFieldType==="none"?of:af;i.push(...this._activePagesMeshData);for(const s of this._activePagesMeshData)this.removeChild(s.mesh);this._activePagesMeshData=[],i.filter(s=>e[s.mesh.texture.baseTexture.uid]).forEach(s=>{s.mesh.texture=Y.EMPTY});for(const s in e)e[s].destroy(),delete e[s];this._font=null,this._tintColor=null,this._textureCache=null,super.destroy(t)}};ow.styleDefaults={align:"left",tint:16777215,maxWidth:0,letterSpacing:0};const aw=[".xml",".fnt"],lw={extension:{type:X.LoadParser,priority:Ee.Normal},name:"loadBitmapFont",test(r){return aw.includes(kt.extname(r).toLowerCase())},async testParse(r){return zn.test(r)||ml.test(r)},async parse(r,t,e){const i=zn.test(r)?zn.parse(r):ml.parse(r),{src:s}=t,{page:n}=i,o=[];for(let h=0;h<n.length;++h){const c=n[h].file;let u=kt.join(kt.dirname(s),c);u=Ja(u,s),o.push(u)}const a=await e.load(o),l=o.map(h=>a[h]);return Ar.install(i,l,!0)},async load(r,t){return(await z.ADAPTER.fetch(r)).text()},unload(r){r.destroy()}};j.add(lw);const yl=class ki extends Er{constructor(){super(...arguments),this._fonts=[],this._overrides=[],this._stylesheet="",this.fontsDirty=!1}static from(t){return new ki(Object.keys(ki.defaultOptions).reduce((e,i)=>({...e,[i]:t[i]}),{}))}cleanFonts(){this._fonts.length>0&&(this._fonts.forEach(t=>{URL.revokeObjectURL(t.src),t.refs--,t.refs===0&&(t.fontFace&&document.fonts.delete(t.fontFace),delete ki.availableFonts[t.originalUrl])}),this.fontFamily="Arial",this._fonts.length=0,this.styleID++,this.fontsDirty=!0)}loadFont(t,e={}){const{availableFonts:i}=ki;if(i[t]){const s=i[t];return this._fonts.push(s),s.refs++,this.styleID++,this.fontsDirty=!0,Promise.resolve()}return z.ADAPTER.fetch(t).then(s=>s.blob()).then(async s=>new Promise((n,o)=>{const a=URL.createObjectURL(s),l=new FileReader;l.onload=()=>n([a,l.result]),l.onerror=o,l.readAsDataURL(s)})).then(async([s,n])=>{const o=Object.assign({family:kt.basename(t,kt.extname(t)),weight:"normal",style:"normal",display:"auto",src:s,dataSrc:n,refs:1,originalUrl:t,fontFace:null},e);i[t]=o,this._fonts.push(o),this.styleID++;const a=new FontFace(o.family,`url(${o.src})`,{weight:o.weight,style:o.style,display:o.display});o.fontFace=a,await a.load(),document.fonts.add(a),await document.fonts.ready,this.styleID++,this.fontsDirty=!0})}addOverride(...t){const e=t.filter(i=>!this._overrides.includes(i));e.length>0&&(this._overrides.push(...e),this.styleID++)}removeOverride(...t){const e=t.filter(i=>this._overrides.includes(i));e.length>0&&(this._overrides=this._overrides.filter(i=>!e.includes(i)),this.styleID++)}toCSS(t){return[`transform: scale(${t})`,"transform-origin: top left","display: inline-block",`color: ${this.normalizeColor(this.fill)}`,`font-size: ${this.fontSize}px`,`font-family: ${this.fontFamily}`,`font-weight: ${this.fontWeight}`,`font-style: ${this.fontStyle}`,`font-variant: ${this.fontVariant}`,`letter-spacing: ${this.letterSpacing}px`,`text-align: ${this.align}`,`padding: ${this.padding}px`,`white-space: ${this.whiteSpace}`,...this.lineHeight?[`line-height: ${this.lineHeight}px`]:[],...this.wordWrap?[`word-wrap: ${this.breakWords?"break-all":"break-word"}`,`max-width: ${this.wordWrapWidth}px`]:[],...this.strokeThickness?[`-webkit-text-stroke-width: ${this.strokeThickness}px`,`-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,`text-stroke-width: ${this.strokeThickness}px`,`text-stroke-color: ${this.normalizeColor(this.stroke)}`,"paint-order: stroke"]:[],...this.dropShadow?[this.dropShadowToCSS()]:[],...this._overrides].join(";")}toGlobalCSS(){return this._fonts.reduce((t,e)=>`${t}
|
|
1141
1141
|
@font-face {
|
|
1142
1142
|
font-family: "${e.family}";
|
|
1143
1143
|
src: url('${e.dataSrc}');
|
|
1144
1144
|
font-weight: ${e.weight};
|
|
1145
1145
|
font-style: ${e.style};
|
|
1146
1146
|
font-display: ${e.display};
|
|
1147
|
-
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=Z_(t)),typeof t=="number"?K_(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,Ui.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=W.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};yl.availableFonts={},yl.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let _l=yl;const jn=class ki extends Ci{constructor(t="",e={}){super(q.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=q.from(i,{scaleMode:W.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new it,s.trim=new it,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=ki.defaultMaxWidth,this.maxHeight=ki.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=ki.defaultAutoResolution,this._resolution=ki.defaultResolution??W.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(c=this._style)==null?void 0:c.toCSS(s)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},ki.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=gr(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=gr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof _l?(this.ownsStyle=!1,this._style=t):t instanceof Er?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=_l.from(t)):(this.ownsStyle=!0,this._style=new _l(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};jn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},jn.defaultMaxWidth=2024,jn.defaultMaxHeight=2024,jn.defaultAutoResolution=!0;const hw=1733608,cw=.25;let Sr=!1,Yn;const vl=r=>{const t={tint:r!=null&&r.fill?new vt(r.fill).toNumber():hw,alpha:(r==null?void 0:r.fillOpacity)===void 0?cw:Math.min(r.fillOpacity,1)},e={tint:(r==null?void 0:r.stroke)&&new vt(r.stroke).toNumber(),alpha:(r==null?void 0:r.strokeOpacity)===void 0?r!=null&&r.stroke?1:0:Math.min(r.strokeOpacity,1),lineWidth:r!=null&&r.stroke?(r==null?void 0:r.strokeWidth)||1:0};return{fillStyle:t,strokeStyle:e}},xl=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=vl(i),o=new ms;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new ms,l=n.lineWidth===1?1:n.lineWidth/Yn;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},uw=xl((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),dw=xl((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),fw=xl((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),hf=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},pw=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=hf(r);n!==Yn&&!Sr&&(Sr=!0,e.forEach(({stroke:u,strokeWidth:d})=>{const{lineStyle:f}=u.geometry.graphicsData[0];d>1?(Sr=!1,f.width=d/n,u.geometry.invalidate()):d===1&&!f.native&&(f.width=1,f.native=!0,u.geometry.invalidate())})),Yn=n;const o=Math.PI*r.viewport.getRotation()/180,a=-s.x*n,l=-s.y*n;let h,c;o>0&&o<=Math.PI/2?(h=s.height*n,c=0):o>Math.PI/2&&o<=Math.PI?(h=s.width*n,c=s.height*n):o>Math.PI&&o<=Math.PI*1.5?(h=0,c=s.width*n):(h=0,c=0),t.position.x=h+a*Math.cos(o)-l*Math.sin(o),t.position.y=c+a*Math.sin(o)+l*Math.cos(o),t.scale.set(n,n),t.rotation=o,i.render(t)},mw=(r,t)=>{const e=new ms,i=nd({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o;Yn=hf(r);const a=m=>{Sr=!1;const{selector:g}=m.target,y=typeof o=="function"?o(m):o;let x;g.type===bt.RECTANGLE?x=fw(e,g,y):g.type===bt.POLYGON?x=dw(e,g,y):g.type===bt.ELLIPSE?x=uw(e,g,y):console.warn(`Unsupported shape type: ${g.type}`),x&&s.set(m.id,{annotation:m,...x})},l=m=>{const g=s.get(m.id);g&&(s.delete(m.id),g.fill.destroy(),g.stroke.destroy())},h=(m,g)=>{Sr=!1;const y=s.get(m.id);y&&(s.delete(m.id),y.fill.destroy(),y.stroke.destroy(),a(g))},c=(m,g)=>{i.resize(m,g),i.render(e)},u=m=>{Sr=!1;const{children:g}=e;s.forEach(({fill:y,stroke:x,annotation:_})=>{const v=m?n.has(_.id)||m(_):!0;v&&!g.includes(y)?(e.addChild(y),e.addChild(x)):!v&&g.includes(y)&&(e.removeChild(y),e.removeChild(x))}),i.render(e)},d=m=>{const{selected:g}=m;n=new Set(g.map(y=>y.id))},f=m=>{if(typeof m=="function")s.forEach(({annotation:g,fill:y,stroke:x,strokeWidth:_},v)=>{_>1&&(Sr=!1);const{fillStyle:w,strokeStyle:R}=vl(m(g));y.tint=w.tint,y.alpha=w.alpha,x.tint=R.tint||16777215,x.alpha=R.alpha,s.set(g.id,{annotation:g,fill:y,stroke:x,strokeWidth:_})});else{const{fillStyle:g,strokeStyle:y}=vl(m);y.lineWidth>1&&(Sr=!1),s.forEach(({annotation:x,fill:_,stroke:v,strokeWidth:w},R)=>{_.tint=g.tint,_.alpha=g.alpha,v.tint=y.tint||16777215,v.alpha=y.alpha,s.set(x.id,{annotation:x,fill:_,stroke:v,strokeWidth:w})})}o=m,i.render(e)};return{addAnnotation:a,destroy:()=>i.destroy(),redraw:pw(r,e,s,i),removeAnnotation:l,resize:c,setFilter:u,setSelected:d,setStyle:f,updateAnnotation:h}};function gw(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t;const{store:h,hover:c,selection:u,viewport:d}=o;wo(r,c,w=>e(10,i=w)),wo(r,u,w=>e(7,s=w));const f=Us();let p,m;const g=w=>{const R=new jt.Point(w.x,w.y),{x:C,y:b}=l.viewport.pointFromPixel(R);return l.viewport.viewportToImageCoordinates(C,b)},y=w=>{const{x:R,y:C}=w.position;m={x:R,y:C}},x=w=>R=>{const{x:C,y:b}=g(new jt.Point(R.offsetX,R.offsetY)),T=h.getAt(C,b);T&&(!n||n(T))?(w.classList.add("hover"),i!==T.id&&c.set(T.id)):(w.classList.remove("hover"),i&&c.set(void 0))},_=w=>{const R=w.originalEvent,{x:C,y:b}=w.position,T=C-m.x,I=b-m.y;if(Math.sqrt(T*T+I*I)<5){const{x:M,y:E}=g(w.position),S=h.getAt(M,E);S?f("click",{originalEvent:R,annotation:S}):f("click",{originalEvent:R})}m=void 0};let v;return Ns(()=>{var O;const{offsetWidth:w,offsetHeight:R}=l.canvas,C=document.createElement("canvas");C.width=w,C.height=R,C.className="a9s-gl-canvas",(O=l.element.querySelector(".openseadragon-canvas"))==null||O.appendChild(C),e(6,p=mw(l,C));const b=x(C);C.addEventListener("pointermove",b),new ResizeObserver(M=>{try{const{width:E,height:S}=M[0].contentRect;C.width=E,C.height=S,p.resize(E,S)}catch{console.warn("WebGL canvas already disposed")}}).observe(C);const I=()=>{const M=l.viewport.getBounds();v=l.viewport.viewportToImageRectangle(M);const{x:E,y:S,width:L,height:k}=v,G=h.getIntersecting(E,S,L,k);d.set(G.map(H=>H.id))};return l.addHandler("canvas-press",y),l.addHandler("canvas-release",_),l.addHandler("update-viewport",p.redraw),l.addHandler("animation-finish",I),()=>{var M;C.removeEventListener("pointermove",b),l.removeHandler("canvas-press",y),l.removeHandler("canvas-release",_),l.removeHandler("update-viewport",p.redraw),l.removeHandler("animation-finish",I),p.destroy(),(M=C.parentNode)==null||M.removeChild(C)}}),h.observe(w=>{const{created:R,updated:C,deleted:b}=w.changes;if((R||[]).forEach(T=>p.addAnnotation(T)),(C||[]).forEach(({oldValue:T,newValue:I})=>p.updateAnnotation(T,I)),(b||[]).forEach(T=>p.removeAnnotation(T)),v){const{x:T,y:I,width:O,height:M}=v,E=h.getIntersecting(T,I,O,M);d.set(E.map(S=>S.id))}else d.set(h.all().map(T=>T.id));p.redraw()}),r.$$set=w=>{"filter"in w&&e(2,n=w.filter),"state"in w&&e(3,o=w.state),"style"in w&&e(4,a=w.style),"viewer"in w&&e(5,l=w.viewer)},r.$$.update=()=>{r.$$.dirty&68&&(p==null||p.setFilter(n)),r.$$.dirty&192&&(p==null||p.setSelected(s)),r.$$.dirty&80&&(p==null||p.setStyle(a))},[c,u,n,o,a,l,p,s]}class yw extends oe{constructor(t){super(),ne(this,t,gw,null,Qt,{filter:2,state:3,style:4,viewer:5})}}let qn;const _w=new Uint8Array(16);function vw(){if(!qn&&(qn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!qn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qn(_w)}const Wt=[];for(let r=0;r<256;++r)Wt.push((r+256).toString(16).slice(1));function xw(r,t=0){return Wt[r[t+0]]+Wt[r[t+1]]+Wt[r[t+2]]+Wt[r[t+3]]+"-"+Wt[r[t+4]]+Wt[r[t+5]]+"-"+Wt[r[t+6]]+Wt[r[t+7]]+"-"+Wt[r[t+8]]+Wt[r[t+9]]+"-"+Wt[r[t+10]]+Wt[r[t+11]]+Wt[r[t+12]]+Wt[r[t+13]]+Wt[r[t+14]]+Wt[r[t+15]]}const cf={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function bw(r,t,e){if(cf.randomUUID&&!t&&!r)return cf.randomUUID();r=r||{};const i=r.random||(r.rng||vw)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return xw(i)}var Fi=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Fi||{});const bl=(r,t)=>t,ww=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Ew={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};bl(Fi.ELLIPSE,Ew);const Tw={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};bl(Fi.POLYGON,Tw);const Aw={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};bl(Fi.RECTANGLE,Aw);function uf(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function df(r){let t,e;return t=new gs({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){qt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function Sw(r){let t,e,i,s,n,o,a,l,h,c,u,d=li(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=df(uf(r,d,m));const p=m=>ut(f[m],1,1,()=>{f[m]=null});return{c(){t=Et("polygon"),s=ge(),n=Et("polygon"),a=ge();for(let m=0;m<f.length;m+=1)f[m].c();l=ur(),P(t,"class","a9s-outer"),P(t,"style",e=r[1]?"display:none;":void 0),P(t,"points",i=r[4].points.map(ff).join(" ")),P(n,"class","a9s-inner a9s-shape-handle"),P(n,"style",r[1]),P(n,"points",o=r[4].points.map(pf).join(" "))},m(m,g){ct(m,t,g),ct(m,s,g),ct(m,n,g),ct(m,a,g);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,g);ct(m,l,g),h=!0,c||(u=[Xt(t,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Xt(n,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,g){if(r=m,(!h||g&2&&e!==(e=r[1]?"display:none;":void 0))&&P(t,"style",e),(!h||g&16&&i!==(i=r[4].points.map(ff).join(" ")))&&P(t,"points",i),(!h||g&2)&&P(n,"style",r[1]),(!h||g&16&&o!==(o=r[4].points.map(pf).join(" ")))&&P(n,"points",o),g&536){d=li(r[4].points);let y;for(y=0;y<d.length;y+=1){const x=uf(r,d,y);f[y]?(f[y].p(x,g),st(f[y],1)):(f[y]=df(x),f[y].c(),st(f[y],1),f[y].m(l.parentNode,l))}for(Je(),y=d.length;y<f.length;y+=1)p(y);Qe()}},i(m){if(!h){for(let g=0;g<d.length;g+=1)st(f[g]);h=!0}},o(m){f=f.filter(Boolean);for(let g=0;g<f.length;g+=1)ut(f[g]);h=!1},d(m){m&&(lt(t),lt(s),lt(n),lt(a),lt(l)),Eo(f,m),c=!1,qe(u)}}}function Cw(r){let t,e;return t=new gf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Sw,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}const ff=r=>r.join(","),pf=r=>r.join(",");function Iw(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const g=d.geometry;f==="SHAPE"?m=g.points.map(([x,_])=>[x+p[0],_+p[1]]):m=g.points.map(([x,_],v)=>f===`HANDLE-${v}`?[x+p[0],_+p[1]]:[x,_]);const y=ww(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Pw extends oe{constructor(t){super(),ne(this,t,Iw,Cw,Qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Rw="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Mw(r){let t,e,i,s,n,o;return{c(){t=Et("rect"),P(t,"class",e=Fs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),P(t,"x",i=r[0]-r[5]/2),P(t,"y",s=r[1]-r[5]/2),P(t,"width",r[5]),P(t,"height",r[5])},m(a,l){ct(a,t,l),n||(o=Xt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Fs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&P(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&P(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&P(t,"y",s),l&32&&P(t,"width",a[5]),l&32&&P(t,"height",a[5])},d(a){a&<(t),n=!1,o()}}}function Bw(r){let t,e,i,s,n,o,a,l,h;return{c(){t=Et("g"),e=Et("circle"),s=Et("rect"),P(e,"cx",r[0]),P(e,"cy",r[1]),P(e,"r",i=r[3]/r[2]),P(e,"class","a9s-touch-halo svelte-1sgkh33"),Ls(e,"touched",r[4]),P(s,"class",n=Fs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),P(s,"x",o=r[0]-r[5]/2),P(s,"y",a=r[1]-r[5]/2),P(s,"width",r[5]),P(s,"height",r[5]),P(t,"class","a9s-touch-handle")},m(c,u){ct(c,t,u),Ke(t,e),Ke(t,s),l||(h=[Xt(e,"pointerdown",r[10]),Xt(e,"pointerdown",r[6]),Xt(e,"pointerup",r[7]),Xt(s,"pointerdown",r[9]),Xt(s,"pointerdown",r[6]),Xt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&P(e,"cx",c[0]),u&2&&P(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&P(e,"r",i),u&16&&Ls(e,"touched",c[4]),u&256&&n!==(n=Fs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&P(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&P(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&P(s,"y",a),u&32&&P(s,"width",c[5]),u&32&&P(s,"height",c[5])},d(c){c&<(t),l=!1,qe(h)}}}function Dw(r){let t;function e(n,o){return Rw?Bw:Mw}let s=e()(r);return{c(){s.c(),t=ur()},m(n,o){s.m(n,o),ct(n,t,o)},p(n,[o]){s.p(n,o)},i:Me,o:Me,d(n){n&<(t),s.d(n)}}}function Ow(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){Ze.call(this,r,p)}function d(p){Ze.call(this,r,p)}function f(p){Ze.call(this,r,p)}return r.$$set=p=>{e(8,t=bo(bo({},t),Fh(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Fh(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class gs extends oe{constructor(t){super(),ne(this,t,Ow,Dw,Qt,{x:0,y:1,scale:2,radius:3})}}function Fw(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g,y,x,_,v,w,R,C,b,T,I,O,M,E,S,L,k,G,H,X,D,F,j,nt,Q,V,_t,Tt;return H=new gs({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),H.$on("pointerdown",function(){qt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),D=new gs({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),D.$on("pointerdown",function(){qt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),j=new gs({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),j.$on("pointerdown",function(){qt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),Q=new gs({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),Q.$on("pointerdown",function(){qt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=Et("rect"),a=ge(),l=Et("rect"),f=ge(),p=Et("rect"),x=ge(),_=Et("rect"),C=ge(),b=Et("rect"),M=ge(),E=Et("rect"),G=ge(),te(H.$$.fragment),X=ge(),te(D.$$.fragment),F=ge(),te(j.$$.fragment),nt=ge(),te(Q.$$.fragment),P(t,"class","a9s-outer"),P(t,"style",e=r[1]?"display:none;":void 0),P(t,"x",i=r[4].x),P(t,"y",s=r[4].y),P(t,"width",n=r[4].w),P(t,"height",o=r[4].h),P(l,"class","a9s-inner a9s-shape-handle"),P(l,"style",r[1]),P(l,"x",h=r[4].x),P(l,"y",c=r[4].y),P(l,"width",u=r[4].w),P(l,"height",d=r[4].h),P(p,"class","a9s-edge-handle a9s-edge-handle-top"),P(p,"x",m=r[4].x),P(p,"y",g=r[4].y),P(p,"height",1),P(p,"width",y=r[4].w),P(_,"class","a9s-edge-handle a9s-edge-handle-right"),P(_,"x",v=r[4].x+r[4].w),P(_,"y",w=r[4].y),P(_,"height",R=r[4].h),P(_,"width",1),P(b,"class","a9s-edge-handle a9s-edge-handle-bottom"),P(b,"x",T=r[4].x),P(b,"y",I=r[4].y+r[4].h),P(b,"height",1),P(b,"width",O=r[4].w),P(E,"class","a9s-edge-handle a9s-edge-handle-left"),P(E,"x",S=r[4].x),P(E,"y",L=r[4].y),P(E,"height",k=r[4].h),P(E,"width",1)},m(N,B){ct(N,t,B),ct(N,a,B),ct(N,l,B),ct(N,f,B),ct(N,p,B),ct(N,x,B),ct(N,_,B),ct(N,C,B),ct(N,b,B),ct(N,M,B),ct(N,E,B),ct(N,G,B),Kt(H,N,B),ct(N,X,B),Kt(D,N,B),ct(N,F,B),Kt(j,N,B),ct(N,nt,B),Kt(Q,N,B),V=!0,_t||(Tt=[Xt(t,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Xt(l,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Xt(p,"pointerdown",function(){qt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Xt(_,"pointerdown",function(){qt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Xt(b,"pointerdown",function(){qt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Xt(E,"pointerdown",function(){qt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(N,B){r=N,(!V||B&2&&e!==(e=r[1]?"display:none;":void 0))&&P(t,"style",e),(!V||B&16&&i!==(i=r[4].x))&&P(t,"x",i),(!V||B&16&&s!==(s=r[4].y))&&P(t,"y",s),(!V||B&16&&n!==(n=r[4].w))&&P(t,"width",n),(!V||B&16&&o!==(o=r[4].h))&&P(t,"height",o),(!V||B&2)&&P(l,"style",r[1]),(!V||B&16&&h!==(h=r[4].x))&&P(l,"x",h),(!V||B&16&&c!==(c=r[4].y))&&P(l,"y",c),(!V||B&16&&u!==(u=r[4].w))&&P(l,"width",u),(!V||B&16&&d!==(d=r[4].h))&&P(l,"height",d),(!V||B&16&&m!==(m=r[4].x))&&P(p,"x",m),(!V||B&16&&g!==(g=r[4].y))&&P(p,"y",g),(!V||B&16&&y!==(y=r[4].w))&&P(p,"width",y),(!V||B&16&&v!==(v=r[4].x+r[4].w))&&P(_,"x",v),(!V||B&16&&w!==(w=r[4].y))&&P(_,"y",w),(!V||B&16&&R!==(R=r[4].h))&&P(_,"height",R),(!V||B&16&&T!==(T=r[4].x))&&P(b,"x",T),(!V||B&16&&I!==(I=r[4].y+r[4].h))&&P(b,"y",I),(!V||B&16&&O!==(O=r[4].w))&&P(b,"width",O),(!V||B&16&&S!==(S=r[4].x))&&P(E,"x",S),(!V||B&16&&L!==(L=r[4].y))&&P(E,"y",L),(!V||B&16&&k!==(k=r[4].h))&&P(E,"height",k);const xt={};B&16&&(xt.x=r[4].x),B&16&&(xt.y=r[4].y),B&8&&(xt.scale=r[3]),H.$set(xt);const ft={};B&16&&(ft.x=r[4].x+r[4].w),B&16&&(ft.y=r[4].y),B&8&&(ft.scale=r[3]),D.$set(ft);const gt={};B&16&&(gt.x=r[4].x+r[4].w),B&16&&(gt.y=r[4].y+r[4].h),B&8&&(gt.scale=r[3]),j.$set(gt);const yt={};B&16&&(yt.x=r[4].x),B&16&&(yt.y=r[4].y+r[4].h),B&8&&(yt.scale=r[3]),Q.$set(yt)},i(N){V||(st(H.$$.fragment,N),st(D.$$.fragment,N),st(j.$$.fragment,N),st(Q.$$.fragment,N),V=!0)},o(N){ut(H.$$.fragment,N),ut(D.$$.fragment,N),ut(j.$$.fragment,N),ut(Q.$$.fragment,N),V=!1},d(N){N&&(lt(t),lt(a),lt(l),lt(f),lt(p),lt(x),lt(_),lt(C),lt(b),lt(M),lt(E),lt(G),lt(X),lt(F),lt(nt)),Zt(H,N),Zt(D,N),Zt(j,N),Zt(Q,N),_t=!1,qe(Tt)}}}function Lw(r){let t,e;return t=new gf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Fw,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function Nw(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[g,y]=[m.minX,m.minY],[x,_]=[m.maxX,m.maxY];const[v,w]=p;if(f==="SHAPE")g+=v,x+=v,y+=w,_+=w;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=w;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{_+=w;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=v;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{x+=v;break}}}const R=Math.min(g,x),C=Math.min(y,_),b=Math.abs(x-g),T=Math.abs(_-y);return{...d,geometry:{x:R,y:C,w:b,h:T,bounds:{minX:R,minY:C,maxX:R+b,maxY:C+T}}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Uw extends oe{constructor(t){super(),ne(this,t,Nw,Lw,Qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Fi.RECTANGLE,Fi.POLYGON;const kw=r=>({}),mf=r=>({grab:r[0]});function Gw(r){let t,e,i,s;const n=r[7].default,o=Rh(n,r,r[6],mf);return{c(){t=Et("g"),o&&o.c(),P(t,"class","a9s-annotation selected")},m(a,l){ct(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Xt(t,"pointerup",r[2]),Xt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Dh(o,n,a,a[6],e?Bh(n,a[6],l,kw):Oh(a[6]),mf)},i(a){e||(st(o,a),e=!0)},o(a){ut(o,a),e=!1},d(a){a&<(t),o&&o.d(a),i=!1,qe(s)}}}function $w(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Us();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>g=>{h=m,c=l.elementToImage(g.offsetX,g.offsetY),u=o,g.target.setPointerCapture(g.pointerId),n("grab",g)},f=m=>{if(h){const[g,y]=l.elementToImage(m.offsetX,m.offsetY),x=[g-c[0],y-c[1]];e(3,o=a(u,h,x)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class gf extends oe{constructor(t){super(),ne(this,t,$w,Gw,Qt,{shape:3,editor:4,transform:5})}}const Hw=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s}=e;let n="";return i&&(n+=`fill:${i};stroke:${i};`),n+=`fill-opacity:${s||"0.25"};`,n}};function Xw(r,t,e){let i;const s=Us();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Ns(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&(i=Hw(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c})},[n,o,a,l,h,c,u]}class Vw extends oe{constructor(t){super(),ne(this,t,Xw,null,Qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}navigator.userAgent.indexOf("Mac OS X");const zw=r=>({transform:r&2,scale:r&1}),yf=r=>({transform:r[1],scale:r[0]});function Ww(r){let t;const e=r[4].default,i=Rh(e,r,r[3],yf);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Dh(i,e,s,s[3],t?Bh(e,s[3],n,zw):Oh(s[3]),yf)},i(s){t||(st(i,s),t=!0)},o(s){ut(i,s),t=!1},d(s){i&&i.d(s)}}}function jw(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,c=n.viewport.getZoom(!0),u=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new jt.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/n.world.getContentFactor(),p=u?-f:f,m=n.viewport.getRotation();e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=c*h/n.world.getContentFactor())};return Ns(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class _f extends oe{constructor(t){super(),ne(this,t,jw,Ww,Qt,{viewer:2})}}function Yw(r,t,e){const i=Us();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,c;return Ns(()=>{const u=n.closest("svg"),d=[],f=(p,m,g)=>{if(u==null||u.addEventListener(p,m,g),d.push(()=>u==null?void 0:u.removeEventListener(p,m,g)),p==="pointerup"||p==="dblclick"){const y=_=>{const{originalEvent:v}=_;m(v)},x=p==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(x,y),d.push(()=>l.removeHandler(x,y))}else if(p==="pointermove"){const y=x=>{const{originalEvent:_}=x;m(_)};l.addHandler("canvas-drag",y),d.push(()=>l.removeHandler("canvas-drag",y))}};return e(6,c=new o({target:n,props:{addEventListener:f,drawingMode:s,transform:a,viewportScale:h}})),c.$on("create",p=>i("create",p.detail)),()=>{d.forEach(p=>p()),c.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewer"in u&&e(4,l=u.viewer),"viewportScale"in u&&e(5,h=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&c&&c.$set({transform:a}),r.$$.dirty&96&&c&&c.$set({viewportScale:h})},[s,n,o,a,l,h,c]}class qw extends oe{constructor(t){super(),ne(this,t,Yw,null,Qt,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function vf(r,t,e){const i=r.slice();return i[29]=t[e],i}function Kw(r){let t=r[2],e,i,s=xf(r);return{c(){s.c(),e=ur()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&4&&Qt(t,t=n[2])?(Je(),ut(s,1,1,Me),Qe(),s=xf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&<(e),s.d(n)}}}function Zw(r){let t,e,i=li(r[6]),s=[];for(let o=0;o<i.length;o+=1)s[o]=wf(vf(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ur()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a[0]&268459618){i=li(o[6]);let l;for(l=0;l<i.length;l+=1){const h=vf(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=wf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(Je(),l=i.length;l<s.length;l+=1)n(l);Qe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&<(t),Eo(s,o)}}}function xf(r){let t,e;return t=new qw({props:{target:r[5],tool:r[7],drawingMode:r[4],transform:{elementToImage:r[9]},viewer:r[3],viewportScale:r[28]}}),t.$on("create",r[13]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&128&&(n.tool=i[7]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[0]&268435456&&(n.viewportScale=i[28]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function bf(r){let t,e;return t=new Vw({props:{target:r[5],editor:r[14](r[29].target.selector),annotation:r[29],style:r[1],transform:{elementToImage:r[9]},viewportScale:r[28]}}),t.$on("grab",r[10]),t.$on("change",function(){qt(r[12](r[29]))&&r[12](r[29]).apply(this,arguments)}),t.$on("release",r[11]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&64&&(n.editor=r[14](r[29].target.selector)),s[0]&64&&(n.annotation=r[29]),s[0]&2&&(n.style=r[1]),s[0]&268435456&&(n.viewportScale=r[28]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function wf(r){let t=r[29].id,e,i,s=bf(r);return{c(){s.c(),e=ur()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&64&&Qt(t,t=n[29].id)?(Je(),ut(s,1,1,Me),Qe(),s=bf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&<(e),s.d(n)}}}function Jw(r){let t,e,i,s,n,o;const a=[Zw,Kw],l=[];function h(c,u){return c[5]&&c[6]?0:c[5]&&c[7]&&c[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=Et("svg"),e=Et("g"),s&&s.c(),P(e,"transform",n=r[27]),P(e,"class","svelte-190cqdf"),P(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),Ls(t,"drawing",r[0])},m(c,u){ct(c,t,u),Ke(t,e),~i&&l[i].m(e,null),r[21](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(s&&(Je(),ut(l[d],1,1,()=>{l[d]=null}),Qe()),~i?(s=l[i],s?s.p(c,u):(s=l[i]=a[i](c),s.c()),st(s,1),s.m(e,null)):s=null),(!o||u[0]&134217728&&n!==(n=c[27]))&&P(e,"transform",n),(!o||u[0]&1)&&Ls(t,"drawing",c[0])},i(c){o||(st(s),o=!0)},o(c){ut(s),o=!1},d(c){c&<(t),~i&&l[i].d(),r[21](null)}}}function Qw(r){let t,e;return t=new _f({props:{viewer:r[3],$$slots:{default:[Jw,({transform:i,scale:s})=>({27:i,28:s}),({transform:i,scale:s})=>[(i?134217728:0)|(s?268435456:0)]]},$$scope:{ctx:r}}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&402653439|s[1]&2&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function tE(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:c}=t,{style:u=void 0}=t,{toolName:d=Ms()[0]}=t,{user:f}=t,{viewer:p}=t,m;const{store:g,selection:y,hover:x}=c;wo(r,y,S=>e(20,o=S));let _,v,w;const R=S=>{g.unobserve(_);const L=S.filter(({editable:k})=>k).map(({id:k})=>k);L.length>0?(e(6,v=L.map(k=>g.getAnnotation(k))),_=k=>{const{updated:G}=k.changes;e(6,v=(G||[]).map(H=>H.newValue))},g.observe(_,{annotations:L})):e(6,v=void 0)},C=(S,L)=>{const{x:k,y:G}=p.viewport.viewerElementToImageCoordinates(new jt.Point(S,L));return[k,G]},b=S=>{p.setMouseNavEnabled(!1),w=S.timeStamp},T=S=>{if(p.setMouseNavEnabled(!0),performance.now()-(w||0)<300){const{offsetX:k,offsetY:G}=S.detail,[H,X]=C(k,G),D=g.getAt(H,X);D&&(!l||l(D))&&!v.find(j=>j.id===D.id)&&(x.set(D.id),y.setSelected(D.id))}},I=S=>L=>{var X;const{target:k}=S,G=10*60*1e3,H=((X=k.creator)==null?void 0:X.id)!==f.id||!k.created||new Date().getTime()-k.created.getTime()>G;g.updateTarget({...k,selector:L.detail,created:H?k.created:new Date,updated:H?new Date:void 0,updatedBy:H?f:void 0})},O=S=>{const L=bw(),k={id:L,bodies:[],target:{annotation:L,selector:S.detail,creator:f,created:new Date}};g.addAnnotation(k),y.setSelected(k.id),p.setMouseNavEnabled(!0)},M=S=>rh(S);function E(S){ks[S?"unshift":"push"](()=>{m=S,e(5,m)})}return r.$$set=S=>{"drawingEnabled"in S&&e(0,a=S.drawingEnabled),"filter"in S&&e(15,l=S.filter),"preferredDrawingMode"in S&&e(16,h=S.preferredDrawingMode),"state"in S&&e(17,c=S.state),"style"in S&&e(1,u=S.style),"toolName"in S&&e(2,d=S.toolName),"user"in S&&e(18,f=S.user),"viewer"in S&&e(3,p=S.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(7,{tool:i,opts:s}=Bs(d)||{tool:void 0,opts:void 0},i,(e(19,s),e(2,d))),r.$$.dirty[0]&589824&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(a&&n==="drag"?p.setMouseNavEnabled(!1):p.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&y.clear(),r.$$.dirty[0]&1048601&&o.selected.length===0&&n==="drag"&&a&&p.setMouseNavEnabled(!1),r.$$.dirty[0]&1048576&&R(o.selected)},[a,u,d,p,n,m,v,i,y,C,b,T,I,O,M,l,h,c,f,s,o,E]}class eE extends oe{constructor(t){super(),ne(this,t,tE,Qw,Qt,{drawingEnabled:0,filter:15,preferredDrawingMode:16,state:17,style:1,toolName:2,user:18,viewer:3},null,[-1,-1])}}function rE(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=Et("g"),e=Et("rect"),a=Et("text"),h=To(l),P(e,"class","a9s-presence-label-bg svelte-1rehw2p"),P(e,"x",r[0]),P(e,"y",i=r[1]-18/r[3]),P(e,"height",s=18/r[3]),P(e,"fill",n=r[2].appearance.color),P(e,"stroke",o=r[2].appearance.color),P(a,"font-size",c=12/r[3]),P(a,"x",u=r[0]+Math.round(5/r[3])),P(a,"y",d=r[1]-5/r[3]),P(a,"class","svelte-1rehw2p"),P(t,"class","a9s-presence-label")},m(f,p){ct(f,t,p),Ke(t,e),Ke(t,a),Ke(a,h),r[6](t)},p(f,[p]){p&1&&P(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&P(e,"y",i),p&8&&s!==(s=18/f[3])&&P(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&P(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&P(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&Dg(h,l),p&8&&c!==(c=12/f[3])&&P(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&P(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&P(a,"y",d)},i:Me,o:Me,d(f){f&<(t),r[6](null)}}}function iE(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){ks[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,s=u.y),"user"in u&&e(2,n=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,c]}class Ef extends oe{constructor(t){super(),ne(this,t,iE,rE,Qt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function sE(r){let t,e,i,s,n,o;return e=new Ef({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=Et("g"),te(e.$$.fragment),i=Et("polygon"),P(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),P(i,"stroke",s=r[0].appearance.color),P(i,"fill","transparent"),P(i,"points",n=r[2].points.map(Tf).join(" ")),P(t,"class","a9s-presence-overlay")},m(a,l){ct(a,t,l),Kt(e,t,null),Ke(t,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),e.$set(h),(!o||l&1&&s!==(s=a[0].appearance.color))&&P(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(Tf).join(" ")))&&P(i,"points",n)},i(a){o||(st(e.$$.fragment,a),o=!0)},o(a){ut(e.$$.fragment,a),o=!1},d(a){a&<(t),Zt(e)}}}const Tf=r=>r.join(",");function nE(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class oE extends oe{constructor(t){super(),ne(this,t,nE,sE,Qt,{annotation:4,user:0,scale:1})}}function aE(r){let t,e,i,s,n,o,a,l,h;return e=new Ef({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=Et("g"),te(e.$$.fragment),i=Et("rect"),P(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),P(i,"stroke",s=r[0].appearance.color),P(i,"fill","transparent"),P(i,"x",n=r[2].x),P(i,"y",o=r[2].y),P(i,"width",a=r[2].w),P(i,"height",l=r[2].h),P(t,"class","a9s-presence-overlay")},m(c,u){ct(c,t,u),Kt(e,t,null),Ke(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&s!==(s=c[0].appearance.color))&&P(i,"stroke",s),(!h||u&4&&n!==(n=c[2].x))&&P(i,"x",n),(!h||u&4&&o!==(o=c[2].y))&&P(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&P(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&P(i,"height",l)},i(c){h||(st(e.$$.fragment,c),h=!0)},o(c){ut(e.$$.fragment,c),h=!1},d(c){c&<(t),Zt(e)}}}function lE(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class hE extends oe{constructor(t){super(),ne(this,t,lE,aE,Qt,{annotation:3,user:0,scale:1})}}const{Boolean:cE}=Mg;function Af(r,t,e){const i=r.slice();return i[8]=t[e],i}function Sf(r){let t,e;return t=new _f({props:{viewer:r[0],$$slots:{default:[fE,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function Cf(r){let t,e,i=li(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=If(Af(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ur()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&132){i=li(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Af(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=If(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(Je(),l=i.length;l<s.length;l+=1)n(l);Qe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(cE);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&<(t),Eo(s,o)}}}function uE(r){let t,e;return t=new oE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function dE(r){let t,e;return t=new hE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function If(r){let t,e,i,s;const n=[dE,uE],o=[];function a(l,h){return l[8].annotation.target.selector.type===bt.RECTANGLE?0:l[8].annotation.target.selector.type===bt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ur()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Je(),ut(o[c],1,1,()=>{o[c]=null}),Qe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),st(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(st(e),s=!0)},o(l){ut(e),s=!1},d(l){l&<(i),~t&&o[t].d(l)}}}function fE(r){let t,e,i,s,n=r[2].length>0&&Cf(r);return{c(){t=Et("svg"),e=Et("g"),n&&n.c(),P(e,"transform",i=r[6]),P(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ct(o,t,a),Ke(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&st(n,1)):(n=Cf(o),n.c(),st(n,1),n.m(e,null)):n&&(Je(),ut(n,1,1,()=>{n=null}),Qe()),(!s||a&64&&i!==(i=o[6]))&&P(e,"transform",i)},i(o){s||(st(n),s=!0)},o(o){ut(n),s=!1},d(o){o&<(t),n&&n.d()}}}function pE(r){let t=!!r[1],e,i,s=t&&Sf(r);return{c(){s&&s.c(),e=ur()},m(n,o){s&&s.m(n,o),ct(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&st(s,1)):(s=Sf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s&&(Je(),ut(s,1,1,()=>{s=null}),Qe())},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&<(e),s&&s.d(n)}}}function mE(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(g=>g.id)),m=o.filter(({annotation:g})=>!p.has(g.id)).map(g=>{const y=(f||[]).find(x=>x.oldValue.id===g.annotation.id);return y?{selectedBy:g.selectedBy,annotation:y.newValue}:g});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return Fg(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class gE extends oe{constructor(t){super(),ne(this,t,mE,pE,Qt,{store:3,viewer:0,provider:1})}}const Pf=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=Eh(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Rf=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o)return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:g}=o.target.selector.geometry.bounds,y=m-f,x=g-p,_=f-d*y,v=p-h*x,w=y+(c+d)*y,R=x+(h+u)*x,C=r.viewport.imageToViewportRectangle(_,v,w,R);r.viewport[e](C,s.immediately)},yE=(r,t)=>Rf(r,t,"fitBounds"),_E=(r,t)=>Rf(r,t,"fitBoundsWithConstraints"),vE=(r,t={})=>{const e=Ah(t,{drawingEnabled:!1,drawingMode:th?"drag":"click",pointerSelectAction:ro.EDIT,theme:"light"}),i=wh(e),{hover:s,selection:n,store:o}=i,a=qf(o),l=Kf(i,a,e.adapter,e.autoSave);let h=sp(),c=e.drawingEnabled,u=e.drawingMode;const d=Ch(a,r.element),f=new yw({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),p=new gE({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),m=new eE({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}});f.$on("click",S=>{const{originalEvent:L,annotation:k}=S.detail;k&&!(u==="click"&&c)?n.clickSelect(k.id,L):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",S=>{if(s.current){const L=o.getAnnotation(s.current);l.emit("clickAnnotation",L,S)}}),Pf(r,e.theme);const g=Jf(i,a,e.adapter),y=()=>{f.$destroy(),p.$destroy(),m.$destroy(),d.destroy(),a.destroy()},x=yE(r,o),_=_E(r,o),v=()=>h,w=(S,L,k)=>hh(S,L,k),R=(S,L)=>ih(S,L),C=S=>{if(!Bs(S))throw`No drawing tool named ${S}`;m.$set({toolName:S})},b=S=>{c=S,m.$set({drawingEnabled:c})},T=S=>{f.$set({filter:S}),m.$set({filter:S})},I=S=>{f.$set({style:S}),m.$set({style:S})},O=S=>p.$set({provider:S}),M=S=>Pf(r,S),E=S=>{h=S,m.$set({user:S})};return{...g,destroy:y,fitBounds:x,fitBoundsWithConstraints:_,getUser:v,listDrawingTools:Ms,on:l.on,off:l.off,registerDrawingTool:w,registerShapeEditor:R,setDrawingEnabled:b,setDrawingTool:C,setFilter:T,setPresenceProvider:O,setStyle:I,setTheme:M,setUser:E,state:i,viewer:r}},xE=op,bE=ro,wE=Gf,EE=Ig,TE=bt,AE=mm;Dt.PointerSelectAction=bE,Dt.ShapeType=TE,Dt.W3CImageFormat=AE,Dt.createBody=wE,Dt.createImageAnnotator=EE,Dt.createOSDAnnotator=vE,Dt.defaultColorProvider=xE,Object.defineProperty(Dt,Symbol.toStringTag,{value:"Module"})});
|
|
1147
|
+
}`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(t){this._stylesheet!==t&&(this._stylesheet=t,this.styleID++)}normalizeColor(t){return Array.isArray(t)&&(t=Z_(t)),typeof t=="number"?K_(t):t}dropShadowToCSS(){let t=this.normalizeColor(this.dropShadowColor);const e=this.dropShadowAlpha,i=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),s=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);t.startsWith("#")&&e<1&&(t+=(e*255|0).toString(16).padStart(2,"0"));const n=`${i}px ${s}px`;return this.dropShadowBlur>0?`text-shadow: ${n} ${this.dropShadowBlur}px ${t}`:`text-shadow: ${n} ${t}`}reset(){Object.assign(this,ki.defaultOptions)}onBeforeDraw(){const{fontsDirty:t}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&t?new Promise(e=>setTimeout(e,100)):Promise.resolve()}get isSafari(){const{userAgent:t}=z.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}set fillGradientStops(t){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(t){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(t){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(t){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(t){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(t){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(t){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};yl.availableFonts={},yl.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};let _l=yl;const jn=class Gi extends Ci{constructor(t="",e={}){super(Y.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this.localStyleID=-1,this.dirty=!1,this._updateID=0,this.ownsStyle=!1;const i=new Image,s=Y.from(i,{scaleMode:z.SCALE_MODE,resourceOptions:{autoLoad:!1}});s.orig=new it,s.trim=new it,this.texture=s;const n="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xhtml",a=document.createElementNS(n,"svg"),l=document.createElementNS(n,"foreignObject"),h=document.createElementNS(o,"div"),c=document.createElementNS(o,"style");l.setAttribute("width","10000"),l.setAttribute("height","10000"),l.style.overflow="hidden",a.appendChild(l),this.maxWidth=Gi.defaultMaxWidth,this.maxHeight=Gi.defaultMaxHeight,this._domElement=h,this._styleElement=c,this._svgRoot=a,this._foreignObject=l,this._foreignObject.appendChild(c),this._foreignObject.appendChild(h),this._image=i,this._loadImage=new Image,this._autoResolution=Gi.defaultAutoResolution,this._resolution=Gi.defaultResolution??z.RESOLUTION,this.text=t,this.style=e}measureText(t){var c,u;const{text:e,style:i,resolution:s}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},t);Object.assign(this._domElement,{innerHTML:e,style:i.toCSS(s)}),this._styleElement.textContent=i.toGlobalCSS(),document.body.appendChild(this._svgRoot);const n=this._domElement.getBoundingClientRect();this._svgRoot.remove();const{width:o,height:a}=n;(o>this.maxWidth||a>this.maxHeight)&&console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");const l=Math.min(this.maxWidth,Math.ceil(o)),h=Math.min(this.maxHeight,Math.ceil(a));return this._svgRoot.setAttribute("width",l.toString()),this._svgRoot.setAttribute("height",h.toString()),e!==this._text&&(this._domElement.innerHTML=this._text),i!==this._style&&(Object.assign(this._domElement,{style:(c=this._style)==null?void 0:c.toCSS(s)}),this._styleElement.textContent=(u=this._style)==null?void 0:u.toGlobalCSS()),{width:l+i.padding*2,height:h+i.padding*2}}async updateText(t=!0){const{style:e,_image:i,_loadImage:s}=this;if(this.localStyleID!==e.styleID&&(this.dirty=!0,this.localStyleID=e.styleID),!this.dirty&&t)return;const{width:n,height:o}=this.measureText();i.width=s.width=Math.ceil(Math.max(1,n)),i.height=s.height=Math.ceil(Math.max(1,o)),this._updateID++;const a=this._updateID;await new Promise(l=>{s.onload=async()=>{if(a<this._updateID){l();return}await e.onBeforeDraw(),i.src=s.src,s.onload=null,s.src="",this.updateTexture(),l()};const h=new XMLSerializer().serializeToString(this._svgRoot);s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`})}get source(){return this._image}updateTexture(){const{style:t,texture:e,_image:i,resolution:s}=this,{padding:n}=t,{baseTexture:o}=e;e.trim.width=e._frame.width=i.width/s,e.trim.height=e._frame.height=i.height/s,e.trim.x=-n,e.trim.y=-n,e.orig.width=e._frame.width-n*2,e.orig.height=e._frame.height-n*2,this._onTextureUpdate(),o.setRealSize(i.width,i.height,s),this.dirty=!1}_render(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._render(t)}_renderCanvas(t){this._autoResolution&&this._resolution!==t.resolution&&(this._resolution=t.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(t)}getLocalBounds(t){return this.updateText(!0),super.getLocalBounds(t)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(t){var i,s,n,o,a;typeof t=="boolean"&&(t={children:t}),t=Object.assign({},Gi.defaultDestroyOptions,t),super.destroy(t);const e=null;this.ownsStyle&&((i=this._style)==null||i.cleanFonts()),this._style=e,(s=this._svgRoot)==null||s.remove(),this._svgRoot=e,(n=this._domElement)==null||n.remove(),this._domElement=e,(o=this._foreignObject)==null||o.remove(),this._foreignObject=e,(a=this._styleElement)==null||a.remove(),this._styleElement=e,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=e,this._image.src="",this._image=e}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(t){this.updateText(!0);const e=gr(this.scale.x)||1;this.scale.x=e*t/this._image.width/this.resolution,this._width=t}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(t){this.updateText(!0);const e=gr(this.scale.y)||1;this.scale.y=e*t/this._image.height/this.resolution,this._height=t}get style(){return this._style}set style(t){this._style!==t&&(t=t||{},t instanceof _l?(this.ownsStyle=!1,this._style=t):t instanceof Er?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=_l.from(t)):(this.ownsStyle=!0,this._style=new _l(t)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(t){t=String(t===""||t===null||t===void 0?" ":t),t=this.sanitiseText(t),this._text!==t&&(this._text=t,this.dirty=!0)}get resolution(){return this._resolution}set resolution(t){this._autoResolution=!1,this._resolution!==t&&(this._resolution=t,this.dirty=!0)}sanitiseText(t){return t.replace(/<br>/gi,"<br/>").replace(/<hr>/gi,"<hr/>").replace(/ /gi," ")}};jn.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0},jn.defaultMaxWidth=2024,jn.defaultMaxHeight=2024,jn.defaultAutoResolution=!0;const hw=1733608,cw=.25;let Sr=!1,Yn;const vl=r=>{const t={tint:r!=null&&r.fill?new vt(r.fill).toNumber():hw,alpha:(r==null?void 0:r.fillOpacity)===void 0?cw:Math.min(r.fillOpacity,1)},e={tint:(r==null?void 0:r.stroke)&&new vt(r.stroke).toNumber(),alpha:(r==null?void 0:r.strokeOpacity)===void 0?r!=null&&r.stroke?1:0:Math.min(r.strokeOpacity,1),lineWidth:r!=null&&r.stroke?(r==null?void 0:r.strokeWidth)||1:0};return{fillStyle:t,strokeStyle:e}},xl=r=>(t,e,i)=>{const{fillStyle:s,strokeStyle:n}=vl(i),o=new gs;o.beginFill(16777215),r(e,o),o.endFill(),o.tint=s.tint,o.alpha=s.alpha,t.addChild(o);const a=new gs,l=n.lineWidth===1?1:n.lineWidth/Yn;return a.lineStyle(l,16777215,1,.5,n.lineWidth===1),r(e,a),a.tint=n.tint||16777215,a.alpha=n.alpha,t.addChild(a),{fill:o,stroke:a,strokeWidth:n.lineWidth}},uw=xl((r,t)=>{const{cx:e,cy:i,rx:s,ry:n}=r.geometry;t.drawEllipse(e,i,s,n)}),dw=xl((r,t)=>{const e=r.geometry.points.reduce((i,s)=>[...i,...s],[]);t.drawPolygon(e)}),fw=xl((r,t)=>{const{x:e,y:i,w:s,h:n}=r.geometry;t.drawRect(e,i,s,n)}),hf=r=>{const t=r.viewport.getContainerSize().x;return r.viewport.getZoom(!0)*t/r.world.getContentFactor()},pw=(r,t,e,i)=>()=>{const s=r.viewport.viewportToImageRectangle(r.viewport.getBounds(!0)),n=hf(r);n!==Yn&&!Sr&&(Sr=!0,e.forEach(({stroke:u,strokeWidth:d})=>{const{lineStyle:f}=u.geometry.graphicsData[0];d>1?(Sr=!1,f.width=d/n,u.geometry.invalidate()):d===1&&!f.native&&(f.width=1,f.native=!0,u.geometry.invalidate())})),Yn=n;const o=Math.PI*r.viewport.getRotation()/180,a=-s.x*n,l=-s.y*n;let h,c;o>0&&o<=Math.PI/2?(h=s.height*n,c=0):o>Math.PI/2&&o<=Math.PI?(h=s.width*n,c=s.height*n):o>Math.PI&&o<=Math.PI*1.5?(h=0,c=s.width*n):(h=0,c=0),t.position.x=h+a*Math.cos(o)-l*Math.sin(o),t.position.y=c+a*Math.sin(o)+l*Math.cos(o),t.scale.set(n,n),t.rotation=o,i.render(t)},mw=(r,t)=>{const e=new gs,i=nd({width:t.width,height:t.height,backgroundAlpha:0,view:t,antialias:!0,resolution:2}),s=new Map;let n=new Set,o;Yn=hf(r);const a=g=>{Sr=!1;const{selector:y}=g.target,v=typeof o=="function"?o(g):o;let _;y.type===bt.RECTANGLE?_=fw(e,y,v):y.type===bt.POLYGON?_=dw(e,y,v):y.type===bt.ELLIPSE?_=uw(e,y,v):console.warn(`Unsupported shape type: ${y.type}`),_&&s.set(g.id,{annotation:g,..._})},l=g=>{const y=s.get(g.id);y&&(s.delete(g.id),y.fill.destroy(),y.stroke.destroy())},h=(g,y)=>{Sr=!1;const v=s.get(g.id);v&&(s.delete(g.id),v.fill.destroy(),v.stroke.destroy(),a(y))},c=(g,y)=>{i.resize(g,y),i.render(e)},u=g=>{Sr=!1;const{children:y}=e;s.forEach(({fill:v,stroke:_,annotation:x})=>{const T=g?n.has(x.id)||g(x):!0;T&&!y.includes(v)?(e.addChild(v),e.addChild(_)):!T&&y.includes(v)&&(e.removeChild(v),e.removeChild(_))}),i.render(e)},d=g=>{const{selected:y}=g;n=new Set(y.map(v=>v.id))},f=g=>{if(typeof g=="function")s.forEach(({annotation:y,fill:v,stroke:_,strokeWidth:x},T)=>{x>1&&(Sr=!1);const{fillStyle:P,strokeStyle:I}=vl(g(y));v.tint=P.tint,v.alpha=P.alpha,_.tint=I.tint||16777215,_.alpha=I.alpha,s.set(y.id,{annotation:y,fill:v,stroke:_,strokeWidth:x})});else{const{fillStyle:y,strokeStyle:v}=vl(g);v.lineWidth>1&&(Sr=!1),s.forEach(({annotation:_,fill:x,stroke:T,strokeWidth:P},I)=>{x.tint=y.tint,x.alpha=y.alpha,T.tint=v.tint||16777215,T.alpha=v.alpha,s.set(_.id,{annotation:_,fill:x,stroke:T,strokeWidth:P})})}o=g,i.render(e)},p=g=>{g?t.classList.remove("hidden"):t.classList.add("hidden")};return{addAnnotation:a,destroy:()=>i.destroy(),redraw:pw(r,e,s,i),removeAnnotation:l,resize:c,setFilter:u,setSelected:d,setStyle:f,setVisible:p,updateAnnotation:h}};function gw(r,t,e){let i,s,{filter:n}=t,{state:o}=t,{style:a}=t,{viewer:l}=t,{visible:h=!0}=t;const{store:c,hover:u,selection:d,viewport:f}=o;wo(r,u,P=>e(11,i=P)),wo(r,d,P=>e(8,s=P));const p=Us();let m,g;const y=P=>{const I=new jt.Point(P.x,P.y),{x:b,y:E}=l.viewport.pointFromPixel(I);return l.viewport.viewportToImageCoordinates(b,E)},v=P=>{const{x:I,y:b}=P.position;g={x:I,y:b}},_=P=>I=>{const{x:b,y:E}=y(new jt.Point(I.offsetX,I.offsetY)),S=c.getAt(b,E);S&&(!n||n(S))?(P.classList.add("hover"),i!==S.id&&u.set(S.id)):(P.classList.remove("hover"),i&&u.set(void 0))},x=P=>{const I=P.originalEvent,{x:b,y:E}=P.position,S=b-g.x,D=E-g.y;if(Math.sqrt(S*S+D*D)<5){const{x:w,y:C}=y(P.position),F=c.getAt(w,C);F?p("click",{originalEvent:I,annotation:F}):p("click",{originalEvent:I})}g=void 0};let T;return Ns(()=>{var B;const{offsetWidth:P,offsetHeight:I}=l.canvas,b=document.createElement("canvas");b.width=P,b.height=I,b.className="a9s-gl-canvas",(B=l.element.querySelector(".openseadragon-canvas"))==null||B.appendChild(b),e(7,m=mw(l,b));const E=_(b);b.addEventListener("pointermove",E),new ResizeObserver(w=>{try{const{width:C,height:F}=w[0].contentRect;b.width=C,b.height=F,m.resize(C,F)}catch{console.warn("WebGL canvas already disposed")}}).observe(b);const D=()=>{const w=l.viewport.getBounds();T=l.viewport.viewportToImageRectangle(w);const{x:C,y:F,width:k,height:G}=T,$=c.getIntersecting(C,F,k,G);f.set($.map(nt=>nt.id))};return l.addHandler("canvas-press",v),l.addHandler("canvas-release",x),l.addHandler("update-viewport",m.redraw),l.addHandler("animation-finish",D),()=>{var w;b.removeEventListener("pointermove",E),l.removeHandler("canvas-press",v),l.removeHandler("canvas-release",x),l.removeHandler("update-viewport",m.redraw),l.removeHandler("animation-finish",D),m.destroy(),(w=b.parentNode)==null||w.removeChild(b)}}),c.observe(P=>{const{created:I,updated:b,deleted:E}=P.changes;if((I||[]).forEach(S=>m.addAnnotation(S)),(b||[]).forEach(({oldValue:S,newValue:D})=>m.updateAnnotation(S,D)),(E||[]).forEach(S=>m.removeAnnotation(S)),T){const{x:S,y:D,width:B,height:w}=T,C=c.getIntersecting(S,D,B,w);f.set(C.map(F=>F.id))}else f.set(c.all().map(S=>S.id));m.redraw()}),r.$$set=P=>{"filter"in P&&e(2,n=P.filter),"state"in P&&e(3,o=P.state),"style"in P&&e(4,a=P.style),"viewer"in P&&e(5,l=P.viewer),"visible"in P&&e(6,h=P.visible)},r.$$.update=()=>{r.$$.dirty&132&&(m==null||m.setFilter(n)),r.$$.dirty&384&&(m==null||m.setSelected(s)),r.$$.dirty&144&&(m==null||m.setStyle(a)),r.$$.dirty&192&&(m==null||m.setVisible(h))},[u,d,n,o,a,l,h,m,s]}class yw extends oe{constructor(t){super(),ne(this,t,gw,null,Qt,{filter:2,state:3,style:4,viewer:5,visible:6})}}let qn;const _w=new Uint8Array(16);function vw(){if(!qn&&(qn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!qn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qn(_w)}const Wt=[];for(let r=0;r<256;++r)Wt.push((r+256).toString(16).slice(1));function xw(r,t=0){return Wt[r[t+0]]+Wt[r[t+1]]+Wt[r[t+2]]+Wt[r[t+3]]+"-"+Wt[r[t+4]]+Wt[r[t+5]]+"-"+Wt[r[t+6]]+Wt[r[t+7]]+"-"+Wt[r[t+8]]+Wt[r[t+9]]+"-"+Wt[r[t+10]]+Wt[r[t+11]]+Wt[r[t+12]]+Wt[r[t+13]]+Wt[r[t+14]]+Wt[r[t+15]]}const cf={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function bw(r,t,e){if(cf.randomUUID&&!t&&!r)return cf.randomUUID();r=r||{};const i=r.random||(r.rng||vw)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return xw(i)}var Li=(r=>(r.ELLIPSE="ELLIPSE",r.POLYGON="POLYGON",r.RECTANGLE="RECTANGLE",r))(Li||{});const bl=(r,t)=>t,ww=r=>{let t=1/0,e=1/0,i=-1/0,s=-1/0;return r.forEach(([n,o])=>{t=Math.min(t,n),e=Math.min(e,o),i=Math.max(i,n),s=Math.max(s,o)}),{minX:t,minY:e,maxX:i,maxY:s}},Ew={area:r=>Math.PI*r.geometry.rx*r.geometry.ry,intersects:(r,t,e)=>{const{cx:i,cy:s,rx:n,ry:o}=r.geometry,a=0,l=Math.cos(a),h=Math.sin(a),c=t-i,u=e-s,d=l*c+h*u,f=h*c-l*u;return d*d/(n*n)+f*f/(o*o)<=1}};bl(Li.ELLIPSE,Ew);const Tw={area:r=>{const{points:t}=r.geometry;let e=0,i=t.length-1;for(let s=0;s<t.length;s++)e+=(t[i][0]+t[s][0])*(t[i][1]-t[s][1]),i=s;return Math.abs(.5*e)},intersects:(r,t,e)=>{const{points:i}=r.geometry;let s=!1;for(let n=0,o=i.length-1;n<i.length;o=n++){const a=i[n][0],l=i[n][1],h=i[o][0],c=i[o][1];l>e!=c>e&&t<(h-a)*(e-l)/(c-l)+a&&(s=!s)}return s}};bl(Li.POLYGON,Tw);const Aw={area:r=>r.geometry.w*r.geometry.h,intersects:(r,t,e)=>t>=r.geometry.x&&t<=r.geometry.x+r.geometry.w&&e>=r.geometry.y&&e<=r.geometry.y+r.geometry.h};bl(Li.RECTANGLE,Aw);function uf(r,t,e){const i=r.slice();return i[10]=t[e],i[12]=e,i}function df(r){let t,e;return t=new ys({props:{x:r[10][0],y:r[10][1],scale:r[3]}}),t.$on("pointerdown",function(){qt(r[9](`HANDLE-${r[12]}`))&&r[9](`HANDLE-${r[12]}`).apply(this,arguments)}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){r=i;const n={};s&16&&(n.x=r[10][0]),s&16&&(n.y=r[10][1]),s&8&&(n.scale=r[3]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function Sw(r){let t,e,i,s,n,o,a,l,h,c,u,d=hi(r[4].points),f=[];for(let m=0;m<d.length;m+=1)f[m]=df(uf(r,d,m));const p=m=>ut(f[m],1,1,()=>{f[m]=null});return{c(){t=Et("polygon"),s=ge(),n=Et("polygon"),a=ge();for(let m=0;m<f.length;m+=1)f[m].c();l=ur(),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"points",i=r[4].points.map(ff).join(" ")),M(n,"class","a9s-inner a9s-shape-handle"),M(n,"style",r[1]),M(n,"points",o=r[4].points.map(pf).join(" "))},m(m,g){ct(m,t,g),ct(m,s,g),ct(m,n,g),ct(m,a,g);for(let y=0;y<f.length;y+=1)f[y]&&f[y].m(m,g);ct(m,l,g),h=!0,c||(u=[Xt(t,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Xt(n,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)})],c=!0)},p(m,g){if(r=m,(!h||g&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!h||g&16&&i!==(i=r[4].points.map(ff).join(" ")))&&M(t,"points",i),(!h||g&2)&&M(n,"style",r[1]),(!h||g&16&&o!==(o=r[4].points.map(pf).join(" ")))&&M(n,"points",o),g&536){d=hi(r[4].points);let y;for(y=0;y<d.length;y+=1){const v=uf(r,d,y);f[y]?(f[y].p(v,g),st(f[y],1)):(f[y]=df(v),f[y].c(),st(f[y],1),f[y].m(l.parentNode,l))}for(Je(),y=d.length;y<f.length;y+=1)p(y);Qe()}},i(m){if(!h){for(let g=0;g<d.length;g+=1)st(f[g]);h=!0}},o(m){f=f.filter(Boolean);for(let g=0;g<f.length;g+=1)ut(f[g]);h=!1},d(m){m&&(lt(t),lt(s),lt(n),lt(a),lt(l)),Eo(f,m),c=!1,qe(u)}}}function Iw(r){let t,e;return t=new gf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Sw,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("change",r[6]),t.$on("grab",r[7]),t.$on("release",r[8]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&8730&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}const ff=r=>r.join(","),pf=r=>r.join(",");function Cw(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{let m;const g=d.geometry;f==="SHAPE"?m=g.points.map(([v,_])=>[v+p[0],_+p[1]]):m=g.points.map(([v,_],x)=>f===`HANDLE-${x}`?[v+p[0],_+p[1]]:[v,_]);const y=ww(m);return{...d,geometry:{points:m,bounds:y}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Pw extends oe{constructor(t){super(),ne(this,t,Cw,Iw,Qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}const Rw="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;function Mw(r){let t,e,i,s,n,o;return{c(){t=Et("rect"),M(t,"class",e=Fs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(t,"x",i=r[0]-r[5]/2),M(t,"y",s=r[1]-r[5]/2),M(t,"width",r[5]),M(t,"height",r[5])},m(a,l){ct(a,t,l),n||(o=Xt(t,"pointerdown",r[11]),n=!0)},p(a,l){l&256&&e!==(e=Fs(`a9s-handle ${a[8].class||""}`.trim())+" svelte-1sgkh33")&&M(t,"class",e),l&33&&i!==(i=a[0]-a[5]/2)&&M(t,"x",i),l&34&&s!==(s=a[1]-a[5]/2)&&M(t,"y",s),l&32&&M(t,"width",a[5]),l&32&&M(t,"height",a[5])},d(a){a&<(t),n=!1,o()}}}function Bw(r){let t,e,i,s,n,o,a,l,h;return{c(){t=Et("g"),e=Et("circle"),s=Et("rect"),M(e,"cx",r[0]),M(e,"cy",r[1]),M(e,"r",i=r[3]/r[2]),M(e,"class","a9s-touch-halo svelte-1sgkh33"),Ls(e,"touched",r[4]),M(s,"class",n=Fs(`a9s-handle ${r[8].class||""}`.trim())+" svelte-1sgkh33"),M(s,"x",o=r[0]-r[5]/2),M(s,"y",a=r[1]-r[5]/2),M(s,"width",r[5]),M(s,"height",r[5]),M(t,"class","a9s-touch-handle")},m(c,u){ct(c,t,u),Ke(t,e),Ke(t,s),l||(h=[Xt(e,"pointerdown",r[10]),Xt(e,"pointerdown",r[6]),Xt(e,"pointerup",r[7]),Xt(s,"pointerdown",r[9]),Xt(s,"pointerdown",r[6]),Xt(s,"pointerup",r[7])],l=!0)},p(c,u){u&1&&M(e,"cx",c[0]),u&2&&M(e,"cy",c[1]),u&12&&i!==(i=c[3]/c[2])&&M(e,"r",i),u&16&&Ls(e,"touched",c[4]),u&256&&n!==(n=Fs(`a9s-handle ${c[8].class||""}`.trim())+" svelte-1sgkh33")&&M(s,"class",n),u&33&&o!==(o=c[0]-c[5]/2)&&M(s,"x",o),u&34&&a!==(a=c[1]-c[5]/2)&&M(s,"y",a),u&32&&M(s,"width",c[5]),u&32&&M(s,"height",c[5])},d(c){c&<(t),l=!1,qe(h)}}}function Dw(r){let t;function e(n,o){return Rw?Bw:Mw}let s=e()(r);return{c(){s.c(),t=ur()},m(n,o){s.m(n,o),ct(n,t,o)},p(n,[o]){s.p(n,o)},i:Me,o:Me,d(n){n&<(t),s.d(n)}}}function Ow(r,t,e){let i,{x:s}=t,{y:n}=t,{scale:o}=t,{radius:a=30}=t,l=!1;const h=p=>{p.pointerType==="touch"&&e(4,l=!0)},c=()=>e(4,l=!1);function u(p){Ze.call(this,r,p)}function d(p){Ze.call(this,r,p)}function f(p){Ze.call(this,r,p)}return r.$$set=p=>{e(8,t=bo(bo({},t),Fh(p))),"x"in p&&e(0,s=p.x),"y"in p&&e(1,n=p.y),"scale"in p&&e(2,o=p.scale),"radius"in p&&e(3,a=p.radius)},r.$$.update=()=>{r.$$.dirty&4&&e(5,i=10/o)},t=Fh(t),[s,n,o,a,l,i,h,c,t,u,d,f]}class ys extends oe{constructor(t){super(),ne(this,t,Ow,Dw,Qt,{x:0,y:1,scale:2,radius:3})}}function Fw(r){let t,e,i,s,n,o,a,l,h,c,u,d,f,p,m,g,y,v,_,x,T,P,I,b,E,S,D,B,w,C,F,k,G,$,nt,R,L,W,Q,J,H,_t,Tt;return $=new ys({props:{class:"a9s-corner-handle-topleft",x:r[4].x,y:r[4].y,scale:r[3]}}),$.$on("pointerdown",function(){qt(r[9]("TOP_LEFT"))&&r[9]("TOP_LEFT").apply(this,arguments)}),R=new ys({props:{class:"a9s-corner-handle-topright",x:r[4].x+r[4].w,y:r[4].y,scale:r[3]}}),R.$on("pointerdown",function(){qt(r[9]("TOP_RIGHT"))&&r[9]("TOP_RIGHT").apply(this,arguments)}),W=new ys({props:{class:"a9s-corner-handle-bottomright",x:r[4].x+r[4].w,y:r[4].y+r[4].h,scale:r[3]}}),W.$on("pointerdown",function(){qt(r[9]("BOTTOM_RIGHT"))&&r[9]("BOTTOM_RIGHT").apply(this,arguments)}),J=new ys({props:{class:"a9s-corner-handle-bottomleft",x:r[4].x,y:r[4].y+r[4].h,scale:r[3]}}),J.$on("pointerdown",function(){qt(r[9]("BOTTOM_LEFT"))&&r[9]("BOTTOM_LEFT").apply(this,arguments)}),{c(){t=Et("rect"),a=ge(),l=Et("rect"),f=ge(),p=Et("rect"),v=ge(),_=Et("rect"),I=ge(),b=Et("rect"),B=ge(),w=Et("rect"),G=ge(),te($.$$.fragment),nt=ge(),te(R.$$.fragment),L=ge(),te(W.$$.fragment),Q=ge(),te(J.$$.fragment),M(t,"class","a9s-outer"),M(t,"style",e=r[1]?"display:none;":void 0),M(t,"x",i=r[4].x),M(t,"y",s=r[4].y),M(t,"width",n=r[4].w),M(t,"height",o=r[4].h),M(l,"class","a9s-inner a9s-shape-handle"),M(l,"style",r[1]),M(l,"x",h=r[4].x),M(l,"y",c=r[4].y),M(l,"width",u=r[4].w),M(l,"height",d=r[4].h),M(p,"class","a9s-edge-handle a9s-edge-handle-top"),M(p,"x",m=r[4].x),M(p,"y",g=r[4].y),M(p,"height",1),M(p,"width",y=r[4].w),M(_,"class","a9s-edge-handle a9s-edge-handle-right"),M(_,"x",x=r[4].x+r[4].w),M(_,"y",T=r[4].y),M(_,"height",P=r[4].h),M(_,"width",1),M(b,"class","a9s-edge-handle a9s-edge-handle-bottom"),M(b,"x",E=r[4].x),M(b,"y",S=r[4].y+r[4].h),M(b,"height",1),M(b,"width",D=r[4].w),M(w,"class","a9s-edge-handle a9s-edge-handle-left"),M(w,"x",C=r[4].x),M(w,"y",F=r[4].y),M(w,"height",k=r[4].h),M(w,"width",1)},m(N,O){ct(N,t,O),ct(N,a,O),ct(N,l,O),ct(N,f,O),ct(N,p,O),ct(N,v,O),ct(N,_,O),ct(N,I,O),ct(N,b,O),ct(N,B,O),ct(N,w,O),ct(N,G,O),Kt($,N,O),ct(N,nt,O),Kt(R,N,O),ct(N,L,O),Kt(W,N,O),ct(N,Q,O),Kt(J,N,O),H=!0,_t||(Tt=[Xt(t,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Xt(l,"pointerdown",function(){qt(r[9]("SHAPE"))&&r[9]("SHAPE").apply(this,arguments)}),Xt(p,"pointerdown",function(){qt(r[9]("TOP"))&&r[9]("TOP").apply(this,arguments)}),Xt(_,"pointerdown",function(){qt(r[9]("RIGHT"))&&r[9]("RIGHT").apply(this,arguments)}),Xt(b,"pointerdown",function(){qt(r[9]("BOTTOM"))&&r[9]("BOTTOM").apply(this,arguments)}),Xt(w,"pointerdown",function(){qt(r[9]("LEFT"))&&r[9]("LEFT").apply(this,arguments)})],_t=!0)},p(N,O){r=N,(!H||O&2&&e!==(e=r[1]?"display:none;":void 0))&&M(t,"style",e),(!H||O&16&&i!==(i=r[4].x))&&M(t,"x",i),(!H||O&16&&s!==(s=r[4].y))&&M(t,"y",s),(!H||O&16&&n!==(n=r[4].w))&&M(t,"width",n),(!H||O&16&&o!==(o=r[4].h))&&M(t,"height",o),(!H||O&2)&&M(l,"style",r[1]),(!H||O&16&&h!==(h=r[4].x))&&M(l,"x",h),(!H||O&16&&c!==(c=r[4].y))&&M(l,"y",c),(!H||O&16&&u!==(u=r[4].w))&&M(l,"width",u),(!H||O&16&&d!==(d=r[4].h))&&M(l,"height",d),(!H||O&16&&m!==(m=r[4].x))&&M(p,"x",m),(!H||O&16&&g!==(g=r[4].y))&&M(p,"y",g),(!H||O&16&&y!==(y=r[4].w))&&M(p,"width",y),(!H||O&16&&x!==(x=r[4].x+r[4].w))&&M(_,"x",x),(!H||O&16&&T!==(T=r[4].y))&&M(_,"y",T),(!H||O&16&&P!==(P=r[4].h))&&M(_,"height",P),(!H||O&16&&E!==(E=r[4].x))&&M(b,"x",E),(!H||O&16&&S!==(S=r[4].y+r[4].h))&&M(b,"y",S),(!H||O&16&&D!==(D=r[4].w))&&M(b,"width",D),(!H||O&16&&C!==(C=r[4].x))&&M(w,"x",C),(!H||O&16&&F!==(F=r[4].y))&&M(w,"y",F),(!H||O&16&&k!==(k=r[4].h))&&M(w,"height",k);const xt={};O&16&&(xt.x=r[4].x),O&16&&(xt.y=r[4].y),O&8&&(xt.scale=r[3]),$.$set(xt);const ft={};O&16&&(ft.x=r[4].x+r[4].w),O&16&&(ft.y=r[4].y),O&8&&(ft.scale=r[3]),R.$set(ft);const gt={};O&16&&(gt.x=r[4].x+r[4].w),O&16&&(gt.y=r[4].y+r[4].h),O&8&&(gt.scale=r[3]),W.$set(gt);const yt={};O&16&&(yt.x=r[4].x),O&16&&(yt.y=r[4].y+r[4].h),O&8&&(yt.scale=r[3]),J.$set(yt)},i(N){H||(st($.$$.fragment,N),st(R.$$.fragment,N),st(W.$$.fragment,N),st(J.$$.fragment,N),H=!0)},o(N){ut($.$$.fragment,N),ut(R.$$.fragment,N),ut(W.$$.fragment,N),ut(J.$$.fragment,N),H=!1},d(N){N&&(lt(t),lt(a),lt(l),lt(f),lt(p),lt(v),lt(_),lt(I),lt(b),lt(B),lt(w),lt(G),lt(nt),lt(L),lt(Q)),Zt($,N),Zt(R,N),Zt(W,N),Zt(J,N),_t=!1,qe(Tt)}}}function Lw(r){let t,e;return t=new gf({props:{shape:r[0],transform:r[2],editor:r[5],$$slots:{default:[Fw,({grab:i})=>({9:i}),({grab:i})=>i?512:0]},$$scope:{ctx:r}}}),t.$on("grab",r[6]),t.$on("change",r[7]),t.$on("release",r[8]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,[s]){const n={};s&1&&(n.shape=i[0]),s&4&&(n.transform=i[2]),s&1562&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function Nw(r,t,e){let i,{shape:s}=t,{computedStyle:n}=t,{transform:o}=t,{viewportScale:a=1}=t;const l=(d,f,p)=>{const m=d.geometry.bounds;let[g,y]=[m.minX,m.minY],[v,_]=[m.maxX,m.maxY];const[x,T]=p;if(f==="SHAPE")g+=x,v+=x,y+=T,_+=T;else{switch(f){case"TOP":case"TOP_LEFT":case"TOP_RIGHT":{y+=T;break}case"BOTTOM":case"BOTTOM_LEFT":case"BOTTOM_RIGHT":{_+=T;break}}switch(f){case"LEFT":case"TOP_LEFT":case"BOTTOM_LEFT":{g+=x;break}case"RIGHT":case"TOP_RIGHT":case"BOTTOM_RIGHT":{v+=x;break}}}const P=Math.min(g,v),I=Math.min(y,_),b=Math.abs(v-g),E=Math.abs(_-y);return{...d,geometry:{x:P,y:I,w:b,h:E,bounds:{minX:P,minY:I,maxX:P+b,maxY:I+E}}}};function h(d){Ze.call(this,r,d)}function c(d){Ze.call(this,r,d)}function u(d){Ze.call(this,r,d)}return r.$$set=d=>{"shape"in d&&e(0,s=d.shape),"computedStyle"in d&&e(1,n=d.computedStyle),"transform"in d&&e(2,o=d.transform),"viewportScale"in d&&e(3,a=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&1&&e(4,i=s.geometry)},[s,n,o,a,i,l,h,c,u]}class Uw extends oe{constructor(t){super(),ne(this,t,Nw,Lw,Qt,{shape:0,computedStyle:1,transform:2,viewportScale:3})}}Li.RECTANGLE,Li.POLYGON;const kw=r=>({}),mf=r=>({grab:r[0]});function Gw(r){let t,e,i,s;const n=r[7].default,o=Rh(n,r,r[6],mf);return{c(){t=Et("g"),o&&o.c(),M(t,"class","a9s-annotation selected")},m(a,l){ct(a,t,l),o&&o.m(t,null),e=!0,i||(s=[Xt(t,"pointerup",r[2]),Xt(t,"pointermove",r[1])],i=!0)},p(a,[l]){o&&o.p&&(!e||l&64)&&Dh(o,n,a,a[6],e?Bh(n,a[6],l,kw):Oh(a[6]),mf)},i(a){e||(st(o,a),e=!0)},o(a){ut(o,a),e=!1},d(a){a&<(t),o&&o.d(a),i=!1,qe(s)}}}function $w(r,t,e){let{$$slots:i={},$$scope:s}=t;const n=Us();let{shape:o}=t,{editor:a}=t,{transform:l}=t,h,c,u;const d=m=>g=>{h=m,c=l.elementToImage(g.offsetX,g.offsetY),u=o,g.target.setPointerCapture(g.pointerId),n("grab",g)},f=m=>{if(h){const[g,y]=l.elementToImage(m.offsetX,m.offsetY),v=[g-c[0],y-c[1]];e(3,o=a(u,h,v)),n("change",o)}},p=m=>{m.target.releasePointerCapture(m.pointerId),h=void 0,u=o,n("release",m)};return r.$$set=m=>{"shape"in m&&e(3,o=m.shape),"editor"in m&&e(4,a=m.editor),"transform"in m&&e(5,l=m.transform),"$$scope"in m&&e(6,s=m.$$scope)},[d,f,p,o,a,l,s,i]}class gf extends oe{constructor(t){super(),ne(this,t,$w,Gw,Qt,{shape:3,editor:4,transform:5})}}const Hw=(r,t)=>{const e=typeof t=="function"?t(r):t;if(e){const{fill:i,fillOpacity:s}=e;let n="";return i&&(n+=`fill:${i};stroke:${i};`),n+=`fill-opacity:${s||"0.25"};`,n}};function Xw(r,t,e){let i;const s=Us();let{annotation:n}=t,{editor:o}=t,{style:a}=t,{target:l}=t,{transform:h}=t,{viewportScale:c}=t,u;return Ns(()=>(e(6,u=new o({target:l,props:{shape:n.target.selector,computedStyle:i,transform:h,viewportScale:c}})),u.$on("change",d=>{u.$$set({shape:d.detail}),s("change",d.detail)}),u.$on("grab",d=>s("grab",d.detail)),u.$on("release",d=>s("release",d.detail)),()=>{u.$destroy()})),r.$$set=d=>{"annotation"in d&&e(0,n=d.annotation),"editor"in d&&e(1,o=d.editor),"style"in d&&e(2,a=d.style),"target"in d&&e(3,l=d.target),"transform"in d&&e(4,h=d.transform),"viewportScale"in d&&e(5,c=d.viewportScale)},r.$$.update=()=>{r.$$.dirty&5&&(i=Hw(n,a)),r.$$.dirty&65&&n&&(u==null||u.$set({shape:n.target.selector})),r.$$.dirty&80&&u&&u.$set({transform:h}),r.$$.dirty&96&&u&&u.$set({viewportScale:c})},[n,o,a,l,h,c,u]}class Vw extends oe{constructor(t){super(),ne(this,t,Xw,null,Qt,{annotation:0,editor:1,style:2,target:3,transform:4,viewportScale:5})}}navigator.userAgent.indexOf("Mac OS X");const zw=r=>({transform:r&2,scale:r&1}),yf=r=>({transform:r[1],scale:r[0]});function Ww(r){let t;const e=r[4].default,i=Rh(e,r,r[3],yf);return{c(){i&&i.c()},m(s,n){i&&i.m(s,n),t=!0},p(s,[n]){i&&i.p&&(!t||n&11)&&Dh(i,e,s,s[3],t?Bh(e,s[3],n,zw):Oh(s[3]),yf)},i(s){t||(st(i,s),t=!0)},o(s){ut(i,s),t=!1},d(s){i&&i.d(s)}}}function jw(r,t,e){let{$$slots:i={},$$scope:s}=t,{viewer:n}=t,o=1,a;const l=()=>{const h=n.viewport.getContainerSize().x,c=n.viewport.getZoom(!0),u=n.viewport.getFlip(),d=n.viewport.pixelFromPoint(new jt.Point(0,0),!0);u&&(d.x=h-d.x);const f=c*h/n.world.getContentFactor(),p=u?-f:f,m=n.viewport.getRotation();e(1,a=`translate(${d.x}, ${d.y}) scale(${p}, ${f}) rotate(${m})`),e(0,o=c*h/n.world.getContentFactor())};return Ns(()=>(n.addHandler("update-viewport",l),()=>{n.removeHandler("update-viewport",l)})),r.$$set=h=>{"viewer"in h&&e(2,n=h.viewer),"$$scope"in h&&e(3,s=h.$$scope)},[o,a,n,s,i]}class _f extends oe{constructor(t){super(),ne(this,t,jw,Ww,Qt,{viewer:2})}}function Yw(r,t,e){const i=Us();let{drawingMode:s}=t,{target:n}=t,{tool:o}=t,{transform:a}=t,{viewer:l}=t,{viewportScale:h}=t,c;return Ns(()=>{const u=n.closest("svg"),d=[],f=(p,m,g)=>{if(u==null||u.addEventListener(p,m,g),d.push(()=>u==null?void 0:u.removeEventListener(p,m,g)),p==="pointerup"||p==="dblclick"){const y=_=>{const{originalEvent:x}=_;m(x)},v=p==="pointerup"?"canvas-click":"canvas-double-click";l.addHandler(v,y),d.push(()=>l.removeHandler(v,y))}else if(p==="pointermove"){const y=v=>{const{originalEvent:_}=v;m(_)};l.addHandler("canvas-drag",y),d.push(()=>l.removeHandler("canvas-drag",y))}};return e(6,c=new o({target:n,props:{addEventListener:f,drawingMode:s,transform:a,viewportScale:h}})),c.$on("create",p=>i("create",p.detail)),()=>{d.forEach(p=>p()),c.$destroy()}}),r.$$set=u=>{"drawingMode"in u&&e(0,s=u.drawingMode),"target"in u&&e(1,n=u.target),"tool"in u&&e(2,o=u.tool),"transform"in u&&e(3,a=u.transform),"viewer"in u&&e(4,l=u.viewer),"viewportScale"in u&&e(5,h=u.viewportScale)},r.$$.update=()=>{r.$$.dirty&72&&c&&c.$set({transform:a}),r.$$.dirty&96&&c&&c.$set({viewportScale:h})},[s,n,o,a,l,h,c]}class qw extends oe{constructor(t){super(),ne(this,t,Yw,null,Qt,{drawingMode:0,target:1,tool:2,transform:3,viewer:4,viewportScale:5})}}function vf(r,t,e){const i=r.slice();return i[29]=t[e],i}function Kw(r){let t=r[2],e,i,s=xf(r);return{c(){s.c(),e=ur()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&4&&Qt(t,t=n[2])?(Je(),ut(s,1,1,Me),Qe(),s=xf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&<(e),s.d(n)}}}function Zw(r){let t,e,i=hi(r[6]),s=[];for(let o=0;o<i.length;o+=1)s[o]=wf(vf(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ur()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a[0]&268459618){i=hi(o[6]);let l;for(l=0;l<i.length;l+=1){const h=vf(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=wf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(Je(),l=i.length;l<s.length;l+=1)n(l);Qe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(Boolean);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&<(t),Eo(s,o)}}}function xf(r){let t,e;return t=new qw({props:{target:r[5],tool:r[7],drawingMode:r[4],transform:{elementToImage:r[9]},viewer:r[3],viewportScale:r[28]}}),t.$on("create",r[13]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s[0]&32&&(n.target=i[5]),s[0]&128&&(n.tool=i[7]),s[0]&16&&(n.drawingMode=i[4]),s[0]&8&&(n.viewer=i[3]),s[0]&268435456&&(n.viewportScale=i[28]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function bf(r){let t,e;return t=new Vw({props:{target:r[5],editor:r[14](r[29].target.selector),annotation:r[29],style:r[1],transform:{elementToImage:r[9]},viewportScale:r[28]}}),t.$on("grab",r[10]),t.$on("change",function(){qt(r[12](r[29]))&&r[12](r[29]).apply(this,arguments)}),t.$on("release",r[11]),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){r=i;const n={};s[0]&32&&(n.target=r[5]),s[0]&64&&(n.editor=r[14](r[29].target.selector)),s[0]&64&&(n.annotation=r[29]),s[0]&2&&(n.style=r[1]),s[0]&268435456&&(n.viewportScale=r[28]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function wf(r){let t=r[29].id,e,i,s=bf(r);return{c(){s.c(),e=ur()},m(n,o){s.m(n,o),ct(n,e,o),i=!0},p(n,o){o[0]&64&&Qt(t,t=n[29].id)?(Je(),ut(s,1,1,Me),Qe(),s=bf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s.p(n,o)},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&<(e),s.d(n)}}}function Jw(r){let t,e,i,s,n,o;const a=[Zw,Kw],l=[];function h(c,u){return c[5]&&c[6]?0:c[5]&&c[7]&&c[0]?1:-1}return~(i=h(r))&&(s=l[i]=a[i](r)),{c(){t=Et("svg"),e=Et("g"),s&&s.c(),M(e,"transform",n=r[27]),M(e,"class","svelte-190cqdf"),M(t,"class","a9s-annotationlayer a9s-osd-drawinglayer svelte-190cqdf"),Ls(t,"drawing",r[0])},m(c,u){ct(c,t,u),Ke(t,e),~i&&l[i].m(e,null),r[21](e),o=!0},p(c,u){let d=i;i=h(c),i===d?~i&&l[i].p(c,u):(s&&(Je(),ut(l[d],1,1,()=>{l[d]=null}),Qe()),~i?(s=l[i],s?s.p(c,u):(s=l[i]=a[i](c),s.c()),st(s,1),s.m(e,null)):s=null),(!o||u[0]&134217728&&n!==(n=c[27]))&&M(e,"transform",n),(!o||u[0]&1)&&Ls(t,"drawing",c[0])},i(c){o||(st(s),o=!0)},o(c){ut(s),o=!1},d(c){c&<(t),~i&&l[i].d(),r[21](null)}}}function Qw(r){let t,e;return t=new _f({props:{viewer:r[3],$$slots:{default:[Jw,({transform:i,scale:s})=>({27:i,28:s}),({transform:i,scale:s})=>[(i?134217728:0)|(s?268435456:0)]]},$$scope:{ctx:r}}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s[0]&8&&(n.viewer=i[3]),s[0]&402653439|s[1]&2&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function tE(r,t,e){let i,s,n,o,{drawingEnabled:a}=t,{filter:l}=t,{preferredDrawingMode:h}=t,{state:c}=t,{style:u=void 0}=t,{toolName:d=Ms()[0]}=t,{user:f}=t,{viewer:p}=t,m;const{store:g,selection:y,hover:v}=c;wo(r,y,C=>e(20,o=C));let _,x,T;const P=C=>{g.unobserve(_);const F=C.filter(({editable:k})=>k).map(({id:k})=>k);F.length>0?(e(6,x=F.map(k=>g.getAnnotation(k))),_=k=>{const{updated:G}=k.changes;e(6,x=(G||[]).map($=>$.newValue))},g.observe(_,{annotations:F})):e(6,x=void 0)},I=(C,F)=>{const{x:k,y:G}=p.viewport.viewerElementToImageCoordinates(new jt.Point(C,F));return[k,G]},b=C=>{p.setMouseNavEnabled(!1),T=C.timeStamp},E=C=>{if(p.setMouseNavEnabled(!0),performance.now()-(T||0)<300){const{offsetX:k,offsetY:G}=C.detail,[$,nt]=I(k,G),R=g.getAt($,nt);R&&(!l||l(R))&&!x.find(W=>W.id===R.id)&&(v.set(R.id),y.setSelected(R.id))}},S=C=>F=>{var nt;const{target:k}=C,G=10*60*1e3,$=((nt=k.creator)==null?void 0:nt.id)!==f.id||!k.created||new Date().getTime()-k.created.getTime()>G;g.updateTarget({...k,selector:F.detail,created:$?k.created:new Date,updated:$?new Date:void 0,updatedBy:$?f:void 0})},D=C=>{const F=bw(),k={id:F,bodies:[],target:{annotation:F,selector:C.detail,creator:f,created:new Date}};g.addAnnotation(k),y.setSelected(k.id),p.setMouseNavEnabled(!0)},B=C=>rh(C);function w(C){ks[C?"unshift":"push"](()=>{m=C,e(5,m)})}return r.$$set=C=>{"drawingEnabled"in C&&e(0,a=C.drawingEnabled),"filter"in C&&e(15,l=C.filter),"preferredDrawingMode"in C&&e(16,h=C.preferredDrawingMode),"state"in C&&e(17,c=C.state),"style"in C&&e(1,u=C.style),"toolName"in C&&e(2,d=C.toolName),"user"in C&&e(18,f=C.user),"viewer"in C&&e(3,p=C.viewer)},r.$$.update=()=>{r.$$.dirty[0]&4&&e(7,{tool:i,opts:s}=Bs(d)||{tool:void 0,opts:void 0},i,(e(19,s),e(2,d))),r.$$.dirty[0]&589824&&e(4,n=(s==null?void 0:s.drawingMode)||h),r.$$.dirty[0]&25&&(a&&n==="drag"?p.setMouseNavEnabled(!1):p.setMouseNavEnabled(!0)),r.$$.dirty[0]&1&&a&&y.clear(),r.$$.dirty[0]&1048601&&o.selected.length===0&&n==="drag"&&a&&p.setMouseNavEnabled(!1),r.$$.dirty[0]&1048576&&P(o.selected)},[a,u,d,p,n,m,x,i,y,I,b,E,S,D,B,l,h,c,f,s,o,w]}class eE extends oe{constructor(t){super(),ne(this,t,tE,Qw,Qt,{drawingEnabled:0,filter:15,preferredDrawingMode:16,state:17,style:1,toolName:2,user:18,viewer:3},null,[-1,-1])}}function rE(r){let t,e,i,s,n,o,a,l=r[2].appearance.label+"",h,c,u,d;return{c(){t=Et("g"),e=Et("rect"),a=Et("text"),h=To(l),M(e,"class","a9s-presence-label-bg svelte-1rehw2p"),M(e,"x",r[0]),M(e,"y",i=r[1]-18/r[3]),M(e,"height",s=18/r[3]),M(e,"fill",n=r[2].appearance.color),M(e,"stroke",o=r[2].appearance.color),M(a,"font-size",c=12/r[3]),M(a,"x",u=r[0]+Math.round(5/r[3])),M(a,"y",d=r[1]-5/r[3]),M(a,"class","svelte-1rehw2p"),M(t,"class","a9s-presence-label")},m(f,p){ct(f,t,p),Ke(t,e),Ke(t,a),Ke(a,h),r[6](t)},p(f,[p]){p&1&&M(e,"x",f[0]),p&10&&i!==(i=f[1]-18/f[3])&&M(e,"y",i),p&8&&s!==(s=18/f[3])&&M(e,"height",s),p&4&&n!==(n=f[2].appearance.color)&&M(e,"fill",n),p&4&&o!==(o=f[2].appearance.color)&&M(e,"stroke",o),p&4&&l!==(l=f[2].appearance.label+"")&&Dg(h,l),p&8&&c!==(c=12/f[3])&&M(a,"font-size",c),p&9&&u!==(u=f[0]+Math.round(5/f[3]))&&M(a,"x",u),p&10&&d!==(d=f[1]-5/f[3])&&M(a,"y",d)},i:Me,o:Me,d(f){f&<(t),r[6](null)}}}function iE(r,t,e){let{x:i}=t,{y:s}=t,{user:n}=t,{scale:o}=t,{hAlign:a=null}=t,l;const h=u=>{const d=l.querySelector("text"),f=l.querySelector("rect"),p=d.getBBox().width+10/u;a==="CENTER"&&l.setAttribute("style",`transform: translateX(-${p/2}px)`),f.setAttribute("width",`${p}`)};function c(u){ks[u?"unshift":"push"](()=>{l=u,e(4,l)})}return r.$$set=u=>{"x"in u&&e(0,i=u.x),"y"in u&&e(1,s=u.y),"user"in u&&e(2,n=u.user),"scale"in u&&e(3,o=u.scale),"hAlign"in u&&e(5,a=u.hAlign)},r.$$.update=()=>{r.$$.dirty&24&&l&&h(o)},[i,s,n,o,l,a,c]}class Ef extends oe{constructor(t){super(),ne(this,t,iE,rE,Qt,{x:0,y:1,user:2,scale:3,hAlign:5})}}function sE(r){let t,e,i,s,n,o;return e=new Ef({props:{scale:r[1],user:r[0],x:r[3][0],y:r[3][1],hAlign:"CENTER"}}),{c(){t=Et("g"),te(e.$$.fragment),i=Et("polygon"),M(i,"class","a9s-presence-shape a9s-presence-polygon svelte-fgq4n0"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"points",n=r[2].points.map(Tf).join(" ")),M(t,"class","a9s-presence-overlay")},m(a,l){ct(a,t,l),Kt(e,t,null),Ke(t,i),o=!0},p(a,[l]){const h={};l&2&&(h.scale=a[1]),l&1&&(h.user=a[0]),l&8&&(h.x=a[3][0]),l&8&&(h.y=a[3][1]),e.$set(h),(!o||l&1&&s!==(s=a[0].appearance.color))&&M(i,"stroke",s),(!o||l&4&&n!==(n=a[2].points.map(Tf).join(" ")))&&M(i,"points",n)},i(a){o||(st(e.$$.fragment,a),o=!0)},o(a){ut(e.$$.fragment,a),o=!1},d(a){a&<(t),Zt(e)}}}const Tf=r=>r.join(",");function nE(r,t,e){let i,s,{annotation:n}=t,{user:o}=t,{scale:a}=t;const l=h=>{let[c,...u]=h.points;return u.forEach(([d,f])=>{f<c[1]&&(c=[d,f])}),c};return r.$$set=h=>{"annotation"in h&&e(4,n=h.annotation),"user"in h&&e(0,o=h.user),"scale"in h&&e(1,a=h.scale)},r.$$.update=()=>{r.$$.dirty&16&&e(2,i=n.target.selector.geometry),r.$$.dirty&4&&e(3,s=l(i))},[o,a,i,s,n]}class oE extends oe{constructor(t){super(),ne(this,t,nE,sE,Qt,{annotation:4,user:0,scale:1})}}function aE(r){let t,e,i,s,n,o,a,l,h;return e=new Ef({props:{scale:r[1],user:r[0],x:r[2].x,y:r[2].y}}),{c(){t=Et("g"),te(e.$$.fragment),i=Et("rect"),M(i,"class","a9s-presence-shape a9s-presence-rectangle svelte-gze948"),M(i,"stroke",s=r[0].appearance.color),M(i,"fill","transparent"),M(i,"x",n=r[2].x),M(i,"y",o=r[2].y),M(i,"width",a=r[2].w),M(i,"height",l=r[2].h),M(t,"class","a9s-presence-overlay")},m(c,u){ct(c,t,u),Kt(e,t,null),Ke(t,i),h=!0},p(c,[u]){const d={};u&2&&(d.scale=c[1]),u&1&&(d.user=c[0]),u&4&&(d.x=c[2].x),u&4&&(d.y=c[2].y),e.$set(d),(!h||u&1&&s!==(s=c[0].appearance.color))&&M(i,"stroke",s),(!h||u&4&&n!==(n=c[2].x))&&M(i,"x",n),(!h||u&4&&o!==(o=c[2].y))&&M(i,"y",o),(!h||u&4&&a!==(a=c[2].w))&&M(i,"width",a),(!h||u&4&&l!==(l=c[2].h))&&M(i,"height",l)},i(c){h||(st(e.$$.fragment,c),h=!0)},o(c){ut(e.$$.fragment,c),h=!1},d(c){c&<(t),Zt(e)}}}function lE(r,t,e){let i,{annotation:s}=t,{user:n}=t,{scale:o}=t;return r.$$set=a=>{"annotation"in a&&e(3,s=a.annotation),"user"in a&&e(0,n=a.user),"scale"in a&&e(1,o=a.scale)},r.$$.update=()=>{r.$$.dirty&8&&e(2,i=s.target.selector.geometry)},[n,o,i,s]}class hE extends oe{constructor(t){super(),ne(this,t,lE,aE,Qt,{annotation:3,user:0,scale:1})}}const{Boolean:cE}=Mg;function Af(r,t,e){const i=r.slice();return i[8]=t[e],i}function Sf(r){let t,e;return t=new _f({props:{viewer:r[0],$$slots:{default:[fE,({transform:i,scale:s})=>({6:i,7:s}),({transform:i,scale:s})=>(i?64:0)|(s?128:0)]},$$scope:{ctx:r}}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s&1&&(n.viewer=i[0]),s&2244&&(n.$$scope={dirty:s,ctx:i}),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function If(r){let t,e,i=hi(r[2]),s=[];for(let o=0;o<i.length;o+=1)s[o]=Cf(Af(r,i,o));const n=o=>ut(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o<s.length;o+=1)s[o].c();t=ur()},m(o,a){for(let l=0;l<s.length;l+=1)s[l]&&s[l].m(o,a);ct(o,t,a),e=!0},p(o,a){if(a&132){i=hi(o[2]);let l;for(l=0;l<i.length;l+=1){const h=Af(o,i,l);s[l]?(s[l].p(h,a),st(s[l],1)):(s[l]=Cf(h),s[l].c(),st(s[l],1),s[l].m(t.parentNode,t))}for(Je(),l=i.length;l<s.length;l+=1)n(l);Qe()}},i(o){if(!e){for(let a=0;a<i.length;a+=1)st(s[a]);e=!0}},o(o){s=s.filter(cE);for(let a=0;a<s.length;a+=1)ut(s[a]);e=!1},d(o){o&<(t),Eo(s,o)}}}function uE(r){let t,e;return t=new oE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function dE(r){let t,e;return t=new hE({props:{annotation:r[8].annotation,user:r[8].selectedBy,scale:r[7]}}),{c(){te(t.$$.fragment)},m(i,s){Kt(t,i,s),e=!0},p(i,s){const n={};s&4&&(n.annotation=i[8].annotation),s&4&&(n.user=i[8].selectedBy),s&128&&(n.scale=i[7]),t.$set(n)},i(i){e||(st(t.$$.fragment,i),e=!0)},o(i){ut(t.$$.fragment,i),e=!1},d(i){Zt(t,i)}}}function Cf(r){let t,e,i,s;const n=[dE,uE],o=[];function a(l,h){return l[8].annotation.target.selector.type===bt.RECTANGLE?0:l[8].annotation.target.selector.type===bt.POLYGON?1:-1}return~(t=a(r))&&(e=o[t]=n[t](r)),{c(){e&&e.c(),i=ur()},m(l,h){~t&&o[t].m(l,h),ct(l,i,h),s=!0},p(l,h){let c=t;t=a(l),t===c?~t&&o[t].p(l,h):(e&&(Je(),ut(o[c],1,1,()=>{o[c]=null}),Qe()),~t?(e=o[t],e?e.p(l,h):(e=o[t]=n[t](l),e.c()),st(e,1),e.m(i.parentNode,i)):e=null)},i(l){s||(st(e),s=!0)},o(l){ut(e),s=!1},d(l){l&<(i),~t&&o[t].d(l)}}}function fE(r){let t,e,i,s,n=r[2].length>0&&If(r);return{c(){t=Et("svg"),e=Et("g"),n&&n.c(),M(e,"transform",i=r[6]),M(t,"class","a9s-osd-presencelayer svelte-1krwc4m")},m(o,a){ct(o,t,a),Ke(t,e),n&&n.m(e,null),s=!0},p(o,a){o[2].length>0?n?(n.p(o,a),a&4&&st(n,1)):(n=If(o),n.c(),st(n,1),n.m(e,null)):n&&(Je(),ut(n,1,1,()=>{n=null}),Qe()),(!s||a&64&&i!==(i=o[6]))&&M(e,"transform",i)},i(o){s||(st(n),s=!0)},o(o){ut(n),s=!1},d(o){o&<(t),n&&n.d()}}}function pE(r){let t=!!r[1],e,i,s=t&&Sf(r);return{c(){s&&s.c(),e=ur()},m(n,o){s&&s.m(n,o),ct(n,e,o),i=!0},p(n,[o]){o&2&&(t=!!n[1]),t?s?(s.p(n,o),o&2&&st(s,1)):(s=Sf(n),s.c(),st(s,1),s.m(e.parentNode,e)):s&&(Je(),ut(s,1,1,()=>{s=null}),Qe())},i(n){i||(st(s),i=!0)},o(n){ut(s),i=!1},d(n){n&<(e),s&&s.d(n)}}}function mE(r,t,e){let{store:i}=t,{viewer:s}=t,{provider:n}=t,o=[],a;const l=(h,c)=>{e(2,o=[...o.filter(({selectedBy:u})=>u.presenceKey!==h.presenceKey),...(c||[]).map(u=>({annotation:i.getAnnotation(u),selectedBy:h}))].filter(({annotation:u})=>(u||console.warn("Selection event on unknown annotation"),!!u))),a&&i.unobserve(a),a=u=>{const{deleted:d,updated:f}=u.changes,p=new Set((d||[]).map(g=>g.id)),m=o.filter(({annotation:g})=>!p.has(g.id)).map(g=>{const y=(f||[]).find(v=>v.oldValue.id===g.annotation.id);return y?{selectedBy:g.selectedBy,annotation:y.newValue}:g});e(2,o=m)},i.observe(a,{annotations:o.map(u=>u.annotation.id)})};return Fg(()=>{a&&i.unobserve(a)}),r.$$set=h=>{"store"in h&&e(3,i=h.store),"viewer"in h&&e(0,s=h.viewer),"provider"in h&&e(1,n=h.provider)},r.$$.update=()=>{r.$$.dirty&2&&n&&n.on("selectionChange",l)},[s,n,o,i]}class gE extends oe{constructor(t){super(),ne(this,t,mE,pE,Qt,{store:3,viewer:0,provider:1})}}const Pf=(r,t)=>{t==="auto"?r.addHandler("open",e=>{const i=r.world.getItemCount();r.world.getItemAt(i-1).addOnceHandler("fully-loaded-change",n=>{const{fullyLoaded:o}=n;if(o){const a=r.canvas.querySelector("canvas"),l=Eh(a);r.element.setAttribute("data-theme",l)}})}):r.element.setAttribute("data-theme",t)},Rf=(r,t,e)=>(i,s={})=>{const n=typeof i=="string"?i:i.id,o=t.getAnnotation(n);if(!o)return;const a=r.container.getBoundingClientRect(),{padding:l}=s;let[h,c,u,d]=l?Array.isArray(l)?l:[l,l,l,l]:[0,0,0,0];h=h/a.height,c=c/a.width,u=u/a.height,d=d/a.width;const{minX:f,minY:p,maxX:m,maxY:g}=o.target.selector.geometry.bounds,y=m-f,v=g-p,_=f-d*y,x=p-h*v,T=y+(c+d)*y,P=v+(h+u)*v,I=r.viewport.imageToViewportRectangle(_,x,T,P);r.viewport[e](I,s.immediately)},yE=(r,t)=>Rf(r,t,"fitBounds"),_E=(r,t)=>Rf(r,t,"fitBoundsWithConstraints"),vE=(r,t={})=>{const e=Ah(t,{drawingEnabled:!1,drawingMode:th?"drag":"click",pointerSelectAction:ro.EDIT,theme:"light"}),i=wh(e),{hover:s,selection:n,store:o}=i,a=qf(o),l=Kf(i,a,e.adapter,e.autoSave);let h=sp(),c=e.drawingEnabled,u=e.drawingMode;const d=Ih(a,r.element),f=new yw({target:r.element,props:{state:i,viewer:r,style:e.style,filter:void 0}}),p=new gE({target:r.element.querySelector(".openseadragon-canvas"),props:{provider:void 0,store:o,viewer:r}}),m=new eE({target:r.element.querySelector(".openseadragon-canvas"),props:{drawingEnabled:!!c,filter:void 0,preferredDrawingMode:u,state:i,style:e.style,user:h,viewer:r}});f.$on("click",F=>{const{originalEvent:k,annotation:G}=F.detail;G&&!(u==="click"&&c)?n.clickSelect(G.id,k):n.isEmpty()||n.clear()}),r.element.addEventListener("pointerdown",F=>{if(s.current){const k=o.getAnnotation(s.current);l.emit("clickAnnotation",k,F)}}),Pf(r,e.theme);const g=Jf(i,a,e.adapter),y=()=>{f.$destroy(),p.$destroy(),m.$destroy(),d.destroy(),a.destroy()},v=yE(r,o),_=_E(r,o),x=()=>h,T=(F,k,G)=>hh(F,k,G),P=(F,k)=>ih(F,k),I=F=>{if(!Bs(F))throw`No drawing tool named ${F}`;m.$set({toolName:F})},b=F=>{c=F,m.$set({drawingEnabled:c})},E=F=>{f.$set({filter:F}),m.$set({filter:F})},S=F=>{f.$set({style:F}),m.$set({style:F})},D=F=>p.$set({provider:F}),B=F=>Pf(r,F),w=F=>{h=F,m.$set({user:F})},C=F=>f.$set({visible:F});return{...g,destroy:y,fitBounds:v,fitBoundsWithConstraints:_,getUser:x,listDrawingTools:Ms,on:l.on,off:l.off,registerDrawingTool:T,registerShapeEditor:P,setDrawingEnabled:b,setDrawingTool:I,setFilter:E,setPresenceProvider:D,setStyle:S,setTheme:B,setUser:w,setVisible:C,state:i,viewer:r}},xE=op,bE=ro,wE=Gf,EE=Cg,TE=bt,AE=mm;Dt.PointerSelectAction=bE,Dt.ShapeType=TE,Dt.W3CImageFormat=AE,Dt.createBody=wE,Dt.createImageAnnotator=EE,Dt.createOSDAnnotator=vE,Dt.defaultColorProvider=xE,Object.defineProperty(Dt,Symbol.toStringTag,{value:"Module"})});
|
|
1148
1148
|
//# sourceMappingURL=annotorious-openseadragon.js.map
|